UNCDATASQLDIR=%INST_SQLDIR%
DBLOGFILE=$DBMLOGDIR/unc_db_script.log
-PGCTL_WAIT=190
+PGCTL_START_WAIT=333
+PGCTL_STOP_WAIT=180
clm_date() { date +'%y-%m-%d %H:%M:%S.%N'; }
rm -f $PIDFILE
rm -f $lock_file
su -m $SUUSER -c \
- "$PGINST/bin/pg_ctl start -D $PGDATA -w -t $PGCTL_WAIT" \
+ "$PGINST/bin/pg_ctl start -D $PGDATA -w -t $PGCTL_START_WAIT" \
> /dev/null
[ $? -ne 0 ] && return 2
return 0
su -m $SUUSER -c \
"$PGINST/bin/pg_ctl stop -D $PGDATA $stop_mode \
- -t $PGCTL_WAIT" > /dev/null
+ -t $PGCTL_STOP_WAIT" > /dev/null
[ $? -ne 0 ] && return 1
return 0
}
exit 1
fi
+log_output $$ INFO $0 "UNC DB has stopped." $DBLOGFILE
+
exit 0
[UNC_DB_DRIVER]
Decription = PostgreSQL ODBC
Driver = /usr/pgsql-9.1/lib/psqlodbcw.so
+Threading = 2
REQUIRED => ['_GNU_SOURCE'],
IGNORE_ERROR => 1,
CODE => $code});
+
+ $code = <<'OUT';
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/prctl.h>
+
+static int
+change_dumpable(int value)
+{
+ int ret;
+
+ ret = prctl(PR_SET_DUMPABLE, value);
+ if (ret == -1) {
+ printf("NO:prctl(PR_SET_DUMPABLE, %d) failed: %s\n", value,
+ strerror(errno));
+ return 0;
+ }
+ else if (ret != 0) {
+ printf("NO:prctl(PR_SET_DUMPABLE, %d) returned unexpected "
+ "value: %d, %d\n", value, ret);
+ return 0;
+ }
+
+ ret = prctl(PR_GET_DUMPABLE);
+ if (ret != value) {
+ printf("NO:prctl(PR_GET_DUMPABLE) returned unexpected value: "
+ "%d, %d:\n", value, ret);
+ return 0;
+ }
+
+ return 1;
+}
+
+int
+main(int argc, char **argv)
+{
+#if !defined(PR_GET_DUMPABLE)
+ printf("NO:PR_GET_DUMPABLE is not defined.\n");
+#elif !defined(PR_SET_DUMPABLE)
+ printf("NO:PR_SET_DUMPABLE is not defined.\n");
+#else /* PR_GET_DUMPABLE && PR_GET_DUMPABLE */
+
+ /* Disable core dump. */
+ if (change_dumpable(0) == 0) {
+ return 0;
+ }
+
+ /* Enable core dump. */
+ if (change_dumpable(1) == 0) {
+ return 0;
+ }
+
+ printf("OK:yes\n");
+#endif /* !PR_GET_DUMPABLE */
+
+ return 0;
+}
+OUT
+
+ push(@CONFIG_TESTS, {CHECK => 'whether prctl(PR_SET_DUMPABLE) works',
+ DESC => 'Define 1 if prctl(PR_SET_DUMPABLE) is ' .
+ 'supported.',
+ DEFINE => 'PFC_HAVE_PRCTL_DUMPABLE',
+ IGNORE_ERROR => 1,
+ CODE => $code});
}
# Required Google Test version. (1.0 or later)
# Compiler option for strict checking.
use constant GCC_WARN_OPTS =>
- qw(-Wall -Wextra -Wno-clobbered -Wno-unused-parameter);
+ qw(-Wall -Wextra -Wno-clobbered -Wno-unused-parameter
+ -Wno-unused-local-typedefs);
use constant GCC_NO_STRICT_ALIAS => '-fno-strict-aliasing';
const pfc_hostaddr_t *PFC_RESTRICT haddr,
ipc_clchan_t **PFC_RESTRICT chpp,
ipc_elsess_t **PFC_RESTRICT elspp);
+static int ipc_elsess_getsockerror(ipc_elsess_t *elsp, int sock);
static pfc_cptr_t ipc_evhdlr_getkey(pfc_rbnode_t *node);
static pfc_cptr_t ipc_elsess_getkey(pfc_rbnode_t *node);
/*
* static inline int PFC_FATTR_ALWAYS_INLINE
- * ipc_event_gettimeout(pfc_timespec_t *abstime)
- * Determine I/O timeout.
+ * ipc_event_gettimeout_msec(pfc_timespec_t *abstime, uint32_t msec)
+ * Determine absolute I/O timeout from the specified milliseconds.
*
* Calling/Exit State:
* Upon successful completion, an upper limit of I/O time from now is set
* Otherwise error number which indicates the cause of error is returned.
*/
static inline int PFC_FATTR_ALWAYS_INLINE
-ipc_event_gettimeout(pfc_timespec_t *abstime)
+ipc_event_gettimeout_msec(pfc_timespec_t *abstime, uint32_t msec)
{
pfc_timespec_t timeout;
int err;
- pfc_clock_msec2time(&timeout, ipc_event_opts.evopt_timeout);
+ pfc_clock_msec2time(&timeout, msec);
err = pfc_clock_abstime(abstime, &timeout);
if (PFC_EXPECT_FALSE(err != 0)) {
/* This should never happen. */
return err;
}
+/*
+ * static inline int PFC_FATTR_ALWAYS_INLINE
+ * ipc_event_gettimeout(pfc_timespec_t *abstime)
+ * Determine I/O timeout.
+ *
+ * Calling/Exit State:
+ * Upon successful completion, an upper limit of I/O time from now is set
+ * to the buffer pointed by `abstime', and zero is returned.
+ * Otherwise error number which indicates the cause of error is returned.
+ */
+static inline int PFC_FATTR_ALWAYS_INLINE
+ipc_event_gettimeout(pfc_timespec_t *abstime)
+{
+ uint32_t msec = ipc_event_opts.evopt_timeout;
+
+ return ipc_event_gettimeout_msec(abstime, msec);
+}
+
/*
* static inline int PFC_FATTR_ALWAYS_INLINE
* ipc_evctx_gettime(uint64_t *tp)
IPC_ELSESS_LOCK(elsp);
IPC_ELSESS_EPOLL_ASSERT(elsp, ectx);
- if (PFC_EXPECT_FALSE(events & (EPOLLOUT | EPOLLHUP))) {
+ if (PFC_EXPECT_FALSE(events & (EPOLLOUT | EPOLLHUP | EPOLLERR))) {
int err, fd;
/* Remove the session socket from the epoll instance. */
#endif /* PFC_VERBOSE_DEBUG */
IPC_EVCTX_UNLOCK(ectx);
- if (events & EPOLLHUP) {
+ if (events & (EPOLLHUP | EPOLLERR)) {
+ int soerr;
+
+ /* Determine socket level error. */
+ soerr = ipc_elsess_getsockerror(elsp, fd);
+ if (soerr == 0) {
+ /* Session was reset by peer. */
+ soerr = ECONNRESET;
+ }
+
/* Need to update the state of this session. */
- ipc_elsess_setdowncode(elsp, ECONNRESET);
+ ipc_elsess_setdowncode(elsp, soerr);
ipc_evtaskq_post(elsp);
}
return 0;
}
+/*
+ * static int
+ * ipc_elsess_getsockerror(ipc_elsess_t *elsp, int sock)
+ * Get and clear the socket error pending on the given socket.
+ *
+ * Calling/Exit State:
+ * Upon successful completion, a pending socket error number is
+ * returned.
+ * On failure, an error number which indicates the cause of error is
+ * returned.
+ */
+static int
+ipc_elsess_getsockerror(ipc_elsess_t *elsp, int sock)
+{
+ int soerr, ret;
+ socklen_t optlen = sizeof(soerr);
+
+ ret = getsockopt(sock, SOL_SOCKET, SO_ERROR, &soerr, &optlen);
+ if (PFC_EXPECT_FALSE(ret != 0)) {
+ soerr = errno;
+ IPCCLNT_LOG_ERROR("%s: Failed to get socket error: %s",
+ IPC_CLCHAN_NAME(elsp->els_chan),
+ strerror(soerr));
+ if (PFC_EXPECT_FALSE(soerr == 0)) {
+ soerr = EIO;
+ }
+ }
+ else if (soerr != 0) {
+ IPCCLNT_LOG_ERROR("%s: Detected socket error: %s",
+ IPC_CLCHAN_NAME(elsp->els_chan),
+ strerror(soerr));
+ }
+
+ return soerr;
+}
+
+
/*
* static pfc_cptr_t
* ipc_evhdlr_getkey(pfc_rbnode_t *node)
#include "pwd_impl.h"
#include "conf_impl.h"
+#ifdef PFC_HAVE_PRCTL_DUMPABLE
+#include <sys/prctl.h>
+#endif /* PFC_HAVE_PRCTL_DUMPABLE */
+
/*
* Set user ID of the calling process.
*/
* Internal prototypes.
*/
static int cred_loadconf(void);
+static int cred_enable_coredump(void);
/*
* int
* Otherwise error number which indicates the cause of error is returned.
*
* Remarks:
- * pfc_cred_set() always tries to change group ID before user ID.
- * And it returns a non-zero value without reverting group ID if it fails
- * to change user ID of the calling process.
+ * - pfc_cred_set() always tries to change group ID before user ID.
+ * And it returns a non-zero value without reverting group ID if it
+ * fails to change user ID of the calling process.
+ *
+ * - On Linux platform, this function always set 1 to the suid core
+ * dumpable flag for the current process on successful return.
*/
int
pfc_cred_set(uid_t uid, gid_t gid, pfc_bool_t initgrp)
}
}
+ /*
+ * Setting UID or GID may disable the calling process for dumping
+ * core file. So we need to enable explicitly.
+ */
+ err = cred_enable_coredump();
+ if (PFC_EXPECT_FALSE(err != 0)) {
+ goto error;
+ }
+
return 0;
error:
* Otherwise error number which indicates the cause of error is returned.
*
* Remarks:
- * pfc_cred_setbyname() always tries to change group ID before user ID.
- * And it returns a non-zero value without reverting group ID if it fails
- * to change user ID of the calling process.
+ * - pfc_cred_setbyname() always tries to change group ID before user ID.
+ * And it returns a non-zero value without reverting group ID if it
+ * fails to change user ID of the calling process.
+ *
+ * - On Linux platform, this function always set 1 to the suid core
+ * dumpable flag for the current process on successful return.
*/
int
pfc_cred_setbyname(const char *user, const char *group, pfc_bool_t initgrp)
}
}
+ /*
+ * Setting UID or GID may disable the calling process for dumping
+ * core file. So we need to enable explicitly.
+ */
+ err = cred_enable_coredump();
+ if (PFC_EXPECT_FALSE(err != 0)) {
+ goto error;
+ }
+
pfc_pwd_destroyuser(&uinfo);
return 0;
return err;
}
+
+/*
+ * static int
+ * cred_enable_coredump(void)
+ * Allow the calling process to dump core file.
+ *
+ * Calling/Exit State:
+ * Upon successful completion, zero is returned.
+ * Otherwise error number which indicates the cause of error is returned.
+ *
+ * Remarks:
+ * Currently, this function works only on Linux.
+ */
+static int
+cred_enable_coredump(void)
+{
+#ifdef PFC_HAVE_PRCTL_DUMPABLE
+ int ret;
+
+ ret = prctl(PR_SET_DUMPABLE, 1);
+ if (PFC_EXPECT_FALSE(ret != 0)) {
+ PFC_ASSERT(ret == -1);
+ ret = errno;
+ }
+
+ return ret;
+#else /* !PFC_HAVE_PRCTL_DUMPABLE */
+ return 0;
+#endif /* PFC_HAVE_PRCTL_DUMPABLE */
+}
#include <pfc/util.h>
#include <pfc/path.h>
#include <pfc/conf.h>
+#include <pfc/strtoint.h>
#include <conf_impl.h>
#include "test.h"
#include "child.hh"
#include "tmpfile.hh"
#include "random.hh"
+#ifdef PFC_HAVE_PRCTL_DUMPABLE
+#include <sys/prctl.h>
+#include <fcntl.h>
+
+/*
+ * Verify suid dumpable flag for the calling process.
+ */
+#define ASSERT_DUMPABLE(expected) \
+ { \
+ int __value(prctl(PR_GET_DUMPABLE)); \
+ \
+ ASSERT_NE(-1, __value) << "*** ERROR: " << strerror(errno); \
+ ASSERT_EQ(expected, __value); \
+ }
+
+#endif /* PFC_HAVE_PRCTL_DUMPABLE */
+
/*
* This test uses getres[ug]id() and setres[ug]id().
*/
// Change user and group ID.
ASSERT_EQ(0, pfc_cred_set(uid, gid, PFC_FALSE));
+ // Ensure that suid dumpable flag is set.
+ ASSERT_DUMPABLE(1);
+
// Ensure that user and group ID have been changed.
if (uid != UID_UNDEF) {
for (uid_t *u(uids); u < PFC_ARRAY_LIMIT(uids); u++) {
ASSERT_EQ(0, pfc_cred_set(uid, gid, PFC_TRUE))
<< "uid=" << uid << " gid=" << gid;
+ // Ensure that suid dumpable flag is set.
+ ASSERT_DUMPABLE(1);
+
// Ensure that user and group ID have been changed.
uid_t curuids[NUM_CREDID];
gid_t curgids[NUM_CREDID];
ASSERT_EQ(0, pfc_cred_set(UID_UNDEF, GID_UNDEF, PFC_FALSE));
CHECK_RESUGID(uids, gids);
+ ASSERT_DUMPABLE(1);
+
// Unprivileged process can switch user and group ID to effective user and
// group ID respectively.
gid_t egid(gids[1]);
ASSERT_EQ(0, pfc_cred_set(UID_UNDEF, egid, PFC_FALSE));
gid_t g[] = {egid, egid, egid};
CHECK_RESUGID(uids, g);
+ ASSERT_DUMPABLE(1);
uid_t euid(uids[1]);
ASSERT_EQ(0, pfc_cred_set(euid, GID_UNDEF, PFC_FALSE));
CHECK_UGID(euid, egid);
+ ASSERT_DUMPABLE(1);
ASSERT_EQ(0, pfc_cred_set(uids[1], gids[1], PFC_FALSE));
CHECK_UGID(euid, egid);
+ ASSERT_DUMPABLE(1);
// Ensure that unprivileged process can not change user and group ID to
// others.
load_group_list(curgroups);
RETURN_ON_ERROR();
ASSERT_GIDSET_EQ(groups, curgroups);
+
+ // Ensure that suid dumpable flag is set.
+ ASSERT_DUMPABLE(1);
#endif /* DO_CRED_TEST */
}
// This should do nothing.
ASSERT_EQ(0, pfc_cred_set(UID_UNDEF, GID_UNDEF, PFC_TRUE));
CHECK_RESUGID(uids, gids);
+ ASSERT_DUMPABLE(1);
{
gidset_t curgroups;
load_group_list(curgroups);
ASSERT_EQ(0, pfc_cred_set(uid, GID_UNDEF, PFC_TRUE));
uid_t u[] = {uid, uid, uid};
CHECK_RESUGID(u, gids);
+ ASSERT_DUMPABLE(1);
{
gidset_t curgroups;
load_group_list(curgroups);
// Ensure that unprivileged user can not change the group list.
ASSERT_EQ(EPERM, pfc_cred_set(uid + 1, GID_UNDEF, PFC_TRUE));
CHECK_RESUGID(u, gids);
+ ASSERT_DUMPABLE(1);
{
gidset_t curgroups;
load_group_list(curgroups);
RETURN_ON_ERROR();
ASSERT_GIDSET_EQ(groups, curgroups);
}
+
+ // Ensure that suid dumpable flag is set.
+ ASSERT_DUMPABLE(1);
#endif /* DO_CRED_TEST */
}
// Ensure that real group ID can be set as effective group ID.
ASSERT_EQ(0, pfc_cred_set(uids[0], gids[1], PFC_TRUE));
CHECK_UGID(uids[0], gids[1]);
+ ASSERT_DUMPABLE(1);
// Ensure that group list is not changed.
gidset_t curgroups;
load_group_list(curgroups);
RETURN_ON_ERROR();
ASSERT_GIDSET_EQ(groups, curgroups);
+
+ // Ensure that suid dumpable flag is set.
+ ASSERT_DUMPABLE(1);
#endif /* DO_CRED_TEST */
}
// Change user and group ID.
ASSERT_EQ(0, pfc_cred_setbyname(user, group, PFC_FALSE));
+ // Ensure that suid dumpable flag is set.
+ ASSERT_DUMPABLE(1);
+
// Ensure that user and group ID have been changed.
if (user != NULL) {
uid_t uid((requid == UID_UNDEF) ? map->getUID(user) : requid);
// Change user and group ID.
ASSERT_EQ(0, pfc_cred_setbyname(user, group, PFC_TRUE));
+ // Ensure that suid dumpable flag is set.
+ ASSERT_DUMPABLE(1);
+
// Ensure that user and group ID have been changed.
uid_t curuids[NUM_CREDID];
gid_t curgids[NUM_CREDID];
ASSERT_EQ(0, pfc_cred_setbyname(NULL, NULL, PFC_FALSE));
CHECK_RESUGID(uids, gids);
+ // Ensure that suid dumpable flag is set.
+ ASSERT_DUMPABLE(1);
+
// EINVAL test.
ASSERT_EQ(EINVAL, pfc_cred_setbyname("", NULL, PFC_FALSE));
CHECK_RESUGID(uids, gids);
gid_t egid(gids[1]);
gid_t g[] = {egid, egid, egid};
CHECK_RESUGID(uids, g);
+ ASSERT_DUMPABLE(1);
ASSERT_EQ(0, pfc_cred_setbyname(map->pm_euname, NULL, PFC_FALSE));
uid_t euid(uids[1]);
ASSERT_EQ(0, pfc_cred_setbyname(map->pm_euname, map->pm_egname,
PFC_FALSE));
CHECK_UGID(euid, egid);
+ ASSERT_DUMPABLE(1);
// Ensure that unprivileged process can not change user and group ID to
// others.
load_group_list(curgroups);
RETURN_ON_ERROR();
ASSERT_GIDSET_EQ(groups, curgroups);
+
+ // Ensure that suid dumpable flag is set.
+ ASSERT_DUMPABLE(1);
#endif /* DO_CRED_TEST */
}
// This should do nothing.
ASSERT_EQ(0, pfc_cred_setbyname(NULL, NULL, PFC_TRUE));
CHECK_RESUGID(uids, gids);
+ ASSERT_DUMPABLE(1);
{
gidset_t curgroups;
load_group_list(curgroups);
gid_t egid(gids[1]);
gid_t g[] = {egid, egid, egid};
CHECK_RESUGID(uids, g);
+ ASSERT_DUMPABLE(1);
{
gidset_t curgroups;
load_group_list(curgroups);
ASSERT_EQ(0, pfc_cred_setbyname(map->pm_uname, NULL, PFC_TRUE));
uid_t ruid(uids[0]);
CHECK_UGID(ruid, egid);
+ ASSERT_DUMPABLE(1);
{
gidset_t curgroups;
load_group_list(curgroups);
ASSERT_EQ(0, pfc_cred_setbyname(map->pm_uname, map->pm_egname, PFC_TRUE));
CHECK_UGID(ruid, egid);
+ ASSERT_DUMPABLE(1);
{
gidset_t curgroups;
load_group_list(curgroups);
load_group_list(curgroups);
RETURN_ON_ERROR();
ASSERT_GIDSET_EQ(groups, curgroups);
+
+ // Ensure that suid dumpable flag is set.
+ ASSERT_DUMPABLE(1);
#endif /* DO_CRED_TEST */
}
// Ensure that real group ID can be set as effective group ID.
ASSERT_EQ(0, pfc_cred_setbyname(users[0], groups[1], PFC_TRUE));
CHECK_UGID(uids[0], gids[1]);
+ ASSERT_DUMPABLE(1);
// Ensure that group list is not changed.
gidset_t curgroups;
// Ensure that group list is not changed.
ASSERT_GIDSET_EQ(glist, curgroups);
}
+
+ // Ensure that suid dumpable flag is set.
+ ASSERT_DUMPABLE(1);
#endif /* DO_CRED_TEST */
}
/* Invalid IPv4 address. */
pfc_hostaddr_t addr;
int gerr(pfc_hostaddr_init(&addr, AF_INET, "100.200.300.400"));
- if (gerr != EAI_NODATA) {
- ASSERT_EQ(EAI_NONAME, gerr);
- }
+ ASSERT_NE(0, gerr);
gerr = pfc_hostaddr_fromstring(&addr, "100.200.300.400/INET4");
- if (gerr != EAI_NODATA) {
- ASSERT_EQ(EAI_NONAME, gerr);
- }
+ ASSERT_NE(0, gerr);
/* NULL address must be converted into loopback. */
struct in_addr iaddr;
/* Invalid IPv6 address. */
pfc_hostaddr_t addr;
int gerr(pfc_hostaddr_init(&addr, AF_INET6, "::ffff:gggg:hhhh:iiii"));
- if (gerr != EAI_NODATA) {
- ASSERT_EQ(EAI_NONAME, gerr);
- }
+ ASSERT_NE(0, gerr);
gerr = pfc_hostaddr_fromstring(&addr, "::ffff:gggg:hhhh:iiii/INET6");
- if (gerr != EAI_NODATA) {
- ASSERT_EQ(EAI_NONAME, gerr);
- }
+ ASSERT_NE(0, gerr);
/* NULL address must be converted into loopback. */
struct in6_addr iaddr;
const char *name("unknown-host-name::");
pfc_hostaddr_t addr;
int gerr(pfc_hostaddr_init(&addr, AF_UNSPEC, name));
- if (gerr != EAI_NODATA) {
- ASSERT_EQ(EAI_NONAME, gerr);
- }
+ ASSERT_NE(0, gerr);
gerr = pfc_hostaddr_fromstring(&addr, name);
- if (gerr != EAI_NODATA) {
- ASSERT_EQ(EAI_NONAME, gerr);
- }
+ ASSERT_NE(0, gerr);
/* IPv4 address. */
RandomGenerator rand;
CONFIGURE_ARGS += --with-java-libdir=$(JAVA_LIBDIR)
CONFIGURE_ARGS += --with-tomcat-libdir=$(TOMCAT_LIBDIR)
-ifeq ($(strip $(VTN_DEBUG)),)
+ifneq ($(strip $(VTN_DEBUG)),true)
CONFIGURE_ARGS += --disable-debug
-endif # empty(VTN_DEBUG)
+endif # VTN_DEBUG != true
ifneq ($(strip $(VTN_BUILD_ID)),)
CONFIGURE_ARGS += --with-build-id="$(VTN_BUILD_ID)"
<vtn.build.destdir>root</vtn.build.destdir>
<vtn.build.prefix>/usr/local/vtn</vtn.build.prefix>
- <vtn.build.debug>true</vtn.build.debug>
+ <vtn.build.debug>false</vtn.build.debug>
<!-- The number of GNU make jobs -->
<vtn.build.jobs>1</vtn.build.jobs>
UNC_KT_VTN,
UNC_KT_VTN_MAPPING_CONTROLLER,
UNC_KT_VTN_DATAFLOW_CONTROLLER,
- UNC_KT_VTN_FLOWFILTER,
- UNC_KT_VTN_FLOWFILTER_ENTRY,
- UNC_KT_VTN_FLOWFILTER_CONTROLLER,
- UNC_KT_VTN_PATHMAP_ENTRY,
- UNC_KT_VTN_PATHMAP_CONTROLLER,
- UNC_KT_VTN_POLICINGMAP,
- UNC_KT_VTN_POLICINGMAP_CONTROLLER,
UNC_KT_VBRIDGE,
UNC_KT_VBR_VLANMAP,
UNC_KT_VBR_NWMONITOR,
UNC_KT_VBR_FLOWFILTER_ENTRY,
UNC_KT_VBR_IF,
UNC_KT_IF_MACENTRY,
- UNC_KT_VBRIF_FLOWFILTER,
- UNC_KT_VBRIF_FLOWFILTER_ENTRY,
UNC_KT_VBRIF_POLICINGMAP,
UNC_KT_VBRIF_POLICINGMAP_ENTRY,
+ UNC_KT_VBRIF_FLOWFILTER,
+ UNC_KT_VBRIF_FLOWFILTER_ENTRY,
UNC_KT_VROUTER,
+ UNC_KT_VRT_IF,
+ UNC_KT_VRTIF_FLOWFILTER,
+ UNC_KT_VRTIF_FLOWFILTER_ENTRY,
UNC_KT_VRT_IPROUTE,
UNC_KT_DHCPRELAY_SERVER,
UNC_KT_DHCPRELAY_IF,
- UNC_KT_VRT_IF,
UNC_KT_IF_ARPENTRY,
- UNC_KT_VRTIF_FLOWFILTER,
- UNC_KT_VRTIF_FLOWFILTER_ENTRY,
UNC_KT_VUNKNOWN,
UNC_KT_VUNK_IF,
UNC_KT_VTEP,
UNC_KT_VTUNNEL,
UNC_KT_VTUNNEL_IF,
UNC_KT_VLINK,
+ UNC_KT_VTN_POLICINGMAP,
+ UNC_KT_VTN_POLICINGMAP_CONTROLLER,
+ UNC_KT_VTN_FLOWFILTER,
+ UNC_KT_VTN_FLOWFILTER_ENTRY,
+ UNC_KT_VTN_FLOWFILTER_CONTROLLER,
+ UNC_KT_VTN_PATHMAP_ENTRY,
+ UNC_KT_VTN_PATHMAP_CONTROLLER,
/* UPPL: 0x200~0x3ff */
UNC_KT_CONTROLLER = 0x200,
UNC_KT_SWITCH,
UNC_CS_UNKNOWN= 0,
UNC_CS_APPLIED,
UNC_CS_PARTAILLY_APPLIED,
+ UNC_CS_PARTIALLY_APPLIED = UNC_CS_PARTAILLY_APPLIED,
UNC_CS_NOT_APPLIED,
UNC_CS_INVALID,
UNC_CS_NOT_SUPPORTED
UNC_VF_INVALID= 0,
UNC_VF_VALID,
UNC_VF_VALID_NO_VALUE,
- UNC_VF_NOT_SOPPORTED
+ UNC_VF_NOT_SOPPORTED,
+ UNC_VF_NOT_SUPPORTED = UNC_VF_NOT_SOPPORTED,
+ UNC_VF_VALUE_NOT_MODIFIED
} unc_keytype_validflag_t;
/* Controller type enum. */
#include "unc/base.h"
-/* enum for val_vtn structure */
-typedef enum {
- PFCDRV_IDX_DOMAIN_ID_VTN = 0,
- PFCDRV_IDX_DESC_VTN
-} pfcdrv_val_vtn_index_t;
-
/* enum for pfcdrv val vbrif structure */
typedef enum {
PFCDRV_IDX_VAL_VBRIF = 0,
PFCDRV_IDX_VLINK_NAME_VBRIF,
} pfcdrv_val_vbr_if_index_t;
-/* index enumeration for val_vbr_if structure */
-typedef enum {
- PFCDRV_IDX_DESC_VBRI = 0,
- PFCDRV_IDX_ADMIN_STATUS_VBRI,
- PFCDRV_IDX_PM_VBRI
-} pfcdrv_upll_val_vbr_if_index;
-
-/* enum for val port map structure */
-typedef enum {
- PFCDRV_IDX_LOGICAL_PORT_ID_PM = 0,
- PFCDRV_IDX_VLAN_ID_PM,
- PFCDRV_IDX_TAGGED_PM,
-} pfcdrv_upll_val_port_map_index_t;
-
-/* specify vlan tagged */
-typedef enum {
- PFCDRV_VLAN_UNTAGGED = 0,
- PFCDRV_VLAN_TAGGED
-} pfcdrv_vlan_tagged_t;
-
-
/*index enumeration for pfcdrv_val_vbrif structure */
typedef enum {
PFCDRV_IDX_INTERFACE_TYPE = 0,
TC_AUTOSAVE_ENABLED
} TcAutoSaveValue;
+/* Audit operation Status */
+typedef enum {
+ TC_AUDIT_OPER_FAILURE = 0,
+ TC_AUDIT_OPER_SUCCESS
+} TcAuditStatus;
+
#endif // SRC_INCLUDE_UNC_TC_EXTERNAL_TC_SERVICES_H_
* KT_LOGICAL_PORT specific
*/
typedef enum {
- UPPL_LP_SWITCH = 0,
- UPPL_LP_PHYSICAL_PORT,
- UPPL_LP_TRUNK_PORT,
- UPPL_LP_SUBDOMAIN,
- UPPL_LP_TUNNEL_ENDPOINT
+ UPPL_LP_SWITCH = 1,
+ UPPL_LP_PHYSICAL_PORT = 2,
+ UPPL_LP_TRUNK_PORT = 11,
+ UPPL_LP_SUBDOMAIN = 12,
+ UPPL_LP_TUNNEL_ENDPOINT = 13
}UpplLogicalPortType;
typedef enum {
*/
/**
-* @file vnpdriver_include.h
-* @brief VNP Driver common definition.
-* @par History
-* - 2013/01/01 Create.
-*/
+ * @brief VNP Driver common definition.
+ * @file vnpdriver_include.h
+ * @author HCL
+ * @date 2013
+ * @version SYSTEM:UNC 1.0, MODULE:VNPDriver
+ *
+ */
#ifndef _VNPDRIVER_INCLUDE_H_
#define _VNPDRIVER_INCLUDE_H_
/*provides methods to access IPC server session data*/
class TcServerSessionUtils {
public:
+ /*method to set timeout for server session*/
+ static TcUtilRet
+ set_srv_timeout(pfc::core::ipc::ServerSession* ssess,
+ const pfc_timespec_t *timeout);
/*methods to retrieve data*/
static TcUtilRet get_uint32(
pfc::core::ipc::ServerSession* ssess,
static pfc::core::ipc::ClientSession* create_tc_client_session(
std::string channel_name,
uint32_t service_id,
- pfc_ipcconn_t &conn);
+ pfc_ipcconn_t &conn,
+ pfc_bool_t infinite_timeout = PFC_TRUE);
static TcUtilRet tc_session_invoke(pfc::core::ipc::ClientSession* csess,
pfc_ipcresp_t& response);
- static pfc::core::ipc::ClientSession* tc_session_close(
- pfc::core::ipc::ClientSession* csess,
- pfc_ipcconn_t conn);
+ static TcUtilRet tc_session_close(pfc::core::ipc::ClientSession** csess,
+ pfc_ipcconn_t conn);
/*methods to retrieve data*/
static TcUtilRet get_uint32(
pfc::core::ipc::ClientSession* csess,
/*
* Copyright (c) 2012-2013 NEC Corporation
* All rights reserved.
- *
+ *
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this
* distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
file_ = file_name;
line_ = line_no;
func_ = fn_name;
+#ifdef UPLL_PERF_TIME
+ pfc_clock_gettime(&start);
+#endif
pfc_log_trace("%s:%d: Entering function %s", file_, line_, func_);
}
inline ~LogFuncTrace() {
+#ifdef UPLL_PERF_TIME
+ pfc_timespec_t end;
+ pfc_clock_gettime(&end);
+ pfc_timespec_sub(&end, &start);
+ uint64_t elapsed(pfc_clock_time2msec(&end));
+ pfc_log_trace("%s:%d: Leaving function %s: CONSUMED :%" PFC_PFMT_u64 ": ms"
+ , file_, line_, func_, elapsed);
+#else
pfc_log_trace("%s:%d: Leaving function %s", file_, line_, func_);
+#endif
}
+#ifdef UPLL_PERF_TIME
+ pfc_timespec_t start;
+#endif
const char *file_, *func_;
int line_;
};
LogFuncTrace func_trace___(__FILE__, __LINE__, __FUNCTION__);
#else
#define UPLL_FUNC_TRACE
+#endif // PFC_VERBOSE_DEBUG
+
+class LogFuncTracePerf {
+ public:
+ inline LogFuncTracePerf(const char *file_name, int line_no, const char *fn_name) {
+ file_ = file_name;
+ line_ = line_no;
+ func_ = fn_name;
+ pfc_clock_gettime(&start);
+ pfc_log_info("%s:%d: Entering function %s", file_, line_, func_);
+ }
+ inline ~LogFuncTracePerf() {
+ pfc_timespec_t end;
+ pfc_clock_gettime(&end);
+ pfc_timespec_sub(&end, &start);
+ uint64_t elapsed(pfc_clock_time2msec(&end));
+ pfc_log_info("%s:%d: Leaving function %s: CONSUMED :%" PFC_PFMT_u64 ": ms"
+ , file_, line_, func_, elapsed);
+ }
+ pfc_timespec_t start;
+ const char *file_, *func_;
+ int line_;
+};
+#if 0
+#define UPLL_FUNC_TRACE_PERF \
+ LogFuncTracePerf func_trace_perf___(__FILE__, __LINE__, __FUNCTION__);
+#else
+#define UPLL_FUNC_TRACE_PERF
#endif
#endif // UPLL_LOG_HH_
# UPPL_LP_PHYSICAL_PORT
# UPPL_LP_TRUNK_PORT
# UPPL_LP_SUBDOMAIN
+ # UPPL_LP_TUNNEL_ENDPOINT
UINT8 switch_id[256];
UINT8 physical_port_id[32];
UINT8 oper_down_criteria; # supported values are
# distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
#
-#
-# define UID/ROLE/PWD.
-#2ROLES can be defined.(oper|admin)
-# At most 1000 UID/ROLE/PWD can be defined.
-#
-# username:role:MD5(password)
-# fox example:
-oper:oper:25e4ee4e9229397b6b17776bfceaf8e7
-admin:admin:25e4ee4e9229397b6b17776bfceaf8e7
+# Value struct for DELETE operation of VTUNNEL and VTUNNEL_IF
+
+ipc_struct vnpdrv_val_vtunnel {
+ UINT8 valid[1];
+ UINT32 label;
+};
+
+ipc_struct vnpdrv_val_vtunnel_if {
+ UINT8 valid[2];
+ UINT32 label;
+ UINT16 vlan_id;
+};
final JsonObject requestBody) throws VtnServiceException {
try {
VtnServiceUtil.trimParamValues(requestBody);
+ /*
+ * remove the parameters which contains empty strings
+ */
+ if(VtnServiceConsts.POST.equals(requestType)){
+ VtnServiceUtil.removeEmptyParamas(requestBody);
+ }
resource.getValidator().validate(requestType, requestBody);
} catch (final Exception exception) {
resource.createErrorInfo(UncCommonEnum.UncResultCode.UNC_CLIENT_ERROR
# distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
#
-# IPC Server's Channel adresse's
+# IPC Server's Channel name
uncd=uncd
phynwd=phynwd
lgcnwd=lgcnwd
public static final String STRUCT_METHOD_PREFIX = "get";
public static final String RESOURCES = "org/opendaylight/vtn/javaapi/resources";
public static final String TEST_RESOURCES = "org.opendaylight.vtn.javaapi.resources";
- public static final String GUI_LOG_FILEPATH = "gui_log_path";
- public static final String API_LOG_FILEPATH = "api_log_path";
- public static final String DEFAULT_LOG_FILEPATH = "default_log_path";
- public static final String LOG_NAME = "vtn-javaapi";
public static final String CONN_POOL_SIZE = "max_ipc_conn_pool_size_";
public static final String MAX_REP_DEFAULT = "max_repetition_default";
public static final String DOT_REGEX = "\\.";
public static final String MAC_ADD_REGEX = "^([0-9a-fA-F]{4}(\\.[0-9a-fA-F]{4}){2})$";
- public static final String ETH_TYPE_REGEX = "0[xX][0-9a-fA-F]{4}";
+ public static final String ETH_TYPE_REGEX = "0[xX][0-9a-fA-F]{1,4}";
public static final String IPV4_ADD_REGEX = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$";
public static final String IPV6_ADD_REGEX = "^[a-f0-9]{1,4}:([a-f0-9]{0,4}:){2,6}[a-f0-9]{1,4}$";
public static final String INTEGER_REGEX = "\\d+";
public static final String ALARM_REGEX="^(\\d{1,19})$";
public static final String SLASH = "/";
public static final String EMPTY_STRING = "";
- public static final String COMMA = "";
+ public static final String COMMA = ",";
public static final String SPACE = " ";
public static final String EQUAL = "=";
public static final String DOT = ".";
public static final String WEB_API = "WEB-API";
public static final String UNC_GUI = "UNC-GUI";
public static final String ZERO = "0";
+ public static final String INCORRECT_METHOD_INVOCATION = "Incorrect method invocation";
+
+ public static final int DEFAULT_NUMBER = 0;
+ public static final String DEFAULT_IP = "0.0.0.0";
+ public static final String DEFAULT_IPV6 = "0000:0000:0000:0000:0000:0000:0000:0000";
+ public static final String DEFAULT_MAC = "0000.0000.0000";
+
}
public static final String SESS_TYPE = "sess_type";
public static final String LOGIN_TIME = "login_time";
public static final String USER_TYPE = "user_type";
+ public static final String SESS_MODE = "sess_mode";
+ public static final String CONFIG_STATUS = "config_status";
public static final String IP_ADDR = "ip_addr";
public static final String MAC_ETH_TYPE="mac_eth_type";
public static final String DST_IP="dst_ip";
public static final String USESS_USER_WEB_OPER = "UNC_WEB_OPER";
public static final String USESS_IPC_TIMESPEC = "usess_ipc_timespec";
public static final String TV_SEC = "tv_sec";
+ public static final String MAJOR = "major";
+ public static final String MINOR = "minor";
+ public static final String REVISION = "revision";
+ public static final String PATCHLEVEL = "patchlevel";
+ public static final String ENABLE_PASSWORD = "enable_passwd";
+
+ public static final String GET_FLOW_LIST_RESPONSE = "getFlowListResponse";
+ public static final String GET_FLOW_LIST_ENTRY_RESPONSE = "getFlowListEntryResponse";
+ public static final String GET_VTN_RESPONSE = "getVtnResponse";
+ public static final String GET_VTN_FLOW_FILETER_ENTRY_RESPONSE = "getVtnFlowFilterEntryResponse";
+ public static final String GET_VBYPASS_INTERFACE_RESPONSE ="getVBypassInterfaceResponse";
+ public static final String GET_VBYPASS_RESPONSE = "getVBypassResponse";
+ public static final String GET_VBRIDGE_RESPONSE = "getVBridgeResponse";
+ public static final String GET_SWITCH_RESPONSE = "getSwitchResponse";
+ public static final String GET_DOMAIN_RESPONSE = "getDomainResponse";
+ public static final String GET_VBRIDGE_FLOW_FILTER_ENTRY_RESPONSE = "getVBridgeFlowFilterEntryResponse";
+ public static final String GET_VBRIDGE_VLANMAP_RESPONSE = "getVlanMapResponse";
+ public static final String GET_LINK_RESPONSE = "getLinkResponse";
+ public static final String GET_CONTROLLER_RESPONSE = "getControllerResponse";
+ public static final String GET_VBRIDGE_INTERFACE_RESPONSE = "getVBridgeInterfaceResponse";
+ public static final String GET_VROUTER_RESPONSE = "getVRouterResponse";
+ public static final String GET_VROUTER_INTERFACE_RESPONSE = "getVRouterInterfaceResponse";
+ public static final String GET_DHCP_RELAY_IF_RESPONSE = "getDhcpRelayInterfaceResponse";
+ public static final String GET_DHCP_RELAY_SERVER_RESPONSE = "getDHCPRelayServerResponse";
+ public static final String GET_STATIC_IPROUTE_SERVER_RESPONSE = "getStaticIpRouteResponse";
+ public static final String GET_VTUNNEL_RESPONSE = "getVTunnelResponse";
+ public static final String GET_VBRIDGE_INTERFACE_FLOW_FILTER_ENTRY_RESPONSE = "getVBridgeInterfaceFlowFilterEntryResponse";
+ public static final String GET_VROUTER_INTERFACE_FLOW_FILTER_ENTRY_RESPONSE = "getVRouterInterfaceFlowFilterEntryResponse";
+ public static final String GET_VTEP_RESPONSE = "getVtepResponse";
+ public static final String GET_BOUNDARY_RESPONSE = "getBoundaryResponse";
+ public static final String GET_VTEP_INTERFACE_RESPONSE = "getVTepInterfaceResponse";
+ public static final String GET_VTUNNEL_INTERFACE_RESPONSE = "getVTunnelInterfaceResourceResponse";
+ public static final String GET_VLINKS_RESPONSE = "getVLinkResponse";
+ public static final String GET_SWITCH_PORT_INTERFACE_RESPONSE = "getSwitchPortResponse";
+ public static final String GET_DOMAIN_LOGICAL_PORT_RESPONSE = "getDomainLogicalPortResponse";
}
-
// Host Address
public static final String HOST_ADDR = "hostaddr";
- public static final String NETMASK = "netmask";
+ public static final String PREFIX = "prefix";
// L2 Domain
public static final String L2DOMAINS = "l2domains";
public static final String SERVER = "server";
public static final String SERVERS = "servers";
- // vUnknown
- public static final String VUNKNOWN = "vbypass";
- public static final String VUKNAME = "vbypass_name";
- public static final String VUNKNOWNS = "vbypasses";
+ // vByPass
+ public static final String VBYPASS = "vbypass";
+ public static final String VBYPASS_NAME = "vbypass_name";
+ public static final String VBYPASSES = "vbypasses";
// vTep
public static final String VTEP = "vtep";
public static final String INFO = "info";
public static final String USERTYPE = "usertype";
public static final String LOGINTIME = "login_time";
+ public static final String CONFIGSTATUS = "configstatus";
// validation requirements
public static final String APIVERSION = "api_version";
public static final BigInteger BIG_VAL0 = new BigInteger("0");
public static final BigInteger BIG_VAL = new BigInteger("4294967295");
public static final BigInteger BIG_VAL_18446744073709551615 = new BigInteger("18446744073709551615");
+ public static final BigInteger BIG_VAL_9999999999999999999 = new BigInteger("9999999999999999999");
public static final long LONG_VAL_0 = 0L;
+ public static final long LONG_VAL_1 = 1L;
public static final long LONG_VAL_4294967295 = 4294967295L;
public static final String LOGIN_NAME = "login_name";
public static final String LOGIN_TIME = "login_time";
public static final String SWITCHID_NOT_FOUND= "switchIdNotFound";
public static final String PORTID_NOT_FOUND = "portIdNotFound";
public static final String VNP = "vnp";
+ public static final String DIFF = "diff";
+ public static final String DIFF_STATUS = "diff_status";
public static final String TWO = "2";
+ public static final String DEL = "del";
+ public static final String V = "V";
+ //Constatnts for portmap under overlay
+ public static final String VTUNNEL_INTERFACE_PORTMAP = "VTunnelInterfacePortMap";
+ public static final String VTEP_INTERFACE_PORTMAP = "VTepInterfacePortMap";
+ public static final String VBRIDGE_INTERFACE_PORTMAP = "VBridgeInterfacePortMap";
}
* The Class PackageScan. Scans the resource classes for VTN Service
*/
public final class PackageScan {
+ /**
+ * Pairs of REST resource path and associated resource class.
+ */
+ private final HashMap<String, Class<?>> _cachedClasses =
+ new HashMap<String, Class<?>>();
- private static final Logger LOG = Logger.getLogger(PackageScan.class
- .getName());
-
- private static final Map<String, Class<?>> CACHEDRESOURCES = new HashMap<String, Class<?>>();
-
- private PackageScan() {
+ /**
+ * Private class that keeps a single global instance of
+ * {@code PackageScan}.
+ */
+ private final static class PackageScanHolder {
+ /**
+ * A single global instance of {@code PackageScan}.
+ */
+ private final static PackageScan _instance = new PackageScan();
}
/**
- * Load resources.
+ * Return a single global instance of {@code PackageScan}.
*
- * @throws VtnServiceException
- * the vtn service exception
+ * @return A single global instance of {@code PackageScan}.
*/
- public static void loadResources() throws VtnServiceException {
+ public final static PackageScan getInstance() {
+ return PackageScanHolder._instance;
+ }
- LOG.trace("Start PackageScan#loadResources()");
+ /**
+ * Create a single global instance of {@code PackageScan}.
+ *
+ * @throws IllegalStateException
+ * Failed to load properties file that defines resource clas
+ses.
+ */
+ private PackageScan() {
+ Logger log = Logger.getLogger(PackageScan.class.getName());
+ log.trace("Start PackageScan#PackageScan()");
- List<String> classNameList = null;
// create the list of resource classes from a given package
+ String jar = VtnServiceInitManager.
+ getConfigurationMap().
+ getConfigValue(VtnServiceConsts.JAVAAPI_JARPATH);
+ List<String> classNameList;
try {
- //classNameList = getClassNameList(VtnServiceConsts.TEST_RESOURCES);
- classNameList = getFromJARFile(
- VtnServiceInitManager.getConfigurationMap().getConfigValue(
- VtnServiceConsts.JAVAAPI_JARPATH),
- VtnServiceConsts.RESOURCES);
-
- if (classNameList == null) {
- return;
+ classNameList =
+ getFromJARFile(jar, VtnServiceConsts.RESOURCES);
+ } catch (FileNotFoundException e) {
+ String msg = "Java API JAR file not found: " + jar;
+ log.error(msg + ": " + e);
+ throw new IllegalStateException(msg, e);
+ } catch (IOException e) {
+ String msg = "Failed to load Java API JAR file: " + jar;
+ log.error(msg + ": " + e);
+ throw new IllegalStateException(msg, e);
+ }
+
+ for (final String className : classNameList) {
+ // check the class validity for each resource
+ // class
+ Class<?> cls = null;
+ try {
+ cls = Class.forName(className);
+ } catch (ClassNotFoundException e) {
+ log.warning("Failed to load resource class: " +
+ className + ": " + e);
+ continue;
+ }
+
+ // continue if resource class is not derived
+ // from AbstractClass
+ if (cls == null ||
+ AbstractResource.class != cls.getSuperclass()) {
+ continue;
+ }
+
+ final UNCVtnService annotion =
+ cls.getAnnotation(UNCVtnService.class);
+ if (annotion == null) {
+ continue;
}
- for (final String className : classNameList) {
- Class<?> classResource = null;
-
- // check the class validity for each resource class
- classResource = Class.forName(className);
-
- // continue if resource class is not derived from AbstractClass
- if (classResource == null
- || AbstractResource.class != classResource
- .getSuperclass()) {
- continue;
- }
-
- final UNCVtnService annotion = classResource
- .getAnnotation(UNCVtnService.class);
- if (annotion == null) {
- continue;
- }
-
- // map the annotation path with resource class
- final String path = annotion.path();
- if (path != null
- && !VtnServiceConsts.EMPTY_STRING.equals(path.trim())) {
- CACHEDRESOURCES.put(path, classResource);
- }
+ // map the annotation path with resource class
+ final String path = annotion.path();
+ if (path != null && path.trim().length() != 0) {
+ _cachedClasses.put(path, cls);
}
- } catch (final Exception e) {
- VtnServiceInitManager
- .getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
- UncJavaAPIErrorCode.RESOURCE_LOAD_ERROR
- .getErrorCode(),
- UncJavaAPIErrorCode.RESOURCE_LOAD_ERROR
- .getErrorMessage(), e);
}
- LOG.trace("Complete PackageScan#loadResources()");
+ log.trace("Complete PackageScan#PackageScan()");
}
/**
* @return list of class names
* @throws FileNotFoundException
* @throws IOException
- * @throws ClassNotFoundException
*/
- static List<String> getFromJARFile(final String jar,
- final String packageName) throws FileNotFoundException,
- IOException, ClassNotFoundException {
+ private List<String> getFromJARFile(final String jar,
+ final String packageName)
+ throws FileNotFoundException, IOException {
final List<String> classes = new ArrayList<String>();
- final JarInputStream jarFile = new JarInputStream(new FileInputStream(
- jar));
- JarEntry jarEntry;
+ final JarInputStream jarFile =
+ new JarInputStream(new FileInputStream(jar));
+
/*
* iterate for all the class files in Jar file
*/
- do {
- jarEntry = jarFile.getNextJarEntry();
- if (jarEntry != null) {
- String className = jarEntry.getName();
- if (className.endsWith(VtnServiceConsts.CLASS_EXT)) {
- className = stripFilenameExtension(className);
- if (className.startsWith(packageName)) {
- classes.add(className.replaceAll(
- VtnServiceConsts.SLASH, VtnServiceConsts.DOT));
- }
- }
+ for (JarEntry jarEntry = jarFile.getNextJarEntry();
+ jarEntry != null; jarEntry = jarFile.getNextJarEntry()) {
+ String className = jarEntry.getName();
+ if (!className.endsWith(VtnServiceConsts.CLASS_EXT)) {
+ continue;
}
- } while (jarEntry != null);
+
+ className = stripFilenameExtension(className);
+ if (className.startsWith(packageName)) {
+ classes.add(className.replaceAll
+ (VtnServiceConsts.SLASH,
+ VtnServiceConsts.DOT));
+ }
+ }
jarFile.close();
return classes;
}
/**
- * Stripping the class name
+ * Return a resource class associated with the given path.
*
- * @param className
- * @return
+ * @param path A path.
+ * @return A {@code Class} instance associated with the given path
+ * if found. {@code null} if not found.
*/
- public static String stripFilenameExtension(final String className) {
- final String str = className.substring(0, className.lastIndexOf('.'));
- return str;
+ public Class<?> getResourceClass(String path) {
+ return _cachedClasses.get(path);
}
/**
- * Gets the class name list.
+ * Return a string array which contains all REST paths.
*
- * @param packageName
- * the package name
- * @return the class name list
- * @throws VtnServiceException
- * the vtn service exception
+ * @return A string array which contains all REST paths.
*/
- private static List<String> getClassNameList(final String packageName)
- throws VtnServiceException {
-
- LOG.trace("Start PackageScan#getClassNameList()");
- LOG.debug("Input value for package name : " + packageName);
- final List<String> classNames = new ArrayList<String>();
- final ClassLoader loader = Thread.currentThread()
- .getContextClassLoader();
- try {
- // load all the classes from given package
- final String resourceName = packageName.replaceAll(
- VtnServiceConsts.DOT_REGEX, VtnServiceConsts.SLASH);
- final URL url = loader.getResource(resourceName);
- final File urlFile = new File(url.toURI());
- final File[] files = urlFile.listFiles();
- // get class name of each file present in package
- for (final File f : files) {
- getClassName(packageName, f, classNames);
- }
- } catch (final URISyntaxException e) {
- VtnServiceInitManager
- .getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
- UncJavaAPIErrorCode.INIT_ERROR.getErrorCode(),
- UncJavaAPIErrorCode.INIT_ERROR.getErrorCode(), e);
- }
- LOG.debug("Class list:" + classNames.toArray());
- LOG.trace("Complete PackageScan#getClassNameList()");
- return classNames;
- }
+ public String[] getAllPaths() {
+ String[] array = new String[_cachedClasses.size()];
- /**
- * Gets the class name.
- *
- * @param packageName
- * the package name
- * @param packageFile
- * the package file
- * @param list
- * the list
- * @return the class name
- */
- private static void getClassName(final String packageName,
- final File packageFile, final List<String> list) {
-
- LOG.trace("Start PackageScan#getClassName()");
- if (packageFile.isFile()) {
- list.add(packageName
- + VtnServiceConsts.DOT
- + packageFile.getName().replace(VtnServiceConsts.CLASS_EXT,
- VtnServiceConsts.EMPTY_STRING));
- } else {
- final File[] files = packageFile.listFiles();
- final String tmPackageName = packageName + VtnServiceConsts.DOT
- + packageFile.getName();
- for (final File file : files) {
- getClassName(tmPackageName, file, list);
- }
- }
- LOG.trace("Complete PackageScan#getClassName()");
+ return _cachedClasses.keySet().toArray(array);
}
/**
- * Gets the cached resources.
+ * Stripping the class name
*
- * @return the cached resources
+ * @param className
+ * @return
*/
- public static Map<String, Class<?>> getCachedResources() {
- LOG.trace("Return from PackageScan#getCachedResources()");
- return CACHEDRESOURCES;
+ private static String stripFilenameExtension(final String className) {
+ return className.substring(0, className.lastIndexOf('.'));
}
}
.getContextClassLoader(), ipcConnPool);
// load the resources
- PackageScan.loadResources();
+ PackageScan.getInstance();
} catch (final VtnServiceException e) {
LOG.error("VtnService Initialization Failed : " + e);
throw new VtnServiceInitFailException(
.getResponse(VtnServiceConsts.IPC_RESUL_CODE_INDEX));
LOG.debug("Result code received: " + resultCode);
final int keyType = requestPacket.getKeyType().intValue();
- if (keyType >= UncCommonEnum.MIN_LOGICAL_KEYTYPE
- && keyType <= UncCommonEnum.MAX_LOGICAL_KEYTYPE
- && Integer.parseInt(resultCode) == VtnServiceConsts.UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- noSuchInstanceFlag = true;
- LOG.debug("No such instance case for UPLL");
- } else if (keyType >= UncCommonEnum.MIN_PHYSICAL_KEYTYPE
- && keyType <= UncCommonEnum.MAX_PHYSICAL_KEYTYPE
- && Integer.parseInt(resultCode) == VtnServiceConsts.UPPL_RC_ERR_NO_SUCH_INSTANCE) {
- noSuchInstanceFlag = true;
- LOG.debug("No such instance case for UPPL");
- } else {
- LOG.debug(" Either Key Type does not exists or operation is not success");
- }
+
+ if(requestPacket.getOperation().intValue() == UncOperationEnum.UNC_OP_READ.ordinal()
+ || requestPacket.getOperation().intValue() == UncOperationEnum.UNC_OP_READ_SIBLING_BEGIN.ordinal()
+ || requestPacket.getOperation().intValue() == UncOperationEnum.UNC_OP_READ_SIBLING.ordinal()
+ || requestPacket.getOperation().intValue() == UncOperationEnum.UNC_OP_READ_SIBLING_COUNT.ordinal()){
+ if (keyType >= UncCommonEnum.MIN_LOGICAL_KEYTYPE
+ && keyType <= UncCommonEnum.MAX_LOGICAL_KEYTYPE
+ && Integer.parseInt(resultCode) == VtnServiceConsts.UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ noSuchInstanceFlag = true;
+ LOG.debug("No such instance case for UPLL");
+ } else if (keyType >= UncCommonEnum.MIN_PHYSICAL_KEYTYPE
+ && keyType <= UncCommonEnum.MAX_PHYSICAL_KEYTYPE
+ && Integer.parseInt(resultCode) == VtnServiceConsts.UPPL_RC_ERR_NO_SUCH_INSTANCE) {
+ noSuchInstanceFlag = true;
+ LOG.debug("No such instance case for UPPL");
+ } else {
+ LOG.debug(" Either Key Type does not exists or operation is not success");
+ }
+ }
+
// if return code is not success, then create the error Json for
// received result code
if (null == resultCode
LOG.trace("Start getValVtnStruct");
final IpcStruct valVtnStruct = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.ValVtn.getValue());
-
if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.VTN)
&& requestBody.getAsJsonObject(VtnServiceJsonConsts.VTN).has(
*/
public IpcStruct getValFlowListEntryStruct(final JsonObject requestBody,
final List<String> uriParameters) {
-
LOG.trace("Start getValFlowListEntryStruct");
final IpcStruct valFlowListEntryStruct = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.ValFlowListEntry.getValue());
-
if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.FLOWLISTENTRY)) {
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.MACDSTADDR)) {
+ JsonObject flowListEntry = requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY);
+ if (flowListEntry.has(VtnServiceJsonConsts.MACDSTADDR)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_MAC_DST_FLE
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
.ordinal()));
-
IpcDataUnitWrapper.setMacAddress(
valFlowListEntryStruct,
- VtnServiceIpcConsts.MACDST,
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.MACDSTADDR)
- .getAsString());
+ VtnServiceIpcConsts.MACDST,flowListEntry.get(VtnServiceJsonConsts.MACDSTADDR).getAsString(),
+ UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_MAC_DST_FLE.ordinal());
} else {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.MACSRCADDR)) {
+ if (flowListEntry.has(VtnServiceJsonConsts.MACSRCADDR)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_MAC_SRC_FLE
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
.ordinal()));
-
IpcDataUnitWrapper.setMacAddress(
valFlowListEntryStruct,
VtnServiceIpcConsts.MACSRC,
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.MACSRCADDR)
- .getAsString());
+ flowListEntry.get(VtnServiceJsonConsts.MACSRCADDR).getAsString(),
+ UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_MAC_SRC_FLE.ordinal());
} else {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.MACETHERTYPE)) {
+ if (flowListEntry.has(VtnServiceJsonConsts.MACETHERTYPE)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_MAC_ETH_TYPE_FLE
.ordinal()));
valFlowListEntryStruct.set(
VtnServiceIpcConsts.MAC_ETH_TYPE,
- IpcDataUnitWrapper.setIpcUint16HexaValue(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.MACETHERTYPE)
- .getAsString()));
+ IpcDataUnitWrapper.setIpcUint16HexaValue(flowListEntry.get(VtnServiceJsonConsts.MACETHERTYPE).getAsString(),
+ valFlowListEntryStruct, UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_MAC_ETH_TYPE_FLE.ordinal()));
LOG.debug("macethertype:"
- + requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.MACETHERTYPE)
+ + flowListEntry.get(VtnServiceJsonConsts.MACETHERTYPE)
.getAsString());
} else {
valFlowListEntryStruct
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.IPDSTADDR)) {
+ if (flowListEntry.has(VtnServiceJsonConsts.IPDSTADDR)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_DST_IP_FLE
.ordinal()));
valFlowListEntryStruct.set(
VtnServiceIpcConsts.DST_IP,
- IpcDataUnitWrapper.setIpcInet4AddressValue(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.IPDSTADDR)
- .getAsString()));
+ IpcDataUnitWrapper.setIpcInet4AddressValue(flowListEntry.get(VtnServiceJsonConsts.IPDSTADDR).getAsString(),
+ valFlowListEntryStruct, UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_DST_IP_FLE.ordinal()));
} else {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.IPDSTADDRPREFIX)) {
+ if (flowListEntry.has(VtnServiceJsonConsts.IPDSTADDRPREFIX)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_DST_IP_PREFIX_FLE
.ordinal()));
valFlowListEntryStruct.set(
VtnServiceIpcConsts.DST_IP_PREFIXLEN,
- IpcDataUnitWrapper.setIpcUint8Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.IPDSTADDRPREFIX)
- .getAsString()));
+ IpcDataUnitWrapper.setIpcUint8Value(flowListEntry.get(VtnServiceJsonConsts.IPDSTADDRPREFIX).getAsString(),
+ valFlowListEntryStruct, UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_DST_IP_PREFIX_FLE.ordinal()));
} else {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.IPSRCADDR)) {
+ if (flowListEntry.has(VtnServiceJsonConsts.IPSRCADDR)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_SRC_IP_FLE
.ordinal()));
valFlowListEntryStruct.set(
VtnServiceIpcConsts.SRC_IP,
- IpcDataUnitWrapper.setIpcInet4AddressValue(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.IPSRCADDR)
- .getAsString()));
+ IpcDataUnitWrapper.setIpcInet4AddressValue(flowListEntry.get(VtnServiceJsonConsts.IPSRCADDR).getAsString(),
+ valFlowListEntryStruct, UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_SRC_IP_FLE.ordinal()));
} else {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.IPSRCADDRPREFIX)) {
+ if (flowListEntry.has(VtnServiceJsonConsts.IPSRCADDRPREFIX)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_SRC_IP_PREFIX_FLE
.ordinal()));
valFlowListEntryStruct.set(
VtnServiceIpcConsts.SRC_IP_PREFIXLEN,
- IpcDataUnitWrapper.setIpcUint8Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.IPSRCADDRPREFIX)
- .getAsString()));
+ IpcDataUnitWrapper.setIpcUint8Value(flowListEntry.get(VtnServiceJsonConsts.IPSRCADDRPREFIX).getAsString(),
+ valFlowListEntryStruct, UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_SRC_IP_PREFIX_FLE.ordinal()));
} else {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.MACVLANPRIORITY)) {
+ if (flowListEntry.has(VtnServiceJsonConsts.MACVLANPRIORITY)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_VLAN_PRIORITY_FLE
.ordinal()));
valFlowListEntryStruct.set(
VtnServiceIpcConsts.VLAN_PRIORITY,
- IpcDataUnitWrapper.setIpcUint8Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.MACVLANPRIORITY)
- .getAsString()));
+ IpcDataUnitWrapper.setIpcUint8Value(flowListEntry.get(VtnServiceJsonConsts.MACVLANPRIORITY).getAsString(),
+ valFlowListEntryStruct, UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_VLAN_PRIORITY_FLE.ordinal()));
} else {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.IPV6DSTADDR)) {
+ if (flowListEntry.has(VtnServiceJsonConsts.IPV6DSTADDR)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_DST_IP_V6_FLE
.ordinal()));
valFlowListEntryStruct.set(
VtnServiceIpcConsts.DST_IPV6,
- IpcDataUnitWrapper.setIpcInet6AddressValue(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.IPV6DSTADDR)
- .getAsString()));
+ IpcDataUnitWrapper.setIpcInet6AddressValue(flowListEntry.get(VtnServiceJsonConsts.IPV6DSTADDR).getAsString(),
+ valFlowListEntryStruct, UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_DST_IP_V6_FLE.ordinal()));
} else {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.IPV6DSTADDRPREFIX)) {
+ if (flowListEntry.has(VtnServiceJsonConsts.IPV6DSTADDRPREFIX)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_DST_IP_V6_PREFIX_FLE
.ordinal()));
valFlowListEntryStruct.set(
VtnServiceIpcConsts.DST_IPV6_PREFIXLEN,
- IpcDataUnitWrapper.setIpcUint8Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.IPV6DSTADDRPREFIX)
- .getAsString()));
+ IpcDataUnitWrapper.setIpcUint8Value(flowListEntry.get(VtnServiceJsonConsts.IPV6DSTADDRPREFIX).getAsString(),
+ valFlowListEntryStruct, UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_DST_IP_V6_PREFIX_FLE.ordinal()));
} else {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.IPV6SRCADDR)) {
+ if (flowListEntry.has(VtnServiceJsonConsts.IPV6SRCADDR)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_SRC_IP_V6_FLE
.ordinal()));
valFlowListEntryStruct.set(
VtnServiceIpcConsts.SRC_IPV6,
- IpcDataUnitWrapper.setIpcInet6AddressValue(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.IPV6SRCADDR)
- .getAsString()));
+ IpcDataUnitWrapper.setIpcInet6AddressValue(flowListEntry.get(VtnServiceJsonConsts.IPV6SRCADDR).getAsString(),
+ valFlowListEntryStruct, UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_SRC_IP_V6_FLE.ordinal()));
LOG.debug("ipv6srcaddr:"
- + requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.IPV6SRCADDR)
+ + flowListEntry.get(VtnServiceJsonConsts.IPV6SRCADDR)
.getAsString());
} else {
valFlowListEntryStruct
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.IPV6DSTADDRPREFIX)) {
+ if (flowListEntry.has(VtnServiceJsonConsts.IPV6SRCADDRPREFIX)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_SRC_IP_V6_PREFIX_FLE
.ordinal()));
valFlowListEntryStruct.set(
VtnServiceIpcConsts.SRC_IPV6_PREFIXLEN,
- IpcDataUnitWrapper.setIpcUint8Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.IPV6DSTADDRPREFIX)
- .getAsString()));
+ IpcDataUnitWrapper.setIpcUint8Value(flowListEntry.get(VtnServiceJsonConsts.IPV6SRCADDRPREFIX).getAsString(),
+ valFlowListEntryStruct, UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_SRC_IP_V6_PREFIX_FLE.ordinal()));
} else {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.IPPROTO)) {
+ if (flowListEntry.has(VtnServiceJsonConsts.IPPROTO)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_IP_PROTOCOL_FLE
.ordinal()));
valFlowListEntryStruct.set(
VtnServiceIpcConsts.IP_PROTO,
- IpcDataUnitWrapper.setIpcUint8Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.IPPROTO)
- .getAsString()));
+ IpcDataUnitWrapper.setIpcUint8Value(flowListEntry.get(VtnServiceJsonConsts.IPPROTO).getAsString(),
+ valFlowListEntryStruct, UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_IP_PROTOCOL_FLE.ordinal()));
} else {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.IPDSCP)) {
+ if (flowListEntry.has(VtnServiceJsonConsts.IPDSCP)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_IP_DSCP_FLE
valFlowListEntryStruct
.set(VtnServiceIpcConsts.IP_DSCP,
IpcDataUnitWrapper
- .setIpcUint8Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.IPDSCP)
- .getAsString()));
+ .setIpcUint8Value(flowListEntry.get(VtnServiceJsonConsts.IPDSCP).getAsString(),
+ valFlowListEntryStruct, UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_IP_DSCP_FLE.ordinal()));
} else {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.L4DSTPORT)) {
+ if (flowListEntry.has(VtnServiceJsonConsts.L4DSTPORT)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_L4_DST_PORT_FLE
.ordinal()));
valFlowListEntryStruct.set(
VtnServiceIpcConsts.L4_DST_PORT,
- IpcDataUnitWrapper.setIpcUint16Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.L4DSTPORT)
- .getAsString()));
+ IpcDataUnitWrapper.setIpcUint16Value(flowListEntry.get(VtnServiceJsonConsts.L4DSTPORT).getAsString(),
+ valFlowListEntryStruct, UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_L4_DST_PORT_FLE.ordinal()));
} else {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.L4DSTENDPORT)) {
+ if (flowListEntry.has(VtnServiceJsonConsts.L4DSTENDPORT)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_L4_DST_PORT_ENDPT_FLE
.ordinal()));
valFlowListEntryStruct.set(
VtnServiceIpcConsts.L4_DST_PORT_ENDPT,
- IpcDataUnitWrapper.setIpcUint16Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.L4DSTENDPORT)
- .getAsString()));
+ IpcDataUnitWrapper.setIpcUint16Value(flowListEntry.get(VtnServiceJsonConsts.L4DSTENDPORT).getAsString(),
+ valFlowListEntryStruct, UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_L4_DST_PORT_ENDPT_FLE.ordinal()));
} else {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.L4SRCPORT)) {
+ if (flowListEntry.has(VtnServiceJsonConsts.L4SRCPORT)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_L4_SRC_PORT_FLE
.ordinal()));
valFlowListEntryStruct.set(
VtnServiceIpcConsts.L4_SRC_PORT,
- IpcDataUnitWrapper.setIpcUint16Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.L4SRCPORT)
- .getAsString()));
+ IpcDataUnitWrapper.setIpcUint16Value(flowListEntry.get(VtnServiceJsonConsts.L4SRCPORT).getAsString(),
+ valFlowListEntryStruct, UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_L4_SRC_PORT_FLE.ordinal()));
} else {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.L4SRCENDPORT)) {
+ if (flowListEntry.has(VtnServiceJsonConsts.L4SRCENDPORT)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_L4_SRC_PORT_ENDPT_FLE
.ordinal()));
valFlowListEntryStruct.set(
VtnServiceIpcConsts.L4_SRC_PORT_ENDPT,
- IpcDataUnitWrapper.setIpcUint16Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.L4SRCENDPORT)
- .getAsString()));
+ IpcDataUnitWrapper.setIpcUint16Value(flowListEntry.get(VtnServiceJsonConsts.L4SRCENDPORT).getAsString(),
+ valFlowListEntryStruct, UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_L4_SRC_PORT_ENDPT_FLE.ordinal()));
} else {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.ICMPTYPENUM)) {
+ if (flowListEntry.has(VtnServiceJsonConsts.ICMPTYPENUM)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_ICMP_TYPE_FLE
.ordinal()));
valFlowListEntryStruct.set(
VtnServiceIpcConsts.ICMP_TYPE,
- IpcDataUnitWrapper.setIpcUint8Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.ICMPTYPENUM)
- .getAsString()));
+ IpcDataUnitWrapper.setIpcUint8Value(flowListEntry.get(VtnServiceJsonConsts.ICMPTYPENUM).getAsString(),
+ valFlowListEntryStruct, UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_ICMP_TYPE_FLE.ordinal()));
} else {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.ICMPCODENUM)) {
+ if (flowListEntry.has(VtnServiceJsonConsts.ICMPCODENUM)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_ICMP_CODE_FLE
.ordinal()));
valFlowListEntryStruct.set(
VtnServiceIpcConsts.ICMP_CODE,
- IpcDataUnitWrapper.setIpcUint8Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.ICMPCODENUM)
- .getAsString()));
+ IpcDataUnitWrapper.setIpcUint8Value(flowListEntry.get(VtnServiceJsonConsts.ICMPCODENUM).getAsString(),
+ valFlowListEntryStruct, UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_ICMP_CODE_FLE.ordinal()));
} else {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.IPV6ICMPTYPENUM)) {
+ if (flowListEntry.has(VtnServiceJsonConsts.IPV6ICMPTYPENUM)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_ICMP_V6_TYPE_FLE
.ordinal()));
valFlowListEntryStruct.set(
VtnServiceIpcConsts.ICMPV6_TYPE,
- IpcDataUnitWrapper.setIpcUint8Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.IPV6ICMPTYPENUM)
- .getAsString()));
+ IpcDataUnitWrapper.setIpcUint8Value(flowListEntry.get(VtnServiceJsonConsts.IPV6ICMPTYPENUM).getAsString(),
+ valFlowListEntryStruct, UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_ICMP_V6_TYPE_FLE.ordinal()));
} else {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWLISTENTRY)
- .has(VtnServiceJsonConsts.IPV6ICMPCODENUM)) {
+ if (flowListEntry.has(VtnServiceJsonConsts.IPV6ICMPCODENUM)) {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_ICMP_V6_CODE_FLE
.ordinal()));
valFlowListEntryStruct.set(
VtnServiceIpcConsts.ICMPV6_CODE,
- IpcDataUnitWrapper.setIpcUint8Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWLISTENTRY)
- .get(VtnServiceJsonConsts.IPV6ICMPCODENUM)
- .getAsString()));
+ IpcDataUnitWrapper.setIpcUint8Value(flowListEntry.get(VtnServiceJsonConsts.IPV6ICMPCODENUM).getAsString(),
+ valFlowListEntryStruct, UncStructIndexEnum.ValFlowlistEntryIndex.UPLL_IDX_ICMP_V6_CODE_FLE.ordinal()));
} else {
valFlowListEntryStruct
.set(VtnServiceIpcConsts.VALID,
}
LOG.info("Value Structure: " + valFlowListEntryStruct.toString());
LOG.trace("Complete getValFlowListEntryStruct");
-
return valFlowListEntryStruct;
}
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
.ordinal()));
- ValVTunnelIfStruct
- .set(VtnServiceJsonConsts.DESCRIPTION,
- IpcDataUnitWrapper
- .setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.INTERFACE)
- .get(VtnServiceJsonConsts.DESCRIPTION)
- .getAsString(),
- ValVTunnelIfStruct,
- UncStructIndexEnum.ValVtunnelIfIndex.UPLL_IDX_DESC_VTNL_IF
- .ordinal()));
+ ValVTunnelIfStruct.set(VtnServiceJsonConsts.DESCRIPTION,
+ IpcDataUnitWrapper
+ .setIpcUint8ArrayValue(requestBody
+ .getAsJsonObject(
+ VtnServiceJsonConsts.INTERFACE)
+ .get(VtnServiceJsonConsts.DESCRIPTION)
+ .getAsString()));
} else {
ValVTunnelIfStruct
.set(VtnServiceIpcConsts.VALID,
ValVTunnelIfStruct
.set(VtnServiceJsonConsts.ADMIN_STATUS,
IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_ENABLE
- .getValue()));
+ .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_ENABLE.getValue(),
+ ValVTunnelIfStruct, UncStructIndexEnum.ValVtunnelIfIndex.UPLL_IDX_ADMIN_ST_VTNL_IF.ordinal()));
} else {
ValVTunnelIfStruct
.set(VtnServiceJsonConsts.ADMIN_STATUS,
IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_DISABLE
- .getValue()));
+ .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_DISABLE.getValue(),
+ ValVTunnelIfStruct, UncStructIndexEnum.ValVtunnelIfIndex.UPLL_IDX_ADMIN_ST_VTNL_IF.ordinal()));
}
LOG.debug("adminstatus:"
+ requestBody
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
+ } else if (requestBody != null
+ && requestBody.has(VtnServiceJsonConsts.PORTMAP)) {
+ IpcStruct valPortMapStruct = null;
+ ValVTunnelIfStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVtunnelIfIndex.UPLL_IDX_ADMIN_ST_VTNL_IF
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()));
+ ValVTunnelIfStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVtunnelIfIndex.UPLL_IDX_DESC_VTNL_IF
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()));
+ ValVTunnelIfStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVtunnelIfIndex.UPLL_IDX_PORT_MAP_VTNL_IF
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
+ .ordinal()));
+ valPortMapStruct = getValPortMapStruct(requestBody, uriParameters);
+ ValVTunnelIfStruct.set(VtnServiceIpcConsts.PORTMAP,
+ valPortMapStruct);
+ } else if (requestBody == null) {
+ final IpcStruct valPortMapStruct = IpcDataUnitWrapper
+ .setIpcStructValue(UncStructEnum.ValPortMap.getValue());
+ ValVTunnelIfStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVtunnelIfIndex.UPLL_IDX_PORT_MAP_VTNL_IF
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID_NO_VALUE
+ .ordinal()));
+ ValVTunnelIfStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVtunnelIfIndex.UPLL_IDX_DESC_VTNL_IF
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()));
+ ValVTunnelIfStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVtunnelIfIndex.UPLL_IDX_ADMIN_ST_VTNL_IF
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()));
+ valPortMapStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValPortMapIndex.UPLL_IDX_LOGICAL_PORT_ID_PM
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID_NO_VALUE
+ .ordinal()));
+ valPortMapStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValPortMapIndex.UPLL_IDX_VLAN_ID_PM
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID_NO_VALUE
+ .ordinal()));
+ valPortMapStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValPortMapIndex.UPLL_IDX_TAGGED_PM
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID_NO_VALUE
+ .ordinal()));
+ ValVTunnelIfStruct.set(VtnServiceIpcConsts.PORTMAP,
+ valPortMapStruct);
} else {
LOG.warning("request body and uri parameters are not correct for getValVtunnelIfStruct");
}
*/
public IpcStruct getKeyVlinkStruct(final JsonObject requestBody,
final List<String> uriParameters) {
-
LOG.trace("Start getKeyVlinkStruct");
final IpcStruct KeyVlinkStruct = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.KeyVlink.getValue());
LOG.trace("Start getValVlinkStruct");
final IpcStruct ValVlinkStruct = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.ValVlink.getValue());
-
if (requestBody != null && requestBody.has(VtnServiceJsonConsts.VLINK)) {
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VLINK).has(
- VtnServiceJsonConsts.ADMINSTATUS)) {
+ JsonObject vLink = requestBody.getAsJsonObject(VtnServiceJsonConsts.VLINK);
+ if (vLink.has(VtnServiceJsonConsts.ADMINSTATUS)) {
ValVlinkStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_ADMIN_STATUS_VLNK
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
.ordinal()));
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VLINK)
- .get(VtnServiceJsonConsts.ADMINSTATUS).getAsString()
+ if (vLink.get(VtnServiceJsonConsts.ADMINSTATUS).getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.ENABLE)) {
ValVlinkStruct
.set(VtnServiceJsonConsts.ADMIN_STATUS,
IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_ENABLE
- .getValue()));
+ .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_ENABLE.getValue(),
+ ValVlinkStruct,UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_ADMIN_STATUS_VLNK.ordinal()));
} else {
ValVlinkStruct
.set(VtnServiceJsonConsts.ADMIN_STATUS,
IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_DISABLE
- .getValue()));
+ .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_DISABLE.getValue(),
+ ValVlinkStruct,UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_ADMIN_STATUS_VLNK.ordinal()));
}
LOG.debug("adminstatus:"
- + requestBody
- .getAsJsonObject(VtnServiceJsonConsts.VLINK)
- .get(VtnServiceJsonConsts.ADMINSTATUS)
+ + vLink.get(VtnServiceJsonConsts.ADMINSTATUS)
.getAsString());
} else {
ValVlinkStruct
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VLINK).has(
- VtnServiceJsonConsts.VNODE1NAME)) {
+ if (vLink.has(VtnServiceJsonConsts.VNODE1NAME)) {
ValVlinkStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VNODE1_NAME_VLNK
.set(VtnServiceJsonConsts.VNODE1NAME,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VLINK)
- .get(VtnServiceJsonConsts.VNODE1NAME)
+ vLink.get(VtnServiceJsonConsts.VNODE1NAME)
.getAsString(),
ValVlinkStruct,
UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VNODE1_NAME_VLNK
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VLINK).has(
- VtnServiceJsonConsts.IF1NAME)) {
+ if (vLink.has(VtnServiceJsonConsts.IF1NAME)) {
ValVlinkStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VNODE1_IF_NAME_VLNK
.set(VtnServiceIpcConsts.VNODE1IFNAME,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VLINK)
- .get(VtnServiceJsonConsts.IF1NAME)
+ vLink.get(VtnServiceJsonConsts.IF1NAME)
.getAsString(),
ValVlinkStruct,
UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VNODE1_IF_NAME_VLNK
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VLINK).has(
- VtnServiceJsonConsts.VNODE2NAME)) {
+ if (vLink.has(VtnServiceJsonConsts.VNODE2NAME)) {
ValVlinkStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VNODE2_NAME_VLNK
.set(VtnServiceJsonConsts.VNODE2NAME,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VLINK)
- .get(VtnServiceJsonConsts.VNODE2NAME)
+ vLink.get(VtnServiceJsonConsts.VNODE2NAME)
.getAsString(),
ValVlinkStruct,
UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VNODE2_NAME_VLNK
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VLINK).has(
- VtnServiceJsonConsts.IF2NAME)) {
+ if (vLink.has(VtnServiceJsonConsts.IF2NAME)) {
ValVlinkStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VNODE2_IF_NAME_VLNK
.set(VtnServiceIpcConsts.VNODE2IFNAME,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VLINK)
- .get(VtnServiceJsonConsts.IF2NAME)
+ vLink.get(VtnServiceJsonConsts.IF2NAME)
.getAsString(),
ValVlinkStruct,
UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VNODE2_IF_NAME_VLNK
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VLINK).has(
- VtnServiceJsonConsts.BOUNDARYMAP)
- && requestBody.getAsJsonObject(VtnServiceJsonConsts.VLINK)
- .getAsJsonObject(VtnServiceJsonConsts.BOUNDARYMAP)
- .has(VtnServiceJsonConsts.BOUNDARYID)) {
- ValVlinkStruct
- .set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_BOUNDARY_NAME_VLNK
- .ordinal(),
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
- .ordinal()));
- ValVlinkStruct
- .set(VtnServiceIpcConsts.BOUNDARY_NAME,
- IpcDataUnitWrapper
- .setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VLINK)
- .getAsJsonObject(
- VtnServiceJsonConsts.BOUNDARYMAP)
- .get(VtnServiceJsonConsts.BOUNDARYID)
- .getAsString(),
- ValVlinkStruct,
- UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_BOUNDARY_NAME_VLNK
- .ordinal()));
- } else {
- ValVlinkStruct
- .set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_BOUNDARY_NAME_VLNK
- .ordinal(),
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
- .ordinal()));
- }
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VLINK).has(
- VtnServiceJsonConsts.BOUNDARYMAP)
- && requestBody.getAsJsonObject(VtnServiceJsonConsts.VLINK)
- .getAsJsonObject(VtnServiceJsonConsts.BOUNDARYMAP)
- .has(VtnServiceJsonConsts.VLANID)) {
- LOG.debug("Valid VLAN ID Case");
- ValVlinkStruct
- .set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VLAN_ID_VLNK
- .ordinal(),
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
- .ordinal()));
- ValVlinkStruct
- .set(VtnServiceJsonConsts.VLANID,
- IpcDataUnitWrapper
- .setIpcUint16Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VLINK)
- .getAsJsonObject(
- VtnServiceJsonConsts.BOUNDARYMAP)
- .get(VtnServiceJsonConsts.VLANID)
- .getAsString()));
- } else if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VLINK)
- .has(VtnServiceJsonConsts.BOUNDARYMAP)
- && requestBody.getAsJsonObject(VtnServiceJsonConsts.VLINK)
- .getAsJsonObject(VtnServiceJsonConsts.BOUNDARYMAP)
- .has(VtnServiceJsonConsts.NO_VLAN_ID)) {
- LOG.debug("Valid NO VLAN ID Case");
- ValVlinkStruct
- .set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VLAN_ID_VLNK
- .ordinal(),
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
- .ordinal()));
- ValVlinkStruct
- .set(VtnServiceJsonConsts.VLANID,
- IpcDataUnitWrapper
- .setIpcUint16HexaValue(VtnServiceIpcConsts.VLAN_ID_DEFAULT_VALUE));
- } else {
- LOG.debug("InValid VLAN ID Case");
- ValVlinkStruct
- .set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VLAN_ID_VLNK
- .ordinal(),
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
+ if (vLink.has(VtnServiceJsonConsts.BOUNDARYMAP)){
+ JsonObject boundaryMap = vLink.getAsJsonObject(VtnServiceJsonConsts.BOUNDARYMAP);
+ if (boundaryMap.has(VtnServiceJsonConsts.BOUNDARYID)) {
+ ValVlinkStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_BOUNDARY_NAME_VLNK
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
+ .ordinal()));
+ ValVlinkStruct
+ .set(VtnServiceIpcConsts.BOUNDARY_NAME,
+ IpcDataUnitWrapper
+ .setIpcUint8ArrayValue(
+ boundaryMap
+ .get(VtnServiceJsonConsts.BOUNDARYID)
+ .getAsString(),
+ ValVlinkStruct,
+ UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_BOUNDARY_NAME_VLNK
+ .ordinal()));
+ } else {
+ ValVlinkStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_BOUNDARY_NAME_VLNK
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()));
+ }
+ if (boundaryMap.has(VtnServiceJsonConsts.VLANID)) {
+ LOG.debug("Valid VLAN ID Case");
+ ValVlinkStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VLAN_ID_VLNK
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
+ .ordinal()));
+ ValVlinkStruct.set(VtnServiceJsonConsts.VLANID,
+ IpcDataUnitWrapper.setIpcUint16Value(boundaryMap.get(VtnServiceJsonConsts.VLANID).getAsString(),
+ ValVlinkStruct, UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VLAN_ID_VLNK.ordinal()));
+ } else if (boundaryMap.has(VtnServiceJsonConsts.NO_VLAN_ID)) {
+ LOG.debug("Valid NO VLAN ID Case");
+ ValVlinkStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VLAN_ID_VLNK
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
+ .ordinal()));
+ ValVlinkStruct
+ .set(VtnServiceJsonConsts.VLANID,
+ IpcDataUnitWrapper
+ .setIpcUint16HexaValue(VtnServiceIpcConsts.VLAN_ID_DEFAULT_VALUE,
+ ValVlinkStruct, UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VLAN_ID_VLNK.ordinal()));
+ } else {
+ LOG.debug("InValid VLAN ID Case");
+ ValVlinkStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VLAN_ID_VLNK
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()));
+ }
+ LOG.debug("VLAN ID Valid Bit : "
+ + ValVlinkStruct
+ .getByte(
+ VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VLAN_ID_VLNK
.ordinal()));
}
- LOG.debug("VLAN ID Valid Bit : "
- + ValVlinkStruct
- .getByte(
- VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VLAN_ID_VLNK
- .ordinal()));
-
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VLINK).has(
- VtnServiceJsonConsts.DESCRIPTION)) {
+ if (vLink.has(VtnServiceJsonConsts.DESCRIPTION)) {
ValVlinkStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_DESCRIPTION_VLNK
.set(VtnServiceIpcConsts.DESCRIPTION,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VLINK)
- .get(VtnServiceJsonConsts.DESCRIPTION)
+ vLink.get(
+ VtnServiceJsonConsts.DESCRIPTION)
.getAsString(),
ValVlinkStruct,
UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_DESCRIPTION_VLNK
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
} else {
LOG.warning("request body and uri parameters are not correct for getValVlinkStruct");
}
public IpcStruct getKeyVtepStruct(final JsonObject requestBody,
final List<String> uriParameters) {
LOG.trace("Start getKeyVtepStruct");
-
final IpcStruct KeyVtepStruct = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.KeyVtep.getValue());
IpcStruct keyVtnStruct = null;
* cs_attr[23]; UINT8 description[128]; UINT8 controller_id[32]; UINT8
* domain_id[32] };
*/
-
LOG.trace("Start getValVtepStruct");
final IpcStruct ValVtepStruct = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.ValVtep.getValue());
-
if (requestBody != null && requestBody.has(VtnServiceJsonConsts.VTEP)) {
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VTEP).has(
- VtnServiceJsonConsts.DESCRIPTION)) {
+ JsonObject vtep = requestBody.getAsJsonObject(VtnServiceJsonConsts.VTEP);
+ if (vtep.has(VtnServiceJsonConsts.DESCRIPTION)) {
ValVtepStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVtepVndex.UPLL_IDX_DESC_VTEP
.set(VtnServiceJsonConsts.DESCRIPTION,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VTEP)
- .get(VtnServiceJsonConsts.DESCRIPTION)
+ vtep.get(VtnServiceJsonConsts.DESCRIPTION)
.getAsString(),
ValVtepStruct,
UncStructIndexEnum.ValVtepVndex.UPLL_IDX_DESC_VTEP
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VTEP).has(
- VtnServiceJsonConsts.CONTROLLERID)) {
+ if (vtep.has(VtnServiceJsonConsts.CONTROLLERID)) {
ValVtepStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVtepVndex.UPLL_IDX_CONTROLLER_ID_VTEP
.set(VtnServiceJsonConsts.CONTROLLERID,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VTEP)
- .get(VtnServiceJsonConsts.CONTROLLERID)
+ vtep.get(VtnServiceJsonConsts.CONTROLLERID)
.getAsString(),
ValVtepStruct,
UncStructIndexEnum.ValVtepVndex.UPLL_IDX_CONTROLLER_ID_VTEP
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VTEP).has(
- VtnServiceJsonConsts.DOMAINID)) {
+ if (vtep.has(VtnServiceJsonConsts.DOMAINID)) {
ValVtepStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVtepVndex.UPLL_IDX_DOMAIN_ID_VTEP
.set(VtnServiceJsonConsts.DOMAINID,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VTEP)
- .get(VtnServiceJsonConsts.DOMAINID)
+ vtep.get(VtnServiceJsonConsts.DOMAINID)
.getAsString(),
ValVtepStruct,
UncStructIndexEnum.ValVtepVndex.UPLL_IDX_DOMAIN_ID_VTEP
}
LOG.info("Value Structure: " + ValVtepStruct.toString());
LOG.trace("Complete getValVtepStruct");
-
return ValVtepStruct;
}
LOG.trace("Start getValVtepIfStruct");
final IpcStruct ValVtepIfStruct = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.ValVtepIf.getValue());
-
if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.INTERFACE)) {
if (requestBody.getAsJsonObject(VtnServiceJsonConsts.INTERFACE)
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
.ordinal()));
- ValVtepIfStruct
- .set(VtnServiceJsonConsts.DESCRIPTION,
- IpcDataUnitWrapper
- .setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.INTERFACE)
- .get(VtnServiceJsonConsts.DESCRIPTION)
- .getAsString(),
- ValVtepIfStruct,
- UncStructIndexEnum.ValVtepIfIndex.UPLL_IDX_DESC_VTEPI
- .ordinal()));
+ ValVtepIfStruct.set(VtnServiceJsonConsts.DESCRIPTION,
+ IpcDataUnitWrapper
+ .setIpcUint8ArrayValue(requestBody
+ .getAsJsonObject(
+ VtnServiceJsonConsts.INTERFACE)
+ .get(VtnServiceJsonConsts.DESCRIPTION)
+ .getAsString()));
} else {
ValVtepIfStruct
.set(VtnServiceIpcConsts.VALID,
ValVtepIfStruct
.set(VtnServiceJsonConsts.ADMIN_STATUS,
IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_ENABLE
- .getValue()));
+ .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_ENABLE.getValue(),
+ ValVtepIfStruct,UncStructIndexEnum.ValVtepIfIndex.UPLL_IDX_ADMIN_ST_VTEPI.ordinal()));
} else {
ValVtepIfStruct
.set(VtnServiceJsonConsts.ADMIN_STATUS,
IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_DISABLE
- .getValue()));
+ .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_DISABLE.getValue(),
+ ValVtepIfStruct,UncStructIndexEnum.ValVtepIfIndex.UPLL_IDX_ADMIN_ST_VTEPI.ordinal()));
}
LOG.debug("adminstatus:"
+ requestBody
}
ValVtepIfStruct
.set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValVtepIfIndex.UPLL_IDX_PORT_MAP_VTEPI
+ UncStructIndexEnum.ValVtepIfIndex.UPLL_IDX_PORT_MAP_VTEPI
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()));
+ } else if (requestBody != null
+ && requestBody.has(VtnServiceJsonConsts.PORTMAP)) {
+ IpcStruct valPortMapStruct = null;
+ ValVtepIfStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVtepIfIndex.UPLL_IDX_ADMIN_ST_VTEPI
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()));
+ ValVtepIfStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVtepIfIndex.UPLL_IDX_DESC_VTEPI
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()));
+ ValVtepIfStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVtepIfIndex.UPLL_IDX_PORT_MAP_VTEPI
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
+ .ordinal()));
+ valPortMapStruct = getValPortMapStruct(requestBody, uriParameters);
+ ValVtepIfStruct.set(VtnServiceIpcConsts.PORTMAP, valPortMapStruct);
+ } else if (requestBody == null) {
+ final IpcStruct valPortMapStruct = IpcDataUnitWrapper
+ .setIpcStructValue(UncStructEnum.ValPortMap.getValue());
+ ValVtepIfStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVtepIfIndex.UPLL_IDX_PORT_MAP_VTEPI
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID_NO_VALUE
+ .ordinal()));
+ ValVtepIfStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVtepIfIndex.UPLL_IDX_DESC_VTEPI
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()));
+ ValVtepIfStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVtepIfIndex.UPLL_IDX_ADMIN_ST_VTEPI
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()));
+ valPortMapStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValPortMapIndex.UPLL_IDX_LOGICAL_PORT_ID_PM
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID_NO_VALUE
+ .ordinal()));
+ valPortMapStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValPortMapIndex.UPLL_IDX_VLAN_ID_PM
.ordinal(),
IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID_NO_VALUE
+ .ordinal()));
+ valPortMapStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValPortMapIndex.UPLL_IDX_TAGGED_PM
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID_NO_VALUE
.ordinal()));
+ ValVtepIfStruct.set(VtnServiceIpcConsts.PORTMAP, valPortMapStruct);
} else {
LOG.warning("request body and uri parameters are not correct for getValVtepIfStruct");
}
LOG.info("Value Structure: " + ValVtepIfStruct.toString());
LOG.trace("Complete getValVtepIfStruct");
+
return ValVtepIfStruct;
}
LOG.trace("Start getKeyVrtIfFlowFilterStruct");
final IpcStruct KeyVrtIfFlowFilterStruct = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.KeyVrtIfFlowFilter.getValue());
-
IpcStruct KeyVrtIfStruct = null;
if (uriParameters != null
&& uriParameters.size() >= UncIndexEnum.THREE.ordinal()) {
KeyVrtIfStruct = getKeyVrtIfStruct(requestBody,
uriParameters.subList(0, 3));
-
}
KeyVrtIfFlowFilterStruct.set(VtnServiceIpcConsts.KEYVBRIF,
KeyVrtIfStruct);
-
if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.FLOWFILTER)
&& ((JsonObject) requestBody
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.FlowfilterDirection.UPLL_FLOWFILTER_DIR_IN
.ordinal()));
-
} else {
keyVbrIfFlowFilterStruct
.setIpcStructValue(UncStructEnum.ValVbr.getValue());
if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.VBRIDGE)) {
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VBRIDGE).has(
- VtnServiceJsonConsts.CONTROLLERID)) {
+ JsonObject vBridge = requestBody.getAsJsonObject(VtnServiceJsonConsts.VBRIDGE);
+ if (vBridge.has(VtnServiceJsonConsts.CONTROLLERID)) {
valVbrStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVbrIndex.UPLL_IDX_CONTROLLER_ID_VBR
.set(VtnServiceJsonConsts.CONTROLLERID,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VBRIDGE)
- .get(VtnServiceJsonConsts.CONTROLLERID)
+ vBridge.get(VtnServiceJsonConsts.CONTROLLERID)
.getAsString(),
valVbrStruct,
UncStructIndexEnum.ValVbrIndex.UPLL_IDX_CONTROLLER_ID_VBR
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VBRIDGE).has(
- VtnServiceJsonConsts.DOMAINID)) {
+ if (vBridge.has(VtnServiceJsonConsts.DOMAINID)) {
valVbrStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVbrIndex.UPLL_IDX_DOMAIN_ID_VBR
.set(VtnServiceJsonConsts.DOMAINID,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VBRIDGE)
- .get(VtnServiceJsonConsts.DOMAINID)
+ vBridge.get(VtnServiceJsonConsts.DOMAINID)
.getAsString(),
valVbrStruct,
UncStructIndexEnum.ValVbrIndex.UPLL_IDX_DOMAIN_ID_VBR
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VBRIDGE).has(
- VtnServiceJsonConsts.DESCRIPTION)) {
+ if (vBridge.has(VtnServiceJsonConsts.DESCRIPTION)) {
valVbrStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVbrIndex.UPLL_IDX_DESC_VBR
.set(VtnServiceJsonConsts.VBRDESCRIPTION,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VBRIDGE)
- .get(VtnServiceJsonConsts.DESCRIPTION)
+ vBridge.get(VtnServiceJsonConsts.DESCRIPTION)
.getAsString(),
valVbrStruct,
UncStructIndexEnum.ValVbrIndex.UPLL_IDX_DESC_VBR
.ordinal()));
} else if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.IPADDRESS)) {
+ JsonObject ipAddress = requestBody.getAsJsonObject(VtnServiceJsonConsts.IPADDRESS);
valVbrStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVbrIndex.UPLL_IDX_CONTROLLER_ID_VBR
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.IPADDRESS)
- .has(VtnServiceJsonConsts.IPADDR)) {
+ if (ipAddress.has(VtnServiceJsonConsts.IPADDR)) {
valVbrStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVbrIndex.UPLL_IDX_HOST_ADDR_VBR
.ordinal()));
valVbrStruct.set(VtnServiceIpcConsts.HOST_ADDR,
IpcDataUnitWrapper
- .setIpcInet4AddressValue(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.IPADDRESS)
- .get(VtnServiceJsonConsts.IPADDR)
- .getAsString()));
+ .setIpcInet4AddressValue(ipAddress.get(VtnServiceJsonConsts.IPADDR).getAsString(),
+ valVbrStruct, UncStructIndexEnum.ValVbrIndex.UPLL_IDX_HOST_ADDR_VBR.ordinal()));
} else {
valVbrStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.IPADDRESS)
- .has(VtnServiceJsonConsts.NETMASK)) {
+ if (ipAddress.has(VtnServiceJsonConsts.PREFIX)) {
valVbrStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVbrIndex.UPLL_IDX_HOST_ADDR_PREFIXLEN_VBR
.ordinal()));
valVbrStruct.set(VtnServiceIpcConsts.HOST_ADDR_PREFIXLEN,
IpcDataUnitWrapper
- .setIpcUint8Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.IPADDRESS)
- .get(VtnServiceJsonConsts.NETMASK)
- .getAsString()));
+ .setIpcUint8Value(ipAddress.get(VtnServiceJsonConsts.PREFIX).getAsString(),
+ valVbrStruct, UncStructIndexEnum.ValVbrIndex.UPLL_IDX_HOST_ADDR_PREFIXLEN_VBR.ordinal()));
} else {
valVbrStruct
.set(VtnServiceIpcConsts.VALID,
uriParameters.subList(0, 2));
}
keyVlanMapStruct.set(VtnServiceIpcConsts.VBRKEY, keyVbrStruct);
-
if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.VLANMAP)
&& uriParameters.size() < UncIndexEnum.THREE.ordinal()) {
*/
public IpcStruct getValVlanMapStruct(final JsonObject requestBody,
final List<String> uriParameters) {
-
final IpcStruct valVlanMapStruct = new IpcStruct(
UncStructEnum.ValVlanMap.getValue());
/*
VtnServiceJsonConsts.VLANID,
IpcDataUnitWrapper.setIpcUint16Value(requestBody
.getAsJsonObject(VtnServiceJsonConsts.VLANMAP)
- .get(VtnServiceJsonConsts.VLANID).getAsString()));
+ .get(VtnServiceJsonConsts.VLANID).getAsString(),
+ valVlanMapStruct, UncStructIndexEnum.ValVlanMapIndex.UPLL_IDX_VLAN_ID_VM.ordinal()));
} else if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.VLANMAP)
&& requestBody.getAsJsonObject(VtnServiceJsonConsts.VLANMAP)
valVlanMapStruct
.set(VtnServiceJsonConsts.VLANID,
IpcDataUnitWrapper
- .setIpcUint16HexaValue(VtnServiceIpcConsts.VLAN_ID_DEFAULT_VALUE));
+ .setIpcUint16HexaValue(VtnServiceIpcConsts.VLAN_ID_DEFAULT_VALUE,
+ valVlanMapStruct, UncStructIndexEnum.ValVlanMapIndex.UPLL_IDX_VLAN_ID_VM.ordinal()));
} else {
valVlanMapStruct
.set(VtnServiceIpcConsts.VALID,
}
keyVunknownStruct.set(VtnServiceIpcConsts.VTNKEY, keyVtnStruct);
if (requestBody != null
- && requestBody.has(VtnServiceJsonConsts.VUNKNOWN)
- && ((JsonObject) requestBody.get(VtnServiceJsonConsts.VUNKNOWN))
- .has(VtnServiceJsonConsts.VUKNAME)) {
+ && requestBody.has(VtnServiceJsonConsts.VBYPASS)
+ && ((JsonObject) requestBody.get(VtnServiceJsonConsts.VBYPASS))
+ .has(VtnServiceJsonConsts.VBYPASS_NAME)) {
keyVunknownStruct
.set(VtnServiceIpcConsts.VUNKNOWNNAME,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(((JsonObject) requestBody
- .get(VtnServiceJsonConsts.VUNKNOWN))
- .get(VtnServiceJsonConsts.VUKNAME)
+ .get(VtnServiceJsonConsts.VBYPASS))
+ .get(VtnServiceJsonConsts.VBYPASS_NAME)
.getAsString()));
} else if (uriParameters != null
&& uriParameters.size() == UncIndexEnum.TWO.ordinal()) {
*/
public IpcStruct getKeyStaticIpRouteStruct(final JsonObject requestBody,
final List<String> uriParameters) {
-
// Lower level structure
/*
* ipc_struct key_static_ip_route { key_vrt vrt_key; IPV4 dst_addr;
* UINT8 dst_addr_prefixlen; UINT8 nwm_name[32]; };
*/
-
LOG.trace("Start getKeyStaticIpRouteStruct");
final IpcStruct keyStaticIpRouteStruct = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.KeyStaticIpRoute.getValue());
uriParameters.subList(0, 2));
}
keyStaticIpRouteStruct.set(VtnServiceIpcConsts.VRTKEY, keyVtnVrtStruct);
-
if (requestBody != null
- && requestBody.has(VtnServiceJsonConsts.STATIC_IPROUTE)
- && ((JsonObject) requestBody
- .get(VtnServiceJsonConsts.STATIC_IPROUTE))
- .has(VtnServiceJsonConsts.IPADDR)
- && ((JsonObject) requestBody
- .get(VtnServiceJsonConsts.STATIC_IPROUTE))
- .has(VtnServiceJsonConsts.NETMASK)
- && ((JsonObject) requestBody
- .get(VtnServiceJsonConsts.STATIC_IPROUTE))
- .has(VtnServiceJsonConsts.NMG_NAME)) {
- keyStaticIpRouteStruct.set(VtnServiceIpcConsts.DST_ADDR,
- IpcDataUnitWrapper
- .setIpcInet4AddressValue(((JsonObject) requestBody
- .get(VtnServiceJsonConsts.STATIC_IPROUTE))
- .get(VtnServiceJsonConsts.IPADDR)
- .getAsString()));
- keyStaticIpRouteStruct.set(VtnServiceIpcConsts.DST_ADDR_PREFIXLEN,
- IpcDataUnitWrapper
- .setIpcUint8Value(((JsonObject) requestBody
- .get(VtnServiceJsonConsts.STATIC_IPROUTE))
- .get(VtnServiceJsonConsts.NETMASK)
- .getAsString()));
- keyStaticIpRouteStruct.set(VtnServiceIpcConsts.NEXT_HOP_ADDR,
- IpcDataUnitWrapper
- .setIpcInet4AddressValue(((JsonObject) requestBody
- .get(VtnServiceJsonConsts.STATIC_IPROUTE))
- .get(VtnServiceJsonConsts.NEXTHOPADDR)
- .getAsString()));
- keyStaticIpRouteStruct.set(VtnServiceIpcConsts.NWM_NAME,
- IpcDataUnitWrapper
- .setIpcUint8ArrayValue(((JsonObject) requestBody
- .get(VtnServiceJsonConsts.STATIC_IPROUTE))
- .get(VtnServiceJsonConsts.NMG_NAME)
- .getAsString()));
- }
-
- else if (uriParameters != null
+ && requestBody.has(VtnServiceJsonConsts.STATIC_IPROUTE)) {
+ JsonObject staticIpRoute = requestBody
+ .getAsJsonObject(VtnServiceJsonConsts.STATIC_IPROUTE);
+ if (staticIpRoute.has(VtnServiceJsonConsts.IPADDR)
+ && staticIpRoute.has(VtnServiceJsonConsts.PREFIX)
+ && staticIpRoute.has(VtnServiceJsonConsts.NEXTHOPADDR)) {
+ keyStaticIpRouteStruct.set(VtnServiceIpcConsts.DST_ADDR,
+ IpcDataUnitWrapper
+ .setIpcInet4AddressValue(staticIpRoute.get(
+ VtnServiceJsonConsts.IPADDR)
+ .getAsString()));
+ keyStaticIpRouteStruct.set(
+ VtnServiceIpcConsts.DST_ADDR_PREFIXLEN,
+ IpcDataUnitWrapper.setIpcUint8Value(staticIpRoute.get(
+ VtnServiceJsonConsts.PREFIX).getAsString()));
+ keyStaticIpRouteStruct.set(VtnServiceIpcConsts.NEXT_HOP_ADDR,
+ IpcDataUnitWrapper
+ .setIpcInet4AddressValue(staticIpRoute.get(
+ VtnServiceJsonConsts.NEXTHOPADDR)
+ .getAsString()));
+
+ } else if (staticIpRoute.has(VtnServiceJsonConsts.NEXTHOPADDR)){
+ keyStaticIpRouteStruct.set(VtnServiceIpcConsts.NEXT_HOP_ADDR,
+ IpcDataUnitWrapper
+ .setIpcInet4AddressValue(staticIpRoute.get(
+ VtnServiceJsonConsts.NEXTHOPADDR)
+ .getAsString()));
+ }
+ } else if (uriParameters != null
&& uriParameters.size() == UncIndexEnum.THREE.ordinal()) {
final String[] staticIpRouteId = uriParameters.get(2).split(
VtnServiceJsonConsts.HYPHEN);
keyStaticIpRouteStruct.set(VtnServiceIpcConsts.NEXT_HOP_ADDR,
IpcDataUnitWrapper
.setIpcInet4AddressValue(staticIpRouteId[1]));
- if (staticIpRouteId.length > 3) {
- keyStaticIpRouteStruct.set(VtnServiceIpcConsts.NWM_NAME,
- IpcDataUnitWrapper
- .setIpcUint8ArrayValue(staticIpRouteId[3]));
- }
} else {
- LOG.warning("request body and uri parameters are not correct for getKeyStaticIpRouteStruct");
+ LOG.warning("Request body and uri parameters are not correct for getKeyStaticIpRouteStruct");
}
LOG.info("Key Structure: " + keyStaticIpRouteStruct.toString());
LOG.trace("Complete getKeyStaticIpRouteStruct");
-
return keyStaticIpRouteStruct;
}
*/
public IpcStruct getValVtnFlowFilterEntryStruct(
final JsonObject requestBody, final List<String> uriParameters) {
-
// Lower level structure
/*
* ipc_struct ValVtnFlowFilterEntry{ UINT8 valid[5]; UINT8
LOG.trace("Start getValVtnFlowFilterEntryStruct");
final IpcStruct valVtnFlowFilterEntryStruct = new IpcStruct(
UncStructEnum.ValVtnFlowFilterEntry.getValue());
-
if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.FLOWFILTERENTRY)) {
- if (requestBody.getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY).has(
- VtnServiceJsonConsts.FLNAME)) {
+ JsonObject flowFilterEntry = requestBody.getAsJsonObject(
+ VtnServiceJsonConsts.FLOWFILTERENTRY);
+ if (flowFilterEntry.has(VtnServiceJsonConsts.FLNAME)) {
valVtnFlowFilterEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVtnFlowfilterEntryIndex.UPLL_IDX_FLOWLIST_NAME_VFFE
.set(VtnServiceJsonConsts.FLOWLISTNAME,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY)
- .get(VtnServiceJsonConsts.FLNAME)
+ flowFilterEntry.get(VtnServiceJsonConsts.FLNAME)
.getAsString(),
valVtnFlowFilterEntryStruct,
UncStructIndexEnum.ValVtnFlowfilterEntryIndex.UPLL_IDX_FLOWLIST_NAME_VFFE
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY).has(
- VtnServiceJsonConsts.ACTIONTYPE)) {
+ if (flowFilterEntry.has(VtnServiceJsonConsts.ACTIONTYPE)) {
valVtnFlowFilterEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVtnFlowfilterEntryIndex.UPLL_IDX_ACTION_VFFE
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
.ordinal()));
- if (requestBody
- .getAsJsonObject(VtnServiceJsonConsts.FLOWFILTERENTRY)
- .get(VtnServiceJsonConsts.ACTIONTYPE).getAsString()
+ if (flowFilterEntry.get(VtnServiceJsonConsts.ACTIONTYPE).getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.PASS)) {
valVtnFlowFilterEntryStruct
.set(VtnServiceJsonConsts.ACTION,
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.FlowfilterAction.UPLL_FLOWFILTER_ACT_PASS
.ordinal()));
- }
-
- else if (requestBody
- .getAsJsonObject(VtnServiceJsonConsts.FLOWFILTERENTRY)
- .get(VtnServiceJsonConsts.ACTIONTYPE).getAsString()
+ } else if (flowFilterEntry.get(VtnServiceJsonConsts.ACTIONTYPE).getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.DROP)) {
valVtnFlowFilterEntryStruct
.set(VtnServiceJsonConsts.ACTION,
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.FlowfilterAction.UPLL_FLOWFILTER_ACT_DROP
.ordinal()));
- } else if (requestBody
- .getAsJsonObject(VtnServiceJsonConsts.FLOWFILTERENTRY)
- .get(VtnServiceJsonConsts.ACTIONTYPE).getAsString()
+ } else if (flowFilterEntry.get(VtnServiceJsonConsts.ACTIONTYPE).getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.REDIRECT)) {
valVtnFlowFilterEntryStruct
.set(VtnServiceJsonConsts.ACTION,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY).has(
- VtnServiceJsonConsts.NMGNAME)) {
+ if (flowFilterEntry.has(VtnServiceJsonConsts.NMGNAME)) {
valVtnFlowFilterEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVtnFlowfilterEntryIndex.UPLL_IDX_NWN_NAME_VFFE
.set(VtnServiceIpcConsts.NWMNAME,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY)
- .get(VtnServiceJsonConsts.NMGNAME)
+ flowFilterEntry.get(VtnServiceJsonConsts.NMGNAME)
.getAsString(),
valVtnFlowFilterEntryStruct,
UncStructIndexEnum.ValVtnFlowfilterEntryIndex.UPLL_IDX_NWN_NAME_VFFE
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY).has(
- VtnServiceJsonConsts.DSCP)) {
+ if (flowFilterEntry.has(VtnServiceJsonConsts.DSCP)) {
valVtnFlowFilterEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVtnFlowfilterEntryIndex.UPLL_IDX_DSCP_VFFE
.ordinal()));
valVtnFlowFilterEntryStruct.set(
VtnServiceJsonConsts.DSCP,
- IpcDataUnitWrapper.setIpcUint8Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY)
- .get(VtnServiceJsonConsts.DSCP).getAsString()));
+ IpcDataUnitWrapper.setIpcUint8Value(flowFilterEntry.get(VtnServiceJsonConsts.DSCP).getAsString(),
+ valVtnFlowFilterEntryStruct,UncStructIndexEnum.ValVtnFlowfilterEntryIndex.UPLL_IDX_DSCP_VFFE.ordinal()));
} else {
valVtnFlowFilterEntryStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY).has(
- VtnServiceJsonConsts.PRIORITY)) {
+ if (flowFilterEntry.has(VtnServiceJsonConsts.PRIORITY)) {
valVtnFlowFilterEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVtnFlowfilterEntryIndex.UPLL_IDX_PRIORITY_VFFE
.ordinal()));
valVtnFlowFilterEntryStruct.set(
VtnServiceJsonConsts.PRIORITY,
- IpcDataUnitWrapper.setIpcUint8Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY)
- .get(VtnServiceJsonConsts.PRIORITY)
- .getAsString()));
+ IpcDataUnitWrapper.setIpcUint8Value(flowFilterEntry.get(VtnServiceJsonConsts.PRIORITY).getAsString(),
+ valVtnFlowFilterEntryStruct,UncStructIndexEnum.ValVtnFlowfilterEntryIndex.UPLL_IDX_PRIORITY_VFFE.ordinal()));
} else {
valVtnFlowFilterEntryStruct
.set(VtnServiceIpcConsts.VALID,
}
LOG.info("Value Structure: " + valVtnFlowFilterEntryStruct.toString());
LOG.trace("Complete getValVtnFlowFilterEntryStruct");
-
return valVtnFlowFilterEntryStruct;
}
final List<String> uriParameters) {
// Lower level structure
/*
- *
* ipc_struct val_vunknown { UINT8 valid[4]; UINT8 cs_row_status; UINT8
* cs_attr[4]; UINT8 description[128]; UINT8 type; UINT8
* controller_id[32]; UINT8 domain_id[32]; };
LOG.trace("Start getValVunknownStruct");
final IpcStruct valValVunknownStruct = new IpcStruct(
UncStructEnum.ValVunknown.getValue());
-
if (requestBody != null
- && requestBody.has(VtnServiceJsonConsts.VUNKNOWN)) {
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VUNKNOWN).has(
- VtnServiceJsonConsts.DESCRIPTION)) {
+ && requestBody.has(VtnServiceJsonConsts.VBYPASS)) {
+ JsonObject vByPass = requestBody.getAsJsonObject(VtnServiceJsonConsts.VBYPASS);
+ if (vByPass.has(VtnServiceJsonConsts.DESCRIPTION)) {
valValVunknownStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVunknownIndex.UPLL_IDX_DESC_VUN
.set(VtnServiceJsonConsts.DESCRIPTION,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VUNKNOWN)
- .get(VtnServiceJsonConsts.DESCRIPTION)
+ vByPass.get(VtnServiceJsonConsts.DESCRIPTION)
.getAsString(),
valValVunknownStruct,
UncStructIndexEnum.ValVunknownIndex.UPLL_IDX_DESC_VUN
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- // update after query reply
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VUNKNOWN).has(
- VtnServiceJsonConsts.TYPE)) {
+ if (vByPass.has(VtnServiceJsonConsts.TYPE)) {
valValVunknownStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVunknownIndex.UPLL_IDX_TYPE_VUN
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
.ordinal()));
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VUNKNOWN)
- .get(VtnServiceJsonConsts.TYPE).getAsString()
+ if (vByPass.get(VtnServiceJsonConsts.TYPE).getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.BRIDGE)) {
valValVunknownStruct
.set(VtnServiceIpcConsts.TYPE,
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.ValVunknowntype.VUNKNOWN_TYPE_BRIDGE
.ordinal()));
- } else if (requestBody
- .getAsJsonObject(VtnServiceJsonConsts.VUNKNOWN)
- .get(VtnServiceJsonConsts.TYPE).getAsString()
+ } else if (vByPass.get(VtnServiceJsonConsts.TYPE).getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.ROUTER)) {
valValVunknownStruct
.set(VtnServiceIpcConsts.TYPE,
.ordinal()));
}
LOG.debug("type:"
- + requestBody
- .getAsJsonObject(VtnServiceJsonConsts.VUNKNOWN)
- .get(VtnServiceJsonConsts.TYPE).getAsString());
+ + vByPass.get(VtnServiceJsonConsts.TYPE).getAsString());
} else {
valValVunknownStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VUNKNOWN).has(
- VtnServiceJsonConsts.DOMAINID)) {
+ if (vByPass.has(VtnServiceJsonConsts.DOMAINID)) {
valValVunknownStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVunknownIndex.UPLL_IDX_DOMAIN_ID_VUN
.set(VtnServiceJsonConsts.DOMAINID,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VUNKNOWN)
- .get(VtnServiceJsonConsts.DOMAINID)
+ vByPass.get(VtnServiceJsonConsts.DOMAINID)
.getAsString(),
valValVunknownStruct,
UncStructIndexEnum.ValVunknownIndex.UPLL_IDX_DOMAIN_ID_VUN
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VUNKNOWN).has(
- VtnServiceJsonConsts.CONTROLLERID)) {
+ if (vByPass.has(VtnServiceJsonConsts.CONTROLLERID)) {
valValVunknownStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVunknownIndex.UPLL_IDX_CONTROLLER_ID_VUN
.set(VtnServiceJsonConsts.CONTROLLERID,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VUNKNOWN)
- .get(VtnServiceJsonConsts.CONTROLLERID)
+ vByPass.get(VtnServiceJsonConsts.CONTROLLERID)
.getAsString(),
valValVunknownStruct,
UncStructIndexEnum.ValVunknownIndex.UPLL_IDX_CONTROLLER_ID_VUN
}
LOG.info("Value Structure: " + valValVunknownStruct.toString());
LOG.trace("Complete getValVunknownStruct");
-
return valValVunknownStruct;
}
*/
public IpcStruct getValVunkIfStruct(final JsonObject requestBody,
final List<String> uriParameters) {
-
// Lower level structure
/*
* ipc_struct val_vunk_if { UINT8 valid[2]; UINT8 cs_row_status; UINT8
LOG.trace("Start getValVunkIfStruct");
final IpcStruct valVunkIfStruct = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.ValVunkIf.getValue());
-
if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.INTERFACE)) {
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.INTERFACE)
- .has(VtnServiceJsonConsts.DESCRIPTION)) {
+ JsonObject vunkIf = requestBody.getAsJsonObject(VtnServiceJsonConsts.INTERFACE);
+ if (vunkIf.has(VtnServiceJsonConsts.DESCRIPTION)) {
valVunkIfStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVunkIfIndex.UPLL_IDX_DESC_VUNI
.set(VtnServiceJsonConsts.DESCRIPTION,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.INTERFACE)
- .get(VtnServiceJsonConsts.DESCRIPTION)
+ vunkIf.get(VtnServiceJsonConsts.DESCRIPTION)
.getAsString(),
valVunkIfStruct,
UncStructIndexEnum.ValVunkIfIndex.UPLL_IDX_DESC_VUNI
.ordinal()));
-
} else {
valVunkIfStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.INTERFACE)
- .has(VtnServiceJsonConsts.ADMINSTATUS)) {
+ if (vunkIf.has(VtnServiceJsonConsts.ADMINSTATUS)) {
valVunkIfStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVunkIfIndex.UPLL_IDX_ADMIN_ST_VUNI
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
.ordinal()));
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.INTERFACE)
- .get(VtnServiceJsonConsts.ADMINSTATUS).getAsString()
+ if (vunkIf.get(VtnServiceJsonConsts.ADMINSTATUS).getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.ENABLE)) {
valVunkIfStruct
.set(VtnServiceJsonConsts.ADMIN_STATUS,
IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_ENABLE
- .getValue()));
+ .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_ENABLE.getValue(),
+ valVunkIfStruct, UncStructIndexEnum.ValVunkIfIndex.UPLL_IDX_ADMIN_ST_VUNI.ordinal()));
} else {
valVunkIfStruct
.set(VtnServiceJsonConsts.ADMIN_STATUS,
IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_DISABLE
- .getValue()));
+ .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_DISABLE.getValue(),
+ valVunkIfStruct, UncStructIndexEnum.ValVunkIfIndex.UPLL_IDX_ADMIN_ST_VUNI.ordinal()));
}
LOG.debug("adminstatus:"
- + requestBody
- .getAsJsonObject(VtnServiceJsonConsts.INTERFACE)
- .get(VtnServiceJsonConsts.ADMINSTATUS)
+ + vunkIf.get(VtnServiceJsonConsts.ADMINSTATUS)
.getAsString());
} else {
valVunkIfStruct
}
LOG.info("Value Structure: " + valVunkIfStruct.toString());
LOG.trace("Complete getValVunkIfStruct");
-
return valVunkIfStruct;
}
*/
public IpcStruct getKeyVbrFlowFilterEntryStruct(
final JsonObject requestBody, final List<String> uriParameters) {
-
/*
* ipc_struct key_vbr_flowfilter_entry { key_vbr_flowfilter
* flowfilter_key; UINT16 sequence_num; };
}
LOG.info("Key Structure: " + keyVbrFlowFilterEntryStruct.toString());
LOG.trace("Complete getKeyVbrFlowFilterEntryStruct");
-
return keyVbrFlowFilterEntryStruct;
}
LOG.trace("Start getValFlowfilterEntryStruct");
final IpcStruct valFlowfilterEntryStruct = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.ValFlowfilterEntry.getValue());
-
if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.FLOWFILTERENTRY)) {
- if (requestBody.getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY).has(
- VtnServiceJsonConsts.FLNAME)) {
+ JsonObject flowFilterEntry = requestBody.getAsJsonObject(
+ VtnServiceJsonConsts.FLOWFILTERENTRY);
+ if (flowFilterEntry.has(VtnServiceJsonConsts.FLNAME)) {
valFlowfilterEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_FLOWLIST_NAME_FFE
.set(VtnServiceJsonConsts.FLOWLISTNAME,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY)
- .get(VtnServiceJsonConsts.FLNAME)
+ flowFilterEntry.get(VtnServiceJsonConsts.FLNAME)
.getAsString(),
valFlowfilterEntryStruct,
UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_FLOWLIST_NAME_FFE
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
- if (requestBody.getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY).has(
- VtnServiceJsonConsts.ACTIONTYPE)) {
+ if (flowFilterEntry.has(VtnServiceJsonConsts.ACTIONTYPE)) {
valFlowfilterEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_ACTION_FFE
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
.ordinal()));
- if (requestBody
- .getAsJsonObject(VtnServiceJsonConsts.FLOWFILTERENTRY)
- .get(VtnServiceJsonConsts.ACTIONTYPE).getAsString()
+ if (flowFilterEntry.get(VtnServiceJsonConsts.ACTIONTYPE).getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.PASS)) {
valFlowfilterEntryStruct
.set(VtnServiceIpcConsts.ACTION,
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.FlowfilterAction.UPLL_FLOWFILTER_ACT_PASS
.ordinal()));
- } else if (requestBody
- .getAsJsonObject(VtnServiceJsonConsts.FLOWFILTERENTRY)
- .get(VtnServiceJsonConsts.ACTIONTYPE).getAsString()
+ } else if (flowFilterEntry.get(VtnServiceJsonConsts.ACTIONTYPE).getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.DROP)) {
valFlowfilterEntryStruct
.set(VtnServiceIpcConsts.ACTION,
.ordinal()));
}
LOG.debug("action_type:"
- + requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY)
- .get(VtnServiceJsonConsts.ACTIONTYPE)
+ + flowFilterEntry.get(VtnServiceJsonConsts.ACTIONTYPE)
.getAsString());
} else {
valFlowfilterEntryStruct
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
- if (requestBody.getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY).has(
- VtnServiceJsonConsts.REDIRECTDST)
- && requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY)
- .getAsJsonObject(VtnServiceJsonConsts.REDIRECTDST)
- .has(VtnServiceJsonConsts.VNODENAME)) {
- valFlowfilterEntryStruct
- .set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_REDIRECT_NODE_FFE
- .ordinal(),
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
- .ordinal()));
- valFlowfilterEntryStruct
- .set(VtnServiceIpcConsts.REDIRECTNODE,
- IpcDataUnitWrapper
- .setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY)
- .getAsJsonObject(
- VtnServiceJsonConsts.REDIRECTDST)
- .get(VtnServiceJsonConsts.VNODENAME)
- .getAsString(),
- valFlowfilterEntryStruct,
- UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_REDIRECT_NODE_FFE
- .ordinal()));
- } else {
- valFlowfilterEntryStruct
- .set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_REDIRECT_NODE_FFE
- .ordinal(),
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
- .ordinal()));
- }
-
- if (requestBody.getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY).has(
- VtnServiceJsonConsts.REDIRECTDST)
- && requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY)
- .getAsJsonObject(VtnServiceJsonConsts.REDIRECTDST)
- .has(VtnServiceJsonConsts.IFNAME)) {
- valFlowfilterEntryStruct
- .set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_REDIRECT_PORT_FFE
- .ordinal(),
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
- .ordinal()));
- valFlowfilterEntryStruct
- .set(VtnServiceIpcConsts.REDIRECTPORT,
- IpcDataUnitWrapper
- .setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY)
- .getAsJsonObject(
- VtnServiceJsonConsts.REDIRECTDST)
- .get(VtnServiceJsonConsts.IFNAME)
- .getAsString(),
- valFlowfilterEntryStruct,
- UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_REDIRECT_PORT_FFE
- .ordinal()));
- } else {
- valFlowfilterEntryStruct
- .set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_REDIRECT_PORT_FFE
- .ordinal(),
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
- .ordinal()));
- }
-
- if (requestBody.getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY).has(
- VtnServiceJsonConsts.REDIRECTDST)
- && requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY)
- .getAsJsonObject(VtnServiceJsonConsts.REDIRECTDST)
- .has(VtnServiceJsonConsts.MACDSTADDR)) {
- valFlowfilterEntryStruct
- .set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_MODIFY_DST_MAC_FFE
- .ordinal(),
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
- .ordinal()));
- // valFlowfilterEntryStruct.set(VtnServiceIpcConsts.MODIFYDSTMACADDR,IpcDataUnitWrapper.setIpcUint8ArrayValue(requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWFILTERENTRY).getAsJsonObject(VtnServiceJsonConsts.REDIRECTDST).get(VtnServiceJsonConsts.MACDSTADDR).getAsString()));
- IpcDataUnitWrapper.setMacAddress(
- valFlowfilterEntryStruct,
- VtnServiceIpcConsts.MODIFYDSTMACADDR,
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY)
- .getAsJsonObject(
- VtnServiceJsonConsts.REDIRECTDST)
- .get(VtnServiceJsonConsts.MACDSTADDR)
- .getAsString());
- } else {
- valFlowfilterEntryStruct
- .set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_MODIFY_DST_MAC_FFE
- .ordinal(),
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
- .ordinal()));
- }
-
- if (requestBody.getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY).has(
- VtnServiceJsonConsts.REDIRECTDST)
- && requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY)
- .getAsJsonObject(VtnServiceJsonConsts.REDIRECTDST)
- .has(VtnServiceJsonConsts.MACSRCADDR)) {
- valFlowfilterEntryStruct
- .set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_MODIFY_SRC_MAC_FFE
- .ordinal(),
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
- .ordinal()));
-
- IpcDataUnitWrapper.setMacAddress(
- valFlowfilterEntryStruct,
- VtnServiceIpcConsts.MODIFYSRCMACADDR,
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY)
- .getAsJsonObject(
- VtnServiceJsonConsts.REDIRECTDST)
- .get(VtnServiceJsonConsts.MACSRCADDR)
- .getAsString());
- } else {
- valFlowfilterEntryStruct
- .set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_MODIFY_SRC_MAC_FFE
- .ordinal(),
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
- .ordinal()));
+ if (flowFilterEntry.has(VtnServiceJsonConsts.REDIRECTDST)) {
+ JsonObject redirectDst = flowFilterEntry
+ .getAsJsonObject(VtnServiceJsonConsts.REDIRECTDST);
+ if (redirectDst.has(VtnServiceJsonConsts.VNODENAME)) {
+ valFlowfilterEntryStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_REDIRECT_NODE_FFE
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
+ .ordinal()));
+ valFlowfilterEntryStruct
+ .set(VtnServiceIpcConsts.REDIRECTNODE,
+ IpcDataUnitWrapper
+ .setIpcUint8ArrayValue(
+ redirectDst
+ .get(VtnServiceJsonConsts.VNODENAME)
+ .getAsString(),
+ valFlowfilterEntryStruct,
+ UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_REDIRECT_NODE_FFE
+ .ordinal()));
+ } else {
+ valFlowfilterEntryStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_REDIRECT_NODE_FFE
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()));
+ }
+ if (redirectDst.has(VtnServiceJsonConsts.IFNAME)) {
+ valFlowfilterEntryStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_REDIRECT_PORT_FFE
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
+ .ordinal()));
+ valFlowfilterEntryStruct
+ .set(VtnServiceIpcConsts.REDIRECTPORT,
+ IpcDataUnitWrapper
+ .setIpcUint8ArrayValue(
+ redirectDst
+ .get(VtnServiceJsonConsts.IFNAME)
+ .getAsString(),
+ valFlowfilterEntryStruct,
+ UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_REDIRECT_PORT_FFE
+ .ordinal()));
+ } else {
+ valFlowfilterEntryStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_REDIRECT_PORT_FFE
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()));
+ }
+ if (redirectDst.has(VtnServiceJsonConsts.MACDSTADDR)) {
+ valFlowfilterEntryStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_MODIFY_DST_MAC_FFE
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
+ .ordinal()));
+ // valFlowfilterEntryStruct.set(VtnServiceIpcConsts.MODIFYDSTMACADDR,IpcDataUnitWrapper.setIpcUint8ArrayValue(requestBody.getAsJsonObject(VtnServiceJsonConsts.FLOWFILTERENTRY).getAsJsonObject(VtnServiceJsonConsts.REDIRECTDST).get(VtnServiceJsonConsts.MACDSTADDR).getAsString()));
+ IpcDataUnitWrapper.setMacAddress(valFlowfilterEntryStruct,
+ VtnServiceIpcConsts.MODIFYDSTMACADDR, redirectDst
+ .get(VtnServiceJsonConsts.MACDSTADDR).getAsString(),
+ UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_MODIFY_DST_MAC_FFE.ordinal());
+ } else {
+ valFlowfilterEntryStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_MODIFY_DST_MAC_FFE
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()));
+ }
+ if (redirectDst.has(VtnServiceJsonConsts.MACSRCADDR)) {
+ valFlowfilterEntryStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_MODIFY_SRC_MAC_FFE
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
+ .ordinal()));
+ IpcDataUnitWrapper.setMacAddress(valFlowfilterEntryStruct,
+ VtnServiceIpcConsts.MODIFYSRCMACADDR, redirectDst
+ .get(VtnServiceJsonConsts.MACSRCADDR).getAsString(),
+ UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_MODIFY_SRC_MAC_FFE.ordinal());
+ } else {
+ valFlowfilterEntryStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_MODIFY_SRC_MAC_FFE
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()));
+ }
}
-
- if (requestBody.getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY).has(
- VtnServiceJsonConsts.NMGNAME)) {
+ if (flowFilterEntry.has(VtnServiceJsonConsts.NMGNAME)) {
valFlowfilterEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_NWM_NAME_FFE
.set(VtnServiceIpcConsts.NWMNAME,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY)
- .get(VtnServiceJsonConsts.NMGNAME)
+ flowFilterEntry.get(VtnServiceJsonConsts.NMGNAME)
.getAsString(),
valFlowfilterEntryStruct,
UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_NWM_NAME_FFE
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
- if (requestBody.getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY).has(
- VtnServiceJsonConsts.DSCP)) {
+ if (flowFilterEntry.has(VtnServiceJsonConsts.DSCP)) {
valFlowfilterEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_DSCP_FFE
.ordinal()));
valFlowfilterEntryStruct.set(
VtnServiceIpcConsts.DSCP,
- IpcDataUnitWrapper.setIpcUint8Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY)
- .get(VtnServiceJsonConsts.DSCP).getAsString()));
+ IpcDataUnitWrapper.setIpcUint8Value(flowFilterEntry.get(VtnServiceJsonConsts.DSCP).getAsString(),
+ valFlowfilterEntryStruct, UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_DSCP_FFE.ordinal()));
} else {
valFlowfilterEntryStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
- if (requestBody.getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY).has(
- VtnServiceJsonConsts.PRIORITY)) {
+ if (flowFilterEntry.has(VtnServiceJsonConsts.PRIORITY)) {
valFlowfilterEntryStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_PRIORITY_FFE
.ordinal()));
valFlowfilterEntryStruct.set(
VtnServiceIpcConsts.PRIORITY,
- IpcDataUnitWrapper.setIpcUint8Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.FLOWFILTERENTRY)
- .get(VtnServiceJsonConsts.PRIORITY)
- .getAsString()));
+ IpcDataUnitWrapper.setIpcUint8Value(flowFilterEntry.get(VtnServiceJsonConsts.PRIORITY).getAsString(),
+ valFlowfilterEntryStruct, UncStructIndexEnum.ValFlowfilterEntryIndex.UPLL_IDX_PRIORITY_FFE.ordinal()));
} else {
valFlowfilterEntryStruct
.set(VtnServiceIpcConsts.VALID,
}
LOG.info("Value Structure: " + valFlowfilterEntryStruct.toString());
LOG.trace("Complete getValFlowfilterEntryStruct");
-
return valFlowfilterEntryStruct;
}
}
LOG.info("Key Structure: " + keyVbrIfStruct.toString());
LOG.trace("Complete getKeyVbrIfStruct");
-
return keyVbrIfStruct;
}
.setIpcStructValue(UncStructEnum.ValPortMap.getValue());
if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.PORTMAP)) {
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.PORTMAP).has(
- VtnServiceJsonConsts.LOGICAL_PORT_ID)) {
+ JsonObject portMap = requestBody.getAsJsonObject(VtnServiceJsonConsts.PORTMAP);
+ if (portMap.has(VtnServiceJsonConsts.LOGICAL_PORT_ID)) {
valPortMapStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValPortMapIndex.UPLL_IDX_LOGICAL_PORT_ID_PM
.set(VtnServiceJsonConsts.LOGICAL_PORT_ID,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.PORTMAP)
- .get(VtnServiceJsonConsts.LOGICAL_PORT_ID)
+ portMap.get(VtnServiceJsonConsts.LOGICAL_PORT_ID)
.getAsString(),
valPortMapStruct,
UncStructIndexEnum.ValPortMapIndex.UPLL_IDX_LOGICAL_PORT_ID_PM
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.PORTMAP).has(
- VtnServiceJsonConsts.VLANID)) {
+ if (portMap.has(VtnServiceJsonConsts.VLANID)) {
valPortMapStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValPortMapIndex.UPLL_IDX_VLAN_ID_PM
.ordinal()));
valPortMapStruct.set(VtnServiceJsonConsts.VLANID,
IpcDataUnitWrapper
- .setIpcUint16Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.PORTMAP)
- .get(VtnServiceJsonConsts.VLANID)
- .getAsString()));
+ .setIpcUint16Value(portMap.get(VtnServiceJsonConsts.VLANID).getAsString(),
+ valPortMapStruct, UncStructIndexEnum.ValPortMapIndex.UPLL_IDX_VLAN_ID_PM.ordinal()));
}
else {
valPortMapStruct
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.PORTMAP).has(
- VtnServiceJsonConsts.TAGGED)) {
+ if (portMap.has(VtnServiceJsonConsts.TAGGED)) {
valPortMapStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValPortMapIndex.UPLL_IDX_TAGGED_PM
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
.ordinal()));
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.PORTMAP)
- .get(VtnServiceJsonConsts.TAGGED).getAsString()
+ if (portMap.get(VtnServiceJsonConsts.TAGGED).getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.TRUE)) {
valPortMapStruct
.set(VtnServiceJsonConsts.TAGGED,
IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.vlan_tagged.UPLL_VLAN_TAGGED
- .getValue()));
- } else {
+ .setIpcUint8Value(UncStructIndexEnum.vlan_tagged.UPLL_VLAN_TAGGED.getValue(),
+ valPortMapStruct, UncStructIndexEnum.ValPortMapIndex.UPLL_IDX_TAGGED_PM.ordinal()));
+ } else if (portMap.get(VtnServiceJsonConsts.TAGGED).getAsString()
+ .equalsIgnoreCase(VtnServiceJsonConsts.FALSE)){
valPortMapStruct
.set(VtnServiceJsonConsts.TAGGED,
IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.vlan_tagged.UPLL_VLAN_UNTAGGED
- .getValue()));
+ .setIpcUint8Value(UncStructIndexEnum.vlan_tagged.UPLL_VLAN_UNTAGGED.getValue(),
+ valPortMapStruct, UncStructIndexEnum.ValPortMapIndex.UPLL_IDX_TAGGED_PM.ordinal()));
+ } else {
+ valPortMapStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValPortMapIndex.UPLL_IDX_TAGGED_PM
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID_NO_VALUE
+ .ordinal()));
}
LOG.debug("tagged:"
- + requestBody
- .getAsJsonObject(VtnServiceJsonConsts.PORTMAP)
- .get(VtnServiceJsonConsts.TAGGED).getAsString());
+ + portMap.get(VtnServiceJsonConsts.TAGGED).getAsString());
} else {
valPortMapStruct
.set(VtnServiceIpcConsts.VALID,
}
LOG.info("Value Structure: " + valPortMapStruct.toString());
LOG.trace("Complete getValPortMapStruct");
-
return valPortMapStruct;
}
.setIpcStructValue(UncStructEnum.ValVbrIf.getValue());
if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.INTERFACE)) {
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.INTERFACE)
- .has(VtnServiceJsonConsts.ADMINSTATUS)) {
+ JsonObject vbrIf = requestBody.getAsJsonObject(VtnServiceJsonConsts.INTERFACE);
+ if (vbrIf.has(VtnServiceJsonConsts.ADMINSTATUS)) {
valVbrIfStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVbrIfIndex.UPLL_IDX_ADMIN_STATUS_VBRI
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
.ordinal()));
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.INTERFACE)
- .get(VtnServiceJsonConsts.ADMINSTATUS).getAsString()
+ if (vbrIf.get(VtnServiceJsonConsts.ADMINSTATUS).getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.ENABLE)) {
valVbrIfStruct
.set(VtnServiceJsonConsts.ADMIN_STATUS,
IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_ENABLE
- .getValue()));
+ .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_ENABLE.getValue(),
+ valVbrIfStruct, UncStructIndexEnum.ValVbrIfIndex.UPLL_IDX_ADMIN_STATUS_VBRI.ordinal()));
} else {
valVbrIfStruct
.set(VtnServiceJsonConsts.ADMIN_STATUS,
IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_DISABLE
- .getValue()));
+ .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_DISABLE.getValue(),
+ valVbrIfStruct, UncStructIndexEnum.ValVbrIfIndex.UPLL_IDX_ADMIN_STATUS_VBRI.ordinal()));
}
LOG.debug("adminstatus"
- + requestBody
- .getAsJsonObject(VtnServiceJsonConsts.INTERFACE)
- .get(VtnServiceJsonConsts.ADMINSTATUS)
+ + vbrIf.get(VtnServiceJsonConsts.ADMINSTATUS)
.getAsString());
} else {
valVbrIfStruct
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.INTERFACE)
- .has(VtnServiceJsonConsts.DESCRIPTION)) {
+ if (vbrIf.has(VtnServiceJsonConsts.DESCRIPTION)) {
valVbrIfStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVbrIfIndex.UPLL_IDX_DESC_VBRI
.set(VtnServiceJsonConsts.DESCRIPTION,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.INTERFACE)
- .get(VtnServiceJsonConsts.DESCRIPTION)
+ vbrIf.get(VtnServiceJsonConsts.DESCRIPTION)
.getAsString(),
valVbrIfStruct,
UncStructIndexEnum.ValVbrIfIndex.UPLL_IDX_DESC_VBRI
public IpcStruct getValVrtStruct(final JsonObject requestBody,
final List<String> uriParameters) {
// Lower level structure
-
/*
* ipc_struct val_vrt { UINT8 valid[43]; UINT8 cs_row_status; UINT8
* cs_attr[34]; UINT8 controller_id[32]; UINT8 domain_id[32] UINT8
* vrt_description[128]; UINT8 dhcp_relay_admin_status; };
*/
LOG.trace("Start getValVrtStruct");
-
final IpcStruct valVrtStruct = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.ValVrt.getValue());
-
if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.VROUTER)) {
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VROUTER).has(
- VtnServiceJsonConsts.CONTROLLERID)) {
+ JsonObject vRouter = requestBody.getAsJsonObject(VtnServiceJsonConsts.VROUTER);
+ if (vRouter.has(VtnServiceJsonConsts.CONTROLLERID)) {
valVrtStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVrtIndex.UPLL_IDX_CONTROLLER_ID_VRT
.set(VtnServiceJsonConsts.CONTROLLERID,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VROUTER)
- .get(VtnServiceJsonConsts.CONTROLLERID)
+ vRouter.get(VtnServiceJsonConsts.CONTROLLERID)
.getAsString(),
valVrtStruct,
UncStructIndexEnum.ValVrtIndex.UPLL_IDX_CONTROLLER_ID_VRT
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VROUTER).has(
- VtnServiceJsonConsts.DOMAINID)) {
+ if (vRouter.has(VtnServiceJsonConsts.DOMAINID)) {
valVrtStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVrtIndex.UPLL_IDX_DOMAIN_ID_VRT
.set(VtnServiceJsonConsts.DOMAINID,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VROUTER)
- .get(VtnServiceJsonConsts.DOMAINID)
+ vRouter.get(VtnServiceJsonConsts.DOMAINID)
.getAsString(),
valVrtStruct,
UncStructIndexEnum.ValVrtIndex.UPLL_IDX_DOMAIN_ID_VRT
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VROUTER).has(
- VtnServiceJsonConsts.DESCRIPTION)) {
+ if (vRouter.has(VtnServiceJsonConsts.DESCRIPTION)) {
valVrtStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVrtIndex.UPLL_IDX_DESC_VRT
.set(VtnServiceIpcConsts.VRTDESCRIPTION,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VROUTER)
- .get(VtnServiceJsonConsts.DESCRIPTION)
+ vRouter.get(VtnServiceJsonConsts.DESCRIPTION)
.getAsString(),
valVrtStruct,
UncStructIndexEnum.ValVrtIndex.UPLL_IDX_DESC_VRT
valVrtStruct
.set(VtnServiceIpcConsts.DHCPRELAYADMINSTATUS,
IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_ENABLE
- .getValue()));
+ .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_ENABLE.getValue(),
+ valVrtStruct, UncStructIndexEnum.ValVrtIndex.UPLL_IDX_DHCP_RELAY_ADMIN_STATUS_VRT.ordinal()));
} else {
valVrtStruct
.set(VtnServiceIpcConsts.DHCPRELAYADMINSTATUS,
IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_DISABLE
- .getValue()));
+ .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_DISABLE.getValue(),
+ valVrtStruct, UncStructIndexEnum.ValVrtIndex.UPLL_IDX_DHCP_RELAY_ADMIN_STATUS_VRT.ordinal()));
}
LOG.debug("dhcp_relay_status"
+ requestBody
}
LOG.info("Value Structure: " + valVrtStruct.toString());
LOG.trace("Complete getValVrtStruct");
-
return valVrtStruct;
}
public IpcStruct getValVrtIfStruct(final JsonObject requestBody,
final List<String> uriParameters) {
// Lower level structure
-
/*
* ipc_struct val_vrt_if { UINT8 valid[5]; UINT8 cs_row_status; UINT8
* cs_attr[5]; UINT8 description[128]; IPV4 ip_addr; UINT8 prefixlen;
LOG.trace("Start getValVrtIfStruct");
final IpcStruct valVrtIfStruct = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.ValVrtIf.getValue());
-
if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.INTERFACE)) {
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.INTERFACE)
- .has(VtnServiceJsonConsts.DESCRIPTION)) {
+ JsonObject vRouterIf = requestBody.getAsJsonObject(VtnServiceJsonConsts.INTERFACE);
+ if (vRouterIf.has(VtnServiceJsonConsts.DESCRIPTION)) {
valVrtIfStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVrtIfIndex.UPLL_IDX_DESC_VI
.set(VtnServiceJsonConsts.DESCRIPTION,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.INTERFACE)
- .get(VtnServiceJsonConsts.DESCRIPTION)
+ vRouterIf.get(VtnServiceJsonConsts.DESCRIPTION)
.getAsString(),
valVrtIfStruct,
UncStructIndexEnum.ValVrtIfIndex.UPLL_IDX_DESC_VI
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.INTERFACE)
- .has(VtnServiceJsonConsts.IPADDR)) {
+ if (vRouterIf.has(VtnServiceJsonConsts.IPADDR)) {
valVrtIfStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVrtIfIndex.UPLL_IDX_IP_ADDR_VI
.ordinal()));
valVrtIfStruct.set(VtnServiceIpcConsts.IP_ADDR,
IpcDataUnitWrapper
- .setIpcInet4AddressValue(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.INTERFACE)
- .get(VtnServiceJsonConsts.IPADDR)
- .getAsString()));
+ .setIpcInet4AddressValue(vRouterIf.get(VtnServiceJsonConsts.IPADDR).getAsString(),
+ valVrtIfStruct, UncStructIndexEnum.ValVrtIfIndex.UPLL_IDX_IP_ADDR_VI.ordinal()));
} else {
valVrtIfStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.INTERFACE)
- .has(VtnServiceJsonConsts.NETMASK)) {
+ if (vRouterIf.has(VtnServiceJsonConsts.PREFIX)) {
valVrtIfStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVrtIfIndex.UPLL_IDX_PREFIXLEN_VI
.ordinal()));
valVrtIfStruct.set(VtnServiceIpcConsts.PREFIXLEN,
IpcDataUnitWrapper
- .setIpcUint8Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.INTERFACE)
- .get(VtnServiceJsonConsts.NETMASK)
- .getAsString()));
+ .setIpcUint8Value(vRouterIf.get(VtnServiceJsonConsts.PREFIX).getAsString(),
+ valVrtIfStruct, UncStructIndexEnum.ValVrtIfIndex.UPLL_IDX_PREFIXLEN_VI.ordinal()));
} else {
valVrtIfStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.INTERFACE)
- .has(VtnServiceJsonConsts.MACADDR)) {
+ if (vRouterIf.has(VtnServiceJsonConsts.MACADDR)) {
valVrtIfStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVrtIfIndex.UPLL_IDX_MAC_ADDR_VI
.setMacAddress(
valVrtIfStruct,
VtnServiceIpcConsts.MACADDR,
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.INTERFACE)
- .get(VtnServiceJsonConsts.MACADDR)
- .getAsString());
+ vRouterIf.get(VtnServiceJsonConsts.MACADDR).getAsString(),
+ UncStructIndexEnum.ValVrtIfIndex.UPLL_IDX_MAC_ADDR_VI.ordinal());
} else {
valVrtIfStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.INTERFACE)
- .has(VtnServiceJsonConsts.ADMINSTATUS)) {
+ if (vRouterIf.has(VtnServiceJsonConsts.ADMINSTATUS)) {
valVrtIfStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVrtIfIndex.UPLL_IDX_ADMIN_ST_VI
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
.ordinal()));
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.INTERFACE)
- .get(VtnServiceJsonConsts.ADMINSTATUS).getAsString()
+ if (vRouterIf.get(VtnServiceJsonConsts.ADMINSTATUS).getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.DISABLE)) {
-
valVrtIfStruct
.set(VtnServiceJsonConsts.ADMIN_STATUS,
IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_DISABLE
- .getValue()));
+ .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_DISABLE.getValue(),
+ valVrtIfStruct, UncStructIndexEnum.ValVrtIfIndex.UPLL_IDX_ADMIN_ST_VI.ordinal()));
} else {
valVrtIfStruct
.set(VtnServiceJsonConsts.ADMIN_STATUS,
IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_ENABLE
- .getValue()));
+ .setIpcUint8Value(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_ENABLE.getValue(),
+ valVrtIfStruct, UncStructIndexEnum.ValVrtIfIndex.UPLL_IDX_ADMIN_ST_VI.ordinal()));
}
LOG.debug("adminstatus:"
- + requestBody
- .getAsJsonObject(VtnServiceJsonConsts.INTERFACE)
- .get(VtnServiceJsonConsts.ADMINSTATUS)
+ + vRouterIf.get(VtnServiceJsonConsts.ADMINSTATUS)
.getAsString());
} else {
valVrtIfStruct
LOG.warning("request body and uri parameters are not correct for getValVrtIfStruct");
}
LOG.info("Value Structure: " + valVrtIfStruct.toString());
- LOG.trace("Complete getKeyVtnStruct");
-
+ LOG.trace("Complete getValVrtIfStruct");
return valVrtIfStruct;
}
*/
public IpcStruct getValVtunnelStruct(final JsonObject requestBody,
final List<String> uriParameters) {
-
// Lower level structure
-
/*
* ipc_struct val_vtunnel { UINT8 valid[6]; UINT8 cs_row_status; UINT8
* cs_attr[6]; UINT8 description[128]; UINT8 controller_id[32]; UINT8
LOG.trace("Start getValVtunnelStruct");
final IpcStruct valVtunnelStruct = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.ValVtunnel.getValue());
-
if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.VTUNNEL)) {
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VTUNNEL).has(
- VtnServiceJsonConsts.DESCRIPTION)) {
+ JsonObject vTunnel = requestBody.getAsJsonObject(VtnServiceJsonConsts.VTUNNEL);
+ if (vTunnel.has(VtnServiceJsonConsts.DESCRIPTION)) {
valVtunnelStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVtunnelIndex.UPLL_IDX_DESC_VTNL
.set(VtnServiceJsonConsts.DESCRIPTION,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VTUNNEL)
- .get(VtnServiceJsonConsts.DESCRIPTION)
+ vTunnel.get(VtnServiceJsonConsts.DESCRIPTION)
.getAsString(),
valVtunnelStruct,
UncStructIndexEnum.ValVtunnelIndex.UPLL_IDX_DESC_VTNL
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VTUNNEL).has(
- VtnServiceJsonConsts.CONTROLLERID)) {
+ if (vTunnel.has(VtnServiceJsonConsts.CONTROLLERID)) {
valVtunnelStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVtunnelIndex.UPLL_IDX_CONTROLLER_ID_VTNL
.set(VtnServiceJsonConsts.CONTROLLERID,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VTUNNEL)
- .get(VtnServiceJsonConsts.CONTROLLERID)
+ vTunnel.get(VtnServiceJsonConsts.CONTROLLERID)
.getAsString(),
valVtunnelStruct,
UncStructIndexEnum.ValVtunnelIndex.UPLL_IDX_CONTROLLER_ID_VTNL
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VTUNNEL).has(
- VtnServiceJsonConsts.DOMAINID)) {
+ if (vTunnel.has(VtnServiceJsonConsts.DOMAINID)) {
valVtunnelStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVtunnelIndex.UPLL_IDX_DOMAIN_ID_VTNL
.set(VtnServiceJsonConsts.DOMAINID,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VTUNNEL)
- .get(VtnServiceJsonConsts.DOMAINID)
+ vTunnel.get(VtnServiceJsonConsts.DOMAINID)
.getAsString(),
valVtunnelStruct,
UncStructIndexEnum.ValVtunnelIndex.UPLL_IDX_DOMAIN_ID_VTNL
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VTUNNEL).has(
- VtnServiceJsonConsts.VTNNAME)) {
+ if (vTunnel.has(VtnServiceJsonConsts.VTNNAME)) {
valVtunnelStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVtunnelIndex.UPLL_IDX_VTN_NAME_VTNL
.set(VtnServiceIpcConsts.VTNNAME,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VTUNNEL)
- .get(VtnServiceJsonConsts.VTNNAME)
+ vTunnel.get(VtnServiceJsonConsts.VTNNAME)
.getAsString(),
valVtunnelStruct,
UncStructIndexEnum.ValVtunnelIndex.UPLL_IDX_VTN_NAME_VTNL
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VTUNNEL).has(
- VtnServiceJsonConsts.VTEPGROUPNAME)) {
+ if (vTunnel.has(VtnServiceJsonConsts.VTEPGROUPNAME)) {
valVtunnelStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVtunnelIndex.UPLL_IDX_VTEP_GRP_NAME_VTNL
.set(VtnServiceIpcConsts.VTEPGRPNAME,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VTUNNEL)
- .get(VtnServiceJsonConsts.VTEPGROUPNAME)
+ vTunnel.get(VtnServiceJsonConsts.VTEPGROUPNAME)
.getAsString(),
valVtunnelStruct,
UncStructIndexEnum.ValVtunnelIndex.UPLL_IDX_VTEP_GRP_NAME_VTNL
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.VTUNNEL).has(
- VtnServiceJsonConsts.LABEL)) {
+ if (vTunnel.has(VtnServiceJsonConsts.LABEL)) {
valVtunnelStruct
.set(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVtunnelIndex.UPLL_IDX_LABEL_VTNL
valVtunnelStruct
.set(VtnServiceIpcConsts.LABEL, IpcDataUnitWrapper
- .setIpcUint32Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VTUNNEL)
- .get(VtnServiceJsonConsts.LABEL)
- .getAsString()));
+ .setIpcUint32Value(vTunnel.get(VtnServiceJsonConsts.LABEL).getAsString(),
+ valVtunnelStruct, UncStructIndexEnum.ValVtunnelIndex.UPLL_IDX_LABEL_VTNL.ordinal()));
} else {
valVtunnelStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
} else {
LOG.warning("request body and uri parameters are not correct for getValVtunnelStruct");
}
LOG.info("Value Structure: " + valVtunnelStruct.toString());
LOG.trace("Complete getValVtunnelStruct");
-
return valVtunnelStruct;
}
*/
public IpcStruct getKeyVtnFlowfilterControllerStruct(
final JsonObject requestBody, final List<String> uriParameters) {
-
// Lower level structure
/*
* ipc_struct KeyVtnFlowfilterController { KeyVtn vtn_key; UINT8
LOG.info("Key Structure: "
+ keyVtnFlowfilterControllerStruct.toString());
LOG.trace("Complete getKeyVtnFlowfilterControllerStruct");
-
return keyVtnFlowfilterControllerStruct;
}
*/
public IpcStruct getValFlowFilterControllerStruct(
final JsonObject requestBody, final List<String> uriParameters) {
-
// Lower level structure
/*
* ipc_struct ValFlowFilterController{ UINT8 valid[2]; UINT8 direction;
LOG.trace("Start getValFlowFilterControllerStruct");
final IpcStruct valFlowFilterContollerStruct = new IpcStruct(
UncStructEnum.ValFlowFilterController.getValue());
-
if (uriParameters != null) {
if (uriParameters.size() >= UncIndexEnum.THREE.ordinal()) {
valFlowFilterContollerStruct
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
if (uriParameters.size() == UncIndexEnum.THREE.ordinal()) {
valFlowFilterContollerStruct
.set(VtnServiceIpcConsts.VALID,
.ordinal()));
valFlowFilterContollerStruct.set(
VtnServiceIpcConsts.SEQUENCENUM, IpcDataUnitWrapper
- .setIpcUint16Value(uriParameters.get(2)));
+ .setIpcUint16Value(uriParameters.get(2),
+ valFlowFilterContollerStruct, UncStructIndexEnum.ValFlowfilterControllerIndex.UPLL_IDX_SEQ_NUM_FFC.ordinal()));
} else {
valFlowFilterContollerStruct
.set(VtnServiceIpcConsts.VALID,
}
LOG.info("Key Structure: " + keyVtepGrpStruct.toString());
LOG.trace("Complete getKeyVtepGrpStruct");
-
return keyVtepGrpStruct;
}
}
LOG.info("Key Structure: " + keyVtepGrpMemberStruct.toString());
LOG.trace("Complete getKeyVtepGrpMemberStruct");
-
return keyVtepGrpMemberStruct;
}
LOG.trace("Start getValVtepGrpStruct");
final IpcStruct valVtepGrpStruct = new IpcStruct(
UncStructEnum.ValVtepGrp.getValue());
-
- if (requestBody != null
- && requestBody.has(VtnServiceJsonConsts.VTEPGROUP)
- && requestBody.getAsJsonObject(VtnServiceJsonConsts.VTEPGROUP)
- .has(VtnServiceJsonConsts.CONTROLLERID)) {
- valVtepGrpStruct
- .set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.val_vtep_grp_index.UPLL_IDX_CONTROLLER_ID_VTEPG
- .ordinal(),
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
- .ordinal()));
- valVtepGrpStruct
- .set(VtnServiceIpcConsts.CONTROLLERID,
- IpcDataUnitWrapper
- .setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VTEPGROUP)
- .get(VtnServiceJsonConsts.CONTROLLERID)
- .getAsString(),
- valVtepGrpStruct,
- UncStructIndexEnum.val_vtep_grp_index.UPLL_IDX_CONTROLLER_ID_VTEPG
- .ordinal()));
- } else {
- valVtepGrpStruct
- .set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.val_vtep_grp_index.UPLL_IDX_CONTROLLER_ID_VTEPG
- .ordinal(),
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
- .ordinal()));
- }
-
if (requestBody != null
- && requestBody.has(VtnServiceJsonConsts.VTEPGROUP)
- && requestBody.getAsJsonObject(VtnServiceJsonConsts.VTEPGROUP)
- .has(VtnServiceJsonConsts.DESCRIPTION)) {
- valVtepGrpStruct
- .set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.val_vtep_grp_index.UPLL_IDX_DESCRIPTION_VTEPG
- .ordinal(),
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
- .ordinal()));
- valVtepGrpStruct
- .set(VtnServiceIpcConsts.DESCRIPTION,
- IpcDataUnitWrapper
- .setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.VTEPGROUP)
- .get(VtnServiceJsonConsts.DESCRIPTION)
- .getAsString(),
- valVtepGrpStruct,
- UncStructIndexEnum.val_vtep_grp_index.UPLL_IDX_DESCRIPTION_VTEPG
- .ordinal()));
- } else {
- valVtepGrpStruct
- .set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.val_vtep_grp_index.UPLL_IDX_CONTROLLER_ID_VTEPG
- .ordinal(),
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
- .ordinal()));
+ && requestBody.has(VtnServiceJsonConsts.VTEPGROUP)) {
+ JsonObject vTepGroup = requestBody
+ .getAsJsonObject(VtnServiceJsonConsts.VTEPGROUP);
+ if (vTepGroup.has(VtnServiceJsonConsts.CONTROLLERID)) {
+ valVtepGrpStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.val_vtep_grp_index.UPLL_IDX_CONTROLLER_ID_VTEPG
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
+ .ordinal()));
+ valVtepGrpStruct
+ .set(VtnServiceIpcConsts.CONTROLLERID,
+ IpcDataUnitWrapper
+ .setIpcUint8ArrayValue(
+ vTepGroup
+ .get(VtnServiceJsonConsts.CONTROLLERID)
+ .getAsString(),
+ valVtepGrpStruct,
+ UncStructIndexEnum.val_vtep_grp_index.UPLL_IDX_CONTROLLER_ID_VTEPG
+ .ordinal()));
+ } else {
+ valVtepGrpStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.val_vtep_grp_index.UPLL_IDX_CONTROLLER_ID_VTEPG
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()));
+ }
+ if (vTepGroup.has(VtnServiceJsonConsts.DESCRIPTION)) {
+ valVtepGrpStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.val_vtep_grp_index.UPLL_IDX_DESCRIPTION_VTEPG
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
+ .ordinal()));
+ valVtepGrpStruct
+ .set(VtnServiceIpcConsts.DESCRIPTION,
+ IpcDataUnitWrapper
+ .setIpcUint8ArrayValue(
+ vTepGroup
+ .get(VtnServiceJsonConsts.DESCRIPTION)
+ .getAsString(),
+ valVtepGrpStruct,
+ UncStructIndexEnum.val_vtep_grp_index.UPLL_IDX_DESCRIPTION_VTEPG
+ .ordinal()));
+ } else {
+ valVtepGrpStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.val_vtep_grp_index.UPLL_IDX_DESCRIPTION_VTEPG
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()));
+ }
}
-
LOG.info("Value Structure: " + valVtepGrpStruct.toString());
LOG.trace("Complete getValVtepGrpStruct");
-
return valVtepGrpStruct;
}
LOG.trace("Start getValStaticIpRouteStruct");
final IpcStruct valStaticIpRouteStruct = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.ValStaticIpRoute.getValue());
-
- if (requestBody != null
- && requestBody.has(VtnServiceJsonConsts.STATIC_IPROUTE)
- && requestBody.getAsJsonObject(
- VtnServiceJsonConsts.STATIC_IPROUTE).has(
- VtnServiceJsonConsts.GROUPMETRIC)) {
- valStaticIpRouteStruct
- .set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValStaticIpRouteIndex.UPLL_IDX_GROUP_METRIC_SIR
- .ordinal(),
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
- .ordinal()));
- valStaticIpRouteStruct.set(
- VtnServiceIpcConsts.GROUP_METRIC,
- IpcDataUnitWrapper.setIpcUint16Value(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.STATIC_IPROUTE)
- .get(VtnServiceJsonConsts.GROUPMETRIC)
- .getAsString()));
+ if (requestBody != null) {
+ if (requestBody.has(VtnServiceJsonConsts.STATIC_IPROUTE)
+ && requestBody.getAsJsonObject(
+ VtnServiceJsonConsts.STATIC_IPROUTE).has(
+ VtnServiceJsonConsts.GROUPMETRIC)) {
+ valStaticIpRouteStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValStaticIpRouteIndex.UPLL_IDX_GROUP_METRIC_SIR
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
+ .ordinal()));
+ valStaticIpRouteStruct.set(
+ VtnServiceIpcConsts.GROUP_METRIC,
+ IpcDataUnitWrapper.setIpcUint16Value(requestBody
+ .getAsJsonObject(VtnServiceJsonConsts.STATIC_IPROUTE)
+ .get(VtnServiceJsonConsts.GROUPMETRIC).getAsString(),
+ valStaticIpRouteStruct, UncStructIndexEnum.ValStaticIpRouteIndex.UPLL_IDX_GROUP_METRIC_SIR.ordinal()));
+ } else {
+ valStaticIpRouteStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValStaticIpRouteIndex.UPLL_IDX_GROUP_METRIC_SIR
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()));
+ }
} else {
- valStaticIpRouteStruct
- .set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValStaticIpRouteIndex.UPLL_IDX_GROUP_METRIC_SIR
- .ordinal(),
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
- .ordinal()));
+ LOG.warning("Request body and uri parameters are not correct for getValStaticIpRouteStruct");
}
- LOG.warning("request body and uri parameters are not correct for getValStaticIpRouteStruct");
LOG.info("Value Structure: " + valStaticIpRouteStruct.toString());
LOG.trace("Complete getValStaticIpRouteStruct");
-
return valStaticIpRouteStruct;
}
final IpcStruct keyVtnstationController = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.KeyVtnstationController
.getValue());
-
/*
* Check if controller_id is available in request body then set the same
* to Key Structure
&& requestBody.has(VtnServiceJsonConsts.CONTROLLERID)) {
// in case op is count then, Key Structure's controller_id will not
// be set
- if (requestBody.has(VtnServiceJsonConsts.OP)
- && !requestBody.get(VtnServiceJsonConsts.OP).getAsString()
- .equalsIgnoreCase(VtnServiceJsonConsts.COUNT)) {
+ if (requestBody.has(VtnServiceJsonConsts.OP)) {
keyVtnstationController.set(VtnServiceIpcConsts.CONTROLLERNAME,
IpcDataUnitWrapper.setIpcUint8ArrayValue(requestBody
.get(VtnServiceJsonConsts.CONTROLLERID)
}
LOG.info("Key Structure: " + keyVtnstationController.toString());
LOG.trace("Complete getKeyVtnstationControllerStruct");
-
return keyVtnstationController;
}
final IpcStruct valVtnstationControllerSt = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.ValVtnstationControllerSt
.getValue());
-
/*
* If optional parameters are available in request body then add the
* same to Value structure and set the valid bit
*/
if (requestBody != null) {
-
// for station_id parameter
valVtnstationControllerSt
.set(VtnServiceIpcConsts.VALID,
.ordinal()));
IpcDataUnitWrapper.setMacAddress(valVtnstationControllerSt,
VtnServiceIpcConsts.MAC_ADDR,
- requestBody.get(VtnServiceJsonConsts.MACADDR)
- .getAsString());
+ requestBody.get(VtnServiceJsonConsts.MACADDR).getAsString(),
+ UncStructIndexEnum.ValVtnstationControllerStIndex.UPLL_IDX_MAC_ADDR_VSCS.ordinal());
} else {
valVtnstationControllerSt
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
// for ipv4_count parameter
if (requestBody.has(VtnServiceJsonConsts.IPADDR)) {
valVtnstationControllerSt
.ordinal()));
valVtnstationControllerSt.set(VtnServiceIpcConsts.IPV4_COUNT,
IpcDataUnitWrapper
- .setIpcUint32Value(VtnServiceJsonConsts.ONE));
+ .setIpcUint32Value(VtnServiceJsonConsts.ONE,
+ valVtnstationControllerSt, UncStructIndexEnum.ValVtnstationControllerStIndex.UPLL_IDX_IPV4_COUNT_VSCS.ordinal()));
} else {
valVtnstationControllerSt
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
// for ipv6_count parameter
if (requestBody.has(VtnServiceJsonConsts.IPV6ADDR)) {
valVtnstationControllerSt
.ordinal()));
valVtnstationControllerSt.set(VtnServiceIpcConsts.IPV6_COUNT,
IpcDataUnitWrapper
- .setIpcUint32Value(VtnServiceJsonConsts.ONE));
+ .setIpcUint32Value(VtnServiceJsonConsts.ONE,
+ valVtnstationControllerSt, UncStructIndexEnum.ValVtnstationControllerStIndex.UPLL_IDX_IPV6_COUNT_VSCS.ordinal()));
} else {
valVtnstationControllerSt
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
// for switch_id parameter
if (requestBody.has(VtnServiceJsonConsts.SWITCHID)) {
valVtnstationControllerSt
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
// for port_name parameter
if (requestBody.has(VtnServiceJsonConsts.PORTNAME)) {
valVtnstationControllerSt
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
// for vlan_id parameter
if (requestBody.has(VtnServiceJsonConsts.VLANID) || requestBody.has(VtnServiceJsonConsts.NO_VLAN_ID)) {
valVtnstationControllerSt
valVtnstationControllerSt.set(
VtnServiceIpcConsts.VLANID,
IpcDataUnitWrapper.setIpcUint16Value(requestBody.get(
- VtnServiceJsonConsts.VLANID).getAsString()));
+ VtnServiceJsonConsts.VLANID).getAsString(),
+ valVtnstationControllerSt, UncStructIndexEnum.ValVtnstationControllerStIndex.UPLL_IDX_VLAN_ID_VSCS.ordinal()));
} else {
valVtnstationControllerSt
.set(VtnServiceIpcConsts.VLANID,
IpcDataUnitWrapper
- .setIpcUint16HexaValue(VtnServiceIpcConsts.VLAN_ID_DEFAULT_VALUE));
+ .setIpcUint16HexaValue(VtnServiceIpcConsts.VLAN_ID_DEFAULT_VALUE,
+ valVtnstationControllerSt,
+ UncStructIndexEnum.ValVtnstationControllerStIndex.UPLL_IDX_VLAN_ID_VSCS.ordinal()));
}
} else {
valVtnstationControllerSt
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
// for map_type parameter
valVtnstationControllerSt
.set(VtnServiceIpcConsts.VALID,
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
-
// for map_status parameter
valVtnstationControllerSt
.set(VtnServiceIpcConsts.VALID,
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
-
// for vtn_name parameter
if (requestBody.has(VtnServiceJsonConsts.VTNNAME)) {
valVtnstationControllerSt
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
// for domain_id parameter
if (requestBody.has(VtnServiceJsonConsts.DOMAINID)) {
valVtnstationControllerSt
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
// for vbr_name parameter
if (requestBody.has(VtnServiceJsonConsts.VBRNAME)) {
valVtnstationControllerSt
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
// for if_name parameter
if (requestBody.has(VtnServiceJsonConsts.IFNAME)) {
valVtnstationControllerSt
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
// for vbrif_status parameter
valVtnstationControllerSt
.set(VtnServiceIpcConsts.VALID,
}
LOG.info("Value Structure: " + valVtnstationControllerSt.toString());
LOG.trace("Complete getValVtnstationControllerStStruct");
-
return valVtnstationControllerSt;
}
final IpcStruct keyCtrDomain = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.KeyCtrDomain.getValue());
IpcStruct keyCtrStruct = null;
-
if (uriParameters != null
&& uriParameters.size() >= UncIndexEnum.ONE.ordinal()) {
// call Controller Key
uriParameters.subList(0, 1));
}
keyCtrDomain.set(VtnServiceIpcConsts.CTR_KEY, keyCtrStruct);
-
if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.DOMAIN)
&& ((JsonObject) requestBody.get(VtnServiceJsonConsts.DOMAIN))
}
LOG.info("Key Structure: " + keyCtrDomain.toString());
LOG.trace("Complete getKeyCtrDomainStruct");
-
return keyCtrDomain;
}
*/
public IpcStruct getKeySwitchStruct(final JsonObject requestBody,
final List<String> uriParameters) {
-
// Key structure
/*
* ipc_struct key_switch{ key_ctr ctr_key; UINT8 switch_id[256]; };
final IpcStruct keySwitch = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.KeySwitch.getValue());
IpcStruct keyCtrStruct = null;
-
if (uriParameters != null
&& uriParameters.size() >= UncIndexEnum.ONE.ordinal()) {
// call Controller Key
uriParameters.subList(0, 1));
}
keySwitch.set(VtnServiceIpcConsts.CTR_KEY, keyCtrStruct);
-
if (uriParameters != null
&& uriParameters.size() == UncIndexEnum.TWO.ordinal()) {
keySwitch.set(VtnServiceJsonConsts.SWITCHID, IpcDataUnitWrapper
}
LOG.info("Key Structure: " + keySwitch.toString());
LOG.trace("Complete getKeySwitchStruct");
-
return keySwitch;
}
uriParameters.subList(0, 1));
keyLink.set(VtnServiceIpcConsts.CTR_KEY, keyLinkStruct);
}
-
if (requestBody != null && requestBody.has(VtnServiceJsonConsts.INDEX)) {
String linkName[] = requestBody.get(VtnServiceJsonConsts.INDEX)
.getAsString().split(VtnServiceJsonConsts.LINKSAPERATOR);
}
} else if (uriParameters != null
&& uriParameters.size() == UncIndexEnum.TWO.ordinal()) {
-
String linkName[] = uriParameters.get(1).split(
VtnServiceJsonConsts.LINKSAPERATOR);
if (linkName.length == UncIndexEnum.FOUR.ordinal()) {
} else {
LOG.error("Value of linkname is incorrect");
}
+ } else if (requestBody != null
+ && (requestBody.has(VtnServiceJsonConsts.SWITCH1ID) || requestBody
+ .has(VtnServiceJsonConsts.SWITCH2ID))) {
+ if (requestBody.has(VtnServiceJsonConsts.SWITCH1ID)) {
+ keyLink.set(VtnServiceIpcConsts.SWITCH_ID1, IpcDataUnitWrapper
+ .setIpcUint8ArrayValue(requestBody.get(
+ VtnServiceJsonConsts.SWITCH1ID).getAsString()));
+ }
+
+ if (requestBody.has(VtnServiceJsonConsts.SWITCH2ID)) {
+ keyLink.set(VtnServiceIpcConsts.SWITCH_ID2, IpcDataUnitWrapper
+ .setIpcUint8ArrayValue(requestBody.get(
+ VtnServiceJsonConsts.SWITCH2ID).getAsString()));
+ }
} else {
LOG.warning("request body and uri parameters are not correct for getKeyLink");
}
}
LOG.info("Key Structure: " + keyCtrStruct.toString());
LOG.trace("Complete getKeyCtrStruct");
-
return keyCtrStruct;
}
LOG.trace("Start getValCtrStruct");
final IpcStruct valCtrStruct = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.ValCtr.getValue());
-
if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.CONTROLLER)) {
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.CONTROLLER)
- .has(VtnServiceJsonConsts.TYPE)) {
+ JsonObject controller = requestBody.getAsJsonObject(VtnServiceJsonConsts.CONTROLLER);
+ if (controller.has(VtnServiceJsonConsts.TYPE)) {
valCtrStruct
.set(VtnServiceIpcConsts.VALID,
UncPhysicalStructIndexEnum.UpplValCtrIndex.kIdxType
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
.ordinal()));
- if (requestBody
- .getAsJsonObject(VtnServiceJsonConsts.CONTROLLER)
- .get(VtnServiceJsonConsts.TYPE).getAsString()
+ if (controller.get(VtnServiceJsonConsts.TYPE).getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.BYPASS)) {
valCtrStruct
.set(VtnServiceJsonConsts.TYPE,
IpcDataUnitWrapper
.setIpcUint8Value(UncPhysicalStructIndexEnum.UpplTypeIndex.UNC_CT_UNKNOWN
.ordinal()));
- } else if (requestBody
- .getAsJsonObject(VtnServiceJsonConsts.CONTROLLER)
- .get(VtnServiceJsonConsts.TYPE).getAsString()
+ } else if (controller.get(VtnServiceJsonConsts.TYPE).getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.PFC)) {
valCtrStruct
.set(VtnServiceJsonConsts.TYPE,
IpcDataUnitWrapper
.setIpcUint8Value(UncPhysicalStructIndexEnum.UpplTypeIndex.UNC_CT_PFC
.ordinal()));
- } else if (requestBody
- .getAsJsonObject(VtnServiceJsonConsts.CONTROLLER)
- .get(VtnServiceJsonConsts.TYPE).getAsString()
+ } else if (controller.get(VtnServiceJsonConsts.TYPE).getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.VNP)) {
valCtrStruct
.set(VtnServiceJsonConsts.TYPE,
.ordinal()));
}
LOG.debug("type:"
- + requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.CONTROLLER)
- .get(VtnServiceJsonConsts.TYPE).getAsString());
+ + controller.get(VtnServiceJsonConsts.TYPE).getAsString());
} else {
valCtrStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.CONTROLLER)
- .has(VtnServiceJsonConsts.VERSION)) {
+ if (controller.has(VtnServiceJsonConsts.VERSION)) {
valCtrStruct
.set(VtnServiceIpcConsts.VALID,
UncPhysicalStructIndexEnum.UpplValCtrIndex.kIdxVersion
.set(VtnServiceJsonConsts.VERSION,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.CONTROLLER)
- .get(VtnServiceJsonConsts.VERSION)
+ controller.get(VtnServiceJsonConsts.VERSION)
.getAsString(),
valCtrStruct,
UncPhysicalStructIndexEnum.UpplValCtrIndex.kIdxVersion
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.CONTROLLER)
- .has(VtnServiceJsonConsts.DESCRIPTION)) {
+ if (controller.has(VtnServiceJsonConsts.DESCRIPTION)) {
valCtrStruct
.set(VtnServiceIpcConsts.VALID,
UncPhysicalStructIndexEnum.UpplValCtrIndex.kIdxDescription
.set(VtnServiceJsonConsts.DESCRIPTION,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.CONTROLLER)
- .get(VtnServiceJsonConsts.DESCRIPTION)
+ controller.get(VtnServiceJsonConsts.DESCRIPTION)
.getAsString(),
valCtrStruct,
UncPhysicalStructIndexEnum.UpplValCtrIndex.kIdxDescription
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.CONTROLLER)
- .has(VtnServiceJsonConsts.IPADDR)) {
+ if (controller.has(VtnServiceJsonConsts.IPADDR)) {
valCtrStruct
.set(VtnServiceIpcConsts.VALID,
UncPhysicalStructIndexEnum.UpplValCtrIndex.kIdxIpAddress
valCtrStruct
.set(VtnServiceIpcConsts.IP_ADDRESS,
IpcDataUnitWrapper
- .setIpcInet4AddressValue(requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.CONTROLLER)
- .get(VtnServiceJsonConsts.IPADDR)
- .getAsString()));
+ .setIpcInet4AddressValue(controller.get(VtnServiceJsonConsts.IPADDR).getAsString(),
+ valCtrStruct, UncPhysicalStructIndexEnum.UpplValCtrIndex.kIdxIpAddress.ordinal()));
} else {
valCtrStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.CONTROLLER)
- .has(VtnServiceJsonConsts.USERNAME)) {
+ if (controller.has(VtnServiceJsonConsts.USERNAME)) {
valCtrStruct
.set(VtnServiceIpcConsts.VALID,
UncPhysicalStructIndexEnum.UpplValCtrIndex.kIdxUser
.set(VtnServiceIpcConsts.USER,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.CONTROLLER)
- .get(VtnServiceJsonConsts.USERNAME)
+ controller.get(VtnServiceJsonConsts.USERNAME)
.getAsString(),
valCtrStruct,
UncPhysicalStructIndexEnum.UpplValCtrIndex.kIdxUser
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.CONTROLLER)
- .has(VtnServiceJsonConsts.PASSWORD)) {
+ if (controller.has(VtnServiceJsonConsts.PASSWORD)) {
valCtrStruct
.set(VtnServiceIpcConsts.VALID,
UncPhysicalStructIndexEnum.UpplValCtrIndex.kIdxPassword
.set(VtnServiceJsonConsts.PASSWORD,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.CONTROLLER)
- .get(VtnServiceJsonConsts.PASSWORD)
+ controller.get(VtnServiceJsonConsts.PASSWORD)
.getAsString(),
valCtrStruct,
UncPhysicalStructIndexEnum.UpplValCtrIndex.kIdxPassword
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.CONTROLLER)
- .has(VtnServiceJsonConsts.AUDITSTATUS)) {
+ if (controller.has(VtnServiceJsonConsts.AUDITSTATUS)) {
valCtrStruct
.set(VtnServiceIpcConsts.VALID,
UncPhysicalStructIndexEnum.UpplValCtrIndex.kIdxEnableAudit
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
.ordinal()));
- if (requestBody
- .getAsJsonObject(VtnServiceJsonConsts.CONTROLLER)
- .get(VtnServiceJsonConsts.AUDITSTATUS).getAsString()
+ if (controller.get(VtnServiceJsonConsts.AUDITSTATUS).getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.DISABLE)) {
valCtrStruct
.set(VtnServiceIpcConsts.ENABLE_AUDIT,
IpcDataUnitWrapper
.setIpcUint8Value(UncPhysicalStructIndexEnum.UpplControllerAuditStatus.UPPL_AUTO_AUDIT_DISABLED
.ordinal()));
- } else if (requestBody
- .getAsJsonObject(VtnServiceJsonConsts.CONTROLLER)
- .get(VtnServiceJsonConsts.AUDITSTATUS).getAsString()
+ } else if (controller.get(VtnServiceJsonConsts.AUDITSTATUS).getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.ENABLE)) {
valCtrStruct
.set(VtnServiceIpcConsts.ENABLE_AUDIT,
.ordinal()));
}
LOG.debug("auditstatus"
- + requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.CONTROLLER)
- .get(VtnServiceJsonConsts.AUDITSTATUS)
+ + controller.get(VtnServiceJsonConsts.AUDITSTATUS)
.getAsString());
} else {
valCtrStruct
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
} else {
LOG.warning("request body and uri parameters are not correct for getValCtrStruct");
}
LOG.trace("Start getValCtrDomainStruct");
final IpcStruct valCtrDomainStruct = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.ValCtrDomain.getValue());
-
if (requestBody != null && requestBody.has(VtnServiceJsonConsts.DOMAIN)) {
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.DOMAIN).has(
- VtnServiceJsonConsts.TYPE)) {
+ JsonObject domain = requestBody.getAsJsonObject(VtnServiceJsonConsts.DOMAIN);
+ if (domain.has(VtnServiceJsonConsts.TYPE)) {
valCtrDomainStruct
.set(VtnServiceIpcConsts.VALID,
UncPhysicalStructIndexEnum.UpplValDomainIndex.kIdxDomainType
IpcDataUnitWrapper
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
.ordinal()));
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.DOMAIN)
- .get(VtnServiceJsonConsts.TYPE).getAsString()
+ if (domain.get(VtnServiceJsonConsts.TYPE).getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.DEFAULT)) {
valCtrDomainStruct
.set(VtnServiceJsonConsts.TYPE,
IpcDataUnitWrapper
.setIpcUint8Value(UncPhysicalStructIndexEnum.UpplDomainType.UPPL_DOMAIN_TYPE_DEFAULT
.ordinal()));
- } else if (requestBody
- .getAsJsonObject(VtnServiceJsonConsts.DOMAIN)
- .get(VtnServiceJsonConsts.TYPE).getAsString()
+ } else if (domain.get(VtnServiceJsonConsts.TYPE).getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.NORMAL)) {
valCtrDomainStruct
.set(VtnServiceJsonConsts.TYPE,
.ordinal()));
}
LOG.debug("type:"
- + requestBody
- .getAsJsonObject(VtnServiceJsonConsts.DOMAIN)
- .get(VtnServiceJsonConsts.TYPE).getAsString());
+ + domain.get(VtnServiceJsonConsts.TYPE).getAsString());
} else {
valCtrDomainStruct
.set(VtnServiceIpcConsts.VALID,
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.DOMAIN).has(
- VtnServiceJsonConsts.DESCRIPTION)) {
+ if (domain.has(VtnServiceJsonConsts.DESCRIPTION)) {
valCtrDomainStruct
.set(VtnServiceIpcConsts.VALID,
UncPhysicalStructIndexEnum.UpplValDomainIndex.kIdxDomainDescription
.set(VtnServiceJsonConsts.DESCRIPTION,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.DOMAIN)
- .get(VtnServiceJsonConsts.DESCRIPTION)
+ domain.get(VtnServiceJsonConsts.DESCRIPTION)
.getAsString(),
valCtrDomainStruct,
UncPhysicalStructIndexEnum.UpplValDomainIndex.kIdxDomainDescription
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
} else {
LOG.warning("request body and uri parameters are not correct for getValCtrDomainStruct");
}
LOG.info("Value Structure: " + valCtrDomainStruct.toString());
LOG.trace("Complete getValCtrDomainStruct");
-
return valCtrDomainStruct;
}
LOG.trace("Start getValBoundaryStruct");
final IpcStruct valBoundaryStruct = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.ValBoundary.getValue());
-
if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.BOUNDARY)) {
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.BOUNDARY).has(
- VtnServiceJsonConsts.DESCRIPTION)) {
+ JsonObject boundary = requestBody.getAsJsonObject(VtnServiceJsonConsts.BOUNDARY);
+ if (boundary.has(VtnServiceJsonConsts.DESCRIPTION)) {
valBoundaryStruct
.set(VtnServiceIpcConsts.VALID,
UncPhysicalStructIndexEnum.UpplValBoundaryIndex.kIdxBoundaryDescription
.set(VtnServiceJsonConsts.DESCRIPTION,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.BOUNDARY)
- .get(VtnServiceJsonConsts.DESCRIPTION)
+ boundary.get(VtnServiceJsonConsts.DESCRIPTION)
.getAsString(),
valBoundaryStruct,
UncPhysicalStructIndexEnum.UpplValBoundaryIndex.kIdxBoundaryDescription
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.BOUNDARY).has(
- VtnServiceJsonConsts.LINK)) {
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.BOUNDARY)
- .getAsJsonObject(VtnServiceJsonConsts.LINK)
- .has(VtnServiceJsonConsts.CONTROLLER1ID)) {
+ if (boundary.has(VtnServiceJsonConsts.LINK)) {
+ JsonObject link = boundary.getAsJsonObject(VtnServiceJsonConsts.LINK);
+ if (link.has(VtnServiceJsonConsts.CONTROLLER1ID)) {
valBoundaryStruct
.set(VtnServiceIpcConsts.VALID,
UncPhysicalStructIndexEnum.UpplValBoundaryIndex.kIdxBoundaryControllerName1
.set(VtnServiceIpcConsts.CONTROLLER_NAME1,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.BOUNDARY)
- .getAsJsonObject(
- VtnServiceJsonConsts.LINK)
- .get(VtnServiceJsonConsts.CONTROLLER1ID)
+ link.get(VtnServiceJsonConsts.CONTROLLER1ID)
.getAsString(),
valBoundaryStruct,
UncPhysicalStructIndexEnum.UpplValBoundaryIndex.kIdxBoundaryControllerName1
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.BOUNDARY)
- .getAsJsonObject(VtnServiceJsonConsts.LINK)
- .has(VtnServiceJsonConsts.DOMAIN1_ID)) {
+ if (link.has(VtnServiceJsonConsts.DOMAIN1_ID)) {
valBoundaryStruct
.set(VtnServiceIpcConsts.VALID,
UncPhysicalStructIndexEnum.UpplValBoundaryIndex.kIdxBoundaryDomainName1
.set(VtnServiceIpcConsts.DOMAIN_NAME1,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.BOUNDARY)
- .getAsJsonObject(
- VtnServiceJsonConsts.LINK)
- .get(VtnServiceJsonConsts.DOMAIN1_ID)
+ link.get(VtnServiceJsonConsts.DOMAIN1_ID)
.getAsString(),
valBoundaryStruct,
UncPhysicalStructIndexEnum.UpplValBoundaryIndex.kIdxBoundaryDomainName1
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.BOUNDARY)
- .getAsJsonObject(VtnServiceJsonConsts.LINK)
- .has(VtnServiceJsonConsts.LOGICAL_PORT1_ID)) {
+ if (link.has(VtnServiceJsonConsts.LOGICAL_PORT1_ID)) {
valBoundaryStruct
.set(VtnServiceIpcConsts.VALID,
UncPhysicalStructIndexEnum.UpplValBoundaryIndex.kIdxBoundaryLogicalPortId1
.set(VtnServiceIpcConsts.LOGICAL_PORT_ID1,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.BOUNDARY)
- .getAsJsonObject(
- VtnServiceJsonConsts.LINK)
- .get(VtnServiceJsonConsts.LOGICAL_PORT1_ID)
+ link.get(VtnServiceJsonConsts.LOGICAL_PORT1_ID)
.getAsString(),
valBoundaryStruct,
UncPhysicalStructIndexEnum.UpplValBoundaryIndex.kIdxBoundaryLogicalPortId1
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.BOUNDARY)
- .getAsJsonObject(VtnServiceJsonConsts.LINK)
- .has(VtnServiceJsonConsts.CONTROLLER2ID)) {
+ if (link.has(VtnServiceJsonConsts.CONTROLLER2ID)) {
valBoundaryStruct
.set(VtnServiceIpcConsts.VALID,
UncPhysicalStructIndexEnum.UpplValBoundaryIndex.kIdxBoundaryControllerName2
.set(VtnServiceIpcConsts.CONTROLLER_NAME2,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.BOUNDARY)
- .getAsJsonObject(
- VtnServiceJsonConsts.LINK)
- .get(VtnServiceJsonConsts.CONTROLLER2ID)
+ link.get(VtnServiceJsonConsts.CONTROLLER2ID)
.getAsString(),
valBoundaryStruct,
UncPhysicalStructIndexEnum.UpplValBoundaryIndex.kIdxBoundaryControllerName2
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.BOUNDARY)
- .getAsJsonObject(VtnServiceJsonConsts.LINK)
- .has(VtnServiceJsonConsts.DOMAIN2_ID)) {
+ if (link.has(VtnServiceJsonConsts.DOMAIN2_ID)) {
valBoundaryStruct
.set(VtnServiceIpcConsts.VALID,
UncPhysicalStructIndexEnum.UpplValBoundaryIndex.kIdxBoundaryDomainName2
.set(VtnServiceIpcConsts.DOMAIN_NAME2,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.BOUNDARY)
- .getAsJsonObject(
- VtnServiceJsonConsts.LINK)
- .get(VtnServiceJsonConsts.DOMAIN2_ID)
+ link.get(VtnServiceJsonConsts.DOMAIN2_ID)
.getAsString(),
valBoundaryStruct,
UncPhysicalStructIndexEnum.UpplValBoundaryIndex.kIdxBoundaryDomainName2
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
- if (requestBody.getAsJsonObject(VtnServiceJsonConsts.BOUNDARY)
- .getAsJsonObject(VtnServiceJsonConsts.LINK)
- .has(VtnServiceJsonConsts.LOGICAL_PORT2_ID)) {
+ if (link.has(VtnServiceJsonConsts.LOGICAL_PORT2_ID)) {
valBoundaryStruct
.set(VtnServiceIpcConsts.VALID,
UncPhysicalStructIndexEnum.UpplValBoundaryIndex.kIdxBoundaryLogicalPortId2
.set(VtnServiceIpcConsts.LOGICAL_PORT_ID2,
IpcDataUnitWrapper
.setIpcUint8ArrayValue(
- requestBody
- .getAsJsonObject(
- VtnServiceJsonConsts.BOUNDARY)
- .getAsJsonObject(
- VtnServiceJsonConsts.LINK)
- .get(VtnServiceJsonConsts.LOGICAL_PORT2_ID)
+ link.get(VtnServiceJsonConsts.LOGICAL_PORT2_ID)
.getAsString(),
valBoundaryStruct,
UncPhysicalStructIndexEnum.UpplValBoundaryIndex.kIdxBoundaryLogicalPortId2
.setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()));
}
-
else {
LOG.warning("request body and uri parameters are not correct for getValCtrStruct");
}
LOG.info("Value Structure: " + valBoundaryStruct.toString());
LOG.trace("Complete getValBoundaryStruct");
-
return valBoundaryStruct;
}
*/
public IpcStruct getKeyPortStruct(final JsonObject requestBody,
final List<String> uriParameters) {
-
/*
* ipc_struct key_port { key_switch sw_key; UINT8 port_id[32]; };
*/
public IpcStruct getValVrtArpEntryStStruct(final JsonObject requestBody,
final List<String> uriParameters) {
-
/*
* ipc_struct val_vrt_arp_entry_st { UINT8 valid[4]; UINT8 macaddr[6];
* IPV4 ip_addr; UINT8 type; UINT8 if_name[32]; };
LOG.trace("Start getValVrtArpEntryStStruct");
final IpcStruct ValArpStruct = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.ValVrtArpEntrySt.getValue());
-
if (requestBody != null) {
if (requestBody.has(VtnServiceJsonConsts.TYPE)) {
ValArpStruct
public IpcStruct getKeyLogicalPortStruct(final JsonObject requestBody,
final List<String> uriParameters) {
-
/*
* ipc_struct key_logical_port { key_ctr_domain domain_key; UINT8 port
* _id[320]; };
final IpcStruct keyLogicalPortStruct = IpcDataUnitWrapper
.setIpcStructValue(UncStructEnum.KeyLogicalPort.getValue());
IpcStruct keyDomainStruct = null;
-
if (uriParameters != null
&& uriParameters.size() >= UncIndexEnum.TWO.ordinal()) {
// call Domain Key
}
keyLogicalPortStruct.set(VtnServiceIpcConsts.DOMAIN_KEY,
keyDomainStruct);
-
if (uriParameters != null
&& uriParameters.size() == UncIndexEnum.THREE.ordinal()) {
keyLogicalPortStruct.set(VtnServiceJsonConsts.PORT_ID,
}
LOG.info("Key Structure: " + keyLogicalPortStruct.toString());
LOG.trace("Complete getKeyLogicalPortStruct");
-
return keyLogicalPortStruct;
}
public IpcStruct getKeyLogicalMemberPortStruct(
final JsonObject requestBody, final List<String> uriParameters) {
-
/*
* ipc_struct key_logical_member_port { key_logical_port
* logical_port_key; UINT8 switch_id[256]; UINT8 physical_port_id[32];
.setIpcStructValue(UncStructEnum.KeyLogicalMemberPort
.getValue());
IpcStruct keyLogicalPortStruct = null;
-
if (uriParameters != null
&& uriParameters.size() >= UncIndexEnum.THREE.ordinal()) {
// call LogicalPort Key
}
keyLogicalMemberPortStruct.set(VtnServiceIpcConsts.LOGICAL_PORT_KEY,
keyLogicalPortStruct);
-
if (uriParameters != null
&& uriParameters.size() == UncIndexEnum.FIVE.ordinal()) {
}
LOG.info("Key Structure: " + keyLogicalMemberPortStruct.toString());
LOG.trace("Complete getKeyLogicalMemberPortStruct");
-
return keyLogicalMemberPortStruct;
}
-
}
return new IpcUint8(Integer.parseInt(jsonValue));
}
+ /**
+ * Set json string value to IpcUint8 type
+ *
+ * @param jsonValue
+ * @return
+ */
+ public static IpcUint8 setIpcUint8Value(final String jsonValue,
+ final IpcStruct struct, final int index) {
+ if (jsonValue == null || jsonValue.isEmpty()) {
+ setNoValueFlag(struct, index);
+ return new IpcUint8(VtnServiceConsts.DEFAULT_NUMBER);
+ }
+ return new IpcUint8(Integer.parseInt(jsonValue));
+ }
+
/**
* Set json integer value to IpcUint8 type
*
public static String setIpcUint8ArrayValue(final String jsonValue,
final IpcStruct struct, final int index) {
if (jsonValue == null || jsonValue.isEmpty()) {
- struct.set(
- VtnServiceIpcConsts.VALID,
- index,
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID_NO_VALUE
- .ordinal()));
+ setNoValueFlag(struct, index);
}
return jsonValue;
}
public static IpcUint16 setIpcUint16Value(final String jsonValue) {
return new IpcUint16(Integer.parseInt(jsonValue));
}
+
+ /**
+ * Set json string value to IpcUint16 type
+ *
+ * @param jsonValue
+ * @return
+ */
+ public static IpcUint16 setIpcUint16Value(final String jsonValue,
+ final IpcStruct struct, final int index) {
+ if (jsonValue == null || jsonValue.isEmpty()) {
+ setNoValueFlag(struct, index);
+ return new IpcUint16(VtnServiceConsts.DEFAULT_NUMBER);
+ }
+ return new IpcUint16(Integer.parseInt(jsonValue));
+ }
/**
* Set json integer value to IpcUint16 type
return new IpcUint16(jsonValue);
}
+ /**
+ * Set json hex string value to IpcUint16 type
+ *
+ * @param jsonValue
+ * @return
+ */
+ public static IpcUint16 setIpcUint16HexaValue(final String jsonValue,
+ final IpcStruct struct, final int index) {
+ if (jsonValue == null || jsonValue.isEmpty()) {
+ setNoValueFlag(struct, index);
+ return new IpcUint16(VtnServiceConsts.DEFAULT_NUMBER);
+ }
+ return new IpcUint16(jsonValue);
+ }
+
/**
* Set json string value to IpcUint32 type
*
return new IpcUint32(Long.parseLong(jsonValue));
}
+ /**
+ * Set json string value to IpcUint32 type
+ *
+ * @param jsonValue
+ * @return
+ */
+ public static IpcUint32 setIpcUint32Value(final String jsonValue,
+ final IpcStruct struct, final int index) {
+ if (jsonValue == null || jsonValue.isEmpty()) {
+ setNoValueFlag(struct, index);
+ return new IpcUint32(VtnServiceConsts.DEFAULT_NUMBER);
+ }
+ return new IpcUint32(Long.parseLong(jsonValue));
+ }
+
/**
* Set int string value to IpcInt32 type
*
return new IpcUint64(jsonValue);
}
+ /**
+ * Set json string value to IpcUint64 type
+ *
+ * @param jsonValue
+ * @return
+ */
+ public static IpcUint64 setIpcUint64Value(final String jsonValue,
+ final IpcStruct struct, final int index) {
+ if (jsonValue == null || jsonValue.isEmpty()) {
+ setNoValueFlag(struct, index);
+ return new IpcUint64(VtnServiceConsts.DEFAULT_NUMBER);
+ }
+ return new IpcUint64(jsonValue);
+ }
+
/**
* Set json ipaddress value to IpcInet4Address type
*
.textToNumericFormatV4(jsonValue));
}
+ /**
+ * Set json ipaddress value to IpcInet4Address type
+ *
+ * @param jsonValue
+ * @return
+ */
+ public static IpcInet4Address setIpcInet4AddressValue(final String jsonValue,
+ final IpcStruct struct, final int index) {
+ if (jsonValue == null || jsonValue.isEmpty()) {
+ setNoValueFlag(struct, index);
+ return (IpcInet4Address) IpcInetAddress.create(IpAddressUtil
+ .textToNumericFormatV4(VtnServiceConsts.DEFAULT_IP));
+ }
+ return (IpcInet4Address) IpcInetAddress.create(IpAddressUtil
+ .textToNumericFormatV4(jsonValue));
+ }
+
/**
* Set json ipaddress value to IpcInet6Address type
*
.textToNumericFormatV6(jsonValue));
}
+ /**
+ * Set json ipaddress value to IpcInet6Address type
+ *
+ * @param jsonValue
+ * @return
+ */
+ public static IpcInet6Address setIpcInet6AddressValue(final String jsonValue,
+ final IpcStruct struct, final int index) {
+ if (jsonValue == null || jsonValue.isEmpty()) {
+ setNoValueFlag(struct, index);
+ return (IpcInet6Address) IpcInetAddress.create(IpAddressUtil
+ .textToNumericFormatV6(VtnServiceConsts.DEFAULT_IPV6));
+ }
+ return (IpcInet6Address) IpcInetAddress.create(IpAddressUtil
+ .textToNumericFormatV6(jsonValue));
+ }
+
/**
* Create IpcStruct with name as Json string value
*
public static IpcStruct setIpcStructValue(final String jsonValue) {
return new IpcStruct(jsonValue);
}
-
+
/**
* Get string value of IpcDataUnit
*
stringValue = ((IpcInet4Address) ipcUnit).toString();
} else if (ipcUnit.getType() == IpcDataUnit.IPV6) {
stringValue = ((IpcInet6Address) ipcUnit).toString();
+ } else if (ipcUnit.getType() == IpcDataUnit.UINT8) {
+ stringValue = ((IpcUint8) ipcUnit).toString();
} else if (ipcUnit.getType() == IpcDataUnit.STRING) {
stringValue = ((IpcString) ipcUnit).getValue();
}
return struct.getInner(parameterName);
}
+ /**
+ * Get string value of hexadecimal IpcUint64
+ *
+ * @param struct
+ * @param parameterName
+ * @return
+ */
public static String getIpcStructUint64HexaValue(final IpcStruct struct,
final String parameterName) {
long longValue = ((IpcUint64) struct.get(parameterName)).longValue();
* @param jsonValue
*/
public static void setMacAddress(final IpcStruct struct,
- final String parameterName, final String jsonValue) {
+ final String parameterName, final String jsonValue, final int index) {
+ if (jsonValue == null || jsonValue.isEmpty()) {
+ setNoValueFlag(struct, index);
+ return ;
+ }
String macAddress = jsonValue.replaceAll(VtnServiceConsts.DOT_REGEX,
VtnServiceConsts.EMPTY_STRING);
if (macAddress.length() != UncIndexEnum.TWELVE.ordinal()) {
return;
} else {
int structIndex = UncIndexEnum.ZERO.ordinal();
- int index = UncIndexEnum.ZERO.ordinal();
+ int counter = UncIndexEnum.ZERO.ordinal();
while (structIndex != UncIndexEnum.SIX.ordinal()) {
struct.set(
parameterName,
structIndex,
new IpcUint8(Integer.valueOf(
- macAddress.substring(index, index
+ macAddress.substring(counter, counter
+ UncIndexEnum.TWO.ordinal()),
UncIndexEnum.SIXTEEN.ordinal())));
structIndex++;
- index = index + UncIndexEnum.TWO.ordinal();
+ counter = counter + UncIndexEnum.TWO.ordinal();
}
}
}
UncIndexEnum.SIX.ordinal(),
UncIndexEnum.EIGHT.ordinal());
} else if (value >= UncIndexEnum.ZERO.ordinal()
- && value < UncIndexEnum.TEN.ordinal()) {
+ && value < UncIndexEnum.SIXTEEN.ordinal()) {
jsonString = jsonString
+ VtnServiceConsts.ZERO
+ Integer.toHexString((int) struct.getByte(
}
return jsonString;
}
+
+ /**
+ * Set UNC_VF_VALID_NO_VALUE in case of receiving empty string for parameter
+ *
+ * @param struct
+ * @param index
+ */
+ private static void setNoValueFlag(final IpcStruct struct, final int index) {
+ struct.set(
+ VtnServiceIpcConsts.VALID,
+ index,
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID_NO_VALUE
+ .ordinal()));
+ }
+
}
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vtn,
VtnServiceJsonConsts.DESCRIPTION,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valVtnStStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vtn,
VtnServiceJsonConsts.CREATEDTIME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vtn,
VtnServiceJsonConsts.LASTCOMMITTEDTIME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (validBit == (byte) UncStructIndexEnum.Valid.UNC_VF_VALID
.ordinal()) {
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (validBit == (byte) UncStructIndexEnum.Valid.UNC_VF_VALID
.ordinal()) {
setValueToJsonObject(validBit, ipAddress,
- VtnServiceJsonConsts.NETMASK,
+ VtnServiceJsonConsts.PREFIX,
IpcDataUnitWrapper.getIpcStructUint8Value(
valVbrStruct,
VtnServiceIpcConsts.HOST_ADDR_PREFIXLEN));
.getIpcDataUnitValue(responsePacket[VtnServiceConsts.IPC_COUNT_INDEX]));
root.add(rootJsonName, l2Domain);
} else {
- for (int index = 0; index < responsePacket.length; index++) {
+ // There is no use of key type, key structure and count of l2domains
+ for (int index = 3; index < responsePacket.length;) {
l2Domain = new JsonObject();
byte validBit;
- // There is no use of key type
- LOG.debug("Skip key type: no use");
- index++;
-
- /*
- * There is no use of key structure
- */
- LOG.debug("Skip key Structure: no use");
- index++;
-
/*
* add valid informations from value structure
*/
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, l2Domain,
VtnServiceJsonConsts.L2DOMAINID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
memberCount = Integer.parseInt(IpcDataUnitWrapper
.getIpcStructUint32Value(valVbrL2DomainSt,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(
validBit,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, l2DomainMember,
VtnServiceJsonConsts.VLANID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, macEntries,
VtnServiceJsonConsts.MACADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valVbrMacEntrySt,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, macEntries,
VtnServiceJsonConsts.PORTNAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valVbrMacEntrySt,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowFilterEntry,
VtnServiceJsonConsts.FLNAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowFilterEntry,
VtnServiceJsonConsts.NMGNAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowFilterEntry,
VtnServiceJsonConsts.PRIORITY,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowFilterEntry,
VtnServiceJsonConsts.DSCP,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, redirectDst,
VtnServiceJsonConsts.VNODENAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, redirectDst,
VtnServiceJsonConsts.IFNAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, redirectDst,
VtnServiceJsonConsts.MACDSTADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, redirectDst,
VtnServiceJsonConsts.MACSRCADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowFilterEntry,
VtnServiceJsonConsts.NMG_STATUS,
flowFilterEntry.add(flowListName, flowListJson);
} else {
LOG.debug("Show ,Operation : normal and target db :state Skip flowList value strutures ");
- for (; index < responsePacket.length; index++) {
- // increasing index to eliminate flow list entry
- // structures in case of show and op : normal
- }
+ // increasing index to eliminate flow list entry
+ // structures in case of show and op : normal
+ index = responsePacket.length - 1;
}
}
if (getType.equals(VtnServiceJsonConsts.LIST)
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vRouter,
VtnServiceJsonConsts.CONTROLLERID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vRouter,
VtnServiceJsonConsts.DOMAINID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vRouter,
VtnServiceJsonConsts.DESCRIPTION,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valVrtStStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valFlowListStruct,
return root;
}
- public JsonObject getVUnknownResponse(final IpcDataUnit[] responsePacket,
+ public JsonObject getVBypassResponse(final IpcDataUnit[] responsePacket,
final JsonObject requestBody, final String getType) {
- LOG.trace("Start getVUnknownResponse");
+ LOG.trace("Start getVBypassResponse");
final JsonObject root = new JsonObject();
- JsonArray vUnknownArray = null;
+ JsonArray vBypassArray = null;
LOG.debug("getType: " + getType);
/*
* operation type will be required to resolve the response type
String rootJsonName;
/*
* get type (show or list) will be required to resolve root json name
- * here it will be vunknown for show and vunknowns for list
+ * here it will be VBYPASS for show and VBYPASS for list
*/
if (getType.equals(VtnServiceJsonConsts.SHOW)) {
- rootJsonName = VtnServiceJsonConsts.VUNKNOWN;
+ rootJsonName = VtnServiceJsonConsts.VBYPASS;
} else {
- rootJsonName = VtnServiceJsonConsts.VUNKNOWNS;
+ rootJsonName = VtnServiceJsonConsts.VBYPASSES;
// json array will be required for list type of cases
- vUnknownArray = new JsonArray();
+ vBypassArray = new JsonArray();
}
LOG.debug("Json Name :" + rootJsonName);
- JsonObject vUnknownList = null;
+ JsonObject vBypassList = null;
if (opType.equalsIgnoreCase(VtnServiceJsonConsts.COUNT)) {
/*
* Create Json for Count
*/
- vUnknownList = new JsonObject();
- vUnknownList
+ vBypassList = new JsonObject();
+ vBypassList
.addProperty(
VtnServiceJsonConsts.COUNT,
IpcDataUnitWrapper
.getIpcDataUnitValue(responsePacket[VtnServiceConsts.IPC_COUNT_INDEX]));
- root.add(rootJsonName, vUnknownList);
+ root.add(rootJsonName, vBypassList);
} else {
for (int index = 0; index < responsePacket.length; index++) {
- vUnknownList = new JsonObject();
+ vBypassList = new JsonObject();
byte validBit;
// There is no use of key type
* add mandatory informations from key structure
*/
final IpcStruct keyFlowListStruct = (IpcStruct) responsePacket[index++];
- vUnknownList.addProperty(VtnServiceJsonConsts.VUKNAME,
+ vBypassList.addProperty(VtnServiceJsonConsts.VBYPASS_NAME,
IpcDataUnitWrapper.getIpcStructUint8ArrayValue(
keyFlowListStruct,
VtnServiceIpcConsts.VUNKNOWNNAME));
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
- setValueToJsonObject(validBit, vUnknownList,
+ setValueToJsonObject(validBit, vBypassList,
VtnServiceJsonConsts.DESCRIPTION,
IpcDataUnitWrapper.getIpcStructUint8ArrayValue(
valVUnknownStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valVUnknownStruct,
.equalsIgnoreCase(
UncStructIndexEnum.ValVunknowntype.VUNKNOWN_TYPE_BRIDGE
.getValue())) {
- setValueToJsonObject(validBit, vUnknownList,
+ setValueToJsonObject(validBit, vBypassList,
VtnServiceJsonConsts.TYPE,
VtnServiceJsonConsts.BRIDGE);
} else if (IpcDataUnitWrapper
.equalsIgnoreCase(
UncStructIndexEnum.ValVunknowntype.VUNKNOWN_TYPE_ROUTER
.getValue())) {
- setValueToJsonObject(validBit, vUnknownList,
+ setValueToJsonObject(validBit, vBypassList,
VtnServiceJsonConsts.TYPE,
VtnServiceJsonConsts.ROUTER);
} else {
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
- setValueToJsonObject(validBit, vUnknownList,
+ setValueToJsonObject(validBit, vBypassList,
VtnServiceJsonConsts.CONTROLLERID,
IpcDataUnitWrapper.getIpcStructUint8ArrayValue(
valVUnknownStruct,
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
- setValueToJsonObject(validBit, vUnknownList,
+ setValueToJsonObject(validBit, vBypassList,
VtnServiceJsonConsts.DOMAINID,
IpcDataUnitWrapper.getIpcStructUint8ArrayValue(
valVUnknownStruct,
}
// add current json object to array, if it has been initialized
// earlier
- if (null != vUnknownArray) {
- vUnknownArray.add(vUnknownList);
+ if (null != vBypassArray) {
+ vBypassArray.add(vBypassList);
}
}
/*
* finally add either array or single object to root json object and
* return the same.
*/
- if (null != vUnknownArray) {
- root.add(rootJsonName, vUnknownArray);
+ if (null != vBypassArray) {
+ root.add(rootJsonName, vBypassArray);
} else {
- root.add(rootJsonName, vUnknownList);
+ root.add(rootJsonName, vBypassList);
}
}
LOG.debug("response Json: " + root.toString());
- LOG.trace("Complete getVUnknownResponse");
+ LOG.trace("Complete getVBypassResponse");
return root;
}
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
flowFilterEntry.addProperty(
VtnServiceJsonConsts.SEQNUM,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowFilterEntry,
VtnServiceJsonConsts.NMG_STATUS,
flowFilterEntry.add(flowListName, flowListJson);
} else {
LOG.debug("Show ,Operation : normal and target db :state Skip flowList value strutures ");
- for (; index < responsePacket.length; index++) {
- // increasing index to eliminate flow list entry
- // structures in case of show and oop : normal
- }
+ // increasing index to eliminate flow list entry
+ // structures in case of show and op : normal
+ index = responsePacket.length - 1;
}
// root.add(subRootJsonName, statistics);
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntriesJson,
VtnServiceJsonConsts.SEQNUM,
pomStatsIndexSet.getSoftware());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
validBit = IpcDataUnitWrapper
.getInnerIpcStruct(responseStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, softwareFFJson,
VtnServiceJsonConsts.PACKETS,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, softwareFFJson,
VtnServiceIpcConsts.OCTETS,
pomStatsIndexSet.getExistingFlow());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
validBit = IpcDataUnitWrapper
.getInnerIpcStruct(responseStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, existFFJson,
VtnServiceJsonConsts.PACKETS,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, existFFJson,
VtnServiceIpcConsts.OCTETS,
pomStatsIndexSet.getExpiredFlow());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
validBit = IpcDataUnitWrapper
.getInnerIpcStruct(responseStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, expireFFJson,
VtnServiceJsonConsts.PACKETS,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, expireFFJson,
VtnServiceIpcConsts.OCTETS,
pomStatsIndexSet.getTotal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
validBit = IpcDataUnitWrapper
.getInnerIpcStruct(responseStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, totalFFJson,
VtnServiceJsonConsts.PACKETS,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, totalFFJson,
VtnServiceIpcConsts.OCTETS,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper.getIpcStructUint8Value(valVrtStruct,
VtnServiceIpcConsts.DHCPRELAYADMINSTATUS).equals(
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
LOG.debug("targetdb : State");
if (IpcDataUnitWrapper
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.MACDSTADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.MACSRCADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.MACETHERTYPE,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.MACVLANPRIORITY,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.IPDSTADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.IPDSTADDRPREFIX,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.IPSRCADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.IPSRCADDRPREFIX,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.IPV6DSTADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.IPV6DSTADDRPREFIX,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.IPV6SRCADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.IPV6SRCADDRPREFIX,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.IPPROTO,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.IPDSCP,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.L4DSTPORT,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.L4DSTENDPORT,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.L4SRCPORT,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.L4SRCENDPORT,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.ICMPTYPENUM,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.ICMPCODENUM,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.IPV6ICMPTYPENUM,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowListEntry,
VtnServiceJsonConsts.IPV6ICMPCODENUM,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, aRPEntries,
VtnServiceJsonConsts.IPADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, aRPEntries,
VtnServiceJsonConsts.MACADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, aRPEntries,
VtnServiceJsonConsts.IFNAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vRouterflowFilterEntry,
VtnServiceJsonConsts.FLNAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vRouterflowFilterEntry,
VtnServiceJsonConsts.NMGNAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vRouterflowFilterEntry,
VtnServiceJsonConsts.PRIORITY,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vRouterflowFilterEntry,
VtnServiceJsonConsts.DSCP,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, redirectDst,
VtnServiceJsonConsts.VNODENAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, redirectDst,
VtnServiceJsonConsts.IFNAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, redirectDst,
VtnServiceJsonConsts.MACDSTADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, redirectDst,
VtnServiceJsonConsts.MACSRCADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit,
vRouterflowFilterEntry,
} else {
LOG.debug("Show ,Operation : normal and target db :state Skip flowList value strutures ");
- for (; index < responsePacket.length; index++) {
- // increasing index to eliminate flow list entry
- // structures in case of show and oop : normal
- }
+ // increasing index to eliminate flow list entry
+ // structures in case of show and op : normal
+ index = responsePacket.length - 1;
}
}
if (getType.equals(VtnServiceJsonConsts.LIST)
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vTunnel,
VtnServiceJsonConsts.DESCRIPTION,
valVtunnelStruct,
VtnServiceIpcConsts.DESCRIPTION));
}
+ validBit = valVtunnelStruct
+ .getByte(
+ VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVtunnelIndex.UPLL_IDX_CONTROLLER_ID_VTNL
+ .ordinal());
+ if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
+ .ordinal()) {
+ setValueToJsonObject(validBit, vTunnel,
+ VtnServiceJsonConsts.CONTROLLERID,
+ IpcDataUnitWrapper.getIpcStructUint8ArrayValue(
+ valVtunnelStruct,
+ VtnServiceIpcConsts.CONTROLLERID));
+ }
validBit = valVtunnelStruct
.getByte(
VtnServiceIpcConsts.VALID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vTunnel,
VtnServiceJsonConsts.VTNNAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vTunnel,
VtnServiceJsonConsts.VTEPGROUPNAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vTunnel,
VtnServiceJsonConsts.LABEL,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vTunnel,
VtnServiceJsonConsts.DOMAINID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valVtunnelStStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valVLinkStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vLink,
VtnServiceJsonConsts.VNODE1NAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vLink,
VtnServiceJsonConsts.IF1NAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vLink,
VtnServiceJsonConsts.VNODE2NAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vLink,
VtnServiceJsonConsts.IF2NAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vLink,
VtnServiceJsonConsts.DESCRIPTION,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, boundaryMapJson,
VtnServiceJsonConsts.BOUNDARYID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint16HexaValue(valVLinkStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valVLinkStStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vrtInterface,
VtnServiceJsonConsts.DESCRIPTION,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valVrtIfStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vrtInterface,
VtnServiceJsonConsts.IPADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vrtInterface,
- VtnServiceJsonConsts.NETMASK,
+ VtnServiceJsonConsts.PREFIX,
IpcDataUnitWrapper.getIpcStructUint8Value(
valVrtIfStruct,
VtnServiceIpcConsts.PREFIXLEN));
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vrtInterface,
VtnServiceJsonConsts.MACADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valVrtIfStStruct,
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vtepInterface,
VtnServiceJsonConsts.DESCRIPTION,
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
return root;
}
- public JsonObject getVUnknownInterfaceResponse(
+ public JsonObject getVBypassInterfaceResponse(
final IpcDataUnit[] responsePacketIf, final JsonObject requestBody,
final String getType) {
- LOG.trace("Start getVUnknownInterfaceResponse");
+ LOG.trace("Start getVBypassInterfaceResponse");
final JsonObject root = new JsonObject();
- JsonArray vukInterfacesArray = null;
+ JsonArray vBypassInterfacesArray = null;
LOG.debug("getType: " + getType);
/*
* operation type will be required to resolve the response type
} else {
rootJsonName = VtnServiceJsonConsts.INTERFACES;
// json array will be required for list type of cases
- vukInterfacesArray = new JsonArray();
+ vBypassInterfacesArray = new JsonArray();
}
LOG.debug("Json Name :" + rootJsonName);
- JsonObject vukInterface = null;
+ JsonObject vBypassInterface = null;
if (opType.equalsIgnoreCase(VtnServiceJsonConsts.COUNT)) {
/*
* Create Json for Count
*/
- vukInterface = new JsonObject();
- vukInterface
+ vBypassInterface = new JsonObject();
+ vBypassInterface
.addProperty(
VtnServiceJsonConsts.COUNT,
IpcDataUnitWrapper
.getIpcDataUnitValue(responsePacketIf[VtnServiceConsts.IPC_COUNT_INDEX]));
- root.add(rootJsonName, vukInterface);
+ root.add(rootJsonName, vBypassInterface);
} else {
for (int index = 0; index < responsePacketIf.length; index++) {
- vukInterface = new JsonObject();
+ vBypassInterface = new JsonObject();
byte validBit;
// There is no use of key type so skipped it.
* add mandatory informations from key structure
*/
final IpcStruct keyVukIfStruct = (IpcStruct) responsePacketIf[index++];
- vukInterface.addProperty(VtnServiceJsonConsts.IFNAME,
+ vBypassInterface.addProperty(VtnServiceJsonConsts.IFNAME,
IpcDataUnitWrapper.getIpcStructUint8ArrayValue(
keyVukIfStruct, VtnServiceIpcConsts.IFNAME));
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
- setValueToJsonObject(validBit, vukInterface,
+ setValueToJsonObject(validBit, vBypassInterface,
VtnServiceJsonConsts.DESCRIPTION,
IpcDataUnitWrapper.getIpcStructUint8ArrayValue(
valVukIfStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valVukIfStruct,
VtnServiceIpcConsts.ADMIN_STATUS)
.equals(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_ENABLE
.getValue())) {
- setValueToJsonObject(validBit, vukInterface,
+ setValueToJsonObject(validBit, vBypassInterface,
VtnServiceJsonConsts.ADMINSTATUS,
VtnServiceJsonConsts.ENABLE);
} else if (IpcDataUnitWrapper
VtnServiceIpcConsts.ADMIN_STATUS)
.equals(UncStructIndexEnum.ValAdminStatus.UPLL_ADMIN_DISABLE
.getValue())) {
- setValueToJsonObject(validBit, vukInterface,
+ setValueToJsonObject(validBit, vBypassInterface,
VtnServiceJsonConsts.ADMINSTATUS,
VtnServiceJsonConsts.DISABLE);
} else {
// add current json object to array, if it has been initialized
// earlier
- if (null != vukInterfacesArray) {
- vukInterfacesArray.add(vukInterface);
+ if (null != vBypassInterfacesArray) {
+ vBypassInterfacesArray.add(vBypassInterface);
}
}
/*
* finally add either array or single object to root json object and
* return the same.
*/
- if (null != vukInterfacesArray) {
- root.add(rootJsonName, vukInterfacesArray);
+ if (null != vBypassInterfacesArray) {
+ root.add(rootJsonName, vBypassInterfacesArray);
} else {
- root.add(rootJsonName, vukInterface);
+ root.add(rootJsonName, vBypassInterface);
}
}
LOG.debug("response Json: " + root.toString());
- LOG.trace("Complete getVUnknownInterfaceResponse");
+ LOG.trace("Complete getVBypassInterfaceResponse");
return root;
}
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vTepGroup,
VtnServiceJsonConsts.CONTROLLERID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vTepGroup,
VtnServiceJsonConsts.DESCRIPTION,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vbrInterface,
VtnServiceJsonConsts.DESCRIPTION,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valVbrInterfaceStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valVbrIfStStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, neighbor,
VtnServiceJsonConsts.VNODENAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, neighbor,
VtnServiceJsonConsts.IFNAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, neighbor,
VtnServiceJsonConsts.VLINKNAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vBridge,
VtnServiceJsonConsts.CONTROLLERID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vBridge,
VtnServiceJsonConsts.DOMAINID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vBridge,
VtnServiceJsonConsts.DESCRIPTION,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valVbrStStruct,
}
public JsonObject getPortMapResponse(final IpcDataUnit[] responsePacket,
- final JsonObject requestBody, final String getType) {
+ final JsonObject requestBody, final String getType, String ifType) {
LOG.trace("Start getPortMapResponse");
final JsonObject root = new JsonObject();
for (int index = 0; index < responsePacket.length; index++) {
portMap = new JsonObject();
- byte validBit;
+ byte validBit=0;
// There is no use of key type
LOG.debug("Skip key type: no use");
index++;
/*
* add valid informations from value structure
*/
- final IpcStruct valVbrIfStruct = (IpcStruct) responsePacket[index++];
- validBit = valVbrIfStruct
- .getByte(VtnServiceIpcConsts.VALID,
+ final IpcStruct valIfStruct = (IpcStruct) responsePacket[index++];
+ if (ifType != null && !ifType.isEmpty()) {
+ if (ifType
+ .equalsIgnoreCase(VtnServiceJsonConsts.VBRIDGE_INTERFACE_PORTMAP)) {
+ validBit = valIfStruct.getByte(VtnServiceIpcConsts.VALID,
UncStructIndexEnum.ValVbrIfIndex.UPLL_IDX_PM_VBRI
.ordinal());
- if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
- .ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
- .ordinal()) {
-
- IpcStruct valPortMapStruct = IpcDataUnitWrapper
- .getInnerIpcStruct(valVbrIfStruct,
- VtnServiceJsonConsts.PORTMAP);
- /*
- * add valid switch_id from value structure
- */
- validBit = valPortMapStruct
- .getByte(
- VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValPortMapIndex.UPLL_IDX_LOGICAL_PORT_ID_PM
- .ordinal());
- if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
- .ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
- .ordinal()) {
- setValueToJsonObject(validBit, portMap,
- VtnServiceJsonConsts.LOGICAL_PORT_ID,
- IpcDataUnitWrapper.getIpcStructUint8ArrayValue(
- valPortMapStruct,
- VtnServiceIpcConsts.LOGICAL_PORT_ID));
+ } else if (ifType
+ .equalsIgnoreCase(VtnServiceJsonConsts.VTEP_INTERFACE_PORTMAP)) {
+ validBit = valIfStruct
+ .getByte(
+ VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVtepIfIndex.UPLL_IDX_PORT_MAP_VTEPI
+ .ordinal());
+ } else if (ifType
+ .equalsIgnoreCase(VtnServiceJsonConsts.VTUNNEL_INTERFACE_PORTMAP)) {
+ validBit = valIfStruct
+ .getByte(
+ VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVtunnelIfIndex.UPLL_IDX_PORT_MAP_VTNL_IF
+ .ordinal());
+ } else {
+ LOG.debug("Incorrect ifType:" + ifType);
}
- /*
- * add valid Novlanid from value structure
- */
- validBit = valPortMapStruct.getByte(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValPortMapIndex.UPLL_IDX_VLAN_ID_PM
- .ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
- setValueToJsonObject(validBit, portMap,
- VtnServiceJsonConsts.VLANID,
- IpcDataUnitWrapper.getIpcStructUint16Value(
- valPortMapStruct,
- VtnServiceJsonConsts.VLANID));
- LOG.debug("Vlan Id :"
- + IpcDataUnitWrapper.getIpcStructUint16Value(
- valPortMapStruct,
- VtnServiceJsonConsts.VLANID));
-
- }
- /*
- * add valid tagged from value structure
- */
- validBit = valPortMapStruct.getByte(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValPortMapIndex.UPLL_IDX_TAGGED_PM
- .ordinal());
- if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
- .ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
- .ordinal()) {
- if (IpcDataUnitWrapper
- .getIpcStructUint8Value(valPortMapStruct,
- VtnServiceIpcConsts.TAGGED)
- .equals(UncStructIndexEnum.vlan_tagged.UPLL_VLAN_TAGGED
- .getValue())) {
+ IpcStruct valPortMapStruct = IpcDataUnitWrapper
+ .getInnerIpcStruct(valIfStruct,
+ VtnServiceJsonConsts.PORTMAP);
+ /*
+ * add valid switch_id from value structure
+ */
+ validBit = valPortMapStruct
+ .getByte(
+ VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValPortMapIndex.UPLL_IDX_LOGICAL_PORT_ID_PM
+ .ordinal());
+ if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
+ .ordinal()) {
setValueToJsonObject(validBit, portMap,
- VtnServiceJsonConsts.TAGGED,
- VtnServiceJsonConsts.TRUE);
- } else if (IpcDataUnitWrapper
- .getIpcStructUint8Value(valPortMapStruct,
- VtnServiceIpcConsts.TAGGED)
- .equals(UncStructIndexEnum.vlan_tagged.UPLL_VLAN_UNTAGGED
- .getValue())) {
+ VtnServiceJsonConsts.LOGICAL_PORT_ID,
+ IpcDataUnitWrapper.getIpcStructUint8ArrayValue(
+ valPortMapStruct,
+ VtnServiceIpcConsts.LOGICAL_PORT_ID));
+ }
+ /*
+ * add valid Novlanid from value structure
+ */
+ validBit = valPortMapStruct
+ .getByte(
+ VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValPortMapIndex.UPLL_IDX_VLAN_ID_PM
+ .ordinal());
+ if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
+ .ordinal()) {
setValueToJsonObject(validBit, portMap,
- VtnServiceJsonConsts.TAGGED,
- VtnServiceJsonConsts.FALSE);
+ VtnServiceJsonConsts.VLANID,
+ IpcDataUnitWrapper.getIpcStructUint16Value(
+ valPortMapStruct,
+ VtnServiceJsonConsts.VLANID));
+ // }
+ LOG.debug("Vlan Id :"
+ + IpcDataUnitWrapper.getIpcStructUint16Value(
+ valPortMapStruct,
+ VtnServiceJsonConsts.VLANID));
+ }
+ /*
+ * add valid tagged from value structure
+ */
+ validBit = valPortMapStruct
+ .getByte(
+ VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValPortMapIndex.UPLL_IDX_TAGGED_PM
+ .ordinal());
+ if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
+ .ordinal()) {
+ /*
+ * setValueToJsonObject(validBit, portMap,
+ * VtnServiceJsonConsts.TAGGED,
+ * IpcDataUnitWrapper.getIpcStructUint8ArrayValue
+ * (valPortMapStruct, VtnServiceIpcConsts.TAGGED));
+ */if (IpcDataUnitWrapper
+ .getIpcStructUint8Value(valPortMapStruct,
+ VtnServiceIpcConsts.TAGGED)
+ .equals(UncStructIndexEnum.vlan_tagged.UPLL_VLAN_TAGGED
+ .getValue())) {
+ setValueToJsonObject(validBit, portMap,
+ VtnServiceJsonConsts.TAGGED,
+ VtnServiceJsonConsts.TRUE);
+ } else if (IpcDataUnitWrapper
+ .getIpcStructUint8Value(valPortMapStruct,
+ VtnServiceIpcConsts.TAGGED)
+ .equals(UncStructIndexEnum.vlan_tagged.UPLL_VLAN_UNTAGGED
+ .getValue())) {
+ setValueToJsonObject(validBit, portMap,
+ VtnServiceJsonConsts.TAGGED,
+ VtnServiceJsonConsts.FALSE);
+ }
+ LOG.debug("Tagged :"
+ + IpcDataUnitWrapper.getIpcStructUint8Value(
+ valPortMapStruct,
+ VtnServiceIpcConsts.TAGGED));
}
- LOG.debug("Tagged :"
- + IpcDataUnitWrapper.getIpcStructUint8Value(
- valPortMapStruct,
- VtnServiceIpcConsts.TAGGED));
}
- }
- if (dataType.equalsIgnoreCase(VtnServiceJsonConsts.STATE)) {
- LOG.debug("In target db state case-skip val_vbr_if_st ");
- index++;
+ if (dataType.equalsIgnoreCase(VtnServiceJsonConsts.STATE)) {
+ LOG.debug("In target db state case-skip St structure ");
+ index++;
+ }
+ } else {
+ LOG.debug("IfType:: " + "is either null or incorrect");
}
}
/*
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint16HexaValue(valVlanMapStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vbrIfFlowFilterEntry,
VtnServiceJsonConsts.FLNAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vbrIfFlowFilterEntry,
VtnServiceJsonConsts.NMGNAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vbrIfFlowFilterEntry,
VtnServiceJsonConsts.PRIORITY,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vbrIfFlowFilterEntry,
VtnServiceJsonConsts.DSCP,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, redirectDst,
VtnServiceJsonConsts.VNODENAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, redirectDst,
VtnServiceJsonConsts.IFNAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, redirectDst,
VtnServiceJsonConsts.MACDSTADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, redirectDst,
VtnServiceJsonConsts.MACSRCADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit,
vbrIfFlowFilterEntry,
vbrIfFlowFilterEntry.add(flowListName, flowListJson);
} else {
LOG.debug("Show ,Operation : normal and target db :state Skip flowList value strutures ");
- for (; index < responsePacket.length; index++) {
- // increasing index to eliminate flow list entry
- // structures in case of show and oop : normal
- }
+ // increasing index to eliminate flow list entry
+ // structures in case of show and op : normal
+ index = responsePacket.length - 1;
}
}
if (getType.equals(VtnServiceJsonConsts.LIST)
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vTunnelInterface,
VtnServiceJsonConsts.DESCRIPTION,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valVtunnelIfStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(
for (int index = 0; index < responsePacket.length; index++) {
staticIpRoute = new JsonObject();
- byte validBit;
// There is no use of key type
LOG.debug("Skip key type: no use");
final String nextHopAddr = IpcDataUnitWrapper
.getIpcStructIpv4Value(keyStaticIpRouteStruct,
VtnServiceIpcConsts.NEXT_HOP_ADDR);
- final String nwm_name = IpcDataUnitWrapper
- .getIpcStructUint8ArrayValue(keyStaticIpRouteStruct,
- VtnServiceIpcConsts.NWM_NAME);
- /*
- * this part is always required in Show, but not required in
- * List + "normal" op type
- */
- final IpcStruct valStaticIpRouteStruct = (IpcStruct) responsePacket[index++];
+
+ // no use of value structure
+ LOG.debug("no use of value structure");
+ index++;
final String staticIpRouteStr = dst_addr
+ VtnServiceJsonConsts.HYPHEN + nextHopAddr
- + VtnServiceJsonConsts.HYPHEN + prefixlen
- + VtnServiceJsonConsts.HYPHEN + nwm_name;
+ + VtnServiceJsonConsts.HYPHEN + prefixlen;
staticIpRoute.addProperty(VtnServiceJsonConsts.STATICIPROUTEID,
staticIpRouteStr);
if (getType.equals(VtnServiceJsonConsts.SHOW)
LOG.debug("Case : Show or detail");
staticIpRoute.addProperty(VtnServiceJsonConsts.IPADDR,
dst_addr);
- staticIpRoute.addProperty(VtnServiceJsonConsts.NETMASK,
+ staticIpRoute.addProperty(VtnServiceJsonConsts.PREFIX,
prefixlen);
staticIpRoute.addProperty(VtnServiceJsonConsts.NEXTHOPADDR,
nextHopAddr);
- staticIpRoute.addProperty(VtnServiceJsonConsts.NMG_NAME,
- nwm_name);
-
- validBit = valStaticIpRouteStruct
- .getByte(
- VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValStaticIpRouteIndex.UPLL_IDX_GROUP_METRIC_SIR
- .ordinal());
- if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
- .ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
- .ordinal()) {
- setValueToJsonObject(validBit, staticIpRoute,
- VtnServiceJsonConsts.GROUPMETRIC,
- IpcDataUnitWrapper.getIpcStructUint16Value(
- valStaticIpRouteStruct,
- VtnServiceIpcConsts.GROUP_METRIC));
- }
-
- } else {
- LOG.debug("Operation : normal Skip value struture");
- index++;
}
// add current json object to array, if it has been initialized
// earlier
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vtep,
VtnServiceJsonConsts.CONTROLLERID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vtep,
VtnServiceJsonConsts.DESCRIPTION,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vtep,
VtnServiceJsonConsts.DOMAINID,
valVtepStruct,
VtnServiceJsonConsts.DOMAINID));
}
- }
+
/*
* If data type is set as "state", then value structure will
* also contain the state information
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valVtepStStruct,
}
}
-
+ }
else {
LOG.debug("Operation : normal Skip value struture");
index++;
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowFilterEntry,
VtnServiceJsonConsts.FLNAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valFlowFilterEntryStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowFilterEntry,
VtnServiceJsonConsts.NMGNAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowFilterEntry,
VtnServiceJsonConsts.PRIORITY,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, flowFilterEntry,
VtnServiceJsonConsts.DSCP,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vtnStation,
VtnServiceJsonConsts.STATIONID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vtnStation,
VtnServiceJsonConsts.CREATEDTIME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vtnStation,
VtnServiceJsonConsts.MACADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (UncStructIndexEnum.ValVbrIfMapType.UPLL_IF_OFS_MAP.getValue()
.equals(IpcDataUnitWrapper.getIpcStructUint8Value(
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (UncStructIndexEnum.ValVtnMapStatus.UPLL_VTN_MAP_VALID
.getValue().equals(
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vtnStation,
VtnServiceJsonConsts.VTNNAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vtnStation,
VtnServiceJsonConsts.DOMAINID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vtnStation,
VtnServiceJsonConsts.VBRIDGENAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, interfaceObj,
VtnServiceJsonConsts.IFNAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (UncStructIndexEnum.ValOperStatus.UPLL_OPER_STATUS_UP.getValue()
.equals(IpcDataUnitWrapper.getIpcStructUint8Value(
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vtnStation,
VtnServiceJsonConsts.SWITCHID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, vtnStation,
VtnServiceJsonConsts.PORTNAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint16HexaValue(valVtnstationControllerSt,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, allRx, VtnServiceJsonConsts.PACKETS,
IpcDataUnitWrapper.getIpcStructUint64Value(
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, allRx, VtnServiceJsonConsts.OCTETS,
IpcDataUnitWrapper.getIpcStructUint64Value(
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, allTx, VtnServiceJsonConsts.PACKETS,
IpcDataUnitWrapper.getIpcStructUint64Value(
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, allTx, VtnServiceJsonConsts.OCTETS,
IpcDataUnitWrapper.getIpcStructUint64Value(
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, allRx, VtnServiceJsonConsts.PACKETS,
IpcDataUnitWrapper.getIpcStructUint64Value(
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, allRx, VtnServiceJsonConsts.OCTETS,
IpcDataUnitWrapper.getIpcStructUint64Value(
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, allTx, VtnServiceJsonConsts.PACKETS,
IpcDataUnitWrapper.getIpcStructUint64Value(
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, allTx, VtnServiceJsonConsts.OCTETS,
IpcDataUnitWrapper.getIpcStructUint64Value(
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, existingRx,
VtnServiceJsonConsts.PACKETS,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, existingRx,
VtnServiceJsonConsts.OCTETS,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, existingTx,
VtnServiceJsonConsts.PACKETS,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, existingTx,
VtnServiceJsonConsts.OCTETS,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, expiredRx,
VtnServiceJsonConsts.PACKETS,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, expiredRx,
VtnServiceJsonConsts.OCTETS,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, expiredTx,
VtnServiceJsonConsts.PACKETS,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, expiredTx,
VtnServiceJsonConsts.OCTETS,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, allDropRx,
VtnServiceJsonConsts.PACKETS,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, allDropRx,
VtnServiceJsonConsts.OCTETS,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, existingDropRx,
VtnServiceJsonConsts.PACKETS,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, existingDropRx,
VtnServiceJsonConsts.OCTETS,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, expiredDropRx,
VtnServiceJsonConsts.PACKETS,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, expiredDropRx,
VtnServiceJsonConsts.OCTETS,
root.add(rootJsonName, vtnStation);
} else {
vtnStationsArray = new JsonArray();
- for (int index = 0; index < responsePacket.length; index++) {
+ LOG.debug("Skip Key Type, Key Structure and Count of VTN-Stations");
+ for (int index = 3; index < responsePacket.length; ) {
vtnStation = new JsonObject();
byte validBit;
-
- // There is no use of key type
- LOG.debug("Skip key type: no use");
- index++;
-
- /*
- * add mandatory informations from key structure
- */
- // final IpcStruct keyVtnstationController = (IpcStruct)
- // responsePacket[index++];
- LOG.debug("Skip key Structure: no use");
- index++; // no need to use key structure
-
+
final IpcStruct valVtnstationControllerSt = (IpcStruct) responsePacket[index++];
createVtnStationConstJson(vtnStation, valVtnstationControllerSt);
+
+ if (opType.equalsIgnoreCase(VtnServiceJsonConsts.DETAIL)) {
+ LOG.debug("op : detail");
+ final IpcStruct valVtnstationControllerStat = (IpcStruct) responsePacket[index++];
+
+ final JsonObject vtnStationStats = new JsonObject();
+ addVtnStationStatsData(vtnStationStats,
+ valVtnstationControllerStat);
+ vtnStation.add(VtnServiceJsonConsts.STATISTICS,
+ vtnStationStats);
+ }
// for ipaddrs parameter
validBit = valVtnstationControllerSt
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
final int ipv4_count = Integer.parseInt(IpcDataUnitWrapper
.getIpcStructUint32Value(valVtnstationControllerSt,
.getIpcDataUnitValue(responsePacket[index++]));
ipaddrsArray.add(ipaddrs);
}
- vtnStation.add(VtnServiceJsonConsts.IPADDRS, ipaddrsArray);
+ if(ipaddrsArray.size() > 0){
+ vtnStation.add(VtnServiceJsonConsts.IPADDRS, ipaddrsArray);
+ }
LOG.debug("count of ipv4 address : " + ipv4_count);
- } else {
- // for ipv6addrs parameter
- validBit = valVtnstationControllerSt
- .getByte(
- VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValVtnstationControllerStIndex.UPLL_IDX_IPV6_COUNT_VSCS
- .ordinal());
- if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
- .ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
- .ordinal()) {
- final int ipv6_count = Integer
- .parseInt(IpcDataUnitWrapper
- .getIpcStructUint32Value(
- valVtnstationControllerSt,
- VtnServiceIpcConsts.IPV6_COUNT));
- final JsonArray ipaddrsArray = new JsonArray();
- for (int i = 0; i < ipv6_count; i++) {
- final JsonPrimitive ipaddrs = new JsonPrimitive(
- IpcDataUnitWrapper
- .getIpcDataUnitValue(responsePacket[index++]));
- ipaddrsArray.add(ipaddrs);
- }
- vtnStation.add(VtnServiceJsonConsts.IPV6ADDRS,
- ipaddrsArray);
- LOG.debug("count of ip64 address : " + ipv6_count);
- }
}
-
- if (opType.equalsIgnoreCase(VtnServiceJsonConsts.DETAIL)) {
- LOG.debug("op : detail");
- final IpcStruct valVtnstationControllerStat = (IpcStruct) responsePacket[index++];
-
- final JsonObject vtnStationStats = new JsonObject();
- addVtnStationStatsData(vtnStationStats,
- valVtnstationControllerStat);
- vtnStation.add(VtnServiceJsonConsts.STATISTICS,
- vtnStationStats);
+ // for ipv6addrs parameter
+ validBit = valVtnstationControllerSt
+ .getByte(
+ VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVtnstationControllerStIndex.UPLL_IDX_IPV6_COUNT_VSCS
+ .ordinal());
+ if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
+ .ordinal()
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
+ .ordinal()) {
+ final int ipv6_count = Integer
+ .parseInt(IpcDataUnitWrapper
+ .getIpcStructUint32Value(
+ valVtnstationControllerSt,
+ VtnServiceIpcConsts.IPV6_COUNT));
+ final JsonArray ipaddrsArray = new JsonArray();
+ for (int i = 0; i < ipv6_count; i++) {
+ final JsonPrimitive ipaddrs = new JsonPrimitive(
+ IpcDataUnitWrapper
+ .getIpcDataUnitValue(responsePacket[index++]));
+ ipaddrsArray.add(ipaddrs);
+ }
+ if(ipaddrsArray.size() > 0){
+ vtnStation.add(VtnServiceJsonConsts.IPV6ADDRS, ipaddrsArray);
+ }
+ LOG.debug("count of ip64 address : " + ipv6_count);
}
// add current json object to array, if it has been initialized
* Create Json for Count
*/
ipRouteList = new JsonObject();
- ipRouteList
- .addProperty(
- VtnServiceJsonConsts.COUNT,
- IpcDataUnitWrapper
- .getIpcDataUnitValue(responsePacket[VtnServiceConsts.IPC_COUNT_INDEX]));
+ String count = VtnServiceConsts.ZERO;
+ if (responsePacket.length != 0) {
+ count = IpcDataUnitWrapper
+ .getIpcDataUnitValue(responsePacket[VtnServiceConsts.IPC_COUNT_INDEX]);
+ }
+ ipRouteList.addProperty(VtnServiceJsonConsts.COUNT, count);
root.add(rootJsonName, ipRouteList);
} else {
int index = 0;
LOG.debug("Skip key Structure: no use");
index++;
// get count of value structure
- final Long count = Long
- .parseLong(IpcDataUnitWrapper
- .getIpcDataUnitValue(responsePacket[VtnServiceConsts.IPC_COUNT_INDEX]));
+ Long count = 0L;
+ if (responsePacket.length != 0) {
+ count = Long
+ .valueOf(IpcDataUnitWrapper
+ .getIpcDataUnitValue(responsePacket[VtnServiceConsts.IPC_COUNT_INDEX]));
+ }
LOG.debug("Count of value structure: " + count);
/*
* moving from count to value structure parameter
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, ipRouteList,
VtnServiceJsonConsts.DSTADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, ipRouteList,
VtnServiceJsonConsts.GATEWAY,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, ipRouteList,
- VtnServiceJsonConsts.NETMASK,
+ VtnServiceJsonConsts.PREFIX,
IpcDataUnitWrapper.getIpcStructUint8Value(
vaVvrtIpRouteSt,
VtnServiceIpcConsts.PREFIXLEN));
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, ipRouteList,
VtnServiceJsonConsts.FLAGS,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, ipRouteList,
VtnServiceJsonConsts.METRIC,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, ipRouteList,
VtnServiceJsonConsts.USE,
validBit = vaVvrtIpRouteSt
.getByte(
VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValVrtIpRouteStIndex.UPLL_IDX_USE_VIRS
+ UncStructIndexEnum.ValVrtIpRouteStIndex.UPLL_IDX_IF_NAME_VIRS
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, ipRouteList,
VtnServiceJsonConsts.IFNAME,
- IpcDataUnitWrapper.getIpcStructUint32Value(
+ IpcDataUnitWrapper.getIpcStructUint8ArrayValue(
vaVvrtIpRouteSt,
VtnServiceJsonConsts.IFNAME));
}
validBit = vaVvrtIpRouteSt
.getByte(
VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValVrtIpRouteStIndex.UPLL_IDX_USE_VIRS
+ UncStructIndexEnum.ValVrtIpRouteStIndex.UPLL_IDX_NW_MONITOR_GR_VIRS
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, ipRouteList,
VtnServiceJsonConsts.NMG_NAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, ipRouteList,
VtnServiceJsonConsts.GROUPMETRIC,
LOG.trace("Complete getIpRouteResponse");
return root;
}
-}
\ No newline at end of file
+}
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
// valCtrDomainStruct=
// (IpcStruct)valCtrDomainStSruct.get(VtnServiceJsonConsts.DOMAIN);
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valCtrDomainStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, domain,
VtnServiceJsonConsts.DESCRIPTION,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
valBoundaryStruct = IpcDataUnitWrapper
.getInnerIpcStruct(valBoundaryStSruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valBoundaryStSruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, boundary,
VtnServiceJsonConsts.DESCRIPTION,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, link,
VtnServiceJsonConsts.CONTROLLER1ID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, link,
VtnServiceJsonConsts.DOMAIN1ID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, link,
VtnServiceJsonConsts.LOGICALPORT1ID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, link,
VtnServiceJsonConsts.CONTROLLER2ID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, link,
VtnServiceJsonConsts.DOMAIN2ID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, link,
VtnServiceJsonConsts.LOGICALPORT2ID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
valControllerStruct = IpcDataUnitWrapper
.getInnerIpcStruct(valControllerStSruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(
validBit,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, controller,
VtnServiceJsonConsts.DESCRIPTION,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, controller,
VtnServiceJsonConsts.IPADDR,
UncPhysicalStructIndexEnum.UpplValCtrIndex.kIdxType.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper.getIpcStructUint8Value(valControllerStruct,
VtnServiceIpcConsts.TYPE).equalsIgnoreCase(
UncPhysicalStructIndexEnum.UpplTypeIndex.UNC_CT_UNKNOWN
.getValue())) {
setValueToJsonObject(validBit, controller,
- VtnServiceJsonConsts.TYPE, VtnServiceJsonConsts.UNKNOWN);
+ VtnServiceJsonConsts.TYPE, VtnServiceJsonConsts.BYPASS);
} else if (IpcDataUnitWrapper.getIpcStructUint8Value(
valControllerStruct, VtnServiceIpcConsts.TYPE)
.equalsIgnoreCase(
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valControllerStruct,
UncPhysicalStructIndexEnum.UpplValCtrIndex.kIdxUser.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, controller,
VtnServiceJsonConsts.USERNAME,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, controller,
VtnServiceJsonConsts.PASSWORD,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, controller,
VtnServiceJsonConsts.VERSION,
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valPortStStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, switchPort,
VtnServiceJsonConsts.MACADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, switchPort,
VtnServiceJsonConsts.SPEED,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
final String duplexVal = IpcDataUnitWrapper
.getIpcStructUint8Value(valPortStStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, switchPort,
VtnServiceJsonConsts.ALARMSSTATUS,
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
final String direction = IpcDataUnitWrapper
.getIpcStructUint8Value(valPortStStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, switchPort,
VtnServiceJsonConsts.LOGICAL_PORT_ID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
valPortStruct = IpcDataUnitWrapper.getInnerIpcStruct(
valPortStStruct, VtnServiceIpcConsts.PORT);
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, switchPort,
VtnServiceJsonConsts.PORT_ID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(
validBit,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valPortStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(
validBit,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, switchPortNeighbour,
VtnServiceJsonConsts.CONNECTED_SWITCH_ID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, switchPortNeighbour,
VtnServiceJsonConsts.CONNECTED_PORT_ID,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
final IpcStruct valLinkStruct = IpcDataUnitWrapper
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(
validBit,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valLinkStStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
// IpcStruct valSwitchStruct=
// (IpcStruct)valSwitchStStruct.get(VtnServiceIpcConsts.SWITCH_VAL);
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(
validBit,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, switches,
VtnServiceJsonConsts.MODEL,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valSwitchStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, switches,
VtnServiceJsonConsts.IPADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, switches,
VtnServiceJsonConsts.IPV6ADDR,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(
validBit,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(valSwitchStStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, switches,
VtnServiceJsonConsts.MANUFACTURER,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, switches,
VtnServiceJsonConsts.HARDWARE,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, switches,
VtnServiceJsonConsts.SOFTWARE,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(validBit, switches,
VtnServiceJsonConsts.ALARMSSTATUS,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
valLogicalPortStruct = IpcDataUnitWrapper
.getInnerIpcStruct(valLogicalPortStStruct,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(
validBit,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(
validBit,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
setValueToJsonObject(
validBit,
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(
.ordinal());
if (validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_INVALID
.ordinal()
- && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SOPPORTED
+ && validBit != (byte) UncStructIndexEnum.Valid.UNC_VF_NOT_SUPPORTED
.ordinal()) {
if (IpcDataUnitWrapper
.getIpcStructUint8Value(
UncDataType.UNC_DT_CANDIDATE.ordinal(),
UncKeyTypeEnum.UNC_KT_VRT_IPROUTE.getValue(),
UncStructEnum.KeyStaticIpRoute.name(),
- UncStructEnum.ValStaticIpRoute.name()),
+ UncStructEnum.NONE.name()),
KT_VRT_IPROUTE_UPDATE(UncOperationEnum.UNC_OP_UPDATE.ordinal(),
UncOption1Enum.UNC_OPT1_NORMAL.ordinal(),
UncOption2Enum.UNC_OPT2_NONE.ordinal(),
UncDataType.UNC_DT_CANDIDATE.ordinal(),
UncKeyTypeEnum.UNC_KT_VRT_IPROUTE.getValue(),
UncStructEnum.KeyStaticIpRoute.name(),
- UncStructEnum.ValStaticIpRoute.name()),
+ UncStructEnum.NONE.name()),
KT_VRT_IPROUTE_GET(UncOperationEnum.UNC_OP_READ.ordinal(),
UncOption1Enum.UNC_OPT1_NORMAL.ordinal(),
UncOption2Enum.UNC_OPT2_NONE.ordinal(),
UncDataType.UNC_DT_STATE.ordinal(),
UncKeyTypeEnum.UNC_KT_VRT_IPROUTE.getValue(),
UncStructEnum.KeyStaticIpRoute.name(),
- UncStructEnum.ValStaticIpRoute.name()),
+ UncStructEnum.NONE.name()),
KT_VRT_IPROUTE_CREATE(UncOperationEnum.UNC_OP_CREATE.ordinal(),
UncOption1Enum.UNC_OPT1_NORMAL.ordinal(),
UncOption2Enum.UNC_OPT2_NONE.ordinal(),
UncDataType.UNC_DT_CANDIDATE.ordinal(),
UncKeyTypeEnum.UNC_KT_VRT_IPROUTE.getValue(),
UncStructEnum.KeyStaticIpRoute.name(),
- UncStructEnum.ValStaticIpRoute.name()),
+ UncStructEnum.NONE.name()),
KT_VBR_FLOWFILTER_CREATE(UncOperationEnum.UNC_OP_CREATE.ordinal(),
UncOption1Enum.UNC_OPT1_NORMAL.ordinal(),
UncOption2Enum.UNC_OPT2_NONE.ordinal(),
UncKeyTypeEnum.UNC_KT_VTEP_GRP.getValue(),
UncStructEnum.KeyVtepGrp.name(),
UncStructEnum.NONE.name()),
+ KT_VTEP_GRP_MEMBER_DELETE(UncOperationEnum.UNC_OP_DELETE.ordinal(),
+ UncOption1Enum.UNC_OPT1_NORMAL.ordinal(),
+ UncOption2Enum.UNC_OPT2_NONE.ordinal(),
+ UncDataType.UNC_DT_CANDIDATE.ordinal(),
+ UncKeyTypeEnum.UNC_KT_VTEP_GRP_MEMBER.getValue(),
+ UncStructEnum.KeyVtepGrpMember.name(),
+ UncStructEnum.NONE.name()),
KT_VTEP_GRP_GET(UncOperationEnum.UNC_OP_READ.ordinal(),
UncOption1Enum.UNC_OPT1_NORMAL.ordinal(),
UncOption2Enum.UNC_OPT2_NONE.ordinal(),
UncKeyTypeEnum.UNC_KT_VTEP_GRP.getValue(),
UncStructEnum.KeyVtepGrp.name(),
UncStructEnum.NONE.name()),
- KT_VTEP_GRP_MEMBER_GET(UncOperationEnum.UNC_OP_READ_SIBLING_BEGIN.ordinal(),
+ KT_VTEP_GRP_MEMBER_GET(UncOperationEnum.UNC_OP_READ.ordinal(),
UncOption1Enum.UNC_OPT1_NORMAL.ordinal(),
UncOption2Enum.UNC_OPT2_NONE.ordinal(),
UncDataType.UNC_DT_STATE.ordinal(),
UncKeyTypeEnum.UNC_KT_BOUNDARY.getValue(),
UncStructEnum.KeyBoundary.name(),
UncStructEnum.NONE.name()),
- KT_VTNSTATION_CONTROLLER_GET_COUNT(UncOperationEnum.UNC_OP_READ.ordinal(),
+ KT_VTNSTATION_CONTROLLER_GET_COUNT(UncOperationEnum.UNC_OP_READ_SIBLING_COUNT.ordinal(),
UncOption1Enum.UNC_OPT1_COUNT.ordinal(),
UncOption2Enum.UNC_OPT2_NONE.ordinal(),
UncDataType.UNC_DT_STATE.ordinal(),
UncKeyTypeEnum.UNC_KT_VTNSTATION_CONTROLLER.getValue(),
UncStructEnum.KeyVtnstationController.name(),
- UncStructEnum.NONE.name());
+ UncStructEnum.ValVtnstationControllerSt.name());
private int operation;
private int option1;
public enum ConfigStatus{
UNC_CS_UNKNOWN,
UNC_CS_APPLIED,
- UNC_CS_PARTAILLY_APPLIED,
+ UNC_CS_PARTIALLY_APPLIED,
UNC_CS_NOT_APPLIED,
UNC_CS_INVALID,
UNC_CS_NOT_SUPPORTED
}
/* Enumeration for Valid flag. */
- public enum ValidFlag{
- UNC_VF_INVALID,
- UNC_VF_VALID,
- UNC_VF_VALID_NO_VALUE,
- UNC_VF_NOT_SOPPORTED
- }
+// public enum ValidFlag{
+// UNC_VF_INVALID,
+// UNC_VF_VALID,
+// UNC_VF_VALID_NO_VALUE,
+// UNC_VF_NOT_SUPPORTED,
+// UNC_VF_VALUE_NOT_MODIFIED
+// }
/* Controller type enum. */
public enum ControllerType{
public enum UncResultCode {
UNC_SUCCESS(200,"Success"),
- UNC_CLIENT_ERROR(400,"Validation error for parameter: "),
+ UNC_CLIENT_ERROR(400,"Validation error for: "),
UNC_SERVER_ERROR(500, "IPC server error");
private final int value;
private static final Map<Integer, UncErrorBean> LOGICAL_CODES = new HashMap<Integer, UncErrorBean>();
- private static final Map<Integer, String> TC_CODES = new HashMap<Integer,String>();
+ private static final Map<Integer, UncTCEnums.OperationStatus> TC_CODES = new HashMap<Integer,UncTCEnums.OperationStatus>();
- private static final Map<Integer, String> SESSION_CODES = new HashMap<Integer, String>();
+ private static final Map<Integer, UncSessionEnums.UsessIpcErrE> SESSION_CODES = new HashMap<Integer, UncSessionEnums.UsessIpcErrE>();
- private static final Map<Integer, String> NODE_CODES = new HashMap<Integer, String>();
+ private static final Map<Integer, UncSYSMGEnums.NodeIpcErrorT> NODE_CODES = new HashMap<Integer, UncSYSMGEnums.NodeIpcErrorT>();
private static final Map<Integer, String> SYSMG_CODES = new HashMap<Integer, String>();
*/
index = 0;
for(UncTCEnums.OperationStatus operationStatus : UncTCEnums.OperationStatus.values()){
- TC_CODES.put(operationStatus.getCode(), operationStatus.getMessage());
+ TC_CODES.put(operationStatus.getCode(), operationStatus);
}
/*
*/
index = 0;
for(UncSessionEnums.UsessIpcErrE operationStatus : UncSessionEnums.UsessIpcErrE.values()){
- SESSION_CODES.put(index++, operationStatus.getMessage());
+ SESSION_CODES.put(index++, operationStatus);
}
/*
*/
index = 0;
for(UncSYSMGEnums.NodeIpcErrorT operationStatus : UncSYSMGEnums.NodeIpcErrorT.values()){
- NODE_CODES.put(index++, operationStatus.getMessage());
+ NODE_CODES.put(index++, operationStatus);
}
/*
* @param errorKey
* @return
*/
- public static String getTcCodes(final int errorKey) {
+ public static UncTCEnums.OperationStatus getTcCodes(final int errorKey) {
return TC_CODES.get(errorKey);
}
* @param errorKey
* @return
*/
- public static String getSessionCodes(final int errorKey) {
+ public static UncSessionEnums.UsessIpcErrE getSessionCodes(final int errorKey) {
return SESSION_CODES.get(errorKey);
}
* @param errorKey
* @return
*/
- public static String getNodeCodes(final int errorKey) {
+ public static UncSYSMGEnums.NodeIpcErrorT getNodeCodes(final int errorKey) {
return NODE_CODES.get(errorKey);
}
*/
package org.opendaylight.vtn.javaapi.ipc.enums;
-// TODO: Auto-generated Javadoc
/**
* The Enum UncKeyTypeEnum.
*/
UNC_KT_VTN(0x008),
UNC_KT_VTN_MAPPING_CONTROLLER(0x009),
UNC_KT_VTN_DATAFLOW_CONTROLLER(0x00a),
- UNC_KT_VTN_FLOWFILTER(0x00b),
- UNC_KT_VTN_FLOWFILTER_ENTRY(0x00c),
- UNC_KT_VTN_FLOWFILTER_CONTROLLER(0x00d),
- UNC_KT_VTN_PATHMAP_ENTRY(0x00e),
- UNC_KT_VTN_PATHMAP_CONTROLLER(0x00f),
- UNC_KT_VTN_POLICINGMAP(0x010),
- UNC_KT_VTN_POLICINGMAP_CONTROLLER(0x011),
- UNC_KT_VBRIDGE(0x012),
- UNC_KT_VBR_VLANMAP(0x013),
- UNC_KT_VBR_NWMONITOR(0x014),
- UNC_KT_VBR_NWMONITOR_HOST(0x015),
- UNC_KT_VBR_POLICINGMAP(0x016),
- UNC_KT_VBR_POLICINGMAP_ENTRY(0x017),
- UNC_KT_VBR_FLOWFILTER(0x018),
- UNC_KT_VBR_FLOWFILTER_ENTRY(0x019),
- UNC_KT_VBR_IF(0x01a),
- UNC_KT_IF_MACENTRY(0x01b),
- UNC_KT_VBRIF_FLOWFILTER(0x01c),
- UNC_KT_VBRIF_FLOWFILTER_ENTRY(0x01d),
- UNC_KT_VBRIF_POLICINGMAP(0x01e),
- UNC_KT_VBRIF_POLICINGMAP_ENTRY(0x01f),
- UNC_KT_VROUTER(0x020),
- UNC_KT_VRT_IPROUTE(0x021),
- UNC_KT_DHCPRELAY_SERVER(0x022),
- UNC_KT_DHCPRELAY_IF(0x023),
- UNC_KT_VRT_IF(0x024),
- UNC_KT_IF_ARPENTRY(0x025),
- UNC_KT_VRTIF_FLOWFILTER(0x026),
- UNC_KT_VRTIF_FLOWFILTER_ENTRY(0x027),
- UNC_KT_VUNKNOWN(0x028),
- UNC_KT_VUNK_IF(0x029),
- UNC_KT_VTEP(0x02a),
- UNC_KT_VTEP_IF(0x02b),
- UNC_KT_VTEP_GRP(0x02c),
- UNC_KT_VTEP_GRP_MEMBER(0x02d),
- UNC_KT_VTUNNEL(0x02e),
- UNC_KT_VTUNNEL_IF(0x02f),
- UNC_KT_VLINK(0x030),
+ UNC_KT_VBRIDGE(0x00b),
+ UNC_KT_VBR_VLANMAP(0x00c),
+ UNC_KT_VBR_NWMONITOR(0x00d),
+ UNC_KT_VBR_NWMONITOR_HOST(0x00e),
+ UNC_KT_VBR_POLICINGMAP(0x00f),
+ UNC_KT_VBR_POLICINGMAP_ENTRY(0x010),
+ UNC_KT_VBR_FLOWFILTER(0x011),
+ UNC_KT_VBR_FLOWFILTER_ENTRY(0x012),
+ UNC_KT_VBR_IF(0x013),
+ UNC_KT_IF_MACENTRY(0x014),
+ UNC_KT_VBRIF_POLICINGMAP(0x015),
+ UNC_KT_VBRIF_POLICINGMAP_ENTRY(0x016),
+ UNC_KT_VBRIF_FLOWFILTER(0x017),
+ UNC_KT_VBRIF_FLOWFILTER_ENTRY(0x018),
+ UNC_KT_VROUTER(0x019),
+ UNC_KT_VRT_IF(0x01a),
+ UNC_KT_VRTIF_FLOWFILTER(0x01b),
+ UNC_KT_VRTIF_FLOWFILTER_ENTRY(0x01c),
+ UNC_KT_VRT_IPROUTE(0x01d),
+ UNC_KT_DHCPRELAY_SERVER(0x01e),
+ UNC_KT_DHCPRELAY_IF(0x01f),
+ UNC_KT_IF_ARPENTRY(0x020),
+ UNC_KT_VUNKNOWN(0x021),
+ UNC_KT_VUNK_IF(0x022),
+ UNC_KT_VTEP(0x023),
+ UNC_KT_VTEP_IF(0x024),
+ UNC_KT_VTEP_GRP(0x025),
+ UNC_KT_VTEP_GRP_MEMBER(0x026),
+ UNC_KT_VTUNNEL(0x027),
+ UNC_KT_VTUNNEL_IF(0x028),
+ UNC_KT_VLINK(0x029),
+ UNC_KT_VTN_POLICINGMAP(0x02a),
+ UNC_KT_VTN_POLICINGMAP_CONTROLLER(0x02b),
+ UNC_KT_VTN_FLOWFILTER(0x02c),
+ UNC_KT_VTN_FLOWFILTER_ENTRY(0x02d),
+ UNC_KT_VTN_FLOWFILTER_CONTROLLER(0x02e),
+ UNC_KT_VTN_PATHMAP_ENTRY(0x02f),
+ UNC_KT_VTN_PATHMAP_CONTROLLER(0x030),
/* UPPL: 0x200~0x3ff */
UNC_KT_CONTROLLER(0x200),
UNC_KT_SWITCH(0x201),
UNC_KT_LOGICAL_PORT(0x205),
UNC_KT_LOGICAL_MEMBER_PORT(0x206),
UNC_KT_BOUNDARY(0x207);
-
+
private final int value;
/**
kIdxLogicalPortOperDownCriteria
};
public enum UpplLogicalPortType {
- UPPL_LP_SWITCH("0"),
- UPPL_LP_PHYSICAL_PORT("1"),
- UPPL_LP_TRUNK_PORT("2"),
- UPPL_LP_SUBDOMAIN("3"),
- UPPL_LP_TUNNEL_ENDPOINT("4");
+ UPPL_LP_SWITCH("1"),
+ UPPL_LP_PHYSICAL_PORT("2"),
+ UPPL_LP_TRUNK_PORT("11"),
+ UPPL_LP_SUBDOMAIN("12"),
+ UPPL_LP_TUNNEL_ENDPOINT("13");
private final String value;
private UpplLogicalPortType(final String value) {
* The Enum NodeMgrReturnCode.
*/
public enum NodeIpcErrorT{
- NOMG_E_OK("Success"),
- NOMG_E_NG("Error"),
- NOMG_E_NOENT("No Entry"),
- NOMG_E_INVAL("Invalid"),
- NOMG_E_INITING("Initiating"),
- NOMG_E_ABRT("Abort");
+ NOMG_E_OK(200, "Success"),
+ NOMG_E_NG(500, "Error"),
+ NOMG_E_NOENT(400, "No Entry"),
+ NOMG_E_INVAL(500, "Invalid"),
+ NOMG_E_INITING(500, "Initiating"),
+ NOMG_E_ABRT(500, "Abort");
+
private String message;
-
+ private int code;
+
/**
* Instantiates a new node mgr return code.
- *
- * @param message the message
+ *
+ * @param message
+ * the message
*/
- private NodeIpcErrorT(String message) {
+ private NodeIpcErrorT(int code, String message) {
+ this.code = code;
this.message = message;
}
+ /**
+ * Gets the code.
+ *
+ * @return the code
+ */
+ public int getCode() {
+ return code;
+ }
+
/**
* Gets the message.
- *
+ *
* @return the message
*/
public String getMessage() {
private MgmtIpcErrorT(String message) {
this.message = message;
}
-
+
/**
* Gets the message.
*
kUsessIpcNipcs; // number of IPC service ID.
}
+ // Type of user session.
public enum UsessTypeE{
USESS_TYPE_UNKNOWN("0"), // Unknown session type.
USESS_TYPE_CLI("1"), // CLI session type.
}
}
+ // Type of user.
public enum UserTypeE {
USER_TYPE_UNKNOWN("0"), // Unknown user.
USER_TYPE_OPER("1"), // operator user.
}
}
+ // Mode of user session
+ public enum UsessModeE {
+ USESS_MODE_UNKNOWN("0"), // Unknown mode.
+ USESS_MODE_OPER("1"), // operator mode.
+ USESS_MODE_ENABLE("2"), // enable mode.
+ USESS_MODE_DEL("3"); // administrator user.
+
+ private final String value;
+
+ private UsessModeE(final String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+ }
+
+ // config mode status.
+ public enum UsessConfigModeE {
+ CONFIG_STATUS_NONE("0"), // Not Configuration mode.
+ CONFIG_STATUS_TCLOCK("1"); // Configuration mode.
+
+ private final String value;
+
+ private UsessConfigModeE(final String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+ }
+
// error code.
public enum UsessIpcErrE {
- USESS_E_OK("success"), // success.
- USESS_E_NG("error"), // error.
- USESS_E_INVALID_SESSID("Invalid current session ID"), // Invalid current session ID.
- USESS_E_NO_SUCH_SESSID("Invalid target session ID"), // Invalod target session ID.
- USESS_E_INVALID_PRIVILEGE("Invalid privileges"), // Invalid privileges
- USESS_E_INVALID_MODE("Invalid target session ID"), // Invalid mode.
- USESS_E_INVALID_SESSTYPE("Invalid session type"), // Invalid session type.
- USESS_E_INVALID_USER("Invalid user name"), // Invalid user name.
- USESS_E_INVALID_PASSWD("Invalid password"), // Invalid password.
- USESS_E_SESS_OVER("Over the number of user sessions"); // Over the number of user sessions
+ USESS_E_OK(200, "Success"), // success.
+ USESS_E_NG(500, "Internal error"), // error.
+ USESS_E_INVALID_SESSID(400, "Invalid current session ID"), // Invalid current session ID.
+ USESS_E_NO_SUCH_SESSID(404, "Invalid target session ID"), // Invalid target session ID.
+ USESS_E_INVALID_PRIVILEGE(403, "Invalid privileges"), // Invalid privileges
+ USESS_E_INVALID_MODE(400, "Invalid mode"), // Invalid mode.
+ USESS_E_INVALID_SESSTYPE(400, "Invalid session type"), // Invalid session type.
+ USESS_E_INVALID_USER(400, "Invalid user name"), // Invalid user name.
+ USESS_E_INVALID_PASSWD(400, "Invalid password"), // Invalid password.
+ USESS_E_SESS_OVER(500, "Over the number of user sessions"); // Over the number of user sessions
private String message;
+ private int code;
- private UsessIpcErrE(String message) {
+ private UsessIpcErrE(int code, String message) {
+ this.code = code;
this.message = message;
}
public String getMessage() {
return message;
}
+
+ public int getCode() {
+ return code;
+ }
}
}
ValPortSt("val_port_st"),
ValPortStNeighbour("val_port_st_neighbor"),
KeyLogicalPort("key_logical_port"),
- KeyLogicalMemberPort("key_logical_member_port");
+ KeyLogicalMemberPort("key_logical_member_port"),
+ UsessIpcReqSessEnable("usess_ipc_req_sess_enable");
private String value;
UNC_VF_INVALID,
UNC_VF_VALID,
UNC_VF_VALID_NO_VALUE,
- UNC_VF_NOT_SOPPORTED
+ UNC_VF_NOT_SUPPORTED,
+ UNC_VF_VALUE_NOT_MODIFIED
};
// vtn
public enum ValVtnIndex{
//ValVbrIf for VBridgeInterface APIs
public enum ValVbrIfIndex {
- UPLL_IDX_DESC_VBRI,
UPLL_IDX_ADMIN_STATUS_VBRI,
+ UPLL_IDX_DESC_VBRI,
UPLL_IDX_PM_VBRI
};
return value;
}
};
+ public enum DirtyStatus {
+ FALSE("0"),
+ TRUE("1");
+ private final String value;
+
+ private DirtyStatus(final String value){
+ this.value = value;
+ }
+ public String getValue(){
+ return value;
+ }
+ };
}
\ No newline at end of file
public class UncTCEnums {
+ public static final String UNC_CHANNEL_NAME = "uncd";
+ public static final String TC_SERVICE_NAME = "tc";
- public static final String UNC_CHANNEL_NAME="uncd";
- public static final String TC_SERVICE_NAME="tc";
+ public enum ServiceID {
- public enum ServiceID{
-
- TC_CONFIG_SERVICES,
- TC_CANDIDATE_SERVICES,
- TC_STARTUP_DB_SERVICES,
- TC_READ_ACCESS_SERVICES,
- TC_AUTO_SAVE_SERVICES,
+ TC_CONFIG_SERVICES,
+ TC_CANDIDATE_SERVICES,
+ TC_STARTUP_DB_SERVICES,
+ TC_READ_ACCESS_SERVICES,
+ TC_AUTO_SAVE_SERVICES,
TC_AUDIT_SERVICES;
-
+
}
- public enum ServiceType{
- TC_OP_CONFIG_ACQUIRE,
- TC_OP_CONFIG_RELEASE,
- TC_OP_CONFIG_ACQUIRE_FORCE,
- TC_OP_CANDIDATE_COMMIT,
- TC_OP_CANDIDATE_ABORT,
- TC_OP_RUNNING_SAVE,
- TC_OP_CLEAR_STARTUP,
- TC_OP_READ_ACQUIRE,
- TC_OP_READ_RELEASE,
- TC_OP_AUTOSAVE_GET,
- TC_OP_AUTOSAVE_ENABLE,
- TC_OP_AUTOSAVE_DISABLE,
- TC_OP_USER_AUDIT,
- TC_OP_DRIVER_AUDIT,
- TC_OP_INVALID
+ public enum ServiceType {
+ TC_OP_CONFIG_ACQUIRE,
+ TC_OP_CONFIG_RELEASE,
+ TC_OP_CONFIG_ACQUIRE_FORCE,
+ TC_OP_CANDIDATE_COMMIT,
+ TC_OP_CANDIDATE_ABORT,
+ TC_OP_RUNNING_SAVE,
+ TC_OP_CLEAR_STARTUP,
+ TC_OP_READ_ACQUIRE,
+ TC_OP_READ_RELEASE,
+ TC_OP_AUTOSAVE_GET,
+ TC_OP_AUTOSAVE_ENABLE,
+ TC_OP_AUTOSAVE_DISABLE,
+ TC_OP_USER_AUDIT,
+ TC_OP_DRIVER_AUDIT,
+ TC_OP_INVALID
}
-public enum OperationStatus{
+ public enum OperationStatus {
- /* System Failover */
+ /* System Fail over */
- TC_OPER_FAILURE(-11,"OPeration failure"),
+ TC_OPER_FAILURE(-11, 500, "Operation failure"),
- /* Invalid Input Values Passed*/
+ /* Invalid Input Values Passed */
- TC_OPER_INVALID_INPUT(-10,"Invalid Input Values Passed"),
+ TC_OPER_INVALID_INPUT(-10, 500, "Invalid Input Values Passed"),
- TC_OPER_SUCCESS(0,"Success"),
+ TC_OPER_SUCCESS(0, 200, "Success"),
- TC_CONFIG_NOT_PRESENT(1,"Configuration not present"),
+ TC_CONFIG_NOT_PRESENT(1, 404, "Configuration not present"),
- TC_CONFIG_PRESENT(2,"Config present"),
+ TC_CONFIG_PRESENT(2, 503, "Service unavailable"),
- TC_INVALID_CONFIG_ID(3,"Invalid config id"),
+ TC_INVALID_CONFIG_ID(3, 400, "Invalid config id"),
- TC_INVALID_OPERATION_TYPE(4,"Invalid operation type"),
+ TC_INVALID_OPERATION_TYPE(4, 500, "Invalid operation type"),
- TC_INVALID_SESSION_ID(5,"Invalid session id"),
+ TC_INVALID_SESSION_ID(5, 400, "Invalid session id"),
- TC_INVALID_STATE(6,"Invalid state"),
+ TC_INVALID_STATE(6, 503, "Invalid state"),
- TC_OPER_ABORT(7,"Operation abort"),
+ TC_OPER_ABORT(7, 500, "Operation abort"),
- TC_SESSION_ALREADY_ACTIVE(8,"Session already active"),
+ TC_SESSION_ALREADY_ACTIVE(8, 503, "Service unavailable"),
- TC_SESSION_NOT_ACTIVE(9,"Session not active"),
+ TC_SESSION_NOT_ACTIVE(9, 404, "Session not active"),
- TC_SYSTEM_BUSY(10,"System busy"),
+ TC_SYSTEM_BUSY(10, 503, "System busy"),
- TC_SYSTEM_FAILURE(11,"System failure");
+ TC_SYSTEM_FAILURE(11, 500, "System failure");
private final String message;
private final int code;
-
- private OperationStatus(final int code, final String message) {
- this.code =code;
+ private final int errorCode;
+
+ private OperationStatus(final int code, final int errorCode,
+ final String message) {
+ this.code = code;
+ this.errorCode = errorCode;
this.message = message;
}
public int getCode() {
return code;
}
+
+ public int getErrorCode() {
+ return errorCode;
+ }
}
- public enum RequestIndex{
- TC_REQ_OP_TYPE_INDEX,
- TC_REQ_SESSION_ID_INDEX,
+ public enum RequestIndex {
+ TC_REQ_OP_TYPE_INDEX,
+ TC_REQ_SESSION_ID_INDEX,
TC_REQ_ARG_INDEX
}
- public enum ResponseIndex{
- TC_RES_OP_TYPE_INDEX,
- TC_RES_SESSION_ID_INDEX,
- TC_RES_OP_STATUS_INDEX,
+ public enum ResponseIndex {
+ TC_RES_OP_TYPE_INDEX,
+ TC_RES_SESSION_ID_INDEX,
+ TC_RES_OP_STATUS_INDEX,
TC_RES_VALUE_INDEX;
}
- public enum CandidateOperRespIndex{
- TC_CAND_RES_OP_TYPE_INDEX,
- TC_CAND_RES_SESSION_ID_INDEX,
- TC_CAND_RES_CONFIG_ID_INDEX,
+ public enum CandidateOperRespIndex {
+ TC_CAND_RES_OP_TYPE_INDEX,
+ TC_CAND_RES_SESSION_ID_INDEX,
+ TC_CAND_RES_CONFIG_ID_INDEX,
TC_CAND_RES_OP_STATUS_INDEX;
}
-
-
- public enum AutoSave{
- TC_AUTOSAVE_DISABLED("0"),
+ public enum AutoSave {
+ TC_AUTOSAVE_DISABLED("0"),
TC_AUTOSAVE_ENABLED("1");
private final String value;
}
}
-
}
}
/* UPLL IPC Operations supported under GlobalConfig Service ID */
- public enum GlobalConfigServiceID{
+ public enum UpllGlobalConfigOpT{
UPLL_IS_CANDIDATE_DIRTY_OP(101),
UPLL_IMPORT_CTRLR_CONFIG_OP(102),
UPLL_MERGE_IMPORT_CONFIG_OP(103),
private final int value;
- private GlobalConfigServiceID(final int value) {
+ private UpllGlobalConfigOpT(final int value) {
this.value = value;
}
public enum ServiceID{
UPPL_SVC_CONFIGREQ,
UPPL_SVC_READREQ,
- UPPL_SVC_CONTROL,
- UPPL_SVC_GLOBAL_CONFIG,
- UPPL_SVC_NOTIFICATION;
+ UPPL_SVC_GLOBAL_CONFIG;
}
public enum RowStatus{
NOT_SET
}
- public enum AddlOperation{
+ public enum UncAddlOperationT{
UNC_OP_IS_CANDIDATE_DIRTY,
UNC_OP_IMPORT_CONTROLLER_CONFIG,
UNC_OP_MERGE_CONTROLLER_CONFIG,
UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR=500:Internal Server Error:The operation not supported by controller
UPLL_RC_ERR_NOT_SUPPORTED_BY_STANDBY=503:Service is unavailable:The operation not supported by standby UPLL
UPLL_RC_ERR_PARENT_DOES_NOT_EXIST=404:The specified resource is not found:For creating the given keytype instance, its parent does not exist
-UPLL_RC_ERR_INSTANCE_EXISTS=422:The specified resource already exists:The given keytype instance cannot be created because it already exists
+UPLL_RC_ERR_INSTANCE_EXISTS=409:The specified resource already exists:The given keytype instance cannot be created because it already exists
UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT=405:Method is not allowed for the specified URI:Not allowed for this datatype
UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT=405:Method is not allowed for the specified URI:Not allowed for this KT
UPLL_RC_ERR_NOT_ALLOWED_AT_THIS_TIME=405:Method is not allowed for the specified URI:Not allowed for at this time
UPPL_RC_ERR_CFG_SEMANTIC=400:The specified parameter(s) is(are) invalid:Semantic check failed
UPPL_RC_ERR_PARENT_DOES_NOT_EXIST=400:The specified parameter(s) is(are) invalid:For creating the given keytype instance, its parent does not exist
UPPL_RC_ERR_NO_SUCH_INSTANCE=404:The specified resource is not found:Instance specified by key does not exist
-UPPL_RC_ERR_INSTANCE_EXISTS=422:The specified resource already exists:The given keytype instance cannot be created because it already exists
+UPPL_RC_ERR_INSTANCE_EXISTS=409:The specified resource already exists:The given keytype instance cannot be created because it already exists
UPPL_RC_ERR_EXCEEDS_RESOURCE_LIMIT=500:Internal Server Error:The given operation exceeds the resource limit
UPPL_RC_ERR_DB_ACCESS=500:Internal Server Error:DB Access Error
UPPL_RC_ERR_NOT_SUPPORTED_BY_STANDBY=503:Service is unavailable:The operation not supported by standby UPPL
// resource class. Also set the URI parameters
final String key = matchResource(fields, path);
if (key != null) {
- final Class<?> resourceClass = PackageScan.getCachedResources()
- .get(key);
+ PackageScan pscan = PackageScan.getInstance();
+ final Class<?> resourceClass = pscan.getResourceClass(key);
if (resourceClass != null) {
try {
// instantiate the resource class
return returnKey;
}
// iterate for each value of KeySet in scanned resource classes
- for (final String key : PackageScan.getCachedResources().keySet()) {
+ //for (final String key : PackageScan.getCachedResources().keySet()) {
+ PackageScan pscan = PackageScan.getInstance();
+ for (final String key: pscan.getAllPaths()) {
if (returnKey != null) {
break;
}
UncTCEnums.ServiceID.TC_CANDIDATE_SERVICES.ordinal(),
getExceptionHandler());
LOG.info("Session created successfully");
+ // set session timeout as infinity for abort operation
+ session.setTimeout(null);
if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.CANDIDATE)
&& requestBody
LOG.info("OperationStatus" + operationStatus);
if (operationStatus != UncTCEnums.OperationStatus.TC_OPER_SUCCESS
.getCode()) {
- createErrorInfo(
- UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue(),
- UncIpcErrorCode.getTcCodes(operationStatus));
+ createTcErrorInfo(UncIpcErrorCode.getTcCodes(operationStatus));
LOG.info("Request not processed successfully");
status = UncCommonEnum.UncResultCode.UNC_SERVER_ERROR
.getValue();
*/
package org.opendaylight.vtn.javaapi.resources;
+import java.lang.reflect.Method;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
+import org.opendaylight.vtn.core.ipc.ClientSession;
+import org.opendaylight.vtn.core.ipc.IpcDataUnit;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.VtnServiceResource;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.exception.VtnServiceExceptionHandler;
+import org.opendaylight.vtn.javaapi.init.VtnServiceConfiguration;
import org.opendaylight.vtn.javaapi.init.VtnServiceInitManager;
+import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
+import org.opendaylight.vtn.javaapi.ipc.conversion.IpcDataUnitWrapper;
+import org.opendaylight.vtn.javaapi.ipc.conversion.IpcLogicalResponseFactory;
+import org.opendaylight.vtn.javaapi.ipc.conversion.IpcPhysicalResponseFactory;
+import org.opendaylight.vtn.javaapi.ipc.enums.IpcRequestPacketEnum;
import org.opendaylight.vtn.javaapi.ipc.enums.UncCommonEnum;
import org.opendaylight.vtn.javaapi.ipc.enums.UncCommonEnum.UncResultCode;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncJavaAPIErrorCode;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncOption2Enum;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncSYSMGEnums;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncSessionEnums;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncTCEnums;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncUPLLEnums;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncUPPLEnums;
import org.opendaylight.vtn.javaapi.validation.VtnServiceValidator;
/**
private IpcConnPool connPool;
public AbstractResource() {
-// ResponseFielPathFinder.key = this.getClass()
-// .getAnnotation(UNCVtnService.class).path()
-// + VtnServiceConsts.COLON + VtnServiceConsts.GET;
}
public void setConnPool() {
LOG.trace("Complete AbstractResource#createErrorInfo");
}
+ /**
+ * Create error Json specific to session error codes
+ *
+ * @param errorMessage
+ */
+ public void createSessionErrorInfo(UncSessionEnums.UsessIpcErrE errorEnum) {
+ LOG.trace("Complete AbstractResource#createSessionErrorInfo");
+ final JsonObject errorJsonObject = new JsonObject();
+ final JsonObject error = new JsonObject();
+ error.addProperty(VtnServiceJsonConsts.CODE, errorEnum.getCode());
+ error.addProperty(VtnServiceJsonConsts.MSG, errorEnum.getMessage());
+ errorJsonObject.add(VtnServiceJsonConsts.ERROR, error);
+ setInfo(errorJsonObject);
+ LOG.trace("Complete AbstractResource#createSessionErrorInfo");
+ }
+
+ /**
+ * Create error Json specific to tc error codes
+ *
+ * @param errorMessage
+ */
+ public void createTcErrorInfo(UncTCEnums.OperationStatus errorEnum) {
+ LOG.trace("Complete AbstractResource#createTcErrorInfo");
+ final JsonObject errorJsonObject = new JsonObject();
+ final JsonObject error = new JsonObject();
+ error.addProperty(VtnServiceJsonConsts.CODE, errorEnum.getErrorCode());
+ error.addProperty(VtnServiceJsonConsts.MSG, errorEnum.getMessage());
+ errorJsonObject.add(VtnServiceJsonConsts.ERROR, error);
+ setInfo(errorJsonObject);
+ LOG.trace("Complete AbstractResource#createTcErrorInfo");
+ }
+
+ /**
+ * Create error Json specific to node manager error codes
+ *
+ * @param errorMessage
+ */
+ public void createNoMgErrorInfo(UncSYSMGEnums.NodeIpcErrorT errorEnum) {
+ LOG.trace("Complete AbstractResource#createNoMgErrorInfo");
+ final JsonObject errorJsonObject = new JsonObject();
+ final JsonObject error = new JsonObject();
+ error.addProperty(VtnServiceJsonConsts.CODE, errorEnum.getCode());
+ error.addProperty(VtnServiceJsonConsts.MSG, errorEnum.getMessage());
+ errorJsonObject.add(VtnServiceJsonConsts.ERROR, error);
+ setInfo(errorJsonObject);
+ LOG.trace("Complete AbstractResource#createNoMgErrorInfo");
+ }
+
/**
* Return a Null Json Object
*
return null;
}
+ /**
+ * Invoke the UPPL services, if the previous call contains more than 10K
+ * (configurable)
+ *
+ * @param requestBody
+ * @param requestProcessor
+ * @param responseGenerator
+ * @param responseArray
+ * @param JsonArrayName
+ * @param IndexName
+ * @param requestPackeEnumName
+ * @param uriParameters
+ * @param methodName
+ * @return
+ * @throws VtnServiceException
+ */
+ public JsonObject getResponseJsonArrayPhysical(
+ final JsonObject requestBody, IpcRequestProcessor requestProcessor,
+ Object responseGenerator, JsonArray responseArray,
+ String JsonArrayName, String IndexName,
+ IpcRequestPacketEnum requestPackeEnumName,
+ List<String> uriParameters, String methodName)
+ throws VtnServiceException {
+ // session reset
+ requestProcessor.setServiceInfo(UncUPPLEnums.UPPL_IPC_SVC_NAME,
+ UncUPPLEnums.ServiceID.UPPL_SVC_READREQ.ordinal());
+ int status = ClientSession.RESP_FATAL;
+ int memberIndex = 0;
+ VtnServiceConfiguration configuration = VtnServiceInitManager
+ .getConfigurationMap();
+ int max_rep_count = Integer.parseInt(configuration
+ .getConfigValue(VtnServiceConsts.MAX_REP_DEFAULT));
+ memberIndex = responseArray.size();
+ if (memberIndex != 0) {
+ JsonObject memberLastIndex = (JsonObject) responseArray
+ .get(responseArray.size() - 1);
+ if (requestBody.has(VtnServiceJsonConsts.INDEX)) {
+ uriParameters.remove(uriParameters.size() - 1);
+ uriParameters.add(uriParameters.size(),
+ memberLastIndex.get(IndexName).getAsString());
+ } else {
+ uriParameters.add(memberLastIndex.get(IndexName).getAsString());
+ }
+ while (memberIndex == max_rep_count) {
+
+ JsonArray memberArray = null;
+ memberLastIndex = (JsonObject) responseArray.get(responseArray
+ .size() - 1);
+ uriParameters.remove(uriParameters.size() - 1);
+ uriParameters.add(uriParameters.size(),
+ memberLastIndex.get(IndexName).getAsString());
+
+ requestProcessor.createIpcRequestPacket(requestPackeEnumName,
+ requestBody, uriParameters);
+ // for testing only
+ requestProcessor
+ .getRequestPacket()
+ .setOption2(
+ IpcDataUnitWrapper
+ .setIpcUint32Value(UncOption2Enum.UNC_OPT2_NEIGHBOR
+ .ordinal()));
+
+ status = requestProcessor.processIpcRequest();
+ if (status == ClientSession.RESP_FATAL) {
+ throw new VtnServiceException(
+ Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR
+ .getErrorMessage());
+ }
+ try {
+ Method method;
+
+ final Class<IpcPhysicalResponseFactory> sourceClass = IpcPhysicalResponseFactory.class;
+ // get the method name to get the IpcLogicalResponseFactory
+ // object for given key
+ method = sourceClass.getMethod(methodName,
+ new Class<?>[] { IpcDataUnit[].class,
+ JsonObject.class, String.class });
+ // get IpcLogicalResponseFactory object
+
+ memberArray = ((JsonObject) method.invoke(
+ responseGenerator,
+ requestProcessor.getIpcResponsePacket(),
+ requestBody, VtnServiceJsonConsts.LIST))
+ .getAsJsonArray(JsonArrayName);
+ } catch (final Exception e) {
+ exceptionHandler.raise(
+ Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
+ UncJavaAPIErrorCode.INTERNAL_ERROR.getErrorCode(),
+ UncJavaAPIErrorCode.INTERNAL_ERROR
+ .getErrorMessage(), e);
+ }
+ if (null != memberArray && !memberArray.isJsonNull()
+ && memberArray.size() > 0) {
+ responseArray.getAsJsonArray().addAll(memberArray);
+ } else {
+ break;
+ }
+ memberIndex = memberArray.size();
+ }
+ }
+ JsonObject root = new JsonObject();
+ root.add(JsonArrayName, responseArray);
+ return root;
+ }
+
+ /**
+ * Invoke the UPLL services, if the previous call contains more than 10K
+ * (configurable)
+ *
+ * @param requestBody
+ * @param requestProcessor
+ * @param responseGenerator
+ * @param responseArray
+ * @param JsonArrayName
+ * @param IndexName
+ * @param requestPackeEnumName
+ * @param uriParameters
+ * @param methodName
+ * @return
+ * @throws VtnServiceException
+ */
+ public JsonObject getResponseJsonArrayLogical(final JsonObject requestBody,
+ IpcRequestProcessor requestProcessor, Object responseGenerator,
+ JsonArray responseArray, String JsonArrayName, String IndexName,
+ IpcRequestPacketEnum requestPackeEnumName,
+ List<String> uriParameters, String methodName)
+ throws VtnServiceException {
+ // session reset
+ requestProcessor.setServiceInfo(UncUPLLEnums.UPLL_IPC_SERVICE_NAME,
+ UncUPLLEnums.ServiceID.UPLL_READ_SVC_ID.ordinal());
+ int status = ClientSession.RESP_FATAL;
+ int memberIndex = 0;
+ VtnServiceConfiguration configuration = VtnServiceInitManager
+ .getConfigurationMap();
+ int max_rep_count = Integer.parseInt(configuration
+ .getConfigValue(VtnServiceConsts.MAX_REP_DEFAULT));
+ memberIndex = responseArray.size();
+ if (memberIndex != 0) {
+ JsonObject memberLastIndex = (JsonObject) responseArray
+ .get(responseArray.size() - 1);
+ if (requestBody.has(VtnServiceJsonConsts.INDEX)) {
+ uriParameters.remove(uriParameters.size() - 1);
+ uriParameters.add(uriParameters.size(),
+ memberLastIndex.get(IndexName).getAsString());
+ } else {
+ uriParameters.add(memberLastIndex.get(IndexName).getAsString());
+ }
+ while (memberIndex == max_rep_count) {
+
+ JsonArray memberArray = null;
+ memberLastIndex = (JsonObject) responseArray.get(responseArray
+ .size() - 1);
+ uriParameters.remove(uriParameters.size() - 1);
+ uriParameters.add(uriParameters.size(),
+ memberLastIndex.get(IndexName).getAsString());
+
+ requestProcessor.createIpcRequestPacket(requestPackeEnumName,
+ requestBody, uriParameters);
+ // for testing only
+ requestProcessor
+ .getRequestPacket()
+ .setOption2(
+ IpcDataUnitWrapper
+ .setIpcUint32Value(UncOption2Enum.UNC_OPT2_NEIGHBOR
+ .ordinal()));
+
+ status = requestProcessor.processIpcRequest();
+ if (status == ClientSession.RESP_FATAL) {
+ throw new VtnServiceException(
+ Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR
+ .getErrorMessage());
+ }
+ try {
+ Method method;
+
+ final Class<IpcLogicalResponseFactory> sourceClass = IpcLogicalResponseFactory.class;
+ // get the method name to get the IpcLogicalResponseFactory
+ // object for given key
+ method = sourceClass.getMethod(methodName,
+ new Class<?>[] { IpcDataUnit[].class,
+ JsonObject.class, String.class });
+ // get IpcLogicalResponseFactory object
+
+ memberArray = ((JsonObject) method.invoke(
+ responseGenerator,
+ requestProcessor.getIpcResponsePacket(),
+ requestBody, VtnServiceJsonConsts.LIST))
+ .getAsJsonArray(JsonArrayName);
+ } catch (final Exception e) {
+ exceptionHandler.raise(
+ Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
+ UncJavaAPIErrorCode.INTERNAL_ERROR.getErrorCode(),
+ UncJavaAPIErrorCode.INTERNAL_ERROR
+ .getErrorMessage(), e);
+ }
+ if (null != memberArray && !memberArray.isJsonNull()
+ && memberArray.size() > 0) {
+ responseArray.getAsJsonArray().addAll(memberArray);
+ } else {
+ break;
+ }
+ memberIndex = memberArray.size();
+ }
+ }
+ JsonObject root = new JsonObject();
+ root.add(JsonArrayName, responseArray);
+ return root;
+ }
}
LOG.info("ConfigId " + configId);
if (operationStatus != UncTCEnums.OperationStatus.TC_OPER_SUCCESS
.getCode()) {
- createErrorInfo(
- UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue(),
- UncIpcErrorCode.getTcCodes(operationStatus));
+ createTcErrorInfo(UncIpcErrorCode.getTcCodes(operationStatus));
LOG.info("Request not processed successfully");
status = UncCommonEnum.UncResultCode.UNC_SERVER_ERROR
.getValue();
LOG.info("OperationStatus" + operationStatus);
if (operationStatus != UncTCEnums.OperationStatus.TC_OPER_SUCCESS
.getCode()) {
- createErrorInfo(
- UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue(),
- UncIpcErrorCode.getTcCodes(operationStatus));
+ createTcErrorInfo(UncIpcErrorCode.getTcCodes(operationStatus));
LOG.info("Request not processed successfully");
status = UncCommonEnum.UncResultCode.UNC_SERVER_ERROR
.getValue();
if (operationStatus != UncTCEnums.OperationStatus.TC_OPER_SUCCESS
.getCode()) {
- createErrorInfo(
- UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue(),
- UncIpcErrorCode.getTcCodes(operationStatus));
+ createTcErrorInfo(UncIpcErrorCode.getTcCodes(operationStatus));
LOG.info("Request not processed successfully");
status = UncCommonEnum.UncResultCode.UNC_SERVER_ERROR
.getValue();
UncTCEnums.ServiceID.TC_CANDIDATE_SERVICES
.ordinal(), getExceptionHandler());
LOG.info("Session created successfully");
+ // set session timeout as infinity for commit operation
+ session.setTimeout(null);
session.addOutput(new IpcUint32(
UncTCEnums.ServiceType.TC_OP_CANDIDATE_COMMIT
.ordinal()));
UncTCEnums.ServiceID.TC_STARTUP_DB_SERVICES
.ordinal(), getExceptionHandler());
LOG.info("Session created successfully");
+ // set session timeout as infinity for save operation
+ session.setTimeout(null);
session.addOutput(IpcDataUnitWrapper
.setIpcUint32Value(UncTCEnums.ServiceType.TC_OP_RUNNING_SAVE
.ordinal()));
LOG.info("OperationStatus" + operationStatus);
if (operationStatus != UncTCEnums.OperationStatus.TC_OPER_SUCCESS
.getCode()) {
- createErrorInfo(
- UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue(),
- UncIpcErrorCode.getTcCodes(operationStatus));
+ createTcErrorInfo(UncIpcErrorCode.getTcCodes(operationStatus));
LOG.info("Request not processed successfully");
status = UncCommonEnum.UncResultCode.UNC_SERVER_ERROR
.getValue();
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 NEC Corporation
+ * All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.vtn.javaapi.resources;
+
+import com.google.gson.JsonObject;
+import org.opendaylight.vtn.core.ipc.ClientSession;
+import org.opendaylight.vtn.core.ipc.IpcException;
+import org.opendaylight.vtn.core.util.Logger;
+import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
+import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
+import org.opendaylight.vtn.javaapi.ipc.conversion.IpcDataUnitWrapper;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncCommonEnum;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncIpcErrorCode;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncJavaAPIErrorCode;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncStructIndexEnum;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncUPLLEnums;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncUPPLEnums;
+import org.opendaylight.vtn.javaapi.validation.DifferenceConfigResourceValidator;
+
+/**
+ * The Class DifferenceConfigResource implements the put method of Difference
+ * Configuration API
+ */
+
+@UNCVtnService(path = "/configuration/diff")
+public class DifferenceConfigResource extends AbstractResource {
+
+ private static final Logger LOG = Logger
+ .getLogger(DifferenceConfigResource.class.getName());
+
+ /**
+ * Instantiates a new difference config resource.
+ */
+ public DifferenceConfigResource() {
+ super();
+ LOG.trace("Start DifferenceConfigResource#DifferenceConfigResource()");
+ setValidator(new DifferenceConfigResourceValidator(this));
+ LOG.trace("Complete DifferenceConfigResource#DifferenceConfigResource()");
+ }
+
+ /**
+ * Implementation of Put method of Difference Configuration API
+ *
+ * @param requestBody
+ * the request Json object
+ *
+ * @return Error code
+ * @throws VtnServiceException
+ * the vtn service exception
+ */
+ @Override
+ public int get() throws VtnServiceException {
+ LOG.trace("Starts DifferenceConfigResource#get()");
+ ClientSession session = null;
+ int status = ClientSession.RESP_FATAL;
+ try {
+ LOG.debug("Start Ipc framework call");
+ session = getConnPool().getSession(
+ UncUPLLEnums.UPLL_IPC_CHANNEL_NAME,
+ UncUPLLEnums.UPLL_IPC_SERVICE_NAME,
+ UncUPLLEnums.ServiceID.UPLL_GLOBAL_CONFIG_SVC_ID.ordinal(),
+ getExceptionHandler());
+ LOG.debug("Session created successfully");
+ // set session timeout as infinity for config diff operation
+ session.setTimeout(null);
+ session.addOutput(IpcDataUnitWrapper
+ .setIpcUint32Value(UncUPLLEnums.UpllGlobalConfigOpT.UPLL_IS_CANDIDATE_DIRTY_OP
+ .getValue()));
+ LOG.info("Request packet created successfully");
+ status = session.invoke();
+ LOG.info("Request packet processed with status:" + status);
+ String operationType = IpcDataUnitWrapper
+ .getIpcDataUnitValue(session
+ .getResponse(VtnServiceJsonConsts.VAL_0));
+ int result = Integer.parseInt(IpcDataUnitWrapper
+ .getIpcDataUnitValue(session
+ .getResponse(VtnServiceJsonConsts.VAL_1)));
+ String dirtyStatus = IpcDataUnitWrapper.getIpcDataUnitValue(session
+ .getResponse(VtnServiceJsonConsts.VAL_2));
+ LOG.debug("Response retreived successfully");
+ LOG.debug("Operation type: " + operationType);
+ LOG.debug("Result Code: " + result);
+ LOG.debug("DirtyStatus: " + dirtyStatus);
+ if (result != UncIpcErrorCode.RC_SUCCESS) {
+ createTcErrorInfo(UncIpcErrorCode.getTcCodes(result));
+ status = UncCommonEnum.UncResultCode.UNC_SERVER_ERROR
+ .getValue();
+ } else {
+ if (UncStructIndexEnum.DirtyStatus.FALSE.getValue().equals(
+ dirtyStatus)) {
+ session = getConnPool().getSession(
+ UncUPPLEnums.UPPL_IPC_CHN_NAME,
+ UncUPPLEnums.UPPL_IPC_SVC_NAME,
+ UncUPPLEnums.ServiceID.UPPL_SVC_GLOBAL_CONFIG
+ .ordinal(), getExceptionHandler());
+ // set session timeout as infinity for config diff operation
+ session.setTimeout(null);
+ session.addOutput(IpcDataUnitWrapper
+ .setIpcUint32Value(UncUPPLEnums.UncAddlOperationT.UNC_OP_IS_CANDIDATE_DIRTY
+ .ordinal()));
+ LOG.debug("Request packet created successfully");
+ status = session.invoke();
+ LOG.debug("Request packet processed with status:" + status);
+ operationType = IpcDataUnitWrapper
+ .getIpcDataUnitValue(session
+ .getResponse(VtnServiceJsonConsts.VAL_0));
+ result = Integer.parseInt(IpcDataUnitWrapper
+ .getIpcDataUnitValue(session
+ .getResponse(VtnServiceJsonConsts.VAL_1)));
+ dirtyStatus = IpcDataUnitWrapper
+ .getIpcDataUnitValue(session
+ .getResponse(VtnServiceJsonConsts.VAL_2));
+ LOG.debug("Response retreived successfully");
+ LOG.debug("Operation type: " + operationType);
+ LOG.debug("Result Code: " + result);
+ LOG.debug("DirtyStatus: " + dirtyStatus);
+ if (result != UncIpcErrorCode.RC_SUCCESS) {
+ createTcErrorInfo(UncIpcErrorCode.getTcCodes(result));
+ status = UncCommonEnum.UncResultCode.UNC_SERVER_ERROR
+ .getValue();
+ } else {
+ createResponse(dirtyStatus);
+ LOG.debug("Request processed successfully");
+ status = UncCommonEnum.UncResultCode.UNC_SUCCESS
+ .getValue();
+ }
+ } else {
+ createResponse(dirtyStatus);
+ LOG.debug("Request processed successfully");
+ status = UncCommonEnum.UncResultCode.UNC_SUCCESS.getValue();
+ }
+ }
+ LOG.debug("Complete Ipc framework call");
+ } catch (final VtnServiceException e) {
+ getExceptionHandler()
+ .raise(Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR
+ .getErrorMessage(), e);
+ throw e;
+ } catch (final IpcException e) {
+ getExceptionHandler()
+ .raise(Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR
+ .getErrorMessage(), e);
+ } finally {
+ if (status == ClientSession.RESP_FATAL) {
+ createErrorInfo(UncCommonEnum.UncResultCode.UNC_SERVER_ERROR
+ .getValue());
+ status = UncCommonEnum.UncResultCode.UNC_SERVER_ERROR
+ .getValue();
+ }
+ // destroy session by common handler
+ getConnPool().destroySession(session);
+ }
+ LOG.trace("Completed DifferenceConfigResource#get()");
+ return status;
+ }
+
+ /**
+ * Creates Json response.
+ *
+ * @param dirtyStatus
+ * the dirty status
+ */
+ private void createResponse(String dirtyStatus) {
+ LOG.trace("Starts DifferenceConfigResource#createResponse()");
+ JsonObject response = new JsonObject();
+ JsonObject dirtyJson = new JsonObject();
+ if (UncStructIndexEnum.DirtyStatus.TRUE.getValue().equals(dirtyStatus)) {
+ dirtyJson.addProperty(VtnServiceJsonConsts.DIFF_STATUS,
+ VtnServiceJsonConsts.TRUE);
+ } else if (UncStructIndexEnum.DirtyStatus.FALSE.getValue().equals(
+ dirtyStatus)) {
+ dirtyJson.addProperty(VtnServiceJsonConsts.DIFF_STATUS,
+ VtnServiceJsonConsts.FALSE);
+ } else {
+ LOG.debug("dirtyStatus: invalid");
+ }
+ response.add(VtnServiceJsonConsts.DIFF, dirtyJson);
+ setInfo(response);
+ LOG.trace("Completed DifferenceConfigResource#createResponse()");
+ }
+}
LOG.info("OperationStatus" + operationStatus);
if (operationStatus != UncTCEnums.OperationStatus.TC_OPER_SUCCESS
.getCode()) {
- createErrorInfo(
- UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue(),
- UncIpcErrorCode.getTcCodes(operationStatus));
+ createTcErrorInfo(UncIpcErrorCode.getTcCodes(operationStatus));
LOG.info("Request not processed successfully");
status = UncCommonEnum.UncResultCode.UNC_SERVER_ERROR
.getValue();
LOG.info("OperationStatus" + operationStatus);
if (operationStatus != UncTCEnums.OperationStatus.TC_OPER_SUCCESS
.getCode()) {
- createErrorInfo(
- UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue(),
- UncIpcErrorCode.getTcCodes(operationStatus));
+ createTcErrorInfo(UncIpcErrorCode.getTcCodes(operationStatus));
LOG.info("Request not processed successfully");
status = UncCommonEnum.UncResultCode.UNC_SERVER_ERROR
.getValue();
LOG.info("OperationStatus" + operationStatus);
if (operationStatus != UncTCEnums.OperationStatus.TC_OPER_SUCCESS
.getCode()) {
- createErrorInfo(
- UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue(),
- UncIpcErrorCode.getTcCodes(operationStatus));
+ createTcErrorInfo(UncIpcErrorCode.getTcCodes(operationStatus));
LOG.info("Request not processed successfully");
status = UncCommonEnum.UncResultCode.UNC_SERVER_ERROR
.getValue();
LOG.info("Request packet processed with status:"+status);
if (status != UncSessionEnums.UsessIpcErrE.USESS_E_OK.ordinal()) {
LOG.info("Error occurred while performing operation");
- createErrorInfo(
- UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue(),
- UncIpcErrorCode.getSessionCodes(status));
+ createSessionErrorInfo(UncIpcErrorCode.getSessionCodes(status));
status = UncResultCode.UNC_SERVER_ERROR.getValue();
} else {
LOG.info("Opeartion successfully performed");
LOG.info("Request packet processed with status:"+status);
if (status != UncSessionEnums.UsessIpcErrE.USESS_E_OK.ordinal()) {
LOG.info("Error occurred while performing operation");
- createErrorInfo(
- UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue(),
- UncIpcErrorCode.getSessionCodes(status));
+ createSessionErrorInfo(UncIpcErrorCode.getSessionCodes(status));
status = UncResultCode.UNC_SERVER_ERROR.getValue();
} else {
LOG.info("Opeartion successfully performed");
.equals(UncSessionEnums.UsessTypeE.USESS_TYPE_WEB_UI.getValue())) {
sessJson.addProperty(VtnServiceJsonConsts.TYPE,
VtnServiceJsonConsts.WEBUI);
+ } else{
+ LOG.debug("Incorrect value for type");
}
LOG.debug("type:"
+ IpcDataUnitWrapper.getIpcStructUint32Value(responseStruct,
} else if (VtnServiceIpcConsts.USESS_USER_WEB_OPER.equals(userName)) {
sessJson.addProperty(VtnServiceJsonConsts.USERNAME,
VtnServiceJsonConsts.OPER);
+ } else{
+ LOG.debug("Incorrect value for user_name");
}
// add user type to response json
if (IpcDataUnitWrapper
.equals(UncSessionEnums.UserTypeE.USER_TYPE_OPER.getValue())) {
sessJson.addProperty(VtnServiceJsonConsts.USERTYPE,
VtnServiceJsonConsts.OPER);
+ } else{
+ LOG.debug("Incorrect value for user_type");
}
LOG.debug("usertype:"
+ IpcDataUnitWrapper.getIpcStructUint32Value(responseStruct,
LOG.debug("info:"
+ IpcDataUnitWrapper.getIpcStructUint8ArrayValue(
responseStruct, VtnServiceJsonConsts.INFO));
+ // add mode to response json
+ if (IpcDataUnitWrapper
+ .getIpcStructUint32Value(responseStruct,
+ VtnServiceIpcConsts.SESS_MODE).toString()
+ .equals(UncSessionEnums.UsessModeE.USESS_MODE_OPER.getValue())) {
+ sessJson.addProperty(VtnServiceJsonConsts.MODE,
+ VtnServiceJsonConsts.OPER);
+ } else if (IpcDataUnitWrapper
+ .getIpcStructUint32Value(responseStruct,
+ VtnServiceIpcConsts.SESS_MODE)
+ .toString()
+ .equals(UncSessionEnums.UsessModeE.USESS_MODE_ENABLE.getValue())) {
+ sessJson.addProperty(VtnServiceJsonConsts.MODE,
+ VtnServiceJsonConsts.ENABLE);
+ } else if (IpcDataUnitWrapper
+ .getIpcStructUint32Value(responseStruct,
+ VtnServiceIpcConsts.SESS_MODE).toString()
+ .equals(UncSessionEnums.UsessModeE.USESS_MODE_DEL.getValue())) {
+ sessJson.addProperty(VtnServiceJsonConsts.MODE,
+ VtnServiceJsonConsts.DEL);
+ } else if (IpcDataUnitWrapper
+ .getIpcStructUint32Value(responseStruct,
+ VtnServiceIpcConsts.SESS_MODE)
+ .toString()
+ .equals(UncSessionEnums.UsessModeE.USESS_MODE_UNKNOWN
+ .getValue())) {
+ sessJson.addProperty(VtnServiceJsonConsts.MODE,
+ VtnServiceJsonConsts.UNKNOWN);
+ } else{
+ LOG.debug("Incorrect value for mode");
+ }
+ LOG.debug("mode: "
+ + IpcDataUnitWrapper.getIpcStructUint32Value(responseStruct,
+ VtnServiceIpcConsts.SESS_MODE));
+ // add configstatus to response json
+ if (IpcDataUnitWrapper
+ .getIpcStructUint32Value(responseStruct,
+ VtnServiceIpcConsts.CONFIG_STATUS)
+ .toString()
+ .equals(UncSessionEnums.UsessConfigModeE.CONFIG_STATUS_NONE
+ .getValue())) {
+ sessJson.addProperty(VtnServiceJsonConsts.CONFIGSTATUS,
+ VtnServiceJsonConsts.DISABLE);
+ } else if (IpcDataUnitWrapper
+ .getIpcStructUint32Value(responseStruct,
+ VtnServiceIpcConsts.CONFIG_STATUS)
+ .toString()
+ .equals(UncSessionEnums.UsessConfigModeE.CONFIG_STATUS_TCLOCK
+ .getValue())) {
+ sessJson.addProperty(VtnServiceJsonConsts.CONFIGSTATUS,
+ VtnServiceJsonConsts.ENABLE);
+ } else{
+ LOG.debug("Incorrect value for config_status");
+ }
+ LOG.debug("configstatus: "
+ + IpcDataUnitWrapper.getIpcStructUint32Value(responseStruct,
+ VtnServiceIpcConsts.CONFIG_STATUS));
response.add(VtnServiceJsonConsts.SESSION, sessJson);
LOG.trace("Completed SessionResource#createGetResponse()");
return response;
public int post(final JsonObject requestBody) throws VtnServiceException {
LOG.trace("Starts SessionsResource#post()");
ClientSession session = null;
+ ClientSession sessionEnable = null;
int status = ClientSession.RESP_FATAL;
try {
LOG.debug("Start Ipc framework call");
.setIpcUint8ArrayValue(VtnServiceIpcConsts.USESS_USER_WEB_ADMIN));
LOG.debug("Login from admin user"
+ sessionJson.getAsJsonPrimitive(
- VtnServiceJsonConsts.USERNAME).toString());
+ VtnServiceJsonConsts.USERNAME)
+ .getAsString());
} else {
usessIpcReqSessAdd
.set(VtnServiceIpcConsts.SESS_UNAME,
.setIpcUint8ArrayValue(VtnServiceIpcConsts.USESS_USER_WEB_OPER));
LOG.debug("Login from oper user"
+ sessionJson.getAsJsonPrimitive(
- VtnServiceJsonConsts.USERNAME).toString());
+ VtnServiceJsonConsts.USERNAME)
+ .getAsString());
}
LOG.debug("sess_uname: "
+ IpcDataUnitWrapper.getIpcStructUint8ArrayValue(
// add type to usess_ipc_req_sess_add structure
if (sessionJson.has(VtnServiceJsonConsts.TYPE)
&& sessionJson.getAsJsonPrimitive(
- VtnServiceJsonConsts.TYPE).getAsString() != null) {
- final String type = sessionJson
- .getAsJsonPrimitive(VtnServiceJsonConsts.TYPE)
- .getAsString().trim();
- if (VtnServiceJsonConsts.WEBAPI.equalsIgnoreCase(type)) {
- usessIpcReqSessAdd
- .set(VtnServiceIpcConsts.SESS_TYPE,
- IpcDataUnitWrapper
- .setIpcInt32Value(UncSessionEnums.UsessTypeE.USESS_TYPE_WEB_API
- .ordinal()));
- } else {
- usessIpcReqSessAdd
- .set(VtnServiceIpcConsts.SESS_TYPE,
- IpcDataUnitWrapper
- .setIpcInt32Value(UncSessionEnums.UsessTypeE.USESS_TYPE_WEB_UI
- .ordinal()));
- }
+ VtnServiceJsonConsts.TYPE).getAsString() != null
+ && sessionJson
+ .getAsJsonPrimitive(VtnServiceJsonConsts.TYPE)
+ .getAsString().trim()
+ .equalsIgnoreCase(VtnServiceJsonConsts.WEBAPI)) {
+ usessIpcReqSessAdd
+ .set(VtnServiceIpcConsts.SESS_TYPE,
+ IpcDataUnitWrapper
+ .setIpcInt32Value(UncSessionEnums.UsessTypeE.USESS_TYPE_WEB_API
+ .ordinal()));
} else {
usessIpcReqSessAdd
- .set(VtnServiceIpcConsts.SESS_TYPE,
- IpcDataUnitWrapper
- .setIpcInt32Value(UncSessionEnums.UsessTypeE.USESS_TYPE_WEB_UI
- .ordinal()));
+ .set(VtnServiceIpcConsts.SESS_TYPE,
+ IpcDataUnitWrapper
+ .setIpcInt32Value(UncSessionEnums.UsessTypeE.USESS_TYPE_WEB_UI
+ .ordinal()));
}
+ LOG.debug("sess_type: "
+ + IpcDataUnitWrapper.getIpcStructUint32Value(
+ usessIpcReqSessAdd,
+ VtnServiceIpcConsts.SESS_TYPE));
// add ip address to usess_ipc_req_sess_add structure
usessIpcReqSessAdd.set(VtnServiceJsonConsts.IPADDR,
session.addOutput(usessIpcReqSessAdd);
LOG.info("Request packet created successfully");
status = session.invoke();
- LOG.info("Request packet processed with status:"+status);
+ LOG.info("Request packet processed with status:" + status);
if (status != UncSessionEnums.UsessIpcErrE.USESS_E_OK.ordinal()) {
LOG.info("Error occurred while performing operation");
- createErrorInfo(
- UncCommonEnum.UncResultCode.UNC_SERVER_ERROR
- .getValue(),
- UncIpcErrorCode.getSessionCodes(status));
+ createSessionErrorInfo(UncIpcErrorCode.getSessionCodes(status));
status = UncResultCode.UNC_SERVER_ERROR.getValue();
} else {
LOG.info("Opeartion successfully performed");
final IpcStruct responseStruct = (IpcStruct) session
.getResponse(0);
final JsonObject sessionInfo = new JsonObject();
+ final String sessionId = IpcDataUnitWrapper.getIpcStructUint32Value(
+ responseStruct, VtnServiceIpcConsts.ID)
+ .toString();
sessionInfo.addProperty(
- VtnServiceJsonConsts.SESSIONID,
- IpcDataUnitWrapper.getIpcStructUint32Value(
- responseStruct, VtnServiceIpcConsts.ID)
- .toString());
+ VtnServiceJsonConsts.SESSIONID, sessionId);
response.add(VtnServiceJsonConsts.SESSION, sessionInfo);
setInfo(response);
- status = UncResultCode.UNC_SUCCESS.getValue();
+
+ if (sessionJson.has(VtnServiceJsonConsts.USERNAME)
+ && sessionJson
+ .getAsJsonPrimitive(
+ VtnServiceJsonConsts.USERNAME)
+ .getAsString()
+ .equalsIgnoreCase(
+ VtnServiceJsonConsts.ADMIN)) {
+ sessionEnable = getConnPool()
+ .getSession(
+ UncSessionEnums.UNCD_IPC_CHANNEL,
+ UncSessionEnums.UNCD_IPC_SERVICE,
+ UncSessionEnums.ServiceID.kUsessEnable
+ .ordinal(),
+ getExceptionHandler());
+ LOG.info("Session created successfully");
+ // create request packet for IPC call based on API key
+ // and JsonObject
+ final IpcStruct usessIpcReqSessEnable = new IpcStruct(
+ UncStructEnum.UsessIpcReqSessEnable.getValue());
+ // create request IPC Structure for current session from
+ // which user logged in
+ final IpcStruct usessIpcReqSessIdCurrent = new IpcStruct(
+ UncStructEnum.UsessIpcSessId.getValue());
+ usessIpcReqSessIdCurrent
+ .set(VtnServiceIpcConsts.ID, IpcDataUnitWrapper
+ .setIpcUint32Value(sessionId));
+ usessIpcReqSessEnable.set(VtnServiceIpcConsts.CURRENT,
+ usessIpcReqSessIdCurrent);
+ usessIpcReqSessEnable
+ .set(VtnServiceIpcConsts.ENABLE_PASSWORD,
+ IpcDataUnitWrapper
+ .setIpcUint8ArrayValue(sessionJson
+ .getAsJsonPrimitive(
+ VtnServiceJsonConsts.PASSWORD)
+ .getAsString()));
+ sessionEnable.addOutput(usessIpcReqSessEnable);
+ LOG.info("Request packet created successfully");
+ status = sessionEnable.invoke();
+ LOG.info("Request packet processed with status:"
+ + status);
+ if (status != UncSessionEnums.UsessIpcErrE.USESS_E_OK
+ .ordinal()) {
+ LOG.info("Error occurred while performing operation");
+ createSessionErrorInfo(UncIpcErrorCode
+ .getSessionCodes(status));
+ status = UncResultCode.UNC_SERVER_ERROR.getValue();
+ } else {
+ status = UncResultCode.UNC_SUCCESS.getValue();
+ }
+ } else {
+ status = UncResultCode.UNC_SUCCESS.getValue();
+ }
}
}
LOG.debug("Complete Ipc framework call");
}
// destroy session by common handler
getConnPool().destroySession(session);
+ if(sessionEnable != null){
+ getConnPool().destroySession(sessionEnable);
+ }
}
LOG.trace("Completed SessionsResource#post()");
return status;
session.addOutput(usessIpcReqSessId);
LOG.info("Request packet created successfully");
status = session.invoke();
- LOG.info("Request packet processed with status:"+status);
+ LOG.info("Request packet processed with status:" + status);
if (status != UncSessionEnums.UsessIpcErrE.USESS_E_OK.ordinal()) {
LOG.info("Error occurred while performing operation");
- createErrorInfo(
- UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue(),
- UncIpcErrorCode.getSessionCodes(status));
+ createSessionErrorInfo(UncIpcErrorCode.getSessionCodes(status));
status = UncResultCode.UNC_SERVER_ERROR.getValue();
} else {
LOG.info("Opeartion successfully performed");
sessJson = new JsonObject();
final IpcStruct ipcResponseStructId = responseStruct
.getInner(VtnServiceIpcConsts.SESS);
- LOG.debug("user_type:" + responseStruct.get("user_type"));
- // LOG.debug("sess_uname:" + responseStruct.get("sess_uname"));
- // add session id to response json
sessJson.addProperty(
VtnServiceJsonConsts.SESSIONID,
IpcDataUnitWrapper.getIpcStructUint32Value(
.getValue())) {
sessJson.addProperty(VtnServiceJsonConsts.TYPE,
VtnServiceJsonConsts.WEBUI);
+ } else {
+ LOG.debug("Incorrect value for type");
}
LOG.debug("type:"
+ IpcDataUnitWrapper.getIpcStructUint32Value(
.equals(userName)) {
sessJson.addProperty(VtnServiceJsonConsts.USERNAME,
VtnServiceJsonConsts.OPER);
+ } else {
+ LOG.debug("Incorrect value for user_name");
}
// add user type to response json
if (IpcDataUnitWrapper
.getValue())) {
sessJson.addProperty(VtnServiceJsonConsts.USERTYPE,
VtnServiceJsonConsts.OPER);
+ } else {
+ LOG.debug("Incorrect value for usertype");
}
LOG.debug("usertype:"
+ IpcDataUnitWrapper.getIpcStructUint32Value(
LOG.debug("info:"
+ IpcDataUnitWrapper.getIpcStructUint8ArrayValue(
responseStruct, VtnServiceJsonConsts.INFO));
+ // add mode to response json
+ if (IpcDataUnitWrapper
+ .getIpcStructUint32Value(responseStruct,
+ VtnServiceIpcConsts.SESS_MODE).toString()
+ .equals(UncSessionEnums.UsessModeE.USESS_MODE_OPER.getValue())) {
+ sessJson.addProperty(VtnServiceJsonConsts.MODE,
+ VtnServiceJsonConsts.OPER);
+ } else if (IpcDataUnitWrapper
+ .getIpcStructUint32Value(responseStruct,
+ VtnServiceIpcConsts.SESS_MODE)
+ .toString()
+ .equals(UncSessionEnums.UsessModeE.USESS_MODE_ENABLE.getValue())) {
+ sessJson.addProperty(VtnServiceJsonConsts.MODE,
+ VtnServiceJsonConsts.ENABLE);
+ } else if (IpcDataUnitWrapper
+ .getIpcStructUint32Value(responseStruct,
+ VtnServiceIpcConsts.SESS_MODE).toString()
+ .equals(UncSessionEnums.UsessModeE.USESS_MODE_DEL.getValue())) {
+ sessJson.addProperty(VtnServiceJsonConsts.MODE,
+ VtnServiceJsonConsts.DEL);
+ } else if (IpcDataUnitWrapper
+ .getIpcStructUint32Value(responseStruct,
+ VtnServiceIpcConsts.SESS_MODE)
+ .toString()
+ .equals(UncSessionEnums.UsessModeE.USESS_MODE_UNKNOWN
+ .getValue())) {
+ sessJson.addProperty(VtnServiceJsonConsts.MODE,
+ VtnServiceJsonConsts.UNKNOWN);
+ } else {
+ LOG.debug("Incorrect value for mode");
+ }
+ LOG.debug("mode: "
+ + IpcDataUnitWrapper.getIpcStructUint32Value(responseStruct,
+ VtnServiceIpcConsts.SESS_MODE));
+ // add configstatus to response json
+ if (IpcDataUnitWrapper
+ .getIpcStructUint32Value(responseStruct,
+ VtnServiceIpcConsts.CONFIG_STATUS)
+ .toString()
+ .equals(UncSessionEnums.UsessConfigModeE.CONFIG_STATUS_NONE
+ .getValue())) {
+ sessJson.addProperty(VtnServiceJsonConsts.CONFIGSTATUS,
+ VtnServiceJsonConsts.DISABLE);
+ } else if (IpcDataUnitWrapper
+ .getIpcStructUint32Value(responseStruct,
+ VtnServiceIpcConsts.CONFIG_STATUS)
+ .toString()
+ .equals(UncSessionEnums.UsessConfigModeE.CONFIG_STATUS_TCLOCK
+ .getValue())) {
+ sessJson.addProperty(VtnServiceJsonConsts.CONFIGSTATUS,
+ VtnServiceJsonConsts.ENABLE);
+ } else {
+ LOG.debug("Incorrect value for config_status");
+ }
+ LOG.debug("configstatus: "
+ + IpcDataUnitWrapper.getIpcStructUint32Value(responseStruct,
+ VtnServiceIpcConsts.CONFIG_STATUS));
}
sessArray.add(sessJson);
}
response.add(VtnServiceJsonConsts.SESSIONS, sessArray);
LOG.trace("Completed SessionsResource#createGetResponse()");
}
-
}
usessIpcReqSessId);
// set user name
+ LOG.info("set user name for : " + getUserName());
usessIpcReqUserPasswd.set(VtnServiceIpcConsts.SESS_UNAME,
- IpcDataUnitWrapper.setIpcUint8ArrayValue(getUserName()));
+ IpcDataUnitWrapper.setIpcUint8ArrayValue(getUNCUserName(getUserName())));
// set password
+ LOG.info("set password");
usessIpcReqUserPasswd.set(
- VtnServiceJsonConsts.PASSWORD,
+ VtnServiceIpcConsts.SESS_PASSWD,
IpcDataUnitWrapper.setIpcUint8ArrayValue(requestBody
.getAsJsonPrimitive(VtnServiceJsonConsts.PASSWORD)
.getAsString().trim()));
LOG.info("Request packet processed with status:"+status);
if (status != UncSessionEnums.UsessIpcErrE.USESS_E_OK.ordinal()) {
LOG.info("Error occurred while performing operation");
- createErrorInfo(
- UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue(),
- UncIpcErrorCode.getSessionCodes(status));
+ createSessionErrorInfo(UncIpcErrorCode.getSessionCodes(status));
status = UncResultCode.UNC_SERVER_ERROR.getValue();
} else {
LOG.info("Opeartion successfully performed");
LOG.trace("Completed UserResource#put()");
return status;
}
+
+ /**
+ * Convert the higher level user name to USESS user name
+ * @param userName
+ * @return
+ */
+ private String getUNCUserName(String userName) {
+ LOG.debug("User name : " + userName);
+ String uncUserName = null;
+ if (userName.equalsIgnoreCase(VtnServiceJsonConsts.ADMIN)) {
+ uncUserName = VtnServiceIpcConsts.USESS_USER_WEB_ADMIN;
+ } else if (userName.equalsIgnoreCase(VtnServiceJsonConsts.OPER)){
+ uncUserName = VtnServiceIpcConsts.USESS_USER_WEB_OPER;
+ }
+ LOG.debug("UNC user name : " + uncUserName);
+ return uncUserName;
+ }
}
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
/** The vrt name. */
@UNCField("vrt_name")
private String vrtName;
+
/**
* @return the vtn name
*/
public String getVtnName() {
return vtnName;
}
+
/**
* @return the vrt name
*/
public String getVrtName() {
return vrtName;
}
+
private static final Logger LOG = Logger
.getLogger(DhcpRelayInterfacesResource.class.getName());
+
/**
* Instantiates a new dhcp relay interfaces resource.
*/
setValidator(new InterfaceResourceValidator(this));
LOG.trace("Complete DhcpRelayInterfacesResource#DhcpRelayInterfacesResource()");
}
+
/**
* Implementation of post method of Dhcp Relay Interface
*
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_DHCPRELAY_IF_CREATE, requestBody,
- getUriParameters(requestBody));
+ uriParameterList);
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
return status;
}
+
/**
* Implementation of get method of Dhcp Relay Interface
*
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_DHCPRELAY_IF_GET, requestBody,
- getUriParameters(requestBody));
+ uriParameterList);
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
- setInfo(responseGenerator.getDhcpRelayInterfaceResponse(
- requestProcessor.getIpcResponsePacket(), requestBody,
- VtnServiceJsonConsts.LIST));
+ /*
+ * setInfo(responseGenerator.getDhcpRelayInterfaceResponse(
+ * requestProcessor.getIpcResponsePacket(), requestBody,
+ * VtnServiceJsonConsts.LIST));
+ */
+ JsonObject responseJson = responseGenerator
+ .getDhcpRelayInterfaceResponse(
+ requestProcessor.getIpcResponsePacket(),
+ requestBody, VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.INTERFACES).isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.INTERFACES).getAsJsonArray();
+ responseJson = getResponseJsonArrayLogical(requestBody,
+ requestProcessor, responseGenerator, responseArray,
+ VtnServiceJsonConsts.INTERFACES,
+ VtnServiceJsonConsts.IFNAME,
+ IpcRequestPacketEnum.KT_DHCPRELAY_IF_GET,
+ uriParameterList,
+ VtnServiceIpcConsts.GET_DHCP_RELAY_IF_RESPONSE);
+ }
+ setInfo(responseJson);
LOG.debug("Response object created successfully");
LOG.debug("Ipc framework call complete");
} catch (final VtnServiceException e) {
LOG.trace("Completed DhcpRelayInterfacesResource#get()");
return status;
}
+
/**
* Add URI parameters to list
*
* @return
*/
- private List<String> getUriParameters(final JsonObject requestBody) {
+ private List<String> getUriParameters(final JsonObject requestBody) {
LOG.trace("Start DhcpRelayInterfacesResource#getUriParameters()");
final List<String> uriParameters = new ArrayList<String>();
uriParameters.add(vtnName);
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
/** The vrt name. */
@UNCField("vrt_name")
private String vrtName;
+
/**
*
* @return the vtn name
public String getVtnName() {
return vtnName;
}
+
/**
*
* @return the vrt name
public String getVrtName() {
return vrtName;
}
+
private static final Logger LOG = Logger
.getLogger(DhcpRelayServersResource.class.getName());
+
/**
* Instantiates a new dhcp relay servers resource.
*/
setValidator(new DhcpRelayServerResourceValidator(this));
LOG.trace("Complete DhcpRelayServersResource#DhcpRelayServersResource()");
}
+
/**
* Implementation of post method of Dhcp Relay Server
*
UncUPLLEnums.ServiceID.UPLL_EDIT_SVC_ID.ordinal(),
getExceptionHandler());
LOG.debug("Session created successfully");
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_DHCPRELAY_SERVER_CREATE,
- requestBody, getUriParameters(requestBody));
+ requestBody, uriParameterList);
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
LOG.trace("Complete DhcpRelayServersResource#post()");
return status;
}
+
/**
* Implementation of get method of Dhcp Relay Server
*
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_DHCPRELAY_SERVER_GET, requestBody,
- getUriParameters(requestBody));
+ uriParameterList);
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
- setInfo(responseGenerator.getDHCPRelayServerResponse(
- requestProcessor.getIpcResponsePacket(), requestBody,
- VtnServiceJsonConsts.LIST));
+ /*
+ * setInfo(responseGenerator.getDHCPRelayServerResponse(
+ * requestProcessor.getIpcResponsePacket(), requestBody,
+ * VtnServiceJsonConsts.LIST));
+ */
+ JsonObject responseJson = responseGenerator
+ .getDHCPRelayServerResponse(
+ requestProcessor.getIpcResponsePacket(),
+ requestBody, VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.SERVERS).isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.SERVERS).getAsJsonArray();
+ responseJson = getResponseJsonArrayLogical(requestBody,
+ requestProcessor, responseGenerator, responseArray,
+ VtnServiceJsonConsts.SERVERS,
+ VtnServiceJsonConsts.IPADDR,
+ IpcRequestPacketEnum.KT_DHCPRELAY_SERVER_GET,
+ uriParameterList,
+ VtnServiceIpcConsts.GET_DHCP_RELAY_SERVER_RESPONSE);
+ }
+ setInfo(responseJson);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
LOG.trace("Complete DhcpRelayServersResource#get()");
return status;
}
+
/**
* Add URI parameters to list
*
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ // Uriparamter list
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VTN_FLOWFILTER_ENTRY_GET,
- requestBody, getUriParameters(requestBody));
+ requestBody, uriParameterList);
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
- setInfo(responseGenerator.getVtnFlowFilterEntryResponse(
+ /*setInfo(responseGenerator.getVtnFlowFilterEntryResponse(
+ requestProcessor.getIpcResponsePacket(), requestBody,
+ VtnServiceJsonConsts.LIST));*/
+ JsonObject responseJson = responseGenerator.getVtnFlowFilterEntryResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
- VtnServiceJsonConsts.LIST));
+ VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.FLOWFILTERENTRIES).isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.FLOWFILTERENTRIES).getAsJsonArray();
+
+ responseJson = getResponseJsonArrayLogical(requestBody,
+ requestProcessor, responseGenerator,
+ responseArray, VtnServiceJsonConsts.FLOWFILTERENTRIES,
+ VtnServiceJsonConsts.SEQNUM,
+ IpcRequestPacketEnum.KT_VTN_FLOWFILTER_ENTRY_GET,
+ uriParameterList,VtnServiceIpcConsts.GET_VTN_FLOW_FILETER_ENTRY_RESPONSE);
+ }
+ setInfo(responseJson);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
+ .raise(Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR
- .getErrorMessage(), e);
+ .getErrorMessage(), e);
throw e;
} finally {
if (status == ClientSession.RESP_FATAL) {
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
+ .raise(Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR
- .getErrorMessage(), e);
+ .getErrorMessage(), e);
throw e;
} finally {
if (status == ClientSession.RESP_FATAL) {
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ // Uriparamter list
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_FLOWLIST_ENTRY_GET, requestBody,
- getUriParameters(requestBody));
+ uriParameterList);
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
- setInfo(responseGenerator.getFlowListEntryResponse(
+ /* setInfo(responseGenerator.getFlowListEntryResponse(
+ requestProcessor.getIpcResponsePacket(), requestBody,
+ VtnServiceJsonConsts.LIST));*/
+ JsonObject responseJson = responseGenerator.getFlowListEntryResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
- VtnServiceJsonConsts.LIST));
+ VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.FLOWLISTENTRIES).isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.FLOWLISTENTRIES).getAsJsonArray();
+
+ responseJson = getResponseJsonArrayLogical(requestBody,
+ requestProcessor, responseGenerator,
+ responseArray, VtnServiceJsonConsts.FLOWLISTENTRIES,
+ VtnServiceJsonConsts.SEQNUM,
+ IpcRequestPacketEnum.KT_FLOWLIST_ENTRY_GET,
+ uriParameterList,VtnServiceIpcConsts.GET_FLOW_LIST_ENTRY_RESPONSE);
+ }
+ setInfo(responseJson);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
+ .raise(Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR
- .getErrorMessage(), e);
+ .getErrorMessage(), e);
throw e;
} finally {
if (status == ClientSession.RESP_FATAL) {
if (requestBody != null && requestBody.has(VtnServiceJsonConsts.INDEX)) {
uriParameters.add(requestBody.get(VtnServiceJsonConsts.INDEX).getAsString());
- }
+ }
LOG.trace("Completed FlowListEntriesResource#getUriParameters()");
return uriParameters;
}
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
} catch (final VtnServiceException e) {
getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
+ .raise(Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR
- .getErrorMessage(), e);
+ .getErrorMessage(), e);
throw e;
} finally {
if (status == ClientSession.RESP_FATAL) {
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ // Uriparamter list
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_FLOWLIST_GET, requestBody,
- getUriParameters(requestBody));
+ uriParameterList);
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
- setInfo(responseGenerator.getFlowListResponse(
+ /*
+ * setInfo(responseGenerator.getFlowListResponse(
+ * requestProcessor.getIpcResponsePacket(), requestBody,
+ * VtnServiceJsonConsts.LIST));
+ */
+ JsonObject responseJson = responseGenerator.getFlowListResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
- VtnServiceJsonConsts.LIST));
+ VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.FLOWLISTS).isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.FLOWLISTS).getAsJsonArray();
+
+
+ responseJson = getResponseJsonArrayLogical(requestBody,
+ requestProcessor, responseGenerator,
+ responseArray, VtnServiceJsonConsts.FLOWLISTS,
+ VtnServiceJsonConsts.FLNAME,
+ IpcRequestPacketEnum.KT_FLOWLIST_GET,
+ uriParameterList,VtnServiceIpcConsts.GET_FLOW_LIST_RESPONSE);
+
+ }
+ setInfo(responseJson);
+
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
+ .raise(Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR
- .getErrorMessage(), e);
+ .getErrorMessage(), e);
throw e;
} finally {
if (status == ClientSession.RESP_FATAL) {
IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
setInfo(responseGenerator.getPortMapResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
- VtnServiceJsonConsts.SHOW));
+ VtnServiceJsonConsts.SHOW,VtnServiceJsonConsts.VBRIDGE_INTERFACE_PORTMAP));
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
return status;
}
- /**
- * Implementation of put method of Static Ip Routes
- *
- * @param requestBody
- * the request Json object
- *
- * @return Error code
- * @throws VtnServiceException
- */
- @Override
- public int put(final JsonObject requestBody) throws VtnServiceException {
- LOG.trace("Start StaticIpRouteResource#put()");
- ClientSession session = null;
- IpcRequestProcessor requestProcessor = null;
- int status = ClientSession.RESP_FATAL;
- try {
- LOG.debug("Start Ipc framework call");
- session = getConnPool().getSession(
- UncUPLLEnums.UPLL_IPC_CHANNEL_NAME,
- UncUPLLEnums.UPLL_IPC_SERVICE_NAME,
- UncUPLLEnums.ServiceID.UPLL_EDIT_SVC_ID.ordinal(),
- getExceptionHandler());
- LOG.debug("Session created successfully");
- requestProcessor = new IpcRequestProcessor(session, getSessionID(),
- getConfigID(), getExceptionHandler());
- requestProcessor.createIpcRequestPacket(
- IpcRequestPacketEnum.KT_VRT_IPROUTE_UPDATE, requestBody,
- getUriParameters());
- LOG.debug("Request Packet created successfully");
- status = requestProcessor.processIpcRequest();
- LOG.debug("Request packet processed with status" + status);
- LOG.debug("Complete Ipc framework call");
- } catch (final VtnServiceException e) {
- getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
- UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
- UncJavaAPIErrorCode.IPC_SERVER_ERROR
- .getErrorMessage(), e);
- throw e;
- } finally {
- if (status == ClientSession.RESP_FATAL) {
- if (null != requestProcessor.getErrorJson()) {
- setInfo(requestProcessor.getErrorJson());
- } else {
- createErrorInfo(UncCommonEnum.UncResultCode.UNC_SERVER_ERROR
- .getValue());
- }
- status = UncResultCode.UNC_SERVER_ERROR.getValue();
- }
- getConnPool().destroySession(session);
- }
-
- LOG.trace("Complete StaticIpRouteResource#put()");
- return status;
- }
+// /**
+// * Implementation of put method of Static Ip Routes
+// *
+// * @param requestBody
+// * the request Json object
+// *
+// * @return Error code
+// * @throws VtnServiceException
+// */
+// @Override
+// public int put(final JsonObject requestBody) throws VtnServiceException {
+// LOG.trace("Start StaticIpRouteResource#put()");
+// ClientSession session = null;
+// IpcRequestProcessor requestProcessor = null;
+// int status = ClientSession.RESP_FATAL;
+// try {
+// LOG.debug("Start Ipc framework call");
+// session = getConnPool().getSession(
+// UncUPLLEnums.UPLL_IPC_CHANNEL_NAME,
+// UncUPLLEnums.UPLL_IPC_SERVICE_NAME,
+// UncUPLLEnums.ServiceID.UPLL_EDIT_SVC_ID.ordinal(),
+// getExceptionHandler());
+// LOG.debug("Session created successfully");
+// requestProcessor = new IpcRequestProcessor(session, getSessionID(),
+// getConfigID(), getExceptionHandler());
+// requestProcessor.createIpcRequestPacket(
+// IpcRequestPacketEnum.KT_VRT_IPROUTE_UPDATE, requestBody,
+// getUriParameters());
+// LOG.debug("Request Packet created successfully");
+// status = requestProcessor.processIpcRequest();
+// LOG.debug("Request packet processed with status" + status);
+// LOG.debug("Complete Ipc framework call");
+// } catch (final VtnServiceException e) {
+// getExceptionHandler()
+// .raise(Thread.currentThread().getStackTrace()[1]
+// .getClassName()
+// + VtnServiceConsts.HYPHEN
+// + Thread.currentThread().getStackTrace()[1]
+// .getMethodName(),
+// UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
+// UncJavaAPIErrorCode.IPC_SERVER_ERROR
+// .getErrorMessage(), e);
+// throw e;
+// } finally {
+// if (status == ClientSession.RESP_FATAL) {
+// if (null != requestProcessor.getErrorJson()) {
+// setInfo(requestProcessor.getErrorJson());
+// } else {
+// createErrorInfo(UncCommonEnum.UncResultCode.UNC_SERVER_ERROR
+// .getValue());
+// }
+// status = UncResultCode.UNC_SERVER_ERROR.getValue();
+// }
+// getConnPool().destroySession(session);
+// }
+//
+// LOG.trace("Complete StaticIpRouteResource#put()");
+// return status;
+// }
/**
* Add URI parameters to list
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
- if (requestBody != null
+ /*if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.STATIC_IPROUTE)
&& !((JsonObject) requestBody
.get(VtnServiceJsonConsts.STATIC_IPROUTE))
((JsonObject) requestBody
.get(VtnServiceJsonConsts.STATIC_IPROUTE)).addProperty(
VtnServiceJsonConsts.NMG_NAME, "");
- }
+ }*/
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VRT_IPROUTE_CREATE, requestBody,
- getUriParameters(requestBody));
+ uriParameterList);
LOG.debug("Request Packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
// StaticIp Route
String ipAddr = null;
String nextHopAddr = null;
- String netMask = null;
- String nmgName = null;
+ String prefix = null;
+ //String nmgName = null;
String staticIpRouteId = null;
if (requestBody != null
&& requestBody.has(VtnServiceJsonConsts.STATIC_IPROUTE)
.has(VtnServiceJsonConsts.IPADDR)
&& ((JsonObject) requestBody
.get(VtnServiceJsonConsts.STATIC_IPROUTE))
- .has(VtnServiceJsonConsts.NETMASK)
- && ((JsonObject) requestBody
- .get(VtnServiceJsonConsts.STATIC_IPROUTE))
- .has(VtnServiceJsonConsts.NMG_NAME)
+ .has(VtnServiceJsonConsts.PREFIX)
&& ((JsonObject) requestBody
.get(VtnServiceJsonConsts.STATIC_IPROUTE))
.has(VtnServiceJsonConsts.NEXTHOPADDR)) {
nextHopAddr = ((JsonObject) requestBody
.get(VtnServiceJsonConsts.STATIC_IPROUTE)).get(
VtnServiceJsonConsts.NEXTHOPADDR).getAsString();
- netMask = ((JsonObject) requestBody
+ prefix = ((JsonObject) requestBody
.get(VtnServiceJsonConsts.STATIC_IPROUTE)).get(
- VtnServiceJsonConsts.NETMASK).getAsString();
- nmgName = ((JsonObject) requestBody
+ VtnServiceJsonConsts.PREFIX).getAsString();
+ /* nmgName = ((JsonObject) requestBody
.get(VtnServiceJsonConsts.STATIC_IPROUTE)).get(
- VtnServiceJsonConsts.NMG_NAME).getAsString();
+ VtnServiceJsonConsts.NMG_NAME).getAsString();*/
staticIpRouteId = ipAddr + VtnServiceJsonConsts.HYPHEN
- + nextHopAddr + VtnServiceJsonConsts.HYPHEN + netMask
- + VtnServiceJsonConsts.HYPHEN + nmgName;
+ + nextHopAddr + VtnServiceJsonConsts.HYPHEN + prefix;
}
JsonObject root = new JsonObject();
JsonObject staticIpRoute = new JsonObject();
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VRT_IPROUTE_GET, requestBody,
- getUriParameters(requestBody));
+ uriParameterList);
LOG.debug("Request Packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
- setInfo(responseGenerator.getStaticIpRouteResponse(
- requestProcessor.getIpcResponsePacket(), requestBody,
- VtnServiceJsonConsts.LIST));
+ /*
+ * setInfo(responseGenerator.getStaticIpRouteResponse(
+ * requestProcessor.getIpcResponsePacket(), requestBody,
+ * VtnServiceJsonConsts.LIST));
+ */
+ JsonObject responseJson = responseGenerator
+ .getStaticIpRouteResponse(
+ requestProcessor.getIpcResponsePacket(),
+ requestBody, VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.STATIC_IPROUTES)
+ .isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.STATIC_IPROUTES).getAsJsonArray();
+ responseJson = getResponseJsonArrayLogical(requestBody,
+ requestProcessor, responseGenerator, responseArray,
+ VtnServiceJsonConsts.STATIC_IPROUTES,
+ VtnServiceJsonConsts.STATICIPROUTEID,
+ IpcRequestPacketEnum.KT_VRT_IPROUTE_GET,
+ uriParameterList,
+ VtnServiceIpcConsts.GET_STATIC_IPROUTE_SERVER_RESPONSE);
+ }
+ setInfo(responseJson);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
}
getConnPool().destroySession(session);
}
- LOG.trace("Start StaticIpRoutesResource#get()");
+ LOG.trace("Complete StaticIpRoutesResource#get()");
return status;
}
*
* @return
*/
- private List<String> getUriParameters(final JsonObject requestBody) {
+ private List<String> getUriParameters(final JsonObject requestBody) {
LOG.trace("Start StaticIpRoutesResource#getUriParameters()");
final List<String> uriParameters = new ArrayList<String>();
uriParameters.add(vtnName);
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
/**
* The Class VBridgeFlowFilterEntriesResource implements post and get methods.
- *
+ *
*/
@UNCVtnService(path = "/vtns/{vtn_name}/vbridges/{vbr_name}/flowfilters/{ff_type}/flowfilterentries")
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VBR_FLOWFILTER_ENTRY_CREATE,
- requestBody, getUriParameters(requestBody));
+ requestBody, uriParameterList);
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VBR_FLOWFILTER_ENTRY_GET,
- requestBody, getUriParameters(requestBody));
+ requestBody, uriParameterList);
LOG.debug("Request packet created successfully");
- status= requestProcessor.processIpcRequest();
+ status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
final IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
- setInfo(responseGenerator.getVBridgeFlowFilterEntryResponse(
- requestProcessor.getIpcResponsePacket(), requestBody,
- VtnServiceJsonConsts.LIST));
+ /*
+ * setInfo(responseGenerator.getVBridgeFlowFilterEntryResponse(
+ * requestProcessor.getIpcResponsePacket(), requestBody,
+ * VtnServiceJsonConsts.LIST));
+ */
+ JsonObject responseJson = responseGenerator.getVBridgeFlowFilterEntryResponse(
+ requestProcessor.getIpcResponsePacket(), requestBody,
+ VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.FLOWFILTERENTRIES).isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.FLOWFILTERENTRIES).getAsJsonArray();
+ responseJson = getResponseJsonArrayLogical(requestBody,
+ requestProcessor, responseGenerator,
+ responseArray, VtnServiceJsonConsts.FLOWFILTERENTRIES,
+ VtnServiceJsonConsts.SEQNUM,
+ IpcRequestPacketEnum.KT_VBR_FLOWFILTER_ENTRY_GET,
+ uriParameterList,VtnServiceIpcConsts.GET_VBRIDGE_FLOW_FILTER_ENTRY_RESPONSE);
+ }
+ setInfo(responseJson);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VBRIF_FLOWFILTER_ENTRY_CREATE,
- requestBody, getUriParameters(requestBody));
+ requestBody, uriParameterList);
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VBRIF_FLOWFILTER_ENTRY_GET,
- requestBody, getUriParameters(requestBody));
+ requestBody, uriParameterList);
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
final IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
- setInfo(responseGenerator
+ /*
+ * setInfo(responseGenerator
+ * .getVBridgeInterfaceFlowFilterEntryResponse(
+ * requestProcessor.getIpcResponsePacket(), requestBody,
+ * VtnServiceJsonConsts.LIST));
+ * LOG.debug("Response object created successfully");
+ */
+ JsonObject responseJson = responseGenerator
.getVBridgeInterfaceFlowFilterEntryResponse(
requestProcessor.getIpcResponsePacket(),
- requestBody, VtnServiceJsonConsts.LIST));
- LOG.debug("Response object created successfully");
+ requestBody, VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.FLOWFILTERENTRIES)
+ .isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.FLOWFILTERENTRIES).getAsJsonArray();
+ responseJson = getResponseJsonArrayLogical(requestBody,
+ requestProcessor, responseGenerator, responseArray,
+ VtnServiceJsonConsts.FLOWFILTERENTRIES,
+ VtnServiceJsonConsts.SEQNUM,
+ IpcRequestPacketEnum.KT_VBRIF_FLOWFILTER_ENTRY_GET,
+ uriParameterList,
+ VtnServiceIpcConsts.GET_VBRIDGE_INTERFACE_FLOW_FILTER_ENTRY_RESPONSE);
+ }
+ setInfo(responseJson);
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
getExceptionHandler()
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
requestProcessor.getIpcResponsePacket(), requestBody,
VtnServiceJsonConsts.SHOW);
LOG.debug("Response object created successfully for 1st request");
- if ((VtnServiceJsonConsts.STATE).equalsIgnoreCase(dataType)) {
+ if ((VtnServiceJsonConsts.STATE).equalsIgnoreCase(dataType) && !(vbrInterfaceJson.get(VtnServiceJsonConsts.INTERFACE) instanceof JsonNull)) {
requestProcessor.setServiceInfo(
UncUPLLEnums.UPLL_IPC_SERVICE_NAME,
UncUPLLEnums.ServiceID.UPLL_READ_SVC_ID.ordinal());
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VBR_IF_CREATE, requestBody,
- getUriParameters(requestBody));
+ uriParameterList);
LOG.debug("Request Packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VBR_IF_GET, requestBody,
- getUriParameters(requestBody));
+ uriParameterList);
LOG.debug("Request Packet created successfully for 1st call");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed for 1st call with status" + status);
responsePacket = requestProcessor.getIpcResponsePacket();
vbrInterfaceJson = responseGenerator.getVBridgeInterfaceResponse(
responsePacket, requestBody, VtnServiceJsonConsts.LIST);
- LOG.debug("Response object created successfully for 1st request");
+ if (vbrInterfaceJson.get(VtnServiceJsonConsts.INTERFACES).isJsonArray()) {
+ JsonArray responseArray = vbrInterfaceJson.get(
+ VtnServiceJsonConsts.INTERFACES)
+ .getAsJsonArray();
+ vbrInterfaceJson = getResponseJsonArrayLogical(requestBody,
+ requestProcessor, responseGenerator,
+ responseArray, VtnServiceJsonConsts.INTERFACES,
+ VtnServiceJsonConsts.IFNAME,
+ IpcRequestPacketEnum.KT_VBR_IF_GET,
+ uriParameterList,VtnServiceIpcConsts.GET_VBRIDGE_INTERFACE_RESPONSE);
+ }
+ LOG.debug("Response object created successfully for 1st request");
if ((VtnServiceJsonConsts.STATE).equalsIgnoreCase(dataType)
&& opType.equalsIgnoreCase(VtnServiceJsonConsts.DETAIL)) {
Iterator<JsonElement> interfaceIterator = vbrInterfaceJson
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
+ .raise(Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR
- .getErrorMessage(), e);
+ .getErrorMessage(), e);
throw e;
} finally {
if (status == ClientSession.RESP_FATAL) {
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ // Uriparamter list
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VBRIDGE_GET, requestBody,
- getUriParameters(requestBody));
+ uriParameterList);
LOG.debug("Request Packet created successfully");
- status= requestProcessor.processIpcRequest();
+ status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
- setInfo(responseGenerator.getVBridgeResponse(
+ /*
+ * setInfo(responseGenerator.getVBridgeResponse(
+ * requestProcessor.getIpcResponsePacket(), requestBody,
+ * VtnServiceJsonConsts.LIST));
+ */
+ JsonObject responseJson = responseGenerator.getVBridgeResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
- VtnServiceJsonConsts.LIST));
+ VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.VBRIDGES).isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.VBRIDGES).getAsJsonArray();
+
+ responseJson = getResponseJsonArrayLogical(requestBody,
+ requestProcessor, responseGenerator,
+ responseArray, VtnServiceJsonConsts.VBRIDGES,
+ VtnServiceJsonConsts.VBRIDGENAME,
+ IpcRequestPacketEnum.KT_VBRIDGE_GET,
+ uriParameterList,VtnServiceIpcConsts.GET_VBRIDGE_RESPONSE);
+ }
+ setInfo(responseJson);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
+ .raise(Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR
- .getErrorMessage(), e);
+ .getErrorMessage(), e);
throw e;
} finally {
if (status == ClientSession.RESP_FATAL) {
*
* @return parameter list
*/
- private List<String> getUriParameters(JsonObject requestBody) {
+ private List<String> getUriParameters(JsonObject requestBody) {
LOG.trace("Start VBridgesResource#getUriParameters()");
final List<String> uriParameters = new ArrayList<String>();
uriParameters.add(vtnName);
LOG.trace("Completed VBridgesResource#getUriParameters()");
return uriParameters;
}
-
}
/*
* Copyright (c) 2012-2013 NEC Corporation
* All rights reserved.
- *
+ *
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this
* distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.validation.logical.InterfaceResourceValidator;
/**
- * The Class VUnknownInterfaceResource.
+ * The Class VBypassInterfaceResource.
*/
/* This class handles put, delete and get methods */
@UNCVtnService(path = "/vtns/{vtn_name}/vbypasses/{vbypass_name}/interfaces/{if_name}")
-public class VUnknownInterfaceResource extends AbstractResource {
+public class VBypassInterfaceResource extends AbstractResource {
/** The vtn name. */
@UNCField("vtn_name")
private String vtnName;
- /** The vunknown name. */
+ /** The vbypass name. */
@UNCField("vbypass_name")
- private String vukName;
+ private String vbypassName;
/** The interface name. */
@UNCField("if_name")
private String ifName;
return vtnName;
}
/**
- * Gets the vuk name.
+ * Gets the vbypass name.
*
- * @return the vuk name
+ * @return the vbypass name
*/
- public String getVukName() {
- return vukName;
+ public String getVbypassName() {
+ return vbypassName;
}
/**
* Gets the if name.
return ifName;
}
private static final Logger LOG = Logger
- .getLogger(VUnknownInterfaceResource.class.getName());
+ .getLogger(VBypassInterfaceResource.class.getName());
/**
- * Instantiates a new v unknown interface resource.
+ * Instantiates a new VBypass interface resource.
*/
- public VUnknownInterfaceResource() {
+ public VBypassInterfaceResource() {
super();
- LOG.trace("Start VUnknownInterfaceResource#VUnknownInterfacesResource()");
+ LOG.trace("Start VBypassInterfaceResource#VBypassInterfacesResource()");
setValidator(new InterfaceResourceValidator(this));
- LOG.trace("Completed VUnknownInterfaceResource#VUnknownInterfacesResource()");
+ LOG.trace("Completed VBypassInterfaceResource#VBypassInterfacesResource()");
}
/**
- * Implementation of Put method of VUnknown Interface API
+ * Implementation of Put method of VBypass Interface API
*
* @param requestBody
* the request Json object
*/
@Override
public int put(final JsonObject requestBody) throws VtnServiceException {
- LOG.trace("Starts VUnknownInterfaceResource#put()");
+ LOG.trace("Starts VBypassInterfaceResource#put()");
ClientSession session = null;
IpcRequestProcessor requestProcessor = null;
int status = ClientSession.RESP_FATAL;
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
+ .raise(Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR
- .getErrorMessage(), e);
+ .getErrorMessage(), e);
throw e;
} finally {
if (status == ClientSession.RESP_FATAL) {
}
getConnPool().destroySession(session);
}
- LOG.trace("Completed VUnknownInterfaceResource#put()");
+ LOG.trace("Completed VBypassInterfaceResource#put()");
return status;
}
/**
- * Implementation of Delete method of VUnknown Interface API
+ * Implementation of Delete method of VBypass Interface API
*
* @return Error code
* @throws VtnServiceException
*/
@Override
public int delete() throws VtnServiceException {
- LOG.trace("starts VUnknownInterfaceResource#delete()");
+ LOG.trace("starts VBypassInterfaceResource#delete()");
ClientSession session = null;
IpcRequestProcessor requestProcessor = null;
int status = ClientSession.RESP_FATAL;
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
+ .raise(Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR
- .getErrorMessage(), e);
+ .getErrorMessage(), e);
throw e;
} finally {
if (status == ClientSession.RESP_FATAL) {
}
getConnPool().destroySession(session);
}
- LOG.trace("Completed VUnknownInterfaceResource#delete()");
+ LOG.trace("Completed VBypassInterfaceResource#delete()");
return status;
}
/**
- * Implementation of get method of VUnknown Interface API
+ * Implementation of get method of VBypass Interface API
*
* @param requestBody
* the request Json object
*/
@Override
public int get(final JsonObject requestBody) throws VtnServiceException {
- LOG.trace("Starts VUnknownInterfaceResource#get()");
+ LOG.trace("Starts VBypassInterfaceResource#get()");
ClientSession session = null;
IpcRequestProcessor requestProcessor = null;
int status = ClientSession.RESP_FATAL;
+ VtnServiceConsts.HYPHEN
+ Thread.currentThread().getStackTrace()[1]
.getMethodName(),
- UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
- UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage());
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage());
}
JsonObject neighbor = null;
- JsonObject vukInterfaceJson = null;
+ JsonObject vbypassInterfaceJson = null;
IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
String dataType = null;
if (requestBody.has(VtnServiceJsonConsts.TARGETDB)) {
dataType = requestBody.get(VtnServiceJsonConsts.TARGETDB)
.getAsString();
}
- vukInterfaceJson = responseGenerator.getVUnknownInterfaceResponse(
+ vbypassInterfaceJson = responseGenerator.getVBypassInterfaceResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
VtnServiceJsonConsts.SHOW);
- if ((VtnServiceJsonConsts.STATE).equalsIgnoreCase(dataType)) {
+ if (VtnServiceJsonConsts.STATE.equalsIgnoreCase(dataType) && !(vbypassInterfaceJson.get(VtnServiceJsonConsts.INTERFACE) instanceof JsonNull)) {
requestProcessor.setServiceInfo(
UncUPLLEnums.UPLL_IPC_SERVICE_NAME,
UncUPLLEnums.ServiceID.UPLL_READ_SVC_ID.ordinal());
IpcRequestPacketEnum.KT_VUNK_IF_GET, requestBody,
getUriParameters());
requestProcessor
- .getRequestPacket()
- .setOption2(
- IpcDataUnitWrapper
- .setIpcUint32Value((UncOption2Enum.UNC_OPT2_NEIGHBOR
- .ordinal())));
+ .getRequestPacket()
+ .setOption2(
+ IpcDataUnitWrapper
+ .setIpcUint32Value(UncOption2Enum.UNC_OPT2_NEIGHBOR
+ .ordinal()));
LOG.debug("Request packet created successfully for 2nd request");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet for 2nd request processed with status" + status);
neighbor = responseGenerator.getNeighborResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
VtnServiceJsonConsts.SHOW);
- vukInterfaceJson.get(VtnServiceJsonConsts.INTERFACE)
- .getAsJsonObject()
- .add(VtnServiceJsonConsts.NEIGHBOR, neighbor);
+ vbypassInterfaceJson.get(VtnServiceJsonConsts.INTERFACE)
+ .getAsJsonObject()
+ .add(VtnServiceJsonConsts.NEIGHBOR, neighbor);
}
- setInfo(vukInterfaceJson);
+ setInfo(vbypassInterfaceJson);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
+ .raise(Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR
- .getErrorMessage(), e);
+ .getErrorMessage(), e);
throw e;
} finally {
if (status == ClientSession.RESP_FATAL) {
}
getConnPool().destroySession(session);
}
- LOG.trace("Completed VUnknownInterfaceResource#get()");
+ LOG.trace("Completed VBypassInterfaceResource#get()");
return status;
}
/**
* @return parameter list
*/
private List<String> getUriParameters() {
- LOG.trace("Start VUnknownInterfaceResource#getUriParameters()");
+ LOG.trace("Start VBypassInterfaceResource#getUriParameters()");
List<String> uriParameters = new ArrayList<String>();
uriParameters.add(vtnName);
- uriParameters.add(vukName);
+ uriParameters.add(vbypassName);
uriParameters.add(ifName);
- LOG.trace("Completed VUnknownInterfaceResource#getUriParameters()");
+ LOG.trace("Completed VBypassInterfaceResource#getUriParameters()");
return uriParameters;
}
}
/*
* Copyright (c) 2012-2013 NEC Corporation
* All rights reserved.
- *
+ *
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this
* distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
import org.opendaylight.vtn.javaapi.validation.logical.InterfaceResourceValidator;
/**
- * The Class VUnknownInterfacesResource.
+ * The Class VBypassInterfacesResource.
*/
/* This class handles post and get methods */
@UNCVtnService(path = "/vtns/{vtn_name}/vbypasses/{vbypass_name}/interfaces")
-public class VUnknownInterfacesResource extends AbstractResource {
+public class VBypassInterfacesResource extends AbstractResource {
/** The vtn name. */
@UNCField("vtn_name")
private String vtnName;
/** The vbypass name. */
@UNCField("vbypass_name")
- private String vukName;
+ private String vbypassName;
/**
* Gets the vtn name.
- *
+ *
* @return the vtn name
*/
public String getVtnName() {
return vtnName;
}
/**
- * Gets the vuk name.
+ * Gets the vbypass name.
*
- * @return the vuk name
+ * @return the vbypass name
*/
- public String getVukName() {
- return vukName;
+ public String getVbypassName() {
+ return vbypassName;
}
private static final Logger LOG = Logger
- .getLogger(VUnknownInterfacesResource.class.getName());
+ .getLogger(VBypassInterfacesResource.class.getName());
/**
- * Instantiates a new v unknown interfaces resource.
+ * Instantiates a new vBypass interfaces resource.
*/
- public VUnknownInterfacesResource() {
+ public VBypassInterfacesResource() {
super();
- LOG.trace("Start VUnknownInterfacesResource#VUnknownInterfacesResource()");
+ LOG.trace("Start VBypassInterfacesResource#VBypassInterfacesResource()");
setValidator(new InterfaceResourceValidator(this));
- LOG.trace("Completed VUnknownInterfacesResource#VUnknownInterfacesResource()");
+ LOG.trace("Completed VBypassInterfacesResource#VBypassInterfacesResource()");
}
/**
- * Implementation of Post method of VUnknown Interface API
+ * Implementation of Post method of VBypass Interface API
*
* @param requestBody
* the request Json object
*/
@Override
public int post(final JsonObject requestBody) throws VtnServiceException {
- LOG.trace("Start VUnknownInterfacesResource#post()");
+ LOG.trace("Start VBypassInterfacesResource#post()");
ClientSession session = null;
IpcRequestProcessor requestProcessor = null;
int status = ClientSession.RESP_FATAL;
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
+ .raise(Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR
- .getErrorMessage(), e);
+ .getErrorMessage(), e);
throw e;
} finally {
if (status == ClientSession.RESP_FATAL) {
}
getConnPool().destroySession(session);
}
- LOG.trace("Completed VUnknownInterfacesResource#post()");
+ LOG.trace("Completed VBypassInterfacesResource#post()");
return status;
}
/**
- * Implementation of Get method of VUnknown Interface API
+ * Implementation of Get method of VBypass Interface API
*
* @param requestBody
* the request Json object
*/
@Override
public int get(final JsonObject requestBody) throws VtnServiceException {
- LOG.trace("Starts VUnknownInterfaceResource#get()");
+ LOG.trace("Starts VBypassInterfaceResource#get()");
ClientSession session = null;
IpcRequestProcessor requestProcessor = null;
int status = ClientSession.RESP_FATAL;
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ // Uriparamter list
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VUNK_IF_GET, requestBody,
- getUriParameters(requestBody));
+ uriParameterList);
LOG.debug("Request packet created successfully for 1st request");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet for 1st request processed with status" + status);
+ VtnServiceConsts.HYPHEN
+ Thread.currentThread().getStackTrace()[1]
.getMethodName(),
- UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
- UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage());
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage());
}
JsonObject neighbor = null;
- JsonObject vukInterfacesJson = null;
+ JsonObject vbypassInterfacesJson = null;
IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
String dataType = null;
if (requestBody.has(VtnServiceJsonConsts.TARGETDB)) {
}
JsonObject interfacesJson = null;
JsonArray interfaceArray = new JsonArray();
- vukInterfacesJson = responseGenerator.getVUnknownInterfaceResponse(
+ /*vbypassInterfacesJson = responseGenerator.getVBypassInterfaceResponse(
+ requestProcessor.getIpcResponsePacket(), requestBody,
+ VtnServiceJsonConsts.LIST);*/
+ vbypassInterfacesJson = responseGenerator.getVBypassInterfaceResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
VtnServiceJsonConsts.LIST);
- if ((VtnServiceJsonConsts.STATE).equalsIgnoreCase(dataType)
+ if (vbypassInterfacesJson.get(VtnServiceJsonConsts.INTERFACES).isJsonArray()) {
+ JsonArray responseArray = vbypassInterfacesJson.get(
+ VtnServiceJsonConsts.INTERFACES).getAsJsonArray();
+
+ vbypassInterfacesJson = getResponseJsonArrayLogical(requestBody,
+ requestProcessor, responseGenerator,
+ responseArray, VtnServiceJsonConsts.INTERFACES,
+ VtnServiceJsonConsts.IFNAME,
+ IpcRequestPacketEnum.KT_VUNK_IF_GET,
+ uriParameterList,VtnServiceIpcConsts.GET_VBYPASS_INTERFACE_RESPONSE);
+ }
+ if (VtnServiceJsonConsts.STATE.equalsIgnoreCase(dataType)
&& opType.equalsIgnoreCase(VtnServiceJsonConsts.DETAIL)) {
- Iterator<JsonElement> interfaceIterator = vukInterfacesJson
+ Iterator<JsonElement> interfaceIterator = vbypassInterfacesJson
.get(VtnServiceJsonConsts.INTERFACES).getAsJsonArray()
.iterator();
requestProcessor.setServiceInfo(
IpcRequestPacketEnum.KT_VUNK_IF_GET, requestBody,
getUriParameters(requestBody));
requestProcessor
- .getRequestPacket()
- .setOption2(
- IpcDataUnitWrapper
- .setIpcUint32Value((UncOption2Enum.UNC_OPT2_NEIGHBOR
- .ordinal())));
+ .getRequestPacket()
+ .setOption2(
+ IpcDataUnitWrapper
+ .setIpcUint32Value(UncOption2Enum.UNC_OPT2_NEIGHBOR
+ .ordinal()));
requestProcessor
- .getRequestPacket()
- .setOperation(
- IpcDataUnitWrapper
- .setIpcUint32Value(UncOperationEnum.UNC_OP_READ
- .ordinal()));
+ .getRequestPacket()
+ .setOperation(
+ IpcDataUnitWrapper
+ .setIpcUint32Value(UncOperationEnum.UNC_OP_READ
+ .ordinal()));
LOG.debug("Request packet created successfully for 2nd request");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet for 2nd request processed with status" + status);
interfacesJson.add(VtnServiceJsonConsts.NEIGHBOR, neighbor);
interfaceArray.add(interfacesJson);
}
- vukInterfacesJson.add(VtnServiceJsonConsts.INTERFACES,
+ vbypassInterfacesJson.add(VtnServiceJsonConsts.INTERFACES,
interfaceArray);
}
LOG.trace("Response Packet created successfully for 2nd request");
- setInfo(vukInterfacesJson);
+ setInfo(vbypassInterfacesJson);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
+ .raise(Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR
- .getErrorMessage(), e);
+ .getErrorMessage(), e);
throw e;
} finally {
if (status == ClientSession.RESP_FATAL) {
}
getConnPool().destroySession(session);
}
- LOG.trace("Completed VUnknownInterfacesResource#get()");
+ LOG.trace("Completed VBypassInterfacesResource#get()");
return status;
}
/**
* @return parameter list
*/
private List<String> getUriParameters(JsonObject requestBody) {
- LOG.trace("Start VUnknownInterfacesResource#getUriParameters()");
+ LOG.trace("Start VBypassInterfacesResource#getUriParameters()");
List<String> uriParameters = new ArrayList<String>();
uriParameters.add(vtnName);
- uriParameters.add(vukName);
+ uriParameters.add(vbypassName);
if (requestBody != null && requestBody.has(VtnServiceJsonConsts.INDEX)) {
uriParameters.add(requestBody.get(VtnServiceJsonConsts.INDEX)
.getAsString());
}
- LOG.trace("Completed VUnknownInterfacesResource#getUriParameters()");
+ LOG.trace("Completed VBypassInterfacesResource#getUriParameters()");
return uriParameters;
}
}
/*
* Copyright (c) 2012-2013 NEC Corporation
* All rights reserved.
- *
+ *
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this
* distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
import org.opendaylight.vtn.javaapi.ipc.enums.UncJavaAPIErrorCode;
import org.opendaylight.vtn.javaapi.ipc.enums.UncUPLLEnums;
import org.opendaylight.vtn.javaapi.resources.AbstractResource;
-import org.opendaylight.vtn.javaapi.validation.logical.VUnknownResourceValidator;
+import org.opendaylight.vtn.javaapi.validation.logical.VBypassResourceValidator;
/**
- * The Class VUnknownResource implements get, delete and put.
+ * The Class VBypassResource implements get, delete and put.
*/
@UNCVtnService(path = "/vtns/{vtn_name}/vbypasses/{vbypass_name}")
-public class VUnknownResource extends AbstractResource {
+public class VBypassResource extends AbstractResource {
/** The vtn name. */
@UNCField("vtn_name")
private String vtnName;
public String getVtnName() {
return vtnName;
}
- /** The vunknown name. */
+ /** The vbypass name. */
@UNCField("vbypass_name")
- private String vukName;
+ private String vbypassName;
+
/**
- * @return the vuk name
+ * @return the VBypass name
*/
- public String getVukName() {
- return vukName;
+ public String getVbypassName() {
+ return vbypassName;
}
- private static final Logger LOG = Logger.getLogger(VUnknownResource.class
+ private static final Logger LOG = Logger.getLogger(VBypassResource.class
.getName());
/**
- * Instantiates a new v unknown resource.
+ * Instantiates a new VBypass resource.
*/
- public VUnknownResource() {
+ public VBypassResource() {
super();
- LOG.trace("Start VUnknownResource#VUnknownsResource()");
- setValidator(new VUnknownResourceValidator(this));
- LOG.trace("Completed VUnknownResource#VUnknownsResource()");
+ LOG.trace("Start VBypassResource#VBypassResource()");
+ setValidator(new VBypassResourceValidator(this));
+ LOG.trace("Completed VBypassResource#VBypassResource()");
}
/**
- * Implementation of put method of Vunknown
+ * Implementation of put method of VBypass
*
* @param requestBody
* the request Json object
*/
@Override
public int put(final JsonObject requestBody) throws VtnServiceException {
- LOG.trace("Starts VUnknownResource#put()");
+ LOG.trace("Starts VBypassResource#put()");
ClientSession session = null;
IpcRequestProcessor requestProcessor = null;
int status = ClientSession.RESP_FATAL;
}
getConnPool().destroySession(session);
}
- LOG.trace("Completed VUnknownResource#put()");
+ LOG.trace("Completed VBypassResource#put()");
return status;
}
/**
- * Implementation of delete method of Vunknown
+ * Implementation of delete method of VBypass
*
* @return Error code
* @throws VtnServiceException
*/
@Override
public int delete() throws VtnServiceException {
- LOG.trace("Starts VUnknownResource#delete()");
+ LOG.trace("Starts VBypassResource#delete()");
ClientSession session = null;
IpcRequestProcessor requestProcessor = null;
int status = ClientSession.RESP_FATAL;
}
getConnPool().destroySession(session);
}
- LOG.trace("Completed VUnknownResource#delete()");
+ LOG.trace("Completed VBypassResource#delete()");
return status;
}
/**
- * Implementation of get method of Vunknown
+ * Implementation of get method of VBypass
*
* @param requestBody
* the request Json object
*/
@Override
public int get(final JsonObject requestBody) throws VtnServiceException {
- LOG.trace("Starts VUnknownResource#get()");
+ LOG.trace("Starts VBypassResource#get()");
ClientSession session = null;
IpcRequestProcessor requestProcessor = null;
int status = ClientSession.RESP_FATAL;
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
- setInfo(responseGenerator.getVUnknownResponse(
+ setInfo(responseGenerator.getVBypassResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
VtnServiceJsonConsts.SHOW));
LOG.debug("Response object created successfully");
}
getConnPool().destroySession(session);
}
- LOG.trace("Completed VUnknownResource#get()");
+ LOG.trace("Completed VBypassResource#get()");
return status;
}
/**
* @return parameter list
*/
private List<String> getUriParameters() {
- LOG.trace("Start VUnknownResource#getUriParameters()");
+ LOG.trace("Start VBypassResource#getUriParameters()");
List<String> uriParameters = new ArrayList<String>();
uriParameters.add(vtnName);
- uriParameters.add(vukName);
- LOG.trace("Completed VUnknownResource#getUriParameters()");
+ uriParameters.add(vbypassName);
+ LOG.trace("Completed VBypassResource#getUriParameters()");
return uriParameters;
}
}
/*
* Copyright (c) 2012-2013 NEC Corporation
* All rights reserved.
- *
+ *
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this
* distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
import org.opendaylight.vtn.javaapi.ipc.enums.UncJavaAPIErrorCode;
import org.opendaylight.vtn.javaapi.ipc.enums.UncUPLLEnums;
import org.opendaylight.vtn.javaapi.resources.AbstractResource;
-import org.opendaylight.vtn.javaapi.validation.logical.VUnknownResourceValidator;
+import org.opendaylight.vtn.javaapi.validation.logical.VBypassResourceValidator;
/**
- * The Class VUnknownsResource implements post and get methods.
+ * The Class VBypassesResource implements post and get methods.
*/
@UNCVtnService(path = "/vtns/{vtn_name}/vbypasses")
-public class VUnknownsResource extends AbstractResource {
+public class VBypassesResource extends AbstractResource {
/** The vtn name. */
@UNCField("vtn_name")
private String vtnName;
public String getVtnName() {
return vtnName;
}
- private static final Logger LOG = Logger.getLogger(VUnknownsResource.class
+ private static final Logger LOG = Logger.getLogger(VBypassesResource.class
.getName());
/**
- * Instantiates a new v unknowns resource.
+ * Instantiates a new VBypasse resource.
*/
- public VUnknownsResource() {
+ public VBypassesResource() {
super();
- LOG.trace("Start VUnknownsResource#VUnknownsResource()");
- setValidator(new VUnknownResourceValidator(this));
- LOG.trace("Completed VUnknownsResource#VUnknownsResource()");
+ LOG.trace("Start VBypassesResource#VBypassesResource()");
+ setValidator(new VBypassResourceValidator(this));
+ LOG.trace("Completed VBypassesResource#VBypassesResource()");
}
/**
- * Implementation of post method of Vunknown
+ * Implementation of post method of VBypass
*
* @param requestBody
* the request Json object
*/
@Override
public int post(final JsonObject requestBody) throws VtnServiceException {
- LOG.trace("Starts VUnknownsResource#post()");
+ LOG.trace("Starts VBypassesResource#post()");
ClientSession session = null;
IpcRequestProcessor requestProcessor = null;
int status = ClientSession.RESP_FATAL;
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
+ .raise(Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR
- .getErrorMessage(), e);
+ .getErrorMessage(), e);
throw e;
} finally {
if (status == ClientSession.RESP_FATAL) {
}
getConnPool().destroySession(session);
}
- LOG.trace("Completed VUnknownsResource#post()");
+ LOG.trace("Completed VBypassesResource#post()");
return status;
}
/**
- * Implementation of get method of Vunknown
+ * Implementation of get method of VBypass
*
* @param requestBody
* the request Json object
*/
@Override
public int get(final JsonObject requestBody) throws VtnServiceException {
- LOG.trace("starts VUnknownsResource#get()");
+ LOG.trace("starts VBypassesResource#get()");
ClientSession session = null;
IpcRequestProcessor requestProcessor = null;
int status = ClientSession.RESP_FATAL;
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ // Uriparamter list
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VUNKNOWN_GET, requestBody,
- getUriParameters(requestBody));
+ uriParameterList);
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
- setInfo(responseGenerator.getVUnknownResponse(
+ /*setInfo(responseGenerator.getVBypassResponse(
+ requestProcessor.getIpcResponsePacket(), requestBody,
+ VtnServiceJsonConsts.LIST));*/
+ JsonObject responseJson = responseGenerator.getVBypassResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
- VtnServiceJsonConsts.LIST));
+ VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.VBYPASSES).isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.VBYPASSES).getAsJsonArray();
+
+ responseJson = getResponseJsonArrayLogical(requestBody,
+ requestProcessor, responseGenerator,
+ responseArray, VtnServiceJsonConsts.VBYPASSES,
+ VtnServiceJsonConsts.VBYPASS_NAME,
+ IpcRequestPacketEnum.KT_VUNKNOWN_GET,
+ uriParameterList,VtnServiceIpcConsts.GET_VBYPASS_RESPONSE);
+ }
+ setInfo(responseJson);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
+ .raise(Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR
- .getErrorMessage(), e);
+ .getErrorMessage(), e);
throw e;
} finally {
if (status == ClientSession.RESP_FATAL) {
}
getConnPool().destroySession(session);
}
- LOG.trace("Completed VUnknownsResource#get()");
+ LOG.trace("Completed VBypassesResource#get()");
return status;
}
/**
* @return parameter list
*/
private List<String> getUriParameters(JsonObject requestBody) {
- LOG.trace("Start VUnknownsResource#getUriParameters()");
+ LOG.trace("Start VBypassesResource#getUriParameters()");
List<String> uriParameters = new ArrayList<String>();
uriParameters.add(vtnName);
if (requestBody != null && requestBody.has(VtnServiceJsonConsts.INDEX)) {
uriParameters.add(requestBody.get(VtnServiceJsonConsts.INDEX)
.getAsString());
}
- LOG.trace("Completed VUnknownsResource#getUriParameters()");
+ LOG.trace("Completed VBypassesResource#getUriParameters()");
return uriParameters;
}
}
package org.opendaylight.vtn.javaapi.resources.logical;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.ipc.IpcDataUnit;
import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
+import org.opendaylight.vtn.javaapi.init.VtnServiceConfiguration;
+import org.opendaylight.vtn.javaapi.init.VtnServiceInitManager;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
import org.opendaylight.vtn.javaapi.ipc.conversion.IpcDataUnitWrapper;
import org.opendaylight.vtn.javaapi.ipc.conversion.IpcLogicalResponseFactory;
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VLINK_GET, requestBody,
getUriParameters(requestBody));
- IpcStruct valStruct = new IpcStruct(
- UncStructEnum.ValVlink.getValue());
- requestProcessor.getRequestPacket().setValStruct(valStruct);
- if (requestBody.has(VtnServiceJsonConsts.VNODE1NAME)
- || requestBody.has(VtnServiceJsonConsts.VNODE2NAME)) {
- // IpcStruct valStruct =
- // requestProcessor.getRequestPacket().getValStruct();
- if (requestBody.has(VtnServiceJsonConsts.VNODE1NAME)) {
- valStruct
- .set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VNODE1_NAME_VLNK
- .ordinal(),
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
- .ordinal()));
- valStruct.set(VtnServiceJsonConsts.VNODE1NAME,
- IpcDataUnitWrapper
- .setIpcUint8ArrayValue(requestBody.get(
- VtnServiceJsonConsts.VNODE1NAME)
- .getAsString()));
- }
- if (requestBody.has(VtnServiceJsonConsts.VNODE2NAME)) {
- valStruct
- .set(VtnServiceIpcConsts.VALID,
- UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VNODE2_NAME_VLNK
- .ordinal(),
- IpcDataUnitWrapper
- .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
- .ordinal()));
- valStruct.set(VtnServiceJsonConsts.VNODE2NAME,
- IpcDataUnitWrapper
- .setIpcUint8ArrayValue(requestBody.get(
- VtnServiceJsonConsts.VNODE2NAME)
- .getAsString()));
- }
- }
- if (requestBody.get(VtnServiceJsonConsts.TARGETDB).getAsString()
- .equalsIgnoreCase(VtnServiceJsonConsts.STATE)
- && !requestBody.get(VtnServiceJsonConsts.OP).getAsString()
- .equalsIgnoreCase(VtnServiceJsonConsts.COUNT)) {
- LOG.debug("Add ValVlinkSt to Request Packet");
- IpcDataUnit[] extraDataUnits = new IpcDataUnit[1];
- IpcStruct valStructSt = new IpcStruct(
- UncStructEnum.ValVlinkSt.getValue());
- extraDataUnits[0] = valStructSt;
- requestProcessor.getRequestPacket().setExtraDataUnits(
- extraDataUnits);
- } else {
- requestProcessor.getRequestPacket().setExtraDataUnits(null);
- }
+ getModifiedRequestPacket(requestBody, requestProcessor);
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
+ final List<String> uriParameterList = getUriParameters(requestBody);
LOG.debug("Request packet processed with status" + status);
IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
- setInfo(responseGenerator.getVLinkResponse(
+ /*
+ * setInfo(responseGenerator.getVLinkResponse(
+ * requestProcessor.getIpcResponsePacket(), requestBody,
+ * VtnServiceJsonConsts.LIST));
+ */
+ JsonObject responseJson = responseGenerator.getVLinkResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
- VtnServiceJsonConsts.LIST));
+ VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.VLINKS).isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.VLINKS).getAsJsonArray();
+ responseJson = getResponseJsonArrayLink(requestBody,
+ requestProcessor, responseGenerator,
+ responseArray, VtnServiceJsonConsts.VLINKS,
+ VtnServiceJsonConsts.VLKNAME,
+ IpcRequestPacketEnum.KT_VLINK_GET,
+ uriParameterList,VtnServiceIpcConsts.GET_VLINKS_RESPONSE);
+ }
+ setInfo(responseJson);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
return status;
}
+ private void getModifiedRequestPacket(final JsonObject requestBody,
+ IpcRequestProcessor requestProcessor) {
+ IpcStruct valStruct = new IpcStruct(
+ UncStructEnum.ValVlink.getValue());
+ requestProcessor.getRequestPacket().setValStruct(valStruct);
+ if (requestBody.has(VtnServiceJsonConsts.VNODE1NAME)
+ || requestBody.has(VtnServiceJsonConsts.VNODE2NAME)) {
+ // IpcStruct valStruct =
+ // requestProcessor.getRequestPacket().getValStruct();
+ if (requestBody.has(VtnServiceJsonConsts.VNODE1NAME)) {
+ valStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VNODE1_NAME_VLNK
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
+ .ordinal()));
+ valStruct.set(VtnServiceJsonConsts.VNODE1NAME,
+ IpcDataUnitWrapper
+ .setIpcUint8ArrayValue(requestBody.get(
+ VtnServiceJsonConsts.VNODE1NAME)
+ .getAsString()));
+ }
+ if (requestBody.has(VtnServiceJsonConsts.VNODE2NAME)) {
+ valStruct
+ .set(VtnServiceIpcConsts.VALID,
+ UncStructIndexEnum.ValVlinkIndex.UPLL_IDX_VNODE2_NAME_VLNK
+ .ordinal(),
+ IpcDataUnitWrapper
+ .setIpcUint8Value(UncStructIndexEnum.Valid.UNC_VF_VALID
+ .ordinal()));
+ valStruct.set(VtnServiceJsonConsts.VNODE2NAME,
+ IpcDataUnitWrapper
+ .setIpcUint8ArrayValue(requestBody.get(
+ VtnServiceJsonConsts.VNODE2NAME)
+ .getAsString()));
+ }
+ }
+ if (requestBody.get(VtnServiceJsonConsts.TARGETDB).getAsString()
+ .equalsIgnoreCase(VtnServiceJsonConsts.STATE)
+ && !requestBody.get(VtnServiceJsonConsts.OP).getAsString()
+ .equalsIgnoreCase(VtnServiceJsonConsts.COUNT)) {
+ LOG.debug("Add ValVlinkSt to Request Packet");
+ IpcDataUnit[] extraDataUnits = new IpcDataUnit[1];
+ IpcStruct valStructSt = new IpcStruct(
+ UncStructEnum.ValVlinkSt.getValue());
+ extraDataUnits[0] = valStructSt;
+ requestProcessor.getRequestPacket().setExtraDataUnits(
+ extraDataUnits);
+ } else {
+ requestProcessor.getRequestPacket().setExtraDataUnits(null);
+ }
+ }
+
/**
* Add URI parameters to list
*
LOG.trace("Completed VLinksResource#getUriParameters()");
return uriParameters;
}
+
+ public JsonObject getResponseJsonArrayLink(final JsonObject requestBody,
+ IpcRequestProcessor requestProcessor,
+ Object responseGenerator, JsonArray responseArray,
+ String JsonArrayName, String IndexName,
+ IpcRequestPacketEnum requestPackeEnumName,
+ List<String> uriParameters, String methodName)
+ throws VtnServiceException {
+ //session reset
+ requestProcessor.setServiceInfo(
+ UncUPLLEnums.UPLL_IPC_SERVICE_NAME,
+ UncUPLLEnums.ServiceID.UPLL_READ_SVC_ID.ordinal());
+ int status = ClientSession.RESP_FATAL;
+ int memberIndex = 0;
+ VtnServiceConfiguration configuration = VtnServiceInitManager
+ .getConfigurationMap();
+ int max_rep_count = Integer.parseInt(configuration
+ .getConfigValue(VtnServiceConsts.MAX_REP_DEFAULT));
+ memberIndex = responseArray.size();
+ if (memberIndex != 0) {
+ JsonObject memberLastIndex = (JsonObject) responseArray
+ .get(responseArray.size() - 1);
+ if (requestBody.has(VtnServiceJsonConsts.INDEX)) {
+ uriParameters.remove(uriParameters.size() - 1);
+ uriParameters.add(uriParameters.size(),
+ memberLastIndex.get(IndexName).getAsString());
+ } else {
+ uriParameters.add(memberLastIndex.get(IndexName).getAsString());
+ }
+ while (memberIndex == max_rep_count) {
+
+ JsonArray memberArray = null;
+ memberLastIndex = (JsonObject) responseArray.get(responseArray
+ .size() - 1);
+ uriParameters.remove(uriParameters.size() - 1);
+ uriParameters.add(uriParameters.size(),
+ memberLastIndex.get(IndexName).getAsString());
+
+ requestProcessor.createIpcRequestPacket(requestPackeEnumName,
+ requestBody, uriParameters);
+ getModifiedRequestPacket(requestBody, requestProcessor);
+ status = requestProcessor.processIpcRequest();
+ if (status == ClientSession.RESP_FATAL) {
+ throw new VtnServiceException(
+ Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage());
+ }
+ try {
+ Method method;
+
+ final Class<IpcLogicalResponseFactory> sourceClass = IpcLogicalResponseFactory.class;
+ // get the method name to get the IpcLogicalResponseFactory
+ // object for given key
+ method = sourceClass.getMethod(methodName,
+ new Class<?>[] { IpcDataUnit[].class,
+ JsonObject.class, String.class });
+ // get IpcLogicalResponseFactory object
+ memberArray = ((JsonObject) method.invoke(
+ responseGenerator,
+ requestProcessor.getIpcResponsePacket(),
+ requestBody, VtnServiceJsonConsts.LIST))
+ .getAsJsonArray(JsonArrayName);
+ } catch (final Exception e) {
+ throw new VtnServiceException(
+ Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage());
+ }
+ if (null != memberArray && !memberArray.isJsonNull()
+ && memberArray.size() > 0) {
+ responseArray.getAsJsonArray().addAll(memberArray);
+ } else {
+ break;
+ }
+ memberIndex = memberArray.size();
+ }
+ }
+ JsonObject root = new JsonObject();
+ root.add(JsonArrayName, responseArray);
+ return root;
+ }
}
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VRTIF_FLOWFILTER_ENTRY_CREATE,
- requestBody, getUriParameters(requestBody));
+ requestBody, uriParameterList);
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VRTIF_FLOWFILTER_ENTRY_GET,
- requestBody, getUriParameters(requestBody));
+ requestBody, uriParameterList);
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
final IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
- setInfo(responseGenerator
+ /*
+ * setInfo(responseGenerator
+ * .getVRouterInterfaceFlowFilterEntryResponse(
+ * requestProcessor.getIpcResponsePacket(), requestBody,
+ * VtnServiceJsonConsts.LIST));
+ */
+ JsonObject responseJson = responseGenerator
.getVRouterInterfaceFlowFilterEntryResponse(
requestProcessor.getIpcResponsePacket(),
- requestBody, VtnServiceJsonConsts.LIST));
+ requestBody, VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.FLOWFILTERENTRIES)
+ .isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.FLOWFILTERENTRIES).getAsJsonArray();
+ responseJson = getResponseJsonArrayLogical(requestBody,
+ requestProcessor, responseGenerator, responseArray,
+ VtnServiceJsonConsts.FLOWFILTERENTRIES,
+ VtnServiceJsonConsts.SEQNUM,
+ IpcRequestPacketEnum.KT_VRTIF_FLOWFILTER_ENTRY_GET,
+ uriParameterList,
+ VtnServiceIpcConsts.GET_VROUTER_INTERFACE_FLOW_FILTER_ENTRY_RESPONSE);
+ }
+ setInfo(responseJson);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
if (requestBody != null && requestBody.has(VtnServiceJsonConsts.INDEX)) {
uriParameters.add(requestBody.get(VtnServiceJsonConsts.INDEX)
.getAsString());
- }LOG.trace("Completed VRouterInterfaceFlowFilterEntriesResource#getUriParameters()");
+ }
+ LOG.trace("Completed VRouterInterfaceFlowFilterEntriesResource#getUriParameters()");
return uriParameters;
}
}
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
requestProcessor.getIpcResponsePacket(), requestBody,
VtnServiceJsonConsts.SHOW);
LOG.debug("Response object created successfully for 1st request");
- if ((VtnServiceJsonConsts.STATE).equalsIgnoreCase(dataType)) {
+ if ((VtnServiceJsonConsts.STATE).equalsIgnoreCase(dataType) && !(vrtInterfaceJson.get(VtnServiceJsonConsts.INTERFACE) instanceof JsonNull)) {
requestProcessor.setServiceInfo(
UncUPLLEnums.UPLL_IPC_SERVICE_NAME,
UncUPLLEnums.ServiceID.UPLL_READ_SVC_ID.ordinal());
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VRT_IF_GET, requestBody,
- getUriParameters(requestBody));
+ uriParameterList);
LOG.debug("Request Packet created successfully for 1st call");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed for 1st call with status" + status);
vrtInterfacesJson = responseGenerator.getVRouterInterfaceResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
VtnServiceJsonConsts.LIST);
+ if (vrtInterfacesJson.get(VtnServiceJsonConsts.INTERFACES).isJsonArray()) {
+ JsonArray responseArray = vrtInterfacesJson.get(
+ VtnServiceJsonConsts.INTERFACES)
+ .getAsJsonArray();
+ vrtInterfacesJson = getResponseJsonArrayLogical(requestBody,
+ requestProcessor, responseGenerator,
+ responseArray, VtnServiceJsonConsts.INTERFACES,
+ VtnServiceJsonConsts.IFNAME,
+ IpcRequestPacketEnum.KT_VRT_IF_GET,
+ uriParameterList,VtnServiceIpcConsts.GET_VROUTER_INTERFACE_RESPONSE);
+ }
LOG.debug("Response object created successfully for 1st request");
if ((VtnServiceJsonConsts.STATE).equalsIgnoreCase(dataType)
&& opType.equalsIgnoreCase(VtnServiceJsonConsts.DETAIL)) {
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
import org.opendaylight.vtn.javaapi.ipc.enums.UncUPLLEnums;
import org.opendaylight.vtn.javaapi.resources.AbstractResource;
import org.opendaylight.vtn.javaapi.validation.logical.VRouterResourceValidator;
+
/**
* The Class VRoutersResource implements post and get methods.
*/
private String vtnName;
private static final Logger LOG = Logger.getLogger(VRoutersResource.class
.getName());
+
/**
* Instantiates a new VRouter resource.
*/
setValidator(new VRouterResourceValidator(this));
LOG.trace("Complete VRoutersResource#VRoutersResource()");
}
+
/**
* @return the vtnName
*/
public String getVtnName() {
return vtnName;
}
+
/**
* Implementation of post method of VRouter
*
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VROUTER_CREATE, requestBody,
- getUriParameters(requestBody));
+ uriParameterList);
LOG.debug("Request Packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
LOG.trace("Complete VRoutersResource#post()");
return status;
}
+
/**
* Implementation of get method of VRouter
*
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VROUTER_GET, requestBody,
getUriParameters(requestBody));
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
- setInfo(responseGenerator.getVRouterResponse(
+ /*
+ * setInfo(responseGenerator.getVRouterResponse(
+ * requestProcessor.getIpcResponsePacket(), requestBody,
+ * VtnServiceJsonConsts.LIST));
+ */
+ JsonObject responseJson = responseGenerator.getVRouterResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
- VtnServiceJsonConsts.LIST));
+ VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.VROUTERS).isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.VROUTERS).getAsJsonArray();
+ responseJson = getResponseJsonArrayLogical(requestBody,
+ requestProcessor, responseGenerator, responseArray,
+ VtnServiceJsonConsts.VROUTERS,
+ VtnServiceJsonConsts.VROUTERNAME,
+ IpcRequestPacketEnum.KT_VROUTER_GET, uriParameterList,
+ VtnServiceIpcConsts.GET_VROUTER_RESPONSE);
+ }
+ setInfo(responseJson);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
LOG.trace("Complete VRoutersResource#get()");
return status;
}
+
/**
* Add URI parameters to list
*
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
+import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
.getAsJsonArray();
if (vTepGroupMemberArray.size() > 0) {
for (final JsonElement jsonElement : vTepGroupMemberArray) {
+ status = ClientSession.RESP_FATAL;
+ requestProcessor.setServiceInfo(
+ UncUPLLEnums.UPLL_IPC_SERVICE_NAME,
+ UncUPLLEnums.ServiceID.UPLL_EDIT_SVC_ID.ordinal());
requestProcessor
.createIpcRequestPacket(
- IpcRequestPacketEnum.KT_VTEP_GRP_DELETE,
+ IpcRequestPacketEnum.KT_VTEP_GRP_MEMBER_DELETE,
jsonElement.getAsJsonObject(),
getUriParameters(requestBody));
LOG.debug("Request packet deleted successfully");
break;
}
}
-
}
}
}
LOG.debug("Deletion of member data finished successfully..");
// creating Data members along with VtepGroup
-
+ //status = ClientSession.RESP_FATAL;
if (null != requestBody
&& requestBody.has(VtnServiceJsonConsts.VTEPGROUP)) {
vTepGroup = requestBody
final JsonArray vTepGroupMemberArray = vTepGroup.get(
VtnServiceJsonConsts.VTEPGROUPMEMBERNAME)
.getAsJsonArray();
- if (vTepGroupMemberArray.size() > 0) {
+ if (vTepGroupMemberArray.size() > 0) {
for (final JsonElement jsonElement : vTepGroupMemberArray) {
+ status = ClientSession.RESP_FATAL;
+ requestProcessor.setServiceInfo(
+ UncUPLLEnums.UPLL_IPC_SERVICE_NAME,
+ UncUPLLEnums.ServiceID.UPLL_EDIT_SVC_ID.ordinal());
requestProcessor
.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VTEP_GRP_MEMBER_CREATE,
LOG.debug("Complete Ipc framework call");
LOG.trace("Completed VTepGroupResource#delete()");
}
+ setInfo(null);
return status;
}
/**
JsonObject vtepGroup = responseGenerator.getVTepGroupResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
VtnServiceJsonConsts.SHOW);
+ if(!(vtepGroup.get(VtnServiceJsonConsts.VTEPGROUP) instanceof JsonNull)){
+ requestProcessor.setServiceInfo(
+ UncUPLLEnums.UPLL_IPC_SERVICE_NAME,
+ UncUPLLEnums.ServiceID.UPLL_READ_SVC_ID.ordinal());
- requestProcessor.createIpcRequestPacket(
- IpcRequestPacketEnum.KT_VTEP_GRP_MEMBER_GET, requestBody,
- getUriParameters(requestBody));
- LOG.debug("Request packet created successfully for 2nd call");
- requestProcessor
- .getRequestPacket()
- .setOperation(
- IpcDataUnitWrapper
- .setIpcUint32Value(UncOperationEnum.UNC_OP_READ_SIBLING_BEGIN
- .ordinal()));
- status = requestProcessor.processIpcRequest();
- LOG.debug("Request packet processed with status" + status);
- if (status == ClientSession.RESP_FATAL) {
- throw new VtnServiceException(
- Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
- UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
- UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage());
- }
- LOG.debug("Request packet created successfully");
- vtepGroup = responseGenerator.getVtepGroupMembers(
- requestProcessor.getIpcResponsePacket(),
- vtepGroup.getAsJsonObject(VtnServiceJsonConsts.VTEPGROUP));
- JsonArray memberJsonArray = vtepGroup
- .getAsJsonArray(VtnServiceJsonConsts.MEMBERVTEPS);
- VtnServiceConfiguration configuration = VtnServiceInitManager
- .getConfigurationMap();
- final int max_rep_count = Integer.parseInt(configuration
- .getConfigValue(VtnServiceConsts.MAX_REP_DEFAULT));
- int memberIndex = memberJsonArray.size();
- if (memberJsonArray.size() >= max_rep_count) {
- while (memberIndex >= max_rep_count) {
- memberIndex = memberJsonArray.size();
- JsonObject memberJson = (JsonObject) vtepGroup
- .getAsJsonArray(VtnServiceJsonConsts.MEMBERVTEPS)
- .get(memberIndex - 1);
- requestProcessor.createIpcRequestPacket(
- IpcRequestPacketEnum.KT_VTEP_GRP_MEMBER_GET,
- memberJson, getUriParameters(requestBody));
- requestProcessor
- .getRequestPacket()
- .setOperation(
- IpcDataUnitWrapper
- .setIpcUint32Value(UncOperationEnum.UNC_OP_READ_SIBLING
- .ordinal()));
- status = requestProcessor.processIpcRequest();
- vtepGroup = responseGenerator.getVtepGroupMembers(
- requestProcessor.getIpcResponsePacket(), vtepGroup);
- if (!vtepGroup.has(VtnServiceJsonConsts.MEMBERVTEPS)
- || vtepGroup
- .getAsJsonArray(VtnServiceJsonConsts.MEMBERVTEPS) != null
- && vtepGroup.getAsJsonArray(
- VtnServiceJsonConsts.MEMBERVTEPS).size() == 0) {
- break;
+ requestProcessor.createIpcRequestPacket(
+ IpcRequestPacketEnum.KT_VTEP_GRP_MEMBER_GET,
+ requestBody, getUriParameters(requestBody));
+ LOG.debug("Request packet created successfully for 2nd call");
+ requestProcessor
+ .getRequestPacket()
+ .setOperation(
+ IpcDataUnitWrapper
+ .setIpcUint32Value(UncOperationEnum.UNC_OP_READ_SIBLING_BEGIN
+ .ordinal()));
+ status = requestProcessor.processIpcRequest();
+ LOG.debug("Request packet processed with status" + status);
+ if (status == ClientSession.RESP_FATAL) {
+ throw new VtnServiceException(
+ Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR
+ .getErrorMessage());
+ }
+ LOG.debug("Request packet created successfully");
+ vtepGroup = responseGenerator
+ .getVtepGroupMembers(
+ requestProcessor.getIpcResponsePacket(),
+ vtepGroup
+ .getAsJsonObject(VtnServiceJsonConsts.VTEPGROUP));
+ JsonArray memberJsonArray = vtepGroup
+ .getAsJsonArray(VtnServiceJsonConsts.MEMBERVTEPS);
+ VtnServiceConfiguration configuration = VtnServiceInitManager
+ .getConfigurationMap();
+ final int max_rep_count = Integer.parseInt(configuration
+ .getConfigValue(VtnServiceConsts.MAX_REP_DEFAULT));
+ int memberIndex = memberJsonArray.size();
+ if (memberJsonArray.size() >= max_rep_count) {
+ while (memberIndex >= max_rep_count) {
+ memberIndex = memberJsonArray.size();
+ JsonObject memberJson = (JsonObject) vtepGroup
+ .getAsJsonArray(
+ VtnServiceJsonConsts.MEMBERVTEPS).get(
+ memberIndex - 1);
+ requestProcessor.createIpcRequestPacket(
+ IpcRequestPacketEnum.KT_VTEP_GRP_MEMBER_GET,
+ memberJson, getUriParameters(requestBody));
+ requestProcessor
+ .getRequestPacket()
+ .setOperation(
+ IpcDataUnitWrapper
+ .setIpcUint32Value(UncOperationEnum.UNC_OP_READ_SIBLING
+ .ordinal()));
+ status = requestProcessor.processIpcRequest();
+ vtepGroup = responseGenerator.getVtepGroupMembers(
+ requestProcessor.getIpcResponsePacket(),
+ vtepGroup);
+ if (!vtepGroup.has(VtnServiceJsonConsts.MEMBERVTEPS)
+ || vtepGroup
+ .getAsJsonArray(VtnServiceJsonConsts.MEMBERVTEPS) != null
+ && vtepGroup.getAsJsonArray(
+ VtnServiceJsonConsts.MEMBERVTEPS)
+ .size() == 0) {
+ break;
+ }
+ memberIndex++;
}
- memberIndex++;
}
+ root.add(VtnServiceJsonConsts.VTEPGROUP, vtepGroup);
+ setInfo(root);
+ } else {
+ setInfo(vtepGroup);
}
- root.add(VtnServiceJsonConsts.VTEPGROUP, vtepGroup);
- setInfo(root);
+
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
*/
private List<String> getUriParameters(final JsonObject requestBody) {
LOG.trace("Start VTepGroupResource#getUriParameters()");
+ LOG.info("request body : " + requestBody);
final List<String> uriParameters = new ArrayList<String>();
uriParameters.add(vtnName);
if (null != requestBody
.get(VtnServiceJsonConsts.VTEPGROUPMEMBERNAME)
.getAsJsonArray();
if (vTepGroupMemberArray.size() > 0) {
+ requestProcessor.setServiceInfo(
+ UncUPLLEnums.UPLL_IPC_SERVICE_NAME,
+ UncUPLLEnums.ServiceID.UPLL_EDIT_SVC_ID.ordinal());
+
for (final JsonElement jsonElement : vTepGroupMemberArray) {
requestBody.add(
VtnServiceJsonConsts.INDEX,
JsonObject VtepGrp = responseGenerator.getVTepGroupResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
VtnServiceJsonConsts.LIST);
+
+ requestProcessor.setServiceInfo(
+ UncUPLLEnums.UPLL_IPC_SERVICE_NAME,
+ UncUPLLEnums.ServiceID.UPLL_READ_SVC_ID.ordinal());
+
JsonArray vTepGroupArr = null;
if (VtnServiceJsonConsts.DETAIL.equalsIgnoreCase(opType)) {
.getConfigValue(VtnServiceConsts.MAX_REP_DEFAULT));
while (vtepGrpItr.hasNext()) {
JsonObject vTepGroup = (JsonObject) vtepGrpItr.next();
+ requestBody.addProperty(VtnServiceJsonConsts.INDEX,vTepGroup.get(VtnServiceJsonConsts.VTEPGROUPNAME).getAsString());
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VTEP_GRP_MEMBER_GET,
requestBody, getUriParameters(requestBody));
*/
private List<String> getUriParameters(final JsonObject requestBody) {
LOG.trace("Start VTepGroupsResource#getUriParameters()");
+ LOG.info("request body : " + requestBody);
final List<String> uriParameters = new ArrayList<String>();
uriParameters.add(vtnName);
if (requestBody != null && requestBody.has(VtnServiceJsonConsts.INDEX)) {
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 NEC Corporation
+ * All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.vtn.javaapi.resources.logical;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.gson.JsonObject;
+import org.opendaylight.vtn.core.ipc.ClientSession;
+import org.opendaylight.vtn.core.util.Logger;
+import org.opendaylight.vtn.javaapi.annotation.UNCField;
+import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
+import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
+import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
+import org.opendaylight.vtn.javaapi.ipc.conversion.IpcLogicalResponseFactory;
+import org.opendaylight.vtn.javaapi.ipc.enums.IpcRequestPacketEnum;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncCommonEnum;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncCommonEnum.UncResultCode;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncJavaAPIErrorCode;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncUPLLEnums;
+import org.opendaylight.vtn.javaapi.resources.AbstractResource;
+import org.opendaylight.vtn.javaapi.validation.logical.PortMapResourceValidator;
+
+/**
+ * The Class VTepInterfacePortMapResource implements delete, put and get methods.
+ *
+ */
+
+@UNCVtnService(path = "/vtns/{vtn_name}/vteps/{vtep_name}/interfaces/{if_name}/portmap")
+public class VTepInterfacePortMapResource extends AbstractResource {
+ /** The vtn name. */
+ @UNCField("vtn_name")
+ private String vtnName;
+ /** The vbr name. */
+ @UNCField("vtep_name")
+ private String vtepName;
+ /** The if name. */
+ @UNCField("if_name")
+ private String ifName;
+
+ /** The Constant LOG. */
+ private static final Logger LOG = Logger.getLogger(VTepInterfacePortMapResource.class.getSimpleName());
+ /**
+ * Gets the vtn name.
+ *
+ * @return the vtn name
+ */
+ public String getVtnName() {
+ return vtnName;
+ }
+ /**
+ * Gets the vbr name.
+ *
+ * @return the vbr name
+ */
+ public String getVtepName() {
+ return vtepName;
+ }
+ /**
+ * Gets the if name.
+ *
+ * @return the if name
+ */
+ public String getIfName() {
+ return ifName;
+ }
+ /**
+ * Instantiates a new port map resource.
+ */
+ public VTepInterfacePortMapResource() {
+ super();
+ LOG.trace("Start VTepInterfacePortMapResource#VTepInterfacePortMapResource()");
+ setValidator(new PortMapResourceValidator(this));
+ LOG.trace("Complete VTepInterfacePortMapResource#VTepInterfacePortMapResource()");
+ }
+
+ /**
+ * Implementation of Delete method of VTep Interface PortMap API
+ *
+ * @return Error code
+ * @throws VtnServiceException
+ */
+ @Override
+ public int delete() throws VtnServiceException {
+ LOG.trace("Start VTepInterfacePortMapResource#delete()");
+ ClientSession session = null;
+ IpcRequestProcessor requestProcessor = null;
+ int status = ClientSession.RESP_FATAL;
+ try {
+ session = getConnPool().getSession(UncUPLLEnums.UPLL_IPC_CHANNEL_NAME,UncUPLLEnums.UPLL_IPC_SERVICE_NAME,UncUPLLEnums.ServiceID.UPLL_EDIT_SVC_ID.ordinal(),getExceptionHandler());
+ LOG.debug("Session created successfully");
+ requestProcessor = new IpcRequestProcessor(session, getSessionID(), getConfigID(),getExceptionHandler());
+ requestProcessor.createIpcRequestPacket(IpcRequestPacketEnum.KT_VTEP_IF_UPDATE,getNullJsonObject(),getUriParameters());
+ LOG.debug("Request packet created successfully");
+ status= requestProcessor.processIpcRequest();
+ } catch (final VtnServiceException e) {
+ getExceptionHandler().raise(
+ Thread.currentThread().getStackTrace()[1].getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1].getMethodName(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage(), e);
+ throw e;
+ } finally {
+ if (status == ClientSession.RESP_FATAL) {
+ if(null != requestProcessor.getErrorJson()){
+ setInfo(requestProcessor.getErrorJson());
+ } else {
+ createErrorInfo(UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue());
+ }
+ status = UncResultCode.UNC_SERVER_ERROR.getValue();
+ }
+ getConnPool().destroySession(session);
+ }
+ LOG.trace("Complete VTepInterfacePortMapResource#delete()");
+ return status;
+ }
+ /**
+ * Implementation of get method of VTep Interface PortMap API
+ *
+ * @param requestBody the request Json object
+ *
+ * @return Error code
+ * @throws VtnServiceException
+ */
+ @Override
+ public int get(final JsonObject requestBody) throws VtnServiceException {
+ LOG.trace("Start VTepInterfacePortMapResource#get()");
+ ClientSession session = null;
+ IpcRequestProcessor requestProcessor = null;
+ int status = ClientSession.RESP_FATAL;
+ try {
+ session = getConnPool().getSession(UncUPLLEnums.UPLL_IPC_CHANNEL_NAME,UncUPLLEnums.UPLL_IPC_SERVICE_NAME,UncUPLLEnums.ServiceID.UPLL_READ_SVC_ID.ordinal(),getExceptionHandler());
+ LOG.debug("Session created successfully");
+ requestProcessor = new IpcRequestProcessor(session, getSessionID(), getConfigID(),getExceptionHandler());
+ requestProcessor.createIpcRequestPacket(IpcRequestPacketEnum.KT_VTEP_IF_GET, requestBody,getUriParameters());
+ LOG.debug("Request Packet created successfully");
+ status= requestProcessor.processIpcRequest();
+ IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
+ setInfo(responseGenerator.getPortMapResponse(requestProcessor.getIpcResponsePacket(),requestBody,VtnServiceJsonConsts.SHOW,VtnServiceJsonConsts.VTEP_INTERFACE_PORTMAP));
+ LOG.debug("response object created successfully");
+ LOG.debug("Ipc framework call complete");
+ } catch (final VtnServiceException e) {
+ getExceptionHandler().raise(
+ Thread.currentThread().getStackTrace()[1].getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1].getMethodName(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage(), e);
+ throw e;
+ } finally {
+ if (status == ClientSession.RESP_FATAL) {
+ if(null != requestProcessor.getErrorJson()){
+ setInfo(requestProcessor.getErrorJson());
+ } else {
+ createErrorInfo(UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue());
+ }
+ status = UncResultCode.UNC_SERVER_ERROR.getValue();
+ }
+ getConnPool().destroySession(session);
+ }
+ LOG.trace("Complete VTepInterfacePortMapResource#get()");
+ return status;
+ }
+
+ /**
+ * Implementation of Put method of PortMap API
+ *
+ * @param requestBody the request Json object
+ *
+ * @return Error code
+ * @throws VtnServiceException
+ */
+ @Override
+ public int put(final JsonObject requestBody) throws VtnServiceException {
+ LOG.trace("Start VTepInterfacePortMapResource#put()");
+ ClientSession session = null;
+ IpcRequestProcessor requestProcessor = null;
+ int status = ClientSession.RESP_FATAL;
+ try {
+ session = getConnPool().getSession(UncUPLLEnums.UPLL_IPC_CHANNEL_NAME,UncUPLLEnums.UPLL_IPC_SERVICE_NAME,UncUPLLEnums.ServiceID.UPLL_EDIT_SVC_ID.ordinal(),getExceptionHandler());
+ LOG.debug("Session created successfully");
+ requestProcessor = new IpcRequestProcessor(session, getSessionID(), getConfigID(),getExceptionHandler());
+ requestProcessor.createIpcRequestPacket(IpcRequestPacketEnum.KT_VTEP_IF_UPDATE, requestBody,getUriParameters());
+ LOG.debug("Request Packet created successfully");
+ status = requestProcessor.processIpcRequest();
+ }catch (final VtnServiceException e) {
+ getExceptionHandler().raise(
+ Thread.currentThread().getStackTrace()[1].getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1].getMethodName(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage(), e);
+ throw e;
+ } finally {
+ if (status == ClientSession.RESP_FATAL) {
+ if(null != requestProcessor.getErrorJson()){
+ setInfo(requestProcessor.getErrorJson());
+ } else {
+ createErrorInfo(UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue());
+ }
+ status = UncResultCode.UNC_SERVER_ERROR.getValue();
+ }
+ getConnPool().destroySession(session);
+ }
+ LOG.trace("Complete VTepInterfacePortMapResource#put()");
+ return status;
+ }
+ /**
+ * Add URI parameters to list
+ * @return
+ */
+ private List<String> getUriParameters() {
+ final List<String> uriParameters = new ArrayList<String>();
+ uriParameters.add(vtnName);
+ uriParameters.add(vtepName);
+ uriParameters.add(ifName);
+ return uriParameters;
+ }
+}
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
VtnServiceJsonConsts.SHOW);
LOG.debug("Complete Ipc framework call one");
// Condition check for second call
- if ((VtnServiceJsonConsts.STATE).equalsIgnoreCase(dataType)) {
+ if ((VtnServiceJsonConsts.STATE).equalsIgnoreCase(dataType) && !(vtepInterfaceJson.get(VtnServiceJsonConsts.INTERFACE) instanceof JsonNull)) {
requestProcessor.setServiceInfo(
UncUPLLEnums.UPLL_IPC_SERVICE_NAME,
UncUPLLEnums.ServiceID.UPLL_READ_SVC_ID.ordinal());
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
vTepInterfaceJson = responseGenerator.getVTepInterfaceResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
VtnServiceJsonConsts.LIST);
+ final List<String> uriParameterList = getUriParameters(requestBody);
+ if (vTepInterfaceJson.get(VtnServiceJsonConsts.INTERFACES).isJsonArray()) {
+ JsonArray responseArray = vTepInterfaceJson.get(
+ VtnServiceJsonConsts.INTERFACES)
+ .getAsJsonArray();
+ vTepInterfaceJson = getResponseJsonArrayLogical(requestBody,
+ requestProcessor, responseGenerator,
+ responseArray, VtnServiceJsonConsts.INTERFACES,
+ VtnServiceJsonConsts.IFNAME,
+ IpcRequestPacketEnum.KT_VTEP_IF_GET,
+ uriParameterList,VtnServiceIpcConsts.GET_VTEP_INTERFACE_RESPONSE);
+ }
LOG.trace("Response Packet created successfully for 1st request");
if ((VtnServiceJsonConsts.STATE).equalsIgnoreCase(dataType)
&& opType.equalsIgnoreCase(VtnServiceJsonConsts.DETAIL)) {
import org.opendaylight.vtn.javaapi.ipc.conversion.IpcLogicalResponseFactory;
import org.opendaylight.vtn.javaapi.ipc.enums.IpcRequestPacketEnum;
import org.opendaylight.vtn.javaapi.ipc.enums.UncCommonEnum;
-import org.opendaylight.vtn.javaapi.ipc.enums.UncStructEnum;
import org.opendaylight.vtn.javaapi.ipc.enums.UncCommonEnum.UncResultCode;
import org.opendaylight.vtn.javaapi.ipc.enums.UncJavaAPIErrorCode;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncStructEnum;
import org.opendaylight.vtn.javaapi.ipc.enums.UncUPLLEnums;
import org.opendaylight.vtn.javaapi.resources.AbstractResource;
import org.opendaylight.vtn.javaapi.validation.logical.VTepResourceValidator;
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.ipc.IpcDataUnit;
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
import org.opendaylight.vtn.javaapi.ipc.conversion.IpcLogicalResponseFactory;
import org.opendaylight.vtn.javaapi.ipc.enums.IpcRequestPacketEnum;
import org.opendaylight.vtn.javaapi.ipc.enums.UncCommonEnum;
-import org.opendaylight.vtn.javaapi.ipc.enums.UncStructEnum;
import org.opendaylight.vtn.javaapi.ipc.enums.UncCommonEnum.UncResultCode;
import org.opendaylight.vtn.javaapi.ipc.enums.UncJavaAPIErrorCode;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncStructEnum;
import org.opendaylight.vtn.javaapi.ipc.enums.UncUPLLEnums;
import org.opendaylight.vtn.javaapi.resources.AbstractResource;
import org.opendaylight.vtn.javaapi.validation.logical.VTepResourceValidator;
/** The Constant LOG. */
private static final Logger LOG = Logger.getLogger(VTepsResource.class
.getName());
+
/**
* Instantiates a new v teps resource.
*/
setValidator(new VTepResourceValidator(this));
LOG.trace("Completed VTepsResource#VTepsResource()");
}
+
/**
* @return the vtnName
*/
public String getVtnName() {
return vtnName;
}
+
/**
* Implementation of Post method of Vtep API
*
LOG.trace("Completed VTepsResource#post()");
return status;
}
+
/**
* Implementation of Get method of Vtep API
*
UncUPLLEnums.ServiceID.UPLL_READ_SVC_ID.ordinal(),
getExceptionHandler());
LOG.debug("Session created successfully");
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VTEP_GET, requestBody,
- getUriParameters(requestBody));
+ uriParameterList);
if (requestBody != null
&& ((requestBody.has(VtnServiceJsonConsts.TARGETDB) && requestBody
.get(VtnServiceJsonConsts.TARGETDB).getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.STATE)) && !(requestBody
.get(VtnServiceJsonConsts.OP).getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.COUNT)))) {
-
+
IpcStruct valStruct = new IpcStruct(
UncStructEnum.ValVtep.getValue());
requestProcessor.getRequestPacket().setValStruct(valStruct);
extraDataUnits[0] = valStructSt;
requestProcessor.getRequestPacket().setExtraDataUnits(
extraDataUnits);
- }
+ }
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
- setInfo(responseGenerator.getVtepResponse(
- requestProcessor.getIpcResponsePacket(), requestBody,
- VtnServiceJsonConsts.LIST));
+ /*
+ * setInfo(responseGenerator.getVtepResponse(
+ * requestProcessor.getIpcResponsePacket(), requestBody,
+ * VtnServiceJsonConsts.LIST));
+ */
+ JsonObject responseJson = responseGenerator
+ .getVtepResponse(
+ requestProcessor.getIpcResponsePacket(),
+ requestBody, VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.VTEPS)
+ .isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.VTEPS).getAsJsonArray();
+ responseJson = getResponseJsonArrayLogical(requestBody,
+ requestProcessor, responseGenerator, responseArray,
+ VtnServiceJsonConsts.VTEPS,
+ VtnServiceJsonConsts.VTEPNAME,
+ IpcRequestPacketEnum.KT_VTEP_GET,
+ uriParameterList,
+ VtnServiceIpcConsts.GET_VTEP_RESPONSE);
+ }
+ setInfo(responseJson);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
LOG.trace("Completed VTepsResource#get()");
return status;
}
+
/**
* Add URI parameters to list
*
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 NEC Corporation
+ * All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.vtn.javaapi.resources.logical;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.gson.JsonObject;
+import org.opendaylight.vtn.core.ipc.ClientSession;
+import org.opendaylight.vtn.core.util.Logger;
+import org.opendaylight.vtn.javaapi.annotation.UNCField;
+import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
+import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
+import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
+import org.opendaylight.vtn.javaapi.ipc.conversion.IpcLogicalResponseFactory;
+import org.opendaylight.vtn.javaapi.ipc.enums.IpcRequestPacketEnum;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncCommonEnum;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncCommonEnum.UncResultCode;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncJavaAPIErrorCode;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncUPLLEnums;
+import org.opendaylight.vtn.javaapi.resources.AbstractResource;
+import org.opendaylight.vtn.javaapi.validation.logical.PortMapResourceValidator;
+
+/**
+ * The Class VTunnelInterfacePortMapResource implements delete, put and get methods.
+ *
+ */
+
+@UNCVtnService(path = "/vtns/{vtn_name}/vtunnels/{vtunnel_name}/interfaces/{if_name}/portmap")
+public class VTunnelInterfacePortMapResource extends AbstractResource {
+ /** The vtn name. */
+ @UNCField("vtn_name")
+ private String vtnName;
+ /** The vbr name. */
+ @UNCField("vtunnel_name")
+ private String vtunnelName;
+ /** The if name. */
+ @UNCField("if_name")
+ private String ifName;
+
+ /** The Constant LOG. */
+ private static final Logger LOG = Logger.getLogger(VTunnelInterfacePortMapResource.class.getSimpleName());
+ /**
+ * Gets the vtn name.
+ *
+ * @return the vtn name
+ */
+ public String getVtnName() {
+ return vtnName;
+ }
+ /**
+ * Gets the vbr name.
+ *
+ * @return the vbr name
+ */
+ public String getVtunnelName() {
+ return vtunnelName;
+ }
+ /**
+ * Gets the if name.
+ *
+ * @return the if name
+ */
+ public String getIfName() {
+ return ifName;
+ }
+ /**
+ * Instantiates a new port map resource.
+ */
+ public VTunnelInterfacePortMapResource() {
+ super();
+ LOG.trace("Start VTunnelInterfacePortMapResource#VTunnelInterfacePortMapResource()");
+ setValidator(new PortMapResourceValidator(this));
+ LOG.trace("Complete VTunnelInterfacePortMapResource#VTunnelInterfacePortMapResource()");
+ }
+
+ /**
+ * Implementation of Delete method of VTep Interface PortMap API
+ *
+ * @return Error code
+ * @throws VtnServiceException
+ */
+ @Override
+ public int delete() throws VtnServiceException {
+ LOG.trace("Start VTunnelInterfacePortMapResource#delete()");
+ ClientSession session = null;
+ IpcRequestProcessor requestProcessor = null;
+ int status = ClientSession.RESP_FATAL;
+ try {
+ session = getConnPool().getSession(UncUPLLEnums.UPLL_IPC_CHANNEL_NAME,UncUPLLEnums.UPLL_IPC_SERVICE_NAME,UncUPLLEnums.ServiceID.UPLL_EDIT_SVC_ID.ordinal(),getExceptionHandler());
+ LOG.debug("Session created successfully");
+ requestProcessor = new IpcRequestProcessor(session, getSessionID(), getConfigID(),getExceptionHandler());
+ requestProcessor.createIpcRequestPacket(IpcRequestPacketEnum.KT_VTUNNEL_IF_UPDATE,getNullJsonObject(),getUriParameters());
+ LOG.debug("Request packet created successfully");
+ status= requestProcessor.processIpcRequest();
+ } catch (final VtnServiceException e) {
+ getExceptionHandler().raise(
+ Thread.currentThread().getStackTrace()[1].getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1].getMethodName(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage(), e);
+ throw e;
+ } finally {
+ if (status == ClientSession.RESP_FATAL) {
+ if(null != requestProcessor.getErrorJson()){
+ setInfo(requestProcessor.getErrorJson());
+ } else {
+ createErrorInfo(UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue());
+ }
+ status = UncResultCode.UNC_SERVER_ERROR.getValue();
+ }
+ getConnPool().destroySession(session);
+ }
+ LOG.trace("Complete VTunnelInterfacePortMapResource#delete()");
+ return status;
+ }
+ /**
+ * Implementation of get method of VTep Interface PortMap API
+ *
+ * @param requestBody the request Json object
+ *
+ * @return Error code
+ * @throws VtnServiceException
+ */
+ @Override
+ public int get(final JsonObject requestBody) throws VtnServiceException {
+ LOG.trace("Start VTunnelInterfacePortMapResource#get()");
+ ClientSession session = null;
+ IpcRequestProcessor requestProcessor = null;
+ int status = ClientSession.RESP_FATAL;
+ try {
+ session = getConnPool().getSession(UncUPLLEnums.UPLL_IPC_CHANNEL_NAME,UncUPLLEnums.UPLL_IPC_SERVICE_NAME,UncUPLLEnums.ServiceID.UPLL_READ_SVC_ID.ordinal(),getExceptionHandler());
+ LOG.debug("Session created successfully");
+ requestProcessor = new IpcRequestProcessor(session, getSessionID(), getConfigID(),getExceptionHandler());
+ requestProcessor.createIpcRequestPacket(IpcRequestPacketEnum.KT_VTUNNEL_IF_GET, requestBody,getUriParameters());
+ LOG.debug("Request Packet created successfully");
+ status= requestProcessor.processIpcRequest();
+ IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
+ setInfo(responseGenerator.getPortMapResponse(requestProcessor.getIpcResponsePacket(),requestBody,VtnServiceJsonConsts.SHOW,VtnServiceJsonConsts.VTUNNEL_INTERFACE_PORTMAP));
+ LOG.debug("response object created successfully");
+ LOG.debug("Ipc framework call complete");
+ } catch (final VtnServiceException e) {
+ getExceptionHandler().raise(
+ Thread.currentThread().getStackTrace()[1].getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1].getMethodName(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage(), e);
+ throw e;
+ } finally {
+ if (status == ClientSession.RESP_FATAL) {
+ if(null != requestProcessor.getErrorJson()){
+ setInfo(requestProcessor.getErrorJson());
+ } else {
+ createErrorInfo(UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue());
+ }
+ status = UncResultCode.UNC_SERVER_ERROR.getValue();
+ }
+ getConnPool().destroySession(session);
+ }
+ LOG.trace("Complete VTunnelInterfacePortMapResource#get()");
+ return status;
+ }
+
+ /**
+ * Implementation of Put method of PortMap API
+ *
+ * @param requestBody the request Json object
+ *
+ * @return Error code
+ * @throws VtnServiceException
+ */
+ @Override
+ public int put(final JsonObject requestBody) throws VtnServiceException {
+ LOG.trace("Start VTunnelInterfacePortMapResource#put()");
+ ClientSession session = null;
+ IpcRequestProcessor requestProcessor = null;
+ int status = ClientSession.RESP_FATAL;
+ try {
+ session = getConnPool().getSession(UncUPLLEnums.UPLL_IPC_CHANNEL_NAME,UncUPLLEnums.UPLL_IPC_SERVICE_NAME,UncUPLLEnums.ServiceID.UPLL_EDIT_SVC_ID.ordinal(),getExceptionHandler());
+ LOG.debug("Session created successfully");
+ requestProcessor = new IpcRequestProcessor(session, getSessionID(), getConfigID(),getExceptionHandler());
+ requestProcessor.createIpcRequestPacket(IpcRequestPacketEnum.KT_VTUNNEL_IF_UPDATE, requestBody,getUriParameters());
+ LOG.debug("Request Packet created successfully");
+ status = requestProcessor.processIpcRequest();
+ }catch (final VtnServiceException e) {
+ getExceptionHandler().raise(
+ Thread.currentThread().getStackTrace()[1].getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1].getMethodName(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage(), e);
+ throw e;
+ } finally {
+ if (status == ClientSession.RESP_FATAL) {
+ if(null != requestProcessor.getErrorJson()){
+ setInfo(requestProcessor.getErrorJson());
+ } else {
+ createErrorInfo(UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue());
+ }
+ status = UncResultCode.UNC_SERVER_ERROR.getValue();
+ }
+ getConnPool().destroySession(session);
+ }
+ LOG.trace("Complete VTunnelInterfacePortMapResource#put()");
+ return status;
+ }
+ /**
+ * Add URI parameters to list
+ * @return
+ */
+ private List<String> getUriParameters() {
+ final List<String> uriParameters = new ArrayList<String>();
+ uriParameters.add(vtnName);
+ uriParameters.add(vtunnelName);
+ uriParameters.add(ifName);
+ return uriParameters;
+ }
+}
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
requestProcessor.getIpcResponsePacket(),
requestBody, VtnServiceJsonConsts.SHOW);
LOG.trace("Response Packet created successfully for 1st request");
- if ((VtnServiceJsonConsts.STATE).equalsIgnoreCase(dataType)) {
+ if ((VtnServiceJsonConsts.STATE).equalsIgnoreCase(dataType) && !(vtunnelInterfaceJson.get(VtnServiceJsonConsts.INTERFACE) instanceof JsonNull)) {
requestProcessor.setServiceInfo(
UncUPLLEnums.UPLL_IPC_SERVICE_NAME,
UncUPLLEnums.ServiceID.UPLL_READ_SVC_ID.ordinal());
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
if (requestBody.has(VtnServiceJsonConsts.OP)) {
opType = requestBody.get(VtnServiceJsonConsts.OP).getAsString();
}
+ final List<String> uriParameterList = getUriParameters(requestBody);
JsonObject interfacesJson = null;
final JsonArray interfaceArray = new JsonArray();
vtunnelInterfacesJson = responseGenerator
.getVTunnelInterfaceResourceResponse(
requestProcessor.getIpcResponsePacket(),
requestBody, VtnServiceJsonConsts.LIST);
+ if (vtunnelInterfacesJson.get(VtnServiceJsonConsts.INTERFACES).isJsonArray()) {
+ JsonArray responseArray = vtunnelInterfacesJson.get(
+ VtnServiceJsonConsts.INTERFACES)
+ .getAsJsonArray();
+ vtunnelInterfacesJson = getResponseJsonArrayLogical(requestBody,
+ requestProcessor, responseGenerator,
+ responseArray, VtnServiceJsonConsts.INTERFACES,
+ VtnServiceJsonConsts.IFNAME,
+ IpcRequestPacketEnum.KT_VTUNNEL_IF_GET,
+ uriParameterList,VtnServiceIpcConsts.GET_VTUNNEL_INTERFACE_RESPONSE);
+ }
LOG.trace("Response Packet created successfully for 1st request");
if ((VtnServiceJsonConsts.STATE).equalsIgnoreCase(dataType)
&& opType.equalsIgnoreCase(VtnServiceJsonConsts.DETAIL)) {
import org.opendaylight.vtn.javaapi.ipc.conversion.IpcLogicalResponseFactory;
import org.opendaylight.vtn.javaapi.ipc.enums.IpcRequestPacketEnum;
import org.opendaylight.vtn.javaapi.ipc.enums.UncCommonEnum;
-import org.opendaylight.vtn.javaapi.ipc.enums.UncStructEnum;
import org.opendaylight.vtn.javaapi.ipc.enums.UncCommonEnum.UncResultCode;
import org.opendaylight.vtn.javaapi.ipc.enums.UncJavaAPIErrorCode;
+import org.opendaylight.vtn.javaapi.ipc.enums.UncStructEnum;
import org.opendaylight.vtn.javaapi.ipc.enums.UncUPLLEnums;
import org.opendaylight.vtn.javaapi.resources.AbstractResource;
import org.opendaylight.vtn.javaapi.validation.logical.VTunnelResourceValidator;
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
-import org.opendaylight.vtn.core.ipc.IpcDataUnit;
-import org.opendaylight.vtn.core.ipc.IpcStruct;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
import org.opendaylight.vtn.javaapi.ipc.conversion.IpcLogicalResponseFactory;
import org.opendaylight.vtn.javaapi.ipc.enums.IpcRequestPacketEnum;
import org.opendaylight.vtn.javaapi.ipc.enums.UncCommonEnum;
-import org.opendaylight.vtn.javaapi.ipc.enums.UncStructEnum;
import org.opendaylight.vtn.javaapi.ipc.enums.UncCommonEnum.UncResultCode;
import org.opendaylight.vtn.javaapi.ipc.enums.UncJavaAPIErrorCode;
import org.opendaylight.vtn.javaapi.ipc.enums.UncUPLLEnums;
/** The vtn name. */
@UNCField("vtn_name")
private String vtnName;
+
/**
*
* @return the vtn name
public String getVtnName() {
return vtnName;
}
+
private static final Logger LOG = Logger.getLogger(VTunnelsResource.class
.getName());
+
/**
* Instantiates a new v tunnels resource.
*/
setValidator(new VTunnelResourceValidator(this));
LOG.trace("Complete VTunnelsResource#VTunnelsResource()");
}
+
/**
* Implementation of post method of VTunnels
*
UncUPLLEnums.ServiceID.UPLL_EDIT_SVC_ID.ordinal(),
getExceptionHandler());
LOG.debug("Session created successfully");
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VTUNNEL_CREATE, requestBody,
- getUriParameters(requestBody));
+ uriParameterList);
LOG.debug("Request Packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
LOG.trace("Complete VTunnelsResource#post()");
return status;
}
+
/**
* Implementation of get method of VTunnels
*
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ final List<String> uriParameterList = getUriParameters(requestBody);
if (requestBody.has(VtnServiceJsonConsts.TARGETDB)
&& requestBody.get(VtnServiceJsonConsts.TARGETDB)
.getAsString()
.equalsIgnoreCase(VtnServiceJsonConsts.COUNT))) {
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VTUNNEL_GET, requestBody,
- getUriParameters(requestBody));
+ uriParameterList);
} else {
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VTUNNEL_GET_COUNT, requestBody,
- getUriParameters(requestBody));
+ uriParameterList);
}
LOG.debug("Request Packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
- setInfo(responseGenerator.getVTunnelResponse(
- requestProcessor.getIpcResponsePacket(), requestBody,
- VtnServiceJsonConsts.LIST));
+ /*
+ * setInfo(responseGenerator.getVTunnelResponse(
+ * requestProcessor.getIpcResponsePacket(), requestBody,
+ * VtnServiceJsonConsts.LIST));
+ */
+ JsonObject responseJson = responseGenerator
+ .getVTunnelResponse(
+ requestProcessor.getIpcResponsePacket(),
+ requestBody, VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.VTUNNELS)
+ .isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.VTUNNELS).getAsJsonArray();
+ responseJson = getResponseJsonArrayLogical(requestBody,
+ requestProcessor, responseGenerator, responseArray,
+ VtnServiceJsonConsts.VTUNNELS,
+ VtnServiceJsonConsts.VTUNNELNAME,
+ IpcRequestPacketEnum.KT_VTUNNEL_GET,
+ uriParameterList,
+ VtnServiceIpcConsts.GET_VTUNNEL_RESPONSE);
+ }
+ setInfo(responseJson);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
LOG.trace("Complete VTunnelsResource#get()");
return status;
}
+
/**
* Gets the uri parameters.
*
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VBR_VLANMAP_GET, requestBody,
getUriParameters(requestBody));
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
final IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
- setInfo(responseGenerator.getVlanMapResponse(
+ /*
+ * setInfo(responseGenerator.getVlanMapResponse(
+ * requestProcessor.getIpcResponsePacket(), requestBody,
+ * VtnServiceJsonConsts.LIST));
+ */
+ JsonObject responseJson = responseGenerator.getVlanMapResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
- VtnServiceJsonConsts.LIST));
+ VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.VLANMAPS).isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.VLANMAPS).getAsJsonArray();
+ responseJson = getResponseJsonArrayLogical(requestBody,
+ requestProcessor, responseGenerator,
+ responseArray, VtnServiceJsonConsts.VLANMAPS,
+ VtnServiceJsonConsts.VLANMAPID,
+ IpcRequestPacketEnum.KT_VBR_VLANMAP_GET,
+ uriParameterList,VtnServiceIpcConsts.GET_VBRIDGE_VLANMAP_RESPONSE);
+ }
+ setInfo(responseJson);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
+ .raise(Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR
- .getErrorMessage(), e);
+ .getErrorMessage(), e);
throw e;
} finally {
if (status == ClientSession.RESP_FATAL) {
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ // Uriparamter list
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_VTN_GET, requestBody,
- getUriParameters(requestBody));
+ uriParameterList);
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status" + status);
final IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory();
- setInfo(responseGenerator.getVtnResponse(
+ /*setInfo(responseGenerator.getVtnResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
- VtnServiceJsonConsts.LIST));
+ VtnServiceJsonConsts.LIST));*/
+ JsonObject responseJson = responseGenerator.getVtnResponse(
+ requestProcessor.getIpcResponsePacket(), requestBody,
+ VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.VTNS).isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.VTNS).getAsJsonArray();
+
+ responseJson = getResponseJsonArrayLogical(requestBody,
+ requestProcessor,responseGenerator,
+ responseArray, VtnServiceJsonConsts.VTNS,
+ VtnServiceJsonConsts.VTNNAME,
+ IpcRequestPacketEnum.KT_VTN_GET,
+ uriParameterList,VtnServiceIpcConsts.GET_VTN_RESPONSE);
+ }
+ setInfo(responseJson);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
+ .raise(Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR
- .getErrorMessage(), e);
+ .getErrorMessage(), e);
throw e;
} finally {
if (status == ClientSession.RESP_FATAL) {
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.ipc.IpcException;
+import org.opendaylight.vtn.core.ipc.IpcString;
import org.opendaylight.vtn.core.ipc.IpcStruct;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
LOG.info("Request packet processed with status:" +status);
if (status != UncSYSMGEnums.NodeIpcErrorT.NOMG_E_OK.ordinal()) {
LOG.info("Error occurred while performing operation");
- createErrorInfo(
- UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue(),
- UncIpcErrorCode.getNodeCodes(status));
+ createNoMgErrorInfo(UncIpcErrorCode.getNodeCodes(status));
status = UncResultCode.UNC_SERVER_ERROR.getValue();
} else {
LOG.info("Opeartion successfully performed");
LOG.info("Request packet processed with status:"+status);
if (status != UncSYSMGEnums.NodeIpcErrorT.NOMG_E_OK.ordinal()) {
LOG.info("Error occurred while performing operation");
- createErrorInfo(
- UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue(),
- UncIpcErrorCode.getNodeCodes(status));
+ createNoMgErrorInfo(UncIpcErrorCode.getNodeCodes(status));
status = UncResultCode.UNC_SERVER_ERROR.getValue();
} else {
LOG.info("Opeartion successfully performed");
} else if(IpcDataUnitWrapper.getIpcStructUint8Value(ipcResponseStruct, VtnServiceJsonConsts.TYPE).toString().equals(VtnServiceJsonConsts.TWO)){
sessionDetails.addProperty(VtnServiceJsonConsts.TYPE,VtnServiceJsonConsts.RECOVERED);
}
- final IpcStruct vtnNameStruct = (IpcStruct) session.getResponse(i++);
- sessionDetails.addProperty(VtnServiceJsonConsts.VTNNAME, IpcDataUnitWrapper.getIpcStructUint8ArrayValue(vtnNameStruct, VtnServiceJsonConsts.VTNNAME).toString());
- final IpcStruct summaryStruct = (IpcStruct) session.getResponse(i++);
- sessionDetails.addProperty(VtnServiceJsonConsts.SUMMARY, IpcDataUnitWrapper.getIpcStructUint8ArrayValue(summaryStruct, VtnServiceJsonConsts.SUMMARY).toString());
- final IpcStruct messageStruct = (IpcStruct) session.getResponse(i++);
- sessionDetails.addProperty(VtnServiceJsonConsts.MESSAGE,IpcDataUnitWrapper.getIpcStructUint8ArrayValue(messageStruct, VtnServiceJsonConsts.MESSAGE).toString());
+ sessionDetails.addProperty(VtnServiceJsonConsts.VTNNAME, ((IpcString)session.getResponse(i++)).toString());
+ sessionDetails.addProperty(VtnServiceJsonConsts.SUMMARY, ((IpcString)session.getResponse(i++)).toString());
+ sessionDetails.addProperty(VtnServiceJsonConsts.MESSAGE, ((IpcString)session.getResponse(i++)).toString());
alarmJsonArray.add(sessionDetails);
}
response.add(VtnServiceJsonConsts.ALARMS, alarmJsonArray);
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
getUriParameters(requestBody));
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
- LOG.debug("Request packet processed with status:"+status);
+ LOG.debug("Request packet processed with status:" + status);
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
getExceptionHandler()
if (requestBody.has(VtnServiceJsonConsts.OP)) {
opType = requestBody.get(VtnServiceJsonConsts.OP).getAsString();
}
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_BOUNDARY_GET, requestBody,
getUriParameters(requestBody));
}
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
- LOG.debug("Request packet processed with status:"+status);
+ LOG.debug("Request packet processed with status:" + status);
final IpcPhysicalResponseFactory responseGenerator = new IpcPhysicalResponseFactory();
- setInfo(responseGenerator.getBoundaryResponse(
- requestProcessor.getIpcResponsePacket(), requestBody,
- VtnServiceJsonConsts.LIST));
+ /*
+ * setInfo(responseGenerator.getBoundaryResponse(
+ * requestProcessor.getIpcResponsePacket(), requestBody,
+ * VtnServiceJsonConsts.LIST));
+ */
+ JsonObject responseJson = responseGenerator
+ .getBoundaryResponse(
+ requestProcessor.getIpcResponsePacket(),
+ requestBody, VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.BOUNDARIES)
+ .isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.BOUNDARIES).getAsJsonArray();
+ responseJson = getResponseJsonArrayPhysical(requestBody,
+ requestProcessor, responseGenerator, responseArray,
+ VtnServiceJsonConsts.BOUNDARIES,
+ VtnServiceJsonConsts.BOUNDARYID,
+ IpcRequestPacketEnum.KT_BOUNDARY_GET,
+ uriParameterList,
+ VtnServiceIpcConsts.GET_BOUNDARY_RESPONSE);
+ }
+ setInfo(responseJson);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
getUriParameters(requestBody));
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
- LOG.debug("Request packet processed with status:"+status);
+ LOG.debug("Request packet processed with status:" + status);
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
getExceptionHandler()
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_CONTROLLER_GET, requestBody,
getUriParameters(requestBody));
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
- LOG.debug("Request packet processed with status:"+status);
+ LOG.debug("Request packet processed with status:" + status);
final IpcPhysicalResponseFactory responseGenerator = new IpcPhysicalResponseFactory();
- setInfo(responseGenerator.getControllerResponse(
+ /*
+ * setInfo(responseGenerator.getControllerResponse(
+ * requestProcessor.getIpcResponsePacket(), requestBody,
+ * VtnServiceJsonConsts.LIST));
+ */
+ JsonObject responseJson = responseGenerator.getControllerResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
- VtnServiceJsonConsts.LIST));
+ VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.CONTROLLERS).isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.CONTROLLERS).getAsJsonArray();
+ responseJson = getResponseJsonArrayPhysical(requestBody,
+ requestProcessor, responseGenerator, responseArray,
+ VtnServiceJsonConsts.CONTROLLERS,
+ VtnServiceJsonConsts.CONTROLLERID,
+ IpcRequestPacketEnum.KT_CONTROLLER_GET, uriParameterList,
+ VtnServiceIpcConsts.GET_CONTROLLER_RESPONSE);
+ }
+ setInfo(responseJson);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
import java.util.List;
import com.google.gson.JsonArray;
+import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.ipc.IpcDataUnit;
VtnServiceJsonConsts.SHOW);
JsonArray memberArray = null;
JsonArray memberArrayNew = null;
- if (VtnServiceJsonConsts.STATE.equalsIgnoreCase(dataType)) {
+ if (VtnServiceJsonConsts.STATE.equalsIgnoreCase(dataType) && !(root.get(VtnServiceJsonConsts.LOGICALPORT) instanceof JsonNull)) {
requestProcessor.setServiceInfo(UncUPPLEnums.UPPL_IPC_SVC_NAME,
UncUPPLEnums.ServiceID.UPPL_SVC_READREQ.ordinal());
requestProcessor.createIpcRequestPacket(
.getConfigurationMap();
int max_rep_count = Integer.parseInt(configuration
.getConfigValue(VtnServiceConsts.MAX_REP_DEFAULT));
+ memberIndex = memberArray.size();
if (memberArray.size() >= max_rep_count) {
while (memberIndex >= max_rep_count) {
memberIndex = memberArray.size();
.getConfigurationMap();
int max_rep_count = Integer.parseInt(configuration
.getConfigValue(VtnServiceConsts.MAX_REP_DEFAULT));
+ memberIndex = memberArray.size();
if (memberArray.size() >= max_rep_count) {
while (memberIndex >= max_rep_count) {
memberIndex = memberArray.size();
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
UncUPPLEnums.UPPL_IPC_SVC_NAME,
UncUPPLEnums.ServiceID.UPPL_SVC_READREQ.ordinal(),
getExceptionHandler());
+ // Uriparamter list
+ final List<String> uriParameterList = getUriParameters(requestBody);
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_CTR_DOMAIN_GET, requestBody,
- getUriParameters(requestBody));
+ uriParameterList);
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status:"+status);
final IpcPhysicalResponseFactory responseGenerator = new IpcPhysicalResponseFactory();
- setInfo(responseGenerator.getDomainResponse(
+ /*setInfo(responseGenerator.getDomainResponse(
+ requestProcessor.getIpcResponsePacket(), requestBody,
+ VtnServiceJsonConsts.LIST));*/
+ JsonObject responseJson = responseGenerator.getDomainResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
- VtnServiceJsonConsts.LIST));
+ VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.DOMAINS).isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.DOMAINS).getAsJsonArray();
+
+ responseJson = getResponseJsonArrayPhysical(requestBody,
+ requestProcessor, responseGenerator,
+ responseArray, VtnServiceJsonConsts.DOMAINS,
+ VtnServiceJsonConsts.DOMAINID,
+ IpcRequestPacketEnum.KT_CTR_DOMAIN_GET,
+ uriParameterList,VtnServiceIpcConsts.GET_DOMAIN_RESPONSE);
+ }
+ setInfo(responseJson);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
+ .raise(Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR
- .getErrorMessage(), e);
+ .getErrorMessage(), e);
throw e;
} finally {
if (status == ClientSession.RESP_FATAL) {
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
+ .raise(Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR
- .getErrorMessage(), e);
+ .getErrorMessage(), e);
throw e;
} finally {
if (status == ClientSession.RESP_FATAL) {
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_LINK_GET, requestBody,
- getUriParameters(requestBody));
- if (requestBody.has(VtnServiceJsonConsts.OP)
- && !requestBody.get(VtnServiceJsonConsts.OP).getAsString()
- .equalsIgnoreCase(VtnServiceJsonConsts.COUNT)) {
- if (requestBody.has(VtnServiceJsonConsts.SWITCH1ID)
- && requestBody.has(VtnServiceJsonConsts.SWITCH2ID)) {
- requestProcessor
- .getRequestPacket()
- .setOption2(
- IpcDataUnitWrapper
- .setIpcUint32Value(UncOption2Enum.UNC_OPT2_MATCH_BOTH_SWITCH
- .ordinal()));
- } else if (requestBody.has(VtnServiceJsonConsts.SWITCH1ID)) {
- requestProcessor
- .getRequestPacket()
- .setOption2(
- IpcDataUnitWrapper
- .setIpcUint32Value(UncOption2Enum.UNC_OPT2_MATCH_SWITCH1
- .ordinal()));
- } else if (requestBody.has(VtnServiceJsonConsts.SWITCH2ID)) {
- requestProcessor
- .getRequestPacket()
- .setOption2(
- IpcDataUnitWrapper
- .setIpcUint32Value(UncOption2Enum.UNC_OPT2_MATCH_SWITCH2
- .ordinal()));
- }
- }
+ uriParameterList);
+ getModifiedRequestPacket(requestBody, requestProcessor);
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
- LOG.debug("Request packet processed with status:"+status);
+ LOG.debug("Request packet processed with status:" + status);
final IpcPhysicalResponseFactory responseGenerator = new IpcPhysicalResponseFactory();
- setInfo(responseGenerator.getLinkResponse(
+ JsonObject responseJson = responseGenerator.getLinkResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
- VtnServiceJsonConsts.LIST));
+ VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.LINKS).isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.LINKS).getAsJsonArray();
+ responseJson = getResponseJsonArrayPhysical(requestBody,
+ requestProcessor, responseGenerator, responseArray,
+ VtnServiceJsonConsts.LINKS,
+ VtnServiceJsonConsts.LINKNAME,
+ IpcRequestPacketEnum.KT_LINK_GET, uriParameterList,
+ VtnServiceIpcConsts.GET_LINK_RESPONSE);
+ }
+ setInfo(responseJson);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
return status;
}
+ private void getModifiedRequestPacket(final JsonObject requestBody,
+ IpcRequestProcessor requestProcessor) {
+ if ((requestBody.has(VtnServiceJsonConsts.SWITCH1ID)
+ && requestBody.has(VtnServiceJsonConsts.SWITCH2ID)) || requestBody.has(VtnServiceJsonConsts.INDEX)) {
+ requestProcessor
+ .getRequestPacket()
+ .setOption2(
+ IpcDataUnitWrapper
+ .setIpcUint32Value(UncOption2Enum.UNC_OPT2_MATCH_BOTH_SWITCH
+ .ordinal()));
+ } else if (requestBody.has(VtnServiceJsonConsts.SWITCH1ID)) {
+ requestProcessor
+ .getRequestPacket()
+ .setOption2(
+ IpcDataUnitWrapper
+ .setIpcUint32Value(UncOption2Enum.UNC_OPT2_MATCH_SWITCH1
+ .ordinal()));
+ } else if (requestBody.has(VtnServiceJsonConsts.SWITCH2ID)) {
+ requestProcessor
+ .getRequestPacket()
+ .setOption2(
+ IpcDataUnitWrapper
+ .setIpcUint32Value(UncOption2Enum.UNC_OPT2_MATCH_SWITCH2
+ .ordinal()));
+ }
+ }
+
/**
* Add URI parameters to list
*
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
root = responseGenerator.getSwitchPortResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
VtnServiceJsonConsts.SHOW);
- requestProcessor.setServiceInfo(UncUPPLEnums.UPPL_IPC_SVC_NAME,
- UncUPPLEnums.ServiceID.UPPL_SVC_READREQ.ordinal());
- requestProcessor.createIpcRequestPacket(
- IpcRequestPacketEnum.KT_PORT_GET_MEMBER, requestBody,
- getUriParameters());
- LOG.debug("Request Packet 2nd call created successfully");
- status = requestProcessor.processIpcRequest();
- LOG.debug("Request packet 2nd call processed with status:"+status);
- if (status == ClientSession.RESP_FATAL) {
- throw new VtnServiceException(
- Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
- UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
- UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage());
+ if(!(root.get(VtnServiceJsonConsts.PORT) instanceof JsonNull)){
+ requestProcessor.setServiceInfo(UncUPPLEnums.UPPL_IPC_SVC_NAME,
+ UncUPPLEnums.ServiceID.UPPL_SVC_READREQ.ordinal());
+ requestProcessor.createIpcRequestPacket(
+ IpcRequestPacketEnum.KT_PORT_GET_MEMBER, requestBody,
+ getUriParameters());
+ LOG.debug("Request Packet 2nd call created successfully");
+ status = requestProcessor.processIpcRequest();
+ LOG.debug("Request packet 2nd call processed with status:"+status);
+ if (status == ClientSession.RESP_FATAL) {
+ throw new VtnServiceException(
+ Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
+ UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage());
+ }
+ root = responseGenerator.getSwitchPortMemberResponse(
+ requestProcessor.getIpcResponsePacket(), root,
+ VtnServiceJsonConsts.SHOW);
}
- root = responseGenerator.getSwitchPortMemberResponse(
- requestProcessor.getIpcResponsePacket(), root,
- VtnServiceJsonConsts.SHOW);
setInfo(root);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
*/
JsonObject root = null;
final IpcPhysicalResponseFactory responseGenerator = new IpcPhysicalResponseFactory();
+ final List<String> uriParameterList = getUriParameters(requestBody);
if (opType.equalsIgnoreCase(VtnServiceJsonConsts.COUNT)
|| opType.equalsIgnoreCase(VtnServiceJsonConsts.NORMAL)) {
root = responseGenerator.getSwitchPortResponse(
JsonArray switchPortArray = root
.getAsJsonArray(VtnServiceJsonConsts.PORTS);
JsonArray switchPortArrayRes = new JsonArray();
+ root = getResponseJsonArrayPhysical(requestBody,
+ requestProcessor, responseGenerator,
+ switchPortArray, VtnServiceJsonConsts.PORTS,
+ VtnServiceJsonConsts.PORTNAME,
+ IpcRequestPacketEnum.KT_PORT_GET,
+ uriParameterList,VtnServiceIpcConsts.GET_SWITCH_PORT_INTERFACE_RESPONSE);
requestProcessor.setServiceInfo(UncUPPLEnums.UPPL_IPC_SVC_NAME,
UncUPPLEnums.ServiceID.UPPL_SVC_READREQ.ordinal());
for (int index = 0; index < switchPortArray.size(); index++) {
import java.util.ArrayList;
import java.util.List;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.ipc.ClientSession;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCField;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.IpcRequestProcessor;
LOG.debug("Session created successfully");
requestProcessor = new IpcRequestProcessor(session, getSessionID(),
getConfigID(), getExceptionHandler());
+ // Uriparamter list
+ final List<String> uriParameterList = getUriParameters(requestBody);
requestProcessor.createIpcRequestPacket(
IpcRequestPacketEnum.KT_SWITCH_GET, requestBody,
- getUriParameters(requestBody));
+ uriParameterList);
LOG.debug("Request packet created successfully");
status = requestProcessor.processIpcRequest();
LOG.debug("Request packet processed with status:"+status);
final IpcPhysicalResponseFactory responseGenerator = new IpcPhysicalResponseFactory();
- setInfo(responseGenerator.getSwitchResponse(
+ /*setInfo(responseGenerator.getSwitchResponse(
requestProcessor.getIpcResponsePacket(), requestBody,
- VtnServiceJsonConsts.LIST));
+ VtnServiceJsonConsts.LIST));*/
+ JsonObject responseJson = responseGenerator.getSwitchResponse(
+ requestProcessor.getIpcResponsePacket(), requestBody,
+ VtnServiceJsonConsts.LIST);
+ if (responseJson.get(VtnServiceJsonConsts.SWITCHES).isJsonArray()) {
+ JsonArray responseArray = responseJson.get(
+ VtnServiceJsonConsts.SWITCHES).getAsJsonArray();
+
+ responseJson = getResponseJsonArrayPhysical(requestBody,
+ requestProcessor, responseGenerator,
+ responseArray, VtnServiceJsonConsts.SWITCHES,
+ VtnServiceJsonConsts.SWITCHID,
+ IpcRequestPacketEnum.KT_SWITCH_GET,
+ uriParameterList,VtnServiceIpcConsts.GET_SWITCH_RESPONSE);
+ }
+ setInfo(responseJson);
LOG.debug("Response object created successfully");
LOG.debug("Complete Ipc framework call");
} catch (final VtnServiceException e) {
getExceptionHandler()
- .raise(Thread.currentThread().getStackTrace()[1]
- .getClassName()
- + VtnServiceConsts.HYPHEN
- + Thread.currentThread().getStackTrace()[1]
- .getMethodName(),
+ .raise(Thread.currentThread().getStackTrace()[1]
+ .getClassName()
+ + VtnServiceConsts.HYPHEN
+ + Thread.currentThread().getStackTrace()[1]
+ .getMethodName(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(),
UncJavaAPIErrorCode.IPC_SERVER_ERROR
- .getErrorMessage(), e);
+ .getErrorMessage(), e);
throw e;
} finally {
if (status == ClientSession.RESP_FATAL) {
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.javaapi.annotation.UNCVtnService;
import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
+import org.opendaylight.vtn.javaapi.constants.VtnServiceIpcConsts;
import org.opendaylight.vtn.javaapi.constants.VtnServiceJsonConsts;
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.conversion.IpcDataUnitWrapper;
LOG.info("Request packet processed with status:"+status);
if (status != UncSYSMGEnums.NodeIpcErrorT.NOMG_E_OK.ordinal()) {
LOG.info("error occurred while performing operation");
- createErrorInfo(
- UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue(),
- UncIpcErrorCode.getNodeCodes(status));
+ createNoMgErrorInfo(UncIpcErrorCode.getNodeCodes(status));
status = UncResultCode.UNC_SERVER_ERROR.getValue();
} else {
LOG.info("Operation successfully performed");
final JsonObject versionJson = new JsonObject();
final IpcStruct versionStruct = (IpcStruct) session
.getResponse(VtnServiceJsonConsts.VAL_0);
- versionJson.addProperty(VtnServiceJsonConsts.VERSIONNO,
- IpcDataUnitWrapper.getIpcStructUint8ArrayValue(versionStruct,
- VtnServiceJsonConsts.VERSION));
+ String major = IpcDataUnitWrapper.getIpcStructUint16Value(versionStruct,
+ VtnServiceIpcConsts.MAJOR);
+ LOG.debug("major: "+ IpcDataUnitWrapper.getIpcStructUint16Value(versionStruct,
+ VtnServiceIpcConsts.MAJOR));
+ String minor = IpcDataUnitWrapper.getIpcStructUint16Value(versionStruct,
+ VtnServiceIpcConsts.MINOR);
+ LOG.debug("minor: "+ IpcDataUnitWrapper.getIpcStructUint16Value(versionStruct,
+ VtnServiceIpcConsts.MINOR));
+ String revision = IpcDataUnitWrapper.getIpcStructUint16Value(versionStruct,
+ VtnServiceIpcConsts.REVISION);
+ LOG.debug("revision: "+ IpcDataUnitWrapper.getIpcStructUint16Value(versionStruct,
+ VtnServiceIpcConsts.REVISION));
+ String patchLevel = IpcDataUnitWrapper.getIpcStructUint16Value(versionStruct,
+ VtnServiceIpcConsts.PATCHLEVEL);
+ LOG.debug("patchLevel: "+ IpcDataUnitWrapper.getIpcStructUint16Value(versionStruct,
+ VtnServiceIpcConsts.PATCHLEVEL));
+ String version = VtnServiceJsonConsts.V + major + VtnServiceConsts.DOT + minor + VtnServiceConsts.DOT + revision + VtnServiceConsts.DOT + patchLevel;
+ versionJson.addProperty(VtnServiceJsonConsts.VERSIONNO, version);
final JsonArray patchJsonArray = new JsonArray();
JsonObject patchJson = null;
for (int i = VtnServiceJsonConsts.VAL_1; i < count; i++) {
.equals(entry.getValue().getAsString().trim())) {
entry.setValue(new JsonPrimitive(entry.getValue().getAsString()
.trim()));
- } else {
- // No need to do anything
+ }
+ }
+ return jsonObject;
+ }
+
+ /**
+ * Remove the parameters of given Json which contain empty string
+ *
+ * @param Json
+ * object that require to be update
+ * @return Updated Json Object
+ */
+ public static JsonObject removeEmptyParamas(final JsonObject jsonObject){
+ // extract all the entries in Json Object
+ Set<Entry<String, JsonElement>> jsonSet = jsonObject.entrySet();
+ /*
+ * iterate the loop for each entry
+ */
+ for (Entry<String, JsonElement> entry : jsonSet) {
+ /*
+ * if entry is type of Json Object
+ */
+ if (!(entry.getValue() instanceof JsonNull)
+ && entry.getValue().isJsonObject()) {
+ VtnServiceUtil.removeEmptyParamas((JsonObject) entry.getValue());
+ continue;
+ }
+ /*
+ * if entry is type of Json array
+ */
+ else if (!(entry.getValue() instanceof JsonNull)
+ && entry.getValue().isJsonArray()) {
+ JsonArray array = (JsonArray) entry.getValue();
+ for (int index = 0; index < array.size(); index++) {
+ VtnServiceUtil.removeEmptyParamas(array.get(index)
+ .getAsJsonObject());
+ continue;
+ }
+ continue;
+ }
+ /*
+ * if entry is primitive type value
+ */
+ else if (!(entry.getValue() instanceof JsonNull)
+ && entry.getValue().getAsString()
+ .equals("")) {
+ jsonObject.remove(entry.getKey());
}
}
return jsonObject;
boolean isValid = false;
if (requestBody != null && VtnServiceConsts.PUT.equals(method)) {
isValid = validatePut(requestBody);
+ }else {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
+ isValid = false;
}
if (!isValid) {
LOG.error("Validation failed");
LOG.trace("Complete AbortCandidateConfigResourceValidator#validatePut()");
return isValid;
}
-}
+}
\ No newline at end of file
boolean isValid = false;
if (requestBody != null && VtnServiceConsts.PUT.equals(method)) {
isValid = validatePut(requestBody);
+ }else {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
+ isValid = false;
}
// Throws exception if validation fails
if (!isValid) {
LOG.trace("Complete AutoSaveResourceValidator#validatePut()");
return isValid;
}
-
-}
+}
\ No newline at end of file
VtnServiceJsonConsts.INDEX).getAsString() != null) {
invalidParameter = VtnServiceJsonConsts.INDEX;
isValid = isValidRange(
- Integer.parseInt(requestBody
+ requestBody
.getAsJsonPrimitive(VtnServiceJsonConsts.INDEX)
- .getAsString().trim()),
+ .getAsString().trim(),
VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_65535);
.getAsString() != null
&& !requestBody.getAsJsonPrimitive(VtnServiceJsonConsts.MAX)
.getAsString().trim().isEmpty()) {
- final long max = Long.parseLong(requestBody
+ final String max = requestBody
.getAsJsonPrimitive(VtnServiceJsonConsts.MAX).getAsString()
- .trim());
- isValid = isValidRange(max, VtnServiceJsonConsts.LONG_VAL_0,
+ .trim();
+ isValid = isValidRange(max, VtnServiceJsonConsts.LONG_VAL_1,
VtnServiceJsonConsts.LONG_VAL_4294967295);
} else {
VtnServiceConfiguration configuration = VtnServiceInitManager
return isValid;
}
- /**
- * Validate the description filed's value
- *
- * @param description
- * the value of description in the request Json object
- * @param len
- * length of description field possible
- * @return
- */
- /*
- * public boolean isValidDescription(final String description, final int
- * len) { LOG.trace("Inside CommonValidator#isValidDescription"); return
- * description.matches(VtnServiceConsts.ALPHANUM_REGEX) &&
- * description.length() <= len; }
- */
-
/**
* Checks if is valid range.
*
* the maximum value possible
* @return true, if is valid range
*/
- public boolean isValidRange(final int input, final int min, final int max) {
+ public boolean isValidRange(final String input, final int min, final int max) {
LOG.trace("Inside CommonValidator#isValidRange (int)");
- return input >= min && input <= max;
+ if (!(input.equals(VtnServiceConsts.EMPTY_STRING))) {
+ int inputResult = Integer.parseInt(input);
+ return inputResult >= min && inputResult <= max;
+ } else {
+ return true;
+ }
}
/**
* @return true,if it is valid range
*/
- public boolean isValidRange(final Long input, final Long min, final Long max) {
+ public boolean isValidRange(final String input, final Long min, final Long max) {
LOG.trace("Inside CommonValidator#isValidRange (Long)");
- return input >= min && input <= max;
+ if (!(input.equals(VtnServiceConsts.EMPTY_STRING))) {
+ long inputResult = Long.parseLong(input);
+ return inputResult >= min && inputResult <= max;
+ } else {
+ return true;
+ }
}
/**
*/
public boolean isValidMacAddress(final String input) {
LOG.trace("Inside CommonValidator#isValidMacAddress");
+ if(VtnServiceConsts.EMPTY_STRING.equals(input)){
+ return true;
+ }
return input.matches(VtnServiceConsts.MAC_ADD_REGEX);
}
*/
public boolean isValidEtherType(final String input) {
LOG.trace("Inside CommonValidator#isValidEtherType");
- return input.matches(VtnServiceConsts.ETH_TYPE_REGEX);
+ if (VtnServiceConsts.EMPTY_STRING.equals(input)) {
+ return true;
+ } else if (input.contains("x") || input.contains("X")) {
+ return input.matches(VtnServiceConsts.ETH_TYPE_REGEX);
+ } else {
+ return isValidRange(input, VtnServiceJsonConsts.VAL_0,
+ VtnServiceJsonConsts.VAL_65535);
+ }
}
/**
*/
public boolean isValidIpV4(final String input) {
LOG.trace("Inside CommonValidator#isValidIpV4");
- if (null != IpAddressUtil.textToNumericFormatV4(input)) {
+ if (VtnServiceConsts.EMPTY_STRING.equals(input)) {
+ return true;
+ } else if (null != IpAddressUtil.textToNumericFormatV4(input)) {
return true;
} else {
return false;
}
- // return input.matches(VtnServiceConsts.IPV4_ADD_REGEX);
}
/**
*/
public boolean isValidIpV6(final String input) {
LOG.trace("Inside CommonValidator#isValidIpV6");
- if (null != IpAddressUtil.textToNumericFormatV6(input)) {
+ if (VtnServiceConsts.EMPTY_STRING.equals(input)) {
+ return true;
+ } else if (null != IpAddressUtil.textToNumericFormatV6(input)) {
return true;
} else {
return false;
}
- // return input.matches(VtnServiceConsts.IPV6_ADD_REGEX);
}
- /**
- * Checks if is valid netmask.
- *
- * @param input
- * the value to be validated
- * @return true, if is valid netmask
- */
- /*
- * public boolean isValidNetmask(final String input) {
- * LOG.trace("Inside CommonValidator#isValidNetmask"); return
- * input.matches(VtnServiceConsts.NETMASK_REGEX); }
- */
-
- /**
- * Checks if is valid length.
- *
- * @param input
- * the value to be validated
- * @param length
- * the length
- * @return true, if is valid length
- */
- /*
- * public boolean isValidLength(final String input, final int length) {
- * LOG.trace("Inside CommonValidator#isValidLength"); return input.length()
- * == length; }
- */
-
/**
* Checks if is valid max length.
*
return input.length() <= length;
}
- /**
- * Checks if is valid max length number.
- *
- * @param input
- * the value to be validated
- * @return true, if is valid max length number
- */
- public boolean isValidMaxLengthNumber(final String input) {
- LOG.trace("Inside CommonValidator#isValidMaxLengthNumber");
- return input.matches(VtnServiceConsts.INTEGER_REGEX);
- }
-
/**
* @param input
* the value to be validated
*/
public boolean isValidMaxLengthAlphaNum(final String input, final int length) {
LOG.trace("Inside CommonValidator#isValidMaxLengthAlphaNum");
+ if (VtnServiceConsts.EMPTY_STRING.equals(input)) {
+ return true;
+ }
return input.matches(VtnServiceConsts.ALPHANUM_REGEX)
&& input.length() <= length;
}
/**
- * Type validation recommended values : unknown,pfc,overlay and legacy
+ * Type validation recommended values : bypass,pfc and vnp
*
* @param input
* the value to be validated
*/
public boolean isValidType(final String input) {
LOG.trace("Start CommonValidator#isValidType");
+ if (VtnServiceConsts.EMPTY_STRING.equals(input)) {
+ return true;
+ }
Boolean valid = false;
if (VtnServiceJsonConsts.BYPASS.equalsIgnoreCase(input)
|| VtnServiceJsonConsts.PFC.equalsIgnoreCase(input)
}
/**
- * Audit Status recommended values : enable or disable
- *
+ * Check validation for Audit Status Parameter
* @param input
- * the value to be validated
- * @return true, if is valid audit status
- */
- /*
- * public boolean isValidAuditStatus(final String input) {
- * LOG.trace("Inside CommonValidator#isValidAuditStatus"); Boolean valid =
- * false; if(VtnServiceJsonConsts.UP.equalsIgnoreCase(input) ||
- * VtnServiceJsonConsts.DOWN.equalsIgnoreCase(input) ||
- * VtnServiceJsonConsts.WAITING_AUDIT.equalsIgnoreCase(input) ||
- * VtnServiceJsonConsts.AUDITING.equalsIgnoreCase(input)){ valid = true; }
- * return valid; // return input.length()<=length; }
+ * @return
*/
-
- // updated after integration
public boolean isValidAuditStatus(final String input) {
LOG.trace("Inside CommonValidator#isValidAuditStatus");
+ if (VtnServiceConsts.EMPTY_STRING.equals(input)) {
+ return true;
+ }
return VtnServiceJsonConsts.ENABLE.equalsIgnoreCase(input)
|| VtnServiceJsonConsts.DISABLE.equalsIgnoreCase(input);
}
*/
public boolean isValidPhysicalId(final String linkName, final int length) {
LOG.trace("Inside CommonValidator#isValidPhysicalId");
+ if (VtnServiceConsts.EMPTY_STRING.equals(linkName)) {
+ return true;
+ }
return linkName.matches(VtnServiceConsts.SWITCH_REGEX)
&& linkName.length() <= length;
}
- /**
- * Validator for logical port id allows alphanumeric characters, "-" and "."
- * in the value
- *
- * @param input
- * the value to be validated
- * @param length
- * the maximum length possible
- * @return true, if is valid value
- */
- /*
- * public boolean isValidPhysicalLogicalId(final String linkName, final int
- * length) { LOG.trace("Inside CommonValidator#isValidPhysicalId"); return
- * linkName.matches(VtnServiceConsts.LOGICAL_PORT_ID_REGEX) &&
- * linkName.length() <= length; }
- */
-
/**
* Validator for version, allows alphanumeric characters and "." in the
* value
*/
public boolean isValidVersion(final String input, final int length) {
LOG.trace("Inside CommonValidator#isValidVersion");
+ if (VtnServiceConsts.EMPTY_STRING.equals(input)) {
+ return true;
+ }
return input.matches(VtnServiceConsts.VERSION_REGEX)
&& input.length() <= length;
}
*/
public boolean isValidDomainId(final String input, final int length) {
LOG.trace("Inside CommonValidator#isValidDomainId");
+ if (VtnServiceConsts.EMPTY_STRING.equals(input)) {
+ return true;
+ }
return (input.matches(VtnServiceConsts.ALPHANUM_REGEX) || input
.equals(VtnServiceJsonConsts.DEFAULT_DOMAIN_ID))
&& input.length() <= length;
&& ffEntry.getAsJsonPrimitive(
VtnServiceJsonConsts.PRIORITY).getAsString() != null) {
isValid = isValidRange(
- Integer.parseInt(ffEntry
+ ffEntry
.getAsJsonPrimitive(
VtnServiceJsonConsts.PRIORITY)
- .getAsString().trim()),
+ .getAsString().trim(),
VtnServiceJsonConsts.VAL_0,
VtnServiceJsonConsts.VAL_7);
}
.getAsJsonPrimitive(VtnServiceJsonConsts.DSCP)
.getAsString() != null) {
isValid = isValidRange(
- Integer.parseInt(ffEntry
+ ffEntry
.getAsJsonPrimitive(
VtnServiceJsonConsts.DSCP)
- .getAsString().trim()),
+ .getAsString().trim(),
VtnServiceJsonConsts.VAL_0,
VtnServiceJsonConsts.VAL_63);
}
* @return true, if successful
*/
public boolean isValidRedirectDst(boolean isValid, final JsonObject ffEntry) {
- LOG.trace("Start CommonValidator#isValidRedirectDst()");
+ LOG.trace("Start CommonValidator#isValidRedirectDst()");
setInvalidParameter(VtnServiceJsonConsts.REDIRECTDST);
if (ffEntry.has(VtnServiceJsonConsts.REDIRECTDST)) {
final JsonObject dest = ffEntry
.getAsString().trim());
}
}
- } else {
- isValid = false;
}
LOG.trace("Complete CommonValidator#isValidRedirectDst()");
return isValid;
&& ((ReleaseConfigModeResource) resource).getConfigId() != null
&& !((ReleaseConfigModeResource) resource).getConfigId().trim()
.isEmpty()) {
- isValid = validator.isValidRange(Long
- .parseLong(((ReleaseConfigModeResource) resource)
- .getConfigId().trim()),
- VtnServiceJsonConsts.LONG_VAL_0,
- VtnServiceJsonConsts.LONG_VAL_4294967295);
+ isValid = validator
+ .isValidRange(((ReleaseConfigModeResource) resource)
+ .getConfigId().trim(),
+ VtnServiceJsonConsts.LONG_VAL_0,
+ VtnServiceJsonConsts.LONG_VAL_4294967295);
} else if (resource instanceof AcquireConfigModeResource) {
isValid = true;
}
if (isValid && requestBody != null
&& VtnServiceConsts.POST.equalsIgnoreCase(method)) {
isValid = validatePost(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
// Throws exception if validation fails
LOG.trace("Complete ConfigModeResourceValidator#validatePost()");
return isValid;
}
-
-}
+}
\ No newline at end of file
boolean isValid = false;
if (requestBody != null && VtnServiceConsts.PUT.equals(method)) {
isValid = validatePut(requestBody);
+ }else {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
+ isValid = false;
}
// Throws exception if validation fails
if (!isValid) {
LOG.trace("Complete ConfigResourceValidator#validatePut()");
return isValid;
}
-}
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 NEC Corporation
+ * All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.vtn.javaapi.validation;
+
+import com.google.gson.JsonObject;
+import org.opendaylight.vtn.core.util.Logger;
+import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
+import org.opendaylight.vtn.javaapi.resources.AbstractResource;
+
+public class DifferenceConfigResourceValidator extends VtnServiceValidator{
+
+ private static final Logger LOG = Logger.getLogger(DifferenceConfigResourceValidator.class.getName());
+
+ public DifferenceConfigResourceValidator(final AbstractResource resource) {
+
+ }
+
+ /**
+ * Validate request Json for UNC Difference Config API.
+ */
+ @Override
+ public void validate(final String method, final JsonObject requestBody)
+ throws VtnServiceException {
+ LOG.info("Validation not required for Diffrence Config API");
+ }
+}
try {
if (requestBody != null && VtnServiceConsts.PUT.equals(method)) {
isValid = validatePut(requestBody);
+ }else {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
+ isValid = false;
}
} catch (final NumberFormatException e) {
LOG.error("Inside catch:NumberFormatException");
.getAsJsonPrimitive(VtnServiceJsonConsts.TIMEOUT)
.getAsString() != null) {
isValid = validator.isValidRange(
- Long.parseLong(readLock
- .getAsJsonPrimitive(
- VtnServiceJsonConsts.TIMEOUT)
- .getAsString().trim()),
- VtnServiceJsonConsts.LONG_VAL_0,
+ readLock.getAsJsonPrimitive(
+ VtnServiceJsonConsts.TIMEOUT).getAsString()
+ .trim(), VtnServiceJsonConsts.LONG_VAL_0,
VtnServiceJsonConsts.LONG_VAL_4294967295);
}
}
LOG.trace("Complete ReadLockResourceValidator#validatePut()");
return isValid;
}
-
-}
+}
\ No newline at end of file
&& ((SessionResource) resource).getSessionId() != null
&& !((SessionResource) resource).getSessionId().trim()
.isEmpty()) {
- if (Long.parseLong(((SessionResource) resource).getSessionId()
+ /*if (Long.parseLong(((SessionResource) resource).getSessionId()
.trim()) >= 0) {
isValid = true;
- }
+ }*/
+ isValid = validator.isValidRange(((SessionResource) resource)
+ .getSessionId().trim(), VtnServiceJsonConsts.LONG_VAL_1,
+ VtnServiceJsonConsts.LONG_VAL_4294967295);
setListOpFlag(false);
} else if (resource instanceof SessionsResource) {
isValid = true;
} else if (isValid && requestBody != null
&& VtnServiceConsts.POST.equals(method)) {
isValid = validatePost(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
// Throws exception if validation fails
session.getAsJsonPrimitive(
VtnServiceJsonConsts.LOGIN_NAME)
.getAsString().trim(),
- VtnServiceJsonConsts.LEN_32);
+ VtnServiceJsonConsts.LEN_63);
}
}
// validation for key: username
.trim()
.equalsIgnoreCase(VtnServiceJsonConsts.OPER);
} else {
- requestBody.remove(VtnServiceJsonConsts.USERNAME);
- requestBody.addProperty(VtnServiceJsonConsts.USERNAME,
+ requestBody.getAsJsonObject(VtnServiceJsonConsts.SESSION).remove(VtnServiceJsonConsts.USERNAME);
+ requestBody.getAsJsonObject(VtnServiceJsonConsts.SESSION).addProperty(VtnServiceJsonConsts.USERNAME,
VtnServiceJsonConsts.OPER);
}
}
.equalsIgnoreCase(
VtnServiceJsonConsts.WEBUI);
} else {
- requestBody.remove(VtnServiceJsonConsts.TYPE);
- requestBody.addProperty(VtnServiceJsonConsts.TYPE,
+ requestBody.getAsJsonObject(VtnServiceJsonConsts.SESSION).remove(VtnServiceJsonConsts.TYPE);
+ requestBody.getAsJsonObject(VtnServiceJsonConsts.SESSION).addProperty(VtnServiceJsonConsts.TYPE,
VtnServiceJsonConsts.WEBUI);
}
}
.getAsString().trim().isEmpty()) {
isValid = validator.isValidMaxLength(session
.getAsJsonPrimitive(VtnServiceJsonConsts.INFO)
- .getAsString().trim(), VtnServiceJsonConsts.LEN_64);
+ .getAsString().trim(), VtnServiceJsonConsts.LEN_63);
}
}
}
LOG.trace("Complete SessionResourceValidator#validatePost()");
return isValid;
}
-
-}
+}
\ No newline at end of file
if (isValid && requestBody != null
&& VtnServiceConsts.PUT.equalsIgnoreCase(method)) {
isValid = validatePut(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
// Throws exception if validation fails
boolean isValid = false;
// validation for password
setInvalidParameter(VtnServiceJsonConsts.PASSWORD);
+ if (requestBody.has(VtnServiceJsonConsts.PASSWORD)
+ && requestBody.get(VtnServiceJsonConsts.PASSWORD) instanceof JsonObject
+ && requestBody.get(VtnServiceJsonConsts.PASSWORD)
+ .getAsJsonObject()
+ .getAsJsonPrimitive(VtnServiceJsonConsts.PASSWORD)
+ .getAsString() != null) {
+ String password = requestBody.get(VtnServiceJsonConsts.PASSWORD)
+ .getAsJsonObject().get(VtnServiceJsonConsts.PASSWORD)
+ .getAsString();
+ requestBody.remove(VtnServiceJsonConsts.PASSWORD);
+ requestBody.addProperty(VtnServiceJsonConsts.PASSWORD, password);
+ }
if (requestBody.has(VtnServiceJsonConsts.PASSWORD)
&& requestBody
.getAsJsonPrimitive(VtnServiceJsonConsts.PASSWORD)
LOG.trace("Complete UserResourceValidator#validatePut()");
return isValid;
}
-}
+}
\ No newline at end of file
&& VtnServiceConsts.GET.equals(method)) {
isValid = validateGet(requestBody);
updateOpParameterForList(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
// Throws exception if validation fails
} else if (isValid && requestBody != null
&& VtnServiceConsts.PUT.equals(method)) {
isValid = validatePut(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
} else if (isValid && requestBody != null
&& VtnServiceConsts.POST.equals(method)) {
isValid = validatePost(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
// Throws exception if validation fails
} else if (isValid && requestBody != null
&& VtnServiceConsts.POST.equals(method)) {
isValid = validatePost(requestBody);
- if(validator.getInvalidParameter()!=null){
+ if (validator.getInvalidParameter() != null) {
setInvalidParameter(validator.getInvalidParameter());
}
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
- if(validator.getInvalidParameter()!=null){
+ if (validator.getInvalidParameter() != null) {
setInvalidParameter(validator.getInvalidParameter());
}
LOG.error("Inside catch:NumberFormatException");
isValid = false;
} catch (final ClassCastException e) {
- if(validator.getInvalidParameter()!=null){
+ if (validator.getInvalidParameter() != null) {
setInvalidParameter(validator.getInvalidParameter());
}
LOG.error("Inside catch:ClassCastException");
.getAsString() != null
&& !ffEntry.getAsJsonPrimitive(VtnServiceJsonConsts.SEQNUM)
.getAsString().trim().isEmpty()) {
- isValid = validator.isValidRange(Integer.parseInt(ffEntry
+ isValid = validator.isValidRange(ffEntry
.getAsJsonPrimitive(VtnServiceJsonConsts.SEQNUM)
- .getAsString().trim()), VtnServiceJsonConsts.VAL_1,
+ .getAsString().trim(), VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_65535);
} else {
isValid = false;
if (((FlowFilterEntryResource) resource).getSeqnum() != null
&& !((FlowFilterEntryResource) resource).getSeqnum()
.trim().isEmpty()) {
- isValid = validator.isValidRange(Integer
- .parseInt(((FlowFilterEntryResource) resource)
- .getSeqnum().trim()),
+ isValid = validator.isValidRange(((FlowFilterEntryResource) resource)
+ .getSeqnum().trim(),
VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_65535);
} else {
&& VtnServiceConsts.PUT.equals(method)) {
isValid = validator.isValidFlowFilterEntry(requestBody);
setInvalidParameter(validator.getInvalidParameter());
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
- if(method.equals(VtnServiceConsts.PUT)){
+ if (method.equals(VtnServiceConsts.PUT)) {
setInvalidParameter(validator.getInvalidParameter());
}
LOG.error("Inside catch:NumberFormatException");
private boolean validateGet(final JsonObject requestBody) {
LOG.trace("Start FlowFilterEntryResourceValidator#validateGet()");
boolean isValid = false;
- // validation for key: controller_id(mandatory)
- setInvalidParameter(VtnServiceJsonConsts.CONTROLLERID);
- if (requestBody.has(VtnServiceJsonConsts.CONTROLLERID)
- && requestBody.getAsJsonPrimitive(
- VtnServiceJsonConsts.CONTROLLERID).getAsString() != null) {
- isValid = validator.isValidMaxLengthAlphaNum(requestBody
- .getAsJsonPrimitive(VtnServiceJsonConsts.CONTROLLERID)
- .getAsString().trim(), VtnServiceJsonConsts.LEN_31);
- } else {
- isValid = false;
- }
- if (isValid) {
- // validation for key: domain_id(mandatory)
- setInvalidParameter(VtnServiceJsonConsts.DOMAINID);
- if (requestBody.has(VtnServiceJsonConsts.DOMAINID)
+
+ // validation for key: targetdb
+ setInvalidParameter(VtnServiceJsonConsts.TARGETDB);
+ isValid = validator.isValidRequestDB(requestBody);
+
+ if (isValid
+ && requestBody
+ .getAsJsonPrimitive(VtnServiceJsonConsts.TARGETDB)
+ .getAsString().trim()
+ .equalsIgnoreCase(VtnServiceJsonConsts.STATE)) {
+ // validation for key: controller_id(mandatory)
+ setInvalidParameter(VtnServiceJsonConsts.CONTROLLERID);
+ if (requestBody.has(VtnServiceJsonConsts.CONTROLLERID)
&& requestBody.getAsJsonPrimitive(
- VtnServiceJsonConsts.DOMAINID).getAsString() != null) {
- isValid = validator.isValidDomainId(requestBody
- .getAsJsonPrimitive(VtnServiceJsonConsts.DOMAINID)
+ VtnServiceJsonConsts.CONTROLLERID).getAsString() != null) {
+ isValid = validator.isValidMaxLengthAlphaNum(requestBody
+ .getAsJsonPrimitive(VtnServiceJsonConsts.CONTROLLERID)
.getAsString().trim(), VtnServiceJsonConsts.LEN_31);
} else {
isValid = false;
}
+
+ if (isValid) {
+ // validation for key: domain_id(mandatory)
+ setInvalidParameter(VtnServiceJsonConsts.DOMAINID);
+ if (requestBody.has(VtnServiceJsonConsts.DOMAINID)
+ && requestBody.getAsJsonPrimitive(
+ VtnServiceJsonConsts.DOMAINID).getAsString() != null) {
+ isValid = validator.isValidDomainId(requestBody
+ .getAsJsonPrimitive(VtnServiceJsonConsts.DOMAINID)
+ .getAsString().trim(), VtnServiceJsonConsts.LEN_31);
+ } else {
+ isValid = false;
+ }
+ }
}
- // validation for key: targetdb
- if (isValid) {
- setInvalidParameter(VtnServiceJsonConsts.TARGETDB);
- isValid = validator.isValidRequestDB(requestBody);
- }
+
// validation for key: op
if (isValid) {
setInvalidParameter(VtnServiceJsonConsts.OP);
} else if (isValid && requestBody != null
&& VtnServiceConsts.POST.equals(method)) {
isValid = validatePost(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
if (((FlowListEntryResource) resource).getSeqnum() != null
&& !((FlowListEntryResource) resource).getSeqnum()
.trim().isEmpty()) {
- isValid = validator.isValidRange(Integer
- .parseInt(((FlowListEntryResource) resource)
- .getSeqnum().trim()),
+ isValid = validator.isValidRange(((FlowListEntryResource) resource)
+ .getSeqnum().trim(),
VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_65535);
} else {
} else if (isValid && requestBody != null
&& VtnServiceConsts.POST.equals(method)) {
isValid = validatePost(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
.getAsString() != null) {
isValid = validator
.isValidRange(
- Integer.parseInt(flowListEntry
+ flowListEntry
.getAsJsonPrimitive(
VtnServiceJsonConsts.MACVLANPRIORITY)
- .getAsString().trim()),
+ .getAsString().trim(),
VtnServiceJsonConsts.VAL_0,
VtnServiceJsonConsts.VAL_7);
}
.getAsString() != null) {
isValid = validator
.isValidRange(
- Integer.parseInt(flowListEntry
+ flowListEntry
.getAsJsonPrimitive(
VtnServiceJsonConsts.IPDSTADDRPREFIX)
- .getAsString().trim()),
+ .getAsString().trim(),
VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_32);
}
.getAsString() != null) {
isValid = validator
.isValidRange(
- Integer.parseInt(flowListEntry
+ flowListEntry
.getAsJsonPrimitive(
VtnServiceJsonConsts.IPSRCADDRPREFIX)
- .getAsString().trim()),
+ .getAsString().trim(),
VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_32);
}
.getAsString() != null) {
isValid = validator
.isValidRange(
- Integer.parseInt(flowListEntry
+ flowListEntry
.getAsJsonPrimitive(
VtnServiceJsonConsts.IPV6DSTADDRPREFIX)
- .getAsString().trim()),
+ .getAsString().trim(),
VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_128);
}
.getAsString() != null) {
isValid = validator
.isValidRange(
- Integer.parseInt(flowListEntry
+ flowListEntry
.getAsJsonPrimitive(
VtnServiceJsonConsts.IPV6SRCADDRPREFIX)
- .getAsString().trim()),
+ .getAsString().trim(),
VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_128);
}
&& flowListEntry.getAsJsonPrimitive(
VtnServiceJsonConsts.IPPROTO).getAsString() != null) {
isValid = validator.isValidRange(
- Integer.parseInt(flowListEntry
+ flowListEntry
.getAsJsonPrimitive(
VtnServiceJsonConsts.IPPROTO)
- .getAsString().trim()),
+ .getAsString().trim(),
VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_255);
}
&& flowListEntry.getAsJsonPrimitive(
VtnServiceJsonConsts.IPDSCP).getAsString() != null) {
isValid = validator.isValidRange(
- Integer.parseInt(flowListEntry
+ flowListEntry
.getAsJsonPrimitive(
VtnServiceJsonConsts.IPDSCP)
- .getAsString().trim()),
+ .getAsString().trim(),
VtnServiceJsonConsts.VAL_0,
VtnServiceJsonConsts.VAL_63);
}
&& flowListEntry.getAsJsonPrimitive(
VtnServiceJsonConsts.L4DSTPORT).getAsString() != null) {
isValid = validator.isValidRange(
- Integer.parseInt(flowListEntry
+ flowListEntry
.getAsJsonPrimitive(
VtnServiceJsonConsts.L4DSTPORT)
- .getAsString().trim()),
+ .getAsString().trim(),
VtnServiceJsonConsts.VAL_0,
VtnServiceJsonConsts.VAL_65535);
}
VtnServiceJsonConsts.L4DSTENDPORT)
.getAsString() != null) {
isValid = validator.isValidRange(
- Integer.parseInt(flowListEntry
+ flowListEntry
.getAsJsonPrimitive(
VtnServiceJsonConsts.L4DSTENDPORT)
- .getAsString().trim()),
+ .getAsString().trim(),
VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_65535);
}
&& flowListEntry.getAsJsonPrimitive(
VtnServiceJsonConsts.L4SRCPORT).getAsString() != null) {
isValid = validator.isValidRange(
- Integer.parseInt(flowListEntry
+ flowListEntry
.getAsJsonPrimitive(
VtnServiceJsonConsts.L4SRCPORT)
- .getAsString().trim()),
+ .getAsString().trim(),
VtnServiceJsonConsts.VAL_0,
VtnServiceJsonConsts.VAL_65535);
VtnServiceJsonConsts.L4SRCENDPORT)
.getAsString() != null) {
isValid = validator.isValidRange(
- Integer.parseInt(flowListEntry
+ flowListEntry
.getAsJsonPrimitive(
VtnServiceJsonConsts.L4SRCENDPORT)
- .getAsString().trim()),
+ .getAsString().trim(),
VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_65535);
}
&& flowListEntry.getAsJsonPrimitive(
VtnServiceJsonConsts.ICMPTYPENUM).getAsString() != null) {
isValid = validator.isValidRange(
- Integer.parseInt(flowListEntry
+ flowListEntry
.getAsJsonPrimitive(
VtnServiceJsonConsts.ICMPTYPENUM)
- .getAsString().trim()),
+ .getAsString().trim(),
VtnServiceJsonConsts.VAL_0,
VtnServiceJsonConsts.VAL_255);
}
&& flowListEntry.getAsJsonPrimitive(
VtnServiceJsonConsts.ICMPCODENUM).getAsString() != null) {
isValid = validator.isValidRange(
- Integer.parseInt(flowListEntry
+ flowListEntry
.getAsJsonPrimitive(
VtnServiceJsonConsts.ICMPCODENUM)
- .getAsString().trim()),
+ .getAsString().trim(),
VtnServiceJsonConsts.VAL_0,
VtnServiceJsonConsts.VAL_255);
}
.getAsString() != null) {
isValid = validator
.isValidRange(
- Integer.parseInt(flowListEntry
+ flowListEntry
.getAsJsonPrimitive(
VtnServiceJsonConsts.IPV6ICMPTYPENUM)
- .getAsString().trim()),
+ .getAsString().trim(),
VtnServiceJsonConsts.VAL_0,
VtnServiceJsonConsts.VAL_255);
}
.getAsString() != null) {
isValid = validator
.isValidRange(
- Integer.parseInt(flowListEntry
+ flowListEntry
.getAsJsonPrimitive(
VtnServiceJsonConsts.IPV6ICMPCODENUM)
- .getAsString().trim()),
+ .getAsString().trim(),
VtnServiceJsonConsts.VAL_0,
VtnServiceJsonConsts.VAL_255);
}
if (flowListEntry.has(VtnServiceJsonConsts.SEQNUM)
&& flowListEntry.getAsJsonPrimitive(
VtnServiceJsonConsts.SEQNUM).getAsString() != null) {
- isValid = validator.isValidRange(Integer.parseInt(flowListEntry
+ isValid = validator.isValidRange(flowListEntry
.getAsJsonPrimitive(VtnServiceJsonConsts.SEQNUM)
- .getAsString().trim()), VtnServiceJsonConsts.VAL_1,
+ .getAsString().trim(), VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_65535);
}
if (isValid) {
} else if (isValid && requestBody != null
&& VtnServiceConsts.POST.equals(method)) {
isValid = validatePost(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
} else if (isValid && requestBody != null
&& VtnServiceConsts.PUT.equals(method)) {
isValid = validatePut(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
}
if (isValid) {
// validation for mandatory keys: netmask
- setInvalidParameter(VtnServiceJsonConsts.NETMASK);
- if (ipaddr.has(VtnServiceJsonConsts.NETMASK)
+ setInvalidParameter(VtnServiceJsonConsts.PREFIX);
+ if (ipaddr.has(VtnServiceJsonConsts.PREFIX)
&& ipaddr.getAsJsonPrimitive(
- VtnServiceJsonConsts.NETMASK).getAsString() != null) {
+ VtnServiceJsonConsts.PREFIX).getAsString() != null) {
isValid = validator.isValidRange(
- Integer.parseInt(ipaddr
+ ipaddr
.getAsJsonPrimitive(
- VtnServiceJsonConsts.NETMASK)
- .getAsString().trim()),
+ VtnServiceJsonConsts.PREFIX)
+ .getAsString().trim(),
VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_30);
} else {
import org.opendaylight.vtn.javaapi.resources.logical.DhcpRelayInterfacesResource;
import org.opendaylight.vtn.javaapi.resources.logical.VBridgeInterfaceResource;
import org.opendaylight.vtn.javaapi.resources.logical.VBridgeInterfacesResource;
+import org.opendaylight.vtn.javaapi.resources.logical.VBypassInterfaceResource;
+import org.opendaylight.vtn.javaapi.resources.logical.VBypassInterfacesResource;
import org.opendaylight.vtn.javaapi.resources.logical.VTepInterfaceResource;
import org.opendaylight.vtn.javaapi.resources.logical.VTepInterfacesResource;
import org.opendaylight.vtn.javaapi.resources.logical.VTunnelInterfaceResource;
import org.opendaylight.vtn.javaapi.resources.logical.VTunnelInterfacesResource;
-import org.opendaylight.vtn.javaapi.resources.logical.VUnknownInterfaceResource;
-import org.opendaylight.vtn.javaapi.resources.logical.VUnknownInterfacesResource;
import org.opendaylight.vtn.javaapi.validation.CommonValidator;
import org.opendaylight.vtn.javaapi.validation.VtnServiceValidator;
boolean isValid = false;
setInvalidParameter(VtnServiceJsonConsts.URI
+ VtnServiceJsonConsts.VTNNAME);
- if (resource instanceof VUnknownInterfaceResource
- && ((VUnknownInterfaceResource) resource).getVtnName() != null
- && !((VUnknownInterfaceResource) resource).getVtnName().trim()
+ if (resource instanceof VBypassInterfaceResource
+ && ((VBypassInterfaceResource) resource).getVtnName() != null
+ && !((VBypassInterfaceResource) resource).getVtnName().trim()
.isEmpty()) {
isValid = validator.isValidMaxLengthAlphaNum(
- ((VUnknownInterfaceResource) resource).getVtnName().trim(),
+ ((VBypassInterfaceResource) resource).getVtnName().trim(),
VtnServiceJsonConsts.LEN_31);
if (isValid) {
setInvalidParameter(VtnServiceJsonConsts.URI
- + VtnServiceJsonConsts.VUKNAME);
- if (((VUnknownInterfaceResource) resource).getVukName() != null
- && !((VUnknownInterfaceResource) resource).getVukName()
+ + VtnServiceJsonConsts.VBYPASS_NAME);
+ if (((VBypassInterfaceResource) resource).getVbypassName() != null
+ && !((VBypassInterfaceResource) resource).getVbypassName()
.trim().isEmpty()) {
isValid = validator.isValidMaxLengthAlphaNum(
- ((VUnknownInterfaceResource) resource).getVukName()
+ ((VBypassInterfaceResource) resource).getVbypassName()
.trim(), VtnServiceJsonConsts.LEN_31);
} else {
isValid = false;
if (isValid) {
setInvalidParameter(VtnServiceJsonConsts.URI
+ VtnServiceJsonConsts.IFNAME);
- if (((VUnknownInterfaceResource) resource).getIfName() != null
- && !((VUnknownInterfaceResource) resource).getIfName()
+ if (((VBypassInterfaceResource) resource).getIfName() != null
+ && !((VBypassInterfaceResource) resource).getIfName()
.trim().isEmpty()) {
isValid = validator.isValidMaxLengthAlphaNum(
- ((VUnknownInterfaceResource) resource).getIfName()
+ ((VBypassInterfaceResource) resource).getIfName()
.trim(), VtnServiceJsonConsts.LEN_31);
} else {
isValid = false;
}
}
setListOpFlag(false);
- } else if (resource instanceof VUnknownInterfacesResource
- && ((VUnknownInterfacesResource) resource).getVtnName() != null
- && !((VUnknownInterfacesResource) resource).getVtnName().trim()
+ } else if (resource instanceof VBypassInterfacesResource
+ && ((VBypassInterfacesResource) resource).getVtnName() != null
+ && !((VBypassInterfacesResource) resource).getVtnName().trim()
.isEmpty()) {
isValid = validator
.isValidMaxLengthAlphaNum(
- ((VUnknownInterfacesResource) resource)
+ ((VBypassInterfacesResource) resource)
.getVtnName().trim(),
VtnServiceJsonConsts.LEN_31);
if (isValid) {
setInvalidParameter(VtnServiceJsonConsts.URI
- + VtnServiceJsonConsts.VUKNAME);
- if (((VUnknownInterfacesResource) resource).getVukName() != null
- && !((VUnknownInterfacesResource) resource)
- .getVukName().trim().isEmpty()) {
+ + VtnServiceJsonConsts.VBYPASS_NAME);
+ if (((VBypassInterfacesResource) resource).getVbypassName() != null
+ && !((VBypassInterfacesResource) resource)
+ .getVbypassName().trim().isEmpty()) {
isValid = validator.isValidMaxLengthAlphaNum(
- ((VUnknownInterfacesResource) resource)
- .getVukName().trim(),
+ ((VBypassInterfacesResource) resource)
+ .getVbypassName().trim(),
VtnServiceJsonConsts.LEN_31);
} else {
isValid = false;
} else if (isValid && requestBody != null
&& VtnServiceConsts.PUT.equals(method)) {
isValid = validatePut(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
&& VtnServiceConsts.GET.equals(method)) {
isValid = ValidateGet(requestBody);
updateOpParameterForList(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
// Throws exception if validation fails
&& VtnServiceConsts.GET.equals(method)) {
isValid = validateGet(requestBody);
updateOpParameterForList(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
&& VtnServiceConsts.GET.equals(method)) {
isValid = validateGet(requestBody);
updateOpParameterForList(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
import org.opendaylight.vtn.javaapi.ipc.enums.UncJavaAPIErrorCode;
import org.opendaylight.vtn.javaapi.resources.AbstractResource;
import org.opendaylight.vtn.javaapi.resources.logical.PortMapResource;
+import org.opendaylight.vtn.javaapi.resources.logical.VTepInterfacePortMapResource;
+import org.opendaylight.vtn.javaapi.resources.logical.VTunnelInterfacePortMapResource;
import org.opendaylight.vtn.javaapi.validation.CommonValidator;
import org.opendaylight.vtn.javaapi.validation.VtnServiceValidator;
}
setListOpFlag(false);
}
+ else if (resource instanceof VTunnelInterfacePortMapResource
+ && ((VTunnelInterfacePortMapResource) resource).getVtnName() != null
+ && !((VTunnelInterfacePortMapResource) resource).getVtnName().trim().isEmpty()) {
+ isValid = validator.isValidMaxLengthAlphaNum(
+ ((VTunnelInterfacePortMapResource) resource).getVtnName().trim(),
+ VtnServiceJsonConsts.LEN_31);
+ if (isValid){
+ setInvalidParameter(VtnServiceJsonConsts.URI + VtnServiceJsonConsts.VTUNNELNAME);
+ if(((VTunnelInterfacePortMapResource) resource).getVtunnelName() != null
+ && !((VTunnelInterfacePortMapResource) resource).getVtunnelName().trim().isEmpty()) {
+ isValid = validator.isValidMaxLengthAlphaNum(
+ ((VTunnelInterfacePortMapResource) resource).getVtunnelName().trim(),
+ VtnServiceJsonConsts.LEN_31);
+ } else {
+ isValid = false;
+ }
+ }
+ if (isValid){
+ setInvalidParameter(VtnServiceJsonConsts.URI + VtnServiceJsonConsts.IFNAME);
+ if(((VTunnelInterfacePortMapResource) resource).getIfName() != null
+ && !((VTunnelInterfacePortMapResource) resource).getIfName().trim().isEmpty()) {
+ isValid = validator.isValidMaxLengthAlphaNum(
+ ((VTunnelInterfacePortMapResource) resource).getIfName().trim(),
+ VtnServiceJsonConsts.LEN_31);
+ } else {
+ isValid = false;
+ }
+ }
+ setListOpFlag(false);
+ }else if (resource instanceof VTepInterfacePortMapResource
+ && ((VTepInterfacePortMapResource) resource).getVtnName() != null
+ && !((VTepInterfacePortMapResource) resource).getVtnName().trim().isEmpty()) {
+ isValid = validator.isValidMaxLengthAlphaNum(
+ ((VTepInterfacePortMapResource) resource).getVtnName().trim(),
+ VtnServiceJsonConsts.LEN_31);
+ if (isValid){
+ setInvalidParameter(VtnServiceJsonConsts.URI + VtnServiceJsonConsts.VTEPNAME);
+ if(((VTepInterfacePortMapResource) resource).getVtepName() != null
+ && !((VTepInterfacePortMapResource) resource).getVtepName().trim().isEmpty()) {
+ isValid = validator.isValidMaxLengthAlphaNum(
+ ((VTepInterfacePortMapResource) resource).getVtepName().trim(),
+ VtnServiceJsonConsts.LEN_31);
+ } else {
+ isValid = false;
+ }
+ }
+ if (isValid){
+ setInvalidParameter(VtnServiceJsonConsts.URI + VtnServiceJsonConsts.IFNAME);
+ if(((VTepInterfacePortMapResource) resource).getIfName() != null
+ && !((VTepInterfacePortMapResource) resource).getIfName().trim().isEmpty()) {
+ isValid = validator.isValidMaxLengthAlphaNum(
+ ((VTepInterfacePortMapResource) resource).getIfName().trim(),
+ VtnServiceJsonConsts.LEN_31);
+ } else {
+ isValid = false;
+ }
+ }
+ setListOpFlag(false);
+ }
LOG.trace("Completed PortMapResourceValidator#validateUri()");
return isValid;
}
} else if (isValid && requestBody != null
&& VtnServiceConsts.PUT.equals(method)) {
isValid = validatePut(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
portMap.getAsJsonPrimitive(
VtnServiceJsonConsts.LOGICAL_PORT_ID)
.getAsString().trim(),
- VtnServiceJsonConsts.LEN_255);
+ VtnServiceJsonConsts.LEN_319);
}
if (isValid) {
// validation for key: vlan_id
VtnServiceJsonConsts.VLANID).getAsString() != null) {
isValid = validator.isValidRange(portMap
.getAsJsonPrimitive(VtnServiceJsonConsts.VLANID)
- .getAsInt(), VtnServiceJsonConsts.VAL_1,
+ .getAsString().trim(), VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_4095);
}
}
final String portMp = portMap
.getAsJsonPrimitive(VtnServiceJsonConsts.TAGGED)
.getAsString().trim();
+ if (VtnServiceConsts.EMPTY_STRING.equals(portMp)) {
+ return true;
+ }
isValid = portMp
.equalsIgnoreCase(VtnServiceJsonConsts.TRUE)
|| portMp
isValid = validator.isValidIpV4(staticIpRoute[0])
&& validator.isValidIpV4(staticIpRoute[1])
&& validator
- .isValidRange(Integer.parseInt(staticIpRoute[2]),
- VtnServiceJsonConsts.VAL_1,
- VtnServiceJsonConsts.VAL_30)
+ .isValidRange(staticIpRoute[2],
+ VtnServiceJsonConsts.VAL_0,
+ VtnServiceJsonConsts.VAL_32)
&& (staticIpRoute.length > 3 ? validator
.isValidMaxLengthAlphaNum(staticIpRoute[3],
VtnServiceJsonConsts.LEN_31) : true);
&& VtnServiceConsts.GET.equals(method)) {
isValid = validateGet(requestBody, isListOpFlag());
updateOpParameterForList(requestBody);
- } else if (isValid && requestBody != null
- && VtnServiceConsts.PUT.equals(method)) {
- isValid = validatePut(requestBody);
+// } else if (isValid && requestBody != null
+// && VtnServiceConsts.PUT.equals(method)) {
+// isValid = validatePut(requestBody);
} else if (isValid && requestBody != null
&& VtnServiceConsts.POST.equals(method)) {
isValid = validatePost(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
.getAsString().trim());
}
- // validation for key: netmask(mandatory)
+ // validation for key: prefix(mandatory)
if (isValid) {
- setInvalidParameter(VtnServiceJsonConsts.NETMASK);
- if (staticIp.has(VtnServiceJsonConsts.NETMASK)
+ setInvalidParameter(VtnServiceJsonConsts.PREFIX);
+ if (staticIp.has(VtnServiceJsonConsts.PREFIX)
&& staticIp.getAsJsonPrimitive(
- VtnServiceJsonConsts.NETMASK).getAsString() != null) {
+ VtnServiceJsonConsts.PREFIX).getAsString() != null) {
isValid = validator.isValidRange(
- Integer.parseInt(staticIp
+ staticIp
.getAsJsonPrimitive(
- VtnServiceJsonConsts.NETMASK)
- .getAsString().trim()),
- VtnServiceJsonConsts.VAL_1,
- VtnServiceJsonConsts.VAL_30);
+ VtnServiceJsonConsts.PREFIX)
+ .getAsString().trim(),
+ VtnServiceJsonConsts.VAL_0,
+ VtnServiceJsonConsts.VAL_32);
} else {
isValid = false;
}
}
// validation for key: nmg_name(mandatory)
- if (isValid) {
- setInvalidParameter(VtnServiceJsonConsts.NMGNAME);
- if (staticIp.has(VtnServiceJsonConsts.NMGNAME)
- && staticIp.getAsJsonPrimitive(
- VtnServiceJsonConsts.NMGNAME).getAsString() != null
- && !staticIp
- .getAsJsonPrimitive(
- VtnServiceJsonConsts.NMGNAME)
- .getAsString().trim().isEmpty()) {
- isValid = validator.isValidMaxLengthAlphaNum(staticIp
- .getAsJsonPrimitive(VtnServiceJsonConsts.NMGNAME)
- .getAsString().trim(), VtnServiceJsonConsts.LEN_31);
- }
- }
+// if (isValid) {
+// setInvalidParameter(VtnServiceJsonConsts.NMGNAME);
+// if (staticIp.has(VtnServiceJsonConsts.NMGNAME)
+// && staticIp.getAsJsonPrimitive(
+// VtnServiceJsonConsts.NMGNAME).getAsString() != null
+// && !staticIp
+// .getAsJsonPrimitive(
+// VtnServiceJsonConsts.NMGNAME)
+// .getAsString().trim().isEmpty()) {
+// isValid = validator.isValidMaxLengthAlphaNum(staticIp
+// .getAsJsonPrimitive(VtnServiceJsonConsts.NMGNAME)
+// .getAsString().trim(), VtnServiceJsonConsts.LEN_31);
+// }
+// }
if (isValid) {
isValid = validatePut(requestBody);
}
.getAsJsonPrimitive(VtnServiceJsonConsts.NEXTHOPADDR)
.getAsString().trim());
}
- // validation for key:groupmetric(optional)
- if (isValid) {
- setInvalidParameter(VtnServiceJsonConsts.GROUPMETRIC);
- if (staticIp.has(VtnServiceJsonConsts.GROUPMETRIC)
- && staticIp.getAsJsonPrimitive(
- VtnServiceJsonConsts.GROUPMETRIC).getAsString() != null) {
- isValid = validator.isValidRange(
- Integer.parseInt(staticIp
- .getAsJsonPrimitive(
- VtnServiceJsonConsts.GROUPMETRIC)
- .getAsString().trim()),
- VtnServiceJsonConsts.VAL_1,
- VtnServiceJsonConsts.VAL_65535);
- }
- }
}
LOG.trace("Complete StaticIpRouteResourceValidator#validatePut()");
return isValid;
}
-
}
* VrouterInterfaceFlowFilterEntry API.
*/
public class VBridgeFlowFilterEntriesResourceValidator extends
-VtnServiceValidator {
+ VtnServiceValidator {
private static final Logger LOG = Logger
.getLogger(VBridgeFlowFilterEntriesResourceValidator.class
.getName());
if (resource instanceof VBridgeFlowFilterEntriesResource
&& ((VBridgeFlowFilterEntriesResource) resource).getVtnName() != null
&& !((VBridgeFlowFilterEntriesResource) resource).getVtnName()
- .trim().isEmpty()) {
+ .trim().isEmpty()) {
isValid = validator.isValidMaxLengthAlphaNum(
((VBridgeFlowFilterEntriesResource) resource).getVtnName()
.trim(), VtnServiceJsonConsts.LEN_31);
} else if (isValid && requestBody != null
&& VtnServiceConsts.POST.equals(method)) {
isValid = validatePost(requestBody);
- if(validator.getInvalidParameter()!=null){
+ if (validator.getInvalidParameter() != null) {
setInvalidParameter(validator.getInvalidParameter());
}
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
- if(validator.getInvalidParameter()!=null){
+ if (validator.getInvalidParameter() != null) {
setInvalidParameter(validator.getInvalidParameter());
}
LOG.error("Inside catch:NumberFormatException");
isValid = false;
} catch (final ClassCastException e) {
- if(validator.getInvalidParameter()!=null){
+ if (validator.getInvalidParameter() != null) {
setInvalidParameter(validator.getInvalidParameter());
}
LOG.error("Inside catch:ClassCastException");
if (ffEntry.has(VtnServiceJsonConsts.SEQNUM)
&& ffEntry.getAsJsonPrimitive(VtnServiceJsonConsts.SEQNUM)
.getAsString() != null) {
- isValid = validator.isValidRange(Integer.parseInt(ffEntry
+ isValid = validator.isValidRange(ffEntry
.getAsJsonPrimitive(VtnServiceJsonConsts.SEQNUM)
- .getAsString().trim()), VtnServiceJsonConsts.VAL_1,
+ .getAsString().trim(), VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_65535);
}
if (isValid) {
.getSeqnum().trim().isEmpty()) {
isValid = validator
.isValidRange(
- Integer.parseInt(((VBridgeFlowFilterEntryResource) resource)
- .getSeqnum().trim()),
+ ((VBridgeFlowFilterEntryResource) resource)
+ .getSeqnum().trim(),
VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_65535);
} else {
.getSeqnum().trim().isEmpty()) {
isValid = validator
.isValidRange(
- Integer.parseInt(((VBridgeInterfaceFlowFilterEntryResource) resource)
- .getSeqnum().trim()),
+ ((VBridgeInterfaceFlowFilterEntryResource) resource)
+ .getSeqnum().trim(),
VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_65535);
} else {
.getSeqnum().trim().isEmpty()) {
isValid = validator
.isValidRange(
- Integer.parseInt(((VRouterInterfaceFlowFilterEntryResource) resource)
- .getSeqnum().trim()),
+ ((VRouterInterfaceFlowFilterEntryResource) resource)
+ .getSeqnum().trim(),
VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_65535);
} else {
if(validator.getInvalidParameter()!=null){
setInvalidParameter(validator.getInvalidParameter());
}
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
private boolean validateGet(final JsonObject requestBody) {
LOG.trace("Start VBridgeFlowFilterEntryResourceValidator#validateGet()");
boolean isValid = false;
- // validation for key: controller_id(mandatory)
- setInvalidParameter(VtnServiceJsonConsts.CONTROLLERID);
- if (requestBody.has(VtnServiceJsonConsts.CONTROLLERID)
- && requestBody.getAsJsonPrimitive(
- VtnServiceJsonConsts.CONTROLLERID).getAsString() != null) {
- isValid = validator.isValidMaxLengthAlphaNum(requestBody
- .getAsJsonPrimitive(VtnServiceJsonConsts.CONTROLLERID)
- .getAsString().trim(), VtnServiceJsonConsts.LEN_31);
- }
+// // validation for key: controller_id(mandatory)
+// setInvalidParameter(VtnServiceJsonConsts.CONTROLLERID);
+// if (requestBody.has(VtnServiceJsonConsts.CONTROLLERID)
+// && requestBody.getAsJsonPrimitive(
+// VtnServiceJsonConsts.CONTROLLERID).getAsString() != null) {
+// isValid = validator.isValidMaxLengthAlphaNum(requestBody
+// .getAsJsonPrimitive(VtnServiceJsonConsts.CONTROLLERID)
+// .getAsString().trim(), VtnServiceJsonConsts.LEN_31);
+// }
+
// validation for key: targetdb(optional)
- if (isValid) {
+// if (isValid) {
setInvalidParameter(VtnServiceJsonConsts.TARGETDB);
isValid = validator.isValidRequestDB(requestBody);
- }
+// }
+
// validation for key: op(optinal)
if (isValid) {
setInvalidParameter(VtnServiceJsonConsts.OP);
requestBody.addProperty(VtnServiceJsonConsts.OP,
VtnServiceJsonConsts.NORMAL);
}
-
}
LOG.trace("Complete VBridgeFlowFilterEntryResourceValidator#validateGet()");
} else if (isValid && requestBody != null
&& VtnServiceConsts.POST.equals(method)) {
isValid = validatePost(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
/*
* Copyright (c) 2012-2013 NEC Corporation
* All rights reserved.
- *
+ *
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this
* distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
import org.opendaylight.vtn.javaapi.exception.VtnServiceException;
import org.opendaylight.vtn.javaapi.ipc.enums.UncJavaAPIErrorCode;
import org.opendaylight.vtn.javaapi.resources.AbstractResource;
-import org.opendaylight.vtn.javaapi.resources.logical.VUnknownResource;
-import org.opendaylight.vtn.javaapi.resources.logical.VUnknownsResource;
+import org.opendaylight.vtn.javaapi.resources.logical.VBypassResource;
+import org.opendaylight.vtn.javaapi.resources.logical.VBypassesResource;
import org.opendaylight.vtn.javaapi.validation.CommonValidator;
import org.opendaylight.vtn.javaapi.validation.VtnServiceValidator;
/**
- * The Class VUnknownResourceValidator validates request Json object for
- * Vunknown API.
+ * The Class VBypassResourceValidator validates request Json object for
+ * VBypass API.
*/
-public class VUnknownResourceValidator extends VtnServiceValidator {
+public class VBypassResourceValidator extends VtnServiceValidator {
private static final Logger LOG = Logger
- .getLogger(VUnknownResourceValidator.class.getName());
+ .getLogger(VBypassResourceValidator.class.getName());
private final AbstractResource resource;
final CommonValidator validator = new CommonValidator();
/**
- * Instantiates a new v unknown resource validator.
+ * Instantiates a new VBypass resource validator.
*
* @param resource
* the instance of AbstractResource
*/
- public VUnknownResourceValidator(final AbstractResource resource) {
+ public VBypassResourceValidator(final AbstractResource resource) {
this.resource = resource;
}
/**
- * Validate uri parameters for VUnknownRsource
+ * Validate uri parameters for VBypassResource
*
* @return true, if successful
*/
@Override
public boolean validateUri() {
- LOG.trace("Start VUnknownResourceValidator#validateUri()");
+ LOG.trace("Start VBypassResourceValidator#validateUri()");
boolean isValid = false;
setInvalidParameter(VtnServiceJsonConsts.URI
+ VtnServiceJsonConsts.VTNNAME);
- if (resource instanceof VUnknownResource
- && ((VUnknownResource) resource).getVtnName() != null
- && !((VUnknownResource) resource).getVtnName().trim().isEmpty()) {
+ if (resource instanceof VBypassResource
+ && ((VBypassResource) resource).getVtnName() != null
+ && !((VBypassResource) resource).getVtnName().trim().isEmpty()) {
isValid = validator.isValidMaxLengthAlphaNum(
- ((VUnknownResource) resource).getVtnName().trim(),
+ ((VBypassResource) resource).getVtnName().trim(),
VtnServiceJsonConsts.LEN_31);
if (isValid) {
setInvalidParameter(VtnServiceJsonConsts.URI
- + VtnServiceJsonConsts.VUKNAME);
- if (((VUnknownResource) resource).getVukName() != null
- && !((VUnknownResource) resource).getVukName().trim()
- .isEmpty()) {
+ + VtnServiceJsonConsts.VBYPASS_NAME);
+ if (((VBypassResource) resource).getVbypassName() != null
+ && !((VBypassResource) resource).getVbypassName().trim()
+ .isEmpty()) {
isValid = validator.isValidMaxLengthAlphaNum(
- ((VUnknownResource) resource).getVukName().trim(),
+ ((VBypassResource) resource).getVbypassName().trim(),
VtnServiceJsonConsts.LEN_31);
} else {
isValid = false;
}
}
setListOpFlag(false);
- } else if (resource instanceof VUnknownsResource
- && ((VUnknownsResource) resource).getVtnName() != null
- && !((VUnknownsResource) resource).getVtnName().trim()
- .isEmpty()) {
+ } else if (resource instanceof VBypassesResource
+ && ((VBypassesResource) resource).getVtnName() != null
+ && !((VBypassesResource) resource).getVtnName().trim()
+ .isEmpty()) {
isValid = validator.isValidMaxLengthAlphaNum(
- ((VUnknownsResource) resource).getVtnName().trim(),
+ ((VBypassesResource) resource).getVtnName().trim(),
VtnServiceJsonConsts.LEN_31);
setListOpFlag(true);
}
- LOG.trace("Complete VUnknownResourceValidator#validateUri()");
+ LOG.trace("Complete VBypassResourceValidator#validateUri()");
return isValid;
}
/**
- * Validate request Json object for get, put and post method of VUnknown API
+ * Validate request Json object for get, put and post method of VBypass API
*/
@Override
public void validate(final String method, final JsonObject requestBody)
throws VtnServiceException {
- LOG.trace("Start VUnknownResourceValidator#validate()");
+ LOG.trace("Start VBypassResourceValidator#validate()");
LOG.info("Validating request for " + method
- + " of VUnknownResourceValidator");
+ + " of VBypassResourceValidator");
boolean isValid = false;
try {
isValid = validateUri();
} else if (isValid && requestBody != null
&& VtnServiceConsts.POST.equals(method)) {
isValid = validatePost(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
UncJavaAPIErrorCode.VALIDATION_ERROR.getErrorMessage());
}
LOG.info("Validation successful");
- LOG.trace("Complete VUnknownResourceValidator#validate()");
+ LOG.trace("Complete VBypassResourceValidator#validate()");
}
/**
- * Validate post request Json object for VUnknownRsource.
+ * Validate post request Json object for VBypassResource.
*
* @param requestBody
* the request Json object
*/
private boolean validatePost(final JsonObject requestBody)
throws VtnServiceException {
- LOG.trace("Start VUnknownResourceValidator#validatePost()");
+ LOG.trace("Start VBypassResourceValidator#validatePost()");
boolean isValid = false;
- setInvalidParameter(VtnServiceJsonConsts.VUNKNOWN);
- if (requestBody.has(VtnServiceJsonConsts.VUNKNOWN)
- && requestBody.get(VtnServiceJsonConsts.VUNKNOWN)
- .isJsonObject()) {
- final JsonObject vUnknown = requestBody
- .getAsJsonObject(VtnServiceJsonConsts.VUNKNOWN);
- // validation for key: vuk_name(mandatory)
- setInvalidParameter(VtnServiceJsonConsts.VUKNAME);
- if (vUnknown.has(VtnServiceJsonConsts.VUKNAME)
- && vUnknown
- .getAsJsonPrimitive(VtnServiceJsonConsts.VUKNAME)
- .getAsString() != null) {
- isValid = validator.isValidMaxLengthAlphaNum(vUnknown
- .getAsJsonPrimitive(VtnServiceJsonConsts.VUKNAME)
+ setInvalidParameter(VtnServiceJsonConsts.VBYPASS);
+ if (requestBody.has(VtnServiceJsonConsts.VBYPASS)
+ && requestBody.get(VtnServiceJsonConsts.VBYPASS)
+ .isJsonObject()) {
+ final JsonObject vBypass = requestBody
+ .getAsJsonObject(VtnServiceJsonConsts.VBYPASS);
+ // validation for key: VBYPASS_NAME(mandatory)
+ setInvalidParameter(VtnServiceJsonConsts.VBYPASS_NAME);
+ if (vBypass.has(VtnServiceJsonConsts.VBYPASS_NAME)
+ && vBypass
+ .getAsJsonPrimitive(VtnServiceJsonConsts.VBYPASS_NAME)
+ .getAsString() != null) {
+ isValid = validator.isValidMaxLengthAlphaNum(vBypass
+ .getAsJsonPrimitive(VtnServiceJsonConsts.VBYPASS_NAME)
.getAsString().trim(), VtnServiceJsonConsts.LEN_31);
}
if (isValid) {
- isValid = commonValidations(isValid, vUnknown);
+ isValid = commonValidations(isValid, vBypass);
}
// validation for key: DOMAINID(mandatory)
if (isValid) {
setInvalidParameter(VtnServiceJsonConsts.DOMAINID);
- if (vUnknown.has(VtnServiceJsonConsts.DOMAINID)
- && vUnknown.getAsJsonPrimitive(
+ if (vBypass.has(VtnServiceJsonConsts.DOMAINID)
+ && vBypass.getAsJsonPrimitive(
VtnServiceJsonConsts.DOMAINID).getAsString() != null) {
- isValid = validator.isValidDomainId(vUnknown
+ isValid = validator.isValidDomainId(vBypass
.getAsJsonPrimitive(VtnServiceJsonConsts.DOMAINID)
.getAsString().trim(), VtnServiceJsonConsts.LEN_31);
} else {
}
}
}
- LOG.trace("Complete VUnknownResourceValidator#validatePost()");
+ LOG.trace("Complete VBypassResourceValidator#validatePost()");
return isValid;
}
/**
* @param isValid
- * @param vUnknown
+ * @param vBypass
* @return
*/
- private boolean commonValidations(boolean isValid, final JsonObject vUnknown) {
- LOG.trace("Start VUnknownResourceValidator#commonValidations()");
+ private boolean commonValidations(boolean isValid, final JsonObject vBypass) {
+ LOG.trace("Start VBypassResourceValidator#commonValidations()");
// validation for key: description
setInvalidParameter(VtnServiceJsonConsts.DESCRIPTION);
- if (vUnknown.has(VtnServiceJsonConsts.DESCRIPTION)
- && vUnknown.getAsJsonPrimitive(
+ if (vBypass.has(VtnServiceJsonConsts.DESCRIPTION)
+ && vBypass.getAsJsonPrimitive(
VtnServiceJsonConsts.DESCRIPTION).getAsString() != null
- && !vUnknown
+ && !vBypass
.getAsJsonPrimitive(
VtnServiceJsonConsts.DESCRIPTION)
.getAsString().trim().isEmpty()) {
isValid = validator.isValidMaxLength(
- vUnknown.getAsJsonPrimitive(
+ vBypass.getAsJsonPrimitive(
VtnServiceJsonConsts.DESCRIPTION)
.getAsString().trim(),
VtnServiceJsonConsts.LEN_127);
// validation for key: type
if (isValid) {
setInvalidParameter(VtnServiceJsonConsts.TYPE);
- if (vUnknown.has(VtnServiceJsonConsts.TYPE)
- && vUnknown.getAsJsonPrimitive(
+ if (vBypass.has(VtnServiceJsonConsts.TYPE)
+ && vBypass.getAsJsonPrimitive(
VtnServiceJsonConsts.TYPE).getAsString() != null) {
- isValid = validType(vUnknown
+ isValid = validType(vBypass
.getAsJsonPrimitive(VtnServiceJsonConsts.TYPE)
.getAsString().trim());
}
// validation for key: controller_id
if (isValid) {
setInvalidParameter(VtnServiceJsonConsts.CONTROLLERID);
- if (vUnknown.has(VtnServiceJsonConsts.CONTROLLERID)
- && vUnknown.getAsJsonPrimitive(
+ if (vBypass.has(VtnServiceJsonConsts.CONTROLLERID)
+ && vBypass.getAsJsonPrimitive(
VtnServiceJsonConsts.CONTROLLERID)
.getAsString() != null
- && !vUnknown
+ && !vBypass
.getAsJsonPrimitive(
VtnServiceJsonConsts.CONTROLLERID)
.getAsString().trim().isEmpty()) {
isValid = validator.isValidMaxLengthAlphaNum(
- vUnknown.getAsJsonPrimitive(
+ vBypass.getAsJsonPrimitive(
VtnServiceJsonConsts.CONTROLLERID)
.getAsString().trim(),
VtnServiceJsonConsts.LEN_31);
}
}
- LOG.trace("Complete VUnknownResourceValidator#commonValidations()");
+ LOG.trace("Complete VBypassResourceValidator#commonValidations()");
return isValid;
}
/**
- * Validate put request Json object for VUnknownRsource
+ * Validate put request Json object for VBypassResource
*
* @param requestBody
* the request Json object
*/
private boolean validatePut(final JsonObject requestBody)
throws VtnServiceException {
- LOG.trace("Start VUnknownResourceValidator#validatePut()");
+ LOG.trace("Start VBypassResourceValidator#validatePut()");
boolean isValid = false;
- setInvalidParameter(VtnServiceJsonConsts.VUNKNOWN);
- if (requestBody.has(VtnServiceJsonConsts.VUNKNOWN)
- && requestBody.get(VtnServiceJsonConsts.VUNKNOWN)
- .isJsonObject()) {
+ setInvalidParameter(VtnServiceJsonConsts.VBYPASS);
+ if (requestBody.has(VtnServiceJsonConsts.VBYPASS)
+ && requestBody.get(VtnServiceJsonConsts.VBYPASS)
+ .isJsonObject()) {
isValid = true;
- final JsonObject vUnknown = requestBody
- .getAsJsonObject(VtnServiceJsonConsts.VUNKNOWN);
- isValid = commonValidations(isValid, vUnknown);
+ final JsonObject vBypass = requestBody
+ .getAsJsonObject(VtnServiceJsonConsts.VBYPASS);
+ isValid = commonValidations(isValid, vBypass);
// validation for key: DOMAINID(optional)
if (isValid) {
setInvalidParameter(VtnServiceJsonConsts.DOMAINID);
- if (vUnknown.has(VtnServiceJsonConsts.DOMAINID)
- && vUnknown.getAsJsonPrimitive(
+ if (vBypass.has(VtnServiceJsonConsts.DOMAINID)
+ && vBypass.getAsJsonPrimitive(
VtnServiceJsonConsts.DOMAINID).getAsString() != null
- && !vUnknown
+ && !vBypass
.getAsJsonPrimitive(
VtnServiceJsonConsts.DOMAINID)
- .getAsString().trim().isEmpty()) {
- isValid = validator.isValidDomainId(vUnknown
+ .getAsString().trim().isEmpty()) {
+ isValid = validator.isValidDomainId(vBypass
.getAsJsonPrimitive(VtnServiceJsonConsts.DOMAINID)
.getAsString().trim(), VtnServiceJsonConsts.LEN_31);
}
}
}
- LOG.trace("Complete VUnknownResourceValidator#validatePut()");
+ LOG.trace("Complete VBypassResourceValidator#validatePut()");
return isValid;
}
* @return
*/
private boolean validType(final String type) {
+ if (VtnServiceConsts.EMPTY_STRING.equals(type)) {
+ return true;
+ }
return VtnServiceJsonConsts.ROUTER.equalsIgnoreCase(type)
|| VtnServiceJsonConsts.BRIDGE.equalsIgnoreCase(type);
}
boolean isValid;
if (vlamMapId.contains(VtnServiceJsonConsts.LPID
+ VtnServiceJsonConsts.VLANMAPIDSEPERATOR)) {
- isValid = validator.isValidMaxLength(
- vlamMapId.substring(5),
+ isValid = validator.isValidMaxLength(vlamMapId.substring(5),
VtnServiceJsonConsts.LEN_319);
} else if (vlamMapId.contains(VtnServiceJsonConsts.NOLPID)) {
isValid = true;
} else if (isValid && requestBody != null
&& VtnServiceConsts.POST.equals(method)) {
isValid = validatePost(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
.getAsString().trim().isEmpty()) {
isValid = validator.isValidRange(vLanMap
.getAsJsonPrimitive(VtnServiceJsonConsts.VLANID)
- .getAsInt(), VtnServiceJsonConsts.VAL_1,
+ .getAsString().trim(), VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_4095);
} else {
isValid = false;
} else if (isValid && requestBody != null
&& VtnServiceConsts.POST.equals(method)) {
isValid = validatePost(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
.isValidRange(
boundary.getAsJsonPrimitive(
VtnServiceJsonConsts.VLANID)
- .getAsInt(),
+ .getAsString().trim(),
VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_4095);
} else {
} else {
isValid = false;
}
- } else {
+ }/* else {
isValid = false;
- }
+ }*/
if (isValid) {
setInvalidParameter(VtnServiceJsonConsts.BOUNDARYID);
if (boundary.has(VtnServiceJsonConsts.BOUNDARYID)
.getAsString().trim().isEmpty();
}
}
- } else {
+ }/* else {
isValid = false;
- }
+ }*/
}
LOG.trace("Complete VLinkResourceValidator#commonValidation()");
return isValid;
} else if (isValid && requestBody != null
&& VtnServiceConsts.POST.equals(method)) {
isValid = validatePost(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
}
// validation for key: netmask(optional)
if (isValid) {
- setInvalidParameter(VtnServiceJsonConsts.NETMASK);
- if (vRouterInterface.has(VtnServiceJsonConsts.NETMASK)) {
+ setInvalidParameter(VtnServiceJsonConsts.PREFIX);
+ if (vRouterInterface.has(VtnServiceJsonConsts.PREFIX)) {
isValid = validator.isValidRange(
- Integer.parseInt(vRouterInterface
+ vRouterInterface
.getAsJsonPrimitive(
- VtnServiceJsonConsts.NETMASK)
- .getAsString().trim()),
+ VtnServiceJsonConsts.PREFIX)
+ .getAsString().trim(),
VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_30);
}
} else if (isValid && requestBody != null
&& VtnServiceConsts.POST.equals(method)) {
isValid = validatePost(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
} else if (isValid && requestBody != null
&& VtnServiceConsts.POST.equals(method)) {
isValid = validatePost(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
}
}
}
- }// updated in bug fixing
- else {
- isValid = false;
}
}
LOG.trace("Complete VTepGroupResourceValidator#validatePut()");
} else if (isValid && requestBody != null
&& VtnServiceConsts.POST.equals(method)) {
isValid = validatePost(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
} else if (isValid && requestBody != null
&& VtnServiceConsts.PUT.equals(method)) {
isValid = validatePut(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
setInvalidParameter(VtnServiceJsonConsts.LABEL);
if (isValid && vTunnel.has(VtnServiceJsonConsts.LABEL)) {
isValid = validator.isValidRange(
- Long.parseLong(vTunnel
- .getAsJsonPrimitive(
- VtnServiceJsonConsts.LABEL)
- .getAsString().trim()),
- VtnServiceJsonConsts.LONG_VAL_0,
- VtnServiceJsonConsts.LONG_VAL_4294967295);
+ vTunnel.getAsJsonPrimitive(VtnServiceJsonConsts.LABEL)
+ .getAsString().trim(),
+ VtnServiceJsonConsts.LONG_VAL_0,
+ VtnServiceJsonConsts.LONG_VAL_4294967295);
}
}
LOG.trace("complete VTunnelResourceValidator#commonValidations()");
} else if (isValid && requestBody != null
&& VtnServiceConsts.PUT.equals(method)) {
isValid = validatePut(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
.getAsString().trim(), VtnServiceJsonConsts.LEN_31);
}
if (isValid) {
- isValid= validatePut(requestBody);
+ isValid = validatePut(requestBody);
}
}
LOG.trace("Complete VtnResourceValidator#validatePost()");
&& VtnServiceConsts.GET.equals(method)) {
isValid = validateGet(requestBody);
updateOpParameterForList(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
.getAsString().trim().isEmpty()) {
isValid = validator.isValidRange(requestBody
.getAsJsonPrimitive(VtnServiceJsonConsts.VLANID)
- .getAsInt(), VtnServiceJsonConsts.VAL_1,
+ .getAsString().trim(), VtnServiceJsonConsts.VAL_1,
VtnServiceJsonConsts.VAL_4095);
} else {
isValid = false;
} else {
isValid = false;
}
- } else {
- //isValid = false;
}
}
// validation for key: op
if (isValid && requestBody != null
&& VtnServiceConsts.PUT.equals(method)) {
isValid = validatePut(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
isValid = validator.isValidAlarmRange(new BigInteger(requestBody
.getAsJsonPrimitive(VtnServiceJsonConsts.ALARMNO)
.getAsString().trim()), VtnServiceJsonConsts.BIG_VAL0,
- VtnServiceJsonConsts.BIG_VAL_18446744073709551615);
+ VtnServiceJsonConsts.BIG_VAL_9999999999999999999);
} else {
isValid = false;
}
} else if (isValid && requestBody != null
&& VtnServiceConsts.PUT.equals(method)) {
isValid = validatePut(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
} else if (isValid && requestBody != null
&& VtnServiceConsts.PUT.equals(method)) {
isValid = validatePut(requestBody);
- } else {
+ }else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
&& VtnServiceConsts.GET.equals(method)) {
isValid = validateGet(requestBody, isListOpFlag());
updateOpParameterForList(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
} else if (isValid && requestBody != null
&& VtnServiceConsts.PUT.equals(method)) {
isValid = validatePut(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
// Throws exception if validation fails
.getAsJsonPrimitive(VtnServiceJsonConsts.TYPE)
.getAsString().trim();
isValid = type
- .equalsIgnoreCase(VtnServiceJsonConsts.NORMAL)
- || type.equalsIgnoreCase(VtnServiceJsonConsts.DEFAULT);
+ .equalsIgnoreCase(VtnServiceJsonConsts.NORMAL);
} else {
isValid = false;
}
LOG.trace("Complete DomainResourceValidator#validateGet()");
return isValid;
}
-}
+}
\ No newline at end of file
&& VtnServiceConsts.GET.equals(method)) {
isValid = validateGet(requestBody, isListOpFlag());
updateOpParameterForList(requestBody);
- } else {
+ }else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
&& VtnServiceConsts.GET.equals(method)) {
isValid = validateGet(requestBody, isListOpFlag());
updateOpParameterForList(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
&& VtnServiceConsts.GET.equals(method)) {
isValid = validateGet(requestBody, isListOpFlag());
updateOpParameterForList(requestBody);
- } else {
+ } else if (isValid) {
+ setInvalidParameter(VtnServiceConsts.INCORRECT_METHOD_INVOCATION);
isValid = false;
}
} catch (final NumberFormatException e) {
LOG.trace("Complete SwitchResourceValidator#ValidateGet");
return isValid;
}
-}
+}
\ No newline at end of file
# distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
#
-# Specify whether it is done via Proxy or not
-# 0: No PROXY, 1: Via PROXY
-PROXY_OPT= {0/1}
-
-# Set the source IPv4 address
-# All IPv4 addresses are allowed in case * is set.
-# In case IPv4 address is specified then specified IPv4 address allows the access of corresponding HTTP method.
-# Prioritization is done in case ALL is specified.
-#ALL = *
-#GET = *
-#POST = *
-#DELETE = *
-#PUT = *
-
-#Example:
-PROXY=1
-ALL = {10.0.0.1, 10.0.0.2, 10.0.0.3,127.0.0.1}
-GET = {10.0.1.1}
-POST = {10.0.1.2, 10.0.1.3}
-DELETE = {10.0.1.4}
-PUT = {10.0.1.5}
+#Set the source IPv4 address
+#All IPv4 addresses are allowed in case * is set.
+#In case IPv4 address is specified then specified IPv4 address allows the access of corresponding HTTP method.
+#Prioritization is done in case ALL is specified.
+ALL = *
+GET = *
+POST = *
+DELETE = *
+PUT = *
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.json.JSONException;
import org.json.JSONObject;
+import com.google.gson.JsonObject;
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.webapi.enums.ApplicationConstants;
import org.opendaylight.vtn.webapi.exception.VtnServiceWebAPIException;
if(null != serviceErrorJSON){
try {
final String responseString = DataConverter.getConvertedResponse(serviceErrorJSON, VtnServiceCommonUtil.getContentType(request.getRequestURI()));
- response.setStatus(Integer.valueOf(serviceErrorJSON.getJSONObject(ApplicationConstants.ERROR).getString(ApplicationConstants.ERR_CODE)));
- response.getWriter().write(responseString);
+ setResponseHeader(request, response, responseString);
} catch (IOException e) {
LOG.error("Servlet writer failed error "+e.getMessage());
} catch (NumberFormatException e) {
LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
serviceErrorJSON = VtnServiceWebUtil.prepareErrResponseJson(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
- } catch (JSONException e) {
- LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
- serviceErrorJSON = VtnServiceWebUtil.prepareErrResponseJson(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
} catch (VtnServiceWebAPIException e) {
LOG.error(VtnServiceCommonUtil.logErrorDetails(e.getErrorCode()));
serviceErrorJSON = VtnServiceWebUtil.prepareErrResponseJson(e.getErrorCode(), e.getErrorDescription());
try {
vtnServiceWebAPIHandler = new VtnServiceWebAPIHandler();
final String responseString = vtnServiceWebAPIHandler.get(request);
- response.setContentType(VtnServiceCommonUtil.getContentType(request.getRequestURI()));
- response.getWriter().write(responseString);
+ setResponseHeader(request, response, responseString);
LOG.trace("HTTP GET method finished processing.");
}catch (IOException e) {
LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
if(null != serviceErrorJSON){
try {
final String responseString = DataConverter.getConvertedResponse(serviceErrorJSON, VtnServiceCommonUtil.getContentType(request.getRequestURI()));
- response.setStatus(Integer.valueOf(serviceErrorJSON.getJSONObject(ApplicationConstants.ERROR).getString(ApplicationConstants.ERR_CODE)));
- response.getWriter().write(responseString);
+ setResponseHeader(request, response, responseString);
} catch (IOException e) {
LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
} catch (NumberFormatException e) {
LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
serviceErrorJSON = VtnServiceWebUtil.prepareErrResponseJson(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
- } catch (JSONException e) {
- LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
- serviceErrorJSON = VtnServiceWebUtil.prepareErrResponseJson(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
} catch (VtnServiceWebAPIException e) {
LOG.error(VtnServiceCommonUtil.logErrorDetails(e.getErrorCode()));
serviceErrorJSON = VtnServiceWebUtil.prepareErrResponseJson(e.getErrorCode(), e.getErrorDescription());
JSONObject serviceErrorJSON = null;
try{
vtnServiceWebAPIHandler = new VtnServiceWebAPIHandler();
- final String responseString = vtnServiceWebAPIHandler.post(request);
- response.setContentType(request.getRequestURI());
- response.getWriter().write(responseString);
+ final String responseString = vtnServiceWebAPIHandler.post(request);
+ setResponseHeader(request, response, responseString);
LOG.trace("HTTP POST method finished processing.");
}
catch (IOException e) {
if(null != serviceErrorJSON){
try {
final String responseString = DataConverter.getConvertedResponse(serviceErrorJSON, VtnServiceCommonUtil.getContentType(request.getRequestURI()));
- response.setStatus(Integer.valueOf(serviceErrorJSON.getJSONObject(ApplicationConstants.ERROR).getString(ApplicationConstants.ERR_CODE)));
- response.getWriter().write(responseString);
+ setResponseHeader(request, response, responseString);
} catch (IOException e) {
LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
} catch (NumberFormatException e) {
LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
serviceErrorJSON = VtnServiceWebUtil.prepareErrResponseJson(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
- } catch (JSONException e) {
- LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
- serviceErrorJSON = VtnServiceWebUtil.prepareErrResponseJson(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
} catch (VtnServiceWebAPIException e) {
LOG.error(VtnServiceCommonUtil.logErrorDetails(e.getErrorCode()));
serviceErrorJSON = VtnServiceWebUtil.prepareErrResponseJson(e.getErrorCode(), e.getErrorDescription());
}
}
- }
-
-
+ }
}
/**
try{
vtnServiceWebAPIHandler = new VtnServiceWebAPIHandler();
final String responseString = vtnServiceWebAPIHandler.put(request);
- response.setContentType(request.getRequestURI());
- response.getWriter().write(responseString);
+ setResponseHeader(request, response, responseString);
LOG.trace("HTTP PUT method finished processing.");
}
catch (IOException e) {
if(null != serviceErrorJSON){
try {
final String responseString = DataConverter.getConvertedResponse(serviceErrorJSON, VtnServiceCommonUtil.getContentType(request.getRequestURI()));
- response.setStatus(Integer.valueOf(serviceErrorJSON.getJSONObject(ApplicationConstants.ERROR).getString(ApplicationConstants.ERR_CODE)));
- response.getWriter().write(responseString);
+ setResponseHeader(request, response, responseString);
} catch (IOException e) {
LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
} catch (NumberFormatException e) {
LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
serviceErrorJSON = VtnServiceWebUtil.prepareErrResponseJson(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
- } catch (JSONException e) {
- LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
- serviceErrorJSON = VtnServiceWebUtil.prepareErrResponseJson(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
} catch (VtnServiceWebAPIException e) {
LOG.error(VtnServiceCommonUtil.logErrorDetails(e.getErrorCode()));
serviceErrorJSON = VtnServiceWebUtil.prepareErrResponseJson(e.getErrorCode(), e.getErrorDescription());
try{
vtnServiceWebAPIHandler = new VtnServiceWebAPIHandler();
final String responseString = vtnServiceWebAPIHandler.delete(request);
- response.setContentType(request.getRequestURI());
- response.getWriter().write(responseString);
+ setResponseHeader(request, response, responseString);
LOG.trace("HTTP DELETE method finished processing.");
}
catch (IOException e) {
if(null != serviceErrorJSON){
try {
final String responseString = DataConverter.getConvertedResponse(serviceErrorJSON, VtnServiceCommonUtil.getContentType(request.getRequestURI()));
- response.setStatus(Integer.valueOf(serviceErrorJSON.getJSONObject(ApplicationConstants.ERROR).getString(ApplicationConstants.ERR_CODE)));
- response.getWriter().write(responseString);
+ setResponseHeader(request, response, responseString);
} catch (IOException e) {
LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
} catch (NumberFormatException e) {
LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
serviceErrorJSON = VtnServiceWebUtil.prepareErrResponseJson(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
- } catch (JSONException e) {
- LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
- serviceErrorJSON = VtnServiceWebUtil.prepareErrResponseJson(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
} catch (VtnServiceWebAPIException e) {
LOG.error(VtnServiceCommonUtil.logErrorDetails(e.getErrorCode()));
serviceErrorJSON = VtnServiceWebUtil.prepareErrResponseJson(e.getErrorCode(), e.getErrorDescription());
LOG.trace("Servlet instance is now eligible for garbage collection.");
super.destroy();
}
-
+
+ /**
+ * Set response header information
+ *
+ * @param request the request
+ * @param response the response
+ * @see HttpServlet#doPut(HttpServletRequest, HttpServletResponse)
+ */
+ private void setResponseHeader(final HttpServletRequest request,final HttpServletResponse response, final String responseString) throws IOException, VtnServiceWebAPIException {
+ LOG.debug("Start setResponseHeader");
+ response.setContentType(VtnServiceCommonUtil.getContentType(request.getRequestURI()));
+ response.setCharacterEncoding(ApplicationConstants.CHAR_ENCODING);
+ if(null != responseString && !responseString.isEmpty()){
+ // Set response status in cases where returned response in not success from JavaAPI
+ JsonObject responseJson = DataConverter.getConvertedRequestObject(responseString, VtnServiceCommonUtil.getContentType(request.getRequestURI()));
+ if(responseJson.has(ApplicationConstants.ERROR)){
+ LOG.debug("Set HTTP response status : " + responseJson.get(ApplicationConstants.ERROR).getAsJsonObject().get(ApplicationConstants.ERR_CODE).getAsInt());
+ response.setStatus(responseJson.get(ApplicationConstants.ERROR).getAsJsonObject().get(ApplicationConstants.ERR_CODE).getAsInt());
+ } else {
+ response.getWriter().write(responseString);
+ }
+ }
+ LOG.debug("Complete setResponseHeader");
+ }
}
/**
* Instantiates a new application constants.
*/
- private ApplicationConstants() {//private default constructor so that no one can make the object of this class
+ private ApplicationConstants() {
}
/** The Constant ZERO. */
public static final int ZERO = 0;
+ /** The Constant FOUR for XML length. */
+ public static final int FOUR = 4;
+
+ /** The Constant FIVE for JSON length. */
+ public static final int FIVE = 5;
+
/** The Constant TIMEOUT. */
public static final String TIMEOUT = "timeout";
/** The Constant ACCESS_PROPERTY_PATH. */
public static final String ACCESS_PROPERTY_PATH = "/access.properties";
-
- /** The Constant PWD_PROPERTY_PATH. */
- public static final String PWD_PROPERTY_PATH = "/pwd.properties";
-
+
/** The Constant WEBAPI_CONF_PROPERTY_PATH. */
public static final String WEBAPI_CONF_PROPERTY_PATH = "/webapiconf.properties";
/** The Constant DEFAULT_ERROR_DESCRIPTION. */
public final static String DEFAULT_ERROR_DESCRIPTION = "internal server error";
-
- /** The Constant PROPERTY_NOT_FOUND_ERROR_DESC. */
- public static final String PROPERTY_NOT_FOUND_ERROR_DESC = "Property Read Error";
-
+
/** The Constant OPERATION. */
public static final String OPERATION = "operation";
/** The Constant ONE. */
public static final int ONE = 1;
- /* Http Error codes and error descriptions */
+ /* HTTP Error codes and error descriptions */
//error codes
/** The Constant VTN_ERRORCODE_PREFIX. */
public static final String VTN_ERRORCODE_PREFIX = "vtns_err_";
/** The Constant METHOD_NOT_ALLOWED_ERROR. */
public static final String METHOD_NOT_ALLOWED_ERROR = "405";
-
- /** The Constant MISSING_HEADER_INFO. */
- public static final String MISSING_HEADER_INFO = "410";
-
+
/** The Constant INTERNAL_SERVER_ERROR. */
public static final String INTERNAL_SERVER_ERROR = "500";
-
- /** The Constant PROPERTY_NOT_FOUND_ERROR. */
- public static final String PROPERTY_NOT_FOUND_ERROR = "501";
-
- /** The Constant PROPERTY_FILE_READ_ERROR. */
- public static final String PROPERTY_FILE_READ_ERROR = "502";
-
- /** The Constant SESSION_CREATION_FAILED. */
- public static final String SESSION_CREATION_FAILED = "510";
-
- /** The Constant AQUIRE_CONFIGURATION_FAILED. */
- public static final String AQUIRE_CONFIGURATION_FAILED = "511";
-
- /** The Constant RELEASE_SESSION_FAILED. */
- public static final String RELEASE_SESSION_FAILED = "512";
-
- /** The Constant RELEASE_CONFIGURATION_FAILED. */
- public static final String RELEASE_CONFIGURATION_FAILED = "513";
-
- /** The Constant MD5_ALGO_ERROR. */
- public static final String MD5_ALGO_ERROR = "411";
-
- /** The Constant UNSUPPORTED_PASSWORD_STRING_FORMAT_ERROR. */
- public static final String UNSUPPORTED_PASSWORD_STRING_FORMAT_ERROR = "412";
-
-
- /** The Constant PROXY_OPT. */
- public static final String PROXY_OPT = "PROXY";
-
+
/** The Constant ACCESS_ALL. */
public static final String ACCESS_ALL = "ALL";
/** The Constant CONFIG_ID_STR. */
public static final String CONFIG_ID_STR = "config_id";
- /** The Constant MD5. */
- public static final String MD5 = "MD5";
-
/** The Constant ENCODE_UTF8_FORMAT. */
public static final String ENCODE_UTF8_FORMAT = "UTF-8";
public static final String SESSIONSTR = "/sessions/";
+ public static final String ALARMSTR = "/unc/alarms";
+
+ public static final String UNC_WEB_ADMIN = "UNC_WEB_ADMIN";
+
+ public static final String UNC_WEB_OPER = "UNC_WEB_OPER";
+
+ public static final String CANDIDATE = "candidate";
+
+ public static final String OPERATION_ABORT = "abort";
+
+ public static final String WILD_CARD_STAR = "*";
+
+ public static final String CHAR_ENCODING = "UTF-8";
+
+ public static final String XSLT_FILE = "org/opendaylight/vtn/webapi/utils/tranformXslt.xslt";
+
+ public static final String LINE_FEED = "[\\n\\r]";
+
+ public static final String XML_STANDALONE = "yes";
+
+ public static final char LESS_THAN = '<';
+
+ public static final char GREATER_THAN = '>';
+
+ public static final String NULL_STRING = "null";
+
+ public static final String DUMMY_JSON = "{\"dummy\" : {}}";
+
+ public static final String DUMMY_XML = " dummy=\"\"";
+
+ public static final String EMPTY_JSON = "{}";
+
+ public static final String EMPTY_JSON_ARRAY = "[]";
+
+ public static final String vtepgroup = "vtepgroup";
+
+ public static final String member_vteps = "member_vteps";
+
+ public static final String member_vtep = "member_vtep";
+
+ public static final String ipaddrs = "ipaddrs";
+
+ public static final String ipv6addr = "ipv6addrs";
+
+ public static final String DOT_ZERO = "0";
}
ACQUIRE_RELEASE_MONITORING_PATH("/configuration/readlock"),
/** The COMMI t_ configuration. */
- COMMIT_CONFIGURATION("/configuration");
+ COMMIT_CONFIGURATION("/configuration"),
+ /** The ABORT_ configuration. */
+ ABORT_CONFIGURATION("/configuration/candidate");
/** The path. */
private String path;
//acquire session id
resource.setPath(ResourcePathEnum.SESSION_PATH.getPath());
if(resource.post(sessionJson) != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.SESSION_CREATION_FAILED,VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.SESSION_CREATION_FAILED));
+ isReadlock=false;
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
}
sessionId = VtnServiceCommonUtil.getSessionFromJson(resource.getInfo());
//acquire monitoring mode
resource.setSessionID(sessionId);
if(resource.put(VtnServiceWebUtil.prepareAquireReadLockJSON()) != RESPONSE_SUCCESS){
isReadlock=false;
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.AQUIRE_CONFIGURATION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.AQUIRE_CONFIGURATION_FAILED));
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
}
//send the api request json
resource.setPath(resourcePath);
LOG.debug("JAVA API returned error code #"+status);
if(status != RESPONSE_SUCCESS){
responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ throw new VtnServiceWebAPIException();
}
responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
LOG.debug("JAVA API returned response # "+responseStr);
}catch (VtnServiceWebAPIException vtnException) {
exceptionStatus = true;
- LOG.error(VtnServiceCommonUtil.logErrorDetails(vtnException.getErrorCode()));
}catch (RuntimeException exception) {
exceptionStatus = true;
LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
resource.setPath(ResourcePathEnum.ACQUIRE_RELEASE_MONITORING_PATH.getPath());
resource.setSessionID(sessionId);
if(resource.delete() != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.RELEASE_CONFIGURATION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.RELEASE_CONFIGURATION_FAILED));
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
}
}
if(sessionId != ApplicationConstants.ZERO){
resource.setPath(ResourcePathEnum.RELEASE_SESSION.getPath()+ sessionId);
resource.setSessionID(sessionId);
if(resource.delete() != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.RELEASE_SESSION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.RELEASE_SESSION_FAILED));
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
}
}
responseJSON = new JSONObject(responseStr);
//acquire session id
resource.setPath(ResourcePathEnum.SESSION_PATH.getPath());
if(resource.post(sessionJson) != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.SESSION_CREATION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.SESSION_CREATION_FAILED));
+ isReadlock=false;
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
}
sessionId = VtnServiceCommonUtil.getSessionFromJson(resource.getInfo());
//acquire monitoring mode
resource.setSessionID(sessionId);
if(resource.put(VtnServiceWebUtil.prepareAquireReadLockJSON()) != RESPONSE_SUCCESS){
isReadlock = false;
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.AQUIRE_CONFIGURATION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.AQUIRE_CONFIGURATION_FAILED));
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
}
//send the api request json
resource.setPath(resourcePath);
LOG.debug("JAVA API returned error code #"+status);
if(status != RESPONSE_SUCCESS){
responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ throw new VtnServiceWebAPIException();
}
responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
LOG.debug("JAVA API returned response # "+responseStr);
}catch (VtnServiceWebAPIException vtnException) {
exceptionStatus = true;
- LOG.error(VtnServiceCommonUtil.logErrorDetails(vtnException.getErrorCode()));
}catch (RuntimeException exception) {
exceptionStatus = true;
LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
resource.setPath(ResourcePathEnum.ACQUIRE_RELEASE_MONITORING_PATH.getPath());
resource.setSessionID(sessionId);
if(resource.delete() != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.RELEASE_CONFIGURATION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.RELEASE_CONFIGURATION_FAILED));
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
}
}
resource.setPath(ResourcePathEnum.RELEASE_SESSION.getPath()+ sessionId);
resource.setSessionID(sessionId);
if(resource.delete() != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.RELEASE_SESSION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.RELEASE_SESSION_FAILED));
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
}
}
responseJSON = new JSONObject(responseStr);
long configId = 0;
final RestResource resource = new RestResource();
try{
- LOG.debug("acquiring session id and config mode from java API");
- //acquire session id
- resource.setPath(ResourcePathEnum.SESSION_PATH.getPath());
- if(resource.post(sessionJson) != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.SESSION_CREATION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.SESSION_CREATION_FAILED));
- }
- sessionId = VtnServiceCommonUtil.getSessionFromJson(resource.getInfo());
- //acquire configure mode
- resource.setPath(ResourcePathEnum.ACQUIRE_CONFIG_PATH.getPath());
- resource.setSessionID(sessionId);
- if(resource.post(VtnServiceWebUtil.prepareAquireConfigJSON()) != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.AQUIRE_CONFIGURATION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.AQUIRE_CONFIGURATION_FAILED));
- }
- configId = VtnServiceCommonUtil.getConfigIdFromJson(resource.getInfo());
- //send the api request json
- resource.setPath(resourcePath);
- resource.setSessionID(sessionId);
- resource.setConfigID(configId);
- LOG.debug("Request object passing to JAVA API #"+reqObject);
- final int status = resource.post(reqObject);
- LOG.debug("JAVA API returned error code #"+status);
- if(status != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
- }
- responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
- LOG.debug("JAVA API returned response # "+responseStr);
- resource.setPath(ResourcePathEnum.COMMIT_CONFIGURATION.getPath());
- resource.setSessionID(sessionId);
- resource.setConfigID(configId);
- final int commitStatus = resource.put(VtnServiceWebUtil.prepareConfigCommitOrSaveJSON(ApplicationConstants.OPERATION_COMMIT));
- if (commitStatus != RESPONSE_SUCCESS) {
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.INTERNAL_SERVER_ERROR,
- ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
+ LOG.debug("acquiring session id and config mode from java API");
+ //acquire session id
+ resource.setPath(ResourcePathEnum.SESSION_PATH.getPath());
+ if(resource.post(sessionJson) != RESPONSE_SUCCESS){
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
+ }
+ sessionId = VtnServiceCommonUtil.getSessionFromJson(resource.getInfo());
+ //acquire configure mode
+ resource.setPath(ResourcePathEnum.ACQUIRE_CONFIG_PATH.getPath());
+ resource.setSessionID(sessionId);
+ if(resource.post(VtnServiceWebUtil.prepareAquireConfigJSON()) != RESPONSE_SUCCESS){
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
+ }
+ configId = VtnServiceCommonUtil.getConfigIdFromJson(resource.getInfo());
+ // Abort operation to clear candidate DB
+ responseStr = performAbort(sessionId, configId, resource);
+ //send the api request json
+ resource.setPath(resourcePath);
+ resource.setSessionID(sessionId);
+ resource.setConfigID(configId);
+ LOG.debug("Request object passing to JAVA API #"+reqObject);
+ final int status = resource.post(reqObject);
+ LOG.debug("JAVA API returned error code #"+status);
+ if(status != RESPONSE_SUCCESS){
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();//to save the below steps execution
+ }
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ LOG.debug("JAVA API returned response # "+responseStr);
+ //responseStr = performCommit(sessionId, configId, resource);
+ String commitResponse = performCommit(sessionId, configId, resource);
+ if(commitResponse != null){
+ responseStr = commitResponse;
}
}catch (VtnServiceWebAPIException vtnException) {
exceptionStatus = true;
- LOG.error(VtnServiceCommonUtil.logErrorDetails(vtnException.getErrorCode()));
}catch (RuntimeException exception) {
exceptionStatus = true;
LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
throw new VtnServiceWebAPIException(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
}
- finally{
- try{
- if(configId != ApplicationConstants.ZERO){
- //release monitoring mode
- resource.setPath(ResourcePathEnum.RELEASE_CONFIGURATION.getPath()+configId);
- resource.setSessionID(sessionId);
- resource.setConfigID(configId);
- if(resource.delete() != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.RELEASE_CONFIGURATION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.RELEASE_CONFIGURATION_FAILED));
+ finally{
+ try{
+ if(configId != ApplicationConstants.ZERO){
+ //release monitoring mode
+ resource.setPath(ResourcePathEnum.RELEASE_CONFIGURATION.getPath()+configId);
+ resource.setSessionID(sessionId);
+ resource.setConfigID(configId);
+ if(resource.delete() != RESPONSE_SUCCESS){
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
+ }
}
- }
- if(sessionId != ApplicationConstants.ZERO){
- //release session
- resource.setPath(ResourcePathEnum.RELEASE_SESSION.getPath()+ sessionId);
- resource.setSessionID(sessionId);
- if(resource.delete() != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.RELEASE_SESSION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.RELEASE_SESSION_FAILED));
+ if(sessionId != ApplicationConstants.ZERO){
+ //release session
+ resource.setPath(ResourcePathEnum.RELEASE_SESSION.getPath()+ sessionId);
+ resource.setSessionID(sessionId);
+ if(resource.delete() != RESPONSE_SUCCESS){
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
+ }
}
+
+ if(null == responseStr && !exceptionStatus){
+ responseJSON = VtnServiceWebUtil.prepareErrResponseJson(ApplicationConstants.STATUS_OK, ApplicationConstants.STATUS_SUCCESS);
+ }else{
+ responseJSON = new JSONObject(responseStr);
+ }
+ }catch (Exception exception) {
+ LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
+ throw new VtnServiceWebAPIException(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
}
-
- if(null == responseStr && !exceptionStatus){
- responseJSON = VtnServiceWebUtil.prepareErrResponseJson(ApplicationConstants.STATUS_OK, ApplicationConstants.STATUS_SUCCESS);
- }else{
- responseJSON = VtnServiceWebUtil.prepareErrResponseJson(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
- }
- }catch (Exception exception) {
- exceptionStatus = true;
- LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
- throw new VtnServiceWebAPIException(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
+
+
}
-
-
- }
- return responseJSON;
+ return responseJSON;
}
+
/**
* Put.This method will be required when we have to update any component using Java API.
* This method will work in the following sequence-
//acquire session id
resource.setPath(ResourcePathEnum.SESSION_PATH.getPath());
if(resource.post(sessionJson) != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.SESSION_CREATION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.SESSION_CREATION_FAILED));
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
}
sessionId = VtnServiceCommonUtil.getSessionFromJson(resource.getInfo());
//acquire configure mode
resource.setPath(ResourcePathEnum.ACQUIRE_CONFIG_PATH.getPath());
resource.setSessionID(sessionId);
if(resource.post(VtnServiceWebUtil.prepareAquireConfigJSON()) != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.AQUIRE_CONFIGURATION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.AQUIRE_CONFIGURATION_FAILED));
- }
- configId = VtnServiceCommonUtil.getConfigIdFromJson(resource.getInfo());
- //send the api request json
- resource.setPath(resourcePath);
- resource.setConfigID(configId);
- resource.setSessionID(sessionId);
- LOG.debug("Request object passing to JAVA API #"+reqObject);
- final int status = resource.put(reqObject);
- LOG.debug("JAVA API returned error code #"+status);
- if(status != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
- }
- responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
- LOG.debug("JAVA API returned response # "+responseStr);
- resource.setPath(ResourcePathEnum.COMMIT_CONFIGURATION.getPath());
- resource.setSessionID(sessionId);
- resource.setConfigID(configId);
- final int commitStatus = resource.put(VtnServiceWebUtil.prepareConfigCommitOrSaveJSON(ApplicationConstants.OPERATION_COMMIT));
- if (commitStatus != RESPONSE_SUCCESS) {
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.INTERNAL_SERVER_ERROR,
- ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
- }
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
+ }
+ configId = VtnServiceCommonUtil.getConfigIdFromJson(resource.getInfo());
+ responseStr = performAbort(sessionId, configId, resource);
+ //send the api request json
+ resource.setPath(resourcePath);
+ resource.setConfigID(configId);
+ resource.setSessionID(sessionId);
+ LOG.debug("Request object passing to JAVA API #"+reqObject);
+ final int status = resource.put(reqObject);
+ LOG.debug("JAVA API returned error code #"+status);
+ if(status != RESPONSE_SUCCESS){
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();//to save the below steps execution
+ }
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ LOG.debug("JAVA API returned response # "+responseStr);
+ //responseStr = performCommit(sessionId, configId, resource);
+ String commitResponse = performCommit(sessionId, configId, resource);
+ if(commitResponse != null){
+ responseStr = commitResponse;
+ }
}catch (VtnServiceWebAPIException vtnException) {
exceptionStatus = true;
- LOG.error(VtnServiceCommonUtil.logErrorDetails(vtnException.getErrorCode()));
}catch (RuntimeException exception) {
exceptionStatus = true;
LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
resource.setSessionID(sessionId);
resource.setConfigID(configId);
if(resource.delete() != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.RELEASE_CONFIGURATION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.RELEASE_CONFIGURATION_FAILED));
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
}
}
if(sessionId != ApplicationConstants.ZERO){
resource.setPath(ResourcePathEnum.RELEASE_SESSION.getPath()+ sessionId);
resource.setSessionID(sessionId);
if(resource.delete() != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.RELEASE_SESSION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.RELEASE_SESSION_FAILED));
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
}
}
-
+
if(null == responseStr && !exceptionStatus){
responseJSON = VtnServiceWebUtil.prepareErrResponseJson(ApplicationConstants.STATUS_OK, ApplicationConstants.STATUS_SUCCESS);
}else{
- responseJSON = VtnServiceWebUtil.prepareErrResponseJson(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
+ responseJSON = new JSONObject(responseStr);
}
}catch (Exception exception) {
exceptionStatus = true;
LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
throw new VtnServiceWebAPIException(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
}
-
+
}
return responseJSON;
}
-
+
/**
* Delete.This method will be required when we have to delete any component using Java API.
* This method will work in the following sequence-
//acquire session id
resource.setPath(ResourcePathEnum.SESSION_PATH.getPath());
if(resource.post(sessionJson) != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.SESSION_CREATION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.SESSION_CREATION_FAILED));
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
}
sessionId = VtnServiceCommonUtil.getSessionFromJson(resource.getInfo());
//acquire configure mode
resource.setPath(ResourcePathEnum.ACQUIRE_CONFIG_PATH.getPath());
resource.setSessionID(sessionId);
if(resource.post(VtnServiceWebUtil.prepareAquireConfigJSON()) != RESPONSE_SUCCESS){
- throw new VtnServiceWebAPIException(ApplicationConstants.AQUIRE_CONFIGURATION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.AQUIRE_CONFIGURATION_FAILED));
- }
- configId = VtnServiceCommonUtil.getConfigIdFromJson(resource.getInfo());
- //send the api request json
- resource.setPath(resourcePath);
- resource.setConfigID(configId);
- resource.setSessionID(sessionId);
- LOG.debug("Request object passing to JAVA API #"+reqObject);
- final int status = resource.delete(reqObject);
- LOG.debug("JAVA API returned error code #"+status);
- if(status != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
- }
- responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
- LOG.debug("JAVA API returned response # "+responseStr);
- resource.setPath(ResourcePathEnum.COMMIT_CONFIGURATION.getPath());
- resource.setSessionID(sessionId);
- resource.setConfigID(configId);
- final int commitStatus = resource.put(VtnServiceWebUtil.prepareConfigCommitOrSaveJSON(ApplicationConstants.OPERATION_COMMIT));
- if (commitStatus != RESPONSE_SUCCESS) {
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.INTERNAL_SERVER_ERROR,
- ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
- }
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
+ }
+ configId = VtnServiceCommonUtil.getConfigIdFromJson(resource.getInfo());
+ responseStr = performAbort(sessionId, configId, resource);
+ //send the api request json
+ resource.setPath(resourcePath);
+ resource.setConfigID(configId);
+ resource.setSessionID(sessionId);
+ LOG.debug("Request object passing to JAVA API #"+reqObject);
+ final int status = resource.delete(reqObject);
+ LOG.debug("JAVA API returned error code #"+status);
+ if(status != RESPONSE_SUCCESS){
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();//to save the below steps execution
+ }
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ LOG.debug("JAVA API returned response # "+responseStr);
+ //responseStr = performCommit(sessionId, configId, resource);
+ String commitResponse = performCommit(sessionId, configId, resource);
+ if(commitResponse != null){
+ responseStr = commitResponse;
+ }
}catch (VtnServiceWebAPIException vtnException) {
exceptionStatus = true;
- LOG.error(VtnServiceCommonUtil.logErrorDetails(vtnException.getErrorCode()));
}catch (Exception exception) {
exceptionStatus = true;
LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
resource.setSessionID(sessionId);
resource.setConfigID(configId);
if(resource.delete() != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.RELEASE_CONFIGURATION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.RELEASE_CONFIGURATION_FAILED));
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
}
}
if(sessionId != ApplicationConstants.ZERO){
resource.setPath(ResourcePathEnum.RELEASE_SESSION.getPath()+ sessionId);
resource.setSessionID(sessionId);
if(resource.delete() != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.RELEASE_SESSION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.RELEASE_SESSION_FAILED));
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
}
}
if(null == responseStr && !exceptionStatus){
responseJSON = VtnServiceWebUtil.prepareErrResponseJson(ApplicationConstants.STATUS_OK, ApplicationConstants.STATUS_SUCCESS);
}else{
- responseJSON = VtnServiceWebUtil.prepareErrResponseJson(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
+ responseJSON = new JSONObject(responseStr);
}
}catch (Exception exception) {
exceptionStatus = true;
//acquire session id
resource.setPath(ResourcePathEnum.SESSION_PATH.getPath());
if(resource.post(sessionJson) != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.SESSION_CREATION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.SESSION_CREATION_FAILED));
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
}
sessionId = VtnServiceCommonUtil.getSessionFromJson(resource.getInfo());
//acquire configure mode
resource.setPath(ResourcePathEnum.ACQUIRE_CONFIG_PATH.getPath());
resource.setSessionID(sessionId);
if(resource.post(VtnServiceWebUtil.prepareAquireConfigJSON()) != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.AQUIRE_CONFIGURATION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.AQUIRE_CONFIGURATION_FAILED));
- }
- configId = VtnServiceCommonUtil.getConfigIdFromJson(resource.getInfo());
- //send the api request json
- resource.setPath(resourcePath);
- resource.setConfigID(configId);
- resource.setSessionID(sessionId);
- final int status = resource.delete();
- LOG.debug("JAVA API returned error code #"+status);
- if(status != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
- }
- responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
- LOG.debug("JAVA API returned response # "+responseStr);
- resource.setPath(ResourcePathEnum.COMMIT_CONFIGURATION.getPath());
- resource.setSessionID(sessionId);
- resource.setConfigID(configId);
- final int commitStatus = resource.put(VtnServiceWebUtil.prepareConfigCommitOrSaveJSON(ApplicationConstants.OPERATION_COMMIT));
- if (commitStatus != RESPONSE_SUCCESS) {
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.INTERNAL_SERVER_ERROR,
- ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
- }
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
+ }
+ configId = VtnServiceCommonUtil.getConfigIdFromJson(resource.getInfo());
+ responseStr = performAbort(sessionId, configId, resource);
+ //send the api request json
+ resource.setPath(resourcePath);
+ resource.setConfigID(configId);
+ resource.setSessionID(sessionId);
+ final int status = resource.delete();
+ LOG.debug("JAVA API returned error code #"+status);
+ if(status != RESPONSE_SUCCESS){
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();//to save the below steps execution
+ }
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ LOG.debug("JAVA API returned response # "+responseStr);
+ //responseStr = performCommit(sessionId, configId, resource);
+ String commitResponse = performCommit(sessionId, configId, resource);
+ if(commitResponse != null){
+ responseStr = commitResponse;
+ }
}catch (VtnServiceWebAPIException vtnException) {
exceptionStatus = true;
- LOG.error(VtnServiceCommonUtil.logErrorDetails(vtnException.getErrorCode()));
}catch (RuntimeException exception) {
exceptionStatus = true;
LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
resource.setSessionID(sessionId);
resource.setConfigID(configId);
if(resource.delete() != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.RELEASE_CONFIGURATION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.RELEASE_CONFIGURATION_FAILED));
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
}
}
if(sessionId != ApplicationConstants.ZERO){
resource.setPath(ResourcePathEnum.RELEASE_SESSION.getPath()+ sessionId);
resource.setSessionID(sessionId);
if(resource.delete() != RESPONSE_SUCCESS){
- LOG.error("JAVA API returns error # "+resource.getInfo().getAsString());
- throw new VtnServiceWebAPIException(ApplicationConstants.RELEASE_SESSION_FAILED, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.RELEASE_SESSION_FAILED));
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
}
}
if(null == responseStr && !exceptionStatus){
responseJSON = VtnServiceWebUtil.prepareErrResponseJson(ApplicationConstants.STATUS_OK, ApplicationConstants.STATUS_SUCCESS);
}else{
- responseJSON = VtnServiceWebUtil.prepareErrResponseJson(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
+ responseJSON = new JSONObject(responseStr);
}
}catch (Exception exception) {
exceptionStatus = true;
}
return responseJSON;
}
+
+ /**
+ * Execute commit API for given resource, session and configuration id
+ * @param responseStr
+ * @param sessionId
+ * @param configId
+ * @param resource
+ * @return : response from JavaAPI
+ * @throws VtnServiceWebAPIException
+ */
+ private String performCommit(long sessionId, long configId, final RestResource resource)
+ throws VtnServiceWebAPIException {
+ String responseStr = null ;
+ LOG.trace("Start VtnServiceWebAPIController#performCommit()");
+ resource.setPath(ResourcePathEnum.COMMIT_CONFIGURATION.getPath());
+ resource.setSessionID(sessionId);
+ resource.setConfigID(configId);
+ final int commitStatus = resource.put(VtnServiceWebUtil.prepareConfigCommitOrSaveJSON(ApplicationConstants.OPERATION_COMMIT));
+ if (commitStatus != RESPONSE_SUCCESS) {
+ LOG.error("JAVA API returns error # "+resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ performAbort(sessionId, configId, resource);
+ throw new VtnServiceWebAPIException();
+ }
+ LOG.trace("Complete VtnServiceWebAPIController#performCommit()");
+ return responseStr;
+ }
-
+ /**
+ * Execute abort API for given resource, session and configuration id
+ * @param responseStr
+ * @param sessionId
+ * @param configId
+ * @param resource
+ * @return : response from JavaAPI
+ * @throws VtnServiceWebAPIException
+ */
+ private String performAbort(long sessionId, long configId, final RestResource resource)
+ throws VtnServiceWebAPIException {
+ String responseStr = null ;
+ LOG.trace("Start VtnServiceWebAPIController#performAbort()");
+ resource.setPath(ResourcePathEnum.ABORT_CONFIGURATION.getPath());
+ resource.setSessionID(sessionId);
+ resource.setConfigID(configId);
+ if (resource.put(VtnServiceWebUtil.prepareCandidateAbortJSON(ApplicationConstants.OPERATION_ABORT)) != RESPONSE_SUCCESS) {
+ LOG.error("JAVA API returns error # " + resource.getInfo());
+ responseStr = resource.getInfo() != null? resource.getInfo().toString():null;
+ throw new VtnServiceWebAPIException();
+ }
+ LOG.trace("Complete VtnServiceWebAPIController#performAbort()");
+ return responseStr;
+ }
}
import org.opendaylight.vtn.core.util.Logger;
import org.opendaylight.vtn.webapi.enums.ApplicationConstants;
import org.opendaylight.vtn.webapi.exception.VtnServiceWebAPIException;
+import org.opendaylight.vtn.webapi.pojo.SessionBean;
import org.opendaylight.vtn.webapi.utils.DataConverter;
import org.opendaylight.vtn.webapi.utils.VtnServiceCommonUtil;
import org.opendaylight.vtn.webapi.utils.VtnServiceWebUtil;
LOG.trace("PUT method of web api handler starts #put()");
this.resourcePath = VtnServiceCommonUtil.getResourceURI(request.getRequestURI());
this.contentType = VtnServiceCommonUtil.getContentType(request.getRequestURI());
- serviceRequest = new VtnServiceWebUtil().prepareRequestJson(request, contentType);
+ if (this.resourcePath.equals(ApplicationConstants.ALARMSTR)) {
+ final Map<String, String[]> paramsMap = request.getParameterMap();
+ if (null != paramsMap && !paramsMap.isEmpty()) {
+ serviceRequest = new JsonObject();
+ serviceRequest = DataConverter.convertMapToJson(paramsMap, serviceRequest);
+ }
+ } else {
+ serviceRequest = new VtnServiceWebUtil().prepareRequestJson(request, contentType);
+ }
serviceResponse = vtnServiceWebAPIController.put(VtnServiceWebUtil.prepareHeaderJson(request) ,serviceRequest, this.resourcePath);
responseString = DataConverter.getConvertedResponse(serviceResponse, contentType);
LOG.trace("PUT method of web api handler ends #put()");
throw new VtnServiceWebAPIException(ApplicationConstants.FORBIDDEN_ERROR, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.FORBIDDEN_ERROR));
}
final JsonObject headerInfo = VtnServiceWebUtil.prepareHeaderJson(request);
- if(!VtnServiceCommonUtil.authenticateUser(headerInfo, request.getMethod())){
+ final SessionBean bean = VtnServiceCommonUtil.getSessionObject(headerInfo);
+ if(!VtnServiceCommonUtil.authoriseUser(bean, request.getMethod())){
throw new VtnServiceWebAPIException(ApplicationConstants.USER_UNAUTHORISED_ERROR, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.USER_UNAUTHORISED_ERROR));
}
LOG.trace("validate method of web api handler ends #validate()");
accessConfiguration = new Properties();
accessConfiguration.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(ApplicationConstants.ACCESS_PROPERTY_PATH));
- pwdConfiguration = new Properties();
- pwdConfiguration.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(ApplicationConstants.PWD_PROPERTY_PATH));
+ /*pwdConfiguration = new Properties();
+ pwdConfiguration.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(ApplicationConstants.PWD_PROPERTY_PATH));*/
webAPIConfiguration = new Properties();
webAPIConfiguration.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(ApplicationConstants.WEBAPI_CONF_PROPERTY_PATH));
LOG.trace("configuration properties initialised successfully.");
}catch (FileNotFoundException exception) {
LOG.error(exception.getMessage());
- throw new VtnServiceWebAPIException(ApplicationConstants.PROPERTY_FILE_READ_ERROR, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.PROPERTY_FILE_READ_ERROR));
+ throw new VtnServiceWebAPIException(ApplicationConstants.INTERNAL_SERVER_ERROR, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.INTERNAL_SERVER_ERROR));
}catch (IOException exception) {
LOG.error(exception.getMessage());
- throw new VtnServiceWebAPIException(ApplicationConstants.PROPERTY_FILE_READ_ERROR, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.PROPERTY_FILE_READ_ERROR));
+ throw new VtnServiceWebAPIException(ApplicationConstants.INTERNAL_SERVER_ERROR, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.INTERNAL_SERVER_ERROR));
}
}
final String value = pwdConfiguration.getProperty(key);
//Check if value retrieved is null
if (null == value || value.isEmpty()) {
- LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.PROPERTY_NOT_FOUND_ERROR));
+ LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
throw new VtnServiceWebAPIException(ApplicationConstants.INTERNAL_SERVER_ERROR, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.INTERNAL_SERVER_ERROR));
}
LOG.trace("getPWDProperty end # getPWDProperty()");
final String value = webAPIConfiguration.getProperty(key);
//Check if value retrieved is null
if (null == value || value.isEmpty()) {
- LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.PROPERTY_NOT_FOUND_ERROR));
+ LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
throw new VtnServiceWebAPIException(ApplicationConstants.INTERNAL_SERVER_ERROR, ApplicationConstants.DEFAULT_ERROR_DESCRIPTION);
}
LOG.trace("getConfProperty end # getConfProperty()");
import java.util.Arrays;
import java.util.Map;
+import java.util.Random;
import java.util.Set;
import org.json.JSONException;
* @return the json object
* @throws VtnServiceWebAPIException the vtn service web api exception
*/
-
-
- public static JsonObject getConvertedRequestObject(final String rawRequestString, final String contentType) throws VtnServiceWebAPIException{
+ public static JsonObject getConvertedRequestObject(String rawRequestString, final String contentType) throws VtnServiceWebAPIException{
JsonObject convertedObj=null;
final JsonParser parser = new JsonParser();
try{
LOG.trace("converting request string to JSON Object #getConvertedRequestObject()");
if(ContentTypeEnum.APPLICATION_XML.getContentType().equals(contentType)){
+ final Random random = new Random();
+ String randomString = String.valueOf(random.nextInt());
+ rawRequestString = rawRequestString.replaceAll(ApplicationConstants.DOT_ZERO, randomString + ApplicationConstants.SESSION_TYPE);
org.json.JSONObject jsonObject = XML.toJSONObject(rawRequestString);
- convertedObj = (JsonObject) parser.parse(jsonObject.toString());
+ if(ApplicationConstants.vtepgroup.equals(jsonObject.keys().next().toString())){
+ XMLTransformationUtil.preProcessJson(jsonObject);
+ }
+ LOG.debug("Json before parsing : " + jsonObject);
+ convertedObj = (JsonObject) parser.parse(jsonObject.toString().replaceAll(randomString + ApplicationConstants.SESSION_TYPE, ApplicationConstants.DOT_ZERO));
}else{
convertedObj = (JsonObject) parser.parse(rawRequestString);
}
public static String getConvertedResponse(final JSONObject responseJson, final String requiredContentType) throws VtnServiceWebAPIException {
String responseString = null;
LOG.trace("converting response JSON to String #getConvertedResponse()");
+ LOG.debug("Json : " + responseJson);
try{
- if(null != responseJson){
- responseString = responseJson.toString();
- if(ContentTypeEnum.APPLICATION_XML.getContentType().equals(requiredContentType)){
- responseString = XML.toString(responseJson);
+ if (null != responseJson) {
+ responseString = responseJson.toString();
+ // conversion is required only for XML type response type
+ if (ContentTypeEnum.APPLICATION_XML.getContentType().equals(requiredContentType)) {
+ // modify the json object to remove null and empty nested
+ // json and arrays
+ JSONObject modifiedJson = new JSONObject(responseJson.toString()
+ .replace(ApplicationConstants.NULL_STRING,
+ ApplicationConstants.EMPTY_JSON)
+ .replace(ApplicationConstants.EMPTY_JSON,
+ ApplicationConstants.DUMMY_JSON)
+ .replace(ApplicationConstants.EMPTY_JSON_ARRAY,
+ ApplicationConstants.DUMMY_JSON));
+ LOG.debug("Modified Json : " + modifiedJson.toString());
+ String xml = XMLTransformationUtil.convertJsonToXml(modifiedJson);
+ LOG.debug("Converted XML : " + xml);
+ // remove non-required dummy xml attributes
+ responseString = XMLTransformationUtil.convertAllAttributesToElements(xml).replace(
+ ApplicationConstants.DUMMY_XML,
+ ApplicationConstants.EMPTY_STRING);
+ }
+ LOG.debug("Response String : " + responseString);
}
- }
}catch (JSONException e) {
+ LOG.error(e.getMessage());
LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
throw new VtnServiceWebAPIException(ApplicationConstants.INTERNAL_SERVER_ERROR, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.INTERNAL_SERVER_ERROR));
}catch (Exception e) {
+ LOG.error(e.getMessage());
LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
throw new VtnServiceWebAPIException(ApplicationConstants.INTERNAL_SERVER_ERROR, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.INTERNAL_SERVER_ERROR));
}
package org.opendaylight.vtn.webapi.utils;
import org.opendaylight.vtn.core.util.Logger;
-import org.opendaylight.vtn.javaapi.constants.VtnServiceConsts;
import org.opendaylight.vtn.javaapi.init.VtnServiceInitManager;
import org.opendaylight.vtn.webapi.exception.VtnServiceWebAPIException;
*/
package org.opendaylight.vtn.webapi.utils;
-import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.List;
* @return true, if successful
* @throws VtnServiceWebAPIException the vtn service exception
*/
- public static boolean authenticateUser(final JsonObject headerInfo, final String httpMethod) throws VtnServiceWebAPIException{
+ /*public static boolean authenticateUser(final JsonObject headerInfo, final String httpMethod) throws VtnServiceWebAPIException{
LOG.trace(" Authenticating user #authenticateUser() :starts");
boolean authenticationStatus= false;
String role = null;
}
LOG.trace(" Authenticating user #authenticateUser() :ends");
return authenticationStatus;
- }
+ }*/
/**
* Authorise user.
* @return true, if successful
* @throws VtnServiceWebAPIException the vtn service web api exception
*/
- private static boolean authoriseUser(SessionBean bean, String httpMethod) throws VtnServiceWebAPIException{
+ public static boolean authoriseUser(SessionBean bean, String httpMethod) throws VtnServiceWebAPIException{
boolean ipStatus = false;
ConfigurationManager configurationManager = ConfigurationManager.getInstance();
LOG.trace(" Authorizinging user #authoriseUser() : starts");
- //Proxy check is pending waiting for client reply on this.
- //String proxyStatus = configurationManager.getAccessProperty(ApplicationConstants.PROXY_OPT);
final String ipAddresses = configurationManager.getAccessProperty(ApplicationConstants.ACCESS_ALL);
final String httpMethodAccessIpAddress = configurationManager.getAccessProperty(httpMethod.toUpperCase());
- if(ipAddresses.indexOf(bean.getIpAddress()) != -1){
+ if(ipAddresses != null && ApplicationConstants.WILD_CARD_STAR.equals(ipAddresses.trim())){
+ ipStatus = true;
+ }
+ else if(ipAddresses.indexOf(bean.getIpAddress()) != -1){
+ ipStatus = true;
+ }
+ else if(null != httpMethodAccessIpAddress && !httpMethodAccessIpAddress.isEmpty() && ApplicationConstants.WILD_CARD_STAR.equals(httpMethodAccessIpAddress.trim())){
ipStatus = true;
}
else if(null != httpMethodAccessIpAddress && !httpMethodAccessIpAddress.isEmpty() && httpMethodAccessIpAddress.indexOf(bean.getIpAddress()) != -1){
* @return true, if successful
* @throws VtnServiceWebAPIException the vtn service web api exception
*/
- private static boolean checkRoleAccessability(final String role, final String httpMethod, final String password, final SessionBean bean) throws VtnServiceWebAPIException {
+ /* private static boolean checkRoleAccessability(final String role, final String httpMethod, final String password, final SessionBean bean) throws VtnServiceWebAPIException {
LOG.trace("Validating role and accessability of the user : starts");
boolean authenticationStatus = false;
if(VtnServiceWebUtil.checkStringForNullOrEmpty(role) && ApplicationConstants.ROLE_ADMIN.equals(role) && (VtnServiceWebUtil.checkStringForNullOrEmpty(password) && password.equals(convertPasswordStrToMd5Str(bean.getPassword())))){
}
LOG.trace("Validating role and accessability of the user : ends");
return authenticationStatus;
- }
+ }*/
/**
* Gets the session from json.
*/
public static boolean validateURI(final String uri, final String contentType){
LOG.trace("validation for URI : starts");
+ LOG.debug("uri : " + uri + " content-type : " + contentType);
boolean uriStatus = false;
if(null != uri && (uri.endsWith(ApplicationConstants.TYPE_XML) || uri.endsWith(ApplicationConstants.TYPE_JSON))){
uriStatus = true;
}else{
uriStatus = false;
}
+ LOG.debug("uri : " + uri + " content-type : " + contentType);
LOG.trace("validation for URI : ends");
return uriStatus;
}
public static SessionBean getSessionObject(final JsonObject sessionJson) throws VtnServiceWebAPIException{
LOG.trace("Preparing session object : starts");
SessionBean sessionBean = new SessionBean();
- List<String> mandatoryList = Arrays.asList(SessionEnum.PASSWORD.getSessionElement(), SessionEnum.IPADDRESS.getSessionElement());
+ List<String> mandatoryList = Arrays.asList(SessionEnum.USERNAME.getSessionElement(), SessionEnum.PASSWORD.getSessionElement(), SessionEnum.IPADDRESS.getSessionElement());
JsonObject sessionJsonObj = (JsonObject) sessionJson.get(ApplicationConstants.SESSION_OBJECT);
for (String value : mandatoryList) {
if(!sessionJsonObj.has(value) || null == sessionJsonObj.get(value)){
- throw new VtnServiceWebAPIException(ApplicationConstants.MISSING_HEADER_INFO, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.MISSING_HEADER_INFO));
+ throw new VtnServiceWebAPIException(ApplicationConstants.BAD_REQUEST_ERROR, VtnServiceCommonUtil.getErrorDescription(ApplicationConstants.BAD_REQUEST_ERROR));
}
}
sessionBean.setUserName(sessionJsonObj.get(SessionEnum.USERNAME.getSessionElement()) != null ?sessionJsonObj.get(SessionEnum.USERNAME.getSessionElement()).getAsString() : null );
* @return the resource uri
*/
public static String getResourceURI(final String requestURI) {
- LOG.trace("Getting requested URI: starts");
- String[] finalURI = null;
- if(null != requestURI){
- if(requestURI.endsWith(ApplicationConstants.TYPE_XML)){
- finalURI = requestURI.split(ApplicationConstants.TYPE_XML);
- }else{
- finalURI = requestURI.split(ApplicationConstants.TYPE_JSON);
+ LOG.trace("Getting requested URI: starts " + requestURI);
+ String finalURI = null;
+ if (null != requestURI) {
+ if (requestURI.endsWith(ApplicationConstants.TYPE_XML)) {
+ finalURI = requestURI.substring(ApplicationConstants.ZERO,
+ requestURI.length() - ApplicationConstants.FOUR);
+ } else if (requestURI.endsWith(ApplicationConstants.TYPE_JSON)) {
+ finalURI = requestURI.substring(ApplicationConstants.ZERO,
+ requestURI.length() - ApplicationConstants.FIVE);
}
}
- if(null != finalURI[ApplicationConstants.ZERO]){
- finalURI = finalURI[ApplicationConstants.ZERO].split(ApplicationConstants.CONTEXTPATH);
+ if (null != finalURI) {
+ finalURI = finalURI.replace(ApplicationConstants.CONTEXTPATH,
+ ApplicationConstants.EMPTY_STRING);
}
- LOG.trace("Getting requested URI: ends ");
- return finalURI[ApplicationConstants.ONE];
+ LOG.trace("Getting requested URI: ends " + finalURI);
+ return finalURI;
}
/**
* @return the string
* @throws VtnServiceWebAPIException the vtn service web api exception
*/
- private static String convertPasswordStrToMd5Str(final String simplePasswordStr) throws VtnServiceWebAPIException{
+ /*private static String convertPasswordStrToMd5Str(final String simplePasswordStr) throws VtnServiceWebAPIException{
LOG.trace("Converting password string to MD5 using MD5 algorithm: starts");
StringBuffer sb = null;
try {
}
LOG.trace("Converting password string to MD5 using MD5 algorithm: ends");
return sb.toString();
- }
+ }*/
/**
* Gets the op parameter.
line = reader.readLine();
}
reader.close();
+ LOG.debug("Request String : " + requestStr.toString());
serviceRequest = DataConverter.getConvertedRequestObject(requestStr.toString(), contentType);
LOG.debug("Request object json # serviceRequest #");
return serviceRequest;
final String nextElement = (String)headerEnum.nextElement();
if(SessionEnum.USERNAME.getSessionElement().equals(nextElement) ||
SessionEnum.PASSWORD.getSessionElement().equals(nextElement) ||
- SessionEnum.IPADDRESS.getSessionElement().equals(nextElement) ||
SessionEnum.LOGINNAME.getSessionElement().equals(nextElement) ||
SessionEnum.INFO.getSessionElement().equals(nextElement))
{
}
}
+ headerJson.addProperty(SessionEnum.IPADDRESS.getSessionElement(), request.getRemoteAddr());
headerJson.addProperty(ApplicationConstants.TYPE, ApplicationConstants.SESSION_TYPE);
final JsonObject sessionJson = new JsonObject();
sessionJson.add(SESSION, headerJson);
commitConfigObj.add(ApplicationConstants.CONFIGURATION_STRING, commitConfigJson);
return commitConfigObj;
}
+ /**
+ * Prepare abort commit json.
+ *
+ * @param operation
+ * the operation
+ * @return the json object
+ */
+ public static JsonObject prepareCandidateAbortJSON(final String operation) {
+ JsonObject abortConfigJson = new JsonObject();
+ JsonObject abortConfigObj = new JsonObject();
+ abortConfigJson.addProperty(ApplicationConstants.OPERATION, operation);
+ abortConfigObj.add(ApplicationConstants.CANDIDATE, abortConfigJson);
+ return abortConfigObj;
+ }
/**
* @throws JSONException
*/
public static JSONObject prepareErrResponseJson(final String errCode, final String description) {
- JSONObject temErrorJSON = new JSONObject();
- JSONObject errJson = new JSONObject();
- try{
- temErrorJSON.put(ApplicationConstants.ERR_CODE, errCode);
- temErrorJSON.put(ApplicationConstants.ERR_DESCRIPTION, description);
- errJson.put(ApplicationConstants.ERROR, temErrorJSON);
- }catch(JSONException e){
- LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
+ JSONObject errJson = null;
+ if(!ApplicationConstants.STATUS_OK.equals(errCode)){
+ JSONObject temErrorJSON = new JSONObject();
+ errJson = new JSONObject();
+ try{
+ temErrorJSON.put(ApplicationConstants.ERR_CODE, errCode);
+ temErrorJSON.put(ApplicationConstants.ERR_DESCRIPTION, description);
+ errJson.put(ApplicationConstants.ERROR, temErrorJSON);
+ }catch(JSONException e){
+ LOG.error(VtnServiceCommonUtil.logErrorDetails(ApplicationConstants.INTERNAL_SERVER_ERROR));
+ }
}
return errJson;
}
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 NEC Corporation
+ * All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vtn.webapi.utils;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+import java.util.Iterator;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.stream.StreamResult;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import org.opendaylight.vtn.core.util.Logger;
+import org.opendaylight.vtn.webapi.enums.ApplicationConstants;
+import org.opendaylight.vtn.webapi.exception.VtnServiceWebAPIException;
+
+/**
+ * The Class Transform XML String on the basis of XSLT file. Used XSLT file in
+ * this class contains the rules to transform elements to attributes.
+ *
+ */
+public class XMLTransformationUtil {
+
+ /** The Constant LOG. */
+ private static final Logger LOG = Logger.getLogger(XMLTransformationUtil.class.getName());
+
+ /**
+ * Convert all elements to attributes in XML string
+ *
+ * @param xmlContent
+ * valid XML formatted string
+ * @return attributed XML string
+ * @throws TransformerException
+ */
+ public static String convertAllAttributesToElements(String xmlContent)
+ throws TransformerException {
+ LOG.trace("Start XMLTransformationUtil#convertAllAttributesToElements()");
+ javax.xml.transform.Source xmlSource = new javax.xml.transform.stream.StreamSource(
+ new StringReader(xmlContent));
+ javax.xml.transform.Source xsltSource = new javax.xml.transform.stream.StreamSource(
+ Thread.currentThread().getContextClassLoader()
+ .getResource(ApplicationConstants.XSLT_FILE)
+ .toExternalForm());
+ LOG.trace("Complete XMLTransformationUtil#convertAllAttributesToElements()");
+ return transformContent(xmlSource, xsltSource);
+ }
+
+ /**
+ * Transformation is performed from elements to attributes
+ *
+ * @param xmlSource
+ * @param xsltSource
+ * @return
+ * @throws TransformerException
+ */
+ private static String transformContent(
+ javax.xml.transform.Source xmlSource,
+ javax.xml.transform.Source xsltSource) throws TransformerException {
+ LOG.trace("Start XMLTransformationUtil#transformContent()");
+ String modifiedContent = null;
+ javax.xml.transform.TransformerFactory transFact = javax.xml.transform.TransformerFactory
+ .newInstance();
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ StreamResult result = new javax.xml.transform.stream.StreamResult(
+ outStream);
+ javax.xml.transform.Transformer trans = transFact
+ .newTransformer(xsltSource);
+ trans.setOutputProperty(OutputKeys.STANDALONE,
+ ApplicationConstants.XML_STANDALONE);
+ trans.transform(xmlSource, result);
+ byte[] b = ((ByteArrayOutputStream) result.getOutputStream())
+ .toByteArray();
+ modifiedContent = new String(b);
+ // removing any line feed to save bytes.
+ modifiedContent = modifiedContent.replaceAll(
+ ApplicationConstants.LINE_FEED,
+ ApplicationConstants.EMPTY_STRING);
+ LOG.trace("Complete XMLTransformationUtil#transformContent()");
+ return modifiedContent;
+ }
+
+ /**
+ * Convert JSON format to XML format, without any parent tag name in XML
+ * format
+ *
+ * @param responseJson
+ * @return
+ * @throws JSONException
+ * @throws VtnServiceWebAPIException
+ */
+ public static String convertJsonToXml(Object responseJson)
+ throws JSONException, VtnServiceWebAPIException {
+ return convertJsonToXml(responseJson, null);
+ }
+
+ /**
+ * Convert JSON format to XML format, with given tag name in XML format
+ *
+ * @param responseJson
+ * @param parentTagName
+ * @return
+ * @throws JSONException
+ * @throws VtnServiceWebAPIException
+ */
+ public static String convertJsonToXml(Object responseJson,
+ String parentTagName) throws JSONException, VtnServiceWebAPIException {
+ LOG.trace("Start XMLTransformationUtil#convertJsonToXml()");
+ StringBuffer xmlString = new StringBuffer();
+ // local parameter required for conversion
+ JSONArray jsonArray;
+ JSONObject jsonObject;
+ String jsonKey;
+ Iterator<?> jsonKeys;
+ int counter, length;
+ Object jsonValue;
+
+ // if given object is JSON object
+ if (responseJson instanceof JSONObject) {
+ // if parent tag is specified
+ if (parentTagName != null) {
+ xmlString.append(ApplicationConstants.LESS_THAN);
+ xmlString.append(parentTagName);
+ xmlString.append(ApplicationConstants.GREATER_THAN);
+ }
+ jsonObject = (JSONObject) responseJson;
+ jsonKeys = jsonObject.keys();
+ boolean flag = false;
+ // iterate for all of the element of JSON object
+ while (jsonKeys.hasNext()) {
+ jsonKey = jsonKeys.next().toString();
+ jsonValue = jsonObject.opt(jsonKey);
+ if (jsonValue == null) {
+ jsonValue = ApplicationConstants.EMPTY_STRING;
+ }
+ // if element in JSON object is JSON array type then iterate for
+ // all of element recursively
+ if (jsonValue instanceof JSONArray) {
+ jsonArray = (JSONArray) jsonValue;
+ length = jsonArray.length();
+ // if there is no element in JSON array
+ if (length == 0) {
+ xmlString.append(ApplicationConstants.LESS_THAN);
+ xmlString.append(jsonKey);
+ xmlString.append(ApplicationConstants.SLASH);
+ xmlString.append(ApplicationConstants.GREATER_THAN);
+ } else {
+ xmlString.append(ApplicationConstants.LESS_THAN);
+ xmlString.append(jsonKey);
+ xmlString.append(ApplicationConstants.GREATER_THAN);
+ // get the child name from configuration file and add
+ // the same for array items
+ String childElementName = null;
+ try {
+ childElementName = ConfigurationManager
+ .getInstance().getConfProperty(jsonKey);
+ } catch (VtnServiceWebAPIException e) {
+ LOG.error("Property not found for list element");
+ if (!(ApplicationConstants.ipaddrs.equals(jsonKey)
+ || ApplicationConstants.ipv6addr.equals(jsonKey))) {
+ throw e;
+ } else {
+ flag = true;
+ }
+ }
+ // sb.append('[');
+ for (counter = 0; counter < length; counter += 1) {
+ if(childElementName != null){
+ xmlString.append(ApplicationConstants.LESS_THAN);
+ xmlString.append(childElementName);
+ xmlString.append(ApplicationConstants.GREATER_THAN);
+ }
+ jsonValue = jsonArray.get(counter);
+ if (jsonValue instanceof JSONArray) {
+ xmlString.append(convertJsonToXml(jsonValue));
+ } else {
+ if (!(counter == length - 1) && flag) {
+ jsonValue = jsonValue + ApplicationConstants.COMMA_STR;
+ }
+ xmlString.append(convertJsonToXml(jsonValue));
+ }
+ if(childElementName != null){
+ xmlString.append(ApplicationConstants.LESS_THAN);
+ xmlString.append(ApplicationConstants.SLASH);
+ xmlString.append(childElementName);
+ xmlString.append(ApplicationConstants.GREATER_THAN);
+ }
+ }
+ // sb.append(']');
+ xmlString.append(ApplicationConstants.LESS_THAN);
+ xmlString.append(ApplicationConstants.SLASH);
+ xmlString.append(jsonKey);
+ xmlString.append(ApplicationConstants.GREATER_THAN);
+ flag = false;
+ }
+ } else if (ApplicationConstants.EMPTY_STRING.equals(jsonValue)) {
+ xmlString.append(ApplicationConstants.LESS_THAN);
+ xmlString.append(jsonKey);
+ xmlString.append(ApplicationConstants.SLASH);
+ xmlString.append(ApplicationConstants.GREATER_THAN);
+ } else {
+ xmlString.append(convertJsonToXml(jsonValue, jsonKey));
+ }
+ }
+ if (parentTagName != null) {
+ xmlString.append(ApplicationConstants.LESS_THAN);
+ xmlString.append(ApplicationConstants.SLASH);
+ xmlString.append(parentTagName);
+ xmlString.append(ApplicationConstants.GREATER_THAN);
+ }
+ } else {
+ // if entity is a key-value pair - no JSON object or array is there
+ if (parentTagName != null) {
+ xmlString.append(ApplicationConstants.LESS_THAN);
+ xmlString.append(parentTagName);
+ xmlString.append(ApplicationConstants.GREATER_THAN);
+ }
+ xmlString.append(responseJson);
+ if (parentTagName != null) {
+ xmlString.append(ApplicationConstants.LESS_THAN);
+ xmlString.append(ApplicationConstants.SLASH);
+ xmlString.append(parentTagName);
+ xmlString.append(ApplicationConstants.GREATER_THAN);
+ }
+ }
+ LOG.trace("Complete XMLTransformationUtil#convertJsonToXml()");
+ return xmlString.toString();
+ }
+
+ /**
+ * pre-process request Json for removing unwanted tags
+ * @param jsonObject
+ * @return
+ * @throws JSONException
+ * @throws VtnServiceWebAPIException
+ */
+ public static JSONObject preProcessJson(JSONObject jsonObject) throws JSONException, VtnServiceWebAPIException {
+ // pre-process for vtep-group API
+ if (ApplicationConstants.vtepgroup.equals(jsonObject.keys().next().toString())
+ && jsonObject.getJSONObject(ApplicationConstants.vtepgroup).has(ApplicationConstants.member_vteps)) {
+ JSONObject memberVtepJson = jsonObject.getJSONObject(ApplicationConstants.vtepgroup).getJSONObject(ApplicationConstants.member_vteps);
+ JSONArray newArray = new JSONArray();
+ if (memberVtepJson.has(ApplicationConstants.member_vtep)) {
+ // only one instance
+ if (memberVtepJson.get(ApplicationConstants.member_vtep) instanceof JSONObject) {
+ newArray.put(memberVtepJson
+ .getJSONObject(ApplicationConstants.member_vtep));
+ } // multiple instances
+ else if (memberVtepJson.get(ApplicationConstants.member_vtep) instanceof JSONArray) {
+ newArray = memberVtepJson
+ .getJSONArray(ApplicationConstants.member_vtep);
+ }
+ }
+ jsonObject.getJSONObject(ApplicationConstants.vtepgroup).put(ApplicationConstants.member_vteps, newArray);
+ }
+ return jsonObject;
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<!--
+ Copyright (c) 2012-2013 NEC Corporation
+ All rights reserved.
+
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this
+ distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:template match="*">
+<xsl:copy>
+<xsl:for-each select="@*|*[not(* or @*)]">
+<xsl:attribute name="{name(.)}"><xsl:value-of select="."/>
+</xsl:attribute>
+</xsl:for-each>
+<xsl:apply-templates select="*[* or @*]|text()"/>
+</xsl:copy>
+</xsl:template>
+</xsl:stylesheet>
# distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
#
-
#Common settings or error codes for VTN service web API
vtns_err_200 = OK
vtns_err_400 = Bad Request
vtns_err_500 = Internal Server Error
-vtns_err_401 = User Unauthorised
+vtns_err_401 = User Unauthorized
vtns_err_403 = Forbidden
vtns_err_404 = Resource Not Found
vtns_err_405 = Method Not Allowed
-vtns_err_410 = Header Information Missing
-vtns_err_501 = Property Not Found Error
-vtns_err_502 = Property File Read Error
-vtns_err_510 = Session Creation Failed
-vtns_err_511 = Aquiring Configuration Failed
-vtns_err_512 = Release Session Failed
-vtns_err_513 = Release Configuration Failed
+
op=FORCE
timeout = 1000
-#########################################################################
+
#Default get api list for which blank json should be passed to Java API
-getListAPI = /api_version,/unc/version,/unc/alarms,/configuration/diff,/configuration/autosave
\ No newline at end of file
+getListAPI = /api_version,/unc/version,/unc/alarms,/configuration/diff,/configuration/autosave
+
+#Properties corresponding to List and their respective Show APIs
+flowlists=flowlist
+flowlistentries=flowlistentry
+vtnstations=vtnstation
+vtns=vtn
+flowfilterentries=flowfilterentry
+vbridges=vbridge
+l2domains=l2domain
+l2domain_members=l2domain_member
+macentries=macentry
+vlanmaps=vlanmap
+interfaces=interface
+vrouters=vrouter
+static_iproutes=static_iproute
+iproutes=iproute
+arpentries=arpentry
+servers=server
+vbypasses=vbypass
+vteps=vtep
+vtepgroups=vtepgroup
+member_vteps=member_vtep
+vtunnels=vtunnel
+vlinks=vlink
+controllers=controller
+switches=switch
+ports=port
+links=link
+domains=domain
+logical_ports=logical_port
+member_ports=member_port
+boundaries=boundary
+alarms=alarm
+patches=patch
+sessions=session
# distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
#
-#
-# define default value of max_repetition.
-#
+#define default value of max_repetition.
max_repetition_default=10000
-# IPC Server's IP adresse's
+#IPC Server's IP address
uncd_ip=localhost
phynwd_ip=localhost
lgcnwd_ip=localhost
unc_sysmg_ip=localhost
usess_ip=localhost
-# IPC Server's Channel's connection pool size
+#IPC Server's Channel's connection pool size
max_ipc_conn_pool_size_phynwd=4
max_ipc_conn_pool_size_lgcnwd=4
max_ipc_conn_pool_size_uncd=4
pfc::core::ipc::ClientSession*
TcClientSessionUtils::create_tc_client_session(std::string channel_name,
uint32_t service_id,
- pfc_ipcconn_t &conn) {
+ pfc_ipcconn_t &conn,
+ pfc_bool_t infinite_timeout) {
pfc::core::ipc::ClientSession* result_session = NULL;
int err = 0;
/*open an alternate connection*/
pfc_ipcclnt_altclose(conn);
return NULL;
}
+ /*set infinite timeout for commit/audit operations*/
+ if (infinite_timeout) {
+ err = result_session->setTimeout(NULL);
+ if (err != 0) {
+ pfc_log_fatal("pfc_ipcclnt_sess_settimeout failed");
+ delete result_session;
+ result_session = NULL;
+ pfc_ipcclnt_altclose(conn);
+ return NULL;
+ }
+ }
/*return session pointer*/
return result_session;
}
return TCUTIL_RET_SUCCESS;
}
/*IPC session close*/
-pfc::core::ipc::ClientSession*
-TcClientSessionUtils::tc_session_close(pfc::core::ipc::ClientSession* csess,
+TcUtilRet
+TcClientSessionUtils::tc_session_close(pfc::core::ipc::ClientSession** csess,
pfc_ipcconn_t conn) {
int err = 0;
pfc_log_debug("tc_session_close invoked");
- if (csess != NULL) {
- delete csess;
- csess = NULL;
+ if (*csess != NULL) {
+ delete *csess;
+ *csess = NULL;
}
/*close the alternate connection*/
err = pfc_ipcclnt_altclose(conn);
if (err != 0) {
pfc_log_fatal("pfc_ipcclnt_altclose failed");
- return NULL;
+ return TCUTIL_RET_FAILURE;
}
- return csess;
+ return TCUTIL_RET_SUCCESS;
}
/*retrieve uint32_t data from IPC session*/
TcUtilRet TcClientSessionUtils::get_uint32(
namespace unc {
namespace tc {
+TcUtilRet
+ TcServerSessionUtils::set_srv_timeout(pfc::core::ipc::ServerSession* ssess,
+ const pfc_timespec_t *timeout) {
+ int err = 0;
+ if (ssess == NULL)
+ return TCUTIL_RET_FAILURE;
+
+ err = ssess->setTimeout(timeout);
+ if (err != 0) {
+ pfc_log_fatal("setting timeout to server session failed");
+ return TCUTIL_RET_FAILURE;
+ }
+ return TCUTIL_RET_SUCCESS;
+}
+
/*retrieve uint32_t data from IPC session*/
TcUtilRet TcServerSessionUtils::get_uint32(
pfc::core::ipc::ServerSession* ssess,
const char *idx;
if (LNC_ORDTYPE_HASINDEX(type)) {
- snprintf(buf, sizeof(buf), "[%d]", index);
+ snprintf(buf, size, "[%d]", index);
idx = buf;
}
else {
parent_map_[version] = pfc_conf_get_string(ver_def_cfblk, "parent", "");
}
+bool CapaModule::LoadActualVersion(pfc_conf_t confp, const std::string version,
+ std::list<ActualVersion> &version_list) {
+
+ pfc_cfblk_t ver_def_cfblk = pfc_conf_get_map(confp, "version_definition",
+ version.c_str());
+
+ ActualVersion actual_version;
+ uint32_t actual_count = 0;
+ uint32_t actual_version_size = 0;
+ uint32_t array_index = 0;
+
+ /* Clear actual version list */
+ version_list.clear();
+
+ actual_count = pfc_conf_get_uint32(ver_def_cfblk, "actual_version_count", 0);
+
+ pfc_log_verbose(" Actual version count is %u", actual_count);
+
+ for (uint32_t index = 0; index <actual_count; index++) {
+
+ actual_version_size = pfc_conf_array_size(ver_def_cfblk, "actual_version");
+
+ if ((actual_version_size == 0) || (actual_version_size%4 != 0)) {
+ pfc_log_warn("Actual version array size is not multiples of 4");
+ return false;
+ }
+
+ memset(&actual_version, 0, sizeof(ActualVersion));
+ actual_version.major1 = pfc_conf_array_int32at(ver_def_cfblk,
+ "actual_version", array_index++, 0);
+ actual_version.major2 = pfc_conf_array_int32at(ver_def_cfblk,
+ "actual_version", array_index++, 0);
+ actual_version.minor = pfc_conf_array_int32at(ver_def_cfblk,
+ "actual_version", array_index++, 0);
+ actual_version.update = pfc_conf_array_int32at(ver_def_cfblk,
+ "actual_version", array_index++, 0);
+ version_list.push_back(actual_version);
+ }
+ return true;
+}
+
+bool CapaModule::ValidateVersion(unc_keytype_ctrtype_t ctrlr_type,
+ std::string config_version,
+ uint8_t pfc_version_major1,
+ uint8_t pfc_version_major2,
+ uint8_t pfc_version_minor,
+ uint8_t pfc_version_update) {
+
+ pfc_log_info("Validates Configuration version and actual version ");
+
+ struct CapaCtrlrCommon *ccc = ctrlr_common_map_.find(ctrlr_type)->second;
+ std::list<ActualVersion> actual_version_list;
+ ActualVersion actual;
+
+ if (ccc == NULL) {
+ pfc_log_warn("Failed to find Capa controller common");
+ return false;
+ }
+ memset(&actual, 0, sizeof(ActualVersion));
+
+ if (ccc->actual_version_map_.count(config_version) == 0) {
+ pfc_log_debug("Configuration version is not a member of "
+ "actual version map");
+ return false;
+ }
+
+ actual_version_list = ccc->actual_version_map_.find(config_version)->second;
+
+ while (!actual_version_list.empty()) {
+ actual = actual_version_list.front();
+
+ actual_version_list.pop_front();
+ pfc_log_verbose("Actual version : : (%d.%d.%d.%d)",
+ actual.major1, actual.major2, actual.minor, actual.update);
+
+ if ((actual.major1 == -1) || ((uint8_t)actual.major1 < pfc_version_major1)) {
+ return true;
+ }
+
+ if (((uint8_t)actual.major1 == pfc_version_major1)) {
+ if ((actual.major2 == -1) || ((uint8_t)actual.major2 < pfc_version_major2)) {
+ return true;
+ }
+
+ if ((uint8_t)actual.major2 == pfc_version_major2) {
+ if ((actual.minor == -1) || ((uint8_t)actual.minor < pfc_version_minor)) {
+ return true;
+ }
+
+ if ((uint8_t)actual.minor == pfc_version_minor) {
+ if ((actual.update == -1) || ((uint8_t)actual.update <= pfc_version_update)) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+}
+
+
bool CapaModule::LoadCapabilityFile(unc_keytype_ctrtype_t ctrlr_type) {
int ret;
pfc_conf_t confp;
LoadParentVersion(confp, version_name);
}
+ ccc->actual_version_map_.clear();
// Load KT capability for each controller version
for (int index = 0; index < num_versions; index++) {
/* Read version name from names filed in version list block */
return false;
}
ccc->capa_map[version_name] = cap_ptr;
+
+ pfc_log_verbose("Loading Actual version: %s", version_name);
+ std::list<ActualVersion> version_list;
+ if (false == LoadActualVersion(confp, version_name, version_list)) {
+ pfc_log_warn("Failed to load capability for %s", version_name);
+ return false;
+ }
+ ccc->actual_version_map_[version_name] = version_list;
}
+
/* Close file */
pfc_conf_close(confp);
+
return true;
}
+
// Even if capability files are not loaded the module returns success.
// If file was not loaded, then this module assumes no feature is supported
// for that controller type
#include <string>
#include <map>
+#include <list>
#include "pfcxx/module.hh"
#include "pfcxx/synch.hh"
void VerboseDumpAll();
void VerboseDump(unc_keytype_ctrtype_t ctrlr_type, std::string version);
+ /*
+ * @brief Validates configuration version and actual version of specified
+ * controller type
+ *
+ * @param[in] ctrlr_type controller type
+ * @param[in] config_version configuration version
+ * @param[in] pfc_version actual version
+ *
+ * @retval true Successful
+ * @retval false validation of configuration version and actual version.
+ *
+ * */
+ bool ValidateVersion(unc_keytype_ctrtype_t ctrlr_type,
+ std::string config_version, uint8_t pfc_version_major1,
+ uint8_t pfc_version_major2, uint8_t pfc_version_minor,
+ uint8_t pfc_version_update);
private:
+ struct ActualVersion {
+ int32_t major1;
+ int32_t major2;
+ int32_t minor;
+ int32_t update;
+ };
+
bool LoadCapabilityFile(unc_keytype_ctrtype_t ctrlr_type);
void LoadParentVersion(pfc_conf_t confp, const std::string version);
+ bool LoadActualVersion(pfc_conf_t confp, const std::string version,
+ std::list<ActualVersion> &version_list);
+
/**
* @brief Capability Manager Instance.
*/
struct CapaCtrlrCommon {
std::map<std::string, CtrlrCapability*> capa_map;
+ std::map<std::string, std::list<ActualVersion> > actual_version_map_;
};
std::map<unc_keytype_ctrtype_t, CapaCtrlrCommon*> ctrlr_common_map_;
defmap version_definition {
parent = STRING;
flags = UINT32;
+ actual_version_count = UINT32;
+
+ % Multiples of 4: major1, major2, minor, update
+ actual_version = INT32[];
}
% Capability definitions.
instance_count = UINT32;
% 0:CONF_CREATE, 1:CONF_UPDATE, 2:CONF_READ, 3:STATE_READ
+ domain_id = BOOL[4];
description = BOOL[4];
host_address = BOOL[4];
host_address_prefixlen = BOOL[4];
instance_count = UINT32;
% 0:CONF_CREATE, 1:CONF_UPDATE, 2:CONF_READ, 3:STATE_READ
+ domain_id = BOOL[4];
description = BOOL[4];
dhcp_relay_admin_status = BOOL[4];
operstatus = BOOL[4];
*/
KtAttrMap kam_vbridge[] = {
+ { "domain_id", vbr::kCapDomainId },
{ "description", vbr::kCapDesc },
{ "host_address", vbr::kCapHostAddr },
{ "host_address_prefixlen", vbr::kCapHostAddrPrefixlen },
};
KtAttrMap kam_vrouter[] = {
+ { "domain_id", vrt::kCapDomainId },
{ "description", vrt::kCapDesc },
{ "dhcp_relay_admin_status", vrt::kCapDhcpRelayAdminStatus },
{ "operstatus", vrt::kCapOperStatus }
namespace vbr {
enum vbr {
- kCapDesc = 0,
+ kCapDomainId =0,
+ kCapDesc,
kCapHostAddr,
kCapHostAddrPrefixlen,
kCapOperStatus
namespace vrt {
enum vrt {
- kCapDesc = 0,
+ kCapDomainId =0,
+ kCapDesc,
kCapDhcpRelayAdminStatus,
kCapOperStatus
};
}
version_definition "5.0" {
+ actual_version_count = 1;
+ actual_version = [5, 0, -1, -1];
}
# Capability definitions.
vtn "5.0" {
- instance_count = 0;
+ instance_count = 1000;
# 0:CONF_CREATE, 1:CONF_UPDATE, 2:CONF_READ, 3:STATE_READ
description = [ true, true, true, true ];
}
vbridge "5.0" {
- instance_count = 0;
+ instance_count = 10000;
# 0:CONF_CREATE, 1:CONF_UPDATE, 2:CONF_READ, 3:STATE_READ
+ domain_id = [ true, true, true, true ];
description = [ true, true, true, true ];
host_address = [ true, true, true, true ];
host_address_prefixlen = [ true, true, true, true ];
instance_count = 0;
# 0:CONF_CREATE, 1:CONF_UPDATE, 2:CONF_READ, 3:STATE_READ
+ domain_id = [ true, true, true, true ];
description = [ true, true, true, true ];
dhcp_relay_admin_status = [ true, true, true, true ];
operstatus = [ true, true, true, true ];
}
static_ip_route "5.0" {
- instance_count = 0;
+ instance_count = 65535;
# 0:CONF_CREATE, 1:CONF_UPDATE, 2:CONF_READ, 3:STATE_READ
- group_metric = [ true, true, true, true ];
+ group_metric = [ false, false, false, false ];
}
vrouter_interface "5.0" {
ip_address = [ true, true, true, true ];
prefixlen = [ true, true, true, true ];
mac_address = [ true, true, true, true ];
- admin_status = [ true, true, true, true ];
+ admin_status = [ true, false, true, true ];
operstatus = [ true, true, true, true ];
}
}
network_monitor_ip_host "5.0" {
- instance_count = 0;
+ instance_count = 1000;
# 0:CONF_CREATE, 1:CONF_UPDATE, 2:CONF_READ, 3:STATE_READ
health_interval = [ true, true, true, true ];
#include <sstream>
#include "pfc/base.h"
#include "unc/base.h"
-#include "upll/upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "dal_bind_column_info.hh"
namespace unc {
return false;
}
- if (io_type_ == io_type) {
- UPLL_LOG_TRACE("Overwriting Bind Information for Table(%s) Column(%s): "
- "\nRequested Bind Code - %s, Existing Bind Type - %s, "
- "Computed Bind Type - %s",
- schema::TableName(table_index),
- schema::ColumnName(table_index, column_index_),
- DalIoCodeToStr(io_code).c_str(),
- DalIoTypeToStr(io_type_).c_str(),
- DalIoTypeToStr(io_type).c_str());
+ if (io_type_ == io_type && io_code == kDalIoCodeInput) {
+ UPLL_LOG_TRACE("Overwriting Input Bind Information for Table(%s)"
+ " Column(%s): ", schema::TableName(table_index),
+ schema::ColumnName(table_index, column_index_));
return false;
}
io_type_ = io_type;
}
memset(buff_len_ptr_, 0, sizeof(SQLLEN));
*buff_len_ptr_ = app_array_size_;
- UPLL_LOG_TRACE("Done with first time updation of common member variables "
+ UPLL_LOG_VERBOSE("Done with first time updation of common member variables "
"for Table(%s) Column(%s) with the following data: \n"
"App data type - %s\nApp array size - %zd\n"
"Buff Len Ptr - %p\nBuff Len - %ld\n",
schema::ColumnName(table_index, column_index_));
return false;
}
- UPLL_LOG_TRACE("Updated Input Binding for Table(%s) Column(%s):"
+ UPLL_LOG_VERBOSE("Updated Input Binding for Table(%s) Column(%s):"
"\n User Address - %p, Value - %s"
"\n DAL Address - %p, Value - %s",
schema::TableName(table_index),
schema::ColumnName(table_index, column_index_));
return false;
}
- UPLL_LOG_TRACE("Updated Output Binding for Table(%s) Column(%s):"
+ UPLL_LOG_VERBOSE("Updated Output Binding for Table(%s) Column(%s):"
"\n User Address - %p, Value - %s"
"\n DAL Address - %p, Value - %s",
schema::TableName(table_index),
schema::ColumnName(table_index, column_index_));
return false;
}
- UPLL_LOG_TRACE("Updated Match Binding for Table(%s) Column(%s):"
+ UPLL_LOG_VERBOSE("Updated Match Binding for Table(%s) Column(%s):"
"\n User Address - %p, Value - %s"
"\n DAL Address - %p, Value - %s",
schema::TableName(table_index),
UPLL_LOG_DEBUG("Data Type mismatch");
return false;
}
- UPLL_LOG_TRACE("Copied result for Column(%s) in Table(%s): \n"
- "\nSrc - DAL Output Address - %p, Value - %s"
- "\nDest - User Output Address - %p, Value - %s",
+ UPLL_LOG_VERBOSE("Copied result for Column(%s) in Table(%s): "
+ "Src(%p, %s) Dest (%p, %s)",
schema::ColumnName(table_index, column_index_),
schema::TableName(table_index),
db_in_out_addr_,
UPLL_LOG_DEBUG("Cannot Copy Data - Datatype mismatch Error");
return false;
}
- UPLL_LOG_TRACE("Copied Data from source(%p) to destination(%p)",
+ UPLL_LOG_VERBOSE("Copied Data from source(%p) to destination(%p)",
*src, *dest);
return true;
}
memset(*col_buff, 0, alloc_size);
- UPLL_LOG_TRACE("Allocated Memory for %zd bytes", alloc_size);
+ UPLL_LOG_VERBOSE("Allocated Memory for %zd bytes", alloc_size);
return true;
} // DalBindColumnInfo::AllocateColBuffer
default:
return 0;
}
- UPLL_LOG_TRACE("Calculated DAL Buffer size - %zd"
+ UPLL_LOG_VERBOSE("Calculated DAL Buffer size - %zd"
" for DAL datatype(%d) and array size(%zd)",
buffer_size, dal_data_type, array_size);
return buffer_size;
return 0;
} // switch(app_data_type)
- UPLL_LOG_TRACE("Calculated App Buffer size - %zd"
+ UPLL_LOG_VERBOSE("Calculated App Buffer size - %zd"
" for App datatype(%d) and array size(%zd)",
buffer_size, app_data_type, array_size);
return buffer_size;
*data_type_code = kDalDtCodeInvalid;
break;
}
- UPLL_LOG_TRACE("Copy Data type code - %d",
- *data_type_code);
+ UPLL_LOG_VERBOSE("Copy Data type code - %d", *data_type_code);
return;
} // DalBindColumnInfo::GetCopyDatatype
switch (app_data_type) {
case kDalChar:
for (i = 0; i < array_size; i++) {
- if (((reinterpret_cast<char *>(*dest))+i) == NULL ||
- ((reinterpret_cast<const char *>(*src))+i) == NULL) {
- return false;
- }
*((reinterpret_cast<char *>(*dest))+i) =
*((reinterpret_cast<const char *>(*src))+i);
+ if (*((reinterpret_cast<const char *>(*src))+i) == '\0') {
+ break;
+ }
}
break;
case kDalUint8:
for (i = 0; i < array_size; i++) {
- if (((reinterpret_cast<uint8_t *>(*dest))+i) == NULL ||
- ((reinterpret_cast<const uint8_t *>(*src))+i) == NULL) {
- return false;
- }
*((reinterpret_cast<uint8_t *>(*dest))+i) =
*((reinterpret_cast<const uint8_t *>(*src))+i);
}
case kDalUint16:
for (i = 0; i < array_size; i++) {
- if (((reinterpret_cast<uint16_t *>(*dest))+i) == NULL ||
- ((reinterpret_cast<const uint16_t *>(*src))+i) == NULL) {
- return false;
- }
*((reinterpret_cast<uint16_t *>(*dest))+i) =
*((reinterpret_cast<const uint16_t *>(*src))+i);
}
case kDalUint32:
for (i = 0; i < array_size; i++) {
- if (((reinterpret_cast<uint32_t *>(*dest))+i) == NULL ||
- ((reinterpret_cast<const uint32_t *>(*src))+i) == NULL) {
- return false;
- }
*((reinterpret_cast<uint32_t *>(*dest))+i) =
*((reinterpret_cast<const uint32_t *>(*src))+i);
}
case kDalUint64:
for (i = 0; i < array_size; i++) {
- if (((reinterpret_cast<uint64_t *>(*dest))+i) == NULL ||
- ((reinterpret_cast<const uint64_t *>(*src))+i) == NULL) {
- return false;
- }
*((reinterpret_cast<uint64_t *>(*dest))+i) =
*((reinterpret_cast<const uint64_t *>(*src))+i);
}
return false;
} // switch(app_data_type)
- UPLL_LOG_TRACE("Copied contents of source address(%p) to "
+ UPLL_LOG_VERBOSE("Copied contents of source address(%p) to "
"destination(%p) address", *src, *dest);
return true;
} // DalBindColumnInfo::CopyUsingAppDataType
switch (dal_data_type) {
case SQL_C_CHAR:
for (i = 0; i < array_size; i++) {
- if (((reinterpret_cast<SQLCHAR *>(*dest))+i) == NULL ||
- ((reinterpret_cast<const SQLCHAR *>(*src))+i) == NULL) {
- return false;
- }
*((reinterpret_cast<SQLCHAR *>(*dest))+i) =
*((reinterpret_cast<const SQLCHAR *>(*src))+i);
+ if (*((reinterpret_cast<const SQLCHAR *>(*src))+i) == '\0') {
+ break;
+ }
}
break;
case SQL_C_TINYINT:
case SQL_C_STINYINT:
for (i = 0; i < array_size; i++) {
- if (((reinterpret_cast<SCHAR *>(*dest))+i) == NULL ||
- ((reinterpret_cast<const SCHAR *>(*src))+i) == NULL) {
- return false;
- }
*((reinterpret_cast<SCHAR *>(*dest))+i) =
*((reinterpret_cast<const SCHAR *>(*src))+i);
}
case SQL_C_UTINYINT:
for (i = 0; i < array_size; i++) {
- if (((reinterpret_cast<UCHAR *>(*dest))+i) == NULL ||
- ((reinterpret_cast<const UCHAR *>(*src))+i) == NULL) {
- return false;
- }
*((reinterpret_cast<UCHAR *>(*dest))+i) =
*((reinterpret_cast<const UCHAR *>(*src))+i);
}
case SQL_C_SHORT:
case SQL_C_SSHORT:
for (i = 0; i < array_size; i++) {
- if (((reinterpret_cast<SQLSMALLINT *>(*dest))+i) == NULL ||
- ((reinterpret_cast<const SQLSMALLINT *>(*src))+i) == NULL) {
- return false;
- }
*((reinterpret_cast<SQLSMALLINT *>(*dest))+i) =
*((reinterpret_cast<const SQLSMALLINT *>(*src))+i);
}
case SQL_C_USHORT:
for (i = 0; i < array_size; i++) {
- if (((reinterpret_cast<SQLUSMALLINT *>(*dest))+i) == NULL ||
- ((reinterpret_cast<const SQLUSMALLINT *>(*src))+i) == NULL) {
- return false;
- }
*((reinterpret_cast<SQLUSMALLINT *>(*dest))+i) =
*((reinterpret_cast<const SQLUSMALLINT *>(*src))+i);
}
case SQL_C_LONG:
case SQL_C_SLONG:
for (i = 0; i < array_size; i++) {
- if (((reinterpret_cast<SQLINTEGER *>(*dest))+i) == NULL ||
- ((reinterpret_cast<const SQLINTEGER *>(*src))+i) == NULL) {
- return false;
- }
*((reinterpret_cast<SQLINTEGER *>(*dest))+i) =
*((reinterpret_cast<const SQLINTEGER *>(*src))+i);
}
case SQL_C_ULONG:
for (i = 0; i < array_size; i++) {
- if (((reinterpret_cast<SQLUINTEGER *>(*dest))+i) == NULL ||
- ((reinterpret_cast<const SQLUINTEGER *>(*src))+i) == NULL) {
- return false;
- }
*((reinterpret_cast<SQLUINTEGER *>(*dest))+i) =
*((reinterpret_cast<const SQLUINTEGER *>(*src))+i);
}
case SQL_C_SBIGINT:
for (i = 0; i < array_size; i++) {
- if (((reinterpret_cast<SQLBIGINT *>(*dest))+i) == NULL ||
- ((reinterpret_cast<const SQLBIGINT *>(*src))+i) == NULL) {
- return false;
- }
*((reinterpret_cast<SQLBIGINT *>(*dest))+i) =
*((reinterpret_cast<const SQLBIGINT *>(*src))+i);
}
case SQL_C_UBIGINT:
for (i = 0; i < array_size; i++) {
- if (((reinterpret_cast<SQLUBIGINT *>(*dest))+i) == NULL ||
- ((reinterpret_cast<const SQLUBIGINT *>(*src))+i) == NULL) {
- return false;
- }
*((reinterpret_cast<SQLUBIGINT *>(*dest))+i) =
*((reinterpret_cast<const SQLUBIGINT *>(*src))+i);
}
if (app_data_type == kDalChar ||
app_data_type == kDalUint8) {
for (i = 0; i < array_size; i++) {
- if (((reinterpret_cast<SQLCHAR *>(*dest))+i) == NULL ||
- ((reinterpret_cast<const SQLCHAR *>(*src))+i) == NULL) {
- return false;
- }
*((reinterpret_cast<SQLCHAR *>(*dest))+i) =
*((reinterpret_cast<const SQLCHAR *>(*src))+i);
}
(uint64_t)array_size, app_data_type, dal_data_type);
return false;
}
+ *(reinterpret_cast<uint32_t *>(*dest)) =
+ (*(reinterpret_cast<const uint32_t *>(*src)));
+#if 0
if (input == true) {
*(reinterpret_cast<uint32_t *>(*dest)) =
htonl(*(reinterpret_cast<const uint32_t *>(*src)));
*(reinterpret_cast<uint32_t *>(*dest)) =
ntohl(*(reinterpret_cast<const uint32_t *>(*src)));
}
+#endif
} else if (app_data_type == kDalUint64) {
if (array_size != 8) {
UPLL_LOG_DEBUG("Wrong Array Size(%"PFC_PFMT_u64") for"
return false;
}
- UPLL_LOG_TRACE("Copied contents of source address(%p) to "
+ UPLL_LOG_VERBOSE("Copied contents of source address(%p) to "
"destination(%p) address", *src, *dest);
return true;
} // DalBindColumnInfo::CopyUsingDalDataType
memset(*col_buff, 0, alloc_size);
- UPLL_LOG_TRACE("Contents of address(%p) reset to 0",
+ UPLL_LOG_VERBOSE("Contents of address(%p) reset to 0",
*col_buff);
return true;
} // DalBindColumnInfo::ResetColBuffer
return kDalIoInputAndMatch;
} else if (io_code == kDalIoCodeOutput) {
return kDalIoOutputAndMatch;
+ } else if (io_code == kDalIoCodeMatch) {
+ return kDalIoMatchOnly;
}
break;
case kDalIoInputAndMatch:
+ if (io_code == kDalIoCodeMatch) {
+ return kDalIoInputAndMatch;
+ }
break;
case kDalIoOutputAndMatch:
if (io_code == kDalIoCodeOutput) {
return kDalIoOutputAndMatch;
+ } else if (io_code == kDalIoCodeMatch) {
+ return kDalIoOutputAndMatch;
}
break;
io_type_ == kDalIoInputOnly ||
io_type_ == kDalIoOutputOnly) {
*avail = true;
+ } else if (io_type_ == kDalIoMatchOnly ||
+ io_type_ == kDalIoInputAndMatch ||
+ io_type_ == kDalIoOutputAndMatch) {
+ *avail = false;
} else {
return false;
}
return ss.str();
} // DalBindColumnInfo::ColInfoToStr
+std::string
+DalBindColumnInfo::ColInfoInputToStr(const DalTableIndex table_index) const {
+ std::stringstream ss;
+ ss << "{" << schema::ColumnName(table_index, column_index_) << ", "
+ << AppDataTypeToStr(app_data_type_) << ", "
+ << app_array_size_ << ", " << DalIoTypeToStr(io_type_);
+ if (io_type_ == kDalIoOutputOnly || io_type_ == kDalIoOutputAndMatch) {
+ if (app_out_addr_ != NULL) {
+ ss << ", OUTPUT[" << app_out_addr_ << "]";
+ } else {
+ ss << ", OUTPUT[NULL]";
+ }
+ }
+ if (io_type_ == kDalIoInputOnly || io_type_ == kDalIoInputAndMatch) {
+ if (db_in_out_addr_ != NULL) {
+ ss << ", INPUT[" << db_in_out_addr_ << ", "
+ << ValueInBindAddrToStr(table_index,
+ const_cast<const void**>(&db_in_out_addr_)) << "]";
+ } else {
+ ss << ", INPUT[NULL]";
+ }
+ }
+ if (io_type_ == kDalIoMatchOnly || io_type_ == kDalIoInputAndMatch ||
+ io_type_ == kDalIoOutputAndMatch) {
+ if (db_match_addr_ != NULL) {
+ ss << ", MATCH[" << db_match_addr_ << ", "
+ << ValueInBindAddrToStr(table_index,
+ const_cast<const void**>(&db_match_addr_)) << "]";
+ } else {
+ ss << ", MATCH[NULL]";
+ }
+ }
+ ss << "}";
+ return ss.str();
+} // DalBindColumnInfo::ColInfoInputToStr
+
+std::string
+DalBindColumnInfo::ColInfoResultToStr(const DalTableIndex table_index) const {
+ std::stringstream ss;
+ if (io_type_ == kDalIoOutputOnly || io_type_ == kDalIoOutputAndMatch) {
+ ss << "[";
+ if (app_out_addr_ != NULL) {
+ ss << schema::ColumnName(table_index, column_index_) << ", "
+ << ValueInBindAddrToStr(table_index,
+ const_cast<const void**>(&app_out_addr_));
+ } else {
+ ss << "NULL";
+ }
+ ss << "] ";
+ }
+ return ss.str();
+} // DalBindColumnInfo::ColInfoResultToStr
+
std::string
DalBindColumnInfo::AppDataTypeToStr(DalCDataType app_data_type) const {
switch (app_data_type) {
DalBindColumnInfo::AppValueToStr(const DalCDataType app_data_type,
const void **addr) const {
std::stringstream ss;
+
+ if (addr == NULL || *addr == NULL) {
+ ss << "(null)";
+ return ss.str();
+ }
+
switch (app_data_type) {
case kDalChar:
for (size_t i = 0; i < app_array_size_; i++) {
- if (((reinterpret_cast<const char*>(*addr))+i) == NULL ||
- *((reinterpret_cast<const char*>(*addr))+i) == 0) {
+ if (*((reinterpret_cast<const char*>(*addr))+i) == 0) {
break;
}
ss << *((reinterpret_cast<const char *>(*addr))+i);
char xtemp[3];
ss << "0x";
for (size_t i = 0; i < app_array_size_; i++) {
- if (((reinterpret_cast<const uint8_t *>(*addr))+i) == NULL) {
- ss << "(null) ";
- }
memset(xtemp, 0, 3);
snprintf(xtemp, 3,
"%02X", *((reinterpret_cast<const uint8_t *>(*addr))+i));
case kDalUint16:
for (size_t i = 0; i < app_array_size_; i++) {
- if (((reinterpret_cast<const uint16_t *>(*addr))+i) == NULL) {
- ss << "(null) ";
- }
ss << *((reinterpret_cast<const uint16_t *>(*addr))+i) << " ";
}
break;
case kDalUint32:
for (size_t i = 0; i < app_array_size_; i++) {
- if (((reinterpret_cast<const uint32_t *>(*addr))+i) == NULL) {
- ss << "(null) ";
- }
ss << *((reinterpret_cast<const uint32_t *>(*addr))+i) << " ";
}
break;
case kDalUint64:
for (size_t i = 0; i < app_array_size_; i++) {
- if (((reinterpret_cast<const uint64_t *>(*addr))+i) == NULL) {
- ss << "(null) ";
- }
ss << *((reinterpret_cast<const uint64_t *>(*addr))+i) << " ";
}
break;
std::stringstream ss;
SCHAR schar_temp = 0;
UCHAR uchar_temp = 0;
+
+ if (addr == NULL || *addr == NULL) {
+ ss << "(null)";
+ return ss.str();
+ }
+
switch (dal_data_type) {
case SQL_C_CHAR:
for (size_t i = 0; i < app_array_size_; i++) {
- if (((reinterpret_cast<const SQLCHAR *>(*addr))+i) == NULL ||
- *((reinterpret_cast<const SQLCHAR *>(*addr))+i) == 0) {
+ if (*((reinterpret_cast<const SQLCHAR *>(*addr))+i) == 0) {
break;
}
ss << *((reinterpret_cast<const SQLCHAR *>(*addr))+i);
case SQL_C_TINYINT:
case SQL_C_STINYINT:
for (size_t i = 0; i < app_array_size_; i++) {
- if (((reinterpret_cast<const SCHAR *>(*addr))+i) == NULL) {
- ss << "(null) ";
- }
schar_temp = *((reinterpret_cast<const SCHAR *>(*addr))+i);
ss << (SQLSMALLINT)(schar_temp) << " ";
}
case SQL_C_UTINYINT:
for (size_t i = 0; i < app_array_size_; i++) {
- if (((reinterpret_cast<const UCHAR *>(*addr))+i) == NULL) {
- ss << "(null) ";
- }
uchar_temp = *((reinterpret_cast<const UCHAR *>(*addr))+i);
ss << (SQLSMALLINT)(uchar_temp) << " ";
}
case SQL_C_SHORT:
case SQL_C_SSHORT:
for (size_t i = 0; i < app_array_size_; i++) {
- if (((reinterpret_cast<const SQLSMALLINT *>(*addr))+i) == NULL) {
- ss << "(null) ";
- }
ss << *((reinterpret_cast<const SQLSMALLINT *>(*addr))+i);
}
break;
case SQL_C_USHORT:
for (size_t i = 0; i < app_array_size_; i++) {
- if (((reinterpret_cast<const SQLUSMALLINT *>(*addr))+i) == NULL) {
- ss << "(null) ";
- }
ss << *((reinterpret_cast<const SQLUSMALLINT *>(*addr))+i);
}
break;
case SQL_C_LONG:
case SQL_C_SLONG:
for (size_t i = 0; i < app_array_size_; i++) {
- if (((reinterpret_cast<const SQLINTEGER *>(*addr))+i) == NULL) {
- ss << "(null) ";
- }
ss << *((reinterpret_cast<const SQLINTEGER *>(*addr))+i);
}
break;
case SQL_C_ULONG:
for (size_t i = 0; i < app_array_size_; i++) {
- if (((reinterpret_cast<const SQLUINTEGER *>(*addr))+i) == NULL) {
- ss << "(null) ";
- }
ss << *((reinterpret_cast<const SQLUINTEGER *>(*addr))+i);
}
break;
case SQL_C_SBIGINT:
for (size_t i = 0; i < app_array_size_; i++) {
- if (((reinterpret_cast<const SQLBIGINT *>(*addr))+i) == NULL) {
- ss << "(null) ";
- }
ss << *((reinterpret_cast<const SQLBIGINT *>(*addr))+i);
}
break;
case SQL_C_UBIGINT:
for (size_t i = 0; i < app_array_size_; i++) {
- if (((reinterpret_cast<const SQLUBIGINT *>(*addr))+i) == NULL) {
- ss << "(null) ";
- }
ss << *((reinterpret_cast<const SQLUBIGINT *>(*addr))+i);
}
break;
{
char xtemp[3];
ss << "0x";
- for (size_t i = 0; i < app_array_size_; i++) {
- if (((reinterpret_cast<const SCHAR *>(*addr))+i) == NULL) {
- ss << "(null) ";
+ for (size_t i = 0; i < app_array_size_; i++) {
+ memset(xtemp, 0, 3);
+ snprintf(xtemp, 3,
+ "%02X", *((reinterpret_cast<const SCHAR *>(*addr))+i));
+ ss << xtemp;
}
- memset(xtemp, 0, 3);
- snprintf(xtemp, 3,
- "%02X", *((reinterpret_cast<const SCHAR *>(*addr))+i));
- ss << xtemp;
- }
}
break;
bool ResetDalOutputBuffer(const DalTableIndex table_index);
std::string ColInfoToStr(const DalTableIndex table_index) const;
+ std::string ColInfoInputToStr(const DalTableIndex table_index) const;
+ std::string ColInfoResultToStr(const DalTableIndex table_index) const;
std::string ValueInBindAddrToStr(const DalTableIndex table_index,
const void **addr) const;
#include <sstream>
-#include "upll/upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "dal_bind_info.hh"
namespace unc {
}
input_bind_count_++;
- UPLL_LOG_TRACE("Successfully Bind Input for Column(%s) in Table(%s)",
+ UPLL_LOG_VERBOSE("Successfully Bind Input for Column(%s) in Table(%s)",
schema::ColumnName(table_index_, column_index),
schema::TableName(table_index_));
return true;
return false;
}
output_bind_count_++;
- UPLL_LOG_TRACE("Successfully Bind Output for Column(%s) in Table(%s)",
+ UPLL_LOG_VERBOSE("Successfully Bind Output for Column(%s) in Table(%s)",
schema::ColumnName(table_index_, column_index),
schema::TableName(table_index_));
return true;
return false;
}
match_bind_count_++;
- UPLL_LOG_TRACE("Successfully Bind Match for Column(%s) in Table(%s)",
+ UPLL_LOG_VERBOSE("Successfully Bind Match for Column(%s) in Table(%s)",
schema::ColumnName(table_index_, column_index),
schema::TableName(table_index_));
return true;
// Copy result from DB to Appln buffer
bool
DalBindInfo::CopyResultToApp(void) {
- UPLL_FUNC_TRACE;
DalBindList::iterator iter;
DalBindColumnInfo *col_info = NULL;
}
}
- UPLL_LOG_TRACE("Succesfully copied result for all Columns bound for output "
+ UPLL_LOG_VERBOSE("Succesfully copied result for all Columns bound for output "
"in Table(%s)", schema::TableName(table_index_));
return true;
} // DalBindInfo::CopyResultToApp
// Copy result from DB to Appln buffer
bool
DalBindInfo::ResetDalOutBuffer(void) {
- UPLL_FUNC_TRACE;
DalBindList::iterator iter;
DalBindColumnInfo *col_info = NULL;
}
}
}
- UPLL_LOG_TRACE("Succesfully reset DAL output buffer for all Columns bound "
+ UPLL_LOG_VERBOSE("Succesfully reset DAL output buffer for all Columns bound "
"for output in Table(%s)", schema::TableName(table_index_));
return true;
} // DalBindInfo::ResetDalOutBuffer
schema::TableName(table_index_));
return false;
}
- UPLL_LOG_TRACE("Successfully Updated Column Info for Column(%s) in Table(%s)",
- schema::ColumnName(table_index_, column_index),
- schema::TableName(table_index_));
+ UPLL_LOG_VERBOSE("Successfully Updated Column Info for Column(%s) in "
+ "Table(%s)", schema::ColumnName(table_index_, column_index),
+ schema::TableName(table_index_));
return true;
} // DalBindInfo::BindAttribute
// Methods for Debugging and Testing
-void
-DalBindInfo::PrintBindList(void) {
+std::string
+DalBindInfo::BindListToStr(void) {
DalBindList::iterator iter;
DalBindColumnInfo *col_info = NULL;
std::stringstream ss;
}
}
ss << "\n*************************************\n";
- UPLL_LOG_DEBUG("\n%s", ss.str().c_str());
- return;
-} // DalBindInfo::PrintBindList
+ return (ss.str());
+} // DalBindInfo::BindListToStr
+
+std::string
+DalBindInfo::BindListInputToStr(void) {
+ DalBindList::iterator iter;
+ DalBindColumnInfo *col_info = NULL;
+ std::stringstream ss;
+
+ if (input_bind_count_ == 0 &&
+ output_bind_count_ == 0 &&
+ match_bind_count_ == 0) {
+ UPLL_LOG_DEBUG("No Columns in Table(%s) bound for Input/Ouput/Match",
+ schema::TableName(table_index_));
+ }
+
+ ss << "\n*************************************"
+ << "\n* Input data for Table - "
+ << schema::TableName(table_index_);
+ ss << "\n*************************************";
+
+ for (iter = bind_list_.begin();
+ iter != bind_list_.end();
+ ++iter) {
+ col_info = reinterpret_cast<DalBindColumnInfo *>(*iter);
+ ss << "\n" << col_info->ColInfoInputToStr(table_index_).c_str();
+ }
+ ss << "\n*************************************";
+ return (ss.str());
+} // DalBindInfo::BindListInputToStr
+
+std::string
+DalBindInfo::BindListResultToStr(void) {
+ DalBindList::iterator iter;
+ DalBindColumnInfo *col_info = NULL;
+ std::stringstream ss;
+
+ if (output_bind_count_ == 0) {
+ UPLL_LOG_DEBUG("No Columns in Table(%s) bound for Ouput",
+ schema::TableName(table_index_));
+ }
+
+ ss << "\n*************************************"
+ << "\n* Result Data for Table - "
+ << schema::TableName(table_index_);
+ ss << "\n*************************************";
+ ss << "\n{ ";
+
+ for (iter = bind_list_.begin();
+ iter != bind_list_.end();
+ ++iter) {
+ col_info = reinterpret_cast<DalBindColumnInfo *>(*iter);
+ ss << col_info->ColInfoResultToStr(table_index_).c_str();
+ }
+ ss << "}";
+ ss << "\n*************************************";
+ UPLL_LOG_VERBOSE("\n%s", ss.str().c_str());
+ return (ss.str());
+} // DalBindInfo::BindListResultToStr
} // namespace dal
} // namespace upll
bool ResetDalOutBuffer();
/* Only for Debugging and Testing */
- void PrintBindList();
+ std::string BindListToStr();
+ std::string BindListInputToStr();
+ std::string BindListResultToStr();
private:
// Initialize the bind list for all columns with default values
* Implementation of methods in DalCursor
*/
+#include "uncxx/upll_log.hh"
#include "dal_error_handler.hh"
#include "dal_cursor.hh"
// If has_two_handles is true, do SQLFetch from both the handles
DalResultCode
DalCursor::GetNextRecord() const {
- UPLL_FUNC_TRACE;
DalResultCode dal_rc;
if (stmt_handle_1_ == SQL_NULL_HANDLE) {
// Close Cursor
DalResultCode
DalCursor::CloseCursor(bool delete_bind) {
- UPLL_FUNC_TRACE;
DalResultCode dal_rc_1 = kDalRcSuccess;
DalResultCode dal_rc_2 = kDalRcSuccess;
UPLL_LOG_DEBUG("Failed to copy result");
return kDalRcGeneralError;
}
+ UPLL_LOG_TRACE("%s",
+ ((const_cast<DalBindInfo *>(bind_info))->BindListResultToStr()).c_str());
UPLL_LOG_TRACE("Success Fetching record from Stmt Handle");
return kDalRcSuccess;
} // DalCursor::GetNextRecordFromStmt
#define __DAL_CURSOR_HH__
#include <sql.h>
-#include "upll/upll_log.hh"
#include "dal_defines.hh"
#include "dal_bind_info.hh"
* @return void - None
*/
~DalCursor() {
- if (stmt_handle_1_ != SQL_NULL_HANDLE) {
+ if (stmt_handle_1_ != NULL) {
SQLFreeHandle(SQL_HANDLE_STMT, stmt_handle_1_);
}
- if (stmt_handle_2_ != SQL_NULL_HANDLE) {
+ if (stmt_handle_2_ != NULL) {
SQLFreeHandle(SQL_HANDLE_STMT, stmt_handle_2_);
}
}
* @return DalResultCode - kDalRcSuccess in case of success
* - Valid errorcode otherwise
* On successful execution, both the
- * configurations have same records.
+ * configurations have same records
*
* Note:
* Information on Copy Logic
const DalTableIndex table_index,
const DalBindInfo *output_and_match_attr_info) const = 0;
+ /**
+ * CopyModifiedInsertRecords
+ * Inserts the additional records of table from source configuration to
+ * destination configuration.
+ *
+ * @param[in] dest_cfg_type - Configuration Type where the records to be
+ * copied (not equal to src_cfg_type)
+ * @param[in] src_cfg_type - Configuration Type from where the records
+ * will be copied (not equal to dest_cfg_type)
+ * @param[in] table_index - Valid Index of the table
+ * @param[in] output_and_match_attr_info
+ * - Bind Information for output and match
+ * - columns
+ *
+ * @return DalResultCode - kDalRcSuccess in case of success
+ * - Valid errorcode otherwise
+ * On successful execution, both the
+ * configurations have same records.
+ *
+ * Note:
+ * Information on Copy Logic
+ * 1. Add the records in dest_cfg_type that are result of
+ * GetCreatedRecords(dest_cfg_type, src_cfg_type, ...)
+ *
+ * Information on usage of DalBindInfo
+ * 1. Valid instance of DalBindInfo with same table_index used in this API
+ * 2. BindInput if used for any attributes, ignored.
+ * 3. BindMatch if used for any attributes, ignored.
+ * 4. BindOutput is optional.
+ * BindOutput, if used, copy the values of bound columns from
+ * src_cfg_type to dst_cfg_type
+ * BindOutput, if not used, copy the values of all columns from
+ * src_cfg_type to dst_cfg_type
+ * Since the bound value is not used for this API, it is ok to bind
+ * dummy address. Do not pass NULL address.
+ *
+ */
+ virtual DalResultCode CopyModifiedInsertRecords(
+ const UpllCfgType dest_cfg_type,
+ const UpllCfgType src_cfg_type,
+ const DalTableIndex table_index,
+ const DalBindInfo *output_and_match_attr_info) const = 0;
+
/**
* CopyMatchingRecords
* Copies all the matching records of table from source configuration to
const DalTableIndex table_index,
const DalBindInfo *matching_attr_info,
bool *identical) const = 0;
+
+ /**
+ * ExecuteAppQuerySingleRecord
+ * Execute the user supplied query statement to generate single record as
+ * output
+ *
+ * @param[in] query_stmt - User supplied executable query statement
+ * @param[in] bind_info - Corresponding bind information for the query
+ *
+ * @return DalResultCode - kDalRcSuccess in case of success
+ * - Valid errorcode otherwise
+ */
+ virtual DalResultCode ExecuteAppQuerySingleRecord(
+ const std::string query_stmt,
+ const DalBindInfo *bind_info) const = 0;
+ /**
+ * ExecuteAppQueryMultipleRecords
+ * Execute the user supplied query statement to generate multiple records
+ * in a given cursor as output
+ *
+ * @param[in] query_stmt - User supplied executable query statement
+ * @param[in] bind_info - Corresponding bind information for the query
+ * @param[in] max_record_count- Count of output records expected from the
+ * user.
+ * @param[in/out] cursor - reference to the unallocated DalCursor
+ * pointer
+ * - Output - cursor pointer with valid instance
+ * of DalCursor
+ *
+ * @return DalResultCode - kDalRcSuccess in case of success
+ * - Valid errorcode otherwise
+ */
+ virtual DalResultCode ExecuteAppQueryMultipleRecords(
+ const std::string query_stmt,
+ const size_t max_record_count,
+ const DalBindInfo *bind_info,
+ DalCursor **cursor) const = 0;
}; // class DalDmlIntf
}; // namespace dal
#include <stdint.h>
#include <cstring>
-#include "upll/upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "dal_error_handler.hh"
namespace unc {
*/
#include "pfcxx/module.hh"
-#include "upll/upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "dal_error_handler.hh"
#include "dal_module.hh"
#include <sstream>
#include "pfcxx/module.hh"
-#include "upll/upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "dal_odbc_mgr.hh"
#include "dal_query_builder.hh"
#include "dal_error_handler.hh"
DalOdbcMgr::DalOdbcMgr() {
dal_env_handle_ = SQL_NULL_HANDLE;
dal_conn_handle_ = SQL_NULL_HANDLE;
+ conn_type_ = kDalConnReadOnly;
}
/* Desctructor */
DalResultCode dal_rc;
// PFC_ASSERT(dal_env_handle_);
+ conn_type_ = conn_type;
+
if (dal_conn_handle_ == NULL) {
UPLL_LOG_DEBUG("NULL Connection Handle");
return kDalRcGeneralError;
return kDalRcGeneralError;
}
UPLL_LOG_TRACE("Copied result to the DAL User Buffer");
+ UPLL_LOG_TRACE("%s",
+ ((const_cast<DalBindInfo *>(bind_info))->BindListResultToStr()).c_str());
FreeHandle(SQL_HANDLE_STMT, dal_stmt_handle);
return kDalRcSuccess;
"\n Query - %s; Bind - %s",
schema::TableName(table_index),
schema::TableName(bind_info->get_table_index()));
+ return kDalRcGeneralError;
}
// Build Query Statement
// Allocate Stmt Handle, Bind and Execute the Query Statement
dal_rc = ExecuteQuery(&dal_stmt_handle,
- &query_stmt);
+ &query_stmt, bind_info);
if (dal_rc != kDalRcSuccess) {
UPLL_LOG_DEBUG("Err - %d. Failed Executing Query Stmt - %s",
"\n Query - %s; Bind - %s",
schema::TableName(table_index),
schema::TableName(bind_info->get_table_index()));
+ return kDalRcGeneralError;
}
// Delete deleted records from dst
// Allocate Stmt Handle, Bind and Execute the Query Statement
dal_rc = ExecuteQuery(&dal_stmt_handle,
- &query_stmt);
+ &query_stmt, bind_info);
if (dal_rc != kDalRcSuccess && dal_rc != kDalRcRecordNotFound) {
UPLL_LOG_DEBUG("Err - %d. Failed Executing Query Stmt - %s",
}
dal_rc = ExecuteQuery(&dal_stmt_handle,
- &query_stmt);
+ &query_stmt, bind_info);
if (dal_rc != kDalRcSuccess && dal_rc != kDalRcRecordNotFound) {
UPLL_LOG_DEBUG("Err - %d. Failed Executing Query Stmt - %s",
}
dal_rc = ExecuteQuery(&dal_stmt_handle,
- &query_stmt);
+ &query_stmt, bind_info);
if (dal_rc != kDalRcSuccess && dal_rc != kDalRcRecordNotFound) {
UPLL_LOG_DEBUG("Err - %d. Failed Executing Query Stmt - %s",
return kDalRcSuccess;
} // DalOdbcMgr::CopyModifiedRecords
+// Copies only the modified records from dst to src cfg_type
+DalResultCode
+DalOdbcMgr::CopyModifiedInsertRecords(const UpllCfgType dest_cfg_type,
+ const UpllCfgType src_cfg_type,
+ const DalTableIndex table_index,
+ const DalBindInfo *bind_info) const {
+ SQLHANDLE dal_stmt_handle = SQL_NULL_HANDLE;
+ DalResultCode dal_rc;
+ DalQueryBuilder qbldr;
+ std::string query_stmt;
+
+ // Validating Inputs
+ if (dest_cfg_type == UPLL_DT_INVALID || src_cfg_type == UPLL_DT_INVALID) {
+ UPLL_LOG_DEBUG("Invalid Config Type - %d %d", dest_cfg_type, src_cfg_type);
+ return kDalRcGeneralError;
+ }
+
+ if (dest_cfg_type == src_cfg_type) {
+ UPLL_LOG_DEBUG("Same Config Type - %d %d", dest_cfg_type, src_cfg_type);
+ return kDalRcGeneralError;
+ }
+
+ if (table_index >= schema::table::kDalNumTables) {
+ UPLL_LOG_DEBUG("Invalid Table Index - %d", table_index);
+ return kDalRcGeneralError;
+ }
+
+ // No need to validate bindinfo
+ // BindInput - NA; BindOuput - O; BindMatch - O;
+ if (bind_info != NULL && table_index != bind_info->get_table_index()) {
+ UPLL_LOG_DEBUG("Table Index Mismatch with bind info "
+ "\n Query - %s; Bind - %s",
+ schema::TableName(table_index),
+ schema::TableName(bind_info->get_table_index()));
+ return kDalRcGeneralError;
+ }
+
+ // Insert created records to dst
+ if (qbldr.get_sql_statement(kDalCopyModRecCreateQT, bind_info, query_stmt,
+ table_index, dest_cfg_type, src_cfg_type) != true) {
+ UPLL_LOG_TRACE("Failed Building Query Stmt");
+ return kDalRcGeneralError;
+ } else {
+ UPLL_LOG_DEBUG("Query Stmt - %s", query_stmt.c_str());
+ }
+
+ dal_rc = ExecuteQuery(&dal_stmt_handle,
+ &query_stmt, bind_info);
+
+ if (dal_rc != kDalRcSuccess && dal_rc != kDalRcRecordNotFound) {
+ UPLL_LOG_DEBUG("Err - %d. Failed Executing Query Stmt - %s",
+ dal_rc, query_stmt.c_str());
+ if (dal_stmt_handle != SQL_NULL_HANDLE) {
+ FreeHandle(SQL_HANDLE_STMT, dal_stmt_handle);
+ }
+ return dal_rc;
+ }
+ FreeHandle(SQL_HANDLE_STMT, dal_stmt_handle);
+ UPLL_LOG_TRACE("Completed Executing Query Stmt - %s",
+ query_stmt.c_str());
+ return kDalRcSuccess;
+} // DalOdbcMgr::CopyModifiedInsertRecords
+
// Copies the matching records from dst to src cfg_type
DalResultCode
DalOdbcMgr::CopyMatchingRecords(const UpllCfgType dest_cfg_type,
// Allocate Stmt Handle, Bind and Execute the Query Statement
dal_rc = ExecuteQuery(&dal_stmt_handle,
- &query_stmt);
+ &query_stmt,
+ bind_info);
if (dal_rc != kDalRcSuccess) {
UPLL_LOG_DEBUG("Err - %d. Failed Executing Query Stmt - %s",
return kDalRcSuccess;
} // DalOdbcMgr::CheckRecordsIdentical
+// Executes User supplied query and returns single record in the result set
+DalResultCode
+DalOdbcMgr::ExecuteAppQuerySingleRecord(
+ const std::string query_stmt,
+ const DalBindInfo *bind_info) const {
+ SQLHANDLE dal_stmt_handle = SQL_NULL_HANDLE;
+ SQLRETURN sql_rc;
+ DalResultCode dal_rc;
+
+ // Validating Inputs
+ if (query_stmt.size() == 0) {
+ UPLL_LOG_DEBUG("Empty Query Stmt string");
+ return kDalRcGeneralError;
+ }
+
+ // PFC_ASSERT(bind_info)
+ if (bind_info == NULL) {
+ UPLL_LOG_DEBUG("NULL Bind Info");
+ return kDalRcGeneralError;
+ }
+
+ // Allocate Stmt Handle, Bind and Execute the Query Statement
+ dal_rc = ExecuteQuery(&dal_stmt_handle, &query_stmt, bind_info);
+ if (dal_rc != kDalRcSuccess) {
+ UPLL_LOG_DEBUG("Err - %d. Failed Executing Query Stmt - %s",
+ dal_rc, query_stmt.c_str());
+ FreeHandle(SQL_HANDLE_STMT, dal_stmt_handle);
+ return dal_rc;
+ }
+ UPLL_LOG_TRACE("Completed Executing Query Stmt - %s", query_stmt.c_str());
+
+ // Fetching results from the resultset
+ sql_rc = SQLFetch(dal_stmt_handle);
+ DalErrorHandler::ProcessOdbcErrors(SQL_HANDLE_STMT,
+ dal_stmt_handle,
+ sql_rc, &dal_rc);
+ if (dal_rc != kDalRcSuccess) {
+ UPLL_LOG_DEBUG("%d - Failed to Fetch result", dal_rc);
+ FreeHandle(SQL_HANDLE_STMT, dal_stmt_handle);
+ return dal_rc;
+ }
+ UPLL_LOG_TRACE("Result fetched from DB");
+
+ if (const_cast<DalBindInfo*>(bind_info)->CopyResultToApp() != true) {
+ UPLL_LOG_DEBUG("Failed to Copy result to the DAL User Buffer");
+ FreeHandle(SQL_HANDLE_STMT, dal_stmt_handle);
+ return kDalRcGeneralError;
+ }
+ UPLL_LOG_TRACE("Copied result to the DAL User Buffer");
+ UPLL_LOG_TRACE("%s",
+ ((const_cast<DalBindInfo *>(bind_info))->BindListResultToStr()).c_str());
+
+ FreeHandle(SQL_HANDLE_STMT, dal_stmt_handle);
+ return kDalRcSuccess;
+} // DalOdbcMgr::ExecuteAppQuerySingleRecord
+
+// Executes user given query resulting multiple records in the result set
+DalResultCode
+DalOdbcMgr::ExecuteAppQueryMultipleRecords(
+ const std::string query_stmt,
+ const size_t max_record_count,
+ const DalBindInfo *bind_info,
+ DalCursor **cursor) const {
+ SQLHANDLE dal_stmt_handle = SQL_NULL_HANDLE;
+ DalResultCode dal_rc;
+
+ // Validating Inputs
+ if (query_stmt.size() == 0) {
+ UPLL_LOG_DEBUG("Empty Query Stmt string");
+ return kDalRcGeneralError;
+ }
+
+ // PFC_ASSERT(bind_info)
+ if (bind_info == NULL) {
+ UPLL_LOG_DEBUG("NULL Bind Info");
+ return kDalRcGeneralError;
+ }
+
+ // Allocate Stmt Handle, Bind and Execute the Query Statement
+ dal_rc = ExecuteQuery(&dal_stmt_handle,
+ &query_stmt,
+ bind_info,
+ max_record_count);
+
+ if (dal_rc != kDalRcSuccess) {
+ UPLL_LOG_DEBUG("Err - %d. Failed Executing Query Stmt - %s",
+ dal_rc, query_stmt.c_str());
+ FreeHandle(SQL_HANDLE_STMT, dal_stmt_handle);
+ return dal_rc;
+ }
+ UPLL_LOG_TRACE("Completed Executing Query Stmt - %s",
+ query_stmt.c_str());
+
+ *cursor = new DalCursor(dal_stmt_handle,
+ bind_info);
+ // PFC_ASSERT(*cursor)
+ if (*cursor == NULL) {
+ UPLL_LOG_DEBUG("Failed to allocate cursor handle for the result");
+ FreeHandle(SQL_HANDLE_STMT, dal_stmt_handle);
+ return kDalRcGeneralError;
+ }
+ UPLL_LOG_TRACE("Allocated cursor handle for the result");
+ return kDalRcSuccess;
+} // DalOdbcMgr::ExecuteAppQueryMultipleRecords
+
// Private Methods of DalOdbcMgr
// Set Connection Attributes
DalResultCode
}
// Printing Bind List for debugging
- (const_cast<DalBindInfo *>(bind_info))->PrintBindList();
+ UPLL_LOG_VERBOSE("%s",
+ ((const_cast<DalBindInfo *>(bind_info))->BindListToStr()).c_str());
+ UPLL_LOG_TRACE("%s",
+ ((const_cast<DalBindInfo *>(bind_info))->BindListInputToStr()).c_str());
// Dont change the order of binding(input, output and match)
// Parameter Indexing is dependant on this ordering.
(*param_idx)++;
}
} // for iter
- UPLL_LOG_TRACE("Input Parameters bound sucessfully to Query");
+ UPLL_LOG_VERBOSE("Input Parameters bound sucessfully to Query");
return dal_rc;
} // DalBindInfo::BindInputToQuery
(*param_idx)++;
}
} // for iter
- UPLL_LOG_TRACE("Output Parameters bound sucessfully to Query");
+ UPLL_LOG_VERBOSE("Output Parameters bound sucessfully to Query");
return dal_rc;
} // DalBindInfo::BindOutputToQuery
(*param_idx)++;
}
} // for iter
- UPLL_LOG_TRACE("Match Parameters bound sucessfully to Query");
+ UPLL_LOG_VERBOSE("Match Parameters bound sucessfully to Query");
return dal_rc;
} // DalBindInfo::BindMatchToQuery
FreeHandle(SQL_HANDLE_STMT, *dal_stmt_handle);
return dal_rc;
}
- UPLL_LOG_TRACE("Success Binding parameters to Query");
+ UPLL_LOG_VERBOSE("Success Binding parameters to Query");
}
// Executing the Query Statement
return dal_rc;
}
- UPLL_LOG_TRACE("Query Successfully Executed %s",
+ UPLL_LOG_VERBOSE("Query Successfully Executed %s",
query_stmt->c_str());
return kDalRcSuccess;
} // DalOdbcMgr::ExecuteQuery
* ConnectToDb
* Connects to the DB with the connection parameters from conf file.
*
- * @param[in] conn_type - Type of the connection (Read-Only or Read/Write)
+ * @param[in] conn_type - Type of the connection
+ * (Read-Only or Read/Write)
*
* @return DalResultCode - kDalRcSuccess in case of success
* - Valid errorcode otherwise
*/
DalResultCode DisconnectFromDb() const;
+ inline DalConnType get_conn_type() { return conn_type_; }
+
/**
* CommitTransaction
* Commits all the pending changes in the database for the correpsonding
const DalTableIndex table_index,
const DalBindInfo *output_and_match_attr_info) const;
+ /**
+ * CopyModifiedInsertRecords
+ * Inserts the additional records of table from source configuration to
+ * destination configuration.
+ *
+ * @param[in] dest_cfg_type - Configuration Type where the records to be
+ * copied (not equal to src_cfg_type)
+ * @param[in] src_cfg_type - Configuration Type from where the records
+ * will be copied (not equal to dest_cfg_type)
+ * @param[in] table_index - Valid Index of the table
+ * @param[in] output_and_match_attr_info
+ * - Bind Information for output and match
+ * - columns
+ *
+ * @return DalResultCode - kDalRcSuccess in case of success
+ * - Valid errorcode otherwise
+ * On successful execution, both the
+ * configurations have same records.
+ *
+ * Note:
+ * Information on Copy Logic
+ * 1. Add the records in dest_cfg_type that are result of
+ * GetCreatedRecords(dest_cfg_type, src_cfg_type, ...)
+ *
+ * Information on usage of DalBindInfo
+ * 1. Valid instance of DalBindInfo with same table_index used in this API
+ * 2. BindInput if used for any attributes, ignored.
+ * 3. BindMatch if used for any attributes, ignored.
+ * 4. BindOutput is optional.
+ * BindOutput, if used, copy the values of bound columns from
+ * src_cfg_type to dst_cfg_type
+ * BindOutput, if not used, copy the values of all columns from
+ * src_cfg_type to dst_cfg_type
+ * Since the bound value is not used for this API, it is ok to bind
+ * dummy address. Do not pass NULL address.
+ *
+ */
+ DalResultCode CopyModifiedInsertRecords(
+ const UpllCfgType dest_cfg_type,
+ const UpllCfgType src_cfg_type,
+ const DalTableIndex table_index,
+ const DalBindInfo *output_and_match_attr_info) const;
+
/**
* CopyMatchingRecords
* Copies all the matching records of table from source configuration to
const DalTableIndex table_index,
const DalBindInfo *matching_attr_info,
bool *identical) const;
-
+ /**
+ * ExecuteAppQuerySingleRecord
+ * Execute the user supplied query statement to generate single record as
+ * output
+ *
+ * @param[in] query_stmt - User supplied executable query statement
+ * @param[in] bind_info - Corresponding bind information for the query
+ *
+ * @return DalResultCode - kDalRcSuccess in case of success
+ * - Valid errorcode otherwise
+ */
+ DalResultCode ExecuteAppQuerySingleRecord(
+ const std::string query_stmt,
+ const DalBindInfo *bind_info) const;
+ /**
+ * ExecuteAppQueryMultipleRecords
+ * Execute the user supplied query statement to generate multiple records
+ * in a given cursor as output
+ *
+ * @param[in] query_stmt - User supplied executable query statement
+ * @param[in] bind_info - Corresponding bind information for the query
+ * @param[in] max_record_count- Count of output records expected from the
+ * user.
+ * @param[in/out] cursor - reference to the unallocated DalCursor
+ * pointer
+ * - Output - cursor pointer with valid instance
+ * of DalCursor
+ *
+ * @return DalResultCode - kDalRcSuccess in case of success
+ * - Valid errorcode otherwise
+ */
+ DalResultCode ExecuteAppQueryMultipleRecords(
+ const std::string query_stmt,
+ const size_t max_record_count,
+ const DalBindInfo *bind_info,
+ DalCursor **cursor) const;
private:
/**
* SetConnAttributes
* Sets necessary attributes for the connection from the configuration file
*
- * @param[in] conn_handle - Valid connection handle before conencting to DB
+ * @param[in] conn_handle - Valid connection handle before connecting
+ * to DB
* @param[in] conn_type - Type of the connection
* (Read-Only or Read/Write)
*
/**
* SetCursorAttributes
- * Sets necessary cursor properites for the statement from the configuration file
+ * Sets necessary cursor properites for the statement from the
+ * configuration file
*
* @param[in] stmt_handle - Valid Statment handle before binding query
* @return DalResultCode - kDalRcSuccess in case of success
SQLHANDLE dal_env_handle_; // Environment Handle
SQLHANDLE dal_conn_handle_; // Connection Handle
+ mutable DalConnType conn_type_; // Connection Type
}; // class DalOdbcMgr
} // namespace dal
* Author: guest
*/
-#include "upll/upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "dal_query_builder.hh"
// #include "/home/guest/BuildEnv/src/core/include/cxx/pfcxx/synch.hh"
"UPDATE {config1_table_name} SET {mand_in_columns_with_?}"
" {opt_WHERE_match_columns_eq}";
+#if 0
const char * DalQueryBuilder::DalGetDelRecQT =
"SELECT {mand_out_columns} FROM {config2_table_name}"
" WHERE ({mand_match_columns}) NOT IN"
"SELECT {mand_out_columns} FROM {config1_table_name}"
" WHERE ({mand_match_columns}) NOT IN"
" ( SELECT {mand_match_columns} FROM {config2_table_name})";
+#endif
+const char * DalQueryBuilder::DalGetDelRecQT =
+ "SELECT {mand_out_columns} FROM {config2_table_name} AS temp"
+ " WHERE NOT EXISTS"
+ " ( SELECT {mand_match_columns} FROM {config1_table_name}"
+ " {mand_match_columns_eq_with_temp})";
+
+const char * DalQueryBuilder::DalGetCreatedRecQT =
+ "SELECT {mand_out_columns} FROM {config1_table_name} AS temp"
+ " WHERE NOT EXISTS"
+ " ( SELECT {mand_match_columns} FROM {config2_table_name}"
+ " {mand_match_columns_eq_with_temp})";
const char * DalQueryBuilder::DalGetModRecQT =
"SELECT {mand_out_columns} FROM {config1_table_name}"
" ( SELECT {opt_match_columns} FROM {config2_table_name} EXCEPT"
" SELECT {opt_match_columns} FROM {config1_table_name}"
" ) as temp"
- " )";
+ " ) ORDER BY ({primary_key_columns})";
const char * DalQueryBuilder::DalCopyEntireRecQT =
"DELETE FROM {dst_table_name};"
"{opt_WHERE_match_columns_eq_not_last}";
const char * DalQueryBuilder::DalMandMatchColLstGtrExpr =
"{mand_WHERE_match_columns_last_greater}";
+const char * DalQueryBuilder::DalMandMatchColEqTempExpr =
+ "{mand_match_columns_eq_with_temp}";
// Primary Key related tokens
const char * DalQueryBuilder::DalPkeyColNames = "{primary_key_columns}";
return kDalOptMatchColEqNotLastExpr;
} else if (tokenstr.compare(DalMandMatchColLstGtrExpr) == 0) {
return kDalMandMatchColLstGtrExpr;
+ } else if (tokenstr.compare(DalMandMatchColEqTempExpr) == 0) {
+ return kDalMandMatchColEqTempExpr;
// Primary Key Related tokens
} else if (tokenstr.compare(DalPkeyColNames) == 0) {
}
break;
+ // {mand_match_columns_eq_with_temp}
+ // col1 = temp.col1 AND col2 = temp.col2 ...
+ // For all match columns in bind list
+ case kDalMandMatchColEqTempExpr:
+ if (dbi == NULL) {
+ UPLL_LOG_INFO("Null Bind Info for Mandatory token");
+ return false;
+ }
+
+ if (dbi->get_match_bind_count() == 0) {
+ UPLL_LOG_INFO("No columns bound for Mandatory Match");
+ return false;
+ }
+
+ // Building string for attributes bound for match
+ if (dbi->get_match_bind_count() > 0)
+ replc_str += std::string("WHERE ");
+
+ bind_list = dbi->get_bind_list();
+ for (bl_it = bind_list.begin(); bl_it != bind_list.end(); ++bl_it) {
+ col_info = *bl_it;
+ io_type = col_info->get_io_type();
+ if (io_type == kDalIoMatchOnly ||
+ io_type == kDalIoInputAndMatch ||
+ io_type == kDalIoOutputAndMatch) {
+ if (first != true)
+ replc_str += std::string(" AND ");
+
+ if (first)
+ first = false;
+
+ replc_str += std::string(schema::ColumnName(
+ table_index,
+ col_info->get_column_index()));
+ replc_str += std::string(" = temp.");
+ replc_str += std::string(schema::ColumnName(
+ table_index,
+ col_info->get_column_index()));
+
+ } // if
+ col_count++;
+ } // for
+ break;
+
// {match_dst_primary_key_columns_eq_with_temp} - col1, col2, ...
// <dst_table>.col1 = temp.col1 AND <dst_table>.col2 = temp.col2 ...
// For all primary key column names of the table
kDalOptMatchColEqExpr,
kDalOptMatchColEqNotLastExpr,
kDalMandMatchColLstGtrExpr,
+ kDalMandMatchColEqTempExpr,
// Enum for Primary Key Related Tokens
kDalPkeyColNames,
// n is the number of attributes bound for match
// column names of attributes bound for match
static const char * DalMandMatchColLstGtrExpr;
+ // {mand_match_columns_eq_with_temp}
+ // col1 = temp.col1 AND col2 = temp.col2 ...
+ // For all match columns in bind list
+ static const char * DalMandMatchColEqTempExpr;
+ // {match_dst_primary_key_columns_eq_with_temp} - col1, col2, ...
+ // <dst_table>.col1 = temp.col1 AND <dst_table>.col2 = temp.col2 ...
+ // For all primary key column names of the table
+ static const char * DalMatchPriColEqTempExpr;
// Primary Key Related Tokens
// {primary_key_columns} - col1, col2, ...
// All primary key column names of the table
static const char * DalPkeyColNames;
- // {match_dst_primary_key_columns_eq_with_temp} - col1, col2, ...
- // <dst_table>.col1 = temp.col1 AND <dst_table>.col2 = temp.col2 ...
- // For all primary key column names of the table
- static const char * DalMatchPriColEqTempExpr;
// Table Related Tokens
// {config1_table_name} - <config1>_<table_name>
{"valid_logical_port_id", SQL_SMALLINT, SQL_C_SHORT, 1},
{"valid_vlanid", SQL_SMALLINT, SQL_C_SHORT, 1},
{"valid_tagged", SQL_SMALLINT, SQL_C_SHORT, 1},
+ {"valid_vex_name", SQL_SMALLINT, SQL_C_SHORT, 1},
+ {"valid_vex_if_name", SQL_SMALLINT, SQL_C_SHORT, 1},
+ {"valid_vex_link_name", SQL_SMALLINT, SQL_C_SHORT, 1},
{"valid_oper_status", SQL_SMALLINT, SQL_C_SHORT, 1},
{"cs_rowstatus", SQL_SMALLINT, SQL_C_SHORT, 1},
{"cs_admin_status", SQL_SMALLINT, SQL_C_SHORT, 1},
{"controller2_name", SQL_VARCHAR, SQL_C_CHAR, 32},
{"domain1_id", SQL_VARCHAR, SQL_C_CHAR, 32},
{"domain2_id", SQL_VARCHAR, SQL_C_CHAR, 32},
- {"flags", SQL_SMALLINT, SQL_C_SHORT, 1},
+ {"key_flags", SQL_SMALLINT, SQL_C_SHORT, 1},
+ {"val_flags", SQL_SMALLINT, SQL_C_SHORT, 1},
{"valid_admin_status", SQL_SMALLINT, SQL_C_SHORT, 1},
{"valid_vnode1_name", SQL_SMALLINT, SQL_C_SHORT, 1},
{"valid_vnode1_ifname", SQL_SMALLINT, SQL_C_SHORT, 1},
{"vrouter_name", SQL_VARCHAR, SQL_C_CHAR, 32},
{"dst_ip_addr", SQL_BINARY, SQL_C_BINARY, 4},
{"mask", SQL_SMALLINT, SQL_C_SHORT, 1},
- {"nwm_name", SQL_VARCHAR, SQL_C_CHAR, 32},
{"next_hop_addr", SQL_BINARY, SQL_C_BINARY, 4},
+ {"nwm_name", SQL_VARCHAR, SQL_C_CHAR, 32},
{"metric", SQL_INTEGER, SQL_C_ULONG, 1},
{"controller_name", SQL_VARCHAR, SQL_C_CHAR, 32},
{"domain_id", SQL_VARCHAR, SQL_C_CHAR, 32},
{"logical_port_id", SQL_VARCHAR, SQL_C_CHAR, 320},
{"vlanid", SQL_INTEGER, SQL_C_ULONG, 1},
{"tagged", SQL_SMALLINT, SQL_C_SHORT, 1},
- {"vex_name", SQL_VARCHAR, SQL_C_CHAR, 32},
- {"vex_if_name", SQL_VARCHAR, SQL_C_CHAR, 32},
- {"vex_link_name", SQL_VARCHAR, SQL_C_CHAR, 32},
{"oper_status", SQL_SMALLINT, SQL_C_SHORT, 1},
{"down_count", SQL_BIGINT, SQL_C_UBIGINT, 1},
{"controller_name", SQL_VARCHAR, SQL_C_CHAR, 32},
{"controller_name", SQL_VARCHAR, SQL_C_CHAR, 32},
{"description", SQL_VARCHAR, SQL_C_CHAR, 128},
{"flags", SQL_SMALLINT, SQL_C_SHORT, 1},
- {"valid_controller_name", SQL_VARCHAR, SQL_C_CHAR, 32},
- {"valid_description", SQL_VARCHAR, SQL_C_CHAR, 32},
+ {"valid_controller_name", SQL_SMALLINT, SQL_C_SHORT, 1},
+ {"valid_description", SQL_SMALLINT, SQL_C_SHORT, 1},
{"cs_rowstatus", SQL_SMALLINT, SQL_C_SHORT, 1},
- {"cs_controller_name", SQL_VARCHAR, SQL_C_CHAR, 32},
- {"cs_description", SQL_VARCHAR, SQL_C_CHAR, 32}
+ {"cs_controller_name", SQL_SMALLINT, SQL_C_SHORT, 1},
+ {"cs_description", SQL_SMALLINT, SQL_C_SHORT, 1},
};
}
{"domain_id", SQL_VARCHAR, SQL_C_CHAR, 32},
{"underlay_vtn_name", SQL_VARCHAR, SQL_C_CHAR, 32},
{"vtepgrp_name ", SQL_VARCHAR, SQL_C_CHAR, 32},
- {"label", SQL_INTEGER, SQL_C_LONG, 1},
+ {"label", SQL_BIGINT, SQL_C_UBIGINT, 1},
{"oper_status", SQL_SMALLINT, SQL_C_SHORT, 1},
{"down_count", SQL_BIGINT, SQL_C_UBIGINT, 1},
{"flags", SQL_SMALLINT, SQL_C_SHORT, 1},
{"logical_port_id", SQL_VARCHAR, SQL_C_CHAR, 320},
{"vlanid", SQL_INTEGER, SQL_C_ULONG, 1},
{"tagged", SQL_SMALLINT, SQL_C_SHORT, 1},
- {"vex_name", SQL_VARCHAR, SQL_C_CHAR, 32},
- {"vex_if_name", SQL_VARCHAR, SQL_C_CHAR, 32},
- {"vex_link_name", SQL_VARCHAR, SQL_C_CHAR, 32},
{"oper_status", SQL_SMALLINT, SQL_C_SHORT, 1},
{"down_count", SQL_BIGINT, SQL_C_UBIGINT, 1},
{"controller_name", SQL_VARCHAR, SQL_C_CHAR, 32},
kDbiValidLogicalPortId,
kDbiValidVlanid,
kDbiValidTagged,
+ kDbiValidVexName,
+ kDbiValidVexIfName,
+ kDbiValidVexLinkName,
kDbiValidOperStatus,
kDbiCsRowstatus,
kDbiCsAdminStatus,
kDbiCtrlr2Name,
kDbiDomain1Id,
kDbiDomain2Id,
- kDbiFlags,
+ kDbiKeyFlags,
+ kDbiValFlags,
kDbiValidAdminStatus,
kDbiValidVnode1Name,
kDbiValidVnode1Ifname,
kDbiVrouterName,
kDbiDstIpAddr,
kDbiMask,
- kDbiNwmName,
kDbiNextHopAddr,
+ kDbiNwmName,
kDbiMetric,
kDbiCtrlrName,
kDbiDomainId,
kDbiLogicalPortId,
kDbiVlanId,
kDbiTagged,
- kDbiVexName,
- kDbiVexIfName,
- kDbiVexLinkName,
kDbiOperStatus,
kDbiDownCount,
kDbiCtrlrName,
kDbiLogicalPortId,
kDbiVlanId,
kDbiTagged,
- kDbiVexName,
- kDbiVexIfName,
- kDbiVexLinkName,
kDbiOperStatus,
kDbiDownCount,
kDbiCtrlrName,
// Print Copyright
line.clear();
-/*
- * Copyright (c) 2012-2013 NEC Corporation
- * All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this
- * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
- */
+ line += "/*\n"
+ " * Copyright (c) 2012-2013 NEC Corporation\n"
+ " * All rights reserved.\n"
+ " *\n"
+ " * This program and the accompanying materials are made available "
+ "under the\n"
+ " * terms of the Eclipse Public License v1.0 which accompanies this\n"
+ " * distribution, and is available at "
+ "http://www.eclipse.org/legal/epl-v10.html\n"
+ " */\n";
printf("%s", line.c_str());
// Print File Header
if (def_type == kDefaultTypeBinary) {
line += "'";
for (uint16_t i = 0; i < uudschema::ColumnDbArraySize(tbl_idx, col_idx); i++) {
- line+= get_default_str(kCfgIdCandidate, def_type);
+ line+= get_default_str((UpllDbCfgId)cfg_idx, def_type);
}
line += "'";
} else {
- line+= get_default_str(kCfgIdCandidate, def_type);
+ line+= get_default_str((UpllDbCfgId)cfg_idx, def_type);
}
// uinque constraint for rename tables
}
line += uudschema::ColumnName(tbl_idx, col_idx);
}
- line += ")";
-
- // UINQUE constraint on RENAME tables
- if (strstr(uudschema::TableName(tbl_idx), "rename") != NULL) {
- line += ",\n ";
- line += "UNIQUE(";
- first = true;
- for (col_idx = 0; col_idx < uudschema::TableNumCols(tbl_idx); col_idx++) {
- if (col_idx >= uudschema::TableNumPkCols(tbl_idx)) {
- if (first == false) {
- line += ", ";
- } else {
- first = false;
- }
- line += uudschema::ColumnName(tbl_idx, col_idx);
- }
- }
- line += ")";
- }
- line += ");";
+ line += "));";
printf("\n %s", line.c_str());
printf("\n");
} // for all tables
// Print Copyright
line.clear();
-/*
- * Copyright (c) 2012-2013 NEC Corporation
- * All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this
- * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
- */
+ line += "/*\n"
+ " * Copyright (c) 2012-2013 NEC Corporation\n"
+ " * All rights reserved.\n"
+ " *\n"
+ " * This program and the accompanying materials are made available "
+ "under the\n"
+ " * terms of the Eclipse Public License v1.0 which accompanies this\n"
+ " * distribution, and is available at "
+ "http://www.eclipse.org/legal/epl-v10.html\n"
+ " */\n";
printf("%s", line.c_str());
// Print File Header
valid_last_updated_time smallint default 0,
cs_rowstatus smallint default 3,
cs_description smallint default 3,
- Primary Key(vtn_name));
+ PRIMARY KEY(vtn_name));
CREATE TABLE su_vtn_ctrlr_tbl (
vtn_name varchar(32) default ' ',
valid_alarm_status smallint default 0,
cs_rowstatus smallint default 3,
cs_description smallint default 3,
- Primary Key(vtn_name, controller_name, domain_id));
+ PRIMARY KEY(vtn_name, controller_name, domain_id));
CREATE TABLE su_vtn_rename_tbl (
ctrlr_vtn_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
- unc_vtn_name varchar(32) default ' ' unique,
- Primary Key(ctrlr_vtn_name, controller_name, domain_id));
+ unc_vtn_name varchar(32) default ' ',
+ PRIMARY KEY(ctrlr_vtn_name, controller_name, domain_id));
CREATE TABLE su_vbr_tbl (
vtn_name varchar(32) default ' ',
cs_host_addr smallint default 3,
cs_host_addr_mask smallint default 3,
flags smallint default 0,
- Primary Key(vtn_name, vbridge_name));
+ PRIMARY KEY(vtn_name, vbridge_name));
CREATE TABLE su_vbr_vlanmap_tbl (
vtn_name varchar(32) default ' ',
vbridge_name varchar(32) default ' ',
logical_port_id varchar(320) default ' ',
- logical_port_id_valid varchar(320) default ' ',
- vlanid smallint default 0,
+ logical_port_id_valid smallint default 0,
+ vlanid integer default 0,
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
valid_vlanid smallint default 0,
cs_rowstatus smallint default 3,
cs_vlanid smallint default 3,
- Primary Key(vtn_name, vbridge_name, logical_port_id, logical_port_id_valid));
+ PRIMARY KEY(vtn_name, vbridge_name, logical_port_id, logical_port_id_valid));
CREATE TABLE su_vbr_if_tbl (
vtn_name varchar(32) default ' ',
valid_logical_port_id smallint default 0,
valid_vlanid smallint default 0,
valid_tagged smallint default 0,
+ valid_vex_name smallint default 0,
+ valid_vex_if_name smallint default 0,
+ valid_vex_link_name smallint default 0,
valid_oper_status smallint default 0,
cs_rowstatus smallint default 3,
cs_admin_status smallint default 3,
cs_logical_port_id smallint default 3,
cs_vlanid smallint default 3,
cs_tagged smallint default 3,
- Primary Key(vtn_name, vbridge_name, if_name));
+ PRIMARY KEY(vtn_name, vbridge_name, if_name));
CREATE TABLE su_vrt_tbl (
vtn_name varchar(32) default ' ',
cs_domain_id smallint default 3,
cs_vrt_description smallint default 3,
cs_dhcprelay_admin_status smallint default 3,
- Primary Key(vtn_name, vrouter_name));
+ PRIMARY KEY(vtn_name, vrouter_name));
CREATE TABLE su_vrt_if_tbl (
vtn_name varchar(32) default ' ',
cs_mask smallint default 3,
cs_mac_addr smallint default 3,
cs_admin_status smallint default 3,
- Primary Key(vtn_name, vrouter_name, if_name));
+ PRIMARY KEY(vtn_name, vrouter_name, if_name));
CREATE TABLE su_vnode_rename_tbl (
ctrlr_vtn_name varchar(32) default ' ',
ctrlr_vnode_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
- unc_vtn_name varchar(32) default ' ' unique,
- unc_vnode_name varchar(32) default ' ' unique,
- Primary Key(ctrlr_vtn_name, ctrlr_vnode_name, controller_name, domain_id));
+ unc_vtn_name varchar(32) default ' ',
+ unc_vnode_name varchar(32) default ' ',
+ PRIMARY KEY(ctrlr_vtn_name, ctrlr_vnode_name, controller_name, domain_id));
CREATE TABLE su_vlink_tbl (
vtn_name varchar(32) default ' ',
vlanid integer default 0,
description varchar(128) default ' ',
oper_status smallint default 0,
+ down_count bigint default 0,
controller1_name varchar(32) default ' ',
controller2_name varchar(32) default ' ',
domain1_id varchar(32) default ' ',
domain2_id varchar(32) default ' ',
- flags smallint default 0,
+ key_flags smallint default 0,
+ val_flags smallint default 0,
valid_admin_status smallint default 0,
valid_vnode1_name smallint default 0,
valid_vnode1_ifname smallint default 0,
cs_boundary_name smallint default 3,
cs_vlanid smallint default 3,
cs_description smallint default 3,
- Primary Key(vtn_name, vlink_name));
+ PRIMARY KEY(vtn_name, vlink_name));
CREATE TABLE su_vlink_rename_tbl (
ctrlr_vtn_name varchar(32) default ' ',
ctrlr_vlink_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
- unc_vtn_name varchar(32) default ' ' unique,
- unc_vlink_name varchar(32) default ' ' unique,
- Primary Key(ctrlr_vtn_name, ctrlr_vlink_name, controller_name, domain_id));
+ unc_vtn_name varchar(32) default ' ',
+ unc_vlink_name varchar(32) default ' ',
+ PRIMARY KEY(ctrlr_vtn_name, ctrlr_vlink_name, controller_name, domain_id));
CREATE TABLE su_static_ip_route_tbl (
vtn_name varchar(32) default ' ',
vrouter_name varchar(32) default ' ',
dst_ip_addr bytea default '\000\000\000\000',
mask smallint default 0,
- nwm_name varchar(32) default ' ',
next_hop_addr bytea default '\000\000\000\000',
+ nwm_name varchar(32) default ' ',
metric integer default 0,
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- valid_next_hop_addr integer default 0,
- valid_metric integer default 0,
+ valid_metric smallint default 0,
cs_rowstatus smallint default 3,
- cs_next_hop_addr integer default 3,
- cs_metric integer default 3,
- Primary Key(vtn_name, vrouter_name, dst_ip_addr, mask, nwm_name));
+ cs_metric smallint default 3,
+ PRIMARY KEY(vtn_name, vrouter_name, dst_ip_addr, mask, next_hop_addr, nwm_name));
CREATE TABLE su_dhcp_relay_server_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vrouter_name));
+ PRIMARY KEY(vtn_name, vrouter_name, server_ip_addr));
CREATE TABLE su_dhcp_relay_if_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vrouter_name));
+ PRIMARY KEY(vtn_name, vrouter_name, if_name));
CREATE TABLE su_vbr_nwmon_grp_tbl (
vtn_name varchar(32) default ' ',
valid_oper_status smallint default 0,
cs_rowstatus smallint default 3,
cs_admin_status smallint default 3,
- Primary Key(vtn_name, vbridge_name, nwm_name));
+ PRIMARY KEY(vtn_name, vbridge_name, nwm_name));
CREATE TABLE su_vbr_nwmon_host_tbl (
vtn_name varchar(32) default ' ',
cs_failure_count smallint default 3,
cs_recovery_count smallint default 3,
cs_wait_time smallint default 3,
- Primary Key(vtn_name, vbridge_name, nwm_name, host_address));
+ PRIMARY KEY(vtn_name, vbridge_name, nwm_name, host_address));
CREATE TABLE su_vunknown_tbl (
vtn_name varchar(32) default ' ',
cs_description smallint default 3,
cs_type smallint default 3,
cs_domain_id smallint default 3,
- Primary Key(vtn_name, vunknown_name));
+ PRIMARY KEY(vtn_name, vunknown_name));
CREATE TABLE su_vunknown_if_tbl (
vtn_name varchar(32) default ' ',
cs_rowstatus smallint default 3,
cs_description smallint default 3,
cs_admin_status smallint default 3,
- Primary Key(vtn_name, vunknown_name, if_name));
+ PRIMARY KEY(vtn_name, vunknown_name, if_name));
CREATE TABLE su_vtep_tbl (
vtn_name varchar(32) default ' ',
cs_description smallint default 3,
cs_controller_name smallint default 3,
cs_domain_id smallint default 3,
- Primary Key(vtn_name, vtep_name));
+ PRIMARY KEY(vtn_name, vtep_name));
CREATE TABLE su_vtep_if_tbl (
vtn_name varchar(32) default ' ',
cs_logical_port_id smallint default 3,
cs_vlanid smallint default 3,
cs_tagged smallint default 3,
- Primary Key(vtn_name, vtep_name, if_name));
+ PRIMARY KEY(vtn_name, vtep_name, if_name));
CREATE TABLE su_vtep_grp_tbl (
vtn_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
description varchar(128) default ' ',
flags smallint default 0,
- valid_controller_name varchar(32) default 0,
- valid_description varchar(32) default 0,
+ valid_controller_name smallint default 0,
+ valid_description smallint default 0,
cs_rowstatus smallint default 3,
- cs_controller_name varchar(32) default 3,
- cs_description varchar(32) default 3,
- Primary Key(vtn_name, vtepgrp_name));
+ cs_controller_name smallint default 3,
+ cs_description smallint default 3,
+ PRIMARY KEY(vtn_name, vtepgrp_name));
CREATE TABLE su_vtep_grp_mem_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vtepgrp_name, vtepgrp_member_name));
+ PRIMARY KEY(vtn_name, vtepgrp_name, vtepgrp_member_name));
CREATE TABLE su_vtunnel_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
underlay_vtn_name varchar(32) default ' ',
vtepgrp_name varchar(32) default ' ',
- label integer default 0,
+ label bigint default 0,
oper_status smallint default 0,
down_count bigint default 0,
flags smallint default 0,
cs_underlay_vtn_name smallint default 3,
cs_vtepgrp_name smallint default 3,
cs_label smallint default 3,
- Primary Key(vtn_name, vtunnel_name));
+ PRIMARY KEY(vtn_name, vtunnel_name));
CREATE TABLE su_vtunnel_if_tbl (
vtn_name varchar(32) default ' ',
cs_portmap smallint default 3,
cs_logical_port_id smallint default 3,
cs_vlanid smallint default 3,
- Primary Key(vtn_name, vtunnel_name, if_name, description));
+ cs_tagged smallint default 3,
+ PRIMARY KEY(vtn_name, vtunnel_name, if_name));
CREATE TABLE su_flowlist_tbl (
flowlist_name varchar(33) default ' ',
valid_ip_type smallint default 0,
cs_rowstatus smallint default 3,
cs_ip_type smallint default 3,
- Primary Key(flowlist_name));
+ PRIMARY KEY(flowlist_name));
CREATE TABLE su_flowlist_ctrlr_tbl (
flowlist_name varchar(33) default ' ',
valid_ip_type smallint default 0,
cs_rowstatus smallint default 3,
cs_ip_type smallint default 3,
- Primary Key(flowlist_name, ctrlr_name));
+ PRIMARY KEY(flowlist_name, ctrlr_name));
CREATE TABLE su_flowlist_rename_tbl (
ctrlr_flowlist_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
- unc_flowlist_name varchar(33) default ' ' unique,
- Primary Key(ctrlr_flowlist_name, ctrlr_name));
+ unc_flowlist_name varchar(33) default ' ',
+ PRIMARY KEY(ctrlr_flowlist_name, ctrlr_name));
CREATE TABLE su_flowlist_entry_tbl (
flowlist_name varchar(33) default ' ',
cs_icmp_code smallint default 3,
cs_icmpv6_type smallint default 3,
cs_icmpv6_code smallint default 3,
- Primary Key(flowlist_name, sequence_num));
+ PRIMARY KEY(flowlist_name, sequence_num));
CREATE TABLE su_flowlist_entry_ctrlr_tbl (
flowlist_name varchar(33) default ' ',
cs_icmp_code smallint default 3,
cs_icmpv6_type smallint default 3,
cs_icmpv6_code smallint default 3,
- Primary Key(flowlist_name, sequence_num, ctrlr_name));
+ PRIMARY KEY(flowlist_name, sequence_num, ctrlr_name));
CREATE TABLE su_policingprofile_tbl (
policingprofile_name varchar(33) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(policingprofile_name));
+ PRIMARY KEY(policingprofile_name));
CREATE TABLE su_policingprofile_ctrlr_tbl (
policingprofile_name varchar(33) default ' ',
ref_count bigint default 0,
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(policingprofile_name, ctrlr_name));
+ PRIMARY KEY(policingprofile_name, ctrlr_name));
CREATE TABLE su_policingprofile_rename_tbl (
ctrlr_policingprofile_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
- unc_policingprofile_name varchar(33) default ' ' unique,
- Primary Key(ctrlr_policingprofile_name, ctrlr_name));
+ unc_policingprofile_name varchar(33) default ' ',
+ PRIMARY KEY(ctrlr_policingprofile_name, ctrlr_name));
CREATE TABLE su_policingprofile_entry_tbl (
policingprofile_name varchar(33) default ' ',
cs_red_priority smallint default 3,
cs_red_dscp smallint default 3,
cs_red_drop smallint default 3,
- Primary Key(policingprofile_name, sequence_num));
+ PRIMARY KEY(policingprofile_name, sequence_num));
CREATE TABLE su_policingprofile_entry_ctrlr_tbl (
policingprofile_name varchar(33) default ' ',
cs_red_priority smallint default 3,
cs_red_dscp smallint default 3,
cs_red_drop smallint default 3,
- Primary Key(policingprofile_name, sequence_num, ctrlr_name));
+ PRIMARY KEY(policingprofile_name, sequence_num, ctrlr_name));
CREATE TABLE su_vtn_flowfilter_tbl (
vtn_name varchar(32) default ' ',
direction smallint default 0,
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, direction));
+ PRIMARY KEY(vtn_name, direction));
CREATE TABLE su_vtn_flowfilter_ctrlr_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, direction, ctrlr_name, domain_id));
+ PRIMARY KEY(vtn_name, direction, ctrlr_name, domain_id));
CREATE TABLE su_vtn_flowfilter_entry_tbl (
vtn_name varchar(32) default ' ',
cs_nwn_name smallint default 3,
cs_dscp smallint default 3,
cs_priority smallint default 3,
- Primary Key(vtn_name, direction, sequence_num));
+ PRIMARY KEY(vtn_name, direction, sequence_num));
CREATE TABLE su_vtn_flowfilter_entry_ctrlr_tbl (
vtn_name varchar(32) default ' ',
cs_nwn_name smallint default 3,
cs_dscp smallint default 3,
cs_priority smallint default 3,
- Primary Key(vtn_name, direction, sequence_num, ctrlr_name, domain_id));
+ PRIMARY KEY(vtn_name, direction, sequence_num, ctrlr_name, domain_id));
CREATE TABLE su_vbr_flowfilter_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vbr_name, direction));
+ PRIMARY KEY(vtn_name, vbr_name, direction));
CREATE TABLE su_vbr_flowfilter_entry_tbl (
vtn_name varchar(32) default ' ',
cs_nwm_name smallint default 3,
cs_dscp smallint default 3,
cs_priority smallint default 3,
- Primary Key(vtn_name, vbr_name, direction, sequence_num));
+ PRIMARY KEY(vtn_name, vbr_name, direction, sequence_num));
CREATE TABLE su_vbr_if_flowfilter_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vbr_name, vbr_if_name, direction));
+ PRIMARY KEY(vtn_name, vbr_name, vbr_if_name, direction));
CREATE TABLE su_vbr_if_flowfilter_entry_tbl (
vtn_name varchar(32) default ' ',
cs_nwm_name smallint default 3,
cs_dscp smallint default 3,
cs_priority smallint default 3,
- Primary Key(vtn_name, vbr_name, vbr_if_name, direction, sequence_num));
+ PRIMARY KEY(vtn_name, vbr_name, vbr_if_name, direction, sequence_num));
CREATE TABLE su_vrt_if_flowfilter_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vrt_name, vrt_if_name, direction));
+ PRIMARY KEY(vtn_name, vrt_name, vrt_if_name, direction));
CREATE TABLE su_vrt_if_flowfilter_entry_tbl (
vtn_name varchar(32) default ' ',
cs_nwm_name smallint default 3,
cs_dscp smallint default 3,
cs_priority smallint default 3,
- Primary Key(vtn_name, vrt_name, vrt_if_name, direction, sequence_num));
+ PRIMARY KEY(vtn_name, vrt_name, vrt_if_name, direction, sequence_num));
CREATE TABLE su_vtn_policingmap_tbl (
vtn_name varchar(32) default ' ',
valid_policername smallint default 0,
cs_rowstatus smallint default 3,
cs_policername smallint default 3,
- Primary Key(vtn_name));
+ PRIMARY KEY(vtn_name));
CREATE TABLE su_vtn_policingmap_ctrlr_tbl (
vtn_name varchar(32) default ' ',
valid_policername smallint default 0,
cs_rowstatus smallint default 3,
cs_policername smallint default 3,
- Primary Key(vtn_name, ctrlr_name, domain_id));
+ PRIMARY KEY(vtn_name, ctrlr_name, domain_id));
CREATE TABLE su_vbr_policingmap_tbl (
vtn_name varchar(32) default ' ',
valid_policername smallint default 0,
cs_rowstatus smallint default 3,
cs_policername smallint default 3,
- Primary Key(vtn_name, vbr_name));
+ PRIMARY KEY(vtn_name, vbr_name));
CREATE TABLE su_vbr_if_policingmap_tbl (
vtn_name varchar(32) default ' ',
valid_policername smallint default 0,
cs_rowstatus smallint default 3,
cs_policername smallint default 3,
- Primary Key(vtn_name, vbr_name, vbr_if_name));
+ PRIMARY KEY(vtn_name, vbr_name, vbr_if_name));
CREATE TABLE ca_vtn_tbl (
vtn_name varchar(32) default ' ',
valid_last_updated_time smallint default 0,
cs_rowstatus smallint default 3,
cs_description smallint default 3,
- Primary Key(vtn_name));
+ PRIMARY KEY(vtn_name));
CREATE TABLE ca_vtn_ctrlr_tbl (
vtn_name varchar(32) default ' ',
valid_alarm_status smallint default 0,
cs_rowstatus smallint default 3,
cs_description smallint default 3,
- Primary Key(vtn_name, controller_name, domain_id));
+ PRIMARY KEY(vtn_name, controller_name, domain_id));
CREATE TABLE ca_vtn_rename_tbl (
ctrlr_vtn_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
- unc_vtn_name varchar(32) default ' ' unique,
- Primary Key(ctrlr_vtn_name, controller_name, domain_id));
+ unc_vtn_name varchar(32) default ' ',
+ PRIMARY KEY(ctrlr_vtn_name, controller_name, domain_id));
CREATE TABLE ca_vbr_tbl (
vtn_name varchar(32) default ' ',
cs_host_addr smallint default 3,
cs_host_addr_mask smallint default 3,
flags smallint default 0,
- Primary Key(vtn_name, vbridge_name));
+ PRIMARY KEY(vtn_name, vbridge_name));
CREATE TABLE ca_vbr_vlanmap_tbl (
vtn_name varchar(32) default ' ',
vbridge_name varchar(32) default ' ',
logical_port_id varchar(320) default ' ',
- logical_port_id_valid varchar(320) default ' ',
- vlanid smallint default 0,
+ logical_port_id_valid smallint default 0,
+ vlanid integer default 0,
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
valid_vlanid smallint default 0,
cs_rowstatus smallint default 3,
cs_vlanid smallint default 3,
- Primary Key(vtn_name, vbridge_name, logical_port_id, logical_port_id_valid));
+ PRIMARY KEY(vtn_name, vbridge_name, logical_port_id, logical_port_id_valid));
CREATE TABLE ca_vbr_if_tbl (
vtn_name varchar(32) default ' ',
valid_logical_port_id smallint default 0,
valid_vlanid smallint default 0,
valid_tagged smallint default 0,
+ valid_vex_name smallint default 0,
+ valid_vex_if_name smallint default 0,
+ valid_vex_link_name smallint default 0,
valid_oper_status smallint default 0,
cs_rowstatus smallint default 3,
cs_admin_status smallint default 3,
cs_logical_port_id smallint default 3,
cs_vlanid smallint default 3,
cs_tagged smallint default 3,
- Primary Key(vtn_name, vbridge_name, if_name));
+ PRIMARY KEY(vtn_name, vbridge_name, if_name));
CREATE TABLE ca_vrt_tbl (
vtn_name varchar(32) default ' ',
cs_domain_id smallint default 3,
cs_vrt_description smallint default 3,
cs_dhcprelay_admin_status smallint default 3,
- Primary Key(vtn_name, vrouter_name));
+ PRIMARY KEY(vtn_name, vrouter_name));
CREATE TABLE ca_vrt_if_tbl (
vtn_name varchar(32) default ' ',
cs_mask smallint default 3,
cs_mac_addr smallint default 3,
cs_admin_status smallint default 3,
- Primary Key(vtn_name, vrouter_name, if_name));
+ PRIMARY KEY(vtn_name, vrouter_name, if_name));
CREATE TABLE ca_vnode_rename_tbl (
ctrlr_vtn_name varchar(32) default ' ',
ctrlr_vnode_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
- unc_vtn_name varchar(32) default ' ' unique,
- unc_vnode_name varchar(32) default ' ' unique,
- Primary Key(ctrlr_vtn_name, ctrlr_vnode_name, controller_name, domain_id));
+ unc_vtn_name varchar(32) default ' ',
+ unc_vnode_name varchar(32) default ' ',
+ PRIMARY KEY(ctrlr_vtn_name, ctrlr_vnode_name, controller_name, domain_id));
CREATE TABLE ca_vlink_tbl (
vtn_name varchar(32) default ' ',
vlanid integer default 0,
description varchar(128) default ' ',
oper_status smallint default 0,
+ down_count bigint default 0,
controller1_name varchar(32) default ' ',
controller2_name varchar(32) default ' ',
domain1_id varchar(32) default ' ',
domain2_id varchar(32) default ' ',
- flags smallint default 0,
+ key_flags smallint default 0,
+ val_flags smallint default 0,
valid_admin_status smallint default 0,
valid_vnode1_name smallint default 0,
valid_vnode1_ifname smallint default 0,
cs_boundary_name smallint default 3,
cs_vlanid smallint default 3,
cs_description smallint default 3,
- Primary Key(vtn_name, vlink_name));
+ PRIMARY KEY(vtn_name, vlink_name));
CREATE TABLE ca_vlink_rename_tbl (
ctrlr_vtn_name varchar(32) default ' ',
ctrlr_vlink_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
- unc_vtn_name varchar(32) default ' ' unique,
- unc_vlink_name varchar(32) default ' ' unique,
- Primary Key(ctrlr_vtn_name, ctrlr_vlink_name, controller_name, domain_id));
+ unc_vtn_name varchar(32) default ' ',
+ unc_vlink_name varchar(32) default ' ',
+ PRIMARY KEY(ctrlr_vtn_name, ctrlr_vlink_name, controller_name, domain_id));
CREATE TABLE ca_static_ip_route_tbl (
vtn_name varchar(32) default ' ',
vrouter_name varchar(32) default ' ',
dst_ip_addr bytea default '\000\000\000\000',
mask smallint default 0,
- nwm_name varchar(32) default ' ',
next_hop_addr bytea default '\000\000\000\000',
+ nwm_name varchar(32) default ' ',
metric integer default 0,
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- valid_next_hop_addr integer default 0,
- valid_metric integer default 0,
+ valid_metric smallint default 0,
cs_rowstatus smallint default 3,
- cs_next_hop_addr integer default 3,
- cs_metric integer default 3,
- Primary Key(vtn_name, vrouter_name, dst_ip_addr, mask, nwm_name));
+ cs_metric smallint default 3,
+ PRIMARY KEY(vtn_name, vrouter_name, dst_ip_addr, mask, next_hop_addr, nwm_name));
CREATE TABLE ca_dhcp_relay_server_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vrouter_name));
+ PRIMARY KEY(vtn_name, vrouter_name, server_ip_addr));
CREATE TABLE ca_dhcp_relay_if_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vrouter_name));
+ PRIMARY KEY(vtn_name, vrouter_name, if_name));
CREATE TABLE ca_vbr_nwmon_grp_tbl (
vtn_name varchar(32) default ' ',
valid_oper_status smallint default 0,
cs_rowstatus smallint default 3,
cs_admin_status smallint default 3,
- Primary Key(vtn_name, vbridge_name, nwm_name));
+ PRIMARY KEY(vtn_name, vbridge_name, nwm_name));
CREATE TABLE ca_vbr_nwmon_host_tbl (
vtn_name varchar(32) default ' ',
cs_failure_count smallint default 3,
cs_recovery_count smallint default 3,
cs_wait_time smallint default 3,
- Primary Key(vtn_name, vbridge_name, nwm_name, host_address));
+ PRIMARY KEY(vtn_name, vbridge_name, nwm_name, host_address));
CREATE TABLE ca_vunknown_tbl (
vtn_name varchar(32) default ' ',
cs_description smallint default 3,
cs_type smallint default 3,
cs_domain_id smallint default 3,
- Primary Key(vtn_name, vunknown_name));
+ PRIMARY KEY(vtn_name, vunknown_name));
CREATE TABLE ca_vunknown_if_tbl (
vtn_name varchar(32) default ' ',
cs_rowstatus smallint default 3,
cs_description smallint default 3,
cs_admin_status smallint default 3,
- Primary Key(vtn_name, vunknown_name, if_name));
+ PRIMARY KEY(vtn_name, vunknown_name, if_name));
CREATE TABLE ca_vtep_tbl (
vtn_name varchar(32) default ' ',
cs_description smallint default 3,
cs_controller_name smallint default 3,
cs_domain_id smallint default 3,
- Primary Key(vtn_name, vtep_name));
+ PRIMARY KEY(vtn_name, vtep_name));
CREATE TABLE ca_vtep_if_tbl (
vtn_name varchar(32) default ' ',
cs_logical_port_id smallint default 3,
cs_vlanid smallint default 3,
cs_tagged smallint default 3,
- Primary Key(vtn_name, vtep_name, if_name));
+ PRIMARY KEY(vtn_name, vtep_name, if_name));
CREATE TABLE ca_vtep_grp_tbl (
vtn_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
description varchar(128) default ' ',
flags smallint default 0,
- valid_controller_name varchar(32) default 0,
- valid_description varchar(32) default 0,
+ valid_controller_name smallint default 0,
+ valid_description smallint default 0,
cs_rowstatus smallint default 3,
- cs_controller_name varchar(32) default 3,
- cs_description varchar(32) default 3,
- Primary Key(vtn_name, vtepgrp_name));
+ cs_controller_name smallint default 3,
+ cs_description smallint default 3,
+ PRIMARY KEY(vtn_name, vtepgrp_name));
CREATE TABLE ca_vtep_grp_mem_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vtepgrp_name, vtepgrp_member_name));
+ PRIMARY KEY(vtn_name, vtepgrp_name, vtepgrp_member_name));
CREATE TABLE ca_vtunnel_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
underlay_vtn_name varchar(32) default ' ',
vtepgrp_name varchar(32) default ' ',
- label integer default 0,
+ label bigint default 0,
oper_status smallint default 0,
down_count bigint default 0,
flags smallint default 0,
cs_underlay_vtn_name smallint default 3,
cs_vtepgrp_name smallint default 3,
cs_label smallint default 3,
- Primary Key(vtn_name, vtunnel_name));
+ PRIMARY KEY(vtn_name, vtunnel_name));
CREATE TABLE ca_vtunnel_if_tbl (
vtn_name varchar(32) default ' ',
cs_portmap smallint default 3,
cs_logical_port_id smallint default 3,
cs_vlanid smallint default 3,
- Primary Key(vtn_name, vtunnel_name, if_name, description));
+ cs_tagged smallint default 3,
+ PRIMARY KEY(vtn_name, vtunnel_name, if_name));
CREATE TABLE ca_flowlist_tbl (
flowlist_name varchar(33) default ' ',
valid_ip_type smallint default 0,
cs_rowstatus smallint default 3,
cs_ip_type smallint default 3,
- Primary Key(flowlist_name));
+ PRIMARY KEY(flowlist_name));
CREATE TABLE ca_flowlist_ctrlr_tbl (
flowlist_name varchar(33) default ' ',
valid_ip_type smallint default 0,
cs_rowstatus smallint default 3,
cs_ip_type smallint default 3,
- Primary Key(flowlist_name, ctrlr_name));
+ PRIMARY KEY(flowlist_name, ctrlr_name));
CREATE TABLE ca_flowlist_rename_tbl (
ctrlr_flowlist_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
- unc_flowlist_name varchar(33) default ' ' unique,
- Primary Key(ctrlr_flowlist_name, ctrlr_name));
+ unc_flowlist_name varchar(33) default ' ',
+ PRIMARY KEY(ctrlr_flowlist_name, ctrlr_name));
CREATE TABLE ca_flowlist_entry_tbl (
flowlist_name varchar(33) default ' ',
cs_icmp_code smallint default 3,
cs_icmpv6_type smallint default 3,
cs_icmpv6_code smallint default 3,
- Primary Key(flowlist_name, sequence_num));
+ PRIMARY KEY(flowlist_name, sequence_num));
CREATE TABLE ca_flowlist_entry_ctrlr_tbl (
flowlist_name varchar(33) default ' ',
cs_icmp_code smallint default 3,
cs_icmpv6_type smallint default 3,
cs_icmpv6_code smallint default 3,
- Primary Key(flowlist_name, sequence_num, ctrlr_name));
+ PRIMARY KEY(flowlist_name, sequence_num, ctrlr_name));
CREATE TABLE ca_policingprofile_tbl (
policingprofile_name varchar(33) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(policingprofile_name));
+ PRIMARY KEY(policingprofile_name));
CREATE TABLE ca_policingprofile_ctrlr_tbl (
policingprofile_name varchar(33) default ' ',
ref_count bigint default 0,
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(policingprofile_name, ctrlr_name));
+ PRIMARY KEY(policingprofile_name, ctrlr_name));
CREATE TABLE ca_policingprofile_rename_tbl (
ctrlr_policingprofile_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
- unc_policingprofile_name varchar(33) default ' ' unique,
- Primary Key(ctrlr_policingprofile_name, ctrlr_name));
+ unc_policingprofile_name varchar(33) default ' ',
+ PRIMARY KEY(ctrlr_policingprofile_name, ctrlr_name));
CREATE TABLE ca_policingprofile_entry_tbl (
policingprofile_name varchar(33) default ' ',
cs_red_priority smallint default 3,
cs_red_dscp smallint default 3,
cs_red_drop smallint default 3,
- Primary Key(policingprofile_name, sequence_num));
+ PRIMARY KEY(policingprofile_name, sequence_num));
CREATE TABLE ca_policingprofile_entry_ctrlr_tbl (
policingprofile_name varchar(33) default ' ',
cs_red_priority smallint default 3,
cs_red_dscp smallint default 3,
cs_red_drop smallint default 3,
- Primary Key(policingprofile_name, sequence_num, ctrlr_name));
+ PRIMARY KEY(policingprofile_name, sequence_num, ctrlr_name));
CREATE TABLE ca_vtn_flowfilter_tbl (
vtn_name varchar(32) default ' ',
direction smallint default 0,
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, direction));
+ PRIMARY KEY(vtn_name, direction));
CREATE TABLE ca_vtn_flowfilter_ctrlr_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, direction, ctrlr_name, domain_id));
+ PRIMARY KEY(vtn_name, direction, ctrlr_name, domain_id));
CREATE TABLE ca_vtn_flowfilter_entry_tbl (
vtn_name varchar(32) default ' ',
cs_nwn_name smallint default 3,
cs_dscp smallint default 3,
cs_priority smallint default 3,
- Primary Key(vtn_name, direction, sequence_num));
+ PRIMARY KEY(vtn_name, direction, sequence_num));
CREATE TABLE ca_vtn_flowfilter_entry_ctrlr_tbl (
vtn_name varchar(32) default ' ',
cs_nwn_name smallint default 3,
cs_dscp smallint default 3,
cs_priority smallint default 3,
- Primary Key(vtn_name, direction, sequence_num, ctrlr_name, domain_id));
+ PRIMARY KEY(vtn_name, direction, sequence_num, ctrlr_name, domain_id));
CREATE TABLE ca_vbr_flowfilter_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vbr_name, direction));
+ PRIMARY KEY(vtn_name, vbr_name, direction));
CREATE TABLE ca_vbr_flowfilter_entry_tbl (
vtn_name varchar(32) default ' ',
cs_nwm_name smallint default 3,
cs_dscp smallint default 3,
cs_priority smallint default 3,
- Primary Key(vtn_name, vbr_name, direction, sequence_num));
+ PRIMARY KEY(vtn_name, vbr_name, direction, sequence_num));
CREATE TABLE ca_vbr_if_flowfilter_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vbr_name, vbr_if_name, direction));
+ PRIMARY KEY(vtn_name, vbr_name, vbr_if_name, direction));
CREATE TABLE ca_vbr_if_flowfilter_entry_tbl (
vtn_name varchar(32) default ' ',
cs_nwm_name smallint default 3,
cs_dscp smallint default 3,
cs_priority smallint default 3,
- Primary Key(vtn_name, vbr_name, vbr_if_name, direction, sequence_num));
+ PRIMARY KEY(vtn_name, vbr_name, vbr_if_name, direction, sequence_num));
CREATE TABLE ca_vrt_if_flowfilter_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vrt_name, vrt_if_name, direction));
+ PRIMARY KEY(vtn_name, vrt_name, vrt_if_name, direction));
CREATE TABLE ca_vrt_if_flowfilter_entry_tbl (
vtn_name varchar(32) default ' ',
cs_nwm_name smallint default 3,
cs_dscp smallint default 3,
cs_priority smallint default 3,
- Primary Key(vtn_name, vrt_name, vrt_if_name, direction, sequence_num));
+ PRIMARY KEY(vtn_name, vrt_name, vrt_if_name, direction, sequence_num));
CREATE TABLE ca_vtn_policingmap_tbl (
vtn_name varchar(32) default ' ',
valid_policername smallint default 0,
cs_rowstatus smallint default 3,
cs_policername smallint default 3,
- Primary Key(vtn_name));
+ PRIMARY KEY(vtn_name));
CREATE TABLE ca_vtn_policingmap_ctrlr_tbl (
vtn_name varchar(32) default ' ',
valid_policername smallint default 0,
cs_rowstatus smallint default 3,
cs_policername smallint default 3,
- Primary Key(vtn_name, ctrlr_name, domain_id));
+ PRIMARY KEY(vtn_name, ctrlr_name, domain_id));
CREATE TABLE ca_vbr_policingmap_tbl (
vtn_name varchar(32) default ' ',
valid_policername smallint default 0,
cs_rowstatus smallint default 3,
cs_policername smallint default 3,
- Primary Key(vtn_name, vbr_name));
+ PRIMARY KEY(vtn_name, vbr_name));
CREATE TABLE ca_vbr_if_policingmap_tbl (
vtn_name varchar(32) default ' ',
valid_policername smallint default 0,
cs_rowstatus smallint default 3,
cs_policername smallint default 3,
- Primary Key(vtn_name, vbr_name, vbr_if_name));
+ PRIMARY KEY(vtn_name, vbr_name, vbr_if_name));
CREATE TABLE ca_ctrlr_tbl (
name varchar(32) default ' ',
audit_done smallint default 0,
config_done smallint default 0,
invalid_config smallint default 0,
- Primary Key(name));
+ PRIMARY KEY(name));
CREATE TABLE ru_vtn_tbl (
vtn_name varchar(32) default ' ',
valid_last_updated_time smallint default 0,
cs_rowstatus smallint default 3,
cs_description smallint default 3,
- Primary Key(vtn_name));
+ PRIMARY KEY(vtn_name));
CREATE TABLE ru_vtn_ctrlr_tbl (
vtn_name varchar(32) default ' ',
valid_alarm_status smallint default 0,
cs_rowstatus smallint default 3,
cs_description smallint default 3,
- Primary Key(vtn_name, controller_name, domain_id));
+ PRIMARY KEY(vtn_name, controller_name, domain_id));
CREATE TABLE ru_vtn_rename_tbl (
ctrlr_vtn_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
- unc_vtn_name varchar(32) default ' ' unique,
- Primary Key(ctrlr_vtn_name, controller_name, domain_id));
+ unc_vtn_name varchar(32) default ' ',
+ PRIMARY KEY(ctrlr_vtn_name, controller_name, domain_id));
CREATE TABLE ru_vbr_tbl (
vtn_name varchar(32) default ' ',
cs_host_addr smallint default 3,
cs_host_addr_mask smallint default 3,
flags smallint default 0,
- Primary Key(vtn_name, vbridge_name));
+ PRIMARY KEY(vtn_name, vbridge_name));
CREATE TABLE ru_vbr_vlanmap_tbl (
vtn_name varchar(32) default ' ',
vbridge_name varchar(32) default ' ',
logical_port_id varchar(320) default ' ',
- logical_port_id_valid varchar(320) default ' ',
- vlanid smallint default 0,
+ logical_port_id_valid smallint default 0,
+ vlanid integer default 0,
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
valid_vlanid smallint default 0,
cs_rowstatus smallint default 3,
cs_vlanid smallint default 3,
- Primary Key(vtn_name, vbridge_name, logical_port_id, logical_port_id_valid));
+ PRIMARY KEY(vtn_name, vbridge_name, logical_port_id, logical_port_id_valid));
CREATE TABLE ru_vbr_if_tbl (
vtn_name varchar(32) default ' ',
valid_logical_port_id smallint default 0,
valid_vlanid smallint default 0,
valid_tagged smallint default 0,
+ valid_vex_name smallint default 0,
+ valid_vex_if_name smallint default 0,
+ valid_vex_link_name smallint default 0,
valid_oper_status smallint default 0,
cs_rowstatus smallint default 3,
cs_admin_status smallint default 3,
cs_logical_port_id smallint default 3,
cs_vlanid smallint default 3,
cs_tagged smallint default 3,
- Primary Key(vtn_name, vbridge_name, if_name));
+ PRIMARY KEY(vtn_name, vbridge_name, if_name));
CREATE TABLE ru_vrt_tbl (
vtn_name varchar(32) default ' ',
cs_domain_id smallint default 3,
cs_vrt_description smallint default 3,
cs_dhcprelay_admin_status smallint default 3,
- Primary Key(vtn_name, vrouter_name));
+ PRIMARY KEY(vtn_name, vrouter_name));
CREATE TABLE ru_vrt_if_tbl (
vtn_name varchar(32) default ' ',
cs_mask smallint default 3,
cs_mac_addr smallint default 3,
cs_admin_status smallint default 3,
- Primary Key(vtn_name, vrouter_name, if_name));
+ PRIMARY KEY(vtn_name, vrouter_name, if_name));
CREATE TABLE ru_vnode_rename_tbl (
ctrlr_vtn_name varchar(32) default ' ',
ctrlr_vnode_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
- unc_vtn_name varchar(32) default ' ' unique,
- unc_vnode_name varchar(32) default ' ' unique,
- Primary Key(ctrlr_vtn_name, ctrlr_vnode_name, controller_name, domain_id));
+ unc_vtn_name varchar(32) default ' ',
+ unc_vnode_name varchar(32) default ' ',
+ PRIMARY KEY(ctrlr_vtn_name, ctrlr_vnode_name, controller_name, domain_id));
CREATE TABLE ru_vlink_tbl (
vtn_name varchar(32) default ' ',
vlanid integer default 0,
description varchar(128) default ' ',
oper_status smallint default 0,
+ down_count bigint default 0,
controller1_name varchar(32) default ' ',
controller2_name varchar(32) default ' ',
domain1_id varchar(32) default ' ',
domain2_id varchar(32) default ' ',
- flags smallint default 0,
+ key_flags smallint default 0,
+ val_flags smallint default 0,
valid_admin_status smallint default 0,
valid_vnode1_name smallint default 0,
valid_vnode1_ifname smallint default 0,
cs_boundary_name smallint default 3,
cs_vlanid smallint default 3,
cs_description smallint default 3,
- Primary Key(vtn_name, vlink_name));
+ PRIMARY KEY(vtn_name, vlink_name));
CREATE TABLE ru_vlink_rename_tbl (
ctrlr_vtn_name varchar(32) default ' ',
ctrlr_vlink_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
- unc_vtn_name varchar(32) default ' ' unique,
- unc_vlink_name varchar(32) default ' ' unique,
- Primary Key(ctrlr_vtn_name, ctrlr_vlink_name, controller_name, domain_id));
+ unc_vtn_name varchar(32) default ' ',
+ unc_vlink_name varchar(32) default ' ',
+ PRIMARY KEY(ctrlr_vtn_name, ctrlr_vlink_name, controller_name, domain_id));
CREATE TABLE ru_static_ip_route_tbl (
vtn_name varchar(32) default ' ',
vrouter_name varchar(32) default ' ',
dst_ip_addr bytea default '\000\000\000\000',
mask smallint default 0,
- nwm_name varchar(32) default ' ',
next_hop_addr bytea default '\000\000\000\000',
+ nwm_name varchar(32) default ' ',
metric integer default 0,
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- valid_next_hop_addr integer default 0,
- valid_metric integer default 0,
+ valid_metric smallint default 0,
cs_rowstatus smallint default 3,
- cs_next_hop_addr integer default 3,
- cs_metric integer default 3,
- Primary Key(vtn_name, vrouter_name, dst_ip_addr, mask, nwm_name));
+ cs_metric smallint default 3,
+ PRIMARY KEY(vtn_name, vrouter_name, dst_ip_addr, mask, next_hop_addr, nwm_name));
CREATE TABLE ru_dhcp_relay_server_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vrouter_name));
+ PRIMARY KEY(vtn_name, vrouter_name, server_ip_addr));
CREATE TABLE ru_dhcp_relay_if_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vrouter_name));
+ PRIMARY KEY(vtn_name, vrouter_name, if_name));
CREATE TABLE ru_vbr_nwmon_grp_tbl (
vtn_name varchar(32) default ' ',
valid_oper_status smallint default 0,
cs_rowstatus smallint default 3,
cs_admin_status smallint default 3,
- Primary Key(vtn_name, vbridge_name, nwm_name));
+ PRIMARY KEY(vtn_name, vbridge_name, nwm_name));
CREATE TABLE ru_vbr_nwmon_host_tbl (
vtn_name varchar(32) default ' ',
cs_failure_count smallint default 3,
cs_recovery_count smallint default 3,
cs_wait_time smallint default 3,
- Primary Key(vtn_name, vbridge_name, nwm_name, host_address));
+ PRIMARY KEY(vtn_name, vbridge_name, nwm_name, host_address));
CREATE TABLE ru_vunknown_tbl (
vtn_name varchar(32) default ' ',
cs_description smallint default 3,
cs_type smallint default 3,
cs_domain_id smallint default 3,
- Primary Key(vtn_name, vunknown_name));
+ PRIMARY KEY(vtn_name, vunknown_name));
CREATE TABLE ru_vunknown_if_tbl (
vtn_name varchar(32) default ' ',
cs_rowstatus smallint default 3,
cs_description smallint default 3,
cs_admin_status smallint default 3,
- Primary Key(vtn_name, vunknown_name, if_name));
+ PRIMARY KEY(vtn_name, vunknown_name, if_name));
CREATE TABLE ru_vtep_tbl (
vtn_name varchar(32) default ' ',
cs_description smallint default 3,
cs_controller_name smallint default 3,
cs_domain_id smallint default 3,
- Primary Key(vtn_name, vtep_name));
+ PRIMARY KEY(vtn_name, vtep_name));
CREATE TABLE ru_vtep_if_tbl (
vtn_name varchar(32) default ' ',
cs_logical_port_id smallint default 3,
cs_vlanid smallint default 3,
cs_tagged smallint default 3,
- Primary Key(vtn_name, vtep_name, if_name));
+ PRIMARY KEY(vtn_name, vtep_name, if_name));
CREATE TABLE ru_vtep_grp_tbl (
vtn_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
description varchar(128) default ' ',
flags smallint default 0,
- valid_controller_name varchar(32) default 0,
- valid_description varchar(32) default 0,
+ valid_controller_name smallint default 0,
+ valid_description smallint default 0,
cs_rowstatus smallint default 3,
- cs_controller_name varchar(32) default 3,
- cs_description varchar(32) default 3,
- Primary Key(vtn_name, vtepgrp_name));
+ cs_controller_name smallint default 3,
+ cs_description smallint default 3,
+ PRIMARY KEY(vtn_name, vtepgrp_name));
CREATE TABLE ru_vtep_grp_mem_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vtepgrp_name, vtepgrp_member_name));
+ PRIMARY KEY(vtn_name, vtepgrp_name, vtepgrp_member_name));
CREATE TABLE ru_vtunnel_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
underlay_vtn_name varchar(32) default ' ',
vtepgrp_name varchar(32) default ' ',
- label integer default 0,
+ label bigint default 0,
oper_status smallint default 0,
down_count bigint default 0,
flags smallint default 0,
cs_underlay_vtn_name smallint default 3,
cs_vtepgrp_name smallint default 3,
cs_label smallint default 3,
- Primary Key(vtn_name, vtunnel_name));
+ PRIMARY KEY(vtn_name, vtunnel_name));
CREATE TABLE ru_vtunnel_if_tbl (
vtn_name varchar(32) default ' ',
cs_portmap smallint default 3,
cs_logical_port_id smallint default 3,
cs_vlanid smallint default 3,
- Primary Key(vtn_name, vtunnel_name, if_name, description));
+ cs_tagged smallint default 3,
+ PRIMARY KEY(vtn_name, vtunnel_name, if_name));
CREATE TABLE ru_flowlist_tbl (
flowlist_name varchar(33) default ' ',
valid_ip_type smallint default 0,
cs_rowstatus smallint default 3,
cs_ip_type smallint default 3,
- Primary Key(flowlist_name));
+ PRIMARY KEY(flowlist_name));
CREATE TABLE ru_flowlist_ctrlr_tbl (
flowlist_name varchar(33) default ' ',
valid_ip_type smallint default 0,
cs_rowstatus smallint default 3,
cs_ip_type smallint default 3,
- Primary Key(flowlist_name, ctrlr_name));
+ PRIMARY KEY(flowlist_name, ctrlr_name));
CREATE TABLE ru_flowlist_rename_tbl (
ctrlr_flowlist_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
- unc_flowlist_name varchar(33) default ' ' unique,
- Primary Key(ctrlr_flowlist_name, ctrlr_name));
+ unc_flowlist_name varchar(33) default ' ',
+ PRIMARY KEY(ctrlr_flowlist_name, ctrlr_name));
CREATE TABLE ru_flowlist_entry_tbl (
flowlist_name varchar(33) default ' ',
cs_icmp_code smallint default 3,
cs_icmpv6_type smallint default 3,
cs_icmpv6_code smallint default 3,
- Primary Key(flowlist_name, sequence_num));
+ PRIMARY KEY(flowlist_name, sequence_num));
CREATE TABLE ru_flowlist_entry_ctrlr_tbl (
flowlist_name varchar(33) default ' ',
cs_icmp_code smallint default 3,
cs_icmpv6_type smallint default 3,
cs_icmpv6_code smallint default 3,
- Primary Key(flowlist_name, sequence_num, ctrlr_name));
+ PRIMARY KEY(flowlist_name, sequence_num, ctrlr_name));
CREATE TABLE ru_policingprofile_tbl (
policingprofile_name varchar(33) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(policingprofile_name));
+ PRIMARY KEY(policingprofile_name));
CREATE TABLE ru_policingprofile_ctrlr_tbl (
policingprofile_name varchar(33) default ' ',
ref_count bigint default 0,
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(policingprofile_name, ctrlr_name));
+ PRIMARY KEY(policingprofile_name, ctrlr_name));
CREATE TABLE ru_policingprofile_rename_tbl (
ctrlr_policingprofile_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
- unc_policingprofile_name varchar(33) default ' ' unique,
- Primary Key(ctrlr_policingprofile_name, ctrlr_name));
+ unc_policingprofile_name varchar(33) default ' ',
+ PRIMARY KEY(ctrlr_policingprofile_name, ctrlr_name));
CREATE TABLE ru_policingprofile_entry_tbl (
policingprofile_name varchar(33) default ' ',
cs_red_priority smallint default 3,
cs_red_dscp smallint default 3,
cs_red_drop smallint default 3,
- Primary Key(policingprofile_name, sequence_num));
+ PRIMARY KEY(policingprofile_name, sequence_num));
CREATE TABLE ru_policingprofile_entry_ctrlr_tbl (
policingprofile_name varchar(33) default ' ',
cs_red_priority smallint default 3,
cs_red_dscp smallint default 3,
cs_red_drop smallint default 3,
- Primary Key(policingprofile_name, sequence_num, ctrlr_name));
+ PRIMARY KEY(policingprofile_name, sequence_num, ctrlr_name));
CREATE TABLE ru_vtn_flowfilter_tbl (
vtn_name varchar(32) default ' ',
direction smallint default 0,
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, direction));
+ PRIMARY KEY(vtn_name, direction));
CREATE TABLE ru_vtn_flowfilter_ctrlr_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, direction, ctrlr_name, domain_id));
+ PRIMARY KEY(vtn_name, direction, ctrlr_name, domain_id));
CREATE TABLE ru_vtn_flowfilter_entry_tbl (
vtn_name varchar(32) default ' ',
cs_nwn_name smallint default 3,
cs_dscp smallint default 3,
cs_priority smallint default 3,
- Primary Key(vtn_name, direction, sequence_num));
+ PRIMARY KEY(vtn_name, direction, sequence_num));
CREATE TABLE ru_vtn_flowfilter_entry_ctrlr_tbl (
vtn_name varchar(32) default ' ',
cs_nwn_name smallint default 3,
cs_dscp smallint default 3,
cs_priority smallint default 3,
- Primary Key(vtn_name, direction, sequence_num, ctrlr_name, domain_id));
+ PRIMARY KEY(vtn_name, direction, sequence_num, ctrlr_name, domain_id));
CREATE TABLE ru_vbr_flowfilter_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vbr_name, direction));
+ PRIMARY KEY(vtn_name, vbr_name, direction));
CREATE TABLE ru_vbr_flowfilter_entry_tbl (
vtn_name varchar(32) default ' ',
cs_nwm_name smallint default 3,
cs_dscp smallint default 3,
cs_priority smallint default 3,
- Primary Key(vtn_name, vbr_name, direction, sequence_num));
+ PRIMARY KEY(vtn_name, vbr_name, direction, sequence_num));
CREATE TABLE ru_vbr_if_flowfilter_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vbr_name, vbr_if_name, direction));
+ PRIMARY KEY(vtn_name, vbr_name, vbr_if_name, direction));
CREATE TABLE ru_vbr_if_flowfilter_entry_tbl (
vtn_name varchar(32) default ' ',
cs_nwm_name smallint default 3,
cs_dscp smallint default 3,
cs_priority smallint default 3,
- Primary Key(vtn_name, vbr_name, vbr_if_name, direction, sequence_num));
+ PRIMARY KEY(vtn_name, vbr_name, vbr_if_name, direction, sequence_num));
CREATE TABLE ru_vrt_if_flowfilter_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vrt_name, vrt_if_name, direction));
+ PRIMARY KEY(vtn_name, vrt_name, vrt_if_name, direction));
CREATE TABLE ru_vrt_if_flowfilter_entry_tbl (
vtn_name varchar(32) default ' ',
cs_nwm_name smallint default 3,
cs_dscp smallint default 3,
cs_priority smallint default 3,
- Primary Key(vtn_name, vrt_name, vrt_if_name, direction, sequence_num));
+ PRIMARY KEY(vtn_name, vrt_name, vrt_if_name, direction, sequence_num));
CREATE TABLE ru_vtn_policingmap_tbl (
vtn_name varchar(32) default ' ',
valid_policername smallint default 0,
cs_rowstatus smallint default 3,
cs_policername smallint default 3,
- Primary Key(vtn_name));
+ PRIMARY KEY(vtn_name));
CREATE TABLE ru_vtn_policingmap_ctrlr_tbl (
vtn_name varchar(32) default ' ',
valid_policername smallint default 0,
cs_rowstatus smallint default 3,
cs_policername smallint default 3,
- Primary Key(vtn_name, ctrlr_name, domain_id));
+ PRIMARY KEY(vtn_name, ctrlr_name, domain_id));
CREATE TABLE ru_vbr_policingmap_tbl (
vtn_name varchar(32) default ' ',
valid_policername smallint default 0,
cs_rowstatus smallint default 3,
cs_policername smallint default 3,
- Primary Key(vtn_name, vbr_name));
+ PRIMARY KEY(vtn_name, vbr_name));
CREATE TABLE ru_vbr_if_policingmap_tbl (
vtn_name varchar(32) default ' ',
valid_policername smallint default 0,
cs_rowstatus smallint default 3,
cs_policername smallint default 3,
- Primary Key(vtn_name, vbr_name, vbr_if_name));
+ PRIMARY KEY(vtn_name, vbr_name, vbr_if_name));
CREATE TABLE im_vtn_tbl (
vtn_name varchar(32) default ' ',
valid_alarm_status smallint default 0,
valid_creation_time smallint default 0,
valid_last_updated_time smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- Primary Key(vtn_name));
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ PRIMARY KEY(vtn_name));
CREATE TABLE im_vtn_ctrlr_tbl (
vtn_name varchar(32) default ' ',
flags smallint default 0,
valid_oper_status smallint default 0,
valid_alarm_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- Primary Key(vtn_name, controller_name, domain_id));
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ PRIMARY KEY(vtn_name, controller_name, domain_id));
CREATE TABLE im_vtn_rename_tbl (
ctrlr_vtn_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
- unc_vtn_name varchar(32) default ' ' unique,
- Primary Key(ctrlr_vtn_name, controller_name, domain_id));
+ unc_vtn_name varchar(32) default ' ',
+ PRIMARY KEY(ctrlr_vtn_name, controller_name, domain_id));
CREATE TABLE im_vbr_tbl (
vtn_name varchar(32) default ' ',
valid_host_addr smallint default 0,
valid_host_addr_mask smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_controller_name smallint default 3,
- cs_domain_id smallint default 3,
- cs_vbr_description smallint default 3,
- cs_host_addr smallint default 3,
- cs_host_addr_mask smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_controller_name smallint default 1,
+ cs_domain_id smallint default 1,
+ cs_vbr_description smallint default 1,
+ cs_host_addr smallint default 1,
+ cs_host_addr_mask smallint default 1,
flags smallint default 0,
- Primary Key(vtn_name, vbridge_name));
+ PRIMARY KEY(vtn_name, vbridge_name));
CREATE TABLE im_vbr_vlanmap_tbl (
vtn_name varchar(32) default ' ',
vbridge_name varchar(32) default ' ',
logical_port_id varchar(320) default ' ',
- logical_port_id_valid varchar(320) default ' ',
- vlanid smallint default 0,
+ logical_port_id_valid smallint default 0,
+ vlanid integer default 0,
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
valid_vlanid smallint default 0,
- cs_rowstatus smallint default 3,
- cs_vlanid smallint default 3,
- Primary Key(vtn_name, vbridge_name, logical_port_id, logical_port_id_valid));
+ cs_rowstatus smallint default 1,
+ cs_vlanid smallint default 1,
+ PRIMARY KEY(vtn_name, vbridge_name, logical_port_id, logical_port_id_valid));
CREATE TABLE im_vbr_if_tbl (
vtn_name varchar(32) default ' ',
valid_logical_port_id smallint default 0,
valid_vlanid smallint default 0,
valid_tagged smallint default 0,
+ valid_vex_name smallint default 0,
+ valid_vex_if_name smallint default 0,
+ valid_vex_link_name smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_admin_status smallint default 3,
- cs_description smallint default 3,
- cs_portmap smallint default 3,
- cs_logical_port_id smallint default 3,
- cs_vlanid smallint default 3,
- cs_tagged smallint default 3,
- Primary Key(vtn_name, vbridge_name, if_name));
+ cs_rowstatus smallint default 1,
+ cs_admin_status smallint default 1,
+ cs_description smallint default 1,
+ cs_portmap smallint default 1,
+ cs_logical_port_id smallint default 1,
+ cs_vlanid smallint default 1,
+ cs_tagged smallint default 1,
+ PRIMARY KEY(vtn_name, vbridge_name, if_name));
CREATE TABLE im_vrt_tbl (
vtn_name varchar(32) default ' ',
valid_vrt_description smallint default 0,
valid_dhcprelay_admin_status smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_controller_name smallint default 3,
- cs_domain_id smallint default 3,
- cs_vrt_description smallint default 3,
- cs_dhcprelay_admin_status smallint default 3,
- Primary Key(vtn_name, vrouter_name));
+ cs_rowstatus smallint default 1,
+ cs_controller_name smallint default 1,
+ cs_domain_id smallint default 1,
+ cs_vrt_description smallint default 1,
+ cs_dhcprelay_admin_status smallint default 1,
+ PRIMARY KEY(vtn_name, vrouter_name));
CREATE TABLE im_vrt_if_tbl (
vtn_name varchar(32) default ' ',
valid_mac_addr smallint default 0,
valid_admin_status smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_ip_addr smallint default 3,
- cs_mask smallint default 3,
- cs_mac_addr smallint default 3,
- cs_admin_status smallint default 3,
- Primary Key(vtn_name, vrouter_name, if_name));
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_ip_addr smallint default 1,
+ cs_mask smallint default 1,
+ cs_mac_addr smallint default 1,
+ cs_admin_status smallint default 1,
+ PRIMARY KEY(vtn_name, vrouter_name, if_name));
CREATE TABLE im_vnode_rename_tbl (
ctrlr_vtn_name varchar(32) default ' ',
ctrlr_vnode_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
- unc_vtn_name varchar(32) default ' ' unique,
- unc_vnode_name varchar(32) default ' ' unique,
- Primary Key(ctrlr_vtn_name, ctrlr_vnode_name, controller_name, domain_id));
+ unc_vtn_name varchar(32) default ' ',
+ unc_vnode_name varchar(32) default ' ',
+ PRIMARY KEY(ctrlr_vtn_name, ctrlr_vnode_name, controller_name, domain_id));
CREATE TABLE im_vlink_tbl (
vtn_name varchar(32) default ' ',
vlanid integer default 0,
description varchar(128) default ' ',
oper_status smallint default 0,
+ down_count bigint default 0,
controller1_name varchar(32) default ' ',
controller2_name varchar(32) default ' ',
domain1_id varchar(32) default ' ',
domain2_id varchar(32) default ' ',
- flags smallint default 0,
+ key_flags smallint default 0,
+ val_flags smallint default 0,
valid_admin_status smallint default 0,
valid_vnode1_name smallint default 0,
valid_vnode1_ifname smallint default 0,
valid_vlanid smallint default 0,
valid_description smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_admin_status smallint default 3,
- cs_vnode1_name smallint default 3,
- cs_vnode1_ifname smallint default 3,
- cs_vnode2_name smallint default 3,
- cs_vnode2_ifname smallint default 3,
- cs_boundary_name smallint default 3,
- cs_vlanid smallint default 3,
- cs_description smallint default 3,
- Primary Key(vtn_name, vlink_name));
+ cs_rowstatus smallint default 1,
+ cs_admin_status smallint default 1,
+ cs_vnode1_name smallint default 1,
+ cs_vnode1_ifname smallint default 1,
+ cs_vnode2_name smallint default 1,
+ cs_vnode2_ifname smallint default 1,
+ cs_boundary_name smallint default 1,
+ cs_vlanid smallint default 1,
+ cs_description smallint default 1,
+ PRIMARY KEY(vtn_name, vlink_name));
CREATE TABLE im_vlink_rename_tbl (
ctrlr_vtn_name varchar(32) default ' ',
ctrlr_vlink_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
- unc_vtn_name varchar(32) default ' ' unique,
- unc_vlink_name varchar(32) default ' ' unique,
- Primary Key(ctrlr_vtn_name, ctrlr_vlink_name, controller_name, domain_id));
+ unc_vtn_name varchar(32) default ' ',
+ unc_vlink_name varchar(32) default ' ',
+ PRIMARY KEY(ctrlr_vtn_name, ctrlr_vlink_name, controller_name, domain_id));
CREATE TABLE im_static_ip_route_tbl (
vtn_name varchar(32) default ' ',
vrouter_name varchar(32) default ' ',
dst_ip_addr bytea default '\000\000\000\000',
mask smallint default 0,
- nwm_name varchar(32) default ' ',
next_hop_addr bytea default '\000\000\000\000',
+ nwm_name varchar(32) default ' ',
metric integer default 0,
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- valid_next_hop_addr integer default 0,
- valid_metric integer default 0,
- cs_rowstatus smallint default 3,
- cs_next_hop_addr integer default 3,
- cs_metric integer default 3,
- Primary Key(vtn_name, vrouter_name, dst_ip_addr, mask, nwm_name));
+ valid_metric smallint default 0,
+ cs_rowstatus smallint default 1,
+ cs_metric smallint default 1,
+ PRIMARY KEY(vtn_name, vrouter_name, dst_ip_addr, mask, next_hop_addr, nwm_name));
CREATE TABLE im_dhcp_relay_server_tbl (
vtn_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vrouter_name));
+ cs_rowstatus smallint default 1,
+ PRIMARY KEY(vtn_name, vrouter_name, server_ip_addr));
CREATE TABLE im_dhcp_relay_if_tbl (
vtn_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vrouter_name));
+ cs_rowstatus smallint default 1,
+ PRIMARY KEY(vtn_name, vrouter_name, if_name));
CREATE TABLE im_vbr_nwmon_grp_tbl (
vtn_name varchar(32) default ' ',
flags smallint default 0,
valid_admin_status smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_admin_status smallint default 3,
- Primary Key(vtn_name, vbridge_name, nwm_name));
+ cs_rowstatus smallint default 1,
+ cs_admin_status smallint default 1,
+ PRIMARY KEY(vtn_name, vbridge_name, nwm_name));
CREATE TABLE im_vbr_nwmon_host_tbl (
vtn_name varchar(32) default ' ',
valid_failure_count smallint default 0,
valid_recovery_count smallint default 0,
valid_wait_time smallint default 0,
- cs_rowstatus smallint default 3,
- cs_health_interval smallint default 3,
- cs_recovery_interval smallint default 3,
- cs_failure_count smallint default 3,
- cs_recovery_count smallint default 3,
- cs_wait_time smallint default 3,
- Primary Key(vtn_name, vbridge_name, nwm_name, host_address));
+ cs_rowstatus smallint default 1,
+ cs_health_interval smallint default 1,
+ cs_recovery_interval smallint default 1,
+ cs_failure_count smallint default 1,
+ cs_recovery_count smallint default 1,
+ cs_wait_time smallint default 1,
+ PRIMARY KEY(vtn_name, vbridge_name, nwm_name, host_address));
CREATE TABLE im_vunknown_tbl (
vtn_name varchar(32) default ' ',
valid_description smallint default 0,
valid_type smallint default 0,
valid_domain_id smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_type smallint default 3,
- cs_domain_id smallint default 3,
- Primary Key(vtn_name, vunknown_name));
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_type smallint default 1,
+ cs_domain_id smallint default 1,
+ PRIMARY KEY(vtn_name, vunknown_name));
CREATE TABLE im_vunknown_if_tbl (
vtn_name varchar(32) default ' ',
flags smallint default 0,
valid_description smallint default 0,
valid_admin_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_admin_status smallint default 3,
- Primary Key(vtn_name, vunknown_name, if_name));
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_admin_status smallint default 1,
+ PRIMARY KEY(vtn_name, vunknown_name, if_name));
CREATE TABLE im_vtep_tbl (
vtn_name varchar(32) default ' ',
valid_controller_name smallint default 0,
valid_domain_id smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_controller_name smallint default 3,
- cs_domain_id smallint default 3,
- Primary Key(vtn_name, vtep_name));
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_controller_name smallint default 1,
+ cs_domain_id smallint default 1,
+ PRIMARY KEY(vtn_name, vtep_name));
CREATE TABLE im_vtep_if_tbl (
vtn_name varchar(32) default ' ',
valid_vlanid smallint default 0,
valid_tagged smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_admin_status smallint default 3,
- cs_portmap smallint default 3,
- cs_logical_port_id smallint default 3,
- cs_vlanid smallint default 3,
- cs_tagged smallint default 3,
- Primary Key(vtn_name, vtep_name, if_name));
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_admin_status smallint default 1,
+ cs_portmap smallint default 1,
+ cs_logical_port_id smallint default 1,
+ cs_vlanid smallint default 1,
+ cs_tagged smallint default 1,
+ PRIMARY KEY(vtn_name, vtep_name, if_name));
CREATE TABLE im_vtep_grp_tbl (
vtn_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
description varchar(128) default ' ',
flags smallint default 0,
- valid_controller_name varchar(32) default 0,
- valid_description varchar(32) default 0,
- cs_rowstatus smallint default 3,
- cs_controller_name varchar(32) default 3,
- cs_description varchar(32) default 3,
- Primary Key(vtn_name, vtepgrp_name));
+ valid_controller_name smallint default 0,
+ valid_description smallint default 0,
+ cs_rowstatus smallint default 1,
+ cs_controller_name smallint default 1,
+ cs_description smallint default 1,
+ PRIMARY KEY(vtn_name, vtepgrp_name));
CREATE TABLE im_vtep_grp_mem_tbl (
vtn_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vtepgrp_name, vtepgrp_member_name));
+ cs_rowstatus smallint default 1,
+ PRIMARY KEY(vtn_name, vtepgrp_name, vtepgrp_member_name));
CREATE TABLE im_vtunnel_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
underlay_vtn_name varchar(32) default ' ',
vtepgrp_name varchar(32) default ' ',
- label integer default 0,
+ label bigint default 0,
oper_status smallint default 0,
down_count bigint default 0,
flags smallint default 0,
valid_vtepgrp_name smallint default 0,
valid_label smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_controller_name smallint default 3,
- cs_domain_id smallint default 3,
- cs_underlay_vtn_name smallint default 3,
- cs_vtepgrp_name smallint default 3,
- cs_label smallint default 3,
- Primary Key(vtn_name, vtunnel_name));
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_controller_name smallint default 1,
+ cs_domain_id smallint default 1,
+ cs_underlay_vtn_name smallint default 1,
+ cs_vtepgrp_name smallint default 1,
+ cs_label smallint default 1,
+ PRIMARY KEY(vtn_name, vtunnel_name));
CREATE TABLE im_vtunnel_if_tbl (
vtn_name varchar(32) default ' ',
valid_vlanid smallint default 0,
valid_tagged smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_admin_status smallint default 3,
- cs_portmap smallint default 3,
- cs_logical_port_id smallint default 3,
- cs_vlanid smallint default 3,
- Primary Key(vtn_name, vtunnel_name, if_name, description));
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_admin_status smallint default 1,
+ cs_portmap smallint default 1,
+ cs_logical_port_id smallint default 1,
+ cs_vlanid smallint default 1,
+ cs_tagged smallint default 1,
+ PRIMARY KEY(vtn_name, vtunnel_name, if_name));
CREATE TABLE im_flowlist_tbl (
flowlist_name varchar(33) default ' ',
ip_type smallint default 0,
flags smallint default 0,
valid_ip_type smallint default 0,
- cs_rowstatus smallint default 3,
- cs_ip_type smallint default 3,
- Primary Key(flowlist_name));
+ cs_rowstatus smallint default 1,
+ cs_ip_type smallint default 1,
+ PRIMARY KEY(flowlist_name));
CREATE TABLE im_flowlist_ctrlr_tbl (
flowlist_name varchar(33) default ' ',
ref_count bigint default 0,
flags smallint default 0,
valid_ip_type smallint default 0,
- cs_rowstatus smallint default 3,
- cs_ip_type smallint default 3,
- Primary Key(flowlist_name, ctrlr_name));
+ cs_rowstatus smallint default 1,
+ cs_ip_type smallint default 1,
+ PRIMARY KEY(flowlist_name, ctrlr_name));
CREATE TABLE im_flowlist_rename_tbl (
ctrlr_flowlist_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
- unc_flowlist_name varchar(33) default ' ' unique,
- Primary Key(ctrlr_flowlist_name, ctrlr_name));
+ unc_flowlist_name varchar(33) default ' ',
+ PRIMARY KEY(ctrlr_flowlist_name, ctrlr_name));
CREATE TABLE im_flowlist_entry_tbl (
flowlist_name varchar(33) default ' ',
valid_icmp_code smallint default 0,
valid_icmpv6_type smallint default 0,
valid_icmpv6_code smallint default 0,
- cs_rowstatus smallint default 3,
- cs_mac_dst smallint default 3,
- cs_mac_src smallint default 3,
- cs_mac_eth_type smallint default 3,
- cs_dst_ip smallint default 3,
- cs_dst_ip_prefix smallint default 3,
- cs_src_ip smallint default 3,
- cs_src_ip_prefix smallint default 3,
- cs_vlan_priority smallint default 3,
- cs_dst_ipv6 smallint default 3,
- cs_dst_ipv6_prefix smallint default 3,
- cs_src_ipv6 smallint default 3,
- cs_src_ipv6_prefix smallint default 3,
- cs_ip_protocol smallint default 3,
- cs_ip_dscp smallint default 3,
- cs_l4_dst_port smallint default 3,
- cs_l4_dst_port_endpt smallint default 3,
- cs_l4_src_port smallint default 3,
- cs_l4_src_port_endpt smallint default 3,
- cs_icmp_type smallint default 3,
- cs_icmp_code smallint default 3,
- cs_icmpv6_type smallint default 3,
- cs_icmpv6_code smallint default 3,
- Primary Key(flowlist_name, sequence_num));
+ cs_rowstatus smallint default 1,
+ cs_mac_dst smallint default 1,
+ cs_mac_src smallint default 1,
+ cs_mac_eth_type smallint default 1,
+ cs_dst_ip smallint default 1,
+ cs_dst_ip_prefix smallint default 1,
+ cs_src_ip smallint default 1,
+ cs_src_ip_prefix smallint default 1,
+ cs_vlan_priority smallint default 1,
+ cs_dst_ipv6 smallint default 1,
+ cs_dst_ipv6_prefix smallint default 1,
+ cs_src_ipv6 smallint default 1,
+ cs_src_ipv6_prefix smallint default 1,
+ cs_ip_protocol smallint default 1,
+ cs_ip_dscp smallint default 1,
+ cs_l4_dst_port smallint default 1,
+ cs_l4_dst_port_endpt smallint default 1,
+ cs_l4_src_port smallint default 1,
+ cs_l4_src_port_endpt smallint default 1,
+ cs_icmp_type smallint default 1,
+ cs_icmp_code smallint default 1,
+ cs_icmpv6_type smallint default 1,
+ cs_icmpv6_code smallint default 1,
+ PRIMARY KEY(flowlist_name, sequence_num));
CREATE TABLE im_flowlist_entry_ctrlr_tbl (
flowlist_name varchar(33) default ' ',
valid_icmp_code smallint default 0,
valid_icmpv6_type smallint default 0,
valid_icmpv6_code smallint default 0,
- cs_rowstatus smallint default 3,
- cs_mac_dst smallint default 3,
- cs_mac_src smallint default 3,
- cs_mac_eth_type smallint default 3,
- cs_dst_ip smallint default 3,
- cs_dst_ip_prefix smallint default 3,
- cs_src_ip smallint default 3,
- cs_src_ip_prefix smallint default 3,
- cs_vlan_priority smallint default 3,
- cs_dst_ipv6 smallint default 3,
- cs_dst_ipv6_prefix smallint default 3,
- cs_src_ipv6 smallint default 3,
- cs_src_ipv6_prefix smallint default 3,
- cs_ip_protocol smallint default 3,
- cs_ip_dscp smallint default 3,
- cs_l4_dst_port smallint default 3,
- cs_l4_dst_port_endpt smallint default 3,
- cs_l4_src_port smallint default 3,
- cs_l4_src_port_endpt smallint default 3,
- cs_icmp_type smallint default 3,
- cs_icmp_code smallint default 3,
- cs_icmpv6_type smallint default 3,
- cs_icmpv6_code smallint default 3,
- Primary Key(flowlist_name, sequence_num, ctrlr_name));
+ cs_rowstatus smallint default 1,
+ cs_mac_dst smallint default 1,
+ cs_mac_src smallint default 1,
+ cs_mac_eth_type smallint default 1,
+ cs_dst_ip smallint default 1,
+ cs_dst_ip_prefix smallint default 1,
+ cs_src_ip smallint default 1,
+ cs_src_ip_prefix smallint default 1,
+ cs_vlan_priority smallint default 1,
+ cs_dst_ipv6 smallint default 1,
+ cs_dst_ipv6_prefix smallint default 1,
+ cs_src_ipv6 smallint default 1,
+ cs_src_ipv6_prefix smallint default 1,
+ cs_ip_protocol smallint default 1,
+ cs_ip_dscp smallint default 1,
+ cs_l4_dst_port smallint default 1,
+ cs_l4_dst_port_endpt smallint default 1,
+ cs_l4_src_port smallint default 1,
+ cs_l4_src_port_endpt smallint default 1,
+ cs_icmp_type smallint default 1,
+ cs_icmp_code smallint default 1,
+ cs_icmpv6_type smallint default 1,
+ cs_icmpv6_code smallint default 1,
+ PRIMARY KEY(flowlist_name, sequence_num, ctrlr_name));
CREATE TABLE im_policingprofile_tbl (
policingprofile_name varchar(33) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
- Primary Key(policingprofile_name));
+ cs_rowstatus smallint default 1,
+ PRIMARY KEY(policingprofile_name));
CREATE TABLE im_policingprofile_ctrlr_tbl (
policingprofile_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
ref_count bigint default 0,
flags smallint default 0,
- cs_rowstatus smallint default 3,
- Primary Key(policingprofile_name, ctrlr_name));
+ cs_rowstatus smallint default 1,
+ PRIMARY KEY(policingprofile_name, ctrlr_name));
CREATE TABLE im_policingprofile_rename_tbl (
ctrlr_policingprofile_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
- unc_policingprofile_name varchar(33) default ' ' unique,
- Primary Key(ctrlr_policingprofile_name, ctrlr_name));
+ unc_policingprofile_name varchar(33) default ' ',
+ PRIMARY KEY(ctrlr_policingprofile_name, ctrlr_name));
CREATE TABLE im_policingprofile_entry_tbl (
policingprofile_name varchar(33) default ' ',
valid_red_priority smallint default 0,
valid_red_dscp smallint default 0,
valid_red_drop smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist smallint default 3,
- cs_rate smallint default 3,
- cs_cir smallint default 3,
- cs_cbs smallint default 3,
- cs_pir smallint default 3,
- cs_pbs smallint default 3,
- cs_green_action smallint default 3,
- cs_green_priority smallint default 3,
- cs_green_dscp smallint default 3,
- cs_green_drop smallint default 3,
- cs_yellow_action smallint default 3,
- cs_yellow_priority smallint default 3,
- cs_yellow_dscp smallint default 3,
- cs_yellow_drop smallint default 3,
- cs_red_action smallint default 3,
- cs_red_priority smallint default 3,
- cs_red_dscp smallint default 3,
- cs_red_drop smallint default 3,
- Primary Key(policingprofile_name, sequence_num));
+ cs_rowstatus smallint default 1,
+ cs_flowlist smallint default 1,
+ cs_rate smallint default 1,
+ cs_cir smallint default 1,
+ cs_cbs smallint default 1,
+ cs_pir smallint default 1,
+ cs_pbs smallint default 1,
+ cs_green_action smallint default 1,
+ cs_green_priority smallint default 1,
+ cs_green_dscp smallint default 1,
+ cs_green_drop smallint default 1,
+ cs_yellow_action smallint default 1,
+ cs_yellow_priority smallint default 1,
+ cs_yellow_dscp smallint default 1,
+ cs_yellow_drop smallint default 1,
+ cs_red_action smallint default 1,
+ cs_red_priority smallint default 1,
+ cs_red_dscp smallint default 1,
+ cs_red_drop smallint default 1,
+ PRIMARY KEY(policingprofile_name, sequence_num));
CREATE TABLE im_policingprofile_entry_ctrlr_tbl (
policingprofile_name varchar(33) default ' ',
valid_red_priority smallint default 0,
valid_red_dscp smallint default 0,
valid_red_drop smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist smallint default 3,
- cs_rate smallint default 3,
- cs_cir smallint default 3,
- cs_cbs smallint default 3,
- cs_pir smallint default 3,
- cs_pbs smallint default 3,
- cs_green_action smallint default 3,
- cs_green_priority smallint default 3,
- cs_green_dscp smallint default 3,
- cs_green_drop smallint default 3,
- cs_yellow_action smallint default 3,
- cs_yellow_priority smallint default 3,
- cs_yellow_dscp smallint default 3,
- cs_yellow_drop smallint default 3,
- cs_red_action smallint default 3,
- cs_red_priority smallint default 3,
- cs_red_dscp smallint default 3,
- cs_red_drop smallint default 3,
- Primary Key(policingprofile_name, sequence_num, ctrlr_name));
+ cs_rowstatus smallint default 1,
+ cs_flowlist smallint default 1,
+ cs_rate smallint default 1,
+ cs_cir smallint default 1,
+ cs_cbs smallint default 1,
+ cs_pir smallint default 1,
+ cs_pbs smallint default 1,
+ cs_green_action smallint default 1,
+ cs_green_priority smallint default 1,
+ cs_green_dscp smallint default 1,
+ cs_green_drop smallint default 1,
+ cs_yellow_action smallint default 1,
+ cs_yellow_priority smallint default 1,
+ cs_yellow_dscp smallint default 1,
+ cs_yellow_drop smallint default 1,
+ cs_red_action smallint default 1,
+ cs_red_priority smallint default 1,
+ cs_red_dscp smallint default 1,
+ cs_red_drop smallint default 1,
+ PRIMARY KEY(policingprofile_name, sequence_num, ctrlr_name));
CREATE TABLE im_vtn_flowfilter_tbl (
vtn_name varchar(32) default ' ',
direction smallint default 0,
flags smallint default 0,
- cs_rowstatus smallint default 3,
- Primary Key(vtn_name, direction));
+ cs_rowstatus smallint default 1,
+ PRIMARY KEY(vtn_name, direction));
CREATE TABLE im_vtn_flowfilter_ctrlr_tbl (
vtn_name varchar(32) default ' ',
ctrlr_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
- Primary Key(vtn_name, direction, ctrlr_name, domain_id));
+ cs_rowstatus smallint default 1,
+ PRIMARY KEY(vtn_name, direction, ctrlr_name, domain_id));
CREATE TABLE im_vtn_flowfilter_entry_tbl (
vtn_name varchar(32) default ' ',
valid_nwn_name smallint default 0,
valid_dscp smallint default 0,
valid_priority smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist_name smallint default 3,
- cs_action smallint default 3,
- cs_nwn_name smallint default 3,
- cs_dscp smallint default 3,
- cs_priority smallint default 3,
- Primary Key(vtn_name, direction, sequence_num));
+ cs_rowstatus smallint default 1,
+ cs_flowlist_name smallint default 1,
+ cs_action smallint default 1,
+ cs_nwn_name smallint default 1,
+ cs_dscp smallint default 1,
+ cs_priority smallint default 1,
+ PRIMARY KEY(vtn_name, direction, sequence_num));
CREATE TABLE im_vtn_flowfilter_entry_ctrlr_tbl (
vtn_name varchar(32) default ' ',
valid_nwn_name smallint default 0,
valid_dscp smallint default 0,
valid_priority smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist_name smallint default 3,
- cs_action smallint default 3,
- cs_nwn_name smallint default 3,
- cs_dscp smallint default 3,
- cs_priority smallint default 3,
- Primary Key(vtn_name, direction, sequence_num, ctrlr_name, domain_id));
+ cs_rowstatus smallint default 1,
+ cs_flowlist_name smallint default 1,
+ cs_action smallint default 1,
+ cs_nwn_name smallint default 1,
+ cs_dscp smallint default 1,
+ cs_priority smallint default 1,
+ PRIMARY KEY(vtn_name, direction, sequence_num, ctrlr_name, domain_id));
CREATE TABLE im_vbr_flowfilter_tbl (
vtn_name varchar(32) default ' ',
ctrlr_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vbr_name, direction));
+ cs_rowstatus smallint default 1,
+ PRIMARY KEY(vtn_name, vbr_name, direction));
CREATE TABLE im_vbr_flowfilter_entry_tbl (
vtn_name varchar(32) default ' ',
valid_nwn_name smallint default 0,
valid_dscp smallint default 0,
valid_priority smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist_name smallint default 3,
- cs_action smallint default 3,
- cs_redirect_node smallint default 3,
- cs_redirect_port smallint default 3,
- cs_modify_dst_mac smallint default 3,
- cs_modify_src_mac smallint default 3,
- cs_nwm_name smallint default 3,
- cs_dscp smallint default 3,
- cs_priority smallint default 3,
- Primary Key(vtn_name, vbr_name, direction, sequence_num));
+ cs_rowstatus smallint default 1,
+ cs_flowlist_name smallint default 1,
+ cs_action smallint default 1,
+ cs_redirect_node smallint default 1,
+ cs_redirect_port smallint default 1,
+ cs_modify_dst_mac smallint default 1,
+ cs_modify_src_mac smallint default 1,
+ cs_nwm_name smallint default 1,
+ cs_dscp smallint default 1,
+ cs_priority smallint default 1,
+ PRIMARY KEY(vtn_name, vbr_name, direction, sequence_num));
CREATE TABLE im_vbr_if_flowfilter_tbl (
vtn_name varchar(32) default ' ',
ctrlr_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vbr_name, vbr_if_name, direction));
+ cs_rowstatus smallint default 1,
+ PRIMARY KEY(vtn_name, vbr_name, vbr_if_name, direction));
CREATE TABLE im_vbr_if_flowfilter_entry_tbl (
vtn_name varchar(32) default ' ',
valid_nwn_name smallint default 0,
valid_dscp smallint default 0,
valid_priority smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist_name smallint default 3,
- cs_action smallint default 3,
- cs_redirect_node smallint default 3,
- cs_redirect_port smallint default 3,
- cs_modify_dst_mac smallint default 3,
- cs_modify_src_mac smallint default 3,
- cs_nwm_name smallint default 3,
- cs_dscp smallint default 3,
- cs_priority smallint default 3,
- Primary Key(vtn_name, vbr_name, vbr_if_name, direction, sequence_num));
+ cs_rowstatus smallint default 1,
+ cs_flowlist_name smallint default 1,
+ cs_action smallint default 1,
+ cs_redirect_node smallint default 1,
+ cs_redirect_port smallint default 1,
+ cs_modify_dst_mac smallint default 1,
+ cs_modify_src_mac smallint default 1,
+ cs_nwm_name smallint default 1,
+ cs_dscp smallint default 1,
+ cs_priority smallint default 1,
+ PRIMARY KEY(vtn_name, vbr_name, vbr_if_name, direction, sequence_num));
CREATE TABLE im_vrt_if_flowfilter_tbl (
vtn_name varchar(32) default ' ',
ctrlr_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vrt_name, vrt_if_name, direction));
+ cs_rowstatus smallint default 1,
+ PRIMARY KEY(vtn_name, vrt_name, vrt_if_name, direction));
CREATE TABLE im_vrt_if_flowfilter_entry_tbl (
vtn_name varchar(32) default ' ',
valid_nwn_name smallint default 0,
valid_dscp smallint default 0,
valid_priority smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist_name smallint default 3,
- cs_action smallint default 3,
- cs_redirect_node smallint default 3,
- cs_redirect_port smallint default 3,
- cs_modify_dst_mac smallint default 3,
- cs_modify_src_mac smallint default 3,
- cs_nwm_name smallint default 3,
- cs_dscp smallint default 3,
- cs_priority smallint default 3,
- Primary Key(vtn_name, vrt_name, vrt_if_name, direction, sequence_num));
+ cs_rowstatus smallint default 1,
+ cs_flowlist_name smallint default 1,
+ cs_action smallint default 1,
+ cs_redirect_node smallint default 1,
+ cs_redirect_port smallint default 1,
+ cs_modify_dst_mac smallint default 1,
+ cs_modify_src_mac smallint default 1,
+ cs_nwm_name smallint default 1,
+ cs_dscp smallint default 1,
+ cs_priority smallint default 1,
+ PRIMARY KEY(vtn_name, vrt_name, vrt_if_name, direction, sequence_num));
CREATE TABLE im_vtn_policingmap_tbl (
vtn_name varchar(32) default ' ',
policername varchar(33) default ' ',
flags smallint default 0,
valid_policername smallint default 0,
- cs_rowstatus smallint default 3,
- cs_policername smallint default 3,
- Primary Key(vtn_name));
+ cs_rowstatus smallint default 1,
+ cs_policername smallint default 1,
+ PRIMARY KEY(vtn_name));
CREATE TABLE im_vtn_policingmap_ctrlr_tbl (
vtn_name varchar(32) default ' ',
policername varchar(33) default ' ',
flags smallint default 0,
valid_policername smallint default 0,
- cs_rowstatus smallint default 3,
- cs_policername smallint default 3,
- Primary Key(vtn_name, ctrlr_name, domain_id));
+ cs_rowstatus smallint default 1,
+ cs_policername smallint default 1,
+ PRIMARY KEY(vtn_name, ctrlr_name, domain_id));
CREATE TABLE im_vbr_policingmap_tbl (
vtn_name varchar(32) default ' ',
policername varchar(33) default ' ',
flags smallint default 0,
valid_policername smallint default 0,
- cs_rowstatus smallint default 3,
- cs_policername smallint default 3,
- Primary Key(vtn_name, vbr_name));
+ cs_rowstatus smallint default 1,
+ cs_policername smallint default 1,
+ PRIMARY KEY(vtn_name, vbr_name));
CREATE TABLE im_vbr_if_policingmap_tbl (
vtn_name varchar(32) default ' ',
policername varchar(33) default ' ',
flags smallint default 0,
valid_policername smallint default 0,
- cs_rowstatus smallint default 3,
- cs_policername smallint default 3,
- Primary Key(vtn_name, vbr_name, vbr_if_name));
+ cs_rowstatus smallint default 1,
+ cs_policername smallint default 1,
+ PRIMARY KEY(vtn_name, vbr_name, vbr_if_name));
CREATE TABLE au_vtn_tbl (
vtn_name varchar(32) default ' ',
valid_alarm_status smallint default 0,
valid_creation_time smallint default 0,
valid_last_updated_time smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- Primary Key(vtn_name));
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ PRIMARY KEY(vtn_name));
CREATE TABLE au_vtn_ctrlr_tbl (
vtn_name varchar(32) default ' ',
flags smallint default 0,
valid_oper_status smallint default 0,
valid_alarm_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- Primary Key(vtn_name, controller_name, domain_id));
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ PRIMARY KEY(vtn_name, controller_name, domain_id));
CREATE TABLE au_vtn_rename_tbl (
ctrlr_vtn_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
- unc_vtn_name varchar(32) default ' ' unique,
- Primary Key(ctrlr_vtn_name, controller_name, domain_id));
+ unc_vtn_name varchar(32) default ' ',
+ PRIMARY KEY(ctrlr_vtn_name, controller_name, domain_id));
CREATE TABLE au_vbr_tbl (
vtn_name varchar(32) default ' ',
valid_host_addr smallint default 0,
valid_host_addr_mask smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_controller_name smallint default 3,
- cs_domain_id smallint default 3,
- cs_vbr_description smallint default 3,
- cs_host_addr smallint default 3,
- cs_host_addr_mask smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_controller_name smallint default 1,
+ cs_domain_id smallint default 1,
+ cs_vbr_description smallint default 1,
+ cs_host_addr smallint default 1,
+ cs_host_addr_mask smallint default 1,
flags smallint default 0,
- Primary Key(vtn_name, vbridge_name));
+ PRIMARY KEY(vtn_name, vbridge_name));
CREATE TABLE au_vbr_vlanmap_tbl (
vtn_name varchar(32) default ' ',
vbridge_name varchar(32) default ' ',
logical_port_id varchar(320) default ' ',
- logical_port_id_valid varchar(320) default ' ',
- vlanid smallint default 0,
+ logical_port_id_valid smallint default 0,
+ vlanid integer default 0,
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
valid_vlanid smallint default 0,
- cs_rowstatus smallint default 3,
- cs_vlanid smallint default 3,
- Primary Key(vtn_name, vbridge_name, logical_port_id, logical_port_id_valid));
+ cs_rowstatus smallint default 1,
+ cs_vlanid smallint default 1,
+ PRIMARY KEY(vtn_name, vbridge_name, logical_port_id, logical_port_id_valid));
CREATE TABLE au_vbr_if_tbl (
vtn_name varchar(32) default ' ',
valid_logical_port_id smallint default 0,
valid_vlanid smallint default 0,
valid_tagged smallint default 0,
+ valid_vex_name smallint default 0,
+ valid_vex_if_name smallint default 0,
+ valid_vex_link_name smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_admin_status smallint default 3,
- cs_description smallint default 3,
- cs_portmap smallint default 3,
- cs_logical_port_id smallint default 3,
- cs_vlanid smallint default 3,
- cs_tagged smallint default 3,
- Primary Key(vtn_name, vbridge_name, if_name));
+ cs_rowstatus smallint default 1,
+ cs_admin_status smallint default 1,
+ cs_description smallint default 1,
+ cs_portmap smallint default 1,
+ cs_logical_port_id smallint default 1,
+ cs_vlanid smallint default 1,
+ cs_tagged smallint default 1,
+ PRIMARY KEY(vtn_name, vbridge_name, if_name));
CREATE TABLE au_vrt_tbl (
vtn_name varchar(32) default ' ',
valid_vrt_description smallint default 0,
valid_dhcprelay_admin_status smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_controller_name smallint default 3,
- cs_domain_id smallint default 3,
- cs_vrt_description smallint default 3,
- cs_dhcprelay_admin_status smallint default 3,
- Primary Key(vtn_name, vrouter_name));
+ cs_rowstatus smallint default 1,
+ cs_controller_name smallint default 1,
+ cs_domain_id smallint default 1,
+ cs_vrt_description smallint default 1,
+ cs_dhcprelay_admin_status smallint default 1,
+ PRIMARY KEY(vtn_name, vrouter_name));
CREATE TABLE au_vrt_if_tbl (
vtn_name varchar(32) default ' ',
valid_mac_addr smallint default 0,
valid_admin_status smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_ip_addr smallint default 3,
- cs_mask smallint default 3,
- cs_mac_addr smallint default 3,
- cs_admin_status smallint default 3,
- Primary Key(vtn_name, vrouter_name, if_name));
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_ip_addr smallint default 1,
+ cs_mask smallint default 1,
+ cs_mac_addr smallint default 1,
+ cs_admin_status smallint default 1,
+ PRIMARY KEY(vtn_name, vrouter_name, if_name));
CREATE TABLE au_vnode_rename_tbl (
ctrlr_vtn_name varchar(32) default ' ',
ctrlr_vnode_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
- unc_vtn_name varchar(32) default ' ' unique,
- unc_vnode_name varchar(32) default ' ' unique,
- Primary Key(ctrlr_vtn_name, ctrlr_vnode_name, controller_name, domain_id));
+ unc_vtn_name varchar(32) default ' ',
+ unc_vnode_name varchar(32) default ' ',
+ PRIMARY KEY(ctrlr_vtn_name, ctrlr_vnode_name, controller_name, domain_id));
CREATE TABLE au_vlink_tbl (
vtn_name varchar(32) default ' ',
vlanid integer default 0,
description varchar(128) default ' ',
oper_status smallint default 0,
+ down_count bigint default 0,
controller1_name varchar(32) default ' ',
controller2_name varchar(32) default ' ',
domain1_id varchar(32) default ' ',
domain2_id varchar(32) default ' ',
- flags smallint default 0,
+ key_flags smallint default 0,
+ val_flags smallint default 0,
valid_admin_status smallint default 0,
valid_vnode1_name smallint default 0,
valid_vnode1_ifname smallint default 0,
valid_vlanid smallint default 0,
valid_description smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_admin_status smallint default 3,
- cs_vnode1_name smallint default 3,
- cs_vnode1_ifname smallint default 3,
- cs_vnode2_name smallint default 3,
- cs_vnode2_ifname smallint default 3,
- cs_boundary_name smallint default 3,
- cs_vlanid smallint default 3,
- cs_description smallint default 3,
- Primary Key(vtn_name, vlink_name));
+ cs_rowstatus smallint default 1,
+ cs_admin_status smallint default 1,
+ cs_vnode1_name smallint default 1,
+ cs_vnode1_ifname smallint default 1,
+ cs_vnode2_name smallint default 1,
+ cs_vnode2_ifname smallint default 1,
+ cs_boundary_name smallint default 1,
+ cs_vlanid smallint default 1,
+ cs_description smallint default 1,
+ PRIMARY KEY(vtn_name, vlink_name));
CREATE TABLE au_vlink_rename_tbl (
ctrlr_vtn_name varchar(32) default ' ',
ctrlr_vlink_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
- unc_vtn_name varchar(32) default ' ' unique,
- unc_vlink_name varchar(32) default ' ' unique,
- Primary Key(ctrlr_vtn_name, ctrlr_vlink_name, controller_name, domain_id));
+ unc_vtn_name varchar(32) default ' ',
+ unc_vlink_name varchar(32) default ' ',
+ PRIMARY KEY(ctrlr_vtn_name, ctrlr_vlink_name, controller_name, domain_id));
CREATE TABLE au_static_ip_route_tbl (
vtn_name varchar(32) default ' ',
vrouter_name varchar(32) default ' ',
dst_ip_addr bytea default '\000\000\000\000',
mask smallint default 0,
- nwm_name varchar(32) default ' ',
next_hop_addr bytea default '\000\000\000\000',
+ nwm_name varchar(32) default ' ',
metric integer default 0,
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- valid_next_hop_addr integer default 0,
- valid_metric integer default 0,
- cs_rowstatus smallint default 3,
- cs_next_hop_addr integer default 3,
- cs_metric integer default 3,
- Primary Key(vtn_name, vrouter_name, dst_ip_addr, mask, nwm_name));
+ valid_metric smallint default 0,
+ cs_rowstatus smallint default 1,
+ cs_metric smallint default 1,
+ PRIMARY KEY(vtn_name, vrouter_name, dst_ip_addr, mask, next_hop_addr, nwm_name));
CREATE TABLE au_dhcp_relay_server_tbl (
vtn_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vrouter_name));
+ cs_rowstatus smallint default 1,
+ PRIMARY KEY(vtn_name, vrouter_name, server_ip_addr));
CREATE TABLE au_dhcp_relay_if_tbl (
vtn_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vrouter_name));
+ cs_rowstatus smallint default 1,
+ PRIMARY KEY(vtn_name, vrouter_name, if_name));
CREATE TABLE au_vbr_nwmon_grp_tbl (
vtn_name varchar(32) default ' ',
flags smallint default 0,
valid_admin_status smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_admin_status smallint default 3,
- Primary Key(vtn_name, vbridge_name, nwm_name));
+ cs_rowstatus smallint default 1,
+ cs_admin_status smallint default 1,
+ PRIMARY KEY(vtn_name, vbridge_name, nwm_name));
CREATE TABLE au_vbr_nwmon_host_tbl (
vtn_name varchar(32) default ' ',
valid_failure_count smallint default 0,
valid_recovery_count smallint default 0,
valid_wait_time smallint default 0,
- cs_rowstatus smallint default 3,
- cs_health_interval smallint default 3,
- cs_recovery_interval smallint default 3,
- cs_failure_count smallint default 3,
- cs_recovery_count smallint default 3,
- cs_wait_time smallint default 3,
- Primary Key(vtn_name, vbridge_name, nwm_name, host_address));
+ cs_rowstatus smallint default 1,
+ cs_health_interval smallint default 1,
+ cs_recovery_interval smallint default 1,
+ cs_failure_count smallint default 1,
+ cs_recovery_count smallint default 1,
+ cs_wait_time smallint default 1,
+ PRIMARY KEY(vtn_name, vbridge_name, nwm_name, host_address));
CREATE TABLE au_vunknown_tbl (
vtn_name varchar(32) default ' ',
valid_description smallint default 0,
valid_type smallint default 0,
valid_domain_id smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_type smallint default 3,
- cs_domain_id smallint default 3,
- Primary Key(vtn_name, vunknown_name));
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_type smallint default 1,
+ cs_domain_id smallint default 1,
+ PRIMARY KEY(vtn_name, vunknown_name));
CREATE TABLE au_vunknown_if_tbl (
vtn_name varchar(32) default ' ',
flags smallint default 0,
valid_description smallint default 0,
valid_admin_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_admin_status smallint default 3,
- Primary Key(vtn_name, vunknown_name, if_name));
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_admin_status smallint default 1,
+ PRIMARY KEY(vtn_name, vunknown_name, if_name));
CREATE TABLE au_vtep_tbl (
vtn_name varchar(32) default ' ',
valid_controller_name smallint default 0,
valid_domain_id smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_controller_name smallint default 3,
- cs_domain_id smallint default 3,
- Primary Key(vtn_name, vtep_name));
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_controller_name smallint default 1,
+ cs_domain_id smallint default 1,
+ PRIMARY KEY(vtn_name, vtep_name));
CREATE TABLE au_vtep_if_tbl (
vtn_name varchar(32) default ' ',
valid_vlanid smallint default 0,
valid_tagged smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_admin_status smallint default 3,
- cs_portmap smallint default 3,
- cs_logical_port_id smallint default 3,
- cs_vlanid smallint default 3,
- cs_tagged smallint default 3,
- Primary Key(vtn_name, vtep_name, if_name));
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_admin_status smallint default 1,
+ cs_portmap smallint default 1,
+ cs_logical_port_id smallint default 1,
+ cs_vlanid smallint default 1,
+ cs_tagged smallint default 1,
+ PRIMARY KEY(vtn_name, vtep_name, if_name));
CREATE TABLE au_vtep_grp_tbl (
vtn_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
description varchar(128) default ' ',
flags smallint default 0,
- valid_controller_name varchar(32) default 0,
- valid_description varchar(32) default 0,
- cs_rowstatus smallint default 3,
- cs_controller_name varchar(32) default 3,
- cs_description varchar(32) default 3,
- Primary Key(vtn_name, vtepgrp_name));
+ valid_controller_name smallint default 0,
+ valid_description smallint default 0,
+ cs_rowstatus smallint default 1,
+ cs_controller_name smallint default 1,
+ cs_description smallint default 1,
+ PRIMARY KEY(vtn_name, vtepgrp_name));
CREATE TABLE au_vtep_grp_mem_tbl (
vtn_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vtepgrp_name, vtepgrp_member_name));
+ cs_rowstatus smallint default 1,
+ PRIMARY KEY(vtn_name, vtepgrp_name, vtepgrp_member_name));
CREATE TABLE au_vtunnel_tbl (
vtn_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
underlay_vtn_name varchar(32) default ' ',
vtepgrp_name varchar(32) default ' ',
- label integer default 0,
+ label bigint default 0,
oper_status smallint default 0,
down_count bigint default 0,
flags smallint default 0,
valid_vtepgrp_name smallint default 0,
valid_label smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_controller_name smallint default 3,
- cs_domain_id smallint default 3,
- cs_underlay_vtn_name smallint default 3,
- cs_vtepgrp_name smallint default 3,
- cs_label smallint default 3,
- Primary Key(vtn_name, vtunnel_name));
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_controller_name smallint default 1,
+ cs_domain_id smallint default 1,
+ cs_underlay_vtn_name smallint default 1,
+ cs_vtepgrp_name smallint default 1,
+ cs_label smallint default 1,
+ PRIMARY KEY(vtn_name, vtunnel_name));
CREATE TABLE au_vtunnel_if_tbl (
vtn_name varchar(32) default ' ',
valid_vlanid smallint default 0,
valid_tagged smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_admin_status smallint default 3,
- cs_portmap smallint default 3,
- cs_logical_port_id smallint default 3,
- cs_vlanid smallint default 3,
- Primary Key(vtn_name, vtunnel_name, if_name, description));
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_admin_status smallint default 1,
+ cs_portmap smallint default 1,
+ cs_logical_port_id smallint default 1,
+ cs_vlanid smallint default 1,
+ cs_tagged smallint default 1,
+ PRIMARY KEY(vtn_name, vtunnel_name, if_name));
CREATE TABLE au_flowlist_tbl (
flowlist_name varchar(33) default ' ',
ip_type smallint default 0,
flags smallint default 0,
valid_ip_type smallint default 0,
- cs_rowstatus smallint default 3,
- cs_ip_type smallint default 3,
- Primary Key(flowlist_name));
+ cs_rowstatus smallint default 1,
+ cs_ip_type smallint default 1,
+ PRIMARY KEY(flowlist_name));
CREATE TABLE au_flowlist_ctrlr_tbl (
flowlist_name varchar(33) default ' ',
ref_count bigint default 0,
flags smallint default 0,
valid_ip_type smallint default 0,
- cs_rowstatus smallint default 3,
- cs_ip_type smallint default 3,
- Primary Key(flowlist_name, ctrlr_name));
+ cs_rowstatus smallint default 1,
+ cs_ip_type smallint default 1,
+ PRIMARY KEY(flowlist_name, ctrlr_name));
CREATE TABLE au_flowlist_rename_tbl (
ctrlr_flowlist_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
- unc_flowlist_name varchar(33) default ' ' unique,
- Primary Key(ctrlr_flowlist_name, ctrlr_name));
+ unc_flowlist_name varchar(33) default ' ',
+ PRIMARY KEY(ctrlr_flowlist_name, ctrlr_name));
CREATE TABLE au_flowlist_entry_tbl (
flowlist_name varchar(33) default ' ',
valid_icmp_code smallint default 0,
valid_icmpv6_type smallint default 0,
valid_icmpv6_code smallint default 0,
- cs_rowstatus smallint default 3,
- cs_mac_dst smallint default 3,
- cs_mac_src smallint default 3,
- cs_mac_eth_type smallint default 3,
- cs_dst_ip smallint default 3,
- cs_dst_ip_prefix smallint default 3,
- cs_src_ip smallint default 3,
- cs_src_ip_prefix smallint default 3,
- cs_vlan_priority smallint default 3,
- cs_dst_ipv6 smallint default 3,
- cs_dst_ipv6_prefix smallint default 3,
- cs_src_ipv6 smallint default 3,
- cs_src_ipv6_prefix smallint default 3,
- cs_ip_protocol smallint default 3,
- cs_ip_dscp smallint default 3,
- cs_l4_dst_port smallint default 3,
- cs_l4_dst_port_endpt smallint default 3,
- cs_l4_src_port smallint default 3,
- cs_l4_src_port_endpt smallint default 3,
- cs_icmp_type smallint default 3,
- cs_icmp_code smallint default 3,
- cs_icmpv6_type smallint default 3,
- cs_icmpv6_code smallint default 3,
- Primary Key(flowlist_name, sequence_num));
+ cs_rowstatus smallint default 1,
+ cs_mac_dst smallint default 1,
+ cs_mac_src smallint default 1,
+ cs_mac_eth_type smallint default 1,
+ cs_dst_ip smallint default 1,
+ cs_dst_ip_prefix smallint default 1,
+ cs_src_ip smallint default 1,
+ cs_src_ip_prefix smallint default 1,
+ cs_vlan_priority smallint default 1,
+ cs_dst_ipv6 smallint default 1,
+ cs_dst_ipv6_prefix smallint default 1,
+ cs_src_ipv6 smallint default 1,
+ cs_src_ipv6_prefix smallint default 1,
+ cs_ip_protocol smallint default 1,
+ cs_ip_dscp smallint default 1,
+ cs_l4_dst_port smallint default 1,
+ cs_l4_dst_port_endpt smallint default 1,
+ cs_l4_src_port smallint default 1,
+ cs_l4_src_port_endpt smallint default 1,
+ cs_icmp_type smallint default 1,
+ cs_icmp_code smallint default 1,
+ cs_icmpv6_type smallint default 1,
+ cs_icmpv6_code smallint default 1,
+ PRIMARY KEY(flowlist_name, sequence_num));
CREATE TABLE au_flowlist_entry_ctrlr_tbl (
flowlist_name varchar(33) default ' ',
valid_icmp_code smallint default 0,
valid_icmpv6_type smallint default 0,
valid_icmpv6_code smallint default 0,
- cs_rowstatus smallint default 3,
- cs_mac_dst smallint default 3,
- cs_mac_src smallint default 3,
- cs_mac_eth_type smallint default 3,
- cs_dst_ip smallint default 3,
- cs_dst_ip_prefix smallint default 3,
- cs_src_ip smallint default 3,
- cs_src_ip_prefix smallint default 3,
- cs_vlan_priority smallint default 3,
- cs_dst_ipv6 smallint default 3,
- cs_dst_ipv6_prefix smallint default 3,
- cs_src_ipv6 smallint default 3,
- cs_src_ipv6_prefix smallint default 3,
- cs_ip_protocol smallint default 3,
- cs_ip_dscp smallint default 3,
- cs_l4_dst_port smallint default 3,
- cs_l4_dst_port_endpt smallint default 3,
- cs_l4_src_port smallint default 3,
- cs_l4_src_port_endpt smallint default 3,
- cs_icmp_type smallint default 3,
- cs_icmp_code smallint default 3,
- cs_icmpv6_type smallint default 3,
- cs_icmpv6_code smallint default 3,
- Primary Key(flowlist_name, sequence_num, ctrlr_name));
+ cs_rowstatus smallint default 1,
+ cs_mac_dst smallint default 1,
+ cs_mac_src smallint default 1,
+ cs_mac_eth_type smallint default 1,
+ cs_dst_ip smallint default 1,
+ cs_dst_ip_prefix smallint default 1,
+ cs_src_ip smallint default 1,
+ cs_src_ip_prefix smallint default 1,
+ cs_vlan_priority smallint default 1,
+ cs_dst_ipv6 smallint default 1,
+ cs_dst_ipv6_prefix smallint default 1,
+ cs_src_ipv6 smallint default 1,
+ cs_src_ipv6_prefix smallint default 1,
+ cs_ip_protocol smallint default 1,
+ cs_ip_dscp smallint default 1,
+ cs_l4_dst_port smallint default 1,
+ cs_l4_dst_port_endpt smallint default 1,
+ cs_l4_src_port smallint default 1,
+ cs_l4_src_port_endpt smallint default 1,
+ cs_icmp_type smallint default 1,
+ cs_icmp_code smallint default 1,
+ cs_icmpv6_type smallint default 1,
+ cs_icmpv6_code smallint default 1,
+ PRIMARY KEY(flowlist_name, sequence_num, ctrlr_name));
CREATE TABLE au_policingprofile_tbl (
policingprofile_name varchar(33) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
- Primary Key(policingprofile_name));
+ cs_rowstatus smallint default 1,
+ PRIMARY KEY(policingprofile_name));
CREATE TABLE au_policingprofile_ctrlr_tbl (
policingprofile_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
ref_count bigint default 0,
flags smallint default 0,
- cs_rowstatus smallint default 3,
- Primary Key(policingprofile_name, ctrlr_name));
+ cs_rowstatus smallint default 1,
+ PRIMARY KEY(policingprofile_name, ctrlr_name));
CREATE TABLE au_policingprofile_rename_tbl (
ctrlr_policingprofile_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
- unc_policingprofile_name varchar(33) default ' ' unique,
- Primary Key(ctrlr_policingprofile_name, ctrlr_name));
+ unc_policingprofile_name varchar(33) default ' ',
+ PRIMARY KEY(ctrlr_policingprofile_name, ctrlr_name));
CREATE TABLE au_policingprofile_entry_tbl (
policingprofile_name varchar(33) default ' ',
valid_red_priority smallint default 0,
valid_red_dscp smallint default 0,
valid_red_drop smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist smallint default 3,
- cs_rate smallint default 3,
- cs_cir smallint default 3,
- cs_cbs smallint default 3,
- cs_pir smallint default 3,
- cs_pbs smallint default 3,
- cs_green_action smallint default 3,
- cs_green_priority smallint default 3,
- cs_green_dscp smallint default 3,
- cs_green_drop smallint default 3,
- cs_yellow_action smallint default 3,
- cs_yellow_priority smallint default 3,
- cs_yellow_dscp smallint default 3,
- cs_yellow_drop smallint default 3,
- cs_red_action smallint default 3,
- cs_red_priority smallint default 3,
- cs_red_dscp smallint default 3,
- cs_red_drop smallint default 3,
- Primary Key(policingprofile_name, sequence_num));
+ cs_rowstatus smallint default 1,
+ cs_flowlist smallint default 1,
+ cs_rate smallint default 1,
+ cs_cir smallint default 1,
+ cs_cbs smallint default 1,
+ cs_pir smallint default 1,
+ cs_pbs smallint default 1,
+ cs_green_action smallint default 1,
+ cs_green_priority smallint default 1,
+ cs_green_dscp smallint default 1,
+ cs_green_drop smallint default 1,
+ cs_yellow_action smallint default 1,
+ cs_yellow_priority smallint default 1,
+ cs_yellow_dscp smallint default 1,
+ cs_yellow_drop smallint default 1,
+ cs_red_action smallint default 1,
+ cs_red_priority smallint default 1,
+ cs_red_dscp smallint default 1,
+ cs_red_drop smallint default 1,
+ PRIMARY KEY(policingprofile_name, sequence_num));
CREATE TABLE au_policingprofile_entry_ctrlr_tbl (
policingprofile_name varchar(33) default ' ',
valid_red_priority smallint default 0,
valid_red_dscp smallint default 0,
valid_red_drop smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist smallint default 3,
- cs_rate smallint default 3,
- cs_cir smallint default 3,
- cs_cbs smallint default 3,
- cs_pir smallint default 3,
- cs_pbs smallint default 3,
- cs_green_action smallint default 3,
- cs_green_priority smallint default 3,
- cs_green_dscp smallint default 3,
- cs_green_drop smallint default 3,
- cs_yellow_action smallint default 3,
- cs_yellow_priority smallint default 3,
- cs_yellow_dscp smallint default 3,
- cs_yellow_drop smallint default 3,
- cs_red_action smallint default 3,
- cs_red_priority smallint default 3,
- cs_red_dscp smallint default 3,
- cs_red_drop smallint default 3,
- Primary Key(policingprofile_name, sequence_num, ctrlr_name));
+ cs_rowstatus smallint default 1,
+ cs_flowlist smallint default 1,
+ cs_rate smallint default 1,
+ cs_cir smallint default 1,
+ cs_cbs smallint default 1,
+ cs_pir smallint default 1,
+ cs_pbs smallint default 1,
+ cs_green_action smallint default 1,
+ cs_green_priority smallint default 1,
+ cs_green_dscp smallint default 1,
+ cs_green_drop smallint default 1,
+ cs_yellow_action smallint default 1,
+ cs_yellow_priority smallint default 1,
+ cs_yellow_dscp smallint default 1,
+ cs_yellow_drop smallint default 1,
+ cs_red_action smallint default 1,
+ cs_red_priority smallint default 1,
+ cs_red_dscp smallint default 1,
+ cs_red_drop smallint default 1,
+ PRIMARY KEY(policingprofile_name, sequence_num, ctrlr_name));
CREATE TABLE au_vtn_flowfilter_tbl (
vtn_name varchar(32) default ' ',
direction smallint default 0,
flags smallint default 0,
- cs_rowstatus smallint default 3,
- Primary Key(vtn_name, direction));
+ cs_rowstatus smallint default 1,
+ PRIMARY KEY(vtn_name, direction));
CREATE TABLE au_vtn_flowfilter_ctrlr_tbl (
vtn_name varchar(32) default ' ',
ctrlr_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
- Primary Key(vtn_name, direction, ctrlr_name, domain_id));
+ cs_rowstatus smallint default 1,
+ PRIMARY KEY(vtn_name, direction, ctrlr_name, domain_id));
CREATE TABLE au_vtn_flowfilter_entry_tbl (
vtn_name varchar(32) default ' ',
valid_nwn_name smallint default 0,
valid_dscp smallint default 0,
valid_priority smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist_name smallint default 3,
- cs_action smallint default 3,
- cs_nwn_name smallint default 3,
- cs_dscp smallint default 3,
- cs_priority smallint default 3,
- Primary Key(vtn_name, direction, sequence_num));
+ cs_rowstatus smallint default 1,
+ cs_flowlist_name smallint default 1,
+ cs_action smallint default 1,
+ cs_nwn_name smallint default 1,
+ cs_dscp smallint default 1,
+ cs_priority smallint default 1,
+ PRIMARY KEY(vtn_name, direction, sequence_num));
CREATE TABLE au_vtn_flowfilter_entry_ctrlr_tbl (
vtn_name varchar(32) default ' ',
valid_nwn_name smallint default 0,
valid_dscp smallint default 0,
valid_priority smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist_name smallint default 3,
- cs_action smallint default 3,
- cs_nwn_name smallint default 3,
- cs_dscp smallint default 3,
- cs_priority smallint default 3,
- Primary Key(vtn_name, direction, sequence_num, ctrlr_name, domain_id));
+ cs_rowstatus smallint default 1,
+ cs_flowlist_name smallint default 1,
+ cs_action smallint default 1,
+ cs_nwn_name smallint default 1,
+ cs_dscp smallint default 1,
+ cs_priority smallint default 1,
+ PRIMARY KEY(vtn_name, direction, sequence_num, ctrlr_name, domain_id));
CREATE TABLE au_vbr_flowfilter_tbl (
vtn_name varchar(32) default ' ',
ctrlr_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vbr_name, direction));
+ cs_rowstatus smallint default 1,
+ PRIMARY KEY(vtn_name, vbr_name, direction));
CREATE TABLE au_vbr_flowfilter_entry_tbl (
vtn_name varchar(32) default ' ',
valid_nwn_name smallint default 0,
valid_dscp smallint default 0,
valid_priority smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist_name smallint default 3,
- cs_action smallint default 3,
- cs_redirect_node smallint default 3,
- cs_redirect_port smallint default 3,
- cs_modify_dst_mac smallint default 3,
- cs_modify_src_mac smallint default 3,
- cs_nwm_name smallint default 3,
- cs_dscp smallint default 3,
- cs_priority smallint default 3,
- Primary Key(vtn_name, vbr_name, direction, sequence_num));
+ cs_rowstatus smallint default 1,
+ cs_flowlist_name smallint default 1,
+ cs_action smallint default 1,
+ cs_redirect_node smallint default 1,
+ cs_redirect_port smallint default 1,
+ cs_modify_dst_mac smallint default 1,
+ cs_modify_src_mac smallint default 1,
+ cs_nwm_name smallint default 1,
+ cs_dscp smallint default 1,
+ cs_priority smallint default 1,
+ PRIMARY KEY(vtn_name, vbr_name, direction, sequence_num));
CREATE TABLE au_vbr_if_flowfilter_tbl (
vtn_name varchar(32) default ' ',
ctrlr_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vbr_name, vbr_if_name, direction));
+ cs_rowstatus smallint default 1,
+ PRIMARY KEY(vtn_name, vbr_name, vbr_if_name, direction));
CREATE TABLE au_vbr_if_flowfilter_entry_tbl (
vtn_name varchar(32) default ' ',
valid_nwn_name smallint default 0,
valid_dscp smallint default 0,
valid_priority smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist_name smallint default 3,
- cs_action smallint default 3,
- cs_redirect_node smallint default 3,
- cs_redirect_port smallint default 3,
- cs_modify_dst_mac smallint default 3,
- cs_modify_src_mac smallint default 3,
- cs_nwm_name smallint default 3,
- cs_dscp smallint default 3,
- cs_priority smallint default 3,
- Primary Key(vtn_name, vbr_name, vbr_if_name, direction, sequence_num));
+ cs_rowstatus smallint default 1,
+ cs_flowlist_name smallint default 1,
+ cs_action smallint default 1,
+ cs_redirect_node smallint default 1,
+ cs_redirect_port smallint default 1,
+ cs_modify_dst_mac smallint default 1,
+ cs_modify_src_mac smallint default 1,
+ cs_nwm_name smallint default 1,
+ cs_dscp smallint default 1,
+ cs_priority smallint default 1,
+ PRIMARY KEY(vtn_name, vbr_name, vbr_if_name, direction, sequence_num));
CREATE TABLE au_vrt_if_flowfilter_tbl (
vtn_name varchar(32) default ' ',
ctrlr_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
- Primary Key(vtn_name, vrt_name, vrt_if_name, direction));
+ cs_rowstatus smallint default 1,
+ PRIMARY KEY(vtn_name, vrt_name, vrt_if_name, direction));
CREATE TABLE au_vrt_if_flowfilter_entry_tbl (
vtn_name varchar(32) default ' ',
valid_nwn_name smallint default 0,
valid_dscp smallint default 0,
valid_priority smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist_name smallint default 3,
- cs_action smallint default 3,
- cs_redirect_node smallint default 3,
- cs_redirect_port smallint default 3,
- cs_modify_dst_mac smallint default 3,
- cs_modify_src_mac smallint default 3,
- cs_nwm_name smallint default 3,
- cs_dscp smallint default 3,
- cs_priority smallint default 3,
- Primary Key(vtn_name, vrt_name, vrt_if_name, direction, sequence_num));
+ cs_rowstatus smallint default 1,
+ cs_flowlist_name smallint default 1,
+ cs_action smallint default 1,
+ cs_redirect_node smallint default 1,
+ cs_redirect_port smallint default 1,
+ cs_modify_dst_mac smallint default 1,
+ cs_modify_src_mac smallint default 1,
+ cs_nwm_name smallint default 1,
+ cs_dscp smallint default 1,
+ cs_priority smallint default 1,
+ PRIMARY KEY(vtn_name, vrt_name, vrt_if_name, direction, sequence_num));
CREATE TABLE au_vtn_policingmap_tbl (
vtn_name varchar(32) default ' ',
policername varchar(33) default ' ',
flags smallint default 0,
valid_policername smallint default 0,
- cs_rowstatus smallint default 3,
- cs_policername smallint default 3,
- Primary Key(vtn_name));
+ cs_rowstatus smallint default 1,
+ cs_policername smallint default 1,
+ PRIMARY KEY(vtn_name));
CREATE TABLE au_vtn_policingmap_ctrlr_tbl (
vtn_name varchar(32) default ' ',
policername varchar(33) default ' ',
flags smallint default 0,
valid_policername smallint default 0,
- cs_rowstatus smallint default 3,
- cs_policername smallint default 3,
- Primary Key(vtn_name, ctrlr_name, domain_id));
+ cs_rowstatus smallint default 1,
+ cs_policername smallint default 1,
+ PRIMARY KEY(vtn_name, ctrlr_name, domain_id));
CREATE TABLE au_vbr_policingmap_tbl (
vtn_name varchar(32) default ' ',
policername varchar(33) default ' ',
flags smallint default 0,
valid_policername smallint default 0,
- cs_rowstatus smallint default 3,
- cs_policername smallint default 3,
- Primary Key(vtn_name, vbr_name));
+ cs_rowstatus smallint default 1,
+ cs_policername smallint default 1,
+ PRIMARY KEY(vtn_name, vbr_name));
CREATE TABLE au_vbr_if_policingmap_tbl (
vtn_name varchar(32) default ' ',
policername varchar(33) default ' ',
flags smallint default 0,
valid_policername smallint default 0,
- cs_rowstatus smallint default 3,
- cs_policername smallint default 3,
- Primary Key(vtn_name, vbr_name, vbr_if_name));
+ cs_rowstatus smallint default 1,
+ cs_policername smallint default 1,
+ PRIMARY KEY(vtn_name, vbr_name, vbr_if_name));
DROP TABLE au_vtn_policingmap_tbl;
DROP TABLE au_vtn_policingmap_ctrlr_tbl;
DROP TABLE au_vbr_policingmap_tbl;
-DROP TABLE au_vbr_if_policingmap_tbl;
+DROP TABLE au_vbr_if_policingmap_tbl;
\ No newline at end of file
PFC_LIBS += \
- libtc_common
+ libtc_common
USE_ODBC = 1
/*class to handle all database related operations*/
class TcDbHandler {
public:
- TcDbHandler(std::string dsn_name, std::string driver_name);
+ TcDbHandler(std::string dsn_name);
TcDbHandler(const TcDbHandler&);
~TcDbHandler() {
CloseDBConnection();
SQLHANDLE handle);
std::string dsn_name_; /*DB DSN name*/
- std::string drv_name_; /*DB driver name*/
SQLHENV db_env_; /*Environment handle for application*/
SQLHDBC db_conn_handle_; /*Connection handle */
};
TcOperStatus TcCreateMsgList();
TcOperStatus FillTcMsgData(TcMsg*, TcMsgOperType);
TcOperStatus SendAdditionalResponse(TcOperStatus);
- TcOperStatus HandleLockRet(TcLockRet LockRet);
+ TcOperStatus HandleLockRet(TcLockRet LockRet);
TcOperStatus GetSessionId();
- TcOperStatus SetControllerId();
+ TcOperStatus SetAuditOperationStatus();
TcOperStatus Execute();
+ TcOperStatus SendAuditStatusNotification(int32_t alarm_id);
pfc_bool_t AuditTransStart();
pfc_bool_t AuditTransEnd();
pfc_bool_t AuditVote();
*/
class TcTaskqUtil {
public:
- explicit TcTaskqUtil(uint32_t concurrency);
+ explicit TcTaskqUtil(uint32_t concurrency, int32_t alarm_id);
~TcTaskqUtil();
pfc::core::TaskQueue* taskq_;
pfc::core::Timer* timed_;
+ int32_t auditq_alarm_;
int PostReadTimer(uint32_t session_id,
uint32_t timeout,
TcLock* tclock,
TcLock* tclock_;
TcChannelNameMap& unc_channel_map_;
unc_keytype_ctrtype_t driver_id_;
+ int32_t alarm_id_;
AuditParams(std::string controller_id,
TcDbHandler* db_handler,
TcLock* tclock,
TcChannelNameMap& unc_map,
- unc_keytype_ctrtype_t driver_id);
+ unc_keytype_ctrtype_t driver_id,
+ int32_t alarm_id);
void operator() () {
HandleDriverAudit();
}
tclib::TcTransEndResult GetTransResult();
TcOperRet SetTransResult(tclib::TcTransEndResult result);
/*method to send response to VTN*/
+ TcOperRet ForwardResponseInternal(pfc::core::ipc::ServerSession& srv_sess,
+ pfc::core::ipc::ClientSession* clnt_sess,
+ pfc_bool_t decr_resp);
TcOperRet ForwardResponseToVTN(pfc::core::ipc::ServerSession&
srv_sess);
%% Configuration file format for tc.conf.
%%
defblock tc_db_params{
- tc_db_driver = STRING: max=63;
tc_db_dsn_name = STRING: max=63;
}
##
tc_db_params {
- tc_db_driver = "UNC_DB_DRIVER";
tc_db_dsn_name = "UNC_DB_DSN";
}
# lnctest module uses APIs provided by launcher module.
launcher
clstat
+alarm
#include <tc_operations.hh>
-
+#include <alarm.hh>
+#include <unc/component.h>
namespace unc {
namespace tc {
(tc_oper_ != TC_OP_DRIVER_AUDIT)) {
return TC_INVALID_OPERATION_TYPE;
}
+ /*set IPC timeout to infinity for audit operations*/
+ if (tc_oper_ == TC_OP_USER_AUDIT) {
+ TcUtilRet ret = TcServerSessionUtils::set_srv_timeout(ssess_, NULL);
+ if (ret == TCUTIL_RET_FAILURE) {
+ return TC_OPER_FAILURE;
+ }
+ }
return TC_OPER_SUCCESS;
}
TcOperRet oper_ret(tc_drv_msg->Execute());
if ( oper_ret != TCOPER_RET_SUCCESS ) {
user_response_ = HandleMsgRet(oper_ret);
+ delete tc_drv_msg;
+ tc_drv_msg = NULL;
return PFC_FALSE;
}
driver_id_ = tc_drv_msg->GetResult();
if ( driver_id_ == UNC_CT_UNKNOWN ) {
pfc_log_error("Controller of Unknown type");
+ delete tc_drv_msg;
+ tc_drv_msg = NULL;
return PFC_FALSE;
}
delete tc_drv_msg;
if ( AuditEnd() == PFC_FALSE ) {
return user_response_;
}
+ if ( db_hdlr_->UpdateRecoveryTable(UNC_DT_INVALID,
+ TC_OP_INVALID)!= TCOPER_RET_SUCCESS) {
+ pfc_log_info("Recovery Table not updated");
+ user_response_ = TC_OPER_FAILURE;
+ return TC_OPER_FAILURE;
+ }
+ return TC_OPER_SUCCESS;
+}
+
+/*set Audit operation status*/
+TcOperStatus
+TcAuditOperations::SetAuditOperationStatus() {
+ pfc_log_info("Audit status:%d", audit_result_);
+
+ TcUtilRet ret =
+ TcServerSessionUtils::set_uint32(ssess_,
+ audit_result_);
+ if ( ret != TCUTIL_RET_SUCCESS ) {
+ return TC_OPER_FAILURE;
+ }
return TC_OPER_SUCCESS;
}
if ( api_audit_ == PFC_TRUE ) {
return oper_stat;
}
+ /*Append the status of Audit operation*/
+ if (SetAuditOperationStatus() != TC_OPER_SUCCESS) {
+ return TC_OPER_FAILURE;
+ }
if (tc_oper_ == TC_OP_USER_AUDIT &&
resp_tc_msg_ != NULL) {
TcOperRet ret = resp_tc_msg_->ForwardResponseToVTN(*ssess_);
return TC_SYSTEM_FAILURE;
}
}
- if ( oper_stat == TC_OPER_SUCCESS ) {
- if ( db_hdlr_->UpdateRecoveryTable(UNC_DT_INVALID,
- TC_OP_INVALID)!= TCOPER_RET_SUCCESS) {
- pfc_log_info("Recovery Table not updated");
- }
- }
return oper_stat;
}
+/*
+ * * @brief Send Alarm notification for driver audit failure
+ * */
+TcOperStatus
+TcAuditOperations::SendAuditStatusNotification(int32_t alarm_id) {
+ std::string alm_msg;
+ std::string alm_msg_summary;
+ std::string vtn_name = "";
+ pfc::alarm::alarm_info_with_key_t* data =
+ new pfc::alarm::alarm_info_with_key_t;
+
+ if (audit_result_ == unc::tclib::TC_AUDIT_SUCCESS) {
+ alm_msg = "Controller audit success.Controller Id - " +\
+ controller_id_;
+ alm_msg_summary = "Controller audit success";
+ data->alarm_class = pfc::alarm::ALM_NOTICE;
+ data->alarm_kind = 0;
+ } else {
+ alm_msg = "Controller audit failure.Controller Id - " +\
+ controller_id_;
+ alm_msg_summary = "Controller audit failure";
+ data->alarm_class = pfc::alarm::ALM_WARNING;
+ data->alarm_kind = 1;
+ }
+ data->apl_No = UNCCID_TC;
+ data->alarm_category = 2;
+ data->alarm_key_size = controller_id_.length();
+ data->alarm_key = new uint8_t[controller_id_.length()+1];
+ memcpy(data->alarm_key,
+ controller_id_.c_str(),
+ controller_id_.length()+1);
+ pfc::alarm::alarm_return_code_t ret = pfc::alarm::pfc_alarm_send_with_key(
+ vtn_name,
+ alm_msg,
+ alm_msg_summary,
+ data, alarm_id);
+ if (ret != pfc::alarm::ALM_OK) {
+ delete []data->alarm_key;
+ delete data;
+ return TC_OPER_FAILURE;
+ }
+ delete []data->alarm_key;
+ delete data;
+ return TC_OPER_SUCCESS;
+}
+
} // namespace tc
} // namespace unc
(tc_oper_ != TC_OP_CANDIDATE_COMMIT)) {
return TC_INVALID_OPERATION_TYPE;
}
+
+ /*set IPC timeout to infinity for candidate operations*/
+ TcUtilRet ret = TcServerSessionUtils::set_srv_timeout(ssess_, NULL);
+ if (ret == TCUTIL_RET_FAILURE) {
+ return TC_OPER_FAILURE;
+ }
return TC_OPER_SUCCESS;
}
return TC_SYSTEM_FAILURE;
}
if (FillTcMsgData(tcmsg_, *MsgIter) != TC_OPER_SUCCESS) {
+ delete tcmsg_;
+ tcmsg_ = NULL;
return TC_SYSTEM_FAILURE;
}
TcOperRet MsgRet = tcmsg_->Execute();
user_response_ = HandleMsgRet(MsgRet);
}
MsgIter++;
+ delete tcmsg_;
+ tcmsg_ = NULL;
}
return user_response_;
TcMsg* tc_start_msg= TcMsg::CreateInstance(session_id_,
unc::tclib::MSG_COMMIT_TRANS_START,
unc_oper_channel_map_);
- PFC_ASSERT(tc_start_msg != NULL);
+ PFC_VERIFY(tc_start_msg != NULL);
FillTcMsgData(tc_start_msg, unc::tclib::MSG_COMMIT_TRANS_START);
TcOperRet oper_ret(tc_start_msg->Execute());
if ( oper_ret != TCOPER_RET_SUCCESS ) {
unc::tclib::MSG_COMMIT_VOTE,
unc_oper_channel_map_);
- PFC_ASSERT(tc_vote_msg != NULL);
+ PFC_VERIFY(tc_vote_msg != NULL);
FillTcMsgData(tc_vote_msg, unc::tclib::MSG_COMMIT_VOTE);
TcOperRet oper_ret(tc_vote_msg->Execute());
if ( oper_ret != TCOPER_RET_SUCCESS ) {
unc::tclib::MSG_COMMIT_GLOBAL,
unc_oper_channel_map_);
- PFC_ASSERT(tc_commit_msg != NULL);
+ PFC_VERIFY(tc_commit_msg != NULL);
FillTcMsgData(tc_commit_msg, unc::tclib::MSG_COMMIT_GLOBAL);
TcOperRet oper_ret(tc_commit_msg->Execute());
trans_result_ = tc_commit_msg->GetTransResult();
unc::tclib::MSG_COMMIT_TRANS_END,
unc_oper_channel_map_);
- PFC_ASSERT(tc_end_msg != NULL);
+ PFC_VERIFY(tc_end_msg != NULL);
FillTcMsgData(tc_end_msg, unc::tclib::MSG_COMMIT_TRANS_END);
TcOperRet oper_ret(tc_end_msg->Execute());
if ( oper_ret != TCOPER_RET_SUCCESS ) {
}
delete tc_end_msg;
- if ( autosave_enabled_ == PFC_TRUE ) {
+ if ( autosave_enabled_ == PFC_TRUE &&
+ user_response_ == TC_OPER_SUCCESS ) {
TcMsg* tc_save_msg = TcMsg::CreateInstance(session_id_,
unc::tclib::MSG_SAVE_CONFIG,
unc_oper_channel_map_);
/*
* @brief : Constructor
*/
-TcDbHandler::TcDbHandler(std::string dsn_name, std::string driver_name)
+TcDbHandler::TcDbHandler(std::string dsn_name)
:dsn_name_(dsn_name),
- drv_name_(driver_name),
db_env_(NULL),
db_conn_handle_(NULL) {
- PFC_ASSERT(TCOPER_RET_SUCCESS == OpenDBConnection());
+ if (TCOPER_RET_SUCCESS != OpenDBConnection()) {
+ pfc_log_fatal("Creating Database Handler Failed!!");
+ }
}
*/
TcDbHandler::TcDbHandler(const TcDbHandler& db_hdlr)
: dsn_name_(db_hdlr.dsn_name_),
- drv_name_(db_hdlr.drv_name_) {
- PFC_ASSERT(TCOPER_RET_SUCCESS == OpenDBConnection());
+ db_env_(NULL), db_conn_handle_(NULL) {
+ if (TCOPER_RET_SUCCESS != OpenDBConnection()) {
+ pfc_log_fatal("Creating Database Handler Failed!!");
+ }
}
/*!\brief method to get the error reason */
/*sets the connection string for SQLDriverConnect API*/
std::string TcDbHandler::GetDBConnectString() {
std::string conn_str;
- /*append DB driver name*/
- conn_str.append("Driver=");
- conn_str.append(drv_name_);
/*append DSN name*/
- conn_str.append(";DSN=");
+ conn_str.append("DSN=");
conn_str.append(dsn_name_);
return conn_str;
return retval;
}
/* check if the inputs are valid */
- PFC_ASSERT(TCOPER_RET_SUCCESS ==
- TcMsg::ValidateAuditDBAttributes(data_base, operation));
+ if (TCOPER_RET_SUCCESS !=
+ TcMsg::ValidateAuditDBAttributes(data_base, operation)) {
+ pfc_log_error("Audit DB attributes mismatch");
+ return TCOPER_RET_FAILURE;
+ }
/* create query */
upd_query.append("UPDATE TC_RECOVERY_TABLE SET database=");
tc_oper_ != TC_OP_CLEAR_STARTUP) {
return TC_INVALID_OPERATION_TYPE;
}
+ /*set infinite timeout for startup operations*/
+ TcUtilRet ret = TcServerSessionUtils::set_srv_timeout(ssess_, NULL);
+ if (ret == TCUTIL_RET_FAILURE) {
+ return TC_OPER_FAILURE;
+ }
return TC_OPER_SUCCESS;
}
tc_config_lock_.is_taken = PFC_FALSE;
/* Initialize read lock information */
std::set<uint32_t> &sessions(tc_read_lock_.read_sessions);
- PFC_ASSERT(tc_rwlock_.rw_owner == sessions.size() + 1);
+ PFC_VERIFY(tc_rwlock_.rw_owner == sessions.size() + 1);
sessions.clear();
tc_rwlock_.rw_owner = 1;
/* Initialize write lock information */
*@return TC_LOCK_INVALID_UNC_STATE The lock can not be held in this state.
*/
TcLockRet TcLock::TcAcquireReadLockForStateTransition() {
- PFC_ASSERT(tc_state_lock_.current_state != TC_STOP);
+ PFC_VERIFY(tc_state_lock_.current_state != TC_STOP);
while (!tc_rwlock_.canReadLock() ||
tc_state_lock_.state_transition_in_progress) {
#include <tc_module.hh>
+#include <alarm.hh>
+#include <unc/component.h>
+
+static int32_t alarm_id;
namespace unc {
namespace tc {
void TcModule::collect_db_params() {
pfc::core::ModuleConfBlock tc_db_block(tc_conf_block);
- dsn_name=
+ dsn_name =
tc_db_block.getString(tc_conf_db_dsn_name_param,
tc_def_db_dsn_name_value.c_str());
-
- drv_name=
- tc_db_block.getString(tc_conf_db_drv_name_param,
- tc_def_db_drv_name_value.c_str());
}
/**
* @brief Module Init
*/
pfc_bool_t TcModule::init() {
+ /*Initialize Audit failure alarm*/
+ pfc::alarm::alarm_return_code_t alarm_retval = pfc::alarm::ALM_OK;
+ alarm_retval = pfc::alarm::pfc_alarm_initialize(&alarm_id);
+ if (alarm_retval != pfc::alarm::ALM_OK) {
+ pfc_log_debug("Alarm intialization failed: %d", alarm_retval);
+ return PFC_FALSE;
+ } else {
+ pfc_log_info("Initialised audit alarm fd: %d", alarm_id);
+ }
+
// Assign Memory to task queues
- read_q_ = new TcTaskqUtil(TC_READ_CONCURRENCY);
+ read_q_ = new TcTaskqUtil(TC_READ_CONCURRENCY, 0);
if (PFC_EXPECT_FALSE(read_q_ == NULL)) {
pfc_log_error("ReadQ Creation Failed");
return PFC_FALSE;
}
- audit_q_ = new TcTaskqUtil(TC_AUDIT_CONCURRENCY);
+ audit_q_ = new TcTaskqUtil(TC_AUDIT_CONCURRENCY, alarm_id);
if (PFC_EXPECT_FALSE(audit_q_ == NULL)) {
pfc_log_error("AuditQ Creation Failed");
return PFC_FALSE;
}
// Read the configuration file
collect_db_params();
- TcDbHandler tc_db_hdlr_(dsn_name, drv_name);
+ TcDbHandler tc_db_hdlr_(dsn_name);
if (validate_tc_db(&tc_db_hdlr_) == PFC_FALSE) {
return PFC_FALSE;
}
return PFC_FALSE;
}
tc_lock_.ResetTcGlobalDataOnStateTransition();
+ /*clear alarms in transition*/
+ pfc::alarm::pfc_alarm_clear(UNCCID_TC);
- TcDbHandler* tc_db_hdlr_ = new TcDbHandler(dsn_name, drv_name);
- PFC_ASSERT(tc_db_hdlr_ != NULL);
+ TcDbHandler* tc_db_hdlr_ = new TcDbHandler(dsn_name);
+ if (tc_db_hdlr_ == NULL) {
+ return PFC_FALSE;
+ }
// create operations to send setup/setup_complete
TcStartUpOperations startup_(&tc_lock_, NULL, tc_db_hdlr_, tc_channels_,
is_switch);
*/
TcOperStatus TcModule::HandleStartUpRequests(pfc::core::ipc::ServerSession*
oper_sess) {
- TcDbHandler* tc_db_hdlr_ = new TcDbHandler(dsn_name, drv_name);
- PFC_ASSERT(tc_db_hdlr_ != NULL);
+ TcDbHandler* tc_db_hdlr_ = new TcDbHandler(dsn_name);
+ if (tc_db_hdlr_ == NULL) {
+ pfc_log_fatal("allocating DB handler failed");
+ return TC_OPER_FAILURE;
+ }
TcDbOperations tc_db_oper(&tc_lock_,
oper_sess,
tc_db_hdlr_,
*/
TcOperStatus TcModule::HandleAutoSaveRequests(pfc::core::ipc::ServerSession*
oper_sess) {
- TcDbHandler* tc_db_hdlr_ = new TcDbHandler(dsn_name, drv_name);
- PFC_ASSERT(tc_db_hdlr_ != NULL);
+ TcDbHandler* tc_db_hdlr_ = new TcDbHandler(dsn_name);
+ if (tc_db_hdlr_ == NULL) {
+ pfc_log_fatal("allocating DB handler failed");
+ return TC_OPER_FAILURE;
+ }
+
TcAutoSaveOperations tc_as_oper(&tc_lock_,
oper_sess,
tc_db_hdlr_,
*/
TcOperStatus TcModule::HandleCandidateRequests(pfc::core::ipc::ServerSession*
oper_sess) {
- TcDbHandler* tc_db_hdlr_ = new TcDbHandler(dsn_name, drv_name);
- PFC_ASSERT(tc_db_hdlr_ != NULL);
+ TcDbHandler* tc_db_hdlr_ = new TcDbHandler(dsn_name);
+ if (tc_db_hdlr_ == NULL) {
+ pfc_log_fatal("allocating DB handler failed");
+ return TC_OPER_FAILURE;
+ }
+
TcCandidateOperations tc_commit_oper(&tc_lock_,
oper_sess,
tc_db_hdlr_,
*/
TcOperStatus TcModule::HandleAuditRequests(pfc::core::ipc::ServerSession*
oper_sess) {
- TcDbHandler* tc_db_hdlr_ = new TcDbHandler(dsn_name, drv_name);
- PFC_ASSERT(tc_db_hdlr_ != NULL);
+ TcDbHandler* tc_db_hdlr_ = new TcDbHandler(dsn_name);
+ if (tc_db_hdlr_ == NULL) {
+ pfc_log_fatal("allocating DB handler failed");
+ return TC_OPER_FAILURE;
+ }
TcAuditOperations tc_audit_oper(&tc_lock_,
oper_sess,
tc_db_hdlr_,
pfc_bool_t TcModule::fini() {
pfc_log_info("TC fini");
UnRegisterStateHandlers();
+ pfc::alarm::pfc_alarm_close(alarm_id);
delete read_q_;
read_q_ = NULL;
delete audit_q_;
return TC_SYSTEM_FAILURE;
}
if (FillTcMsgData(tcmsg_, *MsgIter) != TC_OPER_SUCCESS) {
+ delete tcmsg_;
+ tcmsg_ = NULL;
return TC_SYSTEM_FAILURE;
}
TcOperRet MsgRet = tcmsg_->Execute();
- if ( MsgRet != TCOPER_RET_SUCCESS )
+ if ( MsgRet != TCOPER_RET_SUCCESS ) {
+ delete tcmsg_;
+ tcmsg_ = NULL;
return HandleMsgRet(MsgRet);
+ }
MsgIter++;
delete tcmsg_;
*@param[in] concurrency Number of simultanious tasks.
*/
-TcTaskqUtil::TcTaskqUtil(uint32_t concurrency) {
+TcTaskqUtil::TcTaskqUtil(uint32_t concurrency, int32_t audit_alarm) {
taskq_ = pfc::core::TaskQueue::create(concurrency);
timed_ = pfc::core::Timer::create(taskq_->getId());
+ auditq_alarm_ = audit_alarm;
}
/**
pfc_log_info("Read Timeout sess_id:%d", session_id_);
if ( tc_read_oper_.Dispatch() != TC_OPER_SUCCESS )
- pfc_log_error("from taskq failed sesion_id=%d",
- tc_read_oper_.session_id_);
+ pfc_log_info("taskq read release failed");
}
/*
TcDbHandler* db_handler,
TcLock* tclock,
TcChannelNameMap& unc_map,
- unc_keytype_ctrtype_t driver_id)
+ unc_keytype_ctrtype_t driver_id,
+ int32_t alarm_id)
: controller_id_(controller_id),
audit_db_hdlr_(db_handler),
tclock_(tclock),
unc_channel_map_(unc_map),
- driver_id_(driver_id) {}
+ driver_id_(driver_id),
+ alarm_id_(alarm_id) {}
/**
if (tc_audit_oper_.Dispatch() != TC_OPER_SUCCESS )
pfc_log_error("Driver Audit from taskq failed controller_id=%s",
tc_audit_oper_.controller_id_.c_str());
+
+ if (TC_OPER_SUCCESS !=
+ tc_audit_oper_.SendAuditStatusNotification(alarm_id_)) {
+ pfc_log_warn("could not notify audit status");
+ }
}
/**
tc_db_hdlr,
tclock,
unc_map,
- driver_id);
+ driver_id,
+ auditq_alarm_);
pfc::core::taskq_func_t task_func(func_obj);
ret = taskq_->dispatch(task_func);
if (ret != 0) {
if (sess_) {
delete sess_;
sess_ = NULL;
- PFC_ASSERT_INT(pfc_ipcclnt_altclose(conn_), 0);
+ if (TCOPER_RET_SUCCESS != pfc_ipcclnt_altclose(conn_)) {
+ pfc_log_fatal("pfc_ipcclnt_altclose of sess_ failed");
+ }
}
if (upll_sess_) {
delete upll_sess_;
upll_sess_ = NULL;
- PFC_ASSERT_INT(pfc_ipcclnt_altclose(upll_conn_), 0);
+ if (TCOPER_RET_SUCCESS != pfc_ipcclnt_altclose(upll_conn_)) {
+ pfc_log_fatal("pfc_ipcclnt_altclose of upll_sess_ failed");
+ }
}
if (uppl_sess_) {
delete uppl_sess_;
uppl_sess_ = NULL;
- PFC_ASSERT_INT(pfc_ipcclnt_altclose(uppl_conn_), 0);
+ if (TCOPER_RET_SUCCESS != pfc_ipcclnt_altclose(uppl_conn_)) {
+ pfc_log_fatal("pfc_ipcclnt_altclose of uppl_sess_ failed");
+ }
}
}
/*create client session*/
pfc::core::ipc::ClientSession* sess_ =
TcClientSessionUtils::create_tc_client_session(channel_name,
- tclib::TCLIB_CONTROLLER_TYPE, conn);
- PFC_ASSERT(NULL != sess_);
+ tclib::TCLIB_CONTROLLER_TYPE, conn, PFC_FALSE);
+ if (NULL == sess_) {
+ return TCOPER_RET_FATAL;
+ }
TcUtilRet ret = TcClientSessionUtils::tc_session_invoke(sess_, resp);
if (PFC_EXPECT_TRUE(ret == TCUTIL_RET_SUCCESS)) {
/*controller type is returned in resp*/
*ctrtype = (unc_keytype_ctrtype_t) resp;
} else {
- TcClientSessionUtils::tc_session_close(sess_, conn);
+ TcClientSessionUtils::tc_session_close(&sess_, conn);
return TCOPER_RET_FATAL;
}
pfc_log_info("GetControllerType() exit - controller_type::%d",
*ctrtype);
- sess_ = TcClientSessionUtils::tc_session_close(sess_, conn);
- PFC_ASSERT(NULL == sess_);
-
+ TcClientSessionUtils::tc_session_close(&sess_, conn);
return TCOPER_RET_SUCCESS;
}
return UNC_CT_UNKNOWN;
}
+/*!\brief This internal method forwards result from client session to server
+ * session
+ * @result - TcOperRet - TCOPER_RET_SUCCESS/TCOPER_RET_FAILURE
+ * */
+TcOperRet
+TcMsg::ForwardResponseInternal(pfc::core::ipc::ServerSession& srv_sess,
+ pfc::core::ipc::ClientSession* clnt_sess,
+ pfc_bool_t decr_resp) {
+
+ uint32_t respcount = clnt_sess->getResponseCount();
+ if (PFC_EXPECT_TRUE(respcount == 0)) {
+ pfc_log_info("session is empty");
+ return TCOPER_RET_SUCCESS;
+ }
+
+ uint32_t from_index = 0, to_index = 0;
+ if (decr_resp == PFC_TRUE) {
+ to_index = respcount - 1;
+ } else {
+ to_index = respcount;
+ }
+
+ if (clnt_sess->forwardTo(srv_sess, from_index, to_index)
+ != TCOPER_RET_SUCCESS) {
+ pfc_log_fatal("forwardTo failed!!");
+ return TCOPER_RET_FATAL;
+ }
+ pfc_log_info("data size forwarded to VTN: %d", to_index);
+ return TCOPER_RET_SUCCESS;
+}
+
/*!\brief method to forward the response from other modules to VTN.
*@param srv_sess - VTN session parameter.
- *@result TcOperRet - TCOPER_RET_SUCCESS/TCtclib::MSG_FATAL
+ *@result TcOperRet - TCOPER_RET_SUCCESS/TCOPER_RET_FATAL
**/
+
TcOperRet
-TcMsg::ForwardResponseToVTN(pfc::core::ipc::ServerSession& srv_sess_) {
+TcMsg::ForwardResponseToVTN(pfc::core::ipc::ServerSession& srv_sess) {
pfc_log_debug("TcMsg::ForwardResponseToVTN() entry");
- uint32_t respcount = 0;
-
+ TcOperRet ret = TCOPER_RET_SUCCESS;
+
if (sess_) {
- respcount = sess_->getResponseCount();
- if (PFC_EXPECT_TRUE(respcount > 0)) {
- pfc_log_info("forwarding client session data to VTN");
- PFC_ASSERT_INT(sess_->forwardTo(srv_sess_, 0, UINT32_MAX), 0);
+ pfc_log_info("forward client session data");
+ ret = ForwardResponseInternal(srv_sess, sess_, PFC_FALSE);
+ if (ret != TCOPER_RET_SUCCESS) {
+ pfc_log_info("forwarding session data to VTN failed");
+ return TCOPER_RET_FATAL;
}
}
if (upll_sess_) {
- respcount = upll_sess_->getResponseCount();
- if (PFC_EXPECT_TRUE(respcount > 0)) {
- if (PFC_EXPECT_TRUE(opertype_ == tclib::MSG_AUDIT_GLOBAL)) {
- /*filtering audit_result of global commit*/
- pfc_log_info("forwarding UPLL session data to VTN:%d", respcount-1);
- PFC_ASSERT_INT(upll_sess_->forwardTo(srv_sess_, 0, respcount-1), 0);
- } else {
- pfc_log_info("forwarding UPLL session data to VTN:%d", respcount);
- PFC_ASSERT_INT(upll_sess_->forwardTo(srv_sess_, 0, respcount), 0);
- }
+ pfc_log_info("forward UPLL session data");
+ if (PFC_EXPECT_TRUE(opertype_ == tclib::MSG_AUDIT_GLOBAL)) {
+ /*filtering audit_result of global commit*/
+ ret = ForwardResponseInternal(srv_sess, upll_sess_, PFC_TRUE);
+ } else {
+ ret = ForwardResponseInternal(srv_sess, upll_sess_, PFC_FALSE);
+ }
+ if (ret != TCOPER_RET_SUCCESS) {
+ pfc_log_info("forwarding UPLL session data to VTN failed");
+ return TCOPER_RET_FATAL;
}
}
if (uppl_sess_) {
- respcount = uppl_sess_->getResponseCount();
- if (PFC_EXPECT_TRUE(respcount > 0)) {
- if (PFC_EXPECT_TRUE(opertype_ == tclib::MSG_AUDIT_GLOBAL)) {
- /*filtering audit_result of global commit*/
- pfc_log_info("forwarding UPPL session data to VTN:%d", respcount-1);
- PFC_ASSERT_INT(uppl_sess_->forwardTo(srv_sess_, 0, respcount-1), 0);
- } else {
- pfc_log_info("forwarding UPPL session data to VTN:%d", respcount);
- PFC_ASSERT_INT(uppl_sess_->forwardTo(srv_sess_, 0, respcount), 0);
- }
+ pfc_log_info("forward UPPL session data");
+ if (PFC_EXPECT_TRUE(opertype_ == tclib::MSG_AUDIT_GLOBAL)) {
+ /*filtering audit_result of global commit*/
+ ret = ForwardResponseInternal(srv_sess, uppl_sess_, PFC_TRUE);
+ } else {
+ ret = ForwardResponseInternal(srv_sess, uppl_sess_, PFC_FALSE);
+ }
+ if (ret != TCOPER_RET_SUCCESS) {
+ pfc_log_info("forwarding UPPL session data to VTN failed");
+ return TCOPER_RET_FATAL;
}
}
pfc_log_debug("TcMsg::ForwardResponseToVTN() exit");
case TC_OP_CANDIDATE_COMMIT:
case TC_OP_USER_AUDIT:
case TC_OP_DRIVER_AUDIT: {
- PFC_ASSERT(data_base == UNC_DT_RUNNING);
+ PFC_VERIFY(data_base == UNC_DT_RUNNING);
break;
}
case TC_OP_CANDIDATE_ABORT: {
- PFC_ASSERT(data_base == UNC_DT_CANDIDATE);
+ PFC_VERIFY(data_base == UNC_DT_CANDIDATE);
break;
}
case TC_OP_RUNNING_SAVE:
case TC_OP_CLEAR_STARTUP: {
- PFC_ASSERT(data_base == UNC_DT_STARTUP);
+ PFC_VERIFY(data_base == UNC_DT_STARTUP);
break;
}
case TC_OP_INVALID: {
- PFC_ASSERT(data_base == UNC_DT_INVALID);
+ PFC_VERIFY(data_base == UNC_DT_INVALID);
break;
}
default: {
sess_ = TcClientSessionUtils::create_tc_client_session(channel_name,
service_id,
- conn_);
- PFC_ASSERT(NULL != sess_);
+ conn_, PFC_FALSE);
+ if (NULL == sess_) {
+ return TCOPER_RET_FATAL;
+ }
pfc_log_info("notify %s with srv_id %d",
channel_name.c_str(), service_id);
return ReturnUtilResp(util_resp);
}
- sess_ = TcClientSessionUtils::tc_session_close(sess_, conn_);
+ TcClientSessionUtils::tc_session_close(&sess_, conn_);
if (PFC_EXPECT_TRUE(resp == tclib::TC_FAILURE)) {
pfc_log_info("Failure response from %s", channel_name.c_str());
}
sess_ = TcClientSessionUtils::create_tc_client_session(channel_name,
- tclib::TCLIB_NOTIFY_SESSION_CONFIG, conn_);
- PFC_ASSERT(NULL != sess_);
+ tclib::TCLIB_NOTIFY_SESSION_CONFIG,
+ conn_, PFC_FALSE);
+ if (NULL == sess_) {
+ return TCOPER_RET_FATAL;
+ }
util_resp = TcClientSessionUtils::set_uint32(sess_, session_id_);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
return ReturnUtilResp(util_resp);
}
- sess_ = TcClientSessionUtils::tc_session_close(sess_, conn_);
+ TcClientSessionUtils::tc_session_close(&sess_, conn_);
if (PFC_EXPECT_TRUE(resp == tclib::TC_FAILURE)) {
pfc_log_info("Failure response from %s", channel_name.c_str());
/*Create session for the given module name and service id*/
sess_ = TcClientSessionUtils::create_tc_client_session(channel_name,
- service_id,
- conn_);
- PFC_ASSERT(NULL != sess_);
+ service_id,
+ conn_);
+ if (NULL == sess_) {
+ return TCOPER_RET_FATAL;
+ }
/*append data to channel */
if (PFC_EXPECT_TRUE(session_id_ > 0)) {
util_resp = TcClientSessionUtils::set_uint32(sess_, session_id_);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
return ReturnUtilResp(util_resp);
}
- sess_ = TcClientSessionUtils::tc_session_close(sess_, conn_);
- PFC_ASSERT(NULL == sess_);
+ TcClientSessionUtils::tc_session_close(&sess_, conn_);
if (PFC_EXPECT_TRUE(resp == tclib::TC_FAILURE)) {
pfc_log_info("Failure response from %s", channel_name.c_str());
/*channel_names_ map should not be empty */
PFC_ASSERT(TCOPER_RET_SUCCESS == channel_names_.empty());
- PFC_ASSERT(TCOPER_RET_SUCCESS == TcMsg::ValidateAuditDBAttributes(target_db_,
- fail_oper_));
+ if (TCOPER_RET_SUCCESS != TcMsg::ValidateAuditDBAttributes(target_db_,
+ fail_oper_)) {
+ pfc_log_error("Invalid AuditDB Attributes");
+ return TCOPER_RET_FAILURE;
+ }
notifyorder_.push_back(TC_UPLL);
notifyorder_.push_back(TC_UPPL);
pfc_log_info("sending AUDIT-DB notification");
/*Create session for the given module name and service id*/
sess_ = TcClientSessionUtils::create_tc_client_session(channel_name,
- tclib::TCLIB_AUDIT_CONFIG, conn_);
- PFC_ASSERT(NULL != sess_);
+ tclib::TCLIB_AUDIT_CONFIG, conn_, PFC_FALSE);
+ if (NULL == sess_) {
+ return TCOPER_RET_FATAL;
+ }
/*append data to channel */
util_resp = TcClientSessionUtils::set_uint8(sess_, target_db_);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
return ReturnUtilResp(util_resp);
}
- sess_ = TcClientSessionUtils::tc_session_close(sess_, conn_);
- PFC_ASSERT(NULL == sess_);
+ TcClientSessionUtils::tc_session_close(&sess_, conn_);
if (PFC_EXPECT_TRUE(resp == tclib::TC_FAILURE)) {
pfc_log_info("Failure response from %s", channel_name.c_str());
}
for (it = abort_on_fail_.begin(); it != abort_on_fail_.end(); it++) {
channel_name = GetChannelName(*it);
- if (PFC_EXPECT_TRUE(channel_name.empty())) {
- /*channel name of overlay driver may be empty - ignore*/
- continue;
- /* need to revisit once they are added.
- * pfc_log_error("channel name is empty");
- * return TCOPER_RET_FAILURE;*/
- }
+ PFC_ASSERT(TCOPER_RET_SUCCESS == channel_name.empty());
+
/*Create session for the given module name and service id*/
pfc::core::ipc::ClientSession* abortsess =
tc::TcClientSessionUtils::create_tc_client_session(channel_name,
tclib::TCLIB_AUDIT_GLOBAL_ABORT, conn);
- PFC_ASSERT(NULL != abortsess);
+ if (NULL == abortsess) {
+ return TCOPER_RET_FATAL;
+ }
/*append data to channel */
util_resp = tc::TcClientSessionUtils::set_uint8(abortsess,
tclib::MSG_AUDIT_ABORT);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(abortsess, conn);
+ TcClientSessionUtils::tc_session_close(&abortsess, conn);
return ReturnUtilResp(util_resp);
}
util_resp = tc::TcClientSessionUtils::set_uint32(abortsess, session_id_);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(abortsess, conn);
+ TcClientSessionUtils::tc_session_close(&abortsess, conn);
return ReturnUtilResp(util_resp);
}
PFC_EXPECT_TRUE(driver_id_ <= UNC_CT_VNP)) {
util_resp = tc::TcClientSessionUtils::set_uint8(abortsess, driver_id_);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(abortsess, conn);
+ TcClientSessionUtils::tc_session_close(&abortsess, conn);
return ReturnUtilResp(util_resp);
}
} else {
util_resp = tc::TcClientSessionUtils::set_string(abortsess,
controller_id_);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(abortsess, conn);
+ TcClientSessionUtils::tc_session_close(&abortsess, conn);
return ReturnUtilResp(util_resp);
}
}
util_resp = tc::TcClientSessionUtils::set_uint8(abortsess, fail_phase);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(abortsess, conn);
+ TcClientSessionUtils::tc_session_close(&abortsess, conn);
return ReturnUtilResp(util_resp);
}
pfc_log_info("notify ABORT to %s - fail_phase:%d", channel_name.c_str(),
/*invoke session*/
util_resp = tc::TcClientSessionUtils::tc_session_invoke(abortsess, resp);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(abortsess, conn);
+ TcClientSessionUtils::tc_session_close(&abortsess, conn);
return ReturnUtilResp(util_resp);
}
- abortsess = TcClientSessionUtils::tc_session_close(abortsess, conn);
- PFC_ASSERT(NULL == abortsess);
+ TcClientSessionUtils::tc_session_close(&abortsess, conn);
if (PFC_EXPECT_TRUE(resp == tclib::TC_FAILURE)) {
pfc_log_error("Failure response from %s", channel_name.c_str());
pfc::core::ipc::ClientSession* end_sess =
tc::TcClientSessionUtils::create_tc_client_session(channel_name,
tclib::TCLIB_AUDIT_TRANSACTION, conn);
- PFC_ASSERT(NULL != end_sess);
+ if (NULL == end_sess) {
+ return TCOPER_RET_FATAL;
+ }
/*append data to channel */
pfc_log_info("notify Audit/TxEnd to %s", channel_name.c_str());
util_resp = tc::TcClientSessionUtils::set_uint8(end_sess, oper);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(end_sess, conn);
+ TcClientSessionUtils::tc_session_close(&end_sess, conn);
return ReturnUtilResp(util_resp);
}
util_resp = tc::TcClientSessionUtils::set_uint32(end_sess, session_id_);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(end_sess, conn);
+ TcClientSessionUtils::tc_session_close(&end_sess, conn);
return ReturnUtilResp(util_resp);
}
if (PFC_EXPECT_TRUE(driver_id_ >= UNC_CT_PFC) &&
PFC_EXPECT_TRUE(driver_id_ <= UNC_CT_VNP)) {
util_resp = tc::TcClientSessionUtils::set_uint8(end_sess, driver_id_);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(end_sess, conn);
+ TcClientSessionUtils::tc_session_close(&end_sess, conn);
return ReturnUtilResp(util_resp);
}
} else {
util_resp = tc::TcClientSessionUtils::set_string(end_sess,
controller_id_);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(end_sess, conn);
+ TcClientSessionUtils::tc_session_close(&end_sess, conn);
return ReturnUtilResp(util_resp);
}
}
if (PFC_EXPECT_TRUE(oper == tclib::MSG_AUDIT_TRANS_END)) {
util_resp = tc::TcClientSessionUtils::set_uint8(end_sess, trans_result_);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(end_sess, conn);
+ TcClientSessionUtils::tc_session_close(&end_sess, conn);
return ReturnUtilResp(util_resp);
}
pfc_log_info("trans_result_:%d", trans_result_);
if (PFC_EXPECT_TRUE(oper == tclib::MSG_AUDIT_END)) {
util_resp = tc::TcClientSessionUtils::set_uint8(end_sess, audit_result_);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(end_sess, conn);
+ TcClientSessionUtils::tc_session_close(&end_sess, conn);
return ReturnUtilResp(util_resp);
}
pfc_log_info("audit_result_:%d", audit_result_);
/*invoke session*/
util_resp = tc::TcClientSessionUtils::tc_session_invoke(end_sess, resp);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(end_sess, conn);
+ TcClientSessionUtils::tc_session_close(&end_sess, conn);
return ReturnUtilResp(util_resp);
}
- end_sess = TcClientSessionUtils::tc_session_close(end_sess, conn);
- PFC_ASSERT(NULL == end_sess);
+ TcClientSessionUtils::tc_session_close(&end_sess, conn);
if (PFC_EXPECT_TRUE(resp == tclib::TC_FAILURE)) {
pfc_log_info("Failure response from %s", channel_name.c_str());
PFC_ASSERT(TCOPER_RET_SUCCESS == channel_name.empty());
sess_ = tc::TcClientSessionUtils::create_tc_client_session(channel_name,
- tclib::TCLIB_GET_DRIVERID, conn_);
- PFC_ASSERT(NULL != sess_);
+ tclib::TCLIB_GET_DRIVERID,
+ conn_, PFC_FALSE);
+ if (NULL == sess_) {
+ return TCOPER_RET_FATAL;
+ }
PFC_ASSERT(TCOPER_RET_SUCCESS == controller_id_.empty());
util_resp = tc::TcClientSessionUtils::set_string(sess_, controller_id_);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
/*Create session for the given module name and service id*/
sess_ = tc::TcClientSessionUtils::create_tc_client_session(channel_name,
tclib::TCLIB_AUDIT_TRANSACTION, conn_);
- PFC_ASSERT(NULL != sess_);
+ if (NULL == sess_) {
+ return TCOPER_RET_FATAL;
+ }
pfc_log_info("notify %s - session_id:%d cntrlr_id:%s",
channel_name.c_str(), session_id_, controller_id_.c_str());
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
return ReturnUtilResp(util_resp);
}
- pfc_log_info("trans_result_:%d", trans_result_);
}
if (opertype_ == tclib::MSG_AUDIT_END) {
util_resp = tc::TcClientSessionUtils::set_uint8(sess_, audit_result_);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
return ReturnUtilResp(util_resp);
}
- pfc_log_info("audit_result_:%d", audit_result_);
}
/*invoke session*/
util_resp = tc::TcClientSessionUtils::tc_session_invoke(sess_, resp);
/*session is not closed in case of failure as its contents
* are forwarded to VTN*/
if (PFC_EXPECT_TRUE(ret_val == TCOPER_RET_SUCCESS)) {
- sess_ = TcClientSessionUtils::tc_session_close(sess_, conn_);
+ TcClientSessionUtils::tc_session_close(&sess_, conn_);
}
pfc_log_debug("AuditTransaction::SendRequest() exit");
return ret_val;
list_iter != notifyorder_.end(); list_iter++) {
channel_name = GetChannelName(*list_iter);
if (channel_name.empty()) {
- /*channel name of overlay driver may be empty - ignore*/
+ /*channel names of drivers may be empty - ignore*/
continue;
- /* need to revisit once they are added.
- * pfc_log_error("channel name is empty");
- * return TCOPER_RET_FAILURE;*/
}
ret_val = SendRequest(channel_name);
upll_sess_ = TcClientSessionUtils::create_tc_client_session(channel_name,
tclib::TCLIB_AUDIT_DRV_RESULT,
upll_conn_);
- PFC_ASSERT(NULL != upll_sess_);
+ if (NULL == upll_sess_) {
+ return TCOPER_RET_FATAL;
+ }
ret_val = SetSessionToForwardDriverResult(upll_sess_);
if (PFC_EXPECT_TRUE(ret_val != TCOPER_RET_SUCCESS)) {
PFC_ASSERT(TCOPER_RET_SUCCESS == channel_name.empty());
uppl_sess_ = TcClientSessionUtils::create_tc_client_session(channel_name,
tclib::TCLIB_AUDIT_DRV_RESULT, uppl_conn_);
- PFC_ASSERT(NULL != uppl_sess_);
+ if (NULL == uppl_sess_) {
+ return TCOPER_RET_FATAL;
+ }
ret_val = SetSessionToForwardDriverResult(uppl_sess_);
if (PFC_EXPECT_TRUE(ret_val != TCOPER_RET_SUCCESS)) {
sess_ = tc::TcClientSessionUtils::create_tc_client_session(channel_name,
tclib::TCLIB_AUDIT_DRV_VOTE_GLOBAL,
conn_);
- PFC_ASSERT(NULL != sess_);
+ if (NULL == sess_) {
+ return TCOPER_RET_FATAL;
+ }
/*append data to channel */
util_resp = tc::TcClientSessionUtils::set_uint8(sess_, oper);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
return ReturnUtilResp(util_resp);
}
-#if 0
- util_resp = tc::TcClientSessionUtils::set_uint8(sess_, driver_id_);
- if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- return ReturnUtilResp(util_resp);
- }
-#endif
util_resp = tc::TcClientSessionUtils::set_string(sess_, controller_id_);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
return ReturnUtilResp(util_resp);
/*validate the driver_id saved from UPLL controllerinfo*/
if (PFC_EXPECT_TRUE(dmndrvinfo.find((*it).first) != dmndrvinfo.end())) {
pfc_log_debug("forward response to UPLL session");
- PFC_ASSERT_INT(upll_sess_->forward(*sess_, 0, UINT32_MAX), 0);
+ if (TCOPER_RET_SUCCESS != upll_sess_->forward(*sess_, 0, UINT32_MAX)) {
+ pfc_log_fatal("forward failed");
+ return TCOPER_RET_FATAL;
+ }
}
dmndrvinfo.clear();
/*validate the driver_id saved from UPPL controllerinfo*/
if (PFC_EXPECT_TRUE(dmndrvinfo.find((*it).first) != dmndrvinfo.end())) {
pfc_log_debug("forward response to UPPL session");
- PFC_ASSERT_INT(uppl_sess_->forward(*sess_, 0, UINT32_MAX), 0);
+ if (TCOPER_RET_SUCCESS != uppl_sess_->forward(*sess_, 0, UINT32_MAX)) {
+ pfc_log_fatal("forward failed");
+ return TCOPER_RET_FATAL;
+ }
}
/*append channelname to handle failure*/
abort_on_fail_.push_back(tc_driverid);
ret_val = TCOPER_RET_FATAL;
}
if (ret_val == TCOPER_RET_SUCCESS) {
- sess_ = TcClientSessionUtils::tc_session_close(sess_, conn_);
+ TcClientSessionUtils::tc_session_close(&sess_, conn_);
} else {
return ret_val;
}
/*Create session for the given module name and service id*/
sess_ = tc::TcClientSessionUtils::create_tc_client_session(channel_name,
tclib::TCLIB_AUDIT_TRANSACTION, conn_);
- PFC_ASSERT(NULL != sess_);
+ if (NULL == sess_) {
+ return TCOPER_RET_FATAL;
+ }
/*append data to channel */
util_resp = tc::TcClientSessionUtils::set_uint8(sess_, opertype_);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
PFC_EXPECT_TRUE(respcount > 1)) {
/*append the driver info from log/phy in TcControllerInfoMap
* * driverinfo_map_*/
- PFC_ASSERT(TCOPER_RET_SUCCESS == GetControllerInfo(sess_));
+ if (TCOPER_RET_SUCCESS != GetControllerInfo(sess_)) {
+ pfc_log_error("could not retrieve controller-info");
+ return TCOPER_RET_FAILURE;
+ }
ret_val = TCOPER_RET_SUCCESS;
} else if (PFC_EXPECT_TRUE(resp == tclib::TC_FAILURE) &&
PFC_EXPECT_TRUE(opertype_ == tclib::MSG_AUDIT_VOTE)) {
/*delete the session pointer*/
if (ret_val == TCOPER_RET_SUCCESS) {
pfc_log_info("success response from %s", channel_name.c_str());
- sess_ = TcClientSessionUtils::tc_session_close(sess_, conn_);
+ TcClientSessionUtils::tc_session_close(&sess_, conn_);
}
pfc_log_debug("TwoPhaseAudit::SendRequest() exit");
return ret_val;
for (it = abort_on_fail_.begin() ; it != abort_on_fail_.end(); it++) {
channel_name = GetChannelName(*it);
- if (PFC_EXPECT_TRUE(channel_name.empty())) {
- /*channel name of overlay drivers can be empty - ignore*/
- continue;
- /* need to revisit once they are added.
- * pfc_log_error("channel name is empty");
- * return TCOPER_RET_FAILURE;*/
- }
+ PFC_ASSERT(TCOPER_RET_SUCCESS == channel_name.empty());
+
pfc_log_info("send ABORT to %s - fail_phase:%d",
channel_name.c_str(), fail_phase);
/*Create session for the given module name and service id*/
pfc::core::ipc::ClientSession* abortsess =
TcClientSessionUtils::create_tc_client_session(channel_name,
tclib::TCLIB_COMMIT_GLOBAL_ABORT, conn);
- PFC_ASSERT(NULL != abortsess);
+ if (NULL == abortsess) {
+ return TCOPER_RET_FATAL;
+ }
/*append data to channel */
util_resp = TcClientSessionUtils::set_uint8(abortsess,
tclib::MSG_COMMIT_ABORT);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(abortsess, conn);
+ TcClientSessionUtils::tc_session_close(&abortsess, conn);
return ReturnUtilResp(util_resp);
}
/*validate session_id_ and config_id_*/
PFC_EXPECT_TRUE(config_id_ > 0)) {
util_resp = TcClientSessionUtils::set_uint32(abortsess, session_id_);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(abortsess, conn);
+ TcClientSessionUtils::tc_session_close(&abortsess, conn);
return ReturnUtilResp(util_resp);
}
util_resp = TcClientSessionUtils::set_uint32(abortsess, config_id_);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(abortsess, conn);
+ TcClientSessionUtils::tc_session_close(&abortsess, conn);
return ReturnUtilResp(util_resp);
}
} else {
util_resp = TcClientSessionUtils::set_uint8(abortsess, fail_phase);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(abortsess, conn);
+ TcClientSessionUtils::tc_session_close(&abortsess, conn);
return ReturnUtilResp(util_resp);
}
/*invoke session*/
util_resp = TcClientSessionUtils::tc_session_invoke(abortsess, resp);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(abortsess, conn);
+ TcClientSessionUtils::tc_session_close(&abortsess, conn);
return ReturnUtilResp(util_resp);
}
- abortsess = TcClientSessionUtils::tc_session_close(abortsess, conn);
- PFC_ASSERT(NULL == abortsess);
+ TcClientSessionUtils::tc_session_close(&abortsess, conn);
if (PFC_EXPECT_TRUE(tclib::TC_FAILURE == resp)) {
pfc_log_error("Failure response from %s", channel_name.c_str());
pfc::core::ipc::ClientSession* end_sess =
TcClientSessionUtils::create_tc_client_session(channel_name,
tclib::TCLIB_COMMIT_TRANSACTION, conn);
- PFC_ASSERT(NULL != end_sess);
+ if (NULL == end_sess) {
+ return TCOPER_RET_FATAL;
+ }
/*append data to channel */
util_resp = TcClientSessionUtils::set_uint8(end_sess,
tclib::MSG_COMMIT_TRANS_END);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(end_sess, conn);
+ TcClientSessionUtils::tc_session_close(&end_sess, conn);
return ReturnUtilResp(util_resp);
}
/*validate session_id_ and config_id_*/
if (PFC_EXPECT_TRUE(session_id_ > 0) && PFC_EXPECT_TRUE(config_id_ > 0)) {
util_resp = TcClientSessionUtils::set_uint32(end_sess, session_id_);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(end_sess, conn);
+ TcClientSessionUtils::tc_session_close(&end_sess, conn);
return ReturnUtilResp(util_resp);
}
util_resp = TcClientSessionUtils::set_uint32(end_sess, config_id_);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(end_sess, conn);
+ TcClientSessionUtils::tc_session_close(&end_sess, conn);
return ReturnUtilResp(util_resp);
}
} else {
util_resp = TcClientSessionUtils::set_uint8(end_sess,
tclib::TRANS_END_FAILURE);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(end_sess, conn);
+ TcClientSessionUtils::tc_session_close(&end_sess, conn);
return ReturnUtilResp(util_resp);
}
/*invoke session*/
util_resp = TcClientSessionUtils::tc_session_invoke(end_sess, resp);
if (PFC_EXPECT_TRUE(util_resp != TCUTIL_RET_SUCCESS)) {
- TcClientSessionUtils::tc_session_close(end_sess, conn);
+ TcClientSessionUtils::tc_session_close(&end_sess, conn);
return ReturnUtilResp(util_resp);
}
- end_sess = TcClientSessionUtils::tc_session_close(end_sess, conn);
- PFC_ASSERT(NULL == end_sess);
+ TcClientSessionUtils::tc_session_close(&end_sess, conn);
if (tclib::TC_FAILURE == resp) {
pfc_log_error("Failure response from %s", channel_name.c_str());
/*Create session for the given module name and service id*/
sess_ = TcClientSessionUtils::create_tc_client_session(channel_name,
tclib::TCLIB_USER_ABORT, conn_);
- PFC_ASSERT(NULL != sess_);
+ if (NULL == sess_) {
+ return TCOPER_RET_FATAL;
+ }
/*append data to channel - validate session_id_ and config_id_*/
if (PFC_EXPECT_TRUE(session_id_ > 0) &&
return ReturnUtilResp(util_resp);
}
- sess_ = TcClientSessionUtils::tc_session_close(sess_, conn_);
+ TcClientSessionUtils::tc_session_close(&sess_, conn_);
if (resp == tclib::TC_FAILURE) {
pfc_log_info("Failure response from %s", channel_name.c_str());
break;
+ } else {
+ pfc_log_info("Success response from %s", channel_name.c_str());
}
}
/*return server response*/
/*Create session for the given module name and service id*/
sess_ = TcClientSessionUtils::create_tc_client_session(channel_name,
tclib::TCLIB_COMMIT_TRANSACTION, conn_);
- PFC_ASSERT(NULL != sess_);
+ if (NULL == sess_) {
+ return TCOPER_RET_FATAL;
+ }
/*append data to channel */
util_resp = TcClientSessionUtils::set_uint8(sess_, opertype_);
/*session is not closed in case of failure as
* its contents are forwarded to VTN*/
if (PFC_EXPECT_TRUE(ret_val == TCOPER_RET_SUCCESS)) {
- sess_ = TcClientSessionUtils::tc_session_close(sess_, conn_);
+ TcClientSessionUtils::tc_session_close(&sess_, conn_);
}
pfc_log_debug("CommitTransaction::SendRequest() exit");
return ret_val;
list_iter != notifyorder_.end(); list_iter++) {
channel_name = GetChannelName(*list_iter);
if (PFC_EXPECT_TRUE(channel_name.empty())) {
- /*channel name of overlay driver may be empty - ignore*/
+ /*channel names of drivers may be empty - ignore*/
continue;
- /* need to revisit once they are added.
- pfc_log_error("channel name is empty");
- return TCOPER_RET_FAILURE;*/
}
+
ret_val = SendRequest(channel_name);
if (PFC_EXPECT_TRUE(ret_val != TCOPER_RET_SUCCESS)) {
return ret_val;
upll_sess_ = TcClientSessionUtils::create_tc_client_session(channel_name,
tclib::TCLIB_COMMIT_DRV_RESULT,
upll_conn_);
- PFC_ASSERT(NULL != upll_sess_);
+ if (NULL == upll_sess_) {
+ return TCOPER_RET_FATAL;
+ }
ret_val = SetSessionToForwardDriverResult(upll_sess_);
if (PFC_EXPECT_TRUE(ret_val != TCOPER_RET_SUCCESS)) {
uppl_sess_ = TcClientSessionUtils::create_tc_client_session(channel_name,
tclib::TCLIB_COMMIT_DRV_RESULT,
uppl_conn_);
- PFC_ASSERT(NULL != uppl_sess_);
+ if (NULL == uppl_sess_) {
+ return TCOPER_RET_FATAL;
+ }
ret_val = SetSessionToForwardDriverResult(uppl_sess_);
if (PFC_EXPECT_TRUE(ret_val != TCOPER_RET_SUCCESS)) {
/*Create session for the given module name and service id*/
sess_ = TcClientSessionUtils::create_tc_client_session(channel_name,
tclib::TCLIB_COMMIT_DRV_VOTE_GLOBAL, conn_);
- PFC_ASSERT(NULL != sess_);
+ if (NULL == sess_) {
+ return TCOPER_RET_FATAL;
+ }
/*append data to channel */
util_resp = TcClientSessionUtils::set_uint8(sess_, oper);
/*validate the driver_id saved from UPLL controllerinfo*/
if (PFC_EXPECT_TRUE(dmndrvinfo.find((*it).first) != dmndrvinfo.end())) {
pfc_log_debug("forward response to UPLL session");
- PFC_ASSERT_INT(upll_sess_->forward(*sess_, 0, UINT32_MAX), 0);
+ if (TCOPER_RET_SUCCESS != upll_sess_->forward(*sess_, 0, UINT32_MAX)) {
+ pfc_log_fatal("forward failed");
+ return TCOPER_RET_FATAL;
+ }
}
dmndrvinfo.clear();
dmndrvinfo = driverset_map_[TC_UPPL];
/*validate the driver_id saved from UPPL controllerinfo*/
if (PFC_EXPECT_TRUE(dmndrvinfo.find((*it).first) != dmndrvinfo.end())) {
pfc_log_debug("forward response to UPPL session");
- PFC_ASSERT_INT(uppl_sess_->forward(*sess_, 0, UINT32_MAX), 0);
+ if (TCOPER_RET_SUCCESS != upll_sess_->forward(*sess_, 0, UINT32_MAX)) {
+ pfc_log_fatal("forward failed");
+ return TCOPER_RET_FATAL;
+ }
}
/*append channelname to handle failure*/
abort_on_fail_.push_back(tc_driverid);
}
if (ret_val == TCOPER_RET_SUCCESS) {
- sess_ = TcClientSessionUtils::tc_session_close(sess_, conn_);
+ TcClientSessionUtils::tc_session_close(&sess_, conn_);
} else {
return ret_val;
}
/*Create session for the given module name and service id*/
sess_ = TcClientSessionUtils::create_tc_client_session(channel_name,
tclib::TCLIB_COMMIT_TRANSACTION, conn_);
- PFC_ASSERT(NULL != sess_);
+ if (NULL == sess_) {
+ return TCOPER_RET_FATAL;
+ }
/*append data to channel */
util_resp = TcClientSessionUtils::set_uint8(sess_, opertype_);
PFC_EXPECT_TRUE(respcount > 0)) {
/*append the driver info from log/phy in
* TcControllerInfoMap driverinfo_map_*/
- PFC_ASSERT(TCOPER_RET_SUCCESS == GetControllerInfo(sess_));
+ if (TCOPER_RET_SUCCESS != GetControllerInfo(sess_)) {
+ pfc_log_error("could not retrieve controller-info");
+ return TCOPER_RET_FAILURE;
+ }
ret_val = TCOPER_RET_SUCCESS;
} else if (PFC_EXPECT_TRUE(resp == tclib::TC_FAILURE) &&
PFC_EXPECT_TRUE(opertype_ == tclib::MSG_COMMIT_VOTE)) {
if (ret_val == TCOPER_RET_SUCCESS) {
pfc_log_info("Success response from %s", channel_name.c_str());
- sess_ = TcClientSessionUtils::tc_session_close(sess_, conn_);
+ TcClientSessionUtils::tc_session_close(&sess_, conn_);
}
pfc_log_debug("TwoPhaseCommit::SendRequest() exit");
return ret_val;
controller_key_map_.clear();
commit_phase_result_.clear();
- pfc_bool_t mtx_flag1 = PFC_TRUE;
- pfc_bool_t mtx_flag2 = PFC_TRUE;
-
- // unlock mutex if already locked
- if ((tclib_mutex_.trylock() == EBUSY)) {
- tclib_mutex_.unlock();
- mtx_flag1 = PFC_FALSE;
- pfc_log_info("%s %d tclib_mutex_ unlock", __FUNCTION__, __LINE__);
- }
-
- if (mtx_flag1 == PFC_TRUE) {
- tclib_mutex_.unlock();
- }
-
- if ((tclib_ipc_control_mutex_.trylock() == EBUSY)) {
- tclib_ipc_control_mutex_.unlock();
- mtx_flag2 = PFC_FALSE;
- pfc_log_info("%s %d tclib_ipc_control_mutex_ unlock",
- __FUNCTION__, __LINE__);
- }
-
- if (mtx_flag2 == PFC_TRUE) {
- tclib_ipc_control_mutex_.unlock();
- }
-
- pfc_log_info("%s %d tclib termination", __FUNCTION__, __LINE__);
+ pfc_log_info("%s %d tclib shutdown", __FUNCTION__, __LINE__);
return PFC_TRUE;
}
if (!controller_key_map_.empty()) {
it = controller_key_map_.find(controller_id);
+ if (it == controller_key_map_.end()) {
+ pfc_log_error("Missing contrl-id:%s", controller_id.c_str());
+ return TC_INVALID_PARAM;
+ }
key_type_map = it->second;
if (!key_type_map.empty()) {
key_it = key_type_map.find(err_pos);
TcCommonRet TcLibModule::UpdateControllerKeyList() {
TcCommonRet ret = TC_SUCCESS;
uint32_t argcount = 0, idx = 0;
- TcControllerResult ctrl_res;
TcCommitPhaseResult comm_phase_res;
tc::TcUtilRet util_ret = tc::TCUTIL_RET_SUCCESS;
return ret;
}
+
+ TcControllerResult ctrl_res;
util_ret = tc::TcServerSessionUtils::get_string(sess_, idx,
ctrl_res.controller_id);
if (util_ret != tc::TCUTIL_RET_SUCCESS) {
__FUNCTION__, __LINE__, ret);
return ret;
}
-
+
pfc_log_info("%s %d Handler returned with %d",
__FUNCTION__, __LINE__, ret);
return ret;
__FUNCTION__, __LINE__, ret);
return ret;
}
-
+
pfc_log_info("%s %d Handler returned with %d",
__FUNCTION__, __LINE__, ret);
return ret;
__FUNCTION__, __LINE__);
return PFC_IPCRESP_FATAL;
}
-
- /*
- * Try to acquire the mutex lock.
- *
- * Zero is returned on success.
- * EBUSY is returned, if the mutex was already locked.
- */
+ /*set IPC timeout to infinity for commit/audit operations*/
+ if (service >= TCLIB_COMMIT_TRANSACTION &&
+ service <= TCLIB_USER_ABORT) {
+ if (TC_SUCCESS != sess.setTimeout(NULL)) {
+ pfc_log_debug("setting IPC timeout to infinity failed");
+ }
+ }
sess_ = &sess;
switch (service) {
vbr_momgr.cc vbr_if_momgr.cc \
vrt_momgr.cc vrt_if_momgr.cc \
vlink_momgr.cc vlanmap_momgr.cc iproute_momgr.cc \
- dhcprelay_server_momgr.cc dhcprelay_if_momgr.cc \
+ dhcprelay_server_momgr.cc dhcprelay_if_momgr.cc \
nwm_momgr.cc nwm_host_momgr.cc \
- vunk_momgr.cc vunk_if_momgr.cc
+ vunk_momgr.cc vunk_if_momgr.cc \
+ vtep_momgr.cc vtep_if_momgr.cc \
+ vtep_grp_momgr.cc vtepgrp_mem_momgr.cc \
+ vtunnel_momgr.cc vtunnel_if_momgr.cc
POM_SOURCES = policingprofile_momgr.cc policingprofile_entry_momgr.cc \
flowlist_momgr.cc flowlist_entry_momgr.cc \
#include "unc/pfcdriver_include.h"
#include "ipct_st.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "upll_util.hh"
#include "kt_util.hh"
#include "vrt_if_flowfilter_momgr.hh"
#include "vunk_momgr.hh"
#include "vunk_if_momgr.hh"
+#include "vtep_momgr.hh"
+#include "vtep_if_momgr.hh"
+#include "vtep_grp_momgr.hh"
+#include "vtepgrp_mem_momgr.hh"
+#include "vtunnel_momgr.hh"
+#include "vtunnel_if_momgr.hh"
namespace unc {
namespace upll {
using unc::upll::upll_util::upll_strncpy;
+namespace uuk = unc::upll::kt_momgr;
namespace uudal = unc::upll::dal;
UpllConfigMgr *UpllConfigMgr::singleton_instance_;
UPLL_LOG_ERROR("Unable to get tclib module");
return false;
}
- unc::tclib::TcApiCommonRet tacr = tclib->TcLibRegisterHandler(
- new TcLibIntfImpl(this));
+ TcLibIntfImpl *tlii = new TcLibIntfImpl(this);
+ unc::tclib::TcApiCommonRet tacr = tclib->TcLibRegisterHandler(tlii);
if (tacr != unc::tclib::TC_API_COMMON_SUCCESS) {
UPLL_LOG_ERROR("Failed to register handler with tclib");
+ delete tlii;
return false;
}
}
// Open Dal Connection
- bool read_write_conn = false;
+ DalOdbcMgr *dom = NULL;
switch (msghdr->operation) {
case UNC_OP_CREATE:
case UNC_OP_UPDATE:
case UNC_OP_DELETE:
case UNC_OP_RENAME:
- read_write_conn = true;
+ dom = &config_rw_dom_;
+ break;
+ case UNC_OP_READ:
+ case UNC_OP_READ_NEXT:
+ case UNC_OP_READ_BULK:
+ case UNC_OP_READ_SIBLING_BEGIN:
+ case UNC_OP_READ_SIBLING:
+ case UNC_OP_READ_SIBLING_COUNT:
+ if (msghdr->datatype == UPLL_DT_CANDIDATE) {
+ dom = &config_ro_dom_;
+ }
break;
default:
// UNC_OP_CONTROL and other UNC_OP_READ* operations
- read_write_conn = false;
+ // For now use read only connection.
+ dom = NULL;
}
- DalOdbcMgr dom;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dom, read_write_conn, __FUNCTION__))) {
- msghdr->result_code = urc;
- if (ReleaseConfigLock(msghdr->operation, msghdr->datatype) == false) {
- UPLL_LOG_ERROR("Failed to release config lock.");
+ if (dom != NULL) {
+ // already selected the dom
+ } else {
+ if (UPLL_RC_SUCCESS != (urc = DalOpen(&dom, false, __FUNCTION__))) {
+ msghdr->result_code = urc;
+ if (ReleaseConfigLock(msghdr->operation, msghdr->datatype) == false) {
+ UPLL_LOG_ERROR("Failed to release config lock.");
+ }
+ return 0;
}
- return 0;
}
switch (msghdr->operation) {
case UNC_OP_READ:
- urc = momgr->ReadMo(msghdr, first_ckv, &dom);
+ urc = momgr->ReadMo(msghdr, first_ckv, dom);
break;
case UNC_OP_READ_NEXT:
- urc = ReadNextMo(msghdr, first_ckv, &dom);
+ urc = ReadNextMo(msghdr, first_ckv, dom);
break;
case UNC_OP_READ_BULK:
- urc = ReadBulkMo(msghdr, first_ckv, &dom);
+ urc = ReadBulkMo(msghdr, first_ckv, dom);
break;
case UNC_OP_READ_SIBLING_BEGIN:
- urc = momgr->ReadSiblingMo(msghdr, first_ckv, true, &dom);
+ urc = momgr->ReadSiblingMo(msghdr, first_ckv, true, dom);
break;
case UNC_OP_READ_SIBLING:
- urc = momgr->ReadSiblingMo(msghdr, first_ckv, false, &dom);
+ urc = momgr->ReadSiblingMo(msghdr, first_ckv, false, dom);
break;
case UNC_OP_READ_SIBLING_COUNT:
- urc = momgr->ReadSiblingCount(msghdr, first_ckv, &dom);
+ urc = momgr->ReadSiblingCount(msghdr, first_ckv, dom);
break;
case UNC_OP_CREATE:
- urc = momgr->CreateMo(msghdr, first_ckv, &dom);
+ urc = momgr->CreateMo(msghdr, first_ckv, dom);
break;
case UNC_OP_UPDATE:
- urc = momgr->UpdateMo(msghdr, first_ckv, &dom);
+ urc = momgr->UpdateMo(msghdr, first_ckv, dom);
break;
case UNC_OP_DELETE:
- urc = momgr->DeleteMo(msghdr, first_ckv, &dom);
+ urc = momgr->DeleteMo(msghdr, first_ckv, dom);
break;
case UNC_OP_RENAME:
if (import_ctrlr_id_.empty()) {
UPLL_LOG_DEBUG("Reanme operation is not allowed as "
"import operation not in progress");
} else {
- urc = momgr->RenameMo(msghdr, first_ckv, &dom,
+ urc = momgr->RenameMo(msghdr, first_ckv, dom,
import_ctrlr_id_.c_str());
}
break;
case UNC_OP_CONTROL:
- urc = momgr->ControlMo(msghdr, first_ckv, &dom);
+ urc = momgr->ControlMo(msghdr, first_ckv, dom);
break;
default:
UPLL_LOG_DEBUG("Unknown keytype operation: %d", msghdr->operation);
}
msghdr->result_code = urc;
- upll_rc_t db_urc = DalClose(&dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+ upll_rc_t db_urc = DalClose(dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
if (urc == UPLL_RC_SUCCESS) {
msghdr->result_code = urc = db_urc;
}
cktt_.AddKeyType(UNC_KT_ROOT, UNC_KT_VTN) &&
(
// skip UNC_KT_VTN_DATAFLOW_CONTROLLER
- cktt_.AddKeyType(UNC_KT_VTN, UNC_KT_VTN_FLOWFILTER) &&
- (
- cktt_.AddKeyType(UNC_KT_VTN_FLOWFILTER,
- UNC_KT_VTN_FLOWFILTER_ENTRY)
- ) &&
- // skip UNC_KT_VTN_FLOWFILTER_ENTRY
- // skip UNC_KT_VTN_FLOWFILTER_CONTROLLER
- // skip UNC_KT_VTN_PATHMAP_ENTRY
- // skip UNC_KT_VTN_PATHMAP_CONTROLLER
- cktt_.AddKeyType(UNC_KT_VTN, UNC_KT_VTN_POLICINGMAP) &&
- // skip UNC_KT_VTN_POLICINGMAP_CONTROLLER
cktt_.AddKeyType(UNC_KT_VTN, UNC_KT_VBRIDGE) &&
(
cktt_.AddKeyType(UNC_KT_VBRIDGE, UNC_KT_VBR_VLANMAP) &&
UNC_KT_VBR_FLOWFILTER_ENTRY) &&
cktt_.AddKeyType(UNC_KT_VBRIDGE, UNC_KT_VBR_IF) &&
// skip UNC_KT_IF_MACENTRY
+ cktt_.AddKeyType(UNC_KT_VBR_IF, UNC_KT_VBRIF_POLICINGMAP) &&
+ // skip UNC_KT_VBRIF_POLICINGMAP_ENTRY
cktt_.AddKeyType(UNC_KT_VBR_IF, UNC_KT_VBRIF_FLOWFILTER) &&
cktt_.AddKeyType(UNC_KT_VBRIF_FLOWFILTER,
- UNC_KT_VBRIF_FLOWFILTER_ENTRY) &&
- cktt_.AddKeyType(UNC_KT_VBR_IF, UNC_KT_VBRIF_POLICINGMAP)
- // skip UNC_KT_VBRIF_POLICINGMAP_ENTRY
+ UNC_KT_VBRIF_FLOWFILTER_ENTRY)
) && // NOLINT
cktt_.AddKeyType(UNC_KT_VTN, UNC_KT_VROUTER) &&
(
- cktt_.AddKeyType(UNC_KT_VROUTER, UNC_KT_VRT_IPROUTE) &&
- cktt_.AddKeyType(UNC_KT_VROUTER, UNC_KT_DHCPRELAY_SERVER) &&
- cktt_.AddKeyType(UNC_KT_VROUTER, UNC_KT_DHCPRELAY_IF) &&
cktt_.AddKeyType(UNC_KT_VROUTER, UNC_KT_VRT_IF) &&
- // skip UNC_KT_IF_ARPENTRY
cktt_.AddKeyType(UNC_KT_VRT_IF, UNC_KT_VRTIF_FLOWFILTER) &&
cktt_.AddKeyType(UNC_KT_VRTIF_FLOWFILTER,
- UNC_KT_VRTIF_FLOWFILTER_ENTRY)
+ UNC_KT_VRTIF_FLOWFILTER_ENTRY) &&
+ cktt_.AddKeyType(UNC_KT_VROUTER, UNC_KT_VRT_IPROUTE) &&
+ cktt_.AddKeyType(UNC_KT_VROUTER, UNC_KT_DHCPRELAY_SERVER) &&
+ cktt_.AddKeyType(UNC_KT_VROUTER, UNC_KT_DHCPRELAY_IF)
+ // skip UNC_KT_IF_ARPENTRY
) && // NOLINT
cktt_.AddKeyType(UNC_KT_VTN, UNC_KT_VUNKNOWN) &&
cktt_.AddKeyType(UNC_KT_VUNKNOWN, UNC_KT_VUNK_IF) &&
- // TODO(a)cktt_.AddKeyType(UNC_KT_VTN, UNC_KT_VTEP) &&
- // TODO(a)cktt_.AddKeyType(UNC_KT_VTEP, UNC_KT_VTEP_IF) &&
- // TODO(a)cktt_.AddKeyType(UNC_KT_VTN, UNC_KT_VTEP_GRP) &&
- // TODO(a)cktt_.AddKeyType(UNC_KT_VTEP_GRP, UNC_KT_VTEP_GRP_MEMBER) &&
- // TODO(a)cktt_.AddKeyType(UNC_KT_VTN, UNC_KT_VTUNNEL) &&
- // TODO(a)cktt_.AddKeyType(UNC_KT_VTUNNEL, UNC_KT_VTUNNEL_IF) &&
- cktt_.AddKeyType(UNC_KT_VTN, UNC_KT_VLINK)
+ cktt_.AddKeyType(UNC_KT_VTN, UNC_KT_VTEP) &&
+ cktt_.AddKeyType(UNC_KT_VTEP, UNC_KT_VTEP_IF) &&
+ cktt_.AddKeyType(UNC_KT_VTN, UNC_KT_VTEP_GRP) &&
+ cktt_.AddKeyType(UNC_KT_VTEP_GRP, UNC_KT_VTEP_GRP_MEMBER) &&
+ cktt_.AddKeyType(UNC_KT_VTN, UNC_KT_VTUNNEL) &&
+ cktt_.AddKeyType(UNC_KT_VTUNNEL, UNC_KT_VTUNNEL_IF) &&
+ cktt_.AddKeyType(UNC_KT_VTN, UNC_KT_VLINK) &&
+ cktt_.AddKeyType(UNC_KT_VTN, UNC_KT_VTN_POLICINGMAP) &&
+ // skip UNC_KT_VTN_POLICINGMAP_CONTROLLER
+ cktt_.AddKeyType(UNC_KT_VTN, UNC_KT_VTN_FLOWFILTER) &&
+ (
+ cktt_.AddKeyType(UNC_KT_VTN_FLOWFILTER,
+ UNC_KT_VTN_FLOWFILTER_ENTRY)
+ )
+ // skip UNC_KT_VTN_FLOWFILTER_CONTROLLER
+ // skip UNC_KT_VTN_PATHMAP_ENTRY
+ // skip UNC_KT_VTN_PATHMAP_CONTROLLER
)
) {
} else {
kt_name_map_[UNC_KT_VBRIF_POLICINGMAP] = "VBRIF_POLICINGMAP";
kt_name_map_[UNC_KT_VBRIF_POLICINGMAP_ENTRY] = "VBRIF_POLICINGMAP_ENTRY";
kt_name_map_[UNC_KT_VROUTER] = "VROUTER";
+ kt_name_map_[UNC_KT_VRT_IF] = "VRT_IF";
kt_name_map_[UNC_KT_VRT_IPROUTE] = "IPROUTE";
kt_name_map_[UNC_KT_DHCPRELAY_SERVER] = "DHCPRELAY_SERVER";
kt_name_map_[UNC_KT_DHCPRELAY_IF] = "DHCPRELAY_IF";
- kt_name_map_[UNC_KT_VRT_IF] = "VRT_IF";
kt_name_map_[UNC_KT_IF_ARPENTRY] = "IF_ARPENTRY";
kt_name_map_[UNC_KT_VRTIF_FLOWFILTER] = "VRTIF_FLOWFILTER";
kt_name_map_[UNC_KT_VRTIF_FLOWFILTER_ENTRY] = "VRTIF_FLOWFILTER_ENTRY";
upll_kt_momgrs_[UNC_KT_VRT_IF] = new uuk::VrtIfMoMgr();
upll_kt_momgrs_[UNC_KT_VUNKNOWN] = new uuk::VunknownMoMgr();
upll_kt_momgrs_[UNC_KT_VUNK_IF] = new uuk::VunkIfMoMgr();
- // upll_kt_momgrs_[UNC_KT_VTEP] = new uuk::VtepMoMgr();
- // upll_kt_momgrs_[UNC_KT_VTEP_IF] = new uuk::VtepIfMoMgr();
- // upll_kt_momgrs_[UNC_KT_VTEP_GRP] = new uuk::VtepGrpMoMgr();
- // upll_kt_momgrs_[UNC_KT_VTEP_GRP_MEMBER] = new uuk::VtepGrpMemMoMgr();
- // upll_kt_momgrs_[UNC_KT_VTUNNEL] = new uuk::VtunnelMoMgr();
- // upll_kt_momgrs_[UNC_KT_VTUNNEL_IF] = new uuk::VtunnelIfMoMgr();
+ upll_kt_momgrs_[UNC_KT_VTEP] = new uuk::VtepMoMgr();
+ upll_kt_momgrs_[UNC_KT_VTEP_IF] = new uuk::VtepIfMoMgr();
+ upll_kt_momgrs_[UNC_KT_VTEP_GRP] = new uuk::VtepGrpMoMgr();
+ upll_kt_momgrs_[UNC_KT_VTEP_GRP_MEMBER] = new uuk::VtepGrpMemMoMgr();
+ upll_kt_momgrs_[UNC_KT_VTUNNEL] = new uuk::VtunnelMoMgr();
+ upll_kt_momgrs_[UNC_KT_VTUNNEL_IF] = new uuk::VtunnelIfMoMgr();
upll_kt_momgrs_[UNC_KT_VLINK] = new uuk::VlinkMoMgr();
upll_kt_momgrs_[UNC_KT_FLOWLIST] = new uuk::FlowListMoMgr();
}
upll_rc_t UpllConfigMgr::ValidateImport(uint32_t sess_id, uint32_t config_id,
- const char *caller) {
+ const char *ctrlr_id,
+ uint32_t operation) {
UPLL_FUNC_TRACE;
- // Validate user key
+ // fix import_operation string for debug purpose
+ const char *import_operation = "";
+ if (operation == UPLL_IMPORT_CTRLR_CONFIG_OP)
+ import_operation = "import";
+ else if (operation == UPLL_MERGE_IMPORT_CONFIG_OP)
+ import_operation = "merge";
+ else if (operation == UPLL_CLEAR_IMPORT_CONFIG_OP)
+ import_operation = "clear";
+ else
+ return UPLL_RC_ERR_GENERIC;
+
+ // Validate user session
upll_rc_t urc = ValidSession(sess_id, config_id);
if (urc != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Invalid session_id %u and/or config_id %u in IPC request."
- " Err: %d", sess_id, config_id, urc);
+ UPLL_LOG_INFO("Invalid session_id %u and/or config_id %u in IPC request,"
+ " Err: %d, %s not allowed for controller %s",
+ sess_id, config_id, urc, import_operation, ctrlr_id);
return urc;
}
- // Validate if import is in progress
- pfc::core::ScopedMutex lock(import_mutex_lock_);
- if (import_in_progress_ == false) {
- UPLL_LOG_INFO("%s: Import is not in progress", caller);
+ if (operation == UPLL_CLEAR_IMPORT_CONFIG_OP)
+ return UPLL_RC_SUCCESS; // the other below checks are not required
+
+ /* TODO - can contoller be deleted and added with different type when import
+ * is in progress? -- Such scenario need to be restricted by Physical. For now
+ * Logical does not implement such a check. */
+
+ // Check controller type
+ unc_keytype_ctrtype_t ctrlr_type;
+ if (false == CtrlrMgr::GetInstance()->GetCtrlrType(
+ ctrlr_id, UPLL_DT_CANDIDATE, &ctrlr_type)) {
+ UPLL_LOG_INFO("Unable to get controller type. Cannot do %s for %s ",
+ import_operation, ctrlr_id);
+ return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ }
+ if (ctrlr_type != UNC_CT_PFC) {
+ UPLL_LOG_INFO("Import is not allowed for controller type %d."
+ " Cannot do %s for %s ",
+ ctrlr_type, import_operation, ctrlr_id);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ }
+
+ bool candidate_dirty = true;
+ // Note: caller supposed to take the lock on the database
+ urc = IsCandidateDirtyNoLock(&candidate_dirty);
+ if (urc != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("Failed to find if candidate is dirty. Urc=%d."
+ " Cannot do %s for %s", urc, import_operation, ctrlr_id);
+ return urc;
+ }
+ if (candidate_dirty == true) {
+ UPLL_LOG_INFO("There are uncommitted changes. Cannot do %s for %s",
+ import_operation, ctrlr_id);
+ return UPLL_RC_ERR_CANDIDATE_IS_DIRTY;
+ }
+
+ bool ctr_in_use = true;
+ key_ctr_t *ctr_key = reinterpret_cast<key_ctr_t*>(
+ ConfigKeyVal::Malloc(sizeof(key_ctr_t)));
+ upll_strncpy(ctr_key->controller_name, ctrlr_id, KtUtil::kCtrlrNameLenWith0);
+ ConfigKeyVal ckv(UNC_KT_CONTROLLER, IpctSt::kIpcStKeyCtr, ctr_key);
+ // Note: caller supposed to take the lock on the database
+ urc = IsKeyInUseNoLock(UPLL_DT_RUNNING, &ckv, &ctr_in_use);
+ if (urc != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("Failed to find if controller is in running config. Urc=%d."
+ "Cannot do %s for %s", urc, import_operation, ctrlr_id);
+ return urc;
+ }
+ if (ctr_in_use == true) {
+ UPLL_LOG_INFO("Controller is already configured. Cannot do %s for %s",
+ import_operation, ctrlr_id);
return UPLL_RC_ERR_NOT_ALLOWED_AT_THIS_TIME;
}
+
return UPLL_RC_SUCCESS;
}
upll_rc_t UpllConfigMgr::ImportCtrlrConfig(const char *ctrlr_id,
- upll_keytype_datatype_t dest_dt) {
+ upll_keytype_datatype_t dest_dt) {
UPLL_FUNC_TRACE;
upll_rc_t urc = UPLL_RC_SUCCESS;
- // Open Dal Connection
- DalOdbcMgr dom;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dom, true, __FUNCTION__))) {
- return urc;
- }
+ DalOdbcMgr *dom = &import_rw_dom_; // Dal Connection
key_root_t *root_key = reinterpret_cast<key_root_t *>(
ConfigKeyVal::Malloc(sizeof(key_root_t)));
// as there will be more than one VTN. A VTN will be sent in the
// response only if a VNODE is present for the VTN. VNODE val structure
// will have domain id.
- urc = momgr->CreateImportMo(&one_reqhdr, one_ckv, &dom, ctrlr_id, NULL);
+ urc = momgr->CreateImportMo(&one_reqhdr, one_ckv, dom, ctrlr_id, NULL);
delete one_ckv;
one_ckv = NULL;
if (urc != UPLL_RC_SUCCESS) {
}
UPLL_LOG_DEBUG("Import configuration status. Urc=%d", urc);
- upll_rc_t close_urc = DalClose(&dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+ upll_rc_t close_urc = DalClose(dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
if (urc == UPLL_RC_SUCCESS) {
urc = close_urc;
}
uint32_t config_id) {
UPLL_FUNC_TRACE;
- // Validate user key
- upll_rc_t urc = ValidSession(sess_id, config_id);
- if (urc != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Invalid session_id %u and/or config_id %u in IPC request."
- " Err: %d. Cannot do import for %s", sess_id, config_id, urc,
- ctrlr_id);
- return urc;
- }
-
pfc::core::ScopedMutex import_lock(import_mutex_lock_);
// Validate if import is already in progress
return UPLL_RC_ERR_NOT_ALLOWED_AT_THIS_TIME;
}
- unc_keytype_ctrtype_t ctrlr_type;
- if (false == CtrlrMgr::GetInstance()->GetCtrlrType(
- ctrlr_id, UPLL_DT_CANDIDATE, &ctrlr_type)) {
- UPLL_LOG_INFO("Unable to get controller type. Cannot do import for %s ",
- ctrlr_id);
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
- }
- if (ctrlr_type != UNC_CT_PFC) {
- UPLL_LOG_INFO("Import is not allowed for this controller type."
- " Cannot do import for %s ",
- ctrlr_id);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
- }
+ ScopedConfigLock scfg_lock(cfg_lock_,
+ UPLL_DT_IMPORT, ConfigLock::CFG_WRITE_LOCK,
+ UPLL_DT_CANDIDATE, ConfigLock::CFG_READ_LOCK);
- bool candidate_dirty = true;
- urc = IsCandidateDirty(&candidate_dirty);
- if (urc != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Failed to find if candidate is dirty. Urc=%d."
- " Cannot do import for %s", urc, ctrlr_id);
- return urc;
- }
- if (candidate_dirty == true) {
- UPLL_LOG_INFO("There are uncommitted changes. Cannot do import for %s",
- ctrlr_id);
- return UPLL_RC_ERR_CANDIDATE_IS_DIRTY;
- }
+ // Take read lock on running for doing IsCandidateDirty and IsKeyInUse check
+ // in ValidateImport
+ ScopedConfigLock scfg_lock2(cfg_lock_,
+ UPLL_DT_RUNNING, ConfigLock::CFG_READ_LOCK);
- bool ctr_in_use = true;
- key_ctr_t *ctr_key = reinterpret_cast<key_ctr_t*>(
- ConfigKeyVal::Malloc(sizeof(key_ctr_t)));
- upll_strncpy(ctr_key->controller_name, ctrlr_id, KtUtil::kCtrlrNameLenWith0);
- ConfigKeyVal ckv(UNC_KT_CONTROLLER, IpctSt::kIpcStKeyCtr, ctr_key);
- urc = IsKeyInUse(UPLL_DT_RUNNING, &ckv, &ctr_in_use);
- if (urc != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Failed to find if controller is in running config. Urc=%d."
- "Cannot do import for %s", urc, ctrlr_id);
+
+ upll_rc_t urc = ValidateImport(sess_id, config_id, ctrlr_id,
+ UPLL_IMPORT_CTRLR_CONFIG_OP);
+ if (urc != UPLL_RC_SUCCESS)
return urc;
- }
- if (ctr_in_use == true) {
- UPLL_LOG_INFO("Controller is already configured. Cannot do import for %s",
- ctrlr_id);
- return UPLL_RC_ERR_CANDIDATE_IS_DIRTY;
- }
+
// All checks are over. Let us import configuration.
import_in_progress_ = true;
UPLL_FUNC_TRACE;
upll_rc_t urc;
- urc = ValidateImport(sess_id, config_id, __FUNCTION__);
+ // Validate if import is in progress
+ pfc::core::ScopedMutex lock(import_mutex_lock_);
+ if (import_in_progress_ == false) {
+ UPLL_LOG_INFO("Import is not in progress. Merge cannot be done");
+ return UPLL_RC_ERR_NOT_ALLOWED_AT_THIS_TIME;
+ }
+
+ ScopedConfigLock scfg_lock(cfg_lock_,
+ UPLL_DT_IMPORT, ConfigLock::CFG_READ_LOCK,
+ UPLL_DT_CANDIDATE, ConfigLock::CFG_WRITE_LOCK);
+
+ // Take read lock on running for doing IsCandidateDirty and IsKeyInUse check
+ // in ValidateImport
+ ScopedConfigLock scfg_lock2(cfg_lock_,
+ UPLL_DT_RUNNING, ConfigLock::CFG_READ_LOCK);
+
+ DalOdbcMgr *dom = &import_rw_dom_;
+
+ urc = ValidateImport(sess_id, config_id, import_ctrlr_id_.c_str(),
+ UPLL_MERGE_IMPORT_CONFIG_OP);
+
if (urc == UPLL_RC_SUCCESS)
- urc = MergeValidate();
+ urc = MergeValidate(); // validate if merge conflicts with existing config
if (urc == UPLL_RC_SUCCESS)
- urc = MergeImportToCandidate();
+ urc = MergeImportToCandidate(); // merge import config to candidate config
+
+ upll_rc_t db_urc = DalClose(dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+ if (urc == UPLL_RC_SUCCESS) {
+ urc = db_urc;
+ }
+
+ if (urc == UPLL_RC_SUCCESS) {
+ candidate_dirty_qc_lock_.lock();
+ candidate_dirty_qc_ = true;
+ candidate_dirty_qc_lock_.unlock();
+ }
return urc;
}
upll_rc_t UpllConfigMgr::MergeValidate() {
UPLL_FUNC_TRACE;
- upll_rc_t urc;
+ upll_rc_t urc = UPLL_RC_SUCCESS;
unc_key_type_t kt;
- ScopedConfigLock scfg_lock(cfg_lock_,
- UPLL_DT_IMPORT, ConfigLock::CFG_READ_LOCK,
- UPLL_DT_CANDIDATE, ConfigLock::CFG_READ_LOCK);
- DalOdbcMgr dom;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dom, false, __FUNCTION__))) {
- return urc;
- }
+ DalOdbcMgr *dom = &import_rw_dom_;
const std::list<unc_key_type_t> *pre_list = cktt_.get_preorder_list();
for (std::list<unc_key_type_t>::const_iterator pre_it = pre_list->begin();
pre_it != pre_list->end(); pre_it++) {
kt = *pre_it;
+ bool flag = false;
if (upll_kt_momgrs_.count(kt) > 0) {
+ unc_key_type_t child_key[]= { UNC_KT_VBRIDGE, UNC_KT_VBR_VLANMAP,
+ UNC_KT_VBR_NWMONITOR, UNC_KT_VBR_NWMONITOR_HOST,
+ UNC_KT_VBR_IF, UNC_KT_VROUTER, UNC_KT_VRT_IPROUTE,
+ UNC_KT_DHCPRELAY_SERVER, UNC_KT_DHCPRELAY_IF,
+ UNC_KT_VRT_IF, UNC_KT_VUNKNOWN, UNC_KT_VUNK_IF,
+ UNC_KT_VTEP, UNC_KT_VTEP_IF, UNC_KT_VTEP_GRP,
+ UNC_KT_VTEP_GRP_MEMBER, UNC_KT_VTUNNEL,
+ UNC_KT_VTUNNEL_IF, UNC_KT_VLINK
+ };
+ for (unsigned int i = 0; i < sizeof(child_key)/sizeof(child_key[0]);
+ i++) {
+ const unc_key_type_t ktype = child_key[i];
+ if (ktype == kt) {
+ UPLL_LOG_TRACE("Skip MergeValidate Here, Its done in UNC_KT_VTN for"
+ "the key type %d if applicable", ktype);
+ flag = true;
+ break;
+ }
+ }
+ if (flag)
+ continue;
MoManager *momgr = upll_kt_momgrs_[kt];
ConfigKeyVal conflict_ckv(kt);
urc = momgr->MergeValidate(kt, import_ctrlr_id_.c_str(),
- &conflict_ckv, &dom);
+ &conflict_ckv, dom);
if (urc != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("MergeValidate failed %d", urc);
break;
}
}
}
-
- urc = DalClose(&dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
-
return urc;
}
upll_rc_t UpllConfigMgr::MergeImportToCandidate() {
UPLL_FUNC_TRACE;
- upll_rc_t urc;
+ upll_rc_t urc = UPLL_RC_SUCCESS;
unc_key_type_t kt;
- ScopedConfigLock scfg_lock(cfg_lock_,
- UPLL_DT_IMPORT, ConfigLock::CFG_READ_LOCK,
- UPLL_DT_CANDIDATE, ConfigLock::CFG_WRITE_LOCK);
- DalOdbcMgr dom;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dom, true, __FUNCTION__))) {
- return urc;
- }
+ DalOdbcMgr *dom = &import_rw_dom_;
const std::list<unc_key_type_t> *pre_list = cktt_.get_preorder_list();
for (std::list<unc_key_type_t>::const_iterator pre_it = pre_list->begin();
kt = *pre_it;
if (upll_kt_momgrs_.count(kt) > 0) {
MoManager *momgr = upll_kt_momgrs_[kt];
- urc = momgr->MergeImportToCandidate(kt, import_ctrlr_id_.c_str(), &dom);
+ urc = momgr->MergeImportToCandidate(kt, import_ctrlr_id_.c_str(), dom);
if (urc != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("MergeImportToCandidate failed %d", urc);
break;
}
}
- urc = DalClose(&dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+#if 0
+ upll_rc_t db_urc = DalClose(dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
candidate_dirty_qc_lock_.lock();
candidate_dirty_qc_ = true;
candidate_dirty_qc_lock_.unlock();
-
+ if (urc == UPLL_RC_SUCCESS) {
+ urc = db_urc;
+ }
+#endif
return urc;
}
upll_rc_t UpllConfigMgr::IsCandidateDirty(bool *dirty) {
UPLL_FUNC_TRACE;
- upll_rc_t urc;
+
+ ScopedConfigLock scfg_lock(cfg_lock_,
+ UPLL_DT_CANDIDATE, ConfigLock::CFG_READ_LOCK,
+ UPLL_DT_RUNNING, ConfigLock::CFG_WRITE_LOCK);
+ return IsCandidateDirtyNoLock(dirty);
+}
+
+upll_rc_t UpllConfigMgr::IsCandidateDirtyNoLock(bool *dirty) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t urc = UPLL_RC_SUCCESS;
unc_key_type_t kt;
if (dirty == NULL) {
UPLL_LOG_DEBUG("Null argument: dirty");
return UPLL_RC_ERR_GENERIC;
}
- ScopedConfigLock scfg_lock(cfg_lock_,
- UPLL_DT_CANDIDATE, ConfigLock::CFG_READ_LOCK,
- UPLL_DT_RUNNING, ConfigLock::CFG_WRITE_LOCK);
-
candidate_dirty_qc_lock_.lock();
*dirty = candidate_dirty_qc_;
candidate_dirty_qc_lock_.unlock();
- if (*dirty == true) {
+ if (*dirty == false) {
return UPLL_RC_SUCCESS;
}
- DalOdbcMgr dom;
+ DalOdbcMgr *dom = NULL;
if (UPLL_RC_SUCCESS != (urc = DalOpen(&dom, false, __FUNCTION__))) {
return urc;
}
+ *dirty = false;
+
const std::list<unc_key_type_t> *pre_list = cktt_.get_preorder_list();
for (std::list<unc_key_type_t>::const_iterator pre_it = pre_list->begin();
pre_it != pre_list->end(); pre_it++) {
kt = *pre_it;
if (upll_kt_momgrs_.count(kt) > 0) {
MoManager *momgr = upll_kt_momgrs_[kt];
- urc = momgr->IsCandidateDirty(kt, dirty, &dom);
+ urc = momgr->IsCandidateDirty(kt, dirty, dom);
if (urc != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("IsCandidateDirty failed %d", urc);
break;
}
- if (*dirty == true)
+ if (*dirty == true) {
+ UPLL_LOG_DEBUG("CandidateDirty KT - %s", kt_name_map_[kt].c_str());
break;
+ }
}
}
- urc = DalClose(&dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+ upll_rc_t db_urc = DalClose(dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+ if (urc == UPLL_RC_SUCCESS) {
+ urc = db_urc;
+ }
return urc;
}
upll_rc_t UpllConfigMgr::IsKeyInUse(upll_keytype_datatype_t datatype,
const ConfigKeyVal *ckv, bool *in_use) {
UPLL_FUNC_TRACE;
+ ScopedConfigLock scfg_lock(cfg_lock_, datatype, ConfigLock::CFG_READ_LOCK);
+ return IsKeyInUseNoLock(datatype, ckv, in_use);
+}
+
+
+upll_rc_t UpllConfigMgr::IsKeyInUseNoLock(upll_keytype_datatype_t datatype,
+ const ConfigKeyVal *ckv,
+ bool *in_use) {
+ UPLL_FUNC_TRACE;
PFC_ASSERT(ckv != NULL);
PFC_ASSERT(in_use != NULL);
return UPLL_RC_ERR_NO_SUCH_NAME;
}
if (momgr) {
- ScopedConfigLock scfg_lock(cfg_lock_, datatype, ConfigLock::CFG_READ_LOCK);
-
- DalOdbcMgr dom;
+ DalOdbcMgr *dom = NULL;
if (UPLL_RC_SUCCESS != (urc = DalOpen(&dom, false, __FUNCTION__))) {
return urc;
}
- urc = momgr->IsKeyInUse(datatype, ckv, in_use, &dom);
+ urc = momgr->IsKeyInUse(datatype, ckv, in_use, dom);
- urc = DalClose(&dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+ upll_rc_t db_urc = DalClose(dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+ if (urc == UPLL_RC_SUCCESS) {
+ urc = db_urc;
+ }
} else {
urc = UPLL_RC_ERR_GENERIC;
}
return UPLL_RC_ERR_GENERIC;
}
-upll_rc_t UpllConfigMgr::DalOpen(DalOdbcMgr *dom, bool read_write_conn,
+upll_rc_t UpllConfigMgr::DalOpen(DalOdbcMgr **dom, bool read_write_conn,
const char *caller) {
UPLL_FUNC_TRACE;
uudal::DalConnType conn_type = ((read_write_conn) ? uudal::kDalConnReadWrite :
uudal::kDalConnReadOnly);
+ bool dom_allocated = false;
+ if ((*dom != &config_rw_dom_) && (*dom != &import_rw_dom_) &&
+ (*dom != &alarm_rw_dom_) && (*dom != &config_ro_dom_)) {
+ *dom = new DalOdbcMgr();
+ dom_allocated = true;
+ }
// Initialize
- drc = dom->Init();
+ drc = (*dom)->Init();
if (drc != uudal::kDalRcSuccess) {
if (read_write_conn) {
pfc_log_fatal("%s: Failed to initialize DalOdbcMgr. Err=%d", caller, drc);
UPLL_LOG_ERROR("%s: Failed to initialize DalOdbcMgr. Err=%d", caller,
drc);
}
+ if (dom_allocated) {
+ delete (*dom);
+ *dom = NULL;
+ }
return ConvertDalResultCode(drc);
} else {
UPLL_LOG_TRACE("%s: DalOdbcMgr init successful.", caller);
}
// Connect to DB
- drc = dom->ConnectToDb(conn_type);
+ drc = (*dom)->ConnectToDb(conn_type);
if (drc != uudal::kDalRcSuccess) {
if (read_write_conn) {
pfc_log_fatal("%s: Failed to connect to database. Err=%d", caller, drc);
} else {
UPLL_LOG_ERROR("%s: Failed to connect to database. Err=%d", caller, drc);
}
+ if (dom_allocated) {
+ delete (*dom);
+ *dom = NULL;
+ }
return ConvertDalResultCode(drc);
} else {
UPLL_LOG_TRACE("%s: Connected to database.", caller);
}
+
return UPLL_RC_SUCCESS;
}
upll_rc_t UpllConfigMgr::DalClose(DalOdbcMgr *dom, bool commit,
const char *caller) {
UPLL_FUNC_TRACE;
- // TODO(a): FATAL on DB access errors
+
uudal::DalResultCode drc;
upll_rc_t urc = UPLL_RC_SUCCESS;
- if (commit) {
- // Commit the transaction
- drc = dom->CommitTransaction();
- if (drc != uudal::kDalRcSuccess) {
- UPLL_LOG_ERROR("%s: Failed to commit DB transaction. Err=%d",
- caller, drc);
- urc = ConvertDalResultCode(drc);
+ // Commit or Rollback is required only read-write connections
+ if (dom->get_conn_type() == uudal::kDalConnReadWrite) {
+ if (commit) {
+ // Commit the transaction
+ drc = dom->CommitTransaction();
+ if (drc != uudal::kDalRcSuccess) {
+ UPLL_LOG_ERROR("%s: Failed to commit DB transaction. Err=%d",
+ caller, drc);
+ urc = ConvertDalResultCode(drc);
+ } else {
+ UPLL_LOG_TRACE("%s: Committed the DB transaction.", caller);
+ urc = UPLL_RC_SUCCESS;
+ }
} else {
- UPLL_LOG_TRACE("%s: Committed the DB transaction.", caller);
- urc = UPLL_RC_SUCCESS;
+ // Rollback the transaction
+ drc = dom->RollbackTransaction();
+ if (drc != uudal::kDalRcSuccess) {
+ UPLL_LOG_ERROR("%s: Failed to rollback DB transaction. Err=%d",
+ caller, drc);
+ urc = ConvertDalResultCode(drc);
+ } else {
+ UPLL_LOG_TRACE("%s: Rolledback the DB transaction.", caller);
+ urc = UPLL_RC_SUCCESS;
+ }
}
- } else {
- // Rollback the transaction
- drc = dom->RollbackTransaction();
+ }
+
+ // disconnect and delete dom instance for dynamic connections .
+ if ((dom != &config_rw_dom_) && (dom != &import_rw_dom_) &&
+ (dom != &alarm_rw_dom_) && (dom != &config_ro_dom_)) {
+ // Disconnect from database; on error do not change urc.
+ drc = dom->DisconnectFromDb();
if (drc != uudal::kDalRcSuccess) {
- UPLL_LOG_ERROR("%s: Failed to rollback DB transaction. Err=%d",
- caller, drc);
- urc = ConvertDalResultCode(drc);
+ UPLL_LOG_ERROR("%s: Failed to disconnect from database. Err=%d",
+ caller, drc);
} else {
- UPLL_LOG_TRACE("%s: Rolledback the DB transaction.", caller);
- urc = UPLL_RC_SUCCESS;
+ UPLL_LOG_TRACE("%s: Disconnected from database.", caller);
}
+
+ delete dom;
+ }
+
+ return urc;
+}
+
+upll_rc_t UpllConfigMgr::DalOpenInitialConnections() {
+ UPLL_FUNC_TRACE;
+ pfc::core::ScopedMutex lock(rw_dom_mutex_lock_);
+ upll_rc_t urc = UPLL_RC_SUCCESS;
+
+ DalOdbcMgr *dom = &config_rw_dom_;
+ if (UPLL_RC_SUCCESS != (urc = DalOpen(&dom, true, __FUNCTION__))) {
+ return urc;
+ }
+ dom = &config_ro_dom_;
+ if (UPLL_RC_SUCCESS != (urc = DalOpen(&dom, true, __FUNCTION__))) {
+ return urc;
+ }
+ dom = &import_rw_dom_;
+ if (UPLL_RC_SUCCESS != (urc = DalOpen(&dom, true, __FUNCTION__))) {
+ return urc;
+ }
+ dom = &alarm_rw_dom_;
+ if (UPLL_RC_SUCCESS != (urc = DalOpen(&dom, true, __FUNCTION__))) {
+ return urc;
}
- // Disconnect from database; on error do not change urc.
- drc = dom->DisconnectFromDb();
+ return urc;
+}
+
+upll_rc_t UpllConfigMgr::DalCloseInitialConnections() {
+ UPLL_FUNC_TRACE;
+ pfc::core::ScopedMutex lock(rw_dom_mutex_lock_);
+ upll_rc_t urc = UPLL_RC_SUCCESS;
+ uudal::DalResultCode drc;
+
+ drc = config_rw_dom_.DisconnectFromDb();
if (drc != uudal::kDalRcSuccess) {
- UPLL_LOG_ERROR("%s: Failed to disconnect from database. Err=%d",
- caller, drc);
- } else {
- UPLL_LOG_TRACE("%s: Disconnected from database.", caller);
+ UPLL_LOG_ERROR("Failed to disconnect config_rw_dom_ from database. Err=%d",
+ drc);
+ urc = UPLL_RC_ERR_GENERIC;
+ }
+ drc = config_ro_dom_.DisconnectFromDb();
+ if (drc != uudal::kDalRcSuccess) {
+ UPLL_LOG_ERROR("Failed to disconnect config_ro_dom_ from database. Err=%d",
+ drc);
+ urc = UPLL_RC_ERR_GENERIC;
+ }
+ drc = import_rw_dom_.DisconnectFromDb();
+ if (drc != uudal::kDalRcSuccess) {
+ UPLL_LOG_ERROR("Failed to disconnect import_rw_dom_ from database. Err=%d",
+ drc);
+ urc = UPLL_RC_ERR_GENERIC;
+ }
+ drc = alarm_rw_dom_.DisconnectFromDb();
+ if (drc != uudal::kDalRcSuccess) {
+ UPLL_LOG_ERROR("Failed to disconnect alarm_rw_dom_ from database. Err=%d",
+ drc);
+ urc = UPLL_RC_ERR_GENERIC;
}
return urc;
}
void UpllConfigMgr::OnPathFaultAlarm(const char *ctrlr_name,
- const char *domain_id,
+ const char *domain_name,
std::vector<std::string> &ingress_ports,
std::vector<std::string> &egress_ports,
bool alarm_asserted) {
UPLL_FUNC_TRACE;
- ScopedConfigLock lock(cfg_lock_, UPLL_DT_RUNNING, ConfigLock::CFG_READ_LOCK);
- upll_rc_t urc;
- DalOdbcMgr dom;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dom, true, __FUNCTION__))) {
- return;
- }
- MoManager *mgr = GetMoManager(UNC_KT_VBR_IF);
+ ScopedConfigLock lock(cfg_lock_, UPLL_DT_RUNNING, ConfigLock::CFG_WRITE_LOCK);
+ uuk::VbrIfMoMgr *mgr = reinterpret_cast<uuk::VbrIfMoMgr *>
+ (GetMoManager(UNC_KT_VBR_IF));
if (mgr != NULL) {
- /*
- urc = mgr->PathFaultHandler(ctrlr_name, domain_id, ingress_ports,
- egress_ports, alarm_asserted, dom);
- */
+ upll_rc_t urc;
+ DalOdbcMgr *dom = &alarm_rw_dom_;
+ urc = mgr->PathFaultHandler(ctrlr_name, domain_name, ingress_ports,
+ egress_ports, alarm_asserted, dom);
+ DalClose(dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
}
- DalClose(&dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
}
-void UpllConfigMgr::OnControllerDown(const char *ctrlr_name) {
+void UpllConfigMgr::OnControllerStatusChange(const char *ctrlr_name,
+ bool operstatus) {
UPLL_FUNC_TRACE;
- ScopedConfigLock lock(cfg_lock_, UPLL_DT_RUNNING, ConfigLock::CFG_READ_LOCK);
- upll_rc_t urc;
- DalOdbcMgr dom;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dom, true, __FUNCTION__))) {
- return;
- }
- MoManager *mgr = GetMoManager(UNC_KT_VTN);
+ ScopedConfigLock lock(cfg_lock_, UPLL_DT_RUNNING, ConfigLock::CFG_WRITE_LOCK);
+ uuk::VtnMoMgr *mgr = reinterpret_cast<uuk::VtnMoMgr *>
+ (GetMoManager(UNC_KT_VTN));
if (mgr != NULL) {
- // mgr->ControllerDisconnectHandler(ctrlr_name, dom);
+ upll_rc_t urc;
+ DalOdbcMgr *dom = &alarm_rw_dom_;
+ urc = mgr->ControllerStatusHandler(reinterpret_cast<uint8_t*>(
+ const_cast<char*>(ctrlr_name)), dom, operstatus);
+ DalClose(dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
}
- DalClose(&dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
}
void UpllConfigMgr::OnLogicalPortStatusChange(const char *ctrlr_name,
const char *logical_port_id,
bool oper_status) {
UPLL_FUNC_TRACE;
- ScopedConfigLock lock(cfg_lock_, UPLL_DT_RUNNING, ConfigLock::CFG_READ_LOCK);
- upll_rc_t urc;
- DalOdbcMgr dom;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dom, true, __FUNCTION__))) {
- return;
- }
- MoManager *mgr = GetMoManager(UNC_KT_VBR_IF);
+ ScopedConfigLock lock(cfg_lock_, UPLL_DT_RUNNING, ConfigLock::CFG_WRITE_LOCK);
+ uuk::VbrIfMoMgr *mgr = reinterpret_cast<uuk::VbrIfMoMgr *>
+ (GetMoManager(UNC_KT_VBR_IF));
if (mgr != NULL) {
- // mgr->PortStatusHandler(ctrlr_name, domain_name, logical_port_id,
- // oper_status, dom);
+ upll_rc_t urc;
+ DalOdbcMgr *dom = &alarm_rw_dom_;
+ urc = mgr->PortStatusHandler(ctrlr_name, domain_name, logical_port_id,
+ oper_status, dom);
+ DalClose(dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
}
- DalClose(&dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
}
void UpllConfigMgr::OnBoundaryStatusChange(const char *boundary_id,
bool oper_status) {
UPLL_FUNC_TRACE;
- ScopedConfigLock lock(cfg_lock_, UPLL_DT_RUNNING, ConfigLock::CFG_READ_LOCK);
- upll_rc_t urc;
- DalOdbcMgr dom;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dom, true, __FUNCTION__))) {
- return;
- }
- MoManager *mgr = GetMoManager(UNC_KT_VLINK);
+ ScopedConfigLock lock(cfg_lock_, UPLL_DT_RUNNING, ConfigLock::CFG_WRITE_LOCK);
+#if 1
+ uuk::VlinkMoMgr *mgr = reinterpret_cast<uuk::VlinkMoMgr *>
+ (GetMoManager(UNC_KT_VLINK));
if (mgr != NULL) {
- // mgr->BoundaryStatusHandler(ctrlr_name, domain_name, logical_port_id,
- // oper_status, dom);
- }
- DalClose(&dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+ upll_rc_t urc;
+ DalOdbcMgr *dom = &alarm_rw_dom_;
+ urc = mgr->BoundaryStatusHandler(
+ reinterpret_cast<uint8_t*>(const_cast<char*>(boundary_id)),
+ oper_status, dom);
+ DalClose(dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+ }
+#else
+ UPLL_LOG_DEBUG("Recevied boundary %s oper status %d\n",boundary_id,oper_status);
+#endif
}
void UpllConfigMgr::OnPolicerFullAlarm(
UPLL_FUNC_TRACE;
namespace uuk = unc::upll::kt_momgr;
ScopedConfigLock lock(cfg_lock_, UPLL_DT_RUNNING, ConfigLock::CFG_READ_LOCK);
- upll_rc_t urc;
- DalOdbcMgr dom;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dom, true, __FUNCTION__))) {
- return;
- }
uuk::VbrPolicingMapMoMgr *mgr = reinterpret_cast<uuk::VbrPolicingMapMoMgr*>
- (const_cast<MoManager*> (GetMoManager(UNC_KT_VBR_POLICINGMAP)));
+ (GetMoManager(UNC_KT_VBR_POLICINGMAP));
if (mgr != NULL) {
- mgr->OnPolicerFullAlarm(ctrlr_name,domain_id, key_vtn,
- alarm_data, alarm_raised, &dom);
+ upll_rc_t urc;
+ DalOdbcMgr *dom = NULL;
+ if (UPLL_RC_SUCCESS != (urc = DalOpen(&dom, false, __FUNCTION__))) {
+ return;
+ }
+ urc = mgr->OnPolicerFullAlarm(ctrlr_name, domain_id, key_vtn,
+ alarm_data, alarm_raised, dom);
+ DalClose(dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
}
- DalClose(&dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
}
void UpllConfigMgr::OnPolicerFailAlarm(
UPLL_FUNC_TRACE;
namespace uuk = unc::upll::kt_momgr;
ScopedConfigLock lock(cfg_lock_, UPLL_DT_RUNNING, ConfigLock::CFG_READ_LOCK);
- upll_rc_t urc;
- DalOdbcMgr dom;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dom, true, __FUNCTION__))) {
- return;
- }
+
uuk::VbrPolicingMapMoMgr *mgr = reinterpret_cast<uuk::VbrPolicingMapMoMgr*>
- (const_cast<MoManager*> (GetMoManager(UNC_KT_VBR_POLICINGMAP)));
+ (GetMoManager(UNC_KT_VBR_POLICINGMAP));
if (mgr != NULL) {
- mgr->OnPolicerFailAlarm(ctrlr_name,domain_id, key_vtn,
- alarm_data, alarm_raised, &dom);
+ upll_rc_t urc;
+ DalOdbcMgr *dom = NULL;
+ if (UPLL_RC_SUCCESS != (urc = DalOpen(&dom, false, __FUNCTION__))) {
+ return;
+ }
+ urc = mgr->OnPolicerFailAlarm(ctrlr_name, domain_id, key_vtn,
+ alarm_data, alarm_raised, dom);
+ DalClose(dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
}
- DalClose(&dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
}
void UpllConfigMgr::OnNwmonFaultAlarm(
- string ctrlr_name, string domain_id, const key_vtn_t &key_vtn,
+ string ctrlr_name, string domain_id, const key_vtn_t &vtn_key,
const pfcdrv_network_mon_alarm_data_t &alarm_data, bool alarm_raised) {
UPLL_FUNC_TRACE;
ScopedConfigLock lock(cfg_lock_, UPLL_DT_RUNNING, ConfigLock::CFG_READ_LOCK);
- upll_rc_t urc;
- DalOdbcMgr dom;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dom, true, __FUNCTION__))) {
- return;
- }
- MoManager *mgr = GetMoManager(UNC_KT_VBR_NWMONITOR);
- if (mgr != NULL) {
- // TODO(a) mgr->OnNwmonFault(ctrlr_name, key_vtn, alarm_data, alarm_raised,
- // dom);
+ uuk::NwMonitorMoMgr *nwm_mgr = reinterpret_cast<uuk::NwMonitorMoMgr*>
+ (const_cast<MoManager*>(GetMoManager(UNC_KT_VBR_NWMONITOR)));
+ if (nwm_mgr != NULL) {
+ upll_rc_t urc;
+ DalOdbcMgr *dom = &alarm_rw_dom_;
+ urc = nwm_mgr->OnNwmonFault(ctrlr_name, domain_id, vtn_key, alarm_data,
+ alarm_raised, dom);
+ DalClose(dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
}
- DalClose(&dom, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
}
/**
data.alarm_class = pfc::alarm::ALM_WARNING;
data.alarm_kind = 1; // assert alarm
} else {
- message = "Operational status down";
- message_summary = "Operational status down";
+ message = "Operational status up";
+ message_summary = "Operational status up";
data.alarm_class = pfc::alarm::ALM_NOTICE;
data.alarm_kind = 0; // clear alarm
}
pfc::alarm::alarm_return_code_t ret = pfc::alarm::pfc_alarm_send_with_key(
vtn_name, message, message_summary, &data, alarm_fd);
if (ret != pfc::alarm::ALM_OK) {
- UPLL_LOG_WARN("Failed to %s invalid configuration alarm",
- (assert_alarm) ? "assert" : "clear");
- return false;
+ UPLL_LOG_WARN("Failed to %s invalid configuration alarm, Err=%d",
+ ((assert_alarm) ? "assert" : "clear"), ret);
+ // return false;
+ return true;
}
return true;
* @return @see upll_rc_t
*/
upll_rc_t IsCandidateDirty(bool *dirty);
+ // caller should have taken the READ lock on CANDIDATE and RUNNING
+ upll_rc_t IsCandidateDirtyNoLock(bool *dirty);
/**
* @brief Imports controller configuration to DT_IMPORT
* @param[in] config_id Config ID of the service user
* @param[in] sby2act_trans state transition to active
*
- * @return
+ * @return
*/
upll_rc_t ClearImport(uint32_t session_id, uint32_t config_id,
bool sby2act_trans);
*/
upll_rc_t IsKeyInUse(upll_keytype_datatype_t datatype,
const ConfigKeyVal *ckv, bool *in_use);
+ // Caller should have taken the READ lock on the datatype
+ upll_rc_t IsKeyInUseNoLock(upll_keytype_datatype_t datatype,
+ const ConfigKeyVal *ckv, bool *in_use);
/**
* @brief Path Fault Alarm Handler
* @param[in] egress_ports vector of egress ports
* @param[in] alarm_asserted true if alarm is asserted, false otherwise
*/
- void OnPathFaultAlarm(const char *ctrlr_name, const char *domain_id,
+ void OnPathFaultAlarm(const char *ctrlr_name,
+ const char *domain_name,
std::vector<std::string> &ingress_ports,
std::vector<std::string> &egress_ports,
bool alarm_asserted);
* @brief Controller down event handler
*
* @param[in] ctrlr_name name of the controller
+ * @param[in] operstatus operational status of controller
*/
- void OnControllerDown(const char *ctrlr_name);
+ void OnControllerStatusChange(const char *ctrlr_name, bool operstatus);
/**
* @brief Logical Port operstatus change event handler
upll_rc_t OnTxVoteCtrlrStatus(std::list<CtrlrVoteStatus*> *ctrlr_vote_status);
upll_rc_t OnAuditTxVoteCtrlrStatus(CtrlrVoteStatus *ctrlr_vote_status);
upll_rc_t OnTxGlobalCommit(const std::set<std::string> **affected_ctrlr_list);
- upll_rc_t OnAuditTxGlobalCommit(const char *ctrlr_id,
- const std::set<std::string> **affected_ctrlr_list);
+ upll_rc_t OnAuditTxGlobalCommit(
+ const char *ctrlr_id, const std::set<std::string> **affected_ctrlr_list);
upll_rc_t OnTxCommitCtrlrStatus(
uint32_t session_id, uint32_t config_id,
std::list<CtrlrCommitStatus*> *ctrlr_commit_status);
tclib_impl_.SetClusterState(active);
sys_state_rwlock_.unlock();
if (active) {
+ DalOpenInitialConnections();
OnAuditEnd("", true);
ClearImport(0, 0, true);
+ } else {
+ DalCloseInitialConnections();
}
}
bool IsActiveNode() {
sys_state_rwlock_.unlock();
return state;
}
+ bool SendOperStatusAlarm(const char *vtn_name, const char *vnode_name,
+ const char *vif_name, bool assert_alarm);
private:
UpllConfigMgr();
upll_rc_t ValidateCommit(const char *caller);
upll_rc_t ValidateAudit(const char *caller, const char *ctrlr_id);
upll_rc_t ValidateImport(uint32_t session_id, uint32_t config_id,
- const char *caller);
+ const char *ctrlr_id, uint32_t operation);
upll_rc_t ImportCtrlrConfig(const char *ctrlr_id, upll_keytype_datatype_t dt);
// Helper functions or DB operations
- upll_rc_t DalOpen(DalOdbcMgr *dom, bool read_write_conn, const char *caller);
+ upll_rc_t DalOpen(DalOdbcMgr **dom, bool read_write_conn, const char *caller);
upll_rc_t DalClose(DalOdbcMgr *dom, bool commit, const char *caller);
+ upll_rc_t DalOpenInitialConnections();
+ upll_rc_t DalCloseInitialConnections();
bool SendInvalidConfigAlarm(string ctrlr_name, bool assert_alarm);
- bool SendOperStatusAlarm(const char *vtn_name, const char *vnode_name,
- const char *vif_name, bool assert_alarm);
bool node_active_; // cluster state
pfc::core::Mutex audit_mutex_lock_;
std::set<std::string> affected_ctrlr_set_;
+ // Initail database connections. When node turns ACTIVE, intial connections
+ // are mode, and when node turns STANDBY from ACTIVE, initial connections are
+ // closed.
+ pfc::core::Mutex rw_dom_mutex_lock_;
+ DalOdbcMgr config_rw_dom_;
+ DalOdbcMgr config_ro_dom_;
+ DalOdbcMgr import_rw_dom_;
+ DalOdbcMgr alarm_rw_dom_;
+
int32_t alarm_fd;
static UpllConfigMgr *singleton_instance_;
#include "unc/pfcdriver_include.h"
#include "unc/upll_svc.h"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "kt_util.hh"
#include "ctrlr_mgr.hh"
return PFC_IPCRESP_FATAL;
}
+ // Increasing IPC session timeout only for PING operation
+ if (msghdr.operation == UNC_OP_CONTROL && msghdr.option2 == UNC_OPT2_PING) {
+ pfc_timespec_t ping_tspec;
+ ping_tspec.tv_sec = kIpcTimeoutPing;
+ ping_tspec.tv_nsec = 0;
+ sess->setTimeout(&ping_tspec);
+ UPLL_LOG_DEBUG("IPC Server Session timeout for Ping set to %d",
+ kIpcTimeoutPing);
+ }
+
pfc_ipcresp_t ret = config_mgr_->KtServiceHandler(service, &msghdr, ckv);
if (ret != 0) {
UPLL_LOG_DEBUG("Failed in processing the key tree request");
switch (operation) {
case UPLL_IS_CANDIDATE_DIRTY_OP: {
bool dirty = true;
+ sess->setTimeout(NULL);
+ UPLL_LOG_DEBUG("IPC Server Session timeout for IS_CANDIDATE_DIRTY is set "
+ " to infinite");
urc = config_mgr_->IsCandidateDirty(&dirty);
// Write response
if ((0 != (ipc_err = sess->addOutput((uint32_t)operation))) ||
}
return 0;
}
+
+ /*
+ pfc_timespec_t sess_timeout;
+ sess_timeout.tv_sec = kIpcTimeoutImport;
+ sess_timeout.tv_nsec = 0;
+ sess->setTimeout(&sess_timeout);
+ UPLL_LOG_DEBUG("IPC Server Session timeout for Import set to %d",
+ kIpcTimeoutImport);
+ */
+ sess->setTimeout(NULL);
+ UPLL_LOG_DEBUG("IPC Server Session timeout for Import set to infinite.");
+
urc = config_mgr_->StartImport(ctrlr_name, session_id, config_id);
+ UPLL_LOG_TRACE("StartImport: urc=%d, ctrlr_name=%s,"
+ " session_id=%d, config_id=%d",
+ urc, ctrlr_name, session_id, config_id);
// Write response
if ((0 != (ipc_err = sess->addOutput((uint32_t)operation))) ||
(0 != (ipc_err = sess->addOutput((uint32_t)urc)))) {
arg, ipc_err);
return PFC_IPCRESP_FATAL;
}
+
+ /*
+ pfc_timespec_t sess_timeout;
+ sess_timeout.tv_sec = kIpcTimeoutImport;
+ sess_timeout.tv_nsec = 0;
+ sess->setTimeout(&sess_timeout);
+ UPLL_LOG_DEBUG("IPC Server Session timeout for ImportMerge set to %d",
+ kIpcTimeoutImport);
+ */
+ sess->setTimeout(NULL);
+ UPLL_LOG_DEBUG("IPC Server Session timeout for Merge set to infinite");
+
urc = config_mgr_->OnMerge(session_id, config_id);
+ UPLL_LOG_TRACE("Merge: urc=%d, session_id=%d, config_id=%d",
+ urc, session_id, config_id);
// Write response
if ((0 != (ipc_err = sess->addOutput((uint32_t)operation))) ||
(0 != (ipc_err = sess->addOutput((uint32_t)urc)))) {
return PFC_IPCRESP_FATAL;
}
urc = config_mgr_->ClearImport(session_id, config_id, false);
+ UPLL_LOG_TRACE("ClearImport: urc=%d, session_id=%d, config_id=%d",
+ urc, session_id, config_id);
// Write response
if ((0 != (ipc_err = sess->addOutput((uint32_t)operation))) ||
(0 != (ipc_err = sess->addOutput((uint32_t)urc)))) {
uint32_t keytype;
key_ctr_t ctr_key;
val_ctr_t ctr_val;
+ memset(&ctr_key, 0, sizeof(key_ctr_t));
+ memset(&ctr_val, 0, sizeof(val_ctr_t));
int ipc_err;
upll_rc_t urc = UPLL_RC_SUCCESS;
CtrlrMgr *ctrlr_mgr = CtrlrMgr::GetInstance();
if (operation == UNC_OP_CREATE) {
- if (ctr_val.valid[kIdxType] == UNC_VF_VALID &&
- ctr_val.valid[kIdxVersion] == UNC_VF_VALID) {
+ urc = UPLL_RC_SUCCESS;
+ if (ctr_val.valid[kIdxType] == UNC_VF_VALID) {
+ // For Unknown, version is optional.
+ if (((unc_keytype_ctrtype_t)ctr_val.type == UNC_CT_PFC ||
+ (unc_keytype_ctrtype_t)ctr_val.type == UNC_CT_VNP)) {
+ if (ctr_val.valid[kIdxVersion] == UNC_VF_INVALID) {
+ urc = UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ } else if ((unc_keytype_ctrtype_t)ctr_val.type == UNC_CT_UNKNOWN) {
+ if (ctr_val.valid[kIdxVersion] == UNC_VF_INVALID) {
+ memset(ctr_val.version, 0, sizeof(ctr_val.version));
+ }
+ } else {
+ urc = UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ } else {
+ urc = UPLL_RC_ERR_CFG_SYNTAX;
+ }
- CtrlrMgr::Ctrlr ctrlr(reinterpret_cast<char*>(ctr_key.controller_name),
- (unc_keytype_ctrtype_t)ctr_val.type,
- reinterpret_cast<char*>(ctr_val.version));
- urc = ctrlr_mgr->Add(ctrlr, (upll_keytype_datatype_t)datatype);
- if (urc != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Controller add failed %s",
- reinterpret_cast<char*>(ctr_key.controller_name));
+ if (urc != UPLL_RC_SUCCESS) {
+ if ((0 != (ipc_err = sess->addOutput((uint32_t)UPLL_UPPL_UPDATE_OP))) ||
+ (0 != (ipc_err = sess->addOutput((uint32_t)urc)))) {
+ UPLL_LOG_DEBUG("Unable to write IPC response. Err=%d", ipc_err);
+ return PFC_IPCRESP_FATAL;
}
+ return 0;
+ }
+
+ CtrlrMgr::Ctrlr ctrlr(reinterpret_cast<char*>(ctr_key.controller_name),
+ (unc_keytype_ctrtype_t)ctr_val.type,
+ reinterpret_cast<char*>(ctr_val.version));
+ urc = ctrlr_mgr->Add(ctrlr, (upll_keytype_datatype_t)datatype);
+ if (urc != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Controller add failed %s",
+ reinterpret_cast<char*>(ctr_key.controller_name));
}
} else if (operation == UNC_OP_DELETE) {
urc = ctrlr_mgr->Delete(reinterpret_cast<char *>(ctr_key.controller_name),
/* Set Physical module as a target. */
pfc::core::ipc::IpcEventMask phy_mask;
+ phy_mask.empty();
phy_mask.add(UPPL_ALARMS_PHYS_PATH_FAULT);
phy_mask.add(UPPL_EVENTS_KT_LOGICAL_PORT);
phy_mask.add(UPPL_EVENTS_KT_BOUNDARY);
/* Set PFC Driver module as a target. */
pfc::core::ipc::IpcEventMask pfc_mask;
+ pfc_mask.empty();
// Mask adjustment needed once PFC code is checkedin
pfc_mask.add(UNC_ALARMS);
}
if ((old_ctr_st.oper_status == UPPL_CONTROLLER_OPER_UP) &&
(new_ctr_st.oper_status != UPPL_CONTROLLER_OPER_UP)) {
- config_mgr_->OnControllerDown(
- reinterpret_cast<char *>(key_ctr.controller_name));
- }
+ config_mgr_->OnControllerStatusChange(
+ reinterpret_cast<char *>(key_ctr.controller_name),
+ UPPL_CONTROLLER_OPER_DOWN);
+ } else if ((old_ctr_st.oper_status != UPPL_CONTROLLER_OPER_UP) &&
+ (new_ctr_st.oper_status == UPPL_CONTROLLER_OPER_UP)) {
+ config_mgr_->OnControllerStatusChange(
+ reinterpret_cast<char *>(key_ctr.controller_name),
+ UPPL_CONTROLLER_OPER_UP);
+ }
}
}
return;
#include <sstream>
#include "cxx/pfcxx/synch.hh"
-#include "upll/upll_log.hh"
+#include "uncxx/upll_log.hh"
// #include "config_mgr.hh"
#include "ctrlr_mgr.hh"
it != ctrlrs_.end(); ++it) {
if ((*it)->name_.compare(pctrlr->name_) == 0 &&
(*it)->datatype_ == pctrlr->datatype_) {
- UPLL_LOG_ERROR("Ctrlr(%s) Already exists", pctrlr->name_.c_str());
+ UPLL_LOG_ERROR("Ctrlr(%s) Already exists in datatype(%d)",
+ pctrlr->name_.c_str(), datatype);
delete pctrlr;
return UPLL_RC_ERR_INSTANCE_EXISTS;
} else if ((*it)->name_.compare(pctrlr->name_) < 0) {
}
/* Deleting in the map */
bool deleted = false;
+ Ctrlr *ctrlr = NULL;
for (std::list<Ctrlr*>::iterator it = ctrlrs_.begin();
it != ctrlrs_.end(); ++it) {
if ((*it)->name_.compare(ctrlr_name) == 0 &&
(*it)->datatype_ == datatype) {
+ ctrlr = *it;
ctrlrs_.erase(it);
+ delete ctrlr;
deleted = true;
break;
}
const std::string in_name, const upll_keytype_datatype_t datatype,
std::string *next_name) {
pfc::core::ScopedMutex lock(ctrlr_mutex_);
+ UPLL_LOG_TRACE("Input Ctrlr (%s) next Ctrlr (%s) ",
+ in_name.c_str(), (*next_name).c_str());
upll_keytype_datatype_t mapped_dt;
mapped_dt = MapDataType(datatype);
if (next_name == NULL) {
}
for (std::list<Ctrlr*>::iterator it = ctrlrs_.begin();
it != ctrlrs_.end(); ++it) {
- if ((*it)->name_.compare(in_name) < 0) {
+ if ((*it)->datatype_ != mapped_dt)
continue;
- } else if ((*it)->datatype_ != mapped_dt) {
- continue;
- } else {
- UPLL_LOG_TRACE("Ctrlr (%s) is next to (%s) in datatype(%d)",
- (*it)->name_.c_str(), in_name.c_str(), datatype);
+ if ((*it)->name_.compare(in_name) > 0) {
+ UPLL_LOG_DEBUG("ctlr in list (%s) and input ctrlr (%s) are same",
+ (*it)->name_.c_str(), in_name.c_str());
*next_name = (*it)->name_;
+ UPLL_LOG_DEBUG("next_name Ctrlr (%s)", (*next_name).c_str());
return UPLL_RC_SUCCESS;
}
}
#include <string>
#include <list>
+#include "uncxx/upll_log.hh"
#include "upll/keytype_upll_ext.h"
#include "unc/upll_errno.h"
#include "dal/dal_odbc_mgr.hh"
CtrlrMgr() { }
virtual ~CtrlrMgr() {
+ CleanUp();
}
static CtrlrMgr *singleton_instance_;
upll_rc_t result_code = UPLL_RC_SUCCESS;
if (ikey->get_key_type() != UNC_KT_DHCPRELAY_IF)
result_code = UPLL_RC_ERR_CFG_SYNTAX;
+
+ #if 0
+ /* Check if vrouter admin status is disabled */
+ result_code = IsAdminStatusEnable(ikey, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ #endif
+
/* Check if vrt interface exists */
MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>
(GetMoManager(UNC_KT_VRT_IF)));
if (!mgr) {
- UPLL_LOG_DEBUG("Invalid param\n");
+ UPLL_LOG_DEBUG("Invalid param");
return UPLL_RC_ERR_GENERIC;
}
ConfigKeyVal *ckv_vrtif = NULL;
result_code = mgr->GetChildConfigKey(ckv_vrtif, ikey);
if (!ckv_vrtif || result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returing error %d \n",result_code);
+ UPLL_LOG_DEBUG("Returing error %d",result_code);
return UPLL_RC_ERR_GENERIC;
}
DbSubOp dbop = {kOpReadExist, kOpMatchNone, kOpInOutNone};
- result_code = mgr->UpdateConfigDB(ckv_vrtif, UPLL_DT_CANDIDATE,
+ result_code = mgr->UpdateConfigDB(ckv_vrtif, req->datatype,
UNC_OP_READ, dmi, &dbop, MAINTBL);
if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- string s(ckv_vrtif->ToStr());
- UPLL_LOG_DEBUG("Vrt interface does not exist %s\n",s.c_str());
+ UPLL_LOG_DEBUG("Vrt interface does not exist %s",(ckv_vrtif->ToStr()).c_str());
+ delete ckv_vrtif;
return UPLL_RC_ERR_CFG_SEMANTIC;
} else if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
+ delete ckv_vrtif;
return UPLL_RC_SUCCESS;
} else {
- UPLL_LOG_DEBUG(" Returning error %d\n",result_code);
+ UPLL_LOG_DEBUG(" Returning error %d",result_code);
}
+ delete ckv_vrtif;
return result_code;
}
ConfigKeyVal *ikey,
const char *ctrlr_name) {
UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- if (ikey->get_key_type() != UNC_KT_DHCPRELAY_IF) result_code =
- UPLL_RC_ERR_CFG_SYNTAX;
- return result_code;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+
+ if ((NULL == req) || (NULL == ikey)) {
+ UPLL_LOG_DEBUG("IpcReqRespHeader/ConfigKeyval is NULL");
+ return result_code;
+ }
+
+ if (!ctrlr_name) {
+ ctrlr_name = reinterpret_cast<char*>((reinterpret_cast<key_user_data_t *>
+ (ikey->get_user_data()))->ctrlr_id);
+ if (!ctrlr_name || !strlen(ctrlr_name)) {
+ UPLL_LOG_DEBUG("Controller Name is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+
+ upll_keytype_datatype_t dt_type = req->datatype;
+ unc_keytype_operation_t operation = req->operation;
+ unc_keytype_option1_t option1 = req->option1;
+ unc_keytype_option2_t option2 = req->option2;
+
+ UPLL_LOG_TRACE("Controller - %s"
+ "dt_type: (%d) "
+ "operation: (%d) "
+ "option1: (%d) "
+ "option2: (%d) ",
+ ctrlr_name, dt_type, operation, option1, option2);
+
+ bool ret_code = false;
+ uint32_t max_attrs = 0;
+ uint32_t max_instance_count = 0;
+ const uint8_t *attrs = NULL;
+ switch (operation) {
+ case UNC_OP_CREATE: {
+ ret_code = GetCreateCapability(ctrlr_name,
+ ikey->get_key_type(),
+ &max_instance_count,
+ &max_attrs,
+ &attrs);
+ if (ret_code && (max_instance_count != 0) &&
+ (cur_instance_count >= max_instance_count)) {
+ UPLL_LOG_DEBUG("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
+ __LINE__, __FUNCTION__, cur_instance_count,
+ max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
+ break;
+ }
+ case UNC_OP_UPDATE: {
+ ret_code = GetUpdateCapability(ctrlr_name,
+ ikey->get_key_type(),
+ &max_attrs,
+ &attrs);
+ break;
+ }
+ case UNC_OP_READ:
+ case UNC_OP_READ_SIBLING:
+ case UNC_OP_READ_SIBLING_BEGIN:
+ case UNC_OP_READ_SIBLING_COUNT: {
+ ret_code = GetReadCapability(ctrlr_name,
+ ikey->get_key_type(),
+ &max_attrs,
+ &attrs);
+ break;
+ }
+ default:
+ UPLL_LOG_DEBUG("Invalid Operation Code - (%d)", operation);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_DEBUG("ret_code (%d)", ret_code);
+ if (!ret_code) {
+ UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s) "
+ "for opearion(%d)",
+ ikey->get_key_type(), ctrlr_name, operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ return UPLL_RC_SUCCESS;
}
bool DhcpRelayIfMoMgr::IsValidKey(void *key, uint64_t index) {
+ UPLL_FUNC_TRACE;
key_dhcp_relay_if *dhcp_rs_key = reinterpret_cast<key_dhcp_relay_if *>(key);
- pfc_log_trace("Entering IsValidKey");
- bool ret_val = UPLL_RC_SUCCESS;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
switch (index) {
case uudst::dhcprelay_interface::kDbiVtnName:
ret_val = ValidateKey(reinterpret_cast<char *>
(dhcp_rs_key->vrt_key.vtn_key.vtn_name),
kMinLenVtnName, kMaxLenVtnName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_trace("VTN Name is not valid(%d)", ret_val);
+ UPLL_LOG_TRACE("VTN Name is not valid(%d)", ret_val);
return false;
}
break;
(dhcp_rs_key->vrt_key.vrouter_name),
kMinLenVnodeName, kMaxLenVnodeName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_trace("VRouter Name is not valid(%d)", ret_val);
+ UPLL_LOG_TRACE("VRouter Name is not valid(%d)", ret_val);
return false;
}
break;
ret_val = ValidateKey(reinterpret_cast<char *>(dhcp_rs_key->if_name),
kMinLenInterfaceName, kMaxLenInterfaceName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_trace("dhcprelayIf Name is not valid(%d)", ret_val);
+ UPLL_LOG_TRACE("dhcprelayIf Name is not valid(%d)", ret_val);
return false;
}
break;
default:
- pfc_log_trace("Invalid Key Index");
+ UPLL_LOG_TRACE("Invalid Key Index");
break;
}
- pfc_log_trace("Leaving IsValidKey");
return true;
}
void *pkey;
if (parent_key == NULL) {
dhcp_key = reinterpret_cast<key_dhcp_relay_if *>
- (malloc(sizeof(key_dhcp_relay_if)));
- if (!dhcp_key) return UPLL_RC_ERR_GENERIC;
- memset(dhcp_key, 0, sizeof(key_dhcp_relay_if));
+ (ConfigKeyVal::Malloc(sizeof(key_dhcp_relay_if)));
+ if (okey) delete okey;
okey = new ConfigKeyVal(UNC_KT_DHCPRELAY_IF, IpctSt::kIpcStKeyDhcpRelayIf,
dhcp_key, NULL);
return UPLL_RC_SUCCESS;
dhcp_key = reinterpret_cast<key_dhcp_relay_if *>(okey->get_key());
} else {
dhcp_key = reinterpret_cast<key_dhcp_relay_if *>
- (malloc(sizeof(key_dhcp_relay_if)));
- if (!dhcp_key) return UPLL_RC_ERR_GENERIC;
- memset(dhcp_key, 0, sizeof(key_dhcp_relay_if));
+ (ConfigKeyVal::Malloc(sizeof(key_dhcp_relay_if)));
}
unc_key_type_t keytype = parent_key->get_key_type();
switch (keytype) {
if (!okey)
okey = new ConfigKeyVal(UNC_KT_DHCPRELAY_IF, IpctSt::kIpcStKeyDhcpRelayIf,
dhcp_key, NULL);
+ else if (okey->get_key() != dhcp_key)
+ okey->SetKey(IpctSt::kIpcStKeyDhcpRelayIf, dhcp_key);
if (okey == NULL) {
free(dhcp_key);
result_code = UPLL_RC_ERR_GENERIC;
key_dhcp_relay_if *pkey = reinterpret_cast<key_dhcp_relay_if *>
(ikey->get_key());
if (!pkey) return UPLL_RC_ERR_GENERIC;
- key_vrt *vrt_key = reinterpret_cast<key_vrt *>(malloc(sizeof(key_vrt)));
- if (!vrt_key) return UPLL_RC_ERR_GENERIC;
- memset(vrt_key, 0, sizeof(key_vrt));
- uuu::upll_strncpy(vrt_key->vtn_key.vtn_name,
- reinterpret_cast<key_dhcp_relay_if*>(pkey)->vrt_key.vtn_key.vtn_name,
+ key_vrt *vrt_key = reinterpret_cast<key_vrt *>
+ (ConfigKeyVal::Malloc(sizeof(key_vrt)));
+ uuu::upll_strncpy(vrt_key->vtn_key.vtn_name,
+ reinterpret_cast<key_dhcp_relay_if*>(pkey)->vrt_key.vtn_key.vtn_name,
(kMaxLenVtnName + 1));
uuu::upll_strncpy(vrt_key->vrouter_name,
reinterpret_cast<key_dhcp_relay_if*>(pkey)->vrt_key.vrouter_name,
(kMaxLenVnodeName + 1));
+ if (okey) delete okey;
okey = new ConfigKeyVal(UNC_KT_VROUTER, IpctSt::kIpcStKeyVrt, vrt_key, NULL);
if (okey == NULL) {
free(vrt_key);
if (ck_val != NULL) return UPLL_RC_ERR_GENERIC;
switch (tbl) {
case MAINTBL:
- val = malloc(sizeof(val_dhcp_relay_if));
- if (!val) return UPLL_RC_ERR_GENERIC;
- memset(val, 0, sizeof(val_dhcp_relay_if));
+ val = ConfigKeyVal::Malloc(sizeof(val_dhcp_relay_if));
ck_val = new ConfigVal(IpctSt::kIpcStValDhcpRelayIf, val);
break;
default:
val_dhcp_relay_if *ival =
reinterpret_cast<val_dhcp_relay_if *>(GetVal(req));
val_dhcp_relay_if *dhcp_val =
- reinterpret_cast<val_dhcp_relay_if *>(malloc(
+ reinterpret_cast<val_dhcp_relay_if *>(ConfigKeyVal::Malloc(
sizeof(val_dhcp_relay_if)));
- if (!dhcp_val) return UPLL_RC_ERR_GENERIC;
memcpy(dhcp_val, ival, sizeof(val_dhcp_relay_if));
tmp1 = new ConfigVal(IpctSt::kIpcStValDhcpRelayIf, dhcp_val);
}
};
- void *tkey = (req != NULL) ? (req)->get_key() : NULL;
+ void *tkey = (req)->get_key();
key_dhcp_relay_if *ikey = reinterpret_cast<key_dhcp_relay_if *>(tkey);
- key_dhcp_relay_if *dhcp_key = reinterpret_cast<key_dhcp_relay_if *>(malloc(
- sizeof(key_dhcp_relay_if)));
- if (!dhcp_key) return UPLL_RC_ERR_GENERIC;
+ key_dhcp_relay_if *dhcp_key = reinterpret_cast<key_dhcp_relay_if *>(
+ ConfigKeyVal::Malloc(sizeof(key_dhcp_relay_if)));
memcpy(dhcp_key, ikey, sizeof(key_dhcp_relay_if));
okey = new ConfigKeyVal(UNC_KT_DHCPRELAY_IF, IpctSt::kIpcStKeyDhcpRelayIf,
dhcp_key, tmp1);
- if (okey) SET_USER_DATA(okey, req);
+ if (!okey) {
+ DELETE_IF_NOT_NULL(tmp1);
+ FREE_IF_NOT_NULL(dhcp_key);
+ return UPLL_RC_ERR_GENERIC;
+ } else {
+ SET_USER_DATA(okey, req);
+ }
return UPLL_RC_SUCCESS;
}
reinterpret_cast<val_dhcp_relay_if *>(GetVal(ikey));
unc_keytype_configstatus_t cs_status =
- (driver_result == 0) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
+ (driver_result == UPLL_RC_SUCCESS) ? UNC_CS_APPLIED
+ : UNC_CS_NOT_APPLIED;
if (dhcp_val == NULL) return UPLL_RC_ERR_GENERIC;
if (op == UNC_OP_CREATE) {
dhcp_val->cs_row_status = cs_status;
- } else {
- return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_TRACE("%s",(ikey->ToStrAll()).c_str());
+ val_dhcp_relay_if *dhcp_val2 =
+ reinterpret_cast<val_dhcp_relay_if *>(GetVal(upd_key));
+ if (dhcp_val2 == NULL) return UPLL_RC_ERR_GENERIC;
+ if (UNC_OP_UPDATE == op) {
+ UPLL_LOG_TRACE("%s",(upd_key->ToStrAll()).c_str());
+ dhcp_val->cs_row_status = dhcp_val2->cs_row_status;
}
return UPLL_RC_SUCCESS;
}
reinterpret_cast<val_dhcp_relay_if_t *>(GetVal(ckv_running)) : NULL;
if (NULL == val) return UPLL_RC_ERR_GENERIC;
if (uuc::kUpllUcpCreate == phase) val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
return result_code;
}
}
uuu::upll_strncpy(key_dhcp->vrt_key.vrouter_name,
key_rename->old_unc_vnode_name, (kMaxLenVnodeName + 1));
+ } else {
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_unc_vnode_name))) {
+ FREE_IF_NOT_NULL(key_dhcp);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(key_dhcp->vrt_key.vrouter_name,
+ key_rename->new_unc_vnode_name, (kMaxLenVnodeName+1));
}
+
okey = new ConfigKeyVal(UNC_KT_DHCPRELAY_IF, IpctSt::kIpcStKeyDhcpRelayIf,
key_dhcp, NULL);
if (!okey) {
(dhcprelayif_key->vrt_key.vtn_key.vtn_name),
kMinLenVtnName, kMaxLenVtnName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("syntax check failed. VTN Name - %s",
+ UPLL_LOG_DEBUG("syntax check failed. VTN Name - %s",
dhcprelayif_key->vrt_key.vtn_key.vtn_name);
return UPLL_RC_ERR_CFG_SYNTAX;
}
(dhcprelayif_key->vrt_key.vrouter_name),
kMinLenVnodeName, kMaxLenVnodeName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("syntax check failed. VROUTER Name - %s",
+ UPLL_LOG_DEBUG("syntax check failed. VROUTER Name - %s",
dhcprelayif_key->vrt_key.vrouter_name);
return UPLL_RC_ERR_CFG_SYNTAX;
}
(dhcprelayif_key->if_name), kMinLenInterfaceName,
kMaxLenInterfaceName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("syntax check failed. If name - %s",
+ UPLL_LOG_DEBUG("syntax check failed. If name - %s",
dhcprelayif_key->if_name);
return UPLL_RC_ERR_CFG_SYNTAX;
}
return UPLL_RC_SUCCESS;
}
+upll_rc_t DhcpRelayIfMoMgr::IsAdminStatusEnable(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ MoMgrImpl *vrt_mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>
+ (GetMoManager(UNC_KT_VROUTER)));
+ if (!vrt_mgr) {
+ UPLL_LOG_DEBUG("Invalid param");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigKeyVal *ckv_vrt = NULL;
+ result_code = GetParentConfigKey(ckv_vrt, ikey);
+ if (!ckv_vrt || result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returing error %d",result_code);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutNone};
+ result_code = vrt_mgr->ReadConfigDB(ckv_vrt, UPLL_DT_CANDIDATE, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (result_code == UPLL_RC_SUCCESS) {
+ val_vrt_t *vrt_val = reinterpret_cast<val_vrt_t *>(GetVal(ckv_vrt));
+ if (vrt_val && vrt_val->dhcp_relay_admin_status == UPLL_ADMIN_ENABLE) {
+ UPLL_LOG_DEBUG("DHCP relay agent must be disabled!");
+ DELETE_IF_NOT_NULL(ckv_vrt);
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ }
+ DELETE_IF_NOT_NULL(ckv_vrt);
+ return result_code;
+}
+
} // namespace kt_momgr
} // namespace upll
} // namespace unc
upll_rc_t CopyToConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *ikey);
upll_rc_t IsReferenced(ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi);
-
+ upll_rc_t IsAdminStatusEnable(ConfigKeyVal *ikey,DalDmlIntf *dmi);
+
public:
DhcpRelayIfMoMgr();
virtual ~DhcpRelayIfMoMgr() {
upll_rc_t result_code = UPLL_RC_SUCCESS;
if (ikey->get_key_type() != UNC_KT_DHCPRELAY_SERVER) result_code =
UPLL_RC_ERR_CFG_SYNTAX;
- return result_code;
-}
-upll_rc_t DhcpRelayServerMoMgr::ValidateCapability(IpcReqRespHeader *req,
- ConfigKeyVal *ikey, const
- char *ctrlr_name) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- if (ikey->get_key_type() != UNC_KT_DHCPRELAY_SERVER) result_code =
- UPLL_RC_ERR_CFG_SYNTAX;
+ #if 0
+ /* Check if vrouter admin status is disabled */
+ result_code = IsAdminStatusEnable(ikey, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ #endif
return result_code;
}
+
bool DhcpRelayServerMoMgr::IsValidKey(void *key, uint64_t index) {
+ UPLL_FUNC_TRACE;
key_dhcp_relay_server *dhcp_rs_key =
reinterpret_cast<key_dhcp_relay_server *>(key);
- pfc_log_trace("Entering IsValidKey");
uint32_t val = 0;
- bool ret_val = UPLL_RC_SUCCESS;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
switch (index) {
case uudst::dhcprelay_server::kDbiVtnName:
ret_val = ValidateKey(reinterpret_cast<char *>
(dhcp_rs_key->vrt_key.vtn_key.vtn_name),
kMinLenVtnName, kMaxLenVtnName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_trace("VTN Name is not valid(%d)", ret_val);
+ UPLL_LOG_TRACE("VTN Name is not valid(%d)", ret_val);
return false;
}
break;
(dhcp_rs_key->vrt_key.vrouter_name),
kMinLenVnodeName, kMaxLenVnodeName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_trace("VRouter Name is not valid(%d)", ret_val);
+ UPLL_LOG_TRACE("VRouter Name is not valid(%d)", ret_val);
return false;
}
break;
case uudst::dhcprelay_server::kDbiServerIpAddr:
val = dhcp_rs_key->server_addr.s_addr;
if (val == 0xffffffff || val == 0x00000000) {
- pfc_log_trace("Invalid Server Address /n");
+ UPLL_LOG_TRACE("Invalid Server Address /n");
return false;
}
break;
default:
- pfc_log_trace("Invalid Key Index");
+ UPLL_LOG_TRACE("Invalid Key Index");
break;
}
- pfc_log_trace("Leaving IsValidKey");
return true;
}
void *pkey;
if (parent_key == NULL) {
dhcp_key = reinterpret_cast<key_dhcp_relay_server *>
- (malloc(sizeof(key_dhcp_relay_server)));
- if (!dhcp_key) return UPLL_RC_ERR_GENERIC;
- memset(dhcp_key, 0, sizeof(key_dhcp_relay_server));
+ (ConfigKeyVal::Malloc(sizeof(key_dhcp_relay_server)));
+ if (okey) delete okey;
okey = new ConfigKeyVal(UNC_KT_DHCPRELAY_SERVER,
IpctSt::kIpcStKeyDhcpRelayServer, dhcp_key, NULL);
return UPLL_RC_SUCCESS;
if (!okey)
okey = new ConfigKeyVal(UNC_KT_DHCPRELAY_SERVER,
IpctSt::kIpcStKeyDhcpRelayServer, dhcp_key, NULL);
+ else if (okey->get_key() != dhcp_key)
+ okey->SetKey(IpctSt::kIpcStKeyDhcpRelayServer, dhcp_key);
if (okey == NULL) {
free(dhcp_key);
result_code = UPLL_RC_ERR_GENERIC;
uuu::upll_strncpy(vrt_key->vrouter_name,
reinterpret_cast<key_dhcp_relay_server *>(pkey)->vrt_key.vrouter_name,
(kMaxLenVnodeName + 1));
+ if (okey) delete okey;
okey = new ConfigKeyVal(UNC_KT_VROUTER, IpctSt::kIpcStKeyVrt, vrt_key, NULL);
if (okey == NULL) {
free(vrt_key);
val_dhcp_relay_server *ival =
reinterpret_cast<val_dhcp_relay_server *>(GetVal(req));
if (!ival) {
- UPLL_LOG_DEBUG("Invalid dhcp_relay_server value\n");
+ UPLL_LOG_DEBUG("Invalid dhcp_relay_server value");
return UPLL_RC_ERR_GENERIC;
}
val_dhcp_relay_server *dhcp_val =
memcpy(dhcp_key, ikey, sizeof(key_dhcp_relay_server));
okey = new ConfigKeyVal(UNC_KT_DHCPRELAY_SERVER,
IpctSt::kIpcStKeyDhcpRelayServer, dhcp_key, tmp1);
- if (okey) SET_USER_DATA(okey, req);
+ if (!okey) {
+ DELETE_IF_NOT_NULL(tmp1);
+ FREE_IF_NOT_NULL(dhcp_key);
+ return UPLL_RC_ERR_GENERIC;
+ } else {
+ SET_USER_DATA(okey, req);
+ }
return UPLL_RC_SUCCESS;
}
reinterpret_cast<val_dhcp_relay_server *>(GetVal(ikey));
unc_keytype_configstatus_t cs_status =
- (driver_result == 0) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
+ (driver_result == UPLL_RC_SUCCESS) ? UNC_CS_APPLIED
+ : UNC_CS_NOT_APPLIED;
if (dhcp_val == NULL) return UPLL_RC_ERR_GENERIC;
if (op == UNC_OP_CREATE) {
dhcp_val->cs_row_status = cs_status;
- } else {
- return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_TRACE("%s",(ikey->ToStrAll()).c_str());
+ val_dhcp_relay_server *dhcp_val2 =
+ reinterpret_cast<val_dhcp_relay_server *>(GetVal(upd_key));
+ if (dhcp_val2 == NULL) return UPLL_RC_ERR_GENERIC;
+ if (UNC_OP_UPDATE == op) {
+ UPLL_LOG_TRACE("%s",(upd_key->ToStrAll()).c_str());
+ dhcp_val->cs_row_status = dhcp_val2->cs_row_status;
}
return UPLL_RC_SUCCESS;
}
return UPLL_RC_ERR_GENERIC;
}
if (uuc::kUpllUcpCreate == phase) val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
return result_code;
}
+upll_rc_t DhcpRelayServerMoMgr::GetVrtDhcpRelayServerAddress(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code;
+ ConfigKeyVal *ck_dhcp = NULL;
+ result_code = GetChildConfigKey(ck_dhcp, ikey);
+ if (!ck_dhcp || result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey is failed- %d", result_code);
+ return result_code;
+ }
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
+ result_code = ReadConfigDB(ck_dhcp, UPLL_DT_RUNNING, UNC_OP_READ, dbop,
+ dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to ReadConfigDb- %d", result_code);
+ DELETE_IF_NOT_NULL (ck_dhcp);
+ return result_code;
+ }
+ val_vrt_dhcp_relay_st *val_vrt_dhcp = reinterpret_cast<val_vrt_dhcp_relay_st *>
+ (ConfigKeyVal::Malloc(sizeof(val_vrt_dhcp_relay_st)));
+ val_vrt_dhcp->valid[UPLL_IDX_DHCP_RELAY_ADMIN_STATUS_VDRS] = UNC_VF_INVALID;
+ val_vrt_dhcp->valid[UPLL_IDX_IP_COUNT_VDRS] = UNC_VF_VALID;
+ val_vrt_dhcp->valid[UPLL_IDX_IF_COUNT_VDRS] = UNC_VF_INVALID;
+ ConfigKeyVal *tmp= ck_dhcp;
+ while(tmp != NULL) {
+ val_vrt_dhcp->ip_count++;
+ tmp = tmp->get_next_cfg_key_val();
+ }
+ ikey->SetCfgVal(new ConfigVal(IpctSt::kIpcStValVrtDhcpRelaySt, val_vrt_dhcp));
+ uint32_t ipcount = 0;
+ ConfigKeyVal *tkey = ck_dhcp;
+ while (tkey && ipcount < val_vrt_dhcp->ip_count) {
+ key_dhcp_relay_server *dhcp_key =
+ reinterpret_cast<key_dhcp_relay_server_t *>(tkey->get_key());
+ uint32_t *ip_addr =
+ reinterpret_cast<uint32_t *>(ConfigKeyVal::Malloc(sizeof(uint32_t)));
+ *ip_addr = dhcp_key->server_addr.s_addr; // assign ipaddress
+ ikey->AppendCfgVal( IpctSt::kIpcStIpv4, ip_addr);
+ ipcount++;
+ tkey = tkey->get_next_cfg_key_val();
+ }
+ if (ck_dhcp)
+ delete ck_dhcp;
+ return UPLL_RC_SUCCESS;
+}
+
upll_rc_t DhcpRelayServerMoMgr::CopyToConfigKey(ConfigKeyVal *&okey,
ConfigKeyVal *ikey) {
if (!ikey || !(ikey->get_key())) return UPLL_RC_ERR_GENERIC;
uuu::upll_strncpy(key_dhcp->vrt_key.vrouter_name,
key_rename->old_unc_vnode_name,
(kMaxLenVnodeName + 1));
+ } else {
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_unc_vnode_name))) {
+ FREE_IF_NOT_NULL(key_dhcp);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(key_dhcp->vrt_key.vrouter_name,
+ key_rename->new_unc_vnode_name, (kMaxLenVnodeName+1));
}
+
okey = new ConfigKeyVal(UNC_KT_DHCPRELAY_SERVER,
IpctSt::kIpcStKeyDhcpRelayServer, key_dhcp, NULL);
if (!okey) {
return UPLL_RC_SUCCESS;
}
+upll_rc_t DhcpRelayServerMoMgr::ValidateCapability(IpcReqRespHeader *req,
+ ConfigKeyVal *ikey, const
+ char *ctrlr_name) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+
+ if ((NULL == req) || (NULL == ikey)) {
+ UPLL_LOG_DEBUG("IpcReqRespHeader/ConfigKeyval is NULL");
+ return result_code;
+ }
+
+ if (!ctrlr_name) {
+ ctrlr_name = reinterpret_cast<char*>((reinterpret_cast<key_user_data_t *>
+ (ikey->get_user_data()))->ctrlr_id);
+ if (!ctrlr_name || !strlen(ctrlr_name)) {
+ UPLL_LOG_DEBUG("Controller Name is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+
+ upll_keytype_datatype_t dt_type = req->datatype;
+ unc_keytype_operation_t operation = req->operation;
+ unc_keytype_option1_t option1 = req->option1;
+ unc_keytype_option2_t option2 = req->option2;
+
+ UPLL_LOG_TRACE("Controller - %s"
+ "dt_type: (%d) "
+ "operation: (%d) "
+ "option1: (%d) "
+ "option2: (%d) ",
+ ctrlr_name, dt_type, operation, option1, option2);
+
+ bool ret_code = false;
+ uint32_t max_attrs = 0;
+ uint32_t max_instance_count = 0;
+ const uint8_t *attrs = NULL;
+ switch (operation) {
+ case UNC_OP_CREATE: {
+ ret_code = GetCreateCapability(ctrlr_name,
+ ikey->get_key_type(),
+ &max_instance_count,
+ &max_attrs,
+ &attrs);
+ if (ret_code && (max_instance_count != 0) &&
+ (cur_instance_count >= max_instance_count)) {
+ UPLL_LOG_DEBUG("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
+ __LINE__, __FUNCTION__, cur_instance_count,
+ max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
+ break;
+ }
+ case UNC_OP_UPDATE: {
+ ret_code = GetUpdateCapability(ctrlr_name,
+ ikey->get_key_type(),
+ &max_attrs,
+ &attrs);
+ break;
+ }
+ case UNC_OP_READ:
+ case UNC_OP_READ_SIBLING:
+ case UNC_OP_READ_SIBLING_BEGIN:
+ case UNC_OP_READ_SIBLING_COUNT: {
+ ret_code = GetReadCapability(ctrlr_name,
+ ikey->get_key_type(),
+ &max_attrs,
+ &attrs);
+ break;
+ }
+ default:
+ UPLL_LOG_DEBUG("Invalid Operation Code - (%d)", operation);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_DEBUG("ret_code (%d)", ret_code);
+ if (!ret_code) {
+ UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s) "
+ "for opearion(%d)",
+ ikey->get_key_type(), ctrlr_name, operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
upll_rc_t DhcpRelayServerMoMgr::IsReferenced(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi) {
return UPLL_RC_SUCCESS;
}
+upll_rc_t DhcpRelayServerMoMgr::IsAdminStatusEnable(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ MoMgrImpl *vrt_mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>
+ (GetMoManager(UNC_KT_VROUTER)));
+ if (!vrt_mgr) {
+ UPLL_LOG_DEBUG("Invalid param");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigKeyVal *ckv_vrt = NULL;
+ result_code = GetParentConfigKey(ckv_vrt, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returing error %d \n",result_code);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutNone};
+ result_code = vrt_mgr->ReadConfigDB(ckv_vrt, UPLL_DT_CANDIDATE, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (result_code == UPLL_RC_SUCCESS) {
+ val_vrt_t *vrt_val = reinterpret_cast<val_vrt_t *>(GetVal(ckv_vrt));
+ if (vrt_val && vrt_val->dhcp_relay_admin_status == UPLL_ADMIN_ENABLE) {
+ UPLL_LOG_DEBUG("DHCP relay agent must be disabled!");
+ delete ckv_vrt;
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ }
+ DELETE_IF_NOT_NULL(ckv_vrt);
+ return result_code;
+}
+
} // namespaces kt_momgr
} // namespace upll
} // namespace unc
return true;
}
+ /**
+ * @Brief Checks if the specified key type(KT_DHCPRELAY_SERVER) and
+ * associated attributes are supported on the given controller,
+ * based on the valid flag
+ *
+ * @param[in] req This structure contains IpcReqRespHeader
+ * (first 8 fields of input request structure).
+ * @param[in] ikey ikey contains key and value structure.
+ * @param[in] ctrlr_name Controller name associated with ikey.
+ *
+ * @retval UPLL_RC_SUCCESS Validation succeeded.
+ * @retval UPLL_RC_ERR_GENERIC Validation failure.
+ * @retval UPLL_RC_ERR_INVALID_OPTION1 Option1 is not valid.
+ * @retval UPLL_RC_ERR_INVALID_OPTION2 Option2 is not valid.
+ **/
upll_rc_t ValidateCapability(IpcReqRespHeader *req, ConfigKeyVal *ikey,
const char *ctrlr_name);
upll_rc_t CopyToConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *ikey);
upll_rc_t IsReferenced(ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi);
+ upll_rc_t IsAdminStatusEnable(ConfigKeyVal *ikey,DalDmlIntf *dmi);
public:
DhcpRelayServerMoMgr();
* @retval false input key is invalid.
**/
bool IsValidKey(void *tkey, uint64_t index);
+
+ upll_rc_t GetVrtDhcpRelayServerAddress(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi);
};
} // namespace kt_momgr
#include "policingprofile_entry_momgr.hh"
#include "ctrlr_capa_defines.hh"
#include "upll_validation.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "dal/dal_odbc_mgr.hh"
-#define NUM_FL_KEY_MAIN_COL 4
-#define NUM_FL_KEY_CTRLR_COL 5
+#define NUM_FL_KEY_MAIN_COL 3
+#define NUM_FL_KEY_CTRLR_COL 3
#define RENAME_FLOWLIST 0x01
#define GET_VALID_MAINCTRL(tbl, l_val_ctrl_ff, l_val_ff, en) \
(tbl == MAINTBL) ? &(l_val_ff->valid[en]) : &(l_val_ctrl_ff->valid[en])
-
+using unc::upll::ipc_util::IpcUtil;
namespace unc {
namespace upll {
namespace kt_momgr {
uud::kDalChar, (kMaxLenCtrlrId + 1)},
{ uudst::flowlist_entry_ctrlr::kDbiFlags,
CK_VAL,
- offsetof(val_flowlist_entry_ctrl_t, flags),
+ offsetof(key_user_data_t, flags),
uud::kDalUint8, 1 },
{ uudst::flowlist_entry_ctrlr::kDbiValidMacDst,
CFG_META_VAL,
CFG_MATCH_KEY,
offsetof(key_flowlist_entry_t, flowlist_key.flowlist_name),
uud::kDalChar, kMaxLenFlowListName+1 },
- {uudst::flowlist_entry::kDbiSequenceNum,
- CFG_MATCH_KEY,
- offsetof(key_flowlist_entry_t, sequence_num),
- uud::kDalUint16, 1},
{uudst::flowlist_entry::kDbiFlowListName,
CFG_INPUT_KEY,
offsetof(key_rename_vnode_info_t, new_flowlist_name),
uud::kDalChar, kMaxLenFlowListName+1},
{ uudst::flowlist_entry::kDbiFlags,
- CFG_INPUT_KEY,
+ CK_VAL,
offsetof(key_user_data_t, flags),
uud::kDalUint8, 1 }
};
CFG_MATCH_KEY,
offsetof(key_flowlist_entry_t, flowlist_key.flowlist_name),
uud::kDalChar, (kMaxLenFlowListName + 1) },
- {uudst::flowlist_entry_ctrlr::kDbiSequenceNum,
- CFG_MATCH_KEY,
- offsetof(key_flowlist_entry_t, sequence_num),
- uud::kDalUint16, 1},
- {uudst::flowlist_entry_ctrlr::kDbiCtrlrName,
- CFG_MATCH_KEY,
- offsetof(key_user_data_t, ctrlr_id),
- uud::kDalChar, (kMaxLenCtrlrId + 1) },
{uudst::flowlist_entry_ctrlr::kDbiFlowListName,
CFG_INPUT_KEY,
offsetof(key_rename_vnode_info_t, new_flowlist_name),
uud::kDalChar, kMaxLenFlowListName+1},
{ uudst::flowlist_entry_ctrlr::kDbiFlags,
- CFG_INPUT_KEY,
+ CK_VAL,
offsetof(key_user_data_t, flags),
uud::kDalUint8, 1}
};
bool FlowListEntryMoMgr::GetRenameKeyBindInfo(unc_key_type_t key_type,
BindInfo *&binfo, int &nattr, MoMgrTables tbl) {
- switch (key_type) {
- case UNC_KT_FLOWLIST_ENTRY:
- if (MAINTBL == tbl) {
- nattr = NUM_FL_KEY_MAIN_COL;
- binfo = rename_flowlist_entry_main_tbl;
- } else if (CTRLRTBL == tbl) {
- nattr = NUM_FL_KEY_CTRLR_COL;
- binfo = rename_flowlist_entry_ctrlr_tbl;
- }
- default:
- break;
+ if (MAINTBL == tbl) {
+ nattr = NUM_FL_KEY_MAIN_COL;
+ binfo = rename_flowlist_entry_main_tbl;
+ } else if (CTRLRTBL == tbl) {
+ nattr = NUM_FL_KEY_CTRLR_COL;
+ binfo = rename_flowlist_entry_ctrlr_tbl;
}
return PFC_TRUE;
}
nchild = 0;
child = NULL;
+ cur_instance_count = 0;
}
break;
default :
valid = NULL;
- break;
+ return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_DEBUG("GetValidAttributte is Succesfull");
return UPLL_RC_SUCCESS;
return UPLL_RC_ERR_GENERIC;
}
if (okey) {
- if (okey->get_key_type() != UNC_KT_FLOWLIST_ENTRY) {
+ if (okey->get_key_type() != UNC_KT_FLOWLIST_ENTRY)
return UPLL_RC_ERR_GENERIC;
- }
+ }
+ if ((okey) && (okey->get_key())) {
key_fle = reinterpret_cast<key_flowlist_entry_t *>(okey->get_key());
} else {
key_fle = reinterpret_cast<key_flowlist_entry_t *>
break;
}
+ if ((okey) && !(okey->get_key())) {
+ UPLL_LOG_DEBUG("okey not null and flow list name updated");
+ okey->SetKey(IpctSt::kIpcStKeyFlowlistEntry, key_fle);
+ }
+
if (!okey)
okey = new ConfigKeyVal(UNC_KT_FLOWLIST_ENTRY,
IpctSt::kIpcStKeyFlowlistEntry,
UPLL_FUNC_TRACE;
upll_rc_t result_code;
ConfigKeyVal *unc_key = NULL;
+ UPLL_LOG_TRACE("%s GetRenamedUncKey fl_entry start",
+ ctrlr_key->ToStrAll().c_str());
key_flowlist_entry_t *ctrlr_flowlist_entry_key =
reinterpret_cast<key_flowlist_entry_t *> (ctrlr_key->get_key());
- DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
-
- if (NULL == ctrlr_flowlist_entry_key)
+ if (NULL == ctrlr_flowlist_entry_key) {
+ UPLL_LOG_DEBUG("ctrlr_flowlist_entry_key NULL");
return UPLL_RC_ERR_GENERIC;
+ }
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
val_rename_flowlist_t *rename_flowlist =
reinterpret_cast<val_rename_flowlist_t *>
(ConfigKeyVal::Malloc(sizeof(val_rename_flowlist_t)));
+ if (!rename_flowlist) {
+ UPLL_LOG_TRACE("rename_flowlist NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(rename_flowlist->flowlist_newname,
ctrlr_flowlist_entry_key->flowlist_key.flowlist_name,
(kMaxLenFlowListName+1));
FlowListMoMgr *mgr =
reinterpret_cast<FlowListMoMgr *>(const_cast<MoManager *>(GetMoManager(
UNC_KT_FLOWLIST)));
-
+ if (!mgr) {
+ UPLL_LOG_TRACE("mgr failed");
+ if (rename_flowlist) free(rename_flowlist);
+ return UPLL_RC_ERR_GENERIC;
+ }
result_code = mgr->GetChildConfigKey(unc_key, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
+ if (rename_flowlist) free(rename_flowlist);
+ mgr = NULL;
+ return result_code;
+ }
+ if (!unc_key) {
+ UPLL_LOG_DEBUG("unc_key NULL");
+ if (rename_flowlist) free(rename_flowlist);
+ mgr = NULL;
+ return result_code;
+ }
unc_key->AppendCfgVal(IpctSt::kIpcStValRenameFlowlist,
rename_flowlist);
+ UPLL_LOG_DEBUG("ctrlr_id fle (%s)", ctrlr_id);
SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
result_code = mgr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL);
-
if (result_code == UPLL_RC_SUCCESS) {
key_flowlist_entry_t *flowlist_entry =
reinterpret_cast<key_flowlist_entry_t *> (unc_key->get_key());
flowlist_entry->flowlist_key.flowlist_name,
(kMaxLenFlowListName+1));
}
- delete unc_key;
+ UPLL_LOG_TRACE("%s GetRenamedUncKey fl_entry end",
+ ctrlr_key->ToStrAll().c_str());
+ DELETE_IF_NOT_NULL(unc_key);
+ mgr = NULL;
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)
+ result_code = UPLL_RC_SUCCESS;
return result_code;
}
return UPLL_RC_ERR_GENERIC;
}
+#if 0
upll_rc_t FlowListEntryMoMgr::UpdateConfigStatus(ConfigKeyVal *key,
unc_keytype_operation_t op, uint32_t driver_result, ConfigKeyVal *nreq,
DalDmlIntf *dmi, ConfigKeyVal *ctrlr_key) {
case UNC_CS_UNKNOWN:
status = cs_status;
break;
- case UNC_CS_PARTAILLY_APPLIED:
+ case UNC_CS_PARTIALLY_APPLIED:
if (ctrlr_val_flowlist->cs_row_status == UNC_CS_NOT_APPLIED) {
/* changes need to do */
}
case UNC_CS_INVALID:
default:
status =
- (cs_status == UNC_CS_APPLIED) ? UNC_CS_PARTAILLY_APPLIED : status;
+ (cs_status == UNC_CS_APPLIED) ? UNC_CS_PARTIALLY_APPLIED : status;
break;
}
flowlist_val->cs_row_status = status;
+ ctrlr_val_flowlist->cs_row_status = cs_status;
for ( unsigned int loop = 0;
loop < sizeof(flowlist_val->valid)/sizeof(flowlist_val->valid[0]);
++loop ) {
// Setting CS to the not supported attributes
- if ( UNC_VF_NOT_SOPPORTED == flowlist_val->valid[loop] ) {
+ if ( UNC_VF_NOT_SUPPORTED == flowlist_val->valid[loop] ) {
flowlist_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
continue;
}
- if ( UNC_VF_NOT_SOPPORTED == ctrlr_val_flowlist->valid[loop] ) {
+ if ( UNC_VF_NOT_SUPPORTED == ctrlr_val_flowlist->valid[loop] ) {
ctrlr_val_flowlist->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
continue;
}
if ((UNC_VF_VALID == flowlist_val->valid[loop]) ||
(UNC_VF_VALID_NO_VALUE == flowlist_val->valid[loop]))
- if (ctrlr_val_flowlist->valid[loop] != UNC_VF_NOT_SOPPORTED) {
+ if (ctrlr_val_flowlist->valid[loop] != UNC_VF_NOT_SUPPORTED) {
ctrlr_val_flowlist->cs_attr[loop] = cs_status;
flowlist_val->cs_attr[loop] = (uint8_t)flowlist_val->cs_row_status;
}
void *flowlist_val1 = GetVal(key);
void *flowlist_val2 = GetVal(nreq);
- CompareValidValue(flowlist_val1, flowlist_val2, false);
+ CompareValidValue(flowlist_val1, flowlist_val2, true);
for (unsigned int loop = 0;
loop < sizeof(flowlist_val->valid) / sizeof(flowlist_val->valid[0]);
++loop) {
- if (ctrlr_val_flowlist->valid[loop] != UNC_VF_NOT_SOPPORTED) {
+ if (ctrlr_val_flowlist->valid[loop] != UNC_VF_NOT_SUPPORTED) {
ctrlr_val_flowlist->cs_attr[loop] = cs_status;
} else {
ctrlr_val_flowlist->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
flowlist_val->cs_attr[loop] = (uint8_t)flowlist_val->cs_row_status;
}
}
+ bool flag_applied = false;
+ bool flag_not_applied = false;
+ for (unsigned int loop = 0;
+ loop < sizeof(ctrlr_val_flowlist->valid) / sizeof(ctrlr_val_flowlist->valid[0]);
+ ++loop) {
+ if (ctrlr_val_flowlist->cs_attr[loop] == UNC_CS_APPLIED)
+ flag_applied = true;
+ else if (ctrlr_val_flowlist->cs_attr[loop] == UNC_CS_NOT_APPLIED)
+ flag_not_applied = true;
+ }
+ if ((true == flag_applied) && (true == flag_not_applied)) {
+ UPLL_LOG_DEBUG("cs_row_status set to UNC_CS_PARTIALLY_APPLIED");
+ ctrlr_val_flowlist->cs_row_status = UNC_CS_PARTIALLY_APPLIED;
+ } else if ((true == flag_applied) && (false == flag_not_applied)) {
+ UPLL_LOG_DEBUG("cs_row_status set to UNC_CS_APPLIED");
+ ctrlr_val_flowlist->cs_row_status = UNC_CS_APPLIED;
+ } else if ((false == flag_applied) && (true == flag_not_applied)) {
+ UPLL_LOG_DEBUG("cs_row_status set to UNC_CS_NOT_APPLIED");
+ ctrlr_val_flowlist->cs_row_status = UNC_CS_NOT_APPLIED;
+ } else {
+ UPLL_LOG_DEBUG("cs_row_status set to UNC_CS_UNKNOWN");
+ ctrlr_val_flowlist->cs_row_status = UNC_CS_UNKNOWN;
+ }
return result_code;
}
+#endif
bool FlowListEntryMoMgr::CompareKey(ConfigKeyVal *key1,
ConfigKeyVal *key2) {
return match;
}
+bool FlowListEntryMoMgr::FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op) {
+ UPLL_FUNC_TRACE;
+ if (op != UNC_OP_CREATE)
+ return CompareValidValue(val1, val2, copy_to_running);
+ return false;
+}
+
bool FlowListEntryMoMgr::CompareValidValue(void *&val1, void *val2,
- bool audit) {
+ bool copy_to_running) {
UPLL_FUNC_TRACE;
+ bool invalid_attr = true;
val_flowlist_entry_t *flowlist_entry_val1 =
reinterpret_cast<val_flowlist_entry_t *>(val1);
if (!flowlist_entry_val1 || !flowlist_entry_val2) {
return false;
}
-// if (audit) {
- for ( unsigned int loop = 0; loop < (sizeof(flowlist_entry_val1->valid)
+ for ( unsigned int loop = 0; loop < (sizeof(flowlist_entry_val1->valid)
/(sizeof(flowlist_entry_val1->valid[0])));
++loop ) {
if (UNC_VF_INVALID == flowlist_entry_val1->valid[loop] &&
UNC_VF_VALID == flowlist_entry_val2->valid[loop])
flowlist_entry_val1->valid[loop] = UNC_VF_VALID_NO_VALUE;
- }
-// }
+ }
if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_MAC_DST_FLE] &&
UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_MAC_DST_FLE])
if (!memcmp(flowlist_entry_val1->mac_dst, flowlist_entry_val2->mac_dst,
if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_L4_DST_PORT_FLE] &&
UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_L4_DST_PORT_FLE] )
if (flowlist_entry_val1->l4_dst_port == flowlist_entry_val2->l4_dst_port)
- flowlist_entry_val1->valid[UPLL_IDX_L4_DST_PORT_FLE] = UNC_VF_INVALID;
+ flowlist_entry_val1->valid[UPLL_IDX_L4_DST_PORT_FLE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_L4_DST_PORT_ENDPT_FLE]
&& UNC_VF_VALID ==
if (flowlist_entry_val1->l4_dst_port_endpt ==
flowlist_entry_val2->l4_dst_port_endpt)
flowlist_entry_val1->valid[UPLL_IDX_L4_DST_PORT_ENDPT_FLE] =
- UNC_VF_INVALID;
-
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
+
if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_L4_SRC_PORT_FLE] &&
UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_L4_SRC_PORT_FLE] )
if (flowlist_entry_val1->l4_src_port == flowlist_entry_val2->l4_src_port)
- flowlist_entry_val1->valid[UPLL_IDX_L4_SRC_PORT_FLE] = UNC_VF_INVALID;
+ flowlist_entry_val1->valid[UPLL_IDX_L4_SRC_PORT_FLE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
+
if (UNC_VF_VALID ==
flowlist_entry_val1->valid[UPLL_IDX_L4_SRC_PORT_ENDPT_FLE] &&
if (flowlist_entry_val1->l4_src_port_endpt ==
flowlist_entry_val2->l4_src_port_endpt)
flowlist_entry_val1->valid[UPLL_IDX_L4_SRC_PORT_ENDPT_FLE] =
- UNC_VF_INVALID;
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_ICMP_TYPE_FLE] &&
UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_ICMP_TYPE_FLE])
UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_ICMP_V6_CODE_FLE])
if (flowlist_entry_val1->icmpv6_code == flowlist_entry_val2->icmpv6_code)
flowlist_entry_val1->valid[UPLL_IDX_ICMP_V6_CODE_FLE] = UNC_VF_INVALID;
- return false;
+
+ for (unsigned int loop = 0;
+ loop < sizeof(flowlist_entry_val1->valid) / sizeof(uint8_t); ++loop) {
+ if ((UNC_VF_VALID == (uint8_t) flowlist_entry_val1->valid[loop]) ||
+ (UNC_VF_VALID_NO_VALUE == (uint8_t) flowlist_entry_val1->valid[loop]))
+ invalid_attr = false;
+ }
+ return invalid_attr;
+}
+
+bool FlowListEntryMoMgr::CompareValidVal(void *&val1, void *val2, void *val3,
+ bool copy_to_running) {
+ UPLL_FUNC_TRACE;
+ bool invalid_attr = true;
+ val_flowlist_entry_t *flowlist_entry_val1 =
+ reinterpret_cast<val_flowlist_entry_t *>(val1);
+
+ val_flowlist_entry_t *flowlist_entry_val2 =
+ reinterpret_cast<val_flowlist_entry_t *>(val2);
+
+ val_flowlist_entry_t *flowlist_entry_val3 =
+ reinterpret_cast<val_flowlist_entry_t *>(val2);
+
+ if (!flowlist_entry_val1 || !flowlist_entry_val2 || flowlist_entry_val3) {
+ return false;
+ }
+ for ( unsigned int loop = 0; loop < (sizeof(flowlist_entry_val1->valid)
+ /(sizeof(flowlist_entry_val1->valid[0])));
+ ++loop ) {
+ if (UNC_VF_INVALID == flowlist_entry_val1->valid[loop] &&
+ UNC_VF_VALID == flowlist_entry_val2->valid[loop])
+ flowlist_entry_val1->valid[loop] = UNC_VF_VALID_NO_VALUE;
+ }
+ if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_MAC_DST_FLE] &&
+ UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_MAC_DST_FLE])
+ if (!memcmp(flowlist_entry_val3->mac_dst, flowlist_entry_val2->mac_dst,
+ sizeof(flowlist_entry_val2->mac_dst)))
+ flowlist_entry_val1->valid[UPLL_IDX_MAC_DST_FLE] = UNC_VF_INVALID;
+
+ if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_MAC_SRC_FLE] &&
+ UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_MAC_SRC_FLE] )
+ if (!memcmp(flowlist_entry_val3->mac_src, flowlist_entry_val2->mac_src,
+ sizeof(flowlist_entry_val2->mac_src)))
+ flowlist_entry_val1->valid[UPLL_IDX_MAC_SRC_FLE] = UNC_VF_INVALID;
+
+ if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_MAC_ETH_TYPE_FLE] &&
+ UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_MAC_ETH_TYPE_FLE] )
+ if (flowlist_entry_val3->mac_eth_type == flowlist_entry_val2->mac_eth_type)
+ flowlist_entry_val1->valid[UPLL_IDX_MAC_ETH_TYPE_FLE] = UNC_VF_INVALID;
+
+ if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_DST_IP_FLE] &&
+ UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_DST_IP_FLE] )
+ if (!memcmp(&flowlist_entry_val3->dst_ip,
+ &flowlist_entry_val2->dst_ip,
+ sizeof(flowlist_entry_val2->dst_ip)))
+ flowlist_entry_val1->valid[UPLL_IDX_DST_IP_FLE] = UNC_VF_INVALID;
+
+ if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_DST_IP_PREFIX_FLE] &&
+ UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_DST_IP_PREFIX_FLE] )
+ if (flowlist_entry_val3->dst_ip_prefixlen ==
+ flowlist_entry_val2->dst_ip_prefixlen)
+ flowlist_entry_val1->valid[UPLL_IDX_DST_IP_PREFIX_FLE] = UNC_VF_INVALID;
+
+
+ if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_SRC_IP_FLE] &&
+ UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_SRC_IP_FLE] )
+ if (!memcmp(&flowlist_entry_val3->src_ip,
+ &flowlist_entry_val2->src_ip,
+ sizeof(flowlist_entry_val2->src_ip)))
+ flowlist_entry_val1->valid[UPLL_IDX_SRC_IP_FLE] = UNC_VF_INVALID;
+
+ if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_SRC_IP_PREFIX_FLE] &&
+ UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_SRC_IP_PREFIX_FLE] )
+ if (flowlist_entry_val3->src_ip_prefixlen ==
+ flowlist_entry_val2->src_ip_prefixlen)
+ flowlist_entry_val1->valid[UPLL_IDX_SRC_IP_PREFIX_FLE] = UNC_VF_INVALID;
+
+ if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_VLAN_PRIORITY_FLE] &&
+ UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_VLAN_PRIORITY_FLE] )
+ if (flowlist_entry_val3->vlan_priority ==
+ flowlist_entry_val2->vlan_priority)
+ flowlist_entry_val1->valid[UPLL_IDX_VLAN_PRIORITY_FLE] = UNC_VF_INVALID;
+
+ if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_DST_IP_V6_FLE] &&
+ UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_DST_IP_V6_FLE] )
+ if (!memcmp(&flowlist_entry_val3->dst_ipv6,
+ &flowlist_entry_val2->dst_ipv6,
+ sizeof(flowlist_entry_val2->dst_ipv6)))
+ flowlist_entry_val1->valid[UPLL_IDX_DST_IP_V6_FLE] = UNC_VF_INVALID;
+
+ if (UNC_VF_VALID ==
+ flowlist_entry_val1->valid[UPLL_IDX_DST_IP_V6_PREFIX_FLE] &&
+ UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_DST_IP_V6_PREFIX_FLE])
+ if (flowlist_entry_val3->dst_ipv6_prefixlen ==
+ flowlist_entry_val2->dst_ipv6_prefixlen)
+ flowlist_entry_val1->valid[UPLL_IDX_DST_IP_V6_PREFIX_FLE] = UNC_VF_INVALID;
+
+ if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_SRC_IP_V6_FLE] &&
+ UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_SRC_IP_V6_FLE] )
+ if (!memcmp(&flowlist_entry_val3->src_ipv6,
+ &flowlist_entry_val2->src_ipv6,
+ sizeof(flowlist_entry_val2->src_ipv6)))
+ flowlist_entry_val1->valid[UPLL_IDX_SRC_IP_V6_FLE] = UNC_VF_INVALID;
+
+ if (UNC_VF_VALID ==
+ flowlist_entry_val1->valid[UPLL_IDX_SRC_IP_V6_PREFIX_FLE] &&
+ UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_SRC_IP_V6_PREFIX_FLE])
+ if (flowlist_entry_val3->src_ipv6_prefixlen ==
+ flowlist_entry_val2->src_ipv6_prefixlen)
+ flowlist_entry_val1->valid[UPLL_IDX_SRC_IP_V6_PREFIX_FLE] = UNC_VF_INVALID;
+
+ if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_IP_PROTOCOL_FLE] &&
+ UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_IP_PROTOCOL_FLE] )
+ if (flowlist_entry_val3->ip_proto == flowlist_entry_val2->ip_proto)
+ flowlist_entry_val1->valid[UPLL_IDX_IP_PROTOCOL_FLE] = UNC_VF_INVALID;
+
+ if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_IP_DSCP_FLE] &&
+ UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_IP_DSCP_FLE] )
+ if (flowlist_entry_val3->ip_dscp == flowlist_entry_val2->ip_dscp)
+ flowlist_entry_val1->valid[UPLL_IDX_IP_DSCP_FLE] = UNC_VF_INVALID;
+
+
+ if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_L4_DST_PORT_FLE] &&
+ UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_L4_DST_PORT_FLE] )
+ if (flowlist_entry_val3->l4_dst_port == flowlist_entry_val2->l4_dst_port)
+ flowlist_entry_val1->valid[UPLL_IDX_L4_DST_PORT_FLE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
+
+ if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_L4_DST_PORT_ENDPT_FLE]
+ && UNC_VF_VALID ==
+ flowlist_entry_val2->valid[UPLL_IDX_L4_DST_PORT_ENDPT_FLE])
+ if (flowlist_entry_val3->l4_dst_port_endpt ==
+ flowlist_entry_val2->l4_dst_port_endpt)
+ flowlist_entry_val1->valid[UPLL_IDX_L4_DST_PORT_ENDPT_FLE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
+
+ if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_L4_SRC_PORT_FLE] &&
+ UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_L4_SRC_PORT_FLE] )
+ if (flowlist_entry_val3->l4_src_port == flowlist_entry_val2->l4_src_port)
+ flowlist_entry_val1->valid[UPLL_IDX_L4_SRC_PORT_FLE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
+
+
+ if (UNC_VF_VALID ==
+ flowlist_entry_val1->valid[UPLL_IDX_L4_SRC_PORT_ENDPT_FLE] &&
+ UNC_VF_VALID ==
+ flowlist_entry_val2->valid[UPLL_IDX_L4_SRC_PORT_ENDPT_FLE] )
+ if (flowlist_entry_val3->l4_src_port_endpt ==
+ flowlist_entry_val2->l4_src_port_endpt)
+ flowlist_entry_val1->valid[UPLL_IDX_L4_SRC_PORT_ENDPT_FLE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
+
+ if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_ICMP_TYPE_FLE] &&
+ UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_ICMP_TYPE_FLE])
+ if (flowlist_entry_val3->icmp_type == flowlist_entry_val2->icmp_type)
+ flowlist_entry_val1->valid[UPLL_IDX_ICMP_TYPE_FLE] = UNC_VF_INVALID;
+
+ if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_ICMP_CODE_FLE] &&
+ UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_ICMP_CODE_FLE])
+ if (flowlist_entry_val3->icmp_code == flowlist_entry_val2->icmp_code)
+ flowlist_entry_val1->valid[UPLL_IDX_ICMP_CODE_FLE] = UNC_VF_INVALID;
+
+ if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_ICMP_V6_TYPE_FLE] &&
+ UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_ICMP_V6_TYPE_FLE])
+ if (flowlist_entry_val3->icmpv6_type == flowlist_entry_val2->icmpv6_type)
+ flowlist_entry_val1->valid[UPLL_IDX_ICMP_V6_TYPE_FLE] = UNC_VF_INVALID;
+
+ if (UNC_VF_VALID == flowlist_entry_val1->valid[UPLL_IDX_ICMP_V6_CODE_FLE] &&
+ UNC_VF_VALID == flowlist_entry_val2->valid[UPLL_IDX_ICMP_V6_CODE_FLE])
+ if (flowlist_entry_val3->icmpv6_code == flowlist_entry_val2->icmpv6_code)
+ flowlist_entry_val1->valid[UPLL_IDX_ICMP_V6_CODE_FLE] = UNC_VF_INVALID;
+
+ for (unsigned int loop = 0;
+ loop < sizeof(flowlist_entry_val1->valid) / sizeof(uint8_t); ++loop) {
+ if ((UNC_VF_VALID == (uint8_t) flowlist_entry_val1->valid[loop]) ||
+ (UNC_VF_VALID_NO_VALUE == (uint8_t) flowlist_entry_val1->valid[loop]))
+ invalid_attr = false;
+ }
+ return invalid_attr;
}
upll_rc_t FlowListEntryMoMgr::MergeValidate(unc_key_type_t keytype,
- const char *ctrlr_id, ConfigKeyVal *ikey, DalDmlIntf *dmi) {
+ const char *ctrlr_id,
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
- UPLL_LOG_DEBUG(" FlowListEntryMoMgr::MergeValidate successful ");
- return UPLL_RC_SUCCESS;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_FLOWLIST)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Invalid mgr param");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ result_code = mgr->MergeValidate(keytype, ctrlr_id, ikey, dmi);
+ UPLL_LOG_DEBUG("MergeValidate result code (%d)", result_code);
+ return result_code;
}
upll_rc_t FlowListEntryMoMgr::RenameMo(IpcReqRespHeader *req,
upll_rc_t result_code = UPLL_RC_SUCCESS;
// int refcount = 0;
// uint8_t *ctrlr_id = { 0 };
- ConfigKeyVal *okey = NULL;
+ // ConfigKeyVal *okey = NULL;
if (NULL == ikey) {
UPLL_LOG_DEBUG("ikey is NULL");
return UPLL_RC_ERR_CFG_SEMANTIC;
}
- result_code = GetFlowListKeyVal(okey, ikey);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Memory is not allocated for okey %d", result_code);
- return result_code;
+ key_flowlist_entry_t *key_fle = reinterpret_cast
+ <key_flowlist_entry_t *>(ikey->get_key());
+ PolicingProfileEntryMoMgr *mgr =
+ reinterpret_cast<PolicingProfileEntryMoMgr *>(const_cast<MoManager *>
+ (GetMoManager(UNC_KT_POLICING_PROFILE_ENTRY)));
+ if (NULL == mgr) {
+ return UPLL_RC_ERR_GENERIC;
}
- MoMgrImpl *mgr =
- reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
- UNC_KT_FLOWLIST)));
- result_code = mgr->IsReferenced(okey, UPLL_DT_CANDIDATE, dmi);
-
+ result_code = mgr->IsFlowListMatched(reinterpret_cast<const char *>
+ (key_fle->flowlist_key.flowlist_name), UPLL_DT_CANDIDATE, dmi);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("IsReferenced id Faliled %d", result_code);
+ UPLL_LOG_DEBUG("IsFlowListMatched failed from ppe %d", result_code);
}
- delete okey;
return result_code;
}
}
-upll_rc_t FlowListEntryMoMgr::GetRenamedControllerKey(ConfigKeyVal *&ikey,
+upll_rc_t FlowListEntryMoMgr::GetRenamedControllerKey(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
controller_domain *ctrlr_dom) {
UPLL_FUNC_TRACE;
ConfigKeyVal *okey = NULL;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
if (NULL == ctrlr_dom) {
UPLL_LOG_DEBUG("ctrlr_dom is NULL");
if (!rename)
return UPLL_RC_SUCCESS;
/* Flowlist is renamed */
- key_flowlist_entry_t *ctrlr_key =
- reinterpret_cast<key_flowlist_entry_t *>
- (ConfigKeyVal::Malloc(sizeof(key_flowlist_entry_t)));
if (rename & RENAME_FLOWLIST) {
- GetChildConfigKey(okey, ikey);
- SET_USER_DATA_CTRLR(okey, ctrlr_name);
-
- DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
-
+ UPLL_LOG_DEBUG("flow list renamed");
MoMgrImpl *mgr =
reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
UNC_KT_FLOWLIST)));
- mgr->ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi, RENAMETBL);
+
+ result_code = mgr->GetChildConfigKey(okey, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail (%d)", result_code);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ if (ctrlr_dom != NULL)
+ SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
+ uuu::upll_strncpy(
+ reinterpret_cast<key_flowlist_t *>(okey->get_key())->flowlist_name,
+ reinterpret_cast <key_flowlist_entry *>
+ (ikey->get_key())->flowlist_key.flowlist_name,
+ (kMaxLenFlowListName + 1));
+
+ UPLL_LOG_DEBUG("flowlist name (%s) (%s)",
+ reinterpret_cast<key_flowlist_t *>(okey->get_key())->flowlist_name,
+ reinterpret_cast <key_flowlist_entry *>
+ (ikey->get_key())->flowlist_key.flowlist_name);
+
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
+
+ result_code = mgr->ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi, RENAMETBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB no instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("ReadConfigDB failed (%d)", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+
val_rename_flowlist_t *rename_val = NULL;
rename_val = reinterpret_cast<val_rename_flowlist_t *> (GetVal(okey));
- if (!rename_val
- || (rename_val->valid[UPLL_IDX_RENAME_FLOWLIST_RFL] != UNC_VF_VALID)) {
+ if (!rename_val) {
UPLL_LOG_DEBUG("FlowList Name is not valid");
- free(ctrlr_key);
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
- uuu::upll_strncpy(ctrlr_key->flowlist_key.flowlist_name,
+ key_flowlist_entry *key = reinterpret_cast<key_flowlist_entry *>(ikey->get_key());
+ uuu::upll_strncpy(key->flowlist_key.flowlist_name,
rename_val->flowlist_newname,
(kMaxLenFlowListName+1));
- delete okey;
- }
- free(ikey->get_key());
- ikey->SetKey(IpctSt::kIpcStKeyFlowlistEntry,
- reinterpret_cast<void *> (ctrlr_key));
+ UPLL_LOG_DEBUG("flowlist re name (%s) (%s)",
+ key->flowlist_key.flowlist_name,
+ rename_val->flowlist_newname);
+ DELETE_IF_NOT_NULL(okey);
+ }
+
UPLL_LOG_DEBUG("GetRenamedControllerKey is Successfull");
return UPLL_RC_SUCCESS;
}
dup_ckmain = NULL;
result_code = GetChildConfigKey(dup_ckmain, ck_main);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
if (dup_ckmain) delete dup_ckmain;
return result_code;
}
result_code = ReadConfigDB(dup_ckmain, UPLL_DT_CANDIDATE,
UNC_OP_READ, dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- string s(dup_ckmain->ToStrAll());
- UPLL_LOG_INFO("%s Flowlist read failed %d", s.c_str(), result_code);
+ UPLL_LOG_DEBUG("%s Flowlist read failed %d",
+ (dup_ckmain->ToStrAll()).c_str(), result_code);
delete dup_ckmain;
return result_code;
}
result_code = GetRenamedControllerKey(dup_ckmain, UPLL_DT_CANDIDATE,
dmi, ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
+ if ((op == UNC_OP_CREATE) && dup_ckmain) {
+ DELETE_IF_NOT_NULL(dup_ckmain);
+ }
return result_code;
}
result_code = SendIpcReq(ipc_resp->header.clnt_sess_id,
ipc_resp->header.config_id, op,
UPLL_DT_CANDIDATE, dup_ckmain, ctrlr_dom, ipc_resp);
if (result_code == UPLL_RC_ERR_RESOURCE_DISCONNECTED) {
- UPLL_LOG_DEBUG("Controller disconnected\n");
+ UPLL_LOG_DEBUG("Controller disconnected");
result_code = UPLL_RC_SUCCESS;
}
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("IpcSend failed %d\n", result_code);
+ UPLL_LOG_DEBUG("IpcSend failed %d", result_code);
}
if ((op == UNC_OP_CREATE) && dup_ckmain) {
delete dup_ckmain;
req, nreq, &dal_cursor_handle, dmi, MAINTBL);
break;
default:
- UPLL_LOG_TRACE("Invalid operation \n");
+ UPLL_LOG_TRACE("Invalid operation");
return UPLL_RC_ERR_GENERIC;
}
resp.header.clnt_sess_id = session_id;
affected_ctrlr_set->insert((const char *)ctrlr_dom.ctrlr);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("TxUpdateProcess Returns error %d", result_code);
+ upll_keytype_datatype_t dt_type = (UNC_OP_DELETE == op)?
+ UPLL_DT_RUNNING:UPLL_DT_CANDIDATE;
+ upll_rc_t local_rc = GetRenamedUncKey(resp.ckv_data, dt_type, dmi,
+ ctrlr_dom.ctrlr);
+ if (UPLL_RC_SUCCESS != local_rc &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != local_rc) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey failed %d", local_rc);
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(resp.ckv_data);
+ result_code = UPLL_RC_ERR_GENERIC;
+ break;
+ }
*err_ckv = resp.ckv_data;
+ DELETE_IF_NOT_NULL(ck_main);
break;
}
+ DELETE_IF_NOT_NULL(resp.ckv_data);
} else if (op == UNC_OP_UPDATE) {
ConfigKeyVal *ck_ctrlr = NULL;
result_code = DupConfigKeyVal(ck_main, req, MAINTBL);
}
*/
result_code = GetChildConfigKey(ck_ctrlr, ck_main);
- if (result_code != UPLL_RC_SUCCESS)
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(req);
+ if (dal_cursor_handle) {
+ dmi->CloseCursor(dal_cursor_handle, true);
+ dal_cursor_handle = NULL;
+ }
return result_code;
+ }
if (GetControllerSpan(ck_ctrlr, UPLL_DT_CANDIDATE, dmi) ==
UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- delete ck_ctrlr;
- ck_ctrlr = NULL;
+ DELETE_IF_NOT_NULL(ck_ctrlr);
+ DELETE_IF_NOT_NULL(ck_main);
continue;
}
void *main = GetVal(ck_main);
UPLL_LOG_DEBUG("Invalid controller");
return UPLL_RC_ERR_GENERIC;
}
-
+ ConfigKeyVal *temp_ck_main = NULL;
+ result_code = DupConfigKeyVal(temp_ck_main, ck_main, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed %d", result_code);
+ DELETE_IF_NOT_NULL(ck_ctrlr);
+ DELETE_IF_NOT_NULL(ck_main);
+ return result_code;
+ }
result_code = TxUpdateProcess(ck_main, &resp, op, dmi, &ctrlr_dom);
affected_ctrlr_set->insert(reinterpret_cast<const char *>
(ctrlr_dom.ctrlr));
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("TxUpdate Process returns with %d\n", result_code);
- *err_ckv = resp.ckv_data;
+ UPLL_LOG_DEBUG("TxUpdate Process returns with %d", result_code);
+ *err_ckv = temp_ck_main;
+ DELETE_IF_NOT_NULL(resp.ckv_data);
+ DELETE_IF_NOT_NULL(ck_ctrlr);
+ DELETE_IF_NOT_NULL(ck_main);
break;
}
+ DELETE_IF_NOT_NULL(resp.ckv_data);
+ DELETE_IF_NOT_NULL(temp_ck_main);
}
- if (ck_ctrlr) delete ck_ctrlr;
+ DELETE_IF_NOT_NULL(ck_ctrlr);
}
- if (ck_main) delete ck_main;
+ DELETE_IF_NOT_NULL(ck_main);
}
- if (nreq)
- delete nreq;
- if (req)
- delete req;
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(req);
if (dal_cursor_handle) {
dmi->CloseCursor(dal_cursor_handle, true);
dal_cursor_handle = NULL;
upll_rc_t FlowListEntryMoMgr::AddFlowListToController(char *flowlist_name,
DalDmlIntf *dmi,
char* ctrl_id,
+ upll_keytype_datatype_t dt_type,
unc_keytype_operation_t op) {
UPLL_FUNC_TRACE
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *okey = NULL;
result_code = GetChildConfigKey(okey, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
+ return result_code;
+ }
key_flowlist_entry_t *flowlist_key = reinterpret_cast<key_flowlist_entry_t*>
(okey->get_key());
uuu::upll_strncpy(flowlist_key->flowlist_key.flowlist_name,
flowlist_name, (kMaxLenFlowListName+1));
- DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutNone};
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutCs};
result_code = ReadConfigDB(okey,
- UPLL_DT_CANDIDATE,
+ dt_type,
UNC_OP_READ,
dbop, dmi, MAINTBL);
if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
UPLL_LOG_DEBUG("No such instance in entry table");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_SUCCESS;
}
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Unable to read flowlist configuration from DB %d",
result_code);
- delete okey;
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
- #if 0
- req_header = reinterpret_cast<IpcReqRespHeader*>
- (ConfigKeyVal::Malloc(sizeof(IpcReqRespHeader)));
-
- req_header->operation = op;
- req_header->datatype = UPLL_DT_CANDIDATE;
- // Validate whether the attributes supported by controller or not
- result_code = ValidateCapability(req_header, okey, ctrl_id);
- if (result_code != UPLL_RC_SUCCESS) {
- // Error should be returned if the failure code is other then ctrlr not
- // supported
-// if (result_code != UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR) {
- if (result_code != UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT) {
- free(okey);
- UPLL_LOG_DEBUG("ValidateCapability Failed: result_code=%d",
- result_code);
- free(req_header);
- return result_code;
- }
- }
- }
- #endif
- #if 0
- ConfigKeyVal *temp_ckv = okey;
- while (NULL != temp_ckv) {
- val_flowlist_entry_t *val_flowlist =
- reinterpret_cast<val_flowlist_entry_t *>
- ((temp_ckv->get_cfg_val()->get_val()));
- SetValidAttributesForController(val_flowlist);
- SET_USER_DATA_CTRLR(temp_ckv, ctrl_id);
- temp_ckv = temp_ckv->get_next_cfg_key_val();
- }
- #endif
// Update the flowlist entry controller table based on the operation
- result_code = UpdateControllerTable(okey, op, dmi, ctrl_id);
-
+ result_code = UpdateControllerTable(okey, op, dt_type, dmi, ctrl_id);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
UPLL_FUNC_TRACE;
for ( unsigned int loop = 0;
loop < sizeof(val->valid)/sizeof(val->valid[0]); ++loop ) {
- if ((val->valid[loop] == UNC_VF_NOT_SOPPORTED)
+ if ((val->valid[loop] == UNC_VF_NOT_SUPPORTED)
|| (val->valid[loop] ==
UNC_VF_VALID_NO_VALUE)) {
val->valid[loop] = UNC_VF_INVALID;
upll_rc_t FlowListEntryMoMgr::UpdateControllerTable(ConfigKeyVal *ikey,
unc_keytype_operation_t op,
+ upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
char* ctrl_id) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
val_flowlist_entry_ctrl_t *val_flowlist_entry_ctrl = NULL;
ConfigKeyVal *temp_ikey = ikey;
+ unc_keytype_ctrtype_t ctrlrtype = UNC_CT_UNKNOWN;
+ uuc::CtrlrMgr *ctrlr_mgr = uuc::CtrlrMgr::GetInstance();
+
while (temp_ikey != NULL) {
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
ConfigKeyVal *ctrlr_ckv = NULL;
result_code = GetChildConfigKey(ctrlr_ckv, temp_ikey);
SET_USER_DATA_CTRLR(ctrlr_ckv, ctrl_id);
- result_code = ReadConfigDB(ctrlr_ckv, UPLL_DT_CANDIDATE, UNC_OP_READ,
+ result_code = ReadConfigDB(ctrlr_ckv, dt_type, UNC_OP_READ,
dbop, dmi, CTRLRTBL);
if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
if (op == UNC_OP_CREATE || op == UNC_OP_UPDATE) {
val_flowlist_entry_t *val_flowlist_entry =
reinterpret_cast<val_flowlist_entry_t *>
(GetVal(temp_ikey));
- val_flowlist_entry_ctrl = reinterpret_cast<val_flowlist_entry_ctrl_t*>
- (GetVal(ctrlr_ckv));
- for ( unsigned int loop = 0;
+
+ //capability check
+ ConfigKeyVal *temp_key = NULL;
+ result_code = GetChildConfigKey(temp_key, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ UPLL_LOG_DEBUG("GetChildConfigKey failed(%d)",result_code);
+ return result_code;
+ }
+
+ result_code = GetInstanceCount(temp_key, ctrl_id,
+ dt_type,
+ &cur_instance_count,
+ dmi, CTRLRTBL);
+ DELETE_IF_NOT_NULL(temp_key);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetInstanceCount failed(%d)",result_code);
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return result_code;
+ }
+
+ IpcReqRespHeader *req_header = reinterpret_cast<IpcReqRespHeader*>
+ (ConfigKeyVal::Malloc(sizeof(IpcReqRespHeader)));
+
+ req_header->operation = op;
+ req_header->datatype = UPLL_DT_CANDIDATE;
+
+ // Validate whether the attributes supported by controller or not
+ result_code = ValidateCapability(req_header, temp_ikey, ctrl_id);
+ free(req_header);
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ // Error should be returned if the failure code is other then ctrlr not
+ // supported
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ if ((!ctrlr_mgr->GetCtrlrType(reinterpret_cast<char *>(ctrl_id),
+ dt_type, &ctrlrtype)) || (ctrlrtype != UNC_CT_PFC)) {
+ result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_DEBUG("Controller type is %d", ctrlrtype);
+ temp_ikey = temp_ikey->get_next_cfg_key_val();
+ continue;
+ }
+ UPLL_LOG_DEBUG("ValidateCapability Failed: result_code=%d",
+ result_code);
+ return result_code;
+ }
+ /** change NOT_SOPPRTED attribute to INVALID to store in ctrlr table */
+ SetValidAttributesForController(val_flowlist_entry);
+
+ val_flowlist_entry_ctrl = reinterpret_cast<val_flowlist_entry_ctrl_t*>
+ (GetVal(ctrlr_ckv));
+ for ( unsigned int loop = 0;
loop < sizeof
(val_flowlist_entry->valid)/sizeof(val_flowlist_entry->valid[0]);
++loop ) {
val_flowlist_entry_ctrl->valid[loop] =
val_flowlist_entry->valid[loop];
}
- result_code = UpdateConfigDB(ctrlr_ckv, UPLL_DT_CANDIDATE,
+ result_code = UpdateConfigDB(ctrlr_ckv, dt_type,
UNC_OP_CREATE, dmi,
CTRLRTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Unable to create a FlowListEntry in Ctrlr table=%d",
result_code);
- delete ctrlr_ckv;
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
return result_code;
}
- delete ctrlr_ckv;
}
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
} else if (UPLL_RC_SUCCESS == result_code) {
if (op == UNC_OP_UPDATE || op == UNC_OP_DELETE) {
if (op == UNC_OP_UPDATE) {
val_flowlist_entry_t *val_flowlist_entry =
reinterpret_cast<val_flowlist_entry_t *>
(GetVal(temp_ikey));
+
+ // Capability check
+ IpcReqRespHeader *req_header = reinterpret_cast<IpcReqRespHeader*>
+ (ConfigKeyVal::Malloc(sizeof(IpcReqRespHeader)));
+
+ req_header->operation = op;
+ req_header->datatype = UPLL_DT_CANDIDATE;
+
+ // Validate whether the attributes supported by controller or not
+ result_code = ValidateCapability(req_header, temp_ikey, reinterpret_cast<char*>(ctrl_id));
+ free(req_header);
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ // FlowListEntry is not supported for other than PFC Controller
+ // so SKIP the adding entry for such sontroller
+ if ((!ctrlr_mgr->GetCtrlrType(reinterpret_cast<char *>(ctrl_id),
+ dt_type, &ctrlrtype)) || (ctrlrtype != UNC_CT_PFC)) {
+ result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_DEBUG("Controller type is %d", ctrlrtype);
+ temp_ikey = temp_ikey->get_next_cfg_key_val();
+ continue;
+ }
+ UPLL_LOG_DEBUG("Key not supported by controller");
+ return result_code;
+ }
+
val_flowlist_entry_ctrl = reinterpret_cast<val_flowlist_entry_ctrl_t*>
(GetVal(ctrlr_ckv));
for ( unsigned int loop = 0;
loop < sizeof
(val_flowlist_entry->valid)/sizeof(val_flowlist_entry->valid[0]);
++loop ) {
+ if (val_flowlist_entry->valid[loop] == UNC_VF_NOT_SUPPORTED) {
+ val_flowlist_entry_ctrl->valid[loop] = UNC_VF_INVALID;
+ } else {
val_flowlist_entry_ctrl->valid[loop] =
- val_flowlist_entry->valid[loop];
+ val_flowlist_entry->valid[loop];
+ }
}
}
+ if ((UPLL_DT_AUDIT == dt_type) && (UNC_OP_DELETE != op) ) {
+ val_flowlist_entry_t *val_flowlist_entry =
+ reinterpret_cast<val_flowlist_entry_t *>
+ (GetVal(temp_ikey));
+ val_flowlist_entry_ctrl = reinterpret_cast<val_flowlist_entry_ctrl_t*>
+ (GetVal(ctrlr_ckv));
+ for ( unsigned int loop = 0;
+ loop < sizeof
+ (val_flowlist_entry->valid)/sizeof(val_flowlist_entry->valid[0]);
+ ++loop ) {
+ val_flowlist_entry_ctrl->cs_attr[loop] = (unc_keytype_configstatus_t)
+ val_flowlist_entry->cs_attr[loop];
+ }
+ val_flowlist_entry_ctrl->cs_row_status = (unc_keytype_configstatus_t)
+ val_flowlist_entry->cs_row_status;
+ }
SET_USER_DATA_CTRLR(ctrlr_ckv, ctrl_id);
- result_code = UpdateConfigDB(ctrlr_ckv, UPLL_DT_CANDIDATE,
+ result_code = UpdateConfigDB(ctrlr_ckv, dt_type,
op, dmi, CTRLRTBL);
- if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) continue;
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ continue;
+ }
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Unable to delete a FlowListEntry in Ctrlr table=%d",
result_code);
// delete ctrlr_ckv;
}
- delete ctrlr_ckv;
}
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
} else {
UPLL_LOG_DEBUG("ReadConfigDB failed %d ", result_code);
- delete ctrlr_ckv;
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
return result_code;
}
temp_ikey = temp_ikey->get_next_cfg_key_val();
DalResultCode db_result;
unc_keytype_operation_t op[]= { UNC_OP_DELETE, UNC_OP_CREATE, UNC_OP_UPDATE};
int nop = sizeof(op) / sizeof(op[0]);
- ConfigKeyVal *fle_key = NULL, *req = NULL, *nreq = NULL;
+ ConfigKeyVal *fle_key = NULL, *req = NULL;
+ ConfigKeyVal *nreq = NULL , *fl_run_key = NULL;
+ ConfigKeyVal *fl_run_ctrl_key = NULL , *fl_ck_run = NULL;
DalCursor *cfg1_cursor = NULL;
uint8_t *ctrlr_id = NULL;
#if 0
for (int i = 0; i < nop; i++) {
if (op[i] != UNC_OP_UPDATE) {
result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i], req,
- nreq, &cfg1_cursor, dmi, MAINTBL);
+ nreq, &cfg1_cursor, dmi, NULL, MAINTBL, true);
while (result_code == UPLL_RC_SUCCESS) {
db_result = dmi->GetNextRecord(cfg1_cursor);
result_code = DalToUpllResCode(db_result);
nreq, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Updating Main table Error %d", result_code);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
}
dmi->CloseCursor(cfg1_cursor, true);
cfg1_cursor = NULL;
}
- if (req)
- delete req;
- req = NULL;
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
}
UPLL_LOG_DEBUG("Updating main table complete with op %d", op[i]);
}
for (int i = 0; i < nop; i++) {
MoMgrTables tbl = (op[i] == UNC_OP_UPDATE)?MAINTBL:CTRLRTBL;
result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i], req,
- nreq, &cfg1_cursor, dmi, tbl);
+ nreq, &cfg1_cursor, dmi, NULL, tbl,true);
ConfigKeyVal *fle_ctrlr_key = NULL;
while (result_code == UPLL_RC_SUCCESS) {
result_code = DalToUpllResCode(db_result);
if (result_code != UPLL_RC_SUCCESS)
break;
-
if (op[i] == UNC_OP_UPDATE) {
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr };
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr | kOpInOutCs };
result_code = GetChildConfigKey(fle_ctrlr_key, req);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
result_code);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
/* Capability check
result_code = ReadConfigDB(fle_ctrlr_key, UPLL_DT_CANDIDATE,
UNC_OP_READ, dbop, dmi, CTRLRTBL);
if (result_code != UPLL_RC_SUCCESS) {
- delete fle_ctrlr_key;
+ DELETE_IF_NOT_NULL(fle_ctrlr_key);
if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("No record found in FlowlistEntry Ctrlr Tbl");
result_code = UpdateMainTbl(req, op[i], UPLL_RC_SUCCESS,
nreq, dmi);
if (result_code != UPLL_RC_SUCCESS) {
continue;
}
} else {
+ UPLL_LOG_DEBUG("DB err while reading records from ctrlrtbl, err %d",
+ result_code);
+
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
}
-
- result_code = DupConfigKeyVal(fle_key, req, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("DupConfigKeyVal is failed result_code = %d",
- result_code);
- delete(fle_ctrlr_key); // COVERITY RESOURCE LEAk
- return result_code;
- }
- GET_USER_DATA_CTRLR(fle_ctrlr_key, ctrlr_id);
- string controller(reinterpret_cast<char *>(ctrlr_id));
- void *fle_val1 = GetVal(fle_ctrlr_key);
- void *fle_val2 = GetVal(nreq);
for (ConfigKeyVal *tmp = fle_ctrlr_key; tmp != NULL; tmp =
tmp->get_next_cfg_key_val()) {
+
+ GET_USER_DATA_CTRLR(tmp, ctrlr_id);
+ string controller(reinterpret_cast<char *>(ctrlr_id));
+
+ UPLL_LOG_DEBUG("Controller ID =%s", controller.c_str());
+ DbSubOp dbop_maintbl = { kOpReadSingle, kOpMatchNone, kOpInOutFlag | kOpInOutCs };
+ result_code = GetChildConfigKey(fle_key, req);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
+ result_code);
+ DELETE_IF_NOT_NULL(fle_ctrlr_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+ result_code = ReadConfigDB(fle_key, UPLL_DT_CANDIDATE,
+ UNC_OP_READ, dbop_maintbl, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to read configuration from CandidateDb");
+ DELETE_IF_NOT_NULL(fle_key);
+ DELETE_IF_NOT_NULL(fle_ctrlr_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+ static_cast<val_flowlist_entry_t *>
+ (GetVal(fle_key))->cs_row_status =
+ static_cast<val_flowlist_entry_t *>
+ (GetVal(nreq))->cs_row_status;
+
+ // ReadingConfigstatus for main tbl
+ result_code = GetChildConfigKey(fl_run_key, req);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
+ result_code);
+ DELETE_IF_NOT_NULL(fle_key);
+ DELETE_IF_NOT_NULL(fle_ctrlr_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+
+ return result_code;
+ }
+
+ result_code = ReadConfigDB(fl_run_key, UPLL_DT_RUNNING ,
+ UNC_OP_READ, dbop_maintbl, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to read configuration from CandidateDb");
+ DELETE_IF_NOT_NULL(fle_key);
+ DELETE_IF_NOT_NULL(fle_ctrlr_key);
+ DELETE_IF_NOT_NULL(fl_run_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+
+ val_flowlist_entry_t *val_main_can = reinterpret_cast
+ <val_flowlist_entry_t *>(GetVal(fle_key));
+ val_flowlist_entry_t *val_main = reinterpret_cast
+ <val_flowlist_entry_t *>(GetVal(fl_run_key));
+ for (unsigned int loop = 0; loop < sizeof(val_main->valid)/
+ sizeof(val_main->valid[0]); ++loop) {
+ val_main_can->cs_attr[loop] = val_main->cs_attr[loop];
+ }
+
+ // For Reading The controller table for config status
+ result_code = GetChildConfigKey(fl_run_ctrl_key, tmp);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
+ result_code);
+ DELETE_IF_NOT_NULL(fle_key);
+ DELETE_IF_NOT_NULL(fle_ctrlr_key);
+ DELETE_IF_NOT_NULL(fl_run_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+ result_code = ReadConfigDB(fl_run_ctrl_key, UPLL_DT_RUNNING ,
+ UNC_OP_READ, dbop_maintbl, dmi, CTRLRTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to read configuration from CandidateDb");
+ DELETE_IF_NOT_NULL(fle_key);
+ DELETE_IF_NOT_NULL(fle_ctrlr_key);
+ DELETE_IF_NOT_NULL(fl_run_key);
+ DELETE_IF_NOT_NULL(fl_run_ctrl_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+ val_flowlist_entry_ctrl *val_ctrlr_can = reinterpret_cast
+ <val_flowlist_entry_ctrl_t *>(GetVal(tmp));
+ val_flowlist_entry_ctrl *val_ctrlr_run = reinterpret_cast
+ <val_flowlist_entry_ctrl_t *>(GetVal(fl_run_ctrl_key));
+ val_ctrlr_can->cs_row_status = val_ctrlr_run->cs_row_status;
+
+ for (unsigned int loop = 0; loop < sizeof(val_ctrlr_run->valid)/
+ sizeof(val_ctrlr_run->valid[0]); ++loop) {
+ val_ctrlr_can->cs_attr[loop] = val_ctrlr_run->cs_attr[loop];
+ }
+ //End Reading The controller table for config status
result_code = UpdateConfigStatus(fle_key, op[i],
ctrlr_result[controller], nreq,
dmi, tmp);
- if (result_code != UPLL_RC_SUCCESS) break;
- CompareValidValue(fle_val1, fle_val2, false);
- result_code = UpdateConfigDB(fle_ctrlr_key,
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigStatus Failed ,err %d", result_code);
+ break;
+ }
+ DELETE_IF_NOT_NULL(fl_run_key);
+ DELETE_IF_NOT_NULL(fl_run_ctrl_key);
+ void *fle_val1 = GetVal(tmp);
+ void *fle_val2 = GetVal(nreq);
+ void *fle_val3 = GetVal(req);
+ CompareValidVal(fle_val1, fle_val2, fle_val3, false);
+ result_code = UpdateConfigDB(tmp,
UPLL_DT_RUNNING, op[i], dmi, CTRLRTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("UpdateConfigDB for ctrlr tbl is failed ");
- delete fle_ctrlr_key; // COVERITY RESOURCE LEAk
- delete fle_key;
+ DELETE_IF_NOT_NULL(fle_ctrlr_key);
+ DELETE_IF_NOT_NULL(fle_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
result_code = UpdateConfigDB(fle_key, UPLL_DT_RUNNING,
op[i], dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("UpdateConfigDB for main tbl is failed");
- delete fle_ctrlr_key; // COVERITY RESOURCE LEAk
+ DELETE_IF_NOT_NULL(fle_ctrlr_key);
+ DELETE_IF_NOT_NULL(fle_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
} // COV UNREACHABLE
EnqueCfgNotification(op[i], UPLL_DT_RUNNING,
- fle_ctrlr_key);
+ fle_key);
+ DELETE_IF_NOT_NULL(fle_key);
}
} else {
if (op[i] == UNC_OP_CREATE) {
- DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag };
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag |kOpInOutCs };
result_code = GetChildConfigKey(fle_key, req);
- result_code = ReadConfigDB(fle_key, UPLL_DT_CANDIDATE,
+ result_code = ReadConfigDB(fle_key, UPLL_DT_RUNNING,
UNC_OP_READ, dbop, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ReadConfigDB is failed -%d", result_code);
- return result_code;
+ if ((result_code != UPLL_RC_SUCCESS) &&
+ (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG("ReadConfigDB is failed -%d", result_code);
+ DELETE_IF_NOT_NULL(fle_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
}
/* Capability check
* req_header->operation = op[i];
* strcpy((char*)req_header->datatype,(char*)UNC_DT_CANDIDATE);
* result_code = ValidateCapability(req_header, vtn_ctrlr_key);
* */
+
+ // set consolidated config status to UNKNOWN to init vtn cs_status
+ // to the cs_status of first controller
+ uint32_t cur_instance_count;
+ result_code = GetInstanceCount(fle_key, NULL,
+ UPLL_DT_CANDIDATE, &cur_instance_count,
+ dmi, CTRLRTBL);
+ if ((result_code == UPLL_RC_SUCCESS) && (cur_instance_count == 1))
+ reinterpret_cast<val_flowlist_entry *>(GetVal(fle_key))->cs_row_status =
+ UNC_CS_UNKNOWN;
result_code = DupConfigKeyVal(fle_ctrlr_key, req, tbl);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("DupConfigKeyVal is failed -%d", result_code);
+ DELETE_IF_NOT_NULL(fle_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
GET_USER_DATA_CTRLR(fle_ctrlr_key, ctrlr_id);
string controller(reinterpret_cast<char *>(ctrlr_id));
result_code = UpdateConfigStatus(fle_key, op[i],
- ctrlr_result[controller], NULL,
+ ctrlr_result[controller], nreq,
dmi, fle_ctrlr_key);
} else if (op[i] == UNC_OP_DELETE) {
- result_code = GetChildConfigKey(fle_ctrlr_key, req);
- }
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("FlowListEntryMoMgr::GetChildConfigKey is failed -%d",
+ // Reading Main Running DB for delete op
+ DbSubOp dbop1 = { kOpReadSingle, kOpMatchNone,
+ kOpInOutFlag | kOpInOutCs };
+ GET_USER_DATA_CTRLR(req, ctrlr_id);
+ result_code = GetChildConfigKey(fl_ck_run, req);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
result_code);
- return result_code;
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+
+ GET_USER_DATA_CTRLR(req, ctrlr_id);
+ result_code = ReadConfigDB(fl_ck_run, UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop1, dmi, MAINTBL);
+
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Unable to read configuration from RunningDB");
+ DELETE_IF_NOT_NULL(fl_ck_run);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+ if (result_code == UPLL_RC_SUCCESS) {
+ //If Record exists in MainTBL then perform consolidation
+ result_code = SetFlowlistEntryConsolidatedStatus(fl_ck_run,
+ ctrlr_id, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Could not set consolidated status %d",
+ result_code);
+ DELETE_IF_NOT_NULL(fl_ck_run);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+ }
+ DELETE_IF_NOT_NULL(fl_ck_run);
+ result_code = GetChildConfigKey(fle_ctrlr_key, req);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error in getting the GetChildConfigKey,err=%d",
+ result_code);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+
}
+
result_code = UpdateConfigDB(fle_ctrlr_key, UPLL_DT_RUNNING,
op[i], dmi, CTRLRTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("UpdateConfigDB in ctrlr tbl is failed -%d",
result_code);
+ DELETE_IF_NOT_NULL(fle_ctrlr_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
if (op[i] != UNC_OP_DELETE) {
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("UpdateConfigDB in main tbl is failed -%d",
result_code);
+ DELETE_IF_NOT_NULL(fle_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
}
fle_key);
}
if (fle_key) delete fle_key;
+ DELETE_IF_NOT_NULL(fle_ctrlr_key);
fle_key = fle_ctrlr_key = NULL;
result_code = DalToUpllResCode(db_result);
}
UPLL_LOG_DEBUG("TxcopyCandidateto Running is successful -%d", result_code);
return result_code;
}
+upll_rc_t
+FlowListEntryMoMgr::SetFlowlistEntryConsolidatedStatus(ConfigKeyVal *ikey,
+ uint8_t *ctrlr_id,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ UPLL_LOG_DEBUG("Input controller id %s", ctrlr_id);
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ctrlr_ckv = NULL;
+ val_flowlist_entry_ctrl_t *ctrlr_val = NULL;
+ uint8_t *fle_exist_on_ctrlr = NULL;
+ bool applied = false, not_applied = false, invalid = false;
+ unc_keytype_configstatus_t c_status = UNC_CS_NOT_APPLIED;
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone,
+ kOpInOutCtrlr | kOpInOutDomain | kOpInOutCs };
+ if (!ikey || !dmi) {
+ UPLL_LOG_DEBUG("Invalid Input");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = GetChildConfigKey(ctrlr_ckv, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed err code %d", result_code);
+ return result_code;
+ }
+ result_code = ReadConfigDB(ctrlr_ckv, UPLL_DT_RUNNING, UNC_OP_READ, dbop, dmi,
+ CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB from ctrltbl failed err code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return result_code;
+ }
+
+ for (ConfigKeyVal *tmp = ctrlr_ckv; tmp != NULL;
+ tmp = tmp->get_next_cfg_key_val()) {
+
+ ctrlr_val = reinterpret_cast<val_flowlist_entry_ctrl_t *>(GetVal(tmp));
+ if (!ctrlr_val) {
+ UPLL_LOG_DEBUG("Controller Value is empty");
+ tmp = NULL;
+ delete ctrlr_ckv;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ GET_USER_DATA_CTRLR(tmp, fle_exist_on_ctrlr);
+ UPLL_LOG_DEBUG("internally read ctrollername %s", fle_exist_on_ctrlr);
+ if (!strcmp(reinterpret_cast<char *>(fle_exist_on_ctrlr),
+ reinterpret_cast<char *>(ctrlr_id)))
+ continue; // skipping entry of deleted controller
+
+ switch (ctrlr_val->cs_row_status) {
+ case UNC_CS_APPLIED:
+ applied = true;
+ break;
+ case UNC_CS_NOT_APPLIED:
+ not_applied = true;
+ break;
+ case UNC_CS_INVALID:
+ invalid = true;
+ break;
+ default:
+ UPLL_LOG_DEBUG("Invalid status");
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ // return UPLL_RC_ERR_GENERIC;
+ }
+ fle_exist_on_ctrlr = NULL;
+ }
+ if (invalid) {
+ c_status = UNC_CS_INVALID;
+ } else if (applied && !not_applied) {
+ c_status = UNC_CS_APPLIED;
+ } else if (!applied && not_applied) {
+ c_status = UNC_CS_NOT_APPLIED;
+ } else if (applied && not_applied) {
+ c_status = UNC_CS_PARTIALLY_APPLIED;
+ } else {
+ c_status = UNC_CS_APPLIED;
+ }
+ applied = not_applied =false;
+ // Set cs_status
+ val_flowlist_entry_t *fleval =
+ static_cast<val_flowlist_entry_t *>(GetVal(ikey));
+ fleval->cs_row_status = c_status;
+
+ for (unsigned int loop = 0; loop < sizeof(fleval->valid)/
+ sizeof(fleval->valid[0]); ++loop) {
+ for (ConfigKeyVal *tmp = ctrlr_ckv; tmp != NULL;
+ tmp = tmp->get_next_cfg_key_val()) {
+ ctrlr_val = reinterpret_cast<val_flowlist_entry_ctrl_t *>(GetVal(tmp));
+
+ GET_USER_DATA_CTRLR(tmp, fle_exist_on_ctrlr);
+ UPLL_LOG_DEBUG("internally read ctrollername %s", fle_exist_on_ctrlr);
+ if (!strcmp(reinterpret_cast<char *>(fle_exist_on_ctrlr),
+ reinterpret_cast<char *>(ctrlr_id)))
+ continue; // skipping entry of deleted controller
+ if (ctrlr_val->valid[loop] == UNC_VF_VALID) {
+ switch (ctrlr_val->cs_attr[loop]) {
+ case UNC_CS_APPLIED:
+ applied = true;
+ break;
+ case UNC_CS_NOT_APPLIED:
+ not_applied = true;
+ break;
+ case UNC_CS_INVALID:
+ invalid = true;
+ break;
+ default:
+ UPLL_LOG_DEBUG("Invalid status %d", ctrlr_val->cs_attr[loop]);
+ }
+ }
+ }
+ if (invalid) {
+ c_status = UNC_CS_INVALID;
+ } else if (applied && !not_applied) {
+ c_status = UNC_CS_APPLIED;
+ } else if (!applied && not_applied) {
+ c_status = UNC_CS_NOT_APPLIED;
+ } else if (applied && not_applied) {
+ c_status = UNC_CS_PARTIALLY_APPLIED;
+ } else {
+ c_status = UNC_CS_APPLIED;
+ }
+ fleval->cs_attr[loop] = c_status;
+ applied = not_applied =false;
+ }
+ DbSubOp dbop_update = {kOpNotRead, kOpMatchNone, kOpInOutCs};
+ result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_UPDATE, dmi,
+ &dbop_update, MAINTBL);
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return result_code;
+}
upll_rc_t FlowListEntryMoMgr::UpdateAuditConfigStatus(
unc_keytype_configstatus_t cs_status,
return UPLL_RC_ERR_GENERIC;
}
if (uuc::kUpllUcpCreate == phase )
- val->cs_row_status = cs_status;
+ val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
for ( unsigned int loop = 0;
loop < sizeof(val->valid)/sizeof(val->valid[0]);
++loop ) {
- if (cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop])
- val->cs_attr[loop] = cs_status;
- else if (cs_status == UNC_CS_APPLIED)
- val->cs_attr[loop] = cs_status;
+ if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
+ cs_status == UNC_CS_APPLIED)
+ val->cs_attr[loop] = cs_status;
}
return result_code;
}
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *ckv = NULL;
- DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutNone};
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutCs};
result_code = GetChildConfigKey(ckv, ikey);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("Unable to create ConfigKeyVal");
}
std::vector<list<unc_keytype_configstatus_t> > vec_attr;
std::list< unc_keytype_configstatus_t > list_cs_row;
- val_flowlist_entry_t *val;
+ val_flowlist_entry_ctrl_t *val;
for (unsigned int loop = 0; loop < sizeof(val->valid)/sizeof(val->valid[0]);
++loop) {
std::list< unc_keytype_configstatus_t > list_attr;
vec_attr.push_back(list_attr);
}
- for ( ; ckv != NULL ; ckv = ckv->get_next_cfg_key_val()) {
- val = reinterpret_cast<val_flowlist_entry_t *>(GetVal(ckv));
+ ConfigKeyVal *temp_ckv = ckv;
+ for ( ; temp_ckv != NULL ; temp_ckv = temp_ckv->get_next_cfg_key_val()) {
+ val = reinterpret_cast<val_flowlist_entry_ctrl_t *>(GetVal(temp_ckv));
list_cs_row.push_back((unc_keytype_configstatus_t)val->cs_row_status);
for (unsigned int loop = 0; loop < sizeof(val->valid)/sizeof(val->valid[0]);
++loop) {
vec_attr[loop].push_back((unc_keytype_configstatus_t)val->cs_attr[loop]);
}
}
+ DELETE_IF_NOT_NULL(ckv);
val_flowlist_entry_t *val_temp =
reinterpret_cast<val_flowlist_entry_t *>(GetVal(ikey));
val_temp->cs_row_status = GetConsolidatedCsStatus(list_cs_row);
const char *ctrlr_name) {
UPLL_FUNC_TRACE;
- // TODO(Author) added to bypass capability check
- return UPLL_RC_SUCCESS;
- // endTODO
-
upll_rc_t rt_code = UPLL_RC_ERR_GENERIC;
if ((NULL == req) || (NULL == key)) {
if (!ctrlr_name) {
ctrlr_name = static_cast<char *>(key->get_user_data());
}
- uint32_t dt_type = req->datatype;
- uint32_t operation = req->operation;
- uint32_t option1 = req->option1;
- uint32_t option2 = req->option2;
- UPLL_LOG_DEBUG("dt_type : (%d)"
- "operation : (%d)"
- "option1 : (%d)"
- "option2 : (%d)",
- dt_type, operation, option1, option2);
+ if (NULL == ctrlr_name) {
+ UPLL_LOG_DEBUG("ctrlr_name is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_DEBUG("ctrlr_name(%s), datatype :(%d)",
+ ctrlr_name, req->datatype);
bool result_code = false;
- uint32_t instance_count;
+ uint32_t max_instance_count = 0;
const uint8_t *attrs = NULL;
uint32_t max_attrs = 0;
- switch (operation) {
+ switch (req->operation) {
case UNC_OP_CREATE: {
result_code = GetCreateCapability(ctrlr_name, key->get_key_type(),
- &instance_count, &max_attrs, &attrs);
+ &max_instance_count, &max_attrs, &attrs);
+ if (result_code && (max_instance_count != 0) &&
+ (cur_instance_count >= max_instance_count)) {
+ UPLL_LOG_DEBUG("Instance count %d exceeds %d", cur_instance_count,
+ max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
break;
}
case UNC_OP_UPDATE: {
break;
}
default: {
- result_code = GetReadCapability(ctrlr_name, key->get_key_type(),
+ if (req->datatype == UPLL_DT_STATE) {
+ result_code = GetStateCapability(ctrlr_name, key->get_key_type(),
+ &max_attrs, &attrs);
+ } else {
+ result_code = GetReadCapability(ctrlr_name, key->get_key_type(),
&max_attrs, &attrs);
+ }
}
}
if (!result_code) {
UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s) "
"for opeartion(%d)",
- key->get_key_type(), ctrlr_name, operation);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
- }
-
- val_flowlist_entry_t *val_flowlist_entry = NULL;
- /** check valid key, val struct received in ConfigKeyVal */
- if (key->get_cfg_val() && (key->get_cfg_val()->get_st_num() ==
- IpctSt::kIpcStValFlowlistEntry)) {
- val_flowlist_entry =
- reinterpret_cast<val_flowlist_entry_t *>(key->get_cfg_val()->get_val());
+ key->get_key_type(), ctrlr_name, req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
- if ((operation == UNC_OP_CREATE) || (operation == UNC_OP_UPDATE)) {
- if (dt_type == UPLL_DT_CANDIDATE) {
- if (val_flowlist_entry) {
- if (max_attrs > 0) {
- return ValFlowlistEntryAttributeSupportCheck(val_flowlist_entry,
- attrs);
- } else {
- UPLL_LOG_DEBUG("Attribute list is empty for operation %d", operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else {
- UPLL_LOG_DEBUG("Error value struct is mandatory for CREATE/UPDATE");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else {
- UPLL_LOG_DEBUG("Unsupported datatype for CREATE/UPDATE");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else if (READ_SUPPORTED_OPERATION) {
- if (READ_SUPPORTED_DATATYPE) {
- if (option1 != UNC_OPT1_NORMAL) {
- UPLL_LOG_DEBUG(" Error: option1 is not NORMAL");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- if (option2 != UNC_OPT2_NONE) {
- UPLL_LOG_DEBUG(" Error: option2 is not NONE");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
+ val_flowlist_entry_t *val_flowlist_entry =
+ reinterpret_cast<val_flowlist_entry_t *>(GetVal(key));
- /** Valid options received, validate value struct */
- if (val_flowlist_entry) {
- if (max_attrs > 0) {
- return ValFlowlistEntryAttributeSupportCheck(val_flowlist_entry,
+ if (val_flowlist_entry) {
+ if (max_attrs > 0) {
+ return ValFlowlistEntryAttributeSupportCheck(val_flowlist_entry,
attrs);
- } else {
- UPLL_LOG_DEBUG("Attribute list is empty for operation %d", operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- }
- return UPLL_RC_SUCCESS;
} else {
- UPLL_LOG_DEBUG("Error Unsupported datatype(%d)", dt_type);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d", req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
- } else if (OPEARTION_WITH_VAL_STRUCT_NONE) {
- /** Value struct is NONE for this operations */
- UPLL_LOG_DEBUG("Skip Attribute check, Operation type is %d", operation);
- return UPLL_RC_SUCCESS;
}
-
- UPLL_LOG_DEBUG("Error Unsupported operation ");
- return UPLL_RC_ERR_CFG_SYNTAX;
+ return UPLL_RC_SUCCESS;
}
upll_rc_t FlowListEntryMoMgr::ValFlowlistEntryAttributeSupportCheck(
UPLL_FUNC_TRACE;
/** validate dst_mac, src_mac attributes*/
- if (ValidateMacAttribute(val_flowlist_entry, attrs) != UPLL_RC_SUCCESS) {
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
+ ValidateMacAttribute(val_flowlist_entry, attrs);
/** validate dst_ip, dst_ip_prefixlen, src_ip, src_ipprefixlen attributes */
- if (ValidateIPAttribute(val_flowlist_entry, attrs) != UPLL_RC_SUCCESS) {
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
+ ValidateIPAttribute(val_flowlist_entry, attrs);
/** validate mac_eth_type attribyte */
- if (ValidateMacEthTypeAttribute(val_flowlist_entry, attrs)
- != UPLL_RC_SUCCESS) {
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
+ ValidateMacEthTypeAttribute(val_flowlist_entry, attrs);
/** validate vlan_priority attribute */
- if (ValidateVlanPriorityAttribute(val_flowlist_entry, attrs)
- != UPLL_RC_SUCCESS) {
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
+ ValidateVlanPriorityAttribute(val_flowlist_entry, attrs);
/** validates dst_ipv6 and src_ipv6 attributes and its length*/
- if (ValidateIPV6Attribute(val_flowlist_entry, attrs) != UPLL_RC_SUCCESS) {
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
+ ValidateIPV6Attribute(val_flowlist_entry, attrs);
/** validates ip_proto attribute */
- if (ValidateIpProtoAttribute(val_flowlist_entry, attrs) != UPLL_RC_SUCCESS) {
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
+ ValidateIpProtoAttribute(val_flowlist_entry, attrs);
- if (ValidateIpDscpAttribute(val_flowlist_entry, attrs) != UPLL_RC_SUCCESS) {
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
+ ValidateIpDscpAttribute(val_flowlist_entry, attrs);
/** validates l4 dstport, srxport and endpt attributes */
- if (ValidateL4PortAttribute(val_flowlist_entry, attrs) != UPLL_RC_SUCCESS) {
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
+ ValidateL4PortAttribute(val_flowlist_entry, attrs);
+
/** validates icmp_type icmp_code, icmpv6_type, icmpv6_code attributes */
- if (ValidateICMPAttribute(val_flowlist_entry, attrs) != UPLL_RC_SUCCESS) {
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
+ ValidateICMPAttribute(val_flowlist_entry, attrs);
+
return UPLL_RC_SUCCESS;
}
-upll_rc_t FlowListEntryMoMgr::ValidateIpProtoAttribute(
+void FlowListEntryMoMgr::ValidateIpProtoAttribute(
val_flowlist_entry_t *val_flowlist_entry, const uint8_t *attrs) {
UPLL_FUNC_TRACE;
if (attrs[unc::capa::flowlist_entry::kCapIpProtocol] == 0) {
UPLL_LOG_DEBUG("ip_proto attr is not supported by ctrlr");
val_flowlist_entry->valid[UPLL_IDX_IP_PROTOCOL_FLE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ UNC_VF_NOT_SUPPORTED;
}
}
- return UPLL_RC_SUCCESS;
}
-upll_rc_t FlowListEntryMoMgr::ValidateVlanPriorityAttribute(
+void FlowListEntryMoMgr::ValidateVlanPriorityAttribute(
val_flowlist_entry_t *val_flowlist_entry, const uint8_t *attrs) {
UPLL_FUNC_TRACE;
if (attrs[unc::capa::flowlist_entry::kCapVlanPriority] == 0) {
UPLL_LOG_DEBUG("VlanPriority attr is not supported by ctrlr");
val_flowlist_entry->valid[UPLL_IDX_VLAN_PRIORITY_FLE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ UNC_VF_NOT_SUPPORTED;
}
}
- return UPLL_RC_SUCCESS;
}
-upll_rc_t FlowListEntryMoMgr::ValidateMacEthTypeAttribute(
+void FlowListEntryMoMgr::ValidateMacEthTypeAttribute(
val_flowlist_entry_t *val_flowlist_entry, const uint8_t *attrs) {
UPLL_FUNC_TRACE;
if (attrs[unc::capa::flowlist_entry::kCapMacEthType] == 0) {
UPLL_LOG_DEBUG(" Eth type attr is not supported by ctrlr");
val_flowlist_entry->valid[UPLL_IDX_MAC_ETH_TYPE_FLE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ UNC_VF_NOT_SUPPORTED;
}
}
- return UPLL_RC_SUCCESS;
}
-upll_rc_t FlowListEntryMoMgr::ValidateIpDscpAttribute(
+void FlowListEntryMoMgr::ValidateIpDscpAttribute(
val_flowlist_entry_t *val_flowlist_entry, const uint8_t *attrs) {
UPLL_FUNC_TRACE;
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::flowlist_entry::kCapIpDscp] == 0) {
UPLL_LOG_DEBUG(" IP_DSCP attr is not supported by ctrlr");
- val_flowlist_entry->valid[UPLL_IDX_IP_DSCP_FLE] = UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ val_flowlist_entry->valid[UPLL_IDX_IP_DSCP_FLE] = UNC_VF_NOT_SUPPORTED;
}
}
- return UPLL_RC_SUCCESS;
}
-upll_rc_t FlowListEntryMoMgr::ValidateMacAttribute(
+void FlowListEntryMoMgr::ValidateMacAttribute(
val_flowlist_entry_t *val_flowlist_entry, const uint8_t *attrs) {
-
UPLL_FUNC_TRACE;
+
if ((val_flowlist_entry->valid[UPLL_IDX_MAC_DST_FLE] == UNC_VF_VALID)
|| (val_flowlist_entry->valid[UPLL_IDX_MAC_DST_FLE]
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::flowlist_entry::kCapMacDst] == 0) {
UPLL_LOG_DEBUG(" DST_MAC attr is not supported by ctrlr");
- val_flowlist_entry->valid[UPLL_IDX_MAC_DST_FLE] = UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ val_flowlist_entry->valid[UPLL_IDX_MAC_DST_FLE] = UNC_VF_NOT_SUPPORTED;
}
}
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::flowlist_entry::kCapMacSrc] == 0) {
UPLL_LOG_DEBUG(" SRC_MAC attr is not supported by ctrlr");
- val_flowlist_entry->valid[UPLL_IDX_MAC_SRC_FLE] = UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ val_flowlist_entry->valid[UPLL_IDX_MAC_SRC_FLE] = UNC_VF_NOT_SUPPORTED;
}
}
- return UPLL_RC_SUCCESS;
}
-upll_rc_t FlowListEntryMoMgr::ValidateIPAttribute(
+void FlowListEntryMoMgr::ValidateIPAttribute(
val_flowlist_entry_t *val_flowlist_entry, const uint8_t *attrs) {
UPLL_FUNC_TRACE;
-
+
if ((val_flowlist_entry->valid[UPLL_IDX_DST_IP_FLE] == UNC_VF_VALID)
|| (val_flowlist_entry->valid[UPLL_IDX_DST_IP_FLE]
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::flowlist_entry::kCapDstIp] == 0) {
UPLL_LOG_DEBUG(" DST_IP attr is not supported by ctrlr");
- val_flowlist_entry->valid[UPLL_IDX_DST_IP_FLE] = UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ val_flowlist_entry->valid[UPLL_IDX_DST_IP_FLE] = UNC_VF_NOT_SUPPORTED;
}
}
if (attrs[unc::capa::flowlist_entry::kCapDstIpPrefix] == 0) {
UPLL_LOG_DEBUG(" DST_IP_PREFIX attr is not supported by ctrlr");
val_flowlist_entry->valid[UPLL_IDX_DST_IP_PREFIX_FLE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ UNC_VF_NOT_SUPPORTED;
}
}
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::flowlist_entry::kCapSrcIp] == 0) {
UPLL_LOG_DEBUG(" SRC_IP attr is not supported by ctrlr");
- val_flowlist_entry->valid[UPLL_IDX_SRC_IP_FLE] = UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ val_flowlist_entry->valid[UPLL_IDX_SRC_IP_FLE] = UNC_VF_NOT_SUPPORTED;
}
}
if (attrs[unc::capa::flowlist_entry::kCapSrcIpPrefix] == 0) {
UPLL_LOG_DEBUG(" SRC_IP_PREFIX attr is not supported by ctrlr");
val_flowlist_entry->valid[UPLL_IDX_SRC_IP_PREFIX_FLE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ UNC_VF_NOT_SUPPORTED;
}
}
- return UPLL_RC_SUCCESS;
}
-upll_rc_t FlowListEntryMoMgr::ValidateIPV6Attribute(
+void FlowListEntryMoMgr::ValidateIPV6Attribute(
val_flowlist_entry_t *val_flowlist_entry, const uint8_t *attrs) {
UPLL_FUNC_TRACE;
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::flowlist_entry::kCapDstIpV6] == 0) {
UPLL_LOG_DEBUG(" DST_IP_V6 attr is not supported by ctrlr");
- val_flowlist_entry->valid[UPLL_IDX_DST_IP_V6_FLE] = UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ val_flowlist_entry->valid[UPLL_IDX_DST_IP_V6_FLE] = UNC_VF_NOT_SUPPORTED;
}
}
if (attrs[unc::capa::flowlist_entry::kCapDstIpV6Prefix] == 0) {
UPLL_LOG_DEBUG(" DST_IP_V6_PREFIX attr is not supported by ctrlr");
val_flowlist_entry->valid[UPLL_IDX_DST_IP_V6_PREFIX_FLE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ UNC_VF_NOT_SUPPORTED;
}
}
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::flowlist_entry::kCapSrcIpV6] == 0) {
UPLL_LOG_DEBUG(" SRC_IP_V6 attr is not supported by ctrlr");
- val_flowlist_entry->valid[UPLL_IDX_SRC_IP_V6_FLE] = UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ val_flowlist_entry->valid[UPLL_IDX_SRC_IP_V6_FLE] = UNC_VF_NOT_SUPPORTED;
}
}
if (attrs[unc::capa::flowlist_entry::kCapSrcIpV6Prefix] == 0) {
UPLL_LOG_DEBUG(" SRC_IP_V6_PREFIX attr is not supported by ctrlr");
val_flowlist_entry->valid[UPLL_IDX_SRC_IP_V6_PREFIX_FLE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ UNC_VF_NOT_SUPPORTED;
}
}
- return UPLL_RC_SUCCESS;
}
-upll_rc_t FlowListEntryMoMgr::ValidateL4PortAttribute(
+void FlowListEntryMoMgr::ValidateL4PortAttribute(
val_flowlist_entry_t *val_flowlist_entry, const uint8_t *attrs) {
UPLL_FUNC_TRACE;
if (attrs[unc::capa::flowlist_entry::kCapL4DstPort] == 0) {
UPLL_LOG_DEBUG(" L4_DST_PORT attr is not supported by ctrlr");
val_flowlist_entry->valid[UPLL_IDX_L4_DST_PORT_FLE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ UNC_VF_NOT_SUPPORTED;
}
}
if (attrs[unc::capa::flowlist_entry::kCapL4DstPortEndpt] == 0) {
UPLL_LOG_DEBUG(" L4_DST_PORT_ENDPT attr is not supported by ctrlr");
val_flowlist_entry->valid[UPLL_IDX_L4_DST_PORT_ENDPT_FLE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ UNC_VF_NOT_SUPPORTED;
}
}
if (attrs[unc::capa::flowlist_entry::kCapL4SrcPort] == 0) {
UPLL_LOG_DEBUG(" L4_SRC_PORT attr is not supported by ctrlr");
val_flowlist_entry->valid[UPLL_IDX_L4_SRC_PORT_FLE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ UNC_VF_NOT_SUPPORTED;
}
}
if (attrs[unc::capa::flowlist_entry::kCapL4SrcPortEndpt] == 0) {
UPLL_LOG_DEBUG(" L4_SRC_PORT_ENDPT attr is not supported by ctrlr");
val_flowlist_entry->valid[UPLL_IDX_L4_SRC_PORT_ENDPT_FLE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ UNC_VF_NOT_SUPPORTED;
}
}
-
- return UPLL_RC_SUCCESS;
}
-upll_rc_t FlowListEntryMoMgr::ValidateICMPAttribute(
+void FlowListEntryMoMgr::ValidateICMPAttribute(
val_flowlist_entry_t *val_flowlist_entry, const uint8_t *attrs) {
UPLL_FUNC_TRACE;
-
+
if ((val_flowlist_entry->valid[UPLL_IDX_ICMP_TYPE_FLE] == UNC_VF_VALID)
|| (val_flowlist_entry->valid[UPLL_IDX_ICMP_TYPE_FLE]
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::flowlist_entry::kCapIcmpType] == 0) {
UPLL_LOG_DEBUG(" ICMP_TYPE attr is not supported by ctrlr");
- val_flowlist_entry->valid[UPLL_IDX_ICMP_TYPE_FLE] = UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ val_flowlist_entry->valid[UPLL_IDX_ICMP_TYPE_FLE] = UNC_VF_NOT_SUPPORTED;
}
}
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::flowlist_entry::kCapIcmpCode] == 0) {
UPLL_LOG_DEBUG(" ICMP CODE attr is not supported by ctrlr");
- val_flowlist_entry->valid[UPLL_IDX_ICMP_CODE_FLE] = UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ val_flowlist_entry->valid[UPLL_IDX_ICMP_CODE_FLE] = UNC_VF_NOT_SUPPORTED;
}
}
if (attrs[unc::capa::flowlist_entry::kCapIcmpV6Type] == 0) {
UPLL_LOG_DEBUG(" ICMP_V6_TYPE attr is not supported by ctrlr");
val_flowlist_entry->valid[UPLL_IDX_ICMP_V6_TYPE_FLE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ UNC_VF_NOT_SUPPORTED;
}
}
if (attrs[unc::capa::flowlist_entry::kCapIcmpV6Code] == 0) {
UPLL_LOG_DEBUG(" ICMP_V6 attr is not supported by ctrlr");
val_flowlist_entry->valid[UPLL_IDX_ICMP_V6_CODE_FLE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ UNC_VF_NOT_SUPPORTED;
}
}
-
- UPLL_LOG_DEBUG("ICMP attribute validation is success");
- return UPLL_RC_SUCCESS;
}
upll_rc_t FlowListEntryMoMgr::ValidateMessage(IpcReqRespHeader *req,
UPLL_LOG_DEBUG(" invalid option2(%d)", req->option2);
return UPLL_RC_ERR_INVALID_OPTION2;
}
-
- if (UPLL_RC_SUCCESS !=
- (rt_code = ValidateFlowlistEntryKey(key, req->operation))) {
- UPLL_LOG_DEBUG("KT_FLOWLIST_ENTRY key structure syntax "
- "validation failed: Err code-%d",
- rt_code);
- return rt_code;
- }
+
+ if (UPLL_RC_SUCCESS !=
+ (rt_code = ValidateFlowlistEntryKey(key, req->operation))) {
+ UPLL_LOG_DEBUG("KT_FLOWLIST_ENTRY key structure syntax "
+ "validation failed: Err code-%d",
+ rt_code);
+ return rt_code;
+ }
if (UPLL_RC_SUCCESS != (rt_code = ValidateFlowlistEntryVal(
key, req->operation, req->datatype))) {
UPLL_LOG_DEBUG("IsFlowListMatched failed in fle %d", result_code);
return result_code;
}
+ if (UNC_OP_CREATE == req->operation) {
+ result_code = SetRenameFlag(ikey, dmi, req);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("SetRenameFlag failed %d", result_code);
+ return result_code;
+ }
+ }
UPLL_LOG_DEBUG("ValidateAttribute Successfull.");
return result_code;
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- if (UNC_OP_UPDATE == req->operation) {
+ if (UNC_OP_UPDATE == req->operation ||
+ UNC_OP_CREATE == req->operation) {
key_flowlist_entry_t *key_fle = reinterpret_cast
<key_flowlist_entry_t *>(ikey->get_key());
PolicingProfileEntryMoMgr *mgr =
(key_fle->flowlist_key.flowlist_name), req->datatype, dmi);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("IsFlowListMatched failed from ppe %d", result_code);
+ return UPLL_RC_ERR_CFG_SEMANTIC;
}
}
return result_code;
key_flowlist_entry_t *key_flowlist = NULL;
upll_rc_t result_code = UPLL_RC_SUCCESS;
-
- if (UNC_KT_FLOWLIST_ENTRY == ikey->get_key_type()) {
- key_rename_vnode_info_t *key_rename =
- reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
- key_flowlist =
- reinterpret_cast<key_flowlist_entry_t *>
- (ConfigKeyVal::Malloc(sizeof(key_flowlist_entry_t)));
- uuu::upll_strncpy(key_flowlist->flowlist_key.flowlist_name,
- key_rename->old_flowlist_name,
- (kMaxLenFlowListName+1));
- okey = new ConfigKeyVal(UNC_KT_FLOWLIST,
- IpctSt::kIpcStKeyFlowlistEntry, key_flowlist, NULL);
- }
+ key_rename_vnode_info_t *key_rename =
+ reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
+ key_flowlist =
+ reinterpret_cast<key_flowlist_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_flowlist_entry_t)));
+ uuu::upll_strncpy(key_flowlist->flowlist_key.flowlist_name,
+ key_rename->old_flowlist_name,
+ (kMaxLenFlowListName+1));
+ okey = new ConfigKeyVal(UNC_KT_FLOWLIST_ENTRY,
+ IpctSt::kIpcStKeyFlowlistEntry, key_flowlist, NULL);
if (!okey) {
free(key_flowlist);
+ UPLL_LOG_DEBUG("Copy to ConfigKey Failed");
result_code = UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_DEBUG("ValidateMessage failed, Error - %d", result_code);
return result_code;
}
-
+ result_code = ValidateAttribute(ikey, dmi, req);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ValidateAttribute failed %d", result_code);
+ return result_code;
+ }
// validate syntax for parameters that has
// database dependency
result_code = ValidateFlowlistEntryVal(req, ikey, dmi);
result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_READ, dmi);
if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS
|| result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
-// std::cout << "Record already exists in Candidate DB\n";
+// std::cout << "Record already exists in Candidate DB";
return result_code;
}
-
+ if (UPLL_DT_CANDIDATE == req->datatype) {
// Check if flowlist entry exists in RUNNING DB and move it to CANDIDATE DB
result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING,
UNC_OP_READ, dmi, MAINTBL);
result_code = RestoreChildren(ikey, req->datatype, UPLL_DT_RUNNING, dmi);
if (result_code != UPLL_RC_SUCCESS) {
return UPLL_RC_ERR_GENERIC;
+ }
}
- } else if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ }
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
// create a record in CANDIDATE DB
+ result_code = SetRenameFlag(ikey, dmi, req);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("SetRenameFlag failed %d", result_code);
+ return result_code;
+ }
+
result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_CREATE, dmi);
- return result_code;
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed for maintbl %d", result_code);
+ return result_code;
+ }
+ result_code = CreateEntryCtrlrTbl(req, ikey, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("CreateEntryCtrlrTbl failed %d", result_code);
+ return result_code;
+ }
} else {
- UPLL_LOG_DEBUG("Error in reading DB\n");
+ UPLL_LOG_DEBUG("Error in reading DB");
}
return result_code;
}
+upll_rc_t FlowListEntryMoMgr::CreateEntryCtrlrTbl(IpcReqRespHeader *req,
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ ConfigKeyVal *pkey = NULL;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ result_code = GetParentConfigKey(pkey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ return result_code;
+ }
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr};
+ FlowListMoMgr *mgr =
+ reinterpret_cast<FlowListMoMgr *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_FLOWLIST)));
+ if (NULL == mgr) {
+ UPLL_LOG_DEBUG("mgr is NULL");
+ DELETE_IF_NOT_NULL(pkey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = mgr->ReadConfigDB(pkey, req->datatype, UNC_OP_READ,
+ dbop, dmi, CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("No record in flowlist ctrlrtbl");
+ DELETE_IF_NOT_NULL(pkey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(pkey);
+ return result_code;
+ }
+ ConfigKeyVal *temp_pkey = pkey;
+ while (NULL != temp_pkey) {
+ ConfigKeyVal *ctrlr_ckv = NULL;
+ result_code = GetChildConfigKey(ctrlr_ckv, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(pkey);
+ return result_code;
+ }
+ uint8_t *ctrlr_id = NULL;
+ uuc::CtrlrMgr *ctrlr_mgr = uuc::CtrlrMgr::GetInstance();
+ unc_keytype_ctrtype_t ctrlrtype = UNC_CT_UNKNOWN;
+ GET_USER_DATA_CTRLR(temp_pkey, ctrlr_id);
+ SET_USER_DATA_CTRLR(ctrlr_ckv, ctrlr_id);
+
+ ConfigKeyVal *temp_key = NULL;
+ result_code = GetChildConfigKey(temp_key, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(pkey);
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ UPLL_LOG_DEBUG("GetChildConfigKey failed(%d)", result_code);
+ return result_code;
+ }
+
+ result_code = GetInstanceCount(temp_key, reinterpret_cast<char *>(ctrlr_id),
+ req->datatype,
+ &cur_instance_count,
+ dmi, CTRLRTBL);
+ DELETE_IF_NOT_NULL(temp_key);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetInstanceCount failed(%d)", result_code);
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ DELETE_IF_NOT_NULL(pkey);
+ return result_code;
+ }
+
+ // Validate whether the attributes supported by controller or not
+ result_code = ValidateCapability(req, ikey, reinterpret_cast<char *>(
+ ctrlr_id));
+ if (result_code != UPLL_RC_SUCCESS) {
+ // Error should be returned if the failure code is other then ctrlr not
+ // supported
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ if ((!ctrlr_mgr->GetCtrlrType(reinterpret_cast<char *>(ctrlr_id),
+ req->datatype, &ctrlrtype)) || (ctrlrtype != UNC_CT_PFC)) {
+ result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_DEBUG("Controller type is %d", ctrlrtype);
+ temp_pkey = temp_pkey->get_next_cfg_key_val();
+ continue;
+ }
+ DELETE_IF_NOT_NULL(pkey);
+ UPLL_LOG_DEBUG("ValidateCapability Failed: result_code=%d",
+ result_code);
+ return result_code;
+ }
+ val_flowlist_entry_t *val_fle = reinterpret_cast<val_flowlist_entry_t *>
+ (GetVal(temp_pkey));
+ /** change NOT_SOPPRTED attribute to INVALID to store in ctrlr table */
+ SetValidAttributesForController(val_fle);
+
+ val_flowlist_entry_ctrl_t *val_ctrlr = reinterpret_cast
+ <val_flowlist_entry_ctrl_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_flowlist_entry_ctrl_t)));
+ for ( unsigned int loop = 0;
+ loop < sizeof(val_fle->valid)/sizeof(val_fle->valid[0]);
+ ++loop ) {
+ val_ctrlr->valid[loop] = val_fle->valid[loop];
+ }
+ ctrlr_ckv->AppendCfgVal(IpctSt::kIpcStValFlowlistEntry, val_ctrlr);
+ DbSubOp dbop1 = {kOpNotRead, kOpMatchNone, kOpInOutCtrlr};
+ result_code = UpdateConfigDB(ctrlr_ckv, req->datatype, UNC_OP_CREATE,
+ dmi, &dbop1, CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(pkey);
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ temp_pkey = temp_pkey->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(pkey);
+ return UPLL_RC_SUCCESS;
+}
+
upll_rc_t FlowListEntryMoMgr::UpdateMo(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
DalDmlIntf *dmi) {
dbop, dmi, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("Record does Not Exists");
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
result_code = ValidateAttribute(okey, dmi, req);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("Validate Attribute is Failed");
- delete okey;
- okey = NULL;
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("DupConfigKeyVal is failed result_code = %d",
result_code);
- delete okey;
- okey = NULL;
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_UPDATE,
dmi, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("Updation Failure in DB : %d", result_code);
- delete okey;
- okey = NULL;
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
+ DbSubOp dbop_ctrlr = {kOpReadMultiple, kOpMatchNone,
+ kOpInOutCtrlr | kOpInOutDomain | kOpInOutFlag};
result_code = ReadConfigDB(okey, req->datatype, UNC_OP_READ,
- dbop, dmi, CTRLRTBL);
+ dbop_ctrlr, dmi, CTRLRTBL);
if (UPLL_RC_SUCCESS == result_code ||
result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
UPLL_LOG_DEBUG("Record Exists in flowlist controller table");
- GET_USER_DATA_CTRLR(okey, ctrlr_id);
- result_code = UpdateControllerTable(ctrl_key,
+ ConfigKeyVal *tmp_key = okey;
+ while (tmp_key != NULL) {
+ GET_USER_DATA_CTRLR(tmp_key, ctrlr_id);
+ result_code = UpdateControllerTable(ctrl_key,
UNC_OP_UPDATE,
+ req->datatype,
dmi,
reinterpret_cast<char*>(ctrlr_id));
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Failed to Update the controller Table err(%d)",
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Update the controller Table err(%d)",
result_code);
- DELETE_IF_NOT_NULL(okey);
- DELETE_IF_NOT_NULL(ctrl_key);
- okey = NULL;
- ctrl_key = NULL;
- return result_code;
- }
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(ctrl_key);
+ okey = NULL;
+ ctrl_key = NULL;
+ return result_code;
+ }
+ ctrlr_id = NULL;
+ tmp_key = tmp_key->get_next_cfg_key_val();
+ }
}
+
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(ctrl_key);
UPLL_LOG_TRACE("Updated Done Successfully %d", result_code);
return UPLL_RC_SUCCESS;
}
if (op != UNC_OP_DELETE) {
result_code = DupConfigKeyVal(ck_fle, fle_key, MAINTBL);
if (!ck_fle || result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
return UPLL_RC_ERR_GENERIC;
}
fle_val = reinterpret_cast<val_flowlist_entry_t *>(GetVal(ck_fle));
if (!fle_val) {
- UPLL_LOG_DEBUG("invalid val \n");
+ UPLL_LOG_DEBUG("invalid val");
return UPLL_RC_ERR_GENERIC;
}
} else {
result_code = GetChildConfigKey(ck_fle, fle_key);
if (!ck_fle || result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
return UPLL_RC_ERR_GENERIC;
}
}
switch (op) {
case UNC_OP_CREATE:
- fle_val->cs_row_status = UNC_CS_NOT_APPLIED;
+ fle_val->cs_row_status = UNC_CS_APPLIED;
break;
case UNC_OP_UPDATE:
- fleval = reinterpret_cast<void *>(&fle_val);
+ fleval = GetVal(ck_fle);
nfleval = (nreq)?GetVal(nreq):NULL;
if (!nfleval) {
- UPLL_LOG_DEBUG("Invalid param\n");
+ UPLL_LOG_DEBUG("Invalid param");
return UPLL_RC_ERR_GENERIC;
}
- CompareValidValue(fleval, nfleval, false);
+ CompareValidValue(fleval, nfleval, true);
+ fle_val->cs_row_status =
+ reinterpret_cast<val_flowlist_entry_t*>(GetVal(nreq))->cs_row_status;
+
break;
case UNC_OP_DELETE:
break;
default:
- UPLL_LOG_DEBUG("Inalid operation\n");
+ UPLL_LOG_DEBUG("Inalid operation");
return UPLL_RC_ERR_GENERIC;
}
- result_code = UpdateConfigDB(ck_fle, UPLL_DT_STATE, op, dmi, MAINTBL);
+
+ DbSubOp dbop = {kOpNotRead, kOpMatchNone, kOpInOutNone};
+ dbop.inoutop = kOpInOutCs;
+ result_code = UpdateConfigDB(ck_fle, UPLL_DT_STATE, op, dmi,&dbop, MAINTBL);
EnqueCfgNotification(op, UPLL_DT_RUNNING, ck_fle);
delete ck_fle;
return result_code;
SET_USER_DATA(okey, ikey);
return UPLL_RC_SUCCESS;
}
+
+upll_rc_t FlowListEntryMoMgr::SetValidAudit(ConfigKeyVal *&ikey) {
+ UPLL_FUNC_TRACE;
+ val_flowlist_entry_t *val = reinterpret_cast
+ <val_flowlist_entry_t *>(GetVal(ikey));
+ if (NULL == val) {
+ UPLL_LOG_DEBUG("val is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ for ( unsigned int loop = 0;
+ loop < sizeof(val->valid)/sizeof(val->valid[0]);
+ ++loop ) {
+ val->cs_attr[loop] = UNC_CS_APPLIED;
+ }
+ val->cs_row_status = UNC_CS_APPLIED;
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t FlowListEntryMoMgr::UpdateConfigStatus(ConfigKeyVal *main_ckv,
+ unc_keytype_operation_t op,
+ uint32_t driver_result,
+ ConfigKeyVal *upd_key,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ctrlr_key) {
+ UPLL_FUNC_TRACE;
+ // upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_flowlist_entry_ctrl_t *ctrlr_val;
+
+ val_flowlist_entry_t *val_main = reinterpret_cast
+ <val_flowlist_entry_t *>(GetVal(main_ckv));
+ uint8_t cs_status;
+ unc_keytype_configstatus_t ctrlr_status =
+ (driver_result == UPLL_RC_SUCCESS) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
+ ctrlr_val = reinterpret_cast<val_flowlist_entry_ctrl_t *>(GetVal(ctrlr_key));
+ if (ctrlr_val == NULL) return UPLL_RC_ERR_GENERIC;
+ cs_status = (val_main->cs_row_status);
+ UPLL_LOG_TRACE("cs_status %d ctrlr_status %d\n", cs_status, ctrlr_status);
+ if (op == UNC_OP_CREATE) {
+ ctrlr_val->cs_row_status = ctrlr_status;
+ if (val_main->cs_row_status == UNC_CS_UNKNOWN) {
+ /* first entry in ctrlr table */
+ cs_status = ctrlr_status;
+ } else if (val_main->cs_row_status == UNC_CS_INVALID) {
+ cs_status = UNC_CS_INVALID;
+ } else if (val_main->cs_row_status == UNC_CS_APPLIED) {
+ if (ctrlr_status == UNC_CS_NOT_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ }
+ } else if (val_main->cs_row_status == UNC_CS_NOT_APPLIED) {
+ if (ctrlr_status == UNC_CS_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ }
+ } else {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ }
+ val_main->cs_row_status = cs_status;
+ }
+
+ val_flowlist_entry_ctrl_t *run_ctrlr_val =
+ reinterpret_cast<val_flowlist_entry_ctrl_t *>
+ (GetVal(upd_key));
+ // Updating the Controller cs_row_status
+ if ((op == UNC_OP_UPDATE) && (upd_key != NULL)) {
+ // ctrlr_val->cs_row_status = run_ctrlr_val->cs_row_status;
+ void *valmain = reinterpret_cast<void *>(val_main);
+ CompareValidValue(valmain, (GetVal(upd_key)), true);
+ for (unsigned int loop = 0; loop < sizeof(val_main->valid)/
+ sizeof(val_main->valid[0]); ++loop) {
+ if ((val_main->valid[loop] != UNC_VF_INVALID) && (val_main->valid[loop]
+ != UNC_VF_VALID_NO_VALUE)) {
+ if (ctrlr_status == UNC_CS_APPLIED) {
+ if(ctrlr_val->valid[loop] == UNC_VF_VALID) {
+ ctrlr_val->cs_attr[loop] = UNC_CS_APPLIED;
+ }
+ if(val_main->cs_attr[loop] == UNC_CS_UNKNOWN) {
+ cs_status = UNC_CS_APPLIED;
+ } else if (val_main->cs_attr[loop] == UNC_CS_NOT_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED ;
+ } else if (val_main->cs_attr[loop] == UNC_CS_INVALID) {
+ cs_status = UNC_CS_INVALID;
+ }
+ } else if (ctrlr_status == UNC_CS_NOT_APPLIED) {
+ ctrlr_val->cs_attr[loop] = UNC_CS_NOT_APPLIED;
+ if(val_main->cs_attr[loop] == UNC_CS_UNKNOWN) {
+ cs_status = UNC_CS_NOT_APPLIED;
+ } else if(val_main->cs_attr[loop] == UNC_CS_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED ;
+ } else if (val_main->cs_attr[loop] == UNC_CS_INVALID) {
+ cs_status = UNC_CS_INVALID;
+ }
+ }
+ val_main->cs_attr[loop] = cs_status;
+ UPLL_LOG_DEBUG("UpdatePath tbl cs_attr : %d", val_main->cs_attr[loop]);
+ }
+ if (val_main->valid[loop] == UNC_VF_INVALID) {
+ if (ctrlr_status == UNC_CS_APPLIED){
+ if (run_ctrlr_val->valid[loop] == UNC_VF_VALID) {
+ if (val_main->cs_attr[loop] == UNC_CS_PARTIALLY_APPLIED) {
+ val_main->cs_attr[loop] = UNC_CS_PARTIALLY_APPLIED;
+ } else if (val_main->cs_attr[loop] == UNC_CS_NOT_APPLIED) {
+ val_main->cs_attr[loop] = UNC_CS_NOT_APPLIED;
+ } else if (val_main->cs_attr[loop] == UNC_CS_INVALID) {
+ val_main->cs_attr[loop] = UNC_CS_INVALID;
+ } else {
+ val_main->cs_attr[loop] = ctrlr_status;
+ }
+ }
+ if (ctrlr_val->cs_attr[loop] == UNC_CS_APPLIED) {
+ ctrlr_val->cs_attr[loop] = ctrlr_status;
+ }
+ } else if (ctrlr_status == UNC_CS_NOT_APPLIED) {
+ if (run_ctrlr_val->valid[loop] == UNC_VF_VALID) {
+ if (val_main->cs_attr[loop] == UNC_CS_PARTIALLY_APPLIED) {
+ val_main->cs_attr[loop] = UNC_CS_PARTIALLY_APPLIED;
+ } else if (val_main->cs_attr[loop] == UNC_CS_NOT_APPLIED) {
+ val_main->cs_attr[loop] = UNC_CS_NOT_APPLIED;
+ } else if (val_main->cs_attr[loop] == UNC_CS_INVALID) {
+ val_main->cs_attr[loop] = UNC_CS_INVALID;
+ } else {
+ val_main->cs_attr[loop] = UNC_CS_PARTIALLY_APPLIED;
+ }
+ }
+ }
+ }
+ if (val_main->valid[loop] == UNC_VF_VALID_NO_VALUE) {
+ ctrlr_val->cs_attr[loop] = UNC_CS_UNKNOWN;
+ val_main->cs_attr[loop] = UNC_CS_UNKNOWN;
+ }
+ }
+ }
+
+ if (op == UNC_OP_CREATE ) {
+ for (unsigned int loop = 0; loop < sizeof(val_main->valid)/
+ sizeof(val_main->valid[0]); ++loop) {
+ if (val_main->valid[loop] != UNC_VF_INVALID){
+ if (ctrlr_val->cs_attr[loop] != UNC_CS_NOT_SUPPORTED)
+ ctrlr_val->cs_attr[loop] = ctrlr_status;
+ else
+ ctrlr_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
+
+ if (val_main->cs_attr[loop] == ctrlr_status) {
+ cs_status = ctrlr_status;
+ } else if (ctrlr_status == UNC_CS_APPLIED) {
+ if (val_main->cs_attr[loop] == UNC_CS_UNKNOWN) {
+ cs_status = ctrlr_status;
+ } else if (val_main->cs_attr[loop] == UNC_CS_NOT_APPLIED) {
+ val_main->cs_attr[loop] = UNC_CS_PARTIALLY_APPLIED;
+ } else if (val_main->cs_attr[loop] == UNC_CS_INVALID) {
+ val_main->cs_attr[loop] = UNC_CS_INVALID;
+ } else {
+ cs_status = val_main->cs_attr[loop];
+ }
+ } else if(ctrlr_status == UNC_CS_NOT_APPLIED) {
+ if(val_main->cs_attr[loop] == UNC_CS_NOT_APPLIED) {
+ cs_status = UNC_CS_NOT_APPLIED;
+ } else if (val_main->cs_attr[loop] == UNC_CS_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ } else if (val_main->cs_attr[loop] == UNC_CS_INVALID) {
+ val_main->cs_attr[loop] = UNC_CS_INVALID;
+ } else {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ }
+ }
+ val_main->cs_attr[loop] = cs_status;
+ UPLL_LOG_DEBUG("Main tbl cs_attr : %d", val_main->cs_attr[loop]);
+ }
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t FlowListEntryMoMgr::Get_Tx_Consolidated_Status(
+ unc_keytype_configstatus_t &status,
+ unc_keytype_configstatus_t drv_result_status,
+ unc_keytype_configstatus_t current_cs,
+ unc_keytype_configstatus_t current_ctrlr_cs) {
+
+ switch (current_cs) {
+ case UNC_CS_UNKNOWN:
+ status = drv_result_status;
+ break;
+ case UNC_CS_PARTIALLY_APPLIED:
+ if (current_ctrlr_cs == UNC_CS_NOT_APPLIED) {
+ // Todo: if this vtn has caused it then to change to applied.
+ status = (drv_result_status != UNC_CS_APPLIED) ?
+ UNC_CS_PARTIALLY_APPLIED : drv_result_status;
+ }
+ break;
+ case UNC_CS_APPLIED:
+ case UNC_CS_NOT_APPLIED:
+ case UNC_CS_INVALID:
+ default:
+ status = (drv_result_status == UNC_CS_NOT_APPLIED)?
+ UNC_CS_PARTIALLY_APPLIED:
+ (status == UNC_CS_UNKNOWN)?drv_result_status:status;
+ break;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t FlowListEntryMoMgr::SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *pkey = NULL;
+ result_code = GetParentConfigKey(pkey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetParentConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_FLOWLIST)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("mgr is NULL");
+ DELETE_IF_NOT_NULL(pkey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t rename = 0;
+ result_code = mgr->IsRenamed(pkey, req->datatype, dmi, rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(pkey);
+ return result_code;
+ }
+ UPLL_LOG_DEBUG("Flag from parent : %d", rename);
+ SET_USER_DATA_FLAGS(ikey, rename);
+ DELETE_IF_NOT_NULL(pkey);
+ return UPLL_RC_SUCCESS;
+}
} // namespace kt_momgr
} // namespace upll
} // namespace unc
static BindInfo rename_flowlist_entry_main_tbl[];
static BindInfo rename_flowlist_entry_ctrlr_tbl[];
-
+ uint32_t cur_instance_count;
+
bool GetRenameKeyBindInfo(unc_key_type_t key_type,
BindInfo *&binfo, int &nattr, MoMgrTables tbl);
* @param[in] ctrlr_name controller_name
*
* @retval UPLL_RC_SUCCESS Validation succeeded.
- * @retval UPLL_RC_ERR_GENERIC Validation failure.
- * @retval UPLL_RC_ERR_INVALID_OPTION1 Option1 is not valid.
- * @retval UPLL_RC_ERR_INVALID_OPTION2 Option2 is not valid.
+ * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Validation failure.
*/
upll_rc_t ValidateCapability(IpcReqRespHeader *req, ConfigKeyVal *key,
const char *ctrlr_name = NULL);
* @param[in] val_flowlist_entry KT_FLOWLIST_ENTRY value structure.
* @param[in] attrs pointer to controller attribute
*
- * @retval UPLL_RC_SUCCESS validation succeeded.
- * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
- * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ * @retval UPLL_RC_SUCCESS indicates attribute check completion
*/
upll_rc_t ValFlowlistEntryAttributeSupportCheck(
val_flowlist_entry_t *val_flowlist_entry,
* on the given controller, based on the valid flag.
*
* @param[in] val_flowlist_entry KT_FLOWLIST_ENTRY value structure
+ * @param[in] attrs pointer to controller attribute
*
- * @retval UPLL_RC_SUCCESS validation succeeded.
- * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
*/
- upll_rc_t ValidateIpProtoAttribute(
+ void ValidateIpProtoAttribute(
val_flowlist_entry_t *val_flowlist_entry, const uint8_t *attrs);
/**
* on the given controller, based on the valid flag.
*
* @param[in] val_flowlist_entry KT_FLOWLIST_ENTRY value structure
- *
- * @retval UPLL_RC_SUCCESS validation succeeded.
- * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
+ * @param[in] attrs pointer to controller attributee
*/
- upll_rc_t ValidateVlanPriorityAttribute(
+ void ValidateVlanPriorityAttribute(
val_flowlist_entry_t *val_flowlist_entry, const uint8_t *attrs);
/**
* on the given controller, based on the valid flag.
*
* @param[in] val_flowlist_entry KT_FLOWLIST_ENTRY value structure
- *
- * @retval UPLL_RC_SUCCESS validation succeeded.
- * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
+ * @param[in] attrs pointer to controller attribute
*/
- upll_rc_t ValidateMacAttribute(val_flowlist_entry_t *val_flowlist_entry,
+ void ValidateMacAttribute(val_flowlist_entry_t *val_flowlist_entry,
const uint8_t *attrs);
/**
* are supported on the given controller, based on the valid flag.
*
* @param[in] val_flowlist_entry KT_FLOWLIST_ENTRY value structure
- *
- * @retval UPLL_RC_SUCCESS validation succeeded.
- * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
+ * @param[in] attrs pointer to controller attribute
*/
- upll_rc_t ValidateIPAttribute(val_flowlist_entry_t *val_flowlist_entry,
+ void ValidateIPAttribute(val_flowlist_entry_t *val_flowlist_entry,
const uint8_t *attrs);
/**
* are supported on the given controller, based on the valid flag.
*
* @param[in] val_flowlist_entry KT_FLOWLIST_ENTRY value structure
- *
- * @retval UPLL_RC_SUCCESS validation succeeded.
- * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
+ * @param[in] attrs pointer to controller attribute
*/
- upll_rc_t ValidateIPV6Attribute(val_flowlist_entry_t *val_flowlist_entry,
+ void ValidateIPV6Attribute(val_flowlist_entry_t *val_flowlist_entry,
const uint8_t *attrs);
/**
* are supported on the given controller, based on the valid flag.
*
* @param[in] val_flowlist_entry KT_FLOWLIST_ENTRY value structure
- *
- * @retval UPLL_RC_SUCCESS validation succeeded.
- * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
+ * @param[in] attrs pointer to controller attribute
*/
- upll_rc_t ValidateL4PortAttribute(val_flowlist_entry_t *val_flowlist_entry,
+ void ValidateL4PortAttribute(val_flowlist_entry_t *val_flowlist_entry,
const uint8_t *attrs);
/**
* are supported on the given controller, based on the valid flag.
*
* @param[in] val_flowlist_entry KT_FLOWLIST_ENTRY value structure
- *
- * @retval UPLL_RC_SUCCESS validation succeeded.
- * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
+ * @param[in] attrs pointer to controller attribute
*/
- upll_rc_t ValidateICMPAttribute(val_flowlist_entry_t *val_flowlist_entry,
+ void ValidateICMPAttribute(val_flowlist_entry_t *val_flowlist_entry,
const uint8_t *attrs);
/**
* @Brief Checks Mac_eth_type attributes is supported
* on the given controller, based on the valid flag.
*
* @param[in] val_flowlist_entry KT_FLOWLIST_ENTRY value structure
- *
- * @retval UPLL_RC_SUCCESS validation succeeded.
- * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
+ * @param[in] attrs pointer to controller attribute
*/
- upll_rc_t ValidateMacEthTypeAttribute(
+ void ValidateMacEthTypeAttribute(
val_flowlist_entry_t *val_flowlist_entry, const uint8_t *attrs);
/**
* on the given controller, based on the valid flag.
*
* @param[in] val_flowlist_entry KT_FLOWLIST_ENTRY value structure
- *
- * @retval UPLL_RC_SUCCESS validation succeeded.
- * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
+ * @param[in] attrs pointer to controller attribute
*/
- upll_rc_t ValidateIpDscpAttribute(
+ void ValidateIpDscpAttribute(
val_flowlist_entry_t *val_flowlist_entry, const uint8_t *attrs);
/**
* @retval UPLL_RC_ERR_NO_SUCH_INSTANCE No record found in DB
* @retval UPLL_RC_ERR_DB_ACCESS DB access error
*/
- upll_rc_t GetRenamedControllerKey(ConfigKeyVal *&ikey,
+ upll_rc_t GetRenamedControllerKey(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
controller_domain *ctrlr_dom = NULL);
/**
DalDmlIntf *dmi,
ConfigKeyVal **err_ckv);
- bool CompareValidValue(void *&val1, void *val2, bool audit);
+ bool CompareValidValue(void *&val1, void *val2, bool copy_to_running);
/**
* @brief Method to compare to keys
*/
upll_rc_t UpdateControllerTable(ConfigKeyVal *ikey,
unc_keytype_operation_t op,
+ upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
char* ctrl_id);
void SetValidAttributesForController(val_flowlist_entry_t *val);
upll_rc_t AddFlowListToController(char *flowlist_name,
DalDmlIntf *dmi,
char* ctrl_id,
+ upll_keytype_datatype_t dt_type,
unc_keytype_operation_t op);
/**
upll_rc_t IsFlowListMatched(ConfigKeyVal *ikey,
DalDmlIntf *dmi,
IpcReqRespHeader *req);
+
+ upll_rc_t SetValidAudit(ConfigKeyVal *&ikey);
+
+ upll_rc_t AuditUpdateController1(unc_key_type_t keytype,
+ const char *ctrlr_id,
+ uint32_t session_id,
+ uint32_t config_id,
+ uuc::UpdateCtrlrPhase phase,
+ bool *ctrlr_affected,
+ DalDmlIntf *dmi);
+
+ bool FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op);
+
+ upll_rc_t Get_Tx_Consolidated_Status(
+ unc_keytype_configstatus_t &status,
+ unc_keytype_configstatus_t drv_result_status,
+ unc_keytype_configstatus_t current_cs,
+ unc_keytype_configstatus_t current_ctrlr_cs);
+
+ upll_rc_t CreateEntryCtrlrTbl(IpcReqRespHeader *req,
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi);
+
+ upll_rc_t SetFlowlistEntryConsolidatedStatus(ConfigKeyVal *ikey,
+ uint8_t *ctrlr_id,
+ DalDmlIntf *dmi);
+
+ upll_rc_t SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req);
+ bool CompareValidVal(void *&val1, void *val2, void *val3,
+ bool copy_to_running);
};
typedef struct val_flowlist_entry_ctrl {
#include "upll_validation.hh"
#include "unc/upll_ipc_enum.h"
#include "ctrlr_capa_defines.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
namespace unc {
namespace upll {
namespace kt_momgr {
#define NUM_KEY_MAIN_COL 3
-#define NUM_KEY_CTRL_COL 4
+#define NUM_KEY_CTRL_COL 3
#define NUM_KEY_RENAME_COL 2
#define FLOWLIST_RENAME 0x01
+#define NO_FLOWLIST_RENAME 0xFE
// FlowList Table(Main Table)
BindInfo FlowListMoMgr::flowlist_bind_info[] = {
uud::kDalChar,
(kMaxLenFlowListName + 1) },
{ uudst::flowlist::kDbiFlags,
- CFG_VAL,
- offsetof(val_flowlist_ctrl, flags),
+ CK_VAL,
+ offsetof(key_user_data_t, flags),
uud::kDalUint8, 1}
};
offsetof(key_flowlist_t, flowlist_name),
uud::kDalChar,
(kMaxLenFlowListName + 1) },
- { uudst::flowlist_ctrlr::kDbiCtrlrName,
- CFG_MATCH_KEY,
- offsetof(key_user_data_t, ctrlr_id),
- uud::kDalChar,
- (kMaxLenCtrlrId + 1) },
{ uudst::flowlist_ctrlr::kDbiFlowListName,
CFG_INPUT_KEY,
offsetof(key_rename_vnode_info_t, new_flowlist_name),
uud::kDalChar,
(kMaxLenFlowListName + 1) },
{ uudst::flowlist_ctrlr::kDbiFlags,
- CFG_VAL,
- offsetof(val_flowlist_ctrl, flags),
+ CK_VAL,
+ offsetof(key_user_data_t, flags),
uud::kDalUint8, 1}
};
nchild = sizeof(flowlist_child) / sizeof(flowlist_child[0]);
child = flowlist_child;
+ cur_instance_count = 0;
}
bool FlowListMoMgr::GetRenameKeyBindInfo(unc_key_type_t key_type,
if (val == NULL) return UPLL_RC_ERR_GENERIC;
if (tbl == MAINTBL) {
- if (uudst::flowlist::kDbiIpType == indx) {
+ valid = NULL;
+ switch(indx) {
+ case uudst::flowlist::kDbiIpType:
+ valid = &(reinterpret_cast<val_flowlist_t*>
+ (val))->valid[UPLL_IDX_IP_TYPE_FL];
+ break;
+ default:
+ return UPLL_RC_ERR_GENERIC;
+ }
+ #if 0
+ if (indx == uudst::flowlist::kDbiIpType) {
valid = &(reinterpret_cast<val_flowlist_t*>
(val))->valid[UPLL_IDX_IP_TYPE_FL];
} else {
valid = NULL;
}
+ #endif
} else if (tbl == RENAMETBL) {
valid = NULL;
+ switch(indx) {
+ case uudst::flowlist_rename::kDbiFlowListNameCtrlr:
+ valid = &(reinterpret_cast<val_rename_flowlist *>
+ (val))->valid[UPLL_IDX_RENAME_FLOWLIST_RFL];
+ break;
+ default:
+ return UPLL_RC_ERR_GENERIC;
+ }
+ #if 0
+ if (indx == uudst::flowlist_rename::kDbiFlowListNameCtrlr) {
+ valid = &(reinterpret_cast<val_rename_flowlist *>
+ (val))->valid[UPLL_IDX_RENAME_FLOWLIST_RFL];
+ } else {
+ valid = NULL;
+ }
+ #endif
} else if (tbl == CTRLRTBL) {
- if (uudst::flowlist_ctrlr::kDbiValidIpType == indx) {
+ #if 0
+ if (indx == uudst::flowlist_ctrlr::kDbiValidIpType) {
valid = &(reinterpret_cast<val_flowlist_ctrl*>(val))->valid[0];
- } else if (uudst::flowlist_ctrlr::kDbiRefCount == indx) {
+ } else if (indx ==uudst::flowlist_ctrlr::kDbiRefCount) {
valid = &(reinterpret_cast<val_flowlist_ctrl*>(val))->valid[1];
} else {
valid = NULL;
}
+ #endif
+ valid = NULL;
+ switch(indx) {
+ case uudst::flowlist_ctrlr::kDbiValidIpType:
+ valid = &(reinterpret_cast<val_flowlist_ctrl*>(val))->valid[0];
+ break;
+ case uudst::flowlist_ctrlr::kDbiRefCount:
+ valid = &(reinterpret_cast<val_flowlist_ctrl*>(val))->valid[1];
+ default:
+ break;
+ }
} else {
valid = NULL;
return UPLL_RC_ERR_GENERIC;
}
if (!pkey) {
- free(flowlist_key);
+ UPLL_LOG_DEBUG("pkey NULL");
return UPLL_RC_ERR_GENERIC;
}
if (okey) {
if (okey->get_key_type() != UNC_KT_FLOWLIST)
return UPLL_RC_ERR_GENERIC;
- flowlist_key = reinterpret_cast<key_flowlist_t *>(okey->get_key());
+ }
+ if ((okey) && (okey->get_key())) {
+ flowlist_key = reinterpret_cast<key_flowlist_t *>(okey->get_key());
} else {
flowlist_key = reinterpret_cast<key_flowlist_t *>
(ConfigKeyVal::Malloc(sizeof(key_flowlist_t)));
if (flowlist_key) free(flowlist_key);
return UPLL_RC_ERR_GENERIC;
}
-
// Allocate and assign the out configkeyval
- if (!okey)
- okey = new ConfigKeyVal(UNC_KT_FLOWLIST, IpctSt::kIpcStKeyFlowlist,
- flowlist_key, NULL);
-
+ if ((okey) && !(okey->get_key())) {
+ UPLL_LOG_DEBUG("okey not null and flow list name updated");
+ okey->SetKey(IpctSt::kIpcStKeyFlowlist, flowlist_key);
+ }
+ if (!okey) {
+ okey = new ConfigKeyVal(UNC_KT_FLOWLIST, IpctSt::kIpcStKeyFlowlist,
+ flowlist_key, NULL);
+ }
SET_USER_DATA(okey, parent_key);
+ UPLL_LOG_TRACE("%s GetChildConfigKey fl start",
+ okey->ToStrAll().c_str());
return result_code;
}
UPLL_FUNC_TRACE;
upll_rc_t result_code;
ConfigKeyVal *unc_key = NULL;
+ UPLL_LOG_TRACE("%s GetRenamedUncKey fl start",
+ ctrlr_key->ToStrAll().c_str());
key_flowlist_t *ctrlr_flowlist_key =
reinterpret_cast<key_flowlist_t *>(ctrlr_key->get_key());
if (NULL == ctrlr_flowlist_key) return UPLL_RC_ERR_GENERIC;
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
-
val_rename_flowlist_t *rename_flowlist =
reinterpret_cast<val_rename_flowlist_t*>
(ConfigKeyVal::Malloc(sizeof(val_rename_flowlist_t)));
+ if (!rename_flowlist) {
+ UPLL_LOG_DEBUG("rename_flowlist NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(rename_flowlist->flowlist_newname,
ctrlr_flowlist_key->flowlist_name,
(kMaxLenFlowListName + 1));
result_code = GetChildConfigKey(unc_key, NULL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetChildConfigKey returns failure result_code:%d",
- result_code);
+ UPLL_LOG_DEBUG("GetChildConfigKey failure %d", result_code);
free(rename_flowlist);
return result_code;
}
+
+ if (!unc_key) {
+ UPLL_LOG_DEBUG("unc_key NULL");
+ free(rename_flowlist);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
unc_key->AppendCfgVal(IpctSt::kIpcStValRenameFlowlist, rename_flowlist);
- SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
+ UPLL_LOG_DEBUG("ctrlr_id fl (%s)", ctrlr_id);
+ if (ctrlr_id) {
+ SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
+ } else {
+ dbop.matchop = kOpMatchNone;
+ }
result_code = ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL);
flowlist_key->flowlist_name,
(kMaxLenFlowListName + 1));
}
- delete unc_key;
+ UPLL_LOG_TRACE("%s GetRenamedUncKey fl end",
+ ctrlr_key->ToStrAll().c_str());
+ DELETE_IF_NOT_NULL(unc_key);
return result_code;
}
upll_rc_t FlowListMoMgr::GetRenamedControllerKey(
- ConfigKeyVal *&ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
+ ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
controller_domain *ctrlr_dom) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
UPLL_LOG_DEBUG("Key is not Renamed");
return UPLL_RC_SUCCESS;
}
+ UPLL_LOG_DEBUG("Key Renamed");
/* FlowList renamed */
- key_flowlist_t *ctrlr_key = reinterpret_cast<key_flowlist_t*>
- (ConfigKeyVal::Malloc(sizeof(key_flowlist_t)));
if (rename & FLOWLIST_RENAME) {
result_code = GetChildConfigKey(okey, ikey);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetChildConfigKey returns error, result_code:%d"
- , result_code);
- free(ctrlr_key);
+ UPLL_LOG_DEBUG("GetChildConfigKey fail (%d)", result_code);
return result_code;
}
if (ctrlr_dom != NULL)
SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
- ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi, RENAMETBL);
+
+ result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi, RENAMETBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB no instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
val_rename_flowlist_t *rename_val =
reinterpret_cast<val_rename_flowlist_t *>(GetVal(okey));
- if (!rename_val
- || (rename_val->valid[UPLL_IDX_RENAME_FLOWLIST_RFL] != UNC_VF_VALID)) {
- if (okey) delete okey;
- if (ctrlr_key) free(ctrlr_key);
+ if (!rename_val) {
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
- uuu::upll_strncpy(ctrlr_key->flowlist_name,
+
+ UPLL_LOG_DEBUG("valid flowlist (%d)", rename_val->valid[UPLL_IDX_RENAME_FLOWLIST_RFL]);
+ key_flowlist *key = reinterpret_cast<key_flowlist *>(ikey->get_key());
+ uuu::upll_strncpy(key->flowlist_name,
rename_val->flowlist_newname,
(kMaxLenFlowListName + 1));
- delete okey;
+ UPLL_LOG_DEBUG("flow list name (%s) (%s)", key->flowlist_name, rename_val->flowlist_newname);
+ DELETE_IF_NOT_NULL(okey);
}
- free(ikey->get_key());
- ikey->SetKey(IpctSt::kIpcStKeyFlowlist,
- reinterpret_cast<void *> (ctrlr_key));
-
return UPLL_RC_SUCCESS;
}
return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
}
+upll_rc_t FlowListMoMgr::SetFlowListConsolidatedStatus(ConfigKeyVal *ikey,
+ uint8_t *ctrlr_id,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ctrlr_ckv = NULL;
+ val_flowlist_ctrl *ctrlr_val = NULL;
+ uint8_t *flowlist_exist_on_ctrlr = NULL;
+ bool applied = false, not_applied = false, invalid = false;
+ unc_keytype_configstatus_t c_status = UNC_CS_NOT_APPLIED;
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone,
+ kOpInOutCtrlr | kOpInOutDomain | kOpInOutCs };
+ if (!ikey || !dmi || !ctrlr_id) {
+ UPLL_LOG_DEBUG("Invalid Input");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = GetChildConfigKey(ctrlr_ckv, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed err code %d", result_code);
+ return result_code;
+ }
+ result_code = ReadConfigDB(ctrlr_ckv, UPLL_DT_RUNNING, UNC_OP_READ, dbop, dmi,
+ CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB from ctrltbl failed err code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return result_code;
+ }
+
+ for (ConfigKeyVal *tmp = ctrlr_ckv; tmp != NULL;
+ tmp = tmp->get_next_cfg_key_val()) {
+ ctrlr_val = reinterpret_cast<val_flowlist_ctrl *>(GetVal(tmp));
+ if (!ctrlr_val) {
+ UPLL_LOG_DEBUG("Controller Value is empty");
+ tmp = NULL;
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ GET_USER_DATA_CTRLR(tmp, flowlist_exist_on_ctrlr);
+ if (!strcmp(reinterpret_cast<char *>(flowlist_exist_on_ctrlr),
+ reinterpret_cast<char *>(ctrlr_id)))
+ continue; // skipping entry of deleted controller
+
+ switch (ctrlr_val->cs_row_status) {
+ case UNC_CS_APPLIED:
+ applied = true;
+ break;
+ case UNC_CS_NOT_APPLIED:
+ not_applied = true;
+ break;
+ case UNC_CS_INVALID:
+ invalid = true;
+ default:
+ UPLL_LOG_DEBUG("Invalid status");
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ break;
+ // return UPLL_RC_ERR_GENERIC;
+ }
+ flowlist_exist_on_ctrlr = NULL;
+ }
+ if (invalid) {
+ c_status = UNC_CS_INVALID;
+ } if (applied && !not_applied) {
+ c_status = UNC_CS_APPLIED;
+ } else if (!applied && not_applied) {
+ c_status = UNC_CS_NOT_APPLIED;
+ } else if (applied && not_applied) {
+ c_status = UNC_CS_PARTIALLY_APPLIED;
+ } else {
+ c_status = UNC_CS_APPLIED;
+ }
+ // Set cs_status
+ val_flowlist_t *flowlist_val = static_cast<val_flowlist_t *>(GetVal(ikey));
+ flowlist_val->cs_row_status = c_status;
+ flowlist_val->cs_attr[0] = c_status;
+ DbSubOp dbop_update = {kOpNotRead, kOpMatchNone, kOpInOutCs};
+ result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_UPDATE, dmi,
+ &dbop_update, MAINTBL);
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return result_code;
+}
upll_rc_t FlowListMoMgr::ReadRecord(IpcReqRespHeader *req, ConfigKeyVal *ikey,
DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
// DbSubOp dbop = NULL;
- if (NULL == configkey || ctrl_id == NULL) return result_code;
-
- SET_USER_DATA_CTRLR(configkey, ctrl_id)
- DbSubOp dbop = { kOpReadExist, kOpMatchNone, kOpInOutNone };
- // Validate if Controller Id exists in the ImportDB or not
- result_code = UpdateConfigDB(configkey, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
- &dbop, CTRLRTBL);
- if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code) {
- UPLL_LOG_DEBUG("The given Controller ID does not exist");
+ ConfigKeyVal *ckey = NULL;
+ ConfigKeyVal *temp_ckey = NULL;
+ if (ctrl_id == NULL) return result_code;
+ // Read the Configuration from the IMPORT
+ result_code = GetChildConfigKey(temp_ckey, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey ckval NULL");
return result_code;
}
- // Read the Configuration from the IMPORT
+
DbSubOp dbop1 = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
- result_code = ReadConfigDB(configkey, UPLL_DT_IMPORT, UNC_OP_READ, dbop1, dmi,
+ result_code = ReadConfigDB(temp_ckey, UPLL_DT_IMPORT, UNC_OP_READ, dbop1, dmi,
MAINTBL);
- if (UPLL_RC_SUCCESS != result_code) {
+ if (UPLL_RC_SUCCESS != result_code &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
UPLL_LOG_DEBUG("Unable to read the ImportConfiguration");
+ DELETE_IF_NOT_NULL(temp_ckey);
return result_code;
}
- while (configkey != NULL) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ DELETE_IF_NOT_NULL(temp_ckey);
+ return UPLL_RC_SUCCESS;
+ }
+ ckey = temp_ckey;
+ while (ckey != NULL) {
+ UPLL_LOG_DEBUG("ckey not null");
+
+ // Check the flow list as stand alone
+ DbSubOp dbop = { kOpReadExist, kOpMatchNone, kOpInOutNone };
+ result_code = UpdateConfigDB(ckey, UPLL_DT_IMPORT, UNC_OP_READ, dmi, &dbop,
+ CTRLRTBL);
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("flow list is stand alone");
+ result_code = GetChildConfigKey(configkey, ckey);
+ DELETE_IF_NOT_NULL(temp_ckey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal fail");
+ return result_code;
+ }
+ return UPLL_RC_ERR_MERGE_CONFLICT;
+ } else if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
+ UPLL_LOG_DEBUG("Database Error");
+ DELETE_IF_NOT_NULL(temp_ckey);
+ return result_code;
+ }
+
// Check whether the configuration exists in the Running configuration or
// not
// if exists then return an error
- result_code = UpdateConfigDB(configkey, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
+ result_code = UpdateConfigDB(ckey, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
MAINTBL);
- if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code)
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ UPLL_LOG_DEBUG("record exists");
+ result_code = GetChildConfigKey(configkey, ckey);
+ DELETE_IF_NOT_NULL(temp_ckey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal fail");
+ return result_code;
+ }
return UPLL_RC_ERR_MERGE_CONFLICT;
- configkey = configkey->get_next_cfg_key_val();
+ } else if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("record not available");
+ ckey = ckey->get_next_cfg_key_val();
+ } else {
+ UPLL_LOG_DEBUG("UpdateConfigDB fail");
+ DELETE_IF_NOT_NULL(temp_ckey);
+ return result_code;
+ }
}
- return result_code;
+ DELETE_IF_NOT_NULL(temp_ckey);
+ UPLL_LOG_DEBUG("MergeValidate result_code (%d)", result_code);
+ return UPLL_RC_SUCCESS;
}
upll_rc_t FlowListMoMgr::IsReferenced(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
dbop, dmi, CTRLRTBL);
if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
if (UPLL_RC_SUCCESS == result_code)
- result_code = UPLL_RC_ERR_INSTANCE_EXISTS;
+ result_code = UPLL_RC_ERR_CFG_SEMANTIC;
UPLL_LOG_DEBUG("IsRef failed %d", result_code);
if (tmp_ckv) delete tmp_ckv;
return result_code;
(fl_key->flowlist_name), dmi);
if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
if (UPLL_RC_SUCCESS == result_code)
- result_code = UPLL_RC_ERR_INSTANCE_EXISTS;
+ result_code = UPLL_RC_ERR_CFG_SEMANTIC;
UPLL_LOG_DEBUG("IsRef failed %d", result_code);
return result_code;
}
(fl_key->flowlist_name), dmi);
if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
if (UPLL_RC_SUCCESS == result_code)
- result_code = UPLL_RC_ERR_INSTANCE_EXISTS;
+ result_code = UPLL_RC_ERR_CFG_SEMANTIC;
UPLL_LOG_DEBUG("IsRef failed %d", result_code);
return result_code;
}
- key_flowlist_t *key_fle = reinterpret_cast
+
+ /*key_flowlist_t *key_fle = reinterpret_cast
<key_flowlist_t *>(ikey->get_key());
PolicingProfileEntryMoMgr *ppe_mgr =
reinterpret_cast<PolicingProfileEntryMoMgr *>(const_cast<MoManager *>
if (NULL == ppe_mgr) {
return UPLL_RC_ERR_GENERIC;
}
- result_code = ppe_mgr->IsFlowListMatched(reinterpret_cast<const char *>
- (key_fle->flowlist_name), dt_type, dmi);
+ */
+
+ result_code = mgr->IsFlowListMatched(reinterpret_cast<const char *>
+ (fl_key->flowlist_name), dt_type, dmi);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("IsFlowListMatched failed from ppe %d", result_code);
- return result_code;
+ return UPLL_RC_ERR_CFG_SEMANTIC;
}
return UPLL_RC_SUCCESS;
}
upll_rc_t FlowListMoMgr::SwapKeyVal(ConfigKeyVal *ikey, ConfigKeyVal *&okey,
- DalDmlIntf *dmi, uint8_t *ctrlr) {
+ DalDmlIntf *dmi, uint8_t *ctrlr,
+ bool &no_rename) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
// ConfigVal *tmp1;
UPLL_LOG_DEBUG("Output ConfigKey should be NULL");
return UPLL_RC_ERR_GENERIC;
}
+ if (!strlen(reinterpret_cast<const char*>(ctrlr))) {
+ UPLL_LOG_DEBUG("Controller ID is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
if (ikey == NULL) {
UPLL_LOG_DEBUG("Input ConfigKey Cannot be null");
return UPLL_RC_ERR_BAD_REQUEST;
return UPLL_RC_ERR_BAD_REQUEST;
}
ConfigVal *cfg_val = ikey->get_cfg_val();
- if (cfg_val == NULL) return UPLL_RC_ERR_BAD_REQUEST;
+ if (cfg_val == NULL) {
+ UPLL_LOG_DEBUG("Rename Val configkey is NULL");
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
val_rename_flowlist_t *tval =
reinterpret_cast<val_rename_flowlist_t *>(cfg_val->get_val());
-
- /* The New Name and PFC name should not be same name */
- if (!strcmp(reinterpret_cast<char *>
- (reinterpret_cast<key_flowlist_t *>(ikey->get_key())->flowlist_name),
- reinterpret_cast<char *>(tval->flowlist_newname)))
- return UPLL_RC_ERR_GENERIC;
+ if (!tval) {
+ UPLL_LOG_DEBUG("Val is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
key_flowlist_t *key_flowlist = reinterpret_cast<key_flowlist_t*>
(ConfigKeyVal::Malloc(sizeof(key_flowlist_t)));
+ /* no rename*/
+ if (UNC_VF_VALID_NO_VALUE == tval->valid[UPLL_IDX_RENAME_FLOWLIST_RFL]) {
+ no_rename = true;
+ uuu::upll_strncpy(key_flowlist->flowlist_name,
+ reinterpret_cast<key_flowlist_t*>(ikey->get_key())->flowlist_name,
+ (kMaxLenFlowListName + 1));
- if (tval->valid[0] == UNC_VF_VALID) {
+ } else if (tval->valid[UPLL_IDX_RENAME_FLOWLIST_RFL] == UNC_VF_VALID) {
// checking the string is empty or not
if (!strlen(reinterpret_cast<char *>(tval->flowlist_newname))) {
- if (key_flowlist !=NULL) free(key_flowlist);
+ free(key_flowlist);
return UPLL_RC_ERR_GENERIC;
}
uuu::upll_strncpy(key_flowlist->flowlist_name,
tval->flowlist_newname,
(kMaxLenFlowListName + 1));
+ /* The New Name and PFC name should not be same name */
+ if (!strcmp(reinterpret_cast<char *>
+ (reinterpret_cast<key_flowlist_t *>(ikey->get_key())->flowlist_name),
+ reinterpret_cast<char *>(tval->flowlist_newname))) {
+ free(key_flowlist);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
}
okey = new ConfigKeyVal(UNC_KT_FLOWLIST, IpctSt::kIpcStKeyFlowlist,
DalDmlIntf *dmi,
ConfigKeyVal *ctrlr_key) {
UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- unc_keytype_configstatus_t status = UNC_CS_UNKNOWN;
- unc_keytype_configstatus_t cs_status = UNC_CS_UNKNOWN;
- cs_status = (driver_result == 0) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
+ unc_keytype_configstatus_t ctrlr_status;
+ uint8_t cs_status;
+ ctrlr_status = (driver_result == 0) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
if ((NULL == flowlist_key) || (NULL == ctrlr_key)) {
UPLL_LOG_DEBUG("input struct is NULL");
UPLL_LOG_DEBUG("Value structure is empty!!");
return UPLL_RC_ERR_GENERIC;
}
+ cs_status = val_flowlist->cs_row_status;
+ UPLL_LOG_TRACE("cs_status %d ctrlr_status %d\n", cs_status, ctrlr_status);
+
if (op == UNC_OP_CREATE) {
- // ctrlr_val_flowlist->valid[0] = UNC_VF_INVALID;
- /* update the status in main tbl */
- switch (val_flowlist->cs_row_status) {
- case UNC_CS_UNKNOWN:
- status = cs_status;
- break;
- case UNC_CS_PARTAILLY_APPLIED:
- if (ctrlr_val_flowlist->cs_row_status == UNC_CS_NOT_APPLIED) {
- // if this vtn has caused it then to change to applied.
- }
- break;
- case UNC_CS_APPLIED:
- case UNC_CS_NOT_APPLIED:
- case UNC_CS_INVALID:
- default:
- status =
- (cs_status == UNC_CS_APPLIED) ? UNC_CS_PARTAILLY_APPLIED : status;
- break;
- }
- val_flowlist->cs_row_status = status;
- if ( UNC_VF_NOT_SOPPORTED == val_flowlist->valid[0] ) {
- val_flowlist->cs_attr[0] = UNC_CS_NOT_SUPPORTED;
+ ctrlr_val_flowlist->cs_row_status = ctrlr_status;
+ if (val_flowlist->cs_row_status == UNC_CS_INVALID) {
+ cs_status = UNC_CS_INVALID;
+ } else if (val_flowlist->cs_row_status == UNC_CS_UNKNOWN) {
+ /* first entry in ctrlr table */
+ cs_status = ctrlr_status;
+ } else if (val_flowlist->cs_row_status == UNC_CS_APPLIED) {
+ if (ctrlr_status == UNC_CS_NOT_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ }
+ } else if (val_flowlist->cs_row_status == UNC_CS_NOT_APPLIED) {
+ if (ctrlr_status == UNC_CS_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ }
+ } else {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
}
- if (UNC_VF_NOT_SOPPORTED == ctrlr_val_flowlist->valid[0]) {
+ val_flowlist->cs_row_status = cs_status;
+ val_flowlist->cs_attr[0] = cs_status;
+ }
+ // Updating the Controller cs_row_status
+ if ((op == UNC_OP_UPDATE) && (nreq != NULL)) {
+ val_flowlist_ctrl *run_ctrlr_val = reinterpret_cast<val_flowlist_ctrl *>
+ (GetVal(nreq));
+ if (run_ctrlr_val != NULL)
+ ctrlr_val_flowlist->cs_row_status = run_ctrlr_val->cs_row_status;
+ }
+ if (val_flowlist->valid[0] != UNC_VF_INVALID) {
+ if (ctrlr_val_flowlist->cs_attr[0] != UNC_CS_NOT_SUPPORTED)
+ ctrlr_val_flowlist->cs_attr[0] = ctrlr_status;
+ else
ctrlr_val_flowlist->cs_attr[0] = UNC_CS_NOT_SUPPORTED;
- }
- if ((UNC_VF_VALID == val_flowlist->valid[0]) ||
- (UNC_VF_VALID_NO_VALUE == val_flowlist->valid[0]))
- if (ctrlr_val_flowlist->valid[0] != UNC_VF_NOT_SOPPORTED) {
- ctrlr_val_flowlist->cs_attr[0] = cs_status;
- val_flowlist->cs_attr[0] = (uint8_t)val_flowlist->cs_row_status;
+
+ if (val_flowlist->cs_attr[0] == ctrlr_status) {
+ cs_status = ctrlr_status;
+ } else if (val_flowlist->cs_attr[0] == UNC_CS_INVALID) {
+ cs_status = UNC_CS_INVALID;
+ } else if (ctrlr_status == UNC_CS_APPLIED) {
+ if (val_flowlist->cs_attr[0] == UNC_CS_UNKNOWN) {
+ cs_status = ctrlr_status;
+ }
+ if (val_flowlist->cs_attr[0] == UNC_CS_NOT_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ } else {
+ cs_status = val_flowlist->cs_attr[0];
}
- } else if (op == UNC_OP_UPDATE) {
- if (ctrlr_val_flowlist->valid[0] != UNC_VF_NOT_SOPPORTED)
- ctrlr_val_flowlist->cs_attr[0] = cs_status;
- else
- ctrlr_val_flowlist->cs_attr[0] = UNC_CS_NOT_SUPPORTED;
- val_flowlist->cs_attr[0] = (uint8_t)val_flowlist->cs_row_status;
+ } else if(ctrlr_status == UNC_CS_NOT_APPLIED) {
+ if(val_flowlist->cs_attr[0] == UNC_CS_NOT_APPLIED) {
+ cs_status = UNC_CS_NOT_APPLIED;
+ } else {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ }
+ }
+ val_flowlist->cs_attr[0] = cs_status;
+ UPLL_LOG_DEBUG("Main tbl cs_attr : %d", val_flowlist->cs_attr[0]);
}
- return result_code;
+ return UPLL_RC_SUCCESS;
}
upll_rc_t FlowListMoMgr::AddFlowListToController(char *flowlist_name,
DalDmlIntf *dmi,
char* ctrl_id,
+ upll_keytype_datatype_t dt_type,
unc_keytype_operation_t op) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
if (UNC_OP_CREATE == op || UNC_OP_UPDATE == op) {
- result_code = CreateFlowListToController(flowlist_name, dmi, ctrl_id, op);
+ result_code = CreateFlowListToController(flowlist_name, dmi,
+ ctrl_id, dt_type, op);
} else if (UNC_OP_DELETE == op) {
- result_code = DeleteFlowListToController(flowlist_name, dmi, ctrl_id, op);
+ result_code = DeleteFlowListToController(flowlist_name, dmi,
+ ctrl_id, dt_type, op);
}
return result_code;
}
upll_rc_t FlowListMoMgr::DeleteFlowListToController(char *flowlist_name,
- DalDmlIntf *dmi,
- char* ctrl_id,
- unc_keytype_operation_t op) {
+ DalDmlIntf *dmi,
+ char* ctrl_id,
+ upll_keytype_datatype_t dt_type,
+ unc_keytype_operation_t op) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *okey = NULL;
return result_code;
}
key_flowlist_t *okey_key = reinterpret_cast<key_flowlist_t *>
- (okey->get_key());
+ (okey->get_key());
uuu::upll_strncpy(okey_key->flowlist_name,
- flowlist_name,
- (kMaxLenFlowListName+1));
+ flowlist_name,
+ (kMaxLenFlowListName+1));
SET_USER_DATA_CTRLR(okey, ctrl_id);
DbSubOp dbop = {kOpReadSingle, kOpMatchCtrlr, kOpInOutNone};
result_code = ReadConfigDB(okey,
- UPLL_DT_CANDIDATE,
- UNC_OP_READ,
- dbop, dmi, CTRLRTBL);
+ dt_type,
+ UNC_OP_READ,
+ dbop, dmi, CTRLRTBL);
if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
UPLL_LOG_DEBUG("No matching record found in Ctrlrtbl");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_SUCCESS;
} else if (UPLL_RC_SUCCESS == result_code) {
UPLL_LOG_DEBUG("Matching records found in ctrlrtbl");
ctrlr_val->refcount -= 1;
if (1 > ctrlr_val->refcount) {
ctrlr_val->valid[1] = UNC_VF_VALID;
- result_code = UpdateConfigDB(okey, UPLL_DT_CANDIDATE, UNC_OP_DELETE, dmi,
- CTRLRTBL);
+ result_code = UpdateConfigDB(okey, dt_type, UNC_OP_DELETE, dmi,
+ CTRLRTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("Delete from ctrlrtbl failed");
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
- fl_entry_del = true;
+ fl_entry_del = true;
} else {
ctrlr_val->valid[1] = UNC_VF_VALID;
- result_code = UpdateConfigDB(okey, UPLL_DT_CANDIDATE, UNC_OP_UPDATE, dmi,
- CTRLRTBL);
+ result_code = UpdateConfigDB(okey, dt_type, UNC_OP_UPDATE, dmi,
+ CTRLRTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("Update in ctrlrtbl failed");
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
}
} else {
UPLL_LOG_DEBUG("ReadConfigDB failed in Ctrlrtbl");
- delete okey;
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
+ DELETE_IF_NOT_NULL(okey);
if (fl_entry_del) {
- FlowListEntryMoMgr *mgr = reinterpret_cast<FlowListEntryMoMgr *>
- (const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST_ENTRY)));
- result_code = mgr->AddFlowListToController(
- flowlist_name, dmi, ctrl_id, op);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Unable to update the controller table for flowlistentry");
- return result_code;
- }
-}
+ FlowListEntryMoMgr *mgr = reinterpret_cast<FlowListEntryMoMgr *>
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST_ENTRY)));
+ result_code = mgr->AddFlowListToController(
+ flowlist_name, dmi, ctrl_id, dt_type, op);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to update the controller table for flowlistentry");
+ return result_code;
+ }
+ }
return UPLL_RC_SUCCESS;
}
upll_rc_t FlowListMoMgr::CreateFlowListToController(char *flowlist_name,
DalDmlIntf *dmi,
char* ctrl_id,
+ upll_keytype_datatype_t dt_type,
unc_keytype_operation_t op) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
return result_code;
}
+ unc_keytype_ctrtype_t ctrlrtype = UNC_CT_UNKNOWN;
+ uuc::CtrlrMgr *ctrlr_mgr = uuc::CtrlrMgr::GetInstance();
+
key_flowlist_t *okey_key = reinterpret_cast<key_flowlist_t *>
(okey->get_key());
uuu::upll_strncpy(okey_key->flowlist_name,
flowlist_name,
(kMaxLenFlowListName+1));
SET_USER_DATA_CTRLR(okey, ctrl_id);
- DbSubOp dbop = {kOpReadSingle, kOpMatchCtrlr, kOpInOutNone};
+ DbSubOp dbop = {kOpReadSingle, kOpMatchCtrlr, kOpInOutCs};
result_code = ReadConfigDB(okey,
- UPLL_DT_CANDIDATE,
+ dt_type,
UNC_OP_READ,
dbop, dmi, CTRLRTBL);
if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
result_code = GetChildConfigKey(main_ckv, okey);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
- DbSubOp dbop1 = {kOpReadSingle, kOpMatchNone, kOpInOutNone};
+ DbSubOp dbop1 = {kOpReadSingle, kOpMatchNone, kOpInOutCs};
result_code = ReadConfigDB(main_ckv,
- UPLL_DT_CANDIDATE,
+ dt_type,
UNC_OP_READ,
dbop1, dmi, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("ReadConfigDB in maintbl failed %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(main_ckv);
return result_code;
}
val_flowlist_t *main_val = reinterpret_cast<val_flowlist_t *>
(GetVal(main_ckv));
if (NULL == main_val) {
UPLL_LOG_DEBUG(" Main Val struct is NULL");
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(main_ckv);
return UPLL_RC_ERR_GENERIC;
}
val_flowlist_ctrl_t *ctrlr_val = reinterpret_cast<val_flowlist_ctrl_t *>
(GetVal(okey));
if (NULL == ctrlr_val) {
UPLL_LOG_DEBUG(" Ctrlr Val struct is NULL");
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(main_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ // capability check
+ ConfigKeyVal *temp_key = NULL;
+
+ result_code = GetChildConfigKey(temp_key, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(main_ckv);
+ DELETE_IF_NOT_NULL(okey);
+ UPLL_LOG_DEBUG("GetChildConfigKey failed(%d)",result_code);
+ return result_code;
+ }
+
+ result_code = GetInstanceCount(temp_key, ctrl_id,
+ dt_type,
+ &cur_instance_count,
+ dmi, CTRLRTBL);
+
+ DELETE_IF_NOT_NULL(temp_key);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(main_ckv);
+ DELETE_IF_NOT_NULL(okey);
+ UPLL_LOG_DEBUG("GetInstanceCount failed(%d)",result_code);
+ return result_code;
+ }
+
+ IpcReqRespHeader *temp_req = reinterpret_cast<IpcReqRespHeader *>
+ (ConfigKeyVal::Malloc(sizeof(IpcReqRespHeader)));
+
+ if (NULL == temp_req) {
+ UPLL_LOG_DEBUG(" Memory allocation for IpcReqRespHeader failed");
+ DELETE_IF_NOT_NULL(main_ckv);
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
+ temp_req->operation = op;
+ temp_req->datatype = UPLL_DT_CANDIDATE;
+
+ result_code = ValidateCapability(temp_req, main_ckv, ctrl_id);
+ free(temp_req);
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ // FlowList is not supported for other than PFC Controller
+ // so SKIP the adding entry for such sontroller
+ DELETE_IF_NOT_NULL(main_ckv);
+ DELETE_IF_NOT_NULL(okey);
+ if ((!ctrlr_mgr->GetCtrlrType(reinterpret_cast<char *>(ctrl_id),
+ dt_type, &ctrlrtype)) || (ctrlrtype != UNC_CT_PFC)) {
+ UPLL_LOG_DEBUG("Controller type is %d", ctrlrtype);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("Key not supported by controller");
+ return result_code;
+ }
+
ctrlr_val->refcount = 1;
ctrlr_val->valid[1] = UNC_VF_VALID;
ctrlr_val->valid[UPLL_IDX_IP_TYPE_FL] =
main_val->valid[UPLL_IDX_IP_TYPE_FL];
- if (ctrlr_val->valid[UPLL_IDX_IP_TYPE_FL] == UNC_VF_NOT_SOPPORTED) {
+ if (ctrlr_val->valid[UPLL_IDX_IP_TYPE_FL] == UNC_VF_NOT_SUPPORTED) {
ctrlr_val->valid[UPLL_IDX_IP_TYPE_FL] = UNC_VF_INVALID;
}
- result_code = UpdateConfigDB(okey, UPLL_DT_CANDIDATE,
+ if (UPLL_DT_AUDIT == dt_type) {
+ UPLL_LOG_DEBUG("Setting cs cs_attr %d cs_row_status %d", main_val->cs_attr[0], main_val->cs_row_status);
+ ctrlr_val->cs_row_status = (unc_keytype_configstatus_t)main_val->cs_row_status;
+ ctrlr_val->cs_attr[0] = (unc_keytype_configstatus_t)main_val->cs_attr[0];
+ UPLL_LOG_DEBUG("Sutting ctrlr cs cs_attr %d cs_row_status %d", ctrlr_val->cs_attr[0], ctrlr_val->cs_row_status);
+ }
+ result_code = UpdateConfigDB(okey, dt_type,
UNC_OP_CREATE, dmi,
CTRLRTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("UpdateConfigDB failed to create in ctrlrtbl %d",
result_code);
+ DELETE_IF_NOT_NULL(main_ckv);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
+ DELETE_IF_NOT_NULL(main_ckv);
} else if (UPLL_RC_SUCCESS == result_code) {
UPLL_LOG_DEBUG("Entry Already exists in ctrlrtbl");
val_flowlist_ctrl_t *ctrlr_val = reinterpret_cast<val_flowlist_ctrl_t *>
(GetVal(okey));
if (NULL == ctrlr_val) {
UPLL_LOG_DEBUG(" Ctrlr Val struct is NULL");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
ctrlr_val->refcount += 1;
ctrlr_val->valid[1] = UNC_VF_VALID;
- result_code = UpdateConfigDB(okey, UPLL_DT_CANDIDATE,
+ UPLL_LOG_DEBUG("Updating the ctrlrtbl of flowlist");
+ result_code = UpdateConfigDB(okey, dt_type,
UNC_OP_UPDATE, dmi,
CTRLRTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("UpdateConfigDB failed to create in ctrlrtbl %d",
result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
} else {
FlowListEntryMoMgr *mgr = reinterpret_cast<FlowListEntryMoMgr *>
(const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST_ENTRY)));
result_code = mgr->AddFlowListToController(
- flowlist_name, dmi, ctrl_id, op);
+ flowlist_name, dmi, ctrl_id, dt_type, op);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Unable to update the controller table for flowlistentry");
- delete okey;
+ DELETE_IF_NOT_NULL(okey);;
return result_code;
}
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
GET_USER_DATA_CTRLR_DOMAIN(ck_main, ctrlr_dom);
UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom.ctrlr,
ctrlr_dom.domain);
- if (NULL == ctrlr_dom.ctrlr || NULL == ctrlr_dom.domain) {
- UPLL_LOG_INFO("Invalid controller/domain");
+ if (NULL == ctrlr_dom.ctrlr) {
+ UPLL_LOG_DEBUG("Invalid controller/domain");
result_code = UPLL_RC_ERR_GENERIC;
- if (ck_main) delete ck_main;
+ DELETE_IF_NOT_NULL(ck_main);
break;
}
result_code = TxUpdateProcess(ck_main, &resp, op,
affected_ctrlr_set->insert((const char *)ctrlr_dom.ctrlr);
} else {
UPLL_LOG_DEBUG("TxUpdateProcess error %d", result_code);
+ upll_keytype_datatype_t dt_type = (UNC_OP_DELETE == op)?
+ UPLL_DT_RUNNING:UPLL_DT_CANDIDATE;
+ upll_rc_t local_rc = GetRenamedUncKey(resp.ckv_data, dt_type, dmi,
+ ctrlr_dom.ctrlr);
+ if (UPLL_RC_SUCCESS != local_rc &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != local_rc) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey failed %d", local_rc);
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(resp.ckv_data);
+ result_code = UPLL_RC_ERR_GENERIC;
+ break;
+ }
*err_ckv = resp.ckv_data;
- if (ck_main) delete ck_main;
+ DELETE_IF_NOT_NULL(ck_main);
break;
}
+ DELETE_IF_NOT_NULL(resp.ckv_data);
}
- if (ck_main) {
- delete ck_main;
- ck_main = NULL;
- }
+ DELETE_IF_NOT_NULL(ck_main);
}
- if (nreq)
- delete nreq;
- if (req)
- delete req;
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(req);
if (dal_cursor_handle) {
dmi->CloseCursor(dal_cursor_handle, true);
dal_cursor_handle = NULL;
dup_ckmain = NULL;
result_code = GetChildConfigKey(dup_ckmain, ck_main);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
if (dup_ckmain) delete dup_ckmain;
return result_code;
}
result_code = ReadConfigDB(dup_ckmain, UPLL_DT_CANDIDATE,
UNC_OP_READ, dbop, dmi, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
- string s(dup_ckmain->ToStrAll());
UPLL_LOG_DEBUG("%s flowlist read failed from candidatedb (%d)",
- s.c_str(), result_code);
+ (dup_ckmain->ToStrAll()).c_str(), result_code);
delete dup_ckmain;
return result_code;
}
UPLL_LOG_DEBUG("controller disconnected error proceed with commit");
}
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("IpcSend failed %d\n", result_code);
+ UPLL_LOG_DEBUG("IpcSend failed %d", result_code);
}
if ((op == UNC_OP_CREATE) && dup_ckmain) {
delete dup_ckmain;
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
DalResultCode db_result;
- unc_keytype_operation_t op[] = { UNC_OP_CREATE, UNC_OP_DELETE };
+ unc_keytype_operation_t op[] = { UNC_OP_CREATE, UNC_OP_DELETE,
+ UNC_OP_UPDATE};
int nop = sizeof(op) / sizeof(op[0]);
- ConfigKeyVal *flowlist_key = NULL, *req = NULL, *nreq = NULL;
+ ConfigKeyVal *flowlist_key = NULL, *req = NULL, *nreq = NULL , *instance_key = NULL;
DalCursor *cfg1_cursor = NULL;
uint8_t *ctrlr_id = NULL;
map<string, int> ctrlr_result;
// Update the Main table
if (op[i] != UNC_OP_UPDATE) {
result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i],
- req, nreq, &cfg1_cursor, dmi, MAINTBL);
+ req, nreq, &cfg1_cursor, dmi, NULL, MAINTBL ,true);
while (result_code == UPLL_RC_SUCCESS) {
db_result = dmi->GetNextRecord(cfg1_cursor);
result_code = DalToUpllResCode(db_result);
nreq, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Updating Main table Error %d", result_code);
+
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
}
for (int i = 0; i < nop; i++) {
// Update the controller table
result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i], req,
- nreq, &cfg1_cursor, dmi, CTRLRTBL);
+ nreq, &cfg1_cursor, dmi, NULL, CTRLRTBL,true);
ConfigKeyVal *flowlist_ctrlr_key = NULL;
while (result_code == UPLL_RC_SUCCESS) {
db_result = dmi->GetNextRecord(cfg1_cursor);
break;
}
if (op[i] == UNC_OP_CREATE) {
- DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag };
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag | kOpInOutCs };
result_code = GetChildConfigKey(flowlist_key, req);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
result_code);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
- result_code = ReadConfigDB(flowlist_key, UPLL_DT_CANDIDATE,
+ result_code = ReadConfigDB(flowlist_key,UPLL_DT_RUNNING ,
UNC_OP_READ, dbop, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
+ if ((result_code != UPLL_RC_SUCCESS) &&
+ (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
UPLL_LOG_DEBUG("Unable to read configuration from CandidateDb");
- delete flowlist_key;
+ DELETE_IF_NOT_NULL(flowlist_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
result_code = DupConfigKeyVal(flowlist_ctrlr_key, req, CTRLRTBL);
if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(flowlist_key);
UPLL_LOG_DEBUG("DupConfigVal function is failed %d", result_code);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
+ result_code = GetChildConfigKey(instance_key, flowlist_key);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
+ result_code);
+ DELETE_IF_NOT_NULL(flowlist_ctrlr_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+
+ /* set consolidated config status to UNKNOWN to init cs_status
+ * to the cs_status of first controller
+ */
+ uint32_t cur_instance_count;
+ result_code = GetInstanceCount(instance_key, NULL,
+ UPLL_DT_CANDIDATE, &cur_instance_count,
+ dmi, CTRLRTBL);
+ UPLL_LOG_TRACE("in iiiflowlist cs_status %d \n",cur_instance_count);
+ if ((result_code == UPLL_RC_SUCCESS) && (cur_instance_count == 1))
+ reinterpret_cast<val_flowlist *>(GetVal(flowlist_key))->
+ cs_row_status = UNC_CS_UNKNOWN ;
+
+ DELETE_IF_NOT_NULL(instance_key);
+
GET_USER_DATA_CTRLR(flowlist_ctrlr_key, ctrlr_id);
string controller(reinterpret_cast<char *>(ctrlr_id));
result_code = UpdateConfigStatus(flowlist_key, op[i],
- ctrlr_result[controller], NULL,
+ ctrlr_result[controller], nreq,
dmi, flowlist_ctrlr_key);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG(" UpdateConfigStatus Function Failed - %d ",
result_code);
- delete flowlist_key;
+ DELETE_IF_NOT_NULL(flowlist_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
} else if (op[i] == UNC_OP_DELETE) {
- result_code = GetChildConfigKey(flowlist_ctrlr_key, req);
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone,
+ kOpInOutFlag | kOpInOutCs };
+ result_code = GetChildConfigKey(flowlist_key, req);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
+ result_code);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+ GET_USER_DATA_CTRLR(req, ctrlr_id);
+ result_code = ReadConfigDB(flowlist_key, UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Unable to read configuration from RunningDB");
+ DELETE_IF_NOT_NULL(flowlist_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+ if (result_code == UPLL_RC_SUCCESS) {
+ result_code = SetFlowListConsolidatedStatus(flowlist_key,
+ ctrlr_id, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Could not set consolidated status %d",
+ result_code);
+ DELETE_IF_NOT_NULL(flowlist_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+ }
+ result_code = GetChildConfigKey(flowlist_ctrlr_key, req);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed %d", result_code);
+ DELETE_IF_NOT_NULL(flowlist_key);
+ return result_code;
+ }
+ }
+ if (UNC_OP_CREATE == op[i]) {
+ val_flowlist_ctrl_t *val_ctrlr_temp = reinterpret_cast
+ <val_flowlist_ctrl_t *>(GetVal(flowlist_ctrlr_key));
+ val_flowlist_ctrl_t *val_ctrlr_temp1 = reinterpret_cast
+ <val_flowlist_ctrl_t *>(GetVal(req));
+ val_ctrlr_temp->valid[1] = UNC_VF_VALID;
+ val_ctrlr_temp1->refcount = val_ctrlr_temp->refcount;
+ } else if (UNC_OP_UPDATE == op[i]) {
+ result_code = DupConfigKeyVal(flowlist_ctrlr_key, nreq, CTRLRTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetChildConfigKey Failed %d", result_code);
+ UPLL_LOG_DEBUG("DupConfigVal function is failed %d",
+ result_code);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
+ val_flowlist_ctrl_t *val_ctrlr_temp = reinterpret_cast
+ <val_flowlist_ctrl_t *>(GetVal(flowlist_ctrlr_key));
+ val_ctrlr_temp->valid[1] = UNC_VF_VALID;
+ val_flowlist_ctrl_t *val_ctrlr_temp1 = reinterpret_cast
+ <val_flowlist_ctrl_t *>(GetVal(req));
+ val_ctrlr_temp->refcount = val_ctrlr_temp1->refcount;
+ UPLL_LOG_DEBUG("Ref count in dupckv%d", val_ctrlr_temp->refcount);
+ UPLL_LOG_DEBUG("Ref count in req%d", val_ctrlr_temp1->refcount);
}
+
result_code = UpdateConfigDB(flowlist_ctrlr_key, UPLL_DT_RUNNING, op[i],
dmi, CTRLRTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Unable to Update Configuration at DB %d", result_code);
- delete flowlist_ctrlr_key;
+ DELETE_IF_NOT_NULL(flowlist_ctrlr_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
// update the consolidated config status in the Main Table
- if (op[i] != UNC_OP_DELETE) {
- result_code = UpdateConfigDB(flowlist_key, UPLL_DT_RUNNING,
- UNC_OP_UPDATE, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS)
- return result_code;
+ if (op[i] == UNC_OP_CREATE) {
+ result_code = UpdateConfigDB(flowlist_key, UPLL_DT_RUNNING,
+ UNC_OP_UPDATE, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
}
+ }
EnqueCfgNotification(op[i], UPLL_DT_RUNNING, flowlist_ctrlr_key);
if (flowlist_ctrlr_key) delete flowlist_ctrlr_key;
+ DELETE_IF_NOT_NULL(flowlist_key);
flowlist_key = flowlist_ctrlr_key = NULL;
result_code = DalToUpllResCode(db_result);
}
if (req) delete req;
if (nreq) delete nreq;
nreq = req = NULL;
+ result_code = TxCopyRenameTableFromCandidateToRunning(keytype,
+ op[i], dmi);
+ UPLL_LOG_DEBUG("TxCopyRenameTableFromCandidateToRunning returned %d",
+ result_code);
}
result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) ?
UPLL_RC_SUCCESS : result_code;
unc_keytype_configstatus_t cs_status,
uuc::UpdateCtrlrPhase phase,
ConfigKeyVal *&ckv_running) {
+ UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- val_flowlist_t *val;
+ val_flowlist_ctrl_t *val;
val = (ckv_running != NULL)?
- reinterpret_cast<val_flowlist_t *>
+ reinterpret_cast<val_flowlist_ctrl_t *>
(GetVal(ckv_running)):NULL;
if (NULL == val) {
+ UPLL_LOG_DEBUG("Value Structure is Empty");
return UPLL_RC_ERR_GENERIC;
}
+ UPLL_LOG_DEBUG("The Value of Cs Status at start is %d",cs_status);
if (uuc::kUpllUcpCreate == phase )
- val->cs_row_status = cs_status;
- for ( unsigned int loop = 0;
- loop < sizeof(val->valid)/sizeof(val->valid[0]);
- ++loop ) {
- if (cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop])
- val->cs_attr[loop] = cs_status;
- else if (cs_status == UNC_CS_APPLIED)
- val->cs_attr[loop] = cs_status;
- }
+ val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
+ if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[0]) ||
+ cs_status == UNC_CS_APPLIED)
+ val->cs_attr[0] = cs_status;
+
return result_code;
}
DalDmlIntf *dmi) {
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *ckv = NULL;
- DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutNone};
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutCs};
result_code = GetChildConfigKey(ckv, ikey);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("Unable to Get the configKey");
}
std::list< unc_keytype_configstatus_t > list_cs_row;
std::list< unc_keytype_configstatus_t > list_cs_attr;
- val_flowlist_t *val;
- for ( ; ckv != NULL ; ckv = ckv->get_next_cfg_key_val()) {
- val = reinterpret_cast<val_flowlist_t *>(GetVal(ckv));
+ val_flowlist_ctrl_t *val;
+ ConfigKeyVal *temp_ckv = ckv;
+ for ( ; temp_ckv != NULL ; temp_ckv = temp_ckv->get_next_cfg_key_val()) {
+ val = reinterpret_cast<val_flowlist_ctrl_t *>(GetVal(temp_ckv));
list_cs_row.push_back((unc_keytype_configstatus_t)val->cs_row_status);
list_cs_attr.push_back((unc_keytype_configstatus_t)val->cs_attr[0]);
}
+ DELETE_IF_NOT_NULL(ckv);
val_flowlist_t *val_temp = reinterpret_cast<val_flowlist_t *>(GetVal(ikey));
val_temp->cs_row_status = GetConsolidatedCsStatus(list_cs_row);
val_temp->cs_attr[0] = GetConsolidatedCsStatus(list_cs_attr);
uint32_t operation,
uint32_t datatype) {
UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
if (!key->get_cfg_val()) {
// operation is read/read_sibling/read_sibling_begin and data type is import
val_rename_flowlist_t *val_rename_flowlist =
static_cast<val_rename_flowlist_t *>(key->get_cfg_val()->get_val());
+ if (UPLL_DT_IMPORT != datatype) {
if (val_rename_flowlist->valid[UPLL_IDX_RENAME_FLOWLIST_RFL]
!= UNC_VF_VALID) {
UPLL_LOG_DEBUG(" flowlist rename value is not set");
return UPLL_RC_ERR_BAD_REQUEST;
+ }
}
- result_code = ValidateKey(
+ if (val_rename_flowlist->valid[UPLL_IDX_RENAME_FLOWLIST_RFL]
+ == UNC_VF_VALID) {
+ result_code = ValidateKey(
reinterpret_cast<char *>(val_rename_flowlist->flowlist_newname),
(unsigned int)kMinLenFlowListName,
(unsigned int)kMaxLenFlowListName);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG(" flowlist rename value validation failed %s",
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG(" flowlist rename value validation failed %s",
val_rename_flowlist->flowlist_newname);
+ return result_code;
+ }
}
return result_code;
}
if (!key->get_cfg_val()) {
// request val structure can be null in following condition
// operation is delete
- // operation is read_sibiling/read_sibling_begin/read_sibling_count and
- // data type is candidate/running/state/startup
+ // operation is read/read_sibiling/read_sibling_begin/read_sibling_count
+ // and data type is candidate/running/state/startup
//
// request val structure is mandatory when
- // operation is read and
+ // operation is create and
// data type is candidate/running/state/startup
- if ((operation == UNC_OP_CREATE) || (operation == UNC_OP_READ)) {
+ if ((operation == UNC_OP_CREATE)/* || (operation == UNC_OP_READ)*/) {
UPLL_LOG_DEBUG(" val structure is mandatory");
return UPLL_RC_ERR_BAD_REQUEST;
} else {
ConfigKeyVal *ikey,
const char* ctrlr_name) {
UPLL_FUNC_TRACE;
- // TODO(Author) added to bypass capability check
- return UPLL_RC_SUCCESS;
- // endTODO
upll_rc_t ret_val = UPLL_RC_ERR_GENERIC;
return ret_val;
}
- // ctrlr_name is not correct.
if (!ctrlr_name) {
ctrlr_name = static_cast<char *>(ikey->get_user_data());
}
- const std::string version;
- /** Maximum fields in value struct */
- uint32_t dt_type = req->datatype;
- uint32_t operation = req->operation;
- uint32_t option1 = req->option1;
- uint32_t option2 = req->option2;
- UPLL_LOG_TRACE("dt_type : (%d)"
- "operation : (%d)"
- "option1 : (%d)"
- "option2 : (%d)",
- dt_type, operation, option1, option2);
+ if (NULL == ctrlr_name) {
+ UPLL_LOG_DEBUG("ctrlr_name is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_TRACE("ctrlr_name(%s), datatype : (%d)",
+ ctrlr_name, req->datatype);
bool result_code = false;
- uint32_t instance_count = 0;
+ uint32_t max_instance_count = 0;
const uint8_t *attrs = 0;
uint32_t max_attrs = 0;
- switch (operation) {
+ switch (req->operation) {
case UNC_OP_CREATE: {
result_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
- &instance_count, &max_attrs, &attrs);
+ &max_instance_count, &max_attrs, &attrs);
+ if (result_code && (max_instance_count != 0) &&
+ (cur_instance_count >= max_instance_count)) {
+ UPLL_LOG_DEBUG("Instance count %d exceeds %d", cur_instance_count,
+ max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
break;
}
case UNC_OP_UPDATE: {
break;
}
default:
- result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ if (req->datatype == UPLL_DT_STATE) {
+ result_code = GetStateCapability(ctrlr_name, ikey->get_key_type(),
&max_attrs, &attrs);
+ } else {
+ result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ }
break;
}
if (!result_code) {
UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s)"
" for operation(%d)",
- ikey->get_key_type(), ctrlr_name, operation);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
- }
-
- val_flowlist_t *val_flowlist = NULL;
- if (ikey->get_cfg_val() && (ikey->get_cfg_val()->get_st_num() ==
- IpctSt::kIpcStValFlowlist)) {
- val_flowlist =
- reinterpret_cast<val_flowlist_t *>(ikey->get_cfg_val()->get_val());
+ ikey->get_key_type(), ctrlr_name, req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
- if ((operation == UNC_OP_CREATE)) {
- if (dt_type == UPLL_DT_CANDIDATE) {
- if (val_flowlist) {
- if (max_attrs > 0) {
- return ValFlowlistAttributeSupportCheck(val_flowlist, attrs);
- } else {
- UPLL_LOG_DEBUG("Attribute list is empty for operation %d", operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else {
- UPLL_LOG_DEBUG("Error Mandatory value structure is NULL for"
- " CREATE operation ");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- }
- } else if ((READ_SUPPORTED_OPERATION) || (
- ((operation == UNC_OP_READ_NEXT) || (operation == UNC_OP_READ_BULK)) &&
- (dt_type != UPLL_DT_STATE))) {
- if ((READ_SUPPORTED_DATATYPE)|| ((dt_type == UPLL_DT_IMPORT) &&
- (operation != UNC_OP_READ_SIBLING_COUNT))) {
- if (option1 != UNC_OPT1_NORMAL) {
- UPLL_LOG_DEBUG(" Error: option1 is not NORMAL");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- if (option2 != UNC_OPT2_NONE) {
- UPLL_LOG_DEBUG(" Error: option2 is not NONE");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- /** Valid options received, validate value struct */
- if (val_flowlist) {
- if (max_attrs > 0) {
- return ValFlowlistAttributeSupportCheck(val_flowlist, attrs);
- } else {
- UPLL_LOG_DEBUG("Attribute list is empty for operation %d", operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else if ((operation == UNC_OP_READ) && (dt_type == UPLL_DT_STATE)) {
- UPLL_LOG_DEBUG("Error- Mandatory value struct is NULL for READ");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- /** val_flowlist is optional, return SUCCESS if it is NULL*/
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Error Unsupported datatype (%d)", dt_type);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else if (operation == UNC_OP_DELETE) {
- UPLL_LOG_TRACE("skip val struct validation for DELETE");
- return UPLL_RC_SUCCESS;
- }
- UPLL_LOG_DEBUG("Error unsupported operation(%d) ", operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ val_flowlist_t *val_flowlist =
+ reinterpret_cast<val_flowlist_t *>(GetVal(ikey));
+
+ if (val_flowlist) {
+ if (max_attrs > 0) {
+ return ValFlowlistAttributeSupportCheck(val_flowlist, attrs);
+ } else {
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d", req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ return UPLL_RC_SUCCESS;
}
upll_rc_t FlowListMoMgr::ValFlowlistAttributeSupportCheck(
val_flowlist_t *val_flowlist, const uint8_t* attrs ) {
UPLL_FUNC_TRACE;
- if (val_flowlist != NULL) {
- if ((val_flowlist->valid[UPLL_IDX_IP_TYPE_FL] == UNC_VF_VALID)
- || (val_flowlist->valid[UPLL_IDX_IP_TYPE_FL] ==
- UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::flowlist::kCapIpType] == 0) {
- val_flowlist->valid[UPLL_IDX_IP_TYPE_FL] = UNC_VF_NOT_SOPPORTED;
+ if ((val_flowlist->valid[UPLL_IDX_IP_TYPE_FL] == UNC_VF_VALID)
+ || (val_flowlist->valid[UPLL_IDX_IP_TYPE_FL] ==
+ UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::flowlist::kCapIpType] == 0) {
+ val_flowlist->valid[UPLL_IDX_IP_TYPE_FL] = UNC_VF_NOT_SUPPORTED;
- UPLL_LOG_DEBUG("IPType attr is not supported by ctrlr");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
+ UPLL_LOG_DEBUG("IPType attr is not supported by ctrlr");
}
- UPLL_LOG_DEBUG("val_flowlist attribute validation is success");
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Error value struct is NULL");
- return UPLL_RC_ERR_GENERIC;
}
-
- return UPLL_RC_ERR_CFG_SYNTAX;
+ return UPLL_RC_SUCCESS;
}
upll_rc_t FlowListMoMgr::GetRenameInfo(ConfigKeyVal *ikey,
const char *ctrlr_id, bool &renamed) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- if (!ikey || !okey || NULL == rename_info)
+ if (!ikey || !okey || NULL != rename_info
+ || !(ikey->get_key()) || !(okey->get_key())) {
+ UPLL_LOG_DEBUG("Insufficient parameters");
return UPLL_RC_ERR_GENERIC;
-
+ }
key_rename_vnode_info_t *key_rename_info =
reinterpret_cast<key_rename_vnode_info_t*>
(ConfigKeyVal::Malloc(sizeof(key_rename_vnode_info_t)));
key_flowlist_t *flowlist_key = NULL;
- if (!(ikey->get_key())) {
- free(key_rename_info);
- return UPLL_RC_ERR_GENERIC;
- }
flowlist_key = reinterpret_cast<key_flowlist_t *>
(ikey->get_key());
- if (!strlen(reinterpret_cast<char *>
- (flowlist_key->flowlist_name))) {
- free(key_rename_info);
- return UPLL_RC_ERR_GENERIC;
+ if (renamed) {
+ uuu::upll_strncpy(key_rename_info->ctrlr_flowlist_name,
+ reinterpret_cast<val_rename_flowlist_t*>(GetVal(ikey))->flowlist_newname,
+ (kMaxLenFlowListName+1));
+
+ } else {
+ /* if not renamed the ikey contains the controller name */
+ uuu::upll_strncpy(key_rename_info->ctrlr_flowlist_name,
+ flowlist_key->flowlist_name,
+ (kMaxLenFlowListName + 1));
+ UPLL_LOG_DEBUG("key_rename_info->ctrlr_flowlist_name ::: (%s)",
+ key_rename_info->ctrlr_flowlist_name);
}
+
uuu::upll_strncpy(key_rename_info->old_flowlist_name,
flowlist_key->flowlist_name,
(kMaxLenFlowListName+1));
- if (!(okey->get_key())) {
- free(key_rename_info);
- return UPLL_RC_ERR_GENERIC;
- }
flowlist_key = reinterpret_cast<key_flowlist_t *>
(okey->get_key());
- if (!strlen(reinterpret_cast<char *>
- (flowlist_key->flowlist_name))) {
- free(key_rename_info);
- return UPLL_RC_ERR_GENERIC;
- }
uuu::upll_strncpy(key_rename_info->new_flowlist_name,
flowlist_key->flowlist_name,
(kMaxLenFlowListName+1));
rename_info = new ConfigKeyVal(UNC_KT_FLOWLIST,
IpctSt::kIpcInvalidStNum, key_rename_info, NULL);
+ if (!rename_info) {
+ free(key_rename_info);
+ key_rename_info = NULL;
+ UPLL_LOG_DEBUG("Failed to allocate memory for ConfigKeyVal");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ DbSubOp dbop = {kOpReadExist, kOpMatchNone, kOpInOutNone};
+ result_code = UpdateConfigDB(ikey, UPLL_DT_IMPORT,
+ UNC_OP_READ, dmi, &dbop, CTRLRTBL);
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ result_code = UPLL_RC_ERR_NOT_ALLOWED_AT_THIS_TIME;
+ UPLL_LOG_DEBUG("StandAlone configuration found %d", result_code);
+ return result_code;
+ } else if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed - %d", result_code);
+ return result_code;
+ }
SET_USER_DATA_CTRLR(rename_info, ctrlr_id);
if (!renamed) {
val_rename_flowlist_t *val_rename =
uuu::upll_strncpy(val_rename->flowlist_newname,
key_rename_info->old_flowlist_name,
(kMaxLenFlowListName+1));
+ val_rename->valid[UPLL_IDX_RENAME_FLOWLIST_RFL] = UNC_VF_VALID;
ConfigVal *cfg_val = new ConfigVal(IpctSt::kIpcStValRenameFlowlist,
val_rename);
- okey->AppendCfgVal(cfg_val);
+ okey->SetCfgVal(cfg_val);
SET_USER_DATA_CTRLR(okey, ctrlr_id);
- DbSubOp dbop = {kOpNotRead, kOpMatchNone, kOpInOutCtrlr};
+ DbSubOp dbop1 = {kOpNotRead, kOpMatchNone, kOpInOutCtrlr};
result_code = UpdateConfigDB(okey, UPLL_DT_IMPORT, UNC_OP_CREATE, dmi,
- &dbop, RENAMETBL);
+ &dbop1, RENAMETBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG(" GetRenameInfo Failed. UpdateConfigDb Failed"
" Result code - %d", result_code);
- free(key_rename_info);
- // free(val_rename);
}
}
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code)
+ result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_DEBUG("Exiting GetRenameInfo result_code - %d", result_code);
return result_code;
}
UPLL_LOG_DEBUG("Memory allocation failed for ConfigKeyVal");
free(key_flowlist);
result_code = UPLL_RC_ERR_GENERIC;
+ return result_code;
}
+ SET_USER_DATA(okey, ikey);
} else {
UPLL_LOG_DEBUG("Invalid Keytype (%d)", ikey->get_key_type());
result_code = UPLL_RC_ERR_GENERIC;
return result_code;
}
+bool FlowListMoMgr::FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op) {
+ UPLL_FUNC_TRACE;
+ if (op != UNC_OP_CREATE)
+ return CompareValidValue(val1, val2, copy_to_running);
+ return false;
+}
+
bool FlowListMoMgr::CompareValidValue(void *&val1, void *val2,
bool audit) {
UPLL_FUNC_TRACE;
+ bool invalid_attr = true;
val_flowlist_t *flowlist_val1 =
reinterpret_cast<val_flowlist_t *>(val1);
val_flowlist_t *flowlist_val2 =
reinterpret_cast<val_flowlist_t *>(val2);
- if (flowlist_val1 && flowlist_val2) {
- if (audit) {
+// if (flowlist_val1 && flowlist_val2) {
+ // if (audit) {
for ( unsigned int loop = 0; loop < sizeof(flowlist_val1->valid);
++loop ) {
if (UNC_VF_INVALID == flowlist_val1->valid[loop] &&
UNC_VF_VALID == flowlist_val2->valid[loop])
flowlist_val1->valid[loop] = UNC_VF_VALID_NO_VALUE;
}
- }
+ // }
if (UNC_VF_VALID == flowlist_val1->valid[UPLL_IDX_IP_TYPE_FL] &&
UNC_VF_VALID == flowlist_val2->valid[UPLL_IDX_IP_TYPE_FL]) {
if (flowlist_val1->ip_type == flowlist_val2->ip_type) {
flowlist_val1->valid[UPLL_IDX_IP_TYPE_FL] = UNC_VF_INVALID;
}
}
+ for (unsigned int loop = 0;
+ loop < sizeof(flowlist_val1->valid) / sizeof(uint8_t); ++loop) {
+ if ((UNC_VF_VALID == (uint8_t) flowlist_val1->valid[loop]) ||
+ (UNC_VF_VALID_NO_VALUE == (uint8_t) flowlist_val1->valid[loop]))
+ invalid_attr = false;
}
- return false;
+ return invalid_attr;
}
upll_rc_t FlowListMoMgr::UpdateMainTbl(ConfigKeyVal *key_fl,
case UNC_OP_CREATE:
result_code = DupConfigKeyVal(ck_fl, key_fl, MAINTBL);
if (!ck_fl || (result_code != UPLL_RC_SUCCESS)) {
- UPLL_LOG_DEBUG("DupConfigKeyVal() Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("DupConfigKeyVal() Returning error %d", result_code);
return result_code;
}
val_fl = reinterpret_cast<val_flowlist_t *>(GetVal(ck_fl));
if (!val_fl) {
- UPLL_LOG_DEBUG("invalid val \n");
+ UPLL_LOG_DEBUG("invalid val");
return UPLL_RC_ERR_GENERIC;
}
- val_fl->cs_row_status = UNC_CS_NOT_APPLIED;
+ val_fl->cs_row_status = UNC_CS_APPLIED;
break;
case UNC_OP_DELETE:
}
break;
default:
- UPLL_LOG_DEBUG("Inalid operation\n");
+ UPLL_LOG_DEBUG("Inalid operation");
return UPLL_RC_ERR_GENERIC;
}
SET_USER_DATA(okey, ikey);
return UPLL_RC_SUCCESS;
}
+
+upll_rc_t FlowListMoMgr::SetValidAudit(ConfigKeyVal *&ikey) {
+ UPLL_FUNC_TRACE;
+ val_flowlist_t *val = reinterpret_cast
+ <val_flowlist_t *>(GetVal(ikey));
+ if (NULL == val) {
+ UPLL_LOG_DEBUG("val is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val->cs_attr[0] = UNC_CS_APPLIED;
+ val->cs_row_status = UNC_CS_APPLIED;
+ return UPLL_RC_SUCCESS;
+}
} // namespace kt_momgr
} // namespace upll
} // namespace unc
*/
static BindInfo rename_flowlist_rename_tbl[];
+ uint32_t cur_instance_count;
+
/**
* @Brief Validates the syntax of the specified key and value structure
* for KT_FLOWLIST keytype
* @retval UPLL_RC_ERR_GENERIC For failue case GENERIC ERROR
*/
upll_rc_t SwapKeyVal(ConfigKeyVal *ikey, ConfigKeyVal *&okey,
- DalDmlIntf *dmi, uint8_t *ctrlr);
+ DalDmlIntf *dmi, uint8_t *ctrlr, bool &no_rename);
upll_rc_t UpdateConfigStatus(ConfigKeyVal *flowlist_key,
unc_keytype_operation_t op,
* @retval UPLL_RC_SUCCECSS Successful Completion
* @retval UPLL_RC_ERR_GENERIC On Failure
**/
- upll_rc_t GetRenamedControllerKey(ConfigKeyVal *&ikey,
+ upll_rc_t GetRenamedControllerKey(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
controller_domain *ctrlr_dom = NULL);
upll_rc_t AddFlowListToController(char *flowlist_name,
DalDmlIntf *dmi,
char* ctrl_id,
+ upll_keytype_datatype_t dt_type,
unc_keytype_operation_t op);
/**
* @brief Method to Set the Consolidated status
upll_rc_t CreateFlowListToController(
char *flowlist_name, DalDmlIntf *dmi, char* ctrl_id,
- unc_keytype_operation_t op);
+ upll_keytype_datatype_t dt_type, unc_keytype_operation_t op);
upll_rc_t DeleteFlowListToController(
char *flowlist_name, DalDmlIntf *dmi, char* ctrl_id,
- unc_keytype_operation_t op);
+ upll_keytype_datatype_t dt_type, unc_keytype_operation_t op);
+
+ upll_rc_t SetValidAudit(ConfigKeyVal *&ikey);
+
+ bool FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op);
+
+ upll_rc_t SetFlowListConsolidatedStatus(ConfigKeyVal *ikey,
+ uint8_t *ctrlr_id,
+ DalDmlIntf *dmi);
};
typedef struct val_flowlist_ctrl {
#include "pfc/log.h"
#include "ipct_st.hh"
-
#include "unc/uppl_common.h"
#include "unc/upll_svc.h"
#include "unc/pfcdriver_include.h"
+#include "unc/vnpdriver_include.h"
#include "unc/unc_base.h"
#include "ctrlr_mgr.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "upll_util.hh"
#include "kt_util.hh"
#include "ipc_util.hh"
delete cv;
cv = tmp_cv;
}
- cv = NULL;
+ next_cfg_val_ = NULL;
}
std::string ConfigVal::ToStr() const {
unc_keytype_ctrtype_t ctrlr_type, uint32_t driver_result_code) {
switch (ctrlr_type) {
case UNC_CT_PFC:
+ case UNC_CT_VNP:
{
switch (driver_result_code) {
case DRVAPI_RESPONSE_SUCCESS:
}
}
break;
- //case UNC_CT_LEGACY:
- case UNC_CT_VNP:
default:
return UPLL_RC_ERR_GENERIC;
}
pfc_ipcid_t /* service_id */,
IpcRequest *req, bool /* edit_conn */,
IpcResponse *resp) {
+ UPLL_FUNC_TRACE
PFC_ASSERT(ctrlr_name != NULL);
unc_keytype_ctrtype_t ctrlr_type = UNC_CT_UNKNOWN;
pfc_ipcid_t service_id;
if (unc::upll::config_momgr::CtrlrMgr::GetInstance()->GetCtrlrType(
- ctrlr_name, req->header.datatype, &ctrlr_type) == false) {
- UPLL_LOG_WARN("Unable to get controller type for %s", ctrlr_name);
- resp->header.result_code = UPLL_RC_ERR_GENERIC;
- return false;
+ ctrlr_name, req->header.datatype, &ctrlr_type) == false) {
+ if ((req->header.operation == UNC_OP_DELETE) &&
+ (req->header.datatype != UPLL_DT_RUNNING)) {
+ if (unc::upll::config_momgr::CtrlrMgr::GetInstance()->GetCtrlrType(
+ ctrlr_name, UPLL_DT_RUNNING, &ctrlr_type) == false) {
+ UPLL_LOG_WARN("Unable to get controller type for %s", ctrlr_name);
+ resp->header.result_code = UPLL_RC_ERR_GENERIC;
+ return false;
+ }
+ } else {
+ UPLL_LOG_WARN("Unable to get controller type for %s", ctrlr_name);
+ resp->header.result_code = UPLL_RC_ERR_GENERIC;
+ return false;
+ }
}
switch (ctrlr_type) {
case UNC_CT_PFC:
service_name = PFCDRIVER_SERVICE_NAME;
service_id = PFCDRIVER_SVID_LOGICAL;
break;
- // TODO(a) need to do for other controller types
+ case UNC_CT_VNP:
+ channel_name = VNPDRIVER_CHANNEL_NAME;
+ service_name = VNPDRIVER_SERVICE_NAME;
+ service_id = VNPDRV_SVID_LOGICAL;
+ break;
default:
UPLL_LOG_WARN("Unknown controller type %d", ctrlr_type);
resp->header.result_code = UPLL_RC_ERR_GENERIC;
switch (result_code) {
case UPPL_RC_SUCCESS:
return UPLL_RC_SUCCESS;
+ case UPPL_RC_ERR_NO_SUCH_INSTANCE:
+ return UPLL_RC_ERR_NO_SUCH_INSTANCE;
default:
return UPLL_RC_ERR_GENERIC;
}
bool driver_msg,
const char *ctrlr_name, char *domain_id,
IpcRequest *req, IpcResponse *resp) {
+ UPLL_FUNC_TRACE
if (channel_name == NULL || service_name == NULL ||
req == NULL || resp == NULL) {
UPLL_LOG_DEBUG("NULL argument");
return false;
}
+ // Increasing IPC session timeout
+ if (req->header.operation == UNC_OP_CONTROL &&
+ req->header.option2 == UNC_OPT2_PING) {
+ pfc_timespec_t sess_timeout;
+ sess_timeout.tv_sec = kIpcTimeoutPing;
+ sess_timeout.tv_nsec = 0;
+ cl_sess.setTimeout(&sess_timeout);
+ UPLL_LOG_TRACE("IPC Client Session timeout for channel %s set to %d secs"
+ " for operation %d",
+ channel_name, kIpcTimeoutPing, req->header.operation);
+
+ } else if ((driver_msg) && (req->header.operation == UNC_OP_READ_BULK)) {
+ // Import takes lot of time
+ cl_sess.setTimeout(NULL);
+ UPLL_LOG_TRACE("IPC Client Session timeout for channel %s set to infinity"
+ " for operation %d",
+ channel_name, req->header.operation);
+ }
+
bool ret = WriteKtRequest(&cl_sess, driver_msg, ctrlr_name, domain_id,
req->header, req->ckv_data);
if (!ret) {
pfc_ipcresp_t ipcresp;
err = cl_sess.invoke(ipcresp);
if (err != 0) {
- pfc_log_fatal("Failed to send IPC request to %s:%s:%d. Err=%d",
+ resp->header.result_code = UPLL_RC_ERR_GENERIC;
+ if (err == ETIMEDOUT) {
+ UPLL_LOG_DEBUG("IPC Session to %s:%s:%d has timed out",
+ channel_name, service_name, service_id);
+ resp->return_code = PFC_IPCRESP_FATAL;
+ } else {
+ pfc_log_fatal("Failed to send IPC request to %s:%s:%d. Err=%d",
channel_name, service_name, service_id, err);
+ resp->return_code = PFC_IPCRESP_FATAL;
+ }
err = pfc_ipcclnt_altclose(connid); // Close the IPC connection handle
if (err != 0) {
UPLL_LOG_DEBUG("Failed to close the IPC connection %s:%s:%d. Err=%d",
channel_name, service_name, service_id, err);
}
- resp->header.result_code = UPLL_RC_ERR_GENERIC;
- resp->return_code = PFC_IPCRESP_FATAL;
return false;
}
if (ipcresp != 0) {
resp->ckv_data = new ConfigKeyVal(local_resp.ckv_data->get_key_type());
}
resp->ckv_data->ResetWith(local_resp.ckv_data);
+ if (local_resp.ckv_data)
+ delete local_resp.ckv_data;
resp->return_code = 0;
/* Close the IPC connection handle. */
*ipc_struct);
break;
case PFC_IPCTYPE_STRING:
- *st_num = IpctSt::kIpcStString;
- READ_PRIMARY_IPCTYPE_FROM_SERVER(sess, index, const char *,
- *ipc_struct);
+ {
+ *st_num = IpctSt::kIpcStString;
+ READ_PRIMARY_IPCTYPE_FROM_SERVER(sess, index, const char *,
+ *ipc_struct);
+ char *str = strdup(*(reinterpret_cast<char **>(*ipc_struct)));
+ *ipc_struct = str;
+ }
break;
case PFC_IPCTYPE_STRUCT:
ret = ReadIpcStruct(sess, index, st_num, ipc_struct);
*ipc_struct);
break;
case PFC_IPCTYPE_STRING:
- *st_num = IpctSt::kIpcStString;
- READ_PRIMARY_IPCTYPE_FROM_CLIENT(sess, index, const char *,
- *ipc_struct);
+ {
+ *st_num = IpctSt::kIpcStString;
+ READ_PRIMARY_IPCTYPE_FROM_CLIENT(sess, index, const char *,
+ *ipc_struct);
+ char *str = strdup(*(reinterpret_cast<char **>(*ipc_struct)));
+ *ipc_struct = str;
+ }
break;
case PFC_IPCTYPE_STRUCT:
ret = ReadIpcStruct(sess, index, st_num, ipc_struct);
WRITE_PRIMARY_IPCTYPE(sess, addOutput, struct in6_addr, ipc_struct);
break;
case IpctSt::kIpcStString:
- WRITE_PRIMARY_IPCTYPE(sess, addOutput, const char *, ipc_struct);
+ /* With -03 the following line gives compilation error.
+ * So macro isn't used.
+ * WRITE_PRIMARY_IPCTYPE(sess, addOutput, const char *, &ipc_struct);
+ */
+ {
+ ret = true;
+ int ipc_ret = sess->addOutput(
+ reinterpret_cast<const char *>(ipc_struct));
+ if (ipc_ret != 0) {
+ UPLL_LOG_DEBUG("Failed to read argument in the IPC request, Err=%d",
+ ipc_ret);
+ ret = false;
+ }
+ }
break;
case IpctSt::kIpcStBinary:
return false;
WRITE_PRIMARY_IPCTYPE(sess, addOutput, struct in6_addr, ipc_struct);
break;
case IpctSt::kIpcStString:
- WRITE_PRIMARY_IPCTYPE(sess, addOutput, const char *, ipc_struct);
+ /* With -03 the following line gives compilation error.
+ * So macro isn't used.
+ * WRITE_PRIMARY_IPCTYPE(sess, addOutput, const char *, &ipc_struct);
+ */
+ {
+ ret = true;
+ int ipc_ret = sess->addOutput(
+ reinterpret_cast<const char *>(ipc_struct));
+ if (ipc_ret != 0) {
+ UPLL_LOG_DEBUG("Failed to read argument in the IPC request, Err=%d",
+ ipc_ret);
+ ret = false;
+ }
+ }
break;
case IpctSt::kIpcStBinary:
return false;
pfc_ipcid_t /* service */,
IpcReqRespHeader *msg_hdr,
ConfigKeyVal **first_ckv) {
+ UPLL_FUNC_TRACE;
if (sess == NULL || msg_hdr == NULL || first_ckv == NULL) {
UPLL_LOG_DEBUG("Null argument");
return false;
return;
}
UPLL_LOG_TRACE("IpcReponse: Pos %d: %s", arg, st_name.c_str());
-
}
}
arg++;
bool driver_msg, char *domain_id,
IpcReqRespHeader *msg_hdr,
ConfigKeyVal **first_ckv) {
+ UPLL_FUNC_TRACE;
if (sess == NULL || msg_hdr == NULL || first_ckv == NULL) {
UPLL_LOG_DEBUG("Null argument");
return false;
}
*first_ckv = new ConfigKeyVal((unc_key_type_t)keytype, st_num, ipc_st, NULL);
ConfigKeyVal *curr_ckv = *first_ckv;
+ ConfigVal *curr_cv = NULL;
// read all key type and value structures
while (arg < arg_cnt) {
st_num, ipc_st, NULL);
curr_ckv->set_next_cfg_key_val(next_ckv);
curr_ckv = next_ckv;
+ curr_cv = NULL;
} else {
if (!IpcUtil::ReadIpcArg(sess, arg++, &st_num, &ipc_st)) {
UPLL_LOG_DEBUG("Failed to get structure at %u in the key tree response",
*first_ckv = NULL;
return false;
}
- curr_ckv->AppendCfgVal(st_num, ipc_st);
+ if (curr_cv == NULL) {
+ curr_ckv->AppendCfgVal(st_num, ipc_st);
+ curr_cv = curr_ckv->get_cfg_val();
+ } else {
+ curr_cv->AppendCfgVal(st_num, ipc_st);
+ curr_cv = curr_cv->get_next_cfg_val();
+ }
}
}
return true;
#include "./keytype_upll_ext.h"
#include "ipct_st.hh"
-
+#include "uncxx/upll_log.hh"
namespace unc {
namespace upll {
+static const uint32_t kIpcTimeoutPing = 330;
+static const uint32_t kIpcTimeoutImport = 300;
+
namespace ipc_util {
// using pfc::core::ipc::ServerSession;
next_cfg_val_ = NULL;
user_data_ = NULL;
}
- virtual ~ConfigVal() {
- if (next_cfg_val_)
- delete next_cfg_val_;
- next_cfg_val_ = NULL;
+ inline virtual ~ConfigVal() {
if (val_)
free(val_);
val_ = NULL;
- // DeleteNextCfgVal();
if (user_data_)
free(user_data_);
user_data_ = NULL;
+ DeleteNextCfgVal();
}
inline IpctSt::IpcStructNum get_st_num() const { return st_num_; }
inline void *get_val() const { return val_; }
+ inline void *GetValAndUnlink() {
+ void *t = val_;
+ val_ = NULL;
+ return t;
+ }
inline void SetVal(IpctSt::IpcStructNum st_num, void *val) {
st_num_ = st_num;
if (val_) free(val_);
}
inline ConfigVal *get_cfg_val() const { return cfg_val_; }
- void SetCfgVal(ConfigVal *val) {
+ inline void SetCfgVal(ConfigVal *val) {
DeleteCfgVal();
cfg_val_ = val;
}
- void AppendCfgVal(IpctSt::IpcStructNum st_num, void *val) {
+ inline void AppendCfgVal(IpctSt::IpcStructNum st_num, void *val) {
ConfigVal *cv = new ConfigVal(st_num, val);
AppendCfgVal(cv);
}
cfg_val_->AppendCfgVal(cv);
}
}
+ inline ConfigVal *GetCfgValAndUnlink() {
+ ConfigVal *t = cfg_val_;
+ cfg_val_ = NULL;
+ return t;
+ }
inline void DeleteCfgVal() {
if (cfg_val_) {
SetKey(from->st_num_, from->key_);
from->key_ = NULL;
SetUserData(from->user_data_);
- from->user_data_ = NULL;
+ from->user_data_ = NULL;
DeleteCfgVal();
AppendCfgVal(from->cfg_val_);
from->cfg_val_ = NULL;
std::string ToStr() const;
std::string ToStrAll() const;
- static void *Malloc(size_t size) throw (std::bad_alloc) {
+ static void *Malloc(size_t size) throw(std::bad_alloc) {
void *ptr = malloc(size);
if (ptr == NULL) {
throw new std::bad_alloc;
const char *IpctSt::kIpcStrStValBoundary = "val_boundary";
const char *IpctSt::kIpcStrStValBoundarySt = "val_boundary_st";
const char *IpctSt::kIpcStrStValPathFaultAlarm = "val_path_fault_alarm";
+ // Add Overlay Driver structures below
+const char *IpctSt::kIpcStrStVnpdrvValVtunnel = "vnpdrv_val_vtunnel";
+const char *IpctSt::kIpcStrStVnpdrvValVtunnelIf ="vnpdrv_val_vtunnel_if";
std::map<std::string, const pfc_ipcstdef_t*> IpctSt::ipc_stdef_smap_;
std::map<IpctSt::IpcStructNum, const pfc_ipcstdef_t*> IpctSt::ipc_stdef_nmap_;
REGISTER_STDEF(val_boundary,
kIpcStrStValBoundary,
kIpcStValBoundary);
+ REGISTER_STDEF(val_boundary_st,
+ kIpcStrStValBoundarySt,
+ kIpcStValBoundarySt);
+ // Add Overlay Driver structures below
+ REGISTER_STDEF(vnpdrv_val_vtunnel,
+ kIpcStrStVnpdrvValVtunnel,
+ kIpcStVnpdrvValVtunnel);
+ REGISTER_STDEF(vnpdrv_val_vtunnel_if,
+ kIpcStrStVnpdrvValVtunnelIf,
+ kIpcStVnpdrvValVtunnelIf);
}
} // namespace ipc_util
static const char *kIpcStrStValBoundary;
static const char *kIpcStrStValBoundarySt;
static const char *kIpcStrStValPathFaultAlarm;
+ // Overlay Driver structures
+ static const char *kIpcStrStVnpdrvValVtunnel;
+ static const char *kIpcStrStVnpdrvValVtunnelIf;
enum IpcStructNum {
kIpcInvalidStNum = 0,
kIpcStKeyBoundary,
kIpcStValBoundary,
kIpcStValBoundarySt,
- kIpcStValPathFaultAlarm
+ kIpcStValPathFaultAlarm,
+ // Overlay Driver structures
+ kIpcStVnpdrvValVtunnel,
+ kIpcStVnpdrvValVtunnelIf
}; // enum IpcStructNum
static uint32_t Register(const char *stname, IpcStructNum stnum);
namespace upll {
namespace kt_momgr {
+ uint16_t IpRouteMoMgr::kIpRouteNumChildKey = 4;
+
BindInfo IpRouteMoMgr::ip_route_bind_info[] = {
{ uudst::static_ip_route::kDbiVtnName, CFG_KEY, offsetof(
key_static_ip_route, vrt_key.vtn_key.vtn_name),
return PFC_TRUE;
}
-upll_rc_t IpRouteMoMgr::ValidateAttribute(ConfigKeyVal *ikey,
+upll_rc_t IpRouteMoMgr::ValidateAttribute(ConfigKeyVal *ikey,
DalDmlIntf *dmi,
IpcReqRespHeader *req) {
UPLL_FUNC_TRACE;
}
bool IpRouteMoMgr::IsValidKey(void *key, uint64_t index) {
+ UPLL_FUNC_TRACE;
key_static_ip_route *iproute_key =
reinterpret_cast<key_static_ip_route*>(key);
- pfc_log_trace("Entering IsValidKey");
uint32_t val = 0;
- bool ret_val = UPLL_RC_SUCCESS;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
switch (index) {
case uudst::static_ip_route::kDbiVtnName:
ret_val = ValidateKey(
reinterpret_cast<char *>(iproute_key->vrt_key.vtn_key.vtn_name),
kMinLenVtnName, kMaxLenVtnName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_trace("VTN Name is not valid(%d)", ret_val);
+ UPLL_LOG_TRACE("VTN Name is not valid(%d)", ret_val);
return false;
}
break;
reinterpret_cast<char *>(iproute_key->vrt_key.vrouter_name),
kMinLenVnodeName, kMaxLenVnodeName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_trace("VRouter Name is not valid(%d)", ret_val);
+ UPLL_LOG_TRACE("VRouter Name is not valid(%d)", ret_val);
return false;
}
break;
case uudst::static_ip_route::kDbiDstIpAddr:
val = iproute_key->dst_addr.s_addr;
- if (val == 0xffffffff || val == 0x00000000) {
- pfc_log_trace("Invalid destination Address");
+ if (val == 0xffffffff) {
+ UPLL_LOG_TRACE("Invalid destination Address");
return false;
}
break;
case uudst::static_ip_route::kDbiNextHopAddr:
val = iproute_key->next_hop_addr.s_addr;
if (val == 0xffffffff || val == 0x00000000) {
- pfc_log_trace("Invalid Next Hop Addr Address");
+ UPLL_LOG_TRACE("Invalid Next Hop Addr Address");
return false;
}
break;
case uudst::static_ip_route::kDbiMask:
if (!ValidateNumericRange(iproute_key->dst_addr_prefixlen,
- (uint8_t) kMinIpv4Prefix,
- (uint8_t) kMaxIpv4Prefix, true, true)) {
- pfc_log_trace(
+ (uint8_t) kMinIpRoutePrefix,
+ (uint8_t) kMaxIpRoutePrefix, true, true)) {
+ UPLL_LOG_TRACE(
"Numeric range check failure for iproute_key->dst_addr_prefixlen");
return false;
}
ret_val = ValidateKey(reinterpret_cast<char *>(iproute_key->nwm_name),
kMinLenNwmName, kMaxLenNwmName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_trace("syntax check failure for iproute_key->nwm_name");
+ UPLL_LOG_TRACE("syntax check failure for iproute_key->nwm_name");
return false;
}
break;
default:
-// pfc_log_trace("Invalid Key Index %d", index);
+// UPLL_LOG_TRACE("Invalid Key Index %d", index);
break;
}
- pfc_log_trace("Leaving IsValidKey");
return true;
}
ConfigKeyVal *parent_key) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- key_static_ip_route *vrt_ip_route;
+ key_static_ip_route *vrt_ip_route = NULL;
void *pkey;
if (parent_key == NULL) {
vrt_ip_route = reinterpret_cast<key_static_ip_route *>
- (malloc(sizeof(key_static_ip_route)));
- if (!vrt_ip_route) return UPLL_RC_ERR_GENERIC;
- memset(vrt_ip_route, 0, sizeof(key_static_ip_route));
+ (ConfigKeyVal::Malloc(sizeof(key_static_ip_route)));
+ if (okey) delete okey;
okey = new ConfigKeyVal(UNC_KT_VRT_IPROUTE, IpctSt::kIpcStKeyStaticIpRoute,
vrt_ip_route, NULL);
+ vrt_ip_route->dst_addr_prefixlen = INVALID_PREFIX_LENGTH;
+ vrt_ip_route->dst_addr.s_addr = INVALID_DST_IP_ADDR;
+ vrt_ip_route->next_hop_addr.s_addr = INVALID_NEXT_HOP_ADDR;
return UPLL_RC_SUCCESS;
} else {
pkey = parent_key->get_key();
vrt_ip_route = reinterpret_cast<key_static_ip_route *>(okey->get_key());
} else {
vrt_ip_route = reinterpret_cast<key_static_ip_route *>
- (malloc(sizeof(key_static_ip_route)));
- if (!vrt_ip_route) return UPLL_RC_ERR_GENERIC;
- memset(vrt_ip_route, 0, sizeof(key_static_ip_route));
+ (ConfigKeyVal::Malloc(sizeof(key_static_ip_route)));
+ vrt_ip_route->dst_addr_prefixlen = INVALID_PREFIX_LENGTH;
+ vrt_ip_route->dst_addr.s_addr = INVALID_DST_IP_ADDR;
+ vrt_ip_route->next_hop_addr.s_addr = INVALID_NEXT_HOP_ADDR;
}
unc_key_type_t keytype = parent_key->get_key_type();
- vrt_ip_route->dst_addr.s_addr = 0;
- vrt_ip_route->dst_addr_prefixlen = 0;
- vrt_ip_route->next_hop_addr.s_addr = 0;
- *(vrt_ip_route->nwm_name) = *"";
switch (keytype) {
case UNC_KT_VTN:
uuu::upll_strncpy(vrt_ip_route->vrt_key.vtn_key.vtn_name,
reinterpret_cast<key_static_ip_route *>(pkey)->next_hop_addr.s_addr;
break;
default:
- free(vrt_ip_route);
+ if (!okey || !(okey->get_key()))
+ free(vrt_ip_route);
return UPLL_RC_ERR_GENERIC;
}
if (!okey)
okey = new ConfigKeyVal(UNC_KT_VRT_IPROUTE, IpctSt::kIpcStKeyStaticIpRoute,
vrt_ip_route, NULL);
+ else if (okey->get_key() != vrt_ip_route)
+ okey->SetKey(IpctSt::kIpcStKeyStaticIpRoute, vrt_ip_route);
if (okey == NULL) {
free(vrt_ip_route);
result_code = UPLL_RC_ERR_GENERIC;
key_static_ip_route *pkey = reinterpret_cast<key_static_ip_route *>
(ikey->get_key());
if (!pkey) return UPLL_RC_ERR_GENERIC;
- key_vrt *vrt_key = reinterpret_cast<key_vrt *>(malloc(sizeof(key_vrt)));
- if (!vrt_key) return UPLL_RC_ERR_GENERIC;
- memset(vrt_key, 0, sizeof(key_vrt));
+ key_vrt *vrt_key = reinterpret_cast<key_vrt *>
+ (ConfigKeyVal::Malloc(sizeof(key_vrt)));
uuu::upll_strncpy(vrt_key->vtn_key.vtn_name,
pkey->vrt_key.vtn_key.vtn_name, (kMaxLenVtnName + 1));
uuu::upll_strncpy(vrt_key->vrouter_name,
if (ck_val != NULL) return UPLL_RC_ERR_GENERIC;
switch (tbl) {
case MAINTBL:
- val = malloc(sizeof(val_static_ip_route));
- if (!val) return UPLL_RC_ERR_GENERIC;
- memset(val, 0, sizeof(val_static_ip_route));
+ val = ConfigKeyVal::Malloc(sizeof(val_static_ip_route));
ck_val = new ConfigVal(IpctSt::kIpcStValStaticIpRoute, val);
break;
default:
if (tbl == MAINTBL) {
val_static_ip_route *ival =
reinterpret_cast<val_static_ip_route *>(GetVal(req));
+ if (ival == NULL) {
+ UPLL_LOG_DEBUG("NULL val structure");
+ return UPLL_RC_ERR_GENERIC;
+ }
val_static_ip_route *vrt_val =
- reinterpret_cast<val_static_ip_route *>(malloc(
+ reinterpret_cast<val_static_ip_route *>(ConfigKeyVal::Malloc(
sizeof(val_static_ip_route)));
- if (!vrt_val) return UPLL_RC_ERR_GENERIC;
memcpy(vrt_val, ival, sizeof(val_static_ip_route));
tmp1 = new ConfigVal(IpctSt::kIpcStValStaticIpRoute, vrt_val);
}
};
- void *tkey = (req != NULL) ? (req)->get_key() : NULL;
+ void *tkey = (req)->get_key();
key_static_ip_route *ikey;
if (tkey) {
ikey = reinterpret_cast<key_static_ip_route *>(tkey);
return UPLL_RC_ERR_GENERIC;
}
key_static_ip_route *vrt_key =
- reinterpret_cast<key_static_ip_route *>(malloc(
+ reinterpret_cast<key_static_ip_route *>(ConfigKeyVal::Malloc(
sizeof(key_static_ip_route)));
- if (!vrt_key) return UPLL_RC_ERR_GENERIC;
memcpy(vrt_key, ikey, sizeof(key_static_ip_route));
okey = new ConfigKeyVal(UNC_KT_VRT_IPROUTE, IpctSt::kIpcStKeyStaticIpRoute,
vrt_key, tmp1);
upll_rc_t IpRouteMoMgr::UpdateConfigStatus(ConfigKeyVal *ikey,
unc_keytype_operation_t op,
uint32_t driver_result,
- ConfigKeyVal *upd_key,
+ ConfigKeyVal *upd_key,
DalDmlIntf *dmi,
ConfigKeyVal *ctrlr_key) {
UPLL_FUNC_TRACE;
val_static_ip_route *vrt_val =
- reinterpret_cast<val_static_ip_route *>(GetVal(ikey));
+ static_cast<val_static_ip_route *>(GetVal(ikey));
+ if (vrt_val == NULL) return UPLL_RC_ERR_GENERIC;
+ val_static_ip_route *vrt_val2 =
+ reinterpret_cast<val_static_ip_route *>(GetVal(upd_key));
unc_keytype_configstatus_t cs_status =
- (driver_result == 0) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
- if (vrt_val == NULL) return UPLL_RC_ERR_GENERIC;
- vrt_val->cs_row_status = cs_status;
+ (driver_result == UPLL_RC_SUCCESS) ? UNC_CS_APPLIED
+ : UNC_CS_NOT_APPLIED;
+ UPLL_LOG_TRACE("%s", (ikey->ToStrAll()).c_str());
if (op == UNC_OP_CREATE) {
- for (unsigned int loop = 0;
- loop < (sizeof(vrt_val->valid) / sizeof(vrt_val->valid[0]));
- ++loop) {
- // Setting CS to the not supported attributes
- if (UNC_VF_NOT_SOPPORTED == vrt_val->valid[loop]) {
- vrt_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
- continue;
- }
- if ((UNC_VF_VALID == (uint8_t) vrt_val->valid[loop])
- || (UNC_VF_VALID_NO_VALUE == (uint8_t) vrt_val->valid[loop]))
- vrt_val->cs_attr[loop] = cs_status;
- }
+ vrt_val->cs_row_status = cs_status;
} else if (op == UNC_OP_UPDATE) {
void *val = reinterpret_cast<void *>(&vrt_val);
CompareValidValue(val, GetVal(upd_key), true);
- for (unsigned int loop = 0;
- loop < (sizeof(vrt_val->valid) / sizeof(vrt_val->valid[0]));
- ++loop) {
- if ((uint8_t) vrt_val->valid[loop] != UNC_VF_NOT_SOPPORTED) {
- if ((UNC_VF_VALID == (uint8_t) vrt_val->valid[loop])
- || (UNC_VF_VALID_NO_VALUE == (uint8_t) vrt_val->valid[loop]))
- vrt_val->cs_attr[loop] = cs_status;
- } else {
- vrt_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
- }
- }
+ UPLL_LOG_TRACE("%s", (upd_key->ToStrAll()).c_str());
+ vrt_val->cs_row_status = vrt_val2->cs_row_status;
} else {
return UPLL_RC_ERR_GENERIC;
}
+ for (unsigned int loop = 0;
+ loop < (sizeof(vrt_val->valid) / sizeof(vrt_val->valid[0]));
+ ++loop) {
+ if ((UNC_VF_VALID == vrt_val->valid[loop])
+ || (UNC_VF_VALID_NO_VALUE == vrt_val->valid[loop])) {
+ vrt_val->cs_attr[loop] = cs_status;
+ } else if ((UNC_VF_INVALID == vrt_val->valid[loop]) &&
+ (UNC_OP_CREATE == op)) {
+ vrt_val->cs_attr[loop] = UNC_CS_APPLIED;
+ } else if ((UNC_VF_INVALID == vrt_val->valid[loop]) &&
+ (UNC_OP_UPDATE == op)) {
+ vrt_val->cs_attr[loop] = vrt_val2->cs_attr[loop];
+ }
+ }
return UPLL_RC_SUCCESS;
}
return UPLL_RC_ERR_GENERIC;
}
if (uuc::kUpllUcpCreate == phase) val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
for (unsigned int loop = 0; loop < sizeof(val->valid) / sizeof(uint8_t);
++loop) {
- if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
+ if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
cs_status == UNC_CS_APPLIED) {
val->cs_attr[loop] = cs_status;
}
if (dt_type == UPLL_DT_CANDIDATE || UPLL_DT_IMPORT == dt_type) {
if (NULL == ikey->get_cfg_val()) {
UPLL_LOG_DEBUG("ConfigVal struct is empty");
- return UPLL_RC_SUCCESS;
+ if (UNC_OP_UPDATE == op) {
+ return UPLL_RC_ERR_BAD_REQUEST;
+ } else {
+ return UPLL_RC_SUCCESS;
+ }
}
if (ikey->get_cfg_val()->get_st_num() != IpctSt::kIpcStValStaticIpRoute) {
UPLL_LOG_DEBUG(
}
ret_val = ValidateIpRouteValue(iproute_val, op);
if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("syntax check failure for val_static_ip_route structure");
+ UPLL_LOG_DEBUG("Syntax check failure for val_static_ip_route");
return UPLL_RC_ERR_CFG_SYNTAX;
}
return UPLL_RC_SUCCESS;
} else {
UPLL_LOG_DEBUG("Unsupported data type - (%d)", dt_type);
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
} else if (op == UNC_OP_READ || op == UNC_OP_READ_SIBLING
|| op == UNC_OP_READ_SIBLING_BEGIN || op == UNC_OP_READ_SIBLING_COUNT) {
}
ret_val = ValidateIpRouteValue(iproute_val, op);
if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("syntax check failure for val_static_ip_route structure");
+ UPLL_LOG_DEBUG("Syntax check failure for val_static_ip_route");
return UPLL_RC_ERR_CFG_SYNTAX;
}
return UPLL_RC_SUCCESS;
} else {
UPLL_LOG_DEBUG("Unsupported data type - (%d)", dt_type);
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
} else if (op == UNC_OP_READ_NEXT || op == UNC_OP_READ_BULK) {
if (dt_type == UPLL_DT_CANDIDATE || dt_type == UPLL_DT_RUNNING
return UPLL_RC_SUCCESS;
} else {
UPLL_LOG_DEBUG("Unsupported data type - (%d)", dt_type);
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
}
UPLL_LOG_DEBUG("Unsupported operation - (%d)", op);
iproute_key->vrt_key.vrouter_name);
return UPLL_RC_ERR_CFG_SYNTAX;
}
- if ((operation != UNC_OP_READ_SIBLING_BEGIN) &&
- (operation != UNC_OP_READ_SIBLING_COUNT)) {
- if (strlen(reinterpret_cast<char*>(iproute_key->nwm_name)) != 0) {
- ret_val = ValidateKey(reinterpret_cast<char *>(iproute_key->nwm_name),
- kMinLenNwmName,
- kMaxLenNwmName);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("syntax check failed. nwm name - %s", iproute_key->nwm_name);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- }
- if (!ValidateNumericRange(iproute_key->dst_addr_prefixlen,
- (uint8_t) kMinIpv4Prefix, (uint8_t) kMaxIpv4Prefix,
- true, true)) {
- UPLL_LOG_DEBUG("Numeric range check failed. dst_addr_prefixlen - %d",
- iproute_key->dst_addr_prefixlen);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- if (iproute_key->dst_addr.s_addr == 0xffffffff) {
- UPLL_LOG_DEBUG("Bad destination address. addr:0x%08x\n",
- iproute_key->dst_addr.s_addr);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- if (iproute_key->next_hop_addr.s_addr == 0xffffffff) {
- UPLL_LOG_DEBUG("Bad next hop address. addr:0x%08x\n",
- iproute_key->next_hop_addr.s_addr);
+
+ if ((operation == UNC_OP_READ_SIBLING_BEGIN) ||
+ (operation == UNC_OP_READ_SIBLING_COUNT)) {
+ // Poisoning child keys for this operation
+ UPLL_LOG_TRACE("Operation is %d", operation);
+ StringReset(iproute_key->nwm_name);
+ iproute_key->dst_addr_prefixlen = INVALID_PREFIX_LENGTH;
+ iproute_key->dst_addr.s_addr = INVALID_DST_IP_ADDR;
+ iproute_key->next_hop_addr.s_addr = INVALID_NEXT_HOP_ADDR;
+ return UPLL_RC_SUCCESS;
+ }
+
+ if (strlen(reinterpret_cast<char*>(iproute_key->nwm_name)) != 0) {
+ UPLL_LOG_DEBUG("Currently nwm name is not supported for this KT");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ /*
+ ret_val = ValidateKey(reinterpret_cast<char *>(iproute_key->nwm_name),
+ kMinLenNwmName,
+ kMaxLenNwmName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("syntax check failed. nwm name - %s", iproute_key->nwm_name);
return UPLL_RC_ERR_CFG_SYNTAX;
}
- } else {
- UPLL_LOG_TRACE("Operation is %d", operation);
- StringReset(iproute_key->nwm_name);
- iproute_key->dst_addr_prefixlen = 0;
- iproute_key->dst_addr.s_addr = 0x00000000;
- iproute_key->next_hop_addr.s_addr = 0x00000000;
+ */
+ }
+
+ // TODO(s): Need to validate if inputs are given
+ if (!ValidateNumericRange(iproute_key->dst_addr_prefixlen,
+ (uint8_t) kMinIpRoutePrefix,
+ (uint8_t) kMaxIpRoutePrefix,
+ true, true)) {
+ UPLL_LOG_DEBUG("Numeric range check failed. dst_addr_prefixlen - %d",
+ iproute_key->dst_addr_prefixlen);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ if (iproute_key->dst_addr.s_addr == 0xffffffff) {
+ UPLL_LOG_DEBUG("Bad destination address. addr:0x%08x",
+ iproute_key->dst_addr.s_addr);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ if (iproute_key->next_hop_addr.s_addr == 0x00000000 ||
+ iproute_key->next_hop_addr.s_addr == 0xffffffff) {
+ UPLL_LOG_DEBUG("Bad next hop address. addr:0x%08x",
+ iproute_key->next_hop_addr.s_addr);
+ return UPLL_RC_ERR_CFG_SYNTAX;
}
return UPLL_RC_SUCCESS;
}
uint32_t op) {
UPLL_FUNC_TRACE;
+ if (iproute_val->group_metric != 0 ||
+ iproute_val->valid[UPLL_IDX_GROUP_METRIC_SIR] == UNC_VF_VALID ||
+ iproute_val->valid[UPLL_IDX_GROUP_METRIC_SIR] == UNC_VF_VALID_NO_VALUE) {
+ iproute_val->valid[UPLL_IDX_GROUP_METRIC_SIR] = UNC_VF_NOT_SUPPORTED;
+ UPLL_LOG_DEBUG("Currently metric is not supported for this KT");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ /*
if (iproute_val->valid[UPLL_IDX_GROUP_METRIC_SIR] == UNC_VF_VALID) {
if (!ValidateNumericRange(iproute_val->group_metric,
(uint16_t) kMinLenGroupMetric,
&& (op == UNC_OP_CREATE || op == UNC_OP_UPDATE)) {
iproute_val->group_metric = 0;
}
+ */
return UPLL_RC_SUCCESS;
}
ConfigKeyVal *ikey,
const char *ctrlr_name) {
UPLL_FUNC_TRACE;
- upll_rc_t ret_val = UPLL_RC_SUCCESS;
- /** read datatype, operation, options from IpcReqRespHeader */
+ upll_rc_t ret_val = UPLL_RC_ERR_GENERIC;
if (!req || !ikey) {
UPLL_LOG_DEBUG("IpcReqRespHeader / ConfigKeyVal is NULL");
return UPLL_RC_ERR_GENERIC;
}
- if (!ctrlr_name) ctrlr_name = reinterpret_cast<char *>(ikey->get_user_data());
-
- uint32_t dt_type = req->datatype;
- uint32_t op = req->operation;
- uint32_t opt1 = req->option1;
- uint32_t opt2 = req->option2;
-
- if (op == UNC_OP_CREATE) { // C, I
- if (dt_type == UPLL_DT_CANDIDATE || dt_type == UPLL_DT_IMPORT) {
- ret_val = ValIpRouteAttributeSupportCheck(ctrlr_name, ikey, op);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(
- "IP_ROUTE struct Capa check failure for create operation");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Invalid data type");
+ if (!ctrlr_name) {
+ ctrlr_name = reinterpret_cast<char*>((reinterpret_cast<key_user_data_t *>
+ (ikey->get_user_data()))->ctrlr_id);
+ if (!ctrlr_name || !strlen(ctrlr_name)) {
+ UPLL_LOG_DEBUG("Controller Name is NULL");
return UPLL_RC_ERR_GENERIC;
}
- } else if (op == UNC_OP_UPDATE) { // C
- if (dt_type == UPLL_DT_CANDIDATE) {
- ret_val = ValIpRouteAttributeSupportCheck(ctrlr_name, ikey, op);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("In IP_ROUTE Capa check failure for Update operation");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Unsupported data type - (%d)", dt_type);
- return UPLL_RC_ERR_GENERIC;
- }
- } else if (op == UNC_OP_READ || op == UNC_OP_READ_SIBLING
- || op == UNC_OP_READ_SIBLING_BEGIN || op == UNC_OP_READ_SIBLING_COUNT) {
- if (dt_type == UPLL_DT_CANDIDATE || dt_type == UPLL_DT_RUNNING
- || dt_type == UPLL_DT_STARTUP || dt_type == UPLL_DT_STATE) {
- if (opt1 != UNC_OPT1_NORMAL) {
- UPLL_LOG_DEBUG("Error option1 is not NORMAL");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- if (opt2 != UNC_OPT2_NONE) {
- UPLL_LOG_DEBUG("option2 is not NONE");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- if (NULL == ikey->get_cfg_val()) {
- UPLL_LOG_DEBUG("ConfigVal struct is empty");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- if (ikey->get_cfg_val()->get_val() == NULL) {
- UPLL_LOG_DEBUG("val_static_ip_route struct is an optional");
- return UPLL_RC_SUCCESS;
- }
- ret_val = ValIpRouteAttributeSupportCheck(ctrlr_name, ikey, op);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("IP_ROUTE struct capa check failure for read operation");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Unsupported data type - (%d)", dt_type);
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
- }
}
- UPLL_LOG_DEBUG("Unsupported operation - (%d)", op);
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
-}
-upll_rc_t IpRouteMoMgr::ValIpRouteAttributeSupportCheck(const char *ctrlr_name,
- ConfigKeyVal *ikey,
- uint32_t operation) {
- UPLL_FUNC_TRACE;
bool result_code = false;
uint32_t max_attrs = 0;
uint32_t max_instance_count = 0;
const uint8_t *attrs;
- switch (operation) {
+ switch (req->operation) {
case UNC_OP_CREATE:
result_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
&max_instance_count, &max_attrs,
&attrs);
- if (result_code && cur_instance_count >= max_instance_count) {
+ if (result_code && (max_instance_count != 0) &&
+ (cur_instance_count >= max_instance_count)) {
UPLL_LOG_DEBUG("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
__LINE__, __FUNCTION__, cur_instance_count,
max_instance_count);
&max_attrs, &attrs);
break;
default:
- UPLL_LOG_DEBUG("INVALID OPERATION CODE - (%d)", operation);
+ UPLL_LOG_DEBUG("INVALID OPERATION CODE - (%d)", req->operation);
return UPLL_RC_ERR_GENERIC;
}
if (!result_code) {
UPLL_LOG_DEBUG("key_type - %d is not supported by controller - %s",
ikey->get_key_type(), ctrlr_name);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
- if (NULL == ikey->get_cfg_val()) {
- UPLL_LOG_DEBUG("ConfigVal struct is empty");
- return UPLL_RC_ERR_CFG_SYNTAX;
+ val_static_ip_route *iproute_val = NULL;
+ if ((ikey->get_cfg_val()) && (ikey->get_cfg_val()->get_st_num() ==
+ IpctSt::kIpcStValStaticIpRoute)) {
+ iproute_val =
+ reinterpret_cast<val_static_ip_route*>(ikey->get_cfg_val()->get_val());
}
- if (ikey->get_cfg_val()->get_st_num() != IpctSt::kIpcStValStaticIpRoute) {
- UPLL_LOG_DEBUG(
- "value structure matching is invalid. st.num - %d",
- ikey->get_cfg_val()->get_st_num());
- return UPLL_RC_ERR_BAD_REQUEST;
+ if (iproute_val) {
+ if (max_attrs > 0) {
+ ret_val = ValIpRouteAttributeSupportCheck(iproute_val, attrs,
+ req->operation);
+ return ret_val;
+ } else {
+ UPLL_LOG_DEBUG("Error- Mandatory value struct is NULL for READ");
+ return UPLL_RC_ERR_GENERIC;
+ }
}
- val_static_ip_route *iproute_val =
- reinterpret_cast<val_static_ip_route *>(ikey->get_cfg_val()->get_val());
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t IpRouteMoMgr::ValIpRouteAttributeSupportCheck(
+ val_static_ip_route *iproute_val,
+ const uint8_t *attrs,
+ unc_keytype_operation_t operation) {
+ UPLL_FUNC_TRACE;
if (iproute_val != NULL) {
if ((iproute_val->valid[UPLL_IDX_GROUP_METRIC_SIR] == UNC_VF_VALID)
|| (iproute_val->valid[UPLL_IDX_GROUP_METRIC_SIR]
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::static_ip_route::kCapGroupMetric] == 0) {
- iproute_val->valid[UPLL_IDX_GROUP_METRIC_SIR] = UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_DEBUG("Vrt_if structure attr is not supported by ctrlr ");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ iproute_val->valid[UPLL_IDX_GROUP_METRIC_SIR] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("Metric attr is not supported by ctrlr ");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
}
}
- return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_DEBUG("Error val_static_ip_route struct is NULL");
+ return UPLL_RC_ERR_GENERIC;
}
- UPLL_LOG_DEBUG("Error val_static_ip_route struct is NULL");
- return UPLL_RC_ERR_GENERIC;
+ return UPLL_RC_SUCCESS;
}
upll_rc_t IpRouteMoMgr::CopyToConfigKey(ConfigKeyVal *&okey,
key_rename_vnode_info *key_rename =
reinterpret_cast<key_rename_vnode_info *>(ikey->get_key());
key_static_ip_route * key_route =
- reinterpret_cast<key_static_ip_route *>(malloc(
+ reinterpret_cast<key_static_ip_route *>(ConfigKeyVal::Malloc(
sizeof(key_static_ip_route)));
- if (!key_route)
- return UPLL_RC_ERR_GENERIC;
- memset(key_route , 0, sizeof(key_static_ip_route));
+ key_route->dst_addr_prefixlen = INVALID_PREFIX_LENGTH;
+ key_route->dst_addr.s_addr = INVALID_DST_IP_ADDR;
+ key_route->next_hop_addr.s_addr = INVALID_NEXT_HOP_ADDR;
if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vtn_name))) {
free(key_route);
return UPLL_RC_ERR_GENERIC;
}
uuu::upll_strncpy(key_route->vrt_key.vrouter_name,
key_rename->old_unc_vnode_name, (kMaxLenVnodeName + 1));
+ } else {
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_unc_vnode_name))) {
+ FREE_IF_NOT_NULL(key_route);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(key_route->vrt_key.vrouter_name,
+ key_rename->new_unc_vnode_name, (kMaxLenVnodeName+1));
}
+
+
okey = new ConfigKeyVal(UNC_KT_VRT_IPROUTE, IpctSt::kIpcStKeyStaticIpRoute,
key_route, NULL);
if (!okey) {
return false;
}
-bool IpRouteMoMgr::CompareValidValue(void *&val1, void *val2, bool audit) {
+bool IpRouteMoMgr::CompareValidValue(void *&val1, void *val2,
+ bool copy_to_running) {
UPLL_FUNC_TRACE;
bool invalid_attr = true;
val_static_ip_route_t *val_iprte1 =
for (unsigned int loop = 0;
loop < sizeof(val_iprte1->valid) / sizeof(uint8_t); ++loop) {
if (UNC_VF_INVALID == val_iprte1->valid[loop]
- && UNC_VF_VALID == val_iprte2->valid[loop])
+ && UNC_VF_VALID == val_iprte2->valid[loop])
val_iprte1->valid[loop] = UNC_VF_VALID_NO_VALUE;
}
if (UNC_VF_VALID == val_iprte1->valid[UPLL_IDX_GROUP_METRIC_SIR]
&& UNC_VF_VALID == val_iprte2->valid[UPLL_IDX_GROUP_METRIC_SIR]) {
if (val_iprte1->group_metric == val_iprte2->group_metric)
- val_iprte1->valid[UPLL_IDX_GROUP_METRIC_SIR] = UNC_VF_INVALID;
+ val_iprte1->valid[UPLL_IDX_GROUP_METRIC_SIR] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
for (unsigned int loop = 0;
loop < (sizeof(val_iprte1->valid) / sizeof(val_iprte1->valid[0]));
++loop) {
if ((UNC_VF_VALID == (uint8_t) val_iprte1->valid[loop]) ||
- (UNC_VF_VALID_NO_VALUE == (uint8_t) val_iprte1->valid[loop]))
- invalid_attr = false;
+ (UNC_VF_VALID_NO_VALUE == (uint8_t) val_iprte1->valid[loop])) {
+ invalid_attr = false;
+ break;
+ }
}
return invalid_attr;
}
+
upll_rc_t IpRouteMoMgr::IsReferenced(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi) {
return UPLL_RC_SUCCESS;
}
+
+
upll_rc_t IpRouteMoMgr::MergeValidate(unc_key_type_t keytype,
- const char *ctrlr_id, ConfigKeyVal *ikey,
+ const char *ctrlr_id,
+ ConfigKeyVal *ikey,
DalDmlIntf *dmi) {
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ /* NEC changed the design so the below code is not required
+ */
+ #if 0
upll_rc_t result_code = UPLL_RC_SUCCESS;
DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
ConfigKeyVal *tkey = NULL;
+ ConfigKeyVal * travel_key = NULL;
if (!ikey || !(ikey->get_key())) {
UPLL_LOG_DEBUG(" Input is NULL");
return UPLL_RC_ERR_GENERIC;
- }
+ }
/*
* Here getting FULL Key (VTN & IPROUTE Name )
*/
result_code = ReadConfigDB(ikey, UPLL_DT_IMPORT, UNC_OP_READ, dbop, dmi,
MAINTBL);
if (UPLL_RC_SUCCESS != result_code) return result_code;
- while (ikey) {
- tkey = ikey;
+ travel_key = ikey;
+ while (travel_key) {
+ result_code = GetChildConfigKey(tkey, travel_key);
+ if (UPLL_RC_SUCCESS != result_code){
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed");
+ DELETE_IF_NOT_NULL(tkey);
+ return result_code;
+ }
/*Check the network host name should not be present same vtn */
memset(reinterpret_cast<key_static_ip_route_t*>
(tkey->get_key())->vrt_key.vrouter_name, 0, (kMaxLenVnodeName+1));
(tkey->get_key())->dst_addr_prefixlen = 0;
reinterpret_cast<key_static_ip_route_t*>
(tkey->get_key())->next_hop_addr.s_addr = 0;
- result_code = ReadConfigDB(tkey, UPLL_DT_RUNNING, UNC_OP_READ, dbop, dmi,
+ result_code = ReadConfigDB(tkey, UPLL_DT_CANDIDATE, UNC_OP_READ, dbop, dmi,
MAINTBL);
if (UPLL_RC_SUCCESS == result_code) {
UPLL_LOG_DEBUG("Conflict in IpRoute %d", result_code);
+ delete ikey;
+ ikey = NULL;
+ ikey->ResetWith(tkey);
+ delete tkey;
return UPLL_RC_ERR_MERGE_CONFLICT;
}
/* Any other DB error */
if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
UPLL_LOG_DEBUG(" ReadConfigDB Failed %d", result_code);
- return result_code;
- }
- ikey = ikey->get_next_cfg_key_val();
- if (tkey) {
- free(tkey->get_key());
delete tkey;
- tkey = NULL;
+ return result_code;
}
+ travel_key = travel_key->get_next_cfg_key_val();
}
+ /* ikey is deleting in the vtn file. If memory leak tool
+ * shows any error don't fix it.
+ */
return result_code;
+ #endif
}
+// Overridden Read Sibling from momgr_impl.
+// This keytype contains 4 child keys and needs special handling.
+upll_rc_t IpRouteMoMgr::ReadSiblingMo(IpcReqRespHeader *header,
+ ConfigKeyVal *ikey,
+ bool begin,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+ uint32_t result_count = 0;
+
+ if (begin == true) {
+ return (MoMgrImpl::ReadSiblingMo(header, ikey, begin, dmi));
+ }
+ if ((header->operation != UNC_OP_READ_SIBLING_BEGIN) &&
+ (header->operation != UNC_OP_READ_SIBLING)) {
+ UPLL_LOG_DEBUG("Operation type is not Sibling begin/Sibling");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (ikey == NULL || dmi == NULL) {
+ UPLL_LOG_DEBUG("Null Param ikey/dmi");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = ValidateMessage(header, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ValidateMessage failed result_code %d",
+ result_code);
+ return result_code;
+ }
+
+ MoMgrTables tbl = MAINTBL;
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone,
+ kOpInOutCtrlr | kOpInOutDomain | kOpInOutFlag};
+
+ if (UPLL_DT_RUNNING == header->datatype) {
+ UPLL_LOG_TRACE("Status Flag enabled");
+ dbop.inoutop |= kOpInOutCs;
+ }
+ switch (header->datatype) {
+ case UPLL_DT_IMPORT:
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ case UPLL_DT_CANDIDATE:
+ case UPLL_DT_RUNNING:
+ case UPLL_DT_STARTUP:
+ case UPLL_DT_STATE:
+ {
+ // To read the record(s) from DB
+ upll_keytype_datatype_t dt_type = (header->datatype == UPLL_DT_STATE) ?
+ UPLL_DT_RUNNING : header->datatype;
+ ConfigVal *cval = ikey->get_cfg_val();
+ ConfigVal *new_cval = NULL;
+ AllocVal(new_cval, dt_type, MAINTBL);
+ if (new_cval == NULL) {
+ UPLL_LOG_DEBUG("Null new_cval after AllocVal");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ if (cval != NULL && cval->get_val() != NULL) {
+ memcpy(new_cval->get_val(), cval->get_val(),
+ sizeof(val_static_ip_route));
+ }
+ ikey->SetCfgVal(new_cval);
+
+ // Used in ReadConfigDB in each Iteration
+ ConfigKeyVal *queryckval = NULL;
+ result_code = DupConfigKeyVal(queryckval, ikey, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS || queryckval == NULL) {
+ UPLL_LOG_DEBUG("Error while DupConfigKeyVal");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ // uint16_t kIpRouteNumChildKey = 4;
+ bool fetched_from_query = false;
+ for (uint16_t childKeyIndex = uuds::TableNumPkCols(
+ uudst::kDbiStaticIpRouteTbl) - 1;
+ childKeyIndex >= uuds::TableNumPkCols(
+ uudst::kDbiStaticIpRouteTbl) - kIpRouteNumChildKey;
+ childKeyIndex--) {
+ if (IsValidKey(queryckval->get_key(), childKeyIndex) == false)
+ continue;
+ uint32_t tmp_count = header->rep_count;
+ result_code = ReadConfigDB(queryckval, dt_type, header->operation,
+ dbop, tmp_count, dmi, tbl);
+
+ if (result_code == UPLL_RC_SUCCESS) {
+ ConfigKeyVal *qtmpckval = queryckval;
+ ConfigKeyVal *tmpckval = NULL;
+ ConfigKeyVal *appendckval = NULL;
+ // Iterating through all ConfigKeyVal from the result set
+ // and storing the result set in ikey
+ while (qtmpckval != NULL) {
+ if (result_count == header->rep_count) {
+ UPLL_LOG_TRACE("Fetched (%d) records", result_count);
+ delete queryckval;
+ return UPLL_RC_SUCCESS;
+ }
+ result_code = DupConfigKeyVal(tmpckval, qtmpckval, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error while DupConfigKeyVal");
+ if (queryckval)
+ delete queryckval;
+ if (tmpckval)
+ delete tmpckval;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_TRACE("Appending ConfigKeyVal");
+ appendckval = tmpckval;
+ if (fetched_from_query == false) {
+ ikey->ResetWith(appendckval);
+ DELETE_IF_NOT_NULL(appendckval);
+ result_count++;
+ fetched_from_query = true;
+ } else {
+ ikey->AppendCfgKeyVal(appendckval);
+ result_count++;
+ }
+ tmpckval = NULL;
+ qtmpckval = qtmpckval->get_next_cfg_key_val();
+ } // while (qtmpckval != NULL)
+#if 0
+ // Copying the last available key structure for next iteration
+ if (appendckval != NULL && appendckval->get_key() != NULL) {
+ memcpy(queryckval->get_key(), appendckval->get_key(),
+ sizeof(key_static_ip_route));
+ } else {
+ memcpy(queryckval->get_key(), ikey->get_key(),
+ sizeof(key_static_ip_route));
+ }
+#endif
+ } else if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Error while ReadConfigDB");
+ delete queryckval;
+ return result_code;
+ }
+
+ // Preparing Child Key data for next Sibling Iteration
+ key_static_ip_route *key_ipr =
+ reinterpret_cast<key_static_ip_route *>(queryckval->get_key());
+ if (ResetDataForSibling(key_ipr,
+ (uudst::static_ip_route::kStaticIpRouteIndex)childKeyIndex)
+ == false) {
+ UPLL_LOG_DEBUG("Data Not Reset for the index(%d)", childKeyIndex);
+ delete queryckval;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (GetVal(ikey)) {
+ memcpy(queryckval->get_cfg_val()->get_val(),
+ ikey->get_cfg_val()->get_val(),
+ sizeof(val_static_ip_route));
+ } else {
+ queryckval->SetCfgVal(NULL);
+ }
+ UPLL_LOG_TRACE("Next Query After Reset: %s",
+ (queryckval->ToStrAll()).c_str());
+ } // for
+ header->rep_count = result_count;
+ delete queryckval;
+ break;
+ } // case
+ default:
+ break;
+ }
+
+ if (header->rep_count > 0) {
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)
+ ? UPLL_RC_SUCCESS : result_code;
+ if (result_code == UPLL_RC_SUCCESS) {
+ result_code = AdaptValToVtnService(ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("AdaptValToVtnService failed result_code %d",
+ result_code);
+ return result_code;
+ }
+ }
+ } else {
+ return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ }
+ return result_code;
+} // IpRouteMoMgr::ReadSiblingMo
+
+// To reset the data available in index to empty
+// Currently implemented only for child index
+bool IpRouteMoMgr::ResetDataForSibling(key_static_ip_route *key_ipr,
+ uudst::static_ip_route::kStaticIpRouteIndex index) {
+ switch (index) {
+ case uudst::static_ip_route::kDbiDstIpAddr:
+ key_ipr->dst_addr.s_addr = INVALID_DST_IP_ADDR;
+ case uudst::static_ip_route::kDbiMask:
+ key_ipr->dst_addr_prefixlen = INVALID_PREFIX_LENGTH;
+ case uudst::static_ip_route::kDbiNextHopAddr:
+ key_ipr->next_hop_addr.s_addr = INVALID_NEXT_HOP_ADDR;
+ case uudst::static_ip_route::kDbiNwmName:
+ memset(key_ipr->nwm_name, 0, sizeof(key_ipr->nwm_name));
+ break;
+ default:
+ UPLL_LOG_DEBUG("Not a child key index");
+ return false;
+ }
+ UPLL_LOG_TRACE("Resetting Data for index(%d)", index);
+ return true;
+}
} // namespace kt_momgr
} // namespace upll
} // namespace unc
#ifndef UNC_UPLL_IPROUTE_MOMGR_H
#define UNC_UPLL_IPROUTE_MOMGR_H
-
#include <string>
#include "momgr_impl.hh"
#include "vnode_child_momgr.hh"
namespace upll {
namespace kt_momgr {
+#define INVALID_PREFIX_LENGTH 33
+#define INVALID_DST_IP_ADDR 0xffffffff
+#define INVALID_NEXT_HOP_ADDR 0xffffffff
+
+namespace uuds = unc::upll::dal::schema;
+namespace uudst = unc::upll::dal::schema::table;
class IpRouteMoMgr : public VnodeChildMoMgr {
private:
static BindInfo ip_route_bind_info[];
static BindInfo key_ip_route_maintbl_update_bind_info[];
/**
- * @brief Gets the valid array position of the variable in the value
- * structure from the table in the specified configuration
+ * @brief Gets the valid array position of the variable in the value
+ * structure from the table in the specified configuration
*
- * @param[in] val pointer to the value structure
+ * @param[in] val pointer to the value structure
* @param[in] indx database index for the variable
- * @param[out] valid position of the variable in the valid array -
+ * @param[out] valid position of the variable in the valid array -
* NULL if valid does not exist.
* @param[in] dt_type specifies the configuration
- * @param[in] tbl specifies the table containing the given value
+ * @param[in] tbl specifies the table containing the given value
*
**/
upll_rc_t GetValid(void *val, uint64_t indx, uint8_t *&valid,
/**
* @brief Compares the valid value between two database records.
* if both the values are same, update the valid flag for corresponding
- * attribute as invalid in the first record.
+ * attribute as invalid in the first record.
*
* @param[in/out] val1 first record value instance.
* @param[in] val2 second record value instance.
* associated attributes are supported on the given controller,
* based on the valid flag.
*
- * @param[in] crtlr_name Controller name.
- * @param[in] ikey Corresponding key and value structure.
+ * @param[in] iproute_val KT_VRT_IPROUTE value structure.
+ * @param[in] attrs Pointer to controller attribute.
* @param[in] operation Operation name.
*
* @retval UPLL_RC_SUCCESS validation succeeded.
* @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
* @retval UPLL_RC_ERR_GENERIC Generic failure.
*/
- upll_rc_t ValIpRouteAttributeSupportCheck(const char *ctrlr_name,
- ConfigKeyVal *ikey,
- uint32_t operation);
+ upll_rc_t ValIpRouteAttributeSupportCheck(
+ val_static_ip_route *iproute_val,
+ const uint8_t *attrs,
+ unc_keytype_operation_t operation);
- upll_rc_t ValidateAttribute(ConfigKeyVal *kval,
+ upll_rc_t ValidateAttribute(ConfigKeyVal *kval,
DalDmlIntf *dmi,
IpcReqRespHeader *req = NULL);
/**
- * @brief Duplicates the input configkeyval including the key and val.
+ * @brief Duplicates the input configkeyval including the key and val.
* based on the tbl specified.
*
* @param[in] okey Output Configkeyval - allocated within the function
upll_rc_t DupConfigKeyVal(ConfigKeyVal *&okey, ConfigKeyVal *&req,
MoMgrTables tbl = MAINTBL);
/**
- * @brief Allocates for the specified val in the given configuration in the * specified table.
+ * @brief Allocates for the specified val in the given configuration in the * specified table.
*
- * @param[in] ck_val Reference pointer to configval structure allocated. * @param[in] dt_type specifies the configuration candidate/running/state
- * @param[in] tbl specifies if the corresponding table is the main
+ * @param[in] ck_val Reference pointer to configval structure allocated. * @param[in] dt_type specifies the configuration candidate/running/state
+ * @param[in] tbl specifies if the corresponding table is the main
* table / controller table or rename table.
*
* @retval UPLL_RC_SUCCESS Successfull completion.
/**
* @brief Method to get a configkeyval of a specified keytype from an input configkeyval
*
- * @param[in/out] okey pointer to output ConfigKeyVal
+ * @param[in/out] okey pointer to output ConfigKeyVal
* @param[in] parent_key pointer to the configkeyval from which the output configkey val is initialized.
*
* @retval UPLL_RC_SUCCESS Successfull completion.
*/
upll_rc_t GetChildConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *parent_key);
/**
- * @brief Allocates for the specified val in the given configuration in the * specified table.
+ * @brief Allocates for the specified val in the given configuration in the * specified table.
*
- * @param[in] ck_val Reference pointer to configval structure allocated. * @param[in] dt_type specifies the configuration candidate/running/state
- * @param[in] tbl specifies if the corresponding table is the main
+ * @param[in] ck_val Reference pointer to configval structure allocated. * @param[in] dt_type specifies the configuration candidate/running/state
+ * @param[in] tbl specifies if the corresponding table is the main
* table / controller table or rename table.
*
* @retval UPLL_RC_SUCCESS Successfull completion.
upll_rc_t MergeValidate(unc_key_type_t keytype, const char *ctrlr_id,
ConfigKeyVal *ikey, DalDmlIntf *dmi);
+ bool ResetDataForSibling(key_static_ip_route *key_ipr,
+ uudst::static_ip_route::kStaticIpRouteIndex index);
+
+ static uint16_t kIpRouteNumChildKey;
+
public:
IpRouteMoMgr();
virtual ~IpRouteMoMgr() {
* @retval false input key is invalid.
**/
bool IsValidKey(void *tkey, uint64_t index);
+
+ /* @brief READ_SIBLING_BEGIN: Gets the first MO from the sibling group
+ * under the parent
+ * specified in the key from the specified UNC database
+ * READ_SIBLING: Gets the next MO from the sibling group
+ * under the parent
+ * specified in the key from the specified UNC database
+ *
+ * @param[in] req Pointer to IpcResResHeader
+ * @param[in/out] key Pointer to the ConfigKeyVal Structure
+ * @param[in] begin boolean variable to decide the sibling operation
+ * @param[in] dal Pointer to the DalDmlIntf(DB Interface)
+ *
+ * @retval UPLL_RC_SUCCESS Completed successfully.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ * @retval UPLL_RC_ERR_RESOURCE_DISCONNECTED Resource disconnected.
+ * @retval UPLL_RC_ERR_DB_ACCESS DB Read/Write error.
+ * @retval UPLL_RC_ERR_NO_SUCH_INSTANCE Given key does not exist
+ *
+ * @Note: Overridden from base class MoMgrImpl
+ **/
+ virtual upll_rc_t ReadSiblingMo(IpcReqRespHeader *req,
+ ConfigKeyVal *key,
+ bool begin,
+ DalDmlIntf *dal);
};
} // namespace kt_momgr
* distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "key_tree.hh"
}
const KeyTreeNode *KeyTree::GetNode(unc_key_type_t key_type) const {
- std::map<unc_key_type_t,KeyTreeNode *>::const_iterator it =
+ std::map<unc_key_type_t, KeyTreeNode *>::const_iterator it =
all_kt_map_.find(key_type);
if (it != all_kt_map_.end())
return it->second;
for (std::list<KeyTreeNode*>::iterator it = children.begin();
it != children.end(); ++it) {
- UPLL_LOG_VERBOSE("child in iterator: %d\n", (*it)->key_type);
+ UPLL_LOG_VERBOSE("child in iterator: %d", (*it)->key_type);
if ((*it)->key_type == node->key_type) {
if (++it != children.end()) {
- UPLL_LOG_VERBOSE("found sibling: %d\n", (*it)->key_type);
+ UPLL_LOG_VERBOSE("found sibling: %d", (*it)->key_type);
return (*it);
} else {
break;
} // namespace keytree
} // namespace upll
} // namespace unc
-
#include <iomanip>
#include <sstream>
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "kt_util.hh"
namespace unc {
// UNC_KT_VBRIF_FLOWFILTER_ENTRY
tmpl = new KtMsgTemplate();
tmpl->kt_cfg_msg.push_back(IpctSt::kIpcStKeyVbrIfFlowfilterEntry);
- tmpl->kt_cfg_msg.push_back(IpctSt::kIpcStValFlowfilterEntry);
+ tmpl->kt_cfg_msg.push_back(IpctSt::kIpcStPfcdrvValFlowfilterEntry);
// can't do; TC does not support
// tmpl->kt_cfg_msg.push_back(IpctSt::kIpcStPfcdrvValVbrifVextif);
kt_msg_templates_[UNC_KT_FLOWLIST_ENTRY] = tmpl;
// UNC_KT_DHCPRELAY_SERVER
tmpl = new KtMsgTemplate();
tmpl->kt_cfg_msg.push_back(IpctSt::kIpcStKeyDhcpRelayServer);
- tmpl->kt_cfg_msg.push_back(IpctSt::kIpcStValDhcpRelayServer);
+ // NO - VAL
+ // tmpl->kt_cfg_msg.push_back(IpctSt::kIpcStValDhcpRelayServer);
kt_msg_templates_[UNC_KT_DHCPRELAY_SERVER] = tmpl;
// UNC_KT_DHCPRELAY_IF
tmpl = new KtMsgTemplate();
tmpl->kt_cfg_msg.push_back(IpctSt::kIpcStKeyDhcpRelayIf);
- tmpl->kt_cfg_msg.push_back(IpctSt::kIpcStValDhcpRelayIf);
+ // NO - VAL
+ // tmpl->kt_cfg_msg.push_back(IpctSt::kIpcStValDhcpRelayIf);
kt_msg_templates_[UNC_KT_DHCPRELAY_IF] = tmpl;
// UNC_KT_VRT_IF
tmpl = new KtMsgTemplate();
// UNC_KT_VRTIF_FLOWFILTER
tmpl = new KtMsgTemplate();
tmpl->kt_cfg_msg.push_back(IpctSt::kIpcStKeyVrtIfFlowfilter);
- // NO-VAL
+ tmpl->kt_cfg_msg.push_back(IpctSt::kIpcStPfcdrvValVbrifVextif);
kt_msg_templates_[UNC_KT_VRTIF_FLOWFILTER] = tmpl;
// UNC_KT_VRTIF_FLOWFILTER_ENTRY
tmpl = new KtMsgTemplate();
tmpl->kt_cfg_msg.push_back(IpctSt::kIpcStKeyVrtIfFlowfilterEntry);
- tmpl->kt_cfg_msg.push_back(IpctSt::kIpcStValFlowfilterEntry);
+ tmpl->kt_cfg_msg.push_back(IpctSt::kIpcStPfcdrvValFlowfilterEntry);
kt_msg_templates_[UNC_KT_VRTIF_FLOWFILTER_ENTRY] = tmpl;
// UNC_KT_VUNKNOWN
tmpl = new KtMsgTemplate();
<< Ipv6AddrToStr(*reinterpret_cast<struct in6_addr*>(data));
return ss.str();
case IpctSt::kIpcStString:
- ss << " -->string " << *(reinterpret_cast<char**>(data));
+ ss << " -->string " << (reinterpret_cast<char*>(data));
return ss.str();
case IpctSt::kIpcStBinary:
/*
return IpcStructToStr(*reinterpret_cast<val_boundary_st*>(data));
case IpctSt::kIpcStValPathFaultAlarm:
return IpcStructToStr(*reinterpret_cast<val_path_fault_alarm*>(data));
+ // Overlay Driver structures
+ case IpctSt::kIpcStVnpdrvValVtunnel:
+ return IpcStructToStr(*reinterpret_cast<vnpdrv_val_vtunnel*>(data));
+ case IpctSt::kIpcStVnpdrvValVtunnelIf:
+ return IpcStructToStr(*reinterpret_cast<vnpdrv_val_vtunnel_if*>(data));
}
return ss.str();
}
}
std::string KtUtil::Ipv6AddrToStr(struct in6_addr address) {
+ socklen_t ipv6_len = INET6_ADDRSTRLEN;
char str_addr[INET6_ADDRSTRLEN];
- if (NULL == inet_ntop(AF_INET6, &address, str_addr, INET6_ADDRSTRLEN)) {
+ if (NULL == inet_ntop(AF_INET6, &address, str_addr, ipv6_len)) {
+ UPLL_LOG_TRACE(" Invalid IPV6 Address");
return " Invalid IPV6 Address..!!! ";
}
return str_addr;
case UNC_VF_VALID_NO_VALUE:
ss << "N";
break;
- case UNC_VF_NOT_SOPPORTED:
+ case UNC_VF_NOT_SUPPORTED:
ss << "X";
break;
+ case UNC_VF_VALUE_NOT_MODIFIED:
+ ss << "M";
+ break;
default:
ss << "!" << chr2int(validarray[i]) << "!:";
break;
case UNC_CS_APPLIED:
ss << "A";
break;
- case UNC_CS_PARTAILLY_APPLIED:
+ case UNC_CS_PARTIALLY_APPLIED:
ss << "P";
break;
case UNC_CS_NOT_APPLIED:
// ss << " -->vtn_key "<< endl;
ss << IpcStructToStr(data.vtn_key);
ss << " -->controller_name " << data.controller_name << endl;
+ ss << " -->domain_name " << data.domain_id << endl;
return ss.str();
}
ss << " -->cs_attr " << CS_ARRAY_TO_STR(val_vtep_if.cs_attr);
ss << " -->description " << val_vtep_if.description << endl;
ss << " -->admin_status " << chr2int(val_vtep_if.admin_status) << endl;
+ ss << IpcStructToStr(val_vtep_if.portmap);
return ss.str();
}
ss << " -->cs_attr " << CS_ARRAY_TO_STR(val_vtunnel_if.cs_attr);
ss << " -->description " << val_vtunnel_if.description << endl;
ss << " -->admin_status " << chr2int(val_vtunnel_if.admin_status) << endl;
+ ss << IpcStructToStr(val_vtunnel_if.portmap);
return ss.str();
}
ss << " -->cs_attr " << CS_ARRAY_TO_STR(val_vunknown.cs_attr);
ss << " -->description " << val_vunknown.description << endl;
ss << " -->type " << chr2int(val_vunknown.type) << endl;
+ ss << " -->domain_id " << val_vunknown.domain_id << endl;
return ss.str();
}
ss << " -->dst_ip_prefixlen " << chr2int(data.dst_ip_prefixlen) << endl;
ss << " -->src_ip " << Ipv4AddrToStr(data.src_ip) << endl;
ss << " -->src_ip_prefixlen " << chr2int(data.src_ip_prefixlen) << endl;
- ss << " -->vlan_priority " << data.vlan_priority << endl;
+ ss << " -->vlan_priority " << chr2int(data.vlan_priority) << endl;
ss << " -->dst_ipv6 " << Ipv6AddrToStr(data.dst_ipv6) << endl;
ss << " -->dst_ipv6_prefixlen " << chr2int(data.dst_ipv6_prefixlen) << endl;
ss << " -->src_ipv6 " << Ipv6AddrToStr(data.src_ipv6) << endl;
// ss << " -->vtn_key " << endl;
ss << IpcStructToStr(data.vtn_key);
ss << " -->controller_name " << data.controller_name << endl;
+ ss << " -->domain_name " << data.domain_id << endl;
return ss.str();
}
ss << " -->policer_id " << data.policer_id << endl;
ss << " -->switch_id " << data.switch_id << endl;
ss << " -->status " << chr2int(data.status) << endl;
+ ss << " -->vBridge_name " << data.vbr_name << endl;
ss << " -->if_name " << data.if_name << endl;
ss << " -->port_name " << data.port_name << endl;
ss << " -->vlanid " << data.vlanid << endl;
ss << IpcStructToStr(key_vtn_policingmap_controller.vtn_key);
ss << " -->controller_name "
<< key_vtn_policingmap_controller.controller_name << endl;
+ ss << " -->domain_name "
+ << key_vtn_policingmap_controller.domain_id << endl;
return ss.str();
}
return ss.str();
}
+// VNP-DRV
+std::string KtUtil::IpcStructToStr(const vnpdrv_val_vtunnel& data) {
+ std::stringstream ss;
+ ss << " ----- vnpdrv_val_vtunnel ----- " << endl;
+ ss << " -->valid " << VALID_ARRAY_TO_STR(data.valid);
+ ss << " -->label " << data.label << endl;
+ return ss.str();
+}
+
+std::string KtUtil::IpcStructToStr(const vnpdrv_val_vtunnel_if& data) {
+ std::stringstream ss;
+ ss << " ----- vnpdrv_val_vtunnel_if ----- " << endl;
+ ss << " -->valid " << VALID_ARRAY_TO_STR(data.valid);
+ ss << " -->label " << data.label << endl;
+ ss << " -->vlan_id " << data.vlan_id << endl;
+ return ss.str();
+}
+
+
+
} // namespace ipc_util
} // namespace upll
} // namespace unc
static string ValidArrayToStr(const uint8_t *validarray, int size);
static string ConfigStatusToStr(const uint8_t *cfgstatus, int size);
+ static string IpcStructToStr(const vnpdrv_val_vtunnel &data);
+ static string IpcStructToStr(const vnpdrv_val_vtunnel_if &data);
+
private:
KtUtil() {}
void Init();
#include "pfc/log.h"
#include "unc/uppl_common.h"
#include "momgr_impl.hh"
+#include "dhcprelay_server_momgr.hh"
// #include "vtn_momgr.hh"
// #include "vbr_momgr.hh"
#include "vlink_momgr.hh"
// #include "vbr_if_momgr.hh"
// #include "policingprofile_entry_momgr.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
// using namespace std;
using unc::upll::ipc_util::IpcUtil;
UPLL_LOG_DEBUG("ValidateAttribute failed, Error - %d", result_code);
return result_code;
}
+
+ // Parent check
+ if (ikey->get_key_type() == UNC_KT_VUNKNOWN ||
+ ikey->get_key_type() == UNC_KT_VUNK_IF) {
+ ConfigKeyVal *okey = NULL;
+ if (ikey->get_key_type() == UNC_KT_VUNKNOWN) {
+ // Vnode Existence check in CANDIDATE DB
+ result_code = VnodeChecks(ikey, req->datatype, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG(
+ "Another Vnode with the same name already exists. Error code : %d",
+ result_code);
+ return result_code;
+ }
+ result_code = GetParentConfigKey(okey, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error in retrieving the parent ConfigKeyVal");
+ if (okey)
+ delete okey;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ MoMgrImpl *vtn_mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>
+ (const_cast<MoManager*>(GetMoManager(UNC_KT_VTN))));
+ result_code = vtn_mgr->UpdateConfigDB(okey, req->datatype, UNC_OP_READ,
+ dmi, MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code) {
+ UPLL_LOG_DEBUG("Parent doesn't exist!");
+ if (okey)
+ delete okey;
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ return UPLL_RC_ERR_PARENT_DOES_NOT_EXIST;
+ }else {
+ UPLL_LOG_DEBUG("UpdateConfigDB Failed %d", result_code);
+ return result_code;
+ }
+ }
+ if (okey)
+ delete okey;
+ }
+ if (ikey->get_key_type() == UNC_KT_VUNK_IF) {
+ result_code = GetParentConfigKey(okey, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error in retrieving the parent ConfigKeyVal");
+ if (okey)
+ delete okey;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ MoMgrImpl *vunk_mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>
+ (const_cast<MoManager*>(GetMoManager(UNC_KT_VUNKNOWN))));
+ result_code = vunk_mgr->UpdateConfigDB(okey, req->datatype, UNC_OP_READ,
+ dmi, MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code) {
+ UPLL_LOG_DEBUG("Parent doesn't exist!");
+ if (okey)
+ delete okey;
+ return UPLL_RC_ERR_PARENT_DOES_NOT_EXIST;
+ }
+ if (okey)
+ delete okey;
+ }
+ }
// Check if VTN already exists in CANDIDATE DB
result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_READ, dmi);
if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS
- || result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
-// std::cout << "Record already exists in Candidate DB";
+ || result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
return result_code;
}
if (UPLL_DT_CANDIDATE == req->datatype) {
- // Check if VTN exists in RUNNING DB and move it to CANDIDATE DB
- result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING,
+ // Check if VTN exists in RUNNING DB and move it to CANDIDATE DB
+ result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING,
UNC_OP_READ, dmi, MAINTBL);
- if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
- result_code = RestoreChildren(ikey, req->datatype, UPLL_DT_RUNNING, dmi);
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code &&
+ UPLL_RC_ERR_INSTANCE_EXISTS != result_code) {
+ UPLL_LOG_DEBUG("Error in UpdateConfigDB %d", result_code);
+ return result_code;
+ }
+ if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
+ result_code = RestoreChildren(ikey, req->datatype, UPLL_DT_RUNNING, dmi);
if (result_code != UPLL_RC_SUCCESS) {
- return UPLL_RC_ERR_GENERIC;
+ return result_code;
}
return result_code;
}
}
- if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- // create a record in CANDIDATE DB
- result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_CREATE, dmi);
- return result_code;
- } else {
- UPLL_LOG_ERROR("Error in reading DB");
- }
+ // create a record in CANDIDATE DB
+ result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_CREATE, dmi);
return result_code;
}
const char *ctrlr_id) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- UPLL_LOG_DEBUG("\n ikey is %s\n", ikey->ToStrAll().c_str());
+ UPLL_LOG_TRACE(" ikey is %s", ikey->ToStrAll().c_str());
uint8_t *controller_id = reinterpret_cast<uint8_t *>(
const_cast<char *>(ctrlr_id));
*/
result_code = GetRenamedUncKey(ikey, UPLL_DT_RUNNING, dmi, controller_id);
if (result_code != UPLL_RC_SUCCESS && result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- UPLL_LOG_DEBUG("GetRenamedUncKey Failed err_code %d\n", result_code);
+ UPLL_LOG_DEBUG("GetRenamedUncKey Failed err_code %d", result_code);
return result_code;
}
- UPLL_LOG_DEBUG("ikey After GetRenamedUncKey %s\n", ikey->ToStrAll().c_str());
- // Create a record in AUDIT DB
- result_code = UpdateConfigDB(ikey, UPLL_DT_AUDIT, UNC_OP_CREATE, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("UpdateConfigDB Failed err_code %d\n", result_code);
- }
- return result_code;
-}
-
-
-upll_rc_t MoMgrImpl::CreateImportMoImpl(IpcReqRespHeader *req,
- ConfigKeyVal *ikey,
- DalDmlIntf *dmi,
- const char *ctrlr_id,
- const char *domain_id) {
- UPLL_FUNC_TRACE;
-// std::cout << "MoMgrImpl::CreateImportMoImpl";
- upll_rc_t result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_TRACE("ikey After GetRenamedUncKey %s", ikey->ToStrAll().c_str());
- // check for key support on controller and max count
- result_code = ValidateCapability(req, ikey, ctrlr_id);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_ERROR("ValidateCapability failed");
+ result_code = SetValidAudit(ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
return result_code;
}
- /* Check if the record already esits in IMPORT DB
- ** if eixsts - return
- ** else - create a record
- */
- result_code = UpdateConfigDB(ikey, UPLL_DT_IMPORT, UNC_OP_READ, dmi);
- if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
- // cout << "Record already exists in IMPORT DB";
+ result_code = UpdateConfigDB(ikey, UPLL_DT_AUDIT, UNC_OP_READ, dmi, MAINTBL);
+ if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS && result_code !=
+ UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("UpdateConfigDB Failed err_code %d", result_code);
return result_code;
}
- SET_USER_DATA_DOMAIN(ikey, domain_id);
- SET_USER_DATA_CTRLR(ikey, ctrlr_id);
- result_code = UpdateConfigDB(ikey, UPLL_DT_IMPORT, UNC_OP_CREATE, dmi);
- return result_code;
-}
-upll_rc_t MoMgrImpl::GetVrtDhcpRelayServerAddress(ConfigKeyVal *ikey, DalDmlIntf *dmi) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code;
- MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>
- (GetMoManager(UNC_KT_DHCPRELAY_SERVER)));
- ConfigKeyVal *ck_dhcp = NULL;
- result_code = mgr->GetChildConfigKey(ck_dhcp, ikey);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetChildConfigKey is failed- %d", result_code);
+ result_code = (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) ? UPLL_RC_SUCCESS :
+ result_code;
+ // Create a record in AUDIT DB
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ result_code = UpdateConfigDB(ikey, UPLL_DT_AUDIT, UNC_OP_CREATE, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigDB Failed err_code %d", result_code);
+ }
+ }
return result_code;
- }
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
- result_code = mgr->ReadConfigDB(ck_dhcp, UPLL_DT_RUNNING, UNC_OP_READ, dbop,
- dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Failed to ReadConfigDb- %d", result_code);
- return result_code;
- }
- val_vrt_dhcp_relay_st *val_vrt_dhcp = reinterpret_cast<val_vrt_dhcp_relay_st *>
- (ConfigKeyVal::Malloc(sizeof(val_vrt_dhcp_relay_st)));
- val_vrt_dhcp->valid[UPLL_IDX_DHCP_RELAY_ADMIN_STATUS_VDRS] = UNC_VF_INVALID;
- val_vrt_dhcp->valid[UPLL_IDX_IP_COUNT_VDRS] = UNC_VF_VALID;
- val_vrt_dhcp->valid[UPLL_IDX_IF_COUNT_VDRS] = UNC_VF_INVALID;
- ConfigKeyVal *tmp= ck_dhcp;
- while(tmp != NULL) {
- val_vrt_dhcp->ip_count++;
- tmp = tmp->get_next_cfg_key_val();
- }
- ikey->SetCfgVal(new ConfigVal(IpctSt::kIpcStValVrtDhcpRelaySt, val_vrt_dhcp));
- uint32_t ipcount = 0;
- ConfigKeyVal *tkey = ck_dhcp;
- while (tkey && ipcount < val_vrt_dhcp->ip_count) {
- key_dhcp_relay_server *dhcp_key =
- reinterpret_cast<key_dhcp_relay_server_t *>(tkey->get_key());
- uint32_t *ip_addr = reinterpret_cast<uint32_t *>(ConfigKeyVal::Malloc(sizeof(uint32_t)));
- *ip_addr = dhcp_key->server_addr.s_addr; // assign ipaddress
- ikey->AppendCfgVal( IpctSt::kIpcStIpv4, ip_addr);
- ipcount++;
- tkey = tkey->get_next_cfg_key_val();
- }
- if (ck_dhcp)
- delete ck_dhcp;
-return UPLL_RC_SUCCESS;
}
upll_rc_t MoMgrImpl::ReadMo(IpcReqRespHeader *header,
DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ck_dhcp = NULL;
controller_domain ctrlr_dom;
memset(&ctrlr_dom, 0, sizeof(controller_domain));
-
+
+ DhcpRelayServerMoMgr *mgr_dhcp = reinterpret_cast<DhcpRelayServerMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_DHCPRELAY_SERVER)));
+ if (!mgr_dhcp) {
+ UPLL_LOG_DEBUG("Invalid Mgr");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
// To validate the read request from VTNService
result_code = ValidateMessage(header, ikey);
if (result_code != UPLL_RC_SUCCESS) {
result_code);
return result_code;
}
+
+ if (header->option2 == UNC_OPT2_NEIGHBOR) {
+ if (ikey->get_key_type() != UNC_KT_VUNK_IF) {
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ }
+
+ if ((header->operation == UNC_OP_READ) &&
+ ((header->datatype == UPLL_DT_CANDIDATE) ||
+ (header->datatype == UPLL_DT_RUNNING) ||
+ (header->datatype == UPLL_DT_STARTUP) ||
+ (header->datatype == UPLL_DT_STATE))) {
+ result_code = PopulateValVtnNeighbor(ikey, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("PopulateValVtnNeighbor failed result_code %d", result_code);
+ }
+ return result_code;
+ }
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+
if ( ((header->option1 != UNC_OPT1_DETAIL) ||
- ((header->option1 == UNC_OPT1_DETAIL) &&
+ ((header->option1 == UNC_OPT1_DETAIL) &&
(ikey->get_key_type() == UNC_KT_VBR_NWMONITOR)))&&
header->option2 == UNC_OPT2_NONE) {
-
result_code = ReadInfoFromDB(header, ikey, dmi, &ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadInfoFromDB failed, result_code= %d",
}
}
if (header->datatype == UPLL_DT_STATE &&
- (header->option1 != UNC_OPT1_COUNT &&
- header->option2 == UNC_OPT2_DHCP_RELAY)) {
- GetVrtDhcpRelayServerAddress(ikey, dmi);
+ (header->option1 != UNC_OPT1_COUNT &&
+ header->option2 == UNC_OPT2_DHCP_RELAY)) {
+ result_code = mgr_dhcp->GetVrtDhcpRelayServerAddress(ikey, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetVrtDhcpRelayServerAddress Failed");
+ return result_code;
+ }
}
if ((header->datatype == UPLL_DT_STATE) &&
((ikey->get_key_type() == UNC_KT_VBR_NWMONITOR) ||
+ (ikey->get_key_type() == UNC_KT_DHCPRELAY_IF) ||
((header->option1 == UNC_OPT1_DETAIL) ||
- ((header->option2 != UNC_OPT2_DHCP_RELAY) &&
+ ((header->option2 != UNC_OPT2_DHCP_RELAY) &&
(header->option2 != UNC_OPT2_NONE))))) {
// check with karthi GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
// Getting the controller vtn, vnode name
- result_code = UpdateConfigDB(ikey, header->datatype, UNC_OP_READ, dmi);
+// result_code = UpdateConfigDB(ikey, header->datatype, UNC_OP_READ, dmi);
+// if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code) {
+// UPLL_LOG_ERROR("Record Doesn't Exists in DB ");
+// return result_code;
+// }
+
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain };
+
+ if (ikey->get_key_type() != UNC_KT_VTN) {
+ ctrlr_dom.ctrlr = ctrlr_dom.domain = NULL;
+ result_code = GetChildConfigKey(ck_dhcp, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey is failed- %d", result_code);
+ delete ck_dhcp;
+ return result_code;
+ }
+ result_code = ReadConfigDB(ck_dhcp, header->datatype, UNC_OP_READ, dbop,
+ dmi, MAINTBL);
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Failed to ReadConfigDb- %d", result_code);
+ delete ck_dhcp;
+ return result_code;
+ }
+ GET_USER_DATA_CTRLR_DOMAIN(ck_dhcp, ctrlr_dom);
+ UPLL_LOG_TRACE("Controller Name is: %s", ctrlr_dom.ctrlr);
+ result_code = ValidateCapability(
+ header, ikey, reinterpret_cast<char *>(ctrlr_dom.ctrlr));
- if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code) {
- UPLL_LOG_ERROR("Record Doesn't Exists in DB ");
- return result_code;
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ValidateCapability is failed: %d", result_code);
+ delete ck_dhcp;
+ return result_code;
+ }
+ if (ikey->get_key_type() == UNC_KT_VLINK) {
+ controller_domain ctrlr_vnode2_ctrlr;
+ memset(&ctrlr_vnode2_ctrlr, 0, sizeof(controller_domain));
+ GET_USER_DATA_CTRLR_DOMAIN(ck_dhcp->get_cfg_val(), ctrlr_vnode2_ctrlr);
+ UPLL_LOG_INFO("2nd controller name %s",
+ reinterpret_cast<const char *>(ctrlr_vnode2_ctrlr.ctrlr));
+ if (strcmp((const char *)ctrlr_vnode2_ctrlr.ctrlr,
+ (const char *)ctrlr_dom.ctrlr)) {
+ result_code = ValidateCapability(header, ikey,
+ reinterpret_cast<const char *>(ctrlr_vnode2_ctrlr.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ValidateCapability Failed for vlink %d", result_code);
+ return result_code;
+ }
+ }
+ }
}
result_code = GetRenamedControllerKey(ikey, header->datatype, dmi,
&ctrlr_dom);
result_code);
return result_code;
}
- UPLL_LOG_TRACE("After Read %s",(ikey->ToStrAll()).c_str());
+ UPLL_LOG_TRACE("After Read %s", (ikey->ToStrAll()).c_str());
IpcResponse ipc_resp;
- memset(&(ipc_resp),0,sizeof(IpcResponse));
+ memset(&(ipc_resp), 0, sizeof(IpcResponse));
IpcRequest ipc_req;
memset(&ipc_req, 0, sizeof(ipc_req));
memcpy(&(ipc_req.header), header, sizeof(IpcReqRespHeader));
- UPLL_LOG_TRACE("ConfigId %d",ipc_req.header.config_id);
- UPLL_LOG_TRACE("Operation %d",ipc_req.header.operation);
+ UPLL_LOG_TRACE("ConfigId %d", ipc_req.header.config_id);
+ UPLL_LOG_TRACE("Operation %d", ipc_req.header.operation);
UPLL_LOG_TRACE(" DataType %d", ipc_req.header.datatype);
UPLL_LOG_TRACE("Option1 %d Option2 %d", ipc_req.header.option1, ipc_req.header.option2);
ipc_req.ckv_data = ikey;
- UPLL_LOG_TRACE("Before Sending to Driver %s",(ikey->ToStrAll()).c_str());
- UPLL_LOG_TRACE("Domain Name %s \n", ctrlr_dom.domain);
- UPLL_LOG_TRACE("Controller Name %s \n", ctrlr_dom.ctrlr);
+ UPLL_LOG_TRACE("Before Sending to Driver %s", (ikey->ToStrAll()).c_str());
+ UPLL_LOG_TRACE("Domain Name %s", ctrlr_dom.domain);
+ UPLL_LOG_TRACE("Controller Name %s", ctrlr_dom.ctrlr);
if (!IpcUtil::SendReqToDriver((const char *)(ctrlr_dom.ctrlr),
- reinterpret_cast<char *>(ctrlr_dom.domain), PFCDRIVER_SERVICE_NAME,
+ reinterpret_cast<char *>(ctrlr_dom.domain), PFCDRIVER_SERVICE_NAME,
PFCDRIVER_SVID_LOGICAL, &ipc_req, true, &ipc_resp)) {
UPLL_LOG_INFO("Request to driver for Key %d for controller %s failed ",
ikey->get_key_type(), reinterpret_cast<char *>(ctrlr_dom.ctrlr));
-
+ return ipc_resp.header.result_code;
}
-
- UPLL_LOG_TRACE("AfterDriver Read from Controller %s",(ikey->ToStrAll()).c_str());
+
+ UPLL_LOG_TRACE("AfterDriver Read from Controller %s", (ikey->ToStrAll()).c_str());
// Populate ConfigKeyVal and IpcReqRespHeader with the response from driver
- ikey->ResetWith(ipc_resp.ckv_data);
+ if (ipc_resp.header.result_code == UPLL_RC_SUCCESS) {
+ ikey->ResetWith(ipc_resp.ckv_data);
+ }
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
result_code = ipc_resp.header.result_code;
+ upll_rc_t child_result_code = GetChildConfigKey(ikey, ck_dhcp);
+ if (UPLL_RC_SUCCESS != child_result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKeyFailed %d", child_result_code);
+ return child_result_code;
+ }
}
- UPLL_LOG_TRACE("Before AdaptValtovtnservice %s",(ikey->ToStrAll()).c_str());
- if (result_code == UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("Before AdaptValtovtnservice %s", (ikey->ToStrAll()).c_str());
+ if (result_code == UPLL_RC_SUCCESS && UPLL_DT_IMPORT != header->datatype) {
result_code = AdaptValToVtnService(ikey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("AdaptValToVtnService failed result_code %d",
return result_code;
}
}
+ if (ck_dhcp)
+ delete ck_dhcp;
+
return result_code;
}
return result_code;
}
- // To validate the read sibling / read sibling begin request from VTNService
- result_code = ReadInfoFromDB(header, ikey, dmi, &ctrlr_dom);
+ ConfigKeyVal *tkey = NULL;
+ ConfigKeyVal *start_key = ikey;
+
+ bool set_flag = false;
+ if (header->datatype == UPLL_DT_STATE && UNC_OPT2_NONE != header->option2) {
+ if (ikey->get_cfg_val() == NULL) {
+ set_flag = true;
+ result_code = ReadInfoFromDB(header, ikey, dmi, &ctrlr_dom);
+ } else {
+ result_code = GetChildConfigKey(tkey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed");
+ return result_code;
+ }
+ result_code = ReadInfoFromDB(header, tkey, dmi, &ctrlr_dom);
+ ConfigKeyVal *travel_key = tkey;
+ while (travel_key) {
+ ConfigVal *travel_val = ikey->get_cfg_val();
+ ConfigVal *fval = (travel_val)->DupVal();
+ travel_key->SetCfgVal(fval);
+ while (travel_val) {
+ travel_val = travel_val->get_next_cfg_val();
+ if (travel_val) {
+ ConfigVal *sval = travel_val->DupVal();
+ travel_key->AppendCfgVal(sval);
+ } else {
+ break;
+ }
+ }
+ travel_key = travel_key->get_next_cfg_key_val();
+ }
+ ikey =tkey;
+ }
+ } else {
+ set_flag = true;
+ result_code = ReadInfoFromDB(header, ikey, dmi, &ctrlr_dom);
+ }
+
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadInfoFromDB failed result_code %d",
result_code);
return result_code;
}
-
+
if (header->datatype == UPLL_DT_STATE &&
- ((ikey->get_key_type() == UNC_KT_VBR_NWMONITOR) ||
- header->option1 == UNC_OPT1_DETAIL ||
- header->option2 != UNC_OPT2_NONE)) {
- // ikey is retained in next_ckv,and then refered by end_resp_ckv. Once the
- // while loop is executed once, end_resp_ckv and ikey point to same.
- ConfigKeyVal *end_resp_ckv = NULL;
- ConfigKeyVal *one_ckv;
- ConfigKeyVal *next_ckv = ikey;
- while (NULL != next_ckv) {
- one_ckv = next_ckv;
- next_ckv = next_ckv->get_next_cfg_key_val();
- one_ckv->set_next_cfg_key_val(NULL);
- GET_USER_DATA_CTRLR_DOMAIN(one_ckv, ctrlr_dom);
- // Get controller key
- // TODO GetReanmedControllerKey changes the actual data and the same will
- // go to VTN Service. BUG.
- if (header->datatype == UPLL_DT_STATE &&
- (header->option1 != UNC_OPT1_COUNT &&
- header->option2 == UNC_OPT2_DHCP_RELAY)) {
- GetVrtDhcpRelayServerAddress(one_ckv, dmi);
- if (header->option1 == UNC_OPT1_NORMAL) {
- if (end_resp_ckv == NULL) {
- end_resp_ckv = ikey;
- } else {
- end_resp_ckv->AppendCfgKeyVal(one_ckv);
- }
- continue;
- }
+ ((ikey->get_key_type() == UNC_KT_VBR_NWMONITOR) ||
+ (ikey->get_key_type() == UNC_KT_DHCPRELAY_IF) ||
+ header->option1 == UNC_OPT1_DETAIL ||
+ header->option2 != UNC_OPT2_NONE)) {
+ // ikey is retained in next_ckv, and then refered by end_resp_ckv. Once the
+ // while loop is executed once, end_resp_ckv and ikey point to same.
+ ConfigKeyVal *end_resp_ckv = NULL;
+ ConfigKeyVal *one_ckv , *next_ckv;
+
+ next_ckv = ikey;
+ ConfigKeyVal *end_resp_ckv_tail = NULL;
+ while (NULL != next_ckv) {
+ one_ckv = next_ckv;
+ next_ckv = next_ckv->get_next_cfg_key_val();
+ one_ckv->set_next_cfg_key_val(NULL);
+ GET_USER_DATA_CTRLR_DOMAIN(one_ckv, ctrlr_dom);
+ // Get controller key
+ // TODO(myself) GetReanmedControllerKey changes the actual data
+ // and same will go to VTN Service. BUG.
+ if (header->datatype == UPLL_DT_STATE &&
+ (header->option1 != UNC_OPT1_COUNT &&
+ header->option2 == UNC_OPT2_DHCP_RELAY)) {
+ DhcpRelayServerMoMgr *mgr_dhcp =
+ reinterpret_cast<DhcpRelayServerMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_DHCPRELAY_SERVER)));
+ if (!mgr_dhcp) {
+ UPLL_LOG_DEBUG("Invalid Mgr");
+ return UPLL_RC_ERR_GENERIC;
}
-
- result_code = GetRenamedControllerKey(one_ckv, header->datatype, dmi,
- &ctrlr_dom);
+ result_code = mgr_dhcp->GetVrtDhcpRelayServerAddress(one_ckv, dmi);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetRenamedControllerKey failed result_code %d",
- result_code);
+ UPLL_LOG_DEBUG("GetVrtDhcpRelayServerAddress Failed");
return result_code;
}
- UPLL_LOG_TRACE("After Read %s",(one_ckv->ToStrAll()).c_str());
+ if (header->option1 == UNC_OPT1_NORMAL) {
+ if (end_resp_ckv == NULL) {
+ end_resp_ckv = ikey;
+ } else {
+ end_resp_ckv->AppendCfgKeyVal(one_ckv);
+ }
+ continue;
+ }
+ }
- IpcResponse ipc_resp;
- memset(&(ipc_resp),0,sizeof(IpcResponse));
- IpcRequest ipc_req;
- memset(&ipc_req, 0, sizeof(ipc_req));
- memcpy(&(ipc_req.header), header, sizeof(IpcReqRespHeader));
- ipc_req.header.operation = UNC_OP_READ;
- ipc_req.ckv_data = one_ckv;
+ DbSubOp dbop1 = { kOpReadSingle, kOpMatchNone, kOpInOutCtrlr | kOpInOutFlag
+ | kOpInOutDomain };
+ ConfigKeyVal *temp_key = NULL;
+ result_code = GetChildConfigKey(temp_key, one_ckv);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed");
+ return result_code;
+ }
+ result_code = ReadConfigDB(temp_key, header->datatype,
+ UNC_OP_READ, dbop1, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(temp_key);
+ return result_code;
+ }
+ memset(&ctrlr_dom, 0, sizeof(controller_domain));
+ GET_USER_DATA_CTRLR_DOMAIN(temp_key, ctrlr_dom);
- if (!IpcUtil::SendReqToDriver((const char *)(ctrlr_dom.ctrlr),
- reinterpret_cast<char *>(ctrlr_dom.domain), PFCDRIVER_SERVICE_NAME,
- PFCDRIVER_SVID_LOGICAL, &ipc_req, true, &ipc_resp)) {
- UPLL_LOG_INFO("Request to driver for Key %d for controller %s failed ",
- one_ckv->get_key_type(), reinterpret_cast<char *>(ctrlr_dom.ctrlr));
- }
- UPLL_LOG_TRACE("AfterDriver Read from Controller %s",(one_ckv->ToStrAll()).c_str());
- // Populate ConfigKeyVal with the response from driver
- one_ckv->ResetWith(ipc_resp.ckv_data);
- if (end_resp_ckv == NULL) {
- end_resp_ckv = ikey; // ikey and one_ckv should be same here
- if (one_ckv == ikey) {
- UPLL_LOG_TRACE("ikey has val\n");
- } else {
- UPLL_LOG_TRACE("ikey %p one_ckv %p\n",ikey,one_ckv);
- }
- } else {
- end_resp_ckv->AppendCfgKeyVal(one_ckv);
- UPLL_LOG_TRACE("ikey %p one_ckv %p end_ckv %p\n",ikey,one_ckv,end_resp_ckv);
- }
- result_code = ipc_resp.header.result_code;
- }
- }
- if (header->rep_count > 0) {
- if (result_code == UPLL_RC_SUCCESS) {
- result_code = AdaptValToVtnService(ikey);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("AdaptValToVtnService failed result_code %d",
- result_code);
- return result_code;
- }
- }
+ result_code = ValidateCapability(
+ header, one_ckv, reinterpret_cast<const char *>
+ (ctrlr_dom.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ValidateCapability Failed %d", result_code);
+ DELETE_IF_NOT_NULL(temp_key);
+ return result_code;
+ }
+ if (ikey->get_key_type() == UNC_KT_VLINK) {
+ controller_domain ctrlr_vnode2_ctrlr;
+ memset(&ctrlr_vnode2_ctrlr, 0, sizeof(controller_domain));
+ GET_USER_DATA_CTRLR_DOMAIN(temp_key->get_cfg_val(), ctrlr_vnode2_ctrlr);
+ if (strcmp((const char *)ctrlr_vnode2_ctrlr.ctrlr,
+ (const char *)ctrlr_dom.ctrlr)) {
+ result_code = ValidateCapability(header, one_ckv,
+ reinterpret_cast<const char *>(ctrlr_vnode2_ctrlr.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ValidateCapability Failed %d", result_code);
+ DELETE_IF_NOT_NULL(temp_key);
+ return result_code;
+ }
+ }
+ }
+ result_code = GetRenamedControllerKey(one_ckv, header->datatype, dmi,
+ &ctrlr_dom);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetRenamedControllerKey failed result_code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(temp_key);
+ return result_code;
+ }
+ if (UNC_KT_VBRIDGE == one_ckv->get_key_type() &&
+ UNC_OPT2_NONE != header->option2) {
+ UPLL_LOG_DEBUG("Set NULL for ConfigVal");
+ one_ckv->SetCfgVal(NULL);
+ }
+ UPLL_LOG_TRACE("After Read %s", (one_ckv->ToStrAll()).c_str());
+ IpcResponse ipc_resp;
+ memset(&(ipc_resp), 0, sizeof(IpcResponse));
+ IpcRequest ipc_req;
+ memset(&ipc_req, 0, sizeof(ipc_req));
+ memcpy(&(ipc_req.header), header, sizeof(IpcReqRespHeader));
+ ipc_req.header.operation = UNC_OP_READ;
+ ipc_req.ckv_data = one_ckv;
+
+ if (!IpcUtil::SendReqToDriver((const char *)(ctrlr_dom.ctrlr),
+ reinterpret_cast<char *>(ctrlr_dom.domain), PFCDRIVER_SERVICE_NAME,
+ PFCDRIVER_SVID_LOGICAL, &ipc_req, true, &ipc_resp)) {
+ UPLL_LOG_INFO("Request to driver for Key %d for controller %s failed ",
+ one_ckv->get_key_type(), reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ return ipc_resp.header.result_code;
+ }
+ UPLL_LOG_TRACE("AfterDriver Read from Controller %s",
+ (one_ckv->ToStrAll()).c_str());
+ // Populate ConfigKeyVal with the response from driver
+ if (ipc_resp.header.result_code == UPLL_RC_SUCCESS) {
+ one_ckv->ResetWith(ipc_resp.ckv_data);
+ delete ipc_resp.ckv_data;
+ } else {
+ DELETE_IF_NOT_NULL(temp_key);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ return ipc_resp.header.result_code;
+ }
+ if (end_resp_ckv == NULL) {
+ end_resp_ckv = ikey; // ikey and one_ckv should be same here
+ if (one_ckv == ikey) {
+ UPLL_LOG_TRACE("ikey has val");
+ } else {
+ UPLL_LOG_TRACE("ikey %p one_ckv %p", ikey, one_ckv);
+ }
+ end_resp_ckv_tail = end_resp_ckv;
+ } else {
+ end_resp_ckv_tail->AppendCfgKeyVal(one_ckv);
+ end_resp_ckv_tail = one_ckv;
+ UPLL_LOG_TRACE("ikey %p one_ckv %p end_ckv %p", ikey,
+ one_ckv, end_resp_ckv);
+ }
+ result_code = ipc_resp.header.result_code;
+ upll_rc_t child_result_code = GetChildConfigKey(one_ckv, temp_key);
+ if (UPLL_RC_SUCCESS != child_result_code) {
+ DELETE_IF_NOT_NULL(temp_key);
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed %d", child_result_code);
+ return child_result_code;
+ }
+
+ DELETE_IF_NOT_NULL(temp_key);
+ UPLL_LOG_TRACE("AfterDriver Read from Controller %s",
+ (one_ckv->ToStrAll()).c_str());
+ }
+
+ UPLL_LOG_TRACE("BEFORE REST WITHr %s",
+ (end_resp_ckv->ToStrAll()).c_str());
+ if (!set_flag && end_resp_ckv) {
+ start_key->ResetWith(end_resp_ckv);
+ delete end_resp_ckv;
+ }
+ UPLL_LOG_TRACE("AFTER REST WITHr %s",
+ (end_resp_ckv->ToStrAll()).c_str());
+ }
+
+ if (header->rep_count > 0) {
+ if (result_code == UPLL_RC_SUCCESS
+ && UPLL_DT_IMPORT != header->datatype) {
+ result_code = AdaptValToVtnService(start_key);
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("AdaptValToVtnService failed result_code %d",
+ result_code);
+ return result_code;
+ }
}
+ }
+
return result_code;
}
result_code);
return result_code;
}
+#if 0
+ DbSubOp dbop1 = { kOpReadSingle, kOpMatchNone, kOpInOutCtrlr | kOpInOutFlag
+ | kOpInOutDomain };
+ ConfigKeyVal *temp_key = NULL;
+ result_code = GetChildConfigKey(temp_key, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed");
+ return result_code;
+ }
+ result_code = ReadConfigDB(temp_key, header->datatype,
+ UNC_OP_READ, dbop1, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ return result_code;
+ }
+ GET_USER_DATA_CTRLR_DOMAIN(temp_key, ctrlr_dom);
+ result_code = ValidateCapability(
+ header, ikey, reinterpret_cast<const char *>
+ (ctrlr_dom.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ValidateCapability Failed %d", result_code);
+ return result_code;
+ }
+ if (ikey->get_key_type() == UNC_KT_VLINK) {
+ controller_domain ctrlr_vnode2_ctrlr;
+ memset(&ctrlr_vnode2_ctrlr, 0, sizeof(controller_domain));
+ GET_USER_DATA_CTRLR_DOMAIN(temp_key->get_cfg_val(), ctrlr_vnode2_ctrlr);
+ if (strcmp((const char *)ctrlr_vnode2_ctrlr.ctrlr,
+ (const char *)ctrlr_dom.ctrlr)) {
+ result_code = ValidateCapability(header, ikey,
+ reinterpret_cast<const char *>(ctrlr_vnode2_ctrlr.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ValidateCapability Failed %d", result_code);
+ return result_code;
+ }
+ }
+ }
+#endif
result_code = ReadInfoFromDB(header, ikey, dmi, &ctrlr_dom);
return result_code;
}
#if 0
MoMgrTables tbl = (header->operation != UNC_OP_READ_SIBLING_COUNT &&
header->datatype == UPLL_DT_IMPORT) ? RENAMETBL:MAINTBL;
- #endif
+ #endif
MoMgrTables tbl = MAINTBL;
- DbSubOp dbop = {kOpReadSingle, kOpMatchNone,
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone,
kOpInOutCtrlr | kOpInOutDomain | kOpInOutFlag};
// To validate the READ, READ_SIBLING, READ_SIBLING_BEGIN
// and READ_SIBLING_COUNT message
- unc_key_type_t key_type = ikey->get_key_type();
- if (KEY_TYPE_BIND_CS(key_type)) {
- dbop.inoutop = kOpInOutCs;
- }
+ /* There is not difference between show running configuration
+ * and show running configuration status in the request. so
+ * binding cs statuin in ruuing. Once the request is differentiate
+ * have to modify here
+ */
+ if (UPLL_DT_RUNNING == header->datatype) {
+ UPLL_LOG_TRACE("Status Flag enabled");
+ dbop.inoutop |= kOpInOutCs;
+ } else if(KEY_TYPE_BIND_CS(ikey->get_key_type())) {
+ UPLL_LOG_TRACE("Status Flag enabled");
+ dbop.inoutop |= kOpInOutCs;
+ }
switch (header->datatype) {
case UPLL_DT_IMPORT:
- #if 0
if (header->operation != UNC_OP_READ_SIBLING_COUNT) {
- result_code = GetRenamedUncKey(ikey, header->datatype, dmi, NULL);
- if (result_code != UPLL_RC_SUCCESS)
- UPLL_LOG_DEBUG("GetRenamedUncKey failed result_code %d",
- result_code);
+ result_code = ReadImportDB(ikey, header, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadImportDB failed %d", result_code);
return result_code;
+ }
+ return result_code;
}
- #endif
+ break;
case UPLL_DT_CANDIDATE:
case UPLL_DT_RUNNING:
case UPLL_DT_STARTUP:
ConfigVal *new_cval = NULL;
ConfigVal *orig_new_cval = NULL;
if (cval) {
- while(cval) {
+ while (cval) {
UPLL_LOG_TRACE("Allocate new value struct...");
AllocVal(new_cval, dt_type, MAINTBL);
- if(orig_new_cval == NULL)
+ if (orig_new_cval == NULL)
orig_new_cval = new_cval;
const pfc_ipcstdef_t *st_def = IpctSt::GetIpcStdef(
cval->get_st_num());
UPLL_LOG_TRACE("Allocate new value struct for st_num:%d...", cval->get_st_num());
- memcpy(new_cval->get_val(),cval->get_val(),st_def->ist_size);
+ memcpy(new_cval->get_val(), cval->get_val(), st_def->ist_size);
if (dt_type == UPLL_DT_STATE) {
cval = cval->get_next_cfg_val();
new_cval = new_cval->get_next_cfg_val();
- }
- else
+ } else {
break;
+ }
}
ikey->SetCfgVal(orig_new_cval);
}
if ((header->operation == UNC_OP_READ_SIBLING_BEGIN) ||
(header->operation == UNC_OP_READ_SIBLING)) {
dbop.readop = kOpReadMultiple;
- }else if (header->operation == UNC_OP_READ_SIBLING_COUNT) {
- dbop.readop = kOpReadCount;
+ } else if (header->operation == UNC_OP_READ_SIBLING_COUNT) {
+ dbop.readop = kOpReadCount;
}
UPLL_LOG_TRACE("Before the Read ConfigVal is %s", (ikey->ToStrAll()).c_str());
break;
}
if (result_code != UPLL_RC_SUCCESS)
- UPLL_LOG_DEBUG("Returning %d",result_code);
+ UPLL_LOG_DEBUG("Returning %d", result_code);
return result_code;
}
if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code) {
UPLL_LOG_ERROR("Record Doesn't Exists in DB ");
return result_code;
- } else
- result_code = UPLL_RC_SUCCESS;
+ } else {
+ result_code = UPLL_RC_SUCCESS;
+ }
#if 1
result_code = IsReferenced(ikey, req->datatype, dmi);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_ERROR("Semantic Error - IsReferenced ");
+ UPLL_LOG_ERROR("Semantic Error - IsReferenced ErrorCode: %d",
+ result_code);
return result_code; // Semantic Error
}
#endif
+
+ #if 0
+ /* Check if vrouter admin status is disabled */
+ result_code = IsAdminStatusEnable(ikey, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_ERROR("IsAdminStatusEnable Failed %d ", result_code);
+ return result_code;
+ }
+ #endif
+
return result_code;
}
upll_rc_t MoMgrImpl::DeleteMo(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
DalDmlIntf *dmi) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = ValidateDeleteMoReq(req,ikey,dmi);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_ERROR("Returning Error - %d",result_code);
- return result_code; // Semantic Error
- }
- result_code = DeleteCandidateMo(req,ikey,dmi);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_ERROR("Returning Error - %d",result_code);
- }
- return result_code;
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = ValidateDeleteMoReq(req, ikey, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_ERROR("Returning Error - %d", result_code);
+ return result_code; // Semantic Error
+ }
+ result_code = DeleteCandidateMo(req, ikey, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_ERROR("Returning Error - %d", result_code);
+ }
+ return result_code;
}
upll_rc_t MoMgrImpl::DeleteCandidateMo(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
DalDmlIntf *dmi) {
-
UPLL_FUNC_TRACE;
bool fail = false;
#if 0
#endif
upll_rc_t result_code = DeleteChildren(ikey, req->datatype, dmi, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_ERROR("DeleteChildren %d",result_code);
+ UPLL_LOG_ERROR("DeleteChildren %d", result_code);
return result_code; // Semantic Error
}
- for (int i = 0 ; i < ntable; i++) {
+ for (int i = 0; i < ntable; i++) {
if (GetTable((MoMgrTables)i, UPLL_DT_CANDIDATE) >= uudst::kDalNumTables) {
continue;
}
result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
UPLL_RC_SUCCESS:result_code;
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_ERROR("Delete Operation fails with %d",result_code);
+ UPLL_LOG_ERROR("Delete Operation fails with %d", result_code);
fail = true;
}
}
UPLL_LOG_ERROR("Given Input is Empty");
return UPLL_RC_ERR_GENERIC;
}
- UPLL_LOG_ERROR("UpdateMo for %d", ikey->get_key_type());
+ UPLL_LOG_INFO("UpdateMo for %d", ikey->get_key_type());
result_code = ValidateMessage(req, ikey);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_ERROR("Validation Message is Failed ");
return result_code;
}
+ controller_domain ctrlr_dom;
+ ctrlr_dom.ctrlr = ctrlr_dom.domain = NULL;
+ ConfigKeyVal *temp_ck = NULL;
+ result_code = GetChildConfigKey(temp_ck, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_ERROR("Error in retrieving the Child ConfigKeyVal");
+ if (temp_ck)
+ delete temp_ck;
+ return result_code;
+ }
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain };
+ result_code = ReadConfigDB(temp_ck, req->datatype, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("ReadConfigDB Failed %d", result_code);
+ delete temp_ck;
+ return result_code;
+ }
+ GET_USER_DATA_CTRLR_DOMAIN(temp_ck, ctrlr_dom);
+ SET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+ if (ikey->get_key_type() != UNC_KT_VTN) {
+ result_code = ValidateCapability(
+ req, ikey, reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Validate Capability is Failed. Error_code : %d",
+ result_code);
+ delete temp_ck;
+ return result_code;
+ }
+ }
+ delete temp_ck;
+ // ValidateAttribute needs Controller Domain
result_code = ValidateAttribute(ikey, dmi, req);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_ERROR("Validate Attribute is Failed");
return result_code;
}
+ dbop.matchop = kOpMatchCtrlr | kOpMatchDomain;
result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_UPDATE,
dmi, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
CtrlrVoteStatusList *ctrlr_vote_status,
DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
+ upll_rc_t driver_result, result_code;
+ driver_result = result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *err_key = NULL;
uint8_t* ctrlr_id = NULL;
CtrlrVoteStatusList::iterator cvsListItr;
cvsListItr = ctrlr_vote_status->begin();
CtrlrVoteStatus *cv_status_ptr;
+ bool keytype_no_err = false;
if (OVERLAY_KT(keytype))
return UPLL_RC_SUCCESS;
const_cast<char *>(cv_status_ptr->ctrlr_id.c_str()));
UPLL_LOG_TRACE("TxVoteCtrlrStatus cvStatus controller ID: %s",
(cv_status_ptr->ctrlr_id).c_str());
- result_code = (upll_rc_t) cv_status_ptr->upll_ctrlr_result;
- if (result_code == UPLL_RC_ERR_RESOURCE_DISCONNECTED) {
+ driver_result = (upll_rc_t) cv_status_ptr->upll_ctrlr_result; \
+
+ if (driver_result == UPLL_RC_ERR_RESOURCE_DISCONNECTED) {
UPLL_LOG_DEBUG(" vote status is controller disconnect");
continue;
}
- if (result_code == UPLL_RC_SUCCESS) {
+ if (driver_result == UPLL_RC_SUCCESS) {
UPLL_LOG_TRACE("TxVoteCtrlrStatus cvStatus net result: UPLL_RC_SUCCESS");
continue;
}
err_key = err_key->get_next_cfg_key_val()) {
if (keytype != err_key->get_key_type())
continue;
+ keytype_no_err = true;
/* if renamed obtain the unc specifc name */
result_code = GetRenamedUncKey(err_key, UPLL_DT_CANDIDATE, dmi, ctrlr_id);
if ((result_code != UPLL_RC_SUCCESS) &&
}
vn_if_type iftype;
result_code = mgr->CheckIfMemberOfVlink(err_key,
- UPLL_DT_CANDIDATE, ck_vlink,dmi,iftype);
+ UPLL_DT_CANDIDATE, ck_vlink, dmi, iftype);
/* replace err_key with ck_vlink */
if (result_code == UPLL_RC_SUCCESS) {
if ((iftype == kVlinkBoundaryNode1) || (iftype == kVlinkBoundaryNode2)) {
err_key->ResetWith(ck_vlink);
continue;
} else {
- string s(err_key->ToStr());
if (ck_vlink) delete ck_vlink;
- UPLL_LOG_DEBUG("%s is an internal vlink",s.c_str());
+ UPLL_LOG_TRACE("%s is an internal vlink", (err_key->ToStr()).c_str());
}
} else if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- UPLL_LOG_DEBUG("Returning error %d",result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
if (ck_vlink) delete ck_vlink;
return UPLL_RC_ERR_GENERIC;
} else {
- string s(err_key->ToStr());
if (ck_vlink) delete ck_vlink;
- UPLL_LOG_DEBUG("%s is not part of a vlink",s.c_str());
+ UPLL_LOG_TRACE("%s is not part of a vlink", (err_key->ToStr()).c_str());
}
}
+ result_code = AdaptValToVtnService(err_key);
}
}
- UPLL_LOG_TRACE("TxVote Controller Status : %d", result_code);
+ UPLL_LOG_TRACE("TxVote Controller Status : %d", driver_result);
+ if (!keytype_no_err)
+ return UPLL_RC_SUCCESS;
// Return vote Result to UPLLManager
- result_code = (result_code == UPLL_RC_ERR_RESOURCE_DISCONNECTED)?
- UPLL_RC_SUCCESS : result_code;
+ driver_result = (driver_result == UPLL_RC_ERR_RESOURCE_DISCONNECTED)?
+ UPLL_RC_SUCCESS : driver_result;
+ // return driver_result;
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) ?
+ UPLL_RC_SUCCESS : result_code;
return result_code;
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
DalResultCode db_result;
ConfigKeyVal *req = NULL, *nreq = NULL, *ck_main = NULL;
- controller_domain_t ctrlr_dom,vlink_ctrlr_dom[2];
+ controller_domain_t ctrlr_dom, vlink_ctrlr_dom[2];
vlink_ctrlr_dom[0].ctrlr = NULL;
vlink_ctrlr_dom[0].domain = NULL;
vlink_ctrlr_dom[1].ctrlr = NULL;
/* fall through intended */
result_code = DupConfigKeyVal(ck_main, req);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("DupConfigKeyVal failed %d",result_code);
+ UPLL_LOG_TRACE("DupConfigKeyVal failed %d", result_code);
dmi->CloseCursor(dal_cursor_handle, true);
delete req;
if (nreq) delete nreq;
case UNC_OP_DELETE:
result_code = GetChildConfigKey(ck_main, req);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("GetChildConfigKey failed %d",result_code);
+ UPLL_LOG_TRACE("GetChildConfigKey failed %d", result_code);
dmi->CloseCursor(dal_cursor_handle, true);
delete req;
if (nreq) delete nreq;
delete ck_main;
return UPLL_RC_ERR_GENERIC;
}
- result_code = mgr->BoundaryVlink(ck_main,vlink_ctrlr_dom,bound_vlink);
+ result_code = mgr->BoundaryVlink(ck_main, vlink_ctrlr_dom, bound_vlink);
if (bound_vlink) {
- UPLL_LOG_TRACE("%s is an boundary Link. Not Sent to Controller/n",
+ UPLL_LOG_TRACE("%s is a boundary Link. Not Sent to Controller",
(reinterpret_cast<key_vlink *>(ck_main->get_key()))->vlink_name);
if (ck_main) delete ck_main;
continue;
if (!OVERLAY_KT(keytype)) {
upll_keytype_datatype_t dt_type = (op == UNC_OP_DELETE)?
UPLL_DT_RUNNING : UPLL_DT_CANDIDATE;
- controller_domain_t *tctrlr_dom =
- (ck_main->get_key_type() == UNC_KT_VLINK)?
+ if (ck_main->get_key_type() == UNC_KT_VLINK) {
+ if (ck_main->get_cfg_val()) {
+ GET_USER_DATA_CTRLR_DOMAIN(ck_main->get_cfg_val(), vlink_ctrlr_dom[1]);
+ } else {
+ vlink_ctrlr_dom[1].ctrlr = NULL;
+ vlink_ctrlr_dom[1].domain = NULL;
+ }
+ }
+ controller_domain_t *tctrlr_dom =
+ (ck_main->get_key_type() == UNC_KT_VLINK)?
&vlink_ctrlr_dom[1]:&ctrlr_dom;
result_code = GetRenamedControllerKey(ck_main, dt_type,
- dmi, tctrlr_dom);
+ dmi, tctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(" GetRenamedControllerKey failed err code(%d)",
- result_code);
- if (ck_main)
- delete ck_main;
- break;
+ UPLL_LOG_DEBUG(" GetRenamedControllerKey failed err code(%d)",
+ result_code);
+ if (ck_main)
+ delete ck_main;
+ break;
}
if (ck_main->get_key_type() == UNC_KT_VLINK && (op == UNC_OP_DELETE)) {
/* boundary vlink */
- if((memcmp(ctrlr_dom.ctrlr, tctrlr_dom->ctrlr,kMaxLenCtrlrId)) ||
- (memcmp(ctrlr_dom.domain, tctrlr_dom->domain,kMaxLenDomainId))) {
- UPLL_LOG_TRACE("%s is an boundary Link. Not Sent to Controller/n",
+ VlinkMoMgr *vlink_mgr = reinterpret_cast<VlinkMoMgr *>(
+ const_cast<MoManager *>(GetMoManager(UNC_KT_VLINK)));
+ if (!vlink_mgr) {
+ UPLL_LOG_DEBUG("Invalid mgr");
+ if (ck_main) delete ck_main;
+ DELETE_IF_NOT_NULL(req);
+ dmi->CloseCursor(dal_cursor_handle, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ unc_key_type_t ktype[2] = {UNC_KT_ROOT, UNC_KT_ROOT};
+ for (int vnode_count = 0; vnode_count < 2; vnode_count++)
+ ktype[vnode_count] = vlink_mgr->
+ GetVlinkVnodeIfKeyType(ck_main, vnode_count);
+ if (ktype[0] == UNC_KT_VUNK_IF || ktype[1] == UNC_KT_VUNK_IF ||
+ strncmp(reinterpret_cast<const char *>(ctrlr_dom.ctrlr),
+ reinterpret_cast<const char *>(tctrlr_dom->ctrlr),
+ kMaxLenCtrlrId + 1) ||
+ strncmp(reinterpret_cast<const char *>(ctrlr_dom.domain),
+ reinterpret_cast<const char *>(tctrlr_dom->domain),
+ kMaxLenDomainId + 1)) {
+ UPLL_LOG_TRACE("%s is a boundary Link. Not Sent to Controller/n",
(reinterpret_cast<key_vlink *>(ck_main->get_key()))->vlink_name);
if (ck_main)
delete ck_main;
continue;
}
}
+ } else if (op == UNC_OP_DELETE) {
+ UPLL_LOG_TRACE("Overlay KeyType %d", keytype);
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone,
+ kOpInOutCtrlr | kOpInOutDomain};
+ result_code = ReadConfigDB(ck_main, UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ReadConfigDB from running failed %d", result_code);
+ DELETE_IF_NOT_NULL(req);
+ dmi->CloseCursor(dal_cursor_handle, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (keytype == UNC_KT_VTUNNEL || keytype == UNC_KT_VTUNNEL_IF) {
+ result_code = PopulateDriverDeleteCkv(ck_main, dmi, UPLL_DT_RUNNING);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Couldnt form Driver Val structure %d", result_code);
+ if (ck_main) delete ck_main;
+ DELETE_IF_NOT_NULL(req);
+ dmi->CloseCursor(dal_cursor_handle, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
}
UPLL_LOG_TRACE("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
ctrlr_dom.domain);
result_code = UPLL_RC_SUCCESS;
}
if (result_code != UPLL_RC_SUCCESS) {
+ // If Driver returned error, return the err_ckv received from driver after
+ // getting its UNC key and apdapting the CKV to North Bound API
+ // If update to driver failed, exit the loop.
UPLL_LOG_DEBUG("IpcSend failed %d", result_code);
- *err_ckv = ipc_resp.ckv_data;
+ upll_keytype_datatype_t dt_type = (op == UNC_OP_DELETE)?
+ UPLL_DT_RUNNING : UPLL_DT_CANDIDATE;
+ upll_rc_t local_rc = GetRenamedUncKey(ipc_resp.ckv_data, dt_type, dmi,
+ ctrlr_dom.ctrlr);
+ if (UPLL_RC_SUCCESS != local_rc &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != local_rc) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey failed %d", local_rc);
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ result_code = UPLL_RC_ERR_GENERIC;
+ break;
+ }
+ if (ipc_resp.ckv_data) {
+ upll_rc_t local_rc = AdaptValToVtnService(ipc_resp.ckv_data);
+ if (local_rc != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("AdaptValToVtnService failed result_code %d",
+ local_rc);
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ result_code = UPLL_RC_ERR_GENERIC;
+ break;
+ }
+ *err_ckv = ipc_resp.ckv_data;
+ }
if (ck_main)
delete ck_main;
break;
}
- if (ck_main)
- delete ck_main;
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(ck_main);
}
- dmi->CloseCursor(dal_cursor_handle, true);
+ if (dal_cursor_handle)
+ dmi->CloseCursor(dal_cursor_handle, true);
if (req)
delete req;
if (nreq)
IpcResponse *ipc_resp) {
UPLL_FUNC_TRACE;
upll_rc_t rc = UPLL_RC_SUCCESS;
- if (!ipc_resp)
+ if (!ipc_resp)
return UPLL_RC_ERR_GENERIC;
- memset(ipc_resp,0,sizeof(IpcResponse));
+ memset(ipc_resp, 0, sizeof(IpcResponse));
IpcRequest ipc_req;
memset(&ipc_req, 0, sizeof(ipc_req));
ipc_req.header.clnt_sess_id = session_id;
ipc_req.header.datatype = dt_type;
ipc_req.ckv_data = ckv;
- UPLL_LOG_DEBUG(" session id - %d, configuration id - %d",
+ UPLL_LOG_TRACE(" session id - %d, configuration id - %d",
session_id, config_id);
if (ctrlr_dom == NULL) {
- if (!uui::IpcUtil::SendReqToPhysical(UPPL_IPC_SVC_NAME, UPPL_SVC_READREQ,
+ if (!uui::IpcUtil::SendReqToPhysical(UPPL_IPC_SVC_NAME, UPPL_SVC_READREQ,
&ipc_req, ipc_resp)) {
UPLL_LOG_INFO("Send Request to physical for Key %d failed ", ckv->get_key_type());
-
}
} else {
- if (!IpcUtil::SendReqToDriver((const char *)ctrlr_dom->ctrlr, reinterpret_cast<char *>
- (ctrlr_dom->domain), PFCDRIVER_SERVICE_NAME,
- PFCDRIVER_SVID_LOGICAL, &ipc_req, true, ipc_resp)) {
+ if (!IpcUtil::SendReqToDriver((const char *)ctrlr_dom->ctrlr,
+ reinterpret_cast<char *>(ctrlr_dom->domain),
+ NULL,
+ static_cast<pfc_ipcid_t>(0),
+ &ipc_req, true, ipc_resp)) {
UPLL_LOG_INFO("Request to driver for Key %d for controller %s failed ",
ckv->get_key_type(), reinterpret_cast<char *>(ctrlr_dom->ctrlr));
}
}
- rc = ipc_resp->header.result_code;
+ rc = ipc_resp->header.result_code;
if (rc != UPLL_RC_SUCCESS) {
UPLL_LOG_INFO("Request for Key %d failed with error %d",
ckv->get_key_type(), rc);
if (!OVERLAY_KT(key_type)) {
result_code = GetRenamedUncKey(ck_err, UPLL_DT_CANDIDATE,
dmi, ctrlr_id);
- if (result_code != UPLL_RC_SUCCESS)
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey failed. Result: %d", result_code);
return result_code;
+ }
}
if (ck_err->get_key_type() == UNC_KT_VBR_IF) {
ConfigKeyVal *ck_vlink = NULL;
}
vn_if_type iftype;
result_code = mgr->CheckIfMemberOfVlink(ck_err,
- UPLL_DT_CANDIDATE, ck_vlink,dmi,iftype);
+ UPLL_DT_CANDIDATE, ck_vlink, dmi, iftype);
/* replace ck_err with ck_vlink */
if (result_code == UPLL_RC_SUCCESS) {
- if ((iftype == kVlinkBoundaryNode1) ||
+ if ((iftype == kVlinkBoundaryNode1) ||
(iftype == kVlinkBoundaryNode2)) {
ck_err->ResetWith(ck_vlink);
continue;
} else {
- string s(ck_err->ToStr());
if (ck_vlink) delete ck_vlink;
- UPLL_LOG_DEBUG("%s is an internal vlink",s.c_str());
+ UPLL_LOG_DEBUG("%s is an internal vlink", (ck_err->ToStr()).c_str());
}
} else if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- UPLL_LOG_DEBUG("Returning error %d",result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
if (ck_vlink) delete ck_vlink;
+ result_code = AdaptValToVtnService(ck_err);
return UPLL_RC_ERR_GENERIC;
} else {
- string s(ck_err->ToStr());
if (ck_vlink) delete ck_vlink;
- UPLL_LOG_DEBUG("%s is not part of a vlink",s.c_str());
+ UPLL_LOG_TRACE("%s is not part of a vlink", (ck_err->ToStr()).c_str());
}
}
+ result_code = AdaptValToVtnService(ck_err);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ return result_code;
+ }
}
}
}
for (int i = 0; i < nop; i++) {
result_code= DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i],
- req, nreq, &cfg1_cursor, dmi, MAINTBL);
+ req, nreq, &cfg1_cursor, dmi, NULL, MAINTBL, true);
while (result_code == UPLL_RC_SUCCESS) {
db_result = dmi->GetNextRecord(cfg1_cursor);
result_code = DalToUpllResCode(db_result);
if (key_type == UNC_KT_VLINK) {
uint8_t *ctrlr_id2 = NULL;
GET_USER_DATA_CTRLR(ckey->get_cfg_val(), ctrlr_id2);
- if (ctrlr_id2 && memcmp(ctrlr_id, ctrlr_id2, kMaxLenCtrlrId+1)) {
+ if (ctrlr_id2 && strncmp(reinterpret_cast<const char *>(ctrlr_id),
+ reinterpret_cast<const char *>(ctrlr_id2),
+ kMaxLenCtrlrId+1)) {
string controller2(reinterpret_cast<char *>(ctrlr_id2));
uint32_t cons_result = ctrlr_result[controller2] |
ctrlr_result[controller];
UpdateConfigStatus(ckey, op[i], ctrlr_result[controller],
nreq, dmi);
}
- } else if ((op[i] == UNC_OP_UPDATE) && PORT_MAPPED_KEYTYPE(key_type)) {
+ } else if ((op[i] == UNC_OP_UPDATE) && VN_IF_KEYTYPE(key_type)) {
UpdateConfigStatus(ckey, op[i], driver_result, nreq, dmi);
- /* if portmapping on interface is updated, oper status has to be reset*/
- if (GetStateVal(ckey))
- dt_type = UPLL_DT_STATE;
- } else
- UpdateConfigStatus(ckey, op[i], driver_result, nreq, dmi);
+ } else {
+ UpdateConfigStatus(ckey, op[i], driver_result, nreq, dmi);
+ }
+ /* if portmapping / admin status on kt is updated,
+ * oper status has to be reset*/
+ if (GetStateVal(ckey))
+ dt_type = UPLL_DT_STATE;
+ } else {
+ if (OperStatusSupported(ckey->get_key_type())) {
+ result_code = UpdateParentOperStatus(ckey,dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ delete ckey;
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ return result_code;
+ }
+ }
}
- result_code = UpdateConfigDB(ckey, dt_type, op[i], dmi, MAINTBL);
+ DbSubOp dbop_update = {kOpNotRead, kOpMatchNone, kOpInOutCs |
+ kOpInOutFlag | kOpInOutCtrlr | kOpInOutDomain};
+ result_code = UpdateConfigDB(ckey, dt_type, op[i], dmi, &dbop_update,
+ MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
delete ckey;
if (cfg1_cursor)
dmi->CloseCursor(cfg1_cursor, true);
- UPLL_LOG_DEBUG("Returning error %d",result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
return UPLL_RC_ERR_GENERIC;
}
EnqueCfgNotification(op[i], UPLL_DT_RUNNING, ckey);
if (nreq)
delete nreq;
req = nreq = NULL;
+ if (cfg1_cursor) {
+ dmi->CloseCursor(cfg1_cursor, true);
+ cfg1_cursor = NULL;
+ }
+ // Copying Rename Table to Running
+ UPLL_LOG_TRACE("keytype is %d", key_type);
+ if ((key_type == UNC_KT_VBRIDGE) ||
+ (key_type == UNC_KT_VLINK)) {
+ result_code = TxCopyRenameTableFromCandidateToRunning(key_type,
+ op[i], dmi);
+ UPLL_LOG_DEBUG("TxCopyRenameTableFromCandidateToRunning returned %d",
+ result_code);
+ }
}
ctrlr_result.clear();
- if (cfg1_cursor)
- dmi->CloseCursor(cfg1_cursor, true);
result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
UPLL_RC_SUCCESS: result_code;
return result_code;
ConfigNotification *ck_notify;
unc_keytype_datatype_t unc_type = (unc_keytype_datatype_t)dt_type;
ConfigKeyVal *okey = NULL;
- upll_rc_t result_code = GetChildConfigKey(okey,ctrlr_key);
+ upll_rc_t result_code = GetChildConfigKey(okey, ctrlr_key);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d",result_code);
- return result_code;
- }
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ return result_code;
+ }
ck_notify = new ConfigNotification(op, unc_type, okey);
- ConfigNotifier::BufferNotificationToUpllUser(ck_notify);
+ if (!(ConfigNotifier::BufferNotificationToUpllUser(ck_notify))) {
+ delete ck_notify;
+ }
return UPLL_RC_SUCCESS;
}
-void MoMgrImpl::DumpRenameInfo (ConfigKeyVal *ikey) {
-
+void MoMgrImpl::DumpRenameInfo(ConfigKeyVal *ikey) {
UPLL_FUNC_TRACE;
if (!ikey || !ikey->get_key()) {
- UPLL_LOG_TRACE("Input key is NULL");
- return ;
+ UPLL_LOG_TRACE("Input key is NULL");
+ return;
}
key_rename_vnode_info *rename = reinterpret_cast<key_rename_vnode_info *>(
- ikey->get_key());
+ ikey->get_key());
UPLL_LOG_TRACE("The Rename for the Key type %d", ikey->get_key_type());
if (strlen(reinterpret_cast<char *>(rename->new_unc_vtn_name)))
UPLL_LOG_TRACE("new_unc_vtn_name = %s",
- reinterpret_cast<char*>(rename->new_unc_vtn_name));
+ reinterpret_cast<char*>(rename->new_unc_vtn_name));
if (strlen(reinterpret_cast<char *>(rename->old_unc_vtn_name)))
UPLL_LOG_TRACE("old_unc_vtn_name = %s",
- reinterpret_cast<char*>(rename->old_unc_vtn_name));
+ reinterpret_cast<char*>(rename->old_unc_vtn_name));
if (strlen(reinterpret_cast<char *>(rename->new_unc_vnode_name)))
UPLL_LOG_TRACE("new_unc_vnode_name = %s",
- reinterpret_cast<char*>(rename->new_unc_vnode_name));
+ reinterpret_cast<char*>(rename->new_unc_vnode_name));
if (strlen(reinterpret_cast<char *>(rename->old_unc_vnode_name)))
UPLL_LOG_TRACE("old_unc_vnode_name = %s",
- reinterpret_cast<char*>(rename->old_unc_vnode_name));
+ reinterpret_cast<char*>(rename->old_unc_vnode_name));
if (strlen(reinterpret_cast<char *>(rename->ctrlr_vtn_name)))
UPLL_LOG_TRACE("ctrlr_vtn_name = %s",
- reinterpret_cast<char*>(rename->ctrlr_vtn_name));
+ reinterpret_cast<char*>(rename->ctrlr_vtn_name));
if (strlen(reinterpret_cast<char *>(rename->ctrlr_vnode_name)))
UPLL_LOG_TRACE("ctrlr_vnode_name = %s",
- reinterpret_cast<char*>(rename->ctrlr_vnode_name));
+ reinterpret_cast<char*>(rename->ctrlr_vnode_name));
}
no_rename);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("SwapKeyVal Return Failure = %d ", result_code);
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
result_code = GetChildConfigKey(dup_ikey, ikey);
UPLL_LOG_TRACE(" After SwapKeyVal Ikey %s", (dup_ikey->ToStrAll()).c_str());
UPLL_LOG_TRACE(" After SwapKeyVal Okey %s", (okey->ToStrAll()).c_str());
/* the vnode name should not be same */
- switch (dup_ikey->get_key_type()) {
- case UNC_KT_VBRIDGE:
- case UNC_KT_VROUTER:
- case UNC_KT_VLINK:
- result_code = VnodeChecks(okey, req->datatype, dmi);
- if (UPLL_RC_SUCCESS != result_code) {
- return UPLL_RC_ERR_GENERIC;
- }
- result_code = VnodeChecks(okey, UPLL_DT_CANDIDATE, dmi);
- if (UPLL_RC_SUCCESS != result_code) {
- return UPLL_RC_ERR_GENERIC;
- }
-
- default:
- break;
+ if (!no_rename) {
+ switch (dup_ikey->get_key_type()) {
+ case UNC_KT_VBRIDGE:
+ case UNC_KT_VROUTER:
+ case UNC_KT_VLINK:
+ result_code = VnodeChecks(okey, req->datatype, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(dup_ikey);
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = VnodeChecks(okey, UPLL_DT_CANDIDATE, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(dup_ikey);
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ default:
+ break;
+ }
}
- /* Set The controller ID into the dup_ikey & okey */
+ // Set The controller ID into the dup_ikey & okey
SET_USER_DATA_CTRLR(dup_ikey, ctrlr_id);
SET_USER_DATA_CTRLR(okey, ctrlr_id);
// Checks if the PFC name is already renamed
result_code = GetRenamedUncKey(dup_ikey, req->datatype, dmi,
reinterpret_cast<uint8_t *>(const_cast<char *>(ctrlr_id)));
if (result_code == UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("Given PFC already Renamed %s", (dup_ikey->ToStrAll()).c_str());
+ UPLL_LOG_TRACE("Given PFC Exists in Import DB %s", (dup_ikey->ToStrAll()).c_str());
result_code = UpdateConfigDB(dup_ikey, req->datatype, UNC_OP_READ,
dmi, MAINTBL);
/* Entry in rename table but no corresponding entry in main table */
if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code) {
UPLL_LOG_ERROR("UpdateConfigDB Return Failure = %d ", result_code);
+ DELETE_IF_NOT_NULL(dup_ikey);
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
renamed = true;
+ } else if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey failed. Result : %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(dup_ikey);
+ return UPLL_RC_ERR_GENERIC;
}
- /* ensure no other vtn has the renamed name in the main table */
+ /* ensure no other vnode has the renamed name in the main table */
result_code = UpdateConfigDB(okey, req->datatype,
UNC_OP_READ, dmi, MAINTBL);
- if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
- UPLL_LOG_ERROR("UpdateConfigDB Returns Failure = %d ", result_code);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("UpdateConfigDB Failed %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(dup_ikey);
+ return result_code;
}
-
- /* Ensure the renamed name does not corrspond to an existing UNC name */
- result_code = UpdateConfigDB(okey, UPLL_DT_CANDIDATE, UNC_OP_READ,
- dmi, MAINTBL);
if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
- UPLL_LOG_DEBUG("UpdateConfigDB Return Failure = %d ", result_code);
+ UPLL_LOG_DEBUG("Record Exists in DT IMPORT = %d ", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(dup_ikey);
+ return result_code;
+ }
+ /* Ensure the renamed name does not correspond to an existing UNC name */
+ if (!no_rename) {
+ result_code = UpdateConfigDB(okey, UPLL_DT_CANDIDATE, UNC_OP_READ,
+ dmi, MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("UpdateConfigDB Failed %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(dup_ikey);
+ return result_code;
+ }
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code &&
+ UNC_KT_VTN != okey->get_key_type()) {
+ UPLL_LOG_DEBUG("Record Exists in DT CANDIDATE %d ", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(dup_ikey);
+ return result_code;
+ }
}
if (renamed) {
UPLL_LOG_TRACE("Before Read from Rename Table %s", (dup_ikey->ToStrAll()).c_str());
dmi, RENAMETBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_TRACE("ERROR :: %d:%s:%s", __LINE__, __FILE__, __func__);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(dup_ikey);
return result_code;
}
}
- /* Get The PFC, Old UNC, and New UNC name and maintains in rename_info
+ /* Get The PFC, Old UNC, and New UNC name and maintains in rename_info
* dup_ikey -> Old Unc Name (or) Controller Name
* okey -> New Name
* rename_info -> Empty
* */
+ SET_USER_DATA_FLAGS(okey, no_rename);
result_code = GetRenameInfo(dup_ikey, okey, rename_info, dmi,
ctrlr_id, renamed);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetRenameInfo is Failed %d", result_code);
+ DELETE_IF_NOT_NULL(dup_ikey);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
UPLL_LOG_TRACE("The Control Id is %s", ctrlr_id);
/* Update the New name into the tabels */
UPLL_LOG_TRACE("Rename Info detail");
- DumpRenameInfo (rename_info);
+ DumpRenameInfo(rename_info);
result_code = UpdateTables(req, rename_info, renamed, dmi, no_rename);
UPLL_LOG_TRACE("UpdateTable Result is %d", result_code);
- if (okey)
- delete okey;
- if (rename_info)
- delete rename_info;
- if (dup_ikey)
- delete dup_ikey;
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(dup_ikey);
+ DELETE_IF_NOT_NULL(rename_info);
return result_code;
}
UPLL_FUNC_TRACE;
DalResultCode dal_result = uud::kDalRcSuccess;
UPLL_LOG_TRACE("MergeImportToCandidate ");
- for (int tbl = MAINTBL ; tbl < ntable ; tbl++) {
+ for (int tbl = MAINTBL; tbl < ntable; tbl++) {
uudst::kDalTableIndex tbl_index;
tbl_index = GetTable((MoMgrTables)tbl, UPLL_DT_IMPORT);
- if (tbl_index < uudst::kDalNumTables) {
-
+ /* skipping VTN Main Table */
+ if (tbl_index < uudst::kDalNumTables && tbl_index != 0) {
UPLL_LOG_TRACE("Merging the %d Table ", tbl);
if (table[tbl]->get_key_type() != keytype)
return UPLL_RC_ERR_GENERIC;
DalBindInfo *dal_bind_info = new DalBindInfo(tbl_index);
- dal_result = dmi->CopyModifiedRecords(UPLL_DT_CANDIDATE,
+ dal_result = dmi->CopyModifiedInsertRecords(UPLL_DT_CANDIDATE,
UPLL_DT_IMPORT, tbl_index, dal_bind_info);
UPLL_LOG_TRACE("%d Table is completed ", tbl);
if (dal_result != uud::kDalRcSuccess) {
// UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
// cout<<" ImportClear ";
- for (int tbl = MAINTBL ; tbl < ntable ; tbl++) {
+ for (int tbl = MAINTBL; tbl < ntable; tbl++) {
uudst::kDalTableIndex tbl_index;
tbl_index = GetTable((MoMgrTables)tbl, UPLL_DT_IMPORT);
if ((tbl_index < uudst::kDalNumTables)) {
ConfigKeyVal *ckv_audit,
uuc::UpdateCtrlrPhase phase, MoMgrTables tbl,
ConfigKeyVal *&okey,
- DalDmlIntf *dmi) {
+ DalDmlIntf *dmi,
+ bool &invalid_attr) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *ckv_dup = NULL;
- DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutCtrlr | kOpInOutDomain};
+ okey = NULL;
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutCtrlr | kOpInOutDomain|
+ kOpInOutFlag | kOpInOutCs};
switch (phase) {
case uuc::kUpllUcpDelete:
- UPLL_LOG_DEBUG("Deleted record is %s\n ",ckv_running->ToStrAll().c_str());
+ UPLL_LOG_TRACE("Deleted record is %s ", ckv_running->ToStrAll().c_str());
result_code = GetChildConfigKey(okey, ckv_running);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetChildConfigKey failed. err_code & phase %d %d\n",
+ UPLL_LOG_DEBUG("GetChildConfigKey failed. err_code & phase %d %d",
result_code, phase);
return result_code;
}
break;
case uuc::kUpllUcpCreate:
if (tbl == CTRLRTBL) {
- UPLL_LOG_DEBUG("Created record fot ctrlr_tbl is %s\n ",ckv_running->ToStrAll().c_str());
+ UPLL_LOG_TRACE("Created record fot ctrlr_tbl is %s ", ckv_running->ToStrAll().c_str());
+ dbop.inoutop = kOpInOutCtrlr | kOpInOutDomain;
result_code = GetChildConfigKey(okey, ckv_running);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetChildConfigKey failed. err_code & phase %d %d\n",
+ UPLL_LOG_DEBUG("GetChildConfigKey failed. err_code & phase %d %d",
result_code, phase);
return result_code;
}
result_code = ReadConfigDB(okey, UPLL_DT_RUNNING,
UNC_OP_READ, dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ReadConfigDB failed. err_code & phase %d %d\n",
+ UPLL_LOG_DEBUG("ReadConfigDB failed. err_code & phase %d %d",
result_code, phase);
return result_code;
}
} else {
- UPLL_LOG_DEBUG("Created record is %s\n ",ckv_running->ToStrAll().c_str());
+ UPLL_LOG_TRACE("Created record is %s ", ckv_running->ToStrAll().c_str());
result_code = DupConfigKeyVal(okey, ckv_running, tbl);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("DupConfigKeyVal failed. err_code & phase %d %d\n",
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed. err_code & phase %d %d",
result_code, phase);
return result_code;
}
break;
case uuc::kUpllUcpUpdate:
if (tbl == CTRLRTBL) {
- UPLL_LOG_DEBUG("UpdateRecord record for Ctrlr_tbl is %s\n ",ckv_running->ToStrAll().c_str());
- UPLL_LOG_DEBUG("UpdateRecord record for Ctrlr_tbl is %s\n ",ckv_audit->ToStrAll().c_str());
+ UPLL_LOG_TRACE("UpdateRecord record for Ctrlr_tbl is %s ", ckv_running->ToStrAll().c_str());
+ UPLL_LOG_TRACE("UpdateRecord record for Ctrlr_tbl is %s ", ckv_audit->ToStrAll().c_str());
result_code = GetChildConfigKey(okey, ckv_running);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetChildConfigKey for running record failed. \
- err_code & phase %d %d\n", result_code, phase);
+ UPLL_LOG_DEBUG("GetChildConfigKey for running record failed. "
+ "err_code & phase %d %d", result_code, phase);
return result_code;
}
result_code = ReadConfigDB(okey, UPLL_DT_RUNNING,
UNC_OP_READ, dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ReadConfigDB from running failed. \
- err_code & phase %d %d\n", result_code, phase);
+ UPLL_LOG_DEBUG("ReadConfigDB from running failed. "
+ "err_code & phase %d %d", result_code, phase);
return result_code;
}
result_code = GetChildConfigKey(ckv_dup, ckv_audit);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetChildConfigKey for audit record failed. \
- err_code & phase %d %d\n", result_code, phase);
+ UPLL_LOG_DEBUG("GetChildConfigKey for audit record failed. "
+ "err_code & phase %d %d", result_code, phase);
+ if (ckv_dup)
+ delete ckv_dup;
return result_code;
}
result_code = ReadConfigDB(ckv_dup, UPLL_DT_AUDIT,
UNC_OP_READ, dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ReadConfigDB from audit failed. \
- err_code & phase %d %d\n", result_code, phase);
+ UPLL_LOG_DEBUG("ReadConfigDB from audit failed. "
+ "err_code & phase %d %d", result_code, phase);
+ delete ckv_dup;
return result_code;
}
} else {
- UPLL_LOG_DEBUG("UpdateRecord record is %s\n ",ckv_running->ToStrAll().c_str());
- UPLL_LOG_DEBUG("UpdateRecord record is %s\n ",ckv_audit->ToStrAll().c_str());
+ UPLL_LOG_TRACE("UpdateRecord record is %s ", ckv_running->ToStrAll().c_str());
+ UPLL_LOG_TRACE("UpdateRecord record is %s ", ckv_audit->ToStrAll().c_str());
result_code = DupConfigKeyVal(okey, ckv_running, tbl);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("DupConfigKeyVal failed for running record. \
- err_code & phase %d %d\n", result_code, phase);
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed for running record. "
+ "err_code & phase %d %d", result_code, phase);
+ delete ckv_dup;
return result_code;
}
result_code = DupConfigKeyVal(ckv_dup, ckv_audit, tbl);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("DupConfigKeyVal failed for audit record. \
- err_code & phase %d %d\n", result_code, phase);
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed for audit record. "
+ "err_code & phase %d %d", result_code, phase);
+ if (ckv_dup)
+ delete ckv_dup;
return result_code;
}
}
if (GetVal(okey) != NULL &&
GetVal(ckv_dup) != NULL) {
void *val1 = GetVal(okey);
- FilterAttributes(val1, GetVal(ckv_dup), true,
+ invalid_attr = FilterAttributes(val1, GetVal(ckv_dup), false,
UNC_OP_UPDATE);
}
break;
default:
- UPLL_LOG_DEBUG("Invalid operation %d\n", phase);
+ UPLL_LOG_DEBUG("Invalid operation %d", phase);
return UPLL_RC_ERR_NO_SUCH_OPERATION;
break;
}
+ delete ckv_dup;
return result_code;
}
+
upll_rc_t MoMgrImpl::AuditUpdateController(unc_key_type_t keytype,
const char *ctrlr_id,
uint32_t session_id,
upll_rc_t result_code = UPLL_RC_SUCCESS;
DalResultCode db_result = uud::kDalRcSuccess;
MoMgrTables tbl = MAINTBL;
- controller_domain_t ctrlr_dom,vlink_ctrlr_dom[2];
+ controller_domain_t ctrlr_dom, vlink_ctrlr_dom[2];
+ vlink_ctrlr_dom[0].ctrlr = NULL;
+ vlink_ctrlr_dom[0].domain = NULL;
+ vlink_ctrlr_dom[1].ctrlr = NULL;
+ vlink_ctrlr_dom[1].domain = NULL;
ctrlr_dom.ctrlr = NULL;
ctrlr_dom.domain = NULL;
ConfigKeyVal *ckv_running = NULL;
ConfigKeyVal *ckv_audit = NULL;
ConfigKeyVal *ckv_drvr = NULL;
+ ConfigKeyVal *resp = NULL;
DalCursor *cursor = NULL;
- uint8_t *ctrlr = reinterpret_cast<uint8_t *>(const_cast<char *>(ctrlr_id));
+ bool invalid_attr = false;
+ uint8_t *in_ctrlr = reinterpret_cast<uint8_t *>(const_cast<char *>(ctrlr_id));
/* decides whether to retrieve from controller table or main table */
GET_TABLE_TYPE(keytype, tbl);
unc_keytype_operation_t op = (phase == uuc::kUpllUcpCreate)?UNC_OP_CREATE:
- ((phase == uuc::kUpllUcpUpdate)?UNC_OP_UPDATE:
- ((phase == uuc::kUpllUcpDelete)?UNC_OP_DELETE:UNC_OP_INVALID));
+ ((phase == uuc::kUpllUcpUpdate)?UNC_OP_UPDATE:
+ ((phase == uuc::kUpllUcpDelete)?UNC_OP_DELETE:UNC_OP_INVALID));
if (phase == uuc::kUpllUcpDelete2)
- return result_code;
+ return result_code;
/* retreives the delta of running and audit configuration */
- UPLL_LOG_DEBUG("Operation is %d\n", op);
+ UPLL_LOG_TRACE("Operation is %d", op);
+ if ((op == UNC_OP_UPDATE) && (keytype == UNC_KT_VTN))
+ return UPLL_RC_SUCCESS;
result_code = DiffConfigDB(UPLL_DT_RUNNING, UPLL_DT_AUDIT, op,
- ckv_running, ckv_audit,
- &cursor, dmi, ctrlr, tbl);
+ ckv_running, ckv_audit,
+ &cursor, dmi, in_ctrlr, tbl, true);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("DiffConfigDB failed - %d", result_code);
return result_code;
while (uud::kDalRcSuccess == (db_result = dmi->GetNextRecord(cursor))) {
/* ignore records of another controller for create and update operation */
if (phase != uuc::kUpllUcpDelete) {
- uint8_t *ctrlr = NULL;
- GET_USER_DATA_CTRLR(ckv_running,ctrlr);
- if (ctrlr && strncmp(reinterpret_cast<const char *>(ctrlr),
- reinterpret_cast<const char *>(ctrlr_id),
- sizeof(strlen(reinterpret_cast<const char *>(ctrlr_id)))))
+ uint8_t *db_ctrlr = NULL;
+ GET_USER_DATA_CTRLR(ckv_running, db_ctrlr);
+ UPLL_LOG_TRACE("db ctrl_id and audit ctlr_id are %s %s", db_ctrlr, ctrlr_id);
+ if (db_ctrlr && strncmp(reinterpret_cast<const char *>(db_ctrlr),
+ reinterpret_cast<const char *>(ctrlr_id),
+ strlen(reinterpret_cast<const char *>(ctrlr_id)) + 1))
continue;
}
- UPLL_LOG_DEBUG("Diff Record: Keytype: Operation: is %d\n %d\n %s\n",
- keytype, op, ckv_running->ToStrAll().c_str());
+ UPLL_LOG_TRACE("Diff Running Record for Keytype: Operation: is %d %d\n %s",
+ keytype, op, ckv_running->ToStrAll().c_str());
+ if (op == UNC_OP_UPDATE)
+ UPLL_LOG_TRACE("Diff Audit Record for Keytype: Operation: is %d %d\n %s",
+ keytype, op, ckv_audit->ToStrAll().c_str());
result_code = GetDiffRecord(ckv_running, ckv_audit, phase, tbl,
- ckv_drvr, dmi);
+ ckv_drvr, dmi, invalid_attr);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("GetDiffRecord failed err code is %d\n", result_code);
- return result_code;
+ UPLL_LOG_INFO("GetDiffRecord failed err code is %d", result_code);
+ DELETE_IF_NOT_NULL(ckv_running);
+ DELETE_IF_NOT_NULL(ckv_audit);
+ DELETE_IF_NOT_NULL(ckv_drvr);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ if (invalid_attr) {
+ DELETE_IF_NOT_NULL(ckv_drvr);
+ continue;
+ }
+ if (OVERLAY_KT(keytype) && (op == UNC_OP_DELETE)) {
+ UPLL_LOG_TRACE("Overlay KeyType %d", keytype);
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone,
+ kOpInOutCtrlr | kOpInOutDomain};
+ result_code = ReadConfigDB(ckv_drvr, UPLL_DT_AUDIT,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ReadConfigDB from AuditdB failed %d", result_code);
+ DELETE_IF_NOT_NULL(ckv_running);
+ DELETE_IF_NOT_NULL(ckv_audit);
+ DELETE_IF_NOT_NULL(ckv_drvr);
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (keytype == UNC_KT_VTUNNEL || keytype == UNC_KT_VTUNNEL_IF) {
+ result_code = PopulateDriverDeleteCkv(ckv_drvr, dmi, UPLL_DT_AUDIT);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Couldnt form Driver Val structure %d", result_code);
+ DELETE_IF_NOT_NULL(ckv_running);
+ DELETE_IF_NOT_NULL(ckv_audit);
+ DELETE_IF_NOT_NULL(ckv_drvr);
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
}
/* Boundary VLink is not sent to Controller*/
if (ckv_drvr->get_key_type() == UNC_KT_VLINK && (op != UNC_OP_DELETE)) {
bool bound_vlink = false;
VlinkMoMgr *mgr = reinterpret_cast<VlinkMoMgr *>(
- const_cast<MoManager *>(GetMoManager(UNC_KT_VLINK)));
+ const_cast<MoManager *>(GetMoManager(UNC_KT_VLINK)));
if (!mgr) {
UPLL_LOG_DEBUG("Invalid mgr");
+ DELETE_IF_NOT_NULL(ckv_running);
+ DELETE_IF_NOT_NULL(ckv_audit);
+ DELETE_IF_NOT_NULL(ckv_drvr);
+ dmi->CloseCursor(cursor, true);
return UPLL_RC_ERR_GENERIC;
}
result_code = mgr->BoundaryVlink(ckv_drvr, vlink_ctrlr_dom, bound_vlink);
if (bound_vlink) {
- UPLL_LOG_TRACE("%s is an boundary Link. Not Sent to Controller/n",
+ UPLL_LOG_TRACE("%s is a boundary Link. Not Sent to Controller/n",
(reinterpret_cast<key_vlink *>(ckv_drvr->get_key()))->vlink_name);
if (ckv_drvr) delete ckv_drvr;
ckv_drvr = NULL;
}
}
GET_USER_DATA_CTRLR_DOMAIN(ckv_drvr, ctrlr_dom);
+ UPLL_LOG_DEBUG("Outside if %d", keytype);
if (!OVERLAY_KT(keytype)) {
+ UPLL_LOG_DEBUG("Inside if %d", keytype);
upll_keytype_datatype_t dt_type = (op == UNC_OP_DELETE)?
UPLL_DT_AUDIT : UPLL_DT_RUNNING;
- controller_domain_t *tctrlr_dom =
- (ckv_drvr->get_key_type() == UNC_KT_VLINK)?
- &vlink_ctrlr_dom[1]:&ctrlr_dom;
+ if (ckv_drvr->get_key_type() == UNC_KT_VLINK) {
+ if (ckv_drvr->get_cfg_val()) {
+ GET_USER_DATA_CTRLR_DOMAIN(ckv_drvr->get_cfg_val(), vlink_ctrlr_dom[1]);
+ } else {
+ vlink_ctrlr_dom[1].ctrlr = NULL;
+ vlink_ctrlr_dom[1].domain = NULL;
+ }
+ }
+ controller_domain_t *tctrlr_dom =
+ (ckv_drvr->get_key_type() == UNC_KT_VLINK)?
+ &vlink_ctrlr_dom[1]:&ctrlr_dom;
+ if (UNC_KT_POLICING_PROFILE == ckv_drvr->get_key_type() ||
+ UNC_KT_POLICING_PROFILE_ENTRY == ckv_drvr->get_key_type() ||
+ UNC_KT_FLOWLIST == ckv_drvr->get_key_type() ||
+ UNC_KT_FLOWLIST_ENTRY == ckv_drvr->get_key_type() ||
+ UNC_KT_VTN_POLICINGMAP == ckv_drvr->get_key_type() ||
+ UNC_KT_VTN_FLOWFILTER == ckv_drvr->get_key_type() ||
+ UNC_KT_VTN_FLOWFILTER_ENTRY == ckv_drvr->get_key_type()) {
+ dt_type = UPLL_DT_RUNNING;
+ }
+ result_code = DupConfigKeyVal(resp, ckv_drvr, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG(" DupConfigKeyVal failed err code(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv_running);
+ DELETE_IF_NOT_NULL(ckv_audit);
+ DELETE_IF_NOT_NULL(ckv_drvr);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
result_code = GetRenamedControllerKey(ckv_drvr, dt_type,
- dmi, tctrlr_dom);
- if (result_code != UPLL_RC_SUCCESS && result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ dmi, tctrlr_dom);
+ if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG(" GetRenamedControllerKey failed err code(%d)",
- result_code);
- return result_code;
+ result_code);
+ DELETE_IF_NOT_NULL(ckv_running);
+ DELETE_IF_NOT_NULL(ckv_audit);
+ DELETE_IF_NOT_NULL(ckv_drvr);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
}
if (ckv_drvr->get_key_type() == UNC_KT_VLINK && (op == UNC_OP_DELETE)) {
/* boundary vlink */
- if((memcmp(ctrlr_dom.ctrlr, tctrlr_dom->ctrlr,kMaxLenCtrlrId)) ||
- (memcmp(ctrlr_dom.domain, tctrlr_dom->domain,kMaxLenDomainId))) {
- UPLL_LOG_TRACE("%s is an boundary Link. Not Sent to Controller/n",
- (reinterpret_cast<key_vlink *>(ckv_drvr->get_key()))->vlink_name);
+ VlinkMoMgr *vlink_mgr = reinterpret_cast<VlinkMoMgr *>(
+ const_cast<MoManager *>(GetMoManager(UNC_KT_VLINK)));
+ if (!vlink_mgr) {
+ UPLL_LOG_DEBUG("Invalid mgr");
+ DELETE_IF_NOT_NULL(ckv_running);
+ DELETE_IF_NOT_NULL(ckv_audit);
+ DELETE_IF_NOT_NULL(ckv_drvr);
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ unc_key_type_t ktype[2] = {UNC_KT_ROOT, UNC_KT_ROOT};
+ for (int vnode_count = 0; vnode_count < 2; vnode_count++) {
+ ktype[vnode_count] = vlink_mgr->
+ GetVlinkVnodeIfKeyType(ckv_drvr, vnode_count);
+ }
+ if (ktype[0] != UNC_KT_VUNK_IF && ktype[1] != UNC_KT_VUNK_IF) {
+ if (!ctrlr_dom.ctrlr || !tctrlr_dom->ctrlr || !ctrlr_dom.domain
+ || !tctrlr_dom->domain) {
+ UPLL_LOG_INFO("Ctrlr id or domain id is Null in vlink delete");
+ if (ckv_drvr)
+ delete ckv_drvr;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ if (ktype[0] == UNC_KT_VUNK_IF || ktype[1] == UNC_KT_VUNK_IF ||
+ strncmp(reinterpret_cast<const char *>(ctrlr_dom.ctrlr),
+ reinterpret_cast<const char *>(tctrlr_dom->ctrlr),
+ kMaxLenCtrlrId + 1) ||
+ strncmp(reinterpret_cast<const char *>(ctrlr_dom.domain),
+ reinterpret_cast<const char *>(tctrlr_dom->domain),
+ kMaxLenDomainId + 1)) {
+ UPLL_LOG_TRACE("%s is a boundary Link. Not Sent to Controller/n",
+ (reinterpret_cast<key_vlink *>(ckv_drvr->get_key()))->vlink_name);
+ DELETE_IF_NOT_NULL(resp);
if (ckv_drvr)
delete ckv_drvr;
ckv_drvr = NULL;
continue;
}
-
}
}
- if ((ctrlr_dom.ctrlr == NULL) || (NULL == ctrlr_dom.domain)) {
- UPLL_LOG_INFO("controller id or domain is NULL");
+
+ if (ctrlr_dom.ctrlr != NULL) {
+ bool domain = false;
+ KEYTYPE_WITHOUT_DOMAIN(keytype, domain);
+ if (!domain) {
+ if (NULL == ctrlr_dom.domain) {
+ UPLL_LOG_INFO(" domain is NULL");
+ DELETE_IF_NOT_NULL(ckv_running);
+ DELETE_IF_NOT_NULL(ckv_audit);
+ DELETE_IF_NOT_NULL(resp);
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ } else {
+ UPLL_LOG_DEBUG("Controller Id is NULL");
+ DELETE_IF_NOT_NULL(ckv_running);
+ DELETE_IF_NOT_NULL(ckv_audit);
+ DELETE_IF_NOT_NULL(resp);
+ dmi->CloseCursor(cursor, true);
return UPLL_RC_ERR_GENERIC;
}
- UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
- ctrlr_dom.domain);
+
+ UPLL_LOG_TRACE("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
IpcResponse ipc_response;
memset(&ipc_response, 0, sizeof(IpcResponse));
IpcRequest ipc_req;
ipc_req.header.datatype = UPLL_DT_CANDIDATE;
ipc_req.ckv_data = ckv_drvr;
if (!IpcUtil::SendReqToDriver((const char *)ctrlr_dom.ctrlr, reinterpret_cast<char *>
- (ctrlr_dom.domain), PFCDRIVER_SERVICE_NAME,
- PFCDRIVER_SVID_LOGICAL, &ipc_req, true, &ipc_response)) {
+ (ctrlr_dom.domain), PFCDRIVER_SERVICE_NAME,
+ PFCDRIVER_SVID_LOGICAL, &ipc_req, true, &ipc_response)) {
UPLL_LOG_INFO("Request to driver for Key %d for controller %s failed ",
- ckv_drvr->get_key_type(), reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ ckv_drvr->get_key_type(), reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ DELETE_IF_NOT_NULL(resp);
+ DELETE_IF_NOT_NULL(ckv_running);
+ DELETE_IF_NOT_NULL(ckv_audit);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ dmi->CloseCursor(cursor, true);
return UPLL_RC_ERR_GENERIC;
}
- if (ipc_response.header.result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("driver return failure err_code is %d\n", ipc_response.header.result_code);
- ConfigKeyVal *resp = NULL;
- result_code = DupConfigKeyVal(resp, ipc_response.ckv_data);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("DupConfigKeyVal failed for ipc response ckv err_code %d\n",
- result_code);
- delete ipc_response.ckv_data;
- return result_code;
- }
- result_code = UpdateAuditConfigStatus(UNC_CS_INVALID, phase, resp);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("Update Audit config status failed %d",
- result_code);
- return result_code;
- }
- result_code = UpdateConfigDB(resp, UPLL_DT_RUNNING, UNC_OP_UPDATE,
- dmi, tbl);
+ if ((ipc_response.header.result_code != UPLL_RC_SUCCESS) && (phase != uuc::kUpllUcpDelete)) {
+ UPLL_LOG_DEBUG("driver return failure err_code is %d", ipc_response.header.result_code);
+ ConfigKeyVal *ctrlr_key = NULL;
+ if (CTRLRTBL == (GET_TABLE_TYPE(keytype, tbl))) {
+ result_code = DupConfigKeyVal(ctrlr_key, ckv_running, CTRLRTBL);
+ } else {
+ result_code = DupConfigKeyVal(ctrlr_key, ckv_running, MAINTBL);
+ }
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("DupConfigKeyVal failed");
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ DELETE_IF_NOT_NULL(resp);
+ DELETE_IF_NOT_NULL(ckv_running);
+ DELETE_IF_NOT_NULL(ckv_audit);
+ DELETE_IF_NOT_NULL(ckv_drvr);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ if (UNC_KT_VTN == keytype) {
+ result_code = UpdateCtrlrConfigStatus(UNC_CS_INVALID,
+ phase, ctrlr_key);
+ } else {
+ result_code = UpdateAuditConfigStatus(UNC_CS_INVALID,
+ phase, ctrlr_key);
+ }
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("UpdateAuditConfigStatus failed");
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ DELETE_IF_NOT_NULL(resp);
+ DELETE_IF_NOT_NULL(ckv_running);
+ DELETE_IF_NOT_NULL(ckv_audit);
+ DELETE_IF_NOT_NULL(ckv_drvr);
+ dmi->CloseCursor(cursor, true);
+ DELETE_IF_NOT_NULL(ctrlr_key);
+ return result_code;
+ }
+ result_code = UpdateConfigDB(ctrlr_key, UPLL_DT_RUNNING, UNC_OP_UPDATE,
+ dmi, tbl);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed for ipc response ckv err_code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ DELETE_IF_NOT_NULL(resp);
+ DELETE_IF_NOT_NULL(ckv_running);
+ DELETE_IF_NOT_NULL(ckv_audit);
+ DELETE_IF_NOT_NULL(ckv_drvr);
+ dmi->CloseCursor(cursor, true);
+ DELETE_IF_NOT_NULL(ctrlr_key);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(ctrlr_key);
+ if (CTRLRTBL == (GET_TABLE_TYPE(keytype, tbl))) {
+ result_code = SetConsolidatedStatus(resp, dmi);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("UpdateConfigDB failed for ipc response ckv err_code %d\n",
- result_code);
+ UPLL_LOG_DEBUG("SetConsolidatedStatus failed for ipc response ckv err_code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ DELETE_IF_NOT_NULL(ckv_running);
+ DELETE_IF_NOT_NULL(ckv_audit);
+ DELETE_IF_NOT_NULL(ckv_drvr);
+ dmi->CloseCursor(cursor, true);
+ DELETE_IF_NOT_NULL(resp);
return result_code;
- }
- if (keytype == UNC_KT_VTN) {
- result_code = SetConsolidatedStatus(resp, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("SetConsolidatedStatus failed for ipc response ckv err_code %d\n",
- result_code);
- return result_code;
- }
}
- if (resp)
- delete resp;
- }
- if (ckv_drvr) {
- delete ckv_drvr;
- ckv_drvr = NULL;
+ }
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ DELETE_IF_NOT_NULL(ckv_running);
+ DELETE_IF_NOT_NULL(ckv_audit);
+ DELETE_IF_NOT_NULL(ckv_drvr);
+ dmi->CloseCursor(cursor, true);
+ DELETE_IF_NOT_NULL(resp);
+ return ipc_response.header.result_code;
}
+ DELETE_IF_NOT_NULL(ckv_drvr);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
*ctrlr_affected = true;
+ DELETE_IF_NOT_NULL(resp);
}
- dmi->CloseCursor(cursor, true);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
if (uud::kDalRcSuccess != db_result) {
- UPLL_LOG_DEBUG("GetNextRecord from database failed - %d", db_result);
- result_code = DalToUpllResCode(db_result);
+ UPLL_LOG_DEBUG("GetNextRecord from database failed - %d", db_result);
+ result_code = DalToUpllResCode(db_result);
}
if (ckv_running)
- delete ckv_running;
+ delete ckv_running;
if (ckv_audit)
- delete ckv_audit;
+ delete ckv_audit;
result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)
- ? UPLL_RC_SUCCESS : result_code;
+ ? UPLL_RC_SUCCESS : result_code;
return result_code;
}
upll_rc_t MoMgrImpl::AuditVoteCtrlrStatus(unc_key_type_t keytype,
- CtrlrVoteStatus *vote_status,
- DalDmlIntf *dmi) {
+ CtrlrVoteStatus *vote_status,
+ DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
if ((vote_status == NULL) || (dmi == NULL)) {
UPLL_LOG_INFO("vote_status or dmi is null");
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *ckv_dup = NULL;
+ ConfigKeyVal *ckv_au_dup = NULL;
uuc::UpdateCtrlrPhase operation = uuc::kUpllUcpUpdate;
MoMgrTables tbl = MAINTBL;
uint32_t ctrlr_result = vote_status->upll_ctrlr_result;
- uint8_t *ctrlr_id = reinterpret_cast<uint8_t *>(&(vote_status->ctrlr_id));
- UPLL_LOG_INFO("controller id & vote result is %s %d\n", ctrlr_id,
- ctrlr_result);
+ uint8_t *ctrlr_id =
+ reinterpret_cast<uint8_t *>((char *)(vote_status->ctrlr_id.c_str()));
+ UPLL_LOG_INFO("controller id & vote result is %s %d", ctrlr_id,
+ ctrlr_result);
switch (ctrlr_result) {
case UPLL_RC_SUCCESS: /* No Operation */
break;
rename the key with UNC name */
ConfigKeyVal *ckv_drv_rslt = NULL;
for (ckv_drv_rslt = vote_status->err_ckv;
- ckv_drv_rslt != NULL; ckv_drv_rslt = ckv_drv_rslt->get_next_cfg_key_val()) {
+ ckv_drv_rslt != NULL; ckv_drv_rslt = ckv_drv_rslt->get_next_cfg_key_val()) {
if (ckv_drv_rslt->get_key_type() != keytype)
continue;
+ UPLL_LOG_INFO("err ConfigKeyVal are %s", (vote_status->err_ckv)->ToStrAll().c_str());
/* Get the Unc key */
- result_code = GetRenamedUncKey(ckv_drv_rslt, UPLL_DT_RUNNING,
- dmi, ctrlr_id);
- if (UPLL_RC_SUCCESS != result_code &&
- UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
- UPLL_LOG_DEBUG("GetRenamedUncKey failed - %d", result_code);
- return result_code;
+ if (!OVERLAY_KT(keytype)) {
+ result_code = GetRenamedUncKey(ckv_drv_rslt, UPLL_DT_RUNNING,
+ dmi, ctrlr_id);
+ if (UPLL_RC_SUCCESS != result_code &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey failed - %d", result_code);
+ return result_code;
+ }
}
- result_code = DupConfigKeyVal(ckv_dup, ckv_drv_rslt, MAINTBL);
+ result_code = GetChildConfigKey(ckv_dup, ckv_drv_rslt);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("Duplicate ConfigKeyVal failed - %d", result_code);
+ DELETE_IF_NOT_NULL(ckv_dup);
return result_code;
}
/* Record exist check from running - if not found, it is a delete*/
- DbSubOp dbop = {kOpReadExist, kOpMatchCtrlr | kOpMatchDomain , kOpInOutNone};
- result_code = UpdateConfigDB(ckv_dup, UPLL_DT_RUNNING,
- UNC_OP_READ, dmi, &dbop, MAINTBL);
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutNone};
+ result_code = ReadConfigDB(ckv_dup, UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
if (UPLL_RC_SUCCESS == result_code) { /* exists in Running Database */
- /* Record exist check from audit - if exists then update else create*/
- UPLL_LOG_DEBUG("Record exist in running tbl result_code %d\n",
- result_code);
- result_code = UpdateConfigDB(ckv_dup, UPLL_DT_AUDIT,
- UNC_OP_READ, dmi, &dbop, MAINTBL);
+ /* Record exist check from audit - if exists then update else create*/
+ UPLL_LOG_TRACE("Record exist in running tbl result_code %d",
+ result_code);
+ result_code = GetChildConfigKey(ckv_au_dup, ckv_drv_rslt);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKeyVal failed for ckv_au_dup - %d", result_code);
+ delete ckv_dup; //check with Vinoth
+ DELETE_IF_NOT_NULL(ckv_au_dup);
+ return result_code;
+ }
+ result_code = ReadConfigDB(ckv_au_dup, UPLL_DT_AUDIT,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
if (UPLL_RC_SUCCESS == result_code) {
- UPLL_LOG_DEBUG("Record exist in running & audit tbl result_code %d\n",
- result_code);
+ UPLL_LOG_TRACE("Record exist in running & audit tbl result_code %d",
+ result_code);
operation = uuc::kUpllUcpUpdate;
} else {
- UPLL_LOG_DEBUG("Record exist in running tbl only result_code %d\n",
- result_code);
- operation = uuc::kUpllUcpCreate;
+ UPLL_LOG_TRACE("Record exist in running tbl only result_code %d",
+ result_code);
+ operation = uuc::kUpllUcpCreate;
}
+ DELETE_IF_NOT_NULL(ckv_au_dup);
} else {
- result_code = UpdateConfigDB(ckv_dup, UPLL_DT_AUDIT,
- UNC_OP_READ, dmi, &dbop, MAINTBL);
- if (UPLL_RC_SUCCESS == result_code) { /* exists in Audit Database */
- UPLL_LOG_DEBUG("Record exist in audit tbl only result_code %d\n",
- result_code);
- operation = uuc::kUpllUcpDelete;
- ckv_dup->DeleteCfgVal();
- UPLL_LOG_DEBUG("ConfigKeyVal failed during AuditVote Phase is %s\n",
- ckv_dup->ToStrAll().c_str());
+ result_code = ReadConfigDB(ckv_dup, UPLL_DT_AUDIT,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS == result_code) { /* exists in Audit Database */
+ UPLL_LOG_TRACE("Record exist in audit tbl only result_code %d",
+ result_code);
+ operation = uuc::kUpllUcpDelete;
+ ckv_dup->DeleteCfgVal();
+ UPLL_LOG_DEBUG("ConfigKeyVal failed during AuditVote Phase is %s",
+ ckv_dup->ToStrAll().c_str());
+ } else {
+ UPLL_LOG_TRACE("Record neither exists in running nor "
+ "audit tbl result_code %d", result_code);
+ }
+ DELETE_IF_NOT_NULL(ckv_dup);//check with Vinoth
+ continue;
+ }
+ if (uuc::kUpllUcpDelete != operation) {
+ ConfigKeyVal *temp_ckv_dup = NULL;
+ if (CTRLRTBL == (GET_TABLE_TYPE(keytype, tbl))) {
+ result_code = GetChildConfigKey(temp_ckv_dup, ckv_drv_rslt);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Duplicate ConfigKeyVal failed - %d", result_code);
+ DELETE_IF_NOT_NULL(ckv_dup);
+ return result_code;
+ }
+ ConfigKeyVal *ctrlr_ckv = NULL;
+ result_code = GetChildConfigKey(ctrlr_ckv, temp_ckv_dup);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKeyVal failed %d", result_code);
+ DELETE_IF_NOT_NULL(ckv_dup);
+ DELETE_IF_NOT_NULL(temp_ckv_dup);
+ return result_code;
+ }
+ SET_USER_DATA_CTRLR(ctrlr_ckv, ctrlr_id);
+ DbSubOp dbop1 = {kOpReadMultiple, kOpMatchCtrlr,
+ kOpInOutCtrlr | kOpInOutDomain};
+ result_code = ReadConfigDB(ctrlr_ckv, UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop1, dmi, CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(ckv_dup);
+ DELETE_IF_NOT_NULL(temp_ckv_dup);
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return result_code;
+ }
+ ConfigKeyVal *temp_ctrlr_ckv = ctrlr_ckv;
+ while(temp_ctrlr_ckv) {
+ if (UNC_KT_VTN == keytype) {
+ result_code = UpdateCtrlrConfigStatus(UNC_CS_INVALID,
+ operation, temp_ctrlr_ckv);
} else {
- UPLL_LOG_DEBUG("Record neither exists in running nor \
- audit tbl result_code %d\n", result_code);
+ result_code = UpdateAuditConfigStatus(UNC_CS_INVALID,
+ operation, temp_ctrlr_ckv);
}
- continue;
- }
- result_code = UpdateAuditConfigStatus(UNC_CS_INVALID,
- operation, ckv_dup);
- if (UPLL_RC_SUCCESS == result_code) {
- result_code = UpdateConfigDB(ckv_dup, UPLL_DT_RUNNING,
- UNC_OP_UPDATE, dmi, MAINTBL);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("Update config status failed err code %d\n",
- result_code);
- return result_code;
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateAuditConfigStatus failed %d", result_code);
+ DELETE_IF_NOT_NULL(ckv_dup);
+ DELETE_IF_NOT_NULL(temp_ckv_dup);
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return result_code;
+ }
+ result_code = UpdateConfigDB(temp_ctrlr_ckv, UPLL_DT_RUNNING,
+ UNC_OP_UPDATE, dmi, CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(ckv_dup);
+ DELETE_IF_NOT_NULL(temp_ckv_dup);
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return result_code;
+ }
+ temp_ctrlr_ckv = temp_ctrlr_ckv->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ } else {
+ result_code = DupConfigKeyVal(temp_ckv_dup, ckv_drv_rslt, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed %d", result_code);
+ DELETE_IF_NOT_NULL(ckv_dup);
+ return result_code;
+ }
+ result_code = UpdateAuditConfigStatus(UNC_CS_INVALID,
+ operation, temp_ckv_dup);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateAuditConfigStatus failed %d", result_code);
+ DELETE_IF_NOT_NULL(ckv_dup);
+ DELETE_IF_NOT_NULL(temp_ckv_dup);
+ return result_code;
+ }
+ result_code = UpdateConfigDB(temp_ckv_dup, UPLL_DT_RUNNING,
+ UNC_OP_UPDATE, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(ckv_dup);
+ DELETE_IF_NOT_NULL(temp_ckv_dup);
+ return result_code;
+ }
}
- }
- if (CTRLRTBL == (GET_TABLE_TYPE(keytype,tbl))) {
- result_code = SetConsolidatedStatus(ckv_dup, dmi);
+ result_code = SetConsolidatedStatus(ckv_drv_rslt, dmi);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("SetConsolidatedStatus failed err code %d\n", result_code);
+ UPLL_LOG_INFO("SetConsolidatedStatus failed err code %d", result_code);
+ DELETE_IF_NOT_NULL(ckv_dup);
+ DELETE_IF_NOT_NULL(temp_ckv_dup);
return result_code;
}
- }
- if (ckv_dup) {
- delete ckv_dup;
- ckv_dup = NULL;
+ DELETE_IF_NOT_NULL(temp_ckv_dup);
}
- }
- if (vote_status->err_ckv)
- delete vote_status->err_ckv;
+ DELETE_IF_NOT_NULL(ckv_dup);
+ }
}
return result_code;
}
ConfigKeyVal *ckv_running = NULL;
ConfigKeyVal *ckv_audit = NULL;
ConfigKeyVal *ckv_update = NULL;
+ ConfigKeyVal *ctrlr_key = NULL;
DalCursor *cursor = NULL;
+ bool invalid_attr = false;
uint8_t *ctrlr_id =
reinterpret_cast<uint8_t *>((char *)(ctrlr_commit_status->ctrlr_id.c_str()));
uint32_t ctrlr_result = ctrlr_commit_status->upll_ctrlr_result;
- UPLL_LOG_INFO("controller id & commit result is %s %d\n", ctrlr_id,
+ UPLL_LOG_INFO("controller id & commit result is %s %d", ctrlr_id,
ctrlr_result);
MoMgrTables tbl = MAINTBL;
- GET_TABLE_TYPE(keytype,tbl);
+ unc_keytype_operation_t operation = UNC_OP_INVALID;
+ GET_TABLE_TYPE(keytype, tbl);
switch (ctrlr_result) {
/* if controller returns commit success, set CS Status as applied
retreived from database */
/* retreives the delta of running and audit configuration
- created and updated only */
for (int loop = uuc::kUpllUcpCreate; loop < uuc::kUpllUcpDelete; ++loop) {
+ operation = (loop == uuc::kUpllUcpCreate)?UNC_OP_CREATE:UNC_OP_UPDATE;
+/* if ((operation == UNC_OP_UPDATE) && (keytype == UNC_KT_VTN))
+ return UPLL_RC_SUCCESS;*/
result_code = DiffConfigDB(UPLL_DT_RUNNING, UPLL_DT_AUDIT,
- (unc_keytype_operation_t)loop,
+ operation,
ckv_running, ckv_audit,
&cursor,
- dmi, ctrlr_id, tbl);
+ dmi, ctrlr_id, tbl, true);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("DiffConfigDB failed - %d", result_code);
return result_code;
while (uud::kDalRcSuccess == (db_result = dmi->GetNextRecord(cursor))) {
/* ignore records of another controller for create and update operation */
uint8_t *ctrlr = NULL;
- GET_USER_DATA_CTRLR(ckv_running,ctrlr);
+ GET_USER_DATA_CTRLR(ckv_running, ctrlr);
if (ctrlr && strncmp(reinterpret_cast<const char *>(ctrlr),
- reinterpret_cast<const char *>(ctrlr_id),
+ reinterpret_cast<const char *>(ctrlr_id),
sizeof(strlen(reinterpret_cast<const char *>(ctrlr_id)))))
continue;
- UPLL_LOG_DEBUG("Diff Record: Keytype: Phase: is %d\n %d\n %s\n",
+ UPLL_LOG_TRACE("Diff Record: Keytype: Phase: is %d\n %d\n %s",
keytype, loop, ckv_running->ToStrAll().c_str());
result_code = GetDiffRecord(ckv_running, ckv_audit, (uuc::UpdateCtrlrPhase)loop, tbl,
- ckv_update, dmi);
+ ckv_update, dmi, invalid_attr);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("GetDiffRecord failed err code is %d\n", result_code);
+ UPLL_LOG_INFO("GetDiffRecord failed err code is %d", result_code);
return result_code;
}
- result_code = UpdateAuditConfigStatus(UNC_CS_APPLIED,
- (uuc::UpdateCtrlrPhase)loop, ckv_update);
+ if (CTRLRTBL == (GET_TABLE_TYPE(keytype, tbl))) {
+ result_code = DupConfigKeyVal(ctrlr_key, ckv_running, CTRLRTBL);
+ } else {
+ result_code = DupConfigKeyVal(ctrlr_key, ckv_running, MAINTBL);
+ }
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("DupConfigKeyVal failed");
+ DELETE_IF_NOT_NULL(ckv_running);
+ DELETE_IF_NOT_NULL(ckv_audit);
+ DELETE_IF_NOT_NULL(ckv_update);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ if (UNC_KT_VTN == keytype) {
+ result_code = UpdateCtrlrConfigStatus(UNC_CS_APPLIED,
+ (uuc::UpdateCtrlrPhase)loop, ctrlr_key);
+ } else {
+ result_code = UpdateAuditConfigStatus(UNC_CS_APPLIED,
+ (uuc::UpdateCtrlrPhase)loop, ctrlr_key);
+ }
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_INFO("UpdateAuditConfigStatus failed");
+ DELETE_IF_NOT_NULL(ckv_running);
+ DELETE_IF_NOT_NULL(ckv_audit);
+ DELETE_IF_NOT_NULL(ckv_update);
+ DELETE_IF_NOT_NULL(ctrlr_key);
+ dmi->CloseCursor(cursor, true);
return result_code;
- }
- result_code = UpdateConfigDB(ckv_update, UPLL_DT_RUNNING,
+ }
+ result_code = UpdateConfigDB(ctrlr_key, UPLL_DT_RUNNING,
UNC_OP_UPDATE, dmi, tbl);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("UpdateConfigDB for config status update failed %d",
result_code);
+ DELETE_IF_NOT_NULL(ckv_running);
+ DELETE_IF_NOT_NULL(ckv_audit);
+ DELETE_IF_NOT_NULL(ckv_update);
+ DELETE_IF_NOT_NULL(ctrlr_key);
+ dmi->CloseCursor(cursor, true);
return result_code;
}
- #if 0
- if (CTRLRTBL == (GET_TABLE_TYPE(keytype,tbl))) {
+ DELETE_IF_NOT_NULL(ctrlr_key);
+ if (CTRLRTBL == (GET_TABLE_TYPE(keytype, tbl))) {
result_code = SetConsolidatedStatus(ckv_update, dmi);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("SetConsolidatedStatus failed err code %d\n", result_code);
+ UPLL_LOG_INFO("SetConsolidatedStatus failed err code %d", result_code);
+ DELETE_IF_NOT_NULL(ckv_running);
+ DELETE_IF_NOT_NULL(ckv_audit);
+ DELETE_IF_NOT_NULL(ckv_update);
+ dmi->CloseCursor(cursor, true);
return result_code;
}
}
- #endif
- if (ckv_update)
- delete ckv_update;
- ckv_update = NULL;
+ DELETE_IF_NOT_NULL(ckv_update);
+ if (invalid_attr)
+ continue;
+ }
+ if (cursor) {
+ dmi->CloseCursor(cursor, true);
+ cursor = NULL;
}
+ DELETE_IF_NOT_NULL(ckv_running);
+ DELETE_IF_NOT_NULL(ckv_audit);
}
- if (ckv_running)
- delete ckv_running;
- if (ckv_audit)
- delete ckv_audit;
if (uud::kDalRcSuccess != db_result) {
UPLL_LOG_DEBUG("GetNextRecord from database failed - %d",
db_result);
default:
/* retrieves the error configkeyval one by one and if the keytype matches,
rename the key with UNC name */
- result_code = AuditVoteCtrlrStatus(keytype, ctrlr_commit_status, dmi);
+ result_code = AuditVoteCtrlrStatus(keytype, ctrlr_commit_status, dmi);
}
return result_code;
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
DalResultCode db_result;
uudst::kDalTableIndex tbl_index;
- for (int tbl = MAINTBL ; tbl < ntable ; tbl++) {
+ for (int tbl = MAINTBL; tbl < ntable; tbl++) {
tbl_index = GetTable((MoMgrTables)tbl, UPLL_DT_AUDIT);
- UPLL_LOG_DEBUG("Table Index value is %d\n", tbl_index);
+ UPLL_LOG_DEBUG("Table Index value is %d", tbl_index);
if (tbl_index >= uudst::kDalNumTables)
continue;
db_result = dmi->DeleteRecords(UPLL_DT_AUDIT, tbl_index, NULL);
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
DalResultCode db_result;
- for (int tbl = MAINTBL ; tbl < ntable ; tbl++) {
+ for (int tbl = MAINTBL; tbl < ntable; tbl++) {
uudst::kDalTableIndex tbl_index;
tbl_index = GetTable((MoMgrTables)tbl, UPLL_DT_IMPORT);
if ((tbl_index >= uudst::kDalNumTables) ||
DalResultCode db_result = uud::kDalRcSuccess;
upll_rc_t result_code = UPLL_RC_SUCCESS;
bool identical = false;
+ *dirty = false;
upll_keytype_datatype_t cfg_type1 = UPLL_DT_RUNNING;
upll_keytype_datatype_t cfg_type2 = UPLL_DT_CANDIDATE;
continue;
DalBindInfo dal_bind_info(tbl_index);
result_code = BindCandidateDirty(&dal_bind_info,
- cfg_type1,(MoMgrTables)i);
+ cfg_type1, (MoMgrTables)i,
+ tbl_index);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Error while binding %d\n",result_code);
+ UPLL_LOG_DEBUG("Error while binding %d", result_code);
return result_code;
}
db_result = dmi->CheckRecordsIdentical(cfg_type1,
&dal_bind_info,
&identical);
result_code = DalToUpllResCode(db_result);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Check Records identical Failed %d", result_code);
+ return result_code;
+ }
/* dirty is set if records are identical */
- if (result_code == UPLL_RC_SUCCESS)
- *dirty = !identical;
+ *dirty = !identical;
+ if (!identical) {
+ break;
+ }
}
return result_code;
}
return UPLL_RC_ERR_GENERIC;
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
- for (int tbl = MAINTBL ; tbl < ntable ; tbl++) {
+ for (int tbl = MAINTBL; tbl < ntable; tbl++) {
if (GetTable((MoMgrTables)tbl, data_type) < uudst::kDalNumTables) {
UPLL_LOG_TRACE("TABLE INDEX IS %d", GetTable((MoMgrTables)tbl, data_type));
DbSubOp dbop = {kOpNotRead, kOpMatchNone, kOpInOutFlag};
return UPLL_RC_ERR_GENERIC;
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
-
+
ConfigKeyVal *okey = NULL;
uint8_t rename = 0;
-
+
ConfigKeyVal *combine_key = NULL;
/* Create the partial key */
result_code = CopyToConfigKey(okey, rename_info);
- if (!okey || !(okey->get_key())) {
+ if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("CopyToConfig Return Empty key");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_DEBUG("The CopyToConfigKey out is %s", (okey->ToStrAll()).c_str());
/* Get the Full key Information */
DbSubOp dbop = {kOpReadMultiple, kOpMatchNone,
- kOpInOutCtrlr|kOpInOutDomain|kOpInOutFlag};
-
- result_code = ReadConfigDB(okey, data_type, UNC_OP_READ, dbop, dmi, MAINTBL);
+ kOpInOutFlag | kOpInOutCtrlr | kOpInOutDomain};
+ /* For VTN, we need to read it from Controller Table
+ * since while doing VTN rename we are skipping the vtn
+ * MAINTBL
+ */
+ result_code = ReadConfigDB(okey, data_type, UNC_OP_READ, dbop, dmi, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("ReadConfigDB returns Error = %d ", result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
+ ConfigKeyVal *temp = okey;
while (okey) {
+ rename = 0;
+ val_rename_vnode *vnode = NULL;
key_rename_vnode_info *vnode_rename =
- reinterpret_cast<key_rename_vnode_info *>(rename_info->get_key());
-
+ reinterpret_cast<key_rename_vnode_info *>(rename_info->get_key());
GET_USER_DATA_FLAGS(okey, rename);
/* Set the rename flag */
UPLL_LOG_TRACE("Before Renaming the Rename Flag = %d", rename);
switch (rename_info->get_key_type()) {
case UNC_KT_VTN:
- if (!no_rename)
- rename = rename | VTN_RENAME;
- else
- rename = rename & NO_VTN_RENAME;
- UPLL_LOG_TRACE("After the Renaming the Rename Flag = %d ", rename);
- break;
+ if (!no_rename)
+ rename = rename | VTN_RENAME;
+ else
+ rename = rename & NO_VTN_RENAME;
+ UPLL_LOG_TRACE("After the Renaming the Rename Flag = %d ", rename);
+ break;
case UNC_KT_VROUTER:
case UNC_KT_VLINK:
case UNC_KT_VBRIDGE:
- if (!no_rename)
- rename = rename | VN_RENAME;
- else
- rename = rename & NO_VN_RENAME;
- UPLL_LOG_TRACE("After the Renaming the Rename Flag = %d ", rename);
- break;
- // Update Here
+ if (!no_rename)
+ rename = rename | VN_RENAME;
+ else
+ rename = rename & NO_VN_RENAME;
+ UPLL_LOG_TRACE("After the Renaming the Rename Flag = %d ", rename);
+ break;
+ // Update Here
case UNC_KT_POLICING_PROFILE:
- switch (table[MAINTBL]->get_key_type()) {
- case UNC_KT_POLICING_PROFILE:
- case UNC_KT_POLICING_PROFILE_ENTRY:
- if (!no_rename)
- rename = rename | PP_RENAME;
- else
- rename = rename & NO_PP_RENAME;
- break;
- case UNC_KT_VTN_POLICINGMAP:
- case UNC_KT_VBR_POLICINGMAP:
- case UNC_KT_VBRIF_POLICINGMAP:
- if (!no_rename)
- rename = rename | PM_RENAME;
- else
- rename = rename & NO_PM_RENAME;
- break;
- default:
- break;
- }
- break;
+ switch (table[MAINTBL]->get_key_type()) {
+ case UNC_KT_POLICING_PROFILE:
+ case UNC_KT_POLICING_PROFILE_ENTRY:
+ if (!no_rename)
+ rename = rename | PP_RENAME;
+ else
+ rename = rename & NO_PP_RENAME;
+ break;
+ case UNC_KT_VTN_POLICINGMAP:
+ case UNC_KT_VBR_POLICINGMAP:
+ case UNC_KT_VBRIF_POLICINGMAP:
+ if (!no_rename)
+ rename = rename | PM_RENAME;
+ else
+ rename = rename & NO_PM_RENAME;
+ break;
+ default:
+ break;
+ }
+ break;
case UNC_KT_FLOWLIST:
switch (table[MAINTBL]->get_key_type()) {
case UNC_KT_FLOWLIST:
case UNC_KT_FLOWLIST_ENTRY:
- if (!no_rename)
- rename = rename | FL_RENAME;
- else
- rename = rename & NO_FL_RENAME;
- break;
+ if (!no_rename)
+ rename = rename | FL_RENAME;
+ else
+ rename = rename & NO_FL_RENAME;
+ break;
case UNC_KT_VTN_FLOWFILTER:
case UNC_KT_VTN_FLOWFILTER_ENTRY:
case UNC_KT_VTN_FLOWFILTER_CONTROLLER:
case UNC_KT_VBRIF_FLOWFILTER_ENTRY:
case UNC_KT_VRTIF_FLOWFILTER:
case UNC_KT_VRTIF_FLOWFILTER_ENTRY:
- if (!no_rename)
- rename = rename | FF_RENAME;
- else
- rename = rename & NO_FF_RENAME;
- break;
+ if (!no_rename)
+ rename = rename | FF_RENAME;
+ else
+ rename = rename & NO_FF_RENAME;
+ break;
default:
- break;
- }
+ break;
+ }
default:
break;
}
/* Create the duplicate key by using this function */
- UPLL_LOG_TRACE ("The Okey is %s", okey->ToStrAll().c_str());
+ UPLL_LOG_TRACE("The Okey is %s", okey->ToStrAll().c_str());
result_code = GetChildConfigKey(combine_key, okey);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetChildConfigKey Return Empty Key ");
- return UPLL_RC_ERR_GENERIC;
+ if (combine_key) {
+ combine_key->set_next_cfg_key_val(NULL);
+ DELETE_IF_NOT_NULL(combine_key);
+ }
+ DELETE_IF_NOT_NULL(temp);
+ return UPLL_RC_ERR_GENERIC;
}
-
/* Set the rename flag */
SET_USER_DATA_FLAGS(combine_key, rename);
- DumpRenameInfo (rename_info);
- val_rename_vnode *vnode =
- reinterpret_cast<val_rename_vnode *>(
- ConfigKeyVal::Malloc(sizeof(val_rename_vnode)));
+ DumpRenameInfo(rename_info);
switch (rename_info->get_key_type()) {
- /* fill the vnode if vtn is named
+ /* fill the vnode if vtn is renamed
* This part create an etrn in vnode rename table*/
case UNC_KT_VTN:
- UPLL_LOG_TRACE("Update the Vnode rename tables");
- uuu::upll_strncpy(vnode->ctrlr_vtn_name,
- vnode_rename->ctrlr_vtn_name,
- (kMaxLenCtrlrId + 1) );
- switch (table[MAINTBL]->get_key_type()) {
- case UNC_KT_VBRIDGE:
- uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
- (reinterpret_cast<key_vbr_t *>(okey->get_key()))->vbridge_name,
- (kMaxLenVnodeName + 1));
- uuu::upll_strncpy(vnode->ctrlr_vnode_name,
- (reinterpret_cast<key_vbr_t *>(okey->get_key()))->vbridge_name,
- (kMaxLenVnodeName + 1));
- break;
- case UNC_KT_VROUTER:
- uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
- (reinterpret_cast<key_vrt_t *>(okey->get_key()))->vrouter_name,
- (kMaxLenVnodeName + 1));
- uuu::upll_strncpy(vnode->ctrlr_vnode_name,
- (reinterpret_cast<key_vrt_t *>(okey->get_key()))->vrouter_name,
- (kMaxLenVnodeName + 1));
- break;
- case UNC_KT_VLINK:
- uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
- (reinterpret_cast<key_vlink_t *>(okey->get_key()))->vlink_name,
- (kMaxLenVlinkName + 1));
- uuu::upll_strncpy(vnode->ctrlr_vnode_name,
- (reinterpret_cast<key_vlink_t *>(okey->get_key()))->vlink_name,
- (kMaxLenVlinkName + 1));
- break;
- case UNC_KT_VBR_POLICINGMAP:
- uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
- (reinterpret_cast<key_vbr_t *>(okey->get_key()))->vbridge_name,
- (kMaxLenVnodeName + 1));
- break;
-
- case UNC_KT_VBRIF_POLICINGMAP:
- uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
- (reinterpret_cast<key_vbr_if *>
- (okey->get_key()))->vbr_key.vbridge_name,
- (kMaxLenVnodeName + 1));
- break;
- case UNC_KT_VBR_FLOWFILTER:
- uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
- (reinterpret_cast<key_vbr_flowfilter *>
- (okey->get_key()))->vbr_key.vbridge_name,
- (kMaxLenVnodeName + 1));
- break;
-
- case UNC_KT_VBR_FLOWFILTER_ENTRY:
- uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
- (reinterpret_cast<key_vbr_flowfilter_entry *>
- (okey->get_key()))->flowfilter_key.vbr_key.vbridge_name,
- (kMaxLenVnodeName + 1));
- break;
- case UNC_KT_VBRIF_FLOWFILTER:
- uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
- (reinterpret_cast<key_vbr_if_flowfilter *>
- (okey->get_key()))->if_key.vbr_key.vbridge_name,
- (kMaxLenVnodeName + 1));
- break;
-
- case UNC_KT_VBRIF_FLOWFILTER_ENTRY:
- uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
- (reinterpret_cast<key_vbr_if_flowfilter_entry *>
- (okey->get_key()))->flowfilter_key.if_key.vbr_key.vbridge_name,
- (kMaxLenVnodeName + 1));
- break;
- case UNC_KT_VRTIF_FLOWFILTER:
- uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
- (reinterpret_cast<key_vrt_if_flowfilter *>
- (okey->get_key()))->if_key.vrt_key.vrouter_name,
- (kMaxLenVnodeName + 1));
- break;
- case UNC_KT_VRTIF_FLOWFILTER_ENTRY:
- uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
- (reinterpret_cast<key_vrt_if_flowfilter_entry *>
- (okey->get_key()))->flowfilter_key.if_key.vrt_key.vrouter_name,
- (kMaxLenVnodeName + 1));
- break;
- default:
- break;
- }
- UPLL_LOG_TRACE("The Renamed Value is %d", renamed);
- if (!renamed && !no_rename) {
- /* If VTN is renamed add the entry in vnode and vlink rename table */
- if (table[MAINTBL]->get_key_type() == UNC_KT_VBRIDGE ||
- table[MAINTBL]->get_key_type() == UNC_KT_VROUTER ||
- table[MAINTBL]->get_key_type() == UNC_KT_VLINK) {
- ConfigKeyVal *tmp_key = NULL;
- DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain};
- controller_domain ctrlr_dom;
- UPLL_LOG_TRACE("Updating the Rename Table");
- result_code = GetControllerDomainId(okey, &ctrlr_dom);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("GetControllerDomainId Failed");
- return result_code;
- }
- result_code = GetChildConfigKey (tmp_key, okey);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("GetChildConfigKey Failed");
- return result_code;
- }
- ConfigVal *cfg_val = new ConfigVal(IpctSt::kIpcInvalidStNum, vnode);
- tmp_key->SetCfgVal(cfg_val);
- SET_USER_DATA_CTRLR_DOMAIN(tmp_key, ctrlr_dom);
- dbop.matchop = kOpMatchCtrlr | kOpMatchDomain;
- result_code = ReadConfigDB(tmp_key, data_type, UNC_OP_READ, dbop,
- dmi, RENAMETBL);
- if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
- /* If rename case create an entry in rename table
- * otherwise delete from the rename table */
- vnode->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
- vnode->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_VALID;
-
- dbop.readop = kOpNotRead;
- dbop.matchop = kOpMatchNone;
- dbop.inoutop = kOpInOutCtrlr | kOpInOutDomain ;
- UPLL_LOG_TRACE("Rename No Rename Falg = %d", no_rename);
- result_code = UpdateConfigDB(tmp_key, data_type, UNC_OP_CREATE,
- dmi, &dbop, RENAMETBL);
+ UPLL_LOG_TRACE("Update the Vnode rename tables");
+ vnode = reinterpret_cast<val_rename_vnode *>(
+ ConfigKeyVal::Malloc(sizeof(val_rename_vnode)));
+ uuu::upll_strncpy(vnode->ctrlr_vtn_name,
+ vnode_rename->ctrlr_vtn_name,
+ (kMaxLenCtrlrId + 1));
+ switch (table[MAINTBL]->get_key_type()) {
+ case UNC_KT_VBRIDGE:
+ uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
+ (reinterpret_cast<key_vbr_t *>(okey->get_key()))->vbridge_name,
+ (kMaxLenVnodeName + 1));
+ uuu::upll_strncpy(vnode->ctrlr_vnode_name,
+ (reinterpret_cast<key_vbr_t *>(okey->get_key()))->vbridge_name,
+ (kMaxLenVnodeName + 1));
+ break;
+ case UNC_KT_VROUTER:
+ uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
+ (reinterpret_cast<key_vrt_t *>(okey->get_key()))->vrouter_name,
+ (kMaxLenVnodeName + 1));
+ uuu::upll_strncpy(vnode->ctrlr_vnode_name,
+ (reinterpret_cast<key_vrt_t *>(okey->get_key()))->vrouter_name,
+ (kMaxLenVnodeName + 1));
+ break;
+ case UNC_KT_VLINK:
+ uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
+ (reinterpret_cast<key_vlink_t *>(okey->get_key()))->vlink_name,
+ (kMaxLenVlinkName + 1));
+ uuu::upll_strncpy(vnode->ctrlr_vnode_name,
+ (reinterpret_cast<key_vlink_t *>(okey->get_key()))->vlink_name,
+ (kMaxLenVlinkName + 1));
+ break;
+ case UNC_KT_VBR_POLICINGMAP:
+ uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
+ (reinterpret_cast<key_vbr_t *>(okey->get_key()))->vbridge_name,
+ (kMaxLenVnodeName + 1));
+ break;
+
+ case UNC_KT_VBRIF_POLICINGMAP:
+ uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
+ (reinterpret_cast<key_vbr_if *>
+ (okey->get_key()))->vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+ break;
+ case UNC_KT_VBR_FLOWFILTER:
+ uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
+ (reinterpret_cast<key_vbr_flowfilter *>
+ (okey->get_key()))->vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+ break;
+
+ case UNC_KT_VBR_FLOWFILTER_ENTRY:
+ uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
+ (reinterpret_cast<key_vbr_flowfilter_entry *>
+ (okey->get_key()))->flowfilter_key.vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+ break;
+ case UNC_KT_VBRIF_FLOWFILTER:
+ uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
+ (reinterpret_cast<key_vbr_if_flowfilter *>
+ (okey->get_key()))->if_key.vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+ break;
+
+ case UNC_KT_VBRIF_FLOWFILTER_ENTRY:
+ uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
+ (reinterpret_cast<key_vbr_if_flowfilter_entry *>
+ (okey->get_key()))->flowfilter_key.if_key.vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+ break;
+ case UNC_KT_VRTIF_FLOWFILTER:
+ uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
+ (reinterpret_cast<key_vrt_if_flowfilter *>
+ (okey->get_key()))->if_key.vrt_key.vrouter_name,
+ (kMaxLenVnodeName + 1));
+ break;
+ case UNC_KT_VRTIF_FLOWFILTER_ENTRY:
+ uuu::upll_strncpy(vnode_rename->new_unc_vnode_name,
+ (reinterpret_cast<key_vrt_if_flowfilter_entry *>
+ (okey->get_key()))->flowfilter_key.if_key.vrt_key.vrouter_name,
+ (kMaxLenVnodeName + 1));
+ break;
+ default:
+ break;
}
- if (tmp_key)
- delete tmp_key;
- tmp_key = NULL;
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG(" UpdateConfigDB Failed %d", result_code);
- return result_code;
+ UPLL_LOG_TRACE("The Renamed Value is %d", renamed);
+ if (!renamed && !no_rename) {
+ /* If VTN is renamed add the entry in vnode and vlink rename table */
+ if (table[MAINTBL]->get_key_type() == UNC_KT_VBRIDGE ||
+ table[MAINTBL]->get_key_type() == UNC_KT_VROUTER ||
+ table[MAINTBL]->get_key_type() == UNC_KT_VLINK) {
+ ConfigKeyVal *tmp_key = NULL;
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain};
+ controller_domain ctrlr_dom;
+ UPLL_LOG_TRACE("Updating the Rename Table");
+ result_code = GetControllerDomainId(okey, &ctrlr_dom);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetControllerDomainId Failed");
+ free(vnode);
+ if (combine_key) {
+ combine_key->set_next_cfg_key_val(NULL);
+ DELETE_IF_NOT_NULL(combine_key);
+ }
+ DELETE_IF_NOT_NULL(temp);
+ return result_code;
+ }
+ result_code = GetChildConfigKey(tmp_key, okey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed");
+ free(vnode);
+ if (combine_key) {
+ combine_key->set_next_cfg_key_val(NULL);
+ DELETE_IF_NOT_NULL(combine_key);
+ }
+ DELETE_IF_NOT_NULL(temp);
+ return result_code;
+ }
+ ConfigVal *cfg_val = new ConfigVal(IpctSt::kIpcInvalidStNum, vnode);
+ tmp_key->SetCfgVal(cfg_val);
+ SET_USER_DATA_CTRLR_DOMAIN(tmp_key, ctrlr_dom);
+ dbop.readop = kOpReadSingle;
+ dbop.matchop = kOpMatchCtrlr | kOpMatchDomain;
+ result_code = ReadConfigDB(tmp_key, data_type, UNC_OP_READ, dbop,
+ dmi, RENAMETBL);
+ if (UPLL_RC_SUCCESS != result_code &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB Failed %d", result_code);
+ DELETE_IF_NOT_NULL(tmp_key);
+ DELETE_IF_NOT_NULL(temp);
+ if (combine_key) {
+ combine_key->set_next_cfg_key_val(NULL);
+ DELETE_IF_NOT_NULL(combine_key);
+ }
+ return result_code;
+ }
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ /* If rename case create an entry in rename table
+ * otherwise delete from the rename table */
+ vnode->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
+ vnode->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_VALID;
+
+ dbop.readop = kOpNotRead;
+ dbop.matchop = kOpMatchNone;
+ dbop.inoutop = kOpInOutCtrlr | kOpInOutDomain;
+ UPLL_LOG_TRACE("Rename No Rename Falg = %d", no_rename);
+ result_code = UpdateConfigDB(tmp_key, data_type, UNC_OP_CREATE,
+ dmi, &dbop, RENAMETBL);
+ }
+ DELETE_IF_NOT_NULL(tmp_key);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG(" UpdateConfigDB Failed %d", result_code);
+ if (combine_key) {
+ combine_key->set_next_cfg_key_val(NULL);
+ DELETE_IF_NOT_NULL(combine_key);
+ }
+ DELETE_IF_NOT_NULL(temp);
+ return result_code;
+ }
+ } else {
+ FREE_IF_NOT_NULL(vnode);
+ }
+ } else {
+ FREE_IF_NOT_NULL(vnode);
}
- }
+ break;
+ default:
+ break;
}
- break;
- default:
- break;
- }
- UPLL_LOG_TRACE("Delete Entry from Rename Table");
- if (no_rename) {
- if (table[MAINTBL]->get_key_type() == UNC_KT_VTN ||
- table[MAINTBL]->get_key_type() == UNC_KT_VBRIDGE ||
- table[MAINTBL]->get_key_type() == UNC_KT_VROUTER ||
- table[MAINTBL]->get_key_type() == UNC_KT_VLINK) {
- UPLL_LOG_TRACE("Rename Flag is %d", rename);
- if ((table[MAINTBL]->get_key_type() == UNC_KT_VLINK && (rename & 0X0F))
- || !rename) {
+ if (no_rename) {
+ if (table[MAINTBL]->get_key_type() == UNC_KT_VTN ||
+ table[MAINTBL]->get_key_type() == UNC_KT_VBRIDGE ||
+ table[MAINTBL]->get_key_type() == UNC_KT_VROUTER ||
+ table[MAINTBL]->get_key_type() == UNC_KT_VLINK ||
+ table[MAINTBL]->get_key_type() == UNC_KT_FLOWLIST ||
+ table[MAINTBL]->get_key_type() == UNC_KT_POLICING_PROFILE) {
+ UPLL_LOG_TRACE("Delete Entry from Rename Table");
+ UPLL_LOG_TRACE("Rename Flag is %d", rename);
+ if ((table[MAINTBL]->get_key_type() == UNC_KT_VLINK && !(rename & 0X03))
+ || !rename) {
ConfigKeyVal *rename_key = NULL;
result_code = GetChildConfigKey(rename_key, okey);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("CopyToConfigKey Failed");
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed");
+ if (combine_key) {
+ combine_key->set_next_cfg_key_val(NULL);
+ DELETE_IF_NOT_NULL(combine_key);
+ }
+ DELETE_IF_NOT_NULL(temp);
return result_code;
}
DbSubOp dbop = {kOpNotRead, kOpMatchCtrlr|kOpMatchDomain, kOpInOutNone};
result_code = UpdateConfigDB(rename_key, data_type, UNC_OP_DELETE,
- dmi, &dbop, RENAMETBL);
- if (rename_key)
- delete rename_key;
+ dmi, &dbop, RENAMETBL);
+ if (rename_key)
+ DELETE_IF_NOT_NULL(rename_key);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_TRACE("UpdateConfigDB Failed");
+ DELETE_IF_NOT_NULL(temp);
+ if (combine_key) {
+ combine_key->set_next_cfg_key_val(NULL);
+ DELETE_IF_NOT_NULL(combine_key);
+ }
+ return result_code;
+ }
+ }
}
}
- }
- DumpRenameInfo (rename_info);
+ DumpRenameInfo(rename_info);
/* Add the New name configkeyval to old name configkeyval */
- combine_key->AppendCfgKeyVal(table[MAINTBL]->get_key_type(),
- IpctSt::kIpcInvalidStNum, vnode_rename, NULL);
+ combine_key->AppendCfgKeyVal(rename_info);
/* Update the new name into the table */
-// UPLL_LOG_TRACE("Before UpdateVnodeTables input is %s", (combine_key->ToStrAll()).c_str());
-//
- DumpRenameInfo (rename_info);
+ DumpRenameInfo(rename_info);
result_code = UpdateVnodeTables(combine_key, data_type, dmi);
+ if (combine_key) {
+ combine_key->set_next_cfg_key_val(NULL);
+ DELETE_IF_NOT_NULL(combine_key);
+ }
UPLL_LOG_TRACE("Updated in Vnode Tables ");
- if (UPLL_RC_SUCCESS != result_code)
- return result_code;
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(temp);
+ return result_code;
+ }
for (int i = 0; i < nchild; i++) {
unc_key_type_t ktype = child[i];
- /* Current Instance is Support Renaming or Not */
+ /* Avoid the Overlay key types here */
+ if (OVERLAY_KT(ktype)) {
+ UPLL_LOG_TRACE("Overlay Key type %d is skipping from rename operation"
+ , ktype);
+ continue;
+ }
MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(
- const_cast<MoManager *>(GetMoManager(ktype)));
+ const_cast<MoManager *>(GetMoManager(ktype)));
if (!mgr) {
UPLL_LOG_DEBUG("Invalid mgr param");
+ DELETE_IF_NOT_NULL(temp);
return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_TRACE("Update Key for the Child key type %d", ktype);
- DumpRenameInfo (rename_info);
+ DumpRenameInfo(rename_info);
result_code = mgr->UpdateRenamedValue(rename_info, dmi, data_type,
- renamed, no_rename);
- if (UPLL_RC_SUCCESS != result_code
+ renamed, no_rename);
+ if (UPLL_RC_SUCCESS != result_code
&& UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
- UPLL_LOG_DEBUG("UpdateRenamedValue is Failed %d", result_code);
- return result_code;
- }
- }
- UPLL_LOG_TRACE("The current Instance key type %d return result_code %d",
- table[MAINTBL]->get_key_type(), result_code);
- if (combine_key) {
- combine_key->set_next_cfg_key_val(NULL);
- delete combine_key;
- combine_key = NULL;
- }
- ConfigKeyVal *tmp = okey;
- okey = okey->get_next_cfg_key_val();
- if (tmp){
- tmp->set_next_cfg_key_val(NULL);
- delete tmp;
- }
- UPLL_LOG_TRACE("Fetching Next Record ");
+ DELETE_IF_NOT_NULL(temp);
+ UPLL_LOG_DEBUG("UpdateRenamedValue is Failed %d", result_code);
+ return result_code;
+ }
+ }
+ UPLL_LOG_TRACE("The current Instance key type %d return result_code %d",
+ table[MAINTBL]->get_key_type(), result_code);
+ okey = okey->get_next_cfg_key_val();
+ UPLL_LOG_TRACE("Fetching Next Record ");
}
+ DELETE_IF_NOT_NULL(temp);
return result_code;
}
upll_rc_t MoMgrImpl::UpdateTables(IpcReqRespHeader *req,
- ConfigKeyVal *&rename_info,
- bool &renamed,
- DalDmlIntf *dmi, bool &no_rename) {
- UPLL_FUNC_TRACE;
+ ConfigKeyVal *&rename_info,
+ bool &renamed,
+ DalDmlIntf *dmi, bool &no_rename) {
+ UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
if (!rename_info) {
UPLL_LOG_DEBUG("Input key is null");
return UPLL_RC_ERR_GENERIC;
}
- switch (rename_info->get_key_type()) {
+ switch (rename_info->get_key_type()) {
case UNC_KT_VTN:
case UNC_KT_VROUTER:
case UNC_KT_VBRIDGE:
case UNC_KT_VLINK:
case UNC_KT_POLICING_PROFILE:
case UNC_KT_FLOWLIST:
- /* Update the new name into the tables */
- DumpRenameInfo (rename_info);
- /* Current Instance is Supporting Rename
- * Then Get the Info */
- result_code = UpdateRenamedValue(rename_info, dmi, req->datatype,
- renamed, no_rename);
- if (UPLL_RC_SUCCESS != result_code
- && UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code){
- UPLL_LOG_DEBUG("UpdateRenamedValue is Failed %d", result_code);
- return result_code;
- }
- UPLL_LOG_TRACE("UpdateRenamedValue Return code %d", result_code);
- break;
+ /* Update the new name into the tables */
+ DumpRenameInfo(rename_info);
+ /* Current Instance is Supporting Rename
+ * Then Get the Info */
+ result_code = UpdateRenamedValue(rename_info, dmi, req->datatype,
+ renamed, no_rename);
+ if (UPLL_RC_SUCCESS != result_code
+ && UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("UpdateRenamedValue is Failed %d", result_code);
+ return result_code;
+ }
+ UPLL_LOG_TRACE("UpdateRenamedValue Return code %d", result_code);
+ break;
default:
- break;
+ break;
}
switch (rename_info->get_key_type()) {
case UNC_KT_VBRIDGE:
case UNC_KT_VROUTER:
- {
- /* The current instance is VBRIDGE or VROUTER then only
- * call this api
- */
- MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(
- const_cast<MoManager*>(GetMoManager(UNC_KT_VLINK)));
- if (!mgr) {
- UPLL_LOG_DEBUG("Invalid mgr");
- return UPLL_RC_ERR_GENERIC;
- }
-
- DumpRenameInfo (rename_info);
- /* Update the Vnode info in the Vlink table */
- result_code = mgr->UpdateVnodeVal(rename_info, dmi, req->datatype,
- no_rename);
- UPLL_LOG_TRACE("The Update Vnode val return value is %d", result_code);
-// }
- }
- break;
- case UNC_KT_FLOWLIST:
{
- /*unc::upll::pom::PolicingProfileEntryMoMgr *ppemgr = reinterpret_cast<unc::upll::pom::PolicingProfileEntryMoMgr *>
- (const_cast<MoManager *>(GetMoManager(UNC_KT_POLICING_PROFILE_ENTRY)));
- if (!ppemgr) {
+ /* The current instance is VBRIDGE or VROUTER then only
+ * call this api
+ */
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(
+ const_cast<MoManager*>(GetMoManager(UNC_KT_VLINK)));
+ if (!mgr) {
UPLL_LOG_DEBUG("Invalid mgr");
return UPLL_RC_ERR_GENERIC;
}
- result_code = ppemgr->UpdatePolicingProfileEntryRenamed(rename_info,
- dmi, req->datatype);*/
+
+ DumpRenameInfo(rename_info);
+ /* Update the Vnode info in the Vlink table */
+ result_code = mgr->UpdateVnodeVal(rename_info, dmi, req->datatype,
+ no_rename);
+ UPLL_LOG_TRACE("The Update Vnode val return value is %d", result_code);
+
+ unc_key_type_t child_key[]= {
+ UNC_KT_VBR_FLOWFILTER_ENTRY, UNC_KT_VBRIF_FLOWFILTER_ENTRY,
+ UNC_KT_VRTIF_FLOWFILTER_ENTRY };
+
+ for (unsigned int i = 0;
+ i < sizeof(child_key)/sizeof(child_key[0]); i++) {
+ const unc_key_type_t ktype = child_key[i];
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(
+ const_cast<MoManager *>(GetMoManager(ktype)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Instance is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ DumpRenameInfo(rename_info);
+ /* Update the Vnode info in the Vlink table */
+ result_code = mgr->UpdateVnodeVal(rename_info, dmi, req->datatype,
+ no_rename);
+ UPLL_LOG_TRACE("The Update Vnode val return value is %d", result_code);
+ }
}
- break;
+ break;
+ case UNC_KT_FLOWLIST:
+ {
+ unc_key_type_t child_key[]= {
+ UNC_KT_POLICING_PROFILE, UNC_KT_POLICING_PROFILE_ENTRY,
+ UNC_KT_VTN_FLOWFILTER, UNC_KT_VTN_FLOWFILTER_ENTRY,
+ UNC_KT_VBR_FLOWFILTER, UNC_KT_VBR_FLOWFILTER_ENTRY,
+ UNC_KT_VBRIF_FLOWFILTER, UNC_KT_VBRIF_FLOWFILTER_ENTRY,
+ UNC_KT_VRTIF_FLOWFILTER, UNC_KT_VRTIF_FLOWFILTER_ENTRY};
+ for (unsigned int i = 0;
+ i < sizeof(child_key)/sizeof(child_key[0]); i++) {
+ const unc_key_type_t ktype = child_key[i];
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(
+ const_cast<MoManager *>(GetMoManager(ktype)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Instance is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ DumpRenameInfo(rename_info);
+ /* Update the Vnode info in the Vlink table */
+ result_code = mgr->UpdateVnodeVal(rename_info, dmi, req->datatype,
+ no_rename);
+ UPLL_LOG_TRACE("The Update Vnode val return value is %d", result_code);
+ }
+ }
+ break;
+ case UNC_KT_POLICING_PROFILE:
+ {
+ unc_key_type_t child_key[]= {
+ UNC_KT_VTN_POLICINGMAP, UNC_KT_VBR_POLICINGMAP,
+ UNC_KT_VBRIF_POLICINGMAP };
+ for (unsigned int i = 0;
+ i < sizeof(child_key)/sizeof(child_key[0]); i++) {
+ const unc_key_type_t ktype = child_key[i];
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(
+ const_cast<MoManager *>(GetMoManager(ktype)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Instance is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ DumpRenameInfo(rename_info);
+ /* Update the Vnode info in the Vlink table */
+ result_code = mgr->UpdateVnodeVal(rename_info, dmi, req->datatype,
+ no_rename);
+ UPLL_LOG_TRACE("The Update Vnode val return value is %d", result_code);
+ }
+ }
+ break;
default:
- break;
+ break;
}
result_code = (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code)?
- UPLL_RC_SUCCESS:result_code;
+ UPLL_RC_SUCCESS:result_code;
return result_code;
}
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- if (!ikey)
+ if (!ikey || !(ikey->get_key()))
return UPLL_RC_ERR_GENERIC;
- // unc_key_type_t nodes[] = {UNC_KT_VBRIDGE, UNC_KT_VROUTER, UNC_KT_VLINK,
- // UNC_KT_VUNKNOWN, UNC_KT_VTEP, UNC_KT_VTUNNEL};
- // TODO(l)
- unc_key_type_t nodes[] = {UNC_KT_VBRIDGE, UNC_KT_VROUTER, UNC_KT_VLINK};
+ unc_key_type_t nodes[] = {UNC_KT_VBRIDGE, UNC_KT_VROUTER, UNC_KT_VLINK,
+ UNC_KT_VUNKNOWN, UNC_KT_VTEP, UNC_KT_VTUNNEL};
int nop = sizeof(nodes)/ sizeof(nodes[0]);
- UPLL_LOG_DEBUG("ikey keytype %d", ikey->get_key_type());
- for (int indx = 0 ; indx < nop; indx++) {
+ ConfigKeyVal *ck_vnode = NULL;
+ UPLL_LOG_TRACE("ikey keytype %d", ikey->get_key_type());
+ for (int indx = 0; indx < nop; indx++) {
MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(
const_cast<MoManager *>(GetMoManager(nodes[indx])));
if (!mgr) {
UPLL_LOG_TRACE("Invalid mgr");
continue;
}
- ConfigKeyVal *ck_vnode = NULL;
result_code = mgr->CreateVnodeConfigKey(ikey, ck_vnode);
- /* checks the vnode is available or not*/
- if (ck_vnode && (ck_vnode->get_key())) {
- UPLL_LOG_TRACE("Configkeycreated keytype %d result_code %d",
- ck_vnode->get_key_type(), result_code);
- } else {
- UPLL_LOG_DEBUG("ck_vnode NULL %d", result_code);
- if (ck_vnode) {
- delete ck_vnode;
- }
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("CreateVnodeConfigKey failed - %d", result_code);
return result_code;
}
result_code = mgr->UpdateConfigDB(ck_vnode, dt_type, UNC_OP_READ,
dmi, MAINTBL);
- UPLL_LOG_DEBUG("Existence check in keytype %d result_code %d",
- ck_vnode->get_key_type(), result_code);
- if (ck_vnode) {
+ if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_TRACE("Existence check in keytype %d result_code %d",
+ ck_vnode->get_key_type(), result_code);
delete ck_vnode;
+ return result_code;
}
- if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code
- || UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ if (ikey->get_key_type() != ck_vnode->get_key_type()) {
+ UPLL_LOG_INFO("vnode already exists in another vnode tbl");
+ result_code = UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ delete ck_vnode;
return result_code;
}
+ if (ck_vnode) {
+ delete ck_vnode;
+ ck_vnode = NULL;
+ }
}
- return UPLL_RC_SUCCESS;
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) ? UPLL_RC_SUCCESS :
+ result_code;
+ return result_code;
}
unc_keytype_configstatus_t MoMgrImpl::GetConsolidatedCsStatus(
}
while (iter != cs_status.end()) {
- ++iter;
current_cs_status = *iter;
final_cs_status = ComputeStatus(final_cs_status, current_cs_status);
+ ++iter;
}
return final_cs_status;
}
unc_keytype_configstatus_t result_code;
/* UNC_CS_APPLIED UNC_CS_INVALID UNC_CS_INVALID
- * UNC_CS_PARTAILLY_APPLIED UNC_CS_INVALID UNC_CS_INVALID
+ * UNC_CS_PARTIALLY_APPLIED UNC_CS_INVALID UNC_CS_INVALID
* UNC_CS_NOT_APPLIED UNC_CS_INVALID UNC_CS_INVALID
* UNC_CS_INVALID UNC_CS_APPLIED UNC_CS_INVALID
* UNC_CS_INVALID UNC_CS_INVALID UNC_CS_INVALID
* UNC_CS_INVALID UNC_CS_NOT_APPLIED UNC_CS_INVALID
* UNC_CS_NOT_SUPPORTED UNC_CS_INVALID UNC_CS_INVALID*/
-
- if(UNC_CS_INVALID == db_status || UNC_CS_INVALID == cs_status) {
+ if (UNC_CS_INVALID == db_status || UNC_CS_INVALID == cs_status) {
result_code = UNC_CS_INVALID;
}
/* UNC_CS_APPLIED UNC_CS_APPLIED UNC_CS_APPLIED*/
- else if(UNC_CS_APPLIED == db_status && UNC_CS_APPLIED == cs_status) {
+ else if (UNC_CS_APPLIED == db_status && UNC_CS_APPLIED == cs_status) {
result_code = UNC_CS_APPLIED;
}
* UNC_CS_NOT_APPLIED UNC_CS_NOT_SUPPORTED UNC_CS_NOT_APPLIED
* UNC_CS_NOT_SUPPORTED UNC_CS_NOT_SUPPORTED UNC_CS_NOT_APPLIED*/
- else if((UNC_CS_NOT_APPLIED == db_status &&
+ else if ((UNC_CS_NOT_APPLIED == db_status &&
UNC_CS_NOT_APPLIED == cs_status) ||
(UNC_CS_NOT_SUPPORTED == db_status &&
UNC_CS_NOT_APPLIED == cs_status) ||
result_code = UNC_CS_NOT_APPLIED;
}
-/* UNC_CS_APPLIED UNC_CS_NOT_APPLIED UNC_CS_PARTAILLY_APPLIED
- * UNC_CS_NOT_APPLIED UNC_CS_APPLIED UNC_CS_PARTAILLY_APPLIED
- * UNC_CS_NOT_SUPPORTED UNC_CS_APPLIED UNC_CS_PARTAILLY_APPLIED
- * UNC_CS_APPLIED UNC_CS_NOT_SUPPORTED UNC_CS_PARTAILLY_APPLIED
- * UNC_CS_PARTAILLY_APPLIED UNC_CS_APPLIED UNC_CS_PARTAILLY_APPLIED
- * UNC_CS_APPLIED UNC_CS_PARTAILLY_APPLIED UNC_CS_PARTAILLY_APPLIED
- * UNC_CS_NOT_APPLIED UNC_CS_PARTAILLY_APPLIED UNC_CS_PARTAILLY_APPLIED
- * UNC_CS_PARTAILLY_APPLIED UNC_CS_NOT_APPLIED UNC_CS_PARTAILLY_APPLIED
- * UNC_CS_PARTAILLY_APPLIED UNC_CS_PARTAILLY_APPLIED UNC_CS_PARTAILLY_APPLIED*/
+/* UNC_CS_APPLIED UNC_CS_NOT_APPLIED UNC_CS_PARTIALLY_APPLIED
+ * UNC_CS_NOT_APPLIED UNC_CS_APPLIED UNC_CS_PARTIALLY_APPLIED
+ * UNC_CS_NOT_SUPPORTED UNC_CS_APPLIED UNC_CS_PARTIALLY_APPLIED
+ * UNC_CS_APPLIED UNC_CS_NOT_SUPPORTED UNC_CS_PARTIALLY_APPLIED
+ * UNC_CS_PARTIALLY_APPLIED UNC_CS_APPLIED UNC_CS_PARTIALLY_APPLIED
+ * UNC_CS_APPLIED UNC_CS_PARTIALLY_APPLIED UNC_CS_PARTIALLY_APPLIED
+ * UNC_CS_NOT_APPLIED UNC_CS_PARTIALLY_APPLIED UNC_CS_PARTIALLY_APPLIED
+ * UNC_CS_PARTIALLY_APPLIED UNC_CS_NOT_APPLIED UNC_CS_PARTIALLY_APPLIED
+ * UNC_CS_PARTIALLY_APPLIED UNC_CS_PARTIALLY_APPLIED UNC_CS_PARTIALLY_APPLIED*/
- else if((UNC_CS_APPLIED == db_status ||
+ else if ((UNC_CS_APPLIED == db_status ||
UNC_CS_NOT_APPLIED == db_status ||
UNC_CS_NOT_SUPPORTED == db_status ||
- UNC_CS_PARTAILLY_APPLIED == db_status) &&
+ UNC_CS_PARTIALLY_APPLIED == db_status) &&
(UNC_CS_APPLIED == cs_status ||
UNC_CS_NOT_APPLIED == cs_status ||
UNC_CS_NOT_SUPPORTED == cs_status ||
- UNC_CS_PARTAILLY_APPLIED == cs_status)) {
- result_code = UNC_CS_PARTAILLY_APPLIED;
- }
-
- else {
+ UNC_CS_PARTIALLY_APPLIED == cs_status)) {
+ result_code = UNC_CS_PARTIALLY_APPLIED;
+ } else {
result_code = UNC_CS_UNKNOWN;
}
return result_code;
}
-
-
} // namespace kt_momgr
} // namespace upll
} // namespace unc
#ifndef UNC_UPLL_MOMGR_IMPL_H
#define UNC_UPLL_MOMGR_IMPL_H
+#include <sys/time.h>
+// #include <functional>
+
#include <map>
#include <string>
#include <cstring>
#include <list>
#include <set>
-// #include <functional>
#include "unc/keytype.h"
#include "unc/pfcdriver_include.h"
+#include "unc/pfcdriver_ipc_enum.h"
#include "unc/upll_ipc_enum.h"
#include "ipc_util.hh"
#include "ipct_st.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "upll_util.hh"
#include "dal_defines.hh"
#include "dal_schema.hh"
#define MAX_RENAME_FLAG_LEN 1
-#define ResetValid(x,val) { \
+#define INVALID_MATCH_VALUE 0xFFFF
+
+#define ResetValid(x, val) { \
struct x *tval = reinterpret_cast<struct x *>(val); \
- for (uint8_t i=0; i < sizeof(tval->valid)/sizeof(tval->valid[0]);i++) \
+ for (uint8_t i = 0; i < sizeof(tval->valid)/sizeof(tval->valid[0]); i++) \
*reinterpret_cast<uint8_t *>(tval->valid + i) = UNC_VF_INVALID; \
}
: NULL)
// #define KEY_RESET(x) *(x) = ' '
-
+
// typedef list<string> ListStr;
(keytype == UNC_KT_VTUNNEL_IF))
#define PORT_MAPPED_KEYTYPE(keytype) ((keytype == UNC_KT_VBR_IF) || \
- (keytype == UNC_KT_VTEP_IF) || (keytype == UNC_KT_VTUNNEL_IF))
+ (keytype == UNC_KT_VTEP_IF) || (keytype == UNC_KT_VTUNNEL_IF))
+
+#define VN_IF_KEYTYPE(keytype) ((keytype == UNC_KT_VBR_IF) || \
+ (keytype == UNC_KT_VTEP_IF) || (keytype == UNC_KT_VTUNNEL_IF) || \
+ (keytype == UNC_KT_VRT_IF))
#define GET_USER_DATA(ckey) { \
void *user_data = (ckey)->get_user_data(); \
#define SET_USER_DATA(ckey, skey) { \
key_user_data_t *suser_data = \
- reinterpret_cast<key_user_data_t *>(skey->get_user_data()); \
+ reinterpret_cast<key_user_data_t *>((skey)?(skey->get_user_data()):NULL); \
if (suser_data) {\
GET_USER_DATA(ckey) \
key_user_data_t *user_data = \
key_user_data_t *user_data = \
reinterpret_cast<key_user_data_t *>(ckey->get_user_data()); \
if (user_data) { \
+ if (strlen(reinterpret_cast<char *>((reinterpret_cast<key_user_data_t *> \
+ (ckey->get_user_data()))->ctrlr_id))) { \
(ctrlr_domain).ctrlr = \
- (reinterpret_cast<key_user_data_t *>(ckey->get_user_data()))->ctrlr_id; \
+ (reinterpret_cast<key_user_data_t *>(ckey->get_user_data()))->ctrlr_id; \
+ } \
+ if (strlen(reinterpret_cast<char *>((reinterpret_cast<key_user_data_t *> \
+ (ckey->get_user_data()))->domain_id))) { \
(ctrlr_domain).domain = \
- (reinterpret_cast<key_user_data_t *>(ckey->get_user_data()))->domain_id;\
+ (reinterpret_cast<key_user_data_t *>(ckey->get_user_data()))->domain_id;\
+ } \
} \
}
do { \
if (key)\
delete key;\
+ key = NULL;\
} while (0);
#define GET_TABLE_TYPE(keytype, tbl) \
||(keytype == UNC_KT_POLICING_PROFILE_ENTRY) \
|| (keytype == UNC_KT_FLOWLIST) || (keytype == UNC_KT_FLOWLIST_ENTRY) \
|| (keytype == UNC_KT_VTN_POLICINGMAP) \
- || (keytype == UNC_KT_VTN_FLOWFILTER))?CTRLRTBL:MAINTBL; \
+ || (keytype == UNC_KT_VTN_FLOWFILTER) \
+ || (keytype == UNC_KT_VTN_FLOWFILTER_ENTRY))? CTRLRTBL:MAINTBL; \
}
-
#define READ_OP(op) ((op == UNC_OP_READ) || (op == UNC_OP_READ_SIBLING) || \
(op == UNC_OP_READ_SIBLING_BEGIN) || \
(op == UNC_OP_READ_SIBLING_COUNT) || \
(op == UNC_OP_READ_BULK) || (op == UNC_OP_READ_NEXT))
+#define KEYTYPE_WITHOUT_DOMAIN(keytype, domain) \
+{ \
+ domain = ((keytype == UNC_KT_POLICING_PROFILE) \
+ || (keytype == UNC_KT_POLICING_PROFILE_ENTRY) \
+ || (keytype == UNC_KT_FLOWLIST) \
+ || (keytype == UNC_KT_FLOWLIST_ENTRY) \
+ || (keytype == UNC_KT_VTEP_GRP) \
+ || (keytype == UNC_KT_VTEP_GRP_MEMBER))?true:false; \
+}
+
+#define IS_POM_KT(keytype, flag) \
+{ \
+ flag = ((keytype == UNC_KT_VTN_POLICINGMAP) \
+ || (keytype == UNC_KT_VBR_POLICINGMAP) \
+ || (keytype == UNC_KT_VBRIF_POLICINGMAP) \
+ || (keytype == UNC_KT_VTN_FLOWFILTER) \
+ || (keytype == UNC_KT_VTN_FLOWFILTER_ENTRY) \
+ || (keytype == UNC_KT_VBR_FLOWFILTER) \
+ || (keytype == UNC_KT_VBR_FLOWFILTER_ENTRY) \
+ || (keytype == UNC_KT_VBRIF_FLOWFILTER) \
+ || (keytype == UNC_KT_VBRIF_FLOWFILTER_ENTRY) \
+ || (keytype == UNC_KT_VRTIF_FLOWFILTER) \
+ || (keytype == UNC_KT_VRTIF_FLOWFILTER_ENTRY))?true:false; \
+}
+
enum state_notification {
- kCtrlrDisconnect = 0x0,
+ kCtrlrReconnect = 0x0,
+ kCtrlrReconnectIfUp,
+ kCtrlrReconnectIfDown,
+ kCtrlrDisconnect,
+ kAdminStatusDisabled,
+ kAdminStatusEnabled,
kPortFault,
kPathFault,
- kCtrlrReconnect,
kPortFaultReset,
kPathFaultReset,
kBoundaryFault,
kBoundaryFaultReset
};
-#define RENAME 0x11
+#define POM_RENAME_KT(ktype) (((ktype) == UNC_KT_VBR_POLICINGMAP) || \
+ ((ktype) == UNC_KT_VBRIF_POLICINGMAP) || \
+ ((ktype) == UNC_KT_VBR_FLOWFILTER_ENTRY) || \
+ ((ktype) == UNC_KT_VBRIF_FLOWFILTER_ENTRY) || \
+ ((ktype) == UNC_KT_VRTIF_FLOWFILTER_ENTRY))
+#define RENAME 0x07
+#define RENAME_BITS 0x03
+#define GET_RENAME_FLAG(rename, ktype) \
+{ \
+ if (POM_RENAME_KT(ktype)) \
+ rename = rename & RENAME; \
+ else \
+ rename = rename & RENAME_BITS; \
+}
+
#define NO_VTN_RENAME 0xFE
#define NO_VN_RENAME 0xFD
#define NO_PP_RENAME 0x00
#define PM_RENAME 0x04
#define FL_RENAME 0x01
#define FF_RENAME 0x04
-
+#define NO_RENAME 0x00
enum val_rename_vnode_index {
UPLL_CTRLR_VTN_NAME_VALID = 0,
uint8_t vnode_name[kMaxLenVnodeName+1];
} key_vnode_t;
+typedef struct key_vnode_type {
+ key_vnode vnode_key;
+ unc_key_type_t key_type;
+} key_vnode_type_t;
+struct key_vnode_type_compare {
+ inline bool operator()(const key_vnode_type &keyvnodetype1,
+ const key_vnode_type keyvnodetype2) const {
+ int ret = strcmp((const char *)keyvnodetype1.vnode_key.vtn_key.vtn_name,
+ (const char *)keyvnodetype1.vnode_key.vtn_key.vtn_name);
+ if (ret == 0) {
+ return (strcmp((const char *)keyvnodetype1.vnode_key.vnode_name,
+ (const char*)keyvnodetype2.vnode_key.vnode_name) < 0);
+ } else {
+ return (ret < 0);
+ }
+ }
+};
enum rename_key {
UNC_RENAME_KEY,
CTRLR_RENAME_KEY
enum vnode_if_type {
kInvalid = 0x0,
kVbrIf,
- kVrtIf ,
+ kVrtIf,
kVunkIf,
kVtepIf,
- kVtunnelIf
+ kVtunnelIf
};
#define VLINK_FLAG_NODE_TYPE 0xFC
#define GET_VLINK_NODE2_TYPE(vlink_flag) \
((vlink_flag & VLINK_FLAG_NODE2_TYPE) >> kVlinkVnodeIf2Type)
-
enum if_type {
kUnboundInterface = 0x0,
kMappedInterface,
kBoundaryInterface,
- kLinkedInterface
+ kLinkedInterface
};
enum vn_if_type {
kVlinkInternalNode2 = 0x10
};
-enum InterfacePortMapInfo{
+enum InterfacePortMapInfo {
kVlinkPortMapNotConfigured = 0x00,
kVlinkConfigured = 0x01,
kPortMapConfigured = 0x02, /*Vlinked*/
CK_VAL,
CK_VAL2,
CS_VAL,
+ CFG_DEF_VAL,
+ CFG_ST_VAL,
+ CFG_ST_META_VAL,
CFG_INPUT_KEY,
CFG_MATCH_KEY
};
uint8_t ctrlr_vnode_name[kMaxLenVnodeName+1];
uint8_t old_policingprofile_name[kMaxLenPolicingProfileName+1];
uint8_t new_policingprofile_name[kMaxLenPolicingProfileName+1];
+ uint8_t ctrlr_profile_name[kMaxLenPolicingProfileName+1];
uint8_t old_flowlist_name[kMaxLenFlowListName+1];
uint8_t new_flowlist_name[kMaxLenFlowListName+1];
+ uint8_t ctrlr_flowlist_name[kMaxLenFlowListName+1];
}key_rename_vnode_info_t;
+
+
+
class Table {
uudst::kDalTableIndex tbl_index;
unc_key_type_t key_type;
const char *ctrlr_id,
const char *domain_id);
+ // Returns Query String for Read Import based on operation and keytype
+ std::string GetReadImportQueryString(unc_keytype_operation_t op,
+ unc_key_type_t kt) const;
+
+ bool OperStatusSupported(unc_key_type_t kt) {
+ switch (kt) {
+ case UNC_KT_VTN:
+ case UNC_KT_VBRIDGE:
+ case UNC_KT_VROUTER:
+ case UNC_KT_VBR_IF:
+ case UNC_KT_VRT_IF:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+
protected:
Table **table;
int ntable;
int nchild;
upll_rc_t DalToUpllResCode(DalResultCode result_code);
+ /* @brief Populate val_vtn_neighbor for the READ/READ_SIBLING operations
+ *
+ * @param[in/out] key Pointer to the ConfigKeyVal Structure
+ * @param[in] dmi Pointer to the DalDmlIntf(DB Interface)
+ *
+ * @retval UPLL_RC_SUCCESS Completed successfully.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ * @retval UPLL_RC_ERR_RESOURCE_DISCONNECTED Resource disconnected.
+ * @retval UPLL_RC_ERR_DB_ACCESS DB Read/Write error.
+ * @retval UPLL_RC_ERR_NO_SUCH_INSTANCE Given key does not exist
+ *
+ **/
+ virtual upll_rc_t PopulateValVtnNeighbor(ConfigKeyVal *&key,
+ DalDmlIntf *dmi) {
+ return UPLL_RC_SUCCESS;
+ }
+
+ upll_rc_t TxCopyRenameTableFromCandidateToRunning(
+ unc_key_type_t key_type,
+ unc_keytype_operation_t op,
+ DalDmlIntf* dmi);
+
+
#if 0
/**
* @brief Get configkey val with oper status initialized to UNINIT
*
- * @param[out] ck_vn pointer to ConfigKeyVal
- * @param[in] ktype key type
+ * @param[out] ck_vn pointer to ConfigKeyVal
+ * @param[in] ktype key type
* @param[in] dmi Poiner to database connection params.
*
* @retval UPLL_RC_SUCCESS Successful
unc_key_type_t ktype,
DalDmlIntf *dmi);
#else
- /* @brief Gets ports with uninitialized oper status
+ /* @brief Gets ports with uninitialized oper status
* - ports whose status have to be obtained from physical
- *
- * @param[out] ikey Pointer to a list of configkeyvals
+ *
+ * @param[out] ikey Pointer to a list of configkeyvals
* @param[in] dmi Database connection parameter
*
* @retval UPLL_RC_SUCCESS Completed successfully.
* @retval UPLL_RC_ERR_GENERIC Generic failure.
- *
- **/
- template<typename T1,typename T2>
+ *
+ **/
upll_rc_t GetUninitOperState(ConfigKeyVal *&ck_vn, DalDmlIntf *dmi);
#endif
bool &no_rename) {
return UPLL_RC_ERR_GENERIC;
};
- upll_rc_t GetVrtDhcpRelayServerAddress(ConfigKeyVal *ikey,
- DalDmlIntf *dmi) ;
upll_rc_t ValidateDeleteMoReq(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
- DalDmlIntf *dmi) ;
+ DalDmlIntf *dmi);
upll_rc_t DeleteCandidateMo(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
- DalDmlIntf *dmi) ;
+ DalDmlIntf *dmi);
virtual upll_rc_t CreateAuditMoImpl(ConfigKeyVal *ikey,
DalDmlIntf *dmi,
const char *ctrlr_id);
- /**
- * @brief Method to get a configkeyval of the parent keytype
- *
- * @param[in/out] okey pointer to parent ConfigKeyVal
- * @param[in] ikey pointer to the child configkeyval from
- * which the parent configkey val is obtained.
- *
- * @retval UPLL_RC_SUCCESS Successfull completion.
- * @retval UPLL_RC_ERR_GENERIC Failure case.
- **/
- virtual upll_rc_t GetParentConfigKey(ConfigKeyVal *&okey,
- ConfigKeyVal *ikey) = 0;
/**
- * @brief Enqueues oper status notifications
- *
- * @param[in] ikey pointer to the configkeyval with
- * the changed oper status
+ * @brief Update parent oper status on delete for Transaction commit
*
- * @retval UPLL_RC_SUCCESS Successfull completion.
- * @retval UPLL_RC_ERR_GENERIC Failure case.
- **/
- virtual upll_rc_t EnqueOperStatusNotification(ConfigKeyVal *ikey) {
- return UPLL_RC_SUCCESS;
+ * @param[int] ikey ConfigKeyVal instance
+ * @param[in] dmi Database connection parameter
+
+ * @retval UPLL_RC_SUCCESS Completed successfully.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ */
+ virtual upll_rc_t UpdateParentOperStatus(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
+ UPLL_LOG_DEBUG("Unsupported operation for this keytype %d\n",
+ (ikey)?ikey->get_key_type():0);
+ return UPLL_RC_ERR_GENERIC;
}
-
+
/**
* @brief Update config status for Transaction commit
*
unc_keytype_configstatus_t cs_status,
uuc::UpdateCtrlrPhase phase,
ConfigKeyVal *&ckv_running) = 0;
+ virtual upll_rc_t UpdateCtrlrConfigStatus(
+ unc_keytype_configstatus_t cs_status,
+ uuc::UpdateCtrlrPhase phase,
+ ConfigKeyVal *&ckv_running) {
+ return UPLL_RC_SUCCESS;
+ }
virtual upll_rc_t UpdateRenameKey(ConfigKeyVal *&ikey,
upll_keytype_datatype_t dt_type,
unc_keytype_operation_t op,
ConfigKeyVal *ckv_audit,
uuc::UpdateCtrlrPhase phase, MoMgrTables tbl,
ConfigKeyVal *&ckv_driver_req,
- DalDmlIntf *dmi);
+ DalDmlIntf *dmi,
+ bool &invalid_attr);
virtual upll_rc_t ValidateMessage(IpcReqRespHeader *req,
ConfigKeyVal *ikey) = 0;
/**
- * @brief Perform Semantic Check to check Different vbridges
+ * @brief Perform Semantic Check to check Different vbridges
* contain same switch-id and vlan-id
*
* @param[in] ikey ConfigKeyVal
uint8_t *&valid,
upll_keytype_datatype_t dt_type,
MoMgrTables tbl = MAINTBL)= 0;
- /**
- * @brief Allocates for the specified val in the given configuration in the * specified table.
- *
- * @param[in] ck_val Reference pointer to configval structure allocated. * @param[in] dt_type specifies the configuration candidate/running/state
- * @param[in] tbl specifies if the corresponding table is the main
- * table / controller table or rename table.
- *
- * @retval UPLL_RC_SUCCESS Successfull completion.
- * @retval UPLL_RC_ERR_GENERIC Failure case.
- **/
- virtual upll_rc_t AllocVal(ConfigVal *&ck_val,
- upll_keytype_datatype_t dt_type,
- MoMgrTables tbl = MAINTBL) = 0;
virtual upll_rc_t CreateCandidateMo(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
DalDmlIntf *dmi);
upll_rc_t BindCandidateDirty(DalBindInfo *db_info,
upll_keytype_datatype_t dt_type,
- MoMgrTables tbl = MAINTBL);
+ MoMgrTables tbl = MAINTBL,
+ const uudst::kDalTableIndex index = uudst::kDalNumTables);
virtual upll_rc_t BindAttr(DalBindInfo *db_info,
ConfigKeyVal *&req,
upll_keytype_datatype_t dt_type,
DbSubOp dbop, MoMgrTables tbl = MAINTBL);
- upll_rc_t GetInstanceCount(ConfigKeyVal *ikey, char *ctrlr_id,
- upll_keytype_datatype_t dt_type,
- uint32_t *count,
- DalDmlIntf *dmi,
- MoMgrTables tbl);
/*const */uudst::kDalTableIndex GetTable(MoMgrTables tbl,
upll_keytype_datatype_t dt_type) {
if (NULL != table[tbl])
return UPLL_RC_SUCCESS;
}
/**
- * @brief Method to assign ctrlr_dom
+ * @brief Method to assign ctrlr_dom
*
* @param[in/out] ikey ConfigVal pointer to input unc key
* @param[in] dmi specifies the db connection info
*/
upll_rc_t GetUserDataCtrlrDomain(ConfigKeyVal *ikey,
controller_domain *ctrlr_dom);
+
public:
MoMgrImpl() {
table = NULL;
ntable = 0;
child = NULL;
nchild = 0;
+ cur_instance_count = 0;
}
virtual ~MoMgrImpl() {}
+ uint32_t cur_instance_count;
+ /* @brief - allocates a configkeyval with oper status = UNINIT
+ *
+ * @param[out] ck_vn Pointer to a configkeyval
+ * @param[in] ikey null if no key is to be copied
+ * @param[in] dmi Database connection parameter
+ *
+ * @retval UPLL_RC_SUCCESS Completed successfully.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ *
+ **/
+ upll_rc_t GetCkvUninit(ConfigKeyVal *&ck_vn, ConfigKeyVal *ikey,
+ DalDmlIntf *dmi);
virtual upll_rc_t ValidateCapability(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
const char *ctrlr_name = NULL) = 0;
+ upll_rc_t GetInstanceCount(ConfigKeyVal *ikey, char *ctrlr_id,
+ upll_keytype_datatype_t dt_type,
+ uint32_t *count,
+ DalDmlIntf *dmi,
+ MoMgrTables tbl);
/**
* @brief Duplicates the input configkeyval including the key and val.
* based on the tbl specified.
void *val2,
bool audit) = 0;
+ virtual upll_rc_t PopulateDriverDeleteCkv(ConfigKeyVal *&vnpCkv,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t dt_type) {
+ return UPLL_RC_SUCCESS; }
+
/**
* @brief Method to get renamed controller key from unc key.
* On success unc key contains the controller key if renamed.
* @param[in] ikey pointer to input ConfigKeyVal
* @param[in] dt_type specifies the configuration type
* @param[in] dmi specifies the db connection info
- * @param[in/out] rename if rename is 0 input key is duplicated before
+ * @param[in/out] rename if rename is 0 input key is duplicated before
* reading from db.
* @retval UPLL_RC_SUCCESS Successfull completion.
* @retval UPLL_RC_ERR_GENERIC Failure case.
DalCursor **cfg1_cursor,
DalDmlIntf *dmi,
uint8_t *cntrlr_id,
- MoMgrTables tbl = MAINTBL);
+ MoMgrTables tbl = MAINTBL,
+ bool read_withcs = false);
/**
* @brief To populate the Ipc command
*
* @retval UPLL_RC_SUCCESS Successfull completion.
* @retval UPLL_RC_ERR_GENERIC Failure case.
*/
- virtual upll_rc_t UpdateVnodeVal(ConfigKeyVal *rename_info,
- DalDmlIntf *dmi,
- upll_keytype_datatype_t data_type,
- bool &no_rename) {
- UPLL_FUNC_TRACE;
- return UPLL_RC_ERR_GENERIC;
+ virtual upll_rc_t UpdateVnodeVal(ConfigKeyVal *rename_info,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t data_type,
+ bool &no_rename) {
+ UPLL_FUNC_TRACE;
+ return UPLL_RC_ERR_GENERIC;
}
/**
* @retval UNC_CS_INVALID Overall Configuration status is invalid
* @retval UNC_CS_APPLIED Overall Configuration status is applied.
* @retval UNC_CS_NOT_APPLIED Overall Configuration status is not applied.
- * @retval UNC_CS_PARTAILLY_APPLIED Configuration is not applied on all controllers
+ * @retval UNC_CS_PARTIALLY_APPLIED Configuration is not applied on all controllers
* pertaining to this configuration
* @retval UNC_CS_UNKNOWN State before the exact status of configuration is known.
*/
* @retval UNC_CS_INVALID Overall Configuration status is invalid
* @retval UNC_CS_APPLIED Overall Configuration status is applied.
* @retval UNC_CS_NOT_APPLIED Overall Configuration status is not applied.
- * @retval UNC_CS_PARTAILLY_APPLIED Configuration is not applied on all controllers
+ * @retval UNC_CS_PARTIALLY_APPLIED Configuration is not applied on all controllers
* pertaining to this configuration
* @retval UNC_CS_UNKNOWN State before the exact status of configuration is known.
*/
unc_keytype_configstatus_t ComputeStatus(unc_keytype_configstatus_t db_status,
unc_keytype_configstatus_t cs_status);
- upll_rc_t SetConsolidatedStatus(ConfigKeyVal *ikey,
+ virtual upll_rc_t SetConsolidatedStatus(ConfigKeyVal *ikey,
DalDmlIntf *dmi) {
- return UPLL_RC_ERR_GENERIC;
+ return UPLL_RC_SUCCESS;
}
int get_ntable() {
virtual upll_rc_t UpdateControllerTableForVtn(uint8_t *vtn_name,
controller_domain *ctrlr_dom,
unc_keytype_operation_t op,
- DalDmlIntf *dmi) {
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi,
+ uint8_t flag) {
UPLL_FUNC_TRACE
return UPLL_RC_ERR_GENERIC;
}
virtual upll_rc_t SetVlinkPortmapConfiguration(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
- InterfacePortMapInfo flag) {
+ InterfacePortMapInfo flag,
+ unc_keytype_operation_t oper) {
return UPLL_RC_ERR_GENERIC;
}
+ virtual upll_rc_t RestorePOMInCtrlTbl(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl,
+ DalDmlIntf* dmi) {
+ UPLL_FUNC_TRACE;
+ return UPLL_RC_SUCCESS;
+ }
/**
- * @Brief This API is to Dump the local rename's structure.
+ * @Brief This API is to Dump the local rename's structure.
*/
- void DumpRenameInfo (ConfigKeyVal *ikey);
+ void DumpRenameInfo(ConfigKeyVal *ikey);
/**
* @brief returns the controller name from ConfigKeyVal
*
* @param[in] ikey ConfigKeyVal pointer
*
- * @retval uint8_t pointer
- * @retval NULL if ConfigKeyVal is empty
+ * @retval uint8_t pointer
+ * @retval NULL if ConfigKeyVal is empty
*/
virtual upll_rc_t GetControllerDomainId(ConfigKeyVal *ikey,
controller_domain_t *ctrlr_dom) {
return UPLL_RC_ERR_GENERIC;
}
- virtual upll_rc_t IsHostAddrAndPrefixLenInUse(ConfigKeyVal *ckv, DalDmlIntf *dmi,
- IpcReqRespHeader *req) {
+ virtual upll_rc_t IsHostAddrAndPrefixLenInUse(ConfigKeyVal *ckv,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
return UPLL_RC_SUCCESS;
};
- virtual upll_rc_t IsLogicalPortAndVlanIdInUse(ConfigKeyVal *ckv, DalDmlIntf *dmi,
- IpcReqRespHeader *req) {
+ virtual upll_rc_t IsLogicalPortAndVlanIdInUse(ConfigKeyVal *ckv,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
return UPLL_RC_SUCCESS;
};
+ virtual upll_rc_t EnableAdminStatus(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ return UPLL_RC_SUCCESS;
+ };
+ virtual upll_rc_t IsAdminStatusEnable(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
+ return UPLL_RC_SUCCESS;
+ };
+ virtual upll_rc_t DeleteChildrenPOM(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi) {
+ return UPLL_RC_SUCCESS;
+ }
+ virtual upll_rc_t SetValidAudit(ConfigKeyVal *&ikey) {
+ return UPLL_RC_SUCCESS;
+ }
+
+ /* This is bind function for import read operation */
+ upll_rc_t BindImportDB(ConfigKeyVal *&ikey,
+ DalBindInfo *&db_info,
+ upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl);
+ /* This is called during import read operation */
+ upll_rc_t ReadImportDB(ConfigKeyVal *&ikey,
+ IpcReqRespHeader *header,
+ DalDmlIntf *dmi);
+ /* This is swap the value after read operation in Import table */
+ upll_rc_t SwapKey(ConfigKeyVal *&ikey,
+ uint8_t rename);
+ upll_rc_t Getvalstnum(ConfigKeyVal *&ikey,
+ uui::IpctSt::IpcStructNum &struct_num);
+ upll_rc_t Swapvaltokey(ConfigKeyVal *&ikey,
+ uint8_t rename_flag);
+ /**
+ * @brief Method to get a configkeyval of the parent keytype
+ *
+ * @param[in/out] okey pointer to parent ConfigKeyVal
+ * @param[in] ikey pointer to the child configkeyval from
+ * which the parent configkey val is obtained.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ virtual upll_rc_t GetParentConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *ikey) = 0;
+ /**
+ * @brief Allocates for the specified val in the given configuration in the
+ * specified table.
+ *
+ * @param[in] ck_val Reference pointer to configval structure allocated.
+ * @param[in] dt_type specifies the configuration candidate/running/state
+ * @param[in] tbl specifies if the corresponding table is the main
+ * table / controller table or rename table.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ virtual upll_rc_t AllocVal(ConfigVal *&ck_val,
+ upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl = MAINTBL) = 0;
+
}; // class MoMgrImpl
} // namespace kt_momgr
} // namespace upll
uint32_t *num_attrs,
const uint8_t **attrs,
upll_keytype_datatype_t datatype) {
+ UPLL_FUNC_TRACE;
unc_keytype_ctrtype_t type;
std::string version;
uint32_t *num_attrs,
const uint8_t **attrs,
upll_keytype_datatype_t datatype) {
+ UPLL_FUNC_TRACE;
unc_keytype_ctrtype_t type;
std::string version;
uint32_t session_id,
uint32_t config_id,
DalDmlIntf *dmi) {
- UPLL_LOG_DEBUG("kt: %u \n", ktype );
+ UPLL_LOG_DEBUG("kt: %u", ktype);
return UPLL_RC_SUCCESS;
- }
+ }
virtual upll_rc_t TxEnd(unc_key_type_t keytype, DalDmlIntf *dmi) = 0;
};
#include "momgr_impl.hh"
#include "vtn_momgr.hh"
#include "vbr_momgr.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "vlink_momgr.hh"
#include "vnode_momgr.hh"
#include "vnode_child_momgr.hh"
+#define IMPORT_READ_FAILURE 0xFF
namespace unc {
namespace upll {
namespace kt_momgr {
UPLL_LOG_DEBUG(" Invalid Table index - %d", tbl_index);
return UPLL_RC_ERR_GENERIC;
}
- if (ikey == NULL || ctrlr_id == NULL || strlen(ctrlr_id) == 0) {
+ if (ikey == NULL) {
UPLL_LOG_DEBUG("Invalid Param ikey/ctrlr_id");
return UPLL_RC_ERR_GENERIC;
}
- SET_USER_DATA_CTRLR(ikey, ctrlr_id);
DbSubOp dbop = { kOpReadCount, kOpMatchCtrlr, kOpInOutNone };
+ if (!ctrlr_id || strlen(ctrlr_id) == 0) {
+ dbop.matchop = kOpMatchNone;
+ } else {
+ SET_USER_DATA_CTRLR(ikey, ctrlr_id);
+ }
DalBindInfo *dal_bind_info = new DalBindInfo(tbl_index);
result_code = BindAttr(dal_bind_info, ikey, UNC_OP_READ, dt_type, dbop, tbl);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("BindAttr returns error %d\n", result_code);
+ UPLL_LOG_DEBUG("BindAttr returns error %d", result_code);
delete dal_bind_info;
return UPLL_RC_ERR_GENERIC;
}
result_code = DalToUpllResCode(
- dmi->GetRecordCount(dt_type, tbl_index, dal_bind_info, count));
+ dmi->GetRecordCount((dt_type == UPLL_DT_STATE)?UPLL_DT_RUNNING:dt_type, tbl_index, dal_bind_info, count));
delete dal_bind_info;
return result_code;
}
| kOpInOutDomain };
ConfigKeyVal *okey = NULL;
upll_rc_t result_code;
- /* rename is set implies user wants the ikey
- * populated with val from db */
- if (!rename) {
- result_code = GetChildConfigKey(okey,ikey);
+ MoMgrTables tbl = MAINTBL;
+ /* rename is set and dt_type is running/audit implies
+ * operaton is delete and ikey has to be populated with
+ * val from db.
+ */
+ if (rename &&
+ ((dt_type == UPLL_DT_RUNNING) ||
+ (dt_type == UPLL_DT_AUDIT))) {
+ okey = ikey;
+ } else {
+ result_code = GetChildConfigKey(okey, ikey);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("Returning error %d\n",result_code);
- return result_code;
+ UPLL_LOG_TRACE("Returning error %d",result_code);
+ return result_code;
}
- } else
- okey = ikey;
+ }
+
+ if (UNC_KT_VTN == table[MAINTBL]->get_key_type()) {
+ controller_domain_t ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ GET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
+ /* if controller and domain is present then bind it for
+ * match and get the exact information from vtn controller
+ * table
+ */
+ if (ctrlr_dom.ctrlr != NULL && ctrlr_dom.domain != NULL) {
+ dbop.matchop = kOpMatchCtrlr | kOpMatchDomain;
+ dbop.inoutop = kOpInOutFlag;
+ }
+ tbl = CTRLRTBL;
+ }
result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi,
- MAINTBL);
+ tbl);
if ((result_code != UPLL_RC_SUCCESS) &&
(result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
- UPLL_LOG_DEBUG("Returning error code %d\n",result_code);
+ UPLL_LOG_DEBUG("Returning error code %d",result_code);
if (okey != ikey) delete okey;
return UPLL_RC_ERR_GENERIC;
}
+ if (okey != ikey)
+ SET_USER_DATA(ikey,okey);
GET_USER_DATA_FLAGS(okey, rename);
- SET_USER_DATA(ikey,okey);
+#if 0
rename &= RENAME;
+#else
+ GET_RENAME_FLAG(rename,ikey->get_key_type())
+#endif
if (okey != ikey) delete okey;
return UPLL_RC_SUCCESS;
}
MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>
(const_cast<MoManager *>(GetMoManager(ktype)));
if (!mgr) {
- UPLL_LOG_DEBUG("Invalid mgr\n");
+ UPLL_LOG_DEBUG("Invalid mgr");
return UPLL_RC_ERR_GENERIC;
}
// cout << *ikey << ktype << " " << mgr << "\n";
SET_USER_DATA_FLAGS(tmp, rename);
result_code = mgr->UpdateConfigDB(tkey, dt_type, UNC_OP_UPDATE, dmi, tbl);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("UpdateConfigDB failed with error code %d\n",
+ UPLL_LOG_DEBUG("UpdateConfigDB failed with error code %d",
result_code);
return result_code;
}
tkey = NULL;
result_code = mgr->RenameChildren(ikey, dt_type, dmi);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Renamed failed with error code %d\n", result_code);
+ UPLL_LOG_DEBUG("Renamed failed with error code %d", result_code);
fail = true;
}
}
MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>
(const_cast<MoManager*>(GetMoManager(ktype)));
if (!mgr) {
- UPLL_LOG_DEBUG("Invalid mgr %d\n", ktype);
+ UPLL_LOG_DEBUG("Invalid mgr %d", ktype);
continue;
}
+ bool kt_flag = false;
+ IS_POM_KT(ktype, kt_flag);
+ if (kt_flag) {
+ mgr->DeleteChildrenPOM(ikey, dt_type, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DeleteChildrenPOM failed %d", result_code);
+ return result_code;
+ }
+ }
mgr->GetChildConfigKey(tkey, ikey);
- // std::cout << "Deleting keytype " << ktype << " " << *tkey << "\n";
+ /* For deleting the vnode rename table for the vtn or vnode
+ * need no to match the controller and domain
+ */
+ memset(tkey->get_user_data(), 0 , sizeof(key_user_data_t));
result_code = mgr->DeleteChildren(tkey, dt_type, dmi);
/* Delete all the tables for this momgr
* RENAMETBL to be deleted only once */
(mgr->GetTable((MoMgrTables)j, dt_type) >= uudst::kDalNumTables)) {
continue;
}
- result_code = mgr->UpdateConfigDB(tkey, dt_type, UNC_OP_DELETE, dmi,
+ /* Match Controller and domain is not need for delete children*/
+ DbSubOp dbop = {kOpNotRead, kOpMatchNone, kOpInOutNone};
+ result_code = mgr->UpdateConfigDB(tkey, dt_type, UNC_OP_DELETE, dmi, &dbop,
(MoMgrTables) j);
result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
UPLL_RC_SUCCESS : result_code;
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("DeleteChild failed with result_code %d\n", result_code);
+ UPLL_LOG_DEBUG("DeleteChild failed with result_code %d", result_code);
fail = true;
}
}
UPLL_FUNC_TRACE;
ConfigKeyVal *tkey = NULL;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- DalResultCode db_result;
bool fail = false;
+ int i = 0;
- for (int i = 0; i < nchild; i++) {
- unc_key_type_t ktype = child[i];
- MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>
- (const_cast<MoManager*>((GetMoManager(ktype))));
- if (!mgr) {
- UPLL_LOG_DEBUG("Invalid mgr\n");
- return UPLL_RC_ERR_GENERIC;
+ MoMgrImpl *chld_mgr = NULL;
+ unc_key_type_t chld_ktype = (unc_key_type_t)0;
+ while (true) {
+ unc_key_type_t ktype = (unc_key_type_t)0;
+
+ if (GetMoMgrKeyType(tbl, src_cfg) == ikey->get_key_type()) {
+ ktype = ikey->get_key_type();
}
- const uudst::kDalTableIndex tbl_index = mgr->GetTable(tbl, dest_cfg);
- if (tbl_index >= uudst::kDalNumTables) {
- UPLL_LOG_DEBUG(" Invalid Table index - %d", tbl_index);
- return UPLL_RC_ERR_GENERIC;
+
+ for (int index = MAINTBL; index < MAX_MOMGR_TBLS; index++) {
+ if (table[index] == NULL)
+ continue;
+ result_code = GetChildConfigKey(tkey, ikey);
+
+ if (UPLL_RC_SUCCESS != result_code) {
+ return result_code;
+ }
+
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone,
+ kOpInOutFlag | kOpInOutCtrlr | kOpInOutDomain };
+ result_code = ReadConfigDB(tkey, src_cfg, UNC_OP_READ, dbop, dmi, (MoMgrTables)index);
+
+ if (UPLL_RC_SUCCESS != result_code
+ && UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("GetControllerDomainId Failed");
+ DELETE_IF_NOT_NULL(tkey);
+ return result_code;
+ }
+
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ DELETE_IF_NOT_NULL(tkey);
+ continue;
+ }
+ ConfigKeyVal *tmp1 = tkey;
+ while (tkey != NULL) {
+ ConfigKeyVal *tmp = NULL;
+ result_code = DupConfigKeyVal(tmp, tkey, (MoMgrTables)index);
+ SET_USER_DATA(tmp, tkey);
+
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DupConfiKeyVal Failed");
+ }
+ chld_ktype = tmp->get_key_type();
+ dbop.readop = kOpNotRead;
+ result_code = UpdateConfigDB(tmp, dest_cfg, UNC_OP_CREATE, dmi, &dbop, (MoMgrTables)index);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed with error code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(tmp);
+ return result_code;
+ }
+ if ((chld_ktype == UNC_KT_VTN_FLOWFILTER_ENTRY) ||
+ (chld_ktype == UNC_KT_VBR_FLOWFILTER_ENTRY) ||
+ (chld_ktype == UNC_KT_VBRIF_FLOWFILTER_ENTRY) ||
+ (chld_ktype == UNC_KT_VRTIF_FLOWFILTER_ENTRY) ||
+ (chld_ktype == UNC_KT_VTN_POLICINGMAP) ||
+ (chld_ktype == UNC_KT_VBR_POLICINGMAP) ||
+ (chld_ktype == UNC_KT_VBRIF_POLICINGMAP)) {
+ chld_mgr = reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *>(GetMoManager(chld_ktype)));
+ if (!chld_mgr) {
+ UPLL_LOG_DEBUG("Invalid mgr");
+ DELETE_IF_NOT_NULL(tmp);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ result_code = chld_mgr->RestorePOMInCtrlTbl(tmp,
+ dest_cfg,
+ (MoMgrTables)index,
+ dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Err in restoring POM Obj in Ctrltbl, err %d, kt%d",
+ result_code, chld_ktype);
+ DELETE_IF_NOT_NULL(tmp);
+ return result_code;
+ }
+ chld_mgr = NULL;
+ }
+ tkey = tkey->get_next_cfg_key_val();
+ DELETE_IF_NOT_NULL(tmp);
+ }
+ DELETE_IF_NOT_NULL(tmp1);
}
- DalBindInfo *dal_bind_info = new DalBindInfo(tbl_index);
- mgr->GetChildConfigKey(tkey, ikey);
- DbSubOp dbop = { kOpReadMultiple, kOpMatchCtrlr | kOpMatchDomain,
- kOpInOutNone };
- result_code = BindAttr(dal_bind_info, tkey, UNC_OP_READ, dest_cfg, dbop,
- tbl);
- db_result = dmi->CopyMatchingRecords(dest_cfg, src_cfg, tbl_index,
- dal_bind_info);
- result_code = DalToUpllResCode(db_result);
- if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- UPLL_LOG_DEBUG("No matching instance in running config\n");
- } else if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Failed to restore child from running config %d\n",
- result_code);
- fail = true;
+
+ if (nchild == 0) {
+ return UPLL_RC_SUCCESS;
}
- result_code = mgr->RestoreChildren(tkey, dest_cfg, src_cfg, dmi);
- delete dal_bind_info;
- delete tkey;
- tkey = NULL;
+
+ while (true) {
+ ktype = child[i];
+ chld_mgr = reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *>(GetMoManager(ktype)));
+ if (!chld_mgr) {
+ UPLL_LOG_DEBUG("Invalid mgr");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ result_code = chld_mgr->RestoreChildren(ikey, dest_cfg, src_cfg, dmi);
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Restored failed with error code %d", result_code);
+ fail = true;
+ break;
+ }
+
+ if ((nchild-1) <= i)
+ return UPLL_RC_SUCCESS;
+ i++;
+ }
+ break;
}
return ((fail == true) ? UPLL_RC_ERR_GENERIC : UPLL_RC_SUCCESS);
}
DalCursor **cfg1_cursor,
DalDmlIntf *dmi,
uint8_t *ctrlr_id,
- MoMgrTables tbl) {
+ MoMgrTables tbl, bool read_withcs) {
UPLL_FUNC_TRACE;
const uudst::kDalTableIndex tbl_index = GetTable(tbl, dt_cfg1);
if (tbl_index >= uudst::kDalNumTables) {
UPLL_LOG_DEBUG(" Invalid Table index - %d", tbl_index);
return UPLL_RC_ERR_GENERIC;
}
- UPLL_LOG_DEBUG("Table Index %d Table %d Operation op %d\n",
+ UPLL_LOG_DEBUG("Table Index %d Table %d Operation op %d",
tbl_index, tbl, op);
upll_rc_t result_code;
DalResultCode db_result = uud::kDalRcSuccess;
if (UNC_OP_DELETE == op)
dbop.matchop = kOpMatchCtrlr | kOpMatchDomain;
uint16_t max_record_count = 0;
+ #if 0
if (ctrlr_id) {
dbop.inoutop &= ~kOpInOutCtrlr;
SET_USER_DATA_CTRLR(req, ctrlr_id)
}
+ #endif
if (tbl == CTRLRTBL) {
dbop.inoutop |= kOpInOutCs;
}
if (op == UNC_OP_UPDATE) {
- dbop.matchop = kOpMatchFlag;
+ if (tbl == CTRLRTBL)
+ dbop.matchop |= kOpMatchFlag;
+ else
+ dbop.matchop = kOpMatchFlag;
dbop.readop |= kOpReadDiffUpd;
+ if (read_withcs)
+ dbop.inoutop |= kOpInOutCs;
}
if (dt_cfg2 == UPLL_DT_AUDIT) dbop.matchop |= kOpMatchCs;
DalBindInfo *binfo_cfg1 = new DalBindInfo(tbl_index);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Error from BindAttr for table(%d)", tbl_index);
delete binfo_cfg1;
+ delete req;
+ req = NULL;
return result_code;
}
UPLL_LOG_DEBUG("Failed in GetChildConfigKey");
delete binfo_cfg1;
delete binfo_cfg2;
+ delete req;
+ req = NULL;
return result_code;
}
- result_code = BindAttr(binfo_cfg2, nreq, UNC_OP_READ, dt_cfg2, dbop, tbl);
+ result_code = BindAttr(binfo_cfg2, nreq, UNC_OP_READ,((dt_cfg2 == UPLL_DT_RUNNING)?UPLL_DT_STATE:dt_cfg2), dbop, tbl);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Error from BindAttr for table(%d)", tbl_index);
delete binfo_cfg1;
delete binfo_cfg2;
+ delete req;
+ delete nreq;
+ req = nreq = NULL;
return result_code;
}
db_result = dmi->GetUpdatedRecords(dt_cfg1, dt_cfg2, tbl_index,
max_record_count, binfo_cfg1,
binfo_cfg2, cfg1_cursor);
- // delete binfo_cfg2; TODO(l): Not a place to delete
+ // For Success case, binfo_cfg2 will be deleted by the caller.
+ if (db_result != uud::kDalRcSuccess) {
+ delete binfo_cfg2;
+ }
break;
}
default:
break;
}
result_code = DalToUpllResCode(db_result);
- // if (binfo_cfg1) delete binfo_cfg1; TODO(l): Not a place to delete
+ // For Success case, binfo_cfg1 will be deleted by the caller.
+ if (result_code != UPLL_RC_SUCCESS) {
+ delete binfo_cfg1;
+ }
return result_code;
}
result_code = BindAttr(dal_bind_info, ikey, op, dt_type, dbop, tbl);
if (result_code != UPLL_RC_SUCCESS) {
if (dal_bind_info) delete dal_bind_info;
- UPLL_LOG_INFO("Exiting MoMgrImpl::ReadConfigDB result code %d\n",
+ UPLL_LOG_INFO("Exiting MoMgrImpl::ReadConfigDB result code %d",
result_code);
return result_code;
}
db_result = dmi->GetRecordCount(dt_type, tbl_index, dal_bind_info,
&sibling_count);
uint32_t *sib_count =
- reinterpret_cast<uint32_t*>(malloc(sizeof(uint32_t)));
+ reinterpret_cast<uint32_t*>(ConfigKeyVal::Malloc
+ (sizeof(uint32_t)));
*sib_count = sibling_count;
ikey->SetCfgVal(new ConfigVal(IpctSt::kIpcStUint32, sib_count));
}
}
result_code = DalToUpllResCode(db_result);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning %d\n",result_code);
+ UPLL_LOG_DEBUG("Returning %d",result_code);
delete dal_bind_info;
return result_code;
}
}
break;
}
+ ConfigKeyVal *prev_key = tkey;
tkey = NULL;
result_code = DupConfigKeyVal(tkey, ikey, tbl);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Dup failed error %d\n",result_code);
+ UPLL_LOG_DEBUG("Dup failed error %d",result_code);
delete dal_bind_info;
+ DELETE_IF_NOT_NULL(end_resp);
return result_code;
}
if (!end_resp)
end_resp = tkey;
- else
- end_resp->AppendCfgKeyVal(tkey);
+ else {
+ prev_key->AppendCfgKeyVal(tkey);
+ }
if (op != UNC_OP_READ) count++; else nrec_read++;
}
if (result_code == UPLL_RC_SUCCESS) {
if (end_resp)
ikey->ResetWith(end_resp);
- string s(ikey->ToStrAll());
- UPLL_LOG_DEBUG(" sibling_count %d count %d operation %d response %s\n",
- sibling_count, count, op, s.c_str());
+ UPLL_LOG_DEBUG(" sibling_count %d count %d operation %d response %s",
+ sibling_count, count, op, (ikey->ToStrAll()).c_str());
}
dmi->CloseCursor(dal_cursor_handle);
+ DELETE_IF_NOT_NULL(end_resp);
}
if (dal_bind_info) delete dal_bind_info;
return result_code;
return UPLL_RC_ERR_GENERIC;
}
-// cout << tbl_index << "\n";
bool exists = false;
DalBindInfo *dal_bind_info = new DalBindInfo(tbl_index);
upll_rc_t result_code;
}
}
} else {
- if (dt_type != UPLL_DT_CANDIDATE)
+ if (dt_type != UPLL_DT_CANDIDATE || tbl == CTRLRTBL)
dbop.inoutop |= kOpInOutCs;
}
pdbop = &dbop;
return result_code;
}
dt_type = (dt_type == UPLL_DT_STATE) ? UPLL_DT_RUNNING : dt_type;
- string s(ikey->ToStrAll());
switch (op) {
case UNC_OP_CREATE:
- UPLL_LOG_TRACE("Dbop %s dt_type %d CREATE %d\n", s.c_str(), dt_type,
+ UPLL_LOG_TRACE("Dbop %s dt_type %d CREATE %d", (ikey->ToStrAll()).c_str(), dt_type,
tbl_index);
result_code = DalToUpllResCode(
dmi->CreateRecord(dt_type, tbl_index, dal_bind_info));
break;
case UNC_OP_DELETE:
- UPLL_LOG_TRACE("Dbop %s dt_type %d DELETE %d\n", s.c_str(), dt_type,
+ UPLL_LOG_TRACE("Dbop %s dt_type %d DELETE %d", (ikey->ToStrAll()).c_str(), dt_type,
tbl_index);
result_code = DalToUpllResCode(
dmi->DeleteRecords(dt_type, tbl_index, dal_bind_info));
break;
case UNC_OP_UPDATE:
- UPLL_LOG_TRACE("Dbop %s dt_type %d UPD %d\n", s.c_str(), dt_type,
+ UPLL_LOG_TRACE("Dbop %s dt_type %d UPD %d", (ikey->ToStrAll()).c_str(), dt_type,
tbl_index);
result_code = DalToUpllResCode(
dmi->UpdateRecords(dt_type, tbl_index, dal_bind_info));
break;
case UNC_OP_READ:
- UPLL_LOG_TRACE("Dbop %s dt_type %d EXISTS %d\n", s.c_str(), dt_type,
+ UPLL_LOG_TRACE("Dbop %s dt_type %d EXISTS %d", (ikey->ToStrAll()).c_str(), dt_type,
tbl_index);
result_code = DalToUpllResCode(
dmi->RecordExists(dt_type, tbl_index, dal_bind_info, &exists));
uint8_t *valid = NULL, *valid_st = NULL;
key_user_data_t *tuser_data = NULL;
- UPLL_LOG_TRACE("Valid Falg is true ConfigKeyVal %s", (req->ToStrAll()).c_str());
if ((req == NULL) || (tkey == NULL)) {
UPLL_LOG_DEBUG("NULL input parameters");
return UPLL_RC_ERR_GENERIC;
}
+ UPLL_LOG_TRACE("Valid Falg is true ConfigKeyVal %s", (req->ToStrAll()).c_str());//COV: FORWARD NULL
if (!GetBindInfo(tbl, dt_type, binfo, nattr)) return UPLL_RC_ERR_GENERIC;
tuser_data = reinterpret_cast<key_user_data_t *>(req->get_user_data());
switch (op) {
uint8_t *ctrlr = NULL;
GET_USER_DATA_CTRLR(req, ctrlr);
if (!ctrlr) {
- UPLL_LOG_DEBUG("Invalid Controller\n");
+ UPLL_LOG_DEBUG("Invalid Controller");
return UPLL_RC_ERR_GENERIC;
}
} else if (dbop.matchop & kOpMatchDomain) {
uint8_t *dom = NULL;
GET_USER_DATA_DOMAIN(req, dom);
if (!dom) {
- UPLL_LOG_DEBUG("Invalid Domain\n");
+ UPLL_LOG_DEBUG("Invalid Domain");
return UPLL_RC_ERR_GENERIC;
}
}
for (int i = 0; i < nattr; i++) {
uint64_t indx = binfo[i].index;
BindStructTypes attr_type = binfo[i].struct_type;
- UPLL_LOG_DEBUG(" the attr_type %x number %d \n", binfo[i].struct_type, i);
+ UPLL_LOG_TRACE(" the attr_type %x number %d", binfo[i].struct_type, i);
if (attr_type == CFG_KEY) {
p = reinterpret_cast<void *>(reinterpret_cast<char *>(tkey)
+ binfo[i].offset);
- UPLL_LOG_DEBUG(" key struct %d tkey %p p %p\n", attr_type, tkey, p);
+ UPLL_LOG_TRACE(" key struct %d tkey %p p %p", attr_type, tkey, p);
switch (op) {
case UNC_OP_CREATE:
- UPLL_LOG_DEBUG(" Bind input Key %"PFC_PFMT_u64" p %p\n", indx, p);
+ UPLL_LOG_TRACE(" Bind input Key %"PFC_PFMT_u64" p %p", indx, p);
db_info->BindInput(indx, binfo[i].app_data_type, binfo[i].array_size,
p);
break;
case UNC_OP_UPDATE:
if (IsValidKey(tkey, indx)) {
- UPLL_LOG_DEBUG("tkey %p bind match UPD p %p\n", tkey, p);
+ UPLL_LOG_TRACE("tkey %p bind match UPD p %p", tkey, p);
db_info->BindMatch(indx, binfo[i].app_data_type,
binfo[i].array_size, p);
}
break;
case UNC_OP_DELETE:
if (IsValidKey(tkey, indx)) {
- UPLL_LOG_DEBUG("tkey %p bind match DEL p %p\n", tkey, p);
+ UPLL_LOG_TRACE("tkey %p bind match DEL p %p", tkey, p);
db_info->BindMatch(indx, binfo[i].app_data_type,
binfo[i].array_size, p);
}
if ((dbop.readop & kOpReadSingle) || (dbop.readop & kOpReadExist)
|| (dbop.readop & kOpReadMultiple) || (dbop.readop & kOpReadCount)) {
if (IsValidKey(tkey, indx)) {
- UPLL_LOG_DEBUG("tkey %p bind match READ p %p\n", tkey, p);
+ UPLL_LOG_TRACE("tkey %p bind match READ p %p", tkey, p);
db_info->BindMatch(indx, binfo[i].app_data_type,
binfo[i].array_size, p);
if (dbop.readop & kOpReadMultiple) {
- UPLL_LOG_DEBUG("tkey %p bind output READ p %p\n", tkey, p);
+ UPLL_LOG_TRACE("tkey %p bind output READ p %p", tkey, p);
db_info->BindOutput(indx, binfo[i].app_data_type,
binfo[i].array_size, p);
}
} else {
- UPLL_LOG_DEBUG("tkey %p bind output READ p %p\n", tkey, p);
+ UPLL_LOG_TRACE("tkey %p bind output READ p %p", tkey, p);
db_info->BindOutput(indx, binfo[i].app_data_type,
binfo[i].array_size, p);
}
} else if (dbop.readop & kOpReadDiff) {
- UPLL_LOG_DEBUG("tkey %p DIFF match/output p %p\n", tkey, p);
+ UPLL_LOG_TRACE("tkey %p DIFF match/output p %p", tkey, p);
db_info->BindMatch(indx, binfo[i].app_data_type,
binfo[i].array_size, p);
db_info->BindOutput(indx, binfo[i].app_data_type,
tuser_data = reinterpret_cast<key_user_data_t *>(req->get_user_data());
}
if (!tuser_data) {
- UPLL_LOG_DEBUG("null tuser_data\n");
+ UPLL_LOG_DEBUG("null tuser_data");
continue;
}
p = reinterpret_cast<void *>(reinterpret_cast<char *>(tuser_data)
if ((par_ctrlr && (dbop.inoutop & kOpInOutCtrlr)) ||
(par_dom && (dbop.inoutop & kOpInOutDomain)) ||
(par_flag && (dbop.inoutop & kOpInOutFlag))) {
- UPLL_LOG_DEBUG("CR bind input Cntrlr/Domain/Flag %p\n", p);
+ UPLL_LOG_TRACE("CR bind input Cntrlr/Domain/Flag %p", p);
db_info->BindInput(indx, binfo[i].app_data_type,
binfo[i].array_size, p);
}
if ((par_ctrlr && (dbop.matchop & kOpMatchCtrlr)) ||
(par_dom && (dbop.matchop & kOpMatchDomain)) ||
(par_flag && (dbop.matchop & kOpMatchFlag))) {
- UPLL_LOG_DEBUG("UPD bind match flag/Cntrlr %p\n ", p);
+ UPLL_LOG_TRACE("UPD bind match flag/Cntrlr %p ", p);
db_info->BindMatch(indx, binfo[i].app_data_type,
binfo[i].array_size, p);
} else if ((par_ctrlr && (dbop.inoutop & kOpInOutCtrlr))
|| (par_dom && (dbop.inoutop & kOpInOutDomain))
|| (par_flag && (dbop.inoutop & kOpInOutFlag))) {
- UPLL_LOG_DEBUG("UPD bind input flag/Cntrlr/domain %p\n ", p);
+ UPLL_LOG_TRACE("UPD bind input flag/Cntrlr/domain %p ", p);
db_info->BindInput(indx, binfo[i].app_data_type,
binfo[i].array_size, p);
}
if ((par_ctrlr && (dbop.inoutop & kOpInOutCtrlr)) ||
(par_dom && (dbop.inoutop & kOpInOutDomain)) ||
(par_flag && (dbop.inoutop & kOpInOutFlag))) {
- UPLL_LOG_DEBUG("RD bind output flag/Cntrlr/domain %p\n", p);
+ UPLL_LOG_TRACE("RD bind output flag/Cntrlr/domain %p", p);
db_info->BindOutput(indx, binfo[i].app_data_type,
binfo[i].array_size, p);
}
if ((par_ctrlr && (dbop.matchop & kOpMatchCtrlr)) ||
(par_dom && (dbop.matchop & kOpMatchDomain)) ||
(par_flag && (dbop.matchop & kOpMatchFlag))) {
- UPLL_LOG_DEBUG("RD/DEL bind match flag/Cntrlr/domain %p\n", p);
+ UPLL_LOG_TRACE("RD/DEL bind match flag/Cntrlr/domain %p", p);
db_info->BindMatch(indx, binfo[i].app_data_type,
binfo[i].array_size, p);
}
}
} else if (tval && (attr_type != ST_VAL) && (attr_type != ST_META_VAL)) {
-
+#if 1
+ if (attr_type == CFG_DEF_VAL) {
+ attr_type = (dbop.readop & kOpReadDiffUpd)?attr_type:CFG_META_VAL;
+ UPLL_LOG_DEBUG("ATTR: attr_type %d readop %d op %d\n",attr_type, dbop.readop,op);
+ }
+#endif
if (op == UNC_OP_DELETE) continue;
+ if (dt_type == UPLL_DT_STATE) {
+#if 0
+ attr_type = (attr_type == CFG_ST_VAL)?CFG_VAL:
+ ((attr_type == CFG_ST_META_VAL)?CFG_META_VAL:attr_type);
+#else
+ // bind down count only for output and not for match
+ if (attr_type == CFG_ST_VAL) {
+ attr_type = (dbop.readop & kOpReadDiffUpd)?CFG_DEF_VAL:CFG_VAL;
+ } else if (attr_type == CFG_ST_META_VAL) {
+ attr_type = (dbop.readop & kOpReadDiffUpd)?CFG_DEF_VAL:CFG_META_VAL;
+ }
+#endif
+ } else if ((attr_type == CFG_ST_VAL) || (attr_type == CFG_ST_META_VAL)) {
+ continue;
+ }
p = reinterpret_cast<void *>(reinterpret_cast<char *>(tval)
+ binfo[i].offset);
bool valid_is_defined = false;
if (attr_type == CFG_VAL) {
result_code = GetValid(tval, indx, valid, dt_type, tbl);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning %d\n",result_code);
+ UPLL_LOG_TRACE("Returning %d",result_code);
return result_code;
}
if (!valid) {
- UPLL_LOG_DEBUG(" Invalid for attr %d", i);
+ UPLL_LOG_TRACE(" Invalid for attr %d", i);
switch (op) {
case UNC_OP_CREATE:
case UNC_OP_UPDATE:
default:
valid_is_defined = false;
}
- } else if (((uint8_t) *valid == UNC_VF_VALID) ||
- ((uint8_t) *valid == UNC_VF_VALID_NO_VALUE)) {
+ } else if ((*valid == UNC_VF_VALID) ||
+ ( *valid == UNC_VF_VALID_NO_VALUE)) {
valid_is_defined = true;
}
} else if (attr_type == CFG_META_VAL) {
}
switch (op) {
case UNC_OP_CREATE:
+#if 0
if ((attr_type == CFG_META_VAL) || valid_is_defined
+#else
+ if ((attr_type == CFG_META_VAL) || (attr_type == CFG_VAL)
+#endif
|| ((attr_type == CS_VAL) && (dbop.inoutop & kOpInOutCs))) {
- UPLL_LOG_DEBUG("tval/meta CR bind input %p p %p\n", tval, p);
+ UPLL_LOG_TRACE("tval/meta CR bind input %p p %p", tval, p);
db_info->BindInput(indx, binfo[i].app_data_type,
binfo[i].array_size,
reinterpret_cast<void *>(p));
#if 0
if ((attr_type == CFG_META_VAL)
|| ((attr_type == CS_VAL) && (dbop.matchop & kOpMatchCs))) {
- UPLL_LOG_DEBUG("tval/meta UP bind match %p p %p\n", tval, p);
+ UPLL_LOG_TRACE("tval/meta UP bind match %p p %p", tval, p);
db_info->BindMatch(indx, binfo[i].app_data_type,
binfo[i].array_size,
reinterpret_cast<void *>(p));
#endif
if (valid_is_defined ||
((attr_type == CS_VAL) && (dbop.inoutop & kOpInOutCs))) {
- UPLL_LOG_DEBUG("tval/meta UP bind input %p p %p\n", tval, p);
+ UPLL_LOG_TRACE("tval/meta UP bind input %p p %p", tval, p);
// store VALID_NO_VALUE flag in candidate as INVALID
- if ((attr_type == CFG_META_VAL) &&
+ if ((attr_type == CFG_META_VAL) &&
(*(reinterpret_cast<uint8_t *>(p)) == UNC_VF_VALID_NO_VALUE)) {
- UPLL_LOG_TRACE("Resetting VALID_NO_VALUE to INVALID %p \n", p);
+ UPLL_LOG_TRACE("Resetting VALID_NO_VALUE to INVALID %p", p);
*(reinterpret_cast<uint8_t *>(p)) = UNC_VF_INVALID;
}
db_info->BindInput(indx, binfo[i].app_data_type,
case UNC_OP_READ_SIBLING_COUNT:
if (dbop.readop & ~(kOpReadDiff | kOpReadExist | kOpReadDiffUpd)) {
if (valid_is_defined) {
- UPLL_LOG_DEBUG("tval RD bind match %p p %p\n", tval, p);
+ UPLL_LOG_TRACE("tval RD bind match %p p %p", tval, p);
db_info->BindMatch(indx, binfo[i].app_data_type,
binfo[i].array_size,
reinterpret_cast<void *>(p));
switch (attr_type) {
case CS_VAL:
if (dbop.inoutop & kOpInOutCs) {
- UPLL_LOG_DEBUG("tvalcs RD bind output %p p %p\n", tval, p);
+ UPLL_LOG_TRACE("tvalcs RD bind output %p p %p", tval, p);
db_info->BindOutput(indx, binfo[i].app_data_type,
binfo[i].array_size,
reinterpret_cast<void *>(p));
break;
case CFG_VAL:
case CFG_META_VAL:
- UPLL_LOG_DEBUG("tval RD bind output %p p %p\n", tval, p);
+ UPLL_LOG_TRACE("tval RD bind output %p p %p", tval, p);
db_info->BindOutput(indx, binfo[i].app_data_type,
binfo[i].array_size,
reinterpret_cast<void *>(p));
}
}
} else if (dbop.readop & kOpReadDiff) {
- if ((attr_type == CFG_META_VAL) || (attr_type == CFG_VAL)
- || ((attr_type == CS_VAL) && (dbop.inoutop & kOpInOutCs))) {
- UPLL_LOG_DEBUG("tval %d RDDiff bind output %p p %p\n", attr_type,
+ if ((attr_type == CFG_META_VAL) || (attr_type == CFG_VAL) ||
+#if 1
+ (attr_type == CFG_DEF_VAL) ||
+#endif
+ ((attr_type == CS_VAL) && (dbop.inoutop & kOpInOutCs))) {
+ UPLL_LOG_TRACE("tval %d RDDiff bind output %p p %p", attr_type,
tval, p);
db_info->BindOutput(indx, binfo[i].app_data_type,
binfo[i].array_size,
reinterpret_cast<void *>(p));
}
+#if 1
if ((attr_type == CFG_META_VAL) || (attr_type == CFG_VAL) ||
+#else
+ if ((attr_type == CFG_VAL) ||
+#endif
((attr_type == CS_VAL) && (dbop.matchop & kOpMatchCs))) {
- if (dbop.readop & kOpReadDiffUpd) {
- UPLL_LOG_DEBUG("tval %d RDDiff bind match %p p %p\n", attr_type,
+#if 1
+ if ((dbop.readop & kOpReadDiffUpd) && (attr_type != CFG_DEF_VAL)) {
+#else
+ if (dbop.readop & kOpReadDiffUpd)
+#endif
+ UPLL_LOG_TRACE("tval %d RDDiff bind match %p p %p", attr_type,
tval, p);
db_info->BindMatch(indx, binfo[i].app_data_type,
binfo[i].array_size,
bool valid_is_defined = false;
p = reinterpret_cast<void *>(reinterpret_cast<char *>(sval)
+ binfo[i].offset);
+#if 0
+ if (attr_type == CFG_ST_VAL) {
+ uint32_t val_p = *(reinterpret_cast<uint32_t *>(p));
+ attr_type = (op == UNC_OP_UPDATE)?
+ ((val_p != INVALID_MATCH_VALUE)?ST_VAL:attr_type):ST_VAL;
+ }
+#endif
if (attr_type == ST_VAL) {
result_code = GetValid(sval, indx, valid_st, dt_type, tbl);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning %d\n",result_code);
+ UPLL_LOG_TRACE("Returning %d",result_code);
return result_code;
}
if (!valid_st) {
switch (op) {
case UNC_OP_CREATE:
if ((attr_type == ST_META_VAL) || valid_is_defined) {
- UPLL_LOG_DEBUG("sval CR/UPD bind input %p p %p\n", sval, p);
+ UPLL_LOG_TRACE("sval CR/UPD bind input %p p %p", sval, p);
db_info->BindInput(indx, binfo[i].app_data_type,
binfo[i].array_size,
reinterpret_cast<void *>(p));
case UNC_OP_UPDATE:
#if 0
if (attr_type == ST_META_VAL) {
- UPLL_LOG_DEBUG("sval/meta UP bind match %p p %p\n", sval, p);
+ UPLL_LOG_TRACE("sval/meta UP bind match %p p %p", sval, p);
db_info->BindMatch(indx, binfo[i].app_data_type,
binfo[i].array_size,
reinterpret_cast<void *>(p));
}
#endif
if (valid_is_defined) {
- UPLL_LOG_DEBUG("sval/meta UP bind input %p p %p\n", sval, p);
+ UPLL_LOG_TRACE("sval/meta UP bind input %p p %p", sval, p);
db_info->BindInput(indx, binfo[i].app_data_type,
binfo[i].array_size,
reinterpret_cast<void *>(p));
case UNC_OP_READ_SIBLING_COUNT:
if (dbop.readop & ~( kOpReadDiff | kOpReadDiffUpd | kOpReadExist)) {
if (valid_is_defined) {
- UPLL_LOG_DEBUG("sval RD bind match %p p %p\n", sval, p);
+ UPLL_LOG_TRACE("sval RD bind match %p p %p", sval, p);
db_info->BindMatch(indx, binfo[i].app_data_type,
binfo[i].array_size,
reinterpret_cast<void *>(p));
} else if ((dbop.readop & (kOpReadExist | kOpReadCount)) == 0) {
- UPLL_LOG_DEBUG("sval RD bind output %p p %p\n", sval, p);
+ UPLL_LOG_TRACE("sval RD bind output %p p %p", sval, p);
db_info->BindOutput(indx, binfo[i].app_data_type,
binfo[i].array_size,
reinterpret_cast<void *>(p));
}
} else if (dbop.readop & kOpReadDiff) {
if ((attr_type == ST_META_VAL) || (attr_type == ST_VAL)) {
- UPLL_LOG_DEBUG("sval %d RDDiff bind output %p p %p\n", attr_type,
+ UPLL_LOG_TRACE("sval %d RDDiff bind output %p p %p", attr_type,
sval, p);
db_info->BindOutput(indx, binfo[i].app_data_type,
binfo[i].array_size,
reinterpret_cast<void *>(p));
+#if 0
if (dbop.readop & kOpReadDiffUpd) {
- UPLL_LOG_DEBUG("sval %d RDDiff bind match %p p %p\n", attr_type,
+ UPLL_LOG_TRACE("sval %d RDDiff bind match %p p %p", attr_type,
sval, p);
db_info->BindMatch(indx, binfo[i].app_data_type,
binfo[i].array_size,
reinterpret_cast<void *>(p));
}
+#endif
}
}
default:
}
pdbop = &dbop;
}
- result_code = BindAttrRename(dal_bind_info, ikey, op, dt_type, *pdbop, tbl);
- switch (op) {
- case UNC_OP_CREATE:
- result_code = DalToUpllResCode(
- dmi->CreateRecord(dt_type, tbl_index, dal_bind_info));
- break;
- case UNC_OP_UPDATE:
- result_code = DalToUpllResCode(
- dmi->UpdateRecords(dt_type, tbl_index, dal_bind_info));
- break;
- case UNC_OP_READ:
- result_code = DalToUpllResCode(
- dmi->RecordExists(dt_type, tbl_index, dal_bind_info, &exists));
- if (result_code == UPLL_RC_SUCCESS) {
- if (exists)
- result_code = UPLL_RC_ERR_INSTANCE_EXISTS;
- else
- result_code = UPLL_RC_ERR_NO_SUCH_INSTANCE;
- }
- break;
- default:
- break;
- }
- delete dal_bind_info;
+ result_code = BindAttrRename(dal_bind_info, ikey, op, dt_type, *pdbop, tbl);
+ switch (op) {
+ case UNC_OP_CREATE:
+ result_code = DalToUpllResCode(
+ dmi->CreateRecord(dt_type, tbl_index, dal_bind_info));
+ break;
+ case UNC_OP_UPDATE:
+ result_code = DalToUpllResCode(
+ dmi->UpdateRecords(dt_type, tbl_index, dal_bind_info));
+ break;
+ case UNC_OP_READ:
+ result_code = DalToUpllResCode(
+ dmi->RecordExists(dt_type, tbl_index, dal_bind_info, &exists));
+ if (result_code == UPLL_RC_SUCCESS) {
+ if (exists)
+ result_code = UPLL_RC_ERR_INSTANCE_EXISTS;
+ else
+ result_code = UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ }
+ break;
+ default:
+ break;
+ }
+ delete dal_bind_info;
- return result_code;
-}
+ return result_code;
+ }
-upll_rc_t MoMgrImpl::BindAttrRename(DalBindInfo *db_info,
+ upll_rc_t MoMgrImpl::BindAttrRename(DalBindInfo *db_info,
ConfigKeyVal *&req,
unc_keytype_operation_t op,
upll_keytype_datatype_t dt_type,
UPLL_LOG_TRACE("The If condition value is %d i=%d", (nattr/2), i);
if (i == (nattr / 2)) {
if (req->get_next_cfg_key_val()
- && (req->get_next_cfg_key_val())->get_key())
+ && (req->get_next_cfg_key_val())->get_key()) {
tkey = (req->get_next_cfg_key_val())->get_key();
DumpRenameInfo(req->get_next_cfg_key_val());
+ }
}
-
indx = binfo[i].index;
BindStructTypes attr_type = binfo[i].struct_type;
- UPLL_LOG_DEBUG("the attr_type %d attr number %d\n", binfo[i].struct_type,
+ UPLL_LOG_TRACE("the attr_type %d attr number %d", binfo[i].struct_type,
i);
p = reinterpret_cast<void *>(reinterpret_cast<char *>(tkey)
+ binfo[i].offset);
- UPLL_LOG_DEBUG("key struct %d tkey %p p %p\n", attr_type, tkey, p);
+ UPLL_LOG_TRACE("key struct %d tkey %p p %p", attr_type, tkey, p);
if (CFG_INPUT_KEY == attr_type || CFG_MATCH_KEY == attr_type) {
switch (op) {
case UNC_OP_CREATE:
#if 0
if (!IsValidKey(tkey, indx)) {
- UPLL_LOG_DEBUG("Given Key is Invalid %s", (req->ToStrAll()).c_str());
+ UPLL_LOG_TRACE("Given Key is Invalid %s", (req->ToStrAll()).c_str());
return UPLL_RC_ERR_GENERIC;
}
#endif
- UPLL_LOG_DEBUG(" Bind input Key %"PFC_PFMT_u64" p %p\n", indx,
+ UPLL_LOG_TRACE(" Bind input Key %"PFC_PFMT_u64" p %p", indx,
reinterpret_cast<char*>(p));
db_info->BindInput(indx, binfo[i].app_data_type, binfo[i].array_size,
p);
// if (IsValidKey(tkey, indx)) {
switch (attr_type) {
case CFG_INPUT_KEY:
- UPLL_LOG_DEBUG("tkey %p bindinput %p\n", tkey,
+ UPLL_LOG_TRACE("tkey %p bindinput %p", tkey,
reinterpret_cast<char*>(p));
db_info->BindInput(indx, binfo[i].app_data_type,
binfo[i].array_size, p);
break;
case CFG_MATCH_KEY:
- UPLL_LOG_DEBUG("tkey %p bindmatch %p\n", tkey,
+ UPLL_LOG_TRACE("tkey %p bindmatch %p", tkey,
reinterpret_cast<char*>(p));
db_info->BindMatch(indx, binfo[i].app_data_type,
binfo[i].array_size, p);
default:
break;
}
-// } else {
-// UPLL_LOG_DEBUG("Invalid Key for the given key %s", (req->ToStrAll()).c_str());
-// }
break;
default:
break;
switch (op) {
case UNC_OP_CREATE:
if ((dbop.inoutop & (kOpInOutCtrlr | kOpInOutDomain))) {
- UPLL_LOG_DEBUG("CR bind input Cntrlr/Flag %p\n", p);
+ UPLL_LOG_TRACE("CR bind input Cntrlr/Flag %p", p);
db_info->BindInput(indx, binfo[i].app_data_type,
binfo[i].array_size, p);
}
case UNC_OP_UPDATE:
if ((dbop.matchop & (kOpMatchCtrlr | kOpMatchDomain))
|| (dbop.matchop & kOpMatchFlag)) {
- UPLL_LOG_DEBUG("UPD bind match Cntrlr/Flag %p\n", p);
+ UPLL_LOG_TRACE("UPD bind match Cntrlr/Flag %p", p);
db_info->BindMatch(indx, binfo[i].app_data_type,
binfo[i].array_size, p);
} else if ((dbop.inoutop & (kOpInOutCtrlr | kOpInOutDomain))
|| (dbop.inoutop & kOpInOutFlag)) {
- UPLL_LOG_DEBUG("UPD bind input Cntrlr/Flag %p\n", p);
+ UPLL_LOG_TRACE("UPD bind input Cntrlr/Flag %p", p);
db_info->BindInput(indx, binfo[i].app_data_type,
binfo[i].array_size, p);
}
// Binding Dummy pointers for matching
// This is currently specific for CheckRecordsIdentical API.
upll_rc_t MoMgrImpl::BindCandidateDirty(DalBindInfo *db_info,
- upll_keytype_datatype_t dt_type, MoMgrTables tbl) {
+ upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl,
+ const uudst::kDalTableIndex index) {
UPLL_FUNC_TRACE;
int nattr;
BindInfo *binfo;
void *dummy = malloc(sizeof(uint16_t)); /* dummy pointer */
if (dummy == NULL) {
+ free(dummy);
throw new std::bad_alloc;
}
memset(dummy, 0, sizeof(uint16_t));
- if (!GetBindInfo(tbl, dt_type, binfo, nattr))
+ if (!GetBindInfo(tbl, dt_type, binfo, nattr)) {
+ free(dummy);
return UPLL_RC_ERR_GENERIC;
+ }
for (int i = 0; i < nattr; i++) {
uint64_t indx = binfo[i].index;
BindStructTypes attr_type = binfo[i].struct_type;
if (attr_type != CS_VAL && attr_type != ST_VAL &&
- attr_type != ST_META_VAL &&
- (attr_type == CFG_META_VAL && indx != uudst::kDbiVtnCtrlrTbl)) {
+ attr_type != ST_META_VAL && (((attr_type == CFG_KEY)
+ || (uudst::kDbiVtnCtrlrTbl != index))
+ || ((CK_VAL == attr_type) && (uudst::kDbiVtnCtrlrTbl == index)))) {
+ UPLL_LOG_TRACE("Bind for attr type %d", attr_type);
db_info->BindMatch(indx, binfo[i].app_data_type,
binfo[i].array_size, dummy);
}
return UPLL_RC_SUCCESS;
}
+upll_rc_t MoMgrImpl::TxCopyRenameTableFromCandidateToRunning(
+ unc_key_type_t key_type,
+ unc_keytype_operation_t op,
+ DalDmlIntf* dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *can_ckv = NULL, *run_ckv = NULL;
+ DalCursor *cfg1_cursor;
+ DalResultCode db_result = uud::kDalRcSuccess;
+ if (op == UNC_OP_UPDATE) {
+ UPLL_LOG_TRACE("No action is performed for Update");
+ return UPLL_RC_SUCCESS;
+ }
+ result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op,
+ can_ckv, run_ckv, &cfg1_cursor, dmi, NULL, RENAMETBL, true);
+ while (result_code == UPLL_RC_SUCCESS) {
+ db_result = dmi->GetNextRecord(cfg1_cursor);
+ result_code = DalToUpllResCode(db_result);
+ if (result_code != UPLL_RC_SUCCESS)
+ break;
+ /* VRT and VBR sharing the same table so need not use
+ * VRT key type here */
+ switch (key_type) {
+ case UNC_KT_VTN: {
+ val_rename_vtn *ren_val = static_cast<val_rename_vtn *>(
+ GetVal(can_ckv));
+ ren_val->valid[UPLL_IDX_NEW_NAME_RVTN] = UNC_VF_VALID;
+ }
+ break;
+ case UNC_KT_VBRIDGE:
+ case UNC_KT_VLINK: {
+ val_rename_vnode *ren_val = static_cast<val_rename_vnode *>(
+ GetVal(can_ckv));
+ ren_val->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
+ ren_val->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_VALID;
+ }
+ break;
+ case UNC_KT_POLICING_PROFILE: {
+ val_rename_policingprofile_t *ren_val = static_cast
+ <val_rename_policingprofile_t *>(GetVal(can_ckv));
+ ren_val->valid[UPLL_IDX_RENAME_PROFILE_RPP] = UNC_VF_VALID;
+ }
+ break;
+ case UNC_KT_FLOWLIST: {
+ val_rename_flowlist_t *ren_val = static_cast
+ <val_rename_flowlist_t *>(GetVal(can_ckv));
+ ren_val->valid[UPLL_IDX_RENAME_FLOWLIST_RFL] = UNC_VF_VALID;
+ }
+ break;
+ default:
+ UPLL_LOG_DEBUG("No special operation for %u", key_type);
+ break;
+ }
+ // Copy Rename Table Info into Running
+ result_code = UpdateConfigDB(can_ckv, UPLL_DT_RUNNING, op, dmi, RENAMETBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ delete can_ckv; can_ckv = NULL;
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ UPLL_LOG_DEBUG("Returning error %d",result_code);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(can_ckv);
+ DELETE_IF_NOT_NULL(run_ckv);
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
+ UPLL_RC_SUCCESS : result_code;
+ return result_code;
+}
#if 0
template<typename T1, typename T2>
(GetMoManager(UNC_KT_VTUNNEL_IF)));
break;
default:
- UPLL_LOG_DEBUG("Unsupported operation on keytype %d\n",ktype);
+ UPLL_LOG_DEBUG("Unsupported operation on keytype %d",ktype);
return UPLL_RC_ERR_GENERIC;
}
result_code = mgr->GetChildConfigKey(ck_vn, NULL);
template upll_rc_t
MoMgrImpl::GetCkvWithOperSt<val_vtn_st_t,val_db_vtn_st_t> (ConfigKeyVal *&ck_vn, unc_key_type_t ktype, DalDmlIntf *dmi) ;
#else
-template<typename T1,typename T2>
+
upll_rc_t MoMgrImpl::GetUninitOperState(ConfigKeyVal *&ck_vn,
DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- ConfigVal *cval = NULL;
- /* Allocate Memory for vnode st */
- result_code = AllocVal(cval,UPLL_DT_STATE,MAINTBL);
+ result_code = GetCkvUninit(ck_vn, NULL, dmi);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d",result_code);
- return result_code;
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ return result_code;
}
- /* initialize vnode st */
- T2 *vnif_st = reinterpret_cast<T2 *>
- (cval->get_next_cfg_val()->get_val());
- if (!vnif_st) {
- delete cval;
- UPLL_LOG_DEBUG("Invalid param");
- return UPLL_RC_ERR_GENERIC;
- }
- T1 *vnif = reinterpret_cast<T1 *>(vnif_st);
- vnif->valid[UPLL_IDX_OPER_STATUS_VBRIS] = UNC_VF_VALID;
- vnif->oper_status = UPLL_OPER_STATUS_UNINIT;
- /* Create Vnode If child */
- result_code = GetChildConfigKey (ck_vn, NULL);
- if (UPLL_RC_SUCCESS != result_code) {
- free(vnif_st);
- UPLL_LOG_DEBUG("GetChildConfigKey Failed %d", result_code);
- return result_code;
- }
- ck_vn->AppendCfgVal(cval);
-
- /* Reading the Vnode Table and Check the Operstatus is unknown
- * for any one of the vnode if */
- DbSubOp dbop = { kOpReadExist | kOpReadMultiple, kOpMatchNone, kOpInOutFlag |
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutFlag |
kOpInOutCtrlr | kOpInOutDomain };
- if (PORT_MAPPED_KEYTYPE(ck_vn->get_key_type()))
- dbop.readop = kOpReadMultiple;
result_code = ReadConfigDB(ck_vn, UPLL_DT_STATE, UNC_OP_READ,
dbop, dmi, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
UPLL_RC_SUCCESS : result_code;
UPLL_LOG_DEBUG("Returning %d",result_code);
- if (ck_vn) delete ck_vn;
+ delete ck_vn;
ck_vn = NULL;
}
return result_code;
}
+
+upll_rc_t MoMgrImpl::GetCkvUninit(ConfigKeyVal *&ck_vn,
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+
+ if (ck_vn == NULL) {
+ ConfigVal *cval = NULL;
+ /* Create ckv of corresponding keytype */
+ result_code = GetChildConfigKey (ck_vn, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed %d", result_code);
+ return result_code;
+ }
+ /* Allocate Memory for vnode st */
+ result_code = AllocVal(cval,UPLL_DT_STATE,MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d",result_code);
+ DELETE_IF_NOT_NULL(ck_vn);
+ return result_code;
+ }
+ ck_vn->AppendCfgVal(cval);
+ }
+ /* initialize vnode st */
+ void *vnif = GetStateVal(ck_vn);
+ if (!vnif) {
+ UPLL_LOG_DEBUG("Invalid param\n");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ switch (ck_vn->get_key_type()) {
+ case UNC_KT_VTN:
+ {
+ val_vtn_st *vtnst = reinterpret_cast<val_vtn_st *>(vnif);
+ vtnst->valid[UPLL_IDX_OPER_STATUS_VBRIS] = UNC_VF_VALID;
+ vtnst->oper_status = UPLL_OPER_STATUS_UNINIT;
+ break;
+ }
+ case UNC_KT_VBRIDGE:
+ case UNC_KT_VROUTER:
+ case UNC_KT_VTUNNEL:
+ case UNC_KT_VTEP:
+ case UNC_KT_VLINK:
+ {
+ /* cast generically as vbr as all vnode st structures
+ * are the same and form the first field in the db st structure.
+ */
+ val_vbr_st *vnodest = reinterpret_cast<val_vbr_st *>(vnif);
+ vnodest->valid[UPLL_IDX_OPER_STATUS_VBRIS] = UNC_VF_VALID;
+ vnodest->oper_status = UPLL_OPER_STATUS_UNINIT;
+ break;
+ }
+ case UNC_KT_VBR_IF:
+ case UNC_KT_VRT_IF:
+ case UNC_KT_VTEP_IF:
+ case UNC_KT_VTUNNEL_IF:
+ {
+ /* cast generically as vbr_if as all vnodeif st structures
+ * are the same and form the first field in the db st structure.
+ */
+ val_vbr_if_st *vnifst = reinterpret_cast<val_vbr_if_st *>(vnif);
+ vnifst->valid[UPLL_IDX_OPER_STATUS_VBRIS] = UNC_VF_VALID;
+ vnifst->oper_status = UPLL_OPER_STATUS_UNINIT;
+ break;
+ }
+ default:
+ UPLL_LOG_DEBUG("Unsupported keytype\n");
+ DELETE_IF_NOT_NULL(ck_vn);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+#if 0
+ /* Reading the Vnode Table and Check the Operstatus is unknown
+ * for any one of the vnode if */
+ DbSubOp dbop = { kOpReadExist | kOpReadMultiple, kOpMatchNone, kOpInOutFlag |
+ kOpInOutCtrlr | kOpInOutDomain };
+ if (PORT_MAPPED_KEYTYPE(ck_vn->get_key_type()))
+ dbop.readop = kOpReadMultiple;
+#endif
+ return result_code;
+}
+
+upll_rc_t MoMgrImpl::BindImportDB(ConfigKeyVal *&ikey,
+ DalBindInfo *&db_info,
+ upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl ) {
+ UPLL_FUNC_TRACE;
+ int nattr = 0;
+ BindInfo *binfo;
+ ConfigVal *ck_val = NULL;
+ key_user_data *tuser_data = NULL;
+ if (!ikey || !(ikey->get_key())) {
+ UPLL_LOG_DEBUG("Input key is Empty");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ /* Allocate memeory for key user data to fetch
+ * controller, domain and rename flag */
+ AllocVal(ck_val, dt_type, RENAMETBL);
+ if(!ck_val) return UPLL_RC_ERR_GENERIC;
+ ikey->SetCfgVal(ck_val);
+ void *tval = ck_val->get_val();
+ if (!tval) return UPLL_RC_ERR_GENERIC;
+ GET_USER_DATA(ikey);
+ tuser_data = reinterpret_cast<key_user_data_t *>(ikey->get_user_data());
+
+ if (!tuser_data) {
+ UPLL_LOG_DEBUG("Memory Allocation Failed");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ void *tkey = ikey->get_key();
+ void *p = NULL;
+
+ if (!GetBindInfo(tbl, dt_type, binfo, nattr))
+ return UPLL_RC_ERR_GENERIC;
+
+ for (int i = 0; i < nattr; i++) {
+ uint64_t indx = binfo[i].index;
+ BindStructTypes attr_type = binfo[i].struct_type;
+
+ UPLL_LOG_TRACE("Attribute type is %d", attr_type);
+ if (CFG_KEY == attr_type) {
+ p = reinterpret_cast<void *>(reinterpret_cast<char *>(tkey)
+ + binfo[i].offset);
+ UPLL_LOG_TRACE("Attribute type is %d", attr_type);
+ if (IsValidKey(tkey, indx)) {
+ UPLL_LOG_TRACE("Key is valid ");
+ db_info->BindMatch(indx, binfo[i].app_data_type,
+ binfo[i].array_size, p);
+ }
+ }
+ if (CK_VAL == attr_type) {
+ /* For Domain and controller output */
+ UPLL_LOG_TRACE("Attribute type is %d", attr_type);
+ p = reinterpret_cast<void *>(reinterpret_cast<char *>(tuser_data)
+ + binfo[i].offset);
+ }
+ if (CFG_VAL == attr_type) {
+ UPLL_LOG_TRACE("Attribute type is %d", attr_type);
+ p = reinterpret_cast<void *>(reinterpret_cast<char *>(tval)
+ + binfo[i].offset);
+ }
+ if (p)
+ db_info->BindOutput(indx, binfo[i].app_data_type,
+ binfo[i].array_size, p);
+ }
+
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t MoMgrImpl::Getvalstnum(ConfigKeyVal *&ikey,
+ uui::IpctSt::IpcStructNum &struct_num) {
+
+ switch(ikey->get_key_type()) {
+ case UNC_KT_FLOWLIST:
+ struct_num = IpctSt::kIpcStValRenameFlowlist;
+ break;
+ case UNC_KT_POLICING_PROFILE:
+ struct_num = IpctSt::kIpcStValRenamePolicingprofile;
+ break;
+ case UNC_KT_VTN:
+ struct_num = IpctSt::kIpcStValRenameVtn;
+ break;
+ case UNC_KT_VBRIDGE:
+ struct_num = IpctSt::kIpcStValRenameVbr;
+ break;
+ case UNC_KT_VROUTER:
+ struct_num = IpctSt::kIpcStValRenameVrt;
+ break;
+ case UNC_KT_VLINK:
+ struct_num = IpctSt::kIpcStValRenameVlink;
+ break;
+ default:
+ struct_num = IpctSt::kIpcInvalidStNum;
+ break;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t MoMgrImpl::Swapvaltokey(ConfigKeyVal *&ikey,
+ uint8_t rename_flag) {
+ UPLL_FUNC_TRACE;
+ void *rename_val = NULL;
+ uint8_t temp_str[33];
+ void *rename = NULL;
+ uui::IpctSt::IpcStructNum struct_num = IpctSt::kIpcInvalidStNum;
+ if (!ikey || !(ikey->get_key())) {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ Getvalstnum(ikey, struct_num);
+ if (rename_flag != IMPORT_READ_FAILURE) {
+ switch (ikey->get_key_type()) {
+ case UNC_KT_FLOWLIST:
+ {
+ rename = reinterpret_cast<val_rename_flowlist_t *>(
+ ConfigKeyVal::Malloc(sizeof(val_rename_flowlist_t)));
+ rename_val = reinterpret_cast<val_rename_flowlist_t *>(GetVal(ikey));
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("Val is Empty");
+ free(rename);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (!rename_flag) {
+ if (!strcmp((const char *)reinterpret_cast<key_flowlist_t *>(ikey->get_key())->flowlist_name,
+ (const char *)reinterpret_cast<val_rename_vtn_t*>(rename_val)->new_name))
+ reinterpret_cast<val_rename_flowlist_t*>(rename)->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_INVALID;
+ }
+ else {
+ reinterpret_cast<val_rename_flowlist_t*>(rename)->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
+ }
+ /* copyt key to temp */
+ uuu::upll_strncpy (temp_str, reinterpret_cast<key_flowlist_t*>
+ (ikey->get_key())->flowlist_name,
+ (kMaxLenFlowListName+1));
+ /* Copy Controller name to key */
+ uuu::upll_strncpy( reinterpret_cast<key_flowlist_t *>(ikey->get_key())->flowlist_name,
+ reinterpret_cast<val_rename_flowlist_t* >(rename_val)->flowlist_newname,
+ (kMaxLenFlowListName+1));
+ /* Copy the UNC name to Val */
+ uuu::upll_strncpy ( reinterpret_cast<val_rename_flowlist_t*>(rename)->flowlist_newname, temp_str,
+ (kMaxLenFlowListName+1));
+ }
+ break;
+ case UNC_KT_POLICING_PROFILE:
+ {
+ rename = reinterpret_cast<val_rename_policingprofile_t *>(
+ ConfigKeyVal::Malloc(sizeof(val_rename_policingprofile_t)));
+ rename_val = reinterpret_cast<val_rename_policingprofile_t *>(GetVal(ikey));
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("Val is Empty");
+ free(rename);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (!rename_flag) {
+ if (!strcmp((const char *)reinterpret_cast<key_policingprofile *>(ikey->get_key())->policingprofile_name,
+ (const char *)reinterpret_cast<val_rename_vtn_t*>(rename_val)->new_name))
+ reinterpret_cast<val_rename_policingprofile_t*>(rename)->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_INVALID;
+ }
+ else {
+ reinterpret_cast<val_rename_policingprofile_t*>(rename)->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
+ }
+ /* copyt key to temp */
+ uuu::upll_strncpy (temp_str, reinterpret_cast<key_policingprofile_t*>
+ (ikey->get_key())->policingprofile_name,
+ (kMaxLenPolicingProfileName+1));
+ /* Copy Controller name to key */
+ uuu::upll_strncpy( reinterpret_cast<key_policingprofile_t *>
+ (ikey->get_key())->policingprofile_name,
+ reinterpret_cast<val_rename_policingprofile_t* >
+ (rename_val)->policingprofile_newname,
+ (kMaxLenPolicingProfileName+1));
+ /* Copy the UNC name to Val */
+ uuu::upll_strncpy ( reinterpret_cast<val_rename_policingprofile_t*>(rename)->policingprofile_newname, temp_str,
+ (kMaxLenPolicingProfileName+1));
+ }
+
+ break;
+ case UNC_KT_VTN:
+ {
+ rename = reinterpret_cast<val_rename_vtn_t *>(
+ ConfigKeyVal::Malloc(sizeof(val_rename_vtn_t)));
+ rename_val = reinterpret_cast<val_rename_vtn_t *>(GetVal(ikey));
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("Val is Empty");
+ free(rename);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (!rename_flag) {
+ if (!strcmp((const char *)reinterpret_cast<key_vtn_t *>(ikey->get_key())->vtn_name,
+ (const char *)reinterpret_cast<val_rename_vtn_t*>(rename_val)->new_name))
+ reinterpret_cast<val_rename_vtn_t*>(rename)->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_INVALID;
+ }
+ else {
+ reinterpret_cast<val_rename_vtn_t*>(rename)->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
+ }
+ /* copyt key to temp */
+ uuu::upll_strncpy (temp_str, reinterpret_cast<key_vtn_t*>
+ (ikey->get_key())->vtn_name,
+ (kMaxLenVtnName+1));
+ /* Copy Controller name to key */
+ uuu::upll_strncpy( reinterpret_cast<key_vtn_t *>
+ (ikey->get_key())->vtn_name,
+ reinterpret_cast<val_rename_vtn_t* >
+ (rename_val)->new_name,
+ (kMaxLenVtnName+1));
+ /* Copy the UNC name to Val */
+ uuu::upll_strncpy (reinterpret_cast<val_rename_vtn_t*>(rename)->new_name, temp_str,
+ (kMaxLenVtnName+1));
+ }
+ break;
+ case UNC_KT_VBRIDGE:
+ case UNC_KT_VROUTER:
+ case UNC_KT_VLINK:
+ {
+ rename = reinterpret_cast<val_rename_vtn_t *>(
+ ConfigKeyVal::Malloc(sizeof(val_rename_vtn_t)));
+ rename_val = reinterpret_cast<val_rename_vnode_t *>(GetVal(ikey));
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("Val is Empty");
+ free(rename);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (!strcmp((const char*)reinterpret_cast<key_vbr_t *>(ikey->get_key())->vbridge_name,
+ (const char *)reinterpret_cast<val_rename_vnode_t*>(rename_val)->ctrlr_vnode_name)) {
+ reinterpret_cast<val_rename_vtn_t*>(rename)->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_INVALID;
+ }
+ else {
+ reinterpret_cast<val_rename_vtn_t*>(rename)->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
+ }
+
+ /* copyt key to temp */
+ uuu::upll_strncpy (temp_str, reinterpret_cast<key_vbr_t*>
+ (ikey->get_key())->vbridge_name,
+ (kMaxLenVnodeName+1));
+
+ /* Copy Controller name to key */
+ uuu::upll_strncpy( reinterpret_cast<key_vbr_t *>
+ (ikey->get_key())->vtn_key.vtn_name,
+ reinterpret_cast<val_rename_vnode_t* >
+ (rename_val)->ctrlr_vtn_name,
+ (kMaxLenVtnName+1));
+ uuu::upll_strncpy( reinterpret_cast<key_vbr_t *>
+ (ikey->get_key())->vbridge_name,
+ reinterpret_cast<val_rename_vnode_t* >
+ (rename_val)->ctrlr_vnode_name,
+ (kMaxLenVnodeName+1));
+ /* Copy the UNC name to Val */
+ uuu::upll_strncpy ( reinterpret_cast<val_rename_vtn_t*>(rename)->new_name, temp_str,
+ (kMaxLenVnodeName+1));
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ ikey->SetCfgVal(new ConfigVal(struct_num, rename));
+ return UPLL_RC_SUCCESS;
+
+}
+
+
+upll_rc_t MoMgrImpl::SwapKey(ConfigKeyVal *&ikey,
+ uint8_t rename_flag) {
+ UPLL_FUNC_TRACE;
+ uui::IpctSt::IpcStructNum struct_num = IpctSt::kIpcInvalidStNum;
+ void *rename = NULL;
+ UPLL_LOG_TRACE("Before Swap Key %s %d", ikey->ToStrAll().c_str(),rename_flag);
+ if (rename_flag) {
+ Swapvaltokey(ikey, rename_flag);
+ } else {
+
+ Getvalstnum(ikey, struct_num);
+
+ switch (ikey->get_key_type()) {
+ case UNC_KT_FLOWLIST:
+ rename = reinterpret_cast
+ <val_rename_flowlist *>(ConfigKeyVal::Malloc
+ (sizeof(val_rename_flowlist)));
+ uuu::upll_strncpy(reinterpret_cast<val_rename_flowlist *>(rename)
+ ->flowlist_newname,
+ reinterpret_cast<key_flowlist_t*>(ikey->get_key())
+ ->flowlist_name, (kMaxLenFlowListName+1));
+ break;
+ case UNC_KT_POLICING_PROFILE:
+ rename = reinterpret_cast
+ <val_rename_policingprofile *>(
+ ConfigKeyVal::Malloc(sizeof(val_rename_policingprofile)));
+ uuu::upll_strncpy(reinterpret_cast<val_rename_policingprofile *>
+ (rename)->policingprofile_newname,
+ reinterpret_cast<key_policingprofile_t*>
+ (ikey->get_key())->policingprofile_name,
+ (kMaxLenPolicingProfileName+1));
+ break;
+ case UNC_KT_VTN:
+ rename = reinterpret_cast<val_rename_vtn_t *>(
+ ConfigKeyVal::Malloc(sizeof(val_rename_vtn_t)));
+ uuu::upll_strncpy(reinterpret_cast<val_rename_vtn_t *>
+ (rename)->new_name,
+ reinterpret_cast<key_vtn_t*>(ikey->get_key())->vtn_name,
+ (kMaxLenVtnName+1));
+ break;
+ case UNC_KT_VBRIDGE:
+ case UNC_KT_VROUTER:
+ case UNC_KT_VLINK:
+ rename = reinterpret_cast<val_rename_vtn_t *>(
+ ConfigKeyVal::Malloc(sizeof(val_rename_vtn_t)));
+ uuu::upll_strncpy(reinterpret_cast<val_rename_vtn_t *>
+ (rename)->new_name,
+ reinterpret_cast<key_vbr_t*>(ikey->get_key())->vbridge_name,
+ (kMaxLenVnodeName+1));
+ break;
+ default:
+ return UPLL_RC_ERR_GENERIC;
+ break;
+ }
+
+ reinterpret_cast<val_rename_vtn_t *>(rename)->valid
+ [UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_INVALID;
+ ikey->SetCfgVal(new ConfigVal(struct_num, rename));
+ }
+ UPLL_LOG_TRACE("AfterSwap Key %s", ikey->ToStrAll().c_str());
+ return UPLL_RC_SUCCESS;
+}
+
+
+std::string MoMgrImpl::GetReadImportQueryString(unc_keytype_operation_t op,
+ unc_key_type_t kt) const {
+ std::string query_string = "";
+ if (op == UNC_OP_READ_SIBLING) {
+ switch (kt) {
+ case UNC_KT_FLOWLIST:
+ query_string = \
+ " (select unc_flowlist_name, ctrlr_name, ctrlr_flowlist_name from "
+ " (select unc_flowlist_name, ctrlr_name, ctrlr_flowlist_name "
+ " from im_flowlist_rename_tbl "
+ " union all "
+ "select flowlist_name, ctrlr_name, flowlist_name from "
+ "im_flowlist_ctrlr_tbl where flags & 1 = 0 ) as temp "
+ "where ctrlr_flowlist_name > ?) "
+ " order by ctrlr_flowlist_name ";
+ break;
+ case UNC_KT_POLICING_PROFILE:
+ query_string = "(select unc_policingprofile_name, ctrlr_name, ctrlr_policingprofile_name from \
+ (select unc_policingprofile_name, ctrlr_name, ctrlr_policingprofile_name \
+ from im_policingprofile_rename_tbl union all select policingprofile_name,\
+ ctrlr_name, policingprofile_name from im_policingprofile_ctrlr_tbl \
+ where flags & 1 = 0 ) as temp where ctrlr_policingprofile_name > ?) \
+ order by ctrlr_policingprofile_name";
+ break;
+ case UNC_KT_VTN:
+ query_string = "(select unc_vtn_name, controller_name, domain_id, ctrlr_vtn_name from \
+ (select unc_vtn_name, controller_name, domain_id, ctrlr_vtn_name \
+ from im_vtn_rename_tbl union all select vtn_name,\
+ controller_name, domain_id, vtn_name from im_vtn_ctrlr_tbl \
+ where flags & 1 = 0 ) as temp where ctrlr_vtn_name > ?) order by ctrlr_vtn_name";
+ break;
+ case UNC_KT_VBRIDGE:
+ query_string = "(select unc_vtn_name, unc_vnode_name, controller_name, domain_id, "
+ "ctrlr_vtn_name, ctrlr_vnode_name from "
+ "(select unc_vtn_name, unc_vnode_name, controller_name, domain_id, "
+ "ctrlr_vtn_name, ctrlr_vnode_name from im_vnode_rename_tbl where "
+ "(unc_vtn_name, unc_vnode_name) IN (select vtn_name, vbridge_name "
+ "from im_vbr_tbl) "
+ "union all select vtn_name, vbridge_name, controller_name, domain_id, "
+ "vtn_name, vbridge_name from im_vbr_tbl where flags & 3 = 0) as temp where "
+ "ctrlr_vtn_name = ? and ctrlr_vnode_name > ?) order by ctrlr_vtn_name, ctrlr_vnode_name ";
+ break;
+ case UNC_KT_VROUTER:
+ query_string = "(select unc_vtn_name, unc_vnode_name, controller_name, domain_id, "
+ "ctrlr_vtn_name, ctrlr_vnode_name from "
+ "(select unc_vtn_name, unc_vnode_name, controller_name, domain_id, "
+ "ctrlr_vtn_name, ctrlr_vnode_name from im_vnode_rename_tbl where "
+ "(unc_vtn_name, unc_vnode_name) IN (select vtn_name, vrouter_name "
+ "from im_vrt_tbl) "
+ "union all select vtn_name, vrouter_name, controller_name, domain_id, "
+ "vtn_name, vrouter_name from im_vrt_tbl where flags & 3 = 0) as temp where "
+ "ctrlr_vtn_name = ? and ctrlr_vnode_name > ?) order by ctrlr_vtn_name, ctrlr_vnode_name ";
+ break;
+ case UNC_KT_VLINK:
+ query_string = "(select unc_vtn_name, unc_vlink_name, controller_name, domain_id, "
+ "ctrlr_vtn_name, ctrlr_vlink_name from "
+ "(select unc_vtn_name, unc_vlink_name, controller_name, domain_id, "
+ "ctrlr_vtn_name, ctrlr_vlink_name from im_vlink_rename_tbl "
+ "union all select vtn_name, vlink_name, controller1_name, domain1_id, "
+ "vtn_name, vlink_name from im_vlink_tbl where key_flags & 3 = 0) as temp where "
+ "ctrlr_vtn_name = ? and ctrlr_vlink_name > ?) order by ctrlr_vtn_name, ctrlr_vlink_name ";
+ break;
+ default:
+ break;
+ }
+ } else if (op == UNC_OP_READ_SIBLING_BEGIN) {
+ switch (kt) {
+ case UNC_KT_FLOWLIST:
+ query_string = "(select unc_flowlist_name, ctrlr_name, ctrlr_flowlist_name from im_flowlist_rename_tbl \
+ union all select flowlist_name, ctrlr_name, flowlist_name from im_flowlist_ctrlr_tbl \
+ where flags & 1 = 0) order by ctrlr_flowlist_name ";
+ break;
+ case UNC_KT_POLICING_PROFILE:
+ query_string = "(select unc_policingprofile_name, ctrlr_name, ctrlr_policingprofile_name from im_policingprofile_rename_tbl \
+ union all select policingprofile_name, ctrlr_name, policingprofile_name from im_policingprofile_ctrlr_tbl \
+ where flags & 1 = 0) order by ctrlr_policingprofile_name";
+ break;
+ case UNC_KT_VTN:
+ query_string = "(select unc_vtn_name, controller_name, domain_id, \
+ ctrlr_vtn_name from im_vtn_rename_tbl union all \
+ select vtn_name, controller_name, domain_id, vtn_name \
+ from im_vtn_ctrlr_tbl where flags & 1 = 0) \
+ order by ctrlr_vtn_name ";
+ break;
+ case UNC_KT_VBRIDGE:
+ query_string = "(select unc_vtn_name, unc_vnode_name, controller_name, domain_id, "
+ "ctrlr_vtn_name, ctrlr_vnode_name from "
+ "(select unc_vtn_name, unc_vnode_name, controller_name, domain_id, "
+ "ctrlr_vtn_name, ctrlr_vnode_name from im_vnode_rename_tbl where "
+ "(unc_vtn_name, unc_vnode_name) IN (select vtn_name, vbridge_name "
+ "from im_vbr_tbl) "
+ "union all select vtn_name, vbridge_name, controller_name, domain_id, "
+ "vtn_name, vbridge_name from im_vbr_tbl where flags & 3 = 0) as temp where "
+ "ctrlr_vtn_name = ?) order by ctrlr_vtn_name, ctrlr_vnode_name ";
+ break;
+ case UNC_KT_VROUTER:
+ query_string = "(select unc_vtn_name, unc_vnode_name, controller_name, domain_id, "
+ "ctrlr_vtn_name, ctrlr_vnode_name from "
+ "(select unc_vtn_name, unc_vnode_name, controller_name, domain_id, "
+ "ctrlr_vtn_name, ctrlr_vnode_name from im_vnode_rename_tbl where "
+ "(unc_vtn_name, unc_vnode_name) IN (select vtn_name, vrouter_name "
+ "from im_vrt_tbl) "
+ "union all select vtn_name, vrouter_name, controller_name, domain_id, "
+ "vtn_name, vrouter_name from im_vrt_tbl where flags & 3 = 0) as temp where "
+ "ctrlr_vtn_name = ?) order by ctrlr_vtn_name, ctrlr_vnode_name ";
+ break;
+ case UNC_KT_VLINK:
+ query_string = "(select unc_vtn_name, unc_vlink_name, controller_name, domain_id, "
+ "ctrlr_vtn_name, ctrlr_vlink_name from "
+ "(select unc_vtn_name, unc_vlink_name, controller_name, domain_id, "
+ "ctrlr_vtn_name, ctrlr_vlink_name from im_vlink_rename_tbl "
+ "union all select vtn_name, vlink_name, controller1_name, domain1_id, "
+ "vtn_name, vlink_name from im_vlink_tbl where key_flags & 3 = 0) as temp where "
+ "ctrlr_vtn_name = ? ) order by ctrlr_vtn_name, ctrlr_vlink_name ";
+ break;
+ default:
+ break;
+ }
+ }
+ return query_string;
+}
+
+upll_rc_t MoMgrImpl::ReadImportDB (ConfigKeyVal *&in_key,
+ IpcReqRespHeader *header,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ uint8_t rename = 0;
+ uint32_t count = 0;
+ ConfigKeyVal *ikey = NULL;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ result_code = GetChildConfigKey(ikey, in_key);
+ if (UPLL_RC_SUCCESS != result_code)
+ return result_code;
+ const uudst::kDalTableIndex tbl_index = GetTable(RENAMETBL, header->datatype);
+ void *tkey = (ikey)?ikey->get_key():NULL;
+ if (!tkey) {
+ delete ikey;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (tbl_index >= uudst::kDalNumTables) {
+ UPLL_LOG_DEBUG(" Invalid Table index - %d", tbl_index);
+ delete ikey;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ DalCursor *dal_cursor_handle;
+ UPLL_LOG_TRACE("tbl_index is %d", tbl_index);
+ unc_keytype_operation_t op = header->operation;
+
+ if (!READ_OP(op)) {
+ UPLL_LOG_INFO("Exiting MoMgrImpl::ReadConfigDB");
+ delete ikey;
+ return UPLL_RC_ERR_GENERIC;
+ }
+#if 0
+ uint16_t max_record_count = 1;
+ result_code = GetRenamedUncKey( ikey, header->datatype,
+ dmi, NULL);
+ if (UPLL_RC_SUCCESS != result_code &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey is Failed %d", result_code);
+ return result_code;
+ }
+#endif
+
+ if (op == UNC_OP_READ_SIBLING_BEGIN || op == UNC_OP_READ_SIBLING) {
+ DalBindInfo *dal_bind_info = new DalBindInfo(tbl_index);
+ result_code = BindImportDB(ikey, dal_bind_info, header->datatype,
+ RENAMETBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (dal_bind_info) delete dal_bind_info;
+ UPLL_LOG_INFO("Exiting MoMgrImpl::ReadConfigDB result code %d",
+ result_code);
+ delete ikey;
+ return result_code;
+ }
+ std::string query_string = GetReadImportQueryString(op, ikey->get_key_type());
+ if (query_string.empty()) {
+ UPLL_LOG_TRACE("Null Query String for Operation(%d) KeyType(%d)",
+ op, ikey->get_key_type());
+ if (dal_bind_info) delete dal_bind_info;
+ delete ikey;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = DalToUpllResCode(
+ dmi->ExecuteAppQueryMultipleRecords(query_string, header->rep_count,
+ dal_bind_info, &dal_cursor_handle));
+ ConfigKeyVal *end_resp = NULL;
+ bool flag = false;
+ while (result_code == UPLL_RC_SUCCESS && ((count < header->rep_count) ||
+ (header->rep_count == 0))) {
+ result_code = DalToUpllResCode(dmi->GetNextRecord(dal_cursor_handle));
+ if (UPLL_RC_SUCCESS == result_code) {
+ ConfigKeyVal *tkey = NULL;
+ val_rename_vtn_t *val = (ikey)?reinterpret_cast<val_rename_vtn_t*>
+ (GetVal(ikey)):NULL;
+ if (val) {
+ val->valid[UPLL_IDX_NEW_NAME_RVTN] = UNC_VF_VALID;
+ }
+ UPLL_LOG_TRACE("GetNextRecord %s", ikey->ToStrAll().c_str());
+ result_code = DupConfigKeyVal(tkey, ikey, RENAMETBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Dup failed error %d",result_code);
+ delete ikey;
+ delete dal_bind_info;
+ dmi->CloseCursor(dal_cursor_handle);
+ return result_code;
+ }
+ flag = true;
+ rename = 0;
+ result_code = UpdateConfigDB(tkey, header->datatype, UNC_OP_READ,
+ dmi, RENAMETBL);
+ if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS)
+ rename = 1;
+ else if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ delete ikey;
+ dmi->CloseCursor(dal_cursor_handle);
+ delete dal_bind_info;
+ DELETE_IF_NOT_NULL(tkey);
+ return result_code;
+ }
+ result_code = SwapKey(tkey, rename);
+ UPLL_LOG_TRACE("After No SwapKey %s", ikey->ToStrAll().c_str());
+ ConfigKeyVal *prev_key = tkey;
+ if (!end_resp)
+ end_resp = tkey;
+ else
+ prev_key->AppendCfgKeyVal(tkey);
+ count++;
+ UPLL_LOG_TRACE("end_resp %s", end_resp->ToStrAll().c_str());
+ }
+ }
+ header->rep_count = count;
+ result_code = (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code && flag)?
+ UPLL_RC_SUCCESS:result_code;
+ dmi->CloseCursor(dal_cursor_handle);
+ delete dal_bind_info;
+ if (result_code == UPLL_RC_SUCCESS) {
+ if (end_resp)
+ ikey->ResetWith(end_resp);
+ DELETE_IF_NOT_NULL(end_resp);
+ in_key->ResetWith(ikey);
+ DELETE_IF_NOT_NULL(ikey);
+ UPLL_LOG_TRACE("ResetWith is Called");
+ } else {
+ delete ikey;
+ return result_code;
+ }
+ } else if (op == UNC_OP_READ) {
+#if 0 // tbl is set, but not used.
+ MoMgrTables tbl = MAINTBL;
+ if (UNC_KT_VTN == ikey->get_key_type() ||
+ UNC_KT_FLOWLIST == ikey->get_key_type() ||
+ UNC_KT_POLICING_PROFILE == ikey->get_key_type())
+ tbl = CTRLRTBL;
+#endif
+ /* We are not allow to read using the UNC Name
+ */
+#if 1
+ DbSubOp dbop = { kOpReadExist, kOpMatchNone, kOpInOutNone};
+
+ ConfigKeyVal *temp = NULL;
+ result_code = DupConfigKeyVal (temp, ikey, RENAMETBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal Failed");
+ return result_code;
+ }
+ result_code = UpdateConfigDB(temp, header->datatype, UNC_OP_READ,
+ dmi, &dbop, RENAMETBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(temp);
+ return result_code;
+ }
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ UPLL_LOG_DEBUG("Read Not allowed by using UNC Name");
+ delete ikey;
+ DELETE_IF_NOT_NULL(temp);
+ return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ }
+ DELETE_IF_NOT_NULL(temp);
+#endif
+ rename = 0;
+ result_code = GetRenamedUncKey( ikey, header->datatype,
+ dmi, NULL);
+ if (UPLL_RC_SUCCESS != result_code &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey is Failed %d", result_code);
+ delete ikey;
+ return result_code;
+ }
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ result_code = UpdateConfigDB(ikey, header->datatype, UNC_OP_READ,
+ dmi, MAINTBL);
+ if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
+ UPLL_LOG_DEBUG("VTN doesn't exist in IMPORT DB. Error code : %d",
+ result_code);
+ delete ikey;
+ return result_code;
+ } else
+ result_code = UPLL_RC_SUCCESS;
+ ikey->SetCfgVal(NULL);
+ } else {
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutNone};
+ result_code = ReadConfigDB(ikey, header->datatype, header->operation,
+ dbop, dmi, RENAMETBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ delete ikey;
+ return result_code;
+ }
+ rename = 1;
+ }
+ result_code = SwapKey(ikey, rename);
+ UPLL_LOG_TRACE("After No SwapKey %s", ikey->ToStrAll().c_str());
+ in_key->ResetWith(ikey);
+ delete ikey;
+ } else {
+ UPLL_LOG_TRACE("Unexpected Operation : %d", op);
+ delete ikey;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ return result_code;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#if 0
template upll_rc_t
MoMgrImpl::GetUninitOperState<val_vlink_st_t,val_db_vlink_st_t>
(ConfigKeyVal *&ck_vn, DalDmlIntf *dmi) ;
MoMgrImpl::GetUninitOperState<val_vbr_if_st_t,val_db_vbr_if_st_t>
(ConfigKeyVal *&ck_vn, DalDmlIntf *dmi) ;
template upll_rc_t
+MoMgrImpl::GetUninitOperState<val_vrt_if_st_t,val_db_vrt_if_st_t>
+ (ConfigKeyVal *&ck_vn, DalDmlIntf *dmi) ;
+template upll_rc_t
MoMgrImpl::GetUninitOperState<val_vrt_st_t,val_db_vrt_st_t>
(ConfigKeyVal *&ck_vn, DalDmlIntf *dmi) ;
template upll_rc_t
MoMgrImpl::GetUninitOperState<val_vtn_st_t,val_db_vtn_st_t>
(ConfigKeyVal *&ck_vn, DalDmlIntf *dmi);
#endif
+#endif
} // namespace kt_momgr
*/
#include "nwm_host_momgr.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "nwm_momgr.hh"
#define NUM_KEY_MAIN_TBL_ 6
}
bool NwMonitorHostMoMgr::IsValidKey(void *key, uint64_t index) {
+ UPLL_FUNC_TRACE;
key_nwm_host *nwmh_key = reinterpret_cast<key_nwm_host *>(key);
- UPLL_LOG_DEBUG("Entering IsValidKey");
uint32_t val = 0;
- bool ret_val = UPLL_RC_SUCCESS;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
switch (index) {
case uudst::vbridge_networkmonitor_host::kDbiVtnName:
ret_val = ValidateKey(
UPLL_LOG_INFO("Invalid Key Index");
return false;
}
- UPLL_LOG_DEBUG("Leaving IsValidKey");
return true;
}
void *pkey;
if (parent_key == NULL || !(parent_key->get_key())) {
UPLL_LOG_DEBUG("parentkey is Null");
- nwmh_key = reinterpret_cast<key_nwm_host *>(malloc(sizeof(key_nwm_host)));
- memset(nwmh_key, 0, sizeof(key_nwm_host));
+ nwmh_key = reinterpret_cast<key_nwm_host *>(
+ ConfigKeyVal::Malloc(sizeof(key_nwm_host)));
+ if (okey) delete okey;
okey = new ConfigKeyVal(UNC_KT_VBR_NWMONITOR_HOST, IpctSt::kIpcStKeyNwmHost,
nwmh_key, NULL);
return UPLL_RC_SUCCESS;
return UPLL_RC_ERR_GENERIC;
nwmh_key = reinterpret_cast<key_nwm_host *>(okey->get_key());
} else {
- nwmh_key = reinterpret_cast<key_nwm_host *>(malloc(sizeof(key_nwm_host)));
- memset(nwmh_key, 0, sizeof(key_nwm_host));
+ nwmh_key = reinterpret_cast<key_nwm_host *>(
+ ConfigKeyVal::Malloc(sizeof(key_nwm_host)));
}
unc_key_type_t keytype = parent_key->get_key_type();
switch (keytype) {
uuu::upll_strncpy(nwmh_key->nwm_key.nwmonitor_name,
reinterpret_cast<key_nwm *>(pkey)->nwmonitor_name,
(kMaxLenNwmName + 1));
- nwmh_key->host_address.s_addr = 0;
break;
case UNC_KT_VBR_NWMONITOR_HOST:
uuu::upll_strncpy(nwmh_key->nwm_key.vbr_key.vtn_key.vtn_name,
if (!okey)
okey = new ConfigKeyVal(UNC_KT_VBR_NWMONITOR_HOST, IpctSt::kIpcStKeyNwmHost,
nwmh_key, NULL);
+ else if (okey->get_key() != nwmh_key)
+ okey->SetKey(IpctSt::kIpcStKeyNwmHost, nwmh_key);
+
if (okey == NULL) {
free(nwmh_key);
result_code = UPLL_RC_ERR_GENERIC;
key_nwm_host *pkey = reinterpret_cast<key_nwm_host *>
(ikey->get_key());
if (!pkey) return UPLL_RC_ERR_GENERIC;
- key_nwm *nwm_key = reinterpret_cast<key_nwm *>(malloc(sizeof(key_nwm)));
- if (!nwm_key) return UPLL_RC_ERR_GENERIC;
- memset(nwm_key, 0, sizeof(key_nwm));
+ key_nwm *nwm_key = reinterpret_cast<key_nwm *>(
+ ConfigKeyVal::Malloc(sizeof(key_nwm)));
uuu::upll_strncpy(nwm_key->vbr_key.vtn_key.vtn_name,
reinterpret_cast<key_nwm_host *>(pkey)->nwm_key.vbr_key.vtn_key.vtn_name,
(kMaxLenVtnName + 1));
uuu::upll_strncpy(nwm_key->nwmonitor_name,
reinterpret_cast<key_nwm_host *>(pkey)->nwm_key.nwmonitor_name,
(kMaxLenNwmName + 1));
+ if (okey) delete okey;
okey = new ConfigKeyVal(UNC_KT_VBR_NWMONITOR, IpctSt::kIpcStKeyNwm, nwm_key,
NULL);
if (okey == NULL) {
- if (nwm_key) free(nwm_key);
+ free(nwm_key);
result_code = UPLL_RC_ERR_GENERIC;
} else {
SET_USER_DATA(okey, ikey);
if (ck_val != NULL) return UPLL_RC_ERR_GENERIC;
switch (tbl) {
case MAINTBL:
- val = malloc(sizeof(val_nwm_host));
- if (!val) return UPLL_RC_ERR_GENERIC;
- memset(val, 0, sizeof(val_nwm_host));
+ val = ConfigKeyVal::Malloc(sizeof(val_nwm_host));
ck_val = new ConfigVal(IpctSt::kIpcStValNwmHost, val);
if (dt_type == UPLL_DT_STATE) {
- val = malloc(sizeof(val_nwm_host_st));
- if (!val) return UPLL_RC_ERR_GENERIC;
- memset(val, 0, sizeof(val_nwm_host_st));
+ val = ConfigKeyVal::Malloc(sizeof(val_nwm_host_st));
ConfigVal *ck_nxtval = new ConfigVal(IpctSt::kIpcStValNwmHostSt, val);
ck_val->AppendCfgVal(ck_nxtval);
}
if (req->get_key_type() != UNC_KT_VBR_NWMONITOR_HOST)
return UPLL_RC_ERR_GENERIC;
ConfigVal *tmp1 = NULL, *tmp = (req)->get_cfg_val();
- if (NULL == tmp) {
- return UPLL_RC_ERR_GENERIC;
- }
if (tmp) {
if (tbl == MAINTBL) {
val_nwm_host *ival = reinterpret_cast<val_nwm_host *>(GetVal(req));
+ if (ival == NULL) {
+ UPLL_LOG_DEBUG("NULL val structure");
+ return UPLL_RC_ERR_GENERIC;
+ }
val_nwm_host *nwm_val = reinterpret_cast<val_nwm_host *>
- (malloc(sizeof(val_nwm_host)));
+ (ConfigKeyVal::Malloc(sizeof(val_nwm_host)));
memcpy(nwm_val, ival, sizeof(val_nwm_host));
tmp1 = new ConfigVal(IpctSt::kIpcStValNwmHost, nwm_val);
}
if (tbl == MAINTBL) {
val_nwm_host_st *ival = reinterpret_cast<val_nwm_host_st *>
(tmp->get_val());
+ if (ival == NULL) {
+ UPLL_LOG_DEBUG("NULL val structure");
+ delete tmp1;
+ return UPLL_RC_ERR_GENERIC;
+ }
val_nwm_host_st *val_nwmst = new val_nwm_host_st(*ival);
ConfigVal *tmp2 = new ConfigVal(IpctSt::kIpcStValNwmHostSt, val_nwmst);
tmp1->AppendCfgVal(tmp2);
}
};
- void *tkey = (req != NULL) ? (req)->get_key() : NULL;
+ void *tkey = req->get_key();
if (!tkey) {
+ delete tmp1;
return UPLL_RC_ERR_GENERIC;
}
key_nwm_host *ikey = reinterpret_cast<key_nwm_host *>(tkey);
key_nwm_host *nwm_key = reinterpret_cast<key_nwm_host *>
- (malloc(sizeof(key_nwm_host)));
+ (ConfigKeyVal::Malloc(sizeof(key_nwm_host)));
memcpy(nwm_key, ikey, sizeof(key_nwm_host));
okey = new ConfigKeyVal(UNC_KT_VBR_NWMONITOR_HOST, IpctSt::kIpcStKeyNwmHost,
nwm_key, tmp1);
ConfigKeyVal *ctrlr_key) {
UPLL_FUNC_TRACE;
val_nwm_host *nwm_val = reinterpret_cast<val_nwm_host_t*>(GetVal(ikey));
+ val_nwm_host *nwm_val2 = reinterpret_cast<val_nwm_host *>(GetVal(upd_key));
unc_keytype_configstatus_t cs_status =
(driver_result == 0) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
if (nwm_val == NULL) return UPLL_RC_ERR_GENERIC;
- nwm_val->cs_row_status = cs_status;
- if (op == UNC_OP_UPDATE) {
+ UPLL_LOG_TRACE("Key in Candidate %s", (ikey->ToStrAll()).c_str());
+ if (op == UNC_OP_CREATE) {
+ nwm_val->cs_row_status = cs_status;
+ } else if (op == UNC_OP_UPDATE) {
void *val = reinterpret_cast<void*>(nwm_val);
CompareValidValue(val, GetVal(upd_key), true);
- } else if (op != UNC_OP_CREATE) {
+ UPLL_LOG_TRACE("Key in Running %s",(upd_key->ToStrAll()).c_str());
+ nwm_val->cs_row_status = nwm_val2->cs_row_status;
+ } else {
return UPLL_RC_ERR_GENERIC;
}
for (unsigned int loop = 0;
if ((UNC_VF_VALID == (uint8_t) nwm_val->valid[loop])
|| (UNC_VF_VALID_NO_VALUE == (uint8_t) nwm_val->valid[loop])) {
nwm_val->cs_attr[loop] = cs_status;
- } else if (UNC_VF_NOT_SOPPORTED == (uint8_t) nwm_val->valid[loop]) {
- nwm_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
+ } else if ((UNC_VF_INVALID == nwm_val->valid[loop]) &&
+ (UNC_OP_CREATE == op)) {
+ nwm_val->cs_attr[loop] = UNC_CS_NOT_APPLIED;
+ } else if ((UNC_VF_INVALID == nwm_val->valid[loop]) &&
+ (UNC_OP_UPDATE == op)) {
+ nwm_val->cs_attr[loop] = nwm_val2->cs_attr[loop];
}
}
return UPLL_RC_SUCCESS;
if (UNC_VF_VALID == valnwmhost1->valid[UPLL_IDX_HEALTH_INTERVAL_NWMH]
&& UNC_VF_VALID == valnwmhost2->valid[UPLL_IDX_HEALTH_INTERVAL_NWMH]) {
if (valnwmhost1->health_interval == valnwmhost2->health_interval)
- valnwmhost1->valid[UPLL_IDX_HEALTH_INTERVAL_NWMH] = UNC_VF_INVALID;
+ valnwmhost1->valid[UPLL_IDX_HEALTH_INTERVAL_NWMH] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (UNC_VF_VALID == valnwmhost1->valid[UPLL_IDX_RECOVERY_INTERVAL_NWMH]
&& UNC_VF_VALID == valnwmhost2->valid[UPLL_IDX_RECOVERY_INTERVAL_NWMH]) {
if (valnwmhost1->recovery_interval == valnwmhost2->recovery_interval)
- valnwmhost1->valid[UPLL_IDX_RECOVERY_INTERVAL_NWMH] = UNC_VF_INVALID;
+ valnwmhost1->valid[UPLL_IDX_RECOVERY_INTERVAL_NWMH] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (UNC_VF_VALID == valnwmhost1->valid[UPLL_IDX_FAILURE_COUNT_NWMH]
&& UNC_VF_VALID == valnwmhost2->valid[UPLL_IDX_FAILURE_COUNT_NWMH]) {
if (valnwmhost1->failure_count == valnwmhost2->failure_count)
- valnwmhost1->valid[UPLL_IDX_FAILURE_COUNT_NWMH] = UNC_VF_INVALID;
+ valnwmhost1->valid[UPLL_IDX_FAILURE_COUNT_NWMH] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (UNC_VF_VALID == valnwmhost1->valid[UPLL_IDX_RECOVERY_COUNT_NWMH]
&& UNC_VF_VALID == valnwmhost2->valid[UPLL_IDX_RECOVERY_COUNT_NWMH]) {
if (valnwmhost1->recovery_count == valnwmhost2->recovery_count)
- valnwmhost1->valid[UPLL_IDX_RECOVERY_COUNT_NWMH] = UNC_VF_INVALID;
+ valnwmhost1->valid[UPLL_IDX_RECOVERY_COUNT_NWMH] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (UNC_VF_VALID == valnwmhost1->valid[UPLL_IDX_WAIT_TIME_NWMH]
&& UNC_VF_VALID == valnwmhost2->valid[UPLL_IDX_WAIT_TIME_NWMH]) {
if (valnwmhost1->wait_time == valnwmhost2->wait_time)
- valnwmhost1->valid[UPLL_IDX_WAIT_TIME_NWMH] = UNC_VF_INVALID;
+ valnwmhost1->valid[UPLL_IDX_WAIT_TIME_NWMH] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
for (unsigned int loop = 0;
loop < (sizeof(valnwmhost1->valid) / sizeof(valnwmhost1->valid[0]));
++loop) {
if ((UNC_VF_VALID == (uint8_t) valnwmhost1->valid[loop])
- || (UNC_VF_VALID == (uint8_t) valnwmhost2->valid[loop]))
+ || (UNC_VF_VALID_NO_VALUE == (uint8_t) valnwmhost1->valid[loop])) {
invalid_attr = false;
+ break;
+ }
}
return invalid_attr;
}
return UPLL_RC_ERR_GENERIC;
}
if (uuc::kUpllUcpCreate == phase) val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
for (unsigned int loop = 0; loop < sizeof(val->valid) / sizeof(uint8_t);
++loop) {
if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
key_rename_vnode_info *key_rename =
reinterpret_cast<key_rename_vnode_info *>(ikey->get_key());
- key_nwm_host_t * key_vwm = static_cast<key_nwm_host_t *>(malloc(sizeof(key_nwm_host_t)));
+ key_nwm_host_t * key_vwm = static_cast<key_nwm_host_t *>(
+ ConfigKeyVal::Malloc(sizeof(key_nwm_host_t)));
// key_nwm_host, nwm_key.vbr_key.vtn_key.vtn_name
- if (!key_vwm) return UPLL_RC_ERR_GENERIC;
- memset(key_vwm, 0 , sizeof(key_nwm_host_t));
if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vtn_name))) {
free(key_vwm);
return UPLL_RC_ERR_GENERIC;
uuu::upll_strncpy(key_vwm->nwm_key.vbr_key.vtn_key.vtn_name,
key_rename->old_unc_vtn_name, (kMaxLenVtnName + 1));
if (ikey->get_key_type() == UNC_KT_VBRIDGE) {
- if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vnode_name)))
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vnode_name))) {
+ free(key_vwm);
return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(key_vwm->nwm_key.vbr_key.vbridge_name,
key_rename->old_unc_vnode_name, (kMaxLenVnodeName + 1));
+ } else {
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_unc_vnode_name))) {
+ FREE_IF_NOT_NULL(key_vwm);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(key_vwm->nwm_key.vbr_key.vbridge_name,
+ key_rename->new_unc_vnode_name, (kMaxLenVnodeName+1));
}
okey = new ConfigKeyVal(UNC_KT_VBR_NWMONITOR_HOST, IpctSt::kIpcStKeyNwmHost,
key_vwm, NULL);
return result_code;
}
upll_rc_t NwMonitorHostMoMgr::ValidateMessage(IpcReqRespHeader *req,
- ConfigKeyVal *ikey) {
+ ConfigKeyVal *ikey) {
UPLL_FUNC_TRACE;
upll_rc_t ret_val = UPLL_RC_SUCCESS;
- if (NULL == req) {
- UPLL_LOG_DEBUG("IpcReqRespHeader is NULL");
- return UPLL_RC_ERR_GENERIC;
- }
- if (ikey == NULL) {
- UPLL_LOG_DEBUG("ConfigKeyVal is NULL");
- return UPLL_RC_ERR_GENERIC;
+ if (!ikey || !req || !(ikey->get_key())) {
+ UPLL_LOG_DEBUG("IpcReqRespHeader or ConfigKeyVal is Null");
+ return UPLL_RC_ERR_BAD_REQUEST;
}
+
unc_key_type_t keytype = ikey->get_key_type();
if (UNC_KT_VBR_NWMONITOR_HOST != keytype) {
UPLL_LOG_DEBUG("Invalid keytype. Keytype- %d", keytype);
- return UPLL_RC_ERR_GENERIC;
+ return UPLL_RC_ERR_BAD_REQUEST;
}
if ((ikey->get_st_num()) != IpctSt::kIpcStKeyNwmHost) {
UPLL_LOG_DEBUG(
"Invalid structure received.Expected struct-kIpcStKeyNwmHost,"
"received struct -%d ",
(ikey->get_st_num()));
- return UPLL_RC_ERR_GENERIC;
+ return UPLL_RC_ERR_BAD_REQUEST;
}
key_nwm_host_t *key_nwm_host =
- reinterpret_cast<key_nwm_host_t *>(ikey->get_key());
+ reinterpret_cast<key_nwm_host_t *>(ikey->get_key());
val_nwm_host_t *val_nwm_host = NULL;
if ((ikey->get_cfg_val())
&& ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValNwmHost)) {
val_nwm_host =
- reinterpret_cast<val_nwm_host_t *>(ikey->get_cfg_val()->get_val());
+ reinterpret_cast<val_nwm_host_t *>(ikey->get_cfg_val()->get_val());
}
upll_keytype_datatype_t dt_type = req->datatype;
unc_keytype_operation_t operation = req->operation;
if (key_nwm_host == NULL) {
UPLL_LOG_DEBUG("key structure is empty!!");
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ return UPLL_RC_ERR_BAD_REQUEST;
}
ret_val = ValidateNwMonHostKey(key_nwm_host, operation);
if (ret_val != UPLL_RC_SUCCESS) {
return UPLL_RC_ERR_CFG_SYNTAX;
} else {
if (((operation == UNC_OP_CREATE) || (operation == UNC_OP_UPDATE))
- && ((dt_type == UPLL_DT_CANDIDATE)|| (UPLL_DT_IMPORT == dt_type))) {
+ && ((dt_type == UPLL_DT_CANDIDATE)||(UPLL_DT_IMPORT == dt_type))) {
if (val_nwm_host != NULL) {
ret_val = ValidateNwMonHostValue(val_nwm_host, operation);
if (ret_val != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Syntax check failed for VBR_NWMONITOR_HOST");
return UPLL_RC_ERR_CFG_SYNTAX;
- } else {
- pfc_log_trace("Syntax check success for VBR_NWMONITOR_HOST");
- return UPLL_RC_SUCCESS;
}
+ return UPLL_RC_SUCCESS;
} else {
UPLL_LOG_DEBUG("Value structure is mandatory");
return UPLL_RC_ERR_CFG_SYNTAX;
}
} else if (((operation == UNC_OP_READ) || (operation == UNC_OP_READ_SIBLING)
- || (operation == UNC_OP_READ_SIBLING_BEGIN)
- || (operation == UNC_OP_READ_SIBLING_COUNT))
+ || (operation == UNC_OP_READ_SIBLING_BEGIN)
+ || (operation == UNC_OP_READ_SIBLING_COUNT))
&& ((dt_type == UPLL_DT_CANDIDATE) || (dt_type == UPLL_DT_RUNNING)
- || (dt_type == UPLL_DT_STARTUP))) {
+ || (dt_type == UPLL_DT_STARTUP) || (dt_type == UPLL_DT_STATE))) {
if (option1 == UNC_OPT1_NORMAL) {
if (option2 == UNC_OPT2_NONE) {
if (val_nwm_host != NULL) {
if (ret_val != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Syntax check failed for NWMONITOR_HOST");
return UPLL_RC_ERR_CFG_SYNTAX;
- } else {
- pfc_log_trace("Syntax check success for VBR_NWMONITOR_HOST");
- return UPLL_RC_SUCCESS;
}
- } else {
- UPLL_LOG_DEBUG("Value structure is optional");
return UPLL_RC_SUCCESS;
- }
- } else {
- UPLL_LOG_DEBUG("option2 is not matching");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- } else {
- UPLL_LOG_DEBUG("option1 is not matching");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
-
- } else if (((operation == UNC_OP_READ_SIBLING_COUNT)
- || (operation == UNC_OP_READ) || (operation == UNC_OP_READ_SIBLING)
- || (operation == UNC_OP_READ_SIBLING_BEGIN))
- && (dt_type == UPLL_DT_STATE)) {
- if (option1 == UNC_OPT1_NORMAL) {
- if (option2 == UNC_OPT2_NONE) {
- if (val_nwm_host != NULL) {
- ret_val = ValidateNwMonHostValue(val_nwm_host);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Syntax check failed for NWMONITOR_HOST");
- return UPLL_RC_ERR_CFG_SYNTAX;
- } else {
- pfc_log_trace("Syntax check success for NWMONITOR_HOST");
- return UPLL_RC_SUCCESS;
- }
} else {
UPLL_LOG_DEBUG("Value structure is optional");
return UPLL_RC_SUCCESS;
}
} else if ((operation == UNC_OP_DELETE) || (operation == UNC_OP_READ_NEXT)
|| (operation == UNC_OP_READ_BULK)) {
- pfc_log_trace("Value structure is none for operation type:%d", operation);
+ UPLL_LOG_TRACE("Value structure is none for operation type:%d", operation);
return UPLL_RC_SUCCESS;
} else {
UPLL_LOG_DEBUG("Invalid datatype(%d) and operation(%d)", dt_type,
- operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ operation);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
}
+ return UPLL_RC_SUCCESS;
}
upll_rc_t NwMonitorHostMoMgr::ValidateNwMonHostValue(
val_nwm_host_t *val_nwm_host, unc_keytype_operation_t operation) {
if (val_nwm_host->valid[UPLL_IDX_HEALTH_INTERVAL_NWMH] == UNC_VF_VALID) {
if (!ValidateNumericRange(val_nwm_host->health_interval,
- (uint16_t) kMinNWMHHealthInterval,
- uint16_t(kMaxNWMHHealthInterval), true, true)) {
+ (uint16_t) kMinNWMHHealthInterval,
+ uint16_t(kMaxNWMHHealthInterval), true, true)) {
UPLL_LOG_DEBUG("Syntax check failed.health_interval(%d)",
- val_nwm_host->health_interval);
+ val_nwm_host->health_interval);
return UPLL_RC_ERR_CFG_SYNTAX;
}
}
#if 0
else if ((val_nwm_host->valid[UPLL_IDX_HEALTH_INTERVAL_NWMH]
- == UNC_VF_VALID_NO_VALUE)
+ == UNC_VF_VALID_NO_VALUE)
&& ((operation == UNC_OP_UPDATE) || (operation == UNC_OP_CREATE))) {
val_nwm_host->health_interval = 0;
}
if (val_nwm_host->valid[UPLL_IDX_RECOVERY_INTERVAL_NWMH] == UNC_VF_VALID) {
if (!ValidateNumericRange(val_nwm_host->recovery_interval,
- (uint16_t) kMinNWMHRecoveryInterval,
- (uint16_t) kMaxNWMHRecoveryInterval, true,
- true)) {
+ (uint16_t) kMinNWMHRecoveryInterval,
+ (uint16_t) kMaxNWMHRecoveryInterval, true,
+ true)) {
UPLL_LOG_DEBUG("Syntax check failed.recovery_interval:(%d)",
- val_nwm_host->recovery_interval);
+ val_nwm_host->recovery_interval);
return UPLL_RC_ERR_CFG_SYNTAX;
}
}
#if 0
else if ((val_nwm_host->valid[UPLL_IDX_RECOVERY_INTERVAL_NWMH]
- == UNC_VF_VALID_NO_VALUE)
+ == UNC_VF_VALID_NO_VALUE)
&& ((operation == UNC_OP_UPDATE) || (operation == UNC_OP_CREATE))) {
val_nwm_host->recovery_interval = 0;
}
if (val_nwm_host->valid[UPLL_IDX_FAILURE_COUNT_NWMH] == UNC_VF_VALID) {
if (!ValidateNumericRange(val_nwm_host->failure_count,
- (uint8_t) kMinNWMHFailureCount,
- (uint8_t) kMaxNWMHFailureCount, true, true)) {
+ (uint8_t) kMinNWMHFailureCount,
+ (uint8_t) kMaxNWMHFailureCount, true, true)) {
UPLL_LOG_DEBUG("Syntax check failed.failure_count(%d)",
- val_nwm_host->failure_count);
+ val_nwm_host->failure_count);
return UPLL_RC_ERR_CFG_SYNTAX;
}
}
#if 0
else if ((val_nwm_host->valid[UPLL_IDX_FAILURE_COUNT_NWMH]
- == UNC_VF_VALID_NO_VALUE)
+ == UNC_VF_VALID_NO_VALUE)
&& ((operation == UNC_OP_UPDATE) || (operation == UNC_OP_CREATE))) {
val_nwm_host->failure_count = 0;
}
if (val_nwm_host->valid[UPLL_IDX_RECOVERY_COUNT_NWMH] == UNC_VF_VALID) {
if (!ValidateNumericRange(val_nwm_host->recovery_count,
- (uint8_t) kMinNWMHRecoveryCount,
- (uint8_t) kMaxNWMHRecoveryCount, true, true)) {
+ (uint8_t) kMinNWMHRecoveryCount,
+ (uint8_t) kMaxNWMHRecoveryCount, true, true)) {
UPLL_LOG_DEBUG("Syntax check failed.recovery_count(%d)",
- val_nwm_host->recovery_count);
+ val_nwm_host->recovery_count);
return UPLL_RC_ERR_CFG_SYNTAX;
}
}
#if 0
else if ((val_nwm_host->valid[UPLL_IDX_RECOVERY_COUNT_NWMH]
- == UNC_VF_VALID_NO_VALUE)
+ == UNC_VF_VALID_NO_VALUE)
&& ((operation == UNC_OP_UPDATE) || (operation == UNC_OP_CREATE))) {
val_nwm_host->recovery_count = 0;
}
if (val_nwm_host->valid[UPLL_IDX_WAIT_TIME_NWMH] == UNC_VF_VALID) {
if (!ValidateNumericRange(val_nwm_host->wait_time,
- (uint8_t) kMinNWMHWaitTime,
- (uint8_t) kMaxNWMHWaitTime, true, true)) {
+ (uint8_t) kMinNWMHWaitTime,
+ (uint8_t) kMaxNWMHWaitTime, true, true)) {
UPLL_LOG_DEBUG("Syntax check failed.wait_time(%d)",
- val_nwm_host->wait_time);
+ val_nwm_host->wait_time);
return UPLL_RC_ERR_CFG_SYNTAX;
}
}
#if 0
else if ((val_nwm_host->valid[UPLL_IDX_WAIT_TIME_NWMH]
- == UNC_VF_VALID_NO_VALUE)
+ == UNC_VF_VALID_NO_VALUE)
&& ((operation == UNC_OP_UPDATE) || (operation == UNC_OP_CREATE))) {
val_nwm_host->wait_time = 0;
}
#endif
- pfc_log_trace("Value structure validation successful for NWMONITOR_HOST");
return UPLL_RC_SUCCESS;
}
UPLL_FUNC_TRACE;
bool ret_val = UPLL_RC_SUCCESS;
NwMonitorMoMgr *objnwmmgr =
- reinterpret_cast<NwMonitorMoMgr*>(const_cast<MoManager *>(GetMoManager(
- UNC_KT_VBR_NWMONITOR)));
+ reinterpret_cast<NwMonitorMoMgr*>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_VBR_NWMONITOR)));
if (NULL == objnwmmgr) {
UPLL_LOG_DEBUG("unable to get NwMonitorMoMgr");
return UPLL_RC_ERR_GENERIC;
return UPLL_RC_ERR_CFG_SYNTAX;
}
if ((operation == UNC_OP_READ_SIBLING_BEGIN) ||
- (operation == UNC_OP_READ_SIBLING_COUNT)) {
-
+ (operation == UNC_OP_READ_SIBLING_COUNT)) {
+
key_nwm_host->host_address.s_addr = 0x00000000;
}
return UPLL_RC_SUCCESS;
}
upll_rc_t NwMonitorHostMoMgr::ValNwMonHostAttributeSupportCheck(
- const char * crtlr_name, ConfigKeyVal *ikey, uint32_t operation) {
+ val_nwm_host_t *val_nwm_host,
+ const uint8_t* attrs, unc_keytype_operation_t operation) {
UPLL_FUNC_TRACE;
- bool result_code = false;
- uint32_t max_instance_count = 0;
- uint32_t num_attrs = 0;
- const uint8_t *attrs = 0;
- if (ikey == NULL) {
- UPLL_LOG_DEBUG("ConfigKeyVal is NULL");
- return UPLL_RC_ERR_GENERIC;
- }
- val_nwm_host_t *val_nwm_host = NULL;
- if ((ikey->get_cfg_val())
- && (ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValNwmHost) {
- val_nwm_host =
- reinterpret_cast<val_nwm_host_t *>(ikey->get_cfg_val()->get_val());
- }
- if (val_nwm_host != NULL) {
- switch (operation) {
- case UNC_OP_CREATE:
- result_code = GetCreateCapability(crtlr_name, ikey->get_key_type(),
- &max_instance_count, &num_attrs,
- &attrs);
- if (result_code && cur_instance_count >= max_instance_count) {
- UPLL_LOG_DEBUG("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
- __LINE__, __FUNCTION__, cur_instance_count,
- max_instance_count);
- return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
- }
- break;
-
- case UNC_OP_UPDATE:
- result_code = GetUpdateCapability(crtlr_name, ikey->get_key_type(),
- &num_attrs, &attrs);
- break;
-
- case UNC_OP_READ:
- case UNC_OP_READ_SIBLING:
- case UNC_OP_READ_SIBLING_BEGIN:
- case UNC_OP_READ_SIBLING_COUNT:
- result_code = GetReadCapability(crtlr_name, ikey->get_key_type(),
- &num_attrs, &attrs);
- break;
-
- default:
- UPLL_LOG_DEBUG("Invalid operation");
- break;
- }
-
- if (!result_code) {
- UPLL_LOG_DEBUG("key_type - %d is not supported by controller - %s",
- ikey->get_key_type(), crtlr_name);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
- }
- if ((val_nwm_host->valid[UPLL_IDX_HEALTH_INTERVAL_NWMH] == UNC_VF_VALID)
- || (val_nwm_host->valid[UPLL_IDX_HEALTH_INTERVAL_NWMH]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::nwm_host::kCapHealthInterval] == 0) {
- val_nwm_host->valid[UPLL_IDX_HEALTH_INTERVAL_NWMH] =
- UNC_VF_NOT_SOPPORTED;
+ if ((val_nwm_host->valid[UPLL_IDX_HEALTH_INTERVAL_NWMH] == UNC_VF_VALID)
+ || (val_nwm_host->valid[UPLL_IDX_HEALTH_INTERVAL_NWMH]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::nwm_host::kCapHealthInterval] == 0) {
+ val_nwm_host->valid[UPLL_IDX_HEALTH_INTERVAL_NWMH] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
UPLL_LOG_DEBUG("HealthInterval not supported in pfc controller");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
}
- if ((val_nwm_host->valid[UPLL_IDX_RECOVERY_INTERVAL_NWMH] == UNC_VF_VALID)
- || (val_nwm_host->valid[UPLL_IDX_RECOVERY_INTERVAL_NWMH]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::nwm_host::kCapRecoveryInterval] == 0) {
- val_nwm_host->valid[UPLL_IDX_RECOVERY_INTERVAL_NWMH] =
- UNC_VF_NOT_SOPPORTED;
+ }
+ if ((val_nwm_host->valid[UPLL_IDX_RECOVERY_INTERVAL_NWMH] == UNC_VF_VALID)
+ || (val_nwm_host->valid[UPLL_IDX_RECOVERY_INTERVAL_NWMH]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::nwm_host::kCapRecoveryInterval] == 0) {
+ val_nwm_host->valid[UPLL_IDX_RECOVERY_INTERVAL_NWMH] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
UPLL_LOG_DEBUG("RecoveryInterval not supported in pfc controller");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
}
- if ((val_nwm_host->valid[UPLL_IDX_FAILURE_COUNT_NWMH] == UNC_VF_VALID)
- || (val_nwm_host->valid[UPLL_IDX_FAILURE_COUNT_NWMH]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::nwm_host::kCapFailureCount] == 0) {
- val_nwm_host->valid[UPLL_IDX_FAILURE_COUNT_NWMH] = UNC_VF_NOT_SOPPORTED;
+ }
+ if ((val_nwm_host->valid[UPLL_IDX_FAILURE_COUNT_NWMH] == UNC_VF_VALID)
+ || (val_nwm_host->valid[UPLL_IDX_FAILURE_COUNT_NWMH]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::nwm_host::kCapFailureCount] == 0) {
+ val_nwm_host->valid[UPLL_IDX_FAILURE_COUNT_NWMH] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
UPLL_LOG_DEBUG("FailureCount not supported in pfc controller");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
}
- if ((val_nwm_host->valid[UPLL_IDX_RECOVERY_COUNT_NWMH] == UNC_VF_VALID)
- || (val_nwm_host->valid[UPLL_IDX_RECOVERY_COUNT_NWMH]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::nwm_host::kCapRecoveryCount] == 0) {
- val_nwm_host->valid[UPLL_IDX_RECOVERY_COUNT_NWMH] =
- UNC_VF_NOT_SOPPORTED;
+ }
+ if ((val_nwm_host->valid[UPLL_IDX_RECOVERY_COUNT_NWMH] == UNC_VF_VALID)
+ || (val_nwm_host->valid[UPLL_IDX_RECOVERY_COUNT_NWMH]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::nwm_host::kCapRecoveryCount] == 0) {
+ val_nwm_host->valid[UPLL_IDX_RECOVERY_COUNT_NWMH] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
UPLL_LOG_DEBUG("RecoveryCount not supported in pfc controller");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
}
- if ((val_nwm_host->valid[UPLL_IDX_WAIT_TIME_NWMH] == UNC_VF_VALID)
- || (val_nwm_host->valid[UPLL_IDX_WAIT_TIME_NWMH]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::nwm_host::kCapWaitTime] == 0) {
- val_nwm_host->valid[UPLL_IDX_WAIT_TIME_NWMH] = UNC_VF_NOT_SOPPORTED;
+ }
+ if ((val_nwm_host->valid[UPLL_IDX_WAIT_TIME_NWMH] == UNC_VF_VALID)
+ || (val_nwm_host->valid[UPLL_IDX_WAIT_TIME_NWMH]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::nwm_host::kCapWaitTime] == 0) {
+ val_nwm_host->valid[UPLL_IDX_WAIT_TIME_NWMH] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
UPLL_LOG_DEBUG("WaitTime not supported in pfc controller");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
}
- } else {
- UPLL_LOG_DEBUG("Value structure is empty");
- return UPLL_RC_ERR_GENERIC;
}
- pfc_log_trace("Attrbutes supported in PFC controller");
return UPLL_RC_SUCCESS;
}
upll_rc_t NwMonitorHostMoMgr::ValidateCapability(IpcReqRespHeader *req,
- ConfigKeyVal *ikey,
- const char * ctrlr_name) {
+ ConfigKeyVal *ikey,
+ const char * ctrlr_name) {
UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- if (NULL == req) {
- UPLL_LOG_DEBUG("IpcReqRespHeader is NULL");
- return UPLL_RC_ERR_GENERIC;
- }
- if (ikey == NULL) {
- UPLL_LOG_DEBUG("ConfigKeyVal is NULL");
+ if (!ikey || !req ) {
+ UPLL_LOG_DEBUG("ConfigKeyVal / IpcReqRespHeader is Null");
return UPLL_RC_ERR_GENERIC;
}
- if (!ctrlr_name) ctrlr_name = reinterpret_cast<char *>(ikey->get_user_data());
- pfc_log_trace("controller name (%s)", ctrlr_name);
- upll_keytype_datatype_t dt_type = req->datatype;
- unc_keytype_operation_t operation = req->operation;
- unc_keytype_option1_t option1 = req->option1;
- unc_keytype_option2_t option2 = req->option2;
- if (((operation == UNC_OP_CREATE) || (operation == UNC_OP_UPDATE))
- && (dt_type == UPLL_DT_CANDIDATE)) {
- if (GetVal(ikey) != NULL) {
- result_code = ValNwMonHostAttributeSupportCheck(ctrlr_name, ikey,
- operation);
- if (result_code == UPLL_RC_SUCCESS) {
- pfc_log_trace("Attribute validation successful (%d)", result_code);
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Attribute validation failure (%d)", result_code);
- return result_code;
- }
- } else {
- UPLL_LOG_DEBUG("Value structure is mandatory");
- return UPLL_RC_ERR_CFG_SEMANTIC;
- }
- } else if (((operation == UNC_OP_READ) || (operation == UNC_OP_READ_SIBLING)
- || (operation == UNC_OP_READ_SIBLING_BEGIN)
- || (operation == UNC_OP_READ_SIBLING_COUNT))
- && ((dt_type == UPLL_DT_CANDIDATE) || (dt_type == UPLL_DT_RUNNING)
- || (dt_type == UPLL_DT_STARTUP))) {
- if (option1 == UNC_OPT1_NORMAL) {
- if (option2 == UNC_OPT2_NONE) {
- if ((GetVal(ikey)) != NULL) {
- result_code = ValNwMonHostAttributeSupportCheck(ctrlr_name, ikey,
- operation);
- if (result_code == UPLL_RC_SUCCESS) {
- pfc_log_trace("Attribute validation successful (%d)", result_code);
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Attribute validation failure (%d)", result_code);
- return UPLL_RC_ERR_CFG_SEMANTIC;
- }
- } else {
- UPLL_LOG_DEBUG("value structure is optional");
- return UPLL_RC_SUCCESS;
- }
- } else {
- UPLL_LOG_DEBUG("option2 is not matching");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- } else {
- UPLL_LOG_DEBUG("option1 is not matching");
- return UPLL_RC_ERR_INVALID_OPTION1;
+ if (!ctrlr_name) {
+ ctrlr_name = reinterpret_cast<char*>((reinterpret_cast<key_user_data_t *>
+ (ikey->get_user_data()))->ctrlr_id);
+ if (!ctrlr_name || !strlen(ctrlr_name)) {
+ UPLL_LOG_DEBUG("Controller Name is NULL");
+ return UPLL_RC_ERR_GENERIC;
}
- } else if (((operation == UNC_OP_READ_SIBLING_COUNT)
- || (operation == UNC_OP_READ) || (operation == UNC_OP_READ_SIBLING)
- || (operation == UNC_OP_READ_SIBLING_BEGIN))
- && (dt_type == UPLL_DT_STATE)) {
- if (option1 == UNC_OPT1_NORMAL) {
- if (option2 == UNC_OPT2_NONE) {
- if ((GetVal(ikey)) != NULL) {
- result_code = ValNwMonHostAttributeSupportCheck(ctrlr_name, ikey,
- operation);
- if (result_code == UPLL_RC_SUCCESS) {
- pfc_log_trace("Attribute validation successful (%d)", result_code);
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Attribute validation failure (%d)", result_code);
- return UPLL_RC_ERR_CFG_SEMANTIC;
- }
- } else {
- UPLL_LOG_DEBUG("value structure is optional");
- return UPLL_RC_SUCCESS;
- }
- } else {
- UPLL_LOG_DEBUG("option2 is not matching");
- return UPLL_RC_ERR_INVALID_OPTION2;
+ }
+
+ UPLL_LOG_TRACE("ctrlr_name(%s), operation : (%d)",
+ ctrlr_name, req->operation);
+
+ bool result_code = false;
+ uint32_t max_instance_count = 0;
+ uint32_t max_attrs = 0;
+ const uint8_t *attrs = 0;
+
+ switch (req->operation) {
+ case UNC_OP_CREATE:
+ result_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_instance_count, &max_attrs,
+ &attrs);
+ if (result_code && (max_instance_count != 0) &&
+ cur_instance_count >= max_instance_count) {
+ UPLL_LOG_DEBUG("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
+ __LINE__, __FUNCTION__, cur_instance_count,
+ max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
}
+ break;
+
+ case UNC_OP_UPDATE:
+ result_code = GetUpdateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ break;
+
+ case UNC_OP_READ:
+ case UNC_OP_READ_SIBLING:
+ case UNC_OP_READ_SIBLING_BEGIN:
+ case UNC_OP_READ_SIBLING_COUNT:
+ result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ break;
+
+ default:
+ UPLL_LOG_DEBUG("Invalid operation");
+ break;
+ }
+ if (!result_code) {
+ UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s) "
+ "for operation(%d)",
+ ikey->get_key_type(), ctrlr_name, req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ val_nwm_host_t *val_nwm_host = NULL;
+ if ((ikey->get_cfg_val())
+ && (ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValNwmHost) {
+ val_nwm_host =
+ reinterpret_cast<val_nwm_host_t *>(ikey->get_cfg_val()->get_val());
+ }
+ if (val_nwm_host) {
+ if (max_attrs > 0) {
+ return ValNwMonHostAttributeSupportCheck(val_nwm_host, attrs, req->operation);
} else {
- UPLL_LOG_DEBUG("option1 is not matching");
- return UPLL_RC_ERR_INVALID_OPTION1;
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d", req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
- } else if ((operation == UNC_OP_DELETE) || (operation == UNC_OP_READ_NEXT)
- || (operation == UNC_OP_READ_BULK)) {
- pfc_log_trace("Value structure is none for operation type:%d", operation);
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Invalid datatype(%d) and operation(%d)", dt_type, operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
}
+ return UPLL_RC_SUCCESS;
}
upll_rc_t NwMonitorHostMoMgr::GetControllerDomainId(ConfigKeyVal *ikey,
upll_rc_t result_code = mgr->ReadConfigDB(ikey, dt_type, UNC_OP_READ,
dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ UPLL_LOG_DEBUG("Returning error %d",result_code);
return result_code;
}
GET_USER_DATA_CTRLR_DOMAIN(ikey,*ctrlr_dom);
if ((!ctrlr_dom->ctrlr || !ctrlr_dom->domain))
return UPLL_RC_ERR_GENERIC;
- UPLL_LOG_DEBUG("ctrlr %s domain %s\n",ctrlr_dom->ctrlr,ctrlr_dom->domain);
+ UPLL_LOG_DEBUG("ctrlr %s domain %s",ctrlr_dom->ctrlr,ctrlr_dom->domain);
return UPLL_RC_SUCCESS;
}
* associated attributes are supported on the given controller,
* based on the valid flag.
*
- * @param[in] crtlr_name Controller name.
- * @param[in] ikey Corresponding key and value structure.
+ * @param[in] val_nwm_host Value Structure.
+ * @param[in] attr pointer to controller attribute
+ * @param[in] operation Operation Name
*
* @retval UPLL_RC_SUCCESS validation succeeded.
* @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
* @retval UPLL_RC_ERR_GENERIC Generic failure.
*/
- upll_rc_t ValNwMonHostAttributeSupportCheck(const char * crtlr_name,
- ConfigKeyVal *ikey,
- uint32_t operation);
+ upll_rc_t ValNwMonHostAttributeSupportCheck(val_nwm_host_t *val_nwm_host,
+ const uint8_t* attrs, unc_keytype_operation_t operation);
upll_rc_t IsReferenced(ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi);
*/
#include "nwm_momgr.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "vbr_momgr.hh"
+#include "vtn_momgr.hh"
#define NUM_KEY_MAIN_TBL_ 6
namespace unc {
key_nwm, nwmonitor_name),
uud::kDalChar, kMaxLenVnodeName + 1 },
{ uudst::vbridge_networkmonitor_group::kDbiVtnName, CFG_INPUT_KEY, offsetof(
- key_nwm, vbr_key.vtn_key.vtn_name),
+ key_rename_vnode_info_t, new_unc_vtn_name),
uud::kDalChar, kMaxLenVtnName + 1 },
{ uudst::vbridge_networkmonitor_group::kDbiVbrName, CFG_INPUT_KEY, offsetof(
- key_nwm, vbr_key.vbridge_name),
+ key_rename_vnode_info_t, new_unc_vnode_name),
uud::kDalChar, kMaxLenVnodeName + 1 },
{ uudst::vbridge_networkmonitor_group::kDbiFlags, CK_VAL, offsetof(
key_user_data, flags),
}
bool NwMonitorMoMgr::IsValidKey(void *key, uint64_t index) {
+ UPLL_FUNC_TRACE;
key_nwm *nwm_key = reinterpret_cast<key_nwm *>(key);
- pfc_log_info("Entering IsValidKey");
- bool ret_val = UPLL_RC_SUCCESS;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
switch (index) {
case uudst::vbridge_networkmonitor_group::kDbiVtnName:
ret_val = ValidateKey(reinterpret_cast<char *>
(nwm_key->vbr_key.vtn_key.vtn_name),
kMinLenVtnName, kMaxLenVtnName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_info("VTN Name is not valid(%d)", ret_val);
+ UPLL_LOG_INFO("VTN Name is not valid(%d)", ret_val);
return false;
}
break;
(nwm_key->vbr_key.vbridge_name),
kMinLenVnodeName, kMaxLenVnodeName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_info("VBridge Name is not valid(%d)", ret_val);
+ UPLL_LOG_INFO("VBridge Name is not valid(%d)", ret_val);
return false;
}
break;
(nwm_key->nwmonitor_name), kMinLenNwmName,
kMaxLenNwmName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_info("NwMonitor Name is not valid(%d)", ret_val);
+ UPLL_LOG_INFO("NwMonitor Name is not valid(%d)", ret_val);
return false;
}
break;
default:
- pfc_log_info("Invalid Key Index");
+ UPLL_LOG_INFO("Invalid Key Index");
break;
}
- pfc_log_info("Leaving IsValidKey");
return true;
}
key_nwm *nwm_key;
void *pkey;
if (parent_key == NULL) {
- nwm_key = reinterpret_cast<key_nwm *>(malloc(sizeof(key_nwm)));
- if (!nwm_key) return UPLL_RC_ERR_GENERIC;
- memset(nwm_key, 0, sizeof(key_nwm));
+ nwm_key = reinterpret_cast<key_nwm *>(
+ ConfigKeyVal::Malloc(sizeof(key_nwm)));
+ if (okey) delete okey;
okey = new ConfigKeyVal(UNC_KT_VBR_NWMONITOR, IpctSt::kIpcStKeyNwm, nwm_key,
NULL);
return UPLL_RC_SUCCESS;
return UPLL_RC_ERR_GENERIC;
nwm_key = reinterpret_cast<key_nwm *>(okey->get_key());
} else {
- nwm_key = reinterpret_cast<key_nwm *>(malloc(sizeof(key_nwm)));
- if (!nwm_key) return UPLL_RC_ERR_GENERIC;
- memset(nwm_key, 0, sizeof(key_nwm));
+ nwm_key = reinterpret_cast<key_nwm *>(
+ ConfigKeyVal::Malloc(sizeof(key_nwm)));
}
unc_key_type_t keytype = parent_key->get_key_type();
switch (keytype) {
if (!okey)
okey = new ConfigKeyVal(UNC_KT_VBR_NWMONITOR, IpctSt::kIpcStKeyNwm, nwm_key,
NULL);
+ else if (okey->get_key() != nwm_key)
+ okey->SetKey(IpctSt::kIpcStKeyNwm, nwm_key);
if (okey == NULL) {
free(nwm_key);
- result_code = UPLL_RC_ERR_GENERIC;
- } else {
- SET_USER_DATA(okey, parent_key);
+ return UPLL_RC_ERR_GENERIC;
}
+ SET_USER_DATA(okey, parent_key);
return result_code;
}
if (ikey_type != UNC_KT_VBR_NWMONITOR) return UPLL_RC_ERR_GENERIC;
key_nwm *pkey = reinterpret_cast<key_nwm *>(ikey->get_key());
if (!pkey) return UPLL_RC_ERR_GENERIC;
- key_vbr *vbr_key = reinterpret_cast<key_vbr *>(malloc(sizeof(key_vbr)));
- if (!vbr_key) return UPLL_RC_ERR_GENERIC;
- memset(vbr_key, 0, sizeof(key_vbr));
+ key_vbr *vbr_key = reinterpret_cast<key_vbr *>(
+ ConfigKeyVal::Malloc(sizeof(key_vbr)));
uuu::upll_strncpy(vbr_key->vtn_key.vtn_name,
reinterpret_cast<key_nwm *>(pkey)->vbr_key.vtn_key.vtn_name,
(kMaxLenVtnName + 1));
uuu::upll_strncpy(vbr_key->vbridge_name,
reinterpret_cast<key_nwm *>(pkey)->vbr_key.vbridge_name,
(kMaxLenVnodeName + 1));
+ if (okey) delete okey;
okey = new ConfigKeyVal(UNC_KT_VBRIDGE, IpctSt::kIpcStKeyVbr, vbr_key, NULL);
- if (okey == NULL) {
- free(vbr_key);
- result_code = UPLL_RC_ERR_GENERIC;
- } else {
- SET_USER_DATA(okey, ikey);
- }
+ SET_USER_DATA(okey, ikey);
return result_code;
}
if (ck_val != NULL) return UPLL_RC_ERR_GENERIC;
switch (tbl) {
case MAINTBL:
- val = malloc(sizeof(val_nwm));
- if (!val) return UPLL_RC_ERR_GENERIC;
- memset(val, 0, sizeof(val_nwm));
+ val = ConfigKeyVal::Malloc(sizeof(val_nwm));
ck_val = new ConfigVal(IpctSt::kIpcStValNwm, val);
if (dt_type == UPLL_DT_STATE) {
- val = malloc(sizeof(val_nwm_st));
- if (!val) return UPLL_RC_ERR_GENERIC;
- memset(val, 0, sizeof(val_nwm_st));
+ val = ConfigKeyVal::Malloc(sizeof(val_nwm_st));
ConfigVal *ck_nxtval = new ConfigVal(IpctSt::kIpcStValNwmSt, val);
ck_val->AppendCfgVal(ck_nxtval);
}
if (tmp) {
if (tbl == MAINTBL) {
val_nwm *ival = reinterpret_cast<val_nwm *>(GetVal(req));
- val_nwm *nwm_val = reinterpret_cast<val_nwm *>(malloc(sizeof(val_nwm)));
- if (!nwm_val) return UPLL_RC_ERR_GENERIC;
+ val_nwm *nwm_val = reinterpret_cast<val_nwm *>(
+ ConfigKeyVal::Malloc(sizeof(val_nwm)));
memcpy(nwm_val, ival, sizeof(val_nwm));
tmp1 = new ConfigVal(IpctSt::kIpcStValNwm, nwm_val);
}
if (tmp) {
if (tbl == MAINTBL) {
val_nwm_st *ival = reinterpret_cast<val_nwm_st *>(tmp->get_val());
- val_nwm_st *val_nwmst =
- reinterpret_cast<val_nwm_st *>(malloc(sizeof(val_nwm_st)));
- if (!val_nwmst) {
- /* Addressed RESOURCE_LEAK */
- DELETE_IF_NOT_NULL(tmp1);
- return UPLL_RC_ERR_GENERIC;
- }
+ val_nwm_st *val_nwmst = reinterpret_cast<val_nwm_st *>(
+ ConfigKeyVal::Malloc(sizeof(val_nwm_st)));
memcpy(val_nwmst, ival, sizeof(val_nwm_st));
ConfigVal *tmp2 = new ConfigVal(IpctSt::kIpcStValNwmSt, val_nwmst);
tmp1->AppendCfgVal(tmp2);
};
void *tkey = (req != NULL) ? (req)->get_key() : NULL;
key_nwm *ikey = reinterpret_cast<key_nwm *>(tkey);
- key_nwm *nwm_key = reinterpret_cast<key_nwm *>(malloc(sizeof(key_nwm)));
+ key_nwm *nwm_key = reinterpret_cast<key_nwm *>(
+ ConfigKeyVal::Malloc(sizeof(key_nwm)));
if (!ikey || !nwm_key) {
- UPLL_LOG_INFO("Invalid params\n");
+ UPLL_LOG_INFO("Invalid params");
/* Addressed RESOURCE_LEAK */
FREE_IF_NOT_NULL(nwm_key);
DELETE_IF_NOT_NULL(tmp1);
if (okey) {
SET_USER_DATA(okey, req);
} else {
- delete tmp1;
+ DELETE_IF_NOT_NULL(tmp1);
+ FREE_IF_NOT_NULL(nwm_key);
}
return UPLL_RC_SUCCESS;
}
return UPLL_RC_ERR_GENERIC;
}
val_nwm *nwm_val = reinterpret_cast<val_nwm_t *>(GetVal(ikey));
+ val_nwm *nwm_val2 = reinterpret_cast<val_nwm *>(GetVal(upd_key));
+ UPLL_LOG_TRACE("Key in Candidate %s", (ikey->ToStrAll()).c_str());
unc_keytype_configstatus_t cs_status =
(driver_result == 0) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
if (nwm_val == NULL) return UPLL_RC_ERR_GENERIC;
- nwm_val->cs_row_status = cs_status;
- if (op == UNC_OP_UPDATE) {
+ if (op == UNC_OP_CREATE) {
+ nwm_val->cs_row_status = cs_status;
+ } else if (op == UNC_OP_UPDATE) {
void *val = reinterpret_cast<void*>(nwm_val);
CompareValidValue(val, GetVal(upd_key), true);
- } else if (op != UNC_OP_CREATE) {
+ UPLL_LOG_TRACE("Key in Running %s", (upd_key->ToStrAll()).c_str());
+ nwm_val->cs_row_status = nwm_val2->cs_row_status;
+ } else {
return UPLL_RC_ERR_GENERIC;
}
for (unsigned int loop = 0;
loop < (sizeof(nwm_val->valid) / sizeof(nwm_val->valid[0]));
++loop) {
- if (nwm_val->valid[loop] != UNC_VF_NOT_SOPPORTED) {
- if ((UNC_VF_VALID == (uint8_t) nwm_val->valid[loop])
+ if ((UNC_VF_VALID == (uint8_t) nwm_val->valid[loop])
|| (UNC_VF_VALID_NO_VALUE == (uint8_t) nwm_val->valid[loop]))
nwm_val->cs_attr[loop] = cs_status;
- } else {
- nwm_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
- }
+ else if ((UNC_VF_INVALID == nwm_val->valid[loop]) &&
+ (UNC_OP_CREATE == op))
+ nwm_val->cs_attr[loop] = UNC_CS_NOT_APPLIED;
+ else if ((UNC_VF_INVALID == nwm_val->valid[loop]) &&
+ (UNC_OP_UPDATE == op))
+ nwm_val->cs_attr[loop] = nwm_val2->cs_attr[loop];
}
return UPLL_RC_SUCCESS;
}
return UPLL_RC_ERR_GENERIC;
}
if (uuc::kUpllUcpCreate == phase) val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
for (unsigned int loop = 0; loop < sizeof(val->valid) / sizeof(uint8_t);
++loop) {
if ((cs_status == UNC_CS_INVALID &&
key_rename_vnode_info *key_rename =
reinterpret_cast<key_rename_vnode_info *>(ikey->get_key());
- key_nwm_t * key_vwm = new key_nwm_t();
- if (!key_vwm) return UPLL_RC_ERR_GENERIC;
- memset(key_vwm, 0 , sizeof(key_nwm_t));
+ key_nwm_t *key_vwm = reinterpret_cast<key_nwm_t*>(
+ ConfigKeyVal::Malloc(sizeof(key_nwm_t)));
if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vtn_name))) {
/* Addressed RESOURCE_LEAK */
- DELETE_IF_NOT_NULL(key_vwm);
+ ConfigKeyVal::Free(key_vwm);
return UPLL_RC_ERR_GENERIC;
}
uuu::upll_strncpy(key_vwm->vbr_key.vtn_key.vtn_name,
if (ikey->get_key_type() == UNC_KT_VBRIDGE) {
if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vnode_name))) {
/* Addressed RESOURCE_LEAK */
- DELETE_IF_NOT_NULL(key_vwm);
+ ConfigKeyVal::Free(key_vwm);
return UPLL_RC_ERR_GENERIC;
}
uuu::upll_strncpy(key_vwm->vbr_key.vbridge_name,
key_rename->old_unc_vnode_name, (kMaxLenVnodeName + 1));
+ } else {
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_unc_vnode_name))) {
+ ConfigKeyVal::Free(key_vwm);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(key_vwm->vbr_key.vbridge_name,
+ key_rename->new_unc_vnode_name, (kMaxLenVnodeName+1));
}
+
okey = new ConfigKeyVal(UNC_KT_VBR_NWMONITOR, IpctSt::kIpcStKeyNwm, key_vwm,
NULL);
- if (!okey) return UPLL_RC_ERR_GENERIC;
return result_code;
}
return false;
}
-bool NwMonitorMoMgr::CompareValidValue(void *&val1, void *val2, bool copy_to_running) {
+bool NwMonitorMoMgr::CompareValidValue(void *&val1, void *val2,
+ bool copy_to_running) {
UPLL_FUNC_TRACE;
bool invalid_attr = true;
val_nwm_t *val_nwm1 = reinterpret_cast<val_nwm_t*>(val1);
for (unsigned int loop = 0;
loop < sizeof(val_nwm1->valid) / sizeof(uint8_t); ++loop) {
if (UNC_VF_INVALID == val_nwm1->valid[loop]
- && UNC_VF_VALID == val_nwm2->valid[loop])
+ && UNC_VF_VALID == val_nwm2->valid[loop])
val_nwm1->valid[loop] = UNC_VF_VALID_NO_VALUE;
}
- if (val_nwm1->valid[UPLL_IDX_ADMIN_STATUS_NWM] == UNC_VF_VALID
- && val_nwm2->valid[UPLL_IDX_ADMIN_STATUS_NWM] == UNC_VF_VALID) {
+ if (val_nwm1->valid[UPLL_IDX_ADMIN_STATUS_NWM] != UNC_VF_INVALID
+ && val_nwm2->valid[UPLL_IDX_ADMIN_STATUS_NWM] != UNC_VF_INVALID) {
if (val_nwm1->admin_status == val_nwm2->admin_status)
val_nwm1->valid[UPLL_IDX_ADMIN_STATUS_NWM] = UNC_VF_INVALID;
}
loop < (sizeof(val_nwm1->valid) / sizeof(val_nwm1->valid[0]));
++loop) {
if ((UNC_VF_VALID == (uint8_t) val_nwm1->valid[loop])||
- (UNC_VF_VALID_NO_VALUE == (uint8_t) val_nwm1->valid[loop]))
- invalid_attr = false;
+ (UNC_VF_VALID_NO_VALUE == (uint8_t) val_nwm1->valid[loop])) {
+ invalid_attr = false;
+ break;
+ }
}
- return invalid_attr;
+ return invalid_attr;
}
upll_rc_t NwMonitorMoMgr::ValidateMessage(IpcReqRespHeader *req,
- ConfigKeyVal *ikey) {
+ ConfigKeyVal *ikey) {
UPLL_FUNC_TRACE;
upll_rc_t ret_val = UPLL_RC_ERR_GENERIC;
- if (NULL == req) {
- UPLL_LOG_DEBUG("IpcReqRespHeader is NULL");
- return UPLL_RC_ERR_GENERIC;
- }
- if (ikey == NULL) {
- UPLL_LOG_DEBUG("ConfigKeyVal is NULL");
- return UPLL_RC_ERR_GENERIC;
+ if (!ikey || !req || !(ikey->get_key())) {
+ UPLL_LOG_DEBUG("IpcReqRespHeader or ConfigKeyVal is Null");
+ return UPLL_RC_ERR_BAD_REQUEST;
}
unc_key_type_t keytype = ikey->get_key_type();
if (UNC_KT_VBR_NWMONITOR != keytype) {
UPLL_LOG_DEBUG("Invalid keytype. Keytype- %d", keytype);
- return UPLL_RC_ERR_GENERIC;
+ return UPLL_RC_ERR_BAD_REQUEST;
}
if (ikey->get_st_num() != IpctSt::kIpcStKeyNwm) {
UPLL_LOG_DEBUG(
"Invalid structure received.Expected struct-kIpcStKeyNwm,"
"received struct -%d ", (ikey->get_st_num()));
- return UPLL_RC_ERR_GENERIC;
+ return UPLL_RC_ERR_BAD_REQUEST;
}
key_nwm_t *key_nwm = reinterpret_cast<key_nwm_t *>(ikey->get_key());
val_nwm_t *val_nwm = NULL;
unc_keytype_option2_t option2 = req->option2;
if (key_nwm == NULL) {
- pfc_log_debug("key structure is empty!!");
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ UPLL_LOG_DEBUG("key structure is empty!!");
+ return UPLL_RC_ERR_BAD_REQUEST;
}
ret_val = ValidateNwMonKey(key_nwm, operation);
if (ret_val != UPLL_RC_SUCCESS) {
return UPLL_RC_ERR_CFG_SYNTAX;
} else {
if (((operation == UNC_OP_CREATE) || (operation == UNC_OP_UPDATE))
- && ((dt_type == UPLL_DT_CANDIDATE)|| (UPLL_DT_IMPORT == dt_type))) {
+ && ((dt_type == UPLL_DT_CANDIDATE)|| (dt_type == UPLL_DT_IMPORT))) {
if (val_nwm != NULL) {
ret_val = ValidateNwMonValue(val_nwm, operation);
if (ret_val != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Syntax check failed for NWMONITOR value struct");
return UPLL_RC_ERR_CFG_SYNTAX;
- } else {
- UPLL_LOG_DEBUG("Syntax check success for NWMONITOR value struct");
- return UPLL_RC_SUCCESS;
}
+ return UPLL_RC_SUCCESS;
} else {
UPLL_LOG_DEBUG("Value structure mandatory CREATE/UPDATE");
return UPLL_RC_ERR_CFG_SYNTAX;
((dt_type == UPLL_DT_CANDIDATE) ||
(dt_type == UPLL_DT_RUNNING) ||
(dt_type == UPLL_DT_STARTUP) ||
- (dt_type == UPLL_DT_STATE))) {
- if ((option1 == UNC_OPT1_NORMAL) || ((option1 == UNC_OPT1_DETAIL) &&
- (operation != UNC_OP_READ_SIBLING_COUNT))) {
+ (dt_type == UPLL_DT_STATE))) {
+ if ((option1 == UNC_OPT1_NORMAL) ||
+ ((option1 == UNC_OPT1_DETAIL) &&
+ (operation != UNC_OP_READ_SIBLING_COUNT) &&
+ (dt_type == UPLL_DT_STATE))) {
if (option2 == UNC_OPT2_NONE) {
if (val_nwm != NULL) {
ret_val = ValidateNwMonValue(val_nwm);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("Syntax check failed for NWMONITOR value struct");
+ UPLL_LOG_DEBUG("Syntax check failed for NWMONITOR value struct");
return UPLL_RC_ERR_CFG_SYNTAX;
} else {
- pfc_log_trace("Syntax check success for NWMONITOR value struct");
+ UPLL_LOG_TRACE("Syntax check success for NWMONITOR value struct");
return UPLL_RC_SUCCESS;
}
} else {
- pfc_log_trace("value structure is optional");
+ UPLL_LOG_TRACE("value structure is optional");
return UPLL_RC_SUCCESS;
}
} else {
- pfc_log_debug("option2 is not matching");
+ UPLL_LOG_DEBUG("option2 is not matching");
return UPLL_RC_ERR_INVALID_OPTION2;
}
} else {
- pfc_log_debug("option1 is not matching");
+ UPLL_LOG_DEBUG("option1 is not matching");
return UPLL_RC_ERR_INVALID_OPTION1;
}
} else if ((operation == UNC_OP_DELETE) || (operation == UNC_OP_READ_NEXT)
|| (operation == UNC_OP_READ_BULK)) {
- pfc_log_trace("Value structure is none for operation type:%d", operation);
+ UPLL_LOG_TRACE("Value structure is none for operation type:%d",
+ operation);
return UPLL_RC_SUCCESS;
} else {
- pfc_log_debug("Invalid datatype(%d) and operation(%d)", dt_type,
- operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ UPLL_LOG_DEBUG("Invalid datatype(%d) and operation(%d)", dt_type,
+ operation);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
}
+ return UPLL_RC_SUCCESS;
}
upll_rc_t NwMonitorMoMgr::ValidateNwMonValue(val_nwm_t *val_nwm,
unc_keytype_operation_t operation) {
if (val_nwm->valid[UPLL_IDX_ADMIN_STATUS_NWM] == UNC_VF_VALID) {
if (!ValidateNumericRange(val_nwm->admin_status,
- (uint8_t) UPLL_ADMIN_ENABLE,
- (uint8_t) UPLL_ADMIN_DISABLE, true, true)) {
- pfc_log_debug("Syntax check failed admin_stat-%d", val_nwm->admin_status);
+ (uint8_t) UPLL_ADMIN_ENABLE,
+ (uint8_t) UPLL_ADMIN_DISABLE, true, true)) {
+ UPLL_LOG_DEBUG("Syntax check failed admin_stat-%d",
+ val_nwm->admin_status);
return UPLL_RC_ERR_CFG_SYNTAX;
}
} else if ((val_nwm->valid[UPLL_IDX_ADMIN_STATUS_NWM] ==
- UNC_VF_VALID_NO_VALUE)
+ UNC_VF_VALID_NO_VALUE)
&& ((operation == UNC_OP_UPDATE) || (operation == UNC_OP_CREATE))) {
/* Copy default value */
val_nwm->admin_status = UPLL_ADMIN_ENABLE;
}
- pfc_log_trace("value structure validation successful for VTUNNEL_IF keytype");
return UPLL_RC_SUCCESS;
}
upll_rc_t NwMonitorMoMgr::ValidateNwMonKey(key_nwm_t *key_nwm,
upll_rc_t ret_val = UPLL_RC_SUCCESS;
VbrMoMgr *objvbrmgr =
- reinterpret_cast<VbrMoMgr *>(const_cast<MoManager *>(GetMoManager(
- UNC_KT_VBRIDGE)));
+ reinterpret_cast<VbrMoMgr *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_VBRIDGE)));
if (NULL == objvbrmgr) {
UPLL_LOG_DEBUG("unable to get VbrMoMgr object to validate key_vbr");
return UPLL_RC_ERR_GENERIC;
return ret_val;
}
-upll_rc_t NwMonitorMoMgr::ValNwMonAttributeSupportCheck(const char * crtlr_name,
- ConfigKeyVal *ikey,
- uint32_t operation) {
+upll_rc_t NwMonitorMoMgr::ValNwMonAttributeSupportCheck(val_nwm_t *val_nwm,
+ const uint8_t* attrs, unc_keytype_operation_t operation) {
UPLL_FUNC_TRACE;
+ if ((val_nwm->valid[UPLL_IDX_ADMIN_STATUS_NWM] == UNC_VF_VALID) ||
+ (val_nwm->valid[UPLL_IDX_ADMIN_STATUS_NWM] == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::nwm::kCapAdminStatus] == 0) {
+ val_nwm->valid[UPLL_IDX_ADMIN_STATUS_NWM] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG(
+ "UPLL_IDX_ADMIN_STATUS_NWM not supported in pfc controller");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t NwMonitorMoMgr::ValidateCapability(IpcReqRespHeader *req,
+ ConfigKeyVal *ikey,
+ const char * ctrlr_name) {
+ UPLL_FUNC_TRACE;
+
+ if (!ikey || !req) {
+ UPLL_LOG_DEBUG("ConfigKeyVal / IpcReqRespHeader is Null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ if (!ctrlr_name) {
+ ctrlr_name = reinterpret_cast<char*>((reinterpret_cast<key_user_data_t *>
+ (ikey->get_user_data()))->ctrlr_id);
+ if (!ctrlr_name || !strlen(ctrlr_name)) {
+ UPLL_LOG_DEBUG("Controller Name is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+
+ UPLL_LOG_TRACE("ctrlr_name(%s), operation : (%d)",
+ ctrlr_name, req->operation);
+
bool result_code = false;
uint32_t max_instance_count = 0;
- uint32_t num_attrs = 0;
- const uint8_t *attrs = 0;
- if (ikey == NULL) {
- UPLL_LOG_DEBUG("ConfigKeyVal is NULL");
- return UPLL_RC_ERR_GENERIC;
+ uint32_t max_attrs = 0;
+ const uint8_t *attrs = NULL;
+
+ switch (req->operation) {
+ case UNC_OP_CREATE: {
+ result_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_instance_count, &max_attrs,
+ &attrs);
+ if (result_code && (max_instance_count != 0) &&
+ cur_instance_count >= max_instance_count) {
+ UPLL_LOG_DEBUG("Instance count %d exceeds %d", cur_instance_count,
+ max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
+ break;
+ }
+
+ case UNC_OP_UPDATE: {
+ result_code = GetUpdateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ break;
+ }
+
+ case UNC_OP_READ:
+ case UNC_OP_READ_SIBLING:
+ case UNC_OP_READ_SIBLING_BEGIN:
+ case UNC_OP_READ_SIBLING_COUNT: {
+ result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ break;
+ }
+ default: {
+ UPLL_LOG_DEBUG("Invalid operation");
+ break;
+ }
+ }
+ if (!result_code) {
+ UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s) "
+ "for operation(%d)",
+ ikey->get_key_type(), ctrlr_name, req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
val_nwm_t *val_nwm = NULL;
if ((ikey->get_cfg_val())
&& ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValNwm)) {
val_nwm = reinterpret_cast<val_nwm_t *>(ikey->get_cfg_val()->get_val());
}
- if (val_nwm != NULL) {
- switch (operation) {
- case UNC_OP_CREATE:
- result_code = GetCreateCapability(crtlr_name, ikey->get_key_type(),
- &max_instance_count, &num_attrs,
- &attrs);
- if (result_code && cur_instance_count >= max_instance_count) {
- pfc_log_debug("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
- __LINE__, __FUNCTION__, cur_instance_count,
- max_instance_count);
- return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
- }
- break;
-
- case UNC_OP_UPDATE:
- result_code = GetUpdateCapability(crtlr_name, ikey->get_key_type(),
- &num_attrs, &attrs);
- break;
-
- case UNC_OP_READ:
- case UNC_OP_READ_SIBLING:
- case UNC_OP_READ_SIBLING_BEGIN:
- case UNC_OP_READ_SIBLING_COUNT:
- result_code = GetReadCapability(crtlr_name, ikey->get_key_type(),
- &num_attrs, &attrs);
- break;
-
- default:
- pfc_log_debug("Invalid operation");
- break;
- }
-
- if (!result_code) {
- pfc_log_debug("key_type - %d is not supported by controller - %s",
- ikey->get_key_type(), crtlr_name);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
- }
- if ((val_nwm->valid[UPLL_IDX_ADMIN_STATUS_NWM] == UNC_VF_VALID) ||
- (val_nwm->valid[UPLL_IDX_ADMIN_STATUS_NWM] == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::nwm::kCapAdminStatus] == 0) {
- val_nwm->valid[UPLL_IDX_ADMIN_STATUS_NWM] = UNC_VF_NOT_SOPPORTED;
- pfc_log_debug(
- "UPLL_IDX_ADMIN_STATUS_NWM not supported in pfc controller");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
+ if (val_nwm) {
+ if (max_attrs > 0) {
+ return ValNwMonAttributeSupportCheck(val_nwm, attrs, req->operation);
+ } else {
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d",
+ req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
- } else {
- pfc_log_debug("Value structure is empty");
- return UPLL_RC_ERR_GENERIC;
}
- pfc_log_info("Exiting KT_VBR_NWMONITOR: ValNwMonAttributeSupportCheck()");
return UPLL_RC_SUCCESS;
}
-upll_rc_t NwMonitorMoMgr::ValidateCapability(IpcReqRespHeader *req,
- ConfigKeyVal *ikey,
- const char * ctrlr_name) {
+
+
+upll_rc_t NwMonitorMoMgr::IsReferenced(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- if (NULL == req) {
- UPLL_LOG_DEBUG("IpcReqRespHeader is NULL");
+ if (!ikey)
return UPLL_RC_ERR_GENERIC;
+ unc_key_type_t nodes[] = { UNC_KT_VTN_FLOWFILTER_ENTRY,
+ UNC_KT_VBR_FLOWFILTER_ENTRY, UNC_KT_VBRIF_FLOWFILTER_ENTRY,
+ UNC_KT_VRTIF_FLOWFILTER_ENTRY
+ };
+ int nop = sizeof(nodes)/ sizeof(nodes[0]);
+ ConfigKeyVal *ckv_tmp = NULL;
+ ConfigVal *cval = NULL;
+ for (int indx = 0 ; indx < nop; indx++) {
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(
+ const_cast<MoManager *>(GetMoManager(nodes[indx])));
+ if (!mgr) {
+ UPLL_LOG_TRACE("Invalid mgr");
+ continue;
+ }
+ if (indx == 0) {
+ val_vtn_flowfilter_entry_t *flowfilter_val =reinterpret_cast
+ <val_vtn_flowfilter_entry_t*>
+ (ConfigKeyVal::Malloc(sizeof(val_vtn_flowfilter_entry_t)));
+ flowfilter_val->valid[UPLL_IDX_NWN_NAME_VFFE] = UNC_VF_VALID;
+ uuu::upll_strncpy(flowfilter_val->nwm_name, reinterpret_cast<key_nwm *>
+ (ikey->get_key())->nwmonitor_name, (kMaxLenNwmName + 1));
+ cval = new ConfigVal(IpctSt::kIpcStValVtnFlowfilterEntry,
+ flowfilter_val);
+ } else {
+ val_flowfilter_entry_t *flowfilter_val =reinterpret_cast
+ <val_flowfilter_entry_t*>
+ (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_t)));
+ flowfilter_val->valid[UPLL_IDX_NWM_NAME_FFE] = UNC_VF_VALID;
+ uuu::upll_strncpy(flowfilter_val->nwm_name, reinterpret_cast<key_nwm *>
+ (ikey->get_key())->nwmonitor_name, (kMaxLenNwmName + 1));
+ cval = new ConfigVal(IpctSt::kIpcStValFlowfilterEntry,
+ flowfilter_val);
+ }
+ result_code = mgr->GetChildConfigKey(ckv_tmp, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed - %d", result_code);
+ if (ckv_tmp)
+ delete ckv_tmp;
+ DELETE_IF_NOT_NULL(cval);
+ return result_code;
+ }
+ ckv_tmp->SetCfgVal(cval);
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone };
+ result_code = mgr->ReadConfigDB(ckv_tmp, dt_type, UNC_OP_READ, dbop,
+ dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Existence check in keytype %d result_code %d",
+ ckv_tmp->get_key_type(), result_code);
+ delete ckv_tmp;
+ return result_code;
+ }
+ if (UPLL_RC_SUCCESS == result_code) {
+ delete ckv_tmp;
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ delete ckv_tmp;
+ ckv_tmp = NULL;
+ cval = NULL;
}
- if (ikey == NULL) {
- UPLL_LOG_DEBUG("ConfigKeyVal is NULL");
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) ?
+ UPLL_RC_SUCCESS : result_code;
+ return result_code;
+}
+
+upll_rc_t NwMonitorMoMgr::OnNwmonFault(
+ string ctrlr_name ,
+ string domain_id,
+ const key_vtn &key_vtn,
+ const pfcdrv_network_mon_alarm_data_t &alarm_data,
+ bool alarm_raised,
+ DalDmlIntf *dmi ) {
+ UPLL_FUNC_TRACE;
+ ConfigKeyVal *ikey = NULL;
+ char *alarm_status = NULL;
+ char al_raised[] = "Raised";
+ char al_cleared[] = "Cleared";
+ key_vtn_t *vtn_key = NULL;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ char *vtn_name = NULL;
+ VtnMoMgr *vtn_mgr = reinterpret_cast<VtnMoMgr*>
+ (const_cast<MoManager*>(GetMoManager(UNC_KT_VTN)));
+ if (NULL == vtn_mgr) {
+ UPLL_LOG_DEBUG("unable to get VtnMoMgr object to validate key_vtn");
return UPLL_RC_ERR_GENERIC;
}
- if (!ctrlr_name) ctrlr_name = reinterpret_cast<char *>(ikey->get_user_data());
- pfc_log_trace("controller name (%s)", ctrlr_name);
- upll_keytype_datatype_t dt_type = req->datatype;
- unc_keytype_operation_t operation = req->operation;
- unc_keytype_option1_t option1 = req->option1;
- unc_keytype_option2_t option2 = req->option2;
- pfc_log_trace("dt_type : (%d)"
- "operation : (%d)"
- "option1 : (%d)"
- "option2 : (%d)",
- dt_type, operation, option1, option2);
- if (((operation == UNC_OP_CREATE) || (operation == UNC_OP_UPDATE))
- && (dt_type == UPLL_DT_CANDIDATE)) {
- if ((GetVal(ikey)) != NULL) {
- result_code = ValNwMonAttributeSupportCheck(ctrlr_name, ikey, operation);
- if (result_code == UPLL_RC_SUCCESS) {
- pfc_log_trace("Attribute check success for KT_VBR_NWMONITOR");
- return UPLL_RC_SUCCESS;
- } else {
- pfc_log_debug("Attribute check failed for KT_VBR_NWMONITOR");
- return UPLL_RC_ERR_CFG_SEMANTIC;
- }
- } else {
- pfc_log_debug("value structure mandatory");
- return UPLL_RC_ERR_CFG_SEMANTIC;
- }
- } else if (((operation == UNC_OP_READ) ||
- (operation == UNC_OP_READ_SIBLING) ||
- (operation == UNC_OP_READ_SIBLING_BEGIN) ||
- (operation == UNC_OP_READ_SIBLING_COUNT)) &&
- ((dt_type == UPLL_DT_CANDIDATE) ||
- (dt_type == UPLL_DT_RUNNING) ||
- (dt_type == UPLL_DT_STARTUP) ||
- (dt_type == UPLL_DT_STATE))) {
- if ((option1 == UNC_OPT1_NORMAL) || ((option1 == UNC_OPT1_DETAIL) &&
- (operation != UNC_OP_READ_SIBLING_COUNT))) {
- if (option2 == UNC_OPT2_NONE) {
- if ((GetVal(ikey)) != NULL) {
- result_code = ValNwMonAttributeSupportCheck(ctrlr_name, ikey,
- operation);
- if (result_code == UPLL_RC_SUCCESS) {
- pfc_log_trace("Attribute check success for KT_VBR_NWMONITOR");
- return UPLL_RC_SUCCESS;
- } else {
- pfc_log_debug("Attribute check failed for KT_VBR_NWMONITOR");
- return UPLL_RC_ERR_CFG_SEMANTIC;
- }
- } else {
- pfc_log_trace("value structure is optional");
- return UPLL_RC_SUCCESS;
- }
- } else {
- pfc_log_debug("option2 is not matching");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- } else {
- pfc_log_debug("option1 is not matching");
- return UPLL_RC_ERR_INVALID_OPTION1;
+ result_code = vtn_mgr->GetChildConfigKey(ikey, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
+ return result_code;
+ }
+ vtn_key = reinterpret_cast<key_vtn_t*>(ikey->get_key());
+ uuu::upll_strncpy(vtn_key->vtn_name, key_vtn.vtn_name,
+ (kMaxLenVtnName + 1));
+
+ result_code = vtn_mgr->ValidateVtnKey(vtn_key);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Vtn Key validation failed - %d", result_code);
+ DELETE_IF_NOT_NULL(ikey);
+ return result_code;
+ }
+ uint8_t *ctrlr_id = reinterpret_cast<uint8_t*>
+ (const_cast<char*>(ctrlr_name.c_str()));
+ result_code = vtn_mgr->GetRenamedUncKey(ikey, UPLL_DT_RUNNING,
+ dmi, ctrlr_id);
+ if (result_code != UPLL_RC_SUCCESS &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("Error in getting renamed vtn name");
+ DELETE_IF_NOT_NULL(ikey);
+ return result_code;
+ }
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ ikey->SetCfgVal(NULL);
+ result_code = vtn_mgr->UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_READ,
+ dmi, MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code) {
+ delete ikey;
+ return result_code;
}
+ result_code = UPLL_RC_ERR_INSTANCE_EXISTS == result_code?UPLL_RC_SUCCESS:
+ result_code;
+ }
+
+ vtn_key = reinterpret_cast<key_vtn_t*>(ikey->get_key());
+ vtn_name = reinterpret_cast<char*>(vtn_key->vtn_name);
- } else if ((operation == UNC_OP_DELETE) || (operation == UNC_OP_READ_NEXT)
- || (operation == UNC_OP_READ_BULK)) {
- pfc_log_trace("Value structure is none for operation type:%d", operation);
- return UPLL_RC_SUCCESS;
+ if (alarm_raised) {
+ alarm_status = al_raised;
} else {
- pfc_log_debug("Invalid datatype(%d) and operation(%d)", dt_type, operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ alarm_status = al_cleared;
}
-}
-upll_rc_t NwMonitorMoMgr::IsReferenced(ConfigKeyVal *ikey,
- upll_keytype_datatype_t dt_type,
- DalDmlIntf *dmi) {
- return UPLL_RC_SUCCESS;
+ UPLL_LOG_INFO("Network Monitor Fault alarm : status - %s, "
+ "network_mon_group_name - %s, "
+ "controller - %s, domain - %s, vtn - %s",
+ alarm_status, alarm_data.network_mon_group_name,
+ ctrlr_name.c_str(), domain_id.c_str(),
+ vtn_name);
+ DELETE_IF_NOT_NULL(ikey);
+ return result_code;
}
} // namespace kt_momgr
* associated attributes are supported on the given controller,
* based on the valid flag.
*
- * @param[in] crtlr_name Controller name.
- * @param[in] ikey Corresponding key and value structure.
+ * @param[in] val_nwm Value Structure.
+ * @param[in] attr pointer to controller attribute
+ * @param[in] operation Operation Name
*
* @retval UPLL_RC_SUCCESS validation succeeded.
* @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
* @retval UPLL_RC_ERR_GENERIC Generic failure.
*/
- upll_rc_t ValNwMonAttributeSupportCheck(const char * crtlr_name,
- ConfigKeyVal *ikey,
- uint32_t operation);
+ upll_rc_t ValNwMonAttributeSupportCheck(val_nwm_t *val_nwm,
+ const uint8_t* attrs,
+ unc_keytype_operation_t operation);
upll_rc_t IsReferenced(ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi);
*/
upll_rc_t ValidateNwMonKey(key_nwm_t *key_nwm,
unc_keytype_operation_t operation = UNC_OP_INVALID);
+ upll_rc_t OnNwmonFault(
+ string ctrlr_name ,
+ string domain_id,
+ const key_vtn &key_vtn,
+ const pfcdrv_network_mon_alarm_data_t &alarm_data,
+ bool alarm_raised,
+ DalDmlIntf *dmi );
};
} // namespace kt_momgr
} // namespace upll
#include "policingprofile_entry_momgr.hh"
#include "policingprofile_momgr.hh"
#include "flowlist_momgr.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "upll_validation.hh"
#include "unc/upll_ipc_enum.h"
#include "unc/upll_errno.h"
#define FL_RENAME_FLAG 0x02
#define FLT_RENAME_FLAG 0X04
-#define NUM_PP_KEY_MAIN_COL 3
-#define NUM_PP_KEY_CTRLR_COL 5
-#define NUM_FL_KEY_MAIN_COL 4
-#define NUM_FL_KEY_CTRLR_COL 4
+#define FLOWLIST_RENAME 0x02
+#define NO_FLOWLIST_RENAME 0xFD
+
+#define NUM_PP_KEY_MAIN_COL 4
+#define NUM_PP_KEY_CTRLR_COL 4
BindInfo PolicingProfileEntryMoMgr::policingprofileentry_bind_info[] = {
{ uudst::policingprofile_entry::kDbiPolicingProfileName,
key_user_data_t, ctrlr_id),
uud::kDalChar, kMaxLenCtrlrId + 1 },
{ uudst::policingprofile_entry_ctrlr::kDbiFlags, CK_VAL, offsetof(
- val_policingprofile_entry_ctrl_t, flags),
+ key_user_data_t, flags),
uud::kDalUint8, 1 },
{ uudst::policingprofile_entry_ctrlr::kDbiValidFlowlist, CFG_META_VAL,
offsetof(val_policingprofile_entry_ctrl_t, valid[0]),
{ uudst::policingprofile_entry::kDbiPolicingProfileName, CFG_INPUT_KEY,
offsetof(key_rename_vnode_info_t, new_policingprofile_name),
uud::kDalChar, kMaxLenPolicingProfileName + 1 },
- { uudst::policingprofile_entry::kDbiFlags, CFG_INPUT_KEY,
+ { uudst::policingprofile_entry::kDbiFlags, CK_VAL,
offsetof(key_user_data_t, flags), uud::kDalUint8, 1 } };
BindInfo PolicingProfileEntryMoMgr::rename_policingprofile_entry_ctrl_tbl[] = {
{ uudst::policingprofile_entry_ctrlr::kDbiSequenceNum, CFG_MATCH_KEY,
offsetof(key_policingprofile_entry_t, sequence_num),
uud::kDalUint8, 1 },
- { uudst::policingprofile_entry_ctrlr::kDbiCtrlrName, CFG_MATCH_KEY, offsetof(
- key_user_data_t, ctrlr_id),
- uud::kDalChar, kMaxLenCtrlrId + 1 },
{ uudst::policingprofile_entry_ctrlr::kDbiPolicingProfileName, CFG_INPUT_KEY,
offsetof(key_rename_vnode_info_t, new_policingprofile_name),
uud::kDalChar, kMaxLenPolicingProfileName + 1 },
- { uudst::policingprofile_entry_ctrlr::kDbiFlags, CFG_INPUT_KEY, offsetof(
- key_user_data_t, flags),
- uud::kDalUint8, 1 } };
-
-BindInfo PolicingProfileEntryMoMgr::rename_flowlist_pp_entry_main_tbl[] = {
- { uudst::policingprofile_entry::kDbiPolicingProfileName, CFG_MATCH_KEY,
- offsetof(key_policingprofile_entry_t,
- policingprofile_key.policingprofile_name),
- uud::kDalChar, kMaxLenFlowListName + 1 },
- { uudst::policingprofile_entry::kDbiSequenceNum, CFG_MATCH_KEY, offsetof(
- key_policingprofile_entry_t, sequence_num),
- uud::kDalUint8, 1 },
- { uudst::policingprofile_entry::kDbiFlowlist, CFG_MATCH_KEY, offsetof(
- key_rename_vnode_info_t, new_flowlist_name),
- uud::kDalChar, kMaxLenFlowListName + 1 },
- { uudst::policingprofile_entry::kDbiFlags, CFG_INPUT_KEY,
- offsetof(key_user_data_t, flags), uud::kDalUint8, 1 } };
-
-BindInfo PolicingProfileEntryMoMgr::rename_flowlist_pp_entry_ctrl_tbl[] = {
- { uudst::policingprofile_entry_ctrlr::kDbiPolicingProfileName, CFG_MATCH_KEY,
- offsetof(key_policingprofile_entry_t,
- policingprofile_key.policingprofile_name),
- uud::kDalChar, kMaxLenFlowListName + 1 },
- { uudst::policingprofile_entry_ctrlr::kDbiSequenceNum, CFG_MATCH_KEY,
- offsetof(key_policingprofile_entry_t, sequence_num), uud::kDalUint8, 1 },
- { uudst::policingprofile_entry_ctrlr::kDbiCtrlrName, CFG_MATCH_KEY, offsetof(
- key_user_data_t, ctrlr_id),
- uud::kDalChar, kMaxLenCtrlrId + 1 },
- { uudst::policingprofile_entry_ctrlr::kDbiFlags, CFG_INPUT_KEY, offsetof(
- key_user_data_t, flags),
- uud::kDalUint8, 1 } };
+ { uudst::policingprofile_entry_ctrlr::kDbiFlags, CK_VAL, offsetof(
+ key_user_data_t, flags),
+ uud::kDalUint8, 1 } };
bool PolicingProfileEntryMoMgr::GetRenameKeyBindInfo(unc_key_type_t key_type,
BindInfo *&binfo,
int &nattr,
- MoMgrTables tbl) {
- switch (key_type) {
- case UNC_KT_POLICING_PROFILE_ENTRY:
- if (MAINTBL == tbl) {
- nattr = NUM_PP_KEY_MAIN_COL;
- binfo = rename_policingprofile_entry_main_tbl;
- } else if (CTRLRTBL == tbl) {
- nattr = NUM_PP_KEY_CTRLR_COL;
- binfo = rename_policingprofile_entry_ctrl_tbl;
- } else {
- return PFC_FALSE;
- }
- break;
- case UNC_KT_FLOWLIST:
- if (MAINTBL == tbl) {
- nattr = NUM_FL_KEY_MAIN_COL;
- binfo = rename_flowlist_pp_entry_main_tbl;
- } else if (CTRLRTBL == tbl) {
- nattr = NUM_FL_KEY_CTRLR_COL;
- binfo = rename_flowlist_pp_entry_ctrl_tbl;
- } else {
- return PFC_FALSE;
- }
- break;
- default:
- return PFC_FALSE;
+ MoMgrTables tbl) {
+ UPLL_FUNC_TRACE;
+ if (MAINTBL == tbl) {
+ nattr = NUM_PP_KEY_MAIN_COL;
+ binfo = rename_policingprofile_entry_main_tbl;
+ } else if (CTRLRTBL == tbl) {
+ nattr = NUM_PP_KEY_CTRLR_COL;
+ binfo = rename_policingprofile_entry_ctrl_tbl;
+ } else {
+ return PFC_FALSE;
}
return PFC_TRUE;
}
nchild = 0;
child = NULL;
+ cur_instance_count = 0;
};
UPLL_LOG_DEBUG("Okey not NULL");
if (okey->get_key_type() != UNC_KT_POLICING_PROFILE_ENTRY)
return UPLL_RC_ERR_GENERIC;
+ }
+ if ((okey) && (okey->get_key())) {
key_ppe = reinterpret_cast<key_policingprofile_entry_t *>(okey->get_key());
} else {
UPLL_LOG_DEBUG("Okey NULL");
key_ppe->policingprofile_key.policingprofile_name);
UPLL_LOG_DEBUG("GetChildConfigKey %d",
key_ppe->sequence_num);
+
+ if ((okey) && !(okey->get_key())) {
+ UPLL_LOG_TRACE("okey not NULL profile name updated");
+ okey->SetKey(IpctSt::kIpcStKeyPolicingprofileEntry, key_ppe);
+ }
- if (!okey)
+ if (!okey) {
okey = new ConfigKeyVal(UNC_KT_POLICING_PROFILE_ENTRY,
IpctSt::kIpcStKeyPolicingprofileEntry,
key_ppe, NULL);
+ }
SET_USER_DATA(okey, parent_key);
UPLL_LOG_DEBUG(
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
ConfigKeyVal *unc_key = NULL;
- if (NULL == ctrlr_key) {
+ UPLL_LOG_TRACE("%s GetRenamedUncKey pp_entry start",
+ ctrlr_key->ToStrAll().c_str());
+ if ((NULL == ctrlr_key) || (NULL == ctrlr_id) || (NULL == dmi)) {
UPLL_LOG_DEBUG(" PolicingProfileEntryMoMgr::GetRenamedUncKey Failed.");
return result_code;
}
val_rename_policingprofile_t *rename_policingprofile =
reinterpret_cast<val_rename_policingprofile_t *>(ConfigKeyVal::Malloc(
sizeof(val_rename_policingprofile_t)));
+ if (!rename_policingprofile) {
+ UPLL_LOG_DEBUG("rename_policingprofile NULL");
+ return result_code;
+ }
uuu::upll_strncpy(
rename_policingprofile->policingprofile_newname,
ctrlr_policingprofile_entry_key->policingprofile_key.policingprofile_name,
MoMgrImpl *mgr =
reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
UNC_KT_POLICING_PROFILE)));
+ if (!mgr) {
+ UPLL_LOG_TRACE("mgr failed");
+ if (rename_policingprofile) free(rename_policingprofile);
+ return UPLL_RC_ERR_GENERIC;
+ }
result_code = mgr->GetChildConfigKey(unc_key, NULL);
if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey NULL");
free(rename_policingprofile);
return result_code;
}
+ if (!unc_key) {
+ UPLL_LOG_DEBUG("unc_key NULL");
+ free(rename_policingprofile);
+ return UPLL_RC_ERR_GENERIC;
+ }
unc_key->AppendCfgVal(IpctSt::kIpcStValRenamePolicingprofile,
rename_policingprofile);
if (ctrlr_id)
SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
+ UPLL_LOG_DEBUG("ctrlr_id (%s)", ctrlr_id);
result_code = mgr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL);
if (UPLL_RC_SUCCESS == result_code) {
(kMaxLenPolicingProfileName + 1));
} else if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(unc_key);
+ mgr = NULL;
return result_code;
}
+ mgr = NULL;
+ DELETE_IF_NOT_NULL(unc_key);
+
val_policingprofile_entry_t *val_ppe =
reinterpret_cast<val_policingprofile_entry_t *>(GetVal(ctrlr_key));
+ if (!val_ppe) {
+ UPLL_LOG_DEBUG("val_ppe NULL");
+ return UPLL_RC_SUCCESS;
+ }
if (UNC_VF_VALID != val_ppe->valid[UPLL_IDX_FLOWLIST_PPE ]) {
+ UPLL_LOG_DEBUG("flowlist invalid");
return UPLL_RC_SUCCESS;
}
ConfigKeyVal *fl_ckv = NULL;
reinterpret_cast<val_rename_flowlist_t *>(ConfigKeyVal::Malloc(
sizeof(val_rename_flowlist_t)));
+ if (!rename_flowlist) {
+ UPLL_LOG_DEBUG("rename_flowlist NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(rename_flowlist->flowlist_newname,
val_ppe->flowlist,
(kMaxLenFlowListName + 1));
MoMgrImpl *mgr_fl =
reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
UNC_KT_FLOWLIST)));
+ if (!mgr_fl) {
+ UPLL_LOG_TRACE("mgr failed");
+ if (rename_flowlist) free(rename_flowlist);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
result_code = mgr_fl->GetChildConfigKey(fl_ckv, NULL);
if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey NULL");
+ free(rename_flowlist);
return result_code;
}
- unc_key->AppendCfgVal(IpctSt::kIpcStValRenameFlowlist,
+ if (!fl_ckv) {
+ UPLL_LOG_DEBUG("fl_ckv NULL");
+ free(rename_flowlist);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ fl_ckv->AppendCfgVal(IpctSt::kIpcStValRenameFlowlist,
rename_flowlist);
+
+ UPLL_LOG_DEBUG("ctrlr_id ppe (%s)", ctrlr_id);
+
if (ctrlr_id)
SET_USER_DATA_CTRLR(fl_ckv, ctrlr_id);
- result_code = mgr->ReadConfigDB(fl_ckv, dt_type, UNC_OP_READ, dbop, dmi,
+
+ result_code = mgr_fl->ReadConfigDB(fl_ckv, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL);
if (UPLL_RC_SUCCESS == result_code) {
key_flowlist_t *key_flowlist =
(kMaxLenFlowListName + 1));
} else if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ mgr_fl = NULL;
+ DELETE_IF_NOT_NULL(fl_ckv);
return result_code;
}
- delete unc_key;
- delete fl_ckv;
- unc_key = fl_ckv = NULL;
- UPLL_LOG_DEBUG(" PolicingProfileEntryMoMgr::GetRenamedUncKey Failed : %d",
- result_code);
- return result_code;
+ UPLL_LOG_TRACE("%s GetRenamedUncKey pp_entry end",
+ ctrlr_key->ToStrAll().c_str());
+ DELETE_IF_NOT_NULL(fl_ckv);
+ mgr_fl = NULL;
+ return UPLL_RC_SUCCESS;
}
upll_rc_t PolicingProfileEntryMoMgr::DupConfigKeyVal(ConfigKeyVal *&okey,
ConfigKeyVal *&ckv_running) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- val_policingprofile_entry_t *val;
+ val_policingprofile_entry_ctrl_t *val;
val = (ckv_running != NULL) ? reinterpret_cast
- <val_policingprofile_entry_t *>(GetVal(
+ <val_policingprofile_entry_ctrl_t *>(GetVal(
ckv_running)) : NULL;
if (NULL == val) {
return UPLL_RC_ERR_GENERIC;
}
- if (uuc::kUpllUcpCreate == phase) val->cs_row_status = cs_status;
+ if (uuc::kUpllUcpCreate == phase )
+ val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
for (unsigned int loop = 0; loop < sizeof(val->valid)/sizeof(val->valid[0]);
++loop) {
- if (cs_status == UNC_CS_INVALID && UNC_VF_VALID ==
- val->valid[loop]) val->cs_attr[loop] = cs_status;
- else
- val->cs_attr[loop] = cs_status;
+ if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
+ cs_status == UNC_CS_APPLIED)
+ val->cs_attr[loop] = cs_status;
}
return result_code;
}
const char *ctrlr_id,
ConfigKeyVal *ikey,
DalDmlIntf *dmi) {
- // No Implementation for Merge Validate.
UPLL_FUNC_TRACE;
- UPLL_LOG_DEBUG(
- " PolicingProfileEntryMoMgr::Rename Not required:: successful ");
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_POLICING_PROFILE)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Invalid mgr param");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ result_code = mgr->MergeValidate(keytype, ctrlr_id, ikey, dmi);
+ UPLL_LOG_DEBUG("MergeValidate result code (%d)", result_code);
+ return result_code;
}
upll_rc_t PolicingProfileEntryMoMgr::RenameMo(IpcReqRespHeader *req,
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *okey = NULL;
- ConfigKeyVal *ppe_okey = NULL;
- result_code = GetChildConfigKey(ppe_okey, NULL);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("GetChildConfigKey failed ");
- return result_code;
- }
result_code = UpdateConfigDB(ikey,
dt_type, UNC_OP_READ, dmi, CTRLRTBL);
if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
return UPLL_RC_ERR_CFG_SEMANTIC;
} else if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
- delete ppe_okey;
return result_code;
}
// Change to GetParentKey
result_code = GetPolicingprofileKeyVal(okey, ikey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Memory is not allocated for okey %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
MoMgrImpl *mgr =
reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
UNC_KT_POLICING_PROFILE)));
if (!mgr) {
- UPLL_LOG_DEBUG("Invalid mgr param\n");
- delete okey; // RESOURCE LEAK
+ UPLL_LOG_DEBUG("Invalid mgr param");
+ DELETE_IF_NOT_NULL(okey); // RESOURCE LEAK
return UPLL_RC_ERR_GENERIC;
}
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("IsReferenced id Faliled %d", result_code);
- delete okey;
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
- delete okey;
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
}
upll_rc_t PolicingProfileEntryMoMgr::GetRenamedControllerKey(
- ConfigKeyVal *&ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
+ ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
controller_domain *ctrlr_dom) {
UPLL_FUNC_TRACE;
if (!ikey) {
}
upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
ConfigKeyVal *okey = NULL;
- uint8_t rename = 0, rename_fl = 0;
+ uint8_t rename = 0;
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
- uint8_t *ctrlr_id = ctrlr_dom->ctrlr;
+
IsRenamed(ikey, dt_type, dmi, rename);
if (!rename) {
+ UPLL_LOG_DEBUG("Key not Renamed");
return UPLL_RC_SUCCESS;
}
/* PolicingProfile_name is renamed */
- key_policingprofile_entry_t *ctrlr_key =
- reinterpret_cast<key_policingprofile_entry_t *>(ConfigKeyVal::Malloc(
- sizeof(key_policingprofile_entry_t)));
-
if (rename & PP_RENAME_FLAG) {
- result_code = GetChildConfigKey(okey, ikey);
+ MoMgrImpl *ppmgr = static_cast<MoMgrImpl*>
+ ((const_cast<MoManager*>(GetMoManager(UNC_KT_POLICING_PROFILE))));
+ result_code = ppmgr->GetChildConfigKey(okey, NULL);
if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail (%d)", result_code);
return UPLL_RC_ERR_GENERIC;
}
- if (NULL != ctrlr_id) {
- SET_USER_DATA_CTRLR(okey, ctrlr_id);
- }
+
+ if (ctrlr_dom != NULL)
+ SET_USER_DATA_CTRLR(okey, ctrlr_dom->ctrlr);
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
+ uuu::upll_strncpy(
+ reinterpret_cast<key_policingprofile_t *>(okey->get_key())->policingprofile_name,
+ reinterpret_cast <key_policingprofile_entry *>
+ (ikey->get_key())->policingprofile_key.policingprofile_name,
+ (kMaxLenPolicingProfileName + 1));
+
+ UPLL_LOG_DEBUG("profile name (%s) (%s)",
+ reinterpret_cast<key_policingprofile_t *>(okey->get_key())->policingprofile_name,
+ reinterpret_cast <key_policingprofile_entry *>
+ (ikey->get_key())->policingprofile_key.policingprofile_name);
+
/* ctrlr_name */
- result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi,
+ result_code = ppmgr->ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL); // COVERITY CHECKED RETURN
if (result_code != UPLL_RC_SUCCESS) {
- free(ctrlr_key); // COV RESOURCE LEAK FIX
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB no instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
+ DELETE_IF_NOT_NULL(okey);
+ UPLL_LOG_DEBUG("ReadConfigDB failed (%d)", result_code);
return result_code;
}
/* Null check missing */
val_rename_policingprofile_t *rename_val =
reinterpret_cast<val_rename_policingprofile_t *>(GetVal(okey));
-
- if (!rename_val
- || (rename_val->valid[UPLL_IDX_RENAME_PROFILE_RPP] != UNC_VF_VALID)) {
- UPLL_LOG_DEBUG("rename failed :-");
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("rename_val null");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
+
uuu::upll_strncpy(
- ctrlr_key->policingprofile_key.policingprofile_name,
+ reinterpret_cast<key_policingprofile_entry_t *>
+ (ikey->get_key())->policingprofile_key.policingprofile_name,
rename_val->policingprofile_newname,
(kMaxLenPolicingProfileName + 1));
- delete okey;
+ DELETE_IF_NOT_NULL(okey);
}
- free(ikey->get_key());
- ikey->SetKey(IpctSt::kIpcStKeyPolicingprofileEntry,
- reinterpret_cast<void *>(ctrlr_key));
/* rename flowlist */
- val_policingprofile_entry_t *val_policingprofile_entry =
- reinterpret_cast<val_policingprofile_entry_t *>(GetVal(ikey));
- key_flowlist_t *key_flowlist =
- reinterpret_cast<key_flowlist_t *>(GetVal(okey));
+ if (rename & FLOWLIST_RENAME) {
+ UPLL_LOG_DEBUG("flowlist name renamed");
+ // Since during delete there wont be val structure
+ if (NULL == GetVal(ikey)) {
+ return UPLL_RC_SUCCESS;
+ }
+ MoMgrImpl *mgrflist = static_cast<MoMgrImpl*>
+ ((const_cast<MoManager*> (GetMoManager(UNC_KT_FLOWLIST))));
+ result_code = mgrflist->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+ if (NULL != ctrlr_dom) {
+ SET_USER_DATA_CTRLR(okey, ctrlr_dom->ctrlr);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
- uuu::upll_strncpy(key_flowlist->flowlist_name,
- val_policingprofile_entry->flowlist,
- (kMaxLenFlowListName + 1));
+ UPLL_LOG_DEBUG("ctrlr : %s;", ctrlr_dom->ctrlr);
- MoMgrImpl *mgr =
- reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
- UNC_KT_FLOWLIST)));
+ uuu::upll_strncpy(
+ reinterpret_cast<key_flowlist_t *>(okey->get_key())->flowlist_name,
+ reinterpret_cast<val_policingprofile_entry_t*>
+ (ikey->get_cfg_val()->get_val())->flowlist,
+ kMaxLenFlowListName + 1);
- IsRenamed(okey, dt_type, dmi, rename_fl);
- if (rename_fl == 0) {
- delete okey;
- return UPLL_RC_SUCCESS;
- }
- SET_USER_DATA_CTRLR(okey, ctrlr_id);
- result_code = mgr->ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi,
- RENAMETBL);
- if (result_code != UPLL_RC_SUCCESS) {
- return result_code;
- }
- val_rename_flowlist_t *rename_flowlist =
- reinterpret_cast<val_rename_flowlist_t *>(GetVal(okey));
- if (rename_fl & FL_RENAME_FLAG) { /* flowlist renamed */
- uuu::upll_strncpy(val_policingprofile_entry->flowlist,
- rename_flowlist->flowlist_newname,
- (kMaxLenFlowListName + 1));
+ UPLL_LOG_DEBUG("flowlist name (%s) (%s)",
+ reinterpret_cast<key_flowlist_t *>(okey->get_key())->flowlist_name,
+ reinterpret_cast<val_policingprofile_entry_t *>
+ (ikey->get_cfg_val()->get_val())->flowlist);
+
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
+ /* ctrlr_name */
+ result_code = mgrflist->ReadConfigDB(okey, dt_type,
+ UNC_OP_READ, dbop, dmi, RENAMETBL);
+ if ( result_code != UPLL_RC_SUCCESS ) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB no instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val_rename_flowlist_t *rename_val =
+ reinterpret_cast <val_rename_flowlist_t*>(GetVal(okey));
+
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("flowlist is not valid");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(
+ reinterpret_cast<val_policingprofile_entry_t *>
+ (ikey->get_cfg_val()->get_val())->flowlist,
+ rename_val->flowlist_newname,
+ (kMaxLenFlowListName + 1));
+ DELETE_IF_NOT_NULL(okey);
}
- // TODO(Author) has to fi th eissue DEAD CODE
- // rename = rename_fl || FLT_RENAME_FLAG;
- SET_USER_DATA_FLAGS(okey, rename);
- /* GetControlerKey(*ikey); */
- free(ctrlr_key);
- UPLL_LOG_DEBUG(
- " PolicingProfileEntryMoMgr::GetRenamedControllerKey is successful ");
+
+ UPLL_LOG_DEBUG("%s GetRenamedCtrl pp_entry end",
+ (ikey->ToStrAll()).c_str());
+ UPLL_LOG_DEBUG("GetRenamedControllerKey is successful ");
return UPLL_RC_SUCCESS;
}
req, nreq, &dal_cursor_handle, dmi, MAINTBL);
break;
default:
- UPLL_LOG_TRACE("Invalid operation \n");
+ UPLL_LOG_TRACE("Invalid operation");
return UPLL_RC_ERR_GENERIC;
}
resp.header.clnt_sess_id = session_id;
ck_main = NULL;
if ((op == UNC_OP_CREATE) || (op == UNC_OP_DELETE)) {
result_code = DupConfigKeyVal(ck_main, req, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS)
+ if (result_code != UPLL_RC_SUCCESS) {
+ dmi->CloseCursor(dal_cursor_handle, true);
return result_code;
-
+ }
GET_USER_DATA_CTRLR_DOMAIN(req, ctrlr_dom);
UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom.ctrlr,
ctrlr_dom.domain);
UPLL_LOG_DEBUG("Invalid controller");
DELETE_IF_NOT_NULL(ck_main);
ck_main = NULL;
+ dmi->CloseCursor(dal_cursor_handle, true);
+ dal_cursor_handle = NULL;
return UPLL_RC_ERR_GENERIC;
}
result_code = TxUpdateProcess(ck_main, &resp,
affected_ctrlr_set->insert((const char *)ctrlr_dom.ctrlr);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("TxUpdateProcess Returns error %d", result_code);
+ upll_keytype_datatype_t dt_type = (UNC_OP_DELETE == op)?
+ UPLL_DT_RUNNING:UPLL_DT_CANDIDATE;
+ upll_rc_t local_rc = GetRenamedUncKey(resp.ckv_data, dt_type, dmi,
+ ctrlr_dom.ctrlr);
+ if (UPLL_RC_SUCCESS != local_rc &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != local_rc) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey failed %d", local_rc);
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(resp.ckv_data);
+ result_code = UPLL_RC_ERR_GENERIC;
+ break;
+ }
*err_ckv = resp.ckv_data;
DELETE_IF_NOT_NULL(ck_main);
- ck_main = NULL;
break;
}
+ DELETE_IF_NOT_NULL(resp.ckv_data);
+ DELETE_IF_NOT_NULL(ck_main);
+ ck_main = NULL;
} else if (op == UNC_OP_UPDATE) {
- UPLL_LOG_TRACE(" Not supported operation \n");
+ dmi->CloseCursor(dal_cursor_handle, true);
+ dal_cursor_handle = NULL;
+ UPLL_LOG_TRACE(" Not supported operation");
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return UPLL_RC_SUCCESS;
- #if 0
- ConfigKeyVal *ck_ctrlr = NULL;
-
- result_code = DupConfigKeyVal(ck_main, req, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS)
- return result_code;
- /*
- result_code = ValidateCapability(&(ipc_req.header), ck_main);
- if (result_code != UPLL_RC_SUCCESS) {
- DELETE_IF_NOT_NULL(ck_main);
- return result_code;
- }
- */
- result_code = GetChildConfigKey(ck_ctrlr, req);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code)
- delete ck_main;
- return result_code;
- }
- result_code = GetControllerSpan(ck_ctrlr, UPLL_DT_CANDIDATE, dmi);
- if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- UPLL_LOG_DEBUG("GetControllerSpan no instance");
- delete ck_ctrlr;
- ck_ctrlr = NULL;
- continue;
- } else if (UPLL_RC_SUCCESS != result_code) {
- delete ck_ctrlr;
- ck_ctrlr = NULL;
- UPLL_LOG_DEBUG("GetControllerSpan failed %d", result_code);
- return result_code;
- }
-
- for (ConfigKeyVal *tmp = ck_ctrlr; tmp != NULL;
- tmp = tmp->get_next_cfg_key_val()) {
- ctrlr_dom.ctrlr = NULL;
- GET_USER_DATA_CTRLR_DOMAIN(tmp, ctrlr_dom);
- UPLL_LOG_DEBUG("ctrlr id - %s ", ctrlr_dom.ctrlr);
- if (ctrlr_dom.ctrlr == NULL) {
- UPLL_LOG_DEBUG("Invalid controller");
- return UPLL_RC_ERR_GENERIC;
- }
- UPLL_LOG_DEBUG("ctrlr id - %s ", ctrlr_dom.ctrlr);
- result_code = TxUpdateProcess(ck_main, &resp, op, dmi, &ctrlr_dom);
- affected_ctrlr_set->insert(reinterpret_cast<const char *>
- (ctrlr_dom.ctrlr));
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("TxUpdate Process returns with %d\n", result_code);
- *err_ckv = resp.ckv_data;
- break;
- }
- }
- DELETE_IF_NOT_NULL(ck_ctrlr);
- ck_ctrlr = NULL;
- #endif
}
DELETE_IF_NOT_NULL(ck_main);
- ck_main = NULL;
}
DELETE_IF_NOT_NULL(nreq);
- nreq = NULL;
DELETE_IF_NOT_NULL(req);
- req = NULL;
if (dal_cursor_handle) {
dmi->CloseCursor(dal_cursor_handle, true);
dal_cursor_handle = NULL;
}
upll_rc_t PolicingProfileEntryMoMgr::TxUpdateProcess(ConfigKeyVal *ck_main,
- IpcResponse *ipc_resp,
- unc_keytype_operation_t op,
- DalDmlIntf *dmi,
- controller_domain *ctrlr_dom) {
+ IpcResponse *ipc_resp,
+ unc_keytype_operation_t op,
+ DalDmlIntf *dmi,
+ controller_domain *ctrlr_dom) {
UPLL_FUNC_TRACE;
upll_rc_t result_code;
/* read from main table */
dup_ckmain = NULL;
result_code = GetChildConfigKey(dup_ckmain, ck_main);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
if (dup_ckmain) delete dup_ckmain;
return result_code;
}
result_code = ReadConfigDB(dup_ckmain, UPLL_DT_CANDIDATE,
UNC_OP_READ, dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- string s(dup_ckmain->ToStrAll());
- UPLL_LOG_INFO("%s Policingprofile Entry read failed %d",
- s.c_str(), result_code);
+ UPLL_LOG_DEBUG("%s Policingprofile Entry read failed %d",
+ (dup_ckmain->ToStrAll()).c_str(), result_code);
delete dup_ckmain;
return result_code;
}
ipc_resp->header.config_id, op,
UPLL_DT_CANDIDATE, dup_ckmain, ctrlr_dom, ipc_resp);
if (result_code == UPLL_RC_ERR_RESOURCE_DISCONNECTED) {
- UPLL_LOG_DEBUG("Controller disconnected\n");
+ UPLL_LOG_DEBUG("Controller disconnected");
result_code = UPLL_RC_SUCCESS;
}
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("IpcSend failed %d\n", result_code);
+ UPLL_LOG_DEBUG("IpcSend failed %d", result_code);
}
if ((op == UNC_OP_CREATE) && dup_ckmain) {
delete dup_ckmain;
unc_keytype_operation_t op[] = { UNC_OP_DELETE,UNC_OP_CREATE,
UNC_OP_UPDATE };
int nop = sizeof(op) / sizeof(op[0]);
- ConfigKeyVal *ppe_key = NULL, *req = NULL, *nreq = NULL;
+ ConfigKeyVal *ppe_key = NULL, *req = NULL, *nreq = NULL,
+ *pp_ck_run = NULL;
DalCursor *cfg1_cursor = NULL;
uint8_t *ctrlr_id = NULL;
#if 0
for (int i = 0; i < nop; i++) {
if (op[i] != UNC_OP_UPDATE) {
result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i], req,
- nreq, &cfg1_cursor, dmi, MAINTBL);
+ nreq, &cfg1_cursor, dmi, NULL, MAINTBL,true);
while (result_code == UPLL_RC_SUCCESS) {
db_result = dmi->GetNextRecord(cfg1_cursor);
result_code = DalToUpllResCode(db_result);
nreq, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Updating Main table Error %d", result_code);
+ DELETE_IF_NOT_NULL(req);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
}
dmi->CloseCursor(cfg1_cursor, true);
cfg1_cursor = NULL;
}
- if (req)
- delete req;
- req = NULL;
+ DELETE_IF_NOT_NULL(req);
}
UPLL_LOG_DEBUG("Updating main table complete with op %d", op[i]);
}
for (int i = 0; i < nop; i++) {
MoMgrTables tbl = (op[i] == UNC_OP_UPDATE)?MAINTBL:CTRLRTBL;
result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i], req,
- nreq, &cfg1_cursor, dmi, tbl);
+ nreq, &cfg1_cursor, dmi, NULL, tbl, true);
ConfigKeyVal *ppe_ctrlr_key = NULL;
while (result_code == UPLL_RC_SUCCESS) {
break;
if (op[i] == UNC_OP_UPDATE) {
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr };
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr |kOpInOutCs };
result_code = GetChildConfigKey(ppe_ctrlr_key, req);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
- result_code);
+ result_code);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
/* Capability check
result_code = ReadConfigDB(ppe_ctrlr_key, UPLL_DT_CANDIDATE,
UNC_OP_READ, dbop, dmi, CTRLRTBL);
if (result_code != UPLL_RC_SUCCESS) {
- delete ppe_ctrlr_key;
+ DELETE_IF_NOT_NULL(ppe_ctrlr_key);
if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
result_code = UpdateMainTbl(req, op[i], UPLL_RC_SUCCESS,
nreq, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Error updating main table%d", result_code);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(ppe_ctrlr_key);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
} else {
+ DELETE_IF_NOT_NULL(ppe_ctrlr_key);
continue;
}
} else {
+ UPLL_LOG_DEBUG("DB err while reading records from ctrlrtbl, err %d",
+ result_code);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(ppe_ctrlr_key);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
}
- result_code = DupConfigKeyVal(ppe_key, req, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("DupConfigKeyVal is failed result_code = %d",
- result_code);
- delete(ppe_ctrlr_key); // COVERITY RESOURCE LEAk
- return result_code;
- }
- GET_USER_DATA_CTRLR(ppe_ctrlr_key, ctrlr_id);
- string controller(reinterpret_cast<char *>(ctrlr_id));
- void *fle_val1 = GetVal(ppe_ctrlr_key);
- void *fle_val2 = GetVal(nreq);
for (ConfigKeyVal *tmp = ppe_ctrlr_key; tmp != NULL; tmp =
tmp->get_next_cfg_key_val()) {
+
+ GET_USER_DATA_CTRLR(tmp, ctrlr_id);
+ string controller(reinterpret_cast<char *>(ctrlr_id));
+
+ UPLL_LOG_DEBUG("Controller ID =%s", controller.c_str());
+ DbSubOp dbop_maintbl = { kOpReadSingle, kOpMatchNone, kOpInOutFlag };
+ result_code = GetChildConfigKey(ppe_key, req);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
+ result_code);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(ppe_ctrlr_key);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ result_code = ReadConfigDB(ppe_key, UPLL_DT_CANDIDATE,
+ UNC_OP_READ, dbop_maintbl, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to read configuration from CandidateDb");
+ DELETE_IF_NOT_NULL(ppe_key);
+ DELETE_IF_NOT_NULL(ppe_ctrlr_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ static_cast<val_policingprofile_entry_t *>
+ (GetVal(ppe_key))->cs_row_status =
+ static_cast<val_policingprofile_entry_t *>
+ (GetVal(nreq))->cs_row_status;
+
result_code = UpdateConfigStatus(ppe_key, op[i],
ctrlr_result[controller], nreq,
dmi, tmp);
if (result_code != UPLL_RC_SUCCESS) break;
- CompareValidValue(fle_val1, fle_val2, false);
- result_code = UpdateConfigDB(ppe_ctrlr_key,
+
+ void *fle_val1 = GetVal(tmp);
+ void *fle_val2 = GetVal(nreq);
+ CompareValidValue(fle_val1, fle_val2, true);
+ result_code = UpdateConfigDB(tmp,
UPLL_DT_RUNNING, op[i], dmi, CTRLRTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("UpdateConfigDB for ctrlr tbl is failed ");
- delete ppe_ctrlr_key; // COVERITY RESOURCE LEAk
- delete ppe_key;
+ DELETE_IF_NOT_NULL(ppe_ctrlr_key);
+ DELETE_IF_NOT_NULL(ppe_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
result_code = UpdateConfigDB(ppe_key, UPLL_DT_RUNNING,
op[i], dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("UpdateConfigDB for main tbl is failed");
- delete ppe_ctrlr_key; // COVERITY RESOURCE LEAk
+ DELETE_IF_NOT_NULL(ppe_ctrlr_key);
+ DELETE_IF_NOT_NULL(ppe_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
} // COV UNREACHABLE
EnqueCfgNotification(op[i], UPLL_DT_RUNNING,
- ppe_ctrlr_key);
+ tmp);
+ DELETE_IF_NOT_NULL(ppe_key);
}
+ DELETE_IF_NOT_NULL(ppe_ctrlr_key);
} else {
if (op[i] == UNC_OP_CREATE) {
- DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag };
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag |kOpInOutCs };
result_code = GetChildConfigKey(ppe_key, req);
- result_code = ReadConfigDB(ppe_key, UPLL_DT_CANDIDATE,
- UNC_OP_READ, dbop, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
+ }
+ result_code = ReadConfigDB(ppe_key, UPLL_DT_RUNNING /*UPLL_DT_CANDIDATE*/,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if ((result_code != UPLL_RC_SUCCESS) &&
+ (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
UPLL_LOG_DEBUG("ReadConfigDB is failed -%d", result_code);
+ DELETE_IF_NOT_NULL(ppe_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
+ /* set consolidated config status to UNKNOWN to init vtn cs_status
+ * to the cs_status of first controller
+ */
+ uint32_t cur_instance_count;
+ result_code = GetInstanceCount(ppe_key, NULL,
+ UPLL_DT_CANDIDATE, &cur_instance_count,
+ dmi, CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetInstanceCount failed %d", result_code);
+ DELETE_IF_NOT_NULL(ppe_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ if (cur_instance_count == 1)
+ reinterpret_cast<val_policingprofile_entry*>(GetVal(ppe_key))->
+ cs_row_status = UNC_CS_UNKNOWN ;
/* Capability check
* req_header->operation = op[i];
* strcpy((char*)req_header->datatype, (char*)UNC_DT_CANDIDATE);
result_code = DupConfigKeyVal(ppe_ctrlr_key, req, tbl);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("DupConfigKeyVal is failed -%d", result_code);
+ DELETE_IF_NOT_NULL(ppe_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
GET_USER_DATA_CTRLR(ppe_ctrlr_key, ctrlr_id);
string controller(reinterpret_cast<char *>(ctrlr_id));
result_code = UpdateConfigStatus(ppe_key, op[i],
- ctrlr_result[controller], NULL,
- dmi, ppe_ctrlr_key);
+ ctrlr_result[controller], nreq,
+ dmi, ppe_ctrlr_key);
} else if (op[i] == UNC_OP_DELETE) {
+ //Reading Main Running DB for delete op
+ DbSubOp dbop1 = { kOpReadSingle, kOpMatchNone, kOpInOutFlag | kOpInOutCs };
+ result_code = GetChildConfigKey(pp_ck_run, req);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
+ result_code);
+ DELETE_IF_NOT_NULL(req);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ result_code = ReadConfigDB(pp_ck_run, UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop1, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Unable to read configuration from RunningDB");
+ DELETE_IF_NOT_NULL(pp_ck_run);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ if (result_code == UPLL_RC_SUCCESS) {
+ GET_USER_DATA_CTRLR(req, ctrlr_id);
+ string controller(reinterpret_cast<char *>(ctrlr_id));
+ result_code = SetPPEntryConsolidatedStatus(pp_ck_run, ctrlr_id, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Could not set consolidated status %d", result_code);
+ DELETE_IF_NOT_NULL(pp_ck_run);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ }
+ DELETE_IF_NOT_NULL(pp_ck_run);
result_code = GetChildConfigKey(ppe_ctrlr_key, req);
- }
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetChildConfigKey is failed -%d",
- result_code);
- return result_code;
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
}
result_code = UpdateConfigDB(ppe_ctrlr_key, UPLL_DT_RUNNING,
op[i], dmi, CTRLRTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("UpdateConfigDB in ctrlr tbl is failed -%d",
result_code);
+ DELETE_IF_NOT_NULL(ppe_key);
+ DELETE_IF_NOT_NULL(ppe_ctrlr_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
if (op[i] != UNC_OP_DELETE) {
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("UpdateConfigDB in main tbl is failed -%d",
result_code);
+ DELETE_IF_NOT_NULL(ppe_key);
+ DELETE_IF_NOT_NULL(ppe_ctrlr_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
}
EnqueCfgNotification(op[i], UPLL_DT_RUNNING,
ppe_key);
}
- if (ppe_key) delete ppe_key;
- ppe_key = ppe_ctrlr_key = NULL;
+ DELETE_IF_NOT_NULL(ppe_key);
+ DELETE_IF_NOT_NULL(ppe_ctrlr_key);
result_code = DalToUpllResCode(db_result);
}
if (cfg1_cursor) {
if (op != UNC_OP_DELETE) {
result_code = DupConfigKeyVal(ck_ppe, ppe_key, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
return UPLL_RC_ERR_GENERIC;
}
ppe_val = reinterpret_cast<val_policingprofile_entry_t *>(GetVal(ck_ppe));
if (!ppe_val) {
- UPLL_LOG_DEBUG("invalid val \n");
+ UPLL_LOG_DEBUG("invalid val");
return UPLL_RC_ERR_GENERIC;
}
} else {
result_code = GetChildConfigKey(ck_ppe, ppe_key);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
return UPLL_RC_ERR_GENERIC;
}
}
switch (op) {
case UNC_OP_CREATE:
- ppe_val->cs_row_status = UNC_CS_NOT_APPLIED;
+ ppe_val->cs_row_status = UNC_CS_APPLIED;
break;
case UNC_OP_UPDATE:
-
ppeval = GetVal(ck_ppe);
nppeval = (nreq)?GetVal(nreq):NULL;
if (!nppeval) {
- UPLL_LOG_DEBUG("Invalid param\n");
+ UPLL_LOG_DEBUG("Invalid param");
return UPLL_RC_ERR_GENERIC;
}
- CompareValidValue(ppeval, nppeval, false);
+ CompareValidValue(ppeval, nppeval, true);
+ ppe_val->cs_row_status =
+ reinterpret_cast<val_policingprofile_entry_t *>(GetVal(nreq))->cs_row_status;
+
break;
case UNC_OP_DELETE:
break;
default:
- UPLL_LOG_DEBUG("Inalid operation\n");
+ UPLL_LOG_DEBUG("Inalid operation");
return UPLL_RC_ERR_GENERIC;
}
- result_code = UpdateConfigDB(ck_ppe, UPLL_DT_RUNNING, op, dmi, MAINTBL);
+
+ DbSubOp dbop = {kOpNotRead, kOpMatchNone, kOpInOutNone};
+ dbop.inoutop = kOpInOutCs | kOpInOutFlag;
+ result_code = UpdateConfigDB(ck_ppe, UPLL_DT_RUNNING, op, dmi,
+ &dbop, MAINTBL);
EnqueCfgNotification(op, UPLL_DT_RUNNING, ck_ppe);
delete ck_ppe;
return result_code;
}
bool PolicingProfileEntryMoMgr::CompareValidValue(void *&val1, void *val2,
- bool audit) {
+ bool copy_to_running) {
UPLL_FUNC_TRACE;
+ bool invalid_attr = true;
val_policingprofile_entry_t *val_pp_entry1 =
reinterpret_cast<val_policingprofile_entry_t *>(val1);
val_policingprofile_entry_t *val_pp_entry2 =
if (val_pp_entry1->valid[UPLL_IDX_RATE_PPE] == UNC_VF_VALID
&& val_pp_entry2->valid[UPLL_IDX_RATE_PPE] == UNC_VF_VALID) {
if (val_pp_entry1->rate == val_pp_entry2->rate) {
- val_pp_entry1->valid[UPLL_IDX_RATE_PPE] = UNC_VF_INVALID;
+ val_pp_entry1->valid[UPLL_IDX_RATE_PPE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
}
if (val_pp_entry1->valid[UPLL_IDX_CIR_PPE] == UNC_VF_VALID
&& val_pp_entry2->valid[UPLL_IDX_CIR_PPE] == UNC_VF_VALID) {
if (val_pp_entry1->cir == val_pp_entry2->cir)
- val_pp_entry1->valid[UPLL_IDX_CIR_PPE] = UNC_VF_INVALID;
+ val_pp_entry1->valid[UPLL_IDX_CIR_PPE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_pp_entry1->valid[UPLL_IDX_CBS_PPE] == UNC_VF_VALID
&& val_pp_entry2->valid[UPLL_IDX_CBS_PPE] == UNC_VF_VALID) {
if (val_pp_entry1->cbs == val_pp_entry2->cbs)
- val_pp_entry1->valid[UPLL_IDX_CBS_PPE] = UNC_VF_INVALID;
+ val_pp_entry1->valid[UPLL_IDX_CBS_PPE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_pp_entry1->valid[UPLL_IDX_PIR_PPE] == UNC_VF_VALID
&& val_pp_entry2->valid[UPLL_IDX_PIR_PPE] == UNC_VF_VALID) {
if (val_pp_entry1->pir == val_pp_entry2->pir)
- val_pp_entry1->valid[UPLL_IDX_PIR_PPE] = UNC_VF_INVALID;
+ val_pp_entry1->valid[UPLL_IDX_PIR_PPE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_pp_entry1->valid[UPLL_IDX_PBS_PPE] == UNC_VF_VALID
&& val_pp_entry2->valid[UPLL_IDX_PBS_PPE] == UNC_VF_VALID) {
if (val_pp_entry1->pbs == val_pp_entry2->pbs)
- val_pp_entry1->valid[UPLL_IDX_PBS_PPE] = UNC_VF_INVALID;
+ val_pp_entry1->valid[UPLL_IDX_PBS_PPE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_pp_entry1->valid[UPLL_IDX_GREEN_ACTION_PPE] == UNC_VF_VALID
&& val_pp_entry2->valid[UPLL_IDX_GREEN_ACTION_PPE] == UNC_VF_VALID) {
if (val_pp_entry1->green_action == val_pp_entry2->green_action)
- val_pp_entry1->valid[UPLL_IDX_GREEN_ACTION_PPE] = UNC_VF_INVALID;
+ val_pp_entry1->valid[UPLL_IDX_GREEN_ACTION_PPE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_pp_entry1->valid[UPLL_IDX_GREEN_PRIORITY_PPE] == UNC_VF_VALID
&& val_pp_entry2->valid[UPLL_IDX_GREEN_PRIORITY_PPE] == UNC_VF_VALID) {
- if (val_pp_entry1->green_action_priority !=
+ if (val_pp_entry1->green_action_priority ==
val_pp_entry2->green_action_priority)
- val_pp_entry1->valid[UPLL_IDX_GREEN_PRIORITY_PPE] = UNC_VF_INVALID;
+ val_pp_entry1->valid[UPLL_IDX_GREEN_PRIORITY_PPE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_pp_entry1->valid[UPLL_IDX_GREEN_DSCP_PPE] == UNC_VF_VALID
&& val_pp_entry2->valid[UPLL_IDX_GREEN_DSCP_PPE] == UNC_VF_VALID) {
if (val_pp_entry1->green_action_dscp == val_pp_entry2->green_action_dscp)
- val_pp_entry1->valid[UPLL_IDX_GREEN_DSCP_PPE] = UNC_VF_INVALID;
+ val_pp_entry1->valid[UPLL_IDX_GREEN_DSCP_PPE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_pp_entry1->valid[UPLL_IDX_GREEN_DROP_PPE] == UNC_VF_VALID
&& val_pp_entry2->valid[UPLL_IDX_GREEN_DROP_PPE] == UNC_VF_VALID) {
if (val_pp_entry1->green_action_drop_precedence ==
val_pp_entry2->green_action_drop_precedence)
- val_pp_entry1->valid[UPLL_IDX_GREEN_DROP_PPE] = UNC_VF_INVALID;
+ val_pp_entry1->valid[UPLL_IDX_GREEN_DROP_PPE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_pp_entry1->valid[UPLL_IDX_YELLOW_ACTION_PPE] == UNC_VF_VALID
&& val_pp_entry2->valid[UPLL_IDX_YELLOW_ACTION_PPE] == UNC_VF_VALID) {
if (val_pp_entry1->yellow_action == val_pp_entry2->yellow_action)
- val_pp_entry1->valid[UPLL_IDX_YELLOW_ACTION_PPE] = UNC_VF_INVALID;
+ val_pp_entry1->valid[UPLL_IDX_YELLOW_ACTION_PPE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_pp_entry1->valid[UPLL_IDX_YELLOW_PRIORITY_PPE] == UNC_VF_VALID
&& val_pp_entry2->valid[UPLL_IDX_YELLOW_PRIORITY_PPE] == UNC_VF_VALID) {
if (val_pp_entry1->yellow_action_priority ==
val_pp_entry2->yellow_action_priority)
- val_pp_entry1->valid[UPLL_IDX_YELLOW_PRIORITY_PPE] = UNC_VF_INVALID;
+ val_pp_entry1->valid[UPLL_IDX_YELLOW_PRIORITY_PPE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_pp_entry1->valid[UPLL_IDX_YELLOW_DSCP_PPE] == UNC_VF_VALID
&& val_pp_entry2->valid[UPLL_IDX_YELLOW_DSCP_PPE] == UNC_VF_VALID) {
if (val_pp_entry1->yellow_action_dscp == val_pp_entry2->yellow_action_dscp)
- val_pp_entry1->valid[UPLL_IDX_YELLOW_DSCP_PPE] = UNC_VF_INVALID;
+ val_pp_entry1->valid[UPLL_IDX_YELLOW_DSCP_PPE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_pp_entry1->valid[UPLL_IDX_YELLOW_DROP_PPE] == UNC_VF_VALID
&& val_pp_entry2->valid[UPLL_IDX_YELLOW_DROP_PPE] == UNC_VF_VALID) {
if (val_pp_entry1->yellow_action_drop_precedence ==
val_pp_entry2->yellow_action_drop_precedence)
- val_pp_entry1->valid[UPLL_IDX_YELLOW_DROP_PPE] = UNC_VF_INVALID;
+ val_pp_entry1->valid[UPLL_IDX_YELLOW_DROP_PPE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_pp_entry1->valid[UPLL_IDX_RED_ACTION_PPE] == UNC_VF_VALID
&& val_pp_entry2->valid[UPLL_IDX_RED_ACTION_PPE] == UNC_VF_VALID) {
if (val_pp_entry1->red_action == val_pp_entry2->red_action)
- val_pp_entry1->valid[UPLL_IDX_RED_ACTION_PPE] = UNC_VF_INVALID;
+ val_pp_entry1->valid[UPLL_IDX_RED_ACTION_PPE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_pp_entry1->valid[UPLL_IDX_RED_PRIORITY_PPE] == UNC_VF_VALID
&& val_pp_entry2->valid[UPLL_IDX_RED_PRIORITY_PPE] == UNC_VF_VALID) {
if (val_pp_entry1->red_action_priority ==
val_pp_entry2->red_action_priority)
- val_pp_entry1->valid[UPLL_IDX_RED_PRIORITY_PPE] = UNC_VF_INVALID;
+ val_pp_entry1->valid[UPLL_IDX_RED_PRIORITY_PPE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_pp_entry1->valid[UPLL_IDX_RED_DSCP_PPE] == UNC_VF_VALID
&& val_pp_entry2->valid[UPLL_IDX_RED_DSCP_PPE] == UNC_VF_VALID) {
if (val_pp_entry1->red_action_dscp ==
val_pp_entry2->red_action_dscp)
- val_pp_entry1->valid[UPLL_IDX_RED_DSCP_PPE] = UNC_VF_INVALID;
+ val_pp_entry1->valid[UPLL_IDX_RED_DSCP_PPE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_pp_entry1->valid[UPLL_IDX_RED_DROP_PPE] == UNC_VF_VALID
&& val_pp_entry2->valid[UPLL_IDX_RED_DROP_PPE] == UNC_VF_VALID) {
if (val_pp_entry1->red_action_drop_precedence ==
val_pp_entry2->red_action_drop_precedence)
- val_pp_entry1->valid[UPLL_IDX_RED_DROP_PPE] = UNC_VF_INVALID;
+ val_pp_entry1->valid[UPLL_IDX_RED_DROP_PPE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
- return true;
+ for (unsigned int loop = 0;
+ loop < sizeof(val_pp_entry1->valid)/ sizeof(uint8_t); ++loop) {
+ if ((UNC_VF_VALID == (uint8_t) val_pp_entry1->valid[loop]) ||
+ (UNC_VF_VALID_NO_VALUE == (uint8_t) val_pp_entry1->valid[loop]))
+ invalid_attr = false;
+ }
+ return invalid_attr;
}
upll_rc_t PolicingProfileEntryMoMgr::ReadRecord(IpcReqRespHeader *req,
UPLL_LOG_DEBUG(" Input Key is NULL");
return UPLL_RC_ERR_GENERIC;
}
-
+ DELETE_IF_NOT_NULL(okey);
unc_key_type_t ikey_type = ikey->get_key_type();
if (ikey_type != UNC_KT_POLICING_PROFILE_ENTRY) {
UPLL_LOG_DEBUG(" Invalid key type received. Key type - %d", ikey_type);
const char* ctrlr_name) {
UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
if ((NULL == req) || (NULL == ikey)) {
UPLL_LOG_DEBUG("IpcReqRespHeader/ConfigKeyval is NULL");
return UPLL_RC_ERR_GENERIC;
if (!ctrlr_name)
ctrlr_name = static_cast<char *>(ikey->get_user_data());
- uint32_t dt_type = req->datatype;
- uint32_t operation = req->operation;
- uint32_t option1 = req->option1;
- uint32_t option2 = req->option2;
-
- UPLL_LOG_DEBUG("dt_type : (%d)"
- "operation : (%d)"
- "option1 : (%d)"
- "option2 : (%d)",
- dt_type, operation, option1, option2);
+ if (NULL == ctrlr_name) {
+ UPLL_LOG_DEBUG("ctrlr_name is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_TRACE("ctrlr_name(%s), operation : (%d)",
+ ctrlr_name, req->operation);
bool ret_code = false;
- uint32_t instance_count;
+ uint32_t max_instance_count = 0;
const uint8_t *attrs = NULL;
uint32_t max_attrs = 0;
- switch (operation) {
+ switch (req->operation) {
case UNC_OP_CREATE: {
ret_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
- &instance_count, &max_attrs, &attrs);
+ &max_instance_count, &max_attrs, &attrs);
+
+ if (ret_code && (max_instance_count != 0) &&
+ (cur_instance_count >= max_instance_count)) {
+ UPLL_LOG_DEBUG("Instance count %d exceeds %d", cur_instance_count,
+ max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
break;
}
case UNC_OP_UPDATE: {
break;
}
default: {
- ret_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ if (req->datatype == UPLL_DT_STATE)
+ ret_code = GetStateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ else
+ ret_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
&max_attrs, &attrs);
}
}
+
if (!ret_code) {
UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s) "
"for operation(%d)",
- ikey->get_key_type(), ctrlr_name, operation);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ ikey->get_key_type(), ctrlr_name, req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
- val_policingprofile_entry_t *val_policingprofile_entry = NULL;
- /** check valid key, val struct received in ConfigKeyVal */
- if (ikey->get_cfg_val() && (ikey->get_cfg_val()->get_st_num() ==
- IpctSt::kIpcStValPolicingprofileEntry)) {
- val_policingprofile_entry =
+ val_policingprofile_entry_t *val_policingprofile_entry =
reinterpret_cast<val_policingprofile_entry_t *>(
- ikey->get_cfg_val()->get_val());
- }
+ GetVal(ikey));
- if ((operation == UNC_OP_CREATE) || (operation == UNC_OP_UPDATE)) {
- if (dt_type == UPLL_DT_CANDIDATE) {
- if (val_policingprofile_entry) {
- if (max_attrs > 0) {
- return ValPolicingProfileEntryAttributeSupportCheck(
- val_policingprofile_entry, attrs);
- } else {
- UPLL_LOG_DEBUG("Attribute list is empty for operation %d", operation);
- }
- } else {
- UPLL_LOG_DEBUG("Error value struct is mandatory for CREATE/UPDATE");
- return result_code;
- }
- } else {
- UPLL_LOG_DEBUG("Unsupported datatype for CREATE/UPDATE");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else if (READ_SUPPORTED_OPERATION) {
- if (READ_SUPPORTED_DATATYPE) {
- if (option1 != UNC_OPT1_NORMAL) {
- UPLL_LOG_DEBUG(" Error: option1 is not NORMAL");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- if (option2 == UNC_OPT2_NONE) {
- UPLL_LOG_DEBUG(" Error: option2 is not NONE");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- /** Valid options received, validate value struct */
- if (val_policingprofile_entry) {
- if (max_attrs > 0) {
- return ValPolicingProfileEntryAttributeSupportCheck(
- val_policingprofile_entry, attrs);
- } else {
- UPLL_LOG_DEBUG("Attribute list is empty for operation %d", operation);
- }
- }
- return UPLL_RC_SUCCESS;
+ if (val_policingprofile_entry) {
+ if (max_attrs > 0) {
+ return ValPolicingProfileEntryAttributeSupportCheck(
+ val_policingprofile_entry, attrs);
} else {
- UPLL_LOG_DEBUG("Error Unsupported datatype (%d)", dt_type);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d", req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
- } else if (OPEARTION_WITH_VAL_STRUCT_NONE) {
- /** Value struct is NONE for this operations */
- UPLL_LOG_DEBUG("Skip capability check, Operation type is %d", operation);
- return UPLL_RC_SUCCESS;
}
-
- UPLL_LOG_DEBUG("Error Unsupported operation (%d)", operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ return UPLL_RC_SUCCESS;
}
upll_rc_t PolicingProfileEntryMoMgr::
const uint8_t *attrs) {
UPLL_FUNC_TRACE;
- upll_rc_t ret_code = UPLL_RC_ERR_GENERIC;
-
- if (val_policingprofile_entry != NULL) {
- if ((val_policingprofile_entry->valid[UPLL_IDX_FLOWLIST_PPE] ==
- UNC_VF_VALID)
- || (val_policingprofile_entry->valid[UPLL_IDX_FLOWLIST_PPE]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::policingprofile_entry::kCapFlowlist] == 0) {
- UPLL_LOG_DEBUG("FLOWLIST attr is not supported by ctrlr");
- val_policingprofile_entry->valid[UPLL_IDX_FLOWLIST_PPE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
+ if ((val_policingprofile_entry->valid[UPLL_IDX_FLOWLIST_PPE] ==
+ UNC_VF_VALID)
+ || (val_policingprofile_entry->valid[UPLL_IDX_FLOWLIST_PPE]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::policingprofile_entry::kCapFlowlist] == 0) {
+ UPLL_LOG_DEBUG("FLOWLIST attr is not supported by ctrlr");
+ val_policingprofile_entry->valid[UPLL_IDX_FLOWLIST_PPE] =
+ UNC_VF_NOT_SUPPORTED;
}
+ }
- if ((val_policingprofile_entry->valid[UPLL_IDX_RATE_PPE] ==
- UNC_VF_VALID)
- || (val_policingprofile_entry->valid[UPLL_IDX_RATE_PPE]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::policingprofile_entry::kCapRate] == 0) {
- UPLL_LOG_DEBUG("FLOWLIST attr is not supported by ctrlr");
- val_policingprofile_entry->valid[UPLL_IDX_RATE_PPE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
+ if ((val_policingprofile_entry->valid[UPLL_IDX_RATE_PPE] ==
+ UNC_VF_VALID)
+ || (val_policingprofile_entry->valid[UPLL_IDX_RATE_PPE]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::policingprofile_entry::kCapRate] == 0) {
+ UPLL_LOG_DEBUG("FLOWLIST attr is not supported by ctrlr");
+ val_policingprofile_entry->valid[UPLL_IDX_RATE_PPE] =
+ UNC_VF_NOT_SUPPORTED;
}
+ }
- if ((val_policingprofile_entry->valid[UPLL_IDX_CIR_PPE] == UNC_VF_VALID)
- || (val_policingprofile_entry->valid[UPLL_IDX_CIR_PPE]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::policingprofile_entry::kCapCir] == 0) {
- UPLL_LOG_DEBUG("CIR attr is not supported by ctrlr");
- val_policingprofile_entry->valid[UPLL_IDX_CIR_PPE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
+ if ((val_policingprofile_entry->valid[UPLL_IDX_CIR_PPE] == UNC_VF_VALID)
+ || (val_policingprofile_entry->valid[UPLL_IDX_CIR_PPE]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::policingprofile_entry::kCapCir] == 0) {
+ UPLL_LOG_DEBUG("CIR attr is not supported by ctrlr");
+ val_policingprofile_entry->valid[UPLL_IDX_CIR_PPE] =
+ UNC_VF_NOT_SUPPORTED;
}
+ }
- if ((val_policingprofile_entry->valid[UPLL_IDX_CBS_PPE] == UNC_VF_VALID)
- || (val_policingprofile_entry->valid[UPLL_IDX_CBS_PPE]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::policingprofile_entry::kCapCbs] == 0) {
- UPLL_LOG_DEBUG("CBS attr is not supported by ctrlr");
- val_policingprofile_entry->valid[UPLL_IDX_CBS_PPE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
+ if ((val_policingprofile_entry->valid[UPLL_IDX_CBS_PPE] == UNC_VF_VALID)
+ || (val_policingprofile_entry->valid[UPLL_IDX_CBS_PPE]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::policingprofile_entry::kCapCbs] == 0) {
+ UPLL_LOG_DEBUG("CBS attr is not supported by ctrlr");
+ val_policingprofile_entry->valid[UPLL_IDX_CBS_PPE] =
+ UNC_VF_NOT_SUPPORTED;
}
+ }
- if ((val_policingprofile_entry->valid[UPLL_IDX_PIR_PPE] == UNC_VF_VALID)
- || (val_policingprofile_entry->valid[UPLL_IDX_PIR_PPE]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::policingprofile_entry::kCapPir] == 0) {
- UPLL_LOG_DEBUG("PIR attr is not supported by ctrlr");
- val_policingprofile_entry->valid[UPLL_IDX_PIR_PPE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
+ if ((val_policingprofile_entry->valid[UPLL_IDX_PIR_PPE] == UNC_VF_VALID)
+ || (val_policingprofile_entry->valid[UPLL_IDX_PIR_PPE]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::policingprofile_entry::kCapPir] == 0) {
+ UPLL_LOG_DEBUG("PIR attr is not supported by ctrlr");
+ val_policingprofile_entry->valid[UPLL_IDX_PIR_PPE] =
+ UNC_VF_NOT_SUPPORTED;
}
+ }
- if ((val_policingprofile_entry->valid[UPLL_IDX_PBS_PPE] == UNC_VF_VALID)
- || (val_policingprofile_entry->valid[UPLL_IDX_PBS_PPE]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::policingprofile_entry::kCapPbs] == 0) {
- UPLL_LOG_DEBUG("PBS attr is not supported by ctrlr");
- val_policingprofile_entry->valid[UPLL_IDX_PBS_PPE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
+ if ((val_policingprofile_entry->valid[UPLL_IDX_PBS_PPE] == UNC_VF_VALID)
+ || (val_policingprofile_entry->valid[UPLL_IDX_PBS_PPE]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::policingprofile_entry::kCapPbs] == 0) {
+ UPLL_LOG_DEBUG("PBS attr is not supported by ctrlr");
+ val_policingprofile_entry->valid[UPLL_IDX_PBS_PPE] =
+ UNC_VF_NOT_SUPPORTED;
}
+ }
- if ((ret_code
- == ValidateGreenFieldAttribute(val_policingprofile_entry, attrs))
- != UPLL_RC_SUCCESS) {
- return ret_code;
- }
+ ValidateGreenFieldAttribute(val_policingprofile_entry, attrs);
- if ((ret_code == ValidateRedFieldAttribute(val_policingprofile_entry,
- attrs))!= UPLL_RC_SUCCESS) {
- return ret_code;
- }
+ ValidateRedFieldAttribute(val_policingprofile_entry, attrs);
- if ((ret_code
- == ValidateYellowFieldAttribute(val_policingprofile_entry, attrs))
- != UPLL_RC_SUCCESS) {
- return ret_code;
- }
- return UPLL_RC_SUCCESS;
- }
- UPLL_LOG_DEBUG(
- "Error, Unable to validate the attribute since val struct is NULL");
- return UPLL_RC_ERR_CFG_SYNTAX;
+ ValidateYellowFieldAttribute(val_policingprofile_entry, attrs);
+
+ return UPLL_RC_SUCCESS;
}
-upll_rc_t PolicingProfileEntryMoMgr::ValidateGreenFieldAttribute(
+void PolicingProfileEntryMoMgr::ValidateGreenFieldAttribute(
val_policingprofile_entry_t * val_policingprofile_entry,
const uint8_t *attrs) {
UPLL_FUNC_TRACE;
if (attrs[unc::capa::policingprofile_entry::kCapGreenAction] == 0) {
UPLL_LOG_DEBUG("GREEN_ACTION attr is not supported by ctrlr");
val_policingprofile_entry->valid[UPLL_IDX_GREEN_ACTION_PPE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_CFG_SYNTAX;
+ UNC_VF_NOT_SUPPORTED;
}
}
if (attrs[unc::capa::policingprofile_entry::kCapGreenPriority] == 0) {
UPLL_LOG_DEBUG("GREEN_PRIORITY attr is not supported by ctrlr");
val_policingprofile_entry->valid[UPLL_IDX_GREEN_PRIORITY_PPE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_CFG_SYNTAX;
+ UNC_VF_NOT_SUPPORTED;
}
}
if (attrs[unc::capa::policingprofile_entry::kCapGreenDscp] == 0) {
UPLL_LOG_DEBUG("GREEN_DSCP attr is not supported by ctrlr");
val_policingprofile_entry->valid[UPLL_IDX_GREEN_DSCP_PPE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
+ UNC_VF_NOT_SUPPORTED;
+ }
}
if ((val_policingprofile_entry->valid[UPLL_IDX_GREEN_DROP_PPE] ==
if (attrs[unc::capa::policingprofile_entry::kCapGreenDrop] == 0) {
UPLL_LOG_DEBUG("GREEN_DROP attr is not supported by ctrlr");
val_policingprofile_entry->valid[UPLL_IDX_GREEN_DROP_PPE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_CFG_SYNTAX;
+ UNC_VF_NOT_SUPPORTED;
}
}
- return UPLL_RC_SUCCESS;
}
-upll_rc_t PolicingProfileEntryMoMgr::ValidateYellowFieldAttribute(
+void PolicingProfileEntryMoMgr::ValidateYellowFieldAttribute(
val_policingprofile_entry_t * val_policingprofile_entry,
const uint8_t *attrs) {
UPLL_FUNC_TRACE;
if (attrs[unc::capa::policingprofile_entry::kCapYellowAction] == 0) {
UPLL_LOG_DEBUG("YELLOW_ACTION attr is not supported by ctrlr");
val_policingprofile_entry->valid[UPLL_IDX_YELLOW_ACTION_PPE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_CFG_SYNTAX;
+ UNC_VF_NOT_SUPPORTED;
}
}
if (attrs[unc::capa::policingprofile_entry::kCapYellowPriority] == 0) {
UPLL_LOG_DEBUG("YELLOW_PRIORITY attr is not supported by ctrlr");
val_policingprofile_entry->valid[UPLL_IDX_YELLOW_PRIORITY_PPE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
+ UNC_VF_NOT_SUPPORTED;
+ }
}
if ((val_policingprofile_entry->valid[UPLL_IDX_YELLOW_DSCP_PPE]
if (attrs[unc::capa::policingprofile_entry::kCapYellowDscp] == 0) {
UPLL_LOG_DEBUG("YELLOW_DSCP attr is not supported by ctrlr");
val_policingprofile_entry->valid[UPLL_IDX_YELLOW_DSCP_PPE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_CFG_SYNTAX;
+ UNC_VF_NOT_SUPPORTED;
}
}
if (attrs[unc::capa::policingprofile_entry::kCapYellowDrop] == 0) {
UPLL_LOG_DEBUG("YELLOW_DROP attr is not supported by ctrlr");
val_policingprofile_entry->valid[UPLL_IDX_YELLOW_DROP_PPE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_CFG_SYNTAX;
+ UNC_VF_NOT_SUPPORTED;
}
}
- return UPLL_RC_SUCCESS;
}
-upll_rc_t PolicingProfileEntryMoMgr::ValidateRedFieldAttribute(
+void PolicingProfileEntryMoMgr::ValidateRedFieldAttribute(
val_policingprofile_entry_t * val_policingprofile_entry,
const uint8_t *attrs) {
UPLL_FUNC_TRACE;
if (attrs[unc::capa::policingprofile_entry::kCapRedAction] == 0) {
UPLL_LOG_DEBUG("RED_ACTION attr is not supported by ctrlr");
val_policingprofile_entry->valid[UPLL_IDX_RED_ACTION_PPE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_CFG_SYNTAX;
+ UNC_VF_NOT_SUPPORTED;
}
}
if (attrs[unc::capa::policingprofile_entry::kCapRedPriority] == 0) {
UPLL_LOG_DEBUG("RED_PRIORITY attr is not supported by ctrlr");
val_policingprofile_entry->valid[UPLL_IDX_RED_PRIORITY_PPE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_CFG_SYNTAX;
+ UNC_VF_NOT_SUPPORTED;
}
}
if (attrs[unc::capa::policingprofile_entry::kCapRedDscp] == 0) {
UPLL_LOG_DEBUG("RED_DSCP attr is not supported by ctrlr");
val_policingprofile_entry->valid[UPLL_IDX_RED_DSCP_PPE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_CFG_SYNTAX;
+ UNC_VF_NOT_SUPPORTED;
}
}
if (attrs[unc::capa::policingprofile_entry::kCapRedDrop] == 0) {
UPLL_LOG_DEBUG("RED_DROP attr is not supported by ctrlr");
val_policingprofile_entry->valid[UPLL_IDX_RED_DROP_PPE] =
- UNC_VF_NOT_SOPPORTED;
- return UPLL_RC_ERR_CFG_SYNTAX;
+ UNC_VF_NOT_SUPPORTED;
}
}
- return UPLL_RC_SUCCESS;
}
upll_rc_t PolicingProfileEntryMoMgr::CopyToConfigKey(ConfigKeyVal *&okey,
UPLL_FUNC_TRACE;
if (NULL == ikey || NULL ==(ikey->get_key()) ||
NULL != okey) {
+ UPLL_LOG_DEBUG("Invalid Input");
return UPLL_RC_ERR_GENERIC;
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
- if (UNC_KT_POLICING_PROFILE == ikey->get_key_type()) {
- key_rename_vnode_info_t *key_rename =
- reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
-
- key_policingprofile_entry_t *key_policingprofile =
- reinterpret_cast<key_policingprofile_entry_t *>(ConfigKeyVal::Malloc(
- sizeof(key_policingprofile_entry_t)));
- if (!strlen(
- reinterpret_cast<char *>(key_rename->old_policingprofile_name))) {
- free(key_policingprofile);
- return UPLL_RC_ERR_GENERIC;
- }
- uuu::upll_strncpy(
- key_policingprofile->policingprofile_key.policingprofile_name,
- key_rename->old_policingprofile_name,
- (kMaxLenPolicingProfileName + 1));
+ key_rename_vnode_info_t *key_rename =
+ reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
- okey = new ConfigKeyVal(UNC_KT_POLICING_PROFILE,
- IpctSt::kIpcStKeyPolicingprofileEntry,
- key_policingprofile, NULL);
- // free(key_policingprofile);
- } else if (UNC_KT_FLOWLIST == ikey->get_key_type()) {
- key_rename_vnode_info_t *key_rename =
- reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
+ key_policingprofile_entry_t *key_policingprofile =
+ reinterpret_cast<key_policingprofile_entry_t *>(ConfigKeyVal::Malloc(
+ sizeof(key_policingprofile_entry_t)));
+ if (!strlen(
+ reinterpret_cast<char *>(key_rename->old_policingprofile_name))) {
+ UPLL_LOG_DEBUG("key_rename->old_policingprofile_name NULL");
+ if (key_policingprofile) free(key_policingprofile);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(
+ key_policingprofile->policingprofile_key.policingprofile_name,
+ key_rename->old_policingprofile_name,
+ (kMaxLenPolicingProfileName + 1));
- if (!strlen(
- reinterpret_cast<char *>(key_rename->old_flowlist_name))) {
- return UPLL_RC_ERR_GENERIC;
- }
+ okey = new ConfigKeyVal(UNC_KT_POLICING_PROFILE_ENTRY,
+ IpctSt::kIpcStKeyPolicingprofileEntry,
+ key_policingprofile, NULL);
+ if (!okey) {
+ UPLL_LOG_DEBUG("okey NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ return result_code;
+}
- val_policingprofile_entry_t *val =
- reinterpret_cast<val_policingprofile_entry_t *>(ConfigKeyVal::Malloc(
- sizeof(val_policingprofile_entry_t)));
+upll_rc_t PolicingProfileEntryMoMgr::UpdateVnodeVal(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t data_type,
+ bool &no_rename) {
+ UPLL_FUNC_TRACE;
+ ConfigKeyVal *okey = NULL;
+ ConfigKeyVal *kval = NULL;
- uuu::upll_strncpy(val->flowlist,
- key_rename->old_flowlist_name,
- (kMaxLenPolicingProfileName + 1));
+ uint8_t rename = 0;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
- val->valid[UPLL_IDX_FLOWLIST_PPE] = UNC_VF_VALID;
+ key_rename_vnode_info_t *key_rename =
+ reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
+ UPLL_LOG_TRACE("old name (%s) (%s)",key_rename->old_flowlist_name,
+ key_rename->new_flowlist_name);
+ val_policingprofile_entry_t *val_ppe =
+ reinterpret_cast<val_policingprofile_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_policingprofile_entry_t)));
+ if (!val_ppe) {
+ UPLL_LOG_TRACE("val_ppe Failed");
+ return UPLL_RC_ERR_GENERIC;
+ }
- ConfigVal *ckv = new ConfigVal(IpctSt::kIpcStValPolicingprofileEntry, val);
- okey = new ConfigKeyVal(UNC_KT_POLICING_PROFILE,
- IpctSt::kIpcStKeyPolicingprofileEntry, NULL, ckv);
- // free(val);
+ memset(val_ppe, 0, sizeof(val_policingprofile_entry_t));
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_flowlist_name))) {
+ UPLL_LOG_TRACE("old_flowlist_name null");
+ if (val_ppe) free(val_ppe);
+ return UPLL_RC_ERR_GENERIC;
}
- if (!okey) {
+
+ result_code = GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("GetChildConfigKey Failed ");
+ FREE_IF_NOT_NULL(val_ppe);
return UPLL_RC_ERR_GENERIC;
}
+ uuu::upll_strncpy(val_ppe->flowlist, key_rename->old_flowlist_name,
+ (kMaxLenFlowListName + 1));
+ val_ppe->valid[UPLL_IDX_FLOWLIST_PPE] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("policer name and valid (%d) (%s)",
+ val_ppe->valid[UPLL_IDX_FLOWLIST_PPE], val_ppe->flowlist);
+ okey->SetCfgVal(new ConfigVal (IpctSt::kIpcStValPolicingprofileEntry, val_ppe));
+
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutFlag };
+
+ // Read the record of key structure and old policer name in maintbl
+ result_code = ReadConfigDB(okey, data_type, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG(" ReadConfigDB failed ");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ ConfigKeyVal *first_ckv = okey;
+ while (okey != NULL) {
+ // Update the new flowlist name in MAINTBL
+ result_code = GetChildConfigKey(kval, okey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey kval NULL");
+ DELETE_IF_NOT_NULL(first_ckv);
+ return result_code;
+ }
+
+ // Copy the new flowlist name in val_policingprofile_entry
+ val_policingprofile_entry_t *val1 =
+ reinterpret_cast<val_policingprofile_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_policingprofile_entry_t)));
+ if (!val1) return UPLL_RC_ERR_GENERIC;
+ memset(val1, 0, sizeof(val_policingprofile_entry_t));
+
+ // New name null check
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_flowlist_name))) {
+ if (val1) free(val1);
+ UPLL_LOG_DEBUG("new_policingprofile_name NULL");
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(first_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ // Copy the new flowlist name into val_policingprofile_entry_t
+ uuu::upll_strncpy(val1->flowlist, key_rename->new_flowlist_name,
+ (kMaxLenFlowListName + 1));
+ val1->valid[UPLL_IDX_FLOWLIST_PPE] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("policer name and valid (%d) (%s)",
+ val1->valid[UPLL_IDX_FLOWLIST_PPE], val1->flowlist);
+
+ ConfigVal *cval1 = new ConfigVal(IpctSt::kIpcStValPolicingprofileEntry, val1);
+
+ kval->SetCfgVal(cval1);
+
+ GET_USER_DATA_FLAGS(okey, rename);
+
+ if (!no_rename)
+ rename = rename | FLOWLIST_RENAME;
+ else
+ rename = rename & NO_FLOWLIST_RENAME;
+
+ SET_USER_DATA_FLAGS(kval, rename);
+
+ // Update the new flowlist name in MAINTBL
+ result_code = UpdateConfigDB(kval, data_type, UNC_OP_UPDATE, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Create record Err in vtnpolicingmaptbl CANDIDATE DB(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(first_ckv);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(kval);
+ okey = okey->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(first_ckv);
return result_code;
}
DbSubOp dbop1 = { kOpReadMultiple, kOpMatchNone, kOpInOutFlag };
result_code = ReadConfigDB(okey, data_type, UNC_OP_READ, dbop1, dmi, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
- delete key_rename;
+ free(key_rename);
return result_code;
}
while (okey) {
result_code = GetChildConfigKey(tmp_key, okey);
if (result_code != UPLL_RC_SUCCESS) {
- delete key_rename; // COV RESOURCE LEAK FIC
+ free(key_rename); // COV RESOURCE LEAK FIC
return result_code;
}
result_code = GetChildConfigKey(ctrlr_tmp_key, okey);
if (result_code != UPLL_RC_SUCCESS) {
// COV RESOURCE LEAK FIX
delete tmp_key;
- delete key_rename;
+ free(key_rename);
return result_code;
}
if (!tmp_key || !(tmp_key->get_key())) { // COVERITY FORWARD NULL
delete ctrlr_tmp_key; // COV RESOURCE LEAK FIX
- delete key_rename;
+ free(key_rename);
delete tmp_key;
return UPLL_RC_ERR_GENERIC;
}
// COVERITY FORWARD NULL
if (!ctrlr_tmp_key || !(ctrlr_tmp_key->get_key())) {
// COV RESOURCE LEAK FIX
- delete key_rename;
+ free(key_rename);
delete ctrlr_tmp_key;
delete tmp_key;
return UPLL_RC_ERR_GENERIC;
result_code = UpdateRenameKey(tmp_key, data_type, UNC_OP_UPDATE, dmi, &dbop,
MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(tmp_key);
+ DELETE_IF_NOT_NULL(ctrlr_tmp_key);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
SET_USER_DATA_CTRLR(ctrlr_tmp_key, ctrlr_id);
result_code = UpdateRenameKey(tmp_key, data_type, UNC_OP_UPDATE, dmi,
&dbop1, CTRLRTBL);
if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(tmp_key);
+ DELETE_IF_NOT_NULL(ctrlr_tmp_key);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
- if (tmp_key) {
- free(tmp_key->get_key());
- delete tmp_key;
- }
- if (ctrlr_tmp_key) {
- free(ctrlr_tmp_key->get_key());
- delete ctrlr_tmp_key;
- }
+ // Check with Sarath - Start
+ DELETE_IF_NOT_NULL(tmp_key);
+ DELETE_IF_NOT_NULL(ctrlr_tmp_key);
okey = okey->get_next_cfg_key_val();
}
- if (okey) { // TODO(Author) has to fix the issue
- free(okey->get_key());
- delete okey;
- }
- delete key_rename;
+ DELETE_IF_NOT_NULL(okey); // Logically dead code
+ FREE_IF_NOT_NULL(key_rename);
return result_code;
}
UPLL_FUNC_TRACE;
key_policingprofile_entry *key =
reinterpret_cast<key_policingprofile_entry *>(ikey);
- UPLL_LOG_TRACE("Entering IsValidKey");
- bool ret_val = UPLL_RC_SUCCESS;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
if (index == uudst::policingprofile_entry::kDbiPolicingProfileName) {
ret_val = ValidateKey(
policingprofile_name,
ctrlr_id);
if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ppe_ckv);
return result_code;
}
result_code = GetPolicingprofileKeyVal(okey, ppe_ckv);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetPolicingprofileKeyVal failed %d", result_code);
+ DELETE_IF_NOT_NULL(ppe_ckv);
return result_code;
}
PolicingProfileMoMgr *mgr = reinterpret_cast<PolicingProfileMoMgr *>
(const_cast<MoManager *>(GetMoManager(UNC_KT_POLICING_PROFILE)));
+ if (NULL == mgr) {
+ UPLL_LOG_DEBUG("mgr is NULL");
+ DELETE_IF_NOT_NULL(ppe_ckv);
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
DbSubOp dbop = { kOpReadExist, kOpMatchCtrlr, kOpInOutNone };
result_code = mgr->UpdateConfigDB(okey, dt_type, UNC_OP_READ, dmi, &dbop,
CTRLRTBL);
if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
UPLL_LOG_DEBUG("Delete in entry table");
result_code = CtrlrTblDelete(ppe_ckv, dmi, dt_type);
+ DELETE_IF_NOT_NULL(okey);
} else if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
- UPLL_LOG_DEBUG("Dont delete return success");
- return UPLL_RC_SUCCESS;
+ UPLL_LOG_DEBUG("Dont delete . Drecrement refcount in flowlist");
+ result_code = DecrementRefCount(okey, dmi, dt_type);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DecrementRefCount failed %d", result_code);
+ DELETE_IF_NOT_NULL(ppe_ckv);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(ppe_ckv);
+ DELETE_IF_NOT_NULL(okey);
} else {
UPLL_LOG_DEBUG("Update configdb failed %d", result_code);
- delete ppe_ckv;
- delete okey;
+ DELETE_IF_NOT_NULL(ppe_ckv);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
} else {
result_code = UPLL_RC_ERR_NO_SUCH_OPERATION;
}
- delete ppe_ckv; // COV RESOURCE LEAK FIX
+ DELETE_IF_NOT_NULL(ppe_ckv); // COV RESOURCE LEAK FIX
return result_code;
}
+upll_rc_t PolicingProfileEntryMoMgr::DecrementRefCount(
+ ConfigKeyVal *ppe_ckv, DalDmlIntf *dmi, upll_keytype_datatype_t dt_type) {
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *temp_ckv = NULL;
+ uint8_t *ctrlr_id = NULL;
+ result_code = GetChildConfigKey(temp_ckv, ppe_ckv);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
+ return result_code;
+ }
+ DbSubOp dbop1 = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
+ result_code = ReadConfigDB(temp_ckv, dt_type, UNC_OP_READ, dbop1,
+ dmi, MAINTBL);
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("No entry in policingprofile entry maintbl");
+ DELETE_IF_NOT_NULL(temp_ckv);
+ return UPLL_RC_SUCCESS;
+ }
+ ConfigKeyVal *loop_ckv = temp_ckv;
+ while (loop_ckv) {
+ GET_USER_DATA_CTRLR(loop_ckv, ctrlr_id);
+ val_policingprofile_entry_t *temp_ppe_val = reinterpret_cast
+ <val_policingprofile_entry_t *>(GetVal(loop_ckv));
+ if (NULL == temp_ppe_val) {
+ UPLL_LOG_DEBUG("val_policingprofile_entry is NULL");
+ DELETE_IF_NOT_NULL(temp_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (UNC_VF_VALID == temp_ppe_val->valid[UPLL_IDX_FLOWLIST_PPE ]) {
+ FlowListMoMgr *flowlist_mgr = reinterpret_cast<FlowListMoMgr *>
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
+ if (NULL == flowlist_mgr) {
+ UPLL_LOG_DEBUG("flowlist_mgr is NULL");
+ DELETE_IF_NOT_NULL(temp_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = flowlist_mgr->AddFlowListToController(
+ reinterpret_cast<char *>(temp_ppe_val->flowlist), dmi,
+ reinterpret_cast<char *>(ctrlr_id), dt_type, UNC_OP_DELETE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ continue;
+ }
+ UPLL_LOG_DEBUG("AddFlowListToController failed err code(%d)",
+ result_code)
+ DELETE_IF_NOT_NULL(temp_ckv);
+ return result_code;
+ }
+ }
+ loop_ckv = loop_ckv->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(temp_ckv);
+ return UPLL_RC_SUCCESS;
+}
+
upll_rc_t PolicingProfileEntryMoMgr::CtrlrTblDelete(
ConfigKeyVal *ppe_ckv, DalDmlIntf *dmi, upll_keytype_datatype_t dt_type) {
UPLL_FUNC_TRACE;
dmi, MAINTBL);
if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
UPLL_LOG_DEBUG("No entry in policingprofile entry maintbl");
+ DELETE_IF_NOT_NULL(temp_ckv);
return UPLL_RC_SUCCESS;
}
-
- while (temp_ckv) {
- GET_USER_DATA_CTRLR(temp_ckv, ctrlr_id);
+ ConfigKeyVal *loop_ckv = temp_ckv;
+ while (loop_ckv) {
+ GET_USER_DATA_CTRLR(loop_ckv, ctrlr_id);
val_policingprofile_entry_t *temp_ppe_val = reinterpret_cast
- <val_policingprofile_entry_t *>(GetVal(temp_ckv));
+ <val_policingprofile_entry_t *>(GetVal(loop_ckv));
+ if (NULL == temp_ppe_val) {
+ UPLL_LOG_DEBUG("val_policingprofile_entry is NULL");
+ DELETE_IF_NOT_NULL(temp_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
if (UNC_VF_VALID == temp_ppe_val->valid[UPLL_IDX_FLOWLIST_PPE ]) {
FlowListMoMgr *flowlist_mgr = reinterpret_cast<FlowListMoMgr *>
(const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
result_code = flowlist_mgr->AddFlowListToController(
reinterpret_cast<char *>(temp_ppe_val->flowlist), dmi,
- reinterpret_cast<char *>(ctrlr_id) , UNC_OP_DELETE);
+ reinterpret_cast<char *>(ctrlr_id), dt_type, UNC_OP_DELETE);
if (result_code != UPLL_RC_SUCCESS) {
if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ loop_ckv = loop_ckv->get_next_cfg_key_val();
continue;
}
UPLL_LOG_DEBUG("AddFlowListToController failed err code(%d)",
result_code)
- delete temp_ckv;
+ DELETE_IF_NOT_NULL(temp_ckv);
return result_code;
}
}
- temp_ckv = temp_ckv->get_next_cfg_key_val();
+ loop_ckv = loop_ckv->get_next_cfg_key_val();
}
+ DELETE_IF_NOT_NULL(temp_ckv);
DbSubOp dbop = { kOpNotRead, kOpMatchCtrlr, kOpInOutNone };
result_code = UpdateConfigDB(ppe_ckv, dt_type, UNC_OP_DELETE, dmi, &dbop,
CTRLRTBL);
upll_rc_t result_code = UPLL_RC_SUCCESS;
uint8_t *ctrlr_id = NULL;
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCs };
result_code = ReadConfigDB(ppe_ckv, dt_type, UNC_OP_READ, dbop, dmi, MAINTBL);
if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
GET_USER_DATA_CTRLR(ppe_ckv, ctrlr_id);
val_policingprofile_entry_t *temp_ppe_val = reinterpret_cast
<val_policingprofile_entry_t *>(GetVal(ppe_ckv));
+ if (NULL == temp_ppe_val) {
+ UPLL_LOG_DEBUG("PolicingprofileEntry val is Null");
+ free(req_header);
+ return UPLL_RC_ERR_GENERIC;
+ }
if (UNC_VF_VALID == temp_ppe_val->valid[UPLL_IDX_FLOWLIST_PPE ]) {
FlowListMoMgr *flowlist_mgr = reinterpret_cast<FlowListMoMgr *>
(const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
+ if (NULL == flowlist_mgr) {
+ UPLL_LOG_DEBUG("flowlist_mgr is NULL");
+ free(req_header);
+ return UPLL_RC_ERR_GENERIC;
+ }
result_code = flowlist_mgr->AddFlowListToController(
reinterpret_cast<char *>(temp_ppe_val->flowlist), dmi,
- reinterpret_cast<char *>(ctrlr_id) , UNC_OP_CREATE);
+ reinterpret_cast<char *>(ctrlr_id), dt_type, UNC_OP_CREATE);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("AddFlowListToController failed err code(%d)",
result_code)
CTRLRTBL);
if (UPLL_RC_SUCCESS == result_code) {
ppe_ckv = ppe_ckv->get_next_cfg_key_val();
+ DELETE_IF_NOT_NULL(new_ppe);
continue;
} else if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
UPLL_LOG_DEBUG("CtrlrTbl create failed %d", result_code);
free(req_header);
+ DELETE_IF_NOT_NULL(new_ppe);
return result_code;
}
val_policingprofile_entry_ctrl_t *val_ctrlr =
reinterpret_cast<val_policingprofile_entry_ctrl_t*>(GetVal(new_ppe));
if (NULL == val_ctrlr) {
free(req_header);
+ DELETE_IF_NOT_NULL(new_ppe);
return UPLL_RC_ERR_GENERIC;
}
val_policingprofile_entry_t *val =
reinterpret_cast<val_policingprofile_entry_t *>(GetVal(ppe_ckv));
val_ctrlr->cs_row_status = (unc_keytype_configstatus_t)val->cs_row_status;
- /*result_code = ValidateCapability(req_header, ppe_ckv,
- reinterpret_cast<const char *>(ctrlr_id));
- if (result_code != UPLL_RC_SUCCESS
- || result_code != UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR) {
- free(val_ctrlr);
- delete ppe_ckv;
+
+ // capability check
+ ConfigKeyVal *temp_key = NULL;
+ result_code = GetChildConfigKey(temp_key, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(new_ppe);
+ free(req_header);
+ UPLL_LOG_DEBUG("GetChildConfigKey failed(%d)",result_code);
+ return result_code;
+ }
+
+ result_code = GetInstanceCount(temp_key,
+ reinterpret_cast<char*>(ctrlr_id),
+ dt_type,
+ &cur_instance_count,
+ dmi, CTRLRTBL);
+ DELETE_IF_NOT_NULL(temp_key);
+
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(new_ppe);
free(req_header);
+ UPLL_LOG_DEBUG("GetInstanceCount failed(%d)",result_code);
return result_code;
- }*/
- // TODO(Author) has to fix th eissue DEAD CODE
+ }
+
+ result_code = ValidateCapability(
+ req_header, ppe_ckv, reinterpret_cast<char *>(ctrlr_id));
+ unc_keytype_ctrtype_t ctrlrtype = UNC_CT_UNKNOWN;
+ uuc::CtrlrMgr *ctrlr_mgr = uuc::CtrlrMgr::GetInstance();
+ if (result_code != UPLL_RC_SUCCESS) {
+ // Policingprofile is not supported for other than PFC Controller
+ // so skip adding entry for such sontroller in ctrlr table
+ DELETE_IF_NOT_NULL(new_ppe);
+ if ((!ctrlr_mgr->GetCtrlrType(reinterpret_cast<char *>(ctrlr_id),
+ dt_type, &ctrlrtype)) || (ctrlrtype != UNC_CT_PFC)) {
+ result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_DEBUG("Controller type is %d", ctrlrtype);
+ ppe_ckv = ppe_ckv->get_next_cfg_key_val();
+ continue;
+ }
+ free(req_header);
+ UPLL_LOG_DEBUG("Key not supported by controller");
+ return result_code;
+ }
+
for (unsigned int loop = 0;
loop < (sizeof(val_ctrlr->valid)/sizeof(val_ctrlr->valid[0]));
loop++) {
- val_ctrlr->valid[loop] = val->valid[loop];
+ if (val->valid[loop] == UNC_VF_NOT_SUPPORTED)
+ val_ctrlr->valid[loop] = UNC_VF_INVALID;
+ else
+ val_ctrlr->valid[loop] = val->valid[loop];
UPLL_LOG_DEBUG("valid of %d - %d ctrlrtbl - %d", loop, val->valid[loop],
val_ctrlr->valid[loop]);
}
- // ppe_ckv(Author) has to fic the issue UNUSED_VALUE
- string s(new_ppe->ToStrAll());
- UPLL_LOG_INFO("%s new_ppe Policingprofile", s.c_str());
- string s1(ppe_ckv->ToStrAll());
- UPLL_LOG_INFO("%s ppe_ckv Policingprofile", s1.c_str());
+ //Audit
+ if (UPLL_DT_AUDIT == dt_type) {
+ UPLL_LOG_DEBUG("Audit db setting cs");
+ for (unsigned int loop = 0;
+ loop < (sizeof(val_ctrlr->valid)/sizeof(val_ctrlr->valid[0]));
+ loop++) {
+ val_ctrlr->cs_attr[loop] = (unc_keytype_configstatus_t)val->cs_attr[loop];
+ }
+ val_ctrlr->cs_row_status = (unc_keytype_configstatus_t)val->cs_row_status;
+ }
result_code = UpdateConfigDB(new_ppe, dt_type, UNC_OP_CREATE, dmi,
CTRLRTBL);
if (UPLL_RC_SUCCESS != result_code) {
- delete new_ppe;
+ DELETE_IF_NOT_NULL(new_ppe);
free(req_header);
return result_code;
}
ppe_ckv = ppe_ckv->get_next_cfg_key_val();
- delete new_ppe;
+ DELETE_IF_NOT_NULL(new_ppe);
}
free(req_header);
return UPLL_RC_SUCCESS;
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *ckv = NULL;
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCs};
result_code = GetChildConfigKey(ckv, ikey);
if (UPLL_RC_SUCCESS != result_code) {
return result_code;
}
std::vector < list<unc_keytype_configstatus_t> > vec_attr;
std::list < unc_keytype_configstatus_t > list_cs_row;
- val_policingprofile_entry_t *val;
+ val_policingprofile_entry_ctrl_t *val;
for (unsigned int loop = 0; loop < sizeof(val->valid)/sizeof(val->valid[0]);
++loop) {
std::list < unc_keytype_configstatus_t > list_attr;
vec_attr.push_back(list_attr);
}
- for (; ckv != NULL; ckv = ckv->get_next_cfg_key_val()) {
- val = reinterpret_cast<val_policingprofile_entry_t *>(GetVal(ckv));
+ ConfigKeyVal *temp_ckv = ckv;
+ for (; temp_ckv != NULL; temp_ckv = temp_ckv->get_next_cfg_key_val()) {
+ val = reinterpret_cast<val_policingprofile_entry_ctrl_t *>
+ (GetVal(temp_ckv));
list_cs_row.push_back((unc_keytype_configstatus_t) val->cs_row_status);
for (unsigned int loop = 0; loop < sizeof(val->valid)/
sizeof(val->valid[0]); ++loop) {
if (UPLL_RC_SUCCESS != result_code) {
return result_code;
}
+ DELETE_IF_NOT_NULL(ckv);
return result_code;
}
upll_rc_t PolicingProfileEntryMoMgr::ReadPolicingProfileEntry(
const char *policingprofile_name, uint8_t seq_num, const char *ctrlr_id,
- DalDmlIntf *dmi, upll_keytype_datatype_t dt_type, ConfigKeyVal *&ppe_ckv) {
+ DalDmlIntf *dmi, upll_keytype_datatype_t dt_type, ConfigKeyVal *&ppe_ckv,
+ unc_keytype_option1_t opt1) {
UPLL_FUNC_TRACE;
+
+ const uint8_t *attrs = NULL;
+ uint32_t max_attrs = 0;
upll_rc_t result_code;
if (NULL == policingprofile_name || (!ctrlr_id) || (!dmi)) { // FORWARD NULL
return UPLL_RC_ERR_GENERIC;
val_policingprofile_entry_ctrl_t *ctrl_val =
reinterpret_cast<val_policingprofile_entry_ctrl_t *>(GetVal(ctrlr_ckv));
val->cs_row_status = ctrl_val->cs_row_status;
- for (unsigned int loop = 0; loop <
- sizeof(val->valid[loop]/sizeof(val->valid[0])); loop++) {
- val->valid[loop] = ctrl_val->valid[loop];
- val->cs_attr[loop] = ctrl_val->cs_attr[loop];
+ bool ret_code = false;
+
+ if ((opt1 == UNC_OPT1_DETAIL) && (dt_type == UPLL_DT_STATE)) {
+ ret_code = GetStateCapability(ctrlr_id, UNC_KT_POLICING_PROFILE_ENTRY,
+ &max_attrs, &attrs);
+ if (!ret_code ) {
+ UPLL_LOG_DEBUG("GetStateCapability Is failed in PolicingProfileEntry %d",
+ ret_code);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ if (max_attrs>0) {
+ result_code = ValPolicingProfileEntryAttributeSupportCheck(
+ val, attrs);
+ }
+ for (unsigned int loop = 0; loop <
+ sizeof(val->valid[loop]/sizeof(val->valid[0])); loop++) {
+ val->cs_attr[loop] = ctrl_val->cs_attr[loop];
+ }
+ } else {
+ for (unsigned int loop = 0; loop <
+ sizeof(val->valid[loop]/sizeof(val->valid[0])); loop++) {
+ val->valid[loop] = ctrl_val->valid[loop];
+ val->cs_attr[loop] = ctrl_val->cs_attr[loop];
+ }
}
+
+ if (val->valid[UPLL_IDX_FLOWLIST_PPE] != UNC_VF_VALID) {
+ uuu::upll_strncpy(val->flowlist,
+ "\0", (kMaxLenFlowListName + 1));
+ }
+ if (val->valid[UPLL_IDX_CBS_PPE] != UNC_VF_VALID) {
+ val->cbs = 0;
+ }
+ if (val->valid[UPLL_IDX_PIR_PPE] != UNC_VF_VALID) {
+ val->pir = 0;
+ }
+ if (val->valid[UPLL_IDX_PBS_PPE] != UNC_VF_VALID) {
+ val->pbs = 0;
+ }
+ if (val->valid[UPLL_IDX_GREEN_ACTION_PPE] != UNC_VF_VALID) {
+ val->green_action = 0;
+ }
+ if (val->valid[UPLL_IDX_GREEN_PRIORITY_PPE] != UNC_VF_VALID) {
+ val->green_action_priority = 0;
+ }
+ if (val->valid[UPLL_IDX_GREEN_DSCP_PPE] != UNC_VF_VALID) {
+ val->green_action_dscp = 0;
+ }
+ if (val->valid[UPLL_IDX_GREEN_DROP_PPE] != UNC_VF_VALID) {
+ val->green_action_drop_precedence = 0;
+ }
+
+ if (val->valid[UPLL_IDX_YELLOW_ACTION_PPE] != UNC_VF_VALID) {
+ val->yellow_action = 0;
+ }
+
+ if (val->valid[UPLL_IDX_YELLOW_PRIORITY_PPE] != UNC_VF_VALID) {
+ val->yellow_action_priority = 0;
+ }
+
+ if (val->valid[UPLL_IDX_YELLOW_DSCP_PPE] != UNC_VF_VALID) {
+ val->yellow_action_dscp = 0;
+ }
+
+ if (val->valid[UPLL_IDX_YELLOW_DROP_PPE] != UNC_VF_VALID) {
+ val->yellow_action_drop_precedence = 0;
+ }
+
+ if (val->valid[UPLL_IDX_RED_ACTION_PPE] != UNC_VF_VALID) {
+ val->red_action = 0;
+ }
+
+ if (val->valid[UPLL_IDX_RED_PRIORITY_PPE] != UNC_VF_VALID) {
+ val->red_action_priority = 0;
+ }
+
+ if (val->valid[UPLL_IDX_RED_DSCP_PPE] != UNC_VF_VALID) {
+ val->red_action_dscp = 0;
+ }
+
+ if (val->valid[UPLL_IDX_RED_DROP_PPE] != UNC_VF_VALID) {
+ val->red_action_drop_precedence = 0;
+ }
+
temp_ckv = temp_ckv->get_next_cfg_key_val();
delete ctrlr_ckv;
}
default :
valid = NULL;
- break;
+ return UPLL_RC_ERR_GENERIC;
}
return UPLL_RC_SUCCESS;
}
-upll_rc_t PolicingProfileEntryMoMgr::UpdateConfigStatus(ConfigKeyVal *key,
- unc_keytype_operation_t op, uint32_t driver_result, ConfigKeyVal *nreq,
- DalDmlIntf *dmi, ConfigKeyVal *ctrlr_key) {
- UPLL_FUNC_TRACE;
- // char obj;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- unc_keytype_configstatus_t status = UNC_CS_UNKNOWN,
- cs_status = UNC_CS_UNKNOWN;
- cs_status = (driver_result == 0) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
- if ((NULL == ctrlr_key) || (NULL == key)) return UPLL_RC_ERR_GENERIC;
- val_policingprofile_entry_t *ppe_val =
- reinterpret_cast<val_policingprofile_entry_t *>(GetVal(key));
- val_policingprofile_entry_ctrl *ppe_ctrlr_val =
- reinterpret_cast<val_policingprofile_entry_ctrl*>(GetVal(ctrlr_key));
- if ((ppe_val == NULL) || (NULL == ppe_ctrlr_val)) {
- UPLL_LOG_DEBUG("ppe_val not supported :-");
- return UPLL_RC_ERR_GENERIC;
- }
- if (op == UNC_OP_CREATE) {
- switch (ppe_val->cs_row_status) {
- case UNC_CS_UNKNOWN:
- status = cs_status;
- break;
- case UNC_CS_PARTAILLY_APPLIED:
- if (ppe_ctrlr_val->cs_row_status == UNC_CS_NOT_APPLIED) {
- /* changes need to do */
- }
- case UNC_CS_APPLIED:
- case UNC_CS_NOT_APPLIED:
- case UNC_CS_INVALID:
- default:
- status =
- (cs_status == UNC_CS_APPLIED) ? UNC_CS_PARTAILLY_APPLIED : status;
- break;
- }
- ppe_val->cs_row_status = status;
- for (unsigned int loop = 0;
- loop < sizeof(ppe_val->valid)/sizeof(ppe_val->valid[0]);
- ++loop) {
- // Setting CS to the not supported attributes
- if (UNC_VF_NOT_SOPPORTED == ppe_val->valid[loop]) {
- ppe_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
- continue;
- }
- if (UNC_VF_NOT_SOPPORTED == ppe_ctrlr_val->valid[loop]) {
- ppe_ctrlr_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
- continue;
- }
- if ((UNC_VF_VALID == ppe_val->valid[loop]) ||
- (UNC_VF_VALID_NO_VALUE == ppe_val->valid[loop]))
- if (ppe_ctrlr_val->valid[loop] != UNC_VF_NOT_SOPPORTED) {
- ppe_ctrlr_val->cs_attr[loop] = cs_status;
- ppe_val->cs_attr[loop] = (uint8_t)ppe_val->cs_row_status;
- }
- }
-
- } else if (op == UNC_OP_UPDATE) {
- // void *flowlistentryval = NULL;
- void* ppeval_1 = GetVal(key);
- void* ppeval_2 = GetVal(nreq);
- CompareValidValue(ppeval_1, ppeval_2, false);
- for (unsigned int loop = 0;
- loop < sizeof(ppe_val->valid) / sizeof(ppe_val->valid[0]);
- ++loop) {
- if (ppe_ctrlr_val->valid[loop] != UNC_VF_NOT_SOPPORTED) {
- ppe_ctrlr_val->cs_attr[loop] = cs_status;
- } else {
- ppe_ctrlr_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
- }
- ppe_val->cs_attr[loop] = (uint8_t)ppe_val->cs_row_status;
- }
- }
- return result_code;
-}
-
-
-#if 0
-upll_rc_t PolicingProfileEntryMoMgr::UpdateConfigStatus(ConfigKeyVal *ppe_key,
- unc_keytype_operation_t op, uint32_t driver_result, ConfigKeyVal *upd_key,
- DalDmlIntf *dmi, ConfigKeyVal *ctrlr_key) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- val_policingprofile_entry_t *ppe_val = NULL;
-
- unc_keytype_configstatus_t cs_status =
- (driver_result == UPLL_RC_SUCCESS) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
- ppe_val = reinterpret_cast<val_policingprofile_entry_t *>(GetVal(ppe_key));
- if (ppe_val == NULL) {
- return UPLL_RC_ERR_GENERIC;
- }
- ppe_val->cs_row_status = cs_status;
- if (op == UNC_OP_CREATE) {
- for (unsigned int loop = 0; loop < sizeof(ppe_val->valid) /
- sizeof(ppe_val->valid[0]); ++loop) {
- /* Setting CS to the not supported attributes */
- if (UNC_VF_NOT_SOPPORTED == ppe_val->valid[loop]) {
- ppe_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
- continue;
- }
- if ((UNC_VF_VALID == ppe_val->valid[loop])
- || (UNC_VF_VALID_NO_VALUE == ppe_val->valid[loop]))
- ppe_val->cs_attr[loop] = ppe_val->cs_row_status;
- }
- } else if (op == UNC_OP_UPDATE) {
- void *ppeval = reinterpret_cast<void *>(&ppe_val);
- CompareValidValue(ppeval, GetVal(upd_key), false);
- for (unsigned int loop = 0; loop < sizeof(ppe_val->valid) /
- sizeof(ppe_val->valid[0]); ++loop) {
- if (ppe_val->valid[loop] != UNC_VF_NOT_SOPPORTED) {
- if ((UNC_VF_VALID == ppe_val->valid[loop])
- || (UNC_VF_VALID_NO_VALUE == ppe_val->valid[loop]))
- ppe_val->cs_attr[loop] = ppe_val->cs_row_status;
- } else {
- ppe_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
- }
- }
- } else {
- return UPLL_RC_ERR_GENERIC;
- }
- return result_code;
-}
-#endif
upll_rc_t PolicingProfileEntryMoMgr::IsFlowlistConfigured(
const char* flowlist_name, DalDmlIntf *dmi) {
upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
delete okey;
return result_code;
}
+ delete okey;
result_code = ValidateAttribute(ikey, dmi, req);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_ERROR("Validate Attribute is Failed");
return result_code;
}
+ DbSubOp dbop1 = {kOpNotRead, kOpMatchNone, kOpInOutFlag};
result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_UPDATE,
- dmi, MAINTBL);
+ dmi, &dbop1, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_ERROR("Updation Failure in DB : %d", result_code);
return result_code;
return result_code;
}
+ result_code = SetRenameFlag(ikey, dmi, req);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("SetRenameFlag failed %d", result_code);
+ return result_code;
+ }
return result_code;
}
+upll_rc_t PolicingProfileEntryMoMgr::SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_policingprofile_entry_t *val_ppe = reinterpret_cast
+ <val_policingprofile_entry_t *>(GetVal(ikey));
+ if (!val_ppe) {
+ UPLL_LOG_DEBUG("Val is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigKeyVal *pkey = NULL;
+ if (UNC_OP_CREATE == req->operation) {
+ result_code = GetParentConfigKey(pkey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetParentConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_POLICING_PROFILE)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("mgr is NULL");
+ DELETE_IF_NOT_NULL(pkey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t rename = 0;
+ result_code = mgr->IsRenamed(pkey, req->datatype, dmi, rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(pkey);
+ return result_code;
+ }
+ UPLL_LOG_DEBUG("Flag from parent : %d", rename);
+ DELETE_IF_NOT_NULL(pkey);
+ // Check flowlist is renamed
+ if ((UNC_VF_VALID == val_ppe->valid[UPLL_IDX_FLOWLIST_PPE]) &&
+ ((UNC_OP_CREATE == req->operation))) {
+ ConfigKeyVal *fl_ckv = NULL;
+ result_code = GetFlowlistConfigKey(reinterpret_cast<const char *>
+ (val_ppe->flowlist), fl_ckv, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetFlowlistConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *fl_mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_FLOWLIST)));
+ if (NULL == fl_mgr) {
+ UPLL_LOG_DEBUG("fl_mgr is NULL");
+ DELETE_IF_NOT_NULL(fl_ckv);
+ }
+ uint8_t fl_rename = 0;
+ result_code = fl_mgr->IsRenamed(fl_ckv, req->datatype, dmi, fl_rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(fl_ckv);
+ return result_code;
+ }
+ if (fl_rename & 0x01) {
+ rename |= FLOWLIST_RENAME; // TODO Check for correct flag value
+ }
+ DELETE_IF_NOT_NULL(fl_ckv);
+ }
+ SET_USER_DATA_FLAGS(ikey, rename);
+ } else if (UNC_OP_UPDATE == req->operation) {
+ uint8_t rename = 0;
+ result_code = IsRenamed(ikey, req->datatype, dmi, rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ return result_code;
+ }
+ if (UNC_VF_VALID == val_ppe->valid[UPLL_IDX_FLOWLIST_PPE]) {
+ ConfigKeyVal *fl_ckv = NULL;
+ result_code = GetFlowlistConfigKey(reinterpret_cast<const char *>
+ (val_ppe->flowlist), fl_ckv, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetFlowlistConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *fl_mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_FLOWLIST)));
+ if (NULL == fl_mgr) {
+ UPLL_LOG_DEBUG("fl_mgr is NULL");
+ DELETE_IF_NOT_NULL(fl_ckv);
+ }
+ uint8_t fl_rename = 0;
+ result_code = fl_mgr->IsRenamed(fl_ckv, req->datatype, dmi, fl_rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(fl_ckv);
+ return result_code;
+ }
+ if (fl_rename & 0x01) {
+ rename |= FLOWLIST_RENAME; // TODO Check for correct flag value
+ } else {
+ rename = rename & NO_FLOWLIST_RENAME;
+ }
+ DELETE_IF_NOT_NULL(fl_ckv);
+ } else if (UNC_VF_VALID_NO_VALUE == val_ppe->valid
+ [UPLL_IDX_FLOWLIST_PPE]) {
+ rename |= ~FLOWLIST_RENAME; // TODO Check for correct flag value. No rename flowlist value should be set
+ }
+ SET_USER_DATA_FLAGS(ikey, rename);
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t PolicingProfileEntryMoMgr::GetFlowlistConfigKey(
+ const char *flowlist_name, ConfigKeyVal *&okey,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_FLOWLIST)));
+ result_code = mgr->GetChildConfigKey(okey, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
+ return result_code;
+ }
+ key_flowlist_t *okey_key = reinterpret_cast<key_flowlist_t *>
+ (okey->get_key());
+ uuu::upll_strncpy(okey_key->flowlist_name,
+ flowlist_name,
+ (kMaxLenFlowListName+1));
+ return UPLL_RC_SUCCESS;
+}
+
upll_rc_t PolicingProfileEntryMoMgr::ValidatePolicingProfileName(
ConfigKeyVal *ikey, DalDmlIntf *dmi,
IpcReqRespHeader *req) {
UPLL_FUNC_TRACE;
- upll_rc_t rt_val = UPLL_RC_ERR_GENERIC;
+ upll_rc_t rt_code = UPLL_RC_ERR_GENERIC;
+ // if policing profile is applied in policing map return error
+ if (req->operation == UNC_OP_CREATE) {
+ rt_code = ValidatePolicingProfileEntryInPolicingMap(ikey, dmi, req);
+ if (rt_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Update not allowed when policingprofile is in use");
+ return rt_code;
+ }
+ }
/* validate policingprofile name */
key_policingprofile_entry_t *ppe_key =reinterpret_cast
<key_policingprofile_entry_t *>(ikey->get_key());
return UPLL_RC_ERR_GENERIC;
}
ConfigKeyVal *pp_ckv = NULL;
- rt_val = mgr->GetChildConfigKey(pp_ckv, NULL);
- if (UPLL_RC_SUCCESS != rt_val) {
- UPLL_LOG_DEBUG("GetChildConfigKey fails %d", rt_val);
- return rt_val;
+ rt_code = mgr->GetChildConfigKey(pp_ckv, NULL);
+ if (UPLL_RC_SUCCESS != rt_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fails %d", rt_code);
+ return rt_code;
}
key_policingprofile_t *pp_key = reinterpret_cast<key_policingprofile_t *>
(pp_ckv->get_key());
ppe_key->policingprofile_key.policingprofile_name,
kMaxLenPolicingProfileName+1);
- rt_val = mgr->UpdateConfigDB(pp_ckv, req->datatype,
+ rt_code = mgr->UpdateConfigDB(pp_ckv, req->datatype,
UNC_OP_READ, dmi);
- if (rt_val != UPLL_RC_ERR_INSTANCE_EXISTS) {
+ if (rt_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
UPLL_LOG_DEBUG("policingprofile name does not exists in "
"KT_POLICINGPROFILE table");
delete pp_ckv;
return UPLL_RC_ERR_PARENT_DOES_NOT_EXIST;
}
+ delete pp_ckv;
return UPLL_RC_SUCCESS;
}
}
uint32_t operation = req->operation;
if (UNC_OP_CREATE == operation) {
- if ((val_ppe->valid[UPLL_IDX_RATE_PPE] == UNC_VF_VALID)
+ if ((val_ppe->valid[UPLL_IDX_FLOWLIST_PPE] == UNC_VF_VALID)
+ || (val_ppe->valid[UPLL_IDX_RATE_PPE] == UNC_VF_VALID)
|| (val_ppe->valid[UPLL_IDX_CIR_PPE] == UNC_VF_VALID)
|| (val_ppe->valid[UPLL_IDX_CBS_PPE] == UNC_VF_VALID)
|| (val_ppe->valid[UPLL_IDX_PIR_PPE] == UNC_VF_VALID)
check = true;
}
} else if (UNC_OP_UPDATE == operation) {
- if ((val_ppe->valid[UPLL_IDX_RATE_PPE] == UNC_VF_VALID)
+ if ((val_ppe->valid[UPLL_IDX_FLOWLIST_PPE] == UNC_VF_VALID)
+ || (val_ppe->valid[UPLL_IDX_RATE_PPE] == UNC_VF_VALID)
|| (val_ppe->valid[UPLL_IDX_CIR_PPE] == UNC_VF_VALID)
|| (val_ppe->valid[UPLL_IDX_CBS_PPE] == UNC_VF_VALID)
|| (val_ppe->valid[UPLL_IDX_PIR_PPE] == UNC_VF_VALID)
|| (val_ppe->valid[UPLL_IDX_RED_PRIORITY_PPE] == UNC_VF_VALID)
|| (val_ppe->valid[UPLL_IDX_RED_DSCP_PPE] == UNC_VF_VALID)
|| (val_ppe->valid[UPLL_IDX_RED_DROP_PPE] == UNC_VF_VALID)
+ || (val_ppe->valid[UPLL_IDX_FLOWLIST_PPE] == UNC_VF_VALID_NO_VALUE)
|| (val_ppe->valid[UPLL_IDX_RATE_PPE] == UNC_VF_VALID_NO_VALUE)
|| (val_ppe->valid[UPLL_IDX_CIR_PPE] == UNC_VF_VALID_NO_VALUE)
|| (val_ppe->valid[UPLL_IDX_CBS_PPE] == UNC_VF_VALID_NO_VALUE)
}
}
if (check) {
- rt_code =
- ValidatePolicingProfileNameInVtnVbrVbrIfPolicingMapTbl(
- ikey, dmi, req);
+ rt_code = ValidatePolicingProfileEntryInPolicingMap(ikey, dmi, req);
if (rt_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Update not allowed when policingprofile is in use");
return rt_code;
if (UPLL_RC_SUCCESS != rt_code) {
UPLL_LOG_DEBUG(" flowlist key validation failed %s, err code - %d",
ppe_val->flowlist, rt_code);
+ return rt_code;
}
MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>
rt_code = mgr->UpdateConfigDB(fl_ckv, req->datatype,
UNC_OP_READ, dmi);
+ delete fl_ckv;
if (rt_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
UPLL_LOG_DEBUG("flowlist name does not exists in "
"KT_FLOWLIST table");
- delete fl_ckv;
return UPLL_RC_ERR_CFG_SEMANTIC;
}
} else if ((req->operation == UNC_OP_UPDATE ||
return UPLL_RC_SUCCESS;
}
-upll_rc_t PolicingProfileEntryMoMgr::
- ValidatePolicingProfileNameInVtnVbrVbrIfPolicingMapTbl(
- ConfigKeyVal *ikey, DalDmlIntf *dmi,
+upll_rc_t PolicingProfileEntryMoMgr::ValidatePolicingProfileEntryInPolicingMap(
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
IpcReqRespHeader *req) {
UPLL_FUNC_TRACE;
MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>
(const_cast<MoManager*>(GetMoManager(UNC_KT_VTN_POLICINGMAP)));
if (!mgr) {
- delete tempval;
+ DELETE_IF_NOT_NULL(tempval);
return UPLL_RC_ERR_GENERIC;
}
ConfigKeyVal *vtn_ckv = NULL;
result_code = mgr->GetChildConfigKey(vtn_ckv, NULL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetChildConfigKey Failed %d", result_code);
- delete tempval;
+ DELETE_IF_NOT_NULL(tempval);
return result_code;
}
vtn_ckv->AppendCfgVal(tempval);
dmi, MAINTBL);
if (result_code == UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Policing profile name used in VTN_POLICINGMAP table");
+ DELETE_IF_NOT_NULL(vtn_ckv);
return UPLL_RC_ERR_CFG_SEMANTIC;
} else if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
UPLL_LOG_DEBUG("Policing profile name check in pm failed %d",
result_code);
- delete vtn_ckv;
+ DELETE_IF_NOT_NULL(vtn_ckv);
return result_code;
}
- delete vtn_ckv;
+ DELETE_IF_NOT_NULL(vtn_ckv);
val_policingmap_t *val_policingmap1 =
reinterpret_cast<val_policingmap_t *>
reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>(GetMoManager(
UNC_KT_VBR_POLICINGMAP)));
if (!mgr) {
+ DELETE_IF_NOT_NULL(tempval1);
return UPLL_RC_ERR_GENERIC;
}
ConfigKeyVal *vbr_ckv = NULL;
result_code = mgr->GetChildConfigKey(vbr_ckv, NULL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetChildConfigKey Failed %d", result_code);
+ DELETE_IF_NOT_NULL(tempval1);
return result_code;
}
vbr_ckv->AppendCfgVal(tempval1);
dmi, MAINTBL);
if (result_code == UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Policing profile name used in VTN_POLICINGMAP table");
+ DELETE_IF_NOT_NULL(vbr_ckv);
return UPLL_RC_ERR_CFG_SEMANTIC;
} else if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
UPLL_LOG_DEBUG("Policing profile name check in pm failed %d",
result_code);
+ DELETE_IF_NOT_NULL(vbr_ckv);
return result_code;
}
- delete vbr_ckv;
+ DELETE_IF_NOT_NULL(vbr_ckv);
val_policingmap_t *val_policingmap2 =
reinterpret_cast<val_policingmap_t *>
reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>(GetMoManager(
UNC_KT_VBRIF_POLICINGMAP)));
if (!mgr) {
+ DELETE_IF_NOT_NULL(tempval2);
return UPLL_RC_ERR_GENERIC;
}
ConfigKeyVal *vbrif_ckv = NULL;
result_code = mgr->GetChildConfigKey(vbrif_ckv, NULL);
if (UPLL_RC_SUCCESS != result_code) {
- delete tempval;
+ DELETE_IF_NOT_NULL(tempval2);
UPLL_LOG_DEBUG("GetChildConfigKey Failed %d", result_code);
return result_code;
}
result_code = mgr->ReadConfigDB(vbrif_ckv, req->datatype, UNC_OP_READ, dbop,
dmi, MAINTBL);
if (result_code == UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(vbrif_ckv);
UPLL_LOG_DEBUG("Policing profile name used in VTN_POLICINGMAP table");
return UPLL_RC_ERR_CFG_SEMANTIC;
} else if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
UPLL_LOG_DEBUG("Policing profile name check in pm failed %d",
result_code);
+ DELETE_IF_NOT_NULL(vbrif_ckv);
return result_code;
}
- delete vbrif_ckv;
+ DELETE_IF_NOT_NULL(vbrif_ckv);
return UPLL_RC_SUCCESS;
}
+upll_rc_t PolicingProfileEntryMoMgr::GetFlowListEntryConfigKey(
+ ConfigKeyVal *&okey, ConfigKeyVal *ikey) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+
+ val_policingprofile_entry_t *val = reinterpret_cast
+ <val_policingprofile_entry_t *>(GetVal(ikey));
+ key_flowlist_entry_t *out_key = reinterpret_cast
+ <key_flowlist_entry_t *>(ConfigKeyVal::
+ Malloc(sizeof(key_flowlist_entry_t)));
+ uuu::upll_strncpy(out_key->flowlist_key.flowlist_name,
+ val->flowlist, kMaxLenFlowListName);
+ okey = new ConfigKeyVal(UNC_KT_FLOWLIST_ENTRY,
+ IpctSt::kIpcStKeyFlowlistEntry, out_key, NULL);
+ if (!okey)
+ return UPLL_RC_ERR_GENERIC;
+ return result_code;
+}
+
upll_rc_t PolicingProfileEntryMoMgr::ValidateValidElements(
const char *policingprofile_name, DalDmlIntf *dmi,
upll_keytype_datatype_t dt_type) {
delete ppe_ckv;
return result_code;
}
- while (NULL != ppe_ckv) {
+ ConfigKeyVal *temp_ppe_ckv = ppe_ckv;
+ while (NULL != temp_ppe_ckv) {
val_policingprofile_entry_t *val_ppe = reinterpret_cast
- <val_policingprofile_entry_t *>(GetVal(ppe_ckv));
+ <val_policingprofile_entry_t *>(GetVal(temp_ppe_ckv));
if (UNC_VF_VALID != val_ppe->valid[UPLL_IDX_FLOWLIST_PPE ]) {
UPLL_LOG_DEBUG("Attribute flowlist is not valid");
+ DELETE_IF_NOT_NULL(ppe_ckv);
return UPLL_RC_ERR_CFG_SEMANTIC;
}
+ if (UNC_VF_VALID == val_ppe->valid[UPLL_IDX_FLOWLIST_PPE ]) {
+ ConfigKeyVal *okey = NULL;
+ result_code = GetFlowListEntryConfigKey(okey, temp_ppe_ckv);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ppe_ckv);
+ return result_code;
+ }
+ MoMgrImpl *fle_mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_FLOWLIST_ENTRY)));
+ if (NULL == fle_mgr) {
+ UPLL_LOG_DEBUG("fle_mgr is NULL");
+ DELETE_IF_NOT_NULL(ppe_ckv);
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = fle_mgr->UpdateConfigDB(okey,
+ dt_type, UNC_OP_READ, dmi, MAINTBL);
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("No seq number for given flowlist");
+ DELETE_IF_NOT_NULL(ppe_ckv);
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ } else if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(ppe_ckv);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(okey);
+ }
if (UNC_VF_VALID != val_ppe->valid[UPLL_IDX_RATE_PPE]) {
UPLL_LOG_DEBUG("Attribute rate is not valid");
+ DELETE_IF_NOT_NULL(ppe_ckv);
return UPLL_RC_ERR_CFG_SEMANTIC;
}
if (UNC_VF_VALID != val_ppe->valid[UPLL_IDX_CIR_PPE]) {
UPLL_LOG_DEBUG("Attribute cir is not valid");
+ DELETE_IF_NOT_NULL(ppe_ckv);
return UPLL_RC_ERR_CFG_SEMANTIC;
}
if (UNC_VF_VALID != val_ppe->valid[UPLL_IDX_PIR_PPE]) {
UPLL_LOG_DEBUG("Attribute pir is not valid");
+ DELETE_IF_NOT_NULL(ppe_ckv);
return UPLL_RC_ERR_CFG_SEMANTIC;
}
if (UNC_VF_VALID == val_ppe->valid[UPLL_IDX_GREEN_ACTION_PPE]) {
UPLL_LOG_DEBUG("Atleast one is valid");
} else {
UPLL_LOG_DEBUG("Attribute UPLL_IDX_GREEN_ACTION_PPE failed");
+ DELETE_IF_NOT_NULL(ppe_ckv);
return UPLL_RC_ERR_CFG_SEMANTIC;
}
}
} else {
+ DELETE_IF_NOT_NULL(ppe_ckv);
return UPLL_RC_ERR_CFG_SEMANTIC;
}
if (UNC_VF_VALID == val_ppe->valid[UPLL_IDX_RED_ACTION_PPE]) {
UPLL_LOG_DEBUG("Atleast one is valid");
} else {
UPLL_LOG_DEBUG("Attribute UPLL_IDX_RED_ACTION_PPE failed");
+ DELETE_IF_NOT_NULL(ppe_ckv);
return UPLL_RC_ERR_CFG_SEMANTIC;
}
}
} else {
+ DELETE_IF_NOT_NULL(ppe_ckv);
return UPLL_RC_ERR_CFG_SYNTAX;
}
if (UNC_VF_VALID == val_ppe->valid[UPLL_IDX_YELLOW_ACTION_PPE]) {
} else {
UPLL_LOG_DEBUG("Attribute UPLL_IDX_YELLOW_ACTION_PPE failed");
+ DELETE_IF_NOT_NULL(ppe_ckv);
return UPLL_RC_ERR_CFG_SEMANTIC;
}
}
} else {
+ DELETE_IF_NOT_NULL(ppe_ckv);
return UPLL_RC_ERR_CFG_SEMANTIC;
}
- ppe_ckv = ppe_ckv->get_next_cfg_key_val();
+ temp_ppe_ckv = temp_ppe_ckv->get_next_cfg_key_val();
}
+ DELETE_IF_NOT_NULL(ppe_ckv);
return UPLL_RC_SUCCESS;
}
result_code = ReadConfigDB(ppe_ckv, dt_type, UNC_OP_READ, dbop, dmi,
MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ppe_ckv);
if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
UPLL_LOG_DEBUG("Flowlist is not referred by any policingprofile");
return UPLL_RC_SUCCESS;
result_code = GetChildConfigKey(ctrlr_ppe_ckv, temp_ppe_ckv);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetChildConfigKey failed");
+ DELETE_IF_NOT_NULL(ppe_ckv);
return result_code;
}
DbSubOp dbop1 = {kOpReadMultiple, kOpMatchNone, kOpInOutNone};
result_code = ReadConfigDB(ctrlr_ppe_ckv, dt_type, UNC_OP_READ, dbop1, dmi,
CTRLRTBL);
if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ DELETE_IF_NOT_NULL(ppe_ckv);
+ DELETE_IF_NOT_NULL(ctrlr_ppe_ckv);
if (UPLL_RC_SUCCESS == result_code) {
UPLL_LOG_DEBUG("Flowlist is referred by policingprofile which"
"is referred by a policingmap");
return result_code;
}
temp_ppe_ckv = temp_ppe_ckv->get_next_cfg_key_val();
+ DELETE_IF_NOT_NULL(ctrlr_ppe_ckv);
}
- delete ppe_ckv;
- ppe_ckv = NULL;
+ DELETE_IF_NOT_NULL(ppe_ckv);
return UPLL_RC_SUCCESS;
}
+
+upll_rc_t PolicingProfileEntryMoMgr::SetValidAudit(ConfigKeyVal *&ikey) {
+ UPLL_FUNC_TRACE;
+ val_policingprofile_entry_t *val = reinterpret_cast
+ <val_policingprofile_entry_t *>(GetVal(ikey));
+ if (NULL == val) {
+ UPLL_LOG_DEBUG("val is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ for (unsigned int loop = 0;
+ loop < sizeof(val->valid) / sizeof(val->valid[0]);
+ ++loop) {
+ val->cs_attr[loop] = UNC_CS_APPLIED;
+ }
+ val->cs_row_status = UNC_CS_APPLIED;
+ return UPLL_RC_SUCCESS;
+}
+
+bool PolicingProfileEntryMoMgr::FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op) {
+ UPLL_FUNC_TRACE;
+ if (op != UNC_OP_CREATE)
+ return CompareValidValue(val1, val2, copy_to_running);
+ return false;
+}
+
+upll_rc_t PolicingProfileEntryMoMgr::UpdateConfigStatus(ConfigKeyVal *main_ckv,
+ unc_keytype_operation_t op,
+ uint32_t driver_result,
+ ConfigKeyVal *upd_key,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ctrlr_key) {
+ UPLL_FUNC_TRACE;
+ val_policingprofile_entry_ctrl_t *ppe_val;
+ unc_keytype_configstatus_t ctrlr_status;
+ uint8_t cs_status;
+ val_policingprofile_entry_t *val_ppe_main = reinterpret_cast
+ <val_policingprofile_entry_t *>(GetVal(main_ckv));
+ ctrlr_status =
+ (driver_result == UPLL_RC_SUCCESS) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
+ ppe_val = reinterpret_cast<val_policingprofile_entry_ctrl_t *>
+ (GetVal(ctrlr_key));
+ if (ppe_val == NULL) return UPLL_RC_ERR_GENERIC;
+ cs_status = (val_ppe_main->cs_row_status);
+
+ UPLL_LOG_TRACE("cs_status %d ctrlr_status %d\n", cs_status, ctrlr_status);
+ if (op == UNC_OP_CREATE) {
+ ppe_val->cs_row_status = ctrlr_status;
+ if (val_ppe_main->cs_row_status == UNC_CS_UNKNOWN) {
+ /* first entry in ctrlr table */
+ cs_status = ctrlr_status;
+ } else if (val_ppe_main->cs_row_status == UNC_CS_APPLIED) {
+ if (ctrlr_status == UNC_CS_NOT_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ }
+
+ } else if (val_ppe_main->cs_row_status == UNC_CS_NOT_APPLIED) {
+ if (ctrlr_status == UNC_CS_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ }
+ } else if (val_ppe_main->cs_row_status == UNC_CS_INVALID) {
+ cs_status = UNC_CS_INVALID;
+ } else {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ }
+ val_ppe_main->cs_row_status = cs_status;
+ }
+ // Updating the Controller cs_row_status
+ val_policingprofile_entry_ctrl *run_ctrlr_val =
+ reinterpret_cast<val_policingprofile_entry_ctrl_t *>
+ (GetVal(upd_key));
+ if ((op == UNC_OP_UPDATE) && (upd_key != NULL)) {
+ if (run_ctrlr_val != NULL)
+ ppe_val->cs_row_status = run_ctrlr_val->cs_row_status;
+ }
+
+ for (unsigned int loop = 0; loop < sizeof(val_ppe_main->valid)/
+ sizeof(val_ppe_main->valid[0]); ++loop) {
+ if (val_ppe_main->valid[loop] != UNC_VF_INVALID) {
+ if (ppe_val->cs_attr[loop] != UNC_CS_NOT_SUPPORTED)
+ ppe_val->cs_attr[loop] = ctrlr_status;
+ else
+ ppe_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
+
+ if (op == UNC_OP_CREATE ) {
+ if (val_ppe_main->cs_attr[loop] == UNC_CS_INVALID) {
+ cs_status = UNC_CS_INVALID;
+ } if (val_ppe_main->cs_attr[loop] == ctrlr_status) {
+ cs_status = ctrlr_status;
+ } else if (ctrlr_status == UNC_CS_APPLIED) {
+ if (val_ppe_main->cs_attr[loop] == UNC_CS_UNKNOWN) {
+ cs_status = ctrlr_status;
+ } else if (val_ppe_main->cs_attr[loop] == UNC_CS_NOT_APPLIED) {
+ val_ppe_main->cs_attr[loop] = UNC_CS_PARTIALLY_APPLIED;
+ } else {
+ cs_status = val_ppe_main->cs_attr[loop];
+ }
+ } else if(ctrlr_status == UNC_CS_NOT_APPLIED) {
+ if(val_ppe_main->cs_attr[loop] == UNC_CS_NOT_APPLIED) {
+ cs_status = UNC_CS_NOT_APPLIED;
+ }
+ } else {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ }
+ val_ppe_main->cs_attr[loop] = cs_status;
+ UPLL_LOG_DEBUG("Main tbl cs_attr : %d", val_ppe_main->cs_attr[loop]);
+ }
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t PolicingProfileEntryMoMgr::Get_Tx_Consolidated_Status(
+ unc_keytype_configstatus_t &status,
+ unc_keytype_configstatus_t drv_result_status,
+ unc_keytype_configstatus_t current_cs,
+ unc_keytype_configstatus_t current_ctrlr_cs) {
+
+ switch (current_cs) {
+ case UNC_CS_UNKNOWN:
+ status = drv_result_status;
+ break;
+ case UNC_CS_PARTIALLY_APPLIED:
+ if (current_ctrlr_cs == UNC_CS_NOT_APPLIED) {
+ // Todo: if this vtn has caused it then to change to applied.
+ status = (drv_result_status != UNC_CS_APPLIED) ?
+ UNC_CS_PARTIALLY_APPLIED : drv_result_status;
+ }
+ break;
+ case UNC_CS_APPLIED:
+ case UNC_CS_NOT_APPLIED:
+ case UNC_CS_INVALID:
+ default:
+ status = (drv_result_status == UNC_CS_NOT_APPLIED)?
+ UNC_CS_PARTIALLY_APPLIED:
+ (status == UNC_CS_UNKNOWN)?drv_result_status:status;
+ break;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t PolicingProfileEntryMoMgr::SetPPEntryConsolidatedStatus(ConfigKeyVal *ikey,
+ uint8_t *ctrlr_id,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ctrlr_ckv = NULL;
+ val_policingprofile_entry_ctrl_t *ctrlr_val = NULL;
+ uint8_t *pp_exist_on_ctrlr = NULL;
+ bool applied = false, not_applied = false, invalid = false;
+ unc_keytype_configstatus_t c_status = UNC_CS_NOT_APPLIED;
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone,
+ kOpInOutCtrlr | kOpInOutCs };
+ if (!ikey || !dmi) {
+ UPLL_LOG_DEBUG("Invalid Input");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = GetChildConfigKey(ctrlr_ckv, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed err code %d", result_code);
+ return result_code;
+ }
+ result_code = ReadConfigDB(ctrlr_ckv, UPLL_DT_RUNNING, UNC_OP_READ, dbop, dmi,
+ CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB from ctrltbl failed err code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return result_code;
+ }
+
+ for (ConfigKeyVal *tmp = ctrlr_ckv; tmp != NULL;
+ tmp = tmp->get_next_cfg_key_val()) {
+ ctrlr_val = reinterpret_cast<val_policingprofile_entry_ctrl_t *>
+ (GetVal(tmp));
+ if (!ctrlr_val) {
+ UPLL_LOG_DEBUG("Controller Value is empty");
+ tmp = NULL;
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ GET_USER_DATA_CTRLR(tmp, pp_exist_on_ctrlr);
+ if (!strcmp(reinterpret_cast<char *>(pp_exist_on_ctrlr),
+ reinterpret_cast<char *>(ctrlr_id)))
+ continue; // skipping entry of deleted controller
+
+ switch (ctrlr_val->cs_row_status) {
+ case UNC_CS_APPLIED:
+ applied = true;
+ break;
+ case UNC_CS_NOT_APPLIED:
+ not_applied = true;
+ break;
+ case UNC_CS_INVALID:
+ invalid = true;
+ break;
+ default:
+ UPLL_LOG_DEBUG("Invalid status");
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ break;
+ // return UPLL_RC_ERR_GENERIC;
+ }
+ pp_exist_on_ctrlr = NULL;
+ }
+ UPLL_LOG_DEBUG("PPE - applied %d not_applied %d", applied, not_applied);
+ if (invalid) {
+ c_status = UNC_CS_INVALID;
+ } if (applied && !not_applied) {
+ c_status = UNC_CS_APPLIED;
+ } else if (!applied && not_applied) {
+ c_status = UNC_CS_NOT_APPLIED;
+ } else if (applied && not_applied) {
+ c_status = UNC_CS_PARTIALLY_APPLIED;
+ } else {
+ c_status = UNC_CS_APPLIED;
+ }
+ // Set cs_status
+ val_policingprofile_entry_t *val = static_cast
+ <val_policingprofile_entry_t *>(GetVal(ikey));
+ val->cs_row_status = c_status;
+ for (unsigned int loop = 0; loop <
+ sizeof(val->valid)/sizeof(val->valid[0]);
+ ++loop) {
+ for (ConfigKeyVal *tmp = ctrlr_ckv; tmp != NULL;
+ tmp = tmp->get_next_cfg_key_val()) {
+ ctrlr_val = reinterpret_cast<val_policingprofile_entry_ctrl_t *>(GetVal(tmp));
+
+ GET_USER_DATA_CTRLR(tmp, pp_exist_on_ctrlr);
+ UPLL_LOG_DEBUG("Controller name in DB %s",pp_exist_on_ctrlr);
+ if (!strcmp(reinterpret_cast<char *>(pp_exist_on_ctrlr),
+ reinterpret_cast<char *>(ctrlr_id)))
+ continue; // skipping entry of deleted controller
+ if (ctrlr_val->valid[loop] == UNC_VF_VALID) {
+ switch (ctrlr_val->cs_attr[loop]) {
+ case UNC_CS_APPLIED:
+ applied = true;
+ break;
+ case UNC_CS_NOT_APPLIED:
+ not_applied = true;
+ break;
+ case UNC_CS_INVALID:
+ invalid = true;
+ break;
+ default:
+ UPLL_LOG_DEBUG("Invalid status %d", ctrlr_val->cs_attr[loop]);
+ }
+ }
+ }
+ if (invalid) {
+ c_status = UNC_CS_INVALID;
+ } else if (applied && !not_applied) {
+ c_status = UNC_CS_APPLIED;
+ } else if (!applied && not_applied) {
+ c_status = UNC_CS_NOT_APPLIED;
+ } else if (applied && not_applied) {
+ c_status = UNC_CS_PARTIALLY_APPLIED;
+ } else {
+ c_status = UNC_CS_APPLIED;
+ }
+ val->cs_attr[loop] = c_status;
+ applied = not_applied =false;
+ }
+
+ DbSubOp dbop_update = {kOpNotRead, kOpMatchNone, kOpInOutCs};
+ result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_UPDATE, dmi,
+ &dbop_update, MAINTBL);
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return result_code;
+}
} // namespace kt_momgr
} // namespace upll
} // namespace unc
* Member Variable for PolicingProfileEntryBindInfo.
*/
static BindInfo rename_flowlist_pp_entry_ctrl_tbl[];
+ uint32_t cur_instance_count;
/**
* @brief Validates the Attribute of a Particular Class.
*
*
* @retval UPLL_RC_SUCCESS validation succeeded.
* @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
- * @retval UPLL_RC_ERR_GENERIC Generic failure.
*/
upll_rc_t ValPolicingProfileEntryAttributeSupportCheck(
val_policingprofile_entry_t *val_policingprofile_entry,
* @param[in] val_policingprofile_entry value structure.
* @param[in] attrs Refers supported capability file attributes
* for the given controller name.
- *
- * @retval UPLL_RC_SUCCESS validation succeeded.
- * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
*/
- upll_rc_t ValidateGreenFieldAttribute(val_policingprofile_entry_t *
+ void ValidateGreenFieldAttribute(val_policingprofile_entry_t *
val_policingprofile_entry, const uint8_t *attrs);
/**
* @param[in] val_policingprofile_entry value structure.
* @param[in] attrs Refers supported capability file
* attributes for the given controller name.
- *
- * @retval UPLL_RC_SUCCESS validation succeeded.
- * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
*/
- upll_rc_t ValidateYellowFieldAttribute(val_policingprofile_entry_t *
- val_policingprofile_entry, const uint8_t *attrs);
+ void ValidateYellowFieldAttribute(val_policingprofile_entry_t *
+ val_policingprofile_entry, const uint8_t *attrs);
/**
* @Brief Checks if the specified red_action, red_action_priority,
*
* @param[in] val_policingprofile_entry value structure.
* @param[in] attrs Refers supported capability file attributes
- * for the given controller name.
- *
- * @retval UPLL_RC_SUCCESS validation succeeded.
- * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
*/
- upll_rc_t ValidateRedFieldAttribute(val_policingprofile_entry_t *
+ void ValidateRedFieldAttribute(val_policingprofile_entry_t *
val_policingprofile_entry, const uint8_t *attrs);
/**
* @retval UPLL_RC_SUCCESS validation succeeded.
* @retval UPLL_RC_ERR_CFG_SYNTAX validation failed.
*/
- upll_rc_t ValidatePolicingProfileNameInVtnVbrVbrIfPolicingMapTbl(
- ConfigKeyVal *ikey, DalDmlIntf *dmi,
- IpcReqRespHeader *req);
+ upll_rc_t ValidatePolicingProfileEntryInPolicingMap(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req);
public:
* @retval UPLL_RC_ERR_GENERIC Failure.
*/
- upll_rc_t GetRenamedControllerKey(ConfigKeyVal *&ikey,
+ upll_rc_t GetRenamedControllerKey(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
controller_domain *ctrlr_dom = NULL);
* @return TRUE Successfull completion.
*/
- bool CompareValidValue(void *&val1, void *val2, bool audit);
+ bool CompareValidValue(void *&val1, void *val2, bool copy_to_running);
/**
* @brief Method for TxUpdateController for updating the controller .
upll_rc_t ReadPolicingProfileEntry(
const char *policingprofile_name, uint8_t seq_num,
const char *ctrlr_id, DalDmlIntf *dmi, upll_keytype_datatype_t dt_type,
- ConfigKeyVal *&ppe_ckv);
+ ConfigKeyVal *&ppe_ckv, unc_keytype_option1_t opt1 = UNC_OPT1_NORMAL);
upll_rc_t IsFlowlistConfigured(const char* flowlist_name,
DalDmlIntf *dmi);
upll_rc_t IsFlowListMatched(const char *flowlist_name,
upll_keytype_datatype_t dt_type, DalDmlIntf *dmi);
+
+ upll_rc_t SetValidAudit(ConfigKeyVal *&ikey);
+
+ upll_rc_t DecrementRefCount(
+ ConfigKeyVal *ppe_ckv, DalDmlIntf *dmi,
+ upll_keytype_datatype_t dt_type);
+ upll_rc_t UpdateVnodeVal(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t data_type,
+ bool &no_rename);
+ bool FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op);
+
+ upll_rc_t Get_Tx_Consolidated_Status(
+ unc_keytype_configstatus_t &status,
+ unc_keytype_configstatus_t drv_result_status,
+ unc_keytype_configstatus_t current_cs,
+ unc_keytype_configstatus_t current_ctrlr_cs);
+
+ upll_rc_t GetFlowListEntryConfigKey(
+ ConfigKeyVal *&okey, ConfigKeyVal *ikey);
+
+ upll_rc_t SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req);
+
+ upll_rc_t GetFlowlistConfigKey(
+ const char *flowlist_name, ConfigKeyVal *&okey,
+ DalDmlIntf *dmi);
+
+ upll_rc_t SetPPEntryConsolidatedStatus(ConfigKeyVal *ikey,
+ uint8_t *ctrlr_id,
+ DalDmlIntf *dmi);
};
typedef struct val_policingprofile_entry_ctrl {
#include "policingprofile_momgr.hh"
#include "policingprofile_entry_momgr.hh"
#include "vtn_policingmap_momgr.hh"
-#include "upll_log.hh"
+#include "vbr_policingmap_momgr.hh"
+#include "vbr_if_policingmap_momgr.hh"
+#include "uncxx/upll_log.hh"
namespace unc {
namespace upll {
namespace kt_momgr {
#define NUM_KEY_MAIN_COL 3
-#define NUM_KEY_CTRL_COL 4
+#define NUM_KEY_CTRL_COL 3
#define NUM_KEY_RENAME_COL 2
#define POLICINGPROFILE_RENAME 0x01
uud::kDalUint32, 1 },
{ uudst::policingprofile_ctrlr::kDbiFlags,
CK_VAL,
- offsetof(val_policingprofile_ctrl_t, flags),
+ offsetof(key_user_data_t, flags),
uud::kDalUint8, 1},
{ uudst::policingprofile_ctrlr::kDbiCsRowStatus,
CS_VAL,
uud::kDalChar,
(kMaxLenPolicingProfileName + 1) },
{ uudst::policingprofile::kDbiFlags,
- CFG_VAL,
+ CK_VAL,
offsetof(key_user_data_t, flags),
uud::kDalUint8, 1 }
};
offsetof(key_policingprofile_t, policingprofile_name),
uud::kDalChar,
(kMaxLenPolicingProfileName + 1) },
- { uudst::policingprofile_ctrlr::kDbiCtrlrName,
- CFG_VAL,
- offsetof(key_user_data_t, ctrlr_id),
- uud::kDalChar,
- (kMaxLenCtrlrId + 1) },
{ uudst::policingprofile_ctrlr::kDbiPolicingProfileName,
CFG_INPUT_KEY,
offsetof(key_rename_vnode_info_t, new_policingprofile_name),
uud::kDalChar,
(kMaxLenPolicingProfileName + 1) },
{ uudst::policingprofile_ctrlr::kDbiFlags,
- CFG_VAL,
+ CK_VAL,
offsetof(key_user_data_t, flags),
uud::kDalUint8, 1 }
};
nchild = sizeof(policingprofile_child) / sizeof(policingprofile_child[0]);
child = policingprofile_child;
+ cur_instance_count = 0;
}
/**
reinterpret_cast<val_policingprofile_ctrl_t *>(val);
if (uudst::policingprofile_ctrlr::kDbiRefCount == indx) {
valid = &val_ctrl->valid[0];
- UPLL_LOG_DEBUG(" valid in GetValid %d ", val_ctrl->valid[0]);
}
} else {
valid = NULL;
}
if (NULL == pkey) {
-// if (policingprofile_key) free(policingprofile_key);
- UPLL_LOG_TRACE(" Key structure is NULL");
+ UPLL_LOG_TRACE("Key structure is NULL");
return UPLL_RC_ERR_GENERIC;
}
if (okey) {
if (okey->get_key_type() != UNC_KT_POLICING_PROFILE)
return UPLL_RC_ERR_GENERIC;
- policingprofile_key = reinterpret_cast<key_policingprofile_t *>
+ }
+ if ((okey) && (okey->get_key())) {
+ policingprofile_key = reinterpret_cast<key_policingprofile_t *>
(okey->get_key());
} else {
policingprofile_key = reinterpret_cast<key_policingprofile_t *>
(ConfigKeyVal::Malloc(sizeof(key_policingprofile_t)));
}
+
switch (parent_key->get_key_type()) {
case UNC_KT_ROOT:
break;
if (policingprofile_key) free(policingprofile_key);
return UPLL_RC_ERR_GENERIC;
}
-
- if (!okey)
+ if ((okey) && !(okey->get_key())) {
+ UPLL_LOG_TRACE("okey not NULL profile name updated");
+ okey->SetKey(IpctSt::kIpcStKeyPolicingprofile, policingprofile_key);
+ }
+ if (!okey) {
okey = new ConfigKeyVal(UNC_KT_POLICING_PROFILE,
IpctSt::kIpcStKeyPolicingprofile,
policingprofile_key, NULL);
-
+ }
SET_USER_DATA(okey, parent_key);
- UPLL_LOG_TRACE(" PolicingProfileMoMgr::ConfigKeyVal Allocation Successful ");
+ UPLL_LOG_TRACE("%s GetChildConfigKey fl start",
+ okey->ToStrAll().c_str());
return UPLL_RC_SUCCESS;
}
uint8_t *ctrlr_id) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
- if (NULL == ctrlr_key) {
+ UPLL_LOG_TRACE("%s GetRenamedUncKey pp start",
+ ctrlr_key->ToStrAll().c_str());
+ if ((NULL == ctrlr_key) || (NULL == dmi)) {
UPLL_LOG_DEBUG(" PolicingProfileMoMgr::Input ConfigKeyVal is NULL.");
return result_code;
}
key_policingprofile_t *ctrlr_policingprofile_key =
reinterpret_cast<key_policingprofile_t *>(ctrlr_key->get_key());
if (NULL == ctrlr_policingprofile_key) {
- UPLL_LOG_DEBUG(" PolicingProfileMoMgr::Key struct is NULL");
+ UPLL_LOG_DEBUG("PolicingProfileMoMgr::Key struct is NULL");
return result_code;
}
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
val_rename_policingprofile_t *rename_policingprofile =
reinterpret_cast <val_rename_policingprofile_t *>
(ConfigKeyVal::Malloc(sizeof(val_rename_policingprofile_t)));
+ if (!rename_policingprofile) {
+ UPLL_LOG_DEBUG("rename_policingprofile NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(rename_policingprofile->policingprofile_newname,
ctrlr_policingprofile_key->policingprofile_name,
result_code = GetChildConfigKey(unc_key, NULL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(" PolicingProfileMoMgr:: PolicingProfile Creating"
- " ConfigKeyval failed.");
+ UPLL_LOG_DEBUG("GetChildConfigKey failed (%d)", result_code);
free(rename_policingprofile);
return result_code;
}
+ if (!unc_key) {
+ UPLL_LOG_DEBUG("unc_key NULL");
+ free(rename_policingprofile);
+ return UPLL_RC_ERR_GENERIC;
+ }
unc_key->AppendCfgVal(IpctSt::kIpcStValRenamePolicingprofile,
rename_policingprofile);
-
- SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
+ UPLL_LOG_DEBUG("ctrlr_id pp (%s)", ctrlr_id);
+ if (ctrlr_id) {
+ SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
+ } else {
+ dbop.matchop = kOpMatchNone;
+ }
result_code = ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL);
-
if (result_code == UPLL_RC_SUCCESS) {
key_policingprofile_t *policingprofile_key =
reinterpret_cast<key_policingprofile_t *>(unc_key->get_key());
policingprofile_key->policingprofile_name,
(kMaxLenPolicingProfileName+1));
}
- delete unc_key;
- UPLL_LOG_TRACE(" PolicingProfileMoMgr::GetRenamedUncKey Successful");
+ UPLL_LOG_TRACE("%s GetRenamedUncKey pp end",
+ ctrlr_key->ToStrAll().c_str());
+ DELETE_IF_NOT_NULL(unc_key);
return result_code;
}
upll_rc_t PolicingProfileMoMgr::GetRenamedControllerKey(
- ConfigKeyVal *&ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
+ ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
controller_domain *ctrlr_dom) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
- if (NULL == ikey) {
- UPLL_LOG_DEBUG(" PolicingProfileMoMgr::GetRenamedControllerKey Failed."
- " Input ConfigKeyVal is NULL");
- return result_code;
- }
- if (NULL == dmi) {
+ if (NULL == ikey || (NULL == dmi)) {
+ UPLL_LOG_DEBUG("Input ConfigKeyVal is NULL");
return result_code;
}
+
ConfigKeyVal *okey = NULL;
uint8_t rename = 0;
result_code = IsRenamed(ikey, dt_type, dmi, rename);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG(" PolicingProfileMoMgr::GetRenamedControllerKey Failed."
- " IsRenamed function failed - %d", result_code);
+ UPLL_LOG_DEBUG("IsRenamed function failed (%d)", result_code);
return result_code;
}
if (!rename) {
- UPLL_LOG_DEBUG(" PolicingProfileMoMgr::GetRenamedControllerKey Success."
- " The Key is not renamed");
+ UPLL_LOG_DEBUG("Key not renamed");
return UPLL_RC_SUCCESS;
}
+ UPLL_LOG_TRACE("%s GetRenamedCtrl pp start", (ikey->ToStrAll()).c_str());
+
/* PolicingProfile renamed */
- key_policingprofile_t *ctrlr_key = reinterpret_cast<key_policingprofile_t *>
- (ConfigKeyVal::Malloc(sizeof(key_policingprofile_t)));
if (rename & POLICINGPROFILE_RENAME) {
result_code = GetChildConfigKey(okey, ikey);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG(" PolicingProfileMoMgr::GetRenamedControllerKey Failed."
- " Memory allocation for ConfigKeyVal failed - %d", result_code);
- free(ctrlr_key);
+ UPLL_LOG_DEBUG("GetChildConfigKey fail (%d)", result_code);
return result_code;
}
- if (NULL == ctrlr_dom) {
- UPLL_LOG_DEBUG(" Ctrlr_id is NULL");
- free(ctrlr_key);
+
+ if (NULL != ctrlr_dom) {
+ SET_USER_DATA_CTRLR(okey, ctrlr_dom->ctrlr);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
- SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL); /* ctrlr_name */
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG(" PolicingProfileMoMgr::GetRenamedControllerKey Failed."
- " ReadConfigDB function failed - %d", result_code);
- free(ctrlr_key);
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB no instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("ReadConfigDB failed (%d)", result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
+
val_rename_policingprofile_t *rename_val =
reinterpret_cast<val_rename_policingprofile_t *>(GetVal(okey));
if (NULL == rename_val) {
- UPLL_LOG_DEBUG(" PolicingProfileMoMgr::GetRenamedControllerKey Failed."
- " Memory Allocation failed for rename val struct");
- free(ctrlr_key);
+ UPLL_LOG_DEBUG("memory Allocation failed for rename val struct");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
- if (rename_val->valid[UPLL_IDX_RENAME_PROFILE_RPP] != UNC_VF_VALID) {
- UPLL_LOG_DEBUG(" PolicingProfileMoMgr::GetRenamedControllerKey Failed."
- " Rename is INVALID");
- free(ctrlr_key);
- return UPLL_RC_ERR_GENERIC;
- }
- uuu::upll_strncpy(ctrlr_key->policingprofile_name,
- rename_val->policingprofile_newname,
- (kMaxLenPolicingProfileName+1));
- delete okey;
+
+ uuu::upll_strncpy(
+ reinterpret_cast<key_policingprofile_t *>
+ (ikey->get_key())->policingprofile_name,
+ rename_val->policingprofile_newname,
+ (kMaxLenPolicingProfileName+1));
+ UPLL_LOG_DEBUG("profile name (%s) (%s)",
+ reinterpret_cast<key_policingprofile_t *>
+ (ikey->get_key())->policingprofile_name,
+ rename_val->policingprofile_newname);
+ DELETE_IF_NOT_NULL(okey);
}
- free(ikey->get_key());
- ikey->SetKey(IpctSt::kIpcStValPolicingprofile,
- reinterpret_cast<void *> (ctrlr_key));
+ SET_USER_DATA_FLAGS(ikey, rename);
+ UPLL_LOG_TRACE("%s GetRenamedCtrl pp end", (ikey->ToStrAll()).c_str());
UPLL_LOG_TRACE(" PolicingProfileMOMgr::GetRenameUncKey Successful");
return UPLL_RC_SUCCESS;
}
okey = new ConfigKeyVal(UNC_KT_POLICING_PROFILE,
IpctSt::kIpcStKeyPolicingprofile, policingprofile_key,
tmp1);
- if (NULL == okey) {
- UPLL_LOG_DEBUG(" PolicingProfileMoMgr::DupConfigKeyVal Failed.");
- UPLL_LOG_DEBUG(" ConfigKeyVal allocation failed");
- free(policingprofile_key);
- return UPLL_RC_ERR_GENERIC;
- }
SET_USER_DATA(okey, req);
return UPLL_RC_SUCCESS;
}
ConfigKeyVal *&ckv_running) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- val_policingprofile_t *val = NULL;
- val = (ckv_running != NULL)?reinterpret_cast<val_policingprofile_t *>
+ val_policingprofile_ctrl_t *val = NULL;
+ val = (ckv_running != NULL)?reinterpret_cast
+ <val_policingprofile_ctrl_t *>
(GetVal(ckv_running)):NULL;
if (NULL == val) {
return UPLL_RC_ERR_GENERIC;
}
if (uuc::kUpllUcpCreate == phase )
- val->cs_row_status = cs_status;
-
+ val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
return result_code;
}
upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
ConfigKeyVal *ckval = NULL;
if (NULL == ctrlr_id) {
+ UPLL_LOG_DEBUG("ctrlr_id NULL");
return result_code;
}
result_code = GetChildConfigKey(ckval, NULL);
if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ckval fail");
return result_code;
}
DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone};
result_code = ReadConfigDB(ckval, UPLL_DT_IMPORT,
UNC_OP_READ, dbop, dmi, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
- return result_code;
+ DELETE_IF_NOT_NULL(ckval);
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ return result_code;
+ }
+ return UPLL_RC_SUCCESS;
}
- okey = ckval;
- while (NULL != okey) {
- result_code = UpdateConfigDB(okey, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
+ ConfigKeyVal *tmp_ckval = ckval;
+ while (NULL != ckval) {
+ // Check the profile is stand alone
+ ConfigKeyVal *ctrl_ckval = NULL;
+ DbSubOp dbop = { kOpReadExist, kOpMatchNone, kOpInOutNone };
+ result_code = GetChildConfigKey(ctrl_ckval, ckval);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Failed to get ctrl configkeyval,err %d", result_code);
+ DELETE_IF_NOT_NULL(tmp_ckval);
+ return result_code;
+ }
+ result_code = UpdateConfigDB(ctrl_ckval,
+ UPLL_DT_IMPORT,
+ UNC_OP_READ, dmi,
+ &dbop, CTRLRTBL);
+ DELETE_IF_NOT_NULL(ctrl_ckval);
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("profile name is stand alone");
+ result_code = GetChildConfigKey(okey, ckval);
+ DELETE_IF_NOT_NULL(tmp_ckval);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+ return UPLL_RC_ERR_MERGE_CONFLICT;
+ } else if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
+ UPLL_LOG_DEBUG("Database Error");
+ DELETE_IF_NOT_NULL(tmp_ckval);
+ return result_code;
+ }
+
+ // Check whether the configuration exists in the Running configuration or
+ // not, if exists then return an error
+ result_code = UpdateConfigDB(ckval, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
MAINTBL);
if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ result_code = GetChildConfigKey(okey, ckval);
+ DELETE_IF_NOT_NULL(tmp_ckval);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
return UPLL_RC_ERR_MERGE_CONFLICT;
} else if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
- okey = ckval->get_next_cfg_key_val();
+ ckval = ckval->get_next_cfg_key_val();
} else {
+ DELETE_IF_NOT_NULL(tmp_ckval);
return result_code;
}
}
+ DELETE_IF_NOT_NULL(tmp_ckval);
return UPLL_RC_SUCCESS;
}
uint8_t *ctrlr, bool &no_rename) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- if (NULL == ikey) {
- UPLL_LOG_DEBUG(
- " PolicingProfileMoMgr::SwapKeyVal Failed. Input ConfigKeyVal is NULL");
- return UPLL_RC_ERR_GENERIC;
- }
- if (NULL != okey) {
+ if (!ikey || !(ikey->get_key()) || !(strlen(reinterpret_cast<const char *>
+ (ctrlr)))){
+ UPLL_LOG_DEBUG("Input ConfigKeyVal is NULL");
return UPLL_RC_ERR_GENERIC;
}
+
ConfigVal *cfg_val = ikey->get_cfg_val();
if (NULL == cfg_val) {
- UPLL_LOG_DEBUG(
- " PolicingProfileMoMgr::SwapKeyVal Failed. Val struct is NULL");
- // return UPLL_RC_ERR_BAD_REQUEST;
+ UPLL_LOG_DEBUG("Value struct is NULL");
return UPLL_RC_ERR_GENERIC;
}
+
val_rename_policingprofile_t *tval =
reinterpret_cast<val_rename_policingprofile_t *>(cfg_val->get_val());
if (NULL == tval) {
- UPLL_LOG_DEBUG(
- " PolicingProfileMoMgr::SwapKeyVal Failed. Val struct is NULL");
- // return UPLL_RC_ERR_BAD_REQUEST;
- return UPLL_RC_ERR_GENERIC;
- }
- if (NULL == ikey->get_key()) {
- return UPLL_RC_ERR_GENERIC;
- }
- key_policingprofile_t *pp_key =
- reinterpret_cast<key_policingprofile_t *>(ikey->get_key());
- if (!strlen(reinterpret_cast<char *>(pp_key->policingprofile_name))) {
- return UPLL_RC_ERR_GENERIC;
- }
- /* The New Name and PFC name should not be same name */
- if (strcmp(
- reinterpret_cast<char *>
- (pp_key->policingprofile_name),
- reinterpret_cast<char *>(tval->policingprofile_newname)) == 0) {
- UPLL_LOG_DEBUG(
- " PolicingProfileMoMgr::SwapKeyVal Failed.");
- UPLL_LOG_DEBUG(" Policingprofile names are same");
+ UPLL_LOG_DEBUG("Rename val struct is NULL");
return UPLL_RC_ERR_GENERIC;
}
+
key_policingprofile_t *key_policingprofile =
- reinterpret_cast<key_policingprofile_t *>
- (ConfigKeyVal::Malloc(sizeof(key_policingprofile_t)));
- if (UNC_VF_VALID == tval->valid[0]) {
- /* checking the string is empty or not*/
- if (!strlen(reinterpret_cast<char *>(tval->policingprofile_newname))) {
- UPLL_LOG_DEBUG(
- " PolicingProfileMoMgr::SwapKeyVal Failed.");
- UPLL_LOG_DEBUG(" PolicingProfile_newname is NULL");
- free(key_policingprofile);
- return UPLL_RC_ERR_GENERIC;
- }
- uuu::upll_strncpy(key_policingprofile->policingprofile_name,
- tval->policingprofile_newname,
- (kMaxLenPolicingProfileName+1));
- } else if (UNC_VF_VALID_NO_VALUE == tval->valid[0]) {
+ reinterpret_cast<key_policingprofile_t *>(ConfigKeyVal::Malloc
+ (sizeof(key_policingprofile_t)));
+
+ if (UNC_VF_VALID_NO_VALUE ==
+ tval->valid[UPLL_IDX_RENAME_PROFILE_RPP]) {
no_rename = true;
uuu::upll_strncpy(key_policingprofile->policingprofile_name,
reinterpret_cast<key_policingprofile_t *>
(ikey->get_key())->policingprofile_name,
(kMaxLenPolicingProfileName+1));
+ UPLL_LOG_DEBUG("No Rename Operation %d", no_rename);
+ } else {
+ if (UNC_VF_VALID == tval->valid[UPLL_IDX_RENAME_PROFILE_RPP]) {
+ /* checking the string is empty or not*/
+ if (!strlen(reinterpret_cast<char *>(tval->policingprofile_newname))) {
+ UPLL_LOG_DEBUG(" PolicingProfile_newname is NULL");
+ free(key_policingprofile);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(key_policingprofile->policingprofile_name,
+ tval->policingprofile_newname,
+ (kMaxLenPolicingProfileName+1));
+ // copy the new UNC name to KeyVtn
+ /* The New Name and PFC name should not be same name */
+ if (!strcmp(reinterpret_cast<char *>
+ ((reinterpret_cast<key_policingprofile_t *>(ikey->get_key()))
+ ->policingprofile_name), reinterpret_cast<char *>
+ (tval->policingprofile_newname))) {
+ UPLL_LOG_DEBUG("ctrl , new name is same");
+ free(key_policingprofile);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ } else {
+ UPLL_LOG_DEBUG("Invalid Input");
+ free(key_policingprofile);
+ return UPLL_RC_ERR_GENERIC;
+ }
}
+
okey = new ConfigKeyVal(UNC_KT_POLICING_PROFILE,
IpctSt::kIpcStValPolicingprofile, key_policingprofile,
NULL);
if (NULL == okey) {
- UPLL_LOG_DEBUG(
- " PolicingProfileMoMgr::SwapKeyVal Failed.");
- UPLL_LOG_DEBUG(" Memory Allocation for ConfigKeyVal failed");
+ UPLL_LOG_DEBUG("okey Memory Allocation for ConfigKeyVal failed");
free(key_policingprofile);
return UPLL_RC_ERR_GENERIC;
}
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
DalResultCode db_result = uud::kDalRcGeneralError;
- unc_keytype_operation_t op[] = { UNC_OP_CREATE, UNC_OP_DELETE };
+ unc_keytype_operation_t op[] = { UNC_OP_CREATE, UNC_OP_DELETE ,
+ UNC_OP_UPDATE};
int nop = sizeof(op) / sizeof(op[0]);
- ConfigKeyVal *policingprofile_key = NULL, *req = NULL, *nreq = NULL;
+ ConfigKeyVal *policingprofile_key = NULL, *req = NULL, *nreq = NULL,
+ *pp_ck_run = NULL;
DalCursor *cfg1_cursor = NULL;
uint8_t *ctrlr_id = NULL;
#if 0
// Update the Main table
if (op[i] != UNC_OP_UPDATE) {
result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i],
- req, nreq, &cfg1_cursor, dmi, MAINTBL);
+ req, nreq, &cfg1_cursor, dmi,NULL, MAINTBL, true);
while (result_code == UPLL_RC_SUCCESS) {
db_result = dmi->GetNextRecord(cfg1_cursor);
result_code = DalToUpllResCode(db_result);
nreq, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Updating Main table Error %d", result_code);
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
return result_code;
}
}
dmi->CloseCursor(cfg1_cursor, true);
cfg1_cursor = NULL;
}
- if (req)
- delete req;
- req = NULL;
+ DELETE_IF_NOT_NULL(req);
}
UPLL_LOG_DEBUG("Updating main table complete with op %d", op[i]);
}
for (int i = 0; i < nop; i++) {
// Update the controller table
result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i], req,
- nreq, &cfg1_cursor, dmi, CTRLRTBL);
+ nreq, &cfg1_cursor, dmi,NULL, CTRLRTBL, true);
ConfigKeyVal *pp_ctrlr_key = NULL;
while (result_code == UPLL_RC_SUCCESS) {
db_result = dmi->GetNextRecord(cfg1_cursor);
result_code = DalToUpllResCode(db_result);
if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+
result_code = UPLL_RC_SUCCESS;
break;
}
- if (op[i] == UNC_OP_CREATE) {
- DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag };
+ if (op[i] == UNC_OP_CREATE ) {
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag |kOpInOutCs };
result_code = GetChildConfigKey(policingprofile_key, req);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
- result_code);
+ result_code);
+ DELETE_IF_NOT_NULL(req);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
- result_code = ReadConfigDB(policingprofile_key, UPLL_DT_CANDIDATE,
- UNC_OP_READ, dbop, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
+
+ result_code = ReadConfigDB(policingprofile_key, UPLL_DT_RUNNING /*UPLL_DT_CANDIDATE*/,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if ((result_code != UPLL_RC_SUCCESS) &&
+ (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
UPLL_LOG_DEBUG("Unable to read configuration from CandidateDb");
+ DELETE_IF_NOT_NULL(policingprofile_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ /* set consolidated config status to UNKNOWN to init vtn cs_status
+ * to the cs_status of first controller
+ */
+ uint32_t cur_instance_count;
+ ConfigKeyVal *temp_val=NULL;
+ result_code = DupConfigKeyVal(temp_val, req, CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DupConfigval failed %d", result_code);
+ DELETE_IF_NOT_NULL(policingprofile_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(temp_val);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
+ result_code = GetInstanceCount(temp_val, NULL,
+ UPLL_DT_CANDIDATE, &cur_instance_count,
+ dmi, CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetInstanceCount failed %d", result_code);
+ DELETE_IF_NOT_NULL(policingprofile_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(temp_val);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ if (cur_instance_count == 1) {
+ reinterpret_cast<val_policingprofile *>
+ (GetVal(policingprofile_key))->cs_row_status =
+ UNC_CS_UNKNOWN;
+ }
result_code = DupConfigKeyVal(pp_ctrlr_key, req, CTRLRTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("DupConfigVal function is failed %d", result_code);
+ DELETE_IF_NOT_NULL(policingprofile_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(temp_val);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
+
+ DELETE_IF_NOT_NULL(temp_val);
GET_USER_DATA_CTRLR(pp_ctrlr_key, ctrlr_id);
string controller(reinterpret_cast<char *>(ctrlr_id));
result_code = UpdateConfigStatus(policingprofile_key, op[i],
- ctrlr_result[controller], NULL,
- dmi, pp_ctrlr_key);
+ ctrlr_result[controller], nreq,
+ dmi, pp_ctrlr_key);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG(" UpdateConfigStatus Function Failed - %d ",
result_code);
- delete policingprofile_key;
+ DELETE_IF_NOT_NULL(policingprofile_key);
+ DELETE_IF_NOT_NULL(pp_ctrlr_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
} else if (op[i] == UNC_OP_DELETE) {
+ //Reading Main Running DB for delete op
+ DbSubOp dbop1 = { kOpReadSingle, kOpMatchNone, kOpInOutFlag | kOpInOutCs };
+ result_code = GetChildConfigKey(pp_ck_run, req);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
+ result_code);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ result_code = ReadConfigDB(pp_ck_run, UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop1, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Unable to read configuration from CandidateDb");
+ DELETE_IF_NOT_NULL(pp_ck_run);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ if (result_code == UPLL_RC_SUCCESS) {
+ GET_USER_DATA_CTRLR(req, ctrlr_id);
+ result_code = SetPPConsolidatedStatus(pp_ck_run, ctrlr_id, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Could not set consolidated status %d", result_code);
+ DELETE_IF_NOT_NULL(pp_ck_run);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ }
+ DELETE_IF_NOT_NULL(pp_ck_run);
result_code = GetChildConfigKey(pp_ctrlr_key, req);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetChildConfigKey Failed %d", result_code);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
}
+ if (UNC_OP_CREATE == op[i]) {
+ val_policingprofile_ctrl_t *val_ctrlr_temp = reinterpret_cast
+ <val_policingprofile_ctrl_t *>(GetVal(pp_ctrlr_key));
+ val_ctrlr_temp->valid[0] = UNC_VF_VALID;
+ val_policingprofile_ctrl_t *val_ctrlr_temp1 = reinterpret_cast
+ <val_policingprofile_ctrl_t *>(GetVal(req));
+ val_ctrlr_temp->ref_count = val_ctrlr_temp1->ref_count;
+ UPLL_LOG_DEBUG("Ref count in dupckv%d", val_ctrlr_temp->ref_count);
+ UPLL_LOG_DEBUG("Ref count in req%d", val_ctrlr_temp1->ref_count);
+ } else if (UNC_OP_UPDATE == op[i]) {
+ result_code = DupConfigKeyVal(pp_ctrlr_key, nreq, CTRLRTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigVal function is failed %d", result_code);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ val_policingprofile_ctrl_t *val_ctrlr_temp = reinterpret_cast
+ <val_policingprofile_ctrl_t *>(GetVal(pp_ctrlr_key));
+ val_ctrlr_temp->valid[0] = UNC_VF_VALID;
+ val_policingprofile_ctrl_t *val_ctrlr_temp1 = reinterpret_cast
+ <val_policingprofile_ctrl_t *>(GetVal(req));
+ val_ctrlr_temp->ref_count = val_ctrlr_temp1->ref_count;
+ UPLL_LOG_DEBUG("Ref count in dupckv%d", val_ctrlr_temp->ref_count);
+ UPLL_LOG_DEBUG("Ref count in req%d", val_ctrlr_temp1->ref_count);
+ }
result_code = UpdateConfigDB(pp_ctrlr_key, UPLL_DT_RUNNING, op[i],
dmi, CTRLRTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Unable to Update Configuration at DB %d", result_code);
- delete pp_ctrlr_key;
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(pp_ctrlr_key);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
// update the consolidated config status in the Main Table
- if (op[i] != UNC_OP_DELETE) {
- result_code = UpdateConfigDB(policingprofile_key, UPLL_DT_RUNNING,
- UNC_OP_UPDATE, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS)
- return result_code;
- }
+ if (op[i] == UNC_OP_CREATE) {
+ result_code = UpdateConfigDB(policingprofile_key, UPLL_DT_RUNNING,
+ UNC_OP_UPDATE, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(policingprofile_key);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ }
EnqueCfgNotification(op[i], UPLL_DT_RUNNING, pp_ctrlr_key);
- if (pp_ctrlr_key) delete pp_ctrlr_key;
- policingprofile_key = pp_ctrlr_key = NULL;
+ DELETE_IF_NOT_NULL(policingprofile_key);
+ DELETE_IF_NOT_NULL(pp_ctrlr_key);
result_code = DalToUpllResCode(db_result);
}
if (cfg1_cursor) {
dmi->CloseCursor(cfg1_cursor, true);
cfg1_cursor = NULL;
}
- if (req) delete req;
- if (nreq) delete nreq;
- nreq = req = NULL;
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ result_code = TxCopyRenameTableFromCandidateToRunning(keytype,
+ op[i], dmi);
+ UPLL_LOG_DEBUG("TxCopyRenameTableFromCandidateToRunning returned %d",
+ result_code);
}
result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) ?
UPLL_RC_SUCCESS : result_code;
case UNC_OP_CREATE:
result_code = DupConfigKeyVal(ck_pp, key_pp, MAINTBL);
if (!ck_pp || (result_code != UPLL_RC_SUCCESS)) {
- UPLL_LOG_DEBUG("DupConfigKeyVal() Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("DupConfigKeyVal() Returning error %d", result_code);
return result_code;
}
val_pp = reinterpret_cast<val_policingprofile_t *>(GetVal(ck_pp));
if (!val_pp) {
- UPLL_LOG_DEBUG("invalid val \n");
+ UPLL_LOG_DEBUG("invalid val");
return UPLL_RC_ERR_GENERIC;
}
- val_pp->cs_row_status = UNC_CS_NOT_APPLIED;
+ val_pp->cs_row_status = UNC_CS_APPLIED;
break;
case UNC_OP_DELETE:
}
break;
default:
- UPLL_LOG_DEBUG("Inalid operation\n");
+ UPLL_LOG_DEBUG("Inalid operation");
return UPLL_RC_ERR_GENERIC;
}
- result_code = UpdateConfigDB(ck_pp, UPLL_DT_STATE, op, dmi, MAINTBL);
+ DbSubOp dbop = {kOpNotRead, kOpMatchNone, kOpInOutNone};
+ dbop.inoutop = kOpInOutCs | kOpInOutFlag;
+ result_code = UpdateConfigDB(ck_pp, UPLL_DT_STATE, op, dmi, &dbop, MAINTBL);
EnqueCfgNotification(op, UPLL_DT_RUNNING, key_pp);
delete ck_pp;
return result_code;
case UNC_OP_UPDATE:
// not supported by keytype
// return success
- UPLL_LOG_TRACE(" Not supported operation \n");
+ UPLL_LOG_TRACE(" Not supported operation");
return UPLL_RC_SUCCESS;
default:
- UPLL_LOG_TRACE(" Invalid ooperation \n");
+ UPLL_LOG_TRACE(" Invalid ooperation");
return UPLL_RC_ERR_GENERIC;
}
resp.header.clnt_sess_id = session_id;
GET_USER_DATA_CTRLR_DOMAIN(ck_main, ctrlr_dom);
UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom.ctrlr,
ctrlr_dom.domain);
- if (NULL == ctrlr_dom.ctrlr || NULL == ctrlr_dom.domain) {
- UPLL_LOG_INFO("Invalid controller/domain");
+ if (NULL == ctrlr_dom.ctrlr) {
+ UPLL_LOG_DEBUG("Invalid controller/domain");
result_code = UPLL_RC_ERR_GENERIC;
- if (ck_main) delete ck_main;
+ DELETE_IF_NOT_NULL(ck_main);
break;
}
result_code = TxUpdateProcess(ck_main, &resp, op,
affected_ctrlr_set->insert((const char *)ctrlr_dom.ctrlr);
} else {
UPLL_LOG_DEBUG("TxUpdateProcess error %d", result_code);
+ upll_keytype_datatype_t dt_type = (UNC_OP_DELETE == op)?
+ UPLL_DT_RUNNING:UPLL_DT_CANDIDATE;
+ upll_rc_t local_rc = GetRenamedUncKey(resp.ckv_data, dt_type, dmi,
+ ctrlr_dom.ctrlr);
+ if (UPLL_RC_SUCCESS != local_rc &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != local_rc) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey failed %d", local_rc);
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(resp.ckv_data);
+ result_code = UPLL_RC_ERR_GENERIC;
+ break;
+ }
*err_ckv = resp.ckv_data;
- if (ck_main) delete ck_main;
+ DELETE_IF_NOT_NULL(ck_main);
break;
}
+ DELETE_IF_NOT_NULL(resp.ckv_data);
}
- if (ck_main) {
- delete ck_main;
- ck_main = NULL;
- }
+ DELETE_IF_NOT_NULL(ck_main);
}
if (nreq)
delete nreq;
dup_ckmain = NULL;
result_code = GetChildConfigKey(dup_ckmain, ck_main);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
if (dup_ckmain) delete dup_ckmain;
return result_code;
}
result_code = ReadConfigDB(dup_ckmain, UPLL_DT_CANDIDATE,
UNC_OP_READ, dbop, dmi, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
- string s(dup_ckmain->ToStrAll());
UPLL_LOG_DEBUG("%s policingprofile read failed from candidatedb (%d)",
- s.c_str(), result_code);
+ (dup_ckmain->ToStrAll()).c_str(), result_code);
+ // Since during delete ck_main is set to dup_ckmain
+ // which is deleted by calling method
+ if (op == UNC_OP_CREATE)
+ DELETE_IF_NOT_NULL(dup_ckmain);
return result_code;
}
}
dmi, ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Failed to get the Renamed ControllerKey");
+ // Since during delete ck_main is set to dup_ckmain
+ // which is deleted by calling method
+ if (op == UNC_OP_CREATE)
+ DELETE_IF_NOT_NULL(dup_ckmain);
return result_code;
}
result_code = SendIpcReq(ipc_resp->header.clnt_sess_id,
UPLL_LOG_DEBUG("controller disconnected error proceed with commit");
}
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("IpcSend failed %d\n", result_code);
+ UPLL_LOG_DEBUG("IpcSend failed %d", result_code);
}
if ((op == UNC_OP_CREATE) && dup_ckmain) {
delete dup_ckmain;
return result_code;
}
+upll_rc_t PolicingProfileMoMgr::GetDiffRecord(ConfigKeyVal *ckv_running,
+ ConfigKeyVal *ckv_audit,
+ uuc::UpdateCtrlrPhase phase, MoMgrTables tbl,
+ ConfigKeyVal *&okey,
+ DalDmlIntf *dmi,
+ bool &invalid_attr) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ckv_dup = NULL;
+ okey = NULL;
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutCs};
+ switch (phase) {
+ case uuc::kUpllUcpDelete:
+ UPLL_LOG_DEBUG("Deleted record is %s ",ckv_running->ToStrAll().c_str());
+ result_code = GetChildConfigKey(okey, ckv_running);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed. err_code & phase %d %d",
+ result_code, phase);
+ return result_code;
+ }
+ break;
+ case uuc::kUpllUcpCreate:
+ if (tbl == CTRLRTBL) {
+ UPLL_LOG_DEBUG("Created record fot ctrlr_tbl is %s ",ckv_running->ToStrAll().c_str());
+ result_code = GetChildConfigKey(okey, ckv_running);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed. err_code & phase %d %d",
+ result_code, phase);
+ return result_code;
+ }
+ result_code = ReadConfigDB(okey, UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed. err_code & phase %d %d",
+ result_code, phase);
+ return result_code;
+ }
+ } else {
+ UPLL_LOG_DEBUG("Created record is %s ",ckv_running->ToStrAll().c_str());
+ result_code = DupConfigKeyVal(okey, ckv_running, tbl);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed. err_code & phase %d %d",
+ result_code, phase);
+ return result_code;
+ }
+ }
+ break;
+ case uuc::kUpllUcpUpdate:
+ if (tbl == CTRLRTBL) {
+ UPLL_LOG_DEBUG("UpdateRecord record for run Ctrlr_tbl is %s ",ckv_running->ToStrAll().c_str());
+ /*To be removed*/
+ val_policingprofile_ctrl_t *val1 = reinterpret_cast<val_policingprofile_ctrl_t *>
+ (GetVal(ckv_running));
+ UPLL_LOG_DEBUG("cs_row_status : %d flags : %d ref_count : %d", val1->cs_row_status,
+ val1->flags, val1->ref_count);
+ UPLL_LOG_DEBUG("UpdateRecord record for audit Ctrlr_tbl is %s ",ckv_audit->ToStrAll().c_str());
+ val_policingprofile_ctrl_t *val2 = reinterpret_cast<val_policingprofile_ctrl_t *>
+ (GetVal(ckv_audit));
+ UPLL_LOG_DEBUG("cs_row_status : %d flags : %d ref_count : %d", val2->cs_row_status,
+ val2->flags, val2->ref_count);
+ result_code = GetChildConfigKey(okey, ckv_running);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey for running record failed. \
+ err_code & phase %d %d", result_code, phase);
+ return result_code;
+ }
+ result_code = ReadConfigDB(okey, UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ReadConfigDB from running failed. \
+ err_code & phase %d %d", result_code, phase);
+ return result_code;
+ }
+ result_code = GetChildConfigKey(ckv_dup, ckv_audit);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey for audit record failed. \
+ err_code & phase %d %d", result_code, phase);
+ return result_code;
+ }
+ result_code = ReadConfigDB(ckv_dup, UPLL_DT_AUDIT,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ReadConfigDB from audit failed. \
+ err_code & phase %d %d", result_code, phase);
+ DELETE_IF_NOT_NULL(ckv_dup);
+ return result_code;
+ }
+ } else {
+ UPLL_LOG_DEBUG("UpdateRecord record is %s ",ckv_running->ToStrAll().c_str());
+ UPLL_LOG_DEBUG("UpdateRecord record is %s ",ckv_audit->ToStrAll().c_str());
+ result_code = DupConfigKeyVal(okey, ckv_running, tbl);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed for running record. \
+ err_code & phase %d %d", result_code, phase);
+ return result_code;
+ }
+ result_code = DupConfigKeyVal(ckv_dup, ckv_audit, tbl);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed for audit record. \
+ err_code & phase %d %d", result_code, phase);
+ return result_code;
+ }
+ }
+ if (GetVal(okey) != NULL &&
+ GetVal(ckv_dup) != NULL) {
+ void *val1 = GetVal(okey);
+ invalid_attr = FilterAttributes(val1, GetVal(ckv_dup), true,
+ UNC_OP_UPDATE);
+ }
+ DELETE_IF_NOT_NULL(ckv_dup);
+ break;
+ default:
+ UPLL_LOG_DEBUG("Invalid operation %d", phase);
+ return UPLL_RC_ERR_NO_SUCH_OPERATION;
+ break;
+ }
+ return result_code;
+}
+
upll_rc_t PolicingProfileMoMgr::IsReferenced(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
if (NULL == ikey) return UPLL_RC_ERR_GENERIC;
- result_code = UpdateConfigDB(ikey, dt_type, UNC_OP_READ, dmi, CTRLRTBL);
- if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
- return UPLL_RC_ERR_CFG_SEMANTIC;
- } else if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
- UPLL_LOG_DEBUG(" PolicingProfileMoMgr::IsReferenced. Result Code - %d",
- result_code);
- return result_code;
- }
- unc::upll::kt_momgr::VtnPolicingMapMoMgr *pmmgr = reinterpret_cast
+
+ unc::upll::kt_momgr::VtnPolicingMapMoMgr *vtnpmmgr = reinterpret_cast
<unc::upll::kt_momgr::VtnPolicingMapMoMgr *>
(const_cast<MoManager *>(GetMoManager(UNC_KT_VTN_POLICINGMAP)));
- if (NULL == pmmgr) {
+ if (NULL == vtnpmmgr) {
return UPLL_RC_ERR_GENERIC;
}
- result_code = pmmgr->IsPolicingProfileConfigured(
+ result_code = vtnpmmgr->IsPolicingProfileConfigured(
reinterpret_cast<const char *>
(reinterpret_cast<key_policingprofile *>(ikey->get_key())->
policingprofile_name), dmi);
if (UPLL_RC_SUCCESS != result_code) {
if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ UPLL_LOG_DEBUG("PolicingProfile is referred in VTN");
return UPLL_RC_ERR_CFG_SEMANTIC;
}
- UPLL_LOG_DEBUG(" IsPolicingProfileConfigured failed");
+ UPLL_LOG_DEBUG("VTN IsPolicingProfileConfigured failed. code(%d)",
+ result_code);
+ return result_code;
+ }
+
+ unc::upll::kt_momgr::VbrPolicingMapMoMgr *vbrpmmgr = reinterpret_cast
+ <unc::upll::kt_momgr::VbrPolicingMapMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VBR_POLICINGMAP)));
+ if (NULL == vbrpmmgr) {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = vbrpmmgr->IsPolicingProfileConfigured(
+ reinterpret_cast<const char *>
+ (reinterpret_cast<key_policingprofile *>(ikey->get_key())->
+ policingprofile_name), dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ UPLL_LOG_DEBUG("PolicingProfile is referred in vBridge");
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ UPLL_LOG_DEBUG("vBridge IsPolicingProfileConfigured failed. code(%d)",
+ result_code);
+ return result_code;
+ }
+
+ unc::upll::kt_momgr::VbrIfPolicingMapMoMgr *vbrifpmmgr = reinterpret_cast
+ <unc::upll::kt_momgr::VbrIfPolicingMapMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VBRIF_POLICINGMAP)));
+ if (NULL == vbrifpmmgr) {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = vbrifpmmgr->IsPolicingProfileConfigured(
+ reinterpret_cast<const char *>
+ (reinterpret_cast<key_policingprofile *>(ikey->get_key())->
+ policingprofile_name), dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ UPLL_LOG_DEBUG(" PolicingProfile is referred in vBridge Interface");
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ UPLL_LOG_DEBUG("vBridge If IsPolicingProfileConfigured failed. code(%d)",
+ result_code);
return result_code;
}
return UPLL_RC_SUCCESS;
if (!ctrlr_name) {
ctrlr_name = static_cast<char *>(ikey->get_user_data());
}
- uint32_t dt_type = req->datatype;
- uint32_t operation = req->operation;
- uint32_t option1 = req->option1;
- uint32_t option2 = req->option2;
- UPLL_LOG_DEBUG("dt_type : (%d)"
- "operation : (%d)"
- "option1 : (%d)"
- "option2 : (%d)",
- dt_type, operation, option1, option2);
+ UPLL_LOG_TRACE("Controller_name:(%s), operation:(%d)",
+ ctrlr_name, req->operation);
bool result_code = false;
- uint32_t instance_count;
+ uint32_t max_instance_count;
const uint8_t *attrs = NULL;
uint32_t max_attrs = 0;
- switch (operation) {
+ switch (req->operation) {
case UNC_OP_CREATE: {
result_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
- &instance_count, &max_attrs, &attrs);
+ &max_instance_count, &max_attrs, &attrs);
+ if (result_code && (max_instance_count != 0) &&
+ (cur_instance_count >= max_instance_count)) {
+ UPLL_LOG_DEBUG("Instance count %d exceeds %d", cur_instance_count,
+ max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
break;
}
case UNC_OP_UPDATE: {
break;
}
default: {
- result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ if (req->datatype == UPLL_DT_STATE)
+ result_code = GetStateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ else
+ result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
&max_attrs, &attrs);
}
}
if (!result_code) {
UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s) "
"for opeartion(%d)",
- ikey->get_key_type(), ctrlr_name, operation);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ ikey->get_key_type(), ctrlr_name, req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
return UPLL_RC_SUCCESS;
}
upll_rc_t PolicingProfileMoMgr::GetRenameInfo(ConfigKeyVal *ikey,
ConfigKeyVal *okey, ConfigKeyVal *&rename_info, DalDmlIntf *dmi,
const char *ctrlr_id, bool &renamed) {
-
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- if (!ikey || !okey || NULL != rename_info ||
- NULL == ctrlr_id || NULL == ikey->get_key()) { // COVERITY FORWARD NULL
+ if (!ikey || !okey || NULL != rename_info
+ || !(ikey->get_key()) || !(okey->get_key())) {
+ UPLL_LOG_DEBUG("Input is NULL");
return UPLL_RC_ERR_GENERIC;
}
- key_rename_vnode_info_t *key_rename_info =
- reinterpret_cast<key_rename_vnode_info_t *>
- (ConfigKeyVal::Malloc(sizeof(key_rename_vnode_info_t)));
key_policingprofile_t *policingprofile_key = NULL;
- if (!(ikey->get_key())) {
- free(key_rename_info);
- return UPLL_RC_ERR_GENERIC;
- }
policingprofile_key = reinterpret_cast<key_policingprofile_t *>
(ikey->get_key());
- if (!strlen(reinterpret_cast<char *>
- (policingprofile_key->policingprofile_name))) {
- free(key_rename_info);
+ if (policingprofile_key == NULL) {
+ UPLL_LOG_DEBUG("policingprofile_key NULL");
return UPLL_RC_ERR_GENERIC;
}
+ key_rename_vnode_info_t *key_rename_info =
+ reinterpret_cast<key_rename_vnode_info_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_rename_vnode_info_t)));
+
+ /* Checks the profile is already renamed or not */
+ if (renamed) {
+ /* if already renamed store the controller name */
+ uuu::upll_strncpy(key_rename_info->ctrlr_profile_name,
+ reinterpret_cast<val_rename_policingprofile *>(GetVal(ikey))
+ ->policingprofile_newname, (kMaxLenPolicingProfileName + 1));
+ UPLL_LOG_DEBUG("key_rename_info->ctrlr_profile_name ::: (%s)",
+ key_rename_info->ctrlr_profile_name);
+ } else {
+ /* if not renamed the ikey contains the controller name */
+ uuu::upll_strncpy(key_rename_info->ctrlr_profile_name,
+ policingprofile_key->policingprofile_name,
+ (kMaxLenPolicingProfileName + 1));
+ UPLL_LOG_DEBUG("key_rename_info->ctrlr_profile_name ::: (%s)",
+ key_rename_info->ctrlr_profile_name);
+ }
+ // To check for standalone configuration
+ DbSubOp dbop1 = {kOpReadExist, kOpMatchNone,
+ kOpInOutNone};
+ result_code = UpdateConfigDB(ikey, UPLL_DT_IMPORT,
+ UNC_OP_READ, dmi, &dbop1, CTRLRTBL);
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ result_code = UPLL_RC_ERR_NOT_ALLOWED_AT_THIS_TIME;
+ UPLL_LOG_DEBUG("Stand Alone configuration found %d", result_code);
+ free(key_rename_info); // resource leak
+ return result_code;
+ } else if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed - %d", result_code);
+ free(key_rename_info); // resource leak
+ return result_code;
+ }
+ /* Store the old UNC VTN name */
uuu::upll_strncpy(key_rename_info->old_policingprofile_name,
policingprofile_key->policingprofile_name,
- strlen(reinterpret_cast<const char *>
- (policingprofile_key->policingprofile_name)));
+ (kMaxLenPolicingProfileName + 1));
+ UPLL_LOG_DEBUG("key_rename_info->old_policingprofile_name ::: (%s)",
+ key_rename_info->old_policingprofile_name);
- if (!(okey->get_key())) {
- free(key_rename_info);
- return UPLL_RC_ERR_GENERIC;
- }
policingprofile_key = reinterpret_cast<key_policingprofile_t *>
(okey->get_key());
- if (!strlen(reinterpret_cast<char *>
- (policingprofile_key->policingprofile_name))) {
- free(key_rename_info);
- return UPLL_RC_ERR_GENERIC;
- }
uuu::upll_strncpy(key_rename_info->new_policingprofile_name,
policingprofile_key->policingprofile_name,
- strlen(reinterpret_cast<const char *>
- (policingprofile_key->policingprofile_name)));
+ (kMaxLenPolicingProfileName + 1));
+ UPLL_LOG_DEBUG("key_rename_info->new_policingprofile_name ::: (%s)",
+ key_rename_info->new_policingprofile_name);
rename_info = new ConfigKeyVal(UNC_KT_POLICING_PROFILE,
IpctSt::kIpcInvalidStNum, key_rename_info, NULL);
+ if (!rename_info) {
+ free(key_rename_info);
+ UPLL_LOG_DEBUG("Failed to allocate memory for ConfigkeyVal");
+ return UPLL_RC_ERR_GENERIC;
+ }
SET_USER_DATA_CTRLR(rename_info, ctrlr_id);
+
if (!renamed) {
val_rename_policingprofile_t *val_rename =
reinterpret_cast<val_rename_policingprofile_t *>
(ConfigKeyVal::Malloc(sizeof(val_rename_policingprofile_t)));
uuu::upll_strncpy(val_rename->policingprofile_newname,
- key_rename_info->old_policingprofile_name,
+ key_rename_info->ctrlr_profile_name,
(kMaxLenPolicingProfileName+1));
+ val_rename->valid[UPLL_IDX_RENAME_PROFILE_RPP] = UNC_VF_VALID;
ConfigVal *cfg_val = new ConfigVal(IpctSt::kIpcStValRenamePolicingprofile,
val_rename);
- okey->AppendCfgVal(cfg_val);
- SET_USER_DATA_CTRLR(okey, ctrlr_id);
+
+ SET_USER_DATA_CTRLR(ikey, ctrlr_id);
+
+ ikey->SetCfgVal(cfg_val);
+
DbSubOp dbop = {kOpNotRead, kOpMatchNone, kOpInOutCtrlr};
- result_code = UpdateConfigDB(okey, UPLL_DT_IMPORT, UNC_OP_CREATE, dmi,
+ result_code = UpdateConfigDB(ikey, UPLL_DT_IMPORT, UNC_OP_CREATE, dmi,
&dbop, RENAMETBL);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG(" GetRenameInfo Failed. UpdateConfigDb Failed"
- " Result code - %d", result_code);
- free(key_rename_info);
- free(val_rename);
+ UPLL_LOG_DEBUG("UpdateConfigDb Failed (%d)", result_code);
}
}
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code)
+ result_code = UPLL_RC_SUCCESS;
return result_code;
}
upll_rc_t PolicingProfileMoMgr::CopyToConfigKey(ConfigKeyVal *&okey,
ConfigKeyVal *ikey) {
-
UPLL_FUNC_TRACE;
if (NULL == ikey || NULL == (ikey->get_key()) || NULL != okey) {
+ UPLL_LOG_DEBUG("Invalid Input");
return UPLL_RC_ERR_GENERIC;
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
- if (UNC_KT_POLICING_PROFILE == ikey->get_key_type()) {
- key_rename_vnode_info_t *key_rename =
- reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
- key_policingprofile_t *key_policingprofile =
- reinterpret_cast<key_policingprofile_t *>
- (ConfigKeyVal::Malloc(sizeof(key_policingprofile_t)));
- if (!strlen(reinterpret_cast<char *>
- (key_rename->old_policingprofile_name))) {
- UPLL_LOG_DEBUG(" Invalid Policing Profile Name");
- free(key_policingprofile);
- return UPLL_RC_ERR_GENERIC;
- }
- uuu::upll_strncpy(key_policingprofile->policingprofile_name,
- key_rename->old_policingprofile_name,
- kMaxLenPolicingProfileName+1);
+ key_rename_vnode_info_t *key_rename =
+ reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
+ if (!strlen(reinterpret_cast<char *>
+ (key_rename->old_policingprofile_name))) {
+ UPLL_LOG_DEBUG(" Invalid Policing Profile Name");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ key_policingprofile_t *key_policingprofile =
+ reinterpret_cast<key_policingprofile_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_policingprofile_t)));
+ uuu::upll_strncpy(key_policingprofile->policingprofile_name,
+ key_rename->old_policingprofile_name,
+ kMaxLenPolicingProfileName+1);
- okey = new ConfigKeyVal(UNC_KT_POLICING_PROFILE,
- IpctSt::kIpcStKeyPolicingprofile, key_policingprofile, NULL);
- if (!okey) {
- free(key_policingprofile);
- return UPLL_RC_ERR_GENERIC;
- }
- } else {
+ okey = new ConfigKeyVal(UNC_KT_POLICING_PROFILE,
+ IpctSt::kIpcStKeyPolicingprofile, key_policingprofile, NULL);
+ if (!okey) {
+ UPLL_LOG_DEBUG("okey NULL");
+ free(key_policingprofile);
return UPLL_RC_ERR_GENERIC;
}
+ SET_USER_DATA(okey, ikey);
return result_code;
}
bool PolicingProfileMoMgr::IsValidKey(void *ikey, uint64_t index) {
+ UPLL_FUNC_TRACE;
key_policingprofile_t *key =
- reinterpret_cast<key_policingprofile_t *>(ikey);
- UPLL_LOG_TRACE("Entering IsValidKey");
- bool ret_val = UPLL_RC_SUCCESS;
+ reinterpret_cast<key_policingprofile_t *>(ikey);
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
- ret_val = ValidateKey(reinterpret_cast<char *>
- (key->policingprofile_name),
- kMinLenPolicingProfileName, kMaxLenPolicingProfileName);
+ ret_val = ValidateKey(reinterpret_cast<char *>(key->policingprofile_name),
+ kMinLenPolicingProfileName,
+ kMaxLenPolicingProfileName);
if (UPLL_RC_SUCCESS != ret_val) {
UPLL_LOG_DEBUG("Policingprofile Name is not valid(%d)", ret_val);
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *ckv = NULL;
- DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutNone};
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutCs};
result_code = GetChildConfigKey(ckv, ikey);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG(" SetConsolidatedStatus failed. GetChildConfigKey Failed"
return result_code;
}
std::list< unc_keytype_configstatus_t > list_cs_row;
- val_policingprofile_t *val;
+ val_policingprofile_ctrl_t *val;
ConfigKeyVal *tmp_ckv = ckv;
- for ( ; tmp_ckv != NULL ; tmp_ckv = ckv->get_next_cfg_key_val()) {
- val = reinterpret_cast<val_policingprofile_t *>(GetVal(tmp_ckv));
+ for ( ; tmp_ckv != NULL ; tmp_ckv = tmp_ckv->get_next_cfg_key_val()) {
+ val = reinterpret_cast<val_policingprofile_ctrl_t *>(GetVal(tmp_ckv));
list_cs_row.push_back((unc_keytype_configstatus_t)val->cs_row_status);
+ UPLL_LOG_DEBUG("Printing Cs_attr %d",val->cs_row_status);
}
if (ckv) delete ckv;
val_policingprofile_t *val_temp =
UNC_OP_READ, dbop, dmi, CTRLRTBL);
UPLL_LOG_DEBUG(" Read result in CtrlrTblCreate %d ", result_code);
if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ // capability check
+ ConfigKeyVal *temp_key = NULL;
+ uint8_t *ctrlr_id = NULL;
+ GET_USER_DATA_CTRLR(pp_ckv, ctrlr_id);
+
+ result_code = GetChildConfigKey(temp_key, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed(%d)",result_code);
+ return result_code;
+ }
+
+ result_code = GetInstanceCount(temp_key, reinterpret_cast<char*>(ctrlr_id),
+ dt_type,
+ &cur_instance_count,
+ dmi, CTRLRTBL);
+ DELETE_IF_NOT_NULL(temp_key);
+
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetInstanceCount failed(%d)",result_code);
+ return result_code;
+ }
+
+ IpcReqRespHeader *temp_req = reinterpret_cast<IpcReqRespHeader *>
+ (ConfigKeyVal::Malloc(sizeof(IpcReqRespHeader)));
+
+ temp_req->operation = UNC_OP_CREATE;
+ temp_req->datatype = dt_type;
+
+ result_code = ValidateCapability(temp_req, pp_ckv, reinterpret_cast<char*>(ctrlr_id));
+
+ free(temp_req);
+
+ unc_keytype_ctrtype_t ctrlrtype = UNC_CT_UNKNOWN;
+ uuc::CtrlrMgr *ctrlr_mgr = uuc::CtrlrMgr::GetInstance();
+ if (result_code != UPLL_RC_SUCCESS) {
+ // Policingprofile is not supported for other than PFC Controller
+ // so skip adding entry for such sontroller in ctrlr table
+ if ((!ctrlr_mgr->GetCtrlrType(reinterpret_cast<char *>(ctrlr_id),
+ dt_type, &ctrlrtype)) || (ctrlrtype != UNC_CT_PFC)) {
+ UPLL_LOG_DEBUG("Controller type is %d", ctrlrtype);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("Key not supported by controller");
+ return result_code;
+ }
UPLL_LOG_DEBUG(" No record found. Create new record");
val_ctrlr = reinterpret_cast<val_policingprofile_ctrl_t *>
(GetVal(pp_ckv));
val_ctrlr->ref_count = 1;
val_ctrlr->valid[0] = UNC_VF_VALID;
+ if (UPLL_DT_AUDIT == dt_type) {
+ ConfigKeyVal *temp_pp_ckv = NULL;
+ result_code = GetChildConfigKey(temp_pp_ckv, pp_ckv);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed");
+ return result_code;
+ }
+ DbSubOp dbop1 = {kOpReadSingle, kOpMatchNone, kOpInOutCs};
+ result_code = ReadConfigDB(temp_pp_ckv, dt_type,
+ UNC_OP_READ, dbop1, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(temp_pp_ckv);
+ return result_code;
+ }
+ val_policingprofile_t *temp_val = reinterpret_cast
+ <val_policingprofile_t *>(GetVal(temp_pp_ckv));
+ val_ctrlr->cs_row_status = static_cast<unc_keytype_configstatus_t>
+ (temp_val->cs_row_status);
+ DELETE_IF_NOT_NULL(temp_pp_ckv);
+ }
result_code = UpdateConfigDB(pp_ckv, dt_type,
UNC_OP_CREATE, dmi, CTRLRTBL);
if (UPLL_RC_SUCCESS != result_code) {
}
upll_rc_t PolicingProfileMoMgr::UpdateConfigStatus(ConfigKeyVal *ckv,
- unc_keytype_operation_t op,
- uint32_t driver_result,
- ConfigKeyVal *nreq,
- DalDmlIntf *dmi,
- ConfigKeyVal *ctrlr_key) {
+ unc_keytype_operation_t op,
+ uint32_t driver_result,
+ ConfigKeyVal *nreq,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ctrlr_key) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- unc_keytype_configstatus_t status = UNC_CS_UNKNOWN;
- unc_keytype_configstatus_t cs_status = UNC_CS_UNKNOWN;
- cs_status = (driver_result == 0) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
-
+ unc_keytype_configstatus_t ctrlr_status;
+ uint8_t cs_status;
+ ctrlr_status = (driver_result == UPLL_RC_SUCCESS) ?
+ UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
if ((NULL == ckv) || (NULL == ctrlr_key)) {
UPLL_LOG_DEBUG("input struct is NULL");
return UPLL_RC_ERR_GENERIC;
UPLL_LOG_ERROR("Value structure is empty!!");
return UPLL_RC_ERR_GENERIC;
}
+ cs_status = val_policingprofile->cs_row_status;
+ UPLL_LOG_TRACE("cs_status %d ctrlr_status %d\n", cs_status, ctrlr_status);
if (op == UNC_OP_CREATE) {
- switch (val_policingprofile->cs_row_status) {
- case UNC_CS_UNKNOWN:
- status = cs_status;
- break;
- case UNC_CS_PARTAILLY_APPLIED:
- if (ctrlr_val_policingprofile->cs_row_status == UNC_CS_NOT_APPLIED) {
+ ctrlr_val_policingprofile->cs_row_status = ctrlr_status;
+ /* update the vtn status in main tbl */
+ if (val_policingprofile->cs_row_status == UNC_CS_UNKNOWN) {
+ /* first entry in ctrlr table */
+ cs_status = ctrlr_status;
+ } else if (val_policingprofile->cs_row_status == UNC_CS_APPLIED) {
+ if (ctrlr_status == UNC_CS_NOT_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
}
- break;
- case UNC_CS_APPLIED:
- case UNC_CS_NOT_APPLIED:
- case UNC_CS_INVALID:
- default:
- status =
- (cs_status == UNC_CS_APPLIED) ? UNC_CS_PARTAILLY_APPLIED : status;
- break;
+ } else if (val_policingprofile->cs_row_status == UNC_CS_NOT_APPLIED) {
+ if (ctrlr_status == UNC_CS_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ }
+ } else if (val_policingprofile->cs_row_status == UNC_CS_INVALID) {
+ cs_status = UNC_CS_INVALID;
+ } else {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
}
- val_policingprofile->cs_row_status = status;
+ val_policingprofile->cs_row_status = cs_status;
}
return result_code;
}
SET_USER_DATA(okey, ikey);
return UPLL_RC_SUCCESS;
}
+
+upll_rc_t PolicingProfileMoMgr::SetValidAudit(ConfigKeyVal *&ikey) {
+ UPLL_FUNC_TRACE;
+ val_policingprofile_t *val = reinterpret_cast<val_policingprofile_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_policingprofile_t)));
+ val->cs_row_status = UNC_CS_APPLIED;
+ ikey->AppendCfgVal(IpctSt::kIpcStValPolicingprofile, val);
+ return UPLL_RC_SUCCESS;
+}
+
+bool PolicingProfileMoMgr::FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op) {
+ UPLL_FUNC_TRACE;
+ if (op != UNC_OP_CREATE)
+ return true;
+ return false;
+}
+
+upll_rc_t PolicingProfileMoMgr::SetPPConsolidatedStatus(ConfigKeyVal *ikey,
+ uint8_t *ctrlr_id,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ctrlr_ckv = NULL;
+ val_policingprofile_ctrl_t *ctrlr_val = NULL;
+ uint8_t *pp_exist_on_ctrlr = NULL;
+ bool applied = false, not_applied = false, invalid = false;
+ unc_keytype_configstatus_t c_status = UNC_CS_NOT_APPLIED;
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone,
+ kOpInOutCtrlr | kOpInOutCs };
+ if (!ikey || !dmi) {
+ UPLL_LOG_DEBUG("Invalid Input");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = GetChildConfigKey(ctrlr_ckv, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed err code %d", result_code);
+ return result_code;
+ }
+ result_code = ReadConfigDB(ctrlr_ckv, UPLL_DT_RUNNING, UNC_OP_READ, dbop, dmi,
+ CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB from ctrltbl failed err code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return result_code;
+ }
+
+ for (ConfigKeyVal *tmp = ctrlr_ckv; tmp != NULL;
+ tmp = tmp->get_next_cfg_key_val()) {
+ ctrlr_val = reinterpret_cast<val_policingprofile_ctrl_t *>(GetVal(tmp));
+ if (!ctrlr_val) {
+ UPLL_LOG_DEBUG("Controller Value is empty");
+ tmp = NULL;
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ GET_USER_DATA_CTRLR(tmp, pp_exist_on_ctrlr);
+ if (!strcmp(reinterpret_cast<char *>(pp_exist_on_ctrlr),
+ reinterpret_cast<char *>(ctrlr_id)))
+ continue; // skipping entry of deleted controller
+
+ switch (ctrlr_val->cs_row_status) {
+ case UNC_CS_APPLIED:
+ applied = true;
+ break;
+ case UNC_CS_NOT_APPLIED:
+ not_applied = true;
+ break;
+ case UNC_CS_INVALID:
+ invalid = true;
+ break;
+ default:
+ UPLL_LOG_DEBUG("Invalid status");
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ // return UPLL_RC_ERR_GENERIC;
+ }
+ pp_exist_on_ctrlr = NULL;
+ }
+ if (invalid) {
+ c_status = UNC_CS_INVALID;
+ } else if (applied && !not_applied) {
+ c_status = UNC_CS_APPLIED;
+ } else if (!applied && not_applied) {
+ c_status = UNC_CS_NOT_APPLIED;
+ } else if (applied && not_applied) {
+ c_status = UNC_CS_PARTIALLY_APPLIED;
+ } else {
+ c_status = UNC_CS_APPLIED;
+ }
+ // Set cs_status
+ val_policingprofile_t *val = static_cast<val_policingprofile_t *>
+ (GetVal(ikey));
+ val->cs_row_status = c_status;
+ DbSubOp dbop_update = {kOpNotRead, kOpMatchNone, kOpInOutCs};
+ result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_UPDATE, dmi,
+ &dbop_update, MAINTBL);
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return result_code;
+}
} // namespace kt_momgr
} // namespace upll
} // namespace unc
* Member Variable for PolicingProfileBindInfo.
*/
static BindInfo rename_policingprofile_rename_tbl[];
-
+ uint32_t cur_instance_count;
/**
* @Brief Validates the syntax of the specified key and value structure
* for KT_POLICINGPROFILE keytype
* @retval UPLL_RC_ERR_NO_SUCH_INSTANCE No record found in DB
* @retval UPLL_RC_ERR_DB_ACCESS DB access error
*/
- upll_rc_t GetRenamedControllerKey(ConfigKeyVal *&ikey,
+ upll_rc_t GetRenamedControllerKey(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
controller_domain *ctrlr_dom = NULL);
upll_rc_t UpdateMainTbl(ConfigKeyVal *key_pp,
unc_keytype_operation_t op, uint32_t driver_result,
ConfigKeyVal *nreq, DalDmlIntf *dmi);
+
+ upll_rc_t GetDiffRecord(ConfigKeyVal *ckv_running,
+ ConfigKeyVal *ckv_audit,
+ uuc::UpdateCtrlrPhase phase, MoMgrTables tbl,
+ ConfigKeyVal *&okey,
+ DalDmlIntf *dmi,
+ bool &invalid_attr);
+
+ upll_rc_t SetValidAudit(ConfigKeyVal *&ikey);
+
+ bool FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op);
+
+ upll_rc_t SetPPConsolidatedStatus(ConfigKeyVal *ikey,
+ uint8_t *ctrlr_id,
+ DalDmlIntf *dmi);
};
typedef struct val_policingprofile_ctrl {
upll_rc_t new_urc = ReadBulkGetSubtree(kt_tree, datatype,
local_bulk_ckv_req,
(requested_cnt - (*added_cnt)),
- &local_bulk_ckv_resp, &new_cnt, dmi);
+ &local_bulk_ckv_resp, &new_cnt,
+ dmi);
delete local_bulk_ckv_req;
if (new_urc == UPLL_RC_SUCCESS) {
(*added_cnt) += new_cnt;
}
UPLL_LOG_DEBUG("KT: %u Got %u Urc %d", curr_kt, (*added_cnt), new_urc);
} // For all sibling instances
+
+ delete curr_req_ckv;
+
if ((curr_urc != UPLL_RC_ERR_NO_SUCH_INSTANCE) &&
(curr_urc != UPLL_RC_SUCCESS)) {
if (*user_resp_ckv != NULL) {
delete *user_resp_ckv;
*user_resp_ckv = NULL;
}
- delete curr_req_ckv;
return curr_urc;
}
} // For all children KT
UPLL_LOG_DEBUG("KT: %u Requested: %u, Got %u",
user_req_ckv->get_key_type(), requested_cnt, (*added_cnt));
UPLL_LOG_TRACE("Req:%s\nResponse: %s", user_req_ckv->ToStr().c_str(),
- ((*user_resp_ckv) ? (*user_resp_ckv)->ToStrAll().c_str() : "null"));
+ ((*user_resp_ckv) ? (*user_resp_ckv)->ToStrAll().c_str()
+ : "null"));
return UPLL_RC_SUCCESS;
}
// Find first instance in the database
MoManager *momgr = GetMoManager(user_req_ckv->get_key_type());
if (momgr == NULL) {
- UPLL_LOG_DEBUG("KT %u is not managed by UPLL", user_req_ckv->get_key_type());
+ UPLL_LOG_DEBUG("KT %u is not managed by UPLL",
+ user_req_ckv->get_key_type());
msghdr->result_code = UPLL_RC_ERR_NO_SUCH_NAME;
return UPLL_RC_ERR_NO_SUCH_NAME;
}
delete step_req_ckv;
step_req_ckv = NULL;
+ ConfigKeyVal *subtree_req_ckv = step_resp_ckv->DupKey();
+
if (retrieve_user_req_mo) {
retrieve_user_req_mo = false;
+ delete step_resp_ckv;
+ step_resp_ckv = NULL;
} else {
// Add the node;
added_cnt++;
(*user_resp_ckv)->AppendCfgKeyVal(step_resp_ckv);
}
}
+
begin = false;
- ConfigKeyVal *subtree_req_ckv = step_resp_ckv->DupKey();
ConfigKeyVal *subtree_resp_ckv = NULL;
uint32_t step_added_cnt = 0;
upll_rc_t urc = ReadBulkGetSubtree(*kt_tree, msghdr->datatype,
subtree_req_ckv, pending_cnt,
&subtree_resp_ckv,
&step_added_cnt, dmi);
- delete subtree_req_ckv;
- subtree_req_ckv = NULL;
if (urc != UPLL_RC_SUCCESS) {
UPLL_LOG_INFO("ReadBulkGetSubtree failed. Urc=%d", urc);
+ delete subtree_req_ckv;
+ subtree_req_ckv = NULL;
if (*user_resp_ckv) {
delete *user_resp_ckv;
*user_resp_ckv = NULL;
}
if (pending_cnt > 0) {
// continue; and fetch more
- step_req_ckv = step_resp_ckv->DupKey();
+ step_req_ckv = subtree_req_ckv->DupKey();
+ delete subtree_req_ckv;
+ subtree_req_ckv = NULL;
} else {
/* Can't delete step_resp_ckv as is it attached to user_resp_ckv
delete step_resp_ckv;
*/
+ delete subtree_req_ckv;
+ subtree_req_ckv = NULL;
msghdr->result_code = UPLL_RC_SUCCESS;
msghdr->rep_count = added_cnt;
UPLL_LOG_TRACE("Returning from %s", __FUNCTION__);
done = true;
msghdr->result_code = UPLL_RC_ERR_GENERIC;
} else {
+ delete step_req_ckv;
step_req_ckv = parent_ckv;
parent_ckv = NULL;
}
}
if (done) {
- if (step_req_ckv) {
- delete step_req_ckv;
- step_req_ckv = NULL;
- }
+ delete step_req_ckv;
+ step_req_ckv = NULL;
+
if ((msghdr->result_code != UPLL_RC_SUCCESS &&
msghdr->result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) &&
- (user_resp_ckv != NULL)) {
+ (*user_resp_ckv != NULL)) {
delete *user_resp_ckv;
*user_resp_ckv = NULL;
}
#include "ctrlr_mgr.hh"
#include "config_mgr.hh"
#include "ipct_st.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
namespace unc {
namespace upll {
using unc::upll::ipc_util::IpctSt;
using unc::upll::ipc_util::KtUtil;
+const char * const TcLibIntfImpl::kUpllCtrlrId = "";
+
TcLibIntfImpl::TcLibIntfImpl(UpllConfigMgr *ucm) {
ucm_ = ucm;
session_id_ = 0;
if (err_ckv != NULL) {
// Local error in UPLL, send it to TC with controller id as ""
list<CtrlrTxResult*> tx_res_list;
- CtrlrTxResult unc_res("", urc, urc);
+ CtrlrTxResult unc_res(kUpllCtrlrId, urc, urc);
unc_res.err_ckv = err_ckv; // err_ckv will be freed by CtlrTxResult
tx_res_list.push_back(&unc_res);
if (WriteBackTxResult(tx_res_list) != true) {
upll_keytype_datatype_t datatype;
datatype = audit ? UPLL_DT_RUNNING : UPLL_DT_CANDIDATE;
if (false == CtrlrMgr::GetInstance()->GetCtrlrType(
- ctrlr_name.c_str(), datatype, &ctrlr_type)) {
- UPLL_LOG_WARN("Unable to get controller type for %s", ctrlr_name.c_str());
- return UPLL_RC_ERR_GENERIC;
+ ctrlr_name.c_str(), datatype, &ctrlr_type)) {
+ if (datatype != UPLL_DT_RUNNING) {
+ if (false == CtrlrMgr::GetInstance()->GetCtrlrType(
+ ctrlr_name.c_str(), UPLL_DT_RUNNING, &ctrlr_type)) {
+ UPLL_LOG_WARN("Unable to get controller type for %s",
+ ctrlr_name.c_str());
+ return UPLL_RC_ERR_GENERIC;
+ }
+ } else {
+ UPLL_LOG_WARN("Unable to get controller type for %s",
+ ctrlr_name.c_str());
+ return UPLL_RC_ERR_GENERIC;
+ }
}
UPLL_LOG_TRACE("Affected controller name=%s, type=%d",
ctrlr_name.c_str(), ctrlr_type);
if (err_ckv != NULL) {
// Local error in UPLL, send it to TC with controller id as ""
list<CtrlrTxResult*> tx_res_list;
- CtrlrTxResult unc_res("", urc, urc);
+ CtrlrTxResult unc_res(kUpllCtrlrId, urc, urc);
unc_res.err_ckv = err_ckv; // err_ckv will be freed by CtlrTxResult
tx_res_list.push_back(&unc_res);
if (WriteBackTxResult(tx_res_list) != true) {
upll_rc_t urc = ucm_->OnTxGlobalCommit(&affected_ctrlr_list);
if (urc == UPLL_RC_SUCCESS) {
urc = FillTcDriverInfoMap(&driver_info, affected_ctrlr_list, false);
+ if (urc != UPLL_RC_SUCCESS) {
+ pfc_log_fatal("Failed to fill TcDriverInfoMap in Commit-GlobalCommit");
+ }
}
return ((urc == UPLL_RC_SUCCESS) ? unc::tclib::TC_SUCCESS :
unc::tclib::TC_FAILURE);
unc::tclib::TcLibModule *tclib = UpllConfigMgr::GetTcLibModule();
if (tclib == NULL) {
- UPLL_LOG_DEBUG("Unable to get tclib module");
+ UPLL_LOG_ERROR("Unable to get tclib module");
return false;
}
// Read Key and Value from the Tclib Module.
const pfc_ipcstdef_t *key_stdef = IpctSt::GetIpcStdef(key_stnum);
- const pfc_ipcstdef_t *val_stdef = IpctSt::GetIpcStdef(val_stnum);
+ // Need a dummy for val_stdef;
+ pfc_ipcstdef_t val_stdef_dummy;
+ const pfc_ipcstdef_t *val_stdef;
+ if (val_exists) {
+ val_stdef = IpctSt::GetIpcStdef(val_stnum);
+ } else {
+ bzero(&val_stdef_dummy, sizeof(val_stdef_dummy));
+ val_stdef = &val_stdef_dummy;
+ }
if (key_stdef == NULL || (val_exists && (val_stdef == NULL))) {
UPLL_LOG_TRACE("key_stnum=%d key_stdef=%p val_stnum=%d val_stdef=%p",
key_stnum, key_stdef, val_stnum, val_stdef);
return false;
}
- void *key = malloc(key_stdef->ist_size);
- void *val = (val_exists) ? malloc(val_stdef->ist_size) : NULL;
+ void *key = ConfigKeyVal::Malloc(key_stdef->ist_size);
+ void *val = (val_exists) ? ConfigKeyVal::Malloc(val_stdef->ist_size) : NULL;
if (key == NULL || (val_exists && (val == NULL))) {
UPLL_LOG_TRACE("Failed to allocate key=%p val=%p", key, val);
- if (key != NULL) free(key);
- if (val != NULL) free(val);
+ if (key != NULL) ConfigKeyVal::Free(key);
+ if (val != NULL) ConfigKeyVal::Free(val);
if (*err_ckv != NULL) {
delete *err_ckv;
*err_ckv = NULL;
ctrlr_id, err_pos, keytype, *key_stdef, *val_stdef, key, val);
if (tclib_ret != unc::tclib::TC_API_COMMON_SUCCESS) {
UPLL_LOG_DEBUG("Failed to read from tclib %d", tclib_ret);
- free(key);
+ ConfigKeyVal::Free(key);
if (val != NULL) {
- free(val);
+ ConfigKeyVal::Free(val);
}
if (*err_ckv != NULL) {
delete *err_ckv;
unc_keytype_ctrtype_t ctrlr_type, int driver_result_code) {
switch (ctrlr_type) {
case UNC_CT_PFC:
+ case UNC_CT_VNP:
{
switch (driver_result_code) {
case DRVAPI_RESPONSE_SUCCESS:
case DRVAPI_RESPONSE_INVALID_KEYTYPE:
case DRVAPI_RESPONSE_MISSING_KEY_STRUCT:
case DRVAPI_RESPONSE_MISSING_VAL_STRUCT:
+ case DRVAPI_RESPONSE_NO_SUCH_INSTANCE:
case DRVAPI_RESPONSE_INVALID_TRANSACTION:
default:
return UPLL_RC_ERR_GENERIC;
}
}
break;
- // case UNC_CT_LEGACY:
- case UNC_CT_VNP:
default:
return UPLL_RC_ERR_GENERIC;
}
ctr_it != driver_result->end(); ++ctr_it) {
unc_keytype_ctrtype_t ctrlr_type = UNC_CT_UNKNOWN;
if (false == CtrlrMgr::GetInstance()->GetCtrlrType(
- ctr_it->controller_id.c_str(), UPLL_DT_CANDIDATE, &ctrlr_type)) {
- UPLL_LOG_DEBUG("Controller %s does not exist",
- ctr_it->controller_id.c_str());
- // empty tx_res_list and free its contents
- for (list<CtrlrTxResult*>::iterator tx_res_it = tx_res_list->begin();
- tx_res_it != tx_res_list->end(); tx_res_it++) {
- CtrlrTxResult *tx_res = *tx_res_it;
- delete tx_res;
+ ctr_it->controller_id.c_str(), UPLL_DT_CANDIDATE, &ctrlr_type)) {
+ if (false == CtrlrMgr::GetInstance()->GetCtrlrType(
+ ctr_it->controller_id.c_str(), UPLL_DT_RUNNING, &ctrlr_type)) {
+ UPLL_LOG_DEBUG("Controller %s does not exist",
+ ctr_it->controller_id.c_str());
+ // empty tx_res_list and free its contents
+ for (list<CtrlrTxResult*>::iterator tx_res_it = tx_res_list->begin();
+ tx_res_it != tx_res_list->end(); tx_res_it++) {
+ CtrlrTxResult *tx_res = *tx_res_it;
+ delete tx_res;
+ }
+ tx_res_list->clear();
+ return false;
}
- tx_res_list->clear();
- return false;
}
/*
if (ctrlr_type == UNC_CT_PFC) {
}
*/
- UPLL_LOG_TRACE("Controller ID=%s Result=%d ErrCount=%d",
- ctr_it->controller_id.c_str(), converted_result,
- ctr_it->num_of_errors);
+ UPLL_LOG_INFO("Controller ID=%s CtrlrResult=%d Urc=%d ErrCount=%d",
+ ctr_it->controller_id.c_str(), ctr_it->resp_code,
+ converted_result, ctr_it->num_of_errors);
CtrlrTxResult *tx_res = new CtrlrTxResult(ctr_it->controller_id,
converted_result,
delete tx_res;
return false;
}
+ if (tx_res->err_ckv != NULL) {
+ UPLL_LOG_INFO("Error CKV received from controller <%s>: %s",
+ ctr_it->controller_id.c_str(),
+ tx_res->err_ckv->ToStrAll().c_str());
+ }
tx_res_list->push_back(tx_res);
/*
if (tx_res->err_ckv->size() != 0) {
unc::tclib::TcLibModule *tclib = UpllConfigMgr::GetTcLibModule();
if (tclib == NULL) {
- UPLL_LOG_DEBUG("Unable to get tclib module");
+ UPLL_LOG_ERROR("Unable to get tclib module");
return false;
}
for (std::list<CtrlrTxResult*>::const_iterator ctrlr_it = tx_res_list.begin();
ctrlr_it != tx_res_list.end(); ctrlr_it++) {
const CtrlrTxResult *res = *ctrlr_it;
+ // Skip controllers whose status is success.
+ // During Vote/G-Commit, disconnected controller information is not skipped
+ // During Vote, DRVAPI_RESPONSE_NOT_SENT_TO_CONTROLLER is not skipped.
+ if ((res->ctrlr_id.compare(kUpllCtrlrId) != 0) &&
+ (res->ctrlr_orig_result == DRVAPI_RESPONSE_SUCCESS)) {
+ continue;
+ }
unc::tclib::TcApiCommonRet tclib_ret = tclib->TcLibWriteControllerInfo(
res->ctrlr_id, res->ctrlr_orig_result, res->err_ckv->size());
if (tclib_ret != unc::tclib::TC_API_COMMON_SUCCESS) {
UPLL_LOG_DEBUG("Failed to write to tclib %d", tclib_ret);
return false;
}
+ if (res->err_ckv) {
+ UPLL_LOG_INFO("Proccessed Error CKV for controller <%s>: %s",
+ res->ctrlr_id.c_str(), res->err_ckv->ToStrAll().c_str());
+ }
for (const ConfigKeyVal *ckv = res->err_ckv; ckv;
ckv = ckv->get_next_cfg_key_val()) {
if (ckv->get_key() == NULL) {
UPLL_LOG_TRACE("ConfigMgr failed to process the commit result %d", urc);
tcr = unc::tclib::TC_FAILURE;
}
- // free tx_res_list;
+ // free tx_res_list and also compute final TC result;
for (list<CtrlrTxResult*>::iterator tx_res_it = tx_res_list.begin();
tx_res_it != tx_res_list.end(); tx_res_it++) {
CtrlrTxResult *tx_res = *tx_res_it;
+ UPLL_LOG_TRACE("Driver received error %d from controller %s",
+ tx_res->ctrlr_orig_result, tx_res->ctrlr_id.c_str());
+ // For Vote phase, tcr will be failure if controller result is failure.
+ // For Global-Commit phase, tcr is not dependent on the controller result.
+ if (tcr == unc::tclib::TC_SUCCESS) {
+ if (tx_phase == unc::tclib::TC_COMMIT_VOTE_PHASE) {
+ if ((tx_res->ctrlr_orig_result != DRVAPI_RESPONSE_SUCCESS) &&
+ (tx_res->ctrlr_orig_result !=
+ DRVAPI_RESPONSE_CONTROLLER_DISCONNECTED)) {
+ /* Assumption: If err is DRVAPI_RESPONSE_NOT_SENT_TO_CONTROLLER, then
+ * atleast one controller failed the vote. */
+ tcr = unc::tclib::TC_FAILURE;
+ }
+ } else if (tx_phase == unc::tclib::TC_AUDIT_VOTE_PHASE) {
+ if (tx_res->ctrlr_orig_result != DRVAPI_RESPONSE_SUCCESS) {
+ /* Note: If err is DRVAPI_RESPONSE_CONTROLLER_DISCONNECTED, then
+ * Audit for the controller is incomplete, so tcr is failure. */
+ tcr = unc::tclib::TC_FAILURE;
+ }
+ }
+ }
delete tx_res;
}
tx_res_list.clear();
&affected_ctrlr_list);
if (urc == UPLL_RC_SUCCESS) {
urc = FillTcDriverInfoMap(&driver_info, affected_ctrlr_list, true);
+ if (urc != UPLL_RC_SUCCESS) {
+ pfc_log_fatal("Failed to fill TcDriverInfoMap in AuditGlobalCommit");
+ }
}
+ audit_result = ((urc == UPLL_RC_SUCCESS) ? unc::tclib::TC_AUDIT_SUCCESS :
+ unc::tclib::TC_AUDIT_FAILURE);
return ((urc == UPLL_RC_SUCCESS) ? unc::tclib::TC_SUCCESS :
- unc::tclib::TC_FAILURE);
+ unc::tclib::TC_FAILURE);
}
TcCommonRet TcLibIntfImpl::HandleAuditDriverResult(
uint32_t session_id, std::string controller_id,
TcCommitPhaseType phase, TcCommitPhaseResult driver_result,
TcAuditResult &audit_result) {
- // return unc::tclib::TC_SUCCESS;
- return HandleCommonTxDriverResult(session_id, 0, phase, driver_result);
+ TcCommonRet tcr = HandleCommonTxDriverResult(session_id, 0, phase,
+ driver_result);
+ /* Note: audit_result is applicable only to TC_AUDIT_GLOBAL_COMMIT_PHASE.
+ * For TC_AUDIT_VOTE_PHASE, audit_result will be set to SUCCESS irrespective
+ * of the vote result at UNC / Controler. */
+ audit_result = unc::tclib::TC_AUDIT_SUCCESS;
+ if (phase == unc::tclib::TC_AUDIT_GLOBAL_COMMIT_PHASE) {
+ if (tcr != unc::tclib::TC_SUCCESS) {
+ audit_result = unc::tclib::TC_AUDIT_FAILURE;
+ } else {
+ /* Iterate over each controller status to find audit_result */
+ for (TcCommitPhaseResult::const_iterator ctr_it = driver_result.begin();
+ ctr_it != driver_result.end(); ++ctr_it) {
+ if (ctr_it->resp_code != DRVAPI_RESPONSE_SUCCESS) {
+ /* audit_result is failure even if ctrlr is disconnected or
+ * vote request not sent to controller. */
+ audit_result = unc::tclib::TC_AUDIT_FAILURE;
+ break;
+ }
+ }
+ }
+ }
+ return tcr;
}
TcCommonRet TcLibIntfImpl::HandleAuditGlobalAbort(
*/
TcCommonRet TcLibIntfImpl::HandleAuditConfig(unc_keytype_datatype_t db_target,
TcServiceType fail_oper) {
- if ((!IsActiveNode()) || IsShuttingDown()) {
+ if (IsActiveNode()) {
+ UPLL_LOG_WARN("Node is active, cannot handle Tclib audit config");
+ return unc::tclib::TC_FAILURE;
+ }
+ if (IsShuttingDown()) {
+ UPLL_LOG_WARN("Shutting down, cannot handle Tclib audit config");
return unc::tclib::TC_FAILURE;
}
class TcLibIntfImpl : public unc::tclib::TcLibInterface {
public:
+ static const char * const kUpllCtrlrId;
+
explicit TcLibIntfImpl(UpllConfigMgr *ucm);
virtual ~TcLibIntfImpl();
/* commit related interfaces */
#include "cxx/pfcxx/synch.hh"
#include "unc/component.h"
#include "alarm.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "ctrlr_mgr.hh"
#include "config_mgr.hh"
const std::list<unc_key_type_t> *lst = cktt_.get_preorder_list(); \
for (std::list<unc_key_type_t>::const_iterator it = lst->begin(); \
it != lst->end(); it++) { \
- kt = *it; \
+ const unc_key_type_t kt(*it); \
if (upll_kt_momgrs_.count(kt) > 0) { \
- UPLL_LOG_DEBUG("kt: %u; kt_name: %s", kt, kt_name_map_[kt].c_str());\
+ UPLL_LOG_DEBUG("KT: %u; kt_name: %s", kt, kt_name_map_[kt].c_str());\
MoManager *momgr = upll_kt_momgrs_[kt]; \
urc = momgr->func(kt, __VA_ARGS__); \
if (urc != UPLL_RC_SUCCESS) { \
- UPLL_LOG_WARN("Error = %d, kt: %s", urc, kt_name_map_[kt].c_str());\
+ UPLL_LOG_WARN("Error = %d, KT: %s", urc, kt_name_map_[kt].c_str());\
break; \
} \
} \
const std::list<unc_key_type_t> *lst = cktt_.get_reverse_postorder_list();\
for (std::list<unc_key_type_t>::const_iterator it = lst->begin(); \
it != lst->end(); it++) { \
- kt = *it; \
+ const unc_key_type_t kt(*it); \
if (upll_kt_momgrs_.count(kt) > 0) { \
- UPLL_LOG_DEBUG("kt: %u; kt_name: %s", kt, kt_name_map_[kt].c_str());\
+ UPLL_LOG_DEBUG("KT: %u; kt_name: %s", kt, kt_name_map_[kt].c_str());\
MoManager *momgr = upll_kt_momgrs_[kt]; \
urc = momgr->func(kt, __VA_ARGS__); \
if (urc != UPLL_RC_SUCCESS) { \
- UPLL_LOG_INFO("Error = %d, kt: %s", urc, kt_name_map_[kt].c_str());\
+ UPLL_LOG_INFO("Error = %d, KT: %s", urc, kt_name_map_[kt].c_str());\
break; \
} \
} \
ConfigKeyVal **err_ckv) {
UPLL_FUNC_TRACE;
upll_rc_t urc = UPLL_RC_ERR_GENERIC;
- unc_key_type_t kt;
commit_mutex_lock_.lock();
if (commit_in_progress_ == true) {
UPLL_DT_CANDIDATE, ConfigLock::CFG_WRITE_LOCK,
UPLL_DT_RUNNING, ConfigLock::CFG_READ_LOCK);
- DalOdbcMgr dbinst;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dbinst, true, __FUNCTION__))) {
- // pfc_log_fatal("DalOpen failed");
- return urc;
- }
+ DalOdbcMgr *dbinst = &config_rw_dom_;
CALL_MOMGRS_REVERSE_ORDER(TxUpdateController, session_id, config_id,
- kUpllUcpDelete, &affected_ctrlr_set_, &dbinst,
+ kUpllUcpDelete, &affected_ctrlr_set_, dbinst,
err_ckv);
if (urc != UPLL_RC_SUCCESS) {
- DalClose(&dbinst, false, __FUNCTION__);
+ DalClose(dbinst, false, __FUNCTION__);
return urc;
}
CALL_MOMGRS_PREORDER(TxUpdateController, session_id, config_id,
- kUpllUcpCreate, &affected_ctrlr_set_, &dbinst, err_ckv);
+ kUpllUcpCreate, &affected_ctrlr_set_, dbinst, err_ckv);
if (urc != UPLL_RC_SUCCESS) {
- DalClose(&dbinst, false, __FUNCTION__);
+ DalClose(dbinst, false, __FUNCTION__);
return urc;
}
CALL_MOMGRS_PREORDER(TxUpdateController, session_id, config_id,
- kUpllUcpUpdate, &affected_ctrlr_set_, &dbinst, err_ckv);
+ kUpllUcpUpdate, &affected_ctrlr_set_, dbinst, err_ckv);
if (urc != UPLL_RC_SUCCESS) {
- DalClose(&dbinst, false, __FUNCTION__);
+ DalClose(dbinst, false, __FUNCTION__);
return urc;
}
UNC_KT_FLOWLIST
};
for (unsigned int i = 0; i < sizeof(phase2_kts)/sizeof(phase2_kts[0]); i++) {
- if (upll_kt_momgrs_.count(kt) > 0) {
- UPLL_LOG_DEBUG("kt: %u; kt_name: %s", kt, kt_name_map_[phase2_kts[i]].c_str());
- MoManager *momgr = upll_kt_momgrs_[phase2_kts[i]];
+ const unc_key_type_t phase2_kt(phase2_kts[i]);
+ if (upll_kt_momgrs_.count(phase2_kt) > 0) {
+ UPLL_LOG_DEBUG("KT: %u; kt_name: %s",
+ phase2_kt, kt_name_map_[phase2_kt].c_str());
+ MoManager *momgr = upll_kt_momgrs_[phase2_kt];
if (momgr == NULL)
continue;
- urc = momgr->TxUpdateController(phase2_kts[i], session_id, config_id,
- kUpllUcpDelete2, &affected_ctrlr_set_, &dbinst,
- err_ckv);
+ urc = momgr->TxUpdateController(phase2_kt, session_id, config_id,
+ kUpllUcpDelete2, &affected_ctrlr_set_, dbinst,
+ err_ckv);
if (urc != UPLL_RC_SUCCESS) {
- UPLL_LOG_WARN("Error = %d, kt: %s", urc, kt_name_map_[phase2_kts[i]].c_str());
+ UPLL_LOG_WARN("Error = %d, KT: %s",
+ urc, kt_name_map_[phase2_kt].c_str());
break;
}
}
}
- upll_rc_t db_urc = DalClose(&dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+ upll_rc_t db_urc = DalClose(dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
if (urc == UPLL_RC_SUCCESS) {
urc = db_urc;
}
uint32_t config_id) {
UPLL_FUNC_TRACE;
upll_rc_t urc = UPLL_RC_ERR_GENERIC;
- unc_key_type_t kt;
if (UPLL_RC_SUCCESS != (urc = ValidateAudit(__FUNCTION__, ctrlr_id))) {
return urc;
UPLL_DT_AUDIT, ConfigLock::CFG_READ_LOCK,
UPLL_DT_RUNNING, ConfigLock::CFG_READ_LOCK);
- DalOdbcMgr dbinst;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dbinst, true, __FUNCTION__))) {
- // pfc_log_fatal("DalOpen failed");
- return urc;
- }
+ DalOdbcMgr *dbinst = &config_rw_dom_;
affected_ctrlr_set_.clear();
bool ctrlr_affected = false;
CALL_MOMGRS_REVERSE_ORDER(AuditUpdateController, ctrlr_id, session_id,
config_id, kUpllUcpDelete, &ctrlr_affected,
- &dbinst);
+ dbinst);
if (urc != UPLL_RC_SUCCESS) {
- DalClose(&dbinst, false, __FUNCTION__);
+ DalClose(dbinst, false, __FUNCTION__);
return urc;
}
CALL_MOMGRS_PREORDER(AuditUpdateController, ctrlr_id, session_id, config_id,
- kUpllUcpCreate, &ctrlr_affected, &dbinst);
+ kUpllUcpCreate, &ctrlr_affected, dbinst);
if (urc != UPLL_RC_SUCCESS) {
- DalClose(&dbinst, false, __FUNCTION__);
+ DalClose(dbinst, false, __FUNCTION__);
return urc;
}
CALL_MOMGRS_PREORDER(AuditUpdateController, ctrlr_id, session_id, config_id,
- kUpllUcpUpdate, &ctrlr_affected, &dbinst);
+ kUpllUcpUpdate, &ctrlr_affected, dbinst);
if (urc != UPLL_RC_SUCCESS) {
- DalClose(&dbinst, false, __FUNCTION__);
+ DalClose(dbinst, false, __FUNCTION__);
return urc;
}
UNC_KT_FLOWLIST
};
for (unsigned int i = 0; i < sizeof(phase2_kts)/sizeof(phase2_kts[0]); i++) {
- if (upll_kt_momgrs_.count(kt) > 0) {
- UPLL_LOG_DEBUG("kt: %u; kt_name: %s", kt,
- kt_name_map_[phase2_kts[i]].c_str());
- MoManager *momgr = upll_kt_momgrs_[phase2_kts[i]];
- if (momgr == NULL)
- continue;
- urc = momgr->AuditUpdateController(phase2_kts[i], ctrlr_id, session_id,
- config_id, kUpllUcpDelete2,
- &ctrlr_affected, &dbinst);
- if (urc != UPLL_RC_SUCCESS) {
- UPLL_LOG_WARN("Error = %d, kt: %s", urc,
- kt_name_map_[phase2_kts[i]].c_str());
- break;
+ const unc_key_type_t phase2_kt(phase2_kts[i]);
+ if (upll_kt_momgrs_.count(phase2_kt) > 0) {
+ UPLL_LOG_DEBUG("KT: %u; kt_name: %s", phase2_kt,
+ kt_name_map_[phase2_kt].c_str());
+ MoManager *momgr = upll_kt_momgrs_[phase2_kt];
+ if (momgr == NULL)
+ continue;
+ urc = momgr->AuditUpdateController(phase2_kt, ctrlr_id, session_id,
+ config_id, kUpllUcpDelete2,
+ &ctrlr_affected, dbinst);
+ if (urc != UPLL_RC_SUCCESS) {
+ UPLL_LOG_WARN("Error = %d, KT: %s", urc,
+ kt_name_map_[phase2_kt].c_str());
+ break;
+ }
}
- }
}
- upll_rc_t db_urc = DalClose(&dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+ upll_rc_t db_urc = DalClose(dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
if (urc == UPLL_RC_SUCCESS) {
urc = db_urc;
}
const std::set<std::string> **affected_ctrlr_set, ConfigKeyVal **err_ckv) {
UPLL_FUNC_TRACE;
upll_rc_t urc = UPLL_RC_ERR_GENERIC;
- unc_key_type_t kt;
if (UPLL_RC_SUCCESS != (urc = ValidateCommit(__FUNCTION__))) {
return urc;
UPLL_DT_CANDIDATE, ConfigLock::CFG_READ_LOCK,
UPLL_DT_RUNNING, ConfigLock::CFG_READ_LOCK);
- DalOdbcMgr dbinst;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dbinst, false, __FUNCTION__))) {
- // pfc_log_fatal("DalOpen failed");
- return urc;
- }
+ DalOdbcMgr *dbinst = &config_rw_dom_;
- CALL_MOMGRS_PREORDER(TxVote, &dbinst, err_ckv);
+ CALL_MOMGRS_PREORDER(TxVote, dbinst, err_ckv);
- upll_rc_t db_urc = DalClose(&dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+ upll_rc_t db_urc = DalClose(dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
if (urc == UPLL_RC_SUCCESS) {
urc = db_urc;
}
list<CtrlrVoteStatus*> *ctrlr_vote_status) {
UPLL_FUNC_TRACE;
upll_rc_t urc = UPLL_RC_ERR_GENERIC;
- unc_key_type_t kt;
if (UPLL_RC_SUCCESS != (urc = ValidateCommit(__FUNCTION__))) {
return urc;
UPLL_DT_CANDIDATE, ConfigLock::CFG_READ_LOCK,
UPLL_DT_RUNNING, ConfigLock::CFG_READ_LOCK);
- DalOdbcMgr dbinst;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dbinst, false, __FUNCTION__))) {
- // pfc_log_fatal("DalOpen failed");
- return urc;
- }
+ DalOdbcMgr *dbinst = &config_rw_dom_;
- CALL_MOMGRS_PREORDER(TxVoteCtrlrStatus, ctrlr_vote_status, &dbinst);
+ CALL_MOMGRS_PREORDER(TxVoteCtrlrStatus, ctrlr_vote_status, dbinst);
- upll_rc_t db_urc = DalClose(&dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+ upll_rc_t db_urc = DalClose(dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
if (urc == UPLL_RC_SUCCESS) {
urc = db_urc;
}
CtrlrVoteStatus *ctrlr_vote_status) {
UPLL_FUNC_TRACE;
upll_rc_t urc = UPLL_RC_ERR_GENERIC;
- unc_key_type_t kt;
if (UPLL_RC_SUCCESS != (urc = ValidateAudit(
__FUNCTION__, ctrlr_vote_status->ctrlr_id.c_str()))) {
UPLL_DT_AUDIT, ConfigLock::CFG_READ_LOCK,
UPLL_DT_RUNNING, ConfigLock::CFG_WRITE_LOCK);
- DalOdbcMgr dbinst;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dbinst, true, __FUNCTION__))) {
- // pfc_log_fatal("DalOpen failed");
- return urc;
- }
+ DalOdbcMgr *dbinst = &config_rw_dom_;
- CALL_MOMGRS_PREORDER(AuditVoteCtrlrStatus, ctrlr_vote_status, &dbinst);
+ CALL_MOMGRS_PREORDER(AuditVoteCtrlrStatus, ctrlr_vote_status, dbinst);
upll_rc_t db_urc;
- if (UPLL_RC_SUCCESS != (db_urc = DalClose(&dbinst, (urc == UPLL_RC_SUCCESS),
+ if (UPLL_RC_SUCCESS != (db_urc = DalClose(dbinst, (urc == UPLL_RC_SUCCESS),
__FUNCTION__))) {
return ((urc != UPLL_RC_SUCCESS) ? urc : db_urc);
}
list<CtrlrCommitStatus*> *ctrlr_commit_status) {
UPLL_FUNC_TRACE;
upll_rc_t urc = UPLL_RC_ERR_GENERIC;
- unc_key_type_t kt;
using unc::upll::ipc_util::ConfigNotifier;
- if (UPLL_RC_SUCCESS != (urc = ValidateCommit(__FUNCTION__))) {
- return urc;
+ // During normal transaction ctrlr_commit_status will not be NULL.
+ // For TcLibInterface::HandleAuditConfig, if TcServiceType is
+ // TC_OP_CANDIDATE_COMMIT, then ctrlr_commit_status is NULL
+ if (ctrlr_commit_status != NULL) {
+ if (UPLL_RC_SUCCESS != (urc = ValidateCommit(__FUNCTION__))) {
+ return urc;
+ }
}
ScopedConfigLock scfg_lock(cfg_lock_,
UPLL_DT_RUNNING, ConfigLock::CFG_WRITE_LOCK);
// TODO(a): Why do we need write lock on CANDIDATE?
- DalOdbcMgr dbinst;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dbinst, true, __FUNCTION__))) {
- pfc_log_fatal("DalOpen failed");
- return urc;
- }
+ DalOdbcMgr *dbinst = &config_rw_dom_;
- CALL_MOMGRS_PREORDER(TxCopyCandidateToRunning, ctrlr_commit_status, &dbinst);
+ CALL_MOMGRS_PREORDER(TxCopyCandidateToRunning, ctrlr_commit_status, dbinst);
if (urc == UPLL_RC_SUCCESS) {
- unc_key_type_t state_kts[] = { UNC_KT_VBR_IF, UNC_KT_VRT_IF,
- UNC_KT_VLINK,
+ unc_key_type_t state_kts[] = { UNC_KT_VLINK, UNC_KT_VBR_IF,
+ UNC_KT_VRT_IF,
UNC_KT_VBRIDGE, UNC_KT_VROUTER,
UNC_KT_VTN };
for (unsigned int i = 0; i < sizeof(state_kts)/sizeof(state_kts[0]); i++) {
if (momgr == NULL)
continue;
urc = momgr->TxUpdateDtState(state_kts[i], session_id, config_id,
- &dbinst);
+ dbinst);
if (urc != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Failed to update status for KT %d", state_kts[i]);
break;
}
}
- upll_rc_t db_urc = DalClose(&dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+ upll_rc_t db_urc = DalClose(dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
if (urc == UPLL_RC_SUCCESS) {
urc = db_urc;
}
CtrlrCommitStatus * ctrlr_commit_status) {
UPLL_FUNC_TRACE;
upll_rc_t urc = UPLL_RC_ERR_GENERIC;
- unc_key_type_t kt;
if (UPLL_RC_SUCCESS != (urc = ValidateAudit(
__FUNCTION__, ctrlr_commit_status->ctrlr_id.c_str()))) {
UPLL_DT_AUDIT, ConfigLock::CFG_READ_LOCK,
UPLL_DT_RUNNING, ConfigLock::CFG_WRITE_LOCK);
- DalOdbcMgr dbinst;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dbinst, true, __FUNCTION__))) {
- pfc_log_fatal("DalOpen failed");
- return urc;
- }
+ DalOdbcMgr *dbinst = &config_rw_dom_;
- CALL_MOMGRS_PREORDER(AuditCommitCtrlrStatus, ctrlr_commit_status, &dbinst);
+ CALL_MOMGRS_PREORDER(AuditCommitCtrlrStatus, ctrlr_commit_status, dbinst);
upll_rc_t db_urc;
- if (UPLL_RC_SUCCESS != (db_urc = DalClose(&dbinst, (urc == UPLL_RC_SUCCESS),
+ if (UPLL_RC_SUCCESS != (db_urc = DalClose(dbinst, (urc == UPLL_RC_SUCCESS),
__FUNCTION__))) {
return ((urc != UPLL_RC_SUCCESS) ? urc : db_urc);
}
upll_rc_t UpllConfigMgr::OnTxEnd() {
UPLL_FUNC_TRACE;
upll_rc_t urc = UPLL_RC_ERR_GENERIC;
- unc_key_type_t kt;
if (UPLL_RC_SUCCESS != (urc = ValidateCommit(__FUNCTION__))) {
return urc;
UPLL_DT_CANDIDATE, ConfigLock::CFG_WRITE_LOCK,
UPLL_DT_RUNNING, ConfigLock::CFG_WRITE_LOCK);
- DalOdbcMgr dbinst;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dbinst, true, __FUNCTION__))) {
- pfc_log_fatal("DalOpen failed");
- return urc;
- }
+ DalOdbcMgr *dbinst = &config_rw_dom_;
- CALL_MOMGRS_PREORDER(TxEnd, &dbinst);
+ CALL_MOMGRS_PREORDER(TxEnd, dbinst);
- upll_rc_t db_urc = DalClose(&dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+ upll_rc_t db_urc = DalClose(dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
if (urc == UPLL_RC_SUCCESS) {
urc = db_urc;
}
commit_in_progress_ = false;
commit_mutex_lock_.unlock();
+ affected_ctrlr_set_.clear();
+
if (urc != UPLL_RC_SUCCESS) {
pfc_log_fatal("TxEnd failed. Urc=%d", urc);
}
upll_rc_t UpllConfigMgr::OnAuditEnd(const char *ctrlr_id, bool sby2act_trans) {
UPLL_FUNC_TRACE;
upll_rc_t urc = UPLL_RC_ERR_GENERIC;
- unc_key_type_t kt;
if (!sby2act_trans) {
if (UPLL_RC_SUCCESS != (urc = ValidateAudit(__FUNCTION__, ctrlr_id))) {
ScopedConfigLock scfg_lock(cfg_lock_,
UPLL_DT_AUDIT, ConfigLock::CFG_WRITE_LOCK);
- DalOdbcMgr dbinst;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dbinst, true, __FUNCTION__))) {
- pfc_log_fatal("DalOpen failed");
- return urc;
- }
+ DalOdbcMgr *dbinst = &config_rw_dom_;
- CALL_MOMGRS_PREORDER(AuditEnd, ctrlr_id, &dbinst);
+ CALL_MOMGRS_PREORDER(AuditEnd, ctrlr_id, dbinst);
if (urc != UPLL_RC_SUCCESS) {
pfc_log_fatal("AuditEnd failed. Error:%d", urc);
}
- upll_rc_t db_urc = DalClose(&dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+ upll_rc_t db_urc = DalClose(dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
if (urc == UPLL_RC_SUCCESS) {
urc = db_urc;
}
audit_ctrlr_id_ = "";
audit_mutex_lock_.unlock();
+ affected_ctrlr_set_.clear();
+
if (urc != UPLL_RC_SUCCESS) {
pfc_log_fatal("AuditEnd failed. Urc=%d", urc);
}
}
upll_rc_t urc = UPLL_RC_ERR_GENERIC;
- unc_key_type_t kt;
ScopedConfigLock scfg_lock(cfg_lock_,
UPLL_DT_STARTUP, ConfigLock::CFG_READ_LOCK,
UPLL_DT_CANDIDATE, ConfigLock::CFG_WRITE_LOCK,
UPLL_DT_IMPORT, ConfigLock::CFG_WRITE_LOCK,
UPLL_DT_AUDIT, ConfigLock::CFG_WRITE_LOCK);
- DalOdbcMgr dbinst;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dbinst, true, __FUNCTION__))) {
- pfc_log_fatal("DalOpen failed");
- return urc;
- }
+ DalOdbcMgr *dbinst = &config_rw_dom_;
- CALL_MOMGRS_PREORDER(LoadStartup, &dbinst);
+ CALL_MOMGRS_PREORDER(LoadStartup, dbinst);
// Audit and Import tables have been already cleared as part of transitioning
// to ACTIVE
- upll_rc_t db_urc = DalClose(&dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+ upll_rc_t db_urc = DalClose(dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
if (urc == UPLL_RC_SUCCESS) {
urc = db_urc;
}
}
upll_rc_t urc = UPLL_RC_ERR_GENERIC;
- unc_key_type_t kt;
ScopedConfigLock scfg_lock(cfg_lock_,
UPLL_DT_STARTUP, ConfigLock::CFG_WRITE_LOCK,
UPLL_DT_RUNNING, ConfigLock::CFG_READ_LOCK);
- DalOdbcMgr dbinst;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dbinst, true, __FUNCTION__))) {
- pfc_log_fatal("DalOpen failed");
- return urc;
- }
+ DalOdbcMgr *dbinst = &config_rw_dom_;
- CALL_MOMGRS_PREORDER(CopyRunningToStartup, &dbinst);
+ CALL_MOMGRS_PREORDER(CopyRunningToStartup, dbinst);
- upll_rc_t db_urc = DalClose(&dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+ upll_rc_t db_urc = DalClose(dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
if (urc == UPLL_RC_SUCCESS) {
urc = db_urc;
}
}
upll_rc_t urc = UPLL_RC_ERR_GENERIC;
- unc_key_type_t kt;
ScopedConfigLock scfg_lock(cfg_lock_,
UPLL_DT_CANDIDATE, ConfigLock::CFG_WRITE_LOCK,
UPLL_DT_RUNNING, ConfigLock::CFG_READ_LOCK);
- DalOdbcMgr dbinst;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dbinst, true, __FUNCTION__))) {
- pfc_log_fatal("DalOpen failed");
- return urc;
- }
+ DalOdbcMgr *dbinst = &config_rw_dom_;
- CALL_MOMGRS_PREORDER(CopyRunningToCandidate, &dbinst);
+ CALL_MOMGRS_PREORDER(CopyRunningToCandidate, dbinst);
- upll_rc_t db_urc = DalClose(&dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+ upll_rc_t db_urc = DalClose(dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
if (urc == UPLL_RC_SUCCESS) {
urc = db_urc;
}
}
upll_rc_t urc = UPLL_RC_ERR_GENERIC;
- unc_key_type_t kt;
ScopedConfigLock scfg_lock(cfg_lock_,
UPLL_DT_STARTUP, ConfigLock::CFG_WRITE_LOCK);
- DalOdbcMgr dbinst;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dbinst, true, __FUNCTION__))) {
- pfc_log_fatal("DalOpen failed");
- return urc;
- }
+ DalOdbcMgr *dbinst = &config_rw_dom_;
- CALL_MOMGRS_PREORDER(ClearStartup, &dbinst);
+ CALL_MOMGRS_PREORDER(ClearStartup, dbinst);
- upll_rc_t db_urc = DalClose(&dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+ upll_rc_t db_urc = DalClose(dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
if (urc == UPLL_RC_SUCCESS) {
urc = db_urc;
}
bool sby2act_trans) {
UPLL_FUNC_TRACE;
upll_rc_t urc = UPLL_RC_ERR_GENERIC;
- unc_key_type_t kt;
+
+ pfc::core::ScopedMutex lock(import_mutex_lock_);
if (!sby2act_trans) {
- if (UPLL_RC_SUCCESS != (urc = ValidateImport(session_id, config_id,
- __FUNCTION__))) {
+ if (import_in_progress_ == false) {
+ UPLL_LOG_INFO("Import is not in progress. Clear cannot be done");
+ return UPLL_RC_ERR_NOT_ALLOWED_AT_THIS_TIME;
+ }
+ if (UPLL_RC_SUCCESS != (urc = ValidateImport(
+ session_id, config_id, import_ctrlr_id_.c_str(),
+ UPLL_CLEAR_IMPORT_CONFIG_OP))) {
return urc;
}
}
ScopedConfigLock scfg_lock(cfg_lock_,
UPLL_DT_IMPORT, ConfigLock::CFG_WRITE_LOCK);
- DalOdbcMgr dbinst;
- if (UPLL_RC_SUCCESS != (urc = DalOpen(&dbinst, true, __FUNCTION__))) {
- // pfc_log_fatal("DalOpen failed");
- return urc;
- }
+ DalOdbcMgr *dbinst = &import_rw_dom_;
- CALL_MOMGRS_PREORDER(ImportClear, import_ctrlr_id_.c_str(), &dbinst);
+ CALL_MOMGRS_PREORDER(ImportClear, import_ctrlr_id_.c_str(), dbinst);
- upll_rc_t db_urc = DalClose(&dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
+ upll_rc_t db_urc = DalClose(dbinst, (urc == UPLL_RC_SUCCESS), __FUNCTION__);
if (urc == UPLL_RC_SUCCESS) {
urc = db_urc;
}
- import_mutex_lock_.lock();
import_in_progress_ = false;
import_ctrlr_id_ = "";
- import_mutex_lock_.unlock();
return urc;
}
# distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
#
+clstat
dal
tclib
capa
alarm
-clstat
const uint16_t kMinVlanId = 1;
const uint16_t kMaxVlanId = 4095;
+const uint8_t kMinIpRoutePrefix = 0;
+const uint8_t kMaxIpRoutePrefix = 32;
+
+const uint8_t kMinVnodeIpv4Prefix = 1;
+const uint8_t kMaxVnodeIpv4Prefix = 30;
+
const uint8_t kMinIpv4Prefix = 1;
const uint8_t kMaxIpv4Prefix = 32;
const uint8_t kMaxIpv6Prefix = 128;
const uint16_t kMinPingPacketLen = 1;
-const uint16_t kMaxPingPacketLen = 65468;
+const uint16_t kMaxPingPacketLen = 65467;
const uint32_t kMinPingCount = 1;
const uint32_t kMaxPingCount = 655350;
const uint32_t kMinRateType = 0;
const uint32_t kMaxRateType = 4294967295u;
-const uint32_t kMinBurstSize = 1;
+const uint32_t kMinBurstSize = 0;
const uint32_t kMaxBurstSize = 4294967295u;
const uint8_t kMinPrecedence = 1;
}
// wrapper function for validating default strings
-inline upll_rc_t ValidateDefaultStr(char *str, unsigned int min, unsigned int max) {
+inline bool ValidateDefaultStr(uint8_t *str,
+ unsigned int min,
+ unsigned int max) {
if (NULL == str) {
UPLL_LOG_DEBUG(" Input string is NULL ");
- return UPLL_RC_ERR_GENERIC;
- } else if (!ValidateStringRange(str, min, max)) {
- UPLL_LOG_DEBUG(" Invalid string length %d", (unsigned int) strlen(str));
- return UPLL_RC_ERR_CFG_SYNTAX;
+ return false;
+ } else if (!ValidateStringRange(reinterpret_cast<char *>(str), min, max)) {
+ UPLL_LOG_DEBUG(" Invalid string length %d",
+ (unsigned int) strlen(reinterpret_cast<char *>(str)));
+ return false;
} else if ((str[0] == '(') &&
- (0 == strncmp(str, kDefaultDomainId, strlen(kDefaultDomainId)))) {
- return UPLL_RC_SUCCESS;
- } else if (!ValidateStrId(str)) {
- UPLL_LOG_DEBUG(" Invalid string format %s", str);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ (0 == strncmp(reinterpret_cast<char *>(str),
+ kDefaultDomainId, strlen(kDefaultDomainId)))) {
+ return true;
+ } else if (!ValidateStrId(reinterpret_cast<char *>(str))) {
+ UPLL_LOG_DEBUG("Invalid string format %s", str);
+ return false;
}
- return UPLL_RC_SUCCESS;
+ return true;
}
// wrapper function for validating key strings
return UPLL_RC_SUCCESS;
}
+inline bool ValidateString(uint8_t *str, unsigned int min, unsigned int max) {
+ upll_rc_t result_code = ValidateKey(reinterpret_cast<char *>(str), min, max);
+ if (result_code != UPLL_RC_SUCCESS) {
+ return false;
+ }
+ return true;
+}
+
+
// wrapper function for validating description strings
-inline upll_rc_t ValidateDesc(char *str, unsigned int min, unsigned int max) {
+inline bool ValidateDesc(uint8_t *str, unsigned int min, unsigned int max) {
bool ret_val = false;
if (NULL == str) {
UPLL_LOG_DEBUG("Input string is NULL ");
- return UPLL_RC_ERR_GENERIC;
+ return false;
}
- if (!(ret_val = ValidateStringRange(str, min, max))) {
- UPLL_LOG_DEBUG("Invalid string length %d", (unsigned int) strlen(str));
+ if (!(ret_val = ValidateStringRange(reinterpret_cast<char *>(str),
+ min, max))) {
+ UPLL_LOG_DEBUG("Invalid string length %d",
+ (unsigned int) strlen(reinterpret_cast<char *>(str)));
} else {
- if (!(ret_val = ValidateStrPrint(str))) {
+ if (!(ret_val = ValidateStrPrint(reinterpret_cast<char *>(str)))) {
UPLL_LOG_DEBUG("Invalid string format %s", str);
}
}
if (!ret_val) {
- return UPLL_RC_ERR_CFG_SYNTAX;
+ return ret_val;
}
- return UPLL_RC_SUCCESS;
+ return true;
}
// wrapper function for validating logical port id
-inline upll_rc_t ValidateLogicalPortId(char *str, unsigned int min,
+inline bool ValidateLogicalPortId(char *str, unsigned int min,
unsigned int max) {
UPLL_LOG_DEBUG("Inside ValidateLogicalPortId");
if (NULL == str) {
UPLL_LOG_DEBUG(" Input string is NULL ");
- return UPLL_RC_ERR_GENERIC;
+ return false;
}
UPLL_LOG_DEBUG("Input string expected min (%d) max (%d)", min, max);
UPLL_LOG_DEBUG("String length %d", (unsigned int) strlen(str));
if (!(ValidateStringRange(str, min, max))) {
UPLL_LOG_DEBUG("Invalid string length %d", (unsigned int) strlen(str));
- return UPLL_RC_ERR_CFG_SYNTAX;
+ return false;
}
/*
str++;
}
*/
- return UPLL_RC_SUCCESS;
+ return true;
}
inline bool ValidateMacAddr(uint8_t *mac_addr) {
}
}
-inline upll_rc_t ValidateIpv4Addr(uint32_t host_addr, uint8_t prefix_len) {
+inline bool ValidateIpv4Addr(uint32_t host_addr, uint8_t prefix_len) {
int32_t i;
uint32_t mask = 0;
if (!chk_ip_mask(ip_mask)) {
UPLL_LOG_DEBUG(" Invalid Input subnet mask - 0x%08X", ip_mask);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ return false;
}
if (!chk_ip_mask_allow(ip_mask)) {
UPLL_LOG_DEBUG(" Invalid Input subnet mask - 0x%08X", ip_mask);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ return false;
}
if (host_addr == 0xffffffff || host_addr == 0x00000000) {
UPLL_LOG_DEBUG(" Invalid Input host address - 0x%08X", host_addr);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ return false;
}
if (!chk_ip_address_muticast(host_addr)) {
UPLL_LOG_DEBUG(" Invalid Input host address - 0x%08X", host_addr);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ return false;
}
if (!chk_ip_host_id(host_addr, ip_mask)) {
UPLL_LOG_DEBUG(" Invalid Input host id - 0x%08X", host_addr);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ return false;
}
- return UPLL_RC_SUCCESS;
+ return true;
}
inline bool bc_check(const uint32_t &ip_adr) {
}
}
-inline void StringReset(uint8_t *key){
+inline void StringReset(uint8_t *key) {
PFC_ASSERT(key != NULL);
key[0] = '\0';
}
#include "flowlist_entry_momgr.hh"
#include "vbr_momgr.hh"
#include "upll_validation.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
using unc::upll::ipc_util::IpcUtil;
namespace unc {
namespace upll {
namespace kt_momgr {
-#define NUM_KEY_MAIN_TBL 6
-#define NUM_KEY_RENAME_MAIN_TBL 5
#define VTN_RENAME_FLAG 0x01
-#define VBR_RENAME_FLAG 0x10
+#define VBR_RENAME_FLAG 0x02
+#define NO_VBR_RENAME_FLAG ~VBR_RENAME_FLAG
#define FLOWLIST_RENAME_FLAG 0x04
+#define FLOW_RENAME 0x04
+#define NO_FLOWLIST_RENAME ~FLOWLIST_RENAME_FLAG
// VbrFlowFilterEntry Table(Main Table)
BindInfo VbrFlowFilterEntryMoMgr::vbr_flowfilterentry_bind_info[] = {
{ uudst::vbr_flowfilter_entry::kDbiVtnName, CFG_KEY,
{ uudst::vbr_flowfilter_entry::kDbiVbrName, CFG_MATCH_KEY, offsetof(
key_vbr_flowfilter_entry_t, flowfilter_key.vbr_key.vbridge_name),
uud::kDalChar, kMaxLenVnodeName + 1 },
- { uudst::vbr_flowfilter_entry::kDbiInputDirection, CFG_MATCH_KEY,
- offsetof(key_vbr_flowfilter_entry_t, flowfilter_key.direction),
- uud::kDalUint8, 1 },
- { uudst::vbr_flowfilter_entry::kDbiSequenceNum, CFG_MATCH_KEY,
- offsetof(key_vbr_flowfilter_entry_t, sequence_num),
- uud::kDalUint16, 1 },
{ uudst::vbr_flowfilter_entry::kDbiVtnName, CFG_INPUT_KEY, offsetof(
key_rename_vnode_info_t, new_unc_vtn_name),
uud::kDalChar, kMaxLenVtnName + 1 },
{ uudst::vbr_flowfilter_entry::kDbiVbrName, CFG_INPUT_KEY, offsetof(
key_rename_vnode_info_t, new_unc_vnode_name),
uud::kDalChar, kMaxLenVnodeName + 1 },
- { uudst::vbr_flowfilter_entry::kDbiFlags, CFG_INPUT_KEY, offsetof(
- key_user_data_t, flags),
- uud::kDalUint8, 1 }
-};
-
-
-BindInfo VbrFlowFilterEntryMoMgr::vbr_flowlist_rename_bind_info[] = {
- { uudst::vbr_flowfilter_entry::kDbiVtnName, CFG_MATCH_KEY, offsetof(
- key_vbr_flowfilter_entry_t, flowfilter_key.vbr_key.vtn_key.vtn_name),
- uud::kDalChar, kMaxLenVtnName + 1 },
- { uudst::vbr_flowfilter_entry::kDbiVbrName, CFG_MATCH_KEY, offsetof(
- key_vbr_flowfilter_entry_t, flowfilter_key.vbr_key.vbridge_name),
- uud::kDalChar, kMaxLenVnodeName + 1 },
- { uudst::vbr_flowfilter_entry::kDbiInputDirection, CFG_MATCH_KEY,
- offsetof(key_vbr_flowfilter_entry_t, flowfilter_key.direction),
- uud::kDalUint8, 1 },
- { uudst::vbr_flowfilter_entry::kDbiSequenceNum, CFG_MATCH_KEY, offsetof(
- key_vbr_flowfilter_entry_t, sequence_num),
- uud::kDalUint16, 1 },
- { uudst::vbr_flowfilter_entry::kDbiFlowlistName, CFG_INPUT_KEY, offsetof(
- key_rename_vnode_info_t, new_flowlist_name),
- uud::kDalChar, kMaxLenFlowListName + 1 },
- { uudst::vbr_flowfilter_entry::kDbiFlags, CFG_INPUT_KEY, offsetof(
+ { uudst::vbr_flowfilter_entry::kDbiFlags, CK_VAL, offsetof(
key_user_data_t, flags),
uud::kDalUint8, 1 }
};
UPLL_FUNC_TRACE;
// Rename and ctrlr tables not required for this KT
// setting max tables toto 1
+ cur_instance_count = 0;
ntable = (MAX_MOMGR_TBLS);
table = new Table *[ntable];
int &nattr,
MoMgrTables tbl ) {
UPLL_FUNC_TRACE;
- if (UNC_KT_VBR_FLOWFILTER_ENTRY == key_type) {
+
/* Main Table only update */
- if (MAINTBL == tbl) {
- nattr = NUM_KEY_MAIN_TBL;
- binfo = vbr_flowfilter_entry_maintbl_bind_info;
- } else {
- return PFC_FALSE;
- }
- }
- /* Check for Flowlist Rename*/
- if (UNC_KT_FLOWLIST == key_type) {
- nattr = NUM_KEY_RENAME_MAIN_TBL;
- binfo = vbr_flowlist_rename_bind_info;
- }
+ nattr = sizeof(vbr_flowfilter_entry_maintbl_bind_info)/
+ sizeof(vbr_flowfilter_entry_maintbl_bind_info[0]);
+ binfo = vbr_flowfilter_entry_maintbl_bind_info;
UPLL_LOG_DEBUG("Successful Completeion");
return PFC_TRUE;
bool VbrFlowFilterEntryMoMgr::IsValidKey(void *key, uint64_t index) {
UPLL_FUNC_TRACE;
- bool ret_val = UPLL_RC_SUCCESS;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
key_vbr_flowfilter_entry_t *ff_key =
reinterpret_cast<key_vbr_flowfilter_entry_t *>(key);
if (ff_key == NULL)
}
break;
case uudst::vbr_flowfilter_entry::kDbiInputDirection:
- if (!ValidateNumericRange(ff_key->flowfilter_key.direction,
+ if (ff_key->flowfilter_key.direction == 0xFE) {
+ // if operation is read sibling begin or
+ // read sibling count return false
+ // for output binding
+ ff_key->flowfilter_key.direction = 0;
+ return false;
+ } else if (!ValidateNumericRange(ff_key->flowfilter_key.direction,
(uint8_t) UPLL_FLOWFILTER_DIR_IN,
(uint8_t) UPLL_FLOWFILTER_DIR_OUT,
true, true)) {
UPLL_LOG_DEBUG(" Error: option1 is not NORMAL for ReadSiblingCount");
return UPLL_RC_ERR_INVALID_OPTION1;
}
-
+ if ((req->option1 == UNC_OPT1_DETAIL) &&
+ (req->datatype != UPLL_DT_STATE)) {
+ UPLL_LOG_DEBUG(" Invalid Datatype(%d)", req->datatype);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+ if ((req->datatype == UPLL_DT_IMPORT) && (req->operation == UNC_OP_READ ||
+ req->operation == UNC_OP_READ_SIBLING ||
+ req->operation == UNC_OP_READ_SIBLING_BEGIN ||
+ req->operation == UNC_OP_READ_NEXT ||
+ req->operation == UNC_OP_READ_BULK ||
+ req->operation == UNC_OP_READ_SIBLING_COUNT)) {
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+
/** Read key & value structure */
key_vbr_flowfilter_entry_t *key_vbr_flowfilter_entry =
reinterpret_cast<key_vbr_flowfilter_entry_t *>(key->get_key());
kMinLenFlowListName,
kMaxLenFlowListName);
if (rt_code != UPLL_RC_SUCCESS) {
- pfc_log_debug("FlowList name syntax check failed."
+ UPLL_LOG_DEBUG("FlowList name syntax check failed."
"Received Flowlist name - %s",
val_flowfilter_entry->flowlist_name);
return UPLL_RC_ERR_CFG_SYNTAX;
kMinLenNwmName,
kMaxLenNwmName);
if (rt_code != UPLL_RC_SUCCESS) {
- pfc_log_debug("Nwm name syntax check failed."
+ UPLL_LOG_DEBUG("Nwm name syntax check failed."
"Received Nwm name - %s",
val_flowfilter_entry->nwm_name);
return UPLL_RC_ERR_CFG_SYNTAX;
/* In case of update if action is not configured, check DB. if
action is not exists in DB also then send error */
if (val_flowfilter_entry->valid[UPLL_IDX_DSCP_FFE] == UNC_VF_VALID) {
- if ((val_flowfilter_entry->valid[UPLL_IDX_ACTION_FFE] ==
- UNC_VF_VALID) || action_valid) {
- if (!ValidateNumericRange(val_flowfilter_entry->dscp, kMinIPDscp,
- kMaxIPDscp, true, true)) {
- UPLL_LOG_DEBUG("DSCP syntax validation failed");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else {
- UPLL_LOG_DEBUG("Error DSCP is configured when Action is not filled");
- return UPLL_RC_ERR_CFG_SYNTAX;
+ if (!ValidateNumericRange(val_flowfilter_entry->dscp, kMinIPDscp,
+ kMaxIPDscp, true, true)) {
+ UPLL_LOG_DEBUG("DSCP syntax validation failed");
+ return UPLL_RC_ERR_CFG_SYNTAX;
}
} else if ((operation == UNC_OP_UPDATE)
&& (val_flowfilter_entry->valid[UPLL_IDX_DSCP_FFE]
/** validate Priority*/
if (val_flowfilter_entry->valid[UPLL_IDX_PRIORITY_FFE] == UNC_VF_VALID) {
- if ((val_flowfilter_entry->valid[UPLL_IDX_ACTION_FFE] ==
- UNC_VF_VALID) || action_valid) {
- if (!ValidateNumericRange(val_flowfilter_entry->priority,
- kMinVlanPriority, kMaxVlanPriority, true,
- true)) {
- UPLL_LOG_DEBUG("Priority syntax validation failed :Err Code - %d",
- rt_code);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else {
- UPLL_LOG_DEBUG("Error PRIORITY is configured when Action is not filled");
+ if (!ValidateNumericRange(val_flowfilter_entry->priority,
+ kMinVlanPriority, kMaxVlanPriority, true,
+ true)) {
+ UPLL_LOG_DEBUG("Priority syntax validation failed :Err Code - %d",
+ rt_code);
return UPLL_RC_ERR_CFG_SYNTAX;
}
} else if ((operation == UNC_OP_UPDATE)
val_flowfilter_entry_t *val_flowfilter_entry, uint32_t operation) {
upll_rc_t rt_code = UPLL_RC_ERR_GENERIC;
+ if ((val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_NODE_FFE]
+ == UNC_VF_VALID) &&
+ (val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_PORT_FFE]
+ != UNC_VF_VALID)) {
+ UPLL_LOG_DEBUG("redirect_node: interface is invalid");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ } else if ((val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_NODE_FFE]
+ != UNC_VF_VALID) &&
+ (val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_PORT_FFE]
+ == UNC_VF_VALID)) {
+ UPLL_LOG_DEBUG("redirect_node: node is invalid");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
/** validate redirect_node */
if (val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_NODE_FFE] == UNC_VF_VALID) {
rt_code = ValidateKey(
bool db_up_action_valid, bool action_redirect) {
UPLL_FUNC_TRACE;
+#if 0 // action_is_redirect is set, but not used
bool action_is_redirect = false;
+#endif
/** validate action */
if (val_flowfilter_entry->valid[UPLL_IDX_ACTION_FFE] == UNC_VF_VALID) {
if (!ValidateNumericRange(val_flowfilter_entry->action,
val_flowfilter_entry->action = 0;
}
- /** At the time of UPDATE if action is not set, then check DB, db_up_action_valid flag is
- * true when operation is update and valid flag for action is INVALID, action_redirect is
- * true when action is configured as REDIRECT in DB */
-
+#if 0 // action_is_redirect is set, but not used
+ /** At the time of UPDATE if action is not set, then check DB,
+ * db_up_action_valid flag is true when operation is update and valid flag for
+ * action is INVALID, action_redirect is true when action is configured as
+ * REDIRECT in DB */
if (val_flowfilter_entry->valid[UPLL_IDX_ACTION_FFE] == UNC_VF_VALID) {
if (val_flowfilter_entry->action == UPLL_FLOWFILTER_ACT_REDIRECT) {
action_is_redirect = true;
action_is_redirect = true;
}
}
-
- if ((!action_is_redirect)
- && ((val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_NODE_FFE]
- == UNC_VF_VALID)
- || (val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_PORT_FFE]
- == UNC_VF_VALID)
- || (val_flowfilter_entry->valid[UPLL_IDX_MODIFY_DST_MAC_FFE]
- == UNC_VF_VALID)
- || (val_flowfilter_entry->valid[UPLL_IDX_MODIFY_SRC_MAC_FFE]
- == UNC_VF_VALID))) {
- UPLL_LOG_DEBUG(
- "redirect_node/redirect_port/modify_dstmac/modify_srcmac is configured"
- "when action is not REDIRECT");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
+#endif
return UPLL_RC_SUCCESS;
}
ConfigKeyVal *ikey,
const char* ctrlr_name) {
UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+ // upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
if ((NULL == req) || (NULL == ikey)) {
UPLL_LOG_DEBUG("IpcReqRespHeader/ConfigKeyval is NULL");
- return result_code;
+ return UPLL_RC_ERR_GENERIC;
}
if (!ctrlr_name)
ctrlr_name = static_cast<char *>(ikey->get_user_data());
+
+ if (NULL == ctrlr_name) {
+ UPLL_LOG_DEBUG("ctrlr_name is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
- uint32_t dt_type = req->datatype;
- uint32_t operation = req->operation;
- uint32_t option1 = req->option1;
- uint32_t option2 = req->option2;
-
- UPLL_LOG_TRACE("dt_type : (%d)"
- "operation : (%d)"
- "option1 : (%d)"
- "option2 : (%d)",
- dt_type, operation, option1, option2);
+ UPLL_LOG_TRACE("ctrlr_name : (%s)"
+ "operation : (%d)",
+ ctrlr_name, req->operation);
bool ret_code = false;
uint32_t instance_count = 0;
const uint8_t *attrs = NULL;
uint32_t max_attrs = 0;
- switch (operation) {
+ switch (req->operation) {
case UNC_OP_CREATE: {
+ UPLL_LOG_TRACE("Calling GetCreateCapability Operation %d ", req->operation);
+
ret_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
&instance_count, &max_attrs, &attrs);
+ if (ret_code && cur_instance_count >= instance_count &&
+ cur_instance_count !=0 && instance_count != 0) {
+ UPLL_LOG_DEBUG("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
+ __LINE__, __FUNCTION__, cur_instance_count,
+ instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
break;
}
case UNC_OP_UPDATE: {
break;
}
default: {
- ret_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ if (req->datatype == UPLL_DT_STATE) {
+ UPLL_LOG_TRACE("Calling GetStateCapability Operation %d ", req->operation);
+ ret_code = GetStateCapability(ctrlr_name, ikey->get_key_type(),
&max_attrs, &attrs);
+ } else {
+ UPLL_LOG_TRACE("Calling GetReadCapability Operation %d ", req->operation);
+ ret_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ }
break;
}
}
if (!ret_code) {
UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s)",
ikey->get_key_type(), ctrlr_name);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
- }
-
- val_flowfilter_entry_t *val_flowfilter_entry = NULL;
-
- if (ikey->get_cfg_val() && (ikey->get_cfg_val()->get_st_num()
- == IpctSt::kIpcStValFlowfilterEntry)) {
- val_flowfilter_entry =
- reinterpret_cast<val_flowfilter_entry_t *>(
- ikey->get_cfg_val()->get_val());
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
- if ((operation == UNC_OP_CREATE) || (operation == UNC_OP_UPDATE)) {
- if (dt_type == UPLL_DT_CANDIDATE) {
- if (val_flowfilter_entry) {
- if (max_attrs > 0) {
- return ValFlowFilterEntryAttributeSupportCheck(val_flowfilter_entry,
- attrs);
- } else {
- UPLL_LOG_DEBUG("Attribute list is empty for operation %d", operation);
- }
- } else {
- UPLL_LOG_DEBUG("Error value struct is mandatory for CREATE/UPDATE");
- return result_code;
- }
- } else {
- UPLL_LOG_DEBUG("Unsupported datatype for CREATE/UPDATE");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else if (READ_SUPPORTED_OPERATION) {
- if (READ_SUPPORTED_DATATYPE) {
- if ((option1 != UNC_OPT1_NORMAL)
- && (option1 == UNC_OPT1_DETAIL
- && operation == UNC_OP_READ_SIBLING_COUNT)) {
- UPLL_LOG_DEBUG(" Error: option1 is not NORMAL");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
-
- if (option2 != UNC_OPT2_NONE) {
- UPLL_LOG_DEBUG(" Error: option2 is not NONE");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
+ val_flowfilter_entry_t *val_flowfilter_entry =
+ reinterpret_cast<val_flowfilter_entry_t *>(GetVal(ikey));
- if (val_flowfilter_entry) {
- if (max_attrs > 0) {
- return ValFlowFilterEntryAttributeSupportCheck(val_flowfilter_entry,
- attrs);
- } else {
- UPLL_LOG_DEBUG("Attribute list is empty for operation %d", operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- }
- return UPLL_RC_SUCCESS;
+ if (val_flowfilter_entry) {
+ if (max_attrs > 0) {
+ return ValFlowFilterEntryAttributeSupportCheck(val_flowfilter_entry,
+ attrs);
} else {
- UPLL_LOG_DEBUG("Error Unsupported datatype (%d)", dt_type);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d", req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR ;
}
- } else if (OPEARTION_WITH_VAL_STRUCT_NONE) {
- /** Value struct is NONE for this operations */
- UPLL_LOG_DEBUG("Skip Attribute validation, Operation type is %d",
- operation);
- return UPLL_RC_SUCCESS;
- }
-
- UPLL_LOG_DEBUG("Error Unsupported operation (%d)", operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ return UPLL_RC_SUCCESS;
}
upll_rc_t VbrFlowFilterEntryMoMgr::ValFlowFilterEntryAttributeSupportCheck(
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr_flowfilter_entry::kCapFlowlistName] == 0) {
val_flowfilter_entry->valid[UPLL_IDX_FLOWLIST_NAME_FFE] =
- UNC_VF_NOT_SOPPORTED;
-
+ UNC_VF_NOT_SUPPORTED;
UPLL_LOG_DEBUG("flowlist_name attr is not supported by ctrlr");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr_flowfilter_entry::kCapAction] == 0) {
val_flowfilter_entry->valid[UPLL_IDX_ACTION_VFFE] =
- UNC_VF_NOT_SOPPORTED;
+ UNC_VF_NOT_SUPPORTED;
UPLL_LOG_DEBUG("action attr is not supported by ctrlr");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr_flowfilter_entry::kCapRedirectNode] == 0) {
val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_NODE_FFE] =
- UNC_VF_NOT_SOPPORTED;
+ UNC_VF_NOT_SUPPORTED;
UPLL_LOG_DEBUG("redirect_node attr is not supported by ctrlr");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr_flowfilter_entry::kCapRedirectPort] == 0) {
val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_PORT_FFE] =
- UNC_VF_NOT_SOPPORTED;
+ UNC_VF_NOT_SUPPORTED;
UPLL_LOG_DEBUG("redirect_port attr is not supported by ctrlr");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr_flowfilter_entry::kCapModifyDstMac] == 0) {
val_flowfilter_entry->valid[UPLL_IDX_MODIFY_DST_MAC_FFE] =
- UNC_VF_NOT_SOPPORTED;
+ UNC_VF_NOT_SUPPORTED;
- UPLL_LOG_DEBUG("modify_dst attr is not supported by ctrlr");
+ UPLL_LOG_DEBUG("modify_dst attr is not supported by ctrlr");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
}
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr_flowfilter_entry::kCapModifySrcMac] == 0) {
val_flowfilter_entry->valid[UPLL_IDX_MODIFY_SRC_MAC_FFE] =
- UNC_VF_NOT_SOPPORTED;
+ UNC_VF_NOT_SUPPORTED;
UPLL_LOG_DEBUG("modify_src attr is not supported by ctrlr");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr_flowfilter_entry::kCapNwmName] == 0) {
val_flowfilter_entry->valid[UPLL_IDX_NWM_NAME_FFE] =
- UNC_VF_NOT_SOPPORTED;
+ UNC_VF_NOT_SUPPORTED;
UPLL_LOG_DEBUG("Nwmname attr is not supported by ctrlr");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
- return UPLL_RC_SUCCESS;
}
- /*
+
if ((val_flowfilter_entry->valid[UPLL_IDX_DSCP_FFE] == UNC_VF_VALID)
|| (val_flowfilter_entry->valid[UPLL_IDX_DSCP_FFE]
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr_flowfilter_entry::kCapDscp] == 0) {
- val_flowfilter_entry->valid[UPLL_IDX_DSCP_FFE] = UNC_VF_NOT_SOPPORTED;
+ val_flowfilter_entry->valid[UPLL_IDX_DSCP_FFE] = UNC_VF_NOT_SUPPORTED;
UPLL_LOG_DEBUG("dscp attr is not supported by ctrlr");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
- return UPLL_RC_SUCCESS;
}
if ((val_flowfilter_entry->valid[UPLL_IDX_PRIORITY_FFE] == UNC_VF_VALID)
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr_flowfilter_entry::kCapPriority] == 0) {
val_flowfilter_entry->valid[UPLL_IDX_PRIORITY_FFE] =
- UNC_VF_NOT_SOPPORTED;
+ UNC_VF_NOT_SUPPORTED;
UPLL_LOG_DEBUG("Priority attr is not supported by ctrlr");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
- return UPLL_RC_SUCCESS;
}
- */
} else {
- UPLL_LOG_DEBUG("Error value struct is NULL");
+ UPLL_LOG_DEBUG("value struct is NULL in "
+ "ValFlowFilterEntryAttributeSupportCheck");
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VbrFlowFilterEntryMoMgr::CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_TRACE(" ikey is %s", ikey->ToStrAll().c_str());
+ uint8_t *controller_id = reinterpret_cast<uint8_t *>(
+ const_cast<char *>(ctrlr_id));
+
+ /* check if object is renamed in the corresponding Rename Tbl
+ * if "renamed" create the object by the UNC name.
+ * else - create using the controller name.
+ */
+ result_code = GetRenamedUncKey(ikey, UPLL_DT_RUNNING, dmi, controller_id);
+ if (result_code != UPLL_RC_SUCCESS && result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey Failed err_code %d", result_code);
+ return result_code;
+ }
+
+ controller_domain ctrlr_dom;
+ memset(&ctrlr_dom, 0, sizeof(ctrlr_dom));
+ result_code = GetControllerDomainID(ikey, &ctrlr_dom, UPLL_DT_AUDIT, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get the Controller Domain details,err:%d",
+ result_code);
+ return result_code;
+ }
+
+ val_flowfilter_entry_t *val_flowfilter_entry =
+ static_cast<val_flowfilter_entry_t *>(
+ ikey->get_cfg_val()->get_val());
+
+
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+ UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
+ ctrlr_dom.ctrlr, ctrlr_dom.domain);
+
+ FlowListMoMgr *mgr = reinterpret_cast<FlowListMoMgr *>
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
+ if (mgr == NULL) {
+ UPLL_LOG_DEBUG("Invalid FlowListMoMgr Instance");
return UPLL_RC_ERR_GENERIC;
}
+
+ if (val_flowfilter_entry->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
+ result_code = mgr->AddFlowListToController(reinterpret_cast<char *>
+ (val_flowfilter_entry->flowlist_name), dmi,
+ reinterpret_cast<char *> (const_cast<char *>(ctrlr_id)) ,
+ UPLL_DT_AUDIT, UNC_OP_CREATE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Reference Count Updation Fails %d", result_code);
+ return result_code;
+ }
+ }
+ result_code = SetValidAudit(ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ return result_code;
+ }
+ // Create a record in AUDIT DB
+ result_code = UpdateConfigDB(ikey, UPLL_DT_AUDIT, UNC_OP_CREATE, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigDB Failed err_code %d", result_code);
+ return result_code;
+ }
return UPLL_RC_SUCCESS;
}
+upll_rc_t VbrFlowFilterEntryMoMgr::VerifyRedirectDestination(
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t dt_type) {
+ UPLL_FUNC_TRACE;
+ MoMgrImpl *mgr = NULL;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *okey = NULL;
+ if (!ikey || !ikey->get_key()) {
+ UPLL_LOG_DEBUG("input key is null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ controller_domain ctrlr_dom;
+ memset(&ctrlr_dom, 0, sizeof(controller_domain));
+ key_vbr_flowfilter_entry_t *key_vbr_ffe =
+ reinterpret_cast<key_vbr_flowfilter_entry_t *>(ikey->get_key());
+
+ /* read val_vtn_flowfilter_entry from ikey*/
+ val_flowfilter_entry_t *val_flowfilter_entry =
+ static_cast<val_flowfilter_entry_t *>(
+ ikey->get_cfg_val()->get_val());
+ // Symentic Validation for redirect destination
+ if ((val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_NODE_FFE] ==
+ UNC_VF_VALID) &&
+ (val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_PORT_FFE] ==
+ UNC_VF_VALID)) {
+ DbSubOp dbop_up = { kOpReadExist, kOpMatchCtrlr|kOpMatchDomain,
+ kOpInOutNone };
+ result_code = GetControllerDomainID(ikey, &ctrlr_dom, dt_type, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get the Controller Domain details, err:%d",
+ result_code);
+ }
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+
+ UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
+ ctrlr_dom.ctrlr, ctrlr_dom.domain);
+ // Verify whether the vtnnode and interface are exists in DB
+ // 1. Check for the vbridge Node
+ mgr = reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VBR_IF)));
+ if (NULL == mgr) {
+ UPLL_LOG_DEBUG("Unable to get VBRIDGE Interface object");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = mgr->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Memory allocation failed for VBRIDGE key struct - %d",
+ result_code);
+ return result_code;
+ }
+ key_vbr_if_t *vbrif_key = static_cast<key_vbr_if_t*>(
+ okey->get_key());
+ uuu::upll_strncpy(vbrif_key->vbr_key.vtn_key.vtn_name,
+ key_vbr_ffe->flowfilter_key.vbr_key.vtn_key.vtn_name,
+ kMaxLenVtnName + 1);
+
+ uuu::upll_strncpy(vbrif_key->vbr_key.vbridge_name,
+ reinterpret_cast<char *>
+ (val_flowfilter_entry->redirect_node),
+ (kMaxLenVnodeName + 1));
+ uuu::upll_strncpy(vbrif_key->if_name,
+ reinterpret_cast<char *>
+ (val_flowfilter_entry->redirect_port),
+ kMaxLenInterfaceName + 1);
+
+ /* Check vtnnode and interface exists in table*/
+
+ SET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
+
+ result_code = mgr->UpdateConfigDB(okey, dt_type,
+ UNC_OP_READ, dmi, &dbop_up, MAINTBL);
+
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ UPLL_LOG_DEBUG("vtn node/interface in val_flowfilter_entry exists"
+ "in DB");
+ DELETE_IF_NOT_NULL(okey);
+ } else if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ // 2. Check for Vrouter Node
+
+ // Verify whether the vtnnode and interface are exists in DB
+ DELETE_IF_NOT_NULL(okey);
+ mgr = reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VRT_IF)));
+ if (NULL == mgr) {
+ UPLL_LOG_DEBUG("Unable to get VROUTER Interface object");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = mgr->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Memory allocation failed for VROUTER key struct - %d",
+ result_code);
+ return result_code;
+ }
+ key_vrt_if_t *vrtif_key = static_cast<key_vrt_if_t*>(
+ okey->get_key());
+ uuu::upll_strncpy(vrtif_key->vrt_key.vtn_key.vtn_name,
+ key_vbr_ffe->flowfilter_key.vbr_key.vtn_key.vtn_name,
+ kMaxLenVtnName + 1);
+
+ uuu::upll_strncpy(vrtif_key->vrt_key.vrouter_name,
+ reinterpret_cast<char *>
+ (val_flowfilter_entry->redirect_node),
+ (kMaxLenVnodeName + 1));
+ uuu::upll_strncpy(vrtif_key->if_name,
+ reinterpret_cast<char *>
+ (val_flowfilter_entry->redirect_port),
+ kMaxLenInterfaceName + 1);
+
+ UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
+ ctrlr_dom.ctrlr, ctrlr_dom.domain);
+ SET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
+ /* Check vtnnode and interface exists in table*/
+ result_code = mgr->UpdateConfigDB(okey, dt_type,
+ UNC_OP_READ, dmi, &dbop_up, MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code) {
+ UPLL_LOG_DEBUG("vtn node/interface in val struct does not exists"
+ "in DB");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ DELETE_IF_NOT_NULL(okey);
+ }
+ result_code =
+ (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) ? UPLL_RC_SUCCESS :
+ result_code;
+ DELETE_IF_NOT_NULL(okey);
+ } // end of Symentic Validation
+ return result_code;
+}
+/*Return result of validation*/
+upll_rc_t VbrFlowFilterEntryMoMgr::TxVote(unc_key_type_t keytype,
+ DalDmlIntf *dmi,
+ ConfigKeyVal **err_ckv) {
+ UPLL_FUNC_TRACE;
+ ConfigKeyVal *req = NULL, *nreq = NULL;
+ DalResultCode db_result;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ unc_keytype_operation_t op[]= { UNC_OP_CREATE, UNC_OP_UPDATE};
+ int nop = sizeof(op) / sizeof(op[0]);
+ DalCursor *cfg1_cursor = NULL;
+
+ for (int i = 0; i < nop; i++) {
+ result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i], req,
+ nreq, &cfg1_cursor, dmi, MAINTBL);
+ while (result_code == UPLL_RC_SUCCESS) {
+ db_result = dmi->GetNextRecord(cfg1_cursor);
+ result_code = DalToUpllResCode(db_result);
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_DEBUG("No diff found for op %d", op[i]);
+ break;
+ }
+ val_flowfilter_entry_t* val = reinterpret_cast<val_flowfilter_entry_t *>
+ (GetVal(req));
+ if ((val->valid[UPLL_IDX_REDIRECT_NODE_FFE] ==
+ UNC_VF_VALID) &&
+ (val->valid[UPLL_IDX_REDIRECT_PORT_FFE] ==
+ UNC_VF_VALID)) {
+ result_code = VerifyRedirectDestination(req, dmi,
+ UPLL_DT_CANDIDATE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Invalid redirect-destination node/interface");
+ *err_ckv = req;
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ }
+ }
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ req = nreq = NULL;
+ }
+ return result_code;
+}
upll_rc_t VbrFlowFilterEntryMoMgr::ValidateAttribute(ConfigKeyVal *ikey,
DalDmlIntf *dmi,
IpcReqRespHeader *req) {
delete okey;
okey = NULL;
}
-
if (val_flowfilter_entry->valid[UPLL_IDX_NWM_NAME_FFE]
== UNC_VF_VALID) {
// validate nwm_name in KT_VBR_NWMONITOR table
delete okey;
okey = NULL;
} // nwm_name is valid
+ result_code = SetRenameFlag(ikey, dmi, req);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("SetRenameFlag failed %d", result_code);
+ return result_code;
+ }
UPLL_LOG_DEBUG("ValidateAttribute Successfull.");
return result_code;
}
if (parent_key == NULL) {
vbr_ffe_key = reinterpret_cast<key_vbr_flowfilter_entry_t*>
(ConfigKeyVal::Malloc(sizeof(key_vbr_flowfilter_entry_t)));
-
+ // If no direction is specified , 0xFE is filled to bind output direction
+ vbr_ffe_key->flowfilter_key.direction = 0xFE;
okey = new ConfigKeyVal(UNC_KT_VBR_FLOWFILTER_ENTRY,
IpctSt::kIpcStKeyVbrFlowfilterEntry,
vbr_ffe_key, NULL);
if (okey) {
if (okey->get_key_type() != UNC_KT_VBR_FLOWFILTER_ENTRY)
return UPLL_RC_ERR_GENERIC;
+ }
+
+ if ((okey) && (okey->get_key())) {
vbr_ffe_key = reinterpret_cast<key_vbr_flowfilter_entry_t *>
(okey->get_key());
} else {
vbr_ffe_key = reinterpret_cast<key_vbr_flowfilter_entry_t *>
(ConfigKeyVal::Malloc(sizeof(key_vbr_flowfilter_entry_t)));
+ // If no direction is specified , 0xFE is filled to bind output direction
+ vbr_ffe_key->flowfilter_key.direction = 0xFE;
}
switch (parent_key->get_key_type()) {
case UNC_KT_VTN:
reinterpret_cast<key_vbr_flowfilter_entry_t *>
(pkey)->sequence_num;
break;
+ case UNC_KT_VBR_NWMONITOR:
+ uuu::upll_strncpy(vbr_ffe_key->flowfilter_key.vbr_key.vtn_key.vtn_name,
+ reinterpret_cast<key_vbr_flowfilter_entry_t *>
+ (pkey)->flowfilter_key.vbr_key.vtn_key.vtn_name,
+ kMaxLenVtnName + 1);
+ break;
default:
if (vbr_ffe_key) free(vbr_ffe_key);
return UPLL_RC_ERR_GENERIC;
}
+
+
+ if ((okey) && !(okey->get_key())) {
+ UPLL_LOG_DEBUG("okey not null and flow list name updated");
+ okey->SetKey(IpctSt::kIpcStKeyVbrFlowfilterEntry, vbr_ffe_key);
+ }
+
if (!okey) {
okey = new ConfigKeyVal(UNC_KT_VBR_FLOWFILTER_ENTRY,
IpctSt::kIpcStKeyVbrFlowfilterEntry,
SET_USER_DATA(okey, req)
} else {
UPLL_LOG_DEBUG("okey is Null");
+ DELETE_IF_NOT_NULL(tmp1);
return UPLL_RC_ERR_GENERIC;
}
upll_rc_t VbrFlowFilterEntryMoMgr::GetRenamedUncKey(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type, DalDmlIntf *dmi, uint8_t *ctrlr_id) {
- // ConfigKeyVal *unc_key = new ConfigKeyVal(UNC_KT_VBR_FLOWFILTER_ENTRY);
+ UPLL_FUNC_TRACE;
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vbrff_entry start",
+ ikey->ToStrAll().c_str());
ConfigKeyVal *unc_key = NULL;
- if (NULL == ikey) {
+ if ((NULL == ikey) || (ctrlr_id == NULL) || (NULL == dmi)) {
+ UPLL_LOG_DEBUG("ikey/ctrlr_id dmi NULL");
return UPLL_RC_ERR_GENERIC;
}
-
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
upll_rc_t result_code = UPLL_RC_SUCCESS;
MoMgrImpl *mgrvbr = reinterpret_cast<MoMgrImpl *>
(const_cast<MoManager *> (GetMoManager(UNC_KT_VBRIDGE)));
+ if (!mgrvbr) {
+ UPLL_LOG_TRACE("mgrvbr failed");
+ return UPLL_RC_ERR_GENERIC;
+ }
val_rename_vnode *rename_val = reinterpret_cast<val_rename_vnode*>
(ConfigKeyVal::Malloc(sizeof(val_rename_vnode)));
+ if (!rename_val) {
+ UPLL_LOG_TRACE("rename_val NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
key_vbr_flowfilter_entry_t *ctrlr_key =
reinterpret_cast<key_vbr_flowfilter_entry_t *> (ikey->get_key());
-
+ if (!ctrlr_key) {
+ UPLL_LOG_TRACE("rename_val NULL");
+ free(rename_val);
+ return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(rename_val->ctrlr_vtn_name,
ctrlr_key->flowfilter_key.vbr_key.vtn_key.vtn_name,
(kMaxLenVtnName + 1));
+ rename_val->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
+
uuu::upll_strncpy(rename_val->ctrlr_vnode_name,
ctrlr_key->flowfilter_key.vbr_key.vbridge_name,
(kMaxLenVnodeName + 1));
- result_code = mgrvbr->GetChildConfigKey(unc_key, NULL);
+ rename_val->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_VALID;
+ result_code = mgrvbr->GetChildConfigKey(unc_key, NULL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_ERROR("GetRenamedUnckey:GetChildConfigKey returned error");
- free(rename_val); // RESOURCE LEAK
+ UPLL_LOG_DEBUG("GetChildConfigKey returned error");
+ free(rename_val);
+ mgrvbr = NULL;
return result_code;
}
- if (ctrlr_id == NULL) {
- UPLL_LOG_DEBUG("Controller Name is Not Valid");
+ if (!unc_key) {
+ UPLL_LOG_DEBUG("unc_key NULL");
free(rename_val);
- delete unc_key;
- return UPLL_RC_ERR_GENERIC;
+ mgrvbr = NULL;
+ return result_code;
}
-
- unc_key->set_user_data(ctrlr_id);
+ SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
unc_key->AppendCfgVal(IpctSt::kIpcStValRenameVtn, rename_val);
result_code = mgrvbr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ,
dbop, dmi, RENAMETBL);
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(unc_key);
+ mgrvbr = NULL;
+ return result_code;
+ }
+
if (result_code == UPLL_RC_SUCCESS) {
key_vbr_flowfilter_entry_t *vbr_flowfilter_entry_key =
reinterpret_cast<key_vbr_flowfilter_entry_t *> (unc_key->get_key());
vbr_flowfilter_entry_key->flowfilter_key.vbr_key.vbridge_name,
(kMaxLenVnodeName + 1));
}
-
- delete unc_key;
- unc_key = NULL;
- val_rename_flowlist_t *rename_flowlist =
- reinterpret_cast<val_rename_flowlist_t*>
- (ConfigKeyVal::Malloc(sizeof(val_rename_flowlist_t)));
+ mgrvbr = NULL;
+ DELETE_IF_NOT_NULL(unc_key);
val_flowfilter_entry_t *val_flowfilter_entry =
reinterpret_cast<val_flowfilter_entry_t *> (GetVal(ikey));
+ if (!val_flowfilter_entry) {
+ UPLL_LOG_ERROR("val_flowfilter_entry NULL");
+ return UPLL_RC_SUCCESS;
+ }
- uuu::upll_strncpy(rename_flowlist->flowlist_newname,
+ if (UNC_VF_VALID == val_flowfilter_entry
+ ->valid[UPLL_IDX_FLOWLIST_NAME_FFE]) {
+ val_rename_flowlist_t *rename_flowlist =
+ reinterpret_cast<val_rename_flowlist_t*>
+ (ConfigKeyVal::Malloc(sizeof(val_rename_flowlist_t)));
+ if (!rename_flowlist) {
+ UPLL_LOG_DEBUG("rename_flowlist NULL %d", result_code);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ uuu::upll_strncpy(rename_flowlist->flowlist_newname,
val_flowfilter_entry->flowlist_name,
(kMaxLenFlowListName + 1));
+ rename_flowlist->valid[UPLL_IDX_RENAME_FLOWLIST_RFL] = UNC_VF_VALID;
MoMgrImpl* mgr = reinterpret_cast<MoMgrImpl *>
(const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("mgr failed");
+ if (rename_flowlist) free(rename_flowlist);
+ return UPLL_RC_ERR_GENERIC;
+ }
result_code = mgr->GetChildConfigKey(unc_key, NULL);
-
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_ERROR("GetChildConfigKey Returned an error");
- free(rename_flowlist); // RESOURCE LEAK
+ UPLL_LOG_DEBUG("GetChildConfigKey Returned an error");
+ free(rename_flowlist);
+ mgr = NULL;
return result_code;
}
SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
unc_key->AppendCfgVal(IpctSt::kIpcStValRenameFlowlist, rename_flowlist);
result_code = mgr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL);
- if (result_code == UPLL_RC_SUCCESS) {
- key_flowlist_t *key_flowlist = NULL;
- key_flowlist = reinterpret_cast<key_flowlist_t *> (unc_key->get_key());
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(unc_key);
+ mgr = NULL;
+ return result_code;
+ }
- uuu::upll_strncpy(val_flowfilter_entry->flowlist_name,
+ if (result_code == UPLL_RC_SUCCESS) {
+ key_flowlist_t *key_flowlist = NULL;
+ key_flowlist = reinterpret_cast<key_flowlist_t *> (unc_key->get_key());
+
+ uuu::upll_strncpy(val_flowfilter_entry->flowlist_name,
key_flowlist->flowlist_name,
(kMaxLenFlowListName + 1));
- }
+ }
+ DELETE_IF_NOT_NULL(unc_key);
+ mgr = NULL;
+ }
+
+ if ((UNC_VF_VALID ==
+ val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_NODE_FFE]) &&
+ (UNC_VF_VALID ==
+ val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_PORT_FFE])) {
+ unc_key_type_t child_key[]= { UNC_KT_VBRIDGE, UNC_KT_VROUTER };
+ bool isRedirectVnodeVbridge = false;
+ for (unsigned int i = 0;
+ i < sizeof(child_key)/sizeof(child_key[0]); i++) {
+ const unc_key_type_t ktype = child_key[i];
+ MoMgrImpl *mgrvbr = reinterpret_cast<MoMgrImpl *>(
+ const_cast<MoManager *>(GetMoManager(ktype)));
+ if (!mgrvbr) {
+ UPLL_LOG_TRACE("mgrvbr failed");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val_rename_vnode *rename_val = reinterpret_cast<val_rename_vnode*>
+ (ConfigKeyVal::Malloc(sizeof(val_rename_vnode)));
+ if (!rename_val) {
+ UPLL_LOG_TRACE("rename_val NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
- UPLL_LOG_DEBUG("Key is filled with UncKey Successfully %d", result_code);
- free(rename_val);
- delete unc_key;
- return result_code;
+ uuu::upll_strncpy(rename_val->ctrlr_vnode_name,
+ val_flowfilter_entry->redirect_node,
+ (kMaxLenVnodeName + 1));
+ rename_val->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_VALID;
+
+ result_code = mgrvbr->GetChildConfigKey(unc_key, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Returned an error");
+ if (rename_val) free(rename_val);
+ mgrvbr = NULL;
+ return result_code;
+ }
+ SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
+ unc_key->AppendCfgVal(IpctSt::kIpcStValRenameVtn, rename_val);
+ result_code = mgrvbr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
+ RENAMETBL);
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(unc_key);
+ mgrvbr = NULL;
+ return result_code;
+ }
+
+ if (result_code == UPLL_RC_SUCCESS) {
+ if (unc_key->get_key_type() == UNC_KT_VBRIDGE) {
+ isRedirectVnodeVbridge = true;
+ key_vbr *vbr_key = reinterpret_cast<key_vbr *>(unc_key->get_key());
+ uuu::upll_strncpy(val_flowfilter_entry->redirect_node,
+ vbr_key->vbridge_name,
+ (kMaxLenVnodeName + 1));
+ } else if (unc_key->get_key_type() == UNC_KT_VROUTER) {
+ key_vrt *vrt_key = reinterpret_cast<key_vrt *>(unc_key->get_key());
+ uuu::upll_strncpy(val_flowfilter_entry->redirect_node,
+ vrt_key->vrouter_name,
+ (kMaxLenVnodeName + 1));
+ }
+ }
+ DELETE_IF_NOT_NULL(unc_key);
+ mgrvbr = NULL;
+ if (isRedirectVnodeVbridge) {
+ UPLL_LOG_DEBUG("RedirectVnode is Vbridge");
+ break;
+ }
+ }
+ }
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vbrff_entry end",
+ ikey->ToStrAll().c_str());
+ DELETE_IF_NOT_NULL(unc_key);
+ return UPLL_RC_SUCCESS;
}
upll_rc_t VbrFlowFilterEntryMoMgr::GetRenamedControllerKey(
ConfigKeyVal *okey = NULL;
upll_rc_t result_code = UPLL_RC_SUCCESS;
uint8_t rename = 0;
- IsRenamed(ikey, dt_type, dmi, rename);
- if (!rename)
- return UPLL_RC_SUCCESS;
- /* Vtn renamed */
- MoMgrImpl *mgrvtn = reinterpret_cast<MoMgrImpl *>
- (const_cast<MoManager *> (GetMoManager(UNC_KT_VTN)));
- if (rename & VTN_RENAME_FLAG) {
- mgrvtn->GetChildConfigKey(okey, NULL);
- if (ctrlr_dom != NULL) {
- SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
- } else {
- delete okey; // RESOURCE LEAK
- return UPLL_RC_ERR_GENERIC;
- }
+ /* Get the controller's redirect node(vbridge/vrt) name -start*/
+ val_flowfilter_entry_t *val_flowfilter_entry =
+ reinterpret_cast<val_flowfilter_entry_t *> (GetVal(ikey));
- uuu::upll_strncpy(reinterpret_cast<key_vtn *>(okey->get_key())->vtn_name,
+ if (val_flowfilter_entry) {
+ if ((UNC_VF_VALID ==
+ val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_NODE_FFE]) &&
+ (UNC_VF_VALID ==
+ val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_PORT_FFE])) {
+ unc_key_type_t child_key[]= { UNC_KT_VBRIDGE, UNC_KT_VROUTER };
+ bool isRedirectVnodeVbridge = false;
+ for (unsigned int i = 0;
+ i < sizeof(child_key)/sizeof(child_key[0]); i++) {
+ const unc_key_type_t ktype = child_key[i];
+ MoMgrImpl *mgrvbr = reinterpret_cast<MoMgrImpl *>(
+ const_cast<MoManager *>(GetMoManager(ktype)));
+ if (!mgrvbr) {
+ UPLL_LOG_DEBUG("mgrvbr failed");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ result_code = mgrvbr->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+ if (NULL != ctrlr_dom) {
+ SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+ // SET_USER_DATA_CTRLR(okey, ctrlr_dom->ctrlr);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+ if (okey->get_key_type() == UNC_KT_VBRIDGE) {
+ uuu::upll_strncpy(reinterpret_cast<key_vbr_t *>
+ (okey->get_key())->vbridge_name,
+ reinterpret_cast<val_flowfilter_entry_t *>(ikey->get_cfg_val()->
+ get_val())->redirect_node, (kMaxLenVnodeName + 1));
+
+ UPLL_LOG_DEBUG("redirect node vbr name (%s) (%s)",
+ reinterpret_cast<key_vbr_t *>(okey->get_key())->vbridge_name,
+ reinterpret_cast<val_flowfilter_entry_t *>(ikey->get_cfg_val()->
+ get_val())->redirect_node);
+ } else if (okey->get_key_type() == UNC_KT_VROUTER) {
+ uuu::upll_strncpy(reinterpret_cast<key_vrt_t *>
+ (okey->get_key())->vrouter_name,
+ reinterpret_cast<val_flowfilter_entry_t *>(ikey->get_cfg_val()->
+ get_val())->redirect_node, (kMaxLenVnodeName + 1));
+
+ UPLL_LOG_DEBUG("redirect node vrt name (%s) (%s)",
+ reinterpret_cast<key_vrt_t *>(okey->get_key())->vrouter_name,
+ reinterpret_cast<val_flowfilter_entry_t *>(ikey->get_cfg_val()->
+ get_val())->redirect_node);
+ }
+
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr | kOpMatchDomain, kOpInOutFlag };
+ result_code = mgrvbr->ReadConfigDB(okey, dt_type, UNC_OP_READ,
+ dbop, dmi, RENAMETBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ }
+
+ if (result_code == UPLL_RC_SUCCESS) {
+ val_rename_vnode *rename_val = NULL;
+ isRedirectVnodeVbridge = true;
+ rename_val = reinterpret_cast<val_rename_vnode *> (GetVal(okey));
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("rename_val NULL.");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ uuu::upll_strncpy(reinterpret_cast<val_flowfilter_entry_t*>
+ (ikey->get_cfg_val()->get_val())->redirect_node,
+ rename_val->ctrlr_vnode_name, (kMaxLenVtnName + 1));
+ }
+ DELETE_IF_NOT_NULL(okey);
+ if (isRedirectVnodeVbridge)
+ break;
+ }
+ }
+ }
+ /* -end*/
+
+ IsRenamed(ikey, dt_type, dmi, rename);
+ if (!rename) {
+ UPLL_LOG_DEBUG("no renamed");
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_TRACE("Start Input ConfigKeyVal %s",
+ ikey->ToStrAll().c_str());
+ MoMgrImpl *mgrvbr = reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_VBRIDGE)));
+
+ result_code = mgrvbr->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+
+ if (NULL != ctrlr_dom) {
+ SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom)
+ }
+ else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
+ uuu::upll_strncpy(reinterpret_cast<key_vbr *> (okey->get_key())->vtn_key.vtn_name,
+ reinterpret_cast<key_vbr_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.vbr_key.vtn_key.vtn_name,
+ (kMaxLenVnodeName + 1));
+ UPLL_LOG_DEBUG("vtn name (%s) (%s)",
+ reinterpret_cast<key_vbr *> (okey->get_key())->vtn_key.vtn_name,
+ reinterpret_cast<key_vbr_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.vbr_key.vtn_key.vtn_name);
+
+ uuu::upll_strncpy(reinterpret_cast<key_vbr *>
+ (okey->get_key())->vbridge_name,
+ reinterpret_cast<key_vbr_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+
+ UPLL_LOG_DEBUG("vtn name (%s) (%s)",
+ reinterpret_cast<key_vbr *>
+ (okey->get_key())->vbridge_name,
+ reinterpret_cast<key_vbr_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.vbr_key.vbridge_name);
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr | kOpMatchDomain, kOpInOutFlag };
+ result_code = mgrvbr->ReadConfigDB(okey, dt_type, UNC_OP_READ,
+ dbop, dmi, RENAMETBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB no instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ val_rename_vnode *rename_val = NULL;
+ rename_val = reinterpret_cast<val_rename_vnode *> (GetVal(okey));
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("Vbr Name is not Valid.");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ if (rename & VTN_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("vtn name renamed");
+ uuu::upll_strncpy(reinterpret_cast<key_vbr_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.vbr_key.vtn_key.vtn_name,
+ rename_val->ctrlr_vtn_name,
+ (kMaxLenVtnName + 1));
+ }
+
+ if (rename & VBR_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("vbr name renamed");
+ uuu::upll_strncpy(reinterpret_cast<char *>
+ (reinterpret_cast<key_vbr_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.vbr_key.vbridge_name),
+ reinterpret_cast<const char *> (rename_val->ctrlr_vnode_name),
+ kMaxLenVnodeName + 1);
+ }
+
+ DELETE_IF_NOT_NULL(okey);
+
+ // Flowlist is Renamed
+ if (rename & FLOWLIST_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("flowlist name renamed");
+ if (!GetVal(ikey)) {
+ UPLL_LOG_DEBUG("value structure is null");
+ return UPLL_RC_SUCCESS;
+ }
+ MoMgrImpl *mgrflist = reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
+ result_code = mgrflist->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+ if (NULL != ctrlr_dom) {
+ SET_USER_DATA_CTRLR(okey, ctrlr_dom->ctrlr);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
+ uuu::upll_strncpy(
+ reinterpret_cast<key_flowlist_t *>
+ (okey->get_key())->flowlist_name,
+ reinterpret_cast<val_flowfilter_entry_t *>(ikey->get_cfg_val()->
+ get_val())->flowlist_name,
+ (kMaxLenFlowListName + 1));
+ UPLL_LOG_DEBUG("flowlist name (%s) (%s)",
+ reinterpret_cast<key_flowlist_t *>
+ (okey->get_key())->flowlist_name,
+ reinterpret_cast<val_flowfilter_entry_t *>(ikey->get_cfg_val()->
+ get_val())->flowlist_name);
+// UPLL_LOG_DEBUG("flowlist name (%s) (%s)", (okey->get_key())->flowlist_name,
+// (ikey->get_cfg_val()->get_val())->flowlist_name);
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
+ result_code = mgrflist->ReadConfigDB(okey, dt_type, UNC_OP_READ,
+ dbop, dmi, RENAMETBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB no instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+
+ val_rename_flowlist_t *rename_val = NULL;
+ rename_val = reinterpret_cast<val_rename_flowlist_t *> (GetVal(okey));
+
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("flowlist is not valid");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ uuu::upll_strncpy(reinterpret_cast<val_flowfilter_entry_t*>
+ (ikey->get_cfg_val()->get_val())->flowlist_name,
+ rename_val->flowlist_newname,
+ (kMaxLenFlowListName + 1));
+ DELETE_IF_NOT_NULL(okey);
+ }
+ UPLL_LOG_TRACE("%s GetRenamedCtrl vbr_ff_entry end",
+ ikey->ToStrAll().c_str());
+ UPLL_LOG_DEBUG("Renamed Controller key is sucessfull.");
+ return UPLL_RC_SUCCESS;
+#if 0
+ /* Vtn renamed */
+ if (rename & VTN_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("vtn name renamed");
+ MoMgrImpl *mgrvtn = reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_VTN)));
+ result_code = mgrvtn->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+
+ if (ctrlr_dom != NULL) {
+ SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
+ uuu::upll_strncpy(reinterpret_cast<key_vtn *>(okey->get_key())->vtn_name,
reinterpret_cast<key_vbr_flowfilter_entry_t *>
(ikey->get_key())->flowfilter_key.vbr_key.vtn_key.vtn_name,
(kMaxLenVtnName + 1));
+// UPLL_LOG_DEBUG("vtn name (%s) (%s)", (okey->get_key())->vtn_name,
+// (ikey->get_key())->flowfilter_key.vbr_key.vtn_key.vtn_name);
+
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
- mgrvtn->ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi, RENAMETBL);
+ result_code = mgrvtn->ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi, RENAMETBL);
+ if ( result_code != UPLL_RC_SUCCESS ) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
val_rename_vtn *rename_val = NULL;
rename_val = reinterpret_cast<val_rename_vtn *> (GetVal(okey));
- if (!rename_val
- || (rename_val->valid[UPLL_IDX_NEW_NAME_RVTN] != UNC_VF_VALID)) {
+ if (!rename_val) {
UPLL_LOG_DEBUG("Vtn Name is not Valid.");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
(ikey->get_key())->flowfilter_key.vbr_key.vtn_key.vtn_name,
rename_val->new_name,
(kMaxLenVtnName + 1));
- delete okey;
+ DELETE_IF_NOT_NULL(okey);
}
// Vbr Renamed
- MoMgrImpl *mgrvbr = reinterpret_cast<MoMgrImpl *>
- (const_cast<MoManager *> (GetMoManager(UNC_KT_VBRIDGE)));
if (rename & VBR_RENAME_FLAG) {
- result_code = mgrvbr->GetChildConfigKey(okey, NULL); // COV USE AFTER FREE
- if (result_code != UPLL_RC_SUCCESS) {
- return result_code;
- }
- if (NULL != ctrlr_dom)
+ UPLL_LOG_DEBUG("vbr name renamed");
+ MoMgrImpl *mgrvbr = reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_VBRIDGE)));
+
+ result_code = mgrvbr->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+
+ if (NULL != ctrlr_dom) {
SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom)
- else
+ }
+ else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
+ uuu::upll_strncpy(reinterpret_cast<key_vbr *> (okey->get_key())->vtn_key.vtn_name,
+ reinterpret_cast<key_vbr_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.vbr_key.vtn_key.vtn_name,
+ (kMaxLenVnodeName + 1));
+ UPLL_LOG_DEBUG("vtn name (%s) (%s)",
+ reinterpret_cast<key_vbr *> (okey->get_key())->vtn_key.vtn_name,
+ reinterpret_cast<key_vbr_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.vbr_key.vtn_key.vtn_name);
uuu::upll_strncpy(reinterpret_cast<key_vbr *>
(okey->get_key())->vbridge_name,
reinterpret_cast<key_vbr_flowfilter_entry_t *>
(ikey->get_key())->flowfilter_key.vbr_key.vbridge_name,
(kMaxLenVnodeName + 1));
+// UPLL_LOG_DEBUG("vbr name (%s) (%s)", (okey->get_key())->vbridge_name,
+// (ikey->get_key())->flowfilter_key.vbr_key.vbridge_name);
+ UPLL_LOG_DEBUG("vtn name (%s) (%s)",
+ reinterpret_cast<key_vbr *>
+ (okey->get_key())->vbridge_name,
+ reinterpret_cast<key_vbr_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.vbr_key.vbridge_name);
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
result_code = mgrvbr->ReadConfigDB(okey, dt_type, UNC_OP_READ,
dbop, dmi, RENAMETBL);
- if (result_code != UPLL_RC_SUCCESS) { // COV CHECKED RETURNS
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
- val_rename_vbr *rename_val = NULL;
- rename_val = reinterpret_cast<val_rename_vbr *> (GetVal(okey));
- if (!rename_val
- || (rename_val->valid[UPLL_IDX_NEW_NAME_RVBR] != UNC_VF_VALID)) {
+ val_rename_vnode *rename_val = NULL;
+ rename_val = reinterpret_cast<val_rename_vnode *> (GetVal(okey));
+ if (!rename_val) {
UPLL_LOG_DEBUG("Vbr Name is not Valid.");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
uuu::upll_strncpy(reinterpret_cast<char *>
(reinterpret_cast<key_vbr_flowfilter_entry_t *>
(ikey->get_key())->flowfilter_key.vbr_key.vbridge_name),
- reinterpret_cast<const char *> (rename_val->new_name),
+ reinterpret_cast<const char *> (rename_val->ctrlr_vnode_name),
kMaxLenVnodeName + 1);
- delete okey;
+ DELETE_IF_NOT_NULL(okey);
}
// Flowlist is Renamed
if (rename & FLOWLIST_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("flowlist name renamed");
MoMgrImpl *mgrflist = reinterpret_cast<MoMgrImpl *>
(const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
- mgrflist->GetChildConfigKey(okey, ikey);
-
+ result_code = mgrflist->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
if (NULL != ctrlr_dom) {
SET_USER_DATA_CTRLR(okey, ctrlr_dom->ctrlr);
} else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
-
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
+ uuu::upll_strncpy(
+ reinterpret_cast<key_flowlist_t *>
+ (okey->get_key())->flowlist_name,
+ reinterpret_cast<val_flowfilter_entry_t *> (ikey->get_cfg_val()->
+ get_val())->flowlist_name,
+ (kMaxLenFlowListName + 1));
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
result_code = mgrflist->ReadConfigDB(okey, dt_type, UNC_OP_READ,
dbop, dmi, RENAMETBL);
- if (result_code != UPLL_RC_SUCCESS) { // COV CHECKED RETURNS
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
+
val_rename_flowlist_t *rename_val = NULL;
rename_val = reinterpret_cast<val_rename_flowlist_t *> (GetVal(okey));
- if (!rename_val
- || (rename_val->valid[UPLL_IDX_NEW_NAME_RVTN] != UNC_VF_VALID)) {
+ if (!rename_val) {
UPLL_LOG_DEBUG("flowlist is not valid");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
(ikey->get_cfg_val()->get_val())->flowlist_name,
rename_val->flowlist_newname,
(kMaxLenFlowListName + 1));
- SET_USER_DATA_FLAGS(ikey, VTN_RENAME); // TODO(me) :FLOWLIST_RENAME
- delete okey;
+ SET_USER_DATA_FLAGS(ikey, rename);
+ DELETE_IF_NOT_NULL(okey);
}
-
+ UPLL_LOG_TRACE("%s GetRenamedCtrl vbr_ff_entry end",
+ ikey->ToStrAll().c_str());
UPLL_LOG_DEBUG("Renamed Controller key is sucessfull.");
return UPLL_RC_SUCCESS;
+#endif
}
upll_rc_t VbrFlowFilterEntryMoMgr::GetControllerDomainID(ConfigKeyVal *ikey,
controller_domain *ctrlr_dom,
DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ckv = NULL;
VbrMoMgr *mgrvbr =
reinterpret_cast<VbrMoMgr *>(const_cast<MoManager *>(GetMoManager(
UNC_KT_VBRIDGE)));
- ConfigKeyVal *ckv = NULL;
result_code = mgrvbr->GetChildConfigKey(ckv, NULL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Unable to get the ParentConfigKey, resultcode=%d",
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Unable to Read the details from DB for the parent err %d",
result_code);
- delete ckv;
+ DELETE_IF_NOT_NULL(ckv);
return result_code;
}
result_code = mgrvbr->GetControllerDomainId(ckv, ctrlr_dom);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetControllerDomainId failed %d ", result_code);
+ DELETE_IF_NOT_NULL(ckv);
return result_code;
}
+ uint8_t temp_flag = 0;
+ GET_USER_DATA_FLAGS(ikey, temp_flag);
+ SET_USER_DATA(ikey, ckv);
+ SET_USER_DATA_FLAGS(ikey, temp_flag);
+ DELETE_IF_NOT_NULL(ckv);
return result_code;
}
upll_rc_t VbrFlowFilterEntryMoMgr::CreateCandidateMo(IpcReqRespHeader *req,
- ConfigKeyVal *ikey, DalDmlIntf *dmi) {
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
uint8_t *ctrlr_id = NULL;
ConfigKeyVal* okey = NULL;
+ ConfigKeyVal *temp_key = NULL;
controller_domain ctrlr_dom;
if (ikey == NULL && req == NULL) {
UPLL_LOG_DEBUG(
- "Cannot perform create operation due to insufficient parameters\n");
+ "Cannot perform create operation due to insufficient parameters");
return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_DEBUG("ValidateAttribute failed %d", result_code);
return result_code;
}
-
- /*
- result_code = ValidateCapability(req, ikey);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("validate Capability Failed %d", result_code);
- return result_code;
- }
- */
// Check if Object already exists in CANDIDATE DB
result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_READ, dmi);
if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
}
// Check if Object exists in RUNNING DB and move it to CANDIDATE DB
- result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
- MAINTBL);
- if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
- result_code = RestoreChildren(ikey, req->datatype, UPLL_DT_RUNNING, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Restore Chidlren Failed");
- return result_code;
- }
- } else if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- UPLL_LOG_DEBUG("UpdateConfigDb failed to read running");
+ FlowListMoMgr *mgr = NULL;
+ val_flowfilter_entry_t *flowfilter_val =
+ reinterpret_cast<val_flowfilter_entry_t *> (GetVal(ikey));
+ result_code = GetControllerDomainID(ikey, &ctrlr_dom, req->datatype, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get the Controller Domain details, err:%d",
+ result_code);
+ }
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+
+ UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
+ ctrlr_dom.ctrlr, ctrlr_dom.domain);
+ ctrlr_id = ctrlr_dom.ctrlr;
+
+ result_code = GetChildConfigKey(temp_key, NULL);
+ if(result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed in ValidateCapability");
+ return result_code;
+ }
+ result_code = GetInstanceCount(temp_key,
+ reinterpret_cast<char*>(ctrlr_id),
+ req->datatype,
+ &cur_instance_count,
+ dmi,
+ MAINTBL);
+ delete temp_key;
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetInstanceCount Failed in ValidateCapability");
return result_code;
- } else {
- UPLL_LOG_DEBUG("No instance found in running db");
}
- val_flowfilter_entry_t *flowfilter_val =
- reinterpret_cast<val_flowfilter_entry_t *> (GetVal(ikey));
-FlowListMoMgr *mgr = NULL;
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(ctrlr_id));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("validate Capability Failed %d", result_code);
+ return result_code;
+ }
+ if (UPLL_DT_CANDIDATE == req->datatype) {
+ result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
+ MAINTBL);
+ if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
+ result_code = RestoreChildren(ikey, req->datatype, UPLL_DT_RUNNING, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Restore Operation Failed, err %d", result_code);
+ return result_code;
+ }
+ return result_code;
+ } else if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("UpdateConfigDb failed to read running");
+ return result_code;
+ } else {
+ UPLL_LOG_DEBUG("No instance found in running db");
+ }
+ }
if (flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
mgr = reinterpret_cast<FlowListMoMgr *>
(const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
return result_code;
}
}
- result_code = GetControllerDomainID(ikey, &ctrlr_dom, req->datatype, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Failed to Get the Controller Domain details, err:%d",
- result_code);
- }
- SET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
-
- UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
- ctrlr_dom.ctrlr, ctrlr_dom.domain);
- ctrlr_id = ctrlr_dom.ctrlr;
if (flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
result_code = mgr->AddFlowListToController(
reinterpret_cast<char *>(flowfilter_val->flowlist_name), dmi,
- reinterpret_cast<char *>(ctrlr_id) , UNC_OP_CREATE);
+ reinterpret_cast<char *>(ctrlr_id) , req->datatype, UNC_OP_CREATE);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Unable to Update the FlowList at ctrlr Table");
+ delete okey;
return result_code;
}
}
// N/w monitor
#if 0
NwMonitorMoMgr *nmgr = reinterpret_cast<NwMonitorMoMgr *>
- (const_cast<MoManager *> (GetMoManager(UNC_KT_VBR_NWMONITOR)));
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_VBR_NWMONITOR)));
// result_code = nmgr->GetChildConfigKey(okey, NULL); // TODO
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Recored %d", result_code);
}
key_nwm_t *key_nwm = reinterpret_cast<key_nwm_t*>(okey->get_key());
strncpy(reinterpret_cast<char*>(key_nwm->nwmonitor_name),
- reinterpret_cast<const char*>(flowfilter_val->nwm_name),
- kMaxLenNwmName +1);
-// result_code = nmgr->IsReferenced(okey, req->datatype, dmi); // TODO
+ reinterpret_cast<const char*>(flowfilter_val->nwm_name),
+ kMaxLenNwmName +1);
+ // result_code = nmgr->IsReferenced(okey, req->datatype, dmi); // TODO
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Recored %d", result_code);
return result_code;
// create a record in CANDIDATE DB
DbSubOp dbop = { kOpNotRead, kOpMatchNone, kOpInOutDomain
- | kOpInOutCtrlr };
+ | kOpInOutCtrlr | kOpInOutFlag };
result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_CREATE,
dmi, &dbop, MAINTBL);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
+upll_rc_t VbrFlowFilterEntryMoMgr::RestorePOMInCtrlTbl(
+ ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl,
+ DalDmlIntf* dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+
+ controller_domain ctrlr_dom;
+ FlowListMoMgr *mgr = NULL;
+ uint8_t *ctrlr_id = NULL;
+
+ if (!ikey || !(ikey->get_key())) {
+ UPLL_LOG_DEBUG("Input Key Not Valid");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (tbl != MAINTBL ||
+ ikey->get_key_type() != UNC_KT_VBR_FLOWFILTER_ENTRY) {
+ UPLL_LOG_DEBUG("Ignoring ktype/Table kt=%d, tbl=%d",
+ ikey->get_key_type(), tbl);
+ return result_code;
+ }
+ val_flowfilter_entry_t *flowfilter_val =
+ reinterpret_cast<val_flowfilter_entry_t *> (GetVal(ikey));
+
+ if (NULL == flowfilter_val) {
+ UPLL_LOG_DEBUG(" Value structure is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
+ result_code = GetControllerDomainID(ikey, &ctrlr_dom, dt_type, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get the Controller Domain details, err:%d",
+ result_code);
+ return result_code;
+ }
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+ ctrlr_id = ctrlr_dom.ctrlr;
+
+ mgr = reinterpret_cast<FlowListMoMgr *>
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
+ result_code = mgr->AddFlowListToController(
+ reinterpret_cast<char *>(flowfilter_val->flowlist_name),
+ dmi,
+ reinterpret_cast<char *>(ctrlr_id),
+ dt_type,
+ UNC_OP_CREATE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to Update the FlowList at ctrlr Table, err %d",
+ result_code);
+ return result_code;
+ }
+ }
+ return result_code;
+}
upll_rc_t VbrFlowFilterEntryMoMgr::DeleteMo(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
DalDmlIntf *dmi) {
(const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
result_code = mgr->AddFlowListToController(
reinterpret_cast<char *>(flowfilter_val->flowlist_name), dmi,
- reinterpret_cast<char *>(ctrlr_id), UNC_OP_DELETE);
+ reinterpret_cast<char *>(ctrlr_id), req->datatype, UNC_OP_DELETE);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG(" Send delete request to flowlist failed. err code(%d)",
result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
}
result_code = UpdateConfigDB(ikey, UPLL_DT_CANDIDATE, UNC_OP_DELETE, dmi,
MAINTBL);
+ DELETE_IF_NOT_NULL(okey);
UPLL_LOG_DEBUG("DeleteMo Operation Done %d", result_code);
return result_code;
}
upll_rc_t VbrFlowFilterEntryMoMgr::MergeValidate(unc_key_type_t keytype,
- const char *ctrlr_id, ConfigKeyVal *ikey, DalDmlIntf *dmi) {
+ const char *ctrlr_id,
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
- ConfigKeyVal *tkey;
- ConfigKeyVal *keyval = NULL;
- if (NULL == ikey) {
- UPLL_LOG_DEBUG("Memory is Allocated.");
- return UPLL_RC_ERR_GENERIC;
+ ConfigKeyVal *ckval = NULL;
+ if (NULL == ctrlr_id) {
+ UPLL_LOG_DEBUG("ctrlr_id NULL");
+ return result_code;
}
- result_code = ReadConfigDB(ikey, UPLL_DT_IMPORT, UNC_OP_READ, dbop, dmi,
- MAINTBL);
+ result_code = GetChildConfigKey(ckval, NULL);
if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ckval fail");
return result_code;
}
-
- MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>
- (const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
- tkey = ikey;
- while (ikey != NULL) {
- result_code = mgr->GetChildConfigKey(keyval, NULL);
-
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetChildConfigKey is Failed %d", result_code);
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone};
+ result_code = ReadConfigDB(ckval, UPLL_DT_IMPORT,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ckval);
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
return result_code;
}
-
- val_flowfilter_entry_t *flowfilter_val =
- reinterpret_cast<val_flowfilter_entry_t *> (GetVal(ikey));
- key_flowlist_t *key_flowlist = NULL;
- key_flowlist = reinterpret_cast<key_flowlist_t *> (keyval->get_key());
-
- uuu::upll_strncpy(key_flowlist->flowlist_name,
- flowfilter_val->flowlist_name,
- (kMaxLenFlowListName + 1));
- result_code = mgr->UpdateConfigDB(keyval, UPLL_DT_CANDIDATE, UNC_OP_READ,
- dmi, MAINTBL);
-
- if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
- UPLL_LOG_DEBUG("Instance Already Exists");
- return UPLL_RC_ERR_MERGE_CONFLICT;
+ return UPLL_RC_SUCCESS;
+ }
+ ConfigKeyVal *tmp_ckval = ckval;
+ while (NULL != ckval) {
+ val_flowfilter_entry_t* val = reinterpret_cast<val_flowfilter_entry_t *>
+ (GetVal(ckval));
+ if (val->valid[UPLL_IDX_REDIRECT_NODE_FFE] ==
+ UNC_VF_VALID) {
+ if (val->valid[UPLL_IDX_REDIRECT_PORT_FFE] ==
+ UNC_VF_VALID) {
+ result_code = VerifyRedirectDestination(ckval, dmi, UPLL_DT_IMPORT);
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(ckval);
+ UPLL_LOG_DEBUG("redirect-destination node/interface doesn't exists");
+ return UPLL_RC_ERR_MERGE_CONFLICT;
+ }
+ }
}
-
- ikey = tkey->get_next_cfg_key_val();
+ ckval = ckval->get_next_cfg_key_val();
}
- if (tkey)
- delete tkey;
+ DELETE_IF_NOT_NULL(tmp_ckval);
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_VBR_FLOWFILTER)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Invalid mgr param");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ result_code = mgr->MergeValidate(keytype, ctrlr_id, ikey, dmi);
+ UPLL_LOG_DEBUG("MergeValidate result code (%d)", result_code);
return result_code;
}
return UPLL_RC_ERR_GENERIC;
}
if (uuc::kUpllUcpCreate == phase )
- val->cs_row_status = cs_status;
+ val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
for ( unsigned int loop = 0;
- loop < sizeof(val->valid)/sizeof(val->valid[0]); loop++ ) {
- if ( cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop])
- val->cs_attr[loop] = cs_status;
- else
- val->cs_attr[loop] = cs_status;
+ loop < sizeof(val->valid)/sizeof(uint8_t); ++loop ) {
+ if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
+ cs_status == UNC_CS_APPLIED)
+ val->cs_attr[loop] = cs_status;
}
-
UPLL_LOG_DEBUG("AuditUpdate Config Status Information %d", result_code);
return result_code;
}
UPLL_LOG_DEBUG("Error Accesing CANDIDATE DB (%d)", result_code);
return result_code;
}
- if (okey != NULL) {
delete okey;
okey = NULL;
}
- }
- if (UNC_VF_VALID == flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] ||
- UNC_VF_VALID_NO_VALUE == flowfilter_val->
- valid[UPLL_IDX_FLOWLIST_NAME_FFE]) {
- result_code = GetChildConfigKey(okey, ikey);
+
+ // Get ctrlr_id to do Capa check
+ result_code = GetChildConfigKey(okey, ikey);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetChildConfigKey failed");
return result_code;
result_code = ReadConfigDB(okey, UPLL_DT_CANDIDATE, UNC_OP_READ, dbop, dmi,
MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
+ delete okey;
UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
return result_code;
}
GET_USER_DATA_CTRLR(okey, ctrlr_id);
+
+ UPLL_LOG_DEBUG("Calling validate Capability For UpdateMo");
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char*>(ctrlr_id));
+ if (result_code != UPLL_RC_SUCCESS) {
+ delete okey;
+ UPLL_LOG_DEBUG("validate Capability Failed %d", result_code);
+ return result_code;
+ }
+
+ if (UNC_VF_VALID == flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] ||
+ UNC_VF_VALID_NO_VALUE == flowfilter_val->
+ valid[UPLL_IDX_FLOWLIST_NAME_FFE]) {
+
val_flowfilter_entry_t *temp_ffe_val = reinterpret_cast
<val_flowfilter_entry_t *>(GetVal(okey));
UPLL_LOG_DEBUG("flowlist name %s", flowfilter_val->flowlist_name);
UPLL_LOG_DEBUG("Update option 1");
result_code = flowlist_mgr->AddFlowListToController(
reinterpret_cast<char *>(temp_ffe_val->flowlist_name), dmi,
- reinterpret_cast<char *> (ctrlr_id), UNC_OP_DELETE);
+ reinterpret_cast<char *> (ctrlr_id), req->datatype, UNC_OP_DELETE);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("AddFlowListToController failed %d", result_code);
delete okey;
}
result_code = flowlist_mgr->AddFlowListToController(
reinterpret_cast<char *>(flowfilter_val->flowlist_name), dmi,
- reinterpret_cast<char *>(ctrlr_id), UNC_OP_CREATE);
+ reinterpret_cast<char *>(ctrlr_id), req->datatype, UNC_OP_CREATE);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("AddFlowListToController failed %d", result_code);
delete okey;
UPLL_LOG_DEBUG("Update option 2");
result_code = flowlist_mgr->AddFlowListToController(
reinterpret_cast<char *>(flowfilter_val->flowlist_name), dmi,
- reinterpret_cast<char *>(ctrlr_id), UNC_OP_CREATE);
+ reinterpret_cast<char *>(ctrlr_id), req->datatype, UNC_OP_CREATE);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("AddFlowListToController failed %d", result_code);
delete okey;
UPLL_LOG_DEBUG("Update option 3");
result_code = flowlist_mgr->AddFlowListToController(
reinterpret_cast<char *>(temp_ffe_val->flowlist_name), dmi,
- reinterpret_cast<char *>(ctrlr_id), UNC_OP_DELETE);
+ reinterpret_cast<char *>(ctrlr_id), req->datatype, UNC_OP_DELETE);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("AddFlowListToController failed %d", result_code);
delete okey;
return result_code;
}
#endif
-
+ DbSubOp dbop1 = {kOpNotRead, kOpMatchNone, kOpInOutFlag};
result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_UPDATE, dmi,
- MAINTBL);
+ &dbop1, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Unable to Update the CandidateDB");
return result_code;
}
GET_USER_DATA_CTRLR_DOMAIN(dup_key, ctrlr_dom);
SET_USER_DATA_CTRLR_DOMAIN(l_key, ctrlr_dom);
+ //Adding Capacheck
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(ctrlr_dom.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ delete dup_key;
+ delete l_key;
+ UPLL_LOG_DEBUG("validate Capability Failed %d", result_code);
+ return result_code;
+ }
+
// 1.Getting renamed name if renamed
result_code = GetRenamedControllerKey(l_key, req->datatype,
dmi, &ctrlr_dom);
UPLL_LOG_DEBUG("SendReqToDriver failed for Key %d controller %s",
l_key->get_key_type(),
reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_DEBUG("Driver response for Key %d controller %s result %d",
l_key->get_key_type(), ctrlr_dom.ctrlr,
ipc_resp.header.result_code);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
return ipc_resp.header.result_code;
}
ConfigKeyVal *okey = NULL;
result_code = ConstructReadDetailResponse(dup_key,
ipc_resp.ckv_data,
- dmi, &okey);
+ &okey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ConstructReadDetailResponse error code (%d)",
result_code);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
return result_code;
} else {
if (okey != NULL) {
ikey->ResetWith(okey);
+ DELETE_IF_NOT_NULL(okey);
}
}
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
DELETE_IF_NOT_NULL(dup_key);
DELETE_IF_NOT_NULL(l_key);
}
break;
default:
+ UPLL_LOG_DEBUG("Operation Not Allowed");
result_code = UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
return result_code;
GET_USER_DATA_CTRLR_DOMAIN(dup_key, ctrlr_dom);
SET_USER_DATA_CTRLR_DOMAIN(l_key, ctrlr_dom);
+ //Added CApaCheck
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(ctrlr_dom.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ delete dup_key;
+ delete l_key;
+ UPLL_LOG_DEBUG("validate Capability Failed %d", result_code);
+ return result_code;
+ }
+
// 1.Getting renamed name if renamed
result_code = GetRenamedControllerKey(l_key, req->datatype, dmi,
&ctrlr_dom);
result_code = ConstructReadDetailResponse(tmp_key,
ipc_resp.ckv_data,
- dmi, &okey);
+ &okey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ConstructReadDetailResponse error code (%d)",
return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
}
+#if 0
upll_rc_t VbrFlowFilterEntryMoMgr::UpdateConfigStatus(ConfigKeyVal *key,
unc_keytype_operation_t op, uint32_t driver_result, ConfigKeyVal *upd_key,
DalDmlIntf *dmi, ConfigKeyVal *ctrlr_key) {
UPLL_LOG_DEBUG("Update Config Status Successfull.");
return result_code;
}
+#endif
upll_rc_t VbrFlowFilterEntryMoMgr::GetControllerId(ConfigKeyVal *ikey,
DalDmlIntf *dmi) {
MoMgrImpl *mgr =
reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
UNC_KT_VBRIDGE)));
+ if (NULL == mgr) {
+ UPLL_LOG_DEBUG("mgr is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
result_code = mgr->GetChildConfigKey(temp, ikey);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetChildConfigKey Failed %d", result_code);
DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutCtrlr};
result_code = mgr->ReadConfigDB(temp, UPLL_DT_CANDIDATE, UNC_OP_READ,
dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(temp);
+ return result_code;
+ }
val_vbr *ival = reinterpret_cast<val_vbr *>(GetVal(temp));
if (!ival) {
- delete temp;
- return UPLL_RC_ERR_GENERIC;
- }
- #if 0 // TODO(pranjal)
- if (!ival->controller_id) {
- UPLL_LOG_DEBUG("Controller Id is not valid");
- free(vbr_val);
+ DELETE_IF_NOT_NULL(temp);
return UPLL_RC_ERR_GENERIC;
}
- #endif
SET_USER_DATA_CTRLR(ikey, ival->controller_id);
UPLL_LOG_DEBUG("GetController Id is Successfull");
- free(ival);
+ DELETE_IF_NOT_NULL(temp);
return UPLL_RC_SUCCESS;
}
UPLL_LOG_DEBUG("Input Key Not Valid");
return UPLL_RC_ERR_GENERIC;
}
- if (UNC_KT_VBR_FLOWFILTER_ENTRY == ikey->get_key_type()) {
- key_rename_vnode_info *key_rename = NULL;
- key_rename = reinterpret_cast<key_rename_vnode_info *> (ikey->get_key());
- key_vbr_flowfilter_entry_t * key_vbr_ff_entry =
+ key_rename_vnode_info *key_rename = NULL;
+ key_rename = reinterpret_cast<key_rename_vnode_info *> (ikey->get_key());
+ key_vbr_flowfilter_entry_t * key_vbr_ff_entry =
reinterpret_cast<key_vbr_flowfilter_entry_t *>
(ConfigKeyVal::Malloc(sizeof(key_vbr_flowfilter_entry_t)));
- if (!strlen(reinterpret_cast<char *> (key_rename->old_unc_vtn_name))) {
- UPLL_LOG_DEBUG("String Length not Valid to Perform the Operation");
- free(key_vbr_ff_entry);
+ if (!strlen(reinterpret_cast<char *> (key_rename->old_unc_vtn_name))) {
+ UPLL_LOG_DEBUG("old_unc_vtn_name NULL");
+ if (key_vbr_ff_entry) free(key_vbr_ff_entry);
return UPLL_RC_ERR_GENERIC;
- }
-
- uuu::upll_strncpy(key_vbr_ff_entry->flowfilter_key.vbr_key.vtn_key.vtn_name,
+ }
+ uuu::upll_strncpy(key_vbr_ff_entry->flowfilter_key.vbr_key.vtn_key.vtn_name,
key_rename->old_unc_vtn_name,
(kMaxLenVtnName + 1));
- if (ikey->get_key_type() == table[MAINTBL]->get_key_type()) {
- if (!strlen(reinterpret_cast<char *> (key_rename->old_unc_vnode_name))) {
- free(key_vbr_ff_entry);
- return UPLL_RC_ERR_GENERIC;
- }
+ if (ikey->get_key_type() == UNC_KT_VBRIDGE) {
+ if (!strlen(reinterpret_cast<char *> (key_rename->old_unc_vnode_name))) {
+ UPLL_LOG_DEBUG("old_unc_vnode_name NULL");
+ free(key_vbr_ff_entry);
+ return UPLL_RC_ERR_GENERIC;
+ }
- uuu::upll_strncpy(key_vbr_ff_entry->flowfilter_key.vbr_key.vbridge_name,
+ uuu::upll_strncpy(key_vbr_ff_entry->flowfilter_key.vbr_key.vbridge_name,
key_rename->old_unc_vnode_name,
(kMaxLenVnodeName + 1));
+ } else {
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_unc_vnode_name))) {
+ UPLL_LOG_DEBUG("new_unc_vnode_name NULL");
+ free(key_vbr_ff_entry);
+ return UPLL_RC_ERR_GENERIC;
}
+ uuu::upll_strncpy(key_vbr_ff_entry->flowfilter_key.vbr_key.vbridge_name,
+ key_rename->new_unc_vnode_name, (kMaxLenVnodeName + 1));
+ }
- okey = new ConfigKeyVal(UNC_KT_VBR_FLOWFILTER_ENTRY,
+ okey = new ConfigKeyVal(UNC_KT_VBR_FLOWFILTER_ENTRY,
IpctSt::kIpcStKeyVbrFlowfilterEntry,
key_vbr_ff_entry, NULL);
+ if (!okey) {
+ UPLL_LOG_DEBUG("CopyToConfigKey okey NULL");
+ free(key_vbr_ff_entry);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ return result_code;
+}
+
+upll_rc_t VbrFlowFilterEntryMoMgr::UpdateVnodeVal(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t data_type,
+ bool &no_rename) {
+ UPLL_FUNC_TRACE;
+ ConfigKeyVal *okey = NULL;
+ ConfigKeyVal *kval = NULL;
+ //ConfigKeyVal *ckval = NULL;
+ controller_domain ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
- } else if (UNC_KT_FLOWLIST == ikey->get_key_type()) {
- key_rename_vnode_info_t *key_rename =
+ uint8_t rename = 0;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ if (ikey->get_key_type() == UNC_KT_VROUTER) {
+ UPLL_LOG_DEBUG("vrouter key type");
+ return result_code;
+ }
+ key_rename_vnode_info_t *key_rename =
reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
- val_flowfilter_entry_t *val = reinterpret_cast<val_flowfilter_entry_t*>
- (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_t)));
- uuu::upll_strncpy(val->flowlist_name,
- key_rename->old_flowlist_name,
- (kMaxLenFlowListName+1));
+ //copy the olf flowlist name to val_flowfilter_entry
+ val_flowfilter_entry_t *val_ff_entry = reinterpret_cast<val_flowfilter_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_t)));
- val->valid[UPLL_IDX_FLOWLIST_PPE] = UNC_VF_VALID;
+ if (ikey->get_key_type() == UNC_KT_FLOWLIST) {
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_flowlist_name))) {
+ if (val_ff_entry) free(val_ff_entry);
+ return UPLL_RC_ERR_GENERIC;
+ }
- ConfigVal *ckv = new ConfigVal(IpctSt::kIpcStValFlowfilterEntry, val);
- okey = new ConfigKeyVal(UNC_KT_VBR_FLOWFILTER_ENTRY,
- IpctSt::kIpcStKeyVbrFlowfilterEntry, NULL, ckv);
- } else {
- UPLL_LOG_DEBUG("CopyToConfigKey invalid key type NULL");
- return UPLL_RC_ERR_GENERIC;
+ uuu::upll_strncpy(val_ff_entry->flowlist_name,
+ key_rename->old_flowlist_name,
+ (kMaxLenFlowListName + 1));
+ val_ff_entry->valid[UPLL_IDX_FLOWLIST_NAME_FFE] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("valid and flowlist name (%d) (%s)",
+ val_ff_entry->valid[UPLL_IDX_FLOWLIST_NAME_FFE],
+ val_ff_entry->flowlist_name);
+ } else if (ikey->get_key_type() == UNC_KT_VBRIDGE) {
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vnode_name))) {
+ UPLL_LOG_DEBUG("key_rename->old_unc_vnode_name NULL");
+ if (val_ff_entry) free(val_ff_entry);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(val_ff_entry->redirect_node,
+ key_rename->old_unc_vnode_name,
+ (kMaxLenFlowListName + 1));
+ val_ff_entry->valid[UPLL_IDX_REDIRECT_NODE_FFE] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("valid and vbridge name (%d) (%s)",
+ val_ff_entry->valid[UPLL_IDX_REDIRECT_NODE_FFE],
+ val_ff_entry->redirect_node);
+ }
+
+ result_code = GetChildConfigKey(okey, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("CopyToConfigKey okey NULL");
+ FREE_IF_NOT_NULL(val_ff_entry);
+ return result_code;
+ }
+ if (!okey) {
+ UPLL_LOG_DEBUG("CopyToConfigKey okey NULL");
+ free(val_ff_entry);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ okey->SetCfgVal(new ConfigVal(IpctSt::kIpcStValFlowfilterEntry, val_ff_entry));
+
+ //ConfigVal *cval = new ConfigVal(IpctSt::kIpcStValFlowfilterEntry, val_ff_entry);
+ //okey = new ConfigKeyVal(UNC_KT_VBR_FLOWFILTER_ENTRY, IpctSt::kIpcStKeyVbrFlowfilterEntry, NULL, cval);
+ //if (!okey) {
+ // UPLL_LOG_DEBUG("CopyToConfigKey okey NULL");
+ // if (val_ff_entry) free(val_ff_entry);
+ // return UPLL_RC_ERR_GENERIC;
+ // }
+
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain|kOpInOutFlag };
+
+ // Read the record of key structure and old flowlist name in maintbl
+ result_code = ReadConfigDB(okey, data_type, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG(" pran ReadConfigDB failed ");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ GET_USER_DATA_FLAGS(okey, rename);
+ ConfigKeyVal *first_ckv = okey;
+ while (okey != NULL) {
+ result_code = GetChildConfigKey(kval, okey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey kval NULL");
+ DELETE_IF_NOT_NULL(first_ckv);
+ return result_code;
+ }
+ if (!kval) return UPLL_RC_ERR_GENERIC;
+ // Copy the new flowlist name in val_flowfilter_entry
+ val_flowfilter_entry_t *val_ff_entry_new = reinterpret_cast<val_flowfilter_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_t)));
+ if (!val_ff_entry_new) return UPLL_RC_ERR_GENERIC;
+ if (ikey->get_key_type() == UNC_KT_FLOWLIST) {
+ // New Name NuLL CHECK
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_flowlist_name))) {
+ if (val_ff_entry_new) free(val_ff_entry_new);
+ UPLL_LOG_DEBUG("new_flowlist_name NULL");
+ DELETE_IF_NOT_NULL(first_ckv);
+ DELETE_IF_NOT_NULL(kval);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ // Copy the new flowlist_name into val_flowfilter_entry
+ uuu::upll_strncpy(val_ff_entry_new->flowlist_name,
+ key_rename->new_flowlist_name,
+ (kMaxLenFlowListName + 1));
+ val_ff_entry_new->valid[UPLL_IDX_FLOWLIST_NAME_FFE] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("flowlist name and valid (%d) (%s)",
+ val_ff_entry_new->valid[UPLL_IDX_FLOWLIST_NAME_FFE],
+ val_ff_entry_new->flowlist_name);
+ } else if (ikey->get_key_type() == UNC_KT_VBRIDGE) {
+ // New Name NuLL CHECK
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_unc_vnode_name))) {
+ UPLL_LOG_DEBUG("new_unc_vnode_name NULL");
+ if (val_ff_entry_new) free(val_ff_entry_new);
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(first_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ // Copy the new vbridge name into val_flowfilter_entry
+ uuu::upll_strncpy(val_ff_entry_new->redirect_node,
+ key_rename->new_unc_vnode_name,
+ (kMaxLenFlowListName + 1));
+ val_ff_entry_new->valid[UPLL_IDX_REDIRECT_NODE_FFE] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("vbridge name and valid (%d) (%s)",
+ val_ff_entry_new->valid[UPLL_IDX_FLOWLIST_NAME_FFE],
+ val_ff_entry_new->redirect_node);
+
+ }
+ ConfigVal *cval1 = new ConfigVal(IpctSt::kIpcStValFlowfilterEntry,
+ val_ff_entry_new);
+
+ kval->SetCfgVal(cval1);
+
+ memset(&ctrlr_dom, 0, sizeof(controller_domain));
+ result_code = GetControllerDomainID(okey, &ctrlr_dom, UPLL_DT_IMPORT, dmi);
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get the Controller Domain details, err:%d",
+ result_code);
+ }
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ GET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
+ if (ikey->get_key_type() == UNC_KT_FLOWLIST) {
+ if (!no_rename)
+ rename = rename | FLOW_RENAME;
+ else
+ rename = rename & NO_FLOWLIST_RENAME;
+ } else if (ikey->get_key_type() == UNC_KT_VBRIDGE) {
+ if (!no_rename)
+ rename = rename | VBR_RENAME_FLAG;
+ else
+ rename = rename & NO_VBR_RENAME_FLAG;
+ }
+
+ SET_USER_DATA_FLAGS(kval, rename);
+ SET_USER_DATA_CTRLR_DOMAIN(kval, ctrlr_dom);
+
+ // Update the new flowlist name in MAINTBL
+ result_code = UpdateConfigDB(kval, data_type, UNC_OP_UPDATE, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Update The Existing record Err in vbrflowfilterentrytbl CANDIDATE DB(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(first_ckv);
+ DELETE_IF_NOT_NULL(kval);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(kval);
+
+ okey = okey->get_next_cfg_key_val();
}
+
+ DELETE_IF_NOT_NULL(first_ckv);
+ UPLL_LOG_DEBUG("UpdateVnodeVal result_code (%d)", result_code);
return result_code;
}
bool VbrFlowFilterEntryMoMgr::CompareValidValue(void *&val1, void *val2,
- bool audit) {
+ bool copy_to_running) {
UPLL_FUNC_TRACE;
+ bool attr = true;
val_flowfilter_entry_t *val_ff_entry1 =
reinterpret_cast<val_flowfilter_entry_t *>(val1);
val_flowfilter_entry_t *val_ff_entry2 =
reinterpret_cast<val_flowfilter_entry_t *>(val2);
- // if (audit) {
- for ( unsigned int loop = 0; loop < (sizeof(val_ff_entry1->valid)/
- sizeof(val_ff_entry1->valid[0])) ; ++loop ) {
- if ( UNC_VF_INVALID == val_ff_entry1->valid[loop] &&
- UNC_VF_VALID == val_ff_entry2->valid[loop])
- val_ff_entry1->valid[loop] = UNC_VF_VALID_NO_VALUE;
- }
- // }
+ for ( unsigned int loop = 0; loop < (sizeof(val_ff_entry1->valid)/
+ sizeof(val_ff_entry1->valid[0])) ; ++loop ) {
+ if ( UNC_VF_INVALID == val_ff_entry1->valid[loop] &&
+ UNC_VF_VALID == val_ff_entry2->valid[loop])
+ val_ff_entry1->valid[loop] = UNC_VF_VALID_NO_VALUE;
+ }
if (val_ff_entry1->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID
&& val_ff_entry2->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
}
if (val_ff_entry1->valid[UPLL_IDX_ACTION_FFE] == UNC_VF_VALID &&
val_ff_entry2->valid[UPLL_IDX_ACTION_FFE] == UNC_VF_VALID) {
- if (val_ff_entry1->action != val_ff_entry2->action)
+ if (val_ff_entry1->action == val_ff_entry2->action)
val_ff_entry1->valid[UPLL_IDX_ACTION_FFE] = UNC_VF_INVALID;
}
if (val_ff_entry1->valid[UPLL_IDX_REDIRECT_NODE_FFE] == UNC_VF_VALID
&& val_ff_entry2->valid[UPLL_IDX_REDIRECT_NODE_FFE] == UNC_VF_VALID) {
- if (reinterpret_cast<char *>(val_ff_entry1->redirect_node) !=
- reinterpret_cast<const char *>(val_ff_entry2->redirect_node))
- val_ff_entry1->valid[UPLL_IDX_REDIRECT_NODE_FFE] = UNC_VF_INVALID;
+ if (!strcmp(reinterpret_cast<char *>(val_ff_entry1->redirect_node),
+ reinterpret_cast<const char *>(val_ff_entry2->redirect_node)))
+ val_ff_entry1->valid[UPLL_IDX_REDIRECT_NODE_FFE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_ff_entry1->valid[UPLL_IDX_REDIRECT_PORT_FFE] == UNC_VF_VALID &&
val_ff_entry2->valid[UPLL_IDX_REDIRECT_PORT_FFE] == UNC_VF_VALID) {
- if (reinterpret_cast<char *>(val_ff_entry1->redirect_port) !=
- reinterpret_cast<char *>(val_ff_entry2->redirect_port))
- val_ff_entry1->valid[UPLL_IDX_REDIRECT_PORT_FFE] = UNC_VF_INVALID;
+ if (!strcmp(reinterpret_cast<char *>(val_ff_entry1->redirect_port),
+ reinterpret_cast<char *>(val_ff_entry2->redirect_port)))
+ val_ff_entry1->valid[UPLL_IDX_REDIRECT_PORT_FFE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_ff_entry1->valid[UPLL_IDX_MODIFY_DST_MAC_FFE] == UNC_VF_VALID &&
val_ff_entry2->valid[UPLL_IDX_MODIFY_DST_MAC_FFE] == UNC_VF_VALID) {
- if (reinterpret_cast<char *>(val_ff_entry1->modify_dstmac) !=
- reinterpret_cast<char *>(val_ff_entry2->modify_dstmac))
- val_ff_entry1->valid[UPLL_IDX_MODIFY_DST_MAC_FFE] = UNC_VF_INVALID;
+ if (!memcmp(reinterpret_cast<char *>(val_ff_entry1->modify_dstmac),
+ reinterpret_cast<char *>(val_ff_entry2->modify_dstmac),
+ sizeof(val_ff_entry2->modify_dstmac)))
+ val_ff_entry1->valid[UPLL_IDX_MODIFY_DST_MAC_FFE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_ff_entry1->valid[UPLL_IDX_MODIFY_SRC_MAC_FFE] == UNC_VF_VALID &&
val_ff_entry2->valid[UPLL_IDX_MODIFY_SRC_MAC_FFE] == UNC_VF_VALID) {
- if (reinterpret_cast<char *>(val_ff_entry1->modify_srcmac) !=
- reinterpret_cast<char *>(val_ff_entry2->modify_srcmac))
- val_ff_entry1->valid[UPLL_IDX_MODIFY_SRC_MAC_FFE] = UNC_VF_INVALID;
+ if (!memcmp(reinterpret_cast<char *>(val_ff_entry1->modify_srcmac),
+ reinterpret_cast<char *>(val_ff_entry2->modify_srcmac),
+ sizeof(val_ff_entry2->modify_srcmac)))
+ val_ff_entry1->valid[UPLL_IDX_MODIFY_SRC_MAC_FFE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_ff_entry1->valid[UPLL_IDX_NWM_NAME_FFE] == UNC_VF_VALID &&
val_ff_entry2->valid[UPLL_IDX_NWM_NAME_FFE] == UNC_VF_VALID) {
}
if (val_ff_entry1->valid[UPLL_IDX_DSCP_FFE] == UNC_VF_VALID &&
val_ff_entry2->valid[UPLL_IDX_DSCP_FFE] == UNC_VF_VALID) {
- if (val_ff_entry1->dscp != val_ff_entry2->dscp)
+ if (val_ff_entry1->dscp == val_ff_entry2->dscp)
val_ff_entry1->valid[UPLL_IDX_DSCP_FFE] = UNC_VF_INVALID;
}
if (val_ff_entry1->valid[UPLL_IDX_PRIORITY_FFE] == UNC_VF_VALID &&
val_ff_entry2->valid[UPLL_IDX_PRIORITY_FFE] == UNC_VF_VALID) {
- if (val_ff_entry1->priority != val_ff_entry2->priority)
+ if (val_ff_entry1->priority == val_ff_entry2->priority)
val_ff_entry1->valid[UPLL_IDX_PRIORITY_FFE] = UNC_VF_INVALID;
}
- return false;
-}
-upll_rc_t VbrFlowFilterEntryMoMgr::ReadDetailEntry(
- ConfigKeyVal *ff_ckv, upll_keytype_datatype_t dt_type,
- DbSubOp dbop, DalDmlIntf *dmi
- ) {
- upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
- if (NULL == ff_ckv) {
- return UPLL_RC_ERR_GENERIC;
+ for (unsigned int loop = 0;
+ loop < sizeof(val_ff_entry1->valid)/ sizeof(uint8_t); ++loop) {
+ if ((UNC_VF_VALID == (uint8_t) val_ff_entry1->valid[loop]) ||
+ (UNC_VF_VALID_NO_VALUE == (uint8_t) val_ff_entry1->valid[loop]))
+ attr = false;
}
-
- // SET_USER_DATA_DOMAIN(ff_ckv, domain_id);
- // SET_USER_DATA_CTRLR(ff_ckv, ctrlr_id);
-
- result_code = ReadConfigDB(ff_ckv, dt_type, UNC_OP_READ, dbop, dmi, MAINTBL);
- return result_code;
+ return attr;
}
+
upll_rc_t VbrFlowFilterEntryMoMgr::ConstructReadDetailResponse(
ConfigKeyVal *ikey,
ConfigKeyVal *drv_resp_ckv,
- DalDmlIntf *dmi,
ConfigKeyVal **okey) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *tmp_okey = NULL;
- DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone };
-
result_code = GetChildConfigKey(tmp_okey, ikey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetChildConfigKey failed err code (%d)", result_code);
return result_code;
}
- result_code = ReadConfigDB(tmp_okey, UPLL_DT_RUNNING, UNC_OP_READ,
- dbop, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ReadConfigDB error (%d)", result_code);
- delete tmp_okey;
- return result_code;
- }
-
- ConfigVal *drv_resp_val = NULL;
- drv_resp_val = drv_resp_ckv->get_cfg_val();
- while (drv_resp_val != NULL) {
- if (IpctSt::kIpcStValFlowfilterEntrySt != drv_resp_val->get_st_num()) {
- UPLL_LOG_DEBUG("Incorrect structure received from driver, struct num %d",
- drv_resp_val->get_st_num());
- return UPLL_RC_ERR_GENERIC;
- }
- val_flowfilter_entry_st_t *tmp_ffe_st =
- reinterpret_cast<val_flowfilter_entry_st_t*>
- (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_st_t)));
- memcpy(tmp_ffe_st,
- reinterpret_cast<val_flowfilter_entry_st_t *>
- (drv_resp_val->get_val()),
- sizeof(val_flowfilter_entry_st_t));
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowfilterEntrySt, tmp_ffe_st);
-
- if ((drv_resp_val = drv_resp_val->get_next_cfg_val()) == NULL) {
- UPLL_LOG_DEBUG("No more entries in driver response\n");
- break;
- }
-
- if (IpctSt::kIpcStValFlowlistEntrySt != (drv_resp_val)->get_st_num()) {
- UPLL_LOG_DEBUG("No flowflist entries returned by driver");
- continue;
- }
-
- while (IpctSt::kIpcStValFlowlistEntrySt == drv_resp_val->get_st_num()) {
- val_flowlist_entry_st_t* tmp_val_fl_st =
- reinterpret_cast<val_flowlist_entry_st_t*>
- (ConfigKeyVal::Malloc(sizeof(val_flowlist_entry_st_t)));
- memcpy(tmp_val_fl_st,
- reinterpret_cast<val_flowlist_entry_st_t*>
- (drv_resp_val->get_val()),
- sizeof(val_flowlist_entry_st_t));
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowlistEntrySt,
- tmp_val_fl_st);
- drv_resp_val = drv_resp_val->get_next_cfg_val();
- if (!drv_resp_val) {
- break;
- }
- }
- }
+ tmp_okey->AppendCfgVal(drv_resp_ckv->GetCfgValAndUnlink());
if (*okey == NULL) {
*okey = tmp_okey;
} else {
UPLL_LOG_DEBUG(" Input Key is NULL");
return UPLL_RC_ERR_GENERIC;
}
-
+ DELETE_IF_NOT_NULL(okey);
unc_key_type_t ikey_type = ikey->get_key_type();
if (ikey_type != UNC_KT_VBR_FLOWFILTER_ENTRY) {
UPLL_LOG_DEBUG(" Invalid key type received. Key type - %d", ikey_type);
return UPLL_RC_SUCCESS;
}
+upll_rc_t VbrFlowFilterEntryMoMgr::DeleteChildrenPOM(
+ ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+ uint8_t *ctrlr_id = NULL;
+
+ if (NULL == ikey && NULL == dmi) {
+ UPLL_LOG_DEBUG("Request & InputKey are not are not Valid %d", result_code);
+ return result_code;
+ }
+
+ ConfigKeyVal *temp_okey = NULL;
+ result_code = GetChildConfigKey(temp_okey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ return result_code;
+ }
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr };
+ result_code = ReadConfigDB(temp_okey, UPLL_DT_CANDIDATE,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("UPLL_RC_ERR_NO_SUCH_INSTANCE");
+ result_code = UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("Unable to read configuration from CandidateDb");
+ DELETE_IF_NOT_NULL(temp_okey);
+ return result_code;
+ }
+ ConfigKeyVal *okey = temp_okey;
+ while (NULL != okey) {
+ GET_USER_DATA_CTRLR(okey, ctrlr_id);
+ val_flowfilter_entry_t *flowfilter_val =
+ reinterpret_cast<val_flowfilter_entry_t *> (GetVal(okey));
+ if (flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
+ FlowListMoMgr *mgr = reinterpret_cast<FlowListMoMgr *>
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
+ if (NULL == mgr) {
+ UPLL_LOG_DEBUG("mgr is NULL");
+ DELETE_IF_NOT_NULL(temp_okey);
+ return result_code;
+ }
+ result_code = mgr->AddFlowListToController(
+ reinterpret_cast<char *>(flowfilter_val->flowlist_name), dmi,
+ reinterpret_cast<char *>(ctrlr_id), dt_type, UNC_OP_DELETE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG(" Send delete request to flowlist failed. err code(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(temp_okey);
+ return result_code;
+ }
+ }
+ okey = okey->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(temp_okey);
+ ConfigKeyVal *temp_ikey = NULL;
+ result_code = GetChildConfigKey(temp_ikey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ return result_code;
+ }
+ result_code = UpdateConfigDB(temp_ikey, dt_type, UNC_OP_DELETE, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(temp_ikey);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(temp_ikey);
+ UPLL_LOG_DEBUG("DeleteMo Operation Done %d", result_code);
+ return result_code;
+}
+
+upll_rc_t VbrFlowFilterEntryMoMgr::SetValidAudit(ConfigKeyVal *&ikey) {
+ UPLL_FUNC_TRACE;
+ val_flowfilter_entry_t *val = reinterpret_cast
+ <val_flowfilter_entry_t *>(GetVal(ikey));
+ if (NULL == val) {
+ UPLL_LOG_DEBUG("val is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ for (unsigned int loop = 0;
+ loop < sizeof(val->valid) / sizeof(val->valid[0]);
+ ++loop) {
+ if (val->valid[loop] == UNC_VF_VALID) {
+ val->cs_attr[loop] = UNC_CS_APPLIED;
+ } else if (val->valid[loop] == UNC_VF_INVALID) {
+ val->cs_attr[loop] = UNC_CS_NOT_APPLIED;
+ }
+ }
+ val->cs_row_status = UNC_CS_APPLIED;
+ return UPLL_RC_SUCCESS;
+}
+
+
+upll_rc_t VbrFlowFilterEntryMoMgr::UpdateConfigStatus(ConfigKeyVal *vbr_key,
+ unc_keytype_operation_t op,
+ uint32_t driver_result,
+ ConfigKeyVal *upd_key,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ctrlr_key) {
+ UPLL_FUNC_TRACE;
+ ConfigKeyVal * vbr_ffe_run_key = NULL;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_flowfilter_entry_t *vbr_ffe_val = NULL, *val_main = NULL;
+
+ unc_keytype_configstatus_t cs_status =
+ (driver_result == UPLL_RC_SUCCESS) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
+ vbr_ffe_val = reinterpret_cast<val_flowfilter_entry_t *>(GetVal(vbr_key));
+ if (vbr_ffe_val == NULL) return UPLL_RC_ERR_GENERIC;
+ if (op == UNC_OP_CREATE) {
+ vbr_ffe_val->cs_row_status = cs_status;
+ } else if (op == UNC_OP_UPDATE) {
+ // For Reading The controller table for config status
+ result_code = GetChildConfigKey(vbr_ffe_run_key, vbr_key);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
+ result_code);
+ return result_code;
+ }
+ DbSubOp dbop_maintbl = { kOpReadSingle, kOpMatchNone,
+ kOpInOutFlag |kOpInOutCs };
+ result_code = ReadConfigDB(vbr_ffe_run_key, UPLL_DT_RUNNING ,
+ UNC_OP_READ, dbop_maintbl, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to read configuration from RunningDb");
+ DELETE_IF_NOT_NULL(vbr_ffe_run_key);
+ return result_code;
+ }
+ val_main = reinterpret_cast
+ <val_flowfilter_entry_t *>(GetVal(vbr_ffe_run_key));
+ for (unsigned int loop = 0; loop < sizeof(val_main->valid)/
+ sizeof(val_main->valid[0]); ++loop) {
+ vbr_ffe_val->cs_attr[loop] = val_main->cs_attr[loop];
+ }
+ void *vbrffeval = reinterpret_cast<void *>(vbr_ffe_val);
+ CompareValidValue(vbrffeval, GetVal(upd_key), true);
+ } else {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_TRACE("%s",(vbr_key->ToStrAll()).c_str());
+ val_flowfilter_entry_t *vbr_ffe_val2 =
+ reinterpret_cast<val_flowfilter_entry_t *>(GetVal(upd_key));
+ if (UNC_OP_UPDATE == op) {
+ UPLL_LOG_TRACE("%s",(upd_key->ToStrAll()).c_str());
+ vbr_ffe_val->cs_row_status = vbr_ffe_val2->cs_row_status;
+ }
+ for (unsigned int loop = 0;
+ loop < sizeof(vbr_ffe_val->valid) /
+ sizeof(vbr_ffe_val->valid[0]); ++loop) {
+ /* Setting CS to the not supported attributes*/
+ if (UNC_VF_NOT_SUPPORTED == vbr_ffe_val->valid[loop]) {
+ vbr_ffe_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
+ } else if ((UNC_VF_VALID == vbr_ffe_val->valid[loop])
+ || (UNC_VF_VALID_NO_VALUE == vbr_ffe_val->valid[loop])) {
+ vbr_ffe_val->cs_attr[loop] = cs_status;
+ } else if ((UNC_VF_INVALID == vbr_ffe_val->valid[loop]) &&
+ (UNC_OP_CREATE == op)) {
+ vbr_ffe_val->cs_attr[loop] = UNC_CS_NOT_APPLIED;
+ } else if ((UNC_VF_INVALID == vbr_ffe_val->valid[loop]) &&
+ (UNC_OP_UPDATE == op)) {
+ if (val_main->valid[loop] == UNC_VF_VALID) {
+ if (cs_status == UNC_CS_APPLIED) {
+ vbr_ffe_val->cs_attr[loop] = cs_status;
+ }
+ }
+ } else if ((UNC_VF_VALID == vbr_ffe_val->valid[loop]) &&
+ (UNC_OP_UPDATE == op)) {
+ if (cs_status == UNC_CS_APPLIED) {
+ vbr_ffe_val->cs_attr[loop] = UNC_CS_APPLIED;
+ }
+ }
+ if ((vbr_ffe_val->valid[loop] == UNC_VF_VALID_NO_VALUE)
+ &&(UNC_OP_UPDATE == op)) {
+ vbr_ffe_val->cs_attr[loop] = UNC_CS_UNKNOWN;
+ }
+ }
+ DELETE_IF_NOT_NULL(vbr_ffe_run_key);
+ return result_code;
+}
+
+bool VbrFlowFilterEntryMoMgr::FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op) {
+ UPLL_FUNC_TRACE;
+ if (op != UNC_OP_CREATE)
+ return CompareValidValue(val1, val2, copy_to_running);
+ return false;
+}
+
+upll_rc_t VbrFlowFilterEntryMoMgr::SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_flowfilter_entry_t *val_ffe = reinterpret_cast
+ <val_flowfilter_entry_t *>(GetVal(ikey));
+ if (!val_ffe) {
+ UPLL_LOG_DEBUG("Val is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigKeyVal *pkey = NULL;
+ if (UNC_OP_CREATE == req->operation) {
+ result_code = GetParentConfigKey(pkey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetParentConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_VBR_FLOWFILTER)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("mgr is NULL");
+ DELETE_IF_NOT_NULL(pkey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t rename = 0;
+ result_code = mgr->IsRenamed(pkey, req->datatype, dmi, rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(pkey);
+ return result_code;
+ }
+ UPLL_LOG_DEBUG("Flag from parent : %d", rename);
+ DELETE_IF_NOT_NULL(pkey);
+ // Check flowlist is renamed
+ if ((UNC_VF_VALID == val_ffe->valid[UPLL_IDX_FLOWLIST_NAME_FFE]) &&
+ ((UNC_OP_CREATE == req->operation))) {
+ ConfigKeyVal *fl_ckv = NULL;
+ result_code = GetFlowlistConfigKey(reinterpret_cast<const char *>
+ (val_ffe->flowlist_name), fl_ckv, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetFlowlistConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *fl_mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_FLOWLIST)));
+ if (NULL == fl_mgr) {
+ UPLL_LOG_DEBUG("fl_mgr is NULL");
+ DELETE_IF_NOT_NULL(fl_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t fl_rename = 0;
+ result_code = fl_mgr->IsRenamed(fl_ckv, req->datatype, dmi, fl_rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(fl_ckv);
+ return result_code;
+ }
+ if (fl_rename & 0x01) {
+ rename |= FLOW_RENAME; // TODO Check for correct flag value
+ }
+ DELETE_IF_NOT_NULL(fl_ckv);
+ }
+ SET_USER_DATA_FLAGS(ikey, rename);
+ } else if (UNC_OP_UPDATE == req->operation) {
+ uint8_t rename = 0;
+ result_code = IsRenamed(ikey, req->datatype, dmi, rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ return result_code;
+ }
+ if (UNC_VF_VALID == val_ffe->valid[UPLL_IDX_FLOWLIST_NAME_FFE]) {
+ ConfigKeyVal *fl_ckv = NULL;
+ result_code = GetFlowlistConfigKey(reinterpret_cast<const char *>
+ (val_ffe->flowlist_name), fl_ckv, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetFlowlistConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *fl_mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_FLOWLIST)));
+ if (NULL == fl_mgr) {
+ UPLL_LOG_DEBUG("fl_mgr is NULL");
+ DELETE_IF_NOT_NULL(fl_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t fl_rename = 0;
+ result_code = fl_mgr->IsRenamed(fl_ckv, req->datatype, dmi, fl_rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(fl_ckv);
+ return result_code;
+ }
+ if (fl_rename & 0x01) {
+ rename |= FLOW_RENAME; // TODO Check for correct flag value
+ } else {
+ rename &= NO_FLOWLIST_RENAME;
+ /* reset flag*/
+ }
+ DELETE_IF_NOT_NULL(fl_ckv);
+ } else if (UNC_VF_VALID_NO_VALUE == val_ffe->valid
+ [UPLL_IDX_FLOWLIST_NAME_FFE]) {
+ rename &= NO_FLOWLIST_RENAME; // TODO Check for correct flag value. No rename flowlist value should be set
+ }
+ SET_USER_DATA_FLAGS(ikey, rename);
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VbrFlowFilterEntryMoMgr::GetFlowlistConfigKey(
+ const char *flowlist_name, ConfigKeyVal *&okey,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_FLOWLIST)));
+ result_code = mgr->GetChildConfigKey(okey, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
+ return result_code;
+ }
+ key_flowlist_t *okey_key = reinterpret_cast<key_flowlist_t *>
+ (okey->get_key());
+ uuu::upll_strncpy(okey_key->flowlist_name,
+ flowlist_name,
+ (kMaxLenFlowListName+1));
+ return UPLL_RC_SUCCESS;
+}
} // namespace kt_momgr
} // namespace upll
} // namespace unc
* @brief Member Variable for FlowListRenameBindInfo.
*/
static BindInfo vbr_flowlist_rename_bind_info[];
+ uint32_t cur_instance_count;
public:
/**
DalDmlIntf *dmi,
IpcReqRespHeader *req = NULL);
+ upll_rc_t VerifyRedirectDestination(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t dt_type);
+
+ upll_rc_t TxVote(unc_key_type_t keytype,
+ DalDmlIntf *dmi,
+ ConfigKeyVal **err_ckv);
/**
* @Brief Validates the syntax of the specified key and value structure
* for KT_VBR_FLOWFILTER_ENTRY keytype
unc_keytype_operation_t operation);
upll_rc_t GetControllerDomainID(ConfigKeyVal *ikey,
- controller_domain *ctrlr_dom,
- upll_keytype_datatype_t dt_type,
- DalDmlIntf *dmi);
+ controller_domain *ctrlr_dom,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi);
/**
* @Brief Validates the syntax for val_flowfilter_entry structure.
*
* @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
* @retval UPLL_RC_ERR_GENERIC Generic failure.
*/
- upll_rc_t ValFlowFilterEntryAttributeSupportCheck(
+ static upll_rc_t ValFlowFilterEntryAttributeSupportCheck(
val_flowfilter_entry_t *val_flowfilter_entry, const uint8_t* attrs);
/**
*
* @return No Return Value;
*/
- bool CompareValidValue(void *&val1, void *val2, bool audit);
+ bool CompareValidValue(void *&val1, void *val2, bool copy_to_running);
+
+ /**
+ * @brief Method used for Restoring FlowList in the Controller Table
+ *
+ * @param[in] ikey Pointer to ConfigKeyVal Class
+ * @param[in] dt_type Describes Configiration Information.
+ * @param[in] tbl Describe the destination table
+ * @param[in] dmi Pointer to DalDmlIntf Class.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_DB_ACCESS DB Read/Write error.
+ * @retval UPLL_RC_ERR_INSTANCE_EXISTS Record already exists
+ * @retval UPLL_RC_ERR_GENERIC Returned Generic Error.
+ */
+
+ upll_rc_t RestorePOMInCtrlTbl(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl,
+ DalDmlIntf* dmi);
upll_rc_t ReadSiblingMo(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
bool begin,
upll_rc_t GetParentConfigKey(ConfigKeyVal *&okey,
ConfigKeyVal *ikey);
- upll_rc_t ReadDetailEntry(
- ConfigKeyVal *ff_ckv, upll_keytype_datatype_t dt_type,
- DbSubOp dbop, DalDmlIntf *dmi);
+ upll_rc_t CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id);
/**
* @brief Method to check validity of Key
*
bool IsValidKey(void *key, uint64_t index);
upll_rc_t ConstructReadDetailResponse(ConfigKeyVal *ikey,
ConfigKeyVal *drv_resp_ckv,
- DalDmlIntf *dmi,
ConfigKeyVal **okey);
+
+ upll_rc_t DeleteChildrenPOM(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi);
+
+ upll_rc_t SetValidAudit(ConfigKeyVal *&ikey);
+
+ upll_rc_t UpdateVnodeVal(ConfigKeyVal *ikey, DalDmlIntf *dmi,
+ upll_keytype_datatype_t data_type,
+ bool &no_rename);
+
+ bool FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op);
+
+ upll_rc_t GetFlowlistConfigKey(
+ const char *flowlist_name, ConfigKeyVal *&okey,
+ DalDmlIntf *dmi);
+
+ upll_rc_t SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req);
};
} // namespace kt_momgr
} // namespace upll
#include "vbr_flowfilter_entry_momgr.hh"
#include "vbr_momgr.hh"
#include "upll_validation.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
namespace unc {
namespace upll {
namespace kt_momgr {
using unc::upll::ipc_util::IpcUtil;
-#define NUM_KEY_MAIN_TBL 6
#define VTN_RENAME_FLAG 0x01
-#define VBR_RENAME_FLAG 0x10
+#define VBR_RENAME_FLAG 0x02
// VbrFlowFilterMoMgr Table(Main Table)
BindInfo VbrFlowFilterMoMgr::vbr_flowfilter_bind_info[] = {
{ uudst::vbr_flowfilter::kDbiVbrName, CFG_MATCH_KEY,
offsetof(key_vbr_flowfilter_t, vbr_key.vbridge_name),
uud::kDalChar, (kMaxLenVnodeName + 1) },
- { uudst::vbr_flowfilter::kDbiInputDirection, CFG_MATCH_KEY,
- offsetof(key_vbr_flowfilter_t, direction),
- uud::kDalUint8, 1 },
{ uudst::vbr_flowfilter::kDbiVtnName, CFG_INPUT_KEY,
offsetof(key_rename_vnode_info_t, new_unc_vtn_name),
uud::kDalChar, (kMaxLenVtnName + 1) },
{ uudst::vbr_flowfilter::kDbiVbrName, CFG_INPUT_KEY, offsetof(
key_rename_vnode_info_t, new_unc_vnode_name),
uud::kDalChar, (kMaxLenVnodeName + 1) },
- { uudst::vbr_flowfilter::kDbiFlags, CFG_INPUT_KEY,
+ { uudst::vbr_flowfilter::kDbiFlags, CK_VAL, // changed
offsetof(key_user_data_t, flags),
uud::kDalUint8, 1}
};
nchild = sizeof(vbr_flowfilter_child) / sizeof(vbr_flowfilter_child[0]);
child = vbr_flowfilter_child;
+ cur_instance_count = 0;
}
bool VbrFlowFilterMoMgr::GetRenameKeyBindInfo(unc_key_type_t key_type,
int &nattr,
MoMgrTables tbl) {
UPLL_FUNC_TRACE;
- if (UNC_KT_VBR_FLOWFILTER == key_type) {
- // Main Table only update
- if (MAINTBL == tbl) {
- nattr = NUM_KEY_MAIN_TBL;
- binfo = vbr_flowfilter_maintbl_bind_info;
- } else {
- return PFC_FALSE;
- }
- }
+ nattr = sizeof(vbr_flowfilter_maintbl_bind_info)/
+ sizeof(vbr_flowfilter_maintbl_bind_info[0]);
+ binfo = vbr_flowfilter_maintbl_bind_info;
UPLL_LOG_DEBUG("Successful Completion");
return PFC_TRUE;
}
// Check if Object exists in RUNNING DB and move it to CANDIDATE DB
+ if (UPLL_DT_CANDIDATE == req->datatype) {
result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING,
UNC_OP_READ, dmi, MAINTBL);
if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
result_code = RestoreChildren(ikey, req->datatype, UPLL_DT_RUNNING, dmi);
if (result_code != UPLL_RC_SUCCESS) {
return UPLL_RC_ERR_GENERIC;
+ }
}
- } else if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ }
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
// create a record in CANDIDATE DB
VbrMoMgr *mgrvbr =
reinterpret_cast<VbrMoMgr *>(const_cast<MoManager *>(GetMoManager(
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Unable to Read the details from DB for the parent err %d",
result_code);
+ DELETE_IF_NOT_NULL(ckv);
return result_code;
}
result_code = mgrvbr->GetControllerDomainId(ckv, &ctrlr_dom);
UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
ctrlr_dom.ctrlr, ctrlr_dom.domain);
+
+ ConfigKeyVal *tmp_key = NULL;
+ result_code = GetChildConfigKey(tmp_key, NULL);
+ if(result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed in ValidateCapability");
+ DELETE_IF_NOT_NULL(ckv);
+ return result_code;
+ }
+ result_code = GetInstanceCount(tmp_key,
+ reinterpret_cast<char*>(ctrlr_dom.ctrlr),
+ req->datatype,
+ &cur_instance_count,
+ dmi,
+ MAINTBL);
+
+ delete tmp_key; tmp_key = NULL;
+
+ if(result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetInstanceCount Failed in ValidateCapability");
+ DELETE_IF_NOT_NULL(ckv);
+ return result_code;
+ }
+
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(ctrlr_dom.ctrlr));
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("validate Capability Failed %d", result_code);
+ DELETE_IF_NOT_NULL(ckv);
+ return result_code;
+ }
+
result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_CREATE, dmi);
+ DELETE_IF_NOT_NULL(ckv);
return result_code;
} else {
- UPLL_LOG_DEBUG("Error in reading DB\n");
+ UPLL_LOG_DEBUG("Error in reading DB");
}
return result_code;
}
+upll_rc_t VbrFlowFilterMoMgr::GetControllerDomainID(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi) {
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ VbrMoMgr *mgrvbr =
+ reinterpret_cast<VbrMoMgr *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_VBRIDGE)));
+ if (NULL == mgrvbr) {
+ UPLL_LOG_DEBUG("mgrvbr is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigKeyVal *ckv = NULL;
+ result_code = mgrvbr->GetChildConfigKey(ckv, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to get the ParentConfigKey,resultcode=%d",
+ result_code);
+ return result_code;
+ }
+
+ key_vbr_flowfilter_t *ff_key = reinterpret_cast
+ <key_vbr_flowfilter_t *>(ikey->get_key());
+ key_vbr_t *vbr_key = reinterpret_cast<key_vbr_t *>(ckv->get_key());
+
+ uuu::upll_strncpy(vbr_key->vtn_key.vtn_name,
+ ff_key->vbr_key.vtn_key.vtn_name,
+ kMaxLenVtnName + 1);
+
+ uuu::upll_strncpy(vbr_key->vbridge_name,
+ ff_key->vbr_key.vbridge_name,
+ kMaxLenVnodeName + 1);
+ //Read Controller ID and Domain ID from the VBridge and set it to the
+ //Input ConfigKeyVal
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain };
+ result_code = mgrvbr->ReadConfigDB(ckv, dt_type, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to Read the details from DB for the parent err %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv);
+ return result_code;
+ }
+
+ controller_domain ctrlr_dom;
+ memset(&ctrlr_dom, 0, sizeof(controller_domain));
+ result_code = mgrvbr->GetControllerDomainId(ckv, &ctrlr_dom);
+ SET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+ UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
+ ctrlr_dom.ctrlr, ctrlr_dom.domain);
+ DELETE_IF_NOT_NULL(ckv);
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VbrFlowFilterMoMgr::CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_TRACE(" ikey is %s", ikey->ToStrAll().c_str());
+ uint8_t *controller_id = reinterpret_cast<uint8_t *>(
+ const_cast<char *>(ctrlr_id));
+
+ /* check if object is renamed in the corresponding Rename Tbl
+ * if "renamed" create the object by the UNC name.
+ * else - create using the controller name.
+ */
+ result_code = GetRenamedUncKey(ikey, UPLL_DT_RUNNING, dmi, controller_id);
+ if (result_code != UPLL_RC_SUCCESS && result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey Failed err_code %d", result_code);
+ return result_code;
+ }
+
+ UPLL_LOG_DEBUG("GetRenamedUncKey Passed");
+ result_code = GetControllerDomainID(ikey, UPLL_DT_AUDIT, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get the Controller Domain details,err:%d",
+ result_code);
+ return result_code;
+ }
+
+ UPLL_LOG_DEBUG("GetControllerDomainId Passed");
+ controller_domain ctrlr_dom;
+ memset(&ctrlr_dom, 0, sizeof(controller_domain));
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+ UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
+ ctrlr_dom.ctrlr, ctrlr_dom.domain);
+
+ // Create a record in AUDIT DB
+ result_code = UpdateConfigDB(ikey, UPLL_DT_AUDIT, UNC_OP_CREATE, dmi, MAINTBL);
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigDB Failed err_code %d", result_code);
+ return result_code;
+ }
+
+ return UPLL_RC_SUCCESS;
+}
+
upll_rc_t VbrFlowFilterMoMgr::ValidateAttribute(ConfigKeyVal *ikey,
DalDmlIntf *dmi,
IpcReqRespHeader *req) {
delete okey;
okey = NULL;
+ if (UNC_OP_CREATE == req->operation) {
+ result_code = SetRenameFlag(ikey, dmi, req);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("SetRenameFlag failed %d", result_code);
+ return result_code;
+ }
+ }
+
+
UPLL_LOG_DEBUG("ValidateAttribute Successfull.");
return result_code;
}
+upll_rc_t VbrFlowFilterMoMgr::SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *pkey = NULL;
+ result_code = GetParentConfigKey(pkey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetParentConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_VBRIDGE)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("mgr is NULL");
+ DELETE_IF_NOT_NULL(pkey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t rename = 0;
+ result_code = mgr->IsRenamed(pkey, req->datatype, dmi, rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(pkey);
+ return result_code;
+ }
+ UPLL_LOG_DEBUG("Flag from parent : %d", rename);
+ DELETE_IF_NOT_NULL(pkey);
+ SET_USER_DATA_FLAGS(ikey, rename);
+ return UPLL_RC_SUCCESS;
+}
+
upll_rc_t VbrFlowFilterMoMgr::ValidateCapability(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
const char *ctrlr_name) {
if (!ctrlr_name) {
ctrlr_name = static_cast<char *>(ikey->get_user_data());
}
- uint32_t dt_type = req->datatype;
- uint32_t operation = req->operation;
- uint32_t option1 = req->option1;
- uint32_t option2 = req->option2;
- UPLL_LOG_DEBUG("dt_type : (%d)"
- "operation : (%d)"
- "option1 : (%d)"
- "option2 : (%d)",
- dt_type, operation, option1, option2);
+ if (NULL == ctrlr_name) {
+ UPLL_LOG_DEBUG("ctrlr_name is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_TRACE("ctrlr_name : (%s)"
+ "operation : (%d)",
+ ctrlr_name, req->operation);
bool result_code = false;
uint32_t instance_count;
const uint8_t *attrs = NULL;
uint32_t max_attrs = 0;
- switch (operation) {
+ switch (req->operation) {
case UNC_OP_CREATE: {
+ UPLL_LOG_TRACE("Calling GetCreateCapability Operation %d ", req->operation);
result_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
&instance_count, &max_attrs, &attrs);
- break;
- }
- case UNC_OP_UPDATE: {
- result_code = GetUpdateCapability(ctrlr_name, ikey->get_key_type(),
- &max_attrs, &attrs);
+ if (result_code && cur_instance_count >= instance_count &&
+ cur_instance_count !=0 && instance_count != 0) {
+ UPLL_LOG_DEBUG("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
+ __LINE__, __FUNCTION__, cur_instance_count,
+ instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
+
break;
}
default: {
- result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ if (req->datatype == UPLL_DT_STATE) {
+ UPLL_LOG_TRACE("Calling GetStateCapability Operation %d ", req->operation);
+ result_code = GetStateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ } else {
+ UPLL_LOG_TRACE("Calling GetReadCapability Operation %d ", req->operation);
+ result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
&max_attrs, &attrs);
+ }
}
}
if (!result_code) {
- UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s) "
- "for opeartion(%d)",
- ikey->get_key_type(), ctrlr_name, operation);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ UPLL_LOG_DEBUG(" keytype(%d) is not supported by controller(%s) "
+ "for opeartion(%d) And Result_code (%d)",
+ ikey->get_key_type(), ctrlr_name, req->operation, result_code);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
return UPLL_RC_SUCCESS;
}
UPLL_LOG_DEBUG(" Error: option1 is not NORMAL for ReadSiblingCount");
return UPLL_RC_ERR_INVALID_OPTION1;
}
+ if ((req->option1 == UNC_OPT1_DETAIL) &&
+ (req->datatype != UPLL_DT_STATE)) {
+ UPLL_LOG_DEBUG(" Invalid Datatype(%d)", req->datatype);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+ if ((req->datatype == UPLL_DT_IMPORT) && (req->operation == UNC_OP_READ ||
+ req->operation == UNC_OP_READ_SIBLING ||
+ req->operation == UNC_OP_READ_SIBLING_BEGIN ||
+ req->operation == UNC_OP_READ_NEXT ||
+ req->operation == UNC_OP_READ_BULK ||
+ req->operation == UNC_OP_READ_SIBLING_COUNT)) {
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
/** Read key & value structure */
key_vbr_flowfilter_t *key_vbr_flowfilter =
UPLL_LOG_DEBUG("Invalid Key Index");
return false;
}
- UPLL_LOG_DEBUG("Leaving IsValidKey");
return true;
}
if (parent_key == NULL) {
vbr_ff_key = reinterpret_cast<key_vbr_flowfilter_t*>
(ConfigKeyVal::Malloc(sizeof(key_vbr_flowfilter_t)));
+ // If no direction is specified , 0xFE is filled to bind output direction
+ // vbr_ff_key->direction = 0xFE;
okey = new ConfigKeyVal(UNC_KT_VBR_FLOWFILTER,
IpctSt::kIpcStKeyVbrFlowfilter,
vbr_ff_key, NULL);
if (okey) {
if (okey->get_key_type() != UNC_KT_VBR_FLOWFILTER)
return UPLL_RC_ERR_GENERIC;
+ }
+ if ((okey) && (okey->get_key())) {
vbr_ff_key = reinterpret_cast<key_vbr_flowfilter_t *>
(okey->get_key());
} else {
vbr_ff_key = reinterpret_cast<key_vbr_flowfilter_t *>
(ConfigKeyVal::Malloc(sizeof(key_vbr_flowfilter_t)));
+ // If no direction is specified , 0xFE is filled to bind output direction
+ // vbr_ff_key->direction = 0xFE;
}
switch (parent_key->get_key_type()) {
case UNC_KT_VTN:
if (vbr_ff_key) free(vbr_ff_key);
return UPLL_RC_ERR_GENERIC;
}
+
+ if ((okey) && !(okey->get_key())) {
+ UPLL_LOG_DEBUG("okey not null and flow list name updated");
+ okey->SetKey(IpctSt::kIpcStKeyVbrFlowfilter, vbr_ff_key);
+ }
+
if (!okey)
okey = new ConfigKeyVal(UNC_KT_VBR_FLOWFILTER,
IpctSt::kIpcStKeyVbrFlowfilter,
if (okey)
SET_USER_DATA(okey, req)
else {
- delete tmp1;
+ DELETE_IF_NOT_NULL(tmp1);
return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_DEBUG("DupConfigkeyVal Succesfull.");
}
upll_rc_t VbrFlowFilterMoMgr::MergeValidate(unc_key_type_t keytype,
- const char *ctrlr_id,
- ConfigKeyVal *ikey,
- DalDmlIntf *dmi) {
+ const char *ctrlr_id,
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
- UPLL_LOG_DEBUG("Merge Validate is successfull.");
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ckval = NULL;
+ if (NULL == ctrlr_id) {
+ UPLL_LOG_DEBUG("MergeValidate ctrlr_id NULL");
+ return result_code;
+ }
+
+ result_code = GetChildConfigKey(ckval, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey ckval NULL");
+ return result_code;
+ }
+
+ if (!ckval) return UPLL_RC_ERR_GENERIC;
+
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain};
+ result_code = ReadConfigDB(ckval, UPLL_DT_IMPORT,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ckval);
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ return result_code;
+ }
+ return UPLL_RC_SUCCESS;
+ }
+ ConfigKeyVal *tmp_ckval = ckval;
+ while (NULL != ckval) {
+ result_code = UpdateConfigDB(ckval, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
+ MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ UPLL_LOG_DEBUG("Merge Conflict");
+ result_code = DupConfigKeyVal(ikey, ckval, MAINTBL);
+ DELETE_IF_NOT_NULL(ckval);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal fail");
+ return result_code;
+ }
+ return UPLL_RC_ERR_MERGE_CONFLICT;
+ } else if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ ckval = ckval->get_next_cfg_key_val();
+ } else {
+ UPLL_LOG_DEBUG("Merge Conflict DB err");
+ DELETE_IF_NOT_NULL(ckval);
+ return result_code;
+ }
+ }
+ DELETE_IF_NOT_NULL(tmp_ckval);
return UPLL_RC_SUCCESS;
}
ConfigKeyVal *unc_key = NULL;
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
upll_rc_t result_code = UPLL_RC_SUCCESS;
-
- if (NULL == ikey) {
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vbrff start",
+ ikey->ToStrAll().c_str());
+ if ((NULL == ikey) || (ctrlr_id == NULL) || (NULL == dmi)) {
+ UPLL_LOG_DEBUG("ikey/ctrlr_id dmi NULL");
return UPLL_RC_ERR_GENERIC;
}
- if (ctrlr_id == NULL) {
- return UPLL_RC_ERR_GENERIC;
- }
MoMgrImpl *mgrvbr = reinterpret_cast<MoMgrImpl *>
(const_cast<MoManager *> (GetMoManager(UNC_KT_VBRIDGE)));
-
+ if (!mgrvbr) {
+ UPLL_LOG_DEBUG("mgrvbr failed");
+ return UPLL_RC_ERR_GENERIC;
+ }
val_rename_vnode *rename_val = reinterpret_cast<val_rename_vnode*>
(ConfigKeyVal::Malloc(sizeof(val_rename_vnode)));
-
+ if (!rename_val) {
+ UPLL_LOG_TRACE("rename_val NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
key_vbr_flowfilter_t *ctrlr_key = NULL;
ctrlr_key = reinterpret_cast<key_vbr_flowfilter_t *> (ikey->get_key());
-
+ if (!ctrlr_key) {
+ UPLL_LOG_TRACE("ctrlr_key NULL");
+ free(rename_val);
+ return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(rename_val->ctrlr_vtn_name,
ctrlr_key->vbr_key.vtn_key.vtn_name,
(kMaxLenVtnName + 1));
+ rename_val->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
uuu::upll_strncpy(rename_val->ctrlr_vnode_name,
ctrlr_key->vbr_key.vbridge_name,
(kMaxLenVnodeName + 1));
+ rename_val->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_VALID;
result_code = mgrvbr->GetChildConfigKey(unc_key, NULL);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_ERROR("GetRenamedUnckey:GetChildConfigKey returned error");
- free(rename_val); // RESOURCE LEAK
+ UPLL_LOG_DEBUG("GetRenamedUnckey:GetChildConfigKey returned error");
+ free(rename_val);
+ mgrvbr = NULL;
return result_code;
}
-
- unc_key->set_user_data(ctrlr_id);
+ if (!unc_key) {
+ UPLL_LOG_DEBUG("unc_key NULL");
+ free(rename_val);
+ mgrvbr = NULL;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
unc_key->AppendCfgVal(IpctSt::kIpcStValRenameVtn, rename_val);
result_code = mgrvbr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ,
dbop, dmi, RENAMETBL);
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(unc_key);
+ mgrvbr = NULL;
+ return result_code;
+ }
if (result_code == UPLL_RC_SUCCESS) {
key_vbr_flowfilter_t *vbr_flowfilter_key =
(kMaxLenVnodeName + 1));
}
- UPLL_LOG_DEBUG("Key is filled with UncKey Successfully %d", result_code);
- free(rename_val);
- delete unc_key;
- return result_code;
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vbrff end",
+ ikey->ToStrAll().c_str());
+ DELETE_IF_NOT_NULL(unc_key);
+ mgrvbr = NULL;
+ return UPLL_RC_SUCCESS;
}
upll_rc_t VbrFlowFilterMoMgr::GetRenamedControllerKey(
ConfigKeyVal *okey = NULL;
uint8_t rename = 0;
IsRenamed(ikey, dt_type, dmi, rename);
- MoMgrImpl *mgrvtn =reinterpret_cast<MoMgrImpl *>
- (const_cast<MoManager *> (GetMoManager(UNC_KT_VTN)));
+ if (!rename) {
+ UPLL_LOG_DEBUG("no renamed");
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_TRACE("Start Input ConfigKeyVal %s", ikey->ToStrAll().c_str());
- if (!rename) return UPLL_RC_SUCCESS;
- /* Vtn renamed */
- key_vbr_flowfilter_t *ctrlr_key = reinterpret_cast<key_vbr_flowfilter_t*>
- (ConfigKeyVal::Malloc(sizeof(key_vbr_flowfilter_t)));
+ MoMgrImpl *mgrvbr = reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_VBRIDGE)));
+ result_code = mgrvbr->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+ if (ctrlr_dom)
+ SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
+ uuu::upll_strncpy(reinterpret_cast<key_vbr *> (okey->get_key())->vtn_key.vtn_name,
+ reinterpret_cast<key_vbr_flowfilter_t *>
+ (ikey->get_key())->vbr_key.vtn_key.vtn_name,
+ (kMaxLenVnodeName + 1));
+ UPLL_LOG_DEBUG("vtn name (%s) (%s)",
+ reinterpret_cast<key_vbr *> (okey->get_key())->vtn_key.vtn_name,
+ reinterpret_cast<key_vbr_flowfilter_t *>
+ (ikey->get_key())->vbr_key.vtn_key.vtn_name);
+ uuu::upll_strncpy(reinterpret_cast<key_vbr *> (okey->get_key())->vbridge_name,
+ reinterpret_cast<key_vbr_flowfilter_t *>
+ (ikey->get_key())->vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+ UPLL_LOG_DEBUG("vbr name (%s) (%s)",
+ reinterpret_cast<key_vbr *> (okey->get_key())->vbridge_name,
+ reinterpret_cast<key_vbr_flowfilter_t *>
+ (ikey->get_key())->vbr_key.vbridge_name);
+
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr | kOpMatchDomain, kOpInOutFlag };
+ result_code = mgrvbr->ReadConfigDB(okey, dt_type, UNC_OP_READ,
+ dbop, dmi, RENAMETBL);
+ if ( result_code != UPLL_RC_SUCCESS ) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB no instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ val_rename_vnode *rename_val = NULL;
+ rename_val = reinterpret_cast<val_rename_vnode *> (GetVal(okey));
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("Vbr Name is not Valid.");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
if (rename & VTN_RENAME_FLAG) {
- mgrvtn->GetChildConfigKey(okey, NULL);
- if (ctrlr_dom)
+ UPLL_LOG_DEBUG("vtn name renamed");
+ uuu::upll_strncpy(reinterpret_cast<key_vbr_flowfilter_t *>
+ (ikey->get_key())->vbr_key.vtn_key.vtn_name,
+ rename_val->ctrlr_vtn_name,
+ (kMaxLenVtnName + 1));
+ UPLL_LOG_DEBUG("vtn re name(%s) (%s)",
+ reinterpret_cast<key_vbr_flowfilter_t *>
+ (ikey->get_key())->vbr_key.vtn_key.vtn_name,
+ rename_val->ctrlr_vtn_name);
+ }
+
+
+ if (rename & VBR_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("vbr name renamed");
+ uuu::upll_strncpy(reinterpret_cast<key_vbr_flowfilter_t *>
+ (ikey->get_key())->vbr_key.vbridge_name,
+ rename_val->ctrlr_vnode_name,
+ (kMaxLenVnodeName + 1));
+ UPLL_LOG_DEBUG("vbr name (%s) (%s)",
+ reinterpret_cast<key_vbr_flowfilter_t *>
+ (ikey->get_key())->vbr_key.vbridge_name,
+ rename_val->ctrlr_vnode_name);
+ }
+ DELETE_IF_NOT_NULL(okey);
+ SET_USER_DATA_FLAGS(ikey, rename);
+ UPLL_LOG_TRACE("End Input ConfigKeyVal %s", ikey->ToStrAll().c_str());
+ UPLL_LOG_DEBUG("Renamed Controller key is sucessfull.");
+ return UPLL_RC_SUCCESS;
+#if 0
+ /* Vtn renamed */
+ if (rename & VTN_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("vtn name renamed");
+ MoMgrImpl *mgrvtn =reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_VTN)));
+ result_code = mgrvtn->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+
+ if (ctrlr_dom) {
SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr_dom null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
uuu::upll_strncpy(
reinterpret_cast<key_vtn *> (okey->get_key())->vtn_name,
reinterpret_cast<key_vbr_flowfilter_t *>
(ikey->get_key())->vbr_key.vtn_key.vtn_name,
(kMaxLenVtnName + 1));
-
+// UPLL_LOG_DEBUG("vtn name (%s) (%s)" (okey->get_key())->vtn_name,
+// (ikey->get_key())->vbr_key.vtn_key.vtn_name);
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
result_code = mgrvtn->ReadConfigDB(okey, dt_type, UNC_OP_READ,
dbop, dmi, RENAMETBL);
if ( result_code != UPLL_RC_SUCCESS ) {
- return UPLL_RC_ERR_GENERIC;
+ UPLL_LOG_DEBUG("ReadConfigDB null");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
}
val_rename_vtn *rename_val = NULL;
rename_val = reinterpret_cast<val_rename_vtn *> (GetVal(okey));
- if (!rename_val
- || (rename_val->valid[UPLL_IDX_NEW_NAME_RVTN] != UNC_VF_VALID)) {
+ if (!rename_val) {
UPLL_LOG_DEBUG("Vtn Name is not Valid.");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
- uuu::upll_strncpy(ctrlr_key->vbr_key.vtn_key.vtn_name,
+ uuu::upll_strncpy(reinterpret_cast<key_vbr_flowfilter_t *>
+ (ikey->get_key())->vbr_key.vtn_key.vtn_name,
rename_val->new_name,
(kMaxLenVtnName + 1));
- delete okey;
+ UPLL_LOG_DEBUG("vtn re name(%s) (%s)",
+ reinterpret_cast<key_vbr_flowfilter_t *>
+ (ikey->get_key())->vbr_key.vtn_key.vtn_name,
+ rename_val->new_name);
+ DELETE_IF_NOT_NULL(okey);
+ SET_USER_DATA_FLAGS(ikey, rename);
}
// Vbr Renamed
- MoMgrImpl *mgrvbr = reinterpret_cast<MoMgrImpl *>
- (const_cast<MoManager *> (GetMoManager(UNC_KT_VBRIDGE)));
if (rename & VBR_RENAME_FLAG) {
- mgrvbr->GetChildConfigKey(okey, NULL);
+ UPLL_LOG_DEBUG("vbr name renamed");
+ MoMgrImpl *mgrvbr = reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_VBRIDGE)));
+ result_code = mgrvbr->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
if (ctrlr_dom)
SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
- uuu::upll_strncpy(reinterpret_cast<key_vbr *> (okey)->vbridge_name,
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
+ uuu::upll_strncpy(reinterpret_cast<key_vbr *> (okey->get_key())->vtn_key.vtn_name,
+ reinterpret_cast<key_vbr_flowfilter_t *>
+ (ikey->get_key())->vbr_key.vtn_key.vtn_name,
+ (kMaxLenVnodeName + 1));
+ UPLL_LOG_DEBUG("vtn name (%s) (%s)",
+ reinterpret_cast<key_vbr *> (okey->get_key())->vtn_key.vtn_name,
+ reinterpret_cast<key_vbr_flowfilter_t *>
+ (ikey->get_key())->vbr_key.vtn_key.vtn_name);
+ uuu::upll_strncpy(reinterpret_cast<key_vbr *> (okey->get_key())->vbridge_name,
reinterpret_cast<key_vbr_flowfilter_t *>
(ikey->get_key())->vbr_key.vbridge_name,
(kMaxLenVnodeName + 1));
+ UPLL_LOG_DEBUG("vbr name (%s) (%s)",
+ reinterpret_cast<key_vbr *> (okey->get_key())->vbridge_name,
+ reinterpret_cast<key_vbr_flowfilter_t *>
+ (ikey->get_key())->vbr_key.vbridge_name);
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
result_code = mgrvbr->ReadConfigDB(okey, dt_type, UNC_OP_READ,
dbop, dmi, RENAMETBL);
if ( result_code != UPLL_RC_SUCCESS ) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
- val_rename_vbr *rename_val = NULL;
- rename_val = reinterpret_cast<val_rename_vbr *> (GetVal(okey));
- if (!rename_val
- || (rename_val->valid[UPLL_IDX_NEW_NAME_RVBR] != UNC_VF_VALID)) {
+
+ val_rename_vnode *rename_val = NULL;
+ rename_val = reinterpret_cast<val_rename_vnode *> (GetVal(okey));
+ if (!rename_val) {
UPLL_LOG_DEBUG("Vbr Name is not Valid.");
- free(ctrlr_key);
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
- uuu::upll_strncpy(ctrlr_key->vbr_key.vbridge_name,
- rename_val->new_name,
+ uuu::upll_strncpy(reinterpret_cast<key_vbr_flowfilter_t *>
+ (ikey->get_key())->vbr_key.vbridge_name,
+ rename_val->ctrlr_vnode_name,
(kMaxLenVnodeName + 1));
- delete okey;
+ UPLL_LOG_DEBUG("vbr name (%s) (%s)",
+ reinterpret_cast<key_vbr_flowfilter_t *>
+ (ikey->get_key())->vbr_key.vbridge_name,
+ rename_val->ctrlr_vnode_name);
+ DELETE_IF_NOT_NULL(okey);
}
+ UPLL_LOG_TRACE("%s GetRenamedCtrl end", ikey->ToStrAll().c_str());
UPLL_LOG_DEBUG("Renamed Controller key is sucessfull.");
- free(ctrlr_key);
return UPLL_RC_SUCCESS;
+#endif
}
upll_rc_t VbrFlowFilterMoMgr::UpdateAuditConfigStatus(
ConfigKeyVal *&ckv_running) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- val_flowfilter_t *vbr_flowfilter_val = NULL;
+ val_flowfilter_t *val = NULL;
- vbr_flowfilter_val = (ckv_running != NULL)?
+ val = (ckv_running != NULL)?
reinterpret_cast<val_flowfilter_t *> (GetVal(ckv_running)):NULL;
- if (NULL == vbr_flowfilter_val) {
+ if (NULL == val) {
UPLL_LOG_DEBUG("Memory Not Allocated");
return UPLL_RC_ERR_GENERIC;
}
-
if (uuc::kUpllUcpCreate == phase )
- vbr_flowfilter_val->cs_row_status = cs_status;
+ val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
UPLL_LOG_DEBUG("AuditUpdate Config Status Information %d", result_code);
return result_code;
UNC_OP_READ, dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadConfigDB fail in ReadMo for dup_key");
- delete dup_key;
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
}
result_code = DupConfigKeyVal(l_key, ikey, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("DupConfigKeyVal fail in ReadMo for l_key");
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
}
GET_USER_DATA_CTRLR_DOMAIN(dup_key, ctrlr_dom);
SET_USER_DATA_CTRLR_DOMAIN(l_key, ctrlr_dom);
+ //Added CApaCheck
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(ctrlr_dom.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("validate Capability Failed %d", result_code);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ return result_code;
+ }
+
// 1.Getting renamed name if renamed
result_code = GetRenamedControllerKey(l_key, req->datatype,
dmi, &ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
return result_code;
}
// 2.send request to driver
UPLL_LOG_DEBUG("SendReqToDriver failed for Key %d controller %s",
l_key->get_key_type(),
reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_DEBUG("Driver response for Key %d controller %s result %d",
l_key->get_key_type(), ctrlr_dom.ctrlr,
ipc_resp.header.result_code);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
return ipc_resp.header.result_code;
}
ConfigKeyVal *okey = NULL;
result_code = ConstructReadDetailResponse(dup_key,
ipc_resp.ckv_data,
- req->datatype,
- req->operation,
- dbop, dmi, &okey);
+ &okey);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ConstructReadDetailResponse error code (%d)",
result_code);
- DELETE_IF_NOT_NULL(dup_key);
- DELETE_IF_NOT_NULL(l_key);
return result_code;
} else {
if (okey != NULL) {
ikey->ResetWith(okey);
+ DELETE_IF_NOT_NULL(okey);
}
}
- DELETE_IF_NOT_NULL(dup_key);
- DELETE_IF_NOT_NULL(l_key);
}
break;
default:
+ UPLL_LOG_DEBUG("Operation Not Allowed");
result_code = UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
return result_code;
key_rename->old_unc_vtn_name,
(kMaxLenVtnName + 1));
- if (ikey->get_key_type() == table[MAINTBL]->get_key_type()) {
+ if (ikey->get_key_type() == UNC_KT_VBRIDGE) {
if (!strlen(reinterpret_cast<char *> (key_rename->old_unc_vnode_name))) {
free(key_vbr);
return UPLL_RC_ERR_GENERIC;
uuu::upll_strncpy(key_vbr->vbr_key.vbridge_name,
key_rename->old_unc_vnode_name,
(kMaxLenVnodeName + 1));
+ } else {
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_unc_vnode_name))) {
+ UPLL_LOG_DEBUG("new_unc_vnode_name NULL");
+ free(key_vbr);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(key_vbr->vbr_key.vbridge_name,
+ key_rename->new_unc_vnode_name, (kMaxLenVnodeName + 1));
}
okey = new ConfigKeyVal(UNC_KT_VBR_FLOWFILTER,
return UPLL_RC_ERR_GENERIC;
}
- free(key_vbr);
+ // free(key_vbr);
return result_code;
}
result_code = DupConfigKeyVal(l_key, ikey, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("DupConfigKeyVal fail in ReadSiblingMo for l_key");
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(tctrl_key);
return result_code;
}
GET_USER_DATA_CTRLR_DOMAIN(dup_key, ctrlr_dom);
SET_USER_DATA_CTRLR_DOMAIN(l_key, ctrlr_dom);
+ //Added CApaCheck
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(ctrlr_dom.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("validate Capability Failed %d", result_code);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(tctrl_key);
+ return result_code;
+ }
+
// 1.Getting renamed name if renamed
result_code = GetRenamedControllerKey(l_key, req->datatype,
dmi, &ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
+
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(tctrl_key);
return result_code;
}
UPLL_LOG_DEBUG("SendReqToDriver failed for Key %d controller %s",
l_key->get_key_type(),
reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(tctrl_key);
return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_DEBUG("Driver response for Key %d controller %s result %d",
l_key->get_key_type(), ctrlr_dom.ctrlr,
ipc_resp.header.result_code);
+
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(tctrl_key);
return ipc_resp.header.result_code;
}
result_code = ConstructReadDetailResponse(tmp_key,
ipc_resp.ckv_data,
- req->datatype,
- req->operation,
- dbop, dmi, &okey);
+ &okey);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ConstructReadDetailResponse error code (%d)",
result_code);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(tctrl_key);
return result_code;
}
tmp_key = tmp_key->get_next_cfg_key_val();
upll_rc_t VbrFlowFilterMoMgr::ConstructReadDetailResponse(
ConfigKeyVal *ikey,
ConfigKeyVal *drv_resp_ckv,
- upll_keytype_datatype_t dt_type,
- unc_keytype_operation_t op,
- DbSubOp dbop,
- DalDmlIntf *dmi,
ConfigKeyVal **okey) {
UPLL_FUNC_TRACE;
ConfigKeyVal *tmp_okey = NULL;
if (!tmp_val_ff) {
UPLL_LOG_DEBUG(" Invalid value read from DB");
free(val_ff);
+ delete (tmp_okey);
return UPLL_RC_ERR_GENERIC;
}
memcpy(val_ff, tmp_val_ff, sizeof(val_flowfilter_t));
tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowfilter, val_ff);
+ tmp_okey->AppendCfgVal(drv_resp_ckv->GetCfgValAndUnlink());
- ConfigVal *drv_resp_val = drv_resp_ckv->get_cfg_val();
- while (drv_resp_val != NULL) {
- val_flowfilter_entry_st_t *val_ffe_st = NULL;
- if (IpctSt::kIpcStValFlowfilterEntrySt == drv_resp_val->get_st_num()) {
- val_ffe_st = reinterpret_cast<val_flowfilter_entry_st_t *>
- (drv_resp_val->get_val());
- } else {
- UPLL_LOG_DEBUG("Incorrect structure received from driver, struct num %d",
- drv_resp_val->get_st_num());
- return UPLL_RC_ERR_GENERIC;
- }
-
- if ((val_ffe_st)->valid[UPLL_IDX_SEQ_NUM_FFES] == UNC_VF_VALID) {
- ConfigKeyVal *tmp_ffe_key = NULL;
- key_vbr_flowfilter_t *key_vbr_ff =
- reinterpret_cast<key_vbr_flowfilter_t*>(ikey->get_key());
-
- key_vbr_flowfilter_entry_t *key_vbr_ffe =
- reinterpret_cast<key_vbr_flowfilter_entry_t*>
- (ConfigKeyVal::Malloc(sizeof(key_vbr_flowfilter_entry_t)));
- tmp_ffe_key = new ConfigKeyVal(UNC_KT_VBR_FLOWFILTER_ENTRY,
- IpctSt::kIpcStKeyVbrFlowfilterEntry,
- key_vbr_ffe, NULL);
- key_vbr_ffe->sequence_num = val_ffe_st->sequence_num;
-
- uuu::upll_strncpy(
- key_vbr_ffe->flowfilter_key.vbr_key.vtn_key.vtn_name,
- key_vbr_ff->vbr_key.vtn_key.vtn_name,
- (kMaxLenVtnName+1));
-
- uuu::upll_strncpy(
- key_vbr_ffe->flowfilter_key.vbr_key.vbridge_name,
- key_vbr_ff->vbr_key.vbridge_name,
- (kMaxLenVnodeName+1));
-
- key_vbr_ffe->flowfilter_key.direction =
- (reinterpret_cast<key_vbr_flowfilter*>(ikey->get_key()))->direction;
- VbrFlowFilterEntryMoMgr *mgr =
- reinterpret_cast<VbrFlowFilterEntryMoMgr*>
- (const_cast<MoManager *>(GetMoManager
- (UNC_KT_VBR_FLOWFILTER_ENTRY)));
-
- result_code = mgr->ReadDetailEntry(tmp_ffe_key, dt_type, dbop, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- delete tmp_ffe_key;
- delete tmp_okey;
- return result_code;
- }
-
- val_flowfilter_entry_st_t *tmp_ffe_st =
- reinterpret_cast<val_flowfilter_entry_st_t* >
- (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_st_t)));
- memcpy(tmp_ffe_st, val_ffe_st, sizeof(val_flowfilter_entry_st_t));
-
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowfilterEntrySt, tmp_ffe_st);
- val_flowfilter_entry_t* tmp_val_ffe =
- reinterpret_cast <val_flowfilter_entry_t*>
- (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_t)));
- memcpy(tmp_val_ffe,
- reinterpret_cast<val_flowfilter_entry_t*>
- (tmp_ffe_key->get_cfg_val()->get_val()),
- sizeof(val_flowfilter_entry_t));
-
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowfilterEntry, tmp_val_ffe);
-
- delete tmp_ffe_key;
- tmp_ffe_key = NULL;
-
- if ((drv_resp_val = drv_resp_val->get_next_cfg_val()) == NULL) {
- UPLL_LOG_DEBUG("No more entries in driver response\n");
- break;
- }
-
- if (IpctSt::kIpcStValFlowlistEntrySt != drv_resp_val->get_st_num()) {
- UPLL_LOG_DEBUG("No flowflist entries returned by driver");
- continue;
- }
- while (IpctSt::kIpcStValFlowlistEntrySt == drv_resp_val->get_st_num()) {
- val_flowlist_entry_st_t* tmp_val_fl_st =
- reinterpret_cast<val_flowlist_entry_st_t*>
- (ConfigKeyVal::Malloc(sizeof(val_flowlist_entry_st_t)));
- memcpy(tmp_val_fl_st,
- reinterpret_cast<val_flowlist_entry_st_t*>
- (drv_resp_val->get_val()),
- sizeof(val_flowlist_entry_st_t));
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowlistEntrySt, tmp_val_fl_st);
- drv_resp_val = drv_resp_val->get_next_cfg_val();
- if (!drv_resp_val) {
- break;
- }
- }
- }
- }
if (*okey == NULL) {
*okey = tmp_okey;
} else {
UPLL_LOG_DEBUG(" Input Key is NULL");
return UPLL_RC_ERR_GENERIC;
}
-
+ DELETE_IF_NOT_NULL(okey);
unc_key_type_t ikey_type = ikey->get_key_type();
if (ikey_type != UNC_KT_VBR_FLOWFILTER) {
UPLL_LOG_DEBUG(" Invalid key type received. Key type - %d", ikey_type);
SET_USER_DATA(okey, ikey);
return UPLL_RC_SUCCESS;
}
+
+upll_rc_t VbrFlowFilterMoMgr::DeleteChildrenPOM(
+ ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+
+ if (NULL == ikey || NULL == dmi) {
+ UPLL_LOG_DEBUG("Delete Operation failed:Bad request");
+ return result_code;
+ }
+ // Read the DB get the flowlist value and send the delete request to
+ // flowlist momgr if flowlist is configured.
+
+ ConfigKeyVal *tempckv = NULL;
+ result_code = GetChildConfigKey(tempckv, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ return result_code;
+ }
+ result_code = UpdateConfigDB(tempckv, dt_type, UNC_OP_DELETE, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(tempckv);
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("UPLL_RC_ERR_NO_SUCH_INSTANCE");
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("DeleteMo record Err in vtnpolicingmaptbl (%d)",
+ result_code);
+ return result_code;
+ }
+ delete tempckv;
+ tempckv = NULL;
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VbrFlowFilterMoMgr::SetValidAudit(ConfigKeyVal *&ikey) {
+ UPLL_FUNC_TRACE;
+ val_flowfilter_t *val = reinterpret_cast<val_flowfilter_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_flowfilter_t)));
+ val->cs_row_status = UNC_CS_APPLIED;
+ ikey->AppendCfgVal(IpctSt::kIpcStValFlowfilter, val);
+ return UPLL_RC_SUCCESS;
+}
+
+bool VbrFlowFilterMoMgr::FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op) {
+ UPLL_FUNC_TRACE;
+ if (op != UNC_OP_CREATE)
+ return true;
+ return false;
+}
} // namespace kt_momgr
} // namespace upll
} // namespace unc
*/
static BindInfo vbr_flowfilter_maintbl_bind_info[];
+ uint32_t cur_instance_count;
/**
* @brief Validates the Attribute of a Particular Class.
*
upll_rc_t ConstructReadDetailResponse(ConfigKeyVal *ikey,
ConfigKeyVal *drv_resp_ckv,
- upll_keytype_datatype_t dt_type,
- unc_keytype_operation_t op,
- DbSubOp dbop,
- DalDmlIntf *dmi,
ConfigKeyVal **okey);
+
+ upll_rc_t CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id);
+
+ upll_rc_t GetControllerDomainID(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi);
+
+ upll_rc_t DeleteChildrenPOM(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi);
+
+ upll_rc_t SetValidAudit(ConfigKeyVal *&ikey);
+
+ bool FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op);
+
+ upll_rc_t SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req);
+
};
} // namespace kt_momgr
} // namespace upll
#include "upll_validation.hh"
#include "unc/upll_ipc_enum.h"
#include "flowlist_momgr.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
namespace unc {
namespace upll {
#define FLOWLIST_RENAME_FLAG 0x04 // For 3rd Bit
#define VTN_RENAME_FLAG 0x01 // For first Bit
#define VBR_RENAME_FLAG 0x02 // For 2nd Bit
-#define NUM_KEY_MAIN_TBL_ 7
-#define NUM_KEY_RENAME_MAIN_TBL 6
-#define SET_FLAG_VLINK 0x08
-#define SET_FLAG_PORTMAP 0x10
+#define NO_VBR_RENAME_FLAG ~VBR_RENAME_FLAG
+#define SET_FLAG_VLINK 0x40
+#define SET_FLAG_PORTMAP 0x20
#define SET_FLAG_VLINK_PORTMAP (SET_FLAG_VLINK | SET_FLAG_PORTMAP)
+#define SET_FLAG_NO_VLINK_PORTMAP ~SET_FLAG_VLINK_PORTMAP
+#define FLOW_RENAME 0x04
+#define NO_FLOWLIST_RENAME ~FLOW_RENAME
BindInfo VbrIfFlowFilterEntryMoMgr::vbr_if_flowfilter_entry_bind_info[] = {
{ uudst::vbr_if_flowfilter_entry::kDbiVtnName, CFG_KEY,
offsetof(val_flowfilter_entry_t, cs_attr[5]),
uud::kDalUint8, 1 },
{ uudst::vbr_if_flowfilter_entry::kDbiCsNwmName, CS_VAL,
- offsetof(val_flowlist_entry_t, cs_attr[6]),
+ offsetof(val_flowfilter_entry_t, cs_attr[6]),
uud::kDalUint8, 1 },
{ uudst::vbr_if_flowfilter_entry::kDbiCsDscp, CS_VAL,
- offsetof(val_flowlist_entry_t, cs_attr[7]),
+ offsetof(val_flowfilter_entry_t, cs_attr[7]),
uud::kDalUint8, 1 },
{ uudst::vbr_if_flowfilter_entry::kDbiCsPriority, CS_VAL,
- offsetof(val_flowlist_entry_t, cs_attr[8]),
+ offsetof(val_flowfilter_entry_t, cs_attr[8]),
uud::kDalUint8, 1 }
};
offsetof(key_vbr_if_flowfilter_entry_t,
flowfilter_key.if_key.vbr_key.vbridge_name),
uud::kDalChar, (kMaxLenVnodeName + 1) },
- { uudst::vbr_if_flowfilter_entry::kDbiVbrIfName, CFG_MATCH_KEY,
- offsetof(key_vbr_if_flowfilter_entry_t, flowfilter_key.if_key.if_name),
- uud::kDalChar, (kMaxLenInterfaceName + 1) },
- { uudst::vbr_if_flowfilter_entry::kDbiSequenceNum, CFG_MATCH_KEY,
- offsetof(key_vbr_if_flowfilter_entry_t, sequence_num),
- uud::kDalUint16, 1 },
{ uudst::vbr_if_flowfilter_entry::kDbiVtnName, CFG_INPUT_KEY,
offsetof(key_rename_vnode_info_t, new_unc_vtn_name),
uud::kDalChar, (kMaxLenVtnName + 1) },
{ uudst::vbr_if_flowfilter_entry::kDbiVbrName, CFG_INPUT_KEY,
offsetof(key_rename_vnode_info_t, new_unc_vnode_name),
uud::kDalChar, (kMaxLenVnodeName + 1) },
- { uudst::vbr_if_flowfilter_entry::kDbiFlags, CFG_INPUT_KEY,
+ { uudst::vbr_if_flowfilter_entry::kDbiFlags, CK_VAL,
offsetof(key_user_data_t, flags),
uud::kDalUint8, 1 }
};
-BindInfo VbrIfFlowFilterEntryMoMgr::vbr_if_flowlist_rename_bind_info[] = {
- { uudst::vbr_if_flowfilter_entry::kDbiVtnName, CFG_MATCH_KEY,
- offsetof(key_vbr_if_flowfilter_entry_t,
- flowfilter_key.if_key.vbr_key.vtn_key.vtn_name),
- uud::kDalChar, (kMaxLenVtnName + 1) },
- { uudst::vbr_if_flowfilter_entry::kDbiVbrName, CFG_MATCH_KEY,
- offsetof(key_vbr_if_flowfilter_entry_t,
- flowfilter_key.if_key.vbr_key.vbridge_name),
- uud::kDalChar, (kMaxLenVnodeName + 1) },
- { uudst::vbr_if_flowfilter_entry::kDbiSequenceNum, CFG_MATCH_KEY,
- offsetof(key_vbr_if_flowfilter_entry_t, sequence_num),
- uud::kDalUint16, 1 },
- { uudst::vbr_if_flowfilter_entry::kDbiVbrIfName, CFG_MATCH_KEY,
- offsetof(key_vbr_if_flowfilter_entry_t, flowfilter_key.if_key.if_name),
- uud::kDalChar, (kMaxLenInterfaceName + 1) },
- { uudst::vbr_if_flowfilter_entry::kDbiFlowlistName, CFG_INPUT_KEY,
- offsetof(key_rename_vnode_info_t, new_flowlist_name),
- uud::kDalChar, (kMaxLenFlowListName + 1) },
- { uudst::vbr_if_flowfilter_entry::kDbiFlags, CFG_INPUT_KEY,
- offsetof(key_user_data_t, flags),
- uud::kDalUint8, 1 }
-};
VbrIfFlowFilterEntryMoMgr::VbrIfFlowFilterEntryMoMgr() : MoMgrImpl() {
UPLL_FUNC_TRACE;
// setting rename table and controller index to null
ntable = MAX_MOMGR_TBLS;
table = new Table *[ntable];
-
+ cur_instance_count = 0;
table[MAINTBL] = new Table(uudst::kDbiVbrIfFlowFilterEntryTbl,
UNC_KT_VBRIF_FLOWFILTER_ENTRY, vbr_if_flowfilter_entry_bind_info,
IpctSt::kIpcStKeyVbrIfFlowfilterEntry, IpctSt::kIpcStValFlowfilterEntry,
BindInfo *&binfo,
int &nattr,
MoMgrTables tbl ) {
+ UPLL_FUNC_TRACE;
/* Main Table only update */
- if (UNC_KT_VBRIF_FLOWFILTER_ENTRY == key_type) {
- if (MAINTBL == tbl) {
- nattr = NUM_KEY_MAIN_TBL_;
- binfo = vbr_if_flowfilter_entry_main_tbl_bind_info;
- } else {
- return PFC_FALSE;
- }
- }
- if (UNC_KT_FLOWLIST == key_type) {
- nattr = NUM_KEY_RENAME_MAIN_TBL;
- binfo = vbr_if_flowlist_rename_bind_info;
+ if (MAINTBL == tbl) {
+ nattr = sizeof(vbr_if_flowfilter_entry_main_tbl_bind_info)/
+ sizeof(vbr_if_flowfilter_entry_main_tbl_bind_info[0]);
+ binfo = vbr_if_flowfilter_entry_main_tbl_bind_info;
+ } else {
+ return PFC_FALSE;
}
UPLL_LOG_DEBUG("Successful Completeion");
UPLL_LOG_DEBUG(" Error: option1 is not NORMAL");
return UPLL_RC_ERR_INVALID_OPTION1;
}
- if((req->option1 != UNC_OPT1_NORMAL)
- &&(req->operation == UNC_OP_READ_SIBLING_COUNT)) {
- UPLL_LOG_DEBUG(" Error: option1 is not NORMAL for ReadSiblingCount");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
+ if((req->option1 != UNC_OPT1_NORMAL)
+ &&(req->operation == UNC_OP_READ_SIBLING_COUNT)) {
+ UPLL_LOG_DEBUG(" Error: option1 is not NORMAL for ReadSiblingCount");
+ return UPLL_RC_ERR_INVALID_OPTION1;
+ }
+ if ((req->option1 == UNC_OPT1_DETAIL) &&
+ (req->datatype != UPLL_DT_STATE)) {
+ UPLL_LOG_DEBUG(" Invalid Datatype(%d)", req->datatype);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+ if ((req->datatype == UPLL_DT_IMPORT) && (req->operation == UNC_OP_READ ||
+ req->operation == UNC_OP_READ_SIBLING ||
+ req->operation == UNC_OP_READ_SIBLING_BEGIN ||
+ req->operation == UNC_OP_READ_NEXT ||
+ req->operation == UNC_OP_READ_BULK ||
+ req->operation == UNC_OP_READ_SIBLING_COUNT)) {
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
key_vbr_if_flowfilter_entry_t *key_vbr_if_flowfilter_entry =
reinterpret_cast<key_vbr_if_flowfilter_entry_t *>(key->get_key());
ConfigKeyVal *ikey,
const char* ctrlr_name) {
UPLL_FUNC_TRACE;
- upll_rc_t rt_code = UPLL_RC_ERR_GENERIC;
- /** Use VbrFlowfilterEntryMoMgr::ValidateCapability
- * to validate capability for val_flowfilter_entry structure*/
- VbrFlowFilterEntryMoMgr *mgrvbrff =
- reinterpret_cast<VbrFlowFilterEntryMoMgr *>(const_cast<MoManager *>(
- GetMoManager(UNC_KT_VBR_FLOWFILTER_ENTRY)));
+ if ((NULL == req) || (NULL == ikey)) {
+ UPLL_LOG_DEBUG("IpcReqRespHeader/ConfigKeyval is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ if (!ctrlr_name)
+ ctrlr_name = static_cast<char *>(ikey->get_user_data());
- if (NULL == mgrvbrff) {
+ if (NULL == ctrlr_name) {
+ UPLL_LOG_DEBUG("ctrlr_name is NULL");
return UPLL_RC_ERR_GENERIC;
}
- rt_code = mgrvbrff->ValidateCapability(req, ikey, ctrlr_name);
+ UPLL_LOG_TRACE("ctrlr_name : (%s)"
+ "operation : (%d)",
+ ctrlr_name, req->operation);
+
+ bool ret_code = false;
+ uint32_t instance_count = 0;
+ const uint8_t *attrs = NULL;
+ uint32_t max_attrs = 0;
+
+ switch (req->operation) {
+ case UNC_OP_CREATE: {
+ UPLL_LOG_TRACE("Calling GetCreateCapability Operation %d ", req->operation);
+ ret_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
+ &instance_count, &max_attrs, &attrs);
+ if (ret_code && cur_instance_count >= instance_count &&
+ cur_instance_count !=0 && instance_count != 0) {
+ UPLL_LOG_DEBUG("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
+ __LINE__, __FUNCTION__, cur_instance_count,
+ instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
+ break;
+ }
+ case UNC_OP_UPDATE: {
+ ret_code = GetUpdateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ break;
+ }
+ default: {
+ if (req->datatype == UPLL_DT_STATE) {
+ UPLL_LOG_TRACE("Calling GetStateCapability Operation %d ", req->operation);
+ ret_code = GetStateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ } else {
+ UPLL_LOG_TRACE("Calling GetReadCapability Operation %d ", req->operation);
+ ret_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ }
+ break;
+ }
+ }
- if (UPLL_RC_SUCCESS != rt_code) {
- UPLL_LOG_DEBUG(" VBRIF_FLOWFILTER_ENTRY Attribute validation failed :"
- "Err Code - %d",
- rt_code);
+ if (!ret_code) {
+ UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s)",
+ ikey->get_key_type(), ctrlr_name);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+
+ val_flowfilter_entry_t *val_flowfilter_entry =
+ reinterpret_cast<val_flowfilter_entry_t *>(GetVal(ikey));
+ if (max_attrs > 0) {
+ return VbrFlowFilterEntryMoMgr::ValFlowFilterEntryAttributeSupportCheck(
+ val_flowfilter_entry, attrs);
+ } else {
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d", req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
- return rt_code;
}
+upll_rc_t VbrIfFlowFilterEntryMoMgr::RestorePOMInCtrlTbl(
+ ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl,
+ DalDmlIntf* dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+
+ controller_domain ctrlr_dom;
+ FlowListMoMgr *mgr = NULL;
+ uint8_t *ctrlr_id = NULL;
+
+ if (!ikey || !(ikey->get_key())) {
+ UPLL_LOG_DEBUG("Input Key Not Valid");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (tbl != MAINTBL ||
+ ikey->get_key_type() != UNC_KT_VBRIF_FLOWFILTER_ENTRY) {
+ UPLL_LOG_DEBUG("Ignoring ktype/Table kt=%d, tbl=%d",
+ ikey->get_key_type(), tbl);
+ return result_code;
+ }
+
+ memset(&ctrlr_dom, 0, sizeof(controller_domain));
+ val_flowfilter_entry_t *flowfilter_val =
+ reinterpret_cast<val_flowfilter_entry_t *> (GetVal(ikey));
+ if (NULL == flowfilter_val) {
+ UPLL_LOG_DEBUG(" Value structure is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
+ result_code = GetControllerDomainID(ikey, dt_type, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get the Controller Domain details, err:%d",
+ result_code);
+ }
+
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+ UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
+ ctrlr_dom.ctrlr, ctrlr_dom.domain);
+ ctrlr_id = ctrlr_dom.ctrlr;
+
+ mgr = reinterpret_cast<FlowListMoMgr *>
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
+ result_code = mgr->AddFlowListToController(
+ reinterpret_cast<char *>(flowfilter_val->flowlist_name),
+ dmi,
+ reinterpret_cast<char *>(ctrlr_id) ,
+ dt_type,
+ UNC_OP_CREATE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to Update the FlowList at ctrlr Table");
+ return result_code;
+ }
+ }
+ return result_code;
+}
upll_rc_t VbrIfFlowFilterEntryMoMgr::CreateCandidateMo(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
ConfigKeyVal* okey = NULL;
+ ConfigKeyVal* tmp_key = NULL;
uint8_t *ctrlr_id = NULL;
controller_domain ctrlr_dom;
- if (ikey == NULL && req == NULL) {
+ if (ikey == NULL || req == NULL) {
UPLL_LOG_DEBUG(
- "Cannot perform create operation due to insufficient parameters\n");
+ "Cannot perform create operation due to insufficient parameters");
return UPLL_RC_ERR_GENERIC;
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_TRACE("ikey %s", ikey->ToStrAll().c_str());
+
+ val_flowfilter_entry_t *val_ff_import = NULL;
+ pfcdrv_val_flowfilter_entry_t *pfc_val_import = NULL;
+
+ UPLL_LOG_DEBUG("datatype (%d)", req->datatype);
+
+ if (req->datatype == UPLL_DT_IMPORT) {
+ UPLL_LOG_DEBUG("Inside: %d", req->datatype);
+ if (ikey->get_cfg_val() &&
+ (ikey->get_cfg_val()->get_st_num() ==
+ IpctSt::kIpcStPfcdrvValFlowfilterEntry)) {
+ UPLL_LOG_DEBUG("val struct num (%d)",ikey->get_cfg_val()->get_st_num());
+ pfc_val_import = reinterpret_cast<pfcdrv_val_flowfilter_entry_t *>
+ (ikey->get_cfg_val()->get_val());
+ val_ff_import = reinterpret_cast<val_flowfilter_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_t)));
+ memcpy(val_ff_import, &pfc_val_import->val_ff_entry, sizeof(val_flowfilter_entry_t));
+ UPLL_LOG_DEBUG("FLOWLIST name (%s)", val_ff_import->flowlist_name);
+ ikey->SetCfgVal(NULL);
+ ikey->SetCfgVal(new ConfigVal(IpctSt::kIpcStValFlowfilterEntry, val_ff_import));
+ }
+ }
+
// validate syntax and semantics
result_code = ValidateMessage(req, ikey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG(" ValidateAttribute failed ");
return result_code;
}
-
- /*
- result_code= ValidateCapability(req, ikey);
- if (UPLL_RC_SUCCESS != result_code)
- return result_code;
- */
// Check if Object already exists in CANDIDATE DB
result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_READ, dmi);
if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS
UPLL_LOG_DEBUG("Record already exists in Candidate DB");
return result_code;
}
+ val_flowfilter_entry_t *flowfilter_val =
+ reinterpret_cast<val_flowfilter_entry_t *> (GetVal(ikey));
+ FlowListMoMgr *mgr = NULL;
+ memset(&ctrlr_dom, 0, sizeof(controller_domain));
+ result_code = GetControllerDomainID(ikey, req->datatype, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get the Controller Domain details, err:%d",
+ result_code);
+ }
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+ UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
+ ctrlr_dom.ctrlr, ctrlr_dom.domain);
+ ctrlr_id = ctrlr_dom.ctrlr;
+ result_code = GetChildConfigKey(tmp_key, NULL);
+ if(result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed in ValidateCapability");
+ return result_code;
+ }
+ result_code = GetInstanceCount(tmp_key,
+ reinterpret_cast<char*>(ctrlr_id),
+ req->datatype,
+ &cur_instance_count,
+ dmi,
+ MAINTBL);
+ delete tmp_key;
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetInstanceCount Failed in ValidateCapability");
+ return result_code;
+ }
+
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(ctrlr_id));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("validate Capability Failed %d", result_code);
+ return result_code;
+ }
// Check if Object exists in RUNNING DB and move it to CANDIDATE DB
+ if (UPLL_DT_CANDIDATE == req->datatype) {
result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
MAINTBL);
if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
result_code = RestoreChildren(ikey, req->datatype, UPLL_DT_RUNNING, dmi);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(" RestoreChildren failed. err code(%d)", result_code);
+ UPLL_LOG_DEBUG("Restore Operation Failed, err %d", result_code);
return result_code;
}
- } else if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- UPLL_LOG_DEBUG(" error reading DB. err code(%d)", result_code);
return result_code;
+ } else if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG(" error reading DB. err code(%d)", result_code);
+ return result_code;
} else {
- UPLL_LOG_DEBUG("Record doesn't exist in reading Running DB ");
+ UPLL_LOG_DEBUG("Record doesn't exist in reading Running DB ");
+ }
}
- val_flowfilter_entry_t *flowfilter_val =
- reinterpret_cast<val_flowfilter_entry_t *> (GetVal(ikey));
- FlowListMoMgr *mgr = NULL;
if (flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
mgr = reinterpret_cast<FlowListMoMgr *>
(const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
uuu::upll_strncpy(key_flowlist->flowlist_name,
flowfilter_val->flowlist_name,
(kMaxLenFlowListName +1));
- result_code = mgr->IsReferenced(okey, req->datatype, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Flowlist not available %d", result_code);
+
+ result_code = mgr->UpdateConfigDB(okey, req->datatype, UNC_OP_READ,
+ dmi, MAINTBL);
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Given FlowList does not exists %d", result_code);
+ delete okey;
return result_code;
- }
- if (okey) {
+ } else if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
+ UPLL_LOG_DEBUG("Instance Available");
+ } else if (result_code != UPLL_RC_SUCCESS) {
delete okey;
+ UPLL_LOG_DEBUG("Error Accesing CANDIDATE DB (%d)", result_code);
+ return result_code;
+ }
+ delete okey;
okey = NULL;
- }
- }
- // N/w monitor
-#if 0
- NwMonitorMoMgr *nmgr = reinterpret_cast<NwMonitorMoMgr *>
- (const_cast<MoManager *> (GetMoManager(UNC_KT_VBR_NWMONITOR)));
- // result_code = nmgr->GetChildConfigKey(okey, NULL); //TODO
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Recored %d", result_code);
- return result_code;
- }
- key_nwm_t *key_nwm = reinterpret_cast<key_nwm_t*>(okey->get_key());
- uuu::upll_strncpy(reinterpret_cast<char*>(key_nwm->nwmonitor_name),
- reinterpret_cast<const char*>(flowfilter_val->nwm_name),
- kMaxLenNwmName +1);
- // result_code = nmgr->IsReferenced(okey, req->datatype, dmi); //TODO
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Recored %d", result_code);
- return result_code;
}
-#endif
-
// create a record in CANDIDATE DB
VbrIfMoMgr *mgrvbrif =
reinterpret_cast<VbrIfMoMgr *>(const_cast<MoManager *>(GetMoManager(
vexternal, vex_if, flags);
if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ckv);
FREE_IF_NOT_NULL(vexternal);
FREE_IF_NOT_NULL(vex_if);
UPLL_LOG_DEBUG("GetVExternal failed, result_code %d", result_code);
return result_code;
}
- uint8_t flag_port_map;
+ DELETE_IF_NOT_NULL(ckv);
+ uint8_t flag_port_map = 0;
+ GET_USER_DATA_FLAGS(ikey, flag_port_map);
if (flags & kVlinkConfigured) {
- flag_port_map = SET_FLAG_VLINK;
+ flag_port_map = flag_port_map | SET_FLAG_VLINK;
} else if (flags & kPortMapConfigured) {
- flag_port_map = SET_FLAG_PORTMAP;
+ flag_port_map = flag_port_map | SET_FLAG_PORTMAP;
} else if (flags & kVlinkPortMapConfigured) {
- flag_port_map = SET_FLAG_VLINK_PORTMAP;
- } else {
- // No port map of vlink configuration
- flag_port_map = 0;
+ flag_port_map = flag_port_map | SET_FLAG_VLINK_PORTMAP;
}
-
SET_USER_DATA_FLAGS(ikey, flag_port_map);
+ if (flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
+ if ((flag_port_map & SET_FLAG_VLINK) ||
+ (flag_port_map & SET_FLAG_PORTMAP)) {
+ result_code = mgr->AddFlowListToController(
+ reinterpret_cast<char *>(flowfilter_val->flowlist_name), dmi,
+ reinterpret_cast<char *> (ctrlr_id), req->datatype, UNC_OP_CREATE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ FREE_IF_NOT_NULL(vexternal);
+ FREE_IF_NOT_NULL(vex_if);
+ UPLL_LOG_DEBUG("Reference Count Updation Fails %d", result_code);
+ return result_code;
+ }
+ }
+ }
+ DbSubOp dbop1 = { kOpNotRead, kOpMatchNone, kOpInOutDomain
+ | kOpInOutCtrlr | kOpInOutFlag };
+ result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_CREATE, dmi,
+ &dbop1, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to update CandidateDB %d", result_code);
+ }
- memset(&ctrlr_dom, 0, sizeof(controller_domain));
- result_code = GetControllerDomainID(ikey, req->datatype, dmi);
+ FREE_IF_NOT_NULL(vexternal);
+ FREE_IF_NOT_NULL(vex_if);
+ return result_code;
+}
+
+upll_rc_t VbrIfFlowFilterEntryMoMgr::CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id) {
+ UPLL_FUNC_TRACE;
+ uint8_t flags = 0;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_TRACE(" ikey is %s", ikey->ToStrAll().c_str());
+ uint8_t *controller_id = reinterpret_cast<uint8_t *>(
+ const_cast<char *>(ctrlr_id));
+
+ /* check if object is renamed in the corresponding Rename Tbl
+ * if "renamed" create the object by the UNC name.
+ * else - create using the controller name.
+ */
+ result_code = GetRenamedUncKey(ikey, UPLL_DT_RUNNING, dmi, controller_id);
+ if (result_code != UPLL_RC_SUCCESS && result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey Failed err_code %d", result_code);
+ return result_code;
+ }
+
+ pfcdrv_val_flowfilter_entry_t *pfc_val = reinterpret_cast<pfcdrv_val_flowfilter_entry_t *> (GetVal(ikey));
+ if (pfc_val == NULL) {
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ if (pfc_val->val_vbrif_vextif.interface_type == PFCDRV_IF_TYPE_VBRIF) {
+ UPLL_LOG_DEBUG("Vlink configired in vbrifff");
+ flags = SET_FLAG_VLINK;
+ }
+ else if (pfc_val->val_vbrif_vextif.interface_type == PFCDRV_IF_TYPE_VEXTIF) {
+ flags = SET_FLAG_PORTMAP;
+ }
+ else {
+ UPLL_LOG_DEBUG("Vlink not configired in vbrifff");
+ flags = 0;
+ }
+
+ ConfigKeyVal *okey = NULL;
+ result_code = GetChildConfigKey(okey, ikey);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Failed to Get the Controller Domain details, err:%d",
+ UPLL_LOG_DEBUG("GetChildConfigkey Failed :%d", result_code);
+ return result_code;
+ }
+
+ val_flowfilter_entry_t * val_ff_entry = NULL;
+ val_ff_entry = reinterpret_cast<val_flowfilter_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_t)));
+
+ memcpy(val_ff_entry, &pfc_val->val_ff_entry, sizeof(val_flowfilter_entry_t));
+ okey->AppendCfgVal(IpctSt::kIpcStValFlowfilterEntry, val_ff_entry);
+ SET_USER_DATA_FLAGS(okey, flags);
+
+ controller_domain ctrlr_dom;
+ memset(&ctrlr_dom, 0, sizeof(ctrlr_dom));
+ result_code = GetControllerDomainID(okey, UPLL_DT_AUDIT, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get the Controller Domain details,err:%d",
result_code);
+ delete okey;
+ return result_code;
}
- GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+ GET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
ctrlr_dom.ctrlr, ctrlr_dom.domain);
- ctrlr_id = ctrlr_dom.ctrlr;
- if (flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
- result_code = mgr->AddFlowListToController(
- reinterpret_cast<char *>(flowfilter_val->flowlist_name), dmi,
- reinterpret_cast<char *> (ctrlr_id) , UNC_OP_CREATE);
+ FlowListMoMgr *mgr = reinterpret_cast<FlowListMoMgr *>
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
+ if (mgr == NULL) {
+ UPLL_LOG_DEBUG("Invalid FlowListMoMgr Instance");
+ delete okey;
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ if (pfc_val->val_ff_entry.valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
+ result_code = mgr->AddFlowListToController(reinterpret_cast<char *>
+ (pfc_val->val_ff_entry.flowlist_name), dmi,
+ reinterpret_cast<char *> (const_cast<char *>(ctrlr_id)),
+ UPLL_DT_AUDIT, UNC_OP_CREATE);
if (result_code != UPLL_RC_SUCCESS) {
- FREE_IF_NOT_NULL(vexternal);
- FREE_IF_NOT_NULL(vex_if);
UPLL_LOG_DEBUG("Reference Count Updation Fails %d", result_code);
+ delete okey;
return result_code;
}
}
- result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_CREATE, dmi);
+
+ UPLL_LOG_TRACE("ikey After GetRenamedUncKey %s", ikey->ToStrAll().c_str());
+ result_code = SetValidAudit(ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ delete okey;
+ return result_code;
+ }
+ // Create a record in AUDIT DB
+ result_code = UpdateConfigDB(okey, UPLL_DT_AUDIT, UNC_OP_CREATE, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Unable to update CandidateDB %d", result_code);
+ UPLL_LOG_DEBUG("UpdateConfigDB Failed err_code %d", result_code);
+ delete okey;
+ return result_code;
}
+ delete okey;
+ return UPLL_RC_SUCCESS;
+}
- FREE_IF_NOT_NULL(vexternal);
- FREE_IF_NOT_NULL(vex_if);
+upll_rc_t VbrIfFlowFilterEntryMoMgr::AuditUpdateController(unc_key_type_t keytype,
+ const char *ctrlr_id,
+ uint32_t session_id,
+ uint32_t config_id,
+ uuc::UpdateCtrlrPhase phase1,
+ bool *ctrlr_affected,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ DalResultCode db_result = uud::kDalRcSuccess;
+ controller_domain_t ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ ConfigKeyVal *ckv_running_db = NULL;
+ ConfigKeyVal *ckv_audit_db = NULL;
+ ConfigKeyVal *ckv_driver_req = NULL;
+ ConfigKeyVal *ckv_audit_dup_db = NULL;
+ DalCursor *cursor = NULL;
+ upll_keytype_datatype_t vext_datatype = UPLL_DT_CANDIDATE;
+ uint8_t db_flag = 0;
+ uint8_t auditdb_flag = 0;
+ uint8_t *ctrlr = reinterpret_cast<uint8_t *>(const_cast<char *>(ctrlr_id));
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutCtrlr | kOpInOutDomain};
+ // Skipping the create phase if it comes as an input.
+ // vbr if flowfilter should get applied on controller(pfc) if portma/vlink is
+ // configured.
+ // The portmap/vlink request should come in the update phase so
+ // the vbrif policingmap creation should also be applied during update phase.
+ if (phase1 == uuc::kUpllUcpCreate) {
+ return result_code;
+ }
+ unc_keytype_operation_t op[2] = {UNC_OP_INVALID, UNC_OP_INVALID};
+ int nop = 0;
+ if (phase1 == uuc::kUpllUcpUpdate) {
+ op[0] = UNC_OP_UPDATE;
+ op[1] = UNC_OP_CREATE;
+ nop = 2;
+ } else if (phase1 == uuc::kUpllUcpDelete) {
+ op[0] = UNC_OP_DELETE;
+ nop = 1;
+ }
+ for (int i = 0; i < nop; i++) {
+ UPLL_LOG_DEBUG("Operation is %d", op[i]);
+ unc_keytype_operation_t op1 = op[i];
+ uuc::UpdateCtrlrPhase phase = (op[i] == UNC_OP_UPDATE)?uuc::kUpllUcpUpdate:
+ ((op[i] == UNC_OP_CREATE)?uuc::kUpllUcpCreate:
+ ((op[i] == UNC_OP_DELETE)?uuc::kUpllUcpDelete:uuc::kUpllUcpInvalid));
+ result_code = DiffConfigDB(UPLL_DT_RUNNING, UPLL_DT_AUDIT, op[i],
+ ckv_running_db, ckv_audit_db,
+ &cursor, dmi, ctrlr, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DiffConfigDB failed - %d", result_code);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ if (cursor == NULL) {
+ UPLL_LOG_DEBUG("cursor is null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ while (uud::kDalRcSuccess == (db_result = dmi->GetNextRecord(cursor))) {
+ op1 = op[i];
+ if (phase != uuc::kUpllUcpDelete) {
+ uint8_t *db_ctrlr = NULL;
+ GET_USER_DATA_CTRLR(ckv_running_db,db_ctrlr);
+ UPLL_LOG_DEBUG("db ctrl_id and audit ctlr_id are %s %s",
+ db_ctrlr, ctrlr_id);
+ // Skipping the controller ID if the controller id in DB and
+ // controller id available for Audit are not the same
+ if (db_ctrlr && strncmp(reinterpret_cast<const char *>(db_ctrlr),
+ reinterpret_cast<const char *>(ctrlr_id),
+ strlen(reinterpret_cast<const char *>(ctrlr_id)) + 1)) {
+ continue;
+ }
+ }
+ switch (phase) {
+ case uuc::kUpllUcpDelete:
+ UPLL_LOG_TRACE("Deleted record is %s ",
+ ckv_running_db->ToStrAll().c_str());
+ result_code = GetChildConfigKey(ckv_driver_req, ckv_running_db);
+ UPLL_LOG_TRACE("ckv_driver_req in delete is %s",
+ ckv_driver_req->ToStrAll().c_str());
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed. err_code & phase %d %d",
+ result_code, phase);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ if (ckv_driver_req->get_cfg_val()) {
+ UPLL_LOG_DEBUG("Invalid param");
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = ReadConfigDB(ckv_driver_req, UPLL_DT_AUDIT, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d",result_code);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ GET_USER_DATA_FLAGS(ckv_driver_req, auditdb_flag);
+ break;
+ case uuc::kUpllUcpCreate:
+ UPLL_LOG_TRACE("Created record is %s ",
+ ckv_running_db->ToStrAll().c_str());
+ result_code = DupConfigKeyVal(ckv_driver_req, ckv_running_db, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed. err_code & phase %d %d",
+ result_code, phase);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ break;
+ case uuc::kUpllUcpUpdate:
+ ckv_audit_dup_db = NULL;
+ ckv_driver_req = NULL;
+ UPLL_LOG_TRACE("UpdateRecord record is %s ",
+ ckv_running_db->ToStrAll().c_str());
+ UPLL_LOG_TRACE("UpdateRecord record is %s ",
+ ckv_audit_db->ToStrAll().c_str());
+ result_code = DupConfigKeyVal(ckv_driver_req, ckv_running_db, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed for running record. \
+ err_code & phase %d %d", result_code, phase);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ result_code = DupConfigKeyVal(ckv_audit_dup_db, ckv_audit_db, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed for audit record. \
+ err_code & phase %d %d", result_code, phase);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ GET_USER_DATA_FLAGS(ckv_audit_dup_db, auditdb_flag);
+ break;
+ default:
+ UPLL_LOG_DEBUG("Invalid operation %d", phase);
+ return UPLL_RC_ERR_NO_SUCH_OPERATION;
+ break;
+ }
+ GET_USER_DATA_CTRLR_DOMAIN(ckv_driver_req, ctrlr_dom);
+ if ((NULL == ctrlr_dom.ctrlr) || (NULL == ctrlr_dom.domain)) {
+ UPLL_LOG_INFO("controller id or domain is NULL");
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ckv_audit_dup_db);
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+ db_flag = 0;
+ GET_USER_DATA_FLAGS(ckv_driver_req, db_flag);
+ UPLL_LOG_DEBUG("dbflag 1 - %d", db_flag);
+ // If portmap/vlink flag is not set at running and the operation is
+ // update then portmap/vlink is deleted in the update phase from UNC
+ // hence flowfilter seq no also should get deleted from controller
+ // hence sending the delete request to the controller driver
+ if ((SET_FLAG_PORTMAP & db_flag) || (SET_FLAG_VLINK & db_flag)) {
+ // Continue with further operations
+ }
+ else {
+ if (UNC_OP_UPDATE == op1) {
+ op1 = UNC_OP_DELETE;
+ db_flag = auditdb_flag;
+ } else {
+ // No PortMap/Vlink Configured,
+ // Configuration is not Sent to driver
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ckv_audit_dup_db);
+ continue;
+ }
+ }
+ if (UNC_OP_UPDATE == op1) {
+ void *running_val = NULL;
+ bool invalid_attr = false;
+ running_val = GetVal(ckv_driver_req);
+ invalid_attr = FilterAttributes(running_val,
+ GetVal(ckv_audit_dup_db), false, UNC_OP_UPDATE);
+ if (invalid_attr) {
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ckv_audit_dup_db);
+ continue;
+ }
+ }
+ DELETE_IF_NOT_NULL(ckv_audit_dup_db);
+ pfcdrv_val_flowfilter_entry_t *pfc_val =
+ reinterpret_cast<pfcdrv_val_flowfilter_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(pfcdrv_val_flowfilter_entry_t)));
+ if (op1 == UNC_OP_DELETE) {
+ vext_datatype = UPLL_DT_AUDIT;
+ } else {
+ vext_datatype = UPLL_DT_RUNNING;
+ }
+ result_code = GetVexternalInformation(ckv_driver_req, vext_datatype,
+ pfc_val, db_flag, dmi);
+
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetVexternalInformation failed %d", result_code);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ free(pfc_val);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+
+ val_flowfilter_entry_t* val = reinterpret_cast<val_flowfilter_entry_t *>
+ (GetVal(ckv_driver_req));
+
+
+ pfc_val->valid[PFCDRV_IDX_FLOWFILTER_ENTRY_FFE] = UNC_VF_VALID;
+ memcpy(&pfc_val->val_ff_entry, val, sizeof(val_flowfilter_entry_t));
+ upll_keytype_datatype_t dt_type = (op1 == UNC_OP_DELETE)?
+ UPLL_DT_AUDIT:UPLL_DT_RUNNING;
+ result_code = GetRenamedControllerKey(ckv_driver_req, UPLL_DT_RUNNING,
+ dmi, &ctrlr_dom);
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG(" GetRenamedControllerKey failed err code(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ free(pfc_val);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+
+ ckv_driver_req->SetCfgVal(new ConfigVal(IpctSt::kIpcStPfcdrvValFlowfilterEntry,
+ pfc_val));
+ UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+
+ IpcResponse ipc_response;
+ memset(&ipc_response, 0, sizeof(IpcResponse));
+ IpcRequest ipc_req;
+ memset(&ipc_req, 0, sizeof(IpcRequest));
+ ipc_req.header.clnt_sess_id = session_id;
+ ipc_req.header.config_id = config_id;
+ ipc_req.header.operation = op1;
+ ipc_req.header.datatype = UPLL_DT_CANDIDATE;
+ ipc_req.ckv_data = ckv_driver_req;
+ if (!IpcUtil::SendReqToDriver((const char *)ctrlr_dom.ctrlr, reinterpret_cast<char *>
+ (ctrlr_dom.domain), PFCDRIVER_SERVICE_NAME,
+ PFCDRIVER_SVID_LOGICAL, &ipc_req, true, &ipc_response)) {
+ UPLL_LOG_INFO("Request to driver for Key %d for controller %s failed ",
+ ckv_driver_req->get_key_type(), reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (ipc_response.header.result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("driver return failure err_code is %d", ipc_response.header.result_code);
+ ConfigKeyVal *resp = NULL;
+ result_code = GetChildConfigKey(resp, ipc_response.ckv_data);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed");
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+
+ pfcdrv_val_flowfilter_entry_t *pfc_val_ff = reinterpret_cast<pfcdrv_val_flowfilter_entry_t *>
+ (GetVal(ipc_response.ckv_data));
+ if (NULL == pfc_val_ff) {
+ UPLL_LOG_DEBUG("pfcdrv_val_flowfilter_entry_t is NULL");
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(resp);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val_flowfilter_entry_t* val_ff = reinterpret_cast<val_flowfilter_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_t)));
+ memcpy(val_ff, &pfc_val_ff->val_ff_entry, sizeof(val_flowfilter_entry_t));
+ resp->AppendCfgVal(IpctSt::kIpcStValFlowfilterEntry, val_ff);
+
+
+ result_code = UpdateAuditConfigStatus(UNC_CS_INVALID, phase, resp);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("Update Audit config status failed %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(resp);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+
+ DbSubOp dbop = { kOpNotRead, kOpMatchNone, kOpInOutCs };
+ result_code = UpdateConfigDB(resp, dt_type, UNC_OP_UPDATE,
+ dmi, &dbop, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed for ipc response ckv err_code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(resp);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(resp);
+ }
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ *ctrlr_affected = true;
+ }
+ dmi->CloseCursor(cursor, true);
+ DELETE_IF_NOT_NULL(ckv_running_db);
+ DELETE_IF_NOT_NULL(ckv_audit_db);
+ }
+ if (uud::kDalRcSuccess != db_result) {
+ UPLL_LOG_DEBUG("GetNextRecord from database failed - %d", db_result);
+ result_code = DalToUpllResCode(db_result);
+ }
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)
+ ? UPLL_RC_SUCCESS : result_code;
return result_code;
}
+
upll_rc_t VbrIfFlowFilterEntryMoMgr::DeleteMo(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
DalDmlIntf *dmi) {
(const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
result_code = mgr->AddFlowListToController(
reinterpret_cast<char*>(flowfilter_val->flowlist_name), dmi,
- reinterpret_cast<char *> (ctrlr_id) , UNC_OP_DELETE);
+ reinterpret_cast<char *>(ctrlr_id), req->datatype, UNC_OP_DELETE);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG(" Send delete request to flowlist failed. err code(%d)",
result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
}
result_code = UpdateConfigDB(ikey, UPLL_DT_CANDIDATE, UNC_OP_DELETE, dmi,
MAINTBL);
- if (result_code != UPLL_RC_SUCCESS)
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(okey);
return result_code;
-
+ }
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_SUCCESS;
}
if (parent_key == NULL) {
vbr_if_ffe_key = reinterpret_cast<key_vbr_if_flowfilter_entry_t*>
(ConfigKeyVal::Malloc(sizeof(key_vbr_if_flowfilter_entry_t)));
+ // If no direction is specified , 0xFE is filled to bind output direction
+ vbr_if_ffe_key->flowfilter_key.direction = 0xFE;
okey = new ConfigKeyVal(UNC_KT_VBRIF_FLOWFILTER_ENTRY,
IpctSt::kIpcStKeyVbrIfFlowfilterEntry,
vbr_if_ffe_key, NULL);
if (okey) {
if (okey->get_key_type() != UNC_KT_VBRIF_FLOWFILTER_ENTRY)
return UPLL_RC_ERR_GENERIC;
+ }
+
+ if ((okey) && (okey->get_key())) {
vbr_if_ffe_key = reinterpret_cast<key_vbr_if_flowfilter_entry_t *>
(okey->get_key());
} else {
vbr_if_ffe_key = reinterpret_cast<key_vbr_if_flowfilter_entry_t *>
(ConfigKeyVal::Malloc(sizeof(key_vbr_if_flowfilter_entry_t)));
+ vbr_if_ffe_key->flowfilter_key.direction = 0xFE;
}
switch (parent_key->get_key_type()) {
case UNC_KT_VTN:
reinterpret_cast<key_vbr_if_flowfilter_entry_t *>
(pkey)->sequence_num;
break;
+ case UNC_KT_VBR_NWMONITOR:
+ uuu::upll_strncpy(
+ vbr_if_ffe_key->flowfilter_key.if_key.vbr_key.vtn_key.vtn_name,
+ reinterpret_cast<key_vbr_if_flowfilter_entry_t *>
+ (pkey)->flowfilter_key.if_key.vbr_key.vtn_key.vtn_name,
+ kMaxLenVtnName + 1);
+ break;
default:
if (vbr_if_ffe_key) free(vbr_if_ffe_key);
return UPLL_RC_ERR_GENERIC;
}
+
+ if ((okey) && !(okey->get_key())) {
+ UPLL_LOG_DEBUG("okey not null and flow list name updated");
+ okey->SetKey(IpctSt::kIpcStKeyVbrIfFlowfilterEntry, vbr_if_ffe_key);
+ }
+
if (!okey) {
okey = new ConfigKeyVal(UNC_KT_VBRIF_FLOWFILTER_ENTRY,
IpctSt::kIpcStKeyVbrIfFlowfilterEntry,
ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
uint8_t *ctrlr_id) {
UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *unc_key = NULL;
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vbrifff_entry start",
+ ikey->ToStrAll().c_str());
+ if ((NULL == ikey) || (ctrlr_id == NULL) || (NULL == dmi)) {
+ UPLL_LOG_DEBUG("ikey/ctrlr_id dmi NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
MoMgrImpl *VbrIfMoMgr = static_cast<MoMgrImpl*>
((const_cast<MoManager*>(GetMoManager(UNC_KT_VBRIDGE))));
- if ((NULL == VbrIfMoMgr) || (NULL == ikey)) {
- return UPLL_RC_ERR_GENERIC;}
+ if (NULL == VbrIfMoMgr) {
+ UPLL_LOG_DEBUG("VbrIfMoMgr NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
val_rename_vnode *rename_val = reinterpret_cast<val_rename_vnode*>
(ConfigKeyVal::Malloc(sizeof(val_rename_vnode)));
-
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("rename_val NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
key_vbr_if_flowfilter_entry_t *ctrlr_key = reinterpret_cast
<key_vbr_if_flowfilter_entry_t *>(ikey->get_key());
+ if (!ctrlr_key) {
+ UPLL_LOG_DEBUG("rename_val NULL");
+ free(rename_val);
+ return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(
rename_val->ctrlr_vtn_name,
ctrlr_key->flowfilter_key.if_key.vbr_key.
vtn_key.vtn_name, kMaxLenVtnName + 1);
+ rename_val->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
uuu::upll_strncpy(rename_val->ctrlr_vnode_name,
ctrlr_key->flowfilter_key.if_key.vbr_key.vbridge_name,
kMaxLenVnodeName + 1);
+ rename_val->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_VALID;
- VbrIfMoMgr->GetChildConfigKey(unc_key, NULL);
- if (ctrlr_id == NULL) {
- UPLL_LOG_DEBUG("Controller Name is Not Valid");
+ result_code = VbrIfMoMgr->GetChildConfigKey(unc_key, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get config key structure");
+ free(rename_val);
+ VbrIfMoMgr = NULL;
+ return result_code;
+ }
+ if (!unc_key) {
+ UPLL_LOG_DEBUG("unc_key NULL");
free(rename_val);
- delete unc_key;
+ VbrIfMoMgr = NULL;
return UPLL_RC_ERR_GENERIC;
}
- unc_key->set_user_data(ctrlr_id);
+ SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
unc_key->AppendCfgVal(IpctSt::kIpcStValRenameVtn, rename_val);
- upll_rc_t result_code = VbrIfMoMgr->ReadConfigDB(unc_key, dt_type ,
+ result_code = VbrIfMoMgr->ReadConfigDB(unc_key, dt_type ,
UNC_OP_READ, dbop, dmi, RENAMETBL);
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(unc_key);
+ VbrIfMoMgr = NULL;
+ return result_code;
+ }
+
if (result_code == UPLL_RC_SUCCESS) {
key_vbr_if_flowfilter_entry_t *vbr_flowfilter_entry_key = reinterpret_cast
<key_vbr_if_flowfilter_entry_t *>(unc_key->get_key());
vbr_flowfilter_entry_key->flowfilter_key.if_key.vbr_key.vbridge_name,
kMaxLenVnodeName + 1);
}
- unc_key = NULL;
+ VbrIfMoMgr = NULL;
+ DELETE_IF_NOT_NULL(unc_key);
+
+ val_flowfilter_entry_t *val_flowfilter_entry = NULL;
+ pfcdrv_val_flowfilter_entry_t *pfc_val_import = NULL;
+ if (ikey->get_cfg_val() &&
+ (ikey->get_cfg_val()->get_st_num() ==
+ IpctSt::kIpcStPfcdrvValFlowfilterEntry)) {
+ UPLL_LOG_DEBUG("val struct num (%d)", ikey->get_cfg_val()->get_st_num());
+ pfc_val_import = reinterpret_cast<pfcdrv_val_flowfilter_entry_t *>
+ (ikey->get_cfg_val()->get_val());
+ val_flowfilter_entry = &pfc_val_import->val_ff_entry;
+ UPLL_LOG_DEBUG("FLOWLIST name (%s)", val_flowfilter_entry->flowlist_name);
+ } else if (ikey->get_cfg_val() &&
+ (ikey->get_cfg_val()->get_st_num() ==
+ IpctSt::kIpcStValFlowfilterEntry)) {
+ val_flowfilter_entry = reinterpret_cast
+ <val_flowfilter_entry_t *>(GetVal(ikey));
+ }
+
+ if (!val_flowfilter_entry) {
+ UPLL_LOG_DEBUG("val_flowfilter_entry NULL");
+ return UPLL_RC_SUCCESS;
+ }
+
+ if (UNC_VF_VALID == val_flowfilter_entry
+ ->valid[UPLL_IDX_FLOWLIST_NAME_FFE]) {
val_rename_flowlist_t *rename_flowlist =
reinterpret_cast<val_rename_flowlist_t*>
(ConfigKeyVal::Malloc(sizeof(val_rename_flowlist_t)));
-
- val_flowfilter_entry_t *val_flowfilter_entry = reinterpret_cast
- <val_flowfilter_entry_t *>(GetVal(ikey));
+ if (!rename_flowlist) {
+ UPLL_LOG_DEBUG("rename_flowlist NULL");
+ free(rename_flowlist);
+ return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(rename_flowlist->flowlist_newname,
val_flowfilter_entry->flowlist_name,
(kMaxLenFlowListName + 1));
-
+ rename_flowlist->valid[UPLL_IDX_RENAME_FLOWLIST_RFL] = UNC_VF_VALID;
// FlowList Renamed
MoMgrImpl* mgr = static_cast<MoMgrImpl*>
((const_cast<MoManager*>(GetMoManager(UNC_KT_FLOWLIST))));
if (NULL == mgr) {
- FREE_IF_NOT_NULL(rename_val);
+ UPLL_LOG_DEBUG("mgr NULL");
FREE_IF_NOT_NULL(rename_flowlist);
- UPLL_LOG_DEBUG("Result Code %d", result_code);
return UPLL_RC_ERR_GENERIC;
}
+ UPLL_LOG_TRACE("flowlist name (%s) (%s) ctrlr_name (%s)",
+ rename_flowlist->flowlist_newname,
+ val_flowfilter_entry->flowlist_name,
+ ctrlr_id);
+ result_code = mgr->GetChildConfigKey(unc_key, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get config key structure");
+ if (rename_flowlist) free(rename_flowlist);
+ mgr = NULL;
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
+ unc_key->AppendCfgVal(IpctSt::kIpcStValRenameFlowlist, rename_flowlist);
+ result_code = mgr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
+ RENAMETBL);
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(unc_key);
+ mgr = NULL;
+ return result_code;
+ }
+ if (result_code == UPLL_RC_SUCCESS) {
+ key_flowlist_t *key_flowlist = reinterpret_cast <key_flowlist_t *>
+ (unc_key->get_key());
+ uuu::upll_strncpy(val_flowfilter_entry->flowlist_name,
+ key_flowlist->flowlist_name,
+ (kMaxLenFlowListName + 1));
+ }
+ DELETE_IF_NOT_NULL(unc_key);
+ mgr = NULL;
+ }
+
+ if ((UNC_VF_VALID ==
+ val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_NODE_FFE]) &&
+ (UNC_VF_VALID ==
+ val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_PORT_FFE])) {
+ unc_key_type_t child_key[]= { UNC_KT_VBRIDGE, UNC_KT_VROUTER };
+ bool isRedirectVnodeVbridge = false;
+ for (unsigned int i = 0;
+ i < sizeof(child_key)/sizeof(child_key[0]); i++) {
+ const unc_key_type_t ktype = child_key[i];
+ MoMgrImpl *mgrvbr = reinterpret_cast<MoMgrImpl *>(
+ const_cast<MoManager *>(GetMoManager(ktype)));
+ if (!mgrvbr) {
+ UPLL_LOG_TRACE("mgrvbr failed");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val_rename_vnode *rename_val = reinterpret_cast<val_rename_vnode*>
+ (ConfigKeyVal::Malloc(sizeof(val_rename_vnode)));
+ if (!rename_val) {
+ UPLL_LOG_TRACE("rename_val NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ uuu::upll_strncpy(rename_val->ctrlr_vnode_name,
+ val_flowfilter_entry->redirect_node,
+ (kMaxLenVnodeName + 1));
+ rename_val->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_VALID;
+
+ result_code = mgrvbr->GetChildConfigKey(unc_key, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Returned an error");
+ if (rename_val) free(rename_val);
+ mgrvbr = NULL;
+ return result_code;
+ }
+ SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
+ unc_key->AppendCfgVal(IpctSt::kIpcStValRenameVtn, rename_val);
+ result_code = mgrvbr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
+ RENAMETBL);
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(unc_key);
+ mgrvbr = NULL;
+ return result_code;
+ }
+
+ if (result_code == UPLL_RC_SUCCESS) {
+ if (unc_key->get_key_type() == UNC_KT_VBRIDGE) {
+ isRedirectVnodeVbridge = true;
+ key_vbr *vbr_key = reinterpret_cast<key_vbr *>(unc_key->get_key());
+ uuu::upll_strncpy(val_flowfilter_entry->redirect_node,
+ vbr_key->vbridge_name,
+ (kMaxLenVnodeName + 1));
+ } else if (unc_key->get_key_type() == UNC_KT_VROUTER) {
+ key_vrt *vrt_key = reinterpret_cast<key_vrt *>(unc_key->get_key());
+ uuu::upll_strncpy(val_flowfilter_entry->redirect_node,
+ vrt_key->vrouter_name,
+ (kMaxLenVnodeName + 1));
+ }
+ }
+ DELETE_IF_NOT_NULL(unc_key);
+ mgrvbr = NULL;
+ if (isRedirectVnodeVbridge) {
+ UPLL_LOG_DEBUG("RedirectVnode is Vbridge");
+ break;
+ }
+ }
+ }
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vbrifff_entry end",
+ ikey->ToStrAll().c_str());
+ DELETE_IF_NOT_NULL(unc_key);
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VbrIfFlowFilterEntryMoMgr::GetRenamedControllerKey(
+ ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
+ controller_domain *ctrlr_dom) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *okey = NULL;
+ uint8_t rename = 0;
+
+ /* Get the controller's redirect node(vbridge/vrt) name -start*/
+ val_flowfilter_entry_t *val_flowfilter_entry =
+ reinterpret_cast<val_flowfilter_entry_t *> (GetVal(ikey));
+
+ if (val_flowfilter_entry) {
+ if ((UNC_VF_VALID ==
+ val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_NODE_FFE]) &&
+ (UNC_VF_VALID ==
+ val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_PORT_FFE])) {
+ unc_key_type_t child_key[]= { UNC_KT_VBRIDGE, UNC_KT_VROUTER };
+ bool isRedirectVnodeVbridge = false;
+ for (unsigned int i = 0;
+ i < sizeof(child_key)/sizeof(child_key[0]); i++) {
+ const unc_key_type_t ktype = child_key[i];
+ MoMgrImpl *mgrvbr = reinterpret_cast<MoMgrImpl *>(
+ const_cast<MoManager *>(GetMoManager(ktype)));
+ if (!mgrvbr) {
+ UPLL_LOG_DEBUG("mgrvbr failed");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ result_code = mgrvbr->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+ if (NULL != ctrlr_dom) {
+ SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+ // SET_USER_DATA_CTRLR(okey, ctrlr_dom->ctrlr);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+ if (okey->get_key_type() == UNC_KT_VBRIDGE) {
+ uuu::upll_strncpy(reinterpret_cast<key_vbr_t *>
+ (okey->get_key())->vbridge_name,
+ reinterpret_cast<val_flowfilter_entry_t *>(ikey->get_cfg_val()->
+ get_val())->redirect_node, (kMaxLenVnodeName + 1));
+
+ UPLL_LOG_DEBUG("redirect node vbr name (%s) (%s)",
+ reinterpret_cast<key_vbr_t *>(okey->get_key())->vbridge_name,
+ reinterpret_cast<val_flowfilter_entry_t *>(ikey->get_cfg_val()->
+ get_val())->redirect_node);
+ } else if (okey->get_key_type() == UNC_KT_VROUTER) {
+ uuu::upll_strncpy(reinterpret_cast<key_vrt_t *>
+ (okey->get_key())->vrouter_name,
+ reinterpret_cast<val_flowfilter_entry_t *>(ikey->get_cfg_val()->
+ get_val())->redirect_node, (kMaxLenVnodeName + 1));
+
+ UPLL_LOG_DEBUG("redirect node vrt name (%s) (%s)",
+ reinterpret_cast<key_vrt_t *>(okey->get_key())->vrouter_name,
+ reinterpret_cast<val_flowfilter_entry_t *>(ikey->get_cfg_val()->
+ get_val())->flowlist_name);
+ }
+
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr | kOpMatchDomain, kOpInOutFlag };
+ result_code = mgrvbr->ReadConfigDB(okey, dt_type, UNC_OP_READ,
+ dbop, dmi, RENAMETBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ }
+
+ if (result_code == UPLL_RC_SUCCESS) {
+ val_rename_vnode *rename_val = NULL;
+ isRedirectVnodeVbridge = true;
+ rename_val = reinterpret_cast<val_rename_vnode *> (GetVal(okey));
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("rename_val NULL.");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ uuu::upll_strncpy(reinterpret_cast<val_flowfilter_entry_t*>
+ (ikey->get_cfg_val()->get_val())->redirect_node,
+ rename_val->ctrlr_vnode_name, (kMaxLenVtnName + 1));
+ }
+ DELETE_IF_NOT_NULL(okey);
+ if (isRedirectVnodeVbridge)
+ break;
+ }
+ }
+ }
+ /* -end*/
+ IsRenamed(ikey, dt_type, dmi, rename);
+ if (!rename) {
+ UPLL_LOG_DEBUG("no renamed");
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_TRACE("Start... Input ConfigKeyVal %s", ikey->ToStrAll().c_str());
+
+ MoMgrImpl *VbrIfMoMgr = static_cast<MoMgrImpl*>
+ ((const_cast<MoManager*>(GetMoManager(UNC_KT_VBRIDGE))));
+ if (NULL == VbrIfMoMgr) {
+ UPLL_LOG_DEBUG("obj null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ result_code = VbrIfMoMgr->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+
+ if (NULL != ctrlr_dom) {
+ SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom)
+ }
+ else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vbr *>(okey->get_key())->vtn_key.vtn_name,
+ reinterpret_cast <key_vbr_if_flowfilter_entry_t*>
+ (ikey->get_key())->flowfilter_key.if_key.vbr_key.vtn_key.vtn_name,
+ (kMaxLenVnodeName + 1));
+
+ UPLL_LOG_DEBUG("vtn name (%s) (%s)",
+ reinterpret_cast<key_vbr *>(okey->get_key())->vtn_key.vtn_name,
+ reinterpret_cast <key_vbr_if_flowfilter_entry_t*>
+ (ikey->get_key())->flowfilter_key.if_key.vbr_key.vtn_key.vtn_name);
+
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vbr *>(okey->get_key())->vbridge_name,
+ reinterpret_cast <key_vbr_if_flowfilter_entry_t*>
+ (ikey->get_key())->flowfilter_key.if_key.vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+
+ UPLL_LOG_DEBUG("vbr name (%s) (%s)",
+ reinterpret_cast<key_vbr *>(okey->get_key())->vbridge_name,
+ reinterpret_cast <key_vbr_if_flowfilter_entry_t*>
+ (ikey->get_key())->flowfilter_key.if_key.vbr_key.vbridge_name);
+
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr | kOpMatchDomain, kOpInOutFlag };
+ result_code= VbrIfMoMgr->ReadConfigDB(okey, dt_type, UNC_OP_READ,
+ dbop, dmi, RENAMETBL);
+ if ( result_code != UPLL_RC_SUCCESS ) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB no instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val_rename_vnode *rename_val =reinterpret_cast <val_rename_vnode *>
+ (GetVal(okey));
+
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("Vbr Name is not Valid");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ if (rename & VTN_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("vtn name renamed");
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vbr_if_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.if_key.vbr_key.vtn_key.vtn_name,
+ rename_val->ctrlr_vtn_name,
+ kMaxLenVtnName + 1);
+
+ UPLL_LOG_DEBUG("vtn name (%s) (%s)",
+ reinterpret_cast<key_vbr_if_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.if_key.vbr_key.vtn_key.vtn_name,
+ rename_val->ctrlr_vtn_name);
+ }
+
+ if (rename & VBR_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("vtn name renamed");
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vbr_if_flowfilter_entry_t*>
+ (ikey->get_key())->flowfilter_key.if_key.vbr_key.vbridge_name,
+ rename_val->ctrlr_vnode_name,
+ kMaxLenVnodeName + 1);
+
+ UPLL_LOG_DEBUG("vbr name (%s) (%s)",
+ reinterpret_cast<key_vbr_if_flowfilter_entry_t*>
+ (ikey->get_key())->flowfilter_key.if_key.vbr_key.vbridge_name,
+ rename_val->ctrlr_vnode_name);
+ }
+ DELETE_IF_NOT_NULL(okey);
+
+ // flowlist_name
+ if (rename & FLOWLIST_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("flowlist name renamed");
+ MoMgrImpl *mgrflist = static_cast<MoMgrImpl*>
+ ((const_cast<MoManager*> (GetMoManager(UNC_KT_FLOWLIST))));
+ if (mgrflist == NULL) {
+ UPLL_LOG_DEBUG("obj null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ result_code = mgrflist->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+ if (NULL != ctrlr_dom) {
+ SET_USER_DATA_CTRLR(okey, ctrlr_dom->ctrlr);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+ if (!GetVal(ikey))
+ return UPLL_RC_SUCCESS;
+ uuu::upll_strncpy(
+ reinterpret_cast<key_flowlist_t *>(okey->get_key())->flowlist_name,
+ reinterpret_cast<val_flowfilter_entry_t*>
+ (ikey->get_cfg_val()->get_val())->flowlist_name,
+ kMaxLenVnodeName + 1);
+ UPLL_LOG_DEBUG("flowlist name (%s) (%s)",
+ reinterpret_cast<key_flowlist_t *>(okey->get_key())->flowlist_name,
+ reinterpret_cast<val_flowfilter_entry_t*>
+ (ikey->get_cfg_val()->get_val())->flowlist_name);
- result_code = mgr->GetChildConfigKey(unc_key, NULL);
- SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
- unc_key->AppendCfgVal(IpctSt::kIpcStValRenameFlowlist, rename_flowlist);
- result_code = mgr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
- RENAMETBL);
- if (result_code == UPLL_RC_SUCCESS) {
- key_flowlist_t *key_flowlist = reinterpret_cast <key_flowlist_t *>
- (unc_key->get_key());
- uuu::upll_strncpy(val_flowfilter_entry->flowlist_name,
- key_flowlist->flowlist_name,
- (kMaxLenFlowListName + 1));
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
+ /* ctrlr_name */
+ result_code = mgrflist->ReadConfigDB(okey, dt_type, UNC_OP_READ,
+ dbop, dmi, RENAMETBL);
+ if ( result_code != UPLL_RC_SUCCESS ) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB no instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ // NULL Checks Missing
+ val_rename_flowlist_t *rename_val =reinterpret_cast <val_rename_flowlist_t*>
+ (GetVal(okey));
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("flowlist is not valid");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(
+ reinterpret_cast<val_flowfilter_entry_t*>
+ (ikey->get_cfg_val()->get_val())->flowlist_name,
+ rename_val->flowlist_newname,
+ (kMaxLenFlowListName + 1));
+ DELETE_IF_NOT_NULL(okey);
}
+ UPLL_LOG_TRACE("End... Input ConfigKeyVal %s", ikey->ToStrAll().c_str());
+ UPLL_LOG_DEBUG("Renamed Controller key is sucessfull.");
+ return UPLL_RC_SUCCESS;
- UPLL_LOG_DEBUG("Key is filled with UncKey Successfully %d", result_code);
- free(rename_val);
- delete unc_key;
- return result_code;
-}
-
-upll_rc_t VbrIfFlowFilterEntryMoMgr::GetRenamedControllerKey(
- ConfigKeyVal *&ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
- controller_domain *ctrlr_dom) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- ConfigKeyVal *okey = NULL;
- uint8_t rename = 0;
- IsRenamed(ikey, dt_type, dmi, rename);
- if (!rename) return UPLL_RC_SUCCESS;
+#if 0
/* Vtn renamed */
-
if (rename & VTN_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("vtn name renamed");
MoMgrImpl *mgrvtn = static_cast<MoMgrImpl*>
((const_cast<MoManager*>(GetMoManager(UNC_KT_VTN))));
if (mgrvtn == NULL) {
+ UPLL_LOG_DEBUG("obj null");
return UPLL_RC_ERR_GENERIC;
}
- mgrvtn->GetChildConfigKey(okey, NULL);
- if (ctrlr_dom)
+ result_code = mgrvtn->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+
+ if (ctrlr_dom) {
SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
uuu::upll_strncpy(
reinterpret_cast<key_vtn *>(okey->get_key())->vtn_name,
(ikey->get_key())->flowfilter_key.if_key.vbr_key.vtn_key.vtn_name,
kMaxLenVtnName + 1);
+ UPLL_LOG_DEBUG("vtn name (%s) (%s)",
+ reinterpret_cast<key_vtn *>(okey->get_key())->vtn_name,
+ reinterpret_cast<key_vbr_if_flowfilter_entry_t*>
+ (ikey->get_key())->flowfilter_key.if_key.vbr_key.vtn_key.vtn_name);
+
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
result_code = mgrvtn->ReadConfigDB(okey, dt_type,
UNC_OP_READ, dbop, dmi, RENAMETBL);
if ( result_code != UPLL_RC_SUCCESS ) {
- return UPLL_RC_ERR_GENERIC;
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
}
val_rename_vtn *rename_val = reinterpret_cast<val_rename_vtn *>
(GetVal(okey));
if (!rename_val
|| (rename_val->valid[UPLL_IDX_NEW_NAME_RVTN] != UNC_VF_VALID)) {
UPLL_LOG_DEBUG("Vtn Name is not Valid.");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
(ikey->get_key())->flowfilter_key.if_key.vbr_key.vtn_key.vtn_name,
rename_val->new_name,
kMaxLenVtnName + 1);
-
+ UPLL_LOG_DEBUG("vtn name (%s) (%s)",
+ reinterpret_cast<key_vbr_if_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.if_key.vbr_key.vtn_key.vtn_name,
+ rename_val->new_name);
SET_USER_DATA_FLAGS(ikey, rename);
+ DELETE_IF_NOT_NULL(okey);
}
// Vbr Renamed
if (rename & VBR_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("vtn name renamed");
MoMgrImpl *VbrIfMoMgr = static_cast<MoMgrImpl*>
((const_cast<MoManager*>(GetMoManager(UNC_KT_VBRIDGE))));
- if (NULL ==VbrIfMoMgr) {
+ if (NULL == VbrIfMoMgr) {
+ UPLL_LOG_DEBUG("obj null");
return UPLL_RC_ERR_GENERIC;
}
- VbrIfMoMgr->GetChildConfigKey(okey, NULL);
- if (ctrlr_dom)
- SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+
+ result_code = VbrIfMoMgr->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+
+ if (NULL != ctrlr_dom) {
+ SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom)
+ }
+ else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
uuu::upll_strncpy(
reinterpret_cast<key_vbr *>(okey->get_key())->vbridge_name,
(ikey->get_key())->flowfilter_key.if_key.vbr_key.vbridge_name,
(kMaxLenVnodeName + 1));
+ UPLL_LOG_DEBUG("vbr name (%s) (%s)",
+ reinterpret_cast<key_vbr *>(okey->get_key())->vbridge_name,
+ reinterpret_cast <key_vbr_if_flowfilter_entry_t*>
+ (ikey->get_key())->flowfilter_key.if_key.vbr_key.vbridge_name);
+
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
result_code= VbrIfMoMgr->ReadConfigDB(okey, dt_type, UNC_OP_READ,
dbop, dmi, RENAMETBL);
if ( result_code != UPLL_RC_SUCCESS ) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
val_rename_vbr *rename_val =reinterpret_cast <val_rename_vbr *>
(GetVal(okey));
if (!rename_val
- || (rename_val->valid[UPLL_IDX_NEW_NAME_RVBR] != UNC_VF_VALID))
+ || (rename_val->valid[UPLL_IDX_NEW_NAME_RVBR] != UNC_VF_VALID)) {
+ UPLL_LOG_DEBUG("Vbr Name is not Valid");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(
reinterpret_cast<key_vbr_if_flowfilter_entry_t*>
kMaxLenVnodeName + 1);
SET_USER_DATA_FLAGS(ikey, rename);
+ DELETE_IF_NOT_NULL(okey);
}
// flowlist_name
if (rename & FLOWLIST_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("flowlist name renamed");
MoMgrImpl *mgrflist = static_cast<MoMgrImpl*>
((const_cast<MoManager*> (GetMoManager(UNC_KT_FLOWLIST))));
if (mgrflist == NULL) {
+ UPLL_LOG_DEBUG("obj null");
return UPLL_RC_ERR_GENERIC;
}
- mgrflist->GetChildConfigKey(okey, ikey);
- if (ctrlr_dom)
+ result_code = mgrflist->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+ if (NULL != ctrlr_dom) {
SET_USER_DATA_CTRLR(okey, ctrlr_dom->ctrlr);
-
+ } else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
uuu::upll_strncpy(
reinterpret_cast<key_flowlist_t *>(okey->get_key())->flowlist_name,
reinterpret_cast<val_flowfilter_entry_t*>
(ikey->get_cfg_val()->get_val())->flowlist_name,
kMaxLenVnodeName + 1);
+ UPLL_LOG_DEBUG("flowlist name (%s) (%s)",
+ reinterpret_cast<key_flowlist_t *>(okey->get_key())->flowlist_name,
+ reinterpret_cast<val_flowfilter_entry_t*>
+ (ikey->get_cfg_val()->get_val())->flowlist_name);
+
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
/* ctrlr_name */
result_code = mgrflist->ReadConfigDB(okey, dt_type, UNC_OP_READ,
dbop, dmi, RENAMETBL);
if ( result_code != UPLL_RC_SUCCESS ) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
// NULL Checks Missing
val_rename_flowlist_t *rename_val =reinterpret_cast <val_rename_flowlist_t*>
(GetVal(okey));
- if (!rename_val
- || (rename_val->valid[UPLL_IDX_NEW_NAME_RVTN] != UNC_VF_VALID))
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("flowlist is not valid");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(
reinterpret_cast<val_flowfilter_entry_t*>
(ikey->get_cfg_val()->get_val())->flowlist_name,
rename_val->flowlist_newname,
(kMaxLenFlowListName + 1));
SET_USER_DATA_FLAGS(ikey, rename);
- delete okey;
+ DELETE_IF_NOT_NULL(okey);
}
-
UPLL_LOG_DEBUG("Renamed Controller key is sucessfull.");
return UPLL_RC_SUCCESS;
+#endif
}
upll_rc_t VbrIfFlowFilterEntryMoMgr::RenameMo(IpcReqRespHeader *req,
}
upll_rc_t VbrIfFlowFilterEntryMoMgr::MergeValidate(unc_key_type_t keytype,
- const char *ctrlr_id,
- ConfigKeyVal *ikey,
- DalDmlIntf *dmi) {
+ const char *ctrlr_id,
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
- ConfigKeyVal *tkey;
- ConfigKeyVal *keyval = NULL;
- if (NULL == ikey) {
- UPLL_LOG_DEBUG("ikey is NUll");
+
+ ConfigKeyVal *ckval = NULL;
+ if (NULL == ctrlr_id) {
+ UPLL_LOG_DEBUG("ctrlr_id NULL");
return result_code;
}
- result_code = ReadConfigDB(ikey, UPLL_DT_IMPORT, UNC_OP_READ, dbop, dmi,
- MAINTBL);
+ result_code = GetChildConfigKey(ckval, NULL);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG(" ReadConfigDB is not Success %d", result_code);
+ UPLL_LOG_DEBUG("ckval fail");
return result_code;
}
- MoMgrImpl *mgr = static_cast<MoMgrImpl*>
- ((const_cast<MoManager*>(GetMoManager(UNC_KT_FLOWLIST))));
- tkey = ikey;
- while (ikey != NULL) {
- result_code = mgr->GetChildConfigKey(keyval, NULL);
- /* Dead Code */
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(" GetChildConfigKey is Not Success %d", result_code);
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone};
+ result_code = ReadConfigDB(ckval, UPLL_DT_IMPORT,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ckval);
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
return result_code;
}
- val_flowfilter_entry_t *flowfilter_val = reinterpret_cast
- <val_flowfilter_entry_t *>(GetVal(ikey));
- key_flowlist_t *key_flowlist =reinterpret_cast<key_flowlist_t *>
- (keyval->get_key());
- uuu::upll_strncpy(key_flowlist->flowlist_name,
- flowfilter_val->flowlist_name,
- (kMaxLenFlowListName + 1));
- result_code = mgr->UpdateConfigDB(keyval, UPLL_DT_CANDIDATE, UNC_OP_READ,
- dmi, MAINTBL);
- if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
- UPLL_LOG_DEBUG("UpdateConfigDB::not Success %d", result_code);
- return UPLL_RC_ERR_MERGE_CONFLICT;
+ return UPLL_RC_SUCCESS;
+ }
+ ConfigKeyVal *first_ckv = ckval;
+ while (NULL != ckval) {
+ val_flowfilter_entry_t* val = reinterpret_cast<val_flowfilter_entry_t *>
+ (GetVal(ckval));
+ if ((val->valid[UPLL_IDX_REDIRECT_NODE_FFE] ==
+ UNC_VF_VALID) &&
+ (val->valid[UPLL_IDX_REDIRECT_PORT_FFE] ==
+ UNC_VF_VALID)) {
+ result_code = VerifyRedirectDestination(ckval, dmi, UPLL_DT_IMPORT);
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(first_ckv);
+ UPLL_LOG_DEBUG("redirect-destination node/interface doesn't exists");
+ return UPLL_RC_ERR_MERGE_CONFLICT;
+ }
}
- ikey = tkey->get_next_cfg_key_val();
+ ckval = ckval->get_next_cfg_key_val();
}
- if (tkey) delete tkey;
- UPLL_LOG_DEBUG("MergeValidate is Success.");
- return UPLL_RC_SUCCESS;
+ DELETE_IF_NOT_NULL(first_ckv);
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_VBRIF_FLOWFILTER)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Invalid mgr param");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ result_code = mgr->MergeValidate(keytype, ctrlr_id, ikey, dmi);
+ UPLL_LOG_DEBUG("MergeValidate result code (%d)", result_code);
+ return result_code;
}
upll_rc_t VbrIfFlowFilterEntryMoMgr::UpdateAuditConfigStatus(
if (NULL == val) {
return UPLL_RC_ERR_GENERIC;
}
-
if (uuc::kUpllUcpCreate == phase )
- val->cs_row_status = cs_status;
+ val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
for ( unsigned int loop = 0;
- loop < sizeof(val->valid)/sizeof(val->valid[0]); loop++ ) {
- if ( cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop])
- val->cs_attr[loop] = cs_status;
- else
- val->cs_attr[loop] = cs_status;
+ loop < sizeof(val->valid)/sizeof(uint8_t); ++loop ) {
+ if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
+ cs_status == UNC_CS_APPLIED)
+ val->cs_attr[loop] = cs_status;
}
-
UPLL_LOG_DEBUG("UpdateAuditConfigStatus::Success");
return result_code;
}
bool VbrIfFlowFilterEntryMoMgr::IsValidKey(void *key,
uint64_t index) {
UPLL_FUNC_TRACE;
- bool ret_val = UPLL_RC_SUCCESS;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
key_vbr_if_flowfilter_entry_t *ff_key =
reinterpret_cast<key_vbr_if_flowfilter_entry_t *>(key);
if (ff_key == NULL)
UPLL_LOG_DEBUG("Error Accesing CANDIDATE DB (%d)", result_code);
return result_code;
}
- if (okey != NULL) {
- delete okey;
- okey = NULL;
- }
- }
- if (UNC_VF_VALID == flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] ||
- UNC_VF_VALID_NO_VALUE == flowfilter_val->
- valid[UPLL_IDX_FLOWLIST_NAME_FFE]) {
- result_code = GetChildConfigKey(okey, ikey);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("GetChildConfigKey failed");
- return result_code;
- }
- DbSubOp dbop = { kOpReadSingle, kOpMatchNone,
- kOpInOutCtrlr|kOpInOutDomain };
- result_code = ReadConfigDB(okey, UPLL_DT_CANDIDATE, UNC_OP_READ, dbop, dmi,
- MAINTBL);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
- return result_code;
- }
- GET_USER_DATA_CTRLR(okey, ctrlr_id);
- val_flowfilter_entry_t *temp_ffe_val = reinterpret_cast
- <val_flowfilter_entry_t *>(GetVal(okey));
- UPLL_LOG_DEBUG("flowlist name %s", flowfilter_val->flowlist_name);
- if (UNC_VF_VALID == flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_VFFE] &&
- UNC_VF_VALID == temp_ffe_val->
- valid[UPLL_IDX_FLOWLIST_NAME_VFFE]) {
- UPLL_LOG_DEBUG("Update option 1");
- result_code = flowlist_mgr->AddFlowListToController(
- reinterpret_cast<char *>(temp_ffe_val->flowlist_name), dmi,
- reinterpret_cast<char *>(ctrlr_id) , UNC_OP_DELETE);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("AddFlowListToController failed %d", result_code);
- delete okey;
- return result_code;
- }
- result_code = flowlist_mgr->AddFlowListToController(
- reinterpret_cast<char *>(flowfilter_val->flowlist_name), dmi,
- reinterpret_cast<char *> (ctrlr_id) , UNC_OP_CREATE);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("AddFlowListToController failed %d", result_code);
- delete okey;
- return result_code;
- }
- } else if (UNC_VF_VALID == flowfilter_val->
- valid[UPLL_IDX_FLOWLIST_NAME_VFFE] &&
- (UNC_VF_INVALID == temp_ffe_val->
- valid[UPLL_IDX_FLOWLIST_NAME_VFFE] || UNC_VF_VALID_NO_VALUE ==
- temp_ffe_val->valid[UPLL_IDX_FLOWLIST_NAME_VFFE])) {
- UPLL_LOG_DEBUG("Update option 2");
- result_code = flowlist_mgr->AddFlowListToController(
- reinterpret_cast<char *>(flowfilter_val->flowlist_name), dmi,
- reinterpret_cast<char *>(ctrlr_id) , UNC_OP_CREATE);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("AddFlowListToController failed %d", result_code);
- delete okey;
- return result_code;
- }
- } else if (UNC_VF_VALID_NO_VALUE == flowfilter_val->
- valid[UPLL_IDX_FLOWLIST_NAME_VFFE] &&
- UNC_VF_VALID == temp_ffe_val->
- valid[UPLL_IDX_FLOWLIST_NAME_VFFE]) {
- UPLL_LOG_DEBUG("Update option 3");
- result_code = flowlist_mgr->AddFlowListToController(
- reinterpret_cast<char *>(temp_ffe_val->flowlist_name), dmi,
- reinterpret_cast<char *>(ctrlr_id) , UNC_OP_DELETE);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("AddFlowListToController failed %d", result_code);
- delete okey;
- return result_code;
- }
- }
+ delete okey;
+ okey = NULL;
}
- // N/w monitor
-#if 0
- NwMonitorMoMgr *nmgr = reinterpret_cast<NwMonitorMoMgr *>
- (const_cast<MoManager *> (GetMoManager(UNC_KT_VBR_NWMONITOR)));
- // result_code = nmgr->GetChildConfigKey(okey, NULL); //TODO
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Recored %d", result_code);
+ // Get controller id to do capa check
+ result_code = GetChildConfigKey(okey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed");
return result_code;
}
- key_nwm_t *key_nwm = reinterpret_cast<key_nwm_t*>(okey->get_key());
- uuu::upll_strncpy(key_nwm->nwmonitor_name,
- flowfilter_val->nwm_name,
- (kMaxLenNwmName +1));
- // result_code = nmgr->IsReferenced(okey, req->datatype, dmi); //TODO
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Recored %d", result_code);
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone,
+ kOpInOutCtrlr|kOpInOutDomain|kOpInOutFlag };
+ result_code = ReadConfigDB(okey, UPLL_DT_CANDIDATE, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+
+ if (UPLL_RC_SUCCESS != result_code) {
+ delete okey;
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
return result_code;
}
-#endif
+ GET_USER_DATA_CTRLR(okey, ctrlr_id);
+ result_code= ValidateCapability(req, ikey,
+ reinterpret_cast<const char*>(ctrlr_id));
+ if (UPLL_RC_SUCCESS != result_code) {
+ delete okey;
+ UPLL_LOG_DEBUG("ValidateCapability failed %d", result_code);
+ return result_code;
+ }
+
+ uint8_t dbflag = 0;
+ GET_USER_DATA_FLAGS(okey, dbflag);
+ if (UNC_VF_VALID == flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] ||
+ UNC_VF_VALID_NO_VALUE == flowfilter_val->
+ valid[UPLL_IDX_FLOWLIST_NAME_FFE]) {
+ if ((dbflag & SET_FLAG_VLINK) || (dbflag & SET_FLAG_PORTMAP)) {
+ val_flowfilter_entry_t *temp_ffe_val = reinterpret_cast
+ <val_flowfilter_entry_t *>(GetVal(okey));
+ UPLL_LOG_DEBUG("flowlist name %s", flowfilter_val->flowlist_name);
+ if ((UNC_VF_VALID == flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_VFFE])
+ && (UNC_VF_VALID == temp_ffe_val->
+ valid[UPLL_IDX_FLOWLIST_NAME_VFFE])) {
+ UPLL_LOG_DEBUG("Update option 1");
+ result_code = flowlist_mgr->AddFlowListToController(
+ reinterpret_cast<char *>(temp_ffe_val->flowlist_name), dmi,
+ reinterpret_cast<char *>(ctrlr_id), req->datatype, UNC_OP_DELETE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("AddFlowListToController failed %d", result_code);
+ delete okey;
+ return result_code;
+ }
+ result_code = flowlist_mgr->AddFlowListToController(
+ reinterpret_cast<char *>(flowfilter_val->flowlist_name), dmi,
+ reinterpret_cast<char *> (ctrlr_id), req->datatype, UNC_OP_CREATE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("AddFlowListToController failed %d", result_code);
+ delete okey;
+ return result_code;
+ }
+ } else if (UNC_VF_VALID == flowfilter_val->
+ valid[UPLL_IDX_FLOWLIST_NAME_VFFE] &&
+ (UNC_VF_INVALID == temp_ffe_val->
+ valid[UPLL_IDX_FLOWLIST_NAME_VFFE] || UNC_VF_VALID_NO_VALUE ==
+ temp_ffe_val->valid[UPLL_IDX_FLOWLIST_NAME_VFFE])) {
+ UPLL_LOG_DEBUG("Update option 2");
+ result_code = flowlist_mgr->AddFlowListToController(
+ reinterpret_cast<char *>(flowfilter_val->flowlist_name), dmi,
+ reinterpret_cast<char *>(ctrlr_id),
+ req->datatype, UNC_OP_CREATE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("AddFlowListToController failed %d", result_code);
+ delete okey;
+ return result_code;
+ }
+ } else if (UNC_VF_VALID_NO_VALUE == flowfilter_val->
+ valid[UPLL_IDX_FLOWLIST_NAME_VFFE] &&
+ UNC_VF_VALID == temp_ffe_val->
+ valid[UPLL_IDX_FLOWLIST_NAME_VFFE]) {
+ UPLL_LOG_DEBUG("Update option 3");
+ result_code = flowlist_mgr->AddFlowListToController(
+ reinterpret_cast<char *>(temp_ffe_val->flowlist_name), dmi,
+ reinterpret_cast<char *>(ctrlr_id) ,
+ req->datatype, UNC_OP_DELETE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("AddFlowListToController failed %d",
+ result_code);
+ delete okey;
+ return result_code;
+ }
+ }
+ }
+ }
+
+ DbSubOp dbop1 = {kOpNotRead, kOpMatchNone, kOpInOutFlag};
result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_UPDATE, dmi,
- MAINTBL);
+ &dbop1, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("DB Error while updating the candidatedb");
return UPLL_RC_SUCCESS;
}
+#if 0
upll_rc_t VbrIfFlowFilterEntryMoMgr::UpdateConfigStatus(
ConfigKeyVal *key, unc_keytype_operation_t op, uint32_t driver_result,
ConfigKeyVal *upd_key, DalDmlIntf *dmi, ConfigKeyVal *ctrlr_key) {
}
} else if (op == UNC_OP_UPDATE) {
void *val = reinterpret_cast<void *>(vbrflowfilter_entry_val);
- CompareValidValue(val, GetVal(upd_key), false);
+ CompareValidValue(val, GetVal(upd_key), true);
for (unsigned int loop = 0;
loop < sizeof(vbrflowfilter_entry_val->valid); ++loop) {
if (vbrflowfilter_entry_val->cs_attr[loop] != UNC_CS_NOT_SUPPORTED)
UPLL_LOG_DEBUG("UpdateConfigStatus Success");
return result_code;
}
+#endif
upll_rc_t VbrIfFlowFilterEntryMoMgr::AllocVal(ConfigVal *&ck_val,
upll_keytype_datatype_t dt_type,
UPLL_LOG_DEBUG("AllocVal Success");
return UPLL_RC_SUCCESS;
}
+/*Return result of validation*/
+upll_rc_t VbrIfFlowFilterEntryMoMgr::TxVote(unc_key_type_t keytype,
+ DalDmlIntf *dmi,
+ ConfigKeyVal **err_ckv) {
+ UPLL_FUNC_TRACE;
+ ConfigKeyVal *req = NULL, *nreq = NULL;
+ DalResultCode db_result;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ unc_keytype_operation_t op[]= { UNC_OP_CREATE, UNC_OP_UPDATE};
+ int nop = sizeof(op) / sizeof(op[0]);
+ DalCursor *cfg1_cursor = NULL;
+ // uint8_t *ctrlr_id = NULL;
+
+ for (int i = 0; i < nop; i++) {
+ result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i], req,
+ nreq, &cfg1_cursor, dmi, MAINTBL);
+ while (result_code == UPLL_RC_SUCCESS) {
+ db_result = dmi->GetNextRecord(cfg1_cursor);
+ result_code = DalToUpllResCode(db_result);
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_DEBUG("No diff found for op %d", op[i]);
+ break;
+ }
+ val_flowfilter_entry_t* val = reinterpret_cast<val_flowfilter_entry_t *>
+ (GetVal(req));
+ if ((val->valid[UPLL_IDX_REDIRECT_NODE_FFE] ==
+ UNC_VF_VALID) &&
+ (val->valid[UPLL_IDX_REDIRECT_PORT_FFE] ==
+ UNC_VF_VALID)) {
+ result_code = VerifyRedirectDestination(req, dmi,
+ UPLL_DT_CANDIDATE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Invalid redirect-destination node/interface");
+ *err_ckv = req;
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ }
+ }
+ dmi->CloseCursor(cfg1_cursor, true);
+ if (req) delete req;
+ if (nreq) delete nreq;
+ }
+ return result_code;
+}
+
+upll_rc_t VbrIfFlowFilterEntryMoMgr::VerifyRedirectDestination(
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t dt_type) {
+ UPLL_FUNC_TRACE;
+ MoMgrImpl *mgr = NULL;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *okey = NULL;
+ if (!ikey || !ikey->get_key()) {
+ UPLL_LOG_DEBUG("input key is null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ controller_domain ctrlr_dom;
+ memset(&ctrlr_dom, 0, sizeof(controller_domain));
+ key_vbr_if_flowfilter_entry_t *key_vbrif_ffe =
+ reinterpret_cast<key_vbr_if_flowfilter_entry_t *>(ikey->get_key());
+
+ /* read val_vtn_flowfilter_entry from ikey*/
+ val_flowfilter_entry_t *val_flowfilter_entry =
+ static_cast<val_flowfilter_entry_t *>(
+ ikey->get_cfg_val()->get_val());
+ // Symentic Validation for redirect destination
+ if ((val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_NODE_FFE] ==
+ UNC_VF_VALID) &&
+ (val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_PORT_FFE] ==
+ UNC_VF_VALID)) {
+ DbSubOp dbop_up = { kOpReadExist, kOpMatchCtrlr|kOpMatchDomain,
+ kOpInOutNone };
+ result_code = GetControllerDomainID(ikey, dt_type, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get the Controller Domain details, err:%d",
+ result_code);
+ }
+
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+
+ UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
+ ctrlr_dom.ctrlr, ctrlr_dom.domain);
+ // Verify whether the vtnnode and interface are exists in DB
+ // 1. Check for the vbridge Node
+ mgr = reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VBR_IF)));
+ if (NULL == mgr) {
+ UPLL_LOG_DEBUG("Unable to get VBRIDGE Interface object");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = mgr->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Memory allocation failed for VBRIDGE key struct - %d",
+ result_code);
+ return result_code;
+ }
+ key_vbr_if_t *vbrif_key = static_cast<key_vbr_if_t*>(
+ okey->get_key());
+ uuu::upll_strncpy(vbrif_key->vbr_key.vtn_key.vtn_name,
+ key_vbrif_ffe->flowfilter_key.if_key.vbr_key.vtn_key.vtn_name,
+ kMaxLenVtnName + 1);
+
+ uuu::upll_strncpy(vbrif_key->vbr_key.vbridge_name,
+ reinterpret_cast<char *>
+ (val_flowfilter_entry->redirect_node),
+ (kMaxLenVnodeName + 1));
+ uuu::upll_strncpy(vbrif_key->if_name,
+ reinterpret_cast<char *>
+ (val_flowfilter_entry->redirect_port),
+ kMaxLenInterfaceName + 1);
+
+ /* Check vtnnode and interface exists in table*/
+
+ SET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
+
+ result_code = mgr->UpdateConfigDB(okey, dt_type,
+ UNC_OP_READ, dmi, &dbop_up, MAINTBL);
+
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ UPLL_LOG_DEBUG("vtn node/interface in val_flowfilter_entry exists"
+ "in DB");
+ } else if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ DELETE_IF_NOT_NULL(okey);
+ // 2. Check for Vrouter Node
+
+ // Verify whether the vtnnode and interface are exists in DB
+ mgr = reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VRT_IF)));
+ if (NULL == mgr) {
+ UPLL_LOG_DEBUG("Unable to get VROUTER Interface object");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = mgr->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Memory allocation failed for VROUTER key struct - %d",
+ result_code);
+ return result_code;
+ }
+ key_vrt_if_t *vrtif_key = static_cast<key_vrt_if_t*>(
+ okey->get_key());
+ uuu::upll_strncpy(vrtif_key->vrt_key.vtn_key.vtn_name,
+ key_vbrif_ffe->flowfilter_key.if_key.vbr_key.vtn_key.vtn_name,
+ kMaxLenVtnName + 1);
+
+ uuu::upll_strncpy(vrtif_key->vrt_key.vrouter_name,
+ reinterpret_cast<char *>
+ (val_flowfilter_entry->redirect_node),
+ (kMaxLenVnodeName + 1));
+ uuu::upll_strncpy(vrtif_key->if_name,
+ reinterpret_cast<char *>
+ (val_flowfilter_entry->redirect_port),
+ kMaxLenInterfaceName + 1);
+
+ UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
+ ctrlr_dom.ctrlr, ctrlr_dom.domain);
+ SET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
+ /* Check vtnnode and interface exists in table*/
+ result_code = mgr->UpdateConfigDB(okey, dt_type,
+ UNC_OP_READ, dmi, &dbop_up, MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code) {
+ UPLL_LOG_DEBUG("vtn node/interface in val struct does not exists"
+ "in DB");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ }
+ result_code =
+ (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) ? UPLL_RC_SUCCESS :
+ result_code;
+ DELETE_IF_NOT_NULL(okey);
+ } // end of Symentic Validation
+ return result_code;
+}
upll_rc_t VbrIfFlowFilterEntryMoMgr::ValidateAttribute(ConfigKeyVal *ikey,
DalDmlIntf *dmi,
val_flowfilter_entry->flowlist_name,
kMaxLenFlowListName+1);
- UPLL_LOG_TRACE("Flowlist name in val_flowfilter_entry %s",
- key_flowlist->flowlist_name);
+ UPLL_LOG_TRACE("Flowlist name in val_flowfilter_entry %s data type (%d)",
+ key_flowlist->flowlist_name, req->datatype);
/* Check flowlist_name exists in table*/
result_code = mgr->UpdateConfigDB(okey, req->datatype,
if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code) {
UPLL_LOG_DEBUG("Flowlist name in val_flowfilter_entry does not exists"
- "in FLOWLIST table");
+ "in FLOWLIST table result code (%d)", result_code);
delete okey;
okey = NULL;
return UPLL_RC_ERR_CFG_SEMANTIC;
delete okey;
okey = NULL;
}
-
if (val_flowfilter_entry->valid[UPLL_IDX_NWM_NAME_FFE]
== UNC_VF_VALID) {
// validate nwm_name in KT_VBR_NWMONITOR table*/
delete okey;
okey = NULL;
} // nwm_name is valid
+ result_code = SetRenameFlag(ikey, dmi, req);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("SetRenameFlag failed %d", result_code);
+ return result_code;
+ }
UPLL_LOG_DEBUG("ValidateAttribute Successfull.");
return result_code;
}
result_code = DupConfigKeyVal(l_key, ikey, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG(" DupConfigKeyVal failed for l_key%d ", result_code);
+ delete dup_key;
return result_code;
}
GET_USER_DATA_CTRLR_DOMAIN(dup_key, ctrlr_dom);
SET_USER_DATA_CTRLR_DOMAIN(l_key, ctrlr_dom);
+
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(ctrlr_dom.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ delete dup_key;
+ delete l_key;
+ UPLL_LOG_DEBUG("validate Capability Failed %d", result_code);
+ return result_code;
+ }
+
// 1.Getting renamed name if renamed
result_code = GetRenamedControllerKey(l_key, req->datatype, dmi,
&ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
+ delete dup_key;
+ delete l_key;
return result_code;
}
result_code = DupConfigKeyVal(flag_key, ikey, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG(" DupConfigKeyVal failed for l_key%d ", result_code);
+ delete dup_key;
+ delete l_key;
return result_code;
}
UNC_OP_READ, dbop2, dmi, MAINTBL);
if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
UPLL_LOG_DEBUG("No Recrods in the Vbr_If_FlowFilter_Entry Table");
+ delete dup_key;
+ delete l_key;
+ delete flag_key;
return UPLL_RC_SUCCESS;
}
pfc_val, db_flag, dmi);
if (UPLL_RC_SUCCESS != result_code) {
+ delete dup_key;
+ delete l_key;
+ delete flag_key;
return result_code;
}
-
pfc_val->valid[PFCDRV_IDX_FLOWFILTER_ENTRY_FFE] = UNC_VF_VALID;
l_key->SetCfgVal(new ConfigVal(IpctSt::kIpcStPfcdrvValFlowfilterEntry,
pfc_val));
UPLL_LOG_DEBUG("SendReqToDriver failed for Key %d controller %s",
l_key->get_key_type(),
reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ DELETE_IF_NOT_NULL(ipc_req.ckv_data);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(flag_key);
return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_INFO("Driver response for Key %d controller %s result %d",
l_key->get_key_type(), ctrlr_dom.ctrlr,
ipc_resp.header.result_code);
+ DELETE_IF_NOT_NULL(ipc_req.ckv_data);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(flag_key);
return ipc_resp.header.result_code;
}
ConfigKeyVal *okey = NULL;
result_code = ConstructReadDetailResponse(dup_key,
ipc_resp.ckv_data,
- dmi, &okey);
+ &okey);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(flag_key);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ConstructReadDetailResponse error code (%d)",
result_code);
- DELETE_IF_NOT_NULL(dup_key);
- DELETE_IF_NOT_NULL(l_key);
- DELETE_IF_NOT_NULL(flag_key);
return result_code;
} else {
if (okey != NULL) {
ikey->ResetWith(okey);
+ DELETE_IF_NOT_NULL(okey);
}
}
- DELETE_IF_NOT_NULL(dup_key);
- DELETE_IF_NOT_NULL(l_key);
- DELETE_IF_NOT_NULL(flag_key);
}
break;
default:
GET_USER_DATA_CTRLR_DOMAIN(dup_key, ctrlr_dom);
SET_USER_DATA_CTRLR_DOMAIN(l_key, ctrlr_dom);
+
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(ctrlr_dom.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ delete dup_key;
+ delete l_key;
+ UPLL_LOG_DEBUG("validate Capability Failed %d", result_code);
+ return result_code;
+ }
+
// 1.Getting renamed name if renamed
result_code = GetRenamedControllerKey(l_key, req->datatype, dmi,
&ctrlr_dom);
ipc_req.header.operation = UNC_OP_READ;
ipc_req.header.option1 = req->option1;
ipc_req.header.datatype = req->datatype;
+
tmp_key = tctrl_key;
while (tmp_key != NULL) {
reinterpret_cast<key_vbr_if_flowfilter_entry_t*>
result_code = ConstructReadDetailResponse(tmp_key,
ipc_resp.ckv_data,
- dmi, &okey);
+ &okey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ConstructReadDetailResponse error code (%d)",
return UPLL_RC_ERR_GENERIC;
}
- if (UNC_KT_VBRIF_FLOWFILTER_ENTRY == ikey->get_key_type()) {
key_rename_vnode_info *key_rename = NULL;
key_rename = reinterpret_cast<key_rename_vnode_info *> (ikey->get_key());
key_vbr_if_flowfilter_entry_t * key_vbr_if_ff_entry =
(ConfigKeyVal::Malloc(sizeof(key_vbr_if_flowfilter_entry_t)));
if (!strlen(reinterpret_cast<char *> (key_rename->old_unc_vtn_name))) {
- UPLL_LOG_DEBUG("String Length not Valid to Perform the Operation");
- free(key_vbr_if_ff_entry);
+ UPLL_LOG_DEBUG("old_unc_vtn_name NULL");
+ if(key_vbr_if_ff_entry) free(key_vbr_if_ff_entry);
return UPLL_RC_ERR_GENERIC;
}
key_rename->old_unc_vtn_name,
(kMaxLenVtnName + 1));
- if (ikey->get_key_type() == table[MAINTBL]->get_key_type()) {
- if (!strlen(reinterpret_cast<char *> (key_rename->old_unc_vnode_name))) {
+ if (UNC_KT_VBRIDGE == ikey->get_key_type()) {
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vnode_name))) {
+ UPLL_LOG_DEBUG("old_unc_vnode_name NULL");
free(key_vbr_if_ff_entry);
return UPLL_RC_ERR_GENERIC;
}
- uuu::upll_strncpy(
- key_vbr_if_ff_entry->flowfilter_key.if_key.vbr_key.vbridge_name,
- key_rename->old_unc_vnode_name,
- (kMaxLenVnodeName + 1));
+ uuu::upll_strncpy(key_vbr_if_ff_entry->flowfilter_key.if_key.vbr_key.vbridge_name,
+ key_rename->old_unc_vnode_name, (kMaxLenVnodeName + 1));
+ } else {
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_unc_vnode_name))) {
+ UPLL_LOG_DEBUG("new_unc_vnode_name NULL");
+ free(key_vbr_if_ff_entry);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(key_vbr_if_ff_entry->flowfilter_key.if_key.vbr_key.vbridge_name,
+ key_rename->new_unc_vnode_name, (kMaxLenVnodeName + 1));
}
+ key_vbr_if_ff_entry->flowfilter_key.direction = 0xFE;
okey = new ConfigKeyVal(UNC_KT_VBRIF_FLOWFILTER_ENTRY,
IpctSt::kIpcStKeyVbrIfFlowfilterEntry,
key_vbr_if_ff_entry, NULL);
- } else if (UNC_KT_FLOWLIST == ikey->get_key_type()) {
- key_rename_vnode_info_t *key_rename =
- reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
- val_flowfilter_entry_t *val = reinterpret_cast<val_flowfilter_entry_t*>
- (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_t)));
- uuu::upll_strncpy(val->flowlist_name,
- key_rename->old_flowlist_name,
- (kMaxLenFlowListName+1));
+ if (!okey) {
+ free(key_vbr_if_ff_entry);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ return result_code;
+}
+
+upll_rc_t VbrIfFlowFilterEntryMoMgr::UpdateVnodeVal(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t data_type,
+ bool &no_rename) {
+ UPLL_FUNC_TRACE;
+ ConfigKeyVal *okey = NULL;
+ ConfigKeyVal *kval = NULL;
+ //ConfigKeyVal *ckval = NULL;
+ controller_domain ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
- val->valid[UPLL_IDX_FLOWLIST_PPE] = UNC_VF_VALID;
+ uint8_t rename = 0;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ if (ikey->get_key_type() == UNC_KT_VROUTER) {
+ UPLL_LOG_DEBUG("vrouter key type");
+ return result_code;
+ }
+ key_rename_vnode_info_t *key_rename =
+ reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
+
+ //copy the old flowlist name to val_flowfilter_entry
+ val_flowfilter_entry_t *val_ff_entry = reinterpret_cast<val_flowfilter_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_t)));
+
+ if (ikey->get_key_type() == UNC_KT_FLOWLIST) {
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_flowlist_name))) {
+ UPLL_LOG_DEBUG("key_rename->old_flowlist_name NULL");
+ if (val_ff_entry) free(val_ff_entry);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(val_ff_entry->flowlist_name,
+ key_rename->old_flowlist_name,
+ (kMaxLenFlowListName + 1));
+ val_ff_entry->valid[UPLL_IDX_FLOWLIST_NAME_FFE] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("valid and flowlist name (%d) (%s)",
+ val_ff_entry->valid[UPLL_IDX_FLOWLIST_NAME_FFE],
+ val_ff_entry->flowlist_name);
+ } else if (ikey->get_key_type() == UNC_KT_VBRIDGE) {
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vnode_name))) {
+ UPLL_LOG_DEBUG("key_rename->old_unc_vnode_name NULL");
+ if (val_ff_entry) free(val_ff_entry);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(val_ff_entry->redirect_node,
+ key_rename->old_unc_vnode_name,
+ (kMaxLenFlowListName + 1));
+ val_ff_entry->valid[UPLL_IDX_REDIRECT_NODE_FFE] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("valid and vbridge name (%d) (%s)",
+ val_ff_entry->valid[UPLL_IDX_REDIRECT_NODE_FFE],
+ val_ff_entry->redirect_node);
+ }
- ConfigVal *ckv = new ConfigVal(IpctSt::kIpcStValFlowfilterEntry, val);
- okey = new ConfigKeyVal(UNC_KT_VBRIF_FLOWFILTER_ENTRY,
- IpctSt::kIpcStKeyVbrIfFlowfilterEntry, NULL, ckv);
+ result_code = GetChildConfigKey(okey, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("CopyToConfigKey okey NULL");
+ FREE_IF_NOT_NULL(val_ff_entry);
+ return result_code;
}
+
if (!okey) {
- // free(key_vbr_if_ff_entry);
- return UPLL_RC_ERR_GENERIC;
+ UPLL_LOG_DEBUG("CopyToConfigKey okey NULL");
+ free(val_ff_entry);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ okey->SetCfgVal(new ConfigVal(IpctSt::kIpcStValFlowfilterEntry, val_ff_entry));
+
+
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain|kOpInOutFlag };
+
+ // Read the record of key structure and old flowlist name in maintbl
+ result_code = ReadConfigDB(okey, data_type, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG(" ReadConfigDB failed ");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
}
+ ConfigKeyVal *first_ckv = okey;
+ while (okey != NULL) {
+ result_code = GetChildConfigKey(kval, okey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey kval NULL");
+ DELETE_IF_NOT_NULL(first_ckv);
+ return result_code;
+ }
+ if (!kval) return UPLL_RC_ERR_GENERIC;
+ // Copy the new flowlist name in val_flowfilter_entry
+ val_flowfilter_entry_t *val_ff_entry_new = reinterpret_cast<val_flowfilter_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_t)));
+ if (!val_ff_entry_new) return UPLL_RC_ERR_GENERIC;
+
+ if (ikey->get_key_type() == UNC_KT_FLOWLIST) {
+ // New Name NuLL CHECK
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_flowlist_name))) {
+ UPLL_LOG_DEBUG("new_flowlist_name NULL");
+ if (val_ff_entry_new) free(val_ff_entry_new);
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(first_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ // Copy the new flowlist_name into val_flowfilter_entry
+ uuu::upll_strncpy(val_ff_entry_new->flowlist_name,
+ key_rename->new_flowlist_name,
+ (kMaxLenFlowListName + 1));
+ val_ff_entry_new->valid[UPLL_IDX_FLOWLIST_NAME_FFE] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("flowlist name and valid (%d) (%s)",
+ val_ff_entry_new->valid[UPLL_IDX_FLOWLIST_NAME_FFE],
+ val_ff_entry_new->flowlist_name);
+ } else if (ikey->get_key_type() == UNC_KT_VBRIDGE) {
+ // New Name NuLL CHECK
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_unc_vnode_name))) {
+ UPLL_LOG_DEBUG("new_unc_vnode_name NULL");
+ if (val_ff_entry_new) free(val_ff_entry_new);
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(first_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ // Copy the new vbridge name into val_flowfilter_entry
+ uuu::upll_strncpy(val_ff_entry_new->redirect_node,
+ key_rename->new_unc_vnode_name,
+ (kMaxLenFlowListName + 1));
+ val_ff_entry_new->valid[UPLL_IDX_REDIRECT_NODE_FFE] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("vbridge name and valid (%d) (%s)",
+ val_ff_entry_new->valid[UPLL_IDX_FLOWLIST_NAME_FFE],
+ val_ff_entry_new->redirect_node);
+
+ }
+ ConfigVal *cval1 = new ConfigVal(IpctSt::kIpcStValFlowfilterEntry, val_ff_entry_new);
+
+ kval->SetCfgVal(cval1);
+ memset(&ctrlr_dom, 0, sizeof(controller_domain));
+ result_code = GetControllerDomainID(okey, UPLL_DT_IMPORT, dmi);
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get the Controller Domain details, err:%d",
+ result_code);
+ }
+ GET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
+ GET_USER_DATA_FLAGS(okey, rename);
+
+ if (ikey->get_key_type() == UNC_KT_FLOWLIST) {
+ if (!no_rename)
+ rename = rename | FLOW_RENAME;
+ else
+ rename = rename & NO_FLOWLIST_RENAME;
+ } else if (ikey->get_key_type() == UNC_KT_VBRIDGE) {
+ if (!no_rename)
+ rename = rename | VBR_RENAME_FLAG;
+ else
+ rename = rename & NO_VBR_RENAME_FLAG;
+ }
+
+ SET_USER_DATA_FLAGS(kval, rename);
+ SET_USER_DATA_CTRLR_DOMAIN(kval, ctrlr_dom);
+
+ // Update the new flowlist name in MAINTBL
+ result_code = UpdateConfigDB(kval, data_type, UNC_OP_UPDATE, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Create record Err in vbrflowfilterentrytbl CANDIDATE DB(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(first_ckv);
- // free(key_vbr_if_ff_entry);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(kval);
+ okey = okey->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(first_ckv);
+ UPLL_LOG_DEBUG("UpdateVnodeVal result_code (%d)", result_code);
return result_code;
}
bool VbrIfFlowFilterEntryMoMgr::CompareValidValue(void *&val1,
- void *val2, bool audit) {
+ void *val2, bool copy_to_running) {
UPLL_FUNC_TRACE;
+ bool attr = true;
val_flowfilter_entry_t *val_ff_entry1 =
reinterpret_cast<val_flowfilter_entry_t *>(val1);
val_flowfilter_entry_t *val_ff_entry2 =
reinterpret_cast<val_flowfilter_entry_t *>(val2);
- // if (audit) {
- for ( unsigned int loop = 0; loop < sizeof(val_ff_entry1->valid); ++loop ) {
+ for ( unsigned int loop = 0; loop < sizeof(val_ff_entry1->valid); ++loop ) {
if ( UNC_VF_INVALID == val_ff_entry1->valid[loop] &&
UNC_VF_VALID == val_ff_entry2->valid[loop])
val_ff_entry1->valid[loop] = UNC_VF_VALID_NO_VALUE;
- }
- // }
+ }
if (val_ff_entry1->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID &&
val_ff_entry2->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
}
if (val_ff_entry1->valid[UPLL_IDX_REDIRECT_NODE_FFE] == UNC_VF_VALID &&
val_ff_entry2->valid[UPLL_IDX_REDIRECT_NODE_FFE] == UNC_VF_VALID) {
- if (reinterpret_cast<char *>(val_ff_entry1->redirect_node) ==
- reinterpret_cast<char *>(val_ff_entry2->redirect_node))
- val_ff_entry1->valid[UPLL_IDX_REDIRECT_NODE_FFE] = UNC_VF_INVALID;
+ if (!strcmp(reinterpret_cast<char *>(val_ff_entry1->redirect_node),
+ reinterpret_cast<char *>(val_ff_entry2->redirect_node)))
+ val_ff_entry1->valid[UPLL_IDX_REDIRECT_NODE_FFE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_ff_entry1->valid[UPLL_IDX_REDIRECT_PORT_FFE] == UNC_VF_VALID &&
val_ff_entry2->valid[UPLL_IDX_REDIRECT_PORT_FFE] == UNC_VF_VALID) {
- if (reinterpret_cast<char *>(val_ff_entry1->redirect_port) ==
- reinterpret_cast<char *>(val_ff_entry2->redirect_port))
- val_ff_entry1->valid[UPLL_IDX_REDIRECT_PORT_FFE] = UNC_VF_INVALID;
+ if (!strcmp(reinterpret_cast<char *>(val_ff_entry1->redirect_port),
+ reinterpret_cast<char *>(val_ff_entry2->redirect_port)))
+ val_ff_entry1->valid[UPLL_IDX_REDIRECT_PORT_FFE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_ff_entry1->valid[UPLL_IDX_MODIFY_DST_MAC_FFE] == UNC_VF_VALID &&
val_ff_entry2->valid[UPLL_IDX_MODIFY_DST_MAC_FFE] == UNC_VF_VALID) {
- if (reinterpret_cast<char *>(val_ff_entry1->modify_dstmac) ==
- reinterpret_cast<const char *>(val_ff_entry2->modify_dstmac))
- val_ff_entry1->valid[UPLL_IDX_MODIFY_DST_MAC_FFE] = UNC_VF_INVALID;
+ if (!memcmp(reinterpret_cast<char *>(val_ff_entry1->modify_dstmac),
+ reinterpret_cast<char *>(val_ff_entry2->modify_dstmac),
+ sizeof(val_ff_entry2->modify_dstmac)))
+ val_ff_entry1->valid[UPLL_IDX_MODIFY_DST_MAC_FFE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_ff_entry1->valid[UPLL_IDX_MODIFY_SRC_MAC_FFE] == UNC_VF_VALID &&
val_ff_entry2->valid[UPLL_IDX_MODIFY_SRC_MAC_FFE] == UNC_VF_VALID) {
- if (reinterpret_cast<char *>(val_ff_entry1->modify_srcmac) ==
- reinterpret_cast<char *>(val_ff_entry2->modify_srcmac))
- val_ff_entry1->valid[UPLL_IDX_MODIFY_SRC_MAC_FFE] = UNC_VF_INVALID;
+ if (!memcmp(reinterpret_cast<char *>(val_ff_entry1->modify_srcmac),
+ reinterpret_cast<char *>(val_ff_entry2->modify_srcmac),
+ sizeof(val_ff_entry2->modify_srcmac)))
+ val_ff_entry1->valid[UPLL_IDX_MODIFY_SRC_MAC_FFE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_ff_entry1->valid[UPLL_IDX_NWM_NAME_FFE] == UNC_VF_VALID &&
val_ff_entry2->valid[UPLL_IDX_NWM_NAME_FFE] == UNC_VF_VALID) {
val_ff_entry1->valid[UPLL_IDX_PRIORITY_FFE] = UNC_VF_INVALID;
}
UPLL_LOG_DEBUG("CompareValidValue : Success");
- return false;
-}
-
-upll_rc_t VbrIfFlowFilterEntryMoMgr::ReadDetailEntry(
- ConfigKeyVal *ff_ckv,
- upll_keytype_datatype_t dt_type,
- unc_keytype_operation_t op,
- DbSubOp dbop ,
- DalDmlIntf *dmi
- ) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
-
- if (NULL == ff_ckv) {
- return UPLL_RC_ERR_GENERIC;
- }
-
-// SET_USER_DATA_DOMAIN(ff_ckv, domain_id);
-// SET_USER_DATA_CTRLR(ff_ckv, ctrlr_id);
- result_code = ReadConfigDB(ff_ckv, dt_type, UNC_OP_READ, dbop, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- return UPLL_RC_ERR_GENERIC;
+ for (unsigned int loop = 0;
+ loop < sizeof(val_ff_entry1->valid)/ sizeof(uint8_t); ++loop) {
+ if ((UNC_VF_VALID == (uint8_t) val_ff_entry1->valid[loop]) ||
+ (UNC_VF_VALID_NO_VALUE == (uint8_t) val_ff_entry1->valid[loop]))
+ attr = false;
}
- UPLL_LOG_DEBUG("ReadDetailEntry : Success");
- return UPLL_RC_SUCCESS;
+ return attr;
}
+
upll_rc_t VbrIfFlowFilterEntryMoMgr::TxUpdateController(unc_key_type_t keytype,
uint32_t session_id,
uint32_t config_id,
break;
}
- UPLL_LOG_DEBUG("KeyVal= %s ", (req->ToStrAll()).c_str());
+ UPLL_LOG_TRACE("KeyVal= %s ", (req->ToStrAll()).c_str());
switch (op) {
case UNC_OP_CREATE:
op1 = op;
result_code = DupConfigKeyVal(ck_main, req, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("DupConfigKeyVal failed %d\n", result_code);
+ UPLL_LOG_TRACE("DupConfigKeyVal failed %d", result_code);
return result_code;
}
break;
op1 = op;
result_code = GetChildConfigKey(ck_main, req);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("GetChildConfigKey failed %d\n", result_code);
+ UPLL_LOG_TRACE("GetChildConfigKey failed %d", result_code);
return result_code;
}
DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutCtrlr};
result_code = ReadConfigDB(ck_main, UPLL_DT_RUNNING, UNC_OP_READ,
dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
return UPLL_RC_ERR_GENERIC;
}
}
break;
default:
- break;
+ UPLL_LOG_DEBUG("TxUpdateController Invalid operation");
+ return UPLL_RC_ERR_GENERIC;
}
GET_USER_DATA_CTRLR_DOMAIN(ck_main, ctrlr_dom);
if (ctrlr_dom.ctrlr == NULL) {
- return UPLL_RC_ERR_GENERIC;
+ DELETE_IF_NOT_NULL(ck_main);
+ return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
ctrlr_dom.domain);
- /*
- if ((op == UNC_OP_CREATE) || (op == UNC_OP_UPDATE)) {
- void *main = GetVal(ck_main);
- void *val_nrec = (nreq) ? GetVal(nreq) : NULL;
- FilterAttributes(main, val_nrec, false, op);
- }
- */
GET_USER_DATA_FLAGS(ck_main, db_flag);
ConfigKeyVal *tmp_cfgkeyval = NULL;
if (!(SET_FLAG_PORTMAP & db_flag) && !(SET_FLAG_VLINK & db_flag)) {
if (op != UNC_OP_UPDATE) {
- continue;
+ DELETE_IF_NOT_NULL(ck_main);
+ continue;
} else {
result_code = GetChildConfigKey(tmp_cfgkeyval, ck_main);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetChildConfigKey failed err %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
return result_code;
}
SET_USER_DATA_CTRLR_DOMAIN(tmp_cfgkeyval, ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
UPLL_LOG_DEBUG("Unable to read from DB, err: %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(tmp_cfgkeyval);
return result_code;
}
}
if (!(SET_FLAG_PORTMAP & db_flag_running) &&
!(SET_FLAG_VLINK & db_flag_running)) {
UPLL_LOG_DEBUG("Portmap flag is not set for vbrifFFEntry");
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(tmp_cfgkeyval);
continue;
}
op1 = UNC_OP_DELETE;
vext_datatype = UPLL_DT_RUNNING;
db_flag = db_flag_running;
}
+ DELETE_IF_NOT_NULL(tmp_cfgkeyval);
} else if (op == UNC_OP_UPDATE) {
result_code = GetChildConfigKey(tmp_cfgkeyval, ck_main);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetChildConfigKey failed, err %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
return result_code;
}
SET_USER_DATA_CTRLR_DOMAIN(tmp_cfgkeyval, ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
UPLL_LOG_DEBUG("Unable to read from DB, err: %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(tmp_cfgkeyval);
return result_code;
}
}
void *val_nrec = (nreq) ? GetVal(nreq) : NULL;
FilterAttributes(main, val_nrec, false, op);
}
+ DELETE_IF_NOT_NULL(tmp_cfgkeyval);
}
reinterpret_cast<pfcdrv_val_flowfilter_entry_t *>
(ConfigKeyVal::Malloc(sizeof(pfcdrv_val_flowfilter_entry_t)));
+ if (UNC_OP_DELETE == op1) {
+ vext_datatype = UPLL_DT_RUNNING;
+ }
+
result_code = GetVexternalInformation(ck_main, vext_datatype,
pfc_val, db_flag, dmi);
if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ck_main);
+ free(pfc_val);
+ return result_code;
+ }
+ ConfigKeyVal *temp_ck_main = NULL;
+ result_code = DupConfigKeyVal(temp_ck_main, req, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
+ free(pfc_val);
return result_code;
}
-
- val_flowfilter_entry_t* val = reinterpret_cast<val_flowfilter_entry_t *>
- (GetVal(ck_main));
-
-
- pfc_val->valid[PFCDRV_IDX_FLOWFILTER_ENTRY_FFE] = UNC_VF_VALID;
- memcpy(&pfc_val->val_ff_entry, val, sizeof(val_flowfilter_entry_t));
upll_keytype_datatype_t dt_type = (op1 == UNC_OP_DELETE)?
UPLL_DT_RUNNING:UPLL_DT_CANDIDATE;
result_code = GetRenamedControllerKey(ck_main, dt_type,
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG(" GetRenamedControllerKey failed err code(%d)",
result_code);
+ DELETE_IF_NOT_NULL(ck_main);
+ FREE_IF_NOT_NULL(pfc_val);
break;
}
+ if (UNC_OP_DELETE == op1) {
+ pfc_val->valid[PFCDRV_IDX_FLOWFILTER_ENTRY_FFE] = UNC_VF_INVALID;
+ } else {
+ val_flowfilter_entry_t* val = reinterpret_cast<val_flowfilter_entry_t *>
+ (GetVal(ck_main));
+
+ pfc_val->valid[PFCDRV_IDX_FLOWFILTER_ENTRY_FFE] = UNC_VF_VALID;
+ memcpy(&pfc_val->val_ff_entry, val, sizeof(val_flowfilter_entry_t));
+ UPLL_LOG_TRACE("%s GetRenamedCtrl vtn_ff_entry end",
+ ck_main->ToStrAll().c_str());
+ }
ck_main->SetCfgVal(new ConfigVal(IpctSt::kIpcStPfcdrvValFlowfilterEntry,
pfc_val));
result_code = UPLL_RC_SUCCESS;
}
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("IpcSend failed %d\n", result_code);
- *err_ckv = ipc_resp.ckv_data;
- if (ck_main)
- delete ck_main;
+ UPLL_LOG_DEBUG("IpcSend failed %d", result_code);
+ *err_ckv = temp_ck_main;
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(ck_main);
break;
}
- if (ck_main) {
- delete ck_main;
- ck_main = NULL;
- }
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(temp_ck_main);
+ DELETE_IF_NOT_NULL(ck_main);
}
dmi->CloseCursor(dal_cursor_handle, true);
- if (req)
- delete req;
- if (nreq)
- delete nreq;
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) ?
UPLL_RC_SUCCESS : result_code;
return result_code;
upll_rc_t VbrIfFlowFilterEntryMoMgr::SetVlinkPortmapConfiguration(
ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
- DalDmlIntf *dmi, InterfacePortMapInfo flags) {
+ DalDmlIntf *dmi, InterfacePortMapInfo flags,
+ unc_keytype_operation_t oper) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
if (NULL == ikey || NULL == ikey->get_key()) {
return result_code;
}
- if (!flags) {
- // return UPLL_RC_SUCCESS;
- }
ConfigKeyVal *ckv = NULL;
+ uint8_t *ctrlr_id = NULL;
+ controller_domain ctrlr_dom;
+ memset(&ctrlr_dom, 0, sizeof(ctrlr_dom));
result_code = GetChildConfigKey(ckv, NULL);
if (UPLL_RC_SUCCESS != result_code) {
return result_code;
UNC_OP_READ, dbop, dmi, MAINTBL);
if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
UPLL_LOG_DEBUG("No Recrods in the Vbr_If_FlowFilter_Entry Table");
+ DELETE_IF_NOT_NULL(ckv);
return UPLL_RC_SUCCESS;
}
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("Read ConfigDB failure %d", result_code);
- delete ckv;
+ DELETE_IF_NOT_NULL(ckv);
return result_code;
}
uint8_t flag_port_map = 0;
+ ConfigKeyVal *ckv_first = ckv;
while (ckv) {
flag_port_map = 0;
+ val_flowfilter_entry_t *flowfilter_val =
+ reinterpret_cast<val_flowfilter_entry_t *> (GetVal(ckv));
GET_USER_DATA_FLAGS(ckv, flag_port_map);
if (flags & kVlinkConfigured) {
UPLL_LOG_DEBUG("Vlink for flowfilterentry");
UPLL_LOG_DEBUG("Vlink-portmap for flowfilterentry");
flag_port_map |= SET_FLAG_VLINK_PORTMAP;
} else {
- UPLL_LOG_DEBUG("reset portmapflag for flowfilterentry");
-
- flag_port_map = 0;
+ flag_port_map &= SET_FLAG_NO_VLINK_PORTMAP;
}
SET_USER_DATA_FLAGS(ckv, flag_port_map);
+
+ UPLL_LOG_DEBUG("SET_USER_DATA_FLAGS flag_port_map %d", flag_port_map);
DbSubOp dbop_up = { kOpNotRead, kOpMatchNone, kOpInOutFlag };
result_code = UpdateConfigDB(ckv, dt_type, UNC_OP_UPDATE,
dmi, &dbop_up, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("Unable to update portmap for flowfilterentry");
+ DELETE_IF_NOT_NULL(ckv);
return result_code;
}
+ if (flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
+ unc_keytype_operation_t op = UNC_OP_INVALID;
+ FlowListMoMgr *mgr = reinterpret_cast<FlowListMoMgr *>
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
+ if ((flag_port_map & SET_FLAG_VLINK) ||
+ (flag_port_map & SET_FLAG_PORTMAP)) {
+ op = UNC_OP_CREATE;
+ } else {
+ op = UNC_OP_DELETE;
+ }
+ result_code = GetControllerDomainID(ikey, dt_type, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get the Controller Domain details, err:%d",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv);
+ return result_code;
+ }
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+ UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
+ ctrlr_dom.ctrlr, ctrlr_dom.domain);
+ ctrlr_id = ctrlr_dom.ctrlr;
+ result_code = mgr->AddFlowListToController(
+ reinterpret_cast<char*>(flowfilter_val->flowlist_name), dmi,
+ reinterpret_cast<char *>(ctrlr_id), dt_type, op);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG(" Send delete request to flowlist failed. err code(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv);
+ return result_code;
+ }
+ }
ckv = ckv->get_next_cfg_key_val();
}
+ DELETE_IF_NOT_NULL(ckv_first);
return UPLL_RC_SUCCESS;
}
pfc_val->val_vbrif_vextif.interface_type = PFCDRV_IF_TYPE_VBRIF;
} else {
UPLL_LOG_DEBUG("Portmap/Vlink is not configured");
+ DELETE_IF_NOT_NULL(ckv);
return UPLL_RC_ERR_NOT_ALLOWED_AT_THIS_TIME;
}
+ DELETE_IF_NOT_NULL(ckv);
return UPLL_RC_SUCCESS;
}
UPLL_LOG_DEBUG(" Input Key is NULL");
return UPLL_RC_ERR_GENERIC;
}
-
+ DELETE_IF_NOT_NULL(okey);
unc_key_type_t ikey_type = ikey->get_key_type();
if (ikey_type != UNC_KT_VBRIF_FLOWFILTER_ENTRY) {
UPLL_LOG_DEBUG(" Invalid key type received. Key type - %d", ikey_type);
upll_rc_t VbrIfFlowFilterEntryMoMgr::ConstructReadDetailResponse(
ConfigKeyVal *ikey,
ConfigKeyVal *drv_resp_ckv,
- DalDmlIntf *dmi,
ConfigKeyVal **okey) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *tmp_okey = NULL;
-
- DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone };
-
result_code = GetChildConfigKey(tmp_okey, ikey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetChildConfigKey failed err code (%d)", result_code);
return result_code;
}
- result_code = ReadConfigDB(tmp_okey, UPLL_DT_RUNNING, UNC_OP_READ,
- dbop, dmi, MAINTBL);
+ tmp_okey->AppendCfgVal(drv_resp_ckv->GetCfgValAndUnlink());
+ if (*okey == NULL) {
+ *okey = tmp_okey;
+ } else {
+ (*okey)->AppendCfgKeyVal(tmp_okey);
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VbrIfFlowFilterEntryMoMgr::DeleteChildrenPOM(
+ ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ uint8_t *ctrlr_id = NULL;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+// uint8_t rename = 0;
+ if (NULL == ikey && NULL == dmi) return result_code;
+
+ ConfigKeyVal *temp_okey = NULL;
+ ConfigKeyVal *okey = NULL;
+ result_code = GetChildConfigKey(temp_okey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ return result_code;
+ }
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone,
+ kOpInOutCtrlr|kOpInOutDomain };
+ result_code = ReadConfigDB(temp_okey, UPLL_DT_CANDIDATE,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ReadConfigDB error (%d)", result_code);
- delete tmp_okey;
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("UPLL_RC_ERR_NO_SUCH_INSTANCE");
+ DELETE_IF_NOT_NULL(temp_okey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("Unable to read configuration from CandidateDb");
+ DELETE_IF_NOT_NULL(temp_okey);
return result_code;
}
+ okey = temp_okey;
+ while (NULL != okey) {
+ GET_USER_DATA_CTRLR(okey, ctrlr_id);
+ val_flowfilter_entry_t *flowfilter_val =
+ reinterpret_cast<val_flowfilter_entry_t *> (GetVal(okey));
+ if (flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
+ FlowListMoMgr *mgr = reinterpret_cast<FlowListMoMgr *>
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
+ result_code = mgr->AddFlowListToController(
+ reinterpret_cast<char*>(flowfilter_val->flowlist_name), dmi,
+ reinterpret_cast<char *>(ctrlr_id), dt_type, UNC_OP_DELETE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG(" Send delete request to flowlist failed. err code(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(temp_okey);
+ return result_code;
+ }
+ }
+ result_code = UpdateConfigDB(okey, dt_type, UNC_OP_DELETE, dmi,
+ MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(temp_okey);
+ return result_code;
+ }
+ okey = okey->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(temp_okey);
+ return UPLL_RC_SUCCESS;
+}
- ConfigVal *drv_resp_val = NULL;
- drv_resp_val = drv_resp_ckv->get_cfg_val();
- while (drv_resp_val != NULL) {
- if (IpctSt::kIpcStValFlowfilterEntrySt != drv_resp_val->get_st_num()) {
- UPLL_LOG_DEBUG("Incorrect structure received from driver, struct num %d",
- drv_resp_val->get_st_num());
- return UPLL_RC_ERR_GENERIC;
- }
- val_flowfilter_entry_st_t *tmp_ffe_st =
- reinterpret_cast<val_flowfilter_entry_st_t*>
- (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_st_t)));
- memcpy(tmp_ffe_st,
- reinterpret_cast<val_flowfilter_entry_st_t *>
- (drv_resp_val->get_val()),
- sizeof(val_flowfilter_entry_st_t));
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowfilterEntrySt, tmp_ffe_st);
-
- if ((drv_resp_val = drv_resp_val->get_next_cfg_val()) == NULL) {
- UPLL_LOG_DEBUG("No more entries in driver response\n");
- break;
+upll_rc_t VbrIfFlowFilterEntryMoMgr::SetValidAudit(ConfigKeyVal *&ikey) {
+ UPLL_FUNC_TRACE;
+ val_flowfilter_entry_t *val = reinterpret_cast
+ <val_flowfilter_entry_t *>(GetVal(ikey));
+ if (NULL == val) {
+ UPLL_LOG_DEBUG("val is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ for (unsigned int loop = 0;
+ loop < sizeof(val->valid) / sizeof(val->valid[0]);
+ ++loop) {
+ if (val->valid[loop] == UNC_VF_VALID) {
+ val->cs_attr[loop] = UNC_CS_APPLIED;
+ } else if (val->valid[loop] == UNC_VF_INVALID) {
+ val->cs_attr[loop] = UNC_CS_NOT_APPLIED;
}
+ }
+ val->cs_row_status = UNC_CS_APPLIED;
+ return UPLL_RC_SUCCESS;
+}
+
+bool VbrIfFlowFilterEntryMoMgr::FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op) {
+ UPLL_FUNC_TRACE;
+ if (op != UNC_OP_CREATE)
+ return CompareValidValue(val1, val2, copy_to_running);
+ return false;
+}
+
+upll_rc_t VbrIfFlowFilterEntryMoMgr::UpdateConfigStatus(ConfigKeyVal *ikey,
+ unc_keytype_operation_t op,
+ uint32_t driver_result,
+ ConfigKeyVal *upd_key,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ctrlr_key) {
+ UPLL_FUNC_TRACE;
+ ConfigKeyVal * vbr_ffe_run_key = NULL;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_flowfilter_entry_t *ffe_val = NULL, *val_main = NULL;
- if (IpctSt::kIpcStValFlowlistEntrySt != (drv_resp_val)->get_st_num()) {
- UPLL_LOG_DEBUG("No flowflist entries returned by driver");
- continue;
+ unc_keytype_configstatus_t cs_status =
+ (driver_result == UPLL_RC_SUCCESS) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
+ ffe_val = reinterpret_cast<val_flowfilter_entry_t *>(GetVal(ikey));
+ if (ffe_val == NULL) return UPLL_RC_ERR_GENERIC;
+ if (op == UNC_OP_CREATE) {
+ ffe_val->cs_row_status = cs_status;
+ } else if (op == UNC_OP_UPDATE) {
+ result_code = GetChildConfigKey(vbr_ffe_run_key, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
+ result_code);
+ return result_code;
+ }
+ DbSubOp dbop_maintbl = { kOpReadSingle, kOpMatchNone,
+ kOpInOutFlag |kOpInOutCs };
+ result_code = ReadConfigDB(vbr_ffe_run_key, UPLL_DT_RUNNING ,
+ UNC_OP_READ, dbop_maintbl, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to read configuration from RunningDb");
+ DELETE_IF_NOT_NULL(vbr_ffe_run_key);
+ return result_code;
+ }
+ val_main = reinterpret_cast
+ <val_flowfilter_entry_t *>(GetVal(vbr_ffe_run_key));
+ for (unsigned int loop = 0; loop < sizeof(val_main->valid)/
+ sizeof(val_main->valid[0]); ++loop) {
+ ffe_val->cs_attr[loop] = val_main->cs_attr[loop];
+ }
+ void *ffeval = reinterpret_cast<void *>(ffe_val);
+ CompareValidValue(ffeval, GetVal(upd_key), true);
+ } else {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_TRACE("%s",(ikey->ToStrAll()).c_str());
+ val_flowfilter_entry_t *ffe_val2 =
+ reinterpret_cast<val_flowfilter_entry_t *>(GetVal(upd_key));
+ if (UNC_OP_UPDATE == op) {
+ UPLL_LOG_TRACE("%s", (upd_key->ToStrAll()).c_str());
+ ffe_val->cs_row_status = ffe_val2->cs_row_status;
+ }
+ for (unsigned int loop = 0;
+ loop < sizeof(ffe_val->valid) / sizeof(ffe_val->valid[0]); ++loop) {
+ /* Setting CS to the not supported attributes*/
+ if (UNC_VF_NOT_SUPPORTED == ffe_val->valid[loop]) {
+ ffe_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
+ } else if ((UNC_VF_VALID == ffe_val->valid[loop])
+ || (UNC_VF_VALID_NO_VALUE == ffe_val->valid[loop])) {
+ ffe_val->cs_attr[loop] = cs_status;
+ } else if ((UNC_VF_INVALID == ffe_val->valid[loop]) &&
+ (UNC_OP_CREATE == op)) {
+ ffe_val->cs_attr[loop] = UNC_CS_NOT_APPLIED;
+ } else if ((UNC_VF_INVALID == ffe_val->valid[loop]) &&
+ (UNC_OP_UPDATE == op)) {
+ if (val_main->valid[loop] == UNC_VF_VALID) {
+ if (cs_status == UNC_CS_APPLIED) {
+ ffe_val->cs_attr[loop] = cs_status;
+ }
+ }
+ } else if ((UNC_VF_VALID == ffe_val->valid[loop]) &&
+ (UNC_OP_UPDATE == op)) {
+ if (cs_status == UNC_CS_APPLIED) {
+ ffe_val->cs_attr[loop] = UNC_CS_APPLIED;
+ }
+ }
+ if ((ffe_val->valid[loop] == UNC_VF_VALID_NO_VALUE)
+ &&(UNC_OP_UPDATE == op)) {
+ ffe_val->cs_attr[loop] = UNC_CS_UNKNOWN;
}
+ UPLL_LOG_TRACE("Value : %d Cs : %d", loop, ffe_val->cs_attr[loop]);
+ }
+ DELETE_IF_NOT_NULL(vbr_ffe_run_key);
+ return result_code;
+}
- while (IpctSt::kIpcStValFlowlistEntrySt == drv_resp_val->get_st_num()) {
- val_flowlist_entry_st_t* tmp_val_fl_st =
- reinterpret_cast<val_flowlist_entry_st_t*>
- (ConfigKeyVal::Malloc(sizeof(val_flowlist_entry_st_t)));
- memcpy(tmp_val_fl_st,
- reinterpret_cast<val_flowlist_entry_st_t*>
- (drv_resp_val->get_val()),
- sizeof(val_flowlist_entry_st_t));
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowlistEntrySt,
- tmp_val_fl_st);
- drv_resp_val = drv_resp_val->get_next_cfg_val();
- if (!drv_resp_val) {
- break;
+upll_rc_t VbrIfFlowFilterEntryMoMgr::SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_flowfilter_entry_t *val_ffe = reinterpret_cast
+ <val_flowfilter_entry_t *>(GetVal(ikey));
+ if (!val_ffe) {
+ UPLL_LOG_DEBUG("Val is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigKeyVal *pkey = NULL;
+ if (UNC_OP_CREATE == req->operation) {
+ result_code = GetParentConfigKey(pkey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetParentConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_VBRIF_FLOWFILTER)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("mgr is NULL");
+ DELETE_IF_NOT_NULL(pkey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t rename = 0;
+ result_code = mgr->IsRenamed(pkey, req->datatype, dmi, rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(pkey);
+ return result_code;
+ }
+ UPLL_LOG_DEBUG("Flag from parent : %d", rename);
+ DELETE_IF_NOT_NULL(pkey);
+
+ // Check flowlist is renamed
+ if ((UNC_VF_VALID == val_ffe->valid[UPLL_IDX_FLOWLIST_NAME_FFE]) &&
+ ((UNC_OP_CREATE == req->operation))) {
+ ConfigKeyVal *fl_ckv = NULL;
+ result_code = GetFlowlistConfigKey(reinterpret_cast<const char *>
+ (val_ffe->flowlist_name), fl_ckv, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetFlowlistConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *fl_mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_FLOWLIST)));
+ if (!fl_mgr) {
+ UPLL_LOG_DEBUG("fl_mgr is NULL");
+ DELETE_IF_NOT_NULL(fl_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t fl_rename = 0;
+ result_code = fl_mgr->IsRenamed(fl_ckv, req->datatype, dmi, fl_rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(fl_ckv);
+ return result_code;
+ }
+ if (fl_rename & 0x01) {
+ rename |= FLOW_RENAME;
}
+ DELETE_IF_NOT_NULL(fl_ckv);
}
+ SET_USER_DATA_FLAGS(ikey, rename);
+ } else if (UNC_OP_UPDATE == req->operation) {
+ uint8_t rename = 0;
+ ConfigKeyVal *dup_ckv = NULL;
+ result_code = GetChildConfigKey(dup_ckv, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG(" GetChildConfigKey failed");
+ return result_code;
+ }
+ DbSubOp dbop1 = {kOpReadSingle, kOpMatchNone, kOpInOutFlag};
+ result_code = ReadConfigDB(dup_ckv, req->datatype, UNC_OP_READ,
+ dbop1, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(dup_ckv);
+ return result_code;
+ }
+ GET_USER_DATA_FLAGS(dup_ckv, rename);
+ DELETE_IF_NOT_NULL(dup_ckv);
+ if (UNC_VF_VALID == val_ffe->valid[UPLL_IDX_FLOWLIST_NAME_FFE]) {
+ ConfigKeyVal *fl_ckv = NULL;
+ result_code = GetFlowlistConfigKey(reinterpret_cast<const char *>
+ (val_ffe->flowlist_name), fl_ckv, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetFlowlistConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *fl_mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_FLOWLIST)));
+ if (!fl_mgr) {
+ UPLL_LOG_DEBUG("fl_mgr is NULL");
+ DELETE_IF_NOT_NULL(fl_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t fl_rename = 0;
+ result_code = fl_mgr->IsRenamed(fl_ckv, req->datatype, dmi, fl_rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(fl_ckv);
+ return result_code;
+ }
+ UPLL_LOG_DEBUG("IsRenamed rename value : %d", rename);
+ if (fl_rename & 0x01) {
+ rename |= FLOW_RENAME; // TODO Check for correct flag value
+ UPLL_LOG_DEBUG("rename value after flowlist : %d", rename);
+ } else {
+ rename &= NO_FLOWLIST_RENAME;
+ /* reset flag*/
+ }
+ DELETE_IF_NOT_NULL(fl_ckv);
+ } else if (UNC_VF_VALID_NO_VALUE == val_ffe->valid
+ [UPLL_IDX_FLOWLIST_NAME_FFE]) {
+ rename &= NO_FLOWLIST_RENAME; // TODO Check for correct flag value. No rename flowlist value should be set
+ }
+ SET_USER_DATA_FLAGS(ikey, rename);
}
- if (*okey == NULL) {
- *okey = tmp_okey;
- } else {
- (*okey)->AppendCfgKeyVal(tmp_okey);
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VbrIfFlowFilterEntryMoMgr::GetFlowlistConfigKey(
+ const char *flowlist_name, ConfigKeyVal *&okey,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_FLOWLIST)));
+ result_code = mgr->GetChildConfigKey(okey, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
+ return result_code;
}
+ key_flowlist_t *okey_key = reinterpret_cast<key_flowlist_t *>
+ (okey->get_key());
+ uuu::upll_strncpy(okey_key->flowlist_name,
+ flowlist_name,
+ (kMaxLenFlowListName+1));
return UPLL_RC_SUCCESS;
}
} // namespace kt_momgr
* @brief Member Variable for FlowlistRenameBindInfo.
*/
static BindInfo vbr_if_flowlist_rename_bind_info[];
+ uint32_t cur_instance_count;
public:
/**
DalDmlIntf *dmi,
IpcReqRespHeader *req = NULL);
+ upll_rc_t VerifyRedirectDestination(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t dt_type);
+
/**
* @Brief This API is used to check the object availability
* in CANDIDATE DB
* @retval UPLL_RC_ERR_GENERIC Return Failure
*/
- upll_rc_t GetRenamedControllerKey(ConfigKeyVal *&ikey,
+ upll_rc_t GetRenamedControllerKey(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
controller_domain *ctrlr_dom);
*
* @retval UPLL_RC_SUCCESS;
*/
- bool CompareValidValue(void *&val1, void *val2, bool audit);
- /**
- * @brief Method used for ReadDetailEntry Operation.
- *
- * @param[in,out] ff_ckv Pointer to ConfigKeyVal Class.
- * @param[in] dt_type Describes Configiration Information.
- * @param[in] op Describes the Type of Opeartion.
- * @param[in] dbop Describes the dbop Type
- * @param[in] dmi Pointer to DalDmlIntf Class.
- * @param[in] domain_id Pointer to domain_id.
- * @param[in] dctrlr_id Pointer to ctrlr_id.
- *
- * @retval UPLL_RC_SUCCESS Successfull completion.
- * @retval UPLL_RC_ERR_GENERIC Returned Generic Error.
- */
- upll_rc_t ReadDetailEntry(ConfigKeyVal *ff_ckv,
- upll_keytype_datatype_t dt_type,
- unc_keytype_operation_t op,
- DbSubOp dbop,
- DalDmlIntf *dmi);
- /**
- * @brief Method to check validity of Key
+ bool CompareValidValue(void *&val1, void *val2, bool copy_to_running);
+ /* @brief Method to check validity of Key
*
* @param[in] ConfigKeyVal input COnfigKeyVal
* @param[out] index DB Column Index
* @retval UPLL_RC_ERR_GENERIC Returned Generic Error.
*/
+ /**
+ * @brief Method used for Restoring FlowList in the Controller Table
+ *
+ * @param[in] ikey Pointer to ConfigKeyVal Class
+ * @param[in] dt_type Describes Configiration Information.
+ * @param[in] tbl Describe the destination table
+ * @param[in] dmi Pointer to DalDmlIntf Class.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_DB_ACCESS DB Read/Write error.
+ * @retval UPLL_RC_ERR_INSTANCE_EXISTS Record already exists
+ * @retval UPLL_RC_ERR_GENERIC Returned Generic Error.
+ */
+ upll_rc_t RestorePOMInCtrlTbl(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl,
+ DalDmlIntf* dmi);
+
upll_rc_t ReadSiblingMo(IpcReqRespHeader *req, ConfigKeyVal *ikey,
bool begin, DalDmlIntf *dmi);
DalDmlIntf *dmi,
const char *ctrlr_id);
+ upll_rc_t TxVote(unc_key_type_t keytype,
+ DalDmlIntf *dmi,
+ ConfigKeyVal **err_ckv);
upll_rc_t TxUpdateController(unc_key_type_t keytype,
uint32_t session_id,
uint32_t config_id,
upll_rc_t ConstructReadDetailResponse(ConfigKeyVal *ikey,
ConfigKeyVal *drv_resp_ckv,
- DalDmlIntf *dmi,
ConfigKeyVal **okey);
upll_rc_t GetVexternalInformation(ConfigKeyVal* ck_main,
upll_rc_t SetVlinkPortmapConfiguration(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
- InterfacePortMapInfo flag);
+ InterfacePortMapInfo flag,
+ unc_keytype_operation_t oper);
upll_rc_t GetControllerDomainID(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi);
+ upll_rc_t CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id);
+
+ upll_rc_t AuditUpdateController(unc_key_type_t keytype,
+ const char *ctrlr_id,
+ uint32_t session_id,
+ uint32_t config_id,
+ uuc::UpdateCtrlrPhase phase,
+ bool *ctrlr_affected,
+ DalDmlIntf *dmi);
+
+ upll_rc_t DeleteChildrenPOM(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi);
+
+ upll_rc_t SetValidAudit(ConfigKeyVal *&ikey);
+
+ upll_rc_t UpdateVnodeVal(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t data_type,
+ bool &no_rename);
+
+ bool FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op);
+
+ upll_rc_t GetFlowlistConfigKey(
+ const char *flowlist_name, ConfigKeyVal *&okey,
+ DalDmlIntf *dmi);
+
+ upll_rc_t SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req);
+
public:
VbrIfFlowFilterEntryMoMgr();
~VbrIfFlowFilterEntryMoMgr() {
#include "vbr_if_flowfilter_momgr.hh"
#include "vbr_if_momgr.hh"
#include "vbr_if_flowfilter_entry_momgr.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
namespace unc {
namespace kt_momgr {
using unc::upll::ipc_util::IpcUtil;
-#define NUM_KEY_MAIN_TBL 7
#define VTN_RENAME_FLAG 0x01
#define VBR_RENAME_FLAG 0x02
-#define SET_FLAG_VLINK 0x08
-#define SET_FLAG_PORTMAP 0x10
+#define SET_FLAG_VLINK 0x40
+#define SET_FLAG_PORTMAP 0x20
#define SET_FLAG_VLINK_PORTMAP (SET_FLAG_VLINK | SET_FLAG_PORTMAP)
+#define SET_FLAG_NO_VLINK_PORTMAP 0x9F
// VbrIfFlowFilter Table(Main Table)
BindInfo VbrIfFlowFilterMoMgr::vbr_if_flowfilter_bind_info[] = {
{ uudst::vbr_if_flowfilter::kDbiVbrName, CFG_MATCH_KEY,
offsetof(key_vbr_if_flowfilter_t, if_key.vbr_key.vbridge_name),
uud::kDalChar, (kMaxLenVnodeName + 1) },
- { uudst::vbr_if_flowfilter::kDbiVbrName, CFG_MATCH_KEY,
- offsetof(key_vbr_if_flowfilter_t, if_key.if_name),
- uud::kDalChar, (kMaxLenInterfaceName + 1) },
- { uudst::vbr_if_flowfilter::kDbiInputDirection, CFG_MATCH_KEY,
- offsetof(key_vbr_if_flowfilter_t, direction),
- uud::kDalUint8, 1 },
{ uudst::vbr_if_flowfilter::kDbiVtnName, CFG_INPUT_KEY,
offsetof(key_rename_vnode_info_t, new_unc_vtn_name),
uud::kDalChar, (kMaxLenVtnName + 1) },
{ uudst::vbr_if_flowfilter::kDbiVbrName, CFG_INPUT_KEY,
offsetof(key_rename_vnode_info_t, new_unc_vnode_name),
uud::kDalChar, (kMaxLenVnodeName + 1) },
- { uudst::vbr_if_flowfilter::kDbiFlags, CFG_INPUT_KEY,
+ { uudst::vbr_if_flowfilter::kDbiFlags, CK_VAL,
offsetof(key_user_data_t, flags),
uud::kDalUint8, 1 }
};
// setting table indexed for ctrl and rename table to NULL;
ntable = MAX_MOMGR_TBLS;
table = new Table *[ntable];
-
+ cur_instance_count = 0;
// For Main Table
table[MAINTBL] = new Table(uudst::kDbiVbrIfFlowFilterTbl,
UNC_KT_VBRIF_FLOWFILTER, vbr_if_flowfilter_bind_info,
ConfigKeyVal *ikey,
DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
+ ConfigKeyVal *temp_key = NULL;
+
if (ikey == NULL || req == NULL) {
return UPLL_RC_ERR_GENERIC;
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_TRACE("ikey= %s", ikey->ToStrAll().c_str());
+
+ if (req->datatype == UPLL_DT_IMPORT) {
+ UPLL_LOG_DEBUG("Inside:-%d", req->datatype);
+ if (ikey->get_cfg_val() &&
+ (ikey->get_cfg_val()->get_st_num() ==
+ IpctSt::kIpcStPfcdrvValVbrifVextif)) {
+ UPLL_LOG_DEBUG("val struct num (%d)",ikey->get_cfg_val()->get_st_num());
+ ikey->SetCfgVal(NULL);
+ }
+ }
+
// validate syntax and semantics
result_code = ValidateMessage(req, ikey);
if (result_code != UPLL_RC_SUCCESS) {
return result_code;
}
+ if (UPLL_DT_CANDIDATE == req->datatype) {
result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING,
UNC_OP_READ, dmi, MAINTBL);
if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
result_code = RestoreChildren(ikey, req->datatype, UPLL_DT_RUNNING, dmi);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(" restoring the object failed. err code(%d)", result_code);
+ UPLL_LOG_DEBUG("restoring the object failed. err code(%d)",
+ result_code);
+ return UPLL_RC_ERR_GENERIC;
+ }
return result_code;
}
- } else if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ }
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
// create a record in CANDIDATE DB
VbrIfMoMgr *mgrvbrif =
reinterpret_cast<VbrIfMoMgr *>(const_cast<MoManager *>(GetMoManager(
result_code = mgrvbrif->GetVexternal(ckv, req->datatype, dmi,
vexternal, vex_if, flags);
if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ckv);
+ free(vexternal);
+ free(vex_if);
return result_code;
}
- uint8_t flag_port_map;
+ DELETE_IF_NOT_NULL(ckv);
+ uint8_t flag_port_map = 0;
+ GET_USER_DATA_FLAGS(ikey, flag_port_map);
if (flags & kVlinkConfigured) {
- flag_port_map = SET_FLAG_VLINK;
+ flag_port_map = flag_port_map|SET_FLAG_VLINK;
} else if (flags & kPortMapConfigured) {
- flag_port_map = SET_FLAG_PORTMAP;
+ flag_port_map = flag_port_map|SET_FLAG_PORTMAP;
} else if (flags & kVlinkPortMapConfigured) {
- flag_port_map = SET_FLAG_VLINK_PORTMAP;
- } else {
- // No port map of vlink configuration
- flag_port_map = 0;
+ flag_port_map = flag_port_map|SET_FLAG_VLINK_PORTMAP;
}
free(vexternal);
UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
ctrlr_dom.ctrlr, ctrlr_dom.domain);
- result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_CREATE, dmi);
- if (UPLL_RC_SUCCESS != result_code)
+ result_code = GetChildConfigKey(temp_key, NULL);
+ if(result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed in ValidateCapability");
+ return result_code;
+ }
+ result_code = GetInstanceCount(temp_key,
+ reinterpret_cast <char*>(ctrlr_dom.ctrlr),
+ req->datatype,
+ &cur_instance_count,
+ dmi,
+ MAINTBL);
+ delete temp_key;
+ if(result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetInstanceCount Failed in ValidateCapability");
+ return result_code;
+ }
+
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(ctrlr_dom.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("validate Capability Failed %d", result_code);
return result_code;
+ }
+ DbSubOp dbop1 = {kOpNotRead, kOpMatchNone, kOpInOutCtrlr | kOpInOutDomain |
+ kOpInOutFlag};
+ result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_CREATE,
+ dmi, &dbop1, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Failed to update DB, err %d", result_code);
+ return result_code;
+ }
} else {
- UPLL_LOG_DEBUG("Error in reading DB\n");
+ UPLL_LOG_DEBUG("Error in reading DB");
}
return result_code;
}
+upll_rc_t VbrIfFlowFilterMoMgr::CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id) {
+ UPLL_FUNC_TRACE;
+ uint8_t flags = 0;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_TRACE(" ikey is %s", ikey->ToStrAll().c_str());
+ uint8_t *controller_id = reinterpret_cast<uint8_t *>(
+ const_cast<char *>(ctrlr_id));
+
+ /* check if object is renamed in the corresponding Rename Tbl
+ * if "renamed" create the object by the UNC name.
+ * else - create using the controller name.
+ */
+ result_code = GetRenamedUncKey(ikey, UPLL_DT_RUNNING, dmi, controller_id);
+ if (result_code != UPLL_RC_SUCCESS && result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey Failed err_code %d", result_code);
+ return result_code;
+ }
+
+ pfcdrv_val_vbrif_vextif_t *pfc_val =
+ reinterpret_cast<pfcdrv_val_vbrif_vextif_t *> ((GetVal(ikey)));
+
+ if (pfc_val == NULL) {
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ if (pfc_val->interface_type == PFCDRV_IF_TYPE_VBRIF) {
+ flags = SET_FLAG_VLINK;
+ }
+ else if (pfc_val->interface_type == PFCDRV_IF_TYPE_VEXTIF) {
+ flags = SET_FLAG_PORTMAP;
+ }
+ else {
+ flags = 0;
+ }
+
+
+ ConfigKeyVal *okey = NULL;
+ result_code = GetChildConfigKey(okey, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed :%d",
+ result_code);
+ return result_code;
+ }
+
+ SET_USER_DATA_FLAGS(okey, flags);
+
+ controller_domain ctrlr_dom;
+ memset(&ctrlr_dom, 0, sizeof(controller_domain));
+ result_code = GetControllerDomainID(okey, UPLL_DT_AUDIT, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get the Controller Domain details,err:%d",
+ result_code);
+ }
+
+ GET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
+ UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
+ ctrlr_dom.ctrlr, ctrlr_dom.domain);
+
+ // Create a record in AUDIT DB
+ result_code = UpdateConfigDB(okey, UPLL_DT_AUDIT, UNC_OP_CREATE, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigDB Failed err_code %d", result_code);
+ }
+
+ delete okey;
+ return result_code;
+}
+
+upll_rc_t VbrIfFlowFilterMoMgr::AuditUpdateController(unc_key_type_t keytype,
+ const char *ctrlr_id,
+ uint32_t session_id,
+ uint32_t config_id,
+ uuc::UpdateCtrlrPhase phase1,
+ bool *ctrlr_affected,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ DalResultCode db_result = uud::kDalRcSuccess;
+ controller_domain_t ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ ConfigKeyVal *ckv_running_db = NULL;
+ ConfigKeyVal *ckv_audit_db = NULL;
+ ConfigKeyVal *ckv_driver_req = NULL;
+ ConfigKeyVal *ckv_audit_dup_db = NULL;
+ DalCursor *cursor = NULL;
+ upll_keytype_datatype_t vext_datatype = UPLL_DT_CANDIDATE;
+ uint8_t db_flag = 0;
+ uint8_t auditdb_flag = 0;
+ uint8_t *ctrlr = reinterpret_cast<uint8_t *>(const_cast<char *>(ctrlr_id));
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutCtrlr | kOpInOutDomain};
+ if (phase1 == uuc::kUpllUcpCreate) {
+ return result_code;
+ }
+ unc_keytype_operation_t op[2] = {UNC_OP_INVALID, UNC_OP_INVALID};
+ int nop = 0;
+ if (phase1 == uuc::kUpllUcpUpdate) {
+ op[0] = UNC_OP_UPDATE;
+ op[1] = UNC_OP_CREATE;
+ nop = 2;
+ } else if (phase1 == uuc::kUpllUcpDelete) {
+ op[0] = UNC_OP_DELETE;
+ nop = 1;
+ }
+ for (int i = 0; i < nop; i++) {
+ /* retreives the delta of running and audit configuration */
+ unc_keytype_operation_t op1 = op[i];
+ uuc::UpdateCtrlrPhase phase = (op[i] == UNC_OP_UPDATE)?uuc::kUpllUcpUpdate:
+ ((op[i] == UNC_OP_CREATE)?uuc::kUpllUcpCreate:
+ ((op[i] == UNC_OP_DELETE)?uuc::kUpllUcpDelete:uuc::kUpllUcpInvalid));
+ UPLL_LOG_DEBUG("Operation is %d", op[i]);
+ result_code = DiffConfigDB(UPLL_DT_RUNNING, UPLL_DT_AUDIT, op[i],
+ ckv_running_db, ckv_audit_db,
+ &cursor, dmi, ctrlr, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DiffConfigDB failed - %d", result_code);
+ return result_code;
+ }
+ if (cursor == NULL) {
+ UPLL_LOG_DEBUG("cursor is null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ while (uud::kDalRcSuccess == (db_result = dmi->GetNextRecord(cursor))) {
+ op1 = op[i];
+ if (phase != uuc::kUpllUcpDelete) {
+ uint8_t *db_ctrlr = NULL;
+ GET_USER_DATA_CTRLR(ckv_running_db,db_ctrlr);
+ UPLL_LOG_DEBUG("db ctrl_id and audit ctlr_id are %s %s",
+ db_ctrlr, ctrlr_id);
+ // Skipping the controller ID if the controller id in DB and
+ // controller id available for Audit are not the same
+ if (db_ctrlr && strncmp(reinterpret_cast<const char *>(db_ctrlr),
+ reinterpret_cast<const char *>(ctrlr_id),
+ strlen(reinterpret_cast<const char *>(ctrlr_id)) + 1)) {
+ continue;
+ }
+ }
+
+ switch (phase) {
+ case uuc::kUpllUcpDelete:
+ UPLL_LOG_TRACE("Deleted record is %s ",
+ ckv_running_db->ToStrAll().c_str());
+ result_code = GetChildConfigKey(ckv_driver_req, ckv_running_db);
+ UPLL_LOG_TRACE("ckv_driver_req in delete is %s",
+ ckv_driver_req->ToStrAll().c_str());
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed. err_code & phase %d %d",
+ result_code, phase);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ result_code = ReadConfigDB(ckv_driver_req, UPLL_DT_AUDIT, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d",result_code);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ GET_USER_DATA_FLAGS(ckv_driver_req, auditdb_flag);
+ break;
+ case uuc::kUpllUcpCreate:
+ UPLL_LOG_TRACE("Created record is %s ",
+ ckv_running_db->ToStrAll().c_str());
+ result_code = DupConfigKeyVal(ckv_driver_req, ckv_running_db, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed. err_code & phase %d %d",
+ result_code, phase);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ break;
+ case uuc::kUpllUcpUpdate:
+ ckv_audit_dup_db = NULL;
+ ckv_driver_req = NULL;
+ UPLL_LOG_TRACE("UpdateRecord record is %s ",
+ ckv_running_db->ToStrAll().c_str());
+ UPLL_LOG_TRACE("UpdateRecord record is %s ",
+ ckv_audit_db->ToStrAll().c_str());
+ result_code = DupConfigKeyVal(ckv_driver_req, ckv_running_db, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed for running record. \
+ err_code & phase %d %d", result_code, phase);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ result_code = DupConfigKeyVal(ckv_audit_dup_db, ckv_audit_db, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed for audit record. \
+ err_code & phase %d %d", result_code, phase);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ GET_USER_DATA_FLAGS(ckv_audit_dup_db, auditdb_flag);
+ break;
+ default:
+ UPLL_LOG_DEBUG("Invalid operation %d", phase);
+ return UPLL_RC_ERR_NO_SUCH_OPERATION;
+ break;
+ }
+ GET_USER_DATA_CTRLR_DOMAIN(ckv_driver_req, ctrlr_dom);
+ if ((NULL == ctrlr_dom.ctrlr) || (NULL == ctrlr_dom.domain)) {
+ UPLL_LOG_INFO("controller id or domain is NULL");
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ckv_audit_dup_db);
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+ db_flag = 0;
+ GET_USER_DATA_FLAGS(ckv_driver_req, db_flag);
+ // If portmap/vlink flag is not set at running and the operation is
+ // update then portmap/vlink is deleted in the update phase from UNC
+ // hence flowfilter seq no also should get deleted from controller
+ // hence sending the delete request to the controller driver
+ if ((SET_FLAG_PORTMAP & db_flag) || (SET_FLAG_VLINK & db_flag)) {
+ // Continue the operations
+ } else {
+ if (UNC_OP_UPDATE == op1) {
+ op1 = UNC_OP_DELETE;
+ } else {
+ // NO PortMap/Vlink Configured,
+ // Configuration is not sento to driver.
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ckv_audit_dup_db);
+ continue;
+ }
+ }
+
+ if (UNC_OP_UPDATE == op1) {
+ void *running_val = NULL;
+ bool invalid_attr = false;
+ running_val = GetVal(ckv_driver_req);
+ invalid_attr = FilterAttributes(running_val,
+ GetVal(ckv_audit_dup_db), false, UNC_OP_UPDATE);
+ if (invalid_attr) {
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ckv_audit_dup_db);
+ continue;
+ }
+ }
+
+ DELETE_IF_NOT_NULL(ckv_audit_dup_db);
+ /*pfcdrv_val_flowfilter_entry_t *pfc_val =
+ reinterpret_cast<pfcdrv_val_flowfilter_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(pfcdrv_val_flowfilter_entry_t)));
+
+ */
+ pfcdrv_val_vbrif_vextif *pfc_val =
+ reinterpret_cast<pfcdrv_val_vbrif_vextif *>
+ (ConfigKeyVal::Malloc(sizeof(pfcdrv_val_vbrif_vextif)));
+ if (op1 == UNC_OP_DELETE) {
+ vext_datatype = UPLL_DT_AUDIT;
+ db_flag = auditdb_flag;
+ } else {
+ vext_datatype = UPLL_DT_RUNNING;
+ }
+ result_code = GetVexternalInformation(ckv_driver_req, vext_datatype,
+ pfc_val, db_flag, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetVexternalInformation failed %d", result_code);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ upll_keytype_datatype_t dt_type = (op1 == UNC_OP_DELETE)?
+ UPLL_DT_AUDIT:UPLL_DT_RUNNING;
+ result_code = GetRenamedControllerKey(ckv_driver_req, UPLL_DT_RUNNING,
+ dmi, &ctrlr_dom);
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ UPLL_LOG_DEBUG("GetRenamedControllerKey failed %d", result_code);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+
+ ckv_driver_req->SetCfgVal(new ConfigVal(IpctSt::kIpcStPfcdrvValVbrifVextif,
+ pfc_val));
+ UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+
+
+ IpcResponse ipc_response;
+ memset(&ipc_response, 0, sizeof(IpcResponse));
+ IpcRequest ipc_req;
+ memset(&ipc_req, 0, sizeof(IpcRequest));
+ ipc_req.header.clnt_sess_id = session_id;
+ ipc_req.header.config_id = config_id;
+ ipc_req.header.operation = op1;
+ ipc_req.header.datatype = UPLL_DT_CANDIDATE;
+ ipc_req.ckv_data = ckv_driver_req;
+ if (!IpcUtil::SendReqToDriver((const char *)ctrlr_dom.ctrlr, reinterpret_cast<char *>
+ (ctrlr_dom.domain), PFCDRIVER_SERVICE_NAME,
+ PFCDRIVER_SVID_LOGICAL, &ipc_req, true, &ipc_response)) {
+ UPLL_LOG_INFO("Request to driver for Key %d for controller %s failed ",
+ ckv_driver_req->get_key_type(), reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (ipc_response.header.result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("driver return failure err_code is %d", ipc_response.header.result_code);
+ ConfigKeyVal *resp = NULL;
+ result_code = GetChildConfigKey(resp, ipc_response.ckv_data);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed for ipc response ckv err_code %d",
+ result_code);
+ delete ipc_response.ckv_data;
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCs };
+ result_code = ReadConfigDB(resp, dt_type, UNC_OP_READ, dbop,dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ReadConfigDB Failed");
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(resp);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+
+ result_code = UpdateAuditConfigStatus(UNC_CS_INVALID, phase, resp);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("Update Audit config status failed %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(resp);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ DbSubOp dbop1 = { kOpNotRead, kOpMatchNone, kOpInOutCs };
+ result_code = UpdateConfigDB(resp, dt_type, UNC_OP_UPDATE,
+ dmi, &dbop1, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed for ipc response ckv err_code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(resp);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(resp);
+ }
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ *ctrlr_affected = true;
+ }
+ dmi->CloseCursor(cursor, true);
+ DELETE_IF_NOT_NULL(ckv_running_db);
+ DELETE_IF_NOT_NULL(ckv_audit_db);
+ }
+ if (uud::kDalRcSuccess != db_result) {
+ UPLL_LOG_DEBUG("GetNextRecord from database failed - %d", db_result);
+ result_code = DalToUpllResCode(db_result);
+ }
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)
+ ? UPLL_RC_SUCCESS : result_code;
+ return result_code;
+}
+
+
bool VbrIfFlowFilterMoMgr::GetRenameKeyBindInfo(unc_key_type_t key_type,
BindInfo *&binfo,
int &nattr,
/* Main Table only update */
if (MAINTBL == tbl) {
- nattr = NUM_KEY_MAIN_TBL;
+ nattr = sizeof(vbr_if_flowfiltermaintbl_bind_info)/
+ sizeof(vbr_if_flowfiltermaintbl_bind_info[0]);
binfo = vbr_if_flowfiltermaintbl_bind_info;
} else {
return PFC_FALSE;
if (!ctrlr_name) {
ctrlr_name = static_cast<char *>(ikey->get_user_data());
}
- uint32_t dt_type = req->datatype;
- uint32_t operation = req->operation;
- uint32_t option1 = req->option1;
- uint32_t option2 = req->option2;
- UPLL_LOG_DEBUG("dt_type : (%d)"
- "operation : (%d)"
- "option1 : (%d)"
- "option2 : (%d)",
- dt_type, operation, option1, option2);
+ if (NULL == ctrlr_name) {
+ UPLL_LOG_DEBUG("ctrlr_name is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_TRACE("ctrlr_name : (%s)"
+ "operation : (%d)",
+ ctrlr_name, req->operation);
bool result_code = false;
- uint32_t instance_count;
+ uint32_t max_instance_count;
const uint8_t *attrs = NULL;
uint32_t max_attrs = 0;
- switch (operation) {
+ switch (req->operation) {
case UNC_OP_CREATE: {
+ UPLL_LOG_TRACE("Calling GetCreateCapability Operation %d ", req->operation);
+
result_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
- &instance_count, &max_attrs, &attrs);
- break;
- }
- case UNC_OP_UPDATE: {
- result_code = GetUpdateCapability(ctrlr_name, ikey->get_key_type(),
- &max_attrs, &attrs);
+ &max_instance_count, &max_attrs, &attrs);
+ if (result_code && cur_instance_count >= max_instance_count &&
+ cur_instance_count !=0 && max_instance_count != 0) {
+ UPLL_LOG_DEBUG("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
+ __LINE__, __FUNCTION__, cur_instance_count,
+ max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
break;
}
default: {
- result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ if (req->datatype == UPLL_DT_STATE) {
+ UPLL_LOG_TRACE("Calling GetStateCapability Operation %d ", req->operation);
+ result_code = GetStateCapability(ctrlr_name, ikey->get_key_type(),
&max_attrs, &attrs);
+ } else {
+ UPLL_LOG_TRACE("Calling GetReadCapability Operation %d ", req->operation);
+ result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ }
}
}
if (!result_code) {
UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s) "
"for opeartion(%d)",
- ikey->get_key_type(), ctrlr_name, operation);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ ikey->get_key_type(), ctrlr_name, req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
return UPLL_RC_SUCCESS;
}
UPLL_LOG_DEBUG(" Error: option1 is not NORMAL for ReadSiblingCount");
return UPLL_RC_ERR_INVALID_OPTION1;
}
+ if ((req->option1 == UNC_OPT1_DETAIL) &&
+ (req->datatype != UPLL_DT_STATE)) {
+ UPLL_LOG_DEBUG(" Invalid Datatype(%d)", req->datatype);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+ if ((req->datatype == UPLL_DT_IMPORT) && (req->operation == UNC_OP_READ ||
+ req->operation == UNC_OP_READ_SIBLING ||
+ req->operation == UNC_OP_READ_SIBLING_BEGIN ||
+ req->operation == UNC_OP_READ_NEXT ||
+ req->operation == UNC_OP_READ_BULK ||
+ req->operation == UNC_OP_READ_SIBLING_COUNT)) {
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
/** Read key structure */
key_vbr_if_flowfilter_t *key_vbr_if_flowfilter =
delete okey;
okey = NULL;
+ if (UNC_OP_CREATE == req->operation) {
+ result_code = SetRenameFlag(ikey, dmi, req);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("SetRenameFlag failed %d", result_code);
+ return result_code;
+ }
+ }
+
UPLL_LOG_DEBUG("ValidateAttribute Successfull.");
return result_code;
}
+upll_rc_t VbrIfFlowFilterMoMgr::SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *pkey = NULL;
+ result_code = GetParentConfigKey(pkey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetParentConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_VBR_IF)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("mgr is NULL");
+ DELETE_IF_NOT_NULL(pkey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t rename = 0;
+ result_code = mgr->IsRenamed(pkey, req->datatype, dmi, rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(pkey);
+ return result_code;
+ }
+ UPLL_LOG_DEBUG("Flag from parent : %d", rename);
+ SET_USER_DATA_FLAGS(ikey, rename);
+ DELETE_IF_NOT_NULL(pkey);
+ return UPLL_RC_SUCCESS;
+}
+
+
upll_rc_t VbrIfFlowFilterMoMgr::IsReferenced(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi) {
if (parent_key == NULL) {
vbr_if_ff_key = reinterpret_cast<key_vbr_if_flowfilter_t*>
(ConfigKeyVal::Malloc(sizeof(key_vbr_if_flowfilter_t)));
+ // If no direction is specified , 0xFE is filled to bind output direction
+ vbr_if_ff_key->direction = 0xFE;
okey = new ConfigKeyVal(UNC_KT_VBRIF_FLOWFILTER,
IpctSt::kIpcStKeyVbrIfFlowfilter,
vbr_if_ff_key, NULL);
if (okey) {
if (okey->get_key_type() != UNC_KT_VBRIF_FLOWFILTER)
return UPLL_RC_ERR_GENERIC;
+ }
+ if ((okey) && (okey->get_key())) {
vbr_if_ff_key = reinterpret_cast<key_vbr_if_flowfilter_t *>
(okey->get_key());
} else {
vbr_if_ff_key = reinterpret_cast<key_vbr_if_flowfilter_t *>
(ConfigKeyVal::Malloc(sizeof(key_vbr_if_flowfilter_t)));
+ // If no direction is specified , 0xFE is filled to bind output direction
+ vbr_if_ff_key->direction = 0xFE;
}
switch (parent_key->get_key_type()) {
return UPLL_RC_ERR_GENERIC;
}
+
+ if ((okey) && !(okey->get_key())) {
+ UPLL_LOG_DEBUG("okey not null and flow list name updated");
+ okey->SetKey(IpctSt::kIpcStKeyVbrIfFlowfilter, vbr_if_ff_key);
+ }
+
if (!okey) {
okey = new ConfigKeyVal(UNC_KT_VBRIF_FLOWFILTER,
IpctSt::kIpcStKeyVbrIfFlowfilter,
}
upll_rc_t VbrIfFlowFilterMoMgr::MergeValidate(unc_key_type_t keytype,
- const char *ctrlr_id,
- ConfigKeyVal *ikey,
- DalDmlIntf *dmi) {
+ const char *ctrlr_id,
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
- UPLL_LOG_DEBUG("Merge Validate is successfull.");
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ckval = NULL;
+ if (NULL == ctrlr_id) {
+ UPLL_LOG_DEBUG("MergeValidate ctrlr_id NULL");
+ return result_code;
+ }
+
+ result_code = GetChildConfigKey(ckval, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey ckval NULL");
+ return result_code;
+ }
+
+ if (!ckval) return UPLL_RC_ERR_GENERIC;
+
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain};
+ result_code = ReadConfigDB(ckval, UPLL_DT_IMPORT,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ckval);
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ return result_code;
+ }
+ return UPLL_RC_SUCCESS;
+ }
+ ConfigKeyVal *first_ckv = ckval;
+ while (NULL != ckval) {
+ result_code = UpdateConfigDB(ckval, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
+ MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ UPLL_LOG_DEBUG("Merge Conflict");
+ result_code = DupConfigKeyVal(ikey, ckval, MAINTBL);
+ DELETE_IF_NOT_NULL(first_ckv);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal fail");
+ return result_code;
+ }
+ return UPLL_RC_ERR_MERGE_CONFLICT;
+ } else if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ ckval = ckval->get_next_cfg_key_val();
+ } else {
+ UPLL_LOG_DEBUG("Merge Conflict DB err");
+ DELETE_IF_NOT_NULL(first_ckv);
+ return result_code;
+ }
+ }
+ DELETE_IF_NOT_NULL(first_ckv);
return UPLL_RC_SUCCESS;
}
uint8_t *ctrlr_id) {
UPLL_FUNC_TRACE;
ConfigKeyVal *unc_key = NULL;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vbrifff start",
+ ikey->ToStrAll().c_str());
+ if ((NULL == ikey) || (ctrlr_id == NULL) || (NULL == dmi)) {
+ UPLL_LOG_DEBUG("ikey/ctrlr_id dmi NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
MoMgrImpl *mgrvbr = reinterpret_cast<MoMgrImpl *>
(const_cast<MoManager *> (GetMoManager(UNC_KT_VBRIDGE)));
if (mgrvbr == NULL) {
+ UPLL_LOG_DEBUG("mgrvbr NULL");
return UPLL_RC_ERR_GENERIC;
}
val_rename_vnode *rename_val = reinterpret_cast
<val_rename_vnode*>(ConfigKeyVal::Malloc(sizeof(val_rename_vnode)));
-
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("rename_val NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
key_vbr_if_flowfilter_t *ctrlr_key =
reinterpret_cast<key_vbr_if_flowfilter_t *> (ikey->get_key());
+ if (!ctrlr_key) {
+ UPLL_LOG_DEBUG("ctrlr_key NULL");
+ FREE_IF_NOT_NULL(rename_val);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
uuu::upll_strncpy(rename_val->ctrlr_vtn_name,
ctrlr_key->if_key.vbr_key.vtn_key.vtn_name,
(kMaxLenVtnName + 1));
+ rename_val->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
+
uuu::upll_strncpy(rename_val->ctrlr_vnode_name,
ctrlr_key->if_key.vbr_key.vbridge_name,
(kMaxLenVnodeName + 1));
- if (UPLL_RC_SUCCESS != mgrvbr->GetChildConfigKey(unc_key, NULL)) {
- FREE_IF_NOT_NULL(rename_val);
+ rename_val->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_VALID;
+
+ result_code = mgrvbr->GetChildConfigKey(unc_key, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Unable to get the configkey for Vribdge");
+ FREE_IF_NOT_NULL(rename_val);
+ mgrvbr = NULL;
+ return result_code;
+ }
+ if (!unc_key) {
+ UPLL_LOG_DEBUG("unc_key NULL");
+ FREE_IF_NOT_NULL(rename_val);
+ mgrvbr = NULL;
return UPLL_RC_ERR_GENERIC;
}
-
- if (ctrlr_id == NULL) {
- free(rename_val);
+ SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
+ unc_key->AppendCfgVal(IpctSt::kIpcStValRenameVtn, rename_val);
+ result_code = mgrvbr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ,
+ dbop, dmi, RENAMETBL);
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
DELETE_IF_NOT_NULL(unc_key);
- UPLL_LOG_DEBUG("Controller Name is Not Valid");
- return UPLL_RC_ERR_GENERIC;
+ mgrvbr = NULL;
+ return result_code;
}
- unc_key->set_user_data(ctrlr_id);
- unc_key->AppendCfgVal(IpctSt::kIpcStValRenameVtn, rename_val);
- upll_rc_t result_code = mgrvbr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ,
- dbop, dmi, RENAMETBL);
if (result_code == UPLL_RC_SUCCESS) {
key_vbr_if_flowfilter_t *vbr_if_flowfilter_key =
reinterpret_cast<key_vbr_if_flowfilter_t *> (unc_key->get_key());
(kMaxLenVnodeName + 1));
}
- UPLL_LOG_DEBUG("Keyis filled with UncKey Successfully %d", result_code);
- free(rename_val);
- delete unc_key;
- return result_code;
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vbrifff end",
+ ikey->ToStrAll().c_str());
+ DELETE_IF_NOT_NULL(unc_key);
+ mgrvbr = NULL;
+ return UPLL_RC_SUCCESS;
}
upll_rc_t VbrIfFlowFilterMoMgr::GetRenamedControllerKey(
- ConfigKeyVal *&ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
+ ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
controller_domain *ctrlr_dom) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
ConfigKeyVal *okey = NULL;
uint8_t rename = 0;
IsRenamed(ikey, dt_type, dmi, rename);
-
if (!rename) {
- return UPLL_RC_SUCCESS;
+ UPLL_LOG_DEBUG("no renamed");
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_TRACE("Start Input ConfigKeyval = %s", ikey->ToStrAll().c_str());
+
+ MoMgrImpl *mgrvbr = reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_VBRIDGE)));
+
+ if (mgrvbr == NULL) {
+ UPLL_LOG_DEBUG("obj null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ result_code = mgrvbr->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+
+ if (ctrlr_dom) {
+ SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+ }
+ else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vbr *> (okey->get_key())->vtn_key.vtn_name,
+ reinterpret_cast<key_vbr_if_flowfilter_t *>
+ (ikey->get_key())->if_key.vbr_key.vtn_key.vtn_name,
+ (kMaxLenVnodeName + 1));
+
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vbr *> (okey->get_key())->vbridge_name,
+ reinterpret_cast<key_vbr_if_flowfilter_t *>
+ (ikey->get_key())->if_key.vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr | kOpMatchDomain, kOpInOutFlag };
+ result_code = mgrvbr->ReadConfigDB(okey, dt_type, UNC_OP_READ,
+ dbop, dmi, RENAMETBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB no instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("Unable to Read from DB");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+
+ val_rename_vnode *rename_val = NULL;
+ rename_val = reinterpret_cast<val_rename_vnode *> (GetVal(okey));
+
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("Vbr Name is not Valid.");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ if (rename & VTN_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("vtn name renamed");
+ uuu::upll_strncpy(reinterpret_cast<key_vbr_if_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.if_key.vbr_key.vtn_key.vtn_name,
+ rename_val->ctrlr_vtn_name,
+ (kMaxLenVtnName + 1));
+ UPLL_LOG_DEBUG("vtn rename (%s) (%s)",
+ reinterpret_cast<key_vbr_if_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.if_key.vbr_key.vtn_key.vtn_name,
+ rename_val->ctrlr_vtn_name);
+ }
+
+ if (rename & VBR_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("vbr name renamed");
+ uuu::upll_strncpy(reinterpret_cast<key_vbr_if_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.if_key.vbr_key.vbridge_name,
+ rename_val->ctrlr_vnode_name,
+ (kMaxLenVnodeName + 1));
+ UPLL_LOG_DEBUG("vtn rename (%s) (%s)",
+ reinterpret_cast<key_vbr_if_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.if_key.vbr_key.vbridge_name,
+ rename_val->ctrlr_vnode_name);
}
- // Vtn renamed
- key_vbr_if_flowfilter_t *ctrlr_key =
- reinterpret_cast<key_vbr_if_flowfilter_t*>
- (ConfigKeyVal::Malloc(sizeof(key_vbr_if_flowfilter_t)));
+ SET_USER_DATA_FLAGS(ikey, rename);
+ DELETE_IF_NOT_NULL(okey);
+ UPLL_LOG_TRACE("End Input ConfigKeyVal= %s", ikey->ToStrAll().c_str());
+ UPLL_LOG_DEBUG("Renamed Controller key is sucessfull.");
+ return UPLL_RC_SUCCESS;
+#if 0
+ // Vtn renamed
if (rename & VTN_RENAME_FLAG) {
MoMgrImpl *mgrvtn = reinterpret_cast<MoMgrImpl *>
(const_cast<MoManager *> (GetMoManager(UNC_KT_VTN)));
if (mgrvtn == NULL) {
+ UPLL_LOG_DEBUG("obj null");
return UPLL_RC_ERR_GENERIC;
}
- mgrvtn->GetChildConfigKey(okey, NULL);
- if (ctrlr_dom)
+ result_code = mgrvtn->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+
+ if (ctrlr_dom) {
SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
uuu::upll_strncpy(reinterpret_cast<key_vtn *>(okey->get_key())->vtn_name,
reinterpret_cast<key_vbr_if_flowfilter_t *>
(ikey->get_key())->if_key.vbr_key.vtn_key.vtn_name,
(kMaxLenVtnName + 1));
-
+// UPLL_LOG_DEBUG("vtn name (%s) (%s)", (okey->get_key())->vtn_name,
+// (ikey->get_key())->if_key.vbr_key.vtn_key.vtn_name);
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
result_code =mgrvtn->ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop,
dmi, RENAMETBL);
if (result_code != UPLL_RC_SUCCESS) {
- free(ctrlr_key);
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
val_rename_vtn *rename_val = NULL;
if (!rename_val
|| (rename_val->valid[UPLL_IDX_NEW_NAME_RVTN] != UNC_VF_VALID)) {
UPLL_LOG_DEBUG("Vtn Name is not Valid.");
- free(ctrlr_key);
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
- uuu::upll_strncpy(
- ctrlr_key->if_key.vbr_key.vtn_key.vtn_name,
+ uuu::upll_strncpy(reinterpret_cast<key_vbr_if_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.if_key.vbr_key.vtn_key.vtn_name,
rename_val->new_name,
(kMaxLenVtnName + 1));
- SET_USER_DATA_FLAGS(ikey, VTN_RENAME);
+ SET_USER_DATA_FLAGS(ikey, rename);
}
// Vbr Renamed
if (rename & VBR_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("vbr name renamed");
MoMgrImpl *mgrvbr = reinterpret_cast<MoMgrImpl *>
(const_cast<MoManager *> (GetMoManager(UNC_KT_VBRIDGE)));
- if (mgrvbr == NULL) return UPLL_RC_ERR_GENERIC;
- mgrvbr->GetChildConfigKey(okey, NULL);
+ if (mgrvbr == NULL) {
+ UPLL_LOG_DEBUG("obj null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ result_code = mgrvbr->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
- if (ctrlr_dom)
+ if (ctrlr_dom) {
SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+ }
+ else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
uuu::upll_strncpy(
reinterpret_cast<key_vbr *> (okey->get_key())->vbridge_name,
reinterpret_cast<key_vbr_if_flowfilter_t *>
(ikey->get_key())->if_key.vbr_key.vbridge_name,
(kMaxLenVnodeName + 1));
+// UPLL_LOG_DEBUG("vbr name (%s) (%s)", (okey->get_key())->vbridge_name,
+// (ikey->get_key())->if_key.vbr_key.vbridge_name);
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
result_code = mgrvbr->ReadConfigDB(okey, dt_type, UNC_OP_READ,
dbop, dmi, RENAMETBL);
if (result_code != UPLL_RC_SUCCESS) {
- delete okey;
UPLL_LOG_DEBUG("Unable to Read from DB");
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
val_rename_vbr *rename_val = NULL;
rename_val = reinterpret_cast<val_rename_vbr *> (GetVal(okey));
- if (!rename_val
- || (rename_val->valid[UPLL_IDX_NEW_NAME_RVBR] != UNC_VF_VALID)) {
+ if (!rename_val) {
UPLL_LOG_DEBUG("Vbr Name is not Valid.");
- free(ctrlr_key);
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
- uuu::upll_strncpy(ctrlr_key->if_key.vbr_key.vbridge_name,
+ uuu::upll_strncpy(reinterpret_cast<key_vbr_if_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.if_key.vbr_key.vbridge_name,
rename_val->new_name,
(kMaxLenVnodeName + 1));
- SET_USER_DATA_FLAGS(ikey, VTN_RENAME);
+ DELETE_IF_NOT_NULL(okey);
}
-
+ UPLL_LOG_TRACE("GetRenamedCtrl vbr_if_ff end %s", ikey->ToStrAll().c_str());
UPLL_LOG_DEBUG("Renamed Controller key is sucessfull.");
- // free(ctrlr_key);
return UPLL_RC_SUCCESS;
+#endif
}
upll_rc_t VbrIfFlowFilterMoMgr::UpdateAuditConfigStatus(
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- val_flowfilter_t *vbr_flowfilter_val = NULL;
- vbr_flowfilter_val = (ckv_running != NULL)?
+ val_flowfilter_t *val = NULL;
+ val = (ckv_running != NULL)?
reinterpret_cast<val_flowfilter_t *> (GetVal(ckv_running)):NULL;
- if (NULL == vbr_flowfilter_val) {
+ if (NULL == val) {
UPLL_LOG_DEBUG("val strct is empty");
return UPLL_RC_ERR_GENERIC;
}
-
- if (uuc::kUpllUcpCreate == phase)
- vbr_flowfilter_val->cs_row_status = cs_status;
+ if (uuc::kUpllUcpCreate == phase )
+ val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
UPLL_LOG_DEBUG("AuditUpdate Config Status Information %d", result_code);
return result_code;
}
GET_USER_DATA_CTRLR_DOMAIN(dup_key, ctrlr_dom);
SET_USER_DATA_CTRLR_DOMAIN(l_key, ctrlr_dom);
+ //Added ValidateCapa
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(ctrlr_dom.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("validate Capability Failed %d", result_code);
+ return result_code;
+ }
+
// 1.Getting renamed name if renamed
result_code = GetRenamedControllerKey(l_key, req->datatype,
dmi, &ctrlr_dom);
DELETE_IF_NOT_NULL(dup_key);
DELETE_IF_NOT_NULL(l_key);
DELETE_IF_NOT_NULL(flag_key);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
return UPLL_RC_ERR_GENERIC;
}
if (ipc_resp.header.result_code != UPLL_RC_SUCCESS) {
DELETE_IF_NOT_NULL(dup_key);
DELETE_IF_NOT_NULL(l_key);
DELETE_IF_NOT_NULL(flag_key);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
return ipc_resp.header.result_code;
}
ConfigKeyVal *okey = NULL;
result_code = ConstructReadDetailResponse(dup_key,
ipc_resp.ckv_data,
- req->datatype,
- req->operation,
- dbop, dmi, &okey);
-
+ &okey);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(flag_key);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ConstructReadDetailResponse error code (%d)",
result_code);
- DELETE_IF_NOT_NULL(dup_key);
- DELETE_IF_NOT_NULL(l_key);
- DELETE_IF_NOT_NULL(flag_key);
return result_code;
} else {
if (okey != NULL) {
ikey->ResetWith(okey);
+ DELETE_IF_NOT_NULL(okey);
}
}
- DELETE_IF_NOT_NULL(dup_key);
- DELETE_IF_NOT_NULL(l_key);
- DELETE_IF_NOT_NULL(flag_key);
}
break;
default:
reinterpret_cast<key_vbr_if_flowfilter_t*>
(ConfigKeyVal::Malloc(sizeof(key_vbr_if_flowfilter_t)));
- if (!strlen(reinterpret_cast<char *> (key_rename->old_unc_vtn_name))) {
- UPLL_LOG_DEBUG("String Length not Valid to Perform the Operation");
- free(key_vbr_if);
- return UPLL_RC_ERR_GENERIC;
+ if (!strlen(reinterpret_cast<char *> (key_rename->old_unc_vtn_name))) {
+ UPLL_LOG_DEBUG("old_unc_vtn_name NULL");
+ if (key_vbr_if) free(key_vbr_if);
+ return UPLL_RC_ERR_GENERIC;
}
uuu::upll_strncpy(key_vbr_if->if_key.vbr_key.vtn_key.vtn_name,
key_rename->old_unc_vtn_name,
(kMaxLenVtnName + 1));
- if (ikey->get_key_type() == table[MAINTBL]->get_key_type()) {
- if (!strlen(reinterpret_cast<char *> (key_rename->old_unc_vnode_name))) {
+ if (UNC_KT_VBRIDGE == ikey->get_key_type()) {
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vnode_name))) {
+ UPLL_LOG_DEBUG("old_unc_vnode_name NULL");
free(key_vbr_if);
return UPLL_RC_ERR_GENERIC;
}
uuu::upll_strncpy(key_vbr_if->if_key.vbr_key.vbridge_name,
- key_rename->old_unc_vnode_name,
- (kMaxLenVnodeName + 1));
+ key_rename->old_unc_vnode_name, (kMaxLenVnodeName + 1));
+ } else {
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_unc_vnode_name))) {
+ UPLL_LOG_DEBUG("new_unc_vnode_name NULL");
+ free(key_vbr_if);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(key_vbr_if->if_key.vbr_key.vbridge_name,
+ key_rename->new_unc_vnode_name, (kMaxLenVnodeName + 1));
}
-
+ key_vbr_if->direction = 0xFE;
okey = new ConfigKeyVal(UNC_KT_VBRIF_FLOWFILTER,
IpctSt::kIpcStKeyVbrIfFlowfilter,
key_vbr_if, NULL);
return UPLL_RC_ERR_GENERIC;
}
- // free(key_vbr_if); // Should not free this memory
return result_code;
}
upll_rc_t VbrIfFlowFilterMoMgr::ConstructReadDetailResponse(
ConfigKeyVal *ikey,
ConfigKeyVal *drv_resp_ckv,
- upll_keytype_datatype_t dt_type,
- unc_keytype_operation_t op,
- DbSubOp dbop,
- DalDmlIntf *dmi,
ConfigKeyVal **okey) {
UPLL_FUNC_TRACE;
ConfigKeyVal *tmp_okey = NULL;
return result_code;
}
- val_flowfilter_t *val_ff = reinterpret_cast<val_flowfilter_t *>
- (ConfigKeyVal::Malloc(sizeof(val_flowfilter_t)));
val_flowfilter_t *tmp_val_ff = reinterpret_cast<val_flowfilter_t *>
(GetVal(ikey));
if (!tmp_val_ff) {
UPLL_LOG_DEBUG(" Invalid value read from DB");
- delete tmp_okey;
- free(val_ff);
+ DELETE_IF_NOT_NULL(tmp_okey);
return UPLL_RC_ERR_GENERIC;
}
+ val_flowfilter_t *val_ff = reinterpret_cast<val_flowfilter_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_flowfilter_t)));
memcpy(val_ff, tmp_val_ff, sizeof(val_flowfilter_t));
tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowfilter, val_ff);
-
- ConfigVal *drv_resp_val = NULL;
- drv_resp_val = drv_resp_ckv->get_cfg_val();
- while (drv_resp_val != NULL) {
- val_flowfilter_entry_st_t *val_ffe_st = NULL;
- if (IpctSt::kIpcStValFlowfilterEntrySt == drv_resp_val->get_st_num()) {
- val_ffe_st = reinterpret_cast<val_flowfilter_entry_st_t *>
- (drv_resp_val->get_val());
- } else {
- UPLL_LOG_DEBUG("Incorrect structure received from driver, struct num %d",
- drv_resp_val->get_st_num());
- return UPLL_RC_ERR_GENERIC;
- }
-
- if ((val_ffe_st)->valid[UPLL_IDX_SEQ_NUM_FFES] == UNC_VF_VALID) {
- ConfigKeyVal *tmp_ffe_key = NULL;
-
- key_vbr_if_flowfilter_t *key_vbrif_ff =
- reinterpret_cast<key_vbr_if_flowfilter_t*>(ikey->get_key());
-
- key_vbr_if_flowfilter_entry_t *key_vbrif_ffe =
- reinterpret_cast<key_vbr_if_flowfilter_entry_t*>
- (ConfigKeyVal::Malloc(sizeof(key_vbr_if_flowfilter_entry_t)));
- tmp_ffe_key = new ConfigKeyVal(UNC_KT_VBRIF_FLOWFILTER_ENTRY,
- IpctSt::kIpcStKeyVbrIfFlowfilterEntry,
- key_vbrif_ffe, NULL);
- key_vbrif_ffe->sequence_num = val_ffe_st->sequence_num;
- uuu::upll_strncpy(
- key_vbrif_ffe->flowfilter_key.if_key.vbr_key.vtn_key.vtn_name,
- key_vbrif_ff->if_key.vbr_key.vtn_key.vtn_name,
- (kMaxLenVtnName+1));
-
- uuu::upll_strncpy(
- key_vbrif_ffe->flowfilter_key.if_key.vbr_key.vbridge_name,
- key_vbrif_ff->if_key.vbr_key.vbridge_name,
- (kMaxLenVnodeName+1));
-
- uuu::upll_strncpy(key_vbrif_ffe->flowfilter_key.if_key.if_name,
- key_vbrif_ff->if_key.if_name,
- (kMaxLenInterfaceName +1));
-
- key_vbrif_ffe->flowfilter_key.direction =
- (reinterpret_cast<key_vbr_if_flowfilter*>(
- ikey->get_key()))->direction;
-
- VbrIfFlowFilterEntryMoMgr *mgr =
- reinterpret_cast<VbrIfFlowFilterEntryMoMgr*>
- (const_cast<MoManager *>(GetMoManager
- (UNC_KT_VBRIF_FLOWFILTER_ENTRY)));
- result_code = mgr->ReadDetailEntry(tmp_ffe_key, dt_type,
- UNC_OP_READ, dbop, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(" flowfilter entry read detail error (%d)", result_code);
- delete tmp_ffe_key;
- return result_code;
- }
-
- val_flowfilter_entry_st_t *tmp_ffe_st =
- reinterpret_cast<val_flowfilter_entry_st_t* >
- (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_st_t)));
- memcpy(tmp_ffe_st, val_ffe_st, sizeof(val_flowfilter_entry_st_t));
-
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowfilterEntrySt, tmp_ffe_st);
- val_flowfilter_entry_t* tmp_val_ffe =
- reinterpret_cast <val_flowfilter_entry_t*>
- (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_t)));
- memcpy(tmp_val_ffe,
- reinterpret_cast<val_flowfilter_entry_t*>
- (tmp_ffe_key->get_cfg_val()->get_val()),
- sizeof(val_flowfilter_entry_t));
-
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowfilterEntry, tmp_val_ffe);
-
- delete tmp_ffe_key;
- tmp_ffe_key = NULL;
-
- if ((drv_resp_val = drv_resp_val->get_next_cfg_val()) == NULL) {
- UPLL_LOG_DEBUG("No more entries in driver response\n");
- break;
- }
-
- if (IpctSt::kIpcStValFlowlistEntrySt != drv_resp_val->get_st_num()) {
- UPLL_LOG_DEBUG("No flowflist entries returned by driver");
- continue;
- }
- while (IpctSt::kIpcStValFlowlistEntrySt == drv_resp_val->get_st_num()) {
- val_flowlist_entry_st_t* tmp_val_fl_st =
- reinterpret_cast<val_flowlist_entry_st_t*>
- (ConfigKeyVal::Malloc(sizeof(val_flowlist_entry_st_t)));
- memcpy(tmp_val_fl_st,
- reinterpret_cast<val_flowlist_entry_st_t*>
- (drv_resp_val->get_val()),
- sizeof(val_flowlist_entry_st_t));
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowlistEntrySt, tmp_val_fl_st);
- drv_resp_val = drv_resp_val->get_next_cfg_val();
- if (!drv_resp_val) {
- break;
- }
- }
- }
- }
+ tmp_okey->AppendCfgVal(drv_resp_ckv->GetCfgValAndUnlink());
if (*okey == NULL) {
*okey = tmp_okey;
} else {
}
GET_USER_DATA_CTRLR_DOMAIN(dup_key, ctrlr_dom);
SET_USER_DATA_CTRLR_DOMAIN(l_key, ctrlr_dom);
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(ctrlr_dom.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("validate Capability Failed %d", result_code);
+ return result_code;
+ }
+
// 1.Getting renamed name if renamed
result_code = GetRenamedControllerKey(l_key, req->datatype,
dmi, &ctrlr_dom);
DELETE_IF_NOT_NULL(flag_key);
DELETE_IF_NOT_NULL(tctrl_key);
DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
return UPLL_RC_ERR_GENERIC;
}
DELETE_IF_NOT_NULL(flag_key);
DELETE_IF_NOT_NULL(tctrl_key);
DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
return ipc_resp.header.result_code;
}
result_code = ConstructReadDetailResponse(tmp_key,
ipc_resp.ckv_data,
- req->datatype,
- req->operation,
- dbop, dmi, &okey);
+ &okey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ConstructReadDetailResponse error code (%d)",
result_code);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
DELETE_IF_NOT_NULL(l_key);
DELETE_IF_NOT_NULL(flag_key);
DELETE_IF_NOT_NULL(tctrl_key);
}
if ((okey != NULL) && (result_code == UPLL_RC_SUCCESS)) {
ikey->ResetWith(okey);
+ DELETE_IF_NOT_NULL(okey);
}
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
DELETE_IF_NOT_NULL(l_key);
DELETE_IF_NOT_NULL(flag_key);
DELETE_IF_NOT_NULL(tctrl_key);
op1 = op;
result_code = DupConfigKeyVal(ck_main, req, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("DupConfigKeyVal failed %d\n", result_code);
+ UPLL_LOG_TRACE("DupConfigKeyVal failed %d", result_code);
return result_code;
}
break;
op1 = op;
result_code = GetChildConfigKey(ck_main, req);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("GetChildConfigKey failed %d\n", result_code);
+ UPLL_LOG_TRACE("GetChildConfigKey failed %d", result_code);
return result_code;
}
- default:
break;
- }
-
- /*
- DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone};
- result_code = ReadConfigDB(ck_main, UPLL_DT_RUNNING, UNC_OP_READ,
- dbop, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ default:
+ UPLL_LOG_DEBUG("TxUpdateController Invalid operation");
return UPLL_RC_ERR_GENERIC;
- }
+ }
- */
GET_USER_DATA_CTRLR_DOMAIN(ck_main, ctrlr_dom);
if (ctrlr_dom.ctrlr == NULL) {
+ DELETE_IF_NOT_NULL(ck_main);
return UPLL_RC_ERR_GENERIC;
}
db_flag = 0;
ConfigKeyVal *tmp_cfgkeyval = NULL;
if (!(SET_FLAG_PORTMAP & db_flag) && !(SET_FLAG_VLINK & db_flag)) {
if (op1 != UNC_OP_UPDATE) {
+ DELETE_IF_NOT_NULL(ck_main);
continue;
} else {
result_code = GetChildConfigKey(tmp_cfgkeyval, ck_main);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetChildConfigKey failed, err %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
return result_code;
}
SET_USER_DATA_CTRLR_DOMAIN(tmp_cfgkeyval, ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
UPLL_LOG_DEBUG("Unable to read from DB, err: %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(tmp_cfgkeyval);
return result_code;
}
}
if (!(SET_FLAG_PORTMAP & db_flag_running) &&
!(SET_FLAG_VLINK & db_flag_running)) {
UPLL_LOG_DEBUG("portmap flag is not available at running as well ");
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(tmp_cfgkeyval);
continue;
}
op1 = UNC_OP_DELETE;
vext_datatype = UPLL_DT_RUNNING;
db_flag = db_flag_running;
}
+ DELETE_IF_NOT_NULL(tmp_cfgkeyval);
} else if (op1 == UNC_OP_UPDATE) {
result_code = GetChildConfigKey(tmp_cfgkeyval, ck_main);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetChildConfigKey failed, err %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
return result_code;
}
SET_USER_DATA_CTRLR_DOMAIN(tmp_cfgkeyval, ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
UPLL_LOG_DEBUG("Unable to read from DB, err: %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(tmp_cfgkeyval);
return result_code;
}
}
op1 = UNC_OP_CREATE;
vext_datatype = UPLL_DT_CANDIDATE;
}
+ DELETE_IF_NOT_NULL(tmp_cfgkeyval);
}
reinterpret_cast<pfcdrv_val_vbrif_vextif *>
(ConfigKeyVal::Malloc(sizeof(pfcdrv_val_vbrif_vextif)));
+ if (UNC_OP_DELETE == op1) {
+ vext_datatype = UPLL_DT_RUNNING;
+ }
+
result_code = GetVexternalInformation(ck_main, vext_datatype,
pfc_val, db_flag, dmi);
if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ck_main);
+ free(pfc_val);
+ return result_code;
+ }
+ UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+ ConfigKeyVal *temp_ck_main = NULL;
+ result_code = DupConfigKeyVal(temp_ck_main, req, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
+ free(pfc_val);
return result_code;
}
upll_keytype_datatype_t dt_type = (op1 == UNC_OP_DELETE)?
UPLL_DT_RUNNING:UPLL_DT_CANDIDATE;
result_code = GetRenamedControllerKey(ck_main, dt_type,
dmi, &ctrlr_dom);
- if (result_code != UPLL_RC_SUCCESS)
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetRenamedControllerKey failed %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
+ free(pfc_val);
return result_code;
+ }
ck_main->SetCfgVal(new ConfigVal(IpctSt::kIpcStPfcdrvValVbrifVextif,
pfc_val));
result_code = UPLL_RC_SUCCESS;
}
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("IpcSend failed %d\n", result_code);
- *err_ckv = ipc_resp.ckv_data;
- if (ck_main)
- delete ck_main;
+ UPLL_LOG_DEBUG("IpcSend failed %d", result_code);
+ *err_ckv = temp_ck_main;
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(ck_main);
break;
}
- if (ck_main) {
- delete ck_main;
- ck_main = NULL;
- }
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(temp_ck_main);
+ DELETE_IF_NOT_NULL(ck_main);
}
dmi->CloseCursor(dal_cursor_handle, true);
- if (req)
- delete req;
- if (nreq)
- delete nreq;
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) ?
UPLL_RC_SUCCESS : result_code;
return result_code;
upll_rc_t VbrIfFlowFilterMoMgr::SetVlinkPortmapConfiguration(
ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
- DalDmlIntf *dmi, InterfacePortMapInfo flags) {
+ DalDmlIntf *dmi, InterfacePortMapInfo flags,
+ unc_keytype_operation_t oper) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
if (NULL == ikey || NULL == ikey->get_key()) {
UNC_OP_READ, dbop, dmi, MAINTBL);
if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
UPLL_LOG_DEBUG("No Recrods in the Vbr_If_FlowFilter Table");
+ DELETE_IF_NOT_NULL(ckv);
return UPLL_RC_SUCCESS;
}
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("Read ConfigDB failure %d", result_code);
- delete ckv;
+ DELETE_IF_NOT_NULL(ckv);
return result_code;
}
uint8_t flag_port_map = 0;
- while (ckv) {
- GET_USER_DATA_FLAGS(ckv, flag_port_map);
+ ConfigKeyVal *temp_ckv = ckv;
+ while (temp_ckv) {
+ flag_port_map = 0;
+ GET_USER_DATA_FLAGS(temp_ckv, flag_port_map);
if (flags & kVlinkConfigured) {
UPLL_LOG_DEBUG("only vlink");
- flag_port_map = SET_FLAG_VLINK;
+ flag_port_map |= SET_FLAG_VLINK;
} else if (flags & kPortMapConfigured) {
UPLL_LOG_DEBUG("only portmap");
- flag_port_map = SET_FLAG_PORTMAP;
+ flag_port_map |= SET_FLAG_PORTMAP;
} else if (flags & kVlinkPortMapConfigured) {
UPLL_LOG_DEBUG("portmap with vlink");
- flag_port_map = SET_FLAG_VLINK_PORTMAP;
+ flag_port_map |= SET_FLAG_VLINK_PORTMAP;
} else {
- // No port map of vlink configuration
- UPLL_LOG_DEBUG("NO portmap");
- flag_port_map = 0;
+ flag_port_map &= SET_FLAG_NO_VLINK_PORTMAP;
}
-
- uint8_t rename_flag = 0;
- GET_USER_DATA_FLAGS(ckv, rename_flag);
- rename_flag |= flag_port_map;
- SET_USER_DATA_FLAGS(ckv, flag_port_map);
+ SET_USER_DATA_FLAGS(temp_ckv, flag_port_map);
DbSubOp dbop_up = { kOpNotRead, kOpMatchNone, kOpInOutFlag };
- result_code = UpdateConfigDB(ckv, dt_type, UNC_OP_UPDATE,
+ result_code = UpdateConfigDB(temp_ckv, dt_type, UNC_OP_UPDATE,
dmi, &dbop_up, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("failed to update the portmap configuration");
+ DELETE_IF_NOT_NULL(ckv);
return result_code;
}
reinterpret_cast<VbrIfFlowFilterEntryMoMgr *>
(const_cast<MoManager *>(GetMoManager(UNC_KT_VBRIF_FLOWFILTER_ENTRY)));
if (mgr == NULL) {
+ DELETE_IF_NOT_NULL(ckv);
return UPLL_RC_ERR_GENERIC;
}
- result_code = mgr->SetVlinkPortmapConfiguration(ikey, dt_type, dmi, flags);
+ result_code = mgr->SetVlinkPortmapConfiguration(ikey, dt_type, dmi, flags,
+ oper);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("update portmap flag for flowfilterentry failed, err %d",
result_code);
+ DELETE_IF_NOT_NULL(ckv);
return result_code;
}
- ckv = ckv->get_next_cfg_key_val();
+ temp_ckv = temp_ckv->get_next_cfg_key_val();
}
+ DELETE_IF_NOT_NULL(ckv);
return UPLL_RC_SUCCESS;
}
UPLL_LOG_DEBUG(" Input Key is NULL");
return UPLL_RC_ERR_GENERIC;
}
-
+ DELETE_IF_NOT_NULL(okey);
unc_key_type_t ikey_type = ikey->get_key_type();
if (ikey_type != UNC_KT_VBRIF_FLOWFILTER) {
UPLL_LOG_DEBUG(" Invalid key type received. Key type - %d", ikey_type);
SET_USER_DATA(okey, ikey);
return UPLL_RC_SUCCESS;
}
+
+upll_rc_t VbrIfFlowFilterMoMgr::DeleteChildrenPOM(
+ ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+
+ if (NULL == ikey || NULL == dmi) {
+ UPLL_LOG_DEBUG("Delete Operation failed:Bad request");
+ return result_code;
+ }
+ // Read the DB get the flowlist value and send the delete request to
+ // flowlist momgr if flowlist is configured.
+
+ ConfigKeyVal *tempckv = NULL;
+ result_code = GetChildConfigKey(tempckv, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ return result_code;
+ }
+ result_code = UpdateConfigDB(tempckv, dt_type, UNC_OP_DELETE, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(tempckv);
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("UPLL_RC_ERR_NO_SUCH_INSTANCE");
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("DeleteMo record Err in vtnpolicingmaptbl (%d)",
+ result_code);
+ return result_code;
+ }
+ delete tempckv;
+ tempckv = NULL;
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VbrIfFlowFilterMoMgr::SetValidAudit(ConfigKeyVal *&ikey) {
+ UPLL_FUNC_TRACE;
+ val_flowfilter_t *val = reinterpret_cast<val_flowfilter_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_flowfilter_t)));
+ val->cs_row_status = UNC_CS_APPLIED;
+ ikey->AppendCfgVal(IpctSt::kIpcStValFlowfilter, val);
+ return UPLL_RC_SUCCESS;
+}
+
+bool VbrIfFlowFilterMoMgr::FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op) {
+ UPLL_FUNC_TRACE;
+ if (op != UNC_OP_CREATE)
+ return true;
+ return false;
+}
} // namespace kt_momgr
} // namespace upll
} // namespace unc
* @brief Member Variable for VbrIfFlowfilterMainTblBindInfo.
*/
static BindInfo vbr_if_flowfiltermaintbl_bind_info[];
-
+ uint32_t cur_instance_count;
public:
/**
* @brief VbrIfFlowFilterMoMgr Class Constructor.
* @retval UPLL_RC_SUCCESS Successfull completion.
* @retval UPLL_RC_ERR_GENERIC Returned Generic Error.
*/
- upll_rc_t GetRenamedControllerKey(ConfigKeyVal *&ikey,
+ upll_rc_t GetRenamedControllerKey(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
controller_domain *ctrlr_dom = NULL);
upll_rc_t SetVlinkPortmapConfiguration(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
- DalDmlIntf *dmi, InterfacePortMapInfo flag);
+ DalDmlIntf *dmi, InterfacePortMapInfo flag,
+ unc_keytype_operation_t oper);
upll_rc_t TxUpdateController(unc_key_type_t keytype,
uint32_t session_id,
upll_rc_t ConstructReadDetailResponse(ConfigKeyVal *ikey,
ConfigKeyVal *drv_resp_ckv,
- upll_keytype_datatype_t dt_type,
- unc_keytype_operation_t op,
- DbSubOp dbop,
- DalDmlIntf *dmi,
ConfigKeyVal** okey);
upll_rc_t GetControllerDomainID(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi);
+
+ upll_rc_t CreateAuditMoImpl(unc::upll::ipc_util::ConfigKeyVal*, unc::upll::dal::DalDmlIntf*, const char*);
+ upll_rc_t AuditUpdateController(unc_key_type_t keytype,
+ const char *ctrlr_id,
+ uint32_t session_id,
+ uint32_t config_id,
+ uuc::UpdateCtrlrPhase phase,
+ bool *ctrlr_affected,
+ DalDmlIntf *dmi);
+
+ upll_rc_t DeleteChildrenPOM(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi);
+
+ upll_rc_t SetValidAudit(ConfigKeyVal *&ikey);
+
+ bool FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op);
+
+ upll_rc_t SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req);
};
} // namespace kt_momgr
} // namespace upll
#define UPLL_VLAN_UNTAGGED 0
#define UPLL_VLAN_TAGGED 1
-
BindInfo VbrIfMoMgr::vbr_if_bind_info[] = {
{ uudst::vbridge_interface::kDbiVtnName, CFG_KEY, offsetof(
key_vbr_if, vbr_key.vtn_key.vtn_name),
{ uudst::vbridge_interface::kDbiFlags, CK_VAL, offsetof(
key_user_data_t, flags),
uud::kDalUint8, 1 },
- { uudst::vbridge_interface::kDbiValidAdminStatus, CFG_META_VAL, offsetof(
+ { uudst::vbridge_interface::kDbiValidAdminStatus, CFG_DEF_VAL, offsetof(
val_vbr_if, valid[UPLL_IDX_ADMIN_STATUS_VBRI]),
uud::kDalUint8, 1 },
{ uudst::vbridge_interface::kDbiValidDesc, CFG_META_VAL, offsetof(
{ uudst::vbridge_interface::kDbiValidTagged, CFG_META_VAL, offsetof(
val_vbr_if, portmap.valid[UPLL_IDX_TAGGED_PM]),
uud::kDalUint8, 1 },
+ { uudst::vbridge_interface::kDbiValidVexName, CFG_META_VAL, offsetof(
+ val_drv_vbr_if, valid[PFCDRV_IDX_VEXT_NAME_VBRIF]),
+ uud::kDalUint8, 1 },
+ { uudst::vbridge_interface::kDbiValidVexIfName, CFG_META_VAL, offsetof(
+ val_drv_vbr_if, valid[PFCDRV_IDX_VEXTIF_NAME_VBRIF]),
+ uud::kDalUint8, 1 },
+ { uudst::vbridge_interface::kDbiValidVexLinkName, CFG_META_VAL, offsetof(
+ val_drv_vbr_if, valid[PFCDRV_IDX_VLINK_NAME_VBRIF]),
+ uud::kDalUint8, 1 },
{ uudst::vbridge_interface::kDbiValidOperStatus, ST_META_VAL, offsetof(
val_db_vbr_if_st, vbr_if_val_st.valid[UPLL_IDX_OPER_STATUS_VBRS]),
uud::kDalUint8, 1 },
{ uudst::vbridge_interface::kDbiCsDesc, CS_VAL, offsetof(
val_vbr_if, cs_attr[UPLL_IDX_DESC_VBRI]),
uud::kDalUint8, 1 },
- { uudst::vbridge_interface::kDbiCsPortMap, CFG_META_VAL, offsetof(
- val_vbr_if, portmap.cs_attr[UPLL_IDX_PM_VBRI]),
+ { uudst::vbridge_interface::kDbiCsPortMap, CS_VAL, offsetof(
+ val_vbr_if, cs_attr[UPLL_IDX_PM_VBRI]),
uud::kDalUint8, 1 },
{ uudst::vbridge_interface::kDbiCsLogicalPortId, CS_VAL, offsetof(
val_vbr_if, portmap.cs_attr[UPLL_IDX_LOGICAL_PORT_ID_PM]),
UPLL_LOG_ERROR("Validation Message is Failed ");
return result_code;
}
+#if 0
+ controller_domain ctrlr_dom;
+ ctrlr_dom.ctrlr = ctrlr_dom.domain = NULL;
+ ConfigKeyVal *temp_ck = NULL;
+ result_code = GetParentConfigKey(temp_ck, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_ERROR("Error in retrieving the Parent ConfigKeyVal");
+ delete temp_ck;
+ return result_code;
+ }
+ result_code = GetControllerDomainId(temp_ck, req->datatype, &ctrlr_dom, dmi);
+ UPLL_LOG_INFO("GetControllerDomainId result code is: %d", result_code);
+ if ((result_code != UPLL_RC_SUCCESS) || (ctrlr_dom.ctrlr == NULL)
+ || (ctrlr_dom.domain == NULL)) {
+ UPLL_LOG_INFO("Invalid ctrlr/domain");
+ return UPLL_RC_ERR_GENERIC;
+ }
+#else
+ controller_domain ctrlr_dom;
+ ctrlr_dom.ctrlr = ctrlr_dom.domain = NULL;
+ ConfigKeyVal *temp_ck = NULL;
+ result_code = GetChildConfigKey(temp_ck, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_ERROR("Error in retrieving the Child ConfigKeyVal");
+ delete temp_ck;
+ return result_code;
+ }
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain };
+ result_code = ReadConfigDB(temp_ck, req->datatype, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("ReadConfigDB Failed %d", result_code);
+ delete temp_ck;
+ return result_code;
+ }
+ GET_USER_DATA_CTRLR_DOMAIN(temp_ck, ctrlr_dom);
+ SET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+#endif
+ result_code = ValidateCapability(
+ req, ikey, reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Validate Capability is Failed. Error_code : %d",
+ result_code);
+ delete temp_ck;
+ return result_code;
+ }
+#if 0
result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_READ, dmi, MAINTBL);
if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code) {
UPLL_LOG_ERROR("Record does Not Exists");
return result_code;
}
+#endif
+ delete temp_ck;
result_code = DupConfigKeyVal(okey, ikey, MAINTBL);
- if (UPLL_RC_SUCCESS != result_code) {
+ if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG(" DupConfigKeyVal Failed %d", result_code);
return result_code;
}
- result_code = ValidateAttribute(okey, dmi,req);
+ val_drv_vbr_if *valif = reinterpret_cast<val_drv_vbr_if *>
+ (ConfigKeyVal::Malloc(sizeof(val_drv_vbr_if)));
+ void *ifval = GetVal(ikey);
+ memcpy(&(valif->vbr_if_val), ifval, sizeof(val_vbr_if));
+ (okey->get_cfg_val())->SetVal(IpctSt::kIpcStPfcdrvValVbrIf, valif);
+
+ result_code = ValidateAttribute(okey, dmi, req);
if (UPLL_RC_SUCCESS != result_code) {
delete okey;
UPLL_LOG_ERROR("Validate Attribute is Failed");
return result_code;
}
+
result_code = UpdateConfigVal(okey, req->datatype, dmi);
if (UPLL_RC_SUCCESS != result_code) {
delete okey;
UPLL_LOG_DEBUG("UpdateConfigVal is Failed");
- return UPLL_RC_ERR_GENERIC;
+ return result_code;
}
- DbSubOp dbop = { kOpNotRead, kOpMatchNone, kOpInOutNone };
+ DbSubOp dbop1 = { kOpNotRead, kOpMatchNone, kOpInOutNone };
UPLL_LOG_DEBUG("The okey Structue before update %s", (okey->ToStrAll()).c_str());
result_code = UpdateConfigDB(okey, req->datatype, UNC_OP_UPDATE,
- dmi, &dbop, MAINTBL);
+ dmi, &dbop1, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
delete okey;
UPLL_LOG_ERROR("Updation Failure in DB : %d", result_code);
return result_code;
}
-upll_rc_t VbrIfMoMgr::CreateAuditMoImpl(IpcReqRespHeader *header,
- ConfigKeyVal *ikey, DalDmlIntf *dmi,
+upll_rc_t VbrIfMoMgr::CreateAuditMoImpl(ConfigKeyVal *ikey, DalDmlIntf *dmi,
const char *ctrlr_id) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *ck_ifkey = NULL;
ConfigKeyVal *ck_vlink = NULL;
- result_code = VnodeChildMoMgr::CreateAuditMoImpl(ikey,dmi,ctrlr_id);
- if(result_code != UPLL_RC_SUCCESS) {
- string s(ikey->ToStrAll());
- UPLL_LOG_INFO("Create Audit Vbrif failed %s",s.c_str());
- return UPLL_RC_ERR_GENERIC;
- }
result_code = GetChildConfigKey(ck_ifkey, ikey);
- if(result_code != UPLL_RC_SUCCESS || ck_ifkey == NULL) {
- UPLL_LOG_INFO("GetChildConfigKey failed err_code %d",result_code);
+ if (result_code != UPLL_RC_SUCCESS || ck_ifkey == NULL) {
+ UPLL_LOG_INFO("GetChildConfigKey failed err_code %d", result_code);
return UPLL_RC_ERR_GENERIC;
}
vn_if_type iftype;
UPLL_LOG_DEBUG("Invalid Mgr");
return UPLL_RC_ERR_GENERIC;
}
- result_code = mgr->CheckIfMemberOfVlink(ck_ifkey,UPLL_DT_RUNNING,
- ck_vlink,dmi,iftype);
- if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ result_code = mgr->CheckIfMemberOfVlink(ck_ifkey, UPLL_DT_RUNNING,
+ ck_vlink, dmi, iftype);
+ if ((result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) ||
+ ((iftype == kVlinkInternalNode1) || (iftype == kVlinkInternalNode2))) {
delete ck_ifkey;
if (ck_vlink) delete ck_vlink;
UPLL_LOG_DEBUG("Internal link interface");
- return UPLL_RC_SUCCESS;
+ result_code = VnodeChildMoMgr::CreateAuditMoImpl(ikey, dmi, ctrlr_id);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("Create Audit Vbrif failed %s", (ikey->ToStrAll()).c_str());
+ }
+ return result_code;
} else if (result_code != UPLL_RC_SUCCESS) {
delete ck_ifkey;
if (ck_vlink) delete ck_vlink;
- UPLL_LOG_INFO("Error in reading vlink key %d",result_code);
+ UPLL_LOG_INFO("Error in reading vlink key %d", result_code);
return UPLL_RC_ERR_GENERIC;
- } else if ((iftype == kVlinkInternalNode1) ||
- (iftype == kVlinkInternalNode2)) {
- UPLL_LOG_DEBUG("Internal link interface");
- delete ck_ifkey;
- if (ck_vlink) delete ck_vlink;
- return UPLL_RC_SUCCESS;
}
val_vlink *vlink_val = reinterpret_cast<val_vlink *>(GetVal(ck_vlink));
if (vlink_val == NULL) return UPLL_RC_ERR_GENERIC;
DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutFlag};
result_code = ReadConfigDB(ck_ifkey, UPLL_DT_RUNNING, UNC_OP_READ,
dbop, dmi, MAINTBL);
- if(result_code != UPLL_RC_SUCCESS) {
+ if (result_code != UPLL_RC_SUCCESS) {
delete ck_ifkey;
UPLL_LOG_INFO("Retrieving a Record for VbrIf in RUNNING DB failed");
return result_code;
}
- void *db_val,*drv_val = GetVal(ikey) ;
+ void *db_val, *drv_val = GetVal(ikey) ;
db_val = GetVal(ck_ifkey);
- if (!db_val || !drv_val)
+ if (!db_val || !drv_val) {
+ delete ck_ifkey;
return UPLL_RC_ERR_GENERIC;
+ }
+
//validate params of running against those received from driver
- if (memcmp(db_val,drv_val,sizeof(val_drv_vbr_if)) == 0) {
+ val_port_map vbr_db_portmap = (reinterpret_cast<val_drv_vbr_if*>(db_val))->vbr_if_val.portmap;
+ val_port_map *vbr_drv_portmap = &((reinterpret_cast<val_drv_vbr_if*>(drv_val))->vbr_if_val.portmap);
+ bool portid_equal = (vbr_db_portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] ==
+ vbr_drv_portmap->valid[UPLL_IDX_LOGICAL_PORT_ID_PM]);
+
+ // to be uncommented when driver stops translating from no-vlan-id to 65535 as it
+ // cannot distingish between boundary vlinked / regular mapped vbrifs
+ if (vbr_drv_portmap->valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_INVALID) {
+ vbr_drv_portmap->vlan_id = 0xFFFF;
+ vbr_drv_portmap->valid[UPLL_IDX_VLAN_ID_PM] = UNC_VF_VALID;
+ }
+
+ if (portid_equal &&
+ (vbr_db_portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] == UNC_VF_VALID)) {
+ portid_equal = (strcmp(reinterpret_cast<char*>(vbr_db_portmap.logical_port_id),
+ reinterpret_cast<char*>(vbr_drv_portmap->logical_port_id)) == 0);
+ }
+ bool vlanid_equal = (vbr_db_portmap.valid[UPLL_IDX_VLAN_ID_PM] ==
+ vbr_drv_portmap->valid[UPLL_IDX_VLAN_ID_PM]);
+ if (vlanid_equal &&
+ (vbr_db_portmap.valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID)) {
+ vlanid_equal = (vbr_db_portmap.vlan_id == vbr_drv_portmap->vlan_id);
+ }
+ bool tagged_equal = (vbr_db_portmap.valid[UPLL_IDX_TAGGED_PM] ==
+ vbr_drv_portmap->valid[UPLL_IDX_TAGGED_PM]);
+ if (tagged_equal &&
+ (vbr_db_portmap.valid[UPLL_IDX_TAGGED_PM] == UNC_VF_VALID)) {
+ tagged_equal = (vbr_db_portmap.tagged == vbr_drv_portmap->tagged);
+ }
+
// create boundary vlink
+ if (portid_equal && vlanid_equal && tagged_equal) {
result_code = mgr->UpdateConfigDB(ck_vlink, UPLL_DT_AUDIT,
UNC_OP_CREATE, dmi, MAINTBL);
- if(result_code != UPLL_RC_SUCCESS) {
+ if (result_code != UPLL_RC_SUCCESS) {
delete ck_ifkey;
delete ck_vlink;
UPLL_LOG_INFO("Retrieving a Record for VbrIf in RUNNING DB failed");
return result_code;
}
} else {
- delete ck_ifkey;
- delete ck_vlink;
- UPLL_LOG_INFO("Invalid data");
- return UPLL_RC_ERR_GENERIC;
+ UPLL_LOG_INFO("Boundary data does not match");
}
}
+ result_code = VnodeChildMoMgr::CreateAuditMoImpl(ikey, dmi, ctrlr_id);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("Create Audit Vbrif failed %s", (ikey->ToStrAll()).c_str());
+ return UPLL_RC_ERR_GENERIC;
+ }
delete ck_ifkey;
delete ck_vlink;
return UPLL_RC_SUCCESS;
return result_code;
}
-upll_rc_t VbrIfMoMgr::updateVbrIf(IpcReqRespHeader *req,
+upll_rc_t VbrIfMoMgr::updateVbrIf (IpcReqRespHeader *req,
ConfigKeyVal *ikey,
DalDmlIntf *dmi) {
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *ck_drv_vbr_if = NULL;
-
+#if 0
result_code = GetVbrIfValfromDB(ikey, ck_drv_vbr_if, UPLL_DT_RUNNING, dmi);
+#endif
key_vbr_if *temp_vbr_if_key = reinterpret_cast<key_vbr_if *>(ikey->get_key());
- key_vbr_if *vbr_if_key = reinterpret_cast<key_vbr_if *>(malloc(
+ key_vbr_if *vbr_if_key = reinterpret_cast<key_vbr_if *>(ConfigKeyVal::Malloc(
sizeof(key_vbr_if)));
uuu::upll_strncpy(vbr_if_key->if_name, temp_vbr_if_key->if_name,
(kMaxLenInterfaceName + 1));
UPLL_FUNC_TRACE;
std::string if_name = reinterpret_cast<const char *>(
reinterpret_cast<key_vbr_if*>(ck_port_map->get_key())->if_name);
- if (strlen(if_name.c_str()) >= 18)
- if_name.assign(if_name.c_str(), 18);
-
- std::string vex_name = "vx_" + if_name + static_cast<std::ostringstream*>(
- &(std::ostringstream() << time(NULL)) )->str();
- std::string vex_if_name = "vi_" + if_name + static_cast<std::ostringstream*>(
- &(std::ostringstream() << time(NULL)) )->str();
- std::string vex_link_name = "vl_" + if_name + static_cast<std::ostringstream*>(
- &(std::ostringstream() << time(NULL)) )->str();
+ if (strlen(if_name.c_str()) >= 10) {
+ if_name.erase(10);
+ }
+
+ struct timeval _timeval;
+ struct timezone _timezone;
+ gettimeofday(&_timeval, &_timezone);
+
+ std::stringstream ss;
+ ss << if_name << _timeval.tv_sec << _timeval.tv_usec;
+ std::string unique_id = ss.str();
+ std::string vex_name("vx_");
+ vex_name += unique_id;
+ std::string vex_if_name("vi_");
+ vex_if_name += unique_id;
+ std::string vex_link_name("vl_");
+ vex_link_name += unique_id;
+
val_drv_vbr_if *drv_vbr_if_val = reinterpret_cast<val_drv_vbr_if *>
(GetVal(ck_port_map));
- drv_vbr_if_val->valid[UPLL_IDX_VBR_IF_DRV_PM] = UNC_VF_VALID;
- drv_vbr_if_val->valid[UPLL_IDX_VEXT_DRV_PM] = UNC_VF_VALID;
+ drv_vbr_if_val->valid[PFCDRV_IDX_VAL_VBRIF] = UNC_VF_VALID;
+ drv_vbr_if_val->valid[PFCDRV_IDX_VEXT_NAME_VBRIF] = UNC_VF_VALID;
uuu::upll_strncpy(drv_vbr_if_val->vex_name, vex_name.c_str(),
(kMaxLenVnodeName+1));
- drv_vbr_if_val->valid[UPLL_IDX_VEXT_IF_DRV_PM] = UNC_VF_VALID;
+ drv_vbr_if_val->valid[PFCDRV_IDX_VEXTIF_NAME_VBRIF] = UNC_VF_VALID;
uuu::upll_strncpy(drv_vbr_if_val->vex_if_name, vex_if_name.c_str(),
(kMaxLenVnodeName + 1));
- drv_vbr_if_val->valid[UPLL_IDX_VEXT_LINK_DRV_PM] = UNC_VF_VALID;
+ drv_vbr_if_val->valid[PFCDRV_IDX_VLINK_NAME_VBRIF] = UNC_VF_VALID;
uuu::upll_strncpy(drv_vbr_if_val->vex_link_name, vex_link_name.c_str(),
(kMaxLenVnodeName + 1));
return UPLL_RC_SUCCESS;
bool VbrIfMoMgr::IsValidKey(void *key, uint64_t index) {
UPLL_FUNC_TRACE;
key_vbr_if *if_key = reinterpret_cast<key_vbr_if *>(key);
- bool ret_val = UPLL_RC_SUCCESS;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
switch (index) {
case uudst::vbridge_interface::kDbiVtnName:
ret_val = ValidateKey(
upll_rc_t VbrIfMoMgr::GetChildConfigKey(ConfigKeyVal *&okey,
ConfigKeyVal *parent_key) {
UPLL_FUNC_TRACE;
+ bool cfgval_ctrlr = false;
upll_rc_t result_code = UPLL_RC_SUCCESS;
key_vbr_if *vbr_key_if;
void *pkey;
if (parent_key == NULL) {
vbr_key_if = reinterpret_cast<key_vbr_if_t *>
(ConfigKeyVal::Malloc(sizeof(key_vbr_if_t)));
+ if (okey) delete okey;
okey = new ConfigKeyVal(UNC_KT_VBR_IF, IpctSt::kIpcStKeyVbrIf, vbr_key_if,
NULL);
return UPLL_RC_SUCCESS;
uint8_t flags = 0;
val_vlink *vlink_val = reinterpret_cast<val_vlink *>(GetVal(parent_key));
if (!vlink_val) {
- free(vbr_key_if);
+ if (!okey || !(okey->get_key()))
+ free(vbr_key_if);
return UPLL_RC_ERR_GENERIC;
}
GET_USER_DATA_FLAGS(parent_key->get_cfg_val(), flags);
flags &= VLINK_FLAG_NODE_POS;
- UPLL_LOG_DEBUG("Vlink flag node position %d",flags);
+ UPLL_LOG_DEBUG("Vlink flag node position %d", flags);
if (flags == kVlinkVnode2) {
+ cfgval_ctrlr = true;
vnode_name = vlink_val->vnode2_name;
if_name = vlink_val->vnode2_ifname;
} else {
if (!okey)
okey = new ConfigKeyVal(UNC_KT_VBR_IF, IpctSt::kIpcStKeyVbrIf, vbr_key_if,
NULL);
+ else if (okey->get_key() != vbr_key_if)
+ okey->SetKey(IpctSt::kIpcStKeyVbrIf, vbr_key_if);
+
if (okey == NULL) {
free(vbr_key_if);
result_code = UPLL_RC_ERR_GENERIC;
} else {
- SET_USER_DATA(okey, parent_key);
+ if (cfgval_ctrlr) {
+ SET_USER_DATA(okey, parent_key->get_cfg_val());
+ } else {
+ SET_USER_DATA(okey, parent_key);
+ }
}
return result_code;
}
key_vbr_if *pkey = reinterpret_cast<key_vbr_if *>
(ikey->get_key());
if (!pkey) return UPLL_RC_ERR_GENERIC;
- key_vbr *vbr_key = reinterpret_cast<key_vbr *>(malloc(sizeof(key_vbr)));
- if (!vbr_key) return UPLL_RC_ERR_GENERIC;
- memset(vbr_key, 0, sizeof(key_vbr));
-#if 1
+ key_vbr *vbr_key = reinterpret_cast<key_vbr *>(ConfigKeyVal::Malloc
+ (sizeof(key_vbr)));
uuu::upll_strncpy(vbr_key->vtn_key.vtn_name,
reinterpret_cast<key_vbr_if *>(pkey)->vbr_key.vtn_key.vtn_name,
(kMaxLenVtnName+1));
uuu::upll_strncpy(vbr_key->vbridge_name,
reinterpret_cast<key_vbr_if *>(pkey)->vbr_key.vbridge_name,
(kMaxLenVnodeName+1));
-#endif
if (okey) delete okey;
okey = new ConfigKeyVal(UNC_KT_VBRIDGE, IpctSt::kIpcStKeyVbr, vbr_key, NULL);
if (okey == NULL) {
if (ck_val != NULL) return UPLL_RC_ERR_GENERIC;
switch (tbl) {
case MAINTBL:
- val = reinterpret_cast<void *>(malloc(sizeof(val_drv_vbr_if)));
- if (!val) return UPLL_RC_ERR_GENERIC;
- memset(val, 0, sizeof(val_drv_vbr_if));
+ val = reinterpret_cast<void *>(ConfigKeyVal::Malloc(
+ sizeof(val_drv_vbr_if)));
ck_val = new ConfigVal(IpctSt::kIpcStPfcdrvValVbrIf, val);
if (dt_type == UPLL_DT_STATE) {
- val = reinterpret_cast<void *>(malloc(sizeof(val_db_vbr_if_st)));
- memset(val, 0, sizeof(val_db_vbr_if_st));
+ val = reinterpret_cast<void *>(ConfigKeyVal::Malloc(
+ sizeof(val_db_vbr_if_st)));
ConfigVal *ck_nxtval = new ConfigVal(IpctSt::kIpcStValVbrIfSt, val);
ck_val->AppendCfgVal(ck_nxtval);
}
if ((req->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVbrIf) {
val_vbr_if *ival = reinterpret_cast<val_vbr_if *>(GetVal(req));
if (!ival) return UPLL_RC_ERR_GENERIC;
- val_vbr_if *vbr_val_if = reinterpret_cast<val_vbr_if *>(malloc(
- sizeof(val_vbr_if)));
- if (!vbr_val_if) return UPLL_RC_ERR_GENERIC;
+ val_vbr_if *vbr_val_if = reinterpret_cast<val_vbr_if *>(
+ ConfigKeyVal::Malloc(sizeof(val_vbr_if)));
memcpy(vbr_val_if, ival, sizeof(val_vbr_if));
oval = reinterpret_cast<void *>(vbr_val_if);
} else {
val_drv_vbr_if *ival = reinterpret_cast<val_drv_vbr_if *>(GetVal(req));
if (!ival) return UPLL_RC_ERR_GENERIC;
- val_drv_vbr_if *vbr_val_if = reinterpret_cast<val_drv_vbr_if *>(malloc(
- sizeof(val_drv_vbr_if)));
- if (!vbr_val_if) return UPLL_RC_ERR_GENERIC;
+ val_drv_vbr_if *vbr_val_if = reinterpret_cast<val_drv_vbr_if *>(
+ ConfigKeyVal::Malloc(sizeof(val_drv_vbr_if)));
memcpy(vbr_val_if, ival, sizeof(val_drv_vbr_if));
oval = reinterpret_cast<void *>(vbr_val_if);
}
if (tmp) {
if (tbl == MAINTBL) {
void *ovalst;
- if ((req->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVbrIfSt) {
- val_vbr_if_st *ival = reinterpret_cast<val_vbr_if_st *>(tmp->get_val());
- val_vbr_if_st *val_vbr_if = reinterpret_cast<val_vbr_if_st *>(malloc(
- sizeof(val_vbr_if_st)));
- memcpy(val_vbr_if, ival, sizeof(val_vbr_if_st));
- ovalst = reinterpret_cast<void *>(val_vbr_if);
- } else {
- val_db_vbr_if_st *ival =
+ val_db_vbr_if_st *ival =
reinterpret_cast<val_db_vbr_if_st *>(tmp->get_val());
- val_db_vbr_if_st *val_vbr_if =
- reinterpret_cast<val_db_vbr_if_st *>(malloc(
- sizeof(val_db_vbr_if_st)));
- memcpy(val_vbr_if, ival, sizeof(val_db_vbr_if_st));
- ovalst = reinterpret_cast<void *>(val_vbr_if);
+ if (ival == NULL) {
+ DELETE_IF_NOT_NULL(tmp1);
+ return UPLL_RC_ERR_GENERIC;
}
+ val_db_vbr_if_st *val_vbr_if =
+ reinterpret_cast<val_db_vbr_if_st *>(ConfigKeyVal::Malloc(
+ sizeof(val_db_vbr_if_st)));
+ memcpy(val_vbr_if, ival, sizeof(val_db_vbr_if_st));
+ ovalst = reinterpret_cast<void *>(val_vbr_if);
ConfigVal *tmp2 = new ConfigVal(
req->get_cfg_val()->get_next_cfg_val()->get_st_num(), ovalst);
tmp1->AppendCfgVal(tmp2);
}
}
- void *tkey = (req != NULL) ? (req)->get_key() : NULL;
+ void *tkey = (req)->get_key();
key_vbr_if *ikey = reinterpret_cast<key_vbr_if *>(tkey);
- key_vbr_if *vbr_if_key = reinterpret_cast<key_vbr_if *>(malloc(
+ key_vbr_if *vbr_if_key = reinterpret_cast<key_vbr_if *>(ConfigKeyVal::Malloc(
sizeof(key_vbr_if)));
if (!vbr_if_key) {
UPLL_LOG_DEBUG(" Memory allocation failed");
memcpy(vbr_if_key, ikey, sizeof(key_vbr_if));
okey = new ConfigKeyVal(UNC_KT_VBR_IF, IpctSt::kIpcStKeyVbrIf, vbr_if_key,
tmp1);
- if (okey) SET_USER_DATA(okey, req);
+ if (okey) {
+ SET_USER_DATA(okey, req);
+ } else {
+ DELETE_IF_NOT_NULL(tmp1);
+ FREE_IF_NOT_NULL(vbr_if_key);
+ }
return UPLL_RC_SUCCESS;
}
val_vbr_if_t *vbr_if_val = &vbrif_val->vbr_if_val;
bool port_map_change = false;
switch (op) {
- case UNC_OP_UPDATE:
+ case UNC_OP_UPDATE:
{
void *val = reinterpret_cast<void *>(vbrif_val);
+ val_drv_vbr_if_t *vbrif_val2 = reinterpret_cast<val_drv_vbr_if_t *>
+ (GetVal(upd_key));
+#if 0
+ if (vbr_if_val->valid[UPLL_IDX_PM_VBRI] == UNC_VF_VALID
+ && vbrif_val2->vbr_if_val.valid[UPLL_IDX_PM_VBRI] != UNC_VF_VALID)
+ port_map_change = true;
+#else
+ if (vbr_if_val->valid[UPLL_IDX_PM_VBRI] !=
+ vbrif_val2->vbr_if_val.valid[UPLL_IDX_PM_VBRI])
+ port_map_change = true;
+#endif
CompareValidValue(val, GetVal(upd_key), true);
- if ((vbr_if_val->valid[UPLL_IDX_PM_VBRI] == UNC_VF_VALID) &&
- (vbr_if_val->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] ==
- UNC_VF_VALID))
+ if (vbr_if_val->valid[UPLL_IDX_ADMIN_STATUS_VBRI] != UNC_VF_INVALID)
port_map_change = true;
+ uint8_t cand_flag = 0, run_flag = 0;
+ GET_USER_DATA_FLAGS(ikey, cand_flag);
+ GET_USER_DATA_FLAGS(upd_key, run_flag);
+ if ((cand_flag & VIF_TYPE) != (run_flag & VIF_TYPE))
+ port_map_change = true;
+ UPLL_LOG_DEBUG("ikey flags %d upd_key flags %d %d", cand_flag, run_flag,
+ port_map_change);
}
/* fall through intended */
- case UNC_OP_CREATE:
+ case UNC_OP_CREATE:
if (op == UNC_OP_CREATE) {
vbr_if_val->cs_row_status = cs_status;
port_map_change = true;
val_db_vbr_if_st *vbr_if_valst = reinterpret_cast<val_db_vbr_if_st *>
(ConfigKeyVal::Malloc(sizeof(val_db_vbr_if_st)));
ikey->AppendCfgVal(IpctSt::kIpcStValVbrIfSt, vbr_if_valst);
- upll_rc_t result_code = InitOperStatus<val_vbr_if_st,val_db_vbr_if_st>
- (ikey,vbr_if_val->valid[UPLL_IDX_ADMIN_STATUS_VBRI],
+ UPLL_LOG_DEBUG("valid %d admin %d op %d",
+ vbr_if_val->valid[UPLL_IDX_ADMIN_STATUS_VBRI],
+ vbr_if_val->admin_status, op);
+#if 0
+ if (vbr_if_val->valid[UPLL_IDX_ADMIN_STATUS_VBRI] != UNC_VF_INVALID) {
+ val_vbr_if_st *vnif_st = &(reinterpret_cast<val_db_vbr_if_st *>
+ (GetStateVal(ikey))->vbr_if_val_st);
+ vnif_st->oper_status = UPLL_OPER_STATUS_UNINIT;
+ }
+ upll_rc_t result_code = InitOperStatus<val_vbr_if_st, val_db_vbr_if_st>
+ (ikey, vbr_if_val->valid[UPLL_IDX_ADMIN_STATUS_VBRI],
vbr_if_val->admin_status,
vbr_if_val->valid[UPLL_IDX_PM_VBRI],
&vbr_if_val->portmap);
- vbr_if_valst->down_count = 0;
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Error settiing oper status");
return UPLL_RC_ERR_GENERIC;
}
+#else
+ val_vbr_if_st *vnif_st = &(reinterpret_cast<val_db_vbr_if_st *>
+ (GetStateVal(ikey))->vbr_if_val_st);
+ vnif_st->oper_status = UPLL_OPER_STATUS_UNINIT;
+ vnif_st->valid[UPLL_IDX_OPER_STATUS_VRTS] = UNC_VF_VALID;
+#endif
+ if (op == UNC_OP_CREATE)
+ vbr_if_valst->down_count = 0;
+ else {
+ val_db_vbr_if_st *run_vbrifst = reinterpret_cast<val_db_vbr_if_st *>
+ (GetStateVal(upd_key));
+ vbr_if_valst->down_count = (run_vbrifst ? run_vbrifst->down_count:0);
+ }
}
break;
default:
- UPLL_LOG_DEBUG("Invalid op %d\n",op);
+ UPLL_LOG_DEBUG("Invalid op %d", op);
return UPLL_RC_ERR_GENERIC;
}
- for (unsigned int loop = 0; loop <
+ UPLL_LOG_TRACE("%s", (ikey->ToStrAll()).c_str());
+ val_vbr_if *vbr_if_val2 = reinterpret_cast<val_vbr_if *>(GetVal(upd_key));
+ if (UNC_OP_UPDATE == op) {
+ UPLL_LOG_TRACE("%s", (upd_key->ToStrAll()).c_str());
+ vbr_if_val->cs_row_status = vbr_if_val2->cs_row_status;
+ }
+ for (unsigned int loop = 0; loop <
sizeof(vbr_if_val->valid) / sizeof(vbr_if_val->valid[0]); ++loop) {
- if (UNC_VF_NOT_SOPPORTED == vbr_if_val->valid[loop]) {
- vbr_if_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
- } else if ((UNC_VF_VALID == (uint8_t) vbr_if_val->valid[loop])
+ if ((UNC_VF_VALID == (uint8_t) vbr_if_val->valid[loop])
|| (UNC_VF_VALID_NO_VALUE == (uint8_t) vbr_if_val->valid[loop])) {
- vbr_if_val->cs_attr[loop] = cs_status;
+ // Description is set to APPLIED
+ if (loop == UPLL_IDX_DESC_VBRI)
+ vbr_if_val->cs_attr[loop] = UNC_CS_APPLIED;
+ else
+ vbr_if_val->cs_attr[loop] = cs_status;
+ } else if ((UNC_VF_INVALID == vbr_if_val->valid[loop]) &&
+ (UNC_OP_UPDATE == op)) {
+ vbr_if_val->cs_attr[loop] = vbr_if_val2->cs_attr[loop];
+ } else if ((UNC_VF_INVALID == vbr_if_val->valid[loop]) &&
+ (UNC_OP_CREATE == op)) {
+ vbr_if_val->cs_attr[loop] = UNC_CS_APPLIED;
+ }
+ }
+ val_port_map *pm = &vbr_if_val->portmap;
+ for (unsigned int loop = 0; loop < sizeof(pm->valid) / sizeof(pm->valid[0]);
+ ++loop) {
+ if ((UNC_VF_VALID == (uint8_t) pm->valid[loop])
+ || (UNC_VF_VALID_NO_VALUE == (uint8_t) pm->valid[loop])) {
+ pm->cs_attr[loop] = cs_status;
+ } else if ((UNC_VF_INVALID == pm->valid[loop]) &&
+ (UNC_OP_UPDATE == op)) {
+ pm->cs_attr[loop] = vbr_if_val2->portmap.cs_attr[loop];
+ } else if ((UNC_VF_INVALID == pm->valid[loop]) &&
+ (UNC_OP_CREATE == op)) {
+ pm->cs_attr[loop] = UNC_CS_APPLIED;
}
}
return UPLL_RC_SUCCESS;
unc_keytype_configstatus_t cs_status,
uuc::UpdateCtrlrPhase phase,
ConfigKeyVal *&ckv_running) {
+ UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
val_vbr_if_t *val;
val =
}
if (uuc::kUpllUcpCreate == phase)
val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
for (unsigned int loop = 0; loop < sizeof(val->valid) / sizeof(uint8_t);
++loop) {
if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
cs_status == UNC_CS_APPLIED)
val->cs_attr[loop] = cs_status;
}
+ for (unsigned int loop = 0;
+ loop < sizeof(val->portmap.valid) / sizeof(uint8_t); ++loop) {
+ if ((cs_status == UNC_CS_INVALID &&
+ UNC_VF_VALID == val->portmap.valid[loop])
+ || cs_status == UNC_CS_APPLIED)
+ val->portmap.cs_attr[loop] = cs_status;
+ }
return result_code;
}
((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVtnNeighbor)) {
vtn_neighbor = reinterpret_cast<val_vtn_neighbor *>
(ikey->get_cfg_val()->get_val());
+ } else if ((ikey->get_cfg_val()) &&
+ ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStPfcdrvValVbrIf)) {
+ vbr_if_val = &(reinterpret_cast<val_drv_vbr_if *>(
+ ikey->get_cfg_val()->get_val())->vbr_if_val);
+ } else if ((ikey->get_cfg_val()) &&
+ (((ikey->get_cfg_val())->get_st_num() != IpctSt::kIpcStValVbrIf) ||
+ ((ikey->get_cfg_val())->get_st_num() != IpctSt::kIpcStValVtnNeighbor) ||
+ ((ikey->get_cfg_val())->get_st_num() != IpctSt::kIpcStPfcdrvValVbrIf))) {
+ UPLL_LOG_DEBUG("Invalid val structure received.received struct - %d",
+ ikey->get_cfg_val()->get_st_num());
+ return UPLL_RC_ERR_BAD_REQUEST;
}
if ((operation == UNC_OP_CREATE) && ((dt_type == UPLL_DT_CANDIDATE)
return UPLL_RC_SUCCESS;
}
UPLL_LOG_DEBUG("Error Unsupported datatype (%d) or operation - (%d)",
- dt_type,operation);
+ dt_type, operation);
return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
upll_rc_t VbrIfMoMgr::ValidateVbrIfValue(val_vbr_if *vbr_if_val,
unc_keytype_operation_t operation) {
UPLL_FUNC_TRACE;
- upll_rc_t ret_val = UPLL_RC_SUCCESS;
if (vbr_if_val->valid[UPLL_IDX_DESC_VBRI] == UNC_VF_VALID) {
- ret_val = ValidateDesc(reinterpret_cast<char *>(vbr_if_val->description),
- kMinLenDescription, kMaxLenDescription);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Description syntax check failed."
+ if (!ValidateDesc(vbr_if_val->description,
+ kMinLenDescription, kMaxLenDescription)) {
+ UPLL_LOG_DEBUG("Description syntax check failed."
"Received description - %s",
vbr_if_val->description);
return UPLL_RC_ERR_CFG_SYNTAX;
== UNC_VF_VALID_NO_VALUE)
&& (operation == UNC_OP_UPDATE || operation == UNC_OP_CREATE)) {
vbr_if_val->admin_status = UPLL_ADMIN_ENABLE;
+ } else if ((vbr_if_val->valid[UPLL_IDX_ADMIN_STATUS_VBRI] == UNC_VF_INVALID)
+ && (operation == UNC_OP_CREATE)) {
+ vbr_if_val->admin_status = UPLL_ADMIN_ENABLE;
+ vbr_if_val->valid[UPLL_IDX_ADMIN_STATUS_VBRI] = UNC_VF_VALID_NO_VALUE;
}
if (vbr_if_val->valid[UPLL_IDX_PM_VBRI] == UNC_VF_VALID) {
if (vbr_if_val->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM]
== UNC_VF_VALID) {
- ret_val = ValidateLogicalPortId(
+ if (!ValidateLogicalPortId(
reinterpret_cast<char *>(vbr_if_val->portmap.logical_port_id),
- kMinLenLogicalPortId, kMaxLenLogicalPortId);
- if (ret_val != UPLL_RC_SUCCESS) {
+ kMinLenLogicalPortId, kMaxLenLogicalPortId)) {
UPLL_LOG_DEBUG("Logical Port id syntax check failed."
"Received Logical Port Id - %s",
vbr_if_val->portmap.logical_port_id);
vbr_if_val->portmap.tagged);
return UPLL_RC_ERR_CFG_SYNTAX;
}
- } else if (vbr_if_val->portmap.valid[UPLL_IDX_TAGGED_PM]
- == UNC_VF_VALID_NO_VALUE
+ } else if (((vbr_if_val->portmap.valid[UPLL_IDX_TAGGED_PM]
+ == UNC_VF_VALID_NO_VALUE) ||
+ (vbr_if_val->portmap.valid[UPLL_IDX_TAGGED_PM]
+ == UNC_VF_INVALID))
&& (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE)) {
- vbr_if_val->portmap.tagged = UPLL_VLAN_UNTAGGED;
+ if (vbr_if_val->portmap.valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID) {
+ vbr_if_val->portmap.tagged = UPLL_VLAN_TAGGED;
+ } else {
+ vbr_if_val->portmap.tagged = UPLL_VLAN_UNTAGGED;
+ }
+ vbr_if_val->portmap.valid[UPLL_IDX_TAGGED_PM] = UNC_VF_VALID;
}
} else if ((vbr_if_val->valid[UPLL_IDX_PM_VBRI] == UNC_VF_VALID_NO_VALUE)
&& (operation == UNC_OP_UPDATE || operation == UNC_OP_CREATE)) {
ConfigKeyVal *ikey,
const char *ctrlr_name) {
UPLL_FUNC_TRACE;
- upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ upll_rc_t ret_val = UPLL_RC_ERR_GENERIC;
+
if (!ikey || !req ) {
UPLL_LOG_DEBUG("ConfigKeyVal / IpcReqRespHeader is Null");
return UPLL_RC_ERR_GENERIC;
}
- if (!ctrlr_name) ctrlr_name = reinterpret_cast<char *>(ikey->get_user_data());
-
- upll_keytype_datatype_t dt_type = req->datatype;
- unc_keytype_operation_t operation = req->operation;
- unc_keytype_option1_t option1 = req->option1;
- unc_keytype_option2_t option2 = req->option2;
-
- if (operation == UNC_OP_CREATE) { // C, I
- if (dt_type == UPLL_DT_CANDIDATE || dt_type == UPLL_DT_IMPORT) {
- ret_val = ValVbrIfAttributeSupportCheck(ctrlr_name, ikey, operation, req->datatype);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("VBR_IF struct Capa check failure for create operation");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Error Unsupported datatype - (%d)", dt_type);
- return UPLL_RC_ERR_GENERIC;
- }
- } else if (operation == UNC_OP_UPDATE) { // C
- if (dt_type == UPLL_DT_CANDIDATE) {
- ret_val = ValVbrIfAttributeSupportCheck(ctrlr_name, ikey, operation, req->datatype);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("VBR_IF struct Capa check failure for Update operation");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Error Unsupported datatype - (%d)", dt_type);
- return UPLL_RC_ERR_GENERIC;
- }
- } else if (operation == UNC_OP_READ || operation == UNC_OP_READ_SIBLING
- || operation == UNC_OP_READ_SIBLING_BEGIN
- || operation == UNC_OP_READ_SIBLING_COUNT) {
- if (dt_type == UPLL_DT_CANDIDATE || dt_type == UPLL_DT_RUNNING ||
- dt_type == UPLL_DT_STARTUP || dt_type == UPLL_DT_STATE) {
- if (option1 != UNC_OPT1_NORMAL) {
- UPLL_LOG_DEBUG("Error option1 is not NORMAL");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- if (option2 == UNC_OPT2_NONE) {
- if (ikey->get_cfg_val()->get_val() == NULL) {
- UPLL_LOG_DEBUG("val_vbr_if struct is an optional");
- return UPLL_RC_SUCCESS;
- }
- ret_val = ValVbrIfAttributeSupportCheck(ctrlr_name, ikey, operation, req->datatype);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("VBR_IF struct capa check failure for read operation");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- return UPLL_RC_SUCCESS;
- } else if (option2 == UNC_OPT2_NEIGHBOR) {
- if (ikey->get_cfg_val()->get_val() == NULL) {
- }
- ret_val = ValVtnNeighborAttributeSupportCheck(ctrlr_name, ikey);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(
- "val_vtn_neighbor struct capa check failure for read operation");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Error option2 is not matching");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- } else {
- UPLL_LOG_DEBUG("Error Unsupported datatype - (%d)", dt_type);
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
- }
- }
- UPLL_LOG_DEBUG("Error Unsupported operation - (%d)", operation);
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
-}
-
-upll_rc_t VbrIfMoMgr::ValidateAttribute(ConfigKeyVal *ikey,
- DalDmlIntf *dmi,
- IpcReqRespHeader *req) {
- UPLL_FUNC_TRACE;
- // Semantic check for different vbridges with same switch-id and vlan-id
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- ConfigKeyVal *nw_vbrif_ck = NULL;
- if (ikey->get_key_type() != UNC_KT_VBR_IF)
- return UPLL_RC_ERR_CFG_SYNTAX;
- /* allocate a new vbrif key and val */
- result_code = GetChildConfigKey(nw_vbrif_ck, NULL);
- if (result_code != UPLL_RC_SUCCESS || nw_vbrif_ck == NULL) {
- UPLL_LOG_DEBUG("Failed GetChildConfigKey. Urc=%d", result_code);
- if (nw_vbrif_ck) delete nw_vbrif_ck;
- return result_code;
- }
- // key_vbr_if *if_key = reinterpret_cast<key_vbr_if *>(ikey->get_key());
- val_vbr_if *if_val = reinterpret_cast<val_vbr_if *>(GetVal(ikey));
- if (!if_val) {
- if (req->operation == UNC_OP_CREATE) {
- UPLL_LOG_DEBUG("Val Structure is Null");
- delete nw_vbrif_ck;
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Val structure is must");
- delete nw_vbrif_ck;
+ if (!ctrlr_name) {
+ ctrlr_name = reinterpret_cast<char*>((reinterpret_cast<key_user_data_t *>
+ (ikey->get_user_data()))->ctrlr_id);
+ if (!ctrlr_name || !strlen(ctrlr_name)) {
+ UPLL_LOG_DEBUG("Controller Name is NULL");
return UPLL_RC_ERR_GENERIC;
}
}
- key_vbr_if *nw_ifkey = reinterpret_cast<key_vbr_if *>(nw_vbrif_ck->get_key());
- if (!nw_ifkey) {
- delete nw_vbrif_ck;
- return UPLL_RC_ERR_GENERIC;
- }
- val_drv_vbr_if *valif = reinterpret_cast<val_drv_vbr_if *>
- (ConfigKeyVal::Malloc(sizeof(val_drv_vbr_if)));
- memcpy(&(valif->vbr_if_val), if_val, sizeof(val_vbr_if));
-
-#if 0
- /* init val with portmap parameters from input key */
- if ((if_val->portmap.valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID)
- && (if_val->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] == UNC_VF_VALID)) {
- valif->vbr_if_val.portmap.valid[UPLL_IDX_VLAN_ID_PM] = UNC_VF_VALID;
- valif->vbr_if_val.portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] = UNC_VF_VALID;
- uuu::upll_strncpy(valif->vbr_if_val.portmap.logical_port_id,
- if_val->portmap.logical_port_id, (kMaxLenPortName + 1));
- valif->vbr_if_val.portmap.vlan_id = if_val->portmap.vlan_id;
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutFlag };
- result_code = ReadConfigDB(nw_vbrif_ck, UPLL_DT_CANDIDATE, UNC_OP_READ ,
- dbop, dmi, MAINTBL);
- if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- return UPLL_RC_SUCCESS;
- } else if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Rturning error %d", result_code);
- return result_code;
- } else {
- ConfigKeyVal *tmp = nw_vbrif_ck;
- /* parse read db output */
- while (tmp) {
- if (memcmp(reinterpret_cast<key_vbr_if *>(tmp->get_key()), if_key,
- sizeof(key_vbr_if)) != 0) {
- UPLL_LOG_INFO("Different vbridges contain same switch-id and vlan-id ");
- return UPLL_RC_ERR_CFG_SEMANTIC;
- }
- tmp = tmp->get_next_cfg_key_val();
- }
- }
- delete nw_vbrif_ck;
- }
-#endif
- (ikey->get_cfg_val())->SetVal(IpctSt::kIpcStPfcdrvValVbrIf, valif);
- delete nw_vbrif_ck;
- return UPLL_RC_SUCCESS;
-}
-upll_rc_t VbrIfMoMgr::ValVbrIfAttributeSupportCheck(
- const char *ctrlr_name,
- ConfigKeyVal *ikey,
- unc_keytype_operation_t operation,
- upll_keytype_datatype_t dt_type) {
- UPLL_FUNC_TRACE;
bool result_code = false;
uint32_t max_attrs = 0;
uint32_t max_instance_count = 0;
const uint8_t *attrs;
- switch (operation) {
+ switch (req->operation) {
case UNC_OP_CREATE:
result_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
&max_instance_count, &max_attrs, &attrs);
- if (result_code && cur_instance_count >= max_instance_count &&
- cur_instance_count !=0 && max_instance_count != 0) {
+ if (result_code && (max_instance_count != 0) &&
+ (cur_instance_count >= max_instance_count)) {
UPLL_LOG_INFO("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
__LINE__, __FUNCTION__, cur_instance_count,
max_instance_count);
&max_attrs, &attrs);
break;
default:
- UPLL_LOG_INFO("Invalid operation code - (%d)", operation);
+ UPLL_LOG_INFO("Invalid operation code - (%d)", req->operation);
return UPLL_RC_ERR_GENERIC;
}
if (!result_code) {
UPLL_LOG_INFO("key_type - %d is not supported by controller - %s",
ikey->get_key_type(), ctrlr_name);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
- if (NULL == ikey->get_cfg_val()) {
- UPLL_LOG_INFO("Empty cfg_val is received");
+ if (max_attrs > 0) {
+ ret_val = ValVbrIfAttributeSupportCheck(attrs, ikey, req->operation,
+ req->datatype);
+ return ret_val;
+ } else {
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d", req->operation);
return UPLL_RC_ERR_GENERIC;
}
- if (ikey->get_cfg_val()->get_st_num() != IpctSt::kIpcStValVbrIf && UPLL_DT_IMPORT != dt_type) {
- UPLL_LOG_INFO("Invalid Value structure received. received struct - %d",
- (ikey->get_cfg_val()->get_st_num()));
- return UPLL_RC_ERR_CFG_SYNTAX;
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VbrIfMoMgr::ValidateAttribute(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_drv_vbr_if *if_val = reinterpret_cast<val_drv_vbr_if *>(GetVal(ikey));
+ if (!if_val) {
+ if (req->operation == UNC_OP_CREATE) {
+ UPLL_LOG_DEBUG("Val Structure is Null");
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_DEBUG("Val structure is must");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ result_code = IsLogicalPortAndVlanIdInUse(ikey, dmi, req);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_ERROR("Returning error %d\n", result_code);
+ return result_code;
+ }
+
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VbrIfMoMgr::ValVbrIfAttributeSupportCheck(
+ const uint8_t *attrs, ConfigKeyVal *ikey,
+ unc_keytype_operation_t operation,
+ upll_keytype_datatype_t dt_type) {
+
+ UPLL_FUNC_TRACE;
+ val_vbr_if_t *vbr_if_val = NULL;
+ if (dt_type == UPLL_DT_IMPORT) {
+ ConfigVal *cfg_val = ikey->get_cfg_val();
+ if (!cfg_val)
+ return UPLL_RC_SUCCESS;
+
+ vbr_if_val = &(reinterpret_cast<val_drv_vbr_if *>(
+ cfg_val->get_val())->vbr_if_val);
+ if (vbr_if_val) {
+ }
+ } else {
+ ConfigVal *cfg_val = ikey->get_cfg_val();
+ if (!cfg_val)
+ return UPLL_RC_SUCCESS;
+
+ vbr_if_val =
+ reinterpret_cast<val_vbr_if_t *>(ikey->get_cfg_val()->get_val());
}
- if (UPLL_DT_IMPORT != dt_type) {
- val_vbr_if *vbr_if_val =
- reinterpret_cast<val_vbr_if *>(ikey->get_cfg_val()->get_val());
if (vbr_if_val != NULL) {
- if ((vbr_if_val->valid[UPLL_IDX_DESC_VBRI] == UNC_VF_VALID)
- || (vbr_if_val->valid[UPLL_IDX_DESC_VBRI] == UNC_VF_VALID_NO_VALUE)) {
+ if ((vbr_if_val->valid[UPLL_IDX_DESC_VBRI] == UNC_VF_VALID) ||
+ (vbr_if_val->valid[UPLL_IDX_DESC_VBRI] == UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr_if::kCapDesc] == 0) {
- vbr_if_val->valid[UPLL_IDX_DESC_VBRI] = UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_INFO("Description attr is not supported by ctrlr ");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ vbr_if_val->valid[UPLL_IDX_DESC_VBRI] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_INFO("Description attr is not supported by ctrlr ");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
}
}
- if ((vbr_if_val->valid[UPLL_IDX_ADMIN_STATUS_VBRI] == UNC_VF_VALID)
- ||(vbr_if_val->valid[UPLL_IDX_ADMIN_STATUS_VBRI] ==
- UNC_VF_VALID_NO_VALUE)) {
+ if ((vbr_if_val->valid[UPLL_IDX_ADMIN_STATUS_VBRI] == UNC_VF_VALID) ||
+ (vbr_if_val->valid[UPLL_IDX_ADMIN_STATUS_VBRI] ==
+ UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr_if::kCapAdminStatus] == 0) {
- vbr_if_val->valid[UPLL_IDX_DESC_VBRI] = UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_INFO("Admin status attr is not supported by ctrlr ");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ vbr_if_val->valid[UPLL_IDX_DESC_VBRI] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_INFO("Admin status attr is not supported by ctrlr ");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
}
}
- if ((vbr_if_val->valid[UPLL_IDX_PM_VBRI] == UNC_VF_VALID)
- || (vbr_if_val->valid[UPLL_IDX_PM_VBRI] == UNC_VF_VALID_NO_VALUE)) {
- if ((vbr_if_val->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] == UNC_VF_VALID)
- || (vbr_if_val->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM]
- == UNC_VF_VALID_NO_VALUE)) {
+ if ((vbr_if_val->valid[UPLL_IDX_PM_VBRI] == UNC_VF_VALID) ||
+ (vbr_if_val->valid[UPLL_IDX_PM_VBRI] == UNC_VF_VALID_NO_VALUE)) {
+ if ((vbr_if_val->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM]
+ == UNC_VF_VALID) ||
+ (vbr_if_val->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM]
+ == UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr_if::kCapLogicalPortId] == 0) {
vbr_if_val->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] =
- UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_INFO("portmap.swich_id attr is not supported by ctrlr ");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_INFO("portmap.logical_port_id attr"
+ " is not supported by ctrlr ");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
}
}
- if ((vbr_if_val->portmap.valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID)
- || (vbr_if_val->portmap.valid[UPLL_IDX_VLAN_ID_PM]
- == UNC_VF_VALID_NO_VALUE)) {
+ if ((vbr_if_val->portmap.valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID) ||
+ (vbr_if_val->portmap.valid[UPLL_IDX_VLAN_ID_PM]
+ == UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr_if::kCapVlanId] == 0) {
- vbr_if_val->portmap.valid[UPLL_IDX_VLAN_ID_PM] = UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_INFO("portmap.vlanid attr is not supported by ctrlr ");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ vbr_if_val->portmap.valid[UPLL_IDX_VLAN_ID_PM] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_INFO("portmap.vlanid attr is not supported by ctrlr ");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
}
}
- if ((vbr_if_val->portmap.valid[UPLL_IDX_TAGGED_PM] == UNC_VF_VALID)
- || (vbr_if_val->portmap.valid[UPLL_IDX_TAGGED_PM]
- == UNC_VF_VALID_NO_VALUE)) {
+ if ((vbr_if_val->portmap.valid[UPLL_IDX_TAGGED_PM] == UNC_VF_VALID) ||
+ (vbr_if_val->portmap.valid[UPLL_IDX_TAGGED_PM]
+ == UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr_if::kCapTagged] == 0) {
- vbr_if_val->portmap.valid[UPLL_IDX_TAGGED_PM] = UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_INFO("portmap.Tagged attr is not supported by ctrlr ");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ vbr_if_val->portmap.valid[UPLL_IDX_TAGGED_PM] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_INFO("portmap.Tagged attr is not supported by ctrlr ");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
}
}
}
- return UPLL_RC_SUCCESS;
- }
+ } else {
+ UPLL_LOG_INFO("ERROR:Vbr_if Value structure is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+#if 0
} else if (UPLL_DT_IMPORT == dt_type) {
val_drv_vbr_if *vbr_if_val =
reinterpret_cast<val_drv_vbr_if *>(ikey->get_cfg_val()->get_val());
if ((vbr_if_val->vbr_if_val.valid[UPLL_IDX_DESC_VBRI] == UNC_VF_VALID)
|| (vbr_if_val->vbr_if_val.valid[UPLL_IDX_DESC_VBRI] == UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr_if::kCapDesc] == 0) {
- vbr_if_val->vbr_if_val.valid[UPLL_IDX_DESC_VBRI] = UNC_VF_NOT_SOPPORTED;
+ vbr_if_val->vbr_if_val.valid[UPLL_IDX_DESC_VBRI] = UNC_VF_NOT_SUPPORTED;
UPLL_LOG_INFO("Description attr is not supported by ctrlr ");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
||(vbr_if_val->vbr_if_val.valid[UPLL_IDX_ADMIN_STATUS_VBRI] ==
UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr_if::kCapAdminStatus] == 0) {
- vbr_if_val->vbr_if_val.valid[UPLL_IDX_DESC_VBRI] = UNC_VF_NOT_SOPPORTED;
+ vbr_if_val->vbr_if_val.valid[UPLL_IDX_DESC_VBRI] = UNC_VF_NOT_SUPPORTED;
UPLL_LOG_INFO("Admin status attr is not supported by ctrlr ");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr_if::kCapLogicalPortId] == 0) {
vbr_if_val->vbr_if_val.portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] =
- UNC_VF_NOT_SOPPORTED;
+ UNC_VF_NOT_SUPPORTED;
UPLL_LOG_INFO("portmap.swich_id attr is not supported by ctrlr ");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
|| (vbr_if_val->vbr_if_val.portmap.valid[UPLL_IDX_VLAN_ID_PM]
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr_if::kCapVlanId] == 0) {
- vbr_if_val->vbr_if_val.portmap.valid[UPLL_IDX_VLAN_ID_PM] = UNC_VF_NOT_SOPPORTED;
+ vbr_if_val->vbr_if_val.portmap.valid[UPLL_IDX_VLAN_ID_PM] = UNC_VF_NOT_SUPPORTED;
UPLL_LOG_INFO("portmap.vlanid attr is not supported by ctrlr ");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
|| (vbr_if_val->vbr_if_val.portmap.valid[UPLL_IDX_TAGGED_PM]
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr_if::kCapTagged] == 0) {
- vbr_if_val->vbr_if_val.portmap.valid[UPLL_IDX_TAGGED_PM] = UNC_VF_NOT_SOPPORTED;
+ vbr_if_val->vbr_if_val.portmap.valid[UPLL_IDX_TAGGED_PM] = UNC_VF_NOT_SUPPORTED;
UPLL_LOG_INFO("portmap.Tagged attr is not supported by ctrlr ");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
return UPLL_RC_SUCCESS;
}
}
- UPLL_LOG_INFO("Error VBR_IF STRUCT is NULL");
- return UPLL_RC_ERR_GENERIC;
-}
+#endif
+
+upll_rc_t VbrIfMoMgr::CopyToConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *ikey) {
-upll_rc_t VbrIfMoMgr::ValVtnNeighborAttributeSupportCheck(
- const char *ctrlr_name, ConfigKeyVal *ikey) {
UPLL_FUNC_TRACE;
- bool result_code;
- uint32_t max_attrs;
- const uint8_t *attrs;
+ if (!ikey || !(ikey->get_key()))
+ return UPLL_RC_ERR_GENERIC;
+ key_rename_vnode_info *key_rename =
+ reinterpret_cast<key_rename_vnode_info *>(ikey->get_key());
- result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(), &max_attrs,
- &attrs);
- if (!result_code) {
- UPLL_LOG_INFO("key_type - %d is not supported by controller - %s",
- ikey->get_key_type(), ctrlr_name);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
- }
-
- val_vtn_neighbor *vtn_neighbor =
- reinterpret_cast<val_vtn_neighbor *>(ikey->get_cfg_val()->get_val());
- if (vtn_neighbor != NULL) {
- if ((vtn_neighbor->valid[UPLL_IDX_CONN_VNODE_NAME_VN] == UNC_VF_VALID)
- || (vtn_neighbor->valid[UPLL_IDX_CONN_VNODE_NAME_VN]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vtn_neighbor::kCapConnectedVnodeName] == 0) {
- vtn_neighbor->valid[UPLL_IDX_CONN_VNODE_NAME_VN] = UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_INFO("Vtn_neighbor structure attr is not supported by ctrlr ");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- }
- if ((vtn_neighbor->valid[UPLL_IDX_CONN_VNODE_IF_NAME_VN] == UNC_VF_VALID)
- || (vtn_neighbor->valid[UPLL_IDX_CONN_VNODE_IF_NAME_VN]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vtn_neighbor::kCapConnectedIfName] == 0) {
- vtn_neighbor->valid[UPLL_IDX_CONN_VNODE_IF_NAME_VN] =
- UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_INFO("Vtn_neighbor structure attr is not supported by ctrlr ");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- }
- if ((vtn_neighbor->valid[UPLL_IDX_CONN_VLINK_NAME_VN] == UNC_VF_VALID)
- || (vtn_neighbor->valid[UPLL_IDX_CONN_VLINK_NAME_VN]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vtn_neighbor::kCapConnectedVlinkName] == 0) {
- vtn_neighbor->valid[UPLL_IDX_CONN_VLINK_NAME_VN] = UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_INFO("Vtn_neighbor structure attr is not supported by ctrlr ");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Error VAL_VTN_NEIGHBOR STRUCT is NULL");
- return UPLL_RC_ERR_GENERIC;
- }
-}
-
-upll_rc_t VbrIfMoMgr::CopyToConfigKey(ConfigKeyVal *&okey,
- ConfigKeyVal *ikey) {
-
- UPLL_FUNC_TRACE;
- if (!ikey || !(ikey->get_key()))
- return UPLL_RC_ERR_GENERIC;
- key_rename_vnode_info *key_rename =
- reinterpret_cast<key_rename_vnode_info *>(ikey->get_key());
-
- if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vtn_name)))
- return UPLL_RC_ERR_GENERIC;
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vtn_name)))
+ return UPLL_RC_ERR_GENERIC;
key_vbr_if_t *vbr_if_key = reinterpret_cast<key_vbr_if_t *>
(ConfigKeyVal::Malloc(sizeof(key_vbr_if_t)));
if (UNC_KT_VBRIDGE == ikey->get_key_type()) {
if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vnode_name))) {
free(key_rename);
+ free(vbr_if_key);
return UPLL_RC_ERR_GENERIC;
}
uuu::upll_strncpy(vbr_if_key->vbr_key.vbridge_name,
key_rename->old_unc_vnode_name, (kMaxLenVnodeName + 1));
} else {
- if (!strlen(reinterpret_cast<char *>(key_rename->new_unc_vnode_name)))
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_unc_vnode_name))) {
+ free(vbr_if_key);
return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(vbr_if_key->vbr_key.vbridge_name,
key_rename->new_unc_vnode_name, (kMaxLenVnodeName + 1));
}
bool copy_to_running) {
UPLL_FUNC_TRACE;
bool invalid_attr = true;
+#if 0
val_vbr_if_t *val_vbr_if1 = reinterpret_cast<val_vbr_if_t *>(val1);
val_vbr_if_t *val_vbr_if2 = reinterpret_cast<val_vbr_if_t *>(val2);
+#else
+ val_drv_vbr_if_t *if1 = reinterpret_cast<val_drv_vbr_if_t *>(val1);
+ val_vbr_if_t *val_vbr_if1 = &if1->vbr_if_val;
+ val_drv_vbr_if_t *if2 = reinterpret_cast<val_drv_vbr_if_t *>(val2);
+ val_vbr_if_t *val_vbr_if2 = &if2->vbr_if_val;
+ UPLL_LOG_DEBUG("cand valid_admin %d run valid_admin %d",
+ val_vbr_if1->valid[UPLL_IDX_ADMIN_STATUS_VBRI],
+ val_vbr_if2->valid[UPLL_IDX_ADMIN_STATUS_VBRI]);
+#endif
for (unsigned int loop = 0;
loop < sizeof(val_vbr_if1->valid) / sizeof(uint8_t); ++loop) {
if (UNC_VF_INVALID == val_vbr_if1->valid[loop]
- && UNC_VF_VALID == val_vbr_if2->valid[loop])
+ && ((UNC_VF_VALID == val_vbr_if2->valid[loop]) ||
+ (UNC_VF_VALID_NO_VALUE == val_vbr_if2->valid[loop])))
val_vbr_if1->valid[loop] = UNC_VF_VALID_NO_VALUE;
}
+ for (unsigned int loop = 1;
+ loop < sizeof(if1->valid) / sizeof(uint8_t); ++loop) {
+ if (UNC_VF_INVALID == if1->valid[loop]
+ && UNC_VF_VALID == if2->valid[loop])
+ if1->valid[loop] = UNC_VF_VALID_NO_VALUE;
+ }
+ if ((if1->valid[PFCDRV_IDX_VEXT_NAME_VBRIF] == UNC_VF_VALID_NO_VALUE) &&
+ (if1->valid[PFCDRV_IDX_VEXTIF_NAME_VBRIF] == UNC_VF_VALID_NO_VALUE) &&
+ (if1->valid[PFCDRV_IDX_VLINK_NAME_VBRIF] == UNC_VF_VALID_NO_VALUE)) {
+ uuu::upll_strncpy(if1->vex_name, if2->vex_name, (kMaxLenVnodeName+1));
+ uuu::upll_strncpy(if1->vex_if_name, if2->vex_if_name, (kMaxLenVnodeName+1));
+ uuu::upll_strncpy(if1->vex_link_name, if2->vex_link_name,
+ (kMaxLenVnodeName+1));
+ if1->valid[PFCDRV_IDX_VEXT_NAME_VBRIF] =
+ (copy_to_running)?UNC_VF_VALID_NO_VALUE:UNC_VF_VALID;
+ if1->valid[PFCDRV_IDX_VEXTIF_NAME_VBRIF] =
+ (copy_to_running)?UNC_VF_VALID_NO_VALUE:UNC_VF_VALID;
+ if1->valid[PFCDRV_IDX_VLINK_NAME_VBRIF] =
+ (copy_to_running)?UNC_VF_VALID_NO_VALUE:UNC_VF_VALID;
+ } else {
+ if ((UNC_VF_VALID == if1->valid[PFCDRV_IDX_VEXT_NAME_VBRIF])
+ && (UNC_VF_VALID == if2->valid[PFCDRV_IDX_VEXT_NAME_VBRIF]))
+ if (!strcmp (reinterpret_cast<char *>(if1->vex_name),
+ reinterpret_cast<const char*>(if2->vex_name)))
+ if1->valid[PFCDRV_IDX_VEXT_NAME_VBRIF] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
+ if ((UNC_VF_VALID == if1->valid[PFCDRV_IDX_VEXTIF_NAME_VBRIF])
+ && (UNC_VF_VALID == if2->valid[PFCDRV_IDX_VEXTIF_NAME_VBRIF]))
+ if (!strcmp (reinterpret_cast<char *>(if1->vex_if_name),
+ reinterpret_cast<const char*>(if2->vex_if_name)))
+ if1->valid[PFCDRV_IDX_VEXTIF_NAME_VBRIF] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
+ if ((UNC_VF_VALID == if1->valid[PFCDRV_IDX_VLINK_NAME_VBRIF])
+ && (UNC_VF_VALID == if2->valid[PFCDRV_IDX_VLINK_NAME_VBRIF]))
+ if (!strcmp (reinterpret_cast<char *>(if1->vex_link_name),
+ reinterpret_cast<const char*>(if2->vex_link_name)))
+ if1->valid[PFCDRV_IDX_VLINK_NAME_VBRIF] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
+ }
for (unsigned int loop = 0;
loop < sizeof(val_vbr_if1->valid) / sizeof(uint8_t); ++loop) {
if (UNC_VF_INVALID == val_vbr_if1->portmap.valid[loop]
&& UNC_VF_VALID == val_vbr_if2->portmap.valid[loop])
val_vbr_if1->portmap.valid[loop] = UNC_VF_VALID_NO_VALUE;
}
- if ((UNC_VF_VALID == val_vbr_if1->valid[UPLL_IDX_DESC_VBRI])
- && (UNC_VF_VALID == val_vbr_if2->valid[UPLL_IDX_DESC_VBRI]))
- if (!strcmp (reinterpret_cast<char *>(val_vbr_if1->description),
- reinterpret_cast<const char*>(val_vbr_if2->description)))
+ if (UNC_VF_INVALID != val_vbr_if1->valid[UPLL_IDX_DESC_VBRI]) {
+ if (!copy_to_running ||
+ ((UNC_VF_VALID == val_vbr_if1->valid[UPLL_IDX_DESC_VBRI]) &&
+ (!strcmp (reinterpret_cast<char *>(val_vbr_if1->description),
+ reinterpret_cast<const char*>(val_vbr_if2->description)))))
val_vbr_if1->valid[UPLL_IDX_DESC_VBRI] = UNC_VF_INVALID;
-#if 0
- // admin state val is needed to determine oper status
- if (val_vbr_if1->valid[UPLL_IDX_ADMIN_STATUS_VBRI] == UNC_VF_VALID
- && val_vbr_if2->valid[UPLL_IDX_ADMIN_STATUS_VBRI] == UNC_VF_VALID) {
- if (val_vbr_if1->admin_status == val_vbr_if2->admin_status)
- val_vbr_if1->valid[UPLL_IDX_ADMIN_STATUS_VBRI] = UNC_VF_INVALID;
}
+#if 1
+ // admin state val is needed to determine oper status
+ if (val_vbr_if1->admin_status == val_vbr_if2->admin_status)
+ val_vbr_if1->valid[UPLL_IDX_ADMIN_STATUS_VBRI] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
+ /* Driver cannot shutdown an unmapped vbrif */
+ if (!copy_to_running && val_vbr_if1->valid[UPLL_IDX_PM_VBRI] == UNC_VF_INVALID)
+ val_vbr_if1->valid[UPLL_IDX_ADMIN_STATUS_VBRI] = UNC_VF_INVALID;
#endif
if (val_vbr_if1->valid[UPLL_IDX_PM_VBRI] == UNC_VF_VALID
&& val_vbr_if2->valid[UPLL_IDX_PM_VBRI] == UNC_VF_VALID) {
== UNC_VF_VALID) {
if (!strcmp(reinterpret_cast<char *>(val_vbr_if1->portmap.logical_port_id),
reinterpret_cast<char *>(val_vbr_if2->portmap.logical_port_id)))
- val_vbr_if1->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] =
- UNC_VF_INVALID;
+ val_vbr_if1->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
- if (val_vbr_if1->portmap.valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID
- && val_vbr_if2->portmap.valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID) {
+ if (val_vbr_if1->portmap.valid[UPLL_IDX_VLAN_ID_PM] != UNC_VF_INVALID
+ && val_vbr_if2->portmap.valid[UPLL_IDX_VLAN_ID_PM] != UNC_VF_INVALID) {
if (val_vbr_if1->portmap.vlan_id == val_vbr_if2->portmap.vlan_id)
- val_vbr_if1->portmap.valid[UPLL_IDX_VLAN_ID_PM] = UNC_VF_INVALID;
+ val_vbr_if1->portmap.valid[UPLL_IDX_VLAN_ID_PM] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
-#if 0
- if (val_vbr_if1->portmap.valid[UPLL_IDX_TAGGED_PM] == UNC_VF_VALID
- && val_vbr_if2->portmap.valid[UPLL_IDX_TAGGED_PM] == UNC_VF_VALID) {
+#if 1
+ if (val_vbr_if1->portmap.valid[UPLL_IDX_TAGGED_PM] != UNC_VF_INVALID
+ && val_vbr_if2->portmap.valid[UPLL_IDX_TAGGED_PM] != UNC_VF_INVALID) {
if (val_vbr_if1->portmap.tagged == val_vbr_if2->portmap.tagged)
- val_vbr_if1->portmap.valid[UPLL_IDX_TAGGED_PM] = UNC_VF_INVALID;
+ val_vbr_if1->portmap.valid[UPLL_IDX_TAGGED_PM] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
#endif
} else {
- val_vbr_if1->valid[UPLL_IDX_PM_VBRI] = UNC_VF_INVALID;
- }
- }
+ val_vbr_if1->valid[UPLL_IDX_PM_VBRI] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
+ val_vbr_if1->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
+ val_vbr_if1->portmap.valid[UPLL_IDX_VLAN_ID_PM] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
+ val_vbr_if1->portmap.valid[UPLL_IDX_TAGGED_PM] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
+ }
+ }
+ if (!copy_to_running)
+ val_vbr_if1->valid[UPLL_IDX_DESC_VBRI] = UNC_VF_INVALID;
for (unsigned int loop = 0;
loop < sizeof(val_vbr_if1->valid) / sizeof(val_vbr_if1->valid[0]);
++loop) {
if ((UNC_VF_VALID == (uint8_t) val_vbr_if1->valid[loop]) ||
(UNC_VF_VALID_NO_VALUE == (uint8_t) val_vbr_if1->valid[loop])) {
+ if (loop == UPLL_IDX_PM_VBRI) {
+ for (unsigned int i = 0;
+ i < sizeof(val_vbr_if1->portmap.valid) / sizeof(uint8_t); ++i) {
+ if ((UNC_VF_VALID == (uint8_t) val_vbr_if1->portmap.valid[i]) ||
+ (UNC_VF_VALID_NO_VALUE == (uint8_t) val_vbr_if1->portmap.valid[i])) {
+ invalid_attr = false;
+ break;
+ }
+ }
+ } else {
invalid_attr = false;
- break;
+ }
+ if (invalid_attr == false) break;
+ }
+ }
+ for (unsigned int loop = 1;
+ loop < sizeof(if1->valid) / sizeof(uint8_t); ++loop) {
+ if ((UNC_VF_VALID == if1->valid[loop]) ||
+ (UNC_VF_VALID_NO_VALUE == if1->valid[loop])) {
+ invalid_attr = false;
+ break;
}
}
return invalid_attr;
ConfigKeyVal *okey = NULL;
if (NULL == ikey)
return UPLL_RC_ERR_GENERIC;
- GetChildConfigKey(okey, ikey);
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ result_code = GetChildConfigKey(okey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKeyFailed %d", result_code);
+ return result_code;
+ }
+
DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutFlag };
- upll_rc_t result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ,
+ result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ,
dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
UPLL_RC_SUCCESS:result_code;
+ delete okey;
return result_code;
}
- uint8_t vlink_flag = 0;
- GET_USER_DATA_FLAGS(okey,vlink_flag);
- if (vlink_flag & VIF_TYPE)
- return UPLL_RC_ERR_CFG_SEMANTIC;
+ ConfigKeyVal *temkey = okey;
+ while (temkey != NULL) {
+ uint8_t vlink_flag = 0;
+ GET_USER_DATA_FLAGS(temkey, vlink_flag);
+ if (vlink_flag & VIF_TYPE) {
+ delete okey;
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ temkey = temkey->get_next_cfg_key_val();
+ }
+ delete okey;
#if 0
MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>
(GetMoManager(UNC_KT_VLINK)));
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *okey = NULL;
- uint8_t rename=0;
- bool port_map_valid_status = false;
- bool port_map_status = false;
+ result_code = GetChildConfigKey(okey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failure %d", result_code);
+ return result_code;
+ }
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag };
+ result_code = ReadConfigDB(okey, UPLL_DT_CANDIDATE, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("Read failed %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
val_drv_vbr_if *val_drv_vbr = reinterpret_cast<val_drv_vbr_if *>(GetVal(ikey));
if (!val_drv_vbr) {
UPLL_LOG_DEBUG("Val Vbr is Null");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
+ uint8_t flag = 0;
+ GET_USER_DATA_FLAGS(okey, flag);
+ if ((val_drv_vbr->vbr_if_val.valid[UPLL_IDX_PM_VBRI] == UNC_VF_VALID) ||
+ (val_drv_vbr->vbr_if_val.valid[UPLL_IDX_PM_VBRI] == UNC_VF_VALID_NO_VALUE)) {
+ if (flag & VIF_TYPE) {
+ DELETE_IF_NOT_NULL(okey);
+ UPLL_LOG_DEBUG("Interface is linked/bounded with Vlink. \
+ Could not update Portmap");
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ result_code = UpdatePortMap(okey, datatype, dmi, ikey);
+ }
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+}
+
+upll_rc_t VbrIfMoMgr::UpdatePortMap( ConfigKeyVal *okey,
+ upll_keytype_datatype_t datatype,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ikey) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(
GetMoManager(UNC_KT_VBRIF_FLOWFILTER)));
if (!mgr) {
UPLL_LOG_DEBUG("Invalid Instance");
return UPLL_RC_ERR_GENERIC;
}
- result_code = GetChildConfigKey(okey, ikey);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("GetChildConfigKey Failure %d", result_code);
- return result_code;
+ MoMgrImpl *pm_mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(
+ GetMoManager(UNC_KT_VBRIF_POLICINGMAP)));
+ if (!pm_mgr) {
+ UPLL_LOG_DEBUG("Invalid Instance");
+ return UPLL_RC_ERR_GENERIC;
}
- DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag };
- result_code = ReadConfigDB(okey, UPLL_DT_CANDIDATE, UNC_OP_READ, dbop, dmi,
- MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("Read failed %d\n",result_code);
- return result_code;
- }
- if (val_drv_vbr->vbr_if_val.valid[UPLL_IDX_PM_VBRI] == UNC_VF_VALID) {
- port_map_valid_status = true;
+ val_drv_vbr_if *val_drv_vbr = reinterpret_cast<val_drv_vbr_if *>(GetVal(ikey));
+ bool port_map_status = (val_drv_vbr->vbr_if_val.valid[UPLL_IDX_PM_VBRI] == UNC_VF_VALID)?
+ true:false;
+ if (port_map_status) {
val_drv_vbr_if *vbr_val_db = reinterpret_cast<val_drv_vbr_if *>(GetVal(okey));
if (!vbr_val_db) {
- UPLL_LOG_DEBUG("Invalid param\n");
+ UPLL_LOG_DEBUG("Invalid param");
return UPLL_RC_ERR_GENERIC;
}
if (vbr_val_db->vbr_if_val.valid[UPLL_IDX_PM_VBRI] == UNC_VF_INVALID) {
UPLL_LOG_DEBUG("ConvertToDriverPortMap Failure %d", result_code);
return result_code;
}
- port_map_status = true;
} else {
- /* portmap already exists - only change in vlan/tagged */
- val_drv_vbr->valid[UPLL_IDX_VEXT_DRV_PM] = UNC_VF_INVALID;
- val_drv_vbr->valid[UPLL_IDX_VEXT_IF_DRV_PM] = UNC_VF_INVALID;
- val_drv_vbr->valid[UPLL_IDX_VEXT_LINK_DRV_PM] = UNC_VF_INVALID;
+ /* portmap already exists - only change in vlan/tagged */
+ val_drv_vbr->valid[PFCDRV_IDX_VEXT_NAME_VBRIF] = UNC_VF_INVALID;
+ val_drv_vbr->valid[PFCDRV_IDX_VEXTIF_NAME_VBRIF] = UNC_VF_INVALID;
+ val_drv_vbr->valid[PFCDRV_IDX_VLINK_NAME_VBRIF] = UNC_VF_INVALID;
+ port_map_status = false;
}
- } else if (val_drv_vbr->vbr_if_val.valid[UPLL_IDX_PM_VBRI] == UNC_VF_VALID_NO_VALUE) {
+ } else {
+#if 0
string s(okey->ToStrAll());
-
port_map_valid_status = true;
GET_USER_DATA_FLAGS(okey, rename);
if ((rename & VLINK_VNODE1) || (rename & VLINK_VNODE2)) {
return UPLL_RC_ERR_GENERIC;
}
- val_drv_vbr->valid[UPLL_IDX_VBR_IF_DRV_PM] = UNC_VF_VALID_NO_VALUE;
- val_drv_vbr->valid[UPLL_IDX_VEXT_DRV_PM] = UNC_VF_VALID_NO_VALUE;
- val_drv_vbr->valid[UPLL_IDX_VEXT_IF_DRV_PM] = UNC_VF_VALID_NO_VALUE;
- val_drv_vbr->valid[UPLL_IDX_VEXT_LINK_DRV_PM] = UNC_VF_VALID_NO_VALUE;
- val_drv_vbr->vbr_if_val.portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] =
+#endif
+ val_drv_vbr->valid[PFCDRV_IDX_VAL_VBRIF] = UNC_VF_VALID_NO_VALUE;
+ val_drv_vbr->valid[PFCDRV_IDX_VEXT_NAME_VBRIF] = UNC_VF_VALID_NO_VALUE;
+ val_drv_vbr->valid[PFCDRV_IDX_VEXTIF_NAME_VBRIF] = UNC_VF_VALID_NO_VALUE;
+ val_drv_vbr->valid[PFCDRV_IDX_VLINK_NAME_VBRIF] = UNC_VF_VALID_NO_VALUE;
+ val_drv_vbr->vbr_if_val.portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] =
UNC_VF_VALID_NO_VALUE;
- uuu::upll_strncpy(val_drv_vbr->vbr_if_val.portmap.logical_port_id,
+ uuu::upll_strncpy(val_drv_vbr->vbr_if_val.portmap.logical_port_id,
"\0", 1);
- val_drv_vbr->vbr_if_val.portmap.valid[UPLL_IDX_VLAN_ID_PM] =
+ val_drv_vbr->vbr_if_val.portmap.valid[UPLL_IDX_VLAN_ID_PM] =
UNC_VF_VALID_NO_VALUE;
- val_drv_vbr->vbr_if_val.portmap.valid[UPLL_IDX_TAGGED_PM] =
+ val_drv_vbr->vbr_if_val.portmap.valid[UPLL_IDX_TAGGED_PM] =
UNC_VF_VALID_NO_VALUE;
val_drv_vbr->vbr_if_val.portmap.tagged = UPLL_VLAN_UNTAGGED;
val_drv_vbr->vbr_if_val.portmap.vlan_id = 0;
uuu::upll_strncpy(val_drv_vbr->vex_link_name, " ", (kMaxLenVnodeName+1));
// TODO(karthi): any think inform to POM.. will call it from here
/* Info to POM */
- port_map_status = false;
}
- if (port_map_valid_status) {
- if (port_map_status == true ) {
- UPLL_LOG_DEBUG("Portmapstatus-true");
- result_code = mgr->SetVlinkPortmapConfiguration(okey, datatype, dmi, kPortMapConfigured);
+ if (port_map_status == true ) {
+ UPLL_LOG_DEBUG("Portmapstatus-true");
+ result_code = mgr->SetVlinkPortmapConfiguration(okey, datatype, dmi, kPortMapConfigured,
+ UNC_OP_CREATE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("SetVlinkPortMapConfiguration Failure %d", result_code);
+ return result_code;
+ }
+ result_code = pm_mgr->SetVlinkPortmapConfiguration(okey, datatype, dmi, kPortMapConfigured,
+ UNC_OP_CREATE);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("SetVlinkPortMapConfiguration Failure %d", result_code);
delete okey;
- return result_code;
+ return result_code;
}
- }
- else {
- UPLL_LOG_DEBUG("Portmapstatus-flase");
- result_code = mgr->SetVlinkPortmapConfiguration(okey, datatype, dmi, kVlinkPortMapNotConfigured);
- if (UPLL_RC_SUCCESS != result_code
+ } else {
+ UPLL_LOG_DEBUG("Portmapstatus-flase");
+ result_code = mgr->SetVlinkPortmapConfiguration(okey, datatype, dmi, kVlinkPortMapNotConfigured,
+ UNC_OP_DELETE);
+ if (UPLL_RC_SUCCESS != result_code
+ && UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("SetVlinkPortMapConfiguration Failure %d", result_code);
+ return result_code;
+ }
+ result_code = pm_mgr->SetVlinkPortmapConfiguration(okey, datatype, dmi, kVlinkPortMapNotConfigured,
+ UNC_OP_DELETE);
+ if (UPLL_RC_SUCCESS != result_code
&& UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
UPLL_LOG_DEBUG("SetVlinkPortMapConfiguration Failure %d", result_code);
- delete okey;
return result_code;
- }
- }
- }
- DELETE_IF_NOT_NULL(okey);
+ }
+ }
result_code = (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code)?UPLL_RC_SUCCESS:result_code;
return result_code;
}
while (cval ) {
if (IpctSt::kIpcStPfcdrvValVbrIf == cval->get_st_num()) {
val_vbr_if_t *vbr_if_val = reinterpret_cast<val_vbr_if_t *>
- (malloc(sizeof(val_vbr_if_t)));
- if (!vbr_if_val) {
- UPLL_LOG_ERROR("Memory Allocation failed");
- return UPLL_RC_ERR_GENERIC;
- }
+ (ConfigKeyVal::Malloc(sizeof(val_vbr_if_t)));
val_drv_vbr_if *vbr_drv_if_val = reinterpret_cast<val_drv_vbr_if *>
(cval->get_val());
- memcpy(vbr_if_val,&(vbr_drv_if_val->vbr_if_val),
+ memcpy(vbr_if_val, &(vbr_drv_if_val->vbr_if_val),
sizeof(val_vbr_if_t));
cval->SetVal(IpctSt::kIpcStValVbrIf, vbr_if_val);
/* do not display portmap info if not configured (for boundary)*/
uint8_t vlink_flag = 0;
- GET_USER_DATA_FLAGS(ikey,vlink_flag);
- UPLL_LOG_DEBUG("Interface type %d\n",vlink_flag);
+ GET_USER_DATA_FLAGS(ikey, vlink_flag);
+ UPLL_LOG_DEBUG("Interface type %d", vlink_flag);
+ // set admin status to valid no value
+ if (vbr_if_val->valid[UPLL_IDX_ADMIN_STATUS_VBRI] == UNC_VF_INVALID)
+ vbr_if_val->valid[UPLL_IDX_ADMIN_STATUS_VBRI] = UNC_VF_VALID_NO_VALUE;
if (vlink_flag & VIF_TYPE)
vbr_if_val->valid[UPLL_IDX_PM_VBRI] = UNC_VF_INVALID;
}
if (IpctSt::kIpcStValVbrIfSt == cval->get_st_num()) {
val_vbr_if_st *vbr_if_val_st = reinterpret_cast<val_vbr_if_st *>
- (malloc(sizeof(val_vbr_if_st)));
- if (!vbr_if_val_st) {
- UPLL_LOG_ERROR("Memory Allocation failed");
- return UPLL_RC_ERR_GENERIC;
- }
+ (ConfigKeyVal::Malloc(sizeof(val_vbr_if_st)));
val_db_vbr_if_st *db_vbr_if_val_st = reinterpret_cast<val_db_vbr_if_st *>
(cval->get_val());
- memcpy(vbr_if_val_st,&(db_vbr_if_val_st->vbr_if_val_st),
+ memcpy(vbr_if_val_st, &(db_vbr_if_val_st->vbr_if_val_st),
sizeof(val_vbr_if_st));
cval->SetVal(IpctSt::kIpcStValVbrIfSt, vbr_if_val_st);
}
return UPLL_RC_SUCCESS;
}
-/*This function gives the interfaces mapped to a particular vbridge */
-upll_rc_t VbrIfMoMgr::GetMappedInterfaces(key_vbr_t *vbr_key,
- DalDmlIntf *dmi,
- ConfigKeyVal *&ikey) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
-
- /* Allocate memory for Vbridge interface key and value structure */
- key_vbr_if_t *vbr_if_key = reinterpret_cast<key_vbr_if_t *>
- (ConfigKeyVal::Malloc(sizeof(key_vbr_if_t)));
- val_vbr_if_t *vbr_if_val = reinterpret_cast<val_vbr_if_t *>
- (ConfigKeyVal::Malloc(sizeof(val_vbr_if_t)));
-
- /* initialize the parent vbr key */
- vbr_if_key->vbr_key = *vbr_key;
-
- /*Getting only mapped interfaces - set portmap to valid status*/
- vbr_if_val->valid[UPLL_IDX_PM_VBRI] = UNC_VF_VALID;
- vbr_if_val->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] = UNC_VF_VALID;
- ConfigVal *tempval = new ConfigVal(IpctSt::kIpcStValVbrIf, vbr_if_val);
- ikey = new ConfigKeyVal(UNC_KT_VBR_IF, IpctSt::kIpcStKeyVbrIf, vbr_if_key,
- tempval);
- /* Get all the vbridges under the VTN */
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
- result_code = ReadConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_READ, dbop, dmi,
- MAINTBL);
- return result_code;
-}
-
upll_rc_t VbrIfMoMgr::GetVexternal(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
return UPLL_RC_ERR_GENERIC;
}
val_drv_vbr_if *vbr_if_val = reinterpret_cast<val_drv_vbr_if *>
- (malloc(sizeof(val_drv_vbr_if)));
- if (!vbr_if_val) {
- UPLL_LOG_DEBUG("Invalid vbrif_val");
- return UPLL_RC_ERR_GENERIC;
- }
- memset(vbr_if_val, 0, sizeof(val_drv_vbr_if));
+ (ConfigKeyVal::Malloc(sizeof(val_drv_vbr_if)));
//vbr_if_val->valid[UPLL_IDX_VBR_IF_DRV_PM] = UNC_VF_VALID;
//vbr_if_val->vbr_if_val.valid[UPLL_IDX_PM_VBRI] = UNC_VF_VALID;
//vbr_if_val->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] = UNC_VF_VALID;
return UPLL_RC_SUCCESS;
}
-/*This function gives the bridges connected to a particular switch log port*/
-upll_rc_t VbrIfMoMgr::GetMappedVbridges(uint8_t *logportid, DalDmlIntf *dmi,
- set<key_vnode_t>* sw_vbridge_set) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- key_vbr_t *vbr_key = reinterpret_cast<key_vbr_t *>
- (ConfigKeyVal::Malloc(sizeof(key_vbr_t)));
- key_vbr_if_t *vbr_if_key = reinterpret_cast<key_vbr_if *>
- (ConfigKeyVal::Malloc(sizeof(key_vbr_if_t)));
- val_vbr_if_t *vbr_if_val = reinterpret_cast<val_vbr_if *>
- (ConfigKeyVal::Malloc(sizeof(val_vbr_if_t)));
-
- /* copy switch id to val_vbr_if strcuture */
- uuu::upll_strncpy(vbr_if_val->portmap.logical_port_id, logportid,
- (kMaxLenPortName + 1));
-
- /*Setting portmap and switch_id valid status*/
- vbr_if_val->valid[UPLL_IDX_PM_VBRI] = UNC_VF_VALID;
- vbr_if_val->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] = UNC_VF_VALID;
- ConfigVal *tempval = new ConfigVal(IpctSt::kIpcStValVbrIf, vbr_if_val);
- ConfigKeyVal *ikey = new ConfigKeyVal(UNC_KT_VBR_IF, IpctSt::kIpcStKeyVbrIf,
- vbr_if_key, tempval);
- /* Get all the vbridges under the VTN */
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
- result_code = ReadConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_READ, dbop, dmi,
- MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Error in reading: %d", result_code);
- free(vbr_key);
- return result_code;
- }
- /* populate sw_vbridge set with vbridges mapped to the specified switch*/
- ConfigKeyVal *iter_key = ikey;
- while (iter_key != NULL) {
- key_vbr_if_t *tkey = reinterpret_cast<key_vbr_if_t *>
- (iter_key->get_key());
- uuu::upll_strncpy(vbr_key->vbridge_name, tkey->vbr_key.vbridge_name,
- (kMaxLenVnodeName + 1));
- uuu::upll_strncpy(vbr_key->vtn_key.vtn_name,
- tkey->vbr_key.vtn_key.vtn_name,
- (kMaxLenVtnName + 1));
- sw_vbridge_set->insert(*(reinterpret_cast<key_vnode_t *>(vbr_key)));
- iter_key = iter_key->get_next_cfg_key_val();
- }
- delete ikey;
- return UPLL_RC_SUCCESS;
-}
upll_rc_t VbrIfMoMgr::AuditUpdateController(unc_key_type_t keytype,
const char *ctrlr_id,
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
DalResultCode db_result = uud::kDalRcSuccess;
- controller_domain_t print_ctrlr_dom;
- print_ctrlr_dom.ctrlr = NULL;
- print_ctrlr_dom.domain = NULL;
controller_domain_t ctrlr_dom;
ctrlr_dom.ctrlr = NULL;
ctrlr_dom.domain = NULL;
((phase == uuc::kUpllUcpUpdate)?UNC_OP_UPDATE:
((phase == uuc::kUpllUcpDelete)?UNC_OP_DELETE:UNC_OP_INVALID));
/* retreives the delta of running and audit configuration */
- UPLL_LOG_DEBUG("Operation is %d\n", op);
+ UPLL_LOG_DEBUG("Operation is %d", op);
result_code = DiffConfigDB(UPLL_DT_RUNNING, UPLL_DT_AUDIT, op,
ckv_running_db, ckv_audit_db,
- &cursor, dmi, ctrlr, MAINTBL);
+ &cursor, dmi, ctrlr, MAINTBL, true);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("DiffConfigDB failed - %d", result_code);
return result_code;
return UPLL_RC_ERR_GENERIC;
}
while (uud::kDalRcSuccess == (db_result = dmi->GetNextRecord(cursor))) {
- #if 1
- UPLL_LOG_DEBUG("Diff Record: Keytype: Operation: is %d\n %d\n %s\n", keytype, op, ckv_running_db->ToStrAll().c_str());
- GET_USER_DATA_CTRLR_DOMAIN(ckv_running_db,print_ctrlr_dom);
- if (print_ctrlr_dom.ctrlr != NULL ) {
- UPLL_LOG_DEBUG("print_ctrlr_dom.ctrlr is %s", print_ctrlr_dom.ctrlr);
- }
- if (print_ctrlr_dom.domain != NULL ) {
- UPLL_LOG_DEBUG("print_ctrlr_dom.domain is %s\n",print_ctrlr_dom.domain);
+ UPLL_LOG_DEBUG("Diff Running Record: Operation: is %d\n %s\n", op,
+ ckv_running_db->ToStrAll().c_str());
+ /* ignore records of another controller for create and update operation */
+ if (phase != uuc::kUpllUcpDelete) {
+ uint8_t *db_ctrlr = NULL;
+ GET_USER_DATA_CTRLR(ckv_running_db, db_ctrlr);
+ UPLL_LOG_DEBUG("db ctrl_id and audit ctlr_id are %s %s", db_ctrlr, ctrlr_id);
+ if (db_ctrlr && strncmp(reinterpret_cast<const char *>(db_ctrlr),
+ reinterpret_cast<const char *>(ctrlr_id),
+ strlen(reinterpret_cast<const char *>(ctrlr_id)) + 1))
+ continue;
}
- #endif
switch (phase) {
case uuc::kUpllUcpDelete:
- UPLL_LOG_DEBUG("Deleted record is %s\n ",ckv_running_db->ToStrAll().c_str());
result_code = GetChildConfigKey(ckv_driver_req, ckv_running_db);
- UPLL_LOG_DEBUG("ckv_driver_req in delete is %s\n", ckv_driver_req->ToStrAll().c_str());
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetChildConfigKey failed. err_code & phase %d %d\n",
+ UPLL_LOG_DEBUG("GetChildConfigKey failed. err_code & phase %d %d",
result_code, phase);
return result_code;
}
UPLL_LOG_DEBUG("Invalid param");
return UPLL_RC_ERR_GENERIC;
}
- result_code = ReadConfigDB(ckv_driver_req, UPLL_DT_RUNNING, UNC_OP_READ,
+ result_code = ReadConfigDB(ckv_driver_req, UPLL_DT_AUDIT, UNC_OP_READ,
dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d",result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
return UPLL_RC_ERR_GENERIC;
}
drv_vbr_if = reinterpret_cast<val_drv_vbr_if_t *>
UPLL_LOG_DEBUG("drv_vbr_if is NULL");
return UPLL_RC_ERR_GENERIC;
}
- if (drv_vbr_if->vbr_if_val.valid[UPLL_IDX_PM_DRV_VBRI] != UNC_VF_VALID) {
+ if (drv_vbr_if->vbr_if_val.valid[UPLL_IDX_PM_VBRI] != UNC_VF_VALID) {
ckv_driver_req->DeleteCfgVal();
} else {
drv_vbr_if->valid[0] = UNC_VF_INVALID;
if (drv_vbr_if->vbr_if_val.valid[i] != UNC_VF_INVALID) {
drv_vbr_if->valid[0] = UNC_VF_VALID;
break;
- }
- }
+ }
+ }
}
break;
case uuc::kUpllUcpCreate:
- UPLL_LOG_DEBUG("Created record is %s\n ",ckv_running_db->ToStrAll().c_str());
result_code = DupConfigKeyVal(ckv_driver_req, ckv_running_db, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("DupConfigKeyVal failed. err_code & phase %d %d\n",
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed. err_code & phase %d %d",
result_code, phase);
return result_code;
}
break;
case uuc::kUpllUcpUpdate:
- UPLL_LOG_DEBUG("UpdateRecord record is %s\n ",ckv_running_db->ToStrAll().c_str());
- UPLL_LOG_DEBUG("UpdateRecord record is %s\n ",ckv_audit_db->ToStrAll().c_str());
+ UPLL_LOG_DEBUG("Diff audit record is %s ", ckv_audit_db->ToStrAll().c_str());
result_code = DupConfigKeyVal(ckv_driver_req, ckv_running_db, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("DupConfigKeyVal failed for running record. \
- err_code & phase %d %d\n", result_code, phase);
+ err_code & phase %d %d", result_code, phase);
return result_code;
}
result_code = DupConfigKeyVal(ckv_audit_dup_db, ckv_audit_db, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("DupConfigKeyVal failed for audit record. \
- err_code & phase %d %d\n", result_code, phase);
+ err_code & phase %d %d", result_code, phase);
return result_code;
}
if (GetVal(ckv_driver_req) != NULL &&
GetVal(ckv_audit_dup_db) != NULL) {
void *val1 = GetVal(ckv_driver_req);
- FilterAttributes(val1, GetVal(ckv_audit_dup_db), false,
- UNC_OP_UPDATE);
+ if (FilterAttributes(val1, GetVal(ckv_audit_dup_db), false,
+ UNC_OP_UPDATE)) {
+ delete ckv_driver_req;
+ ckv_driver_req = NULL;
+ delete ckv_audit_dup_db;
+ ckv_audit_dup_db = NULL;
+ continue;
+ }
}
break;
default:
- UPLL_LOG_DEBUG("Invalid operation %d\n", phase);
+ UPLL_LOG_DEBUG("Invalid operation %d", phase);
return UPLL_RC_ERR_NO_SUCH_OPERATION;
break;
}
+ if (phase == uuc::kUpllUcpUpdate || phase == uuc::kUpllUcpCreate) {
+ drv_vbr_if = reinterpret_cast<val_drv_vbr_if_t *>
+ (GetVal(ckv_driver_req));
+ drv_vbr_if->valid[0] = UNC_VF_INVALID;
+ for (int i=0; i < 3 ; i++) {
+ if (drv_vbr_if->vbr_if_val.valid[i] != UNC_VF_INVALID) {
+ drv_vbr_if->valid[0] = UNC_VF_VALID;
+ break;
+ }
+ }
+ }
GET_USER_DATA_CTRLR_DOMAIN(ckv_driver_req, ctrlr_dom);
if ((NULL == ctrlr_dom.ctrlr) || (NULL == ctrlr_dom.domain)) {
UPLL_LOG_INFO("controller id or domain is NULL");
}
UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
ctrlr_dom.domain);
+ upll_keytype_datatype_t dt_type = UPLL_DT_RUNNING;
+ result_code = GetRenamedControllerKey(ckv_driver_req, dt_type,
+ dmi, &ctrlr_dom);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG(" GetRenamedControllerKey failed err code(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv_running_db);
+ DELETE_IF_NOT_NULL(ckv_audit_db);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+
IpcResponse ipc_response;
memset(&ipc_response, 0, sizeof(IpcResponse));
IpcRequest ipc_req;
ipc_req.header.datatype = UPLL_DT_CANDIDATE;
ipc_req.ckv_data = ckv_driver_req;
if (!IpcUtil::SendReqToDriver((const char *)ctrlr_dom.ctrlr, reinterpret_cast<char *>
- (ctrlr_dom.domain), PFCDRIVER_SERVICE_NAME,
+ (ctrlr_dom.domain), PFCDRIVER_SERVICE_NAME,
PFCDRIVER_SVID_LOGICAL, &ipc_req, true, &ipc_response)) {
UPLL_LOG_INFO("Request to driver for Key %d for controller %s failed ",
ckv_driver_req->get_key_type(), reinterpret_cast<char *>(ctrlr_dom.ctrlr));
return UPLL_RC_ERR_GENERIC;
}
if (ipc_response.header.result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("driver return failure err_code is %d\n", ipc_response.header.result_code);
+ UPLL_LOG_DEBUG("driver return failure err_code is %d", ipc_response.header.result_code);
ConfigKeyVal *resp = NULL;
result_code = DupConfigKeyVal(resp, ipc_response.ckv_data);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("DupConfigKeyVal failed for ipc response ckv err_code %d\n",
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed for ipc response ckv err_code %d",
result_code);
delete ipc_response.ckv_data;
return result_code;
- }
+ }
result_code = UpdateAuditConfigStatus(UNC_CS_INVALID, phase, resp);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_TRACE("Update Audit config status failed %d",
result_code);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
return result_code;
}
result_code = UpdateConfigDB(resp, UPLL_DT_RUNNING, UNC_OP_UPDATE,
dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("UpdateConfigDB failed for ipc response ckv err_code %d\n",
+ UPLL_LOG_DEBUG("UpdateConfigDB failed for ipc response ckv err_code %d",
result_code);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
return result_code;
- }
+ }
if (keytype == UNC_KT_VTN) {
result_code = SetConsolidatedStatus(resp, dmi);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("SetConsolidatedStatus failed for ipc response ckv err_code %d\n",
- result_code);
+ UPLL_LOG_DEBUG("SetConsolidatedStatus failed for ipc response ckv err_code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
return result_code;
}
}
if (resp)
delete resp;
}
- if (ckv_driver_req) {
- delete ckv_driver_req;
- ckv_driver_req = NULL;
- }
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ if (ckv_driver_req)
+ delete ckv_driver_req;
+ ckv_driver_req = NULL;
+ if (ckv_audit_dup_db)
+ delete ckv_audit_dup_db;
+ ckv_audit_dup_db = NULL;
+
*ctrlr_affected = true;
}
dmi->CloseCursor(cursor, true);
DalDmlIntf *dmi,
ConfigKeyVal **err_ckv) {
UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
+ upll_rc_t result_code = UPLL_RC_SUCCESS, driver_result = UPLL_RC_SUCCESS;
DalResultCode db_result;
- ConfigKeyVal *req, *nreq = NULL, *ck_main = NULL;
+ ConfigKeyVal *req = NULL, *nreq = NULL, *ck_main = NULL;
controller_domain_t ctrlr_dom;
ctrlr_dom.ctrlr = NULL;
ctrlr_dom.domain = NULL;
if (affected_ctrlr_set == NULL)
return UPLL_RC_ERR_GENERIC;
- result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING,
+ driver_result = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING,
op, req, nreq, &dal_cursor_handle, dmi, MAINTBL);
- while (result_code == UPLL_RC_SUCCESS) {
+ while (driver_result == UPLL_RC_SUCCESS) {
// Get Next Record
db_result = dmi->GetNextRecord(dal_cursor_handle);
- result_code = DalToUpllResCode(db_result);
- if (result_code != UPLL_RC_SUCCESS)
+ driver_result = DalToUpllResCode(db_result);
+ if (driver_result != UPLL_RC_SUCCESS)
break;
switch (op) {
case UNC_OP_CREATE:
case UNC_OP_UPDATE:
/* fall through intended */
result_code = DupConfigKeyVal(ck_main, req);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("DupConfigKeyVal failed %d", result_code);
+ dmi->CloseCursor(dal_cursor_handle, true);
+ delete req;
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
break;
case UNC_OP_DELETE:
result_code = GetChildConfigKey(ck_main, req);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("GetChildConfigKey failed %d", result_code);
+ dmi->CloseCursor(dal_cursor_handle, true);
+ delete req;
+ return result_code;
+ }
default:
break;
}
GET_USER_DATA_CTRLR_DOMAIN(ck_main, ctrlr_dom);
if (ctrlr_dom.ctrlr == NULL) {
- return UPLL_RC_ERR_GENERIC;
+ delete ck_main;
+ delete req;
+ DELETE_IF_NOT_NULL(nreq);
+ return UPLL_RC_ERR_GENERIC;
}
uint8_t bound_vlink = 0;
- GET_USER_DATA_FLAGS(ck_main,bound_vlink);
+ GET_USER_DATA_FLAGS(ck_main, bound_vlink);
if (op == UNC_OP_DELETE) {
if (ck_main->get_cfg_val()) {
UPLL_LOG_DEBUG("Invalid param");
+ delete ck_main;
+ delete req;
return UPLL_RC_ERR_GENERIC;
}
DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone};
result_code = ReadConfigDB(ck_main, UPLL_DT_RUNNING, UNC_OP_READ,
dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d",result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ delete ck_main;
+ delete req;
return UPLL_RC_ERR_GENERIC;
}
val_drv_vbr_if_t *val_vbr = reinterpret_cast<val_drv_vbr_if_t *>
(GetVal(ck_main));
- if (val_vbr->vbr_if_val.valid[UPLL_IDX_PM_DRV_VBRI] != UNC_VF_VALID) {
+ if (val_vbr->vbr_if_val.valid[UPLL_IDX_PM_VBRI] != UNC_VF_VALID) {
ck_main->DeleteCfgVal();
}
}
ck_main = NULL;
continue;
}
- UPLL_LOG_TRACE("%s \n",ck_main->ToStrAll().c_str());
+ UPLL_LOG_TRACE("%s", ck_main->ToStrAll().c_str());
}
val_drv_vbr_if *vbr_ifval = reinterpret_cast<val_drv_vbr_if *>
(GetVal(ck_main));
break;
}
}
- for (int i=1; i < 4 ; i++)
- vbr_ifval->valid[i] = vbr_ifval->vbr_if_val.valid[UPLL_IDX_PM_DRV_VBRI];
- switch (vbr_ifval->vbr_if_val.valid[UPLL_IDX_PM_DRV_VBRI]) {
+ //for (int i=1; i < 4 ; i++)
+ // vbr_ifval->valid[i] = vbr_ifval->vbr_if_val.valid[UPLL_IDX_PM_VBRI];
+ switch (vbr_ifval->vbr_if_val.valid[UPLL_IDX_PM_VBRI]) {
case UNC_VF_VALID_NO_VALUE :
{
- UPLL_LOG_TRACE("entering valid-no-value\n");
+ UPLL_LOG_TRACE("entering valid-no-value");
val_drv_vbr_if *oval_vbrif = reinterpret_cast<val_drv_vbr_if *>
(GetVal(nreq));
if (!oval_vbrif) {
- UPLL_LOG_DEBUG("Invalid param\n");
+ UPLL_LOG_DEBUG("Invalid param");
+ delete req;
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(ck_main);
return UPLL_RC_ERR_GENERIC;
}
- vbr_ifval->valid[UPLL_IDX_VEXT_DRV_PM] = UNC_VF_VALID;
- vbr_ifval->valid[UPLL_IDX_VEXT_IF_DRV_PM] = UNC_VF_VALID;
- vbr_ifval->valid[UPLL_IDX_VEXT_LINK_DRV_PM] = UNC_VF_VALID;
- uuu::upll_strncpy(vbr_ifval->vex_name, oval_vbrif->vex_name,
+ vbr_ifval->valid[PFCDRV_IDX_VEXT_NAME_VBRIF] = UNC_VF_VALID;
+ vbr_ifval->valid[PFCDRV_IDX_VEXTIF_NAME_VBRIF] = UNC_VF_VALID;
+ vbr_ifval->valid[PFCDRV_IDX_VLINK_NAME_VBRIF] = UNC_VF_VALID;
+ uuu::upll_strncpy(vbr_ifval->vex_name, oval_vbrif->vex_name,
kMaxLenVnodeName+1);
- uuu::upll_strncpy(vbr_ifval->vex_if_name, oval_vbrif->vex_if_name,
+ uuu::upll_strncpy(vbr_ifval->vex_if_name, oval_vbrif->vex_if_name,
kMaxLenVnodeName+1);
uuu::upll_strncpy(vbr_ifval->vex_link_name, oval_vbrif->vex_link_name,
kMaxLenVnodeName+1);
break;
- }
+ }
case UNC_VF_VALID:
+ {
// if it is update operation where only the logicalport/vlanid/tag is getting updated
- // set vex/vexif/vexlink to invalid
- if (op == UNC_OP_UPDATE) {
- val_drv_vbr_if *db_ifval = reinterpret_cast<val_drv_vbr_if *>
- (GetVal(nreq));
- if (!db_ifval) {
- UPLL_LOG_TRACE("Invalid param\n");
- return UPLL_RC_ERR_GENERIC;
- }
+ // set vex/vexif/vexlink to invalid
+ val_drv_vbr_if *db_ifval = NULL;
+ db_ifval = (op != UNC_OP_UPDATE) ?
+ reinterpret_cast<val_drv_vbr_if *>(GetVal(ck_main)):
+ reinterpret_cast<val_drv_vbr_if *>(GetVal(nreq));
+ if (!db_ifval) {
+ UPLL_LOG_TRACE("Invalid param");
+ delete req;
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(ck_main);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (op == UNC_OP_DELETE) {
if ((db_ifval->vbr_if_val.valid[UPLL_IDX_PM_VBRI] == UNC_VF_VALID) &&
- (db_ifval->vbr_if_val.portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM]
+ (db_ifval->vbr_if_val.portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM]
== UNC_VF_VALID)) {
- /* portmap is updated - fill in vex,vexlink -
+ /* portmap is updated - fill in vex, vexlink -
vexif set to invalid for portmap update
*/
- vbr_ifval->valid[UPLL_IDX_VEXT_DRV_PM] = UNC_VF_VALID;
- uuu::upll_strncpy(vbr_ifval->vex_name, db_ifval->vex_name,
- kMaxLenVnodeName+1);
- vbr_ifval->valid[UPLL_IDX_VEXT_IF_DRV_PM] = UNC_VF_INVALID;
- vbr_ifval->valid[UPLL_IDX_VEXT_LINK_DRV_PM] = UNC_VF_VALID;
+ vbr_ifval->valid[PFCDRV_IDX_VEXT_NAME_VBRIF] = UNC_VF_VALID;
+ uuu::upll_strncpy(vbr_ifval->vex_name, db_ifval->vex_name,
+ kMaxLenVnodeName+1);
+ vbr_ifval->valid[PFCDRV_IDX_VEXTIF_NAME_VBRIF] = UNC_VF_INVALID;
+ vbr_ifval->valid[PFCDRV_IDX_VLINK_NAME_VBRIF] = UNC_VF_VALID;
uuu::upll_strncpy(vbr_ifval->vex_link_name, db_ifval->vex_link_name,
kMaxLenVnodeName+1);
- if (vbr_ifval->vbr_if_val.portmap.valid[UPLL_IDX_TAGGED_PM] == UNC_VF_VALID) {
- if (vbr_ifval->vbr_if_val.portmap.valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_INVALID) {
+ if (vbr_ifval->vbr_if_val.portmap.valid[UPLL_IDX_TAGGED_PM] == UNC_VF_VALID) {
+ if (vbr_ifval->vbr_if_val.portmap.valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_INVALID) {
vbr_ifval->vbr_if_val.portmap.vlan_id = db_ifval->vbr_if_val.portmap.vlan_id;
- vbr_ifval->vbr_if_val.portmap.valid[UPLL_IDX_VLAN_ID_PM] = UNC_VF_VALID;
+ vbr_ifval->vbr_if_val.portmap.valid[UPLL_IDX_VLAN_ID_PM] = UNC_VF_VALID;
}
}
- }
+ }
+ }
+ if (op == UNC_OP_UPDATE) {
if (vbr_ifval->vbr_if_val.valid[UPLL_IDX_ADMIN_STATUS_VBRI] == UNC_VF_INVALID) {
/* set port admin status to disable */
- if ((db_ifval->vbr_if_val.valid[UPLL_IDX_ADMIN_STATUS_VBRI] == UNC_VF_VALID) &&
+ if ((db_ifval->vbr_if_val.valid[UPLL_IDX_ADMIN_STATUS_VBRI] == UNC_VF_VALID) &&
(db_ifval->vbr_if_val.admin_status == UPLL_ADMIN_DISABLE)) {
- vbr_ifval->vbr_if_val.admin_status = UPLL_ADMIN_DISABLE;
+ vbr_ifval->vbr_if_val.admin_status = UPLL_ADMIN_DISABLE;
vbr_ifval->vbr_if_val.valid[UPLL_IDX_ADMIN_STATUS_VBRI] = UNC_VF_VALID;
}
}
}
break;
+ }
default:
break;
}
}
- UPLL_LOG_TRACE("%s \n",ck_main->ToStrAll().c_str());
+ UPLL_LOG_TRACE("%s", ck_main->ToStrAll().c_str());
if (!OVERLAY_KT(keytype)) {
upll_keytype_datatype_t dt_type = (op == UNC_OP_DELETE)?
UPLL_DT_RUNNING:UPLL_DT_CANDIDATE;
// Inserting the controller to Set
affected_ctrlr_set->insert
(string(reinterpret_cast<char *>(ctrlr_dom.ctrlr)));
- result_code = SendIpcReq(session_id, config_id, op,
+ driver_result = SendIpcReq(session_id, config_id, op,
UPLL_DT_CANDIDATE, ck_main, &ctrlr_dom, &ipc_resp);
- if (result_code == UPLL_RC_ERR_RESOURCE_DISCONNECTED) {
- result_code = UPLL_RC_SUCCESS;
+ if (driver_result == UPLL_RC_ERR_RESOURCE_DISCONNECTED) {
+ driver_result = UPLL_RC_SUCCESS;
UPLL_LOG_DEBUG("Controller disconnected");
}
- if (result_code != UPLL_RC_SUCCESS) {
+ if (driver_result != UPLL_RC_SUCCESS) {
ConfigKeyVal *ck_vlink = NULL;
/* Validating if VbridgeIf is a node for Vlink */
if ((bound_vlink & VIF_TYPE_BOUNDARY) == 0x0)
vn_if_type iftype;
if (!mgr) {
UPLL_LOG_DEBUG("Invalid mgr");
+ delete req;
+ DELETE_IF_NOT_NULL(nreq);
return UPLL_RC_ERR_GENERIC;
}
- result_code = mgr->CheckIfMemberOfVlink(ipc_resp.ckv_data,
- UPLL_DT_CANDIDATE, ck_vlink,dmi,iftype);
+ ConfigKeyVal *ck_vif = NULL;
+ result_code = GetChildConfigKey(ck_vif,req);
+ result_code = mgr->CheckIfMemberOfVlink(ck_vif,
+ UPLL_DT_CANDIDATE, ck_vlink, dmi, iftype);
+ DELETE_IF_NOT_NULL(ck_vif);
if (result_code == UPLL_RC_SUCCESS) {
delete ipc_resp.ckv_data;
*err_ckv = ck_vlink;
+ break;
} else {
*err_ckv = ipc_resp.ckv_data;
if (ck_vlink) delete ck_vlink;
UPLL_LOG_DEBUG("Failed to map boundary if to vlink");
}
}
+ if (*err_ckv) {
+ result_code = AdaptValToVtnService(*err_ckv);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("AdaptValToVtnService failed result_code %d",
+ result_code);
+ delete req;
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+ }
break;
}
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
if (ck_main)
delete ck_main;
ck_main = NULL;
delete req;
if (nreq)
delete nreq;
- result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?UPLL_RC_SUCCESS:result_code;
- return result_code;
+ driver_result = (driver_result == UPLL_RC_ERR_NO_SUCH_INSTANCE)?UPLL_RC_SUCCESS:driver_result;
+ return driver_result;
}
upll_rc_t VbrIfMoMgr::PortStatusHandler(const char *ctrlr_name,
const char *domain_name, const char *portid,
bool oper_status, DalDmlIntf *dmi ) {
UPLL_FUNC_TRACE;
- UPLL_LOG_TRACE("portid :(%s) domain_id :(%s) notification:(%d)",
- portid, domain_name, oper_status);
+ UPLL_LOG_TRACE("controller_name is : (%s) portid :(%s) domain_id :(%s) oper_status :(%d)",
+ ctrlr_name, portid, domain_name, oper_status);
upll_rc_t result_code = UPLL_RC_SUCCESS;
/* Allocate Memory for UNC_KT_VBR_IF key and value structure */
val_drv_vbr_if *vbrif_val = reinterpret_cast<val_drv_vbr_if*>
(ConfigKeyVal::Malloc(sizeof(val_drv_vbr_if)));
- val_port_map_t *pm = &vbrif_val->vbr_if_val.portmap;
- pm->valid[UPLL_IDX_PM_VBRI] = UNC_VF_VALID;
+ val_port_map *pm = &vbrif_val->vbr_if_val.portmap;
+ (vbrif_val->vbr_if_val).valid[UPLL_IDX_PM_VBRI] = UNC_VF_VALID;
/* Copy port_id from input to port_id variable in portmap structure */
uuu::upll_strncpy(pm->logical_port_id, portid,
- sizeof(pm->logical_port_id));
+ (kMaxLenPortName + 1));
/* set valid flag as VALID */
pm->valid[UPLL_IDX_LOGICAL_PORT_ID_PM] = UNC_VF_VALID;
ConfigKeyVal *vbrifkey = NULL;
- result_code = GetChildConfigKey(vbrifkey,NULL);
+ result_code = GetChildConfigKey(vbrifkey, NULL);
if (!vbrifkey || (result_code != UPLL_RC_SUCCESS)) {
free(vbrif_val);
- if(vbrifkey) delete vbrifkey;
+ if (vbrifkey) delete vbrifkey;
return UPLL_RC_ERR_GENERIC;
}
vbrifkey->AppendCfgVal(IpctSt::kIpcStValVbrIf, vbrif_val);
-
+ SET_USER_DATA_CTRLR(vbrifkey, ctrlr_name);
+ SET_USER_DATA_DOMAIN(vbrifkey, domain_name);
state_notification notification =
(oper_status == UPLL_OPER_STATUS_UP) ? kPortFaultReset : kPortFault;
-#if 0
- /* Get all the Vbridgeinterfaces under the same port_name and switch-id */
- DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutNone};
- result_code = ReadConfigDB(vbrifkey, UPLL_DT_STATE, UNC_OP_READ, dbop,
- dmi, MAINTBL);
+ // vlinked interfaces should not be handled
+ result_code = UpdateOperStatus(vbrifkey, dmi, notification, false, false, false);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Error in reading %d", result_code);
+ UPLL_LOG_DEBUG("Invalid oper status update %d", result_code);
+ DELETE_IF_NOT_NULL(vbrifkey);
return result_code;
}
- /* Iterate vbr_if list one by one */
- ConfigKeyVal *tmp = vbrifkey;
- while (tmp != NULL) {
- unc_key_type_t keytype = tmp->get_key_type();
+ if (notification == kPortFaultReset) {
+ VnodeMoMgr *mgr = reinterpret_cast<VnodeMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VBRIDGE)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Returning error\n");
+ DELETE_IF_NOT_NULL(vbrifkey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = mgr->TxUpdateDtState(UNC_KT_VBRIDGE, 0, 0, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("failed to update vnode oper status %d\n", result_code);
+ DELETE_IF_NOT_NULL(vbrifkey);
+ return result_code;
+ }
+
+ VtnMoMgr *vtn_mgr = reinterpret_cast<VtnMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VTN)));
+ if (!vtn_mgr) {
+ UPLL_LOG_DEBUG("Returning error\n");
+ DELETE_IF_NOT_NULL(vbrifkey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = vtn_mgr->TxUpdateDtState(UNC_KT_VTN, 0, 0, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("failed to update vtn oper status %d\n", result_code);
+ }
+ }
+ DELETE_IF_NOT_NULL(vbrifkey);
+ return result_code;
+}
- SetOperStatus<val_vbr_if, val_db_vbr_if_st>
- (tmp, keytype, IpctSt::kIpcStKeyVbrIf, dmi, notification);
- /* Iterate Next record */
- tmp = tmp->get_next_cfg_key_val();
+upll_rc_t VbrIfMoMgr::GetVbrIfFromVExternal(uint8_t *vtn_name,
+ uint8_t *vext_name,
+ ConfigKeyVal *&tmpckv,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_DEBUG(" vtn_name - %s, vext_name - %s", vtn_name, vext_name);
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone };
+ if (tmpckv) {
+ UPLL_LOG_INFO("tmpckv is NULL");
+ return UPLL_RC_ERR_GENERIC;
}
+ key_vbr_if_t *key_vbrif = static_cast<key_vbr_if_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vbr_if_t)));
+ uuu::upll_strncpy(key_vbrif->vbr_key.vtn_key.vtn_name,
+ vtn_name, (kMaxLenVtnName + 1));
+ val_drv_vbr_if_t *drv_val_vbrif = static_cast<val_drv_vbr_if_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_drv_vbr_if_t)));
+ drv_val_vbrif->valid[PFCDRV_IDX_VEXT_NAME_VBRIF] = UNC_VF_VALID;
+ uuu::upll_strncpy(drv_val_vbrif->vex_name,
+ vext_name, (kMaxLenVnodeName + 1));
+ tmpckv = new ConfigKeyVal(UNC_KT_VBR_IF, IpctSt::kIpcStKeyVbrIf, key_vbrif,
+ new ConfigVal(IpctSt::kIpcStPfcdrvValVbrIf, drv_val_vbrif));
+ if (tmpckv == NULL) {
+ free(key_vbrif);
+ free(drv_val_vbrif);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = ReadConfigDB(tmpckv, UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("vbrif ReadConfigDB Failed result_code - %d",
+ result_code);
+ }
+ UPLL_LOG_DEBUG("tmpckv is %s", tmpckv->ToStrAll().c_str());
+ return result_code;
+}
+
+upll_rc_t VbrIfMoMgr::IsLogicalPortAndVlanIdInUse(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ ConfigKeyVal *ckv_vbrif = NULL;
+ val_vbr_if *vbrif_val = NULL;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ if (!ikey || !(ikey->get_cfg_val()))
+ return UPLL_RC_ERR_GENERIC;
+
+ result_code = GetChildConfigKey(ckv_vbrif, NULL);
+ if ((ckv_vbrif == NULL) || (result_code != UPLL_RC_SUCCESS))
+ return UPLL_RC_ERR_GENERIC;
+ if (UPLL_DT_IMPORT == req->datatype) {
+ val_drv_vbr_if * vbr_drv = static_cast<val_drv_vbr_if *>(GetVal(ikey));
+ if (!vbr_drv) {
+ DELETE_IF_NOT_NULL(ckv_vbrif);
+ return UPLL_RC_SUCCESS;
+ }
+ vbrif_val = &vbr_drv->vbr_if_val;
+ } else {
+ vbrif_val = &(static_cast<val_drv_vbr_if *>(GetVal(ikey))->vbr_if_val);
+ }
+ if (!vbrif_val) {
+ UPLL_LOG_DEBUG("Returning error\n");
+ DELETE_IF_NOT_NULL(ckv_vbrif);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (vbrif_val->valid[UPLL_IDX_PM_VBRI] == UNC_VF_VALID) {
+ val_drv_vbr_if *drv_if_val = reinterpret_cast<val_drv_vbr_if *>
+ (ConfigKeyVal::Malloc(sizeof(val_drv_vbr_if)));
+ val_vbr_if_t *if_val = &drv_if_val->vbr_if_val;
+ if (vbrif_val->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] == UNC_VF_VALID) {
+ uuu::upll_strncpy(if_val->portmap.logical_port_id,
+ vbrif_val->portmap.logical_port_id,
+ kMaxLenLogicalPortId+1);
+ if_val->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] = UNC_VF_VALID;
+ if_val->valid[UPLL_IDX_PM_VBRI] = UNC_VF_VALID;
+ }
+#if 0
+ if (vbrif_val->portmap.valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID) {
+ if_val->portmap.vlan_id = vbrif_val->portmap.vlan_id;
+ if_val->portmap.valid[UPLL_IDX_VLAN_ID_PM] =
+ vbrif_val->portmap.valid[UPLL_IDX_VLAN_ID_PM];
+ }
+ if ((vbrif_val->portmap.valid[UPLL_IDX_TAGGED_PM] == UNC_VF_VALID) ||
+ (vbrif_val->portmap.valid[UPLL_IDX_TAGGED_PM] ==
+ UNC_VF_VALID_NO_VALUE)) {
+ if_val->portmap.tagged = vbrif_val->portmap.tagged;
+ if_val->portmap.valid[UPLL_IDX_TAGGED_PM] =
+ vbrif_val->portmap.valid[UPLL_IDX_TAGGED_PM];
+ }
#endif
- result_code = UpdateOperStatus(vbrifkey,dmi,notification,false);
+ ckv_vbrif->AppendCfgVal(IpctSt::kIpcStPfcdrvValVbrIf, drv_if_val);
+ SET_USER_DATA(ckv_vbrif, ikey);
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchCtrlr | kOpMatchDomain,
+ kOpInOutFlag};
+ result_code = ReadConfigDB(ckv_vbrif, UPLL_DT_CANDIDATE, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (result_code == UPLL_RC_SUCCESS) {
+ ConfigKeyVal *tmp = ckv_vbrif;
+ while (tmp) {
+ if (!memcmp(ikey->get_key(), tmp->get_key(),
+ sizeof(key_vbr_if_t))) {
+ UPLL_LOG_TRACE("Looking on the Same key");
+ } else {
+ bool match = false;
+ val_vbr_if_t *if_val = &reinterpret_cast<val_drv_vbr_if *>
+ (GetVal(tmp))->vbr_if_val;
+ if (vbrif_val->portmap.valid[UPLL_IDX_VLAN_ID_PM]
+ == UNC_VF_VALID) {
+ if (if_val->portmap.vlan_id == vbrif_val->portmap.vlan_id) {
+ if (if_val->portmap.tagged == vbrif_val->portmap.tagged)
+ match = true;
+ }
+ } else {
+ if (if_val->portmap.valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID) {
+ if (if_val->portmap.tagged == vbrif_val->portmap.tagged)
+ match = true;
+ } else
+ match = true;
+ }
+ if (match) {
+ UPLL_LOG_DEBUG("More than one vbridge interface is configured "
+ " same logical port id and vlanid!");
+ delete ckv_vbrif;
+ ckv_vbrif = tmp = NULL;
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ }
+ tmp = tmp->get_next_cfg_key_val();
+ }
+ } else if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ result_code = UPLL_RC_SUCCESS;
+ }
+ }
+ delete ckv_vbrif, ckv_vbrif = NULL;
+ return result_code;
+}
+
+upll_rc_t VbrIfMoMgr::PathFaultHandler(const char *ctrlr_name,
+ const char *domain_id,
+ std::vector<std::string> &ingress_ports,
+ std::vector<std::string> &egress_ports,
+ bool alarm_asserted,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ UPLL_LOG_DEBUG("Alarm_asserted is %d", alarm_asserted);
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+
+ set<key_vnode_type_t, key_vnode_type_compare> sw1_vbridge_set,
+ sw2_vbridge_set;
+ set<key_vnode_type_t, key_vnode_type_compare>::iterator vbridge1set_itr,
+ vbridge2set_itr;
+ set<key_vnode_type_t, key_vnode_type_compare> vnode_set;
+ set<key_vnode_type_t, key_vnode_type_compare>::iterator vnodeset_itr;
+ set<key_vlink_t, vlink_compare> vlink_set;
+ set<key_vnode_if_t, key_vnode_if_compare> boundary_if_set;
+ state_notification notification = (alarm_asserted == UPLL_OPER_STATUS_UP) ?
+ kPathFault : kPathFaultReset;
+
+ std::vector<int>::size_type ingress_size = ingress_ports.size();
+ for (uint8_t port_count = 0; port_count < ingress_size; port_count++) {
+ UPLL_LOG_DEBUG("ingress port : %s", ingress_ports[port_count].c_str());
+
+ /* Get all the vbridges connected to sw1*/
+ result_code = GetMappedVbridges(ctrlr_name, domain_id,
+ ingress_ports[port_count],
+ dmi, &sw1_vbridge_set);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error in reading mapped vbridges: %d", result_code);
+ return result_code;
+ }
+ }
+
+ std::vector<int>::size_type egress_size = egress_ports.size();
+ for (uint8_t port_count = 0; port_count < egress_size; port_count++) {
+ UPLL_LOG_DEBUG("egress port : %s", egress_ports[port_count].c_str());
+
+ /* Get all the vbridges connected to sw2*/
+ result_code = GetMappedVbridges(ctrlr_name, domain_id,
+ egress_ports[port_count],
+ dmi, &sw2_vbridge_set);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error in reading mapped vbridges: %d", result_code);
+ return result_code;
+ }
+ }
+
+ /* Iterating through all the vbridges in the vbridge1 set*/
+ for (vbridge1set_itr = sw1_vbridge_set.begin();
+ vbridge1set_itr != sw1_vbridge_set.end(); ) {
+
+ /* Get the connected topology of each vbridge in sw1_vbridge set */
+ VlinkMoMgr *vlink_mgr = reinterpret_cast<VlinkMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VLINK)));
+
+ key_vnode_type temp_vnode_key = *vbridge1set_itr++;
+ key_vnode_type src_vnode_key;
+ memcpy(&(src_vnode_key), &temp_vnode_key, sizeof(key_vnode_type_t));
+ vnode_set.insert(src_vnode_key);
+ vlink_mgr->GetConnected(&src_vnode_key, &vnode_set,
+ &vlink_set, &boundary_if_set, dmi);
+
+ /* Iterating through all the vbridges in the vbridge2 set*/
+ for (vbridge2set_itr = sw2_vbridge_set.begin();
+ vbridge2set_itr != sw2_vbridge_set.end(); ) {
+ /* check if any vbridge in sw2_vbridge set belongs to connected topology
+ of a vbridge in sw1_vbridge set */
+ key_vnode_type_t vn = *vbridge2set_itr++;
+
+ vnodeset_itr = vnode_set.find(vn);
+
+ /* If the vbridge in sw2_vbridge set belongs to the connected toplogy
+ of the vbridge in sw1_vbridge set update the path fault status of
+ the corresponding vnodes in the connected topology of the src vbridge
+ in sw1_vbridge set */
+ if (vnodeset_itr == vnode_set.end())
+ continue;
+ result_code = vlink_mgr->UpdateVlinkOperStatusUsingVlinkSet(
+ &vlink_set, dmi, notification);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Operstatus updation failed");
+ return result_code;
+ }
+
+ set<key_vnode_type_t, key_vnode_type_compare>::iterator vnode_set_iter;
+ set<key_vnode_type_t, key_vnode_type_compare>::iterator vnode_set_end =
+ vnode_set.end();
+ for (vnode_set_iter = vnode_set.begin();
+ vnode_set_iter != vnode_set_end;
+ ++vnode_set_iter) {
+ VnodeChildMoMgr *mgr = reinterpret_cast<VnodeChildMoMgr *>
+ (const_cast<MoManager*>(GetMoManager((*vnode_set_iter).key_type)));
+ result_code = mgr->SetLinkedIfOperStatusforPathFault(*vnode_set_iter,
+ notification,
+ dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Errorin updating Operstatus for Pathfault");
+ return result_code;
+ }
+ }
+
+ result_code = SetBoundaryIfOperStatusforPathFault(
+ boundary_if_set, notification, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Errorin updating Operstatus for Pathfault");
+ return result_code;
+ }
+
+ /*remove the vnodes whose oper status is updated from sw2_vbridge_set and
+ from sw1_vbridge_set*/
+
+ for (vnodeset_itr = vnode_set.begin(); vnodeset_itr != vnode_set_end;) {
+ key_vnode_type_t vn = *vnodeset_itr++;
+ key_vnode_type_t vn1 = *vbridge2set_itr;
+ if (memcmp(&vn, &vn1 ,sizeof(key_vnode_type_t)) == 0)
+ vbridge2set_itr++;
+ sw2_vbridge_set.erase(vn);
+ vn1 = *vbridge1set_itr;
+ if (memcmp(&vn, &vn1, sizeof(key_vnode_type_t)) == 0)
+ vbridge1set_itr++;
+ sw1_vbridge_set.erase(vn);
+ }
+ }
+ boundary_if_set.clear();
+ vnode_set.clear();
+ vlink_set.clear();
+ }
+ result_code = RestoreUnInitOPerStatus(dmi);
+ return result_code;
+}
+
+/*This function gives the bridges connected to a particular switch log port*/
+upll_rc_t VbrIfMoMgr::GetMappedVbridges(
+ const char *ctrlr_name,
+ const char *domain_id,
+ std::string logportid, DalDmlIntf *dmi,
+ set<key_vnode_type_t, key_vnode_type_compare> *sw_vbridge_set) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ck_vbr_if = NULL;
+ result_code = GetChildConfigKey(ck_vbr_if, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed");
+ return result_code;
+ }
+ SET_USER_DATA_CTRLR(ck_vbr_if, ctrlr_name);
+ SET_USER_DATA_DOMAIN(ck_vbr_if, domain_id);
+ ConfigVal *cv_val = NULL;
+ result_code = AllocVal(cv_val, UPLL_DT_RUNNING);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Invalid oper status update %d",result_code);
+ UPLL_LOG_DEBUG("GetChildConfigKey failed");
+ DELETE_IF_NOT_NULL(ck_vbr_if);
+ return result_code;
+ }
+ ck_vbr_if->SetCfgVal(cv_val);
+ val_vbr_if *vbr_if_val = reinterpret_cast<val_vbr_if *>(GetVal(ck_vbr_if));
+ if (!vbr_if_val) {
+ UPLL_LOG_DEBUG("ConfigVal is NULL");
+ DELETE_IF_NOT_NULL(ck_vbr_if);
return UPLL_RC_ERR_GENERIC;
}
- delete vbrifkey;
+
+ /* copy switch id to val_vbr_if strcuture */
+ /*Setting portmap and switch_id valid status*/
+ vbr_if_val->valid[UPLL_IDX_PM_VBRI] = UNC_VF_VALID;
+ vbr_if_val->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] = UNC_VF_VALID;
+ uuu::upll_strncpy(vbr_if_val->portmap.logical_port_id, logportid.c_str(),
+ (kMaxLenPortName + 1));
+
+ /* Get all the vbridges under the VTN */
+ DbSubOp dbop = { kOpReadMultiple,
+ kOpMatchCtrlr | kOpMatchDomain,
+ kOpInOutNone };
+ result_code = ReadConfigDB(ck_vbr_if, UPLL_DT_RUNNING, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ DELETE_IF_NOT_NULL(ck_vbr_if);
+ return UPLL_RC_SUCCESS;
+ } else if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error in reading: %d", result_code);
+ DELETE_IF_NOT_NULL(ck_vbr_if);
+ return result_code;
+ }
+ /* populate sw_vbridge set with vbridges mapped to the specified switch*/
+ key_vbr_if_t *tkey = reinterpret_cast<key_vbr_if_t *>
+ (ck_vbr_if->get_key());
+ key_vbr_t *vbr_key = reinterpret_cast<key_vbr_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vbr_t)));
+ uuu::upll_strncpy(vbr_key->vbridge_name, tkey->vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+ uuu::upll_strncpy(vbr_key->vtn_key.vtn_name,
+ tkey->vbr_key.vtn_key.vtn_name,
+ (kMaxLenVtnName + 1));
+ key_vnode_type_t vnode_type;
+ vnode_type.vnode_key = *(reinterpret_cast<key_vnode_t *>(vbr_key));
+ vnode_type.key_type = UNC_KT_VBR_IF;
+ sw_vbridge_set->insert(vnode_type);
+ ConfigKeyVal::Free(vbr_key);
+ DELETE_IF_NOT_NULL(ck_vbr_if);
+ return result_code;
+}
+
+upll_rc_t VbrIfMoMgr::GetBoundaryInterfaces(key_vnode_if_t boundary_if,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *&iokey) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ GetChildConfigKey(iokey, NULL);
+ key_vnode_if *vnode_if_key = reinterpret_cast<key_vnode_if*>
+ (iokey->get_key());
+ memcpy(vnode_if_key, &boundary_if, sizeof(key_vnode_if));
+
+ /* Get all the vbridges under the VTN */
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
+ result_code = ReadConfigDB(iokey, UPLL_DT_STATE, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ return result_code;
+}
+
+upll_rc_t VbrIfMoMgr::SetBoundaryIfOperStatusforPathFault(
+ const set<key_vnode_if_t, key_vnode_if_compare> &boundary_if_set,
+ state_notification notification,
+ DalDmlIntf *dmi) {
+ set<key_vnode_if_t, key_vnode_if_compare>::iterator boundary_if_set_iter;
+ set<key_vnode_if_t, key_vnode_if_compare>::iterator boundary_if_set_end =
+ boundary_if_set.end();
+ ConfigKeyVal *ck_boundary_if = NULL;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+
+ for (boundary_if_set_iter = boundary_if_set.begin();
+ boundary_if_set_iter != boundary_if_set_end;
+ ++boundary_if_set_iter) {
+ result_code = GetBoundaryInterfaces(*boundary_if_set_iter, dmi,
+ ck_boundary_if);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Operstatus updation failed");
+ DELETE_IF_NOT_NULL(ck_boundary_if);
+ return result_code;
+ }
+ while (ck_boundary_if != NULL) {
+ ConfigKeyVal *ckv_tmp = ck_boundary_if;
+ ck_boundary_if = ck_boundary_if->get_next_cfg_key_val();
+ result_code = UpdateOperStatus(ckv_tmp, dmi, notification,
+ true, false, false);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Operstatus updation failed");
+ DELETE_IF_NOT_NULL(ckv_tmp);
+ DELETE_IF_NOT_NULL(ck_boundary_if);
+ return result_code;
+ }
+ delete ckv_tmp;
+ }
+ }
+ return result_code;
+}
+
+upll_rc_t VbrIfMoMgr::RestoreUnInitOPerStatus(DalDmlIntf *dmi) {
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ VnodeMoMgr *vnode_mgr = NULL;
+ VtnMoMgr *vtn_mgr = NULL;
+ unc_key_type_t key_type[] = {UNC_KT_VBRIDGE, UNC_KT_VROUTER, UNC_KT_VTN};
+ for (int count = 0;
+ count < static_cast<int>(sizeof(key_type)/sizeof(unc_key_type_t));
+ count++) {
+ if (key_type[count] == UNC_KT_VTN) {
+ vtn_mgr = reinterpret_cast<VtnMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(key_type[count])));
+ result_code = vtn_mgr->TxUpdateDtState(key_type[count], 0, 0, dmi);
+ } else {
+ vnode_mgr = reinterpret_cast<VnodeMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(key_type[count])));
+ result_code = vnode_mgr->TxUpdateDtState(key_type[count], 0, 0, dmi);
+ }
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("failed to update vnode oper status %d\n", result_code);
+ // DELETE_IF_NOT_NULL(ck_vnode_if);
+ return result_code;
+ }
+ }
return result_code;
}
#include <set>
#include "momgr_impl.hh"
#include "vnode_child_momgr.hh"
-
+#include "vlink_momgr.hh"
namespace unc {
namespace upll {
namespace kt_momgr {
-// TODO(owner): remove once driver header file included
-enum VexDefines {
- UPLL_IDX_VBR_IF_DRV_PM = 0,
- UPLL_IDX_VEXT_DRV_PM,
- UPLL_IDX_VEXT_IF_DRV_PM,
- UPLL_IDX_VEXT_LINK_DRV_PM
-};
-
#if 0
enum vbr_if_numbers {
VBR_IF_1 = 0x80,
} val_drv_vbr_if_t;
-
-enum val_drv_vbr_if_index {
- UPLL_IDX_DESC_DRV_VBRI = 0,
- UPLL_IDX_ADMIN_STATUS_DRV_VBRI,
- UPLL_IDX_PM_DRV_VBRI
-};
-
class VbrIfMoMgr : public VnodeChildMoMgr {
private:
static unc_key_type_t vbr_if_child[];
static BindInfo vbr_if_bind_info[];
static BindInfo key_vbr_if_maintbl_bind_info[];
- /* @brief Returns portmap information if portmap is valid
- * Else returns NULL for portmap
+ /* @brief Returns admin and portmap information if portmap is
+ * valid. Else returns NULL for portmap
*
* @param[in] ikey Pointer to ConfigKeyVal
* @param[out] valid_pm portmap is valid
*
**/
virtual upll_rc_t GetPortMap(ConfigKeyVal *ikey, uint8_t &valid_pm,
- val_port_map_t *&pm) {
+ val_port_map_t *&pm, uint8_t &valid_admin,
+ uint8_t &admin_status) {
UPLL_FUNC_TRACE;
if (ikey == NULL) return UPLL_RC_ERR_GENERIC;
val_drv_vbr_if *drv_vbrif = reinterpret_cast<val_drv_vbr_if *>
pm = &ifval->portmap;
else
pm = NULL;
+ valid_admin = ifval->valid[UPLL_IDX_ADMIN_STATUS_VBRI];
+ admin_status = ifval->admin_status;
return UPLL_RC_SUCCESS;
}
valid[UPLL_IDX_TAGGED_PM];
break;
case uudst::vbridge_interface::kDbiVexName:
+ valid = &(reinterpret_cast<val_drv_vbr_if_t *>(val))->
+ valid[PFCDRV_IDX_VEXT_NAME_VBRIF];
+ break;
case uudst::vbridge_interface::kDbiVexIfName:
+ valid = &(reinterpret_cast<val_drv_vbr_if_t *>(val))->
+ valid[PFCDRV_IDX_VEXTIF_NAME_VBRIF];
+ break;
case uudst::vbridge_interface::kDbiVexLinkName:
- valid = &(reinterpret_cast<val_vbr_if *>(val))->portmap.
- valid[UPLL_IDX_LOGICAL_PORT_ID_PM];
+ valid = &(reinterpret_cast<val_drv_vbr_if_t *>(val))->
+ valid[PFCDRV_IDX_VLINK_NAME_VBRIF];
break;
default:
return UPLL_RC_ERR_GENERIC;
* associated attributes are supported on the given controller,
* based on the valid flag.
*
- * @param[in] crtlr_name Controller name.
+ * @param[in] attrs Pointer to controller attribute.
* @param[in] ikey Corresponding key and value structure.
* @param[in] operation Operation name.
+ * @param[in] dt_type Data type name
*
* @retval UPLL_RC_SUCCESS validation succeeded.
* @retval UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT Instance count limit is exceeds.
* @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute Not_Supported.
* @retval UPLL_RC_ERR_GENERIC Generic failure.
*/
- upll_rc_t ValVbrIfAttributeSupportCheck(const char *ctrlr_name,
- ConfigKeyVal *ikey, unc_keytype_operation_t operation,
- upll_keytype_datatype_t dt_type);
-
+ upll_rc_t ValVbrIfAttributeSupportCheck(const uint8_t *attrs,
+ ConfigKeyVal *ikey,
+ unc_keytype_operation_t operation,
+ upll_keytype_datatype_t dt_type);
+
/**
* @Brief Checks if the specified key type and
* associated attributes are supported on the given controller,
upll_keytype_datatype_t datatype,
DalDmlIntf *dmi);
+ /* @brief Updates vbrif portmap structure
+ * based on valid[PORTMAP] flag.
+ *
+ * @param[in] db_key Pointer to the ConfigKeyVal structure in db
+ * @param[in] datatype DB type.
+ * @param[in] dmi Pointer to the DalDmlIntf(DB Interface)
+ * @param[in] ikey Pointer to input ConfigKeyVal
+ *
+ * @retval UPLL_RC_SUCCESS Completed successfully.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ *
+ **/
+ upll_rc_t UpdatePortMap(ConfigKeyVal *db_key,
+ upll_keytype_datatype_t datatype,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ikey);
/**
* @brief Method used to Update the Values in the specified key type.
**/
upll_rc_t DupConfigKeyVal(ConfigKeyVal *&okey,
ConfigKeyVal *&req, MoMgrTables tbl = MAINTBL);
- upll_rc_t GetMappedVbridges(uint8_t *logportid, DalDmlIntf *dmi,
- set<key_vnode_t>*sw_vbridge_set);
- upll_rc_t GetMappedInterfaces(key_vbr_t *vbr_key, DalDmlIntf *dmi,
- ConfigKeyVal *&ikey);
+ upll_rc_t GetMappedVbridges(const char* ctrlr_id, const char *domain_id,
+ std::string logportid, DalDmlIntf *dmi,
+ set<key_vnode_type_t,key_vnode_type_compare>*sw_vbridge_set);
/* create mo has to handle vex creation */
/**
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi);
- upll_rc_t CreateAuditMoImpl(IpcReqRespHeader *req,
- ConfigKeyVal *ikey, DalDmlIntf *dmi, const char *ctrlr_id);
+ upll_rc_t CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi, const char *ctrlr_id);
upll_rc_t updateVbrIf(IpcReqRespHeader *req,
ConfigKeyVal *ikey, DalDmlIntf *dmi);
upll_rc_t ConverttoDriverPortMap(ConfigKeyVal *ck_port_map);
uuc::UpdateCtrlrPhase phase,
bool *ctrlr_affected,
DalDmlIntf *dmi);
+
+ upll_rc_t GetVbrIfFromVExternal(uint8_t *vtn_name,
+ uint8_t *vext_name,
+ ConfigKeyVal *&tmpckv,
+ DalDmlIntf *dmi) ;
/**
* @brief Update controller with the new created / updated / deleted configuration
**/
upll_rc_t GetParentConfigKey(ConfigKeyVal *&okey,
ConfigKeyVal *parent_key);
+ upll_rc_t IsLogicalPortAndVlanIdInUse(ConfigKeyVal *ckv,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req);
+ upll_rc_t PathFaultHandler(const char *ctrlr_name,
+ const char *domain_id,
+ std::vector<std::string> &ingress_ports,
+ std::vector<std::string> &egress_ports,
+ bool alarm_asserted,
+ DalDmlIntf *dmi);
+ upll_rc_t GetBoundaryInterfaces(key_vnode_if_t boundary_if,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *&ikey);
+ /**
+ * @brief Method to set the operstatus of boundary interfaces
+ * and corresponding parent elements
+ *
+ * @param[in] boundary_if_set set containing all the boundary interfaces
+ * @param[in] notification pathfault/pathfaultreset notification
+ * @param[in] dmi Pointer to DalDmlIntf class
+ *
+ *
+ * @retval UPLL_RC_SUCCESS Success.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ upll_rc_t SetBoundaryIfOperStatusforPathFault(
+ const set<key_vnode_if_t, key_vnode_if_compare> &boundary_if_set,
+ state_notification notification,
+ DalDmlIntf *dmi);
+ upll_rc_t RestoreUnInitOPerStatus(DalDmlIntf *dmi);
};
} // namespace kt_momgr
#include "vtn_policingmap_momgr.hh"
#include "vbr_if_policingmap_momgr.hh"
#include "vbr_if_momgr.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "upll_validation.hh"
#include "unc/upll_ipc_enum.h"
namespace upll {
namespace kt_momgr {
-#define VBRIF_KEY_COL 5
-#define POLICY_KEY_COL 5
#define VTN_RENAME 0x01
-#define VBR_RENAME 0x10
+#define VBR_RENAME 0x02
#define POLICINGPROFILE_RENAME 0x04
+#define NO_POLICINGPROFILE_RENAME 0xFB
#define VLINK_CONFIGURED 0x01
#define PORTMAP_CONFIGURED 0x02
#define VLINK_PORTMAP_CONFIGURED 0x03
-#define SET_FLAG_VLINK 0x08
-#define SET_FLAG_PORTMAP 0x0A
-#define SET_FLAG_VLINK_PORTMAP 0x018
+#define SET_FLAG_PORTMAP 0x20
+#define SET_FLAG_VLINK 0x40
+#define SET_FLAG_VLINK_PORTMAP 0x80
+#define SET_FLAG_NO_VLINK_PORTMAP ~SET_FLAG_VLINK_PORTMAP
BindInfo VbrIfPolicingMapMoMgr::vbrifpolicingmap_bind_info[] = {
{ uudst::vbr_if_policingmap::kDbiVtnName, CFG_KEY,
{ uudst::vbr_if_policingmap::kDbiVbrName, CFG_MATCH_KEY,
offsetof(key_vbr_if_t, vbr_key.vbridge_name),
uud::kDalChar, (kMaxLenVnodeName + 1) },
- { uudst::vbr_if_policingmap::kDbiVbrIfName, CFG_MATCH_KEY,
- offsetof(key_vbr_if_t, if_name),
- uud::kDalChar, (kMaxLenInterfaceName + 1) },
{ uudst::vbr_if_policingmap::kDbiVtnName, CFG_INPUT_KEY,
offsetof(key_rename_vnode_info_t, new_unc_vtn_name),
uud::kDalChar, (kMaxLenVtnName + 1) },
{ uudst::vbr_if_policingmap::kDbiVbrName, CFG_INPUT_KEY,
offsetof(key_rename_vnode_info_t, new_unc_vnode_name),
uud::kDalChar, (kMaxLenVnodeName + 1) },
- { uudst::vbr_if_policingmap::kDbiFlags, CFG_INPUT_KEY,
- offsetof(key_user_data_t, flags),
- uud::kDalUint8, 1 }
-};
-
-// Rename
-BindInfo VbrIfPolicingMapMoMgr::
-key_vbrifpm_policyname_maintbl_rename_bind_info[] = {
- { uudst::vbr_if_policingmap::kDbiVtnName, CFG_MATCH_KEY,
- offsetof(key_vbr_if_t, vbr_key.vtn_key.vtn_name),
- uud::kDalChar, (kMaxLenVtnName + 1) },
- { uudst::vbr_if_policingmap::kDbiVbrName, CFG_MATCH_KEY,
- offsetof(key_vbr_if_t, vbr_key.vbridge_name),
- uud::kDalChar, (kMaxLenVnodeName + 1) },
- { uudst::vbr_if_policingmap::kDbiPolicername, CFG_INPUT_KEY,
- offsetof(key_rename_vnode_info_t, new_policingprofile_name),
- uud::kDalChar, (kMaxLenPolicingProfileName + 1) },
- { uudst::vbr_if_policingmap::kDbiFlags, CFG_INPUT_KEY,
+ { uudst::vbr_if_policingmap::kDbiFlags, CK_VAL,
offsetof(key_user_data_t, flags),
uud::kDalUint8, 1 }
};
nchild = 0;
child = NULL;
+ cur_instance_count = 0;
+}
+
+upll_rc_t VbrIfPolicingMapMoMgr::RestorePOMInCtrlTbl(
+ ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl,
+ DalDmlIntf* dmi) {
+
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ if (!ikey || !(ikey->get_key())) {
+ UPLL_LOG_DEBUG("Input Key Not Valid");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (tbl != MAINTBL ||
+ (ikey->get_key_type() != UNC_KT_VBRIF_POLICINGMAP)) {
+ UPLL_LOG_DEBUG("Ignoring ktype/Table kt=%d, tbl=%d",
+ ikey->get_key_type(), tbl);
+ return result_code;
+ }
+
+ val_policingmap_t *val_pm = reinterpret_cast<val_policingmap_t *>
+ (GetVal(ikey));
+ if (NULL == val_pm) {
+ UPLL_LOG_DEBUG(" Value structure is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (UNC_VF_VALID == val_pm->valid[UPLL_IDX_POLICERNAME_PM]) {
+ result_code = UpdateRefCountInPPCtrlr(ikey, dt_type, dmi,
+ UNC_OP_CREATE);
+ if (UPLL_RC_SUCCESS != result_code) {
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Failed to update PolicingProfile in CtrlrTbl err %d",
+ result_code);
+ return result_code;
+ }
+ }
+ }
+ return result_code;
}
upll_rc_t VbrIfPolicingMapMoMgr::CreateCandidateMo(IpcReqRespHeader *req,
DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
if (NULL == ikey || NULL == req || NULL == dmi) {
- pfc_log_debug("CreateCandidateMo Failed. Insufficient input parameters");
+ UPLL_LOG_DEBUG("CreateCandidateMo Failed. Insufficient input parameters");
return UPLL_RC_ERR_GENERIC;
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
-
+ uint8_t *ctrlr_id = NULL;
+ val_policingmap_t *val_import = NULL;
+ pfcdrv_val_vbrif_policingmap *pfc_val_import = NULL;
+ UPLL_LOG_DEBUG("datatype (%d)", req->datatype);
+ if (req->datatype == UPLL_DT_IMPORT) {
+ if (ikey->get_cfg_val() && (ikey->get_cfg_val()->get_st_num() == IpctSt::kIpcStPfcdrvValVbrifPolicingmap)) {
+ UPLL_LOG_TRACE("ikey = %s", ikey->ToStrAll().c_str());
+ UPLL_LOG_TRACE("val struct num (%d)",ikey->get_cfg_val()->get_st_num());
+ pfc_val_import = reinterpret_cast<pfcdrv_val_vbrif_policingmap *>(ikey->get_cfg_val()->get_val());
+ if (pfc_val_import->valid[PFCDRV_IDX_VAL_POLICINGMAP_PM] == UNC_VF_VALID) {
+ val_import = reinterpret_cast<val_policingmap_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_policingmap_t)));
+ memcpy(val_import, &pfc_val_import->val_policing_map, sizeof(val_policingmap_t));
+ UPLL_LOG_DEBUG("policer name (%s)", val_import->policer_name);
+ ikey->SetCfgVal(NULL);
+ ikey->SetCfgVal(new ConfigVal(IpctSt::kIpcStValPolicingmap, val_import));
+ }
+ }
+ }
+ UPLL_LOG_TRACE("%s ikey PRINT", ikey->ToStrAll().c_str());
// validate syntax and semantics
result_code = ValidateMessage(req, ikey);
if (result_code != UPLL_RC_SUCCESS) {
- pfc_log_error("ValidateMessage Err (%d)", result_code);
+ UPLL_LOG_INFO("ValidateMessage Err (%d)", result_code);
return result_code;
}
result_code = ValidateAttribute(ikey, dmi, req);
}
ConfigKeyVal *okey = NULL;
- result_code = GetControllerId(ikey, okey, dmi);
+ ConfigKeyVal *tmp_key = NULL;
+
+ result_code = GetControllerId(ikey, okey, req->datatype, dmi);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetControllerId failed %d", result_code);
return result_code;
}
- delete okey;
- // Capability Check
- result_code = ValidateCapability(req, ikey);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Key not supported by controller");
+ GET_USER_DATA_CTRLR(okey, ctrlr_id);
+ UPLL_LOG_TRACE("ctrlrid %s", ctrlr_id);
+
+ result_code = GetChildConfigKey(tmp_key, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(okey);
+ UPLL_LOG_DEBUG("GetChildConfigKey failed:%d", result_code);
return result_code;
}
+
// Check VBRIF object existence in VbrIfPolicingMap CANDIDATE DB
// if record exists, return the error code
result_code = IsReferenced(ikey, req->datatype, dmi);
if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
UPLL_LOG_DEBUG("CreateCandidateMo Object exists in CANDIDATE DB (%d)",
result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
} else if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
UPLL_LOG_DEBUG("CreateCandidateMo Instance Available");
} else if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("CreateCandidateMo Error Accesing CANDIDATE DB (%d)",
result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
UPLL_LOG_DEBUG("Profile Object (%d) not available in CANDIDATE DB",
result_code);
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_CFG_SEMANTIC;
} else {
UPLL_LOG_DEBUG("CreateCandidateMo Error Accesing CANDIDATEDB(%d)",
result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ }
+ }
+
+ // Check if Object exists in RUNNING DB and move it to CANDIDATE DB
+ if (req->datatype == UPLL_DT_CANDIDATE) {
+ result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
+ MAINTBL);
+ if ((result_code != UPLL_RC_ERR_INSTANCE_EXISTS) &&
+ (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG(" Is Exist check operation failed: err code(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
+ result_code = RestoreChildren(ikey, req->datatype, UPLL_DT_RUNNING, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Restore Operation Failed, err %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
}
+ }
+
+ result_code = GetInstanceCount(tmp_key, reinterpret_cast<char*>(ctrlr_id),
+ req->datatype,
+ &cur_instance_count,
+ dmi, MAINTBL);
+ DELETE_IF_NOT_NULL(tmp_key);
+ if(result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetInstanceCount Failed:Err code-%d",
+ result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+
+ // Capability Check
+ result_code = ValidateCapability(req, ikey, reinterpret_cast<char *>(ctrlr_id));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Key not supported by controller");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+
+ if (UNC_VF_VALID == val_pm->valid[UPLL_IDX_POLICERNAME_PM]) {
// 1)Get vbrif associated ctrlr name and invoke the PP and PPE functions to
// check the refcount capability and update the refcount or create the
// record in policingprofilectrltbl and policingprofileentryctrltbl.
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("UpdateRefCountInPPCtrlr Err in CANDIDATE DB(%d)",
result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
}
result_code = mgrvbrif->GetVexternal(ckv, req->datatype, dmi,
vexternal, vex_if, flags);
+ DELETE_IF_NOT_NULL(ckv);
+ FREE_IF_NOT_NULL(vexternal);
+ FREE_IF_NOT_NULL(vex_if);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetVexternal failed %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
UPLL_LOG_DEBUG("GetVexternal flag %d", flags);
uint8_t flag_port_map = 0;
+ GET_USER_DATA_FLAGS(ikey, flag_port_map);
if (flags & VLINK_CONFIGURED) {
UPLL_LOG_DEBUG("VLINK_CONFIGURED");
- flag_port_map = SET_FLAG_VLINK;
+ flag_port_map = flag_port_map | SET_FLAG_VLINK;
} else if (flags & PORTMAP_CONFIGURED) {
UPLL_LOG_DEBUG("PORTMAP_CONFIGURED");
- flag_port_map = SET_FLAG_PORTMAP;
+ flag_port_map = flag_port_map | SET_FLAG_PORTMAP;
} else if (flags & VLINK_PORTMAP_CONFIGURED) {
UPLL_LOG_DEBUG("VLINK_PORTMAP_CONFIGURED");
- flag_port_map = SET_FLAG_VLINK_PORTMAP;
- } else {
- UPLL_LOG_DEBUG("flag_port_map 0");
- flag_port_map = 0;
+ flag_port_map = flag_port_map | SET_FLAG_VLINK_PORTMAP;
}
UPLL_LOG_DEBUG("flag_port_map %d", flag_port_map);
UPLL_LOG_DEBUG("CreateCandidateMo failed. UpdateConfigDb failed."
"Record creation failed - %d",
result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
UPLL_LOG_DEBUG("CreateCandidateMo Successful");
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
result_code = UpdateRefCountInPPCtrlr(okey, req->datatype, dmi,
UNC_OP_DELETE);
if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(okey);
UPLL_LOG_DEBUG("UpdateRefCountInPPCtrlr Error DB (%d)", result_code);
return result_code;
}
}
// Delete the record in vbrifpolicingmap table
- result_code = UpdateConfigDB(ikey, UPLL_DT_CANDIDATE, UNC_OP_DELETE, dmi,
+ result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_DELETE, dmi,
MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("DeleteMo Failed. UpdateConfigdb failed to delete - %d",
result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
+ DELETE_IF_NOT_NULL(okey);
UPLL_LOG_DEBUG("DeleteMo Success");
return UPLL_RC_SUCCESS;
}
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
- ConfigKeyVal *tmp_key = NULL;
-
// validate syntax and semantics
result_code = ValidateMessage(req, ikey);
if (result_code != UPLL_RC_SUCCESS) {
return result_code;
}
- ConfigKeyVal *okey = NULL;
- result_code = GetControllerId(ikey, okey, dmi);
+ result_code = SetRenameFlag(ikey, dmi, req);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("GetControllerId failed %d", result_code);
+ UPLL_LOG_DEBUG(" SetRenameFlag failed %d", result_code);
return result_code;
}
- delete okey;
- // Capability Check
- result_code = ValidateCapability(req, ikey);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Key not supported by controller");
+ ConfigKeyVal *okey = NULL;
+ result_code = GetControllerId(ikey, okey, req->datatype, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetControllerId failed %d", result_code);
return result_code;
}
+ delete okey;
+ okey = NULL;
// Check VBRIF object existence in VbrIfPolicingMap CANDIDATE DB
// If record not exists, return error
result_code = ReadConfigDB(tmpckv, req->datatype, UNC_OP_READ, dbop, dmi,
MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(tmpckv);
UPLL_LOG_DEBUG("ReadConfigDB failed");
return result_code;
}
uint8_t *ctrlr_id = NULL;
GET_USER_DATA_CTRLR(tmpckv, ctrlr_id);
SET_USER_DATA_CTRLR(ikey, ctrlr_id);
+
+ // Capability Check
+ result_code = ValidateCapability(req, ikey, reinterpret_cast<char*>(ctrlr_id));
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(tmpckv);
+ UPLL_LOG_DEBUG("Key not supported by controller");
+ return result_code;
+ }
+
val_policingmap_t *val_tmp_val = reinterpret_cast<val_policingmap_t *>
(GetVal(tmpckv));
if (UNC_VF_VALID == val_ival->valid[UPLL_IDX_POLICERNAME_PM] &&
result_code = UpdateRefCountInPPCtrlr(tmpckv, req->datatype, dmi,
UNC_OP_DELETE);
if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(tmpckv);
UPLL_LOG_DEBUG("UpdateMo UpdateRefCountInPPCtrlr error in delete (%d)",
result_code);
return result_code;
}
+
result_code = UpdateRefCountInPPCtrlr(ikey, req->datatype, dmi,
UNC_OP_CREATE);
if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(tmpckv);
UPLL_LOG_DEBUG("UpdateMo UpdateRefCountInPPCtrlr error in create (%d)",
result_code);
return result_code;
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("UpdateMo UpdateRefCountInPPCtrlr error in create (%d)",
result_code);
+ DELETE_IF_NOT_NULL(tmpckv);
return result_code;
}
} else if (UNC_VF_VALID == val_tmp_val->valid[UPLL_IDX_POLICERNAME_PM] &&
result_code = UpdateRefCountInPPCtrlr(tmpckv, req->datatype, dmi,
UNC_OP_DELETE);
if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(tmpckv);
UPLL_LOG_DEBUG("UpdateMo UpdateRefCountInPPCtrlr error in create (%d)",
result_code);
return result_code;
}
// Update the record in CANDIDATE DB
+ uint8_t temp_flag = 0;
+ GET_USER_DATA_FLAGS(ikey, temp_flag);
+ UPLL_LOG_DEBUG("Flag in ikey: %d", temp_flag);
+ DbSubOp dbop1 = {kOpNotRead, kOpMatchNone, kOpInOutFlag};
result_code = UpdateConfigDB(ikey, req->datatype, req->operation, dmi,
- MAINTBL);
+ &dbop1, MAINTBL);
+ DELETE_IF_NOT_NULL(tmpckv);
UPLL_LOG_TRACE("VtnPolicingMapMoMgr::UpdateMo update record status (%d)",
result_code);
- CONFIGKEYVALCLEAN(tmp_key);
return result_code;
}
result_code = UPLL_RC_SUCCESS;
}
delete okey;
+
+ result_code = SetRenameFlag(ikey, dmi, req);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("SetRenameFlag failed %d", result_code);
+ return result_code;
+ }
UPLL_LOG_DEBUG("ValidateAttribute Successfull.");
return result_code;
}
(const_cast<MoManager *>(GetMoManager
(UNC_KT_POLICING_PROFILE_ENTRY)));
result_code = ppe_mgr->ValidateValidElements(reinterpret_cast
- <const char *>(val_pm->policer_name), dmi, UPLL_DT_CANDIDATE);
+ <const char *>(val_pm->policer_name), dmi, dt_type);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("ValidateValidElements failed %d", result_code);
delete okey;
return result_code;
}
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_SUCCESS;
}
UNC_KT_POLICING_PROFILE)));
if (!pp_mgr) {
UPLL_LOG_TRACE("pp_mgr obj failure (%d)", result_code);
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
#if 0
UNC_KT_POLICING_PROFILE_ENTRY)));
if (!ppe_mgr) {
UPLL_LOG_TRACE("ppe_mgr obj failure (%d)", result_code);
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
#endif
if (NULL == ctrlr_id) {
UPLL_LOG_DEBUG("UpdateRefCountInPPCtrlr ctrlr_id NULL (%d)",
result_code);
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("PolicingProfileCtrlrTblOper err (%d)", result_code);
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
reinterpret_cast<const char*>(ctrlr_id), dmi, op, dt_type);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("PolicingProfileEntryCtrlrTblOper err (%d)", result_code);
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
#endif
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_SUCCESS;
}
upll_rc_t VbrIfPolicingMapMoMgr::GetControllerId(ConfigKeyVal *ikey,
ConfigKeyVal *&okey,
+ upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
(kMaxLenVnodeName + 1));
DbSubOp dbop = { kOpReadSingle, kOpMatchNone,
kOpInOutCtrlr|kOpInOutDomain };
- result_code = mgr->ReadConfigDB(okey, UPLL_DT_CANDIDATE, UNC_OP_READ, dbop,
+ result_code = mgr->ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop,
dmi, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetControllerId ReadConfigDB failed (%d)", result_code);
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
result_code = ReadDTStateNormal(req, ikey, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadDTStateNormal failed");
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
}
} else if ((req->option1 == UNC_OPT1_DETAIL) &&
UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
return result_code;
}
+ key_vbr_if_t *key_if = reinterpret_cast<key_vbr_if_t *>
+ (temp_vbr_if_key->get_key());
val_policingmap_t *val_pm = reinterpret_cast
<val_policingmap_t *>(GetVal(temp_vbr_if_key));
ConfigKeyVal *ppe_ckv = NULL;
temp_req->option1 = UNC_OPT1_NORMAL;
// result_code = mgr->ReadInfoFromDB(req, ppe_ckv, dmi, &ctrlr_dom);
result_code = mgr->ReadSiblingMo(temp_req, ppe_ckv, dmi);
+ req->rep_count = temp_req->rep_count;
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Read sibling of ppe failed (%d)", result_code);
+ ConfigKeyVal::Free(temp_req);
return result_code;
}
+ ConfigKeyVal::Free(temp_req);
ConfigKeyVal *temp_ppe_ckv = ppe_ckv;
ConfigKeyVal *okey = NULL;
while (NULL != temp_ppe_ckv) {
key_vbrif_policingmap_entry_t *temp_vbrif_pm_key = reinterpret_cast
<key_vbrif_policingmap_entry_t *>(temp_vbrif_pm_ckv->get_key());
temp_vbrif_pm_key->sequence_num = temp_ppe_key->sequence_num;
+ uuu::upll_strncpy(reinterpret_cast<char*>(temp_vbrif_pm_key->vbrif_key.if_name),
+ reinterpret_cast<char*>(key_if->if_name),
+ (kMaxLenVnodeName + 1));
result_code = ReadDTStateNormal(req, temp_vbrif_pm_ckv, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadDTStateNormal failed");
}
val_policingmap_t *val_pm = reinterpret_cast
<val_policingmap_t *>(GetVal(temp_vbr_if_key));
+ key_vbr_if_t *key_if = reinterpret_cast<key_vbr_if_t *>
+ (temp_vbr_if_key->get_key());
ConfigKeyVal *ppe_ckv = NULL;
result_code = ConstructPpeCkv(ppe_ckv, reinterpret_cast
<const char *>(val_pm->policer_name),
temp_req->option1 = UNC_OPT1_NORMAL;
// result_code = mgr->ReadInfoFromDB(req, ppe_ckv, dmi, &ctrlr_dom);
result_code = mgr->ReadSiblingMo(temp_req, ppe_ckv, dmi);
+ req->rep_count = temp_req->rep_count;
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Read sibling of ppe failed (%d)", result_code);
+ ConfigKeyVal::Free(temp_req);
return result_code;
}
+ ConfigKeyVal::Free(temp_req);
+
ConfigKeyVal *temp_ppe_ckv = ppe_ckv;
ConfigKeyVal *okey = NULL;
while (NULL != temp_ppe_ckv) {
key_vbrif_policingmap_entry_t *temp_vbrif_pm_key = reinterpret_cast
<key_vbrif_policingmap_entry_t *>(temp_vbrif_pm_ckv->get_key());
temp_vbrif_pm_key->sequence_num = temp_ppe_key->sequence_num;
+ uuu::upll_strncpy(reinterpret_cast<char*>(temp_vbrif_pm_key->vbrif_key.if_name),
+ reinterpret_cast<char*>(key_if->if_name),
+ (kMaxLenVnodeName + 1));
UPLL_LOG_DEBUG("vbrifpmentry sequence_num - %d", result_code);
result_code = ReadEntryDetailRecord(req, temp_vbrif_pm_ckv, dmi);
if (UPLL_RC_SUCCESS != result_code) {
dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadConfigDB Error (%d)", result_code);
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
}
result_code = DupConfigKeyVal(l_key, ikey, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("DupConfigKeyVal Faill in ReadSiblingMo for l_key");
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
}
GET_USER_DATA_CTRLR_DOMAIN(dup_key, ctrlr_dom);
SET_USER_DATA_CTRLR_DOMAIN(l_key, ctrlr_dom);
GET_USER_DATA_FLAGS(dup_key, db_flag);
+ result_code = ValidateCapability(req, ikey, reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ UPLL_LOG_DEBUG("Key not supported by controller");
+ return result_code;
+ }
+
// GET_USER_DATA_FLAGS(dup_key, db_flag);
UPLL_LOG_DEBUG("db_flag ::: (%d)", db_flag);
result_code = GetRenamedControllerKey(l_key, req->datatype,
dmi, &ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetRenamedControllerKey Faill");
- CONFIGKEYVALCLEAN(dup_key);
- CONFIGKEYVALCLEAN(l_key);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
return result_code;
}
pfcdrv_val_vbrif_policingmap *pfc_val =
(ConfigKeyVal::Malloc(sizeof(pfcdrv_val_vbrif_vextif_t)));
UPLL_LOG_DEBUG("GetVexternalInformation (%d)", req->datatype);
- if (req->datatype == UPLL_DT_STATE) req->datatype = UPLL_DT_RUNNING;
- string s(l_key->ToStrAll());
- result_code = GetVexternalInformation(dup_key, req->datatype, pfc_val,
+ result_code = GetVexternalInformation(dup_key, UPLL_DT_RUNNING, pfc_val,
pfc_val_ext, db_flag, dmi);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetVexternalInformation fail");
- CONFIGKEYVALCLEAN(dup_key);
- CONFIGKEYVALCLEAN(l_key);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
return result_code;
}
UPLL_LOG_DEBUG("SendReqToDriver failed for Key %d controller %s",
l_key->get_key_type(),
reinterpret_cast<char *>(ctrlr_dom.ctrlr));
- CONFIGKEYVALCLEAN(l_key);
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(dup_key);
return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_DEBUG("Driver response for Key %d controller %s result %d",
l_key->get_key_type(), ctrlr_dom.ctrlr,
ipc_response.header.result_code);
- CONFIGKEYVALCLEAN(l_key);
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(dup_key);
return ipc_response.header.result_code;
}
ConfigKeyVal *okey = NULL;
dbop, dmi, &okey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadSiblingDetail Error (%d)", result_code);
- CONFIGKEYVALCLEAN(dup_key);
- CONFIGKEYVALCLEAN(l_key);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
return result_code;
} else {
if (okey != NULL) {
MoMgrTables tbl) {
UPLL_FUNC_TRACE;
UPLL_LOG_DEBUG("GetRenameKeyBindInfo (%d) (%d)", key_type, tbl);
- switch (key_type) {
- case UNC_KT_VBRIF_POLICINGMAP:
- nattr = VBRIF_KEY_COL;
- binfo = key_vbrifpm_maintbl_rename_bind_info;
- break;
- case UNC_KT_POLICING_PROFILE:
- nattr = POLICY_KEY_COL;
- binfo = key_vbrifpm_policyname_maintbl_rename_bind_info;
- break;
- default:
- UPLL_LOG_DEBUG("GetRenameKeyBindInfo Invalid key type (%d) (%d)",
- key_type, tbl);
- return PFC_FALSE;
- }
+ nattr = sizeof(key_vbrifpm_maintbl_rename_bind_info)/
+ sizeof(key_vbrifpm_maintbl_rename_bind_info[0]);
+ binfo = key_vbrifpm_maintbl_rename_bind_info;
return PFC_TRUE;
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
- if (UNC_KT_VBRIF_POLICINGMAP == ikey->get_key_type()) {
- key_rename_vnode_info *key_rename =
- reinterpret_cast<key_rename_vnode_info *>(ikey->get_key());
- key_vbr_if_t *key_vbr_if = reinterpret_cast<key_vbr_if_t *>
- (ConfigKeyVal::Malloc(sizeof(key_vbr_if_t)));
- if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vtn_name))) {
- UPLL_LOG_DEBUG("old_unc_vtn_name NULL");
- free(key_vbr_if);
- return UPLL_RC_ERR_GENERIC;
- }
+ key_rename_vnode_info *key_rename =
+ reinterpret_cast<key_rename_vnode_info *>(ikey->get_key());
+ key_vbr_if_t *key_vbr_if = reinterpret_cast<key_vbr_if_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vbr_if_t)));
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vtn_name))) {
+ UPLL_LOG_DEBUG("old_unc_vtn_name NULL");
+ FREE_IF_NOT_NULL(key_vbr_if);
+ return UPLL_RC_ERR_GENERIC;
+ }
- uuu::upll_strncpy(key_vbr_if->vbr_key.vtn_key.vtn_name,
- key_rename->old_unc_vtn_name,
- (kMaxLenVtnName+1));
+ uuu::upll_strncpy(key_vbr_if->vbr_key.vtn_key.vtn_name,
+ key_rename->old_unc_vtn_name,
+ (kMaxLenVtnName+1));
+ if (UNC_KT_VBRIDGE == ikey->get_key_type()) {
if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vnode_name))) {
UPLL_LOG_DEBUG("old_unc_vnode_name NULL");
- free(key_vbr_if);
+ FREE_IF_NOT_NULL(key_vbr_if);
return UPLL_RC_ERR_GENERIC;
}
uuu::upll_strncpy(key_vbr_if->vbr_key.vbridge_name,
- key_rename->old_unc_vnode_name,
- (kMaxLenVnodeName+1));
-
- okey = new ConfigKeyVal(UNC_KT_VBRIF_POLICINGMAP, IpctSt::kIpcStKeyVbrIf,
- key_vbr_if, NULL);
- if (!okey) {
- UPLL_LOG_DEBUG("okey NULL");
- free(key_vbr_if);
- return UPLL_RC_ERR_GENERIC;
- }
- } else if (UNC_KT_POLICING_PROFILE == ikey->get_key_type()) {
- key_rename_vnode_info_t *key_rename =
- reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
-
- val_policingmap_t *val = reinterpret_cast<val_policingmap_t *>
- (ConfigKeyVal::Malloc(sizeof(val_policingmap_t)));
-
- if (!strlen(reinterpret_cast<char *>
- (key_rename->old_policingprofile_name))) {
- UPLL_LOG_DEBUG("old_policingprofile_name NULL");
- free(val);
+ key_rename->old_unc_vnode_name, (kMaxLenVnodeName + 1));
+ } else {
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_unc_vnode_name))) {
+ UPLL_LOG_DEBUG("new_unc_vnode_name NULL");
+ FREE_IF_NOT_NULL(key_vbr_if);
return UPLL_RC_ERR_GENERIC;
}
+ uuu::upll_strncpy(key_vbr_if->vbr_key.vbridge_name,
+ key_rename->new_unc_vnode_name, (kMaxLenVnodeName + 1));
+ }
- uuu::upll_strncpy(val->policer_name,
- key_rename->old_policingprofile_name,
- (kMaxLenPolicingProfileName+1));
- ConfigVal *cval = new ConfigVal(IpctSt::kIpcStValPolicingmap, val);
- okey = new ConfigKeyVal(UNC_KT_POLICING_PROFILE,
- IpctSt::kIpcStKeyPolicingprofile, NULL, cval);
- if (!okey) {
- UPLL_LOG_DEBUG("okey NULL");
- free(val);
- return UPLL_RC_ERR_GENERIC;
- }
- } else {
- UPLL_LOG_DEBUG("CopyToConfigKey invalid key type NULL");
+ okey = new ConfigKeyVal(UNC_KT_VBRIF_POLICINGMAP, IpctSt::kIpcStKeyVbrIf,
+ key_vbr_if, NULL);
+ if (!okey) {
+ UPLL_LOG_DEBUG("okey NULL");
+ FREE_IF_NOT_NULL(key_vbr_if);
return UPLL_RC_ERR_GENERIC;
}
return result_code;
}
-upll_rc_t VbrIfPolicingMapMoMgr::MergeValidate(unc_key_type_t keytype,
- const char *ctrlr_id,
- ConfigKeyVal *ikey,
- DalDmlIntf *dmi) {
+upll_rc_t VbrIfPolicingMapMoMgr::UpdateVnodeVal(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t data_type,
+ bool &no_rename) {
UPLL_FUNC_TRACE;
+ ConfigKeyVal *okey = NULL;
+ ConfigKeyVal *kval = NULL;
+ controller_domain ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+
+ uint8_t rename = 0;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
- ConfigKeyVal *tkey;
- ConfigKeyVal *pp_keyval = NULL;
- if (NULL == ikey) {
- UPLL_LOG_DEBUG("MergeValidate Failed:Insufficient input parameters ");
+
+ key_rename_vnode_info_t *key_rename =
+ reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
+
+ UPLL_LOG_DEBUG("CopyToConfigKey datatype (%d)", data_type);
+ // Copy the old policer name in val_policingmap
+ val_policingmap_t *val = reinterpret_cast<val_policingmap_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_policingmap_t)));
+ if (!val) return UPLL_RC_ERR_GENERIC;
+
+ memset(val, 0, sizeof(val_policingmap_t));
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_policingprofile_name))) {
+ UPLL_LOG_DEBUG("key_rename->old_policingprofile_name NULL");
+ FREE_IF_NOT_NULL(val);
return UPLL_RC_ERR_GENERIC;
}
- result_code = ReadConfigDB(ikey, UPLL_DT_IMPORT, UNC_OP_READ, dbop, dmi,
- MAINTBL);
+ uuu::upll_strncpy(val->policer_name,
+ key_rename->old_policingprofile_name,
+ (kMaxLenPolicingProfileName + 1));
+ val->valid[UPLL_IDX_POLICERNAME_PM] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("policer name and valid (%d) (%s)",
+ val->valid[UPLL_IDX_POLICERNAME_PM], val->policer_name);
+
+ result_code = GetChildConfigKey(okey, NULL);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("MergeValidate Failed:ReadConfigDB Failed%d", result_code);
- return result_code;
+ UPLL_LOG_DEBUG("CopyToConfigKey okey NULL");
+ FREE_IF_NOT_NULL(val);
+ return result_code;
}
-
- MoMgrImpl *mgr =
- reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
- UNC_KT_POLICING_PROFILE)));
- if (NULL == mgr) {
- UPLL_LOG_DEBUG("mgr NULL");
+ if (!okey) {
+ free(val);
return UPLL_RC_ERR_GENERIC;
}
+ okey->SetCfgVal(new ConfigVal(IpctSt::kIpcStValPolicingmap, val));
- tkey = ikey;
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain|kOpInOutFlag };
- while (ikey != NULL) {
- result_code = mgr->GetChildConfigKey(pp_keyval, NULL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("MergeValidate Failed:GetChildConfigKey Failed - %d",
- result_code);
+ // Read the record of key structure and old policer name in maintbl
+ result_code = ReadConfigDB(okey, data_type, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG(" ReadConfigDB failed ");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ ConfigKeyVal *first_ckv = okey;
+ while (okey != NULL) {
+ UPLL_LOG_DEBUG("okey not NULL");
+ // Update the new policer name in MAINTBL
+ result_code = GetChildConfigKey(kval, okey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey kval NULL");
+ DELETE_IF_NOT_NULL(first_ckv);
return result_code;
}
- if (!pp_keyval) return UPLL_RC_ERR_GENERIC;
- val_policingmap_t *policingmap_val =
- reinterpret_cast<val_policingmap_t *>(GetVal(ikey));
+ if (!kval) return UPLL_RC_ERR_GENERIC;
+ // Copy the new policer name in val_policingmap
+ val_policingmap_t *val1 = reinterpret_cast<val_policingmap_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_policingmap_t)));
+ if (!val1) return UPLL_RC_ERR_GENERIC;
+ memset(val1, 0, sizeof(val_policingmap_t));
+
+ // New name null check
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_policingprofile_name))) {
+ FREE_IF_NOT_NULL(val1);
+ UPLL_LOG_DEBUG("new_policingprofile_name NULL");
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(first_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ // Copy the new policer name into val_policingmap
+ uuu::upll_strncpy(val1->policer_name,
+ key_rename->new_policingprofile_name,
+ (kMaxLenPolicingProfileName + 1));
+ val1->valid[UPLL_IDX_POLICERNAME_PM] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("policer name and valid (%d) (%s)",
+ val1->valid[UPLL_IDX_POLICERNAME_PM], val1->policer_name);
+ ConfigVal *cval1 = new ConfigVal(IpctSt::kIpcStValPolicingmap, val1);
+
+ kval->SetCfgVal(cval1);
+#if 0
+ ConfigKeyVal *okey1 = NULL;
+ result_code = GetControllerId(data_type, okey, okey1, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetControllerId failed %d", result_code);
+ return result_code;
+ }
+ delete okey1;
+#endif
+ GET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
+ GET_USER_DATA_FLAGS(okey, rename);
+
+ UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
- key_policingprofile_t *key_policingprofie =
- reinterpret_cast<key_policingprofile_t *>(pp_keyval->get_key());
+ UPLL_LOG_DEBUG("okey flag (%d)", rename);
- uuu::upll_strncpy(key_policingprofie->policingprofile_name,
- policingmap_val->policer_name,
- (kMaxLenPolicingProfileName + 1));
+ if (!no_rename)
+ rename = rename | POLICINGPROFILE_RENAME;
+ else
+ rename = rename & NO_POLICINGPROFILE_RENAME;
+
+ SET_USER_DATA_FLAGS(kval, rename);
+ SET_USER_DATA_CTRLR_DOMAIN(kval, ctrlr_dom);
+
+ UPLL_LOG_DEBUG("kval flag (%d)", rename);
+ // Update the new policer name in MAINTBL
+ result_code = UpdateConfigDB(kval, data_type, UNC_OP_UPDATE, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Create record Err in vtnpolicingmaptbl CANDIDATE DB(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(first_ckv);
+ return result_code;
+ }
+
+ DELETE_IF_NOT_NULL(kval);
+
+ okey = okey->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(first_ckv);
+ return result_code;
+}
+
+upll_rc_t VbrIfPolicingMapMoMgr::MergeValidate(unc_key_type_t keytype,
+ const char *ctrlr_id,
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ckval = NULL;
+ if (NULL == ctrlr_id) {
+ UPLL_LOG_DEBUG("MergeValidate ctrlr_id NULL");
+ return result_code;
+ }
+
+ result_code = GetChildConfigKey(ckval, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey ckval NULL");
+ return result_code;
+ }
+
+ if (!ckval) return UPLL_RC_ERR_GENERIC;
- result_code = mgr->UpdateConfigDB(pp_keyval, UPLL_DT_CANDIDATE, UNC_OP_READ,
- dmi, MAINTBL);
- if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
- UPLL_LOG_DEBUG("Verification policing profile is not configured");
- CONFIGKEYVALCLEAN(pp_keyval);
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain};
+ result_code = ReadConfigDB(ckval, UPLL_DT_IMPORT,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ckval);
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ return result_code;
+ }
+ return UPLL_RC_SUCCESS;
+ }
+ ConfigKeyVal *first_ckv = ckval;
+ while (NULL != ckval) {
+ result_code = UpdateConfigDB(ckval, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
+ MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ UPLL_LOG_DEBUG("Merge Conflict");
+ result_code = DupConfigKeyVal(ikey, ckval, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal fail");
+ DELETE_IF_NOT_NULL(first_ckv);
+ return result_code;
+ }
return UPLL_RC_ERR_MERGE_CONFLICT;
+ } else if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ ckval = ckval->get_next_cfg_key_val();
+ } else {
+ UPLL_LOG_DEBUG("Merge Conflict DB err");
+ DELETE_IF_NOT_NULL(first_ckv);
+ return result_code;
}
- CONFIGKEYVALCLEAN(pp_keyval);
- ikey = tkey->get_next_cfg_key_val();
}
- CONFIGKEYVALCLEAN(tkey);
- UPLL_LOG_DEBUG("MergeValidate is Successful: %d", result_code);
- return result_code;
+ DELETE_IF_NOT_NULL(first_ckv);
+ return UPLL_RC_SUCCESS;
}
upll_rc_t VbrIfPolicingMapMoMgr::GetRenamedUncKey(
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *unc_key = NULL;
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
-
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vbrifpm start",
+ ikey->ToStrAll().c_str());
if (NULL == ikey || NULL == dmi || NULL == ctrlr_id) {
UPLL_LOG_DEBUG("GetRenamedUncKey failed. Insufficient input parameters.");
return UPLL_RC_ERR_GENERIC;
val_rename_vnode *rename_vnode = reinterpret_cast<val_rename_vnode *>
(ConfigKeyVal::Malloc(sizeof(val_rename_vnode)));
-
+ if (!rename_vnode) {
+ UPLL_LOG_DEBUG("rename_vnode NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
key_vbr_if_t *ctrlr_key = reinterpret_cast<key_vbr_if_t *>(ikey->get_key());
if (NULL == ctrlr_key) {
+ UPLL_LOG_DEBUG("ctrlr_key NULL");
free(rename_vnode);
return UPLL_RC_ERR_GENERIC;
}
uuu::upll_strncpy(rename_vnode->ctrlr_vtn_name,
ctrlr_key->vbr_key.vtn_key.vtn_name,
(kMaxLenVtnName + 1));
+ rename_vnode->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
+
uuu::upll_strncpy(rename_vnode->ctrlr_vnode_name,
ctrlr_key->vbr_key.vbridge_name,
(kMaxLenVnodeName + 1));
+ rename_vnode->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_VALID;
MoMgrImpl *mgr =
reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
UNC_KT_VBRIDGE)));
if (NULL == mgr) {
+ UPLL_LOG_DEBUG("mgr NULL");
free(rename_vnode);
return UPLL_RC_ERR_GENERIC;
}
result_code = mgr->GetChildConfigKey(unc_key, NULL);
if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
free(rename_vnode);
- pfc_log_debug("GetRenamedUncKey failed. GetChildConfigKey failed to "
- "allocate memory for ConfigKeyVal - %d",
- result_code);
+ mgr = NULL;
return result_code;
}
if (!unc_key) {
+ UPLL_LOG_DEBUG("unc_key NULL");
free(rename_vnode);
+ mgr = NULL;
return UPLL_RC_ERR_GENERIC;
}
result_code = mgr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL);
- if (UPLL_RC_SUCCESS != result_code
- && UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
- CONFIGKEYVALCLEAN(unc_key);
- pfc_log_debug("GetRenamedUncKey failed. ReadConfigDB failed to read %d ",
- result_code);
- return UPLL_RC_ERR_GENERIC;
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(unc_key);
+ mgr = NULL;
+ return result_code;
}
if (UPLL_RC_SUCCESS == result_code) {
}
mgr = NULL;
- CONFIGKEYVALCLEAN(unc_key);
+ DELETE_IF_NOT_NULL(unc_key);
val_rename_policingprofile *rename_policingprofile =
reinterpret_cast<val_rename_policingprofile *>
(ConfigKeyVal::Malloc(sizeof(val_rename_policingprofile)));
+ if (!rename_policingprofile) {
+ UPLL_LOG_DEBUG("rename_policingprofile NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ pfcdrv_val_vbrif_policingmap *pfc_val_import = NULL;
+ val_policingmap_t *val_policingmap = NULL;
- val_policingmap_t *val_policingmap =
- reinterpret_cast<val_policingmap_t *>(GetVal(ikey));
+ if (ikey->get_cfg_val() &&
+ (ikey->get_cfg_val()->get_st_num() ==
+ IpctSt::kIpcStPfcdrvValVbrifPolicingmap)) {
+ UPLL_LOG_TRACE("val struct num (%d)", ikey->get_cfg_val()->get_st_num());
+ pfc_val_import = reinterpret_cast<pfcdrv_val_vbrif_policingmap *>
+ (ikey->get_cfg_val()->get_val());
+ val_policingmap = &pfc_val_import->val_policing_map;
+ UPLL_LOG_DEBUG("policer name (%s)", val_policingmap->policer_name);
+ } else if (ikey->get_cfg_val() &&
+ (ikey->get_cfg_val()->get_st_num() ==
+ IpctSt:: kIpcStValPolicingmap)) {
+ val_policingmap =
+ reinterpret_cast<val_policingmap_t *>(GetVal(ikey));
+ }
if (!val_policingmap) {
UPLL_LOG_DEBUG("val_policingmap NULL");
free(rename_policingprofile);
- free(rename_vnode);
- return UPLL_RC_ERR_GENERIC;
+ return UPLL_RC_SUCCESS;
}
uuu::upll_strncpy(rename_policingprofile->policingprofile_newname,
val_policingmap->policer_name,
(kMaxLenPolicingProfileName + 1));
+ rename_policingprofile->valid[UPLL_IDX_RENAME_PROFILE_RPP] = UNC_VF_VALID;
mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
UNC_KT_POLICING_PROFILE)));
if (NULL == mgr) {
UPLL_LOG_DEBUG("mgr policing profile NULL");
- free(rename_vnode);
free(rename_policingprofile);
return UPLL_RC_ERR_GENERIC;
}
result_code = mgr->GetChildConfigKey(unc_key, NULL);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("GetRenamedUncKey failed. GetChildConfigKey failed to "
- "create policingprofile ConfigKeyVal %d",
- result_code);
- free(rename_vnode);
+ UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
free(rename_policingprofile);
+ mgr = NULL;
return result_code;
}
if (!unc_key) {
- free(rename_vnode);
+ UPLL_LOG_DEBUG("unc_key NULL");
free(rename_policingprofile);
+ mgr = NULL;
return UPLL_RC_ERR_GENERIC;
}
result_code = mgr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL);
- if (UPLL_RC_SUCCESS != result_code
- && UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
UPLL_LOG_DEBUG("GetRenamedUncKey failed. ReadConfigDB failed to read %d ",
result_code);
- CONFIGKEYVALCLEAN(unc_key);
- return UPLL_RC_ERR_GENERIC;
+ DELETE_IF_NOT_NULL(unc_key);
+ mgr = NULL;
+ return result_code;
}
if (result_code == UPLL_RC_SUCCESS) {
}
}
}
- CONFIGKEYVALCLEAN(unc_key);
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vbrifpm end",
+ ikey->ToStrAll().c_str());
+ DELETE_IF_NOT_NULL(unc_key);
+ mgr = NULL;
return UPLL_RC_SUCCESS;
}
ConfigKeyVal *okey = NULL;
if (NULL == ikey || NULL == dmi || NULL == ctrlr_dom) {
- pfc_log_debug(
+ UPLL_LOG_DEBUG(
"GetRenamedControllerKey failed. Insufficient input resources");
return UPLL_RC_ERR_GENERIC;
}
-
- DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutCtrlr };
+// DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutCtrlr };
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr | kOpMatchDomain, kOpInOutCtrlr };
result_code = IsRenamed(ikey, dt_type, dmi, rename);
if (UPLL_RC_SUCCESS != result_code) {
- pfc_log_debug("GetRenamedControllerKey failed. IsRenamed failed to "
+ UPLL_LOG_DEBUG("GetRenamedControllerKey failed. IsRenamed failed to "
"check rename - %d",
result_code);
return result_code;
}
if (0 == rename) {
- pfc_log_debug(
+ UPLL_LOG_DEBUG(
"GetRenamedControllerKey No Rename");
return UPLL_RC_SUCCESS;
}
+ UPLL_LOG_TRACE("Start Input ConfigKeyVal %s", ikey->ToStrAll().c_str());
+
if (rename & VTN_RENAME || rename & VBR_RENAME) {
MoMgrImpl *mgr =
reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
return result_code;
}
if (!okey) return UPLL_RC_ERR_GENERIC;
- key_vbr_if_t *ovbr_key = reinterpret_cast<key_vbr_if_t*>(okey->get_key());
- key_vbr_if_t *ivbr_key = reinterpret_cast<key_vbr_if_t*>(ikey->get_key());
-
- uuu::upll_strncpy(reinterpret_cast<char*>
- (ovbr_key->vbr_key.vtn_key.vtn_name),
- reinterpret_cast<char*>(ivbr_key->vbr_key.vtn_key.vtn_name),
- (kMaxLenVtnName+1));
- uuu::upll_strncpy(reinterpret_cast<char*>(ovbr_key->vbr_key.vbridge_name),
- reinterpret_cast<char*>(ivbr_key->vbr_key.vbridge_name),
- (kMaxLenVnodeName+1));
if (NULL != ctrlr_dom) {
- SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+ SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom)
+ }
+ else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+ if (UNC_KT_VBRIF_POLICINGMAP == ikey->get_key_type()) {
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vbr_t *>(okey->get_key())->vtn_key.vtn_name,
+ reinterpret_cast<key_vbr_if_t *>(ikey->get_key())->vbr_key.vtn_key.vtn_name,
+ (kMaxLenVtnName + 1));
+
+ UPLL_LOG_DEBUG("vtn name (%s) (%s)",
+ reinterpret_cast<key_vbr *>(okey->get_key())->vtn_key.vtn_name,
+ reinterpret_cast<key_vbr_if_t *>(ikey->get_key())->vbr_key.vtn_key.vtn_name);
+
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vbr *>(okey->get_key())->vbridge_name,
+ reinterpret_cast<key_vbr_if_t *>(ikey->get_key())->vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+
+ UPLL_LOG_DEBUG("vbr name (%s) (%s)",
+ reinterpret_cast<key_vbr *>(okey->get_key())->vbridge_name,
+ reinterpret_cast<key_vbr_if_t *>(ikey->get_key())->vbr_key.vbridge_name);
+ } else if (UNC_KT_VBRIF_POLICINGMAP_ENTRY == ikey->get_key_type()) {
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vbr_t *>(okey->get_key())->vtn_key.vtn_name,
+ reinterpret_cast<key_vbrif_policingmap_entry_t *>
+ (ikey->get_key())->vbrif_key.vbr_key.vtn_key.vtn_name,
+ (kMaxLenVtnName + 1));
+
+ UPLL_LOG_DEBUG("vtn name (%s) (%s)",
+ reinterpret_cast<key_vbr *>(okey->get_key())->vtn_key.vtn_name,
+ reinterpret_cast<key_vbrif_policingmap_entry_t *>
+ (ikey->get_key())->vbrif_key.vbr_key.vtn_key.vtn_name);
+
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vbr *>(okey->get_key())->vbridge_name,
+ reinterpret_cast<key_vbrif_policingmap_entry_t *>
+ (ikey->get_key())->vbrif_key.vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+
+ UPLL_LOG_DEBUG("vbr name (%s) (%s)",
+ reinterpret_cast<key_vbr *>(okey->get_key())->vbridge_name,
+ reinterpret_cast<key_vbrif_policingmap_entry_t *>
+ (ikey->get_key())->vbrif_key.vbr_key.vbridge_name);
}
/* TODO Commented the below code to fix the compilation issues */
result_code = mgr->ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL);
if (result_code != UPLL_RC_SUCCESS) {
- pfc_log_debug("GetRenamedControllerKey failed. ReadConfigDB failed "
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB no instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("GetRenamedControllerKey failed. ReadConfigDB failed "
"to read vbr renametbl - %d",
result_code);
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
val_rename_vnode_t *rename_val =
reinterpret_cast<val_rename_vnode_t *>(GetVal(okey));
if (!rename_val) {
- CONFIGKEYVALCLEAN(okey);
+ UPLL_LOG_DEBUG("rename_val null");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
if (rename & VTN_RENAME) { // vtn renamed
- uuu::upll_strncpy(ivbr_key->vbr_key.vtn_key.vtn_name,
- rename_val->ctrlr_vtn_name,
- (kMaxLenVtnName + 1));
+ UPLL_LOG_DEBUG("vtn name renamed");
+ if (UNC_KT_VBRIF_POLICINGMAP == ikey->get_key_type()) {
+ uuu::upll_strncpy(reinterpret_cast<key_vbr_if_t *>(ikey->get_key())
+ ->vbr_key.vtn_key.vtn_name,
+ rename_val->ctrlr_vtn_name,
+ (kMaxLenVtnName + 1));
+ } else if (UNC_KT_VBRIF_POLICINGMAP_ENTRY == ikey->get_key_type()) {
+ uuu::upll_strncpy(reinterpret_cast<key_vbrif_policingmap_entry_t *>
+ (ikey->get_key())->vbrif_key.vbr_key.vtn_key.vtn_name,
+ rename_val->ctrlr_vtn_name,
+ (kMaxLenVtnName + 1));
+ }
}
+
if (rename & VBR_RENAME) { // vnode renamed
- uuu::upll_strncpy(ivbr_key->vbr_key.vbridge_name,
- rename_val->ctrlr_vnode_name,
- (kMaxLenVnodeName + 1));
+ UPLL_LOG_DEBUG("vbr name renamed");
+ if (UNC_KT_VBRIF_POLICINGMAP == ikey->get_key_type()) {
+ uuu::upll_strncpy(reinterpret_cast<key_vbr_if_t *>(ikey->get_key())
+ ->vbr_key.vbridge_name,
+ rename_val->ctrlr_vnode_name,
+ (kMaxLenVnodeName + 1));
+ } else if (UNC_KT_VBRIF_POLICINGMAP_ENTRY == ikey->get_key_type()) {
+ uuu::upll_strncpy(reinterpret_cast<key_vbrif_policingmap_entry_t *>
+ (ikey->get_key())->vbrif_key.vbr_key.vbridge_name,
+ rename_val->ctrlr_vnode_name,
+ (kMaxLenVnodeName + 1));
+ }
}
- SET_USER_DATA_FLAGS(ikey, rename);
+ DELETE_IF_NOT_NULL(okey);
mgr = NULL;
}
- CONFIGKEYVALCLEAN(okey);
-
+ if (UNC_KT_VBRIF_POLICINGMAP == ikey->get_key_type()) {
if (rename & POLICINGPROFILE_RENAME) {
+ UPLL_LOG_DEBUG("policing profile name renamed");
MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>
(GetMoManager(UNC_KT_POLICING_PROFILE)));
if (NULL == mgr) {
return result_code;
}
if (!okey) return UPLL_RC_ERR_GENERIC;
+
+ if (NULL != ctrlr_dom) {
+ SET_USER_DATA_CTRLR(okey, ctrlr_dom->ctrlr);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
val_policingmap_t *val_policingmap =
reinterpret_cast<val_policingmap_t *>(GetVal(ikey));
+ if (!val_policingmap)
+ return UPLL_RC_SUCCESS;
+
key_policingprofile_t *key_policingprofile =
reinterpret_cast<key_policingprofile_t *>(okey->get_key());
if (NULL == val_policingmap || NULL == key_policingprofile) {
- UPLL_LOG_DEBUG("mgr NULL");
- CONFIGKEYVALCLEAN(okey);
+ UPLL_LOG_DEBUG("val or key struct is NULL");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
val_policingmap->policer_name,
(kMaxLenPolicingProfileName + 1));
- if (ctrlr_dom != NULL) {
- SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
- }
-
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutCtrlr };
result_code = mgr->ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL);
if (result_code != UPLL_RC_SUCCESS) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB no instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
UPLL_LOG_DEBUG("GetRenamedControllerKey failed. ReadConfigDB failed "
"to read policingprofile renametbl - %d",
result_code);
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
reinterpret_cast<val_rename_policingprofile_t *>(GetVal(okey));
if (!rename_policingprofile) {
UPLL_LOG_DEBUG("rename_policingprofile NULL")
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
uuu::upll_strncpy(val_policingmap->policer_name,
rename_policingprofile->policingprofile_newname,
(kMaxLenPolicingProfileName + 1));
- SET_USER_DATA_FLAGS(ikey, rename);
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
+ }
}
- CONFIGKEYVALCLEAN(okey);
return UPLL_RC_SUCCESS;
}
bool VbrIfPolicingMapMoMgr::CompareValidValue(void *&val1, void *val2,
bool audit) {
+ UPLL_FUNC_TRACE;
+ bool invalid_attr = true;
val_policingmap_t *val_pm1 = reinterpret_cast<val_policingmap_t *>(val1);
val_policingmap_t *val_pm2 = reinterpret_cast<val_policingmap_t *>(val2);
- // if (audit) {
- if (UNC_VF_INVALID == val_pm1->valid[UPLL_IDX_POLICERNAME_PM] &&
- UNC_VF_VALID == val_pm2->valid[UPLL_IDX_POLICERNAME_PM])
+ if (UNC_VF_INVALID == val_pm1->valid[UPLL_IDX_POLICERNAME_PM] &&
+ UNC_VF_VALID == val_pm2->valid[UPLL_IDX_POLICERNAME_PM]) {
val_pm1->valid[UPLL_IDX_POLICERNAME_PM] = UNC_VF_VALID_NO_VALUE;
-// }
- if (UNC_VF_VALID == val_pm1->valid[UPLL_IDX_POLICERNAME_PM] &&
+ } else if (UNC_VF_VALID == val_pm1->valid[UPLL_IDX_POLICERNAME_PM] &&
UNC_VF_VALID == val_pm2->valid[UPLL_IDX_POLICERNAME_PM]) {
- if (!strcmp(reinterpret_cast<char*>(val_pm1->policer_name),
- reinterpret_cast<char*>(val_pm2->policer_name)))
- val_pm1->valid[UPLL_IDX_POLICERNAME_PM] = UNC_VF_INVALID;
+ if (!strcmp(reinterpret_cast<char*>(val_pm1->policer_name),
+ reinterpret_cast<char*>(val_pm2->policer_name))) {
+ val_pm1->valid[UPLL_IDX_POLICERNAME_PM] = UNC_VF_INVALID;
+ }
}
- return false;
+ if ((UNC_VF_VALID == (uint8_t)val_pm1->valid[UPLL_IDX_POLICERNAME_PM]) ||
+ (UNC_VF_VALID_NO_VALUE == (uint8_t)val_pm1->valid[UPLL_IDX_POLICERNAME_PM])) {
+ invalid_attr = false;
+ }
+
+ return invalid_attr;
}
bool VbrIfPolicingMapMoMgr::CompareKey(ConfigKeyVal *key1, ConfigKeyVal *key2) {
return match;
}
+#if 0
upll_rc_t VbrIfPolicingMapMoMgr::UpdateConfigStatus(ConfigKeyVal *ckv,
unc_keytype_operation_t op, uint32_t driver_result, ConfigKeyVal *nreq,
DalDmlIntf *dmi, ConfigKeyVal *ctrlr_key) {
val = reinterpret_cast<val_policingmap_t *> (GetVal(ckv));
if (val == NULL) return UPLL_RC_ERR_GENERIC;
if (op == UNC_OP_CREATE) {
- if (val->cs_row_status != UNC_CS_NOT_SUPPORTED)
+ UPLL_LOG_DEBUG("UpdateConfigStatus UNC_OP_CREATE %d", cs_status);
+ val->cs_row_status = cs_status;
+ if (val->cs_row_status != UNC_CS_NOT_SUPPORTED) {
val->cs_row_status = cs_status;
- } else {
- UPLL_LOG_DEBUG("Operation Not Supported.");
- return UPLL_RC_ERR_GENERIC;
+ val->cs_attr[0] = cs_status;
}
+ } else {
+ UPLL_LOG_DEBUG("Operation Not Supported.");
+ return UPLL_RC_ERR_GENERIC;
+ }
UPLL_LOG_DEBUG("Update Config Status Successfull.");
return UPLL_RC_SUCCESS;
}
+#endif
upll_rc_t VbrIfPolicingMapMoMgr::UpdateAuditConfigStatus(
unc_keytype_configstatus_t cs_status,
ConfigKeyVal *&ckv_running) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- val_vbr_t *val;
- val =
- (ckv_running != NULL) ? reinterpret_cast<val_vbr_t *>
- (GetVal(ckv_running)) :NULL;
+ if (NULL == ckv_running)
+ return UPLL_RC_ERR_GENERIC;
+ val_policingmap_t *val;
+ val = reinterpret_cast<val_policingmap_t *>
+ (GetVal(ckv_running));
if (NULL == val) {
UPLL_LOG_DEBUG("vbr_val NULL");
return UPLL_RC_ERR_GENERIC;
}
- if (uuc::kUpllUcpCreate == phase)
+ if (uuc::kUpllUcpCreate == phase )
val->cs_row_status = cs_status;
- for (unsigned int loop = 0; loop < (sizeof(val->valid)/sizeof(uint8_t));
- ++loop) {
- if (cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop])
- val->cs_attr[loop] = cs_status;
- else
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
+ for ( unsigned int loop = 0;
+ loop < sizeof(val->valid)/sizeof(uint8_t); ++loop ) {
+ if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
+ cs_status == UNC_CS_APPLIED)
val->cs_attr[loop] = cs_status;
}
return result_code;
default:
UPLL_LOG_DEBUG("Invalid Index");
valid = NULL;
- break;
+ return UPLL_RC_ERR_GENERIC;
}
}
UPLL_LOG_DEBUG("GetValid IS successful:-");
vbr_if_key, tmp1);
if (!okey) {
if (vbr_if_key) free(vbr_if_key);
- if (policingmap_val) free(policingmap_val);
+ DELETE_IF_NOT_NULL(tmp1);
UPLL_LOG_DEBUG("okey failed");
return UPLL_RC_ERR_GENERIC;
}
if (okey) {
if (okey->get_key_type() != UNC_KT_VBRIF_POLICINGMAP)
return UPLL_RC_ERR_GENERIC;
+ }
+
+ if ((okey) && (okey->get_key())) {
vbr_if_key = reinterpret_cast<key_vbr_if_t *>(okey->get_key());
} else {
vbr_if_key = reinterpret_cast<key_vbr_if_t *>
return UPLL_RC_ERR_GENERIC;
}
+
+ if ((okey) && !(okey->get_key())) {
+ UPLL_LOG_DEBUG("okey not null and flow list name updated");
+ okey->SetKey(IpctSt::kIpcStKeyVbrIf, vbr_if_key);
+ }
+
if (!okey) {
okey = new ConfigKeyVal(UNC_KT_VBRIF_POLICINGMAP,
IpctSt::kIpcStKeyVbrIf, vbr_if_key, NULL);
upll_rc_t rt_code = UPLL_RC_ERR_GENERIC;
if ((NULL == req) || (NULL == key)) {
- UPLL_LOG_DEBUG("ConfigKeyval is NULL");
+ UPLL_LOG_DEBUG("ConfigKeyval/IpcReqRespHeader is NULL");
return UPLL_RC_ERR_BAD_REQUEST;
}
}
if((req->option1 != UNC_OPT1_NORMAL)
&&(req->option1 != UNC_OPT1_DETAIL)) {
- UPLL_LOG_DEBUG(" Error: option1 is not NORMAL");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- if((req->option1 != UNC_OPT1_NORMAL)
- &&(req->operation == UNC_OP_READ_SIBLING_COUNT)) {
- UPLL_LOG_DEBUG(" Error: option1 is not NORMAL for ReadSiblingCount");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
+ UPLL_LOG_DEBUG(" Error: option1 is not NORMAL");
+ return UPLL_RC_ERR_INVALID_OPTION1;
+ }
+
+ if((req->option1 != UNC_OPT1_NORMAL)
+ &&(req->operation == UNC_OP_READ_SIBLING_COUNT)) {
+ UPLL_LOG_DEBUG(" Error: option1 is not NORMAL for ReadSiblingCount");
+ return UPLL_RC_ERR_INVALID_OPTION1;
+ }
+
+ if ((req->option1 == UNC_OPT1_DETAIL) &&
+ (req->datatype != UPLL_DT_STATE)) {
+ UPLL_LOG_DEBUG(" Invalid Datatype(%d)", req->datatype);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
if (UNC_KT_VBRIF_POLICINGMAP == key->get_key_type()) {
+ if ((req->datatype == UPLL_DT_IMPORT) && (req->operation == UNC_OP_READ ||
+ req->operation == UNC_OP_READ_SIBLING ||
+ req->operation == UNC_OP_READ_SIBLING_BEGIN ||
+ req->operation == UNC_OP_READ_NEXT ||
+ req->operation == UNC_OP_READ_BULK ||
+ req->operation == UNC_OP_READ_SIBLING_COUNT)) {
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+
if (key->get_st_num() != IpctSt::kIpcStKeyVbrIf) {
- UPLL_LOG_DEBUG(
- " Invalid structure received expected struct -"
- "kIpcStKeyVbrIf, received struct - %s ",
- reinterpret_cast<const char *>
- (IpctSt::GetIpcStdef(key->get_st_num())));
+ UPLL_LOG_DEBUG("Invalid key structure received. struct num - %d",
+ key->get_st_num());
return UPLL_RC_ERR_BAD_REQUEST;
}
key_vbrif = reinterpret_cast<key_vbr_if_t *>(key->get_key());
} else if (UNC_KT_VBRIF_POLICINGMAP_ENTRY == key->get_key_type()) {
+ if ((req->datatype == UPLL_DT_IMPORT) && (req->operation == UNC_OP_READ ||
+ req->operation == UNC_OP_READ_SIBLING ||
+ req->operation == UNC_OP_READ_SIBLING_BEGIN ||
+ req->operation == UNC_OP_READ_NEXT ||
+ req->operation == UNC_OP_READ_BULK ||
+ req->operation == UNC_OP_READ_SIBLING_COUNT)) {
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+
+ if (req->datatype != UPLL_DT_STATE) {
+ UPLL_LOG_DEBUG(" Unsupported Datatype (%d)", req->datatype);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
if (key->get_st_num() != IpctSt::kIpcStKeyVbrifPolicingmapEntry) {
- UPLL_LOG_DEBUG(
- " Invalid structure received expected struct -"
- "kIpcStKeyVbrifPolicingmapEntry, received struct - %s ",
- reinterpret_cast<const char *>
- (IpctSt::GetIpcStdef(key->get_st_num())));
+ UPLL_LOG_DEBUG("Invalid key structure received. struct num - %d",
+ key->get_st_num());
return UPLL_RC_ERR_BAD_REQUEST;
}
key_vbrif_policingmap_entry =
}
/** Use VbrIfMoMgr api to validate key struct */
+ VbrIfMoMgr *mgrvbrif =
+ reinterpret_cast<VbrIfMoMgr *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_VBR_IF)));
+
+ if (NULL == mgrvbrif) {
+ UPLL_LOG_DEBUG("Unable to get VBR_IF object to validate key_vbrif");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ rt_code = mgrvbrif->ValidateVbrifKey(key_vbrif);
+
+ if (rt_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("key_vbrif validation failed");
+ return rt_code;
+ }
if (UNC_KT_VBRIF_POLICINGMAP_ENTRY == key->get_key_type()) {
/* validate seq number */
- if (!ValidateNumericRange(key_vbrif_policingmap_entry->sequence_num,
- kMinPolicingProfileSeqNum,
- kMaxPolicingProfileSeqNum, true,
- true)) {
- UPLL_LOG_DEBUG("Sequence num syntax validation failed :Err Code - %d",
- rt_code);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- UPLL_LOG_TRACE(
+ if ((req->operation != UNC_OP_READ_SIBLING_COUNT) &&
+ (req->operation != UNC_OP_READ_SIBLING_BEGIN)) {
+ if (!ValidateNumericRange(key_vbrif_policingmap_entry->sequence_num,
+ (uint8_t) kMinPolicingProfileSeqNum,
+ (uint8_t) kMaxPolicingProfileSeqNum, true,
+ true)) {
+ UPLL_LOG_DEBUG("Sequence num syntax validation failed :Err Code - %d",
+ rt_code);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ } else {
+ key_vbrif_policingmap_entry->sequence_num = 0;
+ }
+ UPLL_LOG_DEBUG(
"key struct validation is success for UNC_KT_VBR_POLICINGMAP_ENTRY");
return UPLL_RC_SUCCESS;
}
return UPLL_RC_ERR_BAD_REQUEST;
}
- val_policingmap_t *val_policingmap = NULL;
-
- if (key->get_cfg_val() && (key->get_cfg_val()->get_st_num() ==
- IpctSt::kIpcStValPolicingmap)) {
- val_policingmap =
- reinterpret_cast<val_policingmap_t *>(key->get_cfg_val()->get_val());
- }
-
/** Use VtnPolicingMapMoMgr::ValidatePolicingMapValue
* to validate value structure */
- rt_code = VtnPolicingMapMoMgr::ValidatePolicingMapValue(val_policingmap, req);
+ rt_code = VtnPolicingMapMoMgr::ValidatePolicingMapValue(key, req->operation);
if (UPLL_RC_SUCCESS != rt_code) {
UPLL_LOG_DEBUG(" PolicierName syntax validation failed :"
upll_rc_t rt_code = UPLL_RC_ERR_GENERIC;
- if (NULL == ikey) {
- UPLL_LOG_DEBUG("ConfigKeyval is NULL");
+ if ((NULL == req) || (NULL == ikey)) {
+ UPLL_LOG_DEBUG("IpcReqRespHeader/ConfigKeyval is NULL");
return rt_code;
}
- /** Use VtnPolicingMapMoMgr::ValidateCapability
- * to validate capability for val_policingmap structure*/
- VtnPolicingMapMoMgr *mgrvtnpmap =
- reinterpret_cast<VtnPolicingMapMoMgr *>(const_cast<MoManager *>
- (GetMoManager(UNC_KT_VTN_POLICINGMAP)));
- rt_code = mgrvtnpmap->ValidateCapability(req, ikey);
+ if (!ctrlr_name)
+ ctrlr_name = static_cast<char *>(ikey->get_user_data());
- if (UPLL_RC_SUCCESS != rt_code) {
- UPLL_LOG_DEBUG(" PolicierName Attribute validation failed :"
- "Err Code - %d",
- rt_code);
+ if (NULL == ctrlr_name) {
+ UPLL_LOG_DEBUG(" ctrlr_name is NULL");
+ return rt_code;
}
- return rt_code;
+
+ bool result_code = false;
+ uint32_t max_instance_count = 0;
+ const uint8_t *attrs = NULL;
+ uint32_t max_attrs = 0;
+
+ UPLL_LOG_TRACE("ctrlr_name (%s),operation : (%d)", ctrlr_name, req->operation);
+
+ switch (req->operation) {
+ case UNC_OP_CREATE:
+ result_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_instance_count, &max_attrs, &attrs);
+ if (result_code && (max_instance_count != 0) &&
+ (cur_instance_count >= max_instance_count)) {
+ UPLL_LOG_DEBUG("Instance count %d exceeds %d", cur_instance_count,
+ max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
+ break;
+ case UNC_OP_UPDATE:
+ result_code = GetUpdateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ break;
+ default:
+ if (req->datatype == UPLL_DT_STATE)
+ result_code = GetStateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ else
+ result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ break;
+ }
+
+ if (!result_code) {
+ UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s)"
+ " for operation(%d)",
+ ikey->get_key_type(), ctrlr_name, req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+
+
+ val_policingmap_t *val_policingmap = reinterpret_cast<val_policingmap_t *>(GetVal(ikey));
+ if (val_policingmap) {
+
+ if (max_attrs > 0) {
+
+ if ((val_policingmap->valid[UPLL_IDX_POLICERNAME_PM] == UNC_VF_VALID)
+ || (val_policingmap->valid[UPLL_IDX_POLICERNAME_PM]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtn_policingmap::kCapPolicername] == 0) {
+ val_policingmap->valid[UPLL_IDX_POLICERNAME_PM] =
+ UNC_VF_NOT_SUPPORTED;
+ UPLL_LOG_DEBUG("Policername attr is not supported by ctrlr");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ } else {
+
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d", req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ return UPLL_RC_SUCCESS;
}
upll_rc_t VbrIfPolicingMapMoMgr::GetParentConfigKey(ConfigKeyVal *&okey,
ConfigKeyVal *ikey) {
UPLL_LOG_DEBUG(" Invalid key type received. Key type - %d", ikey_type);
return UPLL_RC_ERR_GENERIC;
}
-
+ DELETE_IF_NOT_NULL(okey);
key_vbr_if_t *pkey = reinterpret_cast<key_vbr_if_t*>(ikey->get_key());
if (!pkey) {
UPLL_LOG_DEBUG(" Input vbr if policing map key is NULL ");
bool VbrIfPolicingMapMoMgr::IsValidKey(void *key, uint64_t index) {
UPLL_FUNC_TRACE;
key_vbr_if *if_key = reinterpret_cast<key_vbr_if *>(key);
- bool ret_val = UPLL_RC_SUCCESS;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
switch (index) {
case uudst::vbridge_interface::kDbiVtnName:
ret_val = ValidateKey(
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
DalResultCode db_result;
- ConfigKeyVal *req, *nreq = NULL, *ck_main = NULL;
+ ConfigKeyVal *req = NULL, *nreq = NULL, *ck_main = NULL;
controller_domain_t ctrlr_dom;
ctrlr_dom.ctrlr = NULL;
ctrlr_dom.domain = NULL;
upll_keytype_datatype_t vext_datatype = UPLL_DT_CANDIDATE;
if (affected_ctrlr_set == NULL) {
- UPLL_LOG_DEBUG("affected_ctrlr_set is NULL\n");
+ UPLL_LOG_DEBUG("affected_ctrlr_set is NULL");
return UPLL_RC_ERR_GENERIC;
}
unc_keytype_operation_t op = (phase == uuc::kUpllUcpCreate)?UNC_OP_CREATE:
op, req, nreq, &dal_cursor_handle, dmi, MAINTBL);
while (result_code == UPLL_RC_SUCCESS) {
// Get Next Record
+ ck_main = NULL;
db_result = dmi->GetNextRecord(dal_cursor_handle);
result_code = DalToUpllResCode(db_result);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("DupConfigKeyVal DELETE (%d)", op);
result_code = GetChildConfigKey(ck_main, req);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("GetChildConfigKey failed %d\n", result_code);
+ UPLL_LOG_TRACE("GetChildConfigKey failed %d", result_code);
return result_code;
}
- default:
break;
- }
-
-#if 0
- if (op == UNC_OP_DELETE) {
- UPLL_LOG_DEBUG("UNC_OP_DELETE\n");
- if (ck_main->get_cfg_val()) {
- UPLL_LOG_DEBUG("Invalid param\n");
- return UPLL_RC_ERR_GENERIC;
- }
- DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone};
- result_code = ReadConfigDB(ck_main, UPLL_DT_RUNNING, UNC_OP_READ,
- dbop, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ default:
+ UPLL_LOG_DEBUG("TxUpdateController Invalid operation");
return UPLL_RC_ERR_GENERIC;
- }
}
-#endif
+
GET_USER_DATA_CTRLR_DOMAIN(ck_main, ctrlr_dom);
if (ctrlr_dom.ctrlr == NULL) {
- UPLL_LOG_DEBUG("ctrlr_dom.ctrlr NULL\n");
+ UPLL_LOG_DEBUG("ctrlr_dom.ctrlr NULL");
+ DELETE_IF_NOT_NULL(ck_main);
return UPLL_RC_ERR_GENERIC;
}
-#if 0
- if ((op == UNC_OP_CREATE) || (op == UNC_OP_UPDATE)) {
- UPLL_LOG_DEBUG("C/U");
- void *main = GetVal(ck_main);
- void *val_nrec = (nreq) ? GetVal(nreq) : NULL;
- FilterAttributes(main, val_nrec, false, op);
- }
-#endif
GET_USER_DATA_FLAGS(ck_main, db_flag);
UPLL_LOG_DEBUG("db_flag (%d)", db_flag);
if (!(SET_FLAG_PORTMAP & db_flag)) {
if (op != UNC_OP_UPDATE) {
- UPLL_LOG_DEBUG("op != UNC_OP_UPDATE continue\n");
+ UPLL_LOG_DEBUG("op != UNC_OP_UPDATE continue");
+ DELETE_IF_NOT_NULL(ck_main);
continue;
} else {
ConfigKeyVal *temp = NULL;
result_code = GetChildConfigKey(temp, ck_main);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("GetChildConfigKey failed %d\n", result_code);
+ UPLL_LOG_TRACE("GetChildConfigKey failed %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
return result_code;
}
SET_USER_DATA_CTRLR_DOMAIN(temp, ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
UPLL_LOG_DEBUG("Unable to read from DB, err: %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(temp);
return result_code;
}
}
GET_USER_DATA_FLAGS(temp, flag);
UPLL_LOG_DEBUG("flag (%d)", flag);
if (!(SET_FLAG_PORTMAP & flag)) {
- UPLL_LOG_DEBUG("SET_FLAG_PORTMAP & flag\n");
+ UPLL_LOG_DEBUG("SET_FLAG_PORTMAP & flag");
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(temp);
continue;
}
op = UNC_OP_DELETE;
UPLL_LOG_DEBUG("Data type changes as RUNNING op (%d) data type(%d)",
op, vext_datatype);
db_flag = flag;
+ DELETE_IF_NOT_NULL(temp);
}
} else if (UNC_OP_UPDATE == op) {
ConfigKeyVal *temp = NULL;
result_code = GetChildConfigKey(temp, ck_main);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("GetChildConfigKey failed %d\n", result_code);
+ UPLL_LOG_TRACE("GetChildConfigKey failed %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
return result_code;
}
SET_USER_DATA_CTRLR_DOMAIN(temp, ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
UPLL_LOG_DEBUG("Unable to read from DB, err: %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(temp);
return result_code;
}
}
UPLL_LOG_DEBUG("Data type changes as CANDIDATE op (%d) , datatype (%d)",
op, vext_datatype);
}
+ DELETE_IF_NOT_NULL(temp);
}
-#if 0
- if (!(SET_FLAG_PORTMAP & db_flag) && !(SET_FLAG_PORTMAP & db_flag)) {
- UPLL_LOG_DEBUG("SET_FLAG_PORTMAP & db_flag");
- result_code = UPLL_RC_SUCCESS;
- continue;
- }
-#endif
pfcdrv_val_vbrif_policingmap *pfc_val =
reinterpret_cast<pfcdrv_val_vbrif_policingmap *>
(ConfigKeyVal::Malloc(sizeof(pfcdrv_val_vbrif_policingmap_t)));
reinterpret_cast<pfcdrv_val_vbrif_vextif *>\
(ConfigKeyVal::Malloc(sizeof(pfcdrv_val_vbrif_vextif_t)));
+ if (UNC_OP_DELETE == op) {
+ vext_datatype = UPLL_DT_RUNNING;
+ }
+
UPLL_LOG_DEBUG("GetVexternalInformation (%d)", vext_datatype);
- string s(ck_main->ToStrAll());
result_code = GetVexternalInformation(ck_main, vext_datatype, pfc_val,
pfc_val_ext, db_flag, dmi);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetVexternalInformation fail");
+ DELETE_IF_NOT_NULL(ck_main);
+ free (pfc_val_ext);
+ free(pfc_val);
return result_code;
}
upll_keytype_datatype_t dt_type = (op == UNC_OP_DELETE)?
UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
ctrlr_dom.domain);
- string s1(ck_main->ToStrAll());
+ ConfigKeyVal *temp_ck_main = NULL;
+ result_code = DupConfigKeyVal(temp_ck_main, req, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
+ free (pfc_val_ext);
+ free(pfc_val);
+ return result_code;
+ }
result_code = GetRenamedControllerKey(ck_main, dt_type,
dmi, &ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetRenamedControllerKey fail");
+ DELETE_IF_NOT_NULL(ck_main);
+ free (pfc_val_ext);
+ free(pfc_val);
break;
}
+ if (UNC_OP_DELETE == op) {
+ pfc_val->valid[PFCDRV_IDX_VAL_POLICINGMAP_PM] = UNC_VF_INVALID;
+ } else {
+ val_policingmap_t* val = reinterpret_cast<val_policingmap_t *>(GetVal(ck_main)); // req
+ UPLL_LOG_DEBUG("val_policingmap_t (%s)", val->policer_name);
- val_policingmap_t* val = reinterpret_cast<val_policingmap_t *>(GetVal(req));
- UPLL_LOG_DEBUG("val_policingmap_t (%s)", val->policer_name);
-
- pfc_val->valid[PFCDRV_IDX_VAL_POLICINGMAP_PM] = UNC_VF_VALID;
- memcpy(&pfc_val->val_policing_map, val, sizeof(val_policingmap_t));
+ pfc_val->valid[PFCDRV_IDX_VAL_POLICINGMAP_PM] = UNC_VF_VALID;
+ memcpy(&pfc_val->val_policing_map, val, sizeof(val_policingmap_t));
+ }
pfc_val->valid[PFCDRV_IDX_VAL_VBRIF_VEXTIF_PM] = UNC_VF_VALID;
memcpy(&pfc_val->val_vbrif_vextif, pfc_val_ext,
sizeof(pfcdrv_val_vbrif_vextif_t));
-
-// delete ck_main->get_cfg_val();
-// ck_main->AppendCfgVal(IpctSt::kIpcStPfcdrvValVbrifPolicingmap, pfc_val);
+ FREE_IF_NOT_NULL(pfc_val_ext);
ck_main->SetCfgVal(new ConfigVal(IpctSt::kIpcStPfcdrvValVbrifPolicingmap,
pfc_val));
result_code = UPLL_RC_SUCCESS;
}
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("IpcSend failed %d\n", result_code);
- *err_ckv = ipc_resp.ckv_data;
- if (ck_main)
- delete ck_main;
+ UPLL_LOG_DEBUG("IpcSend failed %d", result_code);
+ *err_ckv = temp_ck_main;
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(ck_main);
break;
}
-#if 0
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("IpcSend failed %d\n", result_code);
- return result_code;
- }
-
- UPLL_LOG_DEBUG("SendIpcReq");
- if (ipc_resp.header.result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ipc_resp.header.result_code fail");
- *err_ckv = ipc_resp.ckv_data;
- }
-#endif
- if (ck_main)
- delete ck_main;
- ck_main = NULL;
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(temp_ck_main);
+ DELETE_IF_NOT_NULL(ck_main);
}
dmi->CloseCursor(dal_cursor_handle, true);
- if (nreq)
- delete nreq;
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) ?
UPLL_RC_SUCCESS : result_code;
return result_code;
ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
- InterfacePortMapInfo flag) {
+ InterfacePortMapInfo flag,
+ unc_keytype_operation_t oper) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
if (NULL == ikey || NULL == ikey->get_key()) {
UNC_OP_READ, dbop, dmi, MAINTBL);
if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
UPLL_LOG_DEBUG("No Recrods in vbr_if_policingmap Table");
+ DELETE_IF_NOT_NULL(ckv);
return UPLL_RC_SUCCESS;
}
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("Read ConfigDB failure %d", result_code);
- delete ckv;
+ DELETE_IF_NOT_NULL(ckv);
return result_code;
}
uint8_t flag_port_map = 0;
flag_port_map |= SET_FLAG_VLINK_PORTMAP;
} else {
UPLL_LOG_DEBUG("default flag_port_map");
- flag_port_map = 0;
-// return UPLL_RC_ERR_GENERIC;
+ flag_port_map &= SET_FLAG_NO_VLINK_PORTMAP;
}
- uint8_t rename_flag = 0;
- GET_USER_DATA_FLAGS(ckv, rename_flag);
- rename_flag |= flag_port_map;
SET_USER_DATA_FLAGS(ckv, flag_port_map);
DbSubOp dbop_up = { kOpNotRead, kOpMatchNone, kOpInOutFlag };
result_code = UpdateConfigDB(ckv, dt_type, UNC_OP_UPDATE,
dmi, &dbop_up, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("UpdateConfigDB failure %d", result_code);
+ DELETE_IF_NOT_NULL(ckv);
return result_code;
}
-
+ DELETE_IF_NOT_NULL(ckv);
return UPLL_RC_SUCCESS;
}
UPLL_LOG_DEBUG("Not allowed at this time");
free(vex_if);
free(vexternal);
+ DELETE_IF_NOT_NULL(ckv);
return UPLL_RC_ERR_NOT_ALLOWED_AT_THIS_TIME;
}
+ FREE_IF_NOT_NULL(vex_if);
+ FREE_IF_NOT_NULL(vexternal);
+ DELETE_IF_NOT_NULL(ckv);
return UPLL_RC_SUCCESS;
}
if (IpctSt::kIpcStValPolicingmapControllerSt ==
temp_cfg_val->get_st_num()) {
val_entry_st = reinterpret_cast<val_policingmap_controller_st *>
- (temp_cfg_val->get_val());
+ (temp_cfg_val->get_val());
} else {
UPLL_LOG_DEBUG("No val_entry_st (%d)", temp_cfg_val->get_st_num());
delete tmp_okey;
ConfigKeyVal *tkey = NULL;
key_policingprofile_entry_t *key_policingprofile_entry =
- reinterpret_cast<key_policingprofile_entry_t *>
- (ConfigKeyVal::Malloc(sizeof(key_policingprofile_entry_t)));
+ reinterpret_cast<key_policingprofile_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_policingprofile_entry_t)));
tkey = new ConfigKeyVal(UNC_KT_POLICING_PROFILE_ENTRY,
- IpctSt::kIpcStKeyPolicingprofileEntry,
- key_policingprofile_entry, NULL);
+ IpctSt::kIpcStKeyPolicingprofileEntry,
+ key_policingprofile_entry, NULL);
key_policingprofile_entry->sequence_num = val_entry_st->sequence_num;
uuu::upll_strncpy(
val_policingmap->policer_name,
(kMaxLenPolicingProfileName+1));
PolicingProfileEntryMoMgr *mgr = reinterpret_cast
- <PolicingProfileEntryMoMgr*>
- (const_cast<MoManager *>(GetMoManager
- (UNC_KT_POLICING_PROFILE_ENTRY)));
+ <PolicingProfileEntryMoMgr*>
+ (const_cast<MoManager *>(GetMoManager
+ (UNC_KT_POLICING_PROFILE_ENTRY)));
result_code = mgr->ReadDetailEntry(
tkey, dt_type, dbop, dmi);
reinterpret_cast<val_policingprofile_entry_t *>
(ConfigKeyVal::Malloc(sizeof(val_policingprofile_entry_t)));
val_policingprofile_entry_t *temp_val_policingprofile =
- reinterpret_cast<val_policingprofile_entry_t *>
- (tkey->get_cfg_val()->get_val());
+ reinterpret_cast<val_policingprofile_entry_t *>
+ (tkey->get_cfg_val()->get_val());
memcpy(out_val_ppe, temp_val_policingprofile,
- sizeof(val_policingprofile_entry_t));
+ sizeof(val_policingprofile_entry_t));
val_policingmap_controller_st *out_val_entry_st =
reinterpret_cast<val_policingmap_controller_st *>
(ConfigKeyVal::Malloc(sizeof(val_policingmap_controller_st)));
memcpy(out_val_entry_st, val_entry_st,
- sizeof(val_policingmap_controller_st));
+ sizeof(val_policingmap_controller_st));
tmp_okey->AppendCfgVal(IpctSt::kIpcStValPolicingmapControllerSt,
- out_val_entry_st);
+ out_val_entry_st);
tmp_okey->AppendCfgVal(IpctSt::kIpcStValPolicingprofileEntry,
- out_val_ppe);
- if (tkey) {
- delete tkey;
+ out_val_ppe);
+ delete tkey;
+ tkey = NULL;
+ if ((temp_cfg_val = temp_cfg_val->get_next_cfg_val()) == NULL) {
+ UPLL_LOG_DEBUG("No val_policingmap_switch_st in configkeyval");
+ continue;
}
- if ((temp_cfg_val = temp_cfg_val->get_next_cfg_val()) == NULL) {
- UPLL_LOG_DEBUG("Next Vlaue structure is null\n");
- break;
+ if (IpctSt::kIpcStValPolicingmapSwitchSt != temp_cfg_val->get_st_num()) {
+ UPLL_LOG_DEBUG("No PolicingmapSwitchSt entries returned by driver");
+ continue;
}
+ while (IpctSt::kIpcStValPolicingmapSwitchSt ==
+ temp_cfg_val->get_st_num()) {
+ val_policingmap_switch_st_t *val_switch_st =
+ reinterpret_cast<val_policingmap_switch_st_t*>
+ (ConfigKeyVal::Malloc(sizeof(val_policingmap_switch_st_t)));
+ val_policingmap_switch_st_t *drv_val_switch_st =
+ reinterpret_cast<val_policingmap_switch_st_t*>
+ (temp_cfg_val->get_val());
+ memcpy(val_switch_st, drv_val_switch_st,
+ sizeof(val_policingmap_switch_st_t));
+ if(drv_val_switch_st->valid[UPLL_IDX_IF_NAME_PMSS] == UNC_VF_VALID) {
+ key_vbr_if_t *vbrif_pm_key =
+ reinterpret_cast<key_vbr_if_t*>(ikey->get_key());
+ ConfigKeyVal *vbrif_key_val = NULL;
+ unc::upll::kt_momgr::VbrIfMoMgr *vbrifmgr =
+ reinterpret_cast<unc::upll::kt_momgr::VbrIfMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VBR_IF)));
+ if (NULL == vbrifmgr) {
+ free(val_switch_st);
+ delete tmp_okey;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = vbrifmgr->GetVbrIfFromVExternal(
+ vbrif_pm_key->vbr_key.vtn_key.vtn_name,
+ drv_val_switch_st->if_name,
+ vbrif_key_val,
+ dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Get vBridge info failed err code (%d)",
+ result_code);
+ free(val_switch_st);
+ delete tmp_okey;
+ return result_code;
+ }
- if (IpctSt::kIpcStValFlowlistEntrySt == temp_cfg_val->get_st_num()) {
- while (IpctSt::kIpcStValPolicingmapSwitchSt ==
- temp_cfg_val->get_st_num()) {
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValPolicingmapSwitchSt,
- temp_cfg_val->get_val());
- temp_cfg_val = temp_cfg_val->get_next_cfg_val();
- if (temp_cfg_val == NULL)
- break;
+ key_vbr_if_t *key_vbrif = reinterpret_cast<key_vbr_if_t*>
+ (vbrif_key_val->get_key());
+ val_switch_st->valid[UPLL_IDX_VBR_NAME_PMSS] = UNC_VF_VALID;
+ uuu::upll_strncpy(val_switch_st->vbr_name,
+ key_vbrif->vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+
+ val_switch_st->valid[UPLL_IDX_IF_NAME_PMSS] = UNC_VF_VALID;
+ uuu::upll_strncpy(val_switch_st->if_name,
+ key_vbrif->if_name,
+ (kMaxLenInterfaceName + 1));
+ DELETE_IF_NOT_NULL(vbrif_key_val);
}
+ tmp_okey->AppendCfgVal(IpctSt::kIpcStValPolicingmapSwitchSt,
+ val_switch_st);
+ temp_cfg_val = temp_cfg_val->get_next_cfg_val();
+ if (temp_cfg_val == NULL)
+ break;
}
}
}
dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetChildConfigKey failed");
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
}
val_policingmap_t *val_pm = NULL;
val_pm = reinterpret_cast<val_policingmap_t*>(GetVal(dup_key));
+ if (val_pm == NULL) {
+ DELETE_IF_NOT_NULL(dup_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
val_policingmap_t *out_pm_val = reinterpret_cast<val_policingmap_t*>
(ConfigKeyVal::Malloc(sizeof(val_policingmap_t)));
memcpy(out_pm_val, val_pm, sizeof(val_policingmap_t));
tkey, dt_type, dbop, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadDetailEntry failed");
- CONFIGKEYVALCLEAN(tkey);
+ DELETE_IF_NOT_NULL(tkey);
delete okey;
return result_code;
}
return UPLL_RC_SUCCESS;
}
-upll_rc_t VbrIfPolicingMapMoMgr::ReadDTSiblingDetail(ConfigKeyVal *ikey,
- ConfigKeyVal *dup_key,
- IpcResponse *ipc_response,
- upll_keytype_datatype_t dt_type,
- unc_keytype_operation_t op,
- DbSubOp dbop,
- DalDmlIntf *dmi,
- int count,
- ConfigKeyVal** resp_key,
- ConfigKeyVal* tctrl_key) {
+upll_rc_t VbrIfPolicingMapMoMgr::ConstructReadEntryDetailResponse(
+ ConfigKeyVal *ikey,
+ ConfigKeyVal *drv_resp_ckv,
+ upll_keytype_datatype_t dt_type,
+ unc_keytype_operation_t op,
+ DbSubOp dbop,
+ DalDmlIntf *dmi,
+ ConfigKeyVal **okey) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *tmp_okey = NULL;
ConfigVal *temp_cfg_val = NULL;
- ConfigKeyVal *okey = NULL;
-#if 0
- result_code = DupConfigKeyVal(okey, ikey, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("DupConfigKeyVal Faill in ReadMo for dup_key");
- return result_code;
- }
-#endif
- result_code = GetReadVbrIfKey(okey, ikey);
+ result_code = GetChildEntryConfigKey(tmp_okey, ikey);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetReadVbrIfKey Faill ");
- return result_code;
+ UPLL_LOG_DEBUG("GetChildConfigKey failed err code (%d)", result_code);
+ return result_code;
}
- reinterpret_cast<key_vbrif_policingmap_entry*>
- (okey->get_key())->sequence_num =
- reinterpret_cast<key_vbrif_policingmap_entry*>
- (tctrl_key->get_key())->sequence_num;
-
val_policingmap_t *val_policingmap =
- reinterpret_cast<val_policingmap_t *>(GetVal(dup_key));
- val_policingmap_t *val_polmap =
- reinterpret_cast<val_policingmap_t *>
- (ConfigKeyVal::Malloc(sizeof(val_policingmap_t)));
- memcpy(val_polmap, val_policingmap, sizeof(val_policingmap_t));
- okey->AppendCfgVal(IpctSt::kIpcStValPolicingmap, val_polmap);
-
- if (ipc_response->ckv_data)
- temp_cfg_val = ipc_response->ckv_data->get_cfg_val();
+ reinterpret_cast<val_policingmap_t *>(GetVal(ikey));
+ val_policingmap_t *out_val_policingmap =
+ reinterpret_cast<val_policingmap_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_policingmap_t)));
+ memcpy(out_val_policingmap, val_policingmap, sizeof(val_policingmap_t));
+ tmp_okey->AppendCfgVal(IpctSt::kIpcStValPolicingmap, out_val_policingmap);
+ temp_cfg_val = drv_resp_ckv->get_cfg_val();
while (temp_cfg_val != NULL) {
- val_policingmap_controller_st *val_entry_st = NULL;
+ val_policingmap_controller_st *val_entry_st = NULL;
if (IpctSt::kIpcStValPolicingmapControllerSt ==
- temp_cfg_val->get_st_num()) {
+ temp_cfg_val->get_st_num()) {
val_entry_st = reinterpret_cast<val_policingmap_controller_st *>
(temp_cfg_val->get_val());
} else {
UPLL_LOG_DEBUG("No val_entry_st (%d)", temp_cfg_val->get_st_num());
- delete okey;
+ delete tmp_okey;
return UPLL_RC_ERR_GENERIC;
}
if (val_entry_st->valid[UPLL_IDX_SEQ_NUM_FFES] == UNC_VF_VALID) {
+ UPLL_LOG_DEBUG("val_entry_st valid");
ConfigKeyVal *tkey = NULL;
key_policingprofile_entry_t *key_policingprofile_entry =
- reinterpret_cast<key_policingprofile_entry_t *>
- (ConfigKeyVal::Malloc(sizeof(key_vbrif_policingmap_entry_t)));
+ reinterpret_cast<key_policingprofile_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vbrif_policingmap_entry_t)));
tkey = new ConfigKeyVal(UNC_KT_POLICING_PROFILE_ENTRY,
IpctSt::kIpcStKeyPolicingprofileEntry,
key_policingprofile_entry->sequence_num = val_entry_st->sequence_num;
uuu::upll_strncpy(
- key_policingprofile_entry->policingprofile_key.policingprofile_name,
- val_policingmap->policer_name,
- (kMaxLenPolicingProfileName+1));
+ key_policingprofile_entry->policingprofile_key.policingprofile_name,
+ val_policingmap->policer_name,
+ (kMaxLenPolicingProfileName+1));
PolicingProfileEntryMoMgr *mgr = reinterpret_cast
- <PolicingProfileEntryMoMgr*>
- (const_cast<MoManager *>(GetMoManager
- (UNC_KT_POLICING_PROFILE_ENTRY)));
+ <PolicingProfileEntryMoMgr*>
+ (const_cast<MoManager *>(GetMoManager
+ (UNC_KT_POLICING_PROFILE_ENTRY)));
result_code = mgr->ReadDetailEntry(
- tkey, dt_type, dbop, dmi);
+ tkey, dt_type, dbop, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadDetailEntry error (%d)", result_code);
- delete okey;
- delete val_polmap;
+ delete tmp_okey;
delete tkey;
return result_code;
}
+ val_policingprofile_entry_t *out_val_ppe =
+ reinterpret_cast<val_policingprofile_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_policingprofile_entry_t)));
val_policingprofile_entry_t *temp_val_policingprofile =
reinterpret_cast<val_policingprofile_entry_t *>
(tkey->get_cfg_val()->get_val());
- val_policingmap_controller_st* val_pol_st =
- reinterpret_cast<val_policingmap_controller_st *>
- (ConfigKeyVal::Malloc(sizeof(val_policingmap_controller_st)));
- memcpy(val_pol_st, val_entry_st, sizeof(val_policingmap_controller_st));
- okey->AppendCfgVal(IpctSt::kIpcStValPolicingmapControllerSt,
- val_pol_st);
- okey->AppendCfgVal(IpctSt::kIpcStValPolicingprofileEntry,
- temp_val_policingprofile);
-
- if ((temp_cfg_val = temp_cfg_val->get_next_cfg_val()) == NULL) {
- UPLL_LOG_DEBUG("Next Vlaue structure is null\n");
- break;
- }
+ memcpy(out_val_ppe, temp_val_policingprofile,
+ sizeof(val_policingprofile_entry_t));
+ val_policingmap_controller_st *out_val_entry_st =
+ reinterpret_cast<val_policingmap_controller_st *>
+ (ConfigKeyVal::Malloc(sizeof(val_policingmap_controller_st)));
+ memcpy(out_val_entry_st, val_entry_st,
+ sizeof(val_policingmap_controller_st));
+ tmp_okey->AppendCfgVal(IpctSt::kIpcStValPolicingmapControllerSt,
+ out_val_entry_st);
+ tmp_okey->AppendCfgVal(IpctSt::kIpcStValPolicingprofileEntry,
+ out_val_ppe);
+ delete tkey;
+ tkey = NULL;
+
+ if ((temp_cfg_val = temp_cfg_val->get_next_cfg_val()) == NULL) {
+ UPLL_LOG_DEBUG("Next Value structure is null");
+ continue;
+ }
+ if (IpctSt::kIpcStValPolicingmapSwitchSt != temp_cfg_val->get_st_num()) {
+ UPLL_LOG_DEBUG("No PolicingmapSwitchSt entries returned by driver");
+ continue;
+ }
while (IpctSt::kIpcStValPolicingmapSwitchSt ==
temp_cfg_val->get_st_num()) {
- val_policingmap_switch_st* val_polswitch = reinterpret_cast
- <val_policingmap_switch_st*>(temp_cfg_val->get_val());
- val_policingmap_switch_st* val_polswitch_st =
- reinterpret_cast<val_policingmap_switch_st *>
- (ConfigKeyVal::Malloc(sizeof(val_policingmap_switch_st)));
- memcpy(val_polswitch_st, val_polswitch,
- sizeof(val_policingmap_switch_st));
- okey->AppendCfgVal(IpctSt::kIpcStValPolicingmapSwitchSt,
- val_polswitch_st);
+ val_policingmap_switch_st_t *val_switch_st =
+ reinterpret_cast<val_policingmap_switch_st_t*>
+ (ConfigKeyVal::Malloc(sizeof(val_policingmap_switch_st_t)));
+ val_policingmap_switch_st_t *drv_val_switch_st =
+ reinterpret_cast<val_policingmap_switch_st_t*>
+ (temp_cfg_val->get_val());
+ memcpy(val_switch_st, drv_val_switch_st,
+ sizeof(val_policingmap_switch_st_t));
+ if(drv_val_switch_st->valid[UPLL_IDX_IF_NAME_PMSS] == UNC_VF_VALID) {
+ key_vbrif_policingmap_entry *vbrif_pme_key =
+ reinterpret_cast<key_vbrif_policingmap_entry *>(ikey->get_key());
+ ConfigKeyVal *vbrif_key_val = NULL;
+ unc::upll::kt_momgr::VbrIfMoMgr *vbrifmgr =
+ reinterpret_cast<unc::upll::kt_momgr::VbrIfMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VBR_IF)));
+ if (NULL == vbrifmgr) {
+ if (val_switch_st) free(val_switch_st);
+ DELETE_IF_NOT_NULL(tmp_okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = vbrifmgr->GetVbrIfFromVExternal(
+ vbrif_pme_key->vbrif_key.vbr_key.vtn_key.vtn_name,
+ drv_val_switch_st->if_name,
+ vbrif_key_val,
+ dmi);
+ if ((result_code != UPLL_RC_SUCCESS) &&
+ (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG("Get vBridge info failed err code (%d)",
+ result_code);
+ if (val_switch_st) free(val_switch_st);
+ DELETE_IF_NOT_NULL(tmp_okey);
+ DELETE_IF_NOT_NULL(vbrif_key_val);
+ return result_code;
+ }
+
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ key_vbr_if_t *key_vbrif = reinterpret_cast<key_vbr_if_t*>
+ (vbrif_key_val->get_key());
+ val_switch_st->valid[UPLL_IDX_VBR_NAME_PMSS] = UNC_VF_VALID;
+ uuu::upll_strncpy(val_switch_st->vbr_name,
+ key_vbrif->vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+
+ val_switch_st->valid[UPLL_IDX_IF_NAME_PMSS] = UNC_VF_VALID;
+ uuu::upll_strncpy(val_switch_st->if_name,
+ key_vbrif->if_name,
+ (kMaxLenInterfaceName + 1));
+ }
+ DELETE_IF_NOT_NULL(vbrif_key_val);
+ }
+ tmp_okey->AppendCfgVal(IpctSt::kIpcStValPolicingmapSwitchSt,
+ val_switch_st);
temp_cfg_val = temp_cfg_val->get_next_cfg_val();
- if (temp_cfg_val == NULL)
+ if (temp_cfg_val == NULL) {
break;
- }
- }
- }
- if (!count) {
- UPLL_LOG_DEBUG("count is 0");
- *resp_key = okey;
- } else {
- UPLL_LOG_DEBUG("AppendCfgKeyVal in resp_key");
- (*resp_key)->AppendCfgKeyVal(okey);
- }
- return UPLL_RC_SUCCESS;
-}
-
-upll_rc_t VbrIfPolicingMapMoMgr::ConstructReadEntryDetailResponse(
- ConfigKeyVal *ikey,
- ConfigKeyVal *drv_resp_ckv,
- upll_keytype_datatype_t dt_type,
- unc_keytype_operation_t op,
- DbSubOp dbop,
- DalDmlIntf *dmi,
- ConfigKeyVal **okey) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- ConfigKeyVal *tmp_okey = NULL;
- ConfigVal *temp_cfg_val = NULL;
- result_code = GetChildEntryConfigKey(tmp_okey, ikey);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetChildConfigKey failed err code (%d)", result_code);
- return result_code;
- }
- val_policingmap_t *val_policingmap =
- reinterpret_cast<val_policingmap_t *>(GetVal(ikey));
- val_policingmap_t *out_val_policingmap =
- reinterpret_cast<val_policingmap_t *>
- (ConfigKeyVal::Malloc(sizeof(val_policingmap_t)));
- memcpy(out_val_policingmap, val_policingmap, sizeof(val_policingmap_t));
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValPolicingmap, out_val_policingmap);
- temp_cfg_val = drv_resp_ckv->get_cfg_val();
-
- while (temp_cfg_val != NULL) {
- val_policingmap_controller_st *val_entry_st = NULL;
- if (IpctSt::kIpcStValPolicingmapControllerSt ==
- temp_cfg_val->get_st_num()) {
- val_entry_st = reinterpret_cast<val_policingmap_controller_st *>
- (temp_cfg_val->get_val());
- } else {
- UPLL_LOG_DEBUG("No val_entry_st (%d)", temp_cfg_val->get_st_num());
- delete tmp_okey;
- return UPLL_RC_ERR_GENERIC;
- }
-
- if (val_entry_st->valid[UPLL_IDX_SEQ_NUM_FFES] == UNC_VF_VALID) {
- UPLL_LOG_DEBUG("val_entry_st valid");
- ConfigKeyVal *tkey = NULL;
-
- key_policingprofile_entry_t *key_policingprofile_entry =
- reinterpret_cast<key_policingprofile_entry_t *>
- (ConfigKeyVal::Malloc(sizeof(key_vbrif_policingmap_entry_t)));
-
- tkey = new ConfigKeyVal(UNC_KT_POLICING_PROFILE_ENTRY,
- IpctSt::kIpcStKeyPolicingprofileEntry,
- key_policingprofile_entry, NULL);
- key_policingprofile_entry->sequence_num = val_entry_st->sequence_num;
-
- uuu::upll_strncpy(
- key_policingprofile_entry->policingprofile_key.policingprofile_name,
- val_policingmap->policer_name,
- (kMaxLenPolicingProfileName+1));
- PolicingProfileEntryMoMgr *mgr = reinterpret_cast
- <PolicingProfileEntryMoMgr*>
- (const_cast<MoManager *>(GetMoManager
- (UNC_KT_POLICING_PROFILE_ENTRY)));
-
- result_code = mgr->ReadDetailEntry(
- tkey, dt_type, dbop, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ReadDetailEntry error (%d)", result_code);
- delete tmp_okey;
- delete tkey;
- return result_code;
- }
- val_policingprofile_entry_t *out_val_ppe =
- reinterpret_cast<val_policingprofile_entry_t *>
- (ConfigKeyVal::Malloc(sizeof(val_policingprofile_entry_t)));
- val_policingprofile_entry_t *temp_val_policingprofile =
- reinterpret_cast<val_policingprofile_entry_t *>
- (tkey->get_cfg_val()->get_val());
- memcpy(out_val_ppe, temp_val_policingprofile,
- sizeof(val_policingprofile_entry_t));
-
- val_policingmap_controller_st *out_val_entry_st =
- reinterpret_cast<val_policingmap_controller_st *>
- (ConfigKeyVal::Malloc(sizeof(val_policingmap_controller_st)));
- memcpy(out_val_entry_st, val_entry_st,
- sizeof(val_policingmap_controller_st));
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValPolicingmapControllerSt,
- out_val_entry_st);
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValPolicingprofileEntry,
- out_val_ppe);
- if (tkey) {
- delete tkey;
- }
-
- if ((temp_cfg_val = temp_cfg_val->get_next_cfg_val()) == NULL) {
- UPLL_LOG_DEBUG("Next Vlaue structure is null\n");
- break;
- }
-
- if (IpctSt::kIpcStValFlowlistEntrySt == temp_cfg_val->get_st_num()) {
- while (IpctSt::kIpcStValPolicingmapSwitchSt ==
- temp_cfg_val->get_st_num()) {
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValPolicingmapSwitchSt,
- temp_cfg_val->get_val());
- temp_cfg_val = temp_cfg_val->get_next_cfg_val();
- if (temp_cfg_val == NULL)
- break;
- }
+ }
}
}
}
dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadConfigDB Error (%d)", result_code);
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(dup_key);
delete temp_key;
return result_code;
}
MAINTBL);
if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
UPLL_LOG_DEBUG("ReadDetailEntry error (%d)", result_code);
+ delete ppe_ckv;
+ delete dup_key;
return result_code;
}
result_code = GetChildEntryConfigKey(l_key, ikey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("DupConfigKeyVal Faill in ReadSiblingMo for l_key");
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
}
GET_USER_DATA_CTRLR_DOMAIN(temp_key, ctrlr_dom);
SET_USER_DATA_CTRLR_DOMAIN(l_key, ctrlr_dom);
+ result_code = ValidateCapability(req, ikey, reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ UPLL_LOG_DEBUG("Key not supported by controller");
+ return result_code;
+ }
GET_USER_DATA_FLAGS(temp_key, db_flag);
- /*
result_code = GetRenamedControllerKey(l_key, req->datatype,
dmi, &ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetRenamedControllerKey Faill");
- CONFIGKEYVALCLEAN(dup_key);
- CONFIGKEYVALCLEAN(l_key);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
return result_code;
}
- */
pfcdrv_val_vbrif_policingmap *pfc_val =
reinterpret_cast<pfcdrv_val_vbrif_policingmap *>
(ConfigKeyVal::Malloc(sizeof(pfcdrv_val_vbrif_policingmap_t)));
memset(pfc_val_ext, 0, sizeof(pfcdrv_val_vbrif_vextif_t));
UPLL_LOG_DEBUG("GetVexternalInformation (%d)", req->datatype);
- if (req->datatype == UPLL_DT_STATE) req->datatype = UPLL_DT_RUNNING;
- string s(l_key->ToStrAll());
- result_code = GetVexternalInformation(temp_key, req->datatype, pfc_val,
+ result_code = GetVexternalInformation(temp_key, UPLL_DT_RUNNING, pfc_val,
pfc_val_ext, db_flag, dmi);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetVexternalInformation fail");
- CONFIGKEYVALCLEAN(dup_key);
- CONFIGKEYVALCLEAN(l_key);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
return result_code;
}
UPLL_LOG_DEBUG("SendReqToDriver failed for Key %d controller %s",
l_key->get_key_type(),
reinterpret_cast<char *>(ctrlr_dom.ctrlr));
- CONFIGKEYVALCLEAN(l_key);
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(dup_key);
return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_DEBUG("Driver response for Key %d controller %s result %d",
l_key->get_key_type(), ctrlr_dom.ctrlr,
ipc_response.header.result_code);
- CONFIGKEYVALCLEAN(l_key);
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(dup_key);
return ipc_response.header.result_code;
}
ConfigKeyVal *okey = NULL;
dbop, dmi, &okey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadSiblingDetail Error (%d)", result_code);
- CONFIGKEYVALCLEAN(dup_key);
- CONFIGKEYVALCLEAN(l_key);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
return result_code;
} else {
if (okey != NULL) {
ConfigKeyVal* ikey,
DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
- upll_rc_t result_code;
- if (UNC_KT_VBRIF_POLICINGMAP_ENTRY != ikey->get_key_type() &&
- req->datatype != UPLL_DT_STATE) {
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
controller_domain ctrlr_dom;
- result_code = ValidateMessage(req, ikey);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ValidateMessage failed result_code %d",
+ result_code = ValidateMessage(req, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ValidateMessage failed result_code %d",
result_code);
+ return result_code;
+ }
+
+ if (UNC_KT_VBRIF_POLICINGMAP_ENTRY != ikey->get_key_type()) {
+ if(req->datatype == UPLL_DT_STATE ||
+ req->datatype == UPLL_DT_STARTUP ||
+ req->datatype == UPLL_DT_RUNNING ||
+ req->datatype == UPLL_DT_CANDIDATE ) {
+ result_code = ReadInfoFromDB(req, ikey, dmi, &ctrlr_dom);
return result_code;
- }
- result_code = ReadInfoFromDB(req, ikey, dmi, &ctrlr_dom);
- return result_code;
+ } else {
+ UPLL_LOG_DEBUG("ReadSiblingCount is not Allowed For Such datatype %d",
+ req->datatype);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+
}
+ if (UNC_KT_VBRIF_POLICINGMAP_ENTRY == ikey->get_key_type())
+ if(req->datatype != UPLL_DT_STATE) {
+ UPLL_LOG_DEBUG("ReadSiblingCount is not Allowed For Such datatype %d",
+ req->datatype);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+
ConfigKeyVal *temp_vbr_if_key = NULL;
key_vbrif_policingmap_entry_t *vbrif_entry_key = reinterpret_cast
<key_vbrif_policingmap_entry_t *>(ikey->get_key());
(const_cast<MoManager *>(GetMoManager
(UNC_KT_POLICING_PROFILE_ENTRY)));
if (!mgr) {
+ delete ppe_ckv;
return UPLL_RC_ERR_GENERIC;
}
IpcReqRespHeader *temp_req = reinterpret_cast<IpcReqRespHeader *>
result_code = mgr->ReadSiblingMo(temp_req, ppe_ckv, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Read sibling of ppe failed (%d)", result_code);
+ ConfigKeyVal::Free(temp_req);
return result_code;
}
+ ConfigKeyVal::Free(temp_req);
+
ConfigKeyVal *temp_ppe_ckv = ppe_ckv;
uint8_t sibling_count = 0;
while (temp_ppe_ckv !=NULL) {
delete ppe_ckv;
return UPLL_RC_SUCCESS;
}
+
+upll_rc_t VbrIfPolicingMapMoMgr::CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id) {
+ UPLL_FUNC_TRACE;
+ UPLL_LOG_DEBUG("Audit Create for VbrIfPolicingMapMoMgr called!!!");
+ if (NULL == ikey || NULL == dmi) {
+ UPLL_LOG_DEBUG("Insufficient input parameters");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ uint8_t *controller_id = reinterpret_cast<uint8_t *>(
+ const_cast<char *>(ctrlr_id));
+ result_code = GetRenamedUncKey(ikey, UPLL_DT_RUNNING, dmi,
+ controller_id);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey Failed err_code %d", result_code);
+ return result_code;
+ }
+ ConfigKeyVal *okey = NULL;
+ result_code = GetControllerId(ikey, okey, UPLL_DT_AUDIT, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetControllerId failed %d", result_code);
+ return result_code;
+ }
+ delete okey;
+
+ ConfigKeyVal *new_ikey = NULL;
+ result_code = GetChildConfigKey(new_ikey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed");
+ return result_code;
+ }
+ val_policingmap_t *val_pm = reinterpret_cast
+ <val_policingmap_t *>(ConfigKeyVal::Malloc
+ (sizeof(val_policingmap_t)));
+ pfcdrv_val_vbrif_policingmap *pfc_val =
+ reinterpret_cast<pfcdrv_val_vbrif_policingmap *>
+ (GetVal(ikey));
+ if (NULL == pfc_val) {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (pfc_val->valid[PFCDRV_IDX_VAL_POLICINGMAP_PM] == UNC_VF_VALID) {
+ memcpy(val_pm, &(pfc_val->val_policing_map), sizeof(val_policingmap_t));
+ } else {
+ UPLL_LOG_DEBUG("No val_policingmap in driver structure");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t flag_port_map = 0;
+ if (UNC_VF_VALID == pfc_val->valid[PFCDRV_IDX_VAL_VBRIF_VEXTIF_PM]) {
+ flag_port_map = SET_FLAG_PORTMAP;
+ } else {
+ UPLL_LOG_DEBUG("Portmap not configured");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ SET_USER_DATA_FLAGS(new_ikey, flag_port_map);
+ new_ikey->AppendCfgVal(IpctSt::kIpcStValPolicingmap, val_pm);
+
+ if (UNC_VF_VALID == val_pm->valid[UPLL_IDX_POLICERNAME_PM]) {
+ result_code = UpdateRefCountInPPCtrlr(new_ikey, UPLL_DT_AUDIT, dmi,
+ UNC_OP_CREATE);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateRefCountInPPCtrlr Err in CANDIDATE DB(%d)",
+ result_code);
+ return result_code;
+ }
+ }
+ result_code = SetValidAudit(ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ return result_code;
+ }
+ DbSubOp dbop = { kOpNotRead, kOpMatchNone,
+ kOpInOutFlag|kOpInOutCtrlr|kOpInOutDomain|kOpInOutCs };
+ result_code = UpdateConfigDB(new_ikey, UPLL_DT_AUDIT, UNC_OP_CREATE,
+ dmi, &dbop, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("CreateCandidateMo failed. UpdateConfigDb failed."
+ "Record creation failed - %d",
+ result_code);
+ return result_code;
+ }
+ UPLL_LOG_DEBUG("CreateCandidateMo Successful");
+ delete new_ikey;
+ return result_code;
+}
+
+upll_rc_t VbrIfPolicingMapMoMgr::AuditUpdateController(unc_key_type_t keytype,
+ const char *ctrlr_id,
+ uint32_t session_id,
+ uint32_t config_id,
+ uuc::UpdateCtrlrPhase phase1,
+ bool *ctrlr_affected,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ DalResultCode db_result = uud::kDalRcSuccess;
+ MoMgrTables tbl = MAINTBL;
+ controller_domain_t ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ ConfigKeyVal *ckv_running_db = NULL;
+ ConfigKeyVal *ckv_audit_db = NULL;
+ ConfigKeyVal *ckv_driver_req = NULL;
+ ConfigKeyVal *ckv_audit_dup_db = NULL;
+ DalCursor *cursor = NULL;
+ upll_keytype_datatype_t vext_datatype = UPLL_DT_RUNNING;
+ uint8_t *ctrlr = reinterpret_cast<uint8_t *>(const_cast<char *>(ctrlr_id));
+ // Skipping the create phase if it comes as an input.
+ // vbr if policingmap should get applied on controller(pfc) if portmap is
+ // configured.
+ // The portmap request should come in the update phase so
+ // the vbrif policingmap creation should also be applied during update phase.
+ if (phase1 == uuc::kUpllUcpCreate) {
+ return result_code;
+ }
+ unc_keytype_operation_t op[2] = {UNC_OP_INVALID, UNC_OP_INVALID};
+ int nop = 0;
+ if (phase1 == uuc::kUpllUcpUpdate) {
+ op[0] = UNC_OP_UPDATE;
+ op[1] = UNC_OP_CREATE;
+ nop = 2;
+ } else if (phase1 == uuc::kUpllUcpDelete) {
+ op[0] = UNC_OP_DELETE;
+ nop = 1;
+ }
+ for (int i = 0; i < nop; i++) {
+ unc_keytype_operation_t op1 = op[i];
+ uuc::UpdateCtrlrPhase phase = (op[i] == UNC_OP_UPDATE)?uuc::kUpllUcpUpdate:
+ ((op[i] == UNC_OP_CREATE)?uuc::kUpllUcpCreate:
+ ((op[i] == UNC_OP_DELETE)?uuc::kUpllUcpDelete:uuc::kUpllUcpInvalid));
+ /* retreives the delta of running and audit configuration */
+ UPLL_LOG_DEBUG("Operation is %d", op[i]);
+ result_code = DiffConfigDB(UPLL_DT_RUNNING, UPLL_DT_AUDIT, op[i],
+ ckv_running_db, ckv_audit_db,
+ &cursor, dmi, ctrlr, tbl);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DiffConfigDB failed - %d", result_code);
+ return result_code;
+ }
+ if (cursor == NULL) {
+ UPLL_LOG_DEBUG("cursor is null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ while (uud::kDalRcSuccess == (db_result = dmi->GetNextRecord(cursor))) {
+ op1 = op[i];
+ if (phase != uuc::kUpllUcpDelete) {
+ uint8_t *db_ctrlr = NULL;
+ GET_USER_DATA_CTRLR(ckv_running_db,db_ctrlr);
+ UPLL_LOG_DEBUG("db ctrl_id and audit ctlr_id are %s %s",
+ db_ctrlr, ctrlr_id);
+ // Skipping the controller ID if the controller id in DB and
+ // controller id available for Audit are not the same
+ if (db_ctrlr && strncmp(reinterpret_cast<const char *>(db_ctrlr),
+ reinterpret_cast<const char *>(ctrlr_id),
+ strlen(reinterpret_cast<const char *>(ctrlr_id)))) {
+ continue;
+ }
+ }
+ /* ignore records of another controller for create and update operation */
+ UPLL_LOG_DEBUG("Diff Record: Keytype: Operation: is %d\n %d\n %s\n",
+ keytype, op[i], ckv_running_db->ToStrAll().c_str());
+ switch (phase) {
+ case uuc::kUpllUcpDelete:
+ UPLL_LOG_TRACE("Deleted record is %s ",
+ ckv_running_db->ToStrAll().c_str());
+ result_code = GetChildConfigKey(ckv_driver_req, ckv_running_db);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed. err_code & phase %d %d",
+ result_code, phase);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ break;
+ case uuc::kUpllUcpCreate:
+ UPLL_LOG_TRACE("Created record is %s ",
+ ckv_running_db->ToStrAll().c_str());
+ result_code = DupConfigKeyVal(ckv_driver_req, ckv_running_db, tbl);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed. err_code & phase %d %d",
+ result_code, phase);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ break;
+ case uuc::kUpllUcpUpdate:
+ ckv_audit_dup_db = NULL;
+ ckv_driver_req = NULL;
+ UPLL_LOG_TRACE("UpdateRecord record is %s ",
+ ckv_running_db->ToStrAll().c_str());
+ UPLL_LOG_TRACE("UpdateRecord record is %s ",
+ ckv_audit_db->ToStrAll().c_str());
+ result_code = DupConfigKeyVal(ckv_driver_req, ckv_running_db, tbl);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed for running record. \
+ err_code & phase %d %d", result_code, phase);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ result_code = DupConfigKeyVal(ckv_audit_dup_db, ckv_audit_db, tbl);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed for audit record. \
+ err_code & phase %d %d", result_code, phase);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ break;
+ default:
+ UPLL_LOG_DEBUG("Invalid operation %d", phase);
+ return UPLL_RC_ERR_NO_SUCH_OPERATION;
+ break;
+ }
+ GET_USER_DATA_CTRLR_DOMAIN(ckv_driver_req, ctrlr_dom);
+ if (NULL == ctrlr_dom.ctrlr || NULL == ctrlr_dom.domain) {
+ UPLL_LOG_INFO("controller id or domain is NULL");
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ckv_audit_dup_db);
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t db_flag = 0;
+ GET_USER_DATA_FLAGS(ckv_driver_req, db_flag);
+ // If portmap flag is not set at running and the operation is update
+ // then portmap is deleted in the update phase from UNC
+ // hence policingmap also should get deleted from controller
+ // hence sending the delete request to the controller driver
+ if ((SET_FLAG_PORTMAP & db_flag)) {
+ // Continue to further operations
+ } else {
+ if (op1 == UNC_OP_UPDATE) {
+ op1 = UNC_OP_DELETE;
+ } else {
+ // If there is no portmap configured then configuration is not
+ // sent to controller.
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ckv_audit_dup_db);
+ continue;
+ }
+ }
+ if (UNC_OP_UPDATE == op1) {
+ void *running_val = NULL;
+ bool invalid_attr = false;
+ running_val = GetVal(ckv_driver_req);
+ invalid_attr = FilterAttributes(running_val,
+ GetVal(ckv_audit_dup_db), false, UNC_OP_UPDATE);
+ if (invalid_attr) {
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ckv_audit_dup_db);
+ continue;
+ }
+ }
+
+ DELETE_IF_NOT_NULL(ckv_audit_dup_db);
+ pfcdrv_val_vbrif_policingmap *pfc_val =
+ reinterpret_cast<pfcdrv_val_vbrif_policingmap *>
+ (ConfigKeyVal::Malloc(sizeof(pfcdrv_val_vbrif_policingmap_t)));
+ pfcdrv_val_vbrif_vextif *pfc_val_ext =
+ reinterpret_cast<pfcdrv_val_vbrif_vextif *>\
+ (ConfigKeyVal::Malloc(sizeof(pfcdrv_val_vbrif_vextif_t)));
+ if (UNC_OP_DELETE == op1) {
+ vext_datatype = UPLL_DT_AUDIT;
+ } else {
+ vext_datatype = UPLL_DT_RUNNING;
+ }
+ UPLL_LOG_DEBUG("GetVexternalInformation (%d)", vext_datatype);
+ result_code = GetVexternalInformation(ckv_driver_req, vext_datatype, pfc_val,
+ pfc_val_ext, db_flag, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetVexternalInformation fail");
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+ val_policingmap_t* val = reinterpret_cast<val_policingmap_t *>(GetVal(ckv_running_db));
+ UPLL_LOG_DEBUG("val_policingmap_t (%s)", val->policer_name);
+
+ pfc_val->valid[PFCDRV_IDX_VAL_POLICINGMAP_PM] = UNC_VF_VALID;
+ memcpy(&pfc_val->val_policing_map, val, sizeof(val_policingmap_t));
+
+ pfc_val->valid[PFCDRV_IDX_VAL_VBRIF_VEXTIF_PM] = UNC_VF_VALID;
+ memcpy(&pfc_val->val_vbrif_vextif, pfc_val_ext,
+ sizeof(pfcdrv_val_vbrif_vextif_t));
+
+ ConfigKeyVal::Free(pfc_val_ext);
+
+ ckv_driver_req->SetCfgVal(new ConfigVal(IpctSt::kIpcStPfcdrvValVbrifPolicingmap,
+ pfc_val));
+
+ upll_keytype_datatype_t dt_type = (op1 == UNC_OP_DELETE)?
+ UPLL_DT_AUDIT : UPLL_DT_RUNNING;
+ result_code = GetRenamedControllerKey(ckv_driver_req, UPLL_DT_RUNNING,
+ dmi, &ctrlr_dom);
+ if (result_code != UPLL_RC_SUCCESS && result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG(" GetRenamedControllerKey failed err code(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+ IpcResponse ipc_response;
+ memset(&ipc_response, 0, sizeof(IpcResponse));
+ IpcRequest ipc_req;
+ memset(&ipc_req, 0, sizeof(IpcRequest));
+ ipc_req.header.clnt_sess_id = session_id;
+ ipc_req.header.config_id = config_id;
+ ipc_req.header.operation = op1;
+ ipc_req.header.datatype = UPLL_DT_CANDIDATE;
+ ipc_req.ckv_data = ckv_driver_req;
+ if (!uui::IpcUtil::SendReqToDriver((const char *)ctrlr_dom.ctrlr, reinterpret_cast<char *>
+ (ctrlr_dom.domain), PFCDRIVER_SERVICE_NAME,
+ PFCDRIVER_SVID_LOGICAL, &ipc_req, true, &ipc_response)) {
+ UPLL_LOG_INFO("Request to driver for Key %d for controller %s failed ",
+ ckv_driver_req->get_key_type(), reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (ipc_response.header.result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("driver return failure err_code is %d", ipc_response.header.result_code);
+ ConfigKeyVal *resp = NULL;
+ result_code = GetChildConfigKey(resp,ipc_response.ckv_data);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed for ipc response ckv err_code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ pfcdrv_val_vbrif_policingmap *pfc_val_out =
+ reinterpret_cast<pfcdrv_val_vbrif_policingmap *>
+ (GetVal(ipc_response.ckv_data));
+ if (NULL == pfc_val_out) {
+ DELETE_IF_NOT_NULL(resp);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val_policingmap_t *out_val_pm = reinterpret_cast
+ <val_policingmap_t *>(ConfigKeyVal::Malloc(sizeof
+ (val_policingmap_t)));
+ memcpy(out_val_pm, &pfc_val_out->val_policing_map,
+ sizeof(val_policingmap_t));
+ resp->AppendCfgVal(IpctSt::kIpcStValPolicingmap, out_val_pm);
+ result_code = UpdateAuditConfigStatus(UNC_CS_INVALID, phase, resp);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("Update Audit config status failed %d",
+ result_code);
+ DELETE_IF_NOT_NULL(resp);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ result_code = UpdateConfigDB(resp, dt_type, UNC_OP_UPDATE,
+ dmi, tbl);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed for ipc response ckv err_code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(resp);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(resp);
+ }
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ *ctrlr_affected = true;
+ }
+ dmi->CloseCursor(cursor, true);
+ DELETE_IF_NOT_NULL(ckv_running_db);
+ DELETE_IF_NOT_NULL(ckv_audit_db);
+ }
+ UPLL_LOG_DEBUG("No more record");
+ if (uud::kDalRcSuccess != db_result) {
+ UPLL_LOG_DEBUG("GetNextRecord from database failed - %d", db_result);
+ result_code = DalToUpllResCode(db_result);
+ }
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)
+ ? UPLL_RC_SUCCESS : result_code;
+ return result_code;
+}
+
+upll_rc_t VbrIfPolicingMapMoMgr::DeleteChildrenPOM(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+
+ if (NULL == ikey || NULL == dmi) {
+ UPLL_LOG_DEBUG("DeleteMo Failed. Insufficient input parameters");
+ return result_code;
+ }
+
+ // 1)Get vbrif associated ctrlr name and invoke the PP and PPE functions to
+ // decrement the refcount capability. If refcount is zero, remove the record
+ // in policingprofilectrltbl and if refcount not zero update the refcount in
+ // policingprofilectrltbl
+ // 2)Delete the record in policingprofileentryctrltbl
+ ConfigKeyVal *okey = NULL;
+ result_code = GetChildConfigKey(okey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
+ return result_code;
+ }
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone,
+ kOpInOutCtrlr | kOpInOutDomain };
+ result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("UPLL_RC_ERR_NO_SUCH_INSTANCE");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ val_policingmap_t *val_pm = reinterpret_cast<val_policingmap_t *>
+ (GetVal(okey));
+ if (UNC_VF_VALID == val_pm->valid[UPLL_IDX_POLICERNAME_PM]) {
+ result_code = UpdateRefCountInPPCtrlr(okey, dt_type, dmi,
+ UNC_OP_DELETE);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateRefCountInPPCtrlr Error DB (%d)", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ }
+ DELETE_IF_NOT_NULL(okey);
+ // Delete the record in vbrifpolicingmap table
+ ConfigKeyVal *temp_ikey = NULL;
+ result_code = GetChildConfigKey(temp_ikey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed");
+ return result_code;
+ }
+ result_code = UpdateConfigDB(temp_ikey, dt_type, UNC_OP_DELETE, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DeleteMo Failed. UpdateConfigdb failed to delete - %d",
+ result_code);
+ DELETE_IF_NOT_NULL(temp_ikey);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(temp_ikey);
+ UPLL_LOG_DEBUG("DeleteMo Success");
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VbrIfPolicingMapMoMgr::IsPolicingProfileConfigured(
+ const char* policingprofile_name,
+ DalDmlIntf *dmi) {
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+ ConfigKeyVal *ckv = NULL;
+ result_code = GetChildConfigKey(ckv, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ return result_code;
+ }
+ if (!ckv) return UPLL_RC_ERR_GENERIC;
+ val_policingmap_t *pm_val = reinterpret_cast
+ < val_policingmap_t *>(ConfigKeyVal::Malloc(sizeof(val_policingmap_t)));
+ uuu::upll_strncpy(pm_val->policer_name, policingprofile_name,
+ (kMaxLenPolicingProfileName + 1));
+ pm_val->valid[UPLL_IDX_POLICERNAME_PM] = UNC_VF_VALID;
+ ckv->AppendCfgVal(IpctSt::kIpcStValPolicingmap, pm_val);
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone };
+ result_code = ReadConfigDB(ckv, UPLL_DT_CANDIDATE, UNC_OP_READ, dbop,
+ dmi, MAINTBL);
+ DELETE_IF_NOT_NULL(ckv);
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ return UPLL_RC_SUCCESS;
+ } else if (UPLL_RC_SUCCESS == result_code) {
+ result_code = UPLL_RC_ERR_INSTANCE_EXISTS;
+ }
+ return result_code;
+}
+
+upll_rc_t VbrIfPolicingMapMoMgr::SetValidAudit(ConfigKeyVal *&ikey) {
+ UPLL_FUNC_TRACE;
+ val_policingmap_t *val = reinterpret_cast
+ <val_policingmap_t *>(GetVal(ikey));
+ if (NULL == val) {
+ UPLL_LOG_DEBUG("val is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (val->valid[0] == UNC_VF_VALID) {
+ val->cs_attr[0] = UNC_CS_APPLIED;
+ } else if (val->valid[0] == UNC_VF_INVALID) {
+ val->cs_attr[0] = UNC_CS_NOT_APPLIED;
+ }
+ val->cs_row_status = UNC_CS_APPLIED;
+ return UPLL_RC_SUCCESS;
+}
+
+bool VbrIfPolicingMapMoMgr::FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op) {
+ UPLL_FUNC_TRACE;
+ if (op != UNC_OP_CREATE)
+ return CompareValidValue(val1, val2, copy_to_running);
+ return false;
+}
+
+upll_rc_t VbrIfPolicingMapMoMgr::UpdateConfigStatus(ConfigKeyVal *vbrif_key,
+ unc_keytype_operation_t op,
+ uint32_t driver_result,
+ ConfigKeyVal *upd_key,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ctrlr_key) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_policingmap_t *vbr_pm;
+
+ unc_keytype_configstatus_t cs_status =
+ (driver_result == UPLL_RC_SUCCESS) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
+ vbr_pm = reinterpret_cast<val_policingmap_t *>(GetVal(vbrif_key));
+ if (vbr_pm == NULL) return UPLL_RC_ERR_GENERIC;
+ if (op == UNC_OP_CREATE) {
+ vbr_pm->cs_row_status = cs_status;
+ } else if (op == UNC_OP_UPDATE) {
+ void *vbrpm = reinterpret_cast<void *>(vbr_pm);
+ CompareValidValue(vbrpm, GetVal(upd_key), true);
+ } else {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_TRACE("%s", (vbrif_key->ToStrAll()).c_str());
+ val_policingmap_t *vbr_val2 = reinterpret_cast<val_policingmap_t *>(GetVal(upd_key));
+ if (UNC_OP_UPDATE == op) {
+ UPLL_LOG_TRACE("%s", (upd_key->ToStrAll()).c_str());
+ vbr_pm->cs_row_status = vbr_val2->cs_row_status;
+ }
+ if (UNC_VF_NOT_SUPPORTED == vbr_pm->valid[0]) {
+ vbr_pm->cs_attr[0] = UNC_CS_NOT_SUPPORTED;
+ } else if ((UNC_VF_VALID == vbr_pm->valid[0])
+ || (UNC_VF_VALID_NO_VALUE == vbr_pm->valid[0])) {
+ vbr_pm->cs_attr[0] = cs_status;
+ } else if ((UNC_VF_INVALID == vbr_pm->valid[0]) &&
+ (UNC_OP_CREATE == op)) {
+ vbr_pm->cs_attr[0] = UNC_CS_NOT_APPLIED;
+ } else if ((UNC_VF_INVALID == vbr_pm->valid[0]) &&
+ (UNC_OP_UPDATE == op)) {
+ vbr_pm->cs_attr[0] = vbr_val2->cs_attr[0];
+ }
+ return result_code;
+}
+
+upll_rc_t VbrIfPolicingMapMoMgr::IsRenamed(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi,
+ uint8_t &rename) {
+ UPLL_FUNC_TRACE;
+ UPLL_LOG_DEBUG("VbrIfPolicingMapMoMgr IsRenamed");
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag | kOpInOutCtrlr
+ | kOpInOutDomain };
+ ConfigKeyVal *okey = NULL;
+ upll_rc_t result_code;
+ /* rename is set implies user wants the ikey
+ * populated with val from db */
+ if (!rename) {
+ if (UNC_KT_VBRIF_POLICINGMAP == ikey->get_key_type()) {
+ UPLL_LOG_DEBUG("UNC_KT_VBRIF_POLICINGMAP");
+ result_code = GetChildConfigKey(okey, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("Returning error %d",result_code);
+ return result_code;
+ }
+ } else if (UNC_KT_VBRIF_POLICINGMAP_ENTRY == ikey->get_key_type()) {
+ UPLL_LOG_DEBUG("UNC_KT_VBRIF_POLICINGMAP_CONTROLLER");
+
+ key_vbr_if_t *out_key = reinterpret_cast<key_vbr_if_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vbr_if_t)));
+
+ key_vbrif_policingmap_entry_t *in_key = reinterpret_cast
+ <key_vbrif_policingmap_entry_t *>(ikey->get_key());
+
+ uuu::upll_strncpy(out_key->vbr_key.vtn_key.vtn_name,
+ in_key->vbrif_key.vbr_key.vtn_key.vtn_name,
+ (kMaxLenVtnName + 1));
+ uuu::upll_strncpy(out_key->vbr_key.vbridge_name,
+ in_key->vbrif_key.vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+ uuu::upll_strncpy(out_key->if_name,
+ in_key->vbrif_key.if_name,
+ (kMaxLenVnodeName + 1));
+
+ okey = new ConfigKeyVal(UNC_KT_VBRIF_POLICINGMAP,
+ IpctSt::kIpcStKeyVbrIf,
+ out_key, NULL);
+ }
+ } else {
+ okey = ikey;
+ }
+
+ result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if ((result_code != UPLL_RC_SUCCESS) &&
+ (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG("Returning error code %d",result_code);
+ if (okey != ikey)
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ GET_USER_DATA_FLAGS(okey, rename);
+ controller_domain_t ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+
+ GET_USER_DATA_CTRLR_DOMAIN(ikey,ctrlr_dom);
+ UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+ SET_USER_DATA_CTRLR_DOMAIN(okey,ctrlr_dom);
+ UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+
+ SET_USER_DATA(ikey,okey);
+ rename &= RENAME;
+ if (okey != ikey)
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VbrIfPolicingMapMoMgr::SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_policingmap_t *val_pm = reinterpret_cast
+ <val_policingmap_t *>(GetVal(ikey));
+ if (!val_pm) {
+ UPLL_LOG_DEBUG("Val is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigKeyVal *pkey = NULL;
+ if (UNC_OP_CREATE == req->operation) {
+ result_code = GetParentConfigKey(pkey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetParentConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_VBR_IF)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("mgr is NULL");
+ DELETE_IF_NOT_NULL(pkey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t rename = 0;
+ result_code = mgr->IsRenamed(pkey, req->datatype, dmi, rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(pkey);
+ return result_code;
+ }
+
+ UPLL_LOG_DEBUG("Flag from parent : %d", rename);
+ DELETE_IF_NOT_NULL(pkey);
+ // Check flowlist is renamed
+ if ((UNC_VF_VALID == val_pm->valid[UPLL_IDX_POLICERNAME_PM]) &&
+ ((UNC_OP_CREATE == req->operation))) {
+ ConfigKeyVal *pp_ckv = NULL;
+ result_code = GetPolicingProfileConfigKey(reinterpret_cast<const char *>
+ (val_pm->policer_name), pp_ckv, dmi);
+ MoMgrImpl *pp_mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_POLICING_PROFILE)));
+ if (NULL == pp_mgr) {
+ UPLL_LOG_DEBUG("pp_mgr is NULL");
+ DELETE_IF_NOT_NULL(pp_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t pp_rename = 0;
+ result_code = pp_mgr->IsRenamed(pp_ckv, req->datatype, dmi, pp_rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(pp_ckv);
+ return result_code;
+ }
+ if (pp_rename & 0x01) {
+ rename |= POLICINGPROFILE_RENAME; // TODO Check for correct flag value
+ }
+ DELETE_IF_NOT_NULL(pp_ckv);
+ }
+ SET_USER_DATA_FLAGS(ikey, rename);
+ } else if (UNC_OP_UPDATE == req->operation) {
+ uint8_t rename = 0;
+ ConfigKeyVal *dup_ckv = NULL;
+ result_code = GetChildConfigKey(dup_ckv, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG(" GetChildConfigKey failed");
+ return result_code;
+ }
+ DbSubOp dbop1 = {kOpReadSingle, kOpMatchNone, kOpInOutFlag};
+ result_code = ReadConfigDB(dup_ckv, req->datatype, UNC_OP_READ,
+ dbop1, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(dup_ckv);
+ return result_code;
+ }
+ GET_USER_DATA_FLAGS(dup_ckv, rename);
+ DELETE_IF_NOT_NULL(dup_ckv);
+ if (UNC_VF_VALID == val_pm->valid[UPLL_IDX_POLICERNAME_PM]) {
+ ConfigKeyVal *pp_ckv = NULL;
+ result_code = GetPolicingProfileConfigKey(reinterpret_cast<const char *>
+ (val_pm->policer_name), pp_ckv, dmi);
+ MoMgrImpl *pp_mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_POLICING_PROFILE)));
+ if (NULL == pp_mgr) {
+ UPLL_LOG_DEBUG("pp_mgr is NULL");
+ DELETE_IF_NOT_NULL(pp_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t pp_rename = 0;
+ result_code = pp_mgr->IsRenamed(pp_ckv, req->datatype, dmi, pp_rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(pp_ckv);
+ return result_code;
+ }
+ if (pp_rename & 0x01) {
+ rename |= POLICINGPROFILE_RENAME; // TODO Check for correct flag value
+ } else {
+ rename &= NO_POLICINGPROFILE_RENAME;
+ }
+ DELETE_IF_NOT_NULL(pp_ckv);
+ } else if (UNC_VF_VALID_NO_VALUE == val_pm->valid
+ [UPLL_IDX_POLICERNAME_PM]) {
+ rename &= NO_POLICINGPROFILE_RENAME; // TODO Check for correct flag value. No rename flowlist value should be set
+ }
+ SET_USER_DATA_FLAGS(ikey, rename);
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VbrIfPolicingMapMoMgr::GetPolicingProfileConfigKey(
+ const char *pp_name, ConfigKeyVal *&okey,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_POLICING_PROFILE)));
+ result_code = mgr->GetChildConfigKey(okey, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
+ return result_code;
+ }
+ key_policingprofile_t *okey_key = reinterpret_cast<key_policingprofile_t *>
+ (okey->get_key());
+ uuu::upll_strncpy(okey_key->policingprofile_name,
+ pp_name,
+ (kMaxLenPolicingProfileName+1));
+ return UPLL_RC_SUCCESS;
+}
} // kt_momgr
} // upll
} // unc
VBRIFPOLICINGMAPTBL = 0, NVBRIFPOLICINGMAPTBL
};
-#define CONFIGKEYVALCLEAN(ikey) { \
- if (ikey) { \
- delete ikey; \
- ikey = NULL; \
- } \
-}
-
/*This file declares interfaces for keyType KT_VBR_POLICINGMAP */
/**
* @Brief VbrPolicingMapMoMgr class handles all the request
static BindInfo vbrifpolicingmap_bind_info[];
static BindInfo key_vbrifpm_maintbl_rename_bind_info[];
static BindInfo key_vbrifpm_policyname_maintbl_rename_bind_info[];
-
+ uint32_t cur_instance_count;
/**
* @Brief Validates the syntax of the specified key and value structure
* for KT_VBR_POLICINGMAP keytype
* @retval UPLL_RC_SUCCESS Successfull completion.
* */
upll_rc_t GetControllerId(ConfigKeyVal *ikey, ConfigKeyVal *&okey,
+ upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi);
/**
*/
upll_rc_t GetParentConfigKey(ConfigKeyVal *&okey,
ConfigKeyVal *ikey);
+
+ /**
+ * @brief Method used for Restoring Profile in the Controller Table
+ *
+ * @param[in] ikey Pointer to ConfigKeyVal Class
+ * @param[in] dt_type Describes Configiration Information.
+ * @param[in] tbl Describe the destination table
+ * @param[in] dmi Pointer to DalDmlIntf Class.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_DB_ACCESS DB Read/Write error.
+ * @retval UPLL_RC_ERR_INSTANCE_EXISTS Record already exists
+ * @retval UPLL_RC_ERR_GENERIC Returned Generic Error.
+ */
+
+ upll_rc_t RestorePOMInCtrlTbl(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl,
+ DalDmlIntf* dmi);
+
upll_rc_t ReadDetail(ConfigKeyVal *ikey,
ConfigKeyVal *dup_key,
IpcResponse *ipc_response,
ConfigKeyVal *&ikey,
DalDmlIntf *dmi);
- upll_rc_t ReadDTSiblingDetail(ConfigKeyVal *ikey,
- ConfigKeyVal *dup_key,
- IpcResponse *ipc_response,
- upll_keytype_datatype_t dt_type,
- unc_keytype_operation_t op,
- DbSubOp dbop,
- DalDmlIntf *dmi,
- int count,
- ConfigKeyVal** resp_key,
- ConfigKeyVal* tctrl_key);
-
bool CompareKey(void *key1, void *key2);
upll_rc_t SwapKeyVal(ConfigKeyVal *ikey,
upll_rc_t SetVlinkPortmapConfiguration(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
- InterfacePortMapInfo flag);
+ InterfacePortMapInfo flag,
+ unc_keytype_operation_t oper);
upll_rc_t GetVexternalInformation(ConfigKeyVal* ck_main,
upll_keytype_datatype_t dt_type,
upll_rc_t ReadSiblingCount(IpcReqRespHeader *req,
ConfigKeyVal* ikey,
DalDmlIntf *dmi);
+
+ upll_rc_t AuditUpdateController(unc_key_type_t keytype,
+ const char *ctrlr_id,
+ uint32_t session_id,
+ uint32_t config_id,
+ uuc::UpdateCtrlrPhase phase,
+ bool *ctrlr_affected,
+ DalDmlIntf *dmi);
+
+ upll_rc_t CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id);
+
+ upll_rc_t DeleteChildrenPOM(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi);
+
+ upll_rc_t IsPolicingProfileConfigured(const char* policingprofile_name,
+ DalDmlIntf *dmi);
+
+ upll_rc_t SetValidAudit(ConfigKeyVal *&ikey);
+
+ upll_rc_t UpdateVnodeVal(ConfigKeyVal *ikey, DalDmlIntf *dmi,
+ upll_keytype_datatype_t data_type,
+ bool &no_rename);
+
+ bool FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op);
+
+ upll_rc_t IsRenamed(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi,
+ uint8_t &rename);
+
+ upll_rc_t GetPolicingProfileConfigKey(
+ const char *pp_name, ConfigKeyVal *&okey,
+ DalDmlIntf *dmi);
+
+ upll_rc_t SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req);
};
} // kt_momgr
} // upll
ST_META_VAL, offsetof(val_vbr_st,
valid[0]),
uud::kDalUint8, 1 },
+ { uudst::vbridge::kDbiCsRowStatus,
+ CS_VAL, offsetof(val_vbr,
+ cs_row_status),
+ uud::kDalUint8, 1 },
{ uudst::vbridge::kDbiCsCtrlrName,
CS_VAL, offsetof(val_vbr, cs_attr[0]),
uud::kDalUint8, 1 },
{ uudst::vbridge::kDbiCsHostAddrMask,
CS_VAL, offsetof(val_vbr, cs_attr[4]),
uud::kDalUint8, 1 },
- { uudst::vbridge::kDbiCsRowStatus,
- CS_VAL, offsetof(val_vbr,
- cs_row_status),
- uud::kDalUint8, 1 },
{ uudst::vbridge::kDbiVbrFlags, CK_VAL,
offsetof(key_user_data_t, flags),
uud::kDalUint8, 1 } };
table = new Table *[ntable];
table[MAINTBL] = new Table(uudst::kDbiVbrTbl, UNC_KT_VBRIDGE, vbr_bind_info,
IpctSt::kIpcStKeyVbr, IpctSt::kIpcStValVbr,
- uudst::vbridge::kDbiVbrNumCols);
+ (uudst::vbridge::kDbiVbrNumCols+2));
table[RENAMETBL] = new Table(uudst::kDbiVNodeRenameTbl, UNC_KT_VBRIDGE,
vbr_rename_bind_info, IpctSt::kIpcInvalidStNum,
IpctSt::kIpcInvalidStNum,
uint64_t index) {
UPLL_FUNC_TRACE;
key_vbr *vbr_key = reinterpret_cast<key_vbr *>(key);
- bool ret_val = false;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
switch (index) {
case uudst::vbridge::kDbiVtnName:
case uudst::vnode_rename::kDbiUncVtnName:
ConfigKeyVal *parent_key) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- key_vbr *vbr_key = reinterpret_cast<key_vbr *>
+ key_vbr *vbr_key = NULL;
+ if (okey && (okey->get_key())) {
+ vbr_key = reinterpret_cast<key_vbr_t *>
+ (okey->get_key());
+ } else {
+ vbr_key = reinterpret_cast<key_vbr *>
(ConfigKeyVal::Malloc(sizeof(key_vbr)));
+ }
void *pkey;
if (parent_key == NULL) {
- okey = new ConfigKeyVal(UNC_KT_VBRIDGE, IpctSt::kIpcStKeyVbr, vbr_key,
+ if (!okey)
+ okey = new ConfigKeyVal(UNC_KT_VBRIDGE, IpctSt::kIpcStKeyVbr, vbr_key,
NULL);
+ else if (okey->get_key() != vbr_key)
+ okey->SetKey(IpctSt::kIpcStKeyVbr,vbr_key);
return UPLL_RC_SUCCESS;
} else {
pkey = parent_key->get_key();
}
if (!pkey) {
- free(vbr_key);
+ if (!okey || !(okey->get_key()))
+ free(vbr_key);
return UPLL_RC_ERR_GENERIC;
}
uuu::upll_strncpy(vbr_key->vtn_key.vtn_name,
reinterpret_cast<key_vbr *>(pkey)->vtn_key.vtn_name, (kMaxLenVtnName+1));
break;
+ case UNC_KT_VLINK: {
+ uint8_t *vnode_name;
+ uint8_t flags = 0;
+ val_vlink *vlink_val = reinterpret_cast<val_vlink *>(GetVal(parent_key));
+ if (!vlink_val) {
+ free(vbr_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ GET_USER_DATA_FLAGS(parent_key->get_cfg_val(), flags);
+ flags &= VLINK_FLAG_NODE_POS;
+ UPLL_LOG_DEBUG("Vlink flag node position %d",flags);
+ if (flags == kVlinkVnode2) {
+ vnode_name = vlink_val->vnode2_name;
+ } else {
+ vnode_name = vlink_val->vnode1_name;
+ }
+ uuu::upll_strncpy(vbr_key->vbridge_name, vnode_name,
+ (kMaxLenVnodeName + 1));
+ uuu::upll_strncpy(vbr_key->vtn_key.vtn_name, reinterpret_cast<key_vlink *>(
+ parent_key->get_key())->vtn_key.vtn_name , (kMaxLenVtnName+1));
+ }
+ break;
case UNC_KT_VTN:
default:
uuu::upll_strncpy(vbr_key->vtn_key.vtn_name,
reinterpret_cast<key_vtn *>(pkey)->vtn_name, (kMaxLenVtnName+1));
*(vbr_key->vbridge_name) = *"";
}
-// cout << "GetChildConfigKey " << vbr_key->vtn_key.vtn_name << " ";
-// cout << vbr_key->vbridge_name << "";
- okey = new ConfigKeyVal(UNC_KT_VBRIDGE, IpctSt::kIpcStKeyVbr, vbr_key, NULL);
+ if (!okey)
+ okey = new ConfigKeyVal(UNC_KT_VBRIDGE, IpctSt::kIpcStKeyVbr, vbr_key, NULL);
+ else if (okey->get_key() != vbr_key)
+ okey->SetKey(IpctSt::kIpcStKeyVbr,vbr_key);
if (okey == NULL) {
- if (vbr_key) free(vbr_key);
+ free(vbr_key);
result_code = UPLL_RC_ERR_GENERIC;
} else {
SET_USER_DATA(okey, parent_key);
UPLL_LOG_DEBUG("Null ikey param");
return UPLL_RC_ERR_GENERIC;
}
+ DELETE_IF_NOT_NULL(okey);
unc_key_type_t ikey_type = ikey->get_key_type();
if (ikey_type != UNC_KT_VBRIDGE)
return UPLL_RC_ERR_GENERIC;
- void *pkey = (ikey) ? ikey->get_key() : NULL;
+ void *pkey = ikey->get_key();
if (!pkey)
return UPLL_RC_ERR_GENERIC;
key_vtn *vtn_key = reinterpret_cast<key_vtn *>
val_db_vbr_st *ival = reinterpret_cast<val_db_vbr_st *>(tmp->get_val());
if (ival == NULL) {
UPLL_LOG_DEBUG("Null Val structure");
+ delete tmp1;
return UPLL_RC_ERR_GENERIC;
}
val_db_vbr_st *val_vbr = reinterpret_cast<val_db_vbr_st *>
tmp1->AppendCfgVal(tmp2);
}
};
- void *tkey = (req != NULL) ? (req)->get_key() : NULL;
+ void *tkey = (req)->get_key();
if (!tkey) {
UPLL_LOG_DEBUG("Null tkey");
+ DELETE_IF_NOT_NULL(tmp1);
return UPLL_RC_ERR_GENERIC;
}
// cout << "VbrMoMgr::DupConfigKeyVal";
uint8_t *ctrlr_id) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- if (ctrlr_id == NULL)
- return UPLL_RC_ERR_GENERIC;
ConfigKeyVal *unc_key = NULL;
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
val_rename_vnode *rename_vnode = reinterpret_cast<val_rename_vnode *>(
ConfigKeyVal::Malloc(sizeof(val_rename_vnode)));
+ rename_vnode->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_INVALID;
+ rename_vnode->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_INVALID;
key_vbr *ctrlr_key = reinterpret_cast<key_vbr *>(ikey->get_key());
- uuu::upll_strncpy(rename_vnode->ctrlr_vtn_name, ctrlr_key->vtn_key.vtn_name,
+ upll_rc_t ret_val = ValidateKey(reinterpret_cast<char *>(ctrlr_key->vtn_key.vtn_name),
+ kMinLenVtnName, kMaxLenVtnName);
+ if (ret_val == UPLL_RC_SUCCESS) {
+ uuu::upll_strncpy(rename_vnode->ctrlr_vtn_name, ctrlr_key->vtn_key.vtn_name,
(kMaxLenVtnName+1));
- uuu::upll_strncpy(rename_vnode->ctrlr_vnode_name, ctrlr_key->vbridge_name,
+ rename_vnode->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
+ }
+ ret_val = ValidateKey(reinterpret_cast<char *>(ctrlr_key->vbridge_name),
+ kMinLenVnodeName, kMaxLenVnodeName);
+ if (ret_val == UPLL_RC_SUCCESS) {
+ uuu::upll_strncpy(rename_vnode->ctrlr_vnode_name, ctrlr_key->vbridge_name,
(kMaxLenVnodeName+1));
+ rename_vnode->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_VALID;
+ }
result_code = GetChildConfigKey(unc_key, NULL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetChildConfigKey Failed with result_code %d",
FREE_IF_NOT_NULL(rename_vnode);
return result_code;
}
- SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
- rename_vnode->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
- rename_vnode->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_VALID;
+ if (ctrlr_id) {
+ SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
+ }else
+ dbop.matchop = kOpMatchNone;
unc_key->AppendCfgVal(IpctSt::kIpcStValRenameVtn, rename_vnode);
// UPLL_LOG_TRACE("Before Read from Rename Table %s", (unc_key->ToStrAll()).c_str());
result_code = ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
}
SET_USER_DATA(ikey, unc_key);
}
- if (unc_key)
- delete unc_key;
+ delete unc_key;
return result_code;
}
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr | kOpMatchDomain,
kOpInOutFlag };
result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi, RENAMETBL);
- if (result_code != UPLL_RC_SUCCESS)
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(okey);
return result_code;
+ }
val_rename_vnode *rename_val = reinterpret_cast<val_rename_vnode *>
- (GetVal(okey));
- if (!rename_val) return UPLL_RC_ERR_GENERIC;
+ (GetVal(okey));
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("Val is Empty");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
key_vbr *ctrlr_key = reinterpret_cast<key_vbr *>(ikey->get_key());
- if (!ctrlr_key) return UPLL_RC_ERR_GENERIC;
+ if (!ctrlr_key) {
+ UPLL_LOG_DEBUG("Key is Empty");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_TRACE("Rename flag %d", rename);
if (rename & VTN_RENAME) { /* vtn renamed */
uuu::upll_strncpy(ctrlr_key->vtn_key.vtn_name, rename_val->ctrlr_vtn_name,
(kMaxLenVtnName+1));
(kMaxLenVnodeName+1));
}
SET_USER_DATA_FLAGS(ikey, rename);
- delete okey;
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_SUCCESS;
}
val_db_vbr_st *val_vbrst;
unc_keytype_configstatus_t cs_status =
- (driver_result == UPLL_RC_SUCCESS) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
+ (driver_result == UPLL_RC_SUCCESS) ? UNC_CS_APPLIED
+ : UNC_CS_NOT_APPLIED;
vbr_val = reinterpret_cast<val_vbr *>(GetVal(vbr_key));
+ val_vbr *vbr_val2 = reinterpret_cast<val_vbr *>(GetVal(upd_key));
if (vbr_val == NULL) return UPLL_RC_ERR_GENERIC;
+ UPLL_LOG_TRACE("Key in Candidate %s", (vbr_key->ToStrAll()).c_str());
+
if (op == UNC_OP_CREATE) {
vbr_val->cs_row_status = cs_status;
val_vbrst = reinterpret_cast<val_db_vbr_st *>
(ConfigKeyVal::Malloc(sizeof(val_db_vbr_st)));
- val_vbrst->vbr_val_st.oper_status = UPLL_OPER_STATUS_UNINIT;
+ // val_vbrst->vbr_val_st.oper_status = UPLL_OPER_STATUS_UNINIT;
+ val_vbrst->vbr_val_st.oper_status = UPLL_OPER_STATUS_DOWN;
val_vbrst->down_count = 0;
val_vbrst->fault_count = 0;
val_vbrst->vbr_val_st.valid[UPLL_IDX_OPER_STATUS_VBRS] = UNC_VF_VALID;
} else if (op == UNC_OP_UPDATE) {
void *vbrval = reinterpret_cast<void *>(vbr_val);
CompareValidValue(vbrval, GetVal(upd_key), true);
+ UPLL_LOG_TRACE("Key in Running %s", (upd_key->ToStrAll()).c_str());
+ vbr_val->cs_row_status = vbr_val2->cs_row_status;
} else {
return UPLL_RC_ERR_GENERIC;
}
for (unsigned int loop = 0;
loop < sizeof(vbr_val->valid) / sizeof(vbr_val->valid[0]); ++loop) {
- // Setting CS to the not supported attributes
- if (UNC_VF_NOT_SOPPORTED == vbr_val->valid[loop]) {
- vbr_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
- } else if ((UNC_VF_VALID == vbr_val->valid[loop])
+ if ((UNC_VF_VALID == vbr_val->valid[loop])
|| (UNC_VF_VALID_NO_VALUE == vbr_val->valid[loop])) {
- vbr_val->cs_attr[loop] = vbr_val->cs_row_status;
+ // Description is set to APPLIED
+ if (loop == UPLL_IDX_DESC_VBR)
+ vbr_val->cs_attr[loop] = UNC_CS_APPLIED;
+ else
+ vbr_val->cs_attr[loop] = cs_status;
+ } else if ((UNC_VF_INVALID == vbr_val->valid[loop]) &&
+ (UNC_OP_CREATE == op)) {
+ vbr_val->cs_attr[loop] = UNC_CS_APPLIED;
+ } else if ((UNC_VF_INVALID == vbr_val->valid[loop]) &&
+ (UNC_OP_UPDATE == op)) {
+ vbr_val->cs_attr[loop] = vbr_val2->cs_attr[loop];
}
}
return result_code;
}
if (uuc::kUpllUcpCreate == phase)
val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
for (unsigned int loop = 0; loop < sizeof(val->valid) / sizeof(uint8_t);
++loop) {
if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
UPLL_LOG_DEBUG("Input is NULL");
return UPLL_RC_ERR_GENERIC;
}
+ ConfigKeyVal *dup_key = NULL;
+ result_code = GetChildConfigKey(dup_key, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed");
+ if (dup_key) delete dup_key;
+ return result_code;
+ }
/*
* Here getting FULL Key (VTN & VBR Name )
*/
- result_code = ReadConfigDB(ikey, UPLL_DT_IMPORT, UNC_OP_READ, dbop, dmi,
+ result_code = ReadConfigDB(dup_key, UPLL_DT_IMPORT, UNC_OP_READ, dbop, dmi,
MAINTBL);
- if (UPLL_RC_SUCCESS != result_code) return result_code;
- while (ikey) {
+ if (UPLL_RC_SUCCESS != result_code) {
+ if (dup_key) delete dup_key;
+ return result_code;
+ }
+ ConfigKeyVal *travel = dup_key;
+ while (travel) {
/*
* Checks the Val structure is available or not.If availabl
* Checks Host address value is available or not in import ckval
*/
- result_code = DupConfigKeyVal(tkey, ikey, MAINTBL);
+ result_code = DupConfigKeyVal(tkey, travel, MAINTBL);
if (UPLL_RC_SUCCESS != result_code || tkey == NULL) {
UPLL_LOG_DEBUG(" DupConfigKeyVal is Failed");
if (tkey) delete tkey;
+ if (dup_key) delete dup_key;
return result_code;
}
/* Same Name should not present in the vnodes in running*/
- result_code = VnodeChecks(tkey, UPLL_DT_RUNNING, dmi);
- if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ result_code = VnodeChecks(tkey, UPLL_DT_CANDIDATE, dmi);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code ||
+ UPLL_RC_ERR_CFG_SEMANTIC == result_code) {
+ ikey->ResetWith(tkey);
if (tkey) delete tkey;
- UPLL_LOG_DEBUG("VBridge Name Conflict %s", (tkey->ToStrAll()).c_str());
+ if (dup_key) delete dup_key;
+ UPLL_LOG_DEBUG("VBridge Name Conflict %s", (ikey->ToStrAll()).c_str());
return UPLL_RC_ERR_MERGE_CONFLICT;
}
/* Any other DB error */
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("VnodeChecks Failed %d", result_code);
if (tkey) delete tkey;
+ if (dup_key) delete dup_key;
return result_code;
}
/*Checsk the hostaddress should not be present same vtn */
memset(reinterpret_cast<key_vbr_t *>
(tkey->get_key())->vbridge_name, 0, (kMaxLenVnodeName+1));
- result_code = ReadConfigDB(tkey, UPLL_DT_RUNNING, UNC_OP_READ, dbop, dmi,
+ result_code = ReadConfigDB(tkey, UPLL_DT_CANDIDATE, UNC_OP_READ, dbop, dmi,
MAINTBL);
if (UPLL_RC_SUCCESS == result_code) {
+ ikey->ResetWith(tkey);
if (tkey) delete tkey;
+ if(dup_key) delete dup_key;
UPLL_LOG_DEBUG("VBridge Host Address Conflict");
return UPLL_RC_ERR_MERGE_CONFLICT;
}
if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
UPLL_LOG_DEBUG("ReadConfigDB Failed %d", result_code);
if (tkey) delete tkey;
+ if (dup_key) delete dup_key;
return result_code;
}
}
- if (tkey) delete tkey;
- ikey = ikey->get_next_cfg_key_val();
+ if (tkey) {
+ delete tkey;
+ tkey = NULL;
+ }
+ travel = travel->get_next_cfg_key_val();
}
+ if (dup_key)
+ delete dup_key;
return result_code;
}
result_code = ReadConfigDB(tmp_key, UPLL_DT_IMPORT, UNC_OP_READ, dbop, dmi,
MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("ReadConfigDB Failed");
+ UPLL_LOG_INFO("ReadConfigDB Failed %d\n", result_code);
free(vnode);
+ delete tmp_key;
return result_code;
}
controller_domain ctrlr_dom;
result_code = GetControllerDomainId(tmp_key, &ctrlr_dom);
- if (UPLL_RC_SUCCESS != result_code)
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_INFO("Returning error %d\n",result_code);
+ delete tmp_key;
return result_code;
+ }
SET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
uuu::upll_strncpy(vnode->ctrlr_vtn_name, reinterpret_cast<key_vbr_t *>
(ikey->get_key())->vtn_key.vtn_name, (kMaxLenVtnName+1));
dbop.readop = kOpNotRead;
result_code = UpdateConfigDB(okey, UPLL_DT_IMPORT, UNC_OP_CREATE, dmi,
&dbop, RENAMETBL);
- if (tmp_key)
- delete tmp_key;
+ delete tmp_key;
}
return result_code;
}
+upll_rc_t VbrMoMgr::CtrlrIdAndDomainIdUpdationCheck(ConfigKeyVal *ikey,
+ ConfigKeyVal *okey) {
+ UPLL_FUNC_TRACE;
+ val_vbr *vbr_val = reinterpret_cast<val_vbr *>(GetVal(ikey));
+ val_vbr *vbr_val1 = reinterpret_cast<val_vbr *>(GetVal(okey));
+ if (vbr_val->valid[UPLL_IDX_CONTROLLER_ID_VBR] == UNC_VF_VALID) {
+ if (strncmp(reinterpret_cast<const char *>(vbr_val->controller_id),
+ reinterpret_cast<const char *>(vbr_val1->controller_id),
+ kMaxLenCtrlrId+1)) {
+ UPLL_LOG_DEBUG("controller id comparision failed");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ }
+ if (vbr_val->valid[UPLL_IDX_DOMAIN_ID_VBR] == UNC_VF_VALID) {
+ if (strncmp(reinterpret_cast<const char *>(vbr_val->domain_id),
+ reinterpret_cast<const char *>(vbr_val1->domain_id),
+ kMaxLenDomainId+1)) {
+ UPLL_LOG_DEBUG("domain id comparision failed");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+
upll_rc_t VbrMoMgr::ValidateVbrKey(key_vbr *vbr_key,
unc_keytype_operation_t operation) {
UPLL_FUNC_TRACE;
upll_rc_t VbrMoMgr::ValidateVbrValue(val_vbr *vbr_val,
uint32_t operation) {
UPLL_FUNC_TRACE;
- upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ bool ret_val = false;
- if (vbr_val->valid[UPLL_IDX_CONTROLLER_ID_VBR] == UNC_VF_VALID) {
- ret_val = ValidateKey(reinterpret_cast<char *>(vbr_val->controller_id),
- kMinLenCtrlrId,
- kMaxLenCtrlrId);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("controller_id syntax check failed."
- "Received controller_id - %s",
- vbr_val->controller_id);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ // Attribute syntax validation
+ for (unsigned int valid_index = 0;
+ valid_index < sizeof(vbr_val->valid) / sizeof(vbr_val->valid[0]);
+ valid_index++) {
+ if (vbr_val->valid[valid_index] == UNC_VF_VALID) {
+ switch(valid_index) {
+ case UPLL_IDX_CONTROLLER_ID_VBR:
+ ret_val = ValidateString(vbr_val->controller_id,
+ kMinLenCtrlrId, kMaxLenCtrlrId);
+ break;
+ case UPLL_IDX_DOMAIN_ID_VBR:
+ ret_val = ValidateDefaultStr(vbr_val->domain_id,
+ kMinLenDomainId, kMaxLenDomainId);
+ break;
+ case UPLL_IDX_DESC_VBR:
+ ret_val = ValidateDesc(vbr_val->vbr_description,
+ kMinLenDescription, kMaxLenDescription);
+ break;
+ case UPLL_IDX_HOST_ADDR_VBR:
+ ret_val = ValidateIpv4Addr(vbr_val->host_addr.s_addr,
+ vbr_val->host_addr_prefixlen);
+ break;
+ case UPLL_IDX_HOST_ADDR_PREFIXLEN_VBR:
+ ret_val = ValidateNumericRange(
+ (uint8_t) vbr_val->host_addr_prefixlen,
+ kMinIpv4Prefix, kMaxIpv4Prefix, true, true);
+ break;
+ }
+ if (!ret_val) {
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
}
}
- if (vbr_val->valid[UPLL_IDX_DOMAIN_ID_VBR] == UNC_VF_VALID) {
- ret_val = ValidateDefaultStr(reinterpret_cast<char *>(vbr_val->domain_id),
- kMinLenDomainId,
- kMaxLenDomainId);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Domain_id syntax check failed."
- "Received Domain_id - %s",
- vbr_val->domain_id);
- return UPLL_RC_ERR_CFG_SYNTAX;
+
+ // Additional checks
+ for (unsigned int valid_index = 0;
+ valid_index < sizeof(vbr_val->valid) / sizeof(vbr_val->valid[0]);
+ valid_index++) {
+ uint8_t flag = vbr_val->valid[valid_index];
+ switch (operation) {
+ case UNC_OP_CREATE:
+ {
+ switch(valid_index) {
+ case UPLL_IDX_CONTROLLER_ID_VBR:
+ case UPLL_IDX_DOMAIN_ID_VBR:
+ if ((flag == UNC_VF_INVALID || flag == UNC_VF_VALID_NO_VALUE)) {
+ UPLL_LOG_DEBUG("controller_id or domain_id flag is invalid"
+ " or valid_no_value");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ break;
+ case UPLL_IDX_DESC_VBR:
+ break;
+ case UPLL_IDX_HOST_ADDR_VBR:
+ if (vbr_val->valid[UPLL_IDX_HOST_ADDR_VBR] !=
+ vbr_val->valid[UPLL_IDX_HOST_ADDR_PREFIXLEN_VBR]) {
+ UPLL_LOG_DEBUG("Host address and prefix length"
+ "both do not have same valid flags: %d, %d",
+ vbr_val->valid[UPLL_IDX_HOST_ADDR_VBR],
+ vbr_val->valid[UPLL_IDX_HOST_ADDR_PREFIXLEN_VBR]);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ break;
+ case UPLL_IDX_HOST_ADDR_PREFIXLEN_VBR:
+ if ((flag == UNC_VF_INVALID) || (flag == UNC_VF_VALID_NO_VALUE)) {
+ vbr_val->host_addr_prefixlen = 0;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ case UNC_OP_UPDATE:
+ {
+ switch(valid_index) {
+ case UPLL_IDX_CONTROLLER_ID_VBR:
+ case UPLL_IDX_DOMAIN_ID_VBR:
+ if (flag == UNC_VF_VALID_NO_VALUE) {
+ UPLL_LOG_DEBUG("controller_id or domain_id flag is valid_no_value");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ break;
+ case UPLL_IDX_DESC_VBR:
+ case UPLL_IDX_HOST_ADDR_VBR:
+ case UPLL_IDX_HOST_ADDR_PREFIXLEN_VBR:
+ default:
+ break;
+ }
+ }
+ break;
}
}
- if (vbr_val->valid[UPLL_IDX_DESC_VBR] == UNC_VF_VALID) {
- ret_val = ValidateDesc(reinterpret_cast<char *>(vbr_val->vbr_description),
- kMinLenDescription, kMaxLenDescription);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("description syntax check failed."
- "Received description - %s",
- vbr_val->vbr_description);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else if (vbr_val->valid[UPLL_IDX_DESC_VBR] == UNC_VF_VALID_NO_VALUE
- && (operation == UNC_OP_UPDATE || operation == UNC_OP_CREATE)) {
- uuu::upll_strncpy(vbr_val->vbr_description, " ", 2);
- }
- if (vbr_val->valid[UPLL_IDX_HOST_ADDR_PREFIXLEN_VBR] == UNC_VF_VALID) {
- if (ValidateNumericRange((uint8_t) vbr_val->host_addr_prefixlen,
- kMinIpv4Prefix, kMaxIpv4Prefix, true, true)) {
- UPLL_LOG_DEBUG("IPV4 prefixlength validation is success");
- ret_val = ValidateIpv4Addr(vbr_val->host_addr.s_addr,
- vbr_val->host_addr_prefixlen);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Host address Validation failed");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else {
- UPLL_LOG_DEBUG("prefixlen validation check failed."
- "prefixlen - %d",
- vbr_val->host_addr_prefixlen);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else if (vbr_val->valid[UPLL_IDX_HOST_ADDR_PREFIXLEN_VBR]
- == UNC_VF_VALID_NO_VALUE
- && (operation == UNC_OP_UPDATE || operation == UNC_OP_CREATE)) {
- vbr_val->host_addr_prefixlen = 0;
+ // Resets
+ for (unsigned int valid_index = 0;
+ valid_index < sizeof(vbr_val->valid) / sizeof(vbr_val->valid[0]);
+ valid_index++) {
+ uint8_t flag = vbr_val->valid[valid_index];
+ if (flag != UNC_VF_INVALID && flag != UNC_VF_VALID_NO_VALUE)
+ continue;
+
+ switch(valid_index) {
+ case UPLL_IDX_CONTROLLER_ID_VBR:
+ StringReset(vbr_val->controller_id);
+ break;
+ case UPLL_IDX_DOMAIN_ID_VBR:
+ StringReset(vbr_val->domain_id);
+ break;
+ case UPLL_IDX_DESC_VBR:
+ StringReset(vbr_val->vbr_description);
+ break;
+ case UPLL_IDX_HOST_ADDR_VBR:
+ vbr_val->host_addr.s_addr = 0;
+ break;
+ case UPLL_IDX_HOST_ADDR_PREFIXLEN_VBR:
+ vbr_val->host_addr_prefixlen = 0;
+ break;
+ default:
+ UPLL_LOG_TRACE("Never here");
+ break;
+ }
}
return UPLL_RC_SUCCESS;
}
ping_val->target_addr);
return UPLL_RC_ERR_CFG_SYNTAX;
}
+ } else {
+ UPLL_LOG_DEBUG("Target Address is mandatory for ping operation");
+ return UPLL_RC_ERR_CFG_SYNTAX;
}
if (ping_val->valid[UPLL_IDX_SRC_ADDR_PING] == UNC_VF_VALID) {
if ((!bc_check(ping_val->src_addr)) || (!mc_check(ping_val->src_addr))) {
ConfigVal *cfg_val = ikey->get_cfg_val();
if (cfg_val == NULL) {
UPLL_LOG_DEBUG("ConfigVal struct is empty");
- return UPLL_RC_ERR_CFG_SYNTAX;
+ return UPLL_RC_ERR_BAD_REQUEST;
}
if (cfg_val->get_st_num() != IpctSt::kIpcStValVbr) {
UPLL_LOG_DEBUG(
UPLL_LOG_DEBUG(
"Invalid val_ping structure received.received struct - %d",
cfg_val->get_st_num());
- return UPLL_RC_ERR_CFG_SYNTAX;
+ return UPLL_RC_ERR_BAD_REQUEST;
}
val_ping *ping_val = reinterpret_cast<val_ping *>(GetVal(ikey));
if (ping_val == NULL) {
}
UPLL_LOG_DEBUG("Error Unsupported Datatype-(%d) or Operation-(%d)", dt_type,
operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
-upll_rc_t VbrMoMgr::ValVbrAttributeSupportCheck(const char *ctrlr_name,
- ConfigKeyVal *ikey,
- uint32_t operation) {
- return UPLL_RC_SUCCESS;
-#if 1
+upll_rc_t VbrMoMgr::ValVbrAttributeSupportCheck(
+ val_vbr_t *vbr_val,
+ const uint8_t *attrs,
+ unc_keytype_operation_t operation) {
UPLL_FUNC_TRACE;
- bool result_code = false;
- uint32_t max_attrs = 0;
- uint32_t max_instance_count = 0;
- const uint8_t *attrs = NULL;
- switch (operation) {
- case UNC_OP_CREATE:
- result_code = GetCreateCapability(ctrlr_name,
- ikey->get_key_type(),
- &max_instance_count,
- &max_attrs,
- &attrs);
- if (result_code && (max_instance_count != 0) &&
- (cur_instance_count >= max_instance_count)) {
- UPLL_LOG_DEBUG("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
- __LINE__, __FUNCTION__, cur_instance_count,
- max_instance_count);
- return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
- }
- break;
-
- case UNC_OP_UPDATE:
- result_code = GetUpdateCapability(ctrlr_name,
- ikey->get_key_type(),
- &max_attrs,
- &attrs);
- break;
- case UNC_OP_READ:
- case UNC_OP_READ_SIBLING:
- case UNC_OP_READ_SIBLING_BEGIN:
- case UNC_OP_READ_SIBLING_COUNT:
- result_code = GetReadCapability(ctrlr_name,
- ikey->get_key_type(),
- &max_attrs,
- &attrs);
- break;
- default:
- UPLL_LOG_DEBUG("Invalid Operation Code - (%d)", operation);
- return UPLL_RC_ERR_GENERIC;
- }
- if (!result_code) {
- UPLL_LOG_DEBUG("key_type - %d is not supported by controller - %s",
- ikey->get_key_type(), ctrlr_name);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
- }
- ConfigVal *cfg_val = ikey->get_cfg_val();
- if (!cfg_val) return UPLL_RC_ERR_CFG_SYNTAX;
- if (cfg_val->get_st_num() != IpctSt::kIpcStValVbr) {
- UPLL_LOG_DEBUG("value structure matching is invalid. struct. no - %d",
- cfg_val->get_st_num());
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
-
- val_vbr_t *vbr_val = reinterpret_cast<val_vbr_t *>
- (ikey->get_cfg_val()->get_val());
if (vbr_val != NULL) {
+ if ((vbr_val->valid[UPLL_IDX_DOMAIN_ID_VBR] == UNC_VF_VALID)
+ || (vbr_val->valid[UPLL_IDX_DOMAIN_ID_VBR] == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vbr::kCapDomainId] == 0) {
+ vbr_val->valid[UPLL_IDX_DOMAIN_ID_VBR] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("Domain Id Attribute is not supported by ctrlr");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ }
if ((vbr_val->valid[UPLL_IDX_DESC_VBR] == UNC_VF_VALID)
|| (vbr_val->valid[UPLL_IDX_DESC_VBR] == UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr::kCapDesc] == 0) {
- vbr_val->valid[UPLL_IDX_DESC_VBR] = UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_DEBUG("Description Attribute is not supported by pfc ctrlr");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ vbr_val->valid[UPLL_IDX_DESC_VBR] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("Desc. Attribute is not supported by ctrlr");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
}
}
if ((vbr_val->valid[UPLL_IDX_HOST_ADDR_VBR] == UNC_VF_VALID)
|| (vbr_val->valid[UPLL_IDX_HOST_ADDR_VBR] == UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr::kCapHostAddr] == 0) {
- vbr_val->valid[UPLL_IDX_HOST_ADDR_VBR] = UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_DEBUG("host_addr attribute is not supported by pfc ctrlr");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ vbr_val->valid[UPLL_IDX_HOST_ADDR_VBR] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("host_addr attribute is not supported by ctrlr");
+ UPLL_LOG_DEBUG("vbr_val->valid[UPLL_IDX_HOST_ADDR_VBR] is %d",
+ vbr_val->valid[UPLL_IDX_HOST_ADDR_VBR]);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
}
}
if ((vbr_val->valid[UPLL_IDX_HOST_ADDR_PREFIXLEN_VBR] == UNC_VF_VALID)
|| (vbr_val->valid[UPLL_IDX_HOST_ADDR_PREFIXLEN_VBR]
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vbr::kCapHostAddrPrefixlen] == 0) {
- vbr_val->valid[UPLL_IDX_HOST_ADDR_PREFIXLEN_VBR] = UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_DEBUG(
- "host_addr_prefixlen attribute is not supported by pfc ctrlr");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ vbr_val->valid[UPLL_IDX_HOST_ADDR_PREFIXLEN_VBR] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG(
+ "host_addr_prefixlen attribute is not supported by ctrlr");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
}
}
- return UPLL_RC_SUCCESS;
} else {
UPLL_LOG_DEBUG("Error val_vbr Struct is NULL");
return UPLL_RC_ERR_GENERIC;
}
-#endif
+ return UPLL_RC_SUCCESS;
}
upll_rc_t VbrMoMgr::ValidateCapability(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
const char *ctrlr_name) {
UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- if (!ikey || !req ) {
+ upll_rc_t ret_val = UPLL_RC_ERR_GENERIC;
+ if (!ikey || !req ) {
UPLL_LOG_DEBUG("ConfigKeyVal / IpcReqRespHeader is Null");
- return UPLL_RC_ERR_GENERIC;
+ return ret_val;
}
- if (!ctrlr_name) ctrlr_name = reinterpret_cast<char *>(ikey->get_user_data());
- upll_keytype_datatype_t dt_type = req->datatype;
- unc_keytype_operation_t operation = req->operation;
- unc_keytype_option1_t option1 = req->option1;
- unc_keytype_option2_t option2 = req->option2;
-
- if (operation == UNC_OP_CREATE) {
- if (dt_type == UPLL_DT_CANDIDATE || dt_type == UPLL_DT_IMPORT) {
- result_code = ValVbrAttributeSupportCheck(ctrlr_name, ikey, operation);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(" capa check failure for create operation"
- " in val_vbr struct ");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Error Unsupported datatype- (%d)", dt_type);
+ if (!ctrlr_name) {
+ ctrlr_name = reinterpret_cast<char*>((reinterpret_cast<key_user_data_t *>
+ (ikey->get_user_data()))->ctrlr_id);
+ if (!ctrlr_name || !strlen(ctrlr_name)) {
+ UPLL_LOG_DEBUG("Controller Name is NULL");
return UPLL_RC_ERR_GENERIC;
}
- } else if (operation == UNC_OP_UPDATE) {
- if (dt_type == UPLL_DT_CANDIDATE) {
- result_code = ValVbrAttributeSupportCheck(ctrlr_name, ikey, operation);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(
- "capa check failure for update operation in val_vbr struct");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+
+ bool result_code = false;
+ uint32_t max_attrs = 0;
+ uint32_t max_instance_count = 0;
+ const uint8_t *attrs = NULL;
+
+ switch (req->operation) {
+ case UNC_OP_CREATE:
+ result_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_instance_count, &max_attrs,
+ &attrs);
+ if (result_code && (max_instance_count != 0) &&
+ (cur_instance_count >= max_instance_count)) {
+ UPLL_LOG_DEBUG("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
+ __LINE__, __FUNCTION__, cur_instance_count,
+ max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
}
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Error Unsupported datatype- (%d)", dt_type);
+ break;
+
+ case UNC_OP_UPDATE:
+ result_code = GetUpdateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ break;
+ case UNC_OP_READ:
+ case UNC_OP_READ_SIBLING:
+ case UNC_OP_READ_SIBLING_BEGIN:
+ case UNC_OP_READ_SIBLING_COUNT:
+ result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ break;
+ default:
+ UPLL_LOG_DEBUG("Invalid Operation Code - (%d)", req->operation);
return UPLL_RC_ERR_GENERIC;
- }
- } else if (operation == UNC_OP_READ || operation == UNC_OP_READ_SIBLING
- || operation == UNC_OP_READ_SIBLING_BEGIN
- || operation == UNC_OP_READ_SIBLING_COUNT) {
- if (dt_type == UPLL_DT_CANDIDATE || dt_type == UPLL_DT_RUNNING ||
- dt_type == UPLL_DT_STARTUP || dt_type == UPLL_DT_STATE) {
- if (option1 != UNC_OPT1_NORMAL) {
- UPLL_LOG_DEBUG("option1 is not matching");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- if (option2 != UNC_OPT2_NONE) {
- UPLL_LOG_DEBUG("option2 is not matching");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- if (ikey->get_cfg_val()->get_val() != NULL) {
- result_code = ValVbrAttributeSupportCheck(ctrlr_name, ikey, operation);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(
- "capa check failed for Read operation in val_vbr struct");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("capa check for Val_vbr struct is an optional");
- return UPLL_RC_SUCCESS;
- }
+ }
+ if (!result_code) {
+ UPLL_LOG_DEBUG("key_type - %d is not supported by controller - %s",
+ ikey->get_key_type(), ctrlr_name);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+
+ val_vbr *vbr_val = NULL;
+ if (ikey->get_cfg_val() && (ikey->get_cfg_val()->get_st_num() ==
+ IpctSt::kIpcStValVbr)) {
+ vbr_val =
+ reinterpret_cast<val_vbr *>(ikey->get_cfg_val()->get_val());
+ }
+ if (vbr_val) {
+ if (max_attrs > 0) {
+ ret_val = ValVbrAttributeSupportCheck(vbr_val, attrs, req->operation);
+ return ret_val;
} else {
- UPLL_LOG_DEBUG("Error Unsupported datatype- (%d)", dt_type);
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d", req->operation);
return UPLL_RC_ERR_GENERIC;
}
}
- UPLL_LOG_DEBUG("Error Unsupported operation- (%d)", operation);
- return UPLL_RC_ERR_GENERIC;
+ return UPLL_RC_SUCCESS;
}
upll_rc_t VbrMoMgr::CreateVnodeConfigKey(ConfigKeyVal *ikey,
val_vbr_t *val_vbr1 = reinterpret_cast<val_vbr_t *>(val1);
val_vbr_t *val_vbr2 = reinterpret_cast<val_vbr_t *>(val2);
if (!val_vbr2) {
- UPLL_LOG_TRACE("Invalid param\n");
+ UPLL_LOG_TRACE("Invalid param");
return UPLL_RC_ERR_GENERIC;
}
for (unsigned int loop = 0;
val_vbr1->host_addr_prefixlen = val_vbr2->host_addr_prefixlen;
}
}
- if ((UNC_VF_VALID == val_vbr1->valid[UPLL_IDX_DESC_VBR])
- && (UNC_VF_VALID == val_vbr2->valid[UPLL_IDX_DESC_VBR]))
- if (!strcmp(reinterpret_cast<char*>(val_vbr1->vbr_description),
- reinterpret_cast<char*>(val_vbr2->vbr_description)))
+ if (UNC_VF_INVALID != val_vbr1->valid[UPLL_IDX_DESC_VBR]) {
+ if (!copy_to_running ||
+ ((UNC_VF_VALID == val_vbr1->valid[UPLL_IDX_DESC_VBR]) &&
+ !strcmp(reinterpret_cast<char*>(val_vbr1->vbr_description),
+ reinterpret_cast<char*>(val_vbr2->vbr_description))))
val_vbr1->valid[UPLL_IDX_DESC_VBR] = UNC_VF_INVALID;
+ }
if (UNC_VF_VALID == val_vbr1->valid[UPLL_IDX_CONTROLLER_ID_VBR]
&& UNC_VF_VALID == val_vbr2->valid[UPLL_IDX_CONTROLLER_ID_VBR]) {
if (!strcmp(reinterpret_cast<char*>(val_vbr1->controller_id),
reinterpret_cast<char*>(val_vbr2->controller_id)))
val_vbr1->valid[UPLL_IDX_CONTROLLER_ID_VBR] = UNC_VF_INVALID;
}
+ if (UNC_VF_VALID == val_vbr1->valid[UPLL_IDX_DOMAIN_ID_VBR]
+ && UNC_VF_VALID == val_vbr2->valid[UPLL_IDX_DOMAIN_ID_VBR]) {
+ if (!strcmp(reinterpret_cast<char*>(val_vbr1->domain_id),
+ reinterpret_cast<char*>(val_vbr2->domain_id)))
+ val_vbr1->valid[UPLL_IDX_DOMAIN_ID_VBR] = UNC_VF_INVALID;
+ }
if (UNC_VF_VALID == val_vbr1->valid[UPLL_IDX_HOST_ADDR_VBR]
&& UNC_VF_VALID == val_vbr2->valid[UPLL_IDX_HOST_ADDR_VBR]) {
if (!memcmp(&val_vbr1->host_addr, &val_vbr2->host_addr,
if (val_vbr1->host_addr_prefixlen == val_vbr2->host_addr_prefixlen)
val_vbr1->valid[UPLL_IDX_HOST_ADDR_PREFIXLEN_VBR] = UNC_VF_INVALID;
}
+ // Description is not send to Controller
+ if (!copy_to_running)
+ val_vbr1->valid[UPLL_IDX_DESC_VBR] = UNC_VF_INVALID;
for (unsigned int loop = 0;
loop < sizeof(val_vbr1->valid) / sizeof(uint8_t); ++loop) {
if ((UNC_VF_VALID == (uint8_t) val_vbr1->valid[loop]) ||
- (UNC_VF_VALID_NO_VALUE == (uint8_t) val_vbr1->valid[loop]))
- invalid_attr = false;
+ (UNC_VF_VALID_NO_VALUE == (uint8_t) val_vbr1->valid[loop])) {
+ invalid_attr = false;
+ break;
+ }
}
return invalid_attr;
}
DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
result_code = GetChildConfigKey(ckv_vbr, NULL);
-
- val_vbr_t *vbr_val = static_cast<val_vbr_t *>(malloc(sizeof(val_vbr_t)));
- if (!vbr_val) {
- UPLL_LOG_DEBUG("Memory allocation failed");
+ if (!ckv_vbr || result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(ckv_vbr);
return UPLL_RC_ERR_GENERIC;
}
- memset(vbr_val, 0, sizeof(val_vbr_t));
-
+ val_vbr_t *vbr_val = static_cast<val_vbr_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_vbr_t)));
key_vbr *vbrkey = reinterpret_cast<key_vbr*>(ckv->get_key());
if (!strlen(reinterpret_cast<const char *>(vbrkey->vtn_key.vtn_name))) {
free(vbr_val);
+ delete(ckv_vbr);
return UPLL_RC_ERR_GENERIC;
}
if ((vbrval->valid[UPLL_IDX_HOST_ADDR_VBR] != UNC_VF_VALID) &&
(vbrval->valid[UPLL_IDX_HOST_ADDR_PREFIXLEN_VBR] != UNC_VF_VALID)) {
UPLL_LOG_DEBUG("Semantic check not required!");
+ free(vbr_val);
+ delete (ckv_vbr);
+
return UPLL_RC_SUCCESS;
}
vbr_val->host_addr = vbrval->host_addr;
vbr_val->valid[UPLL_IDX_HOST_ADDR_VBR] = UNC_VF_VALID;
ckv_vbr->AppendCfgVal(IpctSt::kIpcStValVbr, vbr_val);
- if (ckv_vbr == NULL) return UPLL_RC_ERR_GENERIC;
- UPLL_LOG_TRACE("\n existence check %s",(ckv_vbr->ToStrAll()).c_str());
+ UPLL_LOG_TRACE(" existence check %s",(ckv_vbr->ToStrAll()).c_str());
result_code = ReadConfigDB(ckv_vbr, dt_type, UNC_OP_READ, dbop, dmi, MAINTBL);
delete ckv_vbr;
+
+ if (UPLL_RC_SUCCESS != result_code &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB Failed %d", result_code);
+ return result_code;
+ }
if (UPLL_RC_SUCCESS == result_code) {
UPLL_LOG_DEBUG("More than one vbridge configured with the same "
"host address and prefix length!");
return UPLL_RC_ERR_CFG_SEMANTIC;
}
+ result_code = (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code)?
+ UPLL_RC_SUCCESS:result_code;
return result_code;
}
*/
upll_rc_t ValidateMessage(IpcReqRespHeader *req,
ConfigKeyVal *ikey);
+ /**
+ * @Brief compares controller id and domain id before
+ * updating the value to DB.
+ *
+ * @param[in] ikey ikey contains key and value structure.
+ * @param[in] okey okey contains key and value structure.
+ *
+ * @retval UPLL_RC_SUCCESS Successful.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX Syntax error.
+ */
+ upll_rc_t CtrlrIdAndDomainIdUpdationCheck(ConfigKeyVal *ikey,
+ ConfigKeyVal *okey);
/**
* @Brief Checks if the specified key type and
* associated attributes are supported on the given controller,
* based on the valid flag.
*
- * @param[in] crtlr_name Controller name.
- * @param[in] ikey Corresponding key and value structure.
+ * @param[in] vbr_val KT_VBRIDGE value structure.
+ * @param[in] attrs Pointer to controller attribute.
* @param[in] operation Operation name.
*
* @retval UPLL_RC_SUCCESS validation succeeded.
* @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
* @retval UPLL_RC_ERR_GENERIC Generic failure.
*/
- upll_rc_t ValVbrAttributeSupportCheck(const char *ctrle_name,
- ConfigKeyVal *ikey,
- uint32_t operation);
-
+ upll_rc_t ValVbrAttributeSupportCheck(val_vbr_t *vbr_val,
+ const uint8_t *attrs,
+ unc_keytype_operation_t operation);
+
/**
* @Brief Validates the syntax for KT_VBR keytype Rename structure.
*
#include "upll_validation.hh"
#include "unc/upll_ipc_enum.h"
#include "vtn_policingmap_momgr.hh"
+#include "vbr_if_momgr.hh"
#include "vbr_momgr.hh"
#include "vtn_momgr.hh"
using unc::upll::ipc_util::IpcUtil;
namespace upll {
namespace kt_momgr {
-#define VBR_KEY_COL 5
-#define POLICY_KEY_COL 5
#define VTN_RENAME 0x01
-#define VBR_RENAME 0x10
+#define VBR_RENAME 0x02
#define POLICINGPROFILE_RENAME 0x04
+#define NO_POLICINGPROFILE_RENAME ~POLICINGPROFILE_RENAME
BindInfo VbrPolicingMapMoMgr::vbr_policingmap_bind_info[] = {
{ uudst::vbr_policingmap::kDbiVtnName, CFG_KEY,
{ uudst::vbr_policingmap::kDbiVbrName, CFG_INPUT_KEY,
offsetof(key_rename_vnode_info_t, new_unc_vnode_name),
uud::kDalChar, (kMaxLenVnodeName + 1) },
- { uudst::vbr_policingmap::kDbiFlags, CFG_INPUT_KEY,
- offsetof(key_user_data_t, flags),
- uud::kDalUint8, 1 }
-};
-
-// Rename
-BindInfo VbrPolicingMapMoMgr::key_vbrpm_policyname_maintbl_rename_bind_info[]
-= {
- { uudst::vbr_policingmap::kDbiVtnName, CFG_MATCH_KEY,
- offsetof(key_vbr_if_t, vbr_key.vtn_key.vtn_name),
- uud::kDalChar, (kMaxLenVtnName + 1) },
- { uudst::vbr_policingmap::kDbiVbrName, CFG_MATCH_KEY,
- offsetof(key_vbr_if_t, vbr_key.vbridge_name),
- uud::kDalChar, (kMaxLenVnodeName + 1) },
- { uudst::vbr_policingmap::kDbiPolicername, CFG_INPUT_KEY,
- offsetof(key_rename_vnode_info_t, new_policingprofile_name),
- uud::kDalChar, (kMaxLenPolicingProfileName + 1) },
- { uudst::vbr_policingmap::kDbiFlags, CFG_INPUT_KEY,
+ { uudst::vbr_policingmap::kDbiFlags, CK_VAL,
offsetof(key_user_data_t, flags),
uud::kDalUint8, 1 }
};
nchild = 0;
child = NULL;
+ cur_instance_count = 0;
}
upll_rc_t VbrPolicingMapMoMgr::CreateCandidateMo(IpcReqRespHeader *req,
}
ConfigKeyVal *okey = NULL;
- result_code = GetControllerId(ikey, okey, dmi);
+ result_code = GetControllerId(ikey, okey, req->datatype, dmi);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetControllerId failed %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
- delete okey;
- /*
- // Capability Check
- result_code = ValidateCapability(req, ikey);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Key not supported by controller");
- return result_code;
- } */
+ DELETE_IF_NOT_NULL(okey);
+
+ uint8_t *ctrlr_id = NULL;
+ GET_USER_DATA_CTRLR(ikey, ctrlr_id);
+
// Check VBR object existence in VbrPolicingMap CANDIDATE DB
// if record exists, return the error code
val_policingmap_t *val_pm = reinterpret_cast<val_policingmap_t *>
(GetVal(ikey));
if (UNC_VF_VALID == val_pm->valid[UPLL_IDX_POLICERNAME_PM]) {
- // Check Policingmap object exists in PolicingProfileTbl CANDIDATE DB
- // If record not exists, return error code
- result_code = IsPolicyProfileReferenced(ikey, req->datatype, dmi,
+ // Check Policingmap object exists in PolicingProfileTbl CANDIDATE DB
+ // If record not exists, return error code
+ result_code = IsPolicyProfileReferenced(ikey, req->datatype, dmi,
UNC_OP_READ);
- if (UPLL_RC_SUCCESS != result_code) {
- if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- UPLL_LOG_DEBUG("Profile Object (%d) not available in CANDIDATE DB",
- result_code);
- return UPLL_RC_ERR_CFG_SEMANTIC;
- } else {
- UPLL_LOG_DEBUG("CreateCandidateMo Error Accesing CANDIDATEDB(%d)",
+ if (UPLL_RC_SUCCESS != result_code) {
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Profile Object (%d) not available in CANDIDATE DB",
result_code);
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ } else {
+ UPLL_LOG_DEBUG("CreateCandidateMo Error Accesing CANDIDATEDB(%d)",
+ result_code);
+ return result_code;
+ }
+ }
+ }
+
+ // Check if Object exists in RUNNING DB and move it to CANDIDATE DB
+ if (req->datatype == UPLL_DT_CANDIDATE) {
+ result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
+ MAINTBL);
+ if ((result_code != UPLL_RC_ERR_INSTANCE_EXISTS) &&
+ (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG(" Is Exist check operation failed: err code(%d)",
+ result_code);
+ return result_code;
+ }
+ if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
+ result_code = RestoreChildren(ikey, req->datatype, UPLL_DT_RUNNING, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("RestoreChildren Failed, err %d", result_code);
+ return result_code;
+ }
return result_code;
}
}
- // 1)Get vbr associated ctrlr name and invoke the PP and PPE functions to
- // check the refcount capability and update the refcount or create the
- // record in policingprofilectrltbl and policingprofileentryctrltbl.
- result_code = UpdateRefCountInPPCtrlr(ikey, req->datatype, dmi,
- UNC_OP_CREATE);
+ ConfigKeyVal *temp_key = NULL;
+ result_code = GetChildConfigKey(temp_key, NULL);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("UpdateRefCountInPPCtrlr Err in CANDIDATE DB(%d)",
- result_code);
+ UPLL_LOG_DEBUG("GetChildConfigKey failed(%d)",result_code);
return result_code;
}
+
+ result_code = GetInstanceCount(temp_key, reinterpret_cast<char*>(ctrlr_id),
+ req->datatype, &cur_instance_count,
+ dmi, MAINTBL);
+ DELETE_IF_NOT_NULL(temp_key);
+
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetInstanceCount failed(%d)",result_code);
+ return result_code;
}
+ result_code = ValidateCapability(req, ikey, reinterpret_cast<char *>(ctrlr_id));
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Key not supported by controller");
+ return result_code;
+ }
- UPLL_LOG_DEBUG("pyn Create - (%s)", val_pm->policer_name);
+ if (UNC_VF_VALID == val_pm->valid[UPLL_IDX_POLICERNAME_PM]) {
+ // 1)Get vbr associated ctrlr name and invoke the PP and PPE functions to
+ // check the refcount capability and update the refcount or create the
+ // record in policingprofilectrltbl and policingprofileentryctrltbl.
+ result_code = UpdateRefCountInPPCtrlr(ikey, req->datatype, dmi,
+ UNC_OP_CREATE);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateRefCountInPPCtrlr Err in CANDIDATE DB(%d)",
+ result_code);
+ return result_code;
+ }
+ }
// create a record in vbrpolicingmap table CANDIDATE DB
result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_CREATE, dmi);
if (UPLL_RC_SUCCESS != result_code) {
return result_code;
}
+upll_rc_t VbrPolicingMapMoMgr::RestorePOMInCtrlTbl(
+ ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl,
+ DalDmlIntf* dmi) {
+
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ if (!ikey || !(ikey->get_key())) {
+ UPLL_LOG_DEBUG("Input Key Not Valid");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (tbl != MAINTBL ||
+ (ikey->get_key_type() != UNC_KT_VBR_POLICINGMAP)) {
+ UPLL_LOG_DEBUG("Ignoring ktype/Table kt=%d, tbl=%d",
+ ikey->get_key_type(), tbl);
+ return result_code;
+ }
+
+ val_policingmap_t *val_pm = reinterpret_cast<val_policingmap_t *>
+ (GetVal(ikey));
+ if (NULL == val_pm) {
+ UPLL_LOG_DEBUG(" Value structure is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (UNC_VF_VALID == val_pm->valid[UPLL_IDX_POLICERNAME_PM]) {
+ result_code = UpdateRefCountInPPCtrlr(ikey, dt_type, dmi,
+ UNC_OP_CREATE);
+ if (UPLL_RC_SUCCESS != result_code) {
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Failed to update policingprofile in ctrlrTbl Err(%d)",
+ result_code);
+ return result_code;
+ }
+ }
+ }
+ return result_code;
+}
+
upll_rc_t VbrPolicingMapMoMgr::DeleteMo(IpcReqRespHeader *req,
ConfigKeyVal *ikey, DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
result_code = UpdateRefCountInPPCtrlr(okey, req->datatype, dmi,
UNC_OP_DELETE);
if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(okey);
UPLL_LOG_DEBUG("UpdateRefCountInPPCtrlr Error DB (%d)", result_code);
return result_code;
}
}
delete okey;
// Delete the record in vbrpolicingmap table
- result_code = UpdateConfigDB(ikey, UPLL_DT_CANDIDATE, UNC_OP_DELETE, dmi,
+ result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_DELETE, dmi,
MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("DeleteMo Failed. UpdateConfigdb failed to delete - %d",
return result_code;
}
- ConfigKeyVal *okey = NULL;
- result_code = GetControllerId(ikey, okey, dmi);
+ result_code = SetRenameFlag(ikey, dmi, req);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("GetControllerId failed %d", result_code);
+ UPLL_LOG_DEBUG(" SetRenameFlag failed %d", result_code);
return result_code;
}
- delete okey;
- // Capability Check
- result_code = ValidateCapability(req, ikey);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Key not supported by controller");
+ ConfigKeyVal *okey = NULL;
+ result_code = GetControllerId(ikey, okey, req->datatype, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetControllerId failed %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
+ delete okey;
// Check VBR object existence in VbrPolicingMap CANDIDATE DB
// If record not exists, return error
result_code = ReadConfigDB(tmpckv, req->datatype, UNC_OP_READ, dbop, dmi,
MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(tmpckv);
UPLL_LOG_DEBUG("ReadConfigDB failed");
return result_code;
}
uint8_t *ctrlr_id = NULL;
GET_USER_DATA_CTRLR(tmpckv, ctrlr_id);
SET_USER_DATA_CTRLR(ikey, ctrlr_id);
+
+ result_code = ValidateCapability(req, ikey, reinterpret_cast<char *>(ctrlr_id));
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(tmpckv);
+ UPLL_LOG_DEBUG("Key not supported by controller");
+ return result_code;
+ }
+
val_policingmap_t *val_tmp_val = reinterpret_cast<val_policingmap_t *>
(GetVal(tmpckv));
if (UNC_VF_VALID == val_ival->valid[UPLL_IDX_POLICERNAME_PM] &&
result_code = UpdateRefCountInPPCtrlr(tmpckv, req->datatype, dmi,
UNC_OP_DELETE);
if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(tmpckv);
UPLL_LOG_DEBUG("UpdateMo UpdateRefCountInPPCtrlr error in delete (%d)",
result_code);
return result_code;
result_code = UpdateRefCountInPPCtrlr(ikey, req->datatype, dmi,
UNC_OP_CREATE);
if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(tmpckv);
UPLL_LOG_DEBUG("UpdateMo UpdateRefCountInPPCtrlr error in create (%d)",
result_code);
return result_code;
result_code = UpdateRefCountInPPCtrlr(ikey, req->datatype, dmi,
UNC_OP_CREATE);
if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(tmpckv);
UPLL_LOG_DEBUG("UpdateMo UpdateRefCountInPPCtrlr error in create (%d)",
result_code);
return result_code;
result_code = UpdateRefCountInPPCtrlr(tmpckv, req->datatype, dmi,
UNC_OP_DELETE);
if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(tmpckv);
UPLL_LOG_DEBUG("UpdateMo UpdateRefCountInPPCtrlr error in create (%d)",
result_code);
return result_code;
}
}
// Update the record in CANDIDATE DB
+ uint8_t temp_flag = 0;
+ GET_USER_DATA_FLAGS(ikey, temp_flag);
+ UPLL_LOG_DEBUG("Flag in ikey: %d", temp_flag);
+ DbSubOp dbop1 = {kOpNotRead, kOpMatchNone, kOpInOutFlag};
result_code = UpdateConfigDB(ikey, req->datatype, req->operation, dmi,
- MAINTBL);
+ &dbop1, MAINTBL);
+ DELETE_IF_NOT_NULL(tmpckv);
UPLL_LOG_DEBUG("VtnPolicingMapMoMgr::UpdateMo update record status (%d)",
result_code);
return result_code;
(const_cast<MoManager *>(GetMoManager
(UNC_KT_POLICING_PROFILE_ENTRY)));
result_code = ppe_mgr->ValidateValidElements(reinterpret_cast
- <const char *>(val_pm->policer_name), dmi, UPLL_DT_CANDIDATE);
+ <const char *>(val_pm->policer_name), dmi, dt_type);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("ValidateValidElements failed %d", result_code);
delete okey;
return result_code;
}
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_SUCCESS;
}
UPLL_LOG_DEBUG(
"VbrPolicingMapMoMgr::UpdateRefCountInPPCtrlr ctrlr_id NULL (%d)",
result_code);
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
reinterpret_cast<const char *>(val_vtn_policingmap->policer_name),
reinterpret_cast<const char *>(ctrlr_id), dmi, op, dt_type);
if (UPLL_RC_SUCCESS != result_code) {
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
(val_vtn_policingmap->policer_name),
reinterpret_cast<const char*>(ctrlr_id), dmi, op, dt_type);
if (UPLL_RC_SUCCESS != result_code) {
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
#endif
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_SUCCESS;
}
upll_rc_t VbrPolicingMapMoMgr::GetControllerId(ConfigKeyVal *ikey,
ConfigKeyVal *&okey,
+ upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
DbSubOp dbop = { kOpReadSingle, kOpMatchNone,
kOpInOutCtrlr|kOpInOutDomain };
- result_code = mgr->ReadConfigDB(okey, UPLL_DT_CANDIDATE, UNC_OP_READ, dbop,
+ result_code = mgr->ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop,
dmi, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetControllerId ReadConfigDB failed (%d)", result_code);
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
controller_domain ctrlr_dom;
result_code = mgr->GetControllerDomainId(okey, &ctrlr_dom);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetControllerDomainId failed %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
- SET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+ uint8_t temp_flag = 0;
+ GET_USER_DATA_FLAGS(ikey, temp_flag);
+ SET_USER_DATA(ikey, okey);
+ SET_USER_DATA_FLAGS(ikey, temp_flag);
return UPLL_RC_SUCCESS;
}
result_code = GetReadVbrKey(dup_key, ikey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadConfigDB failed");
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
}
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadConfigDB failed");
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
}
dmi, &okey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadDTsateNormal failed");
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
} else {
if (okey != NULL) {
result_code = GetReadVbrKey(dup_key, ikey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadConfigDB failed");
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
}
result_code = ReadConfigDB(dup_key, req->datatype, UNC_OP_READ,
dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadConfigDB failed");
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
}
result_code = GetReadVbrEntryKey(dup_key1, ikey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadConfigDB failed");
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
}
GET_USER_DATA_CTRLR_DOMAIN(dup_key, ctrlr_dom);
SET_USER_DATA_CTRLR_DOMAIN(dup_key1, ctrlr_dom);
+
+
+ result_code = ValidateCapability(req, ikey, reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(dup_key1);
+ UPLL_LOG_DEBUG("Key not supported by controller");
+ return result_code;
+ }
+
// 1.Getting renamed name if renamed
-#if 0 // need to uncomment in IMPORT CASE
+ // need to uncomment in IMPORT CASE
result_code = GetRenamedControllerKey(dup_key1, req->datatype,
dmi, &ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetRenamedControllerKey failed");
- CONFIGKEYVALCLEAN(dup_key);
- CONFIGKEYVALCLEAN(dup_key1);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(dup_key1);
return result_code;
}
-#endif
+
IpcRequest ipc_req;
memset(&ipc_req, 0, sizeof(ipc_req));
ipc_req.header.clnt_sess_id = req->clnt_sess_id;
DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- ConfigKeyVal *l_key = NULL, *tctrl_key = NULL, *tmp_key = NULL, *okey = NULL;
+ ConfigKeyVal *tctrl_key = NULL, *tmp_key = NULL, *okey = NULL;
ConfigKeyVal *dup_key = NULL, *dup_key1 = NULL;
controller_domain ctrlr_dom;
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadConfigDB failed");
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
}
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadConfigDB failed");
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
}
key_policingprofile_entry_t* l_pp_key = NULL;
req->datatype, dbop, dmi, &okey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadDTsateNormal failed");
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
}
tmp_key = tmp_key->get_next_cfg_key_val();
result_code = GetReadVbrKey(dup_key, ikey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadConfigDB failed");
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
}
result_code = ReadConfigDB(dup_key, req->datatype, UNC_OP_READ,
dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadConfigDB failed");
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
}
result_code = GetReadVbrEntryKey(dup_key1, ikey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadConfigDB failed");
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
}
GET_USER_DATA_CTRLR_DOMAIN(dup_key, ctrlr_dom);
SET_USER_DATA_CTRLR_DOMAIN(dup_key1, ctrlr_dom);
+ result_code = ValidateCapability(req, ikey, reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Not Supported By Controller");
+ return result_code;
+ }
+
// 1.Getting renamed name if renamed
-#if 0 // need to uncomment for IMPORT case
+ // need to uncomment for IMPORT case
result_code = GetRenamedControllerKey(dup_key1, req->datatype,
dmi, &ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetRenamedControllerKey failed");
- // CONFIGKEYVALCLEAN(dup_key);
- // CONFIGKEYVALCLEAN(dup_key1);
+ // DELETE_IF_NOT_NULL(dup_key);
+ // DELETE_IF_NOT_NULL(dup_key1);
return result_code;
}
-#endif
+
key_policingprofile_entry_t* l_pp_key = NULL;
PolicingProfileEntryMoMgr *mgr =
reinterpret_cast<PolicingProfileEntryMoMgr*>
// result_code = mgr->ReadInfoFromDB(req, ppe_ckv, dmi, &ctrlr_dom);
// result_code = mgr->ReadSiblingMo(temp_req, ppe_ckv, dmi);
result_code = mgr->ReadSiblingMo(temp_req, tctrl_key, dmi);
+ req->rep_count = temp_req->rep_count;
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("ReadConfigDb failed for tctrl_key%d ", result_code);
+ ConfigKeyVal::Free(temp_req);
return result_code;
}
-
+ ConfigKeyVal::Free(temp_req);
tmp_key = tctrl_key;
while (tmp_key != NULL) {
reinterpret_cast <key_vbr_policingmap_entry*>
PFCDRIVER_SERVICE_NAME, PFCDRIVER_SVID_LOGICAL,
&ipc_req, true, &ipc_resp)) {
UPLL_LOG_DEBUG("SendReqToDriver failed for Key %d controller %s",
- l_key->get_key_type(),
+ dup_key1->get_key_type(),
reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ DELETE_IF_NOT_NULL(dup_key1);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
return UPLL_RC_ERR_GENERIC;
}
if (ipc_resp.header.result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Driver response for Key %d ctrlr %s result %d",
- l_key->get_key_type(), ctrlr_dom.ctrlr,
+ dup_key1->get_key_type(), ctrlr_dom.ctrlr,
ipc_resp.header.result_code);
+ DELETE_IF_NOT_NULL(dup_key1);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
return ipc_resp.header.result_code;
}
dmi, &okey);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadDetail failed");
+ DELETE_IF_NOT_NULL(dup_key1);
return result_code;
}
tmp_key = tmp_key->get_next_cfg_key_val();
}
+ DELETE_IF_NOT_NULL(tctrl_key);
if ((okey != NULL) && (result_code == UPLL_RC_SUCCESS)) {
ikey->ResetWith(okey);
+ DELETE_IF_NOT_NULL(okey);
}
DELETE_IF_NOT_NULL(dup_key);
DELETE_IF_NOT_NULL(dup_key1);
}
GET_USER_DATA_CTRLR_DOMAIN(dup_key, ctrlr_dom);
SET_USER_DATA_CTRLR_DOMAIN(l_key, ctrlr_dom);
- /*
+
+ result_code = ValidateCapability(req, ikey, reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ UPLL_LOG_DEBUG("Key not supported by controller");
+ return result_code;
+ }
+
// 1.Getting renamed name if renamed
result_code = GetRenamedControllerKey(l_key, req->datatype,
dmi, &ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetRenamedControllerKey failed");
- CONFIGKEYVALCLEAN(l_key);
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
}
- */
IpcRequest ipc_req;
memset(&ipc_req, 0, sizeof(ipc_req));
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("IpcResponse failed");
- CONFIGKEYVALCLEAN(l_key);
- CONFIGKEYVALCLEAN(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
} else {
if (okey != NULL) {
MoMgrTables tbl) {
UPLL_FUNC_TRACE;
UPLL_LOG_DEBUG("GetRenameKeyBindInfo (%d) (%d)", key_type, tbl);
- switch (key_type) {
- case UNC_KT_VBR_POLICINGMAP:
- nattr = VBR_KEY_COL;
- binfo = key_vbrpm_maintbl_rename_bind_info;
- break;
- case UNC_KT_POLICING_PROFILE:
- nattr = POLICY_KEY_COL;
- binfo = key_vbrpm_policyname_maintbl_rename_bind_info;
- break;
- default:
- UPLL_LOG_DEBUG("GetRenameKeyBindInfo Invalid key type (%d) (%d)",
- key_type, tbl);
- return PFC_FALSE;
- }
+
+ nattr = sizeof(key_vbrpm_maintbl_rename_bind_info)/
+ sizeof(key_vbrpm_maintbl_rename_bind_info[0]);
+ binfo = key_vbrpm_maintbl_rename_bind_info;
return PFC_TRUE;
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
- if (UNC_KT_VBR_POLICINGMAP == ikey->get_key_type()) {
- key_rename_vnode_info *key_rename =
+ key_rename_vnode_info *key_rename =
reinterpret_cast<key_rename_vnode_info *>(ikey->get_key());
- key_vbr_t *key_vbr =
- reinterpret_cast<key_vbr_t *>(ConfigKeyVal::Malloc(sizeof(key_vbr_t)));
- if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vtn_name))) {
- UPLL_LOG_DEBUG("old_unc_vtn_name NULL");
- free(key_vbr);
- return UPLL_RC_ERR_GENERIC;
- }
- uuu::upll_strncpy(key_vbr->vtn_key.vtn_name,
- key_rename->old_unc_vtn_name,
- (kMaxLenVtnName + 1));
+ key_vbr_t *key_vbr =
+ reinterpret_cast<key_vbr_t *>(ConfigKeyVal::Malloc(sizeof(key_vbr_t)));
+
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vtn_name))) {
+ UPLL_LOG_DEBUG("old_unc_vtn_name NULL");
+ FREE_IF_NOT_NULL(key_vbr);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(key_vbr->vtn_key.vtn_name,
+ key_rename->old_unc_vtn_name,
+ (kMaxLenVtnName + 1));
+
+ if (ikey->get_key_type() == table[MAINTBL]->get_key_type()) {
if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vnode_name))) {
UPLL_LOG_DEBUG("old_unc_vnode_name NULL");
- free(key_vbr);
+ FREE_IF_NOT_NULL(key_vbr);
return UPLL_RC_ERR_GENERIC;
}
+
uuu::upll_strncpy(key_vbr->vbridge_name,
- key_rename->old_unc_vnode_name,
- (kMaxLenVnodeName + 1));
+ key_rename->old_unc_vnode_name,
+ (kMaxLenVnodeName + 1));
+ }
- okey = new ConfigKeyVal(UNC_KT_VBR_POLICINGMAP, IpctSt::kIpcStKeyVbr,
- key_vbr, NULL);
- if (!okey) {
- UPLL_LOG_DEBUG("okey NULL");
- free(key_vbr);
- return UPLL_RC_ERR_GENERIC;
- }
- } else if (UNC_KT_POLICING_PROFILE == ikey->get_key_type()) {
- key_rename_vnode_info_t *key_rename =
- reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
+ okey = new ConfigKeyVal(UNC_KT_VBR_POLICINGMAP, IpctSt::kIpcStKeyVbr,
+ key_vbr, NULL);
+ if (!okey) {
+ UPLL_LOG_DEBUG("okey NULL");
+ FREE_IF_NOT_NULL(key_vbr);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ return result_code;
+}
+
+upll_rc_t VbrPolicingMapMoMgr::UpdateVnodeVal(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t data_type,
+ bool &no_rename) {
+ UPLL_FUNC_TRACE;
+ ConfigKeyVal *okey = NULL;
+ ConfigKeyVal *kval = NULL;
+ controller_domain ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+
+ uint8_t rename = 0;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+
+ key_rename_vnode_info_t *key_rename =
+ reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
- val_policingmap_t *val = reinterpret_cast<val_policingmap_t *>
+ UPLL_LOG_DEBUG("CopyToConfigKey datatype (%d)", data_type);
+ // Copy the old policer name in val_policingmap
+ val_policingmap_t *val = reinterpret_cast<val_policingmap_t *>
(ConfigKeyVal::Malloc(sizeof(val_policingmap_t)));
+ if (!val) return UPLL_RC_ERR_GENERIC;
+ memset(val, 0, sizeof(val_policingmap_t));
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_policingprofile_name))) {
+ UPLL_LOG_DEBUG("key_rename->old_policingprofile_name NULL");
+ FREE_IF_NOT_NULL(val);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ uuu::upll_strncpy(val->policer_name,
+ key_rename->old_policingprofile_name,
+ (kMaxLenPolicingProfileName + 1));
+ val->valid[UPLL_IDX_POLICERNAME_PM] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("policer name and valid (%d) (%s)",
+ val->valid[UPLL_IDX_POLICERNAME_PM], val->policer_name);
+
+ result_code = GetChildConfigKey(okey, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("CopyToConfigKey okey NULL");
+ FREE_IF_NOT_NULL(val);
+ return result_code;
+ }
+ if (!okey) {
+ FREE_IF_NOT_NULL(val);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ okey->SetCfgVal(new ConfigVal(IpctSt::kIpcStValPolicingmap, val));
- if (!strlen(
- reinterpret_cast<char *>(key_rename->old_policingprofile_name))) {
- UPLL_LOG_DEBUG("old_policingprofile_name NULL");
- free(val);
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain|kOpInOutFlag };
+
+ // Read the record of key structure and old policer name in maintbl
+ result_code = ReadConfigDB(okey, data_type, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG(" ReadConfigDB failed ");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ ConfigKeyVal *first_ckv = okey;
+ while (okey != NULL) {
+ // Update the new policer name in MAINTBL
+ result_code = GetChildConfigKey(kval, okey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey kval NULL");
+ DELETE_IF_NOT_NULL(first_ckv);
+ return result_code;
+ }
+ if (!kval) return UPLL_RC_ERR_GENERIC;
+ // Copy the new policer name in val_policingmap
+ val_policingmap_t *val1 = reinterpret_cast<val_policingmap_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_policingmap_t)));
+ if (!val1) return UPLL_RC_ERR_GENERIC;
+ memset(val1, 0, sizeof(val_policingmap_t));
+
+ // New name null check
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_policingprofile_name))) {
+ FREE_IF_NOT_NULL(val1);
+ UPLL_LOG_DEBUG("new_policingprofile_name NULL");
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(first_ckv);
return UPLL_RC_ERR_GENERIC;
}
+ // Copy the new policer name into val_policingmap
+ uuu::upll_strncpy(val1->policer_name,
+ key_rename->new_policingprofile_name,
+ (kMaxLenPolicingProfileName + 1));
+ val1->valid[UPLL_IDX_POLICERNAME_PM] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("policer name and valid (%d) (%s)",
+ val1->valid[UPLL_IDX_POLICERNAME_PM], val1->policer_name);
+ ConfigVal *cval1 = new ConfigVal(IpctSt::kIpcStValPolicingmap, val1);
- uuu::upll_strncpy(val->policer_name,
- key_rename->old_policingprofile_name,
- (kMaxLenPolicingProfileName + 1));
- ConfigVal *cval = new ConfigVal(IpctSt::kIpcStValPolicingmap, val);
- okey = new ConfigKeyVal(UNC_KT_POLICING_PROFILE,
- IpctSt::kIpcStKeyPolicingprofile, NULL, cval);
- if (!okey) {
- UPLL_LOG_DEBUG("okey NULL");
- free(val);
- return UPLL_RC_ERR_GENERIC;
+ kval->SetCfgVal(cval1);
+
+ GET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
+ GET_USER_DATA_FLAGS(okey, rename);
+
+ UPLL_LOG_DEBUG("okey flag (%d)", rename);
+
+ if (!no_rename)
+ rename = rename | POLICINGPROFILE_RENAME;
+ else
+ rename = rename & NO_POLICINGPROFILE_RENAME;
+
+ SET_USER_DATA_FLAGS(kval, rename);
+ SET_USER_DATA_CTRLR_DOMAIN(kval, ctrlr_dom);
+
+ UPLL_LOG_DEBUG("kval flag (%d)", rename);
+ // Update the new policer name in MAINTBL
+ result_code = UpdateConfigDB(kval, data_type, UNC_OP_UPDATE, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Create record Err in vtnpolicingmaptbl CANDIDATE DB(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(first_ckv);
+ return result_code;
}
- } else {
- UPLL_LOG_DEBUG("CopyToConfigKey invalid key type NULL");
- return UPLL_RC_ERR_GENERIC;
- }
+
+ DELETE_IF_NOT_NULL(kval);
+
+ okey = okey->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(first_ckv);
return result_code;
}
DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
- ConfigKeyVal *tkey;
- ConfigKeyVal *pp_keyval = NULL;
-
- if (NULL == ikey) {
- UPLL_LOG_DEBUG("ikey NULL");
- return UPLL_RC_ERR_GENERIC;
+ ConfigKeyVal *ckval = NULL;
+ if (NULL == ctrlr_id) {
+ UPLL_LOG_DEBUG("MergeValidate ctrlr_id NULL");
+ return result_code;
}
- result_code = ReadConfigDB(ikey, UPLL_DT_IMPORT, UNC_OP_READ, dbop, dmi,
- MAINTBL);
+
+ result_code = GetChildConfigKey(ckval, NULL);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("ReadConfigDB NULL");
+ UPLL_LOG_DEBUG("GetChildConfigKey ckval NULL");
return result_code;
}
- MoMgrImpl *mgr =
- reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
- UNC_KT_POLICING_PROFILE)));
- tkey = ikey;
- while (ikey != NULL) {
- result_code = mgr->GetChildConfigKey(pp_keyval, NULL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetChildConfigKey NULL");
+ if (!ckval) return UPLL_RC_ERR_GENERIC;
+
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain};
+ result_code = ReadConfigDB(ckval, UPLL_DT_IMPORT,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ckval);
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
return result_code;
}
- if (!pp_keyval) return UPLL_RC_ERR_GENERIC;
- val_policingmap_t *policingmap_val =
- reinterpret_cast<val_policingmap_t *>(GetVal(ikey));
-
- key_policingprofile_t *key_policingprofie =
- reinterpret_cast<key_policingprofile_t *>(pp_keyval->get_key());
-
- uuu::upll_strncpy(key_policingprofie->policingprofile_name,
- policingmap_val->policer_name,
- (kMaxLenPolicingProfileName + 1));
-
- result_code = mgr->UpdateConfigDB(pp_keyval, UPLL_DT_CANDIDATE, UNC_OP_READ,
- dmi, MAINTBL);
- if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
- UPLL_LOG_DEBUG("UpdateConfigDB NULL");
- CONFIGKEYVALCLEAN(pp_keyval);
+ return UPLL_RC_SUCCESS;
+ }
+ ConfigKeyVal *tmp_ckval = ckval;
+ while (NULL != ckval) {
+ result_code = UpdateConfigDB(ckval, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
+ MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ UPLL_LOG_DEBUG("Merge Conflict");
+ result_code = DupConfigKeyVal(ikey, ckval, MAINTBL);
+ DELETE_IF_NOT_NULL(ckval);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal fail");
+ return result_code;
+ }
return UPLL_RC_ERR_MERGE_CONFLICT;
+ } else if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ ckval = ckval->get_next_cfg_key_val();
+ } else {
+ UPLL_LOG_DEBUG("Merge Conflict DB err");
+ DELETE_IF_NOT_NULL(ckval);
+ return result_code;
}
- ikey = tkey->get_next_cfg_key_val();
- CONFIGKEYVALCLEAN(pp_keyval);
}
- if (tkey) delete tkey;
- return result_code;
+ DELETE_IF_NOT_NULL(tmp_ckval);
+ return UPLL_RC_SUCCESS;
}
upll_rc_t VbrPolicingMapMoMgr::GetRenamedUncKey(ConfigKeyVal *ikey,
upll_rc_t result_code;
ConfigKeyVal *unc_key = NULL;
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
-
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vbrpm start",
+ ikey->ToStrAll().c_str());
if (NULL == ikey || NULL == dmi || NULL == ctrlr_id) {
UPLL_LOG_DEBUG(" GetRenamedUncKey failed. Insufficient input parameters.");
return UPLL_RC_ERR_GENERIC;
val_rename_vnode *rename_vnode = reinterpret_cast<val_rename_vnode *>
(ConfigKeyVal::Malloc(sizeof(val_rename_vnode)));
-
+ if (!rename_vnode) {
+ UPLL_LOG_DEBUG("rename_vnode NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(rename_vnode->ctrlr_vtn_name,
ctrlr_key->vtn_key.vtn_name,
(kMaxLenVtnName + 1));
+ rename_vnode->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
+
uuu::upll_strncpy(rename_vnode->ctrlr_vnode_name,
ctrlr_key->vbridge_name,
(kMaxLenVnodeName + 1));
+ rename_vnode->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_VALID;
+
MoMgrImpl *mgr =
reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
UNC_KT_VBRIDGE)));
// Get the memory allocated vbr key structure
result_code = mgr->GetChildConfigKey(unc_key, NULL);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG(" GetRenamedUncKey failed. GetChildConfigKey failed to "
- "allocate memory for ConfigKeyVal - %d",
- result_code);
+ UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
free(rename_vnode);
+ mgr = NULL;
return result_code;
}
if (!unc_key) {
+ UPLL_LOG_DEBUG("unc_key NULL");
free(rename_vnode);
+ mgr = NULL;
return UPLL_RC_ERR_GENERIC;
}
SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
// Read the data from VBR RenameTbl
result_code = mgr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL);
- if (UPLL_RC_SUCCESS != result_code
- && UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
UPLL_LOG_DEBUG(" GetRenamedUncKey failed. ReadConfigDB failed to read %d ",
result_code);
- CONFIGKEYVALCLEAN(unc_key);
+ DELETE_IF_NOT_NULL(unc_key);
+ mgr = NULL;
return result_code;
}
}
}
- CONFIGKEYVALCLEAN(unc_key);
+ DELETE_IF_NOT_NULL(unc_key);
mgr = NULL;
/* ********** Get the Renamed Policer name ******* */
val_rename_policingprofile *rename_policingprofile =
reinterpret_cast<val_rename_policingprofile *>(ConfigKeyVal::Malloc(
sizeof(val_rename_policingprofile)));
-
+ if (!rename_policingprofile) {
+ UPLL_LOG_DEBUG("rename_policingprofile NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
// Get the policer name from ikey
val_policingmap_t *val_policingmap =
if (!val_policingmap) {
UPLL_LOG_DEBUG("val_policingmap NULL");
free(rename_policingprofile);
- return UPLL_RC_ERR_GENERIC;
+ return UPLL_RC_SUCCESS;
}
// Copy the ctrl policer name in rename
uuu::upll_strncpy(
rename_policingprofile->policingprofile_newname,
val_policingmap->policer_name,
(kMaxLenPolicingProfileName + 1));
+ rename_policingprofile->valid[UPLL_IDX_RENAME_PROFILE_RPP] = UNC_VF_VALID;
+
mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
UNC_KT_POLICING_PROFILE)));
if (NULL == mgr) {
UPLL_LOG_DEBUG("mgr policing profile NULL");
free(rename_policingprofile);
+ mgr = NULL;
return UPLL_RC_ERR_GENERIC;
}
// Get the memory allocated policingprofile key structure
result_code = mgr->GetChildConfigKey(unc_key, NULL);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG(" GetRenamedUncKey failed. GetChildConfigKey failed to "
- "create policingprofile ConfigKeyVal %d",
- result_code);
+ UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
free(rename_policingprofile);
+ mgr = NULL;
return result_code;
}
if (!unc_key) {
+ UPLL_LOG_DEBUG("unc_key NULL");
free(rename_policingprofile);
+ mgr = NULL;
return UPLL_RC_ERR_GENERIC;
}
SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
// Read the UNC name from RENAMETBL
result_code = mgr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL);
- if (UPLL_RC_SUCCESS != result_code
- && UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
- UPLL_LOG_DEBUG(" GetRenamedUncKey failed. ReadConfigDB failed to read %d ",
- result_code);
- CONFIGKEYVALCLEAN(unc_key);
- return UPLL_RC_ERR_GENERIC;
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ mgr = NULL;
+ DELETE_IF_NOT_NULL(unc_key);
+ return result_code;
}
// Get the UNC name
}
}
}
- CONFIGKEYVALCLEAN(unc_key);
-
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vbrpm end",
+ ikey->ToStrAll().c_str());
+ DELETE_IF_NOT_NULL(unc_key);
+ mgr = NULL;
return UPLL_RC_SUCCESS;
}
return UPLL_RC_ERR_GENERIC;
}
- DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutCtrlr };
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr | kOpMatchDomain, kOpInOutCtrlr };
// Check the rename
result_code = IsRenamed(ikey, dt_type, dmi, rename);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG(" GetRenamedControllerKey failed. IsRenamed failed to "
- "check rename - %d",
- result_code);
+ UPLL_LOG_DEBUG("IsRenamed failed (%d)", result_code);
return result_code;
}
if (rename == 0) {
- pfc_log_debug(
- "GetRenamedControllerKey No Rename");
+ UPLL_LOG_DEBUG("GetRenamedControllerKey No Rename");
return UPLL_RC_SUCCESS;
}
+ UPLL_LOG_TRACE("Start Input ConfigKeyVal %s", ikey->ToStrAll().c_str());
- if (rename & VTN_RENAME || rename & VBR_RENAME) {
- // Get the vbr object
+ if ((rename & VTN_RENAME) || (rename & VBR_RENAME)) {
MoMgrImpl *mgr =
reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
UNC_KT_VBRIDGE)));
// Get memory allocated vbr key structure
result_code = mgr->GetChildConfigKey(okey, NULL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(" GetRenamedControllerKey failed. "
- "GetChildConfigKey failed to create vbr ConfigKey - %d",
- result_code);
+ UPLL_LOG_DEBUG("GetChildConfigKey failed (%d)", result_code);
return result_code;
}
if (!okey) return UPLL_RC_ERR_GENERIC;
- key_vbr_t *ovbr_key = reinterpret_cast<key_vbr_t*>(okey->get_key());
- key_vbr_t *ivbr_key = reinterpret_cast<key_vbr_t*>(ikey->get_key());
+ if (NULL != ctrlr_dom) {
+ SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom)
+ }
+ else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
- uuu::upll_strncpy(reinterpret_cast<char*>(ovbr_key->vtn_key.vtn_name),
- reinterpret_cast<char*>(ivbr_key->vtn_key.vtn_name),
- (kMaxLenVtnName+1));
- uuu::upll_strncpy(reinterpret_cast<char*>(ovbr_key->vbridge_name),
- reinterpret_cast<char*>(ivbr_key->vbridge_name),
- (kMaxLenVnodeName+1));
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+ if (UNC_KT_VBR_POLICINGMAP == ikey->get_key_type()) {
+ UPLL_LOG_DEBUG("UNC_KT_VBR_POLICINGMAP (%d)", ikey->get_key_type());
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vbr_t *>(okey->get_key())->vtn_key.vtn_name,
+ reinterpret_cast<key_vbr_t *>(ikey->get_key())->vtn_key.vtn_name,
+ (kMaxLenVtnName + 1));
- if (NULL != ctrlr_dom) SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+ UPLL_LOG_DEBUG("vtn name (%s) (%s)",
+ reinterpret_cast<key_vbr *>(okey->get_key())->vtn_key.vtn_name,
+ reinterpret_cast<key_vbr_t *>(ikey->get_key())->vtn_key.vtn_name);
- // Read the renamed vtn/vbr
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vbr *>(okey->get_key())->vbridge_name,
+ reinterpret_cast<key_vbr_t *>(ikey->get_key())->vbridge_name,
+ (kMaxLenVnodeName + 1));
+
+ UPLL_LOG_DEBUG("vbr name (%s) (%s)",
+ reinterpret_cast<key_vbr *>(okey->get_key())->vbridge_name,
+ reinterpret_cast<key_vbr_t *>(ikey->get_key())->vbridge_name);
+ } else if (UNC_KT_VBR_POLICINGMAP_ENTRY == ikey->get_key_type()) {
+ UPLL_LOG_DEBUG("UNC_KT_VBR_POLICINGMAP_ENTRY (%d)", ikey->get_key_type());
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vbr_t *>(okey->get_key())->vtn_key.vtn_name,
+ reinterpret_cast<key_vbr_policingmap_entry_t *>
+ (ikey->get_key())->vbr_key.vtn_key.vtn_name,
+ (kMaxLenVtnName + 1));
+
+ UPLL_LOG_DEBUG("vbr_pm_entry vtn name (%s) (%s)",
+ reinterpret_cast<key_vbr *>(okey->get_key())->vtn_key.vtn_name,
+ reinterpret_cast<key_vbr_policingmap_entry_t *>
+ (ikey->get_key())->vbr_key.vtn_key.vtn_name);
+
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vbr *>(okey->get_key())->vbridge_name,
+ reinterpret_cast<key_vbr_policingmap_entry_t *>(ikey->get_key())->vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+
+ UPLL_LOG_DEBUG("vbr_pm_entry vbr name (%s) (%s)",
+ reinterpret_cast<key_vbr *>(okey->get_key())->vbridge_name,
+ reinterpret_cast<key_vbr_policingmap_entry_t *>(ikey->get_key())->vbr_key.vbridge_name);
+ }
+
+ // Read the renamed vtn/vbr
result_code = mgr->ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(" GetRenamedControllerKey failed. ReadConfigDB failed "
- "to read vbr renametbl - %d",
- result_code);
- CONFIGKEYVALCLEAN(okey);
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB no instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("ReadConfigDB failed (%d)", result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
// Get the key from okey
reinterpret_cast<val_rename_vnode_t *>(GetVal(okey));
if (!rename_val) {
UPLL_LOG_DEBUG("rename_val NULL");
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
if (rename & VTN_RENAME) { /* vtn renamed */
- uuu::upll_strncpy(ivbr_key->vtn_key.vtn_name,
- rename_val->ctrlr_vtn_name,
- (kMaxLenVtnName + 1));
+ UPLL_LOG_DEBUG("vtn name renamed");
+
+ if (UNC_KT_VBR_POLICINGMAP == ikey->get_key_type()) {
+ uuu::upll_strncpy(reinterpret_cast<key_vbr_t *>
+ (ikey->get_key())->vtn_key.vtn_name,
+ rename_val->ctrlr_vtn_name,
+ (kMaxLenVtnName + 1));
+ } else if (UNC_KT_VBR_POLICINGMAP_ENTRY == ikey->get_key_type()) {
+ uuu::upll_strncpy(reinterpret_cast<key_vbr_policingmap_entry_t *>
+ (ikey->get_key())->vbr_key.vtn_key.vtn_name,
+ rename_val->ctrlr_vtn_name,
+ (kMaxLenVtnName + 1));
+ }
}
if (rename & VBR_RENAME) { /* vnode renamed */
- uuu::upll_strncpy(ivbr_key->vbridge_name,
- rename_val->ctrlr_vnode_name,
- (kMaxLenVnodeName + 1));
+ UPLL_LOG_DEBUG("vbr name renamed");
+ if (UNC_KT_VBR_POLICINGMAP == ikey->get_key_type()) {
+ uuu::upll_strncpy(reinterpret_cast<char *>
+ (reinterpret_cast<key_vbr_t *>(ikey->get_key())->vbridge_name),
+ reinterpret_cast<const char *>(rename_val->ctrlr_vnode_name),
+ kMaxLenVnodeName + 1);
+ } else if (UNC_KT_VBR_POLICINGMAP_ENTRY == ikey->get_key_type()) {
+ uuu::upll_strncpy(reinterpret_cast<char *>
+ (reinterpret_cast<key_vbr_policingmap_entry_t *>
+ (ikey->get_key())->vbr_key.vbridge_name),
+ reinterpret_cast<const char *>(rename_val->ctrlr_vnode_name),
+ kMaxLenVnodeName + 1);
+ }
}
- SET_USER_DATA_FLAGS(ikey, rename);
- mgr = NULL;
+ DELETE_IF_NOT_NULL(okey);
}
- CONFIGKEYVALCLEAN(okey);
-
+ if (UNC_KT_VBR_POLICINGMAP == ikey->get_key_type()) {
if (rename & POLICINGPROFILE_RENAME) {
- // Get policingprofile object
+ UPLL_LOG_DEBUG("policing profile name renamed");
MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>
(GetMoManager(UNC_KT_POLICING_PROFILE)));
if (NULL == mgr) {
// Get policingprofile key structure
result_code = mgr->GetChildConfigKey(okey, NULL);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG(" GetRenamedControllerKey GetChildConfigKey failed"
- "to create policingprofile ConfigKey - %d",
- result_code);
+ UPLL_LOG_DEBUG("GetChildConfigKey failed (%d)", result_code);
return result_code;
}
if (!okey) return UPLL_RC_ERR_GENERIC;
+ if (NULL != ctrlr_dom) {
+ SET_USER_DATA_CTRLR(okey, ctrlr_dom->ctrlr);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
val_policingmap_t *val_policingmap =
reinterpret_cast<val_policingmap_t *>(GetVal(ikey));
+ if (!val_policingmap)
+ return UPLL_RC_SUCCESS;
+
key_policingprofile_t *key_policingprofile =
reinterpret_cast<key_policingprofile_t *>(okey->get_key());
-
uuu::upll_strncpy(key_policingprofile->policingprofile_name,
val_policingmap->policer_name,
(kMaxLenPolicingProfileName + 1));
- if (NULL != ctrlr_dom) SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
-
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutCtrlr };
result_code = mgr->ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(" GetRenamedControllerKey failed. ReadConfigDB failed "
- "to read policingprofile renametbl - %d",
- result_code);
- CONFIGKEYVALCLEAN(okey);
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB no instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("ReadConfigDB failed (%d)", result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
val_rename_policingprofile_t *rename_policingprofile =
reinterpret_cast<val_rename_policingprofile_t *>(GetVal(okey));
if (!rename_policingprofile) {
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
+ UPLL_LOG_DEBUG("profile is not valid");
return UPLL_RC_ERR_GENERIC;
}
->policingprofile_newname),
(kMaxLenPolicingProfileName + 1));
- SET_USER_DATA_FLAGS(ikey, rename);
mgr = NULL;
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
+ }
}
- CONFIGKEYVALCLEAN(okey);
+ UPLL_LOG_TRACE("End Input ConfigKeyVal %s", ikey->ToStrAll().c_str());
return UPLL_RC_SUCCESS;
}
bool VbrPolicingMapMoMgr::CompareValidValue(void *&val1, void *val2,
bool audit) {
UPLL_FUNC_TRACE;
+ bool invalid_attr = true;
val_policingmap_t *val_pm1 = reinterpret_cast<val_policingmap_t *>(val1);
val_policingmap_t *val_pm2 = reinterpret_cast<val_policingmap_t *>(val2);
// if (audit) {
reinterpret_cast<char*>(val_pm2->policer_name)))
val_pm1->valid[UPLL_IDX_POLICERNAME_PM] = UNC_VF_INVALID;
}
- return false;
+ if ((UNC_VF_VALID == (uint8_t)val_pm1->valid[UPLL_IDX_POLICERNAME_PM]) ||
+ (UNC_VF_VALID_NO_VALUE == (uint8_t)val_pm1->valid[UPLL_IDX_POLICERNAME_PM]))
+ invalid_attr = false;
+
+ return invalid_attr;
}
+#if 0
upll_rc_t VbrPolicingMapMoMgr::UpdateConfigStatus(ConfigKeyVal *ckv,
unc_keytype_operation_t op, uint32_t driver_result,
ConfigKeyVal *nreq, DalDmlIntf *dmi,
val = reinterpret_cast<val_policingmap_t *> (GetVal(ckv));
if (val == NULL) return UPLL_RC_ERR_GENERIC;
if (op == UNC_OP_CREATE) {
- if (val->cs_row_status != UNC_CS_NOT_SUPPORTED)
+ if (val->cs_row_status != UNC_CS_NOT_SUPPORTED) {
val->cs_row_status = cs_status;
+ val->cs_attr[0] = cs_status;
+ }
} else {
UPLL_LOG_DEBUG("Operation Not Supported.");
return UPLL_RC_ERR_GENERIC;
UPLL_LOG_DEBUG("Update Config Status Successfull.");
return UPLL_RC_SUCCESS;
}
+#endif
upll_rc_t VbrPolicingMapMoMgr::UpdateAuditConfigStatus(
unc_keytype_configstatus_t cs_status,
ConfigKeyVal *&ckv_running) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- val_vbr_t *val;
- val =
- (ckv_running != NULL) ? reinterpret_cast<val_vbr_t *>
- (GetVal(ckv_running)) :NULL;
+ if (NULL == ckv_running)
+ return UPLL_RC_ERR_GENERIC;
+ val_policingmap_t *val = NULL;
+ val = reinterpret_cast<val_policingmap_t *>(GetVal(ckv_running));
if (NULL == val) {
UPLL_LOG_DEBUG("vbr_val NULL");
return UPLL_RC_ERR_GENERIC;
}
- if (uuc::kUpllUcpCreate == phase)
+ if (uuc::kUpllUcpCreate == phase )
val->cs_row_status = cs_status;
- for (unsigned int loop = 0; loop < sizeof(val->valid) / sizeof(uint8_t);
- ++loop) {
- if (cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop])
- val->cs_attr[loop] = cs_status;
- else
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
+ for ( unsigned int loop = 0;
+ loop < sizeof(val->valid)/sizeof(uint8_t); ++loop ) {
+ if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
+ cs_status == UNC_CS_APPLIED)
val->cs_attr[loop] = cs_status;
}
return result_code;
}
delete okey;
+
+ result_code = SetRenameFlag(ikey, dmi, req);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("SetRenameFlag failed %d", result_code);
+ return result_code;
+ }
UPLL_LOG_DEBUG("ValidateAttribute Successfull.");
return result_code;
}
reinterpret_cast<val_policingmap_t *>(ConfigKeyVal::Malloc
(sizeof(val_policingmap_t)));
+ memset(policingmap_val, 0, sizeof(val_policingmap_t));
memcpy(policingmap_val, ival, sizeof(val_policingmap_t));
tmp1 = new ConfigVal(IpctSt::kIpcStValPolicingmap, policingmap_val);
key_vbr_t *ikey = reinterpret_cast<key_vbr_t *>(tkey);
key_vbr_t *vbr_key = reinterpret_cast<key_vbr_t *>
(ConfigKeyVal::Malloc(sizeof(key_vbr_t)));
+ memset(vbr_key, 0, sizeof(key_vbr_t));
memcpy(vbr_key, ikey, sizeof(key_vbr_t));
okey = new ConfigKeyVal(UNC_KT_VBR_POLICINGMAP, IpctSt::kIpcStKeyVbr, vbr_key,
tmp1);
if (!okey) {
if (vbr_key) free(vbr_key);
- if (policingmap_val) free(policingmap_val);
+ DELETE_IF_NOT_NULL(tmp1);
UPLL_LOG_DEBUG("okey failed");
return UPLL_RC_ERR_GENERIC;
}
if (okey) {
if (okey->get_key_type() != UNC_KT_VBR_POLICINGMAP)
return UPLL_RC_ERR_GENERIC;
+ }
+
+ if ((okey) && (okey->get_key())) {
vbr_key = reinterpret_cast<key_vbr_t *>(okey->get_key());
} else {
vbr_key = reinterpret_cast<key_vbr_t *>
if (vbr_key) free(vbr_key);
return UPLL_RC_ERR_GENERIC;
}
+
+ if ((okey) && !(okey->get_key())) {
+ UPLL_LOG_DEBUG("okey not null and flow list name updated");
+ okey->SetKey(IpctSt::kIpcStKeyVbr, vbr_key);
+ }
+
if (!okey) {
okey = new ConfigKeyVal(UNC_KT_VBR_POLICINGMAP, IpctSt::kIpcStKeyVbr,
vbr_key, NULL);
/** check key type is UNC_KT_VBR_POLICINGMAP */
if (UNC_KT_VBR_POLICINGMAP == key->get_key_type()) {
+ if ((req->datatype == UPLL_DT_IMPORT) && (req->operation == UNC_OP_READ ||
+ req->operation == UNC_OP_READ_SIBLING ||
+ req->operation == UNC_OP_READ_SIBLING_BEGIN ||
+ req->operation == UNC_OP_READ_NEXT ||
+ req->operation == UNC_OP_READ_BULK ||
+ req->operation == UNC_OP_READ_SIBLING_COUNT)) {
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+
+ if ((req->option1 == UNC_OPT1_DETAIL) &&
+ (req->datatype != UPLL_DT_STATE)) {
+ UPLL_LOG_DEBUG(" Invalid Datatype(%d)", req->datatype);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+
if (key->get_st_num() != IpctSt::kIpcStKeyVbr) {
- UPLL_LOG_DEBUG(
- " Invalid structure received expected struct -"
- "kIpcStKeyVbr, received struct - %s ",
- reinterpret_cast<const char *>
- (IpctSt::GetIpcStdef(key->get_st_num())));
+ UPLL_LOG_DEBUG(" Invalid key structure received. struct num:%d",
+ key->get_st_num());
return UPLL_RC_ERR_BAD_REQUEST;
}
/** Read key structure */
key_vbr = reinterpret_cast<key_vbr_t *>(key->get_key());
} else if (UNC_KT_VBR_POLICINGMAP_ENTRY == key->get_key_type()) {
+ if ((req->datatype == UPLL_DT_IMPORT) && (req->operation == UNC_OP_READ ||
+ req->operation == UNC_OP_READ_SIBLING ||
+ req->operation == UNC_OP_READ_SIBLING_BEGIN ||
+ req->operation == UNC_OP_READ_NEXT ||
+ req->operation == UNC_OP_READ_BULK ||
+ req->operation == UNC_OP_READ_SIBLING_COUNT)) {
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+
+ if (req->datatype != UPLL_DT_STATE) {
+ UPLL_LOG_DEBUG(" Unsupported Datatype (%d)", req->datatype);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
if (key->get_st_num() != IpctSt::kIpcStKeyVbrPolicingmapEntry) {
- UPLL_LOG_DEBUG(
- " Invalid structure received expected struct -"
- "kIpcStKeyVbrPolicingmapEntry, received struct - %s ",
- reinterpret_cast<const char *>(IpctSt::GetIpcStdef
- (key->get_st_num())));
+ UPLL_LOG_DEBUG(" Invalid key structure received. struct num:%d",
+ key->get_st_num());
return UPLL_RC_ERR_BAD_REQUEST;
}
key_vbr_policingmap_entry =
/** validate val struct for UNC_KT_VBR_POLICINGMAP */
UPLL_LOG_DEBUG(" key struct validation is success");
- val_policingmap_t *val_policingmap = NULL;
-
- if (key->get_cfg_val() && (key->get_cfg_val()->get_st_num() ==
- IpctSt::kIpcStValPolicingmap)) {
- val_policingmap =
- reinterpret_cast<val_policingmap_t *>(key->get_cfg_val()->get_val());
- }
-
- rt_code = VtnPolicingMapMoMgr::ValidatePolicingMapValue(val_policingmap, req);
+ /** validate value structure*/
+ rt_code = VtnPolicingMapMoMgr::ValidatePolicingMapValue(key, req->operation);
if (UPLL_RC_SUCCESS != rt_code) {
UPLL_LOG_DEBUG(" val_policingmap syntax validation failed :"
upll_rc_t rt_code = UPLL_RC_ERR_GENERIC;
- /** Use VtnPolicingMapMoMgr::ValidateCapability
- * to validate capability for val_policingmap structure*/
- VtnPolicingMapMoMgr *mgrvtnpmap = reinterpret_cast<VtnPolicingMapMoMgr *>
- (const_cast<MoManager *>(GetMoManager(UNC_KT_VTN_POLICINGMAP)));
+ if ((NULL == req) || (NULL == ikey)) {
+ UPLL_LOG_DEBUG("IpcReqRespHeader/ConfigKeyval is NULL");
+ return rt_code;
+ }
- rt_code = mgrvtnpmap->ValidateCapability(req, ikey);
+ if (!ctrlr_name)
+ ctrlr_name = static_cast<char *>(ikey->get_user_data());
- if (UPLL_RC_SUCCESS != rt_code) {
- UPLL_LOG_DEBUG(" PolicierName syntax validation failed :"
- "Err Code - %d",
- rt_code);
+ if (NULL == ctrlr_name) {
+ UPLL_LOG_DEBUG(" ctrlr_name is NULL");
+ return rt_code;
}
- return rt_code;
+
+ bool result_code = false;
+ uint32_t max_instance_count = 0;
+ const uint8_t *attrs = NULL;
+ uint32_t max_attrs = 0;
+
+ UPLL_LOG_TRACE("Ctrl_name(%s),operation:(%d)", ctrlr_name, req->operation);
+
+ switch (req->operation) {
+ case UNC_OP_CREATE:
+ result_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_instance_count, &max_attrs, &attrs);
+
+ if (result_code && (max_instance_count != 0) &&
+ (cur_instance_count >= max_instance_count)) {
+ UPLL_LOG_DEBUG("Instance count %d exceeds %d", cur_instance_count,
+ max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
+ break;
+ case UNC_OP_UPDATE:
+ result_code = GetUpdateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ break;
+ default:
+ if (req->datatype == UPLL_DT_STATE)
+ result_code = GetStateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ else
+ result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ break;
+ }
+
+ if (!result_code) {
+ UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s)"
+ " for operation(%d)",
+ ikey->get_key_type(), ctrlr_name, req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+
+ val_policingmap_t *val_policingmap = reinterpret_cast<val_policingmap_t *>(GetVal(ikey));
+
+ if (val_policingmap) {
+ if (max_attrs > 0) {
+ if ((val_policingmap->valid[UPLL_IDX_POLICERNAME_PM] == UNC_VF_VALID)
+ || (val_policingmap->valid[UPLL_IDX_POLICERNAME_PM]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtn_policingmap::kCapPolicername] == 0) {
+ val_policingmap->valid[UPLL_IDX_POLICERNAME_PM] =
+ UNC_VF_NOT_SUPPORTED;
+ UPLL_LOG_DEBUG("Policername attr is not supported by ctrlr");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ } else {
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d", req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+}
+ return UPLL_RC_SUCCESS;
}
bool VbrPolicingMapMoMgr::IsValidKey(void *key, uint64_t index) {
UPLL_FUNC_TRACE;
key_vbr *vbr_key = reinterpret_cast<key_vbr *>(key);
- bool ret_val = false;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
switch (index) {
case uudst::vbridge::kDbiVtnName:
ret_val = ValidateKey(reinterpret_cast<char *>(vbr_key->vtn_key.vtn_name),
} else {
UPLL_LOG_DEBUG("Incorrect structure received from driver, struct num %d",
drv_resp_val->get_st_num());
+ delete tmp_okey;
return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_TRACE("valida of val structure");
sizeof(val_policingprofile_entry_t));
tmp_okey->AppendCfgVal(IpctSt::kIpcStValPolicingprofileEntry,
tmp_val_ppe);
- // temp_cfg_val = temp_cfg_val->get_next_cfg_val();
delete tkey;
tkey = NULL;
if ((drv_resp_val = drv_resp_val->get_next_cfg_val())== NULL) {
while (IpctSt::kIpcStValPolicingmapSwitchSt ==
drv_resp_val->get_st_num()) {
- val_policingmap_switch_st * val_switch_st =
- reinterpret_cast<val_policingmap_switch_st*>
- (ConfigKeyVal::Malloc(sizeof(val_policingmap_switch_st)));
- memcpy(val_switch_st,
- reinterpret_cast<val_policingmap_switch_st*>
- (drv_resp_val->get_val()),
- sizeof(val_policingmap_switch_st));
+ val_policingmap_switch_st_t *val_switch_st =
+ reinterpret_cast<val_policingmap_switch_st_t*>
+ (ConfigKeyVal::Malloc(sizeof(val_policingmap_switch_st_t)));
+ val_policingmap_switch_st_t *drv_val_switch_st =
+ reinterpret_cast<val_policingmap_switch_st_t*>
+ (drv_resp_val->get_val());
+ memcpy(val_switch_st, drv_val_switch_st,
+ sizeof(val_policingmap_switch_st_t));
+ if(drv_val_switch_st->valid[UPLL_IDX_IF_NAME_PMSS] == UNC_VF_VALID) {
+ key_vbr_policingmap_entry *vbr_pme_key =
+ reinterpret_cast<key_vbr_policingmap_entry *>(ikey->get_key());
+ ConfigKeyVal *vbrif_key_val = NULL;
+ unc::upll::kt_momgr::VbrIfMoMgr *vbrifmgr =
+ reinterpret_cast<unc::upll::kt_momgr::VbrIfMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VBR_IF)));
+ if (NULL == vbrifmgr) {
+ if (val_switch_st) free(val_switch_st);
+ DELETE_IF_NOT_NULL(tmp_okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = vbrifmgr->GetVbrIfFromVExternal(
+ vbr_pme_key->vbr_key.vtn_key.vtn_name,
+ drv_val_switch_st->if_name,
+ vbrif_key_val,
+ dmi);
+ if ((result_code != UPLL_RC_SUCCESS) &&
+ (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG("Get vBridge info failed err code (%d)",
+ result_code);
+ if (val_switch_st) free(val_switch_st);
+ DELETE_IF_NOT_NULL(tmp_okey);
+ DELETE_IF_NOT_NULL(vbrif_key_val);
+ return result_code;
+ }
+
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ key_vbr_if_t *key_vbrif = reinterpret_cast<key_vbr_if_t*>
+ (vbrif_key_val->get_key());
+ val_switch_st->valid[UPLL_IDX_VBR_NAME_PMSS] = UNC_VF_VALID;
+ uuu::upll_strncpy(val_switch_st->vbr_name,
+ key_vbrif->vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+
+ val_switch_st->valid[UPLL_IDX_IF_NAME_PMSS] = UNC_VF_VALID;
+ uuu::upll_strncpy(val_switch_st->if_name,
+ key_vbrif->if_name,
+ (kMaxLenInterfaceName + 1));
+ }
+ DELETE_IF_NOT_NULL(vbrif_key_val);
+ }
tmp_okey->AppendCfgVal(IpctSt::kIpcStValPolicingmapSwitchSt,
- drv_resp_val->get_val());
+ val_switch_st);
+
drv_resp_val = drv_resp_val->get_next_cfg_val();
if (!drv_resp_val) {
break;
tkey, dt_type, dbop, dmi);
if (result_code != UPLL_RC_SUCCESS) {
delete tkey;
+ delete tmp_okey;
return result_code;
}
val_policingprofile_entry_t *temp_val_policingprofile =
memcpy(tmp_cont_st, val_entry_st, sizeof(val_policingmap_controller_st));
tmp_okey->AppendCfgVal(IpctSt::kIpcStValPolicingmapControllerSt,
- val_entry_st);
+ tmp_cont_st);
val_policingprofile_entry_t *tmp_val_ppe =
reinterpret_cast<val_policingprofile_entry_t * >
(ConfigKeyVal::Malloc(sizeof(val_policingprofile_entry_t)));
sizeof(val_policingprofile_entry_t));
tmp_okey->AppendCfgVal(IpctSt::kIpcStValPolicingprofileEntry,
tmp_val_ppe);
- // temp_cfg_val = temp_cfg_val->get_next_cfg_val();
delete tkey;
tkey = NULL;
if ((drv_resp_val = drv_resp_val->get_next_cfg_val())== NULL) {
+ free(tmp_cont_st);
continue;
}
if (IpctSt::kIpcStValPolicingmapSwitchSt != drv_resp_val->get_st_num()) {
UPLL_LOG_DEBUG("No PolicingmapSwitchSt entries returned by driver");
+ free(tmp_cont_st);
continue;
}
while (IpctSt::kIpcStValPolicingmapSwitchSt ==
drv_resp_val->get_st_num()) {
- val_policingmap_switch_st * val_switch_st =
- reinterpret_cast<val_policingmap_switch_st*>
- (ConfigKeyVal::Malloc(sizeof(val_policingmap_switch_st)));
- memcpy(val_switch_st,
- reinterpret_cast<val_policingmap_switch_st*>
- (drv_resp_val->get_val()),
- sizeof(val_policingmap_switch_st));
+ val_policingmap_switch_st_t *val_switch_st =
+ reinterpret_cast<val_policingmap_switch_st_t*>
+ (ConfigKeyVal::Malloc(sizeof(val_policingmap_switch_st_t)));
+ val_policingmap_switch_st_t *drv_val_switch_st =
+ reinterpret_cast<val_policingmap_switch_st_t*>
+ (drv_resp_val->get_val());
+ memcpy(val_switch_st, drv_val_switch_st,
+ sizeof(val_policingmap_switch_st_t));
+ if(drv_val_switch_st->valid[UPLL_IDX_IF_NAME_PMSS] == UNC_VF_VALID) {
+ key_vbr_t *vbr_pm_key =
+ reinterpret_cast<key_vbr_t*>(ikey->get_key());
+ ConfigKeyVal *vbrif_key_val = NULL;
+ unc::upll::kt_momgr::VbrIfMoMgr *vbrifmgr =
+ reinterpret_cast<unc::upll::kt_momgr::VbrIfMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VBR_IF)));
+ if (NULL == vbrifmgr) {
+ free(val_switch_st);
+ free(tmp_cont_st);
+ delete tmp_okey;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = vbrifmgr->GetVbrIfFromVExternal(
+ vbr_pm_key->vtn_key.vtn_name,
+ drv_val_switch_st->if_name,
+ vbrif_key_val,
+ dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Get vBridge info failed err code (%d)",
+ result_code);
+ free(val_switch_st);
+ free(tmp_cont_st);
+ delete tmp_okey;
+ return result_code;
+ }
+ key_vbr_if_t *key_vbrif = reinterpret_cast<key_vbr_if_t*>
+ (vbrif_key_val->get_key());
+ val_switch_st->valid[UPLL_IDX_VBR_NAME_PMSS] = UNC_VF_VALID;
+ uuu::upll_strncpy(val_switch_st->vbr_name,
+ key_vbrif->vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+
+ val_switch_st->valid[UPLL_IDX_IF_NAME_PMSS] = UNC_VF_VALID;
+ uuu::upll_strncpy(val_switch_st->if_name,
+ key_vbrif->if_name,
+ (kMaxLenInterfaceName + 1));
+ DELETE_IF_NOT_NULL(vbrif_key_val);
+ }
tmp_okey->AppendCfgVal(IpctSt::kIpcStValPolicingmapSwitchSt,
- drv_resp_val->get_val());
+ val_switch_st);
drv_resp_val = drv_resp_val->get_next_cfg_val();
if (!drv_resp_val) {
break;
val_policingmap = reinterpret_cast<val_policingmap_t*>(GetVal(dup_key));
if (val_policingmap == NULL) {
UPLL_LOG_DEBUG("Invalid value");
+ delete tmp_okey;
return UPLL_RC_ERR_GENERIC;
}
val_policingmap_t *val_pm = reinterpret_cast<val_policingmap_t *>
tkey, dt_type, dbop, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadDetailEntry failed");
- CONFIGKEYVALCLEAN(tkey);
+ DELETE_IF_NOT_NULL(tkey);
delete tmp_okey;
return result_code;
}
UPLL_LOG_DEBUG(" Input Key is NULL");
return UPLL_RC_ERR_GENERIC;
}
-
+ DELETE_IF_NOT_NULL(okey);
unc_key_type_t ikey_type = ikey->get_key_type();
if (ikey_type != UNC_KT_VBR_POLICINGMAP) {
UPLL_LOG_DEBUG(" Invalid key type received. Key type - %d", ikey_type);
result_code);
return result_code;
}
- if (UNC_KT_VBR_POLICINGMAP_ENTRY != ikey->get_key_type() &&
- req->datatype != UPLL_DT_STATE) {
- result_code = ReadInfoFromDB(req, ikey, dmi, &ctrlr_dom);
- return result_code;
+ if (UNC_KT_VBR_POLICINGMAP_ENTRY != ikey->get_key_type()) {
+ if(req->datatype == UPLL_DT_STATE ||
+ req->datatype == UPLL_DT_STARTUP ||
+ req->datatype == UPLL_DT_RUNNING ||
+ req->datatype == UPLL_DT_CANDIDATE ) {
+ result_code = ReadInfoFromDB(req, ikey, dmi, &ctrlr_dom);
+ return result_code;
+ } else {
+ UPLL_LOG_DEBUG("ReadSiblingCount is not Allowed For Such datatype %d",
+ req->datatype);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+ }
+ if (UNC_KT_VBR_POLICINGMAP_ENTRY == ikey->get_key_type())
+ if(req->datatype != UPLL_DT_STATE) {
+ UPLL_LOG_DEBUG("ReadSiblingCount is not Allowed For Such datatype %d",
+ req->datatype);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
+
ConfigKeyVal *temp_vbr_key = NULL;
ConfigKeyVal *tctrl_key = NULL;
result_code = GetReadVbrKey(temp_vbr_key, ikey);
result_code = mgr->ReadSiblingMo(temp_req, tctrl_key, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Read sibling of ppe failed (%d)", result_code);
+ ConfigKeyVal::Free(temp_req);
return result_code;
}
+ ConfigKeyVal::Free(temp_req);
+
ConfigKeyVal *temp_ppe_ckv = tctrl_key;
uint8_t sibling_count = 0;
while (temp_ppe_ckv !=NULL) {
}
if (is_vbr) {
+ mgrvbr = reinterpret_cast<VbrMoMgr*>
+ (const_cast<MoManager*>(GetMoManager(UNC_KT_VBRIDGE)));
+ if (NULL == mgrvbr) {
+ UPLL_LOG_DEBUG("unable to get VbrMoMgr object to validate key_vbr");
+ return UPLL_RC_ERR_GENERIC;
+ }
result_code = GetChildConfigKey(ikey, NULL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
(kMaxLenVtnName + 1));
uuu::upll_strncpy(vbr_key->vbridge_name, alarm_data.vnode_name,
(kMaxLenVnodeName + 1));
- mgrvbr = reinterpret_cast<VbrMoMgr*>
- (const_cast<MoManager*>(GetMoManager(UNC_KT_VBRIDGE)));
- if (NULL == mgrvbr) {
- UPLL_LOG_DEBUG("unable to get VbrMoMgr object to validate key_vbr");
- return UPLL_RC_ERR_GENERIC;
- }
result_code = mgrvbr->ValidateVbrKey(vbr_key);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG(" Vbr key syntax validation failed :" "Err Code - %d",
result_code);
+ DELETE_IF_NOT_NULL(ikey);
return result_code;
}
} else {
mgrvtnpom = reinterpret_cast<VtnPolicingMapMoMgr*>
(const_cast<MoManager*>(GetMoManager(UNC_KT_VTN_POLICINGMAP)));
+
+ mgrvtn = reinterpret_cast<VtnMoMgr*>
+ (const_cast<MoManager*>(GetMoManager(UNC_KT_VTN)));
+ if (NULL == mgrvtn) {
+ UPLL_LOG_DEBUG("unable to get VtnMoMgr object to validate key_vtn");
+ return UPLL_RC_ERR_GENERIC;
+ }
result_code = GetChildConfigKey(ikey, NULL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
uuu::upll_strncpy(vtn_key->vtn_name, key_vtn.vtn_name,
(kMaxLenVtnName + 1));
- mgrvtn = reinterpret_cast<VtnMoMgr*>
- (const_cast<MoManager*>(GetMoManager(UNC_KT_VTN)));
- if (NULL == mgrvtn) {
- UPLL_LOG_DEBUG("unable to get VtnMoMgr object to validate key_vtn");
- return UPLL_RC_ERR_GENERIC;
- }
-
result_code = mgrvtn->ValidateVtnKey(vtn_key);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("Vtn Key validation failed - %d", result_code);
- delete ikey;
+ DELETE_IF_NOT_NULL(ikey);
return result_code;
}
}
dmi, &ctrlr_dom);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetRenamedControllerKey failed %d", result_code);
+ DELETE_IF_NOT_NULL(ikey);
return result_code;
}
vbr_key = reinterpret_cast<key_vbr_t*>(ikey->get_key());
dmi, &ctrlr_dom);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetRenamedControllerKey failed %d", result_code);
+ DELETE_IF_NOT_NULL(ikey);
return result_code;
}
vtn_key = reinterpret_cast<key_vtn_t*>(ikey->get_key());
vtn_name, vbr_name, reinterpret_cast<char*>
(const_cast<uint8_t*>(alarm_data.port_name)),
alarm_data.ofs_dpid);
-
+ DELETE_IF_NOT_NULL(ikey);
return result_code;
}
}
if (is_vbr) {
+ mgrvbr = reinterpret_cast<VbrMoMgr*>
+ (const_cast<MoManager*>(GetMoManager(UNC_KT_VBRIDGE)));
+ if (NULL == mgrvbr) {
+ UPLL_LOG_DEBUG("unable to get VbrMoMgr object to validate key_vbr");
+ return UPLL_RC_ERR_GENERIC;
+ }
result_code = GetChildConfigKey(ikey, NULL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
(kMaxLenVtnName + 1));
uuu::upll_strncpy(vbr_key->vbridge_name, alarm_data.vnode_name,
(kMaxLenVnodeName + 1));
- mgrvbr = reinterpret_cast<VbrMoMgr*>
- (const_cast<MoManager*>(GetMoManager(UNC_KT_VBRIDGE)));
- if (NULL == mgrvbr) {
- UPLL_LOG_DEBUG("unable to get VbrMoMgr object to validate key_vbr");
- return UPLL_RC_ERR_GENERIC;
- }
result_code = mgrvbr->ValidateVbrKey(vbr_key);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG(" Vbr key syntax validation failed :" "Err Code - %d",
result_code);
+ DELETE_IF_NOT_NULL(ikey);;
return result_code;
}
} else {
(const_cast<MoManager*>(GetMoManager(UNC_KT_VTN)));
if (NULL == mgrvtn) {
UPLL_LOG_DEBUG("unable to get VtnMoMgr object to validate key_vtn");
+ DELETE_IF_NOT_NULL(ikey);
return UPLL_RC_ERR_GENERIC;
}
result_code = mgrvtn->ValidateVtnKey(vtn_key);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("Vtn Key validation failed - %d", result_code);
- delete ikey;
+ DELETE_IF_NOT_NULL(ikey);
return result_code;
}
}
dmi, &ctrlr_dom);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetRenamedControllerKey failed %d", result_code);
+ DELETE_IF_NOT_NULL(ikey);
return result_code;
}
vbr_key = reinterpret_cast<key_vbr_t*>(ikey->get_key());
dmi, &ctrlr_dom);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetRenamedControllerKey failed %d", result_code);
+ DELETE_IF_NOT_NULL(ikey);
return result_code;
}
vtn_key = reinterpret_cast<key_vtn_t*>(ikey->get_key());
vtn_name, vbr_name, reinterpret_cast<char*>
(const_cast<uint8_t*>(alarm_data.port_name)),
alarm_data.ofs_dpid);
+ DELETE_IF_NOT_NULL(ikey);
+ return result_code;
+}
+upll_rc_t VbrPolicingMapMoMgr::CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id) {
+ UPLL_FUNC_TRACE;
+ if (NULL == ikey || NULL == dmi ||
+ NULL == ctrlr_id) {
+ UPLL_LOG_DEBUG(" CreateCandidateMo Failed. Insufficient input parameters");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_TRACE("%s Vbr_Pm CreateAuditMoImpl ikey",
+ ikey->ToStrAll().c_str());
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ uint8_t *controller_id = reinterpret_cast<uint8_t *>(
+ const_cast<char *>(ctrlr_id));
+ result_code = GetRenamedUncKey(ikey, UPLL_DT_RUNNING, dmi,
+ controller_id);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey Failed err_code %d", result_code);
+ return result_code;
+ }
+ ConfigKeyVal *okey = NULL;
+ result_code = GetControllerId(ikey, okey, UPLL_DT_AUDIT, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetControllerId failed %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(okey);
+ result_code = SetValidAudit(ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ return result_code;
+ }
+ result_code = UpdateConfigDB(ikey, UPLL_DT_AUDIT, UNC_OP_CREATE, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Create Record failed - %d", result_code);
+ return result_code;
+ }
+
+ val_policingmap_t *val_pm = reinterpret_cast<val_policingmap_t *>
+ (GetVal(ikey));
+ if (UNC_VF_VALID == val_pm->valid[UPLL_IDX_POLICERNAME_PM]) {
+ result_code = UpdateRefCountInPPCtrlr(ikey, UPLL_DT_AUDIT, dmi,
+ UNC_OP_CREATE);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateRefCountInPPCtrlr Err in CANDIDATE DB(%d)",
+ result_code);
+ return result_code;
+ }
+ }
+
+ // create a record in vbrpolicingmap table CANDIDATE DB
+/* result_code = UpdateConfigDB(ikey, UPLL_DT_AUDIT, UNC_OP_CREATE, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Create Record failed - %d", result_code);
+ return result_code;
+ }*/
+ UPLL_LOG_DEBUG("CreateCandidateMo Successful");
return result_code;
}
+
+upll_rc_t VbrPolicingMapMoMgr::DeleteChildrenPOM(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type, DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+
+ if (NULL == ikey || NULL == dmi) {
+ UPLL_LOG_DEBUG(" DeleteMo Failed. Insufficient input parameters");
+ return result_code;
+ }
+ // 1)Get vbr associated ctrlr name and invoke the PP and PPE functions to
+ // decrement the refcount capability. If refcount is zero, remove the record
+ // in policingprofilectrltbl and if refcount not zero update the refcount in
+ // policingprofilectrltbl
+ // 2)Delete the record in policingprofileentryctrltbl
+ ConfigKeyVal *okey = NULL;
+ result_code = GetChildConfigKey(okey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
+ return result_code;
+ }
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone,
+ kOpInOutCtrlr | kOpInOutDomain };
+ result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("UPLL_RC_ERR_NO_SUCH_INSTANCE");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ val_policingmap_t *val_pm = reinterpret_cast<val_policingmap_t *>
+ (GetVal(okey));
+ if (UNC_VF_VALID == val_pm->valid[UPLL_IDX_POLICERNAME_PM]) {
+ result_code = UpdateRefCountInPPCtrlr(okey, dt_type, dmi,
+ UNC_OP_DELETE);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateRefCountInPPCtrlr Error DB (%d)", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ }
+ DELETE_IF_NOT_NULL(okey);
+ // Delete the record in vbrpolicingmap table
+ ConfigKeyVal *temp_ikey = NULL;
+ result_code = GetChildConfigKey(temp_ikey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed");
+ return result_code;
+ }
+ result_code = UpdateConfigDB(temp_ikey, dt_type, UNC_OP_DELETE, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DeleteMo Failed. UpdateConfigdb failed to delete - %d",
+ result_code);
+ DELETE_IF_NOT_NULL(temp_ikey);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(temp_ikey);
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VbrPolicingMapMoMgr::IsPolicingProfileConfigured(
+ const char* policingprofile_name,
+ DalDmlIntf *dmi) {
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+ ConfigKeyVal *ckv = NULL;
+ result_code = GetChildConfigKey(ckv, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ return result_code;
+ }
+ if (!ckv) return UPLL_RC_ERR_GENERIC;
+ val_policingmap_t *pm_val = reinterpret_cast
+ < val_policingmap_t *>(ConfigKeyVal::Malloc(sizeof(val_policingmap_t)));
+ uuu::upll_strncpy(pm_val->policer_name, policingprofile_name,
+ (kMaxLenPolicingProfileName + 1));
+ pm_val->valid[UPLL_IDX_POLICERNAME_PM] = UNC_VF_VALID;
+ ckv->AppendCfgVal(IpctSt::kIpcStValPolicingmap, pm_val);
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone };
+ result_code = ReadConfigDB(ckv, UPLL_DT_CANDIDATE, UNC_OP_READ, dbop,
+ dmi, MAINTBL);
+ DELETE_IF_NOT_NULL(ckv);
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ return UPLL_RC_SUCCESS;
+ } else if (UPLL_RC_SUCCESS == result_code) {
+ result_code = UPLL_RC_ERR_INSTANCE_EXISTS;
+ }
+ return result_code;
+}
+
+upll_rc_t VbrPolicingMapMoMgr::SetValidAudit(ConfigKeyVal *&ikey) {
+ UPLL_FUNC_TRACE;
+ val_policingmap_t *val = reinterpret_cast
+ <val_policingmap_t *>(GetVal(ikey));
+ if (NULL == val) {
+ UPLL_LOG_DEBUG("val is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (val->valid[0] == UNC_VF_VALID) {
+ val->cs_attr[0] = UNC_CS_APPLIED;
+ } else if (val->valid[0] == UNC_VF_INVALID) {
+ val->cs_attr[0] = UNC_CS_NOT_APPLIED;
+ }
+ val->cs_row_status = UNC_CS_APPLIED;
+ return UPLL_RC_SUCCESS;
+}
+
+bool VbrPolicingMapMoMgr::FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op) {
+ UPLL_FUNC_TRACE;
+ if (op != UNC_OP_CREATE)
+ return CompareValidValue(val1, val2, copy_to_running);
+ return false;
+}
+
+upll_rc_t VbrPolicingMapMoMgr::UpdateConfigStatus(ConfigKeyVal *vbr_key,
+ unc_keytype_operation_t op,
+ uint32_t driver_result,
+ ConfigKeyVal *upd_key,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ctrlr_key) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_policingmap_t *vbr_pm;
+
+ unc_keytype_configstatus_t cs_status =
+ (driver_result == UPLL_RC_SUCCESS) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
+ vbr_pm = reinterpret_cast<val_policingmap_t *>(GetVal(vbr_key));
+ if (vbr_pm == NULL) return UPLL_RC_ERR_GENERIC;
+ if (op == UNC_OP_CREATE) {
+ vbr_pm->cs_row_status = cs_status;
+ UPLL_LOG_DEBUG("cs_row_status in create %d", vbr_pm->cs_row_status);
+ } else if (op == UNC_OP_UPDATE) {
+ void *vbrpm = reinterpret_cast<void *>(vbr_pm);
+ CompareValidValue(vbrpm, GetVal(upd_key), true);
+ } else {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_TRACE("%s", (vbr_key->ToStrAll()).c_str());
+ val_policingmap_t *vbr_val2 = reinterpret_cast<val_policingmap_t *>(GetVal(upd_key));
+ if (UNC_OP_UPDATE == op) {
+ UPLL_LOG_TRACE("%s", (upd_key->ToStrAll()).c_str());
+ vbr_pm->cs_row_status = vbr_val2->cs_row_status;
+ }
+ UPLL_LOG_DEBUG("valid after CVV %d", vbr_pm->valid[0]);
+ if (UNC_VF_NOT_SUPPORTED == vbr_pm->valid[0]) {
+ vbr_pm->cs_attr[0] = UNC_CS_NOT_SUPPORTED;
+ } else if ((UNC_VF_VALID == vbr_pm->valid[0])
+ || (UNC_VF_VALID_NO_VALUE == vbr_pm->valid[0])) {
+ vbr_pm->cs_attr[0] = cs_status;
+ UPLL_LOG_DEBUG("cs_attr in V or NV: %d ",vbr_pm->cs_attr[0]);
+ } else if ((UNC_VF_INVALID == vbr_pm->valid[0]) &&
+ (UNC_OP_CREATE == op)) {
+ vbr_pm->cs_attr[0] = UNC_CS_NOT_APPLIED;
+ UPLL_LOG_DEBUG("cs_attr in IN in C: %d ",vbr_pm->cs_attr[0]);
+ } else if ((UNC_VF_INVALID == vbr_pm->valid[0]) &&
+ (UNC_OP_UPDATE == op)) {
+ UPLL_LOG_DEBUG("cs_attr in IN in U: %d ",vbr_pm->cs_attr[0]);
+ vbr_pm->cs_attr[0] = vbr_val2->cs_attr[0];
+ }
+ return result_code;
+}
+
+upll_rc_t VbrPolicingMapMoMgr::IsRenamed(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi,
+ uint8_t &rename) {
+ UPLL_FUNC_TRACE;
+ UPLL_LOG_DEBUG("VbrPolicingMapMoMgr IsRenamed");
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag | kOpInOutCtrlr
+ | kOpInOutDomain };
+ ConfigKeyVal *okey = NULL;
+ upll_rc_t result_code;
+ /* rename is set implies user wants the ikey
+ * populated with val from db */
+ if (!rename) {
+ if (UNC_KT_VBR_POLICINGMAP == ikey->get_key_type()) {
+ UPLL_LOG_DEBUG("UNC_KT_VBR_POLICINGMAP");
+ result_code = GetChildConfigKey(okey, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("Returning error %d",result_code);
+ return result_code;
+ }
+ } else if (UNC_KT_VBR_POLICINGMAP_ENTRY == ikey->get_key_type()) {
+ UPLL_LOG_DEBUG("UNC_KT_VBR_POLICINGMAP_CONTROLLER");
+
+ key_vbr_t *out_key = reinterpret_cast<key_vbr_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vbr_t)));
+
+ key_vbr_policingmap_entry_t *in_key = reinterpret_cast
+ <key_vbr_policingmap_entry_t *>(ikey->get_key());
+
+ uuu::upll_strncpy(out_key->vtn_key.vtn_name,
+ in_key->vbr_key.vtn_key.vtn_name,
+ (kMaxLenVtnName + 1));
+ uuu::upll_strncpy(out_key->vbridge_name,
+ in_key->vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+
+ okey = new ConfigKeyVal(UNC_KT_VBR_POLICINGMAP,
+ IpctSt::kIpcStKeyVbr,
+ out_key, NULL);
+ }
+ } else {
+ okey = ikey;
+ }
+
+ result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if ((result_code != UPLL_RC_SUCCESS) &&
+ (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG("Returning error code %d",result_code);
+ if (okey != ikey) delete okey;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ GET_USER_DATA_FLAGS(okey, rename);
+ controller_domain_t ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+
+ GET_USER_DATA_CTRLR_DOMAIN(ikey,ctrlr_dom);
+ UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+ SET_USER_DATA_CTRLR_DOMAIN(okey,ctrlr_dom);
+ UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+
+ SET_USER_DATA(ikey,okey);
+ rename &= RENAME;
+ if (okey != ikey) delete okey;
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VbrPolicingMapMoMgr::SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_policingmap_t *val_pm = reinterpret_cast
+ <val_policingmap_t *>(GetVal(ikey));
+ if (!val_pm) {
+ UPLL_LOG_DEBUG("Val is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigKeyVal *pkey = NULL;
+ if (UNC_OP_CREATE == req->operation) {
+ result_code = GetParentConfigKey(pkey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetParentConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_VBRIDGE)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("mgr is NULL");
+ DELETE_IF_NOT_NULL(pkey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t rename = 0;
+ result_code = mgr->IsRenamed(pkey, req->datatype, dmi, rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(pkey);
+ return result_code;
+ }
+
+ UPLL_LOG_DEBUG("Flag from parent : %d", rename);
+ DELETE_IF_NOT_NULL(pkey);
+ // Check flowlist is renamed
+ if ((UNC_VF_VALID == val_pm->valid[UPLL_IDX_POLICERNAME_PM]) &&
+ ((UNC_OP_CREATE == req->operation))) {
+ ConfigKeyVal *pp_ckv = NULL;
+ result_code = GetPolicingProfileConfigKey(reinterpret_cast<const char *>
+ (val_pm->policer_name), pp_ckv, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetPolicingProfileConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *pp_mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_POLICING_PROFILE)));
+ if (NULL == pp_mgr) {
+ UPLL_LOG_DEBUG("pp_mgr is NULL");
+ DELETE_IF_NOT_NULL(pp_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t pp_rename = 0;
+ result_code = pp_mgr->IsRenamed(pp_ckv, req->datatype, dmi, pp_rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(pp_ckv);
+ return result_code;
+ }
+ if (pp_rename & 0x01) {
+ rename |= POLICINGPROFILE_RENAME; // TODO Check for correct flag value
+ }
+ DELETE_IF_NOT_NULL(pp_ckv);
+ }
+ SET_USER_DATA_FLAGS(ikey, rename);
+ } else if (UNC_OP_UPDATE == req->operation) {
+ uint8_t rename = 0;
+ result_code = IsRenamed(ikey, req->datatype, dmi, rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ return result_code;
+ }
+ if (UNC_VF_VALID == val_pm->valid[UPLL_IDX_POLICERNAME_PM]) {
+ ConfigKeyVal *pp_ckv = NULL;
+ result_code = GetPolicingProfileConfigKey(reinterpret_cast<const char *>
+ (val_pm->policer_name), pp_ckv, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetPolicingProfileConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *pp_mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_POLICING_PROFILE)));
+ if (NULL == pp_mgr) {
+ UPLL_LOG_DEBUG("pp_mgr is NULL");
+ DELETE_IF_NOT_NULL(pp_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t pp_rename = 0;
+ result_code = pp_mgr->IsRenamed(pp_ckv, req->datatype, dmi, pp_rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ return result_code;
+ }
+ if (pp_rename & 0x01) {
+ rename |= POLICINGPROFILE_RENAME; // TODO Check for correct flag value
+ } else {
+ rename &= NO_POLICINGPROFILE_RENAME;
+ }
+ DELETE_IF_NOT_NULL(pp_ckv);
+ } else if (UNC_VF_VALID_NO_VALUE == val_pm->valid
+ [UPLL_IDX_POLICERNAME_PM]) {
+ rename &= NO_POLICINGPROFILE_RENAME; // TODO Check for correct flag value. No rename flowlist value should be set
+ }
+ SET_USER_DATA_FLAGS(ikey, rename);
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VbrPolicingMapMoMgr::GetPolicingProfileConfigKey(
+ const char *pp_name, ConfigKeyVal *&okey,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_POLICING_PROFILE)));
+ result_code = mgr->GetChildConfigKey(okey, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
+ return result_code;
+ }
+ key_policingprofile_t *okey_key = reinterpret_cast<key_policingprofile_t *>
+ (okey->get_key());
+ uuu::upll_strncpy(okey_key->policingprofile_name,
+ pp_name,
+ (kMaxLenPolicingProfileName+1));
+ return UPLL_RC_SUCCESS;
+}
} // kt_momgr
} // upll
} // unc
VBRPOLICINGMAPTBL = 0, NVBRPOLICINGMAPTABLES
};
-#define CONFIGKEYVALCLEAN(ikey) { \
- if (ikey) { \
- delete ikey; \
- ikey = NULL; \
- } \
-}
/* This file declares interfaces for keyType KT_VBR_POLICINGMAP */
/**
* @Brief VbrPolicingMapMoMgr class handles all the request
static BindInfo vbr_policingmap_bind_info[];
static BindInfo key_vbrpm_maintbl_rename_bind_info[];
static BindInfo key_vbrpm_policyname_maintbl_rename_bind_info[];
-
+ uint32_t cur_instance_count;
public:
/**
* @Brief PolicingProfileMoMgr Class Constructor.
* @retval UPLL_RC_SUCCESS Successfull completion.
* */
upll_rc_t GetControllerId(ConfigKeyVal *ikey, ConfigKeyVal *&okey,
- DalDmlIntf *dmi);
+ upll_keytype_datatype_t dt_type, DalDmlIntf *dmi);
/**
* @Brief This API is used to read the configuration and statistics
upll_rc_t GetParentConfigKey(ConfigKeyVal *&okey,
ConfigKeyVal *ikey);
+ /**
+ * @brief Method used for Restoring PolicingProfile in the Controller Table
+ *
+ * @param[in] ikey Pointer to ConfigKeyVal Class
+ * @param[in] dt_type Describes Configiration Information.
+ * @param[in] tbl Describe the destination table
+ * @param[in] dmi Pointer to DalDmlIntf Class.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_DB_ACCESS DB Read/Write error.
+ * @retval UPLL_RC_ERR_INSTANCE_EXISTS Record already exists
+ * @retval UPLL_RC_ERR_GENERIC Returned Generic Error.
+ */
+
+ upll_rc_t RestorePOMInCtrlTbl(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl,
+ DalDmlIntf* dmi);
+
upll_rc_t ConstructReadDetailResponse(ConfigKeyVal *ikey,
ConfigKeyVal *drv_resp_ckv,
upll_keytype_datatype_t dt_type,
const pfcdrv_policier_alarm_data_t &alarm_data,
bool &alarm_raised,
DalDmlIntf *dmi);
+
+ upll_rc_t CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id);
+
+ upll_rc_t DeleteChildrenPOM(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi);
+
+ upll_rc_t IsPolicingProfileConfigured(const char* policingprofile_name,
+ DalDmlIntf *dmi);
+
+ upll_rc_t SetValidAudit(ConfigKeyVal *&ikey);
+
+ bool FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op);
+
+ upll_rc_t UpdateVnodeVal(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t data_type,
+ bool &no_rename);
+
+ upll_rc_t IsRenamed(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi,
+ uint8_t &rename);
+
+ upll_rc_t GetPolicingProfileConfigKey(
+ const char *pp_name, ConfigKeyVal *&okey,
+ DalDmlIntf *dmi);
+
+ upll_rc_t SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req);
};
} // kt_momgr
} // upll
#include "vlanmap_momgr.hh"
#include <ctype.h>
#define NUM_KEY_MAIN_TBL_ 5
+#define INVALID_LOG_PORT_ID_VALID 0xFF
namespace unc {
namespace upll {
namespace kt_momgr {
+uint16_t VlanMapMoMgr::kVbrVlanMapNumChildKey = 2;
BindInfo VlanMapMoMgr::vlan_map_bind_info[] = {
{ uudst::vbridge_vlanmap::kDbiVtnName, CFG_KEY, offsetof(
BindInfo VlanMapMoMgr::vlan_map_maintbl_update_key_bind_info[] = {
{ uudst::vbridge_vlanmap::kDbiVtnName, CFG_MATCH_KEY, offsetof(
key_vlan_map, vbr_key.vtn_key.vtn_name),
- uud::kDalChar, kMaxLenVtnName },
+ uud::kDalChar, (kMaxLenVtnName+1) },
{ uudst::vbridge_vlanmap::kDbiVbrName, CFG_MATCH_KEY, offsetof(
key_vlan_map, vbr_key.vbridge_name),
- uud::kDalChar, kMaxLenVnodeName },
+ uud::kDalChar, (kMaxLenVnodeName+1) },
{ uudst::vbridge_vlanmap::kDbiVtnName, CFG_INPUT_KEY, offsetof(
key_rename_vnode_info_t, new_unc_vtn_name),
- uud::kDalChar, kMaxLenVtnName },
+ uud::kDalChar, (kMaxLenVtnName+1) },
{ uudst::vbridge_vlanmap::kDbiVbrName, CFG_INPUT_KEY, offsetof(
key_rename_vnode_info_t, new_unc_vnode_name),
- uud::kDalChar, kMaxLenVnodeName },
+ uud::kDalChar, (kMaxLenVnodeName+1) },
{ uudst::vbridge_vlanmap::kDbiVbrVlanMapFlags, CK_VAL, offsetof(
key_user_data_t, flags),
uud::kDalUint8, 1 },
uint64_t index) {
key_vlan_map *vlanmap_key = reinterpret_cast<key_vlan_map *>(key);
UPLL_FUNC_TRACE;
- bool ret_val = UPLL_RC_SUCCESS;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
switch (index) {
case uudst::vbridge_vlanmap::kDbiVtnName:
ret_val = ValidateKey(reinterpret_cast<char *>
(vlanmap_key->vbr_key.vtn_key.vtn_name),
kMinLenVtnName, kMaxLenVtnName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_trace(
+ UPLL_LOG_TRACE(
"syntax check failure for key_vlan_map->vbr_key.vtn_key.vtn_name");
return false;
}
(vlanmap_key->vbr_key.vbridge_name),
kMinLenVnodeName, kMaxLenVnodeName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_trace("VBR Name is not valid(%d)", ret_val);
+ UPLL_LOG_TRACE("VBR Name is not valid(%d)", ret_val);
return false;
}
break;
case uudst::vbridge_vlanmap::kDbiLogicalPortId:
- ret_val = ValidateLogicalPortId(reinterpret_cast<char *>
+ if (!ValidateLogicalPortId(reinterpret_cast<char *>
(vlanmap_key->logical_port_id),
- kMinLenLogicalPortId, kMaxLenLogicalPortId);
- if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_trace("Switch ID is not valid(%d)", ret_val);
+ kMinLenLogicalPortId, kMaxLenLogicalPortId)) {
+ UPLL_LOG_TRACE("Switch ID is not valid");
return false;
}
break;
case uudst::vbridge_vlanmap::kDbiLogicalPortIdValid:
if (!ValidateNumericRange(vlanmap_key->logical_port_id_valid, PFC_FALSE,
PFC_TRUE, true, true)) {
- pfc_log_trace("LogicalPortId validis not valid(%d)", ret_val);
+ UPLL_LOG_TRACE("LogicalPortId validis not valid");
return false;
}
break;
default:
- pfc_log_trace("Invalid Key Index");
+ UPLL_LOG_TRACE("Invalid Key Index");
break;
}
return true;
void *pkey;
if (parent_key == NULL) {
vlanmap_key = reinterpret_cast<key_vlan_map_t *>
- (malloc(sizeof(key_vlan_map_t)));
- memset(vlanmap_key, 0, sizeof(key_vlan_map_t));
+ (ConfigKeyVal::Malloc(sizeof(key_vlan_map_t)));
+ vlanmap_key->logical_port_id_valid = INVALID_LOG_PORT_ID_VALID;
+ if (okey) delete okey;
okey = new ConfigKeyVal(UNC_KT_VBR_VLANMAP, IpctSt::kIpcStKeyVlanMap,
vlanmap_key, NULL);
return UPLL_RC_SUCCESS;
}
if (!pkey) return UPLL_RC_ERR_GENERIC;
if (okey) {
- if (okey->get_key_type() != UNC_KT_VBR_VLANMAP) return UPLL_RC_ERR_GENERIC;
+ if (okey->get_key_type() != UNC_KT_VBR_VLANMAP)
+ return UPLL_RC_ERR_GENERIC;
vlanmap_key = reinterpret_cast<key_vlan_map_t *>(okey->get_key());
} else {
vlanmap_key = reinterpret_cast<key_vlan_map_t *>
- (malloc(sizeof(key_vlan_map_t)));
- memset(vlanmap_key, 0, sizeof(key_vlan_map_t));
+ (ConfigKeyVal::Malloc(sizeof(key_vlan_map_t)));
+ vlanmap_key->logical_port_id_valid = INVALID_LOG_PORT_ID_VALID;
}
unc_key_type_t keytype = parent_key->get_key_type();
switch (keytype) {
if (!okey)
okey = new ConfigKeyVal(UNC_KT_VBR_VLANMAP, IpctSt::kIpcStKeyVlanMap,
vlanmap_key, NULL);
+ else if (okey->get_key() != vlanmap_key)
+ okey->SetKey(IpctSt::kIpcStKeyVlanMap, vlanmap_key);
+
if (okey == NULL) {
free(vlanmap_key);
result_code = UPLL_RC_ERR_GENERIC;
if (ikey_type != UNC_KT_VBR_VLANMAP) return UPLL_RC_ERR_GENERIC;
key_vlan_map_t *pkey = reinterpret_cast<key_vlan_map_t *>(ikey->get_key());
if (!pkey) return UPLL_RC_ERR_GENERIC;
- key_vbr *vbr_key = reinterpret_cast<key_vbr *>(malloc(sizeof(key_vbr)));
- if (!vbr_key) return UPLL_RC_ERR_GENERIC;
- memset(vbr_key, 0, sizeof(key_vbr));
+ key_vbr *vbr_key = reinterpret_cast<key_vbr *>
+ (ConfigKeyVal::Malloc(sizeof(key_vbr)));
uuu::upll_strncpy(vbr_key->vtn_key.vtn_name,
(reinterpret_cast<key_vlan_map_t *>(pkey))->vbr_key.vtn_key.vtn_name,
kMaxLenVtnName+1);
if (ck_val != NULL) return UPLL_RC_ERR_GENERIC;
switch (tbl) {
case MAINTBL:
- val = reinterpret_cast<void *>(malloc(sizeof(val_vlan_map)));
- memset(val, 0, sizeof(val_vlan_map));
+ val = reinterpret_cast<void *>(
+ ConfigKeyVal::Malloc(sizeof(val_vlan_map)));
ck_val = new ConfigVal(IpctSt::kIpcStValVlanMap, val);
break;
default:
if (tbl == MAINTBL) {
val_vlan_map *ival = reinterpret_cast<val_vlan_map *>(GetVal(req));
if (!ival) {
- UPLL_LOG_DEBUG("Invalid vlanmap\n");
+ UPLL_LOG_DEBUG("Invalid vlanmap");
return UPLL_RC_ERR_GENERIC;
}
val_vlan_map *vlanmap_val = reinterpret_cast<val_vlan_map *>
- (malloc(sizeof(val_vlan_map)));
- if (!vlanmap_val) {
- UPLL_LOG_DEBUG("Invalid vlanmap\n");
- return UPLL_RC_ERR_GENERIC;
- }
+ (ConfigKeyVal::Malloc(sizeof(val_vlan_map)));
memcpy(vlanmap_val, ival, sizeof(val_vlan_map));
tmp1 = new ConfigVal(IpctSt::kIpcStValVlanMap, vlanmap_val);
}
void *tkey = (req != NULL) ? (req)->get_key() : NULL;
key_vlan_map_t *ikey = reinterpret_cast<key_vlan_map_t *>(tkey);
key_vlan_map_t *vlanmap_key = reinterpret_cast<key_vlan_map_t *>
- (malloc(sizeof(key_vlan_map_t)));
- if (!vlanmap_key) {
- delete tmp1;
- return UPLL_RC_ERR_GENERIC;
- }
+ (ConfigKeyVal::Malloc(sizeof(key_vlan_map_t)));
memcpy(vlanmap_key, ikey, sizeof(key_vlan_map_t));
okey = new ConfigKeyVal(UNC_KT_VBR_VLANMAP, IpctSt::kIpcStKeyVlanMap,
vlanmap_key, tmp1);
unc_keytype_configstatus_t cs_status =
(driver_result == UPLL_RC_SUCCESS) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
+ val_vlan_map *vlanmap_val2 = reinterpret_cast<val_vlan_map *>(GetVal(upd_key));
+ UPLL_LOG_TRACE("Key from Candidate %s",(ikey->ToStrAll()).c_str());
if (vlanmap_val == NULL) return UPLL_RC_ERR_GENERIC;
- vlanmap_val->cs_row_status = cs_status;
- if (op == UNC_OP_UPDATE) {
+ if (op == UNC_OP_CREATE) {
+ vlanmap_val->cs_row_status = cs_status;
+ } else if (op == UNC_OP_UPDATE) {
void *val = reinterpret_cast<void *>(vlanmap_val);
CompareValidValue(val, GetVal(upd_key), true);
+ UPLL_LOG_TRACE("Key from Running %s",(upd_key->ToStrAll()).c_str());
+ vlanmap_val->cs_row_status = vlanmap_val2->cs_row_status;
} else if (op != UNC_OP_CREATE) {
return UPLL_RC_ERR_GENERIC;
}
for (unsigned int loop = 0;
- loop < sizeof(vlanmap_val->valid) / sizeof(vlanmap_val->valid[0]); ++loop) {
+ loop < sizeof(vlanmap_val->valid) / sizeof(vlanmap_val->valid[0]);
+ ++loop) {
if ((UNC_VF_VALID == (uint8_t) vlanmap_val->valid[loop])
- || (UNC_VF_VALID_NO_VALUE == (uint8_t) vlanmap_val->valid[loop])) {
- vlanmap_val->cs_attr[loop] = cs_status;
- } else if ((uint8_t) vlanmap_val->valid[loop] == UNC_VF_NOT_SOPPORTED) {
- vlanmap_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
+ || (UNC_VF_VALID_NO_VALUE == (uint8_t) vlanmap_val->valid[loop])) {
+ vlanmap_val->cs_attr[loop] = cs_status;
+ } else if ((UNC_VF_INVALID == vlanmap_val->valid[loop]) &&
+ (UNC_OP_CREATE == op)) {
+ vlanmap_val->cs_attr[loop] = UNC_CS_APPLIED;
+ } else if ((UNC_VF_INVALID == vlanmap_val->valid[loop]) &&
+ (UNC_OP_UPDATE == op)) {
+ vlanmap_val->cs_attr[loop] = vlanmap_val2->cs_attr[loop];
}
}
return UPLL_RC_SUCCESS;
return UPLL_RC_ERR_GENERIC;
}
if (uuc::kUpllUcpCreate == phase) val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
for (unsigned int loop = 0; loop < sizeof(val->valid) / sizeof(uint8_t);
++loop) {
if ((cs_status == UNC_CS_INVALID &&
key_rename_vnode_info *key_rename =
reinterpret_cast<key_rename_vnode_info *>(ikey->get_key());
key_vlan_map_t* key_vlan_map = reinterpret_cast<key_vlan_map_t *>
- (malloc(sizeof(key_vlan_map_t)));
- if (!key_vlan_map) return UPLL_RC_ERR_GENERIC;
- memset(key_vlan_map, 0, sizeof(key_vlan_map_t));
+ (ConfigKeyVal::Malloc(sizeof(key_vlan_map_t)));
+ key_vlan_map->logical_port_id_valid = INVALID_LOG_PORT_ID_VALID;
if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vtn_name))) {
free(key_vlan_map);
return UPLL_RC_ERR_GENERIC;
}
uuu::upll_strncpy(key_vlan_map->vbr_key.vbridge_name,
key_rename->old_unc_vnode_name, kMaxLenVnodeName+1);
+ } else {
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_unc_vnode_name))) {
+ free(key_vlan_map);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(key_vlan_map->vbr_key.vbridge_name,
+ key_rename->new_unc_vnode_name, (kMaxLenVnodeName + 1));
}
+
okey = new ConfigKeyVal(UNC_KT_VBR_VLANMAP, IpctSt::kIpcStKeyVlanMap,
key_vlan_map, NULL);
if (dt_type == UPLL_DT_CANDIDATE || UPLL_DT_IMPORT == dt_type) {
ConfigVal *cfg_val = ikey->get_cfg_val();
if (!cfg_val) {
- UPLL_LOG_DEBUG("Value structure mandatory\n");
- return UPLL_RC_ERR_CFG_SYNTAX;
+ UPLL_LOG_DEBUG("Value structure mandatory");
+ return UPLL_RC_ERR_BAD_REQUEST;
}
if (cfg_val->get_st_num() != IpctSt::kIpcStValVlanMap) {
UPLL_LOG_DEBUG("Invalid Value structure received. received struct - %d",
return UPLL_RC_SUCCESS;
} else {
UPLL_LOG_DEBUG("Unsupported data type - (%d)", dt_type);
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
} else if (op == UNC_OP_READ || op == UNC_OP_READ_SIBLING
|| op == UNC_OP_READ_SIBLING_BEGIN || op == UNC_OP_READ_SIBLING_COUNT) {
return UPLL_RC_SUCCESS;
} else {
UPLL_LOG_DEBUG("Unsupported data type - (%d)", dt_type);
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
} else if (op == UNC_OP_READ_NEXT || op == UNC_OP_READ_BULK) {
if (dt_type == UPLL_DT_CANDIDATE || dt_type == UPLL_DT_RUNNING
return UPLL_RC_SUCCESS;
} else {
UPLL_LOG_DEBUG("Unsupported data type - (%d)", dt_type);
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
} else if (op == UNC_OP_DELETE) {
if(dt_type == UPLL_DT_CANDIDATE) {
- pfc_log_debug("Value structure is none for operation type:%d", op);
+ UPLL_LOG_DEBUG("Value structure is none for operation type:%d", op);
return UPLL_RC_SUCCESS;
} else {
- pfc_log_debug("Unsupported data type - (%d)", dt_type);
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ UPLL_LOG_DEBUG("Unsupported data type - (%d)", dt_type);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
}
UPLL_LOG_DEBUG("Unsupported operation - (%d)", op);
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
upll_rc_t VlanMapMoMgr::ValidateVlanmapValue(val_vlan_map *vlanmap_val,
}
if ((operation != UNC_OP_READ_SIBLING_BEGIN) &&
(operation != UNC_OP_READ_SIBLING_COUNT)) {
- if (vlan_map_key->logical_port_id_valid == PFC_TRUE)
- ret_val = ValidateLogicalPortId(
+ if (vlan_map_key->logical_port_id_valid == PFC_TRUE) {
+ if (!ValidateLogicalPortId(
reinterpret_cast<char *>(vlan_map_key->logical_port_id),
- kMinLenLogicalPortId, kMaxLenLogicalPortId);
+ kMinLenLogicalPortId, kMaxLenLogicalPortId)) {
+ ret_val = UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ }
else
ret_val = UPLL_RC_SUCCESS;
if (ret_val != UPLL_RC_SUCCESS) {
ConfigKeyVal *ikey,
const char *ctrlr_name) {
UPLL_FUNC_TRACE;
- upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ upll_rc_t ret_val = UPLL_RC_ERR_GENERIC;
if (!req || !ikey ) {
UPLL_LOG_DEBUG("ConfigKeyVal / IpcReqRespHeader is Null");
return UPLL_RC_ERR_GENERIC;
}
- if (!ctrlr_name) ctrlr_name = reinterpret_cast<char *>
- (ikey->get_user_data());
- upll_keytype_datatype_t dt_type = req->datatype;
- unc_keytype_operation_t op = req->operation;
- unc_keytype_option1_t opt1 = req->option1;
- unc_keytype_option2_t opt2 = req->option2;
- if (op == UNC_OP_CREATE) { // C, I
- if (dt_type == UPLL_DT_CANDIDATE) {
- ret_val = ValVlanmapAttributeSupportCheck(ctrlr_name, ikey, op);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("In VLAN_MAP Capa check failure for create operation");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Unsupported data type - (%d)", dt_type);
- return UPLL_RC_ERR_GENERIC;
- }
- } else if (op == UNC_OP_UPDATE) {
- if (dt_type == UPLL_DT_CANDIDATE) {
- ret_val = ValVlanmapAttributeSupportCheck(ctrlr_name, ikey, op);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("In VLAN_MAP Capa check failure for Update operation");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Unsupported data type - (%d)", dt_type);
+
+ if (!ctrlr_name) {
+ ctrlr_name = reinterpret_cast<char*>((reinterpret_cast<key_user_data_t *>
+ (ikey->get_user_data()))->ctrlr_id);
+ if (!ctrlr_name || !strlen(ctrlr_name)) {
+ UPLL_LOG_DEBUG("Controller Name is NULL");
return UPLL_RC_ERR_GENERIC;
}
- } else if (op == UNC_OP_READ || op == UNC_OP_READ_SIBLING
- || op == UNC_OP_READ_SIBLING_BEGIN || op == UNC_OP_READ_SIBLING_COUNT) {
- if (dt_type == UPLL_DT_CANDIDATE || dt_type == UPLL_DT_RUNNING
- || dt_type == UPLL_DT_STARTUP || dt_type == UPLL_DT_STATE) {
- if (opt1 != UNC_OPT1_NORMAL) {
- UPLL_LOG_DEBUG("Error option1 is not NORMAL");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- if (opt2 != UNC_OPT2_NONE) {
- UPLL_LOG_DEBUG("Error option2 is not NONE");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- if (ikey->get_cfg_val()->get_val() != NULL) {
- ret_val = ValVlanmapAttributeSupportCheck(ctrlr_name, ikey, op);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("In VLAN_MAP capa check failure for read operation");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("val_vlan_map struct is an optional");
- return UPLL_RC_SUCCESS;
- }
- } else {
- UPLL_LOG_DEBUG("Unsupported data type - (%d)", dt_type);
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
- }
}
- UPLL_LOG_DEBUG("Unsupported operation - (%d)", op);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
-}
-upll_rc_t VlanMapMoMgr::ValVlanmapAttributeSupportCheck(const char *ctrlr_name,
- ConfigKeyVal *ikey,
- uint32_t operation) {
- UPLL_FUNC_TRACE;
- bool result_code = 1;
+ bool result_code = false;
uint32_t max_attrs = 0;
uint32_t max_instance_count = 0;
const uint8_t *attrs;
- switch (operation) {
+ switch (req->operation) {
case UNC_OP_CREATE:
result_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
&max_instance_count, &max_attrs,
&attrs);
- if (result_code && cur_instance_count >= max_instance_count) {
+ UPLL_LOG_TRACE("The Current Instance is %d", cur_instance_count);
+ UPLL_LOG_TRACE("The Max Instance is %d", max_instance_count);
+
+ if (result_code && (max_instance_count != 0) &&
+ (cur_instance_count >= max_instance_count)) {
UPLL_LOG_DEBUG("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
__LINE__, __FUNCTION__, cur_instance_count,
max_instance_count);
&max_attrs, &attrs);
break;
default:
- UPLL_LOG_DEBUG("INVALID OPERATION CODE - (%d)", operation);
+ UPLL_LOG_DEBUG("INVALID OPERATION CODE - (%d)", req->operation);
return UPLL_RC_ERR_GENERIC;
}
if (!result_code) {
UPLL_LOG_DEBUG("key_type - %d is not supported by controller - %s",
ikey->get_key_type(), ctrlr_name);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
- }
- ConfigVal *cfg_val = (ikey->get_cfg_val());
- if (!cfg_val) return UPLL_RC_ERR_GENERIC;
- if (cfg_val->get_st_num() != IpctSt::kIpcStValVlanMap) {
- UPLL_LOG_DEBUG("Invalid Value structure received. received struct - %d",
- (cfg_val->get_st_num()));
- return UPLL_RC_ERR_BAD_REQUEST;
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
- val_vlan_map *vlanmap_val = reinterpret_cast<val_vlan_map *>
+ val_vlan_map *vlanmap_val = NULL;
+ if ((ikey->get_cfg_val()) && (ikey->get_cfg_val()->get_st_num() ==
+ IpctSt::kIpcStValVlanMap)) {
+ vlanmap_val = reinterpret_cast<val_vlan_map *>
(ikey->get_cfg_val()->get_val());
+ }
+ if (vlanmap_val) {
+ if (max_attrs > 0) {
+ ret_val = ValVlanmapAttributeSupportCheck(vlanmap_val, attrs, req->operation);
+ return ret_val;
+ } else {
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d", req->operation);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VlanMapMoMgr::ValVlanmapAttributeSupportCheck(val_vlan_map *vlanmap_val,
+ const uint8_t *attrs,
+ unc_keytype_operation_t operation) {
+ UPLL_FUNC_TRACE;
if (vlanmap_val != NULL) {
if ((vlanmap_val->valid[UPLL_IDX_VLAN_ID_VM] == UNC_VF_VALID)
|| (vlanmap_val->valid[UPLL_IDX_VLAN_ID_VM] == UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vlan_map::kCapVlanId] == 0) {
- vlanmap_val->valid[UPLL_IDX_VLAN_ID_VM] = UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_DEBUG("vlan_id attr is not supported by pfc ctrlr ");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ vlanmap_val->valid[UPLL_IDX_VLAN_ID_VM] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("vlan_id attr is not supported by pfc ctrlr ");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
}
}
- return UPLL_RC_SUCCESS;
} else {
UPLL_LOG_DEBUG("Error val_vlan_map struct is NULL");
+ return UPLL_RC_ERR_GENERIC;
}
- return UPLL_RC_ERR_GENERIC;
+ return UPLL_RC_SUCCESS;
}
bool VlanMapMoMgr::FilterAttributes(void *&val1,
if (val_vlan_map1->valid[UPLL_IDX_VLAN_ID_VM] == UNC_VF_VALID
&& val_vlan_map2->valid[UPLL_IDX_VLAN_ID_VM] == UNC_VF_VALID) {
if (val_vlan_map1->vlan_id == val_vlan_map2->vlan_id)
- val_vlan_map1->valid[UPLL_IDX_VLAN_ID_VM] = UNC_VF_INVALID;
+ val_vlan_map1->valid[UPLL_IDX_VLAN_ID_VM] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
for (unsigned int loop = 0;
loop < sizeof(val_vlan_map1->valid) / sizeof(val_vlan_map1->valid[0]);
return UPLL_RC_SUCCESS;
}
-upll_rc_t VlanMapMoMgr::IsLogicalPortAndVlanIdInUse(ConfigKeyVal *ckv,
- DalDmlIntf *dmi,
- IpcReqRespHeader *req) {
+upll_rc_t VlanMapMoMgr::IsLogicalPortAndVlanIdInUse(ConfigKeyVal *ckv,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
UPLL_FUNC_TRACE;
- ConfigKeyVal *ckv_vlanmap = NULL;
+ if (!ckv || !(ckv->get_cfg_val()) || !(ckv->get_key()))
+ return UPLL_RC_ERR_GENERIC;
+
upll_rc_t result_code = UPLL_RC_SUCCESS;
- upll_keytype_datatype_t dt_type = req->datatype;
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
-
- result_code = GetChildConfigKey(ckv_vlanmap, NULL);
- val_vlan_map *vlanmap_val = static_cast<val_vlan_map*>
- (malloc(sizeof(val_vlan_map)));
- if (!vlanmap_val) {
- UPLL_LOG_DEBUG("Memory allocation failed");
+
+ val_vlan_map_t* vlanmapval = reinterpret_cast<val_vlan_map_t*>(GetVal(ckv));
+ key_vlan_map_t* vlanmapkey =
+ reinterpret_cast<key_vlan_map_t *>(ckv->get_key());
+
+ if (vlanmapval->valid[UPLL_IDX_VLAN_ID_VM] == UNC_VF_VALID) {
+
+ key_vlan_map_t* key_vlan_map = reinterpret_cast<key_vlan_map_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vlan_map_t)));
+ val_vlan_map_t* val_vlan_map = static_cast<val_vlan_map_t*>
+ (ConfigKeyVal::Malloc(sizeof(val_vlan_map_t)));
+ if (vlanmapkey->logical_port_id_valid) {
+ uuu::upll_strncpy(key_vlan_map->logical_port_id,
+ vlanmapkey->logical_port_id,
+ kMaxLenLogicalPortId+1);
+ key_vlan_map->logical_port_id_valid = vlanmapkey->logical_port_id_valid;
+ }
+
+ //Populating key and val of vlanmap
+ val_vlan_map->vlan_id = vlanmapval->vlan_id;
+ val_vlan_map->valid[UPLL_IDX_VLAN_ID_VM] = UNC_VF_VALID;
+
+ ConfigKeyVal *ckv_vlanmap = new ConfigKeyVal(UNC_KT_VBR_VLANMAP,
+ IpctSt::kIpcStKeyVlanMap, key_vlan_map, NULL);
+ ckv_vlanmap->AppendCfgVal(IpctSt::kIpcStValVlanMap, val_vlan_map);
+ //Setting Ctrlr/Domain Id to vlanmap
+ SET_USER_DATA(ckv_vlanmap, ckv);
+
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchCtrlr | kOpMatchDomain,
+ kOpInOutFlag};
+ //Read the Configuration from the MainTable
+ result_code = ReadConfigDB(ckv_vlanmap, UPLL_DT_CANDIDATE, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ //Check LogicalPortId and VlanId in use
+ if (result_code == UPLL_RC_SUCCESS) {
+ ConfigKeyVal *tmp = ckv_vlanmap;
+ key_vlan_map_t* tmp_vlanmapkey =
+ reinterpret_cast<key_vlan_map_t *>(tmp->get_key());
+ while (tmp) {
+ if (!memcmp((const void*)&(vlanmapkey->vbr_key),
+ (const void*) &(tmp_vlanmapkey->vbr_key),
+ sizeof(key_vbr_t))) {
+ UPLL_LOG_TRACE("Looking on the Same key");
+ } else {
+ UPLL_LOG_DEBUG("More than one vlanmap is configured with the"
+ " same logical port id and vlanid!");
+ DELETE_IF_NOT_NULL(ckv_vlanmap);
+ tmp = NULL;
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ tmp = tmp->get_next_cfg_key_val();
+ }
+ } else if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ result_code = UPLL_RC_SUCCESS;
+ }
+ DELETE_IF_NOT_NULL(ckv_vlanmap);
+ }
+ return result_code;
+}
+
+// Overridden Read Sibling from momgr_impl.
+// This keytype contains 2 child keys and needs special handling.
+upll_rc_t VlanMapMoMgr::ReadSiblingMo(IpcReqRespHeader *header,
+ ConfigKeyVal *ikey,
+ bool begin,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+ uint32_t result_count = 0;
+
+ if (begin == true) {
+ return (MoMgrImpl::ReadSiblingMo(header, ikey, begin, dmi));
+
+ }
+ // Fix it: This function is for READ_SIBLING
+ if ((header->operation != UNC_OP_READ_SIBLING_BEGIN) &&
+ (header->operation != UNC_OP_READ_SIBLING)) {
+ UPLL_LOG_DEBUG("Operation type is not Sibling begin/Sibling");
return UPLL_RC_ERR_GENERIC;
}
- memset(vlanmap_val, 0, sizeof(val_vlan_map));
- key_vlan_map *vlanmapkey = reinterpret_cast<key_vlan_map*>(ckv->get_key());
- if ((!strlen(reinterpret_cast<const char *>
- (vlanmapkey->vbr_key.vtn_key.vtn_name)))) {
- free(vlanmap_val);
+ if (ikey == NULL || dmi == NULL) {
+ UPLL_LOG_INFO("Null param ikey/dmi");
return UPLL_RC_ERR_GENERIC;
}
+ result_code = ValidateMessage(header, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ValidateMessage failed result_code %d",
+ result_code);
+ return result_code;
+ }
- uuu::upll_strncpy(reinterpret_cast<key_vlan_map*>
- (ckv_vlanmap->get_key())->vbr_key.vtn_key.vtn_name,
- vlanmapkey->vbr_key.vtn_key.vtn_name,
- kMaxLenVtnName+1);
- val_vlan_map *vlanmapval = reinterpret_cast<val_vlan_map*>(GetVal(ckv));
+ MoMgrTables tbl = MAINTBL;
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone,
+ kOpInOutCtrlr | kOpInOutDomain | kOpInOutFlag};
- if (!(vlanmapkey->logical_port_id_valid) &&
- vlanmapval->valid[UPLL_IDX_VLAN_ID_VM] != UNC_VF_VALID) {
- UPLL_LOG_DEBUG("Semantic check not required!");
- return UPLL_RC_SUCCESS;
- }
+ switch (header->datatype) {
+ case UPLL_DT_IMPORT:
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ case UPLL_DT_CANDIDATE:
+ case UPLL_DT_RUNNING:
+ case UPLL_DT_STARTUP:
+ case UPLL_DT_STATE:
+ {
+ // To read the record(s) from DB
+ upll_keytype_datatype_t dt_type = (header->datatype == UPLL_DT_STATE) ?
+ UPLL_DT_RUNNING : header->datatype;
- char *port_id = NULL;
- port_id = reinterpret_cast<char *>(vlanmapkey->logical_port_id);
- uuu::upll_strncpy(reinterpret_cast<key_vlan_map*>
- (ckv_vlanmap->get_key())->logical_port_id,
- port_id, kMaxLenLogicalPortId+1);
+ ConfigKeyVal *result_ckv = NULL;
+ // Used in ReadConfigDB in each Iteration
+ ConfigKeyVal *queryckval = NULL;
+ result_code = DupConfigKeyVal(queryckval, ikey, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS || queryckval == NULL) {
+ UPLL_LOG_INFO("Error while DupConfigKeyVal");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ for (uint16_t childKeyIndex = uuds::TableNumPkCols(
+ uudst::kDbiVbrVlanMapTbl) - 1;
+ childKeyIndex >= uuds::TableNumPkCols(
+ uudst::kDbiVbrVlanMapTbl) - kVbrVlanMapNumChildKey;
+ childKeyIndex--) {
- key_vlan_map *vlanmap_key = reinterpret_cast<key_vlan_map *>
- (ckv_vlanmap->get_key());
- vlanmap_key->logical_port_id_valid = vlanmapkey->logical_port_id_valid;
- vlanmap_val->vlan_id = vlanmapval->vlan_id;
- vlanmap_val->valid[UPLL_IDX_VLAN_ID_VM] = UNC_VF_VALID;
+ // For skipping invalid inputs - do not delete
+ if (IsValidKey(queryckval->get_key(), childKeyIndex) == false)
+ continue;
- ckv_vlanmap->AppendCfgVal(IpctSt::kIpcStValVlanMap, vlanmap_val);
- if (ckv_vlanmap == NULL) return UPLL_RC_ERR_GENERIC;
- UPLL_LOG_TRACE("\n existence check %s",(ckv_vlanmap->ToStrAll()).c_str());
+ uint32_t tmp_count = (header->rep_count - result_count);
+ result_code = ReadConfigDB(queryckval, dt_type, header->operation,
+ dbop, tmp_count, dmi, tbl);
- result_code = ReadConfigDB(ckv_vlanmap, dt_type, UNC_OP_READ,
- dbop, dmi, MAINTBL);
- delete ckv_vlanmap;
+ if (result_code == UPLL_RC_SUCCESS) {
+ // Collect the data into result_ckv.
+ if (result_ckv == NULL) {
+ result_ckv = queryckval;
+ } else {
+ result_ckv->AppendCfgKeyVal(queryckval); // TODO perf
+ }
+ result_count += queryckval->size();
+ queryckval = NULL;
+
+ if (result_count >= header->rep_count) {
+ break; // break the for loop
+ }
+
+ // Used in ReadConfigDB in each Iteration
+ result_code = DupConfigKeyVal(queryckval, ikey, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS || queryckval == NULL) {
+ UPLL_LOG_INFO("Error while DupConfigKeyVal");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ } else if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ // use queryckval in the next iteration;
+ } else {
+ UPLL_LOG_INFO("Error while ReadConfigDB");
+ delete queryckval;
+ return result_code;
+ }
- UPLL_LOG_DEBUG("ReadConfigDB returns %d", result_code);
- if (UPLL_RC_SUCCESS == result_code) {
- UPLL_LOG_DEBUG("More than one vbridge configured with the same"
- " logical port id and vlanid!");
- return UPLL_RC_ERR_CFG_SEMANTIC;
+ // Preparing Child Key data for next Sibling Iteration
+ if (ResetDataForSibling(
+ reinterpret_cast<key_vlan_map *>(queryckval->get_key()),
+ (uudst::vbridge_vlanmap::kVbrVlanMapIndex)childKeyIndex)
+ == false) {
+ UPLL_LOG_DEBUG("Data Not Reset for the index(%d)", childKeyIndex);
+ delete queryckval;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_TRACE("Next Query After Reset: %s",
+ (queryckval->ToStrAll()).c_str());
+ } // for
+ DELETE_IF_NOT_NULL(queryckval);
+ header->rep_count = result_count;
+ if (result_ckv) {
+ ikey->ResetWith(result_ckv);
+ delete result_ckv;
+ }
+ break;
+ } // case
+ default:
+ return UPLL_RC_ERR_GENERIC;
}
- return result_code;
+
+ if (header->rep_count > 0) {
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)
+ ? UPLL_RC_SUCCESS : result_code;
+ if (result_code == UPLL_RC_SUCCESS) {
+ result_code = AdaptValToVtnService(ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("AdaptValToVtnService failed result_code %d",
+ result_code);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ } else {
+ return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ }
+ return UPLL_RC_SUCCESS;
+} // VlanMapMoMgr::ReadSiblingMo
+
+// To reset the data available in index to empty
+// Currently implemented only for child index
+bool VlanMapMoMgr::ResetDataForSibling(key_vlan_map *key_vmap,
+ uudst::vbridge_vlanmap::kVbrVlanMapIndex index) {
+ switch(index) {
+ case uudst::vbridge_vlanmap::kDbiLogicalPortId:
+ memset(key_vmap->logical_port_id, 0, sizeof(key_vmap->logical_port_id));
+ case uudst::vbridge_vlanmap::kDbiLogicalPortIdValid:
+ key_vmap->logical_port_id_valid = INVALID_LOG_PORT_ID_VALID;
+ break;
+ default:
+ UPLL_LOG_DEBUG("Not a child key index");
+ return false;
+ }
+ UPLL_LOG_TRACE("Resetting Data for index(%d)", index);
+ return true;
}
} // namespace kt_momgr
namespace upll {
namespace kt_momgr {
+namespace uuds = unc::upll::dal::schema;
+namespace uudst = unc::upll::dal::schema::table;
class VlanMapMoMgr : public VnodeChildMoMgr {
private:
static BindInfo vlan_map_bind_info[];
static BindInfo vlan_map_maintbl_update_key_bind_info[];
/**
- * @brief Gets the valid array position of the variable in the value
- * structure from the table in the specified configuration
+ * @brief Gets the valid array position of the variable in the value
+ * structure from the table in the specified configuration
*
- * @param[in] val pointer to the value structure
+ * @param[in] val pointer to the value structure
* @param[in] indx database index for the variable
- * @param[out] valid position of the variable in the valid array -
+ * @param[out] valid position of the variable in the valid array -
* NULL if valid does not exist.
* @param[in] dt_type specifies the configuration
- * @param[in] tbl specifies the table containing the given value
+ * @param[in] tbl specifies the table containing the given value
*
**/
upll_rc_t GetValid(void *val,
upll_rc_t UpdateConfigStatus(ConfigKeyVal *req,
unc_keytype_operation_t op,
uint32_t driver_result,
- ConfigKeyVal *upd_key,DalDmlIntf *dmi,
+ ConfigKeyVal *upd_key, DalDmlIntf *dmi,
ConfigKeyVal *ctrlr_key = NULL);
upll_rc_t UpdateAuditConfigStatus(unc_keytype_configstatus_t cs_status,
* associated attributes are supported on the given controller,
* based on the valid flag.
*
- * @param[in] crtlr_name Controller name.
- * @param[in] ikey Corresponding key and value structure.
+ * @param[in] val_vlan_map KT_VBR_VLANMAP Value structure.
+ * @param[in] attrs Pointer to controller attribute.
* @param[in] operation Operation name.
*
* @retval UPLL_RC_SUCCESS validation succeeded.
* @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
* @retval UPLL_RC_ERR_GENERIC Generic failure.
**/
- upll_rc_t ValVlanmapAttributeSupportCheck(const char *ctrlr_name,
- ConfigKeyVal *ikey,
- uint32_t operation);
+ upll_rc_t ValVlanmapAttributeSupportCheck(
+ val_vlan_map *vlanmap_val,
+ const uint8_t *attrs,
+ unc_keytype_operation_t operation);
/**
* @Brief Validates the syntax for KT_VBR_VLANMAP Keytype key structure.
uint32_t op);
/**
- * @brief Perform Semantic Check to check Different vbridges
+ * @brief Perform Semantic Check to check Different vbridges
* contain same switch-id and vlan-id
*
* @param[in] ikey ConfigKeyVal
* @param[out] upll_rc_t UPLL_RC_ERR_CFG_SEMANTIC on error
* UPLL_RC_SUCCESS on success
**/
- upll_rc_t ValidateAttribute(ConfigKeyVal *kval,
+ upll_rc_t ValidateAttribute(ConfigKeyVal *kval,
DalDmlIntf *dmi,
IpcReqRespHeader *req = NULL);
/**
- * @brief Duplicates the input configkeyval including the key and val.
+ * @brief Duplicates the input configkeyval including the key and val.
* based on the tbl specified.
*
* @param[in] okey Output Configkeyval - allocated within the function
ConfigKeyVal *&req,
MoMgrTables tbl = MAINTBL);
/**
- * @brief Allocates for the specified val in the given configuration in the * specified table.
+ * @brief Allocates for the specified val in the given configuration in the * specified table.
*
- * @param[in] ck_val Reference pointer to configval structure allocated. * @param[in] dt_type specifies the configuration candidate/running/state
- * @param[in] tbl specifies if the corresponding table is the main
+ * @param[in] ck_val Reference pointer to configval structure allocated. * @param[in] dt_type specifies the configuration candidate/running/state
+ * @param[in] tbl specifies if the corresponding table is the main
* table / controller table or rename table.
*
* @retval UPLL_RC_SUCCESS Successfull completion.
/**
* @brief Method to get a configkeyval of a specified keytype from an input configkeyval
*
- * @param[in/out] okey pointer to output ConfigKeyVal
+ * @param[in/out] okey pointer to output ConfigKeyVal
* @param[in] parent_key pointer to the configkeyval from which the output configkey val is initialized.
*
* @retval UPLL_RC_SUCCESS Successfull completion.
upll_rc_t GetChildConfigKey(ConfigKeyVal *&okey,
ConfigKeyVal *parent_key);
/**
- * @brief Method to get a configkeyval of the parent keytype
+ * @brief Method to get a configkeyval of the parent keytype
*
- * @param[in/out] okey pointer to parent ConfigKeyVal
- * @param[in] ikey pointer to the child configkeyval from
+ * @param[in/out] okey pointer to parent ConfigKeyVal
+ * @param[in] ikey pointer to the child configkeyval from
* which the parent configkey val is obtained.
*
* @retval UPLL_RC_SUCCESS Successfull completion.
/**
* @brief Compares the valid value between two database records.
* if both the values are same, update the valid flag for corresponding
- * attribute as invalid in the first record.
+ * attribute as invalid in the first record.
*
* @param[in/out] val1 first record value instance.
* @param[in] val2 second record value instance.
upll_rc_t IsReferenced(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi);
+ bool ResetDataForSibling(key_vlan_map *key_vmap,
+ uudst::vbridge_vlanmap::kVbrVlanMapIndex index);
+ static uint16_t kVbrVlanMapNumChildKey;
public:
VlanMapMoMgr();
**/
bool IsValidKey(void *tkey,
uint64_t index);
- upll_rc_t IsLogicalPortAndVlanIdInUse(ConfigKeyVal *ckv, DalDmlIntf *dmi, IpcReqRespHeader *req);
-
+ upll_rc_t IsLogicalPortAndVlanIdInUse(ConfigKeyVal *ckv, DalDmlIntf *dmi,
+ IpcReqRespHeader *req);
+
+ /* @brief READ_SIBLING_BEGIN: Gets the first MO from the sibling group
+ * under the parent
+ * specified in the key from the specified UNC database
+ * READ_SIBLING: Gets the next MO from the sibling group
+ * under the parent
+ * specified in the key from the specified UNC database
+ *
+ * @param[in] req Pointer to IpcResResHeader
+ * @param[in/out] key Pointer to the ConfigKeyVal Structure
+ * @param[in] begin boolean variable to decide the sibling operation
+ * @param[in] dal Pointer to the DalDmlIntf(DB Interface)
+ *
+ * @retval UPLL_RC_SUCCESS Completed successfully.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ * @retval UPLL_RC_ERR_RESOURCE_DISCONNECTED Resource disconnected.
+ * @retval UPLL_RC_ERR_DB_ACCESS DB Read/Write error.
+ * @retval UPLL_RC_ERR_NO_SUCH_INSTANCE Given key does not exist
+ *
+ * @Note: Overridden from base class MoMgrImpl
+ **/
+ virtual upll_rc_t ReadSiblingMo(IpcReqRespHeader *req,
+ ConfigKeyVal *key,
+ bool begin,
+ DalDmlIntf *dal);
};
} // namespace kt_momgr
#include "ctrlr_capa_defines.hh"
#include "capa_intf.hh"
#include "upll_validation.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "vtn_momgr.hh"
+#include "vtunnel_if_momgr.hh"
+#include "vtep_if_momgr.hh"
#include "unc/uppl_common.h"
#define NUM_KEY_RENAME_TBL_ 4
uud::kDalChar, 32 },
{ uudst::vlink::kDbiDomain2Id, CK_VAL2, offsetof(key_user_data, domain_id),
uud::kDalChar, 32 },
- { uudst::vlink::kDbiValidAdminStatus, CFG_META_VAL, offsetof(
+ { uudst::vlink::kDbiValidAdminStatus, CFG_DEF_VAL, offsetof(
val_vlink, valid[UPLL_IDX_ADMIN_STATUS_VLNK]),
uud::kDalUint8, 1 },
{ uudst::vlink::kDbiValidVnode1Name, CFG_META_VAL, offsetof(
{ uudst::vlink::kDbiCsVlanid, CS_VAL, offsetof(
val_vlink, cs_attr[UPLL_IDX_VLAN_ID_VLNK]),
uud::kDalUint8, 1 },
- { uudst::vlink::kDbiCsDesc, CFG_META_VAL, offsetof(
+ { uudst::vlink::kDbiCsDesc, CS_VAL, offsetof(
val_vlink, cs_attr[UPLL_IDX_DESCRIPTION_VLNK]),
uud::kDalUint8, 1 },
{ uudst::vlink::kDbiCsRowstatus, CS_VAL, offsetof(val_vlink, cs_row_status),
uud::kDalUint8, 1 },
- { uudst::vlink::kDbiFlags, CK_VAL, offsetof(key_user_data, flags),
- uud::kDalUint8, 1 } };
+ { uudst::vlink::kDbiKeyFlags, CK_VAL, offsetof(key_user_data, flags),
+ uud::kDalUint8, 1 },
+ { uudst::vlink::kDbiValFlags, CK_VAL2, offsetof(key_user_data, flags),
+ uud::kDalUint8, 1 }};
BindInfo VlinkMoMgr::vlink_rename_bind_info[] = {
{ uudst::vnode_rename::kDbiUncVtnName, CFG_KEY, offsetof(key_vlink_t,
{ uudst::vlink::kDbiVlinkName, CFG_INPUT_KEY, offsetof(
key_rename_vnode_info_t, new_unc_vnode_name),
uud::kDalChar, kMaxLenVnodeName + 1 },
- { uudst::vlink::kDbiFlags, CK_VAL, offsetof(key_user_data_t, flags),
+ { uudst::vlink::kDbiKeyFlags, CK_VAL, offsetof(key_user_data_t, flags),
uud::kDalUint8, 1 } };
BindInfo VlinkMoMgr::key_vlink_renametbl_update_bind_info[] = {
table[MAINTBL] = new Table(uudst::kDbiVlinkTbl, UNC_KT_VLINK,
vlink_bind_info, IpctSt::kIpcStKeyVlink,
IpctSt::kIpcStValVlink,
- uudst::vlink::kDbiVlinkNumCols);
+ (uudst::vlink::kDbiVlinkNumCols));
table[RENAMETBL] = new Table(uudst::kDbiVlinkRenameTbl, UNC_KT_VLINK,
vlink_rename_bind_info, IpctSt::kIpcInvalidStNum,
IpctSt::kIpcInvalidStNum,
nchild = 0;
child = NULL;
ck_boundary = NULL;
-// SetMoManager(UNC_KT_VLINK,(MoMgr *)this);
+// SetMoManager(UNC_KT_VLINK, (MoMgr *)this);
+}
+
+upll_rc_t VlinkMoMgr::CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ if (!ikey || !(ikey->get_key()) || !dmi) {
+ UPLL_LOG_DEBUG("Cannot perform create operation");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t *controller_id = reinterpret_cast<uint8_t *>(
+ const_cast<char *>(ctrlr_id));
+
+ /* check if object is renamed in the corresponding Rename Tbl
+ * if "renamed" create the object by the UNC name.
+ * else - create using the controller name.
+ */
+ result_code = GetRenamedUncKey(ikey, UPLL_DT_RUNNING, dmi, controller_id);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey Failed err_code %d", result_code);
+ return result_code;
+ }
+
+ ConfigKeyVal *ckv_rename = NULL;
+ DbSubOp op = {kOpReadSingle, kOpMatchCtrlr, kOpInOutCtrlr | kOpInOutDomain};
+ key_vtn_t *vtn_key = reinterpret_cast<key_vtn_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn)));
+ memcpy(vtn_key, &(reinterpret_cast<key_vlink *>(ikey->get_key())->vtn_key),
+ sizeof(key_vtn_t));
+ ckv_rename = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcStKeyVtn,
+ vtn_key, NULL);
+ SET_USER_DATA_CTRLR(ckv_rename, ctrlr_id);
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>
+ (GetMoManager(UNC_KT_VTN)));
+ result_code = mgr->ReadConfigDB(ckv_rename, UPLL_DT_RUNNING,
+ UNC_OP_READ, op, dmi, RENAMETBL);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_INFO("ReadConfigDB from rename tbl failed err code %d",
+ result_code);
+ delete ckv_rename;
+ return result_code;
+ } else if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ ckv_rename->SetCfgVal(NULL);
+ result_code = mgr->ReadConfigDB(ckv_rename, UPLL_DT_AUDIT,
+ UNC_OP_READ, op, dmi, CTRLRTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("ReadConfigDB from Ctrlr tbl also failed err code %d",
+ result_code);
+ delete ckv_rename;
+ return result_code;
+ }
+ }
+ controller_domain ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ GET_USER_DATA_CTRLR_DOMAIN(ckv_rename, ctrlr_dom);
+ SET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+ SET_USER_DATA_CTRLR_DOMAIN(ikey->get_cfg_val(), ctrlr_dom);
+ DbSubOp dbop = { kOpNotRead, kOpMatchNone, kOpInOutFlag | kOpInOutDomain
+ | kOpInOutCtrlr };
+ result_code = UpdateConfigDB(ikey, UPLL_DT_AUDIT, UNC_OP_CREATE,
+ dmi, &dbop, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Record Creation failed in CANDIDATE DB");
+ }
+ delete ckv_rename;
+ return result_code;
}
upll_rc_t VlinkMoMgr::CreateCandidateMo(IpcReqRespHeader *req,
UPLL_FUNC_TRACE;
if (ikey == NULL || req == NULL || dmi == NULL) {
UPLL_LOG_INFO("Cannot perform create operation"
- "due to insufficient parameters\n");
+ "due to insufficient parameters");
return UPLL_RC_ERR_GENERIC;
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
}
result_code = ValidateAttribute(ikey, dmi, req);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("ValidateAttribute returning %d\n", result_code);
+ UPLL_LOG_INFO("ValidateAttribute returning %d", result_code);
return result_code;
}
// Vnode Existence check in CANDIDATE DB
UNC_KT_VTN)));
result_code = mgr->UpdateConfigDB(parent_ck_vtn, req->datatype, UNC_OP_READ,
dmi, MAINTBL);
- if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE
- || result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
- UPLL_LOG_DEBUG("VTN doesn't exist in CANDIDATE DB");
+
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ DELETE_IF_NOT_NULL(parent_ck_vtn);
return UPLL_RC_ERR_PARENT_DOES_NOT_EXIST;
}
- // vbrIf checks are done and respective Vnodes ContollerIds are filled
- result_code = UpdateVlinkIf(req->datatype, ikey, dmi, ctrlr_dom);
- if (result_code != UPLL_RC_SUCCESS || ctrlr_dom[0].ctrlr == NULL
- || ctrlr_dom[1].ctrlr == NULL) {
- UPLL_LOG_INFO("Error in checking for Vlink Interfaces");
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE &&
+ result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
+ UPLL_LOG_DEBUG("UpdateConfigDB Failed %d", result_code);
+ DELETE_IF_NOT_NULL(parent_ck_vtn);
return result_code;
}
- UPLL_LOG_TRACE(" The Controller Name is %s", ctrlr_dom[0].ctrlr);
- if (UPLL_DT_CANDIDATE == req->datatype) {
- UPLL_LOG_TRACE(" The Controller Name is %s", ctrlr_dom[0].ctrlr);
- result_code = GetInstanceCount(ikey,
- reinterpret_cast<char *>(ctrlr_dom[0].ctrlr),
- req->datatype, &cur_instance_count, dmi,
- MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(" returns error %d", result_code);
- return UPLL_RC_ERR_GENERIC;
- }
- }
-#if 0
- result_code = ValidateCapability(req, ikey,reinterpret_cast<const char *>
- (ctrlr_dom[0].ctrlr));
+ DELETE_IF_NOT_NULL(parent_ck_vtn);
+ // vbrIf checks are done and respective Vnodes ContollerIds are filled
+ result_code = UpdateVlinkIf(req, ikey, dmi, ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ValidateCapability Failed %d", result_code);
+ UPLL_LOG_INFO("Error in checking for Vlink Interfaces. result code %d",
+ result_code);
return result_code;
}
- if (strcmp((const char *)ctrlr_dom[0].ctrlr,
- (const char *)ctrlr_dom[1].ctrlr)) {
- result_code = GetInstanceCount(ikey, reinterpret_cast<char *>
- (ctrlr_dom[1].ctrlr), req->datatype, &cur_instance_count, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_ERROR(" returns error %d", result_code);
- return UPLL_RC_ERR_GENERIC;
+ ConfigKeyVal *temp_key = NULL;
+ bool is_vunk_interface = true;
+ if (UPLL_DT_CANDIDATE == req->datatype ||
+ UPLL_DT_IMPORT == req->datatype) {
+ result_code = GetChildConfigKey(temp_key, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(temp_key);
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed");
+ return result_code;
}
- result_code = ValidateCapability(req, ikey,
- reinterpret_cast<const char *>(ctrlr_dom[1].ctrlr));
+ SET_USER_DATA_CTRLR_DOMAIN(temp_key, ctrlr_dom[0]);
+ if (UNC_KT_VUNK_IF != GetVlinkVnodeIfKeyType(ikey, 0)) {
+ if (ctrlr_dom[0].ctrlr == NULL) {
+ DELETE_IF_NOT_NULL(temp_key);
+ UPLL_LOG_TRACE(" The Node 1 interface controller name is NULL");
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ UPLL_LOG_TRACE(" The Node 1 interface controller name is %s",
+ ctrlr_dom[0].ctrlr);
+ is_vunk_interface = false;
+ result_code = GetInstanceCount(temp_key,
+ reinterpret_cast<char *>(ctrlr_dom[0].ctrlr),
+ req->datatype, &cur_instance_count, dmi,
+ MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(temp_key);
+ UPLL_LOG_DEBUG(" returns error %d", result_code);
+ return result_code;
+ }
+ }
+ }
+ if (UNC_KT_VUNK_IF != GetVlinkVnodeIfKeyType(ikey, 0)) {
+ result_code = ValidateCapability(req, ikey, reinterpret_cast<const char *>
+ (ctrlr_dom[0].ctrlr));
if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(temp_key);
UPLL_LOG_DEBUG("ValidateCapability Failed %d", result_code);
return result_code;
}
-
}
-#endif
+ if (UNC_KT_VUNK_IF != GetVlinkVnodeIfKeyType(ikey, 1)) {
+ if (ctrlr_dom[1].ctrlr == NULL) {
+ DELETE_IF_NOT_NULL(temp_key);
+ UPLL_LOG_TRACE(" The Node 2 interface controller name is NULL");
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ UPLL_LOG_TRACE(" The Node 2 interface controller name is %s",
+ ctrlr_dom[1].ctrlr);
+ UPLL_LOG_TRACE("The tempKey is %s", temp_key->ToStrAll().c_str());
+ if (is_vunk_interface || strncmp((const char *)ctrlr_dom[0].ctrlr,
+ (const char *)ctrlr_dom[1].ctrlr,
+ kMaxLenCtrlrId)) {
+ result_code = GetInstanceCount(temp_key, reinterpret_cast<char *>
+ (ctrlr_dom[1].ctrlr), req->datatype, &cur_instance_count, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(temp_key);
+ UPLL_LOG_ERROR(" returns error %d", result_code);
+ return result_code;
+ }
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(ctrlr_dom[1].ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(temp_key);
+ UPLL_LOG_DEBUG("ValidateCapability Failed %d", result_code);
+ return result_code;
+ }
+ }
+ }
+ DELETE_IF_NOT_NULL(temp_key);
+ SET_USER_DATA_CTRLR_DOMAIN(ikey, *ctrlr_dom);
result_code = RestoreVnode(ikey, req, dmi, ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS)
- UPLL_LOG_DEBUG("Returning %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning %d", result_code);
return result_code;
}
IpcReqRespHeader *req) {
upll_rc_t result_code;
if (!ikey || !ikey->get_cfg_val()) {
- UPLL_LOG_DEBUG("Invalid parameter\n");
+ UPLL_LOG_DEBUG("Invalid parameter");
return UPLL_RC_ERR_GENERIC;
}
val_vlink_t *vlink_val = reinterpret_cast<val_vlink *>(GetVal(ikey));
controller_domain_t *ctrlr_dom) {
UPLL_FUNC_TRACE;
if (ikey == NULL || dmi == NULL) {
- UPLL_LOG_DEBUG("Create error due to insufficient parameters\n");
+ UPLL_LOG_DEBUG("Create error due to insufficient parameters");
return UPLL_RC_ERR_GENERIC;
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
return UPLL_RC_ERR_GENERIC;
}
} else if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- UPLL_LOG_ERROR("Problem in reading RUNNING DB\n");
+ UPLL_LOG_ERROR("Problem in reading RUNNING DB");
return result_code;
}
MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Record Creation fialed in CANDIDATE DB\n");
+ UPLL_LOG_DEBUG("Record Creation fialed in CANDIDATE DB");
return result_code;
}
return result_code;
keytype))));
mgr->GetChildConfigKey(ck_val, NULL);
if (ck_val == NULL) {
- UPLL_LOG_ERROR("Invalid param\n");
+ UPLL_LOG_ERROR("Invalid param");
return UPLL_RC_ERR_GENERIC;
}
switch (keytype) {
const pfc_ipcstdef_t *key_stdef = IpctSt::GetIpcStdef(
ck_val->get_st_num());
if (!key_stdef) {
- UPLL_LOG_DEBUG("Invalid param\n");
+ UPLL_LOG_DEBUG("Invalid param");
return UPLL_RC_ERR_GENERIC;
}
if (sizeof(reinterpret_cast<key_vnode_t *>(key)) != key_stdef->ist_size)
const pfc_ipcstdef_t *key_stdef = IpctSt::GetIpcStdef(
ck_val->get_st_num());
if (!key_stdef) {
- UPLL_LOG_DEBUG("Invalid param\n");
+ UPLL_LOG_DEBUG("Invalid param");
return UPLL_RC_ERR_GENERIC;
}
if (sizeof(reinterpret_cast<key_vbr_if_t *>(key))
break;
}
default:
- UPLL_LOG_TRACE("Invalid Keytype \n");
+ UPLL_LOG_TRACE("Invalid Keytype");
return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
}
DbSubOp dbop1 = { kOpReadSingle, kOpMatchNone, kOpInOutCtrlr | kOpInOutFlag
if (ikey == NULL) return UPLL_RC_ERR_GENERIC;
key_vlink * vlink_key = reinterpret_cast<key_vlink *>
- (malloc(sizeof(key_vlink)));
+ (ConfigKeyVal::Malloc(sizeof(key_vlink)));
uuu::upll_strncpy(vlink_key->vtn_key.vtn_name,
reinterpret_cast<key_vlink *>(ikey->get_key())->vtn_key.vtn_name,
(kMaxLenVtnName+1));
unc_keytype_operation_t op) {
UPLL_FUNC_TRACE;
if (!ckv_if || !mgr) {
- UPLL_LOG_DEBUG("Invalid param\n");
+ UPLL_LOG_DEBUG("Invalid param");
return UPLL_RC_ERR_GENERIC;
}
ConfigKeyVal *okey = NULL;
ConfigKeyVal *dup_ckvif = NULL;
- upll_rc_t result_code = mgr->DupConfigKeyVal(dup_ckvif,ckv_if,MAINTBL);
+ upll_rc_t result_code = mgr->DupConfigKeyVal(dup_ckvif, ckv_if, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("Dupkey failed\n");
+ UPLL_LOG_TRACE("Dupkey failed");
return result_code;
}
DbSubOp dbop = { kOpNotRead, kOpMatchNone, kOpInOutFlag };
void *if_val = GetVal(dup_ckvif);
if (!if_val) {
- UPLL_LOG_DEBUG("Invalid param\n");
+ UPLL_LOG_DEBUG("Invalid param");
if (dup_ckvif) delete dup_ckvif;
return UPLL_RC_ERR_GENERIC;
}
-
+
switch (ckv_if->get_key_type()) {
case UNC_KT_VBR_IF: {
- MoMgrImpl *pom_mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(
+ MoMgrImpl *pom_mgr = reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *>(
GetMoManager(UNC_KT_VBRIF_FLOWFILTER)));
- MoMgrImpl *vbr_mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(
+ MoMgrImpl *vbr_mgr = reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *>(
GetMoManager(UNC_KT_VBR_IF)));
if (!pom_mgr || !vbr_mgr) {
UPLL_LOG_DEBUG("Instance is NULL");
if (dup_ckvif) delete dup_ckvif;
return UPLL_RC_ERR_GENERIC;
}
- result_code = vbr_mgr->GetChildConfigKey (okey, ckv_if);
+ result_code = vbr_mgr->GetChildConfigKey(okey, ckv_if);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetChilConfigKey Failed");
if (dup_ckvif) delete dup_ckvif;
return UPLL_RC_ERR_GENERIC;
}
if (UNC_OP_CREATE == op)
- result_code = pom_mgr->SetVlinkPortmapConfiguration(okey, dt_type, dmi, kVlinkConfigured);
+ result_code = pom_mgr->SetVlinkPortmapConfiguration(okey, dt_type,
+ dmi, kVlinkConfigured, op);
else if (UNC_OP_DELETE == op)
- result_code = pom_mgr->SetVlinkPortmapConfiguration(okey, dt_type, dmi, kVlinkPortMapNotConfigured);
+ result_code = pom_mgr->SetVlinkPortmapConfiguration(okey, dt_type,
+ dmi, kVlinkPortMapNotConfigured, op);
if (okey) delete okey;
- if (UPLL_RC_SUCCESS != result_code &&
+ if (UPLL_RC_SUCCESS != result_code &&
UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
- UPLL_LOG_DEBUG("SetVlinkPortMapConfiguration Failure %d", result_code);
+ UPLL_LOG_DEBUG("SetVlinkPortMapConfiguration Failure %d",
+ result_code);
if (dup_ckvif) delete dup_ckvif;
return result_code;
}
- ResetValid(val_vbr_if, &reinterpret_cast<val_drv_vbr_if *>
- (if_val)->vbr_if_val)
+ ResetValid(val_vbr_if, &(reinterpret_cast<val_drv_vbr_if *>
+ (if_val)->vbr_if_val))
vnif_type = kVbrIf;
break;
}
case UNC_KT_VRT_IF:
{
- MoMgrImpl *pom_mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(
+ MoMgrImpl *pom_mgr = reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *>(
GetMoManager(UNC_KT_VRTIF_FLOWFILTER)));
- MoMgrImpl *vrt_mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(
+ MoMgrImpl *vrt_mgr = reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *>(
GetMoManager(UNC_KT_VRT_IF)));
if (!pom_mgr || !vrt_mgr) {
if (dup_ckvif) delete dup_ckvif;
return UPLL_RC_ERR_GENERIC;
}
- result_code = vrt_mgr->GetChildConfigKey (okey, ckv_if);
+ result_code = vrt_mgr->GetChildConfigKey(okey, ckv_if);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetChilConfigKey Failed");
if (dup_ckvif) delete dup_ckvif;
return UPLL_RC_ERR_GENERIC;
}
- if (UNC_OP_CREATE == op) {
- result_code = pom_mgr->SetVlinkPortmapConfiguration(okey, dt_type, dmi, kVlinkConfigured);
- }
- else if (UNC_OP_DELETE == op) {
- result_code = pom_mgr->SetVlinkPortmapConfiguration(okey, dt_type, dmi, kVlinkPortMapNotConfigured);
+ if (UNC_OP_CREATE == op) {
+ result_code = pom_mgr->SetVlinkPortmapConfiguration(okey,
+ dt_type, dmi, kVlinkConfigured, op);
+ } else if (UNC_OP_DELETE == op) {
+ result_code = pom_mgr->SetVlinkPortmapConfiguration(okey, dt_type,
+ dmi, kVlinkPortMapNotConfigured, op);
}
if (okey) delete okey;
- if (UPLL_RC_SUCCESS != result_code &&
+ if (UPLL_RC_SUCCESS != result_code &&
UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
- UPLL_LOG_DEBUG("SetVlinkPortMapConfiguration Failure %d", result_code);
+ UPLL_LOG_DEBUG("SetVlinkPortMapConfiguration Failure %d",
+ result_code);
if (dup_ckvif) delete dup_ckvif;
return result_code;
}
- ResetValid(val_vrt_if, if_val);
- vnif_type = kVrtIf;
- break;
- }
+ ResetValid(val_vrt_if, if_val);
+ vnif_type = kVrtIf;
+ break;
+ }
case UNC_KT_VTEP_IF:
ResetValid(val_vtep_if, if_val);
vnif_type = kVtepIf;
break;
default:
if (dup_ckvif) delete dup_ckvif;
- UPLL_LOG_DEBUG("Unsupported keytype %d\n", ckv_if->get_key_type());
+ UPLL_LOG_DEBUG("Unsupported keytype %d", ckv_if->get_key_type());
return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_TRACE("Updating the Flag value in Interface Table %d",
ckv_if->get_key_type());
- result_code = mgr->UpdateConfigDB(ckv_if, dt_type,
+ result_code = mgr->UpdateConfigDB(dup_ckvif, dt_type,
UNC_OP_UPDATE, dmi, &dbop, MAINTBL);
if (result_code != UPLL_RC_SUCCESS)
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
if (dup_ckvif) delete dup_ckvif;
return result_code;
}
-upll_rc_t VlinkMoMgr::UpdateVlinkIf(upll_keytype_datatype_t dt_type,
- ConfigKeyVal *ikey,
- DalDmlIntf *dmi,
- controller_domain *ctrlr_dom) {
+upll_rc_t VlinkMoMgr::UpdateVlinkIf(IpcReqRespHeader *req,
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ controller_domain *ctrlr_dom) {
+ UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
bool bound_vlink = false;
unc_key_type_t key_type;
- if (!ikey || (ikey->get_key_type() != UNC_KT_VLINK)) {
- UPLL_LOG_INFO("Invalid ConfigKeyVal parameter\n");
+ if (!req || !ikey || (ikey->get_key_type() != UNC_KT_VLINK)) {
+ UPLL_LOG_INFO("Invalid ConfigKeyVal parameter");
return UPLL_RC_ERR_GENERIC;
}
+ upll_keytype_datatype_t dt_type = req->datatype;
uint8_t valid_boundary =
reinterpret_cast<val_vlink *>(GetVal(ikey))->
valid[UPLL_IDX_BOUNDARY_NAME_VLNK];
uint8_t rename_flag = 0;
+ uint8_t vnode_rename_flag = 0;
VlinkNodePosition vnodeif_number = kVlinkVnode1;
unc_key_type_t if1_type = UNC_KT_ROOT, if2_type = UNC_KT_ROOT;
ConfigKeyVal *ck_if[2] = { NULL, NULL };
if (!ck_drv_vbr_if || (result_code != UPLL_RC_SUCCESS))
return UPLL_RC_ERR_GENERIC;
void *if_key = ck_drv_vbr_if->get_key();
- if (!if_key) return UPLL_RC_ERR_GENERIC;
- result_code = GetVnodeType(if_key, false, key_type, ck_if[i], dmi, dt_type);
+ if (!if_key) {
+ delete ck_drv_vbr_if; // COV RESOURCE LEAK
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = GetVnodeType(if_key, false, key_type, ck_if[i],
+ dmi, dt_type);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Invalid Vlink if\n");
+ UPLL_LOG_DEBUG("Invalid Vlink if");
+ for (int i =0; i <2; i++)
+ DELETE_IF_NOT_NULL(ck_if[i]);
+ delete ck_drv_vbr_if; // COV RESOURCE LEAK
return (result_code);
}
if (vnodeif_number == kVlinkVnode1) if1_type = key_type;
ctrlr_dom[i].ctrlr, ctrlr_dom[i].domain);
GET_USER_DATA_FLAGS(ck_if[i], rename_flag);
if (rename_flag & VIF_TYPE) {
- UPLL_LOG_DEBUG("Interface is already part of another vlink\n");
+ UPLL_LOG_DEBUG("Interface is already part of another vlink");
+ delete ck_drv_vbr_if; // COV RESOURCE LEAK
+ for (int i =0; i <2; i++)
+ DELETE_IF_NOT_NULL(ck_if[i]);
return UPLL_RC_ERR_CFG_SEMANTIC;
}
+ GET_USER_DATA_FLAGS(ck_if[i], vnode_rename_flag);
+ if (vnode_rename_flag & 0x02) {
+ GET_USER_DATA_FLAGS(cv_link, rename_flag);
+ if (vnodeif_number == kVlinkVnode2)
+ vnode_rename_flag = 0x08;
+ else
+ vnode_rename_flag = 0x04;
+ rename_flag |= vnode_rename_flag;
+ SET_USER_DATA_FLAGS(cv_link, rename_flag);
+ }
delete ck_drv_vbr_if;
ck_drv_vbr_if = NULL;
vnodeif_number = (vnodeif_number == kVlinkVnode1) ?
kVlinkVnode2 : kVlinkVnode1;
i++;
} while (vnodeif_number != kVlinkVnode1);
- if (!ctrlr_dom[0].ctrlr || !ctrlr_dom[1].ctrlr) {
- UPLL_LOG_DEBUG("Invalid ctrlr");
- return UPLL_RC_ERR_GENERIC;
- }
- if ((memcmp(ctrlr_dom[0].ctrlr, ctrlr_dom[1].ctrlr, kMaxLenCtrlrId)) ||
- (memcmp(ctrlr_dom[0].domain, ctrlr_dom[1].domain, kMaxLenDomainId))) {
- UPLL_LOG_DEBUG("Boundary vlink\n");
+ if ((if1_type == UNC_KT_VUNK_IF) || (if2_type == UNC_KT_VUNK_IF)) {
bound_vlink = true;
+ } else {
+ if (!ctrlr_dom[0].ctrlr || !ctrlr_dom[1].ctrlr) {
+ UPLL_LOG_DEBUG("Invalid ctrlr");
+ for (int i =0; i <2; i++)
+ DELETE_IF_NOT_NULL(ck_if[i]);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if ((strncmp((const char *)ctrlr_dom[0].ctrlr,
+ (const char *)ctrlr_dom[1].ctrlr, kMaxLenCtrlrId)) ||
+ (strncmp((const char *)ctrlr_dom[0].domain,
+ (const char *)ctrlr_dom[1].domain, kMaxLenDomainId))) {
+ bound_vlink = true;
+ }
+ }
+ if (bound_vlink) {
+ UPLL_LOG_DEBUG("Boundary vlink");
+ val_vlink_t *vlink_val = reinterpret_cast<val_vlink *>(GetVal(ikey));
+ if (vlink_val && vlink_val->admin_status == UPLL_ADMIN_DISABLE) {
+ UPLL_LOG_ERROR("Boundary vlink cannot be shut\n");
+ for (int i =0; i <2; i++)
+ DELETE_IF_NOT_NULL(ck_if[i]);
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
if ((if1_type == UNC_KT_VRT_IF) || (if2_type == UNC_KT_VRT_IF)) {
- UPLL_LOG_DEBUG("vrt link is not supported on a boundary\n");
+ UPLL_LOG_DEBUG("vrt link is not supported on a boundary");
for (int i =0; i <2; i++)
- if (ck_if[i]) delete ck_if[i];
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ DELETE_IF_NOT_NULL(ck_if[i]);
+ return UPLL_RC_ERR_CFG_SEMANTIC;
}
} else {
if ((if1_type == UNC_KT_VBR_IF) && (if2_type == UNC_KT_VBR_IF)) {
- UPLL_LOG_DEBUG("Internal link between 2 vbridges not allowed\n");
+ UPLL_LOG_DEBUG("Internal link between 2 vbridges not allowed");
for (int i =0; i <2; i++)
- if (ck_if[i]) delete ck_if[i];
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ DELETE_IF_NOT_NULL(ck_if[i]);
+ return UPLL_RC_ERR_CFG_SEMANTIC;
}
}
- if ((if1_type != UNC_KT_VBR_IF) && (if2_type == UNC_KT_VBR_IF)) {
+ // Validate BoundaryCombination
+ result_code = ValidateIfType(ck_if);
+ if (result_code != UPLL_RC_SUCCESS) {
+ for (int i =0; i <2; i++)
+ DELETE_IF_NOT_NULL(ck_if[i]);
+ return result_code;
+ }
+ if ((if1_type == UNC_KT_VRT_IF) && (if2_type == UNC_KT_VBR_IF)) {
result_code = SwapVnodes(ikey);
ConfigKeyVal *tmp = ck_if[0];
ck_if[0] = ck_if[1];
(const_cast<MoManager *>(GetMoManager(key_type)));
result_code = UpdateVlinkMemIfFlag(dt_type, ck_if[i],
- dmi, vnif_type[i], if_mgr,UNC_OP_CREATE);
+ dmi, vnif_type[i], if_mgr, UNC_OP_CREATE);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ for (int i =0; i <2; i++)
+ DELETE_IF_NOT_NULL(ck_if[i]);
return result_code;
}
}
- SET_USER_DATA_CTRLR_DOMAIN(ikey, *ctrlr_dom);
- SET_USER_DATA_CTRLR_DOMAIN(ikey->get_cfg_val(), ctrlr_dom[1]);
/* Reset the pointers to ikey as the current stored pointers
* point to ck_if which is going to get deleted.
*/
- GET_USER_DATA_CTRLR_DOMAIN(ikey, *ctrlr_dom);
- GET_USER_DATA_CTRLR_DOMAIN(ikey->get_cfg_val(), ctrlr_dom[1]);
+ if (if1_type != UNC_KT_VUNK_IF) {
+ SET_USER_DATA_CTRLR_DOMAIN(ikey, *ctrlr_dom);
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, *ctrlr_dom);
+ }
+ if (if2_type != UNC_KT_VUNK_IF) {
+ SET_USER_DATA_CTRLR_DOMAIN(ikey->get_cfg_val(), ctrlr_dom[1]);
+ GET_USER_DATA_CTRLR_DOMAIN(ikey->get_cfg_val(), ctrlr_dom[1]);
+ }
/* Set the vnode if types in first 6 bits of flag */
uint8_t flag = 0;
GET_USER_DATA_FLAGS(ikey, flag);
flag |= (vnif_type[0] << kVlinkVnodeIf1Type);
flag |= (vnif_type[1] << kVlinkVnodeIf2Type);
SET_USER_DATA_FLAGS(ikey, flag);
- UPLL_LOG_DEBUG("Flags for vnode1if type %d vnode2if type %d value %d\n",
+ UPLL_LOG_DEBUG("Flags for vnode1if type %d vnode2if type %d value %d",
vnif_type[0], vnif_type[1], flag);
if (valid_boundary) {
- UPLL_LOG_TRACE("Valid boundary\n");
- result_code = UpdateVbrIfExternal(dt_type, ikey, ck_if, dmi) ;
+ UPLL_LOG_TRACE("Valid boundary");
+ result_code = UpdateVnodeIf(dt_type, ikey, ck_if, dmi, req->operation);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
}
}
for (int i = 0; i <2; i++)
- if (ck_if[i]) delete ck_if[i];
+ DELETE_IF_NOT_NULL(ck_if[i]);
return result_code;
}
+// Validating Boundary Combination
+upll_rc_t VlinkMoMgr::ValidateIfType(ConfigKeyVal **vnodeIf) {
+ UPLL_FUNC_TRACE;
+ if (!(GetVal(vnodeIf[0])) || !(GetVal(vnodeIf[1])))
+ return UPLL_RC_ERR_GENERIC;
+ unc_key_type_t node1_ktype = vnodeIf[0]->get_key_type();
+ unc_key_type_t node2_ktype = vnodeIf[1]->get_key_type();
+ switch (node1_ktype) {
+ case UNC_KT_VUNK_IF:
+ if (node2_ktype == UNC_KT_VRT_IF) {
+ UPLL_LOG_DEBUG("Invalid combination for vlink");
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ break;
+ case UNC_KT_VRT_IF:
+ if ((node2_ktype == UNC_KT_VUNK_IF) || (node2_ktype == UNC_KT_VRT_IF) ||
+ (node2_ktype == UNC_KT_VTUNNEL_IF) ||
+ (node2_ktype == UNC_KT_VTEP_IF)) {
+ UPLL_LOG_DEBUG("Invalid combination for vlink");
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ break;
+ case UNC_KT_VTUNNEL_IF:
+ case UNC_KT_VTEP_IF:
+ if ((node2_ktype == UNC_KT_VRT_IF) || (node2_ktype == UNC_KT_VTEP_IF) ||
+ (node2_ktype == UNC_KT_VTUNNEL_IF)) {
+ UPLL_LOG_DEBUG("Invalid combination for vlink");
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ break;
+ default:
+ UPLL_LOG_DEBUG("Valid Combination");
+ }
+ // Mapped Interface Valdiattion
+ UPLL_LOG_TRACE("Mapped Interface Validation");
+ val_vtunnel_if *vtunnelif_val = NULL;
+ if (node1_ktype == UNC_KT_VTUNNEL_IF)
+ vtunnelif_val = reinterpret_cast<val_vtunnel_if *>(GetVal(vnodeIf[0]));
+ else if (node2_ktype == UNC_KT_VTUNNEL_IF)
+ vtunnelif_val = reinterpret_cast<val_vtunnel_if *>(GetVal(vnodeIf[1]));
+ if (vtunnelif_val)
+ if (vtunnelif_val->valid[UPLL_IDX_PORT_MAP_VTNL_IF] == UNC_VF_VALID) {
+ UPLL_LOG_DEBUG("Tunnel interface is already mapped");
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ val_vtep_if *vtepif_val = NULL;
+ if (node1_ktype == UNC_KT_VTEP_IF)
+ vtepif_val = reinterpret_cast<val_vtep_if *>(GetVal(vnodeIf[0]));
+ else if (node2_ktype == UNC_KT_VTEP_IF)
+ vtepif_val = reinterpret_cast<val_vtep_if *>(GetVal(vnodeIf[1]));
+ if (vtepif_val)
+ if (vtepif_val->valid[UPLL_IDX_PORT_MAP_VTEPI] == UNC_VF_VALID) {
+ UPLL_LOG_DEBUG("Tep interface is already mapped");
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ val_vbr_if *vbrif_val = NULL;
+ if (node1_ktype == UNC_KT_VBR_IF)
+ vbrif_val = reinterpret_cast<val_vbr_if *>(GetVal(vnodeIf[0]));
+ else if (node2_ktype == UNC_KT_VBR_IF)
+ vbrif_val = reinterpret_cast<val_vbr_if *>(GetVal(vnodeIf[1]));
+ if (vbrif_val)
+ if (vbrif_val->valid[UPLL_IDX_PM_VBRI] == UNC_VF_VALID) {
+ UPLL_LOG_DEBUG("Vbridge interface is already mapped");
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ return UPLL_RC_SUCCESS;
+}
/* Pure Virtual functions from MoMgrImpl */
upll_rc_t VlinkMoMgr::GetControllerDomainId(ConfigKeyVal *ikey,
controller_domain *ctrlr_dom) {
UPLL_FUNC_TRACE;
if (!ikey || !ctrlr_dom) {
- UPLL_LOG_INFO("Illegal parameter\n");
+ UPLL_LOG_INFO("Illegal parameter");
return UPLL_RC_ERR_GENERIC;
}
if (ikey->get_user_data()) {
GET_USER_DATA_CTRLR_DOMAIN(ikey, *ctrlr_dom);
- if ((ctrlr_dom->ctrlr &&
+ if ((ctrlr_dom->ctrlr &&
!strlen(reinterpret_cast<const char *>(ctrlr_dom->ctrlr))) ||
- (ctrlr_dom->domain &&
+ (ctrlr_dom->domain &&
!strlen(reinterpret_cast<const char *>(ctrlr_dom->domain)))) {
- UPLL_LOG_DEBUG("Ctrlr domain null\n");
+ UPLL_LOG_DEBUG("Ctrlr domain null");
return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_DEBUG("ctrlr_dom %s %s", ctrlr_dom->ctrlr, ctrlr_dom->domain);
}
if (ikey->get_cfg_val() && ikey->get_cfg_val()->get_user_data()) {
GET_USER_DATA_CTRLR_DOMAIN(ikey->get_cfg_val(), ctrlr_dom[1]);
- if ((ctrlr_dom[1].ctrlr &&
+ if ((ctrlr_dom[1].ctrlr &&
!strlen(reinterpret_cast<const char *>(ctrlr_dom[1].ctrlr))) ||
- (ctrlr_dom[1].domain &&
+ (ctrlr_dom[1].domain &&
!strlen(reinterpret_cast<const char *>(ctrlr_dom[1].domain)))) {
- UPLL_LOG_DEBUG("Ctrlr domain null\n");
+ UPLL_LOG_DEBUG("Ctrlr domain null");
return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_DEBUG("boundary 2nd ctrlr_dom %s %s",
return UPLL_RC_SUCCESS;
}
-
-upll_rc_t VlinkMoMgr::UpdateVbrIfExternal(upll_keytype_datatype_t dt_type,
- ConfigKeyVal *ikey, ConfigKeyVal **vbrif,
- DalDmlIntf *dmi) {
+upll_rc_t VlinkMoMgr::UpdateVnodeIf(upll_keytype_datatype_t dt_type,
+ ConfigKeyVal *ikey, ConfigKeyVal **vnif,
+ DalDmlIntf *dmi,
+ unc_keytype_operation_t op) {
UPLL_FUNC_TRACE;
if (ikey == NULL || dt_type == UPLL_DT_INVALID || dmi == NULL)
return UPLL_RC_ERR_GENERIC;
valid[UPLL_IDX_BOUNDARY_NAME_VLNK];
if (valid_boundary == UNC_VF_VALID) {
for (int i = 0; i < 2; i++) {
- result_code = CheckPortmapValidandUpdateVbrIf(ikey, vbrif[i],
+#if 0
+ result_code = CheckPortmapValidandUpdateVbrIf(ikey, vnif[i],
dmi, dt_type);
+#else
+ UPLL_LOG_TRACE("Before UpdatePortmap %s", (vnif[i]->ToStrAll()).c_str());
+ result_code = UpdateVnodeIfPortmap(ikey, vnif[i], dmi, dt_type, op);
+#endif
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Updation of VbrIf Portmap failed %d\n", result_code);
+ UPLL_LOG_DEBUG("Updation of VnIf Portmap failed %d", result_code);
return result_code;
}
- }
+ }
} else if (valid_boundary == UNC_VF_VALID_NO_VALUE) {
- VbrIfMoMgr *mgr = reinterpret_cast<VbrIfMoMgr *>
- (const_cast<MoManager*>(GetMoManager(UNC_KT_VBR_IF)));
for (int i = 0; i < 2; i++) {
- val_drv_vbr_if *drv_ifval = reinterpret_cast<val_drv_vbr_if *>
- GetVal(vbrif[i]);
- drv_ifval->vbr_if_val.valid[UPLL_IDX_PM_DRV_VBRI] = UNC_VF_VALID_NO_VALUE;
- result_code = reinterpret_cast<VbrIfMoMgr *>(mgr)->
- UpdateConfigVal(vbrif[i], dt_type,dmi);
+ unc_key_type_t ktype = vnif[i]->get_key_type();
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>
+ (GetMoManager(ktype)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Invalid param");
+ return UPLL_RC_ERR_GENERIC;
+ }
+#if 0
+ uint8_t if_flag = 0;
+ GET_USER_DATA_FLAGS(vnif[i], if_flag);
+ if_flag &= ~VIF_TYPE;
+ SET_USER_DATA_FLAGS(vnif[i], if_flag);
+ vnode_if_type vnif_type;
+ result_code = UpdateVlinkMemIfFlag(dt_type, vnif[i], dmi,
+ vnif_type, mgr, UNC_OP_DELETE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ return result_code;
+ }
+#endif
+ val_port_map *portmap = NULL;
+ switch (ktype) {
+ case UNC_KT_VBR_IF:
+ {
+ val_drv_vbr_if *drv_ifval = reinterpret_cast<val_drv_vbr_if *>
+ GetVal(vnif[i]);
+ drv_ifval->vbr_if_val.valid[UPLL_IDX_ADMIN_STATUS_VBRI] =
+ UNC_VF_INVALID;
+ drv_ifval->vbr_if_val.valid[UPLL_IDX_PM_VBRI] = UNC_VF_VALID_NO_VALUE;
+ result_code = reinterpret_cast<VbrIfMoMgr *>(mgr)->
+ UpdatePortMap(vnif[i], dt_type, dmi, vnif[i]);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Clear Portmap failed %d", result_code);
+ return result_code;
+ }
+ break;
+ }
+ case UNC_KT_VTEP_IF:
+ {
+ val_vtep_if *drv_ifval = reinterpret_cast<val_vtep_if *>
+ GetVal(vnif[i]);
+ drv_ifval->valid[UPLL_IDX_ADMIN_ST_VTEPI] = UNC_VF_INVALID;
+ drv_ifval->valid[UPLL_IDX_PORT_MAP_VTEPI] = UNC_VF_VALID_NO_VALUE;
+ portmap = &drv_ifval->portmap;
+ }
+ /* fall through intended */
+ case UNC_KT_VTUNNEL_IF:
+ if (ktype == UNC_KT_VTUNNEL_IF) {
+ val_vtunnel_if *drv_ifval = reinterpret_cast<val_vtunnel_if *>
+ GetVal(vnif[i]);
+ portmap = &drv_ifval->portmap;
+ drv_ifval->valid[UPLL_IDX_ADMIN_ST_VTNL_IF] = UNC_VF_INVALID;
+ drv_ifval->valid[UPLL_IDX_PORT_MAP_VTNL_IF] = UNC_VF_VALID_NO_VALUE;
+ }
+ portmap->valid[UPLL_IDX_LOGICAL_PORT_ID_PM] =
+ UNC_VF_VALID_NO_VALUE;
+ uuu::upll_strncpy(portmap->logical_port_id, "\0", 1);
+ portmap->valid[UPLL_IDX_VLAN_ID_PM] = UNC_VF_VALID_NO_VALUE;
+ portmap->valid[UPLL_IDX_TAGGED_PM] = UNC_VF_VALID_NO_VALUE;
+ portmap->tagged = UPLL_VLAN_UNTAGGED;
+ portmap->vlan_id = 0;
+ break;
+ case UNC_KT_VUNK_IF:
+ break;
+ default:
+ UPLL_LOG_DEBUG("Unsupported keytype %d", ktype);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ DbSubOp dbop = { kOpNotRead, kOpMatchNone, kOpInOutNone };
+ result_code = mgr->UpdateConfigDB(vnif[i], dt_type, UNC_OP_UPDATE,
+ dmi, &dbop, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Clear Portmap failed %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning %d", result_code);
return result_code;
}
}
} else {
- UPLL_LOG_DEBUG("Internal vlink\n");
+ UPLL_LOG_DEBUG("Internal vlink");
}
if (ck_boundary)
delete ck_boundary;
return result_code;
}
+#if 0
upll_rc_t VlinkMoMgr::CheckPortmapValidandUpdateVbrIf(
ConfigKeyVal *ikey, ConfigKeyVal *ck_drv_vbr_if, DalDmlIntf *dmi,
upll_keytype_datatype_t dt_type) {
VbrIfMoMgr *mgr = reinterpret_cast<VbrIfMoMgr *>(const_cast<MoManager*>
(GetMoManager(UNC_KT_VBR_IF)));
if (!mgr) {
- UPLL_LOG_DEBUG("Invalid param\n");
+ UPLL_LOG_DEBUG("Invalid param");
return UPLL_RC_ERR_GENERIC;
}
uint8_t valid_port = reinterpret_cast<val_drv_vbr_if *>
if (valid_port == UNC_VF_INVALID) {
result_code = ConverttoDriverPortMap(ck_drv_vbr_if, ikey);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
return result_code;
}
DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone };
result_code = mgr->UpdateConfigDB(ck_drv_vbr_if, dt_type, UNC_OP_UPDATE,
dmi, &dbop, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Updation failed %d\n", result_code);
+ UPLL_LOG_DEBUG("Updation failed %d", result_code);
return result_code;
}
} else if (valid_port == UNC_VF_VALID) {
#if 0
if (CompareVbrIfWithPhysicalData(ck_drv_vbr_if, ck_boundary, ikey)) {
- UPLL_LOG_DEBUG("VbrIf is already configured \n");
+ UPLL_LOG_DEBUG("VbrIf is already configured");
+ return UPLL_RC_ERR_GENERIC;
+ }
+#endif
+ }
+ return result_code;
+}
+#endif
+
+upll_rc_t VlinkMoMgr::UpdateVnodeIfPortmap(
+ ConfigKeyVal *ikey, ConfigKeyVal *ck_vn_if, DalDmlIntf *dmi,
+ upll_keytype_datatype_t dt_type,
+ unc_keytype_operation_t op) {
+ UPLL_FUNC_TRACE;
+ if (ikey == NULL || ck_boundary == NULL || dmi == NULL
+ || ck_vn_if == NULL || dt_type == UPLL_DT_INVALID) {
+ UPLL_LOG_DEBUG("Invalid param");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ unc_key_type_t ktype = ck_vn_if->get_key_type();
+ // val_port_map *port_map_val;
+ val_vlink *vlink_val = reinterpret_cast<val_vlink *>(GetVal(ikey));
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>
+ (GetMoManager(ktype)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Invalid param");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_TRACE("ktype %d", ktype);
+ uint8_t valid_port;
+ void *val_if = GetVal(ck_vn_if);
+ switch (ktype) {
+ case UNC_KT_VTEP_IF:
+ {
+ val_vtep_if *vtep_if = reinterpret_cast<val_vtep_if *>(val_if);
+ vtep_if->valid[UPLL_IDX_ADMIN_ST_VTEPI] = UNC_VF_INVALID;
+ valid_port = vtep_if->valid[UPLL_IDX_PORT_MAP_VTEPI];
+ // port_map_val = &vtep_if->portmap;
+ break;
+ }
+ case UNC_KT_VTUNNEL_IF:
+ {
+ val_vtunnel_if *vtunnel_if = reinterpret_cast<val_vtunnel_if *>(val_if);
+ vtunnel_if->valid[UPLL_IDX_ADMIN_ST_VTNL_IF] = UNC_VF_INVALID;
+ valid_port = vtunnel_if->valid[UPLL_IDX_PORT_MAP_VTNL_IF];
+ // port_map_val = &vtunnel_if->portmap;
+ break;
+ }
+ case UNC_KT_VBR_IF:
+ {
+ val_drv_vbr_if *vbr_if = reinterpret_cast<val_drv_vbr_if *>(val_if);
+ vbr_if->vbr_if_val.valid[UPLL_IDX_ADMIN_STATUS_VBRI] = UNC_VF_INVALID;
+ valid_port = vbr_if->vbr_if_val.valid[UPLL_IDX_PM_VBRI];
+ // port_map_val = &vbr_if->vbr_if_val.portmap;
+ break;
+ }
+ case UNC_KT_VUNK_IF:
+ return UPLL_RC_SUCCESS;
+ default:
+ UPLL_LOG_DEBUG("Unsupported keytype %d", ktype);
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ UPLL_LOG_DEBUG("valid_port %d valid vlanid %d", valid_port,
+ vlink_val->valid[UPLL_IDX_VLAN_ID_VLNK]);
+ if ((valid_port == UNC_VF_INVALID) ||
+ ((valid_port == UNC_VF_VALID) && (op != UNC_OP_CREATE))) {
+ result_code = ConverttoDriverPortMap(ck_vn_if, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ return result_code;
+ }
+ } else if (op == UNC_OP_CREATE) {
+ UPLL_LOG_DEBUG("Vlink of a mapped interface is not allowed");
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+#if 0
+ else if (valid_port == UNC_VF_VALID) {
+ if (op == UNC_OP_CREATE) {
+ UPLL_LOG_DEBUG("Vlink of a mapped interface is not allowed");
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ port_map_val->tagged = UPLL_VLAN_TAGGED;
+ port_map_val->valid[UPLL_IDX_TAGGED_PM] = UNC_VF_VALID;
+ switch (vlink_val->valid[UPLL_IDX_VLAN_ID_VLNK]) {
+ case UNC_VF_VALID:
+ port_map_val->vlan_id = vlink_val->vlan_id;
+ break;
+ case UNC_VF_VALID_NO_VALUE:
+ port_map_val->vlan_id = 0;
+ port_map_val->tagged = UPLL_VLAN_UNTAGGED;
+ break;
+ default:
+ break;
+ }
+ port_map_val->valid[UPLL_IDX_VLAN_ID_PM] =
+ vlink_val->valid[UPLL_IDX_VLAN_ID_VLNK];
+#if 0
+ if (CompareVbrIfWithPhysicalData(ck_drv_vbr_if, ck_boundary, ikey)) {
+ UPLL_LOG_DEBUG("VbrIf is already configured");
return UPLL_RC_ERR_GENERIC;
}
#endif
}
+#endif
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone };
+ result_code = mgr->UpdateConfigDB(ck_vn_if, dt_type, UNC_OP_UPDATE,
+ dmi, &dbop, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Updation failed %d", result_code);
+ return result_code;
+ }
return result_code;
}
val_boundary *boundary_val_data = reinterpret_cast<val_boundary *>
((GetVal(ck_boundary_data)));
if (boundary_val_data == NULL) {
- UPLL_LOG_DEBUG("Boundary invalid\n");
+ UPLL_LOG_DEBUG("Boundary invalid");
return UPLL_RC_ERR_GENERIC;
}
#if 0
upll_rc_t VlinkMoMgr::ConverttoDriverPortMap(ConfigKeyVal *iokey,
ConfigKeyVal *ikey) {
UPLL_FUNC_TRACE;
+ if (ikey == NULL || iokey == NULL || ikey->get_cfg_val() == NULL ||
+ iokey->get_cfg_val() == NULL) {
+ UPLL_LOG_DEBUG("Invalid Input");
+ return UPLL_RC_ERR_GENERIC;
+ }
val_boundary *boundary_val_data = reinterpret_cast<val_boundary *>
(GetVal(ck_boundary));
if (boundary_val_data == NULL) {
- UPLL_LOG_DEBUG("Invalid parameter\n");
+ UPLL_LOG_DEBUG("Invalid parameter");
return UPLL_RC_ERR_GENERIC;
}
- std::string if_name = reinterpret_cast<const char *>
+ unc_key_type_t ktype = iokey->get_key_type();
+ val_port_map *port_map_val;
+ switch (ktype) {
+ case UNC_KT_VBR_IF:
+ {
+ val_drv_vbr_if *drv_ifval = reinterpret_cast<val_drv_vbr_if *>
+ (GetVal(iokey));
+ if (!drv_ifval) {
+ UPLL_LOG_DEBUG("Invalid param");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (drv_ifval->vbr_if_val.valid[UPLL_IDX_PM_VBRI] == UNC_VF_INVALID) {
+ std::string if_name = reinterpret_cast<const char *>
(reinterpret_cast<key_vbr_if*>(iokey->get_key())->if_name);
- if (strlen(if_name.c_str()) >= 18)
- if_name.assign(if_name.c_str(), 18);
- std::string vex_name = "vx_" + if_name + static_cast<std::ostringstream*>(
- &(std::ostringstream() << time(NULL)) )->str();
- std::string vex_if_name = "vi_" + if_name + static_cast<std::ostringstream*>(
- &(std::ostringstream() << time(NULL)) )->str();
- std::string vex_link_name = "vl_" + if_name + static_cast<std::ostringstream*>(
- &(std::ostringstream() << time(NULL)) )->str();
-
- val_drv_vbr_if *drv_ifval = reinterpret_cast<val_drv_vbr_if *>
+ if (strlen(if_name.c_str()) >= 10) {
+ if_name.erase(10);
+ }
+
+ struct timeval _timeval;
+ struct timezone _timezone;
+ gettimeofday(&_timeval, &_timezone);
+
+ std::stringstream ss;
+ ss << if_name << _timeval.tv_sec << _timeval.tv_usec;
+ std::string unique_id = ss.str();
+ std::string vex_name("vx_");
+ vex_name += unique_id;
+ std::string vex_if_name("vi_");
+ vex_if_name += unique_id;
+ std::string vex_link_name("vl_");
+ vex_link_name += unique_id;
+
+ drv_ifval->vbr_if_val.valid[UPLL_IDX_PM_VBRI] = UNC_VF_VALID;
+ drv_ifval->valid[PFCDRV_IDX_VEXT_NAME_VBRIF] = UNC_VF_VALID;
+ uuu::upll_strncpy(drv_ifval->vex_name, vex_name.c_str(),
+ kMaxLenVnodeName+1);
+
+ drv_ifval->valid[PFCDRV_IDX_VEXTIF_NAME_VBRIF] = UNC_VF_VALID;
+ uuu::upll_strncpy(reinterpret_cast<char *>(drv_ifval->vex_if_name),
+ vex_if_name.c_str(), kMaxLenInterfaceName+1);
+
+ drv_ifval->valid[PFCDRV_IDX_VLINK_NAME_VBRIF] = UNC_VF_VALID;
+ uuu::upll_strncpy(reinterpret_cast<char *>(drv_ifval->vex_link_name),
+ vex_link_name.c_str(), kMaxLenVlinkName+1);
+ }
+ port_map_val = &drv_ifval->vbr_if_val.portmap;
+ break;
+ }
+ case UNC_KT_VTEP_IF:
+ {
+ val_vtep_if *drv_ifval = reinterpret_cast<val_vtep_if *>
+ (GetVal(iokey));
+ if (!drv_ifval) {
+ UPLL_LOG_DEBUG("Invalid param");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ drv_ifval->valid[UPLL_IDX_PORT_MAP_VTEPI] = UNC_VF_VALID;
+ port_map_val = &drv_ifval->portmap;
+ break;
+ }
+ case UNC_KT_VTUNNEL_IF:
+ {
+ val_vtunnel_if *drv_ifval = reinterpret_cast<val_vtunnel_if *>
(GetVal(iokey));
- if (!drv_ifval) {
- UPLL_LOG_DEBUG("Invalid param\n");
+ if (!drv_ifval) {
+ UPLL_LOG_DEBUG("Invalid param");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ drv_ifval->valid[UPLL_IDX_PORT_MAP_VTNL_IF] = UNC_VF_VALID;
+ port_map_val = &drv_ifval->portmap;
+ break;
+ }
+ case UNC_KT_VUNK_IF:
+ return UPLL_RC_SUCCESS;
+ default:
+ UPLL_LOG_DEBUG("Unsupported keytype %d", ktype);
return UPLL_RC_ERR_GENERIC;
}
- val_port_map *port_map_val = &drv_ifval->vbr_if_val.portmap;
uint8_t rename = 0;
- GET_USER_DATA_FLAGS(iokey, rename);
+ controller_domain ctrlr_dom[2] = { { NULL, NULL }, { NULL, NULL } };
+ uint8_t *node_ctrlr = NULL;
+ uint8_t *node_dom = NULL;
char *port_id = NULL;
- uppl_val_boundary_index index;
+ uppl_val_boundary_index index = kIdxBoundaryLogicalPortId1;
+ GET_USER_DATA_FLAGS(iokey, rename);
+
+ upll_rc_t result_code = GetControllerDomainId(ikey, &ctrlr_dom[0]);
+ if (UPLL_RC_SUCCESS != result_code)
+ return result_code;
+
if (rename & kVlinkBoundaryNode1) {
- port_id = reinterpret_cast<char *>(boundary_val_data->logical_port_id1);
- index = kIdxBoundaryLogicalPortId1;
+ node_ctrlr = ctrlr_dom[0].ctrlr;
+ node_dom = ctrlr_dom[0].domain;
+ } else {
+ node_ctrlr = ctrlr_dom[1].ctrlr;
+ node_dom = ctrlr_dom[1].domain;
+ }
+ if (!node_ctrlr || !node_dom) {
+ UPLL_LOG_DEBUG("Returning error\n");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (!(strcmp(reinterpret_cast<const char *>(node_ctrlr),
+ reinterpret_cast<const char *>(boundary_val_data->controller_name1))) &&
+ !(strcmp(reinterpret_cast<const char *>(node_dom),
+ reinterpret_cast<const char *>(boundary_val_data->domain_name1)))) {
+ index = kIdxBoundaryLogicalPortId1;
+ port_id = reinterpret_cast<char *>(boundary_val_data->logical_port_id1);
+ } else if (!(strcmp(reinterpret_cast<const char *>(node_ctrlr),
+ reinterpret_cast<const char *>(boundary_val_data->controller_name2))) &&
+ !(strcmp(reinterpret_cast<const char *>(node_dom),
+ reinterpret_cast<const char *>(boundary_val_data->domain_name2)))) {
+ index = kIdxBoundaryLogicalPortId2;
+ port_id = reinterpret_cast<char *>(boundary_val_data->logical_port_id2);
} else {
- port_id = reinterpret_cast<char *>(boundary_val_data->logical_port_id2);
- index = kIdxBoundaryLogicalPortId2;
+ UPLL_LOG_DEBUG("Wrong Controller / domain \n");
+ return UPLL_RC_ERR_CFG_SEMANTIC;
}
if (boundary_val_data->valid[index] == UNC_VF_VALID) {
port_map_val->valid[UPLL_IDX_LOGICAL_PORT_ID_PM] = UNC_VF_VALID;
} else {
port_map_val->valid[UPLL_IDX_LOGICAL_PORT_ID_PM] = UNC_VF_INVALID;
}
- drv_ifval->vbr_if_val.valid[UPLL_IDX_PM_DRV_VBRI] = UNC_VF_VALID;
- drv_ifval->valid[UPLL_IDX_VEXT_DRV_PM] = UNC_VF_VALID;
- uuu::upll_strncpy(drv_ifval->vex_name, vex_name.c_str(), kMaxLenVnodeName+1);
-
- drv_ifval->valid[UPLL_IDX_VEXT_IF_DRV_PM] = UNC_VF_VALID;
- uuu::upll_strncpy(reinterpret_cast<char *>(drv_ifval->vex_if_name),
- vex_if_name.c_str(), kMaxLenInterfaceName+1);
-
- drv_ifval->valid[UPLL_IDX_VEXT_LINK_DRV_PM] = UNC_VF_VALID;
- uuu::upll_strncpy(reinterpret_cast<char *>(drv_ifval->vex_link_name),
- vex_link_name.c_str(), kMaxLenVlinkName+1);
-
val_vlink *vlink_val = reinterpret_cast<val_vlink *>(GetVal(ikey));
port_map_val->valid[UPLL_IDX_VLAN_ID_PM] =
- vlink_val->valid[UPLL_IDX_VLAN_ID_VLNK];
+ vlink_val->valid[UPLL_IDX_VLAN_ID_VLNK];
switch (vlink_val->valid[UPLL_IDX_VLAN_ID_VLNK]) {
case UNC_VF_VALID:
- port_map_val->vlan_id = reinterpret_cast<val_vlink *>
- ((ikey->get_cfg_val())->get_val())->vlan_id;
+ port_map_val->vlan_id = vlink_val->vlan_id;
+ if (port_map_val->vlan_id == 0xFFFF)
+ port_map_val->tagged = UPLL_VLAN_UNTAGGED;
+ else
+ port_map_val->tagged = UPLL_VLAN_TAGGED;
+ port_map_val->valid[UPLL_IDX_TAGGED_PM] = UNC_VF_VALID;
break;
case UNC_VF_VALID_NO_VALUE:
port_map_val->vlan_id = 0;
+ port_map_val->tagged = UPLL_VLAN_UNTAGGED;
+ port_map_val->valid[UPLL_IDX_TAGGED_PM] = UNC_VF_VALID;
break;
default:
break;
}
- port_map_val->tagged = UPLL_VLAN_TAGGED;
- port_map_val->valid[UPLL_IDX_TAGGED_PM] = UNC_VF_VALID;
return UPLL_RC_SUCCESS;
}
UPLL_FUNC_TRACE;
uint8_t if_flag = 0;
if (!ck_vnif) {
- UPLL_LOG_DEBUG("Invalid ck_vnif\n");
+ UPLL_LOG_DEBUG("Invalid ck_vnif");
return UPLL_RC_ERR_GENERIC;
}
interface_type = kUnlinkedInterface;
interface_type = kUnlinkedInterface;
} else {
if (!ck_vlink) {
- UPLL_LOG_DEBUG("Invalid param\n");
+ UPLL_LOG_DEBUG("Invalid param");
return UPLL_RC_ERR_GENERIC;
}
uint8_t valid_boundary = reinterpret_cast<val_vlink *>(GetVal(ck_vlink))->
} else if (interface_type == kVlinkInternalNode1) {
interface_type = (valid_boundary)? kVlinkBoundaryNode1: interface_type;
} else {
- UPLL_LOG_DEBUG("Invalid value of interface_type %d\n", interface_type);
+ UPLL_LOG_DEBUG("Invalid value of interface_type %d", interface_type);
}
}
SET_USER_DATA_FLAGS(ck_vnif, if_flag);
ConfigKeyVal *&ck_vlink,
DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
- int mem_vlink = 0;
+ uint8_t mem_vlink = 0;
if (!keyVal) {
- UPLL_LOG_DEBUG("Invalid keyVal\n");
+ UPLL_LOG_DEBUG("Invalid keyVal");
return UPLL_RC_ERR_GENERIC;
}
val_vlink *link_val = reinterpret_cast<val_vlink *>
- (malloc(sizeof(val_vlink)));
- if (!link_val) {
- UPLL_LOG_ERROR("Invalid linkval\n");
- return UPLL_RC_ERR_GENERIC;
- }
- memset(link_val, 0, sizeof(val_vlink));
+ (ConfigKeyVal::Malloc(sizeof(val_vlink)));
upll_rc_t res_code = UPLL_RC_SUCCESS;
key_vbr_if *vbr_key_if = reinterpret_cast<key_vbr_if *>(keyVal->get_key());
if (!vbr_key_if) {
- UPLL_LOG_ERROR("Invalid key\n");
+ UPLL_LOG_ERROR("Invalid key");
free(link_val);
return UPLL_RC_ERR_GENERIC;
}
link_val->valid[UPLL_IDX_VNODE2_IF_NAME_VLNK] = UNC_VF_INVALID;
}
- DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag };
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone,
+ kOpInOutFlag | kOpInOutCtrlr | kOpInOutDomain };
/* get vlink key from if key */
upll_rc_t result_code = GetChildConfigKey(ck_vlink, keyVal);
if (!ck_vlink || result_code != UPLL_RC_SUCCESS) {
- if (link_val) free(link_val);
- UPLL_LOG_DEBUG("Returning error %d \n", result_code);
+ free(link_val);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
return result_code;
}
ck_vlink->AppendCfgVal(IpctSt::kIpcStValVlink, link_val);
- res_code = ReadConfigDB(ck_vlink, UPLL_DT_CANDIDATE, UNC_OP_READ,
+ res_code = ReadConfigDB(ck_vlink, dt_type, UNC_OP_READ,
dbop, dmi, MAINTBL);
UPLL_LOG_TRACE(" Vlink ReadConfigDB After %d", res_code);
return res_code;
if (MAINTBL == tbl) {
nattr = NUM_KEY_MAIN_TBL_;
binfo = key_vlink_maintbl_bind_info;
- } else if (RENAMETBL == tbl ) {
+ } else if (RENAMETBL == tbl) {
nattr = NUM_KEY_RENAME_TBL_;
binfo = key_vlink_renametbl_update_bind_info;
}
return UPLL_RC_ERR_GENERIC;
}
} else if (tbl == RENAMETBL) {
- switch(indx) {
+ switch (indx) {
case uudst::vlink_rename::kDbiCtrlrVtnName:
valid = &(reinterpret_cast<val_rename_vnode *>(val))->
valid[UPLL_CTRLR_VTN_NAME_VALID];
bool VlinkMoMgr::IsValidKey(void *key, uint64_t index) {
UPLL_FUNC_TRACE;
key_vlink *vlink_key = reinterpret_cast<key_vlink *>(key);
- bool ret_val = UPLL_RC_SUCCESS;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
switch (index) {
case uudst::vlink::kDbiVtnName:
case uudst::vnode_rename::kDbiUncVtnName:
return false;
break;
}
- UPLL_LOG_TRACE("Leaving IsValidKey");
return true;
}
upll_rc_t VlinkMoMgr::GetChildConfigKey(ConfigKeyVal *&okey,
ConfigKeyVal *parent_key) {
+ UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- key_vlink *vlink_key = reinterpret_cast<key_vlink *>
- (malloc(sizeof(key_vlink)));
- memset(vlink_key, 0, sizeof(key_vlink));
+ key_vlink_t * vlink_key = NULL;
+ if (okey && okey->get_key()) {
+ vlink_key = reinterpret_cast<key_vlink_t *>
+ (okey->get_key());
+ } else {
+ vlink_key = reinterpret_cast<key_vlink *>
+ (ConfigKeyVal::Malloc(sizeof(key_vlink)));
+ }
unc_key_type_t ktype;
void *pkey;
if (parent_key == NULL) {
+ if (!okey)
okey = new ConfigKeyVal(UNC_KT_VLINK, IpctSt::kIpcStKeyVlink, vlink_key,
NULL);
+ else if (okey->get_key() != vlink_key)
+ okey->SetKey(IpctSt::kIpcStKeyVlink,vlink_key);
return (okey)?UPLL_RC_SUCCESS:UPLL_RC_ERR_GENERIC;
} else {
pkey = parent_key->get_key();
}
if (!pkey) {
- free(vlink_key);
+ if (!okey || !(okey->get_key()))
+ free(vlink_key);
return UPLL_RC_ERR_GENERIC;
}
ktype = parent_key->get_key_type();
reinterpret_cast<key_vtep_if *>(pkey)->vtep_key.vtn_key.vtn_name,
(kMaxLenVtnName+1));
break;
+ case UNC_KT_VTUNNEL:
+ uuu::upll_strncpy(vlink_key->vtn_key.vtn_name,
+ reinterpret_cast<key_vtunnel *>(pkey)->vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ break;
+ case UNC_KT_VTUNNEL_IF:
+ uuu::upll_strncpy(vlink_key->vtn_key.vtn_name,
+ reinterpret_cast<key_vtunnel_if *>
+ (pkey)->vtunnel_key.vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ break;
case UNC_KT_VUNKNOWN:
uuu::upll_strncpy(vlink_key->vtn_key.vtn_name,
reinterpret_cast<key_vunknown *>(pkey)->vtn_key.vtn_name,
(kMaxLenVtnName+1));
break;
default:
- free(vlink_key);
+ if (!okey || !(okey->get_key()))
+ free(vlink_key);
return UPLL_RC_ERR_GENERIC; /* OPERATION_NOT_SUPPORTED ? */
}
- okey = new ConfigKeyVal(UNC_KT_VLINK, IpctSt::kIpcStKeyVlink, vlink_key,
+ if (!okey)
+ okey = new ConfigKeyVal(UNC_KT_VLINK, IpctSt::kIpcStKeyVlink, vlink_key,
NULL);
+ else if (okey->get_key() != vlink_key)
+ okey->SetKey(IpctSt::kIpcStKeyVlink,vlink_key);
if (okey == NULL) {
free(vlink_key);
result_code = UPLL_RC_ERR_GENERIC;
upll_rc_t VlinkMoMgr::GetParentConfigKey(ConfigKeyVal *&okey,
ConfigKeyVal *ikey) {
- upll_rc_t result_code = UPLL_RC_SUCCESS;
+ upll_rc_t result_code = UPLL_RC_SUCCESS; // COV REVERSE INULL
+ if (ikey == NULL)
+ return UPLL_RC_ERR_GENERIC;
unc_key_type_t ikey_type = ikey->get_key_type();
if (ikey_type != UNC_KT_VLINK) return UPLL_RC_ERR_GENERIC;
void *pkey = (ikey) ? ikey->get_key() : NULL;
if (!pkey) return UPLL_RC_ERR_GENERIC;
- key_vtn *vtn_key = reinterpret_cast<key_vtn *>(malloc(sizeof(key_vtn)));
- memset(vtn_key, 0, sizeof(key_vtn));
+ key_vtn *vtn_key = reinterpret_cast<key_vtn *>(
+ ConfigKeyVal::Malloc(sizeof(key_vtn)));
uuu::upll_strncpy(vtn_key->vtn_name,
reinterpret_cast<key_vlink *>(pkey)->vtn_key.vtn_name,
(kMaxLenVtnName+1));
okey = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcStKeyVtn, vtn_key, NULL);
if (okey == NULL) result_code = UPLL_RC_ERR_GENERIC;
+ else SET_USER_DATA(okey, ikey);
return result_code;
}
if (ck_val != NULL) return UPLL_RC_ERR_GENERIC;
switch (tbl) {
case MAINTBL:
- val = reinterpret_cast<void *>(malloc(sizeof(val_vlink)));
-
- if (!val) {
- UPLL_LOG_ERROR("Invalid memory allocation\n");
- return UPLL_RC_ERR_GENERIC;
- }
- memset(val, 0, sizeof(val_vlink));
+ val = reinterpret_cast<void *>(ConfigKeyVal::Malloc(sizeof(val_vlink)));
ck_val = new ConfigVal(IpctSt::kIpcStValVlink, val);
if (!ck_val) {
- UPLL_LOG_ERROR("Invalid memory allocation\n");
+ UPLL_LOG_ERROR("Invalid memory allocation");
return UPLL_RC_ERR_GENERIC;
}
if (dt_type == UPLL_DT_STATE) {
- val = reinterpret_cast<void *>(malloc(sizeof(val_db_vlink_st)));
- if (!val) {
- UPLL_LOG_ERROR("Invalid memory allocation\n");
- return UPLL_RC_ERR_GENERIC;
- }
- memset(val, 0, sizeof(val_db_vlink_st));
+ val = reinterpret_cast<void *>(
+ ConfigKeyVal::Malloc(sizeof(val_db_vlink_st)));
ConfigVal *ck_nxtval = new ConfigVal(IpctSt::kIpcStValVlinkSt, val);
ck_val->AppendCfgVal(ck_nxtval);
}
break;
case RENAMETBL:
- val = reinterpret_cast<void *>(malloc(sizeof(val_db_rename_vlink)));
- memset(val, 0, sizeof(val_db_rename_vlink));
+ val = reinterpret_cast<void *>(
+ ConfigKeyVal::Malloc(sizeof(val_db_rename_vlink)));
ck_val = new ConfigVal(IpctSt::kIpcInvalidStNum, val);
break;
default:
if (tbl == MAINTBL) {
val_vlink *ival = reinterpret_cast<val_vlink *>(GetVal(req));
if (!ival) {
- UPLL_LOG_TRACE("Empty Val structure\n");
+ UPLL_LOG_TRACE("Empty Val structure");
return UPLL_RC_ERR_GENERIC;
}
val_vlink *vlink_val = reinterpret_cast<val_vlink *>
- (malloc(sizeof(val_vlink)));
+ (ConfigKeyVal::Malloc(sizeof(val_vlink)));
memcpy(vlink_val, ival, sizeof(val_vlink));
tmp1 = new ConfigVal(IpctSt::kIpcStValVlink, vlink_val);
} else if (tbl == RENAMETBL) {
val_db_rename_vlink *ival = reinterpret_cast<val_db_rename_vlink *>
(GetVal(req));
rename_val = reinterpret_cast<void *>
- (malloc(sizeof(val_db_rename_vlink)));
+ (ConfigKeyVal::Malloc(sizeof(val_db_rename_vlink)));
memcpy(rename_val, ival, sizeof(val_db_rename_vlink));
tmp1 = new ConfigVal(IpctSt::kIpcInvalidStNum, rename_val);
} else {
val_rename_vlink *ival = reinterpret_cast<val_rename_vlink *>
(GetVal(req));
- rename_val = reinterpret_cast<void *>(malloc(sizeof(val_rename_vlink)));
+ rename_val = reinterpret_cast<void *>(
+ ConfigKeyVal::Malloc(sizeof(val_rename_vlink)));
memcpy(rename_val, ival, sizeof(val_rename_vlink));
tmp1 = new ConfigVal(IpctSt::kIpcStValRenameVlink, rename_val);
}
};
if (tmp) {
if (tbl == MAINTBL) {
- val_vlink_st *ival = reinterpret_cast<val_vlink_st *>(tmp->get_val());
- val_vlink_st *val_vlink = reinterpret_cast<val_vlink_st *>
- (malloc(sizeof(val_vlink_st)));
- memcpy(val_vlink, ival, sizeof(val_vlink_st));
- ConfigVal *tmp2 = new ConfigVal(IpctSt::kIpcStValVlinkSt, val_vlink);
+ val_db_vlink_st *ival = reinterpret_cast<val_db_vlink_st *>
+ (tmp->get_val());
+ val_db_vlink_st *val_db_vlink = reinterpret_cast<val_db_vlink_st *>
+ (ConfigKeyVal::Malloc(sizeof(val_db_vlink_st)));
+ memcpy(val_db_vlink, ival, sizeof(val_db_vlink_st));
+ ConfigVal *tmp2 = new ConfigVal(IpctSt::kIpcStValVlinkSt, val_db_vlink);
tmp1->AppendCfgVal(tmp2);
}
};
void *tkey = (req != NULL) ? (req)->get_key() : NULL;
key_vlink *ikey = reinterpret_cast<key_vlink *>(tkey);
key_vlink *vlink_key = reinterpret_cast<key_vlink *>
- (malloc(sizeof(key_vlink)));
+ (ConfigKeyVal::Malloc(sizeof(key_vlink)));
memcpy(vlink_key, ikey, sizeof(key_vlink));
okey = new ConfigKeyVal(UNC_KT_VLINK, IpctSt::kIpcStKeyVlink, vlink_key,
tmp1);
if (okey) {
SET_USER_DATA(okey, req);
- SET_USER_DATA(okey->get_cfg_val(), req->get_cfg_val());
+ if (RENAMETBL != tbl)
+ SET_USER_DATA(okey->get_cfg_val(), req->get_cfg_val());
} else {
delete tmp1;
}
DalDmlIntf *dmi, uint8_t *ctrlr_id) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- if (ctrlr_id == NULL) return UPLL_RC_ERR_GENERIC;
ConfigKeyVal *unc_key = NULL;
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
val_db_rename_vlink *rename_vlink = reinterpret_cast<val_db_rename_vlink *>
- (malloc(sizeof(val_db_rename_vlink)));
- if (rename_vlink == NULL) return UPLL_RC_ERR_GENERIC;
- memset(rename_vlink, 0, sizeof(val_db_rename_vlink));
+ (ConfigKeyVal::Malloc(sizeof(val_db_rename_vlink)));
key_vlink *ctrlr_key = reinterpret_cast<key_vlink *>(ikey->get_key());
- uuu::upll_strncpy(rename_vlink->ctrlr_vtn_name,
- ctrlr_key->vtn_key.vtn_name, (kMaxLenVtnName+1));
- uuu::upll_strncpy(rename_vlink->ctrlr_vlink_name,
- ctrlr_key->vlink_name, (kMaxLenVtnName+1));
-
+ rename_vlink->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_INVALID;
+ rename_vlink->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_INVALID;
+ upll_rc_t ret_val = ValidateKey(
+ reinterpret_cast<char *>(ctrlr_key->vtn_key.vtn_name),
+ kMinLenVtnName, kMaxLenVtnName);
+ if (ret_val == UPLL_RC_SUCCESS) {
+ uuu::upll_strncpy(rename_vlink->ctrlr_vtn_name,
+ ctrlr_key->vtn_key.vtn_name, (kMaxLenVtnName+1));
+ rename_vlink->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
+ }
+ ret_val = ValidateKey(reinterpret_cast<char *>(ctrlr_key->vlink_name),
+ kMinLenVlinkName, kMaxLenVlinkName);
+ if (ret_val == UPLL_RC_SUCCESS) {
+ uuu::upll_strncpy(rename_vlink->ctrlr_vlink_name,
+ ctrlr_key->vlink_name, (kMaxLenVlinkName+1));
+ rename_vlink->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_VALID;
+ }
result_code = GetChildConfigKey(unc_key, NULL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetChildConfigKey Failed result_code %d\n", result_code);
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed result_code %d", result_code);
return result_code;
}
- SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
- rename_vlink->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
- rename_vlink->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_VALID;
+ if (ctrlr_id) {
+ SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
+ } else {
+ dbop.matchop = kOpMatchNone;
+ }
unc_key->AppendCfgVal(IpctSt::kIpcInvalidStNum, rename_vlink);
result_code = ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
controller_domain *ctrlr_dom) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- uint8_t rename = 1;
+ UPLL_LOG_DEBUG("Test : Controller %s Domain %s",
+ ctrlr_dom->ctrlr, ctrlr_dom->domain);
+ uint8_t rename = 1, val_rename = 0, vnode_rename = 0;
ConfigKeyVal *okey = NULL;
+ for (int i = 0; i < 2; i++) {
+ unc_key_type_t ktype = GetVlinkVnodeIfKeyType(ikey, i);
+ if (ktype == UNC_KT_VUNK_IF)
+ return UPLL_RC_SUCCESS;
+ }
result_code = IsRenamed(ikey, dt_type, dmi, rename);
if ((result_code != UPLL_RC_SUCCESS) || !ikey->get_cfg_val()) {
- UPLL_LOG_DEBUG("Invalid param %d\n", result_code);
+ UPLL_LOG_DEBUG("Invalid param %d", result_code);
return UPLL_RC_ERR_GENERIC;
}
if (!ctrlr_dom->ctrlr ||
!strlen(reinterpret_cast<const char *>(ctrlr_dom->domain))) {
GET_USER_DATA_CTRLR_DOMAIN(ikey->get_cfg_val(), *ctrlr_dom);
}
- if (rename == 0) return UPLL_RC_SUCCESS;
+#if 0
+ controller_domain ctrlr_dom_dup;
+ ctrlr_dom_dup.ctrlr = NULL;
+ ctrlr_dom_dup.domain = NULL;
+ uuu::upll_strncpy(ctrlr_dom_dup.ctrlr, ctrlr_dom->ctrlr,
+ (kMaxLenCtrlrId + 1));
+ uuu::upll_strncpy(ctrlr_dom_dup.domain, ctrlr_dom->domain,
+ (kMaxLenDomainId + 1));
+#endif
+ val_vlink_t *val = reinterpret_cast<val_vlink_t *>(GetVal(ikey));
+ if (!val) {
+ UPLL_LOG_DEBUG("Val Structure is Error");
+ return UPLL_RC_ERR_GENERIC;
+ }
- result_code = GetChildConfigKey(okey, ikey);
- if (result_code != UPLL_RC_SUCCESS)
- return result_code;
+ GET_USER_DATA_FLAGS(ikey->get_cfg_val(), val_rename);
+ okey = NULL;
+ if (val_rename) {
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>
+ (GetMoManager(UNC_KT_VBRIDGE)));
+ if (!mgr) {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_TRACE("The Vnode RenameFlag is %d", val_rename);
+ if (val_rename & 0x04) { /* vnode renamed*/
+ vnode_rename = 0x80;
+ SET_USER_DATA_FLAGS(ikey->get_cfg_val(), vnode_rename);
+ result_code = mgr->GetChildConfigKey(okey, ikey);
+ if (UPLL_RC_SUCCESS != result_code)
+ return result_code;
+ result_code = mgr->GetRenamedControllerKey(okey, dt_type,
+ dmi, ctrlr_dom);
+ if (UPLL_RC_SUCCESS == result_code) {
+ UPLL_LOG_TRACE("The ConfigKey is %s", (okey->ToStrAll()).c_str());
+ UPLL_LOG_TRACE("The controller vnode name is %s",
+ reinterpret_cast<key_vbr_t *>(
+ okey->get_key())->vbridge_name);
+ uuu::upll_strncpy(val->vnode1_name, reinterpret_cast<key_vbr_t *>(
+ okey->get_key())->vbridge_name, (kMaxLenVnodeName+1));
+ } else {
+ UPLL_LOG_DEBUG("GetRenamedControllerKey failed. Result : %d",
+ result_code);
+ delete okey;
+ return result_code;
+ }
+ }
+ if (okey)
+ delete okey;
+ okey = NULL;
+ UPLL_LOG_TRACE("The Vnode RenameFlag is %d", val_rename);
+ if (val_rename & 0x08) {
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>
+ (GetMoManager(UNC_KT_VROUTER)));
+ if (!mgr) {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ vnode_rename = 0x40;
+ SET_USER_DATA_FLAGS(ikey->get_cfg_val(), vnode_rename);
+
+ result_code = mgr->GetChildConfigKey(okey, ikey);
+ if (UPLL_RC_SUCCESS != result_code)
+ return result_code;
+ UPLL_LOG_DEBUG("Test : Controller %s Domain %s",
+ ctrlr_dom->ctrlr, ctrlr_dom->domain);
+ result_code = mgr->GetRenamedControllerKey(okey, dt_type,
+ dmi, ctrlr_dom);
+ if (UPLL_RC_SUCCESS == result_code) {
+ UPLL_LOG_TRACE("The ConfigKey is %s", (okey->ToStrAll()).c_str());
+ UPLL_LOG_TRACE("The controller vnode name is %s",
+ reinterpret_cast<key_vrt_t *>(
+ okey->get_key())->vrouter_name);
+ uuu::upll_strncpy(val->vnode2_name, reinterpret_cast<key_vrt_t *>(
+ okey->get_key())->vrouter_name,
+ (kMaxLenVnodeName+1));
+ } else {
+ UPLL_LOG_DEBUG("GetRenamedControllerKey failed. Result : %d",
+ result_code);
+ delete okey;
+ return result_code;
+ }
+ }
+ }
+
+ if (rename == 0) {
+ delete okey;
+ return UPLL_RC_SUCCESS;
+ }
+ if (okey)
+ delete okey;
if ((ctrlr_dom->ctrlr == NULL) || (ctrlr_dom->domain == NULL)) {
- UPLL_LOG_INFO("Invalid ctrlr/domain\n");
+ UPLL_LOG_INFO("Invalid ctrlr/domain");
return UPLL_RC_ERR_GENERIC;
}
+ okey = NULL;
+ result_code = GetChildConfigKey(okey, ikey);
+ if (result_code != UPLL_RC_SUCCESS)
+ return result_code;
+ UPLL_LOG_DEBUG("Test : Controller %s Domain %s",
+ ctrlr_dom->ctrlr, ctrlr_dom->domain);
SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
- DbSubOp dbop = { kOpReadSingle, kOpMatchFlag | kOpMatchCtrlr, kOpInOutFlag
- | kOpInOutCtrlr };
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr|kOpMatchDomain, kOpInOutFlag };
result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi, RENAMETBL);
- if (result_code != UPLL_RC_SUCCESS) return result_code;
+ if (result_code != UPLL_RC_SUCCESS) {
+ delete okey;
+ return result_code;
+ }
val_db_rename_vlink *rename_val = reinterpret_cast<val_db_rename_vlink *>
(GetVal(okey));
- if (!rename_val) return UPLL_RC_ERR_GENERIC;
+ if (!rename_val) {
+ delete okey;
+ return UPLL_RC_ERR_GENERIC;
+ }
key_vlink *ctrlr_key = reinterpret_cast<key_vlink *>(ikey->get_key());
- if (!ctrlr_key) return UPLL_RC_ERR_GENERIC;
- memset(ctrlr_key, 0, sizeof(key_vlink));
+ if (!ctrlr_key) {
+ delete okey;
+ return UPLL_RC_ERR_GENERIC;
+ }
if (rename & 0x01) { /* vtn renamed */
uuu::upll_strncpy(ctrlr_key->vtn_key.vtn_name, rename_val->ctrlr_vtn_name,
(kMaxLenVtnName+1));
}
- if (rename & 0x10) { /* vnode renamed */
+ if (rename & 0x02) { /* vnode renamed */
uuu::upll_strncpy(ctrlr_key->vlink_name, rename_val->ctrlr_vlink_name,
(kMaxLenVlinkName+1));
}
SET_USER_DATA_FLAGS(ikey, rename);
- delete okey;
+
+ SET_USER_DATA_FLAGS(ikey->get_cfg_val(), val_rename);
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_SUCCESS;
}
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
val_vlink *vlink_val;
- val_db_vlink_st *val_vlinkst;
+ val_vlink *vlink_val2 = NULL;
unc_keytype_configstatus_t cs_status =
(driver_result == UPLL_RC_SUCCESS) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
vlink_val = reinterpret_cast<val_vlink *>(GetVal(vlink_key));
if (vlink_val == NULL) return UPLL_RC_ERR_GENERIC;
if (op == UNC_OP_CREATE) {
- val_vlinkst = reinterpret_cast<val_db_vlink_st *>
- (malloc(sizeof(val_db_vlink_st)));
- memset(val_vlinkst, 0, sizeof(val_db_vlink_st));
- val_vlinkst->vlink_val_st.oper_status = UPLL_OPER_STATUS_UNINIT;
- val_vlinkst->down_count = 0;
- val_vlinkst->vlink_val_st.valid[UPLL_IDX_OPER_STATUS_VLNKS]
- = UNC_VF_INVALID;
- vlink_key->AppendCfgVal(IpctSt::kIpcStValVlinkSt, val_vlinkst);
vlink_val->cs_row_status = cs_status;
} else if (op == UNC_OP_UPDATE) {
- void *updval = reinterpret_cast<val_vlink *> (GetVal(upd_key));
- CompareValidValue(updval, vlink_val, true);
+ void *inpval = GetVal(vlink_key);
+ CompareValidValue(inpval, GetVal(upd_key), true);
+ vlink_val2 = reinterpret_cast<val_vlink *>(GetVal(upd_key));
+ vlink_val->cs_row_status = vlink_val2->cs_row_status;
} else {
return UPLL_RC_ERR_GENERIC;
}
+ val_db_vlink_st *val_vlinkst = reinterpret_cast<val_db_vlink_st *>
+ (ConfigKeyVal::Malloc(sizeof(val_db_vlink_st)));
+ val_vlinkst->vlink_val_st.oper_status = UPLL_OPER_STATUS_UNINIT;
+ val_vlinkst->vlink_val_st.valid[UPLL_IDX_OPER_STATUS_VLNKS]
+ = UNC_VF_VALID;
+ if (op == UNC_OP_CREATE) {
+ val_vlinkst->down_count = 0;
+ } else {
+ val_db_vlink_st *run_vlink_st = reinterpret_cast<val_db_vlink_st *>
+ (GetStateVal(upd_key));
+ val_vlinkst->down_count = (run_vlink_st ? run_vlink_st->down_count:0);
+ }
+ vlink_key->AppendCfgVal(IpctSt::kIpcStValVlinkSt, val_vlinkst);
+ UPLL_LOG_TRACE("%s", (vlink_key->ToStrAll()).c_str());
for ( unsigned int loop = 0;
loop < sizeof(vlink_val->valid)/sizeof(vlink_val->valid[0]);
++loop ) {
- // Setting CS to the not supported attributes
- if (UNC_VF_NOT_SOPPORTED == vlink_val->valid[loop]) {
- vlink_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
- continue;
- }
if ( (UNC_VF_VALID == vlink_val->valid[loop]) ||
- (UNC_VF_VALID_NO_VALUE == vlink_val->valid[loop]))
+ (UNC_VF_VALID_NO_VALUE == vlink_val->valid[loop])) {
+ // Description is set to APPLIED
+ if (loop == UPLL_IDX_DESCRIPTION_VLNK)
+ vlink_val->cs_attr[loop] = UNC_CS_APPLIED;
+ else
vlink_val->cs_attr[loop] = cs_status;
+ } else if ((UNC_VF_INVALID == vlink_val->valid[loop]) &&
+ (UNC_OP_CREATE == op)) {
+ vlink_val->cs_attr[loop] = UNC_CS_APPLIED;
+ } else if ((UNC_VF_INVALID == vlink_val->valid[loop]) &&
+ (UNC_OP_UPDATE == op)) {
+ vlink_val->cs_attr[loop] = vlink_val2->cs_attr[loop];
+ }
}
SetConsolidatedStatus(vlink_key, op, cs_status, dmi);
return result_code;
result_code = mgr->GetRenamedUncKey(pkey, UPLL_DT_IMPORT, dmi, ctrlr);
if (UPLL_RC_SUCCESS != result_code
&& UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ delete pkey;
+ pkey = NULL;
free(key_vlink);
return result_code;
}
(ikey->get_key());
key_vlink_t * key_vlink = reinterpret_cast<key_vlink_t *>(
ConfigKeyVal::Malloc(sizeof(key_vlink_t)));
- UPLL_LOG_TRACE("Table is MainTable ");
+ UPLL_LOG_TRACE("Table is MainTable ");
if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vtn_name))) {
FREE_IF_NOT_NULL(key_vlink);
return UPLL_RC_ERR_GENERIC;
}
-
+
uuu::upll_strncpy(key_vlink->vtn_key.vtn_name,
key_rename->old_unc_vtn_name, (kMaxLenVtnName+1));
}
uuu::upll_strncpy(key_vlink->vlink_name,
key_rename->old_unc_vnode_name, (kMaxLenVlinkName+1));
- }
+ }
okey = new ConfigKeyVal(UNC_KT_VLINK, IpctSt::kIpcStKeyVlink, key_vlink,
NULL);
if (!okey) {
result_code = GetChildConfigKey(tmp_key, ikey);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetChildConfigKey Failed ");
+ free(vnode); // COV RESOURCE LEAK
return result_code;
}
DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain};
MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("ReadConfigDB Failed");
+ free(vnode); // COV RESOURCE LEAK
+ delete tmp_key;
return result_code;
}
controller_domain ctrlr_dom;
result_code = GetControllerDomainId(tmp_key, &ctrlr_dom);
- if (UPLL_RC_SUCCESS != result_code)
+ if (UPLL_RC_SUCCESS != result_code) {
+ delete tmp_key;
return result_code;
+ }
SET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
vnode->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
key_rename_vnode_info *rename_info_ =
reinterpret_cast<key_rename_vnode_info *>(
rename_info->get_key());
- if (!rename_info_){
+ if (!rename_info_) {
UPLL_LOG_DEBUG("Rename Info is Empty");
return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_TRACE("Rename NoRename Falg = %d", no_rename);
GetChildConfigKey(okey, NULL);
- if (!okey || !(okey->get_key())) {
+ if (!okey || !(okey->get_key())) {
UPLL_LOG_TRACE("GetChildConfigKey Failed ");
free(val_vlink_);
+ if (okey) delete okey;
return UPLL_RC_ERR_GENERIC;
}
okey->SetCfgVal(new ConfigVal(IpctSt::kIpcStValVlink, val_vlink_));
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutFlag|kOpInOutCtrlr|kOpInOutDomain };
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone,
+ kOpInOutFlag|kOpInOutCtrlr|kOpInOutDomain };
key_vlink_ = reinterpret_cast<key_vlink_t *>(okey->get_key());
result_code = ReadConfigDB(okey, data_type, UNC_OP_READ, dbop, dmi, MAINTBL);
if (UPLL_RC_SUCCESS == result_code) {
+ ConfigKeyVal *tmp = okey;
while (okey) {
val_vlink_ = reinterpret_cast<val_vlink_t *>(GetVal(okey));
- UPLL_LOG_TRACE("After Read ConfigDB in Vlink %s", (okey->ToStrAll()).c_str());
+ UPLL_LOG_TRACE("After Read ConfigDB in Vlink %s",
+ (okey->ToStrAll()).c_str());
- GET_USER_DATA_FLAGS(okey, rename);
+ GET_USER_DATA_FLAGS(okey->get_cfg_val(), rename);
UPLL_LOG_TRACE("Rename No Rename %d", no_rename);
UPLL_LOG_TRACE("Before Update Rename flag =%d", rename);
rename = rename & NO_VN1_RENAME;
UPLL_LOG_TRACE("After Update Rename flag =%d", rename);
- SET_USER_DATA_FLAGS(okey, rename);
+ SET_USER_DATA_FLAGS(okey->get_cfg_val(), rename);
uuu::upll_strncpy(val_vlink_->vnode1_name,
rename_info_->new_unc_vnode_name, (kMaxLenVnodeName+1));
UPLL_LOG_TRACE("The New vnode name %s", val_vlink_->vnode1_name);
- UPLL_LOG_TRACE("Before Update ConfigDB in Vlink %s", (okey->ToStrAll()).c_str());
+ UPLL_LOG_TRACE("Before Update ConfigDB in Vlink %s",
+ (okey->ToStrAll()).c_str());
dbop.readop = kOpNotRead;
- dbop.inoutop = kOpInOutFlag ;
+ dbop.inoutop = kOpInOutFlag;
result_code = UpdateConfigDB(okey, data_type, UNC_OP_UPDATE, dmi,
&dbop, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) return result_code;
okey = okey->get_next_cfg_key_val();
}
- if (okey) {
- delete okey;
+ if (tmp) {
+ delete tmp;
}
return result_code;
}
result_code = ReadConfigDB(okey, data_type, UNC_OP_READ, dbop, dmi, MAINTBL);
if (UPLL_RC_SUCCESS == result_code) {
+ ConfigKeyVal *temp = okey;
while (okey) {
val_vlink_ = reinterpret_cast<val_vlink_t *>(GetVal(okey));
- GET_USER_DATA_FLAGS(okey, rename);
+ GET_USER_DATA_FLAGS(okey->get_cfg_val(), rename);
UPLL_LOG_TRACE("Rename No Rename %d", no_rename);
UPLL_LOG_TRACE("Before Update Rename flag =%d", rename);
UPLL_LOG_TRACE("After Update Rename flag =%d", rename);
- SET_USER_DATA_FLAGS(okey, rename);
+ SET_USER_DATA_FLAGS(okey->get_cfg_val(), rename);
uuu::upll_strncpy(val_vlink_->vnode2_name,
rename_info_->new_unc_vnode_name, (kMaxLenVnodeName+1));
dbop.readop = kOpNotRead;
- dbop.inoutop = kOpInOutFlag ;
+ dbop.inoutop = kOpInOutFlag;
result_code = UpdateConfigDB(okey, data_type, UNC_OP_UPDATE, dmi,
&dbop, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) return result_code;
okey = okey->get_next_cfg_key_val();
}
+ if (temp) {
+ delete temp;
+ }
}
- if (okey) {
+ if (okey)
delete okey;
- }
return result_code;
}
IpcResponse ipc_resp;
key_boundary *bndrykey = static_cast<key_boundary *>
- (malloc(sizeof(key_boundary)));
+ (ConfigKeyVal::Malloc(sizeof(key_boundary))); // COV NULL RETURN
uuu::upll_strncpy(bndrykey->boundary_id, boundary_name,
(kMaxLenBoundaryName+1));
result_code = SendIpcReq(req->clnt_sess_id, req->config_id, UNC_OP_READ,
UPLL_DT_CANDIDATE, ck_boundary, NULL, &ipc_resp);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Error in retrieving boundary data %d\n", result_code);
+ UPLL_LOG_DEBUG("Error in retrieving boundary data %d", result_code);
delete ck_boundary;
ck_boundary = NULL;
return UPLL_RC_ERR_GENERIC;
if (ipc_resp.ckv_data)
ck_boundary->ResetWith(ipc_resp.ckv_data);
else
- UPLL_LOG_DEBUG("Boundary information not obtained from physical\n");
+ UPLL_LOG_DEBUG("Boundary information not obtained from physical");
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
return result_code;
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone };
key_vlink_t *vlink_key = reinterpret_cast<key_vlink_t *>
- (malloc(sizeof(key_vlink)));
- if (!vlink_key) {
- UPLL_LOG_DEBUG("Memory Allocation Failed");
- return UPLL_RC_ERR_GENERIC;
- }
- memset(vlink_key, 0, sizeof(key_vlink));
+ (ConfigKeyVal::Malloc(sizeof(key_vlink)));
val_vlink_t *linkval = static_cast<val_vlink_t *>
- (malloc(sizeof(val_vlink_t)));
- if (!linkval) {
- UPLL_LOG_DEBUG("Invalid memory allocation\n");
- free(vlink_key);
- return UPLL_RC_ERR_GENERIC;
- }
- memset(linkval, 0, sizeof(val_vlink_t));
+ (ConfigKeyVal::Malloc(sizeof(val_vlink_t)));
key_boundary *bndrykey = reinterpret_cast<key_boundary *>(ckv->get_key());
if (!strlen(reinterpret_cast<const char *>(bndrykey->boundary_id))) {
free(linkval);
return UPLL_RC_ERR_GENERIC;
}
if (uuc::kUpllUcpCreate == phase) val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
for (unsigned int loop = 0; loop < sizeof(val->valid) / sizeof(uint8_t);
++loop) {
if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
return false;
}
-bool VlinkMoMgr::CompareValidValue(void *&val1, void *val2, bool copy_to_running) {
+bool VlinkMoMgr::CompareValidValue(void *&val1, void *val2,
+ bool copy_to_running) {
UPLL_FUNC_TRACE;
bool invalid_attr = true;
val_vlink_t *val_vlink1 = reinterpret_cast<val_vlink_t *>(val1);
&& UNC_VF_VALID == val_vlink2->valid[loop])
val_vlink1->valid[loop] = UNC_VF_VALID_NO_VALUE;
}
- val_vlink1->valid[UPLL_IDX_DESCRIPTION_VLNK] = UNC_VF_INVALID;
- if (UNC_VF_VALID == val_vlink1->valid[UPLL_IDX_ADMIN_STATUS_VLNK]
- && UNC_VF_VALID == val_vlink2->valid[UPLL_IDX_ADMIN_STATUS_VLNK]) {
+ if (UNC_VF_INVALID != val_vlink1->valid[UPLL_IDX_DESCRIPTION_VLNK]) {
+ if ((!copy_to_running) ||
+ ((UNC_VF_VALID == val_vlink1->valid[UPLL_IDX_DESCRIPTION_VLNK]) &&
+ (!strcmp(reinterpret_cast<char*>(val_vlink1->description),
+ reinterpret_cast<char*>(val_vlink2->description)))))
+ val_vlink1->valid[UPLL_IDX_DESCRIPTION_VLNK] = UNC_VF_INVALID;
+ }
+ if ((val_vlink2->valid[UPLL_IDX_ADMIN_STATUS_VLNK] ==
+ val_vlink1->valid[UPLL_IDX_ADMIN_STATUS_VLNK])
+ && UNC_VF_INVALID != val_vlink2->valid[UPLL_IDX_ADMIN_STATUS_VLNK]) {
if (val_vlink1->admin_status == val_vlink2->admin_status)
val_vlink1->valid[UPLL_IDX_ADMIN_STATUS_VLNK] = UNC_VF_INVALID;
}
}
if (UNC_VF_VALID == val_vlink1->valid[UPLL_IDX_VLAN_ID_VLNK]
&& UNC_VF_VALID == val_vlink2->valid[UPLL_IDX_VLAN_ID_VLNK]) {
- if (val_vlink1->vlan_id != val_vlink2->vlan_id)
+ if (val_vlink1->vlan_id == val_vlink2->vlan_id)
val_vlink1->valid[UPLL_IDX_VLAN_ID_VLNK] = UNC_VF_INVALID;
}
for (unsigned int loop = 0;
}
upll_rc_t VlinkMoMgr::ValidateMessage(IpcReqRespHeader *req,
- ConfigKeyVal *ikey) {
+ ConfigKeyVal *ikey) {
UPLL_FUNC_TRACE;
upll_rc_t ret_val = UPLL_RC_SUCCESS;
if (!ikey || !req || !(ikey->get_key())) {
unc_keytype_option2_t option2 = req->option2;
if (ikey->get_st_num() != IpctSt::kIpcStKeyVlink) {
UPLL_LOG_DEBUG(
- "Invalid structure received.Expected struct-kIpcStKeyVlink, "
- "received struct -%d ",
- ((ikey->get_st_num())));
+ "Invalid structure received.Expected struct-kIpcStKeyVlink, "
+ "received struct -%d ",
+ ((ikey->get_st_num())));
return UPLL_RC_ERR_BAD_REQUEST;
}
key_vlink_t *key_vlink = reinterpret_cast<key_vlink_t *>(ikey->get_key());
val_vlink_t *val_vlink = NULL;
val_rename_vlink_t *val_rename_vlink = NULL;
if ((ikey->get_cfg_val())
- && ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVlink)) {
+ && ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVlink)) {
val_vlink =
- reinterpret_cast<val_vlink_t *>(ikey->get_cfg_val()->get_val());
+ reinterpret_cast<val_vlink_t *>(ikey->get_cfg_val()->get_val());
} else if ((ikey->get_cfg_val()) &&
- ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValRenameVlink)) {
- val_rename_vlink =
- reinterpret_cast<val_rename_vlink_t *>(ikey->get_cfg_val()->get_val());
+ ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValRenameVlink)) {
+ val_rename_vlink =
+ reinterpret_cast<val_rename_vlink_t *>(ikey->get_cfg_val()->get_val());
}
if ((operation == UNC_OP_CREATE) &&
(dt_type == UPLL_DT_CANDIDATE || dt_type == UPLL_DT_IMPORT)) {
}
return UPLL_RC_SUCCESS;
} else if ((operation == UNC_OP_UPDATE) &&
- (dt_type == UPLL_DT_CANDIDATE)) {
+ (dt_type == UPLL_DT_CANDIDATE)) {
if (val_vlink == NULL) {
UPLL_LOG_DEBUG("Value structure is mandatory for UPDATE op");
return UPLL_RC_ERR_BAD_REQUEST;
} else if ((operation == UNC_OP_RENAME) && (dt_type == UPLL_DT_IMPORT)) {
if (val_rename_vlink == NULL) {
UPLL_LOG_DEBUG("Value rename struct is mandatory for RENAME op");
- return UPLL_RC_ERR_BAD_REQUEST;
+ return UPLL_RC_ERR_BAD_REQUEST;
}
ret_val = ValidateRenameVlinkValue(val_rename_vlink);
if (ret_val != UPLL_RC_SUCCESS) {
}
return UPLL_RC_SUCCESS;
} else if ((operation == UNC_OP_READ || operation == UNC_OP_READ_SIBLING ||
- operation == UNC_OP_READ_SIBLING_BEGIN) &&
- (dt_type == UPLL_DT_IMPORT)) {
+ operation == UNC_OP_READ_SIBLING_BEGIN) &&
+ (dt_type == UPLL_DT_IMPORT)) {
if (option1 != UNC_OPT1_NORMAL) {
UPLL_LOG_DEBUG("option1 is not matching");
return UPLL_RC_ERR_INVALID_OPTION1;
}
if (val_rename_vlink == NULL) {
UPLL_LOG_DEBUG("val rename structure is an optional for READ op");
- return UPLL_RC_SUCCESS;
+ return UPLL_RC_SUCCESS;
}
ret_val = ValidateRenameVlinkValue(val_rename_vlink);
if (ret_val != UPLL_RC_SUCCESS) {
}
return UPLL_RC_SUCCESS;
} else if ((operation == UNC_OP_READ || operation == UNC_OP_READ_SIBLING ||
- operation == UNC_OP_READ_SIBLING_BEGIN) &&
- (dt_type == UPLL_DT_CANDIDATE || dt_type == UPLL_DT_RUNNING ||
- dt_type == UPLL_DT_STARTUP || dt_type == UPLL_DT_STATE)) {
+ operation == UNC_OP_READ_SIBLING_BEGIN) &&
+ (dt_type == UPLL_DT_CANDIDATE || dt_type == UPLL_DT_RUNNING ||
+ dt_type == UPLL_DT_STARTUP || dt_type == UPLL_DT_STATE)) {
if (option1 != UNC_OPT1_NORMAL) {
UPLL_LOG_DEBUG("option1 is not matching");
return UPLL_RC_ERR_INVALID_OPTION1;
(operation == UNC_OP_READ_NEXT) ||
(operation == UNC_OP_READ_BULK)) {
UPLL_LOG_DEBUG("Value structure validation is none for this operation :%d"
- , operation);
+ , operation);
return UPLL_RC_SUCCESS;
}
UPLL_LOG_DEBUG("Invalid datatype(%d) or operation(%d)", dt_type,
UPLL_FUNC_TRACE;
bool ret_val = UPLL_RC_SUCCESS;
UPLL_LOG_TRACE("Operation type :(%d)", operation);
-
+
if ((operation == UNC_OP_CREATE) &&
((val_vlink->valid[UPLL_IDX_VNODE1_NAME_VLNK] == UNC_VF_INVALID) ||
(val_vlink->valid[UPLL_IDX_VNODE1_NAME_VLNK] == UNC_VF_VALID_NO_VALUE)||
(val_vlink->valid[UPLL_IDX_VNODE2_IF_NAME_VLNK] ==
UNC_VF_VALID_NO_VALUE))) {
UPLL_LOG_DEBUG("Vlink node name/If name is mandatory "
- " for Create operation\n");
+ " for Create operation");
return UPLL_RC_ERR_CFG_SYNTAX;
}
if ((operation == UNC_OP_UPDATE) &&
(val_vlink->valid[UPLL_IDX_VNODE2_NAME_VLNK] != UNC_VF_INVALID) ||
(val_vlink->valid[UPLL_IDX_VNODE2_IF_NAME_VLNK] != UNC_VF_INVALID))) {
UPLL_LOG_DEBUG("Vlink node name/If name must be invalid "
- " for Update operation\n");
+ " for Update operation");
return UPLL_RC_ERR_CFG_SYNTAX;
}
if (val_vlink->valid[UPLL_IDX_ADMIN_STATUS_VLNK] == UNC_VF_VALID) {
== UNC_VF_VALID_NO_VALUE)
&& ((operation == UNC_OP_UPDATE) || (operation == UNC_OP_CREATE))) {
val_vlink->admin_status = UPLL_ADMIN_ENABLE;
+ } else if ((val_vlink->valid[UPLL_IDX_ADMIN_STATUS_VLNK] == UNC_VF_INVALID)
+ && (operation == UNC_OP_CREATE)) {
+ val_vlink->admin_status = UPLL_ADMIN_ENABLE;
+ val_vlink->valid[UPLL_IDX_ADMIN_STATUS_VLNK] = UNC_VF_VALID_NO_VALUE;
}
if ((val_vlink->valid[UPLL_IDX_VNODE1_NAME_VLNK] == UNC_VF_VALID) &&
(!READ_OP(operation))) {
}
}
if (val_vlink->valid[UPLL_IDX_DESCRIPTION_VLNK] == UNC_VF_VALID) {
- ret_val = ValidateDesc(reinterpret_cast<char *>(val_vlink->description),
- kMinLenDescription, kMaxLenDescription);
- if (ret_val != UPLL_RC_SUCCESS) {
+ if (!ValidateDesc(val_vlink->description,
+ kMinLenDescription, kMaxLenDescription)) {
UPLL_LOG_DEBUG("Syntax check failed. description- (%s)",
val_vlink->description);
return UPLL_RC_ERR_CFG_SYNTAX;
val_vlink->vnode1_name);
return UPLL_RC_ERR_CFG_SYNTAX;
}
- }
+ }
if (val_vlink->valid[UPLL_IDX_VNODE1_IF_NAME_VLNK] == UNC_VF_VALID) {
ret_val = ValidateKey(reinterpret_cast<char *>(val_vlink->vnode1_ifname),
kMinLenInterfaceName, kMaxLenInterfaceName);
return UPLL_RC_SUCCESS;
}
-upll_rc_t VlinkMoMgr::ValVlinkAttributeSupportCheck(const char * crtlr_name,
- ConfigKeyVal *ikey,
- uint32_t operation) {
+upll_rc_t VlinkMoMgr::ValVlinkAttributeSupportCheck(val_vlink_t *val_vlink,
+ const uint8_t* attrs, unc_keytype_operation_t operation) {
UPLL_FUNC_TRACE;
- bool result_code = false;
- uint32_t instance_count = 0;
- uint32_t num_attrs = 0;
- const uint8_t *attrs = 0;
- if ((ikey->get_cfg_val())->get_st_num() != IpctSt::kIpcStValVlink) {
- UPLL_LOG_DEBUG(
- " Invalid structure received.Expected struct-kIpcStValVlink, "
- "received struct - %s ",
- reinterpret_cast<const char *>(IpctSt::GetIpcStdef(
- (ikey->get_cfg_val())->get_st_num())));
- return UPLL_RC_ERR_GENERIC;
- }
- val_vlink_t *val_vlink = NULL;
- if ((ikey->get_cfg_val())
- && ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVlink)) {
- val_vlink = reinterpret_cast<val_vlink_t *>(ikey->get_cfg_val()->get_val());
- }
- if (val_vlink != NULL) {
- switch (operation) {
- case UNC_OP_CREATE:
- UPLL_LOG_TRACE(" The Controller Name is %s", crtlr_name);
- result_code = GetCreateCapability(crtlr_name, ikey->get_key_type(),
- &instance_count, &num_attrs, &attrs);
- break;
-
- case UNC_OP_UPDATE:
- result_code = GetUpdateCapability(crtlr_name, ikey->get_key_type(),
- &num_attrs, &attrs);
- break;
-
- case UNC_OP_READ:
- case UNC_OP_READ_SIBLING:
- case UNC_OP_READ_SIBLING_BEGIN:
- result_code = GetReadCapability(crtlr_name, ikey->get_key_type(),
- &num_attrs, &attrs);
- break;
-
- default:
- UPLL_LOG_DEBUG("Invalid operation");
- break;
- }
- if (!result_code) {
- UPLL_LOG_DEBUG("key_type - %d is not supported by controller - %s",
- ikey->get_key_type(), crtlr_name);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
- }
- if ((val_vlink->valid[UPLL_IDX_ADMIN_STATUS_VLNK] == UNC_VF_VALID)
- || (val_vlink->valid[UPLL_IDX_ADMIN_STATUS_VLNK]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vlink::kCapAdminStatus] == 0) {
- val_vlink->valid[UPLL_IDX_ADMIN_STATUS_VLNK] = UNC_VF_NOT_SOPPORTED;
+ if ((val_vlink->valid[UPLL_IDX_ADMIN_STATUS_VLNK] == UNC_VF_VALID)
+ || (val_vlink->valid[UPLL_IDX_ADMIN_STATUS_VLNK]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vlink::kCapAdminStatus] == 0) {
+ val_vlink->valid[UPLL_IDX_ADMIN_STATUS_VLNK] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
UPLL_LOG_DEBUG(
"UPLL_IDX_ADMIN_STATUS_VLNK not supported in pfc controller");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
}
+ }
- if ((val_vlink->valid[UPLL_IDX_VNODE1_NAME_VLNK] == UNC_VF_VALID)
- || (val_vlink->valid[UPLL_IDX_VNODE1_NAME_VLNK] ==
- UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vlink::kCapVnode1Name] == 0) {
- val_vlink->valid[UPLL_IDX_VNODE1_NAME_VLNK] = UNC_VF_NOT_SOPPORTED;
+ if ((val_vlink->valid[UPLL_IDX_VNODE1_NAME_VLNK] == UNC_VF_VALID)
+ || (val_vlink->valid[UPLL_IDX_VNODE1_NAME_VLNK] ==
+ UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vlink::kCapVnode1Name] == 0) {
+ val_vlink->valid[UPLL_IDX_VNODE1_NAME_VLNK] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
UPLL_LOG_DEBUG(
"UPLL_IDX_VNODE1_NAME_VLNK not supported in pfc controller");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
}
+ }
- if ((val_vlink->valid[UPLL_IDX_VNODE1_IF_NAME_VLNK] == UNC_VF_VALID)
- || (val_vlink->valid[UPLL_IDX_VNODE1_IF_NAME_VLNK]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vlink::kCapVnode1IfName] == 0) {
- val_vlink->valid[UPLL_IDX_VNODE1_IF_NAME_VLNK] = UNC_VF_NOT_SOPPORTED;
+ if ((val_vlink->valid[UPLL_IDX_VNODE1_IF_NAME_VLNK] == UNC_VF_VALID)
+ || (val_vlink->valid[UPLL_IDX_VNODE1_IF_NAME_VLNK]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vlink::kCapVnode1IfName] == 0) {
+ val_vlink->valid[UPLL_IDX_VNODE1_IF_NAME_VLNK] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
UPLL_LOG_DEBUG(
"UPLL_IDX_VNODE1_IF_NAME_VLNK not supported in pfc controller");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
}
+ }
- if ((val_vlink->valid[UPLL_IDX_VNODE2_NAME_VLNK] == UNC_VF_VALID)
- || (val_vlink->valid[UPLL_IDX_VNODE2_NAME_VLNK] ==
- UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vlink::kCapVnode2Name] == 0) {
- val_vlink->valid[UPLL_IDX_VNODE2_NAME_VLNK] = UNC_VF_NOT_SOPPORTED;
+ if ((val_vlink->valid[UPLL_IDX_VNODE2_NAME_VLNK] == UNC_VF_VALID)
+ || (val_vlink->valid[UPLL_IDX_VNODE2_NAME_VLNK] ==
+ UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vlink::kCapVnode2Name] == 0) {
+ val_vlink->valid[UPLL_IDX_VNODE2_NAME_VLNK] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
UPLL_LOG_DEBUG(
"UPLL_IDX_VNODE2_NAME_VLNK not supported in pfc controller");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
}
+ }
- if ((val_vlink->valid[UPLL_IDX_VNODE2_IF_NAME_VLNK] == UNC_VF_VALID)
- || (val_vlink->valid[UPLL_IDX_VNODE2_IF_NAME_VLNK]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vlink::kCapVnode2IfName] == 0) {
- val_vlink->valid[UPLL_IDX_VNODE2_IF_NAME_VLNK] = UNC_VF_NOT_SOPPORTED;
+ if ((val_vlink->valid[UPLL_IDX_VNODE2_IF_NAME_VLNK] == UNC_VF_VALID)
+ || (val_vlink->valid[UPLL_IDX_VNODE2_IF_NAME_VLNK]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vlink::kCapVnode2IfName] == 0) {
+ val_vlink->valid[UPLL_IDX_VNODE2_IF_NAME_VLNK] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
UPLL_LOG_DEBUG(
"UPLL_IDX_VNODE2_IF_NAME_VLNK not supported in pfc controller");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
}
+ }
- if ((val_vlink->valid[UPLL_IDX_BOUNDARY_NAME_VLNK] == UNC_VF_VALID)
- || (val_vlink->valid[UPLL_IDX_BOUNDARY_NAME_VLNK]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vlink::kCapBoundaryName] == 0) {
- val_vlink->valid[UPLL_IDX_BOUNDARY_NAME_VLNK] = UNC_VF_NOT_SOPPORTED;
+ if ((val_vlink->valid[UPLL_IDX_BOUNDARY_NAME_VLNK] == UNC_VF_VALID)
+ || (val_vlink->valid[UPLL_IDX_BOUNDARY_NAME_VLNK]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vlink::kCapBoundaryName] == 0) {
+ val_vlink->valid[UPLL_IDX_BOUNDARY_NAME_VLNK] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
UPLL_LOG_DEBUG(
"UPLL_IDX_BOUNDARY_NAME_VLNK not supported in pfc controller");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
}
+ }
- if ((val_vlink->valid[UPLL_IDX_VLAN_ID_VLNK] == UNC_VF_VALID)
- || (val_vlink->valid[UPLL_IDX_VLAN_ID_VLNK] == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vlink::kCapVlanId] == 0) {
- val_vlink->valid[UPLL_IDX_VLAN_ID_VLNK] = UNC_VF_NOT_SOPPORTED;
+ if ((val_vlink->valid[UPLL_IDX_VLAN_ID_VLNK] == UNC_VF_VALID)
+ || (val_vlink->valid[UPLL_IDX_VLAN_ID_VLNK] == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vlink::kCapVlanId] == 0) {
+ val_vlink->valid[UPLL_IDX_VLAN_ID_VLNK] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
UPLL_LOG_DEBUG("UPLL_IDX_VLAN_ID_VLNK not supported in pfc controller");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
}
- } else {
- UPLL_LOG_DEBUG("value structure is empty");
- return UPLL_RC_ERR_GENERIC;
}
- UPLL_LOG_TRACE("ValVlink attributes are supported in PFC controller");
+ if ((val_vlink->valid[UPLL_IDX_DESCRIPTION_VLNK] == UNC_VF_VALID)
+ || (val_vlink->valid[UPLL_IDX_DESCRIPTION_VLNK] ==
+ UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vlink::kCapDesc] == 0) {
+ val_vlink->valid[UPLL_IDX_DESCRIPTION_VLNK] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("UPLL_IDX_DESCRIPTION_VLNK not supported "
+ "in pfc controller");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ }
+
return UPLL_RC_SUCCESS;
}
upll_rc_t VlinkMoMgr::ValidateCapability(IpcReqRespHeader *req,
- ConfigKeyVal *ikey,
- const char *ctrlr_name) {
+ ConfigKeyVal *ikey,
+ const char *ctrlr_name) {
UPLL_FUNC_TRACE;
- upll_rc_t ret_val = UPLL_RC_SUCCESS;
-
- /* controller name */
- if (!ctrlr_name)
- ctrlr_name = reinterpret_cast<char *>(ikey->get_user_data());
+ if (!ikey || !req) {
+ UPLL_LOG_DEBUG("ConfigKeyVal / IpcReqRespHeader is Null");
+ return UPLL_RC_ERR_GENERIC;
+ }
- upll_keytype_datatype_t dt_type = req->datatype;
- unc_keytype_operation_t operation = req->operation;
- unc_keytype_option1_t option1 = req->option1;
- unc_keytype_option2_t option2 = req->option2;
- UPLL_LOG_TRACE("dt_type : (%d), "
- "operation : (%d), "
- "option1 : (%d), "
- "option2 : (%d)",
- dt_type, operation, option1, option2);
- if (((operation == UNC_OP_CREATE) || (operation == UNC_OP_UPDATE))
- && (dt_type == UPLL_DT_CANDIDATE)) {
- if ((GetVal(ikey)) != NULL) {
- ret_val = ValVlinkAttributeSupportCheck(ctrlr_name, ikey, operation);
- if (ret_val == UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("Attribute validation success for "
- "VLINK value structure");
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Attribute validation failure for "
- " VLINK value structure");
- return UPLL_RC_ERR_GENERIC;
- }
- } else {
- UPLL_LOG_INFO("Value structure mandatory for the CREATE operation");
+ if (!ctrlr_name) {
+ ctrlr_name = reinterpret_cast<char*>((reinterpret_cast<key_user_data_t *>
+ (ikey->get_user_data()))->ctrlr_id);
+ if (!ctrlr_name || !strlen(ctrlr_name)) {
+ UPLL_LOG_DEBUG("Controller Name is NULL");
return UPLL_RC_ERR_GENERIC;
}
+ }
- } else if (((operation == UNC_OP_READ) || (operation == UNC_OP_READ_SIBLING)
- || (operation == UNC_OP_READ_SIBLING_BEGIN))
- && ((dt_type == UPLL_DT_CANDIDATE) || (dt_type == UPLL_DT_RUNNING)
- || (dt_type == UPLL_DT_STARTUP))) {
- if (option1 == UNC_OPT1_NORMAL) {
- if (option2 == UNC_OPT2_NONE) {
- if ((GetVal(ikey)) != NULL) {
- ret_val = ValVlinkAttributeSupportCheck(ctrlr_name, ikey, operation);
- if (ret_val == UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("Attribute check success for VLINK value structure");
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_INFO("Attribute check failed for VLINK value structure");
- return UPLL_RC_ERR_GENERIC;
- }
- } else {
- UPLL_LOG_TRACE("Value structure is optional");
- return UPLL_RC_SUCCESS;
- }
- } else {
- UPLL_LOG_DEBUG("option2 is not matching");
- return UPLL_RC_ERR_INVALID_OPTION2;
+ UPLL_LOG_TRACE("ctrlr_name(%s), operation : (%d)",
+ ctrlr_name, req->operation);
+
+ bool result_code = false;
+ uint32_t max_instance_count = 0;
+ uint32_t max_attrs = 0;
+ const uint8_t *attrs = NULL;
+
+ switch (req->operation) {
+ case UNC_OP_CREATE:
+ UPLL_LOG_TRACE(" The Controller Name is %s", ctrlr_name);
+ result_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_instance_count, &max_attrs, &attrs);
+ if (result_code && (max_instance_count != 0) &&
+ (cur_instance_count >= max_instance_count)) {
+ UPLL_LOG_DEBUG("[%s:%d:%s max_instance_count %d exceeds %d", __FILE__,
+ __LINE__, __FUNCTION__, cur_instance_count,
+ max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
}
+
+ break;
+
+ case UNC_OP_UPDATE:
+ result_code = GetUpdateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ break;
+
+ case UNC_OP_READ:
+ case UNC_OP_READ_SIBLING:
+ case UNC_OP_READ_SIBLING_BEGIN:
+ case UNC_OP_READ_SIBLING_COUNT:
+ result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ break;
+
+ default:
+ UPLL_LOG_DEBUG("Invalid operation");
+ break;
+ }
+ if (!result_code) {
+ UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s) "
+ "for operation(%d)",
+ ikey->get_key_type(), ctrlr_name, req->operation);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ }
+ val_vlink_t *val_vlink = NULL;
+ if ((ikey->get_cfg_val())
+ && ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVlink)) {
+ val_vlink = reinterpret_cast<val_vlink_t *>(ikey->get_cfg_val()->get_val());
+ }
+
+ if (val_vlink) {
+ if (max_attrs > 0) {
+ return ValVlinkAttributeSupportCheck(val_vlink, attrs, req->operation);
} else {
- UPLL_LOG_DEBUG("option1 is not matching");
- return UPLL_RC_ERR_INVALID_OPTION1;
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d",
+ req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
- } else if ((operation == UNC_OP_DELETE)
- || (operation == UNC_OP_READ_SIBLING_COUNT)
- || (operation == UNC_OP_READ_NEXT) || (operation == UNC_OP_READ_BULK)) {
- UPLL_LOG_TRACE("Value structure is none for operation type:%d", operation);
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Invalid datatype(%d) and operation(%d)", dt_type,
- operation);
- return UPLL_RC_ERR_GENERIC;
}
return UPLL_RC_SUCCESS;
}
result_code = GetChildConfigKey(okey, ikey);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetChildConfigKey failed result code %d\n", result_code);
+ UPLL_LOG_DEBUG("GetChildConfigKey failed result code %d", result_code);
return result_code;
}
val_vlink_t *vlink_val = reinterpret_cast<val_vlink_t *>
- (malloc(sizeof(val_vlink_t)));
- if (!vlink_val) return UPLL_RC_ERR_GENERIC;
- memset(vlink_val, 0, sizeof(val_vlink_t));
+ (ConfigKeyVal::Malloc(sizeof(val_vlink_t)));
vlink_val->valid[UPLL_IDX_VNODE1_NAME_VLNK] = UNC_VF_VALID;
vlink_val->valid[UPLL_IDX_VNODE1_IF_NAME_VLNK] = UNC_VF_VALID;
vlink_val->valid[UPLL_IDX_VNODE2_NAME_VLNK] = UNC_VF_INVALID;
case UNC_KT_VBRIDGE:
case UNC_KT_VBR_IF:
if (!strlen(reinterpret_cast<char *>(reinterpret_cast<key_vbr_if_t*>
- (ikey->get_key())->vbr_key.vbridge_name)))
+ (ikey->get_key())->vbr_key.vbridge_name))) {
+ free(vlink_val); // COV RESOURCE LEAK
+ delete okey;
return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(vlink_val->vnode1_name,
reinterpret_cast<key_vbr_if_t*>(ikey->get_key())->
vbr_key.vbridge_name, (kMaxLenVnodeName+1));
if (!strlen(reinterpret_cast<char *>(reinterpret_cast<key_vbr_if_t*>
- (ikey->get_key())->if_name)))
+ (ikey->get_key())->if_name))) {
+ free(vlink_val); // COV RESOURCE LEAK
+ delete okey;
return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(vlink_val->vnode1_ifname,
reinterpret_cast<key_vbr_if_t*>(ikey->get_key())->if_name,
(kMaxLenInterfaceName+1));
if (!strlen(reinterpret_cast<char *>(reinterpret_cast<key_vbr_if_t*>
- (ikey->get_key())->vbr_key.vbridge_name)))
+ (ikey->get_key())->vbr_key.vbridge_name))) {
+ free(vlink_val); // COV RESOURCE LEAK
+ delete okey;
return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(vlink_val->vnode2_name, reinterpret_cast<key_vbr_if_t*>
(ikey->get_key())->vbr_key.vbridge_name,
(kMaxLenVnodeName+1));
if (!strlen(reinterpret_cast<char *>(reinterpret_cast<key_vbr_if_t*>
- (ikey->get_key())->if_name)))
+ (ikey->get_key())->if_name))) {
+ free(vlink_val); // COV RESOURCE LEAK
+ delete okey;
return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(vlink_val->vnode2_ifname,
reinterpret_cast<key_vbr_if_t*>(ikey->get_key())->if_name,
(kMaxLenInterfaceName+1));
case UNC_KT_VROUTER:
case UNC_KT_VRT_IF:
if (!strlen(reinterpret_cast<char *>(reinterpret_cast<key_vrt_if_t*>
- (ikey->get_key())->vrt_key.vrouter_name)))
+ (ikey->get_key())->vrt_key.vrouter_name))) {
+ free(vlink_val); // COV RESOURCE LEAK
+ delete okey;
return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(vlink_val->vnode1_name,
reinterpret_cast<key_vrt_if_t*>(ikey->get_key())->vrt_key.vrouter_name,
(kMaxLenVnodeName+1));
if (!strlen(reinterpret_cast<char *>(reinterpret_cast<key_vrt_if_t*>
- (ikey->get_key())->if_name)))
+ (ikey->get_key())->if_name))) {
+ free(vlink_val); // COV RESOURCE LEAK
+ delete okey;
return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(vlink_val->vnode1_ifname,
reinterpret_cast<key_vrt_if_t*>(ikey->get_key())->if_name,
(kMaxLenInterfaceName+1));
if (!strlen(reinterpret_cast<char *>(reinterpret_cast<key_vrt_if_t*>
- (ikey->get_key())->vrt_key.vrouter_name)))
+ (ikey->get_key())->vrt_key.vrouter_name))) {
+ free(vlink_val); // COV RESOURCE LEAK
+ delete okey;
return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(vlink_val->vnode2_name,
reinterpret_cast<key_vrt_if_t*>(ikey->get_key())->vrt_key.vrouter_name,
(kMaxLenVnodeName+1));
if (!strlen(reinterpret_cast<char *>(reinterpret_cast<key_vrt_if_t*>
- (ikey->get_key())->if_name)))
+ (ikey->get_key())->if_name))) {
+ free(vlink_val); // COV RESOURCE LEAK
+ delete okey;
return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(vlink_val->vnode2_ifname,
reinterpret_cast<key_vrt_if_t*>(ikey->get_key())->if_name,
(kMaxLenInterfaceName+1));
val = new ConfigVal(IpctSt::kIpcStValVlink, vlink_val);
if (!val) {
free(vlink_val);
+ delete okey; // COV RESOURCE LEAK
return UPLL_RC_ERR_GENERIC;
}
okey->SetCfgVal(val);
DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi, MAINTBL);
if (UPLL_RC_SUCCESS == result_code) {
+ delete okey;
return result_code;
}
vlink_val->valid[UPLL_IDX_VNODE1_NAME_VLNK] = UNC_VF_INVALID;
ConfigKeyVal *ck_vlink = NULL;
upll_rc_t result_code = GetChildConfigKey(ck_vlink, ikey);
if (!ck_vlink || result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Invalid param %d\n", result_code);
+ UPLL_LOG_DEBUG("Invalid param %d", result_code);
return result_code;
}
DbSubOp dbop1 = { kOpReadSingle, kOpMatchNone, kOpInOutFlag};
result_code = ReadConfigDB(ck_vlink, dt_type, UNC_OP_READ, dbop1,
dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Invalid param %d\n", result_code);
+ UPLL_LOG_DEBUG("Invalid param %d", result_code);
+ delete ck_vlink;
return result_code;
}
// uint8_t iftype, if1_type, if2_type;
/* reset the bits of the interfaces constituiing the vlink */
SET_USER_DATA_FLAGS(ck_vlink->get_cfg_val(), kVlinkVnode1);
for (int i = 0 ; i < 2; i++) {
+ bool executed = false;
unc_key_type_t ktype;
ktype = GetVlinkVnodeIfKeyType(ck_vlink, i);
- UPLL_LOG_DEBUG("Vlink Interface %d type : if1 %d \n", i, ktype);
+ UPLL_LOG_DEBUG("Vlink Interface %d type : if1 %d", i, ktype);
if (ktype == UNC_KT_ROOT) {
- UPLL_LOG_DEBUG("Invalid param\n");
+ UPLL_LOG_DEBUG("Invalid param");
+ delete ck_vlink;
return UPLL_RC_ERR_GENERIC;
}
MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>
ConfigKeyVal *ck_vnif = NULL;
result_code = mgr->GetChildConfigKey(ck_vnif, ck_vlink);
if (!ck_vnif || result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ delete ck_vlink;
+ return result_code;
}
result_code = mgr->ReadConfigDB(ck_vnif, dt_type, UNC_OP_READ,
dbop1, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returing error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returing error %d", result_code);
delete ck_vnif;
+ delete ck_vlink;
return result_code;
}
GET_USER_DATA_FLAGS(ck_vnif, if_flag);
SET_USER_DATA_FLAGS(ck_vnif, if_flag);
vnode_if_type vnif_type;
result_code = UpdateVlinkMemIfFlag(dt_type, ck_vnif, dmi,
- vnif_type, mgr,UNC_OP_DELETE);
+ vnif_type, mgr, UNC_OP_DELETE);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
delete ck_vnif;
+ delete ck_vlink;
return result_code;
}
- UPLL_LOG_DEBUG("Reset bit for iftype %d\n", vnif_type);
- if (ktype == UNC_KT_VBR_IF) {
- val_drv_vbr_if *val_drv_vbr = reinterpret_cast<val_drv_vbr_if *>
+ UPLL_LOG_DEBUG("Reset bit for iftype %d", vnif_type);
+ switch (ktype) {
+ case UNC_KT_VBR_IF: {
+ val_drv_vbr_if *val_drv_vbr = reinterpret_cast<val_drv_vbr_if *>
(GetVal(ck_vnif));
- if (val_drv_vbr == NULL) {
- UPLL_LOG_DEBUG("Invalid param\n");
- return UPLL_RC_ERR_GENERIC;
+ if (val_drv_vbr == NULL) {
+ UPLL_LOG_DEBUG("Invalid param");
+ delete ck_vnif;
+ delete ck_vlink;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (val_drv_vbr->vbr_if_val.valid[UPLL_IDX_PM_VBRI] == UNC_VF_VALID) {
+ executed = true;
+ val_drv_vbr->vbr_if_val.valid[UPLL_IDX_PM_VBRI] =
+ UNC_VF_VALID_NO_VALUE;
+ val_drv_vbr->vbr_if_val.valid[UPLL_IDX_ADMIN_STATUS_VBRI] =
+ UNC_VF_INVALID;
+ result_code = reinterpret_cast<VbrIfMoMgr *>(mgr)->
+ UpdateConfigVal(ck_vnif, dt_type, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning %d", result_code);
+ delete ck_vnif;
+ delete ck_vlink;
+ return result_code;
+ }
+ }
+ break;
}
- if (val_drv_vbr->vbr_if_val.valid[UPLL_IDX_PM_VBRI] == UNC_VF_VALID) {
- val_drv_vbr->vbr_if_val.valid[UPLL_IDX_PM_VBRI] = UNC_VF_VALID_NO_VALUE;
- result_code = reinterpret_cast<VbrIfMoMgr *>(mgr)->
- UpdateConfigVal(ck_vnif, dt_type,dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning %d\n",result_code);
- return result_code;
+ case UNC_KT_VTEP_IF: {
+ val_vtep_if *vtepif_val = static_cast<val_vtep_if *>(GetVal(ck_vnif));
+ if (vtepif_val == NULL) {
+ UPLL_LOG_DEBUG("Invalid param");
+ delete ck_vnif;
+ delete ck_vlink;
+ return UPLL_RC_ERR_GENERIC;
}
- DbSubOp dbop = { kOpNotRead, kOpMatchNone, kOpInOutNone };
- result_code = mgr->UpdateConfigDB(ck_vnif, dt_type, UNC_OP_UPDATE,
- dmi, &dbop, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning %d\n",result_code);
- return result_code;
+ if (vtepif_val->valid[UPLL_IDX_PORT_MAP_VTEPI] == UNC_VF_VALID) {
+ executed = true;
+ vtepif_val->valid[UPLL_IDX_ADMIN_ST_VTEPI] = UNC_VF_INVALID;
+ vtepif_val->valid[UPLL_IDX_PORT_MAP_VTEPI] = UNC_VF_VALID_NO_VALUE;
+ result_code = reinterpret_cast<VtepIfMoMgr *>(mgr)->
+ UpdateConfigVal(ck_vnif, dt_type, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigVal returned %d", result_code);
+ delete ck_vnif;
+ delete ck_vlink;
+ return result_code;
+ }
+ }
+ break;
+ }
+ case UNC_KT_VTUNNEL_IF: {
+ val_vtunnel_if *vtunnelif_val = static_cast<val_vtunnel_if *>
+ (GetVal(ck_vnif));
+ if (vtunnelif_val == NULL) {
+ UPLL_LOG_DEBUG("Invalid param");
+ delete ck_vlink;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (vtunnelif_val->valid[UPLL_IDX_PORT_MAP_VTNL_IF] == UNC_VF_VALID) {
+ executed = true;
+ vtunnelif_val->valid[UPLL_IDX_PORT_MAP_VTNL_IF] =
+ UNC_VF_VALID_NO_VALUE;
+ vtunnelif_val->valid[UPLL_IDX_ADMIN_ST_VTNL_IF] = UNC_VF_INVALID;
+ result_code = reinterpret_cast<VtunnelIfMoMgr *>(mgr)->
+ UpdateConfigVal(ck_vnif, dt_type, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ delete ck_vnif;
+ delete ck_vlink;
+ UPLL_LOG_DEBUG("UpdateConfigVal returned %d", result_code);
+ return result_code;
+ }
}
+ break;
+ }
+ default:
+ UPLL_LOG_TRACE("No Portmap");
+ }
+ if (executed) {
+ DbSubOp dbop = { kOpNotRead, kOpMatchNone, kOpInOutNone };
+ result_code = mgr->UpdateConfigDB(ck_vnif, dt_type, UNC_OP_UPDATE,
+ dmi, &dbop, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning %d", result_code);
+ delete ck_vnif;
+ delete ck_vlink;
+ return result_code;
}
}
SET_USER_DATA_FLAGS(ck_vlink->get_cfg_val(), kVlinkVnode2);
upll_rc_t result_code = UPLL_RC_SUCCESS;
val_vlink *vlink_val = reinterpret_cast<val_vlink *>(GetVal(vlink));
bool bound_vlink = false;
+ int node_vunk_if = 0;
if (!vlink_val) {
- UPLL_LOG_DEBUG("Invalid param\n");
- return UPLL_RC_ERR_GENERIC;
- }
- uint8_t *ctrlr1 = NULL, *ctrlr2 = NULL;
- GET_USER_DATA_CTRLR(vlink,ctrlr1);
- GET_USER_DATA_CTRLR(vlink->get_cfg_val(),ctrlr2);
- if (!ctrlr1 || !ctrlr2) {
- UPLL_LOG_DEBUG("Invalid param\n");
+ UPLL_LOG_DEBUG("Invalid param");
return UPLL_RC_ERR_GENERIC;
}
- if (memcmp(ctrlr1,ctrlr2,kMaxLenCtrlrId+1))
- bound_vlink = true;
ConfigKeyVal *vnif[2] = {NULL, NULL};
- unc_keytype_configstatus_t if_cstatus[2];
+ unc_keytype_configstatus_t if_cstatus[2],
+ vlanid_cstatus[2] = {UNC_CS_UNKNOWN, UNC_CS_UNKNOWN};
VlinkNodePosition vnode_number = kVlinkVnode1;
- int i = 0;
uint8_t rename_flag = 0;
GET_USER_DATA_FLAGS(vlink->get_cfg_val(), rename_flag);
- do {
+ for (int i = 0; i < 2; i++) {
unc_key_type_t ktype = GetVlinkVnodeIfKeyType(vlink, i);
- MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>
- (GetMoManager(ktype)));
+ VnodeChildMoMgr *mgr = reinterpret_cast<VnodeChildMoMgr *>
+ (const_cast<MoManager*>
+ (GetMoManager(ktype)));
if (!mgr) {
- UPLL_LOG_DEBUG("Invalid mgr\n");
+ UPLL_LOG_DEBUG("Invalid mgr");
return UPLL_RC_ERR_GENERIC;
}
SET_USER_DATA_FLAGS(vlink->get_cfg_val(), vnode_number);
result_code = mgr->ReadConfigDB(vnif[i], UPLL_DT_STATE, UNC_OP_READ,
dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
return UPLL_RC_ERR_GENERIC;
}
- i++;
- vnode_number = (vnode_number == kVlinkVnode1)?kVlinkVnode2:kVlinkVnode1;
- } while (vnode_number != kVlinkVnode1);
+ vnode_number = kVlinkVnode2;
+ }
SET_USER_DATA_FLAGS(vlink->get_cfg_val(), rename_flag);
if (!GetVal(vnif[0]) ||!GetVal(vnif[1])) {
- UPLL_LOG_DEBUG("Returning error\n");
+ UPLL_LOG_DEBUG("Returning error");
return UPLL_RC_ERR_GENERIC;
}
- if (op == UNC_OP_CREATE) {
- /* update consolidated oper status */
- val_db_vbr_if_st *vnif1_st = reinterpret_cast<val_db_vbr_if_st *>
- (GetStateVal(vnif[0]));
- val_db_vbr_if_st *vnif2_st = reinterpret_cast<val_db_vbr_if_st *>
- (GetStateVal(vnif[1]));
+ if ((vnif[0]->get_key_type() == UNC_KT_VUNK_IF) ||
+ (vnif[1]->get_key_type() == UNC_KT_VUNK_IF)) {
+ bound_vlink = true;
+ if (vnif[0]->get_key_type() == UNC_KT_VUNK_IF)
+ node_vunk_if = 1;
+ if (vnif[1]->get_key_type() == UNC_KT_VUNK_IF)
+ node_vunk_if = 2;
+ } else {
+ uint8_t *ctrlr1 = NULL, *ctrlr2 = NULL, *dom1 = NULL, *dom2 = NULL;
+ GET_USER_DATA_CTRLR(vlink, ctrlr1);
+ GET_USER_DATA_DOMAIN(vlink, dom1);
+ GET_USER_DATA_CTRLR(vlink->get_cfg_val(), ctrlr2);
+ GET_USER_DATA_DOMAIN(vlink->get_cfg_val(), dom2);
+ if (!ctrlr1 || !ctrlr2 || !dom1 || !dom2) {
+ UPLL_LOG_DEBUG("Invalid param");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (strncmp(reinterpret_cast<char *>(ctrlr1),
+ reinterpret_cast<char *>(ctrlr2), kMaxLenCtrlrId+1) ||
+ strncmp(reinterpret_cast<char *>(dom1),
+ reinterpret_cast<char *>(dom2),kMaxLenDomainId+1))
+ bound_vlink = true;
+ }
+ if ((op == UNC_OP_CREATE) || (op == UNC_OP_UPDATE)) {
val_db_vlink_st *val_vlink_st = reinterpret_cast<val_db_vlink_st *>
(GetStateVal(vlink));
- val_oper_status oper_status[2];
-
- if ((vnif1_st->vbr_if_val_st.valid[UPLL_IDX_OPER_STATUS_VBRIS] !=
- UNC_VF_VALID) ||
- (vnif2_st->vbr_if_val_st.valid[UPLL_IDX_OPER_STATUS_VBRIS] !=
- UNC_VF_VALID)) {
- val_vlink_st->vlink_val_st.valid[UPLL_IDX_OPER_STATUS_VLNKS] =
- UNC_VF_INVALID;
- UPLL_LOG_DEBUG("Oper status not initlaized correctly\n");
- } else {
- oper_status[0] = (val_oper_status)vnif1_st->vbr_if_val_st.oper_status;
- oper_status[1] = (val_oper_status)vnif2_st->vbr_if_val_st.oper_status;
- if ((oper_status[0] == oper_status[1]) == UPLL_OPER_STATUS_UP)
- val_vlink_st->vlink_val_st.oper_status = UPLL_OPER_STATUS_UP;
- else if ((oper_status[0] == UPLL_OPER_STATUS_UNKNOWN) ||
- (oper_status[1] == UPLL_OPER_STATUS_UNKNOWN))
- val_vlink_st->vlink_val_st.oper_status = UPLL_OPER_STATUS_UNKNOWN;
- else if ((oper_status[0] == UPLL_OPER_STATUS_DOWN) ||
- (oper_status[1] == UPLL_OPER_STATUS_DOWN))
- val_vlink_st->vlink_val_st.oper_status = UPLL_OPER_STATUS_DOWN;
- val_vlink_st->vlink_val_st.valid[UPLL_IDX_OPER_STATUS_VLNKS] =
- UNC_VF_VALID;
- }
-
- /* update consolidated config status if boundary vlink */
+ UPLL_LOG_TRACE("updated vlink %s down_count %x\n",
+ vlink->ToStrAll().c_str(), val_vlink_st->down_count);
if (bound_vlink) {
- if_cstatus[0] = (unc_keytype_configstatus_t)
- (reinterpret_cast<val_vbr_if *>
- (GetVal(vnif[0]))->cs_row_status);
- if_cstatus[1] = (unc_keytype_configstatus_t)
- (reinterpret_cast<val_vbr_if *>
- (GetVal(vnif[1]))->cs_row_status);
+ unc_key_type_t if_ktype = vnif[0]->get_key_type();
+ unc_keytype_configstatus_t c_status = UNC_CS_UNKNOWN;
+ val_port_map *pm, *pm1, *pm2;
+ pm = pm1 = pm2 = NULL;
+ for (int if_type = 0; if_type < 2; if_type++) {
+ switch (if_ktype) {
+ case UNC_KT_VBR_IF: {
+ pm = &(reinterpret_cast<val_drv_vbr_if *>
+ (GetVal(vnif[if_type]))->vbr_if_val.portmap);
+ c_status = (unc_keytype_configstatus_t)
+ (reinterpret_cast<val_vbr_if *>
+ (GetVal(vnif[if_type]))->cs_row_status); }
+ break;
+ case UNC_KT_VTEP_IF: {
+ pm = &(reinterpret_cast<val_vtep_if *>
+ (GetVal(vnif[if_type]))->portmap);
+ c_status = (unc_keytype_configstatus_t)
+ (reinterpret_cast<val_vtep_if *>
+ (GetVal(vnif[if_type]))->cs_row_status); }
+ break;
+ case UNC_KT_VTUNNEL_IF: {
+ pm = &(reinterpret_cast<val_vtunnel_if *>
+ (GetVal(vnif[if_type]))->portmap);
+ c_status = (unc_keytype_configstatus_t)
+ (reinterpret_cast<val_vtunnel_if *>
+ (GetVal(vnif[if_type]))->cs_row_status); }
+ break;
+ case UNC_KT_VUNK_IF: {
+ c_status = (unc_keytype_configstatus_t)
+ (reinterpret_cast<val_vunk_if *>
+ (GetVal(vnif[if_type]))->cs_row_status); }
+ default:
+ break;
+ }
+ if (if_type == 0)
+ pm1 = static_cast<val_port_map *>(pm);
+ else
+ pm2 = static_cast<val_port_map *>(pm);
+ // Assign Configstatus
+ if_cstatus[if_type] = c_status;
+ if_ktype = vnif[1]->get_key_type();
+ }
+ if (pm1 && (pm1->valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID ||
+ pm1->valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID_NO_VALUE))
+ vlanid_cstatus[0] = (unc_keytype_configstatus_t)
+ (pm1->cs_attr[UPLL_IDX_VLAN_ID_PM]);
+ if (pm2 && (pm1->valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID ||
+ pm2->valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID_NO_VALUE))
+ vlanid_cstatus[1] = (unc_keytype_configstatus_t)
+ (pm2->cs_attr[UPLL_IDX_VLAN_ID_PM]);
+ if ((vlanid_cstatus[0] == UNC_CS_APPLIED) &&
+ (vlanid_cstatus[1] == UNC_CS_APPLIED))
+ vlink_val->cs_attr[UPLL_IDX_VLAN_ID_VLNK] = UNC_CS_APPLIED;
+ else if ((vlanid_cstatus[0] == UNC_CS_INVALID) ||
+ (vlanid_cstatus[1] == UNC_CS_INVALID))
+ vlink_val->cs_attr[UPLL_IDX_VLAN_ID_VLNK] = UNC_CS_INVALID;
+ else if ((vlanid_cstatus[0] == UNC_CS_NOT_APPLIED) &&
+ (vlanid_cstatus[1] == UNC_CS_NOT_APPLIED))
+ vlink_val->cs_attr[UPLL_IDX_VLAN_ID_VLNK] = UNC_CS_NOT_APPLIED;
+ else {
+ if (node_vunk_if == 1) // If first node is KT_VUNKOWN_IF
+ vlink_val->cs_attr[UPLL_IDX_VLAN_ID_VLNK] = vlanid_cstatus[1];
+ else if (node_vunk_if == 2) // If second node is KT_VUNKOWN_IF
+ vlink_val->cs_attr[UPLL_IDX_VLAN_ID_VLNK] = vlanid_cstatus[0];
+ else // Set Partially Applied for other cases
+ vlink_val->cs_attr[UPLL_IDX_VLAN_ID_VLNK] =
+ UNC_CS_PARTIALLY_APPLIED;
+ }
+ /* update consolidated config status if boundary vlink */
+ if (op == UNC_OP_CREATE) {
+ vlink_val->cs_attr[UPLL_IDX_VNODE1_IF_NAME_VLNK] = if_cstatus[0];
+ vlink_val->cs_attr[UPLL_IDX_VNODE2_IF_NAME_VLNK] = if_cstatus[1];
+
if ((if_cstatus[0] == UNC_CS_APPLIED) &&
(if_cstatus[1] == UNC_CS_APPLIED))
vlink_val->cs_row_status = UNC_CS_APPLIED;
(if_cstatus[1] == UNC_CS_NOT_APPLIED))
vlink_val->cs_row_status = UNC_CS_NOT_APPLIED;
else
- vlink_val->cs_row_status = UNC_CS_PARTAILLY_APPLIED;
- }
- }
- if (bound_vlink) {
- val_port_map *pm1 = &(reinterpret_cast<val_drv_vbr_if *>
- (GetVal(vnif[0]))->vbr_if_val.portmap);
- val_port_map *pm2 = &(reinterpret_cast<val_drv_vbr_if *>
- (GetVal(vnif[1]))->vbr_if_val.portmap);
-
- if ((pm1->valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID) ||
- (pm1->valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID_NO_VALUE)) {
- if_cstatus[0] = (unc_keytype_configstatus_t)
- (pm1->cs_attr[UPLL_IDX_VLAN_ID_PM]);
- if_cstatus[1] = (unc_keytype_configstatus_t)
- (pm2->cs_attr[UPLL_IDX_VLAN_ID_PM]);
- if ((if_cstatus[0] == UNC_CS_APPLIED) &&
- (if_cstatus[1] == UNC_CS_APPLIED))
- vlink_val->cs_attr[UPLL_IDX_VLAN_ID_VLNK] = UNC_CS_APPLIED;
- else if ((if_cstatus[0] == UNC_CS_INVALID) ||
- (if_cstatus[1] == UNC_CS_INVALID))
- vlink_val->cs_attr[UPLL_IDX_VLAN_ID_VLNK] = UNC_CS_INVALID;
- else if ((if_cstatus[0] == UNC_CS_NOT_APPLIED) &&
- (if_cstatus[1] == UNC_CS_NOT_APPLIED))
- vlink_val->cs_attr[UPLL_IDX_VLAN_ID_VLNK] = UNC_CS_NOT_APPLIED;
- else
- vlink_val->cs_attr[UPLL_IDX_VLAN_ID_VLNK] = UNC_CS_PARTAILLY_APPLIED;
+ vlink_val->cs_row_status = UNC_CS_PARTIALLY_APPLIED;
+ }
}
}
if (vnif[0]) delete vnif[0];
}
upll_rc_t VlinkMoMgr::SetOperStatus(ConfigKeyVal *ikey, DalDmlIntf *dmi,
- int notification, bool skip) {
+ state_notification notification,
+ bool skip) {
UPLL_FUNC_TRACE;
- if (!ikey) return UPLL_RC_ERR_GENERIC;
- upll_rc_t result_code;
+// bool oper_change = false;
+ if (!ikey) {
+ UPLL_LOG_DEBUG("ikey is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_DEBUG("notification %d skip %d ikey %s\n",notification,skip,
+ ikey->ToStrAll().c_str());
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
if (!skip) {
DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
result_code = ReadConfigDB(ikey, UPLL_DT_STATE, UNC_OP_READ, dbop, dmi,
return result_code;
}
}
- ConfigKeyVal *tkey = ikey;
- while (tkey != NULL) {
+ // ConfigKeyVal *tkey = ikey;
+ while (ikey != NULL) {
ConfigVal *tmp =
(ikey->get_cfg_val()) ? ikey->get_cfg_val()->get_next_cfg_val() : NULL;
- val_vlink_st_t *vlink_valst = (tmp != NULL) ?
- reinterpret_cast<val_vlink_st_t *>(tmp->get_val()) : NULL;
- if (vlink_valst == NULL) return UPLL_RC_ERR_GENERIC;
+ val_db_vlink_st *vlink_db_valst = (tmp != NULL) ?
+ reinterpret_cast<val_db_vlink_st_t *>
+ (tmp->get_val()) : NULL;
+ if (vlink_db_valst == NULL) {
+ UPLL_LOG_ERROR("Returning error \n");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val_vlink *vlink_val = reinterpret_cast<val_vlink *>(GetVal(ikey));
+ if (vlink_val == NULL) {
+ UPLL_LOG_ERROR("Returning error \n");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val_vlink_st_t *vlink_valst = reinterpret_cast<val_vlink_st_t *>
+ (vlink_db_valst);
/* Update oper status based on notification */
vlink_valst->valid[UPLL_IDX_OPER_STATUS_VLNKS] = UNC_VF_VALID;
-#if TODO
+
switch (notification) {
- case CONNECTION_FAULT:
- vlink_valst->oper_status = UPLL_OPER_STATUS_UNKNOWN
+ case kCtrlrReconnectIfUp:
+ case kCtrlrReconnectIfDown: {
+ val_vlink* vlink_val = reinterpret_cast<val_vlink*>(GetVal(ikey));
+ if (!vlink_val) {
+ UPLL_LOG_DEBUG("val vlink is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (vlink_valst->oper_status == UPLL_OPER_STATUS_UP ||
+ vlink_valst->oper_status == UPLL_OPER_STATUS_DOWN) {
+ return result_code;
+ }
+ if (notification == kCtrlrReconnectIfUp &&
+ vlink_val->admin_status == UPLL_ADMIN_ENABLE ) {
+ vlink_valst->oper_status = UPLL_OPER_STATUS_UP;
+ } else {
+ vlink_valst->oper_status = UPLL_OPER_STATUS_DOWN;
+ }
+ }
break;
- case PATHFAULT:
- vlink_valst->down_count = (notification == UPLL_ALARM_RAISE)?
- (vlink_valst->down_count + 1):(vlink_valst->down_count > 0)?
- (vlink_valst->down_count - 1):0;
- if (notification == UPLL_ALARM_RAISE &&
- (vlink_valst->down_count == 1)) {
- vlink_valst->oper_status = UPLL_OPER_STATUS_DOWN
- /* generate alarm */
- /* GenerateAlarm(notification); */
- } else if (notification == UPLL_ALARM_CLEAR &&
- (vlink_valst->down_count == 0)) {
- vlink_valst->oper_status = UPLL_OPER_STATUS_UP;
- /* reset alarm */
- /*ResetAlarm(notification);*/
+ case kCtrlrDisconnect:
+ if (vlink_valst->oper_status == UPLL_OPER_STATUS_UNKNOWN) {
+ return UPLL_RC_SUCCESS;
+ }
+ vlink_valst->oper_status = UPLL_OPER_STATUS_UNKNOWN;
+ vlink_db_valst->down_count = 0;
+ break;
+ case kAdminStatusDisabled:
+ vlink_valst->oper_status = UPLL_OPER_STATUS_DOWN;
+ break;
+ case kAdminStatusEnabled:
+ if (vlink_db_valst->down_count == 0)
+ vlink_valst->oper_status = UPLL_OPER_STATUS_UP;
+ else
+ vlink_valst->oper_status = UPLL_OPER_STATUS_DOWN;
+ break;
+ case kPathFault:
+ case kPortFault:
+ case kBoundaryFault: {
+ vlink_db_valst->down_count = (vlink_db_valst->down_count + 1);
+ if (vlink_db_valst->down_count == 1) {
+ vlink_valst->oper_status = UPLL_OPER_STATUS_DOWN;
+ // oper_change = true;
+ }
}
break;
- default:
+ case kPathFaultReset:
+ case kPortFaultReset:
+ case kBoundaryFaultReset: {
+ vlink_db_valst->down_count = (vlink_db_valst->down_count > 0) ?
+ (vlink_db_valst->down_count - 1) : 0;
+ if (vlink_db_valst->down_count == 0) {
+ if (vlink_val->admin_status == UPLL_ADMIN_ENABLE) {
+ vlink_valst->oper_status = UPLL_OPER_STATUS_UP;
+ // generate alarm
+ // oper_change = true;
+ }
+ }
+ }
break;
+ default:
+ UPLL_LOG_DEBUG("Invalid nofification");
+ return UPLL_RC_ERR_GENERIC;
}
-#endif
+ vlink_val->valid[UPLL_IDX_ADMIN_STATUS_VLNK] = UNC_VF_INVALID;
+ DbSubOp dbop = { kOpNotRead, kOpMatchNone, kOpInOutNone };
result_code = UpdateConfigDB(ikey, UPLL_DT_STATE, UNC_OP_UPDATE, dmi,
- MAINTBL);
+ &dbop, MAINTBL);
+ UPLL_LOG_DEBUG("Vlink SetOperstatus for VTN after Update is \n %s",
+ ikey->ToStrAll().c_str());
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_ERROR("Error in update oper status");
return result_code;
}
- tkey = tkey->get_next_cfg_key_val();
+ if (skip) break;
+ ikey = ikey->get_next_cfg_key_val();
}
- if (ikey->get_cfg_val()) delete ikey->get_cfg_val();
- return UPLL_RC_SUCCESS;
+// if (ikey->get_cfg_val())
+// delete ikey->get_cfg_val();
+ return result_code;
}
upll_rc_t VlinkMoMgr::MergeValidate(unc_key_type_t keytype,
DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- ConfigKeyVal *tmp = NULL;
DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
if (!ikey || !(ikey->get_key())) {
UPLL_LOG_DEBUG(" Input key is NULL");
- return UPLL_RC_ERR_GENERIC;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigKeyVal *dup_key = NULL;
+ result_code = GetChildConfigKey(dup_key, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ if(dup_key) delete dup_key;
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed");
+ return result_code;
}
/*
* Here getting FULL Key (VTN & Vlink Name )
*/
- result_code = ReadConfigDB(ikey, UPLL_DT_IMPORT, UNC_OP_READ, dbop, dmi,
+ result_code = ReadConfigDB(dup_key, UPLL_DT_IMPORT, UNC_OP_READ, dbop, dmi,
MAINTBL);
- if (UPLL_RC_SUCCESS != result_code) return result_code;
+ if (UPLL_RC_SUCCESS != result_code) {
+ if (dup_key) delete dup_key;
+ return result_code;
+ }
/* checks the vnode name present in the running vnode under the
* same vtn
*/
- while (ikey) {
+ ConfigKeyVal * travel = dup_key;
+ while (travel) {
/* Same Name should not present in the vnodes in running*/
- result_code = VnodeChecks(ikey, UPLL_DT_RUNNING, dmi);
-
- if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ result_code = VnodeChecks(travel, UPLL_DT_CANDIDATE, dmi);
+
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code ||
+ UPLL_RC_ERR_CFG_SEMANTIC == result_code) {
+ result_code = GetChildConfigKey(ikey, travel);
+ delete dup_key;
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed");
+ if (dup_key) delete dup_key;
+ return result_code;
+ }
UPLL_LOG_DEBUG("Vlink Name Conflict %d", result_code);
return UPLL_RC_ERR_MERGE_CONFLICT;
}
/* Any other DB error */
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG(" VnodeChecks Failed %d", result_code);
+ if (dup_key) delete dup_key;
return result_code;
}
- tmp = ikey;
- ikey = ikey->get_next_cfg_key_val();
- if (tmp) {
- delete tmp;
- }
+ travel = travel->get_next_cfg_key_val();
}
+ if (dup_key) delete dup_key;
return result_code;
}
UPLL_FUNC_TRACE;
// To adapt the value structure with VTNService
if (!ikey) {
- UPLL_LOG_DEBUG("Invalid ikey\n");
+ UPLL_LOG_DEBUG("Invalid ikey");
return UPLL_RC_ERR_GENERIC;
}
while (ikey) {
ConfigVal *cval = ikey->get_cfg_val();
if (!cval) {
- UPLL_LOG_DEBUG("Config Val is Null\n");
+ UPLL_LOG_DEBUG("Config Val is Null");
return UPLL_RC_ERR_GENERIC;
}
- while (cval ) {
+ while (cval) {
+ if (IpctSt::kIpcStValVlink == cval->get_st_num()) {
+ // set admin status to valid no value
+ val_vlink *vlink_val = reinterpret_cast<val_vlink *>GetVal(ikey);
+ if (vlink_val->valid[UPLL_IDX_ADMIN_STATUS_VLNK] == UNC_VF_INVALID)
+ vlink_val->valid[UPLL_IDX_ADMIN_STATUS_VLNK] = UNC_VF_VALID_NO_VALUE;
+ }
if (IpctSt::kIpcStValVlinkSt == cval->get_st_num()) {
val_vlink_st *vlink_val_st = reinterpret_cast<val_vlink_st *>
- (malloc(sizeof(val_vlink_st)));
- if (!vlink_val_st) {
- UPLL_LOG_ERROR("Memory Allocation failed");
- return UPLL_RC_ERR_GENERIC;
- }
+ (ConfigKeyVal::Malloc(sizeof(val_vlink_st)));
val_db_vlink_st *db_vlink_val_st = reinterpret_cast<val_db_vlink_st *>
(cval->get_val());
memcpy(vlink_val_st, &(db_vlink_val_st->vlink_val_st),
key = ikey->get_key();
ConfigVal *val = ikey->get_cfg_val();
val_rename_vlink_t *val_rename_vlink = reinterpret_cast
- <val_rename_vlink_t *> (malloc(sizeof(val_rename_vlink_t)));
+ <val_rename_vlink_t *> (ConfigKeyVal::Malloc(
+ sizeof(val_rename_vlink_t))); // COV NULL RETURN
// Getting valid
val_rename_vlink->valid[UPLL_IDX_NEW_NAME_RVLNK] = UNC_VF_VALID;
// Getting new_name
UPLL_LOG_ERROR("Record does Not Exists");
return result_code;
}
+ if (dup_ckvlink->get_cfg_val()->get_val()) {
+ val_vlink_t *vlink_val = reinterpret_cast<val_vlink_t *>(
+ GetVal(dup_ckvlink));
+ val_vlink_t *vlink_val1 = reinterpret_cast<val_vlink_t *>(
+ GetVal(ikey));
+
+ if (vlink_val->valid[UPLL_IDX_BOUNDARY_NAME_VLNK] == UNC_VF_VALID &&
+ vlink_val1->valid[UPLL_IDX_BOUNDARY_NAME_VLNK] == UNC_VF_VALID) {
+ if (strncmp(reinterpret_cast<const char *>(vlink_val->boundary_name),
+ reinterpret_cast<const char *>(vlink_val1->boundary_name),
+ kMaxLenBoundaryName+1)) {
+ UPLL_LOG_DEBUG("Vlink boundary name updation not possible");
+ free(dup_ckvlink);
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ }
+ }
#if 0
result_code = DupConfigKeyVal(okey, ikey, MAINTBL);
- if (UPLL_RC_SUCCESS != result_code) {
+ if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG(" DupConfigKeyVal Failed %d", result_code);
return result_code;
}
#endif
- result_code = ValidateAttribute(ikey, dmi, req);
- if (UPLL_RC_SUCCESS != result_code) {
- if (dup_ckvlink) delete dup_ckvlink;
- UPLL_LOG_ERROR("Validate Attribute is Failed");
- return result_code;
+ controller_domain ctrlr_dom[2] = { { NULL, NULL }, { NULL, NULL } };
+
+ result_code = GetControllerDomainId(dup_ckvlink, &ctrlr_dom[0]);
+ if (UPLL_RC_SUCCESS != result_code) {
+ delete dup_ckvlink;
+ return result_code;
+ }
+
+ SET_USER_DATA_CTRLR_DOMAIN(ikey, *ctrlr_dom);
+ SET_USER_DATA(ikey->get_cfg_val(), dup_ckvlink->get_cfg_val());
+
+ if (ctrlr_dom[0].ctrlr != NULL) {
+ result_code = ValidateCapability(
+ req, ikey, reinterpret_cast<const char *>
+ (ctrlr_dom[0].ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ValidateCapability Failed %d", result_code);
+ delete dup_ckvlink;
+ return result_code;
+ }
+ }
+ bool bound_vlink = false;
+ if (ctrlr_dom[1].ctrlr != NULL) {
+ if (ctrlr_dom[0].ctrlr == NULL ||
+ strcmp(reinterpret_cast<const char *>(ctrlr_dom[0].ctrlr),
+ reinterpret_cast<const char *>(ctrlr_dom[1].ctrlr))) {
+ bound_vlink = true;
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(ctrlr_dom[1].ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ValidateCapability Failed %d", result_code);
+ delete dup_ckvlink;
+ return result_code;
+ }
+ }
+ } else {
+ bound_vlink = true;
+ }
+ if (bound_vlink) {
+ /* boundary vlink */
+ val_vlink_t *vlink_val = reinterpret_cast<val_vlink *>(GetVal(ikey));
+ if (vlink_val && vlink_val->admin_status == UPLL_ADMIN_DISABLE) {
+ UPLL_LOG_ERROR("Boundary vlink cannot be shut\n");
+ delete dup_ckvlink;
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
}
val_vlink_t *tmp_val = reinterpret_cast<val_vlink *>(GetVal(ikey));
if (!tmp_val) {
UPLL_LOG_DEBUG("Invalid val");
- if (dup_ckvlink) delete dup_ckvlink;
+ delete dup_ckvlink;
return UPLL_RC_ERR_GENERIC;
}
uint8_t valid_boundary = tmp_val->valid[UPLL_IDX_BOUNDARY_NAME_VLNK];
- if (valid_boundary) {
- MoMgrImpl *mgr =
- reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
- UNC_KT_VBR_IF)));
- if (!mgr) {
- UPLL_LOG_DEBUG("Invalid Mgr");
- if (dup_ckvlink) delete dup_ckvlink;
+ bool check_boundary_valid = false;
+ if (valid_boundary == UNC_VF_INVALID) {
+ val_vlink_t *val = reinterpret_cast<val_vlink *>(GetVal(dup_ckvlink));
+ if (!val) {
+ UPLL_LOG_DEBUG("Invalid val");
+ delete dup_ckvlink;
return UPLL_RC_ERR_GENERIC;
}
- ConfigKeyVal *ck_vbrif[2] = {NULL, NULL};
- SET_USER_DATA_FLAGS(dup_ckvlink->get_cfg_val(), kVlinkVnode1);
- int i = 0;
- do {
- result_code = mgr->GetChildConfigKey(ck_vbrif[i], dup_ckvlink);
+ valid_boundary = val->valid[UPLL_IDX_BOUNDARY_NAME_VLNK];
+ if (valid_boundary == UNC_VF_VALID) {
+ uuu::upll_strncpy(reinterpret_cast<char *>(tmp_val->boundary_name),
+ reinterpret_cast<char *>(val->boundary_name),
+ kMaxLenBoundaryName);
+ tmp_val->valid[UPLL_IDX_BOUNDARY_NAME_VLNK] =
+ val->valid[UPLL_IDX_BOUNDARY_NAME_VLNK];
+ check_boundary_valid = true;
+ }
+ }
+ result_code = ValidateAttribute(ikey, dmi, req);
+ if (UPLL_RC_SUCCESS != result_code) {
+ delete dup_ckvlink;
+ UPLL_LOG_ERROR("Validate Attribute is Failed");
+ return result_code;
+ }
+
+ if (valid_boundary != UNC_VF_INVALID) {
+ uint8_t rename_flag = 0;
+ VlinkNodePosition vnode_number = kVlinkVnode1;
+ ConfigKeyVal *ck_vnif[2] = {NULL, NULL};
+ GET_USER_DATA_FLAGS(dup_ckvlink->get_cfg_val(), rename_flag);
+ for (int i = 0; i < 2; i++) {
+ unc_key_type_t ktype = GetVlinkVnodeIfKeyType(dup_ckvlink, i);
+ if (ktype == UNC_KT_VRT_IF) {
+ UPLL_LOG_DEBUG("Boundary operation on non-boundary interface");
+ if (ck_vnif[0]) delete ck_vnif[0];
+ delete dup_ckvlink;
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>
+ (GetMoManager(ktype)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Invalid Mgr %d", ktype);
+ delete dup_ckvlink;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ SET_USER_DATA_FLAGS(dup_ckvlink->get_cfg_val(), vnode_number);
+ result_code = mgr->GetChildConfigKey(ck_vnif[i], dup_ckvlink);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Returning %d", result_code);
- if (dup_ckvlink) delete dup_ckvlink;
+ delete dup_ckvlink;
return result_code;
}
- result_code = mgr->ReadConfigDB(ck_vbrif[i], req->datatype,
+ result_code = mgr->ReadConfigDB(ck_vnif[i], req->datatype,
UNC_OP_READ, dbop1, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Error in reading %d", result_code);
- if (dup_ckvlink) delete dup_ckvlink;
- if (ck_vbrif[0]) delete ck_vbrif[0];
- if (ck_vbrif[1]) delete ck_vbrif[1];
- ck_vbrif[0] = ck_vbrif[1] = NULL;
+ delete dup_ckvlink;
+ if (ck_vnif[0]) delete ck_vnif[0];
+ if (ck_vnif[1]) delete ck_vnif[1];
+ ck_vnif[0] = ck_vnif[1] = NULL;
return result_code;
}
- SET_USER_DATA_FLAGS(dup_ckvlink->get_cfg_val(), kVlinkVnode2);
- i++;
- } while (i < 2);
- result_code = UpdateVbrIfExternal(req->datatype, ikey, ck_vbrif, dmi);
+ vnode_number = kVlinkVnode2;
+ }
+ SET_USER_DATA_FLAGS(dup_ckvlink->get_cfg_val(), rename_flag);
+ if (!ck_vnif[0] || !ck_vnif[1]) {
+ UPLL_LOG_DEBUG("Invalid param");
+ delete dup_ckvlink;
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ UPLL_LOG_DEBUG("Before UpdateVnodeIf %s", (ikey->ToStrAll()).c_str());
+ result_code = UpdateVnodeIf(req->datatype, ikey, ck_vnif, dmi,
+ req->operation);
+ for (int i = 0; i < 2 ; i++)
+ if (ck_vnif[i]) delete ck_vnif[i];
if (result_code != UPLL_RC_SUCCESS) {
+ delete dup_ckvlink;
UPLL_LOG_DEBUG("Returning error %d", result_code);
+ return result_code;
}
- for (int i = 0; i < 2 ; i++)
- if (ck_vbrif[i]) delete ck_vbrif[i];
}
DbSubOp dbop = { kOpNotRead, kOpMatchNone, kOpInOutNone };
- UPLL_LOG_DEBUG("The ikey Structue before update %s", (ikey->ToStrAll()).c_str());
+ UPLL_LOG_DEBUG("The ikey Structue before update %s",
+ (ikey->ToStrAll()).c_str());
result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_UPDATE,
dmi, &dbop, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
- if (dup_ckvlink) delete dup_ckvlink;
+ delete dup_ckvlink;
UPLL_LOG_ERROR("Updation Failure in DB : %d", result_code);
return result_code;
}
+ if (check_boundary_valid) {
+ tmp_val->valid[UPLL_IDX_BOUNDARY_NAME_VLNK] = UNC_VF_INVALID;
+ }
if (dup_ckvlink) delete dup_ckvlink;
return result_code;
}
-/* This function update the vnode operstatus
+/* This function update the vnode operstatus
* while doing commit
*/
upll_rc_t VlinkMoMgr::TxUpdateDtState(unc_key_type_t ktype,
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *ck_vlink = NULL;
-
- result_code = GetUninitOperState<val_vlink_st_t,val_db_vlink_st_t>
- (ck_vlink, dmi);
+
+ result_code = GetUninitOperState(ck_vlink, dmi);
if (!ck_vlink || UPLL_RC_SUCCESS != result_code) {
- return result_code;
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ return result_code;
}
ConfigKeyVal *tkey = ck_vlink;
// Get consitutent interface status - ignore if unknown
while (tkey) {
- uint8_t oper_status[2];
- ConfigKeyVal *ck_vnif[2];
- result_code = GetVnodeIfFromVlink(tkey, ck_vnif, dmi);
- if (!ck_vnif[0] || !ck_vnif[1] || result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ VnodeChildMoMgr *ktype_mgr[2];
+ bool bound_vlink = false;
+ controller_domain_t vlink_ctrlr_dom[] = { {NULL,NULL}, {NULL,NULL}};
+ result_code = BoundaryVlink(tkey, vlink_ctrlr_dom, bound_vlink);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_ERROR("Returning error %d\n",result_code);
+ DELETE_IF_NOT_NULL(ck_vlink);
return result_code;
- }
+ }
+ /* update consolidated oper status */
+ /* get the constituent interfaces */
+ ConfigKeyVal *vnif[2] = {NULL, NULL};
for (int i = 0; i < 2; i++) {
- oper_status[i] = UPLL_OPER_STATUS_DOWN;
- switch (ck_vnif[i]->get_key_type()) {
- case UNC_KT_VBR_IF:
- {
- val_db_vbr_if_st *vnif_st = reinterpret_cast<val_db_vbr_if_st *>
- (GetStateVal(ck_vnif[i]));
- if (vnif_st && vnif_st->vbr_if_val_st.
- valid[UPLL_IDX_OPER_STATUS_VBRIS] == UNC_VF_VALID) {
- oper_status[i] = vnif_st->vbr_if_val_st.oper_status;
- }
- break;
+ result_code = GetVnodeIfFromVlink(tkey,&vnif[i],dmi,i);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_ERROR("get %d constituent interface of vlink failed %d",
+ i,result_code);
+ DELETE_IF_NOT_NULL(ck_vlink);
+ return result_code;
}
- case UNC_KT_VRT_IF:
- {
- val_db_vrt_if_st *vnif_st = reinterpret_cast<val_db_vrt_if_st *>
- (GetStateVal(ck_vnif[i]));
- if (vnif_st && vnif_st->vrt_if_val_st.
- valid[UPLL_IDX_OPER_STATUS_VRTIS] == UNC_VF_VALID) {
- oper_status[i] = vnif_st->vrt_if_val_st.oper_status;
- }
- break;
+ unc_key_type_t ktype = vnif[i]->get_key_type();
+ ktype_mgr[i] = reinterpret_cast<VnodeChildMoMgr *>
+ (const_cast<MoManager*>(GetMoManager(ktype)));
+ }
+ val_vlink *vlink_val = reinterpret_cast<val_vlink *>(GetVal(tkey));
+ if (!vlink_val) {
+ UPLL_LOG_ERROR("Invalid param \n");
+ DELETE_IF_NOT_NULL(ck_vlink);
+ for (int i = 0; i < 2; i++) {
+ DELETE_IF_NOT_NULL(vnif[i]);
+ }
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val_db_vbr_if_st *vnif1_st;
+ if (vlink_val->admin_status == UPLL_ADMIN_DISABLE) {
+ result_code = SetOperStatus(tkey, dmi, kAdminStatusDisabled, true);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("SetOperStatus failed %d", result_code);
+ DELETE_IF_NOT_NULL(ck_vlink);
+ for (int i = 0; i < 2; i++) {
+ DELETE_IF_NOT_NULL(vnif[i]);
+ }
+ return result_code;
}
- case UNC_KT_VTEP_IF:
- {
- val_db_vtep_if_st *vnif_st = reinterpret_cast<val_db_vtep_if_st *>
- (GetStateVal(ck_vnif[i]));
- if (vnif_st && vnif_st->vtep_if_val_st.
- valid[UPLL_IDX_IF_OPER_STATUS_VTEPIS] == UNC_VF_VALID) {
- oper_status[i] = vnif_st->vtep_if_val_st.oper_status;
- }
- break;
+ for (int i = 0; i < 2; i++) {
+ if (vnif[i]->get_key_type() != UNC_KT_VUNK_IF) {
+ vnif1_st = reinterpret_cast<val_db_vbr_if_st *>(GetStateVal(vnif[i]));
+ vnif1_st = reinterpret_cast<val_db_vbr_if_st *>(GetStateVal(vnif[i]));
+ vnif1_st->vbr_if_val_st.oper_status = UPLL_OPER_STATUS_DOWN;
+ vnif1_st->vbr_if_val_st.valid[UPLL_IDX_OPER_STATUS_VBRIS]
+ = UNC_VF_VALID;
+ result_code = ktype_mgr[i]->UpdateOperStatus(vnif[i], dmi,
+ kAdminStatusDisabled, true, true, false);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ for (int i = 0; i < 2; i++) {
+ DELETE_IF_NOT_NULL(vnif[i]);
+ }
+ DELETE_IF_NOT_NULL(ck_vlink);
+ return result_code;
+ }
+ }
}
- case UNC_KT_VTUNNEL_IF:
- {
- val_db_vtunnel_if_st *vnif_st = reinterpret_cast<val_db_vtunnel_if_st *>
- (GetStateVal(ck_vnif[i]));
- if (vnif_st && vnif_st->vtunnel_if_val_st.
- valid[UPLL_IDX_IF_OPER_STATUS_VTNLI] == UNC_VF_VALID) {
- oper_status[i] = vnif_st->vtunnel_if_val_st.oper_status;
- }
- break;
+ } else if (!bound_vlink) {
+ result_code = SetOperStatus(tkey, dmi, kAdminStatusEnabled, true);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("SetOperStatus failed %d", result_code);
+ DELETE_IF_NOT_NULL(ck_vlink);
+ for (int i = 0; i < 2; i++) {
+ DELETE_IF_NOT_NULL(vnif[i]);
+ }
+ return result_code;
}
- case UNC_KT_VUNK_IF:
- oper_status[i] = UPLL_OPER_STATUS_UP;
- continue;
- default:
- UPLL_LOG_DEBUG("Unsupported operation on key %d\n",
- ck_vnif[i]->get_key_type());
- return UPLL_RC_ERR_GENERIC;
+ for (int i = 0; i < 2; i++) {
+ if (vnif[i]->get_key_type() != UNC_KT_VUNK_IF) {
+ vnif1_st = reinterpret_cast<val_db_vbr_if_st *>(GetStateVal(vnif[i]));
+ vnif1_st->vbr_if_val_st.oper_status = UPLL_OPER_STATUS_UP;
+ vnif1_st->vbr_if_val_st.valid[UPLL_IDX_OPER_STATUS_VBRIS]
+ = UNC_VF_VALID;
+ result_code = ktype_mgr[i]->UpdateOperStatus(vnif[i], dmi,
+ kAdminStatusEnabled, true, true, false);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ for (int i = 0; i < 2; i++) {
+ DELETE_IF_NOT_NULL(vnif[i]);
+ }
+ DELETE_IF_NOT_NULL(ck_vlink);
+ return result_code;
+ }
+ }
+ }
+ } else {
+ state_notification notification = kCtrlrReconnect; //noop
+
+ if (vlink_val->valid[UPLL_IDX_BOUNDARY_NAME_VLNK] ==
+ UNC_VF_VALID) {
+ val_oper_status bound_oper_status;
+
+ result_code = GetBoundaryStatusFromPhysical(vlink_val->boundary_name,
+ vlink_ctrlr_dom, bound_oper_status, session_id, config_id);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_ERROR("Returning error %d\n",result_code);
+ }
+ switch (bound_oper_status) {
+ case UPLL_OPER_STATUS_DOWN:
+ notification = kPortFault;
+ break;
+ case UPLL_OPER_STATUS_UNKNOWN:
+ notification = kCtrlrDisconnect;
+ break;
+ case UPLL_OPER_STATUS_UP:
+ notification = kPortFaultReset;
+ break;
+ default:
+ notification = kPortFault;
+ break;
+ }
+ } else {
+ notification = kAdminStatusDisabled;
+ }
+ result_code = SetOperStatus(tkey, dmi, notification, true);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("SetOperStatus failed %d", result_code);
+ DELETE_IF_NOT_NULL(ck_vlink);
+ for (int i = 0; i < 2; i++) {
+ DELETE_IF_NOT_NULL(vnif[i]);
+ }
+ return result_code;
+ }
+ for (int i = 0; i < 2; i++) {
+ if (vnif[i]->get_key_type() != UNC_KT_VUNK_IF) {
+ result_code = ktype_mgr[i]->UpdateOperStatus(vnif[i], dmi,
+ notification, true, true, false);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error updating oper status %d", result_code);
+ for (int i = 0; i < 2; i++) {
+ DELETE_IF_NOT_NULL(vnif[i]);
+ }
+ DELETE_IF_NOT_NULL(ck_vlink);
+ return result_code;
+ }
+ }
}
- if (ck_vnif[i]) delete ck_vnif[i];
- ck_vnif[i] = NULL;
}
- val_db_vlink_st *val_vlink_st = reinterpret_cast<val_db_vlink_st *>
- (GetStateVal(tkey));
- if (!val_vlink_st) {
- UPLL_LOG_DEBUG("Invalid vlink st\n");
- return UPLL_RC_ERR_GENERIC;
+ for (int i = 0; i < 2; i++) {
+ DELETE_IF_NOT_NULL(vnif[i]);
}
- if ((oper_status[0] == oper_status[1]) == UPLL_OPER_STATUS_UP)
- val_vlink_st->vlink_val_st.oper_status = UPLL_OPER_STATUS_UP;
- else if ((oper_status[0] == UPLL_OPER_STATUS_UNKNOWN) ||
- (oper_status[1] == UPLL_OPER_STATUS_UNKNOWN))
- val_vlink_st->vlink_val_st.oper_status = UPLL_OPER_STATUS_UNKNOWN;
- else
- val_vlink_st->vlink_val_st.oper_status = UPLL_OPER_STATUS_DOWN;
- val_vlink_st->vlink_val_st.valid[UPLL_IDX_OPER_STATUS_VLNKS] =
- UNC_VF_VALID;
tkey= tkey->get_next_cfg_key_val();
}
+ DELETE_IF_NOT_NULL(ck_vlink);
return UPLL_RC_SUCCESS;
}
-upll_rc_t VlinkMoMgr::GetVnodeIfFromVlink(ConfigKeyVal *vlink,
+upll_rc_t VlinkMoMgr::GetVnodeIfFromVlink(ConfigKeyVal *vlink,
ConfigKeyVal **vnif,
- DalDmlIntf *dmi) {
+ DalDmlIntf *dmi, uint8_t pos) {
+ UPLL_FUNC_TRACE;
if (!vlink) {
- UPLL_LOG_TRACE("Input vlink key null\n");
+ UPLL_LOG_TRACE("Input vlink key null");
return UPLL_RC_ERR_GENERIC;
}
- VlinkNodePosition vnode_number = kVlinkVnode1;
- int i = 0;
+ int num = (pos > 1)?2:1;
+ VlinkNodePosition vnode_number =
+ (pos == 1) ?kVlinkVnode2:kVlinkVnode1;
uint8_t rename_flag = 0;
GET_USER_DATA_FLAGS(vlink->get_cfg_val(), rename_flag);
- do {
- unc_key_type_t ktype = GetVlinkVnodeIfKeyType(vlink, i);
+ for (int i = 0; i < num ; i++) {
+ int j = (pos > 1)?i:pos;
+ unc_key_type_t ktype = GetVlinkVnodeIfKeyType(vlink, j);
MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>
(GetMoManager(ktype)));
if (!mgr) {
- UPLL_LOG_DEBUG("Invalid mgr for keytype %d\n",ktype);
+ UPLL_LOG_DEBUG("Invalid mgr for keytype %d", ktype);
return UPLL_RC_ERR_GENERIC;
}
SET_USER_DATA_FLAGS(vlink->get_cfg_val(), vnode_number);
mgr->GetChildConfigKey(vnif[i], vlink);
DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutCs };
- upll_rc_t result_code = mgr->ReadConfigDB(vnif[i], UPLL_DT_STATE,
+ upll_rc_t result_code = mgr->ReadConfigDB(vnif[i], UPLL_DT_STATE,
UNC_OP_READ, dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)
+ result_code = UPLL_RC_ERR_GENERIC;
+ DELETE_IF_NOT_NULL(vnif[i]);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ return result_code;
+ }
+ if (!GetVal(vnif[i])) {
+ UPLL_LOG_DEBUG("Returning error");
+ DELETE_IF_NOT_NULL(vnif[i]);
return UPLL_RC_ERR_GENERIC;
}
- i++;
vnode_number = (vnode_number == kVlinkVnode1)?kVlinkVnode2:kVlinkVnode1;
- } while (vnode_number != kVlinkVnode1);
+ }
SET_USER_DATA_FLAGS(vlink->get_cfg_val(), rename_flag);
- if (!GetVal(vnif[0]) ||!GetVal(vnif[1])) {
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VlinkMoMgr::BoundaryStatusHandler(uint8_t boundary_name[32],
+ bool oper_status, DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+
+ UPLL_LOG_DEBUG("Boundary name :(%s) oper_status:(%d)", boundary_name,
+ oper_status);
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ state_notification notification =
+ (oper_status == UPLL_OPER_STATUS_UP) ? kBoundaryFaultReset :
+ kBoundaryFault;
+
+ /* Allocating memory for vlink key and value structure */
+ val_vlink *vlink_val = reinterpret_cast<val_vlink_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_vlink_t)));
+ /* copy fault boundaryname to vlink value structure */
+ uuu::upll_strncpy(reinterpret_cast<char *>(vlink_val->boundary_name),
+ reinterpret_cast<char *>(boundary_name),
+ kMaxLenBoundaryName);
+
+ /* set Boundary flag as valid */
+ vlink_val->valid[UPLL_IDX_BOUNDARY_NAME_VLNK] = UNC_VF_VALID;
+ /* Allocate a vlink config key with the given val*/
+ ConfigKeyVal *ikey = NULL;
+ result_code = GetChildConfigKey(ikey, NULL);
+ if (!ikey || result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed %d", result_code);
+ free(vlink_val); // COV RESOURCE LEAK
+ return result_code;
+ }
+ ikey->AppendCfgVal(IpctSt::kIpcStValVlink, vlink_val);
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone,
+ kOpInOutFlag | kOpInOutCtrlr | kOpInOutDomain};
+
+ /* Getting list of Vlinks that have same boundaryname */
+ result_code = ReadConfigDB(ikey, UPLL_DT_STATE, UNC_OP_READ, dbop,
+ dmi, MAINTBL);
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error in reading %d", result_code);
+ delete ikey;
+ return result_code;
+ }
+ ConfigKeyVal *tmp = ikey;
+ while (tmp != NULL) {
+ /* setting vlink operstatus */
+ SetOperStatus(tmp, dmi, notification, true);
+
+ ConfigKeyVal *if_key = NULL;
+ uint8_t vlink_flag = 0;
+ GET_USER_DATA_FLAGS(tmp->get_cfg_val(), vlink_flag);
+ VlinkNodePosition vnode_number = kVlinkVnode1;
+ for (int i = 0; i < 2 ; i++) {
+ SET_USER_DATA_FLAGS(tmp->get_cfg_val(), vnode_number);
+ unc_key_type_t ktype = GetVlinkVnodeIfKeyType(tmp,i);
+ if (ktype == UNC_KT_VUNK_IF) {
+ if (vnode_number == kVlinkVnode1) {
+ vnode_number = kVlinkVnode2;
+ }
+ continue;
+ }
+ VnodeChildMoMgr *mgr = (reinterpret_cast<VnodeChildMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(ktype))));
+ result_code = mgr->GetChildConfigKey(if_key, tmp);
+ if (!if_key || result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = mgr->UpdateOperStatus(if_key, dmi, notification,
+ false, true, false);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_ERROR("Updating operstatus of vnode if failed %d\n",
+ result_code);
+ return result_code;
+ }
+ vnode_number = (vnode_number == kVlinkVnode1)?
+ kVlinkVnode2:kVlinkVnode1;
+ DELETE_IF_NOT_NULL(if_key);
+ }
+ SET_USER_DATA_FLAGS(tmp->get_cfg_val(), vlink_flag);
+ tmp = tmp->get_next_cfg_key_val();
+ }
+ VnodeMoMgr *vn_mgr = reinterpret_cast<VnodeMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VBRIDGE)));
+ if (!vn_mgr) {
UPLL_LOG_DEBUG("Returning error\n");
return UPLL_RC_ERR_GENERIC;
}
- return UPLL_RC_SUCCESS;
+ result_code = vn_mgr->TxUpdateDtState(UNC_KT_VBRIDGE,0,0,dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("failed to update vnode oper status %d\n",result_code);
+ return result_code;
+ }
+ VtnMoMgr *vtn_mgr = reinterpret_cast<VtnMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VTN)));
+ if (!vtn_mgr) {
+ UPLL_LOG_DEBUG("Returning error\n");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = vtn_mgr->TxUpdateDtState(UNC_KT_VTN,0,0,dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("failed to update vtn oper status %d\n",result_code);
+ }
+ // ikey->get_cfg_val()->set_user_data(NULL);
+ if (ikey != NULL) {
+ delete ikey;
+ ikey = NULL;
+ }
+ return result_code;
}
+upll_rc_t VlinkMoMgr::UpdateVlinkOperStatus(uint8_t *ctrlr_id,
+ DalDmlIntf *dmi,
+ state_notification notification,
+ bool skip) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ck_val = NULL;
+
+ result_code = GetChildConfigKey(ck_val, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Invalid param");
+ return result_code;
+ }
+ SET_USER_DATA_CTRLR(ck_val, ctrlr_id);
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr | kOpInOutFlag};
+ result_code = ReadConfigDB(ck_val, UPLL_DT_STATE, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if (result_code == UPLL_RC_SUCCESS) {
+ ConfigKeyVal *tkey = ck_val;
+ while (tkey != NULL) {
+ controller_domain_t vlink_ctrlr_dom[2];
+ vlink_ctrlr_dom[0].ctrlr = NULL;
+ vlink_ctrlr_dom[0].domain = NULL;
+ vlink_ctrlr_dom[1].ctrlr = NULL;
+ vlink_ctrlr_dom[1].domain = NULL;
+ result_code = GetControllerDomainId(tkey, vlink_ctrlr_dom);
+ if (UPLL_RC_SUCCESS != result_code) {
+ unc_key_type_t ktype[2] = {UNC_KT_ROOT, UNC_KT_ROOT};
+ for (int vnode_count = 0; vnode_count < 2; vnode_count++) {
+ ktype[vnode_count] = GetVlinkVnodeIfKeyType(tkey, vnode_count);
+ }
+ if (ktype[0] != UNC_KT_VUNK_IF && ktype[1] != UNC_KT_VUNK_IF) {
+ UPLL_LOG_DEBUG("Empty Controller name recieved.")
+ UPLL_LOG_DEBUG("Controller is empty only for UNKNOWN controllers");
+ return result_code;
+ }
+ }
+ char *ctrlr1 = reinterpret_cast<char*>(vlink_ctrlr_dom[0].ctrlr);
+ char *ctrlr2 = reinterpret_cast<char*>(vlink_ctrlr_dom[1].ctrlr);
+ if ((ctrlr1 && !strcmp(ctrlr1, reinterpret_cast<char*>(ctrlr_id))) ||
+ (ctrlr2 && !strcmp(ctrlr2, reinterpret_cast<char*>(ctrlr_id)))) {
+ result_code = SetOperStatus(tkey, dmi, notification, true);
+ }
+ tkey = tkey->get_next_cfg_key_val();
+ }
+ } else if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ result_code = UPLL_RC_SUCCESS;
+ }
+ DELETE_IF_NOT_NULL(ck_val);
+ return result_code;
+}
+
+upll_rc_t VlinkMoMgr::RestoreVlinkOperStatus(ConfigKeyVal *ck_vnif,
+ DalDmlIntf *dmi,
+ state_notification notification,
+ bool skip) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *tmp = ck_vnif;
+ while (tmp != NULL) {
+ ConfigKeyVal *ck_vlink = NULL;
+ uint8_t if_flag = 0;
+ GET_USER_DATA_FLAGS(tmp, if_flag);
+ SET_USER_DATA_FLAGS(tmp, kVlinkVnode1);
+ result_code = GetVlinkKeyVal(tmp, UPLL_DT_STATE, ck_vlink, dmi);
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ // check if the vBrIf is the second VnodeIf in VLINK TBL
+ SET_USER_DATA_FLAGS(tmp, kVlinkVnode2);
+ DELETE_IF_NOT_NULL(ck_vlink);
+ result_code = GetVlinkKeyVal(tmp, UPLL_DT_STATE, ck_vlink, dmi);
+ } else if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Read vlink table");
+ DELETE_IF_NOT_NULL(ck_vlink);
+ return result_code;
+ }
+ if (result_code == UPLL_RC_SUCCESS) {
+ result_code = SetOperStatus(ck_vlink, dmi, notification, true);
+ } else if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ DELETE_IF_NOT_NULL(ck_vlink);
+ UPLL_LOG_DEBUG("Error in reading vlink DB");
+ return result_code;
+ }
+ SET_USER_DATA_FLAGS(tmp, if_flag);
+ DELETE_IF_NOT_NULL(ck_vlink);
+ tmp = tmp->get_next_cfg_key_val();
+ }
+ return result_code;
+}
+
+upll_rc_t VlinkMoMgr::GetBoundaryStatusFromPhysical(uint8_t *boundary,
+ controller_domain_t *ctr_domain,
+ val_oper_status &bound_operStatus,
+ uint32_t session_id,
+ uint32_t config_id) {
+ UPLL_FUNC_TRACE;
+ IpcResponse ipc_resp;
+ ConfigKeyVal *ck_bound = NULL;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ if (boundary == NULL) {
+ UPLL_LOG_DEBUG("Invalid boundary\n");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ key_boundary *bound_cfg = static_cast<key_boundary *>
+ (ConfigKeyVal::Malloc(sizeof(key_boundary)));
+ uuu::upll_strncpy(bound_cfg->boundary_id,
+ reinterpret_cast<const char *>(boundary),
+ (kMaxLenBoundaryName+1));
+ ck_bound = new ConfigKeyVal(UNC_KT_BOUNDARY,
+ IpctSt::kIpcStKeyBoundary, bound_cfg, NULL);
+ result_code = SendIpcReq(session_id, config_id, UNC_OP_READ,
+ UPLL_DT_STATE, ck_bound, NULL, &ipc_resp);
+ if ((result_code != UPLL_RC_SUCCESS) || (!ipc_resp.ckv_data)) {
+ delete ck_bound;
+ ck_bound = NULL;
+ bound_operStatus = UPLL_OPER_STATUS_DOWN;
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ UPLL_LOG_ERROR("Invalid Boundary %s %d\n", boundary,result_code);
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ ck_bound->ResetWith(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ val_boundary_st *bound_st = static_cast<val_boundary_st *>
+ (GetVal(ck_bound));
+ if (!bound_st || (bound_st->valid[kIdxBoundaryStOperStatus] !=
+ UNC_VF_VALID)) {
+ UPLL_LOG_DEBUG("Returning error \n");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ switch (bound_st->oper_status) {
+ case UPPL_BOUNDARY_OPER_UP:
+ bound_operStatus = UPLL_OPER_STATUS_UP;
+ break;
+ case UPPL_BOUNDARY_OPER_UNKNOWN:
+ bound_operStatus = UPLL_OPER_STATUS_UNKNOWN;
+ break;
+ case UPPL_BOUNDARY_OPER_DOWN:
+ default:
+ bound_operStatus = UPLL_OPER_STATUS_DOWN;
+ break;
+ }
+ if (ck_bound)
+ delete ck_bound;
+ return result_code;
+}
+
+upll_rc_t VlinkMoMgr::GetRemoteIf(ConfigKeyVal *ck_vnif,
+ ConfigKeyVal *&ck_remif,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ uint8_t vif_flag = 0;
+ uint8_t rem_if;
+ ConfigKeyVal *ck_vlink = NULL;
+
+ if (!ck_vnif) {
+ UPLL_LOG_DEBUG("Returning error\n");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ GET_USER_DATA_FLAGS(ck_vnif,vif_flag);
+ if (vif_flag & 0xA0)
+ rem_if = 1;
+ else if (vif_flag & 0x50)
+ rem_if = 0;
+ else
+ return UPLL_RC_ERR_GENERIC;
+ result_code = GetVlinkKeyVal(ck_vnif, UPLL_DT_RUNNING, ck_vlink, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_ERROR("Returning error\n");
+ DELETE_IF_NOT_NULL(ck_vlink);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = GetVnodeIfFromVlink(ck_vlink,&ck_remif,dmi,rem_if);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_ERROR("get remote interface failed %d", result_code);
+ DELETE_IF_NOT_NULL(ck_vlink);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(ck_vlink);
+ return result_code;
+}
+
+upll_rc_t VlinkMoMgr::GetConnected(key_vnode_type_t *src_node,
+ set<key_vnode_type, key_vnode_type_compare> *Vnode_set_obj,
+ set<key_vlink_t,vlink_compare>*Vlink_set_obj,
+ set<key_vnode_if_t, key_vnode_if_compare>* boundary_if_set,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ set<key_vlink_t,vlink_compare>::iterator vlink_itr;
+ std::pair< set<key_vnode_type_t>::iterator,bool > pr;
+ key_vnode_t vnode_key;
+ memset(&vnode_key, 0, sizeof(key_vnode_t));
+ /* initialize the vlink key with the vtn name and vlink vnode1 val with
+ * vbridge name
+ */
+ NodePosition npos = kVnode1;
+ do {
+ ConfigKeyVal *ck_vlink = NULL;
+ result_code = GetChildConfigKey(ck_vlink, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed");
+ return result_code;
+ }
+ key_vlink *vlink_key = reinterpret_cast<key_vlink*>(ck_vlink->get_key());
+ uuu::upll_strncpy(vlink_key->vtn_key.vtn_name, src_node->vnode_key.vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ ConfigVal *cv_vlink = NULL;
+ result_code = AllocVal(cv_vlink, UPLL_DT_RUNNING);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to allocate ConfigVal for vlink");
+ DELETE_IF_NOT_NULL(ck_vlink);
+ return result_code;
+ }
+ ck_vlink->SetCfgVal(cv_vlink);
+ val_vlink *vlink_val = reinterpret_cast<val_vlink_t*>
+ (GetVal(ck_vlink));
+ if (vlink_val == NULL) {
+ UPLL_LOG_DEBUG("val vlink is NULL");
+ DELETE_IF_NOT_NULL(ck_vlink);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (npos == kVnode1) {
+ uuu::upll_strncpy(vlink_val->vnode1_name,src_node->vnode_key.vnode_name, (kMaxLenVnodeName+1));
+ vlink_val->valid[UPLL_IDX_VNODE1_NAME_VLNK] = UNC_VF_VALID;
+ vlink_val->valid[UPLL_IDX_VNODE2_NAME_VLNK] = UNC_VF_INVALID;
+ }
+ if (npos == kVnode2) {
+ // check for a match with the given src_vbr as vnode2_name
+ uuu::upll_strncpy(vlink_val->vnode2_name,
+ src_node->vnode_key.vnode_name, (kMaxLenVnodeName+1));
+ vlink_val->valid[UPLL_IDX_VNODE2_NAME_VLNK] = UNC_VF_VALID;
+ vlink_val->valid[UPLL_IDX_VNODE1_NAME_VLNK] = UNC_VF_INVALID;
+ }
+ vlink_val->valid[UPLL_IDX_BOUNDARY_NAME_VLNK] = UNC_VF_INVALID;
+
+ /* Get all the vlinks with the specified vnode as either vnode1
+ or vnode2 under the given VTN. Populate the corresponding
+ vnode and vlink set. Invoke GetConnected on the inserted vnode
+ */
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone,
+ kOpInOutCtrlr| kOpInOutDomain | kOpInOutFlag};
+ result_code = ReadConfigDB(ck_vlink, UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (result_code == UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("vlink records are %s\n ",ck_vlink->ToStrAll().c_str());
+ ConfigKeyVal *tmp = ck_vlink;
+ while(tmp != NULL) {
+ controller_domain_t vlink_ctrlr_dom[2];
+ vlink_ctrlr_dom[0].ctrlr = NULL;
+ vlink_ctrlr_dom[0].domain = NULL;
+ vlink_ctrlr_dom[1].ctrlr = NULL;
+ vlink_ctrlr_dom[1].domain = NULL;
+ bool bound_vlink = false;
+ result_code = BoundaryVlink(tmp, vlink_ctrlr_dom, bound_vlink);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("vlink boundary determination failed");
+ DELETE_IF_NOT_NULL(ck_vlink);
+ return result_code;
+ }
+
+ key_vlink *tmp_vlink_key = reinterpret_cast<key_vlink*>(tmp->get_key());
+ if (tmp_vlink_key == NULL) {
+ UPLL_LOG_DEBUG("key vlink is NULL");
+ DELETE_IF_NOT_NULL(ck_vlink);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ Vlink_set_obj->insert(*tmp_vlink_key);
+
+ val_vlink *tmp_vlink_val = reinterpret_cast<val_vlink*>(GetVal(tmp));
+ if (tmp_vlink_val == NULL) {
+ UPLL_LOG_DEBUG("val vlink is NULL");
+ DELETE_IF_NOT_NULL(ck_vlink);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ int swap_npos = 0;
+ uint8_t boundary_if[kMaxLenInterfaceName+1];
+ if (npos == kVnode1) {
+ uuu::upll_strncpy(vnode_key.vnode_name,
+ tmp_vlink_val->vnode2_name, (kMaxLenVnodeName+1));
+ if (bound_vlink) {
+ uuu::upll_strncpy(boundary_if,
+ tmp_vlink_val->vnode2_ifname, (kMaxLenInterfaceName+1));
+ }
+ swap_npos = 1;
+
+ } else {
+ uuu::upll_strncpy(vnode_key.vnode_name,
+ tmp_vlink_val->vnode1_name, (kMaxLenVnodeName+1));
+ if (bound_vlink) {
+ uuu::upll_strncpy(boundary_if,
+ tmp_vlink_val->vnode1_ifname, (kMaxLenInterfaceName+1));
+ }
+ swap_npos = 0;
+ }
+ uuu::upll_strncpy(vnode_key.vtn_key.vtn_name,
+ tmp_vlink_key->vtn_key.vtn_name, (kMaxLenVtnName+1));
+ unc_key_type_t tmp_key_type = GetVlinkVnodeIfKeyType(tmp, swap_npos);
+ if (bound_vlink) {
+ if (tmp_key_type == UNC_KT_VBR_IF) {
+ key_vnode_if tmp_boundary_vnode_if;
+ tmp_boundary_vnode_if.vnode_key = vnode_key;
+ uuu::upll_strncpy(tmp_boundary_vnode_if.vnode_if_name, boundary_if, (kMaxLenInterfaceName+1));
+ boundary_if_set->insert(tmp_boundary_vnode_if);
+ }
+ tmp = tmp->get_next_cfg_key_val();
+ continue;
+ }
+ key_vnode_type vnode_key_type;
+ vnode_key_type.vnode_key = vnode_key;
+ vnode_key_type.key_type = tmp_key_type;
+ pr = Vnode_set_obj->insert(vnode_key_type);
+ if (pr.second == true) {
+ GetConnected(&vnode_key_type, Vnode_set_obj, Vlink_set_obj,boundary_if_set, dmi);
+ }
+ tmp = tmp->get_next_cfg_key_val();
+ }
+ } else if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Error in reading vlink DB");
+ DELETE_IF_NOT_NULL(ck_vlink);
+ return result_code;
+ }
+ if (npos == kVnode2) {
+ DELETE_IF_NOT_NULL(ck_vlink);
+ break;
+ }
+ npos = kVnode2;
+ DELETE_IF_NOT_NULL(ck_vlink);
+ } while (1);
+ return result_code;
+}
+
+/*This function updates the operational status of the vlink*/
+upll_rc_t VlinkMoMgr::UpdateVlinkOperStatusUsingVlinkSet(
+ set<key_vlink_t, vlink_compare> *vlink_set, DalDmlIntf *dmi,
+ state_notification notification) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ for (set<key_vlink_t>::iterator vlink_itr = vlink_set->begin();
+ vlink_itr != vlink_set->end(); ++vlink_itr) {
+ key_vlink_t *vlink_key = reinterpret_cast<key_vlink_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vlink_t)));
+ *vlink_key = *vlink_itr;
+ ConfigKeyVal *ck_vlink = new ConfigKeyVal(UNC_KT_VLINK, IpctSt::kIpcStKeyVlink,
+ vlink_key, NULL);
+ result_code = SetOperStatus(ck_vlink, dmi, notification);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("Record updation failed in UPLL_DT_STATE %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ck_vlink);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(ck_vlink);
+ }
+ return result_code;
+}
} // namespace kt_momgr
} // namespace upll
} // namespace unc
#define NO_VN1_RENAME 0xFB
#define NO_VN2_RENAME 0xF7
+typedef struct key_vnode_if_t {
+ key_vnode_t vnode_key;
+ uint8_t vnode_if_name[kMaxLenInterfaceName+1];
+}key_vnode_if;
+
+struct key_vnode_if_compare {
+ inline bool operator()(const key_vnode_if &keyvnodeif1,
+ const key_vnode_if keyvnodeif2) const {
+ int ret = strcmp((const char *)keyvnodeif1.vnode_key.vtn_key.vtn_name,
+ (const char *)keyvnodeif2.vnode_key.vtn_key.vtn_name);
+ if (ret == 0) {
+ ret = strcmp((const char *)keyvnodeif1.vnode_key.vnode_name,
+ (const char*)keyvnodeif2.vnode_key.vnode_name);
+ if (ret == 0) {
+ return (strcmp((const char *)keyvnodeif1.vnode_if_name,
+ (const char*)keyvnodeif2.vnode_if_name) < 0);
+ } else
+ return (ret < 0);
+ } else
+ return (ret < 0);
+ }
+};
typedef struct key_vlink_user_data {
key_user_data_t user_data1;
}\
}
+enum NodePosition {
+ kVnode1,
+ kVnode2
+};
+
class VlinkMoMgr : public VnodeMoMgr {
private:
static unc_key_type_t vlink_child[];
static BindInfo key_vlink_renametbl_update_bind_info[];
ConfigKeyVal *ck_boundary;
- /**
- * @brief Gets the associated config and state information for interfaces
- * that constitute the vlink
- *
- * @param[in] vlink ConfigKeyVal pointer to the vlink
- * @param[out] vnif array of pointers to the vlink member interfaces
- * @param[in] dmi Database connection params
- *
- * @retval UPLL_RC_SUCCESS validation succeeded.
- * @retval UPLL_RC_ERR_GENERIC Illegal operation/ invalid paramters
- **/
- upll_rc_t GetVnodeIfFromVlink(ConfigKeyVal *vlink,
- ConfigKeyVal **vnif,
- DalDmlIntf *dmi) ;
+ /* @brief Retrieve oper status of boundary port from physical
+ *
+ * @param[in] boundary_name pointer to boundary name
+ * @param[in] ctr_domain pointer to controller and domain id pair
+ * @param[out] bound_operStatus operstatus of boundary
+ * @param[in] session_id transaction session id
+ * @param[in] config_id transaction config id
+ *
+ * @retval UPLL_RC_SUCCESS Completed successfully.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ *
+ **/
+ upll_rc_t GetBoundaryStatusFromPhysical(uint8_t *boundary_name,
+ controller_domain_t *ctr_domain,
+ val_oper_status &bound_operStatus,
+ uint32_t session_id,
+ uint32_t config_id) ;
- /**
- * @brief Gets the keytype of the vlink member interface specified by pos
- *
- * @param[in] ck_vlink ConfigKeyVal pointer to the vlink
- * @param[in] pos 0/1 corresponding to the first/second member
- * interface
- *
- * @retval unc_key_type_t keytype of the specified member interface
- * KT_ROOT if unsupported iftype.
- **/
- unc_key_type_t GetVlinkVnodeIfKeyType(ConfigKeyVal *ck_vlink,
- int pos ) {
- uint8_t vnif_type;
- uint8_t vlink_flag = 0;
- GET_USER_DATA_FLAGS(ck_vlink,vlink_flag);
- if (pos == 0)
- vnif_type = GET_VLINK_NODE1_TYPE(vlink_flag);
- else
- vnif_type = GET_VLINK_NODE2_TYPE(vlink_flag);
- unc_key_type_t if_ktype[] = {UNC_KT_ROOT,UNC_KT_VBR_IF, UNC_KT_VRT_IF,
- UNC_KT_VUNK_IF, UNC_KT_VTEP_IF,UNC_KT_VTUNNEL_IF};
- if (vnif_type >= sizeof(if_ktype)/sizeof(if_ktype[0]))
- return UNC_KT_ROOT;
- return if_ktype[vnif_type];
- }
/**
* @brief Gets the valid array position of the variable in the value
*/
upll_rc_t ValidateMessage(IpcReqRespHeader *req,
ConfigKeyVal *ikey);
+ /**
+ * @Brief compares controller id and domain id before
+ * updating the value to DB.
+ *
+ * @param[in] ikey ikey contains key and value structure.
+ * @param[in] okey okey contains key and value structure.
+ *
+ * @retval UPLL_RC_SUCCESS Successful.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX Syntax error.
+ */
+ upll_rc_t CtrlrIdAndDomainIdUpdationCheck(ConfigKeyVal *ikey,
+ ConfigKeyVal *okey) {
+ UPLL_LOG_TRACE("Not needed for this KT, returning SUCCESS");
+ return UPLL_RC_SUCCESS;
+ }
/**
* @Brief Validates the syntax for KT_VLINK keytype key structure.
* associated attributes are supported on the given controller,
* based on the valid flag.
*
- * @param[in] crtlr_name Controller name.
- * @param[in] ikey Corresponding key and value structure.
+ * @param[in] val_vlink Value Structure.
+ * @param[in] attr pointer to controller attribute
+ * @param[in] operation Operation Name
*
* @retval UPLL_RC_SUCCESS validation succeeded.
* @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
* @retval UPLL_RC_ERR_GENERIC Generic failure.
*/
- upll_rc_t ValVlinkAttributeSupportCheck(const char * crtlr_name,
- ConfigKeyVal *ikey,
- uint32_t operation);
+ upll_rc_t ValVlinkAttributeSupportCheck(val_vlink_t *val_vlink,
+ const uint8_t* attrs, unc_keytype_operation_t operation);
/**
* @brief Get the specific vtn_name and vnode_name from ConfigKeyVal
**/
upll_rc_t AllocVal(ConfigVal *&ck_val, upll_keytype_datatype_t dt_type,
MoMgrTables tbl = MAINTBL);
- /**
- * @brief Method to get a configkeyval of a specified keytype from an input configkeyval
- *
- * @param[in/out] okey pointer to output ConfigKeyVal
- * @param[in] parent_key pointer to the configkeyval from which the output configkey val is initialized.
- *
- * @retval UPLL_RC_SUCCESS Successfull completion.
- * @retval UPLL_RC_ERR_GENERIC Failure case.
- */
- upll_rc_t GetChildConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *parent_key);
/**
* @brief Method to get a configkeyval of the parent keytype
*
/**
* @brief Check if Vlink interfaces are unique and update accordingly
*
- * @param[in] dt_type database type
+ * @param[in] req IpcReqRespHeader
* @param[in] ikey pointer to ConfigKeyVal
* @param[in] dmi pointer to DalDmlIntf
* @param[in] controller_ids pointer to array of controller domains
* @retval UPLL_RC_SUCCESS Successful
* @retval UPLL_RC_ERR_GENERIC Generic error/Failed to update VbrIf
*/
- upll_rc_t UpdateVlinkIf(upll_keytype_datatype_t dt_type,
+ upll_rc_t UpdateVlinkIf(IpcReqRespHeader *req,
ConfigKeyVal *ikey, DalDmlIntf *dmi,
controller_domain_t *ctrlr_dom);
/**
* @param[in] ikey pointer to ConfigKeyVal
* @param[in] ck_vbrif array of pointers to component vbrifs
* @param[in] dmi pointer to DalDmlIntf
+ * @param[in] op UPLL operation
*
* @retval UPLL_RC_SUCCESS Successful
* @retval UPLL_RC_ERR_GENERIC Generic error/Failed to update VbrIf
*/
- upll_rc_t UpdateVbrIfExternal(upll_keytype_datatype_t dt_type,
- ConfigKeyVal *ikey, ConfigKeyVal **cv_vbrif, DalDmlIntf *dmi);
+ upll_rc_t UpdateVnodeIf(upll_keytype_datatype_t dt_type,
+ ConfigKeyVal *ikey, ConfigKeyVal **cv_vbrif, DalDmlIntf *dmi,
+ unc_keytype_operation_t op);
/**
* @brief Check if the Vlink interface is a VbrIf. If it is VbrIf,
* Update portmap if port on switch in not preconfigured
with settings different from physical data
*
- * @param[in] ikey pointer to ConfigKeyVal
- * @param[in] ikey pointer to ConfigKeyVal
+ * @param[in] ikey pointer to vlink ConfigKeyVal
+ * @param[in] ikey pointer to vnode interface ConfigKeyVal
* @param[in] dmi pointer to DalDmlIntf
- * @param[in] rename_vbr_if uint8_t
+ * @param[in] dt_type Data type (candidate/running)
+ * @param[in] op operation
*
* @retval UPLL_RC_SUCCESS Successful
* @retval UPLL_RC_ERR_NO_SUCH_INSTANCE vLink Interface is not a VbrIf Interface
* @retval UPLL_RC_ERR_GENERIC Generic error/Failed to update VbrIfi
*/
- upll_rc_t CheckPortmapValidandUpdateVbrIf(ConfigKeyVal *ikey,
- ConfigKeyVal *ck_drv_vbr_if,
- DalDmlIntf *dmi,
- upll_keytype_datatype_t dt_type);
+ upll_rc_t UpdateVnodeIfPortmap(ConfigKeyVal *ikey,
+ ConfigKeyVal *ck_drv_vbr_if,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t dt_type,
+ unc_keytype_operation_t op);
bool GetBoundaryData(ConfigKeyVal *ikey,
IpcRequest *ipc_req,
upll_rc_t CreateCandidateMo(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
DalDmlIntf *dmi);
+ upll_rc_t CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id);
/**
* @brief Creates a vnode entry in DB after performing pre-requisite checks
*
unc_keytype_configstatus_t cs_status,
DalDmlIntf *dmi);
+ /**
+ * @brief Validate whether its valid Boundary Combination
+ *
+ * @param[in] node1_ktype Ketype of first Node
+ * @param[in] node2_ktype Ketype of Second Node
+ *
+ * @retval UPLL_RC_SUCCESS Valid combination
+ * @retval UPLL_RC_ERR_CFG_SEMANTIC Invalid combination
+ */
+ upll_rc_t ValidateIfType(ConfigKeyVal **vnodeIf);
+
public:
VlinkMoMgr();
virtual ~VlinkMoMgr() {
delete ck_boundary;
ck_boundary = NULL;
}
+
+ /**
+ * @brief Gets the associated config information for the remote interface
+ * that constitute the vlink
+ *
+ * @param[in] ck_vif ConfigKeyVal pointer to the interface
+ * @param[out] ck_remif ConfigKeyVal pointer to the remote interface
+ * @param[in] dmi Database connection params
+ *
+ * @retval UPLL_RC_SUCCESS validation succeeded.
+ * @retval UPLL_RC_ERR_GENERIC Illegal operation/ invalid paramters
+ **/
+ upll_rc_t GetRemoteIf(ConfigKeyVal *ck_vif,
+ ConfigKeyVal *&ck_remif,
+ DalDmlIntf *dmi);
+ /**
+ * @brief Gets the associated config and state information for interfaces
+ * that constitute the vlink
+ *
+ * @param[in] vlink ConfigKeyVal pointer to the vlink
+ * @param[out] vnif array of pointers to the vlink member interfaces
+ * if both interfaces wanted -
+ * @param[in] dmi Database connection params
+ * @param[in] pos 0 if both interfaces wanted else
+ * kVlinkVnode1/kVlinkVnode2 for that vnode if.
+ *
+ * @retval UPLL_RC_SUCCESS validation succeeded.
+ * @retval UPLL_RC_ERR_GENERIC Illegal operation/ invalid paramters
+ **/
+ upll_rc_t GetVnodeIfFromVlink(ConfigKeyVal *vlink,
+ ConfigKeyVal **vnif,
+ DalDmlIntf *dmi,
+ uint8_t pos = 0) ;
/**
* @brief Method to check if individual portions of a key are valid
*
void *val2,
bool audit);
+ /**
+ * @brief Method to get a configkeyval of a specified keytype from an input configkeyval
+ *
+ * @param[in/out] okey pointer to output ConfigKeyVal
+ * @param[in] parent_key pointer to the configkeyval from which the output configkey val is initialized.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ */
+ upll_rc_t GetChildConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *parent_key);
upll_rc_t ValidateRenameVlinkValue(val_rename_vlink_t *val);
upll_rc_t CheckVnodeInfo(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi);
+
upll_rc_t SetOperStatus(ConfigKeyVal *ikey,
DalDmlIntf *dmi,
- int notification,
+ state_notification notification,
bool skip = false);
upll_rc_t GetNodeType(void *key, bool vnode,
inline upll_rc_t BoundaryVlink(ConfigKeyVal *ck_main,
controller_domain_t *ctrlr_dom,
bool &bound_vlink) {
+ unc_key_type_t ktype1 = GetVlinkVnodeIfKeyType(ck_main, 0);
+ unc_key_type_t ktype2 = GetVlinkVnodeIfKeyType(ck_main, 1);
+ if ((ktype1 == UNC_KT_VUNK_IF) || (ktype2 == UNC_KT_VUNK_IF)) {
+ bound_vlink = true;
+ return UPLL_RC_SUCCESS;
+ }
upll_rc_t result_code = GetControllerDomainId(ck_main, ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning %d", result_code);
return result_code;
}
if((memcmp(ctrlr_dom[0].ctrlr, ctrlr_dom[1].ctrlr,kMaxLenCtrlrId)) ||
uint32_t session_id,
uint32_t config_id,
DalDmlIntf *dmi);
+ upll_rc_t BoundaryStatusHandler(uint8_t boundary_name[32],
+ bool oper_status, DalDmlIntf *dmi);
+
+ /**
+ * @brief Gets the keytype of the vlink member interface specified by pos
+ *
+ * @param[in] ck_vlink ConfigKeyVal pointer to the vlink
+ * @param[in] pos 0/1 corresponding to the first/second member
+ * interface
+ *
+ * @retval unc_key_type_t keytype of the specified member interface
+ * KT_ROOT if unsupported iftype.
+ **/
+ unc_key_type_t GetVlinkVnodeIfKeyType(ConfigKeyVal *ck_vlink,
+ int pos ) {
+ uint8_t vnif_type;
+ uint8_t vlink_flag = 0;
+ if (!ck_vlink || ck_vlink->get_key_type() != UNC_KT_VLINK) {
+ UPLL_LOG_DEBUG("Invalid param");
+ return UNC_KT_ROOT;
+ }
+ GET_USER_DATA_FLAGS(ck_vlink,vlink_flag);
+ if (pos == 0)
+ vnif_type = GET_VLINK_NODE1_TYPE(vlink_flag);
+ else
+ vnif_type = GET_VLINK_NODE2_TYPE(vlink_flag);
+ UPLL_LOG_DEBUG("flag %d vnif_type %d pos %d",vlink_flag,vnif_type,pos);
+ unc_key_type_t if_ktype[] = {UNC_KT_ROOT,UNC_KT_VBR_IF, UNC_KT_VRT_IF,
+ UNC_KT_VUNK_IF, UNC_KT_VTEP_IF,UNC_KT_VTUNNEL_IF};
+ if (vnif_type >= sizeof(if_ktype)/sizeof(if_ktype[0]))
+ return UNC_KT_ROOT;
+ return if_ktype[vnif_type];
+ }
+ upll_rc_t RestoreVlinkOperStatus(ConfigKeyVal *ck_vnif,
+ DalDmlIntf *dmi,
+ state_notification notification,
+ bool skip);
+ upll_rc_t UpdateVlinkOperStatus(uint8_t *ctrlr_id,
+ DalDmlIntf *dmi,
+ state_notification notification,
+ bool skip);
+ upll_rc_t GetConnected(key_vnode_type_t *src_node,
+ set<key_vnode_type_t,key_vnode_type_compare> *Vnode_set_obj,
+ set<key_vlink_t,vlink_compare>*Vlink_set_obj,
+ set<key_vnode_if_t, key_vnode_if_compare>* boundary_vnode_if,
+ DalDmlIntf *dmi);
+
+ upll_rc_t UpdateVlinkOperStatusUsingVlinkSet(
+ set<key_vlink_t, vlink_compare>*vlink_set,
+ DalDmlIntf *dmi, state_notification notification);
+
};
typedef struct val_db_rename_vlink {
#include "vnode_child_momgr.hh"
#include "vnode_momgr.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "vbr_if_momgr.hh"
#include "vtn_momgr.hh"
#include "vlink_momgr.hh"
+#include "config_mgr.hh"
namespace unc {
namespace upll {
ctrlr_dom.ctrlr = NULL;
ctrlr_dom.domain = NULL;
ConfigKeyVal *pckv = NULL;
- result_code = GetParentConfigKey(pckv, ikey);
- if (result_code != UPLL_RC_SUCCESS && pckv == NULL) {
- UPLL_LOG_DEBUG("GetParentConfigKey failed err_code is %d\n",
- result_code);
+ uint8_t *controller_id = reinterpret_cast<uint8_t *>(
+ const_cast<char *>(ctrlr_id));
+
+ /* check if object is renamed in the corresponding Rename Tbl
+ * if "renamed" create the object by the UNC name.
+ * else - create using the controller name.
+ */
+ result_code = GetRenamedUncKey(ikey, UPLL_DT_RUNNING, dmi, controller_id);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey Failed err_code %d", result_code);
return result_code;
}
- result_code = GetControllerDomainId(pckv, UPLL_DT_AUDIT,
- &ctrlr_dom, dmi);
- if ((result_code != UPLL_RC_SUCCESS) || (cntrl_dom.ctrlr == NULL)
- || (cntrl_dom.domain == NULL)) {
- UPLL_LOG_INFO("GetControllerDomainId failed err_code %d\n", result_code);
+ if ((ikey->get_key_type() == UNC_KT_VTEP_GRP) ||
+ (ikey->get_key_type() == UNC_KT_VTEP_GRP_MEMBER)) {
+ result_code = GetControllerDomainId(ikey, UPLL_DT_AUDIT,
+ &ctrlr_dom, dmi);
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+ } else {
+ result_code = GetParentConfigKey(pckv, ikey);
+ if (result_code != UPLL_RC_SUCCESS && pckv == NULL) {
+ UPLL_LOG_DEBUG("GetParentConfigKey failed err_code is %d",
+ result_code);
+ return result_code;
+ }
+ result_code = GetControllerDomainId(pckv, UPLL_DT_AUDIT,
+ &ctrlr_dom, dmi);
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ GET_USER_DATA_CTRLR_DOMAIN(pckv, ctrlr_dom);
+ SET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+ DELETE_IF_NOT_NULL(pckv);
+ }
+
+ if ((result_code != UPLL_RC_SUCCESS) || (ctrlr_dom.ctrlr == NULL)
+ || (ctrlr_dom.domain == NULL)) {
+ UPLL_LOG_INFO("GetControllerDomainId failed err_code %d", result_code);
+ DELETE_IF_NOT_NULL(pckv);
return UPLL_RC_ERR_GENERIC;
}
- SET_USER_DATA_CTRLR_DOMAIN(ikey,ctrlr_dom);
- result_code = UpdateConfigDB(ikey, UPLL_DT_AUDIT, UNC_OP_CREATE, dmi, MAINTBL);
+ DbSubOp dbop = { kOpNotRead, kOpMatchNone, kOpInOutFlag | kOpInOutDomain
+ | kOpInOutCtrlr };
+ // SET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+ result_code = UpdateConfigDB(ikey, UPLL_DT_AUDIT, UNC_OP_CREATE,
+ dmi, &dbop, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("UpdateConfigDB failed for creating vnode child err_code %d\n",
+ UPLL_LOG_INFO("UpdateConfigDB failed for creating vnode child err_code %d",
result_code);
}
+ DELETE_IF_NOT_NULL(pckv);
return result_code;
}
result_code = ValidateMessage(req, ikey);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
return result_code;
}
dmi, MAINTBL);
if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE
|| result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
- UPLL_LOG_INFO("Parent doesn't exist in CANDIDATE DB. Error code : %d",
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_INFO("Parent doesn't exist in CANDIDATE DB. Error code : %d",
result_code);
- return UPLL_RC_ERR_PARENT_DOES_NOT_EXIST;
+ DELETE_IF_NOT_NULL(parent_ck_vnode);
+ return UPLL_RC_ERR_PARENT_DOES_NOT_EXIST;
+ }else {
+ UPLL_LOG_DEBUG("UpdateConfigDB Failed %d", result_code);
+ DELETE_IF_NOT_NULL(parent_ck_vnode);
+ return result_code;
+ }
}
-
- result_code = GetControllerDomainId(parent_ck_vnode, req->datatype,
+ if ((ikey->get_key_type() == UNC_KT_VTEP_GRP) ||
+ (ikey->get_key_type() == UNC_KT_VTEP_GRP_MEMBER)) {
+ result_code = GetControllerDomainId(ikey, req->datatype,
&cntrl_dom, dmi);
+ cntrl_dom.ctrlr = NULL;
+ if (ikey->get_key_type() != UNC_KT_VTEP_GRP)
+ cntrl_dom.domain = NULL;
+
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, cntrl_dom);
+ } else {
+ result_code = GetControllerDomainId(parent_ck_vnode, req->datatype,
+ &cntrl_dom, dmi);
+ cntrl_dom.ctrlr = NULL;
+ cntrl_dom.domain = NULL;
+ GET_USER_DATA_CTRLR_DOMAIN(parent_ck_vnode, cntrl_dom);
+ SET_USER_DATA_CTRLR_DOMAIN(ikey, cntrl_dom);
+ }
if ((result_code != UPLL_RC_SUCCESS) || (cntrl_dom.ctrlr == NULL)
|| (cntrl_dom.domain == NULL)) {
- UPLL_LOG_INFO("Illegal params\n");
- return UPLL_RC_ERR_GENERIC;
+ UPLL_LOG_INFO("Illegal params");
+ DELETE_IF_NOT_NULL(parent_ck_vnode);
+ return result_code;
}
- SET_USER_DATA_CTRLR_DOMAIN(ikey,cntrl_dom);
- // check for key support on controller and max count
- if (UPLL_DT_CANDIDATE == req->datatype) {
- ConfigKeyVal *dup_ikey = NULL;
- result_code = GetChildConfigKey(dup_ikey,ikey);
- if (!dup_ikey || result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n",result_code);
- return result_code;
+ ConfigKeyVal *dup_ikey = NULL;
+ if (UPLL_DT_IMPORT != req->datatype) {
+ void *ifval = GetVal(ikey);
+ if ((ikey->get_key_type() == UNC_KT_VBR_IF) && ifval) {
+ result_code = GetChildConfigKey(dup_ikey, ikey);
+ if (!dup_ikey || result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(parent_ck_vnode);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ return result_code;
+ }
+ val_drv_vbr_if *valif = reinterpret_cast<val_drv_vbr_if *>
+ (ConfigKeyVal::Malloc(sizeof(val_drv_vbr_if)));
+ memcpy(&(valif->vbr_if_val), ifval, sizeof(val_vbr_if));
+ dup_ikey->AppendCfgVal(IpctSt::kIpcStPfcdrvValVbrIf, valif);
+ } else {
+ dup_ikey = ikey;
+ }
+ } else {
+ dup_ikey = ikey;
+ }
+ UPLL_LOG_DEBUG("%s \n",dup_ikey->ToStrAll().c_str());
+
+ // Existence check in DB
+ result_code = UpdateConfigDB(dup_ikey, req->datatype, UNC_OP_READ, dmi, MAINTBL);
+ if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS
+ || result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ DELETE_IF_NOT_NULL(parent_ck_vnode);
+ if (UPLL_DT_IMPORT != req->datatype) {
+ void *ifval = GetVal(ikey);
+ if ((ikey->get_key_type() == UNC_KT_VBR_IF) && ifval) {
+ DELETE_IF_NOT_NULL(dup_ikey);
+ }
}
- result_code = GetInstanceCount(dup_ikey, reinterpret_cast<char*>
+ return result_code;
+ }
+ ConfigKeyVal *inst_key = NULL;
+ result_code = GetChildConfigKey(inst_key, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(parent_ck_vnode);
+ DELETE_IF_NOT_NULL(dup_ikey);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ return result_code;
+ }
+ result_code = GetInstanceCount(inst_key, reinterpret_cast<char*>
(cntrl_dom.ctrlr), req->datatype, &cur_instance_count, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
+ if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_INFO("GetInstanceCount error %d", result_code);
+ DELETE_IF_NOT_NULL(dup_ikey);
+ DELETE_IF_NOT_NULL(parent_ck_vnode);
+ DELETE_IF_NOT_NULL(inst_key);
return UPLL_RC_ERR_GENERIC;
- }
- if (dup_ikey) delete dup_ikey;
- dup_ikey = NULL;
}
-// TODO(vinoth): capa validation
-#if 0
+ DELETE_IF_NOT_NULL(inst_key);
result_code = ValidateCapability(req, ikey);
if (result_code != UPLL_RC_SUCCESS) {
- // cout << "ValidateCapability failed \n";
+ UPLL_LOG_TRACE("ValidateCapability failed");
+ DELETE_IF_NOT_NULL(parent_ck_vnode);
+ if (UPLL_DT_IMPORT != req->datatype) {
+ void *ifval = GetVal(ikey);
+ if ((ikey->get_key_type() == UNC_KT_VBR_IF) && ifval) {
+ DELETE_IF_NOT_NULL(dup_ikey);
+ }
+ }
return result_code;
}
-#endif
- // Existence check in CANDIDATE DB
- result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_READ, dmi, MAINTBL);
- if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS
- || result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- return result_code;
+ SET_USER_DATA_CTRLR_DOMAIN(dup_ikey, cntrl_dom);
+ result_code = RestoreVnode(dup_ikey, req, dmi);
+ DELETE_IF_NOT_NULL(parent_ck_vnode);
+
+ if (UPLL_DT_IMPORT != req->datatype) {
+ void *ifval = GetVal(ikey);
+ if ((ikey->get_key_type() == UNC_KT_VBR_IF) && ifval) {
+ DELETE_IF_NOT_NULL(dup_ikey);
+ }
}
- SET_USER_DATA_CTRLR_DOMAIN(ikey, cntrl_dom);
- result_code = RestoreVnode(ikey, req, dmi);
return result_code;
}
if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
result_code = RestoreChildren(ikey, dt_type, UPLL_DT_RUNNING, dmi);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
return result_code;
}
return result_code;
}
}
- if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE
|| UPLL_DT_IMPORT == req->datatype) {
- UPLL_LOG_TRACE("Given Create Record doesn't exists in Running \n");
+ UPLL_LOG_TRACE("Given Create Record doesn't exists in Running");
result_code = DupConfigKeyVal(dup_ikey, ikey);
if (result_code != UPLL_RC_SUCCESS || dup_ikey == NULL) {
- UPLL_LOG_DEBUG("Returning %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning %d", result_code);
return result_code;
}
result_code = ValidateAttribute(dup_ikey, dmi, req);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("ValidateAttribute semantic check returns error %d\n",
+ UPLL_LOG_INFO("ValidateAttribute semantic check returns error %d",
result_code);
return result_code;
}
return result_code;
}
}
- }
- if (dup_ikey->get_key_type() == UNC_KT_VBR_IF) {
- val_drv_vbr_if_t *if_val = reinterpret_cast<val_drv_vbr_if *>
- (GetVal(dup_ikey));
- if (if_val != NULL &&
+
+ if (dup_ikey->get_key_type() == UNC_KT_VBR_IF) {
+ val_drv_vbr_if_t *if_val = reinterpret_cast<val_drv_vbr_if *>
+ (GetVal(dup_ikey));
+ if (if_val != NULL &&
if_val->vbr_if_val.valid[UPLL_IDX_PM_VBRI] == UNC_VF_VALID) {
- ConverttoDriverPortMap(dup_ikey);
+ ConverttoDriverPortMap(dup_ikey);
+ }
}
}
result_code = UpdateConfigDB(dup_ikey, dt_type, UNC_OP_CREATE, dmi, MAINTBL);
}
result_code = GetChildConfigKey(okey, ikey);
if (result_code != UPLL_RC_SUCCESS || okey == NULL) {
- UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
return result_code;
}
DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutFlag };
- result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop,
+ result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop,
dmi, MAINTBL);
while (okey) {
uint8_t if_flag = 0;
- GET_USER_DATA_FLAGS(okey,if_flag);
+ GET_USER_DATA_FLAGS(okey, if_flag);
if_flag &= VIF_TYPE;
if (if_flag) {
- UPLL_LOG_DEBUG("Part of a vlink %d\n",if_flag);
+ UPLL_LOG_DEBUG("Part of a vlink %d", if_flag);
result_code = UPLL_RC_ERR_CFG_SEMANTIC;
break;
}
&ctrlr_dom,
UNC_RENAME_KEY);
else
- result_code = UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ result_code = UPLL_RC_SUCCESS;
return result_code;
}
UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom->ctrlr,
ctrlr_dom->domain);
} else {
- result_code = UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ result_code = UPLL_RC_SUCCESS;
}
return result_code;
}
unc_key_type_t ktype = ck_parent->get_key_type();
MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>
(GetMoManager(ktype)));
- if (flag == UNC_RENAME_KEY)
- result_code = mgr->GetRenamedUncKey(ck_parent, dt_type, dmi,
- ctrlr_dom->ctrlr);
- else
+ if (flag == UNC_RENAME_KEY) {
+ result_code = mgr->GetRenamedUncKey(ck_parent, dt_type, dmi,
+ ctrlr_dom->ctrlr);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey failed. Result : %d", result_code);
+ DELETE_IF_NOT_NULL(ck_parent);
+ return result_code;
+ }
+ } else {
result_code = mgr->GetRenamedControllerKey(ck_parent, dt_type, dmi,
ctrlr_dom);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetRenamedControllerKey failed. Result: %d", result_code);
+ DELETE_IF_NOT_NULL(ck_parent);
+ return result_code;
+ }
+ }
if (result_code == UPLL_RC_SUCCESS) {
+ result_code = GetChildConfigKey(ikey, ck_parent);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL (ck_parent);
+ UPLL_LOG_DEBUG("GetChildConfigkey Failed");
+ return result_code;
+ }
SET_USER_DATA(ikey, ck_parent)
- GET_USER_DATA_CTRLR_DOMAIN(ikey,*ctrlr_dom);
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, *ctrlr_dom);
}
delete ck_parent;
return result_code;
case UNC_KT_VUNK_IF:
case UNC_KT_VTEP_IF:
case UNC_KT_VTUNNEL_IF:
- UPLL_LOG_DEBUG("read request for %d,option 1 %d option2 %d\n",ktype,
- header->option1,header->option2);
+ UPLL_LOG_DEBUG("read request for %d, option 1 %d option2 %d", ktype,
+ header->option1, header->option2);
if (header->option2 == UNC_OPT2_NEIGHBOR) {
result_code = ValidateMessage(header, ikey);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("ValidateMessage failed result_code %d\n", result_code);
+ UPLL_LOG_DEBUG("ValidateMessage failed result_code %d", result_code);
return result_code;
}
result_code = PopulateValVtnNeighbor(ikey, dmi);
default:
result_code = MoMgrImpl::ReadMo(header, ikey, dmi);
}
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
- }
return result_code;
}
result_code = mgr->ReadConfigDB(pckv, dt_type, UNC_OP_READ, dbop, dmi,
MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("ReadConfigDB failed for pckv err_code %d\n", result_code);
+ UPLL_LOG_INFO("ReadConfigDB failed for pckv err_code %d", result_code);
return result_code;
}
return (mgr->GetControllerDomainId(pckv, ctrlr_dom));
VlinkMoMgr *vlink_momgr = reinterpret_cast<VlinkMoMgr *>
(const_cast<MoManager*>(GetMoManager(UNC_KT_VLINK)));
if (!vlink_momgr) {
- UPLL_LOG_DEBUG("Invalid Mgr\n");
+ UPLL_LOG_DEBUG("Invalid Mgr");
return UPLL_RC_ERR_GENERIC;
}
vn_if_type iftype;
key_vlink_t *vlink_key = reinterpret_cast<key_vlink_t *>
(vlink_ckv->get_key());
if (!vlink_key) {
- UPLL_LOG_DEBUG("Invalid param\n");
+ UPLL_LOG_DEBUG("Invalid param");
if (vlink_ckv) delete vlink_ckv;
return UPLL_RC_ERR_GENERIC;
}
val_vlink_t *vlink_val = reinterpret_cast<val_vlink *>
(GetVal(vlink_ckv));
val_vtn_neighbor_t *val_vtn_neighbor =
- reinterpret_cast<val_vtn_neighbor_t *>(malloc(sizeof(val_vtn_neighbor_t)));
+ reinterpret_cast<val_vtn_neighbor_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtn_neighbor_t)));
memset(val_vtn_neighbor, 0, sizeof(val_vtn_neighbor_t));
val_vtn_neighbor->valid[UPLL_IDX_CONN_VNODE_NAME_VN] = UNC_VF_VALID;
val_vtn_neighbor->valid[UPLL_IDX_CONN_VNODE_IF_NAME_VN] = UNC_VF_VALID;
UPLL_FUNC_TRACE;
T2 *vnif_db_st = reinterpret_cast<T2 *>(GetStateVal(ikey));
if (!vnif_db_st) {
- UPLL_LOG_DEBUG("Invalid param\n");
+ UPLL_LOG_DEBUG("Invalid param");
return UPLL_RC_ERR_GENERIC;
}
T1 *vnif_st = reinterpret_cast<T1 *>(vnif_db_st);
- vnif_db_st->down_count = 0;
+ // vnif_db_st->down_count = 0;
+#if 0
if ((valid_admin == UNC_VF_VALID) ||
- (valid_admin == UNC_VF_VALID_NO_VALUE)) {
- if (admin_status == UPLL_ADMIN_DISABLE) {
+ (valid_admin == UNC_VF_VALID_NO_VALUE))
+#endif
+ if (vnif_st->oper_status != UPLL_OPER_STATUS_UNINIT) {
+ if (admin_status == UPLL_ADMIN_DISABLE) {
vnif_st->oper_status = UPLL_OPER_STATUS_DOWN;
- } else {
- if_type vnif_type = kUnboundInterface;
- GetInterfaceType(ikey, valid_pm, vnif_type);
- switch (vnif_type) {
- case kBoundaryInterface:
- case kMappedInterface:
- if (valid_pm != UNC_VF_VALID)
- vnif_st->oper_status = UPLL_OPER_STATUS_DOWN;
- else
- vnif_st->oper_status = UPLL_OPER_STATUS_UNINIT;
- break;
- case kLinkedInterface:
- vnif_st->oper_status = UPLL_OPER_STATUS_UP;
- break;
- case kUnboundInterface:
- vnif_st->oper_status = UPLL_OPER_STATUS_DOWN;
- break;
+ } else if (admin_status == UPLL_ADMIN_ENABLE) {
+ if_type vnif_type = kUnboundInterface;
+ GetInterfaceType(ikey, valid_pm, vnif_type);
+ UPLL_LOG_DEBUG("ktype %d vnif_type %d valid_pm %d\n",
+ ikey->get_key_type(),vnif_type, valid_pm);
+ switch (vnif_type) {
+ case kBoundaryInterface:
+ case kMappedInterface:
+ if (valid_pm != UNC_VF_VALID)
+ vnif_st->oper_status = UPLL_OPER_STATUS_DOWN;
+ else
+ vnif_st->oper_status = UPLL_OPER_STATUS_UNINIT;
+ break;
+ case kLinkedInterface:
+ vnif_st->oper_status = UPLL_OPER_STATUS_UP;
+ break;
+ case kUnboundInterface:
+ vnif_st->oper_status = UPLL_OPER_STATUS_DOWN;
+ break;
+ }
+ } else {
+ vnif_st->oper_status = UPLL_OPER_STATUS_UNKNOWN;
}
- }
- } else {
- vnif_st->oper_status = UPLL_OPER_STATUS_UNKNOWN;
}
vnif_st->valid[UPLL_IDX_OPER_STATUS_VRTS] = UNC_VF_VALID;
return UPLL_RC_SUCCESS;
uint8_t admin_status,
uint8_t valid_pm,
val_port_map_t *pm);
+template upll_rc_t VnodeChildMoMgr::InitOperStatus<val_vtep_if_st,
+ val_db_vtep_if_st>(
+ ConfigKeyVal *ikey,
+ uint8_t valid_admin,
+ uint8_t admin_status,
+ uint8_t valid_pm,
+ val_port_map_t *pm);
+template upll_rc_t VnodeChildMoMgr::InitOperStatus<val_vtunnel_if_st,
+ val_db_vtunnel_if_st>(
+ ConfigKeyVal *ikey,
+ uint8_t valid_admin,
+ uint8_t admin_status,
+ uint8_t valid_pm,
+ val_port_map_t *pm);
template upll_rc_t VnodeChildMoMgr::InitOperStatus<val_vbr_if_st,
val_db_vbr_if_st>(
ConfigKeyVal *ikey,
if_type &vnif_type ) {
UPLL_FUNC_TRACE;
if (!ck_vnif) {
- UPLL_LOG_DEBUG("Invalid param\n");
+ UPLL_LOG_DEBUG("Invalid param");
return UPLL_RC_ERR_GENERIC;
}
uint8_t flags = 0;
- GET_USER_DATA_FLAGS(ck_vnif,flags);
+ GET_USER_DATA_FLAGS(ck_vnif, flags);
flags = flags & VIF_TYPE;
if (flags & VIF_TYPE_BOUNDARY) {
vnif_type = kBoundaryInterface;
} else {
vnif_type = kUnboundInterface;
}
+ UPLL_LOG_DEBUG("flags %d vnif_type %d", flags, vnif_type);
return UPLL_RC_SUCCESS;
}
+upll_rc_t VnodeChildMoMgr::UpdateParentOperStatus(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ if (!ikey) {
+ UPLL_LOG_ERROR("Returning error \n");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ unc_key_type_t ktype = ikey->get_key_type();
+ if ((ktype != UNC_KT_VBR_IF) && (ktype != UNC_KT_VRT_IF))
+ return UPLL_RC_SUCCESS;
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutNone};
+ // value not bound during delete - read to get down count / oper status
+ result_code = ReadConfigDB(ikey, UPLL_DT_STATE, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ return result_code;
+ }
+ val_db_vbr_if_st *valst = reinterpret_cast<val_db_vbr_if_st *>(GetStateVal(ikey));
+ if (!valst) {
+ UPLL_LOG_DEBUG("Returning error\n");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (valst->vbr_if_val_st.valid[UPLL_IDX_OPER_STATUS_VBRS] == UNC_VF_VALID) {
+ if (valst->vbr_if_val_st.oper_status != UPLL_OPER_STATUS_DOWN)
+ return UPLL_RC_SUCCESS;
+ ConfigKeyVal *ck_vn = NULL;
+ result_code = GetParentConfigKey(ck_vn,ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ return result_code;
+ }
+ VnodeMoMgr *mgr = reinterpret_cast<VnodeMoMgr *>(const_cast<MoManager *>
+ (GetMoManager(ck_vn->get_key_type())));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Returning error \n");
+ delete ck_vn;
+ return UPLL_RC_ERR_GENERIC;
+ }
+#if 0
+ result_code = mgr->ReadConfigDB(ck_vn, UPLL_DT_STATE, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ } else
+ result_code = UPLL_RC_SUCCESS;
+ DELETE_IF_NOT_NULL(ck_vn);
+ return result_code;
+ }
+ val_db_vbr_if_st *vn_valst = reinterpret_cast<val_db_vbr_if_st *>
+ GetStateVal(ck_vn);
+ if (valst->down_count > 0) {
+ vn_valst->down_count--;
+ }
+ result_code = mgr->GetCkvUninit(ck_vn,NULL,dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ DELETE_IF_NOT_NULL(ck_vn);
+ return result_code;
+ }
+ result_code = mgr->UpdateConfigDB(ck_vn, UPLL_DT_STATE, UNC_OP_UPDATE,
+ dmi, MAINTBL);
+#else
+ state_notification notification = (valst->down_count > 0)?kPortFaultReset:kAdminStatusEnabled;
+ result_code = mgr->UpdateOperStatus(ck_vn, dmi, notification, false, true);
+#endif
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
+ UPLL_RC_SUCCESS:result_code;
+ }
+ DELETE_IF_NOT_NULL(ck_vn);
+ }
+ return result_code;
+}
upll_rc_t VnodeChildMoMgr::UpdateOperStatus(ConfigKeyVal *ikey,
DalDmlIntf *dmi,
state_notification notification,
- bool skip) {
- upll_rc_t result_code;
+ bool skip, bool upd_if, bool upd_remif,
+ bool save_to_db) {
UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
if (!skip) {
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchCtrlr | kOpMatchDomain,
+ kOpInOutCtrlr | kOpInOutDomain | kOpInOutFlag };
+ if (notification == kCtrlrDisconnect || notification == kCtrlrReconnect) {
+ dbop.matchop = kOpMatchCtrlr;
+ dbop.inoutop = kOpInOutFlag;
+ }
result_code = ReadConfigDB(ikey, UPLL_DT_STATE, UNC_OP_READ, dbop, dmi,
MAINTBL);
+
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Error in reading: %d", result_code);
+ UPLL_LOG_DEBUG("Error in reading: %d", result_code);
return result_code;
}
}
ConfigKeyVal *tkey = ikey;
- unc_key_type_t ktype = ikey->get_key_type();
+ unc_key_type_t ktype = ikey->get_key_type(),pktype = UNC_KT_ROOT;
while (tkey != NULL) {
- bool oper_status_change;
- if (ktype == UNC_KT_VBR_IF) {
- oper_status_change = SetOperStatus
- <val_vbr_if_st, val_db_vbr_if_st>(tkey, notification, dmi);
- } else if (ktype == UNC_KT_VRT_IF) {
- oper_status_change = SetOperStatus
- <val_vrt_if_st, val_db_vrt_if_st>(tkey, notification, dmi);
- } else if (ktype == UNC_KT_VTEP_IF) {
- oper_status_change = SetOperStatus
- <val_vtep_if_st, val_db_vtep_if_st>(tkey, notification, dmi);
- } else if (ktype == UNC_KT_VTUNNEL_IF) {
- oper_status_change = SetOperStatus
- <val_vtunnel_if_st, val_db_vtunnel_if_st>(tkey, notification, dmi);
- } else {
- UPLL_LOG_DEBUG("oper status attribute not supported\n");
+ /* upd_if is set to true ->if operstatus
+ * is updated as part of vlink processing.
+ */
+ if (!upd_if) {
+ if_type vnif_type ;
+ result_code = GetInterfaceType(tkey,UNC_VF_INVALID,vnif_type);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ return result_code;
+ }
+ if ((vnif_type == kBoundaryInterface) ||
+ (vnif_type == kLinkedInterface)) {
+ tkey = tkey->get_next_cfg_key_val();
+ continue;
+ }
+ }
+ alarm_status oper_status_change = ALARM_NOT_SET;
+ switch (ktype) {
+ case UNC_KT_VBR_IF:
+ pktype = UNC_KT_VBRIDGE;
+ result_code = SetOperStatus
+ <val_vbr_if_st, val_db_vbr_if_st>(tkey, notification, dmi,
+ oper_status_change);
+ if (tkey) {
+ val_drv_vbr_if *vbr_if =
+ reinterpret_cast<val_drv_vbr_if *>(GetVal(tkey));
+ if (vbr_if)
+ vbr_if->vbr_if_val.valid[UPLL_IDX_ADMIN_STATUS_VBRI] =
+ UNC_VF_INVALID;
+ }
+ break;
+ case UNC_KT_VRT_IF:
+ pktype = UNC_KT_VROUTER;
+ result_code = SetOperStatus
+ <val_vrt_if_st, val_db_vrt_if_st>(tkey, notification, dmi,
+ oper_status_change);
+ if (tkey) {
+ val_vrt_if *vrt_if =
+ reinterpret_cast<val_vrt_if *>(GetVal(tkey));
+ if (vrt_if)
+ vrt_if->valid[UPLL_IDX_ADMIN_ST_VI] = UNC_VF_INVALID;
+ }
+ break;
+ case UNC_KT_VTEP_IF:
+ pktype = UNC_KT_VTEP;
+ result_code = SetOperStatus
+ <val_vtep_if_st, val_db_vtep_if_st>(tkey, notification, dmi,
+ oper_status_change);
+ if (tkey) {
+ val_vtep_if *vtep_if =
+ reinterpret_cast<val_vtep_if *>(GetVal(tkey));
+ if (vtep_if)
+ vtep_if->valid[UPLL_IDX_ADMIN_ST_VTEPI] = UNC_VF_INVALID;
+ }
+ break;
+ case UNC_KT_VTUNNEL_IF:
+ pktype = UNC_KT_VTUNNEL;
+ result_code = SetOperStatus
+ <val_vtunnel_if_st, val_db_vtunnel_if_st>(tkey, notification, dmi,
+ oper_status_change);
+ if (tkey) {
+ val_vtunnel_if *vtunnel_if =
+ reinterpret_cast<val_vtunnel_if *>(GetVal(tkey));
+ if (vtunnel_if)
+ vtunnel_if->valid[UPLL_IDX_ADMIN_ST_VTNL_IF] = UNC_VF_INVALID;
+ }
+ break;
+ default:
+ UPLL_LOG_DEBUG("oper status attribute not supported");
return UPLL_RC_SUCCESS;
}
- if (oper_status_change) {
- EnqueOperStatusNotification(tkey);
+ if (oper_status_change != ALARM_NOT_SET) {
+ if (!EnqueOperStatusNotification(tkey, oper_status_change)) {
+ UPLL_LOG_DEBUG("Alarm Notification failed");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ if (notification != kCtrlrDisconnect &&
+ notification != kCtrlrReconnect) {
+ ConfigKeyVal *ck_parent = NULL;
+ result_code = GetParentConfigKey(ck_parent, tkey);
+ if (!ck_parent || result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ VnodeMoMgr *mgr = reinterpret_cast<VnodeMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(ck_parent->get_key_type())));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Invalid mgr");
+ delete ck_parent;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = mgr->UpdateOperStatus(ck_parent, dmi, notification, false, save_to_db);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateOperStatus failed for %d key_type",
+ ck_parent->get_key_type());
+ delete ck_parent;
+ return result_code;
+ }
+ if (save_to_db)
+ delete ck_parent;
}
- ConfigKeyVal *ck_parent = NULL;
- result_code = GetParentConfigKey(ck_parent, tkey);
- if (!ck_parent || result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
- return UPLL_RC_ERR_GENERIC;
+ if (upd_if && upd_remif &&
+ notification != kCtrlrDisconnect &&
+ notification != kCtrlrReconnect &&
+ notification != kCtrlrReconnectIfUp &&
+ notification != kCtrlrReconnectIfDown &&
+ notification != kBoundaryFault &&
+ notification != kBoundaryFaultReset) {
+ uint8_t vlink_flag = 0;
+ uint8_t remote_if = 0;
+ ConfigKeyVal *ck_vlink = NULL;
+ /* interface is a member of a vlink */
+ GET_USER_DATA_FLAGS(ikey, vlink_flag);
+ switch (vlink_flag & VIF_TYPE) {
+ case kVlinkBoundaryNode1:
+ case kVlinkInternalNode1:
+ SET_USER_DATA_FLAGS(ikey, kVlinkVnode1);
+ remote_if = 1;
+ break;
+ case kVlinkBoundaryNode2:
+ case kVlinkInternalNode2:
+ SET_USER_DATA_FLAGS(ikey, kVlinkVnode2);
+ remote_if = 0;
+ break;
+ default:
+ if (skip) {
+ UPLL_LOG_DEBUG("Not member of vlink %s",(ikey->ToStr()).c_str());
+ goto flush_db ;
+ }
+ tkey = tkey->get_next_cfg_key_val();
+ continue;
+ }
+ VlinkMoMgr *mgr = reinterpret_cast<VlinkMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VLINK)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Invalid mgr");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = mgr->GetVlinkKeyVal(ikey, UPLL_DT_STATE, ck_vlink, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ return result_code;
+ }
+ SET_USER_DATA_FLAGS(ikey, vlink_flag);
+ result_code = mgr->SetOperStatus(ck_vlink, dmi, notification, true);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("SetOperStatus failed %d", result_code);
+ return result_code;
+ }
+ /* set the status of the remote interface */
+ ConfigKeyVal *vnif = NULL;
+ result_code = mgr->GetVnodeIfFromVlink(ck_vlink,&vnif,dmi,remote_if);
+ if (result_code != UPLL_RC_SUCCESS &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("get remote interface failed %d", result_code);
+ return result_code;
+ }
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code)
+ return UPLL_RC_SUCCESS;
+
+ VnodeChildMoMgr *rem_mgr = reinterpret_cast<VnodeChildMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(vnif->get_key_type())));
+ if (!rem_mgr) {
+ UPLL_LOG_DEBUG("Invalid mgr");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = rem_mgr->UpdateOperStatus(vnif, dmi, notification, true,
+ true,false);
+ if (vnif) delete vnif;
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error updating rem interface oper status %d",
+ result_code);
+ return result_code;
+ }
+ if (ck_vlink) delete ck_vlink;
}
+ if (skip) break;
+ tkey = tkey->get_next_cfg_key_val();
+ }
+ if (pktype == UNC_KT_ROOT)
+ return UPLL_RC_SUCCESS;
+flush_db:
+ if (!save_to_db) {
+ map<string ,ConfigKeyVal *>::iterator it;
VnodeMoMgr *mgr = reinterpret_cast<VnodeMoMgr *>
- (const_cast<MoManager *>(GetMoManager(ck_parent->get_key_type())));
+ (const_cast<MoManager *>(GetMoManager(pktype)));
if (!mgr) {
- UPLL_LOG_DEBUG("Invalid mgr\n");
- delete ck_parent;
+ UPLL_LOG_DEBUG("Invalid mgr");
return UPLL_RC_ERR_GENERIC;
}
- oper_status_change = mgr->UpdateOperStatus(ck_parent, dmi, notification);
- if (oper_status_change) {
- EnqueOperStatusNotification(tkey);
+ UPLL_LOG_DEBUG("Flushing vnode to db %d",ktype);
+ for (it = mgr->vnode_oper_map.begin(); it != mgr->vnode_oper_map.end(); it++) {
+ DbSubOp dbop = { kOpNotRead, kOpMatchNone, kOpInOutNone };
+ ConfigKeyVal *tckv = it->second;
+ UPLL_LOG_TRACE("%s %p",(it->first).c_str(),it->second);
+ UPLL_LOG_DEBUG("nextvnode %p",tckv);
+ result_code = mgr->UpdateConfigDB(tckv, UPLL_DT_STATE, UNC_OP_UPDATE, dmi,
+ &dbop, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error in update oper status %d", result_code);
+ }
+ if (tckv) delete tckv;
}
- delete ck_parent;
- tkey = tkey->get_next_cfg_key_val();
+ mgr->vnode_oper_map.clear();
}
return result_code;
}
template<typename T1, typename T2>
-bool VnodeChildMoMgr::SetOperStatus(ConfigKeyVal *ikey,
- state_notification notification,
- DalDmlIntf *dmi) {
+upll_rc_t VnodeChildMoMgr::SetOperStatus(ConfigKeyVal *ikey,
+ state_notification ¬ification,
+ DalDmlIntf *dmi, alarm_status &oper_change) {
UPLL_FUNC_TRACE;
- bool result = false;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
/* update corresponding interface operstatus */
ConfigVal *tmp = (ikey->get_cfg_val()) ?
ikey->get_cfg_val()->get_next_cfg_val() : NULL;
T2 *vn_valst = reinterpret_cast<T2 *>((tmp != NULL) ? tmp->get_val() : NULL);
if (vn_valst == NULL) return UPLL_RC_ERR_GENERIC;
T1 *vn_val = reinterpret_cast<T1 *>(vn_valst);
+
+ UPLL_LOG_DEBUG("notification %d down_count %d ",notification, vn_valst->down_count);
/* Update oper status based on notification */
vn_val->valid[0] = UNC_VF_VALID;
switch (notification) {
- case kCtrlrReconnect:
- return false;
+ case kCtrlrReconnect: {
+ uint8_t valid_pm,valid_admin,admin_status;
+ val_port_map_t *pm = NULL;
+ GetPortMap(ikey, valid_pm, pm, valid_admin, admin_status);
+ if_type vnif_type;
+ result_code = GetInterfaceType(ikey, valid_pm, vnif_type);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ return result_code;
+ }
+ UPLL_LOG_DEBUG("vnif_type is %d",vnif_type);
+ if (ikey->get_key_type() == UNC_KT_VBR_IF) {
+ val_vbr_if *vbr_if_val = reinterpret_cast<val_vbr_if*>(GetVal(ikey));
+ if (!vbr_if_val) {
+ UPLL_LOG_DEBUG("val vlink is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ admin_status = vbr_if_val->admin_status;
+ } else if (ikey->get_key_type() == UNC_KT_VRT_IF) {
+ val_vrt_if *vrt_if_val = reinterpret_cast<val_vrt_if*>(GetVal(ikey));
+ if (!vrt_if_val) {
+ UPLL_LOG_DEBUG("val vlink is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ admin_status = vrt_if_val->admin_status;
+ }
+ if (vnif_type == kLinkedInterface) {
+ if (admin_status == UPLL_ADMIN_DISABLE) {
+ vn_val->oper_status = UPLL_OPER_STATUS_DOWN;
+ notification = kCtrlrReconnectIfDown;
+ } else {
+ vn_val->oper_status = UPLL_OPER_STATUS_UP;
+ notification = kCtrlrReconnectIfUp;
+ }
+ VlinkMoMgr *vlink_mgr =
+ reinterpret_cast<VlinkMoMgr *>(const_cast<MoManager *>
+ (const_cast<MoManager*>(GetMoManager(UNC_KT_VLINK))));
+ result_code = vlink_mgr->RestoreVlinkOperStatus(ikey, dmi,
+ notification, false);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("restoring vlink operstatus failed");
+ return result_code;
+ }
+ } else if (vnif_type == kUnboundInterface) {
+ vn_val->oper_status = UPLL_OPER_STATUS_DOWN;
+ notification = kCtrlrReconnectIfDown;
+ } else {
+ return UPLL_RC_SUCCESS;
+ }
+ }
+ break;
+ case kAdminStatusDisabled:
+ vn_val->oper_status = UPLL_OPER_STATUS_DOWN;
+ break;
+ case kAdminStatusEnabled:
+ if (vn_valst->down_count == 0) {
+ if_type vnif_type;
+ uint8_t valid_pm,valid_admin,admin_status;
+ val_port_map_t *pm = NULL;
+ GetPortMap(ikey, valid_pm, pm, valid_admin, admin_status);
+ upll_rc_t result_code = GetInterfaceType(ikey,valid_pm,vnif_type);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d",result_code);
+ return result_code;
+ }
+ if ((vnif_type == kLinkedInterface) || (vnif_type == kMappedInterface) ||
+ (vnif_type == kBoundaryInterface))
+ vn_val->oper_status = UPLL_OPER_STATUS_UP;
+ else if (vnif_type == kUnboundInterface)
+ vn_val->oper_status = UPLL_OPER_STATUS_DOWN;
+ } else
+ vn_val->oper_status = UPLL_OPER_STATUS_DOWN;
+ break;
case kCtrlrDisconnect:
vn_val->oper_status = UPLL_OPER_STATUS_UNKNOWN;
+ vn_valst->down_count = 0;
break;
case kPortFault:
case kPathFault:
case kBoundaryFault:
- vn_valst->down_count = (vn_valst->down_count + 1);
+ if (vn_valst->down_count < 1)
+ vn_valst->down_count = (vn_valst->down_count + 1);
if (vn_valst->down_count == 1) {
vn_val->oper_status = UPLL_OPER_STATUS_DOWN;
// generate alarm
- result = true;
+ oper_change = ALARM_OPER_DOWN;
}
break;
case kPortFaultReset:
case kPathFaultReset:
case kBoundaryFaultReset:
- vn_valst->down_count = (vn_valst->down_count > 0) ?
- (vn_valst->down_count - 1) : 0;
- if (vn_valst->down_count == 0) {
- vn_val->oper_status = UPLL_OPER_STATUS_UP;
- // reset alarm
- result = true;
+ if (vn_valst->down_count > 0) {
+ --vn_valst->down_count;
}
+ if (vn_valst->down_count == 0) {
+ uint8_t valid_pm,valid_admin,admin_status;
+ val_port_map_t *pm = NULL;
+ GetPortMap(ikey, valid_pm, pm, valid_admin, admin_status);
+ if (admin_status == UPLL_ADMIN_ENABLE) {
+ vn_val->oper_status = UPLL_OPER_STATUS_UP;
+ // reset alarm
+ oper_change = ALARM_OPER_UP;
+ } else
+ vn_val->oper_status = UPLL_OPER_STATUS_UP;
+ } else
+ vn_val->oper_status = UPLL_OPER_STATUS_DOWN;
break;
+ default:
+ UPLL_LOG_DEBUG("unsupported notification for operstatus update");
+ return UPLL_RC_ERR_GENERIC;
+ break;
}
DbSubOp dbop = { kOpNotRead, kOpMatchNone, kOpInOutNone };
- upll_rc_t result_code = UpdateConfigDB(ikey, UPLL_DT_STATE, UNC_OP_UPDATE,
+ result_code = UpdateConfigDB(ikey, UPLL_DT_STATE, UNC_OP_UPDATE,
dmi, &dbop, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
- }
- return result;
+ UPLL_LOG_TRACE("VnodeChild SetOperstatus for VTN after Update is \n %s",
+ ikey->ToStrAll().c_str());
+ return result_code;
}
-#if 0
-template<typename T1,typename T2>
-upll_rc_t VnodeChildMoMgr::GetUninitOperState(ConfigKeyVal *&ck_vn,
- DalDmlIntf *dmi) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- ConfigVal *cval = NULL;
- /* Allocate Memory for vnode st */
- result_code = AllocVal(cval,UPLL_DT_STATE,MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d",result_code);
- return result_code;
- }
- /* initialize vnode st */
- T2 *vnif_st = reinterpret_cast<T2 *>
- (cval->get_next_cfg_val()->get_val());
- if (!vnif_st) {
- delete cval;
- UPLL_LOG_DEBUG("Invalid param");
- return UPLL_RC_ERR_GENERIC;
- }
- T1 *vnif = reinterpret_cast<T1 *>(vnif_st);
- vnif->valid[UPLL_IDX_OPER_STATUS_VBRIS] = UNC_VF_VALID;
- // vnif->oper_status = UPLL_OPER_STATUS_UNINIT;
- /* Create Vnode If child */
- result_code = GetChildConfigKey (ck_vn, NULL);
- if (UPLL_RC_SUCCESS != result_code) {
- free(vnif_st);
- UPLL_LOG_DEBUG("GetChildConfigKey Failed %d", result_code);
- return result_code;
- }
- ck_vn->AppendCfgVal(cval);
- /* Reading the Vnode Table and Check the Operstatus is unknown
- * for any one of the vnode if */
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutFlag |
- kOpInOutCtrlr | kOpInOutDomain };
- result_code = ReadConfigDB(ck_vn, UPLL_DT_STATE, UNC_OP_READ,
- dbop,dmi,MAINTBL);
- if (UPLL_RC_SUCCESS != result_code) {
- result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
- UPLL_RC_SUCCESS : result_code;
- UPLL_LOG_DEBUG("Returning %d",result_code);
- if (ck_vn) delete ck_vn;
- }
- return result_code;
-}
-#endif
-
upll_rc_t VnodeChildMoMgr::TxUpdateDtState(unc_key_type_t ktype,
uint32_t session_id,
uint32_t config_id,
UPLL_FUNC_TRACE;
ConfigKeyVal *ck_vn = NULL;
upll_rc_t result_code = UPLL_RC_SUCCESS;
+#if 0
switch (ktype) {
case UNC_KT_VRT_IF:
+ result_code = GetUninitOperState<val_vrt_if_st_t, val_db_vrt_if_st_t>
+ (ck_vn, dmi);
+ break;
case UNC_KT_VUNK_IF:
- UPLL_LOG_DEBUG("Returning success\n");
+ UPLL_LOG_DEBUG("Returning success");
return UPLL_RC_SUCCESS;
case UNC_KT_VBR_IF:
result_code = GetUninitOperState<val_vbr_if_st_t, val_db_vbr_if_st_t>
(ck_vn, dmi);
break;
case UNC_KT_VTUNNEL_IF:
- result_code = GetUninitOperState<val_vtunnel_if_st_t, val_db_vtunnel_if_st_t>
- (ck_vn, dmi);
+ result_code = GetUninitOperState<val_vtunnel_if_st_t,
+ val_db_vtunnel_if_st_t>(ck_vn, dmi);
break;
default:
- UPLL_LOG_DEBUG("Oper status not supported\n");
+ UPLL_LOG_DEBUG("Oper status not supported");
return UPLL_RC_ERR_GENERIC;
}
+#endif
+ result_code = GetUninitOperState(ck_vn, dmi);
if (!ck_vn || result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("UpdateDtState failed %d\n",result_code);
+ UPLL_LOG_DEBUG("UpdateDtState failed %d", result_code);
return result_code;
}
/* Read port status from physical */
- ConfigKeyVal *tkey = ck_vn;
+ ConfigKeyVal *tkey;
controller_domain_t ctrlr_dom;
- while (tkey) {
- uint8_t valid_pm;
- val_port_map_t *pm=NULL;
- GetPortMap(tkey,valid_pm,pm);
- UPLL_LOG_DEBUG("valid_pm %d\n",valid_pm);
- if (valid_pm == UNC_VF_VALID) {
- val_oper_status port_oper_status;
- GET_USER_DATA_CTRLR_DOMAIN(tkey,ctrlr_dom);
- result_code = GetPortStatusFromPhysical(pm, ctrlr_dom,port_oper_status,
- session_id,config_id);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Error retrieving port status from physical %d\n",
- result_code);
- return result_code;
- }
- result_code = UpdateOperStatus(tkey, dmi, kPortFault, true);
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ while (ck_vn) {
+ tkey = ck_vn;
+ ck_vn = ck_vn->get_next_cfg_key_val();
+ tkey->set_next_cfg_key_val(NULL);
+ state_notification notification = kCtrlrReconnect; //noop
+ uint8_t valid_pm,valid_admin,admin_status;
+ val_port_map_t *pm = NULL;
+ result_code = GetPortMap(tkey, valid_pm, pm,valid_admin,admin_status);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ return result_code;
+ }
+ UPLL_LOG_DEBUG("valid_pm %d valid_admin %d admin_status %d",
+ valid_pm, valid_admin,admin_status);
+ if (valid_admin == UNC_VF_VALID &&
+ admin_status == UPLL_ADMIN_DISABLE)
+ notification = kAdminStatusDisabled;
+ else if (valid_pm == UNC_VF_VALID) {
+ val_oper_status port_oper_status;
+ GET_USER_DATA_CTRLR_DOMAIN(tkey, ctrlr_dom);
+ result_code = GetPortStatusFromPhysical(pm, ctrlr_dom, port_oper_status,
+ session_id, config_id);
+ /* During import Physical don't have the Port status
+ * in the running db so its return no such instance
+ * so here comment this check */
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error retrieving port status from physical %d %d",
+ result_code, port_oper_status);
+ // return result_code;
+ }
+ val_db_vbr_if_st *vbrif_valst = reinterpret_cast<val_db_vbr_if_st *>
+ (GetStateVal(tkey));
+ switch (port_oper_status) {
+ case UPLL_OPER_STATUS_DOWN:
+ if (vbrif_valst->down_count == 0)
+ notification = kPortFault;
+ else
+ notification = kAdminStatusEnabled;
+ break;
+ case UPLL_OPER_STATUS_UNKNOWN:
+ notification = kCtrlrDisconnect;
+ break;
+ case UPLL_OPER_STATUS_UP:
+ {
+ if (vbrif_valst->down_count > 0)
+ notification = kPortFaultReset;
+ else
+ notification = kAdminStatusEnabled;
+ break;
+ }
+ default:
+ if (vbrif_valst->down_count == 0)
+ notification = kPortFault;
+ else
+ notification = kAdminStatusEnabled;
+ break;
+ }
+ }
+ if (notification == kAdminStatusEnabled || admin_status == UPLL_ADMIN_ENABLE) {
+ if_type vnif_type;
+ result_code = GetInterfaceType(tkey,valid_pm,vnif_type);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Error updating oper status %d\n",result_code);
+ UPLL_LOG_DEBUG("Returning error %d",result_code);
return result_code;
}
+ if (vnif_type == kBoundaryInterface) {
+ ConfigKeyVal *ck_remif = NULL;
+ VlinkMoMgr *vlink_mgr = reinterpret_cast<VlinkMoMgr *>
+ (const_cast<MoManager*>(GetMoManager(UNC_KT_VLINK)));
+ if (!vlink_mgr) {
+ UPLL_LOG_ERROR("Invalid mgr\n");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = vlink_mgr->GetRemoteIf(tkey,ck_remif, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_ERROR("Returning error %d\n",result_code);
+ DELETE_IF_NOT_NULL(ck_remif);
+ return result_code;
+ }
+ result_code = GetPortMap(ck_remif, valid_pm, pm,
+ valid_admin,admin_status);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ DELETE_IF_NOT_NULL(ck_remif);
+ return result_code;
+ }
+ if (valid_admin == UNC_VF_VALID &&
+ admin_status == UPLL_ADMIN_DISABLE)
+ notification = kAdminStatusDisabled;
+ else
+ notification = kAdminStatusEnabled;
+ DELETE_IF_NOT_NULL(ck_remif);
+ } else if (vnif_type == kLinkedInterface) {
+ notification = kAdminStatusEnabled;
+ } else if (vnif_type == kUnboundInterface) {
+ notification = kAdminStatusDisabled;
+ }
+ }
+ // vlinked interfaces should be handled as part of vlink dt state update
+ result_code = UpdateOperStatus(tkey, dmi, notification, true, true, true);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error updating oper status %d", result_code);
+ return result_code;
+ }
#if 0
DbSubOp dbop1 = { kOpNotRead, kOpMatchNone, kOpInOutNone };
- result_code = UpdateConfigDB(tkey, UPLL_DT_STATE, UNC_OP_UPDATE,
+ result_code = UpdateConfigDB(tkey, UPLL_DT_STATE, UNC_OP_UPDATE,
dmi, &dbop1, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("UpdateConfigDB Executed %d", result_code);
break;
}
#endif
- }
- tkey= tkey->get_next_cfg_key_val();
+ delete tkey;
}
- if (ck_vn)
- delete ck_vn;
return result_code;
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
key_logical_port *phy_logPort_Key = static_cast<key_logical_port *>
- (malloc(sizeof(key_logical_port)));
- memset(phy_logPort_Key, 0, sizeof(key_logical_port));
+ (ConfigKeyVal::Malloc(sizeof(key_logical_port)));
uuu::upll_strncpy(phy_logPort_Key->domain_key.ctr_key.controller_name,
reinterpret_cast<const char *>(ctr_domain.ctrlr),
(kMaxLenCtrlrId+1));
phy_logPort_Key, NULL);
result_code = SendIpcReq(session_id, config_id, UNC_OP_READ,
UPLL_DT_STATE, log_Port_CK, NULL, &ipc_resp);
- if ((result_code != UPLL_RC_SUCCESS) || (! ipc_resp.ckv_data)) {
+ if ((result_code != UPLL_RC_SUCCESS) || (!ipc_resp.ckv_data)) {
delete log_Port_CK;
log_Port_CK = NULL;
- logical_port_operStatus = UPLL_OPER_STATUS_UNKNOWN;
+ logical_port_operStatus = UPLL_OPER_STATUS_DOWN;
if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- UPLL_LOG_DEBUG("Invalid Logical Port Id\n");
- return UPLL_RC_ERR_CFG_SEMANTIC;
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ UPLL_LOG_DEBUG("Invalid Logical Port Id");
+// return UPLL_RC_ERR_CFG_SEMANTIC;
+ return UPLL_RC_SUCCESS;
}
- UPLL_LOG_DEBUG("Error in retrieving LogicalPortId data from Physical\n");
+ UPLL_LOG_DEBUG("Error in retrieving LogicalPortId data from Physical");
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
return UPLL_RC_ERR_GENERIC;
}
log_Port_CK->ResetWith(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
val_logical_port_st *phy_logPort_St = static_cast<val_logical_port_st *>
(GetVal(log_Port_CK));
if (phy_logPort_St)
default:
break;
}
+ if (log_Port_CK)
+ delete log_Port_CK;
+ return result_code;
+}
+
+bool VnodeChildMoMgr::EnqueOperStatusNotification(ConfigKeyVal *ikey,
+ bool oper_status_change) {
+ UPLL_FUNC_TRACE;
+ if (!ikey || !ikey->get_key()) {
+ UPLL_LOG_DEBUG("Inputs are Invalid");
+ return false;
+ }
+ uuc::UpllConfigMgr *cfg_instance = uuc::UpllConfigMgr::GetUpllConfigMgr();
+ unc_key_type_t ktype = ikey->get_key_type();
+ uint8_t *vtn_name = NULL;
+ uint8_t *vnode_name = NULL;
+ uint8_t *vif_name = NULL;
+
+ switch (ktype) {
+ case UNC_KT_VBR_IF:
+ vtn_name = reinterpret_cast<key_vbr_if*>
+ (ikey->get_key())->vbr_key.vtn_key.vtn_name;
+ vnode_name = reinterpret_cast<key_vbr_if*>
+ (ikey->get_key())->vbr_key.vbridge_name;
+ vif_name = (reinterpret_cast<key_vbr_if*>(ikey->get_key()))->if_name;
+ break;
+ case UNC_KT_VRT_IF:
+ vtn_name = reinterpret_cast<key_vrt_if*>
+ (ikey->get_key())->vrt_key.vtn_key.vtn_name;
+ vnode_name = reinterpret_cast<key_vrt_if*>
+ (ikey->get_key())->vrt_key.vrouter_name;
+ vif_name = (reinterpret_cast<key_vrt_if*>(ikey->get_key()))->if_name;
+ break;
+ case UNC_KT_VTUNNEL_IF:
+ vtn_name = reinterpret_cast<key_vtunnel_if*>
+ (ikey->get_key())->vtunnel_key.vtn_key.vtn_name;
+ vnode_name = reinterpret_cast<key_vtunnel_if*>
+ (ikey->get_key())->vtunnel_key.vtunnel_name;
+ vif_name = reinterpret_cast<key_vtunnel_if*>(ikey->get_key())->if_name;
+ break;
+ case UNC_KT_VTEP_IF:
+ vtn_name = reinterpret_cast<key_vtep_if*>
+ (ikey->get_key())->vtep_key.vtn_key.vtn_name;
+ vnode_name = reinterpret_cast<key_vtep_if*>
+ (ikey->get_key())->vtep_key.vtep_name;
+ vif_name = (reinterpret_cast<key_vtep_if*>(ikey->get_key()))->if_name;
+ break;
+ default:
+ UPLL_LOG_DEBUG("Invalid KeyType");
+ }
+ return cfg_instance->SendOperStatusAlarm(reinterpret_cast<char*>(vtn_name),
+ reinterpret_cast<char*>(vnode_name),
+ reinterpret_cast<char*>(vif_name),
+ oper_status_change);
+}
+
+upll_rc_t VnodeChildMoMgr::SetLinkedIfOperStatusforPathFault(
+ const key_vnode_type_t &vnode_key,
+ state_notification notification,
+ DalDmlIntf *dmi) {
+ ConfigKeyVal *ck_vnode_if = NULL;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ result_code = GetMappedInterfaces(vnode_key, dmi, ck_vnode_if);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Operstatus updation failed");
+ return result_code;
+ }
+ ConfigKeyVal *tmp_vnode_if = ck_vnode_if;
+ while (tmp_vnode_if != NULL) {
+ result_code = UpdateOperStatus(tmp_vnode_if, dmi, notification, true, false, false);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Operstatus updation failed");
+ return result_code;
+ }
+ tmp_vnode_if = tmp_vnode_if->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(ck_vnode_if);
+ return result_code;
+}
+
+/*This function gives the interfaces mapped to a particular vbridge */
+upll_rc_t VnodeChildMoMgr::GetMappedInterfaces(const key_vnode_type_t &vnode_key_type,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *&iokey) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ GetChildConfigKey(iokey, NULL);
+ key_vnode *vnode_key = reinterpret_cast<key_vnode*>(iokey->get_key());
+ memcpy(vnode_key, &(vnode_key_type.vnode_key), sizeof(key_vnode));
+
+ /* Get all the vbridges under the VTN */
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
+ result_code = ReadConfigDB(iokey, UPLL_DT_STATE, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ return result_code;
+}
+
+upll_rc_t VnodeChildMoMgr::UpdateVnodeIf(ConfigKeyVal *ck_if,
+ DalDmlIntf *dmi,
+ state_notification notification) {
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone,
+ kOpInOutFlag};
+ result_code = ReadConfigDB(ck_if, UPLL_DT_STATE, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed with result_code %d",
+ result_code);
+ return result_code;
+ }
+ ConfigKeyVal *tmp = ck_if;
+ while (tmp != NULL) {
+ result_code = UpdateOperStatus(tmp, dmi, notification, true, true,
+ true, true);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error updating oper status %d", result_code);
+ return result_code;
+ }
+ tmp = tmp->get_next_cfg_key_val();
+ }
return result_code;
}
UNC_RENAME_KEY, CTRLR_RENAME_KEY
};
+enum alarm_status {
+ ALARM_OPER_UP = 0,
+ ALARM_OPER_DOWN,
+ ALARM_NOT_SET
+};
+
namespace unc {
namespace upll {
namespace kt_momgr {
ConfigKeyVal *parent_ck_vnode;
uint32_t cur_instance_count;
+ /**
+ * @brief Update parent oper status on delete for Transaction commit
+ *
+ * @param[in] ikey ConfigKeyVal instance
+ * @param[in] dmi Database connection parameter
+
+ * @retval UPLL_RC_SUCCESS Completed successfully.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ */
+ virtual upll_rc_t UpdateParentOperStatus(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi);
+
/* @brief Returns portmap information if portmap is valid
* Else returns NULL for portmap
*
*
**/
virtual upll_rc_t GetPortMap(ConfigKeyVal *ikey, uint8_t &valid_pm,
- val_port_map_t *&pm) {
+ val_port_map_t *&pm, uint8_t &valid_admin,
+ uint8_t &admin_status) {
return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
}
return UPLL_RC_ERR_NO_SUCH_OPERATION;
}
template<typename T1, typename T2>
- bool SetOperStatus(ConfigKeyVal *ikey,
- state_notification notification,
- DalDmlIntf *dmi);
+ upll_rc_t SetOperStatus(ConfigKeyVal *ikey,
+ state_notification ¬ification,
+ DalDmlIntf *dmi, alarm_status &oper_change = ALARM_NOT_SET);
- upll_rc_t UpdateOperStatus(ConfigKeyVal *ikey,
- DalDmlIntf *dmi,
- state_notification notification,
- bool skip);
+ /**
+ * @brief Enqueues oper status notifications
+ *
+ * @param[in] ikey pointer to the configkeyval with
+ * the changed oper status
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ bool EnqueOperStatusNotification(ConfigKeyVal *ikey, bool oper_change);
/* @brief Retrieve oper status of logical portid from physical
*
InterfacePortMapInfo flag) {
return UPLL_RC_ERR_GENERIC;
}
+ upll_rc_t UpdateOperStatus(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ state_notification notification,
+ bool skip, bool upd_if, bool upd_remif,
+ bool save_to_db = false);
+ virtual upll_rc_t GetMappedInterfaces(const key_vnode_type_t &vnode_key,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *&iokey);
+ virtual upll_rc_t SetLinkedIfOperStatusforPathFault(
+ const key_vnode_type_t &vnode_key,
+ state_notification notification,
+ DalDmlIntf *dmi);
+ virtual upll_rc_t UpdateVnodeIf(ConfigKeyVal *ck_if,
+ DalDmlIntf *dmi,
+ state_notification notification);
};
} // namespace kt_momgr
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
controller_domain ctrlr_dom;
+ ConfigKeyVal *temp_key = NULL;
result_code = ValidateMessage(req, ikey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ValidateMessage Failed : %d", result_code);
return result_code;
}
- // check for key support on controller and max count
- GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
- if (UPLL_DT_CANDIDATE == req->datatype) {
- result_code = GetInstanceCount(ikey,
- reinterpret_cast<char *>(ctrlr_dom.ctrlr),
- req->datatype, &cur_instance_count, dmi,
- MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("GetInstanceCount error %d", result_code);
- return UPLL_RC_ERR_GENERIC;
- }
- }
-#if 1
- result_code = ValidateCapability(req, ikey);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ValidateCapability Failed. Error_code : %d", result_code);
- return result_code;
- }
-#endif
- UPLL_LOG_DEBUG("ikey keytype %d", ikey->get_key_type());
- // Vnode Existence check in CANDIDATE DB
- result_code = VnodeChecks(ikey, req->datatype, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(
- "Another Vnode with the same name already exists. Error code : %d",
- result_code);
- return result_code;
- }
-
// Parent VTN check
result_code = GetParentConfigKey(parent_ck_vtn, ikey);
if (result_code == UPLL_RC_ERR_GENERIC) {
(const_cast<MoManager*>(GetMoManager(UNC_KT_VTN))));
if (!mgr) {
UPLL_LOG_DEBUG("Invalid Mgr");
+ DELETE_IF_NOT_NULL(parent_ck_vtn);
return UPLL_RC_ERR_GENERIC;
}
result_code = mgr->UpdateConfigDB(parent_ck_vtn, req->datatype, UNC_OP_READ,
if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
UPLL_LOG_DEBUG("VTN doesn't exist in CANDIDATE DB. Error code : %d",
result_code);
+ DELETE_IF_NOT_NULL(parent_ck_vtn);
return UPLL_RC_ERR_PARENT_DOES_NOT_EXIST;
}
- result_code = RestoreVnode(ikey, req, dmi, &ctrlr_dom);
+ DELETE_IF_NOT_NULL(parent_ck_vtn);
+ UPLL_LOG_DEBUG("ikey keytype %d", ikey->get_key_type());
+ // Vnode Existence check in CANDIDATE DB
+ result_code = VnodeChecks(ikey, req->datatype, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG(
+ "Another Vnode with the same name already exists. Error code : %d",
+ result_code);
+ return result_code;
+ }
+
+ // check for key support on controller and max count
+ result_code = GetControllerDomainId(ikey, &ctrlr_dom);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetControllerDomainId Failed");
+ return result_code;
+ }
+ result_code = GetChildConfigKey(temp_key, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed");
+ return result_code;
+ }
+
+ result_code = GetInstanceCount(temp_key,
+ reinterpret_cast<char *>(ctrlr_dom.ctrlr),
+ req->datatype, &cur_instance_count, dmi,
+ MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("GetInstanceCount error %d", result_code);
+ if (temp_key)
+ delete temp_key;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (temp_key)
+ delete temp_key;
+
+ result_code = ValidateCapability(req, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ValidateCapability Failed. Error_code : %d", result_code);
+ return result_code;
+ }
+
+ result_code = RestoreVnode(ikey, req, dmi, &ctrlr_dom);
return result_code;
}
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
controller_domain ctrlr_dom;
+ uint8_t *controller_id = reinterpret_cast<uint8_t *>(
+ const_cast<char *>(ctrlr_id));
+
+ /* check if object is renamed in the corresponding Rename Tbl
+ * if "renamed" create the object by the UNC name.
+ * else - create using the controller name.
+ */
+ result_code = GetRenamedUncKey(ikey, UPLL_DT_RUNNING, dmi, controller_id);
+ if (result_code != UPLL_RC_SUCCESS && result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey Failed err_code %d", result_code);
+ return result_code;
+ }
+
result_code = GetControllerDomainId(ikey, &ctrlr_dom);
if ((result_code != UPLL_RC_SUCCESS) || (ctrlr_dom.ctrlr == NULL)
|| (ctrlr_dom.domain == NULL)) {
SET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
result_code = UpdateConfigDB(ikey, UPLL_DT_AUDIT, UNC_OP_CREATE,
dmi, &dbop, MAINTBL);
- #if 1
- controller_domain_t print_ctrlr_dom;
- print_ctrlr_dom.ctrlr = NULL;
- print_ctrlr_dom.domain = NULL;
- GET_USER_DATA_CTRLR_DOMAIN(ikey,print_ctrlr_dom);
- if (print_ctrlr_dom.ctrlr != NULL ) {
- UPLL_LOG_DEBUG("print_ctrlr_dom.ctrlr is %s", print_ctrlr_dom.ctrlr);
- }
- if (print_ctrlr_dom.domain != NULL ) {
- UPLL_LOG_DEBUG("print_ctrlr_dom.domain is %s\n",print_ctrlr_dom.domain);
- }
- #endif
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Record Creation failed in CANDIDATE DB");
return result_code;
IpcReqRespHeader req;
memset(&req, 0, sizeof(IpcReqRespHeader));
req.datatype = UPLL_DT_AUDIT;
+ result_code = SetValidAudit(ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ return result_code;
+ }
result_code = CheckVtnExistenceOnController(ikey, &req, &ctrlr_dom, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("VTN doesn't exist on controller");
+ return result_code;
}
return result_code;
}
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
controller_domain ctrlr_dom;
+ ctrlr_dom.ctrlr = ctrlr_dom.domain = NULL;
result_code = GetControllerDomainId(ikey, &ctrlr_dom);
if ((result_code != UPLL_RC_SUCCESS) || (ctrlr_dom.ctrlr == NULL)
|| (ctrlr_dom.domain == NULL)) {
IpcReqRespHeader *req) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
+ controller_domain ctrlr_dom;
+ ctrlr_dom.ctrlr = ctrlr_dom.domain = NULL;
if (req->operation == UNC_OP_UPDATE) {
ConfigKeyVal *okey = NULL;
result_code = GetChildConfigKey(okey, ikey);
- DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutCtrlr | kOpInOutDomain | kOpInOutFlag};
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutCtrlr | kOpInOutDomain | kOpInOutFlag};
result_code = ReadConfigDB(okey, req->datatype, UNC_OP_READ, dbop, dmi, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_ERROR("Record does Not Exists");
+ delete okey;
+ return result_code;
+ }
+ GET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
+ result_code = CtrlrIdAndDomainIdUpdationCheck(ikey, okey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_ERROR("Controller_id/domain_id updation check failed");
+ delete okey;
return result_code;
}
result_code = CtrlrTypeAndDomainCheck(okey, req);
+ delete okey;
} else {
result_code = CtrlrTypeAndDomainCheck(ikey, req);
}
UPLL_LOG_ERROR("Controller type and domain check failed");
return result_code;
}
- //*other semantic validations*//
- result_code = IsHostAddrAndPrefixLenInUse(ikey, dmi, req);
- if (result_code != UPLL_RC_ERR_CFG_SEMANTIC) {
- return UPLL_RC_SUCCESS;
+ //* other semantic validations *//
+ if (ikey->get_key_type() == UNC_KT_VBRIDGE) {
+ result_code = IsHostAddrAndPrefixLenInUse(ikey, dmi, req);
}
+ //Commented for #403
+ /*if (ikey->get_key_type() == UNC_KT_VROUTER) {
+ result_code = EnableAdminStatus(ikey, dmi, req);
+ if (result_code != UPLL_RC_ERR_CFG_SEMANTIC) {
+ return UPLL_RC_SUCCESS;
+ }
+ }*/
return result_code;
}
UPLL_LOG_DEBUG("Restoring children failed. Error code : %d", result_code);
return UPLL_RC_ERR_GENERIC;
}
+ if (key_type == UNC_KT_VBRIDGE || key_type == UNC_KT_VROUTER ||
+ key_type == UNC_KT_VTEP || key_type == UNC_KT_VTUNNEL
+ || key_type == UNC_KT_VTEP_GRP) {
+ /* check if controller is aware of parent VTN
+ ** and create an entry in VtnCtrlrTbl on failure
+ */
+ result_code = CheckVtnExistenceOnController(ikey, req, ctrlr_dom, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("VTN doesn't exist on controller");
+ return result_code;
+ }
+ }
return result_code;
- }
+ }
}
if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE ||
UPLL_DT_IMPORT == req->datatype) {
dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_ERROR("VTN doesn't exist on controller");
+ return result_code;
}
return result_code;
}
}
}
}
- /* If parent VTN is renamed, set the renamed flag in Vnode
- ** and create an entry in vnode rename table if VTN is renamed
- */
- result_code = SetVnodeRenameFlag(ikey, req->datatype, ctrlr_dom, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- return result_code;
- }
}
-#if 0
/* set the controller domain in the ikey */
- SET_USER_DATA_CTRLR_DOMAIN(ikey, *ctrlr_dom);
+ // SET_USER_DATA_CTRLR_DOMAIN(ikey, *ctrlr_dom);
+
+#if 0
if (ikey->get_key_type() == UNC_KT_VLINK) {
if (!ikey->get_cfg_val()) return UPLL_RC_ERR_GENERIC;
SET_USER_DATA_CTRLR_DOMAIN(ikey->get_cfg_val(), ctrlr_dom[1]);
result_code = CheckVtnExistenceOnController(ikey, req, ctrlr_dom, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("VTN doesn't exist on controller");
+ return result_code;
}
}
+ // TODO (karthi) moved here, because after creating the vnode
+ // we need to set the rename flag.
+
+ /* If parent VTN is renamed, set the renamed flag in Vnode
+ ** and create an entry in vnode rename table if VTN is renamed
+ */
+ if (UPLL_DT_IMPORT != req->datatype) {
+ result_code = SetVnodeRenameFlag(ikey, req->datatype, ctrlr_dom, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ return result_code;
+ }
+ }
+
return result_code;
}
return UPLL_RC_ERR_GENERIC;
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
-
+ uint8_t *temp_vtn_name = NULL;
+ uint8_t *temp_vnode_name = NULL;
+ ConfigKeyVal *ck_rename_vnode = NULL;
/*Check if parent vtn renamed and get the renamed name */
MoMgrImpl *mgr =
reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>
UPLL_LOG_DEBUG("Invalid Mgr");
return UPLL_RC_ERR_GENERIC;
}
+ result_code = GetParentConfigKey(parent_ck_vtn, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetParentConfigKey Failed");
+ return result_code;
+ }
+ // SET_USER_DATA_CTRLR_DOMAIN(parent_ck_vtn, *ctrlr_dom);
+ UPLL_LOG_DEBUG("ctrlr dom %p %p %p\n", ctrlr_dom->ctrlr, ctrlr_dom->domain,
+ ikey->get_user_data());
+ UPLL_LOG_DEBUG("%p %p %p %p \n", parent_ck_vtn, ikey, ikey->get_user_data(),
+ parent_ck_vtn->get_user_data());
result_code = mgr->GetRenamedControllerKey(parent_ck_vtn, dt_type, dmi,
ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(parent_ck_vtn);
+ UPLL_LOG_DEBUG("GetRenamedControllerKey failed. Result : %d",
+ result_code);
return result_code;
}
int rename = 0;
GET_USER_DATA_FLAGS(parent_ck_vtn, rename);
- if (!(rename & RENAME)) return UPLL_RC_SUCCESS;
- // create entry in Vnode Rename Table-parent_ck_vtn contains the renamed name
- result_code = CreateVnodeRenameEntry(ikey, dt_type, ctrlr_dom, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Update Config result %d", result_code);
- return result_code;
- }
- return result_code;
-}
-
-upll_rc_t VnodeMoMgr::CreateVnodeRenameEntry(ConfigKeyVal *ikey,
- upll_keytype_datatype_t dt_type,
- controller_domain *ctrlr_dom,
- DalDmlIntf *dmi) {
- UPLL_FUNC_TRACE;
- if (ikey == NULL || dmi == NULL || ctrlr_dom == NULL) {
- UPLL_LOG_DEBUG("Create error due to insufficient parameters");
- return UPLL_RC_ERR_GENERIC;
+ if (!(rename & RENAME)) {
+ DELETE_IF_NOT_NULL(parent_ck_vtn);
+ return UPLL_RC_SUCCESS;
}
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- uint8_t *temp_vtn_name = NULL;
- ConfigVal *cv_rename_vnode = NULL; // comment due to configval
- ConfigKeyVal *ck_rename_vnode = NULL;
-
- uint8_t *temp_vnode_name = NULL;
+ // create entry in Vnode Rename Table-parent_ck_vtn contains the renamed name
+ // TODO (karthi) Here removed CreateVnodeRenameEntry and combined
GetVnodeName(ikey, temp_vtn_name, temp_vnode_name);
if (temp_vtn_name == NULL || temp_vnode_name == NULL)
return UPLL_RC_ERR_GENERIC;
-
- // create entry in Vnode Rename Table
- unc_key_type_t key_type = ikey->get_key_type();
key_vnode* key_rename_vnode = reinterpret_cast<key_vnode*>
(ConfigKeyVal::Malloc(sizeof(key_vnode)));
uuu::upll_strncpy(key_rename_vnode->vtn_key.vtn_name,
uuu::upll_strncpy(key_rename_vnode->vnode_name,
temp_vnode_name, (kMaxLenVnodeName+1));
- uint8_t *new_vtn_name =
- reinterpret_cast<key_vtn *>(parent_ck_vtn->get_key())->vtn_name;
val_rename_vnode_t* val_rename_vnode = reinterpret_cast<val_rename_vnode_t*>
(ConfigKeyVal::Malloc(sizeof(val_rename_vnode_t)));
uuu::upll_strncpy(val_rename_vnode->ctrlr_vtn_name,
- new_vtn_name, (kMaxLenVtnName+1));
- cv_rename_vnode = new ConfigVal(IpctSt::kIpcInvalidStNum, val_rename_vnode);
- ck_rename_vnode = new ConfigKeyVal(key_type, IpctSt::kIpcInvalidStNum,
- key_rename_vnode, cv_rename_vnode);
+ reinterpret_cast<key_vtn_t*>(parent_ck_vtn->get_key())->vtn_name,
+ (kMaxLenVtnName+1));
+ uuu::upll_strncpy(val_rename_vnode->ctrlr_vnode_name,
+ temp_vnode_name, (kMaxLenVnodeName+1));
+
+ ck_rename_vnode = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcInvalidStNum,
+ key_rename_vnode,
+ new ConfigVal(IpctSt::kIpcInvalidStNum, val_rename_vnode));
+
+ val_rename_vnode->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
+ val_rename_vnode->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_VALID;
+
SET_USER_DATA_CTRLR_DOMAIN(ck_rename_vnode, *ctrlr_dom);
- result_code = UpdateConfigDB(ck_rename_vnode, dt_type, UNC_OP_CREATE, dmi,
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain};
+ /* Create the Entry in Vnode rename table for vbr and vrt
+ * Vlink rename table for vlink key type */
+
+ result_code = UpdateConfigDB(ck_rename_vnode, dt_type, UNC_OP_CREATE, dmi, &dbop,
RENAMETBL);
// SET_USER_DATA_CTRLR(ck_rename_vnode, ctrlr_id);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Record Creation failed in %d", result_code);
+ DELETE_IF_NOT_NULL(parent_ck_vtn);
delete ck_rename_vnode;
return result_code;
}
- delete ck_rename_vnode;
+ /* Update the Rename Flag for vnode in the main table */
+ DELETE_IF_NOT_NULL (ck_rename_vnode);
+ rename = 0;
+ GET_USER_DATA_FLAGS(ikey, rename);
+ rename |= VTN_RENAME;
+ SET_USER_DATA_FLAGS(ikey, rename);
+ dbop.matchop = kOpMatchNone;
+ dbop.inoutop = kOpInOutFlag;
+ result_code = UpdateConfigDB(ikey, dt_type, UNC_OP_UPDATE, dmi, &dbop,
+ MAINTBL);
+ DELETE_IF_NOT_NULL(parent_ck_vtn);
return result_code;
}
return UPLL_RC_ERR_GENERIC;
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
+ upll_keytype_datatype_t dt_type = UPLL_DT_CANDIDATE;;
ConfigKeyVal *ck_vtn_cntrlr = NULL;
+ ConfigKeyVal *ck_domain_vtn = NULL;
+ ConfigKeyVal *ck_vtn = NULL;
+ val_vtn_ctrlr *ctrlr_val = NULL;
+
unc_keytype_operation_t op = UNC_OP_UPDATE;
result_code = GetParentConfigKey(ck_vtn_cntrlr, ikey);
if (result_code != UPLL_RC_SUCCESS) return result_code;
+
+ result_code = GetParentConfigKey(ck_domain_vtn, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(ck_vtn_cntrlr);
+ return result_code;
+ }
+
/* set the controller -id */
SET_USER_DATA_CTRLR_DOMAIN(ck_vtn_cntrlr, *ctrlr_dom);
MoMgrImpl *mgr =
UNC_KT_VTN)));
if (!mgr) {
UPLL_LOG_DEBUG("Invalid Mgr");
- delete ck_vtn_cntrlr;
+ DELETE_IF_NOT_NULL(ck_vtn_cntrlr);
+ DELETE_IF_NOT_NULL(ck_domain_vtn);
return UPLL_RC_ERR_GENERIC;
}
- DbSubOp dbop = {kOpReadSingle, kOpMatchCtrlr | kOpMatchDomain, kOpInOutNone};
- result_code = mgr->ReadConfigDB(ck_vtn_cntrlr, req->datatype,
- UNC_OP_READ, dbop, dmi, CTRLRTBL);
- if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- ConfigKeyVal *ck_vtn = NULL;
- result_code = GetParentConfigKey(ck_vtn, ikey);
- if (result_code == UPLL_RC_ERR_GENERIC) {
- UPLL_LOG_ERROR("Error in retrieving the parent VTN ConfigKeyVal");
- delete ck_vtn_cntrlr;
- return result_code;
- }
- dbop.matchop = kOpMatchNone;
- result_code = mgr->ReadConfigDB(ck_vtn, req->datatype, UNC_OP_READ,
+
+ result_code = GetParentConfigKey(ck_vtn, ikey);
+ if (result_code == UPLL_RC_ERR_GENERIC) {
+ UPLL_LOG_ERROR("Error in retrieving the parent VTN ConfigKeyVal");
+ DELETE_IF_NOT_NULL(ck_vtn_cntrlr);
+ DELETE_IF_NOT_NULL(ck_domain_vtn);
+ return result_code;
+ }
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutNone};
+
+ result_code = mgr->ReadConfigDB(ck_vtn, req->datatype, UNC_OP_READ,
dbop, dmi, MAINTBL);
- if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- UPLL_LOG_DEBUG("ReadConfigDB Failed %d", result_code);
- delete ck_vtn;
- delete ck_vtn_cntrlr;
- return result_code;
- }
- if (req->datatype != UPLL_DT_AUDIT) {
- result_code = mgr->ValidateCapability(
- req, ck_vtn, reinterpret_cast<char *>(ctrlr_dom->ctrlr));
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("ReadConfigDB Failed %d", result_code);
+ DELETE_IF_NOT_NULL(ck_vtn);
+ DELETE_IF_NOT_NULL(ck_vtn_cntrlr);
+ DELETE_IF_NOT_NULL(ck_domain_vtn);
+ return result_code;
+ }
+ val_vtn *vtn_val = reinterpret_cast<val_vtn*>
+ (GetVal(ck_vtn));
+ if (!vtn_val) {
+ UPLL_LOG_DEBUG("Invalid param");
+ DELETE_IF_NOT_NULL(ck_vtn);
+ DELETE_IF_NOT_NULL(ck_vtn_cntrlr);
+ DELETE_IF_NOT_NULL(ck_domain_vtn);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t valid_vtn_desc = vtn_val->valid[UPLL_IDX_DESC_VTN];
+
+ ConfigKeyVal *temp_key = NULL;
+ result_code = mgr->GetChildConfigKey(temp_key, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed");
+ DELETE_IF_NOT_NULL(ck_vtn);
+ DELETE_IF_NOT_NULL(ck_vtn_cntrlr);
+ DELETE_IF_NOT_NULL(ck_domain_vtn);
+ return result_code;
+ }
+ result_code = mgr->GetInstanceCount(temp_key,
+ reinterpret_cast<char *>(ctrlr_dom->ctrlr),
+ req->datatype, &mgr->cur_instance_count, dmi,
+ MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("GetInstanceCount error %d", result_code);
+ DELETE_IF_NOT_NULL(temp_key);
+ DELETE_IF_NOT_NULL(ck_vtn);
+ DELETE_IF_NOT_NULL(ck_vtn_cntrlr);
+ DELETE_IF_NOT_NULL(ck_domain_vtn);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ DELETE_IF_NOT_NULL(temp_key);
+
+ if (req->datatype != UPLL_DT_AUDIT) {
+ dt_type = req->datatype;
+ result_code = mgr->ValidateCapability(
+ req, ck_vtn, reinterpret_cast<char *>(ctrlr_dom->ctrlr));
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ValidateCapability Failed %d", result_code);
- delete ck_vtn;
- delete ck_vtn_cntrlr;
+ DELETE_IF_NOT_NULL(ck_vtn_cntrlr);
+ DELETE_IF_NOT_NULL(ck_domain_vtn);
+ DELETE_IF_NOT_NULL(ck_vtn);
return result_code;
}
- result_code = IntimatePOMAboutNewController(ikey, ctrlr_dom,
- dmi, UNC_OP_CREATE);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Error in updating POM Manager"
+ } else {
+ dt_type = UPLL_DT_AUDIT;
+ }
+
+ dbop.matchop = kOpMatchCtrlr|kOpMatchDomain;
+ /*Checks VTN exists on the controller and doamin*/
+ result_code = mgr->ReadConfigDB(ck_domain_vtn, req->datatype,
+ UNC_OP_READ, dbop, dmi, CTRLRTBL);
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code &&
+ UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB Failed %d", result_code)
+ DELETE_IF_NOT_NULL(ck_vtn);
+ DELETE_IF_NOT_NULL(ck_vtn_cntrlr);
+ DELETE_IF_NOT_NULL(ck_domain_vtn);
+ return result_code;
+ }
+
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+
+ dbop.matchop = kOpMatchCtrlr;
+ /* If the vtn exists in controller and not in domain
+ * then we have to rename the vtn name */
+ result_code = mgr->ReadConfigDB(ck_vtn_cntrlr, req->datatype,
+ UNC_OP_READ, dbop, dmi, CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB Failed %d", result_code);
+ DELETE_IF_NOT_NULL(ck_vtn);
+ DELETE_IF_NOT_NULL(ck_vtn_cntrlr);
+ DELETE_IF_NOT_NULL(ck_domain_vtn);
+ return result_code;
+ }
+ if (UPLL_RC_SUCCESS == result_code) {
+ /* The VTN name is available in the controller
+ * but not in the domain, so we have to create the new name
+ * for the give vtn */
+ std::string domain = reinterpret_cast<const char*>(ctrlr_dom->domain);
+ std::string vtn_name = reinterpret_cast<const char*>
+ (reinterpret_cast<key_vtn_t*>(
+ ck_domain_vtn->get_key())->vtn_name);
+ if (strlen(vtn_name.c_str())>=10) {
+ vtn_name.assign(vtn_name.c_str(), 10);
+ }
+ struct timeval _timeval;
+ struct timezone _timezone;
+ gettimeofday(&_timeval, &_timezone);
+ /* Renaming the VTN name based on the Time and Micro seconds */
+ std::string vtn_domain_name = vtn_name+"_"+
+ static_cast<std::ostringstream*>(
+ &(std::ostringstream() << _timeval.tv_sec))->str() +
+ static_cast<std::ostringstream*>(
+ &(std::ostringstream() << _timeval.tv_usec) )->str();
+ val_rename_vtn_t* rename_vtn = reinterpret_cast<val_rename_vtn_t*>(
+ ConfigKeyVal::Malloc(sizeof(val_rename_vtn)));
+ uuu::upll_strncpy(rename_vtn->new_name, vtn_domain_name.c_str(),
+ (kMaxLenVtnName+1));
+ rename_vtn->valid[UPLL_IDX_NEW_NAME_RVTN] = UNC_VF_VALID;
+ ck_vtn->SetCfgVal(new ConfigVal(IpctSt::kIpcStValRenameVtn, rename_vtn));
+ SET_USER_DATA(ck_vtn, ck_domain_vtn);
+ dbop.matchop = kOpMatchNone;
+ dbop.inoutop = kOpInOutCtrlr|kOpInOutDomain;
+ /* Create Entry in Rename Table */
+ result_code = mgr->UpdateConfigDB(ck_vtn, req->datatype,
+ UNC_OP_CREATE, dmi, &dbop, RENAMETBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateconfigDB failed");
+ DELETE_IF_NOT_NULL(ck_vtn);
+ DELETE_IF_NOT_NULL(ck_vtn_cntrlr);
+ DELETE_IF_NOT_NULL(ck_domain_vtn);
+ return result_code;
+ }
+ SET_USER_DATA_FLAGS(ck_domain_vtn, VTN_RENAME);
+ SET_USER_DATA_FLAGS(ck_vtn, VTN_RENAME);
+ ck_vtn->SetCfgVal(NULL);
+ /* UpdateRename Flag In VTN Main Table*/
+ dbop.inoutop = kOpInOutFlag;
+ result_code = mgr->UpdateConfigDB(ck_vtn, req->datatype,
+ UNC_OP_UPDATE, dmi, &dbop, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateconfigDB failed");
+ DELETE_IF_NOT_NULL(ck_vtn);
+ DELETE_IF_NOT_NULL(ck_vtn_cntrlr);
+ DELETE_IF_NOT_NULL(ck_domain_vtn);
+ return result_code;
+ }
+ SET_USER_DATA_FLAGS(ikey, VTN_RENAME);
+ }
+ ctrlr_val = reinterpret_cast<val_vtn_ctrlr *>
+ (GetVal(ck_domain_vtn));
+ if (!ctrlr_val) {
+ UPLL_LOG_DEBUG("Val is empty");
+ DELETE_IF_NOT_NULL(ck_vtn_cntrlr);
+ DELETE_IF_NOT_NULL(ck_domain_vtn);
+ DELETE_IF_NOT_NULL(ck_vtn);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ctrlr_val->ref_count = 1;
+ ctrlr_val->down_count = 0;
+ ctrlr_val->flags = 0;
+ ctrlr_val->oper_status = UPLL_OPER_STATUS_UNKNOWN;
+ ctrlr_val->alarm_status = UPLL_ALARM_CLEAR;
+ if (valid_vtn_desc == UNC_VF_NOT_SUPPORTED)
+ ctrlr_val->cs_attr[0] = UNC_CS_NOT_SUPPORTED ;
+ else if (valid_vtn_desc == UNC_VF_VALID)
+ ctrlr_val->cs_attr[0] = UNC_CS_NOT_APPLIED ;
+ ctrlr_val->cs_row_status = UNC_CS_NOT_APPLIED;
+ /* Inform to the POM keytypes for the new entry in vtn controller table*/
+ if (! OVERLAY_KT(ikey->get_key_type())) {
+ result_code = IntimatePOMAboutNewController(ikey, ctrlr_dom,
+ dmi, UNC_OP_CREATE, dt_type);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error in updating POM Manager"
" about the addition of a new Controller");
- delete ck_vtn;
- delete ck_vtn_cntrlr;
- return result_code;
+ DELETE_IF_NOT_NULL(ck_vtn);
+ DELETE_IF_NOT_NULL(ck_vtn_cntrlr);
+ DELETE_IF_NOT_NULL(ck_domain_vtn);
+ return result_code;
+ }
}
- }
-
- val_vtn_ctrlr *ctrlr_val = reinterpret_cast<val_vtn_ctrlr *>
- (GetVal(ck_vtn_cntrlr));
- val_vtn *vtn_val = reinterpret_cast<val_vtn*>
- (GetVal(ck_vtn));
- if (!ctrlr_val || !vtn_val) {
- UPLL_LOG_DEBUG("Invalid param");
- delete ck_vtn;
- delete ck_vtn_cntrlr;
- return UPLL_RC_ERR_GENERIC;
- }
- ctrlr_val->ref_count = 1;
- ctrlr_val->down_count = 0;
- ctrlr_val->flags = 0;
- ctrlr_val->oper_status = UPLL_OPER_STATUS_UNKNOWN;
- ctrlr_val->alarm_status = UPLL_ALARM_CLEAR;
- ctrlr_val->cs_attr[0] = (vtn_val->valid[UPLL_IDX_DESC_VTN] ==
- UNC_VF_NOT_SOPPORTED)? UNC_CS_NOT_SUPPORTED : UNC_CS_UNKNOWN;
- ctrlr_val->cs_row_status = UNC_CS_NOT_APPLIED;
- delete ck_vtn;
op = UNC_OP_CREATE;
- } else if (result_code == UPLL_RC_SUCCESS) {
- val_vtn_ctrlr *ctrlr_val = reinterpret_cast<val_vtn_ctrlr *>
- (GetVal(ck_vtn_cntrlr));
- if (!ctrlr_val) {
- UPLL_LOG_DEBUG("Invalid param");
- return UPLL_RC_ERR_GENERIC;
- }
- ctrlr_val->ref_count++;
+ } else if (UPLL_RC_SUCCESS == result_code) {
+ ctrlr_val = reinterpret_cast<val_vtn_ctrlr *>
+ (GetVal(ck_domain_vtn));
+ if (!ctrlr_val) {
+ UPLL_LOG_DEBUG("Val is empty");
+ DELETE_IF_NOT_NULL(ck_vtn_cntrlr);
+ DELETE_IF_NOT_NULL(ck_domain_vtn);
+ DELETE_IF_NOT_NULL(ck_vtn);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ ctrlr_val->ref_count++;
+ op = UNC_OP_UPDATE;
}
- result_code = mgr->UpdateConfigDB(ck_vtn_cntrlr, req->datatype,
+ // ck_vtn_cntrlr->SetCfgVal(new ConfigVal(IpctSt::kIpcInvalidStNum, ctrlr_val));
+ /* Create/Update Entry in Controller Table*/
+ // result_code = mgr->UpdateConfigDB(ck_vtn_cntrlr, req->datatype,
+ result_code = mgr->UpdateConfigDB(ck_domain_vtn, req->datatype,
op, dmi, CTRLRTBL);
- delete ck_vtn_cntrlr;
+ DELETE_IF_NOT_NULL(ck_vtn);
+ DELETE_IF_NOT_NULL(ck_vtn_cntrlr);
+ DELETE_IF_NOT_NULL(ck_domain_vtn);
return result_code;
}
upll_rc_t VnodeMoMgr::IntimatePOMAboutNewController(ConfigKeyVal *ikey,
controller_domain *ctrlr_dom,
DalDmlIntf *dmi,
- unc_keytype_operation_t op) {
+ unc_keytype_operation_t op,
+ upll_keytype_datatype_t dt_type) {
UPLL_FUNC_TRACE
upll_rc_t result_code = UPLL_RC_SUCCESS;
unc_key_type_t pom_keys[] = { UNC_KT_VTN_FLOWFILTER,
MoMgrImpl *pom_mgr = NULL;
uint8_t *vtn_name = (reinterpret_cast<key_vtn*>(ikey->get_key()))->vtn_name;
if (!vtn_name) return UPLL_RC_ERR_GENERIC;
+ UPLL_LOG_TRACE("Controller : %s; Domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
int npom_mgr = sizeof(pom_keys)/sizeof(pom_keys[0]);
+ uint8_t flag = 0;
+ GET_USER_DATA_FLAGS(ikey, flag);
for (uint8_t count = 0; count < npom_mgr; count++) {
pom_mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>(GetMoManager(
pom_keys[count])));
return UPLL_RC_ERR_GENERIC;
}
result_code = pom_mgr->UpdateControllerTableForVtn(vtn_name,
- ctrlr_dom, UNC_OP_CREATE, dmi);
+ ctrlr_dom, op, dt_type, dmi, flag);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Failed in Intimating POM module of new controller, %d",
result_code);
UPLL_LOG_TRACE("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
ctrlr_dom.domain);
SET_USER_DATA_CTRLR_DOMAIN(parent_key, ctrlr_dom);
- delete ck_vbr;
+ // delete ck_vbr;
/* GetReference count from vtn controller table */
MoMgrImpl *mgr =
reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
UPLL_LOG_DEBUG("Invalid Mgr");
return UPLL_RC_ERR_GENERIC;
}
+ dbop.matchop = kOpMatchCtrlr | kOpMatchDomain ;
result_code = mgr->ReadConfigDB(parent_key, req->datatype, UNC_OP_READ, dbop,
dmi, CTRLRTBL);
if (UPLL_RC_SUCCESS != result_code) return result_code;
val_vtn_ctrlr *vtn_st_val = reinterpret_cast<val_vtn_ctrlr *>
(GetVal(parent_key));
- // vtn_st_val->ref_count = 1; // TODO(l): refcount is not updated.
+ if (!vtn_st_val) {
+ UPLL_LOG_DEBUG("Val is empty");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ if (1 == vtn_st_val->ref_count) {
+ if (! OVERLAY_KT(ikey->get_key_type())) {
+ result_code = IntimatePOMAboutNewController(parent_key, &ctrlr_dom,
+ dmi, UNC_OP_DELETE, req->datatype);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IntimatePOMAboutNewController %d", result_code);
+ return result_code;
+ }
+ }
+ }
+ delete ck_vbr;
/* Delete the Current Node */
if (1 == vtn_st_val->ref_count) {
result_code = mgr->UpdateConfigDB(parent_key, req->datatype, UNC_OP_DELETE,
- dmi, CTRLRTBL);
-
+ dmi, &dbop, CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateconfigDB Failed %d", result_code);
+ return result_code;
+ }
+ parent_key->SetCfgVal(NULL);
+ result_code = mgr->UpdateConfigDB(parent_key, req->datatype, UNC_OP_DELETE,
+ dmi, &dbop, RENAMETBL);
+ if (UPLL_RC_SUCCESS != result_code &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_TRACE("UpdateConfigDB Failed %d", result_code);
+ return result_code;
+ }
+ result_code = (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code)?
+ UPLL_RC_SUCCESS:result_code;
} else {
// Reduce the ref count if vnode is not last node.
vtn_st_val->ref_count--;
result_code = mgr->UpdateConfigDB(parent_key, req->datatype, UNC_OP_UPDATE,
- dmi, CTRLRTBL);
+ dmi, &dbop, CTRLRTBL);
}
delete parent_key;
if (result_code != UPLL_RC_SUCCESS) {
upll_rc_t VnodeMoMgr::ControlMo(IpcReqRespHeader *header, ConfigKeyVal *ikey,
DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
+ if (!header || !ikey || !dmi) {
+ UPLL_LOG_DEBUG("Invalid input parameters");
+ return UPLL_RC_ERR_GENERIC;
+ }
upll_rc_t result_code = UPLL_RC_SUCCESS;
controller_domain_t ctrlr_dom;
ctrlr_dom.ctrlr = NULL;
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
return result_code;
- }
+ }
result_code = UpdateConfigDB(okey, UPLL_DT_RUNNING, UNC_OP_READ,
dmi, MAINTBL);
+ DELETE_IF_NOT_NULL(okey);
if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
UPLL_LOG_DEBUG("Record doesn't exist in DB. Error code : %d",
result_code);
result_code = GetRenamedControllerKey(ikey, UPLL_DT_RUNNING, dmi,
&ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Exiting VnodeMoMgr::ControlMo");
+ UPLL_LOG_DEBUG("GetRenamedControllerKey failed. Result : %d",
+ result_code);
return result_code;
}
GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
- UPLL_LOG_TRACE("After Read %s",(ikey->ToStrAll()).c_str());
+ UPLL_LOG_TRACE("After Read %s", (ikey->ToStrAll()).c_str());
IpcResponse ipc_resp;
- memset(&(ipc_resp),0,sizeof(IpcResponse));
+ memset(&(ipc_resp), 0, sizeof(IpcResponse));
IpcRequest ipc_req;
memset(&ipc_req, 0, sizeof(ipc_req));
memcpy(&(ipc_req.header), header, sizeof(IpcReqRespHeader));
ipc_req.ckv_data = ikey;
if (!uui::IpcUtil::SendReqToDriver((const char *)(ctrlr_dom.ctrlr),
- reinterpret_cast<char *>(ctrlr_dom.domain), PFCDRIVER_SERVICE_NAME,
+ reinterpret_cast<char *>(ctrlr_dom.domain), PFCDRIVER_SERVICE_NAME,
PFCDRIVER_SVID_LOGICAL, &ipc_req, true, &ipc_resp)) {
UPLL_LOG_INFO("Request to driver for Key %d for controller %s failed ",
ikey->get_key_type(), reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
return UPLL_RC_ERR_GENERIC;
}
-
+
// Populate ConfigKeyVal and IpcReqRespHeader with the response from driver
ikey->ResetWith(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ result_code = (header->result_code = ipc_resp.header.result_code);
} else {
UPLL_LOG_DEBUG("Control Operation not allowed for %d data type", header->datatype);
return UPLL_RC_ERR_CFG_SEMANTIC;
- }
+ }
} else {
UPLL_LOG_DEBUG("Control Operation not allowed for %d key type", ikey->get_key_type());
return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
ConfigKeyVal *&ck_val, DalDmlIntf *dmi,
upll_keytype_datatype_t dt_type) {
unc_key_type_t *ktype, if_ktype[] = { UNC_KT_VBR_IF, UNC_KT_VRT_IF,
- UNC_KT_VTEP_IF, UNC_KT_VTUNNEL_IF };
+ UNC_KT_VUNK_IF, UNC_KT_VTEP_IF,
+ UNC_KT_VTUNNEL_IF };
unc_key_type_t vnode_ktype[] = { UNC_KT_VBRIDGE, UNC_KT_VROUTER, UNC_KT_VTEP,
- UNC_KT_VTUNNEL };
+ UNC_KT_VTUNNEL, UNC_KT_VUNKNOWN };
int numnodes;
if (vnode) {
switch (keytype) {
case UNC_KT_VBRIDGE:
case UNC_KT_VROUTER:
+ case UNC_KT_VUNKNOWN:
case UNC_KT_VTUNNEL:
case UNC_KT_VTEP: {
const pfc_ipcstdef_t *key_stdef = IpctSt::GetIpcStdef(
ck_val->get_st_num());
- if (sizeof(key_vnode_t) != key_stdef->ist_size)
+ if (sizeof(key_vnode_t) != key_stdef->ist_size) {
+ DELETE_IF_NOT_NULL(ck_val);
return UPLL_RC_ERR_GENERIC;
+ }
memcpy(ck_val->get_key(), key, sizeof(key_vnode_t));
break;
}
case UNC_KT_VBR_IF:
case UNC_KT_VRT_IF:
+ case UNC_KT_VUNK_IF:
case UNC_KT_VTUNNEL_IF:
case UNC_KT_VTEP_IF: {
const pfc_ipcstdef_t *key_stdef = IpctSt::GetIpcStdef(
ck_val->get_st_num());
if (sizeof(*reinterpret_cast<const key_vbr_if_t *>(key))
- != key_stdef->ist_size)
+ != key_stdef->ist_size) {
+ DELETE_IF_NOT_NULL(ck_val);
return UPLL_RC_ERR_GENERIC;
+ }
memcpy(ck_val->get_key(), key, sizeof(key_vbr_if_t));
break;
}
default:
+ DELETE_IF_NOT_NULL(ck_val);
return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
- DbSubOp dbop1 = { kOpReadSingle, kOpMatchNone, kOpInOutCtrlr | kOpInOutFlag
- | kOpInOutDomain };
+ DbSubOp dbop1 = { kOpReadSingle, kOpMatchNone,
+ kOpInOutFlag | kOpMatchCtrlr | kOpInOutDomain };
result_code = mgr->ReadConfigDB(ck_val, dt_type,
UNC_OP_READ, dbop1, dmi, MAINTBL);
if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ DELETE_IF_NOT_NULL(ck_val);
continue;
} else if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_INFO("Error in reading %d", result_code);
+ DELETE_IF_NOT_NULL(ck_val);
return result_code;
} else {
return UPLL_RC_SUCCESS;
}
}
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ DELETE_IF_NOT_NULL(ck_val);
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+}
+
+upll_rc_t VnodeMoMgr::UpdateParentOperStatus(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ if (!ikey) {
+ UPLL_LOG_ERROR("Returning error \n");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ unc_key_type_t ktype = ikey->get_key_type();
+ if ((ktype != UNC_KT_VBRIDGE) && (ktype != UNC_KT_VROUTER))
+ return UPLL_RC_SUCCESS;
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutCtrlr | kOpInOutDomain};
+ result_code = ReadConfigDB(ikey, UPLL_DT_STATE, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ return result_code;
+ }
+ val_db_vbr_st *valst = reinterpret_cast<val_db_vbr_st *>(GetStateVal(ikey));
+ if (!valst) {
+ UPLL_LOG_DEBUG("Returning error\n");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (valst->vbr_val_st.valid[UPLL_IDX_OPER_STATUS_VBRS] == UNC_VF_VALID) {
+ if (valst->vbr_val_st.oper_status != UPLL_OPER_STATUS_DOWN)
+ return UPLL_RC_SUCCESS;
+ ConfigKeyVal *ck_vtn = NULL;
+ // decrement the down count in vtn controller table
+ result_code = GetParentConfigKey(ck_vtn,ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ return result_code;
+ }
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>
+ (GetMoManager(UNC_KT_VTN)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Returning error \n");
+ delete ck_vtn;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ DbSubOp dbop = {kOpReadSingle, kOpMatchCtrlr | kOpMatchDomain, kOpInOutNone};
+ result_code = mgr->ReadConfigDB(ck_vtn, UPLL_DT_STATE, UNC_OP_READ, dbop,
+ dmi, CTRLRTBL);
+ if (result_code == UPLL_RC_SUCCESS) {
+ val_vtn_ctrlr *vtn_val_st = reinterpret_cast<val_vtn_ctrlr *>(GetVal(ck_vtn));
+ vtn_val_st->down_count--;
+ result_code = mgr->UpdateConfigDB(ck_vtn, UPLL_DT_STATE, UNC_OP_UPDATE,
+ dmi, CTRLRTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ delete ck_vtn;
+ return result_code;
+ }
+ } else {
+ UPLL_LOG_DEBUG("Last vnode in ctrlr table %s\n",
+ (reinterpret_cast<key_vbr *>(ikey->get_key()))->vbridge_name);
+ }
+ // initialize parent vtn of main tbl to uninit so oper status gets computed during dt_state
+ DELETE_IF_NOT_NULL(ck_vtn);
+ result_code = mgr->GetCkvUninit(ck_vtn,NULL,dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ } else
+ result_code = UPLL_RC_SUCCESS;
+ DELETE_IF_NOT_NULL(ck_vtn);
+ return result_code;
+ }
+ result_code = mgr->UpdateConfigDB(ck_vtn, UPLL_DT_STATE, UNC_OP_UPDATE,
+ dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)
+ result_code = UPLL_RC_SUCCESS;
+ }
+ DELETE_IF_NOT_NULL(ck_vtn);
+ }
+ return result_code;
}
-bool VnodeMoMgr::UpdateOperStatus(ConfigKeyVal *ikey,
+upll_rc_t VnodeMoMgr::UpdateOperStatus(ConfigKeyVal *ikey,
DalDmlIntf *dmi,
- state_notification notification) {
+ state_notification notification, bool skip,
+ bool save_to_db) {
UPLL_FUNC_TRACE;
bool oper_status_change = false;
- unc_key_type_t ktype = ikey->get_key_type();
- VnodeMoMgr *mgr = reinterpret_cast<VnodeMoMgr *>
- (const_cast<MoManager*>(GetMoManager(ktype)));
- if (!mgr) {
- UPLL_LOG_DEBUG("Invalid mgr");
- return false;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ if (!ikey) {
+ UPLL_LOG_DEBUG("Returning error");
+ return UPLL_RC_ERR_GENERIC;
}
- switch (ktype) {
- case UNC_KT_VBRIDGE:
- oper_status_change = mgr->SetOperStatus<val_vbr_st_t, val_db_vbr_st_t *>(
- ikey, dmi, notification);
- break;
- case UNC_KT_VROUTER:
- oper_status_change = mgr->SetOperStatus<val_vrt_st_t, val_db_vrt_st_t *>(
- ikey, dmi, notification);
+ unc_key_type_t ktype = ikey->get_key_type();
+ bool read_db = false;
+ string s;
+ if (!skip) {
+ if (!save_to_db) {
+ void *key = ikey->get_key();
+ const char *vtn_name = reinterpret_cast<const char *>(
+ reinterpret_cast<key_vtn *>(key)->vtn_name);
+ s = string(vtn_name) +
+ reinterpret_cast<char *>(
+ reinterpret_cast<char *>(key) + sizeof(struct key_vtn));
+ map<string,ConfigKeyVal *>::const_iterator got
+ = vnode_oper_map.find(s);
+ if (got == vnode_oper_map.end())
+ read_db = true;
+ }
+ if (read_db || save_to_db) {
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone,
+ kOpInOutCtrlr | kOpInOutDomain };
+ result_code = ReadConfigDB(ikey, UPLL_DT_STATE, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("Error in reading: %d", result_code);
+ return result_code;
+ }
+ }
+ } else if (!save_to_db) {
+ UPLL_LOG_ERROR("Returning error \n");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigKeyVal *tkey, *tkey_next = ikey;
+ while (tkey_next != NULL) {
+ tkey = tkey_next;
+ tkey_next = tkey->get_next_cfg_key_val();
+ tkey->set_next_cfg_key_val(NULL);
+
+ switch (ktype) {
+ case UNC_KT_VBRIDGE:
+ oper_status_change = SetOperStatus<val_vbr_st_t, val_db_vbr_st_t *>(
+ tkey, dmi, notification, true, save_to_db);
+ break;
+ case UNC_KT_VROUTER:
+ oper_status_change = SetOperStatus<val_vrt_st_t, val_db_vrt_st_t *>(
+ tkey, dmi, notification, true, save_to_db);
break;
- case UNC_KT_VTEP:
- oper_status_change = mgr->SetOperStatus
+ case UNC_KT_VTEP:
+ oper_status_change = SetOperStatus
<val_vtep_st_t, val_db_vtep_st_t *>(
- ikey, dmi, notification);
- break;
- case UNC_KT_VTUNNEL:
- oper_status_change = mgr->SetOperStatus
+ tkey, dmi, notification, true, save_to_db);
+ break;
+ case UNC_KT_VTUNNEL:
+ oper_status_change = SetOperStatus
<val_vtunnel_st_t, val_db_vtunnel_st_t *>(
- ikey, dmi, notification);
- break;
- default:
- UPLL_LOG_DEBUG("Operstatus attribute not supported for this kt %d",
+ tkey, dmi, notification, true, save_to_db);
+ break;
+ default:
+ UPLL_LOG_DEBUG("Operstatus attribute not supported for this kt %d",
ktype);
+ break;
+ }
+ if ((oper_status_change && notification != kCtrlrDisconnect) ||
+ notification == kCtrlrReconnect ||
+ notification == kCtrlrReconnectIfUp ||
+ notification == kCtrlrReconnectIfDown) {
+ VtnMoMgr *mgr = reinterpret_cast<VtnMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VTN)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Invalid mgr");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigKeyVal *ck_vtn = NULL;
+ upll_rc_t result_code = GetParentConfigKey(ck_vtn, tkey);
+ if (!ck_vtn || result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ return result_code;
+ }
+ result_code = mgr->UpdateOperStatus(ck_vtn, dmi, notification, false);
+ delete ck_vtn;
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("VTN UpdateOperStatus failed");
+ return result_code;
+ }
+ }
+ if (skip)
break;
}
- if (oper_status_change) {
- VtnMoMgr *mgr = reinterpret_cast<VtnMoMgr *>
- (const_cast<MoManager *>(GetMoManager(UNC_KT_VTN)));
- if (!mgr) {
- UPLL_LOG_DEBUG("Invalid mgr");
- return UPLL_RC_ERR_GENERIC;
- }
- ConfigKeyVal *ck_vtn = NULL;
- upll_rc_t result_code = GetParentConfigKey(ck_vtn,ikey);
- if (!ck_vtn || result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d",result_code);
- return false;
- }
- oper_status_change = mgr->UpdateOperStatus(ck_vtn, dmi,
- notification,false);
- }
- return oper_status_change;
-}
-
-/*This function updates the operational status of the node*/
-upll_rc_t VnodeMoMgr::UpdateVnodeOperStatus(
- key_vnode_t *src_vnode, set<key_vnode_t> *vnode_set,
- set<key_vlink_t, vlink_compare> *vlink_set, DalDmlIntf *dmi,
- state_notification notification) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
-
- for (set<key_vnode_t>::iterator vnode_itr = vnode_set->begin();
- vnode_itr != vnode_set->end(); ++vnode_itr) {
- unc_key_type_t ktype;
- ConfigKeyVal *ck_vn;
- key_vnode_t vn_key = *vnode_itr;
- result_code = GetVnodeType(reinterpret_cast<const void *>(&vn_key),
- true, ktype, ck_vn, dmi, UPLL_DT_CANDIDATE);
- if (!ck_vn || result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d ", result_code);
+#if 0
+ if (!save_to_db) {
+ map<void *, ConfigKeyVal *>::const_iterator it;
+ VtnMoMgr *mgr = reinterpret_cast<VtnMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VTN)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Invalid mgr");
return UPLL_RC_ERR_GENERIC;
}
- UpdateOperStatus(ck_vn, dmi, notification);
-#if 0
- if (oper_status_change) {
- VtnMoMgr *mgr = reinterpret_cast<VtnMoMgr *>
- (const_cast<MoManager *>(GetMoManager(UNC_KT_VTN)));
- if (!mgr) {
- UPLL_LOG_DEBUG("Invalid mgr");
- return UPLL_RC_ERR_GENERIC;
+ for (it = mgr->vtn_oper_map.begin(); it != mgr->vtn_oper_map.end(); ++it) {
+ DbSubOp dbop = { kOpNotRead, kOpMatchCtrlr | kOpMatchDomain,
+ kOpInOutNone };
+ ConfigKeyVal *ck_vtn_main = NULL, *tkey = it->second;
+ result_code = mgr->UpdateConfigDB(tkey, UPLL_DT_RUNNING, UNC_OP_UPDATE,
+ dmi, &dbop, CTRLRTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error in update oper status %d", result_code);
+ return result_code;
}
- uint8_t *vtn_name = reinterpret_cast<key_vbr *>
- (ck_vn->get_key())->vtn_key.vtn_name;
- oper_status_change = mgr->SetOperStatus(vtn_name, dmi, notification);
- }
-#endif
- delete ck_vn;
- }
- VlinkMoMgr *mgr = reinterpret_cast<VlinkMoMgr *>(const_cast<MoManager*>
- (GetMoManager(UNC_KT_VLINK)));
- for (set<key_vlink_t>::iterator vlink_itr = vlink_set->begin();
- vlink_itr != vlink_set->end(); ++vlink_itr) {
- key_vlink_t *vlink_key = reinterpret_cast<key_vlink_t *>
- (malloc(sizeof(key_vlink_t)));
- if (!vlink_key) return UPLL_RC_ERR_GENERIC;
- *vlink_key = *vlink_itr;
- ConfigKeyVal *ikey = new ConfigKeyVal(UNC_KT_VLINK, IpctSt::kIpcStKeyVlink,
- vlink_key, NULL);
- result_code = mgr->SetOperStatus(ikey, dmi, notification);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Record updation failed in UPLL_DT_STATE %d",
- result_code);
- return result_code;
+ result_code = mgr->GetChildConfigKey(ck_vtn_main, tkey);
+ if (!ck_vtn_main) {
+ UPLL_LOG_DEBUG("Invalid param");
+ return result_code;
+ }
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
+ result_code = mgr->ReadConfigDB(ck_vtn_main, UPLL_DT_STATE, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error in reading: %d", result_code);
+ DELETE_IF_NOT_NULL(ck_vtn_main);
+ return result_code;
+ }
+ mgr->SetOperStatus(ck_vtn_main, notification, dmi);
+ map<void *, ConfigKeyVal *>::const_iterator local_it = it++;
+ mgr->vtn_oper_map.erase(local_it->first);
+ if (tckv) delete tckv;
}
- delete ikey;
+ mgr->vtn_oper_map.clear();
}
+#endif
return result_code;
}
+
template<typename T1, typename T2>
bool VnodeMoMgr::SetOperStatus(ConfigKeyVal *ikey,
DalDmlIntf *dmi, int notification,
- bool skip) {
+ bool skip, bool save_to_db) {
/* update corresponding vnode operstatus */
+ UPLL_FUNC_TRACE;
bool oper_change = false;
- upll_rc_t result_code;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
if (!skip) {
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
- result_code = ReadConfigDB(ikey, UPLL_DT_STATE, UNC_OP_READ, dbop, dmi,
+ bool read_db = false;;
+ if (!save_to_db) {
+ void *key = ikey->get_key();
+ const char *vtn_name = reinterpret_cast<const char *>(
+ reinterpret_cast<key_vtn *>(key)->vtn_name);
+ string s = string(vtn_name) +
+ reinterpret_cast<char *>(
+ reinterpret_cast<char *>(key) + sizeof(struct key_vtn));
+ map<string, ConfigKeyVal *>::const_iterator got
+ = vnode_oper_map.find(s);
+ if (got == vnode_oper_map.end())
+ read_db = true;
+ }
+ if ( read_db || save_to_db) {
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
+ result_code = ReadConfigDB(ikey, UPLL_DT_STATE, UNC_OP_READ, dbop, dmi,
MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Error in reading: %d", result_code);
- return oper_change;
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("Error in reading: %d", result_code);
+ return oper_change;
+ }
}
}
ConfigVal *tmp =
(ikey->get_cfg_val()) ? ikey->get_cfg_val()->get_next_cfg_val() : NULL;
+ unc_key_type_t ktype = ikey->get_key_type();
T2 vn_valst = (T2)((tmp != NULL) ? tmp->get_val() : NULL);
if (vn_valst == NULL) {
- UPLL_LOG_DEBUG("Invalid param\n");
- return UPLL_RC_ERR_GENERIC;
+ UPLL_LOG_DEBUG("Invalid param");
+ return oper_change;
}
T1 *vn_val = reinterpret_cast<T1 *>(vn_valst);
/* Update oper status based on notification */
vn_val->valid[0] = UNC_VF_VALID;
- UPLL_LOG_DEBUG("notification %d down_count %d fault_count %d\n",notification,
- vn_valst->down_count,vn_valst->fault_count);
+ UPLL_LOG_DEBUG("notification %d down_count %d fault_count %d", notification,
+ vn_valst->down_count, vn_valst->fault_count);
switch (notification) {
+ case kCtrlrReconnect:
+ return UPLL_RC_SUCCESS;
case kCtrlrDisconnect:
+ oper_change = (vn_val->oper_status != UPLL_OPER_STATUS_UNKNOWN)?
+ true:false;
vn_val->oper_status = UPLL_OPER_STATUS_UNKNOWN;
+ vn_valst->down_count = 0;
+ break;
+ case kCtrlrReconnectIfDown:
+ vn_val->oper_status = UPLL_OPER_STATUS_DOWN;
+ break;
+ case kCtrlrReconnectIfUp:
+ if (vn_val->oper_status == UPLL_OPER_STATUS_DOWN) {
+ return UPLL_RC_SUCCESS;
+ }
+ vn_val->oper_status = UPLL_OPER_STATUS_UP;
+ break;
+// return false;
+ case kAdminStatusDisabled:
+ oper_change = (vn_val->oper_status != UPLL_OPER_STATUS_DOWN)?true:false;
+ vn_val->oper_status = UPLL_OPER_STATUS_DOWN;
+ break;
+ case kAdminStatusEnabled:
+ if (vn_valst->down_count == 0) {
+ // oper_change = (vn_val->oper_status != UPLL_OPER_STATUS_UNINIT)?true:false;
+ oper_change = (vn_val->oper_status == UPLL_OPER_STATUS_DOWN)?
+ true:false;
+ if (OVERLAY_KT(ktype))
+ vn_val->oper_status = UPLL_OPER_STATUS_UP;
+ else
+ vn_val->oper_status = UPLL_OPER_STATUS_UNINIT;
+ } else {
+ vn_val->oper_status = UPLL_OPER_STATUS_DOWN;
+ oper_change = (vn_val->oper_status != UPLL_OPER_STATUS_DOWN)?
+ true:false;
+ }
break;
- case kCtrlrReconnect:
- return false;
case kPathFault:
- if (vn_valst->fault_count++ == 1) {
+ vn_valst->down_count= (vn_valst->down_count + 1);
+ vn_valst->fault_count= (vn_valst->fault_count + 1);
+ if (vn_valst->fault_count == 1 || vn_valst->down_count == 1) {
+ oper_change = (vn_val->oper_status != UPLL_OPER_STATUS_DOWN)?true:false;
vn_val->oper_status = UPLL_OPER_STATUS_DOWN;
// generate alarm
- oper_change = true;
}
break;
case kPathFaultReset:
vn_valst->fault_count = (vn_valst->fault_count > 0) ?
(vn_valst->fault_count - 1) : 0;
- if (vn_valst->fault_count == 0) {
- vn_val->oper_status = UPLL_OPER_STATUS_UP;
- // generate alarm
- oper_change = true;
+ vn_valst->down_count = (vn_valst->down_count > 0) ?
+ (vn_valst->down_count - 1) : 0;
+ if (vn_valst->fault_count == 0 || vn_valst->down_count == 0) {
+ oper_change = (vn_val->oper_status == UPLL_OPER_STATUS_DOWN)?true:false;
+ if (OVERLAY_KT(ktype))
+ vn_val->oper_status = UPLL_OPER_STATUS_UP;
+ else
+ vn_val->oper_status = UPLL_OPER_STATUS_UNINIT;
+ // reset alarm
}
break;
case kPortFault:
case kBoundaryFault:
- if (++vn_valst->down_count == 1) {
+ vn_valst->down_count = (vn_valst->down_count + 1);
+ if (vn_valst->down_count == 1) {
+ oper_change = (vn_val->oper_status != UPLL_OPER_STATUS_DOWN)?true:false;
vn_val->oper_status = UPLL_OPER_STATUS_DOWN;
- oper_change = true;
}
break;
case kPortFaultReset:
+ case kBoundaryFaultReset:
vn_valst->down_count = (vn_valst->down_count > 0) ?
(vn_valst->down_count - 1) : 0;
if (vn_valst->down_count == 0) {
- vn_val->oper_status = UPLL_OPER_STATUS_UP;
- // generate alarm
- oper_change = true;
- }
- break;
- case kBoundaryFaultReset:
- vn_valst->fault_count = (vn_valst->fault_count > 0) ?
- (vn_valst->fault_count - 1) : 0;
- if (vn_valst->fault_count == 0) {
- vn_val->oper_status = UPLL_OPER_STATUS_UP;
+ oper_change = (vn_val->oper_status == UPLL_OPER_STATUS_DOWN)?true:false;
+ if (OVERLAY_KT(ktype))
+ vn_val->oper_status = UPLL_OPER_STATUS_UP;
+ else
+ vn_val->oper_status = UPLL_OPER_STATUS_UNINIT;
// generate alarm
- oper_change = true;
}
break;
}
- DbSubOp dbop = { kOpNotRead, kOpMatchNone, kOpInOutNone };
- result_code = UpdateConfigDB(ikey, UPLL_DT_STATE, UNC_OP_UPDATE, dmi,
+ if (save_to_db) {
+ DbSubOp dbop = { kOpNotRead, kOpMatchNone, kOpInOutNone };
+ result_code = UpdateConfigDB(ikey, UPLL_DT_STATE, UNC_OP_UPDATE, dmi,
&dbop, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Error in update oper status %d", result_code);
+ UPLL_LOG_TRACE("Vnode SetOperstatus for VTN after Update is \n %s",
+ ikey->ToStrAll().c_str());
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error in update oper status %d", result_code);
+ }
+ } else {
+ void *key = ikey->get_key();
+ const char *vtn_name = reinterpret_cast<const char *>(
+ reinterpret_cast<key_vtn *>(key)->vtn_name) ;
+ string s = string(vtn_name) +
+ reinterpret_cast<char *>(
+ reinterpret_cast<char *>(key) + sizeof(struct key_vtn));
+ vnode_oper_map[s] = ikey;
+ if (vnode_oper_map[s] == ikey)
+ UPLL_LOG_DEBUG("Storing %s %p", s.c_str(), ikey);
}
return oper_change;
}
-/* This function update the vnode operstatus
+/* This function update the vnode operstatus
* while doing commit
*/
upll_rc_t VnodeMoMgr::TxUpdateDtState(unc_key_type_t ktype,
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *ck_vn = NULL;
+ unc_key_type_t child_keytype;
/* Create Vnode If key */
switch (ktype) {
case UNC_KT_VBRIDGE:
- result_code = GetUninitOperState<val_vbr_st_t, val_db_vbr_st_t>
- (ck_vn, dmi);
+ child_keytype = UNC_KT_VBR_IF;
break;
case UNC_KT_VROUTER:
- result_code = GetUninitOperState<val_vrt_st_t,val_db_vrt_st>
- (ck_vn, dmi);
+ child_keytype = UNC_KT_VRT_IF;
break;
case UNC_KT_VTEP:
- result_code = GetUninitOperState<val_vtep_st_t,val_db_vtep_st>
- (ck_vn, dmi);
+ child_keytype = UNC_KT_VTEP_IF;
break;
case UNC_KT_VTUNNEL:
- result_code = GetUninitOperState<val_vtunnel_st_t,val_db_vtunnel_st>
- (ck_vn, dmi);
+ child_keytype = UNC_KT_VTUNNEL_IF;
break;
default:
- UPLL_LOG_DEBUG("Unsupported operation on keytype %d\n",ktype);
+ UPLL_LOG_DEBUG("Unsupported operation on keytype %d", ktype);
return UPLL_RC_ERR_GENERIC;
}
+ result_code = GetUninitOperState(ck_vn, dmi);
if (UPLL_RC_SUCCESS != result_code || ck_vn == NULL) {
return result_code;
}
ConfigKeyVal *tkey = ck_vn;
DbSubOp dbop1 = { kOpNotRead, kOpMatchNone, kOpInOutNone };
- DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone };
- while (tkey) {
+ while (ck_vn) {
+ state_notification notification;
+ tkey = ck_vn;
+ ck_vn = tkey->get_next_cfg_key_val();
+ tkey->set_next_cfg_key_val(NULL);
/* read the state value */
- ConfigKeyVal *okey = NULL;
- result_code = GetChildConfigKey(okey,tkey);
- if (!okey || result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning %d\n",result_code);
- return result_code;
- }
- result_code = ReadConfigDB(okey, UPLL_DT_STATE,
- UNC_OP_READ, dbop, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning %d\n",result_code);
- return result_code;
- }
val_db_vbr_st * vnode_runst = reinterpret_cast<val_db_vbr_st *>
- (GetStateVal(okey));
+ (GetStateVal(tkey));
if (!vnode_runst) {
- UPLL_LOG_DEBUG("Invalid param\n");
+ UPLL_LOG_DEBUG("Invalid param");
return UPLL_RC_ERR_GENERIC;
}
if ((vnode_runst->down_count == 0) && (vnode_runst->fault_count == 0)) {
- if (vnode_runst->vbr_val_st.oper_status != UPLL_OPER_STATUS_UNKNOWN) {
- val_db_vbr_st * vnode_st = reinterpret_cast<val_db_vbr_st *>
- (GetStateVal(tkey));
- vnode_st->vbr_val_st.valid[UPLL_IDX_OPER_STATUS_VBRS] = UNC_VF_VALID;
- vnode_st->vbr_val_st.oper_status = UPLL_OPER_STATUS_UP;
- vnode_st->down_count = vnode_runst->down_count;
- vnode_st->fault_count = vnode_runst->fault_count;
- result_code = UpdateConfigDB(tkey, UPLL_DT_STATE, UNC_OP_UPDATE,
- dmi, &dbop1, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("UpdateConfigDB Executed %d", result_code);
- break;
+ // get count of vnode ifs down
+ uint32_t cur_instance_count = 0;
+ ConfigKeyVal *ck_vnif = NULL;
+
+ VnodeChildMoMgr *mgr = reinterpret_cast<VnodeChildMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(child_keytype)));
+ result_code = mgr->GetCkvUninit(ck_vnif, tkey, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ return result_code;
+ }
+ val_db_vbr_st *vnif_stval = reinterpret_cast<val_db_vbr_st *>
+ (GetStateVal(ck_vnif));
+ vnif_stval->vbr_val_st.oper_status = UPLL_OPER_STATUS_DOWN;
+ vnif_stval->vbr_val_st.valid[UPLL_IDX_OPER_STATUS_VBRS] = UNC_VF_VALID;
+ result_code = mgr->GetInstanceCount(ck_vnif, NULL, UPLL_DT_STATE,
+ &cur_instance_count, dmi, MAINTBL);
+ if (result_code == UPLL_RC_SUCCESS) {
+ if (cur_instance_count == 0) {
+ vnode_runst->vbr_val_st.oper_status = UPLL_OPER_STATUS_UP;
+ notification = kAdminStatusEnabled;
+ } else {
+ vnode_runst->vbr_val_st.oper_status = UPLL_OPER_STATUS_DOWN;
+ notification = kAdminStatusDisabled;
}
+ } else if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ vnode_runst->vbr_val_st.oper_status = UPLL_OPER_STATUS_DOWN;
+ notification = kAdminStatusDisabled;
+ } else {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ delete ck_vnif;
+ delete tkey;
+ delete ck_vn;
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(ck_vnif);
+ vnode_runst->vbr_val_st.valid[UPLL_IDX_OPER_STATUS_VBRS] = UNC_VF_VALID;
+ } else {
+ if (vnode_runst->down_count > 0)
+ notification = kPortFault;
+ else if (vnode_runst->fault_count > 0)
+ notification = kPathFault;
+ vnode_runst->vbr_val_st.oper_status = UPLL_OPER_STATUS_DOWN;
+ vnode_runst->vbr_val_st.valid[UPLL_IDX_OPER_STATUS_VBRS] = UNC_VF_VALID;
+ }
+ result_code = UpdateConfigDB(tkey, UPLL_DT_STATE,UNC_OP_UPDATE,
+ dmi, &dbop1, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigDB Executed %d", result_code);
+ break;
+ }
+ // invoked from port status handler
+ // don't propagate as the event is already propagated.
+ if ((config_id == 0) && (session_id == 0)) {
+ delete tkey;
+ continue;
+ }
+ if (notification != kAdminStatusEnabled) {
+ VtnMoMgr *mgr = reinterpret_cast<VtnMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VTN)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Invalid mgr");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigKeyVal *ck_vtn = NULL;
+ upll_rc_t result_code = GetParentConfigKey(ck_vtn, tkey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ return result_code;
+ }
+ result_code = mgr->UpdateOperStatus(ck_vtn, dmi, notification, false);
+ delete ck_vtn;
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("VTN UpdateOperStatus failed");
+ return result_code;
}
}
- if (okey) delete okey;
- tkey= tkey->get_next_cfg_key_val();
+ delete tkey;
}
if (ck_vn)
delete ck_vn;
+ ck_vn = NULL;
+ return result_code;
+}
+
+
+#if 0
+upll_rc_t VnodeMoMgr::InitOperStatus(ConfigKeyVal *tkey) {
+ state_notification notification;
+ UPLL_FUNC_TRACE;
+
+ if (!tkey) {
+ UPLL_LOG_DEBUG("Returning error \n");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ /* read the state value */
+ val_db_vbr_st * vnode_runst = reinterpret_cast<val_db_vbr_st *>
+ (GetStateVal(tkey));
+ if (!vnode_runst) {
+ UPLL_LOG_DEBUG("Invalid param");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if ((vnode_runst->down_count == 0) && (vnode_runst->fault_count == 0)) {
+ // get count of vnode ifs down
+ uint32_t cur_instance_count = 0;
+ ConfigKeyVal *ck_vnif = NULL;
+
+ VnodeChildMoMgr *mgr = reinterpret_cast<VnodeChildMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(child_keytype)));
+ result_code = mgr->GetCkvUninit(ck_vnif, tkey, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ return result_code;
+ }
+ val_db_vbr_st *vnif_stval = reinterpret_cast<val_db_vbr_st *>
+ (GetStateVal(ck_vnif));
+ vnif_stval->vbr_val_st.oper_status = UPLL_OPER_STATUS_DOWN;
+ vnif_stval->vbr_val_st.valid[UPLL_IDX_OPER_STATUS_VBRS] = UNC_VF_VALID;
+ result_code = mgr->GetInstanceCount(ck_vnif, NULL, UPLL_DT_STATE,
+ &cur_instance_count, dmi, MAINTBL);
+ if (result_code == UPLL_RC_SUCCESS) {
+ if (cur_instance_count == 0) {
+ vnode_runst->vbr_val_st.oper_status = UPLL_OPER_STATUS_UP;
+ notification = kAdminStatusEnabled;
+ } else {
+ vnode_runst->vbr_val_st.oper_status = UPLL_OPER_STATUS_DOWN;
+ notification = kAdminStatusDisabled;
+ }
+ } else if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ vnode_runst->vbr_val_st.oper_status = UPLL_OPER_STATUS_DOWN;
+ notification = kAdminStatusDisabled;
+ } else {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ delete ck_vnif;
+ delete tkey;
+ delete ck_vn;
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(ck_vnif);
+ vnode_runst->vbr_val_st.valid[UPLL_IDX_OPER_STATUS_VBRS] = UNC_VF_VALID;
+ } else {
+ if (vnode_runst->down_count > 0)
+ notification = kPortFault;
+ else if (vnode_runst->fault_count > 0)
+ notification = kPathFault;
+ vnode_runst->vbr_val_st.oper_status = UPLL_OPER_STATUS_DOWN;
+ vnode_runst->vbr_val_st.valid[UPLL_IDX_OPER_STATUS_VBRS] = UNC_VF_VALID;
+ }
+ DbSubOp dbop1 = { kOpNotRead, kOpMatchNone, kOpInOutNone };
+ result_code = UpdateConfigDB(tkey, UPLL_DT_STATE,UNC_OP_UPDATE,
+ dmi, &dbop1, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigDB Executed %d", result_code);
+ return result_code;
+ }
+ VtnMoMgr *mgr = reinterpret_cast<VtnMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VTN)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Invalid mgr");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigKeyVal *ck_vtn = NULL;
+ upll_rc_t result_code = GetParentConfigKey(ck_vtn, tkey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ return result_code;
+ }
+ result_code = mgr->UpdateOperStatus(ck_vtn, dmi, notification, false);
+ delete ck_vtn;
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("VTN UpdateOperStatus failed");
+ }
return result_code;
}
+#endif
} // namespace kt_momgr
} // namespace upll
#include <string>
#include <set>
+#include <map>
#include "momgr_impl.hh"
namespace unc {
class VnodeMoMgr : public MoMgrImpl {
public:
+ map<string,ConfigKeyVal *> vnode_oper_map;
+
VnodeMoMgr() {
parent_ck_vtn = NULL;
- cur_instance_count = 0;
cntrl_id = NULL;
}
virtual ~VnodeMoMgr() {
parent_ck_vtn = NULL;
}
- bool UpdateOperStatus(ConfigKeyVal *ck_vn,
+ upll_rc_t UpdateOperStatus(ConfigKeyVal *ck_vn,
DalDmlIntf *dmi,
- state_notification notification);
+ state_notification notification, bool skip,
+ bool save_to_db);
upll_rc_t CtrlrTypeAndDomainCheck(ConfigKeyVal *ikey,
IpcReqRespHeader *req);
+ /**
+ * @Brief compares controller id and domain id before
+ * updating the value to DB.
+ * @param[in] ikey ikey contains key and value structure.
+ * @param[in] okey okey contains key and value structure.
+ *
+ * @retval UPLL_RC_SUCCESS Successful.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX Syntax error.
+ */
+ virtual upll_rc_t CtrlrIdAndDomainIdUpdationCheck(ConfigKeyVal *ikey,
+ ConfigKeyVal *okey) = 0;
+
/**
* @brief Perform Semantic Check to check Different vbridges
* contain same switch-id and vlan-id
upll_rc_t IntimatePOMAboutNewController(ConfigKeyVal *ikey,
controller_domain *ctrlr_dom,
DalDmlIntf *dmi,
- unc_keytype_operation_t op);
+ unc_keytype_operation_t op,
+ upll_keytype_datatype_t dt_type);
template<typename T1, typename T2>
bool SetOperStatus(ConfigKeyVal *ikey,
DalDmlIntf *dmi,
int notification,
- bool skip = false);
+ bool skip,
+ bool save_to_db);
+
+ /* @brief To update oper status of vnode
+ *
+ * @param[in] ktype keytype
+ * @param[in] session_id session identifier
+ * @param[in] config_id config identifier
+ * @param[in] dmi Pointer to db connection instance
+ *
+ * @retval UPLL_RC_SUCCESS updated successfully.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ * @retval UPLL_RC_ERR_DB_ACCESS DB Read/Write error.
+ *
+ **/
+ upll_rc_t TxUpdateDtState(unc_key_type_t ktype,
+ uint32_t session_id,
+ uint32_t config_id,
+ DalDmlIntf *dmi) ;
protected:
- uint32_t cur_instance_count;
ConfigKeyVal *parent_ck_vtn;
+ /**
+ * @brief Update parent oper status on delete for Transaction commit
+ *
+ * @param[in] ikey ConfigKeyVal instance
+ * @param[in] dmi Database connection parameter
+
+ * @retval UPLL_RC_SUCCESS Completed successfully.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ */
+ virtual upll_rc_t UpdateParentOperStatus(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi);
+
virtual upll_rc_t DeleteMo(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
DalDmlIntf *dmi);
uint8_t *&vtn_name,
uint8_t *&vnode_name) =0;
- upll_rc_t UpdateVnodeOperStatus(key_vnode_t *src_vnode,
- set<key_vnode_t>*vnode_set,
- set<key_vlink_t, vlink_compare>*vlink_set,
- DalDmlIntf *dmi, state_notification notification);
-
-
/**
* @brief Checks and Updates the VbrIf interfaces associated with the vlink with the
* information from physical if the VbrIf is part of vExternal
upll_rc_t ControlMo(IpcReqRespHeader *header, ConfigKeyVal *ikey,
DalDmlIntf *dmi);
- /* @brief To update oper status of vnode
- *
- * @param[in] ktype keytype
- * @param[in] session_id session identifier
- * @param[in] config_id config identifier
- * @param[in] dmi Pointer to db connection instance
- *
- * @retval UPLL_RC_SUCCESS updated successfully.
- * @retval UPLL_RC_ERR_GENERIC Generic failure.
- * @retval UPLL_RC_ERR_DB_ACCESS DB Read/Write error.
- *
- **/
-
- upll_rc_t TxUpdateDtState(unc_key_type_t ktype,
- uint32_t session_id,
- uint32_t config_id,
- DalDmlIntf *dmi) ;
};
} // namespace kt_momgr
#include "unc/upll_ipc_enum.h"
#include "flowlist_momgr.hh"
#include "vrt_if_momgr.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "vbr_flowfilter_entry_momgr.hh"
namespace unc {
namespace kt_momgr {
using unc::upll::ipc_util::IpcUtil;
-#define NUM_KEY_MAIN_TBL_ 5
-#define NUM_KEY_RENAME_MAIN_TBL 7
#define FLOWLIST_RENAME_FLAG 0x04 // For 3rd Bit
#define VTN_RENAME_FLAG 0x01 // For first Bit
#define VBR_RENAME_FLAG 0x10 // For 2nd Bit
-#define VRT_RENAME_FLAG 0x10 // For 2nd Bit
+#define VRT_RENAME_FLAG 0x02 // For 2nd Bit
+#define NO_VRT_RENAME_FLAG ~VRT_RENAME_FLAG
#define VLINK_CONFIGURED 0x01
#define PORTMAP_CONFIGURED 0x02
#define VLINK_PORTMAP_CONFIGURED 0x03
-#define SET_FLAG_VLINK 0x08
-#define SET_FLAG_PORTMAP 0x0A
-#define SET_FLAG_VLINK_PORTMAP 0x018
+#define SET_FLAG_VLINK 0x40
+#define NO_FLAG_VLINK ~SET_FLAG_VLINK
+#define SET_FLAG_PORTMAP 0x20
+#define SET_FLAG_VLINK_PORTMAP 0x80
+#define SET_FLAG_NO_VLINK_PORTMAP ~SET_FLAG_VLINK_PORTMAP
+#define FLOW_RENAME 0x04
+#define NO_FLOWLIST_RENAME ~FLOW_RENAME
BindInfo VrtIfFlowFilterEntryMoMgr::vrt_if_flowfilter_entry_bind_info[] = {
{ uudst::vrt_if_flowfilter_entry::kDbiVtnName, CFG_KEY,
offsetof(val_flowfilter_entry_t, cs_attr[5]),
uud::kDalUint8, 1 },
{ uudst::vrt_if_flowfilter_entry::kDbiCsNwmName, CS_VAL,
- offsetof(val_flowlist_entry_t, cs_attr[6]),
+ offsetof(val_flowfilter_entry_t, cs_attr[6]),
uud::kDalUint8, 1 },
{ uudst::vrt_if_flowfilter_entry::kDbiCsDscp, CS_VAL,
- offsetof(val_flowlist_entry_t, cs_attr[7]),
+ offsetof(val_flowfilter_entry_t, cs_attr[7]),
uud::kDalUint8, 1 },
{ uudst::vrt_if_flowfilter_entry::kDbiCsPriority, CS_VAL,
- offsetof(val_flowlist_entry_t, cs_attr[8]),
+ offsetof(val_flowfilter_entry_t, cs_attr[8]),
uud::kDalUint8, 1 }
};
offsetof(key_vrt_if_flowfilter_entry_t,
flowfilter_key.if_key.vrt_key.vrouter_name),
uud::kDalChar, (kMaxLenVnodeName + 1) },
- { uudst::vrt_if_flowfilter_entry::kDbiVrtIfName, CFG_MATCH_KEY,
- offsetof(key_vrt_if_flowfilter_entry_t, flowfilter_key.if_key.if_name),
- uud::kDalChar, (kMaxLenInterfaceName + 1) },
- { uudst::vrt_if_flowfilter_entry::kDbiInputDirection, CFG_MATCH_KEY,
- offsetof(key_vrt_if_flowfilter_entry_t, flowfilter_key.direction),
- uud::kDalUint8, 1 },
- { uudst::vrt_if_flowfilter_entry::kDbiSequenceNum, CFG_MATCH_KEY,
- offsetof(key_vrt_if_flowfilter_entry_t, sequence_num),
- uud::kDalUint16, 1 },
{ uudst::vrt_if_flowfilter_entry::kDbiVtnName, CFG_INPUT_KEY,
offsetof(key_rename_vnode_info_t, new_unc_vtn_name),
uud::kDalChar, (kMaxLenVtnName + 1) },
{ uudst::vrt_if_flowfilter_entry::kDbiVrtName, CFG_INPUT_KEY,
offsetof(key_rename_vnode_info_t, new_unc_vnode_name),
uud::kDalChar, (kMaxLenVnodeName + 1) },
- { uudst::vrt_if_flowfilter_entry::kDbiFlags, CFG_INPUT_KEY,
+ { uudst::vrt_if_flowfilter_entry::kDbiFlags, CK_VAL,
offsetof(key_user_data_t, flags),
uud::kDalUint8, 1 }
};
-BindInfo VrtIfFlowFilterEntryMoMgr::vrt_if_flowlist_rename_bind_info[] = {
- { uudst::vrt_if_flowfilter_entry::kDbiVtnName, CFG_MATCH_KEY,
- offsetof(key_vrt_if_flowfilter_entry_t,
- flowfilter_key.if_key.vrt_key.vtn_key.vtn_name),
- uud::kDalChar, (kMaxLenVtnName + 1) },
- { uudst::vrt_if_flowfilter_entry::kDbiVrtName, CFG_MATCH_KEY,
- offsetof(key_vrt_if_flowfilter_entry_t,
- flowfilter_key.if_key.vrt_key.vrouter_name),
- uud::kDalChar, (kMaxLenVnodeName + 1) },
- { uudst::vrt_if_flowfilter_entry::kDbiVrtIfName, CFG_MATCH_KEY,
- offsetof(key_vrt_if_flowfilter_entry_t, flowfilter_key.if_key.if_name),
- uud::kDalChar, (kMaxLenInterfaceName + 1) },
- { uudst::vrt_if_flowfilter_entry::kDbiInputDirection, CFG_MATCH_KEY,
- offsetof(key_vrt_if_flowfilter_entry_t, flowfilter_key.direction),
- uud::kDalUint8, 1 },
- { uudst::vrt_if_flowfilter_entry::kDbiSequenceNum, CFG_MATCH_KEY,
- offsetof(key_vrt_if_flowfilter_entry_t, sequence_num),
- uud::kDalUint16, 1 },
- { uudst::vrt_if_flowfilter_entry::kDbiFlowlistName, CFG_INPUT_KEY,
- offsetof(key_rename_vnode_info_t, new_flowlist_name),
- uud::kDalChar, (kMaxLenFlowListName + 1) },
- { uudst::vrt_if_flowfilter_entry::kDbiFlags, CFG_INPUT_KEY,
- offsetof(key_user_data_t, flags),
- uud::kDalUint8, 1 }
-};
+
VrtIfFlowFilterEntryMoMgr::VrtIfFlowFilterEntryMoMgr() : MoMgrImpl() {
UPLL_FUNC_TRACE;
table[RENAMETBL] = NULL;
table[CTRLRTBL] = NULL;
nchild = 0;
+ cur_instance_count =0;
child = NULL;
}
if (result_code != UPLL_RC_SUCCESS)
return result_code;
- result_code = UpdateConfigDB(ikey, UPLL_DT_CANDIDATE, UNC_OP_READ, dmi);
+ result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_READ, dmi);
if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code) {
- UPLL_LOG_TRACE("Instance Already Exists");
+ UPLL_LOG_TRACE("Instance Does not exist");
return result_code;
}
ConfigKeyVal *okey = NULL;
return result_code;
}
DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutCtrlr };
- result_code = ReadConfigDB(okey, UPLL_DT_CANDIDATE,
+ result_code = ReadConfigDB(okey, req->datatype,
UNC_OP_READ, dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Unable to read configuration from CandidateDb");
delete okey;
return result_code;
}
- GET_USER_DATA_CTRLR(ikey, ctrlr_id);
+ GET_USER_DATA_CTRLR(okey, ctrlr_id);
val_flowfilter_entry_t *flowfilter_val =
reinterpret_cast<val_flowfilter_entry_t *> (GetVal(okey));
if (flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
(const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
result_code = mgr->AddFlowListToController(
reinterpret_cast<char *>(flowfilter_val->flowlist_name), dmi,
- reinterpret_cast<char *>(ctrlr_id) , UNC_OP_DELETE);
- if (result_code != UPLL_RC_SUCCESS) return result_code;
+ reinterpret_cast<char *>(ctrlr_id), req->datatype, UNC_OP_DELETE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
}
-
- result_code = UpdateConfigDB(ikey, UPLL_DT_CANDIDATE, UNC_OP_DELETE, dmi,
+ DELETE_IF_NOT_NULL(okey);
+ result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_DELETE, dmi,
MAINTBL);
return result_code;
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- val_flowfilter_entry_t *vrt_if_flowfilter_entry_val = NULL;
+ val_flowfilter_entry_t *val = NULL;
- vrt_if_flowfilter_entry_val = (ckv_running != NULL)?
+ val = (ckv_running != NULL)?
reinterpret_cast<val_flowfilter_entry_t *> (GetVal(ckv_running)):NULL;
- if (NULL == vrt_if_flowfilter_entry_val) {
- UPLL_LOG_DEBUG("UpdateAuditConfigStatus::vrt_if_flowfilter_entry_val Null");
+ if (NULL == val) {
+ UPLL_LOG_DEBUG("UpdateAuditConfigStatus::val Null");
return UPLL_RC_ERR_GENERIC;
}
-
if (uuc::kUpllUcpCreate == phase )
- vrt_if_flowfilter_entry_val->cs_row_status = cs_status;
+ val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
for ( unsigned int loop = 0;
- loop < sizeof(vrt_if_flowfilter_entry_val->valid)/
- sizeof(vrt_if_flowfilter_entry_val->valid[0]); ++loop ) {
- if ((cs_status == UNC_CS_INVALID) &&
- (UNC_VF_VALID == vrt_if_flowfilter_entry_val->valid[loop]))
- vrt_if_flowfilter_entry_val->cs_attr[loop] = cs_status;
- else
- vrt_if_flowfilter_entry_val->cs_attr[loop] = cs_status;
+ loop < sizeof(val->valid)/sizeof(uint8_t); ++loop ) {
+ if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
+ cs_status == UNC_CS_APPLIED)
+ val->cs_attr[loop] = cs_status;
}
UPLL_LOG_DEBUG("UpdateAuditConfigStatus::Success");
return result_code;
UPLL_LOG_DEBUG("Both Request and Input Key are Null");
return UPLL_RC_ERR_GENERIC;
}
- UPLL_LOG_DEBUG("In updateMo");
result_code = ValidateMessage(req, ikey);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("Vallidation is Failed %d", result_code);
return result_code;
}
-
result_code = ValidateVrtIfValStruct(req, ikey, dmi);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("ValidateVrtIfValStruct Failed %d", result_code);
UPLL_LOG_DEBUG("Error Accesing CANDIDATE DB (%d)", result_code);
return result_code;
}
- if (okey != NULL) {
- delete okey;
- okey = NULL;
- }
- }
- if (UNC_VF_VALID == flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] ||
- UNC_VF_VALID_NO_VALUE == flowfilter_val->
- valid[UPLL_IDX_FLOWLIST_NAME_FFE]) {
- result_code = GetChildConfigKey(okey, ikey);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("GetChildConfigKey failed");
- return result_code;
- }
- DbSubOp dbop = { kOpReadSingle, kOpMatchNone,
- kOpInOutCtrlr|kOpInOutDomain };
- result_code = ReadConfigDB(okey, UPLL_DT_CANDIDATE, UNC_OP_READ, dbop, dmi,
- MAINTBL);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
- return result_code;
- }
- GET_USER_DATA_CTRLR(okey, ctrlr_id);
- val_flowfilter_entry_t *temp_ffe_val = reinterpret_cast
- <val_flowfilter_entry_t *>(GetVal(okey));
- UPLL_LOG_DEBUG("flowlist name %s", flowfilter_val->flowlist_name);
- if (UNC_VF_VALID == flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_VFFE] &&
- UNC_VF_VALID == temp_ffe_val->
- valid[UPLL_IDX_FLOWLIST_NAME_VFFE]) {
- UPLL_LOG_DEBUG("Update option 1");
- result_code = flowlist_mgr->AddFlowListToController(
- reinterpret_cast<char *>(temp_ffe_val->flowlist_name), dmi,
- reinterpret_cast<char *>(ctrlr_id) , UNC_OP_DELETE);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("AddFlowListToController failed %d", result_code);
- delete okey;
- return result_code;
- }
- result_code = flowlist_mgr->AddFlowListToController(
- reinterpret_cast<char *>(flowfilter_val->flowlist_name), dmi,
- reinterpret_cast<char *>(ctrlr_id) , UNC_OP_CREATE);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("AddFlowListToController failed %d", result_code);
- delete okey;
- return result_code;
- }
- } else if (UNC_VF_VALID == flowfilter_val->
- valid[UPLL_IDX_FLOWLIST_NAME_VFFE] &&
- (UNC_VF_INVALID == temp_ffe_val->
- valid[UPLL_IDX_FLOWLIST_NAME_VFFE] || UNC_VF_VALID_NO_VALUE ==
- temp_ffe_val->valid[UPLL_IDX_FLOWLIST_NAME_VFFE])) {
- UPLL_LOG_DEBUG("Update option 2");
- result_code = flowlist_mgr->AddFlowListToController(
- reinterpret_cast<char *>(flowfilter_val->flowlist_name), dmi,
- reinterpret_cast<char *> (ctrlr_id) , UNC_OP_CREATE);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("AddFlowListToController failed %d", result_code);
- delete okey;
- return result_code;
- }
- } else if (UNC_VF_VALID_NO_VALUE == flowfilter_val->
- valid[UPLL_IDX_FLOWLIST_NAME_VFFE] &&
- UNC_VF_VALID == temp_ffe_val->
- valid[UPLL_IDX_FLOWLIST_NAME_VFFE]) {
- UPLL_LOG_DEBUG("Update option 3");
- result_code = flowlist_mgr->AddFlowListToController(
- reinterpret_cast<char *>(temp_ffe_val->flowlist_name), dmi,
- reinterpret_cast<char *>(ctrlr_id) , UNC_OP_DELETE);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("AddFlowListToController failed %d", result_code);
- delete okey;
- return result_code;
- }
- }
+ delete okey;
+ okey = NULL;
}
- // N/w monitor
-#if 0
- NwMonitorMoMgr *nmgr = reinterpret_cast<NwMonitorMoMgr *>
- (const_cast<MoManager *> (GetMoManager(UNC_KT_VBR_NWMONITOR)));
- // result_code = nmgr->GetChildConfigKey(okey, NULL); //TODO
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Recored %d", result_code);
+ result_code = GetChildConfigKey(okey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed");
+ return result_code;
+ }
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone,
+ kOpInOutCtrlr|kOpInOutDomain|kOpInOutFlag };
+ result_code = ReadConfigDB(okey, UPLL_DT_CANDIDATE, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ delete okey;
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
return result_code;
}
- key_nwm_t *key_nwm = reinterpret_cast<key_nwm_t*>(okey->get_key());
- uuu::upll_strncpy(reinterpret_cast<char*>(key_nwm->nwmonitor_name),
- reinterpret_cast<const char*>(flowfilter_val->nwm_name),
- kMaxLenNwmName +1);
- // result_code = nmgr->IsReferenced(okey, req->datatype, dmi); //TODO
+ GET_USER_DATA_CTRLR(okey, ctrlr_id);
+ uint8_t dbflag = 0;
+ GET_USER_DATA_FLAGS(okey, dbflag);
+ UPLL_LOG_DEBUG("CallingValidatecapanin VRTIF flowfilter ");
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char*>(ctrlr_id));
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Recored %d", result_code);
+ delete okey;
+ UPLL_LOG_DEBUG("Key/Attribute not supported by controller");
return result_code;
}
-#endif
+
+ if (UNC_VF_VALID == flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] ||
+ UNC_VF_VALID_NO_VALUE == flowfilter_val->
+ valid[UPLL_IDX_FLOWLIST_NAME_FFE]) {
+ if ((SET_FLAG_VLINK & dbflag)) {
+ val_flowfilter_entry_t *temp_ffe_val = reinterpret_cast
+ <val_flowfilter_entry_t *>(GetVal(okey));
+ UPLL_LOG_DEBUG("flowlist name %s", flowfilter_val->flowlist_name);
+ if (UNC_VF_VALID == flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_VFFE] &&
+ UNC_VF_VALID == temp_ffe_val->
+ valid[UPLL_IDX_FLOWLIST_NAME_VFFE]) {
+ result_code = flowlist_mgr->AddFlowListToController(
+ reinterpret_cast<char *>(temp_ffe_val->flowlist_name), dmi,
+ reinterpret_cast<char *>(ctrlr_id), req->datatype, UNC_OP_DELETE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("AddFlowListToController failed %d", result_code);
+ delete okey;
+ return result_code;
+ }
+ result_code = flowlist_mgr->AddFlowListToController(
+ reinterpret_cast<char *>(flowfilter_val->flowlist_name), dmi,
+ reinterpret_cast<char *>(ctrlr_id), req->datatype, UNC_OP_CREATE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("AddFlowListToController failed %d", result_code);
+ delete okey;
+ return result_code;
+ }
+ } else if (UNC_VF_VALID == flowfilter_val->
+ valid[UPLL_IDX_FLOWLIST_NAME_VFFE] &&
+ (UNC_VF_INVALID == temp_ffe_val->
+ valid[UPLL_IDX_FLOWLIST_NAME_VFFE] || UNC_VF_VALID_NO_VALUE ==
+ temp_ffe_val->valid[UPLL_IDX_FLOWLIST_NAME_VFFE])) {
+ result_code = flowlist_mgr->AddFlowListToController(
+ reinterpret_cast<char *>(flowfilter_val->flowlist_name), dmi,
+ reinterpret_cast<char *> (ctrlr_id), req->datatype, UNC_OP_CREATE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("AddFlowListToController failed %d", result_code);
+ delete okey;
+ return result_code;
+ }
+ } else if (UNC_VF_VALID_NO_VALUE == flowfilter_val->
+ valid[UPLL_IDX_FLOWLIST_NAME_VFFE] &&
+ UNC_VF_VALID == temp_ffe_val->
+ valid[UPLL_IDX_FLOWLIST_NAME_VFFE]) {
+ result_code = flowlist_mgr->AddFlowListToController(
+ reinterpret_cast<char *>(temp_ffe_val->flowlist_name), dmi,
+ reinterpret_cast<char *>(ctrlr_id), req->datatype, UNC_OP_DELETE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("AddFlowListToController failed %d", result_code);
+ delete okey;
+ return result_code;
+ }
+ }
+ }
+ }
+ DbSubOp dbop1 = {kOpNotRead, kOpMatchNone, kOpInOutFlag};
result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_UPDATE,
- dmi, MAINTBL);
+ dmi, &dbop1, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("UpdateConfigDB is Failed %d", result_code);
return result_code;
}
upll_rc_t VrtIfFlowFilterEntryMoMgr::GetRenamedControllerKey(
- ConfigKeyVal *&ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
+ ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
controller_domain *ctrlr_dom) {
UPLL_FUNC_TRACE
ConfigKeyVal *okey = NULL;
upll_rc_t result_code = UPLL_RC_SUCCESS;
// ConfigKeyVal *temp_key=ikey;
uint8_t rename = 0;
+
+ /* Get the controller's redirect node(vbridge/vrt) name -start*/
+ val_flowfilter_entry_t *val_flowfilter_entry =
+ reinterpret_cast<val_flowfilter_entry_t *> (GetVal(ikey));
+
+ if (val_flowfilter_entry) {
+ if ((UNC_VF_VALID ==
+ val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_NODE_FFE]) &&
+ (UNC_VF_VALID ==
+ val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_PORT_FFE])) {
+ unc_key_type_t child_key[]= { UNC_KT_VBRIDGE, UNC_KT_VROUTER };
+ bool isRedirectVnodeVbridge = false;
+ for (unsigned int i = 0;
+ i < sizeof(child_key)/sizeof(child_key[0]); i++) {
+ const unc_key_type_t ktype = child_key[i];
+ MoMgrImpl *mgrvbr = reinterpret_cast<MoMgrImpl *>(
+ const_cast<MoManager *>(GetMoManager(ktype)));
+ if (!mgrvbr) {
+ UPLL_LOG_DEBUG("mgrvbr failed");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ result_code = mgrvbr->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+ if (NULL != ctrlr_dom) {
+ SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+ // SET_USER_DATA_CTRLR(okey, ctrlr_dom->ctrlr);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+ if (okey->get_key_type() == UNC_KT_VBRIDGE) {
+ uuu::upll_strncpy(reinterpret_cast<key_vbr_t *>
+ (okey->get_key())->vbridge_name,
+ reinterpret_cast<val_flowfilter_entry_t *>(ikey->get_cfg_val()->
+ get_val())->redirect_node, (kMaxLenVnodeName + 1));
+
+ UPLL_LOG_DEBUG("redirect node vbr name (%s) (%s)",
+ reinterpret_cast<key_vbr_t *>(okey->get_key())->vbridge_name,
+ reinterpret_cast<val_flowfilter_entry_t *>(ikey->get_cfg_val()->
+ get_val())->redirect_node);
+ } else if (okey->get_key_type() == UNC_KT_VROUTER) {
+ uuu::upll_strncpy(reinterpret_cast<key_vrt_t *>
+ (okey->get_key())->vrouter_name,
+ reinterpret_cast<val_flowfilter_entry_t *>(ikey->get_cfg_val()->
+ get_val())->redirect_node, (kMaxLenVnodeName + 1));
+
+ UPLL_LOG_DEBUG("redirect node vrt name (%s) (%s)",
+ reinterpret_cast<key_vrt_t *>(okey->get_key())->vrouter_name,
+ reinterpret_cast<val_flowfilter_entry_t *>(ikey->get_cfg_val()->
+ get_val())->flowlist_name);
+ }
+
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr | kOpMatchDomain, kOpInOutFlag };
+ result_code = mgrvbr->ReadConfigDB(okey, dt_type, UNC_OP_READ,
+ dbop, dmi, RENAMETBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ }
+
+ if (result_code == UPLL_RC_SUCCESS) {
+ val_rename_vnode *rename_val = NULL;
+ isRedirectVnodeVbridge = true;
+ rename_val = reinterpret_cast<val_rename_vnode *> (GetVal(okey));
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("rename_val NULL.");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ uuu::upll_strncpy(reinterpret_cast<val_flowfilter_entry_t*>
+ (ikey->get_cfg_val()->get_val())->redirect_node,
+ rename_val->ctrlr_vnode_name, (kMaxLenVtnName + 1));
+ }
+ DELETE_IF_NOT_NULL(okey);
+ if (isRedirectVnodeVbridge)
+ break;
+ }
+ }
+ }
+ /* -end*/
+
IsRenamed(ikey, dt_type, dmi, rename);
- if (!rename) return UPLL_RC_SUCCESS;
+ if (!rename) {
+ UPLL_LOG_DEBUG("no rename");
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_TRACE("%s GetRenamedCtrl vrt_if_ff_entry start",
+ ikey->ToStrAll().c_str());
+
+ if ((rename & VTN_RENAME_FLAG) || (rename & VRT_RENAME_FLAG)) {
+ MoMgrImpl *VrtMoMgr = static_cast<MoMgrImpl*>
+ ((const_cast<MoManager*> (GetMoManager(UNC_KT_VROUTER))));
+ if (VrtMoMgr == NULL) {
+ UPLL_LOG_DEBUG("InValid Reference of VRTIF");
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ result_code = VrtMoMgr->GetChildConfigKey(okey, NULL);
+ if ( result_code != UPLL_RC_SUCCESS ) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (ctrlr_dom)
+ SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
+
+ strncpy(reinterpret_cast<char *>
+ (reinterpret_cast<key_vrt *>(okey->get_key())->vtn_key.vtn_name),
+ reinterpret_cast<const char *>
+ (reinterpret_cast<key_vrt_if_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.if_key.vrt_key.vtn_key.vtn_name),
+ kMaxLenVtnName + 1);
+ UPLL_LOG_DEBUG("vrt name (%s) (%s)",
+ reinterpret_cast<char *>
+ (reinterpret_cast<key_vrt *>(okey->get_key())->vtn_key.vtn_name),
+ reinterpret_cast<const char *>
+ (reinterpret_cast<key_vrt_if_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.if_key.vrt_key.vtn_key.vtn_name));
+ strncpy(reinterpret_cast<char *>
+ (reinterpret_cast<key_vrt *>(okey->get_key())->vrouter_name),
+ reinterpret_cast<const char *>
+ (reinterpret_cast<key_vrt_if_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.if_key.vrt_key.vrouter_name),
+ kMaxLenVtnName + 1);
+ UPLL_LOG_DEBUG("vrt name (%s) (%s)",
+ reinterpret_cast<char *>
+ (reinterpret_cast<key_vrt *>(okey->get_key())->vrouter_name),
+ reinterpret_cast<const char *>
+ (reinterpret_cast<key_vrt_if_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.if_key.vrt_key.vrouter_name));
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr | kOpMatchDomain, kOpInOutFlag };
+ /* ctrlr_name */
+ result_code = VrtMoMgr->ReadConfigDB(okey, dt_type, UNC_OP_READ,
+ dbop, dmi, RENAMETBL);
+ if ( result_code != UPLL_RC_SUCCESS ) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB no instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ // NULL Checks Missing
+ val_rename_vnode *rename_val =
+ reinterpret_cast <val_rename_vnode *> (GetVal(okey));
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("VRT Name is not Valid.");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ if (rename & VTN_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("vtn renamed");
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vrt_if_flowfilter_entry_t*>
+ (ikey->get_key())->flowfilter_key.if_key.vrt_key.vtn_key.vtn_name,
+ rename_val->ctrlr_vtn_name,
+ (kMaxLenVtnName + 1));
+ UPLL_LOG_DEBUG("vtn rename (%s) (%s)",
+ reinterpret_cast<key_vrt_if_flowfilter_entry_t*>
+ (ikey->get_key())->flowfilter_key.if_key.vrt_key.vtn_key.vtn_name,
+ rename_val->ctrlr_vtn_name);
+ }
+
+ if (rename & VRT_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("vrt renamed");
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vrt_if_flowfilter_entry_t*>
+ (ikey->get_key())->flowfilter_key.if_key.vrt_key.vrouter_name,
+ rename_val->ctrlr_vnode_name,
+ (kMaxLenVnodeName + 1));
+ UPLL_LOG_DEBUG("vrt rename (%s) (%s)",
+ reinterpret_cast<key_vrt_if_flowfilter_entry_t*>
+ (ikey->get_key())->flowfilter_key.if_key.vrt_key.vrouter_name,
+ rename_val->ctrlr_vnode_name);
+ }
+
+ DELETE_IF_NOT_NULL(okey);
+ }
+ // flowlist_name
+ if (rename & FLOWLIST_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("flowlist name renamed");
+ MoMgrImpl *mgrflist = static_cast<MoMgrImpl*>
+ ((const_cast<MoManager*> (GetMoManager(UNC_KT_FLOWLIST))));
+ result_code = mgrflist->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+ if (NULL != ctrlr_dom) {
+ SET_USER_DATA_CTRLR(okey, ctrlr_dom->ctrlr);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+ if (!GetVal(ikey))
+ return UPLL_RC_SUCCESS;
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
+ /* ctrlr_name */
+ result_code = mgrflist->ReadConfigDB(okey, dt_type,
+ UNC_OP_READ, dbop, dmi, RENAMETBL);
+ if ( result_code != UPLL_RC_SUCCESS ) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB no instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val_rename_flowlist_t *rename_val =
+ reinterpret_cast <val_rename_flowlist_t*>(GetVal(okey));
+
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("flowlist is not valid");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(
+ reinterpret_cast<val_flowfilter_entry_t*>
+ (ikey->get_cfg_val()->get_val())->flowlist_name,
+ rename_val->flowlist_newname,
+ (kMaxLenFlowListName + 1));
+ DELETE_IF_NOT_NULL(okey);
+ }
+ UPLL_LOG_TRACE("%s GetRenamedCtrl vrt_if_ff_entry end",
+ ikey->ToStrAll().c_str());
+ UPLL_LOG_DEBUG("Renamed Controller key is sucessfull.");
+ return UPLL_RC_SUCCESS;
+#if 0
/* vtn renamed */
if (rename & VTN_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("vtn renamed");
MoMgrImpl *mgrvtn = static_cast<MoMgrImpl*>
((const_cast<MoManager*> (GetMoManager(UNC_KT_VTN))));
mgrvtn->GetChildConfigKey(okey, NULL);
- if (ctrlr_dom != NULL)
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+
+ if (ctrlr_dom != NULL) {
SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
uuu::upll_strncpy(
reinterpret_cast<key_vtn *>(okey->get_key())->vtn_name,
reinterpret_cast<key_vrt_if_flowfilter_entry_t *>
(ikey->get_key())->flowfilter_key.if_key.vrt_key.vtn_key.vtn_name,
(kMaxLenVtnName + 1));
+ UPLL_LOG_DEBUG("vtn name (%s) (%s)",
+ reinterpret_cast<key_vtn *>(okey->get_key())->vtn_name,
+ reinterpret_cast<key_vrt_if_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.if_key.vrt_key.vtn_key.vtn_name);
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
/* ctrlr_name */
result_code = mgrvtn->ReadConfigDB(okey, dt_type, UNC_OP_READ,
dbop, dmi, RENAMETBL);
if ( result_code != UPLL_RC_SUCCESS ) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
val_rename_vtn *rename_val = reinterpret_cast <val_rename_vtn *>
(GetVal(okey)); // NULL Checks Missing
- if (!rename_val
- || (rename_val->valid[UPLL_IDX_NEW_NAME_RVTN] != UNC_VF_VALID)) {
+ if (!rename_val) {
UPLL_LOG_DEBUG("Vtn Name is not Valid.");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
uuu::upll_strncpy(
(ikey->get_key())->flowfilter_key.if_key.vrt_key.vtn_key.vtn_name,
rename_val->new_name,
(kMaxLenVtnName + 1));
+ UPLL_LOG_DEBUG("vtn rename (%s) (%s)",
+ reinterpret_cast<key_vrt_if_flowfilter_entry_t*>
+ (ikey->get_key())->flowfilter_key.if_key.vrt_key.vtn_key.vtn_name,
+ rename_val->new_name);
SET_USER_DATA_FLAGS(ikey, rename);
- delete okey;
+ DELETE_IF_NOT_NULL(okey);
}
/*Vrouter_name*/
if (rename & VRT_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("vrt renamed");
okey = NULL;
MoMgrImpl *VrtMoMgr = static_cast<MoMgrImpl*>
((const_cast<MoManager*> (GetMoManager(UNC_KT_VROUTER))));
UPLL_LOG_DEBUG("InValid Reference of VRTIF");
return UPLL_RC_ERR_BAD_REQUEST;
}
- result_code = VrtMoMgr->GetChildConfigKey(okey, ikey);
- if ( result_code != UPLL_RC_SUCCESS ) { // COV USE AFTER FREE
- // delete okey;
+ result_code = VrtMoMgr->GetChildConfigKey(okey, NULL);
+ if ( result_code != UPLL_RC_SUCCESS ) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
return UPLL_RC_ERR_GENERIC;
}
if (ctrlr_dom)
SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
+
+ strncpy(reinterpret_cast<char *>
+ (reinterpret_cast<key_vrt *>(okey->get_key())->vtn_key.vtn_name),
+ reinterpret_cast<const char *>
+ (reinterpret_cast<key_vrt_if_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.if_key.vrt_key.vtn_key.vtn_name),
+ kMaxLenVtnName + 1);
+ UPLL_LOG_DEBUG("vrt name (%s) (%s)",
+ reinterpret_cast<char *>
+ (reinterpret_cast<key_vrt *>(okey->get_key())->vrouter_name),
+ reinterpret_cast<const char *>
+ (reinterpret_cast<key_vrt_if_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.if_key.vrt_key.vrouter_name));
+ strncpy(reinterpret_cast<char *>
+ (reinterpret_cast<key_vrt *>(okey->get_key())->vrouter_name),
+ reinterpret_cast<const char *>
+ (reinterpret_cast<key_vrt_if_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.if_key.vrt_key.vrouter_name),
+ kMaxLenVtnName + 1);
+ UPLL_LOG_DEBUG("vrt name (%s) (%s)",
+ reinterpret_cast<char *>
+ (reinterpret_cast<key_vrt *>(okey->get_key())->vrouter_name),
+ reinterpret_cast<const char *>
+ (reinterpret_cast<key_vrt_if_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.if_key.vrt_key.vrouter_name));
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
/* ctrlr_name */
result_code = VrtMoMgr->ReadConfigDB(okey, dt_type, UNC_OP_READ,
dbop, dmi, RENAMETBL);
if ( result_code != UPLL_RC_SUCCESS ) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
// NULL Checks Missing
- val_rename_vrt_t *rename_val =
- reinterpret_cast <val_rename_vrt_t *> (GetVal(okey));
- if (!rename_val
- || (rename_val->valid[UPLL_IDX_NEW_NAME_RVTN] != UNC_VF_VALID)) {
+ val_rename_vnode *rename_val =
+ reinterpret_cast <val_rename_vnode *> (GetVal(okey));
+ if (!rename_val) {
UPLL_LOG_DEBUG("VRT Name is not Valid.");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
uuu::upll_strncpy(
reinterpret_cast<key_vrt_if_flowfilter_entry_t*>
(ikey->get_key())->flowfilter_key.if_key.vrt_key.vrouter_name,
- rename_val->new_name,
+ rename_val->ctrlr_vnode_name,
(kMaxLenVnodeName + 1));
- SET_USER_DATA_FLAGS(ikey, rename);
- delete okey;
+ UPLL_LOG_DEBUG("vrt rename (%s) (%s)",
+ reinterpret_cast<key_vrt_if_flowfilter_entry_t*>
+ (ikey->get_key())->flowfilter_key.if_key.vrt_key.vrouter_name,
+ rename_val->ctrlr_vnode_name);
+ DELETE_IF_NOT_NULL(okey);
}
// flowlist_name
if (rename & FLOWLIST_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("flowlist name renamed");
MoMgrImpl *mgrflist = static_cast<MoMgrImpl*>
((const_cast<MoManager*> (GetMoManager(UNC_KT_FLOWLIST))));
- mgrflist->GetChildConfigKey(okey, NULL);
- if (ctrlr_dom)
+ result_code = mgrflist->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+ if (NULL != ctrlr_dom) {
SET_USER_DATA_CTRLR(okey, ctrlr_dom->ctrlr);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
/* ctrlr_name */
result_code = mgrflist->ReadConfigDB(okey, dt_type,
UNC_OP_READ, dbop, dmi, RENAMETBL);
if ( result_code != UPLL_RC_SUCCESS ) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
val_rename_flowlist_t *rename_val =
reinterpret_cast <val_rename_flowlist_t*>(GetVal(okey));
- if (!rename_val
- || (rename_val->valid[UPLL_IDX_NEW_NAME_RVTN] != UNC_VF_VALID))
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("flowlist is not valid");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(
reinterpret_cast<val_flowfilter_entry_t*>
(ikey->get_cfg_val()->get_val())->flowlist_name,
rename_val->flowlist_newname,
(kMaxLenFlowListName + 1));
- SET_USER_DATA_FLAGS(ikey, rename);
- delete okey;
+ DELETE_IF_NOT_NULL(okey);
}
+ UPLL_LOG_TRACE("%s GetRenamedCtrl vrt_if_ff_entry end",
+ ikey->ToStrAll().c_str());
UPLL_LOG_DEBUG("Renamed Controller key is sucessfull.");
return UPLL_RC_SUCCESS;
+#endif
}
upll_rc_t VrtIfFlowFilterEntryMoMgr::GetRenamedUncKey(
ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
uint8_t *ctrlr_id) {
UPLL_FUNC_TRACE;
-
- if (ctrlr_id == NULL) {
- UPLL_LOG_DEBUG("ctrlr_id is NULL");
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vrtifff_entry start",
+ ikey->ToStrAll().c_str());
+ if ((NULL == ikey) || (ctrlr_id == NULL) || (NULL == dmi)) {
+ UPLL_LOG_DEBUG("ikey/ctrlr_id dmi NULL");
return UPLL_RC_ERR_GENERIC;
}
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
MoMgrImpl *VrtIfMoMgr = static_cast<MoMgrImpl*>
((const_cast<MoManager*> (GetMoManager(UNC_KT_VROUTER))));
+ if (VrtIfMoMgr == NULL) {
+ UPLL_LOG_DEBUG("VrtMoMgr NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
val_rename_vnode *rename_val = reinterpret_cast<val_rename_vnode*>
(ConfigKeyVal::Malloc(sizeof(val_rename_vnode)));
-
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("VrtMoMgr NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
key_vrt_if_flowfilter_entry_t *ctrlr_key = reinterpret_cast
<key_vrt_if_flowfilter_entry_t *> (ikey->get_key());
-
- if (NULL == ctrlr_key) {
- UPLL_LOG_DEBUG(" ctrlr_key is NULL");
+ if (!ctrlr_key) {
+ UPLL_LOG_DEBUG("ctrlr_key NULL");
free(rename_val);
return UPLL_RC_ERR_GENERIC;
}
-
uuu::upll_strncpy(
rename_val->ctrlr_vtn_name,
ctrlr_key->flowfilter_key.if_key.vrt_key.vtn_key.vtn_name,
(kMaxLenVtnName + 1));
- // rename_val->valid[0] = UNC_VF_VALID; // TODO(UNC):for vrouter_name
+ rename_val->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
+
uuu::upll_strncpy(rename_val->ctrlr_vnode_name,
ctrlr_key->flowfilter_key.if_key.vrt_key.vrouter_name,
(kMaxLenVnodeName + 1));
- // rename_flowlist->valid[0] = UNC_VF_VALID;
- VrtIfMoMgr->GetChildConfigKey(unc_key, NULL);
+ rename_val->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_VALID;
+
+ result_code = VrtIfMoMgr->GetChildConfigKey(unc_key, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG(" Failed to get ChildConfigkey structure");
+ free(rename_val);
+ VrtIfMoMgr = NULL;
+ return result_code;
+ }
if (NULL == unc_key) {
UPLL_LOG_DEBUG(" unc_key is NULL");
free(rename_val);
+ VrtIfMoMgr = NULL;
return UPLL_RC_ERR_GENERIC;
}
- unc_key->set_user_data(ctrlr_id);
+ SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
unc_key->AppendCfgVal(IpctSt::kIpcStValRenameVtn, rename_val);
- upll_rc_t result_code = VrtIfMoMgr->ReadConfigDB(unc_key, dt_type,
+ result_code = VrtIfMoMgr->ReadConfigDB(unc_key, dt_type,
UNC_OP_READ, dbop, dmi, RENAMETBL);
if (result_code == UPLL_RC_SUCCESS) {
key_vrt_if_flowfilter_entry_t *key_vrt_if_flowfilter_entry =reinterpret_cast
ctrlr_key->flowfilter_key.if_key.vrt_key.vrouter_name,
key_vrt_if_flowfilter_entry->flowfilter_key.if_key.vrt_key.vrouter_name,
(kMaxLenVnodeName + 1));
+ } else if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB err");
+ DELETE_IF_NOT_NULL(unc_key);
+ VrtIfMoMgr = NULL;
+ return result_code;
+ }
+ VrtIfMoMgr = NULL;
+ DELETE_IF_NOT_NULL(unc_key);
+
+ val_flowfilter_entry_t *val_flowfilter_entry = NULL;
+ pfcdrv_val_flowfilter_entry_t *pfc_val_import = NULL;
+ if (ikey->get_cfg_val() &&
+ (ikey->get_cfg_val()->get_st_num() ==
+ IpctSt::kIpcStPfcdrvValFlowfilterEntry)) {
+ UPLL_LOG_DEBUG("val struct num (%d)", ikey->get_cfg_val()->get_st_num());
+ pfc_val_import = reinterpret_cast<pfcdrv_val_flowfilter_entry_t *>
+ (ikey->get_cfg_val()->get_val());
+ val_flowfilter_entry = &pfc_val_import->val_ff_entry;
+ UPLL_LOG_DEBUG("FLOWLIST name (%s)", val_flowfilter_entry->flowlist_name);
+ } else if (ikey->get_cfg_val() &&
+ (ikey->get_cfg_val()->get_st_num() ==
+ IpctSt::kIpcStValFlowfilterEntry)) {
+ val_flowfilter_entry = reinterpret_cast
+ <val_flowfilter_entry_t *>(GetVal(ikey));
+ }
+
+ if (!val_flowfilter_entry) {
+ UPLL_LOG_DEBUG("val_flowfilter_entry NULL");
+ return UPLL_RC_SUCCESS;
+ }
+
+ if (UNC_VF_VALID == val_flowfilter_entry
+ ->valid[UPLL_IDX_FLOWLIST_NAME_FFE]) {
+ val_rename_flowlist_t *rename_flowlist =
+ reinterpret_cast<val_rename_flowlist_t*>
+ (ConfigKeyVal::Malloc(sizeof(val_rename_flowlist_t)));
+ if (!rename_flowlist) {
+ UPLL_LOG_DEBUG("rename_flowlist NULL");
+ free(rename_flowlist);
+ return UPLL_RC_ERR_GENERIC;
}
- delete unc_key;
- unc_key = NULL;
- val_rename_flowlist_t *rename_flowlist =
- reinterpret_cast<val_rename_flowlist_t*>
- (ConfigKeyVal::Malloc(sizeof(val_rename_flowlist_t)));
- val_flowfilter_entry_t *val_flowfilter_entry = reinterpret_cast
- <val_flowfilter_entry_t *> (GetVal(ikey));
uuu::upll_strncpy(rename_flowlist->flowlist_newname,
val_flowfilter_entry->flowlist_name,
(kMaxLenFlowListName + 1));
+ rename_flowlist->valid[UPLL_IDX_RENAME_FLOWLIST_RFL] = UNC_VF_VALID;
MoMgrImpl* mgr =static_cast<MoMgrImpl*>
((const_cast<MoManager*> (GetMoManager(UNC_KT_FLOWLIST))));
- result_code = mgr->GetChildConfigKey(unc_key, NULL);
+ if (!mgr) {
+ UPLL_LOG_DEBUG("mgr failed");
+ if (rename_flowlist) free(rename_flowlist);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = mgr->GetChildConfigKey(unc_key, NULL);
if (UPLL_RC_SUCCESS != result_code) {
- free(rename_val);
- free(rename_flowlist); // RESOURCE LEAK FIX
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ free(rename_flowlist);
+ mgr = NULL;
+ return result_code;
+ }
+ if (!unc_key) {
+ UPLL_LOG_DEBUG("unc_key NULL");
+ free(rename_flowlist);
+ mgr = NULL;
return result_code;
}
-
SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
unc_key->AppendCfgVal(IpctSt::kIpcStValRenameFlowlist, rename_flowlist);
result_code = mgr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL);
-
if (result_code == UPLL_RC_SUCCESS) {
- val_flowfilter_entry_t *temp_val_flowfilter_entry = reinterpret_cast
- <val_flowfilter_entry_t *>(unc_key->get_cfg_val()->get_val());
-
+ key_flowlist_t *key_flowlist = reinterpret_cast <key_flowlist_t *>
+ (unc_key->get_key());
uuu::upll_strncpy(val_flowfilter_entry->flowlist_name,
- temp_val_flowfilter_entry->flowlist_name,
- (kMaxLenFlowListName + 1));
+ key_flowlist->flowlist_name,
+ (kMaxLenFlowListName + 1));
+ } else if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB err");
+ DELETE_IF_NOT_NULL(unc_key);
+ mgr = NULL;
+ return result_code;
}
UPLL_LOG_DEBUG("Key is filled with UncKey Successfully %d", result_code);
- free(rename_val);
- delete unc_key;
+ DELETE_IF_NOT_NULL(unc_key);
+ mgr = NULL;
+ }
+
+ if ((UNC_VF_VALID ==
+ val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_NODE_FFE]) &&
+ (UNC_VF_VALID ==
+ val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_PORT_FFE])) {
+ unc_key_type_t child_key[]= { UNC_KT_VBRIDGE, UNC_KT_VROUTER };
+ bool isRedirectVnodeVbridge = false;
+ for (unsigned int i = 0;
+ i < sizeof(child_key)/sizeof(child_key[0]); i++) {
+ const unc_key_type_t ktype = child_key[i];
+ MoMgrImpl *mgrvbr = reinterpret_cast<MoMgrImpl *>(
+ const_cast<MoManager *>(GetMoManager(ktype)));
+ if (!mgrvbr) {
+ UPLL_LOG_TRACE("mgrvbr failed");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val_rename_vnode *rename_val = reinterpret_cast<val_rename_vnode*>
+ (ConfigKeyVal::Malloc(sizeof(val_rename_vnode)));
+ if (!rename_val) {
+ UPLL_LOG_TRACE("rename_val NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ uuu::upll_strncpy(rename_val->ctrlr_vnode_name,
+ val_flowfilter_entry->redirect_node,
+ (kMaxLenVnodeName + 1));
+ rename_val->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_VALID;
+
+ result_code = mgrvbr->GetChildConfigKey(unc_key, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Returned an error");
+ if (rename_val) free(rename_val);
+ mgrvbr = NULL;
+ return result_code;
+ }
+ SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
+ unc_key->AppendCfgVal(IpctSt::kIpcStValRenameVtn, rename_val);
+ result_code = mgrvbr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
+ RENAMETBL);
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(unc_key);
+ mgrvbr = NULL;
+ return result_code;
+ }
+
+ if (result_code == UPLL_RC_SUCCESS) {
+ if (unc_key->get_key_type() == UNC_KT_VBRIDGE) {
+ isRedirectVnodeVbridge = true;
+ key_vbr *vbr_key = reinterpret_cast<key_vbr *>(unc_key->get_key());
+ uuu::upll_strncpy(val_flowfilter_entry->redirect_node,
+ vbr_key->vbridge_name,
+ (kMaxLenVnodeName + 1));
+ } else if (unc_key->get_key_type() == UNC_KT_VROUTER) {
+ key_vrt *vrt_key = reinterpret_cast<key_vrt *>(unc_key->get_key());
+ uuu::upll_strncpy(val_flowfilter_entry->redirect_node,
+ vrt_key->vrouter_name,
+ (kMaxLenVnodeName + 1));
+ }
+ }
+ DELETE_IF_NOT_NULL(unc_key);
+ mgrvbr = NULL;
+ if (isRedirectVnodeVbridge) {
+ UPLL_LOG_DEBUG("RedirectVnode is Vbridge");
+ break;
+ }
+ }
+ }
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code)
+ result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vbrifff_entry end",
+ ikey->ToStrAll().c_str());
return result_code;
}
if (parent_key == NULL) {
vrt_if_ffe_key = reinterpret_cast<key_vrt_if_flowfilter_entry_t*>
(ConfigKeyVal::Malloc(sizeof(key_vrt_if_flowfilter_entry_t)));
+ // If no direction is specified , 0xFE is filled to bind output direction
+ vrt_if_ffe_key->flowfilter_key.direction = 0xFE;
okey = new ConfigKeyVal(UNC_KT_VRTIF_FLOWFILTER_ENTRY,
IpctSt::kIpcStKeyVrtIfFlowfilterEntry,
vrt_if_ffe_key, NULL);
if (okey) {
if (okey->get_key_type() != UNC_KT_VRTIF_FLOWFILTER_ENTRY)
return UPLL_RC_ERR_GENERIC;
+ }
+
+ if ((okey) && (okey->get_key())) {
vrt_if_ffe_key = reinterpret_cast<key_vrt_if_flowfilter_entry_t *>
(okey->get_key());
} else {
vrt_if_ffe_key = reinterpret_cast<key_vrt_if_flowfilter_entry_t *>
(ConfigKeyVal::Malloc(sizeof(key_vrt_if_flowfilter_entry_t)));
+ // If no direction is specified , 0xFE is filled to bind output direction
+ vrt_if_ffe_key->flowfilter_key.direction = 0xFE;
}
switch (parent_key->get_key_type()) {
case UNC_KT_VTN:
reinterpret_cast<key_vrt_if_flowfilter_entry_t *>
(pkey)->sequence_num;
break;
+ case UNC_KT_VBR_NWMONITOR:
+ uuu::upll_strncpy(
+ vrt_if_ffe_key->flowfilter_key.if_key.vrt_key.vtn_key.vtn_name,
+ reinterpret_cast<key_vrt_if_flowfilter_entry_t *>
+ (pkey)->flowfilter_key.if_key.vrt_key.vtn_key.vtn_name,
+ kMaxLenVtnName + 1);
+ break;
default:
if (vrt_if_ffe_key) free(vrt_if_ffe_key);
return UPLL_RC_ERR_GENERIC;
}
+
+ if ((okey) && !(okey->get_key())) {
+ UPLL_LOG_DEBUG("okey not null and flow list name updated");
+ okey->SetKey(IpctSt::kIpcStKeyVrtIfFlowfilterEntry, vrt_if_ffe_key);
+ }
+
if (!okey) {
okey = new ConfigKeyVal(UNC_KT_VRTIF_FLOWFILTER_ENTRY,
IpctSt::kIpcStKeyVrtIfFlowfilterEntry,
}
upll_rc_t VrtIfFlowFilterEntryMoMgr::MergeValidate(unc_key_type_t keytype,
- const char *ctrlr_id,
- ConfigKeyVal *ikey,
- DalDmlIntf *dmi) {
+ const char *ctrlr_id,
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
-
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
- ConfigKeyVal *tkey;
- ConfigKeyVal *keyval = NULL;
-
- if (NULL == ikey) {
- UPLL_LOG_DEBUG("GetChildConfigKey::ikey is Null");
- return UPLL_RC_ERR_BAD_REQUEST;
+ ConfigKeyVal *ckval = NULL;
+ if (NULL == ctrlr_id) {
+ UPLL_LOG_DEBUG("ctrlr_id NULL");
+ return result_code;
}
- result_code = ReadConfigDB(ikey, UPLL_DT_IMPORT, UNC_OP_READ, dbop, dmi,
- MAINTBL);
+ result_code = GetChildConfigKey(ckval, NULL);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("ReadConfigDB is not Success");
+ UPLL_LOG_DEBUG("ckval fail");
return result_code;
}
- MoMgrImpl *mgr = static_cast<MoMgrImpl*>
- ((const_cast<MoManager*> (GetMoManager(UNC_KT_FLOWLIST))));
-
- tkey = ikey;
- while (ikey != NULL) {
- result_code = mgr->GetChildConfigKey(keyval, NULL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetChildConfigKey is not Success");
- return result_code;
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone};
+ result_code = ReadConfigDB(ckval, UPLL_DT_IMPORT,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ckval);
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ return result_code;
+ }
+ return UPLL_RC_SUCCESS;
}
- val_flowfilter_entry_t *flowfilter_val = reinterpret_cast
- <val_flowfilter_entry_t *>((GetVal(ikey)));
- key_flowlist_t *key_flowlist = reinterpret_cast <key_flowlist_t *>
- (keyval->get_key());
-
- uuu::upll_strncpy(key_flowlist->flowlist_name,
- flowfilter_val->flowlist_name,
- (kMaxLenFlowListName + 1));
-
- result_code = mgr->UpdateConfigDB(keyval, UPLL_DT_CANDIDATE, UNC_OP_READ, dmi,
- MAINTBL);
- if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
- return UPLL_RC_ERR_MERGE_CONFLICT;
+ while (NULL != ckval) {
+ val_flowfilter_entry_t* val = reinterpret_cast<val_flowfilter_entry_t *>
+ (GetVal(ckval));
+ if (val->valid[UPLL_IDX_REDIRECT_NODE_FFE] ==
+ UNC_VF_VALID) {
+ if (val->valid[UPLL_IDX_REDIRECT_PORT_FFE] ==
+ UNC_VF_VALID) {
+ result_code = VerifyRedirectDestination(ckval, dmi, UPLL_DT_IMPORT);
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(ckval);
+ UPLL_LOG_DEBUG("redirect-destination node/interface doesn't exists");
+ return UPLL_RC_ERR_MERGE_CONFLICT;
+ }
+ }
+ }
+ ckval = ckval->get_next_cfg_key_val();
}
- ikey = tkey->get_next_cfg_key_val();
+
+ DELETE_IF_NOT_NULL(ckval);
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_VRTIF_FLOWFILTER)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Invalid mgr param");
+ return UPLL_RC_ERR_GENERIC;
}
- if (tkey)
- delete tkey;
- UPLL_LOG_DEBUG("MergeValidate is Success.");
+ result_code = mgr->MergeValidate(keytype, ctrlr_id, ikey, dmi);
+ UPLL_LOG_DEBUG("MergeValidate result code (%d)", result_code);
return result_code;
}
result_code = DupConfigKeyVal(l_key, ikey, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("DupConfigKeyVal Faill in ReadMo for l_key");
+ delete dup_key;
return result_code;
}
GET_USER_DATA_CTRLR_DOMAIN(dup_key, ctrlr_dom);
SET_USER_DATA_CTRLR_DOMAIN(l_key, ctrlr_dom);
- // 1.Getting renamed name if renamed
+
+ //Added CapaCheck
+ UPLL_LOG_DEBUG("Calling ValidateCapability From ReadMo ");
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(ctrlr_dom.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("validate Capability Failed %d", result_code);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ return result_code;
+ }
+
+ // 1.Getting renamed name if renamed
result_code = GetRenamedControllerKey(l_key, req->datatype,
dmi, &ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
return result_code;
}
GET_USER_DATA_FLAGS(dup_key, vlink_flag);
if (!(SET_FLAG_VLINK & vlink_flag)) {
UPLL_LOG_DEBUG("Vlink Not Configured");
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
return UPLL_RC_ERR_NOT_ALLOWED_AT_THIS_TIME;
}
UPLL_LOG_DEBUG("SendReqToDriver failed for Key %d controller %s",
l_key->get_key_type(),
reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ DELETE_IF_NOT_NULL(ipc_req.ckv_data);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(dup_key);
return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_DEBUG("Driver response for Key %d controller %s result %d",
l_key->get_key_type(), ctrlr_dom.ctrlr,
ipc_resp.header.result_code);
+ DELETE_IF_NOT_NULL(ipc_req.ckv_data);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(dup_key);
return ipc_resp.header.result_code;
}
ConfigKeyVal *okey = NULL;
result_code = ConstructReadDetailResponse(dup_key,
ipc_resp.ckv_data,
- dmi, &okey);
+ &okey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ConstructReadDetailResponse error code (%d)",
result_code);
+ DELETE_IF_NOT_NULL(ipc_req.ckv_data);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
} else {
if (okey != NULL) {
ikey->ResetWith(okey);
+ DELETE_IF_NOT_NULL(okey);
}
}
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
DELETE_IF_NOT_NULL(dup_key);
DELETE_IF_NOT_NULL(l_key);
}
break;
default:
+ UPLL_LOG_DEBUG("Operation Not Allowed");
result_code = UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
return result_code;
}
GET_USER_DATA_CTRLR_DOMAIN(dup_key, ctrlr_dom);
SET_USER_DATA_CTRLR_DOMAIN(l_key, ctrlr_dom);
- // 1.Getting renamed name if renamed
+ //Added CapaCheck
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(ctrlr_dom.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("validate Capability Failed %d", result_code);
+ return result_code;
+ }
+
+ // 1.Getting renamed name if renamed
result_code = GetRenamedControllerKey(l_key, req->datatype,
dmi, &ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
result_code = ConstructReadDetailResponse(tmp_key,
ipc_resp.ckv_data,
- dmi, &okey);
+ &okey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ConstructReadDetailResponse error code (%d)",
result_code);
return result_code;
}
+#if 0
upll_rc_t VrtIfFlowFilterEntryMoMgr::UpdateConfigStatus(
ConfigKeyVal *key, unc_keytype_operation_t op, uint32_t driver_result,
ConfigKeyVal *upd_key, DalDmlIntf *dmi, ConfigKeyVal *ctrlr_key) {
} else if (op == UNC_OP_UPDATE) {
void *fle_val1 = GetVal(key);
void *fle_val2 = GetVal(upd_key);
- CompareValidValue(fle_val1, fle_val2, false);
+ CompareValidValue(fle_val1, fle_val2, true);
for (unsigned int loop = 0;
loop < sizeof(vrtif_ff_entry_val->valid)/
sizeof(vrtif_ff_entry_val->valid[0]); ++loop) {
UPLL_LOG_DEBUG("UpdateConfigStatus Success");
return result_code;
}
+#endif
bool VrtIfFlowFilterEntryMoMgr::IsValidKey(void *key,
uint64_t index) {
UPLL_FUNC_TRACE;
- bool ret_val = UPLL_RC_SUCCESS;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
key_vrt_if_flowfilter_entry_t *ff_key =
reinterpret_cast<key_vrt_if_flowfilter_entry_t *>(key);
if (ff_key == NULL)
delete okey;
okey = NULL;
}
-
if (val_flowfilter_entry->valid[UPLL_IDX_NWM_NAME_FFE]
== UNC_VF_VALID) {
// validate nwm_name in KT_VBR_NWMONITOR table
delete okey;
okey = NULL;
} // nwm_name is valid
-
+ result_code = SetRenameFlag(ikey, dmi, req);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("SetRenameFlag failed %d", result_code);
+ return result_code;
+ }
UPLL_LOG_DEBUG("ValidateAttribute Successfull.");
return result_code;
}
UPLL_LOG_DEBUG(" Error: option1 is not NORMAL for ReadSiblingCount");
return UPLL_RC_ERR_INVALID_OPTION1;
}
+ if ((req->option1 == UNC_OPT1_DETAIL) &&
+ (req->datatype != UPLL_DT_STATE)) {
+ UPLL_LOG_DEBUG(" Invalid Datatype(%d)", req->datatype);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+ if ((req->datatype == UPLL_DT_IMPORT) && (req->operation == UNC_OP_READ ||
+ req->operation == UNC_OP_READ_SIBLING ||
+ req->operation == UNC_OP_READ_SIBLING_BEGIN ||
+ req->operation == UNC_OP_READ_NEXT ||
+ req->operation == UNC_OP_READ_BULK ||
+ req->operation == UNC_OP_READ_SIBLING_COUNT)) {
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+
/** Read key structure */
key_vrt_if_flowfilter_entry_t *key_vrt_if_flowfilter_entry =
upll_rc_t rt_code = UPLL_RC_ERR_GENERIC;
- /** Use VbrFlowfilterEntryMoMgr::ValidateCapability
- * to validate capability for val_flowfilter_entry structure*/
- VbrFlowFilterEntryMoMgr *mgrvbrff =
- reinterpret_cast<VbrFlowFilterEntryMoMgr *>(
- const_cast<MoManager *>(GetMoManager(UNC_KT_VBR_FLOWFILTER_ENTRY)));
- rt_code = mgrvbrff->ValidateCapability(req, ikey);
+ if ((NULL == req) || (NULL == ikey)) {
+ UPLL_LOG_DEBUG("IpcReqRespHeader/ConfigKeyval is NULL");
+ return rt_code;
+ }
+
+ if (!ctrlr_name)
+ ctrlr_name = static_cast<char *>(ikey->get_user_data());
+
+ UPLL_LOG_TRACE("dt_type : (%d)"
+ "operation : (%d)", req->datatype, req->operation);
+
+ bool ret_code = false;
+ uint32_t instance_count = 0;
+ const uint8_t *attrs = NULL;
+ uint32_t max_attrs = 0;
+
+ switch (req->operation) {
+ case UNC_OP_CREATE: {
+ UPLL_LOG_TRACE("Calling GetCreateCapability Operation %d ", req->operation);
+ ret_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
+ &instance_count, &max_attrs, &attrs);
+ if (ret_code && cur_instance_count >= instance_count &&
+ cur_instance_count !=0 && instance_count != 0) {
+ UPLL_LOG_DEBUG("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
+ __LINE__, __FUNCTION__, cur_instance_count,
+ instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
- if (UPLL_RC_SUCCESS != rt_code) {
- UPLL_LOG_DEBUG(" VRTIF_FLOWFILTER_ENTRY Attribute validation failed :"
- "Err Code - %d",
- rt_code);
+
+ break;
+ }
+ case UNC_OP_UPDATE: {
+ UPLL_LOG_TRACE("Calling GetUpdateCapability Operation %d ", req->operation);
+ ret_code = GetUpdateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ break;
+ }
+ default: {
+ if (req->datatype == UPLL_DT_STATE) {
+ UPLL_LOG_TRACE("Calling GetStateCapability Operation %d ", req->operation);
+ ret_code = GetStateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ } else {
+ UPLL_LOG_TRACE("Calling GetReadCapability Operation %d ", req->operation);
+ ret_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ }
+ break;
+ }
+ }
+
+ if (!ret_code) {
+ UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s)",
+ ikey->get_key_type(), ctrlr_name);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ val_flowfilter_entry_t *val_flowfilter_entry =
+ reinterpret_cast<val_flowfilter_entry_t *>(GetVal(ikey));
+ if (max_attrs > 0) {
+ return VbrFlowFilterEntryMoMgr::ValFlowFilterEntryAttributeSupportCheck(
+ val_flowfilter_entry, attrs);
+ } else {
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d", req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR ;
}
- return rt_code;
}
bool VrtIfFlowFilterEntryMoMgr::GetRenameKeyBindInfo(unc_key_type_t key_type,
BindInfo *&binfo,
MoMgrTables tbl ) {
/* Main Table only update */
if (MAINTBL == tbl) {
- nattr = NUM_KEY_MAIN_TBL_;
+ nattr = sizeof(vrt_if_flowfilter_entry_maintbl_bind_info)/
+ sizeof(vrt_if_flowfilter_entry_maintbl_bind_info[0]);
binfo = vrt_if_flowfilter_entry_maintbl_bind_info;
}
- if (UNC_KT_FLOWLIST == key_type) {
- nattr = NUM_KEY_RENAME_MAIN_TBL;
- binfo = vrt_if_flowlist_rename_bind_info;
- }
-
UPLL_LOG_DEBUG("Successful Completeion");
return PFC_TRUE;
}
-upll_rc_t VrtIfFlowFilterEntryMoMgr::CopyToConfigKey(ConfigKeyVal *&okey,
+upll_rc_t VrtIfFlowFilterEntryMoMgr::CopyToConfigKey(ConfigKeyVal *&okey,
ConfigKeyVal *ikey) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
key_vrt_if_flowfilter_entry_t *key_vrt_if =
reinterpret_cast<key_vrt_if_flowfilter_entry_t*>
(ConfigKeyVal::Malloc(sizeof(key_vrt_if_flowfilter_entry_t)));
- if (UNC_KT_VRTIF_FLOWFILTER_ENTRY == ikey->get_key_type()) {
+ // if (UNC_KT_VRTIF_FLOWFILTER_ENTRY == ikey->get_key_type()) {
if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vtn_name))) {
UPLL_LOG_DEBUG("String Length not Valid to Perform the Operation");
- free(key_vrt_if); // COV:RESOURCE ELAK
+ free(key_vrt_if);
return UPLL_RC_ERR_GENERIC;
}
key_rename->old_unc_vtn_name,
(kMaxLenVtnName + 1));
-
- if (!strlen(reinterpret_cast<char *> (key_rename->old_unc_vnode_name))) {
- free(key_vrt_if); // COV:RESOURCE ELAK
+ if (UNC_KT_VROUTER == ikey->get_key_type()) {
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vnode_name))) {
+ UPLL_LOG_DEBUG("old_unc_vnode_name NULL");
+ free(key_vrt_if);
return UPLL_RC_ERR_GENERIC;
- }
- uuu::upll_strncpy(key_vrt_if->flowfilter_key.if_key.vrt_key.vrouter_name,
- key_rename->old_unc_vnode_name,
- (kMaxLenVnodeName + 1));
+ }
+ uuu::upll_strncpy(key_vrt_if->flowfilter_key.if_key.vrt_key.vrouter_name,
+ key_rename->old_unc_vnode_name, (kMaxLenVnodeName + 1));
+ } else {
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_unc_vnode_name))) {
+ UPLL_LOG_DEBUG("new_unc_vnode_name NULL");
+ free(key_vrt_if);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(key_vrt_if->flowfilter_key.if_key.vrt_key.vrouter_name,
+ key_rename->new_unc_vnode_name, (kMaxLenVnodeName + 1));
+ }
+ key_vrt_if->flowfilter_key.direction = 0xFE;
okey = new ConfigKeyVal(UNC_KT_VRTIF_FLOWFILTER_ENTRY, IpctSt::
kIpcStKeyVrtIfFlowfilterEntry, key_vrt_if, NULL);
+
+ if (!okey) {
+ free(key_vrt_if);
+ return UPLL_RC_ERR_GENERIC;
}
- if (UNC_KT_FLOWLIST == ikey->get_key_type()) {
- key_rename_vnode_info_t *key_rename =
+ return result_code;
+}
+
+upll_rc_t VrtIfFlowFilterEntryMoMgr::UpdateVnodeVal(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t data_type,
+ bool &no_rename) {
+ UPLL_FUNC_TRACE;
+ ConfigKeyVal *okey = NULL;
+ ConfigKeyVal *kval = NULL;
+ controller_domain ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+
+ uint8_t rename = 0;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+
+ key_rename_vnode_info_t *key_rename =
reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
- val_flowfilter_entry_t *val = reinterpret_cast<val_flowfilter_entry_t*>
- (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_t)));
- uuu::upll_strncpy(val->flowlist_name,
- key_rename->old_flowlist_name,
- (kMaxLenFlowListName+1));
+ //copy the olf flowlist name to val_flowfilter_entry
+ val_flowfilter_entry_t *val_ff_entry = reinterpret_cast<val_flowfilter_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_t)));
- val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] = UNC_VF_VALID;
- ConfigVal *ckv = new ConfigVal(IpctSt::kIpcStValFlowfilterEntry, val);
- okey = new ConfigKeyVal(UNC_KT_VRTIF_FLOWFILTER_ENTRY,
- IpctSt::kIpcStKeyVrtIfFlowfilterEntry, key_vrt_if, ckv);
- if (!okey)
- free(val);
+ if (!val_ff_entry) return UPLL_RC_ERR_GENERIC;
+
+ if (ikey->get_key_type() == UNC_KT_FLOWLIST) {
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_flowlist_name))) {
+ if (val_ff_entry) free(val_ff_entry);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ uuu::upll_strncpy(val_ff_entry->flowlist_name,
+ key_rename->old_flowlist_name,
+ (kMaxLenFlowListName + 1));
+ val_ff_entry->valid[UPLL_IDX_FLOWLIST_NAME_FFE] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("valid and flowlist name (%d) (%s)",
+ val_ff_entry->valid[UPLL_IDX_FLOWLIST_NAME_FFE],
+ val_ff_entry->flowlist_name);
+ } else if ((ikey->get_key_type() == UNC_KT_VBRIDGE) ||
+ (ikey->get_key_type() == UNC_KT_VROUTER)) {
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vnode_name))) {
+ UPLL_LOG_DEBUG("key_rename->old_unc_vnode_name NULL");
+ if (val_ff_entry) free(val_ff_entry);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(val_ff_entry->redirect_node,
+ key_rename->old_unc_vnode_name,
+ (kMaxLenFlowListName + 1));
+ val_ff_entry->valid[UPLL_IDX_REDIRECT_NODE_FFE] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("valid and vbridge name (%d) (%s)",
+ val_ff_entry->valid[UPLL_IDX_REDIRECT_NODE_FFE],
+ val_ff_entry->redirect_node);
}
+ result_code = GetChildConfigKey(okey, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("CopyToConfigKey okey NULL");
+ free(val_ff_entry);
+ return result_code;
+ }
if (!okey) {
- free(key_vrt_if);
+ free(val_ff_entry);
return UPLL_RC_ERR_GENERIC;
}
+
+ okey->SetCfgVal(new ConfigVal(IpctSt::kIpcStValFlowfilterEntry, val_ff_entry));
+
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain|kOpInOutFlag };
+
+ // Read the record of key structure and old flowlist name in maintbl
+ result_code = ReadConfigDB(okey, data_type, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG(" ReadConfigDB failed (%d)", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ while (okey != NULL) {
+ result_code = GetChildConfigKey(kval, okey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey kval NULL");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ if (!kval) {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ // Copy the new flowlist name in val_flowfilter_entry
+ val_flowfilter_entry_t *val_ff_entry_new = reinterpret_cast<val_flowfilter_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_t)));
+ if (!val_ff_entry_new) return UPLL_RC_ERR_GENERIC;
+
+ if (ikey->get_key_type() == UNC_KT_FLOWLIST) {
+ // New Name NuLL CHECK
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_flowlist_name))) {
+ if (val_ff_entry_new) free(val_ff_entry_new);
+ UPLL_LOG_DEBUG("new_flowlist_name NULL");
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ // Copy the new flowlist_name into val_flowfilter_entry
+ uuu::upll_strncpy(val_ff_entry_new->flowlist_name,
+ key_rename->new_flowlist_name,
+ (kMaxLenFlowListName + 1));
+ val_ff_entry_new->valid[UPLL_IDX_FLOWLIST_NAME_FFE] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("flowlist name and valid (%d) (%s)",
+ val_ff_entry_new->valid[UPLL_IDX_FLOWLIST_NAME_FFE],
+ val_ff_entry_new->flowlist_name);
+ } else if ((ikey->get_key_type() == UNC_KT_VBRIDGE) ||
+ (ikey->get_key_type() == UNC_KT_VROUTER)) {
+ // New Name NuLL CHECK
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_unc_vnode_name))) {
+ UPLL_LOG_DEBUG("new_unc_vnode_name NULL");
+ if (val_ff_entry_new) free(val_ff_entry_new);
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ // Copy the new vbridge name into val_flowfilter_entry
+ uuu::upll_strncpy(val_ff_entry_new->redirect_node,
+ key_rename->new_unc_vnode_name,
+ (kMaxLenFlowListName + 1));
+ val_ff_entry_new->valid[UPLL_IDX_REDIRECT_NODE_FFE] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("vbridge name and valid (%d) (%s)",
+ val_ff_entry_new->valid[UPLL_IDX_FLOWLIST_NAME_FFE],
+ val_ff_entry_new->redirect_node);
+
+ }
+ ConfigVal *cval1 = new ConfigVal(IpctSt::kIpcStValFlowfilterEntry, val_ff_entry_new);
+
+ kval->SetCfgVal(cval1);
+ memset(&ctrlr_dom, 0, sizeof(controller_domain));
+ result_code = GetControllerDomainID(okey, UPLL_DT_IMPORT, dmi);
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get the Controller Domain details, err:%d",
+ result_code);
+ }
+ GET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
+ GET_USER_DATA_FLAGS(okey, rename);
+ if (ikey->get_key_type() == UNC_KT_FLOWLIST) {
+ if (!no_rename)
+ rename = rename | FLOW_RENAME;
+ else
+ rename = rename & NO_FLOWLIST_RENAME;
+ } else if (ikey->get_key_type() == UNC_KT_VROUTER) {
+ if (!no_rename)
+ rename = rename | VRT_RENAME_FLAG;
+ else
+ rename = rename & NO_VRT_RENAME_FLAG;
+ }
+
+ SET_USER_DATA_FLAGS(kval, rename);
+ SET_USER_DATA_CTRLR_DOMAIN(kval, ctrlr_dom);
+
+ //Update the new flowlist name in MAINTBL
+ result_code = UpdateConfigDB(kval, data_type, UNC_OP_UPDATE, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Create record Err in vbrflowfilterentrytbl CANDIDATE DB(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(kval);
+ okey = okey->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(okey);
+ UPLL_LOG_DEBUG("UpdateVnodeVal result_code (%d)", result_code);
return result_code;
}
bool VrtIfFlowFilterEntryMoMgr::CompareValidValue(void *&val1,
- void *val2, bool audit) {
+ void *val2, bool copy_to_running) {
UPLL_FUNC_TRACE;
+ bool attr = true;
val_flowfilter_entry_t *val_ff_entry1 =
reinterpret_cast<val_flowfilter_entry_t *>(val1);
val_flowfilter_entry_t *val_ff_entry2 =
reinterpret_cast<val_flowfilter_entry_t *>(val2);
-
- // if (audit) {
- for ( unsigned int loop = 0; loop < sizeof(val_ff_entry1->valid); ++loop ) {
+ for ( unsigned int loop = 0; loop < sizeof(val_ff_entry1->valid); ++loop ) {
if (UNC_VF_INVALID == val_ff_entry1->valid[loop] &&
UNC_VF_VALID == val_ff_entry2->valid[loop])
val_ff_entry1->valid[loop] = UNC_VF_VALID_NO_VALUE;
}
- // }
-
if (val_ff_entry1->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID &&
val_ff_entry2->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
if (!strcmp(reinterpret_cast<char *>(val_ff_entry1->flowlist_name),
val_ff_entry2->valid[UPLL_IDX_REDIRECT_NODE_FFE] == UNC_VF_VALID) {
if (!strcmp(reinterpret_cast<char *>(val_ff_entry1->redirect_node),
reinterpret_cast<char *>(val_ff_entry2->redirect_node)))
- val_ff_entry1->valid[UPLL_IDX_REDIRECT_NODE_FFE] = UNC_VF_INVALID;
+ val_ff_entry1->valid[UPLL_IDX_REDIRECT_NODE_FFE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_ff_entry1->valid[UPLL_IDX_REDIRECT_PORT_FFE] == UNC_VF_VALID &&
val_ff_entry2->valid[UPLL_IDX_REDIRECT_PORT_FFE] == UNC_VF_VALID) {
if (!strcmp(reinterpret_cast<char *>(val_ff_entry1->redirect_port),
reinterpret_cast<char *>(val_ff_entry2->redirect_port)))
- val_ff_entry1->valid[UPLL_IDX_REDIRECT_PORT_FFE] = UNC_VF_INVALID;
+ val_ff_entry1->valid[UPLL_IDX_REDIRECT_PORT_FFE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
}
if (val_ff_entry1->valid[UPLL_IDX_MODIFY_DST_MAC_FFE] == UNC_VF_VALID &&
val_ff_entry2->valid[UPLL_IDX_MODIFY_DST_MAC_FFE] == UNC_VF_VALID) {
- if (!memcmp(val_ff_entry1->modify_dstmac, val_ff_entry2->modify_dstmac,
- sizeof(val_ff_entry2->modify_dstmac)))
- val_ff_entry1->valid[UPLL_IDX_MODIFY_DST_MAC_FFE] = UNC_VF_INVALID;
+
+ if (!memcmp(reinterpret_cast<char*>(val_ff_entry1->modify_dstmac),
+ reinterpret_cast<char *>(val_ff_entry2->modify_dstmac),
+ sizeof(val_ff_entry2->modify_dstmac))) {
+ val_ff_entry1->valid[UPLL_IDX_MODIFY_DST_MAC_FFE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
+ }
}
if (val_ff_entry1->valid[UPLL_IDX_MODIFY_SRC_MAC_FFE] == UNC_VF_VALID &&
val_ff_entry2->valid[UPLL_IDX_MODIFY_SRC_MAC_FFE] == UNC_VF_VALID) {
- if (!memcmp(val_ff_entry1->modify_srcmac, val_ff_entry2->modify_srcmac,
- sizeof(val_ff_entry2->modify_srcmac)))
- val_ff_entry1->valid[UPLL_IDX_MODIFY_SRC_MAC_FFE] = UNC_VF_INVALID;
+ if (!memcmp(reinterpret_cast<char*>(val_ff_entry1->modify_srcmac),
+ reinterpret_cast<char*>(val_ff_entry2->modify_srcmac),
+ sizeof(val_ff_entry2->modify_srcmac))) {
+ val_ff_entry1->valid[UPLL_IDX_MODIFY_SRC_MAC_FFE] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
+ }
}
if (val_ff_entry1->valid[UPLL_IDX_NWM_NAME_FFE] == UNC_VF_VALID &&
val_ff_entry2->valid[UPLL_IDX_NWM_NAME_FFE] == UNC_VF_VALID) {
val_ff_entry1->valid[UPLL_IDX_PRIORITY_FFE] = UNC_VF_INVALID;
}
UPLL_LOG_DEBUG("CompareValidValue :: Success");
- return false;
+ for (unsigned int loop = 0;
+ loop < sizeof(val_ff_entry1->valid)/ sizeof(uint8_t); ++loop) {
+ if ((UNC_VF_VALID == (uint8_t) val_ff_entry1->valid[loop]) ||
+ (UNC_VF_VALID_NO_VALUE == (uint8_t) val_ff_entry1->valid[loop]))
+ attr = false;
+ }
+ return attr;
}
-upll_rc_t VrtIfFlowFilterEntryMoMgr::ReadDetailEntry(
- ConfigKeyVal *ff_ckv,
- upll_keytype_datatype_t dt_type,
- unc_keytype_operation_t op,
- DbSubOp dbop,
- DalDmlIntf *dmi) {
+upll_rc_t VrtIfFlowFilterEntryMoMgr::VerifyRedirectDestination(
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t dt_type) {
UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
-
- if (NULL == ff_ckv) {
- UPLL_LOG_DEBUG("InPut ConfigKeyVal is NULL");
- return UPLL_RC_ERR_BAD_REQUEST;
+ MoMgrImpl *mgr = NULL;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *okey = NULL;
+ if (!ikey || !ikey->get_key()) {
+ UPLL_LOG_DEBUG("input key is null");
+ return UPLL_RC_ERR_GENERIC;
}
- // SET_USER_DATA_DOMAIN(ff_ckv, domain_id);
- // SET_USER_DATA_CTRLR(ff_ckv, ctrlr_id);
+ controller_domain ctrlr_dom;
+ memset(&ctrlr_dom, 0, sizeof(controller_domain));
+ key_vrt_if_flowfilter_entry_t *key_vrtif_ffe =
+ reinterpret_cast<key_vrt_if_flowfilter_entry_t *>(ikey->get_key());
- result_code = ReadConfigDB(ff_ckv, dt_type, UNC_OP_READ, dbop, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- return UPLL_RC_ERR_GENERIC;
- }
- return UPLL_RC_SUCCESS;
+ /* read val_vtn_flowfilter_entry from ikey*/
+ val_flowfilter_entry_t *val_flowfilter_entry =
+ static_cast<val_flowfilter_entry_t *>(
+ ikey->get_cfg_val()->get_val());
+ // Symentic Validation for redirect destination
+ if ((val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_NODE_FFE] ==
+ UNC_VF_VALID) &&
+ (val_flowfilter_entry->valid[UPLL_IDX_REDIRECT_PORT_FFE] ==
+ UNC_VF_VALID)) {
+ DbSubOp dbop_up = { kOpReadExist, kOpMatchCtrlr|kOpMatchDomain,
+ kOpInOutNone };
+ result_code = GetControllerDomainID(ikey, dt_type, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get the Controller Domain details, err:%d",
+ result_code);
+ }
+
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+
+ UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
+ ctrlr_dom.ctrlr, ctrlr_dom.domain);
+ // Verify whether the vtnnode and interface are exists in DB
+ // 1. Check for the vbridge Node
+ mgr = reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VBR_IF)));
+ if (NULL == mgr) {
+ UPLL_LOG_DEBUG("Unable to get VBRIDGE Interface object");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = mgr->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Memory allocation failed for VBRIDGE key struct - %d",
+ result_code);
+ return result_code;
+ }
+ key_vbr_if_t *vbrif_key = static_cast<key_vbr_if_t*>(
+ okey->get_key());
+ uuu::upll_strncpy(vbrif_key->vbr_key.vtn_key.vtn_name,
+ key_vrtif_ffe->flowfilter_key.if_key.vrt_key.vtn_key.vtn_name,
+ kMaxLenVtnName + 1);
+
+ uuu::upll_strncpy(vbrif_key->vbr_key.vbridge_name,
+ reinterpret_cast<char *>
+ (val_flowfilter_entry->redirect_node),
+ (kMaxLenVnodeName + 1));
+ uuu::upll_strncpy(vbrif_key->if_name,
+ reinterpret_cast<char *>
+ (val_flowfilter_entry->redirect_port),
+ kMaxLenInterfaceName + 1);
+
+ /* Check vtnnode and interface exists in table*/
+
+ SET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
+
+ result_code = mgr->UpdateConfigDB(okey, dt_type,
+ UNC_OP_READ, dmi, &dbop_up, MAINTBL);
+
+ DELETE_IF_NOT_NULL(okey);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ UPLL_LOG_DEBUG("vtn node/interface in val_flowfilter_entry exists"
+ "in DB");
+ } else if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ // 2. Check for Vrouter Node
+
+ // Verify whether the vtnnode and interface are exists in DB
+ mgr = reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VRT_IF)));
+ if (NULL == mgr) {
+ UPLL_LOG_DEBUG("Unable to get VROUTER Interface object");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = mgr->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Memory allocation failed for VROUTER key struct - %d",
+ result_code);
+ return result_code;
+ }
+ key_vrt_if_t *vrtif_key = static_cast<key_vrt_if_t*>(
+ okey->get_key());
+ uuu::upll_strncpy(vrtif_key->vrt_key.vtn_key.vtn_name,
+ key_vrtif_ffe->flowfilter_key.if_key.vrt_key.vtn_key.vtn_name,
+ kMaxLenVtnName + 1);
+
+ uuu::upll_strncpy(vrtif_key->vrt_key.vrouter_name,
+ reinterpret_cast<char *>
+ (val_flowfilter_entry->redirect_node),
+ (kMaxLenVnodeName + 1));
+ uuu::upll_strncpy(vrtif_key->if_name,
+ reinterpret_cast<char *>
+ (val_flowfilter_entry->redirect_port),
+ kMaxLenInterfaceName + 1);
+
+ UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
+ ctrlr_dom.ctrlr, ctrlr_dom.domain);
+ SET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
+ /* Check vtnnode and interface exists in table*/
+ result_code = mgr->UpdateConfigDB(okey, dt_type,
+ UNC_OP_READ, dmi, &dbop_up, MAINTBL);
+ DELETE_IF_NOT_NULL(okey);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code) {
+ UPLL_LOG_DEBUG("vtn node/interface in val struct does not exists"
+ "in DB");
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ }
+ result_code =
+ (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) ? UPLL_RC_SUCCESS :
+ result_code;
+
+ } // end of Symentic Validation
+ return result_code;
}
+/*Return result of validation*/
+upll_rc_t VrtIfFlowFilterEntryMoMgr::TxVote(unc_key_type_t keytype,
+ DalDmlIntf *dmi,
+ ConfigKeyVal **err_ckv) {
+ UPLL_FUNC_TRACE;
+ ConfigKeyVal *req = NULL, *nreq = NULL;
+ DalResultCode db_result;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ unc_keytype_operation_t op[]= { UNC_OP_CREATE, UNC_OP_UPDATE};
+ int nop = sizeof(op) / sizeof(op[0]);
+ DalCursor *cfg1_cursor = NULL;
+
+ for (int i = 0; i < nop; i++) {
+ result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i], req,
+ nreq, &cfg1_cursor, dmi, MAINTBL);
+ while (result_code == UPLL_RC_SUCCESS) {
+ db_result = dmi->GetNextRecord(cfg1_cursor);
+ result_code = DalToUpllResCode(db_result);
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_DEBUG("No diff found for op %d", op[i]);
+ break;
+ }
+ val_flowfilter_entry_t* val = reinterpret_cast<val_flowfilter_entry_t *>
+ (GetVal(req));
+ if ((val->valid[UPLL_IDX_REDIRECT_NODE_FFE] ==
+ UNC_VF_VALID) &&
+ (val->valid[UPLL_IDX_REDIRECT_PORT_FFE] ==
+ UNC_VF_VALID)) {
+ result_code = VerifyRedirectDestination(req, dmi,
+ UPLL_DT_CANDIDATE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Invalid redirect-destination node/interface");
+ *err_ckv = req;
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ }
+ }
+ dmi->CloseCursor(cfg1_cursor, true);
+ if (req) delete req;
+ if (nreq) delete nreq;
+ }
+
+ return result_code;
+}
upll_rc_t VrtIfFlowFilterEntryMoMgr::TxUpdateController(
unc_key_type_t keytype,
uint32_t session_id,
/*Restore the original op code for each DB record*/
op1 = op;
result_code = DupConfigKeyVal(ck_main, req, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("DupConfigKeyVal failed %d\n", result_code);
+ if (!ck_main || result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("DupConfigKeyVal failed %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
return result_code;
}
break;
/*Restore the original op code for each DB record*/
op1 = op;
result_code = GetChildConfigKey(ck_main, req);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("GetChildConfigKey failed %d\n", result_code);
+ if (!ck_main || result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("GetChildConfigKey failed %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
return result_code;
}
DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutCtrlr};
result_code = ReadConfigDB(ck_main, UPLL_DT_RUNNING, UNC_OP_READ,
dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
return UPLL_RC_ERR_GENERIC;
}
}
default:
break;
}
+ if (!ck_main) return UPLL_RC_ERR_GENERIC;
GET_USER_DATA_CTRLR_DOMAIN(ck_main, ctrlr_dom);
if (ctrlr_dom.ctrlr == NULL) {
return UPLL_RC_ERR_GENERIC;
ConfigKeyVal *temp = NULL;
result_code = GetChildConfigKey(temp, ck_main);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("GetChildConfigKey failed %d\n", result_code);
+ UPLL_LOG_TRACE("GetChildConfigKey failed %d", result_code);
return result_code;
}
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr|kOpMatchDomain,
result_code = ReadConfigDB(temp, UPLL_DT_RUNNING, UNC_OP_READ,
dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ DELETE_IF_NOT_NULL(temp);
return UPLL_RC_ERR_GENERIC;
}
GET_USER_DATA_FLAGS(temp, flag);
void *val_nrec = (nreq) ? GetVal(nreq) : NULL;
FilterAttributes(main, val_nrec, false, op);
}
+ DELETE_IF_NOT_NULL(temp);
}
}
(ConfigKeyVal::Malloc(sizeof(pfcdrv_val_flowfilter_entry_t)));
pfc_val->valid[PFCDRV_IDX_VAL_VBRIF_VEXTIF_FFE] = UNC_VF_VALID;
- pfc_val->valid[PFCDRV_IDX_FLOWFILTER_ENTRY_FFE] = UNC_VF_VALID;
pfc_val->val_vbrif_vextif.valid[PFCDRV_IDX_INTERFACE_TYPE] = UNC_VF_VALID;
pfc_val->val_vbrif_vextif.interface_type = PFCDRV_IF_TYPE_VBRIF;
-
+#if 0
val_flowfilter_entry_t* val = reinterpret_cast<val_flowfilter_entry_t *>
(GetVal(ck_main));
memcpy(&pfc_val->val_ff_entry, val, sizeof(val_flowfilter_entry_t));
-
+#endif
// Inserting the controller to Set
affected_ctrlr_set->insert
(string(reinterpret_cast<char *>(ctrlr_dom.ctrlr)));
+ ConfigKeyVal *temp_ck_main = NULL;
+ result_code = DupConfigKeyVal(temp_ck_main, req, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
+ return result_code;
+ }
upll_keytype_datatype_t dt_type = (op1 == UNC_OP_DELETE)?
UPLL_DT_RUNNING:UPLL_DT_CANDIDATE;
result_code = GetRenamedControllerKey(ck_main, dt_type,
dmi, &ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS)
break;
-
+ if (UNC_OP_DELETE == op1) {
+ pfc_val->valid[PFCDRV_IDX_FLOWFILTER_ENTRY_FFE] = UNC_VF_INVALID;
+ } else {
+ val_flowfilter_entry_t* val = reinterpret_cast<val_flowfilter_entry_t *>
+ (GetVal(ck_main));
+ memcpy(&pfc_val->val_ff_entry, val, sizeof(val_flowfilter_entry_t));
+ pfc_val->valid[PFCDRV_IDX_FLOWFILTER_ENTRY_FFE] = UNC_VF_VALID;
+ }
+
UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
ctrlr_dom.domain);
ck_main->SetCfgVal(new ConfigVal(IpctSt::kIpcStPfcdrvValFlowfilterEntry,
result_code = UPLL_RC_SUCCESS;
}
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("IpcSend failed %d\n", result_code);
- *err_ckv = ipc_resp.ckv_data;
- if (ck_main)
- delete ck_main;
+ UPLL_LOG_DEBUG("IpcSend failed %d", result_code);
+ *err_ckv = temp_ck_main;
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(ck_main);
break;
}
- if (ck_main) {
- delete ck_main;
- ck_main = NULL;
- }
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(temp_ck_main);
+ DELETE_IF_NOT_NULL(ck_main);
}
if (dal_cursor_handle) {
dmi->CloseCursor(dal_cursor_handle, true);
upll_rc_t VrtIfFlowFilterEntryMoMgr::SetVlinkPortmapConfiguration(
ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
- DalDmlIntf *dmi, InterfacePortMapInfo flag) {
+ DalDmlIntf *dmi, InterfacePortMapInfo flag,
+ unc_keytype_operation_t oper) {
upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+ controller_domain ctrlr_dom;
+ uint8_t *ctrlr_id = NULL;
+
if (NULL == ikey || NULL == ikey->get_key()) {
return result_code;
}
ConfigKeyVal *ckv = NULL;
+ memset(&ctrlr_dom, 0, sizeof(controller_domain));
result_code = GetChildConfigKey(ckv, NULL);
if (UPLL_RC_SUCCESS != result_code) {
return result_code;
DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutFlag };
result_code = ReadConfigDB(ckv, dt_type ,
UNC_OP_READ, dbop, dmi, MAINTBL);
- if (UPLL_RC_SUCCESS != result_code) {
- delete ckv;
- return result_code;
- }
+
if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
UPLL_LOG_DEBUG("No Recrods in the Vbr_If_FlowFilter Table");
+ DELETE_IF_NOT_NULL(ckv);
return UPLL_RC_SUCCESS;
}
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("Read ConfigDB failure %d", result_code);
+ DELETE_IF_NOT_NULL(ckv);
return result_code;
}
uint8_t flag_port_map = 0;
+ ConfigKeyVal *ckv_first = ckv;
while (ckv) {
+ val_flowfilter_entry_t *flowfilter_val =
+ reinterpret_cast<val_flowfilter_entry_t *> (GetVal(ckv));
flag_port_map = 0;
GET_USER_DATA_FLAGS(ckv, flag_port_map);
if (flag & kVlinkConfigured) {
+ UPLL_LOG_DEBUG("Vlink Flag");
flag_port_map |= SET_FLAG_VLINK;
} else {
- flag_port_map = 0;
+
+ UPLL_LOG_DEBUG("No Vlink Flag");
+ flag_port_map &= NO_FLAG_VLINK;
}
+ UPLL_LOG_DEBUG("SET_USER_DATA_FLAGS flag_port_map %d", flag_port_map);
SET_USER_DATA_FLAGS(ckv, flag_port_map);
+
DbSubOp dbop_update = { kOpReadSingle, kOpMatchNone, kOpInOutFlag };
result_code = UpdateConfigDB(ckv, dt_type, UNC_OP_UPDATE,
dmi, &dbop_update, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Failed to update flag in DB ,err %d", result_code);
+ DELETE_IF_NOT_NULL(ckv);
return result_code;
}
+ if (flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
+ unc_keytype_operation_t op = UNC_OP_INVALID;
+ FlowListMoMgr *mgr = reinterpret_cast<FlowListMoMgr *>
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
+ if (flag_port_map & SET_FLAG_VLINK) {
+ op = UNC_OP_CREATE;
+ } else {
+ op = UNC_OP_DELETE;
+ }
+ result_code = GetControllerDomainID(ikey, dt_type, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get the Controller Domain details, err:%d",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv);
+ return result_code;
+ }
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+ UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
+ ctrlr_dom.ctrlr, ctrlr_dom.domain);
+ ctrlr_id = ctrlr_dom.ctrlr;
+ result_code = mgr->AddFlowListToController(
+ reinterpret_cast<char*>(flowfilter_val->flowlist_name), dmi,
+ reinterpret_cast<char *>(ctrlr_id), dt_type, op);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG(" Send delete request to flowlist failed. err code(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv);
+ return result_code;
+ }
+ }
+
ckv = ckv->get_next_cfg_key_val();
}
+ DELETE_IF_NOT_NULL(ckv_first);
return UPLL_RC_SUCCESS;
}
+upll_rc_t VrtIfFlowFilterEntryMoMgr::RestorePOMInCtrlTbl(
+ ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl,
+ DalDmlIntf* dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ controller_domain ctrlr_dom;
+ FlowListMoMgr *mgr = NULL;
+ uint8_t *ctrlr_id = NULL;
+
+ if (!ikey || !(ikey->get_key())) {
+ UPLL_LOG_DEBUG("Input Key Not Valid");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (tbl != MAINTBL ||
+ ikey->get_key_type() != UNC_KT_VRTIF_FLOWFILTER_ENTRY) {
+ UPLL_LOG_DEBUG("Ignoring ktype/Table kt=%d, tbl=%d",
+ ikey->get_key_type(), tbl);
+ return result_code;
+ }
+
+ memset(&ctrlr_dom, 0, sizeof(controller_domain));
+ val_flowfilter_entry_t *flowfilter_val =
+ reinterpret_cast<val_flowfilter_entry_t *> (GetVal(ikey));
+ if (NULL == flowfilter_val) {
+ UPLL_LOG_DEBUG(" Value structure is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
+ result_code = GetControllerDomainID(ikey, dt_type, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get the Controller Domain details, err:%d",
+ result_code);
+ return result_code;
+ }
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+ UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
+ ctrlr_dom.ctrlr, ctrlr_dom.domain);
+ ctrlr_id = ctrlr_dom.ctrlr;
+
+ mgr = reinterpret_cast<FlowListMoMgr *>
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
+ result_code = mgr->AddFlowListToController(
+ reinterpret_cast<char *>(flowfilter_val->flowlist_name),
+ dmi,
+ reinterpret_cast<char *>(ctrlr_id),
+ dt_type,
+ UNC_OP_CREATE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to update the FlowList at ctrlr table.Err %d",
+ result_code);
+ return result_code;
+ }
+ }
+ return result_code;
+}
+
upll_rc_t VrtIfFlowFilterEntryMoMgr::CreateCandidateMo(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
DalDmlIntf *dmi) {
uint8_t *ctrlr_id = NULL;
controller_domain ctrlr_dom;
memset(&ctrlr_dom, 0, sizeof(ctrlr_dom));
- if (ikey == NULL && req == NULL) {
+ if (ikey == NULL || req == NULL) {
UPLL_LOG_DEBUG(
- "Cannot perform create operation due to insufficient parameters\n");
+ "Cannot perform create operation due to insufficient parameters");
return UPLL_RC_ERR_GENERIC;
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_flowfilter_entry_t *val_ff_import = NULL;
+ pfcdrv_val_flowfilter_entry_t *pfc_val_import = NULL;
+
+ if (req->datatype == UPLL_DT_IMPORT) {
+ UPLL_LOG_DEBUG("Inside %d", req->datatype);
+ if (ikey->get_cfg_val() &&
+ (ikey->get_cfg_val()->get_st_num() ==
+ IpctSt::kIpcStPfcdrvValFlowfilterEntry)) {
+ UPLL_LOG_DEBUG("pran:-val struct num (%d)",ikey->get_cfg_val()->get_st_num());
+ pfc_val_import = reinterpret_cast<pfcdrv_val_flowfilter_entry_t *>
+ (ikey->get_cfg_val()->get_val());
+ val_ff_import = reinterpret_cast<val_flowfilter_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_t)));
+ memcpy(val_ff_import, &pfc_val_import->val_ff_entry, sizeof(val_flowfilter_entry_t));
+ UPLL_LOG_DEBUG("FLOWLIST name (%s)", val_ff_import->flowlist_name);
+ ikey->SetCfgVal(NULL);
+ ikey->SetCfgVal(new ConfigVal(IpctSt::kIpcStValFlowfilterEntry, val_ff_import));
+ }
+ }
+ UPLL_LOG_TRACE("%s vrt_if_ff_entry", ikey->ToStrAll().c_str());
// validate syntax and semantics
result_code = ValidateMessage(req, ikey);
if (result_code != UPLL_RC_SUCCESS) {
return result_code;
}
- /*
- result_code= ValidateCapability(req, ikey);
- if (UPLL_RC_SUCCESS != result_code)
- return result_code;
- */
// Check if Object already exists in CANDIDATE DB
result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_READ, dmi);
if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS
UPLL_LOG_DEBUG("Record already exists in Candidate DB");
return result_code;
}
+ val_flowfilter_entry_t *flowfilter_val =
+ reinterpret_cast<val_flowfilter_entry_t *> (GetVal(ikey));
+ FlowListMoMgr *mgr = NULL;
+ result_code = GetControllerDomainID(ikey, req->datatype, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get the Controller Domain details, err:%d",
+ result_code);
+ }
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+
+ UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
+ ctrlr_dom.ctrlr, ctrlr_dom.domain);
+ ctrlr_id = ctrlr_dom.ctrlr;
+
+ ConfigKeyVal *temp_key = NULL;
+ result_code = GetChildConfigKey(temp_key, NULL);
+ if(result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed in ValidateCapability");
+ return result_code;
+ }
+ result_code = GetInstanceCount(temp_key,
+ reinterpret_cast<char*> (ctrlr_id),
+ req->datatype,
+ &cur_instance_count,
+ dmi,
+ MAINTBL);
+ DELETE_IF_NOT_NULL(temp_key);
+ if(result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetInstanceCount Failed in ValidateCapability");
+ return result_code;
+ }
+
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(ctrlr_id));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("validate Capability Failed %d", result_code);
+ return result_code;
+ }
// Check if Object exists in RUNNING DB and move it to CANDIDATE DB
- result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
- MAINTBL);
- if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
- result_code = RestoreChildren(ikey, req->datatype, UPLL_DT_RUNNING, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(" RestoreChildren failed. err code(%d)", result_code);
+ if (UPLL_DT_CANDIDATE == req->datatype) {
+ result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
+ MAINTBL);
+ if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
+ result_code = RestoreChildren(ikey, req->datatype, UPLL_DT_RUNNING, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Restore Operation Failed, err %d", result_code);
+ return result_code;
+ }
+ return result_code;
+ } else if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG(" error reading DB. err code(%d)", result_code);
return result_code;
+ } else {
+ UPLL_LOG_DEBUG("Record doesn't exist in reading Running DB ");
}
- } else if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- UPLL_LOG_DEBUG(" error reading DB. err code(%d)", result_code);
- return result_code;
- } else {
- UPLL_LOG_DEBUG("Record doesn't exist in reading Running DB ");
}
- val_flowfilter_entry_t *flowfilter_val =
- reinterpret_cast<val_flowfilter_entry_t *> (GetVal(ikey));
- FlowListMoMgr *mgr = NULL;
if (flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
mgr = reinterpret_cast<FlowListMoMgr *>
(const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
// Check Flowlist object exist or not
result_code = mgr->GetChildConfigKey(okey, NULL);
- if (result_code != UPLL_RC_SUCCESS) {
+ if (!okey || result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Recored %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
key_flowlist_t *key_flowlist = reinterpret_cast<key_flowlist_t*>
uuu::upll_strncpy(key_flowlist->flowlist_name,
flowfilter_val->flowlist_name,
(kMaxLenFlowListName +1));
- result_code = mgr->IsReferenced(okey, req->datatype, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Flowlist not available %d", result_code);
+
+ result_code = mgr->UpdateConfigDB(okey, req->datatype, UNC_OP_READ,
+ dmi, MAINTBL);
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Given FlowList does not exists %d", result_code);
+ delete okey;
return result_code;
- }
+ } else if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
+ UPLL_LOG_DEBUG("Instance Available");
+ } else if (result_code != UPLL_RC_SUCCESS) {
+ delete okey;
+ UPLL_LOG_DEBUG("Error Accesing CANDIDATE DB (%d)", result_code);
+ return result_code;
+ }
if (okey) {
delete okey;
okey = NULL;
}
}
- // N/w monitor
-#if 0
- NwMonitorMoMgr *nmgr = reinterpret_cast<NwMonitorMoMgr *>
- (const_cast<MoManager *> (GetMoManager(UNC_KT_VBR_NWMONITOR)));
- // result_code = nmgr->GetChildConfigKey(okey, NULL); //TODO
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Recored %d", result_code);
- return result_code;
- }
- key_nwm_t *key_nwm = reinterpret_cast<key_nwm_t*>(okey->get_key());
- uuu::upll_strncpy(reinterpret_cast<char*>(key_nwm->nwmonitor_name),
- reinterpret_cast<const char*>(flowfilter_val->nwm_name),
- kMaxLenNwmName +1);
- // result_code = nmgr->IsReferenced(okey, req->datatype, dmi); //TODO
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Recored %d", result_code);
- return result_code;
- }
-#endif
-
// create a record in CANDIDATE DB
VrtIfMoMgr *vrtifmgr =
reinterpret_cast<VrtIfMoMgr *>(const_cast<MoManager *>(GetMoManager(
ConfigKeyVal *ckv = NULL;
InterfacePortMapInfo flags = kVlinkPortMapNotConfigured;
result_code = vrtifmgr->GetChildConfigKey(ckv, NULL);
- key_vrt_if_flowfilter_entry_t *ff_key = reinterpret_cast
+ key_vrt_if_flowfilter_entry_t *ff_key = reinterpret_cast
<key_vrt_if_flowfilter_entry_t *>(ikey->get_key());
- key_vrt_if_t *vrtif_key = reinterpret_cast<key_vrt_if_t *>(ckv->get_key());
-
- uuu::upll_strncpy(vrtif_key->vrt_key.vtn_key.vtn_name,
- ff_key->flowfilter_key.if_key.vrt_key.vtn_key.vtn_name,
- kMaxLenVtnName + 1);
-
- uuu::upll_strncpy(vrtif_key->vrt_key.vrouter_name,
- ff_key->flowfilter_key.if_key.vrt_key.vrouter_name,
- kMaxLenVtnName + 1);
-
- uuu::upll_strncpy(vrtif_key->if_name,
- ff_key->flowfilter_key.if_key.if_name,
- kMaxLenInterfaceName + 1);
-
- uint8_t* vexternal = reinterpret_cast<uint8_t*>
- (ConfigKeyVal::Malloc(kMaxLenVnodeName + 1));
- uint8_t* vex_if = reinterpret_cast<uint8_t*>
- (ConfigKeyVal::Malloc(kMaxLenInterfaceName + 1));
- result_code = vrtifmgr->GetVexternal(ckv, req->datatype, dmi,
- vexternal, vex_if, flags);
- if (UPLL_RC_SUCCESS != result_code) {
- return result_code;
- }
- uint8_t flag_port_map;
- if (flags & kVlinkConfigured) {
- flag_port_map = SET_FLAG_VLINK;
- } else {
- flag_port_map = 0;
- }
- free(vexternal);
- free(vex_if);
- SET_USER_DATA_FLAGS(ikey, flag_port_map);
-
-
- result_code = GetControllerDomainID(ikey, req->datatype, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Failed to Get the Controller Domain details, err:%d",
- result_code);
+ key_vrt_if_t *vrtif_key = reinterpret_cast<key_vrt_if_t *>(ckv->get_key());
+
+ uuu::upll_strncpy(vrtif_key->vrt_key.vtn_key.vtn_name,
+ ff_key->flowfilter_key.if_key.vrt_key.vtn_key.vtn_name,
+ kMaxLenVtnName + 1);
+
+ uuu::upll_strncpy(vrtif_key->vrt_key.vrouter_name,
+ ff_key->flowfilter_key.if_key.vrt_key.vrouter_name,
+ kMaxLenVtnName + 1);
+
+ uuu::upll_strncpy(vrtif_key->if_name,
+ ff_key->flowfilter_key.if_key.if_name,
+ kMaxLenInterfaceName + 1);
+
+ uint8_t* vexternal = reinterpret_cast<uint8_t*>
+ (ConfigKeyVal::Malloc(kMaxLenVnodeName + 1));
+ uint8_t* vex_if = reinterpret_cast<uint8_t*>
+ (ConfigKeyVal::Malloc(kMaxLenInterfaceName + 1));
+ result_code = vrtifmgr->GetVexternal(ckv, req->datatype, dmi,
+ vexternal, vex_if, flags);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ckv);
+ free(vexternal);
+ free(vex_if);
+ return result_code;
}
- GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
-
- UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
- ctrlr_dom.ctrlr, ctrlr_dom.domain);
- ctrlr_id = ctrlr_dom.ctrlr;
-
- if (flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
- result_code = mgr->AddFlowListToController(
- reinterpret_cast<char *>(flowfilter_val->flowlist_name), dmi,
- reinterpret_cast<char *> (ctrlr_id) , UNC_OP_CREATE);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Reference Count Updation Fails %d", result_code);
- return result_code;
+ DELETE_IF_NOT_NULL(ckv);
+ uint8_t flag_port_map = 0;
+ GET_USER_DATA_FLAGS(ikey, flag_port_map);
+ if (flags & kVlinkConfigured) {
+ flag_port_map = flag_port_map | SET_FLAG_VLINK;
+ }
+ free(vexternal);
+ free(vex_if);
+ SET_USER_DATA_FLAGS(ikey, flag_port_map);
+ if (flags & kVlinkConfigured) {
+ if (flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
+ result_code = mgr->AddFlowListToController(
+ reinterpret_cast<char *>(flowfilter_val->flowlist_name), dmi,
+ reinterpret_cast<char *> (ctrlr_id), req->datatype, UNC_OP_CREATE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Reference Count Updation Fails %d", result_code);
+ return result_code;
+ }
}
}
-
- result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_CREATE, dmi);
+ DbSubOp dbop = { kOpNotRead, kOpMatchNone, kOpInOutDomain
+ | kOpInOutCtrlr | kOpInOutFlag };
+ result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_CREATE, dmi,
+ &dbop, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Unable to update CandidateDB %d", result_code);
}
VrtIfMoMgr *mgrvrtif =
reinterpret_cast<VrtIfMoMgr *>(const_cast<MoManager *>(GetMoManager(
UNC_KT_VRT_IF)));
-
+ if (NULL == mgrvrtif) {
+ UPLL_LOG_DEBUG("mgrvrtif is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
ConfigKeyVal *ckv = NULL;
result_code = mgrvrtif->GetChildConfigKey(ckv, NULL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
ctrlr_dom.ctrlr, ctrlr_dom.domain);
- SET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+ uint8_t temp_flag = 0;
+ GET_USER_DATA_FLAGS(ikey, temp_flag);
+ SET_USER_DATA(ikey, vrt_key);
+ SET_USER_DATA_FLAGS(ikey, temp_flag);
+ // SET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
DELETE_IF_NOT_NULL(vrt_key);
DELETE_IF_NOT_NULL(ckv);
UPLL_LOG_DEBUG(" Input Key is NULL");
return UPLL_RC_ERR_GENERIC;
}
-
+ DELETE_IF_NOT_NULL(okey);
unc_key_type_t ikey_type = ikey->get_key_type();
if (ikey_type != UNC_KT_VRTIF_FLOWFILTER_ENTRY) {
UPLL_LOG_DEBUG(" Invalid key type received. Key type - %d", ikey_type);
upll_rc_t VrtIfFlowFilterEntryMoMgr::ConstructReadDetailResponse(
ConfigKeyVal *ikey,
ConfigKeyVal *drv_resp_ckv,
- DalDmlIntf *dmi,
ConfigKeyVal **okey) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *tmp_okey = NULL;
- DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone };
-
result_code = GetChildConfigKey(tmp_okey, ikey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetChildConfigKey failed err code (%d)", result_code);
return result_code;
}
- result_code = ReadConfigDB(tmp_okey, UPLL_DT_RUNNING, UNC_OP_READ,
- dbop, dmi, MAINTBL);
+ tmp_okey->AppendCfgVal(drv_resp_ckv->GetCfgValAndUnlink());
+ if (*okey == NULL) {
+ *okey = tmp_okey;
+ } else {
+ (*okey)->AppendCfgKeyVal(tmp_okey);
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VrtIfFlowFilterEntryMoMgr::DeleteChildrenPOM(
+ ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ uint8_t *ctrlr_id = NULL;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+// uint8_t rename = 0;
+ if (NULL == ikey && NULL == dmi) return result_code;
+
+ ConfigKeyVal *temp_okey = NULL;
+ ConfigKeyVal *okey = NULL;
+ result_code = GetChildConfigKey(temp_okey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ return result_code;
+ }
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone,
+ kOpInOutCtrlr|kOpInOutDomain };
+ result_code = ReadConfigDB(temp_okey, UPLL_DT_CANDIDATE,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ReadConfigDB error (%d)", result_code);
- delete tmp_okey;
+ DELETE_IF_NOT_NULL(temp_okey);
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("UPLL_RC_ERR_NO_SUCH_INSTANCE");
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("Unable to read configuration from CandidateDb");
return result_code;
}
+ okey = temp_okey;
+ while (NULL != okey) {
+ GET_USER_DATA_CTRLR(okey, ctrlr_id);
+ val_flowfilter_entry_t *flowfilter_val =
+ reinterpret_cast<val_flowfilter_entry_t *> (GetVal(okey));
+ if (flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
+ FlowListMoMgr *mgr = reinterpret_cast<FlowListMoMgr *>
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
+ result_code = mgr->AddFlowListToController(
+ reinterpret_cast<char*>(flowfilter_val->flowlist_name), dmi,
+ reinterpret_cast<char *>(ctrlr_id), dt_type, UNC_OP_DELETE);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG(" Send delete request to flowlist failed. err code(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(temp_okey);
+ return result_code;
+ }
+ }
+ result_code = UpdateConfigDB(okey, dt_type, UNC_OP_DELETE, dmi,
+ MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to delete the vrt if flowfilter entry ,err %d",
+ result_code);
+ DELETE_IF_NOT_NULL(temp_okey);
+ return result_code;
+ }
+ okey = okey->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(temp_okey);
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VrtIfFlowFilterEntryMoMgr::AuditUpdateController(unc_key_type_t keytype,
+ const char *ctrlr_id,
+ uint32_t session_id,
+ uint32_t config_id,
+ uuc::UpdateCtrlrPhase phase,
+ bool *ctrlr_affected,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ DalResultCode db_result = uud::kDalRcSuccess;
+ MoMgrTables tbl = MAINTBL;
+ controller_domain_t ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ ConfigKeyVal *ckv_running_db = NULL;
+ ConfigKeyVal *ckv_audit_db = NULL;
+ ConfigKeyVal *ckv_driver_req = NULL;
+ ConfigKeyVal *ckv_audit_dup_db = NULL;
+ DalCursor *cursor = NULL;
+ uint8_t db_flag = 0;
+ uint8_t *ctrlr = reinterpret_cast<uint8_t *>(const_cast<char *>(ctrlr_id));
+ /* decides whether to retrieve from controller table or main table */
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutCtrlr | kOpInOutDomain};
+ //GET_TABLE_TYPE(keytype, tbl);
+ unc_keytype_operation_t op = (phase == uuc::kUpllUcpCreate)?UNC_OP_CREATE:
+ ((phase == uuc::kUpllUcpUpdate)?UNC_OP_UPDATE:
+ ((phase == uuc::kUpllUcpDelete)?UNC_OP_DELETE:UNC_OP_INVALID));
- ConfigVal *drv_resp_val = NULL;
- drv_resp_val = drv_resp_ckv->get_cfg_val();
- while (drv_resp_val != NULL) {
- if (IpctSt::kIpcStValFlowfilterEntrySt != drv_resp_val->get_st_num()) {
- UPLL_LOG_DEBUG("Incorrect structure received from driver, struct num %d",
- drv_resp_val->get_st_num());
- return UPLL_RC_ERR_GENERIC;
- }
- val_flowfilter_entry_st_t *tmp_ffe_st =
- reinterpret_cast<val_flowfilter_entry_st_t*>
- (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_st_t)));
- memcpy(tmp_ffe_st,
- reinterpret_cast<val_flowfilter_entry_st_t *>
- (drv_resp_val->get_val()),
- sizeof(val_flowfilter_entry_st_t));
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowfilterEntrySt, tmp_ffe_st);
-
- if ((drv_resp_val = drv_resp_val->get_next_cfg_val()) == NULL) {
- UPLL_LOG_DEBUG("No more entries in driver response\n");
- break;
+ unc_keytype_operation_t op1 = op;
+ if (phase == uuc::kUpllUcpDelete2)
+ return result_code;
+ /* retreives the delta of running and audit configuration */
+ UPLL_LOG_DEBUG("Operation is %d", op);
+ result_code = DiffConfigDB(UPLL_DT_RUNNING, UPLL_DT_AUDIT, op,
+ ckv_running_db, ckv_audit_db,
+ &cursor, dmi, ctrlr, tbl);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DiffConfigDB failed - %d", result_code);
+ return result_code;
+ }
+ while (uud::kDalRcSuccess == (db_result = dmi->GetNextRecord(cursor))) {
+ op1 = op;
+ if (phase != uuc::kUpllUcpDelete) {
+ uint8_t *db_ctrlr = NULL;
+ GET_USER_DATA_CTRLR(ckv_running_db,db_ctrlr);
+ UPLL_LOG_DEBUG("db ctrl_id and audit ctlr_id are %s %s",
+ db_ctrlr, ctrlr_id);
+ // Skipping the controller ID if the controller id in DB and
+ // controller id available for Audit are not the same
+ if (db_ctrlr && strncmp(reinterpret_cast<const char *>(db_ctrlr),
+ reinterpret_cast<const char *>(ctrlr_id),
+ strlen(reinterpret_cast<const char *>(ctrlr_id)) + 1)) {
+ continue;
+ }
+ }
+ /* ignore records of another controller for create and update operation */
+ switch (phase) {
+ case uuc::kUpllUcpDelete:
+ UPLL_LOG_TRACE("Deleted record is %s ",
+ ckv_running_db->ToStrAll().c_str());
+ result_code = GetChildConfigKey(ckv_driver_req, ckv_running_db);
+ UPLL_LOG_TRACE("ckv_driver_req in delete is %s",
+ ckv_driver_req->ToStrAll().c_str());
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed. err_code & phase %d %d",
+ result_code, phase);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ if (ckv_driver_req->get_cfg_val()) {
+ UPLL_LOG_DEBUG("Invalid param");
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = ReadConfigDB(ckv_driver_req, UPLL_DT_AUDIT, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d",result_code);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ break;
+ case uuc::kUpllUcpCreate:
+ UPLL_LOG_TRACE("Created record is %s ",
+ ckv_running_db->ToStrAll().c_str());
+ result_code = DupConfigKeyVal(ckv_driver_req, ckv_running_db, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed. err_code & phase %d %d",
+ result_code, phase);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ break;
+ case uuc::kUpllUcpUpdate:
+ ckv_audit_dup_db = NULL;
+ ckv_driver_req = NULL;
+ UPLL_LOG_TRACE("UpdateRecord record is %s ",
+ ckv_running_db->ToStrAll().c_str());
+ UPLL_LOG_TRACE("UpdateRecord record is %s ",
+ ckv_audit_db->ToStrAll().c_str());
+ result_code = DupConfigKeyVal(ckv_driver_req, ckv_running_db, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed for running record. \
+ err_code & phase %d %d", result_code, phase);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ result_code = DupConfigKeyVal(ckv_audit_dup_db, ckv_audit_db, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed for audit record. \
+ err_code & phase %d %d", result_code, phase);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ break;
+ default:
+ UPLL_LOG_DEBUG("Invalid operation %d", phase);
+ return UPLL_RC_ERR_NO_SUCH_OPERATION;
+ break;
}
- if (IpctSt::kIpcStValFlowlistEntrySt != (drv_resp_val)->get_st_num()) {
- UPLL_LOG_DEBUG("No flowflist entries returned by driver");
- continue;
+ GET_USER_DATA_CTRLR_DOMAIN(ckv_driver_req, ctrlr_dom);
+ if (ctrlr_dom.ctrlr == NULL) {
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ckv_audit_dup_db);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
}
- while (IpctSt::kIpcStValFlowlistEntrySt == drv_resp_val->get_st_num()) {
- val_flowlist_entry_st_t* tmp_val_fl_st =
- reinterpret_cast<val_flowlist_entry_st_t*>
- (ConfigKeyVal::Malloc(sizeof(val_flowlist_entry_st_t)));
- memcpy(tmp_val_fl_st,
- reinterpret_cast<val_flowlist_entry_st_t*>
- (drv_resp_val->get_val()),
- sizeof(val_flowlist_entry_st_t));
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowlistEntrySt,
- tmp_val_fl_st);
- drv_resp_val = drv_resp_val->get_next_cfg_val();
- if (!drv_resp_val) {
- break;
+ GET_USER_DATA_FLAGS(ckv_driver_req, db_flag);
+ // If vlink flag is not set at running and the operation is update
+ // then vlink is deleted in the update phase from UNC
+ // hence flowfilter seq no also should get deleted from controller
+ // hence sending the delete request to the controller driver
+ if (SET_FLAG_VLINK & db_flag) {
+ // Continue with further operations
+ } else {
+ if (UNC_OP_UPDATE == op1) {
+ op1 = UNC_OP_DELETE;
+ } else {
+ // No Vlink Configured, Configuration is not
+ // sent to driver
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ckv_audit_dup_db);
+ continue;
}
}
+
+ if (UNC_OP_UPDATE == op1) {
+ void *running_val = NULL;
+ bool invalid_attr = false;
+ running_val = GetVal(ckv_driver_req);
+ invalid_attr = FilterAttributes(running_val,
+ GetVal(ckv_audit_dup_db), false, UNC_OP_UPDATE);
+ if (invalid_attr) {
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ckv_audit_dup_db);
+ continue;
+ }
+ }
+ DELETE_IF_NOT_NULL(ckv_audit_dup_db);
+ upll_keytype_datatype_t dt_type = (op1 == UNC_OP_DELETE)?
+ UPLL_DT_AUDIT : UPLL_DT_RUNNING;
+
+ result_code = GetRenamedControllerKey(ckv_driver_req, UPLL_DT_RUNNING,
+ dmi, &ctrlr_dom);
+ if (result_code != UPLL_RC_SUCCESS && result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG(" GetRenamedControllerKey failed err code(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+
+
+ pfcdrv_val_flowfilter_entry_t *pfc_val = reinterpret_cast<pfcdrv_val_flowfilter_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(pfcdrv_val_flowfilter_entry_t)));
+
+ pfc_val->valid[PFCDRV_IDX_VAL_VBRIF_VEXTIF_FFE] = UNC_VF_VALID;
+ pfc_val->valid[PFCDRV_IDX_FLOWFILTER_ENTRY_FFE] = UNC_VF_VALID;
+ pfc_val->val_vbrif_vextif.valid[PFCDRV_IDX_INTERFACE_TYPE] = UNC_VF_VALID;
+ pfc_val->val_vbrif_vextif.interface_type = PFCDRV_IF_TYPE_VBRIF;
+
+ val_flowfilter_entry_t* val = reinterpret_cast<val_flowfilter_entry_t *>
+ (GetVal(ckv_driver_req));
+ memcpy(&pfc_val->val_ff_entry, val, sizeof(val_flowfilter_entry_t));
+
+ ckv_driver_req->SetCfgVal(new ConfigVal(IpctSt::kIpcStPfcdrvValFlowfilterEntry, pfc_val));
+
+ IpcResponse ipc_response;
+ memset(&ipc_response, 0, sizeof(IpcResponse));
+ IpcRequest ipc_req;
+ memset(&ipc_req, 0, sizeof(IpcRequest));
+ ipc_req.header.clnt_sess_id = session_id;
+ ipc_req.header.config_id = config_id;
+ ipc_req.header.operation = op1;
+ ipc_req.header.datatype = UPLL_DT_CANDIDATE;
+ ipc_req.ckv_data = ckv_driver_req;
+ if (!IpcUtil::SendReqToDriver((const char *)ctrlr_dom.ctrlr, reinterpret_cast<char *>
+ (ctrlr_dom.domain), PFCDRIVER_SERVICE_NAME,
+ PFCDRIVER_SVID_LOGICAL, &ipc_req, true, &ipc_response)) {
+ UPLL_LOG_INFO("Request to driver for Key %d for controller %s failed ",
+ ckv_driver_req->get_key_type(), reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (ipc_response.header.result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("driver return failure err_code is %d", ipc_response.header.result_code);
+ ConfigKeyVal *resp = NULL;
+
+ result_code = GetChildConfigKey(resp, ipc_response.ckv_data);
+ if (!resp || result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed for ipc response ckv err_code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ DELETE_IF_NOT_NULL(resp);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+
+ pfcdrv_val_flowfilter_entry_t *pfc_val_ff = reinterpret_cast<pfcdrv_val_flowfilter_entry_t *>
+ (GetVal(ipc_response.ckv_data));
+ if (NULL == pfc_val_ff) {
+ UPLL_LOG_DEBUG("pfcdrv_val_flowfilter_entry_t is NULL");
+ DELETE_IF_NOT_NULL(resp);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val_flowfilter_entry_t* val_ff = reinterpret_cast<val_flowfilter_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_t)));
+ memcpy(val_ff, &pfc_val_ff->val_ff_entry, sizeof(val_flowfilter_entry_t));
+ resp->AppendCfgVal(IpctSt::kIpcStValFlowfilterEntry, val_ff);
+ result_code = UpdateAuditConfigStatus(UNC_CS_INVALID, phase, resp);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("Update Audit config status failed %d",
+ result_code);
+ DELETE_IF_NOT_NULL(resp);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ DbSubOp dbop = { kOpNotRead, kOpMatchNone, kOpInOutCs };
+ result_code = UpdateConfigDB(resp, dt_type, UNC_OP_UPDATE,
+ dmi, &dbop,tbl);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed for ipc response ckv err_code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(resp);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(resp);
+
+ }
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ *ctrlr_affected = true;
}
- if (*okey == NULL) {
- *okey = tmp_okey;
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ if (uud::kDalRcSuccess != db_result) {
+ UPLL_LOG_DEBUG("GetNextRecord from database failed - %d", db_result);
+ result_code = DalToUpllResCode(db_result);
+ }
+ DELETE_IF_NOT_NULL(ckv_running_db);
+ DELETE_IF_NOT_NULL(ckv_audit_db);
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)
+ ? UPLL_RC_SUCCESS : result_code;
+ return result_code;
+}
+
+upll_rc_t VrtIfFlowFilterEntryMoMgr::SetValidAudit(ConfigKeyVal *&ikey) {
+ UPLL_FUNC_TRACE;
+ val_flowfilter_entry_t *val = reinterpret_cast
+ <val_flowfilter_entry_t *>(GetVal(ikey));
+ if (NULL == val) {
+ UPLL_LOG_DEBUG("val is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ for (unsigned int loop = 0;
+ loop < sizeof(val->valid) / sizeof(val->valid[0]);
+ ++loop) {
+ if (val->valid[loop] == UNC_VF_VALID) {
+ val->cs_attr[loop] = UNC_CS_APPLIED;
+ } else if (val->valid[loop] == UNC_VF_INVALID) {
+ val->cs_attr[loop] = UNC_CS_NOT_APPLIED;
+ }
+ }
+ val->cs_row_status = UNC_CS_APPLIED;
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VrtIfFlowFilterEntryMoMgr::CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id) {
+ UPLL_FUNC_TRACE;
+ uint8_t flags = 0;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_TRACE(" ikey is %s", ikey->ToStrAll().c_str());
+ uint8_t *controller_id = reinterpret_cast<uint8_t *>(
+ const_cast<char *>(ctrlr_id));
+
+ /* check if object is renamed in the corresponding Rename Tbl
+ * * if "renamed" create the object by the UNC name.
+ * * else - create using the controller name.
+ * */
+ result_code = GetRenamedUncKey(ikey, UPLL_DT_RUNNING, dmi, controller_id);
+ if (result_code != UPLL_RC_SUCCESS && result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey Failed err_code %d", result_code);
+ return result_code;
+ }
+
+ pfcdrv_val_flowfilter_entry_t *pfc_val =
+ reinterpret_cast<pfcdrv_val_flowfilter_entry_t *> (GetVal(ikey));
+ if (pfc_val == NULL) {
+ UPLL_LOG_DEBUG("Driver Structure Empty");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ if ( pfc_val->val_vbrif_vextif.interface_type == PFCDRV_IF_TYPE_VBRIF) {
+ flags = SET_FLAG_VLINK;
+ }
+ else {
+ flags = 0;
+ }
+
+ ConfigKeyVal *okey = NULL;
+ result_code = GetChildConfigKey(okey, ikey);
+ if (!okey || result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigkey Failed:%d", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+
+ val_flowfilter_entry_t * val_ff_entry = NULL;
+ val_ff_entry = reinterpret_cast<val_flowfilter_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_t)));
+
+ memcpy(val_ff_entry, &pfc_val->val_ff_entry, sizeof(val_flowfilter_entry_t));
+ okey->AppendCfgVal(IpctSt::kIpcStValFlowfilterEntry, val_ff_entry);
+ SET_USER_DATA_FLAGS(okey, flags);
+
+ controller_domain ctrlr_dom;
+ memset(&ctrlr_dom, 0, sizeof(ctrlr_dom));
+ result_code = GetControllerDomainID(okey, UPLL_DT_AUDIT, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get the Controller Domain details,err:%d",
+ result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+
+ GET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
+ UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
+ ctrlr_dom.ctrlr, ctrlr_dom.domain);
+
+ FlowListMoMgr *mgr = reinterpret_cast<FlowListMoMgr *>
+ (const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
+ if (mgr == NULL) {
+ UPLL_LOG_DEBUG("Invalid FlowListMoMgr Instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ if (pfc_val->val_ff_entry.valid[UPLL_IDX_FLOWLIST_NAME_FFE] == UNC_VF_VALID) {
+ result_code = mgr->AddFlowListToController(reinterpret_cast<char *>
+ (pfc_val->val_ff_entry.flowlist_name), dmi,
+ reinterpret_cast<char *> (const_cast<char *>(ctrlr_id)),
+ UPLL_DT_AUDIT,
+ UNC_OP_CREATE);
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Reference Count Updation Fails %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ }
+
+ UPLL_LOG_TRACE("ikey After GetRenamedUncKey %s", ikey->ToStrAll().c_str());
+ result_code = SetValidAudit(ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ result_code = UpdateConfigDB(okey, UPLL_DT_AUDIT, UNC_OP_CREATE, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigDB Failed err_code %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+}
+
+
+bool VrtIfFlowFilterEntryMoMgr::FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op) {
+ UPLL_FUNC_TRACE;
+ if (op != UNC_OP_CREATE)
+ return CompareValidValue(val1, val2, copy_to_running);
+ return false;
+}
+
+upll_rc_t VrtIfFlowFilterEntryMoMgr::UpdateConfigStatus(ConfigKeyVal *ikey,
+ unc_keytype_operation_t op,
+ uint32_t driver_result,
+ ConfigKeyVal *upd_key,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ctrlr_key) {
+ UPLL_FUNC_TRACE;
+ ConfigKeyVal * vrt_ffe_run_key = NULL;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_flowfilter_entry_t *ffe_val = NULL, *val_main = NULL;
+ unc_keytype_configstatus_t cs_status =
+ (driver_result == UPLL_RC_SUCCESS) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
+ ffe_val = reinterpret_cast<val_flowfilter_entry_t *>(GetVal(ikey));
+ if (ffe_val == NULL) return UPLL_RC_ERR_GENERIC;
+ if (op == UNC_OP_CREATE) {
+ ffe_val->cs_row_status = cs_status;
+ } else if (op == UNC_OP_UPDATE) {
+ result_code = GetChildConfigKey(vrt_ffe_run_key, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
+ result_code);
+ return result_code;
+ }
+ DbSubOp dbop_maintbl = { kOpReadSingle, kOpMatchNone,
+ kOpInOutFlag |kOpInOutCs };
+ result_code = ReadConfigDB(vrt_ffe_run_key, UPLL_DT_RUNNING ,
+ UNC_OP_READ, dbop_maintbl, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to read configuration from CandidateDb");
+ DELETE_IF_NOT_NULL(vrt_ffe_run_key);
+ return result_code;
+ }
+ val_main = reinterpret_cast
+ <val_flowfilter_entry_t *>(GetVal(vrt_ffe_run_key));
+ for (unsigned int loop = 0; loop < sizeof(val_main->valid)/
+ sizeof(val_main->valid[0]); ++loop) {
+ ffe_val->cs_attr[loop] = val_main->cs_attr[loop];
+ }
+ void *ffeval = reinterpret_cast<void *>(ffe_val);
+ CompareValidValue(ffeval, GetVal(vrt_ffe_run_key), true);
} else {
- (*okey)->AppendCfgKeyVal(tmp_okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_TRACE("%s",(ikey->ToStrAll()).c_str());
+ val_flowfilter_entry_t *ffe_val2 =
+ reinterpret_cast<val_flowfilter_entry_t *>(GetVal(upd_key));
+ if (UNC_OP_UPDATE == op) {
+ UPLL_LOG_TRACE("%s",(upd_key->ToStrAll()).c_str());
+ ffe_val->cs_row_status = ffe_val2->cs_row_status;
}
+ for (unsigned int loop = 0;
+ loop < sizeof(ffe_val->valid) / sizeof(ffe_val->valid[0]); ++loop) {
+ /* Setting CS to the not supported attributes*/
+ if (UNC_VF_NOT_SUPPORTED == ffe_val->valid[loop]) {
+ ffe_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
+ } else if ((UNC_VF_VALID == ffe_val->valid[loop])
+ || (UNC_VF_VALID_NO_VALUE == ffe_val->valid[loop])) {
+ ffe_val->cs_attr[loop] = cs_status;
+ } else if ((UNC_VF_INVALID == ffe_val->valid[loop]) &&
+ (UNC_OP_CREATE == op)) {
+ ffe_val->cs_attr[loop] = UNC_CS_NOT_APPLIED;
+ } else if ((UNC_VF_INVALID == ffe_val->valid[loop]) &&
+ (UNC_OP_UPDATE == op)) {
+ if (val_main->valid[loop] == UNC_VF_VALID) {
+ if (cs_status == UNC_CS_APPLIED) {
+ ffe_val->cs_attr[loop] = cs_status;
+ }
+ }
+ } else if ((UNC_VF_VALID == ffe_val->valid[loop]) &&
+ (UNC_OP_UPDATE == op)) {
+ if (cs_status == UNC_CS_APPLIED) {
+ ffe_val->cs_attr[loop] = UNC_CS_APPLIED;
+ }
+ }
+ if ((ffe_val->valid[loop] == UNC_VF_VALID_NO_VALUE)
+ &&(UNC_OP_UPDATE == op)) {
+ ffe_val->cs_attr[loop] = UNC_CS_UNKNOWN;
+ }
+ }
+ DELETE_IF_NOT_NULL(vrt_ffe_run_key);
+ return result_code;
+}
+
+upll_rc_t VrtIfFlowFilterEntryMoMgr::SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_flowfilter_entry_t *val_ffe = reinterpret_cast
+ <val_flowfilter_entry_t *>(GetVal(ikey));
+ if (!val_ffe) {
+ UPLL_LOG_DEBUG("Val is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigKeyVal *pkey = NULL;
+ if (UNC_OP_CREATE == req->operation) {
+ result_code = GetParentConfigKey(pkey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetParentConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_VRTIF_FLOWFILTER)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("mgr is NULL");
+ DELETE_IF_NOT_NULL(pkey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t rename = 0;
+ result_code = mgr->IsRenamed(pkey, req->datatype, dmi, rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(pkey);
+ return result_code;
+ }
+ UPLL_LOG_DEBUG("Flag from parent : %d", rename);
+ DELETE_IF_NOT_NULL(pkey);
+ // Check flowlist is renamed
+ if ((UNC_VF_VALID == val_ffe->valid[UPLL_IDX_FLOWLIST_NAME_FFE]) &&
+ ((UNC_OP_CREATE == req->operation))) {
+ ConfigKeyVal *fl_ckv = NULL;
+ result_code = GetFlowlistConfigKey(reinterpret_cast<const char *>
+ (val_ffe->flowlist_name), fl_ckv, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetFlowlistConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *fl_mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_FLOWLIST)));
+ if (NULL == fl_mgr) {
+ UPLL_LOG_DEBUG("fl_mgr is NULL");
+ DELETE_IF_NOT_NULL(fl_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t fl_rename = 0;
+ result_code = fl_mgr->IsRenamed(fl_ckv, req->datatype, dmi, fl_rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(fl_ckv);
+ return result_code;
+ }
+ if (fl_rename & 0x01) {
+ rename |= FLOW_RENAME; // TODO Check for correct flag value
+ }
+ DELETE_IF_NOT_NULL(fl_ckv);
+ }
+ SET_USER_DATA_FLAGS(ikey, rename);
+ } else if (UNC_OP_UPDATE == req->operation) {
+ uint8_t rename = 0;
+ ConfigKeyVal *dup_ckv = NULL;
+ result_code = GetChildConfigKey(dup_ckv, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG(" GetChildConfigKey failed");
+ return result_code;
+ }
+ DbSubOp dbop1 = {kOpReadSingle, kOpMatchNone, kOpInOutFlag};
+ result_code = ReadConfigDB(dup_ckv, req->datatype, UNC_OP_READ,
+ dbop1, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(dup_ckv);
+ return result_code;
+ }
+ GET_USER_DATA_FLAGS(dup_ckv, rename);
+ DELETE_IF_NOT_NULL(dup_ckv);
+ if (UNC_VF_VALID == val_ffe->valid[UPLL_IDX_FLOWLIST_NAME_FFE]) {
+ ConfigKeyVal *fl_ckv = NULL;
+ result_code = GetFlowlistConfigKey(reinterpret_cast<const char *>
+ (val_ffe->flowlist_name), fl_ckv, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetFlowlistConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *fl_mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_FLOWLIST)));
+ if (NULL == fl_mgr) {
+ UPLL_LOG_DEBUG("fl_mgr is NULL");
+ DELETE_IF_NOT_NULL(fl_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t fl_rename = 0;
+ result_code = fl_mgr->IsRenamed(fl_ckv, req->datatype, dmi, fl_rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(fl_ckv);
+ return result_code;
+ }
+ if (fl_rename & 0x01) {
+ rename |= FLOW_RENAME; // TODO Check for correct flag value
+ } else {
+ rename &= NO_FLOWLIST_RENAME;
+ /* reset flag*/
+ }
+ DELETE_IF_NOT_NULL(fl_ckv);
+ } else if (UNC_VF_VALID_NO_VALUE == val_ffe->valid
+ [UPLL_IDX_FLOWLIST_NAME_FFE]) {
+ rename &= NO_FLOWLIST_RENAME; // TODO Check for correct flag value. No rename flowlist value should be set
+ }
+ SET_USER_DATA_FLAGS(ikey, rename);
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VrtIfFlowFilterEntryMoMgr::GetFlowlistConfigKey(
+ const char *flowlist_name, ConfigKeyVal *&okey,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_FLOWLIST)));
+ result_code = mgr->GetChildConfigKey(okey, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
+ return result_code;
+ }
+ key_flowlist_t *okey_key = reinterpret_cast<key_flowlist_t *>
+ (okey->get_key());
+ uuu::upll_strncpy(okey_key->flowlist_name,
+ flowlist_name,
+ (kMaxLenFlowListName+1));
return UPLL_RC_SUCCESS;
}
} // namespace kt_momgr
* @Brief Member variable for VrtIFlowlistRenameBindInfo
*/
static BindInfo vrt_if_flowlist_rename_bind_info[];
-
+ uint32_t cur_instance_count;
public:
/**
* @brief Method used to fill the CongigKeyVal with the
* @retval UPLL_RC_SUCCESS Successfull completion.
* @retval UPLL_RC_ERR_GENERIC Return Failure
*/
- upll_rc_t GetRenamedControllerKey(ConfigKeyVal *&ikey,
+ upll_rc_t GetRenamedControllerKey(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
controller_domain *ctrlr_dom = NULL);
*
* @retval UPLL_RC_SUCCESS Successfull Completion
*/
- bool CompareValidValue(void *&val1, void *val2, bool audit);
+ bool CompareValidValue(void *&val1, void *val2, bool copy_to_running);
/**
* @brief Method used for ReadSibling Operation.
*
upll_rc_t ReadSiblingMo(IpcReqRespHeader *req, ConfigKeyVal *ikey,
bool begin, DalDmlIntf *dmi);
- /**
- * @brief Method used for ReadDetailEntry Operation.
- *
- * @param[in,out] ff_ckv Pointer to ConfigKeyVal Class.
- * @param[in] dt_type Describes Configiration Information.
- * @param[in] op Describes the Type of Opeartion.
- * @param[in] dbop Describes the dbop Type
- * @param[in] dmi Pointer to DalDmlIntf Class.
- * @param[in] domain_id Pointer to domain_id.
- * @param[in] dctrlr_id Pointer to ctrlr_id.
- *
- * @retval UPLL_RC_SUCCESS Successfull completion.
- * @retval UPLL_RC_ERR_GENERIC Returned Generic Error.
- */
-
- upll_rc_t ReadDetail(ConfigKeyVal *ikey,
- IpcResponse *ipc_response,
- upll_keytype_datatype_t dt_type,
- unc_keytype_operation_t op,
- DbSubOp dbop,
- DalDmlIntf *dmi);
/**
* @brief Method to check validity of Key
* @retval UPLL_RC_SUCCESS Successfull completion.
* @retval UPLL_RC_ERR_GENERIC Returned Generic Error.
*/
-
-
upll_rc_t GetParentConfigKey(ConfigKeyVal *&okey,
ConfigKeyVal *ikey);
+
+
/**
- * @brief Method used for ReadDetailEntry Operation.
+ * @brief Method used for Restoring FlowList in the Controller Table
*
- * @param[in,out] ff_ckv Pointer to ConfigKeyVal Class.
+ * @param[in] ikey Pointer to ConfigKeyVal Class
* @param[in] dt_type Describes Configiration Information.
- * @param[in] op Describes the Type of Opeartion.
- * @param[in] dbop Describes the dbop Type
+ * @param[in] tbl Describe the destination table
* @param[in] dmi Pointer to DalDmlIntf Class.
- * @param[in] domain_id Pointer to domain_id.
- * @param[in] dctrlr_id Pointer to ctrlr_id.
*
* @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_DB_ACCESS DB Read/Write error.
+ * @retval UPLL_RC_ERR_INSTANCE_EXISTS Record already exists
* @retval UPLL_RC_ERR_GENERIC Returned Generic Error.
*/
-
- upll_rc_t ReadDetailEntry(ConfigKeyVal *ff_ckv,
- upll_keytype_datatype_t dt_type,
- unc_keytype_operation_t op,
- DbSubOp dbop,
- DalDmlIntf *dmi);
+ upll_rc_t RestorePOMInCtrlTbl(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl,
+ DalDmlIntf* dmi);
upll_rc_t SetVlinkPortmapConfiguration(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
- InterfacePortMapInfo flag);
+ InterfacePortMapInfo flag,
+ unc_keytype_operation_t oper);
+
+ upll_rc_t TxVote(unc_key_type_t keytype,
+ DalDmlIntf *dmi,
+ ConfigKeyVal **err_ckv);
upll_rc_t TxUpdateController(unc_key_type_t keytype,
uint32_t session_id,
DalDmlIntf *dmi,
ConfigKeyVal **err_ckv);
+ upll_rc_t VerifyRedirectDestination(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t dt_type);
+
upll_rc_t GetControllerDomainID(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi);
upll_rc_t ConstructReadDetailResponse(ConfigKeyVal *ikey,
ConfigKeyVal *drv_resp_ckv,
- DalDmlIntf *dmi,
ConfigKeyVal **okey);
+ upll_rc_t DeleteChildrenPOM(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi);
+
+ upll_rc_t SetValidAudit(ConfigKeyVal *&ikey);
+
+
+ upll_rc_t CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id);
+
+ upll_rc_t AuditUpdateController(unc_key_type_t keytype,
+ const char *ctrlr_id,
+ uint32_t session_id,
+ uint32_t config_id,
+ uuc::UpdateCtrlrPhase phase,
+ bool *ctrlr_affected,
+ DalDmlIntf *dmi);
+
+ upll_rc_t UpdateVnodeVal(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t data_type,
+ bool &no_rename);
+
+ bool FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op);
+
+ upll_rc_t GetFlowlistConfigKey(
+ const char *flowlist_name, ConfigKeyVal *&okey,
+ DalDmlIntf *dmi);
+
+ upll_rc_t SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req);
+
VrtIfFlowFilterEntryMoMgr();
~VrtIfFlowFilterEntryMoMgr() {
for (int i = 0; i < ntable; i++) {
#include "unc/upll_errno.h"
#include "upll_validation.hh"
#include "unc/upll_ipc_enum.h"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "vrt_if_momgr.hh"
#include "vbr_momgr.hh"
namespace kt_momgr {
using unc::upll::ipc_util::IpcUtil;
-#define NUM_KEY_MAIN_TBL_ 5
#define FLOWLIST_RENAME_FLAG 0x04 // For 3rd Bit
#define VTN_RENAME_FLAG 0x01 // For first Bit
#define VRT_RENAME_FLAG 0x02 // For 2nd Bit
-#define SET_FLAG_VLINK 0x08
-
+#define SET_FLAG_VLINK 0x40
+#define SET_FLAG_NO_VLINK_PORTMAP 0x9F
//
// Vrt_If_FlowFilter Table(Main Table)
BindInfo VrtIfFlowFilterMoMgr::vrt_if_flowfilter_bind_info[] = {
{ uudst::vrt_if_flowfilter::kDbiVrtName, CFG_MATCH_KEY,
offsetof(key_vrt_if_flowfilter_t, if_key.vrt_key.vrouter_name),
uud::kDalChar, (kMaxLenVnodeName + 1) },
- { uudst::vrt_if_flowfilter::kDbiVrtIfName, CFG_MATCH_KEY,
- offsetof(key_vrt_if_flowfilter_t, if_key.if_name),
- uud::kDalChar, (kMaxLenInterfaceName + 1) },
- { uudst::vrt_if_flowfilter::kDbiInputDirection, CFG_MATCH_KEY,
- offsetof(key_vrt_if_flowfilter_t, direction),
- uud::kDalUint8, 1 },
{ uudst::vrt_if_flowfilter::kDbiVtnName, CFG_INPUT_KEY,
offsetof(key_rename_vnode_info_t, new_unc_vtn_name),
uud::kDalChar, (kMaxLenVtnName + 1) },
{ uudst::vrt_if_flowfilter::kDbiVrtName, CFG_INPUT_KEY,
offsetof(key_rename_vnode_info_t, new_unc_vnode_name),
uud::kDalChar, (kMaxLenVnodeName + 1) },
- { uudst::vrt_if_flowfilter::kDbiFlags, CFG_INPUT_KEY,
+ { uudst::vrt_if_flowfilter::kDbiFlags, CK_VAL,
offsetof(key_user_data_t, flags),
uud::kDalUint8, 1 }
};
// setting table index for ctrl and rename table as NULL
ntable = (MAX_MOMGR_TBLS);
table = new Table *[ntable];
-
+ cur_instance_count = 0;
table[MAINTBL] = new Table(uudst::kDbiVrtIfFlowFilterTbl,
UNC_KT_VRTIF_FLOWFILTER, vrt_if_flowfilter_bind_info,
IpctSt::kIpcStKeyVrtIfFlowfilter, IpctSt::kIpcStValFlowfilter,
ConfigKeyVal *ikey,
DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
+ ConfigKeyVal *temp_key = NULL;
+
if (ikey == NULL || req == NULL) {
return UPLL_RC_ERR_GENERIC;
}
+ UPLL_LOG_TRACE("InputConfigKeyVal %s", ikey->ToStrAll().c_str());
upll_rc_t result_code = UPLL_RC_SUCCESS;
// validate syntax and semantics
result_code = ValidateMessage(req, ikey);
if (result_code != UPLL_RC_SUCCESS) {
- pfc_log_debug("ValidateMessage failed, Error - %d", result_code);
+ UPLL_LOG_DEBUG("ValidateMessage failed, Error - %d", result_code);
return result_code;
}
-
result_code = ValidateAttribute(ikey, dmi, req);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ValidateAttribute failed, Error - %d", result_code);
|| result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
return result_code;
}
-
+ if (UPLL_DT_CANDIDATE == req->datatype) {
result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING,
UNC_OP_READ, dmi, MAINTBL);
if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
if (result_code != UPLL_RC_SUCCESS) {
return result_code;
}
- } else if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ }
+ }
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
// create a record in CANDIDATE DB
VrtIfMoMgr *mgr =
reinterpret_cast<VrtIfMoMgr *>(const_cast<MoManager *>(GetMoManager(
result_code = mgr->GetVexternal(ckv, req->datatype, dmi,
vexternal, vex_if, flags);
if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ckv);
+ FREE_IF_NOT_NULL(vexternal);
+ FREE_IF_NOT_NULL(vex_if);
return result_code;
}
- uint8_t flag_port_map;
+ uint8_t flag_port_map = 0;
+ GET_USER_DATA_FLAGS(ikey, flag_port_map);
if (flags & kVlinkConfigured) {
- flag_port_map = SET_FLAG_VLINK;
- } else {
- flag_port_map = 0;
+ flag_port_map = flag_port_map|SET_FLAG_VLINK;
}
free(vexternal);
free(vex_if);
+ DELETE_IF_NOT_NULL(ckv);
SET_USER_DATA_FLAGS(ikey, flag_port_map);
controller_domain ctrlr_dom;
UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
ctrlr_dom.ctrlr, ctrlr_dom.domain);
- result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_CREATE, dmi);
+ result_code = GetChildConfigKey(temp_key, NULL);
+ if(result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed in ValidateCapability");
return result_code;
- } else {
- pfc_log_error("Error in reading DB\n");
}
- return result_code;
-}
-
-
-upll_rc_t VrtIfFlowFilterMoMgr::UpdateAuditConfigStatus(
- unc_keytype_configstatus_t cs_status,
- uuc::UpdateCtrlrPhase phase,
- ConfigKeyVal *&ckv_running) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
-
- val_flowfilter_t *vrt_if_flowfilter_val = NULL;
- vrt_if_flowfilter_val = (ckv_running != NULL)?
- reinterpret_cast<val_flowfilter_t *> (GetVal(ckv_running)):NULL;
-
- if (NULL == vrt_if_flowfilter_val) {
- UPLL_LOG_DEBUG("UpdateAuditConfigStatus :: Memory Not Allocated");
- return UPLL_RC_ERR_GENERIC;
+ result_code = GetInstanceCount(temp_key,
+ reinterpret_cast<char*>(ctrlr_dom.ctrlr),
+ req->datatype,
+ &cur_instance_count,
+ dmi,
+ MAINTBL);
+ delete temp_key;
+ if(result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetInstanceCount Failed in ValidateCapability");
+ return result_code;
}
- if (uuc::kUpllUcpCreate == phase )
- vrt_if_flowfilter_val->cs_row_status = cs_status;
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(ctrlr_dom.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("validate Capability Failed %d", result_code);
+ return result_code;
+ }
- UPLL_LOG_DEBUG("Update Audit Config Status Successfull");
+ result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_CREATE, dmi);
+ return result_code;
+ } else {
+ UPLL_LOG_INFO("Error in reading DB");
+ }
return result_code;
}
+
upll_rc_t VrtIfFlowFilterMoMgr::IsReferenced(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi) {
} else {
result_code = UPLL_RC_SUCCESS;
}
+ if (UNC_OP_CREATE == req->operation) {
+ result_code = SetRenameFlag(ikey, dmi, req);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("SetRenameFlag failed %d", result_code);
+ return result_code;
+ }
+ }
delete okey;
okey = NULL;
return result_code;
}
+upll_rc_t VrtIfFlowFilterMoMgr::SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *pkey = NULL;
+ result_code = GetParentConfigKey(pkey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetParentConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_VRT_IF)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("mgr is NULL");
+ DELETE_IF_NOT_NULL(pkey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t rename = 0;
+ result_code = mgr->IsRenamed(pkey, req->datatype, dmi, rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(pkey);
+ return result_code;
+ }
+ UPLL_LOG_DEBUG("Flag from parent : %d", rename);
+ SET_USER_DATA_FLAGS(ikey, rename);
+ DELETE_IF_NOT_NULL(pkey);
+ return UPLL_RC_SUCCESS;
+}
+
+
bool VrtIfFlowFilterMoMgr::IsValidKey(void *key,
uint64_t index) {
UPLL_FUNC_TRACE;
}
upll_rc_t VrtIfFlowFilterMoMgr::GetRenamedControllerKey(
- ConfigKeyVal *&ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
+ ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
controller_domain *ctrlr_dom) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *okey = NULL;
uint8_t rename = 0;
IsRenamed(ikey, dt_type, dmi, rename);
- if (!rename) return UPLL_RC_SUCCESS;
+ if (!rename) {
+ UPLL_LOG_DEBUG("no renamed");
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_TRACE("Start... Input ConfigKeyVal %s",
+ ikey->ToStrAll().c_str());
+
+ MoMgrImpl *VrtMoMgr = reinterpret_cast<MoMgrImpl*>(const_cast<MoManager*>
+ (GetMoManager(UNC_KT_VROUTER)));
+ if (VrtMoMgr == NULL) {
+ UPLL_LOG_DEBUG("obj null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ result_code = VrtMoMgr->GetChildConfigKey(okey, NULL);
+ if ( result_code != UPLL_RC_SUCCESS ) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (ctrlr_dom) {
+ SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+ }
+ else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
+ strncpy(reinterpret_cast<char *>
+ (reinterpret_cast<key_vrt *>(okey->get_key())->vtn_key.vtn_name),
+ reinterpret_cast<const char *>
+ (reinterpret_cast<key_vrt_if_flowfilter_t *>
+ (ikey->get_key())->if_key.vrt_key.vtn_key.vtn_name),
+ kMaxLenVtnName + 1);
+ UPLL_LOG_DEBUG("vrt name (%s) (%s)",
+ reinterpret_cast<char *>
+ (reinterpret_cast<key_vrt *>(okey->get_key())->vtn_key.vtn_name),
+ reinterpret_cast<const char *>
+ (reinterpret_cast<key_vrt_if_flowfilter_t *>
+ (ikey->get_key())->if_key.vrt_key.vtn_key.vtn_name));
+
+ strncpy(reinterpret_cast<char *>
+ (reinterpret_cast<key_vrt *>(okey->get_key())->vrouter_name),
+ reinterpret_cast<const char *>
+ (reinterpret_cast<key_vrt_if_flowfilter_t *>
+ (ikey->get_key())->if_key.vrt_key.vrouter_name),
+ kMaxLenVtnName + 1);
+ UPLL_LOG_DEBUG("vrt name (%s) (%s)",
+ reinterpret_cast<char *>
+ (reinterpret_cast<key_vrt *>(okey->get_key())->vrouter_name),
+ reinterpret_cast<const char *>
+ (reinterpret_cast<key_vrt_if_flowfilter_t *>
+ (ikey->get_key())->if_key.vrt_key.vrouter_name));
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr | kOpMatchDomain, kOpInOutFlag };
+ /* ctrlr_name */
+ result_code = VrtMoMgr->ReadConfigDB(okey, dt_type, UNC_OP_READ,
+ dbop, dmi, RENAMETBL);
+ if ( result_code != UPLL_RC_SUCCESS ) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB no instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ // NULL Checks Missing
+ val_rename_vnode *rename_val = reinterpret_cast <val_rename_vnode *>
+ ((GetVal(okey)));
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("vrt Name is not Valid");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ if (rename & VTN_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("vtn name renamed");
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vrt_if_flowfilter_t*>
+ (ikey->get_key())->if_key.vrt_key.vtn_key.vtn_name,
+ rename_val->ctrlr_vtn_name,
+ (kMaxLenVtnName + 1));
+ }
+
+ if (rename & VRT_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("vrt name renamed");
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vrt_if_flowfilter_t*>
+ (ikey->get_key())->if_key.vrt_key.vrouter_name,
+ rename_val->ctrlr_vnode_name,
+ (kMaxLenVnodeName + 1));
+ }
+ DELETE_IF_NOT_NULL(okey);
+ UPLL_LOG_TRACE("End ... GetRenamedCtrl InputConfigKeyVal %s",
+ ikey->ToStrAll().c_str());
+ UPLL_LOG_DEBUG("GetRenamedControllerKey::Success");
+ return UPLL_RC_SUCCESS;
+#if 0
/* vtn renamed */
if (rename & VTN_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("vtn name renamed");
MoMgrImpl *VtnMoMgr = reinterpret_cast<MoMgrImpl*>(const_cast<MoManager*>
(GetMoManager(UNC_KT_VTN)));
if (VtnMoMgr == NULL) {
+ UPLL_LOG_DEBUG("obj null");
return UPLL_RC_ERR_GENERIC;
}
VtnMoMgr->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
- if (ctrlr_dom)
+ if (ctrlr_dom != NULL) {
SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
strncpy(reinterpret_cast<char *>
(reinterpret_cast<key_vtn *>(okey->get_key())->vtn_name),
(reinterpret_cast<key_vrt_if_flowfilter_t *>
(ikey->get_key())->if_key.vrt_key.vtn_key.vtn_name),
kMaxLenVtnName + 1);
-
+ UPLL_LOG_DEBUG("vtn name (%s) (%s)",
+ reinterpret_cast<char *>
+ (reinterpret_cast<key_vtn *>(okey->get_key())->vtn_name),
+ reinterpret_cast<const char *>
+ (reinterpret_cast<key_vrt_if_flowfilter_t *>
+ (ikey->get_key())->if_key.vrt_key.vtn_key.vtn_name));
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
/* ctrlr_name */
result_code = VtnMoMgr->ReadConfigDB(okey, dt_type, UNC_OP_READ,
dbop, dmi, RENAMETBL);
if ( result_code != UPLL_RC_SUCCESS ) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
// NULL Checks Missing
val_rename_vtn *rename_val = reinterpret_cast <val_rename_vtn *>
((GetVal(okey)));
- if (!rename_val
- || (rename_val->valid[UPLL_IDX_NEW_NAME_RVTN] != UNC_VF_VALID))
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("Vtn Name is not Valid.");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(
reinterpret_cast<key_vrt_if_flowfilter_t*>
(ikey->get_key())->if_key.vrt_key.vtn_key.vtn_name,
rename_val->new_name,
(kMaxLenVtnName + 1));
- SET_USER_DATA_FLAGS(ikey, VTN_RENAME);
- delete okey;
+ SET_USER_DATA_FLAGS(ikey, rename);
+ DELETE_IF_NOT_NULL(okey);
}
/*Vrouter_name*/
if (rename & VRT_RENAME_FLAG) {
+ UPLL_LOG_DEBUG("vrt name renamed");
MoMgrImpl *VrtMoMgr = reinterpret_cast<MoMgrImpl*>(const_cast<MoManager*>
(GetMoManager(UNC_KT_VROUTER)));
if (VrtMoMgr == NULL) {
+ UPLL_LOG_DEBUG("obj null");
return UPLL_RC_ERR_GENERIC;
}
result_code = VrtMoMgr->GetChildConfigKey(okey, ikey);
if ( result_code != UPLL_RC_SUCCESS ) {
- // delete okey;
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
return UPLL_RC_ERR_GENERIC;
}
- if (ctrlr_dom)
+ if (ctrlr_dom) {
SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+ }
+ else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
+ strncpy(reinterpret_cast<char *>
+ (reinterpret_cast<key_vrt *>(okey->get_key())->vtn_key.vtn_name),
+ reinterpret_cast<const char *>
+ (reinterpret_cast<key_vrt_if_flowfilter_t *>
+ (ikey->get_key())->if_key.vrt_key.vtn_key.vtn_name),
+ kMaxLenVtnName + 1);
+ UPLL_LOG_DEBUG("vrt name (%s) (%s)",
+ reinterpret_cast<char *>
+ (reinterpret_cast<key_vrt *>(okey->get_key())->vtn_key.vtn_name),
+ reinterpret_cast<const char *>
+ (reinterpret_cast<key_vrt_if_flowfilter_t *>
+ (ikey->get_key())->if_key.vrt_key.vtn_key.vtn_name));
strncpy(reinterpret_cast<char *>
(reinterpret_cast<key_vrt *>(okey->get_key())->vrouter_name),
(reinterpret_cast<key_vrt_if_flowfilter_t *>
(ikey->get_key())->if_key.vrt_key.vrouter_name),
kMaxLenVtnName + 1);
-
+ UPLL_LOG_DEBUG("vrt name (%s) (%s)",
+ reinterpret_cast<char *>
+ (reinterpret_cast<key_vrt *>(okey->get_key())->vrouter_name),
+ reinterpret_cast<const char *>
+ (reinterpret_cast<key_vrt_if_flowfilter_t *>
+ (ikey->get_key())->if_key.vrt_key.vrouter_name));
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
/* ctrlr_name */
result_code = VrtMoMgr->ReadConfigDB(okey, dt_type, UNC_OP_READ,
dbop, dmi, RENAMETBL);
if ( result_code != UPLL_RC_SUCCESS ) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
// NULL Checks Missing
- val_rename_vtn *rename_val = reinterpret_cast <val_rename_vtn *>
+ val_rename_vnode *rename_val = reinterpret_cast <val_rename_vnode *>
((GetVal(okey)));
- if (!rename_val
- || (rename_val->valid[UPLL_IDX_NEW_NAME_RVTN] != UNC_VF_VALID))
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("vrt Name is not Valid");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(
reinterpret_cast<key_vrt_if_flowfilter_t*>
(ikey->get_key())->if_key.vrt_key.vrouter_name,
- rename_val->new_name,
+ rename_val->ctrlr_vnode_name,
(kMaxLenVnodeName + 1));
- SET_USER_DATA_FLAGS(ikey, VTN_RENAME);
- // delete okey;
+ DELETE_IF_NOT_NULL(okey);
}
-
+ UPLL_LOG_TRACE("%s GetRenamedCtrl vrt_if_ff end", ikey->ToStrAll().c_str());
UPLL_LOG_DEBUG("GetRenamedControllerKey::GetRenamedControllerKey Success");
return UPLL_RC_SUCCESS;
+#endif
}
upll_rc_t VrtIfFlowFilterMoMgr::GetRenamedUncKey(
uint8_t *ctrlr_id) {
UPLL_FUNC_TRACE;
ConfigKeyVal *unc_key = NULL;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vrtifff start",
+ ikey->ToStrAll().c_str());
+ if ((NULL == ikey) || (ctrlr_id == NULL) || (NULL == dmi)) {
+ UPLL_LOG_DEBUG("ikey/ctrlr_id dmi NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
MoMgrImpl *VrtMoMgr = reinterpret_cast <MoMgrImpl *>(const_cast<MoManager*>
(GetMoManager(UNC_KT_VROUTER)));
if (VrtMoMgr == NULL) {
+ UPLL_LOG_DEBUG("VrtMoMgr NULL");
return UPLL_RC_ERR_GENERIC;
}
val_rename_vnode *rename_val = reinterpret_cast<val_rename_vnode*>
(ConfigKeyVal::Malloc(sizeof(val_rename_vnode)));
-
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("rename_val NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
key_vrt_if_flowfilter_t *ctrlr_key =
reinterpret_cast <key_vrt_if_flowfilter_t *>
(ikey->get_key());
+ if (!ctrlr_key) {
+ UPLL_LOG_DEBUG("rename_val NULL");
+ free(rename_val);
+ return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(rename_val->ctrlr_vtn_name,
ctrlr_key->if_key.vrt_key.vtn_key.vtn_name,
(kMaxLenVtnName + 1));
+ rename_val->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
+
uuu::upll_strncpy(rename_val->ctrlr_vnode_name,
ctrlr_key->if_key.vrt_key.vrouter_name,
(kMaxLenVnodeName + 1));
- VrtMoMgr->GetChildConfigKey(unc_key, NULL);
- if (ctrlr_id == NULL) {
- UPLL_LOG_DEBUG("GetRenamedUncKey::ctrlr_id is Null");
- delete unc_key;
+ rename_val->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_VALID;
+
+ result_code = VrtMoMgr->GetChildConfigKey(unc_key, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed To Get Child Config Key structure");
+ free(rename_val);
+ VrtMoMgr = NULL;
+ return result_code;
+ }
+ if (!unc_key) {
+ UPLL_LOG_DEBUG("unc_key NULL");
free(rename_val);
+ VrtMoMgr = NULL;
return UPLL_RC_ERR_GENERIC;
}
- unc_key->set_user_data(ctrlr_id);
+ SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
unc_key->AppendCfgVal(IpctSt::kIpcStValRenameVtn, rename_val);
- upll_rc_t result_code = VrtMoMgr->ReadConfigDB(unc_key, dt_type,
+ result_code = VrtMoMgr->ReadConfigDB(unc_key, dt_type,
UNC_OP_READ, dbop, dmi,
RENAMETBL);
if (result_code == UPLL_RC_SUCCESS) {
(kMaxLenVnodeName + 1));
}
- UPLL_LOG_DEBUG("GetRenamedUncKey::result_code %d", result_code);
- free(rename_val);
- delete unc_key;
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vbrifff end",
+ ikey->ToStrAll().c_str());
+ DELETE_IF_NOT_NULL(unc_key);
+ VrtMoMgr = NULL;
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code)
+ result_code = UPLL_RC_SUCCESS;
return result_code;
}
if (parent_key == NULL) {
vrt_if_ff_key = reinterpret_cast<key_vrt_if_flowfilter_t*>
(ConfigKeyVal::Malloc(sizeof(key_vrt_if_flowfilter_t)));
+ // If no direction is specified , 0xFE is filled to bind output direction
+ vrt_if_ff_key->direction = 0xFE;
okey = new ConfigKeyVal(UNC_KT_VRTIF_FLOWFILTER,
IpctSt::kIpcStKeyVrtIfFlowfilter,
vrt_if_ff_key, NULL);
if (okey) {
if (okey->get_key_type() != UNC_KT_VRTIF_FLOWFILTER)
return UPLL_RC_ERR_GENERIC;
+ }
+ if ((okey) && (okey->get_key())) {
vrt_if_ff_key = reinterpret_cast<key_vrt_if_flowfilter_t *>
(okey->get_key());
} else {
vrt_if_ff_key = reinterpret_cast<key_vrt_if_flowfilter_t *>
(ConfigKeyVal::Malloc(sizeof(key_vrt_if_flowfilter_t)));
+ // If no direction is specified , 0xFE is filled to bind output direction
+ vrt_if_ff_key->direction = 0xFE;
}
switch (parent_key->get_key_type()) {
return UPLL_RC_ERR_GENERIC;
}
+
+ if ((okey) && !(okey->get_key())) {
+ UPLL_LOG_DEBUG("okey not null and flow list name updated");
+ okey->SetKey(IpctSt::kIpcStKeyVrtIfFlowfilter, vrt_if_ff_key);
+ }
+
if (!okey) {
okey = new ConfigKeyVal(UNC_KT_VRTIF_FLOWFILTER,
IpctSt::kIpcStKeyVrtIfFlowfilter,
result_code = DupConfigKeyVal(l_key, ikey, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("DupConfigKeyVal fail in ReadMo for l_key");
+ delete dup_key;
return result_code;
}
GET_USER_DATA_CTRLR_DOMAIN(dup_key, ctrlr_dom);
SET_USER_DATA_CTRLR_DOMAIN(l_key, ctrlr_dom);
- // 1.Getting renamed name if renamed
+
+ // Added CapaCheck
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(ctrlr_dom.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("validate Capability Failed %d", result_code);
+ delete dup_key;
+ delete l_key;
+ return result_code;
+ }
+
+ // 1.Getting renamed name if renamed
result_code = GetRenamedControllerKey(l_key, req->datatype,
dmi, &ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
+ delete dup_key;
+ delete l_key;
return result_code;
}
GET_USER_DATA_FLAGS(dup_key, vlink_flag);
if (!(SET_FLAG_VLINK & vlink_flag)) {
UPLL_LOG_DEBUG("Vlink Not Configured");
+ delete dup_key;
+ delete l_key;
return UPLL_RC_ERR_NOT_ALLOWED_AT_THIS_TIME;
}
UPLL_LOG_DEBUG("SendReqToDriver failed for Key %d controller %s",
l_key->get_key_type(),
reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_DEBUG("Driver response for Key %d controller %s result %d",
l_key->get_key_type(), ctrlr_dom.ctrlr,
ipc_resp.header.result_code);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
return ipc_resp.header.result_code;
}
ConfigKeyVal *okey = NULL;
result_code = ConstructReadDetailResponse(dup_key,
ipc_resp.ckv_data,
- req->datatype,
- req->operation,
- dbop, dmi, &okey);
-
+ &okey);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(dup_key);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ConstructReadDetailResponse error code (%d)",
result_code);
} else {
if (okey != NULL) {
ikey->ResetWith(okey);
+ DELETE_IF_NOT_NULL(okey);
}
}
- DELETE_IF_NOT_NULL(dup_key);
- DELETE_IF_NOT_NULL(l_key);
}
break;
default:
+ UPLL_LOG_DEBUG("Operation Not Allowed");
result_code = UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
return result_code;
}
upll_rc_t VrtIfFlowFilterMoMgr::MergeValidate(unc_key_type_t keytype,
- const char *ctrlr_id,
- ConfigKeyVal *ikey,
- DalDmlIntf *dmi) {
+ const char *ctrlr_id,
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
- UPLL_LOG_DEBUG(" MergeValidate Success ");
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ckval = NULL;
+ if (NULL == ctrlr_id) {
+ UPLL_LOG_DEBUG("MergeValidate ctrlr_id NULL");
+ return result_code;
+ }
+
+ result_code = GetChildConfigKey(ckval, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey ckval NULL");
+ return result_code;
+ }
+
+ if (!ckval) return UPLL_RC_ERR_GENERIC;
+
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain};
+ result_code = ReadConfigDB(ckval, UPLL_DT_IMPORT,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ckval);
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ return result_code;
+ }
+ return UPLL_RC_SUCCESS;
+ }
+
+ while (NULL != ckval) {
+ result_code = UpdateConfigDB(ckval, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
+ MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ UPLL_LOG_DEBUG("Merge Conflict");
+ result_code = DupConfigKeyVal(ikey, ckval, MAINTBL);
+ DELETE_IF_NOT_NULL(ckval);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal fail");
+ return result_code;
+ }
+ return UPLL_RC_ERR_MERGE_CONFLICT;
+ } else if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ ckval = ckval->get_next_cfg_key_val();
+ } else {
+ UPLL_LOG_DEBUG("Merge Conflict DB err");
+ DELETE_IF_NOT_NULL(ckval);
+ return result_code;
+ }
+ }
+ DELETE_IF_NOT_NULL(ckval);
+ return UPLL_RC_SUCCESS;
}
upll_rc_t VrtIfFlowFilterMoMgr::ValidateCapability(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
if (!ctrlr_name) {
ctrlr_name = static_cast<char *>(ikey->get_user_data());
}
- uint32_t dt_type = req->datatype;
- uint32_t operation = req->operation;
- uint32_t option1 = req->option1;
- uint32_t option2 = req->option2;
UPLL_LOG_DEBUG("dt_type : (%d)"
- "operation : (%d)"
- "option1 : (%d)"
- "option2 : (%d)",
- dt_type, operation, option1, option2);
+ "operation : (%d)", req->datatype, req->operation);
bool result_code = false;
- uint32_t instance_count;
+ uint32_t max_instance_count;
const uint8_t *attrs = NULL;
uint32_t max_attrs = 0;
- if (operation == UNC_OP_CREATE) {
- result_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
- &instance_count, &max_attrs, &attrs);
- } else {
- result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ switch (req->operation) {
+ case UNC_OP_CREATE: {
+ result_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_instance_count, &max_attrs, &attrs);
+ if (result_code && cur_instance_count >= max_instance_count &&
+ cur_instance_count !=0 && max_instance_count != 0) {
+ UPLL_LOG_INFO("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
+ __LINE__, __FUNCTION__, cur_instance_count,
+ max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
+ break;
+ }
+ default : {
+ if (req->datatype == UPLL_DT_STATE) {
+ UPLL_LOG_TRACE("Calling GetStateCapability Operation %d ", req->operation);
+ result_code = GetStateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ } else {
+ UPLL_LOG_TRACE("Calling GetReadCapability Operation %d ", req->operation);
+ result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
&max_attrs, &attrs);
+ }
}
+ }
if (!result_code) {
UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s) "
"for opeartion(%d)",
- ikey->get_key_type(), ctrlr_name, operation);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ ikey->get_key_type(), ctrlr_name, req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
return UPLL_RC_SUCCESS;
}
UPLL_LOG_DEBUG(" Error: option1 is not NORMAL for ReadSiblingCount");
return UPLL_RC_ERR_INVALID_OPTION1;
}
-
+ if ((req->option1 == UNC_OPT1_DETAIL) &&
+ (req->datatype != UPLL_DT_STATE)) {
+ UPLL_LOG_DEBUG(" Invalid Datatype(%d)", req->datatype);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+ if ((req->datatype == UPLL_DT_IMPORT) && (req->operation == UNC_OP_READ ||
+ req->operation == UNC_OP_READ_SIBLING ||
+ req->operation == UNC_OP_READ_SIBLING_BEGIN ||
+ req->operation == UNC_OP_READ_NEXT ||
+ req->operation == UNC_OP_READ_BULK ||
+ req->operation == UNC_OP_READ_SIBLING_COUNT)) {
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+
/** Read key structure */
if (key->get_st_num() != IpctSt::kIpcStKeyVrtIfFlowfilter) {
UPLL_LOG_DEBUG("Invalid key structure received. received struct num - %d",
MoMgrTables tbl ) {
/* Main Table only update */
if (MAINTBL == tbl) {
- nattr = NUM_KEY_MAIN_TBL_;
+ nattr = sizeof(vrtIfflowfiltermaintbl_bind_info)/
+ sizeof(vrtIfflowfiltermaintbl_bind_info[0]);
binfo = vrtIfflowfiltermaintbl_bind_info;
}
UPLL_LOG_DEBUG(" GetRenameKeyBindInfo::Successful Completeion");
(ConfigKeyVal::Malloc(sizeof(key_vrt_if_flowfilter_t)));
if (!strlen(reinterpret_cast<char *> (key_rename->old_unc_vtn_name))) {
- UPLL_LOG_DEBUG("String Length not Valid to Perform the Operation");
- free(key_vrt_if);
+ UPLL_LOG_DEBUG("old_unc_vtn_name NULL");
+ if (key_vrt_if) free(key_vrt_if);
return UPLL_RC_ERR_GENERIC;
}
key_rename->old_unc_vtn_name,
(kMaxLenVtnName + 1));
- if (ikey->get_key_type() == table[MAINTBL]->get_key_type()) {
- if (!strlen(reinterpret_cast<char *> (key_rename->old_unc_vnode_name))) {
+ if (UNC_KT_VROUTER == ikey->get_key_type()) {
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vnode_name))) {
+ UPLL_LOG_DEBUG("old_unc_vnode_name NULL");
+ free(key_vrt_if);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(key_vrt_if->if_key.vrt_key.vrouter_name,
+ key_rename->old_unc_vnode_name, (kMaxLenVnodeName + 1));
+ } else {
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_unc_vnode_name))) {
+ UPLL_LOG_DEBUG("new_unc_vnode_name NULL");
free(key_vrt_if);
return UPLL_RC_ERR_GENERIC;
}
- uuu::upll_strncpy(key_vrt_if->if_key.vrt_key.vrouter_name,
- key_rename->old_unc_vnode_name,
- (kMaxLenVnodeName + 1));
+
+ uuu::upll_strncpy(key_vrt_if->if_key.vrt_key.vrouter_name,
+ key_rename->new_unc_vnode_name, (kMaxLenVnodeName + 1));
}
+ key_vrt_if->direction = 0xFE;
okey = new ConfigKeyVal(UNC_KT_VRTIF_FLOWFILTER, IpctSt::
kIpcStKeyVrtIfFlowfilter, key_vrt_if, NULL);
- if (!okey)
+ if (!okey) {
+ UPLL_LOG_DEBUG("okey NULL");
+ free(key_vrt_if);
return UPLL_RC_ERR_GENERIC;
-
+ }
UPLL_LOG_DEBUG("CopyToConfigKey is Success");
-
-return result_code;
+ return result_code;
}
-upll_rc_t VrtIfFlowFilterMoMgr::ReadDetail(ConfigKeyVal *ikey,
- ConfigKeyVal *dup_key,
- IpcResponse *ipc_response,
- upll_keytype_datatype_t dt_type,
- unc_keytype_operation_t op,
- DbSubOp dbop,
- DalDmlIntf *dmi) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
-
- ConfigVal *temp_cfg_val = NULL;
- temp_cfg_val = ipc_response->ckv_data->get_cfg_val();
- val_flowfilter_t* val_flowfilter = reinterpret_cast
- <val_flowfilter_t*>(GetVal(dup_key));
- if (val_flowfilter !=NULL) {
- ikey->AppendCfgVal(IpctSt::kIpcStValFlowfilter, val_flowfilter);
- }
- while (temp_cfg_val != NULL) {
- val_flowfilter_entry_st_t *val_entry_st = NULL;
- if (IpctSt::kIpcStValFlowfilterEntrySt == temp_cfg_val->get_st_num()) {
- val_entry_st = reinterpret_cast<val_flowfilter_entry_st_t *>
- (temp_cfg_val->get_val());
- } else {
- UPLL_LOG_DEBUG("Error Generic ");
- return UPLL_RC_ERR_GENERIC;
- }
-
- if ((val_entry_st)->valid[UPLL_IDX_SEQ_NUM_FFES] == UNC_VF_VALID) {
- ConfigKeyVal *tkey = NULL;
-
- struct key_vrt_if_flowfilter *key_if_flowfilter =
- reinterpret_cast<struct key_vrt_if_flowfilter *>(ikey->get_key());
-
- key_vrt_if_flowfilter_entry_t *key_vrt_if_flowfilter =
- reinterpret_cast<key_vrt_if_flowfilter_entry_t*>
- (ConfigKeyVal::Malloc(sizeof(key_vrt_if_flowfilter_entry_t)));
-
- ikey->AppendCfgVal(IpctSt::kIpcStValFlowfilterEntrySt, val_entry_st);
- tkey = new ConfigKeyVal(UNC_KT_VRTIF_FLOWFILTER_ENTRY,
- IpctSt::kIpcStKeyVrtIfFlowfilterEntry,
- key_vrt_if_flowfilter, NULL);
- key_vrt_if_flowfilter->sequence_num = (val_entry_st->sequence_num);
-
- uuu::upll_strncpy(
- key_vrt_if_flowfilter->flowfilter_key.if_key.vrt_key.vtn_key.vtn_name,
- key_if_flowfilter->if_key.vrt_key.vtn_key.vtn_name,
- (kMaxLenVtnName+1));
-
- uuu::upll_strncpy(
- key_vrt_if_flowfilter->flowfilter_key.if_key.vrt_key.vrouter_name,
- key_if_flowfilter->if_key.vrt_key.vrouter_name,
- (kMaxLenVnodeName+1));
-
- uuu::upll_strncpy(key_vrt_if_flowfilter->flowfilter_key.if_key.if_name,
- key_if_flowfilter->if_key.if_name,
- (kMaxLenInterfaceName+1));
-
- key_vrt_if_flowfilter->flowfilter_key.direction =
- key_if_flowfilter->direction;
-
- VrtIfFlowFilterEntryMoMgr *mgr =
- reinterpret_cast<VrtIfFlowFilterEntryMoMgr*>
- (const_cast<MoManager *>(GetMoManager
- (UNC_KT_VRTIF_FLOWFILTER_ENTRY)));
-
- result_code = mgr->ReadDetailEntry(tkey, dt_type, UNC_OP_READ, dbop, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("ReadDetailEntry Failed %d", result_code);
- delete tkey;
- return result_code;
- }
-
- val_flowfilter_entry_t *temp_val_flowfilter_entry =
- reinterpret_cast<val_flowfilter_entry_t *>(GetVal(tkey));
- // ikey->AppendCfgVal(IpctSt::kIpcStValFlowfilterEntrySt, val_entry_st);
- ikey->AppendCfgVal(IpctSt::kIpcStValFlowfilterEntry,
- temp_val_flowfilter_entry);
- if ((temp_cfg_val = temp_cfg_val->get_next_cfg_val()) == NULL) {
- UPLL_LOG_DEBUG("Next Vlaue structure is null\n");
- break;
- }
-
- while (IpctSt::kIpcStValFlowlistEntrySt ==
- (temp_cfg_val)->get_st_num()) {
- ikey->AppendCfgVal(IpctSt::kIpcStValFlowlistEntrySt,
- temp_cfg_val->get_val());
- temp_cfg_val = temp_cfg_val->get_next_cfg_val();
- if (temp_cfg_val == NULL) break;
- }
- } else {
- temp_cfg_val = temp_cfg_val->get_next_cfg_val();
- }
- }
- UPLL_LOG_DEBUG("ReadDetailEntry Success");
- return UPLL_RC_SUCCESS;
-}
upll_rc_t VrtIfFlowFilterMoMgr::ReadSiblingMo(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
result_code = ReadInfoFromDB(req, tctrl_key, dmi, &ctrlr_dom);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("ReadConfigDb failed for tctrl_key%d ", result_code);
+ DELETE_IF_NOT_NULL(tctrl_key);
return result_code;
}
result_code = DupConfigKeyVal(l_key, ikey, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("DupConfigKeyVal fail in ReadSiblingMo for l_key");
+ DELETE_IF_NOT_NULL(tctrl_key);
+ DELETE_IF_NOT_NULL(dup_key);
return result_code;
}
GET_USER_DATA_CTRLR_DOMAIN(dup_key, ctrlr_dom);
SET_USER_DATA_CTRLR_DOMAIN(l_key, ctrlr_dom);
+ // Adding CapaXheck
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(ctrlr_dom.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("validate Capability Failed %d", result_code);
+ DELETE_IF_NOT_NULL(tctrl_key);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ return result_code;
+ }
// 1.Getting renamed name if renamed
result_code = GetRenamedControllerKey(l_key, req->datatype,
dmi, &ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(tctrl_key);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
return result_code;
}
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG(" DupConfigKeyVal failed for flag_key %d ",
result_code);
+ DELETE_IF_NOT_NULL(tctrl_key);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
return result_code;
}
UNC_OP_READ, dbop2, dmi, MAINTBL);
if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
UPLL_LOG_DEBUG("No Recrods in the Vrt_If_FlowFilter_Entry Table");
+ DELETE_IF_NOT_NULL(tctrl_key);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(flag_key);
return UPLL_RC_SUCCESS;
}
GET_USER_DATA_FLAGS(flag_key, vlink_flag);
if (!(SET_FLAG_VLINK & vlink_flag)) {
UPLL_LOG_DEBUG("Vlink Not Configured");
+ DELETE_IF_NOT_NULL(tctrl_key);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(flag_key);
return UPLL_RC_ERR_NOT_ALLOWED_AT_THIS_TIME;
}
UPLL_LOG_DEBUG("SendReqToDriver failed for Key %d controller %s",
l_key->get_key_type(),
reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ DELETE_IF_NOT_NULL(tctrl_key);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(flag_key);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_DEBUG("Driver response for Key %d controller %s result %d",
l_key->get_key_type(), ctrlr_dom.ctrlr,
ipc_resp.header.result_code);
+ DELETE_IF_NOT_NULL(tctrl_key);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(flag_key);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
return ipc_resp.header.result_code;
}
result_code = ConstructReadDetailResponse(tmp_key,
ipc_resp.ckv_data,
- req->datatype,
- req->operation,
- dbop, dmi, &okey);
+ &okey);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ConstructReadDetailResponse error code (%d)",
result_code);
+ DELETE_IF_NOT_NULL(tctrl_key);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(flag_key);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
return result_code;
}
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
tmp_key = tmp_key->get_next_cfg_key_val();
}
if ((okey != NULL) && (result_code == UPLL_RC_SUCCESS)) {
ikey->ResetWith(okey);
+ DELETE_IF_NOT_NULL(okey);
}
DELETE_IF_NOT_NULL(l_key);
DELETE_IF_NOT_NULL(tctrl_key);
+ DELETE_IF_NOT_NULL(dup_key);
+ DELETE_IF_NOT_NULL(flag_key);
}
break;
default:
ConfigKeyVal **err_ckv) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- ConfigKeyVal *req, *nreq = NULL, *ck_main = NULL;
+ ConfigKeyVal *req = NULL, *nreq = NULL, *ck_main = NULL;
controller_domain_t ctrlr_dom;
ctrlr_dom.ctrlr = NULL;
ctrlr_dom.domain = NULL;
op1 = op;
result_code = DupConfigKeyVal(ck_main, req, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("DupConfigKeyVal failed %d\n", result_code);
+ UPLL_LOG_TRACE("DupConfigKeyVal failed %d", result_code);
return result_code;
}
break;
op1 = op;
result_code = GetChildConfigKey(ck_main, req);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("GetChildConfigKey failed %d\n", result_code);
+ UPLL_LOG_TRACE("GetChildConfigKey failed %d", result_code);
return result_code;
}
default:
break;
}
- /*if (op == UNC_OP_DELETE) {
- if (ck_main->get_cfg_val()) {
- UPLL_LOG_DEBUG("Invalid param\n");
+ if (NULL == ck_main) {
+ UPLL_LOG_DEBUG("ck_main is NULL");
return UPLL_RC_ERR_GENERIC;
- }
- DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone};
- result_code = ReadConfigDB(ck_main, UPLL_DT_RUNNING, UNC_OP_READ,
- dbop, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
- return UPLL_RC_ERR_GENERIC;
- }
- }*/
+ }
GET_USER_DATA_CTRLR_DOMAIN(ck_main, ctrlr_dom);
if (ctrlr_dom.ctrlr == NULL) {
+ DELETE_IF_NOT_NULL(ck_main);
return UPLL_RC_ERR_GENERIC;
}
if (!(SET_FLAG_VLINK & db_flag)) {
if (op1 != UNC_OP_UPDATE) {
+ DELETE_IF_NOT_NULL(ck_main);
continue;
}
ConfigKeyVal *temp = NULL;
result_code = GetChildConfigKey(temp, ck_main);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("GetChildConfigKey failed %d\n", result_code);
+ if (!temp || result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("GetChildConfigKey failed %d", result_code);
+ DELETE_IF_NOT_NULL(temp);
+ DELETE_IF_NOT_NULL(ck_main);
return result_code;
}
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr|kOpMatchDomain,
result_code = ReadConfigDB(temp, UPLL_DT_RUNNING, UNC_OP_READ,
dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ DELETE_IF_NOT_NULL(temp);
+ DELETE_IF_NOT_NULL(ck_main);
return UPLL_RC_ERR_GENERIC;
}
GET_USER_DATA_FLAGS(temp, flag);
if (!(SET_FLAG_VLINK & flag)) {
+ DELETE_IF_NOT_NULL(temp);
+ DELETE_IF_NOT_NULL(ck_main);
continue;
}
op1 = UNC_OP_DELETE;
-
+ DELETE_IF_NOT_NULL(temp);
} else {
if (UNC_OP_UPDATE == op1) {
ConfigKeyVal *temp = NULL;
result_code = GetChildConfigKey(temp, ck_main);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_TRACE("GetChildConfigKey failed %d\n", result_code);
+ UPLL_LOG_TRACE("GetChildConfigKey failed %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
return result_code;
}
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr|kOpMatchDomain,
result_code = ReadConfigDB(temp, UPLL_DT_RUNNING, UNC_OP_READ,
dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ DELETE_IF_NOT_NULL(temp);
+ DELETE_IF_NOT_NULL(ck_main);
return UPLL_RC_ERR_GENERIC;
}
GET_USER_DATA_FLAGS(temp, flag);
if (!(SET_FLAG_VLINK & flag)) {
op1 = UNC_OP_CREATE;
}
+ DELETE_IF_NOT_NULL(temp);
}
}
-
+ ConfigKeyVal *temp_ck_main = NULL;
+ result_code = DupConfigKeyVal(temp_ck_main, req, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed %d", result_code);
+ DELETE_IF_NOT_NULL(ck_main);
+ return result_code;
+ }
upll_keytype_datatype_t dt_type = (op1 == UNC_OP_DELETE)?
UPLL_DT_RUNNING:UPLL_DT_CANDIDATE;
result_code = GetRenamedControllerKey(ck_main, dt_type,
dmi, &ctrlr_dom);
- if (result_code != UPLL_RC_SUCCESS)
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(ck_main);
break;
+ }
pfcdrv_val_vbrif_vextif_t *pfc_val =
reinterpret_cast<pfcdrv_val_vbrif_vextif_t *>
result_code = UPLL_RC_SUCCESS;
}
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("IpcSend failed %d\n", result_code);
- *err_ckv = ipc_resp.ckv_data;
- if (ck_main)
- delete ck_main;
+ UPLL_LOG_DEBUG("IpcSend failed %d", result_code);
+ *err_ckv = temp_ck_main;
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(ck_main);
break;
}
- if (ck_main) {
- delete ck_main;
- ck_main = NULL;
- }
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(temp_ck_main);
+ DELETE_IF_NOT_NULL(ck_main);
}
dmi->CloseCursor(dal_cursor_handle, true);
- if (req)
- delete req;
- if (nreq)
- delete nreq;
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) ?
UPLL_RC_SUCCESS : result_code;
return result_code;
}
-upll_rc_t VrtIfFlowFilterMoMgr::SetVlinkPortmapConfiguration(ConfigKeyVal *ikey,
- upll_keytype_datatype_t dt_type,
- DalDmlIntf *dmi, InterfacePortMapInfo flags) {
+upll_rc_t VrtIfFlowFilterMoMgr::SetVlinkPortmapConfiguration(
+ ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi, InterfacePortMapInfo flags,
+ unc_keytype_operation_t oper) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
if (NULL == ikey || NULL == ikey->get_key()) {
return result_code;
}
key_vrt_if_flowfilter_t *ff_key = reinterpret_cast
- <key_vrt_if_flowfilter_t *>(ckv->get_key());
+ <key_vrt_if_flowfilter_t *>(ckv->get_key());
key_vrt_if_t *vrtif_key = reinterpret_cast<key_vrt_if_t *>(ikey->get_key());
uuu::upll_strncpy(ff_key->if_key.vrt_key.vtn_key.vtn_name,
- vrtif_key->vrt_key.vtn_key.vtn_name,
- kMaxLenVtnName + 1);
+ vrtif_key->vrt_key.vtn_key.vtn_name,
+ kMaxLenVtnName + 1);
uuu::upll_strncpy(ff_key->if_key.vrt_key.vrouter_name,
- vrtif_key->vrt_key.vrouter_name,
- kMaxLenVnodeName + 1);
+ vrtif_key->vrt_key.vrouter_name,
+ kMaxLenVnodeName + 1);
uuu::upll_strncpy(ff_key->if_key.if_name,
- vrtif_key->if_name,
- kMaxLenInterfaceName + 1);
+ vrtif_key->if_name,
+ kMaxLenInterfaceName + 1);
ff_key->direction = 0xFE;
DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutFlag };
- result_code = ReadConfigDB(ckv, dt_type ,
- UNC_OP_READ, dbop, dmi, MAINTBL);
+ result_code = ReadConfigDB(ckv, dt_type, UNC_OP_READ, dbop, dmi, MAINTBL);
if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
UPLL_LOG_DEBUG("No Recrods in the Vrt_If_FlowFilter Table");
+ DELETE_IF_NOT_NULL(ckv);
return UPLL_RC_SUCCESS;
}
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("Read ConfigDB failure %d", result_code);
- delete ckv;
+ DELETE_IF_NOT_NULL(ckv);
return result_code;
}
uint8_t flag_port_map = 0;
- while (ckv != NULL) {
- GET_USER_DATA_FLAGS(ckv, flag_port_map);
- if (flags & kVlinkConfigured) {
- flag_port_map |= SET_FLAG_VLINK;
- } else {
+ ConfigKeyVal *temp_ckv = ckv;
+ while (NULL != temp_ckv) {
flag_port_map = 0;
+ GET_USER_DATA_FLAGS(temp_ckv, flag_port_map);
+ if (flags & kVlinkConfigured) {
+ flag_port_map |= SET_FLAG_VLINK;
+ } else {
+ flag_port_map &= SET_FLAG_NO_VLINK_PORTMAP;
+ }
+ SET_USER_DATA_FLAGS(temp_ckv, flag_port_map);
+ DbSubOp dbop_update = { kOpReadSingle, kOpMatchNone, kOpInOutFlag };
+ result_code = UpdateConfigDB(temp_ckv, dt_type, UNC_OP_UPDATE,
+ dmi, &dbop_update, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ckv);
+ return result_code;
+ }
+ VrtIfFlowFilterEntryMoMgr *mgr =
+ reinterpret_cast<VrtIfFlowFilterEntryMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VRTIF_FLOWFILTER_ENTRY)));
+ if (mgr == NULL) {
+ DELETE_IF_NOT_NULL(ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_DEBUG("Sending vlink flag=%d for ff entry", flags);
+ result_code = mgr->SetVlinkPortmapConfiguration(ikey, dt_type, dmi, flags,
+ oper);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Unable to update vlink flag for flowfilterentry, err %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv);
+ return result_code;
+ }
+ temp_ckv = temp_ckv->get_next_cfg_key_val();
}
- uint8_t rename_flag = 0;
- GET_USER_DATA_FLAGS(ckv, rename_flag);
- rename_flag |= flag_port_map;
- DbSubOp dbop_update = { kOpReadSingle, kOpMatchNone, kOpInOutFlag };
- SET_USER_DATA_FLAGS(ckv, flag_port_map);
- result_code = UpdateConfigDB(ckv, dt_type, UNC_OP_UPDATE,
- dmi, &dbop_update, MAINTBL);
- if (UPLL_RC_SUCCESS != result_code) {
- return result_code;
- }
- VrtIfFlowFilterEntryMoMgr *mgr =
- reinterpret_cast<VrtIfFlowFilterEntryMoMgr *>
- (const_cast<MoManager *>(GetMoManager(UNC_KT_VRTIF_FLOWFILTER_ENTRY)));
- if (mgr == NULL) {
- return UPLL_RC_ERR_GENERIC;
- }
-
- result_code = mgr->SetVlinkPortmapConfiguration(ikey, dt_type, dmi, flags);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("Unable to update vlink flag for flowfilterentry, err %d",
- result_code);
- return result_code;
- }
-
- ckv = ckv->get_next_cfg_key_val();
- }
+ DELETE_IF_NOT_NULL(ckv);
return UPLL_RC_SUCCESS;
}
UPLL_LOG_DEBUG(" Input Key is NULL");
return UPLL_RC_ERR_GENERIC;
}
-
+ DELETE_IF_NOT_NULL(okey);
unc_key_type_t ikey_type = ikey->get_key_type();
if (ikey_type != UNC_KT_VRTIF_FLOWFILTER) {
UPLL_LOG_DEBUG(" Invalid key type received. Key type - %d", ikey_type);
upll_rc_t VrtIfFlowFilterMoMgr::ConstructReadDetailResponse(
ConfigKeyVal *ikey,
ConfigKeyVal *drv_resp_ckv,
- upll_keytype_datatype_t dt_type,
- unc_keytype_operation_t op,
- DbSubOp dbop,
- DalDmlIntf *dmi,
ConfigKeyVal **okey) {
UPLL_FUNC_TRACE;
ConfigKeyVal *tmp_okey = NULL;
(GetVal(ikey));
if (!tmp_val_ff) {
UPLL_LOG_DEBUG(" Invalid value read from DB");
- delete tmp_okey;
+ DELETE_IF_NOT_NULL(tmp_okey);
free(val_ff);
return UPLL_RC_ERR_GENERIC;
}
memcpy(val_ff, tmp_val_ff, sizeof(val_flowfilter_t));
tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowfilter, val_ff);
+ tmp_okey->AppendCfgVal(drv_resp_ckv->GetCfgValAndUnlink());
- ConfigVal *drv_resp_val = NULL;
- drv_resp_val = drv_resp_ckv->get_cfg_val();
- while (drv_resp_val != NULL) {
- val_flowfilter_entry_st_t *val_ffe_st = NULL;
- if (IpctSt::kIpcStValFlowfilterEntrySt == drv_resp_val->get_st_num()) {
- val_ffe_st = reinterpret_cast<val_flowfilter_entry_st_t *>
- (drv_resp_val->get_val());
- } else {
- UPLL_LOG_DEBUG("Incorrect structure received from driver, struct num %d",
- drv_resp_val->get_st_num());
- return UPLL_RC_ERR_GENERIC;
- }
+ if (*okey == NULL) {
+ *okey = tmp_okey;
+ } else {
+ (*okey)->AppendCfgKeyVal(tmp_okey);
+ }
+ return UPLL_RC_SUCCESS;
+}
- if ((val_ffe_st)->valid[UPLL_IDX_SEQ_NUM_FFES] == UNC_VF_VALID) {
- ConfigKeyVal *tmp_ffe_key = NULL;
+upll_rc_t VrtIfFlowFilterMoMgr::CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id) {
+ UPLL_FUNC_TRACE;
+ uint8_t flags = 0;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_TRACE(" ikey is %s", ikey->ToStrAll().c_str());
+ uint8_t *controller_id = reinterpret_cast<uint8_t *>(
+ const_cast<char *>(ctrlr_id));
+
+ /* check if object is renamed in the corresponding Rename Tbl
+ * if "renamed" create the object by the UNC name.
+ * else - create using the controller name.
+ */
+ result_code = GetRenamedUncKey(ikey, UPLL_DT_RUNNING, dmi, controller_id);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey Failed err_code %d", result_code);
+ return result_code;
+ }
- key_vrt_if_flowfilter_t *key_vrtif_ff =
- reinterpret_cast<key_vrt_if_flowfilter_t*>(ikey->get_key());
+ UPLL_LOG_DEBUG("GetRenamed UncKey Passed");
+ pfcdrv_val_vbrif_vextif_t *pfc_val =
+ reinterpret_cast<pfcdrv_val_vbrif_vextif_t *> (GetVal(ikey));
- key_vrt_if_flowfilter_entry_t *key_vrtif_ffe =
- reinterpret_cast<key_vrt_if_flowfilter_entry_t*>
- (ConfigKeyVal::Malloc(sizeof(key_vrt_if_flowfilter_entry_t)));
- tmp_ffe_key = new ConfigKeyVal(UNC_KT_VRTIF_FLOWFILTER_ENTRY,
- IpctSt::kIpcStKeyVrtIfFlowfilterEntry,
- key_vrtif_ffe, NULL);
- key_vrtif_ffe->sequence_num = val_ffe_st->sequence_num;
- uuu::upll_strncpy(
- key_vrtif_ffe->flowfilter_key.if_key.vrt_key.vtn_key.vtn_name,
- key_vrtif_ff->if_key.vrt_key.vtn_key.vtn_name,
- (kMaxLenVtnName+1));
+ if (pfc_val == NULL) {
+ UPLL_LOG_DEBUG("Val Structure is EWmpty");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ if (pfc_val->interface_type == PFCDRV_IF_TYPE_VBRIF) {
+ flags = SET_FLAG_VLINK;
+ }
+ else {
+ flags = 0;
+ }
- uuu::upll_strncpy(
- key_vrtif_ffe->flowfilter_key.if_key.vrt_key.vrouter_name,
- key_vrtif_ff->if_key.vrt_key.vrouter_name,
- (kMaxLenVnodeName+1));
-
- uuu::upll_strncpy(key_vrtif_ffe->flowfilter_key.if_key.if_name,
- key_vrtif_ff->if_key.if_name,
- (kMaxLenInterfaceName +1));
-
- key_vrtif_ffe->flowfilter_key.direction =
- (reinterpret_cast<key_vrt_if_flowfilter*>
- (ikey->get_key()))->direction;
-
- VrtIfFlowFilterEntryMoMgr *mgr =
- reinterpret_cast<VrtIfFlowFilterEntryMoMgr*>
- (const_cast<MoManager *>(GetMoManager
- (UNC_KT_VRTIF_FLOWFILTER_ENTRY)));
- result_code = mgr->ReadDetailEntry(tmp_ffe_key, dt_type,
- UNC_OP_READ, dbop, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(" flowfilter entry read detail error (%d)", result_code);
- delete tmp_ffe_key;
- return result_code;
- }
+ ConfigKeyVal *okey = NULL;
+ result_code = GetChildConfigKey(okey, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed");
+ return result_code;
+ }
- val_flowfilter_entry_st_t *tmp_ffe_st =
- reinterpret_cast<val_flowfilter_entry_st_t* >
- (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_st_t)));
- memcpy(tmp_ffe_st, val_ffe_st, sizeof(val_flowfilter_entry_st_t));
+ SET_USER_DATA_FLAGS(okey, flags);
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowfilterEntrySt, tmp_ffe_st);
- val_flowfilter_entry_t* tmp_val_ffe =
- reinterpret_cast <val_flowfilter_entry_t*>
- (ConfigKeyVal::Malloc(sizeof(val_flowfilter_entry_t)));
- memcpy(tmp_val_ffe,
- reinterpret_cast<val_flowfilter_entry_t*>
- (tmp_ffe_key->get_cfg_val()->get_val()),
- sizeof(val_flowfilter_entry_t));
+ controller_domain ctrlr_dom;
+ memset(&ctrlr_dom, 0, sizeof(controller_domain));
+ result_code = GetControllerDomainID(okey, UPLL_DT_AUDIT, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Failed to Get the Controller Domain details,err:%d",
+ result_code);
+ }
+ GET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
+ UPLL_LOG_DEBUG("ctrlrid %s, domainid %s",
+ ctrlr_dom.ctrlr, ctrlr_dom.domain);
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowfilterEntry, tmp_val_ffe);
+ // Create a record in AUDIT DB
+ result_code = UpdateConfigDB(okey, UPLL_DT_AUDIT, UNC_OP_CREATE, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigDB Failed err_code %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+}
- delete tmp_ffe_key;
- tmp_ffe_key = NULL;
+upll_rc_t VrtIfFlowFilterMoMgr::UpdateAuditConfigStatus(
+ unc_keytype_configstatus_t cs_status,
+ uuc::UpdateCtrlrPhase phase,
+ ConfigKeyVal *&ckv_running) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
- if ((drv_resp_val = drv_resp_val->get_next_cfg_val()) == NULL) {
- UPLL_LOG_DEBUG("No more entries in driver response\n");
- break;
- }
+ val_flowfilter_t *val = NULL;
+ val = (ckv_running != NULL)?
+ reinterpret_cast<val_flowfilter_t *> (GetVal(ckv_running)):NULL;
- if (IpctSt::kIpcStValFlowlistEntrySt != drv_resp_val->get_st_num()) {
- UPLL_LOG_DEBUG("No flowflist entries returned by driver");
+ if (NULL == val) {
+ UPLL_LOG_DEBUG("UpdateAuditConfigStatus :: Memory Not Allocated");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (uuc::kUpllUcpCreate == phase )
+ val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
+
+ UPLL_LOG_DEBUG("Update Audit Config Status Successfull");
+ return result_code;
+}
+
+upll_rc_t VrtIfFlowFilterMoMgr::AuditUpdateController(unc_key_type_t keytype,
+ const char *ctrlr_id,
+ uint32_t session_id,
+ uint32_t config_id,
+ uuc::UpdateCtrlrPhase phase,
+ bool *ctrlr_affected,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ DalResultCode db_result = uud::kDalRcSuccess;
+ MoMgrTables tbl = MAINTBL;
+ controller_domain_t ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ ConfigKeyVal *ckv_running_db = NULL;
+ ConfigKeyVal *ckv_audit_db = NULL;
+ ConfigKeyVal *ckv_driver_req = NULL;
+ ConfigKeyVal *ckv_audit_dup_db = NULL;
+ DalCursor *cursor = NULL;
+ uint8_t db_flag = 0;
+ // uint8_t flag = 0;
+ uint8_t *ctrlr = reinterpret_cast<uint8_t *>(const_cast<char *>(ctrlr_id));
+ /* decides whether to retrieve from controller table or main table */
+ GET_TABLE_TYPE(keytype, tbl);
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutCtrlr | kOpInOutDomain};
+ unc_keytype_operation_t op = (phase == uuc::kUpllUcpCreate)?UNC_OP_CREATE:
+ ((phase == uuc::kUpllUcpUpdate)?UNC_OP_UPDATE:
+ ((phase == uuc::kUpllUcpDelete)?UNC_OP_DELETE:UNC_OP_INVALID));
+
+ unc_keytype_operation_t op1 = op;
+ if (phase == uuc::kUpllUcpDelete2)
+ return result_code;
+ /* retreives the delta of running and audit configuration */
+ UPLL_LOG_DEBUG("Operation is %d", op);
+ result_code = DiffConfigDB(UPLL_DT_RUNNING, UPLL_DT_AUDIT, op,
+ ckv_running_db, ckv_audit_db,
+ &cursor, dmi, ctrlr, tbl);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DiffConfigDB failed - %d", result_code);
+ return result_code;
+ }
+ while (uud::kDalRcSuccess == (db_result = dmi->GetNextRecord(cursor))) {
+ op1 = op;
+ if (phase != uuc::kUpllUcpDelete) {
+ uint8_t *db_ctrlr = NULL;
+ GET_USER_DATA_CTRLR(ckv_running_db,db_ctrlr);
+ UPLL_LOG_DEBUG("db ctrl_id and audit ctlr_id are %s %s",
+ db_ctrlr, ctrlr_id);
+ // Skipping the controller ID if the controller id in DB and
+ // controller id available for Audit are not the same
+ if (db_ctrlr && strncmp(reinterpret_cast<const char *>(db_ctrlr),
+ reinterpret_cast<const char *>(ctrlr_id),
+ strlen(reinterpret_cast<const char *>(ctrlr_id)) + 1)) {
continue;
}
- while (IpctSt::kIpcStValFlowlistEntrySt == drv_resp_val->get_st_num()) {
- val_flowlist_entry_st_t* tmp_val_fl_st =
- reinterpret_cast<val_flowlist_entry_st_t*>
- (ConfigKeyVal::Malloc(sizeof(val_flowlist_entry_st_t)));
- memcpy(tmp_val_fl_st, reinterpret_cast<val_flowlist_entry_st_t*>
- (drv_resp_val->get_val()),
- sizeof(val_flowlist_entry_st_t));
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowlistEntrySt, tmp_val_fl_st);
- drv_resp_val = drv_resp_val->get_next_cfg_val();
- if (!drv_resp_val) {
- break;
+ }
+
+ switch (phase) {
+ case uuc::kUpllUcpDelete:
+ UPLL_LOG_TRACE("Deleted record is %s ",
+ ckv_running_db->ToStrAll().c_str());
+ result_code = GetChildConfigKey(ckv_driver_req, ckv_running_db);
+ if (!ckv_driver_req || result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed. err_code & phase %d %d",
+ result_code, phase);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ UPLL_LOG_TRACE("ckv_driver_req in delete is %s",
+ ckv_driver_req->ToStrAll().c_str())
+ if (ckv_driver_req->get_cfg_val()) {
+ UPLL_LOG_DEBUG("Invalid param");
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
}
+ result_code = ReadConfigDB(ckv_driver_req, UPLL_DT_AUDIT, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d",result_code);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ break;
+ case uuc::kUpllUcpCreate:
+ UPLL_LOG_TRACE("Created record is %s ",
+ ckv_running_db->ToStrAll().c_str());
+ result_code = DupConfigKeyVal(ckv_driver_req, ckv_running_db, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed. err_code & phase %d %d",
+ result_code, phase);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ break;
+ case uuc::kUpllUcpUpdate:
+ ckv_audit_dup_db = NULL;
+ ckv_driver_req = NULL;
+ UPLL_LOG_TRACE("UpdateRecord running DB record is %s ",
+ ckv_running_db->ToStrAll().c_str());
+ UPLL_LOG_TRACE("UpdateRecord AuditDB record is %s ",
+ ckv_audit_db->ToStrAll().c_str());
+ result_code = DupConfigKeyVal(ckv_driver_req, ckv_running_db, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed for running record. \
+ err_code & phase %d %d", result_code, phase);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ result_code = DupConfigKeyVal(ckv_audit_dup_db, ckv_audit_db, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed for audit record. \
+ err_code & phase %d %d", result_code, phase);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ break;
+ default:
+ UPLL_LOG_DEBUG("Invalid operation %d", phase);
+ return UPLL_RC_ERR_NO_SUCH_OPERATION;
+ break;
+ }
+ if (!ckv_driver_req) return UPLL_RC_ERR_GENERIC;
+ GET_USER_DATA_CTRLR_DOMAIN(ckv_driver_req, ctrlr_dom);
+ if ((NULL == ctrlr_dom.ctrlr) || (NULL == ctrlr_dom.domain)) {
+ UPLL_LOG_INFO("controller id or domain is NULL");
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ckv_audit_dup_db);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+ db_flag = 0;
+ GET_USER_DATA_FLAGS(ckv_driver_req, db_flag);
+
+ // If vlink flag is not set at running and the operation is update
+ // then vlink is deleted in the update phase from UNC
+ // hence flowfilter also should get deleted from controller
+ // hence sending the delete request to the controller driver
+ if ((SET_FLAG_VLINK & db_flag)) {
+ // Continue the operations
+ } else {
+ if (UNC_OP_UPDATE == op1) {
+ op1 = UNC_OP_DELETE;
+ } else {
+ // No Vlink Configured,Configuration is not
+ // sent to the driver of the controller.
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ckv_audit_dup_db);
+ continue;
+ }
+ }
+ if (UNC_OP_UPDATE == op1) {
+ void *running_val = NULL;
+ bool invalid_attr = false;
+ running_val = GetVal(ckv_running_db);
+ invalid_attr = FilterAttributes(running_val,
+ GetVal(ckv_audit_dup_db), false, UNC_OP_UPDATE);
+ if (invalid_attr) {
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ckv_audit_dup_db);
+ continue;
}
}
+ DELETE_IF_NOT_NULL(ckv_audit_dup_db);
+ upll_keytype_datatype_t dt_type = (op1 == UNC_OP_DELETE)?
+ UPLL_DT_AUDIT : UPLL_DT_RUNNING;
+
+ result_code = GetRenamedControllerKey(ckv_driver_req, UPLL_DT_RUNNING,
+ dmi, &ctrlr_dom);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG(" GetRenamedControllerKey failed err code(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+
+ pfcdrv_val_vbrif_vextif_t *pfc_val =
+ reinterpret_cast<pfcdrv_val_vbrif_vextif_t *>
+ (ConfigKeyVal::Malloc(sizeof(pfcdrv_val_vbrif_vextif_t)));
+
+ pfc_val->valid[PFCDRV_IDX_INTERFACE_TYPE] = UNC_VF_VALID;
+ pfc_val->valid[PFCDRV_IDX_VEXTERNAL_NAME_VBRIF] = UNC_VF_INVALID;
+ pfc_val->valid[PFCDRV_IDX_VEXT_IF_NAME_VBRIF] = UNC_VF_INVALID;
+ pfc_val->interface_type = PFCDRV_IF_TYPE_VBRIF;
+
+ ckv_driver_req->SetCfgVal(new ConfigVal(IpctSt::kIpcStPfcdrvValVbrifVextif, pfc_val));
+
+ IpcResponse ipc_response;
+ memset(&ipc_response, 0, sizeof(IpcResponse));
+ IpcRequest ipc_req;
+ memset(&ipc_req, 0, sizeof(IpcRequest));
+ ipc_req.header.clnt_sess_id = session_id;
+ ipc_req.header.config_id = config_id;
+ ipc_req.header.operation = op1;
+ ipc_req.header.datatype = UPLL_DT_CANDIDATE;
+ ipc_req.ckv_data = ckv_driver_req;
+ if (!IpcUtil::SendReqToDriver((const char *)ctrlr_dom.ctrlr, reinterpret_cast<char *>
+ (ctrlr_dom.domain), PFCDRIVER_SERVICE_NAME,
+ PFCDRIVER_SVID_LOGICAL, &ipc_req, true, &ipc_response)) {
+ UPLL_LOG_INFO("Request to driver for Key %d for controller %s failed ",
+ ckv_driver_req->get_key_type(), reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (ipc_response.header.result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("driver return failure err_code is %d", ipc_response.header.result_code);
+ ConfigKeyVal *resp = NULL;
+
+ result_code = GetChildConfigKey(resp, ipc_response.ckv_data);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed for ipc response ckv err_code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
+ result_code = ReadConfigDB(resp, dt_type, UNC_OP_READ, dbop,dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ReadConfigDB Failed");
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+
+ result_code = UpdateAuditConfigStatus(UNC_CS_INVALID, phase, resp);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("Update Audit config status failed %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ DbSubOp dbop1 = { kOpNotRead, kOpMatchNone, kOpInOutCs };
+ result_code = UpdateConfigDB(resp, dt_type, UNC_OP_UPDATE,
+ dmi, &dbop1, tbl);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed for ipc response ckv err_code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(resp);
+ }
+ DELETE_IF_NOT_NULL(ckv_driver_req);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ *ctrlr_affected = true;
}
- if (*okey == NULL) {
- *okey = tmp_okey;
- } else {
- (*okey)->AppendCfgKeyVal(tmp_okey);
+
+ if (cursor)
+ dmi->CloseCursor(cursor, true);
+ if (uud::kDalRcSuccess != db_result) {
+ UPLL_LOG_DEBUG("GetNextRecord from database failed - %d", db_result);
+ result_code = DalToUpllResCode(db_result);
+ }
+
+ DELETE_IF_NOT_NULL(ckv_running_db);
+ DELETE_IF_NOT_NULL(ckv_audit_db);
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)
+ ? UPLL_RC_SUCCESS : result_code;
+ return result_code;
+}
+
+upll_rc_t VrtIfFlowFilterMoMgr::DeleteChildrenPOM(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+
+ if (NULL == ikey || NULL == dmi) {
+ UPLL_LOG_DEBUG("Delete Operation failed:Bad request");
+ return result_code;
+ }
+ // Read the DB get the flowlist value and send the delete request to
+ // flowlist momgr if flowlist is configured.
+
+ ConfigKeyVal *tempckv = NULL;
+ result_code = GetChildConfigKey(tempckv, ikey);
+ if (!tempckv || UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(tempckv);
+ return result_code;
}
+ result_code = UpdateConfigDB(tempckv, dt_type, UNC_OP_DELETE, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("UPLL_RC_ERR_NO_SUCH_INSTANCE");
+ DELETE_IF_NOT_NULL(tempckv);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("DeleteMo record Err in vtnpolicingmaptbl (%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(tempckv);
+ return result_code;
+ }
+ delete tempckv;
+ tempckv = NULL;
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VrtIfFlowFilterMoMgr::SetValidAudit(ConfigKeyVal *&ikey) {
+ UPLL_FUNC_TRACE;
+ val_flowfilter_t *val = reinterpret_cast<val_flowfilter_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_flowfilter_t)));
+ val->cs_row_status = UNC_CS_APPLIED;
+ ikey->AppendCfgVal(IpctSt::kIpcStValFlowfilter, val);
return UPLL_RC_SUCCESS;
}
+
+bool VrtIfFlowFilterMoMgr::FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op) {
+ UPLL_FUNC_TRACE;
+ if (op != UNC_OP_CREATE)
+ return true;
+ return false;
+}
} // namespace kt_momgr
} // namespace upll
} // namespace eunc
static unc_key_type_t vrt_if_flowfilter_child[];
static BindInfo vrt_if_flowfilter_bind_info[];
static BindInfo vrtIfflowfiltermaintbl_bind_info[];
-
+ uint32_t cur_instance_count;
public:
/**
* @brief Method used to fill the CongigKeyVal with the
* @retval UPLL_RC_SUCCESS Successfull completion.
* @retval UPLL_RC_ERR_GENERIC Failure
*/
- upll_rc_t GetRenamedControllerKey(ConfigKeyVal *&ikey,
+ upll_rc_t GetRenamedControllerKey(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
controller_domain *ctrlr_dom = NULL);
upll_rc_t SetVlinkPortmapConfiguration(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
- InterfacePortMapInfo flag);
+ InterfacePortMapInfo flag,
+ unc_keytype_operation_t oper);
upll_rc_t TxUpdateController(unc_key_type_t keytype,
uint32_t session_id,
DalDmlIntf *dmi);
upll_rc_t ConstructReadDetailResponse(ConfigKeyVal *ikey,
ConfigKeyVal *drv_resp_ckv,
- upll_keytype_datatype_t dt_type,
- unc_keytype_operation_t op,
- DbSubOp dbop,
- DalDmlIntf *dmi,
ConfigKeyVal **okey);
+ upll_rc_t AuditUpdateController(unc_key_type_t keytype,
+ const char *ctrlr_id,
+ uint32_t session_id,
+ uint32_t config_id,
+ uuc::UpdateCtrlrPhase phase,
+ bool *ctrlr_affected,
+ DalDmlIntf *dmi);
+
+ upll_rc_t CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id);
+
+ upll_rc_t DeleteChildrenPOM(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi);
+
+ upll_rc_t SetValidAudit(ConfigKeyVal *&ikey);
+
+ bool FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op);
+
+ upll_rc_t SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req);
+
public:
VrtIfFlowFilterMoMgr();
~VrtIfFlowFilterMoMgr() {
{ uudst::vrouter_interface::kDbiValidMacAddr, CFG_META_VAL, offsetof(
val_vrt_if, valid[UPLL_IDX_MAC_ADDR_VI]),
uud::kDalUint8, 1 },
- { uudst::vrouter_interface::kDbiValidAdminStatus, CFG_META_VAL, offsetof(
+ { uudst::vrouter_interface::kDbiValidAdminStatus, CFG_DEF_VAL, offsetof(
val_vrt_if, valid[UPLL_IDX_ADMIN_ST_VI]),
uud::kDalUint8, 1 },
{ uudst::vrouter_interface::kDbiValidOperStatus, ST_META_VAL, offsetof(
bool VrtIfMoMgr::IsValidKey(void *key, uint64_t index) {
UPLL_FUNC_TRACE;
key_vrt_if *vrtif_key = reinterpret_cast<key_vrt_if *>(key);
- bool ret_val = UPLL_RC_SUCCESS;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
switch (index) {
case uudst::vrouter_interface::kDbiVtnName:
ret_val = ValidateKey(reinterpret_cast<char *>
(vrtif_key->vrt_key.vrouter_name),
kMinLenVnodeName, kMaxLenVnodeName);
if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("VRouter Name is not valid(%d)", ret_val);
+ UPLL_LOG_TRACE("VRouter Name is not valid(%d)", ret_val);
return false;
}
break;
(vrtif_key->if_name), kMinLenInterfaceName,
kMaxLenInterfaceName);
if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("VRouterInterface Name is not valid(%d)", ret_val);
+ UPLL_LOG_TRACE("VRouterInterface Name is not valid(%d)", ret_val);
return false;
}
break;
if (parent_key == NULL) {
vrt_key_if = reinterpret_cast<key_vrt_if *>
(ConfigKeyVal::Malloc(sizeof(key_vrt_if)));
+ if (okey) delete okey;
okey = new ConfigKeyVal(UNC_KT_VRT_IF, IpctSt::kIpcStKeyVrtIf, vrt_key_if,
NULL);
return UPLL_RC_SUCCESS;
val_vlink *vlink_val = reinterpret_cast<val_vlink *>
(GetVal(parent_key));
if (!vlink_val) {
- free(vrt_key_if);
+ if (!okey || !(okey->get_key()))
+ free(vrt_key_if);
return UPLL_RC_ERR_GENERIC;
}
GET_USER_DATA_FLAGS(parent_key->get_cfg_val(), flags);
if (!okey)
okey = new ConfigKeyVal(UNC_KT_VRT_IF, IpctSt::kIpcStKeyVrtIf, vrt_key_if,
NULL);
+ else if (okey->get_key() != vrt_key_if)
+ okey->SetKey(IpctSt::kIpcStKeyVrtIf, vrt_key_if);
+
if (okey == NULL) {
free(vrt_key_if);
result_code = UPLL_RC_ERR_GENERIC;
UPLL_LOG_DEBUG("ikey is NULL");
return UPLL_RC_ERR_GENERIC;
}
+ DELETE_IF_NOT_NULL(okey);
unc_key_type_t ikey_type = ikey->get_key_type();
if (ikey_type != UNC_KT_VRT_IF) return UPLL_RC_ERR_GENERIC;
memcpy(vrt_if_key, ikey, sizeof(key_vrt_if));
okey = new ConfigKeyVal(UNC_KT_VRT_IF, IpctSt::kIpcStKeyVrtIf, vrt_if_key,
tmp1);
- if (okey) SET_USER_DATA(okey, req);
+ if (okey) {
+ SET_USER_DATA(okey, req);
+ } else {
+ DELETE_IF_NOT_NULL(tmp1);
+ FREE_IF_NOT_NULL(vrt_if_key);
+ }
return UPLL_RC_SUCCESS;
}
return UPLL_RC_ERR_GENERIC;
}
while (cval ) {
+ if (IpctSt::kIpcStValVrtIf == cval->get_st_num()) {
+ // set admin status to valid no value
+ val_vrt_if *vrt_if_val = reinterpret_cast<val_vrt_if *>GetVal(ikey);
+ if (vrt_if_val->valid[UPLL_IDX_ADMIN_ST_VI] == UNC_VF_INVALID)
+ vrt_if_val->valid[UPLL_IDX_ADMIN_ST_VI] = UNC_VF_VALID_NO_VALUE;
+ }
if (IpctSt::kIpcStValVrtIfSt == cval->get_st_num()) {
val_vrt_if_st *vrt_if_val_st = reinterpret_cast<val_vrt_if_st *>
(ConfigKeyVal::Malloc(sizeof(val_vrt_if_st)));
val_vrt_if_t *vrt_if_val = reinterpret_cast<val_vrt_if_t *>(GetVal(ikey));
unc_keytype_configstatus_t cs_status =
- (driver_result == 0) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
+ (driver_result == UPLL_RC_SUCCESS) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
+ bool oper_status_change = true;
if (vrt_if_val == NULL) return UPLL_RC_ERR_GENERIC;
- if (op == UNC_OP_CREATE) {
- vrt_if_val->cs_row_status = cs_status;
+ switch (op) {
+ case UNC_OP_UPDATE:
+ {
+ void *val = reinterpret_cast<void *>(vrt_if_val);
+ CompareValidValue(val, GetVal(upd_key), true);
+ uint8_t cand_flag = 0,run_flag = 0;
+ GET_USER_DATA_FLAGS(ikey,cand_flag);
+ GET_USER_DATA_FLAGS(upd_key,run_flag);
+ if ((cand_flag & VIF_TYPE) == (run_flag & VIF_TYPE))
+ oper_status_change = false;
+ }
+ /* fall through intended */
+ case UNC_OP_CREATE:
+ {
+ if (op == UNC_OP_CREATE)
+ vrt_if_val->cs_row_status = cs_status;
val_db_vrt_if_st *vrt_if_valst = reinterpret_cast<val_db_vrt_if_st *>
(ConfigKeyVal::Malloc(sizeof(val_db_vrt_if_st)));
ikey->AppendCfgVal(IpctSt::kIpcStValVrtIfSt, vrt_if_valst);
+ break;
+ }
+ default:
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (oper_status_change) {
+#if 0
rs_code = InitOperStatus<val_vrt_if_st,val_db_vrt_if_st>(ikey,
- vrt_if_val->valid[UPLL_IDX_ADMIN_STATUS_VBRI],
+ vrt_if_val->valid[UPLL_IDX_ADMIN_ST_VI],
vrt_if_val->admin_status,(uint8_t)UNC_VF_INVALID);
if (rs_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Error setting oper status");
return UPLL_RC_ERR_GENERIC;
}
- } else if (op == UNC_OP_UPDATE) {
- void *val = reinterpret_cast<void *>(vrt_if_val);
- CompareValidValue(val, GetVal(upd_key), true);
- } else {
- return UPLL_RC_ERR_GENERIC;
+#else
+ val_vrt_if_st *vnif_st = &(reinterpret_cast<val_db_vrt_if_st *>
+ (GetStateVal(ikey))->vrt_if_val_st);
+ if (!vnif_st) {
+ UPLL_LOG_DEBUG("Returning error\n");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ vnif_st->oper_status = UPLL_OPER_STATUS_UNINIT;
+ vnif_st->valid[UPLL_IDX_OPER_STATUS_VRTS] = UNC_VF_VALID;
+#endif
+ }
+ UPLL_LOG_TRACE("%s",(ikey->ToStrAll()).c_str());
+ val_vrt_if *vrt_if_val2 = reinterpret_cast<val_vrt_if *>(GetVal(upd_key));
+ if (UNC_OP_UPDATE == op) {
+ UPLL_LOG_TRACE("%s",(upd_key->ToStrAll()).c_str());
+ vrt_if_val->cs_row_status = vrt_if_val2->cs_row_status;
}
for (unsigned int loop = 0; loop <
sizeof(vrt_if_val->valid) / sizeof(vrt_if_val->valid[0]); ++loop) {
if ((UNC_VF_VALID == (uint8_t) vrt_if_val->valid[loop])
|| (UNC_VF_VALID_NO_VALUE == (uint8_t) vrt_if_val->valid[loop])) {
- vrt_if_val->cs_attr[loop] = cs_status;
- } else if (UNC_VF_NOT_SOPPORTED == vrt_if_val->valid[loop]) {
- vrt_if_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
+ if (loop == UPLL_IDX_DESC_VI)
+ vrt_if_val->cs_attr[loop] = UNC_CS_APPLIED;
+ else
+ vrt_if_val->cs_attr[loop] = cs_status;
+ } else if ((UNC_VF_INVALID == vrt_if_val->valid[loop]) &&
+ (UNC_OP_CREATE == op)) {
+ vrt_if_val->cs_attr[loop] = UNC_CS_APPLIED;
+ } else if ((UNC_VF_INVALID == vrt_if_val->valid[loop]) &&
+ (UNC_OP_UPDATE == op)) {
+ vrt_if_val->cs_attr[loop] = vrt_if_val2->cs_attr[loop];
}
+
}
return rs_code;
}
return UPLL_RC_ERR_GENERIC;
}
if (uuc::kUpllUcpCreate == phase) val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
for (unsigned int loop = 0; loop < sizeof(val->valid) / sizeof(uint8_t);
++loop) {
if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVtnNeighbor)) {
vtn_neighbor = reinterpret_cast<val_vtn_neighbor *>
(ikey->get_cfg_val()->get_val());
+ } else if ((ikey->get_cfg_val()) &&
+ (((ikey->get_cfg_val())->get_st_num() != IpctSt::kIpcStValVrtIf) ||
+ ((ikey->get_cfg_val())->get_st_num() != IpctSt::kIpcStValVtnNeighbor))) {
+ UPLL_LOG_DEBUG("Invalid val structure received.received struct - %d",
+ ikey->get_cfg_val()->get_st_num());
+ return UPLL_RC_ERR_BAD_REQUEST;
}
if ((op == UNC_OP_CREATE) && ((dt_type == UPLL_DT_CANDIDATE)
upll_rc_t VrtIfMoMgr::ValidateVrtIfValue(val_vrt_if *vrt_if_val,
unc_keytype_operation_t op) {
UPLL_FUNC_TRACE;
- upll_rc_t ret_val = UPLL_RC_SUCCESS;
if (vrt_if_val->valid[UPLL_IDX_DESC_VI] == UNC_VF_VALID) {
- ret_val = ValidateDesc(reinterpret_cast<char *>(vrt_if_val->description),
+ if (!ValidateDesc(vrt_if_val->description,
kMinLenDescription,
- kMaxLenDescription);
- if (ret_val != UPLL_RC_SUCCESS) {
+ kMaxLenDescription)) {
UPLL_LOG_DEBUG("Description syntax check failed."
"received Description - %s",
vrt_if_val->description);
}
if (vrt_if_val->valid[UPLL_IDX_PREFIXLEN_VI] == UNC_VF_VALID) {
- if (ValidateNumericRange((uint8_t) vrt_if_val->prefixlen, kMinIpv4Prefix,
- kMaxIpv4Prefix, true, true)) {
+ if (ValidateNumericRange((uint8_t) vrt_if_val->prefixlen, kMinVnodeIpv4Prefix,
+ kMaxVnodeIpv4Prefix, true, true)) {
UPLL_LOG_DEBUG("IPV4 prefixlength validation is success");
- ret_val = ValidateIpv4Addr(vrt_if_val->ip_addr.s_addr,
- vrt_if_val->prefixlen);
- if (ret_val != UPLL_RC_SUCCESS) {
+ if (!ValidateIpv4Addr(vrt_if_val->ip_addr.s_addr,
+ vrt_if_val->prefixlen)) {
UPLL_LOG_DEBUG("Ip address Validation failed");
return UPLL_RC_ERR_CFG_SYNTAX;
}
} else if (vrt_if_val->valid[UPLL_IDX_ADMIN_ST_VI] == UNC_VF_VALID_NO_VALUE
&& (op == UNC_OP_CREATE || op == UNC_OP_UPDATE)) {
vrt_if_val->admin_status = UPLL_ADMIN_ENABLE;
+ } else if ((vrt_if_val->valid[UPLL_IDX_ADMIN_ST_VI] == UNC_VF_INVALID)
+ && (op == UNC_OP_CREATE)) {
+ vrt_if_val->admin_status = UPLL_ADMIN_ENABLE;
+ vrt_if_val->valid[UPLL_IDX_ADMIN_ST_VI] = UNC_VF_VALID_NO_VALUE;
}
return UPLL_RC_SUCCESS;
}
ConfigKeyVal *ikey,
const char *ctrlr_name) {
UPLL_FUNC_TRACE;
- upll_rc_t ret_val = UPLL_RC_SUCCESS;
- /** read datatype, operation, options from IpcReqRespHeader */
+ upll_rc_t ret_val = UPLL_RC_ERR_GENERIC;
+
if (!req || !ikey ) {
UPLL_LOG_DEBUG("ConfigKeyVal / IpcReqRespHeader is NULL");
return UPLL_RC_ERR_GENERIC;
}
- if (!ctrlr_name) ctrlr_name = reinterpret_cast<char *>(ikey->get_user_data());
- upll_keytype_datatype_t dt_type = req->datatype;
- unc_keytype_operation_t op = req->operation;
- unc_keytype_option1_t opt1 = req->option1;
- unc_keytype_option2_t opt2 = req->option2;
-
- if (op == UNC_OP_CREATE) {
- if (dt_type == UPLL_DT_CANDIDATE || dt_type == UPLL_DT_IMPORT) {
- if (NULL == ikey->get_cfg_val()) {
- UPLL_LOG_DEBUG("ConfigVal struct is empty");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- if (ikey->get_cfg_val()->get_val() != NULL) {
- ret_val = ValVrtIfAttributeSupportCheck(ctrlr_name, ikey, op);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(
- "VRT_IF struct Capa check failure for create operation");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("val_vrt_if struct is an optional");
- }
- } else {
- UPLL_LOG_DEBUG("Unsupported datatype - (%d)", dt_type);
+ if (!ctrlr_name) {
+ ctrlr_name = reinterpret_cast<char*>((reinterpret_cast<key_user_data_t *>
+ (ikey->get_user_data()))->ctrlr_id);
+ if (!ctrlr_name || !strlen(ctrlr_name)) {
+ UPLL_LOG_DEBUG("Controller Name is NULL");
return UPLL_RC_ERR_GENERIC;
}
- } else if (op == UNC_OP_UPDATE) {
- if (dt_type == UPLL_DT_CANDIDATE) {
- ret_val = ValVrtIfAttributeSupportCheck(ctrlr_name, ikey, op);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("In VRT_IF Capa check failure for Update operation");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Unsupported datatype - (%d)", dt_type);
- return UPLL_RC_ERR_GENERIC;
- }
- } else if (op == UNC_OP_READ || op == UNC_OP_READ_SIBLING
- || op == UNC_OP_READ_SIBLING_BEGIN || op == UNC_OP_READ_SIBLING_COUNT) {
- if (dt_type == UPLL_DT_CANDIDATE || dt_type == UPLL_DT_RUNNING
- || dt_type == UPLL_DT_STARTUP || dt_type == UPLL_DT_STATE) {
- if (opt1 != UNC_OPT1_NORMAL) {
- UPLL_LOG_DEBUG("Error option1 is not NORMAL");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- if (opt2 != UNC_OPT2_NONE) {
- UPLL_LOG_DEBUG("Error option2 is not NONE");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- if (NULL == ikey->get_cfg_val()) {
- UPLL_LOG_DEBUG("ConfigVal struct is empty");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- if (ikey->get_cfg_val()->get_val() == NULL) {
- UPLL_LOG_DEBUG("val_vrt_if struct is an optional");
- return UPLL_RC_SUCCESS;
- }
- ret_val = ValVrtIfAttributeSupportCheck(ctrlr_name, ikey, op);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("VRT_IF struct capa check failure for read operation");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Unsupported datatype - (%d)", dt_type);
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
- }
}
- UPLL_LOG_DEBUG("Unsupported operation -(%d)", op);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
-}
-upll_rc_t VrtIfMoMgr::ValVrtIfAttributeSupportCheck(const char *ctrlr_name,
- ConfigKeyVal *ikey,
- unc_keytype_operation_t operation) {
- UPLL_FUNC_TRACE;
bool result_code = false;
uint32_t max_attrs;
uint32_t max_instance_count;
const uint8_t *attrs;
- switch (operation) {
+ switch (req->operation) {
case UNC_OP_CREATE:
result_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
&max_instance_count, &max_attrs,
&attrs);
- if (result_code && (max_instance_count != 0) && cur_instance_count >= max_instance_count ) {
+ if (result_code && (max_instance_count != 0) &&
+ (cur_instance_count >= max_instance_count)) {
UPLL_LOG_DEBUG("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
__LINE__, __FUNCTION__, cur_instance_count,
max_instance_count);
if (!result_code) {
UPLL_LOG_DEBUG("key_type - %d is not supported by controller - %s",
ikey->get_key_type(), ctrlr_name);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
- if (NULL == ikey->get_cfg_val()) {
- UPLL_LOG_DEBUG("ConfigVal struct is empty");
- return UPLL_RC_ERR_CFG_SYNTAX;
+ val_vrt_if *vrt_if_val = NULL;
+ if ((ikey->get_cfg_val())
+ && ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVrtIf)) {
+ vrt_if_val = reinterpret_cast<val_vrt_if *>
+ (ikey->get_cfg_val()->get_val());
}
- if (ikey->get_cfg_val()->get_st_num() != IpctSt::kIpcStValVrtIf) {
- UPLL_LOG_DEBUG("Invalid value structure received. received struct - %d",
- (ikey->get_cfg_val()->get_st_num()));
- return UPLL_RC_ERR_CFG_SYNTAX;
+ if (vrt_if_val) {
+ if (max_attrs > 0) {
+ ret_val = ValVrtIfAttributeSupportCheck(vrt_if_val, attrs, req->operation);
+ return ret_val;
+ } else {
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d", req->operation);
+ return UPLL_RC_ERR_GENERIC;
+ }
}
- val_vrt_if *vrt_if_val = reinterpret_cast<val_vrt_if *>
- (ikey->get_cfg_val()->get_val());
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VrtIfMoMgr::ValVrtIfAttributeSupportCheck(val_vrt_if *vrt_if_val,
+ const uint8_t *attrs,
+ unc_keytype_operation_t operation) {
+ UPLL_FUNC_TRACE;
+
if (vrt_if_val != NULL) {
if ((vrt_if_val->valid[UPLL_IDX_DESC_VI] == UNC_VF_VALID)
|| (vrt_if_val->valid[UPLL_IDX_DESC_VI] == UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vrt_if::kCapDesc] == 0) {
- vrt_if_val->valid[UPLL_IDX_DESC_VI] = UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_DEBUG("Desc attr is not supported by ctrlr ");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ vrt_if_val->valid[UPLL_IDX_DESC_VI] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("Desc attr is not supported by ctrlr ");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
}
}
if ((vrt_if_val->valid[UPLL_IDX_IP_ADDR_VI] == UNC_VF_VALID)
|| (vrt_if_val->valid[UPLL_IDX_IP_ADDR_VI] == UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vrt_if::kCapIpAddr] == 0) {
- vrt_if_val->valid[UPLL_IDX_IP_ADDR_VI] = UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_DEBUG("Ip addr attr is not supported by ctrlr ");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ vrt_if_val->valid[UPLL_IDX_IP_ADDR_VI] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("Ip addr attr is not supported by ctrlr ");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
}
}
if ((vrt_if_val->valid[UPLL_IDX_PREFIXLEN_VI] == UNC_VF_VALID)
|| (vrt_if_val->valid[UPLL_IDX_PREFIXLEN_VI] == UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vrt_if::kCapPrefixlen] == 0) {
- vrt_if_val->valid[UPLL_IDX_PREFIXLEN_VI] = UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_DEBUG("Prefixlen attr is not supported by ctrlr ");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ vrt_if_val->valid[UPLL_IDX_PREFIXLEN_VI] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("Prefixlen attr is not supported by ctrlr ");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
}
}
// #if 0 //CHECK
if ((vrt_if_val->valid[UPLL_IDX_MAC_ADDR_VI] == UNC_VF_VALID)
|| (vrt_if_val->valid[UPLL_IDX_MAC_ADDR_VI] == UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vrt_if::kCapMacAddr] == 0) {
- vrt_if_val->valid[UPLL_IDX_MAC_ADDR_VI] = UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_DEBUG("Mac addr attr is not supported by ctrlr ");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ vrt_if_val->valid[UPLL_IDX_MAC_ADDR_VI] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("Mac addr attr is not supported by ctrlr ");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
}
}
if ((vrt_if_val->valid[UPLL_IDX_ADMIN_ST_VI] == UNC_VF_VALID)
|| (vrt_if_val->valid[UPLL_IDX_ADMIN_ST_VI] == UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vrt_if::kCapAdminStatus] == 0) {
- vrt_if_val->valid[UPLL_IDX_ADMIN_ST_VI] = UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_DEBUG("Admin status attr is not supported by ctrlr ");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ vrt_if_val->valid[UPLL_IDX_ADMIN_ST_VI] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("Admin status attr is not supported by ctrlr ");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
}
}
// #endif
- return UPLL_RC_SUCCESS;
} else {
UPLL_LOG_DEBUG("Error vrt_if struct is NULL");
+ return UPLL_RC_ERR_GENERIC;
}
- return UPLL_RC_ERR_GENERIC;
+ return UPLL_RC_SUCCESS;
}
upll_rc_t VrtIfMoMgr::CopyToConfigKey(ConfigKeyVal *&okey,
(ikey->get_key());
key_vrt_if_t * key_vrt = reinterpret_cast<key_vrt_if_t *>
(ConfigKeyVal::Malloc(sizeof(key_vrt_if_t)));
- if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vtn_name)))
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vtn_name))) {
+ FREE_IF_NOT_NULL(key_vrt);
return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(key_vrt->vrt_key.vtn_key.vtn_name,
key_rename->old_unc_vtn_name, (kMaxLenVtnName+1));
if (UNC_KT_VROUTER == ikey->get_key_type()) {
- if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vnode_name)))
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vnode_name))) {
+ FREE_IF_NOT_NULL(key_vrt);
return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(key_vrt->vrt_key.vrouter_name,
key_rename->old_unc_vnode_name, (kMaxLenVnodeName+1));
} else {
- if (!strlen(reinterpret_cast<char *>(key_rename->new_unc_vnode_name)))
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_unc_vnode_name))) {
+ FREE_IF_NOT_NULL(key_vrt);
return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(key_vrt->vrt_key.vrouter_name,
key_rename->new_unc_vnode_name, (kMaxLenVnodeName+1));
}
bool VrtIfMoMgr::FilterAttributes(void *&val1, void *val2, bool copy_to_running,
unc_keytype_operation_t op) {
val_vrt_if_t *val_vrt_if1 = reinterpret_cast<val_vrt_if_t *>(val1);
- val_vrt_if1->valid[UPLL_IDX_DESC_VI] = UNC_CS_INVALID;
+ val_vrt_if1->valid[UPLL_IDX_DESC_VI] = UNC_VF_INVALID;
if (op != UNC_OP_CREATE)
return CompareValidValue(val1, val2, copy_to_running);
return false;
val_vrt_if_t *val_vrt_if1 = reinterpret_cast<val_vrt_if_t *>(val1);
val_vrt_if_t *val_vrt_if2 = reinterpret_cast<val_vrt_if_t *>(val2);
if (!val2) {
- UPLL_LOG_TRACE("Invalid param\n");
+ UPLL_LOG_TRACE("Invalid param");
return UPLL_RC_ERR_GENERIC;
}
for (unsigned int loop = 0;
loop < sizeof(val_vrt_if1->valid) / sizeof(uint8_t); ++loop) {
if (UNC_VF_INVALID == val_vrt_if1->valid[loop]
- && UNC_VF_VALID == val_vrt_if2->valid[loop]) val_vrt_if1->valid[loop] =
- UNC_VF_VALID_NO_VALUE;
+ && UNC_VF_VALID == val_vrt_if2->valid[loop])
+ val_vrt_if1->valid[loop] = UNC_VF_VALID_NO_VALUE;
}
if (!copy_to_running) {
if (UNC_VF_VALID_NO_VALUE == val_vrt_if1->valid[UPLL_IDX_IP_ADDR_VI]) {
- memcpy(&val_vrt_if1->ip_addr, &val_vrt_if2->ip_addr,
- sizeof(val_vrt_if1->ip_addr));
+ val_vrt_if1->ip_addr.s_addr = val_vrt_if2->ip_addr.s_addr;
}
if (UNC_VF_VALID_NO_VALUE == val_vrt_if1->valid[UPLL_IDX_PREFIXLEN_VI]) {
val_vrt_if1->prefixlen = val_vrt_if2->prefixlen;
}
if (UNC_VF_VALID_NO_VALUE == val_vrt_if1->valid[UPLL_IDX_MAC_ADDR_VI]) {
- uuu::upll_strncpy(reinterpret_cast<char*>(val_vrt_if1->macaddr),
- reinterpret_cast<char*>(val_vrt_if2->macaddr),6);
+ memcpy(reinterpret_cast<char*>(val_vrt_if1->macaddr),
+ reinterpret_cast<char*>(val_vrt_if2->macaddr),
+ sizeof(val_vrt_if2->macaddr));
}
}
- if ((UNC_VF_VALID == val_vrt_if1->valid[UPLL_IDX_DESC_VI])
- && (UNC_VF_VALID == val_vrt_if2->valid[UPLL_IDX_DESC_VI]))
- if (!strcmp(reinterpret_cast<char*>(val_vrt_if1->description),
- reinterpret_cast<char*>(val_vrt_if2->description)))
+ if (UNC_VF_INVALID != val_vrt_if1->valid[UPLL_IDX_DESC_VI]) {
+ if (!copy_to_running ||
+ ((UNC_VF_VALID == val_vrt_if1->valid[UPLL_IDX_DESC_VI]) &&
+ (!strncmp(reinterpret_cast<char*>(val_vrt_if1->description),
+ reinterpret_cast<char*>(val_vrt_if2->description),
+ sizeof(val_vrt_if2->description)))))
val_vrt_if1->valid[UPLL_IDX_DESC_VI] = UNC_VF_INVALID;
+ }
if (UNC_VF_VALID == val_vrt_if1->valid[UPLL_IDX_IP_ADDR_VI]
&& UNC_VF_VALID == val_vrt_if2->valid[UPLL_IDX_IP_ADDR_VI]) {
- if (!memcmp(&val_vrt_if1->ip_addr, &val_vrt_if2->ip_addr,
- sizeof(val_vrt_if1->ip_addr)))
+ if (val_vrt_if1->ip_addr.s_addr == val_vrt_if2->ip_addr.s_addr)
val_vrt_if1->valid[UPLL_IDX_IP_ADDR_VI] = UNC_VF_INVALID;
}
if (UNC_VF_VALID == val_vrt_if1->valid[UPLL_IDX_PREFIXLEN_VI]
}
if (UNC_VF_VALID == val_vrt_if1->valid[UPLL_IDX_MAC_ADDR_VI]
&& UNC_VF_VALID == val_vrt_if2->valid[UPLL_IDX_MAC_ADDR_VI]) {
- if (!strcmp(reinterpret_cast<char*>(val_vrt_if1->macaddr),
- reinterpret_cast<char*>(val_vrt_if2->macaddr)))
+ if (!memcmp(reinterpret_cast<char*>(val_vrt_if1->macaddr),
+ reinterpret_cast<char*>(val_vrt_if2->macaddr),
+ sizeof(val_vrt_if2->macaddr)))
val_vrt_if1->valid[UPLL_IDX_MAC_ADDR_VI] = UNC_VF_INVALID;
}
val_vrt_if1->valid[UPLL_IDX_ADMIN_ST_VI] = UNC_VF_INVALID;
-
+ // Description is not send to Controller
+ if (!copy_to_running)
+ val_vrt_if1->valid[UPLL_IDX_DESC_VI] = UNC_VF_INVALID;
for (unsigned int loop = 0;
loop < sizeof(val_vrt_if1->valid) / sizeof(val_vrt_if1->valid[0]);
++loop) {
}
}
return invalid_attr;
-
}
upll_rc_t VrtIfMoMgr::IsReferenced(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi) {
- UPLL_FUNC_TRACE;
+ UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *okey = NULL,*ckv_dhcp = NULL;
- if (NULL == ikey) return UPLL_RC_ERR_GENERIC;
+ if (!ikey || !ikey->get_key()) return UPLL_RC_ERR_GENERIC;
- /* return error if dhcp relay is enabled on interface */
- MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>
- (GetMoManager(UNC_KT_DHCPRELAY_IF)));
- result_code = mgr->GetChildConfigKey(ckv_dhcp, ikey);
- if (result_code != UPLL_RC_SUCCESS || ckv_dhcp == NULL) {
- UPLL_LOG_DEBUG("Create key returning error %d\n",result_code);
- return result_code;
- }
- DbSubOp dbop1 = {kOpReadExist, kOpMatchNone, kOpInOutNone};
- result_code = mgr->UpdateConfigDB(ckv_dhcp, UPLL_DT_CANDIDATE,
- UNC_OP_READ, dmi, &dbop1, MAINTBL);
- delete ckv_dhcp;
- if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
- uint8_t *if_name = reinterpret_cast<key_dhcp_relay_if *>
- (ikey->get_key())->if_name;
- UPLL_LOG_DEBUG("Cannot delete dhcp relay enabled interface %s\n",
- if_name);
- return UPLL_RC_ERR_CFG_SEMANTIC;
- } else if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- UPLL_LOG_DEBUG(" Returning error %d\n",result_code);
- return result_code;
- }
result_code = GetChildConfigKey(okey, ikey);
if (result_code != UPLL_RC_SUCCESS || okey == NULL) {
- UPLL_LOG_DEBUG("Create key returning error %d\n",result_code);
+ UPLL_LOG_DEBUG("Create key returning error %d",result_code);
return result_code;
}
- DbSubOp dbop = { kOpReadSingle , kOpMatchNone, kOpInOutFlag };
+ /* Getting the Full key information with help of read operation */
+
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutFlag };
result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
UPLL_RC_SUCCESS:result_code;
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
- uint8_t vlink_flag = 0;
- GET_USER_DATA_FLAGS(okey,vlink_flag);
- if (vlink_flag & VIF_TYPE)
- return UPLL_RC_ERR_CFG_SEMANTIC;
-#if 0
- /* return error if the interface is part of a vlink */
- MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>
- (GetMoManager(UNC_KT_VLINK)));
- if (!mgr) {
- UPLL_LOG_DEBUG("Instance is NULL");
- return UPLL_RC_ERR_GENERIC;
- }
- while (okey) {
- result_code = mgr->CheckVnodeInfo(okey, dt_type, dmi);
- if (UPLL_RC_SUCCESS == result_code)
- return UPLL_RC_ERR_CFG_SEMANTIC;
- if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
- UPLL_LOG_DEBUG("CheckVnodeInfo Failed %d", result_code);
- return result_code;
+ ConfigKeyVal *temkey = okey;
+ while (temkey != NULL) {
+ uint8_t vlink_flag = 0;
+ ckv_dhcp = NULL;
+
+ // Is interface part of vlink?
+ GET_USER_DATA_FLAGS(temkey,vlink_flag);
+ if (vlink_flag & VIF_TYPE) {
+ delete okey;
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+
+ /* return error if dhcp relay is enabled on interface */
+ if (IsValidKey(temkey->get_key(), uudst::vrouter_interface::kDbiIfName)) {
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>
+ (GetMoManager(UNC_KT_DHCPRELAY_IF)));
+ result_code = mgr->GetChildConfigKey(ckv_dhcp, temkey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Create key returning error %d",result_code);
+ delete okey;
+ return result_code;
+ }
+ DbSubOp dbop1 = {kOpReadExist, kOpMatchNone, kOpInOutNone};
+ result_code = mgr->UpdateConfigDB(ckv_dhcp, UPLL_DT_CANDIDATE,
+ UNC_OP_READ, dmi, &dbop1, MAINTBL);
+ if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
+ uint8_t *if_name = reinterpret_cast<key_dhcp_relay_if *>
+ (ckv_dhcp->get_key())->if_name;
+ UPLL_LOG_DEBUG("Cannot delete dhcp relay enabled interface %s",
+ if_name);
+ delete ckv_dhcp;
+ delete okey;
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ } else if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG(" Returning error %d",result_code);
+ delete ckv_dhcp;
+ delete okey;
+ return result_code;
+ }
+ delete ckv_dhcp;
}
- okey = okey->get_next_cfg_key_val();
+ temkey = temkey->get_next_cfg_key_val();
}
-#endif
+ if (okey)
+ delete okey;
return UPLL_RC_SUCCESS;
}
UPLL_LOG_DEBUG("Input is NULL");
return UPLL_RC_ERR_GENERIC;
}
+ ConfigKeyVal *dup_key = NULL;
+ result_code = GetChildConfigKey(dup_key, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed");
+ if (dup_key) delete dup_key;
+ return result_code;
+ }
/*
* Here getting FULL Key (VTN & VRT Name )
*/
DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
- result_code = ReadConfigDB(ikey, UPLL_DT_IMPORT, UNC_OP_READ, dbop, dmi,
+ result_code = ReadConfigDB(dup_key, UPLL_DT_IMPORT, UNC_OP_READ, dbop, dmi,
MAINTBL);
- if (UPLL_RC_SUCCESS != result_code) return result_code;
-
+ if (UPLL_RC_SUCCESS != result_code) {
+ if (dup_key) delete dup_key;
+ return result_code;
+ }
bool tvalid1 = 0;
bool tvalid2 = 0;
- while (ikey) {
+ ConfigKeyVal * travel = dup_key;
+ while (travel) {
/*
* Checks the Val structure is available or not.If availabl
* Checks Host address value is available or not in import ckval
*/
- result_code = DupConfigKeyVal(tkey, ikey, MAINTBL);
+ result_code = DupConfigKeyVal(tkey, travel, MAINTBL);
if (UPLL_RC_SUCCESS != result_code){
UPLL_LOG_DEBUG("DupConfigKeyVal Failed %d", result_code);
+ if (dup_key) delete dup_key;
return result_code;
}
&& tval->valid[UPLL_IDX_MAC_ADDR_VI] != UNC_VF_VALID) {
UPLL_LOG_DEBUG(" MAIN VALUES ARE NOT VALID");
} else {
- if (tval->valid[UPLL_IDX_IP_ADDR_VI] == UNC_VF_INVALID) {
+ if (tval->valid[UPLL_IDX_IP_ADDR_VI] == UNC_VF_VALID &&
+ tval->valid[UPLL_IDX_PREFIXLEN_VI] == UNC_VF_VALID ) {
/* Reset the Valid flag to INVALID and check any one attribute is present
* in the DT */
tvalid1 = 1;
tval->valid[UPLL_IDX_IP_ADDR_VI] = UNC_VF_INVALID;
+ tval->valid[UPLL_IDX_PREFIXLEN_VI] = UNC_VF_INVALID;
}
if (tval->valid[UPLL_IDX_MAC_ADDR_VI] == UNC_VF_VALID) {
tvalid2 = 1;
tval->valid[UPLL_IDX_MAC_ADDR_VI] = UNC_VF_INVALID;
}
- tval->valid[UPLL_IDX_DESC_VI] = UNC_VF_INVALID;
- tval->valid[UPLL_IDX_PREFIXLEN_VI] = UNC_VF_INVALID;
- tval->valid[UPLL_IDX_ADMIN_ST_VI] = UNC_VF_INVALID;
-
+
if (tvalid1) {
+ tval->valid[UPLL_IDX_DESC_VI] = UNC_VF_INVALID;
+ tval->valid[UPLL_IDX_ADMIN_ST_VI] = UNC_VF_INVALID;
+
/* The Same VTN should not have the same MAC and IP address so must
* remove the if_name */
memset(reinterpret_cast<key_vrt_if_t *>(tkey->get_key())->if_name, 0,
kMaxLenInterfaceName);
+
+ memset(reinterpret_cast<key_vrt_if_t *>(tkey->get_key())->vrt_key.
+ vrouter_name, 0, kMaxLenVnodeName);
/* set Valid for IP address */
tval->valid[UPLL_IDX_IP_ADDR_VI] = UNC_VF_VALID;
- result_code = ReadConfigDB(tkey, UPLL_DT_RUNNING, UNC_OP_READ, dbop,
+ tval->valid[UPLL_IDX_PREFIXLEN_VI] = UNC_VF_VALID;
+ result_code = ReadConfigDB(tkey, UPLL_DT_CANDIDATE, UNC_OP_READ, dbop,
dmi, MAINTBL);
if (UPLL_RC_SUCCESS == result_code) {
- UPLL_LOG_DEBUG(" IpRoute Conflicts %d", result_code);
+ UPLL_LOG_DEBUG(" IP Address Conflicts %d", result_code);
+ ikey->ResetWith(tkey);
+ delete tkey;
+ delete dup_key;
return UPLL_RC_ERR_MERGE_CONFLICT;
}
if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
UPLL_LOG_DEBUG("ReadConfigDB Failed %d", result_code);
+ delete tkey;
+ if (dup_key) delete dup_key;
return result_code;
}
- /* set invalid do't affect the mac address */
- tval->valid[UPLL_IDX_IP_ADDR_VI] = UNC_VF_INVALID;
- tval->valid[UPLL_IDX_DESC_VI] = UNC_VF_INVALID;
- tval->valid[UPLL_IDX_PREFIXLEN_VI] = UNC_VF_INVALID;
- tval->valid[UPLL_IDX_ADMIN_ST_VI] = UNC_VF_INVALID;
- }
+ }
if (tvalid2) {
- /* The Same VTN should not have the same MAC and IP address so must
- * remove the if_name */
- memset(reinterpret_cast<key_vrt_if_t *>(tkey->get_key())->if_name, 0,
- kMaxLenInterfaceName);
+ tval = reinterpret_cast<val_vrt_if_t *>
+ (GetVal(tkey));
+ if (tval) {
+ tval->valid[UPLL_IDX_DESC_VI] = UNC_VF_INVALID;
+ tval->valid[UPLL_IDX_ADMIN_ST_VI] = UNC_VF_INVALID;
- /* set Valid for MAC address */
- tval->valid[UPLL_IDX_MAC_ADDR_VI] = UNC_VF_VALID;
- result_code = ReadConfigDB(tkey, UPLL_DT_RUNNING, UNC_OP_READ, dbop, dmi,
- MAINTBL);
- if (UPLL_RC_SUCCESS == result_code) {
- UPLL_LOG_DEBUG(" IpRoute Conflict %d", result_code);
- return UPLL_RC_ERR_MERGE_CONFLICT;
- }
- if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
- UPLL_LOG_DEBUG("ReadConfigDB Failed %d", result_code);
- return result_code;
- }
+ /* The Same VTN should not have the same MAC and IP address so must
+ * remove the if_name */
+ memset(reinterpret_cast<key_vrt_if_t *>(tkey->get_key())->if_name, 0,
+ kMaxLenInterfaceName);
+
+ memset(reinterpret_cast<key_vrt_if_t *>(tkey->get_key())->vrt_key.
+ vrouter_name, 0, kMaxLenVnodeName);
+ /* set Valid for MAC address */
+ if (tvalid1) {
+ tval->valid[UPLL_IDX_IP_ADDR_VI] = UNC_VF_INVALID;
+ tval->valid[UPLL_IDX_PREFIXLEN_VI] = UNC_VF_INVALID;
+ }
+ tval->valid[UPLL_IDX_MAC_ADDR_VI] = UNC_VF_VALID;
+ result_code = ReadConfigDB(tkey, UPLL_DT_CANDIDATE, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS == result_code) {
+ ikey->ResetWith(tkey);
+ delete tkey;
+ delete dup_key;
+ return UPLL_RC_ERR_MERGE_CONFLICT;
+ }
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB Failed %d", result_code);
+ if (dup_key) delete dup_key;
+ delete tkey;
+ return result_code;
+ }
+ }
}
}
} else {
delete tkey;
tkey = NULL;
}
- ikey = ikey->get_next_cfg_key_val();
+ travel = travel->get_next_cfg_key_val();
} // while end
+ if (dup_key)
+ delete dup_key;
return result_code;
}
static unc_key_type_t vrt_if_child[];
static BindInfo vrt_if_bind_info[];
static BindInfo key_vrt_if_maintbl_update_bind_info[];
+
+ /* @brief Returns admin and portmap information if portmap is
+ * valid. Else returns NULL for portmap
+ *
+ * @param[in] ikey Pointer to ConfigKeyVal
+ * @param[out] valid_pm portmap is valid
+ * @param[out] pm pointer to portmap informtation if valid_pm
+ *
+ * @retval UPLL_RC_SUCCESS Completed successfully.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ *
+ **/
+ virtual upll_rc_t GetPortMap(ConfigKeyVal *ikey, uint8_t &valid_pm,
+ val_port_map_t *&pm, uint8_t &valid_admin,
+ uint8_t &admin_status) {
+ UPLL_FUNC_TRACE;
+ if (ikey == NULL) return UPLL_RC_ERR_GENERIC;
+ val_vrt_if *ifval = reinterpret_cast<val_vrt_if *>
+ (GetVal(ikey));
+ if (!ifval) {
+ UPLL_LOG_DEBUG("Invalid param");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ valid_pm = UNC_VF_INVALID;
+ pm = NULL;
+ valid_admin = ifval->valid[UPLL_IDX_ADMIN_ST_VI];
+ admin_status = ifval->admin_status;
+ return UPLL_RC_SUCCESS;
+ }
+
/**
* @brief Gets the valid array position of the variable in the value
* structure from the table in the specified configuration
* associated attributes are supported on the given controller,
* based on the valid flag.
*
- * @param[in] crtlr_name Controller name.
- * @param[in] ikey Corresponding key and value structure.
+ * @param[in] vrt_if_val KT_VRT_IF value structure.
+ * @param[in] attrs Pointer to controller attribute.
* @param[in] operation Operation name.
*
* @retval UPLL_RC_SUCCESS validation succeeded.
* @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
* @retval UPLL_RC_ERR_GENERIC Generic failure.
*/
- upll_rc_t ValVrtIfAttributeSupportCheck(const char *ctrlr_name,
- ConfigKeyVal *ikey,
+ upll_rc_t ValVrtIfAttributeSupportCheck(val_vrt_if *vrt_if_val,
+ const uint8_t *attrs,
unc_keytype_operation_t operation);
/**
table = new Table *[ntable];
table[MAINTBL] = new Table(uudst::kDbiVrtTbl, UNC_KT_VROUTER, vrt_bind_info,
IpctSt::kIpcStKeyVrt, IpctSt::kIpcStValVrt,
- uudst::vrouter::kDbiVrtNumCols);
+ (uudst::vrouter::kDbiVrtNumCols+2));
table[RENAMETBL] = new Table(uudst::kDbiVNodeRenameTbl, UNC_KT_VROUTER,
vrt_rename_bind_info, IpctSt::kIpcInvalidStNum,
IpctSt::kIpcInvalidStNum,
bool VrtMoMgr::IsValidKey(void *key, uint64_t index) {
UPLL_FUNC_TRACE;
key_vrt *vrt_key = reinterpret_cast<key_vrt *>(key);
- bool ret_val = UPLL_RC_SUCCESS;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
switch (index) {
case uudst::vrouter::kDbiVtnName:
case uudst::vnode_rename::kDbiUncVtnName:
ConfigKeyVal *parent_key) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- key_vrt *vrt_key = reinterpret_cast<key_vrt_t *>
- (ConfigKeyVal::Malloc(sizeof(key_vrt_t)));
+ key_vrt *vrt_key = NULL;
+ if (okey && (okey->get_key())) {
+ vrt_key = reinterpret_cast<key_vrt_t *>
+ (okey->get_key());
+ } else {
+ vrt_key = reinterpret_cast<key_vrt_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vrt_t)));
+ }
void *pkey;
if (parent_key == NULL) {
- okey = new ConfigKeyVal(UNC_KT_VROUTER, IpctSt::kIpcStKeyVrt, vrt_key,
+ if (okey == NULL)
+ okey = new ConfigKeyVal(UNC_KT_VROUTER, IpctSt::kIpcStKeyVrt, vrt_key,
NULL);
+ else if (okey->get_key() != vrt_key)
+ okey->SetKey(IpctSt::kIpcStKeyVrt,vrt_key);
return UPLL_RC_SUCCESS;
} else {
pkey = parent_key->get_key();
}
if (!pkey) {
- free(vrt_key);
+ if (!okey || !(okey->get_key()))
+ free(vrt_key);
return UPLL_RC_ERR_GENERIC;
}
reinterpret_cast<key_vtn *>(pkey)->vtn_name,
(kMaxLenVtnName+1) );
break;
+ case UNC_KT_VLINK:
+ {
+ uint8_t *vnode_name;
+ uint8_t flags = 0;
+ val_vlink *vlink_val = reinterpret_cast<val_vlink *>(GetVal(parent_key));
+ if (!vlink_val) {
+ if (!okey || !(okey->get_key()))
+ free(vrt_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ GET_USER_DATA_FLAGS(parent_key->get_cfg_val(), flags);
+ flags &= VLINK_FLAG_NODE_POS;
+ UPLL_LOG_DEBUG("Vlink flag node position %d",flags);
+ if (flags == kVlinkVnode2) {
+ vnode_name = vlink_val->vnode2_name;
+ } else {
+ vnode_name = vlink_val->vnode1_name;
+ }
+ uuu::upll_strncpy(vrt_key->vrouter_name, vnode_name,
+ (kMaxLenVnodeName + 1));
+ uuu::upll_strncpy(vrt_key->vtn_key.vtn_name, reinterpret_cast<key_vlink *>(
+ parent_key->get_key())->vtn_key.vtn_name , (kMaxLenVtnName+1));
+ }
+ break;
case UNC_KT_VTN:
default:
uuu::upll_strncpy(vrt_key->vtn_key.vtn_name,
}
// cout << "GetChildConfigKey " << vrt_key->vtn_key.vtn_name << " ";
// cout << vrt_key->vrouter_name << "";
- okey = new ConfigKeyVal(UNC_KT_VROUTER, IpctSt::kIpcStKeyVrt, vrt_key, NULL);
+ if (!okey)
+ okey = new ConfigKeyVal(UNC_KT_VROUTER, IpctSt::kIpcStKeyVrt, vrt_key, NULL);
+ else if (okey->get_key() != vrt_key)
+ okey->SetKey(IpctSt::kIpcStKeyVrt, vrt_key);
if (okey == NULL)
result_code = UPLL_RC_ERR_GENERIC;
else
UPLL_LOG_DEBUG("ikey is NULL");
return UPLL_RC_ERR_GENERIC;
}
+ DELETE_IF_NOT_NULL(okey);
unc_key_type_t ikey_type = ikey->get_key_type();
if (ikey_type != UNC_KT_VROUTER) return UPLL_RC_ERR_GENERIC;
okey = new ConfigKeyVal(UNC_KT_VROUTER, IpctSt::kIpcStKeyVrt, vrt_key, tmp1);
if (okey) {
SET_USER_DATA(okey, req);
+ } else {
+ DELETE_IF_NOT_NULL(tmp1);
+ FREE_IF_NOT_NULL(vrt_key);
}
return UPLL_RC_SUCCESS;
}
UPLL_LOG_DEBUG("ConfigKeyVal is NULL");
return UPLL_RC_ERR_GENERIC;
}
- if (ctrlr_id == NULL) return UPLL_RC_ERR_GENERIC;
+
+ DbSubOp dbop = {kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
val_rename_vnode *rename_vnode = reinterpret_cast<val_rename_vnode *>
(ConfigKeyVal::Malloc(sizeof(val_rename_vnode)));
key_vrt *ctrlr_key = reinterpret_cast<key_vrt *>(ikey->get_key());
-
- uuu::upll_strncpy(rename_vnode->ctrlr_vtn_name,
- ctrlr_key->vtn_key.vtn_name,
- (kMaxLenVtnName+1));
- uuu::upll_strncpy(rename_vnode->ctrlr_vnode_name,
- ctrlr_key->vrouter_name,
- (kMaxLenVnodeName+1) );
+
+ rename_vnode->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_INVALID;
+ rename_vnode->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_INVALID;
+ upll_rc_t ret_val = ValidateKey(reinterpret_cast<char *>(ctrlr_key->vtn_key.vtn_name),
+ kMinLenVtnName, kMaxLenVtnName);
+ if (ret_val == UPLL_RC_SUCCESS) {
+ uuu::upll_strncpy(rename_vnode->ctrlr_vtn_name,
+ ctrlr_key->vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ rename_vnode->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
+ }
+ ret_val = ValidateKey(reinterpret_cast<char *>(ctrlr_key->vrouter_name),
+ kMinLenVnodeName, kMaxLenVnodeName);
+ if (ret_val == UPLL_RC_SUCCESS) {
+ uuu::upll_strncpy(rename_vnode->ctrlr_vnode_name,
+ ctrlr_key->vrouter_name,
+ (kMaxLenVnodeName+1) );
+ rename_vnode->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_VALID;
+ }
result_code = GetChildConfigKey(unc_key, NULL);
FREE_IF_NOT_NULL(rename_vnode);
return UPLL_RC_ERR_GENERIC;
}
- SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
+ if (ctrlr_id) {
+ SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
+ }else {
+ dbop.matchop = kOpMatchNone;
+ }
- rename_vnode->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
- rename_vnode->valid[UPLL_CTRLR_VNODE_NAME_VALID] = UNC_VF_VALID;
unc_key->AppendCfgVal(IpctSt::kIpcStValRenameVtn, rename_vnode);
- DbSubOp dbop = {kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
result_code = ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL);
if (result_code == UPLL_RC_SUCCESS) {
UPLL_FUNC_TRACE;
uint8_t rename = 0;
ConfigKeyVal *okey = NULL;
- upll_rc_t result_code;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
#if 0
ConfigKeyVal *dup_key = NULL;
ConfigVal *cval = ikey->get_cfg_val();
UPLL_LOG_DEBUG("Returning error %d",result_code);
return result_code;
}
- GET_USER_DATA_CTRLR_DOMAIN(ikey, *ctrlr_dom);
- if (!ctrlr_dom->ctrlr || !ctrlr_dom->domain) return UPLL_RC_ERR_GENERIC;
+// GET_USER_DATA_CTRLR_DOMAIN(ikey, *ctrlr_dom);
+// if (!ctrlr_dom->ctrlr || !ctrlr_dom->domain) return UPLL_RC_ERR_GENERIC;
SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr | kOpMatchDomain,
kOpInOutFlag };
free(rename_val);
return UPLL_RC_ERR_GENERIC;
}
- memset(ctrlr_key, 0, sizeof(key_vrt));
if (rename & 0x01) { /* vtn renamed */
+ UPLL_LOG_TRACE("Controller Vtn name %s", rename_val->ctrlr_vtn_name);
uuu::upll_strncpy(ctrlr_key->vtn_key.vtn_name,
rename_val->ctrlr_vtn_name, (kMaxLenVtnName+1));
}
- if (rename & 0x10) { /* vnode renamed */
+ if (rename & 0x02) { /* vnode renamed */
+ UPLL_LOG_TRACE("COntroller Vnode name %s", rename_val->ctrlr_vnode_name);
uuu::upll_strncpy(ctrlr_key->vrouter_name,
rename_val->ctrlr_vnode_name, (kMaxLenVnodeName+1));
}
- SET_USER_DATA_FLAGS(okey, rename);
+ SET_USER_DATA_FLAGS(ikey, rename);
delete okey;
return UPLL_RC_SUCCESS;
}
unc_keytype_configstatus_t cs_status =
(driver_result == 0) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
vrt_val = reinterpret_cast<val_vrt *> (GetVal(vrt_key));
+ val_vrt *vrt_val2 = reinterpret_cast<val_vrt *>(GetVal(upd_key));
if (vrt_val == NULL) return UPLL_RC_ERR_GENERIC;
- vrt_val->cs_row_status = cs_status;
+ UPLL_LOG_TRACE("Key in Candidate %s", (vrt_key->ToStrAll()).c_str());
+
if (op == UNC_OP_CREATE) {
+ vrt_val->cs_row_status = cs_status;
val_db_vrtst = reinterpret_cast<val_db_vrt_st *>
(ConfigKeyVal::Malloc(sizeof(val_db_vrt_st)));
val_vrtst = &val_db_vrtst->vrt_val_st;
- val_vrtst->oper_status = UPLL_OPER_STATUS_UNINIT;
+ val_vrtst->oper_status = UPLL_OPER_STATUS_DOWN;
val_vrtst->valid[UPLL_IDX_OPER_STATUS_VRTS] = UNC_VF_VALID;
val_db_vrtst->down_count = 0;
val_db_vrtst->fault_count = 0;
/* compare values */
void *val = reinterpret_cast<void *>(vrt_val);
CompareValidValue(val, GetVal(upd_key), true);
+ UPLL_LOG_TRACE("Key in Running%s", (upd_key->ToStrAll()).c_str());
+ vrt_val->cs_row_status = vrt_val2->cs_row_status;
} else {
return UPLL_RC_ERR_GENERIC;
}
for (int loop = 0; loop < nloop; ++loop) {
- if (vrt_val->valid[loop] == UNC_VF_NOT_SOPPORTED) {
- vrt_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
- } else if ((UNC_VF_VALID == (uint8_t) vrt_val->valid[loop])
- || (UNC_VF_VALID_NO_VALUE == (uint8_t) vrt_val->valid[loop])) {
- vrt_val->cs_attr[loop] = (uint8_t) vrt_val->cs_row_status;
- }
+ if ((UNC_VF_VALID == (uint8_t) vrt_val->valid[loop])
+ || (UNC_VF_VALID_NO_VALUE == (uint8_t) vrt_val->valid[loop])) {
+ // Description is set to APPLIED
+ if (loop == UPLL_IDX_DESC_VRT)
+ vrt_val->cs_attr[loop] = UNC_CS_APPLIED;
+ else
+ vrt_val->cs_attr[loop] = cs_status;
+ } else if ((UNC_VF_INVALID == vrt_val->valid[loop]) &&
+ (UNC_OP_CREATE == op)) {
+ vrt_val->cs_attr[loop] = UNC_CS_APPLIED;
+ } else if ((UNC_VF_INVALID == vrt_val->valid[loop]) &&
+ (UNC_OP_UPDATE == op)) {
+ vrt_val->cs_attr[loop] = vrt_val2->cs_attr[loop];
+ }
}
return result_code;
}
return UPLL_RC_ERR_GENERIC;
}
if (uuc::kUpllUcpCreate == phase) val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
for (unsigned int loop = 0; loop < sizeof(val->valid) / sizeof(uint8_t);
++loop) {
if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
UPLL_LOG_DEBUG(" Input is NULL ");
return UPLL_RC_ERR_GENERIC;
}
+ ConfigKeyVal *dup_key = NULL;
+ result_code = GetChildConfigKey(dup_key, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed");
+ if(dup_key) delete dup_key;
+ return result_code;
+ }
/*
* Here getting FULL Key (VTN & VBR Name )
*/
- result_code = ReadConfigDB(ikey, UPLL_DT_IMPORT, UNC_OP_READ, dbop, dmi,
+ result_code = ReadConfigDB(dup_key, UPLL_DT_IMPORT, UNC_OP_READ, dbop, dmi,
MAINTBL);
- if (UPLL_RC_SUCCESS != result_code) return result_code;
+ if (UPLL_RC_SUCCESS != result_code) {
+ if (dup_key) delete dup_key;
+ return result_code;
+ }
/* checks the vnode name present in the running vnode under the
* same vtn
*/
- while (ikey) {
+ ConfigKeyVal * travel = dup_key;
+ while (travel) {
/* Same Name should not present in the vnodes in running*/
- result_code = VnodeChecks(ikey, UPLL_DT_RUNNING, dmi);
-
- if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code){
- UPLL_LOG_DEBUG("VRouter Name Conflict %d", result_code);
- return UPLL_RC_ERR_MERGE_CONFLICT;
+ result_code = VnodeChecks(travel, UPLL_DT_CANDIDATE, dmi);
+
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code ||
+ UPLL_RC_ERR_CFG_SEMANTIC == result_code) {
+ result_code = GetChildConfigKey(ikey, travel);
+ if (dup_key) delete dup_key;
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed");
+ return result_code;
+ }
+ UPLL_LOG_DEBUG("VRouter Name Conflict %d", result_code);
+ return UPLL_RC_ERR_MERGE_CONFLICT;
}
/* Any other DB error */
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("Vnode Checks Failed %d", result_code);
+ if(dup_key) delete dup_key;
return result_code;
}
- ikey = ikey->get_next_cfg_key_val();
+ travel = travel->get_next_cfg_key_val();
}
+ if (dup_key)
+ delete dup_key;
return result_code;
}
result_code = GetChildConfigKey(tmp_key, ikey);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetChildConfigKey Failed ");
+ FREE_IF_NOT_NULL(vnode);
return result_code;
}
DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain};
MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("ReadConfigDB Failed");
+ delete tmp_key;
+ FREE_IF_NOT_NULL(vnode);
return result_code;
}
controller_domain ctrlr_dom;
result_code = GetControllerDomainId(tmp_key, &ctrlr_dom);
- if (UPLL_RC_SUCCESS != result_code)
+ if (UPLL_RC_SUCCESS != result_code) {
+ delete tmp_key;
return result_code;
+ }
SET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
vnode->valid[UPLL_CTRLR_VTN_NAME_VALID] = UNC_VF_VALID;
bool invalid_attr = true;
val_vrt_t *val_vrt1 = reinterpret_cast<val_vrt_t *>(val1);
val_vrt_t *val_vrt2 = reinterpret_cast<val_vrt_t *>(val2);
- if ((UNC_VF_VALID == val_vrt1->valid[UPLL_IDX_DESC_VRT])
- && (UNC_VF_VALID == val_vrt2->valid[UPLL_IDX_DESC_VRT]))
- if (!strcmp(reinterpret_cast<char*>(val_vrt1->vrt_description),
- reinterpret_cast<char*>(val_vrt2->vrt_description)))
- val_vrt1->valid[UPLL_IDX_DESC_VRT] = UNC_VF_INVALID;
for (unsigned int loop = 0;
loop < sizeof(val_vrt1->valid) / sizeof(uint8_t); ++loop) {
if (UNC_VF_INVALID == val_vrt1->valid[loop]
&& UNC_VF_VALID == val_vrt2->valid[loop])
val_vrt1->valid[loop] = UNC_VF_VALID_NO_VALUE;
}
+ if (UNC_VF_INVALID != val_vrt1->valid[UPLL_IDX_DESC_VRT]) {
+ if (!copy_to_running ||
+ ((UNC_VF_VALID == val_vrt1->valid[UPLL_IDX_DESC_VRT]) &&
+ !strcmp(reinterpret_cast<char*>(val_vrt1->vrt_description),
+ reinterpret_cast<char*>(val_vrt2->vrt_description))))
+ val_vrt1->valid[UPLL_IDX_DESC_VRT] = UNC_VF_INVALID;
+ }
if (UNC_VF_VALID == val_vrt1->valid[UPLL_IDX_CONTROLLER_ID_VRT]
&& UNC_VF_VALID == val_vrt2->valid[UPLL_IDX_CONTROLLER_ID_VRT]) {
- if (strcmp(reinterpret_cast<char*>(val_vrt1->controller_id),
- reinterpret_cast<char*>(val_vrt2->controller_id)))
+ if (!strcmp(reinterpret_cast<char*>(val_vrt1->controller_id),
+ reinterpret_cast<char*>(val_vrt2->controller_id)))
val_vrt1->valid[UPLL_IDX_CONTROLLER_ID_VRT] = UNC_VF_INVALID;
}
+ if (UNC_VF_VALID == val_vrt1->valid[UPLL_IDX_DOMAIN_ID_VRT]
+ && UNC_VF_VALID == val_vrt2->valid[UPLL_IDX_DOMAIN_ID_VRT]) {
+ if (!strcmp(reinterpret_cast<char*>(val_vrt1->domain_id),
+ reinterpret_cast<char*>(val_vrt2->domain_id)))
+ val_vrt1->valid[UPLL_IDX_DOMAIN_ID_VRT] = UNC_VF_INVALID;
+ }
if (UNC_VF_VALID == val_vrt1->valid[UPLL_IDX_DHCP_RELAY_ADMIN_STATUS_VRT]
&& UNC_VF_VALID
== val_vrt2->valid[UPLL_IDX_DHCP_RELAY_ADMIN_STATUS_VRT]) {
if (val_vrt1->dhcp_relay_admin_status == val_vrt2->dhcp_relay_admin_status)
val_vrt1->valid[UPLL_IDX_DHCP_RELAY_ADMIN_STATUS_VRT] = UNC_VF_INVALID;
}
+ if (!copy_to_running)
+ val_vrt1->valid[UPLL_IDX_DESC_VRT] = UNC_VF_INVALID;
for (unsigned int loop = 0;
loop < sizeof(val_vrt1->valid) / sizeof(val_vrt1->valid[0]);
++loop) {
if ((UNC_VF_VALID == (uint8_t) val_vrt1->valid[loop]) ||
- (UNC_VF_VALID_NO_VALUE == (uint8_t) val_vrt1->valid[loop]))
- invalid_attr = false;
+ (UNC_VF_VALID_NO_VALUE == (uint8_t) val_vrt1->valid[loop])) {
+ invalid_attr = false;
+ break;
+ }
}
return invalid_attr;
}
return UPLL_RC_SUCCESS;
}
-upll_rc_t VrtMoMgr::ValidateVrtValue(val_vrt *vrt_val,
- uint32_t operation) {
+upll_rc_t VrtMoMgr::CtrlrIdAndDomainIdUpdationCheck(ConfigKeyVal *ikey,
+ ConfigKeyVal *okey) {
UPLL_FUNC_TRACE;
- upll_rc_t ret_val = UPLL_RC_SUCCESS;
-
+ val_vrt *vrt_val = reinterpret_cast<val_vrt *>(GetVal(ikey));
+ val_vrt *vrt_val1 = reinterpret_cast<val_vrt *>(GetVal(okey));
if (vrt_val->valid[UPLL_IDX_CONTROLLER_ID_VRT] == UNC_VF_VALID) {
- ret_val = ValidateKey(reinterpret_cast<char *>(vrt_val->controller_id),
- kMinLenCtrlrId,
- kMaxLenCtrlrId);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("controller_id syntax check failed."
- "Received controller_id - %s",
- vrt_val->controller_id);
+ if (strncmp(reinterpret_cast<const char *>(vrt_val->controller_id),
+ reinterpret_cast<const char *>(vrt_val1->controller_id),
+ kMaxLenCtrlrId+1)) {
+ UPLL_LOG_DEBUG("controller id comparision failed");
return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else if ((vrt_val->valid[UPLL_IDX_CONTROLLER_ID_VRT] == UNC_VF_INVALID ||
- vrt_val->valid[UPLL_IDX_CONTROLLER_ID_VRT] == UNC_VF_VALID_NO_VALUE) &&
- (operation == UNC_OP_CREATE)) {
- UPLL_LOG_DEBUG("Controller id is invalid/ valid_no_value");
- return UPLL_RC_ERR_CFG_SYNTAX;
+ }
}
if (vrt_val->valid[UPLL_IDX_DOMAIN_ID_VRT] == UNC_VF_VALID) {
- ret_val = ValidateDefaultStr(reinterpret_cast<char *>(vrt_val->domain_id),
- kMinLenDomainId,
- kMaxLenDomainId);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Domain_id syntax check failed."
- "Received Domain_id - %s",
- vrt_val->domain_id);
+ if (strncmp(reinterpret_cast<const char *>(vrt_val->domain_id),
+ reinterpret_cast<const char *>(vrt_val1->domain_id),
+ kMaxLenDomainId+1)) {
+ UPLL_LOG_DEBUG("domain id comparision failed");
return UPLL_RC_ERR_CFG_SYNTAX;
}
- } else if ((vrt_val->valid[UPLL_IDX_DOMAIN_ID_VRT] == UNC_VF_INVALID ||
- vrt_val->valid[UPLL_IDX_DOMAIN_ID_VRT] == UNC_VF_VALID_NO_VALUE) &&
- (operation == UNC_OP_CREATE)) {
- UPLL_LOG_DEBUG("Domain id is invalid/ valid_no_value");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- if (vrt_val->valid[UPLL_IDX_DESC_VRT] == UNC_VF_VALID) {
- ret_val = ValidateDesc(reinterpret_cast<char *>(vrt_val->vrt_description),
- kMinLenDescription,
- kMaxLenDescription);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Description syntax check failed."
- "Received Description - %s",
- vrt_val->vrt_description);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+
+upll_rc_t VrtMoMgr::ValidateVrtValue(val_vrt *vrt_val,
+ uint32_t operation) {
+ UPLL_FUNC_TRACE;
+ bool ret_val = false;
+
+ // Attribute syntax validation
+ for (unsigned int valid_index = 0;
+ valid_index < sizeof(vrt_val->valid) / sizeof(vrt_val->valid[0]);
+ valid_index++) {
+ if (vrt_val->valid[valid_index] == UNC_VF_VALID) {
+ switch(valid_index) {
+ case UPLL_IDX_CONTROLLER_ID_VRT:
+ ret_val = ValidateString(vrt_val->controller_id,
+ kMinLenCtrlrId, kMaxLenCtrlrId);
+ break;
+ case UPLL_IDX_DOMAIN_ID_VRT:
+ ret_val = ValidateDefaultStr(vrt_val->domain_id,
+ kMinLenDomainId, kMaxLenDomainId);
+ break;
+ case UPLL_IDX_DESC_VRT:
+ ret_val = ValidateDesc(vrt_val->vrt_description,
+ kMinLenDescription, kMaxLenDescription);
+ break;
+ case UPLL_IDX_DHCP_RELAY_ADMIN_STATUS_VRT:
+ ret_val = ValidateNumericRange(
+ (uint8_t) vrt_val->dhcp_relay_admin_status,
+ (uint8_t) UPLL_ADMIN_ENABLE,
+ (uint8_t) UPLL_ADMIN_DISABLE, true, true);
+ break;
+ }
+ if (!ret_val) {
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
}
- } else if (vrt_val->valid[UPLL_IDX_DESC_VRT] == UNC_VF_VALID_NO_VALUE
- && (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE)) {
- uuu::upll_strncpy(vrt_val->vrt_description, " ", 2);
- }
- if (vrt_val->valid[UPLL_IDX_DHCP_RELAY_ADMIN_STATUS_VRT] == UNC_VF_VALID) {
- if (!ValidateNumericRange((uint8_t) vrt_val->dhcp_relay_admin_status,
- (uint8_t) UPLL_ADMIN_ENABLE,
- (uint8_t) UPLL_ADMIN_DISABLE, true, true)) {
- UPLL_LOG_INFO("Admin status syntax check failed."
- "Received adminstatus - %d",
- vrt_val->dhcp_relay_admin_status);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+
+ // Additional checks
+ for (unsigned int valid_index = 0;
+ valid_index < sizeof(vrt_val->valid) / sizeof(vrt_val->valid[0]);
+ valid_index++) {
+ uint8_t flag = vrt_val->valid[valid_index];
+ switch (operation) {
+ case UNC_OP_CREATE:
+ {
+ switch(valid_index) {
+ case UPLL_IDX_CONTROLLER_ID_VRT:
+ case UPLL_IDX_DOMAIN_ID_VRT:
+ if ((flag == UNC_VF_INVALID || flag == UNC_VF_VALID_NO_VALUE)) {
+ UPLL_LOG_INFO("controller_id or domain_id flag is invalid"
+ " or valid_no_value");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ break;
+ case UPLL_IDX_DESC_VRT:
+ break;
+ case UPLL_IDX_DHCP_RELAY_ADMIN_STATUS_VRT:
+ if ((flag == UNC_VF_INVALID) || (flag == UNC_VF_VALID_NO_VALUE)) {
+ vrt_val->dhcp_relay_admin_status = UPLL_ADMIN_ENABLE; // TODO: Admin status reset value
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ case UNC_OP_UPDATE:
+ {
+ switch(valid_index) {
+ case UPLL_IDX_CONTROLLER_ID_VRT:
+ case UPLL_IDX_DOMAIN_ID_VRT:
+ if (flag == UNC_VF_VALID_NO_VALUE) {
+ UPLL_LOG_INFO("controller_id or domain_id flag is valid_no_value");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ break;
+ case UPLL_IDX_DESC_VRT:
+ case UPLL_IDX_DHCP_RELAY_ADMIN_STATUS_VRT:
+ default:
+ break;
+ }
+ }
+ break;
}
}
-#if 0
- else if (vrt_val->valid[UPLL_IDX_DHCP_RELAY_ADMIN_STATUS_VRT]
- == UNC_VF_VALID_NO_VALUE
- && (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE)) {
- vrt_val->dhcp_relay_admin_status = UPLL_ADMIN_ENABLE;
+
+ // Resets
+ for (unsigned int valid_index = 0;
+ valid_index < sizeof(vrt_val->valid) / sizeof(vrt_val->valid[0]);
+ valid_index++) {
+ uint8_t flag = vrt_val->valid[valid_index];
+ if (flag != UNC_VF_INVALID && flag != UNC_VF_VALID_NO_VALUE)
+ continue;
+
+ switch(valid_index) {
+ case UPLL_IDX_CONTROLLER_ID_VRT:
+ StringReset(vrt_val->controller_id);
+ break;
+ case UPLL_IDX_DOMAIN_ID_VRT:
+ StringReset(vrt_val->domain_id);
+ break;
+ case UPLL_IDX_DESC_VRT:
+ StringReset(vrt_val->vrt_description);
+ break;
+ case UPLL_IDX_DHCP_RELAY_ADMIN_STATUS_VRT: // TODO: check admin_status is enable or disable when reset
+ vrt_val->dhcp_relay_admin_status = UPLL_ADMIN_ENABLE;
+ break;
+ default:
+ UPLL_LOG_TRACE("Never here");
+ break;
+ }
}
-#endif
- return UPLL_RC_SUCCESS;
+ return UPLL_RC_SUCCESS;
}
upll_rc_t VrtMoMgr::ValidateVrtPingValue(val_ping *ping_val) {
ping_val->target_addr);
return UPLL_RC_ERR_CFG_SYNTAX;
}
+ } else {
+ UPLL_LOG_DEBUG("Target Address is mandatory for ping operation");
+ return UPLL_RC_ERR_CFG_SYNTAX;
}
if (ping_val->valid[UPLL_IDX_SRC_ADDR_PING] == UNC_VF_VALID) {
if ((!bc_check(ping_val->src_addr)) || (!mc_check(ping_val->src_addr))) {
}
return UPLL_RC_SUCCESS;
} else if ((operation == UNC_OP_READ || operation == UNC_OP_READ_SIBLING ||
- operation == UNC_OP_READ_SIBLING_BEGIN || UNC_OP_READ_SIBLING_COUNT)
+ operation == UNC_OP_READ_SIBLING_BEGIN ||
+ operation == UNC_OP_READ_SIBLING_COUNT)
&& (dt_type == UPLL_DT_STATE)) {
if (option1 == UNC_OPT1_NORMAL) {
ConfigKeyVal *ikey,
const char *ctrlr_name) {
UPLL_FUNC_TRACE;
- upll_rc_t ret_val = UPLL_RC_SUCCESS;
- /** read datatype, operation, options from IpcReqRespHeader */
+ upll_rc_t ret_val = UPLL_RC_ERR_GENERIC;
+
if (!ikey || !req ) {
UPLL_LOG_INFO(" ConfigKeyVal / IpcReqRespHeader is NULL");
return UPLL_RC_ERR_GENERIC;
}
- if (!ctrlr_name)
- ctrlr_name = reinterpret_cast<char *>(ikey->get_user_data());
-
- upll_keytype_datatype_t dt_type = req->datatype;
- unc_keytype_operation_t operation = req->operation;
- unc_keytype_option1_t option1 = req->option1;
- unc_keytype_option2_t option2 = req->option2;
- if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
- if (dt_type == UPLL_DT_CANDIDATE || UPLL_DT_IMPORT == dt_type) {
- ret_val = ValidateVrtAttributeSupportCheck(ctrlr_name, ikey, operation);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("vrt struct attributes are not supported by ctrlr");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_INFO("Unsupported datatype -(%d)", dt_type);
+ if (!ctrlr_name) {
+ ctrlr_name = reinterpret_cast<char*>((reinterpret_cast<key_user_data_t *>
+ (ikey->get_user_data()))->ctrlr_id);
+ if (!ctrlr_name || !strlen(ctrlr_name)) {
+ UPLL_LOG_DEBUG("Controller Name is NULL");
return UPLL_RC_ERR_GENERIC;
}
- } else if (operation == UNC_OP_READ || operation == UNC_OP_READ_SIBLING
- || operation == UNC_OP_READ_SIBLING_BEGIN
- || operation == UNC_OP_READ_SIBLING_COUNT) {
- if (dt_type == UPLL_DT_CANDIDATE || dt_type == UPLL_DT_RUNNING
- || dt_type == UPLL_DT_STARTUP || dt_type == UPLL_DT_STATE) {
- if (option1 != UNC_OPT1_NORMAL) {
- UPLL_LOG_INFO("Error option1 is not NORMAL");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- if (option2 != UNC_OPT2_NONE) {
- UPLL_LOG_INFO("Error option2 is not NONE");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- if (NULL == ikey->get_cfg_val()) {
- UPLL_LOG_INFO("ConfigVal struct is empty");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- if (ikey->get_cfg_val()->get_val() != NULL) {
- ret_val = ValidateVrtAttributeSupportCheck(ctrlr_name, ikey, operation);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("VRT struct capa check failure for read operation");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_TRACE("val_vrt struct is an optional");
- return UPLL_RC_SUCCESS;
- }
- } else {
- UPLL_LOG_INFO("Unsupported datatype - (%d)", dt_type);
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
- }
}
- UPLL_LOG_INFO("Unsupported operation -(%d)", operation);
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
-}
-upll_rc_t VrtMoMgr::ValidateVrtAttributeSupportCheck(const char *ctrlr_name,
- ConfigKeyVal *ikey,
- uint32_t operation) {
- UPLL_FUNC_TRACE;
bool result_code = false;
uint32_t max_attrs = 0;
uint32_t max_instance_count = 0;
const uint8_t *attrs;
- switch (operation) {
+ switch (req->operation) {
case UNC_OP_CREATE:
result_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
&max_instance_count, &max_attrs,
case UNC_OP_READ_SIBLING:
case UNC_OP_READ_SIBLING_BEGIN:
case UNC_OP_READ_SIBLING_COUNT:
- result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ result_code = GetStateCapability(ctrlr_name, ikey->get_key_type(),
&max_attrs, &attrs);
break;
default:
if (!result_code) {
UPLL_LOG_DEBUG("key_type - %d is not supported by controller - %s",
ikey->get_key_type(), ctrlr_name);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
- if (NULL == ikey->get_cfg_val()) {
- UPLL_LOG_DEBUG("ConfigVal struct is empty");
- return UPLL_RC_ERR_CFG_SYNTAX;
+
+ val_vrt *vrt_val = NULL;
+
+ if ((ikey->get_cfg_val()) &&
+ ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVrt)) {
+ vrt_val = reinterpret_cast<val_vrt *>(ikey->get_cfg_val()->get_val());
}
- if (ikey->get_cfg_val()->get_st_num() != IpctSt::kIpcStValVrt) {
- UPLL_LOG_INFO("Invalid value structure received. received struct - %d",
- ikey->get_cfg_val()->get_st_num());
- return UPLL_RC_ERR_CFG_SYNTAX;
+ if (vrt_val) {
+ if (max_attrs > 0) {
+ ret_val = ValidateVrtAttributeSupportCheck(vrt_val, attrs, req->operation);
+ return ret_val;
+ } else {
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d", req->operation);
+ return UPLL_RC_ERR_GENERIC;
+ }
}
- val_vrt *vrt_val = reinterpret_cast<val_vrt *>
- (ikey->get_cfg_val()->get_val());
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VrtMoMgr::ValidateVrtAttributeSupportCheck(val_vrt_t *vrt_val,
+ const uint8_t *attrs,
+ unc_keytype_operation_t operation) {
+ UPLL_FUNC_TRACE;
if (vrt_val != NULL) {
-#if 0 // CHECK
- if ((vrt_val->valid[UPLL_IDX_CONTROLLER_ID_VRT] == UNC_VF_VALID) ||
- (vrt_val->valid[UPLL_IDX_CONTROLLER_ID_VRT] == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vrt::kCapControllerId] == 0) {
- vrt_val->valid[UPLL_IDX_CONTROLLER_ID_VRT] = UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_INFO("Controller id attr is not supported by pfc ctrlr ");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ if ((vrt_val->valid[UPLL_IDX_DOMAIN_ID_VRT] == UNC_VF_VALID) ||
+ (vrt_val->valid[UPLL_IDX_DOMAIN_ID_VRT] == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vrt::kCapDomainId] == 0) {
+ vrt_val->valid[UPLL_IDX_DOMAIN_ID_VRT] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_INFO("Domain id attr is not supported by pfc ctrlr ");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
}
}
-#endif
if ((vrt_val->valid[UPLL_IDX_DESC_VRT] == UNC_VF_VALID)
|| (vrt_val->valid[UPLL_IDX_DESC_VRT] == UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vrt::kCapDesc] == 0) {
- vrt_val->valid[UPLL_IDX_DESC_VRT] = UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_INFO("Description attr is not supported by pfc ctrlr ");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ vrt_val->valid[UPLL_IDX_DESC_VRT] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_INFO("Description attr is not supported by pfc ctrlr ");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
}
}
if ((vrt_val->valid[UPLL_IDX_DHCP_RELAY_ADMIN_STATUS_VRT] == UNC_VF_VALID)
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vrt::kCapDhcpRelayAdminStatus] == 0) {
vrt_val->valid[UPLL_IDX_DHCP_RELAY_ADMIN_STATUS_VRT] =
- UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_INFO("Admin status attr is not supported by pfc ctrlr ");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_INFO("Admin status attr is not supported by pfc ctrlr ");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
}
}
- return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_INFO("Error Vrouter value structure is NULL");
+ return UPLL_RC_ERR_CFG_SYNTAX;
}
- UPLL_LOG_INFO("Error val_vrt struct is NULL");
- return UPLL_RC_ERR_CFG_SYNTAX;
+ return UPLL_RC_SUCCESS;
}
upll_rc_t VrtMoMgr::CreateVnodeConfigKey(ConfigKeyVal *ikey,
MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>
(GetMoManager(UNC_KT_VRT_IF)));
result_code = mgr->IsReferenced(ikey, dt_type, dmi);
- if (UPLL_RC_SUCCESS != result_code)
- return result_code;
- return UPLL_RC_SUCCESS;
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code (%d)",
+ result_code);
+ return result_code;
+ }
+ UPLL_LOG_DEBUG("IsReferenced result code (%d)", result_code);
+ return result_code;
}
upll_rc_t VrtMoMgr::AdaptValToVtnService(ConfigKeyVal *ikey) {
}
return UPLL_RC_SUCCESS;
}
+
+upll_rc_t VrtMoMgr::EnableAdminStatus(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ if (ikey->get_key_type() != UNC_KT_VROUTER)
+ return UPLL_RC_ERR_CFG_SYNTAX;
+
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutNone};
+ uint32_t sibling_count = 0;
+ string dhcpif_name = "";
+
+ val_vrt_t *vrt_val = reinterpret_cast<val_vrt_t *>(GetVal(ikey));
+ if ((vrt_val->valid[UPLL_IDX_DHCP_RELAY_ADMIN_STATUS_VRT] != UNC_VF_VALID) &&
+ (vrt_val->dhcp_relay_admin_status != UPLL_ADMIN_ENABLE)) {
+ UPLL_LOG_DEBUG("Semantic check not required!");
+ return UPLL_RC_SUCCESS;
+ }
+
+ UPLL_LOG_DEBUG("Check for dhcp-relay server");
+ key_dhcp_relay_server *dhcp_server_key = (key_dhcp_relay_server *)
+ ConfigKeyVal::Malloc(sizeof(key_dhcp_relay_server));
+
+ memcpy(dhcp_server_key, ikey->get_key(), sizeof(key_vrt_t));
+ ConfigKeyVal *ckv_dhcpserver = new ConfigKeyVal(UNC_KT_DHCPRELAY_SERVER,
+ IpctSt::kIpcStKeyDhcpRelayServer,
+ dhcp_server_key);
+
+ MoMgrImpl *dhcpserver_mgr = reinterpret_cast<MoMgrImpl*>(const_cast
+ <MoManager *>(GetMoManager(UNC_KT_DHCPRELAY_SERVER)));
+ upll_rc_t result_code = dhcpserver_mgr->ReadConfigDB(ckv_dhcpserver,
+ UPLL_DT_CANDIDATE, UNC_OP_READ,
+ dbop, sibling_count, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("dhcp-relay server is not configured!");
+ delete ckv_dhcpserver;
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+
+ delete ckv_dhcpserver;
+ UPLL_LOG_DEBUG("Check for dhcp-relay interface");
+ key_dhcp_relay_if *dhcp_if_key = (key_dhcp_relay_if *)
+ malloc(sizeof(key_dhcp_relay_if));
+ memset(dhcp_if_key, 0, sizeof(key_dhcp_relay_if));
+ memcpy(dhcp_if_key, ikey->get_key(), sizeof(key_vrt_t));
+ ConfigKeyVal *ckv_dhcpif = new ConfigKeyVal(UNC_KT_DHCPRELAY_IF,
+ IpctSt::kIpcStKeyDhcpRelayIf,
+ dhcp_if_key);
+ MoMgrImpl *dhcpif_mgr = reinterpret_cast<MoMgrImpl*>(const_cast<MoManager *>
+ (GetMoManager(UNC_KT_DHCPRELAY_IF)));
+ result_code = dhcpif_mgr->ReadConfigDB(ckv_dhcpif, UPLL_DT_CANDIDATE, UNC_OP_READ,
+ dbop, sibling_count, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS || sibling_count == 0) {
+ UPLL_LOG_DEBUG("dhcp-relay interface is not configured!");
+ delete ckv_dhcpif;
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ if (sibling_count > 0) {
+ key_dhcp_relay_if *dhcp_if_key= (key_dhcp_relay_if *)ckv_dhcpif->get_key();
+ dhcpif_name = (const char *)dhcp_if_key->if_name;
+ }
+
+ UPLL_LOG_DEBUG("Check for vrouter interface");
+ key_vrt_if *vrtifkey = (key_vrt_if *)malloc(sizeof(key_vrt_if));
+ memset(vrtifkey, 0, sizeof(key_vrt_if));
+ memcpy(&vrtifkey->vrt_key, ikey->get_key(), sizeof(key_vrt_t));
+ memcpy(vrtifkey->if_name, dhcpif_name.c_str(), dhcpif_name.length()+1);
+ ConfigKeyVal *ckv_vrtif = new ConfigKeyVal(UNC_KT_VRT_IF,
+ IpctSt::kIpcStKeyVrtIf,
+ vrtifkey);
+ DbSubOp dbop2 = {kOpReadSingle, kOpMatchNone, kOpInOutNone};
+ MoMgrImpl *vrtif_mgr = reinterpret_cast<MoMgrImpl*>(const_cast<MoManager *>
+ (GetMoManager(UNC_KT_VRT_IF)));
+ result_code = vrtif_mgr->ReadConfigDB(ckv_vrtif, UPLL_DT_CANDIDATE, UNC_OP_READ,
+ dbop2, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("vrouter interface is not configured!");
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ DELETE_IF_NOT_NULL(ckv_vrtif);
+ UPLL_LOG_DEBUG("Check for vrouter interface on a vlink");
+
+ key_vlink *vlink_key = (key_vlink *)malloc(sizeof(key_vlink));
+ memset(vlink_key, 0, sizeof(key_vlink));
+ key_vrt *vrt_key = (key_vrt *)ikey->get_key();
+ memcpy(&vlink_key->vtn_key, &vrt_key->vtn_key, sizeof(key_vtn_t));
+
+ val_vlink *vlink_val = (val_vlink *)malloc(sizeof(val_vlink));
+ memset(vlink_val, 0, sizeof(val_vlink));
+ memcpy(vlink_val->vnode1_name, vrt_key->vrouter_name, sizeof(vrt_key->vrouter_name));
+ memcpy(vlink_val->vnode1_ifname, dhcpif_name.c_str(), dhcpif_name.length()+1);
+ memcpy(vlink_val->vnode2_name, vrt_key->vrouter_name, sizeof(vrt_key->vrouter_name));
+ memcpy(vlink_val->vnode2_ifname, dhcpif_name.c_str(), dhcpif_name.length()+1);
+ vlink_val->valid[UPLL_IDX_VNODE1_NAME_VLNK] = UNC_VF_VALID;
+ vlink_val->valid[UPLL_IDX_VNODE1_IF_NAME_VLNK] = UNC_VF_VALID;
+ vlink_val->valid[UPLL_IDX_VNODE2_NAME_VLNK] = UNC_VF_INVALID;
+ vlink_val->valid[UPLL_IDX_VNODE2_IF_NAME_VLNK] = UNC_VF_INVALID;
+
+ ConfigKeyVal *ckv_vlink = new ConfigKeyVal(UNC_KT_VLINK,
+ IpctSt::kIpcStKeyVlink,
+ vlink_key,
+ new ConfigVal(IpctSt::kIpcStValVlink, vlink_val));
+ MoMgrImpl *vlink_mgr = reinterpret_cast<MoMgrImpl*>(const_cast<MoManager *>
+ (GetMoManager(UNC_KT_VLINK)));
+ result_code = vlink_mgr->ReadConfigDB(ckv_vlink, UPLL_DT_CANDIDATE, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (result_code == UPLL_RC_SUCCESS) {
+ delete ckv_vlink;
+ UPLL_LOG_DEBUG("vrouter interface is configured on a vlink!");
+ return UPLL_RC_SUCCESS;
+ }
+
+ vlink_val->valid[UPLL_IDX_VNODE1_NAME_VLNK] = UNC_VF_INVALID;
+ vlink_val->valid[UPLL_IDX_VNODE1_IF_NAME_VLNK] = UNC_VF_INVALID;
+ vlink_val->valid[UPLL_IDX_VNODE2_NAME_VLNK] = UNC_VF_VALID;
+ vlink_val->valid[UPLL_IDX_VNODE2_IF_NAME_VLNK] = UNC_VF_VALID;
+
+ result_code = vlink_mgr->ReadConfigDB(ckv_vlink, UPLL_DT_CANDIDATE,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("vrouter interface is not configured on a vlink!");
+ result_code = UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ DELETE_IF_NOT_NULL(ckv_vlink);
+ DELETE_IF_NOT_NULL(ckv_dhcpif);
+ return result_code;
+}
+
} // namespace kt_momgr
} // namespace upll
} // namespace unc
* associated attributes are supported on the given controller,
* based on the valid flag.
*
- * @param[in] crtlr_name Controller name.
- * @param[in] ikey Corresponding key and value structure.
+ * @param[in] vrt_val KT_VROUTER Value structure.
+ * @param[in] attrs Pointer to controller attribute.
* @param[in] operation Operation name.
*
* @retval UPLL_RC_SUCCESS validation succeeded.
* @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
* @retval UPLL_RC_ERR_GENERIC Generic failure.
*/
- upll_rc_t ValidateVrtAttributeSupportCheck(const char *ctrlr_name,
- ConfigKeyVal *kval,
- uint32_t operation);
+ upll_rc_t ValidateVrtAttributeSupportCheck(val_vrt_t *vrt_val,
+ const uint8_t *attrs,
+ unc_keytype_operation_t operation);
/**
* @brief Duplicates the input configkeyval including the key and val.
MoMgrTables tbl);
upll_rc_t CopyToConfigKey(ConfigKeyVal *&okey,
ConfigKeyVal *ikey);
+ /**
+ * @Brief compares controller id and domain id before
+ * updating the value to DB.
+ *
+ * @param[in] ikey ikey contains key and value structure.
+ * @param[in] okey okey contains key and value structure.
+ *
+ * @retval UPLL_RC_SUCCESS Successful.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX Syntax error.
+ */
+ upll_rc_t CtrlrIdAndDomainIdUpdationCheck(ConfigKeyVal *ikey,
+ ConfigKeyVal *okey);
/**
* @brief create entry in Vnode Rename Table,
* with the renamed VTN details fetched from VTN rename Table
*/
upll_rc_t CreateVnodeConfigKey(ConfigKeyVal *ikey,
ConfigKeyVal *&okey);
+ upll_rc_t EnableAdminStatus(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req);
};
} // namespace kt_momgr
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 NEC Corporation
+ * All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+#include "vtep_grp_momgr.hh"
+#include "ctrlr_mgr.hh"
+#include "vtn_momgr.hh"
+#include "vtepgrp_mem_momgr.hh"
+#define NUM_KEY_MAIN_TBL_ 5
+
+namespace unc {
+namespace upll {
+namespace kt_momgr {
+
+ BindInfo VtepGrpMoMgr::vtep_grp_bind_info[] = {
+ { uudst::vtep_group::kDbiVtnName, CFG_KEY,
+ offsetof(key_vtep_grp, vtn_key.vtn_name), uud::kDalChar,
+ kMaxLenVtnName+1 },
+ { uudst::vtep_group::kDbiVtepgrpName, CFG_KEY,
+ offsetof(key_vtep_grp, vtepgrp_name), uud::kDalChar,
+ kMaxLenVnodeName+1 },
+ { uudst::vtep_group::kDbiCtrlrName, CFG_VAL,
+ offsetof(val_vtep_grp, controller_id), uud::kDalChar, kMaxLenCtrlrId+1},
+ { uudst::vtep_group::kDbiCtrlrName, CK_VAL,
+ offsetof(key_user_data_t, ctrlr_id),
+ uud::kDalChar, kMaxLenCtrlrId+1 },
+ { uudst::vtep_group::kDbiDesc, CFG_VAL, offsetof(val_vtep_grp, description),
+ uud::kDalChar, kMaxLenDescription+1},
+ { uudst::vtep_group::kDbiFlags, CK_VAL, offsetof(key_user_data_t, flags),
+ uud::kDalUint8, 1},
+ { uudst::vtep_group::kDbiValidCtrlrName, CFG_META_VAL,
+ offsetof(val_vtep_grp, valid[0]), uud::kDalUint8, 1},
+ { uudst::vtep_group::kDbiValidDesc, CFG_META_VAL,
+ offsetof(val_vtep_grp, valid[1]), uud::kDalUint8, 1},
+ { uudst::vtep_group::kDbiCsRowstatus, CS_VAL,
+ offsetof(val_vtep_grp, cs_row_status), uud::kDalUint8, 1},
+ { uudst::vtep_group::kDbiCsCtrlrName, CS_VAL, offsetof(val_vtep_grp,
+ cs_attr[0]),
+ uud::kDalUint8, 1},
+ { uudst::vtep_group::kDbiCsDesc, CS_VAL, offsetof(val_vtep_grp, cs_attr[1]),
+ uud::kDalUint8, 1}
+ };
+
+unc_key_type_t VtepGrpMoMgr::vtep_grp_child[] = {
+ UNC_KT_VTEP_GRP_MEMBER
+};
+
+VtepGrpMoMgr::VtepGrpMoMgr() {
+ UPLL_FUNC_TRACE;
+ Table *tbl = new Table(uudst::kDbiVtepGrpTbl, UNC_KT_VTEP_GRP,
+ vtep_grp_bind_info,
+ IpctSt::kIpcStKeyVtepGrp, IpctSt::kIpcStValVtepGrp,
+ uudst::vtep_group::kDbiVtepGrpNumCols+1);
+ ntable = MAX_MOMGR_TBLS;
+ table = new Table *[ntable];
+ table[MAINTBL] = tbl;
+ table[RENAMETBL] = NULL;
+ table[CTRLRTBL] = NULL;
+ nchild = sizeof(vtep_grp_child) / sizeof(*vtep_grp_child);
+ child = vtep_grp_child;
+#ifdef _STANDALONE_
+ SetMoManager(UNC_KT_VTEP_GRP, reinterpret_cast<MoMgr *>(this));
+#endif
+}
+
+/*
+ * * Based on the key type the bind info will pass
+ * *
+ bool VtepGrpMoMgr::GetRenameKeyBindInfo(unc_key_type_t key_type, BindInfo *&binfo, int &nattr,
+ MoMgrTables tbl ) {
+ if (MAINTBL == tbl) {
+ nattr = NUM_KEY_MAIN_TBL_;
+ binfo = key_vtep_grp_maintbl_update_bind_info;
+ }
+ return PFC_TRUE;
+ }
+ */
+
+
+
+bool VtepGrpMoMgr::IsValidKey(void *key, uint64_t index) {
+ UPLL_FUNC_TRACE;
+ key_vtep_grp *vtep_grp_key = reinterpret_cast<key_vtep_grp *>(key);
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ switch (index) {
+ case uudst::vtep_group::kDbiVtnName:
+ ret_val = ValidateKey(reinterpret_cast<char *>
+ (vtep_grp_key->vtn_key.vtn_name),
+ kMinLenVtnName, kMaxLenVtnName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("VTN Name is not valid(%d)", ret_val);
+ return false;
+ }
+ break;
+ case uudst::vtep_group::kDbiVtepgrpName:
+ ret_val = ValidateKey(reinterpret_cast<char *>
+ (vtep_grp_key->vtepgrp_name),
+ kMinLenVnodeName,
+ kMaxLenVnodeName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("VtepGroup Name is not valid(%d)", ret_val);
+ return false;
+ }
+ break;
+ default:
+ UPLL_LOG_TRACE("Invalid Key Index");
+ return false;
+ }
+ return true;
+}
+
+upll_rc_t VtepGrpMoMgr::GetChildConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *parent_key) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ key_vtep_grp *vtep_grp_key = static_cast<key_vtep_grp *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtep_grp)));
+ if (vtep_grp_key == NULL) return UPLL_RC_ERR_GENERIC;
+ void *pkey;
+ if (parent_key == NULL) {
+ okey = new ConfigKeyVal(UNC_KT_VTEP_GRP, IpctSt::kIpcStKeyVtepGrp,
+ vtep_grp_key, NULL);
+ return UPLL_RC_SUCCESS;
+ } else {
+ pkey = parent_key->get_key();
+ }
+ if (!pkey) {
+ FREE_IF_NOT_NULL(vtep_grp_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (okey && (okey->get_key())) {
+ FREE_IF_NOT_NULL(vtep_grp_key);
+ if (okey->get_key_type() != UNC_KT_VTEP_GRP)
+ return UPLL_RC_ERR_GENERIC;
+ vtep_grp_key = reinterpret_cast<key_vtep_grp *>(okey->get_key());
+ } else {
+ okey = new ConfigKeyVal(UNC_KT_VTEP_GRP, IpctSt::kIpcStKeyVtepGrp,
+ vtep_grp_key, NULL);
+ if (okey == NULL) {
+ FREE_IF_NOT_NULL(vtep_grp_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ /* presumes MoMgrs receive only supported keytypes */
+ switch (parent_key->get_key_type()) {
+ case UNC_KT_VTEP_GRP:
+ uuu::upll_strncpy(vtep_grp_key->vtepgrp_name,
+ reinterpret_cast<key_vtep_grp *>(pkey)->vtepgrp_name,
+ (kMaxLenVnodeName+1));
+ uuu::upll_strncpy(vtep_grp_key->vtn_key.vtn_name,
+ reinterpret_cast<key_vtep *>(pkey)->vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ break;
+ case UNC_KT_VTN:
+ default:
+ uuu::upll_strncpy(vtep_grp_key->vtn_key.vtn_name,
+ reinterpret_cast<key_vtn *>(pkey)->vtn_name,
+ (kMaxLenVtnName+1));
+ }
+ SET_USER_DATA(okey, parent_key);
+ return result_code;
+}
+
+upll_rc_t VtepGrpMoMgr::GetParentConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *ikey ) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ key_vtep_grp *pkey = (ikey)?
+ static_cast<key_vtep_grp *>(ikey->get_key()):NULL;
+ if (!pkey) return UPLL_RC_ERR_GENERIC;
+
+ if (ikey->get_key_type() != UNC_KT_VTEP_GRP)
+ return UPLL_RC_ERR_GENERIC;
+ key_vtn *vtn_key = reinterpret_cast<key_vtn *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn)));
+ if (!vtn_key) return UPLL_RC_ERR_GENERIC;
+ uuu::upll_strncpy(vtn_key->vtn_name,
+ pkey->vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ DELETE_IF_NOT_NULL(okey);
+ okey = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcStKeyVtn, vtn_key, NULL);
+ if (okey == NULL) {
+ FREE_IF_NOT_NULL(vtn_key);
+ result_code = UPLL_RC_ERR_GENERIC;
+ } else {
+ SET_USER_DATA(okey, ikey);
+ }
+ return result_code;
+}
+
+upll_rc_t VtepGrpMoMgr::AllocVal(ConfigVal *&ck_val,
+ upll_keytype_datatype_t dt_type, MoMgrTables tbl) {
+ UPLL_FUNC_TRACE;
+ void *val;
+ if (ck_val != NULL) return UPLL_RC_ERR_GENERIC;
+ switch (tbl) {
+ case MAINTBL:
+ val = reinterpret_cast<void *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtep_grp)));
+ if (!val) return UPLL_RC_ERR_GENERIC;
+ ck_val = new ConfigVal(IpctSt::kIpcStValVtepGrp, val);
+ if (!ck_val) {
+ FREE_IF_NOT_NULL(reinterpret_cast<val_vtep_grp *>(val));
+ return UPLL_RC_ERR_GENERIC;
+ }
+ break;
+ default:
+ val = NULL;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtepGrpMoMgr::ValidateAttribute(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ controller_domain ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ upll_rc_t result_code = GetControllerDomainId(ikey, UPLL_DT_CANDIDATE,
+ &ctrlr_dom, dmi);
+ if ((result_code != UPLL_RC_SUCCESS) || (ctrlr_dom.ctrlr == NULL)) {
+ UPLL_LOG_INFO("GetControllerDomainId failed err_code %d", result_code);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ // Validate Controller Type
+ unc_keytype_ctrtype_t ctrlrtype;
+ uuc::CtrlrMgr *ctrlr_mgr = uuc::CtrlrMgr::GetInstance();
+ if (!ctrlr_mgr->GetCtrlrType(
+ reinterpret_cast<char *>(ctrlr_dom.ctrlr), req->datatype, &ctrlrtype)) {
+ UPLL_LOG_DEBUG("Specified Controller Doesn't Exist");
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtepGrpMoMgr::GetControllerDomainId(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ controller_domain *ctrlr_dom,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ ConfigKeyVal *okey = NULL;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ if (!ikey || !ctrlr_dom || !(ikey->get_cfg_val())) {
+ UPLL_LOG_INFO("Illegal parameter");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val_vtep_grp *temp_vtep_grp = reinterpret_cast<val_vtep_grp *>
+ (GetVal(ikey));
+ if (temp_vtep_grp->valid[UPLL_IDX_CONTROLLER_ID_VTEPG] != UNC_VF_VALID) {
+ temp_vtep_grp = NULL;
+ result_code = GetChildConfigKey(okey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_ERROR("GetChildConfigKey failed with result_code %d",
+ result_code);
+ return result_code;
+ }
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone,
+ kOpInOutCtrlr | kOpInOutDomain | kOpInOutFlag};
+ result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop,
+ dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_ERROR("Record does Not Exists");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ temp_vtep_grp = reinterpret_cast<val_vtep_grp *>(GetVal(okey));
+ if (!temp_vtep_grp) {
+ UPLL_LOG_DEBUG("value null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (temp_vtep_grp->valid[UPLL_IDX_CONTROLLER_ID_VTEPG] != UNC_VF_VALID
+ || !strlen(reinterpret_cast<char*>(temp_vtep_grp->controller_id))) {
+ ctrlr_dom->ctrlr = NULL;
+ UPLL_LOG_DEBUG("Ctrlr null");
+ } else {
+ SET_USER_DATA(ikey, okey);
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, *ctrlr_dom);
+ DELETE_IF_NOT_NULL(okey);
+ }
+ } else {
+ SET_USER_DATA_CTRLR(ikey, temp_vtep_grp->controller_id);
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, *ctrlr_dom);
+ }
+ ctrlr_dom->domain = reinterpret_cast<uint8_t *>(const_cast<char*>(" "));
+ UPLL_LOG_DEBUG("ctrlr_dom %s %s", ctrlr_dom->ctrlr, ctrlr_dom->domain);
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtepGrpMoMgr::DupConfigKeyVal(ConfigKeyVal *&okey,
+ ConfigKeyVal *&req, MoMgrTables tbl) {
+ UPLL_FUNC_TRACE;
+ if (req == NULL) return UPLL_RC_ERR_GENERIC;
+ if (okey != NULL) return UPLL_RC_ERR_GENERIC;
+ if (req->get_key_type() != UNC_KT_VTEP_GRP)
+ return UPLL_RC_ERR_GENERIC;
+ ConfigVal *tmp1 = NULL, *tmp = (req)->get_cfg_val();
+ if (tmp) {
+ if (tbl == MAINTBL) {
+ val_vtep_grp *ival = reinterpret_cast<val_vtep_grp *>(GetVal(req));
+ val_vtep_grp *vtepgrp_val = reinterpret_cast<val_vtep_grp *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtep_grp)));
+ if (!vtepgrp_val) return UPLL_RC_ERR_GENERIC;
+ memcpy(vtepgrp_val, ival, sizeof(val_vtep_grp));
+ tmp1 = new ConfigVal(IpctSt::kIpcStValVtepGrp, vtepgrp_val);
+ if (!tmp1) {
+ FREE_IF_NOT_NULL(vtepgrp_val);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ };
+ void *tkey = (req != NULL)?(req)->get_key():NULL;
+ key_vtep_grp *ikey = reinterpret_cast<key_vtep_grp *>(tkey);
+ key_vtep_grp *vtepgrp_key = reinterpret_cast<key_vtep_grp *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtep_grp)));
+ if (!vtepgrp_key) {
+ if (tmp1) delete tmp1;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ memcpy(vtepgrp_key, ikey, sizeof(key_vtep_grp));
+ okey = new ConfigKeyVal(UNC_KT_VTEP_GRP, IpctSt::kIpcStKeyVtepGrp,
+ vtepgrp_key, tmp1);
+ if (okey) {
+ SET_USER_DATA(okey, req);
+ } else {
+ if (tmp1) delete tmp1;
+ FREE_IF_NOT_NULL(vtepgrp_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtepGrpMoMgr::UpdateConfigStatus(ConfigKeyVal *vtepgrp_key,
+ unc_keytype_operation_t op,
+ uint32_t driver_result,
+ ConfigKeyVal *upd_key,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ctrlr_key) {
+ UPLL_FUNC_TRACE;
+ val_vtep_grp_t *vtepgrp_val = reinterpret_cast<val_vtep_grp_t *>
+ (GetVal(vtepgrp_key));
+
+ unc_keytype_configstatus_t cs_status =
+ (driver_result == UPLL_RC_SUCCESS) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
+ val_vtep_grp_t *val_running = static_cast<val_vtep_grp_t *>(GetVal(upd_key));
+ if (vtepgrp_val == NULL) return UPLL_RC_ERR_GENERIC;
+ if (op == UNC_OP_CREATE) {
+ vtepgrp_val->cs_row_status = cs_status;
+ } else if (op == UNC_OP_UPDATE) {
+ void *val = reinterpret_cast<void *>(vtepgrp_val);
+ CompareValidValue(val, GetVal(upd_key), true);
+ UPLL_LOG_TRACE("%s", (upd_key->ToStrAll()).c_str());
+ vtepgrp_val->cs_row_status = val_running->cs_row_status;
+ } else {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ for (unsigned int loop = 0;
+ loop < sizeof(vtepgrp_val->valid) / sizeof(vtepgrp_val->valid[0]);
+ ++loop) {
+ if ((UNC_VF_VALID == vtepgrp_val->valid[loop])
+ || (UNC_VF_VALID_NO_VALUE == vtepgrp_val->valid[loop])) {
+ // Description is set to APPLIED
+ if (loop == UPLL_IDX_DESCRIPTION_VTEPG)
+ vtepgrp_val->cs_attr[loop] = UNC_CS_APPLIED;
+ else
+ vtepgrp_val->cs_attr[loop] = cs_status;
+ } else if ((vtepgrp_val->valid[loop] == UNC_VF_INVALID) &&
+ (UNC_OP_CREATE == op)) {
+ vtepgrp_val->cs_attr[loop] = UNC_CS_APPLIED;
+ } else if ((vtepgrp_val->valid[loop] == UNC_VF_INVALID) &&
+ (UNC_OP_UPDATE == op)) {
+ vtepgrp_val->cs_attr[loop] = val_running->cs_attr[loop];
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+bool VtepGrpMoMgr::FilterAttributes(void *&val1, void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op) {
+ UPLL_FUNC_TRACE;
+ val_vtep_grp_t *val_vtepgrp1 = reinterpret_cast<val_vtep_grp_t *>(val1);
+ val_vtepgrp1->valid[UPLL_IDX_DESCRIPTION_VTEPG] = UNC_VF_INVALID;
+ if (op != UNC_OP_CREATE)
+ return CompareValidValue(val1, val2, copy_to_running);
+ return false;
+}
+
+bool VtepGrpMoMgr::CompareValidValue(void *&val1, void *val2,
+ bool copy_to_running) {
+ UPLL_FUNC_TRACE;
+ bool invalid_attr = true;
+ val_vtep_grp_t *val_vtepgrp1 = reinterpret_cast<val_vtep_grp_t *>(val1);
+ val_vtep_grp_t *val_vtepgrp2 = reinterpret_cast<val_vtep_grp_t *>(val2);
+ for ( unsigned int loop = 0;
+ loop < sizeof(val_vtepgrp1->valid)/sizeof(uint8_t); ++loop ) {
+ if ( UNC_VF_INVALID == val_vtepgrp1->valid[loop]
+ && UNC_VF_VALID == val_vtepgrp2->valid[loop])
+ val_vtepgrp1->valid[loop] = UNC_VF_VALID_NO_VALUE;
+ }
+ if (UNC_VF_VALID == val_vtepgrp1->valid[UPLL_IDX_DESCRIPTION_VTEPG]
+ && UNC_VF_VALID == val_vtepgrp2->valid[UPLL_IDX_DESCRIPTION_VTEPG]) {
+ if (!strcmp(reinterpret_cast<char*>(val_vtepgrp1->description),
+ reinterpret_cast<char*>(val_vtepgrp2->description)))
+ val_vtepgrp1->valid[UPLL_IDX_DESCRIPTION_VTEPG] = UNC_VF_INVALID;
+ }
+ if (UNC_VF_VALID == val_vtepgrp1->valid[UPLL_IDX_CONTROLLER_ID_VTEPG]
+ && UNC_VF_VALID == val_vtepgrp2->valid[UPLL_IDX_CONTROLLER_ID_VTEPG]) {
+ if (!strcmp(reinterpret_cast<char*>(val_vtepgrp1->controller_id),
+ reinterpret_cast<char*>(val_vtepgrp2->controller_id)))
+ val_vtepgrp1->valid[UPLL_IDX_CONTROLLER_ID_VTEPG] = UNC_VF_INVALID;
+ }
+ if (!copy_to_running)
+ val_vtepgrp1->valid[UPLL_IDX_DESCRIPTION_VTEPG] = UNC_VF_INVALID;
+ for (unsigned int loop = 0;
+ loop < sizeof(val_vtepgrp1->valid) / sizeof(uint8_t); ++loop) {
+ if ((UNC_VF_VALID == (uint8_t) val_vtepgrp1->valid[loop]) ||
+ (UNC_VF_VALID_NO_VALUE == (uint8_t) val_vtepgrp1->valid[loop])) {
+ invalid_attr = false;
+ break;
+ }
+ }
+ return invalid_attr;
+}
+
+upll_rc_t VtepGrpMoMgr::UpdateAuditConfigStatus(
+ unc_keytype_configstatus_t cs_status,
+ uuc::UpdateCtrlrPhase phase,
+ ConfigKeyVal *&ckv_running) {
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_vtep_grp_t *val = (ckv_running != NULL)?
+ reinterpret_cast<val_vtep_grp_t *>(GetVal(ckv_running)):NULL;
+ if (NULL == val) {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (uuc::kUpllUcpCreate == phase )
+ val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
+ for (unsigned int loop = 0;
+ loop < sizeof(val->valid)/sizeof(uint8_t); ++loop ) {
+ if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
+ cs_status == UNC_CS_APPLIED)
+ val->cs_attr[loop] = cs_status;
+ }
+ return result_code;
+}
+
+upll_rc_t VtepGrpMoMgr::ValidateMessage(IpcReqRespHeader *req,
+ ConfigKeyVal *ikey) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ if (!ikey || !req || !(ikey->get_key())) {
+ UPLL_LOG_DEBUG("IpcReqRespHeader or ConfigKeyVal is Null");
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ unc_key_type_t keytype = ikey->get_key_type();
+ if (UNC_KT_VTEP_GRP != keytype) {
+ UPLL_LOG_DEBUG("Invalid keytype. Keytype- %d", keytype);
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ if (ikey->get_st_num() != IpctSt::kIpcStKeyVtepGrp) {
+ UPLL_LOG_DEBUG("Invalid struct received.Expected struct-kIpcStKeyVtepGrp,"
+ "received struct -%s ", reinterpret_cast<const char *>
+ (IpctSt::GetIpcStdef(ikey->get_st_num())));
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ key_vtep_grp_t *key_vtep_grp = reinterpret_cast<key_vtep_grp_t *>
+ (ikey->get_key());
+ val_vtep_grp_t *val_vtep_grp = NULL;
+ if ((ikey->get_cfg_val()) &&
+ ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVtepGrp)) {
+ val_vtep_grp =
+ reinterpret_cast <val_vtep_grp_t *> (ikey->get_cfg_val()->get_val());
+ }
+ uint32_t dt_type = req->datatype;
+ uint32_t operation = req->operation;
+ uint32_t option1 = req->option1;
+ uint32_t option2 = req->option2;
+
+ ret_val = ValidateVTepGrpKey(key_vtep_grp, operation);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Key struct Validation failed for VTEP_GRP");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ if ((operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) &&
+ (dt_type == UPLL_DT_CANDIDATE)) {
+ if (val_vtep_grp != NULL) {
+ ret_val = ValidateVTepGrpValue(val_vtep_grp, operation);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Val struct validation failed for CREATE/Update op");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_DEBUG("Value structure is mandatory for CREATE/Update op");
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ } else if (((operation == UNC_OP_READ) ||
+ (operation == UNC_OP_READ_SIBLING) ||
+ (operation == UNC_OP_READ_SIBLING_BEGIN) ||
+ (operation == UNC_OP_READ_SIBLING_COUNT)) &&
+ ((dt_type == UPLL_DT_CANDIDATE) ||
+ (dt_type == UPLL_DT_RUNNING) ||
+ (dt_type == UPLL_DT_STARTUP) ||
+ (dt_type == UPLL_DT_STATE))) {
+ if (option1 == UNC_OPT1_NORMAL) {
+ if (option2 == UNC_OPT2_NONE) {
+ if (val_vtep_grp != NULL) {
+ ret_val = ValidateVTepGrpValue(val_vtep_grp);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Val struct validation failed for "
+ "READ operation");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_TRACE("Value strcture is an optional for READ op");
+ return UPLL_RC_SUCCESS;
+ }
+ } else {
+ UPLL_LOG_DEBUG("Option2 is not matching");
+ return UPLL_RC_ERR_INVALID_OPTION2;
+ }
+ } else {
+ UPLL_LOG_DEBUG("Option1 is not matching");
+ return UPLL_RC_ERR_INVALID_OPTION1;
+ }
+ } else if ((operation == UNC_OP_DELETE) ||
+ (((operation == UNC_OP_READ_NEXT) ||
+ (operation == UNC_OP_READ_BULK)) &&
+ ((dt_type == UPLL_DT_CANDIDATE) ||
+ (dt_type == UPLL_DT_RUNNING) ||
+ (dt_type == UPLL_DT_STARTUP)))) {
+ UPLL_LOG_TRACE("Value structure is none for this operation:%d", operation);
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_INFO("Invalid datatype(%d) or operation(%d)", dt_type,
+ operation);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtepGrpMoMgr::ValidateVTepGrpValue(val_vtep_grp_t *val_vtep_grp,
+ uint32_t operation) {
+ UPLL_FUNC_TRACE;
+ bool ret_val =false;
+
+ // Attribute syntax validation
+ for (unsigned int valid_index = 0;
+ valid_index < sizeof(val_vtep_grp->valid)/sizeof(val_vtep_grp->valid[0]);
+ valid_index++) {
+ if (val_vtep_grp->valid[valid_index] == UNC_VF_VALID) {
+ switch (valid_index) {
+ case UPLL_IDX_CONTROLLER_ID_VTEPG:
+ ret_val = ValidateString(val_vtep_grp->controller_id,
+ kMinLenCtrlrId, kMaxLenCtrlrId);
+ break;
+ case UPLL_IDX_DESCRIPTION_VTEPG:
+ ret_val = ValidateDesc(val_vtep_grp->description,
+ kMinLenDescription, kMaxLenDescription);
+ break;
+ }
+ if (!ret_val) {
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ }
+ }
+
+ // Additional checks
+ for (unsigned int valid_index = 0;
+ valid_index < sizeof(val_vtep_grp->valid)/sizeof(val_vtep_grp->valid[0]);
+ valid_index++) {
+ uint8_t flag = val_vtep_grp->valid[valid_index];
+ switch (operation) {
+ case UNC_OP_CREATE:
+ {
+ switch (valid_index) {
+ case UPLL_IDX_CONTROLLER_ID_VTEPG:
+ if ((flag == UNC_VF_INVALID || flag == UNC_VF_VALID_NO_VALUE)) {
+ UPLL_LOG_DEBUG("controller_id flag is invalid"
+ " or valid_no_value");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ break;
+ case UPLL_IDX_DESCRIPTION_VTEPG:
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ case UNC_OP_UPDATE:
+ {
+ switch (valid_index) {
+ case UPLL_IDX_CONTROLLER_ID_VTEPG:
+ if (flag == UNC_VF_VALID_NO_VALUE) {
+ UPLL_LOG_DEBUG("controller_id flag is valid_no_value");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ break;
+ case UPLL_IDX_DESCRIPTION_VTEPG:
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ }
+ }
+
+ // Resets
+ for (unsigned int valid_index = 0;
+ valid_index < sizeof(val_vtep_grp->valid)/sizeof(val_vtep_grp->valid[0]);
+ valid_index++) {
+ uint8_t flag = val_vtep_grp->valid[valid_index];
+ if (flag != UNC_VF_INVALID && flag != UNC_VF_VALID_NO_VALUE)
+ continue;
+
+ switch (valid_index) {
+ case UPLL_IDX_CONTROLLER_ID_VTEPG:
+ StringReset(val_vtep_grp->controller_id);
+ break;
+ case UPLL_IDX_DESCRIPTION_VTEPG:
+ StringReset(val_vtep_grp->description);
+ break;
+ default:
+ UPLL_LOG_TRACE("Never here");
+ break;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtepGrpMoMgr::CtrlrIdAndDomainIdUpdationCheck(ConfigKeyVal *ikey,
+ ConfigKeyVal *okey) {
+ UPLL_FUNC_TRACE;
+ val_vtep_grp *vtepg_val = reinterpret_cast<val_vtep_grp *>(GetVal(ikey));
+ val_vtep_grp *vtepg_val1 = reinterpret_cast<val_vtep_grp *>(GetVal(okey));
+ if (vtepg_val->valid[UPLL_IDX_CONTROLLER_ID_VTEPG] == UNC_VF_VALID) {
+ if (strncmp(reinterpret_cast<const char *>(vtepg_val->controller_id),
+ reinterpret_cast<const char *>(vtepg_val1->controller_id),
+ kMaxLenCtrlrId+1)) {
+ UPLL_LOG_DEBUG("controller id comparision failed");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+upll_rc_t VtepGrpMoMgr::ValidateVTepGrpKey(key_vtep_grp_t *key_vtep_grp,
+ uint32_t operation) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ ret_val = ValidateKey(
+ reinterpret_cast<char *>(key_vtep_grp->vtn_key.vtn_name),
+ kMinLenVtnName, kMaxLenVtnName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("Vtn Name syntax check failed."
+ "Received VTN Name - %s",
+ key_vtep_grp->vtn_key.vtn_name);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ if ((operation != UNC_OP_READ_SIBLING_BEGIN) &&
+ (operation != UNC_OP_READ_SIBLING_COUNT)) {
+ UPLL_LOG_TRACE("UNC_KT_VTEP_GRP:vtepgrp_name (%s)",
+ key_vtep_grp->vtepgrp_name);
+ ret_val = ValidateKey(reinterpret_cast<char *>(key_vtep_grp->vtepgrp_name),
+ kMinLenVnodeName, kMaxLenVnodeName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Syntax check failed. vtepgrp_name (%s)",
+ key_vtep_grp->vtepgrp_name);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ } else {
+ UPLL_LOG_TRACE("Operation is %d", operation);
+ StringReset(key_vtep_grp->vtepgrp_name);
+ }
+ return UPLL_RC_SUCCESS;
+}
+upll_rc_t VtepGrpMoMgr::ValVTepGrpAttributeSupportCheck(
+ val_vtep_grp_t *val_vtep_grp,
+ const uint8_t* attrs, unc_keytype_operation_t operation) {
+ UPLL_FUNC_TRACE;
+
+ if ((val_vtep_grp->valid[UPLL_IDX_DESCRIPTION_VTEPG] == UNC_VF_VALID) ||
+ (val_vtep_grp->valid[UPLL_IDX_DESCRIPTION_VTEPG] ==
+ UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtep_grp::kCapDesc] == 0) {
+ val_vtep_grp->valid[UPLL_IDX_DESCRIPTION_VTEPG] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("Attribute Desc not supported in pfc controller");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+upll_rc_t VtepGrpMoMgr::ValidateCapability(IpcReqRespHeader *req,
+ ConfigKeyVal *ikey, const char * ctrlr_name) {
+ UPLL_FUNC_TRACE;
+ if (!ikey || !req) {
+ UPLL_LOG_DEBUG("ConfigKeyVal / IpcReqRespHeader is Null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ if (!ctrlr_name) {
+ ctrlr_name = reinterpret_cast<char*>((reinterpret_cast<key_user_data_t *>
+ (ikey->get_user_data()))->ctrlr_id);
+ if (!ctrlr_name || !strlen(ctrlr_name)) {
+ UPLL_LOG_DEBUG("Controller Name is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+
+ UPLL_LOG_TRACE("ctrlr_name(%s), operation : (%d)",
+ ctrlr_name, req->operation);
+
+ bool result_code = false;
+ uint32_t max_instance_count = 0;
+ uint32_t max_attrs = 0;
+ const uint8_t *attrs = NULL;
+ switch (req->operation) {
+ case UNC_OP_CREATE:
+ result_code = GetCreateCapability(ctrlr_name,
+ ikey->get_key_type(), &max_instance_count, &max_attrs, &attrs);
+ if (result_code && (max_instance_count != 0) &&
+ cur_instance_count >= max_instance_count) {
+ UPLL_LOG_DEBUG("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
+ __LINE__, __FUNCTION__, cur_instance_count, max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
+ break;
+ case UNC_OP_UPDATE: {
+ result_code = GetUpdateCapability(ctrlr_name,
+ ikey->get_key_type(), &max_attrs, &attrs);
+ }
+ break;
+ case UNC_OP_READ:
+ case UNC_OP_READ_SIBLING:
+ case UNC_OP_READ_SIBLING_BEGIN:
+ case UNC_OP_READ_SIBLING_COUNT:
+ result_code = GetReadCapability(ctrlr_name,
+ ikey->get_key_type(), &max_attrs, &attrs);
+ break;
+
+ default:
+ UPLL_LOG_DEBUG("Invalid operation");
+ break;
+ }
+
+ if (!result_code) {
+ UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s) "
+ "for operation(%d)",
+ ikey->get_key_type(), ctrlr_name, req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ val_vtep_grp_t *val_vtep_grp = NULL;
+ if ((ikey->get_cfg_val()) &&
+ ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVtepGrp)) {
+ val_vtep_grp =
+ reinterpret_cast<val_vtep_grp_t *> (ikey->get_cfg_val()->get_val());
+ }
+ if (val_vtep_grp) {
+ if (max_attrs > 0) {
+ return ValVTepGrpAttributeSupportCheck(val_vtep_grp, attrs,
+ req->operation);
+ } else {
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d",
+ req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtepGrpMoMgr::CreateVtunnelKey(ConfigKeyVal *ikey,
+ ConfigKeyVal *&okey) {
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigVal *tmp;
+ if ( NULL == ikey)
+ return UPLL_RC_ERR_GENERIC;
+ key_vtep_grp *vtepgrp_key = reinterpret_cast<key_vtep_grp *>
+ (ikey->get_key());
+
+ val_vtunnel_t *val_vtunnel = reinterpret_cast<val_vtunnel_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtunnel_t)));
+ key_vtunnel_t *key_vtunnel = reinterpret_cast<key_vtunnel_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtunnel_t)));
+
+ if (!val_vtunnel || !key_vtunnel)
+ return UPLL_RC_ERR_GENERIC;
+ if (!strlen(reinterpret_cast<char *>(vtepgrp_key->vtn_key.vtn_name))) {
+ free(val_vtunnel);
+ free(key_vtunnel);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (!strlen(reinterpret_cast<char *>(vtepgrp_key->vtepgrp_name))) {
+ free(val_vtunnel);
+ free(key_vtunnel);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ uuu::upll_strncpy(val_vtunnel->vtn_name,
+ vtepgrp_key->vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ uuu::upll_strncpy(val_vtunnel->vtep_grp_name,
+ vtepgrp_key->vtepgrp_name,
+ (kMaxLenVnodeName+1));
+ val_vtunnel->valid[UPLL_IDX_VTN_NAME_VTNL] = UNC_VF_VALID;
+ val_vtunnel->valid[UPLL_IDX_VTEP_GRP_NAME_VTNL] = UNC_VF_VALID;
+
+ tmp = new ConfigVal(IpctSt::kIpcStValVtunnel, val_vtunnel);
+ okey = new ConfigKeyVal(UNC_KT_VTUNNEL, IpctSt::kIpcStKeyVtunnel,
+ key_vtunnel, tmp);
+ UPLL_LOG_TRACE("VtnMoMgr::CreateVtunnelKey");
+ if (!okey) {
+ FREE_IF_NOT_NULL(key_vtunnel);
+ FREE_IF_NOT_NULL(val_vtunnel);
+ delete okey;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ return result_code;
+}
+
+upll_rc_t VtepGrpMoMgr::IsReferenced(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type, DalDmlIntf *dmi) {
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *okey = NULL;
+ if ( !ikey || !(ikey->get_key()) || !dmi)
+ return UPLL_RC_ERR_GENERIC;
+ result_code = CreateVtunnelKey(ikey, okey);
+
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>
+ (GetMoManager(UNC_KT_VTUNNEL)));
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutNone};
+ result_code = mgr->ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop,
+ dmi, MAINTBL);
+ UPLL_LOG_TRACE("Vtunnel ReadConfigDb");
+ if (UPLL_RC_SUCCESS == result_code) {
+ delete okey;
+ result_code = UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
+ UPLL_RC_SUCCESS:result_code;
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+}
+
+
+} // namespace vtn
+} // namespace upll
+} // namespace unc
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 NEC Corporation
+ * All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+#ifndef UNC_UPLL_VTEP_GRP_MOMGR_H
+#define UNC_UPLL_VTEP_GRP_MOMGR_H
+
+#include "momgr_impl.hh"
+#include "vnode_child_momgr.hh"
+
+namespace unc {
+namespace upll {
+namespace kt_momgr {
+
+
+enum VtepGrpMoMgrTables {
+ VTEPGRPTBL = 0,
+ NVTEPGRPTABLES
+};
+
+
+class VtepGrpMoMgr : public VnodeChildMoMgr {
+ private:
+ static unc_key_type_t vtep_grp_child[];
+ static BindInfo vtep_grp_bind_info[];
+ // static BindInfo key_vtep_grp_maintbl_update_bind_info[];
+ /**
+ * @brief Gets the valid array position of the variable in the value
+ * structure from the table in the specified configuration
+ *
+ * @param[in] val pointer to the value structure
+ * @param[in] indx database index for the variable
+ * @param[out] valid position of the variable in the valid array -
+ * NULL if valid does not exist.
+ * @param[in] dt_type specifies the configuration
+ * @param[in] tbl specifies the table containing the given value
+ *
+ **/
+ upll_rc_t GetValid(void *val, uint64_t indx, uint8_t *&valid,
+ upll_keytype_datatype_t dt_type, MoMgrTables tbl ) {
+ UPLL_FUNC_TRACE;
+ if (val == NULL) return UPLL_RC_ERR_GENERIC;
+ if (tbl == MAINTBL) {
+ switch (indx) {
+ case uudst::vtep_group::kDbiCtrlrName:
+ valid = &(reinterpret_cast<val_vtep_grp *>(val)->
+ valid[UPLL_IDX_CONTROLLER_ID_VTEPG]);
+ break;
+ case uudst::vtep_group::kDbiDesc:
+ valid = &(reinterpret_cast<val_vtep_grp *>(val)->
+ valid[UPLL_IDX_DESCRIPTION_VTEPG]);
+ break;
+ default:
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+ }
+
+ upll_rc_t GetControllerDomainId(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ controller_domain *ctrlr_dom,
+ DalDmlIntf *dmi);
+
+ upll_rc_t UpdateConfigStatus(ConfigKeyVal *vtepgrp_key,
+ unc_keytype_operation_t op,
+ uint32_t result,
+ ConfigKeyVal *upd_key,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ctrlr_key = NULL);
+ /**
+ * @brief Update config status for commit result and vote result.
+ *
+ * @param[in/out] ckv_running ConfigKeyVal instance.
+ * @param[in] cs_status either UNC_CS_INVALID or UNC_CS_APPLIED.
+ * @param[in] phase specify the phase (CREATE,DELETE or UPDATE)
+ *
+ **/
+ upll_rc_t UpdateAuditConfigStatus(unc_keytype_configstatus_t cs_status,
+ uuc::UpdateCtrlrPhase phase,
+ ConfigKeyVal *&ckv_running);
+
+ upll_rc_t ValidateMessage(ConfigKeyVal *kval,
+ upll_keytype_datatype_t dt_type,
+ unc_keytype_operation_t op);
+
+ /**
+ * @brief Perform Semantic Check
+ *
+ * @param[in] ikey ConfigKeyVal
+ * @param[in] upll_rc_t UPLL_RC_ERR_CFG_SEMANTIC on error
+ * UPLL_RC_SUCCESS on success
+ **/
+ upll_rc_t ValidateAttribute(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req);
+ /**
+ * @brief Duplicates the input configkeyval including the key and val.
+ * based on the tbl specified.
+ *
+ * @param[in] okey Output Configkeyval - allocated within the function
+ * @param[in] req Input ConfigKeyVal to be duplicated.
+ * @param[in] tbl specifies if the val structure belongs to the main table/ controller table or rename table.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ upll_rc_t DupConfigKeyVal(ConfigKeyVal *&okey,
+ ConfigKeyVal *&req, MoMgrTables tbl = MAINTBL);
+ /**
+ * @brief Allocates for the specified val in the given configuration in the * specified table.
+ *
+ * @param[in/out] ck_val Reference pointer to configval structure
+ * allocated.
+ * @param[in] dt_type specifies the configuration candidate/running/
+ * state
+ * @param[in] tbl specifies if the corresponding table is the
+ * main table / controller table or rename table.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ upll_rc_t AllocVal(ConfigVal *&ck_val, upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl = MAINTBL);
+ /**
+ * @brief Method to get a configkeyval of a specified keytype from an input configkeyval
+ *
+ * @param[in/out] okey pointer to output ConfigKeyVal
+ * @param[in] parent_key pointer to the configkeyval from which the output configkey val is initialized.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ */
+ upll_rc_t GetChildConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *parent_key);
+ /**
+ * @brief Method to get a configkeyval of the parent keytype
+ *
+ * @param[in/out] okey pointer to parent ConfigKeyVal
+ * @param[in] ikey pointer to the child configkeyval from
+ * which the parent configkey val is obtained.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ upll_rc_t GetParentConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *ikey);
+
+ /**
+ * @brief Filters the attributes which need not be sent to controller
+ *
+ * @param[in/out] val1 first record value instance.
+ * @param[in] val2 second record value instance.
+ * @param[in] audit Not used for VTN
+ * @param[in] op Operation to be performed
+ *
+ **/
+ bool FilterAttributes(void *&val1, void *val2, bool copy_to_running,
+ unc_keytype_operation_t op);
+ /**
+ * @brief Compares the valid value between two database records.
+ * if both the values are same, update the valid flag for corresponding
+ * attribute as invalid in the first record.
+ *
+ * @param[in/out] val1 first record value instance.
+ * @param[in] val2 second record value instance.
+ * @param[in] audit if true, CompareValidValue called from audit process.
+ *
+ **/
+ bool CompareValidValue(void *&val1, void *val2, bool copy_to_running);
+
+ /**
+ * @Brief Validates the syntax of the specified key and value structure
+ * for KT_VTEP_GRP keytype
+ *
+ * @param[in] req This structure contains
+ * IpcReqRespHeader(first 8 fields of input request structure).
+ * @param[in] ikey ikey contains key and value structure.
+ *
+ * @retval UPLL_RC_SUCCESS Successful.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX Syntax error.
+ * @retval UPLL_RC_ERR_NO_SUCH_INSTANCE key struct is not available.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ * @retval UPLL_RC_ERR_INVALID_OPTION1 option1 is not valid.
+ * @retval UPLL_RC_ERR_INVALID_OPTION2 option2 is not valid.
+ */
+ upll_rc_t ValidateMessage(IpcReqRespHeader *req, ConfigKeyVal *ikey);
+
+ /**
+ * @Brief Validates the syntax for KT_VTEP_GRP keytype value structure.
+ *
+ * @param[in] val_vtep_grp KT_VTEP_GRP value structure.
+ *
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ * @retval UPLL_RC_SUCCESS validation succeeded.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX validation failed.
+ */
+ upll_rc_t ValidateVTepGrpValue(val_vtep_grp_t *val_vtep_grp,
+ uint32_t operation = UNC_OP_INVALID);
+
+ /**
+ * @Brief Checks if the specified key type(KT_VTEP_GRP) and
+ * associated attributes are supported on the given controller,
+ * based on the valid flag
+ *
+ * @param[in] req This structure contains
+ * IpcReqRespHeader(first 8 fields of input request structure).
+ * @param[in] ikey ikey contains key and value structure.
+ * @param[in] crtlr_name Controller name.
+ *
+ * @retval UPLL_RC_SUCCESS Validation succeeded.
+ * @retval UPLL_RC_ERR_GENERIC Validation failure.
+ * @retval UPLL_RC_ERR_INVALID_OPTION1 Option1 is not valid.
+ * @retval UPLL_RC_ERR_INVALID_OPTION2 Option2 is not valid.
+ */
+
+ upll_rc_t ValidateCapability(IpcReqRespHeader *req, ConfigKeyVal *ikey,
+ const char * crtlr_name);
+ /**
+ * @Brief Checks if the specified key type and
+ * associated attributes are supported on the given controller,
+ * based on the valid flag.
+ *
+ * @param[in] val_vtep_grp Value Structure.
+ * @param[in] attr pointer to controller attribute
+ * @param[in] operation Operation Name
+ *
+ * @retval UPLL_RC_SUCCESS validation succeeded.
+ * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ */
+ upll_rc_t ValVTepGrpAttributeSupportCheck(
+ val_vtep_grp_t *val_vtep_grp,
+ const uint8_t* attrs, unc_keytype_operation_t operation);
+
+ upll_rc_t CopyToConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *ikey) {
+ return UPLL_RC_SUCCESS;
+ }
+ bool GetRenameKeyBindInfo(unc_key_type_t key_type, BindInfo *&binfo,
+ int &nattr,
+ MoMgrTables tbl ) {
+ return true;
+ }
+ upll_rc_t GetRenamedControllerKey(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
+ uint8_t *ctrlr_name ) {
+ return UPLL_RC_SUCCESS;
+ }
+ upll_rc_t GetRenamedUncKey(ConfigKeyVal *ctrlr_key,
+ upll_keytype_datatype_t dt_type, DalDmlIntf *dmi, uint8_t *ctrlr_id) {
+ return UPLL_RC_SUCCESS;
+ }
+ upll_rc_t CreateVtunnelKey(ConfigKeyVal *ikey, ConfigKeyVal *&okey);
+ upll_rc_t IsReferenced(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type, DalDmlIntf *dmi);
+ upll_rc_t GetVnodeName(ConfigKeyVal *ikey,
+ uint8_t *&vtn_name, uint8_t *&vnode_name) {
+ return UPLL_RC_SUCCESS;
+ }
+
+ public:
+ VtepGrpMoMgr();
+ virtual ~VtepGrpMoMgr() {
+ for (int i = VTEPGRPTBL; i < NVTEPGRPTABLES; i++)
+ if (table[i]) {
+ delete table[i];
+ }
+ delete[] table;
+ }
+ /**
+ * @brief Method to check if individual portions of a key are valid
+ *
+ * @param[in/out] ikey pointer to ConfigKeyVal referring to a UNC resource
+ * @param[in] index db index associated with the variable
+ *
+ * @retval true input key is valid
+ * @retval false input key is invalid.
+ **/
+ bool IsValidKey(void *tkey, uint64_t index);
+
+ /**
+ * @Brief Validates the syntax for KT_VTEP_GRP keytype key structure.
+ *
+ * @param[in] key_vtep_grp KT_VTEP_GRP key structure.
+ *
+ * @retval UPLL_RC_SUCCESS validation succeeded.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX validation failed.
+ */
+ upll_rc_t ValidateVTepGrpKey(key_vtep_grp_t *key_vtep_grp,
+ uint32_t operation);
+ /**
+ * @Brief compares controller id and domain id before
+ * updating the value to DB.
+ *
+ * @param[in] ikey ikey contains key and value structure.
+ * @param[in] okey okey contains key and value structure.
+ *
+ * @retval UPLL_RC_SUCCESS Successful.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX Syntax error.
+ */
+ upll_rc_t CtrlrIdAndDomainIdUpdationCheck(ConfigKeyVal *ikey,
+ ConfigKeyVal *okey);
+};
+
+
+} // namespace vtn
+} // namespace upll
+} // namespace unc
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 NEC Corporation
+ * All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+#include "vtep_if_momgr.hh"
+#include "vtep_momgr.hh"
+#include "uncxx/upll_log.hh"
+#define NUM_KEY_MAIN_TBL_ 5
+namespace unc {
+namespace upll {
+namespace kt_momgr {
+
+ BindInfo VtepIfMoMgr::vtep_if_bind_info[] = {
+ { uudst::vtep_interface::kDbiVtnName, CFG_KEY,
+ offsetof(key_vtep_if, vtep_key.vtn_key.vtn_name),
+ uud::kDalChar, kMaxLenVtnName+1 },
+ { uudst::vtep_interface::kDbiVtepName, CFG_KEY,
+ offsetof(key_vtep_if, vtep_key.vtep_name),
+ uud::kDalChar, kMaxLenVnodeName+1 },
+ { uudst::vtep_interface::kDbiIfName, CFG_KEY,
+ offsetof(key_vtep_if, if_name),
+ uud::kDalChar, kMaxLenInterfaceName+1},
+ { uudst::vtep_interface::kDbiDesc, CFG_VAL,
+ offsetof(val_vtep_if, description),
+ uud::kDalChar, kMaxLenDescription+1},
+ { uudst::vtep_interface::kDbiAdminStatus, CFG_VAL,
+ offsetof(val_vtep_if, admin_status), uud::kDalUint8, 1},
+ { uudst::vtep_interface::kDbiLogicalPortId, CFG_VAL,
+ offsetof(val_vtep_if, portmap.logical_port_id),
+ uud::kDalChar, 320},
+ { uudst::vtep_interface::kDbiVlanId, CFG_VAL,
+ offsetof(val_vtep_if, portmap.vlan_id), uud::kDalUint16, 1},
+ { uudst::vtep_interface::kDbiTagged, CFG_VAL,
+ offsetof(val_vtep_if, portmap.tagged), uud::kDalUint8, 1},
+ { uudst::vtep_interface::kDbiOperStatus, ST_VAL,
+ offsetof(val_db_vtep_if_st, vtep_if_val_st.oper_status),
+ uud::kDalUint8, 1},
+ { uudst::vtep_interface::kDbiDownCount, ST_VAL, offsetof(
+ val_db_vtep_if_st, down_count),
+ uud::kDalUint32, 1 },
+ { uudst::vtep_interface::kDbiCtrlrName, CK_VAL,
+ offsetof(key_user_data, ctrlr_id), uud::kDalChar, 32},
+ { uudst::vtep_interface::kDbiDomainId, CK_VAL,
+ offsetof(key_user_data, domain_id), uud::kDalChar, 32},
+ { uudst::vtep_interface::kDbiFlags, CK_VAL,
+ offsetof(key_user_data, flags), uud::kDalUint8, 1},
+ { uudst::vtep_interface::kDbiValidDesc, CFG_META_VAL,
+ offsetof(val_vtep_if, valid[UPLL_IDX_DESC_VTEPI]), uud::kDalUint8, 1},
+ { uudst::vtep_interface::kDbiValidAdminStatus, CFG_DEF_VAL,
+ offsetof(val_vtep_if, valid[UPLL_IDX_ADMIN_ST_VTEPI]), uud::kDalUint8, 1},
+ { uudst::vtep_interface::kDbiValidPortMap, CFG_META_VAL,
+ offsetof(val_vtep_if, valid[UPLL_IDX_PORT_MAP_VTEPI]), uud::kDalUint8, 1},
+ { uudst::vtep_interface::kDbiValidLogicalPortId, CFG_META_VAL, offsetof(
+ val_vtep_if, portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM]),
+ uud::kDalUint8, 1 },
+ { uudst::vtep_interface::kDbiValidVlanid, CFG_META_VAL, offsetof(
+ val_vtep_if, portmap.valid[UPLL_IDX_VLAN_ID_PM]),
+ uud::kDalUint8, 1 },
+ { uudst::vtep_interface::kDbiValidTagged, CFG_META_VAL, offsetof(
+ val_vtep_if, portmap.valid[UPLL_IDX_TAGGED_PM]),
+ uud::kDalUint8, 1 },
+ { uudst::vtep_interface::kDbiValidOperStatus, ST_META_VAL,
+ offsetof(val_db_vtep_if_st,
+ vtep_if_val_st.valid[UPLL_IDX_IF_OPER_STATUS_VTEPIS]),
+ uud::kDalUint8, 1},
+ { uudst::vtep_interface::kDbiCsRowstatus, CS_VAL,
+ offsetof(val_vtep_if, cs_row_status), uud::kDalUint8, 1},
+ { uudst::vtep_interface::kDbiCsDesc, CS_VAL, offsetof(val_vtep_if,
+ cs_attr[UPLL_IDX_DESC_VTEPI]), uud::kDalUint8, 1},
+ { uudst::vtep_interface::kDbiCsAdminStatus, CS_VAL, offsetof(val_vtep_if,
+ cs_attr[UPLL_IDX_ADMIN_ST_VTEPI]), uud::kDalUint8, 1},
+ { uudst::vtep_interface::kDbiCsPortMap, CS_VAL, offsetof(val_vtep_if,
+ cs_attr[UPLL_IDX_PORT_MAP_VTEPI]), uud::kDalUint8, 1},
+ { uudst::vtep_interface::kDbiCsLogicalPortId, CS_VAL, offsetof(
+ val_vtep_if, portmap.cs_attr[UPLL_IDX_LOGICAL_PORT_ID_PM]),
+ uud::kDalUint8, 1 },
+ { uudst::vtep_interface::kDbiCsVlanid, CS_VAL, offsetof(
+ val_vtep_if, portmap.cs_attr[UPLL_IDX_VLAN_ID_PM]),
+ uud::kDalUint8, 1 },
+ { uudst::vtep_interface::kDbiCsTagged, CS_VAL, offsetof(
+ val_vtep_if, portmap.cs_attr[UPLL_IDX_TAGGED_PM]),
+ uud::kDalUint8, 1 }
+ };
+
+ VtepIfMoMgr::VtepIfMoMgr() {
+ UPLL_FUNC_TRACE;
+ Table *tbl = new Table(uudst::kDbiVtepIfTbl, UNC_KT_VTEP_IF,
+ vtep_if_bind_info,
+ IpctSt::kIpcStKeyVtepIf, IpctSt::kIpcStValVtepIf,
+ uudst::vtep_interface::kDbiVtepIfNumCols);
+ ntable = MAX_MOMGR_TBLS;
+ table = new Table *[ntable];
+ table[MAINTBL] = tbl;
+ table[RENAMETBL] = NULL;
+ table[CTRLRTBL] = NULL;
+ nchild = 0;
+ child = NULL;
+#ifdef _STANDALONE_
+ SetMoManager(UNC_KT_VTEP_IF, reinterpret_cast<MoMgr *>(this));
+#endif
+ }
+
+ /*
+ * * Based on the key type the bind info will pass
+ * *
+ bool VtepIfMoMgr::GetRenameKeyBindInfo(unc_key_type_t key_type, BindInfo *&binfo, int &nattr,
+ MoMgrTables tbl ) {
+ if (MAINTBL == tbl) {
+ nattr = NUM_KEY_MAIN_TBL_;
+ binfo = key_vtep_if_maintbl_update_bind_info;
+ }
+ return PFC_TRUE;
+ }*/
+
+ upll_rc_t VtepIfMoMgr::ValidateAttribute(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ if (!ikey || (ikey->get_key_type() != UNC_KT_VTEP_IF)
+ || !(ikey->get_cfg_val()))
+ return UPLL_RC_ERR_CFG_SYNTAX;
+
+ val_vtep_if *vtepif_val = static_cast<val_vtep_if *>(GetVal(ikey));
+ if (!vtepif_val) {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (vtepif_val->valid[UPLL_IDX_PORT_MAP_VTEPI] == UNC_VF_VALID) {
+ if (vtepif_val->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] ==
+ UNC_VF_VALID &&
+ vtepif_val->portmap.valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID) {
+ key_vtep_if *vtep_key_if = static_cast<key_vtep_if *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtep_if)));
+ val_vtep_if *vtepif_val_filter = static_cast<val_vtep_if *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtep_if)));
+ vtepif_val_filter->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] =
+ UNC_VF_VALID;
+ vtepif_val_filter->portmap.valid[UPLL_IDX_VLAN_ID_PM] = UNC_VF_VALID;
+ uuu::upll_strncpy(vtepif_val_filter->portmap.logical_port_id,
+ vtepif_val->portmap.logical_port_id,
+ kMaxLenLogicalPortId+1);
+ vtepif_val_filter->portmap.vlan_id = vtepif_val->portmap.vlan_id;
+ ConfigKeyVal *vtepif_ckv = new ConfigKeyVal(UNC_KT_VTEP_IF,
+ IpctSt::kIpcStKeyVtepIf, vtep_key_if, NULL);
+ vtepif_ckv->AppendCfgVal(IpctSt::kIpcStValVtepIf, vtepif_val_filter);
+
+ SET_USER_DATA(vtepif_ckv, ikey);
+ // Read from the DB
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchCtrlr | kOpMatchDomain,
+ kOpInOutFlag};
+ result_code = ReadConfigDB(vtepif_ckv, UPLL_DT_CANDIDATE, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (result_code == UPLL_RC_SUCCESS) {
+ // check different interface has the same port and lan id
+ ConfigKeyVal *tmp = vtepif_ckv;
+ while (tmp) {
+ if (!memcmp((ikey->get_key()), (tmp->get_key()),
+ sizeof(key_vtep_if))) {
+ UPLL_LOG_TRACE("Looking on the Same key");
+ } else {
+ UPLL_LOG_DEBUG("Same port Id and VlanId is used on different"
+ " Vtep Interface within same VTN/Controller");
+ delete vtepif_ckv;
+ vtepif_ckv = tmp = NULL;
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ tmp = tmp->get_next_cfg_key_val();
+ }
+ } else if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ result_code = UPLL_RC_SUCCESS;
+ } else if (result_code != UPLL_RC_SUCCESS) {
+ delete vtepif_ckv;
+ vtepif_ckv = NULL;
+ return result_code;
+ }
+ delete vtepif_ckv;
+ vtepif_ckv = NULL;
+ }
+ }
+ UPLL_LOG_TRACE("PortId and VlanId is not used on any Vtep Interface");
+ // PortMap Validation
+ uint32_t operation = req->operation;
+ if (operation == UNC_OP_UPDATE) {
+ result_code = UpdateConfigVal(ikey, UPLL_DT_CANDIDATE, dmi);
+ UPLL_LOG_TRACE("UpdateConfigVal returned %d", result_code);
+ }
+ return result_code;
+ }
+
+ bool VtepIfMoMgr::IsValidKey(void *key, uint64_t index) {
+ UPLL_FUNC_TRACE;
+ key_vtep_if *if_key = reinterpret_cast<key_vtep_if *>(key);
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ switch (index) {
+ case uudst::vtep_interface::kDbiVtnName:
+ ret_val = ValidateKey(reinterpret_cast<char *>
+ (if_key->vtep_key.vtn_key.vtn_name),
+ kMinLenVtnName, kMaxLenVtnName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("VTN Name is not valid(%d)", ret_val);
+ return false;
+ }
+ break;
+ case uudst::vtep_interface::kDbiVtepName:
+ ret_val = ValidateKey(reinterpret_cast<char *>
+ (if_key->vtep_key.vtep_name),
+ kMinLenVnodeName, kMaxLenVnodeName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("Vtep Name is not valid(%d)", ret_val);
+ return false;
+ }
+ break;
+ case uudst::vtep_interface::kDbiIfName:
+ ret_val = ValidateKey(reinterpret_cast<char *>(if_key->if_name),
+ kMinLenInterfaceName,
+ kMaxLenInterfaceName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("Vtep IF Name is not valid(%d)", ret_val);
+ return false;
+ }
+ break;
+ default:
+ UPLL_LOG_TRACE("Wrong Index");
+ return false;
+ }
+ return true;
+ }
+
+ upll_rc_t VtepIfMoMgr::GetValid(void *val, uint64_t indx, uint8_t *&valid,
+ upll_keytype_datatype_t dt_type, MoMgrTables tbl ) {
+ UPLL_FUNC_TRACE;
+ if (val == NULL) return UPLL_RC_ERR_GENERIC;
+ if (tbl == MAINTBL) {
+ switch (indx) {
+ case uudst::vtep_interface::kDbiOperStatus:
+ valid = &(reinterpret_cast<val_vtep_if_st *>(val))->
+ valid[UPLL_IDX_IF_OPER_STATUS_VTEPIS];
+ break;
+ case uudst::vtep_interface::kDbiDownCount:
+ valid = NULL;
+ break;
+ case uudst::vtep_interface::kDbiAdminStatus:
+ valid = &(reinterpret_cast<val_vtep_if *>(val))->
+ valid[UPLL_IDX_ADMIN_ST_VTEPI];
+ break;
+ case uudst::vtep_interface::kDbiDesc:
+ valid = &(reinterpret_cast<val_vtep_if *>(val))->
+ valid[UPLL_IDX_DESC_VTEPI];
+ break;
+ case uudst::vtep_interface::kDbiValidPortMap:
+ valid = &(reinterpret_cast<val_vtep_if *>(val))->
+ valid[UPLL_IDX_PORT_MAP_VTEPI];
+ break;
+ case uudst::vtep_interface::kDbiLogicalPortId:
+ valid = &(reinterpret_cast<val_vtep_if *>(val))->portmap.
+ valid[UPLL_IDX_LOGICAL_PORT_ID_PM];
+ break;
+ case uudst::vtep_interface::kDbiVlanId:
+ valid = &(reinterpret_cast<val_vtep_if *>(val))->portmap.
+ valid[UPLL_IDX_VLAN_ID_PM];
+ break;
+ case uudst::vtep_interface::kDbiTagged:
+ valid = &(reinterpret_cast<val_vtep_if *>(val))->portmap.
+ valid[UPLL_IDX_TAGGED_PM];
+ break;
+ default:
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+ }
+
+ upll_rc_t VtepIfMoMgr::GetChildConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *parent_key) {
+ UPLL_FUNC_TRACE;
+ bool cfgval_ctrlr = false;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ key_vtep_if *vtep_key_if = static_cast<key_vtep_if *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtep_if)));
+ if (vtep_key_if == NULL) return UPLL_RC_ERR_GENERIC;
+ void *pkey;
+ if (parent_key == NULL) {
+ if (okey) delete okey;
+ okey = new ConfigKeyVal(UNC_KT_VTEP_IF,
+ IpctSt::kIpcStKeyVtepIf,
+ vtep_key_if, NULL);
+ return UPLL_RC_SUCCESS;
+ } else {
+ pkey = parent_key->get_key();
+ }
+ if (!pkey) {
+ FREE_IF_NOT_NULL(vtep_key_if);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (okey && (okey->get_key())) {
+ FREE_IF_NOT_NULL(vtep_key_if);
+ if (okey->get_key_type() != UNC_KT_VTEP_IF)
+ return UPLL_RC_ERR_GENERIC;
+ vtep_key_if = reinterpret_cast<key_vtep_if *>(okey->get_key());
+ } else {
+ okey = new ConfigKeyVal(UNC_KT_VTEP_IF, IpctSt::kIpcStKeyVtepIf,
+ vtep_key_if, NULL);
+ if (okey == NULL) {
+ FREE_IF_NOT_NULL(vtep_key_if);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ unc_key_type_t keytype = parent_key->get_key_type();
+ switch (keytype) {
+ case UNC_KT_VTN:
+ uuu::upll_strncpy(vtep_key_if->vtep_key.vtn_key.vtn_name,
+ static_cast<key_vtn *>(pkey)->vtn_name,
+ (kMaxLenVtnName+1));
+ *(vtep_key_if->vtep_key.vtep_name) = *"";
+ break;
+ case UNC_KT_VTEP:
+ uuu::upll_strncpy(vtep_key_if->vtep_key.vtn_key.vtn_name,
+ static_cast<key_vtep *>(pkey)->vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ uuu::upll_strncpy(vtep_key_if->vtep_key.vtep_name,
+ static_cast<key_vtep *>(pkey)->vtep_name,
+ (kMaxLenVnodeName+1));
+ break;
+ case UNC_KT_VTEP_IF:
+ uuu::upll_strncpy(vtep_key_if->vtep_key.vtn_key.vtn_name,
+ static_cast<key_vtep_if *>
+ (pkey)->vtep_key.vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ uuu::upll_strncpy(vtep_key_if->vtep_key.vtep_name,
+ static_cast<key_vtep_if *>(pkey)->vtep_key.vtep_name,
+ (kMaxLenVnodeName+1));
+ uuu::upll_strncpy(vtep_key_if->if_name,
+ static_cast<key_vtep_if *>(pkey)->if_name,
+ (kMaxLenInterfaceName+1));
+ break;
+ case UNC_KT_VLINK:
+ {
+ uint8_t *vnode_name, *if_name;
+ val_vlink *vlink_val = reinterpret_cast<val_vlink *>
+ (GetVal(parent_key));
+ if (!vlink_val) {
+ free(vtep_key_if);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t flags = 0;
+ GET_USER_DATA_FLAGS(parent_key->get_cfg_val(), flags);
+ flags &= VLINK_FLAG_NODE_POS;
+ UPLL_LOG_DEBUG("Vlink flag node position %d", flags);
+ if (flags == kVlinkVnode1) {
+ vnode_name = vlink_val->vnode1_name;
+ if_name = vlink_val->vnode1_ifname;
+ } else {
+ cfgval_ctrlr = true;
+ vnode_name = vlink_val->vnode2_name;
+ if_name = vlink_val->vnode2_ifname;
+ }
+ uuu::upll_strncpy(vtep_key_if->vtep_key.vtn_key.vtn_name,
+ static_cast<key_vlink *>(pkey)->vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ if (vnode_name)
+ uuu::upll_strncpy(vtep_key_if->vtep_key.vtep_name, vnode_name,
+ (kMaxLenVnodeName+1));
+ if (if_name)
+ uuu::upll_strncpy(vtep_key_if->if_name, if_name,
+ (kMaxLenInterfaceName+1));
+ }
+ default:
+ break;
+ }
+ if (cfgval_ctrlr) {
+ SET_USER_DATA(okey, parent_key->get_cfg_val());
+ } else {
+ SET_USER_DATA(okey, parent_key);
+ }
+ return result_code;
+ }
+
+ upll_rc_t VtepIfMoMgr::GetParentConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *ikey ) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ key_vtep_if *pkey = reinterpret_cast<key_vtep_if *>
+ ((ikey)?ikey->get_key():NULL);
+ if (!pkey) return UPLL_RC_ERR_GENERIC;
+
+ unc_key_type_t ikey_type = ikey->get_key_type();
+ if (ikey_type != UNC_KT_VTEP_IF)
+ return UPLL_RC_ERR_GENERIC;
+ key_vtep *vtep_key = reinterpret_cast<key_vtep *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtep)));
+ if (!vtep_key) return UPLL_RC_ERR_GENERIC;
+ uuu::upll_strncpy(vtep_key->vtn_key.vtn_name,
+ static_cast<key_vtep_if *>(pkey)->vtep_key.vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ uuu::upll_strncpy(vtep_key->vtep_name,
+ static_cast<key_vtep_if *>(pkey)->vtep_key.vtep_name,
+ (kMaxLenVnodeName+1));
+ if (okey) delete okey;
+ okey = new ConfigKeyVal(UNC_KT_VTEP, IpctSt::kIpcStKeyVtep,
+ vtep_key, NULL);
+ if (okey == NULL) {
+ FREE_IF_NOT_NULL(vtep_key);
+ result_code = UPLL_RC_ERR_GENERIC;
+ } else {
+ SET_USER_DATA(okey, ikey);
+ }
+ return result_code;
+ }
+
+
+ upll_rc_t VtepIfMoMgr::AllocVal(ConfigVal *&ck_val,
+ upll_keytype_datatype_t dt_type, MoMgrTables tbl) {
+ UPLL_FUNC_TRACE;
+ void *val;
+ if (ck_val != NULL) return UPLL_RC_ERR_GENERIC;
+ switch (tbl) {
+ case MAINTBL:
+ val = reinterpret_cast<void *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtep_if)));
+ if (!val) return UPLL_RC_ERR_GENERIC;
+ ck_val = new ConfigVal(IpctSt::kIpcStValVtepIf, val);
+ if (!ck_val) {
+ FREE_IF_NOT_NULL(reinterpret_cast<val_vtep_if *>(val));
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (dt_type == UPLL_DT_STATE) {
+ val = reinterpret_cast<void *>
+ (ConfigKeyVal::Malloc(sizeof(val_db_vtep_if_st)));
+ if (!val) {
+ delete ck_val;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigVal *ck_nxtval = new ConfigVal(IpctSt::kIpcStValVtepIfSt, val);
+ if (!ck_nxtval) {
+ delete ck_val;
+ FREE_IF_NOT_NULL(reinterpret_cast<val_db_vtep_if_st *>(val));
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ck_val->AppendCfgVal(ck_nxtval);
+ }
+ break;
+ default:
+ val = NULL;
+ }
+ return UPLL_RC_SUCCESS;
+ }
+
+ upll_rc_t VtepIfMoMgr::DupConfigKeyVal(ConfigKeyVal *&okey,
+ ConfigKeyVal *&req, MoMgrTables tbl) {
+ UPLL_FUNC_TRACE;
+ if (req == NULL) return UPLL_RC_ERR_GENERIC;
+ if (okey != NULL) return UPLL_RC_ERR_GENERIC;
+ if (req->get_key_type() != UNC_KT_VTEP_IF)
+ return UPLL_RC_ERR_GENERIC;
+ ConfigVal *tmp1 = NULL, *tmp = (req)->get_cfg_val();
+
+ if (tmp) {
+ if (tbl == MAINTBL) {
+ val_vtep_if *ival = static_cast<val_vtep_if *>(GetVal(req));
+ val_vtep_if *vtep_val_if = static_cast<val_vtep_if *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtep_if)));
+ if (!vtep_val_if) return UPLL_RC_ERR_GENERIC;
+ memcpy(vtep_val_if, ival, sizeof(val_vtep_if));
+ tmp1 = new ConfigVal(IpctSt::kIpcStValVtepIf, vtep_val_if);
+ if (!tmp1) {
+ FREE_IF_NOT_NULL(vtep_val_if);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ tmp = tmp->get_next_cfg_val();
+ };
+ if (tmp) {
+ if (tbl == MAINTBL) {
+ val_db_vtep_if_st *ival = static_cast<val_db_vtep_if_st *>
+ (tmp->get_val());
+ val_db_vtep_if_st *val_vtep_if = static_cast<val_db_vtep_if_st *>
+ (ConfigKeyVal::Malloc(sizeof(val_db_vtep_if_st)));
+ if (!val_vtep_if) {
+ delete tmp1;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ memcpy(val_vtep_if, ival, sizeof(val_vtep_if_st));
+ ConfigVal *tmp2 = new ConfigVal(IpctSt::kIpcStValVtepIfSt, val_vtep_if);
+ if (!tmp2) {
+ delete tmp1;
+ FREE_IF_NOT_NULL(val_vtep_if);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ tmp1->AppendCfgVal(tmp2);
+ }
+ };
+ void *tkey = (req != NULL)?(req)->get_key():NULL;
+ key_vtep_if *ikey = static_cast<key_vtep_if *>(tkey);
+ key_vtep_if *vtep_if_key = static_cast<key_vtep_if *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtep_if)));
+ if (!vtep_if_key) {
+ if (tmp1) delete tmp1;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ memcpy(vtep_if_key, ikey, sizeof(key_vtep_if));
+ okey = new ConfigKeyVal(UNC_KT_VTEP_IF, IpctSt::kIpcStKeyVtepIf,
+ vtep_if_key, tmp1);
+ if (okey) {
+ SET_USER_DATA(okey, req);
+ } else {
+ if (tmp1) delete tmp1;
+ FREE_IF_NOT_NULL(vtep_if_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ return UPLL_RC_SUCCESS;
+ }
+
+ upll_rc_t VtepIfMoMgr::UpdateConfigVal(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t datatype,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *okey = NULL;
+ uint8_t flag = 0;
+ if (!ikey || !dmi) {
+ UPLL_LOG_DEBUG("Invalid Input");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val_vtep_if *vtepif_val = static_cast<val_vtep_if *>(GetVal(ikey));
+ if (!vtepif_val) {
+ UPLL_LOG_DEBUG("Value Structure is Null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = GetChildConfigKey(okey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failure %d", result_code);
+ return result_code;
+ }
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag };
+ result_code = ReadConfigDB(okey, datatype, UNC_OP_READ, dbop,
+ dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Read failed %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ GET_USER_DATA_FLAGS(okey, flag);
+ if (vtepif_val->valid[UPLL_IDX_PORT_MAP_VTEPI] == UNC_VF_VALID ||
+ vtepif_val->valid[UPLL_IDX_PORT_MAP_VTEPI] == UNC_VF_VALID_NO_VALUE) {
+ if (flag & VIF_TYPE) {
+ DELETE_IF_NOT_NULL(okey);
+ UPLL_LOG_DEBUG("Interface is linked/bounded with Vlink."
+ " Could not update Portmap");
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ }
+ if (vtepif_val->valid[UPLL_IDX_PORT_MAP_VTEPI] == UNC_VF_VALID_NO_VALUE) {
+ vtepif_val->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] =
+ UNC_VF_VALID_NO_VALUE;
+ vtepif_val->portmap.valid[UPLL_IDX_VLAN_ID_PM] = UNC_VF_VALID_NO_VALUE;
+ vtepif_val->portmap.valid[UPLL_IDX_TAGGED_PM] = UNC_VF_VALID_NO_VALUE;
+ uuu::upll_strncpy(vtepif_val->portmap.logical_port_id, "\0", 1);
+ vtepif_val->portmap.vlan_id = 0;
+ vtepif_val->portmap.tagged = UPLL_VLAN_UNTAGGED;
+ }
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+
+ upll_rc_t VtepIfMoMgr::AdaptValToVtnService(ConfigKeyVal *ikey) {
+ UPLL_FUNC_TRACE;
+ if (!ikey) {
+ UPLL_LOG_DEBUG("Invalid ikey");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ while (ikey) {
+ ConfigVal *cval = ikey->get_cfg_val();
+ if (!cval) {
+ UPLL_LOG_DEBUG("Config Val is Null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ while (cval) {
+ if (IpctSt::kIpcStValVtepIf == cval->get_st_num()) {
+ // set admin status to valid no value
+ val_vtep_if *vtepif_val = reinterpret_cast<val_vtep_if *>
+ (GetVal(ikey));
+ if (vtepif_val->valid[UPLL_IDX_ADMIN_ST_VTEPI] == UNC_VF_INVALID)
+ vtepif_val->valid[UPLL_IDX_ADMIN_ST_VTEPI] = UNC_VF_VALID_NO_VALUE;
+
+ uint8_t vlink_flag = 0;
+ GET_USER_DATA_FLAGS(ikey, vlink_flag);
+ UPLL_LOG_DEBUG("Interface type %d", vlink_flag);
+ if (vlink_flag & VIF_TYPE)
+ vtepif_val->valid[UPLL_IDX_PORT_MAP_VTEPI] = UNC_VF_INVALID;
+ }
+ if (IpctSt::kIpcStValVtepIfSt == cval->get_st_num()) {
+ val_vtep_if_st *vtepif_stval = reinterpret_cast<val_vtep_if_st *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtep_if_st)));
+ val_db_vtep_if_st *db_vtepif_stval =
+ reinterpret_cast<val_db_vtep_if_st *>(
+ cval->get_val());
+ memcpy(vtepif_stval, &db_vtepif_stval->vtep_if_val_st,
+ sizeof(val_vtep_if_st));
+ cval->SetVal(IpctSt::kIpcStValVtepIfSt, vtepif_stval);
+ }
+ cval = cval->get_next_cfg_val();
+ }
+ ikey = ikey->get_next_cfg_key_val();
+ }
+ return UPLL_RC_SUCCESS;
+ }
+
+ bool VtepIfMoMgr::FilterAttributes(void *&val1, void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op) {
+ UPLL_FUNC_TRACE;
+ val_vtep_if_t *val_vtep_if1 = reinterpret_cast<val_vtep_if_t *>(val1);
+ /* No need to configure description in controller. */
+ val_vtep_if1->valid[UPLL_IDX_DESC_VTEPI] = UNC_VF_INVALID;
+ if (op != UNC_OP_CREATE)
+ return CompareValidValue(val1, val2, copy_to_running);
+ return false;
+ }
+
+ bool VtepIfMoMgr::CompareValidValue(void *&val1, void *val2,
+ bool copy_to_running) {
+ UPLL_FUNC_TRACE;
+ bool invalid_attr = true;
+ val_vtep_if_t *val_vtep_if1 = reinterpret_cast<val_vtep_if_t *>(val1);
+ val_vtep_if_t *val_vtep_if2 = reinterpret_cast<val_vtep_if_t *>(val2);
+ for (unsigned int loop = 0;
+ loop < sizeof(val_vtep_if1->valid)/sizeof(uint8_t); ++loop ) {
+ if ( UNC_VF_INVALID == val_vtep_if1->valid[loop] &&
+ UNC_VF_VALID == val_vtep_if2->valid[loop])
+ val_vtep_if1->valid[loop] = UNC_VF_VALID_NO_VALUE;
+ }
+ if (UNC_VF_VALID == val_vtep_if1->valid[UPLL_IDX_DESC_VTEPI]
+ && UNC_VF_VALID == val_vtep_if2->valid[UPLL_IDX_DESC_VTEPI]) {
+ if (!strcmp(reinterpret_cast<char*>(val_vtep_if1->description),
+ reinterpret_cast<char*>(val_vtep_if2->description)))
+ val_vtep_if1->valid[UPLL_IDX_DESC_VTEPI] = UNC_VF_INVALID;
+ }
+ if (UNC_VF_INVALID != val_vtep_if1->valid[UPLL_IDX_ADMIN_ST_VTEPI]
+ && UNC_VF_INVALID != val_vtep_if2->valid[UPLL_IDX_ADMIN_ST_VTEPI]) {
+ if (val_vtep_if1->admin_status == val_vtep_if2->admin_status)
+ val_vtep_if1->valid[UPLL_IDX_ADMIN_ST_VTEPI] = UNC_VF_INVALID;
+ }
+ for (unsigned int loop = 0;
+ loop < sizeof(val_vtep_if1->portmap.valid)/sizeof(uint8_t); ++loop ) {
+ if (UNC_VF_INVALID == val_vtep_if1->portmap.valid[loop]
+ && UNC_VF_VALID == val_vtep_if2->portmap.valid[loop])
+ val_vtep_if1->portmap.valid[loop] = UNC_VF_VALID_NO_VALUE;
+ }
+ if (val_vtep_if1->valid[UPLL_IDX_PORT_MAP_VTEPI] == UNC_VF_VALID
+ && val_vtep_if2->valid[UPLL_IDX_PORT_MAP_VTEPI] == UNC_VF_VALID) {
+ if (memcmp(&(val_vtep_if1->portmap), &(val_vtep_if2->portmap),
+ sizeof(val_port_map_t))) {
+ if (val_vtep_if1->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] ==
+ UNC_VF_VALID
+ && val_vtep_if2->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM]
+ == UNC_VF_VALID) {
+ if (!strcmp(reinterpret_cast<char *>
+ (val_vtep_if1->portmap.logical_port_id),
+ reinterpret_cast<char *>(val_vtep_if2->portmap.logical_port_id)))
+ val_vtep_if1->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] =
+ UNC_VF_INVALID;
+ }
+ if ((val_vtep_if1->portmap.valid[UPLL_IDX_VLAN_ID_PM] ==
+ val_vtep_if2->portmap.valid[UPLL_IDX_VLAN_ID_PM])
+ && val_vtep_if2->portmap.valid[UPLL_IDX_VLAN_ID_PM] !=
+ UNC_VF_INVALID) {
+ if (val_vtep_if1->portmap.vlan_id == val_vtep_if2->portmap.vlan_id)
+ val_vtep_if1->portmap.valid[UPLL_IDX_VLAN_ID_PM] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
+ }
+ if ((val_vtep_if1->portmap.valid[UPLL_IDX_TAGGED_PM] ==
+ val_vtep_if2->portmap.valid[UPLL_IDX_TAGGED_PM])
+ && val_vtep_if2->portmap.valid[UPLL_IDX_TAGGED_PM] !=
+ UNC_VF_INVALID) {
+ if (val_vtep_if1->portmap.tagged == val_vtep_if2->portmap.tagged)
+ val_vtep_if1->portmap.valid[UPLL_IDX_TAGGED_PM] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
+ }
+ } else {
+ val_vtep_if1->valid[UPLL_IDX_PORT_MAP_VTEPI] = UNC_VF_INVALID;
+ val_vtep_if1->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] =
+ UNC_VF_INVALID;
+ val_vtep_if1->portmap.valid[UPLL_IDX_VLAN_ID_PM] = UNC_VF_INVALID;
+ val_vtep_if1->portmap.valid[UPLL_IDX_TAGGED_PM] = UNC_VF_INVALID;
+ }
+ }
+ if (!copy_to_running)
+ val_vtep_if1->valid[UPLL_IDX_DESC_VTEPI] = UNC_VF_INVALID;
+ for (unsigned int loop = 0;
+ loop < sizeof(val_vtep_if1->valid) / sizeof(uint8_t); ++loop) {
+ if ((UNC_VF_VALID == (uint8_t) val_vtep_if1->valid[loop]) ||
+ (UNC_VF_VALID_NO_VALUE == (uint8_t) val_vtep_if1->valid[loop])) {
+ if (loop == UPLL_IDX_PORT_MAP_VTEPI) {
+ for (unsigned int i = 0;
+ i < sizeof(val_vtep_if1->portmap.valid) / sizeof(uint8_t); ++i) {
+ if ((UNC_VF_VALID == (uint8_t) val_vtep_if1->portmap.valid[i]) ||
+ (UNC_VF_VALID_NO_VALUE ==
+ (uint8_t) val_vtep_if1->portmap.valid[i])) {
+ invalid_attr = false;
+ break;
+ }
+ }
+ } else {
+ invalid_attr = false;
+ }
+ if (invalid_attr == false) break;
+ }
+ }
+ return invalid_attr;
+ }
+
+ upll_rc_t VtepIfMoMgr::UpdateConfigStatus(ConfigKeyVal *vtepif_keyval,
+ unc_keytype_operation_t op,
+ uint32_t driver_result,
+ ConfigKeyVal *upd_key,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ctrlr_key) {
+ UPLL_FUNC_TRACE;
+ val_vtep_if_t *vtepif_val = static_cast<val_vtep_if_t *>
+ (GetVal(vtepif_keyval));
+ if (vtepif_val == NULL) return UPLL_RC_ERR_GENERIC;
+ unc_keytype_configstatus_t cs_status = (driver_result == UPLL_RC_SUCCESS)?
+ UNC_CS_APPLIED:UNC_CS_NOT_APPLIED;
+ UPLL_LOG_TRACE("DriverResult %d, "
+ "ConfigStatus %d", driver_result, cs_status);
+ UPLL_LOG_TRACE("%s", (vtepif_keyval->ToStrAll()).c_str());
+ val_vtep_if_t *vtep_if_running = static_cast<val_vtep_if_t *>
+ (GetVal(upd_key));
+ if (op == UNC_OP_CREATE) {
+ vtepif_val->cs_row_status = cs_status;
+ val_db_vtep_if_st *vtep_db_valst = static_cast<val_db_vtep_if_st *>
+ (ConfigKeyVal::Malloc(sizeof(val_db_vtep_if_st)));
+ if (vtep_db_valst == NULL) return UPLL_RC_ERR_GENERIC;
+ vtepif_keyval->AppendCfgVal(IpctSt::kIpcStValVtepIfSt, vtep_db_valst);
+#if 0
+ upll_rc_t result_code = InitOperStatus<val_vtep_if_st, val_db_vtep_if_st>
+ (vtepif_keyval,
+ vtepif_val->valid[UPLL_IDX_ADMIN_ST_VTEPI],
+ vtepif_val->admin_status,
+ vtepif_val->valid[UPLL_IDX_PORT_MAP_VTEPI],
+ &vtepif_val->portmap);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error settiing oper status");
+ return UPLL_RC_ERR_GENERIC;
+ }
+#else
+ val_vtep_if_st *vnif_st = &vtep_db_valst->vtep_if_val_st;
+ if (!vnif_st) {
+ UPLL_LOG_DEBUG("Returning error\n");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ vnif_st->oper_status = UPLL_OPER_STATUS_UP;
+ vnif_st->valid[UPLL_IDX_IF_OPER_STATUS_VTEPIS] = UNC_VF_VALID;
+#endif
+ vtep_db_valst->down_count = 0;
+ } else if (op == UNC_OP_UPDATE) {
+ void *val = reinterpret_cast<void *>(vtepif_val);
+ CompareValidValue(val, GetVal(upd_key), true);
+ UPLL_LOG_TRACE("%s", (upd_key->ToStrAll()).c_str());
+ vtepif_val->cs_row_status =
+ vtep_if_running->cs_row_status;
+ } else {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ for (unsigned int loop = 0; loop <
+ sizeof(vtepif_val->valid) / sizeof(vtepif_val->valid[0]);
+ ++loop) {
+ if ((UNC_VF_VALID == (uint8_t) vtepif_val->valid[loop])
+ || (UNC_VF_VALID_NO_VALUE == (uint8_t) vtepif_val->valid[loop])) {
+ // Description is set to APPLIED
+ if (loop == UPLL_IDX_DESC_VTEPI)
+ vtepif_val->cs_attr[loop] = UNC_CS_APPLIED;
+ else
+ vtepif_val->cs_attr[loop] = cs_status;
+ } else if ((UNC_VF_INVALID == vtepif_val->valid[loop]) &&
+ (UNC_OP_CREATE == op)) {
+ vtepif_val->cs_attr[loop] = UNC_CS_APPLIED;
+ } else if ((UNC_VF_INVALID == vtepif_val->valid[loop]) &&
+ (UNC_OP_UPDATE == op)) {
+ vtepif_val->cs_attr[loop] =
+ vtep_if_running->cs_attr[loop];
+ }
+ }
+ for (unsigned int loop = 0;
+ loop < sizeof(vtepif_val->portmap.valid)/
+ sizeof(vtepif_val->portmap.valid[0]); ++loop ) {
+ if ((UNC_VF_VALID == vtepif_val->portmap.valid[loop])
+ || (UNC_VF_VALID_NO_VALUE == vtepif_val->portmap.valid[loop]))
+ vtepif_val->portmap.cs_attr[loop] = cs_status;
+ else if ((UNC_VF_INVALID == vtepif_val->portmap.valid[loop]) &&
+ (UNC_OP_CREATE == op))
+ vtepif_val->portmap.cs_attr[loop] = UNC_CS_APPLIED;
+ else if ((UNC_VF_INVALID == vtepif_val->portmap.valid[loop]) &&
+ (UNC_OP_UPDATE == op))
+ vtepif_val->portmap.cs_attr[loop] =
+ vtep_if_running->portmap.cs_attr[loop];
+ }
+ return UPLL_RC_SUCCESS;
+ }
+
+ upll_rc_t VtepIfMoMgr::UpdateAuditConfigStatus(
+ unc_keytype_configstatus_t cs_status,
+ uuc::UpdateCtrlrPhase phase,
+ ConfigKeyVal *&ckv_running) {
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_vtep_if_t *val;
+ val = (ckv_running != NULL)?reinterpret_cast<val_vtep_if_t *>
+ (GetVal(ckv_running)):NULL;
+ if (NULL == val) {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (uuc::kUpllUcpCreate == phase )
+ val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
+ for ( unsigned int loop = 0;
+ loop < sizeof(val->valid)/sizeof(uint8_t); ++loop ) {
+ if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
+ cs_status == UNC_CS_APPLIED)
+ val->cs_attr[loop] = cs_status;
+ }
+ for (unsigned int loop = 0;
+ loop < sizeof(val->portmap.valid) / sizeof(uint8_t); ++loop) {
+ if ((cs_status == UNC_CS_INVALID &&
+ UNC_VF_VALID == val->portmap.valid[loop])
+ || cs_status == UNC_CS_APPLIED)
+ val->portmap.cs_attr[loop] = cs_status;
+ }
+ return result_code;
+ }
+
+ upll_rc_t VtepIfMoMgr::ValidateMessage(IpcReqRespHeader *req,
+ ConfigKeyVal *ikey) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ if (!ikey || !req || !(ikey->get_key())) {
+ UPLL_LOG_DEBUG("IpcReqRespHeader or ConfigKeyVal is Null");
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ unc_key_type_t keytype = ikey->get_key_type();
+ if (UNC_KT_VTEP_IF != keytype) {
+ UPLL_LOG_DEBUG("Invalid keytype. Keytype- %d", keytype);
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ if (ikey->get_st_num() != IpctSt::kIpcStKeyVtepIf) {
+ UPLL_LOG_DEBUG("Invalid struct received.Expected struct-kIpcStKeyVtepIf,"
+ "received struct -%s ", reinterpret_cast<const char *>
+ (IpctSt::GetIpcStdef(ikey->get_st_num())));
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ key_vtep_if_t *key_vtep_if = reinterpret_cast <key_vtep_if_t *>
+ (ikey->get_key());
+
+ uint32_t dt_type = req->datatype;
+ uint32_t operation = req->operation;
+ uint32_t option1 = req->option1;
+ uint32_t option2 = req->option2;
+
+ ret_val = ValidateVTepIfKey(key_vtep_if, operation);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Key struct Validation failed for VTEP_IF");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ } else {
+ if ((operation == UNC_OP_CREATE) && (dt_type == UPLL_DT_CANDIDATE)) {
+ val_vtep_if_t *val_vtep_if = NULL;
+ if ((ikey->get_cfg_val()) &&
+ ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVtepIf)) {
+ val_vtep_if = reinterpret_cast <val_vtep_if_t *>
+ (ikey->get_cfg_val()->get_val());
+ }
+ if (val_vtep_if != NULL) {
+ ret_val = ValidateVTepIfValue(val_vtep_if, operation);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Val struct Validation failed for CREATE op");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_TRACE("Value structure is an optional for CREATE op");
+ return UPLL_RC_SUCCESS;
+ }
+ } else if ((operation == UNC_OP_UPDATE) &&
+ (dt_type == UPLL_DT_CANDIDATE)) {
+ val_vtep_if_t *val_vtep_if = NULL;
+ if ((ikey->get_cfg_val()) &&
+ ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVtepIf)) {
+ val_vtep_if = reinterpret_cast <val_vtep_if_t *>
+ (ikey->get_cfg_val()->get_val());
+ }
+ if (val_vtep_if != NULL) {
+ ret_val = ValidateVTepIfValue(val_vtep_if, operation);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Val struct Validation failed for UPDATE op");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_DEBUG("Value structure mandatory for UPDATE op");
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ } else if (((operation == UNC_OP_READ) ||
+ (operation == UNC_OP_READ_SIBLING) ||
+ (operation == UNC_OP_READ_SIBLING_BEGIN) ||
+ (operation == UNC_OP_READ_SIBLING_COUNT)) &&
+ ((dt_type == UPLL_DT_CANDIDATE) ||
+ (dt_type == UPLL_DT_RUNNING) ||
+ (dt_type == UPLL_DT_STARTUP) ||
+ (dt_type == UPLL_DT_STATE))) {
+ if (option1 == UNC_OPT1_NORMAL) {
+ if (option2 == UNC_OPT2_NONE) {
+ val_vtep_if_t *val_vtep_if = NULL;
+ if ((ikey->get_cfg_val()) &&
+ ((ikey->get_cfg_val())->get_st_num() ==
+ IpctSt::kIpcStValVtepIf)) {
+ val_vtep_if = reinterpret_cast <val_vtep_if_t *>
+ (ikey->get_cfg_val()->get_val());
+ }
+ if (val_vtep_if != NULL) {
+ ret_val = ValidateVTepIfValue(val_vtep_if);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Val struct Validation failed for READ op");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_TRACE("Value structure is an optional for READ op");
+ return UPLL_RC_SUCCESS;
+ }
+ } else if ((option2 == UNC_OPT2_NEIGHBOR) &&
+ (dt_type == UPLL_DT_STATE) &&
+ (operation == UNC_OP_READ)) {
+ val_vtn_neighbor_t *val_vtn_neighbor = NULL;
+ if ((ikey->get_cfg_val()) &&
+ ((ikey->get_cfg_val())->get_st_num() ==
+ IpctSt::kIpcStValVtnNeighbor)) {
+ val_vtn_neighbor =
+ reinterpret_cast <val_vtn_neighbor_t *>
+ (ikey->get_cfg_val()->get_val());
+ }
+ if (val_vtn_neighbor != NULL) {
+ ret_val = ValidateVtnNeighborValue(val_vtn_neighbor);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Val struct Validation failed for READ op");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_TRACE("value structure is an optional for READ op");
+ return UPLL_RC_SUCCESS;
+ }
+ } else {
+ UPLL_LOG_TRACE("option2 is not matching");
+ return UPLL_RC_ERR_INVALID_OPTION2;
+ }
+ } else {
+ UPLL_LOG_TRACE("option1 is not matching");
+ return UPLL_RC_ERR_INVALID_OPTION1;
+ }
+ } else if ((operation == UNC_OP_DELETE) ||
+ (((operation == UNC_OP_READ_NEXT) ||
+ (operation == UNC_OP_READ_BULK)) &&
+ ((dt_type == UPLL_DT_CANDIDATE) ||
+ (dt_type == UPLL_DT_RUNNING) ||
+ (dt_type == UPLL_DT_STARTUP)))) {
+ UPLL_LOG_TRACE("Value structure is none for operation type:%d",
+ operation);
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_DEBUG("Invalid datatype(%d) or operation(%d)", dt_type,
+ operation);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+ }
+ upll_rc_t VtepIfMoMgr::ValidateVTepIfValue(val_vtep_if_t *val_vtep_if,
+ uint32_t operation) {
+ UPLL_FUNC_TRACE;
+
+ if (val_vtep_if->valid[UPLL_IDX_DESC_VTEPI] == UNC_VF_VALID) {
+ if (!ValidateDesc(val_vtep_if->description,
+ kMinLenDescription, kMaxLenDescription)) {
+ UPLL_LOG_DEBUG("Syntax check failed. desc -%s",
+ val_vtep_if->description);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ } else if ((val_vtep_if->valid[UPLL_IDX_DESC_VTEPI] ==
+ UNC_VF_VALID_NO_VALUE) &&
+ ((operation == UNC_OP_UPDATE) || (operation == UNC_OP_CREATE))) {
+ val_vtep_if->description[0] = '\0';
+ }
+ if (val_vtep_if->valid[UPLL_IDX_ADMIN_ST_VTEPI] == UNC_VF_VALID) {
+ if (!ValidateNumericRange(val_vtep_if->admin_status,
+ (uint8_t) UPLL_ADMIN_ENABLE,
+ (uint8_t) UPLL_ADMIN_DISABLE, true, true)) {
+ UPLL_LOG_DEBUG("Syntax check failed. admin_status- %d",
+ val_vtep_if->admin_status);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ } else if ((val_vtep_if->valid[UPLL_IDX_ADMIN_ST_VTEPI] ==
+ UNC_VF_VALID_NO_VALUE)
+ && ((operation == UNC_OP_UPDATE) || (operation == UNC_OP_CREATE))) {
+ val_vtep_if->admin_status = UPLL_ADMIN_ENABLE;
+ } else if ((val_vtep_if->valid[UPLL_IDX_ADMIN_ST_VTEPI] == UNC_VF_INVALID)
+ && (operation == UNC_OP_CREATE)) {
+ val_vtep_if->valid[UPLL_IDX_ADMIN_ST_VTEPI] = UNC_VF_VALID_NO_VALUE;
+ val_vtep_if->admin_status = UPLL_ADMIN_ENABLE;
+ }
+ if (val_vtep_if->valid[UPLL_IDX_PORT_MAP_VTEPI] == UNC_VF_VALID) {
+ if (val_vtep_if->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM]
+ == UNC_VF_VALID) {
+ if (!ValidateLogicalPortId(
+ reinterpret_cast<char *>(val_vtep_if->portmap.logical_port_id),
+ kMinLenLogicalPortId, kMaxLenLogicalPortId)) {
+ UPLL_LOG_DEBUG("Logical Port id syntax check failed."
+ "Received Logical Port Id - %s",
+ val_vtep_if->portmap.logical_port_id);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ if (toupper(val_vtep_if->portmap.logical_port_id[0]) == 'S'
+ && toupper(val_vtep_if->portmap.logical_port_id[1]) == 'W') {
+ UPLL_LOG_DEBUG("Invalid logical_port_id - %s",
+ val_vtep_if->portmap.logical_port_id);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ } else if (val_vtep_if->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] ==
+ UNC_VF_VALID_NO_VALUE
+ && (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE)) {
+ uuu::upll_strncpy(val_vtep_if->portmap.logical_port_id, " ",
+ kMaxLenLogicalPortId+1);
+ }
+ if (val_vtep_if->portmap.valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID) {
+ if ((val_vtep_if->portmap.vlan_id != 0xFFFF) &&
+ !ValidateNumericRange(val_vtep_if->portmap.vlan_id,
+ (uint16_t) kMinVlanId, (uint16_t) kMaxVlanId,
+ true, true)) {
+ UPLL_LOG_DEBUG("Vlan Id Number check failed."
+ "Received vlan_id - %d",
+ val_vtep_if->portmap.vlan_id);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ } else if (val_vtep_if->portmap.valid[UPLL_IDX_VLAN_ID_PM]
+ == UNC_VF_VALID_NO_VALUE
+ && (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE)) {
+ val_vtep_if->portmap.vlan_id = 0;
+ }
+ if (val_vtep_if->portmap.valid[UPLL_IDX_TAGGED_PM] == UNC_VF_VALID) {
+ if (!ValidateNumericRange((uint8_t) val_vtep_if->portmap.tagged,
+ (uint8_t) UPLL_VLAN_UNTAGGED,
+ (uint8_t) UPLL_VLAN_TAGGED, true, true)) {
+ UPLL_LOG_DEBUG("Tagged Numeric range check failed."
+ "Received Tag - %d",
+ val_vtep_if->portmap.tagged);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ } else if (((val_vtep_if->portmap.valid[UPLL_IDX_TAGGED_PM]
+ == UNC_VF_VALID_NO_VALUE) ||
+ (val_vtep_if->portmap.valid[UPLL_IDX_TAGGED_PM]
+ == UNC_VF_INVALID))
+ && (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE)) {
+ if (val_vtep_if->portmap.valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID)
+ val_vtep_if->portmap.tagged = UPLL_VLAN_TAGGED;
+ else
+ val_vtep_if->portmap.tagged = UPLL_VLAN_UNTAGGED;
+ val_vtep_if->portmap.valid[UPLL_IDX_TAGGED_PM] = UNC_VF_VALID;
+ }
+ } else if ((val_vtep_if->valid[UPLL_IDX_PORT_MAP_VTEPI] ==
+ UNC_VF_VALID_NO_VALUE)
+ && (operation == UNC_OP_UPDATE || operation == UNC_OP_CREATE)) {
+ memset(&(val_vtep_if->portmap), 0, sizeof(val_vtep_if->portmap));
+ }
+ return UPLL_RC_SUCCESS;
+ }
+ upll_rc_t VtepIfMoMgr::ValidateVTepIfKey(key_vtep_if_t *key_vtep_if,
+ uint32_t operation) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ ret_val = ValidateKey(
+ reinterpret_cast<char *>(key_vtep_if->vtep_key.vtn_key.vtn_name),
+ kMinLenVtnName, kMaxLenVtnName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("Vtn Name syntax check failed."
+ "Received VTN Name - %s",
+ key_vtep_if->vtep_key.vtn_key.vtn_name);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ ret_val = ValidateKey(
+ reinterpret_cast<char *>(key_vtep_if->vtep_key.vtep_name),
+ kMinLenVnodeName, kMaxLenVnodeName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("VTEP Name syntax check failed."
+ "Received VTEP Name -%s",
+ key_vtep_if->vtep_key.vtep_name);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ if ((operation != UNC_OP_READ_SIBLING_BEGIN) &&
+ (operation != UNC_OP_READ_SIBLING_COUNT)) {
+ ret_val = ValidateKey(reinterpret_cast<char *> (key_vtep_if->if_name),
+ kMinLenInterfaceName, kMaxLenInterfaceName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Syntax check failed.if_name(%s)", key_vtep_if->if_name);
+ return ret_val;
+ }
+ } else {
+ UPLL_LOG_TRACE("Operation is %d", operation);
+ StringReset(key_vtep_if->if_name);
+ }
+ return UPLL_RC_SUCCESS;
+ }
+
+ upll_rc_t VtepIfMoMgr::ValidateVtnNeighborValue(
+ val_vtn_neighbor_t *val_vtn_neighbor) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+
+ if (val_vtn_neighbor->valid[UPLL_IDX_CONN_VNODE_NAME_VN] == UNC_VF_VALID) {
+ ret_val = ValidateKey(
+ reinterpret_cast<char *>(val_vtn_neighbor->connected_vnode_name),
+ kMinLenVnodeName, kMaxLenVnodeName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Syntax check failed.conn_vnode_name-(%s)",
+ val_vtn_neighbor->connected_vnode_name);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ }
+ if (val_vtn_neighbor->valid[UPLL_IDX_CONN_VNODE_IF_NAME_VN]
+ == UNC_VF_VALID) {
+ ret_val = ValidateKey(
+ reinterpret_cast<char *>(val_vtn_neighbor->connected_if_name),
+ kMinLenInterfaceName, kMaxLenInterfaceName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Syntax check failed. connected_if_name-%s",
+ val_vtn_neighbor->connected_if_name);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ }
+ if (val_vtn_neighbor->valid[UPLL_IDX_CONN_VLINK_NAME_VN] == UNC_VF_VALID) {
+ ret_val = ValidateKey(
+ reinterpret_cast<char *>(val_vtn_neighbor->connected_vlink_name),
+ kMinLenVlinkName, kMaxLenVlinkName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Syntax check failed.connected_vlink_name=%s",
+ val_vtn_neighbor->connected_vlink_name);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+ }
+ upll_rc_t VtepIfMoMgr::ValVTepIfAttributeSupportCheck(
+ val_vtep_if_t *val_vtep_if,
+ const uint8_t* attrs, unc_keytype_operation_t operation) {
+ UPLL_FUNC_TRACE;
+ if ((val_vtep_if->valid[UPLL_IDX_DESC_VTEPI] == UNC_VF_VALID)
+ || (val_vtep_if->valid[UPLL_IDX_DESC_VTEPI] == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtep_if::kCapDesc] == 0) {
+ val_vtep_if->valid[UPLL_IDX_DESC_VTEPI] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("Attribute Desc not supported in pfc controller");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ }
+
+ if ((val_vtep_if->valid[UPLL_IDX_ADMIN_ST_VTEPI] == UNC_VF_VALID)
+ || (val_vtep_if->valid[UPLL_IDX_ADMIN_ST_VTEPI]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtep_if::kCapAdminStatus] == 0) {
+ val_vtep_if->valid[UPLL_IDX_ADMIN_ST_VTEPI] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("Attribute AdminStatus not supported in controller");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ }
+ if ((val_vtep_if->valid[UPLL_IDX_PORT_MAP_VTEPI] == UNC_VF_VALID)
+ || (val_vtep_if->valid[UPLL_IDX_PORT_MAP_VTEPI] ==
+ UNC_VF_VALID_NO_VALUE)) {
+ if ((val_vtep_if->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] ==
+ UNC_VF_VALID)
+ || (val_vtep_if->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtep_if::kCapLogicalPortId] == 0) {
+ val_vtep_if->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] =
+ UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("portmap.swich_id attr is not supported by ctrlr ");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ }
+ if ((val_vtep_if->portmap.valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID)
+ || (val_vtep_if->portmap.valid[UPLL_IDX_VLAN_ID_PM]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtep_if::kCapVlanId] == 0) {
+ val_vtep_if->portmap.valid[UPLL_IDX_VLAN_ID_PM] =
+ UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("portmap.vlanid attr is not supported by ctrlr ");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ }
+ if ((val_vtep_if->portmap.valid[UPLL_IDX_TAGGED_PM] == UNC_VF_VALID)
+ || (val_vtep_if->portmap.valid[UPLL_IDX_TAGGED_PM]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtep_if::kCapTagged] == 0) {
+ val_vtep_if->portmap.valid[UPLL_IDX_TAGGED_PM] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("portmap.Tagged attr is not supported by ctrlr ");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ }
+ }
+ return UPLL_RC_SUCCESS;
+ }
+
+ upll_rc_t VtepIfMoMgr::ValidateCapability(IpcReqRespHeader *req,
+ ConfigKeyVal *ikey, const char * ctrlr_name) {
+ UPLL_FUNC_TRACE;
+ if (!ikey || !req) {
+ UPLL_LOG_DEBUG("ConfigKeyVal / IpcReqRespHeader is Null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ if (!ctrlr_name) {
+ ctrlr_name = reinterpret_cast<char*>((reinterpret_cast<key_user_data_t *>
+ (ikey->get_user_data()))->ctrlr_id);
+ if (!ctrlr_name || !strlen(ctrlr_name)) {
+ UPLL_LOG_DEBUG("Controller Name is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+
+ UPLL_LOG_TRACE("ctrlr_name(%s), operation : (%d)",
+ ctrlr_name, req->operation);
+
+ bool result_code = false;
+ uint32_t max_instance_count = 0;
+ uint32_t max_attrs = 0;
+ const uint8_t *attrs = NULL;
+ switch (req->operation) {
+ case UNC_OP_CREATE:
+ result_code = GetCreateCapability(ctrlr_name,
+ ikey->get_key_type(), &max_instance_count, &max_attrs, &attrs);
+ if (result_code && (max_instance_count != 0) &&
+ cur_instance_count >= max_instance_count) {
+ UPLL_LOG_DEBUG("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
+ __LINE__, __FUNCTION__, cur_instance_count, max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
+ break;
+
+ case UNC_OP_UPDATE:
+ result_code = GetUpdateCapability(ctrlr_name,
+ ikey->get_key_type(), &max_attrs, &attrs);
+ break;
+
+ case UNC_OP_READ:
+ case UNC_OP_READ_SIBLING:
+ case UNC_OP_READ_SIBLING_BEGIN:
+ case UNC_OP_READ_SIBLING_COUNT:
+ result_code = GetReadCapability(ctrlr_name,
+ ikey->get_key_type(), &max_attrs, &attrs);
+ break;
+
+ default:
+ UPLL_LOG_DEBUG("Invalid operation");
+ break;
+ }
+ if (!result_code) {
+ UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s) "
+ "for operation(%d)",
+ ikey->get_key_type(), ctrlr_name, req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ val_vtep_if_t *val_vtep_if = NULL;
+ if ((ikey->get_cfg_val())
+ && ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVtepIf)) {
+ val_vtep_if =
+ reinterpret_cast<val_vtep_if_t *> (ikey->get_cfg_val()->get_val());
+ }
+ if (val_vtep_if) {
+ if (max_attrs > 0) {
+ return ValVTepIfAttributeSupportCheck(val_vtep_if, attrs,
+ req->operation);
+ } else {
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d",
+ req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+ }
+
+ /*
+ upll_rc_t VtepIfMoMgr::CopyToConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *ikey) {
+
+ if ( !ikey || !(ikey->get_key()) )
+ return UPLL_RC_ERR_GENERIC;
+
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+
+ key_rename_vnode_info *key_rename = (key_rename_vnode_info *)ikey->get_key();
+ key_vtep_if_t *vtep_key = (key_vtep_if_t *) malloc ( sizeof (key_vtep_if_t));
+ if (!vtep_key)
+ return UPLL_RC_ERR_GENERIC;
+ if (!strlen ((char *)key_rename->old_unc_vtn_name))
+ return UPLL_RC_ERR_GENERIC;
+ strcpy ((char *)vtep_key->vtep_key.vtn_key.vtn_name, (char *)key_rename->old_unc_vtn_name);
+
+ okey = new ConfigKeyVal (UNC_KT_VTEP_IF, IpctSt::kIpcStKeyVtepIf, vtep_key, NULL);
+ if (!okey) {
+ FREE_IF_NOT_NULL(vtep_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ return result_code;
+ }
+ */
+
+ upll_rc_t VtepIfMoMgr::IsReferenced(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type, DalDmlIntf *dmi) {
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *okey = NULL;
+ if (!ikey || !(ikey->get_key()) ||!dmi )
+ return UPLL_RC_ERR_GENERIC;
+ GetChildConfigKey(okey, ikey);
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutFlag};
+ result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ ConfigKeyVal *tkey = okey;
+ while (okey) {
+ uint8_t vlink_flag = 0;
+ GET_USER_DATA_FLAGS(okey, vlink_flag);
+ if (vlink_flag & VIF_TYPE)
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ okey = okey->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(tkey);
+ return result_code;
+ }
+
+} // namespace vtn
+} // namespace upll
+} // namespace unc
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 NEC Corporation
+ * All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+#ifndef UNC_UPLL_VTEP_IF_MOMGR_H
+#define UNC_UPLL_VTEP_IF_MOMGR_H
+
+#include <set>
+#include "momgr_impl.hh"
+#include "vnode_child_momgr.hh"
+
+namespace unc {
+namespace upll {
+namespace kt_momgr {
+
+
+enum VtepIfMoMgrTables {
+ VTEPIFTBL = 0,
+ NVTEPIFTABLES
+};
+
+
+class VtepIfMoMgr : public VnodeChildMoMgr {
+ private:
+ static BindInfo vtep_if_bind_info[];
+ /* @brief Returns admin and portmap information if portmap is
+ * valid. Else returns NULL for portmap
+ *
+ * @param[in] ikey Pointer to ConfigKeyVal
+ * @param[out] valid_pm portmap is valid
+ * @param[out] pm pointer to portmap informtation if valid_pm
+ * @param[out] valid_admin admin_status valid value
+ * @param[out] admin_status value of admin_status
+ *
+ * @retval UPLL_RC_SUCCESS Completed successfully.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ *
+ **/
+ virtual upll_rc_t GetPortMap(ConfigKeyVal *ikey, uint8_t &valid_pm,
+ val_port_map_t *&pm,
+ uint8_t &valid_admin,
+ uint8_t &admin_status) {
+ UPLL_FUNC_TRACE;
+ if (ikey == NULL) return UPLL_RC_ERR_GENERIC;
+ val_vtep_if *ifval = reinterpret_cast<val_vtep_if *>
+ (GetVal(ikey));
+ if (!ifval) {
+ UPLL_LOG_DEBUG("Invalid param");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ valid_pm = ifval->valid[UPLL_IDX_PORT_MAP_VTEPI];
+ if (valid_pm == UNC_VF_VALID)
+ pm = &ifval->portmap;
+ else
+ pm = NULL;
+ valid_admin = ifval->valid[UPLL_IDX_ADMIN_ST_VTEPI];
+ admin_status = ifval->admin_status;
+ return UPLL_RC_SUCCESS;
+ }
+ /**
+ * @brief Gets the valid array position of the variable in the value
+ * structure from the table in the specified configuration
+ *
+ * @param[in] val pointer to the value structure
+ * @param[in] indx database index for the variable
+ * @param[out] valid position of the variable in the valid array -
+ * NULL if valid does not exist.
+ * @param[in] dt_type specifies the configuration
+ * @param[in] tbl specifies the table containing the given value
+ *
+ **/
+ upll_rc_t GetValid(void *val, uint64_t indx, uint8_t *&valid,
+ upll_keytype_datatype_t dt_type, MoMgrTables tbl);
+ /**
+ * @brief Filters the attributes which need not be sent to controller
+ *
+ * @param[in/out] val1 first record value instance.
+ * @param[in] val2 second record value instance.
+ * @param[in] audit Not used for VTN
+ * @param[in] op Operation to be performed
+ *
+ **/
+ bool FilterAttributes(void *&val1, void *val2, bool copy_to_running,
+ unc_keytype_operation_t op);
+ /**
+ * @brief Compares the valid value between two database records.
+ * if both the values are same, update the valid flag for corresponding
+ * attribute as invalid in the first record.
+ *
+ * @param[in/out] val1 first record value instance.
+ * @param[in] val2 second record value instance.
+ * @param[in] audit if true, CompareValidValue called from audit process.
+ *
+ **/
+ bool CompareValidValue(void *&val1, void *val2, bool copy_to_running);
+
+ upll_rc_t ValidateMessage(ConfigKeyVal *kval,
+ upll_keytype_datatype_t dt_type,
+ unc_keytype_operation_t op);
+ upll_rc_t UpdateConfigStatus(ConfigKeyVal *vtepif_keyval,
+ unc_keytype_operation_t op,
+ uint32_t result,
+ ConfigKeyVal *upd_key,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ctrlr_key = NULL);
+ /**
+ * @brief Update config status for commit result and vote result.
+ *
+ * @param[in/out] ckv_running ConfigKeyVal instance.
+ * @param[in] cs_status either UNC_CS_INVALID or UNC_CS_APPLIED.
+ * @param[in] phase specify the phase (CREATE,DELETE or UPDATE)
+ *
+ **/
+ upll_rc_t UpdateAuditConfigStatus(unc_keytype_configstatus_t cs_status,
+ uuc::UpdateCtrlrPhase phase,
+ ConfigKeyVal *&ckv_running);
+ upll_rc_t ValidateAttribute(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req);
+ /**
+ * @brief Duplicates the input configkeyval including the key and val.
+ * based on the tbl specified.
+ *
+ * @param[in] okey Output Configkeyval - allocated within the function
+ * @param[in] req Input ConfigKeyVal to be duplicated.
+ * @param[in] tbl specifies if the val structure belongs to the main table/ controller table or rename table.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ upll_rc_t DupConfigKeyVal(ConfigKeyVal *&okey,
+ ConfigKeyVal *&req, MoMgrTables tbl = MAINTBL);
+
+ /* @brief To convert the value structure read from DB to
+ * VTNService during READ operations
+ * @param[in/out] ikey Pointer to the ConfigKeyVal Structure
+ *
+ * @retval UPLL_RC_SUCCESS Completed successfully.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ *
+ **/
+ upll_rc_t AdaptValToVtnService(ConfigKeyVal *ikey);
+
+ /**
+ * @brief Allocates for the specified val in the given configuration in the * specified table.
+ *
+ * @param[in/out] ck_val Reference pointer to configval structure
+ * allocated.
+ * @param[in] dt_type specifies the configuration candidate/running/
+ * state
+ * @param[in] tbl specifies if the corresponding table is the
+ * main table / controller table or rename table.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ upll_rc_t AllocVal(ConfigVal *&ck_val, upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl = MAINTBL);
+/**
+ * @brief Method to get a configkeyval of a specified keytype from an input configkeyval
+ *
+ * @param[in/out] okey pointer to output ConfigKeyVal
+ * @param[in] parent_key pointer to the configkeyval from which the output configkey val is initialized.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ */
+ upll_rc_t GetChildConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *parent_key);
+/**
+ * @brief Method to get a configkeyval of the parent keytype
+ *
+ * @param[in/out] okey pointer to parent ConfigKeyVal
+ * @param[in] ikey pointer to the child configkeyval from
+ * which the parent configkey val is obtained.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ upll_rc_t GetParentConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *ikey);
+
+ /**
+ * @Brief Validates the syntax of the specified key and value structure
+ * for KT_VTEP_IF keytype
+ *
+ * @param[in] req This structure contains
+ * IpcReqRespHeader(first 8 fields of input request structure).
+ * @param[in] ikey ikey contains key and value structure.
+ *
+ * @retval UPLL_RC_SUCCESS Successful.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX Syntax error.
+ * @retval UPLL_RC_ERR_NO_SUCH_INSTANCE key structure is not available.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ * @retval UPLL_RC_ERR_INVALID_OPTION1 option1 is not valid.
+ * @retval UPLL_RC_ERR_INVALID_OPTION2 option2 is not valid.
+ */
+ upll_rc_t ValidateMessage(IpcReqRespHeader *req, ConfigKeyVal *ikey);
+
+ /**
+ * @Brief Validates the syntax for KT_VTEP_IF keytype key structure.
+ *
+ * @param[in] key_vtep_if KT_VTEP_IF key structure.
+ *
+ * @retval UPLL_RC_SUCCESS validation succeeded.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX validation failed.
+ */
+ upll_rc_t ValidateVTepIfKey(key_vtep_if_t *key_vtep_if,
+ uint32_t operation);
+
+ /**
+ * @Brief Validates the syntax for KT_VTEP_IF keytype value structure.
+ *
+ * @param[in] val_vtep_if KT_VTEP_IF value structure.
+ *
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ * @retval UPLL_RC_SUCCESS validation succeeded.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX validation failed.
+ */
+ upll_rc_t ValidateVTepIfValue(val_vtep_if_t *val_vtep_if,
+ uint32_t operation = UNC_OP_INVALID);
+ /**
+ * @Brief Validates the syntax for KT_VTEP_IF keytype value structure.
+ *
+ * @param[in] val_vtn_neighbor KT_VTEP_IF value structure.
+ * @param[in] operation Operation type.
+ *
+ * @retval UPLL_RC_SUCCESS validation succeeded.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX validation failed.
+ */
+ upll_rc_t ValidateVtnNeighborValue(
+ val_vtn_neighbor_t *val_vtn_neighbor);
+ /**
+ * @Brief Checks if the specified key type(KT_VTEP_IF) and
+ * associated attributes are supported on the given controller,
+ * based on the valid flag
+ *
+ * @param[in] req This structure contains
+ * IpcReqRespHeader(first 8 fields of input request structure).
+ * @param[in] ikey ikey contains key and value structure.
+ * @param[in] crtlr_name Controller name.
+ *
+ * @retval UPLL_RC_SUCCESS Validation succeeded.
+ * @retval UPLL_RC_ERR_GENERIC Validation failure.
+ * @retval UPLL_RC_ERR_INVALID_OPTION1 Option1 is not valid.
+ * @retval UPLL_RC_ERR_INVALID_OPTION2 Option2 is not valid.
+ */
+
+ upll_rc_t ValidateCapability(IpcReqRespHeader *req, ConfigKeyVal *ikey,
+ const char * crtlr_name);
+ /**
+ * @Brief Checks if the specified key type and
+ * associated attributes are supported on the given controller,
+ * based on the valid flag.
+ *
+ * @param[in] val_vtep_if Value Structure.
+ * @param[in] attr pointer to controller attribute
+ * @param[in] operation Operation Name
+ *
+ * @retval UPLL_RC_SUCCESS validation succeeded.
+ * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ */
+ upll_rc_t ValVTepIfAttributeSupportCheck(
+ val_vtep_if_t *val_vtep_if,
+ const uint8_t* attrs, unc_keytype_operation_t operation);
+ /**
+ * @Brief Checks if the specified key type and
+ * associated attributes are supported on the given controller,
+ * based on the valid flag.
+ *
+ * @param[in] crtlr_name Controller name.
+ * @param[in] ikey Corresponding key and value structure.
+ *
+ * @retval UPLL_RC_SUCCESS validation succeeded.
+ * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ */
+ upll_rc_t ValVtnNeighAttributeSupportCheck(
+ const char * crtlr_name,
+ ConfigKeyVal *ikey);
+ bool GetRenameKeyBindInfo(unc_key_type_t key_type, BindInfo *&binfo,
+ int &nattr,
+ MoMgrTables tbl ) {
+ return true;
+ }
+ upll_rc_t CopyToConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *ikey) {
+ return UPLL_RC_SUCCESS;
+ }
+ upll_rc_t IsReferenced(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type, DalDmlIntf *dmi);
+
+ public:
+ VtepIfMoMgr();
+ virtual ~VtepIfMoMgr() {
+ for (int i = VTEPIFTBL; i < NVTEPIFTABLES; i++)
+ if (table[i]) {
+ delete table[i];
+ }
+ delete[] table;
+ }
+ /**
+ * @brief Method to check if individual portions of a key are valid
+ *
+ * @param[in/out] ikey pointer to ConfigKeyVal referring to a UNC resource
+ * @param[in] index db index associated with the variable
+ *
+ * @retval true input key is valid
+ * @retval false input key is invalid.
+ **/
+ bool IsValidKey(void *tkey, uint64_t index);
+
+ /* @brief Updates vtepif structure
+ * based on valid[PORTMAP] flag.
+ *
+ * @param[in/out] ikey Pointer to the ConfigKeyVal Structure
+ * @param[in] datatype DB type.
+ * @param[in] dmi Pointer to the DalDmlIntf(DB Interface)
+ *
+ * @retval UPLL_RC_SUCCESS Completed successfully.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ *
+ **/
+ upll_rc_t UpdateConfigVal(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t datatype,
+ DalDmlIntf *dmi);
+#if 0
+ upll_rc_t GetMappedVbridges(uint8_t *swid, DalDmlIntf *dmi,
+ set<key_vnode_t>*sw_vbridge_set);
+ upll_rc_t GetMappedInterfaces(key_vbr_t *vbr_key, DalDmlIntf *dmi,
+ ConfigKeyVal *&ikey);
+#endif
+};
+} // namesapce vtn
+} // namespace upll
+} // namespace unc
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 NEC Corporation
+ * All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+#include "vtep_momgr.hh"
+#define NUM_KEY_MAIN_TBL_ 4
+namespace unc {
+namespace upll {
+namespace kt_momgr {
+
+namespace dbl = unc::upll::dal;
+namespace tbl = unc::upll::dal::schema::table;
+
+
+BindInfo VtepMoMgr::vtep_bind_info[] = {
+ { uudst::vtep::kDbiVtnName, CFG_KEY, offsetof(key_vtep, vtn_key.vtn_name),
+ uud::kDalChar, kMaxLenVtnName+1 },
+ { uudst::vtep::kDbiVtepName, CFG_KEY, offsetof(key_vtep, vtep_name),
+ uud::kDalChar, kMaxLenVnodeName+1 },
+ { uudst::vtep::kDbiDesc, CFG_VAL, offsetof(val_vtep, description),
+ uud::kDalChar, kMaxLenDescription+1},
+ { uudst::vtep::kDbiCtrlrName, CFG_VAL, offsetof(val_vtep, controller_id),
+ uud::kDalChar, kMaxLenCtrlrId+1},
+ { uudst::vtep::kDbiCtrlrName, CK_VAL,
+ offsetof(key_user_data_t, ctrlr_id),
+ uud::kDalChar, kMaxLenCtrlrId+1 },
+ { uudst::vtep::kDbiDomainId, CFG_VAL, offsetof(val_vtep, domain_id),
+ uud::kDalChar, kMaxLenDomainId+1},
+ { uudst::vtep::kDbiDomainId, CK_VAL,
+ offsetof(key_user_data_t, domain_id),
+ uud::kDalChar, kMaxLenDomainId+1 },
+ { uudst::vtep::kDbiOperStatus, ST_VAL, offsetof(val_db_vtep_st,
+ vtep_val_st.oper_status), uud::kDalUint8, 1},
+ { uudst::vtep::kDbiDownCount, ST_VAL, offsetof(val_db_vtep_st, down_count),
+ uud::kDalUint32, 1},
+ { uudst::vtep::kDbiFlags, CK_VAL, offsetof(key_user_data_t, flags),
+ uud::kDalUint8, 1},
+ { uudst::vtep::kDbiValidDesc, CFG_META_VAL,
+ offsetof(val_vtep, valid[0]), uud::kDalUint8, 1},
+ { uudst::vtep::kDbiValidCtrlrName, CFG_META_VAL,
+ offsetof(val_vtep, valid[1]), uud::kDalUint8, 1},
+ { uudst::vtep::kDbiValidDomainId, CFG_META_VAL,
+ offsetof(val_vtep, valid[2]), uud::kDalUint8, 1},
+ { uudst::vtep::kDbiValidOperStatus, ST_META_VAL,
+ offsetof(val_db_vtep_st, vtep_val_st.valid[0]), uud::kDalUint8, 1},
+ { uudst::vtep::kDbiCsRowstatus, CS_VAL, offsetof(val_vtep, cs_row_status),
+ uud::kDalUint8, 1},
+ { uudst::vtep::kDbiCsDesc, CS_VAL, offsetof(val_vtep, cs_attr[0]),
+ uud::kDalUint8, 1},
+ { uudst::vtep::kDbiCsCtrlrName, CS_VAL, offsetof(val_vtep, cs_attr[1]),
+ uud::kDalUint8, 1},
+ { uudst::vtep::kDbiCsDomainId, CS_VAL, offsetof(val_vtep,
+ cs_attr[2]), uud::kDalUint8, 1}
+};
+
+unc_key_type_t VtepMoMgr::vtep_child[] = {
+ UNC_KT_VTEP_IF
+};
+
+VtepMoMgr::VtepMoMgr() {
+ UPLL_FUNC_TRACE;
+ Table *tbl = new Table(uudst::kDbiVtepTbl, UNC_KT_VTEP, vtep_bind_info,
+ IpctSt::kIpcStKeyVtep, IpctSt::kIpcStValVtep,
+ uudst::vtep::kDbiVtepNumCols+2);
+ ntable = MAX_MOMGR_TBLS;
+ table = new Table *[ntable];
+ table[MAINTBL] = tbl;
+ table[RENAMETBL] = NULL;
+ table[CTRLRTBL] = NULL;
+ nchild = sizeof(vtep_child) / sizeof(*vtep_child);
+ child = vtep_child;
+#ifdef _STANDALONE_
+ SetMoManager(UNC_KT_VTEP, reinterpret_cast<MoMgr *>(this));
+#endif
+}
+
+/*
+ * * Based on the key type the bind info will pass
+ *
+ bool VtepMoMgr::GetRenameKeyBindInfo(unc_key_type_t key_type, BindInfo *&binfo, int &nattr,
+ MoMgrTables tbl ) {
+ UPLL_FUNC_TRACE;
+ if (MAINTBL == tbl) {
+
+ nattr = NUM_KEY_MAIN_TBL_;
+ binfo = key_vtep_maintbl_bind_info;
+ return true;
+ }
+ return false;;
+ }*/
+
+
+bool VtepMoMgr::IsValidKey(void *key, uint64_t index) {
+ UPLL_FUNC_TRACE;
+ key_vtep *vtep_key = reinterpret_cast<key_vtep *>(key);
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ switch (index) {
+ case uudst::vtep::kDbiVtnName:
+ ret_val = ValidateKey(reinterpret_cast<char *>
+ (vtep_key->vtn_key.vtn_name), kMinLenVtnName, kMaxLenVtnName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("VTN Name is not valid(%d)", ret_val);
+ return false;
+ }
+ break;
+ case uudst::vtep::kDbiVtepName:
+ ret_val = ValidateKey(reinterpret_cast<char *>
+ (vtep_key->vtep_name), kMinLenVnodeName, kMaxLenVnodeName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("Vtep Name is not valid(%d)", ret_val);
+ return false;
+ }
+ break;
+ default:
+ UPLL_LOG_TRACE("Invalid Key Index");
+ return false;
+ }
+ return true;
+}
+
+upll_rc_t VtepMoMgr::GetChildConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *parent_key) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ key_vtep *vtep_key = static_cast<key_vtep *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtep)));
+ void *pkey;
+ if (parent_key == NULL) {
+ if (okey) delete okey;
+ okey = new ConfigKeyVal(UNC_KT_VTEP, IpctSt::kIpcStKeyVtep, vtep_key, NULL);
+ return UPLL_RC_SUCCESS;
+ } else {
+ pkey = parent_key->get_key();
+ }
+ if (!pkey) {
+ FREE_IF_NOT_NULL(vtep_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ switch (parent_key->get_key_type()) {
+ case UNC_KT_VTEP:
+ uuu::upll_strncpy(vtep_key->vtep_name,
+ static_cast<key_vtep *>(pkey)->vtep_name,
+ (kMaxLenVnodeName+1));
+ uuu::upll_strncpy(vtep_key->vtn_key.vtn_name,
+ static_cast<key_vtep *>(pkey)->vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ break;
+ case UNC_KT_VTN:
+ default:
+ uuu::upll_strncpy(vtep_key->vtn_key.vtn_name,
+ reinterpret_cast<key_vtn *>(pkey)->vtn_name,
+ (kMaxLenVtnName+1) );
+ *(vtep_key->vtep_name) = *"";
+ }
+ okey = new ConfigKeyVal(UNC_KT_VTEP, IpctSt::kIpcStKeyVtep, vtep_key, NULL);
+ if (okey == NULL) {
+ FREE_IF_NOT_NULL(vtep_key);
+ result_code = UPLL_RC_ERR_GENERIC;
+ } else {
+ SET_USER_DATA(okey, parent_key);
+ }
+ /* presumes MoMgrs receive only supported keytypes */
+ return result_code;
+}
+
+upll_rc_t VtepMoMgr::GetParentConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *ikey ) {
+ UPLL_FUNC_TRACE;
+ if ((ikey == NULL) || (ikey->get_key() == NULL)) {
+ UPLL_LOG_DEBUG("Null ikey param");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ key_vtep *vtep_key = static_cast<key_vtep *>(ikey->get_key());
+ if (!vtep_key) return UPLL_RC_ERR_GENERIC;
+
+ unc_key_type_t ikey_type = ikey->get_key_type();
+ if (ikey_type != UNC_KT_VTEP)
+ return UPLL_RC_ERR_GENERIC;
+ key_vtn *vtn_key = static_cast<key_vtn *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn)));
+ uuu::upll_strncpy(vtn_key->vtn_name, vtep_key->vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ DELETE_IF_NOT_NULL(okey);
+ okey = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcStKeyVtn, vtn_key, NULL);
+ if (okey == NULL) {
+ FREE_IF_NOT_NULL(vtn_key);
+ return UPLL_RC_ERR_GENERIC;
+ } else {
+ SET_USER_DATA(okey, ikey);
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+
+upll_rc_t VtepMoMgr::AllocVal(ConfigVal *&ck_val,
+ upll_keytype_datatype_t dt_type, MoMgrTables tbl) {
+ UPLL_FUNC_TRACE;
+ void *val;
+
+ if (ck_val != NULL) return UPLL_RC_ERR_GENERIC;
+ switch (tbl) {
+ case MAINTBL:
+ val =reinterpret_cast<void *>(ConfigKeyVal::Malloc(sizeof(val_vtep)));
+ ck_val = new ConfigVal(IpctSt::kIpcStValVtep, val);
+ if (!ck_val) {
+ FREE_IF_NOT_NULL(reinterpret_cast<val_vtep *>(val));
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (dt_type == UPLL_DT_STATE) {
+ val = reinterpret_cast<void *>
+ (ConfigKeyVal::Malloc(sizeof(val_db_vtep_st)));
+ ConfigVal *ck_nxtval = new ConfigVal(IpctSt::kIpcStValVtepSt, val);
+ if (!ck_nxtval) {
+ delete ck_val;
+ FREE_IF_NOT_NULL(reinterpret_cast<val_db_vtep_st *>(val));
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ck_val->AppendCfgVal(ck_nxtval);
+ }
+ break;
+ default:
+ val = NULL;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtepMoMgr::DupConfigKeyVal(ConfigKeyVal *&okey,
+ ConfigKeyVal *&req, MoMgrTables tbl) {
+ UPLL_FUNC_TRACE;
+ if (req == NULL) return UPLL_RC_ERR_GENERIC;
+ if (okey != NULL) return UPLL_RC_ERR_GENERIC;
+ if (req->get_key_type() != UNC_KT_VTEP)
+ return UPLL_RC_ERR_GENERIC;
+ ConfigVal *tmp1 = NULL, *tmp = (req)->get_cfg_val();
+ if (tmp) {
+ if (tbl == MAINTBL) {
+ val_vtep *ival = static_cast<val_vtep *>(GetVal(req));
+ val_vtep *vtep_val = static_cast<val_vtep *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtep)));
+ memcpy(vtep_val, ival, sizeof(val_vtep));
+ tmp1 = new ConfigVal(IpctSt::kIpcStValVtep, vtep_val);
+ if (!tmp1) {
+ FREE_IF_NOT_NULL(vtep_val);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ tmp = tmp->get_next_cfg_val();
+ };
+ if (tmp) {
+ if (tbl == MAINTBL) {
+ val_db_vtep_st *ival = static_cast<val_db_vtep_st *>(tmp->get_val());
+ val_db_vtep_st *vtep_st = static_cast<val_db_vtep_st *>
+ (ConfigKeyVal::Malloc(sizeof(val_db_vtep_st)));
+ if (!vtep_st) {
+ delete tmp1;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ memcpy(vtep_st, ival, sizeof(val_db_vtep_st));
+ ConfigVal *tmp2 = new ConfigVal(IpctSt::kIpcStValVtepSt, vtep_st);
+ if (!tmp2) {
+ delete tmp1;
+ FREE_IF_NOT_NULL(vtep_st);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ tmp1->AppendCfgVal(tmp2);
+ }
+ };
+ void *tkey = (req != NULL)?(req)->get_key():NULL;
+ key_vtep *ikey = static_cast<key_vtep *>(tkey);
+ key_vtep *vtep_key = static_cast<key_vtep *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtep)));
+ if (!vtep_key) {
+ if (tmp1) delete tmp1;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ memcpy(vtep_key, ikey, sizeof(key_vtep));
+ okey = new ConfigKeyVal(UNC_KT_VTEP, IpctSt::kIpcStKeyVtep, vtep_key, tmp1);
+ if (okey) {
+ SET_USER_DATA(okey, req);
+ } else {
+ if (tmp1) delete tmp1;
+ FREE_IF_NOT_NULL(vtep_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtepMoMgr::UpdateConfigStatus(ConfigKeyVal *vtep_key,
+ unc_keytype_operation_t op,
+ uint32_t driver_result,
+ ConfigKeyVal *upd_key,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ctrlr_key) {
+ UPLL_FUNC_TRACE;
+ unc_keytype_configstatus_t cs_status =
+ (driver_result == UPLL_RC_SUCCESS)? UNC_CS_APPLIED
+ : UNC_CS_NOT_APPLIED;
+ val_vtep *vtep_val = static_cast<val_vtep *>(GetVal(vtep_key));
+ if (vtep_val == NULL) return UPLL_RC_ERR_GENERIC;
+ val_vtep *val_running = static_cast<val_vtep *>(GetVal(upd_key));
+ if (op == UNC_OP_CREATE) {
+ vtep_val->cs_row_status = cs_status;
+ /* initialize entity/state information */
+ val_db_vtep_st *vtep_db_valst = static_cast<val_db_vtep_st *>
+ (ConfigKeyVal::Malloc(sizeof(val_db_vtep_st)));
+ val_vtep_st *vtepst_val = &vtep_db_valst->vtep_val_st;
+ vtepst_val->oper_status = UPLL_OPER_STATUS_UP;
+ vtepst_val->valid[UPLL_IDX_OPER_STATUS_VTEPS] = UNC_VF_VALID;
+ vtep_db_valst->down_count = 0;
+ vtep_db_valst->fault_count = 0;
+ vtep_key->AppendCfgVal(IpctSt::kIpcStValVtepSt, vtep_db_valst);
+ } else if (op == UNC_OP_UPDATE) {
+ void *val = reinterpret_cast<void *>(vtep_val);
+ CompareValidValue(val, GetVal(upd_key), true);
+ UPLL_LOG_TRACE("%s", (upd_key->ToStrAll()).c_str());
+ vtep_val->cs_row_status = val_running->cs_row_status;
+ } else {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ for (unsigned int loop = 0;
+ loop < sizeof(vtep_val->valid)/sizeof(vtep_val->valid[0]);
+ ++loop ) {
+ if ((UNC_VF_VALID == vtep_val->valid[loop]) ||
+ (UNC_VF_VALID_NO_VALUE == vtep_val->valid[loop])) {
+ // Description is set to APPLIED
+ if (loop == UPLL_IDX_DESC_VTEP)
+ vtep_val->cs_attr[loop] = UNC_CS_APPLIED;
+ else
+ vtep_val->cs_attr[loop] = cs_status;
+ } else if ((vtep_val->valid[loop] == UNC_VF_INVALID) &&
+ (UNC_OP_CREATE == op)) {
+ vtep_val->cs_attr[loop] = UNC_CS_APPLIED;
+ } else if ((vtep_val->valid[loop] == UNC_VF_INVALID) &&
+ (UNC_OP_UPDATE == op)) {
+ vtep_val->cs_attr[loop] = val_running->cs_attr[loop];
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+bool VtepMoMgr::FilterAttributes(void *&val1, void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op) {
+ UPLL_FUNC_TRACE;
+ val_vtep_t *val_vtep1 = reinterpret_cast<val_vtep_t *>(val1);
+ /* No need to configure description in controller. */
+ val_vtep1->valid[UPLL_IDX_DESC_VTEP] = UNC_VF_INVALID;
+ if (op != UNC_OP_CREATE)
+ return CompareValidValue(val1, val2, copy_to_running);
+ return false;
+}
+
+bool VtepMoMgr::CompareValidValue(void *&val1, void *val2,
+ bool copy_to_running) {
+ UPLL_FUNC_TRACE;
+ bool invalid_attr = true;
+ val_vtep_t *val_vtep1 = reinterpret_cast<val_vtep_t *>(val1);
+ val_vtep_t *val_vtep2 = reinterpret_cast<val_vtep_t *>(val2);
+ for (unsigned int loop = 0;
+ loop < sizeof(val_vtep1->valid)/sizeof(uint8_t); ++loop ) {
+ if (UNC_VF_INVALID == val_vtep1->valid[loop]
+ && UNC_VF_VALID == val_vtep2->valid[loop])
+ val_vtep1->valid[loop] = UNC_VF_VALID_NO_VALUE;
+ }
+ if (UNC_VF_VALID == val_vtep1->valid[UPLL_IDX_DESC_VTEP]
+ && UNC_VF_VALID == val_vtep2->valid[UPLL_IDX_DESC_VTEP]) {
+ if (!strcmp(reinterpret_cast<char*>(val_vtep1->description),
+ reinterpret_cast<char*>(val_vtep2->description)))
+ val_vtep1->valid[UPLL_IDX_DESC_VTEP] = UNC_VF_INVALID;
+ }
+ if (UNC_VF_VALID == val_vtep1->valid[UPLL_IDX_CONTROLLER_ID_VTEP]
+ && UNC_VF_VALID == val_vtep2->valid[UPLL_IDX_CONTROLLER_ID_VTEP]) {
+ if (!strcmp(reinterpret_cast<char*>(val_vtep1->controller_id),
+ reinterpret_cast<char*>(val_vtep2->controller_id)))
+ val_vtep1->valid[UPLL_IDX_CONTROLLER_ID_VTEP] = UNC_VF_INVALID;
+ }
+ if (UNC_VF_VALID == val_vtep1->valid[UPLL_IDX_DOMAIN_ID_VTEP]
+ && UNC_VF_VALID == val_vtep2->valid[UPLL_IDX_DOMAIN_ID_VTEP]) {
+ if (!strcmp(reinterpret_cast<char*>(val_vtep1->domain_id),
+ reinterpret_cast<char*>(val_vtep2->domain_id)))
+ val_vtep1->valid[UPLL_IDX_DOMAIN_ID_VTEP] = UNC_VF_INVALID;
+ }
+ if (!copy_to_running)
+ val_vtep1->valid[UPLL_IDX_DESC_VTEP] = UNC_VF_INVALID;
+ for (unsigned int loop = 0;
+ loop < sizeof(val_vtep1->valid) / sizeof(uint8_t); ++loop) {
+ if ((UNC_VF_VALID == (uint8_t) val_vtep1->valid[loop]) ||
+ (UNC_VF_VALID_NO_VALUE == (uint8_t) val_vtep1->valid[loop])) {
+ invalid_attr = false;
+ break;
+ }
+ }
+ return invalid_attr;
+}
+
+upll_rc_t VtepMoMgr::UpdateAuditConfigStatus(
+ unc_keytype_configstatus_t cs_status,
+ uuc::UpdateCtrlrPhase phase,
+ ConfigKeyVal *&ckv_running) {
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_vtep_t *val = (ckv_running != NULL)?reinterpret_cast<val_vtep_t *>
+ (GetVal(ckv_running)):NULL;
+ if (NULL == val) {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (uuc::kUpllUcpCreate == phase )
+ val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
+ for (unsigned int loop = 0;
+ loop < sizeof(val->valid)/sizeof(uint8_t); ++loop) {
+ if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop])
+ || cs_status == UNC_CS_APPLIED)
+ val->cs_attr[loop] = cs_status;
+ }
+ return result_code;
+}
+
+/* Pure Virtual functions from VnodeMoMgr */
+upll_rc_t VtepMoMgr::GetControllerDomainId(ConfigKeyVal *ikey,
+ controller_domain *ctrlr_dom) {
+ UPLL_FUNC_TRACE;
+ if (!ikey || !ctrlr_dom) {
+ UPLL_LOG_INFO("Illegal parameter");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val_vtep *temp_vtep = static_cast<val_vtep *>(GetVal(ikey));
+ if (!temp_vtep) {
+ UPLL_LOG_DEBUG("value null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (temp_vtep->valid[UPLL_IDX_CONTROLLER_ID_VTEP] != UNC_VF_VALID
+ || !strlen(reinterpret_cast<char*>(temp_vtep->controller_id))) {
+ ctrlr_dom->ctrlr = NULL;
+ UPLL_LOG_DEBUG("Ctrlr null");
+ } else {
+ SET_USER_DATA_CTRLR(ikey, temp_vtep->controller_id);
+ }
+ if (temp_vtep->valid[UPLL_IDX_DOMAIN_ID_VTEP] != UNC_VF_VALID
+ || !strlen(reinterpret_cast<char*>(temp_vtep->domain_id))) {
+ ctrlr_dom->domain = NULL;
+ UPLL_LOG_DEBUG("Domain null");
+ } else {
+ SET_USER_DATA_DOMAIN(ikey, temp_vtep->domain_id);
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, *ctrlr_dom);
+ }
+ UPLL_LOG_DEBUG("ctrlr_dom %s %s", ctrlr_dom->ctrlr, ctrlr_dom->domain);
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtepMoMgr::GetVnodeName(ConfigKeyVal *ikey, uint8_t *&vtn_name,
+ uint8_t *&vnode_name) {
+ UPLL_FUNC_TRACE;
+ if (ikey == NULL) {
+ UPLL_LOG_DEBUG("ConfigKeyVal is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ key_vtep_t *vtep_key = static_cast<key_vtep_t *>(ikey->get_key());
+ if (vtep_key == NULL) return UPLL_RC_ERR_GENERIC;
+ vtn_name = vtep_key->vtn_key.vtn_name;
+ vnode_name = vtep_key->vtep_name;
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtepMoMgr::ValidateMessage(IpcReqRespHeader *req,
+ ConfigKeyVal *ikey) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t ret_val = UPLL_RC_ERR_GENERIC;
+ if (!ikey || !req || !(ikey->get_key())) {
+ UPLL_LOG_DEBUG("IpcReqRespHeader or ConfigKeyVal is Null");
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ unc_key_type_t keytype = ikey->get_key_type();
+ if (UNC_KT_VTEP != keytype) {
+ UPLL_LOG_DEBUG("Invalid keytype. Keytype- %d", keytype);
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ if (ikey->get_st_num() != IpctSt::kIpcStKeyVtep) {
+ UPLL_LOG_DEBUG("Invalid structure received.Expected struct-kIpcStKeyVtep, "
+ "received struct -%s ", reinterpret_cast<const char *>
+ (IpctSt::GetIpcStdef(ikey->get_st_num())));
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ key_vtep_t *key_vtep = reinterpret_cast<key_vtep_t *>(ikey->get_key());
+ val_vtep_t *val_vtep = NULL;
+ if ((ikey->get_cfg_val()) &&
+ ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVtep)) {
+ val_vtep =
+ reinterpret_cast<val_vtep_t *> (ikey->get_cfg_val()->get_val());
+ }
+ uint32_t dt_type = req->datatype;
+ uint32_t operation = req->operation;
+ uint32_t option1 = req->option1;
+ uint32_t option2 = req->option2;
+ ret_val = ValidateVTepKey(key_vtep, operation);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Syntax check failed for VTEP key structure");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ } else {
+ if (((operation == UNC_OP_CREATE) || (operation == UNC_OP_UPDATE)) &&
+ (dt_type == UPLL_DT_CANDIDATE)) {
+ if (val_vtep != NULL) {
+ ret_val = ValidateVTepValue(val_vtep, operation);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Syntax check failed for VTEP value structure");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_DEBUG("Value structure is mandatory");
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ } else if (((operation == UNC_OP_READ) ||
+ (operation == UNC_OP_READ_SIBLING) ||
+ (operation == UNC_OP_READ_SIBLING_BEGIN) ||
+ (operation == UNC_OP_READ_SIBLING_COUNT))
+ && ((dt_type == UPLL_DT_CANDIDATE) ||
+ (dt_type == UPLL_DT_RUNNING) ||
+ (dt_type == UPLL_DT_STARTUP) ||
+ (dt_type == UPLL_DT_STATE))) {
+ if (option1 == UNC_OPT1_NORMAL) {
+ if (option2 == UNC_OPT2_NONE) {
+ if (val_vtep != NULL) {
+ ret_val = ValidateVTepValue(val_vtep);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Syntax check failed for VTEP value structure");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_TRACE("value structure is an optional for READ op");
+ return UPLL_RC_SUCCESS;
+ }
+ } else {
+ UPLL_LOG_DEBUG("option2 is not matching");
+ return UPLL_RC_ERR_INVALID_OPTION2;
+ }
+ } else {
+ UPLL_LOG_DEBUG("option1 is not matching");
+ return UPLL_RC_ERR_INVALID_OPTION1;
+ }
+ } else if ((operation == UNC_OP_DELETE) ||
+ (((operation == UNC_OP_READ_NEXT) ||
+ (operation == UNC_OP_READ_BULK)) &&
+ ((dt_type == UPLL_DT_CANDIDATE) ||
+ (dt_type == UPLL_DT_RUNNING) ||
+ (dt_type == UPLL_DT_STARTUP)))) {
+ UPLL_LOG_TRACE("Value struct is none for operation type:%d", operation);
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_DEBUG("Invalid datatype(%d) or operation(%d)", dt_type,
+ operation);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+upll_rc_t VtepMoMgr::ValidateVTepValue(val_vtep_t *val_vtep,
+ uint32_t operation) {
+ UPLL_FUNC_TRACE;
+ bool ret_val =false;
+
+ // Attribute syntax validation
+ for (unsigned int valid_index = 0;
+ valid_index < sizeof(val_vtep->valid) / sizeof(val_vtep->valid[0]);
+ valid_index++) {
+ if (val_vtep->valid[valid_index] == UNC_VF_VALID) {
+ switch (valid_index) {
+ case UPLL_IDX_CONTROLLER_ID_VTEP:
+ ret_val = ValidateString(val_vtep->controller_id,
+ kMinLenCtrlrId, kMaxLenCtrlrId);
+ break;
+ case UPLL_IDX_DOMAIN_ID_VTEP:
+ ret_val = ValidateDefaultStr(val_vtep->domain_id,
+ kMinLenDomainId, kMaxLenDomainId);
+ break;
+ case UPLL_IDX_DESC_VTEP:
+ ret_val = ValidateDesc(val_vtep->description,
+ kMinLenDescription, kMaxLenDescription);
+ break;
+ }
+ if (!ret_val) {
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ }
+ }
+
+ // Additional checks
+ for (unsigned int valid_index = 0;
+ valid_index < sizeof(val_vtep->valid) / sizeof(val_vtep->valid[0]);
+ valid_index++) {
+ uint8_t flag = val_vtep->valid[valid_index];
+ switch (operation) {
+ case UNC_OP_CREATE:
+ {
+ switch (valid_index) {
+ case UPLL_IDX_CONTROLLER_ID_VTEP:
+ case UPLL_IDX_DOMAIN_ID_VTEP:
+ if ((flag == UNC_VF_INVALID || flag == UNC_VF_VALID_NO_VALUE)) {
+ UPLL_LOG_DEBUG("controller_id or domain_id flag is invalid"
+ " or valid_no_value");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ break;
+ case UPLL_IDX_DESC_VTEP:
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ case UNC_OP_UPDATE:
+ {
+ switch (valid_index) {
+ case UPLL_IDX_CONTROLLER_ID_VTEP:
+ case UPLL_IDX_DOMAIN_ID_VTEP:
+ if (flag == UNC_VF_VALID_NO_VALUE) {
+ UPLL_LOG_DEBUG("controller_id or domain_id flag is"
+ " valid_no_value");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ break;
+ case UPLL_IDX_DESC_VTEP:
+ default:
+ break;
+ }
+ }
+ break;
+ }
+ }
+
+ // Resets
+ for (unsigned int valid_index = 0;
+ valid_index < sizeof(val_vtep->valid) / sizeof(val_vtep->valid[0]);
+ valid_index++) {
+ uint8_t flag = val_vtep->valid[valid_index];
+ if (flag != UNC_VF_INVALID && flag != UNC_VF_VALID_NO_VALUE)
+ continue;
+
+ switch (valid_index) {
+ case UPLL_IDX_CONTROLLER_ID_VTEP:
+ StringReset(val_vtep->controller_id);
+ break;
+ case UPLL_IDX_DOMAIN_ID_VTEP:
+ StringReset(val_vtep->domain_id);
+ break;
+ case UPLL_IDX_DESC_VTEP:
+ StringReset(val_vtep->description);
+ break;
+ default:
+ UPLL_LOG_TRACE("Never here");
+ break;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtepMoMgr::CtrlrIdAndDomainIdUpdationCheck(ConfigKeyVal *ikey,
+ ConfigKeyVal *okey) {
+ UPLL_FUNC_TRACE;
+ val_vtep *vtep_val = reinterpret_cast<val_vtep *>(GetVal(ikey));
+ val_vtep *vtep_val1 = reinterpret_cast<val_vtep *>(GetVal(okey));
+ if (vtep_val->valid[UPLL_IDX_CONTROLLER_ID_VTEP] == UNC_VF_VALID) {
+ if (strncmp(reinterpret_cast<const char *>(vtep_val->controller_id),
+ reinterpret_cast<const char *>(vtep_val1->controller_id),
+ kMaxLenCtrlrId+1)) {
+ UPLL_LOG_DEBUG("controller id comparision failed");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ }
+ if (vtep_val->valid[UPLL_IDX_DOMAIN_ID_VTEP] == UNC_VF_VALID) {
+ if (strncmp(reinterpret_cast<const char *>(vtep_val->domain_id),
+ reinterpret_cast<const char *>(vtep_val1->domain_id),
+ kMaxLenDomainId+1)) {
+ UPLL_LOG_DEBUG("domain id comparision failed");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+upll_rc_t VtepMoMgr::ValidateVTepKey(key_vtep_t *key_vtep,
+ uint32_t operation) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ ret_val = ValidateKey(
+ reinterpret_cast<char *>(key_vtep->vtn_key.vtn_name),
+ kMinLenVtnName, kMaxLenVtnName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("Vtn Name syntax check failed."
+ "Received VTN Name - %s",
+ key_vtep->vtn_key.vtn_name);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ if ((operation != UNC_OP_READ_SIBLING_BEGIN) &&
+ (operation != UNC_OP_READ_SIBLING_COUNT)) {
+ UPLL_LOG_TRACE("UNC_KT_VTEP: vtep_name (%s)", key_vtep->vtep_name);
+ ret_val = ValidateKey(reinterpret_cast<char *>(key_vtep->vtep_name),
+ kMinLenVnodeName, kMaxLenVnodeName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Syntax check failed.vtep_name-(%s)", key_vtep->vtep_name);
+ return ret_val;
+ }
+ } else {
+ UPLL_LOG_TRACE("Operation is %d", operation);
+ StringReset(key_vtep->vtep_name);
+ }
+ return UPLL_RC_SUCCESS;
+}
+upll_rc_t VtepMoMgr::ValVTepAttributeSupportCheck(val_vtep_t *val_vtep,
+ const uint8_t* attrs, unc_keytype_operation_t operation) {
+ UPLL_FUNC_TRACE;
+ if ((val_vtep->valid[UPLL_IDX_DESC_VTEP] == UNC_VF_VALID)
+ || (val_vtep->valid[UPLL_IDX_DESC_VTEP] == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtep::kCapDesc] == 0) {
+ val_vtep->valid[UPLL_IDX_DESC_VTEP] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("CapDesc is not supported for PFC Controller");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+upll_rc_t VtepMoMgr::ValidateCapability(IpcReqRespHeader *req,
+ ConfigKeyVal *ikey, const char * ctrlr_name) {
+ UPLL_FUNC_TRACE;
+ if (!ikey || !req) {
+ UPLL_LOG_DEBUG("ConfigKeyVal / IpcReqRespHeader is Null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (!ctrlr_name) {
+ ctrlr_name = reinterpret_cast<char*>((reinterpret_cast<key_user_data_t *>
+ (ikey->get_user_data()))->ctrlr_id);
+ if (!ctrlr_name || !strlen(ctrlr_name)) {
+ UPLL_LOG_DEBUG("Controller Name is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ UPLL_LOG_TRACE("ctrlr_name(%s), operation : (%d)",
+ ctrlr_name, req->operation);
+ bool result_code = false;
+ uint32_t max_instance_count = 0;
+ uint32_t max_attrs = 0;
+ const uint8_t *attrs = NULL;
+
+ switch (req->operation) {
+ case UNC_OP_CREATE:
+ result_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_instance_count, &max_attrs, &attrs);
+ if (result_code && (max_instance_count != 0) &&
+ cur_instance_count >= max_instance_count) {
+ UPLL_LOG_DEBUG("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
+ __LINE__, __FUNCTION__, cur_instance_count, max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
+ break;
+
+ case UNC_OP_UPDATE:
+ result_code = GetUpdateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ break;
+
+ case UNC_OP_READ:
+ case UNC_OP_READ_SIBLING:
+ case UNC_OP_READ_SIBLING_BEGIN:
+ case UNC_OP_READ_SIBLING_COUNT:
+ result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ break;
+
+ default:
+ UPLL_LOG_DEBUG("Invalid operation");
+ break;
+ }
+ if (!result_code) {
+ UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s) "
+ "for operation(%d)",
+ ikey->get_key_type(), ctrlr_name, req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ val_vtep_t *val_vtep = NULL;
+ if ((ikey->get_cfg_val()) &&
+ ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVtep)) {
+ val_vtep =
+ reinterpret_cast<val_vtep_t *>(ikey->get_cfg_val()->get_val());
+ }
+ if (val_vtep) {
+ if (max_attrs > 0) {
+ return ValVTepAttributeSupportCheck(val_vtep, attrs, req->operation);
+ } else {
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d",
+ req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtepMoMgr::CreateVnodeConfigKey(ConfigKeyVal *ikey,
+ ConfigKeyVal *&okey) {
+ UPLL_FUNC_TRACE;
+ if (ikey == NULL)
+ return UPLL_RC_ERR_GENERIC;
+ key_vtep *temp_key_vtep = static_cast<key_vtep *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtep)));
+ uuu::upll_strncpy(temp_key_vtep->vtn_key.vtn_name,
+ static_cast<key_vtep *>(ikey->get_key())->vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ uuu::upll_strncpy(temp_key_vtep->vtep_name,
+ static_cast<key_vtep *>(ikey->get_key())->vtep_name,
+ (kMaxLenVnodeName+1));
+
+ okey = new ConfigKeyVal(UNC_KT_VTEP, IpctSt::kIpcStKeyVtep,
+ reinterpret_cast<void *>(temp_key_vtep), NULL);
+ return UPLL_RC_SUCCESS;
+}
+/*
+ upll_rc_t VtepMoMgr::CopyToConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *ikey) {
+ UPLL_FUNC_TRACE;
+ if (!ikey || !(ikey->get_key()))
+ return UPLL_RC_ERR_GENERIC;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+
+ key_rename_vnode_info *key_rename = (key_rename_vnode_info *)ikey->get_key();
+ key_vtep_t * vtep_key = (key_vtep_t *) malloc ( sizeof (key_vtep_t));
+ if (!vtep_key)
+ return UPLL_RC_ERR_GENERIC;
+ if (!strlen ((char *)key_rename->old_unc_vtn_name))
+ return UPLL_RC_ERR_GENERIC;
+ strcpy ((char *)vtep_key ->vtn_key.vtn_name, (char *)key_rename->old_unc_vtn_name);
+
+ okey = new ConfigKeyVal (UNC_KT_VTEP, IpctSt::kIpcStKeyVtep, vtep_key, NULL);
+ if (!okey) {
+ FREE_IF_NOT_NULL(vtep_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ return result_code;
+ }
+ */
+upll_rc_t VtepMoMgr::CreateVtepGrpConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *ikey) {
+ UPLL_FUNC_TRACE;
+ key_vtep_grp_member_t *vtep_grp_mem_key = static_cast<key_vtep_grp_member_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtep_grp_member_t)));
+ key_vtep *vtep_key = static_cast<key_vtep *>(ikey->get_key());
+ if (!vtep_grp_mem_key)
+ return UPLL_RC_ERR_GENERIC;
+ if (!strlen(reinterpret_cast<char *>(vtep_key->vtn_key.vtn_name))) {
+ FREE_IF_NOT_NULL(vtep_grp_mem_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(vtep_grp_mem_key->vtepgrp_key.vtn_key.vtn_name,
+ reinterpret_cast<char *>(vtep_key->vtn_key.vtn_name),
+ (kMaxLenVtnName+1));
+ if (!strlen(reinterpret_cast<char *>(vtep_key->vtep_name))) {
+ FREE_IF_NOT_NULL(vtep_grp_mem_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(vtep_grp_mem_key->vtepmember_name,
+ reinterpret_cast<char *>(vtep_key->vtep_name),
+ (kMaxLenVnodeName+1));
+ okey = new ConfigKeyVal(UNC_KT_VTEP_GRP_MEMBER,
+ IpctSt::kIpcStKeyVtepGrpMember, vtep_grp_mem_key, NULL);
+ if (!okey) {
+ FREE_IF_NOT_NULL(vtep_grp_mem_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+
+upll_rc_t VtepMoMgr::IsReferenced(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *okey = NULL;
+ if (!ikey || !(ikey->get_key()) || !dmi)
+ return UPLL_RC_ERR_GENERIC;
+ MoMgrImpl *mgr1 = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>
+ (GetMoManager(UNC_KT_VTEP_IF)));
+ if (!mgr1) return UPLL_RC_ERR_GENERIC;
+ result_code = mgr1->IsReferenced(ikey, dt_type, dmi);
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
+ UPLL_RC_SUCCESS:result_code;
+ UPLL_LOG_DEBUG("Interface IsReferenced returned: (%d)", result_code);
+ if (UPLL_RC_SUCCESS != result_code)
+ return result_code;
+ result_code = CreateVtepGrpConfigKey(okey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ return result_code;
+ }
+ MoMgrImpl *mgr2 = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>
+ (GetMoManager(UNC_KT_VTEP_GRP_MEMBER)));
+ if (!mgr2) {
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = mgr2->UpdateConfigDB(okey, dt_type, UNC_OP_READ, dmi, MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code)
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
+ UPLL_RC_SUCCESS:result_code;
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+}
+
+/*
+ upll_rc_t VtepMoMgr::MergeValidate(unc_key_type_t keytype, const char *ctrlr_id,
+ ConfigKeyVal *ikey, DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutNone};
+ if (!ikey || !(ikey->get_key()) || !dmi
+ || !(strlen((char*)ctrlr_id)))
+ return UPLL_RC_ERR_GENERIC;
+ * Here getting FULL Key (VTN & VBR Name )
+
+ result_code = ReadConfigDB(ikey, UPLL_DT_IMPORT, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if(UPLL_RC_SUCCESS != result_code)
+ return result_code;
+ checks the vnode name present in the running vnode under the
+ * same vtn
+
+ while (!ikey) {
+ Same Name should not present in the vnodes in running
+ result_code = VnodeChecks(ikey, UPLL_DT_RUNNING, dmi);
+
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code )
+ return UPLL_RC_ERR_MERGE_CONFLICT;
+ Any other DB error
+ if ( UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ return result_code;
+ }
+
+
+ ikey = ikey->get_next_cfg_key_val();
+ }
+
+ return result_code;
+ }
+ */
+
+} // namespace vtn
+} // namespace upll
+} // namespace unc
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 NEC Corporation
+ * All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+#ifndef UNC_UPLL_VTEP_MOMGR_H
+#define UNC_UPLL_VTEP_MOMGR_H
+
+#include "vnode_momgr.hh"
+#include "vtn_momgr.hh"
+
+namespace unc {
+namespace upll {
+namespace kt_momgr {
+
+
+enum VtepMoMgrTables {
+ VTEPTBL = 0,
+ NVTEPTABLES
+};
+
+
+class VtepMoMgr : public VnodeMoMgr {
+ private:
+ static unc_key_type_t vtep_child[];
+ static BindInfo vtep_bind_info[];
+ /**
+ * @brief Gets the valid array position of the variable in the value
+ * structure from the table in the specified configuration
+ *
+ * @param[in] val pointer to the value structure
+ * @param[in] indx database index for the variable
+ * @param[out] valid position of the variable in the valid array -
+ * NULL if valid does not exist.
+ * @param[in] dt_type specifies the configuration
+ * @param[in] tbl specifies the table containing the given value
+ *
+ **/
+ upll_rc_t GetValid(void *val,
+ uint64_t indx,
+ uint8_t *&valid,
+ upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl) {
+ UPLL_FUNC_TRACE;
+ if (val == NULL) return UPLL_RC_ERR_GENERIC;
+ if (tbl == MAINTBL) {
+ switch (indx) {
+ case uudst::vtep::kDbiOperStatus:
+ valid = &(reinterpret_cast<val_db_vtep_st *>(val)->
+ vtep_val_st.valid[UPLL_IDX_OPER_STATUS_VTEPS]);
+ break;
+ case uudst::vtep::kDbiDownCount:
+ valid = NULL;
+ break;
+ case uudst::vtep::kDbiDesc:
+ valid = &(reinterpret_cast<val_vtep *>(val)->
+ valid[UPLL_IDX_DESC_VTEP]);
+ break;
+ case uudst::vtep::kDbiCtrlrName:
+ valid = &(reinterpret_cast<val_vtep *>(val)->
+ valid[UPLL_IDX_CONTROLLER_ID_VTEP]);
+ break;
+ case uudst::vtep::kDbiDomainId:
+ valid = &(reinterpret_cast<val_vtep *>(val)->
+ valid[UPLL_IDX_DOMAIN_ID_VTEP]);
+ break;
+ default:
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+ }
+ upll_rc_t UpdateConfigStatus(ConfigKeyVal *vtep_key,
+ unc_keytype_operation_t op,
+ uint32_t result,
+ ConfigKeyVal *upd_key,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ctrlr_key = NULL);
+
+ /**
+ * @brief Update config status for commit result and vote result.
+ *
+ * @param[in/out] ckv_running ConfigKeyVal instance.
+ * @param[in] cs_status either UNC_CS_INVALID or UNC_CS_APPLIED.
+ * @param[in] phase specify the phase (CREATE,DELETE or UPDATE)
+ *
+ **/
+ upll_rc_t UpdateAuditConfigStatus(unc_keytype_configstatus_t cs_status,
+ uuc::UpdateCtrlrPhase phase,
+ ConfigKeyVal *&ckv_running);
+
+ /**
+ * @brief Duplicates the input configkeyval including the key and val.
+ * based on the tbl specified.
+ *
+ * @param[in] okey Output Configkeyval - allocated within the function
+ * @param[in] req Input ConfigKeyVal to be duplicated.
+ * @param[in] tbl specifies if the val structure belongs to the main table/ controller table or rename table.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ upll_rc_t DupConfigKeyVal(ConfigKeyVal *&okey,
+ ConfigKeyVal *&req, MoMgrTables tbl = MAINTBL);
+ /**
+ * @brief Allocates for the specified val in the given configuration in the * specified table.
+ *
+ * @param[in/out] ck_val Reference pointer to configval structure
+ * allocated.
+ * @param[in] dt_type specifies the configuration candidate/running/
+ * state
+ * @param[in] tbl specifies if the corresponding table is the
+ * main table / controller table or rename table.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ upll_rc_t AllocVal(ConfigVal *&ck_val, upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl = MAINTBL);
+/**
+ * @brief Method to get a configkeyval of a specified keytype from an input configkeyval
+ *
+ * @param[in/out] okey pointer to output ConfigKeyVal
+ * @param[in] parent_key pointer to the configkeyval from which the output configkey val is initialized.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ */
+ upll_rc_t GetChildConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *parent_key);
+ upll_rc_t GetRenamedControllerKey(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
+ uint8_t *ctrlr_name ) {
+ return UPLL_RC_SUCCESS;
+ }
+ upll_rc_t GetRenamedUncKey(ConfigKeyVal *ctrlr_key,
+ upll_keytype_datatype_t dt_type, DalDmlIntf *dmi, uint8_t *ctrlr_id) {
+ return UPLL_RC_SUCCESS;
+ }
+
+ /* Pure virtual from VnodeMoMgr */
+ upll_rc_t GetControllerDomainId(ConfigKeyVal *ikey,
+ controller_domain *ctrlr_dom);
+ upll_rc_t GetVnodeName(ConfigKeyVal *ikey,
+ uint8_t *&vtn_name, uint8_t *&vnode_name);
+
+ /**
+ * @brief Filters the attributes which need not be sent to controller
+ *
+ * @param[in/out] val1 first record value instance.
+ * @param[in] val2 second record value instance.
+ * @param[in] audit Not used for VTN
+ * @param[in] op Operation to be performed
+ *
+ **/
+ bool FilterAttributes(void *&val1, void *val2, bool copy_to_running,
+ unc_keytype_operation_t op);
+
+ /**
+ * @brief Compares the valid value between two database records.
+ * if both the values are same, update the valid flag for corresponding
+ * attribute as invalid in the first record.
+ *
+ * @param[in/out] val1 first record value instance.
+ * @param[in] val2 second record value instance.
+ * @param[in] audit if true, CompareValidValue called from audit process.
+ *
+ **/
+ bool CompareValidValue(void *&val1, void *val2, bool copy_to_running);
+ /**
+ * @Brief Validates the syntax of the specified key and value structure
+ * for KT_VTEP keytype
+ *
+ * @param[in] req This structure contains
+ * IpcReqRespHeader(first 8 fields of input request structure).
+ * @param[in] ikey ikey contains key and value structure.
+ *
+ * @retval UPLL_RC_SUCCESS Successful.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX Syntax error.
+ * @retval UPLL_RC_ERR_NO_SUCH_INSTANCE key struct is not available.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ * @retval UPLL_RC_ERR_INVALID_OPTION1 option1 is not valid.
+ * @retval UPLL_RC_ERR_INVALID_OPTION2 option2 is not valid.
+ */
+ upll_rc_t ValidateMessage(IpcReqRespHeader *req, ConfigKeyVal *ikey);
+ /**
+ * @Brief Validates the syntax for KT_VTEP keytype value structure.
+ *
+ * @param[in] val_vtep KT_VTEP value structure.
+ *
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ * @retval UPLL_RC_SUCCESS validation succeeded.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX validation failed.
+ */
+ upll_rc_t ValidateVTepValue(val_vtep_t *val_vtep, uint32_t operation =
+ UNC_OP_INVALID);
+ /**
+ * @Brief Checks if the specified key type(KT_VTEP) and
+ * associated attributes are supported on the given controller,
+ * based on the valid flag
+ *
+ * @param[in] req This structure contains
+ * IpcReqRespHeader(first 8 fields of input request structure).
+ * @param[in] ikey ikey contains key and value structure.
+ * @param[in] crtlr_name Controller name.
+ *
+ * @retval UPLL_RC_SUCCESS Validation succeeded.
+ * @retval UPLL_RC_ERR_GENERIC Validation failure.
+ * @retval UPLL_RC_ERR_INVALID_OPTION1 Option1 is not valid.
+ * @retval UPLL_RC_ERR_INVALID_OPTION2 Option2 is not valid.
+ */
+
+ upll_rc_t ValidateCapability(IpcReqRespHeader *req, ConfigKeyVal *ikey,
+ const char * crtlr_name);
+ /**
+ * @Brief Checks if the specified key type and
+ * associated attributes are supported on the given controller,
+ * based on the valid flag.
+ *
+ * @param[in] val_vtep Value Structure.
+ * @param[in] attr pointer to controller attribute
+ * @param[in] operation Operation Name
+ *
+ * @retval UPLL_RC_SUCCESS validation succeeded.
+ * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ */
+ upll_rc_t ValVTepAttributeSupportCheck(
+ val_vtep_t *val_vtep,
+ const uint8_t* attrs, unc_keytype_operation_t operation);
+ bool GetRenameKeyBindInfo(unc_key_type_t key_type, BindInfo *&binfo,
+ int &nattr,
+ MoMgrTables tbl) {
+ return true;
+ }
+ /**
+ * @Brief Copy the keys for populating Rename structure.
+ * Not applicable for Overlay Keytypes
+ *
+ */
+ upll_rc_t CopyToConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *ikey) {
+ return UPLL_RC_SUCCESS;
+ }
+
+ upll_rc_t IsReferenced(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type, DalDmlIntf *dmi);
+
+ public:
+ VtepMoMgr();
+ virtual ~VtepMoMgr() {
+ for (int i = VTEPTBL; i < NVTEPTABLES; i++)
+ if (table[i]) {
+ delete table[i];
+ }
+ delete[] table;
+ }
+ /**
+ * @Brief compares controller id and domain id before
+ * updating the value to DB.
+ *
+ * @param[in] ikey ikey contains key and value structure.
+ * @param[in] okey okey contains key and value structure.
+ *
+ * @retval UPLL_RC_SUCCESS Successful.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX Syntax error.
+ */
+ upll_rc_t CtrlrIdAndDomainIdUpdationCheck(ConfigKeyVal *ikey,
+ ConfigKeyVal *okey);
+ /**
+ * @brief Method to check if individual portions of a key are valid
+ *
+ * @param[in/out] ikey pointer to ConfigKeyVal referring to a UNC resource
+ * @param[in] index db index associated with the variable
+ *
+ * @retval true input key is valid
+ * @retval false input key is invalid.
+ **/
+ bool IsValidKey(void *tkey, uint64_t index);
+ /**
+ * @Brief Validates the syntax for KT_VTEP keytype key structure.
+ *
+ * @param[in] key_vtep KT_VTEP key structure.
+ *
+ * @retval UPLL_RC_SUCCESS validation succeeded.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX validation failed.
+ */
+ upll_rc_t ValidateVTepKey(key_vtep_t *key_vtep,
+ uint32_t operation);
+
+ /**
+ * @brief Creates Vnode MoMgr specific key
+ *
+ * @param[in] ikey ConfigKeyVal pointer
+ * @param[in/out] iokey ConfigKeyVal pointer
+ *
+ * @retval UPLL_RC_ERR_GENERIC generic error
+ * @retval UPLL_RC_SUCCESS Successful
+ */
+ upll_rc_t CreateVnodeConfigKey(ConfigKeyVal *ikey, ConfigKeyVal *&okey);
+
+/**
+ * @brief Method to get a configkeyval of the parent keytype
+ *
+ * @param[in/out] okey pointer to parent ConfigKeyVal
+ * @param[in] ikey pointer to the child configkeyval from
+ * which the parent configkey val is obtained.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ upll_rc_t GetParentConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *ikey);
+
+ /* @brief This method invoke when the VTEP Delete operation
+ * thie function creates the configkey for vtepgrpmember
+ *
+ *
+ * @param[in/out] okey key and value structure
+ * @param[in] ikey key and value structure
+ *
+ * @retval UPLL_RC_SUCCESS Completed successfully.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ * @retval UPLL_RC_ERR_RESOURCE_DISCONNECTED Resource disconnected.
+ * @retval UPLL_RC_ERR_DB_ACCESS DB Read/Write error.
+ * @retval UPLL_RC_ERR_SEMANTIC Semantic check error.
+ * @retval UPLL_RC_ERR_NO_SUCH_INSTANCE Given key does not exist
+ *
+ **/
+ upll_rc_t CreateVtepGrpConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *ikey);
+ /* @brief This method invoke when the VTN merge hapeening between
+ * Running and DT import. This will checks the vnode name
+ * unique or not.
+ *
+ * @param[in] keytype UNC KEY TYPE
+ * @param[in/out] ctrlr_id Controller ID
+ * @param[in] conflict_ckv key and value structure
+ * @param[in] dal Pointer to the DalDmlIntf(DB Interface)
+ *
+ * @retval UPLL_RC_SUCCESS Completed successfully.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ * @retval UPLL_RC_ERR_RESOURCE_DISCONNECTED Resource disconnected.
+ * @retval UPLL_RC_ERR_DB_ACCESS DB Read/Write error.
+ * @retval UPLL_RC_ERR_MERGE_CONFLICT Semantic check error.
+ * @retval UPLL_RC_ERR_NO_SUCH_INSTANCE Given key does not exist
+ *
+ **/
+ upll_rc_t MergeValidate(unc_key_type_t keytype, const char *ctrlr_id,
+ ConfigKeyVal *ikey, DalDmlIntf *dmi) {
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ }
+};
+
+
+
+
+} // namespace vtn
+} // namespace upll
+} // namespace unc
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 NEC Corporation
+ * All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+#include "vtepgrp_mem_momgr.hh"
+namespace unc {
+namespace upll {
+namespace kt_momgr {
+
+BindInfo VtepGrpMemMoMgr::vtepgrp_mem_bind_info[] = {
+ { uudst::vtep_groupmember::kDbiVtnName, CFG_KEY, offsetof
+ (key_vtep_grp_member, vtepgrp_key.vtn_key.vtn_name),
+ uud::kDalChar, kMaxLenVtnName+1 },
+ { uudst::vtep_groupmember::kDbiVtepgrpName, CFG_KEY, offsetof
+ (key_vtep_grp_member, vtepgrp_key.vtepgrp_name),
+ uud::kDalChar, kMaxLenVnodeName+1 },
+ { uudst::vtep_groupmember::kDbiVtepgrpMemberName, CFG_KEY,
+ offsetof(key_vtep_grp_member, vtepmember_name),
+ uud::kDalChar, kMaxLenVnodeName+1 },
+ { uudst::vtep_groupmember::kDbiCtrlrName, CK_VAL, offsetof
+ (key_user_data_t, ctrlr_id), uud::kDalChar, kMaxLenCtrlrId+1},
+ { uudst::vtep_groupmember::kDbiDomainId, CK_VAL, offsetof
+ (key_user_data_t, domain_id), uud::kDalChar, kMaxLenDomainId+1},
+ { uudst::vtep_groupmember::kDbiFlags, CK_VAL, offsetof
+ (key_user_data_t, flags), uud::kDalUint8, 1},
+ { uudst::vtep_groupmember::kDbiCsRowstatus, CS_VAL, offsetof(
+ val_vtep_grp_member, cs_row_status), uud::kDalUint8, 1}
+};
+
+
+VtepGrpMemMoMgr::VtepGrpMemMoMgr() {
+ UPLL_FUNC_TRACE;
+ Table *tbl = new Table(uudst::kDbiVtepGrpMemTbl, UNC_KT_VTEP_GRP_MEMBER,
+ vtepgrp_mem_bind_info, IpctSt::kIpcStKeyVtepGrpMember,
+ IpctSt::kIpcStValVtepGrpMember,
+ uudst::vtep_groupmember::kDbiVtepGrpMemNumCols);
+ ntable = MAX_MOMGR_TBLS;
+ table = new Table *[ntable];
+ table[MAINTBL] = tbl;
+ table[RENAMETBL] = NULL;
+ table[CTRLRTBL] = NULL;
+ nchild = 0;
+ child = NULL;
+#ifdef _STANDALONE_
+ SetMoManager(UNC_KT_VTEP_GRP_MEMBER, reinterpret_cast<MoMgr *>(this));
+#endif
+}
+
+/*
+ * Based on the key type the bind info will pass
+ *
+ bool VtepGrpMemMoMgr::GetRenameKeyBindInfo(unc_key_type_t key_type, BindInfo *&binfo, int &nattr,
+ MoMgrTables tbl ) {
+ if (MAINTBL == tbl) {
+
+ nattr = NUM_KEY_MAIN_TBL_;
+ binfo = key_vtepgrp_mem_maintbl_update_bind_info;
+ }
+ return PFC_TRUE;
+ }*/
+
+bool VtepGrpMemMoMgr::IsValidKey(void *key, uint64_t index) {
+ UPLL_FUNC_TRACE;
+ key_vtep_grp_member *vtep_grp_mem_key = reinterpret_cast
+ <key_vtep_grp_member *>(key);
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ switch (index) {
+ case uudst::vtep_groupmember::kDbiVtnName:
+ ret_val = ValidateKey(reinterpret_cast<char *>
+ (vtep_grp_mem_key->vtepgrp_key.vtn_key.vtn_name),
+ kMinLenVtnName, kMaxLenVtnName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("VTN Name is not valid(%d)", ret_val);
+ return false;
+ }
+ break;
+ case uudst::vtep_groupmember::kDbiVtepgrpName:
+ ret_val = ValidateKey(reinterpret_cast<char *>
+ (vtep_grp_mem_key->vtepgrp_key.vtepgrp_name),
+ kMinLenVnodeName, kMaxLenVnodeName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("VtepGroup Name is not valid(%d)", ret_val);
+ return false;
+ }
+ break;
+ case uudst::vtep_groupmember::kDbiVtepgrpMemberName:
+ ret_val = ValidateKey(reinterpret_cast<char *>
+ (vtep_grp_mem_key->vtepmember_name),
+ kMinLenVnodeName, kMaxLenVnodeName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("VtepGroup Name is not valid(%d)", ret_val);
+ return false;
+ }
+ break;
+ default:
+ UPLL_LOG_TRACE("Invalid Key Index");
+ return false;
+ }
+ return true;
+}
+
+upll_rc_t VtepGrpMemMoMgr::GetChildConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *parent_key) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ void *pkey;
+ key_vtep_grp_member *vtep_key = static_cast<key_vtep_grp_member *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtep_grp_member)));
+ if (vtep_key == NULL) return UPLL_RC_ERR_GENERIC;
+ if (parent_key == NULL) {
+ okey = new ConfigKeyVal(UNC_KT_VTEP_GRP_MEMBER,
+ IpctSt::kIpcStKeyVtepGrpMember,
+ vtep_key, NULL);
+ return UPLL_RC_SUCCESS;
+ } else {
+ pkey = parent_key->get_key();
+ }
+ if (!pkey) {
+ free(vtep_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (okey && (okey->get_key())) {
+ free(vtep_key);
+ vtep_key = reinterpret_cast<key_vtep_grp_member *>(okey->get_key());
+ } else {
+ okey = new ConfigKeyVal(UNC_KT_VTEP_GRP_MEMBER,
+ IpctSt::kIpcStKeyVtepGrpMember,
+ vtep_key, NULL);
+ if (okey == NULL) {
+ free(vtep_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ /* presumes MoMgrs receive only supported keytypes */
+ switch (parent_key->get_key_type()) {
+ case UNC_KT_VTEP_GRP_MEMBER:
+ uuu::upll_strncpy(vtep_key->vtepmember_name,
+ reinterpret_cast<key_vtep_grp_member *>(pkey)->vtepmember_name,
+ (kMaxLenVnodeName+1));
+ /* fall through intended */
+ case UNC_KT_VTEP_GRP:
+ uuu::upll_strncpy(vtep_key->vtepgrp_key.vtepgrp_name,
+ reinterpret_cast<key_vtep_grp *>(pkey)->vtepgrp_name,
+ (kMaxLenVnodeName+1));
+ uuu::upll_strncpy(vtep_key->vtepgrp_key.vtn_key.vtn_name,
+ reinterpret_cast<key_vtep_grp *>(pkey)->vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ break;
+ case UNC_KT_VTN:
+ default:
+ uuu::upll_strncpy(vtep_key->vtepgrp_key.vtn_key.vtn_name,
+ reinterpret_cast<key_vtn *>(pkey)->vtn_name, (kMaxLenVtnName+1));
+ }
+ SET_USER_DATA(okey, parent_key);
+ return result_code;
+}
+
+upll_rc_t VtepGrpMemMoMgr::GetParentConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *ikey ) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ key_vtep_grp_member *pkey = (ikey)?
+ static_cast<key_vtep_grp_member *>(ikey->get_key()):NULL;
+ if (!pkey) return UPLL_RC_ERR_GENERIC;
+ if (ikey->get_key_type() != UNC_KT_VTEP_GRP_MEMBER)
+ return UPLL_RC_ERR_GENERIC;
+ key_vtep_grp *vtepgrp_key = reinterpret_cast<key_vtep_grp *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtep_grp)));
+ uuu::upll_strncpy(vtepgrp_key->vtn_key.vtn_name,
+ reinterpret_cast<key_vtep_grp_member *>(pkey)->
+ vtepgrp_key.vtn_key.vtn_name, (kMaxLenVtnName+1));
+ uuu::upll_strncpy(vtepgrp_key->vtepgrp_name,
+ reinterpret_cast<key_vtep_grp_member *>(pkey)->
+ vtepgrp_key.vtepgrp_name, (kMaxLenVnodeName+1));
+ DELETE_IF_NOT_NULL(okey);
+ okey = new ConfigKeyVal(UNC_KT_VTEP_GRP, IpctSt::kIpcStKeyVtepGrp,
+ vtepgrp_key, NULL);
+ if (okey == NULL) {
+ free(vtepgrp_key);
+ result_code = UPLL_RC_ERR_GENERIC;
+ } else {
+ SET_USER_DATA(okey, ikey);
+ }
+ return result_code;
+}
+
+
+upll_rc_t VtepGrpMemMoMgr::AllocVal(ConfigVal *&ck_val,
+ upll_keytype_datatype_t dt_type, MoMgrTables tbl) {
+ UPLL_FUNC_TRACE;
+ void *val;
+ if (ck_val != NULL) return UPLL_RC_ERR_GENERIC;
+ switch (tbl) {
+ case MAINTBL:
+ val = reinterpret_cast<void *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtep_grp_member)));
+ if (!val) return UPLL_RC_ERR_GENERIC;
+ ck_val = new ConfigVal(IpctSt::kIpcStValVtepGrpMember, val);
+ if (!ck_val) {
+ free(reinterpret_cast<val_vtep_grp_member *>(val));
+ return UPLL_RC_ERR_GENERIC;
+ }
+ break;
+ default:
+ val = NULL;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtepGrpMemMoMgr::DupConfigKeyVal(ConfigKeyVal *&okey,
+ ConfigKeyVal *&req, MoMgrTables tbl) {
+ UPLL_FUNC_TRACE;
+ if (req == NULL) return UPLL_RC_ERR_GENERIC;
+ if (okey != NULL) return UPLL_RC_ERR_GENERIC;
+ if (req->get_key_type() != UNC_KT_VTEP_GRP_MEMBER)
+ return UPLL_RC_ERR_GENERIC;
+ ConfigVal *tmp1 = NULL, *tmp = (req)->get_cfg_val();
+ if (tmp) {
+ if (tbl == MAINTBL) {
+ val_vtep_grp_member *ival = reinterpret_cast
+ <val_vtep_grp_member *>(GetVal(req));
+ val_vtep_grp_member *vtep_val = reinterpret_cast<val_vtep_grp_member *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtep_grp_member)));
+ if (!vtep_val) return UPLL_RC_ERR_GENERIC;
+ memcpy(vtep_val, ival, sizeof(val_vtep_grp_member));
+ tmp1 = new ConfigVal(IpctSt::kIpcStValVtepGrpMember, vtep_val);
+ if (!tmp1) {
+ free(vtep_val);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ };
+ void *tkey = (req != NULL)?(req)->get_key():NULL;
+ key_vtep_grp_member *ikey = reinterpret_cast<key_vtep_grp_member *>(tkey);
+ key_vtep_grp_member *vtep_key = reinterpret_cast<key_vtep_grp_member *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtep_grp_member)));
+ if (!vtep_key) {
+ if (tmp1) delete tmp1;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ memcpy(vtep_key, ikey, sizeof(key_vtep_grp_member));
+ okey = new ConfigKeyVal(UNC_KT_VTEP_GRP_MEMBER,
+ IpctSt::kIpcStKeyVtepGrpMember,
+ vtep_key, tmp1);
+ if (okey) {
+ SET_USER_DATA(okey, req);
+ } else {
+ if (tmp1) delete tmp1;
+ free(vtep_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtepGrpMemMoMgr::UpdateConfigStatus(ConfigKeyVal *vtepgrpmem_key,
+ unc_keytype_operation_t op,
+ uint32_t driver_result,
+ ConfigKeyVal *upd_key,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ctrlr_key) {
+ UPLL_FUNC_TRACE;
+ val_vtep_grp_member *vtep_grp_member_val;
+ unc_keytype_configstatus_t cs_status =
+ (driver_result == UPLL_RC_SUCCESS)?UNC_CS_APPLIED
+ :UNC_CS_NOT_APPLIED;
+ vtep_grp_member_val = reinterpret_cast<val_vtep_grp_member *>
+ (GetVal(vtepgrpmem_key));
+ if (vtep_grp_member_val == NULL) return UPLL_RC_ERR_GENERIC;
+ if (op == UNC_OP_CREATE) {
+ vtep_grp_member_val->cs_row_status = cs_status;
+ } else if (op == UNC_OP_UPDATE) {
+ val_vtep_grp_member *grp_mem_val_run =
+ reinterpret_cast<val_vtep_grp_member *>
+ (GetVal(upd_key));
+ UPLL_LOG_TRACE("%s", (upd_key->ToStrAll()).c_str());
+ vtep_grp_member_val->cs_row_status =
+ grp_mem_val_run->cs_row_status;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtepGrpMemMoMgr::UpdateAuditConfigStatus(
+ unc_keytype_configstatus_t cs_status,
+ uuc::UpdateCtrlrPhase phase,
+ ConfigKeyVal *&ckv_running) {
+ UPLL_FUNC_TRACE;
+ val_vtep_grp_member_t *vtepgrpmem_val = (ckv_running != NULL)?
+ reinterpret_cast<val_vtep_grp_member_t *>
+ (GetVal(ckv_running)):NULL;
+ if (NULL == vtepgrpmem_val) {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (uuc::kUpllUcpCreate == phase )
+ vtepgrpmem_val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (vtepgrpmem_val->cs_row_status == UNC_CS_INVALID ||
+ vtepgrpmem_val->cs_row_status == UNC_CS_NOT_APPLIED))
+ vtepgrpmem_val->cs_row_status = cs_status;
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtepGrpMemMoMgr::ValidateMessage(IpcReqRespHeader *req,
+ ConfigKeyVal *ikey) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t ret_val = UPLL_RC_ERR_GENERIC;
+ if (!ikey || !req || !(ikey->get_key())) {
+ UPLL_LOG_DEBUG("IpcReqRespHeader or ConfigKeyVal is Null");
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ unc_key_type_t keytype = ikey->get_key_type();
+ if (UNC_KT_VTEP_GRP_MEMBER != keytype) {
+ UPLL_LOG_DEBUG("Invalid keytype. Keytype- %d", keytype);
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ upll_keytype_datatype_t dt_type = req->datatype;
+ unc_keytype_operation_t operation = req->operation;
+ unc_keytype_option1_t option1 = req->option1;
+ unc_keytype_option2_t option2 = req->option2;
+
+ if (ikey->get_st_num() != IpctSt::kIpcStKeyVtepGrpMember) {
+ UPLL_LOG_DEBUG("Invalid structure received.Expected struct-"
+ "kIpcStKeyVtepGrpMember, received struct -%s ",
+ reinterpret_cast<const char *>
+ (IpctSt::GetIpcStdef(ikey->get_st_num())));
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ key_vtep_grp_member_t *key_vtep_grp_member =
+ reinterpret_cast <key_vtep_grp_member_t *> (ikey->get_key());
+
+ ret_val = ValidateVTepGrpMemberKey(key_vtep_grp_member, operation);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("Key struct Validation failed for VTEP_GRP_MEMBER");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ } else {
+ if (((operation == UNC_OP_CREATE) || (operation == UNC_OP_UPDATE) ||
+ (operation == UNC_OP_DELETE)) &&
+ (dt_type == UPLL_DT_CANDIDATE)) {
+ UPLL_LOG_TRACE("Value structure validation is none");
+ return UPLL_RC_SUCCESS;
+ } else if (((operation == UNC_OP_READ) ||
+ (operation == UNC_OP_READ_SIBLING) ||
+ (operation == UNC_OP_READ_SIBLING_BEGIN) ||
+ (operation == UNC_OP_READ_SIBLING_COUNT) ||
+ (operation == UNC_OP_READ_NEXT) ||
+ (operation == UNC_OP_READ_BULK))
+ && ((dt_type == UPLL_DT_CANDIDATE) ||
+ (dt_type == UPLL_DT_RUNNING) ||
+ (dt_type == UPLL_DT_STARTUP) ||
+ (dt_type == UPLL_DT_STATE))) {
+ if (option1 == UNC_OPT1_NORMAL) {
+ if (option2 == UNC_OPT2_NONE) {
+ UPLL_LOG_TRACE("Value structure validation is none");
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_DEBUG("option2 is not matching");
+ return UPLL_RC_ERR_INVALID_OPTION2;
+ }
+ } else {
+ UPLL_LOG_DEBUG("option1 is not matching");
+ return UPLL_RC_ERR_INVALID_OPTION1;
+ }
+ } else {
+ UPLL_LOG_DEBUG("Invalid datatype(%d) and operation(%d)", dt_type,
+ operation);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtepGrpMemMoMgr::ValidateAttribute(ConfigKeyVal *kval,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ ConfigKeyVal *ck_vtep = NULL;
+ upll_rc_t result_code = GetVtepConfigValData(kval, ck_vtep,
+ UPLL_DT_CANDIDATE, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error in fetching the Vtep data from DB %d",
+ result_code);
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
+ UPLL_RC_ERR_CFG_SEMANTIC:result_code;
+ }
+ DELETE_IF_NOT_NULL(ck_vtep);
+ return result_code;
+}
+
+upll_rc_t VtepGrpMemMoMgr::ValidateCapability(
+ IpcReqRespHeader *req,
+ ConfigKeyVal *ikey,
+ const char *ctrlr_name) {
+ UPLL_FUNC_TRACE;
+ bool result_code = false;
+ uint32_t max_attrs = 0;
+ uint32_t max_instance_count = 0;
+ const uint8_t *attrs = NULL;
+
+ if (!ikey || !req) {
+ UPLL_LOG_DEBUG("IpcReqRespHeader or ConfigKeyVal is Null");
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ if (ikey->get_key_type() != UNC_KT_VTEP_GRP_MEMBER) {
+ UPLL_LOG_DEBUG("Invalid keytype. Keytype- %d", ikey->get_key_type());
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+
+ if (!ctrlr_name) {
+ ctrlr_name = reinterpret_cast<char*>((reinterpret_cast<key_user_data_t *>
+ (ikey->get_user_data()))->ctrlr_id);
+ if (!ctrlr_name || !strlen(ctrlr_name)) {
+ UPLL_LOG_DEBUG("Controller Name is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+
+ uint32_t dt_type = req->datatype;
+ uint32_t operation = req->operation;
+ uint32_t option1 = req->option1;
+ uint32_t option2 = req->option2;
+
+ UPLL_LOG_DEBUG("dt_type : (%d)"
+ "operation : (%d)"
+ "option1 : (%d)"
+ "option2 : (%d)",
+ dt_type, operation, option1, option2);
+
+ switch (operation) {
+ case UNC_OP_CREATE: {
+ result_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_instance_count,
+ &max_attrs, &attrs);
+ if (result_code && (max_instance_count != 0) &&
+ (cur_instance_count >= max_instance_count)) {
+ UPLL_LOG_DEBUG("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
+ __LINE__, __FUNCTION__, cur_instance_count,
+ max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
+ break;
+ }
+ case UNC_OP_UPDATE: {
+ result_code = GetUpdateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ break;
+ }
+ case UNC_OP_READ:
+ case UNC_OP_READ_SIBLING:
+ case UNC_OP_READ_SIBLING_BEGIN:
+ case UNC_OP_READ_SIBLING_COUNT:
+
+ result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ break;
+ default:
+ UPLL_LOG_DEBUG("Invalid Operation Code - (%d)", operation);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ if (!result_code) {
+ UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s) "
+ "for opeartion(%d)",
+ ikey->get_key_type(), ctrlr_name, operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtepGrpMemMoMgr::ValidateVTepGrpMemberKey(
+ key_vtep_grp_member_t *key_vtep_grp_member,
+ uint32_t operation) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ ret_val = ValidateKey(
+ reinterpret_cast<char *>(key_vtep_grp_member->vtepgrp_key.vtn_key.vtn_name),
+ kMinLenVtnName, kMaxLenVtnName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("Vtn Name syntax check failed."
+ "Received VTN Name - %s",
+ key_vtep_grp_member->vtepgrp_key.vtn_key.vtn_name);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ ret_val = ValidateKey(
+ reinterpret_cast<char *>(key_vtep_grp_member->vtepgrp_key.vtepgrp_name),
+ kMinLenVnodeName, kMaxLenVnodeName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("VtepGrpName syntax check failed."
+ "Received VtepGrpName -%s",
+ key_vtep_grp_member->vtepgrp_key.vtepgrp_name);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ if ((operation != UNC_OP_READ_SIBLING_BEGIN) &&
+ (operation != UNC_OP_READ_SIBLING_COUNT)) {
+ ret_val = ValidateKey(reinterpret_cast<char *>
+ (key_vtep_grp_member->vtepmember_name),
+ kMinLenVnodeName, kMaxLenVnodeName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("Syntax check failed. vtepmember_name-%s",
+ key_vtep_grp_member->vtepmember_name);
+ return ret_val;
+ }
+ } else {
+ UPLL_LOG_TRACE("Operation is %d", operation);
+ StringReset(key_vtep_grp_member->vtepmember_name);
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtepGrpMemMoMgr::GetControllerDomainId(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ controller_domain_t *ctrlr_dom,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ ConfigKeyVal *ck_vtep = NULL;
+ upll_rc_t result_code = GetVtepConfigValData(ikey, ck_vtep,
+ UPLL_DT_CANDIDATE, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error in fetching the Vtep data from DB %d",
+ result_code);
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
+ UPLL_RC_ERR_CFG_SEMANTIC:result_code;
+ return result_code;
+ }
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>
+ (GetMoManager(UNC_KT_VTEP)));
+ if (!mgr) return UPLL_RC_ERR_GENERIC;
+ result_code = mgr->GetControllerDomainId(ck_vtep, ctrlr_dom);
+ if (result_code != UPLL_RC_SUCCESS)
+ return result_code;
+
+ // GET_USER_DATA_CTRLR_DOMAIN(grp_mem_key, *ctrlr_dom);
+ if (!ctrlr_dom->ctrlr || !ctrlr_dom->domain) {
+ DELETE_IF_NOT_NULL(ck_vtep);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ SET_USER_DATA(ikey, ck_vtep);
+ UPLL_LOG_DEBUG("ctrlr %s domain %s", ctrlr_dom->ctrlr, ctrlr_dom->domain);
+ DELETE_IF_NOT_NULL(ck_vtep);
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtepGrpMemMoMgr::CompareControllers(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi) {
+ ConfigKeyVal *parent_grp_key = NULL;
+ controller_domain *ctrlr_dom[2] = { NULL, NULL };
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ result_code = GetParentConfigKey(parent_grp_key, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("Error in fetching the parent key");
+ return result_code;
+ }
+ result_code = GetControllerDomainId(parent_grp_key, dt_type,
+ ctrlr_dom[0], dmi);
+ if ((result_code != UPLL_RC_SUCCESS) || (ctrlr_dom[0]->ctrlr == NULL)) {
+ UPLL_LOG_INFO("Invalid ctrlr");
+ return result_code;
+ }
+
+ ConfigKeyVal *ck_vtep = NULL;
+ result_code = GetVtepConfigValData(ikey, ck_vtep, dt_type, dmi);
+ if (result_code != UPLL_RC_SUCCESS || (!ck_vtep)) {
+ UPLL_LOG_DEBUG("Error in fetching the Vtep val data from DB");
+ return result_code;
+ }
+ GET_USER_DATA_CTRLR(ck_vtep, ctrlr_dom[1]->ctrlr);
+ if (ctrlr_dom[1]->ctrlr == NULL)
+ return UPLL_RC_ERR_GENERIC;
+ if (!strcmp(reinterpret_cast<char *>(ctrlr_dom[0]->ctrlr),
+ reinterpret_cast<char *>(ctrlr_dom[1]->ctrlr)))
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ return result_code;
+}
+
+upll_rc_t VtepGrpMemMoMgr::GetVtepConfigValData(ConfigKeyVal *ikey,
+ ConfigKeyVal *&okey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi) {
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>
+ (GetMoManager(UNC_KT_VTEP)));
+ if (!mgr) return UPLL_RC_ERR_GENERIC;
+ key_vtep *vtep_key = reinterpret_cast<key_vtep *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtep)));
+ if (!vtep_key) return UPLL_RC_ERR_GENERIC;
+ uuu::upll_strncpy(vtep_key->vtep_name,
+ reinterpret_cast<key_vtep_grp_member *>
+ (ikey->get_key())->vtepmember_name, (kMaxLenVnodeName+1));
+ uuu::upll_strncpy(vtep_key->vtn_key.vtn_name,
+ reinterpret_cast<key_vtep_grp_member *>
+ (ikey->get_key())->vtepgrp_key.vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ okey = new ConfigKeyVal(UNC_KT_VTEP, IpctSt::kIpcStKeyVtep, vtep_key, NULL);
+
+ if (okey == NULL) {
+ free(vtep_key);
+ return UPLL_RC_ERR_GENERIC;
+ } else {
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone,
+ kOpInOutCtrlr | kOpInOutDomain | kOpInOutFlag};
+ result_code = mgr->ReadConfigDB(okey, dt_type, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB Return Failure = %d ", result_code);
+ delete okey;
+ return result_code;
+ }
+ }
+ return result_code;
+}
+/*
+ upll_rc_t VtepGrpMemMoMgr::CopyToConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *ikey) {
+
+ if ( !ikey || !(ikey->get_key()) )
+ return UPLL_RC_ERR_GENERIC;
+
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ key_rename_vnode_info *key_rename = (key_rename_vnode_info *)ikey->get_key();
+ key_vtep_grp_member_t *vtep_key = (key_vtep_grp_member_t *) malloc ( sizeof (key_vtep_grp_member_t));
+ if (!vtep_key)
+ return UPLL_RC_ERR_GENERIC;
+ if (!strlen ((char *)key_rename->old_unc_vtn_name))
+ return UPLL_RC_ERR_GENERIC;
+ strcpy ((char *)vtep_key ->vtepgrp_key.vtn_key.vtn_name, (char *)key_rename->old_unc_vtn_name);
+
+ okey = new ConfigKeyVal (UNC_KT_VTEP_GRP_MEMBER, IpctSt::kIpcStKeyVtepGrpMember, vtep_key, NULL);
+ if (!okey) {
+ free(vtep_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ return result_code;
+ }
+ */
+
+} // namespace vtn
+} // namespace upll
+} // namespace unc
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 NEC Corporation
+ * All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+#ifndef UNC_UPLL_VTEP_GRP_MEM_MOMGR_H
+#define UNC_UPLL_VTEP_GRP_MEM_MOMGR_H
+
+#include "momgr_impl.hh"
+#include "vnode_child_momgr.hh"
+#include "vtep_grp_momgr.hh"
+#include "vtep_momgr.hh"
+
+namespace unc {
+namespace upll {
+namespace kt_momgr {
+
+enum VtepGrpMemMoMgrTables {
+ VTEPGRPMEMTBL = 0,
+ NVTEPGRPMEMTABLES
+};
+
+
+class VtepGrpMemMoMgr : public VnodeChildMoMgr {
+ private:
+ static BindInfo vtepgrp_mem_bind_info[];
+// static BindInfo key_vtepgrp_mem_maintbl_update_bind_info[];
+ /**
+ * @brief Gets the valid array position of the variable in the value
+ * structure from the table in the specified configuration
+ *
+ * @param[in] val pointer to the value structure
+ * @param[in] indx database index for the variable
+ * @param[out] valid position of the variable in the valid array -
+ * NULL if valid does not exist.
+ * @param[in] dt_type specifies the configuration
+ * @param[in] tbl specifies the table containing the given value
+ *
+ **/
+ upll_rc_t GetValid(void *val, uint64_t indx, uint8_t *&valid,
+ upll_keytype_datatype_t dt_type, MoMgrTables tbl ) {
+ UPLL_FUNC_TRACE;
+ valid = NULL;
+ return UPLL_RC_SUCCESS;
+ }
+ upll_rc_t UpdateConfigStatus(ConfigKeyVal *vtepgrpmem_key,
+ unc_keytype_operation_t op,
+ uint32_t result,
+ ConfigKeyVal *upd_key,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ctrlr_key = NULL);
+ upll_rc_t UpdateAuditConfigStatus(
+ unc_keytype_configstatus_t cs_status,
+ uuc::UpdateCtrlrPhase phase,
+ ConfigKeyVal *&ckv_running);
+ bool CompareValidValue(void *&val1, void *val2, bool audit) {
+ return true;
+ }
+
+ upll_rc_t GetControllerDomainId(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ controller_domain_t *ctrlr_dom,
+ DalDmlIntf *dmi);
+
+ upll_rc_t ValidateAttribute(ConfigKeyVal *kval,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req = NULL);
+ /**
+ * @brief Duplicates the input configkeyval including the key and val.
+ * based on the tbl specified.
+ *
+ * @param[in] okey Output Configkeyval - allocated within the function
+ * @param[in] req Input ConfigKeyVal to be duplicated.
+ * @param[in] tbl specifies if the val structure belongs to the main table/ controller table or rename table.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ upll_rc_t DupConfigKeyVal(ConfigKeyVal *&okey,
+ ConfigKeyVal *&req, MoMgrTables tbl = MAINTBL);
+ /**
+ * @brief Allocates for the specified val in the given configuration in the * specified table.
+ *
+ * @param[in/out] ck_val Reference pointer to configval structure
+ * allocated.
+ * @param[in] dt_type specifies the configuration candidate/running/
+ * state
+ * @param[in] tbl specifies if the corresponding table is the
+ * main table / controller table or rename table.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ upll_rc_t AllocVal(ConfigVal *&ck_val, upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl = MAINTBL);
+/**
+ * @brief Method to get a configkeyval of a specified keytype from an input configkeyval
+ *
+ * @param[in/out] okey pointer to output ConfigKeyVal
+ * @param[in] parent_key pointer to the configkeyval from which the output configkey val is initialized.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ */
+ upll_rc_t GetChildConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *parent_key);
+/**
+ * @brief Method to get a configkeyval of the parent keytype
+ *
+ * @param[in/out] okey pointer to parent ConfigKeyVal
+ * @param[in] ikey pointer to the child configkeyval from
+ * which the parent configkey val is obtained.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ upll_rc_t GetParentConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *ikey);
+
+ /**
+ * @Brief Get the VtepConfigKeyVal from VtepTbl
+ *
+ * @param[in] ikey ikey contains key and value structure.
+ * @param[in] okey okey contains key and value structure.
+ * @param[in] dt_type database type
+ * @param[in] dmi pointer to DalDmlIntf
+ *
+ * @retval UPLL_RC_SUCCESS Successful.
+ * @retval UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT Operation not allowed
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ */
+ upll_rc_t GetVtepConfigValData(ConfigKeyVal *ikey, ConfigKeyVal *&okey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi);
+ /**
+ * @Brief Validates the syntax of the specified key and value structure
+ * for KT_VTEP_GRP_MEMBER keytype
+ *
+ * @param[in] req This structure contains
+ * IpcReqRespHeader(first 8 fields of input request structure).
+ * @param[in] ikey ikey contains key and value structure.
+ *
+ * @retval UPLL_RC_SUCCESS Successful.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX Syntax error.
+ * @retval UPLL_RC_ERR_NO_SUCH_INSTANCE key struct is not available.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ * @retval UPLL_RC_ERR_INVALID_OPTION1 option1 is not valid.
+ * @retval UPLL_RC_ERR_INVALID_OPTION2 option2 is not valid.
+ */
+ upll_rc_t ValidateMessage(IpcReqRespHeader *req, ConfigKeyVal *ikey);
+
+ /**
+ * @Brief Validates the syntax for KT_VTEP_GRP_MEMBER keytype key structure.
+ *
+ * @param[in] key_vtep_grp_member KT_VTEP_GRP_MEMBER key structure.
+ *
+ * @retval UPLL_RC_SUCCESS validation succeeded.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX validation failed.
+ */
+ upll_rc_t ValidateVTepGrpMemberKey(
+ key_vtep_grp_member_t *key_vtep_grp_member,
+ uint32_t operation);
+ /**
+ * @Brief Checks if the specified key type(KT_VTEP_GRP_MEMBER) and
+ * associated attributes are supported on the given controller,
+ * based on the valid flag
+ *
+ * @param[in] req This structure contains
+ * IpcReqRespHeader(first 8 fields of input request structure).
+ * @param[in] ikey ikey contains key and value structure.
+ * @param[in] crtlr_name Controller name.
+ *
+ * @retval UPLL_RC_SUCCESS Validation succeeded.
+ * @retval UPLL_RC_ERR_GENERIC Validation failure.
+ * @retval UPLL_RC_ERR_INVALID_OPTION1 Option1 is not valid.
+ * @retval UPLL_RC_ERR_INVALID_OPTION2 Option2 is not valid.
+ */
+
+ upll_rc_t ValidateCapability(IpcReqRespHeader *req, ConfigKeyVal *ikey,
+ const char * crtlr_name);
+
+ upll_rc_t CopyToConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *ikey) {
+ return UPLL_RC_SUCCESS;
+ }
+ bool GetRenameKeyBindInfo(unc_key_type_t key_type, BindInfo *&binfo,
+ int &nattr,
+ MoMgrTables tbl ) {
+ return true;
+ }
+ upll_rc_t IsReferenced(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type, DalDmlIntf *dmi) {
+ return UPLL_RC_SUCCESS;
+ }
+
+ public:
+ VtepGrpMemMoMgr();
+ virtual ~VtepGrpMemMoMgr() {
+ for (int i = VTEPGRPMEMTBL; i < NVTEPGRPMEMTABLES; i++)
+ if (table[i]) {
+ delete table[i];
+ }
+ delete[] table;
+ }
+ /**
+ * @brief Method to check if individual portions of a key are valid
+ *
+ * @param[in/out] ikey pointer to ConfigKeyVal referring to a UNC resource
+ * @param[in] index db index associated with the variable
+ *
+ * @retval true input key is valid
+ * @retval false input key is invalid.
+ **/
+ bool IsValidKey(void *tkey, uint64_t index);
+
+ /**
+ * @Brief Compare if Vtep member ControllerId and VtepGrp ControllerId are same
+ * If same throw an error
+ *
+ * @param[in] req pointer IpcReqResp header
+ * @param[in] ikey ikey contains key and value structure.
+ * @param[in] dt_type database type
+ * @param[in] dmi pointer to DalDmlIntf
+ *
+ * @retval UPLL_RC_SUCCESS Successful.
+ * @retval UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT Operation not allowed
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ */
+ upll_rc_t CompareControllers(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi);
+};
+
+
+} // namespace vtn
+} // namespace upll
+} // namespace unc
+#endif
#include "unc/upll_ipc_enum.h"
#include "flowlist_momgr.hh"
#include "vtn_momgr.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "vbr_flowfilter_entry_momgr.hh"
using std::list;
using std::multimap;
namespace upll {
namespace kt_momgr {
-#define NUM_KEY_MAIN_TBL_ 5
-#define NUM_KEY_RENAME_MAIN_TBL 5
-#define NUM_KEY_CTRLR_TBL 5
-
+#define FLOWLIST_RENAME 0x02
+#define NO_FLOWLIST_RENAME ~FLOWLIST_RENAME
// VTN FlowFilter Entry Main Table
BindInfo VtnFlowFilterEntryMoMgr::vtn_flowfilter_entry_bind_info[] = {
{ uudst::vtn_flowfilter_entry::kDbiVtnName, CFG_KEY,
{uudst::vtn_flowfilter_entry::kDbiVtnName, CFG_MATCH_KEY, offsetof(
key_vtn_flowfilter_entry_t, flowfilter_key.vtn_key.vtn_name),
uud::kDalChar, kMaxLenVtnName + 1},
- {uudst::vtn_flowfilter_entry::kDbiInputDirection, CFG_MATCH_KEY, offsetof(
- key_vtn_flowfilter_entry_t, flowfilter_key.input_direction),
- uud::kDalUint8, 1},
- {uudst::vtn_flowfilter_entry::kDbiSequenceNum, CFG_MATCH_KEY, offsetof(
- key_vtn_flowfilter_entry_t, sequence_num),
- uud::kDalUint8, 1 },
{uudst::vtn_flowfilter_entry::kDbiVtnName, CFG_INPUT_KEY, offsetof(
key_rename_vnode_info_t, new_unc_vtn_name),
uud::kDalChar, kMaxLenVtnName + 1},
- {uudst::vtn_flowfilter_entry::kDbiFlags, CFG_INPUT_KEY, offsetof(
+ {uudst::vtn_flowfilter_entry::kDbiFlags, CK_VAL, offsetof(
key_user_data_t, flags),
uud::kDalUint8, 1}
};
{uudst::vtn_flowfilter_entry_ctrlr::kDbiVtnName, CFG_MATCH_KEY, offsetof(
key_vtn_flowfilter_t, vtn_key.vtn_name),
uud::kDalChar, kMaxLenVtnName + 1},
- { uudst::vtn_flowfilter_entry_ctrlr::kDbiInputDirection, CFG_MATCH_KEY,
- offsetof(key_vtn_flowfilter_t, input_direction),
- uud::kDalUint8, 1},
{uudst::vtn_flowfilter_entry_ctrlr::kDbiVtnName, CFG_INPUT_KEY, offsetof(
key_rename_vnode_info_t, new_unc_vtn_name),
uud::kDalChar, kMaxLenVtnName + 1},
- { uudst::vtn_flowfilter_entry_ctrlr::kDbiCtrlrName, CK_VAL,
- offsetof(key_user_data_t, ctrlr_id),
- uud::kDalChar, kMaxLenCtrlrId + 1},
- {uudst::vtn_flowfilter_entry_ctrlr::kDbiDomainId, CK_VAL,
- offsetof(key_user_data_t, domain_id),
- uud::kDalChar, kMaxLenDomainId + 1},
- {uudst::vtn_flowfilter_entry_ctrlr::kDbiFlags, CFG_INPUT_KEY, offsetof(
+ {uudst::vtn_flowfilter_entry_ctrlr::kDbiFlags, CK_VAL, offsetof(
key_user_data_t, flags),
uud::kDalUint8, 1}
-};
-BindInfo VtnFlowFilterEntryMoMgr::vtn_flowlist_rename_bind_info[] = {
- {uudst::vtn_flowfilter_entry::kDbiVtnName, CFG_MATCH_KEY, offsetof(
- key_vtn_flowfilter_entry_t, flowfilter_key.vtn_key.vtn_name),
- uud::kDalChar, kMaxLenVtnName + 1},
- {uudst::vtn_flowfilter_entry::kDbiInputDirection, CFG_MATCH_KEY, offsetof(
- key_vtn_flowfilter_entry_t, flowfilter_key.input_direction),
- uud::kDalUint8, 1},
- {uudst::vtn_flowfilter_entry::kDbiSequenceNum, CFG_MATCH_KEY, offsetof(
- key_vtn_flowfilter_entry_t, sequence_num),
- uud::kDalUint16, 1},
- {uudst::vtn_flowfilter_entry::kDbiFlowlistName, CFG_INPUT_KEY, offsetof(
- key_rename_vnode_info_t, new_flowlist_name),
- uud::kDalChar, kMaxLenVtnName + 1},
- {uudst::vtn_flowfilter_entry::kDbiFlags, CFG_INPUT_KEY, offsetof(
- key_user_data_t, flags),
- uud::kDalUint8, 1}
};
VtnFlowFilterEntryMoMgr::VtnFlowFilterEntryMoMgr() :MoMgrImpl() {
// VTN FlowFilter Entry Does not have any child
nchild = 0;
child = NULL;
+ cur_instance_count = 0;
}
upll_rc_t VtnFlowFilterEntryMoMgr::IsReferenced(
uint8_t* vtn_name,
controller_domain *ctrlr_dom,
unc_keytype_operation_t op,
- DalDmlIntf *dmi) {
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi,
+ uint8_t flag) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *ikey = NULL;
DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutNone};
// Read the Configuration from the MainTable
- result_code = ReadConfigDB(ikey, UPLL_DT_CANDIDATE,
+ result_code = ReadConfigDB(ikey, dt_type,
UNC_OP_READ, dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ DELETE_IF_NOT_NULL(ikey);
UPLL_LOG_DEBUG(" No Records in main table to be created in ctrlr tbl");
return UPLL_RC_SUCCESS;
}
UPLL_LOG_DEBUG(" Read main table failed ");
- delete ikey;
+ DELETE_IF_NOT_NULL(ikey);
return result_code;
}
+ if (flag != 0) {
+ UPLL_LOG_DEBUG("flag in UpdateControllerTableForVtn %d", flag);
+ ConfigKeyVal *temp_ikey = ikey;
+ ConfigKeyVal *flag_ikey = NULL;
+ while (NULL != temp_ikey) {
+ result_code = DupConfigKeyVal(flag_ikey, temp_ikey, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed %d", result_code);
+ DELETE_IF_NOT_NULL(ikey);
+ return result_code;
+ }
+ uint8_t temp_flag = 0;
+ GET_USER_DATA_FLAGS(flag_ikey, temp_flag);
+ UPLL_LOG_DEBUG("temp_flag in UpdateControllerTableForVtn %d", temp_flag);
+ flag = flag | temp_flag;
+ SET_USER_DATA_FLAGS(flag_ikey, flag);
+ UPLL_LOG_DEBUG("temp_flag in UpdateControllerTableForVtn %d", temp_flag);
+ DbSubOp dbop1 = {kOpNotRead, kOpMatchNone, kOpInOutCs | kOpInOutFlag};
+ result_code = UpdateConfigDB(flag_ikey, dt_type, UNC_OP_UPDATE,
+ dmi, &dbop1, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(ikey);
+ DELETE_IF_NOT_NULL(flag_ikey);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(flag_ikey);
+ temp_ikey = temp_ikey->get_next_cfg_key_val();
+ }
+ }
+
FlowListMoMgr *flowlist_mgr = reinterpret_cast<FlowListMoMgr *>
(const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
-
- while (ikey != NULL) {
- result_code = UpdateControllerTable(ikey, UNC_OP_CREATE,
- UPLL_DT_CANDIDATE, dmi,
+ ConfigKeyVal *new_ikey = ikey;
+ while (new_ikey != NULL) {
+ result_code = UpdateControllerTable(new_ikey, op,
+ dt_type, dmi,
list_ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
+ if ((result_code == UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT) ||
+ (result_code == UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR)) {
+ UPLL_LOG_DEBUG("ValidateCapability failed");
+ DELETE_IF_NOT_NULL(ikey);
+ return result_code;
+ }
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("No instance in UpdateControllerTable");
+ DELETE_IF_NOT_NULL(ikey);
+ return UPLL_RC_SUCCESS;
+ }
UPLL_LOG_DEBUG("create in ctrlr tbl failed: error code (%d)",
result_code);
}
// Notify the flowlistmomgr is flowlist is configured.
//
val_vtn_flowfilter_entry_t *val_vtn_ffe =
- reinterpret_cast<val_vtn_flowfilter_entry_t *> (GetVal(ikey));
+ reinterpret_cast<val_vtn_flowfilter_entry_t *> (GetVal(new_ikey));
// if Flowlist name is configured in the flowfilter
// send controller add/delete request to flowlist momgr.
if (UNC_VF_VALID == val_vtn_ffe->valid[UPLL_IDX_FLOWLIST_NAME_VFFE]) {
result_code = flowlist_mgr->AddFlowListToController(
reinterpret_cast<char *>(val_vtn_ffe->flowlist_name), dmi,
- reinterpret_cast<char *>(ctrlr_id) , op);
+ reinterpret_cast<char *>(ctrlr_id), dt_type, op);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("AddFlowListToController failed err(%d)", result_code)
- return result_code;
+ UPLL_LOG_DEBUG("AddFlowListToController failed err(%d)", result_code);
+ DELETE_IF_NOT_NULL(ikey);
+ return result_code;
}
}
- ikey = ikey->get_next_cfg_key_val();
+ new_ikey = new_ikey->get_next_cfg_key_val();
}
+ DELETE_IF_NOT_NULL(ikey);
UPLL_LOG_DEBUG("Successful completion of the controller table updation");
return result_code;
}
return result_code;
}
// Check if Object exists in RUNNING DB and move it to CANDIDATE DB
- result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
- MAINTBL);
- if ((result_code != UPLL_RC_ERR_INSTANCE_EXISTS) &&
- (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
- UPLL_LOG_DEBUG(" Is Exist check operation failed: err code(%d)",
- result_code);
- return result_code;
- }
- if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
- result_code = RestoreChildren(ikey, req->datatype, UPLL_DT_RUNNING, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- // delete okey;
- return UPLL_RC_ERR_GENERIC;
+ if (req->datatype == UPLL_DT_CANDIDATE) {
+ result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
+ MAINTBL);
+ if ((result_code != UPLL_RC_ERR_INSTANCE_EXISTS) &&
+ (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG(" Is Exist check operation failed: err code(%d)",
+ result_code);
+ return result_code;
+ }
+ if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
+ result_code = RestoreChildren(ikey, req->datatype, UPLL_DT_RUNNING, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Restore Operation Failed, err %d", result_code);
+ return result_code;
+ }
+ return result_code;
}
}
-
std::list<controller_domain_t> list_ctrlr_dom;
- vtn_ctrlr_span_rt_code = GetVtnControllerSpan(ikey, dmi, list_ctrlr_dom);
+ vtn_ctrlr_span_rt_code = GetVtnControllerSpan(ikey, req->datatype, dmi, list_ctrlr_dom);
if ((vtn_ctrlr_span_rt_code != UPLL_RC_SUCCESS) &&
(vtn_ctrlr_span_rt_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
UPLL_LOG_DEBUG(" GetVtnControllerSpan error code (%d)",
dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
// delete okey;
+ FREE_LIST_CTRLR(list_ctrlr_dom);
return result_code;
}
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("create in ctrlr tbl failed: error code (%d)",
result_code);
- result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_DELETE,
+ upll_rc_t del_result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_DELETE,
dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
+ if (del_result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("delete in CandidateDB failed: err code(%d) ",
- result_code);
+ del_result_code);
}
+ FREE_LIST_CTRLR(list_ctrlr_dom);
+ return result_code;
}
}
val_vtn_flowfilter_entry_t *val_vtn_ffe = reinterpret_cast
<val_vtn_flowfilter_entry_t *>(GetVal(ikey));
if (UNC_VF_VALID == val_vtn_ffe->valid[UPLL_IDX_FLOWLIST_NAME_VFFE]) {
- result_code = UpdateFlowListInCtrl(ikey, UNC_OP_CREATE, dmi);
+ result_code = UpdateFlowListInCtrl(ikey, req->datatype, UNC_OP_CREATE, dmi);
if (result_code != UPLL_RC_SUCCESS) {
- // delete okey;
+ if (vtn_ctrlr_span_rt_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ FREE_LIST_CTRLR(list_ctrlr_dom);
+ }
return result_code;
}
}
+
+ if (vtn_ctrlr_span_rt_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ FREE_LIST_CTRLR(list_ctrlr_dom);
+ }
// delete okey;
return result_code;
}
+upll_rc_t VtnFlowFilterEntryMoMgr::RestorePOMInCtrlTbl(
+ ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl,
+ DalDmlIntf* dmi) {
+
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ if (!ikey || !(ikey->get_key())) {
+ UPLL_LOG_DEBUG("Input Key Not Valid");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (tbl != MAINTBL ||
+ (ikey->get_key_type() != UNC_KT_VTN_FLOWFILTER_ENTRY)) {
+ UPLL_LOG_DEBUG("Ignoring ktype/Table kt=%d, tbl=%d",
+ ikey->get_key_type(), tbl);
+ return result_code;
+ }
+ val_vtn_flowfilter_entry_t *flowfilter_val =
+ reinterpret_cast<val_vtn_flowfilter_entry_t *> (GetVal(ikey));
+
+ if (NULL == flowfilter_val) {
+ UPLL_LOG_DEBUG(" Value structure is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (flowfilter_val->valid[UPLL_IDX_FLOWLIST_NAME_VFFE] == UNC_VF_VALID) {
+ result_code = UpdateFlowListInCtrl(ikey, dt_type, UNC_OP_CREATE, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to update flowlist in ctrlr table, err %d",
+ result_code);
+ return result_code;
+ }
+ }
+ return result_code;
+}
upll_rc_t VtnFlowFilterEntryMoMgr::UpdateFlowListInCtrl(
ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
unc_keytype_operation_t op,
DalDmlIntf* dmi) {
UPLL_FUNC_TRACE;
uuu::upll_strncpy(vtn_key->vtn_name,
ff_entry_key->flowfilter_key.vtn_key.vtn_name,
(kMaxLenVtnName + 1));
- result_code = vtnmgr->GetControllerDomainSpan(vtn_okey, UPLL_DT_CANDIDATE,
+ result_code = vtnmgr->GetControllerDomainSpan(vtn_okey, dt_type,
dmi);
if (result_code != UPLL_RC_SUCCESS &&
UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
- delete vtn_okey;
+ DELETE_IF_NOT_NULL(vtn_okey);
UPLL_LOG_DEBUG("Error in getting controller span (%d)",
result_code);
return result_code;
if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
UPLL_LOG_DEBUG("No entry in ctrlr tbl (%d)",
result_code);
+ DELETE_IF_NOT_NULL(vtn_okey);
return UPLL_RC_SUCCESS;
}
ConfigKeyVal *tmp_ckv = vtn_okey;
GET_USER_DATA_CTRLR(tmp_ckv, ctrlr_id);
if (NULL == ctrlr_id) {
UPLL_LOG_DEBUG("ctrlr_id NULL");
- delete vtn_okey;
+ DELETE_IF_NOT_NULL(vtn_okey);
return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_TRACE("flowlist name %s length %zu", flowfilter_val->flowlist_name,
if (UNC_OP_CREATE == op || UNC_OP_DELETE == op) {
result_code = flowlist_mgr->AddFlowListToController(
reinterpret_cast<char *>(flowfilter_val->flowlist_name), dmi,
- reinterpret_cast<char *> (ctrlr_id) , op);
+ reinterpret_cast<char *> (ctrlr_id), dt_type, op);
if (result_code != UPLL_RC_SUCCESS) {
- delete vtn_okey;
+ DELETE_IF_NOT_NULL(vtn_okey);
return result_code;
}
} else if (UNC_OP_UPDATE == op) {
result_code = GetChildConfigKey(tempckv, ikey);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_TRACE("GetChildConfigKey failed");
+ DELETE_IF_NOT_NULL(vtn_okey);
return result_code;
}
DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone };
- result_code = ReadConfigDB(tempckv, UPLL_DT_CANDIDATE, UNC_OP_READ,
+ result_code = ReadConfigDB(tempckv, dt_type, UNC_OP_READ,
dbop, dmi, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("ReadConfigDB failed");
+ DELETE_IF_NOT_NULL(vtn_okey);
+ DELETE_IF_NOT_NULL(tempckv);
return result_code;
}
val_vtn_flowfilter_entry_t *vtn_ffe_val = reinterpret_cast
valid[UPLL_IDX_FLOWLIST_NAME_VFFE]) {
result_code = flowlist_mgr->AddFlowListToController(
reinterpret_cast<char *>(temp_ffe_val->flowlist_name), dmi,
- reinterpret_cast<char *> (ctrlr_id) , UNC_OP_DELETE);
+ reinterpret_cast<char *> (ctrlr_id), dt_type, UNC_OP_DELETE);
if (result_code != UPLL_RC_SUCCESS) {
- delete tempckv;
+ DELETE_IF_NOT_NULL(vtn_okey);
+ DELETE_IF_NOT_NULL(tempckv);
return result_code;
}
result_code = flowlist_mgr->AddFlowListToController(
reinterpret_cast<char *>(vtn_ffe_val->flowlist_name), dmi,
- reinterpret_cast<char *> (ctrlr_id) , UNC_OP_CREATE);
+ reinterpret_cast<char *> (ctrlr_id), dt_type, UNC_OP_CREATE);
if (result_code != UPLL_RC_SUCCESS) {
- delete tempckv;
+ DELETE_IF_NOT_NULL(vtn_okey);
+ DELETE_IF_NOT_NULL(tempckv);
return result_code;
}
} else if (UNC_VF_VALID == vtn_ffe_val->
temp_ffe_val->valid[UPLL_IDX_FLOWLIST_NAME_VFFE])) {
result_code = flowlist_mgr->AddFlowListToController(
reinterpret_cast<char *>(vtn_ffe_val->flowlist_name), dmi,
- reinterpret_cast<char *> (ctrlr_id) , UNC_OP_CREATE);
+ reinterpret_cast<char *> (ctrlr_id), dt_type, UNC_OP_CREATE);
if (result_code != UPLL_RC_SUCCESS) {
- delete tempckv;
+ DELETE_IF_NOT_NULL(vtn_okey);
+ DELETE_IF_NOT_NULL(tempckv);
return result_code;
}
} else if (UNC_VF_VALID_NO_VALUE == vtn_ffe_val->
valid[UPLL_IDX_FLOWLIST_NAME_VFFE]) {
result_code = flowlist_mgr->AddFlowListToController(
reinterpret_cast<char *>(temp_ffe_val->flowlist_name), dmi,
- reinterpret_cast<char *> (ctrlr_id) , UNC_OP_DELETE);
+ reinterpret_cast<char *> (ctrlr_id), dt_type, UNC_OP_DELETE);
if (result_code != UPLL_RC_SUCCESS) {
- delete tempckv;
+ DELETE_IF_NOT_NULL(vtn_okey);
+ DELETE_IF_NOT_NULL(tempckv);
return result_code;
}
}
+ DELETE_IF_NOT_NULL(tempckv);
}
tmp_ckv = tmp_ckv->get_next_cfg_key_val();
}
- delete vtn_okey;
+ DELETE_IF_NOT_NULL(vtn_okey);
return result_code;
}
UNC_OP_READ, dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Unable to read configuration from CandidateDb");
- delete okey;
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
val_vtn_flowfilter_entry_t *vtn_ffe_val = reinterpret_cast
<val_vtn_flowfilter_entry_t *>(GetVal(okey));
if (UNC_VF_VALID == vtn_ffe_val->valid[UPLL_IDX_FLOWLIST_NAME_VFFE]) {
- result_code = UpdateFlowListInCtrl(okey, UNC_OP_DELETE, dmi);
+ result_code = UpdateFlowListInCtrl(okey, req->datatype, UNC_OP_DELETE, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Unable to update flowlist in ctrlr table");
- delete okey;
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
}
- delete okey;
+ DELETE_IF_NOT_NULL(okey);
result_code = DeleteCandidateMo(req, ikey, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Delete Operation Failed DB Error (%d)", result_code);
UPLL_LOG_DEBUG(" UpdateMo Failed. Insufficient input parameters.");
return UPLL_RC_ERR_GENERIC;
}
- ConfigKeyVal *okey = NULL;
result_code = ValidateMessage(req, ikey);
if (UPLL_RC_SUCCESS != result_code) {
return result_code;
}
+ result_code = ValidateAttribute(ikey, dmi, req);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ValidateAttribute failed: err code(%d)", result_code);
+ return result_code;
+ }
+
/*
result_code = ValidateCapability(req, ikey);
if (UPLL_RC_SUCCESS != result_code) {
val_vtn_flowfilter_entry_t *vtn_ffe_val = reinterpret_cast
<val_vtn_flowfilter_entry_t *>(GetVal(ikey));
- if (UNC_VF_VALID == vtn_ffe_val->valid[UPLL_IDX_FLOWLIST_NAME_VFFE]) {
- FlowListMoMgr *flowlist_mgr = reinterpret_cast<FlowListMoMgr *>
- (const_cast<MoManager *> (GetMoManager(UNC_KT_FLOWLIST)));
- result_code = flowlist_mgr->GetChildConfigKey(okey, NULL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetChildConfigKey failed for FlowList %d", result_code);
- return result_code;
- }
- key_flowlist_t *key_flowlist = reinterpret_cast<key_flowlist_t*>
- (okey->get_key());
- uuu::upll_strncpy(key_flowlist->flowlist_name,
- vtn_ffe_val->flowlist_name,
- (kMaxLenFlowListName +1));
- result_code = flowlist_mgr->UpdateConfigDB(okey, req->datatype,
- UNC_OP_READ, dmi, MAINTBL);
- if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- UPLL_LOG_DEBUG("Given FlowList does not exists %d", result_code);
- delete okey;
- return result_code;
- } else if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
- UPLL_LOG_DEBUG("Instance Available");
- } else if (result_code != UPLL_RC_SUCCESS) {
- delete okey;
- UPLL_LOG_DEBUG("Error Accesing CANDIDATE DB (%d)", result_code);
- return result_code;
- }
- }
std::list<controller_domain_t> list_ctrlr_dom;
- vtn_ctrlr_span_rt_code = GetVtnControllerSpan(ikey, dmi, list_ctrlr_dom);
+ vtn_ctrlr_span_rt_code = GetVtnControllerSpan(ikey, req->datatype, dmi, list_ctrlr_dom);
if ((vtn_ctrlr_span_rt_code != UPLL_RC_SUCCESS) &&
(vtn_ctrlr_span_rt_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
UPLL_LOG_DEBUG(" GetVtnControllerSpan error code (%d)",
result_code = DupConfigKeyVal(ctrl_key, ikey, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("DupConfigKeyVal err (%d)", result_code);
- DELETE_IF_NOT_NULL(okey);
+ for (std::list<controller_domain_t>::iterator it= list_ctrlr_dom.begin();
+ it != list_ctrlr_dom.end(); ++it) {
+ free(it->ctrlr);
+ free(it->domain);
+ }
return result_code;
}
if (UNC_VF_VALID == vtn_ffe_val->valid[UPLL_IDX_FLOWLIST_NAME_VFFE] ||
UNC_VF_VALID_NO_VALUE == vtn_ffe_val->valid[UPLL_IDX_FLOWLIST_NAME_VFFE] ) {
- result_code = UpdateFlowListInCtrl(ikey, UNC_OP_UPDATE, dmi);
+ result_code = UpdateFlowListInCtrl(ikey, req->datatype, UNC_OP_UPDATE, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Unable to update flowlist in ctrlr table");
- delete okey;
+ if (vtn_ctrlr_span_rt_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ for (std::list<controller_domain_t>::iterator it= list_ctrlr_dom.begin();
+ it != list_ctrlr_dom.end(); ++it) {
+ free(it->ctrlr);
+ free(it->domain);
+ }
+ }
return result_code;
}
}
-
+ DbSubOp dbop1 = {kOpNotRead, kOpMatchNone, kOpInOutFlag};
+ uint8_t temp_flag = 0;
+ GET_USER_DATA_FLAGS(ikey, temp_flag);
+ UPLL_LOG_DEBUG("GET_USER_DATA_FLAGS in Update %d", temp_flag);
result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_UPDATE, dmi,
- MAINTBL);
+ &dbop1, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("UpdateMo:Failed UpdateConfigDB ");
- delete okey;
+ if (vtn_ctrlr_span_rt_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ for (std::list<controller_domain_t>::iterator it= list_ctrlr_dom.begin();
+ it != list_ctrlr_dom.end(); ++it) {
+ free(it->ctrlr);
+ free(it->domain);
+ }
+ }
return result_code;
}
// Update a record in CANDIDATE DB for controller Table
}*/
}
}
- delete okey;
+ if (vtn_ctrlr_span_rt_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ for (std::list<controller_domain_t>::iterator it= list_ctrlr_dom.begin();
+ it != list_ctrlr_dom.end(); ++it) {
+ free(it->ctrlr);
+ free(it->domain);
+ }
+ }
DELETE_IF_NOT_NULL(ctrl_key);
ctrl_key = NULL;
return result_code;
}
- /* TODO Is Reference and GetChildConfigKey APis of NWM are declared as private
- * Commented the below code to avoid compilation error of access violation
- * nwm_momgr.cc code must be corrected */
-#if 0
-upll_rc_t VtnFlowFilterEntryMoMgr::IsNWMReferenced(ConfigKeyVal *ikey,
- DalDmlIntf *dmi) {
+upll_rc_t VtnFlowFilterEntryMoMgr::MergeImportToCandidate(unc_key_type_t keytype,
+ const char *ctrlr_name,
+ DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
- ConfigKeyVal *okey = NULL;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- NwMonitorMoMgr *nmgr = reinterpret_cast<NwMonitorMoMgr *>
- (const_cast<MoManager *> (GetMoManager(UNC_KT_VBR_NWMONITOR)));
- result_code = nmgr->GetChildConfigKey(okey, NULL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Recored %d", result_code);
+
+ ConfigKeyVal *ckval = NULL;
+ ConfigKeyVal *ckey = NULL;
+
+ controller_domain ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ uint8_t flag = 0;
+
+ if (NULL == ctrlr_name) {
+ UPLL_LOG_DEBUG("MergeValidate ctrlr_id NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ result_code = GetChildConfigKey(ckval, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey ckval NULL");
return result_code;
}
- val_flowfilter_entry_t *flowfilter_val =
- reinterpret_cast<val_flowfilter_entry_t *> (GetVal(ikey));
- key_nwm_t *key_nwm = reinterpret_cast<key_nwm_t*>(okey->get_key());
- strncpy(reinterpret_cast<char*>(key_nwm->nwmonitor_name),
- reinterpret_cast<const char*>(flowfilter_val->nwm_name),
- kMaxLenNwmName +1);
- result_code = nmgr->IsReferenced(okey, UPLL_DT_CANDIDATE, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code) {
- delete okey;
- UPLL_LOG_DEBUG("Unable to get the NWM Reference %d", result_code);
+ if (!ckval) return UPLL_RC_ERR_GENERIC;
+
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutFlag };
+ // Read vtn ff from import main
+ result_code = ReadConfigDB(ckval, UPLL_DT_IMPORT,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ckval);
+ UPLL_LOG_DEBUG("ReadConfigDB ckval NULL (%d)", result_code);
+ if(result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("ReadConfigDB ckval NULL (%d)", result_code);
return result_code;
}
+ return UPLL_RC_SUCCESS;
}
-}
-#endif
-upll_rc_t VtnFlowFilterEntryMoMgr::MergeValidate(unc_key_type_t keytype,
- const char *ctrlr_id,
- ConfigKeyVal *ikey,
- DalDmlIntf *dmi) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
- ConfigKeyVal *tkey;
- ConfigKeyVal *flowlist_keyval = NULL;
- if (NULL == ikey) return result_code;
- result_code = ReadConfigDB(ikey, UPLL_DT_IMPORT, UNC_OP_READ, dbop, dmi,
- MAINTBL);
- if (UPLL_RC_SUCCESS != result_code) return result_code;
- MoMgrImpl *mgr = static_cast<MoMgrImpl*>
- ((const_cast<MoManager*>
- (GetMoManager(UNC_KT_FLOWLIST))));
- tkey = ikey;
- while (ikey != NULL) {
- result_code = mgr->GetChildConfigKey(flowlist_keyval, NULL);
+ UPLL_LOG_DEBUG("ReadConfigDB ckval NULL (%d)", result_code);
+ ConfigKeyVal *tmp_ckval = ckval;
+ while (NULL != ckval) {
+ // Check the VTN already configured in UNC
+ VtnMoMgr *vtnmgr =
+ static_cast<VtnMoMgr *>((const_cast<MoManager *>
+ (GetMoManager(UNC_KT_VTN))));
+ result_code = vtnmgr->GetChildConfigKey(ckey, NULL);
if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey error (%d)", result_code);
+ DELETE_IF_NOT_NULL(tmp_ckval);
+ return result_code;
+ }
+ key_vtn_t *vtn_okey = reinterpret_cast<key_vtn_t *>(ckey->get_key());
+ key_vtn_flowfilter_entry *vtn_ikey = reinterpret_cast<key_vtn_flowfilter_entry_t *>(ckval->get_key());
+ uuu::upll_strncpy(vtn_okey->vtn_name, vtn_ikey->flowfilter_key.vtn_key.vtn_name,
+ kMaxLenVtnName+1);
+ DbSubOp dbop1 = { kOpReadExist, kOpMatchNone, kOpInOutNone };
+ // Check the vtn already exist in vtn tbl
+ result_code = vtnmgr->UpdateConfigDB(ckey, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
+ &dbop1, MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ UPLL_LOG_DEBUG("vtn already exists");
+ DELETE_IF_NOT_NULL(ckey);
+ ckval = ckval->get_next_cfg_key_val();
+ continue;
+ } else if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ DELETE_IF_NOT_NULL(ckey);
+ DELETE_IF_NOT_NULL(tmp_ckval);
return result_code;
}
- val_vtn_flowfilter_entry_t* val_flowfilter_entry = reinterpret_cast
- <val_vtn_flowfilter_entry_t*>(GetVal(ikey));
- key_flowlist_t *key_flowlist = reinterpret_cast
- <key_flowlist_t *> (flowlist_keyval->get_key());
- uuu::upll_strncpy(key_flowlist->flowlist_name,
- val_flowfilter_entry->flowlist_name,
- (kMaxLenFlowListName + 1));
- result_code = mgr->UpdateConfigDB(flowlist_keyval, UPLL_DT_CANDIDATE,
- UNC_OP_READ, dmi, MAINTBL);
- if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
- delete flowlist_keyval;
- UPLL_LOG_DEBUG("MergeValidate Failed:Conflict occured");
- return UPLL_RC_ERR_MERGE_CONFLICT;
+ // If not same vtn, then merge the vtn ff to candidate tbl
+ result_code = UpdateConfigDB(ckval, UPLL_DT_CANDIDATE, UNC_OP_CREATE,
+ dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("create in CandidateDB failed: err code(%d) ",
+ result_code);
+ DELETE_IF_NOT_NULL(ckey);
+ DELETE_IF_NOT_NULL(tmp_ckval);
+ return result_code;
+ }
+
+ result_code = vtnmgr->GetControllerDomainSpan(ckey, UPLL_DT_IMPORT, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("GetControllerSpan no instance/error (%d)", result_code);
+ DELETE_IF_NOT_NULL(ckey);
+ continue;
+ }
+ }
+ ConfigKeyVal *tmp_ckey = ckey;
+ while (ckey != NULL) {
+ ConfigKeyVal *ctrlckv = NULL;
+ GET_USER_DATA_CTRLR_DOMAIN(ckey, ctrlr_dom);
+ GET_USER_DATA_FLAGS(ckval, flag);
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+
+ UPLL_LOG_DEBUG("flag (%d)", flag);
+
+ GetChildConfigKey(ctrlckv, ckval);
+ SET_USER_DATA_CTRLR_DOMAIN(ctrlckv, ctrlr_dom);
+ SET_USER_DATA_FLAGS(ctrlckv, flag);
+
+ UPLL_LOG_DEBUG("flag (%d)", flag);
+
+ // Create/Update/Delete a record in CANDIDATE DB
+ result_code = UpdateConfigDB(ctrlckv, UPLL_DT_CANDIDATE, UNC_OP_CREATE, dmi, CTRLRTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Err while inserting in ctrlr table for candidateDb(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(tmp_ckey);
+ DELETE_IF_NOT_NULL(tmp_ckval);
+ DELETE_IF_NOT_NULL(ctrlckv);
+ return result_code;
}
- ikey = tkey->get_next_cfg_key_val();
+ DELETE_IF_NOT_NULL(ctrlckv);
+ ckey = ckey->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(tmp_ckey);
+ ckval = ckval->get_next_cfg_key_val();
+}
+ DELETE_IF_NOT_NULL(tmp_ckval);
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtnFlowFilterEntryMoMgr::MergeValidate(unc_key_type_t keytype,
+ const char *ctrlr_id,
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_VTN_FLOWFILTER)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Invalid mgr param");
+ return UPLL_RC_ERR_GENERIC;
}
- delete flowlist_keyval;
+
+ result_code = mgr->MergeValidate(keytype, ctrlr_id, ikey, dmi);
+ UPLL_LOG_DEBUG("MergeValidate result code (%d)", result_code);
return result_code;
}
if (parent_key == NULL) {
vtn_ffe_key = reinterpret_cast <key_vtn_flowfilter_entry_t*>
(ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_entry_t)));
+ // If no direction is specified , 0xFE is filled to bind output direction
+ vtn_ffe_key->flowfilter_key.input_direction = 0xFE;
okey = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_ENTRY,
IpctSt::kIpcStKeyVtnFlowfilterEntry,
vtn_ffe_key, NULL);
if (okey) {
if (okey->get_key_type() != UNC_KT_VTN_FLOWFILTER_ENTRY)
return UPLL_RC_ERR_GENERIC;
+ }
+ if ((okey) && (okey->get_key())) {
vtn_ffe_key = reinterpret_cast<key_vtn_flowfilter_entry_t *>
(okey->get_key());
} else {
vtn_ffe_key = reinterpret_cast<key_vtn_flowfilter_entry_t *>
(ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_entry_t)));
+ // If no direction is specified , 0xFE is filled to bind output direction
+ vtn_ffe_key->flowfilter_key.input_direction = 0xFE;
}
switch (parent_key->get_key_type()) {
case UNC_KT_VTN:
reinterpret_cast<key_vtn_flowfilter_entry_t *>
(pkey)->sequence_num;
break;
+ case UNC_KT_VBR_NWMONITOR:
+ uuu::upll_strncpy(vtn_ffe_key->flowfilter_key.vtn_key.vtn_name,
+ reinterpret_cast<key_vtn_flowfilter_entry_t*>
+ (pkey)->flowfilter_key.vtn_key.vtn_name,
+ (kMaxLenVtnName + 1));
+ break;
default:
if (vtn_ffe_key) free(vtn_ffe_key);
return UPLL_RC_ERR_GENERIC;
}
+
+ if ((okey) && !(okey->get_key())) {
+ UPLL_LOG_DEBUG("okey not null and flow list name updated");
+ okey->SetKey(IpctSt::kIpcStKeyVtnFlowfilterEntry, vtn_ffe_key);
+ }
+
if (!okey)
okey = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_ENTRY,
IpctSt::kIpcStKeyVtnFlowfilterEntry,
}
upll_rc_t VtnFlowFilterEntryMoMgr::GetRenamedControllerKey(
- ConfigKeyVal *&ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
+ ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
controller_domain *ctrlr_dom) {
UPLL_FUNC_TRACE;
ConfigKeyVal *okey = NULL;
upll_rc_t result_code;
- uint8_t rename = 0, rename_flowlist = 0;
- // TODO(UNC) :changed to fix compilation issue
- DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr | kOpMatchDomain,
- kOpInOutCtrlr };
- // Check if VTN is renamed on the controller by getting VTN object
- MoMgrImpl *mgr = static_cast<MoMgrImpl*>
- ((const_cast<MoManager*>
- (GetMoManager(UNC_KT_VTN))));
- result_code = mgr->GetChildConfigKey(okey, NULL);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("GetRenamedControllerKey:GetChildConfigKey returns error");
- return result_code;
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+ UPLL_LOG_TRACE("Start Input ConfigKeyVal %s", ikey->ToStrAll().c_str());
+
+ if (UNC_KT_VTN_FLOWFILTER_CONTROLLER == ikey->get_key_type()) {
+ UPLL_LOG_DEBUG("vtn_pm_ctrl vtn name renamed");
+ MoMgrImpl *vtn_mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>
+ (GetMoManager(UNC_KT_VTN)));
+ if (NULL == vtn_mgr) {
+ UPLL_LOG_DEBUG("mgr NULL");
+ return UPLL_RC_ERR_GENERIC;
}
- // mgr->IsRenamed(ikey, dt_type, dmi, rename);
- result_code = IsRenamed(ikey, dt_type, dmi, rename);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("IsRenamed returns error");
- delete okey;
- return result_code;
- }
- if (!rename) {
- delete okey;
- UPLL_LOG_DEBUG(" Not Renamed ");
- return UPLL_RC_SUCCESS;
- }
- /* Vtn renamed */
- if (rename & 0x01) {
- if (ctrlr_dom == NULL) {
- UPLL_LOG_DEBUG("GetRenamedControllerKey:Controller Name cannot be null");
- delete okey;
+
+ result_code = vtn_mgr->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail (%d)", result_code);
+ return result_code;
+ }
+ if (!okey) return UPLL_RC_ERR_GENERIC;
+
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr | kOpMatchDomain,
+ kOpInOutFlag };
+
+ if (ctrlr_dom) {
+ SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr_dom null");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
- SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
- // Copy the input VTN Name into the Okey and send it for rename check IN db
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
uuu::upll_strncpy(
reinterpret_cast<key_vtn *>(okey->get_key())->vtn_name,
- reinterpret_cast<key_vtn_flowfilter_entry_t *>
- (ikey->get_key())->flowfilter_key.vtn_key.vtn_name,
+ reinterpret_cast<key_vtn_flowfilter_controller_t *>
+ (ikey->get_key())->vtn_key.vtn_name,
(kMaxLenVtnName + 1));
- result_code = mgr->ReadConfigDB(okey,
- dt_type,
- UNC_OP_READ, dbop, dmi, RENAMETBL);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("GetRenamedControllerKey:Read Configuration Error");
+
+ UPLL_LOG_DEBUG("vtn name (%s) (%s)",
+ reinterpret_cast<key_vtn *>(okey->get_key())->vtn_name,
+ reinterpret_cast<key_vtn_flowfilter_controller_t *>
+ (ikey->get_key())->vtn_key.vtn_name);
+
+ result_code = vtn_mgr->ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi,
+ RENAMETBL);
+ if (UPLL_RC_SUCCESS != result_code &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("GetRenamedControllerKey ReadConfigDB error");
+ DELETE_IF_NOT_NULL(okey);
return result_code;
- }
- val_rename_vtn *rename_val =reinterpret_cast <val_rename_vtn *>
- (GetVal(okey));
- if (!rename_val
- || (rename_val->valid[UPLL_IDX_NEW_NAME_RVTN] != UNC_VF_VALID)) {
- UPLL_LOG_DEBUG("Rename structure for VTN is not available");
- return UPLL_RC_ERR_GENERIC;
}
- uuu::upll_strncpy(
- reinterpret_cast<key_vtn_flowfilter_entry_t*>
- (ikey->get_key())->flowfilter_key.vtn_key.vtn_name,
- rename_val->new_name,
- (kMaxLenVtnName + 1));
- SET_USER_DATA_FLAGS(ikey, VTN_RENAME);
- }
- okey = NULL;
- mgr = NULL;
- mgr = static_cast<MoMgrImpl*>
- ((const_cast<MoManager*> (GetMoManager(UNC_KT_FLOWLIST))));
- result_code = mgr->GetChildConfigKey(okey, NULL);
- if (result_code != UPLL_RC_SUCCESS) {
- return result_code;
- }
+ if (UPLL_RC_SUCCESS == result_code) {
+ val_rename_vtn *rename_val =
+ reinterpret_cast<val_rename_vtn *>(GetVal(okey));
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("rename_val NULL");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
- // Copy the input VTN Name into the Okey and send it for rename check IN db
- uuu::upll_strncpy(
- reinterpret_cast<key_flowlist_t *>
- (okey->get_key())->flowlist_name,
- reinterpret_cast<val_vtn_flowfilter_entry_t *> (ikey->get_cfg_val()->
- get_val())->flowlist_name,
- (kMaxLenFlowListName + 1));
- result_code = IsRenamed(ikey, dt_type, dmi, rename_flowlist);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("IsRenamed returns error");
- return result_code;
- }
- if (rename_flowlist == 0) {
- delete okey;
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vtn_flowfilter_controller_t*>
+ (ikey->get_key())->vtn_key.vtn_name,
+ rename_val->new_name,
+ kMaxLenVtnName + 1);
+
+ UPLL_LOG_DEBUG("renamed vtn_pm_ctrl vtn name (%s) (%s)",
+ reinterpret_cast<key_vtn_flowfilter_controller_t*>
+ (ikey->get_key())->vtn_key.vtn_name,
+ rename_val->new_name);
+ }
+ DELETE_IF_NOT_NULL(okey);
+ vtn_mgr = NULL;
return UPLL_RC_SUCCESS;
}
- if (ctrlr_dom)
- SET_USER_DATA_CTRLR(okey, ctrlr_dom->ctrlr);
- result_code = mgr->ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi,
- RENAMETBL); /* ctrlr_name */
+
+ // Check if VTN is renamed on the controller by getting VTN object
+ MoMgrImpl *mgr = static_cast<MoMgrImpl*>
+ ((const_cast<MoManager*>
+ (GetMoManager(UNC_KT_VTN))));
+ result_code = mgr->GetChildConfigKey(okey, NULL);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("GetRenamedControllerKey:Read Configuration Error");
+ UPLL_LOG_DEBUG("GetRenamedControllerKey:GetChildConfigKey returns error");
return result_code;
}
- val_rename_flowlist *rename_val =reinterpret_cast <val_rename_flowlist *>
- (GetVal(okey));
- if (!rename_val || (rename_val->valid[UPLL_IDX_IP_TYPE_FL] != UNC_VF_VALID))
+
+ if (ctrlr_dom == NULL) {
+ UPLL_LOG_DEBUG("ctrlr_dom null");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
- uuu::upll_strncpy(
- reinterpret_cast<val_vtn_flowfilter_entry_t*>
- (ikey->get_cfg_val()->get_val())->flowlist_name,
- rename_val->flowlist_newname,
- (kMaxLenFlowListName + 1));
- SET_USER_DATA_FLAGS(ikey, rename_flowlist);
- return UPLL_RC_SUCCESS;
-}
+ }
+ SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
-upll_rc_t VtnFlowFilterEntryMoMgr::GetRenamedUncKey(
- ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
- uint8_t *ctrlr_id) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
- ConfigKeyVal *unc_key = NULL;
- DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
- key_vtn *rename_vtn_key = reinterpret_cast <key_vtn*>
- (ConfigKeyVal::Malloc(sizeof(key_vtn)));
+ // Copy the input VTN Name into the Okey and send it for rename check IN db
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vtn *>(okey->get_key())->vtn_name,
+ reinterpret_cast<key_vtn_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.vtn_key.vtn_name,
+ (kMaxLenVtnName + 1));
- key_vtn_flowfilter_entry_t *ctrlr_key = reinterpret_cast
- <key_vtn_flowfilter_entry_t *> (ikey->get_key());
+ UPLL_LOG_DEBUG("vtn name (%s) (%s)",
+ reinterpret_cast<key_vtn *>(okey->get_key())->vtn_name,
+ reinterpret_cast<key_vtn_flowfilter_entry_t *>
+ (ikey->get_key())->flowfilter_key.vtn_key.vtn_name)
- uuu::upll_strncpy(rename_vtn_key->vtn_name,
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr | kOpMatchDomain, kOpInOutFlag };
+ result_code = mgr->ReadConfigDB(okey,
+ dt_type,
+ UNC_OP_READ, dbop, dmi, RENAMETBL);
+ if (UPLL_RC_SUCCESS != result_code && UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("GetRenamedControllerKey:Read Configuration Error");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ if (UPLL_RC_SUCCESS == result_code) {
+ val_rename_vtn *rename_val =reinterpret_cast <val_rename_vtn *>
+ (GetVal(okey));
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("Rename structure for VTN is not available");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vtn_flowfilter_entry_t*>
+ (ikey->get_key())->flowfilter_key.vtn_key.vtn_name,
+ rename_val->new_name,
+ (kMaxLenVtnName + 1));
+ }
+ DELETE_IF_NOT_NULL(okey);
+ val_vtn_flowfilter_entry_t *val_vtn_flofilter_entry =reinterpret_cast
+ <val_vtn_flowfilter_entry_t *>(GetVal(ikey));
+ if (val_vtn_flofilter_entry) {
+ if (UNC_VF_VALID == val_vtn_flofilter_entry
+ ->valid[UPLL_IDX_FLOWLIST_NAME_VFFE]) {
+ // Flowlist is Renamed
+ MoMgrImpl *mgr_flowlist = static_cast<MoMgrImpl*>
+ ((const_cast<MoManager*> (GetMoManager(UNC_KT_FLOWLIST))));
+
+ result_code = mgr_flowlist->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
+ }
+
+ if (NULL != ctrlr_dom) {
+ SET_USER_DATA_CTRLR(okey, ctrlr_dom->ctrlr);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+ if (!GetVal(ikey))
+ return UPLL_RC_SUCCESS;
+ uuu::upll_strncpy(
+ reinterpret_cast<key_flowlist_t *>
+ (okey->get_key())->flowlist_name,
+ reinterpret_cast<val_vtn_flowfilter_entry_t *> (ikey->get_cfg_val()->
+ get_val())->flowlist_name,
+ (kMaxLenFlowListName + 1));
+ UPLL_LOG_DEBUG("flowlist name (%s) (%s)",
+ reinterpret_cast<key_flowlist_t *>
+ (okey->get_key())->flowlist_name,
+ reinterpret_cast<val_vtn_flowfilter_entry_t *> (ikey->get_cfg_val()->
+ get_val())->flowlist_name);
+ DbSubOp dbop1 = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
+ result_code = mgr_flowlist->ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop1, dmi,
+ RENAMETBL); /* ctrlr_name */
+ if (UPLL_RC_SUCCESS != result_code && UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("GetRenamedControllerKey:Read Configuration Error");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ if (UPLL_RC_SUCCESS == result_code) {
+ val_rename_flowlist *rename_val =reinterpret_cast <val_rename_flowlist *>
+ (GetVal(okey));
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("flowlist is not valid");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ uuu::upll_strncpy(
+ reinterpret_cast<val_vtn_flowfilter_entry_t*>
+ (ikey->get_cfg_val()->get_val())->flowlist_name,
+ rename_val->flowlist_newname,
+ (kMaxLenFlowListName + 1));
+ //SET_USER_DATA_FLAGS(ikey, rename);
+ }
+ }
+ }
+ DELETE_IF_NOT_NULL(okey);
+ UPLL_LOG_TRACE("End Input ConfigKeyVal %s",
+ ikey->ToStrAll().c_str());
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtnFlowFilterEntryMoMgr::GetRenamedUncKey(
+ ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
+ uint8_t *ctrlr_id) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+ ConfigKeyVal *unc_key = NULL;
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vtnffentry start",
+ ikey->ToStrAll().c_str());
+ if ((ikey == NULL) || (ctrlr_id == NULL) || (dmi == NULL)) {
+ UPLL_LOG_DEBUG("ikey/ctrlr_id dmi NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val_rename_vtn *rename_vtn_key = reinterpret_cast <val_rename_vtn*>
+ (ConfigKeyVal::Malloc(sizeof(val_rename_vtn)));
+
+ if (!rename_vtn_key) {
+ UPLL_LOG_DEBUG("rename_vtn_key NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ key_vtn_flowfilter_entry_t *ctrlr_key = reinterpret_cast
+ <key_vtn_flowfilter_entry_t *> (ikey->get_key());
+ if (!ctrlr_key) {
+ UPLL_LOG_DEBUG("ctrlr_key NULL");
+ if (rename_vtn_key) free(rename_vtn_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ uuu::upll_strncpy(rename_vtn_key->new_name,
ctrlr_key->flowfilter_key.vtn_key.vtn_name,
(kMaxLenVtnName + 1));
+ rename_vtn_key->valid[UPLL_IDX_NEW_NAME_RVTN] = UNC_VF_VALID;
+
MoMgrImpl *mgr = static_cast<MoMgrImpl*>
((const_cast<MoManager*>
(GetMoManager(UNC_KT_VTN))));
+ if (!mgr) {
+ UPLL_LOG_TRACE("mgr failed");
+ if (rename_vtn_key) free(rename_vtn_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
result_code = mgr->GetChildConfigKey(unc_key, NULL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetRenamedUnckey:GetChildConfigKey returned error");
free(rename_vtn_key);
+ mgr = NULL;
return result_code;
}
- if (ctrlr_id == NULL) {
- UPLL_LOG_DEBUG("GetRenamedUncKey:Controller Name cannot be be null");
+ if (!unc_key) {
+ UPLL_LOG_DEBUG("unc_key NULL");
free(rename_vtn_key);
- delete unc_key;
+ mgr = NULL;
return UPLL_RC_ERR_GENERIC;
}
SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
unc_key->AppendCfgVal(IpctSt::kIpcStValRenameVtn, rename_vtn_key);
result_code = mgr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop,
dmi, RENAMETBL);
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(unc_key);
+ mgr = NULL;
+ return result_code;
+ }
+
if (result_code == UPLL_RC_SUCCESS) {
key_vtn *vtn_key = reinterpret_cast<key_vtn *> (unc_key->get_key());
uuu::upll_strncpy(ctrlr_key->flowfilter_key.vtn_key.vtn_name,
vtn_key->vtn_name,
(kMaxLenVtnName + 1));
}
- unc_key = NULL;
+ mgr = NULL;
+ DELETE_IF_NOT_NULL(unc_key);
val_rename_flowlist *rename_fl =reinterpret_cast<val_rename_flowlist*>
(ConfigKeyVal::Malloc(sizeof(val_rename_flowlist)));
-
+ if (!rename_fl) {
+ UPLL_LOG_DEBUG("rename_fl NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
val_vtn_flowfilter_entry_t *val_vtn_flofilter_entry =reinterpret_cast
<val_vtn_flowfilter_entry_t *>(GetVal(ikey));
+ if (!val_vtn_flofilter_entry) {
+ UPLL_LOG_DEBUG("val_vtn_flofilter_entry NULL");
+ free(rename_fl);
+ return UPLL_RC_SUCCESS;
+ }
+ if (UNC_VF_VALID != val_vtn_flofilter_entry
+ ->valid[UPLL_IDX_FLOWLIST_NAME_VFFE]) {
+ UPLL_LOG_DEBUG("flowlist invalid");
+ free(rename_fl);
+ return UPLL_RC_SUCCESS;
+ }
uuu::upll_strncpy(rename_fl->flowlist_newname,
val_vtn_flofilter_entry->flowlist_name,
(kMaxLenFlowListName + 1));
+ rename_fl->valid[UPLL_IDX_RENAME_FLOWLIST_RFL] = UNC_VF_VALID;
+
mgr = static_cast<MoMgrImpl*>
((const_cast<MoManager*>
(GetMoManager(UNC_KT_FLOWLIST))));
+ if (!mgr) {
+ UPLL_LOG_TRACE("mgr failed");
+ if (rename_fl) free(rename_fl);
+ return UPLL_RC_ERR_GENERIC;
+ }
result_code = mgr->GetChildConfigKey(unc_key, NULL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetChildConfigKey Returned an error");
free(rename_fl);
- delete unc_key;
+ mgr = NULL;
return result_code;
}
+ if (!unc_key) {
+ UPLL_LOG_DEBUG("unc_key NULL");
+ free(rename_fl);
+ mgr = NULL;
+ return UPLL_RC_ERR_GENERIC;
+ }
SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
unc_key->AppendCfgVal(IpctSt::kIpcStValRenameFlowlist, rename_fl);
result_code = mgr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL);
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(unc_key);
+ mgr = NULL;
+ return result_code;
+ }
+
if (result_code == UPLL_RC_SUCCESS) {
key_flowlist_t *key_flowlist = reinterpret_cast
<key_flowlist_t *>(unc_key->get_key());
key_flowlist->flowlist_name,
(kMaxLenFlowListName + 1));
}
- return result_code;
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vtnffentry end",
+ ikey->ToStrAll().c_str());
+ DELETE_IF_NOT_NULL(unc_key);
+ mgr = NULL;
+ return UPLL_RC_SUCCESS;
}
upll_rc_t VtnFlowFilterEntryMoMgr::DupConfigKeyVal(ConfigKeyVal *&okey,
unc_keytype_operation_t op[] = { UNC_OP_DELETE, UNC_OP_CREATE,
UNC_OP_UPDATE };
int nop = sizeof(op) / sizeof(op[0]);
- ConfigKeyVal *vtn_ffe_key = NULL, *req = NULL, *nreq = NULL;
+ ConfigKeyVal *vtn_ffe_key = NULL, *req = NULL, *nreq = NULL ,
+ *vtn_ffe_run_key = NULL , *vtn_ffe_run_ctrl_key = NULL, *vtn_ck_run= NULL;
DalCursor *cfg1_cursor = NULL;
uint8_t *ctrlr_id = NULL;
for (int i = 0; i < nop; i++) {
if (op[i] != UNC_OP_UPDATE) {
result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i], req,
- nreq, &cfg1_cursor, dmi, MAINTBL);
+ nreq, &cfg1_cursor, dmi, NULL, MAINTBL, true);
while (result_code == UPLL_RC_SUCCESS) {
db_result = dmi->GetNextRecord(cfg1_cursor);
result_code = DalToUpllResCode(db_result);
nreq, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Updating Main table Error %d", result_code);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
}
for (int i = 0; i < nop; i++) {
MoMgrTables tbl = (op[i] == UNC_OP_UPDATE)?MAINTBL:CTRLRTBL;
result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i], req,
- nreq, &cfg1_cursor, dmi, tbl);
+ nreq, &cfg1_cursor, dmi, NULL, tbl, true);
ConfigKeyVal *vtn_ffe_ctrlr_key = NULL;
while (result_code == UPLL_RC_SUCCESS) {
db_result = dmi->GetNextRecord(cfg1_cursor);
}
if (op[i] == UNC_OP_UPDATE) {
DbSubOp dbop = { kOpReadMultiple, kOpMatchNone,
- kOpInOutCtrlr|kOpInOutDomain };
+ kOpInOutCtrlr|kOpInOutDomain | kOpInOutCs };
result_code = GetChildConfigKey(vtn_ffe_ctrlr_key, req);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
result_code);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
- result_code = ReadConfigDB(vtn_ffe_ctrlr_key, UPLL_DT_CANDIDATE,
+ result_code = ReadConfigDB(vtn_ffe_ctrlr_key,UPLL_DT_CANDIDATE,
UNC_OP_READ, dbop, dmi, CTRLRTBL);
if (result_code != UPLL_RC_SUCCESS) {
delete vtn_ffe_ctrlr_key;
continue;
}
} else {
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
}
-
- result_code = DupConfigKeyVal(vtn_ffe_key, req, tbl);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("DupConfigKeyVal is failed result_code = %d",
- result_code);
- return result_code;
- }
-
- GET_USER_DATA_CTRLR(vtn_ffe_ctrlr_key, ctrlr_id);
- string controller(reinterpret_cast<char *> (ctrlr_id));
for (ConfigKeyVal *tmp = vtn_ffe_ctrlr_key; tmp != NULL;
tmp = tmp->get_next_cfg_key_val()) {
+ GET_USER_DATA_CTRLR(tmp, ctrlr_id);
+ string controller(reinterpret_cast<char *> (ctrlr_id));
+ UPLL_LOG_DEBUG("Controller ID =%s", controller.c_str());
+ DbSubOp dbop_maintbl = { kOpReadSingle, kOpMatchNone,
+ kOpInOutFlag |kOpInOutCs };
+ DbSubOp dbop_ctrtbl = { kOpReadSingle, kOpMatchCtrlr |
+ kOpMatchDomain, kOpInOutFlag | kOpInOutCs };
+ result_code = GetChildConfigKey(vtn_ffe_key, req);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
+ result_code);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+ result_code = ReadConfigDB(vtn_ffe_key,UPLL_DT_CANDIDATE ,
+ UNC_OP_READ, dbop_maintbl, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to read configuration from CandidateDb");
+ DELETE_IF_NOT_NULL(vtn_ffe_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+ static_cast<val_vtn_flowfilter_entry_t *>
+ (GetVal(vtn_ffe_key))->cs_row_status =
+ static_cast<val_vtn_flowfilter_entry_t *>
+ (GetVal(nreq))->cs_row_status;
+ // For Reading The Main table for config status
+ result_code = GetChildConfigKey(vtn_ffe_run_key, req);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
+ result_code);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+ result_code = ReadConfigDB(vtn_ffe_run_key, UPLL_DT_RUNNING ,
+ UNC_OP_READ, dbop_maintbl, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to read configuration from RunningDB");
+ DELETE_IF_NOT_NULL(vtn_ffe_key);
+ DELETE_IF_NOT_NULL(vtn_ffe_run_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+ // For Reading The controller table for config status
+ result_code = GetChildConfigKey(vtn_ffe_run_ctrl_key, tmp);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
+ result_code);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+ result_code = ReadConfigDB(vtn_ffe_run_ctrl_key, UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop_ctrtbl, dmi, CTRLRTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to read configuration from RunningDb");
+ DELETE_IF_NOT_NULL(vtn_ffe_key);
+ DELETE_IF_NOT_NULL(vtn_ffe_run_key);
+ DELETE_IF_NOT_NULL(vtn_ffe_run_ctrl_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+ val_vtn_flowfilter_entry_ctrlr *val_ctrlr_can = reinterpret_cast
+ <val_vtn_flowfilter_entry_ctrlr *>(GetVal(tmp));
+ val_vtn_flowfilter_entry_ctrlr *val_ctrlr_run = reinterpret_cast
+ <val_vtn_flowfilter_entry_ctrlr *>(GetVal(vtn_ffe_run_ctrl_key));
+ val_ctrlr_can->cs_row_status =val_ctrlr_run->cs_row_status;
+
+ for (unsigned int loop = 0; loop < sizeof(val_ctrlr_run->valid)/
+ sizeof(val_ctrlr_run->valid[0]); ++loop) {
+ val_ctrlr_can->cs_attr[loop] = val_ctrlr_run->cs_attr[loop];
+ }
+ // End Reading The controller table for config status
+ val_vtn_flowfilter_entry_t *val_main_can = reinterpret_cast
+ <val_vtn_flowfilter_entry_t *>(GetVal(vtn_ffe_key));
+ val_vtn_flowfilter_entry_t *val_main = reinterpret_cast
+ <val_vtn_flowfilter_entry_t *>(GetVal(vtn_ffe_run_key));
+
+ for (unsigned int loop = 0; loop < sizeof(val_main->valid)/
+ sizeof(val_main->valid[0]); ++loop) {
+ val_main_can->cs_attr[loop] = val_main->cs_attr[loop];
+ }
+ DELETE_IF_NOT_NULL(vtn_ffe_run_ctrl_key);
result_code = UpdateConfigStatus(vtn_ffe_key, op[i],
ctrlr_result[controller],
nreq, dmi, tmp);
UPLL_LOG_DEBUG("UpdateConfigStatus failed, err %d", result_code);
break;
}
-
- void *vtnffe_ctrlval = GetVal(vtn_ffe_ctrlr_key);
- CompareValidValue(vtnffe_ctrlval, GetVal(nreq), false);
- result_code = UpdateConfigDB(vtn_ffe_ctrlr_key,
- UPLL_DT_RUNNING, op[i], dmi, CTRLRTBL);
+ DELETE_IF_NOT_NULL(vtn_ffe_run_key);
+ DELETE_IF_NOT_NULL(vtn_ffe_run_ctrl_key);
+ void *vtnffe_ctrlval = GetVal(tmp);
+ CompareValidVal(vtnffe_ctrlval, GetVal(nreq), GetVal(req), false);
+ result_code = UpdateConfigDB(tmp, UPLL_DT_RUNNING,
+ op[i], dmi, CTRLRTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("!!! Failed to Update the controller table, err %d",
result_code);
+ DELETE_IF_NOT_NULL(vtn_ffe_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
result_code = UpdateConfigDB(vtn_ffe_key,
UPLL_DT_RUNNING, op[i], dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Update to Main table failed %d\n", result_code);
+ UPLL_LOG_DEBUG("Update to Main table failed %d", result_code);
+ DELETE_IF_NOT_NULL(vtn_ffe_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
EnqueCfgNotification(op[i], UPLL_DT_RUNNING,
vtn_ffe_key);
+ DELETE_IF_NOT_NULL(vtn_ffe_key);
}
} else {
- if (op[i] == UNC_OP_CREATE) {
- DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag };
+ if (op[i] == UNC_OP_CREATE ) {
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag
+ | kOpInOutCs };
result_code = GetChildConfigKey(vtn_ffe_key, req);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
result_code);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
- result_code = ReadConfigDB(vtn_ffe_key, UPLL_DT_CANDIDATE,
+ result_code = ReadConfigDB(vtn_ffe_key, UPLL_DT_RUNNING ,
UNC_OP_READ, dbop, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE ) {
UPLL_LOG_DEBUG("Unable to read configuration from CandidateDb");
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
-
result_code = DupConfigKeyVal(vtn_ffe_ctrlr_key, req, tbl);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Failed to create duplicate ConfigKeyVal Err (%d)",
result_code);
delete vtn_ffe_key;
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
+ // set consolidated config status to UNKNOWN to init vtn cs_status
+ // to the cs_status of first controller
+ uint32_t cur_instance_count;
+ result_code = GetInstanceCount(vtn_ffe_key, NULL,
+ UPLL_DT_CANDIDATE, &cur_instance_count,
+ dmi, CTRLRTBL);
+ if ((result_code == UPLL_RC_SUCCESS) && (cur_instance_count == 1))
+ reinterpret_cast<val_vtn_flowfilter_entry*>
+ (GetVal(vtn_ffe_key))->cs_row_status = UNC_CS_UNKNOWN ;
GET_USER_DATA_CTRLR(vtn_ffe_ctrlr_key, ctrlr_id);
string controller(reinterpret_cast<char *> (ctrlr_id));
result_code = UpdateConfigStatus(vtn_ffe_key, op[i],
- ctrlr_result[controller], NULL,
- dmi, vtn_ffe_ctrlr_key);
+ ctrlr_result[controller], nreq ,
+ dmi,vtn_ffe_ctrlr_key );
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Error in updating configstatus, resultcode=%d",
- result_code);
- delete vtn_ffe_ctrlr_key;
+ result_code);
+ DELETE_IF_NOT_NULL(vtn_ffe_ctrlr_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
} else if (op[i] == UNC_OP_DELETE) {
+ // Reading Main Running DB for delete op
+ DbSubOp dbop1 = { kOpReadSingle, kOpMatchNone, kOpInOutFlag
+ | kOpInOutCs };
+ result_code = GetChildConfigKey(vtn_ck_run, req);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
+ result_code);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ result_code = ReadConfigDB(vtn_ck_run, UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop1, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Unable to read configuration from CandidateDb");
+ DELETE_IF_NOT_NULL(vtn_ck_run);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ GET_USER_DATA_CTRLR(req, ctrlr_id);
+ if (result_code == UPLL_RC_SUCCESS) {
+ result_code = SetVtnFFEntryConsolidatedStatus(vtn_ck_run,
+ ctrlr_id, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Could not set consolidated status %d",
+ result_code);
+ DELETE_IF_NOT_NULL(vtn_ck_run);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+ }
+ DELETE_IF_NOT_NULL(vtn_ck_run);
result_code = GetChildConfigKey(vtn_ffe_ctrlr_key, req);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Error in getting the configkey, resultcode=%d",
result_code);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(vtn_ck_run);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
}
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("DB Error while updating controller table. err:%d",
result_code);
- delete vtn_ffe_ctrlr_key;
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(vtn_ck_run);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(vtn_ffe_ctrlr_key);
return result_code;
}
if (op[i] != UNC_OP_DELETE) {
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("UpdateConfigDB in main tbl is failed -%d",
result_code);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(vtn_ck_run);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(vtn_ffe_key);
return result_code;
}
}
}
// delete vtn_flowfilter_entry_ctrlr_key;
if (vtn_ffe_key) delete vtn_ffe_key;
+ DELETE_IF_NOT_NULL(vtn_ffe_ctrlr_key);
vtn_ffe_key = vtn_ffe_ctrlr_key = NULL;
result_code = DalToUpllResCode(db_result);
}
UPLL_LOG_DEBUG("TxCopy returned with resultcode %d", result_code);
return result_code;
}
+
+ upll_rc_t
+ VtnFlowFilterEntryMoMgr::SetVtnFFEntryConsolidatedStatus(ConfigKeyVal *ikey,
+ uint8_t *ctrlr_id,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ctrlr_ckv = NULL;
+ val_vtn_flowfilter_entry_ctrlr *ctrlr_val = NULL;
+ uint8_t *vtn_ffe_exist_on_ctrlr = NULL;
+ bool applied = false, not_applied = false, invalid = false;
+ unc_keytype_configstatus_t c_status = UNC_CS_NOT_APPLIED;
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone,
+ kOpInOutCtrlr | kOpInOutDomain | kOpInOutCs };
+ if (!ikey || !dmi) {
+ UPLL_LOG_DEBUG("Invalid Input");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = GetChildConfigKey(ctrlr_ckv, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed err code %d", result_code);
+ return result_code;
+ }
+ result_code = ReadConfigDB(ctrlr_ckv, UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop, dmi,
+ CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB from ctrltbl failed err code %d",
+ result_code);
+ delete ctrlr_ckv;
+ return result_code;
+ }
+
+ for (ConfigKeyVal *tmp = ctrlr_ckv; tmp != NULL;
+ tmp = tmp->get_next_cfg_key_val()) {
+
+ ctrlr_val = reinterpret_cast<val_vtn_flowfilter_entry_ctrlr *>
+ (GetVal(tmp));
+ if (!ctrlr_val) {
+ UPLL_LOG_DEBUG("Controller Value is empty");
+ tmp = NULL;
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ GET_USER_DATA_CTRLR(tmp, vtn_ffe_exist_on_ctrlr);
+ UPLL_LOG_DEBUG("Controllername from DB %s", vtn_ffe_exist_on_ctrlr);
+ if (!strcmp(reinterpret_cast<char *>(vtn_ffe_exist_on_ctrlr),
+ reinterpret_cast<char *>(ctrlr_id)))
+ continue; // skipping entry of deleted controller
+
+ switch (ctrlr_val->cs_row_status) {
+ case UNC_CS_APPLIED:
+ applied = true;
+ break;
+ case UNC_CS_NOT_APPLIED:
+ not_applied = true;
+ break;
+ case UNC_CS_INVALID:
+ invalid = true;
+ break;
+ default:
+ UPLL_LOG_DEBUG("Invalid status");
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ // return UPLL_RC_ERR_GENERIC;
+ }
+ vtn_ffe_exist_on_ctrlr = NULL;
+ }
+ if (invalid) {
+ c_status = UNC_CS_INVALID;
+ } else if (applied && !not_applied) {
+ c_status = UNC_CS_APPLIED;
+ } else if (!applied && not_applied) {
+ c_status = UNC_CS_NOT_APPLIED;
+ } else if (applied && not_applied) {
+ c_status = UNC_CS_PARTIALLY_APPLIED;
+ } else {
+ c_status = UNC_CS_APPLIED;
+ }
+ applied = not_applied = false;
+ // Set cs_status
+ val_vtn_flowfilter_entry_t *vtn_ffe_val =
+ static_cast<val_vtn_flowfilter_entry_t *>(GetVal(ikey));
+ vtn_ffe_val->cs_row_status = c_status;
+ for (unsigned int loop = 0; loop < sizeof(vtn_ffe_val->valid)/
+ sizeof(vtn_ffe_val->valid[0]); ++loop) {
+ for (ConfigKeyVal *tmp = ctrlr_ckv; tmp != NULL;
+ tmp = tmp->get_next_cfg_key_val()) {
+ ctrlr_val = reinterpret_cast<val_vtn_flowfilter_entry_ctrlr *>(GetVal(tmp));
+
+ GET_USER_DATA_CTRLR(tmp, vtn_ffe_exist_on_ctrlr);
+ if (!strcmp(reinterpret_cast<char *>(vtn_ffe_exist_on_ctrlr),
+ reinterpret_cast<char *>(ctrlr_id)))
+ continue; // skipping entry of deleted controller
+ if (ctrlr_val->valid[loop] == UNC_VF_VALID) {
+ switch (ctrlr_val->cs_attr[loop]) {
+ case UNC_CS_APPLIED:
+ applied = true;
+ break;
+ case UNC_CS_NOT_APPLIED:
+ not_applied = true;
+ break;
+ case UNC_CS_INVALID:
+ invalid = true;
+ break;
+ default:
+ UPLL_LOG_DEBUG("Invalid status %d", ctrlr_val->cs_attr[loop]);
+ }
+ }
+ }
+ if (invalid) {
+ c_status = UNC_CS_INVALID;
+ } else if (applied && !not_applied) {
+ c_status = UNC_CS_APPLIED;
+ } else if (!applied && not_applied) {
+ c_status = UNC_CS_NOT_APPLIED;
+ } else if (applied && not_applied) {
+ c_status = UNC_CS_PARTIALLY_APPLIED;
+ } else {
+ c_status = UNC_CS_APPLIED;
+ }
+ vtn_ffe_val->cs_attr[loop] = c_status;
+ applied = not_applied =false;
+ }
+
+
+ DbSubOp dbop_update = {kOpNotRead, kOpMatchNone, kOpInOutCs};
+ result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_UPDATE, dmi,
+ &dbop_update, MAINTBL);
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return result_code;
+}
+#if 0
upll_rc_t VtnFlowFilterEntryMoMgr::UpdateConfigStatus(
ConfigKeyVal *vtn_flow_filter_entry_key, unc_keytype_operation_t op,
uint32_t driver_result, ConfigKeyVal *nreq, DalDmlIntf *dmi,
case UNC_CS_UNKNOWN:
status = cs_status;
break;
- case UNC_CS_PARTAILLY_APPLIED:
+ case UNC_CS_PARTIALLY_APPLIED:
if (ctrlr_val_ff_entry->cs_row_status
== UNC_CS_NOT_APPLIED) {
// if this vtn has caused it then to change to applied.
case UNC_CS_INVALID:
default:
status =
- (cs_status == UNC_CS_APPLIED) ? UNC_CS_PARTAILLY_APPLIED : status;
+ (cs_status == UNC_CS_APPLIED) ? UNC_CS_PARTIALLY_APPLIED : status;
break;
}
vtn_ff_entry_val->cs_row_status = status;
for (unsigned int loop = 0; loop <
sizeof(vtn_ff_entry_val->valid) /sizeof(vtn_ff_entry_val->valid[0]);
++loop) {
- if (UNC_VF_NOT_SOPPORTED == vtn_ff_entry_val->valid[loop]) {
+ if (UNC_VF_NOT_SUPPORTED == vtn_ff_entry_val->valid[loop]) {
vtn_ff_entry_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
continue;
}
- if (UNC_VF_NOT_SOPPORTED == ctrlr_val_ff_entry->valid[loop]) {
+ if (UNC_VF_NOT_SUPPORTED == ctrlr_val_ff_entry->valid[loop]) {
ctrlr_val_ff_entry->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
continue;
}
if ((UNC_VF_VALID == vtn_ff_entry_val->valid[loop]) ||
(UNC_VF_VALID_NO_VALUE == vtn_ff_entry_val->valid[loop]))
- if (ctrlr_val_ff_entry->valid[loop] != UNC_VF_NOT_SOPPORTED) {
+ if (ctrlr_val_ff_entry->valid[loop] != UNC_VF_NOT_SUPPORTED) {
ctrlr_val_ff_entry->cs_attr[loop] = cs_status;
vtn_ff_entry_val->cs_attr[loop] =
static_cast<uint8_t>(vtn_ff_entry_val->cs_row_status);
loop < sizeof(ctrlr_val_ff_entry->valid) / sizeof(
ctrlr_val_ff_entry->valid[0]);
++loop) {
- if (ctrlr_val_ff_entry->valid[loop] != UNC_VF_NOT_SOPPORTED) {
+ if (ctrlr_val_ff_entry->valid[loop] != UNC_VF_NOT_SUPPORTED) {
ctrlr_val_ff_entry->cs_attr[loop] = cs_status;
} else {
ctrlr_val_ff_entry->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
}
return result_code;
}
+#endif
upll_rc_t VtnFlowFilterEntryMoMgr::UpdateAuditConfigStatus(
unc_keytype_configstatus_t cs_status,
uuc::UpdateCtrlrPhase phase,
ConfigKeyVal *&ckv_running) {
upll_rc_t result_code = UPLL_RC_SUCCESS;
- val_vtn_flowfilter_entry_t *val;
+ val_vtn_flowfilter_entry_ctrlr *val;
val = (ckv_running != NULL)?
- reinterpret_cast<val_vtn_flowfilter_entry_t *>(GetVal(ckv_running)):
- NULL;
+ reinterpret_cast<val_vtn_flowfilter_entry_ctrlr *>
+ (GetVal(ckv_running)):NULL;
if (NULL == val) {
return UPLL_RC_ERR_GENERIC;
}
if (uuc::kUpllUcpCreate == phase )
- val->cs_row_status = cs_status;
+ val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
for (unsigned int loop = 0;
loop < sizeof(val->valid)/sizeof(uint8_t); ++loop) {
- if (cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop])
- val->cs_attr[loop] = cs_status;
- else if (cs_status == UNC_CS_APPLIED)
- val->cs_attr[loop] = cs_status;
+ if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
+ cs_status == UNC_CS_APPLIED)
+ val->cs_attr[loop] = cs_status;
}
return result_code;
}
DalDmlIntf *dmi) {
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *ckv = NULL;
- DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutNone};
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutCs};
result_code = GetChildConfigKey(ckv, ikey);
if (UPLL_RC_SUCCESS != result_code) {
return result_code;
std::vector<list<unc_keytype_configstatus_t> > vec_attr;
std::list< unc_keytype_configstatus_t > list_cs_row;
std::list< unc_keytype_configstatus_t > list_cs_attr;
- val_vtn_flowfilter_entry_t *val;
+ val_vtn_flowfilter_entry_ctrlr *val;
for (unsigned int loop = 0; loop < sizeof(val->valid)/sizeof(val->valid[0]);
++loop) {
std::list< unc_keytype_configstatus_t > list_attr;
vec_attr.push_back(list_attr);
}
-
- for (; ckv != NULL; ckv = ckv->get_next_cfg_key_val()) {
- val = reinterpret_cast<val_vtn_flowfilter_entry_t*>(GetVal(ckv));
+ ConfigKeyVal *temp_ckv = ckv;
+ for (; temp_ckv != NULL; temp_ckv = temp_ckv->get_next_cfg_key_val()) {
+ val = reinterpret_cast<val_vtn_flowfilter_entry_ctrlr*>
+ (GetVal(temp_ckv));
list_cs_row.push_back((unc_keytype_configstatus_t)val->cs_row_status);
for (unsigned int loop = 0;
loop < sizeof(val->valid)/sizeof(val->valid[0]);
(unc_keytype_configstatus_t)val->cs_attr[loop]);
}
}
+ DELETE_IF_NOT_NULL(ckv);
val_vtn_flowfilter_entry_t *val_temp =
reinterpret_cast<val_vtn_flowfilter_entry_t *>(GetVal(ikey));
val_temp->cs_row_status = GetConsolidatedCsStatus(list_cs_row);
++loop) {
val_temp->cs_attr[loop] = GetConsolidatedCsStatus(vec_attr[loop]);
}
- result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_UPDATE,
- dmi, MAINTBL);
+ result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING,
+ UNC_OP_UPDATE, dmi, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
return result_code;
}
return result_code;
}
+
upll_rc_t VtnFlowFilterEntryMoMgr::ValidateAttribute(ConfigKeyVal *ikey,
DalDmlIntf *dmi,
IpcReqRespHeader *req) {
delete okey;
okey = NULL;
} // nwm_name is valid
+ result_code = SetRenameFlag(ikey, dmi, req);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("SetRenameFlag failed %d", result_code);
+ return result_code;
+ }
UPLL_LOG_DEBUG("ValidateAttribute Successfull.");
return result_code;
}
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
controller_domain ctrlr_dom;
-
+ ConfigKeyVal *okey = NULL;
DbSubOp dbop1 = { kOpReadExist, kOpMatchNone, kOpInOutNone};
key_vtn_flowfilter_controller_t *key_vtn_flowfilter_ctrl =
reinterpret_cast<key_vtn_flowfilter_controller_t*>(ikey->get_key());
+
key_vtn_flowfilter_entry_t *key_vtn_ffe_ctrl =
reinterpret_cast <key_vtn_flowfilter_entry_t*>
(ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_entry_t)));
key_vtn_flowfilter_ctrl->vtn_key.vtn_name,
(kMaxLenVtnName +1));
+ key_vtn_ffe_ctrl->flowfilter_key.input_direction = 0xFE;
+ // vtn is not configured in vtn_ff_entry main tbl
+ // only vtn/vbr is configured and commited
+ result_code = UpdateConfigDB(dup_ckmain, req->datatype,
+ UNC_OP_READ, dmi, &dbop1, MAINTBL);
+ if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
+ UPLL_LOG_DEBUG("Requested Vtn is Not Configured in"
+ "flowfilterEntryMain Table in Candidate %d", result_code);
+ DELETE_IF_NOT_NULL(dup_ckmain);
+ return result_code;
+ }
+ // vtn is not configured in vtn_ff_entry ctrlr tbl
+ // vtn/ff/entry is configured but no vbr is configured
+
+ // Setting direction again to 0XFE
+ // because it will be set to 0 in updateconfigDB
key_vtn_ffe_ctrl->flowfilter_key.input_direction = 0xFE;
result_code = UpdateConfigDB(dup_ckmain, req->datatype,
UNC_OP_READ, dmi, &dbop1, CTRLRTBL);
- if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ if (result_code !=UPLL_RC_ERR_INSTANCE_EXISTS) {
UPLL_LOG_DEBUG("Requested Vtn is Not Configured in"
"flowfilterEntryCtrlr Table %d", result_code);
+ DELETE_IF_NOT_NULL(dup_ckmain);
return UPLL_RC_ERR_NOT_ALLOWED_AT_THIS_TIME;
}
-
+ DELETE_IF_NOT_NULL(dup_ckmain);
switch (req->datatype) {
case UPLL_DT_STATE:
if ((req->option1 == UNC_OPT1_NORMAL) &&
uuu::upll_strncpy(ctrlr_dom.domain,
key_vtn_flowfilter_ctrl->domain_id,
(kMaxLenDomainId + 1));
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Key not supported by controller ReadMo ");
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
+ return result_code;
+ }
ConfigVal *tmp1 = NULL;
val_flowfilter_controller_t *l_val =reinterpret_cast
UNC_KT_VTN_FLOWFILTER_CONTROLLER,
IpctSt::kIpcStKeyVtnFlowfilterController,
l_key_vtn_flowfilter_ctrl, tmp1);
-#if 0
+ // verifying given reuest is existing in vtn_ff_entry_tbl or not
+ key_vtn_flowfilter_entry_t *key_ctrl =
+ reinterpret_cast <key_vtn_flowfilter_entry_t*>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_entry_t)));
+ ConfigKeyVal *dup_ckmain = new ConfigKeyVal(
+ UNC_KT_VTN_FLOWFILTER_ENTRY,
+ IpctSt::kIpcStKeyVtnFlowfilterEntry,
+ key_ctrl, NULL);
+ uuu::upll_strncpy(
+ key_ctrl->flowfilter_key.vtn_key.vtn_name,
+ key_vtn_flowfilter_ctrl->vtn_key.vtn_name,
+ (kMaxLenVtnName +1));
+ if ((ival->valid[UPLL_IDX_SEQ_NUM_FFC] == UNC_VF_VALID) ||
+ (ival->valid[UPLL_IDX_DIRECTION_FFC] == UNC_VF_VALID)) {
+ if (ival->valid[UPLL_IDX_SEQ_NUM_FFC] == UNC_VF_VALID) {
+ key_ctrl->sequence_num = ival->sequence_num;
+ }
+ if (ival->valid[UPLL_IDX_DIRECTION_FFC] == UNC_VF_VALID) {
+ key_ctrl->flowfilter_key.input_direction = ival->direction;
+ }
+ result_code = UpdateConfigDB(dup_ckmain, req->datatype,
+ UNC_OP_READ, dmi, &dbop1, MAINTBL);
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Requested Configuration is not Configured in"
+ "VtnflowfilterEntry Table %d", result_code);
+ DELETE_IF_NOT_NULL(dup_ckmain);
+ DELETE_IF_NOT_NULL(l_key);
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
+ return result_code;
+ }
+ }
+ DELETE_IF_NOT_NULL(dup_ckmain);
result_code = GetRenamedControllerKey(l_key, req->datatype, dmi,
&ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetRenamedControllerKey Failed %d", result_code);
+ DELETE_IF_NOT_NULL(l_key);
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
return result_code;
}
-#endif
- // Sending the request to driver
- IpcResponse ipc_resp;
- memset(&ipc_resp, 0, sizeof(IpcResponse));
- IpcRequest ipc_req;
- memset(&ipc_req, 0, sizeof(IpcRequest));
- ipc_req.header.clnt_sess_id = req->clnt_sess_id;
- ipc_req.header.config_id = req->config_id;
- ipc_req.header.operation = UNC_OP_READ;
- ipc_req.header.option1 = req->option1;
- ipc_req.header.datatype = req->datatype;
- ipc_req.ckv_data = l_key;
- if (!IpcUtil::SendReqToDriver(
- (const char *)ctrlr_dom.ctrlr,
- reinterpret_cast<char *>(ctrlr_dom.domain),
- PFCDRIVER_SERVICE_NAME, PFCDRIVER_SVID_LOGICAL,
- &ipc_req, true, &ipc_resp)) {
- UPLL_LOG_DEBUG("SendReqToDriver failed for Key %d controller %s",
- l_key->get_key_type(),
- reinterpret_cast<char *>(ctrlr_dom.ctrlr));
- return UPLL_RC_ERR_GENERIC;
- }
+ // Sending the request to driver
+ IpcResponse ipc_resp;
+ memset(&ipc_resp, 0, sizeof(IpcResponse));
+ IpcRequest ipc_req;
+ memset(&ipc_req, 0, sizeof(IpcRequest));
+ ipc_req.header.clnt_sess_id = req->clnt_sess_id;
+ ipc_req.header.config_id = req->config_id;
+ ipc_req.header.operation = UNC_OP_READ;
+ ipc_req.header.option1 = req->option1;
+ ipc_req.header.datatype = req->datatype;
+
+ ipc_req.ckv_data = l_key;
+ if (!IpcUtil::SendReqToDriver(
+ (const char *)ctrlr_dom.ctrlr,
+ reinterpret_cast<char *>(ctrlr_dom.domain),
+ PFCDRIVER_SERVICE_NAME, PFCDRIVER_SVID_LOGICAL,
+ &ipc_req, true, &ipc_resp)) {
+ UPLL_LOG_DEBUG("SendReqToDriver failed for Key %d controller %s",
+ l_key->get_key_type(),
+ reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
+ return UPLL_RC_ERR_GENERIC;
+ }
- if (ipc_resp.header.result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Request for Key %d failed in %s with error %d\n",
- l_key->get_key_type(), ctrlr_dom.ctrlr,
- ipc_resp.header.result_code);
- delete dup_ckmain;
- return ipc_resp.header.result_code;
- }
- ConfigKeyVal *okey = NULL;
- result_code = ReadControllerStateDetail(ikey,
- ipc_resp.ckv_data,
- req->datatype,
- req->operation,
- dmi, &ctrlr_dom, &okey);
- if (result_code!= UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ReadControllerStateDetail Fail err code (%d)",
- result_code);
- return result_code;
- } else {
- if (okey != NULL) {
- ikey->ResetWith(okey);
+ if (ipc_resp.header.result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("Request for Key %d failed in %s with error %d",
+ l_key->get_key_type(), ctrlr_dom.ctrlr,
+ ipc_resp.header.result_code);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(l_key);
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
+ return ipc_resp.header.result_code;
+ }
+ result_code = ReadControllerStateDetail(ikey,
+ ipc_resp.ckv_data,
+ &ctrlr_dom, &okey);
+ if (result_code!= UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ReadControllerStateDetail Fail err code (%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(l_key);
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
+ return result_code;
}
+ if (okey != NULL) {
+ ikey->ResetWith(okey);
+ DELETE_IF_NOT_NULL(okey);
}
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
}
break;
default:
UPLL_FUNC_TRACE;
upll_rc_t result_code;
/* read from main table */
- ConfigKeyVal *dup_ckmain = ck_main;
+ ConfigKeyVal *dup_ckmain = NULL;
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s op = %d", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain, op);
if (op == UNC_OP_CREATE) {
- dup_ckmain = NULL;
result_code = GetChildConfigKey(dup_ckmain, ck_main);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
- if (dup_ckmain) delete dup_ckmain;
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
return result_code;
}
DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutNone};
result_code = ReadConfigDB(dup_ckmain, UPLL_DT_CANDIDATE,
UNC_OP_READ, dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- string s(dup_ckmain->ToStrAll());
- UPLL_LOG_DEBUG("%s Flowfilter entry read failed %d",
- s.c_str(), result_code);
- delete dup_ckmain;
+ UPLL_LOG_TRACE("%s Flowfilter entry read failed err %d",
+ dup_ckmain->ToStrAll().c_str(), result_code);
+ DELETE_IF_NOT_NULL(dup_ckmain);
return result_code;
}
+ } else if (op == UNC_OP_UPDATE) {
+
+ result_code = DupConfigKeyVal(dup_ckmain, ck_main, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigkeyval Failed, err %d", result_code);
+ return result_code;
+ }
+ } else {
+ dup_ckmain = ck_main;
}
-/* Get renamed key if key is renamed */
- result_code = GetRenamedControllerKey(dup_ckmain, UPLL_DT_CANDIDATE,
+
+ /* Get renamed key if key is renamed */
+ if (op == UNC_OP_DELETE)
+ result_code = GetRenamedControllerKey(dup_ckmain, UPLL_DT_RUNNING,
+ dmi, ctrlr_dom);
+ else
+ result_code = GetRenamedControllerKey(dup_ckmain, UPLL_DT_CANDIDATE,
dmi, ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetRenamedControllerKey failed, err %d", result_code);
+ if (op == UNC_OP_UPDATE || op == UNC_OP_CREATE) {
+ DELETE_IF_NOT_NULL(dup_ckmain);
+ }
return result_code;
}
result_code = SendIpcReq(ipc_resp->header.clnt_sess_id,
ipc_resp->header.config_id, op, UPLL_DT_CANDIDATE,
dup_ckmain, ctrlr_dom, ipc_resp);
if (result_code == UPLL_RC_ERR_RESOURCE_DISCONNECTED) {
- UPLL_LOG_DEBUG("Controller disconnected\n");
+ UPLL_LOG_DEBUG("Controller disconnected");
result_code = UPLL_RC_SUCCESS;
}
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("IpcSend failed %d\n", result_code);
+ UPLL_LOG_DEBUG("IpcSend failed %d", result_code);
}
- if ((op == UNC_OP_CREATE) && dup_ckmain) {
- delete dup_ckmain;
- dup_ckmain = NULL;
+ if (op == UNC_OP_UPDATE || op == UNC_OP_CREATE) {
+ DELETE_IF_NOT_NULL(dup_ckmain);
}
return result_code;
}
unc_keytype_operation_t op = (phase == uuc::kUpllUcpCreate) ? UNC_OP_CREATE :
((phase == uuc::kUpllUcpUpdate) ? UNC_OP_UPDATE :
((phase == uuc::kUpllUcpDelete) ?UNC_OP_DELETE:UNC_OP_INVALID));
+
switch (op) {
case UNC_OP_CREATE:
case UNC_OP_DELETE:
nreq, &dal_cursor_handle, dmi, MAINTBL);
break;
default:
- UPLL_LOG_DEBUG("TxUpdateController Invalid operation \n");
+ UPLL_LOG_DEBUG("TxUpdateController Invalid operation");
return UPLL_RC_ERR_GENERIC;
}
resp.header.clnt_sess_id = session_id;
UPLL_LOG_DEBUG("GetChildConfiKey Failed, err %d", result_code);
return result_code;
}
- // GET_USER_DATA_CTRLR_DOMAIN(ck_main, ctrlr_dom);
GET_USER_DATA_CTRLR_DOMAIN(req, ctrlr_dom);
- /*
- result_code = DupConfigKeyVal(ck_main, req, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("DupConfigKeyVal err (%d)", result_code);
- return result_code;
- }*/
- // GET_USER_DATA_CTRLR_DOMAIN(ck_main, ctrlr_dom);
UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom.ctrlr,
ctrlr_dom.domain);
if (ctrlr_dom.ctrlr == NULL || NULL == ctrlr_dom.domain) {
UPLL_LOG_DEBUG("Invalid controller/Domain");
- if (ck_main) delete ck_main;
+ DELETE_IF_NOT_NULL(ck_main);
return UPLL_RC_ERR_GENERIC;
}
result_code = TxUpdateProcess(ck_main, &resp,
op, dmi, &ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("TxUpdateProcess Returns error %d", result_code);
+ upll_keytype_datatype_t dt_type = (UNC_OP_DELETE == op)?
+ UPLL_DT_RUNNING:UPLL_DT_CANDIDATE;
+ upll_rc_t local_rc = GetRenamedUncKey(resp.ckv_data, dt_type, dmi,
+ ctrlr_dom.ctrlr);
+ if (UPLL_RC_SUCCESS != local_rc &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != local_rc) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey failed %d", local_rc);
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(resp.ckv_data);
+ result_code = UPLL_RC_ERR_GENERIC;
+ break;
+ }
*err_ckv = resp.ckv_data;
- if (ck_main) delete ck_main;
+ DELETE_IF_NOT_NULL(ck_main);
break;
}
+ DELETE_IF_NOT_NULL(resp.ckv_data);
affected_ctrlr_set->insert((const char *)ctrlr_dom.ctrlr);
} else if (op == UNC_OP_UPDATE) {
ConfigKeyVal *ck_ctrlr = NULL;
result_code = DupConfigKeyVal(ck_main, req, MAINTBL);
if (result_code != UPLL_RC_SUCCESS)
return result_code;
- /*
- result_code = ValidateCapability(&(ipc_req.header), ck_main);
-
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("TxUpdate ValidateCapability Err (%d) (%d) (%d)",
- result_code, ipc_req.header.operation,
- ipc_req.header.datatype);
- return result_code;
- } */
result_code = GetChildConfigKey(ck_ctrlr, ck_main);
- if (result_code != UPLL_RC_SUCCESS)
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(ck_main);
return result_code;
+ }
if (GetControllerDomainSpan(ck_ctrlr, UPLL_DT_CANDIDATE, dmi) ==
UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- delete ck_ctrlr;
- ck_ctrlr = NULL;
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(ck_ctrlr);
continue;
}
void *main = GetVal(ck_main);
GET_USER_DATA_CTRLR_DOMAIN(tmp, ctrlr_dom);
if (ctrlr_dom.ctrlr == NULL || (ctrlr_dom.domain == NULL)) {
UPLL_LOG_DEBUG("Invalid controller");
- delete ck_ctrlr;
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(ck_ctrlr);
return UPLL_RC_ERR_GENERIC;
}
-
+ ConfigKeyVal *temp_ck_main = NULL;
+ result_code = DupConfigKeyVal(temp_ck_main, ck_main, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed %d", result_code);
+ DELETE_IF_NOT_NULL(ck_ctrlr);
+ DELETE_IF_NOT_NULL(ck_main);
+ return result_code;
+ }
result_code = TxUpdateProcess(ck_main, &resp, op, dmi, &ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("TxUpdate Process returns with %d\n", result_code);
- *err_ckv = resp.ckv_data;
- if (ck_main) delete ck_main;
+ UPLL_LOG_DEBUG("TxUpdate Process returns with %d", result_code);
+ *err_ckv = temp_ck_main;
+ DELETE_IF_NOT_NULL(resp.ckv_data);
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(ck_ctrlr);
break;
}
affected_ctrlr_set->insert(reinterpret_cast<const char *>
(ctrlr_dom.ctrlr));
+ DELETE_IF_NOT_NULL(temp_ck_main);
+ DELETE_IF_NOT_NULL(resp.ckv_data);
}
- delete ck_ctrlr;
+ DELETE_IF_NOT_NULL(ck_ctrlr);
}
- delete ck_main;
+ DELETE_IF_NOT_NULL(ck_main);
}
- if (nreq)
- delete nreq;
- if (req)
- delete req;
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(req);
if (dal_cursor_handle)
dmi->CloseCursor(dal_cursor_handle, true);
result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
sizeof(val_vtn_flowfilter_entry->flowlist_name));
}
+#if 0 // action_field_notconfigured is set, but not used
bool action_field_notconfigured = true;
+#endif
/** validate action */
if (val_vtn_flowfilter_entry->valid[UPLL_IDX_ACTION_VFFE] == UNC_VF_VALID) {
val_vtn_flowfilter_entry->action);
return UPLL_RC_ERR_CFG_SYNTAX;
}
+#if 0 // action_field_notconfigured is set, but not used
action_field_notconfigured = false;
+#endif
} else if ((val_vtn_flowfilter_entry->valid[UPLL_IDX_ACTION_VFFE]
== UNC_VF_INVALID) && (req->operation == UNC_OP_UPDATE)) {
/** Read key struct from ConfigKeyVal argument*/
if ((val_vtn_ffe->valid[UPLL_IDX_ACTION_VFFE] == UNC_VF_VALID) &&
(val_vtn_ffe->action == UPLL_FLOWFILTER_ACT_PASS)) {
UPLL_LOG_TRACE("Action is configured in DB with value as PASS");
+#if 0 // action_field_notconfigured is set, but not used
action_field_notconfigured = false;
+#endif
}
delete okey;
/** validate DSCP */
if (val_vtn_flowfilter_entry->valid[UPLL_IDX_DSCP_VFFE] == UNC_VF_VALID) {
- if (action_field_notconfigured) {
- UPLL_LOG_DEBUG("Error DSCP configured when Action is not filled");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
-
if (!ValidateNumericRange(val_vtn_flowfilter_entry->dscp, kMinIPDscp,
kMaxIPDscp, true, true)) {
UPLL_LOG_DEBUG(" DSCP syntax validation failed ");
/** validate Priority*/
if (val_vtn_flowfilter_entry->valid[UPLL_IDX_PRIORITY_VFFE]
== UNC_VF_VALID) {
- if (action_field_notconfigured) {
- UPLL_LOG_DEBUG("PRIORITY is configured when Action is not filled");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
-
if (!ValidateNumericRange(val_vtn_flowfilter_entry->priority,
kMinVlanPriority, kMaxVlanPriority, true,
true)) {
const uint8_t* attrs) {
UPLL_FUNC_TRACE;
- if (val_vtn_flowfilter_entry != NULL) {
- if ((val_vtn_flowfilter_entry->valid[UPLL_IDX_FLOWLIST_NAME_VFFE]
- == UNC_VF_VALID)
- || (val_vtn_flowfilter_entry->valid[UPLL_IDX_FLOWLIST_NAME_VFFE]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vtn_flowfilter_entry::kCapFlowlistName] == 0) {
- val_vtn_flowfilter_entry->valid[UPLL_IDX_FLOWLIST_NAME_VFFE] =
- UNC_VF_NOT_SOPPORTED;
-
- UPLL_LOG_DEBUG("FlowlistName attr is not supported by ctrlr");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
+ if ((val_vtn_flowfilter_entry->valid[UPLL_IDX_FLOWLIST_NAME_VFFE]
+ == UNC_VF_VALID)
+ || (val_vtn_flowfilter_entry->valid[UPLL_IDX_FLOWLIST_NAME_VFFE]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtn_flowfilter_entry::kCapFlowlistName] == 0) {
+ val_vtn_flowfilter_entry->valid[UPLL_IDX_FLOWLIST_NAME_VFFE] =
+ UNC_VF_NOT_SUPPORTED;
+
+ UPLL_LOG_DEBUG("FlowlistName attr is not supported by ctrlr");
}
+ }
- if ((val_vtn_flowfilter_entry->valid[UPLL_IDX_ACTION_VFFE] == UNC_VF_VALID)
- || (val_vtn_flowfilter_entry->valid[UPLL_IDX_ACTION_VFFE]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vtn_flowfilter_entry::kCapAction] == 0) {
- val_vtn_flowfilter_entry->valid[UPLL_IDX_ACTION_VFFE] =
- UNC_VF_NOT_SOPPORTED;
+ if ((val_vtn_flowfilter_entry->valid[UPLL_IDX_ACTION_VFFE] == UNC_VF_VALID)
+ || (val_vtn_flowfilter_entry->valid[UPLL_IDX_ACTION_VFFE]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtn_flowfilter_entry::kCapAction] == 0) {
+ val_vtn_flowfilter_entry->valid[UPLL_IDX_ACTION_VFFE] =
+ UNC_VF_NOT_SUPPORTED;
- UPLL_LOG_DEBUG("Action attr is not supported by ctrlr");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
+ UPLL_LOG_DEBUG("Action attr is not supported by ctrlr");
}
- if ((val_vtn_flowfilter_entry->valid[UPLL_IDX_NWN_NAME_VFFE] ==
- UNC_VF_VALID)
- || (val_vtn_flowfilter_entry->valid[UPLL_IDX_NWN_NAME_VFFE]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vtn_flowfilter_entry::kCapNwnName] == 0) {
- val_vtn_flowfilter_entry->valid[UPLL_IDX_NWN_NAME_VFFE] =
- UNC_VF_NOT_SOPPORTED;
+ }
+ if ((val_vtn_flowfilter_entry->valid[UPLL_IDX_NWN_NAME_VFFE] ==
+ UNC_VF_VALID)
+ || (val_vtn_flowfilter_entry->valid[UPLL_IDX_NWN_NAME_VFFE]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtn_flowfilter_entry::kCapNwnName] == 0) {
+ val_vtn_flowfilter_entry->valid[UPLL_IDX_NWN_NAME_VFFE] =
+ UNC_VF_NOT_SUPPORTED;
- UPLL_LOG_DEBUG("Nwm name attr is not supported by ctrlr");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
+ UPLL_LOG_DEBUG("Nwm name attr is not supported by ctrlr");
}
- if ((val_vtn_flowfilter_entry->valid[UPLL_IDX_DSCP_VFFE] == UNC_VF_VALID)
- || (val_vtn_flowfilter_entry->valid[UPLL_IDX_DSCP_VFFE]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vtn_flowfilter_entry::kCapDscp] == 0) {
- val_vtn_flowfilter_entry->valid[UPLL_IDX_DSCP_VFFE] =
- UNC_VF_NOT_SOPPORTED;
+ }
+ if ((val_vtn_flowfilter_entry->valid[UPLL_IDX_DSCP_VFFE] == UNC_VF_VALID)
+ || (val_vtn_flowfilter_entry->valid[UPLL_IDX_DSCP_VFFE]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtn_flowfilter_entry::kCapDscp] == 0) {
+ val_vtn_flowfilter_entry->valid[UPLL_IDX_DSCP_VFFE] =
+ UNC_VF_NOT_SUPPORTED;
- UPLL_LOG_DEBUG("Dscp attr is not supported by ctrlr");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
+ UPLL_LOG_DEBUG("Dscp attr is not supported by ctrlr");
}
+ }
- if ((val_vtn_flowfilter_entry->valid[UPLL_IDX_PRIORITY_VFFE] ==
- UNC_VF_VALID)
- || (val_vtn_flowfilter_entry->valid[UPLL_IDX_PRIORITY_VFFE]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vtn_flowfilter_entry::kCapPriority] == 0) {
- val_vtn_flowfilter_entry->valid[UPLL_IDX_PRIORITY_VFFE] =
- UNC_VF_NOT_SOPPORTED;
+ if ((val_vtn_flowfilter_entry->valid[UPLL_IDX_PRIORITY_VFFE] ==
+ UNC_VF_VALID)
+ || (val_vtn_flowfilter_entry->valid[UPLL_IDX_PRIORITY_VFFE]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtn_flowfilter_entry::kCapPriority] == 0) {
+ val_vtn_flowfilter_entry->valid[UPLL_IDX_PRIORITY_VFFE] =
+ UNC_VF_NOT_SUPPORTED;
- UPLL_LOG_DEBUG("Priority attr is not supported by ctrlr");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
+ UPLL_LOG_DEBUG("Priority attr is not supported by ctrlr");
}
-
- } else {
- UPLL_LOG_DEBUG("Error value struct is NULL");
- return UPLL_RC_ERR_GENERIC;
}
return UPLL_RC_SUCCESS;
}
int &nattr,
MoMgrTables tbl) {
/* Main Table only update */
- if (UNC_KT_VTN_FLOWFILTER_ENTRY == key_type) {
- if (MAINTBL == tbl) {
- nattr = NUM_KEY_MAIN_TBL_;
- binfo = vtnflowfilterentrymaintbl_bind_info;
- } else if (CTRLRTBL == tbl) {
- nattr = NUM_KEY_CTRLR_TBL;
- binfo = vtnflowfilterentryctrlrtbl_bind_info;
- }
- }
-
- /* Check for Flowlist Rename*/
- if (UNC_KT_FLOWLIST == key_type) {
- if (MAINTBL == tbl) {
- nattr = NUM_KEY_RENAME_MAIN_TBL;
- binfo = vtn_flowlist_rename_bind_info;
- }
+ if (MAINTBL == tbl) {
+ nattr = sizeof(vtnflowfilterentrymaintbl_bind_info)/
+ sizeof(vtnflowfilterentrymaintbl_bind_info[0]);
+ binfo = vtnflowfilterentrymaintbl_bind_info;
+ } else if (CTRLRTBL == tbl) {
+ nattr = sizeof(vtnflowfilterentryctrlrtbl_bind_info)/
+ sizeof(vtnflowfilterentryctrlrtbl_bind_info[0]);
+ binfo = vtnflowfilterentryctrlrtbl_bind_info;
+ } else {
+ UPLL_LOG_DEBUG("Invalid Table, table type %d", tbl);
+ return PFC_FALSE;
}
+
UPLL_LOG_DEBUG("Successful Completeion");
return PFC_TRUE;
}
upll_rc_t result_code = UPLL_RC_SUCCESS;
- if (UNC_KT_VTN_FLOWFILTER_ENTRY == ikey->get_key_type()) {
- key_rename_vnode_info *key_rename = reinterpret_cast<key_rename_vnode_info*>
- (ikey->get_key());
- key_vtn_flowfilter_entry_t *key_vtn = reinterpret_cast
- <key_vtn_flowfilter_entry_t*>
- (ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_entry_t)));
+ key_rename_vnode_info *key_rename = reinterpret_cast<key_rename_vnode_info*>
+ (ikey->get_key());
+ key_vtn_flowfilter_entry_t *key_vtn = reinterpret_cast
+ <key_vtn_flowfilter_entry_t*>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_entry_t)));
- if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vtn_name))) {
- UPLL_LOG_DEBUG("String Length not Valid to Perform the Operation");
- free(key_vtn);
- return UPLL_RC_ERR_GENERIC;
- }
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vtn_name))) {
+ UPLL_LOG_DEBUG("String Length not Valid to Perform the Operation");
+ free(key_vtn);
+ return UPLL_RC_ERR_GENERIC;
+ }
- uuu::upll_strncpy(key_vtn->flowfilter_key.vtn_key.vtn_name,
- key_rename->old_unc_vtn_name, (kMaxLenVtnName + 1));
-#if 0
- if (ikey->get_key_type() == table[MAINTBL]->get_key_type()) {
- if (!strlen(reinterpret_cast<char *> (key_rename->old_unc_vnode_name)))
- return UPLL_RC_ERR_GENERIC;
- strncpy(reinterpret_cast<char*>
- (key_vrt_if->flowfilter_key.if_key.vrt_key.vrouter_name),
- reinterpret_cast<char *> (key_rename->old_unc_vnode_name), 32);
- }
-#endif
- okey = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_ENTRY, IpctSt::
+ uuu::upll_strncpy(key_vtn->flowfilter_key.vtn_key.vtn_name,
+ key_rename->old_unc_vtn_name, (kMaxLenVtnName + 1));
+ key_vtn->flowfilter_key.input_direction = 0xFE;
+
+ okey = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_ENTRY, IpctSt::
kIpcStKeyVtnFlowfilterEntry, key_vtn, NULL);
+ if (!okey) {
+ FREE_IF_NOT_NULL(key_vtn);
+ return UPLL_RC_ERR_GENERIC;
}
- if (UNC_KT_FLOWLIST == ikey->get_key_type()) {
- key_rename_vnode_info_t *key_rename =
- reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
- val_vtn_flowfilter_entry_t *val =
- reinterpret_cast <val_vtn_flowfilter_entry_t*>
- (ConfigKeyVal::Malloc(sizeof(val_vtn_flowfilter_entry_t)));
- uuu::upll_strncpy(val->flowlist_name,
- key_rename->old_flowlist_name,
- (kMaxLenFlowListName+1));
+ return result_code;
+}
- val->valid[UPLL_IDX_FLOWLIST_PPE] = UNC_VF_VALID;
+upll_rc_t VtnFlowFilterEntryMoMgr::UpdateVnodeVal(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t data_type,
+ bool &no_rename) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *okey = NULL;
+ ConfigKeyVal *kval = NULL;
+ ConfigKeyVal *ckey = NULL;
+ ConfigKeyVal *ctrlr_val = NULL;
+ // key_vtn_flowfilter_entry_t *vtn_ffe_key = NULL;
+ controller_domain ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ uint8_t rename = 0;
- ConfigVal *ckv = new ConfigVal(IpctSt::kIpcStValVtnFlowfilterEntry, val);
- okey = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_ENTRY,
- IpctSt::kIpcStKeyVtnFlowfilterEntry, NULL, ckv);
+ key_rename_vnode_info_t *key_rename =
+ reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
+
+ // Copy the old flowlist name in val_vtn_flowfilter_entry
+ val_vtn_flowfilter_entry_t *val =
+ reinterpret_cast<val_vtn_flowfilter_entry_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtn_flowfilter_entry_t)));
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_flowlist_name))) {
+ if (val) free(val);
+ return UPLL_RC_ERR_GENERIC;
}
+ UPLL_LOG_TRACE("Rename NoRename Falg = %d", no_rename);
- if (!okey)
+ result_code = GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("GetChildConfigKey Failed ");
+ FREE_IF_NOT_NULL(val);
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
+ }
+
+ uuu::upll_strncpy(val->flowlist_name,
+ key_rename->old_flowlist_name,
+ (kMaxLenFlowListName + 1));
+ val->valid[UPLL_IDX_FLOWLIST_NAME_VFFE] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("FlowList name and valid (%d) (%s)",
+ val->valid[UPLL_IDX_FLOWLIST_NAME_VFFE], val->flowlist_name);
+
+ // Construct ConfigKeyVal
+// ConfigVal *cval = new ConfigVal(IpctSt::kIpcStKeyVtnFlowfilterEntry, val);
+ okey->SetCfgVal(new ConfigVal (IpctSt::kIpcStValVtnFlowfilterEntry, val));
+
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutFlag };
+#if 0
+ vtn_ffe_key = reinterpret_cast<key_vtn_flowfilter_entry_t*>(okey->get_key());
+
+ vtn_ffe_key->flowfilter_key.input_direction = 0xFE;
+#endif
+ // Read the record of key structure and old Flowlist name in maintbl
+ result_code = ReadConfigDB(okey, data_type, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG(" ReadConfigDB failed ");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ ConfigKeyVal *tmp_okey = okey;
+ while (okey != NULL) {
+ // Update the new flowlist name in MAINTBL
+ result_code = GetChildConfigKey(kval, okey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey kval NULL");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ if (!kval) return UPLL_RC_ERR_GENERIC;
+ // Copy the new flowlist in val structure
+ val_vtn_flowfilter_entry_t *val1 = reinterpret_cast<val_vtn_flowfilter_entry_t *>
+ (ConfigKeyVal::Malloc
+ (sizeof(val_vtn_flowfilter_entry_t)));
+ // New name null check
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_flowlist_name))) {
+ UPLL_LOG_DEBUG("new_flowlist_name NULL");
+ FREE_IF_NOT_NULL(val1);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(kval);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ // Copy the new flowlist name into val_vtn_flowfilter_entry
+ uuu::upll_strncpy(val1->flowlist_name,
+ key_rename->new_flowlist_name,
+ (kMaxLenPolicingProfileName + 1));
+ val1->valid[UPLL_IDX_FLOWLIST_NAME_VFFE] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("flowlist name and valid (%d) (%s)",
+ val1->valid[UPLL_IDX_FLOWLIST_NAME_VFFE], val1->flowlist_name);
+ ConfigVal *cval1 = new ConfigVal(IpctSt::kIpcStValVtnFlowfilterEntry, val1);
+
+ kval->SetCfgVal(cval1);
+
+ //GET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
+ GET_USER_DATA_FLAGS(okey, rename);
+
+ if (!no_rename)
+ rename = rename | FLOWLIST_RENAME;
+ else
+ rename = rename & NO_FLOWLIST_RENAME;
+
+ SET_USER_DATA_FLAGS(kval, rename);
+ //SET_USER_DATA_CTRLR_DOMAIN(kval, ctrlr_dom);
+ // Update the new flowlist name in MAINTBL
+ result_code = UpdateConfigDB(kval, data_type, UNC_OP_UPDATE, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Update record Err in vtnff entry tbl CANDIDATE DB(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(kval);
+ return result_code;
+ }
+
+// Get the momory alloctaed vtn key structure
+ VtnMoMgr *vtnmgr =
+ static_cast<VtnMoMgr *>((const_cast<MoManager *>
+ (GetMoManager(UNC_KT_VTN))));
+ result_code = vtnmgr->GetChildConfigKey(ckey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateRefCountInPPCtrlr GetChildConfigKey error (%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(kval);
+ return result_code;
+ }
+ if (!ckey) return UPLL_RC_ERR_GENERIC;
+
+ key_vtn_t *vtn_okey = reinterpret_cast<key_vtn_t *>(ckey->get_key());
+ key_vtn_flowfilter_entry *vtn_ikey = reinterpret_cast<key_vtn_flowfilter_entry *>(okey->get_key());
+ uuu::upll_strncpy(vtn_okey->vtn_name, vtn_ikey->flowfilter_key.vtn_key.vtn_name,
+ kMaxLenVtnName+1);
+
+ UPLL_LOG_DEBUG("vtn name ckey (%s) okey (%s)", vtn_okey->vtn_name, vtn_ikey->flowfilter_key.vtn_key.vtn_name);
+ result_code = vtnmgr->GetControllerDomainSpan(ckey, data_type, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetControllerSpan no instance/error (%d)", result_code);
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(ckey);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(ckey);
+ continue;
+ }
+
+ //Update Rename flag in the controller span
+ ConfigKeyVal *tmp_ckey = ckey;
+ while (ckey != NULL) {
+ GET_USER_DATA_CTRLR_DOMAIN(ckey, ctrlr_dom);
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+
+ result_code = GetChildConfigKey(ctrlr_val, okey);
+ if (result_code != UPLL_RC_SUCCESS)
+ return result_code;
+
+ val_vtn_flowfilter_entry_ctrlr *vtnffe_ctrlr_val =
+ reinterpret_cast<val_vtn_flowfilter_entry_ctrlr *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtn_flowfilter_entry_ctrlr)));
+ // Copy the new policer name into val_vtnpolicingmap_ctrl
+ vtnffe_ctrlr_val->valid[UPLL_IDX_FLOWLIST_NAME_VFFE] = UNC_VF_VALID;
+ ConfigVal *cval2 = new ConfigVal(IpctSt::kIpcInvalidStNum, vtnffe_ctrlr_val);
+ ctrlr_val->SetCfgVal(cval2);
+ SET_USER_DATA_CTRLR_DOMAIN(ctrlr_val, ctrlr_dom);
+ SET_USER_DATA_FLAGS(ctrlr_val, rename);
+ // Update the new policer name in CTRLTBL
+ result_code = UpdateConfigDB(ctrlr_val, data_type, UNC_OP_UPDATE, dmi,
+ CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Update record Err in vtnff entry CANDIDATE DB(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(ckey);
+ DELETE_IF_NOT_NULL(ctrlr_val);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(ctrlr_val);
+ ckey = ckey->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(tmp_ckey);
+ okey = okey->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(tmp_okey);
return result_code;
}
bool VtnFlowFilterEntryMoMgr::CompareValidValue(void *&val1,
void *val2, bool audit) {
UPLL_FUNC_TRACE;
+ bool invalid_attr = true;
val_vtn_flowfilter_entry_t *val_ff_entry1 =
reinterpret_cast<val_vtn_flowfilter_entry_t *>(val1);
val_vtn_flowfilter_entry_t *val_ff_entry2 =
}
if (val_ff_entry1->valid[UPLL_IDX_ACTION_VFFE] == UNC_VF_VALID &&
val_ff_entry2->valid[UPLL_IDX_ACTION_VFFE] == UNC_VF_VALID) {
- if (val_ff_entry1->action !=
+ if (val_ff_entry1->action ==
val_ff_entry2->action)
val_ff_entry1->valid[UPLL_IDX_ACTION_VFFE] = UNC_VF_INVALID;
}
if (val_ff_entry1->valid[UPLL_IDX_DSCP_VFFE] == UNC_VF_VALID &&
val_ff_entry2->valid[UPLL_IDX_DSCP_VFFE] == UNC_VF_VALID) {
- if (val_ff_entry1->dscp!=
+ if (val_ff_entry1->dscp ==
val_ff_entry2->dscp)
val_ff_entry1->valid[UPLL_IDX_DSCP_VFFE] = UNC_VF_INVALID;
}
if (val_ff_entry1->valid[UPLL_IDX_PRIORITY_VFFE] == UNC_VF_VALID &&
val_ff_entry2->valid[UPLL_IDX_PRIORITY_VFFE] == UNC_VF_VALID) {
- if (val_ff_entry1->priority !=
+ if (val_ff_entry1->priority ==
val_ff_entry2->priority)
val_ff_entry1->valid[UPLL_IDX_PRIORITY_VFFE] = UNC_VF_INVALID;
}
- return false;
+ for (unsigned int loop = 0;
+ loop < sizeof(val_ff_entry1->valid) / sizeof(uint8_t); ++loop) {
+ if ((UNC_VF_VALID == (uint8_t) val_ff_entry1->valid[loop]) ||
+ (UNC_VF_VALID_NO_VALUE == (uint8_t) val_ff_entry1->valid[loop]))
+ invalid_attr = false;
+ }
+ return invalid_attr;
+}
+
+bool VtnFlowFilterEntryMoMgr::CompareValidVal(void *&val1, void *val2,
+ void *val3, bool audit) {
+ UPLL_FUNC_TRACE;
+ bool invalid_attr = true;
+ val_vtn_flowfilter_entry_t *val_ff_entry1 =
+ reinterpret_cast<val_vtn_flowfilter_entry_t *>(val1);
+ val_vtn_flowfilter_entry_t *val_ff_entry2 =
+ reinterpret_cast<val_vtn_flowfilter_entry_t *>(val2);
+ val_vtn_flowfilter_entry_t *val_ff_entry3 =
+ reinterpret_cast<val_vtn_flowfilter_entry_t *>(val3);
+
+ // if (audit) {
+ for ( unsigned int loop = 0;
+ loop < sizeof(val_ff_entry1->valid)/sizeof(val_ff_entry1->valid[0]);
+ ++loop ) {
+ if ( UNC_VF_INVALID == val_ff_entry1->valid[loop] &&
+ UNC_VF_VALID == val_ff_entry2->valid[loop])
+ val_ff_entry1->valid[loop] = UNC_VF_VALID_NO_VALUE;
+ }
+ // }
+
+ if (val_ff_entry1->valid[UPLL_IDX_FLOWLIST_NAME_VFFE] == UNC_VF_VALID &&
+ val_ff_entry2->valid[UPLL_IDX_FLOWLIST_NAME_VFFE] == UNC_VF_VALID) {
+ if (!strcmp(reinterpret_cast<char *>(val_ff_entry3->flowlist_name),
+ reinterpret_cast<char *>(val_ff_entry2->flowlist_name)))
+ val_ff_entry1->valid[UPLL_IDX_FLOWLIST_NAME_VFFE] = UNC_VF_INVALID;
+ }
+ if (val_ff_entry1->valid[UPLL_IDX_ACTION_VFFE] == UNC_VF_VALID &&
+ val_ff_entry2->valid[UPLL_IDX_ACTION_VFFE] == UNC_VF_VALID) {
+ if (val_ff_entry3->action ==
+ val_ff_entry2->action)
+ val_ff_entry1->valid[UPLL_IDX_ACTION_VFFE] = UNC_VF_INVALID;
+ }
+ if (val_ff_entry1->valid[UPLL_IDX_NWN_NAME_VFFE] == UNC_VF_VALID &&
+ val_ff_entry2->valid[UPLL_IDX_NWN_NAME_VFFE] == UNC_VF_VALID) {
+ if (!strcmp(reinterpret_cast<char *>(val_ff_entry3->nwm_name),
+ reinterpret_cast<char *>(val_ff_entry2->nwm_name)))
+ val_ff_entry1->valid[UPLL_IDX_NWN_NAME_VFFE] = UNC_VF_INVALID;
+ }
+
+ if (val_ff_entry1->valid[UPLL_IDX_DSCP_VFFE] == UNC_VF_VALID &&
+ val_ff_entry2->valid[UPLL_IDX_DSCP_VFFE] == UNC_VF_VALID) {
+ if (val_ff_entry3->dscp ==
+ val_ff_entry2->dscp)
+ val_ff_entry1->valid[UPLL_IDX_DSCP_VFFE] = UNC_VF_INVALID;
+ }
+ if (val_ff_entry1->valid[UPLL_IDX_PRIORITY_VFFE] == UNC_VF_VALID &&
+ val_ff_entry2->valid[UPLL_IDX_PRIORITY_VFFE] == UNC_VF_VALID) {
+ if (val_ff_entry3->priority ==
+ val_ff_entry2->priority)
+ val_ff_entry1->valid[UPLL_IDX_PRIORITY_VFFE] = UNC_VF_INVALID;
+ }
+ for (unsigned int loop = 0;
+ loop < sizeof(val_ff_entry1->valid) / sizeof(uint8_t); ++loop) {
+ if ((UNC_VF_VALID == (uint8_t) val_ff_entry1->valid[loop]) ||
+ (UNC_VF_VALID_NO_VALUE == (uint8_t) val_ff_entry1->valid[loop]))
+ invalid_attr = false;
+ }
+ return invalid_attr;
}
upll_rc_t VtnFlowFilterEntryMoMgr::ReadSiblingMo(IpcReqRespHeader *req,
- ConfigKeyVal *ikey, bool begin,
+ ConfigKeyVal *ikey,
+ bool begin,
DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
controller_domain ctrlr_dom;
DbSubOp dbop1 = { kOpReadExist, kOpMatchNone, kOpInOutNone};
upll_rc_t result_code = UPLL_RC_SUCCESS;
key_vtn_flowfilter_controller_t *key_vtn_ff_ctrl =
- reinterpret_cast<key_vtn_flowfilter_controller_t*>(ikey->get_key());
- key_vtn_flowfilter_entry_t *key_ctrl =
- reinterpret_cast <key_vtn_flowfilter_entry_t*>
- (ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_entry_t)));
+ reinterpret_cast<key_vtn_flowfilter_controller_t*>(ikey->get_key());
+ key_vtn_flowfilter_entry_t *key_ctrl =
+ reinterpret_cast <key_vtn_flowfilter_entry_t*>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_entry_t)));
ConfigKeyVal *dup_ckmain = new ConfigKeyVal(
- UNC_KT_VTN_FLOWFILTER_ENTRY,
- IpctSt::kIpcStKeyVtnFlowfilterEntry,
- key_ctrl, NULL);
+ UNC_KT_VTN_FLOWFILTER_ENTRY,
+ IpctSt::kIpcStKeyVtnFlowfilterEntry,
+ key_ctrl, NULL);
uuu::upll_strncpy(
- key_ctrl->flowfilter_key.vtn_key.vtn_name,
- key_vtn_ff_ctrl->vtn_key.vtn_name,
- (kMaxLenVtnName +1));
+ key_ctrl->flowfilter_key.vtn_key.vtn_name,
+ key_vtn_ff_ctrl->vtn_key.vtn_name,
+ (kMaxLenVtnName +1));
+ key_ctrl->flowfilter_key.input_direction = 0xFE;
+ // vtn is not configured in vtn_ff_entry main tbl
+ // only vtn/vbr is configured and commited
+ result_code = UpdateConfigDB(dup_ckmain, req->datatype,
+ UNC_OP_READ, dmi, &dbop1, MAINTBL);
+ if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
+ UPLL_LOG_DEBUG("Requested Vtn is Not Configured in"
+ "flowfilterEntryMain Table in Candidate %d", result_code);
+ DELETE_IF_NOT_NULL(dup_ckmain);
+ return result_code;
+ }
+ // vtn is not configured in vtn_ff_entry ctrlr tbl
+ // vtn/ff/entry is configured but no vbr is configured
+
+ // Setting direction again to 0XFE
+ // because it will be set to 0 in updateconfigDB
key_ctrl->flowfilter_key.input_direction = 0xFE;
result_code = UpdateConfigDB(dup_ckmain, req->datatype,
UNC_OP_READ, dmi, &dbop1, CTRLRTBL);
- if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
UPLL_LOG_DEBUG("Requested Vtn is Not Configured in"
- "flowfilterEntryCtrlr Table %d", result_code);
+ "flowfilterEntryCtrlr Table %d", result_code);
+ DELETE_IF_NOT_NULL(dup_ckmain);
return UPLL_RC_ERR_NOT_ALLOWED_AT_THIS_TIME;
}
-
+ DELETE_IF_NOT_NULL(dup_ckmain);
switch (req->datatype) {
case UPLL_DT_STATE:
if ((req->option1 == UNC_OPT1_NORMAL) &&
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ReadSiblingControllerStateDetail failed code(%d)",
result_code);
- delete dup_ckmain;
return result_code;
}
} else {
DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
+ uint32_t tmp_sib_count = 0;
+ upll_rc_t vtn_ctrlr_span_rt_code = UPLL_RC_SUCCESS;
ConfigKeyVal *tctrl_key = NULL, *okey = NULL, *tmp_key = NULL;
+ ConfigKeyVal* tmp_okey = NULL;
controller_domain ctrlr_dom, tmp_ctrlr_dom;
// ReadSibling Operation Get The Multiple Key
key_vtn_flowfilter_controller_t *key_vtn_ff_ctrl =
uuu::upll_strncpy(ctrlr_dom.domain, key_vtn_ff_ctrl->domain_id,
(kMaxLenVtnName +1));
// Allocating The Key of KT_VTN_FF_Entry
- key_vtn_flowfilter_entry_t *key_vtn_ffe_ctrl =
- reinterpret_cast <key_vtn_flowfilter_entry_t*>
- (ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_entry_t)));
- // Allocating CKV tctrl_key
- tctrl_key = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_ENTRY,
- IpctSt::kIpcStKeyVtnFlowfilterEntry,
- key_vtn_ffe_ctrl, NULL);
- // Copying The seqno, i/p dir, Vtn_Name to The Above Key of CKV tctrl_key
- uuu::upll_strncpy(key_vtn_ffe_ctrl->flowfilter_key.vtn_key.vtn_name,
- key_vtn_ff_ctrl->vtn_key.vtn_name,
- (kMaxLenVtnName +1));
- if (val_ff_ctrl->valid[UPLL_IDX_SEQ_NUM_FFC] == UNC_VF_VALID) {
- key_vtn_ffe_ctrl->sequence_num = val_ff_ctrl->sequence_num;
- } else {
- key_vtn_ffe_ctrl->sequence_num = 0;
- }
- key_vtn_ffe_ctrl->flowfilter_key.input_direction = val_ff_ctrl->direction;
- // Reading The Entry_Ctrl_Table
- DbSubOp dbop = {kOpReadMultiple, kOpMatchNone,
- kOpInOutCtrlr|kOpInOutDomain};
- result_code = ReadConfigDB(tctrl_key, UPLL_DT_STATE, UNC_OP_READ,
- dbop, req->rep_count, dmi, CTRLRTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Unable to read vtn configuration from CTRL DB %d",
- result_code);
- delete tctrl_key;
- return result_code;
- }
-
- tmp_key = tctrl_key;
if (req->operation == UNC_OP_READ_SIBLING) {
- while (tmp_key !=NULL) {
- GET_USER_DATA_CTRLR_DOMAIN(tmp_key, tmp_ctrlr_dom);
+ std::list<controller_domain_t> list_ctrlr_dom;
+ vtn_ctrlr_span_rt_code = GetVtnControllerSpan(ikey, req->datatype, dmi,
+ list_ctrlr_dom);
+ if ((vtn_ctrlr_span_rt_code != UPLL_RC_SUCCESS) &&
+ (vtn_ctrlr_span_rt_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG(" GetVtnControllerSpan error code (%d)",
+ vtn_ctrlr_span_rt_code);
+ return vtn_ctrlr_span_rt_code;
+ }
+
+ for (std::list<controller_domain_t>::iterator it= list_ctrlr_dom.begin();
+ it != list_ctrlr_dom.end(); ++it) {
int ctrl_len = strcmp((const char*)(ctrlr_dom.ctrlr),
- (const char*)(tmp_ctrlr_dom.ctrlr));
+ reinterpret_cast<const char *>(it->ctrlr));
int dom_len = strcmp((const char*)(ctrlr_dom.domain),
- (const char*)(tmp_ctrlr_dom.domain));
- if ((ctrl_len < 0) || ((ctrl_len == 0) && (dom_len < 0))) {
- result_code = ConstructReadSiblingNormalResponse(tmp_key,
- req->datatype,
- dmi, &okey);
+ reinterpret_cast<const char *>(it->domain));
+ if ((ctrl_len < 0) || ((ctrl_len == 0) && (dom_len < 0))) {
+
+ key_vtn_flowfilter_entry_t *key_vtn_ffe_ctrl =
+ reinterpret_cast <key_vtn_flowfilter_entry_t*>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_entry_t)));
+ // Allocating CKV tctrl_key
+ tctrl_key = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_ENTRY,
+ IpctSt::kIpcStKeyVtnFlowfilterEntry,
+ key_vtn_ffe_ctrl, NULL);
+ // Copying The seqno, i/p dir, Vtn_Name to The Above Key of CKV tctrl_key
+ uuu::upll_strncpy(key_vtn_ffe_ctrl->flowfilter_key.vtn_key.vtn_name,
+ key_vtn_ff_ctrl->vtn_key.vtn_name,
+ (kMaxLenVtnName +1));
+ if (val_ff_ctrl->valid[UPLL_IDX_SEQ_NUM_FFC] == UNC_VF_VALID) {
+ key_vtn_ffe_ctrl->sequence_num = val_ff_ctrl->sequence_num;
+ } else {
+ key_vtn_ffe_ctrl->sequence_num = 0;
+ }
+ if (val_ff_ctrl->valid[UPLL_IDX_DIRECTION_FFC] == UNC_VF_VALID) {
+ key_vtn_ffe_ctrl->flowfilter_key.input_direction = val_ff_ctrl->direction;
+ } else {
+ key_vtn_ffe_ctrl->flowfilter_key.input_direction = 0xFE;
+ }
+ SET_USER_DATA_CTRLR(tctrl_key, reinterpret_cast<const char *>(it->ctrlr));
+ SET_USER_DATA_DOMAIN(tctrl_key, reinterpret_cast<const char *>(it->domain));
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchCtrlr|kOpMatchDomain, kOpInOutNone};
+ result_code = ReadConfigDB(tctrl_key, UPLL_DT_STATE, UNC_OP_READ,
+ dbop, dmi, CTRLRTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ConstructReadSiblingNormalResponse failed %d",
+ UPLL_LOG_DEBUG("Unable to read vtn configuration from CTRL DB %d",
result_code);
+ DELETE_IF_NOT_NULL(tctrl_key);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
+ tmp_key = tctrl_key;
+ key_vtn_flowfilter_entry_t *key_vtn_ffe =
+ reinterpret_cast <key_vtn_flowfilter_entry_t*>
+ (tctrl_key->get_key());
+
+ key_vtn_flowfilter_controller_t *tmp_ff_ctrl =
+ reinterpret_cast <key_vtn_flowfilter_controller_t*>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_controller_t)));
+ uuu::upll_strncpy(tmp_ff_ctrl->vtn_key.vtn_name,
+ key_vtn_ffe->flowfilter_key.vtn_key.vtn_name,
+ (kMaxLenVtnName +1));
+ uuu::upll_strncpy(tmp_ff_ctrl->controller_name,
+ reinterpret_cast<const char *>(it->ctrlr),
+ (kMaxLenCtrlrId +1));
+
+ uuu::upll_strncpy(tmp_ff_ctrl->domain_id,
+ reinterpret_cast<const char *>(it->domain),
+ (kMaxLenDomainId +1));
+ tmp_okey = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_CONTROLLER,
+ IpctSt::kIpcStKeyVtnFlowfilterController,
+ tmp_ff_ctrl, NULL);
+
+ while (tmp_key !=NULL) {
+ result_code = ConstructReadSiblingNormalResponse(tmp_key,
+ req->datatype,
+ dmi, &tmp_okey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ConstructReadSiblingNormalResponse failed %d",
+ result_code);
+ DELETE_IF_NOT_NULL(tmp_okey);
+ DELETE_IF_NOT_NULL(tctrl_key);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+
+ tmp_key = tmp_key->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(tctrl_key);
+ if( okey == NULL) {
+ okey = tmp_okey;
+ } else {
+ okey->AppendCfgKeyVal(tmp_okey);
+ }
+ tmp_sib_count++;
+ if (tmp_sib_count == req->rep_count)
+ break;
+ } else {
+ result_code = UPLL_RC_ERR_NO_SUCH_INSTANCE;
}
- tmp_key = tmp_key->get_next_cfg_key_val();
}
+
if ((okey != NULL) && (result_code == UPLL_RC_SUCCESS)) {
ikey->ResetWith(okey);
+ req->rep_count = tmp_sib_count;
+ } else {
+ DELETE_IF_NOT_NULL(okey);
}
} else if (req->operation == UNC_OP_READ_SIBLING_BEGIN) {
- while (tmp_key !=NULL) {
- GET_USER_DATA_CTRLR_DOMAIN(tmp_key, ctrlr_dom);
- result_code = ConstructReadSiblingNormalResponse(tmp_key,
- req->datatype,
- dmi, &okey);
+ std::list<controller_domain_t> list_ctrlr_dom;
+ vtn_ctrlr_span_rt_code = GetVtnControllerSpan(ikey, req->datatype, dmi, list_ctrlr_dom);
+ if ((vtn_ctrlr_span_rt_code != UPLL_RC_SUCCESS) &&
+ (vtn_ctrlr_span_rt_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG(" GetVtnControllerSpan error code (%d)",
+ vtn_ctrlr_span_rt_code);
+ return result_code;
+ }
+
+ if (vtn_ctrlr_span_rt_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG(" GetVtnControllerSpan failed . Resultcode %d ",
+ vtn_ctrlr_span_rt_code);
+ return vtn_ctrlr_span_rt_code;
+ }
+ for (std::list<controller_domain_t>::iterator it= list_ctrlr_dom.begin();
+ it != list_ctrlr_dom.end(); ++it) {
+ key_vtn_flowfilter_entry_t *key_vtn_ffe_ctrl =
+ reinterpret_cast <key_vtn_flowfilter_entry_t*>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_entry_t)));
+ // Allocating CKV tctrl_key
+ tctrl_key = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_ENTRY,
+ IpctSt::kIpcStKeyVtnFlowfilterEntry,
+ key_vtn_ffe_ctrl, NULL);
+ // Copying The seqno, i/p dir, Vtn_Name to The Above Key of CKV tctrl_key
+ uuu::upll_strncpy(key_vtn_ffe_ctrl->flowfilter_key.vtn_key.vtn_name,
+ key_vtn_ff_ctrl->vtn_key.vtn_name, (kMaxLenVtnName +1));
+ if (val_ff_ctrl->valid[UPLL_IDX_SEQ_NUM_FFC] == UNC_VF_VALID) {
+ key_vtn_ffe_ctrl->sequence_num = val_ff_ctrl->sequence_num;
+ } else {
+ key_vtn_ffe_ctrl->sequence_num = 0;
+ }
+ if (val_ff_ctrl->valid[UPLL_IDX_DIRECTION_FFC] == UNC_VF_VALID) {
+ key_vtn_ffe_ctrl->flowfilter_key.input_direction = val_ff_ctrl->direction;
+ } else {
+ key_vtn_ffe_ctrl->flowfilter_key.input_direction = 0xFE;
+ }
+ SET_USER_DATA_CTRLR(tctrl_key, reinterpret_cast<const char *>(it->ctrlr));
+ SET_USER_DATA_DOMAIN(tctrl_key, reinterpret_cast<const char *>(it->domain));
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchCtrlr|
+ kOpInOutDomain,kOpInOutDomain};
+ result_code = ReadConfigDB(tctrl_key, UPLL_DT_STATE, UNC_OP_READ,
+ dbop, dmi, CTRLRTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ConstructReadSiblingNormalResponse failed %d",
+ UPLL_LOG_DEBUG("Unable to read vtn configuration from CTRL DB %d",
result_code);
+ DELETE_IF_NOT_NULL(tctrl_key);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
- tmp_key = tmp_key->get_next_cfg_key_val();
+ tmp_key = tctrl_key;
+ key_vtn_flowfilter_entry_t *key_vtn_ffe =
+ reinterpret_cast <key_vtn_flowfilter_entry_t*>
+ (tctrl_key->get_key());
+ key_vtn_flowfilter_controller_t *tmp_ff_ctrl =
+ reinterpret_cast <key_vtn_flowfilter_controller_t*>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_controller_t)));
+ uuu::upll_strncpy(tmp_ff_ctrl->vtn_key.vtn_name,
+ key_vtn_ffe->flowfilter_key.vtn_key.vtn_name,
+ (kMaxLenVtnName +1));
+ uuu::upll_strncpy(tmp_ff_ctrl->controller_name,reinterpret_cast<const char *>(it->ctrlr),
+ (kMaxLenCtrlrId +1));
+ uuu::upll_strncpy(tmp_ff_ctrl->domain_id, reinterpret_cast<const char *>(it->domain),
+ (kMaxLenDomainId +1));
+ tmp_okey = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_CONTROLLER,
+ IpctSt::kIpcStKeyVtnFlowfilterController,
+ tmp_ff_ctrl, NULL);
+
+ while (tmp_key !=NULL) {
+ result_code = ConstructReadSiblingNormalResponse(tmp_key,
+ req->datatype,
+ dmi, &tmp_okey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ConstructReadSiblingNormalResponse failed %d",
+ result_code);
+ DELETE_IF_NOT_NULL(tctrl_key);
+ DELETE_IF_NOT_NULL(tmp_okey);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ tmp_key = tmp_key->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(tctrl_key);
+ if( okey == NULL) {
+ okey = tmp_okey;
+ } else {
+ okey->AppendCfgKeyVal(tmp_okey);
+ }
+ tmp_sib_count++;
+ if (tmp_sib_count == req->rep_count)
+ break;
}
if ((okey != NULL) && (result_code == UPLL_RC_SUCCESS)) {
ikey->ResetWith(okey);
+ req->rep_count = tmp_sib_count;
}
} else {
result_code = UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- ConfigKeyVal *tctrl_key = NULL, *okey = NULL, *tmp_key = NULL, *l_key = NULL;
+ DbSubOp dbop1 = { kOpReadExist, kOpMatchNone, kOpInOutNone};
+ upll_rc_t vtn_ctrlr_span_rt_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *okey = NULL, *l_key = NULL , *tmp_okey =NULL;
controller_domain ctrlr_dom, tmp_ctrlr_dom;
key_vtn_flowfilter_controller_t *key_vtn_ff_ctrl =
(ConfigKeyVal::Malloc(kMaxLenCtrlrId + 1));
ctrlr_dom.domain = reinterpret_cast <uint8_t*>
(ConfigKeyVal::Malloc(kMaxLenDomainId + 1));
+ tmp_ctrlr_dom.ctrlr = reinterpret_cast <uint8_t*>
+ (ConfigKeyVal::Malloc(kMaxLenCtrlrId + 1));
+ tmp_ctrlr_dom.domain = reinterpret_cast <uint8_t*>
+ (ConfigKeyVal::Malloc(kMaxLenDomainId + 1));
uuu::upll_strncpy(ctrlr_dom.ctrlr,
key_vtn_ff_ctrl->controller_name,
l_key = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_CONTROLLER, IpctSt::
kIpcStKeyVtnFlowfilterController,
l_key_vtn_ff_ctrl, tmp1);
-#if 0
- UPLL_LOG_DEBUG("GetRenamedControllerKey");
- result_code = GetRenamedControllerKey(l_key, req->datatype, dmi,
- &l_ctrlr_dom);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetRenamedControllerKey Failed %d", result_code);
- return result_code;
- }
-
-#endif
- // Allocating The Key of KT_VTN_FF_Entry
- key_vtn_flowfilter_entry_t *key_vtn_ffe_ctrl =
+ // verifying given reuest is existing in vtn_ff_entry_tbl or not
+ key_vtn_flowfilter_entry_t *key_ctrl =
reinterpret_cast <key_vtn_flowfilter_entry_t*>
(ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_entry_t)));
- // Allocating CKV tctrl_key
- tctrl_key = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_ENTRY,
- IpctSt::kIpcStKeyVtnFlowfilterEntry,
- key_vtn_ffe_ctrl, NULL);
- // Copying The seqno, i/p dir, Vtn_Name to The Above Key of CKV tctrl_key
- uuu::upll_strncpy(key_vtn_ffe_ctrl->flowfilter_key.vtn_key.vtn_name,
- key_vtn_ff_ctrl->vtn_key.vtn_name, (kMaxLenVtnName +1));
- key_vtn_ffe_ctrl->flowfilter_key.input_direction = val_ff_ctrl->direction;
- if (val_ff_ctrl->valid[UPLL_IDX_SEQ_NUM_FFC] == UNC_VF_VALID) {
- key_vtn_ffe_ctrl->sequence_num = val_ff_ctrl->sequence_num;
- } else {
- key_vtn_ffe_ctrl->sequence_num = 0;
- }
- // Reading The Entry_Ctrl_Table
- DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain};
- result_code = ReadConfigDB(tctrl_key, UPLL_DT_STATE, UNC_OP_READ,
- dbop, req->rep_count, dmi, CTRLRTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Unable to read vtn configuration from CTRL DB %d",
- result_code);
- delete l_key;
- delete tctrl_key;
- return result_code;
- }
+ ConfigKeyVal *dup_ckmain = new ConfigKeyVal(
+ UNC_KT_VTN_FLOWFILTER_ENTRY,
+ IpctSt::kIpcStKeyVtnFlowfilterEntry,
+ key_ctrl, NULL);
+ uuu::upll_strncpy(
+ key_ctrl->flowfilter_key.vtn_key.vtn_name,
+ key_vtn_ff_ctrl->vtn_key.vtn_name,
+ (kMaxLenVtnName +1));
+ if ((val_ff_ctrl->valid[UPLL_IDX_SEQ_NUM_FFC] == UNC_VF_VALID) ||
+ (val_ff_ctrl->valid[UPLL_IDX_DIRECTION_FFC] == UNC_VF_VALID)) {
+ if (val_ff_ctrl->valid[UPLL_IDX_SEQ_NUM_FFC] == UNC_VF_VALID) {
+ key_ctrl->sequence_num = val_ff_ctrl->sequence_num;
+ }
+ if (val_ff_ctrl->valid[UPLL_IDX_DIRECTION_FFC] == UNC_VF_VALID) {
+ key_ctrl->flowfilter_key.input_direction = val_ff_ctrl->direction;
+ }
+ result_code = UpdateConfigDB(dup_ckmain, req->datatype,
+ UNC_OP_READ, dmi, &dbop1, MAINTBL);
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Requested Configuration is not Configured in"
+ "VtnflowfilterEntry Table %d", result_code);
+ DELETE_IF_NOT_NULL(dup_ckmain);
+ DELETE_IF_NOT_NULL(l_key);
+ ConfigKeyVal::Free(ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(ctrlr_dom.domain);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.domain);
+ return result_code;
+ }
+ }
+ DELETE_IF_NOT_NULL(dup_ckmain);
// Extracting The Val from CKV tctrl_key
- tmp_key = tctrl_key;
+ uint32_t tmp_sib_count = 0;
if (req->operation == UNC_OP_READ_SIBLING) {
- while (tmp_key != NULL) {
- GET_USER_DATA_CTRLR_DOMAIN(tmp_key, tmp_ctrlr_dom);
+// ====Adding VtnControllerDomainSpan
+ std::list<controller_domain_t> list_ctrlr_dom;
+ vtn_ctrlr_span_rt_code = GetVtnControllerSpan(ikey,
+ req->datatype, dmi, list_ctrlr_dom);
+ if ((vtn_ctrlr_span_rt_code != UPLL_RC_SUCCESS) &&
+ (vtn_ctrlr_span_rt_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG(" GetVtnControllerSpan error code (%d)",
+ vtn_ctrlr_span_rt_code);
+ DELETE_IF_NOT_NULL(l_key);
+ FREE_LIST_CTRLR(list_ctrlr_dom);
+ ConfigKeyVal::Free(ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(ctrlr_dom.domain);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.domain);
+ return vtn_ctrlr_span_rt_code;
+ }
+
+ for (std::list<controller_domain_t>::iterator it= list_ctrlr_dom.begin();
+ it != list_ctrlr_dom.end(); ++it) {
+ ConfigKeyVal* tmp_okey = NULL;
int ctrl_len = strcmp((const char*)(ctrlr_dom.ctrlr),
- (const char*)(tmp_ctrlr_dom.ctrlr));
+ reinterpret_cast<const char *>(it->ctrlr));
int dom_len = strcmp((const char*)(ctrlr_dom.domain),
- (const char*)(tmp_ctrlr_dom.domain));
+ reinterpret_cast<const char *>(it->domain));
if ((ctrl_len < 0) || ((ctrl_len == 0) && (dom_len < 0))) {
- uuu::upll_strncpy(l_key_vtn_ff_ctrl->controller_name,
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(it->ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Key not supported by controller IN ReadSibling");
+ FREE_LIST_CTRLR(list_ctrlr_dom);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(okey);
+ ConfigKeyVal::Free(ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(ctrlr_dom.domain);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.domain);
+ return result_code;
+ }
+
+ key_vtn_flowfilter_controller_t *tmp_ff_ctrl =
+ reinterpret_cast <key_vtn_flowfilter_controller_t*>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_controller_t)));
+ uuu::upll_strncpy(tmp_ff_ctrl->vtn_key.vtn_name,
+ key_vtn_ff_ctrl->vtn_key.vtn_name,
+ (kMaxLenVtnName +1));
+ uuu::upll_strncpy(tmp_ff_ctrl->controller_name,
+ reinterpret_cast<const char *>(it->ctrlr),
+ (kMaxLenCtrlrId +1));
+ uuu::upll_strncpy(tmp_ff_ctrl->domain_id,
+ reinterpret_cast<const char *>(it->domain),
+ (kMaxLenDomainId +1));
+ tmp_okey = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_CONTROLLER,
+ IpctSt::kIpcStKeyVtnFlowfilterController,
+ tmp_ff_ctrl, NULL);
+
+ val_flowfilter_controller_t* tmp_val_ff_ctrl =
+ reinterpret_cast <val_flowfilter_controller_t*>
+ (ConfigKeyVal::Malloc(sizeof(val_flowfilter_controller_t)));
+ memcpy(tmp_val_ff_ctrl, val_ff_ctrl,
+ sizeof(val_flowfilter_controller_t));
+ tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowfilterController,
+ tmp_val_ff_ctrl);
+ uuu::upll_strncpy(tmp_ctrlr_dom.ctrlr,
+ reinterpret_cast<const char *>(it->ctrlr),
+ (kMaxLenCtrlrId +1));
+ uuu::upll_strncpy(tmp_ctrlr_dom.domain,
+ reinterpret_cast<const char *>(it->domain),
+ (kMaxLenDomainId +1));
+ uuu::upll_strncpy(l_key_vtn_ff_ctrl->controller_name,
tmp_ctrlr_dom.ctrlr, (kMaxLenCtrlrId +1));
- uuu::upll_strncpy(l_key_vtn_ff_ctrl->domain_id,
+ uuu::upll_strncpy(l_key_vtn_ff_ctrl->domain_id,
tmp_ctrlr_dom.domain, (kMaxLenDomainId +1));
- l_val->sequence_num = key_vtn_ffe_ctrl->sequence_num;
- IpcResponse ipc_resp;
- memset(&ipc_resp, 0, sizeof(IpcResponse));
- IpcRequest ipc_req;
- memset(&ipc_req, 0, sizeof(IpcRequest));
- ipc_req.header.clnt_sess_id = req->clnt_sess_id;
- ipc_req.header.config_id = req->config_id;
- ipc_req.header.operation = UNC_OP_READ;
- ipc_req.header.option1 = req->option1;
- ipc_req.header.datatype = req->datatype;
- ipc_req.ckv_data = l_key;
-
- if (!IpcUtil::SendReqToDriver(
- (const char *)ctrlr_dom.ctrlr,
- reinterpret_cast<char *>(ctrlr_dom.domain),
+
+ IpcResponse ipc_resp;
+ memset(&ipc_resp, 0, sizeof(IpcResponse));
+ IpcRequest ipc_req;
+ memset(&ipc_req, 0, sizeof(IpcRequest));
+ ipc_req.header.clnt_sess_id = req->clnt_sess_id;
+ ipc_req.header.config_id = req->config_id;
+ ipc_req.header.operation = UNC_OP_READ;
+ ipc_req.header.option1 = req->option1;
+ ipc_req.header.datatype = req->datatype;
+ // Added "GetRenamedControllerKey"
+ UPLL_LOG_DEBUG("Calling GetRenamedControllerKeyin ReadSibling");
+ result_code = GetRenamedControllerKey(l_key, req->datatype, dmi,
+ &tmp_ctrlr_dom);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetRenamedControllerKey Failed %d", result_code);
+ FREE_LIST_CTRLR(list_ctrlr_dom);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(tmp_okey);
+ DELETE_IF_NOT_NULL(okey);
+ ConfigKeyVal::Free(ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(ctrlr_dom.domain);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.domain);
+ return result_code;
+ }
+ ipc_req.ckv_data = l_key;
+ if (!IpcUtil::SendReqToDriver(
+ (const char *)tmp_ctrlr_dom.ctrlr,
+ reinterpret_cast<char *>(tmp_ctrlr_dom.domain),
PFCDRIVER_SERVICE_NAME, PFCDRIVER_SVID_LOGICAL,
&ipc_req, true, &ipc_resp)) {
- UPLL_LOG_DEBUG("SendReqToDriver failed for Key %d controller %s",
+ UPLL_LOG_DEBUG("SendReqToDriver failed for Key %d controller %s",
l_key->get_key_type(),
- reinterpret_cast<char *>(ctrlr_dom.ctrlr));
- return UPLL_RC_ERR_GENERIC;
- }
-
- if (ipc_resp.header.result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Driver response for Key %d controller %s result %d",
- l_key->get_key_type(), ctrlr_dom.ctrlr,
+ reinterpret_cast<char *>(tmp_ctrlr_dom.ctrlr));
+ DELETE_IF_NOT_NULL(tmp_okey);
+ FREE_LIST_CTRLR(list_ctrlr_dom);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ ConfigKeyVal::Free(ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(ctrlr_dom.domain);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.domain);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (ipc_resp.header.result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Driver response for Key %d controller %s result %d",
+ l_key->get_key_type(), tmp_ctrlr_dom.ctrlr,
ipc_resp.header.result_code);
- return ipc_resp.header.result_code;
- }
- result_code = ConstructReadSiblingDetailResponse(
- tmp_key,
- ipc_resp.ckv_data,
- req->datatype,
- dmi, &okey);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ConstructReadDetailResponse error code (%d)",
- result_code);
- return result_code;
- }
- } else {
- result_code = UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ DELETE_IF_NOT_NULL(tmp_okey);
+ FREE_LIST_CTRLR(list_ctrlr_dom);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ ConfigKeyVal::Free(ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(ctrlr_dom.domain);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.domain);
+ return ipc_resp.header.result_code;
+ }
+
+ tmp_okey->AppendCfgVal((ipc_resp.ckv_data)->GetCfgValAndUnlink());
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ tmp_sib_count++;
+ if (okey == NULL) {
+ okey = tmp_okey;
+ } else {
+ okey->AppendCfgKeyVal(tmp_okey);
}
- tmp_key = tmp_key->get_next_cfg_key_val();
+ if (tmp_sib_count == req->rep_count)
+ break;
+ } else {
+ result_code = UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ }
+ if (tmp_sib_count == req->rep_count)
+ break;
}
if ((okey != NULL) && (result_code == UPLL_RC_SUCCESS)) {
ikey->ResetWith(okey);
+ DELETE_IF_NOT_NULL(okey);
+ req->rep_count = tmp_sib_count;
}
+ FREE_LIST_CTRLR(list_ctrlr_dom);
} else if (req->operation == UNC_OP_READ_SIBLING_BEGIN) {
- while (tmp_key != NULL) {
- GET_USER_DATA_CTRLR_DOMAIN(tmp_key, ctrlr_dom);
- uuu::upll_strncpy(l_key_vtn_ff_ctrl->controller_name,
- ctrlr_dom.ctrlr, (kMaxLenCtrlrId +1));
- uuu::upll_strncpy(l_key_vtn_ff_ctrl->domain_id,
- ctrlr_dom.domain, (kMaxLenDomainId +1));
- l_val->sequence_num = key_vtn_ffe_ctrl->sequence_num;
- IpcResponse ipc_resp;
- memset(&ipc_resp, 0, sizeof(IpcResponse));
- IpcRequest ipc_req;
- memset(&ipc_req, 0, sizeof(IpcRequest));
- ipc_req.header.clnt_sess_id = req->clnt_sess_id;
- ipc_req.header.config_id = req->config_id;
- ipc_req.header.operation = UNC_OP_READ;
- ipc_req.header.option1 = req->option1;
- ipc_req.header.datatype = req->datatype;
- ipc_req.ckv_data = l_key;
- if (!IpcUtil::SendReqToDriver(
- (const char *)ctrlr_dom.ctrlr,
- reinterpret_cast<char *>(ctrlr_dom.domain),
- PFCDRIVER_SERVICE_NAME, PFCDRIVER_SVID_LOGICAL, &ipc_req,
- true, &ipc_resp)) {
- UPLL_LOG_DEBUG("SendReqToDriver failed for Key %d controller %s",
- l_key->get_key_type(),
- reinterpret_cast<char *>(ctrlr_dom.ctrlr));
- return UPLL_RC_ERR_GENERIC;
- }
-
- if (ipc_resp.header.result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Driver response for Key %d controller %s result %d",
- l_key->get_key_type(), ctrlr_dom.ctrlr,
- ipc_resp.header.result_code);
- return ipc_resp.header.result_code;
- }
-
- result_code = ConstructReadSiblingDetailResponse(
- tmp_key,
- ipc_resp.ckv_data,
- req->datatype,
- dmi, &okey);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ConstructReadDetailResponse error code (%d)",
- result_code);
- return result_code;
- }
- tmp_key = tmp_key->get_next_cfg_key_val();
+ std::list<controller_domain_t> list_ctrlr_dom;
+ vtn_ctrlr_span_rt_code = GetVtnControllerSpan(ikey,
+ req->datatype, dmi, list_ctrlr_dom);
+ if ((vtn_ctrlr_span_rt_code != UPLL_RC_SUCCESS) &&
+ (vtn_ctrlr_span_rt_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG(" GetVtnControllerSpan error code (%d)",
+ vtn_ctrlr_span_rt_code);
+ DELETE_IF_NOT_NULL(l_key);
+ FREE_LIST_CTRLR(list_ctrlr_dom);
+ ConfigKeyVal::Free(ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(ctrlr_dom.domain);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.domain);
+ return vtn_ctrlr_span_rt_code;
}
- if ((okey != NULL) && (result_code == UPLL_RC_SUCCESS)) {
- ikey->ResetWith(okey);
+ for (std::list<controller_domain_t>::iterator it= list_ctrlr_dom.begin();
+ it != list_ctrlr_dom.end(); ++it) {
+ result_code = ValidateCapability(req, ikey,
+ reinterpret_cast<const char *>(it->ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Key not supported by controller IN ReadSibling");
+ DELETE_IF_NOT_NULL(l_key);
+ FREE_LIST_CTRLR(list_ctrlr_dom);
+ ConfigKeyVal::Free(ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(ctrlr_dom.domain);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.domain);
+ return result_code;
}
- } else {
- result_code = UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
- }
- return result_code;
-}
-
-upll_rc_t VtnFlowFilterEntryMoMgr::ConstructReadSiblingDetailResponse(
- ConfigKeyVal *ikey ,
- ConfigKeyVal *drv_resp_ckv,
- upll_keytype_datatype_t dt_type,
- DalDmlIntf *dmi,
- ConfigKeyVal **okey) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- ConfigKeyVal *tmp_okey = NULL;
- ConfigVal *drv_resp_val = NULL;
- controller_domain ctrlr_dom;
- drv_resp_val = drv_resp_ckv->get_cfg_val();
- // Extracting The Key of KT_VTN_FF_Ctrl
-
- key_vtn_flowfilter_entry_t *key_vtn_ffe =
- reinterpret_cast <key_vtn_flowfilter_entry_t*>
- (ikey->get_key());
- memset(&ctrlr_dom, 0, sizeof(controller_domain));
- GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
-
- key_vtn_flowfilter_controller_t *tmp_ff_ctrl =
+ key_vtn_flowfilter_controller_t *tmp_ff_ctrl =
reinterpret_cast <key_vtn_flowfilter_controller_t*>
(ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_controller_t)));
- uuu::upll_strncpy(tmp_ff_ctrl->vtn_key.vtn_name,
- key_vtn_ffe->flowfilter_key.vtn_key.vtn_name,
+ uuu::upll_strncpy(tmp_ff_ctrl->vtn_key.vtn_name,
+ key_vtn_ff_ctrl->vtn_key.vtn_name,
(kMaxLenVtnName +1));
- uuu::upll_strncpy(tmp_ff_ctrl->controller_name, ctrlr_dom.ctrlr,
+ uuu::upll_strncpy(tmp_ff_ctrl->controller_name,
+ reinterpret_cast<const char *>(it->ctrlr),
(kMaxLenCtrlrId +1));
- uuu::upll_strncpy(tmp_ff_ctrl->domain_id, ctrlr_dom.domain,
+ uuu::upll_strncpy(tmp_ff_ctrl->domain_id,
+ reinterpret_cast<const char *>(it->domain),
(kMaxLenDomainId +1));
- tmp_okey = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_CONTROLLER,
+ tmp_okey = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_CONTROLLER,
IpctSt::kIpcStKeyVtnFlowfilterController,
tmp_ff_ctrl, NULL);
- val_flowfilter_controller_t* tmp_val_ff_ctrl =
- reinterpret_cast <val_flowfilter_controller_t*>
- (ConfigKeyVal::Malloc(sizeof(val_flowfilter_controller_t)));
-
- tmp_val_ff_ctrl->valid[UPLL_IDX_DIRECTION_FFC] = UNC_VF_VALID;
- tmp_val_ff_ctrl->direction = key_vtn_ffe->flowfilter_key.input_direction;
- tmp_val_ff_ctrl->valid[UPLL_IDX_SEQ_NUM_FFC] = UNC_VF_VALID;
- tmp_val_ff_ctrl->sequence_num = key_vtn_ffe->sequence_num;
-
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowfilterController,
+ val_flowfilter_controller_t* tmp_val_ff_ctrl =
+ reinterpret_cast <val_flowfilter_controller_t*>
+ (ConfigKeyVal::Malloc(sizeof(val_flowfilter_controller_t)));
+ memcpy(tmp_val_ff_ctrl, val_ff_ctrl, sizeof(val_flowfilter_controller_t));
+ tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowfilterController,
tmp_val_ff_ctrl);
+ uuu::upll_strncpy(ctrlr_dom.ctrlr,
+ reinterpret_cast<const char *>(it->ctrlr),
+ (kMaxLenCtrlrId +1));
+ uuu::upll_strncpy(ctrlr_dom.domain,
+ reinterpret_cast<const char *>(it->domain),
+ (kMaxLenDomainId +1));
+ uuu::upll_strncpy(l_key_vtn_ff_ctrl->controller_name,
+ ctrlr_dom.ctrlr, (kMaxLenCtrlrId +1));
+ uuu::upll_strncpy(l_key_vtn_ff_ctrl->domain_id,
+ ctrlr_dom.domain, (kMaxLenDomainId +1));
- while (drv_resp_val !=NULL) {
- if (IpctSt::kIpcStValVtnFlowfilterControllerSt !=
- drv_resp_val->get_st_num()) {
- UPLL_LOG_DEBUG("Incorrect structure received from driver, struct num %d",
- drv_resp_val->get_st_num());
- return UPLL_RC_ERR_GENERIC;
- }
- // Now Cheking The 1st Structure of Driver Rersponse
- // is val_vtn_flowfilter_controller_st or Not
- val_vtn_flowfilter_controller_st_t *tmp_vtn_ffe_st =
- reinterpret_cast <val_vtn_flowfilter_controller_st_t *>
- (drv_resp_val->get_val());
- // Check Seq No is Valid Or not
- if ((tmp_vtn_ffe_st)->valid[UPLL_IDX_SEQ_NUM_VFFCS] == UNC_VF_VALID) {
- /******* StartReading From The Vtn_FlowFilter_Entry_CtrlTable*******/
- // Copying The seqno, i/p dir, Vtn_Name to The Above Key of CKV tctrl_key
- ConfigKeyVal *tctrl_key = NULL;
- // Allocating The Key of KT_VTN_FF_Entry
- key_vtn_flowfilter_entry_t *key_vtn_ffe_ctrl =
- reinterpret_cast <key_vtn_flowfilter_entry_t*>
- (ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_entry_t)));
- tctrl_key = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_ENTRY,
- IpctSt::kIpcStKeyVtnFlowfilterEntry,
- key_vtn_ffe_ctrl, NULL);
-
- key_vtn_ffe_ctrl->sequence_num = tmp_vtn_ffe_st->sequence_num;
- uuu::upll_strncpy(
- key_vtn_ffe_ctrl->flowfilter_key.vtn_key.vtn_name,
- key_vtn_ffe->flowfilter_key.vtn_key.vtn_name,
- (kMaxLenVtnName +1));
- key_vtn_ffe_ctrl->flowfilter_key.input_direction =
- key_vtn_ffe->flowfilter_key.input_direction;
- SET_USER_DATA_CTRLR(tctrl_key, ctrlr_dom.ctrlr);
- SET_USER_DATA_DOMAIN(tctrl_key, ctrlr_dom.domain);
- // Reading The Entry_Ctrl_Table
-
- DbSubOp dbop1 = { kOpReadSingle, kOpMatchCtrlr|kOpMatchDomain,
- kOpInOutNone };
- result_code = ReadConfigDB(tctrl_key, dt_type, UNC_OP_READ,
- dbop1, dmi, CTRLRTBL);
- // Extracting The Val from CKV tctrl_key
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Exiting :ReadConfigDB Ctrltable Failed");
- delete tmp_okey;
- delete tctrl_key;
- return result_code;
- }
-
- val_vtn_flowfilter_entry_ctrlr_t* val_vtn_ffe_ctrlr =
- reinterpret_cast<val_vtn_flowfilter_entry_ctrlr_t*>
- (GetVal(tctrl_key));
- if (val_vtn_ffe_ctrlr == NULL) {
- UPLL_LOG_DEBUG("Exiting val_vtn_flowfilter_entry_ctrlr is Null \n");
- return result_code;
- }
-
- val_vtn_flowfilter_entry_t *op_val_vtn_ffe =
- reinterpret_cast<val_vtn_flowfilter_entry_t *>
- (ConfigKeyVal::Malloc(sizeof(val_vtn_flowfilter_entry_t)));
-
- result_code = GetCtrlFlowFilterEntry(key_vtn_ffe_ctrl,
- val_vtn_ffe_ctrlr,
- dt_type,
- dmi,
- op_val_vtn_ffe);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetCtrlFlowFilterEntry error code (%d)", result_code);
- return result_code;
- }
+ IpcResponse ipc_resp;
+ memset(&ipc_resp, 0, sizeof(IpcResponse));
+ IpcRequest ipc_req;
+ memset(&ipc_req, 0, sizeof(IpcRequest));
+ ipc_req.header.clnt_sess_id = req->clnt_sess_id;
+ ipc_req.header.config_id = req->config_id;
+ ipc_req.header.operation = UNC_OP_READ;
+ ipc_req.header.option1 = req->option1;
+ ipc_req.header.datatype = req->datatype;
+ // Added "GetRenamedControllerKey"
+ UPLL_LOG_INFO("Calling GetRenamedControllerKeyin ReadSibling");
+ result_code = GetRenamedControllerKey(l_key, req->datatype, dmi,
+ &ctrlr_dom);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetRenamedControllerKey Failed %d", result_code);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(tmp_okey);
+ FREE_LIST_CTRLR(list_ctrlr_dom);
+ ConfigKeyVal::Free(ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(ctrlr_dom.domain);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.domain);
+ return result_code;
+ }
+ ipc_req.ckv_data = l_key;
+ if (!IpcUtil::SendReqToDriver(
+ (const char *)ctrlr_dom.ctrlr,
+ reinterpret_cast<char *>(ctrlr_dom.domain),
+ PFCDRIVER_SERVICE_NAME, PFCDRIVER_SVID_LOGICAL, &ipc_req,
+ true, &ipc_resp)) {
+ UPLL_LOG_DEBUG("SendReqToDriver failed for Key %d controller %s",
+ l_key->get_key_type(),
+ reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(tmp_okey);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ FREE_LIST_CTRLR(list_ctrlr_dom);
+ ConfigKeyVal::Free(ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(ctrlr_dom.domain);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.domain);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (ipc_resp.header.result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Driver response for Key %d controller %s result %d",
+ l_key->get_key_type(), ctrlr_dom.ctrlr,
+ ipc_resp.header.result_code);
+ DELETE_IF_NOT_NULL(l_key);
+ DELETE_IF_NOT_NULL(tmp_okey);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ FREE_LIST_CTRLR(list_ctrlr_dom);
+ ConfigKeyVal::Free(ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(ctrlr_dom.domain);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.domain);
+ return ipc_resp.header.result_code;
+ }
+ tmp_okey->AppendCfgVal((ipc_resp.ckv_data)->GetCfgValAndUnlink());
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ if (okey == NULL) {
+ okey = tmp_okey;
+ } else {
+ okey->AppendCfgKeyVal(tmp_okey);
+ }
- /*Reading From The Vtn_FlowFilter_Entry_CtrlTable Finished */
- // CKV tkey Consist The key_vtn_flowfilter_entry And
- // Will Be used To Read The VTN_FF_ENTRY_TBL
- /*Reading From VtnFlowfilterEntryTbl Start*/
- // Appending The Ctrl St
- val_vtn_flowfilter_controller_st_t *l_val_ff_st =reinterpret_cast
- <val_vtn_flowfilter_controller_st_t* >
- (ConfigKeyVal::Malloc(sizeof(val_vtn_flowfilter_controller_st_t)));
- memcpy(l_val_ff_st, tmp_vtn_ffe_st,
- sizeof(val_vtn_flowfilter_controller_st_t));
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValVtnFlowfilterControllerSt,
- l_val_ff_st);
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValVtnFlowfilterEntry,
- op_val_vtn_ffe);
-
- if ((drv_resp_val = drv_resp_val->get_next_cfg_val()) == NULL) {
- UPLL_LOG_DEBUG("No More entries in driver response\n");
- break;
- }
- // Appending The FlowlistEntry St
- if (IpctSt::kIpcStValFlowlistEntrySt != drv_resp_val->get_st_num()) {
- UPLL_LOG_DEBUG("No flowflist entries returned by driver");
- continue;
- }
- while (IpctSt::kIpcStValFlowlistEntrySt == (
- drv_resp_val)->get_st_num()) {
- val_flowlist_entry_st_t* tmp_val_fl_st =
- reinterpret_cast<val_flowlist_entry_st_t*>
- (ConfigKeyVal::Malloc(sizeof(val_flowlist_entry_st_t)));
- memcpy(tmp_val_fl_st,
- reinterpret_cast<val_flowlist_entry_st_t*>
- (drv_resp_val->get_val()),
- sizeof(val_flowlist_entry_st_t));
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowlistEntrySt,
- tmp_val_fl_st);
- drv_resp_val = drv_resp_val->get_next_cfg_val();
- if (!drv_resp_val) {
- break;
- }
- }
+ tmp_sib_count++;
+ if (tmp_sib_count == req->rep_count)
+ break;
+ }
+ if ((okey != NULL) && (result_code == UPLL_RC_SUCCESS)) {
+ ikey->ResetWith(okey);
+ req->rep_count = tmp_sib_count;
+ DELETE_IF_NOT_NULL(okey);
}
- }
- if (*okey == NULL) {
- *okey = tmp_okey;
+ FREE_LIST_CTRLR(list_ctrlr_dom);
} else {
- (*okey)->AppendCfgKeyVal(tmp_okey);
+ result_code = UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
- return UPLL_RC_SUCCESS;
+
+ ConfigKeyVal::Free(ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(ctrlr_dom.domain);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.ctrlr);
+ ConfigKeyVal::Free(tmp_ctrlr_dom.domain);
+ DELETE_IF_NOT_NULL(l_key);
+ return result_code;
}
upll_rc_t VtnFlowFilterEntryMoMgr::ReadControllerStateDetail(
ConfigKeyVal *ikey ,
ConfigKeyVal *drv_resp_ckv,
- upll_keytype_datatype_t dt_type,
- unc_keytype_operation_t op,
- DalDmlIntf *dmi,
controller_domain *ctrlr_dom,
ConfigKeyVal **okey) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- ConfigKeyVal *tmp_okey = NULL;
key_vtn_flowfilter_controller_t *key_vtn_ffe =
reinterpret_cast <key_vtn_flowfilter_controller_t*>
(ikey->get_key());
- key_vtn_flowfilter_controller_t *tmp_ff_ctrl =
- reinterpret_cast <key_vtn_flowfilter_controller_t*>
- (ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_controller_t)));
- uuu::upll_strncpy(tmp_ff_ctrl->vtn_key.vtn_name,
- key_vtn_ffe->vtn_key.vtn_name,
- (kMaxLenVtnName +1));
- uuu::upll_strncpy(tmp_ff_ctrl->controller_name, (*ctrlr_dom).ctrlr,
- (kMaxLenCtrlrId +1));
- uuu::upll_strncpy(tmp_ff_ctrl->domain_id, (*ctrlr_dom).domain,
- (kMaxLenDomainId +1));
- tmp_okey = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_CONTROLLER,
- IpctSt::kIpcStKeyVtnFlowfilterController,
- tmp_ff_ctrl, NULL);
+ val_flowfilter_controller_t *ival = reinterpret_cast
+ <val_flowfilter_controller_t *>(GetVal(ikey));
- val_flowfilter_controller_t *val_ff_ctrl =
- reinterpret_cast<val_flowfilter_controller_t*>
+ if (*okey == NULL) {
+ key_vtn_flowfilter_controller_t *tmp_ff_ctrl =
+ reinterpret_cast <key_vtn_flowfilter_controller_t*>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_controller_t)));
+ uuu::upll_strncpy(tmp_ff_ctrl->vtn_key.vtn_name,
+ key_vtn_ffe->vtn_key.vtn_name,
+ (kMaxLenVtnName +1));
+ uuu::upll_strncpy(tmp_ff_ctrl->controller_name, (*ctrlr_dom).ctrlr,
+ (kMaxLenCtrlrId +1));
+ uuu::upll_strncpy(tmp_ff_ctrl->domain_id, (*ctrlr_dom).domain,
+ (kMaxLenDomainId +1));
+ *okey = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_CONTROLLER,
+ IpctSt::kIpcStKeyVtnFlowfilterController,
+ tmp_ff_ctrl, NULL);
+ val_flowfilter_controller_t* tmp_val_ff_ctrl =
+ reinterpret_cast <val_flowfilter_controller_t*>
(ConfigKeyVal::Malloc(sizeof(val_flowfilter_controller_t)));
- val_flowfilter_controller_t *tmp_val_ff_ctrl =
- reinterpret_cast<val_flowfilter_controller_t*>(GetVal(ikey));
- if (!tmp_val_ff_ctrl) {
- UPLL_LOG_DEBUG(" Invalid value read from DB");
- free(val_ff_ctrl);
- return UPLL_RC_ERR_GENERIC;
- }
- memcpy(val_ff_ctrl, tmp_val_ff_ctrl, sizeof(val_flowfilter_controller_t));
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowfilter, val_ff_ctrl);
-
-
- ConfigVal *drv_resp_val = drv_resp_ckv->get_cfg_val();
- // Extracting The Key of KT_VTN_FF_Ctrl
- key_vtn_flowfilter_controller_t *key_vtn_ff_ctrl =
- reinterpret_cast<key_vtn_flowfilter_controller_t*> (ikey->get_key());
-
- while (drv_resp_val != NULL) {
- // Now Cheking The 1st Structure of Driver Rersponse
- // is val_vtn_flowfilter_controller_st or Not
- if (IpctSt::kIpcStValVtnFlowfilterControllerSt !=
- drv_resp_val->get_st_num()) {
- return UPLL_RC_ERR_GENERIC;
- }
- val_vtn_flowfilter_controller_st_t * val_vtn_ff_ctrl_st =
- reinterpret_cast <val_vtn_flowfilter_controller_st_t *>
- (drv_resp_val->get_val());
- // Check Seq No is Valid Or not
- if ((val_vtn_ff_ctrl_st)->valid[UPLL_IDX_SEQ_NUM_VFFCS] == UNC_VF_VALID) {
- /******* StartReading From The Vtn_FlowFilter_Entry_CtrlTable*******/
- // Copying The seqno, i/p dir, Vtn_Name to The Above Key of CKV tctrl_key
- // Allocating The Key of KT_VTN_FF_Entry
- key_vtn_flowfilter_entry_t *key_vtn_ffe_ctrl =
- reinterpret_cast <key_vtn_flowfilter_entry_t*>
- (ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_entry_t)));
-
- ConfigKeyVal *tctrl_key = new ConfigKeyVal(
- UNC_KT_VTN_FLOWFILTER_ENTRY,
- IpctSt::kIpcStKeyVtnFlowfilterEntry,
- key_vtn_ffe_ctrl, NULL);
-
- key_vtn_ffe_ctrl->sequence_num = val_vtn_ff_ctrl_st->sequence_num;
- uuu::upll_strncpy(
- key_vtn_ffe_ctrl->flowfilter_key.vtn_key.vtn_name,
- key_vtn_ff_ctrl->vtn_key.vtn_name,
- (kMaxLenVtnName +1));
- key_vtn_ffe_ctrl->flowfilter_key.input_direction =
- val_vtn_ff_ctrl_st->direction;
-
- SET_USER_DATA_CTRLR(tctrl_key, ctrlr_dom->ctrlr);
- SET_USER_DATA_DOMAIN(tctrl_key, ctrlr_dom->domain);
- // Reading The Entry_Ctrl_Table
-
- DbSubOp dbop1 = { kOpReadSingle, kOpMatchCtrlr|kOpMatchDomain,
- kOpInOutNone };
- result_code = ReadConfigDB(tctrl_key, dt_type, UNC_OP_READ,
- dbop1, dmi, CTRLRTBL);
- // Extracting The Val from CKV tctrl_key
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Exiting :ReadConfigDB Ctrltable Failed");
- delete tmp_okey;
- delete tctrl_key;
- return result_code;
- }
-
- val_vtn_flowfilter_entry_ctrlr_t *val_vtn_ffe_ctrlr =
- reinterpret_cast<val_vtn_flowfilter_entry_ctrlr_t*>
- (GetVal(tctrl_key));
- if (val_vtn_ffe_ctrlr == NULL) {
- UPLL_LOG_DEBUG("Exiting val_vtn_ffe_ctrlr is Null \n");
- return result_code;
- }
- /*Reading From The Vtn_FlowFilter_Entry_CtrlTable Finished */
- // CKV tkey Consist The key_vtn_flowfilter_entry And
- // Will Be used To Read The VTN_FF_ENTRY_TBL
- /*Reading From VtnFlowfilterEntryTbl Start*/
- key_vtn_flowfilter_entry_t *key_vtn_ffe =
- reinterpret_cast<key_vtn_flowfilter_entry_t *>
- (ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_entry_t)));
-
- // Now Matching Seq NO, Dir, VTNNAME To KEY of CKV tkey
- uuu::upll_strncpy(
- key_vtn_ffe->flowfilter_key.vtn_key.vtn_name,
- key_vtn_ff_ctrl->vtn_key.vtn_name, (kMaxLenVtnName +1));
- key_vtn_ffe->flowfilter_key.input_direction =
- val_vtn_ff_ctrl_st->direction;
- key_vtn_ffe->sequence_num =
- val_vtn_ff_ctrl_st->sequence_num;
- val_vtn_flowfilter_entry_t *op_val_vtn_ffe =
- reinterpret_cast<val_vtn_flowfilter_entry_t *>
- (ConfigKeyVal::Malloc(sizeof(val_vtn_flowfilter_entry_t)));
-
- result_code = GetCtrlFlowFilterEntry(key_vtn_ffe,
- val_vtn_ffe_ctrlr,
- dt_type,
- dmi,
- op_val_vtn_ffe);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetCtrlFlowFilterEntry error code (%d)", result_code);
- return result_code;
- }
-
- // Appending The Ctrl St
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValVtnFlowfilterControllerSt,
- val_vtn_ff_ctrl_st);
- // Appending The VAl_FF_Entry
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValVtnFlowfilterEntry,
- op_val_vtn_ffe);
-
- if ((drv_resp_val = drv_resp_val->get_next_cfg_val()) == NULL) {
- UPLL_LOG_DEBUG("Next Vlaue structure is null\n");
- break;
- }
-
- if (IpctSt::kIpcStValFlowlistEntrySt != (drv_resp_val)->get_st_num()) {
- UPLL_LOG_DEBUG("No flowflist entries returned by driver");
- continue;
- }
- // Appending The FlowlistEntry st
- while (IpctSt::kIpcStValFlowlistEntrySt == drv_resp_val->get_st_num()) {
- val_flowlist_entry_st_t* tmp_val_fl_st =
- reinterpret_cast<val_flowlist_entry_st_t*>
- (ConfigKeyVal::Malloc(sizeof(val_flowlist_entry_st_t)));
- memcpy(tmp_val_fl_st,
- reinterpret_cast<val_flowlist_entry_st_t*>
- (drv_resp_val->get_val()),
- sizeof(val_flowlist_entry_st_t));
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowlistEntrySt,
- tmp_val_fl_st);
- drv_resp_val = drv_resp_val->get_next_cfg_val();
- if (!drv_resp_val) {
- break;
- }
- }
- }
- }
- if (*okey == NULL) {
- *okey = tmp_okey;
- } else {
- (*okey)->AppendCfgKeyVal(tmp_okey);
+ memcpy(tmp_val_ff_ctrl, ival, sizeof(val_flowfilter_controller_t));
+ (*okey)->AppendCfgVal(IpctSt::kIpcStValFlowfilterController,
+ tmp_val_ff_ctrl);
}
- return UPLL_RC_SUCCESS;
+ ConfigKeyVal *tmp_okey = *okey;
+ tmp_okey->AppendCfgVal(drv_resp_ckv->GetCfgValAndUnlink());
+ return result_code;
}
upll_rc_t VtnFlowFilterEntryMoMgr::ConstructReadSiblingNormalResponse(
ConfigKeyVal **okey) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- ConfigKeyVal *tmp_okey = NULL;
controller_domain ctrlr_dom;
-
- key_vtn_flowfilter_entry_t *key_vtn_ffe =
- reinterpret_cast <key_vtn_flowfilter_entry_t*>
- (ikey->get_key());
memset(&ctrlr_dom, 0, sizeof(controller_domain));
GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
-
- key_vtn_flowfilter_controller_t *tmp_ff_ctrl =
- reinterpret_cast <key_vtn_flowfilter_controller_t*>
- (ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_controller_t)));
- uuu::upll_strncpy(tmp_ff_ctrl->vtn_key.vtn_name,
- key_vtn_ffe->flowfilter_key.vtn_key.vtn_name,
- (kMaxLenVtnName +1));
- uuu::upll_strncpy(tmp_ff_ctrl->controller_name, ctrlr_dom.ctrlr,
- (kMaxLenCtrlrId +1));
- uuu::upll_strncpy(tmp_ff_ctrl->domain_id, ctrlr_dom.domain,
- (kMaxLenDomainId +1));
- tmp_okey = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_CONTROLLER,
- IpctSt::kIpcStKeyVtnFlowfilterController,
- tmp_ff_ctrl, NULL);
-
- ConfigKeyVal *tctrl_key = NULL;
// Allocating The Key of KT_VTN_FF_Entry
- key_vtn_flowfilter_entry_t *key_vtn_ffe_ctrl =
- reinterpret_cast <key_vtn_flowfilter_entry_t*>
- (ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_entry_t)));
-
- memcpy(key_vtn_ffe_ctrl, key_vtn_ffe, sizeof(key_vtn_flowfilter_entry_t));
-
// Allocating CKV tctrl_key
- tctrl_key = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_ENTRY,
- IpctSt::kIpcStKeyVtnFlowfilterEntry,
- key_vtn_ffe_ctrl, NULL);
-
// Reading The Entry_Ctrl_Table
- SET_USER_DATA_CTRLR(tctrl_key, ctrlr_dom.ctrlr);
- SET_USER_DATA_DOMAIN(tctrl_key, ctrlr_dom.domain);
-
- DbSubOp dbop1 = { kOpReadMultiple, kOpMatchCtrlr|kOpMatchDomain,
- kOpInOutNone };
- result_code = ReadConfigDB(tctrl_key, dt_type, UNC_OP_READ,
- dbop1, dmi, CTRLRTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ReadConfigDB is Not Succes");
- }
// Extracting The Val from CKV tctrl_key
- ConfigKeyVal *tmp_key = tctrl_key;
- while (tmp_key != NULL) {
+
val_flowfilter_controller_t* l_val_ff_ctrl =
reinterpret_cast<val_flowfilter_controller_t *>
(ConfigKeyVal::Malloc(sizeof(val_flowfilter_controller_t)));
val_vtn_flowfilter_entry_ctrlr_t* val_vtn_ffe_ctrlr =
- reinterpret_cast<val_vtn_flowfilter_entry_ctrlr_t*>(GetVal(tmp_key));
+ reinterpret_cast<val_vtn_flowfilter_entry_ctrlr_t*>(GetVal(ikey));
key_vtn_flowfilter_entry_t *l_key_vtn_ffe =
- reinterpret_cast<key_vtn_flowfilter_entry_t *> (tmp_key->get_key());
+ reinterpret_cast<key_vtn_flowfilter_entry_t *> (ikey->get_key());
l_val_ff_ctrl->valid[UPLL_IDX_DIRECTION_FFC] = UNC_VF_VALID;
l_val_ff_ctrl->direction = l_key_vtn_ffe->flowfilter_key.input_direction;
l_val_ff_ctrl->valid[UPLL_IDX_SEQ_NUM_FFC] = UNC_VF_VALID;
l_val_ff_ctrl->sequence_num = l_key_vtn_ffe->sequence_num;
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValFlowfilterController,
+ (*okey)->AppendCfgVal(IpctSt::kIpcStValFlowfilterController,
l_val_ff_ctrl);
val_vtn_flowfilter_entry_t *op_val_vtn_ffe =
val_vtn_ffe_ctrlr,
dt_type,
dmi,
- op_val_vtn_ffe);
+ op_val_vtn_ffe,
+ reinterpret_cast<const char*>(ctrlr_dom.ctrlr));
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetCtrlFlowFilterEntry error code (%d)", result_code);
free(op_val_vtn_ffe);
- delete tmp_okey;
- delete tctrl_key;
return result_code;
}
- tmp_okey->AppendCfgVal(IpctSt::kIpcStValVtnFlowfilterEntry, op_val_vtn_ffe);
- tmp_key = tmp_key->get_next_cfg_key_val();
- }
+ (*okey)->AppendCfgVal(IpctSt::kIpcStValVtnFlowfilterEntry, op_val_vtn_ffe);
- if (*okey == NULL) {
- *okey = tmp_okey;
- } else {
- (*okey)->AppendCfgKeyVal(tmp_okey);
- }
return UPLL_RC_SUCCESS;
}
if (UNC_KT_VTN_FLOWFILTER_ENTRY == key->get_key_type()) {
rt_code = ValidateMessageForVtnFlowFilterEntry(req, key);
if (UPLL_RC_SUCCESS != rt_code) {
- UPLL_LOG_DEBUG(" Vtn name syntax validation failed :"
+ UPLL_LOG_DEBUG(" Vtn flowfilter entry validation failed :"
"Err Code - %d",
rt_code);
return rt_code;
rt_code = ValidateMessageForVtnFlowFilterController(req, key);
if (UPLL_RC_SUCCESS != rt_code) {
- UPLL_LOG_DEBUG(" Vtn name syntax validation failed :"
+ UPLL_LOG_DEBUG(" Vtn flowfilter controller validation failed :"
"Err Code - %d",
rt_code);
return rt_code;
UPLL_LOG_DEBUG(" Invalid keytype(%d)", key->get_key_type());
return UPLL_RC_ERR_BAD_REQUEST;
}
+ if ((req->datatype == UPLL_DT_IMPORT) && (req->operation == UNC_OP_READ ||
+ req->operation == UNC_OP_READ_SIBLING ||
+ req->operation == UNC_OP_READ_SIBLING_BEGIN ||
+ req->operation == UNC_OP_READ_NEXT ||
+ req->operation == UNC_OP_READ_BULK ||
+ req->operation == UNC_OP_READ_SIBLING_COUNT)) {
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
return rt_code;
}
UPLL_LOG_DEBUG(" Invalid option2(%d)", req->option2);
return UPLL_RC_ERR_INVALID_OPTION2;
}
- if((req->option1 != UNC_OPT1_NORMAL)
- &&(req->operation == UNC_OP_READ_SIBLING_COUNT)) {
- UPLL_LOG_DEBUG(" Error: option1 is not NORMAL for ReadSiblingCount");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
if (key->get_st_num() != IpctSt::kIpcStKeyVtnFlowfilterEntry) {
UPLL_LOG_DEBUG("Invalid key structure received. received struct num - %d",
UPLL_LOG_DEBUG(" Invalid request(%d)", req->option1);
return UPLL_RC_ERR_INVALID_OPTION1;
}
+
+ if (req->datatype != UPLL_DT_STATE) {
+ UPLL_LOG_DEBUG(" Invalid Datatype(%d)", req->datatype);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+
if (key->get_st_num() != IpctSt::kIpcStKeyVtnFlowfilterController) {
UPLL_LOG_DEBUG("Invalid key structure received. received struct num - %d",
key->get_st_num());
rt_code);
return rt_code;
}
- rt_code = ValidateDefaultStr(reinterpret_cast<char*>(
- key_vtn_flowfilter_controller->domain_id),
- kMinLenDomainId, kMaxLenDomainId);
-
- if (rt_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("DomainId syntax validation failed: Err code-%d",
- rt_code);
- return rt_code;
+ if (!ValidateDefaultStr(key_vtn_flowfilter_controller->domain_id,
+ kMinLenDomainId, kMaxLenDomainId)) {
+ UPLL_LOG_DEBUG("DomainId syntax validation failed:");
+ return UPLL_RC_ERR_CFG_SYNTAX;
}
} else {
memset(key_vtn_flowfilter_controller->controller_name, 0, kMaxLenCtrlrId);
UPLL_LOG_TRACE("val stucture is optional");
return UPLL_RC_SUCCESS;
} else {
- /*TODO(Author): confirm the mandatory param list*/
UPLL_LOG_DEBUG(" val structure is mandatory");
return UPLL_RC_ERR_BAD_REQUEST;
}
return UPLL_RC_ERR_BAD_REQUEST;
}
- val_flowfilter_controller_t *val_flowfilter_controller =
+ val_flowfilter_controller_t *val_ff_ctrlr =
static_cast<val_flowfilter_controller_t *>(
key->get_cfg_val()->get_val());
- if (NULL == val_flowfilter_controller) {
+ if (NULL == val_ff_ctrlr) {
UPLL_LOG_DEBUG("KT_VTN_FLOWFILTER_CONTROLLER val structure is null");
return UPLL_RC_ERR_BAD_REQUEST;
}
return ValidateVtnFlowfilterControllerValue(
- val_flowfilter_controller, req->operation);
+ val_ff_ctrlr, req->operation);
}
upll_rc_t VtnFlowFilterEntryMoMgr::ValidateVtnFlowfilterControllerValue(
- val_flowfilter_controller_t *val_flowfilter_controller,
+ val_flowfilter_controller_t *val_ff_ctrlr,
uint32_t operation) {
UPLL_FUNC_TRACE;
/** Validate value structure*/
- if (val_flowfilter_controller != NULL) {
+ if (val_ff_ctrlr != NULL) {
/** check direction is filled */
- if (val_flowfilter_controller->valid[UPLL_IDX_DIRECTION_FFC]
+ if (val_ff_ctrlr->valid[UPLL_IDX_DIRECTION_FFC]
== UNC_VF_VALID) {
UPLL_LOG_TRACE("direction field is filled");
/** validate direction range */
- if (!ValidateNumericRange(val_flowfilter_controller->direction,
+ if (!ValidateNumericRange(val_ff_ctrlr->direction,
(uint8_t) UPLL_FLOWFILTER_DIR_IN,
(uint8_t) UPLL_FLOWFILTER_DIR_OUT, true,
true)) {
UPLL_LOG_DEBUG(" direction syntax validation failed ");
return UPLL_RC_ERR_CFG_SYNTAX;
}
- } else if (((operation == UNC_OP_UPDATE) || (operation == UNC_OP_CREATE))
-
- && (val_flowfilter_controller->valid[UPLL_IDX_DIRECTION_FFC]
- == UNC_VF_VALID_NO_VALUE)) {
- UPLL_LOG_TRACE("Reset direction");
- val_flowfilter_controller->direction = 0;
}
/** check sequence number is configured */
- if (val_flowfilter_controller->valid[UPLL_IDX_SEQ_NUM_FFC]
+ if (val_ff_ctrlr->valid[UPLL_IDX_SEQ_NUM_FFC]
== UNC_VF_VALID) {
UPLL_LOG_TRACE("seq_num field is filled");
- if (!ValidateNumericRange(val_flowfilter_controller->sequence_num,
+ if (!ValidateNumericRange(val_ff_ctrlr->sequence_num,
kMinFlowFilterSeqNum, kMaxFlowFilterSeqNum,
true, true)) {
UPLL_LOG_DEBUG(" Sequence Number syntax validation failed ");
return UPLL_RC_ERR_CFG_SYNTAX;
}
- } else if (((operation == UNC_OP_UPDATE) || (operation == UNC_OP_CREATE))
- && (val_flowfilter_controller->valid[UPLL_IDX_SEQ_NUM_FFC]
- == UNC_VF_VALID_NO_VALUE)) {
- UPLL_LOG_TRACE("Reset seq_num");
- val_flowfilter_controller->sequence_num = 0;
}
}
return UPLL_RC_SUCCESS;
const char* ctrlr_name) {
UPLL_FUNC_TRACE;
- // TODO(Author) added to bypass capability check
- return UPLL_RC_SUCCESS;
- // endTODO
+
upll_rc_t rt_code = UPLL_RC_ERR_GENERIC;
if ((NULL == req) || (NULL == ikey)) {
- UPLL_LOG_DEBUG("IpcReqRespHeader/ConfigKeyval is NULL");
+ UPLL_LOG_DEBUG("IpcReqRespHeader/ConfigKeyval is NULL");
return rt_code;
}
const char* ctrlr_name) {
UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
-
if (!ctrlr_name)
ctrlr_name = static_cast<char *>(ikey->get_user_data());
- uint32_t dt_type = req->datatype;
- uint32_t operation = req->operation;
- uint32_t option1 = req->option1;
- uint32_t option2 = req->option2;
-
- UPLL_LOG_TRACE("dt_type : (%d)"
- "operation : (%d)"
- "option1 : (%d)"
- "option2 : (%d)",
- dt_type, operation, option1, option2);
+ UPLL_LOG_TRACE("operation : (%d)", req->operation);
bool ret_code = false;
- uint32_t instance_count = 0;
+ uint32_t max_instance_count = 0;
const uint8_t *attrs = NULL;
uint32_t max_attrs = 0;
- switch (operation) {
+ switch (req->operation) {
case UNC_OP_CREATE: {
ret_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
- &instance_count, &max_attrs, &attrs);
+ &max_instance_count, &max_attrs, &attrs);
+ if (ret_code && (max_instance_count != 0) &&
+ (cur_instance_count >= max_instance_count)) {
+ UPLL_LOG_DEBUG("Instance count %d exceeds %d", cur_instance_count,
+ max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
break;
}
case UNC_OP_UPDATE: {
break;
}
default: {
- ret_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ if (req->datatype == UPLL_DT_STATE) {
+ UPLL_LOG_DEBUG("Calling the GetStateCapability");
+ ret_code = GetStateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ } else {
+ UPLL_LOG_DEBUG("Calling the GetReadCapability");
+ ret_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
&max_attrs, &attrs);
+ }
}
}
if (!ret_code) {
UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s) "
"for opearion(%d)",
- ikey->get_key_type(), ctrlr_name, operation);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
- }
-
- val_vtn_flowfilter_entry_t *val_vtn_flowfilter_entry = NULL;
-
- if (ikey->get_cfg_val() && (ikey->get_cfg_val()->get_st_num()
- == IpctSt::kIpcStValVtnFlowfilterEntry)) {
- val_vtn_flowfilter_entry =
- reinterpret_cast<val_vtn_flowfilter_entry_t *>(
- ikey->get_cfg_val()->get_val());
+ ikey->get_key_type(), ctrlr_name, req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
- if ((operation == UNC_OP_CREATE) || (operation == UNC_OP_UPDATE)) {
- if (dt_type == UPLL_DT_CANDIDATE) {
- if (val_vtn_flowfilter_entry) {
- if (max_attrs > 0) {
- return ValVtnFlowfilterEntryAttributeSupportCheck(
- val_vtn_flowfilter_entry, attrs);
- } else {
- UPLL_LOG_DEBUG("Attribute list is empty for operation %d", operation);
- }
- } else {
- UPLL_LOG_TRACE("Error value struct is mandatory for CREATE/UPDATE");
- return result_code;
- }
- } else {
- UPLL_LOG_DEBUG("Unsupported datatype for CREATE/UPDATE");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else if (READ_SUPPORTED_OPERATION) {
- if (READ_SUPPORTED_DATATYPE) {
- if ((option1 != UNC_OPT1_NORMAL)
- && (option1 == UNC_OPT1_DETAIL
- && operation == UNC_OP_READ_SIBLING_COUNT)) {
- UPLL_LOG_DEBUG(" Error: option1 is not NORMAL");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- if (option2 == UNC_OPT2_NONE) {
- UPLL_LOG_DEBUG(" Error: option2 is not NONE");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- if (val_vtn_flowfilter_entry) {
- if (max_attrs > 0) {
- return ValVtnFlowfilterEntryAttributeSupportCheck(
- val_vtn_flowfilter_entry, attrs);
- } else {
- UPLL_LOG_DEBUG("Attribute list is empty for operation %d", operation);
- }
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Error Unsupported datatype(%d)", dt_type);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else if (OPEARTION_WITH_VAL_STRUCT_NONE) {
- /** Value struct is NONE for this operations */
- UPLL_LOG_TRACE("Skip Attribute check, Operation type is %d", operation);
- return UPLL_RC_SUCCESS;
+ val_vtn_flowfilter_entry_t *val_vtn_flowfilter_entry =
+ reinterpret_cast<val_vtn_flowfilter_entry_t *>(GetVal(ikey));
+
+ if (val_vtn_flowfilter_entry) {
+ if (max_attrs > 0) {
+ return ValVtnFlowfilterEntryAttributeSupportCheck(
+ val_vtn_flowfilter_entry, attrs);
+ } else {
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d", req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
}
-
- UPLL_LOG_DEBUG("Error Unsupported operation(%d)", operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ return UPLL_RC_SUCCESS;
}
+
upll_rc_t VtnFlowFilterEntryMoMgr::ValidateCapabilityForVtnFlowFilterController(
IpcReqRespHeader *req,
ConfigKeyVal *ikey,
if (!ctrlr_name)
ctrlr_name = static_cast<char *> (ikey->get_user_data());
+ if (NULL == ctrlr_name) {
+ UPLL_LOG_DEBUG("ctrlr_name is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
bool result_code = false;
const uint8_t *attrs = 0;
uint32_t max_attrs = 0;
- result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ if (req->datatype == UPLL_DT_STATE) {
+ UPLL_LOG_DEBUG("Calling the GetStateCapability");
+ result_code = GetStateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ } else {
+ UPLL_LOG_DEBUG("Calling the GetReadCapability");
+ result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
&max_attrs, &attrs);
+ }
if (!result_code) {
UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s)",
ikey->get_key_type(), ctrlr_name);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
- val_flowfilter_controller_t *val_flowfilter_controller = NULL;
+ val_flowfilter_controller_t *val_ff_ctrlr =
+ reinterpret_cast<val_flowfilter_controller_t *>(GetVal(ikey));
- if (ikey->get_cfg_val() && (ikey->get_cfg_val()->get_st_num() ==
- IpctSt::kIpcStKeyVtnFlowfilterController)) {
- val_flowfilter_controller =
- reinterpret_cast<val_flowfilter_controller_t *>(
- ikey->get_cfg_val()->get_val());
- }
-
- uint32_t dt_type = req->datatype;
- uint32_t operation = req->operation;
- uint32_t option1 = req->option1;
- uint32_t option2 = req->option2;
-
- UPLL_LOG_TRACE("dt_type : (%d)"
- "operation : (%d)"
- "option1 : (%d)"
- "option2 : (%d)",
- dt_type, operation, option1, option2);
-
- if (READ_SUPPORTED_OPERATION) {
- if (dt_type == UPLL_DT_STATE) {
- if ((option1 != UNC_OPT1_NORMAL)
- && (option1 != UNC_OPT1_DETAIL
- && operation == UNC_OP_READ_SIBLING_COUNT)) {
- UPLL_LOG_DEBUG(" Error: option1 is not NORMAL");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- if (option2 != UNC_OPT2_NONE) {
- UPLL_LOG_DEBUG(" Error: option2 is not NONE");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- if (val_flowfilter_controller) {
- if (max_attrs > 0) {
- return ValVtnFlowfilterCtrlAttributeSupportCheck(
- val_flowfilter_controller, attrs);
- } else {
- UPLL_LOG_DEBUG("Attribute list is empty for operation %d", operation);
- }
- } else if (operation != UNC_OP_READ_SIBLING_COUNT) {
- /** value structure is mandatory for all other operation */
- UPLL_LOG_DEBUG("Mandatory value struct is missing");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- /** return SUCCESS, value struct is optional for
- UNC_OP_READ_SIBLING_COUNT */
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Error Unsupported datatype (%d)", dt_type);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ if (val_ff_ctrlr) {
+ if (max_attrs > 0) {
+ return ValVtnFlowfilterCtrlAttributeSupportCheck(
+ val_ff_ctrlr, attrs);
+ } else {
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d", req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
}
- }
- UPLL_LOG_DEBUG("Error Unsupported operation(%d)", operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ return UPLL_RC_SUCCESS;
}
+
upll_rc_t VtnFlowFilterEntryMoMgr::ValVtnFlowfilterCtrlAttributeSupportCheck(
- val_flowfilter_controller_t *val_flowfilter_controller,
+ val_flowfilter_controller_t *val_ff_ctrlr,
const uint8_t* attrs) {
UPLL_FUNC_TRACE;
- if (val_flowfilter_controller != NULL) {
- if ((val_flowfilter_controller->valid[UPLL_IDX_DIRECTION_FFC] ==
- UNC_VF_VALID) ||
- (val_flowfilter_controller->valid[UPLL_IDX_DIRECTION_FFC] ==
- UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vtn_flowfilter_controller::kCapDirection]== 0) {
- val_flowfilter_controller->valid[UPLL_IDX_DIRECTION_FFC] =
- UNC_VF_NOT_SOPPORTED;
+ if ((val_ff_ctrlr->valid[UPLL_IDX_DIRECTION_FFC] ==
+ UNC_VF_VALID) ||
+ (val_ff_ctrlr->valid[UPLL_IDX_DIRECTION_FFC] ==
+ UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtn_flowfilter_controller::kCapDirection]== 0) {
+ val_ff_ctrlr->valid[UPLL_IDX_DIRECTION_FFC] =
+ UNC_VF_NOT_SUPPORTED;
- UPLL_LOG_DEBUG("Direction attr is not supported by ctrlr");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
+ UPLL_LOG_DEBUG("Direction attr is not supported by ctrlr");
}
+ }
- if ((val_flowfilter_controller->valid[UPLL_IDX_SEQ_NUM_FFC] ==
- UNC_VF_VALID) ||
- (val_flowfilter_controller->valid[UPLL_IDX_SEQ_NUM_FFC] ==
- UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vtn_flowfilter_controller::kCapSeqNum]== 0) {
- val_flowfilter_controller->valid[UPLL_IDX_SEQ_NUM_FFC] =
- UNC_VF_NOT_SOPPORTED;
+ if ((val_ff_ctrlr->valid[UPLL_IDX_SEQ_NUM_FFC] ==
+ UNC_VF_VALID) ||
+ (val_ff_ctrlr->valid[UPLL_IDX_SEQ_NUM_FFC] ==
+ UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtn_flowfilter_controller::kCapSeqNum]== 0) {
+ val_ff_ctrlr->valid[UPLL_IDX_SEQ_NUM_FFC] =
+ UNC_VF_NOT_SUPPORTED;
- UPLL_LOG_DEBUG("SeqNum attr is not supported by ctrlr");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
+ UPLL_LOG_DEBUG("SeqNum attr is not supported by ctrlr");
}
- } else {
- UPLL_LOG_DEBUG("Error value struct is NULL");
- return UPLL_RC_ERR_GENERIC;
}
return UPLL_RC_SUCCESS;
}
key_vtn_ffe_ctrl->flowfilter_key.vtn_key.vtn_name,
key_vtn_ff_ctrl->vtn_key.vtn_name,
(kMaxLenVtnName +1));
- key_vtn_ffe_ctrl->flowfilter_key.input_direction = val_ff_ctrl->direction;
if (val_ff_ctrl->valid[UPLL_IDX_SEQ_NUM_FFC] == UNC_VF_VALID) {
key_vtn_ffe_ctrl->sequence_num = val_ff_ctrl->sequence_num;
} else {
key_vtn_ffe_ctrl->sequence_num = 0;
}
+ if (val_ff_ctrl->valid[UPLL_IDX_DIRECTION_FFC] == UNC_VF_VALID) {
+ key_vtn_ffe_ctrl->flowfilter_key.input_direction = val_ff_ctrl->direction;
+ } else {
+ key_vtn_ffe_ctrl->flowfilter_key.input_direction = 0xFE;
+ }
ikey->DeleteCfgVal();
val_ff_ctrl = NULL;
// Allocating CKV tctrl_key
ConfigKeyVal *tctrl_key = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_ENTRY,
- IpctSt::kIpcStKeyVtnFlowfilterEntry,
- key_vtn_ffe_ctrl, NULL);
+ IpctSt::kIpcStKeyVtnFlowfilterEntry,
+ key_vtn_ffe_ctrl, NULL);
// Reading The Entry_Ctrl_Table
SET_USER_DATA_CTRLR(tctrl_key, key_vtn_ff_ctrl->controller_name);
val_vtn_ffe_ctrlr,
dt_type,
dmi,
- op_val_vtn_ffe);
+ op_val_vtn_ffe,
+ reinterpret_cast<const char*>(key_vtn_ff_ctrl->controller_name));
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetCtrlFlowFilterEntry error code (%d)", result_code);
return result_code;
val_vtn_flowfilter_entry_ctrlr_t *val_vtn_ffe_ctrlr,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
- val_vtn_flowfilter_entry_t *&op_val_vtn_ffe) {
+ val_vtn_flowfilter_entry_t *&op_val_vtn_ffe,
+ const char* ctrlr_name,
+ unc_keytype_option1_t opt1) {
UPLL_FUNC_TRACE;
+ const uint8_t *attrs = NULL;
+ uint32_t max_attrs = 0;
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *tkey = NULL;
key_vtn_flowfilter_entry_t *key_vtn_ffe =
memcpy(temp_val_vtn_ffe->cs_attr, val_vtn_ffe_ctrlr->cs_attr, tmp_size);
temp_val_vtn_ffe->cs_row_status = (uint8_t)val_vtn_ffe_ctrlr->cs_row_status;
+ //Adding capaCheck for controller
+ bool ret_code = false;
+
+ if ((opt1 == UNC_OPT1_DETAIL) && (dt_type == UPLL_DT_STATE)) {
+ ret_code = GetStateCapability(ctrlr_name, UNC_KT_VTN_FLOWFILTER_ENTRY,
+ &max_attrs, &attrs);
+ if(!ret_code ) {
+ UPLL_LOG_DEBUG("GetStateCapability Is failed in GetCtrlFlowFilterEntry %d",
+ ret_code);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+
+ if(max_attrs>0) {
+ result_code = ValVtnFlowfilterEntryAttributeSupportCheck(
+ temp_val_vtn_ffe, attrs);
+ if(result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ERR result_code %d", result_code );
+ return result_code;
+ }
+ }
+ }
- if (temp_val_vtn_ffe->valid[UPLL_IDX_FLOWLIST_NAME_VFFE] == UNC_VF_INVALID) {
+ if (temp_val_vtn_ffe->valid[UPLL_IDX_FLOWLIST_NAME_VFFE] != UNC_VF_VALID) {
uuu::upll_strncpy(temp_val_vtn_ffe->flowlist_name,
"\0", (kMaxLenFlowListName + 1));
}
- if (temp_val_vtn_ffe->valid[UPLL_IDX_ACTION_VFFE] == UNC_VF_INVALID) {
+ if (temp_val_vtn_ffe->valid[UPLL_IDX_ACTION_VFFE] != UNC_VF_VALID) {
temp_val_vtn_ffe->action = 0;
}
- if (temp_val_vtn_ffe->valid[UPLL_IDX_NWN_NAME_VFFE] == UNC_VF_INVALID) {
+ if (temp_val_vtn_ffe->valid[UPLL_IDX_NWN_NAME_VFFE] != UNC_VF_VALID) {
uuu::upll_strncpy(temp_val_vtn_ffe->nwm_name,
"\0", kMaxLenNwmName);
}
- if (temp_val_vtn_ffe->valid[UPLL_IDX_DSCP_VFFE] == UNC_VF_INVALID) {
+ if (temp_val_vtn_ffe->valid[UPLL_IDX_DSCP_VFFE] != UNC_VF_VALID) {
temp_val_vtn_ffe->dscp = 0;
}
- if (temp_val_vtn_ffe->valid[UPLL_IDX_PRIORITY_VFFE] == UNC_VF_INVALID) {
+ if (temp_val_vtn_ffe->valid[UPLL_IDX_PRIORITY_VFFE] != UNC_VF_VALID) {
temp_val_vtn_ffe->priority = 0;
}
upll_rc_t VtnFlowFilterEntryMoMgr::GetVtnControllerSpan(
ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
std::list<controller_domain_t> &list_ctrlr_dom) {
UPLL_FUNC_TRACE;
UPLL_LOG_DEBUG("Key not supported by controller");
return result_code;
}
- key_vtn_t *vtn_key = reinterpret_cast<key_vtn*>(okey->get_key());
- key_vtn_flowfilter_entry_t *ffe_key =
- reinterpret_cast<key_vtn_flowfilter_entry_t*>(ikey->get_key());
- uuu::upll_strncpy(vtn_key->vtn_name,
- ffe_key->flowfilter_key.vtn_key.vtn_name,
- (kMaxLenVtnName+1));
- result_code = mgr->GetControllerDomainSpan(okey, UPLL_DT_CANDIDATE,
- dmi,
- list_ctrlr_dom);
- if ((result_code != UPLL_RC_SUCCESS) &&
- (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
- UPLL_LOG_DEBUG("Error in getting controller span (%d)",
- result_code);
+ key_vtn_t *vtn_key = reinterpret_cast<key_vtn*>(okey->get_key());
+
+ if (ikey->get_key_type() == UNC_KT_VTN_FLOWFILTER_CONTROLLER) {
+
+ key_vtn_flowfilter_controller_t *key_vtn_ff_ctrl =
+ reinterpret_cast<key_vtn_flowfilter_controller_t*>(ikey->get_key());
+ uuu::upll_strncpy(vtn_key->vtn_name,
+ key_vtn_ff_ctrl->vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+
+ } else {
+ key_vtn_flowfilter_entry_t *ffe_key =
+ reinterpret_cast<key_vtn_flowfilter_entry_t*>(ikey->get_key());
+ uuu::upll_strncpy(vtn_key->vtn_name,
+ ffe_key->flowfilter_key.vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ }
+
+ result_code = mgr->GetControllerDomainSpan(okey, dt_type,
+ dmi,
+ list_ctrlr_dom);
+ if ((result_code != UPLL_RC_SUCCESS) &&
+ (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG("Error in getting controller span (%d)",
+ result_code);
+ }
+ UPLL_LOG_DEBUG(" GetVtnControllerSpan Result code - %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+}
+
+upll_rc_t VtnFlowFilterEntryMoMgr::CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id) {
+ UPLL_FUNC_TRACE;
+ if (ikey == NULL || dmi == NULL) {
+ UPLL_LOG_TRACE(
+ "Cannot perform create operation due to insufficient parameters");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ upll_rc_t vtn_ctrlr_span_rt_code = UPLL_RC_SUCCESS;
+ uint8_t *controller_id = reinterpret_cast<uint8_t *>(
+ const_cast<char *>(ctrlr_id));
+ UPLL_LOG_TRACE("%s Vtn_FFE CreateAuditMoImpl ikey",
+ ikey->ToStrAll().c_str());
+ result_code = GetRenamedUncKey(ikey, UPLL_DT_RUNNING, dmi, controller_id);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey Failed err_code %d", result_code);
+ return result_code;
+ }
+ DbSubOp dbop1 = { kOpReadExist, kOpMatchNone, kOpInOutNone };
+
+ result_code = UpdateConfigDB(ikey, UPLL_DT_AUDIT, UNC_OP_READ, dmi,
+ &dbop1, MAINTBL);
+ if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Update record Err in vtnffentry MainTbl(%d)",
+ result_code);
+ return result_code;
+ }
+
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+
+ result_code = UpdateConfigDB(ikey, UPLL_DT_AUDIT, UNC_OP_CREATE,
+ dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Update record Err in vtnffentry MainTbl(%d)",
+ result_code);
+ return result_code;
+ }
+ }
+
+ std::list<controller_domain_t> list_ctrlr_dom;
+ vtn_ctrlr_span_rt_code = GetVtnControllerSpan(ikey, UPLL_DT_AUDIT, dmi, list_ctrlr_dom);
+ if ((vtn_ctrlr_span_rt_code != UPLL_RC_SUCCESS) &&
+ (vtn_ctrlr_span_rt_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG(" GetVtnControllerSpan error code (%d)",
+ vtn_ctrlr_span_rt_code);
+ FREE_LIST_CTRLR(list_ctrlr_dom);
+ return result_code;
+ }
+
+ result_code = SetValidAudit(ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ FREE_LIST_CTRLR(list_ctrlr_dom);
+ return result_code;
}
- UPLL_LOG_DEBUG(" GetVtnControllerSpan Result code - %d", result_code);
- delete okey;
+ // create a record in CANDIDATE DB for controller Table
+ if (vtn_ctrlr_span_rt_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ result_code = UpdateControllerTable(ikey, UNC_OP_CREATE,
+ UPLL_DT_AUDIT, dmi,
+ list_ctrlr_dom);
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ FREE_LIST_CTRLR(list_ctrlr_dom);
+ return result_code;
+ }
+ }
+ val_vtn_flowfilter_entry_t *val_vtn_ffe = reinterpret_cast
+ <val_vtn_flowfilter_entry_t *>(GetVal(ikey));
+ if (UNC_VF_VALID == val_vtn_ffe->valid[UPLL_IDX_FLOWLIST_NAME_VFFE]) {
+ result_code = UpdateFlowListInCtrl(ikey, UPLL_DT_AUDIT, UNC_OP_CREATE, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ return result_code;
+ }
+ }
+ FREE_LIST_CTRLR(list_ctrlr_dom);
return result_code;
}
+
upll_rc_t VtnFlowFilterEntryMoMgr::UpdateControllerTable(
ConfigKeyVal *ikey, unc_keytype_operation_t op,
upll_keytype_datatype_t dt_type,
UPLL_FUNC_TRACE;
ConfigKeyVal *ctrlckv = NULL;
ConfigVal *ctrlcv = NULL;
+ unc_keytype_ctrtype_t ctrlrtype = UNC_CT_UNKNOWN;
+ uuc::CtrlrMgr *ctrlr_mgr = uuc::CtrlrMgr::GetInstance();
upll_rc_t result_code = UPLL_RC_SUCCESS;
- for (std::list<controller_domain_t>::iterator it= list_ctrlr_dom.begin();
- it != list_ctrlr_dom.end(); ++it) {
+ std::list<controller_domain_t>::iterator it= list_ctrlr_dom.begin();
+ while (it != list_ctrlr_dom.end()) {
key_vtn_flowfilter_entry_t *vtn_ffe_key =
reinterpret_cast<key_vtn_flowfilter_entry_t*>
(ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_entry_t)));
(ikey->get_key()), sizeof(key_vtn_flowfilter_entry_t));
val_vtn_flowfilter_entry_t *vtn_ffe_val = reinterpret_cast
<val_vtn_flowfilter_entry_t *>(GetVal(ikey));
+
+ if ((op == UNC_OP_CREATE) || (op == UNC_OP_UPDATE)) {
+ if (op == UNC_OP_CREATE) {
+ //capability check
+
+ ConfigKeyVal *temp_key = NULL;
+ result_code = GetChildConfigKey(temp_key, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ free(vtn_ffe_key);
+ UPLL_LOG_DEBUG("GetChildConfigKey failed(%d)",result_code);
+ return result_code;
+ }
+
+ result_code = GetInstanceCount(temp_key,
+ reinterpret_cast<char*>(it->ctrlr),
+ UPLL_DT_CANDIDATE,
+ &cur_instance_count,
+ dmi, CTRLRTBL);
+
+ if (UPLL_RC_SUCCESS != result_code) {
+ free(vtn_ffe_key);
+ DELETE_IF_NOT_NULL(temp_key);
+ UPLL_LOG_DEBUG("GetInstanceCount failed(%d)",result_code);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(temp_key);
+ }
+ IpcReqRespHeader *req_header = reinterpret_cast<IpcReqRespHeader*>
+ (ConfigKeyVal::Malloc(sizeof(IpcReqRespHeader)));
+
+ req_header->operation = op;
+ req_header->datatype = dt_type;
+
+ // Validate whether the attributes supported by controller or not
+ result_code = ValidateCapability(
+ req_header, ikey, reinterpret_cast<char*>(it->ctrlr));
+ free(req_header);
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ // VTN FlowfilterEntry is not supported for other than PFC Controller
+ // so skip adding entry for such sontroller in ctrlr table
+ free(vtn_ffe_key);
+ if ((!ctrlr_mgr->GetCtrlrType(reinterpret_cast<char *>(it->ctrlr),
+ dt_type, &ctrlrtype)) || (ctrlrtype != UNC_CT_PFC)) {
+ result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_DEBUG("Controller type is %d", ctrlrtype);
+ ++it;
+ continue;
+ }
+ UPLL_LOG_DEBUG("ValidateCapability Failed: result_code=%d",
+ result_code);
+ return result_code;
+ }
+ }
val_vtn_flowfilter_entry_ctrlr_t *ctrlr_val = reinterpret_cast
<val_vtn_flowfilter_entry_ctrlr_t *>(ConfigKeyVal::Malloc(sizeof
(val_vtn_flowfilter_entry_ctrlr_t)));
for (unsigned int loop = 0;
loop < (sizeof(ctrlr_val->valid)/sizeof(ctrlr_val->valid[0]));
loop++) {
- if (UNC_VF_NOT_SOPPORTED == vtn_ffe_val->valid[loop]) {
+ if (UNC_VF_NOT_SUPPORTED == vtn_ffe_val->valid[loop]) {
ctrlr_val->valid[loop] = UNC_VF_INVALID;
} else {
ctrlr_val->valid[loop] = vtn_ffe_val->valid[loop];
ctrlckv = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_ENTRY,
IpctSt::kIpcStKeyVtnFlowfilterEntry,
vtn_ffe_key, ctrlcv);
+ if (!ctrlckv) return UPLL_RC_ERR_GENERIC;
// ctrlckv->AppendCfgVal(IpctSt::kIpcInvalidStNum, ctrlr_val);
SET_USER_DATA_CTRLR_DOMAIN(ctrlckv, *it);
-
+ if (UNC_OP_CREATE == op) {
+ DbSubOp dbop1 = { kOpReadExist, kOpMatchCtrlr |
+ kOpMatchDomain, kOpInOutNone };
+ result_code = UpdateConfigDB(ctrlckv, dt_type, UNC_OP_READ, dmi, &dbop1,
+ CTRLRTBL);
+ if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("UpdateConfigDB Failed err_code %d", result_code);
+ DELETE_IF_NOT_NULL(ctrlckv);
+ return result_code;
+ }
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ ++it;
+ DELETE_IF_NOT_NULL(ctrlckv);
+ continue;
+ }
+ }
// Create/Update/Delete a record in CANDIDATE DB
result_code = UpdateConfigDB(ctrlckv, dt_type, op, dmi, CTRLRTBL);
+ DELETE_IF_NOT_NULL(ctrlckv);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Err while inserting in ctrlr table for candidateDb(%d)",
+ UPLL_LOG_DEBUG("Err while updating the ctrlr table for CandidateDB(%d)",
result_code);
- }
-
- if (ctrlckv) {
- delete ctrlckv;
- ctrlckv = NULL;
- }
- if (result_code != UPLL_RC_SUCCESS) {
return result_code;
}
+
+ ++it;
}
- return result_code;
+ return UPLL_RC_SUCCESS;
}
upll_rc_t VtnFlowFilterEntryMoMgr::UpdateMainTbl(ConfigKeyVal *vtn_ffe_key,
if (op != UNC_OP_DELETE) {
result_code = DupConfigKeyVal(ck_vtn_ffe, vtn_ffe_key, MAINTBL);
if (!ck_vtn_ffe || result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
return UPLL_RC_ERR_GENERIC;
}
vtn_ffe_val = reinterpret_cast<val_vtn_flowfilter_entry_t *>
(GetVal(ck_vtn_ffe));
if (!vtn_ffe_val) {
- UPLL_LOG_DEBUG("invalid val \n");
+ UPLL_LOG_DEBUG("invalid val");
return UPLL_RC_ERR_GENERIC;
}
} else {
result_code = GetChildConfigKey(ck_vtn_ffe, vtn_ffe_key);
if (!ck_vtn_ffe || result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
return UPLL_RC_ERR_GENERIC;
}
}
switch (op) {
case UNC_OP_CREATE:
- vtn_ffe_val->cs_row_status = UNC_CS_NOT_APPLIED;
+ vtn_ffe_val->cs_row_status = UNC_CS_APPLIED;
break;
case UNC_OP_UPDATE:
- ffeval = reinterpret_cast<void *>(&vtn_ffe_val);
- nffeval = (nreq)?GetVal(nreq):NULL;
- if (!nffeval) {
- UPLL_LOG_DEBUG("Invalid param\n");
+ ffeval = GetVal(ck_vtn_ffe);
+ nffeval = GetVal(nreq);
+ if (!nffeval || !ffeval) {
+ UPLL_LOG_DEBUG("Invalid param");
return UPLL_RC_ERR_GENERIC;
}
CompareValidValue(ffeval, nffeval, false);
+ vtn_ffe_val->cs_row_status =
+ reinterpret_cast<val_vtn_flowfilter_entry_t *>(GetVal(nreq))->cs_row_status;
break;
case UNC_OP_DELETE:
break;
default:
- UPLL_LOG_DEBUG("Inalid operation\n");
+ UPLL_LOG_DEBUG("Inalid operation");
return UPLL_RC_ERR_GENERIC;
}
- result_code = UpdateConfigDB(ck_vtn_ffe, UPLL_DT_STATE, op, dmi, MAINTBL);
+
+ DbSubOp dbop = {kOpNotRead, kOpMatchNone, kOpInOutNone};
+ dbop.inoutop = kOpInOutCs | kOpInOutFlag;
+ result_code = UpdateConfigDB(ck_vtn_ffe, UPLL_DT_STATE, op, dmi,
+ &dbop, MAINTBL);
EnqueCfgNotification(op, UPLL_DT_RUNNING, ck_vtn_ffe);
delete ck_vtn_ffe;
return result_code;
dmi, MAINTBL);
if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
UPLL_LOG_DEBUG("No instance in vtn flowfilter entry table");
+ DELETE_IF_NOT_NULL(tempckv);
return UPLL_RC_SUCCESS;
}
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Unable to read configuration from CandidateDb");
- delete tempckv;
+ DELETE_IF_NOT_NULL(tempckv);
return result_code;
}
ConfigKeyVal *iter_ckv = tempckv;
val_vtn_flowfilter_entry_t *vtn_ffe_val = reinterpret_cast
<val_vtn_flowfilter_entry_t *>(GetVal(iter_ckv));
if (UNC_VF_VALID == vtn_ffe_val->valid[UPLL_IDX_FLOWLIST_NAME_VFFE]) {
- result_code = UpdateFlowListInCtrl(iter_ckv, UNC_OP_DELETE, dmi);
+ result_code = UpdateFlowListInCtrl(iter_ckv, req->datatype, UNC_OP_DELETE, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Unable to update flowlist in ctrlr table");
- delete tempckv;
+ DELETE_IF_NOT_NULL(tempckv);
return result_code;
}
}
iter_ckv = iter_ckv->get_next_cfg_key_val();
}
- delete tempckv;
+ DELETE_IF_NOT_NULL(tempckv);
result_code = UpdateConfigDB(ikey, req->datatype, req->operation, dmi,
MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
upll_rc_t VtnFlowFilterEntryMoMgr::IsFlowListConfigured(
const char* flowlist_name, DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
ConfigKeyVal *ckv = NULL;
result_code = GetChildConfigKey(ckv, NULL);
return result_code;
}
if (!ckv) return UPLL_RC_ERR_GENERIC;
- val_flowfilter_entry_t *ffe_val = reinterpret_cast
- <val_flowfilter_entry_t *>(ConfigKeyVal::Malloc(sizeof
- (val_flowfilter_entry_t)));
+ val_vtn_flowfilter_entry_t *ffe_val = reinterpret_cast
+ <val_vtn_flowfilter_entry_t *>(ConfigKeyVal::Malloc(sizeof
+ (val_vtn_flowfilter_entry_t)));
uuu::upll_strncpy(ffe_val->flowlist_name, flowlist_name,
(kMaxLenFlowListName + 1));
- ckv->AppendCfgVal(IpctSt::kIpcStValFlowfilterEntry, ffe_val);
+ ffe_val->valid[UPLL_IDX_FLOWLIST_NAME_VFFE] = UNC_VF_VALID;
+ ckv->AppendCfgVal(IpctSt::kIpcStValVtnFlowfilterEntry, ffe_val);
DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutNone};
// Read the Configuration from the MainTable
result_code = ReadConfigDB(ckv, UPLL_DT_CANDIDATE,
UPLL_LOG_DEBUG(" Input Key is NULL");
return UPLL_RC_ERR_GENERIC;
}
-
+ DELETE_IF_NOT_NULL(okey);
unc_key_type_t ikey_type = ikey->get_key_type();
if (ikey_type != UNC_KT_VTN_FLOWFILTER_ENTRY) {
UPLL_LOG_DEBUG(" Invalid key type received. Key type - %d", ikey_type);
return result_code;
}
if (ikey->get_key_type() == UNC_KT_VTN_FLOWFILTER_ENTRY) {
- result_code = ReadInfoFromDB(req, ikey, dmi, &ctrlr_dom);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(" Read DB request failed result(%d)", result_code);
- return result_code;
- }
+ if(req->datatype == UPLL_DT_STATE ||
+ req->datatype == UPLL_DT_STARTUP ||
+ req->datatype == UPLL_DT_RUNNING ||
+ req->datatype == UPLL_DT_CANDIDATE ) {
+ result_code = ReadInfoFromDB(req, ikey, dmi, &ctrlr_dom);
+ return result_code;
+ } else {
+ UPLL_LOG_DEBUG("ReadSiblingCount is not Allowed For Such datatype %d",
+ req->datatype);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+
} else if (ikey->get_key_type() == UNC_KT_VTN_FLOWFILTER_CONTROLLER) {
if ((req->datatype == UPLL_DT_STATE) && (req->option1 == UNC_OPT1_NORMAL) &&
(req->option2 == UNC_OPT2_NONE)) {
return result_code;
}
+upll_rc_t VtnFlowFilterEntryMoMgr::DeleteChildrenPOM(
+ ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+
+ if (NULL == ikey || NULL == dmi) {
+ UPLL_LOG_DEBUG("Delete Operation failed:Bad request");
+ return result_code;
+ }
+ // Read the DB get the flowlist value and send the delete request to
+ // flowlist momgr if flowlist is configured.
+
+ ConfigKeyVal *okey = NULL;
+ ConfigKeyVal *temp_okey = NULL;
+ result_code = GetChildConfigKey(temp_okey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ return result_code;
+ }
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutFlag };
+ result_code = ReadConfigDB(temp_okey, UPLL_DT_CANDIDATE,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("UPLL_RC_ERR_NO_SUCH_INSTANCE");
+ DELETE_IF_NOT_NULL(temp_okey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("Unable to read configuration from CandidateDb");
+ DELETE_IF_NOT_NULL(temp_okey);
+ return result_code;
+ }
+ okey = temp_okey;
+ while (NULL != okey) {
+ val_vtn_flowfilter_entry_t *vtn_ffe_val = reinterpret_cast
+ <val_vtn_flowfilter_entry_t *>(GetVal(okey));
+ if (UNC_VF_VALID == vtn_ffe_val->valid[UPLL_IDX_FLOWLIST_NAME_VFFE]) {
+ result_code = UpdateFlowListInCtrl(okey, dt_type, UNC_OP_DELETE, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to update flowlist in ctrlr table");
+ DELETE_IF_NOT_NULL(temp_okey);
+ return result_code;
+ }
+ }
+ okey = okey->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(temp_okey);
+ ConfigKeyVal *temp_ikey = NULL;
+ result_code = GetChildConfigKey(temp_ikey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed");
+ return result_code;
+ }
+ result_code = UpdateConfigDB(temp_ikey, dt_type, UNC_OP_DELETE, dmi,
+ MAINTBL);
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
+ UPLL_LOG_DEBUG("DeleteMo record Err in vtnpolicingmaptbl (%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(temp_ikey);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(temp_ikey);
+ ConfigKeyVal *ctrlr_ikey = NULL;
+ result_code = GetChildConfigKey(ctrlr_ikey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed");
+ return result_code;
+ }
+ DbSubOp dbop1 = {kOpNotRead, kOpMatchNone, kOpInOutNone};
+ result_code = UpdateConfigDB(ctrlr_ikey, dt_type, UNC_OP_DELETE, dmi,
+ &dbop1, CTRLRTBL);
+ UPLL_LOG_DEBUG("UpdateConfigDB for entry ctrlr tbl %d", result_code);
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
+ UPLL_LOG_DEBUG("DeleteMo record Err in vtnpolicingmaptbl (%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(ctrlr_ikey);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(ctrlr_ikey);
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtnFlowFilterEntryMoMgr::SetValidAudit(ConfigKeyVal *&ikey) {
+ UPLL_FUNC_TRACE;
+ val_vtn_flowfilter_entry_t *val = reinterpret_cast
+ <val_vtn_flowfilter_entry_t *>(GetVal(ikey));
+ if (NULL == val) {
+ UPLL_LOG_DEBUG("val is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ for (unsigned int loop = 0;
+ loop < sizeof(val->valid) / sizeof(val->valid[0]);
+ ++loop) {
+ val->cs_attr[loop] = UNC_CS_APPLIED;
+ val->cs_attr[loop] = UNC_CS_NOT_APPLIED;
+ }
+ val->cs_row_status = UNC_CS_APPLIED;
+ return UPLL_RC_SUCCESS;
+}
+
+bool VtnFlowFilterEntryMoMgr::FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op) {
+ UPLL_FUNC_TRACE;
+ if (op != UNC_OP_CREATE) {
+ return CompareValidValue(val1, val2, copy_to_running);
+ }
+ return false;
+}
+
+upll_rc_t VtnFlowFilterEntryMoMgr::UpdateConfigStatus(ConfigKeyVal *main_ckv,
+ unc_keytype_operation_t op,
+ uint32_t driver_result,
+ ConfigKeyVal *upd_key,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ctrlr_key) {
+ UPLL_FUNC_TRACE;
+ val_vtn_flowfilter_entry_ctrlr_t *ctrlr_val;
+ val_vtn_flowfilter_entry_t *val_main = reinterpret_cast
+ <val_vtn_flowfilter_entry_t *>(GetVal(main_ckv));
+ unc_keytype_configstatus_t ctrlr_status;
+ uint8_t cs_status;
+ ctrlr_status = (driver_result == UPLL_RC_SUCCESS) ?
+ UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
+ ctrlr_val = reinterpret_cast
+ <val_vtn_flowfilter_entry_ctrlr_t *>(GetVal(ctrlr_key));
+ if ((val_main == NULL) || (ctrlr_val == NULL))
+ return UPLL_RC_ERR_GENERIC;
+ cs_status = (val_main->cs_row_status);
+ UPLL_LOG_TRACE("cs_status %d ctrlr_status %d\n", cs_status, ctrlr_status);
+ if (op == UNC_OP_CREATE) {
+ ctrlr_val->cs_row_status = ctrlr_status;
+ if (val_main->cs_row_status == UNC_CS_UNKNOWN) {
+ /* first entry in ctrlr table */
+ cs_status = ctrlr_status;
+
+ } else if (val_main->cs_row_status == UNC_CS_INVALID) {
+ cs_status = UNC_CS_INVALID;
+ } else if (val_main->cs_row_status == UNC_CS_APPLIED) {
+ if (ctrlr_status == UNC_CS_NOT_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ }
+ } else if (val_main->cs_row_status == UNC_CS_NOT_APPLIED) {
+ if (ctrlr_status == UNC_CS_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ }
+ } else {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ }
+ val_main->cs_row_status = cs_status;
+ }
+ // Updating the Controller cs_row_status
+ val_vtn_flowfilter_entry_ctrlr *run_ctrlr_val =
+ reinterpret_cast<val_vtn_flowfilter_entry_ctrlr *>
+ (GetVal(upd_key));
+ if ((op == UNC_OP_UPDATE) && (run_ctrlr_val != NULL)) {
+ void *valmain = reinterpret_cast<void *>(val_main);
+ CompareValidValue(valmain, (GetVal(upd_key)), true);
+ for (unsigned int loop = 0; loop < sizeof(val_main->valid)/
+ sizeof(val_main->valid[0]); ++loop) {
+ if ((val_main->valid[loop] != UNC_VF_INVALID) &&
+ (val_main->valid[loop]!= UNC_VF_VALID_NO_VALUE)) {
+ if (ctrlr_status == UNC_CS_APPLIED) {
+ if(ctrlr_val->valid[loop] == UNC_VF_VALID) {
+ ctrlr_val->cs_attr[loop] = UNC_CS_APPLIED;
+ }
+ if (val_main->cs_attr[loop] == UNC_CS_UNKNOWN) {
+ cs_status = UNC_CS_APPLIED;
+ } else if (val_main->cs_attr[loop] == UNC_CS_NOT_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED ;
+ } else if (val_main->cs_attr[loop] == UNC_CS_INVALID) {
+ cs_status = UNC_CS_INVALID;
+ }
+ } else if (ctrlr_status == UNC_CS_NOT_APPLIED) {
+ ctrlr_val->cs_attr[loop] = UNC_CS_NOT_APPLIED;
+ if (val_main->cs_attr[loop] == UNC_CS_UNKNOWN) {
+ cs_status = UNC_CS_NOT_APPLIED;
+ } if (val_main->cs_attr[loop] == UNC_CS_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED ;
+ } else if (val_main->cs_attr[loop] == UNC_CS_INVALID) {
+ cs_status = UNC_CS_INVALID;
+ }
+ }
+ val_main->cs_attr[loop] = cs_status;
+ UPLL_LOG_DEBUG("UpdatePath tbl cs_attr : %d", val_main->cs_attr[loop]);
+ }
+ if (val_main->valid[loop] == UNC_VF_INVALID) {
+ if (ctrlr_status == UNC_CS_APPLIED) {
+ if (run_ctrlr_val->valid[loop] == UNC_VF_VALID) {
+ if (val_main->cs_attr[loop] == UNC_CS_PARTIALLY_APPLIED) {
+ val_main->cs_attr[loop] = UNC_CS_PARTIALLY_APPLIED;
+ } else if (val_main->cs_attr[loop] == UNC_CS_NOT_APPLIED) {
+ val_main->cs_attr[loop] = UNC_CS_NOT_APPLIED;
+ } else if (val_main->cs_attr[loop] == UNC_CS_INVALID) {
+ val_main->cs_attr[loop] = UNC_CS_INVALID;
+ } else {
+ val_main->cs_attr[loop] = ctrlr_status;
+ }
+ }
+ if (ctrlr_val->cs_attr[loop] == UNC_CS_APPLIED) {
+ ctrlr_val->cs_attr[loop] = ctrlr_status;
+ }
+ } else if (ctrlr_status == UNC_CS_NOT_APPLIED) {
+ if (run_ctrlr_val->valid[loop] == UNC_VF_VALID) {
+ if (val_main->cs_attr[loop] == UNC_CS_PARTIALLY_APPLIED) {
+ val_main->cs_attr[loop] = UNC_CS_PARTIALLY_APPLIED;
+ } else if (val_main->cs_attr[loop] == UNC_CS_NOT_APPLIED) {
+ val_main->cs_attr[loop] = UNC_CS_NOT_APPLIED;
+ } else if (val_main->cs_attr[loop] == UNC_CS_INVALID) {
+ val_main->cs_attr[loop] = UNC_CS_INVALID;
+ } else {
+ val_main->cs_attr[loop] = UNC_CS_PARTIALLY_APPLIED;
+ }
+ }
+ }
+ }
+ if (val_main->valid[loop] == UNC_VF_VALID_NO_VALUE) {
+ ctrlr_val->cs_attr[loop] = UNC_CS_UNKNOWN;
+ val_main->cs_attr[loop] = UNC_CS_UNKNOWN;
+ }
+ }
+ }
+ if (op == UNC_OP_CREATE ) {
+ for (unsigned int loop = 0; loop < sizeof(val_main->valid)/
+ sizeof(val_main->valid[0]); ++loop) {
+ if (val_main->valid[loop] != UNC_VF_INVALID) {
+ if (ctrlr_val->cs_attr[loop] != UNC_CS_NOT_SUPPORTED)
+ ctrlr_val->cs_attr[loop] = ctrlr_status;
+ else
+ ctrlr_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
+
+ if (val_main->cs_attr[loop] == ctrlr_status) {
+ cs_status = ctrlr_status;
+ } else if (ctrlr_status == UNC_CS_APPLIED) {
+ if (val_main->cs_attr[loop] == UNC_CS_UNKNOWN) {
+ cs_status = ctrlr_status;
+ } else if (val_main->cs_attr[loop] == UNC_CS_NOT_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ } else if (val_main->cs_attr[loop] == UNC_CS_INVALID) {
+ cs_status = UNC_CS_INVALID;
+ }else {
+ cs_status = val_main->cs_attr[loop];
+ }
+ } else if(ctrlr_status == UNC_CS_NOT_APPLIED) {
+ if(val_main->cs_attr[loop] == UNC_CS_NOT_APPLIED) {
+ cs_status = UNC_CS_NOT_APPLIED;
+ } else if (val_main->cs_attr[loop] == UNC_CS_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ } else if (val_main->cs_attr[loop] == UNC_CS_INVALID) {
+ cs_status = UNC_CS_INVALID;
+ }
+ } else {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ }
+ val_main->cs_attr[loop] = cs_status;
+ UPLL_LOG_DEBUG("Main tbl cs_attr : %d", val_main->cs_attr[loop]);
+ }
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtnFlowFilterEntryMoMgr::Get_Tx_Consolidated_Status(
+ unc_keytype_configstatus_t &status,
+ unc_keytype_configstatus_t drv_result_status,
+ unc_keytype_configstatus_t current_cs,
+ unc_keytype_configstatus_t current_ctrlr_cs) {
+
+ switch (current_cs) {
+ case UNC_CS_UNKNOWN:
+ status = drv_result_status;
+ break;
+ case UNC_CS_PARTIALLY_APPLIED:
+ if (current_ctrlr_cs == UNC_CS_NOT_APPLIED) {
+ // Todo: if this vtn has caused it then to change to applied.
+ status = (drv_result_status != UNC_CS_APPLIED) ?
+ UNC_CS_PARTIALLY_APPLIED : drv_result_status;
+ }
+ break;
+ case UNC_CS_APPLIED:
+ case UNC_CS_NOT_APPLIED:
+ case UNC_CS_INVALID:
+ default:
+ status = (drv_result_status == UNC_CS_NOT_APPLIED)?
+ UNC_CS_PARTIALLY_APPLIED:
+ (status == UNC_CS_UNKNOWN)?drv_result_status:status;
+ break;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtnFlowFilterEntryMoMgr::IsRenamed(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi,
+ uint8_t &rename) {
+ UPLL_FUNC_TRACE;
+ UPLL_LOG_DEBUG("VtnFlowFilterEntryMoMgr IsRenamed");
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag | kOpInOutCtrlr
+ | kOpInOutDomain };
+ ConfigKeyVal *okey = NULL;
+ upll_rc_t result_code;
+ /* rename is set implies user wants the ikey
+ * populated with val from db */
+ if (!rename) {
+ if (UNC_KT_VTN_FLOWFILTER_ENTRY == ikey->get_key_type()) {
+ UPLL_LOG_DEBUG("UNC_KT_VTN_FLOWFILTER_ENTRY");
+ result_code = GetChildConfigKey(okey, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("Returning error %d",result_code);
+ return result_code;
+ }
+ } else if (UNC_KT_VTN_FLOWFILTER_CONTROLLER == ikey->get_key_type()) {
+ UPLL_LOG_DEBUG("UNC_KT_VTN_FLOWFILTER_CONTROLLER");
+
+ key_vtn_flowfilter_entry *out_key =
+ reinterpret_cast<key_vtn_flowfilter_entry *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_entry)));
+ key_vtn_flowfilter_controller *in_key = reinterpret_cast
+ <key_vtn_flowfilter_controller_t *>(ikey->get_key());
+ val_flowfilter_controller_t *ival = reinterpret_cast
+ <val_flowfilter_controller_t *>(GetVal(ikey));
+
+ uuu::upll_strncpy(out_key->flowfilter_key.vtn_key.vtn_name,
+ in_key->vtn_key.vtn_name,
+ (kMaxLenVtnName + 1));
+
+ out_key->flowfilter_key.input_direction = ival->direction;
+ out_key->sequence_num = ival->sequence_num;
+
+ okey = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER_ENTRY,
+ IpctSt::kIpcStKeyVtnFlowfilterEntry,
+ out_key, NULL);
+ }
+ } else {
+ okey = ikey;
+ }
+ result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if ((result_code != UPLL_RC_SUCCESS) &&
+ (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG("Returning error code %d",result_code);
+ if (okey != ikey) delete okey;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ GET_USER_DATA_FLAGS(okey, rename);
+ UPLL_LOG_DEBUG("rename flag %d",rename);
+ controller_domain_t ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+
+ GET_USER_DATA_CTRLR_DOMAIN(ikey,ctrlr_dom);
+ UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+ SET_USER_DATA_CTRLR_DOMAIN(okey,ctrlr_dom);
+ UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+
+ SET_USER_DATA(ikey,okey);
+ rename &= RENAME;
+ if (okey != ikey) delete okey;
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtnFlowFilterEntryMoMgr::SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_vtn_flowfilter_entry_t *val_ffe = reinterpret_cast
+ <val_vtn_flowfilter_entry_t *>(GetVal(ikey));
+ if (!val_ffe) {
+ UPLL_LOG_DEBUG("Val is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigKeyVal *pkey = NULL;
+ if (UNC_OP_CREATE == req->operation) {
+ result_code = GetParentConfigKey(pkey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetParentConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_VTN_FLOWFILTER)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("mgr is NULL");
+ DELETE_IF_NOT_NULL(pkey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t rename = 0;
+ result_code = mgr->IsRenamed(pkey, req->datatype, dmi, rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(pkey);
+ return result_code;
+ }
+ UPLL_LOG_DEBUG("Flag from parent : %d", rename);
+ DELETE_IF_NOT_NULL(pkey);
+ // Check flowlist is renamed
+ if ((UNC_VF_VALID == val_ffe->valid[UPLL_IDX_FLOWLIST_NAME_VFFE]) &&
+ ((UNC_OP_CREATE == req->operation))) {
+ ConfigKeyVal *fl_ckv = NULL;
+ result_code = GetFlowlistConfigKey(reinterpret_cast<const char *>
+ (val_ffe->flowlist_name), fl_ckv, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetFlowlistConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *fl_mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_FLOWLIST)));
+ if (NULL == fl_mgr) {
+ UPLL_LOG_DEBUG("fl_mgr is NULL");
+ DELETE_IF_NOT_NULL(fl_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t fl_rename = 0;
+ result_code = fl_mgr->IsRenamed(fl_ckv, req->datatype, dmi, fl_rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(fl_ckv);
+ return result_code;
+ }
+ if (fl_rename & 0x01) {
+ rename |= FLOWLIST_RENAME; // TODO Check for correct flag value
+ }
+ DELETE_IF_NOT_NULL(fl_ckv);
+ }
+ SET_USER_DATA_FLAGS(ikey, rename);
+ } else if (UNC_OP_UPDATE == req->operation) {
+ uint8_t rename = 0;
+ result_code = IsRenamed(ikey, req->datatype, dmi, rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ return result_code;
+ }
+ if (UNC_VF_VALID == val_ffe->valid[UPLL_IDX_FLOWLIST_NAME_VFFE]) {
+ ConfigKeyVal *fl_ckv = NULL;
+ result_code = GetFlowlistConfigKey(reinterpret_cast<const char *>
+ (val_ffe->flowlist_name), fl_ckv, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetFlowlistConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *fl_mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_FLOWLIST)));
+ if (NULL == fl_mgr) {
+ UPLL_LOG_DEBUG("fl_mgr is NULL");
+ DELETE_IF_NOT_NULL(fl_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t fl_rename = 0;
+ result_code = fl_mgr->IsRenamed(fl_ckv, req->datatype, dmi, fl_rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(fl_ckv);
+ return result_code;
+ }
+ if (fl_rename & 0x01) {
+ UPLL_LOG_DEBUG("rename flag in flowlist %d", fl_rename);
+ rename |= FLOWLIST_RENAME; // TODO Check for correct flag value
+ } else {
+ rename &= NO_FLOWLIST_RENAME;
+ /* reset flag*/
+ }
+ DELETE_IF_NOT_NULL(fl_ckv);
+ } else if (UNC_VF_VALID_NO_VALUE == val_ffe->valid
+ [UPLL_IDX_FLOWLIST_NAME_VFFE]) {
+ rename &= NO_FLOWLIST_RENAME; // TODO Check for correct flag value. No rename flowlist value should be set
+ }
+ UPLL_LOG_DEBUG("Setting flag in update %d", rename);
+ SET_USER_DATA_FLAGS(ikey, rename);
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtnFlowFilterEntryMoMgr::GetFlowlistConfigKey(
+ const char *flowlist_name, ConfigKeyVal *&okey,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_FLOWLIST)));
+ result_code = mgr->GetChildConfigKey(okey, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
+ return result_code;
+ }
+ key_flowlist_t *okey_key = reinterpret_cast<key_flowlist_t *>
+ (okey->get_key());
+ uuu::upll_strncpy(okey_key->flowlist_name,
+ flowlist_name,
+ (kMaxLenFlowListName+1));
+ return UPLL_RC_SUCCESS;
+}
} // namespace kt_momgr
} // namespace upll
} // namespace unc
#define FLOWLIST 1
#define NWMONITOR 2
+
+#define FREE_LIST_CTRLR(list_ctrlr_dom) { \
+ for (std::list<controller_domain_t>::iterator it= list_ctrlr_dom.begin(); \
+ it != list_ctrlr_dom.end(); ++it) { \
+ FREE_IF_NOT_NULL(it->ctrlr); \
+ FREE_IF_NOT_NULL(it->domain); \
+ } \
+}
+
typedef struct val_vtn_flowfilter_entry_ctrlr {
uint8_t valid[5];
unc_keytype_configstatus_t cs_row_status;
*/
static BindInfo vtn_flowlist_rename_bind_info[];
+ uint32_t cur_instance_count;
+
public:
/**
* @brief This API is used to verify the existance of
}
delete[] table;
}
+
+ upll_rc_t CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id);
/**
* @brief This API is used to retrive the configuration details.
*
const char *ctrlr_id,
ConfigKeyVal *ikey,
DalDmlIntf *dmi);
+ upll_rc_t MergeImportToCandidate(unc_key_type_t keytype,
+ const char *ctrlr_name,
+ DalDmlIntf *dmi);
/* @brief The Rename Operation is not allowed for the Key type KT_VTN_FLOWFILTER_ENTRY
*
* @return code UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT. Rename operation is not allowed for
* @retval UPLL_RC_ERR_GENERIC Generic Errors.
* **/
- upll_rc_t GetRenamedControllerKey(ConfigKeyVal *&ikey,
+ upll_rc_t GetRenamedControllerKey(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
controller_domain *ctrlr_dom = NULL);
uint8_t* vtn_name,
controller_domain *ctrlr_dom,
unc_keytype_operation_t op,
- DalDmlIntf *dmi);
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi,
+ uint8_t flag);
/**
* @brief Method used for GetParentConfigKey Operation.
*
*/
upll_rc_t GetParentConfigKey(ConfigKeyVal *&okey,
ConfigKeyVal *ikey);
+ /**
+ * @brief Method used for Restoring FlowList in the Controller Table
+ *
+ * @param[in] ikey Pointer to ConfigKeyVal Class
+ * @param[in] dt_type Describes Configiration Information.
+ * @param[in] tbl Describe the destination table
+ * @param[in] dmi Pointer to DalDmlIntf Class.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_DB_ACCESS DB Read/Write error.
+ * @retval UPLL_RC_ERR_INSTANCE_EXISTS Record already exists
+ * @retval UPLL_RC_ERR_GENERIC Returned Generic Error.
+ */
+
+ upll_rc_t RestorePOMInCtrlTbl(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl,
+ DalDmlIntf* dmi);
upll_rc_t UpdateFlowListInCtrl(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
unc_keytype_operation_t op,
DalDmlIntf* dmi);
upll_rc_t IsNWMReferenced(ConfigKeyVal *ikey,
upll_rc_t ReadControllerStateDetail(ConfigKeyVal *ikey ,
ConfigKeyVal *drv_resp_ckv,
- upll_keytype_datatype_t dt_type,
- unc_keytype_operation_t op,
- DalDmlIntf *dmi,
controller_domain *ctrlr_dom,
ConfigKeyVal **okey);
upll_rc_t GetCtrlFlowFilterEntry(
val_vtn_flowfilter_entry_ctrlr_t *val_vtn_ffe_ctrlr,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
- val_vtn_flowfilter_entry_t *&op_val_vtn_ffe);
+ val_vtn_flowfilter_entry_t *&op_val_vtn_ffe,
+ const char* ctrlr_name,
+ unc_keytype_option1_t opt1 = UNC_OPT1_NORMAL);
upll_rc_t ReadSiblingCount(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
DalDmlIntf *dmi,
ConfigKeyVal **okey);
- upll_rc_t ConstructReadSiblingDetailResponse(
- ConfigKeyVal *ikey ,
- ConfigKeyVal *drv_resp_ckv,
- upll_keytype_datatype_t dt_type,
- DalDmlIntf *dmi,
- ConfigKeyVal **okey);
-
upll_rc_t GetVtnControllerSpan(
ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
std::list<controller_domain_t> &list_ctrlr_dom);
upll_rc_t IsFlowListConfigured(
const char* flowlist_name, DalDmlIntf *dmi);
+
+ upll_rc_t DeleteChildrenPOM(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi);
+
+ upll_rc_t SetValidAudit(ConfigKeyVal *&ikey);
+ upll_rc_t UpdateVnodeVal(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t data_type,
+ bool &no_rename);
+
+ bool FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op);
+
+ upll_rc_t Get_Tx_Consolidated_Status(
+ unc_keytype_configstatus_t &status,
+ unc_keytype_configstatus_t drv_result_status,
+ unc_keytype_configstatus_t current_cs,
+ unc_keytype_configstatus_t current_ctrlr_cs);
+
+ upll_rc_t IsRenamed(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi,
+ uint8_t &rename);
+ upll_rc_t
+ SetVtnFFEntryConsolidatedStatus(ConfigKeyVal *ikey,
+ uint8_t *ctrlr_id,
+ DalDmlIntf *dmi);
+
+ upll_rc_t GetFlowlistConfigKey(
+ const char *flowlist_name, ConfigKeyVal *&okey,
+ DalDmlIntf *dmi);
+
+ upll_rc_t SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req);
+
+ bool CompareValidVal(void *&val1, void *val2,
+ void *val3, bool audit);
};
} // namespace kt_momgr
#include "unc/upll_errno.h"
#include "upll_validation.hh"
#include "unc/upll_ipc_enum.h"
-#include"upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "ctrlr_capa_defines.hh"
#include "vtn_momgr.hh"
namespace upll {
namespace kt_momgr {
-#define NUM_KEY_MAIN_TBL_ 5
-
// Vtn_FlowFilter Table(Main Table)
BindInfo VtnFlowFilterMoMgr::vtn_flowfilter_bind_info[] = {
{ uudst::vtn_flowfilter::kDbiVtnName, CFG_KEY,
offsetof(key_user_data_t, flags),
uud::kDalUint8, 1 },
{ uudst::vtn_flowfilter_ctrlr::kDbiCsRowStatus, CS_VAL,
- offsetof(val_flowfilter_t, cs_row_status),
+ offsetof(val_vtn_flowfilter_ctrlr_t, cs_row_status),
uud::kDalUint8, 1 }
};
{ uudst::vtn_flowfilter::kDbiVtnName, CFG_MATCH_KEY, offsetof(
key_vtn_flowfilter_t, vtn_key.vtn_name),
uud::kDalChar, kMaxLenVtnName + 1 },
- { uudst::vtn_flowfilter::kDbiInputDirection, CFG_MATCH_KEY, offsetof(
- key_vtn_flowfilter_t, input_direction),
- uud::kDalUint8, 1 },
{ uudst::vtn_flowfilter::kDbiVtnName, CFG_INPUT_KEY, offsetof(
key_rename_vnode_info_t, new_unc_vtn_name),
uud::kDalChar, kMaxLenVtnName + 1 },
- { uudst::vtn_flowfilter::kDbiFlags, CFG_INPUT_KEY, offsetof(
+ { uudst::vtn_flowfilter::kDbiFlags, CK_VAL, offsetof(
key_user_data_t, flags),
uud::kDalUint8, 1 }
};
{ uudst::vtn_flowfilter_ctrlr::kDbiVtnName, CFG_MATCH_KEY, offsetof(
key_vtn_flowfilter_t, vtn_key.vtn_name),
uud::kDalChar, kMaxLenVtnName + 1 },
- { uudst::vtn_flowfilter_ctrlr::kDbiInputDirection, CFG_MATCH_KEY, offsetof(
- key_vtn_flowfilter_t, input_direction),
- uud::kDalUint8, 1 },
{ uudst::vtn_flowfilter_ctrlr::kDbiVtnName, CFG_INPUT_KEY, offsetof(
key_rename_vnode_info_t, new_unc_vtn_name),
uud::kDalChar, kMaxLenVtnName + 1 },
- { uudst::vtn_flowfilter_ctrlr::kDbiFlags, CFG_INPUT_KEY, offsetof(
+ { uudst::vtn_flowfilter_ctrlr::kDbiFlags, CK_VAL, offsetof(
key_user_data_t, flags),
- uud::kDalUint8, 1 },
- { uudst::vtn_flowfilter_ctrlr::kDbiCtrlrName, CK_VAL, offsetof(
- key_user_data_t, ctrlr_id),
- uud::kDalChar, kMaxLenCtrlrId+1 },
- { uudst::vtn_flowfilter_ctrlr::kDbiDomainId, CK_VAL, offsetof(
- key_user_data_t, domain_id),
- uud::kDalChar, kMaxLenDomainId+1 }
+ uud::kDalUint8, 1 }
};
unc_key_type_t VtnFlowFilterMoMgr::vtn_flowfilter_child[] = {
nchild = sizeof(vtn_flowfilter_child) / sizeof(vtn_flowfilter_child[0]);
child = vtn_flowfilter_child;
+ cur_instance_count = 0;
}
upll_rc_t VtnFlowFilterMoMgr::MergeValidate(unc_key_type_t keytype,
- const char *ctrlr_id,
- ConfigKeyVal *ikey,
+ const char *ctrlr_id,
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ckval = NULL;
+ ConfigKeyVal *ckey = NULL;
+
+ if (NULL == ctrlr_id) {
+ UPLL_LOG_DEBUG("MergeValidate ctrlr_id NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ result_code = GetChildConfigKey(ckval, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey ckval NULL");
+ return result_code;
+ }
+
+ if (!ckval) return UPLL_RC_ERR_GENERIC;
+
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
+
+ result_code = ReadConfigDB(ckval, UPLL_DT_IMPORT,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ckval);
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ return result_code;
+ }
+ return UPLL_RC_SUCCESS;
+ }
+ ConfigKeyVal *tmp_ckval = ckval;
+ while (NULL != ckval) {
+ // Check the VTN already configured in UNC
+ VtnMoMgr *vtnmgr =
+ static_cast<VtnMoMgr *>((const_cast<MoManager *>
+ (GetMoManager(UNC_KT_VTN))));
+ result_code = vtnmgr->GetChildConfigKey(ckey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey error (%d)", result_code);
+ DELETE_IF_NOT_NULL(ckval);
+ return result_code;
+ }
+ if (!ckey) return UPLL_RC_ERR_GENERIC;
+
+ key_vtn_t *vtn_okey = reinterpret_cast<key_vtn_t *>(ckey->get_key());
+ key_vtn_flowfilter_t *vtn_ikey = reinterpret_cast<key_vtn_flowfilter_t *>(ckval->get_key());
+ uuu::upll_strncpy(vtn_okey->vtn_name, vtn_ikey->vtn_key.vtn_name,
+ kMaxLenVtnName+1);
+ DbSubOp dbop1 = { kOpReadExist, kOpMatchNone, kOpInOutNone };
+ // Check the vtn already exist in vtn tbl
+ result_code = vtnmgr->UpdateConfigDB(ckey, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
+ &dbop1, MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ UPLL_LOG_DEBUG("vtn already exists");
+ DELETE_IF_NOT_NULL(ckey);
+ ckval = ckval->get_next_cfg_key_val();
+ continue;
+ }
+
+ DELETE_IF_NOT_NULL(ckey);
+ // If already vtn not configured, then do merge validation
+ DbSubOp dbop2 = { kOpReadExist, kOpMatchNone, kOpInOutNone };
+ result_code = UpdateConfigDB(ckval, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
+ &dbop2, MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ UPLL_LOG_DEBUG("Merge Conflict");
+ result_code = DupConfigKeyVal(ikey, ckval, MAINTBL);
+ DELETE_IF_NOT_NULL(ckval);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal fail");
+ return result_code;
+ }
+ return UPLL_RC_ERR_MERGE_CONFLICT;
+ } else if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ ckval = ckval->get_next_cfg_key_val();
+ } else {
+ UPLL_LOG_DEBUG("Merge Conflict DB err");
+ DELETE_IF_NOT_NULL(ckval);
+ return result_code;
+ }
+ }
+ DELETE_IF_NOT_NULL(tmp_ckval);
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtnFlowFilterMoMgr::MergeImportToCandidate(unc_key_type_t keytype,
+ const char *ctrlr_name,
DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
- UPLL_LOG_DEBUG("No validations require for VTNFlowfilter");
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+
+ ConfigKeyVal *ckval = NULL;
+ ConfigKeyVal *ckey = NULL;
+
+ controller_domain ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ uint8_t flag = 0;
+
+ if (NULL == ctrlr_name) {
+ UPLL_LOG_DEBUG("MergeValidate ctrlr_id NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ result_code = GetChildConfigKey(ckval, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey ckval NULL");
+ return result_code;
+ }
+
+
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutFlag };
+ // Read vtn ff from import main
+ result_code = ReadConfigDB(ckval, UPLL_DT_IMPORT,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ckval);
+ UPLL_LOG_DEBUG("ReadConfigDB ckval NULL (%d)", result_code);
+ if(result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("ReadConfigDB ckval NULL (%d)", result_code);
+ return result_code;
+ }
+ return UPLL_RC_SUCCESS;
+ }
+
+ UPLL_LOG_DEBUG("ReadConfigDB ckval NULL (%d)", result_code);
+ ConfigKeyVal *tmp_ckval1 = ckval;
+ while (NULL != ckval) {
+ // Check the VTN already configured in UNC
+ VtnMoMgr *vtnmgr =
+ static_cast<VtnMoMgr *>((const_cast<MoManager *>
+ (GetMoManager(UNC_KT_VTN))));
+ result_code = vtnmgr->GetChildConfigKey(ckey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey error (%d)", result_code);
+ DELETE_IF_NOT_NULL(ckval);
+ return result_code;
+ }
+ if (!ckey) return UPLL_RC_ERR_GENERIC;
+
+ key_vtn_t *vtn_okey = reinterpret_cast<key_vtn_t *>(ckey->get_key());
+ key_vtn_flowfilter *vtn_ikey = reinterpret_cast<key_vtn_flowfilter_t *>(ckval->get_key());
+ uuu::upll_strncpy(vtn_okey->vtn_name, vtn_ikey->vtn_key.vtn_name,
+ kMaxLenVtnName+1);
+ DbSubOp dbop1 = { kOpReadExist, kOpMatchNone, kOpInOutNone };
+ // Check the vtn already exist in vtn tbl
+ result_code = vtnmgr->UpdateConfigDB(ckey, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
+ &dbop1, MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ UPLL_LOG_DEBUG("vtn already exists");
+ DELETE_IF_NOT_NULL(ckey);
+ ckval = ckval->get_next_cfg_key_val();
+ continue;
+ } else if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ DELETE_IF_NOT_NULL(ckey);
+ DELETE_IF_NOT_NULL(ckval);
+ return result_code;
+ }
+
+ // If not same vtn, then merge the vtn ff to candidate tbl
+ result_code = UpdateConfigDB(ckval, UPLL_DT_CANDIDATE, UNC_OP_CREATE,
+ dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("create in CandidateDB failed: err code(%d) ",
+ result_code);
+ DELETE_IF_NOT_NULL(ckey);
+ DELETE_IF_NOT_NULL(ckval);
+ return result_code;
+ }
+
+ result_code = vtnmgr->GetControllerDomainSpan(ckey, UPLL_DT_IMPORT, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("GetControllerSpan no instance/error (%d)", result_code);
+ DELETE_IF_NOT_NULL(ckey);
+ continue;
+ }
+ }
+ ConfigKeyVal *tmp_ckey1 = ckey;
+ while (ckey != NULL) {
+ ConfigKeyVal *ctrlckv = NULL;
+ GET_USER_DATA_CTRLR_DOMAIN(ckey, ctrlr_dom);
+ GET_USER_DATA_FLAGS(ckval, flag);
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+
+ UPLL_LOG_DEBUG("flag (%d)", flag);
+
+ key_vtn_flowfilter_t *vtn_ff_key = reinterpret_cast<key_vtn_flowfilter_t*>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_t)));
+ memcpy(vtn_ff_key, reinterpret_cast<key_vtn_flowfilter_t*>(ckval->get_key()),
+ sizeof(key_vtn_flowfilter_t));
+
+ ctrlckv = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER, IpctSt::kIpcInvalidStNum,
+ vtn_ff_key, NULL);
+ SET_USER_DATA_CTRLR_DOMAIN(ctrlckv, ctrlr_dom);
+ SET_USER_DATA_FLAGS(ctrlckv, flag);
+
+ UPLL_LOG_DEBUG("flag (%d)", flag);
+
+ // Create/Update/Delete a record in CANDIDATE DB
+ result_code = UpdateConfigDB(ctrlckv, UPLL_DT_CANDIDATE, UNC_OP_CREATE, dmi, CTRLRTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Err while inserting in ctrlr table for candidateDb(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(ckey);
+ DELETE_IF_NOT_NULL(ckval);
+ DELETE_IF_NOT_NULL(ctrlckv);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(ctrlckv);
+ ckey = ckey->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(tmp_ckey1);
+ ckval = ckval->get_next_cfg_key_val();
+}
+
+ DELETE_IF_NOT_NULL(tmp_ckval1);
return UPLL_RC_SUCCESS;
+#if 0
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ctrlr_key = NULL, *req = NULL, *nreq = NULL;
+ DalCursor *cfg1_cursor = NULL;
+ DalResultCode db_result;
+
+ //Get the created records on import configuration which are not available
+ // at running configuration of UNC
+ result_code = DiffConfigDB(UPLL_DT_IMPORT, UPLL_DT_RUNNING, UNC_OP_CREATE, req,
+ nreq, &cfg1_cursor, dmi, MAINTBL);
+ while (result_code == UPLL_RC_SUCCESS) {
+ db_result = dmi->GetNextRecord(cfg1_cursor);
+ result_code = DalToUpllResCode(db_result);
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ result_code = UPLL_RC_SUCCESS;
+ break;
+ }
+
+ // Update the record in the main table
+ result_code = UpdateConfigDB(req, UPLL_DT_CANDIDATE, UNC_OP_CREATE,
+ dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to update the main tbl,DB err %d", result_code);
+ if (cfg1_cursor) {
+ dmi->CloseCursor(cfg1_cursor, true);
+ cfg1_cursor = NULL;
+ }
+ delete req;
+ req = NULL;
+ return result_code;
+ }
+ //Update Controller Table
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchCtrlr,
+ kOpInOutCtrlr|kOpInOutDomain};
+ result_code = DupConfigKeyVal(ctrlr_key, req, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal is failed result_code = %d",
+ result_code);
+ return result_code;
+ }
+ SET_USER_DATA_CTRLR(ctrlr_key, ctrlr_name);
+
+ result_code = ReadConfigDB(ctrlr_key, UPLL_DT_IMPORT, UNC_OP_READ,
+ dbop, dmi, CTRLRTBL);
+ if ((result_code != UPLL_RC_SUCCESS) &&
+ (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG("Error in ReadConfigDb (%d)", result_code);
+ return result_code;
+ }
+ // create a record in CANDIDATE DB
+ result_code = UpdateConfigDB(ctrlr_key, UPLL_DT_CANDIDATE, UNC_OP_CREATE,
+ dmi, CTRLRTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to update ctrl table, DB err %d", result_code);
+ if (cfg1_cursor) {
+ dmi->CloseCursor(cfg1_cursor, true);
+ cfg1_cursor = NULL;
+ }
+ delete req;
+ req = NULL;
+ return result_code;
+ }
+ delete ctrlr_key;
+ ctrlr_key = NULL;
+ }
+ if (cfg1_cursor) {
+ dmi->CloseCursor(cfg1_cursor, true);
+ cfg1_cursor = NULL;
+ }
+ if (req) {
+ delete req;
+ req = NULL;
+ }
+ return result_code;
+#endif
}
upll_rc_t VtnFlowFilterMoMgr::UpdateMo(IpcReqRespHeader *req,
return result_code;
}
// Check if VTN flowfilter exists in RUNNING DB and move it to CANDIDATE DB
+ if (UPLL_DT_CANDIDATE == req->datatype) {
result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_READ,
dmi, MAINTBL);
if ((result_code != UPLL_RC_ERR_INSTANCE_EXISTS) &&
result_code);
return UPLL_RC_ERR_GENERIC;
}
+ return result_code;
+ }
}
std::list<controller_domain_t> list_ctrlr_dom;
- vtn_ctrlr_span_rt_code = GetVtnControllerSpan(ikey, dmi, list_ctrlr_dom);
+ vtn_ctrlr_span_rt_code = GetVtnControllerSpan(ikey, req->datatype, dmi, list_ctrlr_dom);
if ((vtn_ctrlr_span_rt_code != UPLL_RC_SUCCESS) &&
(vtn_ctrlr_span_rt_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
UPLL_LOG_DEBUG(" GetVtnControllerSpan error code (%d)",
return result_code;
}
- if (vtn_ctrlr_span_rt_code == UPLL_RC_SUCCESS) {
- for (std::list<controller_domain_t>::iterator it= list_ctrlr_dom.begin();
- it != list_ctrlr_dom.end(); ++it) {
- result_code = ValidateCapability(
- req, ikey,
- reinterpret_cast<const char *>(it->ctrlr));
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Key not supported by controller");
- return result_code;
- }
- }
- }
// create a record in CANDIDATE DB for Main Table
result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_CREATE,
dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("create in ctrlr tbl failed: error code (%d)",
result_code);
+ #if 0
result_code = UpdateConfigDB(ikey, req->datatype, UNC_OP_DELETE,
dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("delete in CandidateDB failed: err code(%d) ",
result_code);
}
+ #endif
}
}
UPLL_FUNC_TRACE;
ConfigKeyVal *ctrlckv = NULL;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- for (std::list<controller_domain_t>::iterator it= list_ctrlr_dom.begin();
- it != list_ctrlr_dom.end(); ++it) {
+ unc_keytype_ctrtype_t ctrlrtype = UNC_CT_UNKNOWN;
+ uuc::CtrlrMgr *ctrlr_mgr = uuc::CtrlrMgr::GetInstance();
+ std::list<controller_domain_t>::iterator it= list_ctrlr_dom.begin();
+ while (it != list_ctrlr_dom.end()) {
+ if ((op == UNC_OP_CREATE) || (op == UNC_OP_UPDATE)) {
+ if (op == UNC_OP_CREATE) {
+ //capability check
+ ConfigKeyVal *temp_key = NULL;
+ result_code = GetChildConfigKey(temp_key, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed(%d)",result_code);
+ return result_code;
+ }
+
+ result_code = GetInstanceCount(temp_key, reinterpret_cast<char*>(it->ctrlr),
+ UPLL_DT_CANDIDATE,
+ &cur_instance_count,
+ dmi, CTRLRTBL);
+
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(temp_key);
+ UPLL_LOG_DEBUG("GetInstanceCount failed(%d)",result_code);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(temp_key);
+ }
+ IpcReqRespHeader *req_header = reinterpret_cast<IpcReqRespHeader*>
+ (ConfigKeyVal::Malloc(sizeof(IpcReqRespHeader)));
+
+ req_header->operation = op;
+ req_header->datatype = dt_type;
+
+ // Validate whether the attributes supported by controller or not
+ result_code = ValidateCapability(req_header,
+ ikey,
+ reinterpret_cast<char*>(it->ctrlr));
+ free(req_header);
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ if ((!ctrlr_mgr->GetCtrlrType(reinterpret_cast<char *>(it->ctrlr),
+ dt_type, &ctrlrtype)) || (ctrlrtype != UNC_CT_PFC)) {
+
+ UPLL_LOG_DEBUG("Controller type is %d", ctrlrtype);
+ result_code = UPLL_RC_SUCCESS;
+ ++it;
+ continue;
+ }
+ UPLL_LOG_DEBUG("ValidateCapability Failed: result_code=%d",
+ result_code);
+ return result_code;
+ }
+ }
key_vtn_flowfilter_t *vtn_ff_key = reinterpret_cast<key_vtn_flowfilter_t*>
(ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_t)));
memcpy(vtn_ff_key, reinterpret_cast<key_vtn_flowfilter_t*>(ikey->get_key()),
sizeof(key_vtn_flowfilter_t));
ctrlckv = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER, IpctSt::kIpcInvalidStNum,
vtn_ff_key, NULL);
+
SET_USER_DATA_CTRLR_DOMAIN(ctrlckv, *it);
+ if (UNC_OP_CREATE == op) {
+ DbSubOp dbop1 = { kOpReadExist, kOpMatchCtrlr |
+ kOpMatchDomain, kOpInOutNone };
+ result_code = UpdateConfigDB(ctrlckv, dt_type, UNC_OP_READ, dmi, &dbop1,
+ CTRLRTBL);
+ if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ DELETE_IF_NOT_NULL(ctrlckv);
+ return result_code;
+ }
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ ++it;
+ DELETE_IF_NOT_NULL(ctrlckv);
+ continue;
+ }
+ }
// Create/Update/Delete a record in CANDIDATE DB
result_code = UpdateConfigDB(ctrlckv, dt_type, op, dmi, CTRLRTBL);
+ DELETE_IF_NOT_NULL(ctrlckv);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Err while inserting in ctrlr table for candidateDb(%d)",
+ UPLL_LOG_DEBUG("Err while updating the ctrlr table for CandidateDB(%d)",
result_code);
- }
-
- if (ctrlckv) {
- delete ctrlckv;
- ctrlckv = NULL;
- }
- if (result_code != UPLL_RC_SUCCESS) {
return result_code;
}
+ ++it;
}
- return result_code;
+ return UPLL_RC_SUCCESS;
}
upll_rc_t VtnFlowFilterMoMgr::UpdateControllerTableForVtn(uint8_t* vtn_name,
controller_domain *ctrlr_dom,
unc_keytype_operation_t op,
- DalDmlIntf *dmi) {
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi,
+ uint8_t flag) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- /* TODO */
ConfigKeyVal *ctrlckv = NULL, *ikey = NULL;
+ unc_keytype_ctrtype_t ctrlrtype = UNC_CT_UNKNOWN;
+ uuc::CtrlrMgr *ctrlr_mgr = uuc::CtrlrMgr::GetInstance();
+
result_code = GetChildConfigKey(ikey, NULL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetChildConfigKey is fail");
return result_code;
}
+ UPLL_LOG_TRACE("Controller : %s; Domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
key_vtn_flowfilter *vtn_ff_key = reinterpret_cast<key_vtn_flowfilter_t*>
(ikey->get_key());
uuu::upll_strncpy(vtn_ff_key->vtn_key.vtn_name,
// can be bound for output instead of match
vtn_ff_key->input_direction = 0xFE;
- DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutNone};
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutCs | kOpInOutFlag};
// Read the Configuration from the MainTable
- result_code = ReadConfigDB(ikey, UPLL_DT_CANDIDATE,
+ result_code = ReadConfigDB(ikey, dt_type,
UNC_OP_READ, dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
UPLL_LOG_DEBUG(" No Records in main table to be created in ctrlr tbl");
+ DELETE_IF_NOT_NULL(ikey);
return UPLL_RC_SUCCESS;
}
- delete ikey;
+ DELETE_IF_NOT_NULL(ikey);
return result_code;
}
- while (ikey != NULL) {
- result_code = GetControllerKeyval(ctrlckv, ikey, ctrlr_dom);
+ if (flag != 0) {
+ UPLL_LOG_DEBUG("flag in UpdateControllerTableForVtn %d", flag);
+ ConfigKeyVal *temp_ikey = ikey;
+ ConfigKeyVal *flag_ikey = NULL;
+ while (temp_ikey != NULL) {
+ result_code = DupConfigKeyVal(flag_ikey, temp_ikey, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed %d", result_code);
+ DELETE_IF_NOT_NULL(ikey);
+ return result_code;
+ }
+ uint8_t temp_flag = 0;
+ GET_USER_DATA_FLAGS(flag_ikey, temp_flag);
+ UPLL_LOG_DEBUG("temp_flag in UpdateControllerTableForVtn %d", temp_flag);
+ flag = flag | temp_flag;
+ UPLL_LOG_DEBUG("temp_flag in UpdateControllerTableForVtn %d", temp_flag);
+ SET_USER_DATA_FLAGS(flag_ikey, flag);
+ DbSubOp dbop1 = {kOpNotRead, kOpMatchNone, kOpInOutCs | kOpInOutFlag};
+ result_code = UpdateConfigDB(flag_ikey, dt_type, UNC_OP_UPDATE,
+ dmi, &dbop1, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(ikey);
+ DELETE_IF_NOT_NULL(flag_ikey);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(flag_ikey);
+ temp_ikey = temp_ikey->get_next_cfg_key_val();
+ }
+ }
+ ConfigKeyVal *temp_ikey = ikey;
+ while (temp_ikey != NULL) {
+ result_code = GetControllerKeyval(ctrlckv, temp_ikey, ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetControllerKeyval is Fail");
+ DELETE_IF_NOT_NULL(ikey);
return UPLL_RC_ERR_GENERIC;
}
- if (ctrlckv == NULL) {
- UPLL_LOG_DEBUG("ctrlckv is NULL");
- return UPLL_RC_ERR_GENERIC;
+
+ if ((op == UNC_OP_CREATE) || (op == UNC_OP_UPDATE)) {
+ if (op == UNC_OP_CREATE) {
+ //capability check
+ ConfigKeyVal *temp_key = NULL;
+ result_code = GetChildConfigKey(temp_key, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ikey);
+ DELETE_IF_NOT_NULL(ctrlckv);
+ UPLL_LOG_DEBUG("GetChildConfigKey failed(%d)",result_code);
+ return result_code;
+ }
+
+ key_vtn_flowfilter *vtn_ff_capakey = reinterpret_cast<key_vtn_flowfilter_t*>
+ (temp_key->get_key());
+ vtn_ff_capakey->input_direction = 0xFE;
+
+ result_code = GetInstanceCount(temp_key, reinterpret_cast<char*>(ctrlr_dom->ctrlr),
+ UPLL_DT_CANDIDATE,
+ &cur_instance_count,
+ dmi, CTRLRTBL);
+
+ DELETE_IF_NOT_NULL(temp_key);
+
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ikey);
+ DELETE_IF_NOT_NULL(ctrlckv);
+ UPLL_LOG_DEBUG("GetInstanceCount failed(%d)",result_code);
+ return result_code;
+ }
+ }
+
+ IpcReqRespHeader *req_header = reinterpret_cast<IpcReqRespHeader*>
+ (ConfigKeyVal::Malloc(sizeof(IpcReqRespHeader)));
+ req_header->operation = op;
+ req_header->datatype = dt_type;
+
+ // Validate whether the attributes supported by controller or not
+ result_code = ValidateCapability(
+ req_header, temp_ikey,
+ reinterpret_cast<char*>(ctrlr_dom->ctrlr));
+ free(req_header);
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ // VTN Flowfilter is not supported for other than PFC Controller
+ // so skip adding entry for such sontroller in ctrlr table
+ if ((!ctrlr_mgr->GetCtrlrType(reinterpret_cast<char *>(ctrlr_dom->ctrlr),
+ dt_type, &ctrlrtype)) || (ctrlrtype != UNC_CT_PFC)) {
+ result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_DEBUG("Controller type is %d", ctrlrtype);
+ temp_ikey = temp_ikey->get_next_cfg_key_val();
+ DELETE_IF_NOT_NULL(ctrlckv);
+ continue;
+ }
+ UPLL_LOG_DEBUG("ValidateCapability Failed: result_code=%d",
+ result_code);
+ DELETE_IF_NOT_NULL(ikey);
+ DELETE_IF_NOT_NULL(ctrlckv);
+ return result_code;
+ }
+ }
+ if (UPLL_DT_AUDIT == dt_type) {
+ val_vtn_flowfilter_ctrlr_t *val = reinterpret_cast<val_vtn_flowfilter_ctrlr_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtn_flowfilter_ctrlr_t)));
+ val->cs_row_status = UNC_CS_APPLIED;
+ ctrlckv->AppendCfgVal(IpctSt::kIpcInvalidStNum, val);
}
// Create/Update/Delete a record in CANDIDATE DB
- result_code = UpdateConfigDB(ctrlckv, UPLL_DT_CANDIDATE, op, dmi, CTRLRTBL);
+ result_code = UpdateConfigDB(ctrlckv, dt_type, op, dmi, CTRLRTBL);
if (UPLL_RC_SUCCESS != result_code) {
- if (ctrlckv != NULL) delete ctrlckv;
UPLL_LOG_DEBUG("Err while updating in ctrlr table for candidateDb(%d)",
result_code);
+ DELETE_IF_NOT_NULL(ikey);
+ DELETE_IF_NOT_NULL(ctrlckv);
return result_code;
} else {
- if (ctrlckv != NULL) delete ctrlckv;
+ DELETE_IF_NOT_NULL(ctrlckv);
}
- ikey = ikey->get_next_cfg_key_val();
+ temp_ikey = temp_ikey->get_next_cfg_key_val();
}
UPLL_LOG_DEBUG("Successful completion of the controller table updation");
-
+ DELETE_IF_NOT_NULL(ikey);
return result_code;
}
ConfigKeyVal *&ikey,
controller_domain *ctrlrdom) {
UPLL_FUNC_TRACE;
- key_vtn_flowfilter_t *flowfilter_key =
- reinterpret_cast<key_vtn_flowfilter_t*>(ikey->get_key());
- ctrlckv = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER, IpctSt::kIpcInvalidStNum,
- flowfilter_key, NULL);
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+ result_code = GetChildConfigKey(ctrlckv, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed");
+ return result_code;
+ }
SET_USER_DATA_CTRLR_DOMAIN(ctrlckv, *ctrlrdom);
+
return UPLL_RC_SUCCESS;
}
delete okey;
+ if (UNC_OP_CREATE == req->operation) {
+ result_code = SetRenameFlag(ikey, dmi, req);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("SetRenameFlag failed %d", result_code);
+ return result_code;
+ }
+ }
+
UPLL_LOG_DEBUG("ValidateAttribute Successfull.");
return result_code;
}
+upll_rc_t VtnFlowFilterMoMgr::SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *pkey = NULL;
+ result_code = GetParentConfigKey(pkey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetParentConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_VTN)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("mgr is NULL");
+ DELETE_IF_NOT_NULL(pkey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t rename = 0;
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutFlag};
+ result_code = mgr->ReadConfigDB(pkey, req->datatype,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(pkey);
+ return result_code;
+ }
+ GET_USER_DATA_FLAGS(pkey, rename);
+ UPLL_LOG_DEBUG("Flag from parent : %d", rename);
+ SET_USER_DATA_FLAGS(ikey, rename);
+ DELETE_IF_NOT_NULL(pkey);
+ return UPLL_RC_SUCCESS;
+}
+
+
upll_rc_t VtnFlowFilterMoMgr::RenameMo(IpcReqRespHeader *req,
ConfigKeyVal *ikey, DalDmlIntf *dmi,
const char *ctrlr_id) {
if (parent_key == NULL) {
vtn_ff_key = reinterpret_cast<key_vtn_flowfilter_t*>
(ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_t)));
+ // If no direction is specified , 0xFE is filled to bind output direction
+ vtn_ff_key->input_direction = 0xFE;
okey = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER,
IpctSt::kIpcStKeyVtnFlowfilter,
vtn_ff_key, NULL);
if (okey) {
if (okey->get_key_type() != UNC_KT_VTN_FLOWFILTER)
return UPLL_RC_ERR_GENERIC;
+ }
+ if ((okey) && (okey->get_key())) {
vtn_ff_key = reinterpret_cast<key_vtn_flowfilter_t *>
(okey->get_key());
} else {
vtn_ff_key = reinterpret_cast<key_vtn_flowfilter_t *>
(ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_t)));
+ // If no direction is specified , 0xFE is filled to bind output direction
+ vtn_ff_key->input_direction = 0xFE;
}
switch (parent_key->get_key_type()) {
case UNC_KT_VTN:
return UPLL_RC_ERR_GENERIC;
}
- if (!okey)
+ if ((okey) && !(okey->get_key())) {
+ UPLL_LOG_DEBUG("okey not null and flow list name updated");
+ okey->SetKey(IpctSt::kIpcStKeyVtnFlowfilter, vtn_ff_key);
+ }
+
+ if (!okey) {
okey = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER,
IpctSt::kIpcStKeyVtnFlowfilter,
vtn_ff_key, NULL);
+ }
SET_USER_DATA(okey, parent_key);
UPLL_LOG_DEBUG("Okey filled Succesfully %d", result_code);
}
upll_rc_t VtnFlowFilterMoMgr::GetRenamedControllerKey(
- ConfigKeyVal *&ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
+ ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
controller_domain *ctrlr_dom) {
UPLL_FUNC_TRACE;
ConfigKeyVal *okey = NULL;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- uint8_t rename = 0;
- // Check if VTN is renamed on the controller by getting VTN object
+
+ UPLL_LOG_TRACE("Start... Input ConfigKeyVal %s", ikey->ToStrAll().c_str());
MoMgrImpl *mgr = static_cast<MoMgrImpl*>((const_cast<MoManager*>
- (GetMoManager(UNC_KT_VTN))));
- mgr->GetChildConfigKey(okey, NULL);
- // mgr->IsRenamed(ikey, dt_type, dmi, rename);
- IsRenamed(ikey, dt_type, dmi, rename);
- if (!rename) {
- delete okey;
- return UPLL_RC_SUCCESS;
+ (GetMoManager(UNC_KT_VTN))));
+ result_code = mgr->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
+ return result_code;
}
- /* Vtn renamed */
- if (rename & VTN_RENAME) {
- if (ctrlr_dom)
+ if (ctrlr_dom) {
SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
- // Copy the input VTN Name into the Okey and send it for rename check IN db
+ } else {
+ UPLL_LOG_DEBUG("ctrlr_dom null");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
+ // Copy the input VTN Name into the Okey and send it for rename check IN db
uuu::upll_strncpy(
reinterpret_cast<key_vtn *>(okey->get_key())->vtn_name,
reinterpret_cast<key_vtn_flowfilter_t *>
(ikey->get_key())->vtn_key.vtn_name,
(kMaxLenVtnName + 1));
- DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
- /* ctrlr_name */
- result_code = mgr->ReadConfigDB(okey, dt_type, UNC_OP_READ,
- dbop, dmi, RENAMETBL);
- if (result_code != UPLL_RC_SUCCESS) { // COV CHECKED RETURN
- return result_code;
- }
- // NULL Checks Missing
+ UPLL_LOG_DEBUG("vtn name (%s) (%s)",
+ reinterpret_cast<key_vtn *>(okey->get_key())->vtn_name,
+ reinterpret_cast<key_vtn_flowfilter_t *>
+ (ikey->get_key())->vtn_key.vtn_name);
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr |
+ kOpMatchDomain, kOpInOutFlag };
+ /* ctrlr_name */
+ result_code = mgr->ReadConfigDB(okey, dt_type, UNC_OP_READ,
+ dbop, dmi, RENAMETBL);
+ if (result_code != UPLL_RC_SUCCESS &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB null");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ // NULL Checks Missing
+ if (result_code == UPLL_RC_SUCCESS) {
val_rename_vtn *rename_val = reinterpret_cast <val_rename_vtn *>
(GetVal(okey));
- if (!rename_val
- || (rename_val->valid[UPLL_IDX_NEW_NAME_RVTN] != UNC_VF_VALID))
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("Vtn Name is not Valid.");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(
reinterpret_cast<key_vtn_flowfilter_t*>
(ikey->get_key())->vtn_key.vtn_name,
rename_val->new_name,
(kMaxLenVtnName + 1));
- SET_USER_DATA_FLAGS(ikey, VTN_RENAME);
}
-
+ DELETE_IF_NOT_NULL(okey);
+ UPLL_LOG_TRACE("End... Input ConfigKeyVal %s", ikey->ToStrAll().c_str());
UPLL_LOG_DEBUG("GetRenamedControllerKey Success");
return UPLL_RC_SUCCESS;
}
uint8_t *ctrlr_id) {
UPLL_FUNC_TRACE;
ConfigKeyVal *unc_key = NULL;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vtnff start",
+ ikey->ToStrAll().c_str());
+ if ((ikey == NULL) || (ctrlr_id == NULL) || (dmi == NULL)) {
+ UPLL_LOG_DEBUG("ikey/ctrlr_id dmi NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
- key_vtn *rename_vtn_key = reinterpret_cast<key_vtn*>
- (ConfigKeyVal::Malloc(sizeof(key_vtn)));
+ val_rename_vtn *rename_vtn_key = reinterpret_cast<val_rename_vtn*>
+ (ConfigKeyVal::Malloc(sizeof(val_rename_vtn)));
+ if (!rename_vtn_key) {
+ UPLL_LOG_DEBUG("rename_vtn_key NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
key_vtn_flowfilter_t *ctrlr_key =
reinterpret_cast<key_vtn_flowfilter_t *>(ikey->get_key());
- uuu::upll_strncpy(rename_vtn_key->vtn_name,
+ if (!ctrlr_key) {
+ UPLL_LOG_DEBUG("rename_vtn_key NULL");
+ free(rename_vtn_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(rename_vtn_key->new_name,
ctrlr_key->vtn_key.vtn_name,
(kMaxLenVtnName + 1));
+ rename_vtn_key->valid[UPLL_IDX_NEW_NAME_RVTN] = UNC_VF_VALID;
+
MoMgrImpl *mgr = static_cast<MoMgrImpl*>((const_cast<MoManager*>(GetMoManager(
UNC_KT_VTN))));
- mgr->GetChildConfigKey(unc_key, NULL);
- if (ctrlr_id == NULL) {
- if (unc_key !=NULL) {
- delete unc_key;
- }
+ result_code = mgr->GetChildConfigKey(unc_key, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail");
free(rename_vtn_key);
- UPLL_LOG_DEBUG("ctrlr_id is NULL ");
- return UPLL_RC_ERR_GENERIC;
+ return result_code;
+ }
+ if (!unc_key) {
+ UPLL_LOG_DEBUG("unc_key NULL");
+ free(rename_vtn_key);
+ mgr = NULL;
+ return result_code;
}
SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
unc_key->AppendCfgVal(IpctSt::kIpcStValRenameVtn, rename_vtn_key);
- upll_rc_t result_code = mgr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop,
+ result_code = mgr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop,
dmi, RENAMETBL);
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(unc_key);
+ mgr = NULL;
+ return result_code;
+ }
+
if (result_code == UPLL_RC_SUCCESS) {
key_vtn *vtn_key = reinterpret_cast<key_vtn *>(unc_key->get_key());
uuu::upll_strncpy(ctrlr_key->vtn_key.vtn_name,
vtn_key->vtn_name,
(kMaxLenVtnName + 1));
}
- free(rename_vtn_key); // ADDED
- UPLL_LOG_DEBUG("GetRenamedUncKey is Success :: result_code %d", result_code);
- return result_code;
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vtnff end",
+ ikey->ToStrAll().c_str());
+ DELETE_IF_NOT_NULL(unc_key);
+ mgr = NULL;
+ return UPLL_RC_SUCCESS;
}
upll_rc_t VtnFlowFilterMoMgr::DupConfigKeyVal(ConfigKeyVal *&okey,
ConfigKeyVal *&req,
MoMgrTables tbl) {
UPLL_FUNC_TRACE;
- val_flowfilter_controller_t *flowfilter_ctrlr_val = NULL;
val_flowfilter_t *flowfilter_val = NULL;
if (req == NULL) {
UPLL_LOG_DEBUG("In sufficient parameters");
tmp1 = new ConfigVal(IpctSt::kIpcStValFlowfilter, flowfilter_val);
}
} else if (tbl == CTRLRTBL) {
- val_flowfilter_controller_t *ival =
- reinterpret_cast<val_flowfilter_controller_t *>(GetVal(req));
+ val_vtn_flowfilter_ctrlr_t *ival =
+ reinterpret_cast<val_vtn_flowfilter_ctrlr_t *>(GetVal(req));
if (NULL != ival) {
- flowfilter_ctrlr_val =
- reinterpret_cast<val_flowfilter_controller_t *>
- (ConfigKeyVal::Malloc(sizeof(val_flowfilter_controller_t)));
- memcpy(flowfilter_ctrlr_val, ival, sizeof(val_flowfilter_controller_t));
+ val_vtn_flowfilter_ctrlr_t *flowfilter_ctrlr_val = NULL;
+ flowfilter_ctrlr_val =
+ reinterpret_cast<val_vtn_flowfilter_ctrlr_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtn_flowfilter_ctrlr_t)));
+ memcpy(flowfilter_ctrlr_val, ival, sizeof(val_vtn_flowfilter_ctrlr_t));
tmp1 = new ConfigVal(IpctSt::kIpcStValFlowfilter,
flowfilter_ctrlr_val);
UPLL_LOG_DEBUG("Creation of Duplicate ConfigVal is successful");
}
- }
+ }
}
if (tmp1) {
DalDmlIntf *dmi) {
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *ckv = NULL;
- DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutNone};
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutCs};
if (ikey == NULL) {
return UPLL_RC_ERR_GENERIC;
}
return result_code;
}
std::list< unc_keytype_configstatus_t > list_cs_row;
- val_flowfilter_t *val;
- for ( ; ckv != NULL ; ckv = ckv->get_next_cfg_key_val()) {
- val = reinterpret_cast<val_flowfilter_t *>(GetVal(ckv));
+ val_vtn_flowfilter_ctrlr_t *val;
+ ConfigKeyVal *temp_ckv = ckv;
+ for ( ; temp_ckv != NULL ; temp_ckv = temp_ckv->get_next_cfg_key_val()) {
+ val = reinterpret_cast<val_vtn_flowfilter_ctrlr_t *>(GetVal(temp_ckv));
list_cs_row.push_back((unc_keytype_configstatus_t)val->cs_row_status);
}
+ DELETE_IF_NOT_NULL(ckv);
val_flowfilter_t *val_temp =
reinterpret_cast<val_flowfilter_t *>(GetVal(ikey));
val_temp->cs_row_status = GetConsolidatedCsStatus(list_cs_row);
ConfigKeyVal *&ckv_running) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- val_flowfilter_t *val;
+ val_vtn_flowfilter_ctrlr *val;
val = (ckv_running != NULL)?
- reinterpret_cast<val_flowfilter_t *>(GetVal(ckv_running)):NULL;
+ reinterpret_cast<val_vtn_flowfilter_ctrlr *>(GetVal(ckv_running)):NULL;
if (NULL == val) {
return UPLL_RC_ERR_GENERIC;
}
if (uuc::kUpllUcpCreate == phase )
- val->cs_row_status = cs_status;
+ val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
return result_code;
}
ConfigKeyVal *ctrlr_key) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- unc_keytype_configstatus_t status = UNC_CS_UNKNOWN,
- cs_status = UNC_CS_UNKNOWN; // TODO(UNC) :initialize valuefor compilation
- cs_status = (driver_result == 0) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
+ unc_keytype_configstatus_t ctrlr_status ;
+ uint8_t cs_status ;
+ ctrlr_status = (driver_result == UPLL_RC_SUCCESS) ?
+ UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
val_flowfilter_t *vtn_flowfilter_val =
reinterpret_cast<val_flowfilter_t *>(GetVal(vtn_flow_filter_key));
val_vtn_flowfilter_ctrlr *ctrlr_val_vtn_flowfilter =
reinterpret_cast<val_vtn_flowfilter_ctrlr *>(GetVal(ctrlr_key));
+
if ((vtn_flowfilter_val == NULL) || (ctrlr_val_vtn_flowfilter == NULL)) {
- UPLL_LOG_DEBUG("vrtif_flowfilter_entry_val &"
+ UPLL_LOG_DEBUG("vtn_flowfilter &"
"ctrlr_val_vtn_flowfilter is Null");
return UPLL_RC_ERR_GENERIC;
}
+
+ cs_status = vtn_flowfilter_val->cs_row_status;
+ UPLL_LOG_TRACE("cs_status %d ctrlr_status %d\n", cs_status, ctrlr_status);
if (op == UNC_OP_CREATE) {
- /*
- ctrlr_val_vtn->oper_status = UPLL_OPER_STATUS_UNKNOWN;
- ctrlr_val_vtn->alarm_status = UPLL_ALARM_CLEAR;
- ctrlr_val_vtn->valid[0] = UNC_VF_INVALID;
- ctrlr_val_vtn->valid[1] = UNC_VF_INVALID;
- */
- /* update the vtn status in main tbl */
- switch (vtn_flowfilter_val->cs_row_status) {
- case UNC_CS_UNKNOWN:
- status = cs_status;
- break;
- case UNC_CS_PARTAILLY_APPLIED:
- if (ctrlr_val_vtn_flowfilter->cs_row_status == UNC_CS_NOT_APPLIED) {
- // if this vtn has caused it then to change to applied.
+ ctrlr_val_vtn_flowfilter->cs_row_status = ctrlr_status;
+ /* update the vtn status in main tbl */
+ if (vtn_flowfilter_val->cs_row_status == UNC_CS_UNKNOWN) {
+ /* first entry in ctrlr table */
+ cs_status = ctrlr_status;
+ } else if (vtn_flowfilter_val->cs_row_status == UNC_CS_INVALID) {
+ cs_status = UNC_CS_INVALID;
+ } else if (vtn_flowfilter_val->cs_row_status == UNC_CS_APPLIED) {
+ if (ctrlr_status == UNC_CS_NOT_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
}
- break;
+ } else if (vtn_flowfilter_val->cs_row_status == UNC_CS_NOT_APPLIED) {
+ if (ctrlr_status == UNC_CS_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ }
+ } else {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ }
+ vtn_flowfilter_val->cs_row_status = cs_status;
+ }
+ // Updating the Controller cs_row_status
+ if ((op == UNC_OP_UPDATE) && (nreq != NULL)) {
+ val_vtn_flowfilter_ctrlr *run_ctrlr_val =
+ reinterpret_cast<val_vtn_flowfilter_ctrlr*>
+ (GetVal(nreq));
+ if (run_ctrlr_val != NULL)
+ ctrlr_val_vtn_flowfilter->cs_row_status = run_ctrlr_val->cs_row_status;
+ }
+ UPLL_LOG_DEBUG("UpdateConfigStatus is Successfull");
+ return result_code;
+}
+upll_rc_t
+VtnFlowFilterMoMgr::SetVtnFFConsolidatedStatus(ConfigKeyVal *ikey,
+ uint8_t *ctrlr_id,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ctrlr_ckv = NULL;
+ val_vtn_flowfilter_ctrlr_t *ctrlr_val = NULL;
+ uint8_t *vtn_exist_on_ctrlr = NULL;
+ bool applied = false, not_applied = false, invalid = false;
+ unc_keytype_configstatus_t c_status = UNC_CS_NOT_APPLIED;
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone,
+ kOpInOutCtrlr | kOpInOutDomain | kOpInOutCs };
+ if (!ikey || !dmi) {
+ UPLL_LOG_DEBUG("Invalid Input");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = GetChildConfigKey(ctrlr_ckv, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed err code %d", result_code);
+ return result_code;
+ }
+ result_code = ReadConfigDB(ctrlr_ckv, UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop, dmi,
+ CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB from ctrltbl failed err code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return result_code;
+ }
+
+ for (ConfigKeyVal *tmp = ctrlr_ckv; tmp != NULL;
+ tmp = tmp->get_next_cfg_key_val()) {
+ ctrlr_val = reinterpret_cast<val_vtn_flowfilter_ctrlr_t *>(GetVal(tmp));
+ if (!ctrlr_val) {
+ UPLL_LOG_DEBUG("Controller Value is empty");
+ tmp = NULL;
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ GET_USER_DATA_CTRLR(tmp, vtn_exist_on_ctrlr);
+ if (!strcmp(reinterpret_cast<char *>(vtn_exist_on_ctrlr),
+ reinterpret_cast<char *>(ctrlr_id)))
+ continue; // skipping entry of deleted controller
+
+ switch (ctrlr_val->cs_row_status) {
case UNC_CS_APPLIED:
+ applied = true;
+ break;
case UNC_CS_NOT_APPLIED:
+ not_applied = true;
+ break;
case UNC_CS_INVALID:
+ invalid = true;
+ break;
default:
- status =
- (cs_status == UNC_CS_APPLIED) ? UNC_CS_PARTAILLY_APPLIED : status;
- break;
+ UPLL_LOG_DEBUG("Invalid status");
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ // return UPLL_RC_ERR_GENERIC;
}
- /* TODO - determine how to set UNC_CS_NOT_SUPPORTED) */
- if (ctrlr_val_vtn_flowfilter->cs_row_status != UNC_CS_NOT_SUPPORTED)
- ctrlr_val_vtn_flowfilter->cs_row_status = cs_status;
- vtn_flowfilter_val->cs_row_status = status;
- /*
- for ( unsigned int loop = 0; loop < sizeof(vtn_flowfilter_val->valid)/sizeof(char); ++loop ) {
- if ( (UNC_VF_VALID == vtn_flowfilter_val->valid[loop]) ||
- (UNC_VF_VALID_NO_VALUE == vtn_flowfilter_val->valid[loop]))
- if (ctrlr_val_vtn_flowfilter->cs_attr[loop] != UNC_CS_NOT_SUPPORTED) {
- ctrlr_val_vtn_flowfilter->cs_attr[loop] = cs_status;
- vtn_flowfilter_val->cs_attr[loop] = (uint8_t)vtn_flowfilter_val->cs_row_status;
- }
- }*/
- } else if (op == UNC_OP_UPDATE) {
- if (ctrlr_val_vtn_flowfilter->cs_row_status != UNC_CS_NOT_SUPPORTED)
- ctrlr_val_vtn_flowfilter->cs_row_status = cs_status;
- vtn_flowfilter_val->cs_row_status = status;
-
- // for ( unsigned int loop = 0; loop < sizeof(vtn_flowfilter_val->valid)
- // /sizeof(char); ++loop ) {
- // if (ctrlr_val_vtn_flowfilter->cs_attr[loop] != UNC_CS_NOT_SUPPORTED)
- // if ( (UNC_VF_VALID == vtn_flowfilter_val->valid[loop]) ||
- // (UNC_VF_VALID_NO_VALUE == vtn_flowfilter_val->valid[loop]))
-#if 0
- if (CompareVal(vtn_val, nreq->GetVal(), loop)) {
-#endif
- // ctrlr_val_vtn_flowfilter->cs_attr[loop] = cs_status;
- // vtn_flowfilter_val->cs_attr[loop] = cs_status;
-#if 0
- }
-#endif
+ vtn_exist_on_ctrlr = NULL;
+ }
+ if (invalid) {
+ c_status = UNC_CS_INVALID;
+ } else if (applied && !not_applied) {
+ c_status = UNC_CS_APPLIED;
+ } else if (!applied && not_applied) {
+ c_status = UNC_CS_NOT_APPLIED;
+ } else if (applied && not_applied) {
+ c_status = UNC_CS_PARTIALLY_APPLIED;
+ } else {
+ c_status = UNC_CS_APPLIED;
+ }
+ // Set cs_status
+ val_flowfilter_t *vtnval = static_cast<val_flowfilter_t *>(GetVal(ikey));
+ vtnval->cs_row_status = c_status;
+ DbSubOp dbop_update = {kOpNotRead, kOpMatchNone, kOpInOutCs};
+ result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_UPDATE, dmi,
+ &dbop_update, MAINTBL);
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return result_code;
+}
+
+upll_rc_t VtnFlowFilterMoMgr::GetDiffRecord(ConfigKeyVal *ckv_running,
+ ConfigKeyVal *ckv_audit,
+ uuc::UpdateCtrlrPhase phase, MoMgrTables tbl,
+ ConfigKeyVal *&okey,
+ DalDmlIntf *dmi,
+ bool &invalid_attr) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ckv_dup = NULL;
+ okey = NULL;
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutCs};
+ switch (phase) {
+ case uuc::kUpllUcpDelete:
+ UPLL_LOG_TRACE("Deleted record is %s ",ckv_running->ToStrAll().c_str());
+ result_code = GetChildConfigKey(okey, ckv_running);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed. err_code & phase %d %d",
+ result_code, phase);
+ return result_code;
+ }
+ break;
+ case uuc::kUpllUcpCreate:
+ if (tbl == CTRLRTBL) {
+ UPLL_LOG_TRACE("Created record fot ctrlr_tbl is %s ",
+ ckv_running->ToStrAll().c_str());
+ result_code = GetChildConfigKey(okey, ckv_running);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed. err_code & phase %d %d",
+ result_code, phase);
+ return result_code;
+ }
+ result_code = ReadConfigDB(okey, UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed. err_code & phase %d %d",
+ result_code, phase);
+ return result_code;
+ }
+ } else {
+ UPLL_LOG_TRACE("Created record is %s ",ckv_running->ToStrAll().c_str());
+ result_code = DupConfigKeyVal(okey, ckv_running, tbl);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed. err_code & phase %d %d",
+ result_code, phase);
+ return result_code;
+ }
+ }
+ break;
+ case uuc::kUpllUcpUpdate:
+ if (tbl == CTRLRTBL) {
+ UPLL_LOG_TRACE("UpdateRecord record for Ctrlr_tbl is %s ",
+ ckv_running->ToStrAll().c_str());
+ UPLL_LOG_TRACE("UpdateRecord record for Ctrlr_tbl is %s ",
+ ckv_audit->ToStrAll().c_str());
+ result_code = GetChildConfigKey(okey, ckv_running);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey for running record failed. \
+ err_code & phase %d %d", result_code, phase);
+ return result_code;
+ }
+ result_code = ReadConfigDB(okey, UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ReadConfigDB from running failed. \
+ err_code & phase %d %d", result_code, phase);
+ return result_code;
+ }
+ result_code = GetChildConfigKey(ckv_dup, ckv_audit);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey for audit record failed. \
+ err_code & phase %d %d", result_code, phase);
+ return result_code;
+ }
+ result_code = ReadConfigDB(ckv_dup, UPLL_DT_AUDIT,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ReadConfigDB from audit failed. \
+ err_code & phase %d %d", result_code, phase);
+ return result_code;
+ }
+ } else {
+ UPLL_LOG_TRACE("UpdateRecord record is %s ",
+ ckv_running->ToStrAll().c_str());
+ UPLL_LOG_TRACE("UpdateRecord record is %s ",
+ ckv_audit->ToStrAll().c_str());
+ result_code = DupConfigKeyVal(okey, ckv_running, tbl);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed for running record. \
+ err_code & phase %d %d", result_code, phase);
+ return result_code;
+ }
+ result_code = DupConfigKeyVal(ckv_dup, ckv_audit, tbl);
+ if (!ckv_dup || result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed for audit record. \
+ err_code & phase %d %d", result_code, phase);
+ DELETE_IF_NOT_NULL(ckv_dup);
+ return result_code;
+ }
+ }
+ if (GetVal(okey) != NULL &&
+ GetVal(ckv_dup) != NULL) {
+ void *val1 = GetVal(okey);
+ invalid_attr = FilterAttributes(val1, GetVal(ckv_dup), true,
+ UNC_OP_UPDATE);
+ }
+ break;
+ default:
+ UPLL_LOG_DEBUG("Invalid operation %d", phase);
+ return UPLL_RC_ERR_NO_SUCH_OPERATION;
+ break;
}
- UPLL_LOG_DEBUG("UpdateConfigStatus is Successfull");
+ DELETE_IF_NOT_NULL(ckv_dup);
return result_code;
}
UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom.ctrlr,
ctrlr_dom.domain);
if (NULL == ctrlr_dom.ctrlr || NULL == ctrlr_dom.domain) {
- UPLL_LOG_INFO("Invalid controller/domain");
+ UPLL_LOG_DEBUG("Invalid controller/domain");
result_code = UPLL_RC_ERR_GENERIC;
- if (ck_main) delete ck_main;
+ DELETE_IF_NOT_NULL(ck_main);
break;
}
result_code = TxUpdateProcess(ck_main, &resp, op, dmi, &ctrlr_dom);
affected_ctrlr_set->insert((const char *)ctrlr_dom.ctrlr);
} else {
UPLL_LOG_DEBUG("TxUpdateProcess error %d", result_code);
+ upll_keytype_datatype_t dt_type = (UNC_OP_DELETE == op)?
+ UPLL_DT_RUNNING:UPLL_DT_CANDIDATE;
+ upll_rc_t local_rc = GetRenamedUncKey(resp.ckv_data, dt_type, dmi,
+ ctrlr_dom.ctrlr);
+ if (UPLL_RC_SUCCESS != local_rc &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != local_rc) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey failed %d", local_rc);
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(resp.ckv_data);
+ result_code = UPLL_RC_ERR_GENERIC;
+ break;
+ }
*err_ckv = resp.ckv_data;
- if (ck_main) delete ck_main;
+ DELETE_IF_NOT_NULL(ck_main);
break;
}
+ DELETE_IF_NOT_NULL(resp.ckv_data);
}
- if (ck_main) {
- delete ck_main;
- ck_main = NULL;
- }
+ DELETE_IF_NOT_NULL(ck_main);
}
- if (nreq)
- delete nreq;
- if (req)
- delete req;
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(req);
if (dal_cursor_handle) {
dmi->CloseCursor(dal_cursor_handle, true);
dal_cursor_handle = NULL;
dup_ckmain = NULL;
result_code = GetChildConfigKey(dup_ckmain, ck_main);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
if (dup_ckmain) delete dup_ckmain;
return result_code;
}
result_code = ReadConfigDB(dup_ckmain, UPLL_DT_CANDIDATE,
UNC_OP_READ, dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- string s(dup_ckmain->ToStrAll());
- UPLL_LOG_DEBUG("%s vtn flowfilter read failed from candidatedb (%d)",
- s.c_str(), result_code);
+ UPLL_LOG_TRACE("%s vtn flowfilter read failed from candidatedb (%d)",
+ dup_ckmain->ToStrAll().c_str(), result_code);
delete dup_ckmain;
return result_code;
}
}
/* Get renamed key if key is renamed */
- result_code = GetRenamedControllerKey(dup_ckmain, UPLL_DT_CANDIDATE,
+ if (op == UNC_OP_DELETE)
+ result_code = GetRenamedControllerKey(dup_ckmain, UPLL_DT_RUNNING,
+ dmi, ctrlr_dom);
+ else
+ result_code = GetRenamedControllerKey(dup_ckmain, UPLL_DT_CANDIDATE,
dmi, ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Failed to get the Renamed ControllerKey");
UPLL_LOG_DEBUG("controller disconnected error proceed with commit");
}
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("IpcSend failed %d\n", result_code);
+ UPLL_LOG_DEBUG("IpcSend failed %d", result_code);
}
if ((op == UNC_OP_CREATE) && dup_ckmain) {
delete dup_ckmain;
unc_keytype_operation_t op[] = { UNC_OP_DELETE, UNC_OP_CREATE };
int nop = sizeof(op) / sizeof(op[0]);
- ConfigKeyVal *vtn_flowfilter_key = NULL, *req = NULL, *nreq = NULL;
+ ConfigKeyVal *vtn_flowfilter_key = NULL, *req = NULL,
+ *nreq = NULL, *vtn_ck_run = NULL;
DalCursor *cfg1_cursor;
uint8_t *ctrlr_id =NULL;
map<string, int> ctrlr_result;
for (int i = 0; i < nop; i++) {
// Update the Main table
result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i],
- req, nreq, &cfg1_cursor, dmi, MAINTBL);
+ req, nreq, &cfg1_cursor, dmi,NULL, MAINTBL,true);
while (result_code == UPLL_RC_SUCCESS) {
db_result = dmi->GetNextRecord(cfg1_cursor);
result_code = DalToUpllResCode(db_result);
nreq, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Updating Main table Error %d", result_code);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
}
for (int i = 0; i < nop; i++) {
// Update the controller table
result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i], req,
- nreq, &cfg1_cursor, dmi, CTRLRTBL);
+ nreq, &cfg1_cursor, dmi, NULL, CTRLRTBL, true);
ConfigKeyVal *vtn_ff_ctrlr_key = NULL;
while (result_code == UPLL_RC_SUCCESS) {
db_result = dmi->GetNextRecord(cfg1_cursor);
break;
}
if (op[i] == UNC_OP_CREATE) {
- DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag };
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag
+ | kOpInOutCs };
result_code = GetChildConfigKey(vtn_flowfilter_key, req);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
result_code);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
- result_code = ReadConfigDB(vtn_flowfilter_key, UPLL_DT_CANDIDATE,
+ result_code = ReadConfigDB(vtn_flowfilter_key, UPLL_DT_RUNNING,
UNC_OP_READ, dbop, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
UPLL_LOG_DEBUG("Unable to read configuration from CandidateDb");
- delete vtn_flowfilter_key;
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(vtn_flowfilter_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
- result_code = DupConfigKeyVal(vtn_ff_ctrlr_key, req, CTRLRTBL);
+ result_code = CopyVtnFlowFilterControllerCkv(req, vtn_ff_ctrlr_key);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Failed to create duplicate ConfigKeyVal Err (%d)",
result_code);
- delete vtn_flowfilter_key;
+ DELETE_IF_NOT_NULL(vtn_flowfilter_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
+
+ // set consolidated config status to UNKNOWN to init vtn cs_status
+ // to the cs_status of first controller
+ uint32_t cur_instance_count;
+ result_code = GetInstanceCount(vtn_flowfilter_key, NULL,
+ UPLL_DT_CANDIDATE, &cur_instance_count,
+ dmi, CTRLRTBL);
+ if ((result_code == UPLL_RC_SUCCESS) && (cur_instance_count == 1))
+ reinterpret_cast<val_flowfilter *>(GetVal(vtn_flowfilter_key))->\
+ cs_row_status = UNC_CS_UNKNOWN ;
GET_USER_DATA_CTRLR(vtn_ff_ctrlr_key, ctrlr_id);
+
string controller(reinterpret_cast<char *> (ctrlr_id));
+
result_code = UpdateConfigStatus(vtn_flowfilter_key, op[i],
- ctrlr_result[controller], NULL,
+ ctrlr_result[controller], nreq,
dmi, vtn_ff_ctrlr_key);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Error in updating configstatus, resultcode=%d",
result_code);
- delete vtn_flowfilter_key;
+ DELETE_IF_NOT_NULL(vtn_flowfilter_key);
+ DELETE_IF_NOT_NULL(vtn_ff_ctrlr_key);
return result_code;
}
} else if (op[i] == UNC_OP_DELETE) {
+ // Reading Main Running DB for delete op
+ DbSubOp dbop1 = { kOpReadSingle, kOpMatchNone, kOpInOutFlag
+ | kOpInOutCs };
+ result_code = GetChildConfigKey(vtn_ck_run, req);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
+ result_code);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+ result_code = ReadConfigDB(vtn_ck_run, UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop1, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE ) {
+ UPLL_LOG_DEBUG("Unable to read configuration from CandidateDb");
+ DELETE_IF_NOT_NULL(vtn_ck_run);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+ if (result_code == UPLL_RC_SUCCESS) {
+ result_code = SetVtnFFConsolidatedStatus(vtn_ck_run, ctrlr_id, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Could not set consolidated status %d",
+ result_code);
+ DELETE_IF_NOT_NULL(vtn_ck_run);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+ }
+ DELETE_IF_NOT_NULL(vtn_ck_run);
result_code = GetChildConfigKey(vtn_ff_ctrlr_key, req);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Error in getting the configkey, resultcode=%d",
result_code);
+ DELETE_IF_NOT_NULL(vtn_ck_run);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
}
op[i], dmi, CTRLRTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("DB Error while updating controller table. err code:%d",
- result_code);
- delete vtn_ff_ctrlr_key;
+ result_code);
+ DELETE_IF_NOT_NULL(vtn_ff_ctrlr_key);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
// update the consolidated config status in the Main Table
if (op[i] != UNC_OP_DELETE) {
result_code = UpdateConfigDB(vtn_flowfilter_key, UPLL_DT_RUNNING,
UNC_OP_UPDATE, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS)
- return result_code;
- }
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ DELETE_IF_NOT_NULL(vtn_ck_run);
+ DELETE_IF_NOT_NULL(vtn_flowfilter_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ return result_code;
+ }
+ }
EnqueCfgNotification(op[i], UPLL_DT_RUNNING, vtn_ff_ctrlr_key);
- if (vtn_flowfilter_key)
- delete vtn_flowfilter_key;
+ DELETE_IF_NOT_NULL(vtn_flowfilter_key);
+ DELETE_IF_NOT_NULL(vtn_ff_ctrlr_key);
vtn_flowfilter_key = vtn_ff_ctrlr_key = NULL;
result_code = DalToUpllResCode(db_result);
}
break;
case CTRLRTBL:
val = reinterpret_cast<void *>
- (ConfigKeyVal::Malloc(sizeof(val_flowfilter_controller_t)));
- ck_val = new ConfigVal(IpctSt::kIpcStValFlowfilterController, val);
+ (ConfigKeyVal::Malloc(sizeof(val_vtn_flowfilter_ctrlr_t)));
+ ck_val = new ConfigVal(IpctSt::kIpcInvalidStNum, val);
break;
default:
MoMgrTables tbl ) {
/* Main Table only update */
UPLL_FUNC_TRACE;
- nattr = NUM_KEY_MAIN_TBL_;
if (MAINTBL == tbl) {
+ nattr = sizeof(vtn_flowfilter_maintbl_rename_bindinfo)/
+ sizeof(vtn_flowfilter_maintbl_rename_bindinfo[0]);
bindinfo = vtn_flowfilter_maintbl_rename_bindinfo;
} else if (CTRLRTBL ==tbl) {
+ nattr = sizeof(vtn_flowfilter_ctrlrtbl_rename_bindinfo)/
+ sizeof(vtn_flowfilter_ctrlrtbl_rename_bindinfo[0]);
bindinfo = vtn_flowfilter_ctrlrtbl_rename_bindinfo;
}
UPLL_LOG_DEBUG("Successful Completeion");
uuu::upll_strncpy(key_vtn->vtn_key.vtn_name,
key_rename->old_unc_vtn_name, (kMaxLenVtnName + 1));
-#if 0
- if (ikey->get_key_type() == table[MAINTBL]->get_key_type()) {
- if (!strlen(reinterpret_cast<char *> (key_rename->old_unc_vnode_name)))
- return UPLL_RC_ERR_GENERIC;
- strncpy(reinterpret_cast<char*>(key_vrt_if->flowfilter_key.if_key.vrt_key.\
- vrouter_name),
- reinterpret_cast<char *> (key_rename->old_unc_vnode_name), 32);
- }
-#endif
+ key_vtn->input_direction = 0xFE;
+
okey = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER, IpctSt::
kIpcStKeyVtnFlowfilter, key_vtn, NULL);
if (!okey)
UPLL_LOG_DEBUG(" invalid option2(%d)", req->option2);
return UPLL_RC_ERR_INVALID_OPTION2;
}
+ if ((req->datatype == UPLL_DT_IMPORT) && (req->operation == UNC_OP_READ ||
+ req->operation == UNC_OP_READ_SIBLING ||
+ req->operation == UNC_OP_READ_SIBLING_BEGIN ||
+ req->operation == UNC_OP_READ_NEXT ||
+ req->operation == UNC_OP_READ_BULK ||
+ req->operation == UNC_OP_READ_SIBLING_COUNT)) {
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+
key_vtn_flowfilter_t *key_vtn_ff = NULL;
ConfigKeyVal *ikey,
const char* ctrlr_name) {
UPLL_FUNC_TRACE;
- // TODO(Author) added to bypass capability check
- return UPLL_RC_SUCCESS;
- // endTODO
- upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
-
if ((NULL == req) || (NULL == ikey)) {
UPLL_LOG_DEBUG("IpcReqRespHeader/ConfigKeyval is NULL");
- return result_code;
+ return UPLL_RC_ERR_GENERIC;
}
+ if (!ctrlr_name)
+ ctrlr_name = static_cast<char *>(ikey->get_user_data());
+
if (!ctrlr_name) {
UPLL_LOG_DEBUG(" Controller name is NULL ");
return UPLL_RC_ERR_GENERIC;
}
- uint32_t dt_type = req->datatype;
- uint32_t operation = req->operation;
- uint32_t option1 = req->option1;
- uint32_t option2 = req->option2;
-
- UPLL_LOG_TRACE("Controller - %s"
- "dt_type: (%d) "
- "operation: (%d) "
- "option1: (%d) "
- "option2: (%d) ",
- ctrlr_name, dt_type, operation, option1, option2);
-
bool ret_code = false;
- uint32_t instance_count = 0;
+ uint32_t max_instance_count = 0;
const uint8_t *attrs = NULL;
uint32_t max_attrs = 0;
- switch (operation) {
+ switch (req->operation) {
case UNC_OP_CREATE: {
ret_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
- &instance_count, &max_attrs, &attrs);
- break;
- }
- case UNC_OP_UPDATE: {
- ret_code = GetUpdateCapability(ctrlr_name, ikey->get_key_type(),
- &max_attrs, &attrs);
+ &max_instance_count, &max_attrs, &attrs);
+ if (ret_code && (max_instance_count != 0) &&
+ (cur_instance_count >= max_instance_count)) {
+ UPLL_LOG_DEBUG("Instance count %d exceeds %d", cur_instance_count,
+ max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
break;
}
default: {
- ret_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ if (req->datatype == UPLL_DT_STATE)
+ ret_code = GetStateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ else
+ ret_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
&max_attrs, &attrs);
}
break;
}
- UPLL_LOG_DEBUG(" ret_code (%d)", ret_code);
if (!ret_code) {
UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s) "
"for opearion(%d)",
- ikey->get_key_type(), ctrlr_name, operation);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ ikey->get_key_type(), ctrlr_name, req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
return UPLL_RC_SUCCESS;
}
upll_rc_t VtnFlowFilterMoMgr::GetVtnControllerSpan(
ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
std::list<controller_domain_t> &list_ctrlr_dom) {
UPLL_FUNC_TRACE;
uuu::upll_strncpy(vtn_key->vtn_name,
flowfilter_key->vtn_key.vtn_name,
(kMaxLenVtnName+1));
- result_code = mgr->GetControllerDomainSpan(okey, UPLL_DT_CANDIDATE,
+ result_code = mgr->GetControllerDomainSpan(okey, dt_type,
dmi,
list_ctrlr_dom);
if ((result_code != UPLL_RC_SUCCESS) &&
case UNC_OP_CREATE:
result_code = DupConfigKeyVal(ck_vtn_ff, vtn_ff_key, MAINTBL);
if (!ck_vtn_ff || (result_code != UPLL_RC_SUCCESS)) {
- UPLL_LOG_DEBUG("DupConfigKeyVal() Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("DupConfigKeyVal() Returning error %d", result_code);
return result_code;
}
val_ff = reinterpret_cast<val_flowfilter_t *>(GetVal(ck_vtn_ff));
if (!val_ff) {
- UPLL_LOG_DEBUG("invalid val \n");
+ UPLL_LOG_DEBUG("invalid val");
return UPLL_RC_ERR_GENERIC;
}
- val_ff->cs_row_status = UNC_CS_NOT_APPLIED;
+ val_ff->cs_row_status = UNC_CS_APPLIED;
break;
case UNC_OP_DELETE:
}
break;
default:
- UPLL_LOG_DEBUG("Inalid operation\n");
+ UPLL_LOG_DEBUG("Inalid operation");
return UPLL_RC_ERR_GENERIC;
}
-
- result_code = UpdateConfigDB(ck_vtn_ff, UPLL_DT_STATE, op, dmi, MAINTBL);
+ DbSubOp dbop = {kOpNotRead, kOpMatchNone, kOpInOutNone};
+ dbop.inoutop = kOpInOutCs | kOpInOutFlag;
+ result_code = UpdateConfigDB(ck_vtn_ff, UPLL_DT_STATE, op, dmi, &dbop,
+ MAINTBL);
EnqueCfgNotification(op, UPLL_DT_RUNNING, vtn_ff_key);
delete ck_vtn_ff;
return result_code;
}
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("VtnFlowfilterentry delete failed %d", result_code);
+ DELETE_IF_NOT_NULL(vtn_ffe_ckv);
return result_code;
}
DbSubOp dbop = {kOpNotRead, kOpMatchNone, kOpInOutNone};
// UPLL_RC_SUCCESS:result_code;
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_ERROR("Delete Operation fails with %d", result_code);
+ DELETE_IF_NOT_NULL(vtn_ffe_ckv);
return result_code;
}
result_code = UpdateConfigDB(ikey, UPLL_DT_CANDIDATE,
result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
UPLL_RC_SUCCESS:result_code;
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_ERROR("Delete Operation fails with %d", result_code);
+ UPLL_LOG_ERROR("Delete Operation fails with %d", result_code);
+ DELETE_IF_NOT_NULL(vtn_ffe_ckv);
return result_code;
}
+
+ DELETE_IF_NOT_NULL(vtn_ffe_ckv);
return UPLL_RC_SUCCESS;
}
UPLL_LOG_DEBUG(" Input Key is NULL");
return UPLL_RC_ERR_GENERIC;
}
-
+ DELETE_IF_NOT_NULL(okey);
unc_key_type_t ikey_type = ikey->get_key_type();
if (ikey_type != UNC_KT_VTN_FLOWFILTER) {
UPLL_LOG_DEBUG(" Invalid key type received. Key type - %d", ikey_type);
SET_USER_DATA(okey, ikey);
return UPLL_RC_SUCCESS;
}
+
+upll_rc_t VtnFlowFilterMoMgr::DeleteChildrenPOM(
+ ConfigKeyVal *ikey, upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+
+ if (NULL == ikey || NULL == dmi) {
+ UPLL_LOG_DEBUG("Delete Operation failed:Bad request");
+ return result_code;
+ }
+ // Read the DB get the flowlist value and send the delete request to
+ // flowlist momgr if flowlist is configured.
+
+ ConfigKeyVal *tempckv = NULL;
+ result_code = GetChildConfigKey(tempckv, ikey);
+ if (!tempckv || UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(tempckv);
+ return result_code;
+ }
+ ConfigKeyVal *temp_ikey = NULL;
+ result_code = GetChildConfigKey(temp_ikey, ikey);
+ if (!temp_ikey || UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed");
+ DELETE_IF_NOT_NULL(tempckv);
+ DELETE_IF_NOT_NULL(temp_ikey);
+ return result_code;
+ }
+ result_code = UpdateConfigDB(temp_ikey, dt_type, UNC_OP_DELETE, dmi,
+ MAINTBL);
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
+ UPLL_LOG_DEBUG("DeleteMo record Err in vtnpolicingmaptbl (%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(temp_ikey);
+ DELETE_IF_NOT_NULL(tempckv);
+ return result_code;
+ }
+ ConfigKeyVal *ctrlr_ikey = NULL;
+ result_code = GetChildConfigKey(ctrlr_ikey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed");
+ DELETE_IF_NOT_NULL(temp_ikey);
+ return result_code;
+ }
+ DbSubOp dbop = {kOpNotRead, kOpMatchNone, kOpInOutNone};
+ result_code = UpdateConfigDB(ctrlr_ikey, dt_type, UNC_OP_DELETE, dmi,
+ &dbop, CTRLRTBL);
+ UPLL_LOG_DEBUG("UpdateConfigDB failed for ctrlrtbl %d", result_code);
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
+ UPLL_LOG_DEBUG("DeleteMo record Err in vtnpolicingmaptbl (%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(temp_ikey);
+ return result_code;
+ }
+ if (tempckv)
+ delete tempckv;
+ tempckv = NULL;
+ if (temp_ikey)
+ delete temp_ikey;
+ temp_ikey = NULL;
+ if (ctrlr_ikey)
+ delete ctrlr_ikey;
+ ctrlr_ikey = NULL;
+
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtnFlowFilterMoMgr::SetValidAudit(ConfigKeyVal *&ikey) {
+ UPLL_FUNC_TRACE;
+ val_flowfilter_t *val = reinterpret_cast<val_flowfilter_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_flowfilter_t)));
+ val->cs_row_status = UNC_CS_APPLIED;
+ ikey->AppendCfgVal(IpctSt::kIpcStValFlowfilter, val);
+ return UPLL_RC_SUCCESS;
+}
+
+bool VtnFlowFilterMoMgr::FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op) {
+ UPLL_FUNC_TRACE;
+ if (op != UNC_OP_CREATE)
+ return true;
+ return false;
+}
+
+upll_rc_t VtnFlowFilterMoMgr::CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_TRACE(" ikey is %s", ikey->ToStrAll().c_str());
+ uint8_t *controller_id = reinterpret_cast<uint8_t *>(
+ const_cast<char *>(ctrlr_id));
+
+ /* check if object is renamed in the corresponding Rename Tbl
+ * if "renamed" create the object by the UNC name.
+ * else - create using the controller name.
+ */
+ result_code = GetRenamedUncKey(ikey, UPLL_DT_RUNNING, dmi, controller_id);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey Failed err_code %d", result_code);
+ return result_code;
+ }
+ UPLL_LOG_TRACE("ikey After GetRenamedUncKey %s", ikey->ToStrAll().c_str());
+
+ result_code = SetValidAudit(ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ return result_code;
+ }
+ // Create a record in AUDIT DB
+ DbSubOp dbop1 = { kOpReadExist, kOpMatchNone, kOpInOutNone };
+
+ result_code = UpdateConfigDB(ikey, UPLL_DT_AUDIT, UNC_OP_READ,
+ dmi, &dbop1, MAINTBL);
+ if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Update record Err in vtnff MainTbl(%d)",
+ result_code);
+ return result_code;
+ }
+
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ result_code = UpdateConfigDB(ikey, UPLL_DT_AUDIT, UNC_OP_CREATE, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigDB Failed err_code %d", result_code);
+ return result_code;
+ }
+ }
+
+ std::list<controller_domain_t> list_ctrlr_dom;
+ upll_rc_t vtn_ctrlr_span_rt_code = GetVtnControllerSpan(ikey, UPLL_DT_AUDIT, dmi, list_ctrlr_dom);
+ if ((vtn_ctrlr_span_rt_code != UPLL_RC_SUCCESS) &&
+ (vtn_ctrlr_span_rt_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG(" GetVtnControllerSpan error code (%d)",
+ vtn_ctrlr_span_rt_code);
+ for (std::list<controller_domain_t>::iterator it= list_ctrlr_dom.begin();
+ it != list_ctrlr_dom.end(); ++it) {
+ free(it->ctrlr);
+ free(it->domain);
+ }
+ return vtn_ctrlr_span_rt_code;
+ }
+
+ // create a record in CANDIDATE DB for controller Table
+ if (vtn_ctrlr_span_rt_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ result_code = UpdateControllerTable(ikey, UNC_OP_CREATE,
+ UPLL_DT_AUDIT, dmi,
+ list_ctrlr_dom);
+
+ }
+ for (std::list<controller_domain_t>::iterator it= list_ctrlr_dom.begin();
+ it != list_ctrlr_dom.end(); ++it) {
+ free(it->ctrlr);
+ free(it->domain);
+ }
+
+ return result_code;
+}
+
+upll_rc_t VtnFlowFilterMoMgr::CopyVtnFlowFilterControllerCkv(ConfigKeyVal *ikey,
+ ConfigKeyVal *&okey) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+ // controller_domain ctrlr_dom;
+ key_vtn_flowfilter_t *key_tmp =
+ reinterpret_cast<key_vtn_flowfilter_t *>(ikey->get_key());
+ if (!key_tmp)
+ return result_code;
+
+ key_vtn_flowfilter_t *vtn_flowfilterkey =
+ reinterpret_cast<key_vtn_flowfilter_t*>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn_flowfilter_t)));
+ memcpy(vtn_flowfilterkey, key_tmp, sizeof(key_vtn_flowfilter_t));
+
+ ConfigVal *tmp1 = NULL;
+ val_vtn_flowfilter_ctrlr_t *ival = reinterpret_cast<val_vtn_flowfilter_ctrlr_t *>
+ (GetVal(ikey));
+ if (!ival)
+ return UPLL_RC_SUCCESS;
+
+ val_vtn_flowfilter_ctrlr_t *val_tmp = reinterpret_cast<val_vtn_flowfilter_ctrlr_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtn_flowfilter_ctrlr_t)));
+
+ memcpy(val_tmp, ival, sizeof(val_vtn_flowfilter_ctrlr_t));
+ tmp1 = new ConfigVal(IpctSt::kIpcInvalidStNum, val_tmp);
+
+ okey = new ConfigKeyVal(UNC_KT_VTN_FLOWFILTER, IpctSt::kIpcStKeyVtnFlowfilter,
+ vtn_flowfilterkey, tmp1);
+ SET_USER_DATA(okey, ikey);
+
+ return UPLL_RC_SUCCESS;
+}
+
+
} // namespace kt_momgr
} // namespace upll
} // namespace unc
class VtnFlowFilterMoMgr : public MoMgrImpl {
private:
+ uint32_t cur_instance_count;
static unc_key_type_t vtn_flowfilter_child[];
static BindInfo vtn_flowfilter_bind_info[];
static BindInfo vtn_flowfilter_ctrl_bind_info[];
upll_rc_t MergeValidate(unc_key_type_t keytype, const char *ctrlr_id,
ConfigKeyVal *ikey, DalDmlIntf *dmi);
+ upll_rc_t MergeImportToCandidate(unc_key_type_t keytype,
+ const char *ctrlr_name,
+ DalDmlIntf *dmi);
/**
* @brief This API is used to create the record in candidate
* configuration
* @retval UPLL_RC_ERR_DB_ACCESS DB access error
*/
- upll_rc_t GetRenamedControllerKey(ConfigKeyVal *&ikey,
+ upll_rc_t GetRenamedControllerKey(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
controller_domain *ctrlr_dom = NULL);
uint8_t* vtn_name,
controller_domain *ctrlr_dom,
unc_keytype_operation_t op,
- DalDmlIntf *dmi);
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi,
+ uint8_t flag);
upll_rc_t UpdateControllerTable(
ConfigKeyVal *ikey,
upll_rc_t GetVtnControllerSpan(
ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi,
std::list<controller_domain_t> &list_ctrlr_dom);
upll_rc_t DeleteMo(IpcReqRespHeader *req, ConfigKeyVal *ikey,
DalDmlIntf *dmi);
+
+ upll_rc_t GetDiffRecord(ConfigKeyVal *ckv_running,
+ ConfigKeyVal *ckv_audit,
+ uuc::UpdateCtrlrPhase phase, MoMgrTables tbl,
+ ConfigKeyVal *&ckv_driver_req,
+ DalDmlIntf *dmi,
+ bool &invalid_attr);
+
+ upll_rc_t DeleteChildrenPOM(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi);
+ upll_rc_t SetVtnFFConsolidatedStatus(ConfigKeyVal *ikey,
+ uint8_t *ctrlr_id,
+ DalDmlIntf *dmi);
+ upll_rc_t SetValidAudit(ConfigKeyVal *&ikey);
+
+ bool FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op);
+
+ upll_rc_t CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id);
+
+ upll_rc_t SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req);
+
+ upll_rc_t CopyVtnFlowFilterControllerCkv(ConfigKeyVal *ikey,
+ ConfigKeyVal *&okey);
};
typedef struct val_vtn_flowfilter_ctrlr {
#include "vtn_momgr.hh"
#include "vbr_if_momgr.hh"
+#include "vnode_momgr.hh"
+#include "vlink_momgr.hh"
+
#define NUM_KEY_COL 3
using unc::upll::ipc_util::IpcUtil;
{ uudst::vtn_controller::kDbiDomainId, CK_VAL, offsetof(key_user_data_t,
domain_id),
uud::kDalChar, 32 },
- { uudst::vtn_controller::kDbiOperStatus, CFG_VAL, offsetof(val_vtn_ctrlr,
+ { uudst::vtn_controller::kDbiOperStatus, CFG_ST_VAL, offsetof(val_vtn_ctrlr,
oper_status),
uud::kDalUint8, 1 },
- { uudst::vtn_controller::kDbiAlarmStatus, CFG_VAL, offsetof(val_vtn_ctrlr,
- alarm_status),
+ { uudst::vtn_controller::kDbiAlarmStatus, CFG_ST_VAL,
+ offsetof(val_vtn_ctrlr, alarm_status),
uud::kDalUint8, 1 },
- { uudst::vtn_controller::kDbiDownCount, CFG_VAL, offsetof(val_vtn_ctrlr,
+ { uudst::vtn_controller::kDbiDownCount, CFG_ST_VAL, offsetof(val_vtn_ctrlr,
down_count),
uud::kDalUint32, 1 },
{ uudst::vtn_controller::kDbiRefCount, CFG_VAL, offsetof(val_vtn_ctrlr,
ref_count), uud::kDalUint32, 1 },
- { uudst::vtn_controller::kDbiValidOperStatus, CFG_META_VAL,
+ { uudst::vtn_controller::kDbiValidOperStatus, CFG_ST_META_VAL,
offsetof(val_vtn_ctrlr, valid[0]),
uud::kDalUint8, 1 },
- { uudst::vtn_controller::kDbiValidAlarmStatus, CFG_META_VAL, offsetof(
+ { uudst::vtn_controller::kDbiValidAlarmStatus, CFG_ST_META_VAL, offsetof(
val_vtn_ctrlr, valid[1]),
uud::kDalUint8, 1 },
{ uudst::vtn_controller::kDbiCsDesc, CS_VAL, offsetof(val_vtn_ctrlr,
new_unc_vtn_name),
uud::kDalChar, kMaxLenVtnName + 1 },
{ uudst::vtn::kDbiVtnFlags, CK_VAL, offsetof(key_user_data_t, flags),
- uud::kDalUint8, 1 }
+ uud::kDalUint8, 1 }
};
BindInfo VtnMoMgr::key_vtn_ctrlrtbl_bind_info[] = {
key_rename_vnode_info_t, new_unc_vtn_name),
uud::kDalChar, kMaxLenVtnName + 1 }, };
-unc_key_type_t VtnMoMgr::vtn_child[] = { UNC_KT_VBRIDGE, UNC_KT_VROUTER,
- UNC_KT_VUNKNOWN, UNC_KT_VLINK,
+unc_key_type_t VtnMoMgr::vtn_child[] = { UNC_KT_VLINK, UNC_KT_VBRIDGE,
+ UNC_KT_VROUTER, UNC_KT_VUNKNOWN,
+ UNC_KT_VTEP_GRP,
+ UNC_KT_VTEP, UNC_KT_VTUNNEL,
UNC_KT_VTN_FLOWFILTER,
UNC_KT_VTN_POLICINGMAP };
VtnMoMgr::VtnMoMgr() : MoMgrImpl() {
MoMgrTables tbl) {
UPLL_FUNC_TRACE;
nattr = NUM_KEY_COL;
- if (MAINTBL == tbl)
+ if (MAINTBL == tbl)
binfo = key_vtn_maintbl_bind_info;
- if (CTRLRTBL == tbl)
+ if (CTRLRTBL == tbl)
binfo = key_vtn_ctrlrtbl_bind_info;
- if (RENAMETBL == tbl){
+ if (RENAMETBL == tbl) {
nattr = 2;
binfo = key_vtn_renametbl_bind_info;
}
bool VtnMoMgr::IsValidKey(void *key,
uint64_t index) {
+ UPLL_FUNC_TRACE;
key_vtn *vtn_key = reinterpret_cast<key_vtn *>(key);
- UPLL_LOG_TRACE("Entering IsValidKey");
- bool ret_val = UPLL_RC_SUCCESS;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
ret_val = ValidateKey(reinterpret_cast<char *>(vtn_key->vtn_name),
kMinLenVtnName, kMaxLenVtnName);
UPLL_LOG_TRACE("VTN Name is not valid(%d)", ret_val);
return false;
}
- UPLL_LOG_TRACE("Leaving IsValidKey");
return true;
}
return UPLL_RC_ERR_GENERIC;
}
} else if (tbl == RENAMETBL) {
- switch(indx) {
+ switch (indx) {
case uudst::vtn_rename::kDbiCtrlrVtnName:
valid = &(reinterpret_cast<val_rename_vtn *>
(val))->valid[UPLL_IDX_NEW_NAME_RVTN];
if (ck_val != NULL) return UPLL_RC_ERR_GENERIC;
switch (tbl) {
case MAINTBL:
- val = reinterpret_cast<void *>(malloc(sizeof(val_vtn)));
- if (!val) {
- UPLL_LOG_ERROR("val Memory Allocation failed");
- return UPLL_RC_ERR_GENERIC;
- }
- memset(val, 0, sizeof(val_vtn));
+ val = ConfigKeyVal::Malloc(sizeof(val_vtn));
ck_val = new ConfigVal(IpctSt::kIpcStValVtn, val);
if (dt_type == UPLL_DT_STATE) {
- val = reinterpret_cast<void *>(malloc(sizeof(val_db_vtn_st)));
- if (!val) {
- DELETE_IF_NOT_NULL(ck_val);
- UPLL_LOG_ERROR("val Memory Allocation failed");
- return UPLL_RC_ERR_GENERIC;
- }
- memset(val, 0, sizeof(val_db_vtn_st));
+ val = ConfigKeyVal::Malloc(sizeof(val_db_vtn_st));
ConfigVal *ck_nxtval = new ConfigVal(IpctSt::kIpcStValVtnSt, val);
ck_val->AppendCfgVal(ck_nxtval);
}
break;
case RENAMETBL:
- val = reinterpret_cast<void *>(malloc(sizeof(val_rename_vtn)));
- if (!val) {
- UPLL_LOG_ERROR("val Memory Allocation failed");
- return UPLL_RC_ERR_GENERIC;
- }
- memset(val, 0, sizeof(val_rename_vtn));
+ val = ConfigKeyVal::Malloc(sizeof(val_rename_vtn));
ck_val = new ConfigVal(IpctSt::kIpcStValRenameVtn, val);
break;
case CTRLRTBL:
- val = reinterpret_cast<void *>(malloc(sizeof(val_vtn_ctrlr)));
- if (!val) {
- UPLL_LOG_ERROR("val Memory Allocation failed");
- return UPLL_RC_ERR_GENERIC;
- }
- memset(val, 0, sizeof(val_vtn_ctrlr));
+ val = ConfigKeyVal::Malloc(sizeof(val_vtn_ctrlr));
ck_val = new ConfigVal(IpctSt::kIpcInvalidStNum, val);
break;
default:
return UPLL_RC_SUCCESS;
}
+upll_rc_t VtnMoMgr::DupConfigKeyValVtnMapping(ConfigKeyVal *&okey,
+ ConfigKeyVal *req) {
+ UPLL_FUNC_TRACE;
+ void *tkey = req ? (req)->get_key() : NULL;
+ if (tkey == NULL) {
+ UPLL_LOG_INFO("Input Configkeyval or key is Null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (okey != NULL) {
+ UPLL_LOG_INFO("okey is Not Null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigVal *tmp1 = NULL, *tmp = (req)->get_cfg_val();
+ val_vtn_mapping_controller_st_t *vtn_map = NULL;
+ if (tmp) {
+ val_vtn_mapping_controller_st_t *ival =
+ reinterpret_cast<val_vtn_mapping_controller_st_t *>(GetVal(req));
+ vtn_map = reinterpret_cast<val_vtn_mapping_controller_st_t *>(
+ ConfigKeyVal::Malloc(sizeof(val_vtn_mapping_controller_st_t)));
+ memcpy(reinterpret_cast<char *>(vtn_map), reinterpret_cast<char *>(ival),
+ sizeof(val_vtn_mapping_controller_st_t));
+ tmp1 = new ConfigVal(IpctSt::kIpcStValVtnMappingControllerSt, vtn_map);
+ }
+ key_vtn_controller *ikey = reinterpret_cast<key_vtn_controller *>(tkey);
+ key_vtn_controller *key = reinterpret_cast<key_vtn_controller *>(
+ ConfigKeyVal::Malloc(sizeof(key_vtn_controller)));
+ memcpy(reinterpret_cast<char *>(key), reinterpret_cast<char *>(ikey),
+ sizeof(key_vtn_controller));
+ okey = new ConfigKeyVal(UNC_KT_VTN_MAPPING_CONTROLLER,
+ IpctSt::kIpcStKeyVtnController, key, tmp1);
+ SET_USER_DATA(okey, req)
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtnMoMgr::DupConfigKeyValVtnStation(ConfigKeyVal *&okey,
+ ConfigKeyVal *req) {
+ UPLL_FUNC_TRACE;
+ void *tkey = req ? (req)->get_key() : NULL;
+ if (tkey == NULL) {
+ UPLL_LOG_INFO("Input Configkeyval or key is Null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (okey != NULL) {
+ UPLL_LOG_INFO("okey is Not Null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigVal *tmp1 = NULL, *tmp = req->get_cfg_val();
+ val_vtnstation_controller_st *vtnstation = NULL;
+ void *val_nxt = NULL;
+ for (; tmp ; tmp = tmp->get_next_cfg_val()) {
+ if (tmp->get_st_num() == IpctSt::kIpcStValVtnstationControllerSt) {
+ val_vtnstation_controller_st *ival =
+ reinterpret_cast<val_vtnstation_controller_st *>(GetVal(req));
+ vtnstation = reinterpret_cast<val_vtnstation_controller_st *>(
+ ConfigKeyVal::Malloc(sizeof(val_vtnstation_controller_st)));
+ memcpy(reinterpret_cast<char *>(vtnstation), reinterpret_cast<char *>
+ (ival), sizeof(val_vtnstation_controller_st));
+ if (!tmp1)
+ tmp1 = new ConfigVal(IpctSt::kIpcStValVtnstationControllerSt, vtnstation);
+ } else if (tmp->get_st_num() == IpctSt::kIpcStIpv4) {
+ val_nxt = reinterpret_cast<struct in_addr *>
+ (ConfigKeyVal::Malloc(sizeof(struct in_addr)));
+ memcpy(val_nxt, reinterpret_cast<struct in_addr *>(tmp->get_val()),
+ sizeof(struct in_addr));
+ if (!tmp1) {
+ UPLL_LOG_ERROR("val_vtnstation_controller_st is Null");
+ ConfigKeyVal::Free(val_nxt);
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ tmp1->AppendCfgVal(new ConfigVal(IpctSt::kIpcStIpv4, val_nxt));
+ } else if (tmp->get_st_num() == IpctSt::kIpcStIpv6) {
+ val_nxt = reinterpret_cast<struct in6_addr* >
+ (ConfigKeyVal::Malloc(sizeof(struct in6_addr)));
+ memcpy(val_nxt, reinterpret_cast<struct in6_addr *>(tmp->get_val()),
+ sizeof(struct in6_addr));
+ if (!tmp1) {
+ UPLL_LOG_ERROR("val_vtnstation_controller_st is Null");
+ ConfigKeyVal::Free(val_nxt);
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ tmp1->AppendCfgVal(new ConfigVal(IpctSt::kIpcStIpv6, val_nxt));
+ }
+ }
+ key_vtnstation_controller *ikey =
+ reinterpret_cast<key_vtnstation_controller *>(tkey);
+ key_vtnstation_controller *key =
+ reinterpret_cast<key_vtnstation_controller *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtnstation_controller)));
+ memcpy(reinterpret_cast<char *>(key), reinterpret_cast<char *>(ikey),
+ sizeof(key_vtnstation_controller));
+ okey = new ConfigKeyVal(UNC_KT_VTNSTATION_CONTROLLER,
+ IpctSt::kIpcStKeyVtnstationController, key, tmp1);
+ return UPLL_RC_SUCCESS;
+}
+
upll_rc_t VtnMoMgr::DupConfigKeyVal(ConfigKeyVal *&okey,
ConfigKeyVal *&req,
MoMgrTables tbl) {
FREE_IF_NOT_NULL(ctrlr_val);
return UPLL_RC_ERR_GENERIC;
}
- //error user data nneds to be copied
+ // error user data nneds to be copied
SET_USER_DATA(tmp1, tmp)
tmp = tmp->get_next_cfg_val();
};
val_db_vtn_st *ival = reinterpret_cast<val_db_vtn_st *>(tmp->get_val());
val_db_vtn_st *val_vtn = reinterpret_cast<val_db_vtn_st *>(
ConfigKeyVal::Malloc(sizeof(val_db_vtn_st)));
- memset(reinterpret_cast<void *>(val_vtn),0,sizeof(val_db_vtn_st));
+ memset(reinterpret_cast<void *>(val_vtn), 0, sizeof(val_db_vtn_st));
memcpy(reinterpret_cast<char *>(val_vtn), reinterpret_cast<char *>(ival),
sizeof(val_db_vtn_st));
ConfigVal *tmp2 = new ConfigVal(IpctSt::kIpcStValVtnSt, val_vtn);
- if (!tmp2) {
- UPLL_LOG_ERROR("Memory Allocation failed for tmp2");
- FREE_IF_NOT_NULL(val_vtn);
- delete tmp1;
- return UPLL_RC_ERR_GENERIC;
- }
tmp1->AppendCfgVal(tmp2);
}
};
memcpy(reinterpret_cast<char *>(vtn_key), reinterpret_cast<char *>(ikey),
sizeof(key_vtn));
okey = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcStKeyVtn, vtn_key, tmp1);
- if (okey) {
- SET_USER_DATA(okey, req)
- } else {
- delete tmp1;
- return UPLL_RC_ERR_GENERIC;
- }
+ SET_USER_DATA(okey, req)
return UPLL_RC_SUCCESS;
}
while (cval) {
if (IpctSt::kIpcStValVtnSt == cval->get_st_num()) {
val_vtn_st *vtn_val_st = reinterpret_cast<val_vtn_st *>
- (malloc(sizeof(val_vtn_st)));
- if (!vtn_val_st) {
- UPLL_LOG_ERROR("Memory Allocation failed");
- return UPLL_RC_ERR_GENERIC;
- }
+ (ConfigKeyVal::Malloc(sizeof(val_vtn_st)));
val_db_vtn_st *db_vtn_val_st = reinterpret_cast<val_db_vtn_st *>
(cval->get_val());
+ if (!db_vtn_val_st) {
+ FREE_IF_NOT_NULL(vtn_val_st);
+ return UPLL_RC_ERR_GENERIC;
+ }
memcpy(vtn_val_st, &(db_vtn_val_st->vtn_val_st),
sizeof(val_vtn_st));
cval->SetVal(IpctSt::kIpcStValVtnSt, vtn_val_st);
upll_rc_t VtnMoMgr::GetChildConfigKey(ConfigKeyVal *&okey,
ConfigKeyVal *parent_key) {
+ UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- key_vtn_t *vtn_key = reinterpret_cast<key_vtn_t *>(malloc(sizeof(key_vtn)));
- if (!vtn_key) {
- UPLL_LOG_ERROR("malloc failed");
- return UPLL_RC_ERR_GENERIC;
+ key_vtn_t *vtn_key = NULL;
+ if (okey && okey->get_key()) {
+ vtn_key = reinterpret_cast<key_vtn_t *>(
+ okey->get_key());
+ } else {
+ vtn_key = reinterpret_cast<key_vtn_t *>(
+ ConfigKeyVal::Malloc(sizeof(key_vtn)));
}
- memset(vtn_key, 0, sizeof(key_vtn));
void *pkey;
if (parent_key == NULL) {
- okey = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcStKeyVtn, vtn_key, NULL);
+ if (!okey)
+ okey = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcStKeyVtn, vtn_key, NULL);
+ else if (okey->get_key() != vtn_key)
+ okey->SetKey(IpctSt::kIpcStKeyVtn,vtn_key);
return UPLL_RC_SUCCESS;
} else {
pkey = parent_key->get_key();
}
if (!pkey) {
- free(vtn_key);
+ if (!okey || !(okey->get_key()))
+ ConfigKeyVal::Free(vtn_key);
return UPLL_RC_ERR_GENERIC;
}
switch (parent_key->get_key_type()) {
(kMaxLenVtnName+1));
break;
default:
- free(vtn_key);
+ if (!okey || !(okey->get_key())) {
+ ConfigKeyVal::Free(vtn_key);
+ }
return UPLL_RC_ERR_GENERIC;
}
- okey = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcStKeyVtn, vtn_key, NULL);
- if (okey == NULL) {
- free(vtn_key);
- result_code = UPLL_RC_ERR_GENERIC;
- } else {
- SET_USER_DATA(okey, parent_key);
- }
+ if (!okey)
+ okey = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcStKeyVtn, vtn_key, NULL);
+ else if (okey->get_key() != vtn_key)
+ okey->SetKey(IpctSt::kIpcStKeyVtn, vtn_key);
+ SET_USER_DATA(okey, parent_key);
return result_code;
}
key_vtn *ctrlr_vtn_key = reinterpret_cast<key_vtn *>(ctrlr_key->get_key());
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
ConfigKeyVal *unc_key = NULL;
- val_rename_vtn *rename_vtn = reinterpret_cast<val_rename_vtn *>(malloc(
- sizeof(val_rename_vtn)));
- if (!rename_vtn) {
- UPLL_LOG_DEBUG("Memory Allocation Failed");
- return UPLL_RC_ERR_GENERIC;
- }
+ val_rename_vtn *rename_vtn = reinterpret_cast<val_rename_vtn *>(
+ ConfigKeyVal::Malloc(sizeof(val_rename_vtn)));
uuu::upll_strncpy(reinterpret_cast<char*>(rename_vtn->new_name),
reinterpret_cast<char*>(ctrlr_vtn_key->vtn_name),
- strlen(reinterpret_cast<char*>(ctrlr_vtn_key->vtn_name)) + 1);
+ kMaxLenVtnName+1);
rename_vtn->valid[UPLL_IDX_NEW_NAME_RVTN] = UNC_VF_VALID;
result_code = GetChildConfigKey(unc_key, NULL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG(" GetChildConfigKey Failed with result_code %d",
result_code);
- free(rename_vtn);
+ ConfigKeyVal::Free(rename_vtn);
return UPLL_RC_ERR_GENERIC;
}
unc_key->AppendCfgVal(IpctSt::kIpcStValRenameVtn, rename_vtn);
- SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
+ if (ctrlr_id) {
+ SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
+ } else {
+ dbop.matchop = kOpMatchNone;
+ }
result_code = ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL);
if (result_code == UPLL_RC_SUCCESS) {
ConfigKeyVal *okey = NULL;
uint8_t rename = 0;
key_vtn *ctrlr_key = NULL;
- IsRenamed(ikey, dt_type, dmi, rename);
+ result_code = IsRenamed(ikey, dt_type, dmi, rename);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("IsRenamed failed. Result : %d", result_code);
+ return result_code;
+ }
if (!rename) return UPLL_RC_SUCCESS;
/* vtn renamed */
UPLL_LOG_ERROR("Illegal controller domain");
return UPLL_RC_ERR_GENERIC;
}
- GetChildConfigKey(okey, ikey);
+ result_code = GetChildConfigKey(okey, ikey);
+ if (result_code != UPLL_RC_SUCCESS || !okey) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed");
+ return result_code;
+ }
// SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
DbSubOp dbop = {kOpReadSingle, kOpMatchCtrlr | kOpMatchDomain,
kOpInOutFlag};
}
val_rename_vtn *rename_val = reinterpret_cast<val_rename_vtn *>
(GetVal(okey));
- if (!rename_val ||
- (rename_val->valid[UPLL_IDX_NEW_NAME_RVTN] != UNC_VF_VALID))
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("Rename Val is Empty");
return UPLL_RC_ERR_GENERIC;
+ }
ctrlr_key = reinterpret_cast<key_vtn *>(ikey->get_key());
if (!ctrlr_key) return UPLL_RC_ERR_GENERIC;
memset(ctrlr_key, 0, sizeof(key_vtn));
return UPLL_RC_SUCCESS;
}
- upll_rc_t
- VtnMoMgr::GetControllerDomainSpan(ConfigKeyVal *ikey,
- upll_keytype_datatype_t dt_type,
- DalDmlIntf *dmi) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code;
- DbSubOp dbop = {kOpReadMultiple, kOpMatchNone,
- kOpInOutCtrlr|kOpInOutDomain};
- result_code = ReadConfigDB(ikey, dt_type, UNC_OP_READ, dbop, dmi, CTRLRTBL);
+upll_rc_t
+VtnMoMgr::GetControllerDomainSpan(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code;
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone,
+ kOpInOutCtrlr|kOpInOutDomain};
+ result_code = ReadConfigDB(ikey, dt_type, UNC_OP_READ, dbop, dmi, CTRLRTBL);
+ return result_code;
+}
+
+upll_rc_t
+VtnMoMgr::GetControllerDomainSpan(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi,
+ std::list<controller_domain_t> &list_ctrlr_dom) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code;
+ ConfigKeyVal *tmp_ikey = NULL;
+ controller_domain ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone,
+ kOpInOutCtrlr|kOpInOutDomain};
+ result_code = ReadConfigDB(ikey, dt_type, UNC_OP_READ, dbop, dmi, CTRLRTBL);
+ if ((result_code != UPLL_RC_SUCCESS) &&
+ (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG("Error in ReadConfigDb (%d)", result_code);
+ return result_code;
+ }
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG(" Vtn not yet associated with controller ");
return result_code;
}
- upll_rc_t
- VtnMoMgr::GetControllerDomainSpan(ConfigKeyVal *ikey,
- upll_keytype_datatype_t dt_type,
- DalDmlIntf *dmi,
- std::list<controller_domain_t> &list_ctrlr_dom) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code;
- ConfigKeyVal *tmp_ikey = NULL;
- controller_domain ctrlr_dom;
- ctrlr_dom.ctrlr = NULL;
- ctrlr_dom.domain = NULL;
- DbSubOp dbop = {kOpReadMultiple, kOpMatchNone,
- kOpInOutCtrlr|kOpInOutDomain};
- result_code = ReadConfigDB(ikey, dt_type, UNC_OP_READ, dbop, dmi, CTRLRTBL);
- if ((result_code != UPLL_RC_SUCCESS) &&
- (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
- UPLL_LOG_DEBUG("Error in ReadConfigDb (%d)", result_code);
- return result_code;
+ tmp_ikey = ikey;
+ while (NULL != tmp_ikey) {
+ ctrlr_dom.ctrlr = reinterpret_cast<uint8_t *>
+ (ConfigKeyVal::Malloc((kMaxLenCtrlrId + 1)));
+ ctrlr_dom.domain = reinterpret_cast<uint8_t *>
+ (ConfigKeyVal::Malloc((kMaxLenDomainId + 1)));
+ controller_domain_t tmp_ctrlr_dom;
+ tmp_ctrlr_dom.ctrlr = NULL;
+ tmp_ctrlr_dom.domain = NULL;
+ GET_USER_DATA_CTRLR_DOMAIN(tmp_ikey, tmp_ctrlr_dom);
+ UPLL_LOG_TRACE(" ctrlr = %s, dom = %s ", tmp_ctrlr_dom.ctrlr,
+ tmp_ctrlr_dom.domain);
+ uuu::upll_strncpy(ctrlr_dom.ctrlr, tmp_ctrlr_dom.ctrlr,
+ (kMaxLenCtrlrId + 1));
+ uuu::upll_strncpy(ctrlr_dom.domain, tmp_ctrlr_dom.domain,
+ (kMaxLenDomainId + 1));
+ list_ctrlr_dom.push_back(ctrlr_dom);
+ tmp_ikey = tmp_ikey->get_next_cfg_key_val();
+ }
+ return result_code;
+}
+
+upll_rc_t
+VtnMoMgr::UpdateVtnConfigStatus(ConfigKeyVal *vtn_key,
+ unc_keytype_operation_t op, uint32_t driver_result,
+ ConfigKeyVal *nreq, DalDmlIntf *dmi) {
+ ConfigKeyVal *ck_vtn = NULL;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_vtn_t *vtn_val = NULL;
+ val_vtn_st *val_vtnst= NULL;
+ void *vtnval = NULL;
+ void *nvtnval = NULL;
+ val_db_vtn_st *vtn_val_db_st = NULL, *nreq_vtnst = NULL;
+
+ UPLL_FUNC_TRACE;
+ if (op != UNC_OP_DELETE) {
+ result_code = DupConfigKeyVal(ck_vtn, vtn_key, MAINTBL);
+ if (!ck_vtn || result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ return UPLL_RC_ERR_GENERIC;
}
- if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- UPLL_LOG_DEBUG(" Vtn not yet associated with controller ");
- return result_code;
+ vtn_val = reinterpret_cast<val_vtn_t *>(GetVal(ck_vtn));
+ if (!vtn_val) {
+ UPLL_LOG_DEBUG("invalid val ");
+ return UPLL_RC_ERR_GENERIC;
}
-
- tmp_ikey = ikey;
- while (NULL != tmp_ikey) {
-
- ctrlr_dom.ctrlr = reinterpret_cast<uint8_t *>
- (ConfigKeyVal::Malloc((kMaxLenCtrlrId + 1)));
- ctrlr_dom.domain = reinterpret_cast<uint8_t *>
- (ConfigKeyVal::Malloc((kMaxLenDomainId + 1)));
- controller_domain_t tmp_ctrlr_dom;
- tmp_ctrlr_dom.ctrlr = NULL;
- tmp_ctrlr_dom.domain = NULL;
- GET_USER_DATA_CTRLR_DOMAIN(tmp_ikey, tmp_ctrlr_dom);
- UPLL_LOG_TRACE(" ctrlr = %s , dom = %s ", tmp_ctrlr_dom.ctrlr, tmp_ctrlr_dom.domain);
- uuu::upll_strncpy(ctrlr_dom.ctrlr, tmp_ctrlr_dom.ctrlr,
- (kMaxLenCtrlrId + 1));
- uuu::upll_strncpy(ctrlr_dom.domain, tmp_ctrlr_dom.domain,
- (kMaxLenDomainId + 1));
- list_ctrlr_dom.push_back(ctrlr_dom);
- tmp_ikey = tmp_ikey->get_next_cfg_key_val();
+ vtn_val_db_st = reinterpret_cast<val_db_vtn_st *>(
+ ConfigKeyVal::Malloc(sizeof(val_db_vtn_st)));
+ val_vtnst = &(vtn_val_db_st->vtn_val_st);
+ } else {
+ result_code = GetChildConfigKey(ck_vtn, vtn_key);
+ if (!ck_vtn || result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ return UPLL_RC_ERR_GENERIC;
}
- return result_code;
}
+ switch (op) {
+ case UNC_OP_CREATE:
+ vtn_val->cs_row_status = UNC_CS_APPLIED;
+ val_vtnst->creation_time = time(NULL);
+ val_vtnst->last_updated_time = val_vtnst->creation_time;
+ val_vtnst->valid[UPLL_IDX_CREATION_TIME_VS] = UNC_VF_VALID;
+ val_vtnst->valid[UPLL_IDX_LAST_UPDATE_TIME_VS] = UNC_VF_VALID;
+ val_vtnst->oper_status = UPLL_OPER_STATUS_DOWN;
+ val_vtnst->alarm_status = UPLL_ALARM_CLEAR;
+ val_vtnst->valid[UPLL_IDX_OPER_STATUS_VS] = UNC_VF_VALID;
+ val_vtnst->valid[UPLL_IDX_ALARM_STATUS_VS] = UNC_VF_VALID;
+ vtn_val_db_st->down_count = 0;
+ ck_vtn->AppendCfgVal(IpctSt::kIpcStValVtnSt, vtn_val_db_st);
+ break;
+ case UNC_OP_UPDATE:
+ vtnval = reinterpret_cast<void *>(vtn_val);
+ nvtnval = (nreq)?GetVal(nreq):NULL;
+ if (!nvtnval) {
+ UPLL_LOG_DEBUG("Invalid param");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ CompareValidValue(vtnval, nvtnval, true);
- upll_rc_t
- VtnMoMgr::UpdateVtnConfigStatus(ConfigKeyVal *vtn_key,
- unc_keytype_operation_t op, uint32_t driver_result,
- ConfigKeyVal *nreq, DalDmlIntf *dmi) {
- ConfigKeyVal *ck_vtn = NULL;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- val_vtn_t *vtn_val = NULL;
- val_vtn_st *val_vtnst= NULL;
- void *vtnval = NULL;
- void *nvtnval = NULL;
- val_db_vtn_st *vtn_val_db_st = NULL;
-
- UPLL_FUNC_TRACE;
- if (op != UNC_OP_DELETE) {
- result_code = DupConfigKeyVal(ck_vtn, vtn_key, MAINTBL);
- if (!ck_vtn || result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d", result_code);
- return UPLL_RC_ERR_GENERIC;
- }
- vtn_val = reinterpret_cast<val_vtn_t *>(GetVal(ck_vtn));
- if (!vtn_val) {
- UPLL_LOG_DEBUG("invalid val ");
- return UPLL_RC_ERR_GENERIC;
- }
- vtn_val_db_st = reinterpret_cast<val_db_vtn_st *>
- (malloc(sizeof(val_db_vtn_st)));
- if (!vtn_val_db_st) {
- UPLL_LOG_DEBUG("invalid st val ");
- return UPLL_RC_ERR_GENERIC;
- }
- val_vtnst = &(vtn_val_db_st->vtn_val_st);
- } else {
- result_code = GetChildConfigKey(ck_vtn, vtn_key);
- if (!ck_vtn || result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d", result_code);
- return UPLL_RC_ERR_GENERIC;
- }
- }
- switch (op) {
- case UNC_OP_CREATE:
- vtn_val->cs_row_status = UNC_CS_NOT_APPLIED;
- if (vtn_val->valid[UPLL_IDX_DESC_VTN] == UNC_VF_VALID) {
- vtn_val->cs_attr[UPLL_IDX_DESC_VTN] = UNC_CS_APPLIED;
- }
- val_vtnst->creation_time = time(NULL);
- val_vtnst->last_updated_time = val_vtnst->creation_time;
- val_vtnst->valid[UPLL_IDX_CREATION_TIME_VS] = UNC_VF_VALID;
- val_vtnst->valid[UPLL_IDX_LAST_UPDATE_TIME_VS] = UNC_VF_VALID;
- val_vtnst->oper_status = UPLL_OPER_STATUS_UP;
- val_vtnst->alarm_status = UPLL_ALARM_CLEAR;
- val_vtnst->valid[UPLL_IDX_OPER_STATUS_VS] = UNC_VF_VALID;
- val_vtnst->valid[UPLL_IDX_ALARM_STATUS_VS] = UNC_VF_VALID;
- vtn_val_db_st->down_count = 0;
- ck_vtn->AppendCfgVal(IpctSt::kIpcStValVtnSt, vtn_val_db_st);
- break;
- case UNC_OP_UPDATE:
- vtnval = reinterpret_cast<void *>(vtn_val);
- nvtnval = (nreq)?GetVal(nreq):NULL;
- if (!nvtnval) {
- UPLL_LOG_DEBUG("Invalid param");
- return UPLL_RC_ERR_GENERIC;
- }
- CompareValidValue(vtnval, nvtnval, true);
- val_vtnst->last_updated_time = time(NULL);
- val_vtnst->valid[UPLL_IDX_LAST_UPDATE_TIME_VS] = UNC_VF_VALID;
- val_vtnst->valid[UPLL_IDX_OPER_STATUS_VS] = UNC_VF_INVALID;
- val_vtnst->valid[UPLL_IDX_ALARM_STATUS_VS] = UNC_VF_INVALID;
- ck_vtn->AppendCfgVal(IpctSt::kIpcStValVtnSt, val_vtnst);
- break;
- case UNC_OP_DELETE:
+ vtn_val->cs_row_status =
+ reinterpret_cast<val_vtn_t *>(GetVal(nreq))->cs_row_status;
+
+ val_vtnst->last_updated_time = time(NULL);
+ val_vtnst->valid[UPLL_IDX_LAST_UPDATE_TIME_VS] = UNC_VF_VALID;
+ val_vtnst->valid[UPLL_IDX_OPER_STATUS_VS] = UNC_VF_INVALID;
+ val_vtnst->valid[UPLL_IDX_ALARM_STATUS_VS] = UNC_VF_INVALID;
+ nreq_vtnst = reinterpret_cast<val_db_vtn_st *>(GetStateVal(nreq));
+ if (!nreq_vtnst) {
+ UPLL_LOG_DEBUG("Invalid param");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ vtn_val_db_st->down_count = nreq_vtnst->down_count;
+ ck_vtn->AppendCfgVal(IpctSt::kIpcStValVtnSt, val_vtnst);
+ break;
+ case UNC_OP_DELETE:
#if 0
- result_code = UpdateConfigDB(ck_vtn, UPLL_DT_CANDIDATE, UNC_OP_READ,
- dmi, CTRLRTBL);
- if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
- string s(ck_vtn->ToStr());
- UPLL_LOG_DEBUG("Instance exists in ctrlr table - not deleted %s",
- s.c_str());
- delete ck_vtn;
- return UPLL_RC_SUCCESS;
- } else if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- string s(ck_vtn->ToStr());
- UPLL_LOG_DEBUG("Ctrlr table exists read failed- %s", s.c_str());
- delete ck_vtn;
- return result_code;
- }
+ result_code = UpdateConfigDB(ck_vtn, UPLL_DT_CANDIDATE, UNC_OP_READ,
+ dmi, CTRLRTBL);
+ if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
+ string s(ck_vtn->ToStr());
+ UPLL_LOG_DEBUG("Instance exists in ctrlr table - not deleted %s",
+ s.c_str());
+ delete ck_vtn;
+ return UPLL_RC_SUCCESS;
+ } else if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ string s(ck_vtn->ToStr());
+ UPLL_LOG_DEBUG("Ctrlr table exists read failed- %s", s.c_str());
+ delete ck_vtn;
+ return result_code;
+ }
#endif
- break;
- default:
- UPLL_LOG_DEBUG("Invalid operation");
- return UPLL_RC_ERR_GENERIC;
- }
- result_code = UpdateConfigDB(ck_vtn, UPLL_DT_STATE, op, dmi, MAINTBL);
- EnqueCfgNotification(op, UPLL_DT_RUNNING, ck_vtn);
- delete ck_vtn;
- return result_code;
+ break;
+ default:
+ UPLL_LOG_DEBUG("Invalid operation");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if ((op != UNC_OP_DELETE) &&
+ (vtn_val->valid[UPLL_IDX_DESC_VTN] != UNC_VF_INVALID)) {
+ vtn_val->cs_attr[UPLL_IDX_DESC_VTN] = UNC_CS_APPLIED;
+ }
+ DbSubOp dbop = {kOpNotRead, kOpMatchNone, kOpInOutFlag | kOpInOutCs};
+ result_code = UpdateConfigDB(ck_vtn, UPLL_DT_STATE, op, dmi, &dbop, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateConfigDB Failed %d", result_code);
+ return result_code;
+ }
+ result_code = EnqueCfgNotification(op, UPLL_DT_RUNNING, ck_vtn);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("EnqueCfgNotification Failed %d", result_code);
+ return result_code;
}
+ delete ck_vtn;
+ return result_code;
+}
- upll_rc_t
- VtnMoMgr::UpdateConfigStatus(ConfigKeyVal *vtn_key,
- unc_keytype_operation_t op, uint32_t driver_result, ConfigKeyVal *nreq,
- DalDmlIntf *dmi, ConfigKeyVal *ctrlr_key) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- unc_keytype_configstatus_t status = UNC_CS_UNKNOWN, cs_status;
- cs_status = (driver_result == UPLL_RC_SUCCESS)?
+upll_rc_t
+VtnMoMgr::UpdateConfigStatus(ConfigKeyVal *vtn_run,
+ unc_keytype_operation_t op, uint32_t driver_result, ConfigKeyVal *ctrlr_can,
+ DalDmlIntf *dmi, ConfigKeyVal *ctrlr_run) {
+ UPLL_FUNC_TRACE;
+ unc_keytype_configstatus_t ctrlr_status;
+ uint8_t cs_status;
+ bool attribute_change = false;
+ ctrlr_status = (driver_result == UPLL_RC_SUCCESS)?
UNC_CS_APPLIED: UNC_CS_NOT_APPLIED;
- val_vtn_t *vtn_val = reinterpret_cast<val_vtn_t *>(GetVal(vtn_key));
- val_vtn_ctrlr *ctrlr_val_vtn = reinterpret_cast<val_vtn_ctrlr *>
- (GetVal(ctrlr_key));
- if ((vtn_val == NULL) || (ctrlr_val_vtn == NULL))
+ val_vtn_t *vtn_val = reinterpret_cast<val_vtn_t *>(GetVal(vtn_run));
+ val_vtn_ctrlr *ctrlr_val_vtn = NULL;
+ if (ctrlr_can == NULL) {
+ attribute_change = true;
+ } else {
+ ctrlr_val_vtn = reinterpret_cast<val_vtn_ctrlr *>
+ (GetVal(ctrlr_can));
+ }
+ if (vtn_val == NULL)
return UPLL_RC_ERR_GENERIC;
+ cs_status = vtn_val->cs_row_status;
+ UPLL_LOG_TRACE("cs_status %d ctrlr_status %d\n", cs_status, ctrlr_status);
+ uuc::CtrlrMgr *ctrlr_mgr = uuc::CtrlrMgr::GetInstance();
+ unc_keytype_ctrtype_t ctrlrtype = UNC_CT_UNKNOWN;
+ if (ctrlr_can && ctrlr_mgr) {
+ uint8_t *ctrlr_id = NULL;
+ GET_USER_DATA_CTRLR(ctrlr_can, ctrlr_id);
+ if (!ctrlr_id) {
+ UPLL_LOG_DEBUG("Returning error\n");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ctrlr_mgr->GetCtrlrType(reinterpret_cast<char *>(ctrlr_id),
+ UPLL_DT_CANDIDATE, &ctrlrtype);
+ }
+ if (op == UNC_OP_CREATE) {
+ if (ctrlr_val_vtn == NULL) return UPLL_RC_ERR_GENERIC;
+ ctrlr_val_vtn->oper_status = UPLL_OPER_STATUS_UP;
+ ctrlr_val_vtn->alarm_status = UPLL_ALARM_CLEAR;
+ ctrlr_val_vtn->valid[0] = UNC_VF_VALID;
+ ctrlr_val_vtn->valid[1] = UNC_VF_VALID;
+ ctrlr_val_vtn->down_count = 0;
+ if (ctrlrtype == UNC_CT_PFC) {
+ ctrlr_val_vtn->oper_status = UPLL_OPER_STATUS_DOWN;
+ ctrlr_val_vtn->down_count = ctrlr_val_vtn->ref_count;
+ }
+ ctrlr_val_vtn->cs_row_status = ctrlr_status;
- if (op == UNC_OP_CREATE) {
- ctrlr_val_vtn->oper_status = UPLL_OPER_STATUS_UP;
- ctrlr_val_vtn->alarm_status = UPLL_ALARM_CLEAR;
- ctrlr_val_vtn->valid[0] = UNC_VF_VALID;
- ctrlr_val_vtn->valid[1] = UNC_VF_VALID;
-
- /* update the vtn status in main tbl */
- switch (vtn_val->cs_row_status) {
- case UNC_CS_UNKNOWN:
- status = cs_status;
- break;
- case UNC_CS_PARTAILLY_APPLIED:
- if (ctrlr_val_vtn->cs_row_status == UNC_CS_NOT_APPLIED) {
- // Todo: if this vtn has caused it then to change to applied.
- status = (cs_status != UNC_CS_APPLIED) ?
- UNC_CS_PARTAILLY_APPLIED : cs_status;
- }
- break;
- case UNC_CS_APPLIED:
- case UNC_CS_NOT_APPLIED:
- case UNC_CS_INVALID:
- default:
- status = (cs_status == UNC_CS_NOT_APPLIED)?
- UNC_CS_PARTAILLY_APPLIED:status;
- break;
+ /* update the vtn status in main tbl */
+ switch (vtn_val->cs_row_status) {
+ case UNC_CS_APPLIED: {
+ cs_status = (ctrlr_status == UNC_CS_NOT_APPLIED) ?
+ UNC_CS_PARTIALLY_APPLIED : ctrlr_status;
+ }
+ break;
+ case UNC_CS_NOT_APPLIED: {
+ cs_status = (ctrlr_status == UNC_CS_APPLIED) ?
+ UNC_CS_PARTIALLY_APPLIED : ctrlr_status;
}
- vtn_val->cs_row_status = status;
- } else if (op == UNC_OP_UPDATE) {
- val_vtn *vtnval2 = reinterpret_cast<val_vtn *>(GetVal(nreq));
+ break;
+ case UNC_CS_PARTIALLY_APPLIED:
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ break;
+ case UNC_CS_INVALID:
+ cs_status = UNC_CS_INVALID;
+ break;
+ case UNC_CS_UNKNOWN:
+ default:
+ /* first entry in ctrlr table */
+ cs_status = ctrlr_status;
+ }
+ vtn_val->cs_row_status = cs_status;
+ }
+ // description is always applied
+ vtn_val->cs_attr[UPLL_IDX_DESC_VTN] = UNC_CS_APPLIED;
- if ( (UNC_VF_VALID == vtn_val->valid[UPLL_IDX_DESC_VTN]) &&
- (UNC_VF_VALID == vtnval2->valid[UPLL_IDX_DESC_VTN])) {
- if (!strcmp(reinterpret_cast<char*>(vtn_val->description),
- reinterpret_cast<char*>(vtnval2->description)) )
- vtn_val->valid[UPLL_IDX_DESC_VTN] = UNC_VF_INVALID;
- } else if (UNC_VF_NOT_SOPPORTED == vtn_val->valid[UPLL_IDX_DESC_VTN]) {
- vtn_val->cs_attr[UPLL_IDX_DESC_VTN] = UNC_CS_NOT_SUPPORTED;
+ // Updating the Controller cs_row_status
+ // Main tbl update, pass ctrlr_run = NULL
+ val_vtn_ctrlr *run_ctrlr_val = reinterpret_cast<val_vtn_ctrlr *>
+ (GetVal(ctrlr_run));
+ if ((op == UNC_OP_UPDATE) && (run_ctrlr_val != NULL)) {
+ if (attribute_change) {
+ cs_status = run_ctrlr_val->cs_row_status;
+ run_ctrlr_val->cs_row_status = unc_keytype_configstatus_t(cs_status);
+ if (vtn_val->valid[UPLL_IDX_DESC_VTN] != UNC_VF_INVALID) {
+ if (run_ctrlr_val->cs_attr[UPLL_IDX_DESC_VTN] != UNC_CS_NOT_SUPPORTED)
+ run_ctrlr_val->cs_attr[UPLL_IDX_DESC_VTN] = UNC_CS_APPLIED;
+ else
+ run_ctrlr_val->cs_attr[UPLL_IDX_DESC_VTN] = UNC_CS_NOT_SUPPORTED;
+ }
+ return UPLL_RC_SUCCESS;
+ } else {
+ ctrlr_val_vtn->cs_row_status = run_ctrlr_val->cs_row_status;
+ ctrlr_val_vtn->down_count = 0;
+ ctrlr_val_vtn->oper_status = UPLL_OPER_STATUS_UP;
+ ctrlr_val_vtn->valid[0] = UNC_VF_VALID;
+ // down count incremented only for create of vnode
+ // down count decrement handled during deletion of vnode, if needed.
+ if (ctrlrtype == UNC_CT_PFC) {
+ int diff = ctrlr_val_vtn->ref_count - run_ctrlr_val->ref_count;
+ if (diff > 0)
+ ctrlr_val_vtn->down_count = (run_ctrlr_val->down_count + diff);
+ else if (diff == 0)
+ ctrlr_val_vtn->down_count = (run_ctrlr_val->down_count + 1);
+ ctrlr_val_vtn->oper_status = UPLL_OPER_STATUS_DOWN;
}
}
+ }
+ val_db_vtn_st *vtn_val_db_st = reinterpret_cast<val_db_vtn_st *>
+ (GetStateVal(vtn_run));
+ if (!vtn_val_db_st) {
+ UPLL_LOG_DEBUG("Returning error %d\n",UPLL_RC_ERR_GENERIC);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ // initialize the main table vtn oper status to be recomputed.
+ val_vtn_st *val_vtnst = &(vtn_val_db_st->vtn_val_st);
+ val_vtnst->oper_status = UPLL_OPER_STATUS_UNINIT;
+ val_vtnst->valid[UPLL_IDX_OPER_STATUS_VS] = UNC_VF_VALID;
+ if (vtn_val->valid[UPLL_IDX_DESC_VTN] != UNC_VF_INVALID) {
if (ctrlr_val_vtn->cs_attr[UPLL_IDX_DESC_VTN] != UNC_CS_NOT_SUPPORTED)
- ctrlr_val_vtn->cs_attr[UPLL_IDX_DESC_VTN] = cs_status;
+ ctrlr_val_vtn->cs_attr[UPLL_IDX_DESC_VTN] =
+ (ctrlr_status == UNC_CS_UNKNOWN)?UNC_CS_APPLIED:ctrlr_status;
else
ctrlr_val_vtn->cs_attr[UPLL_IDX_DESC_VTN] = UNC_CS_NOT_SUPPORTED;
- vtn_val->cs_attr[UPLL_IDX_DESC_VTN] = UNC_CS_APPLIED;
- return result_code;
}
+ return UPLL_RC_SUCCESS;
+}
- upll_rc_t
- VtnMoMgr::TxCopyCandidateToRunning(unc_key_type_t keytype,
- CtrlrCommitStatusList *ctrlr_commit_status,
- DalDmlIntf *dmi) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- DalResultCode db_result;
- unc_keytype_operation_t op[] = {UNC_OP_DELETE,
- UNC_OP_CREATE, UNC_OP_UPDATE};
- int nop = sizeof(op) / sizeof(op[0]);
- ConfigKeyVal *vtn_key = NULL, *req = NULL, *nreq = NULL;
- DalCursor *cfg1_cursor;
- uint8_t *ctrlr_id = NULL;
- map<string, int> ctrlr_result;
- CtrlrCommitStatusList::iterator ccsListItr;
- CtrlrCommitStatus *ccStatusPtr;
+upll_rc_t
+VtnMoMgr::TxCopyCandidateToRunning(unc_key_type_t keytype,
+ CtrlrCommitStatusList *ctrlr_commit_status,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ DalResultCode db_result;
+ unc_keytype_operation_t op[] = {UNC_OP_DELETE,
+ UNC_OP_CREATE,
+ UNC_OP_UPDATE };
+ int nop = sizeof(op) / sizeof(op[0]);
+ ConfigKeyVal *vtn_ck_run = NULL, *req = NULL, *nreq = NULL;
+ DalCursor *cfg1_cursor;
+ uint8_t *ctrlr_id = NULL;
+ map<string, int> ctrlr_result;
+ CtrlrCommitStatusList::iterator ccsListItr;
+ CtrlrCommitStatus *ccStatusPtr;
- if ((ctrlr_commit_status == NULL) || (dmi == NULL))
- return UPLL_RC_ERR_GENERIC;
- for (ccsListItr = ctrlr_commit_status->begin();
- ccsListItr != ctrlr_commit_status->end(); ++ccsListItr) {
- ccStatusPtr = *ccsListItr;
- ctrlr_id = reinterpret_cast<uint8_t*>
- (const_cast<char*>(ccStatusPtr->ctrlr_id.c_str()));
- ctrlr_result[ccStatusPtr->ctrlr_id] = ccStatusPtr->upll_ctrlr_result;
- if (ccStatusPtr->upll_ctrlr_result != UPLL_RC_SUCCESS) {
- for (ConfigKeyVal *ck_err = ccStatusPtr->err_ckv; ck_err != NULL;
- ck_err = ck_err->get_next_cfg_key_val()) {
- if (ck_err->get_key_type() != keytype) continue;
- result_code = GetRenamedUncKey(ck_err, UPLL_DT_CANDIDATE,
- dmi, ctrlr_id);
- if (result_code != UPLL_RC_SUCCESS)
+ if ((ctrlr_commit_status == NULL) || (dmi == NULL))
+ return UPLL_RC_ERR_GENERIC;
+ for (ccsListItr = ctrlr_commit_status->begin();
+ ccsListItr != ctrlr_commit_status->end(); ++ccsListItr) {
+ ccStatusPtr = *ccsListItr;
+ ctrlr_id = reinterpret_cast<uint8_t*>
+ (const_cast<char*>(ccStatusPtr->ctrlr_id.c_str()));
+ ctrlr_result[ccStatusPtr->ctrlr_id] = ccStatusPtr->upll_ctrlr_result;
+ if (ccStatusPtr->upll_ctrlr_result != UPLL_RC_SUCCESS) {
+ for (ConfigKeyVal *ck_err = ccStatusPtr->err_ckv; ck_err != NULL;
+ ck_err = ck_err->get_next_cfg_key_val()) {
+ if (ck_err->get_key_type() != keytype) continue;
+ result_code = GetRenamedUncKey(ck_err, UPLL_DT_CANDIDATE,
+ dmi, ctrlr_id);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey failed. Result : %d",
+ result_code);
return result_code;
}
}
}
+ }
- for (int i = 0; i < nop; i++) {
- cfg1_cursor = NULL;
- if (op[i] != UNC_OP_UPDATE) {
- result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i],
- req, nreq, &cfg1_cursor, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS || cfg1_cursor == NULL) {
- UPLL_LOG_DEBUG("Cursor not populated");
- return result_code;
- }
- while (result_code == UPLL_RC_SUCCESS) {
- db_result = dmi->GetNextRecord(cfg1_cursor);
- result_code = DalToUpllResCode(db_result);
- if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- result_code = UPLL_RC_SUCCESS;
- break;
- }
- result_code = UpdateVtnConfigStatus(req, op[i], UPLL_RC_SUCCESS,
- nreq, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Error updating vtn config status %d",
- result_code);
- if (cfg1_cursor)
- dmi->CloseCursor(cfg1_cursor, true);
- delete req;
- return result_code;
- }
- }
- if (cfg1_cursor)
- dmi->CloseCursor(cfg1_cursor, true);
- if (req)
- delete req;
- req = NULL;
- }
- UPLL_LOG_DEBUG("done with op %d ", op[i]);
+ for (int i = 0; i < nop; i++) {
+ cfg1_cursor = NULL;
+ result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i],
+ req, nreq, &cfg1_cursor, dmi, NULL, MAINTBL, true);
+ if (result_code != UPLL_RC_SUCCESS || cfg1_cursor == NULL) {
+ UPLL_LOG_DEBUG("Cursor not populated");
+ return result_code;
}
- for (int i = 0; i < nop; i++) {
- cfg1_cursor = NULL;
- MoMgrTables tbl = (op[i] == UNC_OP_UPDATE)?MAINTBL:CTRLRTBL;
- result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i], req,
- nreq, &cfg1_cursor, dmi, tbl);
- if (result_code != UPLL_RC_SUCCESS || cfg1_cursor == NULL) {
- UPLL_LOG_DEBUG("Cursor not populated");
- return result_code;
+ ConfigKeyVal *vtn_ctrlr_key = NULL;
+ while (result_code == UPLL_RC_SUCCESS) {
+ vtn_ctrlr_key = NULL;
+ bool upd_ctrlr = false;
+ db_result = dmi->GetNextRecord(cfg1_cursor);
+ result_code = DalToUpllResCode(db_result);
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ result_code = UPLL_RC_SUCCESS;
+ break;
}
- ConfigKeyVal *vtn_ctrlr_key = NULL;
- while (result_code == UPLL_RC_SUCCESS) {
- db_result = dmi->GetNextRecord(cfg1_cursor);
- result_code = DalToUpllResCode(db_result);
- if (result_code != UPLL_RC_SUCCESS)
- break;
- if (op[i] == UNC_OP_UPDATE) {
- DbSubOp dbop = {kOpReadMultiple, kOpMatchNone,
- kOpInOutCtrlr | kOpInOutDomain };
- result_code = GetChildConfigKey(vtn_ctrlr_key, req);
- if (result_code != UPLL_RC_SUCCESS || vtn_ctrlr_key == NULL)
- return result_code;
-#if 0
- // Capability check
- req_header->operation = op[i];
- req_header->datatype = UPLL_DT_CANDIDATE;
- result_code = ValidateCapability(req_header, vtn_ctrlr_key);
- if (result_code != UPLL_RC_SUCCESS)
+ if (op[i] == UNC_OP_UPDATE) {
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone,
+ kOpInOutCtrlr | kOpInOutDomain | kOpInOutCs };
+ result_code = GetChildConfigKey(vtn_ctrlr_key, req);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed");
return result_code;
-#endif
- result_code = ReadConfigDB(vtn_ctrlr_key, UPLL_DT_CANDIDATE,
- UNC_OP_READ, dbop, dmi, CTRLRTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- delete vtn_ctrlr_key;
- if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- result_code = UpdateVtnConfigStatus(req, op[i], UPLL_RC_SUCCESS,
- nreq, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Error updating vtn config status %d",
- result_code);
- if (cfg1_cursor)
- dmi->CloseCursor(cfg1_cursor, true);
- delete req;
- delete nreq;
- return result_code;
- } else {
- continue;
- }
- } else {
- if (cfg1_cursor)
- dmi->CloseCursor(cfg1_cursor, true);
- delete req;
- delete nreq;
- return result_code;
- }
- }
- result_code = DupConfigKeyVal(vtn_key, req, tbl);
- if (result_code != UPLL_RC_SUCCESS || vtn_key != NULL) {
+ }
+ result_code = ReadConfigDB(vtn_ctrlr_key, UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop, dmi, CTRLRTBL);
+ if (result_code == UPLL_RC_SUCCESS) {
+ upd_ctrlr = true;
+ } else {
+ DELETE_IF_NOT_NULL(vtn_ctrlr_key);
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
if (cfg1_cursor)
dmi->CloseCursor(cfg1_cursor, true);
delete req;
delete nreq;
return result_code;
}
- for (ConfigKeyVal *tmp = vtn_ctrlr_key; tmp != NULL;
- tmp = tmp->get_next_cfg_key_val()) {
- GET_USER_DATA_CTRLR(tmp, ctrlr_id);
- string controller(reinterpret_cast<char *>(ctrlr_id));
- result_code = UpdateConfigStatus(vtn_key, op[i],
- ctrlr_result[controller], nreq, dmi, tmp);
- if (result_code != UPLL_RC_SUCCESS)
+ }
+ }
+ result_code = UpdateVtnConfigStatus(req, op[i], UPLL_RC_SUCCESS,
+ nreq, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error updating vtn config status %d",
+ result_code);
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ delete req;
+ DELETE_IF_NOT_NULL(vtn_ctrlr_key);
+ if (nreq) delete nreq;
+ return result_code;
+ }
+ if (upd_ctrlr) {
+ result_code = DupConfigKeyVal(vtn_ck_run, req, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ delete req;
+ delete nreq;
+ DELETE_IF_NOT_NULL(vtn_ctrlr_key);
+ return result_code;
+ }
+ // Assigning cs_row_status from existing controller
+ static_cast<val_vtn *>(GetVal(vtn_ck_run))->cs_row_status =
+ static_cast<val_vtn *>(GetVal(nreq))->cs_row_status;
+ for (ConfigKeyVal *tmp = vtn_ctrlr_key, *tmp_nxt; tmp!= NULL;
+ tmp = tmp_nxt) {
+ tmp_nxt = tmp->get_next_cfg_key_val();
+ tmp->set_next_cfg_key_val(NULL);
+ GET_USER_DATA_CTRLR(tmp, ctrlr_id);
+ string controller(reinterpret_cast<char *>(ctrlr_id));
+ result_code = UpdateConfigStatus(vtn_ck_run, op[i],
+ ctrlr_result[controller], NULL, dmi, tmp);
+ if (result_code != UPLL_RC_SUCCESS)
break;
- result_code = UpdateConfigDB(tmp, UPLL_DT_RUNNING, op[i],
- dmi, CTRLRTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- if (cfg1_cursor)
- dmi->CloseCursor(cfg1_cursor, true);
- delete req;
- delete nreq;
- return result_code;
- }
- }
- result_code = UpdateConfigDB(vtn_key, UPLL_DT_RUNNING, op[i],
- dmi, MAINTBL);
+ result_code = UpdateConfigDB(tmp, UPLL_DT_RUNNING, op[i],
+ dmi, CTRLRTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning %d", result_code);
if (cfg1_cursor)
dmi->CloseCursor(cfg1_cursor, true);
delete req;
delete nreq;
+ delete tmp;
+ delete tmp_nxt;
+ DELETE_IF_NOT_NULL(vtn_ck_run);
return result_code;
}
- EnqueCfgNotification(op[i], UPLL_DT_RUNNING, vtn_key);
- } else {
- if (op[i] == UNC_OP_CREATE) {
- DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutFlag};
- result_code = GetChildConfigKey(vtn_key, req);
- result_code = ReadConfigDB(vtn_key, UPLL_DT_CANDIDATE, UNC_OP_READ,
- dbop, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- if (cfg1_cursor)
- dmi->CloseCursor(cfg1_cursor, true);
- delete req;
- return result_code;
- }
-#if 0
- // Capability check
- req_header->operation = op[i];
- req_header->datatype = UPLL_DT_CANDIDATE;
- result_code = ValidateCapability(req_header, vtn_ctrlr_key);
- if (result_code != UPLL_RC_SUCCESS)
- return result_code;
-#endif
- result_code = DupConfigKeyVal(vtn_ctrlr_key, req, tbl);
- if (result_code != UPLL_RC_SUCCESS || vtn_ctrlr_key == NULL) {
- if (cfg1_cursor)
- dmi->CloseCursor(cfg1_cursor, true);
- delete req;
- return result_code;
- }
- GET_USER_DATA_CTRLR(vtn_ctrlr_key, ctrlr_id);
- string controller(reinterpret_cast<char *>(ctrlr_id));
- result_code = UpdateConfigStatus(vtn_key, op[i],
- ctrlr_result[controller], NULL, dmi, vtn_ctrlr_key);
- } else if (op[i] == UNC_OP_DELETE) {
- result_code = GetChildConfigKey(vtn_ctrlr_key, req);
-#if 0
- DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutFlag};
- result_code = ReadConfigDB(vtn_key, UPLL_DT_CANDIDATE, UNC_OP_READ,
- dbop, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS)
- return result_code;
-#endif
- }
- if (result_code != UPLL_RC_SUCCESS) {
- if (cfg1_cursor)
- dmi->CloseCursor(cfg1_cursor, true);
- delete req;
- return result_code;
- }
- result_code = UpdateConfigDB(vtn_ctrlr_key, UPLL_DT_RUNNING, op[i],
- dmi, CTRLRTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- if (cfg1_cursor)
- dmi->CloseCursor(cfg1_cursor, true);
- delete req;
- return result_code;
- }
- if (op[i] != UNC_OP_DELETE) {
- result_code = UpdateConfigDB(vtn_key, UPLL_DT_RUNNING,
- UNC_OP_UPDATE, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- if (cfg1_cursor)
- dmi->CloseCursor(cfg1_cursor, true);
- delete req;
- return result_code;
- }
- }
- EnqueCfgNotification(op[i], UPLL_DT_RUNNING, vtn_key);
+ delete tmp;
}
-#if 1
- if (vtn_ctrlr_key)
- delete vtn_ctrlr_key;
-#endif
- if (vtn_key)
- delete vtn_key;
- vtn_key = vtn_ctrlr_key = NULL;
- result_code = DalToUpllResCode(db_result);
- }
- if (cfg1_cursor)
- dmi->CloseCursor(cfg1_cursor, true);
- if (req)
- delete req;
- if (nreq)
- delete nreq;
- nreq = req = NULL;
+ vtn_ctrlr_key = NULL;
+ result_code = UpdateConfigDB(vtn_ck_run, UPLL_DT_RUNNING, op[i],
+ dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ delete req;
+ delete nreq;
+ DELETE_IF_NOT_NULL(vtn_ck_run);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(vtn_ck_run);
+ }
}
- result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
- UPLL_RC_SUCCESS:result_code;
- return result_code;
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ if (req)
+ delete req;
+ if (nreq) delete nreq;
+ req = nreq = NULL;
}
-
-upll_rc_t VtnMoMgr::ReadSingleCtlrlStation(IpcReqRespHeader *header,
+ for (int i = 0; i < nop; i++) {
+ cfg1_cursor = NULL;
+ result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i], req,
+ nreq, &cfg1_cursor, dmi, NULL, CTRLRTBL, true);
+ if (result_code != UPLL_RC_SUCCESS || cfg1_cursor == NULL) {
+ UPLL_LOG_DEBUG("Cursor not populated");
+ return result_code;
+ }
+ ConfigKeyVal *vtn_ctrlr_key = NULL;
+ while (result_code == UPLL_RC_SUCCESS) {
+ db_result = dmi->GetNextRecord(cfg1_cursor);
+ result_code = DalToUpllResCode(db_result);
+ if (result_code != UPLL_RC_SUCCESS) {
+ break;
+ }
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutFlag | kOpInOutCs};
+ result_code = GetChildConfigKey(vtn_ck_run, req);
+ result_code = ReadConfigDB(vtn_ck_run, UPLL_DT_STATE, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if ((op[i] != UNC_OP_DELETE) &&
+ (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ delete req;
+ return result_code;
+ }
+ }
+ if (op[i] == UNC_OP_CREATE) {
+ /* set consolidated config status to UNKNOWN to init vtn cs_status
+ * to the cs_status of first controller
+ */
+ uint32_t cur_instance_count;
+ result_code = GetInstanceCount(vtn_ck_run, NULL,
+ UPLL_DT_CANDIDATE, &cur_instance_count,
+ dmi, CTRLRTBL);
+ if ((result_code == UPLL_RC_SUCCESS) && (cur_instance_count == 1))
+ reinterpret_cast<val_vtn *>(GetVal(vtn_ck_run))->cs_row_status =
+ UNC_CS_UNKNOWN;
+ }
+ if ((op[i] == UNC_OP_CREATE) || (op[i] == UNC_OP_UPDATE)) {
+ result_code = DupConfigKeyVal(vtn_ctrlr_key, req, CTRLRTBL);
+ if (result_code != UPLL_RC_SUCCESS || vtn_ctrlr_key == NULL) {
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ delete req;
+ return result_code;
+ }
+ GET_USER_DATA_CTRLR(vtn_ctrlr_key, ctrlr_id);
+ string controller(reinterpret_cast<char *>(ctrlr_id));
+ // Passing vtn_ck_run instead of nreq
+ result_code = UpdateConfigStatus(vtn_ck_run, op[i],
+ ctrlr_result[controller], vtn_ctrlr_key, dmi, nreq);
+ } else if (op[i] == UNC_OP_DELETE) {
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ GET_USER_DATA_CTRLR(req, ctrlr_id);
+ result_code = SetVtnConsolidatedStatus(vtn_ck_run, ctrlr_id, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Could not set consolidated status %d", result_code);
+ return result_code;
+ }
+ }
+ result_code = GetChildConfigKey(vtn_ctrlr_key, req);
+ }
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ delete req;
+ return result_code;
+ }
+ result_code = UpdateConfigDB(vtn_ctrlr_key, UPLL_DT_STATE, op[i],
+ dmi, CTRLRTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ delete req;
+ return result_code;
+ }
+ if (op[i] != UNC_OP_DELETE) {
+ DbSubOp dbop_update = {kOpNotRead, kOpMatchNone, kOpInOutCs};
+ result_code = UpdateConfigDB(vtn_ck_run, UPLL_DT_STATE,
+ UNC_OP_UPDATE, dmi, &dbop_update, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ delete req;
+ return result_code;
+ }
+ }
+ EnqueCfgNotification(op[i], UPLL_DT_RUNNING, vtn_ck_run);
+#if 1
+ if (vtn_ctrlr_key)
+ delete vtn_ctrlr_key;
+#endif
+ if (vtn_ck_run)
+ delete vtn_ck_run;
+ vtn_ck_run = vtn_ctrlr_key = NULL;
+ result_code = DalToUpllResCode(db_result);
+ }
+ if (cfg1_cursor)
+ dmi->CloseCursor(cfg1_cursor, true);
+ if (req)
+ delete req;
+ if (nreq) delete nreq;
+ req = nreq = NULL;
+ // Copying Rename Table to Running
+ UPLL_LOG_DEBUG("keytype is %d", keytype);
+ result_code = TxCopyRenameTableFromCandidateToRunning(keytype,
+ op[i], dmi);
+ UPLL_LOG_DEBUG("TxCopyRenameTableFromCandidateToRunning returned %d",
+ result_code);
+ }
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
+ UPLL_RC_SUCCESS:result_code;
+ return result_code;
+}
+
+
+upll_rc_t VtnMoMgr::ReadSingleCtlrlVtnMapping(IpcReqRespHeader *header,
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ uint32_t *ckv_count) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+
+ if (*ckv_count >= header->rep_count) {
+ return result_code;
+ }
+ controller_domain ctrlr_dom_in;
+ ctrlr_dom_in.ctrlr = NULL;
+ ctrlr_dom_in.domain = NULL;
+
+ IpcRequest ipc_req;
+ memset(&ipc_req, 0, sizeof(ipc_req));
+ memcpy(&(ipc_req.header), header, sizeof(IpcReqRespHeader));
+ ipc_req.header.operation = UNC_OP_READ;
+
+ ConfigKeyVal *ckv_domain = NULL, *ckv_all_domain = NULL;
+ ConfigKeyVal *ckv_drv = NULL;
+ DbSubOp op = {kOpReadMultiple, kOpMatchCtrlr, kOpInOutCtrlr | kOpInOutDomain};
+
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom_in);
+ key_vtn_t *vtnkey = reinterpret_cast<key_vtn_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn_t)));
+ uuu::upll_strncpy(vtnkey->vtn_name, reinterpret_cast<key_vtn_controller *>(
+ ikey->get_key())->vtn_key.vtn_name, (kMaxLenVtnName + 1));
+ ckv_all_domain = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcStKeyVtn,
+ vtnkey, NULL);
+ SET_USER_DATA_CTRLR(ckv_all_domain, ctrlr_dom_in.ctrlr);
+ result_code = ReadConfigDB(ckv_all_domain, UPLL_DT_RUNNING,
+ UNC_OP_READ, op, dmi, CTRLRTBL);
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ DELETE_IF_NOT_NULL(ckv_all_domain);
+ return result_code;
+ }
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("ReadConfigDB from rename tbl failed. Error code : %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv_all_domain);
+ return result_code;
+ }
+
+ ConfigKeyVal *result_ckv = NULL;
+ for (ckv_domain = ckv_all_domain; ckv_domain;
+ ckv_domain = ckv_domain->get_next_cfg_key_val()) {
+ controller_domain ctrlr_dom_db;
+ ctrlr_dom_db.ctrlr = NULL;
+ ctrlr_dom_db.domain = NULL;
+ GET_USER_DATA_CTRLR_DOMAIN(ckv_domain, ctrlr_dom_db);
+ if (strncmp(reinterpret_cast<const char *>(ctrlr_dom_in.domain),
+ reinterpret_cast<const char *>(ctrlr_dom_db.domain),
+ kMaxLenDomainId +1) >= 0) {
+ UPLL_LOG_TRACE("ctrlr_dom_in.domain %s > ctrlr_dom_db.domain %s",
+ ctrlr_dom_in.domain, ctrlr_dom_db.domain);
+ continue;
+ }
+ UPLL_LOG_TRACE("ckv_domain in loop is \n %s",
+ ckv_domain->ToStrAll().c_str());
+ result_code = DupConfigKeyValVtnMapping(ckv_drv, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyValVtnStation failed err code %d",
+ result_code);
+ delete ckv_all_domain;
+ return result_code;
+ }
+ ckv_domain->SetCfgVal(NULL);
+ key_vtn_t *vtn_key = &(reinterpret_cast<key_vtn_controller *>
+ (ckv_drv->get_key())->vtn_key);
+ result_code = GetRenamedControllerKey(ckv_domain, UPLL_DT_RUNNING,
+ dmi, &ctrlr_dom_db);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_INFO("GetRenamedControllerKey failed err code %d", result_code);
+ delete ckv_all_domain;
+ delete ckv_drv;
+ return result_code;
+ }
+ uuu::upll_strncpy(vtn_key->vtn_name, reinterpret_cast<key_vtn_t *>
+ (ckv_domain->get_key())->vtn_name,
+ (kMaxLenVtnName + 1));
+ UPLL_LOG_TRACE("Controller id and domain id are %s %s", ctrlr_dom_db.ctrlr,
+ ctrlr_dom_db.domain);
+ uuu::upll_strncpy(reinterpret_cast<key_vtn_controller *>
+ (ckv_drv->get_key())->domain_id,
+ ctrlr_dom_db.domain, kMaxLenDomainId+1);
+ ipc_req.ckv_data = ckv_drv;
+ IpcResponse ipc_resp;
+ memset(&ipc_resp, 0, sizeof(IpcResponse));
+ if (!IpcUtil::SendReqToDriver((const char *)(ctrlr_dom_db.ctrlr),
+ reinterpret_cast<char *>(ctrlr_dom_db.domain), PFCDRIVER_SERVICE_NAME,
+ PFCDRIVER_SVID_LOGICAL, &ipc_req, true, &ipc_resp)) {
+ UPLL_LOG_INFO("Request to driver for Key %d for controller %s failed ",
+ ikey->get_key_type(),
+ reinterpret_cast<char *>(ctrlr_dom_db.ctrlr));
+ delete ckv_all_domain;
+ delete ckv_drv;
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ return ipc_resp.header.result_code;
+ }
+ if (ipc_resp.header.result_code != UPLL_RC_SUCCESS
+ && ipc_resp.header.result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_INFO("Read from driver failed err code %d",
+ ipc_resp.header.result_code);
+ delete ckv_all_domain;
+ delete ckv_drv;
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ return ipc_resp.header.result_code;
+ } else if (ipc_resp.header.result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Record Not found for domain %s", ctrlr_dom_db.domain);
+ delete ckv_drv;
+ ckv_drv = NULL;
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ continue;
+ } else if (ipc_resp.header.result_code == UPLL_RC_SUCCESS) {
+ if (ipc_resp.ckv_data == NULL) {
+ // NOTE: Is this still happening: ipc is successfull and no ckv_data?
+ delete ckv_all_domain;
+ delete ckv_drv;
+ UPLL_LOG_DEBUG("Ipc Response ckv_data is NUll %d",
+ ipc_resp.header.result_code);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ckv_drv->ResetWith(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ uint32_t rec_count_dummy = 0;
+ uint32_t *rcd = &rec_count_dummy;
+ result_code = MappingvExtTovBr(ckv_drv, header, dmi, rcd);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("MappingvExtTovBr failed result_code - %d", result_code);
+ DELETE_IF_NOT_NULL(ckv_drv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (result_ckv == NULL) {
+ result_ckv = ckv_drv;
+ } else {
+ result_ckv->AppendCfgKeyVal(ckv_drv);
+ }
+ (*ckv_count)++;
+ ckv_drv = NULL;
+ }
+ if (*ckv_count >= header->rep_count) {
+ break;
+ }
+ }
+ delete ckv_all_domain;
+ if (result_ckv) {
+ ikey->ResetWith(result_ckv);
+ DELETE_IF_NOT_NULL(result_ckv);
+ result_code = UPLL_RC_SUCCESS;
+ } else {
+ result_code = UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ }
+
+ return result_code;
+}
+
+upll_rc_t VtnMoMgr::ReadSingleCtlrlStation(IpcReqRespHeader *header,
ConfigKeyVal *ikey,
DalDmlIntf *dmi,
- uint32_t &rec_count) {
+ uint32_t *rec_count) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
controller_domain ctrlr_dom;
ctrlr_dom.ctrlr = NULL;
ctrlr_dom.domain = NULL;
- key_vtnstation_controller *stkey = NULL;
- ConfigKeyVal *ck_ctrlr = NULL;
- DbSubOp op = {kOpReadMultiple, kOpMatchCtrlr, kOpInOutCtrlr | kOpInOutDomain};
- stkey = reinterpret_cast<key_vtnstation_controller *>(ikey->get_key());
+ DbSubOp op = {kOpNotRead, kOpMatchCtrlr, kOpInOutCtrlr | kOpInOutDomain};
IpcRequest ipc_req;
memset(&ipc_req, 0, sizeof(ipc_req));
memcpy(&(ipc_req.header), header, sizeof(IpcReqRespHeader));
ipc_req.header.operation = UNC_OP_READ;
val_vtnstation_controller_st_t *in_valst = NULL;
val_vtnstation_controller_st_t *valst = NULL;
- ConfigVal *cfgval = NULL;
+ val_rename_vtn *rename_valst = NULL;
ConfigKeyVal *ckv_drv = NULL;
- bool firstcfg = true;
- /* Memory Allocation for ck_ctrlr with VTN keytype */
- if(GetChildConfigKey(ck_ctrlr, NULL)) {
- UPLL_LOG_INFO("GetChildConfigKey failed");
- return UPLL_RC_ERR_GENERIC;
- }
- /* Get the vtn or domain list from the vtn ctrlr table */
- in_valst = reinterpret_cast<val_vtnstation_controller_st_t *>(GetVal(ikey));
- if (in_valst) {
- firstcfg = true;
- if (in_valst->valid[UPLL_IDX_VTN_NAME_VSCS] == UNC_VF_VALID)
- uuu::upll_strncpy(reinterpret_cast<key_vtn *>
- (ck_ctrlr->get_key())->vtn_name, in_valst->vtn_name, (kMaxLenVtnName + 1));
- if (in_valst->valid[UPLL_IDX_DOMAIN_ID_VSCS] == UNC_VF_VALID) {
- ctrlr_dom.domain = in_valst->domain_id;
- op.matchop = kOpMatchCtrlr | kOpMatchDomain;
- }
- }
- ctrlr_dom.ctrlr = stkey->controller_name;
- SET_USER_DATA_CTRLR_DOMAIN(ck_ctrlr, ctrlr_dom);
- result_code = ReadConfigDB(ck_ctrlr, UPLL_DT_RUNNING,
- UNC_OP_READ, op, dmi, CTRLRTBL);
+ ConfigKeyVal *ckv_rename = NULL;
+ ConfigKeyVal *okey = NULL;
+ ConfigKeyVal *ckv_vbrif = NULL;
+ bool renamed = false;
+ IpcResponse ipc_resp;
+ UPLL_LOG_DEBUG("Input ikey is %s", ikey->ToStrAll().c_str());
+ result_code = DupConfigKeyValVtnStation(okey, ikey);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ReadConfigDB failed. err_code %d\n",
- result_code);
+ UPLL_LOG_DEBUG("DupConfigKeyValVtnStation failed err code %d", result_code);
return result_code;
}
- //cfgval = (ikey->get_cfg_val());
- ckv_drv = new ConfigKeyVal(UNC_KT_VTNSTATION_CONTROLLER,
- IpctSt::kIpcStKeyVtnstationController, ikey->get_key(), NULL);
- for (; ck_ctrlr; ck_ctrlr = ck_ctrlr->get_next_cfg_key_val()) {
- IpcResponse ipc_resp;
- memset(&(ipc_resp),0,sizeof(IpcResponse));
- valst = reinterpret_cast<val_vtnstation_controller_st_t *>
- (ConfigKeyVal::Malloc(sizeof(val_vtnstation_controller_st_t)));
- if (in_valst) {
- memcpy(valst, in_valst, sizeof(val_vtnstation_controller_st_t));
- if (firstcfg)
- ikey->SetCfgVal(NULL);
- firstcfg =false;
- }
- valst->valid[UPLL_IDX_VTN_NAME_VSCS] = UNC_VF_VALID;
- valst->valid[UPLL_IDX_DOMAIN_ID_VSCS] = UNC_VF_VALID;
- result_code = GetRenamedControllerKey(ck_ctrlr, UPLL_DT_RUNNING, dmi,
- &ctrlr_dom);
- if (result_code != UPLL_RC_SUCCESS && result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- UPLL_LOG_DEBUG("GetRenamedControllerKey Failed result_code - %d\n", result_code);
+ ikey->SetCfgVal(NULL);
+ ctrlr_dom.ctrlr = reinterpret_cast<key_vtnstation_controller *>
+ (okey->get_key())->controller_name;
+ ckv_rename = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcStKeyVtn, NULL, NULL);
+ if (!(okey->get_cfg_val())) {
+ UPLL_LOG_TRACE("val_vtnstation_controller_st is NULL");
+ } else if (okey->get_cfg_val()->get_st_num() ==
+ IpctSt::kIpcStValVtnstationControllerSt) {
+ in_valst = reinterpret_cast<val_vtnstation_controller_st_t *>(GetVal(okey));
+ if (!in_valst) {
+ UPLL_LOG_INFO("Input val_vtnstation_controller_st in Null");
+ DELETE_IF_NOT_NULL(ckv_rename);
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if ((in_valst->valid[UPLL_IDX_VTN_NAME_VSCS] == UNC_VF_VALID) &&
+ (in_valst->valid[UPLL_IDX_VBR_NAME_VSCS] == UNC_VF_VALID) &&
+ (in_valst->valid[UPLL_IDX_VBR_IF_NAME_VSCS] == UNC_VF_VALID)) {
+ key_vbr_if_t *vbrif_key = reinterpret_cast<key_vbr_if_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vbr_if_t)));
+ uuu::upll_strncpy(vbrif_key->vbr_key.vtn_key.vtn_name,
+ in_valst->vtn_name, (kMaxLenVtnName + 1));
+ uuu::upll_strncpy(vbrif_key->vbr_key.vbridge_name, in_valst->vbr_name,
+ (kMaxLenVnodeName + 1));
+ uuu::upll_strncpy(vbrif_key->if_name, in_valst->vbrif_name,
+ (kMaxLenInterfaceName + 1));
+ ckv_vbrif = new ConfigKeyVal(UNC_KT_VBR_IF,
+ IpctSt::kIpcStKeyVbrIf,
+ vbrif_key, NULL);
+ SET_USER_DATA_CTRLR(ckv_vbrif, ctrlr_dom.ctrlr);
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>
+ (GetMoManager(UNC_KT_VBR_IF)));
+
+ DbSubOp dbop = {kOpReadSingle, kOpMatchCtrlr,
+ kOpInOutCtrlr | kOpInOutDomain};
+ result_code = mgr->ReadConfigDB(ckv_vbrif, UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("ReadConfigDB from VbrIf tbl failed errcode %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv_vbrif);
+ DELETE_IF_NOT_NULL(ckv_rename);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ val_drv_vbr_if_t *val = reinterpret_cast<val_drv_vbr_if_t *>
+ (GetVal(ckv_vbrif));
+ if (val && (val->valid[PFCDRV_IDX_VEXT_NAME_VBRIF] == UNC_VF_VALID)) {
+ uuu::upll_strncpy(in_valst->vbrif_name, val->vex_name,
+ (kMaxLenInterfaceName + 1));
+ } else {
+ UPLL_LOG_INFO("Port Map not configured");
+ DELETE_IF_NOT_NULL(ckv_vbrif);
+ DELETE_IF_NOT_NULL(ckv_rename);
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ }
+ GET_USER_DATA_DOMAIN(ckv_vbrif, ctrlr_dom.domain);
+ ckv_vbrif->SetCfgVal(NULL);
+ result_code = mgr->GetRenamedControllerKey(ckv_vbrif, UPLL_DT_RUNNING,
+ dmi, &ctrlr_dom);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("GetRenamedControllerKey failed. Result : %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv_vbrif);
+ DELETE_IF_NOT_NULL(ckv_rename);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ uuu::upll_strncpy(in_valst->vtn_name,
+ vbrif_key->vbr_key.vtn_key.vtn_name,
+ (kMaxLenVtnName + 1));
+ uuu::upll_strncpy(in_valst->vbr_name, vbrif_key->vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+ } else if (in_valst->valid[UPLL_IDX_VTN_NAME_VSCS] == UNC_VF_VALID) {
+ key_vtn_t *vtn_key = reinterpret_cast<key_vtn_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn)));
+ uuu::upll_strncpy(vtn_key->vtn_name, in_valst->vtn_name,
+ (kMaxLenVtnName + 1));
+ op.readop = kOpReadMultiple;
+ if (in_valst->valid[UPLL_IDX_DOMAIN_ID_VSCS] == UNC_VF_VALID) {
+ ctrlr_dom.domain = in_valst->domain_id;
+ op.matchop = kOpMatchCtrlr | kOpMatchDomain;
+ op.readop = kOpReadSingle;
+ }
+ ckv_rename->SetKey(IpctSt::kIpcStKeyVtn, vtn_key);
+ SET_USER_DATA_CTRLR_DOMAIN(ckv_rename, ctrlr_dom);
+ result_code = ReadConfigDB(ckv_rename, UPLL_DT_RUNNING,
+ UNC_OP_READ, op, dmi, RENAMETBL);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_INFO("ReadConfigDB from rename tbl failed err code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv_rename);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ } else if (result_code == UPLL_RC_SUCCESS) {
+ renamed = true;
+ }
+ }
+ }
+ ConfigKeyVal *temp = ckv_rename;
+ for (; ckv_rename; ckv_rename = ckv_rename->get_next_cfg_key_val()) {
+ UPLL_LOG_TRACE("ckv_rename in loop is \n %s",
+ ckv_rename->ToStrAll().c_str());
+ memset(&(ipc_resp), 0, sizeof(IpcResponse));
+ result_code = DupConfigKeyValVtnStation(ckv_drv, okey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(temp);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(ckv_vbrif);
+ UPLL_LOG_DEBUG("DupConfigKeyValVtnStation failed. err : %d", result_code);
return result_code;
}
- GET_USER_DATA_CTRLR_DOMAIN(ck_ctrlr,ctrlr_dom);
- UPLL_LOG_DEBUG("Controller id and domain id are %s %s\n", ctrlr_dom.ctrlr,
- ctrlr_dom.domain);
- uuu::upll_strncpy(valst->vtn_name, reinterpret_cast<key_vtn_t *>
- (ck_ctrlr->get_key())->vtn_name, (kMaxLenVtnName + 1 ));
- uuu::upll_strncpy(valst->domain_id, ctrlr_dom.domain, (kMaxLenDomainId + 1));
-#if 0
- if (!cfgval) {
- cfgval = new ConfigVal(IpctSt::kIpcStValVtnSt, valst);
- } else {
- cfgval->AppendCfgVal(new ConfigVal(IpctSt::kIpcStValVtnSt, valst));
+ valst = reinterpret_cast<val_vtnstation_controller_st *>(GetVal(ckv_drv));
+ rename_valst = reinterpret_cast<val_rename_vtn *>(GetVal(ckv_rename));
+ if (renamed && (valst != NULL) && (rename_valst != NULL)) {
+ uuu::upll_strncpy(valst->vtn_name, rename_valst->new_name,
+ (kMaxLenVtnName + 1));
}
-#endif
- cfgval = new ConfigVal(IpctSt::kIpcStValVtnstationControllerSt, valst);
- ckv_drv->SetCfgVal(cfgval);
ipc_req.ckv_data = ckv_drv;
- UPLL_LOG_DEBUG("Driver Req Ckv_data is %s\n", ckv_drv->ToStrAll().c_str());
+ UPLL_LOG_DEBUG("Controller id and domain id are %s %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
if (!IpcUtil::SendReqToDriver((const char *)(ctrlr_dom.ctrlr),
- reinterpret_cast<char *>(ctrlr_dom.domain), PFCDRIVER_SERVICE_NAME,
- PFCDRIVER_SVID_LOGICAL, &ipc_req, true, &ipc_resp)) {
+ reinterpret_cast<char *>(ctrlr_dom.domain), PFCDRIVER_SERVICE_NAME,
+ PFCDRIVER_SVID_LOGICAL, &ipc_req, true, &ipc_resp)) {
UPLL_LOG_INFO("Request to driver for Key %d for controller %s failed ",
- ikey->get_key_type(), reinterpret_cast<char *>(ctrlr_dom.ctrlr));
- return ipc_resp.header.result_code;
- }
- if (ipc_resp.header.result_code != UPLL_RC_SUCCESS
- && ipc_resp.header.result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- UPLL_LOG_INFO("Read from driver failed err code %d\n",
- ipc_resp.header.result_code);
+ ikey->get_key_type(), reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ DELETE_IF_NOT_NULL(ckv_drv);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(ckv_vbrif);
+ DELETE_IF_NOT_NULL(temp);
return ipc_resp.header.result_code;
}
- else if (ipc_resp.header.result_code == UPLL_RC_SUCCESS) {
- rec_count++;
+ if (ipc_resp.header.result_code != UPLL_RC_SUCCESS
+ && ipc_resp.header.result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_INFO("Read from driver failed err code %d",
+ ipc_resp.header.result_code);
+ DELETE_IF_NOT_NULL(ckv_drv);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(ckv_vbrif);
+ DELETE_IF_NOT_NULL(temp);
+ return ipc_resp.header.result_code;
+ } else if (ipc_resp.header.result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Record Not found for domain %s", ctrlr_dom.domain);
+ result_code = ipc_resp.header.result_code;
+ DELETE_IF_NOT_NULL(ckv_drv);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ continue;
+ } else if (ipc_resp.header.result_code == UPLL_RC_SUCCESS) {
if (ipc_resp.ckv_data == NULL) {
- UPLL_LOG_DEBUG("Ipc Response ckv_data is NUll %d\n",
- ipc_resp.header.result_code);
- return UPLL_RC_ERR_GENERIC;
- }
- UPLL_LOG_DEBUG("Driver Res Ckv_data is %s\n", (ipc_resp.ckv_data)->ToStrAll().c_str());
- ckv_drv->ResetWith(ipc_resp.ckv_data);
- UPLL_LOG_DEBUG("After reset Ckv_data is %s\n", ckv_drv->ToStrAll().c_str());
- result_code = MappingvExtTovBr(ckv_drv, header, dmi);
+ UPLL_LOG_DEBUG("Ipc Response ckv_data is NUll %d",
+ ipc_resp.header.result_code);
+ DELETE_IF_NOT_NULL(ckv_drv);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(ckv_vbrif);
+ DELETE_IF_NOT_NULL(temp);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ckv_drv->ResetWith(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ result_code = MappingvExtTovBr(ckv_drv, header, dmi, rec_count);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("MappingvExtTovBr failed result_code - %d\n", result_code);
- return result_code;
+ UPLL_LOG_DEBUG("MappingvExtTovBr failed result_code - %d", result_code);
+ DELETE_IF_NOT_NULL(ckv_drv);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(ckv_vbrif);
+ DELETE_IF_NOT_NULL(temp);
+ return result_code;
}
- ikey->AppendCfgVal(ckv_drv->get_cfg_val());
- UPLL_LOG_DEBUG("ikey is %s\n", ikey->ToStrAll().c_str());
+ UPLL_LOG_TRACE("record count is %d", *rec_count);
+ ikey->AppendCfgVal(ckv_drv->GetCfgValAndUnlink());
}
- valst = NULL;
- cfgval = NULL;
+ DELETE_IF_NOT_NULL(ckv_drv);
}
+ DELETE_IF_NOT_NULL(ckv_vbrif);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(temp);
return result_code;
}
- upll_rc_t
- VtnMoMgr::ReadMo(IpcReqRespHeader * header,
- ConfigKeyVal * ikey,
- DalDmlIntf * dmi) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- controller_domain ctrlr_dom;
- ctrlr_dom.ctrlr = NULL;
- ctrlr_dom.domain = NULL;
- key_vtn_controller *mkey = NULL;
- ConfigKeyVal *ck_ctrlr = NULL;
- DbSubOp op = {kOpReadMultiple, kOpMatchCtrlr, kOpInOutCtrlr | kOpInOutDomain};
- if ((ikey->get_key_type() == UNC_KT_VTN_MAPPING_CONTROLLER) ||
- (ikey->get_key_type() == UNC_KT_VTNSTATION_CONTROLLER)) {
- result_code = ValidateMessage(header, ikey);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ValidateMessage failed result_code %d\n",
- result_code);
- return result_code;
- }
+bool
+VtnMoMgr::IsAllInvalidAttributes(const val_vtnstation_controller_st *val_stn) {
+ for (uint16_t iter = 0;
+ iter < sizeof(val_stn->valid)/sizeof(val_stn->valid[0]);
+ iter++) {
+ if (val_stn->valid[iter] != UNC_VF_INVALID) {
+ return false;
}
- IpcRequest ipc_req;
- memset(&ipc_req, 0, sizeof(ipc_req));
- memcpy(&(ipc_req.header), header, sizeof(IpcReqRespHeader));
- uint32_t rec_count = 0;
- switch(ikey->get_key_type()) {
- case UNC_KT_VTN:
- result_code = MoMgrImpl::ReadMo(header, ikey, dmi);
- return result_code;
- break;
- case UNC_KT_VTNSTATION_CONTROLLER:
+ }
+ return true;
+}
+
+upll_rc_t
+VtnMoMgr::ReadMo(IpcReqRespHeader * header,
+ ConfigKeyVal * ikey,
+ DalDmlIntf * dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ controller_domain ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ key_vtn_controller *mkey = NULL;
+ ConfigKeyVal *ck_ctrlr = NULL;
+ DbSubOp op = {kOpReadMultiple, kOpMatchCtrlr,
+ kOpInOutCtrlr | kOpInOutDomain};
+ if ((ikey->get_key_type() == UNC_KT_VTN_MAPPING_CONTROLLER) ||
+ (ikey->get_key_type() == UNC_KT_VTNSTATION_CONTROLLER)) {
+ result_code = ValidateMessage(header, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ValidateMessage failed result_code %d",
+ result_code);
+ return result_code;
+ }
+ }
+ uint32_t rec_count = 0;
+ uint32_t *tmp_count;
+ switch (ikey->get_key_type()) {
+ case UNC_KT_VTN:
+ result_code = MoMgrImpl::ReadMo(header, ikey, dmi);
+ return result_code;
+ break;
+ case UNC_KT_VTNSTATION_CONTROLLER:
+ if (header->option1 == UNC_OPT1_NORMAL ||
+ header->option1 == UNC_OPT1_DETAIL) {
result_code = ReadSingleCtlrlStation(header, ikey,
- dmi,rec_count);
- header->rep_count = rec_count;
- break;
- case UNC_KT_VTN_MAPPING_CONTROLLER:
- IpcResponse ipc_resp;
- memset(&ipc_resp, 0, sizeof(IpcResponse));
- mkey = reinterpret_cast<key_vtn_controller *>(ikey->get_key());
- ctrlr_dom.ctrlr = mkey->controller_name;
- ctrlr_dom.domain = mkey->domain_id;
- result_code = GetChildConfigKey(ck_ctrlr, ikey);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("GetChildConfigKey failed err code %d\n", result_code);
- return result_code;
- }
- op.readop = kOpReadExist;
- op.matchop = kOpMatchCtrlr | kOpMatchDomain;
- SET_USER_DATA_CTRLR_DOMAIN(ck_ctrlr, ctrlr_dom);
- result_code = UpdateConfigDB(ck_ctrlr, UPLL_DT_RUNNING,
- UNC_OP_READ, dmi, &op, CTRLRTBL);
- if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
- UPLL_LOG_DEBUG("ReadConfigDB Failed result_code - %d\n", result_code);
- return result_code;
- }
- result_code = GetRenamedControllerKey(ck_ctrlr, UPLL_DT_RUNNING, dmi,
- &ctrlr_dom);
- if (result_code != UPLL_RC_SUCCESS && result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- UPLL_LOG_DEBUG("GetRenamedControllerKey Failed result_code - %d\n", result_code);
- return result_code;
- }
- uuu::upll_strncpy(mkey->vtn_key.vtn_name,
- reinterpret_cast<key_vtn *>(ck_ctrlr->get_key())->vtn_name, (kMaxLenVtnName + 1));
- ipc_req.ckv_data = ikey;
- if (!IpcUtil::SendReqToDriver((const char *)(ctrlr_dom.ctrlr),
- reinterpret_cast<char *>(ctrlr_dom.domain), PFCDRIVER_SERVICE_NAME,
- PFCDRIVER_SVID_LOGICAL, &ipc_req, true, &ipc_resp)) {
- UPLL_LOG_INFO("Request to driver for Key %d for controller %s failed ",
- ikey->get_key_type(), reinterpret_cast<char *>(ctrlr_dom.ctrlr));
- return ipc_resp.header.result_code;
- }
- if (ipc_resp.header.result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Read from driver failed err code %d\n",
- ipc_resp.header.result_code);
+ dmi, &rec_count);
+ } else if (header->option1 == UNC_OPT1_COUNT &&
+ (GetVal(ikey) != NULL) && !IsAllInvalidAttributes(
+ reinterpret_cast<val_vtnstation_controller_st *>
+ (const_cast<void *>(GetVal(ikey))))) {
+ header->option1 = UNC_OPT1_NORMAL;
+ result_code = ReadSingleCtlrlStation(header, ikey,
+ dmi, &rec_count);
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) ?
+ UPLL_RC_SUCCESS : result_code;
+ header->option1 = UNC_OPT1_COUNT;
+ uint32_t *count =
+ reinterpret_cast<uint32_t*>(ConfigKeyVal::Malloc(sizeof(uint32_t)));
+ *count = rec_count;
+ ikey->SetCfgVal(new ConfigVal(IpctSt::kIpcStUint32, count));
+ } else if (header->option1 == UNC_OPT1_COUNT) {
+ IpcRequest ipc_req;
+ memset(&ipc_req, 0, sizeof(ipc_req));
+ memcpy(&(ipc_req.header), header, sizeof(IpcReqRespHeader));
+ IpcResponse ipc_resp;
+ memset(&ipc_resp, 0, sizeof(IpcResponse));
+ ipc_req.ckv_data = ikey;
+ ctrlr_dom.ctrlr = reinterpret_cast<key_vtnstation_controller *>
+ (ikey->get_key())->controller_name;
+ if (!IpcUtil::SendReqToDriver((const char *)(ctrlr_dom.ctrlr),
+ reinterpret_cast<char *>(ctrlr_dom.domain), PFCDRIVER_SERVICE_NAME,
+ PFCDRIVER_SVID_LOGICAL, &ipc_req, true, &ipc_resp)) {
+ UPLL_LOG_INFO("Request to driver for Key %d on controller %s failed",
+ ikey->get_key_type(), reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ return ipc_resp.header.result_code;
+ }
+ if (ipc_resp.header.result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("Read from driver failed err code %d",
+ ipc_resp.header.result_code);
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
return ipc_resp.header.result_code;
}
if (ipc_resp.ckv_data == NULL) {
- UPLL_LOG_DEBUG("Ipc Response ckv_data is NUll %d\n",
- ipc_resp.header.result_code);
+ UPLL_LOG_DEBUG("Ipc Response ckv_data is NUll %d",
+ ipc_resp.header.result_code);
return UPLL_RC_ERR_GENERIC;
}
ikey->ResetWith(ipc_resp.ckv_data);
- // To map PFC vExternal name to UNC vBridge interface name and vBridge name
- SET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
- result_code = MappingvExtTovBr(ikey, header, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("MappingvExtTovBr failed result_code - %d\n", result_code);
- return result_code;
- }
- break;
- default:
- UPLL_LOG_INFO("Invalid KeyType %d\n", ikey->get_key_type());
+ DELETE_IF_NOT_NULL(ipc_resp.ckv_data);
+ }
+ break;
+ case UNC_KT_VTN_MAPPING_CONTROLLER:
+ IpcRequest ipc_req;
+ memset(&ipc_req, 0, sizeof(ipc_req));
+ memcpy(&(ipc_req.header), header, sizeof(IpcReqRespHeader));
+ IpcResponse ipc_resp;
+ memset(&ipc_resp, 0, sizeof(IpcResponse));
+ mkey = reinterpret_cast<key_vtn_controller *>(ikey->get_key());
+ ctrlr_dom.ctrlr = mkey->controller_name;
+ ctrlr_dom.domain = mkey->domain_id;
+ result_code = GetChildConfigKey(ck_ctrlr, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(ck_ctrlr);
+ UPLL_LOG_INFO("GetChildConfigKey failed err code %d", result_code);
+ return result_code;
+ }
+ SET_USER_DATA_CTRLR_DOMAIN(ck_ctrlr, ctrlr_dom);
+ result_code = UpdateConfigDB(ck_ctrlr, UPLL_DT_RUNNING,
+ UNC_OP_READ, dmi, &op, CTRLRTBL);
+ if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
+ UPLL_LOG_DEBUG("ReadConfigDB Failed result_code - %d", result_code);
+ DELETE_IF_NOT_NULL(ck_ctrlr);
+ return result_code;
+ }
+ result_code = GetRenamedControllerKey(ck_ctrlr, UPLL_DT_RUNNING, dmi,
+ &ctrlr_dom);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetRenamedControllerKey Failed result_code - %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ck_ctrlr);
+ return result_code;
+ }
+ uuu::upll_strncpy(mkey->vtn_key.vtn_name,
+ reinterpret_cast<key_vtn *>(ck_ctrlr->get_key())->vtn_name,
+ (kMaxLenVtnName + 1));
+ ipc_req.ckv_data = ikey;
+ if (!IpcUtil::SendReqToDriver((const char *)(ctrlr_dom.ctrlr),
+ reinterpret_cast<char *>(ctrlr_dom.domain), PFCDRIVER_SERVICE_NAME,
+ PFCDRIVER_SVID_LOGICAL, &ipc_req, true, &ipc_resp)) {
+ UPLL_LOG_INFO("Request to driver for Key %d for controller %s failed ",
+ ikey->get_key_type(), reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ return ipc_resp.header.result_code;
+ }
+ if (ipc_resp.header.result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("Read from driver failed err code %d",
+ ipc_resp.header.result_code);
+ return ipc_resp.header.result_code;
+ }
+ if (ipc_resp.ckv_data == NULL) {
+ UPLL_LOG_DEBUG("Ipc Response ckv_data is NUll %d",
+ ipc_resp.header.result_code);
+ DELETE_IF_NOT_NULL(ck_ctrlr);
return UPLL_RC_ERR_GENERIC;
- }
- return result_code;
+ }
+ ikey->ResetWith(ipc_resp.ckv_data);
+ tmp_count = &rec_count;
+ result_code = MappingvExtTovBr(ikey, header, dmi, tmp_count);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("MappingvExtTovBr failed result_code - %d", result_code);
+ return result_code;
+ }
+ // header->rep_count = *tmp_count;
+ break;
+ default:
+ UPLL_LOG_INFO("Invalid KeyType %d", ikey->get_key_type());
+ DELETE_IF_NOT_NULL(ck_ctrlr);
+ return UPLL_RC_ERR_GENERIC;
}
+ return result_code;
+}
- upll_rc_t
- VtnMoMgr::ReadSiblingMo(IpcReqRespHeader *header,
- ConfigKeyVal *ikey,
- bool begin,
- DalDmlIntf *dmi) {
+upll_rc_t VtnMoMgr::ReadSiblingCount(IpcReqRespHeader *header,
+ ConfigKeyVal* ikey,
+ DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- controller_domain ctrlr_dom;
- ctrlr_dom.ctrlr = NULL;
- ctrlr_dom.domain = NULL;
- key_vtnstation_controller *stkey = NULL;
- key_vtn_controller *mkey = NULL;
- ConfigKeyVal *vtn_ckv = NULL;
- ConfigKeyVal *next_ckv = NULL;
- DbSubOp op = {kOpReadExist, kOpMatchCtrlr | kOpMatchDomain, kOpInOutNone};
- if ((ikey->get_key_type() == UNC_KT_VTN_MAPPING_CONTROLLER) ||
- (ikey->get_key_type() == UNC_KT_VTNSTATION_CONTROLLER)) {
- result_code = ValidateMessage(header, ikey);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ValidateMessage failed result_code %d\n",
- result_code);
- return result_code;
- }
- }
- uint32_t rec_count = 0;
- uint32_t count = 0;
- IpcResponse ipc_resp;
- memset(&ipc_resp, 0, sizeof(IpcResponse));
- IpcRequest ipc_req;
- memset(&ipc_req, 0, sizeof(ipc_req));
- memcpy(&(ipc_req.header), header, sizeof(IpcReqRespHeader));
- ipc_req.ckv_data = ikey;
- uuc::CtrlrMgr *ctrlr_mgr = uuc::CtrlrMgr::GetInstance();
- string ctrlr_id;
- unc_keytype_ctrtype_t ctrlrtype = UNC_CT_UNKNOWN;
- ConfigVal *tmpcval = NULL;
- key_vtnstation_controller *vtnkey = NULL;
- switch(ikey->get_key_type()) {
+ uint32_t *count;
+ switch (ikey->get_key_type()) {
case UNC_KT_VTN:
- result_code = MoMgrImpl::ReadSiblingMo(header, ikey, false, dmi);
+ result_code = MoMgrImpl::ReadSiblingCount(header, ikey, dmi);
return result_code;
break;
case UNC_KT_VTNSTATION_CONTROLLER:
- //stkey = reinterpret_cast<key_vtnstation_controller *>(ikey->get_key());
- if (header->operation == UNC_OP_READ_SIBLING_BEGIN) {
- result_code = ctrlr_mgr->GetFirstCtrlrName(UPLL_DT_RUNNING, &ctrlr_id);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("GetFirstCtrlrName failed err code %d\n", result_code);
- return result_code;
- }
- ctrlr_dom.ctrlr = reinterpret_cast<uint8_t *>(
- const_cast<char *>(ctrlr_id.c_str()));
- UPLL_LOG_DEBUG("ControllerId and DomainId are %s %s\n", ctrlr_dom.ctrlr,
- ctrlr_dom.domain);
- if ((!ctrlr_mgr->GetCtrlrType(reinterpret_cast<char *>(ctrlr_dom.ctrlr),
- UPLL_DT_RUNNING, &ctrlrtype)) || (ctrlrtype != UNC_CT_PFC)) {
- UPLL_LOG_INFO("Controller type is %d\n", ctrlrtype);
- } else {
- uuu::upll_strncpy(reinterpret_cast<key_vtnstation_controller *>
- (ikey->get_key())->controller_name, ctrlr_dom.ctrlr, (kMaxLenCtrlrId + 1));
- result_code = ReadSingleCtlrlStation(header, ikey,
- dmi,rec_count);
- }
- } else {
- ctrlr_id = reinterpret_cast<char *>(stkey->controller_name);
- }
- UPLL_LOG_DEBUG("Input Controller Id is %s\n", ctrlr_id.c_str());
- while ((UPLL_RC_SUCCESS != ctrlr_mgr->GetNextCtrlrName(ctrlr_id, UPLL_DT_RUNNING,
- &ctrlr_id)) && (count <= header->rep_count )) {
- UPLL_LOG_DEBUG("sibling Controller Id is %s\n", ctrlr_id.c_str());
- ctrlr_dom.ctrlr = reinterpret_cast<uint8_t *>(
- const_cast<char *>(ctrlr_id.c_str()));
- if ((!ctrlr_mgr->GetCtrlrType(reinterpret_cast<char *>(ctrlr_dom.ctrlr),
- UPLL_DT_RUNNING, &ctrlrtype)) || (ctrlrtype != UNC_CT_PFC)) {
- UPLL_LOG_INFO("Controller type is %d\n", ctrlrtype);
- continue;
- }
- next_ckv = ikey->get_next_cfg_key_val();
- if (!next_ckv)
- vtnkey = reinterpret_cast<key_vtnstation_controller *>
- (ConfigKeyVal::Malloc(sizeof(key_vtnstation_controller)));
- uuu::upll_strncpy(vtnkey->controller_name, ctrlr_dom.ctrlr, (kMaxLenCtrlrId + 1));
- val_vtnstation_controller_st_t *in_valst = NULL;
- in_valst = reinterpret_cast<val_vtnstation_controller_st_t *>(GetVal(ikey));
- if (in_valst) {
- val_vtnstation_controller_st_t *valst = reinterpret_cast<val_vtnstation_controller_st_t *>
- (ConfigKeyVal::Malloc(sizeof(val_vtnstation_controller_st_t)));
-
- memcpy(valst, in_valst, sizeof(val_vtnstation_controller_st_t));
- tmpcval = new ConfigVal(ikey->get_cfg_val()->get_st_num(), valst);
- }
- next_ckv = new ConfigKeyVal(ikey->get_key_type(), ikey->get_st_num(),vtnkey, tmpcval);
- result_code = ReadSingleCtlrlStation(header, next_ckv,
- dmi,rec_count);
- ikey->AppendCfgKeyVal(next_ckv);
- next_ckv = next_ckv->get_next_cfg_key_val();
- }
+ header->operation = UNC_OP_READ_SIBLING;
+ header->rep_count = UINT32_MAX;
+ result_code = ReadSiblingMo(header, ikey, false, dmi);
+ header->operation = UNC_OP_READ_SIBLING_COUNT;
+ count =
+ reinterpret_cast<uint32_t*>(ConfigKeyVal::Malloc(sizeof(uint32_t)));
+ *count = header->rep_count;
+ ikey->SetCfgVal(new ConfigVal(IpctSt::kIpcStUint32, count));
+ break;
+ default:
+ break;
+ }
+ return result_code;
+}
+upll_rc_t
+VtnMoMgr::ReadSiblingMo(IpcReqRespHeader *header,
+ ConfigKeyVal *ikey,
+ bool begin,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ controller_domain ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ ConfigKeyVal *next_ckv = NULL;
+ if ((ikey->get_key_type() == UNC_KT_VTN_MAPPING_CONTROLLER) ||
+ (ikey->get_key_type() == UNC_KT_VTNSTATION_CONTROLLER)) {
+ result_code = ValidateMessage(header, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ValidateMessage failed result_code %d",
+ result_code);
+ return result_code;
+ }
+ }
+ key_vtn_controller *mkey = NULL;
+ ConfigKeyVal *ck_ctrlr = NULL;
+ uint32_t rec_count = 0;
+ uint32_t count = 0;
+ IpcResponse ipc_resp;
+ memset(&ipc_resp, 0, sizeof(IpcResponse));
+ IpcRequest ipc_req;
+ memset(&ipc_req, 0, sizeof(ipc_req));
+ memcpy(&(ipc_req.header), header, sizeof(IpcReqRespHeader));
+ ipc_req.ckv_data = ikey;
+ uuc::CtrlrMgr *ctrlr_mgr = uuc::CtrlrMgr::GetInstance();
+ string ctrlr_id;
+ unc_keytype_ctrtype_t ctrlrtype = UNC_CT_UNKNOWN;
+ ConfigKeyVal *okey = NULL;
+ key_vtnstation_controller *vtn_stkey = NULL;
+ key_vtn_controller *vtnkey = NULL;
+ DbSubOp op = {kOpReadExist, kOpMatchNone, kOpInOutCtrlr | kOpInOutDomain};
+ switch (ikey->get_key_type()) {
+ case UNC_KT_VTN:
+ result_code = MoMgrImpl::ReadSiblingMo(header, ikey, false, dmi);
+ return result_code;
break;
- case UNC_KT_VTN_MAPPING_CONTROLLER:
- mkey = reinterpret_cast<key_vtn_controller *>(ikey->get_key());
- ctrlr_dom.ctrlr = mkey->controller_name;
- ctrlr_dom.domain = mkey->domain_id;
- result_code = ValidateMessage(header, ikey);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ValidateMessage failed result_code %d\n",
- result_code);
- return result_code;
- }
- //op = {kOpReadMultiple, kOpMatchNone, kOpInOutNone};
- result_code = GetChildConfigKey(vtn_ckv,ikey);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetChildConfigKey failed result_code - %d\n", result_code);
- return result_code;
- }
- result_code = ReadConfigDB(ikey, header->datatype, header->operation,
- op, header->rep_count, dmi, CTRLRTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("ReadConfigDb failed err code %d\n", result_code);
- }
- if ((header->operation == UNC_OP_READ_SIBLING_BEGIN) ||
- (header->operation == UNC_OP_READ_SIBLING)) {
- op.readop = kOpReadMultiple;
- #if 0
- result_code = UpdateConfigDB(vtn_ckv, UPLL_DT_RUNNING,
- UNC_OP_READ, dmi, &op, CTRLRTBL);
- if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
- UPLL_LOG_DEBUG("UpdateConfigDB for read failed result_code - %d\n", result_code);
- return result_code;
- }
- op = {kOpReadMultiple, kOpMatchNone, kOpInOutDomain | kOpInOutDomain};
- result_code = ReadConfigDB(vtn_ckv, UPLL_DT_RUNNING,
- UNC_OP_READ, dmi, &op, CTRLRTBL);
+ case UNC_KT_VTNSTATION_CONTROLLER:
+ result_code = DupConfigKeyValVtnStation(okey, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyValVtnStation failed err code %d",
+ result_code);
+ return result_code;
+ }
+ if (header->operation == UNC_OP_READ_SIBLING_BEGIN) {
+ result_code = ctrlr_mgr->GetFirstCtrlrName(UPLL_DT_RUNNING,
+ &ctrlr_id);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("ReadConfigDB Failed result_code - %d\n", result_code);
+ UPLL_LOG_INFO("GetFirstCtrlrName failed err code %d", result_code);
return result_code;
}
- #endif
+ ctrlr_dom.ctrlr = reinterpret_cast<uint8_t *>(
+ const_cast<char *>(ctrlr_id.c_str()));
+ UPLL_LOG_DEBUG("ControllerId and DomainId are %s %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+ if ((!ctrlr_mgr->GetCtrlrType(reinterpret_cast<char *>
+ (ctrlr_dom.ctrlr), UPLL_DT_RUNNING, &ctrlrtype)) ||
+ (ctrlrtype != UNC_CT_PFC)) {
+ UPLL_LOG_INFO("Controller type is %d", ctrlrtype);
+ } else {
+ uuu::upll_strncpy(reinterpret_cast<key_vtnstation_controller *>
+ (okey->get_key())->controller_name, ctrlr_dom.ctrlr,
+ (kMaxLenCtrlrId + 1));
+ result_code = ReadSingleCtlrlStation(header, okey,
+ dmi, &rec_count);
+ if (result_code == UPLL_RC_SUCCESS)
+ count++;
+ }
+ } else {
+ ctrlr_id = reinterpret_cast<char *>
+ (reinterpret_cast<key_vtnstation_controller *>
+ (okey->get_key())->controller_name);
+ }
+ UPLL_LOG_DEBUG("Input Controller Id is %s", ctrlr_id.c_str());
+ while ((UPLL_RC_SUCCESS == ctrlr_mgr->GetNextCtrlrName(ctrlr_id,
+ UPLL_DT_RUNNING, &ctrlr_id)) &&
+ (count <= header->rep_count)) {
+ UPLL_LOG_DEBUG("sibling Controller Id is %s", ctrlr_id.c_str());
+ ctrlr_dom.ctrlr = reinterpret_cast<uint8_t *>(
+ const_cast<char *>(ctrlr_id.c_str()));
+ if ((!ctrlr_mgr->GetCtrlrType(reinterpret_cast<char *>
+ (ctrlr_dom.ctrlr), UPLL_DT_RUNNING, &ctrlrtype)) ||
+ (ctrlrtype != UNC_CT_PFC)) {
+ UPLL_LOG_INFO("Controller type is %d", ctrlrtype);
+ continue;
}
- result_code = GetRenamedControllerKey(vtn_ckv, header->datatype, dmi,
- &ctrlr_dom);
+ result_code = DupConfigKeyValVtnStation(next_ckv, ikey);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("GetRenamedControllerKey Failed result_code - %d\n", result_code);
+ UPLL_LOG_DEBUG("DupConfigKeyValVtnStation failed err code %d",
+ result_code);
return result_code;
}
- uuu::upll_strncpy(mkey->vtn_key.vtn_name,
- reinterpret_cast<key_vtn *>(vtn_ckv->get_key())->vtn_name, (kMaxLenVtnName + 1));
- break;
- default:
- break;
- }
- return result_code;
- }
+ vtn_stkey = reinterpret_cast<key_vtnstation_controller *>
+ (next_ckv->get_key());
+ uuu::upll_strncpy(vtn_stkey->controller_name, ctrlr_dom.ctrlr,
+ (kMaxLenCtrlrId + 1));
+ result_code = ReadSingleCtlrlStation(header, next_ckv,
+ dmi, &rec_count);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ next_ckv = NULL;
+ continue;
+ }
+ count++;
+ okey->AppendCfgKeyVal(next_ckv);
+ next_ckv = NULL;
+ }
+ header->rep_count = count;
+ ikey->ResetWith(okey);
+ break;
+ case UNC_KT_VTN_MAPPING_CONTROLLER:
+ {
+ mkey = reinterpret_cast<key_vtn_controller *>(ikey->get_key());
+ ctrlr_dom.ctrlr = mkey->controller_name;
+ ctrlr_dom.domain = mkey->domain_id;
+ result_code = GetChildConfigKey(ck_ctrlr, ikey);
- upll_rc_t
- VtnMoMgr::MappingvExtTovBr(ConfigKeyVal * ikey,
- IpcReqRespHeader * req,
- DalDmlIntf * dmi) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone };
- MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>
- (const_cast<MoManager *>(GetMoManager(UNC_KT_VBR_IF)));
- key_vbr_if_t *key_vbrif = static_cast<key_vbr_if_t *>
- (ConfigKeyVal::Malloc(sizeof(key_vbr_if_t)));
- memset(key_vbrif, 0, sizeof(key_vbr_if_t));
- val_vtnstation_controller_st *valst = NULL;
- val_vtn_mapping_controller_st *val_map = NULL;
- if ((GetVal(ikey)) == NULL) {
- UPLL_LOG_DEBUG("Val struct is not present from driver response");
- free(key_vbrif);
- return UPLL_RC_ERR_GENERIC;
- }
- // TODO GetRenamedUncKey is pending
- if (UNC_KT_VTNSTATION_CONTROLLER == ikey->get_key_type()) {
- if (IpctSt::kIpcStValVtnstationControllerSt ==
- (ikey->get_cfg_val())->get_st_num()) {
- valst = reinterpret_cast<val_vtnstation_controller_st_t *>(
- GetVal(ikey));
- if (!valst) {
- UPLL_LOG_DEBUG("val_vtnstation_controller_st is NULL");
- free(key_vbrif);
- return UPLL_RC_ERR_GENERIC;
- }
- if ((valst->valid[UPLL_IDX_VTN_NAME_VSCS] != UNC_VF_VALID) &&
- (valst->valid[UPLL_IDX_VBR_IF_NAME_VSCS] != UNC_VF_VALID)) {
- UPLL_LOG_DEBUG("valid flag of vtn_name/vbrif_name is invalid");
- free(key_vbrif);
- return UPLL_RC_SUCCESS;
- }
- uuu::upll_strncpy(key_vbrif->vbr_key.vtn_key.vtn_name,
- valst->vtn_name,(kMaxLenVtnName + 1));
- val_drv_vbr_if_t *drv_val_vbrif = static_cast<val_drv_vbr_if_t *>
- (ConfigKeyVal::Malloc(sizeof(val_drv_vbr_if_t)));
- drv_val_vbrif->valid[2] = UNC_VF_VALID;
- uuu::upll_strncpy(drv_val_vbrif->vex_if_name,
- valst->vbrif_name, (kMaxLenInterfaceName + 1));
- ConfigKeyVal *tmpckv = new
- ConfigKeyVal(UNC_KT_VBR_IF, IpctSt::kIpcStKeyVbrIf, key_vbrif,
- new ConfigVal(IpctSt::kIpcStPfcdrvValVbrIf, drv_val_vbrif));
- if (tmpckv == NULL) {
- if (key_vbrif) free(key_vbrif);
- return UPLL_RC_ERR_GENERIC;
- }
- result_code = mgr->ReadConfigDB(tmpckv, req->datatype,
- UNC_OP_READ, dbop, dmi, MAINTBL);
+ /* Addressed coverity REVERSE_INULL issue */
+ if (!ck_ctrlr || result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("GetChildConfigKey failed err code %d", result_code);
+ DELETE_IF_NOT_NULL(ck_ctrlr);
+ return result_code;
+ }
+ SET_USER_DATA_CTRLR_DOMAIN(ck_ctrlr, ctrlr_dom);
+ #if 0
+ if (header->operation == UNC_OP_READ_SIBLING_BEGIN)
+ op.matchop = kOpMatchNone;
+ #endif
+ result_code = UpdateConfigDB(ck_ctrlr, UPLL_DT_RUNNING,
+ UNC_OP_READ, dmi, &op, CTRLRTBL);
+ if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
+ UPLL_LOG_DEBUG("ReadConfigDB Failed result_code - %d", result_code);
+ DELETE_IF_NOT_NULL(ck_ctrlr);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(ck_ctrlr);
+ // SET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+ result_code = DupConfigKeyValVtnMapping(okey, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyValVtnMapping failed err code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ bool okey_mapped = false;
+ if (header->operation == UNC_OP_READ_SIBLING_BEGIN) {
+ result_code = ctrlr_mgr->GetFirstCtrlrName(
+ UPLL_DT_RUNNING, &ctrlr_id);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("vbrif ReadConfigDB Failed result_code - %d\n",
- result_code);
- delete tmpckv;
- return UPLL_RC_SUCCESS;
+ UPLL_LOG_INFO("GetFirstCtrlrName failed err code %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
}
- key_vbr_if_t *vbrif_key = reinterpret_cast<key_vbr_if_t *>
- (tmpckv->get_key());
- if (vbrif_key) {
- uuu::upll_strncpy(valst->vbr_name, vbrif_key->vbr_key.vbridge_name,
- (kMaxLenVnodeName + 1));
- uuu::upll_strncpy(valst->vbrif_name, vbrif_key->if_name,
- (kMaxLenInterfaceName + 1));
+ ctrlr_dom.ctrlr = reinterpret_cast<uint8_t *>(
+ const_cast<char *>(ctrlr_id.c_str()));
+ ctrlr_dom.domain = reinterpret_cast<uint8_t *>
+ (const_cast<char *>(" "));
+ SET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
+ UPLL_LOG_TRACE("ControllerId and DomainId are %s %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+ if ((ctrlr_mgr->GetCtrlrType(reinterpret_cast<char *>
+ (ctrlr_dom.ctrlr), UPLL_DT_RUNNING, &ctrlrtype)) &&
+ (ctrlrtype == UNC_CT_PFC)) {
+ uuu::upll_strncpy(reinterpret_cast<key_vtn_controller *>
+ (okey->get_key())->controller_name, ctrlr_dom.ctrlr,
+ (kMaxLenCtrlrId + 1));
+ result_code = ReadSingleCtlrlVtnMapping(header, okey,
+ dmi, &rec_count);
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE &&
+ result_code != UPLL_RC_SUCCESS) {
+ delete okey;
+ return result_code;
+ } else if (result_code == UPLL_RC_SUCCESS) {
+ okey_mapped = true;
+ }
}
- delete tmpckv;
- }
- } else if (UNC_KT_VTN_MAPPING_CONTROLLER == ikey->get_key_type()) {
- if (IpctSt::kIpcStValVtnMappingControllerSt ==
- (ikey->get_cfg_val())->get_st_num()) {
- val_map = reinterpret_cast<val_vtn_mapping_controller_st_t *>
- (GetVal(ikey));
- // Valid flag check before accessing the driver reponse val
- if (val_map->valid[UPLL_IDX_VBR_IF_NAME_VMCS] != UNC_VF_VALID) {
- UPLL_LOG_DEBUG("valid flag of vbrif_name is invalid");
- free(key_vbrif);
- return UPLL_RC_SUCCESS;
+ } else {
+ // check if user given controller can be used.
+ ctrlr_id = reinterpret_cast<char *>
+ (reinterpret_cast<key_vtn_controller *>
+ (okey->get_key())->controller_name);
+ UPLL_LOG_TRACE("Controller Name is %s", ctrlr_id.c_str());
+ ctrlr_dom.ctrlr = reinterpret_cast<uint8_t *>(
+ const_cast<char *>(ctrlr_id.c_str()));
+
+ if ((ctrlr_mgr->GetCtrlrType(reinterpret_cast<char *>
+ (ctrlr_dom.ctrlr), UPLL_DT_RUNNING, &ctrlrtype)) &&
+ (ctrlrtype == UNC_CT_PFC)) {
+ UPLL_LOG_INFO("Controller type is %d", ctrlrtype);
+ // return UPLL_RC_ERR_GENERIC;
+ ctrlr_dom.domain = reinterpret_cast<key_vtn_controller *>
+ (okey->get_key())->domain_id;
+ UPLL_LOG_TRACE("Domain name is %s", ctrlr_dom.domain);
+ SET_USER_DATA_CTRLR_DOMAIN(okey, ctrlr_dom);
+
+ result_code = ReadSingleCtlrlVtnMapping(header, okey,
+ dmi, &rec_count);
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE &&
+ result_code != UPLL_RC_SUCCESS) {
+ delete okey;
+ return result_code;
+ } else if (result_code == UPLL_RC_SUCCESS) {
+ okey_mapped = true;
+ }
+ }
+ }
+ UPLL_LOG_DEBUG("Input controller id is %s", ctrlr_id.c_str());
+ while ((UPLL_RC_SUCCESS == ctrlr_mgr->GetNextCtrlrName(ctrlr_id,
+ UPLL_DT_RUNNING, &ctrlr_id)) &&
+ (rec_count < header->rep_count)) {
+ UPLL_LOG_DEBUG("Sibling controller id is %s", ctrlr_id.c_str());
+ ctrlr_dom.ctrlr = reinterpret_cast<uint8_t *>(
+ const_cast<char *>(ctrlr_id.c_str()));
+ if (!ctrlr_mgr->GetCtrlrType(reinterpret_cast<char*>(ctrlr_dom.ctrlr),
+ UPLL_DT_RUNNING, &ctrlrtype)) {
+ continue;
}
- uuu::upll_strncpy(key_vbrif->vbr_key.vtn_key.vtn_name,
- reinterpret_cast<key_vtn_controller *>
- (ikey->get_key())->vtn_key.vtn_name,
- (kMaxLenVtnName + 1));
- val_drv_vbr_if_t *drv_val_vbrif = static_cast<val_drv_vbr_if_t *>
- (ConfigKeyVal::Malloc(sizeof(val_drv_vbr_if_t)));
- uuu::upll_strncpy(drv_val_vbrif->vex_if_name,
- val_map->vbrif_name, (kMaxLenInterfaceName + 1));
- ConfigKeyVal *tmpckv = new
- ConfigKeyVal(UNC_KT_VBR_IF, IpctSt::kIpcStKeyVbrIf, key_vbrif,
- new ConfigVal(IpctSt::kIpcStPfcdrvValVbrIf, drv_val_vbrif));
- if (tmpckv == NULL) {
- if (key_vbrif) free(key_vbrif);
- return UPLL_RC_ERR_GENERIC;
+ if (ctrlrtype != UNC_CT_PFC) {
+ UPLL_LOG_INFO("Controller type is %d", ctrlrtype);
+ continue;
}
- result_code = mgr->ReadConfigDB(tmpckv, req->datatype,
- UNC_OP_READ, dbop, dmi, MAINTBL);
+ ctrlr_dom.domain = reinterpret_cast<uint8_t *>
+ (const_cast<char *>(" "));
+ SET_USER_DATA_CTRLR_DOMAIN(ikey, ctrlr_dom);
+ result_code = DupConfigKeyValVtnMapping(next_ckv, ikey);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("vbrif ReadConfigDB Failed result_code - %d\n",
- result_code);
- delete tmpckv;
- return UPLL_RC_SUCCESS;
+ UPLL_LOG_DEBUG("DupConfigKeyValVtnStation failed"
+ " err code %d", result_code);
+ delete okey;
+ DELETE_IF_NOT_NULL(next_ckv);
+ return result_code;
}
- UPLL_LOG_DEBUG("tmpckv value is %s\n", tmpckv->ToStrAll().c_str());
- key_vbr_if_t *vbrif_key = reinterpret_cast<key_vbr_if_t *>
- (GetVal(tmpckv));
- if (vbrif_key) {
- uuu::upll_strncpy(val_map->vbr_name, vbrif_key->vbr_key.vbridge_name,
- (kMaxLenVnodeName + 1));
- uuu::upll_strncpy(val_map->vbrif_name, vbrif_key->if_name,
- (kMaxLenInterfaceName + 1));
+ vtnkey = reinterpret_cast<key_vtn_controller *>(next_ckv->get_key());
+ uuu::upll_strncpy(vtnkey->controller_name, ctrlr_dom.ctrlr,
+ (kMaxLenCtrlrId + 1));
+ uuu::upll_strncpy(vtnkey->domain_id, ctrlr_dom.domain,
+ (kMaxLenDomainId + 1));
+ result_code = ReadSingleCtlrlVtnMapping(header, next_ckv, dmi,
+ &rec_count);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ delete okey;
+ DELETE_IF_NOT_NULL(next_ckv);
+ return result_code;
+ } else if (result_code == UPLL_RC_SUCCESS) {
+ if (!okey_mapped) {
+ /* This recent ReadSingleCtlrlVtnMapping gave result,
+ ** but not the previous ones
+ */
+ DELETE_IF_NOT_NULL(okey);
+ okey = next_ckv;
+ okey_mapped = true;
+ } else {
+ okey->AppendCfgKeyVal(next_ckv);
+ }
}
- delete tmpckv;
+ next_ckv = NULL;
}
- } else {
- free(key_vbrif);
+ if (rec_count != 0) {
+ header->rep_count = rec_count;
+ ikey->ResetWith(okey);
+ DELETE_IF_NOT_NULL(okey);
+ result_code = UPLL_RC_SUCCESS;
+ } else {
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(next_ckv);
+ if (result_code == UPLL_RC_SUCCESS ||
+ result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ result_code = UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ }
+ }
+ break;
}
- return result_code;
+ default:
+ return UPLL_RC_ERR_GENERIC;
+ break;
}
- /* Semantic check for the VTN Delete operation */
- upll_rc_t
- VtnMoMgr::IsReferenced(ConfigKeyVal *ikey,
- upll_keytype_datatype_t dt_type,
- DalDmlIntf *dmi) {
- return UPLL_RC_SUCCESS;
- /* Overlay support is not added yet. Returning success for now */
-#if 0
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- ConfigKeyVal *okey = NULL;
- if ( NULL == ikey)
- return UPLL_RC_ERR_GENERIC;
- /* Create the Vtunnel Configkey for checking vtn is underlay vtn or not */
- result_code = CreateVtunnelKey(ikey, okey);
- MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>
- (const_cast<MoManager *>(GetMoManager(UNC_KT_VTUNNEL)));
- DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutNone};
- /* Checks the given vtn is exists or not */
- result_code = mgr->ReadConfigDB(okey, dt_type, UNC_OP_READ,
- dbop, dmi, MAINTBL);
- if ( UPLL_RC_ERR_INSTANCE_EXISTS == result_code )
- return UPLL_RC_ERR_CFG_SEMANTIC;
+ return result_code;
+}
- if (NULL != okey) {
- free(okey->get_key());
- delete okey;
- okey = NULL;
+upll_rc_t
+VtnMoMgr::MappingvExtTovBr(ConfigKeyVal * ikey,
+ IpcReqRespHeader * req,
+ DalDmlIntf * dmi, uint32_t *&rec_count) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone };
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VBR_IF)));
+ val_vtnstation_controller_st *valst = NULL;
+ val_vtn_mapping_controller_st *val_map = NULL;
+ key_vbr_if_t *key_vbrif = NULL;
+ ConfigKeyVal *tmpckv = NULL;
+ if ((GetVal(ikey)) == NULL) {
+ UPLL_LOG_DEBUG("Val struct is not present from driver response");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigVal *tmp_cval = NULL;
+ UPLL_LOG_DEBUG("ikey in MappingvExtTovBr is %s", ikey->ToStrAll().c_str());
+ for (tmp_cval = ikey->get_cfg_val(); tmp_cval;
+ tmp_cval = tmp_cval->get_next_cfg_val()) {
+ if (UNC_KT_VTNSTATION_CONTROLLER == ikey->get_key_type()) {
+ UPLL_LOG_DEBUG("KetType Matched %d", ikey->get_key_type());
+ if (IpctSt::kIpcStValVtnstationControllerSt ==
+ tmp_cval->get_st_num()) {
+ (*rec_count)++;
+ UPLL_LOG_DEBUG("record count is %d", *rec_count);
+ valst = reinterpret_cast<val_vtnstation_controller_st_t *>(
+ tmp_cval->get_val());
+ if (!valst) {
+ UPLL_LOG_DEBUG("val_vtnstation_controller_st is NULL");
+ ConfigKeyVal::Free(key_vbrif);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (valst->map_type == UPLL_IF_VLAN_MAP)
+ continue;
+ if ((valst->valid[UPLL_IDX_VTN_NAME_VSCS] != UNC_VF_VALID) &&
+ (valst->valid[UPLL_IDX_VBR_IF_NAME_VSCS] != UNC_VF_VALID)) {
+ UPLL_LOG_DEBUG("valid flag of vtn_name/vbrif_name is invalid");
+ ConfigKeyVal::Free(key_vbrif);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t *ctrlr_id = reinterpret_cast<key_vtnstation_controller *>
+ (ikey->get_key())->controller_name;
+ key_vtn_t *vtnkey = reinterpret_cast<key_vtn_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn_t)));
+ uuu::upll_strncpy(vtnkey->vtn_name,
+ valst->vtn_name, (kMaxLenVtnName + 1));
+ ConfigKeyVal *ckv_rename = new ConfigKeyVal(UNC_KT_VTN,
+ IpctSt::kIpcStKeyVtn, vtnkey, NULL);
+ result_code = GetRenamedUncKey(ckv_rename, UPLL_DT_RUNNING,
+ dmi, ctrlr_id);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_INFO("GetRenamedUncKey failed error code %d", result_code);
+ if (ckv_rename) delete ckv_rename;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(valst->vtn_name, reinterpret_cast<key_vtn_t *>
+ (ckv_rename->get_key())->vtn_name,
+ (kMaxLenVtnName + 1));
+ key_vbrif = static_cast<key_vbr_if_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vbr_if_t)));
+ uuu::upll_strncpy(key_vbrif->vbr_key.vtn_key.vtn_name,
+ valst->vtn_name, (kMaxLenVtnName + 1));
+ val_drv_vbr_if_t *drv_val_vbrif = static_cast<val_drv_vbr_if_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_drv_vbr_if_t)));
+ drv_val_vbrif->valid[PFCDRV_IDX_VEXT_NAME_VBRIF] = UNC_VF_VALID;
+ uuu::upll_strncpy(drv_val_vbrif->vex_name,
+ valst->vbrif_name, (kMaxLenInterfaceName + 1));
+ tmpckv = new
+ ConfigKeyVal(UNC_KT_VBR_IF, IpctSt::kIpcStKeyVbrIf, key_vbrif,
+ new ConfigVal(IpctSt::kIpcStPfcdrvValVbrIf, drv_val_vbrif));
+ UPLL_LOG_DEBUG("tmpckv is %s", tmpckv->ToStrAll().c_str());
+ result_code = mgr->ReadConfigDB(tmpckv, req->datatype,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("vbrif ReadConfigDB Failed result_code - %d",
+ result_code);
+ delete tmpckv;
+ delete ckv_rename;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ key_vbr_if_t *vbrif_key = reinterpret_cast<key_vbr_if_t *>
+ (tmpckv->get_key());
+ if (vbrif_key) {
+ valst->valid[UPLL_IDX_VBR_NAME_VSCS] = UNC_VF_VALID;
+ uuu::upll_strncpy(valst->vbr_name, vbrif_key->vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+ uuu::upll_strncpy(valst->vbrif_name, vbrif_key->if_name,
+ (kMaxLenInterfaceName + 1));
+ }
+ delete tmpckv;
+ delete ckv_rename;
+ key_vbrif = NULL;
+ tmpckv = NULL;
+ }
+ } else if (UNC_KT_VTN_MAPPING_CONTROLLER == ikey->get_key_type()) {
+ UPLL_LOG_DEBUG("KetType Matched %d", ikey->get_key_type());
+ if (IpctSt::kIpcStValVtnMappingControllerSt ==
+ tmp_cval->get_st_num()) {
+ val_map = reinterpret_cast<val_vtn_mapping_controller_st_t *>
+ (tmp_cval->get_val());
+ if (!val_map) {
+ UPLL_LOG_DEBUG("val_vtn_mapping_controller_st is NULL");
+ ConfigKeyVal::Free(key_vbrif);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (val_map->map_type == UPLL_IF_VLAN_MAP)
+ continue;
+ // Valid flag check before accessing the driver reponse val
+ if (val_map->valid[UPLL_IDX_VBR_IF_NAME_VMCS] != UNC_VF_VALID) {
+ UPLL_LOG_DEBUG("valid flag of vbrif_name is invalid");
+ ConfigKeyVal::Free(key_vbrif);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ (*rec_count)++;
+ UPLL_LOG_DEBUG("record count is %d", *rec_count);
+ key_vbrif = static_cast<key_vbr_if_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vbr_if_t)));
+ uint8_t *ctrlr_id = reinterpret_cast<key_vtn_controller *>
+ (ikey->get_key())->controller_name;
+ key_vtn_t *vtnkey = reinterpret_cast<key_vtn_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn_t)));
+ uuu::upll_strncpy(vtnkey->vtn_name,
+ reinterpret_cast<key_vtn_controller *>
+ (ikey->get_key())->vtn_key.vtn_name,
+ (kMaxLenVtnName + 1));
+ ConfigKeyVal *ckv_rename = new ConfigKeyVal(UNC_KT_VTN,
+ IpctSt::kIpcStKeyVtn, vtnkey, NULL);
+ result_code = GetRenamedUncKey(ckv_rename, UPLL_DT_RUNNING,
+ dmi, ctrlr_id);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_INFO("GetRenamedUncKey failed. Error : %d", result_code);
+ if (ckv_rename) delete ckv_rename;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(reinterpret_cast<key_vtn_controller *>
+ (ikey->get_key())->vtn_key.vtn_name,
+ reinterpret_cast<key_vtn_t *>
+ (ckv_rename->get_key())->vtn_name,
+ (kMaxLenVtnName + 1));
+ uuu::upll_strncpy(key_vbrif->vbr_key.vtn_key.vtn_name,
+ reinterpret_cast<key_vtn_controller *>
+ (ikey->get_key())->vtn_key.vtn_name,
+ (kMaxLenVtnName + 1));
+ val_drv_vbr_if_t *drv_val_vbrif = static_cast<val_drv_vbr_if_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_drv_vbr_if_t)));
+ drv_val_vbrif->valid[PFCDRV_IDX_VEXT_NAME_VBRIF] = UNC_VF_VALID;
+ uuu::upll_strncpy(drv_val_vbrif->vex_name,
+ val_map->vbrif_name, (kMaxLenInterfaceName + 1));
+ tmpckv = new ConfigKeyVal(UNC_KT_VBR_IF, IpctSt::kIpcStKeyVbrIf,
+ key_vbrif,
+ new ConfigVal(IpctSt::kIpcStPfcdrvValVbrIf,
+ drv_val_vbrif));
+ result_code = mgr->ReadConfigDB(tmpckv, req->datatype,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("vbrif ReadConfigDB Failed result_code - %d",
+ result_code);
+ delete ckv_rename;
+ delete tmpckv;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_DEBUG("tmpckv value is %s", tmpckv->ToStrAll().c_str());
+ key_vbr_if_t *vbrif_key = reinterpret_cast<key_vbr_if_t *>
+ (tmpckv->get_key());
+ if (vbrif_key) {
+ val_map->valid[UPLL_IDX_VBR_NAME_VMCS] = UNC_VF_VALID;
+ uuu::upll_strncpy(val_map->vbr_name,
+ vbrif_key->vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+ uuu::upll_strncpy(val_map->vbrif_name, vbrif_key->if_name,
+ (kMaxLenInterfaceName + 1));
+ }
+ delete tmpckv;
+ delete ckv_rename;
+ key_vbrif = NULL;
+ tmpckv = NULL;
+ }
}
+ }
+ return result_code;
+}
+
+/* Semantic check for the VTN Delete operation */
+upll_rc_t
+VtnMoMgr::IsReferenced(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *okey = NULL;
+ if (NULL == ikey || !dmi)
+ return UPLL_RC_ERR_GENERIC;
+ /* Create the Vtunnel Configkey for checking vtn is underlay vtn or not */
+ result_code = CreateVtunnelKey(ikey, okey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Could not Create VtunnelKey %d", result_code);
return result_code;
-#endif
}
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VTUNNEL)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Instance is Null");
+ delete okey;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutNone};
+ /* Checks the given vtn is exists or not */
+ result_code = mgr->ReadConfigDB(okey, dt_type, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS == result_code) {
+ UPLL_LOG_DEBUG("Could not delete an Underlay Vtn referenced to "
+ " an Overlay Vtn");
+ delete okey;
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
+ UPLL_RC_SUCCESS:result_code;
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+}
- /* This function creates the configkey for the vtunnel
- * This funciton take the vtn name and addit into the Vtunnel
- * value structure
- */
- upll_rc_t
- VtnMoMgr::CreateVtunnelKey(ConfigKeyVal * ikey,
- ConfigKeyVal * &okey) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- ConfigVal *tmp;
- if (!ikey || !(ikey->get_key()))
- return UPLL_RC_ERR_GENERIC;
+/* This function creates the configkey for the vtunnel
+ * This funciton take the vtn name and addit into the Vtunnel
+ * value structure
+ */
+upll_rc_t
+VtnMoMgr::CreateVtunnelKey(ConfigKeyVal *ikey,
+ ConfigKeyVal *&okey) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigVal *tmp;
+ if (!ikey || !(ikey->get_key()))
+ return UPLL_RC_ERR_GENERIC;
- key_vtunnel_t *vtunnel_key = reinterpret_cast<key_vtunnel_t *>
- (ConfigKeyVal::Malloc(sizeof(key_vtunnel_t)));
- val_vtunnel_t *vtn_val_vtunnel = reinterpret_cast<val_vtunnel_t *>
- (ConfigKeyVal::Malloc(sizeof(val_vtunnel_t)));
- /* validate message taken care of vtn lengh checking*/
- uuu::upll_strncpy(
- vtn_val_vtunnel->vtn_name,
- reinterpret_cast<key_vtn_t *>
- (ikey->get_key())->vtn_name, (kMaxLenVtnName+1));
- vtn_val_vtunnel->valid[UPLL_IDX_LABEL_VTNL] = UNC_VF_VALID; // == to =
-
- tmp = new ConfigVal(IpctSt::kIpcStValVtunnel, vtn_val_vtunnel);
- okey = new ConfigKeyVal(UNC_KT_VTUNNEL, IpctSt::kIpcStKeyVtunnel,
- vtunnel_key, tmp);
- if (!okey) {
- free(vtunnel_key);
- free(vtn_val_vtunnel);
- delete tmp;
- return UPLL_RC_ERR_GENERIC;
- }
- SET_USER_DATA(okey, ikey);
- return result_code;
+ key_vtunnel_t *vtunnel_key = reinterpret_cast<key_vtunnel_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtunnel_t)));
+ val_vtunnel_t *vtn_val_vtunnel = reinterpret_cast<val_vtunnel_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtunnel_t)));
+ /* validate message taken care of vtn lengh checking*/
+ uuu::upll_strncpy(
+ vtn_val_vtunnel->vtn_name,
+ reinterpret_cast<key_vtn_t *>
+ (ikey->get_key())->vtn_name, (kMaxLenVtnName+1));
+ vtn_val_vtunnel->valid[UPLL_IDX_VTN_NAME_VTNL] = UNC_VF_VALID;
+
+ tmp = new ConfigVal(IpctSt::kIpcStValVtunnel, vtn_val_vtunnel);
+ if (!tmp) {
+ UPLL_LOG_ERROR("Memory Allocation failed for tmp1");
+ FREE_IF_NOT_NULL(vtunnel_key);
+ FREE_IF_NOT_NULL(vtn_val_vtunnel);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ okey = new ConfigKeyVal(UNC_KT_VTUNNEL, IpctSt::kIpcStKeyVtunnel,
+ vtunnel_key, tmp);
+ if (!okey) {
+ delete tmp;
+ FREE_IF_NOT_NULL(vtunnel_key);
+ return UPLL_RC_ERR_GENERIC;
}
+ SET_USER_DATA(okey, ikey);
+ return result_code;
+}
- upll_rc_t
- VtnMoMgr::SwapKeyVal(ConfigKeyVal *ikey,
- ConfigKeyVal *&okey,
- DalDmlIntf *dmi,
- uint8_t *ctrlr,
- bool &no_rename) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- // ConfigVal *tmp1;
- okey = NULL;
- if (!ikey || !(ikey->get_key()) || !(strlen(reinterpret_cast<const char *>
- (ctrlr)))) {
- UPLL_LOG_DEBUG("Input is NULL");
- return UPLL_RC_ERR_GENERIC;
- }
- if (ikey->get_key_type() != UNC_KT_VTN) {
- UPLL_LOG_DEBUG("Bad Request");
- return UPLL_RC_ERR_BAD_REQUEST;
- }
- ConfigVal *cfg_val = ikey->get_cfg_val();
- if (cfg_val == NULL) {
- UPLL_LOG_DEBUG("Configval is NULL");
- return UPLL_RC_ERR_BAD_REQUEST;
- }
- val_rename_vtn_t *tval = reinterpret_cast<val_rename_vtn_t *>
- (cfg_val->get_val());
- if (!tval) {
- UPLL_LOG_DEBUG("Val is NULL");
- return UPLL_RC_ERR_GENERIC;
- }
- key_vtn_t *key_vtn = reinterpret_cast<key_vtn_t *>
- (ConfigKeyVal::Malloc(sizeof(key_vtn_t)));
- /* No rename */
- if (tval->valid[UPLL_IDX_NEW_NAME_RVTN] == UNC_VF_VALID_NO_VALUE) {
- no_rename = true;
- uuu::upll_strncpy(key_vtn->vtn_name,
- ((reinterpret_cast<key_vtn_t*>(ikey->get_key()))->vtn_name),
- (kMaxLenVtnName + 1));
- UPLL_LOG_DEBUG("No Rename Operation %d", no_rename);
- } else {
- if ( tval->valid[UPLL_IDX_NEW_NAME_RVTN] == UNC_VF_VALID ) {
- // checking the string is empty or not
- if (!strlen(reinterpret_cast<char *>(tval->new_name))) {
- free(key_vtn);
- return UPLL_RC_ERR_GENERIC;
- }
- uuu::upll_strncpy(key_vtn->vtn_name, tval->new_name,
- (kMaxLenVtnName + 1));
- // copy the new UNC name to KeyVtn
- /* The New Name and PFC name should not be same name */
- if (!strcmp(reinterpret_cast<char *>
- ((reinterpret_cast<key_vtn_t *>(ikey->get_key()))->vtn_name),
- reinterpret_cast<char *>(tval->new_name))) {
- free(key_vtn);
- return UPLL_RC_ERR_GENERIC;
- }
- } else {
- UPLL_LOG_DEBUG("Invalid Input");
- free(key_vtn);
+upll_rc_t
+VtnMoMgr::SwapKeyVal(ConfigKeyVal *ikey,
+ ConfigKeyVal *&okey,
+ DalDmlIntf *dmi,
+ uint8_t *ctrlr,
+ bool &no_rename) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ // ConfigVal *tmp1;
+ okey = NULL;
+ if (!ikey || !(ikey->get_key()) || !(strlen(reinterpret_cast<const char *>
+ (ctrlr)))) {
+ UPLL_LOG_DEBUG("Input is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (ikey->get_key_type() != UNC_KT_VTN) {
+ UPLL_LOG_DEBUG("Bad Request");
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ ConfigVal *cfg_val = ikey->get_cfg_val();
+ if (cfg_val == NULL) {
+ UPLL_LOG_DEBUG("Configval is NULL");
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ val_rename_vtn_t *tval = reinterpret_cast<val_rename_vtn_t *>
+ (cfg_val->get_val());
+ if (!tval) {
+ UPLL_LOG_DEBUG("Val is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ key_vtn_t *key_vtn = reinterpret_cast<key_vtn_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn_t)));
+ /* No rename */
+ if (tval->valid[UPLL_IDX_NEW_NAME_RVTN] == UNC_VF_VALID_NO_VALUE) {
+ no_rename = true;
+ uuu::upll_strncpy(key_vtn->vtn_name,
+ ((reinterpret_cast<key_vtn_t*>(ikey->get_key()))->vtn_name),
+ (kMaxLenVtnName + 1));
+ UPLL_LOG_DEBUG("No Rename Operation %d", no_rename);
+ } else {
+ if ( tval->valid[UPLL_IDX_NEW_NAME_RVTN] == UNC_VF_VALID ) {
+ // checking the string is empty or not
+ if (!strlen(reinterpret_cast<char *>(tval->new_name))) {
+ ConfigKeyVal::Free(key_vtn);
return UPLL_RC_ERR_GENERIC;
}
- }
- okey = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcStKeyVtn, key_vtn, NULL);
- if (!okey) {
- free(key_vtn);
+ uuu::upll_strncpy(key_vtn->vtn_name, tval->new_name,
+ (kMaxLenVtnName + 1));
+ // copy the new UNC name to KeyVtn
+ /* The New Name and PFC name should not be same name */
+ if (!strcmp(reinterpret_cast<char *>
+ ((reinterpret_cast<key_vtn_t *>(ikey->get_key()))->vtn_name),
+ reinterpret_cast<char *>(tval->new_name))) {
+ ConfigKeyVal::Free(key_vtn);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ } else {
+ UPLL_LOG_DEBUG("Invalid Input");
+ ConfigKeyVal::Free(key_vtn);
return UPLL_RC_ERR_GENERIC;
}
- return result_code;
}
+ okey = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcStKeyVtn, key_vtn, NULL);
+ return result_code;
+}
- bool VtnMoMgr::FilterAttributes(void *&val1,
- void *val2,
- bool copy_to_running,
- unc_keytype_operation_t op) {
- val_vtn_t *val_vtn1 = reinterpret_cast<val_vtn_t *>(val1);
- val_vtn1->valid[UPLL_IDX_DESC_VTN] = UNC_VF_INVALID;
- // to be uncommented when vtn supports other attributes other than description
-#if 0
- val_vtn_ctrlr *ctrlr_val = reinterpret_cast<val_vtn_ctrlr_t *>(val2);
- for (unsigned int loop = 0;
- loop < sizeof(val_vtn1->valid)/sizeof(val_vtn1->valid[0]);
- ++loop) {
- if (ctrlr_val->cs_attr[loop] == UNC_CS_NOT_SUPPORTED)
- val_vtn1->valid[loop] = UNC_VF_INVALID;
- }
- if (op != UNC_OP_CREATE)
- return CompareValidValue(val1, val2, copy_to_running);
-#endif
- return false;
+bool VtnMoMgr::FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op) {
+ val_vtn_t *val_vtn1 = reinterpret_cast<val_vtn_t *>(val1);
+ val_vtn1->valid[UPLL_IDX_DESC_VTN] = UNC_VF_INVALID;
+ // to be uncommented when vtn supports other attributes
+ // other than description
+#if 0
+ val_vtn_ctrlr *ctrlr_val = reinterpret_cast<val_vtn_ctrlr_t *>(val2);
+ for (unsigned int loop = 0;
+ loop < sizeof(val_vtn1->valid)/sizeof(val_vtn1->valid[0]);
+ ++loop) {
+ if (ctrlr_val->cs_attr[loop] == UNC_CS_NOT_SUPPORTED)
+ val_vtn1->valid[loop] = UNC_VF_INVALID;
}
+ if (op != UNC_OP_CREATE)
+ return CompareValidValue(val1, val2, copy_to_running);
+#endif
+ return false;
+}
- // TODO(l): This function may not be required for VTN
- // since VTN has only description which should not go to driver
- bool VtnMoMgr::CompareValidValue(void *&val1, void *val2, bool copy_to_running) {
- UPLL_FUNC_TRACE;
- bool invalid_attr = true;
- val_vtn_t *val_vtn1 = reinterpret_cast<val_vtn_t *>(val1);
- val_vtn_t *val_vtn2 = reinterpret_cast<val_vtn_t *>(val2);
- val_vtn_index vtn_description = UPLL_IDX_DESC_VTN;
- if (UNC_VF_INVALID == val_vtn1->valid[vtn_description] &&
- UNC_VF_VALID == val_vtn2->valid[vtn_description])
- val_vtn1->valid[vtn_description] = UNC_VF_VALID_NO_VALUE;
- if ( (UNC_VF_VALID == val_vtn1->valid[vtn_description]) &&
- (UNC_VF_VALID == val_vtn2->valid[vtn_description])) {
- if (!strcmp(reinterpret_cast<char*>(val_vtn1->description),
- reinterpret_cast<char*>(val_vtn2->description)) )
- val_vtn1->valid[vtn_description] = UNC_VF_INVALID;
- }
- /* filters the attributes from being sent to the controller */
- for (unsigned int loop = 0;
- loop < sizeof(val_vtn1->valid)/sizeof(val_vtn1->valid[0]);
- ++loop) {
- if ((UNC_VF_VALID == val_vtn1->valid[loop]) ||
- (UNC_VF_VALID_NO_VALUE == val_vtn1->valid[loop])) {
- invalid_attr = false;
- break;
- }
+bool VtnMoMgr::CompareValidValue(void *&val1, void *val2,
+ bool copy_to_running) {
+ UPLL_FUNC_TRACE;
+ bool invalid_attr = true;
+ val_vtn_t *val_vtn1 = reinterpret_cast<val_vtn_t *>(val1);
+ val_vtn_t *val_vtn2 = reinterpret_cast<val_vtn_t *>(val2);
+ val_vtn_index vtn_description = UPLL_IDX_DESC_VTN;
+ if (UNC_VF_INVALID == val_vtn1->valid[vtn_description] &&
+ UNC_VF_VALID == val_vtn2->valid[vtn_description])
+ val_vtn1->valid[vtn_description] = UNC_VF_VALID_NO_VALUE;
+ if (UNC_VF_INVALID != val_vtn1->valid[vtn_description]) {
+ if (!copy_to_running ||
+ ((UNC_VF_VALID == val_vtn1->valid[vtn_description]) &&
+ (!strcmp(reinterpret_cast<char*>(val_vtn1->description),
+ reinterpret_cast<char*>(val_vtn2->description)) )))
+ val_vtn1->valid[vtn_description] = UNC_VF_INVALID;
+ }
+ /* filters the attributes from being sent to the controller */
+ for (unsigned int loop = 0;
+ loop < sizeof(val_vtn1->valid)/sizeof(val_vtn1->valid[0]);
+ ++loop) {
+ if ((UNC_VF_VALID == val_vtn1->valid[loop]) ||
+ (UNC_VF_VALID_NO_VALUE == val_vtn1->valid[loop])) {
+ invalid_attr = false;
+ break;
}
- return invalid_attr;
}
+ return invalid_attr;
+}
- upll_rc_t
- VtnMoMgr::UpdateAuditConfigStatus(unc_keytype_configstatus_t cs_status,
- uuc::UpdateCtrlrPhase phase,
- ConfigKeyVal *&ckv_running) {
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- val_vtn_t *val;
- val = (ckv_running != NULL)?
- reinterpret_cast<val_vtn_t *>(GetVal(ckv_running)):NULL;
- if (NULL == val) {
- return UPLL_RC_ERR_GENERIC;
- }
- if (uuc::kUpllUcpCreate == phase )
+upll_rc_t VtnMoMgr::UpdateCtrlrConfigStatus(
+ unc_keytype_configstatus_t cs_status,
+ uuc::UpdateCtrlrPhase phase,
+ ConfigKeyVal *&ckv_running) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_vtn_ctrlr_t *val;
+ val = (ckv_running != NULL)?
+ reinterpret_cast<val_vtn_ctrlr_t *>(GetVal(ckv_running)):NULL;
+ if (NULL == val) {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (uuc::kUpllUcpCreate == phase )
+ val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
val->cs_row_status = cs_status;
- for ( unsigned int loop = 0;
- loop < sizeof(val->valid)/sizeof(uint8_t); ++loop ) {
- if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
- cs_status == UNC_CS_APPLIED)
- val->cs_attr[loop] = cs_status;
- }
+ if ((cs_status == UNC_CS_INVALID &&
+ UNC_VF_VALID == val->valid[UPLL_IDX_DESC_VTN]) ||
+ cs_status == UNC_CS_APPLIED)
+ val->cs_attr[UPLL_IDX_DESC_VTN] = cs_status;
+ return result_code;
+}
+
+upll_rc_t
+VtnMoMgr::UpdateAuditConfigStatus(unc_keytype_configstatus_t cs_status,
+ uuc::UpdateCtrlrPhase phase,
+ ConfigKeyVal *&ckv_running) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_vtn_t *val;
+ val = (ckv_running != NULL)?
+ reinterpret_cast<val_vtn_t *>(GetVal(ckv_running)):NULL;
+ if (NULL == val) {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (uuc::kUpllUcpCreate == phase )
+ val->cs_row_status = cs_status;
+ for ( unsigned int loop = 0;
+ loop < sizeof(val->valid)/sizeof(uint8_t); ++loop ) {
+ if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
+ cs_status == UNC_CS_APPLIED)
+ val->cs_attr[loop] = cs_status;
+ }
+ return result_code;
+}
+
+upll_rc_t
+VtnMoMgr::SetVtnConsolidatedStatus(ConfigKeyVal *ikey,
+ uint8_t *ctrlr_id,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ctrlr_ckv = NULL;
+ val_vtn_ctrlr *ctrlr_val = NULL;
+ uint8_t *vtn_exist_on_ctrlr = NULL;
+ bool applied = false, not_applied = false, invalid = false;
+ unc_keytype_configstatus_t c_status = UNC_CS_NOT_APPLIED;
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone,
+ kOpInOutCtrlr | kOpInOutDomain | kOpInOutCs };
+ if (!ikey || !dmi || !ctrlr_id) {
+ UPLL_LOG_DEBUG("Invalid Input");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = GetChildConfigKey(ctrlr_ckv, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed err code %d", result_code);
+ return result_code;
+ }
+ result_code = ReadConfigDB(ctrlr_ckv, UPLL_DT_RUNNING, UNC_OP_READ, dbop, dmi,
+ CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB from ctrltbl failed err code %d",
+ result_code);
+ delete ctrlr_ckv;
return result_code;
}
- upll_rc_t
- VtnMoMgr::SetConsolidatedStatus(ConfigKeyVal * ikey,
- DalDmlIntf * dmi) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- ConfigKeyVal *ckv = NULL;
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
- result_code = GetChildConfigKey(ckv, ikey);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_INFO("GetChildConfigKey failed err code %d\n", result_code);
- return result_code;
- }
- result_code = ReadConfigDB(ckv, UPLL_DT_RUNNING, UNC_OP_READ, dbop, dmi,
- CTRLRTBL);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_INFO("ReadConfigDB from ctrltbl failed err code %d\n",
- result_code);
- return result_code;
+ for (ConfigKeyVal *tmp = ctrlr_ckv; tmp != NULL;
+ tmp = tmp->get_next_cfg_key_val()) {
+ ctrlr_val = reinterpret_cast<val_vtn_ctrlr *>(GetVal(tmp));
+ if (!ctrlr_val) {
+ UPLL_LOG_DEBUG("Controller Value is empty");
+ tmp = NULL;
+ delete ctrlr_ckv;
+ return UPLL_RC_ERR_GENERIC;
}
- std::list < unc_keytype_configstatus_t > list_cs_row;
- std::list < unc_keytype_configstatus_t > list_cs_attr;
- val_vtn_t *val;
- for (; ckv != NULL; ckv->get_next_cfg_key_val()) {
- val = reinterpret_cast<val_vtn_t *>(GetVal(ckv));
- list_cs_row.push_back((unc_keytype_configstatus_t) val->cs_row_status);
- list_cs_attr.push_back((unc_keytype_configstatus_t) val->cs_attr[0]);
- }
- val_vtn_t *val_temp = reinterpret_cast<val_vtn_t *>(GetVal(ikey));
- val_temp->cs_row_status = GetConsolidatedCsStatus(list_cs_row);
- val_temp->cs_attr[0] = GetConsolidatedCsStatus(list_cs_attr);
- result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_UPDATE, dmi,
- MAINTBL);
- if (UPLL_RC_SUCCESS != result_code) {
- return result_code;
+ GET_USER_DATA_CTRLR(tmp, vtn_exist_on_ctrlr);
+ if (!strcmp(reinterpret_cast<char *>(vtn_exist_on_ctrlr),
+ reinterpret_cast<char *>(ctrlr_id)))
+ continue; // skipping entry of deleted controller
+
+ switch (ctrlr_val->cs_row_status) {
+ case UNC_CS_APPLIED:
+ applied = true;
+ break;
+ case UNC_CS_NOT_APPLIED:
+ case UNC_CS_NOT_SUPPORTED:
+ not_applied = true;
+ break;
+ case UNC_CS_INVALID:
+ invalid = true;
+ break;
+ default:
+ UPLL_LOG_DEBUG("Invalid status");
}
+ vtn_exist_on_ctrlr = NULL;
+ }
+ if (invalid)
+ c_status = UNC_CS_INVALID;
+ else if (applied && !not_applied)
+ c_status = UNC_CS_APPLIED;
+ else if (!applied && not_applied)
+ c_status = UNC_CS_NOT_APPLIED;
+ else if (applied && not_applied)
+ c_status = UNC_CS_PARTIALLY_APPLIED;
+ else
+ c_status = UNC_CS_APPLIED;
+ // Set cs_status
+ val_vtn_t *vtnval = static_cast<val_vtn_t *>(GetVal(ikey));
+ vtnval->cs_row_status = c_status;
+ vtnval->cs_attr[0] = UNC_CS_APPLIED;
+ DbSubOp dbop_update = {kOpNotRead, kOpMatchNone, kOpInOutCs};
+ result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_UPDATE, dmi,
+ &dbop_update, MAINTBL);
+ delete ctrlr_ckv;
+ return result_code;
+}
+
+upll_rc_t
+VtnMoMgr::SetConsolidatedStatus(ConfigKeyVal * ikey,
+ DalDmlIntf * dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ckv = NULL;
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCs };
+ result_code = GetChildConfigKey(ckv, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_INFO("GetChildConfigKey failed err code %d", result_code);
+ return result_code;
+ }
+ result_code = ReadConfigDB(ckv, UPLL_DT_RUNNING, UNC_OP_READ, dbop, dmi,
+ CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_INFO("ReadConfigDB from ctrltbl failed err code %d",
+ result_code);
+ delete(ckv);
return result_code;
}
+ list < unc_keytype_configstatus_t > list_cs_row;
+ val_vtn_ctrlr *val;
+ ConfigKeyVal *tmp = ckv;
+ for (; tmp != NULL; tmp = tmp->get_next_cfg_key_val()) {
+ val = reinterpret_cast<val_vtn_ctrlr *>(GetVal(tmp));
+ list_cs_row.push_back(static_cast<unc_keytype_configstatus_t>(val->cs_row_status));
+ }
+ DELETE_IF_NOT_NULL(ckv);
+ val_vtn_t *val_temp = reinterpret_cast<val_vtn_t *>(GetVal(ikey));
+ val_temp->cs_row_status = GetConsolidatedCsStatus(list_cs_row);
+ result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_UPDATE, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("SetConsolidatedStatus failed. UpdateConfigDB Failed"
+ " Result Code - %d", result_code);
+ }
+ return result_code;
+}
- upll_rc_t
- VtnMoMgr::MergeValidateChildren(ConfigKeyVal *import_ckval,
- const char *ctrlr_id,
- ConfigKeyVal *ikey,
- DalDmlIntf *dmi) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- if (!import_ckval || !(import_ckval->get_key())) {
- UPLL_LOG_DEBUG("Invalid Input");
- return UPLL_RC_ERR_GENERIC;
- }
- ConfigKeyVal *ckval = NULL;
- unc_key_type_t child_key[]= {
- UNC_KT_VBRIDGE, UNC_KT_VROUTER, UNC_KT_VRT_IPROUTE,
- UNC_KT_VRT_IF, UNC_KT_VLINK, UNC_KT_VTEP,
- UNC_KT_VTUNNEL
- };
- while (import_ckval) {
- for (unsigned int i = 0;
- i < sizeof(child_key)/sizeof(child_key[0]); i++) {
- const unc_key_type_t ktype = child_key[i];
- MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(
- const_cast<MoManager *>(GetMoManager(ktype)));
- if (!mgr) {
- UPLL_LOG_DEBUG("Instance is NULL");
- return UPLL_RC_ERR_GENERIC;
+upll_rc_t
+VtnMoMgr::MergeValidateChildren(ConfigKeyVal *import_ckval,
+ const char *ctrlr_id,
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ if (!import_ckval || !(import_ckval->get_key())) {
+ UPLL_LOG_DEBUG("Invalid Input");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigKeyVal *ckval = NULL;
+ unc_key_type_t child_key[]= {
+ UNC_KT_VBRIDGE, UNC_KT_VROUTER,
+ UNC_KT_VRT_IF, UNC_KT_VLINK
+ };
+ while (import_ckval) {
+ for (unsigned int i = 0;
+ i < sizeof(child_key)/sizeof(child_key[0]); i++) {
+ const unc_key_type_t ktype = child_key[i];
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(
+ const_cast<MoManager *>(GetMoManager(ktype)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("Instance is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = mgr->GetChildConfigKey(ckval, import_ckval);
+ if (UPLL_RC_SUCCESS != result_code) {
+ if (ckval) {
+ delete ckval;
+ ckval = NULL;
}
- result_code = mgr->GetChildConfigKey(ckval, import_ckval);
- if (UPLL_RC_SUCCESS != result_code) {
- if (ckval) {
- delete ckval;
- ckval = NULL;
- }
- UPLL_LOG_DEBUG("GetChildConfigKey Failed %d", result_code);
- return result_code;
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed %d", result_code);
+ return result_code;
+ }
+ result_code = mgr->MergeValidate(child_key[i], ctrlr_id, ckval, dmi);
+ UPLL_LOG_TRACE("Result code is %d key type %d", result_code, ktype);
+
+ if (UPLL_RC_SUCCESS != result_code &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ if (UPLL_RC_ERR_MERGE_CONFLICT == result_code) {
+ UPLL_LOG_DEBUG(" Merge Conflict %d", result_code);
+ ikey->ResetWith(ckval);
+ if (ikey)
+ UPLL_LOG_DEBUG("Conflict detail %s", ikey->ToStrAll().c_str());
+ } else {
+ UPLL_LOG_DEBUG("Merge Validate Failed %d", result_code);
}
- result_code = mgr->MergeValidate(child_key[i], ctrlr_id, ckval, dmi);
- if (UPLL_RC_SUCCESS != result_code &&
- UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
- if (UPLL_RC_ERR_MERGE_CONFLICT == result_code) {
- UPLL_LOG_DEBUG(" Merge Conflict %d", result_code);
- mgr->GetChildConfigKey(ikey, ckval);
- } else {
- UPLL_LOG_DEBUG("Merge Validate Failed %d", result_code);
- }
- if (NULL != ckval) {
- delete ckval;
- ckval = NULL;
- }
- return result_code;
+ if (NULL != ckval) {
+ delete ckval;
+ ckval = NULL;
}
+ return result_code;
}
- import_ckval = import_ckval->get_next_cfg_key_val();
+ if (ckval)
+ delete ckval;
+ ckval = NULL;
}
- result_code = (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code)?
- UPLL_RC_SUCCESS:result_code;
- return result_code;
+ import_ckval = import_ckval->get_next_cfg_key_val();
}
+ result_code = (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) ?
+ UPLL_RC_SUCCESS : result_code;
+ return result_code;
+}
- upll_rc_t
- VtnMoMgr::MergeValidate(unc_key_type_t keytype,
- const char *ctrlr_id,
- ConfigKeyVal *ikey,
- DalDmlIntf *dmi) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
- // Import Controller Name Not needed so checks is missing.
- ConfigKeyVal *import_ckval = NULL;
- result_code = GetChildConfigKey(import_ckval, NULL);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("GetChildConfig Failed ");
- return result_code;
- }
- DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutNone};
- result_code = ReadConfigDB(import_ckval, UPLL_DT_IMPORT, UNC_OP_READ,
- dbop, dmi, MAINTBL);
- if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
- UPLL_LOG_DEBUG("No Records in the Import DB");
- return UPLL_RC_SUCCESS;
- }
+upll_rc_t
+VtnMoMgr::MergeValidate(unc_key_type_t keytype,
+ const char *ctrlr_id,
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+ // Import Controller Name Not needed so checks is missing.
+ ConfigKeyVal *import_ckval = NULL;
+ result_code = GetChildConfigKey(import_ckval, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfig Failed ");
+ return result_code;
+ }
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutNone};
+ result_code = ReadConfigDB(import_ckval, UPLL_DT_IMPORT, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("No Records in the Import DB");
+ DELETE_IF_NOT_NULL(import_ckval);
+ return UPLL_RC_SUCCESS;
+ }
- /* Other than UPLL_RC_ERR_NO_SUCH_INSTANCE AND UPLL_RC_SUCCESS */
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG(" ReadConfigDB Failed %d", result_code);
- return result_code;
- }
- result_code = MergeValidateChildren(import_ckval, ctrlr_id, ikey, dmi);
+ /* Other than UPLL_RC_ERR_NO_SUCH_INSTANCE AND UPLL_RC_SUCCESS */
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG(" ReadConfigDB Failed %d", result_code);
+ DELETE_IF_NOT_NULL(import_ckval);
return result_code;
}
+ ConfigKeyVal *start_ckv = import_ckval;
+ result_code = MergeValidateChildren(import_ckval, ctrlr_id, ikey, dmi);
+ DELETE_IF_NOT_NULL(start_ckv); // check with Karthik
- upll_rc_t
- VtnMoMgr::TxUpdateController(unc_key_type_t keytype,
- uint32_t session_id,
- uint32_t config_id,
- uuc::UpdateCtrlrPhase phase,
- set<string> *affected_ctrlr_set,
- DalDmlIntf *dmi,
- ConfigKeyVal **err_ckv) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- DalResultCode dal_result = uud::kDalRcSuccess;
- ConfigKeyVal *req = NULL, *nreq = NULL, *ck_main = NULL;
- controller_domain ctrlr_dom;
- DalCursor *dal_cursor_handle;
- IpcResponse resp;
- memset(&resp, 0, sizeof(resp));
- unc_keytype_operation_t op = (phase == uuc::kUpllUcpCreate)?UNC_OP_CREATE:
- ((phase == uuc::kUpllUcpUpdate)?UNC_OP_UPDATE:
- ((phase == uuc::kUpllUcpDelete)?UNC_OP_DELETE:UNC_OP_INVALID));
- ctrlr_dom.ctrlr = NULL;
- ctrlr_dom.domain = NULL;
- MoMgrTables tbl = (op != UNC_OP_UPDATE)?CTRLRTBL:MAINTBL;
- result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING,
- op, req, nreq, &dal_cursor_handle, dmi, tbl);
- resp.header.clnt_sess_id = session_id;
- resp.header.config_id = config_id;
- while (result_code == UPLL_RC_SUCCESS) {
- // Get Next Record
- dal_result = dmi->GetNextRecord(dal_cursor_handle);
- result_code = DalToUpllResCode(dal_result);
- if (result_code != UPLL_RC_SUCCESS)
+ if (UPLL_RC_SUCCESS == result_code) {
+ ConfigKeyVal *req = NULL;
+ ConfigKeyVal *nreq = NULL;
+ DalCursor *dal_cursor_handle = NULL;
+ UPLL_LOG_TRACE("Create Entry in candidate");
+ result_code = DiffConfigDB(UPLL_DT_IMPORT, UPLL_DT_CANDIDATE,
+ UNC_OP_CREATE, req, nreq, &dal_cursor_handle, dmi, MAINTBL);
+ while (UPLL_RC_SUCCESS == result_code) {
+ result_code = DalToUpllResCode(dmi->GetNextRecord(dal_cursor_handle));
+ if (UPLL_RC_SUCCESS != result_code
+ && UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("GetNextRecord Failed ");
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ if (dal_cursor_handle)
+ dmi->CloseCursor(dal_cursor_handle, true);
+ return result_code;
+ }
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ if (dal_cursor_handle)
+ dmi->CloseCursor(dal_cursor_handle, true);
+ return UPLL_RC_SUCCESS;
+ }
+ dbop.inoutop = kOpInOutFlag | kOpInOutCtrlr | kOpInOutDomain;
+ result_code = UpdateConfigDB(req, UPLL_DT_CANDIDATE, UNC_OP_CREATE,
+ dmi, &dbop, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ if (dal_cursor_handle)
+ dmi->CloseCursor(dal_cursor_handle, true);
+ UPLL_LOG_DEBUG("UpdateConfigDB Failed");
+ return result_code;
+ }
+ }
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ if (dal_cursor_handle)
+ dmi->CloseCursor(dal_cursor_handle, true);
+ }
+ result_code = (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code)?
+ UPLL_RC_SUCCESS : result_code;
+ return result_code;
+}
+
+upll_rc_t
+VtnMoMgr::TxUpdateController(unc_key_type_t keytype,
+ uint32_t session_id,
+ uint32_t config_id,
+ uuc::UpdateCtrlrPhase phase,
+ set<string> *affected_ctrlr_set,
+ DalDmlIntf *dmi,
+ ConfigKeyVal **err_ckv) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ DalResultCode dal_result = uud::kDalRcSuccess;
+ ConfigKeyVal *req = NULL, *nreq = NULL, *ck_main = NULL;
+ controller_domain ctrlr_dom;
+ DalCursor *dal_cursor_handle;
+ IpcResponse resp;
+ memset(&resp, 0, sizeof(resp));
+ unc_keytype_operation_t op = (phase == uuc::kUpllUcpCreate)?UNC_OP_CREATE:
+ ((phase == uuc::kUpllUcpUpdate)?UNC_OP_UPDATE:
+ ((phase == uuc::kUpllUcpDelete)?UNC_OP_DELETE:UNC_OP_INVALID));
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ MoMgrTables tbl = (op != UNC_OP_UPDATE)?CTRLRTBL:MAINTBL;
+ result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING,
+ op, req, nreq, &dal_cursor_handle, dmi, tbl);
+ resp.header.clnt_sess_id = session_id;
+ resp.header.config_id = config_id;
+ while (result_code == UPLL_RC_SUCCESS) {
+ // Get Next Record
+ dal_result = dmi->GetNextRecord(dal_cursor_handle);
+ result_code = DalToUpllResCode(dal_result);
+ if (result_code != UPLL_RC_SUCCESS)
+ break;
+ ck_main = NULL;
+ if (op != UNC_OP_UPDATE) {
+ if (op == UNC_OP_CREATE)
+ result_code = DupConfigKeyVal(ck_main, req, tbl);
+ else
+ result_code = GetChildConfigKey(ck_main, req);
+ if (!ck_main || result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ if (ck_main)
+ delete ck_main;
+ return result_code;
+ }
+ GET_USER_DATA_CTRLR_DOMAIN(ck_main, ctrlr_dom);
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+ if ((ctrlr_dom.ctrlr == NULL) || (ctrlr_dom.domain == NULL)) {
+ UPLL_LOG_INFO("Invalid controller/domain");
+ delete ck_main;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = TxUpdateProcess(ck_main, &resp,
+ op, dmi, &ctrlr_dom);
+ affected_ctrlr_set->insert((const char *)ctrlr_dom.ctrlr);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returns error %d", result_code);
+ *err_ckv = resp.ckv_data;
break;
- ck_main = NULL;
- if ( op != UNC_OP_UPDATE) {
- if (op == UNC_OP_CREATE)
- result_code = DupConfigKeyVal(ck_main, req,tbl);
- else
- result_code = GetChildConfigKey(ck_main, req);
- if (!ck_main || result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n",result_code);
- if (ck_main)
- delete ck_main;
- return result_code;
- }
- GET_USER_DATA_CTRLR_DOMAIN(ck_main, ctrlr_dom);
- UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom.ctrlr,
- ctrlr_dom.domain);
+ }
+ DELETE_IF_NOT_NULL(resp.ckv_data);
+ } else {
+ ConfigKeyVal *ck_ctrlr = NULL;
+ result_code = DupConfigKeyVal(ck_main, req, tbl);
+ if (!ck_main || result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(ck_main);
+ return result_code;
+ }
+#if 0
+ result_code = ValidateCapability(&(ipc_req.header), ck_main);
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(ck_main);
+ return result_code;
+ }
+#endif
+ result_code = GetChildConfigKey(ck_ctrlr, ck_main);
+ if (!ck_ctrlr || result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(ck_ctrlr);
+ return result_code;
+ }
+ if (GetControllerDomainSpan(ck_ctrlr, UPLL_DT_CANDIDATE, dmi) ==
+ UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ delete ck_ctrlr;
+ ck_ctrlr = NULL;
+ delete ck_main;
+ ck_main = NULL;
+ continue;
+ }
+ void *main = GetVal(ck_main);
+ void *val_nrec = (nreq) ? GetVal(nreq) : NULL;
+ if (FilterAttributes(main, val_nrec, false, op)) {
+ delete ck_ctrlr;
+ ck_ctrlr = NULL;
+ continue;
+ }
+ for (ConfigKeyVal *tmp = ck_ctrlr; tmp != NULL;
+ tmp = tmp->get_next_cfg_key_val()) {
+ GET_USER_DATA_CTRLR_DOMAIN(tmp, ctrlr_dom);
if ((ctrlr_dom.ctrlr == NULL) || (ctrlr_dom.domain == NULL)) {
+ DELETE_IF_NOT_NULL(ck_main);
UPLL_LOG_INFO("Invalid controller/domain");
return UPLL_RC_ERR_GENERIC;
}
op, dmi, &ctrlr_dom);
affected_ctrlr_set->insert((const char *)ctrlr_dom.ctrlr);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returns error %d", result_code);
+ UPLL_LOG_DEBUG("TxUpdate Process returns with %d", result_code);
*err_ckv = resp.ckv_data;
break;
}
- } else {
- ConfigKeyVal *ck_ctrlr = NULL;
- result_code = DupConfigKeyVal(ck_main, req,tbl);
- if (result_code != UPLL_RC_SUCCESS)
- return result_code;
-#if 0
- result_code = ValidateCapability(&(ipc_req.header), ck_main);
- if (result_code != UPLL_RC_SUCCESS)
- return result_code;
-#endif
- result_code = GetChildConfigKey(ck_ctrlr, ck_main);
- if (result_code != UPLL_RC_SUCCESS)
- return result_code;
- if (GetControllerDomainSpan(ck_ctrlr, UPLL_DT_CANDIDATE, dmi) ==
- UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- delete ck_ctrlr;
- ck_ctrlr = NULL;
- delete ck_main;
- ck_main = NULL;
- continue;
- }
- void *main = GetVal(ck_main);
- void *val_nrec = (nreq) ? GetVal(nreq) : NULL;
- if (FilterAttributes(main,val_nrec,false,op)) {
- delete ck_ctrlr;
- ck_ctrlr = NULL;
- continue;
- }
- for (ConfigKeyVal *tmp = ck_ctrlr; tmp != NULL;
- tmp = tmp->get_next_cfg_key_val()) {
- GET_USER_DATA_CTRLR_DOMAIN(tmp, ctrlr_dom);
- if ((ctrlr_dom.ctrlr == NULL) || (ctrlr_dom.domain == NULL)) {
- UPLL_LOG_INFO("Invalid controller/domain");
- return UPLL_RC_ERR_GENERIC;
- }
- result_code = TxUpdateProcess(ck_main, &resp,
- op, dmi, &ctrlr_dom);
- affected_ctrlr_set->insert((const char *)ctrlr_dom.ctrlr);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("TxUpdate Process returns with %d", result_code);
- *err_ckv = resp.ckv_data;
- break;
- }
- }
- delete ck_ctrlr;
+ DELETE_IF_NOT_NULL(resp.ckv_data);
}
- delete ck_main;
+ delete ck_ctrlr;
}
- if (nreq)
- delete nreq;
- if (req)
- delete req;
- if (dal_cursor_handle)
- dmi->CloseCursor(dal_cursor_handle, true);
- result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
- UPLL_RC_SUCCESS:result_code;
- return result_code;
+ delete ck_main;
}
+ if (nreq)
+ delete nreq;
+ if (req)
+ delete req;
+ if (dal_cursor_handle)
+ dmi->CloseCursor(dal_cursor_handle, true);
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
+ UPLL_RC_SUCCESS:result_code;
+ return result_code;
+}
- upll_rc_t
- VtnMoMgr::TxUpdateProcess(ConfigKeyVal *ck_main,
- IpcResponse *ipc_resp,
- unc_keytype_operation_t op,
- DalDmlIntf *dmi,
- controller_domain *ctrlr_dom) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code;
- /* read from main table */
- ConfigKeyVal *dup_ckmain = ck_main;
- if ( (op == UNC_OP_CREATE) ) {
- dup_ckmain = NULL;
- result_code = GetChildConfigKey(dup_ckmain, ck_main);
- if (result_code != UPLL_RC_SUCCESS || dup_ckmain == NULL) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
- delete dup_ckmain;
- return result_code;
- }
- DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutNone};
- result_code = ReadConfigDB(dup_ckmain, UPLL_DT_CANDIDATE,
- UNC_OP_READ, dbop, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- string s(dup_ckmain->ToStrAll());
- UPLL_LOG_INFO("%s Vtn read failed %d", s.c_str(), result_code);
- if (dup_ckmain) delete dup_ckmain;
- return result_code;
- }
- /* To filter the attributes to be sent to controller */
- void *val = (ck_main) ? GetVal(ck_main) : NULL;
- void *dup_val = (dup_ckmain) ? GetVal(dup_ckmain) : NULL;
- if (FilterAttributes(dup_val, val, false, op)) {
- if (dup_ckmain) delete dup_ckmain;
- return UPLL_RC_SUCCESS;
- }
- }
- /* Get renamed key if key is renamed */
- result_code = GetRenamedControllerKey(dup_ckmain, UPLL_DT_CANDIDATE,
- dmi, ctrlr_dom);
- if (result_code != UPLL_RC_SUCCESS) {
- if ((op == UNC_OP_CREATE) && dup_ckmain)
- delete dup_ckmain;
+upll_rc_t
+VtnMoMgr::TxUpdateProcess(ConfigKeyVal *ck_main,
+ IpcResponse *ipc_resp,
+ unc_keytype_operation_t op,
+ DalDmlIntf *dmi,
+ controller_domain *ctrlr_dom) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code;
+ controller_domain ctrlr_dom_dup;
+ ctrlr_dom_dup.ctrlr = NULL;
+ ctrlr_dom_dup.domain = NULL;
+ /* read from main table */
+ ConfigKeyVal *dup_ckmain = ck_main;
+ if (op == UNC_OP_CREATE) {
+ dup_ckmain = NULL;
+ result_code = GetChildConfigKey(dup_ckmain, ck_main);
+ if (result_code != UPLL_RC_SUCCESS || dup_ckmain == NULL) {
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
+ delete dup_ckmain;
return result_code;
}
- // ipc_req->ckv_data = ck_main;
- result_code = SendIpcReq(ipc_resp->header.clnt_sess_id,
- ipc_resp->header.config_id, op, UPLL_DT_CANDIDATE,
- dup_ckmain, ctrlr_dom, ipc_resp);
- if (result_code == UPLL_RC_ERR_RESOURCE_DISCONNECTED) {
- UPLL_LOG_DEBUG("Controller disconnected");
- result_code = UPLL_RC_SUCCESS;
- }
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutNone};
+ result_code = ReadConfigDB(dup_ckmain, UPLL_DT_CANDIDATE,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("IpcSend failed %d", result_code);
+ UPLL_LOG_INFO("%s Vtn read failed %d", (dup_ckmain->ToStrAll()).c_str(),
+ result_code);
+ if (dup_ckmain) delete dup_ckmain;
+ return result_code;
}
- if ((op == UNC_OP_CREATE) && dup_ckmain) {
- delete dup_ckmain;
- dup_ckmain = NULL;
+ /* To filter the attributes to be sent to controller */
+ void *val = (ck_main) ? GetVal(ck_main) : NULL;
+ void *dup_val = (dup_ckmain) ? GetVal(dup_ckmain) : NULL;
+ if (FilterAttributes(dup_val, val, false, op)) {
+ if (dup_ckmain) delete dup_ckmain;
+ return UPLL_RC_SUCCESS;
}
+ } else if (op == UNC_OP_UPDATE) {
+ UPLL_LOG_INFO("UPDATE to VTN is not supported at driver. so return..");
+ return UPLL_RC_SUCCESS;
+ }
+ /* Get renamed key if key is renamed */
+ /* For Delete operation we have to get info
+ * from running db
+ */
+ if (op == UNC_OP_DELETE)
+ result_code = GetRenamedControllerKey(dup_ckmain, UPLL_DT_RUNNING,
+ dmi, ctrlr_dom);
+ else {
+ if (op == UNC_OP_CREATE) {
+ ctrlr_dom_dup.ctrlr = NULL;
+ ctrlr_dom_dup.domain = NULL;
+ GET_USER_DATA_CTRLR_DOMAIN(dup_ckmain, ctrlr_dom_dup);
+ }
+ result_code = GetRenamedControllerKey(dup_ckmain, UPLL_DT_CANDIDATE,
+ dmi, &ctrlr_dom_dup);
+ }
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetRenamedControllerKey failed. Result : %d",
+ result_code);
+ if ((op == UNC_OP_CREATE) && dup_ckmain)
+ delete dup_ckmain;
return result_code;
}
+ // ipc_req->ckv_data = ck_main;
+ result_code = SendIpcReq(ipc_resp->header.clnt_sess_id,
+ ipc_resp->header.config_id, op, UPLL_DT_CANDIDATE,
+ dup_ckmain, ctrlr_dom, ipc_resp);
+ if (result_code == UPLL_RC_ERR_RESOURCE_DISCONNECTED) {
+ UPLL_LOG_DEBUG("Controller disconnected");
+ result_code = UPLL_RC_SUCCESS;
+ }
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("IpcSend failed %d", result_code);
+ }
+ if ((op == UNC_OP_CREATE) && dup_ckmain)
+ delete dup_ckmain;
+ return result_code;
+}
- upll_rc_t
- VtnMoMgr::CopyToConfigKey(ConfigKeyVal * &okey,
- ConfigKeyVal * ikey) {
- if (!ikey || !(ikey->get_key())) return UPLL_RC_ERR_GENERIC;
+upll_rc_t
+VtnMoMgr::CopyToConfigKey(ConfigKeyVal * &okey,
+ ConfigKeyVal * ikey) {
+ if (!ikey || !(ikey->get_key())) return UPLL_RC_ERR_GENERIC;
- key_vtn_t *key_vtn = reinterpret_cast<key_vtn_t *>
- (ConfigKeyVal::Malloc(sizeof(key_vtn_t)));
+ key_vtn_t *key_vtn = reinterpret_cast<key_vtn_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn_t)));
- key_rename_vnode_info *key_rename =
- reinterpret_cast<key_rename_vnode_info *>(ikey->get_key());
+ key_rename_vnode_info *key_rename =
+ reinterpret_cast<key_rename_vnode_info *>(ikey->get_key());
- if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vtn_name))) {
- free(key_vtn);
- return UPLL_RC_ERR_GENERIC;
- }
- uuu::upll_strncpy(key_vtn->vtn_name, key_rename->old_unc_vtn_name,
- (kMaxLenVtnName + 1));
-
- okey = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcStKeyVtn, key_vtn, NULL);
- if (!okey) {
- free(key_vtn);
- return UPLL_RC_ERR_GENERIC;
- }
- SET_USER_DATA(okey, ikey);
- return UPLL_RC_SUCCESS;
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vtn_name))) {
+ ConfigKeyVal::Free(key_vtn);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(key_vtn->vtn_name, key_rename->old_unc_vtn_name,
+ (kMaxLenVtnName + 1));
+
+ okey = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcStKeyVtn, key_vtn, NULL);
+ SET_USER_DATA(okey, ikey);
+ return UPLL_RC_SUCCESS;
}
- /* This function will call doing the Rename Operation
- * This functions gets the Old Unc, New Unc and controller
- * names from the ikey, okey and store it in local structure
- * and creates the rename_info configkeyval
- */
+/* This function will call doing the Rename Operation
+ * This functions gets the Old Unc, New Unc and controller
+ * names from the ikey, okey and store it in local structure
+ * and creates the rename_info configkeyval
+ */
- upll_rc_t
- VtnMoMgr:: GetRenameInfo(ConfigKeyVal *ikey,
- ConfigKeyVal *okey,
- ConfigKeyVal *&rename_info,
- DalDmlIntf *dmi,
- const char *ctrlr_id,
- bool &renamed) {
- UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- if (!ikey || !okey || NULL != rename_info
- || !(ikey->get_key()) || !(okey->get_key())) {
- UPLL_LOG_DEBUG("Input is NULL");
- return UPLL_RC_ERR_GENERIC;
- }
- /* allocate memory for struct to store all the details */
- key_rename_vnode_info *vtn_rename_info =
- reinterpret_cast<key_rename_vnode_info *>
- (ConfigKeyVal::Malloc(sizeof(key_rename_vnode_info)));
+upll_rc_t
+VtnMoMgr:: GetRenameInfo(ConfigKeyVal *ikey,
+ ConfigKeyVal *okey,
+ ConfigKeyVal *&rename_info,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id,
+ bool &renamed) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ if (!ikey || !okey || NULL != rename_info
+ || !(ikey->get_key()) || !(okey->get_key())) {
+ UPLL_LOG_DEBUG("Input is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ /* allocate memory for struct to store all the details */
+ key_rename_vnode_info *vtn_rename_info =
+ reinterpret_cast<key_rename_vnode_info *>
+ (ConfigKeyVal::Malloc(sizeof(key_rename_vnode_info)));
- key_vtn_t *vtn_key = NULL;
- vtn_key = reinterpret_cast<key_vtn_t *>(ikey->get_key());
- if (vtn_key == NULL) {
- UPLL_LOG_DEBUG("No VTN Key");
- free(vtn_rename_info);
+ key_vtn_t *vtn_key = NULL;
+ vtn_key = reinterpret_cast<key_vtn_t *>(ikey->get_key());
+ if (vtn_key == NULL) {
+ UPLL_LOG_DEBUG("No VTN Key");
+ ConfigKeyVal::Free(vtn_rename_info);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ /* Checks the vtn is already renamed or not */
+ if (renamed) {
+ /* if already renamed store the controller name */
+ if (!strlen(reinterpret_cast<char *>(
+ (reinterpret_cast<val_rename_vtn_t *>(GetVal(ikey)))->new_name))) {
+ ConfigKeyVal::Free(vtn_rename_info);
return UPLL_RC_ERR_GENERIC;
}
- /* Checks the vtn is already renamed or not */
- if (renamed) {
- /* if already renamed store the controller name */
- if (!strlen(reinterpret_cast<char *>(
- (reinterpret_cast<val_rename_vtn_t *>(GetVal(ikey)))->new_name))) {
- free(vtn_rename_info);
- return UPLL_RC_ERR_GENERIC;
- }
- uuu::upll_strncpy(vtn_rename_info->ctrlr_vtn_name,
- reinterpret_cast<val_rename_vtn_t *>(GetVal(ikey))->new_name,
- (kMaxLenVtnName + 1));
- } else {
- /* if not renamed the ikey contains the controller name */
- if (!strlen(reinterpret_cast<char *>(vtn_key->vtn_name))) {
- free(vtn_rename_info);
- return UPLL_RC_ERR_GENERIC;
- }
- uuu::upll_strncpy(vtn_rename_info->ctrlr_vtn_name, vtn_key->vtn_name,
- (kMaxLenVtnName + 1));
- }
- /* Store the old UNC VTN name */
+ uuu::upll_strncpy(vtn_rename_info->ctrlr_vtn_name,
+ reinterpret_cast<val_rename_vtn_t *>(GetVal(ikey))->new_name,
+ (kMaxLenVtnName + 1));
+ } else {
+ /* if not renamed the ikey contains the controller name */
if (!strlen(reinterpret_cast<char *>(vtn_key->vtn_name))) {
- free(vtn_rename_info);
+ ConfigKeyVal::Free(vtn_rename_info);
return UPLL_RC_ERR_GENERIC;
}
- uuu::upll_strncpy(vtn_rename_info->old_unc_vtn_name, vtn_key->vtn_name,
- (kMaxLenVtnName + 1));
+ uuu::upll_strncpy(vtn_rename_info->ctrlr_vtn_name, vtn_key->vtn_name,
+ (kMaxLenVtnName + 1));
+ }
+ /* Store the old UNC VTN name */
+ if (!strlen(reinterpret_cast<char *>(vtn_key->vtn_name))) {
+ ConfigKeyVal::Free(vtn_rename_info);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(vtn_rename_info->old_unc_vtn_name, vtn_key->vtn_name,
+ (kMaxLenVtnName + 1));
- vtn_key = reinterpret_cast<key_vtn_t *>(okey->get_key());
- /* store the new UNC VTN NAME */
- if (!strlen(reinterpret_cast<char *>(vtn_key->vtn_name))) {
- free(vtn_rename_info);
- return UPLL_RC_ERR_GENERIC;
- }
- uuu::upll_strncpy(vtn_rename_info->new_unc_vtn_name, vtn_key->vtn_name,
- (kMaxLenVtnName + 1));
+ vtn_key = reinterpret_cast<key_vtn_t *>(okey->get_key());
+ /* store the new UNC VTN NAME */
+ if (!strlen(reinterpret_cast<char *>(vtn_key->vtn_name))) {
+ ConfigKeyVal::Free(vtn_rename_info);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(vtn_rename_info->new_unc_vtn_name, vtn_key->vtn_name,
+ (kMaxLenVtnName + 1));
- rename_info = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcInvalidStNum,
- vtn_rename_info, NULL);
- DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain};
- result_code = ReadConfigDB(ikey, UPLL_DT_IMPORT,
- UNC_OP_READ, dbop, dmi, CTRLRTBL);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("ReadConfigDB Error");
- return result_code;
- }
- SET_USER_DATA (rename_info, ikey);
- if (!rename_info) {
- free(vtn_rename_info);
- return UPLL_RC_ERR_GENERIC;
- }
- /* Set the Controller Id*/
- SET_USER_DATA_CTRLR(rename_info, ctrlr_id);
- if (!renamed) {
- val_rename_vtn_t *vtn = reinterpret_cast<val_rename_vtn_t *>
- (ConfigKeyVal::Malloc(sizeof(val_rename_vtn)));
- uuu::upll_strncpy(vtn->new_name, vtn_rename_info->ctrlr_vtn_name,
- (kMaxLenCtrlrId + 1));
- ConfigVal *cfg_val = new ConfigVal(IpctSt::kIpcStValRenameVtn, vtn);
- if (!cfg_val) {
- free(vtn);
- delete rename_info;
- return UPLL_RC_ERR_GENERIC;
- }
- vtn->valid[UPLL_IDX_NEW_NAME_RVTN] = UNC_VF_VALID;
- ikey->SetCfgVal(cfg_val);
- SET_USER_DATA (okey, ikey);
- dbop.readop = kOpNotRead;
- result_code = UpdateConfigDB(ikey, UPLL_DT_IMPORT, UNC_OP_CREATE,
- dmi, &dbop, RENAMETBL);
- }
+ rename_info = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcInvalidStNum,
+ vtn_rename_info, NULL);
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr|kOpInOutDomain};
+ result_code = ReadConfigDB(ikey, UPLL_DT_IMPORT,
+ UNC_OP_READ, dbop, dmi, CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB Error");
+ return result_code;
+ }
+ SET_USER_DATA(rename_info, ikey);
+ if (!rename_info) {
+ ConfigKeyVal::Free(vtn_rename_info);
+ return UPLL_RC_ERR_GENERIC;
+ }
+#if 0
+ /* Vtn Merge with Existing VTN name in
+ * IMPORT Table
+ */
+ ConfigKeyVal *temp_key = NULL;
+ result_code = GetChildConfigKey(temp_key, okey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed");
+ return result_code;
+ }
+ result_code = UpdateConfigDB(temp_key, UPLL_DT_IMPORT, UNC_OP_READ, dmi,
+ &dbop, MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(temp_key);
return result_code;
}
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ SET_USER_DATA_FLAGS(temp_key, VTN_RENAME);
+ /* New Name available in the IMPORT, then
+ * we have to update the rename flag in Main Table */
+ result_code = UpdateConfigDB(temp_key, UPLL_DT_IMPORT,
+ UNC_OP_UPDATE, dmi, &dbop, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(temp_key);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(temp_key);
- upll_rc_t
- VtnMoMgr::ValidateVtnKey(key_vtn * vtn_key) {
- UPLL_FUNC_TRACE;
- upll_rc_t ret_val = UPLL_RC_SUCCESS;
- ret_val = ValidateKey(reinterpret_cast<char *>(vtn_key->vtn_name),
- kMinLenVtnName, kMaxLenVtnName);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("vtn name syntax check failed."
- "Received vtn name - %s",
- vtn_key->vtn_name);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ result_code = GetChildConfigKey(temp_key, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed");
+ return result_code;
+ }
+ /* Remove the Current VTN name from the Main table*/
+ result_code = UpdateConfigDB(temp_key, UPLL_DT_IMPORT,
+ UNC_OP_DELETE, dmi, &dbop, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(temp_key);
+ return result_code;
}
- return UPLL_RC_SUCCESS;
}
-
- upll_rc_t
- VtnMoMgr::ValidateVtnValue(val_vtn *vtn_val,
- uint32_t operation) {
- UPLL_FUNC_TRACE;
- upll_rc_t ret_val = UPLL_RC_SUCCESS;
- if (vtn_val->valid[UPLL_IDX_DESC_VTN] == UNC_VF_VALID) {
- ret_val = ValidateDesc(reinterpret_cast<char *>(vtn_val->description),
- kMinLenDescription, kMaxLenDescription);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Description syntax check failed."
- "Received Description - %s", vtn_val->description);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ /* The new name not available then create an entry in main table */
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code && !no_rename) {
+ result_code = GetChildConfigKey(temp_key, okey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed %d", result_code);
+ return result_code;
+ }
+ SET_USER_DATA_FLAGS(temp_key, VTN_RENAME);
+ /*Create an entry in main table */
+ result_code = UpdateConfigDB(temp_key, UPLL_DT_IMPORT,
+ UNC_OP_CREATE, dmi, &dbop, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(temp_key);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(temp_key);
+ result_code = GetChildConfigKey(temp_key, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed %d", result_code);
+ return result_code;
+ }
+ /* Remove the current name from the main table */
+ result_code = UpdateConfigDB(temp_key, UPLL_DT_IMPORT,
+ UNC_OP_DELETE, dmi, &dbop, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(temp_key);
+ return result_code;
+ }
+ }
+ DELETE_IF_NOT_NULL(temp_key);
+ if (no_rename) {
+ /* This is called during no rename function */
+ UPLL_LOG_TRACE("Calling No Rename");
+ UPLL_LOG_TRACE("Ikey is %s", ikey->ToStrAll().c_str());
+ UPLL_LOG_TRACE("Okey is %s", okey->ToStrAll().c_str());
+ uint32_t ref_count = 0;
+ SET_USER_DATA_FLAGS(okey, NO_RENAME);
+ result_code = GetChildConfigKey(temp_key, okey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed %d", result_code);
+ return result_code;
+ }
+ /* Create an entry with old name */
+ result_code = UpdateConfigDB(temp_key, UPLL_DT_IMPORT, UNC_OP_CREATE, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(temp_key);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(temp_key);
+ result_code = GetChildConfigKey(temp_key, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failed %d", result_code);
+ return result_code;
+ }
+ /* Check the count for the Renamed UNC name */
+ result_code = GetInstanceCount(temp_key, const_cast<char *>(ctrlr_id),
+ UPLL_DT_IMPORT, &ref_count, dmi, RENAMETBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetInstanceCoutn is Failed %d", result_code);
+ return result_code;
+ }
+ if (ref_count == 1) {
+ temp_key->SetCfgVal(NULL);
+ /* if the count is one then remove the Renamed UNC name
+ * from the MAIN TABLE
+ */
+ SET_USER_DATA_FLAGS(temp_key, NO_RENAME);
+ result_code = UpdateConfigDB(temp_key, UPLL_DT_IMPORT, UNC_OP_DELETE, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(temp_key);
+ return result_code;
}
- } else if (vtn_val->valid[UPLL_IDX_DESC_VTN] == UNC_VF_VALID_NO_VALUE &&
- (operation == UNC_OP_UPDATE || operation == UNC_OP_CREATE)) {
- uuu::upll_strncpy(reinterpret_cast<char *>(vtn_val->description), " ", 2);
}
- return UPLL_RC_SUCCESS;
}
+ DELETE_IF_NOT_NULL(temp_key);
+#endif
+ /* Set the Controller Id*/
+ SET_USER_DATA_CTRLR(rename_info, ctrlr_id);
+ if (!renamed) {
+ val_rename_vtn_t *vtn = reinterpret_cast<val_rename_vtn_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_rename_vtn)));
+ uuu::upll_strncpy(vtn->new_name, vtn_rename_info->ctrlr_vtn_name,
+ (kMaxLenCtrlrId + 1));
+ ConfigVal *cfg_val = new ConfigVal(IpctSt::kIpcStValRenameVtn, vtn);
+ vtn->valid[UPLL_IDX_NEW_NAME_RVTN] = UNC_VF_VALID;
+ okey->SetCfgVal(cfg_val);
+ SET_USER_DATA(okey, ikey);
+ dbop.readop = kOpNotRead;
+ result_code = UpdateConfigDB(okey, UPLL_DT_IMPORT, UNC_OP_CREATE,
+ dmi, &dbop, RENAMETBL);
+ }
+ return result_code;
+}
- upll_rc_t
- VtnMoMgr::ValidateVtnRenameValue(val_rename_vtn * vtn_rename) {
- UPLL_FUNC_TRACE;
- upll_rc_t ret_val = UPLL_RC_SUCCESS;
- if (vtn_rename->valid[UPLL_IDX_NEW_NAME_RVTN] == UNC_VF_VALID) {
- ret_val = ValidateKey(reinterpret_cast<char *>(vtn_rename->new_name),
- kMinLenVtnName, kMaxLenVtnName);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Rename syntax check failed."
- "Received vtn_rename - %s",
- vtn_rename->new_name);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
+upll_rc_t
+VtnMoMgr::ValidateVtnKey(key_vtn * vtn_key) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ ret_val = ValidateKey(reinterpret_cast<char *>(vtn_key->vtn_name),
+ kMinLenVtnName, kMaxLenVtnName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("vtn name syntax check failed."
+ "Received vtn name - %s",
+ vtn_key->vtn_name);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t
+VtnMoMgr::ValidateVtnValue(val_vtn *vtn_val,
+ uint32_t operation) {
+ UPLL_FUNC_TRACE;
+ if (vtn_val->valid[UPLL_IDX_DESC_VTN] == UNC_VF_VALID) {
+ if (!ValidateDesc(vtn_val->description,
+ kMinLenDescription, kMaxLenDescription)) {
+ UPLL_LOG_INFO("Description syntax check failed."
+ "Received Description - %s", vtn_val->description);
+ return UPLL_RC_ERR_CFG_SYNTAX;
}
- return UPLL_RC_SUCCESS;
+ } else if (vtn_val->valid[UPLL_IDX_DESC_VTN] == UNC_VF_VALID_NO_VALUE &&
+ (operation == UNC_OP_UPDATE || operation == UNC_OP_CREATE)) {
+ uuu::upll_strncpy(reinterpret_cast<char *>(vtn_val->description), " ", 2);
}
+ return UPLL_RC_SUCCESS;
+}
- upll_rc_t
- VtnMoMgr::ValidateMessage(IpcReqRespHeader * req,
- ConfigKeyVal * ikey) {
- UPLL_FUNC_TRACE;
- upll_rc_t ret_val = UPLL_RC_SUCCESS;
- if (!ikey || !req || !(ikey->get_key())) {
- UPLL_LOG_INFO("ConfigKeyVal / IpcReqRespHeader is Null");
- return UPLL_RC_ERR_GENERIC;
+upll_rc_t
+VtnMoMgr::ValidateVtnRenameValue(val_rename_vtn * vtn_rename) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ if (vtn_rename->valid[UPLL_IDX_NEW_NAME_RVTN] == UNC_VF_VALID) {
+ ret_val = ValidateKey(reinterpret_cast<char *>(vtn_rename->new_name),
+ kMinLenVtnName, kMaxLenVtnName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("Rename syntax check failed."
+ "Received vtn_rename - %s",
+ vtn_rename->new_name);
+ return UPLL_RC_ERR_CFG_SYNTAX;
}
- if (ikey->get_key_type() == UNC_KT_VTNSTATION_CONTROLLER)
- return (ValidateMessageForVtnStnCtrlr(req, ikey));
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t
+VtnMoMgr::ValidateMessage(IpcReqRespHeader * req,
+ ConfigKeyVal * ikey) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ if (!ikey || !req || !(ikey->get_key())) {
+ UPLL_LOG_INFO("ConfigKeyVal / IpcReqRespHeader is Null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (ikey->get_key_type() == UNC_KT_VTNSTATION_CONTROLLER)
+ return (ValidateMessageForVtnStnCtrlr(req, ikey));
- if (ikey->get_key_type() == UNC_KT_VTN_MAPPING_CONTROLLER)
- return (ValidateMessageForVtnMapCtrlr(req, ikey));
+ if (ikey->get_key_type() == UNC_KT_VTN_MAPPING_CONTROLLER)
+ return (ValidateMessageForVtnMapCtrlr(req, ikey));
- if (ikey->get_st_num() != IpctSt::kIpcStKeyVtn) {
- UPLL_LOG_INFO("Invalid Key structure received. received struct - %d",
- (ikey->get_st_num()));
- return UPLL_RC_ERR_BAD_REQUEST;
- }
- key_vtn *vtn_key = reinterpret_cast<key_vtn *>(ikey->get_key());
+ if (ikey->get_st_num() != IpctSt::kIpcStKeyVtn) {
+ UPLL_LOG_INFO("Invalid Key structure received. received struct - %d",
+ (ikey->get_st_num()));
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ key_vtn *vtn_key = reinterpret_cast<key_vtn *>(ikey->get_key());
- unc_key_type_t ktype = ikey->get_key_type();
- if (UNC_KT_VTN != ktype) {
- UPLL_LOG_INFO("Invalid keytype received. received keytype - %d", ktype);
- return UPLL_RC_ERR_BAD_REQUEST;
+ unc_key_type_t ktype = ikey->get_key_type();
+ if (UNC_KT_VTN != ktype) {
+ UPLL_LOG_INFO("Invalid keytype received. received keytype - %d", ktype);
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ upll_keytype_datatype_t dt_type = req->datatype;
+ unc_keytype_operation_t operation = req->operation;
+ unc_keytype_option1_t option1 = req->option1;
+ unc_keytype_option2_t option2 = req->option2;
+ if ((operation != UNC_OP_READ_SIBLING_COUNT) &&
+ (operation != UNC_OP_READ_SIBLING_BEGIN)) {
+ ret_val = ValidateVtnKey(vtn_key);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("syntax check failed for key_vtn struct");
+ return UPLL_RC_ERR_CFG_SYNTAX;
}
- upll_keytype_datatype_t dt_type = req->datatype;
- unc_keytype_operation_t operation = req->operation;
- unc_keytype_option1_t option1 = req->option1;
- unc_keytype_option2_t option2 = req->option2;
- if ((operation != UNC_OP_READ_SIBLING_COUNT) &&
- (operation != UNC_OP_READ_SIBLING_BEGIN)) {
- ret_val = ValidateVtnKey(vtn_key);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("syntax check failed for key_vtn struct");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else {
- UPLL_LOG_TRACE("Operation is %d", operation);
- StringReset(vtn_key->vtn_name);
- }
- if ((operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) &&
- (dt_type == UPLL_DT_CANDIDATE|| UPLL_DT_IMPORT == dt_type)) {
- ConfigVal *cfg_val = ikey->get_cfg_val();
- switch (operation) {
- case UNC_OP_CREATE:
- if (cfg_val == NULL)
- return UPLL_RC_SUCCESS;
- /* fall through intended */
- case UNC_OP_UPDATE:
- {
- if (!cfg_val)
- return UPLL_RC_ERR_CFG_SYNTAX;
- if (cfg_val->get_st_num() != IpctSt::kIpcStValVtn) {
- UPLL_LOG_INFO(
- "Invalid Value structure received. received struct - %d",
- (ikey->get_st_num()));
- return UPLL_RC_ERR_BAD_REQUEST;
- }
- val_vtn *vtn_val = reinterpret_cast<val_vtn *>(GetVal(ikey));
- if (vtn_val == NULL) {
- UPLL_LOG_INFO("syntax check for vtn_val struct is an optional");
- return UPLL_RC_SUCCESS;
- }
- ret_val = ValidateVtnValue(vtn_val, operation);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("syntax check failure for val_vtn structure");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
+ } else {
+ UPLL_LOG_TRACE("Operation is %d", operation);
+ StringReset(vtn_key->vtn_name);
+ }
+ if ((operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) &&
+ (dt_type == UPLL_DT_CANDIDATE|| UPLL_DT_IMPORT == dt_type)) {
+ ConfigVal *cfg_val = ikey->get_cfg_val();
+ switch (operation) {
+ case UNC_OP_CREATE:
+ if (cfg_val == NULL)
return UPLL_RC_SUCCESS;
+ /* fall through intended */
+ case UNC_OP_UPDATE:
+ {
+ if (!cfg_val)
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ if (cfg_val->get_st_num() != IpctSt::kIpcStValVtn) {
+ UPLL_LOG_INFO(
+ "Invalid Value structure received. received struct - %d",
+ (ikey->get_st_num()));
+ return UPLL_RC_ERR_BAD_REQUEST;
}
- default:
- UPLL_LOG_INFO("Invalid operation ");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else if ((operation == UNC_OP_RENAME || operation == UNC_OP_READ ||
- operation == UNC_OP_READ_SIBLING ||
- operation == UNC_OP_READ_SIBLING_BEGIN) &&
- (dt_type == UPLL_DT_IMPORT)) {
- if (option1 != UNC_OPT1_NORMAL) {
- UPLL_LOG_INFO("Error: option1 is not NORMAL");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- if (option2 != UNC_OPT2_NONE) {
- UPLL_LOG_INFO("Error: option2 is not NONE");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- ConfigVal *cfg_val = ikey->get_cfg_val();
- switch (operation) {
- case UNC_OP_READ:
- case UNC_OP_READ_SIBLING:
- case UNC_OP_READ_SIBLING_BEGIN:
- if (cfg_val == NULL)
- return UPLL_RC_SUCCESS;
- case UNC_OP_RENAME:
- {
- if (!cfg_val)
- return UPLL_RC_ERR_CFG_SYNTAX;
- if (cfg_val->get_st_num() != IpctSt::kIpcStValRenameVtn) {
- UPLL_LOG_INFO(
- "Invalid val_rename structure received. received struct - %d",
- (ikey->get_cfg_val())->get_st_num());
- return UPLL_RC_ERR_BAD_REQUEST;
- }
- val_rename_vtn *vtn_rename =
- reinterpret_cast<val_rename_vtn *>(ikey->get_cfg_val()->get_val());
-
- if (vtn_rename == NULL && operation == UNC_OP_RENAME) {
- UPLL_LOG_INFO(
- "val_rename_vtn struct is Mandatory for Rename operation");
- return UPLL_RC_ERR_BAD_REQUEST;
- } else if (vtn_rename == NULL) {
- UPLL_LOG_DEBUG(
- "syntax check for val_rename_vtn struct is optional");
- return UPLL_RC_SUCCESS;
- }
- ret_val = ValidateVtnRenameValue(vtn_rename);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("syntax check failure for val_rename_vtn structure");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
+ val_vtn *vtn_val = reinterpret_cast<val_vtn *>(GetVal(ikey));
+ if (vtn_val == NULL) {
+ UPLL_LOG_INFO("syntax check for vtn_val struct is an optional");
return UPLL_RC_SUCCESS;
}
- default:
- UPLL_LOG_INFO("Invalid operation ");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else if ((operation == UNC_OP_READ || operation == UNC_OP_READ_SIBLING ||
- operation == UNC_OP_READ_SIBLING_BEGIN ||
- operation == UNC_OP_READ_SIBLING_COUNT) &&
- (dt_type == UPLL_DT_CANDIDATE || dt_type == UPLL_DT_RUNNING ||
- dt_type == UPLL_DT_STARTUP || dt_type == UPLL_DT_STATE)) {
- if (option1 != UNC_OPT1_NORMAL) {
- UPLL_LOG_INFO("Error: option1 is not NORMAL");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- if (option2 != UNC_OPT2_NONE) {
- UPLL_LOG_INFO("Error: option2 is not NONE");
- return UPLL_RC_ERR_INVALID_OPTION2;
+ ret_val = ValidateVtnValue(vtn_val, operation);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("syntax check failure for val_vtn structure");
+ return UPLL_RC_ERR_CFG_SYNTAX;
}
- ConfigVal *cfg_val = ikey->get_cfg_val();
+ return UPLL_RC_SUCCESS;
+ }
+ default:
+ UPLL_LOG_INFO("Invalid operation ");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ } else if ((operation == UNC_OP_RENAME || operation == UNC_OP_READ ||
+ operation == UNC_OP_READ_SIBLING ||
+ operation == UNC_OP_READ_SIBLING_BEGIN) &&
+ (dt_type == UPLL_DT_IMPORT)) {
+ if (option1 != UNC_OPT1_NORMAL) {
+ UPLL_LOG_INFO("Error: option1 is not NORMAL");
+ return UPLL_RC_ERR_INVALID_OPTION1;
+ }
+ if (option2 != UNC_OPT2_NONE) {
+ UPLL_LOG_INFO("Error: option2 is not NONE");
+ return UPLL_RC_ERR_INVALID_OPTION2;
+ }
+ ConfigVal *cfg_val = ikey->get_cfg_val();
+ switch (operation) {
+ case UNC_OP_READ:
+ case UNC_OP_READ_SIBLING:
+ case UNC_OP_READ_SIBLING_BEGIN:
if (cfg_val == NULL)
return UPLL_RC_SUCCESS;
- if (cfg_val->get_st_num() != IpctSt::kIpcStValVtn) {
+ case UNC_OP_RENAME:
+ {
+ if (!cfg_val)
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ if (cfg_val->get_st_num() != IpctSt::kIpcStValRenameVtn) {
UPLL_LOG_INFO(
- "Invalid Value structure received. received struct - %d",
- (cfg_val->get_st_num()));
+ "Invalid val_rename structure received. received struct - %d",
+ (ikey->get_cfg_val())->get_st_num());
return UPLL_RC_ERR_BAD_REQUEST;
}
- val_vtn *vtn_val = reinterpret_cast<val_vtn *>
- (ikey->get_cfg_val()->get_val());
- if (vtn_val == NULL) {
- UPLL_LOG_DEBUG("syntax check for vtn struct is an optional");
+ val_rename_vtn *vtn_rename =
+ reinterpret_cast<val_rename_vtn *>(ikey->get_cfg_val()->get_val());
+
+ if (vtn_rename == NULL && operation == UNC_OP_RENAME) {
+ UPLL_LOG_INFO(
+ "val_rename_vtn struct is Mandatory for Rename operation");
+ return UPLL_RC_ERR_BAD_REQUEST;
+ } else if (vtn_rename == NULL) {
+ UPLL_LOG_DEBUG(
+ "syntax check for val_rename_vtn struct is optional");
return UPLL_RC_SUCCESS;
}
- ret_val = ValidateVtnValue(vtn_val, operation);
+ ret_val = ValidateVtnRenameValue(vtn_rename);
if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Base Validation failure for val_vtn structure");
+ UPLL_LOG_INFO("syntax check failure for val_rename_vtn structure");
return UPLL_RC_ERR_CFG_SYNTAX;
}
return UPLL_RC_SUCCESS;
- } else if ((operation == UNC_OP_READ_NEXT ||
- operation == UNC_OP_READ_BULK) && (dt_type == UPLL_DT_CANDIDATE
- || dt_type == UPLL_DT_STARTUP || dt_type == UPLL_DT_RUNNING ||
- dt_type == UPLL_DT_IMPORT)) {
- UPLL_LOG_TRACE("Value structure is none for operation type:%d",
- operation);
+ }
+ default:
+ UPLL_LOG_INFO("Invalid operation ");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ } else if ((operation == UNC_OP_READ || operation == UNC_OP_READ_SIBLING ||
+ operation == UNC_OP_READ_SIBLING_BEGIN ||
+ operation == UNC_OP_READ_SIBLING_COUNT) &&
+ (dt_type == UPLL_DT_CANDIDATE || dt_type == UPLL_DT_RUNNING ||
+ dt_type == UPLL_DT_STARTUP || dt_type == UPLL_DT_STATE)) {
+ if (option1 != UNC_OPT1_NORMAL) {
+ UPLL_LOG_INFO("Error: option1 is not NORMAL");
+ return UPLL_RC_ERR_INVALID_OPTION1;
+ }
+ if (option2 != UNC_OPT2_NONE) {
+ UPLL_LOG_INFO("Error: option2 is not NONE");
+ return UPLL_RC_ERR_INVALID_OPTION2;
+ }
+ ConfigVal *cfg_val = ikey->get_cfg_val();
+ if (cfg_val == NULL)
return UPLL_RC_SUCCESS;
- } else if ((operation == UNC_OP_DELETE) &&
- (dt_type == UPLL_DT_CANDIDATE || UPLL_DT_IMPORT == dt_type)) {
- UPLL_LOG_TRACE("Value structure is none for operation type:%d",
- operation);
+ if (cfg_val->get_st_num() != IpctSt::kIpcStValVtn) {
+ UPLL_LOG_INFO(
+ "Invalid Value structure received. received struct - %d",
+ (cfg_val->get_st_num()));
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ val_vtn *vtn_val = reinterpret_cast<val_vtn *>
+ (ikey->get_cfg_val()->get_val());
+ if (vtn_val == NULL) {
+ UPLL_LOG_DEBUG("syntax check for vtn struct is an optional");
return UPLL_RC_SUCCESS;
- }
- UPLL_LOG_INFO("Error Unsupported datatype(%d) or operation(%d)",
- dt_type, operation);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+ ret_val = ValidateVtnValue(vtn_val, operation);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("Base Validation failure for val_vtn structure");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ return UPLL_RC_SUCCESS;
+ } else if ((operation == UNC_OP_READ_NEXT ||
+ operation == UNC_OP_READ_BULK) && (dt_type == UPLL_DT_CANDIDATE
+ || dt_type == UPLL_DT_STARTUP || dt_type == UPLL_DT_RUNNING ||
+ dt_type == UPLL_DT_IMPORT)) {
+ UPLL_LOG_TRACE("Value structure is none for operation type:%d",
+ operation);
+ return UPLL_RC_SUCCESS;
+ } else if ((operation == UNC_OP_DELETE) &&
+ (dt_type == UPLL_DT_CANDIDATE || UPLL_DT_IMPORT == dt_type)) {
+ UPLL_LOG_TRACE("Value structure is none for operation type:%d",
+ operation);
+ return UPLL_RC_SUCCESS;
}
+ UPLL_LOG_INFO("Error Unsupported datatype(%d) or operation(%d)",
+ dt_type, operation);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+}
- upll_rc_t
- VtnMoMgr::ValVtnAttributeSupportCheck(const char *ctrlr_name,
- ConfigKeyVal *ikey,
- uint32_t operation) {
- return UPLL_RC_SUCCESS; // TEMP FIX till CAPA CHECK
- UPLL_FUNC_TRACE;
- bool result_code = false;
- uint32_t max_attrs = 0;
- uint32_t instance_count = 0;
- const uint8_t *attrs;
-
- switch (operation) {
- case UNC_OP_CREATE:
- result_code = GetCreateCapability(ctrlr_name,
- ikey->get_key_type(),
- &instance_count,
- &max_attrs,
- &attrs);
- break;
-
- case UNC_OP_UPDATE:
- result_code = GetUpdateCapability(ctrlr_name,
- ikey->get_key_type(),
- &max_attrs,
- &attrs);
- break;
- case UNC_OP_READ:
- case UNC_OP_READ_SIBLING:
- case UNC_OP_READ_SIBLING_BEGIN:
- case UNC_OP_READ_SIBLING_COUNT:
- result_code = GetReadCapability(ctrlr_name,
- ikey->get_key_type(),
- &max_attrs,
- &attrs);
- break;
- default:
- UPLL_LOG_INFO("Invalid operation code(%d)", operation);
- return UPLL_RC_ERR_GENERIC;
- }
- if (!result_code) {
- UPLL_LOG_INFO("key_type - %d is not supported by controller - %s",
- ikey->get_key_type(), ctrlr_name);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
- }
- if (NULL == ikey->get_cfg_val()) {
- UPLL_LOG_INFO("Empty cfg_val is received");
- return UPLL_RC_ERR_GENERIC;
- }
- if ((ikey->get_cfg_val())->get_st_num() != IpctSt::kIpcStValVtn) {
- UPLL_LOG_INFO("value structure matching is invalid. struct.no - %d",
- (ikey->get_cfg_val())->get_st_num());
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
+upll_rc_t
+VtnMoMgr::ValVtnAttributeSupportCheck(val_vtn_t *vtn_val,
+ const uint8_t *attrs,
+ uint32_t operation) {
+ UPLL_FUNC_TRACE;
- val_vtn *vtn_val = reinterpret_cast<val_vtn *>
- (ikey->get_cfg_val()->get_val());
- if (vtn_val !=NULL) {
- if ((vtn_val->valid[UPLL_IDX_DESC_VTN] == UNC_VF_VALID) ||
- (vtn_val->valid[UPLL_IDX_DESC_VTN] == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vtn::kCapDesc] == 0) {
- vtn_val->valid[UPLL_IDX_DESC_VTN] = UNC_VF_NOT_SOPPORTED;
+ if (NULL != vtn_val) {
+ if ((vtn_val->valid[UPLL_IDX_DESC_VTN] == UNC_VF_VALID) ||
+ (vtn_val->valid[UPLL_IDX_DESC_VTN] == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtn::kCapDesc] == 0) {
+ vtn_val->valid[UPLL_IDX_DESC_VTN] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE ||
+ operation == UNC_OP_UPDATE) {
UPLL_LOG_INFO("Description attr is not supported by ctrlr");
return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
}
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_INFO("Error val_vtn struct is NULL");
- return UPLL_RC_ERR_GENERIC;
}
}
+ return UPLL_RC_SUCCESS;
+}
+
+
+upll_rc_t
+VtnMoMgr::ValidateCapability(IpcReqRespHeader * req,
+ ConfigKeyVal * ikey,
+ const char *ctrlr_name) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t ret_val = UPLL_RC_ERR_GENERIC;
+ if (!ikey || !req ) {
+ UPLL_LOG_DEBUG("ConfigKeyVal / IpcReqRespHeader is Null");
+ return ret_val;
+ }
- upll_rc_t
- VtnMoMgr::ValidateCapability(IpcReqRespHeader * req,
- ConfigKeyVal * ikey, const char *cntrl_id) {
- UPLL_FUNC_TRACE;
- upll_rc_t ret_val = UPLL_RC_SUCCESS;
- if (!req || !ikey) {
- UPLL_LOG_INFO("ConfigKeyVal / IpcReqRespHeader is Null");
+ if (!ctrlr_name) {
+ ctrlr_name = reinterpret_cast<char*>((reinterpret_cast<key_user_data_t *>
+ (ikey->get_user_data()))->ctrlr_id);
+ if (!ctrlr_name || !strlen(ctrlr_name)) {
+ UPLL_LOG_DEBUG("Controller Name is NULL");
return UPLL_RC_ERR_GENERIC;
}
- const char *ctrlr_name = reinterpret_cast<char *>(ikey->get_user_data());
- upll_keytype_datatype_t dt_type = req->datatype;
- unc_keytype_operation_t operation = req->operation;
- unc_keytype_option1_t option1 = req->option1;
- unc_keytype_option2_t option2 = req->option2;
-
- UPLL_LOG_INFO("dt_type : (%d)"
- "operation : (%d)"
- "option1 : (%d)"
- "option2 : (%d)",
- dt_type, operation, option1, option2);
-
- if (operation == UNC_OP_CREATE) {
- if (dt_type == UPLL_DT_CANDIDATE || dt_type == UPLL_DT_IMPORT) {
- ret_val = ValVtnAttributeSupportCheck(ctrlr_name, ikey, operation);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Capa check failure for create operation");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_INFO("Error Unsupported datatype (%d)", dt_type);
- return UPLL_RC_ERR_GENERIC;
- }
- } else if (operation == UNC_OP_UPDATE) {
- if (dt_type == UPLL_DT_CANDIDATE) {
- ret_val = ValVtnAttributeSupportCheck(ctrlr_name, ikey, operation);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Capa check failure for Update operation");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_INFO("Error Unsupported datatype (%d)", dt_type);
- return UPLL_RC_ERR_GENERIC;
- }
- } else if (operation == UNC_OP_READ
- || operation == UNC_OP_READ_SIBLING_BEGIN
- || operation == UNC_OP_READ_SIBLING
- || operation == UNC_OP_READ_SIBLING_COUNT) {
- if (dt_type == UPLL_DT_CANDIDATE || dt_type == UPLL_DT_RUNNING
- || dt_type == UPLL_DT_STARTUP || dt_type == UPLL_DT_STATE) {
- if (option1 != UNC_OPT1_NORMAL) {
- UPLL_LOG_INFO("Error: option1 is not NORMAL");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- if (option2 != UNC_OPT2_NONE) {
- UPLL_LOG_INFO("Error: option2 is not NONE");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- if (ikey->get_cfg_val()->get_val() != NULL) {
- ret_val = ValVtnAttributeSupportCheck(ctrlr_name, ikey, operation);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("capa check failure for read operation");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_INFO("capa check for val_vtn struct is an optional");
- return UPLL_RC_SUCCESS;
- }
- } else {
- UPLL_LOG_INFO("Error Unsupported datatype (%d)", dt_type);
- return UPLL_RC_ERR_GENERIC;
+ }
+
+ bool result_code = false;
+ uint32_t max_attrs = 0;
+ uint32_t max_instance_count = 0;
+ const uint8_t *attrs = NULL;
+ switch (req->operation) {
+ case UNC_OP_CREATE:
+ result_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_instance_count, &max_attrs,
+ &attrs);
+ if (result_code && (max_instance_count != 0) &&
+ (cur_instance_count > max_instance_count)) {
+ UPLL_LOG_DEBUG("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
+ __LINE__, __FUNCTION__, cur_instance_count,
+ max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
}
+ break;
+
+ case UNC_OP_UPDATE:
+ result_code = GetUpdateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ break;
+ case UNC_OP_READ:
+ case UNC_OP_READ_SIBLING:
+ case UNC_OP_READ_SIBLING_BEGIN:
+ case UNC_OP_READ_SIBLING_COUNT:
+ result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ break;
+ default:
+ UPLL_LOG_INFO("Invalid operation code(%d)", req->operation);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (!result_code) {
+ UPLL_LOG_INFO("key_type - %d is not supported by controller - %s",
+ ikey->get_key_type(), ctrlr_name);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ val_vtn *vtn_val = NULL;
+ if (ikey->get_cfg_val() && (ikey->get_cfg_val()->get_st_num() ==
+ IpctSt::kIpcStValVtn)) {
+ vtn_val =
+ reinterpret_cast<val_vtn *>(ikey->get_cfg_val()->get_val());
+ }
+ if (vtn_val) {
+ if (max_attrs > 0) {
+ ret_val = ValVtnAttributeSupportCheck(vtn_val, attrs, req->operation);
+ return ret_val;
+ } else {
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d", req->operation);
+ return UPLL_RC_ERR_GENERIC;
}
- UPLL_LOG_INFO("Error Unsupported operation(%d)", operation);
- return UPLL_RC_ERR_GENERIC;
+ }
+ return UPLL_RC_SUCCESS;
}
upll_rc_t VtnMoMgr::IsKeyInUse(upll_keytype_datatype_t dt_type,
const ConfigKeyVal *ckv,
bool *in_use,
DalDmlIntf *dmi) {
- UPLL_FUNC_TRACE;
- ConfigKeyVal *ck_ctrlr = NULL;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- DbSubOp dbop = {kOpReadExist, kOpMatchCtrlr, kOpInOutNone};
- key_ctr *ctr = reinterpret_cast<key_ctr *>(ckv->get_key());
-
- if (!ctr || !strlen(reinterpret_cast<char *>(ctr->controller_name))) {
- UPLL_LOG_DEBUG("Controller Name invalid");
- return UPLL_RC_ERR_GENERIC;
- }
- uint8_t *controllerName = reinterpret_cast<uint8_t *>(
- new char[kMaxLenCtrlrId+1]);
- if (!controllerName) {
- UPLL_LOG_DEBUG("memory allocation failed");
- return UPLL_RC_ERR_GENERIC;
- }
- uuu::upll_strncpy(controllerName, ctr->controller_name,
- (kMaxLenCtrlrId + 1));
- result_code = GetChildConfigKey(ck_ctrlr,NULL);
- if (!ck_ctrlr || result_code != UPLL_RC_SUCCESS) {
- delete[] controllerName;
- UPLL_LOG_DEBUG("Controller key allocation failed");
- return UPLL_RC_ERR_GENERIC;
- }
- SET_USER_DATA_CTRLR(ck_ctrlr, controllerName);
+ UPLL_FUNC_TRACE;
+ ConfigKeyVal *ck_ctrlr = NULL;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ DbSubOp dbop = {kOpReadExist, kOpMatchCtrlr, kOpInOutNone};
+ key_ctr *ctr = reinterpret_cast<key_ctr *>(ckv->get_key());
- // result_code = ReadConfigDB(ck_ctrlr, UPLL_DT_RUNNING,
- // UNC_OP_READ, dbop, dmi, CTRLRTBL);
- result_code = UpdateConfigDB(ck_ctrlr, dt_type, UNC_OP_READ,
- dmi, &dbop, CTRLRTBL);
- *in_use = (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) ? true : false;
- delete ck_ctrlr;
- delete []controllerName;
- UPLL_LOG_DEBUG("Returning %d", result_code);
- return ((result_code == UPLL_RC_ERR_INSTANCE_EXISTS ||
- result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)
- ? UPLL_RC_SUCCESS : result_code);
+ if (!ctr || !strlen(reinterpret_cast<char *>(ctr->controller_name))) {
+ UPLL_LOG_DEBUG("Controller Name invalid");
+ return UPLL_RC_ERR_GENERIC;
}
-
- upll_rc_t
- VtnMoMgr::ValidateMessageForVtnStnCtrlr(IpcReqRespHeader * req,
- ConfigKeyVal * ikey) {
- UPLL_FUNC_TRACE;
- upll_rc_t ret_val = UPLL_RC_SUCCESS;
- if (!req || !ikey || !(ikey->get_key())) {
- UPLL_LOG_INFO("ConfigKeyVal / IpcReqRespHeader is Null");
- return UPLL_RC_ERR_GENERIC;
- }
- if (ikey->get_st_num() != IpctSt::kIpcStKeyVtnstationController) {
- UPLL_LOG_INFO("Invalid Key structure received. received struct - %d",
- (ikey->get_st_num()));
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- key_vtnstation_controller *vtn_ctrlr_key =
- reinterpret_cast<key_vtnstation_controller *> (ikey->get_key());
-
- if ((req->operation == UNC_OP_READ) ||
- (req->operation == UNC_OP_READ_SIBLING) ||
- (req->operation == UNC_OP_READ_SIBLING_BEGIN) ||
- (req->operation == UNC_OP_READ_SIBLING_COUNT)) {
- if (req->datatype == UPLL_DT_STATE) {
- if ((req->option1 != UNC_OPT1_NORMAL) &&
- (req->option1 != UNC_OPT1_DETAIL) &&
- (req->option1 != UNC_OPT1_COUNT)) {
- UPLL_LOG_INFO(" Error: option1 is invalid");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- if (req->option2 != UNC_OPT2_NONE) {
- UPLL_LOG_INFO(" Error: option2 is not NONE");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- ret_val = ValidateVtnStnCtrlrKey(vtn_ctrlr_key, req->operation);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("vtn_stn_ctrlr_key syntax check failed.");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_INFO("Error Unsupported datatype (%d)", req->datatype);
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
- }
- }
- UPLL_LOG_INFO("Error Unsupported Operation (%d)", req->operation);
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ uint8_t *controllerName = reinterpret_cast<uint8_t *>(
+ new char[kMaxLenCtrlrId+1]);
+ uuu::upll_strncpy(controllerName, ctr->controller_name,
+ (kMaxLenCtrlrId + 1));
+ result_code = GetChildConfigKey(ck_ctrlr, NULL);
+ if (!ck_ctrlr || result_code != UPLL_RC_SUCCESS) {
+ delete[] controllerName;
+ UPLL_LOG_DEBUG("Controller key allocation failed");
+ return UPLL_RC_ERR_GENERIC;
}
+ SET_USER_DATA_CTRLR(ck_ctrlr, controllerName);
- upll_rc_t
- VtnMoMgr::ValidateMessageForVtnMapCtrlr(IpcReqRespHeader * req,
- ConfigKeyVal * ikey) {
- UPLL_FUNC_TRACE;
- if (!req || !ikey || !(ikey->get_key())) {
- UPLL_LOG_INFO("ConfigKeyVal / IpcReqRespHeader is Null");
- return UPLL_RC_ERR_GENERIC;
- }
- upll_keytype_datatype_t dt_type = req->datatype;
- unc_keytype_operation_t operation = req->operation;
- unc_keytype_option1_t option1 = req->option1;
- unc_keytype_option2_t option2 = req->option2;
-
- upll_rc_t ret_val = UPLL_RC_SUCCESS;
- if (ikey->get_st_num() != IpctSt::kIpcStKeyVtnController) {
- UPLL_LOG_INFO("Invalid key structure received. received struct - %d",
- (ikey->get_st_num()));
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- key_vtn_controller *vtn_ctrlr_key =
- reinterpret_cast<key_vtn_controller *> (ikey->get_key());
+ // result_code = ReadConfigDB(ck_ctrlr, UPLL_DT_RUNNING,
+ // UNC_OP_READ, dbop, dmi, CTRLRTBL);
+ result_code = UpdateConfigDB(ck_ctrlr, dt_type, UNC_OP_READ,
+ dmi, &dbop, CTRLRTBL);
+ *in_use = (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) ? true : false;
+ delete ck_ctrlr;
+ delete []controllerName;
+ UPLL_LOG_DEBUG("Returning %d", result_code);
+ return ((result_code == UPLL_RC_ERR_INSTANCE_EXISTS ||
+ result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)
+ ? UPLL_RC_SUCCESS : result_code);
+}
- if (operation == UNC_OP_READ || operation == UNC_OP_READ_SIBLING
- || operation == UNC_OP_READ_SIBLING_BEGIN) {
- if (dt_type == UPLL_DT_STATE) {
- if (option1 != UNC_OPT1_NORMAL) {
- UPLL_LOG_INFO(" Error: option1 is not NORMAL");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- if (option2 != UNC_OPT2_NONE) {
- UPLL_LOG_INFO(" Error: option2 is not NONE");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- ret_val = ValidateVtnMapCtrlrKey(vtn_ctrlr_key, operation);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("syntax check for key_vtn_ctrlr struct is failed");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- UPLL_LOG_TRACE("value struct validation is none for this keytype");
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_INFO("Error Unsupported datatype (%d)", dt_type);
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
- }
- }
- UPLL_LOG_INFO("Error Unsupported operation(%d)", operation);
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+upll_rc_t
+VtnMoMgr::ValidateMessageForVtnStnCtrlr(IpcReqRespHeader * req,
+ ConfigKeyVal * ikey) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ if (!req || !ikey || !(ikey->get_key())) {
+ UPLL_LOG_INFO("ConfigKeyVal / IpcReqRespHeader is Null");
+ return UPLL_RC_ERR_GENERIC;
}
+ if (ikey->get_st_num() != IpctSt::kIpcStKeyVtnstationController) {
+ UPLL_LOG_INFO("Invalid Key structure received. received struct - %d",
+ (ikey->get_st_num()));
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ key_vtnstation_controller *vtn_ctrlr_key =
+ reinterpret_cast<key_vtnstation_controller *> (ikey->get_key());
- upll_rc_t
- VtnMoMgr::ValidateVtnMapCtrlrKey(key_vtn_controller * vtn_ctrlr_key,
- unc_keytype_operation_t operation) {
- UPLL_FUNC_TRACE;
- upll_rc_t ret_val = UPLL_RC_SUCCESS;
-
- ret_val = ValidateKey(
- reinterpret_cast<char *>(vtn_ctrlr_key->vtn_key.vtn_name),
- kMinLenVtnName, kMaxLenVtnName);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("vtn name syntax check failed."
- "Received vtn_Name - %s",
- vtn_ctrlr_key->vtn_key.vtn_name);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- if ((operation != UNC_OP_READ_SIBLING_COUNT) &&
- (operation != UNC_OP_READ_SIBLING_BEGIN)) {
- ret_val = ValidateKey(
- reinterpret_cast<char *>(vtn_ctrlr_key->controller_name),
- kMinLenCtrlrId, kMaxLenCtrlrId);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("controller_name syntax check failed."
- "Received controller_name - %s",
- vtn_ctrlr_key->controller_name);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ if ((req->operation == UNC_OP_READ) ||
+ (req->operation == UNC_OP_READ_SIBLING) ||
+ (req->operation == UNC_OP_READ_SIBLING_BEGIN) ||
+ (req->operation == UNC_OP_READ_SIBLING_COUNT)) {
+ if (req->datatype == UPLL_DT_STATE) {
+ if ((req->option1 != UNC_OPT1_NORMAL) &&
+ (req->option1 != UNC_OPT1_DETAIL) &&
+ (req->option1 != UNC_OPT1_COUNT)) {
+ UPLL_LOG_INFO(" Error: option1 is invalid");
+ return UPLL_RC_ERR_INVALID_OPTION1;
}
- ret_val = ValidateDefaultStr(
- reinterpret_cast<char *>(vtn_ctrlr_key->domain_id),
- kMinLenDomainId, kMaxLenDomainId);
- if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Domain_id syntax check failed."
- "Received Domain_id - %s",
- vtn_ctrlr_key->domain_id);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ if (req->option2 != UNC_OPT2_NONE) {
+ UPLL_LOG_INFO(" Error: option2 is not NONE");
+ return UPLL_RC_ERR_INVALID_OPTION2;
}
- } else {
- UPLL_LOG_TRACE("Operation is %d", operation);
- StringReset(vtn_ctrlr_key->controller_name);
- StringReset(vtn_ctrlr_key->domain_id);
- }
- return UPLL_RC_SUCCESS;
- }
- upll_rc_t
- VtnMoMgr::ValidateVtnStnCtrlrKey(key_vtnstation_controller * vtn_ctrlr_key,
- unc_keytype_operation_t operation) {
- UPLL_FUNC_TRACE;
- upll_rc_t ret_val = UPLL_RC_SUCCESS;
- if ((operation != UNC_OP_READ_SIBLING_COUNT) &&
- (operation != UNC_OP_READ_SIBLING_BEGIN)) {
- ret_val = ValidateKey(
- reinterpret_cast<char *>(vtn_ctrlr_key->controller_name),
- kMinLenCtrlrId, kMaxLenCtrlrId);
+ ret_val = ValidateVtnStnCtrlrKey(vtn_ctrlr_key, req->operation);
if (ret_val != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("controller_name syntax check failed."
- "Received controller_name - %s",
- vtn_ctrlr_key->controller_name);
+ UPLL_LOG_INFO("vtn_stn_ctrlr_key syntax check failed.");
return UPLL_RC_ERR_CFG_SYNTAX;
}
+ return UPLL_RC_SUCCESS;
} else {
- UPLL_LOG_TRACE("Operation is %d", operation);
- StringReset(vtn_ctrlr_key->controller_name);
+ UPLL_LOG_INFO("Error Unsupported datatype (%d)", req->datatype);
+ return UPLL_RC_ERR_NO_SUCH_INSTANCE;
}
- return UPLL_RC_SUCCESS;
}
+ UPLL_LOG_INFO("Error Unsupported Operation (%d)", req->operation);
+ return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+}
-#if 0
- /* Function is invoked upon a controller disconnect/connect */
+upll_rc_t
+VtnMoMgr::ValidateMessageForVtnMapCtrlr(IpcReqRespHeader * req,
+ ConfigKeyVal * ikey) {
+ UPLL_FUNC_TRACE;
+ if (!req || !ikey || !(ikey->get_key())) {
+ UPLL_LOG_INFO("ConfigKeyVal / IpcReqRespHeader is Null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ upll_keytype_datatype_t dt_type = req->datatype;
+ unc_keytype_operation_t operation = req->operation;
+ unc_keytype_option1_t option1 = req->option1;
+ unc_keytype_option2_t option2 = req->option2;
- upll_rc_t VtnMoMgr::ConnectionStatusHandler(uint8_t *ctrlr_name,
- DalDmlIntf *dmi, uint8_t *notification) {
- UPLL_FUNC_TRACE;
- strncpy(reinterpret_cast<char *>(notification), "CONNECTION_FAULT",
- sizeof(notification));
- /* Set to store all the vtns connected to the given controller */
- set<key_vtn_t>VtnSet;
- set<key_vtn_t>::iterator vtnset_itr;
- /* Function gives all the connected vtns to the controller specified */
- UpdateVtnNodeOperStatus(ctrlr_name, &VtnSet, dmi, notification);
- /* Iterating through all the vtns in the vtnset */
- for (vtnset_itr = VtnSet.begin(); vtnset_itr != VtnSet.end(); ++vtnset_itr) {
- strncpy(reinterpret_cast<char *>(vtn_name_o),
- (const char *)vtnset_itr->vtn_name, sizeof(vtn_name_o));
- /* Function sets Operstatus of Vtn to Unknown */
- VtnSetOperStatus(vtn_name_o, dmi, notification);
- /* Function gives all the vlinks under the given vtn and
- * sets OperStatus to Unknown */
- UpdateVtnVlinkOperStatus(vtn_name_o, dmi);
- }
- return UPLL_RC_SUCCESS;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ if (ikey->get_st_num() != IpctSt::kIpcStKeyVtnController) {
+ UPLL_LOG_INFO("Invalid key structure received. received struct - %d",
+ (ikey->get_st_num()));
+ return UPLL_RC_ERR_CFG_SYNTAX;
}
+ key_vtn_controller *vtn_ctrlr_key =
+ reinterpret_cast<key_vtn_controller *> (ikey->get_key());
- /* Get Vtns connected to the specified Controller name */
- upll_rc_t ConnectionStatus::UpdateVtnNodeOperStatus(uint8_t *ctrlr_name,
- set<key_vtn_t>*VtnSet,
- DalDmlIntf *dmi, uint8_t *notification) {
- UPLL_FUNC_TRACE;
- key_vtn_t *vtn_ctrlr_key = reinterpret_cast<key_vtn_t *>
- (malloc(sizeof(key_vtn_t)));
- ConfigKeyVal *ck_vtn_ctrlr_key = NULL;
- ck_vtn_ctrlr_key = new ConfigKeyVal(UNC_KT_VTN,
- IpctSt::kIpcStKeyVtn, vtn_ctrlr_key, NULL);
- SET_USER_DATA_CTRLR(ck_vtn_ctrlr_key, ctrlr_name);
- /* Get all the vtns with the specified controller name */
- DbSubOp dbop = {kOpReadMultiple, kOpMatchCtrlr, kOpInOutNone};
- upll_rc_t result_code = ReadConfigDB(ck_vtn_ctrlr_key, UPLL_DT_RUNNING,
- UNC_OP_READ, dbop, dmi, CTRLRTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Error in reading:%d", result_code);
- return result_code;
- }
- /* Initialising array of unc_key_types */
- unc_key_type_t node_key_type[]= {UNC_KT_VBRIDGE, UNC_KT_VROUTER, UNC_KT_VTEP,
- UNC_KT_VTUNNEL};
- ConfigKeyVal *ck_val = NULL;
- /* Populating vtnset with vtn names connected to given controller name */
- while (ck_vtn_ctrlr_key != NULL) {
- VtnSet.insert(*(reinterpret_cast<key_vtn *>)(ck_vtn_ctrlr_key->get_key()));
- /* Iterating through each node type in unc key type */
- for (int i = 0; i < sizeof(node_key_type)/sizeof(unc_key_type_t); i++) {
- const unc_key_type_t ktype = node_key_type[i];
- MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(GetMoManager(ktype));
- mgr->GetChildConfigKey(ck_val, ck_vtn_ctrlr_key);
- DbSubOp dbop = {kOpReadMultiple, kOpMatchCtrlr, kOpInOutNone};
- SET_USER_DATA_CTRLR(ck_val, ctrlr_name);
- upll_rc_t result_code = mgr->ReadConfigDB(ck_val, UPLL_DT_STATE,
- UNC_OP_READ, dbop, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Error in reading:%d", result_code);
- return result_code;
- }
- key_vnode_t *vnode_key = (*(reinterpret_cast<key_vnode_t*>)
- (ck_val->get_key()));
- while (ck_val != NULL) {
- switch (ktype) {
- case UNC_KT_VBRIDGE:
- {
- mgr->SetOperStatus<val_vbr_st_t *>(ck_val, ktype, dmi,
- notification);
- MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>
- (GetMoManager(UNC_KT_VBR_IF));
- mgr->SetIfOperStatus(ck_val, vnode_key, dmi);
- break;
- }
- case UNC_KT_VROUTER:
- {
- mgr->SetOperStatus<val_vrt_st_t *>(ck_val, ktype, dmi,
- notification);
- MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>
- (GetMoManager(UNC_KT_VRT_IF));
- mgr->SetIfOperStatus(ck_val, vnode_key, dmi);
- break;
- }
- case UNC_KT_VTEP:
- {
- mgr->SetOperStatus<val_vtep_st_t *>(ck_val, ktype, dmi,
- notification);
- MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>
- (GetMoManager(UNC_KT_VTEP_IF));
- mgr->SetIfOperStatus(ck_val, vnode_key, dmi);
- break;
- }
- case UNC_KT_VTUNNEL:
- {
- mgr->SetOperStatus<val_vtunnel_st_t *>(ck_val, ktype, dmi,
- notification);
- MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>
- (GetMoManager(UNC_KT_VTUNNEL_IF));
- mgr->SetIfOperStatus(ck_val, vnode_key, dmi);
- break;
- }
- default:
- break;
- }
- ck_val = ck_val->get_next_cfg_key_val();
- }
+ if (operation == UNC_OP_READ || operation == UNC_OP_READ_SIBLING
+ || operation == UNC_OP_READ_SIBLING_BEGIN) {
+ if (dt_type == UPLL_DT_STATE) {
+ if (option1 != UNC_OPT1_NORMAL) {
+ UPLL_LOG_INFO(" Error: option1 is not NORMAL");
+ return UPLL_RC_ERR_INVALID_OPTION1;
}
- if (ck_val)
- delete ck_val;
- val_vtn_st_t *val_vtnst = reinterpret_cast<val_vtn_st_t*>
- (GetVal(ck_vtn_ctrlr_key));
- if (!val_vtnst) return UPLL_RC_ERR_GENERIC;
- val_vtnst->oper_status = UPLL_OPER_STATUS_UNKNOWN;
- val_vtn->valid[UPLL_IDX_OPER_STATUS_VS] = UNC_VF_VALID;
- result_code = UpdateConfigDB(ck_val, UPLL_DT_RUNNING, UNC_OP_UPDATE,
- dmi, CTRLRTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Error in update oper status");
+ if (option2 != UNC_OPT2_NONE) {
+ UPLL_LOG_INFO(" Error: option2 is not NONE");
+ return UPLL_RC_ERR_INVALID_OPTION2;
}
-
- ck_vtn_ctrlr_key = ck_vtn_ctrlr_key->get_next_cfg_key_val();
+ ret_val = ValidateVtnMapCtrlrKey(vtn_ctrlr_key, operation);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("syntax check for key_vtn_ctrlr struct is failed");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ UPLL_LOG_TRACE("value struct validation is none for this keytype");
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_INFO("Error Unsupported datatype (%d)", dt_type);
+ return UPLL_RC_ERR_NO_SUCH_INSTANCE;
}
- /* Delete the ck_vtn_ctrlr_key pointer */
- if (ck_vtn_ctrlr_key)
- delete ck_vtn_ctrlr_key;
- return UPLL_RC_SUCCESS;
}
+ UPLL_LOG_INFO("Error Unsupported operation(%d)", operation);
+ return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+}
- /* Get all the vlinks connected to vtn and all the
- * vnodes connected to vlinks */
- upll_rc_t VtnMoMgr::UpdateVtnVlinkOperStatus(uint8_t *vtn_name_o,
- DalDmlIntf *dmi, uint8_t *notification) {
- UPLL_FUNC_TRACE;
- /* Initialising Key and val vlink structure */
- ConfigKeyVal *ck_vlink = NULL;
- key_vlink_t *vlink_key = reinterpret_cast<key_vlink_t *>
- malloc(sizeof(key_vlink_t));
- if (!vlink_key) return UPLL_RC_ERR_GENERIC;
- memset(vlink_key, 0, sizeof(vlink_key));
- /*copy the vtn name connected to controller into key_vlink vtn name */
- strncpy(reinterpret_cast<char *>vlink_key->vtn_key.vtn_name,
- (const char *)vtn_name_o, sizeof(vlink_key->vtn_key.vtn_name));
- ck_vlink = new ConfigKeyVal(UNC_KT_VLINK, IpctSt::kIpcStKeyVlink,
- vlink_key, NULL);
- VlinkMoMgr *mgr = reinterpret_cast<VlinkMoMgr *>GetMoManager(UNC_KT_VLINK);
- result_code = mgr->SetOperStatus(ck_vlink, dmi, notification);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Record updation failed in UPLL_DT_STATE %d",
- result_code);
- return result_code;
- }
- if (ck_vlink)
- delete ck_vlink;
- return UPLL_RC_SUCCESS;
- }
+upll_rc_t
+VtnMoMgr::ValidateVtnMapCtrlrKey(key_vtn_controller * vtn_ctrlr_key,
+ unc_keytype_operation_t operation) {
+ UPLL_FUNC_TRACE;
- /* Set operstatus of vnode_if's of vnode ubder specified vtn to unknown */
- upll_rc_t ConnectionStatus::SetIfOperStatus(ConfigKeyval ck_val,
- key_vnode_t vnode_key, DalDmlIntf dmi) {
- UPLL_FUNC_TRACE;
- ConfigKeyVal *ck_vnode = NULL;
- mgr->GetChildConfigKey(ck_vnode, ck_val);
- DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutNone};
- upll_rc_t result_code = ReadConfigDB(ck_vnode, UPLL_DT_STATE,
- UNC_OP_READ, dbop, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Error in reading:%d", result_code);
- return result_code;
+ if (!ValidateString(
+ vtn_ctrlr_key->vtn_key.vtn_name,
+ kMinLenVtnName, kMaxLenVtnName)) {
+ UPLL_LOG_INFO("vtn name syntax check failed."
+ "Received vtn_Name - %s",
+ vtn_ctrlr_key->vtn_key.vtn_name);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ if ((operation != UNC_OP_READ_SIBLING_COUNT) &&
+ (operation != UNC_OP_READ_SIBLING_BEGIN)) {
+ if (!ValidateString(
+ vtn_ctrlr_key->controller_name,
+ kMinLenCtrlrId, kMaxLenCtrlrId)) {
+ UPLL_LOG_INFO("controller_name syntax check failed."
+ "Received controller_name - %s",
+ vtn_ctrlr_key->controller_name);
+ return UPLL_RC_ERR_CFG_SYNTAX;
}
- ConfigVal *tmp = (ck_val->get_cfg_val())?
- ck_val->get_cfg_val()->get_next_cfg_val():NULL;
- tmp->get_val():NULL;
- while (ck_vnode != NULL) {
- switch (vnode_key) {
- case UNC_KT_VBRIDGE:
- {
- val_vbr_if_st_t *vbr_if_valst = reinterpret_cast<val_vbr_if_st_t *>
- ((tmp != NULL)?tmp->get_val():NULL);
- if (vbr_if_valst == NULL) return UPLL_RC_ERR_GENERIC;
- vbr_if_valst->oper_status = UPLL_OPER_STATUS_UNKNOWN;
- break;
- }
- case UNC_KT_VROUTER:
- {
- val_vrt_if_st_t *vrt_if_valst = reinterpret_cast<val_vrt_if_st_t *>
- ((tmp != NULL)?tmp->get_val():NULL);
- if (vrt_if_valst == NULL) return UPLL_RC_ERR_GENERIC;
- vrt_if_valst->oper_status = UPLL_OPER_STATUS_UNKNOWN;
- break;
- }
- case UNC_KT_VTEP:
- {
- val_vtep_if_st_t *vtep_if_valst = reinterpret_cast<val_vtep_if_st_t *>
- ((tmp != NULL)?tmp->get_val():NULL);
- if (vtep_if_valst == NULL) return UPLL_RC_ERR_GENERIC;
- vtep_if_valst->oper_status = UPLL_OPER_STATUS_UNKNOWN;
- break;
- }
- case UNC_KT_VTUNNEL:
- {
- val_vtunnel_if_st_t *vtunnel_if_valst =
- reinterpret_cast<val_vtunnel_if_st_t *>((tmp != NULL)?
- tmp->get_val():NULL);
- if (vtunnel_if_valst == NULL) return UPLL_RC_ERR_GENERIC;
- vtunnel_if_valst->oper_status = UPLL_OPER_STATUS_UNKNOWN;
- break;
- }
- default:
- break;
- }
- ck_vnode = ck_vnode->get_next_cfg_key_val();
+ if (!ValidateDefaultStr(vtn_ctrlr_key->domain_id,
+ kMinLenDomainId, kMaxLenDomainId)) {
+ UPLL_LOG_INFO("Domain_id syntax check failed."
+ "Received Domain_id - %s",
+ vtn_ctrlr_key->domain_id);
+ return UPLL_RC_ERR_CFG_SYNTAX;
}
- result_code = UpdateConfigDB(ck_vtn, UPLL_DT_STATE, UNC_OP_UPDATE,
- dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_INFO("Error in update oper status");
+ } else {
+ UPLL_LOG_TRACE("Operation is %d", operation);
+ StringReset(vtn_ctrlr_key->controller_name);
+ StringReset(vtn_ctrlr_key->domain_id);
+ }
+ return UPLL_RC_SUCCESS;
+}
+upll_rc_t
+VtnMoMgr::ValidateVtnStnCtrlrKey(key_vtnstation_controller * vtn_ctrlr_key,
+ unc_keytype_operation_t operation) {
+ UPLL_FUNC_TRACE;
+ if ((operation != UNC_OP_READ_SIBLING_COUNT) &&
+ (operation != UNC_OP_READ_SIBLING_BEGIN)) {
+ if (!ValidateString(vtn_ctrlr_key->controller_name,
+ kMinLenCtrlrId, kMaxLenCtrlrId)) {
+ UPLL_LOG_INFO("controller_name syntax check failed."
+ "Received controller_name - %s",
+ vtn_ctrlr_key->controller_name);
+ return UPLL_RC_ERR_CFG_SYNTAX;
}
- return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_TRACE("Operation is %d", operation);
+ StringReset(vtn_ctrlr_key->controller_name);
}
+ return UPLL_RC_SUCCESS;
+}
-#endif
-
-
-bool VtnMoMgr::SetOperStatus(ConfigKeyVal *ikey,
+upll_rc_t VtnMoMgr::SetOperStatus(ConfigKeyVal *ikey,
state_notification notification,
DalDmlIntf *dmi) {
- bool result = false;
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
if (!ikey) {
UPLL_LOG_DEBUG("Invalid param");
- return false;
+ return UPLL_RC_ERR_GENERIC;
}
ConfigVal *tmp = (ikey->get_cfg_val()) ?
ikey->get_cfg_val()->get_next_cfg_val() : NULL;
- val_db_vtn_st_t *vtn_valst = reinterpret_cast<val_db_vtn_st_t *>((tmp != NULL) ? tmp->get_val() : NULL);
+ val_db_vtn_st_t *vtn_valst = reinterpret_cast<val_db_vtn_st_t *>
+ ((tmp != NULL) ? tmp->get_val() : NULL);
if (vtn_valst == NULL) {
UPLL_LOG_DEBUG("Invalid param");
- return false;
+ return UPLL_RC_ERR_GENERIC;
}
val_vtn_st_t *vtn_val = reinterpret_cast<val_vtn_st_t *>(vtn_valst);
/* Update oper status based on notification */
+ if (((notification != kCtrlrReconnectIfUp) &&
+ (notification != kCtrlrReconnectIfDown) &&
+ (notification != kCtrlrReconnect)) &&
+ (vtn_val->oper_status == UPLL_OPER_STATUS_UNKNOWN)) {
+ return result_code;
+ }
vtn_val->valid[0] = UNC_VF_VALID;
switch (notification) {
+ case kCtrlrReconnectIfUp:
+ if (vtn_val->oper_status == UPLL_OPER_STATUS_DOWN) {
+ return UPLL_RC_SUCCESS;
+ }
+ vtn_val->oper_status = UPLL_OPER_STATUS_UP;
+ break;
+ case kCtrlrReconnectIfDown:
+ vtn_val->oper_status = UPLL_OPER_STATUS_DOWN;
+ break;
case kCtrlrReconnect:
- return false;
+ vtn_val->oper_status = UPLL_OPER_STATUS_DOWN;
+ break;
+ case kAdminStatusEnabled:
+ if (vtn_valst->down_count == 0) {
+ vtn_val->oper_status = UPLL_OPER_STATUS_UNINIT;
+ // reset alarm
+ } else
+ vtn_val->oper_status = UPLL_OPER_STATUS_DOWN;
+ break;
+ case kAdminStatusDisabled:
+ vtn_val->oper_status = UPLL_OPER_STATUS_DOWN;
+ break;
case kCtrlrDisconnect:
vtn_val->oper_status = UPLL_OPER_STATUS_UNKNOWN;
break;
if (vtn_valst->down_count == 1) {
vtn_val->oper_status = UPLL_OPER_STATUS_DOWN;
// generate alarm
- result = true;
}
break;
case kPortFaultReset:
vtn_valst->down_count = (vtn_valst->down_count > 0) ?
(vtn_valst->down_count - 1) : 0;
if (vtn_valst->down_count == 0) {
- vtn_val->oper_status = UPLL_OPER_STATUS_UP;
+ vtn_val->oper_status = UPLL_OPER_STATUS_UNINIT;
// reset alarm
- result = true;
}
break;
}
- upll_rc_t result_code = UpdateConfigDB(ikey, UPLL_DT_STATE, UNC_OP_UPDATE,
- dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d", result_code);
- }
- return result;
+
+ DbSubOp dbop = { kOpNotRead, kOpMatchNone, kOpInOutNone };
+ result_code = UpdateConfigDB(ikey, UPLL_DT_STATE, UNC_OP_UPDATE,
+ dmi, &dbop, MAINTBL);
+ UPLL_LOG_DEBUG("SetOperstatus for VTN after Update is \n %s",
+ ikey->ToStrAll().c_str());
+ return result_code;
}
-bool VtnMoMgr::SetCtrlrOperStatus(ConfigKeyVal *ikey,
+upll_rc_t VtnMoMgr::SetCtrlrOperStatus(ConfigKeyVal *ikey,
state_notification notification,
- DalDmlIntf *dmi) {
- bool result = false;
- if (!ikey) return UPLL_RC_ERR_GENERIC;
+ DalDmlIntf *dmi, bool &oper_change) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ if (!ikey) {
+ UPLL_LOG_DEBUG("ikey is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
val_vtn_ctrlr *ctrlr_val = reinterpret_cast<val_vtn_ctrlr *>(GetVal(ikey));
- if (ctrlr_val == NULL) return UPLL_RC_ERR_GENERIC;
+ if (!ctrlr_val) {
+ UPLL_LOG_DEBUG("val_vtn_ctrlr struct is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
- /* Update oper status based on notification */
+ /* Update oper status based on notification */
switch (notification) {
+ case kCtrlrReconnectIfUp:
+ if (ctrlr_val->oper_status == UPLL_OPER_STATUS_DOWN) {
+ return UPLL_RC_SUCCESS;
+ }
+ oper_change = (ctrlr_val->oper_status != UPLL_OPER_STATUS_UP)?
+ true:false;
+ ctrlr_val->oper_status = UPLL_OPER_STATUS_UP;
+ break;
+ case kCtrlrReconnectIfDown:
+ oper_change = (ctrlr_val->oper_status != UPLL_OPER_STATUS_DOWN)?
+ true:false;
+ ctrlr_val->oper_status = UPLL_OPER_STATUS_DOWN;
+ break;
case kCtrlrReconnect:
- return false;
+ oper_change = (ctrlr_val->oper_status != UPLL_OPER_STATUS_DOWN)?
+ true:false;
+ ctrlr_val->oper_status = UPLL_OPER_STATUS_DOWN;
+ break;
case kCtrlrDisconnect:
+ oper_change = (ctrlr_val->oper_status != UPLL_OPER_STATUS_UNKNOWN)?
+ true:false;
ctrlr_val->oper_status = UPLL_OPER_STATUS_UNKNOWN;
+ ctrlr_val->down_count = 0;
break;
+ case kAdminStatusDisabled:
case kPortFault:
case kPathFault:
case kBoundaryFault:
ctrlr_val->down_count = (ctrlr_val->down_count + 1);
+ oper_change = (ctrlr_val->oper_status != UPLL_OPER_STATUS_DOWN)?
+ true:false;
if (ctrlr_val->down_count == 1) {
ctrlr_val->oper_status = UPLL_OPER_STATUS_DOWN;
// generate alarm
- result = true;
}
break;
+ case kAdminStatusEnabled:
case kPortFaultReset:
case kPathFaultReset:
case kBoundaryFaultReset:
+ if (ctrlr_val->oper_status == UPLL_OPER_STATUS_UP) {
+ oper_change = false;
+ UPLL_LOG_DEBUG("SetCtrlrOperstatus status already up\n %s",
+ ikey->ToStrAll().c_str());
+ return UPLL_RC_SUCCESS;
+ }
ctrlr_val->down_count = (ctrlr_val->down_count > 0) ?
(ctrlr_val->down_count - 1) : 0;
if (ctrlr_val->down_count == 0) {
+ oper_change = (ctrlr_val->oper_status != UPLL_OPER_STATUS_UP)?
+ true:false;
ctrlr_val->oper_status = UPLL_OPER_STATUS_UP;
// reset alarm
- result = true;
- }
+ } else
+ ctrlr_val->oper_status = UPLL_OPER_STATUS_DOWN;
break;
}
- upll_rc_t result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_UPDATE,
- dmi, CTRLRTBL);
+ DbSubOp dbop = { kOpNotRead, kOpMatchCtrlr | kOpMatchDomain, kOpInOutNone };
+ if (notification == kCtrlrDisconnect ||
+ notification == kCtrlrReconnectIfUp ||
+ notification == kCtrlrReconnectIfDown)
+ dbop.matchop = kOpMatchCtrlr;
+ result_code = UpdateConfigDB(ikey, UPLL_DT_STATE, UNC_OP_UPDATE,
+ dmi, &dbop, CTRLRTBL);
+ UPLL_LOG_DEBUG("SetCtrlrOperstatus for VTN after Update is \n %s",
+ ikey->ToStrAll().c_str());
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d", result_code);
+ UPLL_LOG_DEBUG("Error in update oper status %d", result_code);
}
- return result;
+ return result_code;
}
upll_rc_t VtnMoMgr::UpdateOperStatus(ConfigKeyVal *ck_vtn,
DalDmlIntf *dmi,
state_notification notification,
bool skip) {
- upll_rc_t result_code;
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
if (!skip) {
- DbSubOp dbop = { kOpReadMultiple, kOpMatchCtrlr | kOpMatchDomain, kOpInOutNone };
- result_code = ReadConfigDB(ck_vtn, UPLL_DT_RUNNING, UNC_OP_READ, dbop, dmi,
- CTRLRTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- delete ck_vtn;
- UPLL_LOG_DEBUG("Error in reading: %d", result_code);
- return result_code;
- }
+ DbSubOp dbop = { kOpReadMultiple,
+ kOpMatchCtrlr | kOpMatchDomain, kOpInOutNone };
+ if (notification == kCtrlrDisconnect ||
+ notification == kCtrlrReconnectIfUp ||
+ notification == kCtrlrReconnectIfDown )
+ dbop.matchop = kOpMatchCtrlr;
+
+ result_code = ReadConfigDB(ck_vtn, UPLL_DT_STATE, UNC_OP_READ, dbop,
+ dmi, CTRLRTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error in reading: %d", result_code);
+ return result_code;
+ }
}
ConfigKeyVal *tkey = ck_vtn;
+ ConfigKeyVal *ck_vtn_main = NULL;
while (tkey != NULL) {
- bool oper_status_change = SetCtrlrOperStatus(tkey, notification, dmi) ;
- if (oper_status_change) {
- ConfigKeyVal *ck_vtn_main = NULL;
- result_code = GetChildConfigKey(ck_vtn_main,tkey);
+ bool oper_change = false;
+ result_code = SetCtrlrOperStatus(tkey, notification, dmi, oper_change);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("SetCtrlrOperStatus failed.Result code : %d", result_code);
+ return result_code;
+ }
+ if (oper_change) {
+ result_code = GetChildConfigKey(ck_vtn_main, tkey);
if (!ck_vtn_main || result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Invalid param");
+ DELETE_IF_NOT_NULL(ck_vtn_main);
return result_code;
}
DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
- result_code = ReadConfigDB(ck_vtn_main, UPLL_DT_STATE, UNC_OP_READ,
+ result_code = ReadConfigDB(ck_vtn_main, UPLL_DT_STATE, UNC_OP_READ,
dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- delete ck_vtn_main;
UPLL_LOG_DEBUG("Error in reading: %d", result_code);
+ DELETE_IF_NOT_NULL(ck_vtn_main);
return result_code;
}
- SetOperStatus(ck_vtn_main, notification, dmi) ;
+ SetOperStatus(ck_vtn_main, notification, dmi);
if (ck_vtn_main)
delete ck_vtn_main;
+ ck_vtn_main = NULL;
}
+ if ( skip ) break;
tkey = tkey->get_next_cfg_key_val();
}
- return UPLL_RC_SUCCESS;
+ return result_code;
}
UPLL_FUNC_TRACE;
bool res = false;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- key_vtn_t *vtn_key = reinterpret_cast<key_vtn_t *>
- (malloc(sizeof(key_vtn_t)));
- if (!vtn_key) {
- UPLL_LOG_DEBUG("Invalid param");
- return false;
- }
+ key_vtn_t *vtn_key = reinterpret_cast<key_vtn_t *>(
+ ConfigKeyVal::Malloc(sizeof(key_vtn_t)));
ConfigKeyVal *ck_vtn = new ConfigKeyVal(UNC_KT_VTN,
IpctSt::kIpcStKeyVtn, vtn_key, NULL);
- if (!ck_vtn) {
- free(vtn_key);
- UPLL_LOG_DEBUG("Invalid param");
- return false;
- }
result_code = UpdateOperStatus(ck_vtn, dmi, notification, false);
if (result_code != UPLL_RC_SUCCESS) {
/* Create Vnode If key */
switch (ktype) {
case UNC_KT_VTN:
- result_code = GetUninitOperState<val_vtn_st,val_db_vtn_st>
- (ck_vtn, dmi);
+ result_code = GetUninitOperState(ck_vtn, dmi);
break;
default:
- UPLL_LOG_DEBUG("Unsupported operation on keytype %d\n",ktype);
+ UPLL_LOG_DEBUG("Unsupported operation on keytype %d", ktype);
return UPLL_RC_ERR_GENERIC;
}
if (UPLL_RC_SUCCESS != result_code) {
return result_code;
}
- ConfigKeyVal *tkey = ck_vtn;
+ ConfigKeyVal *tkey = ck_vtn, *ck_ctrlr;
DbSubOp dbop1 = { kOpNotRead, kOpMatchNone, kOpInOutNone };
- while (tkey) {
- val_db_vtn_st * vtn_st = reinterpret_cast<val_db_vtn_st *>
+ while (ck_vtn) {
+ ck_ctrlr = NULL;
+ tkey = ck_vtn;
+ ck_vtn = tkey->get_next_cfg_key_val();
+ tkey->set_next_cfg_key_val(NULL);
+
+ val_db_vtn_st *vtn_st = reinterpret_cast<val_db_vtn_st *>
(GetStateVal(tkey));
- if (vtn_st->down_count == 0) {
- if (vtn_st->vtn_val_st.oper_status != UPLL_OPER_STATUS_UNKNOWN) {
- vtn_st->vtn_val_st.valid[UPLL_IDX_OPER_STATUS_VS] =
- UNC_VF_VALID;
+ // get count of vnodes down
+ uint32_t cur_instance_count = 0;
+ result_code = GetChildConfigKey(ck_ctrlr, tkey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ return result_code;
+ }
+ val_vtn_ctrlr *ctrlr_val = reinterpret_cast<val_vtn_ctrlr *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtn_ctrlr)));
+ ctrlr_val->valid[UPLL_IDX_OPER_STATUS_VS] = UNC_VF_VALID;
+ ctrlr_val->oper_status = UPLL_OPER_STATUS_DOWN;
+ ck_ctrlr->AppendCfgVal(IpctSt::kIpcInvalidStNum, ctrlr_val);
+ result_code = GetInstanceCount(ck_ctrlr, NULL, UPLL_DT_STATE,
+ &cur_instance_count, dmi, CTRLRTBL);
+ if (result_code == UPLL_RC_SUCCESS) {
+ if (cur_instance_count == 0) {
vtn_st->vtn_val_st.oper_status = UPLL_OPER_STATUS_UP;
- result_code = UpdateConfigDB(tkey, UPLL_DT_STATE,
- UNC_OP_UPDATE, dmi, &dbop1, MAINTBL);
+ } else
+ vtn_st->vtn_val_st.oper_status = UPLL_OPER_STATUS_DOWN;
+ } else if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ vtn_st->vtn_val_st.oper_status = UPLL_OPER_STATUS_DOWN;
+ } else {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ delete tkey;
+ delete ck_vtn;
+ delete ck_ctrlr;
+ return result_code;
+ }
+ vtn_st->vtn_val_st.valid[UPLL_IDX_OPER_STATUS_VS] = UNC_VF_VALID;
+ result_code = UpdateConfigDB(tkey, UPLL_DT_STATE,
+ UNC_OP_UPDATE, dmi, &dbop1, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigDB Executed %d", result_code);
+ delete tkey;
+ delete ck_vtn;
+ delete ck_ctrlr;
+ break;
+ }
+ delete tkey;
+ delete ck_ctrlr;
+ }
+ return result_code;
+}
+
+upll_rc_t VtnMoMgr::ControllerStatusHandler(uint8_t *ctrlr_id,
+ DalDmlIntf *dmi,
+ bool operstatus) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ state_notification notification = kCtrlrDisconnect;
+ if (operstatus) {
+ notification = kCtrlrReconnect;
+ }
+ if (notification == kCtrlrDisconnect) {
+ result_code = RestoreVtnCtrlrOperStatus(ctrlr_id, dmi, notification);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("vtn controller operstatus disconnect update failed");
+ return result_code;
+ }
+ result_code = UpdateVnodeOperStatus(ctrlr_id, dmi, notification, false);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Error in updating node operstatus");
+ return result_code;
+ }
+ VlinkMoMgr *vlink_mgr =
+ reinterpret_cast<VlinkMoMgr *>(const_cast<MoManager *>
+ (const_cast<MoManager*>(GetMoManager(UNC_KT_VLINK))));
+ vlink_mgr->UpdateVlinkOperStatus(ctrlr_id, dmi, notification, false);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("vlink operstatus update failed");
+ return result_code;
+ }
+ } else {
+ result_code = RestoreVnodeOperStatus(ctrlr_id, dmi, notification, false);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error in Updating Operstatus on Controller ReConnect");
+ return result_code;
+ }
+ }
+ return result_code;
+}
+
+upll_rc_t VtnMoMgr::UpdateVnodeOperStatus(uint8_t *ctrlr_id,
+ DalDmlIntf *dmi,
+ state_notification notification,
+ bool skip) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ unc_key_type_t node_key_type[]= {UNC_KT_VBRIDGE, UNC_KT_VROUTER,
+ UNC_KT_VTEP, UNC_KT_VTUNNEL};
+ ConfigKeyVal *ck_val = NULL;
+ for (int vnode_count = 0;
+ vnode_count < static_cast<int>
+ (sizeof(node_key_type)/sizeof(unc_key_type_t));
+ vnode_count++) {
+ const unc_key_type_t ktype = node_key_type[vnode_count];
+
+ VnodeMoMgr *mgr =
+ reinterpret_cast<VnodeMoMgr *>(const_cast<MoManager *>
+ (const_cast<MoManager*>(GetMoManager(ktype))));
+
+ result_code = mgr->GetChildConfigKey(ck_val, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Invalid param");
+ return result_code;
+ }
+
+ SET_USER_DATA_CTRLR(ck_val, ctrlr_id);
+ ConfigVal *cfg_val = NULL;
+ mgr->AllocVal(cfg_val, UPLL_DT_STATE, MAINTBL);
+ ck_val->SetCfgVal(cfg_val);
+ switch (ktype) {
+ case UNC_KT_VBRIDGE: {
+ ConfigVal *tmp =
+ (ck_val->get_cfg_val()) ? ck_val->get_cfg_val()->get_next_cfg_val() :
+ NULL;
+ val_db_vbr_st* vbr_dt_val = reinterpret_cast<val_db_vbr_st *>
+ ((tmp != NULL) ? tmp->get_val() : NULL);
+ if (vbr_dt_val == NULL) {
+ UPLL_LOG_DEBUG("Invalid param");
+ DELETE_IF_NOT_NULL(ck_val);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ vbr_dt_val->vbr_val_st.valid[0] = UNC_VF_VALID;
+ vbr_dt_val->vbr_val_st.oper_status = UPLL_OPER_STATUS_UNKNOWN;
+ }
+ break;
+ case UNC_KT_VROUTER: {
+ ConfigVal *tmp =
+ (ck_val->get_cfg_val()) ? ck_val->get_cfg_val()->get_next_cfg_val() :
+ NULL;
+ val_db_vrt_st* vrt_dt_val = reinterpret_cast<val_db_vrt_st *>
+ ((tmp != NULL) ? tmp->get_val() : NULL);
+ if (vrt_dt_val == NULL) {
+ UPLL_LOG_DEBUG("Invalid param");
+ DELETE_IF_NOT_NULL(ck_val);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ vrt_dt_val->vrt_val_st.valid[0] = UNC_VF_VALID;
+ vrt_dt_val->vrt_val_st.oper_status = UPLL_OPER_STATUS_UNKNOWN;
+ }
+ break;
+ case UNC_KT_VTEP: {
+ ConfigVal *tmp =
+ (ck_val->get_cfg_val()) ? ck_val->get_cfg_val()->get_next_cfg_val() :
+ NULL;
+ val_db_vtep_st* vtep_dt_val = reinterpret_cast<val_db_vtep_st *>
+ ((tmp != NULL) ? tmp->get_val() : NULL);
+ if (vtep_dt_val == NULL) {
+ UPLL_LOG_DEBUG("Invalid param");
+ DELETE_IF_NOT_NULL(ck_val);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ vtep_dt_val->vtep_val_st.valid[0] = UNC_VF_VALID;
+ vtep_dt_val->vtep_val_st.oper_status = UPLL_OPER_STATUS_UNKNOWN;
+ }
+ break;
+ case UNC_KT_VTUNNEL: {
+ ConfigVal *tmp =
+ (ck_val->get_cfg_val()) ? ck_val->get_cfg_val()->get_next_cfg_val() :
+ NULL;
+ val_db_vtunnel_st* vtunnel_dt_val =
+ reinterpret_cast<val_db_vtunnel_st *>
+ ((tmp != NULL) ? tmp->get_val() : NULL);
+ if (vtunnel_dt_val == NULL) {
+ UPLL_LOG_DEBUG("Invalid param");
+ DELETE_IF_NOT_NULL(ck_val);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ vtunnel_dt_val->vtunnel_val_st.valid[0] = UNC_VF_VALID;
+ vtunnel_dt_val->vtunnel_val_st.oper_status = UPLL_OPER_STATUS_UNKNOWN;
+ }
+ break;
+ default:
+ UPLL_LOG_DEBUG("OperStatus not supported for this data type");
+ DELETE_IF_NOT_NULL(ck_val);
+ return UPLL_RC_ERR_GENERIC;
+ break;
+ }
+
+ if (notification == kCtrlrDisconnect) {
+ DbSubOp dbop = { kOpNotRead, kOpMatchCtrlr, kOpInOutNone };
+ result_code = mgr->UpdateConfigDB(ck_val, UPLL_DT_STATE, UNC_OP_UPDATE,
+ dmi, &dbop, MAINTBL);
+ if (result_code == UPLL_RC_SUCCESS) {
+ result_code = UpdateVnodeIfOperStatus(ck_val, dmi, notification,
+ false, vnode_count);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Error in Updating operstatus");
+ DELETE_IF_NOT_NULL(ck_val);
+ return result_code;
+ }
+ } else if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Error in Updating operstatus");
+ DELETE_IF_NOT_NULL(ck_val);
+ return result_code;
+ }
+ }
+ DELETE_IF_NOT_NULL(ck_val);
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtnMoMgr::UpdateVnodeIfOperStatus(ConfigKeyVal *ck_vtn,
+ DalDmlIntf *dmi,
+ state_notification notification,
+ bool skip, int if_type) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ unc_key_type_t if_node_key_type[]= {UNC_KT_VBR_IF, UNC_KT_VRT_IF,
+ UNC_KT_VTEP_IF, UNC_KT_VTUNNEL_IF};
+ ConfigKeyVal *ck_val = NULL;
+ /* Populating vtnset with vtn names connected to given controller name */
+ const unc_key_type_t ktype = if_node_key_type[if_type];
+
+ VnodeChildMoMgr *mgr =
+ reinterpret_cast<VnodeChildMoMgr *>(const_cast<MoManager *>
+ (const_cast<MoManager*>(GetMoManager(ktype))));
+
+ result_code = mgr->GetChildConfigKey(ck_val, ck_vtn);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKEy failed");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigVal *cfg_val = NULL;
+ mgr->AllocVal(cfg_val, UPLL_DT_STATE, MAINTBL);
+ ck_val->SetCfgVal(cfg_val);
+
+ switch (ktype) {
+ case UNC_KT_VBR_IF: {
+ ConfigVal *tmp =
+ (ck_val->get_cfg_val()) ? ck_val->get_cfg_val()->get_next_cfg_val() :
+ NULL;
+ val_db_vbr_if_st* vbr_if_dt_val = reinterpret_cast<val_db_vbr_if_st *>
+ ((tmp != NULL) ? tmp->get_val() : NULL);
+ if (vbr_if_dt_val == NULL) {
+ UPLL_LOG_DEBUG("Invalid param");
+ DELETE_IF_NOT_NULL(ck_val);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ vbr_if_dt_val->vbr_if_val_st.valid[0] = UNC_VF_VALID;
+ vbr_if_dt_val->vbr_if_val_st.oper_status = UPLL_OPER_STATUS_UNKNOWN;
+ }
+ break;
+ case UNC_KT_VRT_IF: {
+ ConfigVal *tmp =
+ (ck_val->get_cfg_val()) ? ck_val->get_cfg_val()->get_next_cfg_val() :
+ NULL;
+ val_db_vrt_if_st* vrt_if_dt_val = reinterpret_cast<val_db_vrt_if_st *>
+ ((tmp != NULL) ? tmp->get_val() : NULL);
+ if (vrt_if_dt_val == NULL) {
+ UPLL_LOG_DEBUG("Invalid param");
+ DELETE_IF_NOT_NULL(ck_val);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ vrt_if_dt_val->vrt_if_val_st.valid[0] = UNC_VF_VALID;
+ vrt_if_dt_val->vrt_if_val_st.oper_status = UPLL_OPER_STATUS_UNKNOWN;
+ }
+ break;
+ case UNC_KT_VTEP_IF: {
+ ConfigVal *tmp =
+ (ck_val->get_cfg_val()) ? ck_val->get_cfg_val()->get_next_cfg_val() :
+ NULL;
+ val_db_vtep_if_st* vtep_if_dt_val = reinterpret_cast<val_db_vtep_if_st *>
+ ((tmp != NULL) ? tmp->get_val() : NULL);
+ if (vtep_if_dt_val == NULL) {
+ UPLL_LOG_DEBUG("Invalid param");
+ DELETE_IF_NOT_NULL(ck_val);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ vtep_if_dt_val->vtep_if_val_st.valid[0] = UNC_VF_VALID;
+ vtep_if_dt_val->vtep_if_val_st.oper_status = UPLL_OPER_STATUS_UNKNOWN;
+ }
+ break;
+ case UNC_KT_VTUNNEL_IF: {
+ ConfigVal *tmp =
+ (ck_val->get_cfg_val()) ? ck_val->get_cfg_val()->get_next_cfg_val() :
+ NULL;
+ val_db_vtunnel_if_st* vtunnel_if_dt_val =
+ reinterpret_cast<val_db_vtunnel_if_st *>
+ ((tmp != NULL) ? tmp->get_val() : NULL);
+ if (vtunnel_if_dt_val == NULL) {
+ UPLL_LOG_DEBUG("Invalid param");
+ DELETE_IF_NOT_NULL(ck_val);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ vtunnel_if_dt_val->vtunnel_if_val_st.valid[0] = UNC_VF_VALID;
+ vtunnel_if_dt_val->vtunnel_if_val_st.oper_status = UPLL_OPER_STATUS_UNKNOWN;
+ }
+ break;
+ default:
+ UPLL_LOG_DEBUG("OperStatus not supported for this data type");
+ DELETE_IF_NOT_NULL(ck_val);
+ return UPLL_RC_ERR_GENERIC;
+ break;
+ }
+ DbSubOp dbop = { kOpNotRead, kOpMatchCtrlr, kOpInOutNone };
+ result_code = mgr->UpdateConfigDB(ck_val, UPLL_DT_STATE, UNC_OP_UPDATE,
+ dmi, &dbop, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Error in Updating interface operstatus");
+ DELETE_IF_NOT_NULL(ck_val);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(ck_val);
+ return result_code;
+}
+
+upll_rc_t VtnMoMgr::RestoreVtnOperStatus(ConfigKeyVal *ck_val,
+ DalDmlIntf *dmi,
+ state_notification notification) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+
+ ConfigKeyVal *ck_vtn = NULL;
+ result_code = GetChildConfigKey(ck_vtn, ck_val);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKEy failed");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone,
+ kOpInOutNone};
+ result_code = ReadConfigDB(ck_vtn, UPLL_DT_STATE, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed with result_code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ck_vtn);
+ return result_code;
+ }
+ ConfigVal *tmp = (ck_vtn->get_cfg_val()) ?
+ ck_vtn->get_cfg_val()->get_next_cfg_val() : NULL;
+ val_db_vtn_st_t *vtn_valst = reinterpret_cast<val_db_vtn_st_t *>
+ ((tmp != NULL) ? tmp->get_val() : NULL);
+ if (vtn_valst == NULL) {
+ UPLL_LOG_DEBUG("Invalid param");
+ DELETE_IF_NOT_NULL(ck_vtn);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (notification == kCtrlrDisconnect) {
+ vtn_valst->vtn_val_st.oper_status = UPLL_OPER_STATUS_UNKNOWN;
+ } else {
+ if (vtn_valst->vtn_val_st.oper_status != UPLL_OPER_STATUS_UP) {
+ vtn_valst->vtn_val_st.oper_status = UPLL_OPER_STATUS_DOWN;
+ }
+ }
+ result_code = UpdateConfigDB(ck_vtn, UPLL_DT_STATE, UNC_OP_UPDATE,
+ dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error in Updating VTN entries");
+ DELETE_IF_NOT_NULL(ck_vtn);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(ck_vtn);
+ return result_code;
+}
+
+upll_rc_t VtnMoMgr::RestoreVtnCtrlrOperStatus(uint8_t *ctrlr_name,
+ DalDmlIntf *dmi,
+ state_notification notification) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ck_vtn = NULL;
+ result_code = GetChildConfigKey(ck_vtn, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ SET_USER_DATA_CTRLR(ck_vtn, ctrlr_name);
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchCtrlr,
+ kOpInOutNone};
+ result_code = ReadConfigDB(ck_vtn, UPLL_DT_STATE, UNC_OP_READ, dbop, dmi,
+ CTRLRTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed with result_code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ck_vtn);
+ return result_code;
+ }
+ ConfigKeyVal *tmp = ck_vtn;
+ while (ck_vtn != NULL) {
+ val_vtn_ctrlr *ctrlr_val = reinterpret_cast<val_vtn_ctrlr *>
+ (GetVal(ck_vtn));
+ if (!ctrlr_val) {
+ UPLL_LOG_DEBUG("val_vtn_ctrlr struct is NULL");
+ DELETE_IF_NOT_NULL(tmp);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (notification == kCtrlrDisconnect) {
+ ctrlr_val->oper_status = UPLL_OPER_STATUS_UNKNOWN;
+ ctrlr_val->down_count = 0;
+ } else {
+ if (ctrlr_val->oper_status != UPLL_OPER_STATUS_UP) {
+ ctrlr_val->oper_status = UPLL_OPER_STATUS_DOWN;
+ }
+ }
+ DbSubOp dbop = { kOpNotRead, kOpMatchCtrlr, kOpInOutNone };
+ result_code = UpdateConfigDB(ck_vtn, UPLL_DT_STATE, UNC_OP_UPDATE,
+ dmi, &dbop, CTRLRTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error in Updating VTN entries");
+ DELETE_IF_NOT_NULL(tmp);
+ return result_code;
+ }
+ RestoreVtnOperStatus(ck_vtn, dmi, notification);
+ ck_vtn = ck_vtn->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(tmp);
+ return result_code;
+}
+
+upll_rc_t VtnMoMgr::RestoreVnodeOperStatus(uint8_t *ctrlr_id,
+ DalDmlIntf *dmi,
+ state_notification notification,
+ bool skip) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ uint32_t down_count = 0;
+ result_code = RestoreVnodeIfAndVtnCtrlr(ctrlr_id, dmi, notification,
+ down_count);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error in Updating OperStatus");
+ return result_code;
+ }
+ ConfigKeyVal *ck_vtn_ctrlr = NULL;
+ result_code = GetChildConfigKey(ck_vtn_ctrlr, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed");
+ return result_code;
+ }
+ SET_USER_DATA_CTRLR(ck_vtn_ctrlr, ctrlr_id);
+ ConfigVal *cv_ctrlr = NULL;
+ AllocVal(cv_ctrlr, UPLL_DT_RUNNING, CTRLRTBL);
+ ck_vtn_ctrlr->SetCfgVal(cv_ctrlr);
+ val_vtn_ctrlr *tmp_ctrlr = reinterpret_cast<val_vtn_ctrlr*>
+ (GetVal(ck_vtn_ctrlr));
+ if (tmp_ctrlr == NULL) {
+ UPLL_LOG_DEBUG("Error in retrieving ctrlr val struct");
+ DELETE_IF_NOT_NULL(ck_vtn_ctrlr);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ tmp_ctrlr->down_count = down_count;
+ DbSubOp dbop = { kOpNotRead, kOpMatchCtrlr, kOpInOutNone };
+ result_code = UpdateConfigDB(ck_vtn_ctrlr, UPLL_DT_STATE, UNC_OP_UPDATE,
+ dmi, &dbop, CTRLRTBL);
+ DELETE_IF_NOT_NULL(ck_vtn_ctrlr);
+ return result_code;
+}
+
+upll_rc_t VtnMoMgr::RestoreVnodeIfAndVtnCtrlr(uint8_t *ctrlr_id,
+ DalDmlIntf *dmi,
+ state_notification notification,
+ uint32_t &down_count) {
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ unc_key_type_t node_key_type[]= {UNC_KT_VBRIDGE, UNC_KT_VROUTER};
+ for (int node_count = 0;
+ node_count < static_cast<int>
+ (sizeof(node_key_type)/sizeof(unc_key_type_t));
+ node_count++) {
+ const unc_key_type_t ktype = node_key_type[node_count];
+ ConfigKeyVal *ck_vnode = NULL;
+
+ VnodeMoMgr *mgr =
+ reinterpret_cast<VnodeMoMgr *>(const_cast<MoManager *>
+ (const_cast<MoManager*>(GetMoManager(ktype))));
+
+ result_code = mgr->GetChildConfigKey(ck_vnode, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ SET_USER_DATA_CTRLR(ck_vnode, ctrlr_id);
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchCtrlr,
+ kOpInOutNone};
+ result_code = mgr->ReadConfigDB(ck_vnode, UPLL_DT_STATE, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ DELETE_IF_NOT_NULL(ck_vnode);
+ continue;
+ } else if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed with result_code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ck_vnode);
+ return result_code;
+ }
+ unc_key_type_t node_key_type[]= {UNC_KT_VBR_IF, UNC_KT_VRT_IF};
+ while (ck_vnode != NULL) {
+ ConfigKeyVal *ckv_tmp = ck_vnode->get_next_cfg_key_val();
+ ck_vnode->set_next_cfg_key_val(NULL);
+ ConfigKeyVal *ck_if = NULL;
+ VnodeChildMoMgr *if_mgr =
+ reinterpret_cast<VnodeChildMoMgr *>(const_cast<MoManager *>
+ (const_cast<MoManager*>(GetMoManager(node_key_type[node_count]))));
+ result_code = if_mgr->GetChildConfigKey(ck_if, ck_vnode);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed");
+ DELETE_IF_NOT_NULL(ckv_tmp);
+ DELETE_IF_NOT_NULL(ck_vnode);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ VnodeMoMgr *node_mgr =
+ reinterpret_cast<VnodeMoMgr *>(const_cast<MoManager *>
+ (const_cast<MoManager*>(GetMoManager(ck_vnode->get_key_type()))));
+ result_code = if_mgr->UpdateVnodeIf(ck_if, dmi, notification);
+ DELETE_IF_NOT_NULL(ck_if);
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ result_code = node_mgr->UpdateOperStatus(ck_vnode, dmi, kCtrlrReconnectIfDown, true, true);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("UpdateConfigDB Executed %d", result_code);
- break;
+ UPLL_LOG_DEBUG("Error in Upodating OperStatus");
+ DELETE_IF_NOT_NULL(ckv_tmp);
+ DELETE_IF_NOT_NULL(ck_vnode);
+ return result_code;
}
+ DELETE_IF_NOT_NULL(ckv_tmp);
+ DELETE_IF_NOT_NULL(ck_vnode);
+ down_count = down_count + 1;
+ return UPLL_RC_SUCCESS;
+ } else if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed with result_code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ckv_tmp);
+ DELETE_IF_NOT_NULL(ck_vnode);
+ return result_code;
+ }
+ uint32_t cur_instance_count = 0;
+ ConfigKeyVal *ck_vnode_tmp = NULL;
+
+ result_code = node_mgr->GetCkvUninit(ck_vnode_tmp, ck_vnode, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Returning error %d\n",result_code);
+ DELETE_IF_NOT_NULL(ckv_tmp);
+ DELETE_IF_NOT_NULL(ck_vnode);
+ return result_code;
+ }
+ val_db_vbr_st *vnode_stval = reinterpret_cast<val_db_vbr_st *>
+ (GetStateVal(ck_vnode_tmp));
+ if (vnode_stval == NULL) {
+ UPLL_LOG_DEBUG("Error in fetching in state structure");
+ DELETE_IF_NOT_NULL(ck_vnode_tmp);
+ DELETE_IF_NOT_NULL(ckv_tmp);
+ DELETE_IF_NOT_NULL(ck_vnode);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ vnode_stval->vbr_val_st.oper_status = UPLL_OPER_STATUS_DOWN;
+ vnode_stval->vbr_val_st.valid[UPLL_IDX_OPER_STATUS_VBRS] = UNC_VF_VALID;
+
+ result_code = node_mgr->GetInstanceCount(ck_vnode_tmp, NULL, UPLL_DT_STATE,
+ &cur_instance_count, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetInstanceCount failed : %d\n",result_code);
+ DELETE_IF_NOT_NULL(ck_vnode_tmp);
+ DELETE_IF_NOT_NULL(ckv_tmp);
+ DELETE_IF_NOT_NULL(ck_vnode);
+ return result_code;
}
+ down_count += cur_instance_count;
+ DELETE_IF_NOT_NULL(ck_vnode_tmp);
+ DELETE_IF_NOT_NULL(ck_vnode);
+ ck_vnode = ckv_tmp;
}
- tkey= tkey->get_next_cfg_key_val();
}
- if (ck_vtn)
- delete ck_vtn;
return result_code;
}
**/
bool FilterAttributes(void *&val1, void *val2, bool audit_status,
unc_keytype_operation_t op);
+ bool IsAllInvalidAttributes(const val_vtnstation_controller_st *val);
+
/** Not used for VTN **/
bool CompareValidValue(void *&val1, void *val2, bool audit);
/*
upll_rc_t UpdateAuditConfigStatus(unc_keytype_configstatus_t cs_status,
uuc::UpdateCtrlrPhase phase,
ConfigKeyVal *&ckv_running);
+ upll_rc_t UpdateCtrlrConfigStatus(unc_keytype_configstatus_t cs_status,
+ uuc::UpdateCtrlrPhase phase,
+ ConfigKeyVal *&ckv_running);
upll_rc_t TxUpdateProcess(ConfigKeyVal *ck_main, IpcResponse *resp,
unc_keytype_operation_t op,
DalDmlIntf *dmi, controller_domain *ctrlr_dom);
**/
upll_rc_t DupConfigKeyVal(ConfigKeyVal *&okey, ConfigKeyVal *&req,
MoMgrTables tbl = MAINTBL);
- upll_rc_t GetRenamedControllerKey(ConfigKeyVal *ikey,
- upll_keytype_datatype_t dt_type,
- DalDmlIntf *dmi,
- controller_domain *ctrlr_dom);
- upll_rc_t GetRenamedUncKey(ConfigKeyVal *ctrlr_key,
- upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
- uint8_t *ctrlr_id);
upll_rc_t MappingvExtTovBr(ConfigKeyVal *ikey, IpcReqRespHeader *req,
- DalDmlIntf *dmi);
+ DalDmlIntf *dmi, uint32_t *&count);
upll_rc_t ReadSingleCtlrlStation(IpcReqRespHeader *header,
ConfigKeyVal *ikey,
DalDmlIntf *dmi,
- uint32_t &count);
+ uint32_t *count);
+ upll_rc_t ReadSingleCtlrlVtnMapping(IpcReqRespHeader *header,
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ uint32_t *count);
/**
* @brief Method used in Delete opertaion. Its semantic checks
* for the VTN key.
*
* @retval UPLL_RC_SUCCESS Validation succeeded.
* @retval UPLL_RC_ERR_GENERIC Validation failure.
- * @retval UPLL_RC_ERR_INVALID_OPTION1 Option1 is not valid.
- * @retval UPLL_RC_ERR_INVALID_OPTION2 Option2 is not valid.
+ * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute not supported.
*/
- upll_rc_t ValidateCapability(IpcReqRespHeader *req, ConfigKeyVal *ikey,
- const char *cntrl_id = NULL);
+ upll_rc_t ValidateCapability(IpcReqRespHeader *req, ConfigKeyVal *ikey,
+ const char *cntrl_id = NULL);
/**
* @Brief Checks if the specified key type and
* associated attributes are supported on the given controller,
* based on the valid flag.
*
- * @param[in] crtlr_name Controller name.
- * @param[in] ikey Corresponding key and value structure.
+ * @param[in] vtn_val KEY_VTN value structure.
+ * @param[in] attrs List of supported attribute from CAPA API.
* @param[in] operation Operation name.
*
* @retval UPLL_RC_SUCCESS validation succeeded.
* @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute not supported.
* @retval UPLL_RC_ERR_GENERIC Generic failure.
*/
- upll_rc_t ValVtnAttributeSupportCheck(const char *ctrlr_name,
- ConfigKeyVal *ikey,
+ upll_rc_t ValVtnAttributeSupportCheck(val_vtn_t *vtn_val,
+ const uint8_t *attrs,
uint32_t operation);
/**
ConfigKeyVal *ikey,
DalDmlIntf *dmi);
- bool SetCtrlrOperStatus(ConfigKeyVal *ikey,
+ upll_rc_t SetCtrlrOperStatus(ConfigKeyVal *ikey,
state_notification notification,
- DalDmlIntf *dmi) ;
+ DalDmlIntf *dmi, bool &oper_change) ;
- bool SetOperStatus(ConfigKeyVal *ikey,
+ upll_rc_t SetOperStatus(ConfigKeyVal *ikey,
state_notification notification,
DalDmlIntf *dmi) ;
+ upll_rc_t DupConfigKeyValVtnStation(ConfigKeyVal *&okey,
+ ConfigKeyVal *req);
+ upll_rc_t DupConfigKeyValVtnMapping(ConfigKeyVal *&okey,
+ ConfigKeyVal *req);
public:
VtnMoMgr();
virtual ~VtnMoMgr() {
DalDmlIntf *dmi,
ConfigKeyVal **err_ckv);
+ /* @brief Set Consolidated config status when controller
+ * table entry is deleted
+ *
+ * @param[in] ikey Vtn Main Table Key
+ * @param[in] ctrlr_id Controller Name which is deleted
+ * @param[in] dmi Database object
+ *
+ */
+ upll_rc_t SetVtnConsolidatedStatus(ConfigKeyVal *ikey, uint8_t *ctrlr_id,
+ DalDmlIntf *dmi);
/* @brief Read the configuration either from RDBMS and/or from the
* controller
*
* @retval UPLL_RC_ERR_NO_SUCH_INSTANCE Given key does not exist
*
**/
+ upll_rc_t ReadSiblingCount(IpcReqRespHeader *req, ConfigKeyVal *ikey,
+ DalDmlIntf *dmi);
+
upll_rc_t MergeValidate(unc_key_type_t keytype, const char *ctrlr_id,
ConfigKeyVal *conflict_ckv, DalDmlIntf *dmi);
/* Rename */
upll_rc_t SetConsolidatedStatus(ConfigKeyVal *ikey, DalDmlIntf *dmi);
- upll_rc_t ControlMo(IpcReqRespHeader *header, ConfigKeyVal *ikey,
- DalDmlIntf *dmi) {
- return UPLL_RC_SUCCESS;
- }
/* @brief To update oper status of vnode
*
* @param[in] ktype keytype
uint32_t session_id,
uint32_t config_id,
DalDmlIntf *dmi) ;
+ upll_rc_t ControllerStatusHandler(uint8_t *ctrlr_name,
+ DalDmlIntf *dmi,
+ bool operstatus);
+ upll_rc_t UpdateVnodeIfOperStatus(ConfigKeyVal *ck_vtn,
+ DalDmlIntf *dmi,
+ state_notification notification,
+ bool skip,
+ int if_type);
+ upll_rc_t UpdateVnodeOperStatus(uint8_t *ctrlr_name,
+ DalDmlIntf *dmi,
+ state_notification notification,
+ bool skip);
+ upll_rc_t RestoreVtnOperStatus(ConfigKeyVal *ck_vtn,
+ DalDmlIntf *dmi,
+ state_notification notification);
+ upll_rc_t RestoreVtnCtrlrOperStatus(uint8_t *ctrlr_name,
+ DalDmlIntf *dmi,
+ state_notification notification);
+ upll_rc_t GetRenamedControllerKey(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi,
+ controller_domain *ctrlr_dom);
+ upll_rc_t GetRenamedUncKey(ConfigKeyVal *ctrlr_key,
+ upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
+ uint8_t *ctrlr_id);
+ upll_rc_t RestoreVnodeOperStatus(uint8_t *ctrlr_id,
+ DalDmlIntf *dmi,
+ state_notification notification,
+ bool skip);
+ upll_rc_t RestoreVnodeIfAndVtnCtrlr(uint8_t *ctrlr_id,
+ DalDmlIntf *dmi,
+ state_notification notification,
+ uint32_t &down_count);
};
typedef struct val_db_vtn_st {
#include "unc/upll_errno.h"
#include "upll_validation.hh"
#include "unc/upll_ipc_enum.h"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
+#include "vbr_if_momgr.hh"
+
using unc::upll::ipc_util::IpcUtil;
namespace unc {
namespace upll {
namespace kt_momgr {
-#define VTN_KEY_COL 3
-#define POLICY_KEY_COL 4
#define VTN_RENAME 0x01
-#define POLICINGPROFILE_RENAME 0x04
+#define POLICINGPROFILE_RENAME 0x02
+#define NO_POLICINGPROFILE_RENAME 0xFD
// VtnPolicingmap Table (Main Table)
BindInfo VtnPolicingMapMoMgr::vtnpolicingmap_bind_info[] = {
{ uudst::vtn_policingmap::kDbiVtnName, CFG_INPUT_KEY,
offsetof(key_rename_vnode_info_t, new_unc_vtn_name),
uud::kDalChar, (kMaxLenVtnName + 1) },
- { uudst::vtn_policingmap::kDbiFlags, CFG_INPUT_KEY,
+ { uudst::vtn_policingmap::kDbiFlags, CK_VAL,
offsetof(key_user_data_t, flags),
uud::kDalUint8, 1 }
};
{ uudst::vtn_policingmap_ctrlr::kDbiVtnName, CFG_INPUT_KEY,
offsetof(key_rename_vnode_info_t, new_unc_vtn_name),
uud::kDalChar, (kMaxLenVtnName + 1) },
- { uudst::vtn_policingmap_ctrlr::kDbiFlags, CFG_INPUT_KEY,
- offsetof(key_user_data_t, flags),
- uud::kDalUint8, 1 }
-};
-
-// Rename Policer name MAINTBL
-BindInfo VtnPolicingMapMoMgr::key_vtnpm_Policyname_maintbl_rename_bind_info[]
-= {
- { uudst::vtn_policingmap::kDbiVtnName, CFG_MATCH_KEY,
- offsetof(key_vtn_t, vtn_name),
- uud::kDalChar, (kMaxLenVtnName + 1) },
- { uudst::vtn_policingmap::kDbiPolicername, CFG_MATCH_KEY,
- offsetof(key_rename_vnode_info_t, old_policingprofile_name),
- uud::kDalChar, (kMaxLenPolicingProfileName + 1) },
- { uudst::vtn_policingmap::kDbiPolicername, CFG_INPUT_KEY,
- offsetof(key_rename_vnode_info_t, new_policingprofile_name),
- uud::kDalChar, (kMaxLenPolicingProfileName + 1) },
- { uudst::vtn_policingmap::kDbiFlags, CFG_INPUT_KEY,
+ { uudst::vtn_policingmap_ctrlr::kDbiFlags, CK_VAL,
offsetof(key_user_data_t, flags),
uud::kDalUint8, 1 }
};
-// Rename Policer name CTRLRTBL
-BindInfo VtnPolicingMapMoMgr::key_vtnpm_Policyname_ctrlrtbl_rename_bind_info[]
-= {
- { uudst::vtn_policingmap_ctrlr::kDbiVtnName, CFG_MATCH_KEY,
- offsetof(key_vtn_t, vtn_name),
- uud::kDalChar, (kMaxLenVtnName + 1) },
- { uudst::vtn_policingmap_ctrlr::kDbiPolicername, CFG_MATCH_KEY,
- offsetof(key_rename_vnode_info_t, old_policingprofile_name),
- uud::kDalChar, (kMaxLenPolicingProfileName + 1) },
- { uudst::vtn_policingmap_ctrlr::kDbiPolicername, CFG_INPUT_KEY,
- offsetof(key_rename_vnode_info_t, new_policingprofile_name),
- uud::kDalChar, (kMaxLenPolicingProfileName + 1) },
- { uudst::vtn_policingmap_ctrlr::kDbiFlags, CFG_INPUT_KEY,
- offsetof(key_user_data_t, flags),
- uud::kDalUint8, 1 }
-};
// Constructor
VtnPolicingMapMoMgr::VtnPolicingMapMoMgr() : MoMgrImpl() {
nchild = 0;
child = NULL;
+ cur_instance_count = 0;
}
+upll_rc_t VtnPolicingMapMoMgr::RestorePOMInCtrlTbl(
+ ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl,
+ DalDmlIntf* dmi) {
+
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ if (!ikey || !(ikey->get_key())) {
+ UPLL_LOG_DEBUG("Input Key Not Valid");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (tbl != CTRLRTBL ||
+ (ikey->get_key_type() != UNC_KT_VTN_POLICINGMAP)) {
+ UPLL_LOG_DEBUG("Ignoring ktype/Table kt=%d, tbl=%d",
+ ikey->get_key_type(), tbl);
+ return result_code;
+ }
+
+ val_policingmap_t *val_pm = reinterpret_cast<val_policingmap_t *>
+ (GetVal(ikey));
+ if (NULL == val_pm) {
+ UPLL_LOG_DEBUG(" Value structure is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (UNC_VF_VALID == val_pm->valid[UPLL_IDX_POLICERNAME_PM]) {
+ result_code = UpdateRefCountInPPCtrlr(ikey, dt_type, dmi,
+ UNC_OP_CREATE);
+ if (UPLL_RC_SUCCESS != result_code) {
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Failed to update PolicingProfile in CtrlrTbl %d",
+ result_code);
+ return result_code;
+ }
+ }
+ }
+ return result_code;
+}
upll_rc_t VtnPolicingMapMoMgr::CreateCandidateMo(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
DalDmlIntf *dmi) {
}
#endif
-
// Check VTNPM object already exists in VtnPolicingMap tbl CANDIDATE DB
// if record exists, return the error code
result_code = IsReferenced(ikey, req->datatype, dmi);
return result_code;
}
}
+ }
+ // Check if Object exists in RUNNING DB and move it to CANDIDATE DB
+ if (req->datatype == UPLL_DT_CANDIDATE) {
+ result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
+ MAINTBL);
+ if ((result_code != UPLL_RC_ERR_INSTANCE_EXISTS) &&
+ (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG(" Is Exist check operation failed: err code(%d)",
+ result_code);
+ return result_code;
+ }
+ if (result_code == UPLL_RC_ERR_INSTANCE_EXISTS) {
+ result_code = RestoreChildren(ikey, req->datatype, UPLL_DT_RUNNING, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Restore Operation Failed, err %d", result_code);
+ return result_code;
+ }
+ return result_code;
+ }
+ }
// 1)Check the ref count capability of vtn associated controller name in
// policingprofilectrltbl If any of one refcount reached the
// max capability, then return error
// exist in policingprofilectrl tbl for the vtn associated controller name
// 2)Create the record in policingprofileentryctrltbl
+
+ if (UNC_VF_VALID == val_pm->valid[UPLL_IDX_POLICERNAME_PM]) {
result_code = UpdateRefCountInPPCtrlr(ikey, req->datatype, dmi,
UNC_OP_CREATE);
if (UPLL_RC_SUCCESS != result_code) {
MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG(" ReadConfigDB failed ");
+ DELETE_IF_NOT_NULL(tempckv);
return result_code;
}
val_policingmap_t *val_pm = reinterpret_cast<val_policingmap_t *>
} else if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("DeleteMo UpdateRefCountInPPCtrlr Error DB (%d)",
result_code);
+ DELETE_IF_NOT_NULL(tempckv);
return result_code;
}
}
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("DeleteMo record Err in vtnpolicingmaptbl (%d)",
result_code);
+ DELETE_IF_NOT_NULL(tempckv);
return result_code;
}
} else if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("DeleteMo record Err in vtnpolicingmapctrltbl (%d)",
result_code);
+ DELETE_IF_NOT_NULL(tempckv);
return result_code;
}
- CONFIGKEYVALCLEAN(tempckv);
+ DELETE_IF_NOT_NULL(tempckv);
return result_code;
}
return result_code;
}
+ result_code = SetRenameFlag(ikey, dmi, req);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG(" SetRenameFlag failed %d", result_code);
+ return result_code;
+ }
+
// Capability Check
#if 0
result_code = ValidateCapability(req, ikey);
result_code = ReadConfigDB(tmpckv, req->datatype, UNC_OP_READ, dbop, dmi,
MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(tmpckv);
UPLL_LOG_DEBUG("ReadConfigDB failed");
return result_code;
}
UNC_OP_DELETE);
if (UPLL_RC_SUCCESS != result_code) {
if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ DELETE_IF_NOT_NULL(tmpckv);
UPLL_LOG_DEBUG("UpdateMo UpdateRefCountInPPCtrlr error in delete (%d)",
result_code);
return result_code;
UNC_OP_CREATE);
if (UPLL_RC_SUCCESS != result_code) {
if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ DELETE_IF_NOT_NULL(tmpckv);
UPLL_LOG_DEBUG("UpdateMo UpdateRefCountInPPCtrlr error in create (%d)",
result_code);
return result_code;
UNC_OP_CREATE);
if (UPLL_RC_SUCCESS != result_code) {
if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ DELETE_IF_NOT_NULL(tmpckv);
UPLL_LOG_DEBUG("UpdateMo UpdateRefCountInPPCtrlr error in create (%d)",
result_code);
return result_code;
UNC_OP_DELETE);
if (UPLL_RC_SUCCESS != result_code) {
if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ DELETE_IF_NOT_NULL(tmpckv);
UPLL_LOG_DEBUG("UpdateMo UpdateRefCountInPPCtrlr error in delete (%d)",
result_code);
return result_code;
}
}
/* Update the record in CANDIDATE DB */
+ uint8_t temp_flag = 0;
+ GET_USER_DATA_FLAGS(ikey, temp_flag);
+ UPLL_LOG_DEBUG("Flag in ikey: %d", temp_flag);
+ DbSubOp dbop1 = {kOpNotRead, kOpMatchNone, kOpInOutFlag};
result_code = UpdateConfigDB(ikey, req->datatype, req->operation, dmi,
- MAINTBL);
+ &dbop1, MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
- CONFIGKEYVALCLEAN(tmp_key);
+ DELETE_IF_NOT_NULL(tmp_key);
UPLL_LOG_DEBUG("Create record Err in vtnpolicingmaptbl CANDIDATE DB(%d)",
result_code);
+ DELETE_IF_NOT_NULL(tmpckv);
return result_code;
}
dmi);
if (UPLL_RC_SUCCESS != result_code) {
if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
- CONFIGKEYVALCLEAN(tmp_key);
+ DELETE_IF_NOT_NULL(tmp_key);
+ DELETE_IF_NOT_NULL(tmpckv);
UPLL_LOG_DEBUG("Create record Err in vtnpolicingmaptbl CANDIDATE DB(%d)",
result_code);
return result_code;
}
}
- CONFIGKEYVALCLEAN(tmp_key);
+ DELETE_IF_NOT_NULL(tmp_key);
+ DELETE_IF_NOT_NULL(tmpckv);
return UPLL_RC_SUCCESS;
}
(const_cast<MoManager *>(GetMoManager
(UNC_KT_POLICING_PROFILE_ENTRY)));
result_code = ppe_mgr->ValidateValidElements(reinterpret_cast
- <const char *>(val_pm->policer_name), dmi, UPLL_DT_CANDIDATE);
+ <const char *>(val_pm->policer_name), dmi, dt_type);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("ValidateValidElements failed %d", result_code);
return result_code;
}
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_SUCCESS;
}
key_vtn_t *vtn_ikey = reinterpret_cast<key_vtn_t *>(ikey->get_key());
uuu::upll_strncpy(vtn_okey->vtn_name, vtn_ikey->vtn_name,
kMaxLenVtnName+1);
- result_code = vtnmgr->GetControllerDomainSpan(okey, UPLL_DT_CANDIDATE, dmi);
+ result_code = vtnmgr->GetControllerDomainSpan(okey, dt_type, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetControllerSpan no instance/error (%d)", result_code);
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
if (NULL == ctrlr_id) {
UPLL_LOG_DEBUG("UpdateRefCountInPPCtrlr ctrlr_id NULL");
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
reinterpret_cast<const char *>(val_vtn_policingmap->policer_name),
reinterpret_cast<const char *>(ctrlr_id), dmi, op, dt_type);
if (UPLL_RC_SUCCESS != result_code) {
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
// Create the record in policingprofileentryctrltbl
reinterpret_cast<const char *>(val_vtn_policingmap->policer_name),
reinterpret_cast<const char *>(ctrlr_id), dmi, op, dt_type);
if (UPLL_RC_SUCCESS != result_code) {
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
#endif
okey = okey->get_next_cfg_key_val();
}
- CONFIGKEYVALCLEAN(tmp_ckv);
+ DELETE_IF_NOT_NULL(tmp_ckv);
return UPLL_RC_SUCCESS;
}
unc_keytype_operation_t op, DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- ConfigKeyVal *ctrlckv = NULL, *okey = NULL;
+ ConfigKeyVal *ctrlckv = NULL, *temp_okey = NULL;
key_vtn_t *vtn_key = reinterpret_cast<key_vtn_t *>(ikey->get_key());
if (NULL == vtn_key) {
UPLL_LOG_DEBUG("key is NULL");
static_cast<VtnMoMgr *>((const_cast<MoManager *>
(GetMoManager(UNC_KT_VTN))));
// Get the memory allocated vtn key structure
- result_code = vtnmgr->GetChildConfigKey(okey, NULL);
+ result_code = vtnmgr->GetChildConfigKey(temp_okey, NULL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG(" GetChildConfigKey error (%d)",
result_code);
return result_code;
}
- if (!okey) return UPLL_RC_ERR_GENERIC;
- key_vtn_t *vtn_okey = reinterpret_cast<key_vtn_t *>(okey->get_key());
+ key_vtn_t *vtn_okey = reinterpret_cast<key_vtn_t *>(temp_okey->get_key());
if (NULL == vtn_okey) {
UPLL_LOG_DEBUG("key is NULL");
- delete okey;
+ DELETE_IF_NOT_NULL(temp_okey);
return UPLL_RC_ERR_GENERIC;
}
uuu::upll_strncpy(vtn_okey->vtn_name, vtn_key->vtn_name,
kMaxLenVtnName+1);
UPLL_LOG_DEBUG(" vtn_name %s", vtn_okey->vtn_name);
// Get the vtn associated controller name
- result_code = vtnmgr->GetControllerDomainSpan(okey, UPLL_DT_CANDIDATE, dmi);
+ result_code = vtnmgr->GetControllerDomainSpan(temp_okey, dt_type, dmi);
if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
UPLL_LOG_DEBUG(" No entry in vtn ctrlr tbl");
+ DELETE_IF_NOT_NULL(temp_okey);
return UPLL_RC_SUCCESS;
}
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetControllerSpan error (%d)",
result_code);
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(temp_okey);
return result_code;
}
-
+ ConfigKeyVal *okey = temp_okey;
while (NULL != okey) {
controller_domain ctrlr_dom;
ctrlr_dom.ctrlr = NULL;
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("CheckRefCountCapability GetPMCtrlKeyval error (%d)",
result_code);
- CONFIGKEYVALCLEAN(okey);
- CONFIGKEYVALCLEAN(ctrlckv);
+ DELETE_IF_NOT_NULL(temp_okey);
return result_code;
}
+ if ((op == UNC_OP_CREATE) || (op ==UNC_OP_UPDATE)) {
+ if (op == UNC_OP_CREATE) {
+ DbSubOp dbop = {kOpReadExist, kOpMatchCtrlr | kOpMatchDomain,
+ kOpInOutNone};
+ result_code = UpdateConfigDB(ctrlckv, dt_type, UNC_OP_READ, dmi,
+ &dbop, CTRLRTBL);
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(ctrlckv);
+ okey = okey->get_next_cfg_key_val();
+ continue;
+ }
+ UPLL_LOG_DEBUG("UpdateConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(temp_okey);
+ DELETE_IF_NOT_NULL(ctrlckv);
+ return result_code;
+ }
+ ConfigKeyVal *temp_key = NULL;
+
+ result_code = GetChildConfigKey(temp_key, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(temp_okey);
+ DELETE_IF_NOT_NULL(ctrlckv);
+ UPLL_LOG_DEBUG("GetChildConfigKey failed(%d)",result_code);
+ return result_code;
+ }
+
+ result_code = GetInstanceCount(temp_key, reinterpret_cast<char*>(ctrlr_dom.ctrlr),
+ dt_type,
+ &cur_instance_count,
+ dmi, CTRLRTBL);
+ UPLL_LOG_INFO("cur_instance_count = %d", cur_instance_count);
+ DELETE_IF_NOT_NULL(temp_key);
+
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(temp_okey);
+ DELETE_IF_NOT_NULL(ctrlckv);
+ UPLL_LOG_DEBUG("GetInstanceCount failed(%d)",result_code);
+ return result_code;
+ }
+ }
+ IpcReqRespHeader *temp_req = reinterpret_cast<IpcReqRespHeader *>
+ (ConfigKeyVal::Malloc(sizeof(IpcReqRespHeader)));
+
+ temp_req->datatype = dt_type;
+ temp_req->operation = op;
+
+ result_code = ValidateCapability(
+ temp_req, ikey, reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+
+ free(temp_req);
+
+ unc_keytype_ctrtype_t ctrlrtype = UNC_CT_UNKNOWN;
+ uuc::CtrlrMgr *ctrlr_mgr = uuc::CtrlrMgr::GetInstance();
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(ctrlckv);
+ // VTN PolicingMap is not supported for other than PFC Controller
+ // so skip adding entry for such sontroller in ctrlr table
+ if ((!ctrlr_mgr->GetCtrlrType(reinterpret_cast<char *>(ctrlr_dom.ctrlr),
+ dt_type, &ctrlrtype)) || (ctrlrtype != UNC_CT_PFC)) {
+ result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_DEBUG("Controller type is %d", ctrlrtype);
+ okey = okey->get_next_cfg_key_val();
+ continue;
+ }
+ DELETE_IF_NOT_NULL(okey);
+ UPLL_LOG_DEBUG("Key not supported by controller");
+ return result_code;
+ }
+ val_policingmap_t *val_policingmap =
+ reinterpret_cast<val_policingmap_t*>(GetVal(ikey));
+ val_vtnpolicingmap_ctrl *val_vtnpmap_ctrl = static_cast<
+ val_vtnpolicingmap_ctrl*>(GetVal(ctrlckv));
+ for ( unsigned int loop = 0;
+ loop < sizeof
+ (val_vtnpmap_ctrl->valid)/sizeof(val_vtnpmap_ctrl->valid[0]);
+ ++loop ) {
+ if (val_policingmap->valid[loop] == UNC_VF_NOT_SUPPORTED)
+ val_vtnpmap_ctrl->valid[loop] = UNC_VF_INVALID;
+ else
+ val_vtnpmap_ctrl->valid[loop] =
+ val_policingmap->valid[loop];
+ }
+ }
// Create/Update/Delete a record in CANDIDATE DB
result_code = UpdateConfigDB(ctrlckv, dt_type, op, dmi, CTRLRTBL);
if (UPLL_RC_SUCCESS != result_code) {
- CONFIGKEYVALCLEAN(okey);
- CONFIGKEYVALCLEAN(ctrlckv);
+ DELETE_IF_NOT_NULL(temp_okey);
+ DELETE_IF_NOT_NULL(ctrlckv);
UPLL_LOG_DEBUG("Create record Err in vtnpolicingmapctrlrtbl CAN DB(%d)",
result_code);
return result_code;
}
- CONFIGKEYVALCLEAN(ctrlckv);
+ DELETE_IF_NOT_NULL(ctrlckv);
okey = okey->get_next_cfg_key_val();
}
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(temp_okey);
return UPLL_RC_SUCCESS;
}
uint8_t* vtn_name,
controller_domain *ctrlr_dom,
unc_keytype_operation_t op,
- DalDmlIntf *dmi) {
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi,
+ uint8_t flag) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- /* TODO */
+ UPLL_LOG_DEBUG("UpdateControllerTableForVtn dt_type (%d)", dt_type);
ConfigKeyVal *ctrlckv = NULL, *ikey = NULL;
result_code = GetChildConfigKey(ikey, NULL);
if (result_code != UPLL_RC_SUCCESS) {
return result_code;
}
if (!ikey) return UPLL_RC_ERR_GENERIC;
+ unc_keytype_ctrtype_t ctrlrtype = UNC_CT_UNKNOWN;
+ uuc::CtrlrMgr *ctrlr_mgr = uuc::CtrlrMgr::GetInstance();
key_vtn_t *vtn_key = reinterpret_cast<key_vtn_t *>
(ikey->get_key());
uuu::upll_strncpy(vtn_key->vtn_name, vtn_name, kMaxLenVtnName+1);
- DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutNone};
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutCs | kOpInOutFlag};
// Read the Configuration from the MainTable
- result_code = ReadConfigDB(ikey, UPLL_DT_CANDIDATE,
+ result_code = ReadConfigDB(ikey, dt_type,
UNC_OP_READ, dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
UPLL_LOG_DEBUG("No Records in main table to be created in ctrlr tbl");
- CONFIGKEYVALCLEAN(ikey);
+ DELETE_IF_NOT_NULL(ikey);
return UPLL_RC_SUCCESS;
}
delete ikey;
return result_code;
}
+ if (flag != 0) {
+ uint8_t temp_flag = 0;
+ GET_USER_DATA_FLAGS(ikey, temp_flag);
+ flag = flag | temp_flag;
+ SET_USER_DATA_FLAGS(ikey, flag);
+ DbSubOp dbop1 = {kOpNotRead, kOpMatchNone, kOpInOutCs | kOpInOutFlag};
+ result_code = UpdateConfigDB(ikey, dt_type, UNC_OP_UPDATE,
+ dmi, &dbop1, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed %d", result_code);
+ return result_code;
+ }
+ }
if (ikey != NULL) {
result_code = GetPMCtrlKeyval(ctrlckv, ikey, ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetPMCtrlKeyval error (%d)", result_code);
- CONFIGKEYVALCLEAN(ikey);
+ DELETE_IF_NOT_NULL(ikey);
return UPLL_RC_ERR_GENERIC;
}
if (ctrlckv == NULL) {
UPLL_LOG_DEBUG("ctrlckv NULL");
- CONFIGKEYVALCLEAN(ikey);
+ DELETE_IF_NOT_NULL(ikey);
return UPLL_RC_ERR_GENERIC;
}
+
+ if (op == UNC_OP_CREATE) {
+ ConfigKeyVal *temp_key = NULL;
+
+ result_code = GetChildConfigKey(temp_key, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ikey);
+ DELETE_IF_NOT_NULL(ctrlckv);
+ UPLL_LOG_DEBUG("GetChildConfigKey failed(%d)",result_code);
+ return result_code;
+ }
+
+ result_code = GetInstanceCount(temp_key, reinterpret_cast<char*>(ctrlr_dom->ctrlr),
+ dt_type,
+ &cur_instance_count,
+ dmi, CTRLRTBL);
+ DELETE_IF_NOT_NULL(temp_key);
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(ikey);
+ DELETE_IF_NOT_NULL(ctrlckv);
+ UPLL_LOG_DEBUG("GetInstanceCount failed(%d)",result_code);
+ return result_code;
+ }
+
+ IpcReqRespHeader *temp_req = reinterpret_cast<IpcReqRespHeader *>
+ (ConfigKeyVal::Malloc(sizeof(IpcReqRespHeader)));
+ temp_req->datatype = UPLL_DT_CANDIDATE;
+ temp_req->operation = op;
+
+ result_code = ValidateCapability(temp_req, ikey, reinterpret_cast<char *>(ctrlr_dom->ctrlr));
+
+ free(temp_req);
+
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(ctrlckv);
+ DELETE_IF_NOT_NULL(ikey);
+ // VTN PolicingMap is not supported for other than PFC Controller
+ // so skip adding entry for such sontroller in ctrlr table
+ if ((!ctrlr_mgr->GetCtrlrType(reinterpret_cast<char *>(ctrlr_dom->ctrlr),
+ dt_type, &ctrlrtype)) || (ctrlrtype != UNC_CT_PFC)) {
+ result_code = UPLL_RC_SUCCESS;
+ UPLL_LOG_DEBUG("Controller type is %d", ctrlrtype);
+ return result_code;
+ }
+ UPLL_LOG_DEBUG("Key not supported by controller");
+ return result_code;
+ }
+
+ val_policingmap_t *val_policingmap = reinterpret_cast<val_policingmap_t*>(GetVal(ikey));
+
+ val_vtnpolicingmap_ctrl *val_vtnpmap_ctrl = reinterpret_cast<val_vtnpolicingmap_ctrl*>
+ (GetVal(ctrlckv));
+ for ( unsigned int loop = 0; loop < sizeof
+ (val_vtnpmap_ctrl->valid)/sizeof(val_vtnpmap_ctrl->valid[0]);
+ ++loop ) {
+ if (val_policingmap->valid[loop] == UNC_VF_NOT_SUPPORTED)
+ val_vtnpmap_ctrl->valid[loop] = UNC_VF_INVALID;
+ else
+ val_vtnpmap_ctrl->valid[loop] =
+ val_policingmap->valid[loop];
+ }
+ }
// Create the entry in VTNPMCtrl table
- result_code = UpdateConfigDB(ctrlckv, UPLL_DT_CANDIDATE, op,
+ if (UPLL_DT_AUDIT == dt_type && UNC_OP_CREATE == op) {
+ val_vtnpolicingmap_ctrl_t *valvtnctrlr = reinterpret_cast
+ <val_vtnpolicingmap_ctrl_t *>(GetVal(ctrlckv));
+ val_policingmap_t *valvtn = reinterpret_cast
+ <val_policingmap_t *>(GetVal(ikey));
+ valvtnctrlr->cs_attr[0] = valvtn->cs_attr[0];
+ valvtnctrlr->cs_row_status = valvtn->cs_row_status;
+ UPLL_LOG_DEBUG("Setting cs for ctrlr tbl in vtnpm cs %d row %d", valvtnctrlr->cs_attr[0], valvtnctrlr->cs_row_status );
+ UPLL_LOG_DEBUG("Setting cs for main tbl in vtnpm cs %d row %d", valvtn->cs_attr[0], valvtn->cs_row_status );
+ }
+ result_code = UpdateConfigDB(ctrlckv, dt_type, op,
dmi, CTRLRTBL);
if (UPLL_RC_SUCCESS != result_code) {
- CONFIGKEYVALCLEAN(ctrlckv);
- CONFIGKEYVALCLEAN(ikey);
+ DELETE_IF_NOT_NULL(ctrlckv);
+ DELETE_IF_NOT_NULL(ikey);
UPLL_LOG_DEBUG("Err while updating in ctrlr table for candidateDb(%d)",
result_code);
return result_code;
result_code = pp_mgr->PolicingProfileCtrlrTblOper(
reinterpret_cast<const char *>(val_vtn_policingmap->policer_name),
reinterpret_cast<const char *>(ctrlr_dom->ctrlr),
- dmi, op, UPLL_DT_CANDIDATE);
+ dmi, op, dt_type);
if (UPLL_RC_SUCCESS != result_code) {
- CONFIGKEYVALCLEAN(ctrlckv);
- CONFIGKEYVALCLEAN(ikey);
+ DELETE_IF_NOT_NULL(ctrlckv);
+ DELETE_IF_NOT_NULL(ikey);
return result_code;
}
- CONFIGKEYVALCLEAN(ikey);
- CONFIGKEYVALCLEAN(ctrlckv);
+ DELETE_IF_NOT_NULL(ikey);
+ DELETE_IF_NOT_NULL(ctrlckv);
}
UPLL_LOG_DEBUG("Successful completion of the controller table updation");
return result_code;
valvtnctrlr->valid[UPLL_IDX_POLICERNAME_PM] =
reinterpret_cast<val_policingmap_t*>(ikey->get_cfg_val()->get_val())
->valid[UPLL_IDX_POLICERNAME_PM];
- if (UNC_VF_VALID == valvtnctrlr->valid[UPLL_IDX_POLICERNAME_PM])
+ if (UNC_VF_VALID == valvtnctrlr->valid[UPLL_IDX_POLICERNAME_PM]) {
uuu::upll_strncpy(
reinterpret_cast<char *>(valvtnctrlr->policer_name),
reinterpret_cast<const char*>(reinterpret_cast<val_policingmap_t*>
(ikey->get_cfg_val()->get_val())->policer_name),
kMaxLenPolicingProfileName + 1);
+ }
} else {
UPLL_LOG_DEBUG("ikey with no val structure");
free(valvtnctrlr);
DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone };
result_code = ReadConfigDB(ckv, UPLL_DT_CANDIDATE, UNC_OP_READ, dbop,
dmi, MAINTBL);
- CONFIGKEYVALCLEAN(ckv);
+ DELETE_IF_NOT_NULL(ckv);
if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
return UPLL_RC_SUCCESS;
} else if (UPLL_RC_SUCCESS == result_code) {
}
return result_code;
}
+
upll_rc_t VtnPolicingMapMoMgr::ReadMo(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
DalDmlIntf *dmi) {
} else if ((req->datatype == UPLL_DT_STATE)&&
((req->option1 == UNC_OPT1_DETAIL) &&
(req->option2 == UNC_OPT2_NONE))) {
- IpcResponse ipc_response;
+ IpcResponse ipc_response;
memset(&ipc_response, 0, sizeof(IpcResponse));
result_code = SendIpcrequestToDriver(
ikey, req, &ipc_response, dmi);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("SendIpcrequestToDriver failed %d", result_code);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
return result_code;
}
ConfigKeyVal *temp_key = NULL;
result_code = CopyVtnControllerCkv(ikey, temp_key);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("CopyVtnControllerCkv failed %d", result_code);
+ delete temp_key;
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
return result_code;
}
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
delete temp_key;
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
return result_code;
}
result_code = ReadControllerStateDetail(ikey, temp_key,
&ipc_response, req->datatype,
req->operation, dmi);
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ DELETE_IF_NOT_NULL(temp_key);
if (result_code != UPLL_RC_SUCCESS) {
- CONFIGKEYVALCLEAN(ikey);
return result_code;
}
} else {
result_code = CopyVtnControllerCkv(ikey, temp_vtn_pm_ckv);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("CopyVtnControllerCkv failed");
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
return result_code;
}
DbSubOp dbop = {kOpReadMultiple, kOpMatchNone,
UNC_OP_READ, dbop,req->rep_count,dmi, CTRLRTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(temp_vtn_pm_ckv);
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
return result_code;
}
vtn_pm_ckv = temp_vtn_pm_ckv;
ConfigKeyVal *okey = NULL;
-
+ ConfigKeyVal *dup_ckv = NULL;
+ uint32_t tmp_sib_count = 0;
+
if (req->operation == UNC_OP_READ_SIBLING) {
- while (NULL != vtn_pm_ckv) {
- controller_domain temp_cd;
- GET_USER_DATA_CTRLR_DOMAIN(vtn_pm_ckv, temp_cd);
- ctrl_len = dom_len = 0;
- ctrl_len = strcmp((const char*)(ctrlr_dom.ctrlr),
- (const char*)(temp_cd.ctrlr));
- dom_len = strcmp((const char*)(ctrlr_dom.domain),
- (const char*)(temp_cd.domain));
-
- ConfigKeyVal *dup_ckv = NULL;
- if ((ctrl_len < 0) || ((ctrl_len == 0) && (dom_len < 0))) {
- result_code = GetChildControllerConfigKey(dup_ckv, vtn_pm_ckv,
- &temp_cd);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("GetChildControllerConfigKey failed");
- return result_code;
- }
- val_policingmap_controller_t *out_val_pm_ctrlr =
- reinterpret_cast<val_policingmap_controller_t *>
- (ConfigKeyVal::Malloc(sizeof(val_policingmap_controller_t)));
- memcpy(out_val_pm_ctrlr, val_pm_ctrlr,
- sizeof(val_policingmap_controller_t));
- dup_ckv->AppendCfgVal(IpctSt::kIpcStValPolicingmapController,
- out_val_pm_ctrlr);
- UPLL_LOG_TRACE(" pppppp %s", (dup_ckv->ToStrAll()).c_str());
- result_code = ReadControllerStateNormal(dup_ckv, req->datatype,
- req->operation, dmi);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("ReadDTStateNormal failed");
- return result_code;
+ while (NULL != vtn_pm_ckv) {
+ controller_domain temp_cd;
+ GET_USER_DATA_CTRLR_DOMAIN(vtn_pm_ckv, temp_cd);
+ ctrl_len = dom_len = 0;
+ ctrl_len = strcmp((const char*)(ctrlr_dom.ctrlr),
+ (const char*)(temp_cd.ctrlr));
+ dom_len = strcmp((const char*)(ctrlr_dom.domain),
+ (const char*)(temp_cd.domain));
+
+ if ((ctrl_len < 0) || ((ctrl_len == 0) && (dom_len < 0))) {
+ result_code = GetChildControllerConfigKey(dup_ckv, vtn_pm_ckv,
+ &temp_cd);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildControllerConfigKey failed");
+ DELETE_IF_NOT_NULL(temp_vtn_pm_ckv);
+ DELETE_IF_NOT_NULL(okey);
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
+ return result_code;
+ }
+ val_policingmap_controller_t *out_val_pm_ctrlr =
+ reinterpret_cast<val_policingmap_controller_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_policingmap_controller_t)));
+ memcpy(out_val_pm_ctrlr, val_pm_ctrlr,
+ sizeof(val_policingmap_controller_t));
+ dup_ckv->AppendCfgVal(IpctSt::kIpcStValPolicingmapController,
+ out_val_pm_ctrlr);
+ result_code = ReadControllerStateNormal(dup_ckv, req->datatype,
+ req->operation, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadDTStateNormal failed");
+ DELETE_IF_NOT_NULL(dup_ckv);
+ DELETE_IF_NOT_NULL(temp_vtn_pm_ckv);
+ DELETE_IF_NOT_NULL(okey);
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
+ return result_code;
+ }
+ if (NULL == okey) {
+ okey = dup_ckv;
+ } else {
+ okey->AppendCfgKeyVal(dup_ckv);
+ }
+ tmp_sib_count++;
+ if (tmp_sib_count == req->rep_count)
+ break;
+ } else {
+ result_code = UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ }
+ vtn_pm_ckv = vtn_pm_ckv->get_next_cfg_key_val();
}
- }
- vtn_pm_ckv = vtn_pm_ckv->get_next_cfg_key_val();
- if (NULL == okey) {
- okey = dup_ckv;
+ if ((okey != NULL) && (result_code == UPLL_RC_SUCCESS)) {
+ ikey->ResetWith(okey);
+ req->rep_count = tmp_sib_count;
+ DELETE_IF_NOT_NULL(okey);
} else {
- okey->AppendCfgKeyVal(dup_ckv);
+ UPLL_LOG_DEBUG("ReadSiblingControllerStateNormal failed %d",
+ result_code);
+ DELETE_IF_NOT_NULL(okey);
}
- }
- if ((okey != NULL) && (result_code == UPLL_RC_SUCCESS)) {
- ikey->ResetWith(okey);
- }
- } else if (req->operation == UNC_OP_READ_SIBLING_BEGIN) {
+ } else if (req->operation == UNC_OP_READ_SIBLING_BEGIN) {
while (NULL != vtn_pm_ckv) {
- controller_domain temp_cd;
- GET_USER_DATA_CTRLR_DOMAIN(vtn_pm_ckv, temp_cd);
- ConfigKeyVal *dup_ckv = NULL;
- result_code = GetChildControllerConfigKey(dup_ckv, vtn_pm_ckv,
- &temp_cd);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("GetChildControllerConfigKey failed");
- return result_code;
+ controller_domain temp_cd;
+ GET_USER_DATA_CTRLR_DOMAIN(vtn_pm_ckv, temp_cd);
+ result_code = GetChildControllerConfigKey(dup_ckv, vtn_pm_ckv,
+ &temp_cd);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildControllerConfigKey failed");
+ DELETE_IF_NOT_NULL(temp_vtn_pm_ckv);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(dup_ckv);
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
+ return result_code;
+ }
+ val_policingmap_controller_t *out_val_pm_ctrlr =
+ reinterpret_cast<val_policingmap_controller_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_policingmap_controller_t)));
+ memcpy(out_val_pm_ctrlr, val_pm_ctrlr,
+ sizeof(val_policingmap_controller_t));
+ dup_ckv->AppendCfgVal(IpctSt::kIpcStValPolicingmapController,
+ out_val_pm_ctrlr);
+ result_code = ReadControllerStateNormal(dup_ckv, req->datatype,
+ req->operation, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadDTStateNormal failed");
+ DELETE_IF_NOT_NULL(dup_ckv);
+ DELETE_IF_NOT_NULL(temp_vtn_pm_ckv);
+ DELETE_IF_NOT_NULL(okey);
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
+ return result_code;
+ }
+ if (NULL == okey) {
+ okey = dup_ckv;
+ } else {
+ okey->AppendCfgKeyVal(dup_ckv);
+ }
+ tmp_sib_count++;
+ if (tmp_sib_count == req->rep_count)
+ break;
+ vtn_pm_ckv = vtn_pm_ckv->get_next_cfg_key_val();
}
- val_policingmap_controller_t *out_val_pm_ctrlr =
- reinterpret_cast<val_policingmap_controller_t *>
- (ConfigKeyVal::Malloc(sizeof(val_policingmap_controller_t)));
- memcpy(out_val_pm_ctrlr, val_pm_ctrlr,
- sizeof(val_policingmap_controller_t));
- dup_ckv->AppendCfgVal(IpctSt::kIpcStValPolicingmapController,
- out_val_pm_ctrlr);
- result_code = ReadControllerStateNormal(dup_ckv, req->datatype,
- req->operation, dmi);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("ReadDTStateNormal failed");
- return result_code;
- }
- vtn_pm_ckv = vtn_pm_ckv->get_next_cfg_key_val();
- if (NULL == okey) {
- okey = dup_ckv;
- } else {
- okey->AppendCfgKeyVal(dup_ckv);
+ if ((okey != NULL) && (result_code == UPLL_RC_SUCCESS)) {
+ ikey->ResetWith(okey);
+ req->rep_count = tmp_sib_count;
+ DELETE_IF_NOT_NULL(okey);
}
- }
- if ((okey != NULL) && (result_code == UPLL_RC_SUCCESS)) {
- ikey->ResetWith(okey);
- }
- } else {
+ } else {
result_code = UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
- }
+ }
+ DELETE_IF_NOT_NULL(temp_vtn_pm_ckv);
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
return result_code;
}
+
upll_rc_t VtnPolicingMapMoMgr::ReadSiblingControllerStateDetail(
ConfigKeyVal *ikey,
IpcReqRespHeader *req,
}
vtn_pm_ckv = temp_vtn_pm_ckv;
ConfigKeyVal *okey = NULL;
-
+ ConfigKeyVal *dup_ckv = NULL;
+ uint32_t tmp_sib_count = 0;
if (req->operation == UNC_OP_READ_SIBLING) {
- while (NULL != vtn_pm_ckv) {
- UPLL_LOG_DEBUG("KT of vtn_pm_ckv in while %d",
- vtn_pm_ckv->get_key_type());
- controller_domain temp_cd;
- GET_USER_DATA_CTRLR_DOMAIN(vtn_pm_ckv, temp_cd);
- ctrl_len = dom_len = 0;
- ctrl_len = strcmp((const char*)(ctrlr_dom.ctrlr),
- (const char*)(temp_cd.ctrlr));
- dom_len = strcmp((const char*)(ctrlr_dom.domain),
- (const char*)(temp_cd.domain));
- ConfigKeyVal *dup_ckv = NULL;
-
- if ((ctrl_len < 0) || ((ctrl_len == 0) && (dom_len < 0))) {
- result_code = GetChildControllerConfigKey(dup_ckv, vtn_pm_ckv,
- &temp_cd);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("GetChildControllerConfigKey failed");
- return result_code;
- }
- val_policingmap_controller_t *out_val_pm_ctrlr =
- reinterpret_cast<val_policingmap_controller_t *>
- (ConfigKeyVal::Malloc(sizeof(val_policingmap_controller_t)));
- memcpy(out_val_pm_ctrlr, val_pm_ctrlr,
- sizeof(val_policingmap_controller_t));
- dup_ckv->AppendCfgVal(IpctSt::kIpcStValPolicingmapController,
- out_val_pm_ctrlr);
- string s1(dup_ckv->ToStrAll());
- UPLL_LOG_INFO("%s DUP_CKV PRINT", s1.c_str());
- IpcResponse ipc_response;
- memset(&ipc_response, 0, sizeof(IpcResponse));
- result_code = SendIpcrequestToDriver(
- dup_ckv, req, &ipc_response, dmi);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("SendIpcrequestToDriver failed %d", result_code);
- return result_code;
- }
- ConfigKeyVal *temp_key = NULL;
- result_code = CopyVtnControllerCkv(dup_ckv, temp_key);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("CopyVtnControllerCkv failed %d", result_code);
- return result_code;
- }
- result_code = ReadConfigDB(temp_key, req->datatype, UNC_OP_READ,
- dbop, dmi, MAINTBL);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
- return result_code;
- }
- result_code = ReadControllerStateDetail(dup_ckv, temp_key, &ipc_response,
- req->datatype, req->operation, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- CONFIGKEYVALCLEAN(ikey);
- return result_code;
- }
- if (NULL == okey) {
- okey = dup_ckv;
- } else {
- okey->AppendCfgKeyVal(dup_ckv);
- }
- } else {
+ while (NULL != vtn_pm_ckv) {
+ UPLL_LOG_DEBUG("KT of vtn_pm_ckv in while %d",
+ vtn_pm_ckv->get_key_type());
+ controller_domain temp_cd;
+ GET_USER_DATA_CTRLR_DOMAIN(vtn_pm_ckv, temp_cd);
+ ctrl_len = dom_len = 0;
+ ctrl_len = strcmp((const char*)(ctrlr_dom.ctrlr),
+ (const char*)(temp_cd.ctrlr));
+ dom_len = strcmp((const char*)(ctrlr_dom.domain),
+ (const char*)(temp_cd.domain));
+
+ if ((ctrl_len < 0) || ((ctrl_len == 0) && (dom_len < 0))) {
+ result_code = GetChildControllerConfigKey(dup_ckv, vtn_pm_ckv,
+ &temp_cd);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildControllerConfigKey failed");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ val_policingmap_controller_t *out_val_pm_ctrlr =
+ reinterpret_cast<val_policingmap_controller_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_policingmap_controller_t)));
+ memcpy(out_val_pm_ctrlr, val_pm_ctrlr,
+ sizeof(val_policingmap_controller_t));
+ dup_ckv->AppendCfgVal(IpctSt::kIpcStValPolicingmapController,
+ out_val_pm_ctrlr);
+ UPLL_LOG_TRACE("%s DUP_CKV ", dup_ckv->ToStrAll().c_str());
+ IpcResponse ipc_response;
+ memset(&ipc_response, 0, sizeof(IpcResponse));
+ result_code = SendIpcrequestToDriver(
+ dup_ckv, req, &ipc_response, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("SendIpcrequestToDriver failed %d", result_code);
+ DELETE_IF_NOT_NULL(dup_ckv);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ ConfigKeyVal *temp_key = NULL;
+ result_code = CopyVtnControllerCkv(dup_ckv, temp_key);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("CopyVtnControllerCkv failed %d", result_code);
+ DELETE_IF_NOT_NULL(dup_ckv);
+ DELETE_IF_NOT_NULL(temp_vtn_pm_ckv);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ result_code = ReadConfigDB(temp_key, req->datatype, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(dup_ckv);
+ DELETE_IF_NOT_NULL(temp_vtn_pm_ckv);
+ DELETE_IF_NOT_NULL(temp_key);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ result_code = ReadControllerStateDetail(dup_ckv, temp_key,
+ &ipc_response, req->datatype,
+ req->operation, dmi);
+
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(dup_ckv);
+ DELETE_IF_NOT_NULL(temp_key);
+ DELETE_IF_NOT_NULL(temp_vtn_pm_ckv);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(temp_key);
+ if (NULL == okey) {
+ okey = dup_ckv;
+ } else {
+ okey->AppendCfgKeyVal(dup_ckv);
+ }
+ tmp_sib_count++;
+ if (tmp_sib_count == req->rep_count)
+ break;
+ } else {
result_code = UPLL_RC_ERR_NO_SUCH_INSTANCE;
- }
- vtn_pm_ckv = vtn_pm_ckv->get_next_cfg_key_val();
- }
- if ((okey != NULL) && (result_code == UPLL_RC_SUCCESS)) {
- ikey->ResetWith(okey);
- }
- } else if (req->operation == UNC_OP_READ_SIBLING_BEGIN) {
- while (NULL != vtn_pm_ckv) {
- UPLL_LOG_DEBUG("KT of vtn_pm_ckv in while %d",
- vtn_pm_ckv->get_key_type());
- controller_domain temp_cd;
- ConfigKeyVal *dup_ckv = NULL;
- GET_USER_DATA_CTRLR_DOMAIN(vtn_pm_ckv, temp_cd);
- result_code = GetChildControllerConfigKey(dup_ckv, vtn_pm_ckv,
- &temp_cd);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("GetChildControllerConfigKey failed");
- return result_code;
- }
- val_policingmap_controller_t *out_val_pm_ctrlr =
- reinterpret_cast<val_policingmap_controller_t *>
- (ConfigKeyVal::Malloc(sizeof(val_policingmap_controller_t)));
- memcpy(out_val_pm_ctrlr, val_pm_ctrlr,
- sizeof(val_policingmap_controller_t));
- dup_ckv->AppendCfgVal(IpctSt::kIpcStValPolicingmapController,
- out_val_pm_ctrlr);
- string s1(dup_ckv->ToStrAll());
- UPLL_LOG_INFO("%s DUP_CKV PRINT", s1.c_str());
- IpcResponse ipc_response;
- memset(&ipc_response, 0, sizeof(IpcResponse));
- result_code = SendIpcrequestToDriver(
- dup_ckv, req, &ipc_response, dmi);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("SendIpcrequestToDriver failed %d", result_code);
- return result_code;
- }
- ConfigKeyVal *temp_key = NULL;
- result_code = CopyVtnControllerCkv(dup_ckv, temp_key);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("CopyVtnControllerCkv failed %d", result_code);
- return result_code;
+ }
+ vtn_pm_ckv = vtn_pm_ckv->get_next_cfg_key_val();
}
- result_code = ReadConfigDB(temp_key, req->datatype, UNC_OP_READ,
- dbop, dmi, MAINTBL);
- if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
- return result_code;
+ if ((okey != NULL) && (result_code == UPLL_RC_SUCCESS)) {
+ ikey->ResetWith(okey);
+ DELETE_IF_NOT_NULL(okey);
+ req->rep_count = tmp_sib_count;
+ } else {
+ DELETE_IF_NOT_NULL(okey);
}
- result_code = ReadControllerStateDetail(dup_ckv, temp_key, &ipc_response,
- req->datatype, req->operation, dmi);
- if (result_code != UPLL_RC_SUCCESS) {
- CONFIGKEYVALCLEAN(ikey);
- return result_code;
+ } else if (req->operation == UNC_OP_READ_SIBLING_BEGIN) {
+ while (NULL != vtn_pm_ckv) {
+ UPLL_LOG_DEBUG("KT of vtn_pm_ckv in while %d",
+ vtn_pm_ckv->get_key_type());
+ controller_domain temp_cd;
+ GET_USER_DATA_CTRLR_DOMAIN(vtn_pm_ckv, temp_cd);
+ result_code = GetChildControllerConfigKey(dup_ckv, vtn_pm_ckv,
+ &temp_cd);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildControllerConfigKey failed");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ val_policingmap_controller_t *out_val_pm_ctrlr =
+ reinterpret_cast<val_policingmap_controller_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_policingmap_controller_t)));
+ memcpy(out_val_pm_ctrlr, val_pm_ctrlr,
+ sizeof(val_policingmap_controller_t));
+ dup_ckv->AppendCfgVal(IpctSt::kIpcStValPolicingmapController,
+ out_val_pm_ctrlr);
+ UPLL_LOG_TRACE("%s DUP_CKV ", dup_ckv->ToStrAll().c_str());
+ IpcResponse ipc_response;
+ memset(&ipc_response, 0, sizeof(IpcResponse));
+ result_code = SendIpcrequestToDriver(
+ dup_ckv, req, &ipc_response, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("SendIpcrequestToDriver failed %d", result_code);
+ DELETE_IF_NOT_NULL(dup_ckv);
+ DELETE_IF_NOT_NULL(temp_vtn_pm_ckv);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ ConfigKeyVal *temp_key = NULL;
+ result_code = CopyVtnControllerCkv(dup_ckv, temp_key);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("CopyVtnControllerCkv failed %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ result_code = ReadConfigDB(temp_key, req->datatype, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(dup_ckv);
+ DELETE_IF_NOT_NULL(temp_key);
+ DELETE_IF_NOT_NULL(temp_vtn_pm_ckv);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ result_code = ReadControllerStateDetail(dup_ckv, temp_key, &ipc_response,
+ req->datatype, req->operation, dmi);
+
+ DELETE_IF_NOT_NULL(ipc_response.ckv_data);
+ if (result_code != UPLL_RC_SUCCESS) {
+ DELETE_IF_NOT_NULL(temp_key);
+ DELETE_IF_NOT_NULL(dup_ckv);
+ DELETE_IF_NOT_NULL(temp_vtn_pm_ckv);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(temp_key);
+ if (NULL == okey) {
+ okey = dup_ckv;
+ } else {
+ okey->AppendCfgKeyVal(dup_ckv);
+ }
+
+ tmp_sib_count++;
+ if (tmp_sib_count == req->rep_count)
+ break;
+ vtn_pm_ckv = vtn_pm_ckv->get_next_cfg_key_val();
}
- if (NULL == okey) {
- okey = dup_ckv;
- } else {
- okey->AppendCfgKeyVal(dup_ckv);
+ if ((okey != NULL) && (result_code == UPLL_RC_SUCCESS)) {
+ ikey->ResetWith(okey);
+ DELETE_IF_NOT_NULL(okey);
+ req->rep_count = tmp_sib_count;
}
- vtn_pm_ckv = vtn_pm_ckv->get_next_cfg_key_val();
}
- if ((okey != NULL) && (result_code == UPLL_RC_SUCCESS)) {
- ikey->ResetWith(okey);
- }
-}
-else {
+ else {
result_code = UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
+ DELETE_IF_NOT_NULL(temp_vtn_pm_ckv);
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
return result_code;
}
MoMgrTables tbl) {
UPLL_FUNC_TRACE;
UPLL_LOG_DEBUG("GetRenameKeyBindInfo (%d) (%d)", key_type, tbl);
- switch (key_type) {
- case UNC_KT_VTN_POLICINGMAP:
- case UNC_KT_VTN_POLICINGMAP_CONTROLLER:
- nattr = VTN_KEY_COL;
- if (MAINTBL == tbl) {
- binfo = key_vtnpm_vtn_maintbl_rename_bind_info;
- } else if (CTRLRTBL == tbl) {
- binfo = key_vtnpm_vtn_ctrlrtbl_rename_bind_info;
- } else {
- UPLL_LOG_DEBUG("GetRenameKeyBindInfo Invalid Tbl (%d)", key_type);
- return PFC_FALSE;
- }
- break;
- case UNC_KT_POLICING_PROFILE:
- nattr = POLICY_KEY_COL;
- if (MAINTBL == tbl) {
- binfo = key_vtnpm_Policyname_maintbl_rename_bind_info;
- } else if (CTRLRTBL == tbl) {
- binfo = key_vtnpm_Policyname_ctrlrtbl_rename_bind_info;
- } else {
- UPLL_LOG_DEBUG("GetRenameKeyBindInfo Invalid Tbl (%d)", key_type);
- return PFC_FALSE;
- }
- break;
- default:
- UPLL_LOG_DEBUG("GetRenameKeyBindInfo Invalid key type (%d) (%d)",
- key_type, tbl);
+ if (MAINTBL == tbl) {
+ nattr = sizeof(key_vtnpm_vtn_maintbl_rename_bind_info)/
+ sizeof(key_vtnpm_vtn_maintbl_rename_bind_info[0]);
+ binfo = key_vtnpm_vtn_maintbl_rename_bind_info;
+ } else if (CTRLRTBL == tbl) {
+ nattr = sizeof(key_vtnpm_vtn_ctrlrtbl_rename_bind_info)/
+ sizeof(key_vtnpm_vtn_ctrlrtbl_rename_bind_info[0]);
+ binfo = key_vtnpm_vtn_ctrlrtbl_rename_bind_info;
+ } else {
+ UPLL_LOG_DEBUG("GetRenameKeyBindInfo Invalid Tbl (%d)", tbl);
return PFC_FALSE;
}
return PFC_TRUE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- if (UNC_KT_VTN_POLICINGMAP == ikey->get_key_type()) {
- key_rename_vnode_info_t *key_rename =
- reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
- key_vtn_t *key_vtn = reinterpret_cast<key_vtn_t *>
- (ConfigKeyVal::Malloc(sizeof(key_vtn_t)));
+ key_rename_vnode_info_t *key_rename =
+ reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
+ key_vtn_t *key_vtn = reinterpret_cast<key_vtn_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn_t)));
- if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vtn_name))) {
- UPLL_LOG_DEBUG("CopyToConfigKey key_rename->old_unc_vtn_name NULL");
- free(key_vtn);
- return UPLL_RC_ERR_GENERIC;
- }
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vtn_name))) {
+ UPLL_LOG_DEBUG("CopyToConfigKey key_rename->old_unc_vtn_name NULL");
+ FREE_IF_NOT_NULL(key_vtn);
+ return UPLL_RC_ERR_GENERIC;
+ }
- uuu::upll_strncpy(key_vtn->vtn_name,
- key_rename->old_unc_vtn_name,
- (kMaxLenVtnName + 1));
+ uuu::upll_strncpy(key_vtn->vtn_name,
+ key_rename->old_unc_vtn_name,
+ (kMaxLenVtnName + 1));
- okey = new ConfigKeyVal(UNC_KT_VTN_POLICINGMAP,
- IpctSt::kIpcStKeyVtn, key_vtn, NULL);
- if (!okey) {
- UPLL_LOG_DEBUG("CopyToConfigKey okey NULL");
- free(key_vtn);
- return UPLL_RC_ERR_GENERIC;
+ okey = new ConfigKeyVal(UNC_KT_VTN_POLICINGMAP,
+ IpctSt::kIpcStKeyVtn, key_vtn, NULL);
+ if (!okey) {
+ UPLL_LOG_DEBUG("CopyToConfigKey okey NULL");
+ FREE_IF_NOT_NULL(key_vtn);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ return result_code;
+}
+
+upll_rc_t VtnPolicingMapMoMgr::UpdateVnodeVal(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t data_type,
+ bool &no_rename) {
+ UPLL_FUNC_TRACE;
+ ConfigKeyVal *okey = NULL;
+ ConfigKeyVal *kval = NULL;
+ ConfigKeyVal *ckval = NULL;
+ ConfigKeyVal *ckey = NULL;
+ controller_domain ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+
+ uint8_t rename = 0;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+
+ UPLL_LOG_DEBUG("CopyToConfigKey datatype (%d)", data_type);
+
+ key_rename_vnode_info_t *key_rename =
+ reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
+
+ // Copy the old policer name in val_policingmap
+ val_policingmap_t *val = reinterpret_cast<val_policingmap_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_policingmap_t)));
+ if (!val) return UPLL_RC_ERR_GENERIC;
+
+ memset(val, 0, sizeof(val_policingmap_t));
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_policingprofile_name))) {
+ FREE_IF_NOT_NULL(val);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ uuu::upll_strncpy(val->policer_name,
+ key_rename->old_policingprofile_name,
+ (kMaxLenPolicingProfileName + 1));
+ val->valid[UPLL_IDX_POLICERNAME_PM] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("policer name and valid (%d) (%s)",
+ val->valid[UPLL_IDX_POLICERNAME_PM], val->policer_name);
+// ConfigVal *cval = new ConfigVal(IpctSt::kIpcStValPolicingmap, val);
+
+ result_code = GetChildConfigKey(okey, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("CopyToConfigKey okey NULL");
+ FREE_IF_NOT_NULL(val);
+ return result_code;
+ }
+ if (!okey) {
+ FREE_IF_NOT_NULL(val);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ okey->SetCfgVal(new ConfigVal(IpctSt::kIpcStValPolicingmap, val));
+
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutFlag };
+
+ // Read the record of key structure and old policer name in maintbl
+ result_code = ReadConfigDB(okey, data_type, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG(" ReadConfigDB failed ");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ ConfigKeyVal *tmp_okey = okey;
+ while (okey != NULL) {
+ // Update the new policer name in MAINTBL
+ result_code = GetChildConfigKey(kval, okey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey kval NULL");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
}
- } else if (UNC_KT_POLICING_PROFILE == ikey->get_key_type()) {
- key_rename_vnode_info_t *key_rename =
- reinterpret_cast<key_rename_vnode_info_t *>(ikey->get_key());
+ if (!kval) return UPLL_RC_ERR_GENERIC;
- val_policingmap_t *val = reinterpret_cast<val_policingmap_t *>
+ // Copy the new policer name in val_policingmap
+ val_policingmap_t *val1 = reinterpret_cast<val_policingmap_t *>
(ConfigKeyVal::Malloc(sizeof(val_policingmap_t)));
- if (!strlen(reinterpret_cast<char *>
- (key_rename->old_policingprofile_name))) {
- free(val);
+ if (!val1) return UPLL_RC_ERR_GENERIC;
+ memset(val1, 0, sizeof(val_policingmap_t));
+
+ // New name null check
+ if (!strlen(reinterpret_cast<char *>(key_rename->new_policingprofile_name))) {
+ FREE_IF_NOT_NULL(val1);
+ UPLL_LOG_DEBUG("new_policingprofile_name NULL");
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
+ // Copy the new policer name into val_policingmap
+ uuu::upll_strncpy(val1->policer_name,
+ key_rename->new_policingprofile_name,
+ (kMaxLenPolicingProfileName + 1));
+ val1->valid[UPLL_IDX_POLICERNAME_PM] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("policer name and valid (%d) (%s)",
+ val1->valid[UPLL_IDX_POLICERNAME_PM], val1->policer_name);
+ ConfigVal *cval1 = new ConfigVal(IpctSt::kIpcStValPolicingmap, val1);
- uuu::upll_strncpy(val->policer_name,
- key_rename->old_policingprofile_name,
- (kMaxLenPolicingProfileName + 1));
- ConfigVal *cval = new ConfigVal(IpctSt::kIpcStValPolicingmap, val);
- okey = new ConfigKeyVal(UNC_KT_POLICING_PROFILE,
- IpctSt::kIpcStKeyPolicingprofile, NULL, cval);
- if (!okey) {
- UPLL_LOG_DEBUG("CopyToConfigKey okey NULL");
- free(val);
- return UPLL_RC_ERR_GENERIC;
+ kval->SetCfgVal(cval1);
+
+ GET_USER_DATA_FLAGS(okey, rename);
+
+ UPLL_LOG_DEBUG("okey flag (%d)", rename);
+ if (!no_rename)
+ rename = rename | POLICINGPROFILE_RENAME;
+ else
+ rename = rename & NO_POLICINGPROFILE_RENAME;
+
+ SET_USER_DATA_FLAGS(kval, rename);
+ UPLL_LOG_DEBUG("kval flag (%d)", rename);
+
+ // Update the new policer name in MAINTBL
+ result_code = UpdateConfigDB(kval, data_type, UNC_OP_UPDATE, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Create record Err in vtnpolicingmaptbl CANDIDATE DB(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
}
- } else {
- UPLL_LOG_DEBUG("CopyToConfigKey invalid key type NULL");
- return UPLL_RC_ERR_GENERIC;
+
+ // Get the momory alloctaed vtn key structure
+ VtnMoMgr *vtnmgr =
+ static_cast<VtnMoMgr *>((const_cast<MoManager *>
+ (GetMoManager(UNC_KT_VTN))));
+ result_code = vtnmgr->GetChildConfigKey(ckey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("UpdateRefCountInPPCtrlr GetChildConfigKey error (%d)",
+ result_code);
+ return result_code;
+ }
+ if (!ckey) return UPLL_RC_ERR_GENERIC;
+ // To get the vtn associated controller name
+ key_vtn_t *vtn_okey = reinterpret_cast<key_vtn_t *>(ckey->get_key());
+ key_vtn_t *vtn_ikey = reinterpret_cast<key_vtn_t *>(okey->get_key());
+ uuu::upll_strncpy(vtn_okey->vtn_name, vtn_ikey->vtn_name,
+ kMaxLenVtnName+1);
+
+ UPLL_LOG_DEBUG("vtn name ckey (%s) okey (%s)", vtn_okey->vtn_name, vtn_ikey->vtn_name);
+ result_code = vtnmgr->GetControllerDomainSpan(ckey, data_type, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetControllerSpan no instance/error (%d)", result_code);
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(ckey);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(ckey);
+ continue;
}
+ ConfigKeyVal *tmp_ckey = ckey;
+ while (ckey != NULL) {
+ GET_USER_DATA_CTRLR_DOMAIN(ckey, ctrlr_dom);
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+
+ // Update the new policer name in CTRLTBL
+ result_code = GetChildConfigKey(ckval, okey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey ckval NULL");
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(okey);
+ DELETE_IF_NOT_NULL(ckey);
+ return result_code;
+ }
+ if (!ckval) return UPLL_RC_ERR_GENERIC;
+
+ val_vtnpolicingmap_ctrl *policingmap_ctrlr_val =
+ reinterpret_cast<val_vtnpolicingmap_ctrl *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtnpolicingmap_ctrl)));
+
+ // Copy the new policer name into val_vtnpolicingmap_ctrl
+ uuu::upll_strncpy(policingmap_ctrlr_val->policer_name,
+ key_rename->new_policingprofile_name,
+ (kMaxLenPolicingProfileName + 1));
+ policingmap_ctrlr_val->valid[UPLL_IDX_POLICERNAME_PM] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("policer name and valid (%d) (%s)",
+ policingmap_ctrlr_val->valid[UPLL_IDX_POLICERNAME_PM],
+ policingmap_ctrlr_val->policer_name);
+
+ SET_USER_DATA_CTRLR_DOMAIN(ckval, ctrlr_dom);
+ ckval->SetCfgVal(new ConfigVal(IpctSt::kIpcInvalidStNum, policingmap_ctrlr_val));
+
+ SET_USER_DATA_FLAGS(ckval, rename);
+
+ UPLL_LOG_TRACE("ckval %s", ckval->ToStrAll().c_str());
+
+ // Update the new policer name in CTRLTBL
+ result_code = UpdateConfigDB(ckval, data_type, UNC_OP_UPDATE, dmi,
+ CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Create record Err in vtnpolicingmaptbl CANDIDATE DB(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(ckval);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+
+ DELETE_IF_NOT_NULL(ckval);
+
+ ckey = ckey->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(kval);
+ DELETE_IF_NOT_NULL(tmp_ckey);
+ okey = okey->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(tmp_okey);
return result_code;
}
upll_rc_t VtnPolicingMapMoMgr::MergeValidate(unc_key_type_t keytype,
- const char *ctrlr_id,
- ConfigKeyVal *ikey,
- DalDmlIntf *dmi) {
+ const char *ctrlr_id,
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
- ConfigKeyVal *tkey;
- ConfigKeyVal *keyval = NULL;
+ ConfigKeyVal *ckval = NULL;
+ ConfigKeyVal *ckey = NULL;
- if (NULL == ikey) {
- UPLL_LOG_DEBUG("MergeValidate ikey NULL");
+ if (NULL == ctrlr_id) {
+ UPLL_LOG_DEBUG("MergeValidate ctrlr_id NULL");
return UPLL_RC_ERR_GENERIC;
}
- // Read the record in IMPORT vtnpolicingmap table
- result_code = ReadConfigDB(ikey, UPLL_DT_IMPORT, UNC_OP_READ, dbop, dmi,
- MAINTBL);
+
+ result_code = GetChildConfigKey(ckval, NULL);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("MergeValidate ReadConfigDB error (%d)", result_code);
+ UPLL_LOG_DEBUG("GetChildConfigKey ckval NULL");
return result_code;
}
- MoMgrImpl *mgr = static_cast<MoMgrImpl *>((const_cast<MoManager *>
- (GetMoManager(UNC_KT_POLICING_PROFILE))));
- tkey = ikey;
- while (ikey != NULL) {
- result_code = mgr->GetChildConfigKey(keyval, NULL);
+
+ if (!ckval) return UPLL_RC_ERR_GENERIC;
+
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutNone };
+
+ result_code = ReadConfigDB(ckval, UPLL_DT_IMPORT,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ckval);
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("ReadConfigDB fail");
+ return result_code;
+ }
+ return UPLL_RC_SUCCESS;
+ }
+ ConfigKeyVal *tmp_ckval = ckval;
+ while (NULL != ckval) {
+ // Check the VTN already configured in UNC
+ VtnMoMgr *vtnmgr =
+ static_cast<VtnMoMgr *>((const_cast<MoManager *>
+ (GetMoManager(UNC_KT_VTN))));
+ result_code = vtnmgr->GetChildConfigKey(ckey, NULL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("MergeValidate GetChildConfigKey error (%d)", result_code);
+ UPLL_LOG_DEBUG("GetChildConfigKey error (%d)", result_code);
+ DELETE_IF_NOT_NULL(ckval);
return result_code;
}
- if (!keyval) return UPLL_RC_ERR_GENERIC;
- val_policingmap_t* val_vtn_policingmap =
- reinterpret_cast<val_policingmap_t *>(GetVal(ikey));
- key_policingprofile_t *key_policingprofile =
- reinterpret_cast<key_policingprofile_t*>(keyval->get_key());
- uuu::upll_strncpy(key_policingprofile->policingprofile_name,
- val_vtn_policingmap->policer_name,
- (kMaxLenPolicingProfileName + 1));
- // Check Import DB's policingmap record with Candidate DB's
- // policingprofile table
- result_code = mgr->UpdateConfigDB(keyval, UPLL_DT_CANDIDATE, UNC_OP_READ,
- dmi, MAINTBL);
- if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
- UPLL_LOG_DEBUG("MergeValidate UpdateConfigDB UPLL_RC_ERR_MERGE_CONFLICT");
- CONFIGKEYVALCLEAN(keyval);
+ if (!ckey) return UPLL_RC_ERR_GENERIC;
+
+ key_vtn_t *vtn_okey = reinterpret_cast<key_vtn_t *>(ckey->get_key());
+ key_vtn_t *vtn_ikey = reinterpret_cast<key_vtn_t *>(ckval->get_key());
+ uuu::upll_strncpy(vtn_okey->vtn_name, vtn_ikey->vtn_name,
+ kMaxLenVtnName+1);
+ DbSubOp dbop1 = { kOpReadExist, kOpMatchNone, kOpInOutNone };
+ // Check the vtn already exist in vtn tbl
+ result_code = vtnmgr->UpdateConfigDB(ckey, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
+ &dbop1, MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ UPLL_LOG_DEBUG("vtn already exists");
+ DELETE_IF_NOT_NULL(ckey);
+ ckval = ckval->get_next_cfg_key_val();
+ continue;
+ }
+
+ DELETE_IF_NOT_NULL(ckey);
+ // If already vtn not configured, then do merge validation
+ result_code = UpdateConfigDB(ckval, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
+ MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ UPLL_LOG_DEBUG("Merge Conflict");
+ result_code = DupConfigKeyVal(ikey, ckval, MAINTBL);
+ DELETE_IF_NOT_NULL(ckval);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal fail");
+ return result_code;
+ }
return UPLL_RC_ERR_MERGE_CONFLICT;
+ } else if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ ckval = ckval->get_next_cfg_key_val();
+ } else {
+ UPLL_LOG_DEBUG("Merge Conflict DB err");
+ DELETE_IF_NOT_NULL(ckval);
+ return result_code;
+ }
+ }
+ DELETE_IF_NOT_NULL(tmp_ckval);
+ return UPLL_RC_SUCCESS;
+}
+#if 0
+upll_rc_t VtnPolicingMapMoMgr::MergeImportToCandidate(unc_key_type_t keytype,
+ const char *ctrlr_name,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ctrlr_key = NULL, *req = NULL, *nreq = NULL;
+ DalCursor *cfg1_cursor = NULL;
+ DalResultCode db_result;
+
+ //Get the created records on import configuration which are not available
+ // at running configuration of UNC
+ result_code = DiffConfigDB(UPLL_DT_IMPORT, UPLL_DT_RUNNING, UNC_OP_CREATE, req,
+ nreq, &cfg1_cursor, dmi, MAINTBL);
+ while (result_code == UPLL_RC_SUCCESS) {
+ db_result = dmi->GetNextRecord(cfg1_cursor);
+ result_code = DalToUpllResCode(db_result);
+ if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ result_code = UPLL_RC_SUCCESS;
+ break;
+ }
+
+ // Update the record in the main table
+ result_code = UpdateConfigDB(req, UPLL_DT_CANDIDATE, UNC_OP_CREATE,
+ dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to update the main tbl,DB err %d", result_code);
+ if (cfg1_cursor) {
+ dmi->CloseCursor(cfg1_cursor, true);
+ cfg1_cursor = NULL;
+ }
+ delete req;
+ req = NULL;
+ return result_code;
+ }
+ //Update Controller Table
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchCtrlr,
+ kOpInOutCtrlr|kOpInOutDomain};
+ result_code = DupConfigKeyVal(ctrlr_key, req, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal is failed result_code = %d",
+ result_code);
+ return result_code;
+ }
+ SET_USER_DATA_CTRLR(ctrlr_key, ctrlr_name);
+
+ result_code = ReadConfigDB(ctrlr_key, UPLL_DT_IMPORT, UNC_OP_READ,
+ dbop, dmi, CTRLRTBL);
+ if ((result_code != UPLL_RC_SUCCESS) &&
+ (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG("Error in ReadConfigDb (%d)", result_code);
+ return result_code;
+ }
+ // create a record in CANDIDATE DB
+ result_code = UpdateConfigDB(ctrlr_key, UPLL_DT_CANDIDATE, UNC_OP_CREATE,
+ dmi, CTRLRTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to update ctrl table, DB err %d", result_code);
+ if (cfg1_cursor) {
+ dmi->CloseCursor(cfg1_cursor, true);
+ cfg1_cursor = NULL;
+ }
+ delete req;
+ req = NULL;
+ return result_code;
}
- ikey = tkey->get_next_cfg_key_val();
- CONFIGKEYVALCLEAN(keyval);
+ delete ctrlr_key;
+ ctrlr_key = NULL;
+ }
+ if (cfg1_cursor) {
+ dmi->CloseCursor(cfg1_cursor, true);
+ cfg1_cursor = NULL;
+ }
+ if (req) {
+ delete req;
+ req = NULL;
}
- CONFIGKEYVALCLEAN(tkey);
return result_code;
}
+#endif
+upll_rc_t VtnPolicingMapMoMgr::MergeImportToCandidate(unc_key_type_t keytype,
+ const char *ctrlr_name,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+
+ ConfigKeyVal *ckval = NULL;
+ ConfigKeyVal *ckey = NULL;
+
+ controller_domain ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+ uint8_t flag = 0;
+
+ if (NULL == ctrlr_name) {
+ UPLL_LOG_DEBUG("MergeValidate ctrlr_id NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ result_code = GetChildConfigKey(ckval, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey ckval NULL");
+ return result_code;
+ }
+
+
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutFlag };
+ // Read vtn ff from import main
+ result_code = ReadConfigDB(ckval, UPLL_DT_IMPORT,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ DELETE_IF_NOT_NULL(ckval);
+ UPLL_LOG_DEBUG("ReadConfigDB ckval NULL (%d)", result_code);
+ if(result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("ReadConfigDB ckval NULL (%d)", result_code);
+ return result_code;
+ }
+ return UPLL_RC_SUCCESS;
+ }
+
+ UPLL_LOG_DEBUG("ReadConfigDB ckval NULL (%d)", result_code);
+ ConfigKeyVal *tmp_ckval = ckval;
+ while (NULL != ckval) {
+ // Check the VTN already configured in UNC
+ VtnMoMgr *vtnmgr =
+ static_cast<VtnMoMgr *>((const_cast<MoManager *>
+ (GetMoManager(UNC_KT_VTN))));
+ result_code = vtnmgr->GetChildConfigKey(ckey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey error (%d)", result_code);
+ DELETE_IF_NOT_NULL(ckval);
+ return result_code;
+ }
+ if (!ckey) return UPLL_RC_ERR_GENERIC;
+
+ key_vtn_t *vtn_okey = reinterpret_cast<key_vtn_t *>(ckey->get_key());
+ key_vtn_flowfilter *vtn_ikey = reinterpret_cast<key_vtn_flowfilter_t *>(ckval->get_key());
+ uuu::upll_strncpy(vtn_okey->vtn_name, vtn_ikey->vtn_key.vtn_name,
+ kMaxLenVtnName+1);
+ DbSubOp dbop1 = { kOpReadExist, kOpMatchNone, kOpInOutNone };
+ // Check the vtn already exist in vtn tbl
+ result_code = vtnmgr->UpdateConfigDB(ckey, UPLL_DT_RUNNING, UNC_OP_READ, dmi,
+ &dbop1, MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS == result_code) {
+ UPLL_LOG_DEBUG("vtn already exists");
+ DELETE_IF_NOT_NULL(ckey);
+ ckval = ckval->get_next_cfg_key_val();
+ continue;
+ } else if (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ DELETE_IF_NOT_NULL(ckey);
+ DELETE_IF_NOT_NULL(ckval);
+ return result_code;
+ }
+
+ // If not same vtn, then merge the vtn ff to candidate tbl
+ result_code = UpdateConfigDB(ckval, UPLL_DT_CANDIDATE, UNC_OP_CREATE,
+ dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("create in CandidateDB failed: err code(%d) ",
+ result_code);
+ DELETE_IF_NOT_NULL(ckey);
+ DELETE_IF_NOT_NULL(ckval);
+ return result_code;
+ }
+
+ result_code = vtnmgr->GetControllerDomainSpan(ckey, UPLL_DT_IMPORT, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("GetControllerSpan no instance/error (%d)", result_code);
+ DELETE_IF_NOT_NULL(ckey);
+ continue;
+ }
+ }
+ ConfigKeyVal *tmp_ckey = ckey;
+ while (ckey != NULL) {
+ ConfigKeyVal *ctrlckv = NULL;
+ GET_USER_DATA_CTRLR_DOMAIN(ckey, ctrlr_dom);
+ GET_USER_DATA_FLAGS(ckval, flag);
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+
+ UPLL_LOG_DEBUG("flag (%d)", flag);
+
+ result_code = GetChildConfigKey(ctrlckv, ckval);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey ckval NULL");
+ DELETE_IF_NOT_NULL(ckval);
+ DELETE_IF_NOT_NULL(ckey);
+ return result_code;
+ }
+ val_policingmap_t *val2 = reinterpret_cast<val_policingmap_t *>(GetVal(ckval));
+ val_vtnpolicingmap_ctrl *policingmap_ctrlr_val =
+ reinterpret_cast<val_vtnpolicingmap_ctrl *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtnpolicingmap_ctrl)));
+ uuu::upll_strncpy(policingmap_ctrlr_val->policer_name, val2->policer_name,
+ (kMaxLenPolicingProfileName + 1));
+
+ policingmap_ctrlr_val->valid[UPLL_IDX_POLICERNAME_PM] = UNC_VF_VALID;
+ UPLL_LOG_DEBUG("policer_name (%s) valid (%d)", policingmap_ctrlr_val->policer_name,
+ policingmap_ctrlr_val->valid[UPLL_IDX_POLICERNAME_PM]);
+ SET_USER_DATA_CTRLR_DOMAIN(ctrlckv, ctrlr_dom);
+ SET_USER_DATA_FLAGS(ctrlckv, flag);
+ UPLL_LOG_DEBUG("GetChildConfigKey ckval NULL");
+ ctrlckv->SetCfgVal(new ConfigVal(IpctSt::kIpcInvalidStNum, policingmap_ctrlr_val));
+ UPLL_LOG_DEBUG("flag (%d)", flag);
+
+ // Create/Update/Delete a record in CANDIDATE DB
+ result_code = UpdateConfigDB(ctrlckv, UPLL_DT_CANDIDATE, UNC_OP_CREATE, dmi, CTRLRTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Err while inserting in ctrlr table for candidateDb(%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(ckey);
+ DELETE_IF_NOT_NULL(ckval);
+ DELETE_IF_NOT_NULL(ctrlckv);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(ctrlckv);
+ ckey = ckey->get_next_cfg_key_val();
+ }
+ DELETE_IF_NOT_NULL(tmp_ckey);
+ ckval = ckval->get_next_cfg_key_val();
+}
+
+ DELETE_IF_NOT_NULL(tmp_ckval);
+ return UPLL_RC_SUCCESS;
+}
upll_rc_t VtnPolicingMapMoMgr::GetRenamedUncKey(ConfigKeyVal *ctrlr_key,
upll_keytype_datatype_t dt_type,
UPLL_FUNC_TRACE;
upll_rc_t result_code;
ConfigKeyVal *unc_key = NULL;
-
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vtnpm start",
+ ctrlr_key->ToStrAll().c_str());
if (NULL == ctrlr_key || NULL == dmi || ctrlr_id[0] == '\0') {
UPLL_LOG_DEBUG("GetRenamedUncKey failed. Insufficient input parameters.");
return UPLL_RC_ERR_GENERIC;
}
key_vtn *ctrlr_vtn_key = reinterpret_cast<key_vtn *>(ctrlr_key->get_key());
-
+ if (!ctrlr_vtn_key) {
+ UPLL_LOG_DEBUG("ctrlr_vtn_key NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
val_rename_vtn *rename_vtn = reinterpret_cast<val_rename_vtn *>
(ConfigKeyVal::Malloc(sizeof(val_rename_vtn)));
+ if (!rename_vtn) {
+ UPLL_LOG_DEBUG("rename_vtn NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
uuu::upll_strncpy(rename_vtn->new_name, ctrlr_vtn_key->vtn_name,
(kMaxLenVtnName + 1));
return result_code;
}
if (!unc_key) {
+ UPLL_LOG_DEBUG("unc_key NULL");
free(rename_vtn);
return UPLL_RC_ERR_GENERIC;
}
result_code = mgr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL);
- if (UPLL_RC_SUCCESS != result_code
- && UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
- pfc_log_debug("GetRenamedUncKey failed. ReadConfigDB failed to read %d ",
- result_code);
- CONFIGKEYVALCLEAN(unc_key);
- return UPLL_RC_ERR_GENERIC;
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(unc_key);
+ mgr = NULL;
+ return result_code;
}
if (result_code == UPLL_RC_SUCCESS) {
}
mgr = NULL;
- CONFIGKEYVALCLEAN(unc_key);
+ DELETE_IF_NOT_NULL(unc_key);
val_rename_policingprofile *rename_policingprofile =
reinterpret_cast<val_rename_policingprofile *>
(ConfigKeyVal::Malloc(sizeof(val_rename_policingprofile)));
-
+ if (!rename_policingprofile) {
+ UPLL_LOG_DEBUG("rename_policingprofile NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
val_policingmap_t *val_policingmap =
reinterpret_cast<val_policingmap_t *>(GetVal(ctrlr_key));
if (!val_policingmap) {
free(rename_policingprofile);
- return UPLL_RC_ERR_GENERIC;
+ return UPLL_RC_SUCCESS;
}
memset(rename_policingprofile->policingprofile_newname, '\0',
val_policingmap->policer_name,
(kMaxLenPolicingProfileName + 1));
+ rename_policingprofile->valid[UPLL_IDX_RENAME_PROFILE_RPP] = UNC_VF_VALID;
+
MoMgrImpl *pp_mgr =
reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
UNC_KT_POLICING_PROFILE)));
if (NULL == pp_mgr) {
UPLL_LOG_DEBUG("mgr NULL");
- free(rename_policingprofile);
+ if (rename_policingprofile) free(rename_policingprofile);
return UPLL_RC_ERR_GENERIC;
}
result_code = pp_mgr->GetChildConfigKey(unc_key, NULL);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG(" GetRenamedUncKey failed. GetChildConfigKey failed to "
- "create policingprofile ConfigKeyVal %d",
- result_code);
- free(rename_policingprofile);
-
+ UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
+ if (rename_policingprofile) free(rename_policingprofile);
return result_code;
}
if (!unc_key) {
- free(rename_policingprofile);
+ UPLL_LOG_DEBUG("unc_key NULL");
+ if (rename_policingprofile) free(rename_policingprofile);
return UPLL_RC_ERR_GENERIC;
}
SET_USER_DATA_CTRLR(unc_key, ctrlr_id);
result_code = pp_mgr->ReadConfigDB(unc_key, dt_type, UNC_OP_READ, dbop, dmi,
RENAMETBL);
- if (UPLL_RC_SUCCESS != result_code
- && UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
- UPLL_LOG_DEBUG(" GetRenamedUncKey failed. ReadConfigDB failed to read %d ",
- result_code);
- CONFIGKEYVALCLEAN(unc_key);
- return UPLL_RC_ERR_GENERIC;
+ if ((UPLL_RC_SUCCESS != result_code) &&
+ (UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code)) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ pp_mgr = NULL;
+ DELETE_IF_NOT_NULL(unc_key);
+ return result_code;
}
- if (result_code == UPLL_RC_SUCCESS) { // COV DEAD CODE
+ if (result_code == UPLL_RC_SUCCESS) {
key_policingprofile_t *key_policingprofile =
reinterpret_cast<key_policingprofile_t *>(unc_key->get_key());
uuu::upll_strncpy(
key_policingprofile->policingprofile_name,
(kMaxLenPolicingProfileName + 1));
}
- CONFIGKEYVALCLEAN(unc_key);
- return result_code;
+ UPLL_LOG_TRACE("%s GetRenamedUncKey vtnpm end",
+ ctrlr_key->ToStrAll().c_str());
+ DELETE_IF_NOT_NULL(unc_key);
+ pp_mgr = NULL;
+ return UPLL_RC_SUCCESS;
}
upll_rc_t VtnPolicingMapMoMgr::TxUpdateController(
req, nreq, &dal_cursor_handle, dmi, MAINTBL);
break;
default:
- UPLL_LOG_DEBUG("TxUpdateController Invalid operation \n");
+ UPLL_LOG_DEBUG("TxUpdateController Invalid operation");
return UPLL_RC_ERR_GENERIC;
}
resp.header.clnt_sess_id = session_id;
result_code = DupConfigKeyVal(ck_main, req, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("DupConfigKeyVal err (%d)", result_code);
+ if (dal_cursor_handle)
+ dmi->CloseCursor(dal_cursor_handle, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
return result_code;
}
GET_USER_DATA_CTRLR_DOMAIN(ck_main, ctrlr_dom);
if (ctrlr_dom.ctrlr == NULL) {
UPLL_LOG_DEBUG("Invalid controller");
- if (ck_main) delete ck_main;
+ if (dal_cursor_handle)
+ dmi->CloseCursor(dal_cursor_handle, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(ck_main);
return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom.ctrlr,
op, dmi, &ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("TxUpdateProcess Returns error %d", result_code);
+ upll_keytype_datatype_t dt_type = (UNC_OP_DELETE == op)?
+ UPLL_DT_RUNNING:UPLL_DT_CANDIDATE;
+ upll_rc_t local_rc = GetRenamedUncKey(resp.ckv_data, dt_type, dmi,
+ ctrlr_dom.ctrlr);
+ if (UPLL_RC_SUCCESS != local_rc &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != local_rc) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey failed %d", local_rc);
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(resp.ckv_data);
+ result_code = UPLL_RC_ERR_GENERIC;
+ break;
+ }
*err_ckv = resp.ckv_data;
- if (ck_main) delete ck_main;
+ DELETE_IF_NOT_NULL(ck_main);
break;
}
+ DELETE_IF_NOT_NULL(resp.ckv_data);
affected_ctrlr_set->insert((const char *)ctrlr_dom.ctrlr);
} else if (op == UNC_OP_UPDATE) {
ConfigKeyVal *ck_ctrlr = NULL;
result_code = DupConfigKeyVal(ck_main, req, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
+ if (dal_cursor_handle)
+ dmi->CloseCursor(dal_cursor_handle, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
UPLL_LOG_DEBUG("DupConfigKeyVal failed");
return result_code;
}
- /*
- result_code = ValidateCapability(&(ipc_req.header), ck_main);
- if (result_code != UPLL_RC_SUCCESS) {
- if (ck_main != NULL) {
- delete ck_main;
- ck_main = NULL;
- }
- return result_code;
- }
- */
result_code = GetChildConfigKey(ck_ctrlr, ck_main);
- if (result_code != UPLL_RC_SUCCESS)
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (dal_cursor_handle)
+ dmi->CloseCursor(dal_cursor_handle, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(ck_main);
return result_code;
+ }
if (GetControllerDomainSpan(ck_ctrlr, UPLL_DT_CANDIDATE, dmi) ==
UPLL_RC_ERR_NO_SUCH_INSTANCE) {
- CONFIGKEYVALCLEAN(ck_ctrlr);
+ DELETE_IF_NOT_NULL(ck_ctrlr);
+ DELETE_IF_NOT_NULL(ck_main);
continue;
}
void *main = GetVal(ck_main);
void *val_nrec = (nreq) ? GetVal(nreq) : NULL;
- CompareValidValue(main, val_nrec, false);
- for (ConfigKeyVal *tmp = ck_ctrlr; tmp != NULL;
+ bool compare = false;
+ compare = CompareValidValue(main, val_nrec, false);
+ if (compare) {
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(ck_ctrlr);
+ continue;
+ }
+ for (ConfigKeyVal *tmp = ck_ctrlr; tmp != NULL;
tmp = tmp->get_next_cfg_key_val()) {
GET_USER_DATA_CTRLR_DOMAIN(tmp, ctrlr_dom);
if (ctrlr_dom.ctrlr == NULL || (ctrlr_dom.domain == NULL)) {
UPLL_LOG_DEBUG("Invalid controller");
- return UPLL_RC_ERR_GENERIC;
+ if (dal_cursor_handle)
+ dmi->CloseCursor(dal_cursor_handle, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(ck_ctrlr);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigKeyVal *temp_ck_main = NULL;
+ result_code = DupConfigKeyVal(temp_ck_main, ck_main, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DupConfigKeyVal failed %d", result_code);
+ if (dal_cursor_handle)
+ dmi->CloseCursor(dal_cursor_handle, true);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(ck_ctrlr);
+ DELETE_IF_NOT_NULL(ck_main);
+ return result_code;
}
-
result_code = TxUpdateProcess(ck_main, &resp, op, dmi, &ctrlr_dom);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("TxUpdate Process returns with %d\n", result_code);
- *err_ckv = resp.ckv_data;
- CONFIGKEYVALCLEAN(ck_main);
+ UPLL_LOG_DEBUG("TxUpdate Process returns with %d", result_code);
+ *err_ckv = temp_ck_main;
+ DELETE_IF_NOT_NULL(resp.ckv_data);
+ DELETE_IF_NOT_NULL(ck_main);
+ DELETE_IF_NOT_NULL(ck_ctrlr);
break;
}
+ DELETE_IF_NOT_NULL(temp_ck_main);
affected_ctrlr_set->insert(reinterpret_cast<const char *>
(ctrlr_dom.ctrlr));
}
- delete ck_ctrlr;
+ DELETE_IF_NOT_NULL(ck_ctrlr);
}
- delete ck_main;
+ DELETE_IF_NOT_NULL(ck_main);
}
- if (nreq)
- delete nreq;
- if (req)
- delete req;
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(req);
if (dal_cursor_handle) {
dmi->CloseCursor(dal_cursor_handle, true);
dal_cursor_handle = NULL;
dup_ckmain = NULL;
result_code = GetChildConfigKey(dup_ckmain, ck_main);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
- if (dup_ckmain) delete dup_ckmain;
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
return result_code;
}
DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutCs};
result_code = ReadConfigDB(dup_ckmain, UPLL_DT_CANDIDATE,
UNC_OP_READ, dbop, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
- string s(dup_ckmain->ToStrAll());
- UPLL_LOG_INFO("%s Policingprofile read failed %d",
- s.c_str(), result_code);
- delete dup_ckmain;
+ UPLL_LOG_TRACE("%s Policingprofile read failed %d",
+ dup_ckmain->ToStrAll().c_str(), result_code);
+ DELETE_IF_NOT_NULL(dup_ckmain);
return result_code;
}
}
/* Get renamed key if key is renamed */
- result_code = GetRenamedControllerKey(dup_ckmain, UPLL_DT_CANDIDATE,
+ if (op == UNC_OP_DELETE) {
+ result_code = GetRenamedControllerKey(dup_ckmain, UPLL_DT_RUNNING,
+ dmi, ctrlr_dom);
+ } else {
+ result_code = GetRenamedControllerKey(dup_ckmain, UPLL_DT_CANDIDATE,
dmi, ctrlr_dom);
+ }
if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetRenamedControllerKey failed %d", result_code);
+ if (op == UNC_OP_CREATE)
+ DELETE_IF_NOT_NULL(dup_ckmain);
return result_code;
}
result_code = SendIpcReq(ipc_resp->header.clnt_sess_id,
ipc_resp->header.config_id, op, UPLL_DT_CANDIDATE,
dup_ckmain, ctrlr_dom, ipc_resp);
if (result_code == UPLL_RC_ERR_RESOURCE_DISCONNECTED) {
- UPLL_LOG_DEBUG("Controller disconnected\n");
+ UPLL_LOG_DEBUG("Controller disconnected");
+ if (op == UNC_OP_CREATE)
+ DELETE_IF_NOT_NULL(dup_ckmain);
result_code = UPLL_RC_SUCCESS;
}
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("IpcSend failed %d\n", result_code);
+ UPLL_LOG_DEBUG("IpcSend failed %d", result_code);
}
- if ((op == UNC_OP_CREATE) && dup_ckmain) {
- delete dup_ckmain;
- dup_ckmain = NULL;
+ if ((op == UNC_OP_CREATE)) {
+ DELETE_IF_NOT_NULL(dup_ckmain);
}
return result_code;
}
if (op != UNC_OP_DELETE) {
result_code = DupConfigKeyVal(ck_vtn, vtn_key, MAINTBL);
if (!ck_vtn || result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
return UPLL_RC_ERR_GENERIC;
}
pm_val = reinterpret_cast<val_policingmap_t *>(GetVal(ck_vtn));
if (!pm_val) {
- UPLL_LOG_DEBUG("invalid val \n");
+ DELETE_IF_NOT_NULL(ck_vtn);
+ UPLL_LOG_DEBUG("invalid val");
return UPLL_RC_ERR_GENERIC;
}
} else {
result_code = GetChildConfigKey(ck_vtn, vtn_key);
if (!ck_vtn || result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Returning error %d\n", result_code);
+ UPLL_LOG_DEBUG("Returning error %d", result_code);
return UPLL_RC_ERR_GENERIC;
}
}
switch (op) {
case UNC_OP_CREATE:
- pm_val->cs_row_status = UNC_CS_NOT_APPLIED;
+ pm_val->cs_row_status = UNC_CS_APPLIED;
break;
case UNC_OP_UPDATE:
pmval = reinterpret_cast<void *>(&pm_val);
npmval = (nreq)?GetVal(nreq):NULL;
if (!npmval) {
- UPLL_LOG_DEBUG("Invalid param\n");
+ DELETE_IF_NOT_NULL(ck_vtn);
+ UPLL_LOG_DEBUG("Invalid param");
return UPLL_RC_ERR_GENERIC;
}
CompareValidValue(pmval, npmval, false);
+ pm_val->cs_row_status =
+ reinterpret_cast<val_policingmap_t *>
+ (GetVal(nreq))->cs_row_status;
break;
case UNC_OP_DELETE:
break;
default:
- UPLL_LOG_DEBUG("Inalid operation\n");
+ DELETE_IF_NOT_NULL(ck_vtn);
+ UPLL_LOG_DEBUG("Inalid operation");
return UPLL_RC_ERR_GENERIC;
}
- result_code = UpdateConfigDB(ck_vtn, UPLL_DT_STATE, op, dmi, MAINTBL);
+
+ DbSubOp dbop = {kOpNotRead, kOpMatchNone, kOpInOutNone};
+ dbop.inoutop = kOpInOutCs | kOpInOutFlag;
+ result_code = UpdateConfigDB(ck_vtn, UPLL_DT_STATE, op, dmi, &dbop, MAINTBL);
EnqueCfgNotification(op, UPLL_DT_RUNNING, ck_vtn);
delete ck_vtn;
return result_code;
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
ConfigKeyVal *okey = NULL;
- uint8_t rename = 0; // rename_pp = 0;
+ uint8_t rename = 0;
if (NULL == ikey || NULL == dmi) {
UPLL_LOG_DEBUG("Insufficient input resources");
result_code = IsRenamed(ikey, dt_type, dmi, rename);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("GetRenamedControllerKey failed. IsRenamed failed to "
- "check rename - %d",
- result_code);
+ UPLL_LOG_DEBUG("IsRenamed failed (%d)", result_code);
return result_code;
}
if (rename == 0) {
- UPLL_LOG_DEBUG("Name has not renamed");
+ UPLL_LOG_DEBUG("Name not renamed");
return UPLL_RC_SUCCESS;
}
+ UPLL_LOG_TRACE("Start .. InputConfigKeyVal %s", ikey->ToStrAll().c_str());
+ if (UNC_KT_VTN_POLICINGMAP_CONTROLLER == ikey->get_key_type()) {
if (rename & VTN_RENAME) {
- DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr|kOpMatchDomain,
- kOpInOutFlag };
-
+ UPLL_LOG_DEBUG("vtn_pm_ctrl vtn name renamed");
MoMgrImpl *vtn_mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>
(GetMoManager(UNC_KT_VTN)));
if (NULL == vtn_mgr) {
result_code = vtn_mgr->GetChildConfigKey(okey, NULL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(" GetRenamedControllerKey failed. "
- "GetChildConfigKey failed to create vbr ConfigKey - %d",
- result_code);
+ UPLL_LOG_DEBUG("GetChildConfigKey fail (%d)", result_code);
return result_code;
}
if (!okey) return UPLL_RC_ERR_GENERIC;
- key_vtn_t *ovtn_key = reinterpret_cast<key_vtn_t*>(okey->get_key());
- key_vtn_t *ivtn_key = reinterpret_cast<key_vtn_t*>(ikey->get_key());
- uuu::upll_strncpy(reinterpret_cast<char*>(ovtn_key->vtn_name),
- reinterpret_cast<char*>(ivtn_key->vtn_name),
- kMaxLenVtnName+1);
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr | kOpMatchDomain, kOpInOutFlag };
- if (!ctrlr_dom)
+ if (ctrlr_dom) {
SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr_dom null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vtn *>(okey->get_key())->vtn_name,
+ reinterpret_cast<key_vtn_policingmap_controller_t *>
+ (ikey->get_key())->vtn_key.vtn_name,
+ (kMaxLenVtnName + 1));
+
+ UPLL_LOG_DEBUG("vtn name (%s) (%s)",
+ reinterpret_cast<key_vtn *>(okey->get_key())->vtn_name,
+ reinterpret_cast<key_vtn_policingmap_controller_t *>
+ (ikey->get_key())->vtn_key.vtn_name);
result_code = vtn_mgr->ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi,
- RENAMETBL); /* ctrlr_name */
+ RENAMETBL);
if (UPLL_RC_SUCCESS != result_code) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB no instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
UPLL_LOG_DEBUG("GetRenamedControllerKey ReadConfigDB error");
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
val_rename_vtn *rename_val =
reinterpret_cast<val_rename_vtn *>(GetVal(okey));
- if (!rename_val
- || (rename_val->valid[UPLL_IDX_NEW_NAME_RVTN] != UNC_VF_VALID)) {
- CONFIGKEYVALCLEAN(okey);
+ if (!rename_val) {
UPLL_LOG_DEBUG("rename_val NULL");
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_GENERIC;
}
- uuu::upll_strncpy(reinterpret_cast<char *>(ivtn_key->vtn_name),
- reinterpret_cast<const char *>(rename_val->new_name),
- kMaxLenVtnName + 1);
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vtn_policingmap_controller_t*>
+ (ikey->get_key())->vtn_key.vtn_name,
+ rename_val->new_name,
+ kMaxLenVtnName + 1);
+
+ UPLL_LOG_DEBUG("renamed vtn_pm_ctrl vtn name (%s) (%s)",
+ reinterpret_cast<key_vtn_policingmap_controller_t*>
+ (ikey->get_key())->vtn_key.vtn_name,
+ rename_val->new_name);
SET_USER_DATA_FLAGS(ikey, rename);
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
vtn_mgr = NULL;
+ return UPLL_RC_SUCCESS;
}
+ }
+ if (rename & VTN_RENAME) {
+ UPLL_LOG_DEBUG("vtn name renamed");
+ MoMgrImpl *vtn_mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>
+ (GetMoManager(UNC_KT_VTN)));
+ if (NULL == vtn_mgr) {
+ UPLL_LOG_DEBUG("mgr NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ result_code = vtn_mgr->GetChildConfigKey(okey, NULL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey fail (%d)", result_code);
+ return result_code;
+ }
+ if (!okey) return UPLL_RC_ERR_GENERIC;
+
+ DbSubOp dbop = { kOpReadSingle, kOpMatchCtrlr | kOpMatchDomain, kOpInOutFlag };
+
+ if (ctrlr_dom) {
+ SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr_dom null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vtn *>(okey->get_key())->vtn_name,
+ reinterpret_cast<key_vtn_t *>
+ (ikey->get_key())->vtn_name,
+ (kMaxLenVtnName + 1));
+
+ UPLL_LOG_DEBUG("vtn name (%s) (%s)",
+ reinterpret_cast<key_vtn *>(okey->get_key())->vtn_name,
+ reinterpret_cast<key_vtn_t *>(ikey->get_key())->vtn_name);
+
+ result_code = vtn_mgr->ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi,
+ RENAMETBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB no instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("GetRenamedControllerKey ReadConfigDB error");
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+
+ val_rename_vtn *rename_val =
+ reinterpret_cast<val_rename_vtn *>(GetVal(okey));
+ if (!rename_val) {
+ UPLL_LOG_DEBUG("rename_val NULL");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
- CONFIGKEYVALCLEAN(okey);
+ uuu::upll_strncpy(
+ reinterpret_cast<key_vtn_t*>(ikey->get_key())->vtn_name,
+ rename_val->new_name,
+ kMaxLenVtnName + 1);
+
+ DELETE_IF_NOT_NULL(okey);
+ vtn_mgr = NULL;
+ }
if (rename & POLICINGPROFILE_RENAME) {
+ UPLL_LOG_DEBUG("vtn name renamed");
MoMgrImpl *pp_mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>
(GetMoManager(UNC_KT_POLICING_PROFILE)));
if (NULL == pp_mgr) {
return result_code;
}
if (!okey) return UPLL_RC_ERR_GENERIC;
+
+ if (NULL != ctrlr_dom) {
+ SET_USER_DATA_CTRLR(okey, ctrlr_dom->ctrlr);
+ } else {
+ UPLL_LOG_DEBUG("ctrlr null");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ UPLL_LOG_DEBUG("ctrlr : %s; domain : %s", ctrlr_dom->ctrlr,
+ ctrlr_dom->domain);
+
val_policingmap_t *val_policingmap =
reinterpret_cast<val_policingmap_t *>(GetVal(ikey));
+ if (!val_policingmap)
+ return UPLL_RC_SUCCESS;
+
key_policingprofile_t *key_policingprofile =
reinterpret_cast<key_policingprofile_t *>(okey->get_key());
val_policingmap->policer_name,
(kMaxLenPolicingProfileName + 1));
- if (!ctrlr_dom) SET_USER_DATA_CTRLR_DOMAIN(okey, *ctrlr_dom);
+ UPLL_LOG_DEBUG("policer name (%s) (%s)", val_policingmap->policer_name,
+ key_policingprofile->policingprofile_name);
DbSubOp dbop1 = { kOpReadSingle, kOpMatchCtrlr, kOpInOutFlag };
result_code = pp_mgr->ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop1, dmi,
RENAMETBL);
if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG(" GetRenamedControllerKey failed. ReadConfigDB failed "
- "to read policingprofile renametbl - %d",
- result_code);
- CONFIGKEYVALCLEAN(okey);
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB no instance");
+ DELETE_IF_NOT_NULL(okey);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG("ReadConfigDB fail (%d)", result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
val_rename_policingprofile_t *rename_policingprofile =
reinterpret_cast<val_rename_policingprofile_t *>(GetVal(okey));
if (!rename_policingprofile) {
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
UPLL_LOG_DEBUG("rename_policingprofile NULL");
return UPLL_RC_ERR_GENERIC;
}
(rename_policingprofile->policingprofile_newname),
(kMaxLenPolicingProfileName + 1));
- SET_USER_DATA_FLAGS(ikey, rename);
+ UPLL_LOG_DEBUG("policer rename (%s) (%s)",
+ reinterpret_cast<char *>(val_policingmap->policer_name),
+ reinterpret_cast<const char *>
+ (rename_policingprofile->policingprofile_newname));
+
pp_mgr = NULL;
}
- CONFIGKEYVALCLEAN(okey);
+ DELETE_IF_NOT_NULL(okey);
+ UPLL_LOG_TRACE("End .. Input ConfigKeyVal %s", ikey->ToStrAll().c_str());
return UPLL_RC_SUCCESS;
}
unc_keytype_operation_t op[] = { UNC_OP_DELETE, UNC_OP_CREATE,
UNC_OP_UPDATE };
int nop = sizeof(op) / sizeof(op[0]);
- ConfigKeyVal *vtn_key = NULL, *req = NULL, *nreq = NULL;
+ ConfigKeyVal *vtn_key = NULL, *req = NULL, *nreq = NULL,
+ *vtn_ck_run = NULL;
DalCursor *cfg1_cursor = NULL;
uint8_t *ctrlr_id = NULL;
/*IpcReqRespHeader *req_header = reinterpret_cast<IpcReqRespHeader *>
- (ConfigKeyVal::Malloc(sizeof(IpcReqRespHeader)));
- */
+ (ConfigKeyVal::Malloc(sizeof(IpcReqRespHeader)));
+ */
map<string, int> ctrlr_result;
CtrlrCommitStatusList::iterator ccsListItr;
CtrlrCommitStatus *ccStatusPtr;
for (int i = 0; i < nop; i++) {
if (op[i] != UNC_OP_UPDATE) {
result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i], req,
- nreq, &cfg1_cursor, dmi, MAINTBL);
+ nreq, &cfg1_cursor, dmi, NULL, MAINTBL, true);
while (result_code == UPLL_RC_SUCCESS) {
db_result = dmi->GetNextRecord(cfg1_cursor);
result_code = DalToUpllResCode(db_result);
nreq, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Updating Main table Error %d", result_code);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
}
for (int i = 0; i < nop; i++) {
MoMgrTables tbl = (op[i] == UNC_OP_UPDATE)?MAINTBL:CTRLRTBL;
result_code = DiffConfigDB(UPLL_DT_CANDIDATE, UPLL_DT_RUNNING, op[i], req,
- nreq, &cfg1_cursor, dmi, tbl);
+ nreq, &cfg1_cursor, dmi, NULL, tbl, true);
ConfigKeyVal *vtn_ctrlr_key = NULL;
while (result_code == UPLL_RC_SUCCESS) {
break;
}
if (op[i] == UNC_OP_UPDATE) {
- DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr };
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutCtrlr |
+ kOpInOutDomain | kOpInOutCs };
result_code = GetChildConfigKey(vtn_ctrlr_key, req);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
- result_code);
+ result_code);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
/* Capability check
result_code = ReadConfigDB(vtn_ctrlr_key, UPLL_DT_CANDIDATE,
UNC_OP_READ, dbop, dmi, CTRLRTBL);
if (result_code != UPLL_RC_SUCCESS) {
- delete vtn_ctrlr_key;
+ DELETE_IF_NOT_NULL(vtn_ctrlr_key);
if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
result_code = UpdateMainTbl(req, op[i], UPLL_RC_SUCCESS,
nreq, dmi);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Error updating main table%d", result_code);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
} else {
continue;
}
} else {
+ UPLL_LOG_DEBUG("DB err while reading records from ctrlrtbl, err %d",
+ result_code);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
}
- result_code = DupConfigKeyVal(vtn_key, req, tbl);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("DupConfigKeyVal is failed result_code = %d",
- result_code);
- CONFIGKEYVALCLEAN(vtn_ctrlr_key);
- return result_code;
- }
- GET_USER_DATA_CTRLR(vtn_ctrlr_key, ctrlr_id);
- string controller(reinterpret_cast<char *>(ctrlr_id));
for (ConfigKeyVal *tmp = vtn_ctrlr_key; tmp != NULL; tmp =
tmp->get_next_cfg_key_val()) {
+
+ GET_USER_DATA_CTRLR(tmp, ctrlr_id);
+ string controller(reinterpret_cast<char *> (ctrlr_id));
+
+ UPLL_LOG_DEBUG("Controller ID =%s", controller.c_str());
+ DbSubOp dbop_maintbl = { kOpReadSingle, kOpMatchNone, kOpInOutFlag };
+ result_code = GetChildConfigKey(vtn_key, req);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
+ result_code);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ result_code = ReadConfigDB(vtn_key, UPLL_DT_CANDIDATE,
+ UNC_OP_READ, dbop_maintbl, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Unable to read configuration from CandidateDb");
+ DELETE_IF_NOT_NULL(vtn_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
result_code = UpdateConfigStatus(vtn_key, op[i],
ctrlr_result[controller], nreq,
dmi, tmp);
if (result_code != UPLL_RC_SUCCESS) break;
- result_code = UpdateConfigDB(vtn_ctrlr_key,
+ result_code = UpdateConfigDB(tmp,
UPLL_DT_RUNNING, op[i], dmi, CTRLRTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("UpdateConfigDB for ctrlr tbl is failed ");
- CONFIGKEYVALCLEAN(vtn_ctrlr_key);
- CONFIGKEYVALCLEAN(vtn_key);
+ DELETE_IF_NOT_NULL(vtn_ctrlr_key);
+ DELETE_IF_NOT_NULL(vtn_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
result_code = UpdateConfigDB(vtn_key, UPLL_DT_RUNNING,
op[i], dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("UpdateConfigDB for main tbl is failed");
- CONFIGKEYVALCLEAN(vtn_ctrlr_key);
- CONFIGKEYVALCLEAN(vtn_key);
+ DELETE_IF_NOT_NULL(vtn_ctrlr_key);
+ DELETE_IF_NOT_NULL(vtn_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
} // COV UNREACHABLE
#if 0
#endif
EnqueCfgNotification(op[i], UPLL_DT_RUNNING,
vtn_key);
+ DELETE_IF_NOT_NULL(vtn_key);
}
} else {
if (op[i] == UNC_OP_CREATE) {
- DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag };
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag |kOpInOutCs };
result_code = GetChildConfigKey(vtn_key, req);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("GetChildConfigKey is failed -%d", result_code);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
- result_code = ReadConfigDB(vtn_key, UPLL_DT_CANDIDATE,
- UNC_OP_READ, dbop, dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
+ result_code = ReadConfigDB(vtn_key,UPLL_DT_RUNNING /*UPLL_DT_CANDIDATE*/,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if ((result_code != UPLL_RC_SUCCESS) &&
+ (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
UPLL_LOG_DEBUG("ReadConfigDB is failed -%d", result_code);
- CONFIGKEYVALCLEAN(vtn_key);
+ DELETE_IF_NOT_NULL(vtn_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ /* set consolidated config status to UNKNOWN to init vtn cs_status
+ * to the cs_status of first controller
+ */
+ uint32_t cur_instance_count;
+ result_code = GetInstanceCount(vtn_key, NULL,
+ UPLL_DT_CANDIDATE, &cur_instance_count,
+ dmi, CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetInstanceCount failed %d", result_code);
+ DELETE_IF_NOT_NULL(vtn_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
+ if (cur_instance_count == 1)
+ reinterpret_cast<val_policingmap*>(GetVal(vtn_key))->cs_row_status
+ = UNC_CS_UNKNOWN ;
+
/* Capability check
* req_header->operation = op[i];
* strcpy((char*)req_header->datatype, (char*)UNC_DT_CANDIDATE);
result_code = DupConfigKeyVal(vtn_ctrlr_key, req, tbl);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("DupConfigKeyVal is failed -%d", result_code);
- CONFIGKEYVALCLEAN(vtn_key);
+ DELETE_IF_NOT_NULL(vtn_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
GET_USER_DATA_CTRLR(vtn_ctrlr_key, ctrlr_id);
string controller(reinterpret_cast<char *>(ctrlr_id));
result_code = UpdateConfigStatus(vtn_key, op[i],
- ctrlr_result[controller], NULL,
- dmi, vtn_ctrlr_key);
+ ctrlr_result[controller], nreq,
+ dmi, vtn_ctrlr_key);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Error in updating configstatus, resultcode=%d",
result_code);
- CONFIGKEYVALCLEAN(vtn_ctrlr_key);
- CONFIGKEYVALCLEAN(vtn_key);
+ DELETE_IF_NOT_NULL(vtn_ctrlr_key);
+ DELETE_IF_NOT_NULL(vtn_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
} else if (op[i] == UNC_OP_DELETE) {
+ //Reading Main Running DB for delete op
+ DbSubOp dbop1 = { kOpReadSingle, kOpMatchNone, kOpInOutFlag | kOpInOutCs };
+ result_code = GetChildConfigKey(vtn_ck_run, req);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetChildConfigKey is failed resultcode=%d",
+ result_code);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ result_code = ReadConfigDB(vtn_ck_run, UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop1, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("Unable to read configuration from Running");
+ DELETE_IF_NOT_NULL(vtn_ck_run);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ GET_USER_DATA_CTRLR(req, ctrlr_id);
+ result_code = SetVtnPmConsolidatedStatus(vtn_ck_run, ctrlr_id, dmi);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Could not set consolidated status %d", result_code);
+ DELETE_IF_NOT_NULL(vtn_ck_run);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
+ return result_code;
+ }
+ }
+ DELETE_IF_NOT_NULL(vtn_ck_run);
result_code = GetChildConfigKey(vtn_ctrlr_key, req);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("Error in getting the configkey, resultcode=%d",
- result_code);
+ result_code);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
}
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("UpdateConfigDB in ctrlr tbl is failed -%d",
result_code);
- CONFIGKEYVALCLEAN(vtn_ctrlr_key);
+ DELETE_IF_NOT_NULL(vtn_ctrlr_key);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
if (op[i] != UNC_OP_DELETE) {
UNC_OP_UPDATE, dmi, MAINTBL);
if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("UpdateConfigDB in main tbl is failed -%d",
- result_code);
+ result_code);
+ DELETE_IF_NOT_NULL(req);
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(vtn_key);
+ dmi->CloseCursor(cfg1_cursor, true);
return result_code;
}
}
EnqueCfgNotification(op[i], UPLL_DT_RUNNING,
vtn_key);
}
- if (vtn_key) delete vtn_key;
- vtn_key = vtn_ctrlr_key = NULL;
+ DELETE_IF_NOT_NULL(vtn_key);
+ DELETE_IF_NOT_NULL(vtn_ctrlr_key);
result_code = DalToUpllResCode(db_result);
}
if (cfg1_cursor) {
dmi->CloseCursor(cfg1_cursor, true);
cfg1_cursor = NULL;
}
- if (nreq) delete nreq;
- if (req) delete req;
- nreq = req = NULL;
+ DELETE_IF_NOT_NULL(nreq);
+ DELETE_IF_NOT_NULL(req);
}
result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) ?
- UPLL_RC_SUCCESS : result_code;
+ UPLL_RC_SUCCESS : result_code;
UPLL_LOG_DEBUG("TxcopyCandidatetoRunning is successful -%d", result_code);
return result_code;
}
unc_keytype_operation_t op, uint32_t driver_result, ConfigKeyVal *nreq,
DalDmlIntf *dmi, ConfigKeyVal *ctrlr_key) {
UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
-#if 0
- unc_keytype_configstatus_t status = UNC_CS_UNKNOWN,
- cs_status = UNC_CS_UNKNOWN;
- cs_status = (driver_result == 0)?UNC_CS_APPLIED: UNC_CS_NOT_APPLIED;
+ unc_keytype_configstatus_t ctrlr_status;
+ uint8_t cs_status;
+ ctrlr_status = (driver_result == 0)?UNC_CS_APPLIED: UNC_CS_NOT_APPLIED;
val_policingmap_t *pm_val =
reinterpret_cast<val_policingmap_t *>(GetVal(ckv));
val_vtnpolicingmap_ctrl_t *ctrlr_val_pm =
UPLL_LOG_DEBUG("Memory Allocation failed for Valstructure");
return UPLL_RC_ERR_GENERIC;
}
-
+ cs_status = (pm_val->cs_row_status);
+ UPLL_LOG_TRACE("cs_status %d ctrlr_status %d\n", cs_status, ctrlr_status);
if (op == UNC_OP_CREATE) {
+ ctrlr_val_pm->cs_row_status = ctrlr_status;
+ ctrlr_val_pm->cs_attr[0] = ctrlr_status;
/* update the vtn status in main tbl */
- switch (pm_val->cs_row_status) {
- case UNC_CS_UNKNOWN:
- status = cs_status;
- break;
- case UNC_CS_PARTAILLY_APPLIED:
- if (ctrlr_val_pm->cs_row_status == UNC_CS_NOT_APPLIED) {
- // if this vtn has caused it then to change to applied.
+ if (pm_val->cs_row_status == UNC_CS_UNKNOWN) {
+ /* first entry in ctrlr table */
+ cs_status = ctrlr_status;
+ } else if (pm_val->cs_row_status == UNC_CS_INVALID) {
+ cs_status = UNC_CS_INVALID;
+ } else if (pm_val->cs_row_status == UNC_CS_APPLIED) {
+ if (ctrlr_status == UNC_CS_NOT_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
}
- break;
- case UNC_CS_APPLIED:
- case UNC_CS_NOT_APPLIED:
- case UNC_CS_INVALID:
- default:
- status = (cs_status == UNC_CS_APPLIED)?UNC_CS_PARTAILLY_APPLIED:status;
- break;
+ } else if (pm_val->cs_row_status == UNC_CS_NOT_APPLIED) {
+ if (ctrlr_status == UNC_CS_APPLIED) {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
+ }
+ } else {
+ cs_status = UNC_CS_PARTIALLY_APPLIED;
}
- if (ctrlr_val_pm->cs_row_status != UNC_CS_NOT_SUPPORTED)
- ctrlr_val_pm->cs_row_status = cs_status;
-// pyn need code
- pm_val->cs_row_status = status;
- } else if (op == UNC_OP_UPDATE) {
- if (ctrlr_val_pm->cs_row_status != UNC_CS_NOT_SUPPORTED)
- ctrlr_val_pm->cs_row_status = cs_status;
- pm_val->cs_row_status = status;
+ pm_val->cs_row_status = cs_status;
+ pm_val->cs_attr[0] = cs_status;
}
-#endif
- UPLL_LOG_DEBUG("UpdateConfigStatus Successfull.");
- return result_code;
+ // Updating the Controller cs_row_status
+ if ((op == UNC_OP_UPDATE) && (nreq != NULL)) {
+ val_vtnpolicingmap_ctrl *run_ctrlr_val =
+ reinterpret_cast<val_vtnpolicingmap_ctrl*>
+ (GetVal(nreq));
+ if (run_ctrlr_val != NULL)
+ ctrlr_val_pm->cs_row_status = run_ctrlr_val->cs_row_status;
+ }
+ return UPLL_RC_SUCCESS;
}
-
upll_rc_t VtnPolicingMapMoMgr::ValidateReadAttribute(ConfigKeyVal *ikey,
DalDmlIntf *dmi,
IpcReqRespHeader *req) {
UPLL_FUNC_TRACE;
+ ConfigKeyVal* vtnkey = NULL;
upll_rc_t result_code;
if (UNC_OPT1_DETAIL == req->option1 &&
- (UNC_OP_READ == req->operation ||
- UNC_OP_READ_SIBLING == req->operation ||
- UNC_OP_READ_SIBLING_BEGIN == req->operation)) {
+ (UNC_OP_READ == req->operation ||
+ UNC_OP_READ_SIBLING == req->operation ||
+ UNC_OP_READ_SIBLING_BEGIN == req->operation)) {
ConfigKeyVal *okey = NULL;
if (UNC_KT_VTN_POLICINGMAP_CONTROLLER == ikey->get_key_type()) {
+ key_vtn_policingmap_controller *l_key =
+ reinterpret_cast<key_vtn_policingmap_controller*>(ikey->get_key());
+
+ key_vtn_t *vtn_key = reinterpret_cast<key_vtn_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn)));
+ uuu::upll_strncpy(vtn_key->vtn_name,
+ l_key->vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+
+ vtnkey = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcStKeyVtn, vtn_key, NULL);
+
+ VtnMoMgr *mgrvtn = reinterpret_cast<VtnMoMgr *>(
+ const_cast<MoManager*>(GetMoManager(UNC_KT_VTN)));
+
+ if (NULL == mgrvtn) {
+ UPLL_LOG_DEBUG("unable to get VtnMoMgr object to validate key_vtn");
+ DELETE_IF_NOT_NULL(vtnkey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ DbSubOp dbop1 = { kOpReadExist, kOpMatchNone, kOpInOutNone};
+ result_code = mgrvtn->UpdateConfigDB(vtnkey, req->datatype,
+ UNC_OP_READ, dmi, &dbop1, MAINTBL);
+ if (result_code != UPLL_RC_ERR_INSTANCE_EXISTS) {
+ UPLL_LOG_DEBUG("Requested Vtn is Not Configured in"
+ "vtnmaintbl Table %d", result_code);
+ DELETE_IF_NOT_NULL(vtnkey);
+ return result_code;
+ }
+ DELETE_IF_NOT_NULL(vtnkey);
+
result_code = CopyVtnControllerCkv(ikey, okey);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("CopyVtnControllerCkv failed %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
} else if (UNC_KT_VTN_POLICINGMAP == ikey->get_key_type()) {
}
}
DbSubOp dbop = {kOpReadMultiple, kOpMatchNone,
- kOpInOutCtrlr | kOpInOutDomain};
+ kOpInOutCtrlr | kOpInOutDomain};
result_code = ReadConfigDB(okey, req->datatype, UNC_OP_READ, dbop, dmi,
- CTRLRTBL);
+ CTRLRTBL);
if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ DELETE_IF_NOT_NULL(okey);
return UPLL_RC_ERR_NOT_ALLOWED_AT_THIS_TIME;
} else if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
- delete okey;
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
+ DELETE_IF_NOT_NULL(okey);
}
return UPLL_RC_SUCCESS;
}
result_code = UPLL_RC_SUCCESS;
}
delete okey;
+
+ result_code = SetRenameFlag(ikey, dmi, req);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG(" SetRenameFlag failed %d", result_code);
+ return result_code;
+ }
return result_code;
}
reinterpret_cast<char*>(val_pm2->policer_name)))
val_pm1->valid[UPLL_IDX_POLICERNAME_PM] = UNC_VF_INVALID;
}
+ if ((UNC_VF_VALID == (uint8_t)val_pm1->valid[UPLL_IDX_POLICERNAME_PM]) ||
+ (UNC_VF_VALID_NO_VALUE == (uint8_t)val_pm1->valid[UPLL_IDX_POLICERNAME_PM]))
+ invalid_attr = false;
return invalid_attr;
}
ConfigKeyVal *&ckv_running) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
- val_policingmap_t *val;
+ val_vtnpolicingmap_ctrl *val;
val =
- (ckv_running != NULL) ? reinterpret_cast<val_policingmap_t *>(GetVal(
+ (ckv_running != NULL) ? reinterpret_cast<val_vtnpolicingmap_ctrl *>(GetVal(
ckv_running)) :
NULL;
if (NULL == val) {
}
if (uuc::kUpllUcpCreate == phase )
val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
for ( unsigned int loop = 0;
loop < sizeof(val->valid)/sizeof(uint8_t); ++loop ) {
- if (cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop])
- val->cs_attr[loop] = cs_status;
- else
- val->cs_attr[loop] = cs_status;
+ if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
+ cs_status == UNC_CS_APPLIED)
+ val->cs_attr[loop] = cs_status;
}
return result_code;
}
IpctSt::kIpcStKeyVtn, vtn_key, tmp1);
if (NULL == okey) {
free(vtn_key);
+ DELETE_IF_NOT_NULL(tmp1);
UPLL_LOG_DEBUG("DupConfigKeyVal okey Allocation Failed");
return UPLL_RC_ERR_GENERIC;
}
if (okey) {
if (okey->get_key_type() != UNC_KT_VTN_POLICINGMAP)
return UPLL_RC_ERR_GENERIC;
+ }
+
+ if ((okey) && (okey->get_key())) {
vtn_key = reinterpret_cast<key_vtn_t *>(okey->get_key());
} else {
vtn_key = reinterpret_cast<key_vtn_t *>
return UPLL_RC_ERR_GENERIC;
}
+ if ((okey) && !(okey->get_key())) {
+ UPLL_LOG_DEBUG("okey not null and flow list name updated");
+ okey->SetKey(IpctSt::kIpcStKeyVtn, vtn_key);
+ }
+
if (!okey) {
okey = new ConfigKeyVal(UNC_KT_VTN_POLICINGMAP, IpctSt::kIpcStKeyVtn,
vtn_key, NULL);
key_vtn_policingmap_controller_t *key_vtn_policingmap_controller = NULL;
if (UNC_KT_VTN_POLICINGMAP == key->get_key_type()) {
+ if ((req->datatype == UPLL_DT_IMPORT) && (req->operation == UNC_OP_READ ||
+ req->operation == UNC_OP_READ_SIBLING ||
+ req->operation == UNC_OP_READ_SIBLING_BEGIN ||
+ req->operation == UNC_OP_READ_NEXT ||
+ req->operation == UNC_OP_READ_BULK ||
+ req->operation == UNC_OP_READ_SIBLING_COUNT)) {
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+
if (req->option1 != UNC_OPT1_NORMAL) {
UPLL_LOG_DEBUG(" Invalid option1(%d)", req->option1);
return UPLL_RC_ERR_INVALID_OPTION1;
}
if (key->get_st_num() != IpctSt::kIpcStKeyVtn) {
- UPLL_LOG_DEBUG(
- " Invalid structure received expected struct -"
- "kIpcStKeyVtn, received struct - %s ",
- reinterpret_cast<const char *> (IpctSt::GetIpcStdef(
- key->get_st_num())));
+ UPLL_LOG_DEBUG("Invalid key structure received. struct num - %d",
+ key->get_st_num());
return UPLL_RC_ERR_BAD_REQUEST;
}
key_vtn = reinterpret_cast<key_vtn_t *>(key->get_key());
} else if (UNC_KT_VTN_POLICINGMAP_CONTROLLER == key->get_key_type()) {
+ if ((req->datatype == UPLL_DT_IMPORT) && (req->operation == UNC_OP_READ ||
+ req->operation == UNC_OP_READ_SIBLING ||
+ req->operation == UNC_OP_READ_SIBLING_BEGIN ||
+ req->operation == UNC_OP_READ_NEXT ||
+ req->operation == UNC_OP_READ_BULK ||
+ req->operation == UNC_OP_READ_SIBLING_COUNT)) {
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+
+ if (req->datatype != UPLL_DT_STATE) {
+ UPLL_LOG_DEBUG(" Invalid Datatype(%d)", req->datatype);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
if ((req->option1 != UNC_OPT1_NORMAL) &&
(req->option1 != UNC_OPT1_DETAIL)) {
key_vtn_policingmap_controller =
reinterpret_cast<key_vtn_policingmap_controller_t *>(key->get_key());
- key_vtn = &(key_vtn_policingmap_controller->vtn_key);
+ key_vtn = reinterpret_cast< key_vtn_t*>(&(key_vtn_policingmap_controller->vtn_key));
+
+ if ((req->operation != UNC_OP_READ_SIBLING_COUNT) &&
+ (req->operation != UNC_OP_READ_SIBLING_BEGIN)) {
+ rt_code = ValidateKey(reinterpret_cast<char*>(
+ key_vtn_policingmap_controller->controller_name),
+ kMinLenCtrlrId, kMaxLenCtrlrId);
+
+ if (rt_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Controllername syntax validation failed: Err code-%d",
+ rt_code);
+ return rt_code;
+ }
+ if (!ValidateDefaultStr(key_vtn_policingmap_controller->domain_id,
+ kMinLenDomainId, kMaxLenDomainId)) {
+ UPLL_LOG_DEBUG("DomainId syntax validation failed:");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ } else {
+ memset(key_vtn_policingmap_controller->controller_name, 0, kMaxLenCtrlrId);
+ memset(key_vtn_policingmap_controller->domain_id, 0, kMaxLenDomainId);
+ }
+
} else {
UPLL_LOG_DEBUG(" Invalid keytype(%d)", key->get_key_type());
- return UPLL_RC_ERR_GENERIC;
+ return UPLL_RC_ERR_BAD_REQUEST;
}
if (NULL == key_vtn) {
rt_code = mgrvtn->ValidateVtnKey(key_vtn);
if (UPLL_RC_SUCCESS != rt_code) {
+ UPLL_LOG_DEBUG(" Vtn name syntax validation failed Err Code - %d",
+ rt_code);
return rt_code;
}
- /** read datatype, operation, options from IpcReqRespHeader */
if (UNC_KT_VTN_POLICINGMAP == key->get_key_type()) {
UPLL_LOG_TRACE(" key struct validation is success");
- val_policingmap_t *val_policingmap = NULL;
- if (key->get_cfg_val() && (key->get_cfg_val()->get_st_num() ==
- IpctSt::kIpcStValPolicingmap)) {
- val_policingmap =
- reinterpret_cast<val_policingmap_t *>(key->get_cfg_val()->get_val());
- }
- return ValidatePolicingMapValue(val_policingmap, req);
+ return ValidatePolicingMapValue(key, req->operation);
}
/** Validate UNC_KT_VTN_POLICINGMAP_CONTROLLER key, val structure */
- /** validate syntax and semantic check(controller name should exists
- in controller table otherwise return semantic error*/
- /* TODO ValidateControllerName() verify inclusion
- rt_code = ValidateControllerName(
- reinterpret_cast<char*>(key_vtn_policingmap_controller->controller_name));
-
- if (rt_code != UPLL_RC_SUCCESS) {
- return rt_code;
- }
- */
- val_policingmap_controller_t *val_policingmap_controller = NULL;
-
- if (key->get_cfg_val() && (key->get_cfg_val()->get_st_num() ==
- IpctSt::kIpcStValPolicingmapController)) {
- val_policingmap_controller =
- reinterpret_cast<val_policingmap_controller_t *>
- (key->get_cfg_val()->get_val());
- }
- UPLL_LOG_TRACE("KT_VTN_POLICINGMAP_CONTROLLER key struct validation"
- "is success");
- /** Read operation, datatype, option1 , option2 from req */
- uint32_t dt_type = req->datatype;
- uint32_t operation = req->operation;
- uint32_t option1 = req->option1;
- uint32_t option2 = req->option2;
-
- if (READ_SUPPORTED_OPERATION) {
- if (dt_type == UPLL_DT_STATE) {
- /** check option1 and option2 */
- if ((option1 != UNC_OPT1_NORMAL)
- && (option1 == UNC_OPT1_DETAIL
- && operation == UNC_OP_READ_SIBLING_COUNT)) {
- UPLL_LOG_DEBUG(" Error: option1 is not NORMAL/DETAIL");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- if (option2 != UNC_OPT2_NONE) {
- UPLL_LOG_DEBUG(" Error: option2 is not NONE");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- if (val_policingmap_controller) {
- return ValidateVtnPolicingMapControllerValue(
- val_policingmap_controller, operation);
-
- } else if (operation == UNC_OP_READ_SIBLING_COUNT) {
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Mandatory value structure is NULL");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else {
- UPLL_LOG_DEBUG("Error Unsupported datatype (%d)", dt_type);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- }
- UPLL_LOG_DEBUG("Error Unsupported operation (%d)", operation);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ return ValidateVtnPolicingMapControllerValue(
+ key, req);
}
upll_rc_t VtnPolicingMapMoMgr::ValidatePolicingMapValue(
- val_policingmap_t *val_policingmap, IpcReqRespHeader *req) {
-
+ ConfigKeyVal *key, uint32_t operation) {
UPLL_FUNC_TRACE;
- uint32_t dt_type = req->datatype;
- uint32_t operation = req->operation;
- uint32_t option1 = req->option1;
- uint32_t option2 = req->option2;
+ val_policingmap_t *val_policingmap = NULL;
- if ((operation == UNC_OP_CREATE) || (operation == UNC_OP_UPDATE)) {
- if (dt_type == UPLL_DT_CANDIDATE) {
- if (val_policingmap) {
- return ValidatePolicingMapValue(val_policingmap, operation);
- } else {
- UPLL_LOG_TRACE("Error value struct is mandatory for CREATE/UPDATE");
- return UPLL_RC_ERR_BAD_REQUEST;
- }
+ if (!key->get_cfg_val()) {
+ if ((operation == UNC_OP_CREATE) || (operation == UNC_OP_UPDATE)) {
+ UPLL_LOG_DEBUG(" val structure is mandatory");
+ return UPLL_RC_ERR_BAD_REQUEST;
} else {
- UPLL_LOG_DEBUG("Unsupported datatype for CREATE/UPDATE");
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
- }
- } else if (READ_SUPPORTED_OPERATION) {
- if (READ_SUPPORTED_DATATYPE) {
- if ((option1 != UNC_OPT1_NORMAL)
- && ((option1 == UNC_OPT1_DETAIL)
- && (operation == UNC_OP_READ_SIBLING_COUNT))) {
- UPLL_LOG_DEBUG(" Error: option1 is not NORMAL/DETAIL");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- if (option2 != UNC_OPT2_NONE) {
- UPLL_LOG_DEBUG(" Error: option2 is not NONE");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- if (val_policingmap) {
- return ValidatePolicingMapValue(val_policingmap, operation);
- }
- /** value struct is optional*/
+ UPLL_LOG_TRACE("val stucture is optional");
return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Error Unsupported datatype (%d)", dt_type);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
- } else if (OPEARTION_WITH_VAL_STRUCT_NONE) {
- /** Value struct is NONE for this operations */
- UPLL_LOG_TRACE("Operation type is %d", operation);
- return UPLL_RC_SUCCESS;
+ }
+
+ if (key->get_cfg_val()->get_st_num() != IpctSt::kIpcStValPolicingmap) {
+ UPLL_LOG_DEBUG("Invalid val structure received. struct num - %d",
+ (key->get_cfg_val())->get_st_num());
+ return UPLL_RC_ERR_BAD_REQUEST;
}
- UPLL_LOG_DEBUG("Error Unsupported operation (%d)", operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
-}
+ val_policingmap =
+ reinterpret_cast<val_policingmap_t *>(key->get_cfg_val()->get_val());
-upll_rc_t VtnPolicingMapMoMgr::ValidatePolicingMapValue(
- val_policingmap_t *val_policingmap, uint32_t operation) {
+ if (val_policingmap == NULL) {
+ UPLL_LOG_DEBUG("KT_VTN_POLICINGMAP val structure is null");
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
- UPLL_FUNC_TRACE;
- if (val_policingmap != NULL) {
- if (val_policingmap->valid[UPLL_IDX_POLICERNAME_PM] == UNC_VF_INVALID) {
- UPLL_LOG_DEBUG("policer name flag is invalid");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- /** Validate policier name*/
- if (val_policingmap->valid[UPLL_IDX_POLICERNAME_PM] == UNC_VF_VALID) {
- /* validate name range is between 1 and 32 */
- if (ValidateKey(reinterpret_cast<char *>(val_policingmap->policer_name),
- kMinLenPolicingProfileName, kMaxLenPolicingProfileName + 1)
+ if (val_policingmap->valid[UPLL_IDX_POLICERNAME_PM] == UNC_VF_INVALID) {
+ UPLL_LOG_DEBUG("policer name flag is invalid");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+
+ /** Validate policier name*/
+ if (val_policingmap->valid[UPLL_IDX_POLICERNAME_PM] == UNC_VF_VALID) {
+ /* validate name range is between 1 and 32 */
+ if (ValidateKey(reinterpret_cast<char *>(val_policingmap->policer_name),
+ kMinLenPolicingProfileName, kMaxLenPolicingProfileName + 1)
!= UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG(" Syntax range check failed for name ");
return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else if (val_policingmap->valid[UPLL_IDX_POLICERNAME_PM] ==
+ }
+ } else if (val_policingmap->valid[UPLL_IDX_POLICERNAME_PM] ==
UNC_VF_VALID_NO_VALUE &&
(operation == UNC_OP_UPDATE || operation == UNC_OP_CREATE)) {
- UPLL_LOG_TRACE("Reset Policingname");
- memset(val_policingmap->policer_name, 0,
- sizeof(val_policingmap->policer_name));
- }
+ UPLL_LOG_TRACE("Reset Policingname");
+ memset(val_policingmap->policer_name, 0,
+ sizeof(val_policingmap->policer_name));
}
return UPLL_RC_SUCCESS;
}
upll_rc_t VtnPolicingMapMoMgr::ValidateVtnPolicingMapControllerValue(
- val_policingmap_controller_t *val_policingmap_controller,
- uint32_t operation) {
-
+ ConfigKeyVal *key, IpcReqRespHeader *req) {
UPLL_FUNC_TRACE;
- if (val_policingmap_controller != NULL) {
- /** Validate policier name*/
+ if (!key->get_cfg_val()) {
+ UPLL_LOG_TRACE("val stucture is optional");
+ return UPLL_RC_SUCCESS;
+ }
+
+ if (key->get_cfg_val()->get_st_num() !=
+ IpctSt::kIpcStValPolicingmapController) {
+ UPLL_LOG_DEBUG("Invalid val structure received. struct num - %d",
+ (key->get_cfg_val())->get_st_num());
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+
+ val_policingmap_controller_t *val_policingmap_controller =
+ reinterpret_cast<val_policingmap_controller_t *>
+ (key->get_cfg_val()->get_val());
+
+ if (NULL == val_policingmap_controller) {
+ UPLL_LOG_TRACE(" Value structure is NULL");
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+
+ if (req->datatype != UPLL_DT_STATE) {
+ UPLL_LOG_DEBUG("Error Unsupported datatype (%d)", req->datatype);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+
+ if (req->option2 != UNC_OPT2_NONE) {
+ UPLL_LOG_DEBUG(" Error: option2 is not NONE");
+ return UPLL_RC_ERR_INVALID_OPTION2;
+ }
+
+ if ((req->option1 != UNC_OPT1_NORMAL) &&
+ ((req->option1 == UNC_OPT1_DETAIL)
+ && (req->operation == UNC_OP_READ_SIBLING_COUNT))) {
+ UPLL_LOG_DEBUG(" Error: option1 is not NORMAL/DETAIL");
+ return UPLL_RC_ERR_INVALID_OPTION1;
+ }
+
+ if ((req->operation == UNC_OP_READ) ||
+ (req->operation == UNC_OP_READ_SIBLING) ||
+ (req->operation == UNC_OP_READ_SIBLING_COUNT) ||
+ (req->operation == UNC_OP_READ_SIBLING_BEGIN)) {
+
+ /** Validate sequence number*/
if (val_policingmap_controller->valid[UPLL_IDX_SEQ_NUM_PMC]
== UNC_VF_VALID) {
/* validate name range is between 1 and 32 */
UPLL_LOG_DEBUG(" Syntax range check failed for seq_num ");
return UPLL_RC_ERR_CFG_SYNTAX;
}
- } else if ((operation == UNC_OP_UPDATE)
- && (val_policingmap_controller->valid[UPLL_IDX_SEQ_NUM_PMC]
- == UNC_VF_VALID_NO_VALUE)) {
- UPLL_LOG_TRACE("Reset seq_num");
- val_policingmap_controller->sequence_num = 0;
}
}
return UPLL_RC_SUCCESS;
if (!ctrlr_name)
ctrlr_name = static_cast<char *>(ikey->get_user_data());
+ if (NULL == ctrlr_name) {
+ UPLL_LOG_DEBUG("ctrlr_name is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
bool result_code = false;
- uint32_t instance_count = 0;
+ uint32_t max_instance_count = 0;
const uint8_t *attrs = NULL;
uint32_t max_attrs = 0;
- /**VTN_POLICINGMAP, VBR_POLICINGMAP, VBRIF_POLICINGMAP, shares this code
- * to validate val_policingmap value structure capability */
+ UPLL_LOG_TRACE("ctrlr_name(%s), datatype : (%d)",
+ ctrlr_name, req->datatype);
- uint32_t dt_type = req->datatype;
- uint32_t operation = req->operation;
- uint32_t option1 = req->option1;
- uint32_t option2 = req->option2;
-
- UPLL_LOG_TRACE("dt_type : (%d)"
- "operation : (%d)"
- "option1 : (%d)"
- "option2 : (%d)",
- dt_type, operation, option1, option2);
-
- switch (operation) {
+ switch (req->operation) {
case UNC_OP_CREATE:
result_code = GetCreateCapability(ctrlr_name, ikey->get_key_type(),
- &instance_count, &max_attrs, &attrs);
+ &max_instance_count, &max_attrs, &attrs);
+
+ UPLL_LOG_INFO("cur_instance_count = %d, max_count= %d", cur_instance_count,
+ max_instance_count);
+ if (result_code && (max_instance_count != 0) &&
+ (cur_instance_count >= max_instance_count)) {
+ UPLL_LOG_DEBUG("Instance count %d exceeds %d", cur_instance_count,
+ max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
break;
case UNC_OP_UPDATE:
result_code = GetUpdateCapability(ctrlr_name, ikey->get_key_type(),
&max_attrs, &attrs);
break;
default:
- result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
+ if (req->datatype == UPLL_DT_STATE)
+ result_code = GetStateCapability(ctrlr_name, ikey->get_key_type(),
+ &max_attrs, &attrs);
+ else
+ result_code = GetReadCapability(ctrlr_name, ikey->get_key_type(),
&max_attrs, &attrs);
break;
}
if (!result_code) {
UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s)"
" for operation(%d)",
- ikey->get_key_type(), ctrlr_name, operation);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ ikey->get_key_type(), ctrlr_name, req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
- if (UNC_KT_VTN_POLICINGMAP_CONTROLLER == ikey->get_key_type()) {
- /** capability check for UNC_KT_VTN_POLICINGMAP_CONTROLLER */
- return ValidateVtnPolicingMapControllerCapability(req, ikey,
- ctrlr_name, max_attrs, attrs);
- }
-
- val_policingmap_t *val_policingmap = NULL;
-
- if (ikey->get_cfg_val() && (ikey->get_cfg_val()->get_st_num() ==
- IpctSt::kIpcStValPolicingmap)) {
- val_policingmap =
- reinterpret_cast<val_policingmap_t *>(ikey->get_cfg_val()->get_val());
- }
-
- if ((operation == UNC_OP_CREATE) || (operation == UNC_OP_UPDATE)) {
- if (dt_type == UPLL_DT_CANDIDATE) {
- if (val_policingmap) {
- if (max_attrs > 0) {
- return ValVtnPolicingMapAttributeSupportCheck(ikey,
+ if (max_attrs > 0) {
+ return ValVtnPolicingMapAttributeSupportCheck(ikey,
attrs);
- } else {
- UPLL_LOG_DEBUG("Attribute list is empty for operation %d", operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else {
- UPLL_LOG_TRACE("Error value struct is mandatory for CREATE/UPDATE");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else {
- UPLL_LOG_DEBUG("Unsupported datatype for CREATE/UPDATE");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else if (READ_SUPPORTED_OPERATION) {
- if (READ_SUPPORTED_DATATYPE) {
- if (option1 != UNC_OPT1_NORMAL) {
- UPLL_LOG_DEBUG(" Error: option1 is not NORMAL");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- if (option2 != UNC_OPT2_NONE) {
- UPLL_LOG_DEBUG(" Error: option2 is not NONE");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- if (val_policingmap) {
- if (max_attrs > 0) {
- return ValVtnPolicingMapAttributeSupportCheck(ikey,
- attrs);
- } else {
- UPLL_LOG_DEBUG("Attribute list is empty for operation %d", operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- }
- /** value struct is optional */
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Error Unsupported datatype (%d)", dt_type);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else if (OPEARTION_WITH_VAL_STRUCT_NONE) {
- /** Value struct is NONE for this operations */
- UPLL_LOG_TRACE("Skip attribute validation, Operation type is %d",
- operation);
- return UPLL_RC_SUCCESS;
- }
- UPLL_LOG_DEBUG("Error Unsupported operation(%d)", operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ } else {
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d", req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
}
upll_rc_t VtnPolicingMapMoMgr::ValVtnPolicingMapAttributeSupportCheck(
UPLL_FUNC_TRACE;
if (UNC_KT_VTN_POLICINGMAP_CONTROLLER == ikey->get_key_type()) {
- val_policingmap_controller_t *val_policingmap_controller = NULL;
- if (ikey->get_cfg_val() && (ikey->get_cfg_val()->get_st_num() ==
- IpctSt::kIpcStValPolicingmapController)) {
- val_policingmap_controller =
- reinterpret_cast<val_policingmap_controller_t *>
- (ikey->get_cfg_val()->get_val());
- }
- if (val_policingmap_controller != NULL) {
+ val_policingmap_controller_t *val_policingmap_controller =
+ reinterpret_cast<val_policingmap_controller_t *>(GetVal(ikey));
+
+ if (val_policingmap_controller) {
if ((val_policingmap_controller->valid[UPLL_IDX_SEQ_NUM_PMC]
== UNC_VF_VALID)
|| (val_policingmap_controller->valid[UPLL_IDX_SEQ_NUM_PMC]
== UNC_VF_VALID_NO_VALUE)) {
if (attrs[unc::capa::vtn_policingmap_controller::kCapSeqNum] == 0) {
val_policingmap_controller->valid[UPLL_IDX_SEQ_NUM_PMC] =
- UNC_VF_NOT_SOPPORTED;
+ UNC_VF_NOT_SUPPORTED;
UPLL_LOG_DEBUG("SeqNum attr is not supported by ctrlr");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
}
}
- } else {
- UPLL_LOG_DEBUG("Error value struct is NULL");
- return UPLL_RC_ERR_GENERIC;
}
return UPLL_RC_SUCCESS;
}
- /**VTN_POLICINGMAP, VBR_POLICINGMAP, VBRIF_POLICINGMAP, shares this code
- * to validate val_policingmap value structure capability */
- if (GetVal(ikey)) {
- val_policingmap_t *val_policingmap =
- reinterpret_cast<val_policingmap_t *>(ikey->get_cfg_val()->get_val());
- if (val_policingmap != NULL) {
- if ((val_policingmap->valid[UPLL_IDX_POLICERNAME_PM] == UNC_VF_VALID)
- || (val_policingmap->valid[UPLL_IDX_POLICERNAME_PM]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vtn_policingmap::kCapPolicername] == 0) {
- val_policingmap->valid[UPLL_IDX_POLICERNAME_PM] =
- UNC_VF_NOT_SOPPORTED;
- UPLL_LOG_DEBUG("Policername attr is not supported by ctrlr");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- }
- } else {
- UPLL_LOG_DEBUG("Error value struct is NULL");
- return UPLL_RC_ERR_GENERIC;
- }
- } else {
- UPLL_LOG_DEBUG("val structure NULL");
- return UPLL_RC_ERR_GENERIC;
- }
- return UPLL_RC_SUCCESS;
-}
-
-upll_rc_t VtnPolicingMapMoMgr::ValidateVtnPolicingMapControllerCapability(
- IpcReqRespHeader *req, ConfigKeyVal *ikey, const char *ctrlr_name,
- uint32_t max_attrs, const uint8_t *attrs) {
- UPLL_FUNC_TRACE;
+ val_policingmap_t *val_policingmap =
+ reinterpret_cast<val_policingmap_t *>(GetVal(ikey));
- val_policingmap_controller_t *val_policingmap_controller = NULL;
+ if (val_policingmap) {
+ if ((val_policingmap->valid[UPLL_IDX_POLICERNAME_PM] == UNC_VF_VALID)
+ || (val_policingmap->valid[UPLL_IDX_POLICERNAME_PM]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtn_policingmap::kCapPolicername] == 0) {
+ val_policingmap->valid[UPLL_IDX_POLICERNAME_PM] =
+ UNC_VF_NOT_SUPPORTED;
- if (ikey->get_cfg_val() && (ikey->get_cfg_val()->get_st_num() ==
- IpctSt::kIpcStValPolicingmapController)) {
- val_policingmap_controller =
- reinterpret_cast<val_policingmap_controller_t *>
- (ikey->get_cfg_val()->get_val());
- }
-
- uint32_t dt_type = req->datatype;
- uint32_t operation = req->operation;
- uint32_t option1 = req->option1;
- uint32_t option2 = req->option2;
-
- if (READ_SUPPORTED_OPERATION) {
- if (dt_type == UPLL_DT_STATE) {
- /** check option1 and option2 */
- if ((option1 == UNC_OPT1_NORMAL)
- || (option1 == UNC_OPT1_DETAIL
- && operation != UNC_OP_READ_SIBLING_COUNT)) {
- if (option2 == UNC_OPT2_NONE) {
- if (val_policingmap_controller) {
- if (max_attrs > 0) {
- return ValVtnPolicingMapAttributeSupportCheck(
- ikey, attrs);
- } else {
- UPLL_LOG_DEBUG("Attribute list is empty for operation %d",
- operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else if (operation == UNC_OP_READ_SIBLING_COUNT) {
- return UPLL_RC_SUCCESS;
- } else {
- UPLL_LOG_DEBUG("Mandatory value structure is NULL");
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else {
- UPLL_LOG_DEBUG(" Error: option2 is not NONE");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- } else {
- UPLL_LOG_DEBUG(" Error: option1 is not NORMAL/DETAIL");
- return UPLL_RC_ERR_INVALID_OPTION1;
+ UPLL_LOG_DEBUG("Policername attr is not supported by ctrlr");
}
- } else {
- UPLL_LOG_DEBUG("Error Unsupported datatype(%d)", dt_type);
- return UPLL_RC_ERR_CFG_SYNTAX;
}
}
- UPLL_LOG_DEBUG("Error Unsupported operation (%d)", operation);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ return UPLL_RC_SUCCESS;
}
upll_rc_t VtnPolicingMapMoMgr::GetParentConfigKey(ConfigKeyVal *&okey,
UPLL_LOG_DEBUG(" Input Key is NULL");
return UPLL_RC_ERR_GENERIC;
}
-
+ DELETE_IF_NOT_NULL(okey);
unc_key_type_t ikey_type = ikey->get_key_type();
if (ikey_type != UNC_KT_VTN_POLICINGMAP) {
UPLL_LOG_DEBUG(" Invalid key type received. Key type - %d", ikey_type);
(ConfigKeyVal::Malloc(sizeof(val_policingmap_t)));
memcpy(out_val_policingmap, val_policingmap, sizeof(val_policingmap_t));
ikey->AppendCfgVal(IpctSt::kIpcStValPolicingmap, out_val_policingmap);
- delete vtn_dup_key;
+ // delete vtn_dup_key;
#if 0
val_policingmap_controller_t* val_policingmap_controller =
reinterpret_cast<val_policingmap_controller_t *>(GetVal(ikey));
if (result_code != UPLL_RC_SUCCESS) {
return result_code;
}
+ val_policingmap_controller_st *val_ppe_st =
+ reinterpret_cast<val_policingmap_controller_st *>
+ (ConfigKeyVal::Malloc(sizeof(val_policingmap_controller_st)));
+ memcpy(val_ppe_st, val_entry_st,
+ sizeof(val_policingmap_controller_st));
ikey->AppendCfgVal(IpctSt::kIpcStValPolicingmapControllerSt,
- val_entry_st);
+ val_ppe_st);
// val_policingmap_controller->sequence_num = val_entry_st->sequence_num;
continue;
}
+ if (IpctSt::kIpcStValPolicingmapSwitchSt != temp_cfg_val->get_st_num()) {
+ UPLL_LOG_DEBUG("No PolicingmapSwitchSt entries returned by driver");
+ continue;
+ }
+
while (IpctSt::kIpcStValPolicingmapSwitchSt ==
temp_cfg_val->get_st_num()) {
- UPLL_LOG_DEBUG("kIpcStValPolicingmapSwitchSt");
+ val_policingmap_switch_st_t *val_switch_st =
+ reinterpret_cast<val_policingmap_switch_st_t*>
+ (ConfigKeyVal::Malloc(sizeof(val_policingmap_switch_st_t)));
+ val_policingmap_switch_st_t *drv_val_switch_st =
+ reinterpret_cast<val_policingmap_switch_st_t*>
+ (temp_cfg_val->get_val());
+ memcpy(val_switch_st, drv_val_switch_st,
+ sizeof(val_policingmap_switch_st_t));
+ if(drv_val_switch_st->valid[UPLL_IDX_IF_NAME_PMSS] == UNC_VF_VALID) {
+ ConfigKeyVal *vbrif_key_val = NULL;
+ unc::upll::kt_momgr::VbrIfMoMgr *vbrifmgr =
+ reinterpret_cast<unc::upll::kt_momgr::VbrIfMoMgr *>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VBR_IF)));
+ if (NULL == vbrifmgr) {
+ free(val_switch_st);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = vbrifmgr->GetVbrIfFromVExternal(
+ vtn_pm_ctrlr_key->vtn_key.vtn_name,
+ drv_val_switch_st->if_name,
+ vbrif_key_val,
+ dmi);
+ if ((result_code != UPLL_RC_SUCCESS) &&
+ (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG("Get vBridge info failed err code (%d)",
+ result_code);
+ if (val_switch_st) free(val_switch_st);
+ DELETE_IF_NOT_NULL(vbrif_key_val);
+ return result_code;
+ }
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ key_vbr_if_t *key_vbrif = reinterpret_cast<key_vbr_if_t*>
+ (vbrif_key_val->get_key());
+ val_switch_st->valid[UPLL_IDX_VBR_NAME_PMSS] = UNC_VF_VALID;
+ uuu::upll_strncpy(val_switch_st->vbr_name,
+ key_vbrif->vbr_key.vbridge_name,
+ (kMaxLenVnodeName + 1));
+
+ val_switch_st->valid[UPLL_IDX_IF_NAME_PMSS] = UNC_VF_VALID;
+ uuu::upll_strncpy(val_switch_st->if_name,
+ key_vbrif->if_name,
+ (kMaxLenInterfaceName + 1));
+ }
+ DELETE_IF_NOT_NULL(vbrif_key_val);
+ }
ikey->AppendCfgVal(IpctSt::kIpcStValPolicingmapSwitchSt,
- temp_cfg_val->get_val());
+ val_switch_st);
temp_cfg_val = temp_cfg_val->get_next_cfg_val();
if (temp_cfg_val == NULL)
break;
result_code = CopyVtnControllerCkv(ikey, main_ckv);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("CopyVtnControllerCkv failed %d", result_code);
+ DELETE_IF_NOT_NULL(main_ckv);
return result_code;
}
result_code = GetChildConfigKey(ctrlr_ckv, main_ckv);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
}
- DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutCs };
- DbSubOp dbop1 = { kOpReadSingle, kOpMatchCtrlr, kOpInOutCs };
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone };
+ DbSubOp dbop1 = { kOpReadSingle, kOpMatchCtrlr, kOpInOutNone };
- result_code = ReadConfigDB(main_ckv, dt_type, op, dbop, dmi,
+ result_code = ReadConfigDB(main_ckv, dt_type, UNC_OP_READ, dbop, dmi,
MAINTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("ReadConfigDB failed in maintbl %d", result_code);
delete main_ckv;
return result_code;
}
- result_code = ReadConfigDB(ctrlr_ckv, dt_type, op, dbop1, dmi,
+ result_code = ReadConfigDB(ctrlr_ckv, dt_type, UNC_OP_READ, dbop1, dmi,
CTRLRTBL);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("ReadConfigDB failed in ctrlrtbl %d", result_code);
+ delete ctrlr_ckv;
+ delete main_ckv;
return result_code;
}
- val_policingmap_t *val_main = reinterpret_cast<val_policingmap_t *>
+ val_policingmap_t *tmp_val_main = reinterpret_cast<val_policingmap_t *>
(GetVal(main_ckv));
- val_policingmap_t *val_ctrlr = reinterpret_cast<val_policingmap_t *>
+ val_policingmap_t *val_main = reinterpret_cast<val_policingmap_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_policingmap_t)));
+ memcpy(val_main, tmp_val_main, sizeof(val_policingmap_t));
+ val_vtnpolicingmap_ctrl *val_ctrlr = reinterpret_cast<val_vtnpolicingmap_ctrl *>
(GetVal(ctrlr_ckv));
val_main->valid[UPLL_IDX_POLICERNAME_PM] =
val_ctrlr->valid[UPLL_IDX_POLICERNAME_PM];
GET_USER_DATA_CTRLR(ctrlr_ckv, ctrlr_id);
ConfigKeyVal *ppe_ckv = NULL, *temp_ppe_ckv = NULL;
if (UNC_VF_INVALID == in_val_vtn_ctrlr_pm->valid[UPLL_IDX_SEQ_NUM_PMC]) {
- in_val_vtn_ctrlr_pm->sequence_num = 0;
+ in_val_vtn_ctrlr_pm->sequence_num = 0;
}
UPLL_LOG_DEBUG("Sequence number - %d", in_val_vtn_ctrlr_pm->sequence_num);
PolicingProfileEntryMoMgr *ppe_mgr =
reinterpret_cast<PolicingProfileEntryMoMgr*>
(const_cast<MoManager *>(GetMoManager
(UNC_KT_POLICING_PROFILE_ENTRY)));
- result_code = ppe_mgr->ReadPolicingProfileEntry(reinterpret_cast
- <const char *>(val_main->policer_name), in_val_vtn_ctrlr_pm->sequence_num,
- reinterpret_cast<const char *>(ctrlr_id), dmi, dt_type, ppe_ckv);
+ result_code = ppe_mgr->ReadPolicingProfileEntry(
+ reinterpret_cast<const char *>(val_main->policer_name),
+ in_val_vtn_ctrlr_pm->sequence_num,
+ reinterpret_cast<const char *>(ctrlr_id),
+ dmi, dt_type, ppe_ckv);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("ReadPolicingProfileEntry failed %d", result_code);
+ FREE_IF_NOT_NULL(val_main);
return result_code;
}
<key_policingprofile_entry_t*>(temp_ppe_ckv->get_key());
val_policingprofile_entry_t *val_ppe = reinterpret_cast
<val_policingprofile_entry_t *>(GetVal(temp_ppe_ckv));
- val_policingmap_controller_t *out_val_vtn_ctrlr_pm = reinterpret_cast
- <val_policingmap_controller_t *>
- (ConfigKeyVal::Malloc(sizeof(val_policingmap_controller_t)));
+ val_policingmap_controller_t *out_val_vtn_ctrlr_pm = reinterpret_cast
+ <val_policingmap_controller_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_policingmap_controller_t)));
out_val_vtn_ctrlr_pm->valid[UPLL_IDX_SEQ_NUM_PMC] = UNC_VF_VALID;
out_val_vtn_ctrlr_pm->sequence_num = key_ppe->sequence_num;
ikey->AppendCfgVal(IpctSt::kIpcStValPolicingmapController,
- out_val_vtn_ctrlr_pm);
+ out_val_vtn_ctrlr_pm);
val_policingprofile_entry_t *in_val_ppe =
reinterpret_cast<val_policingprofile_entry_t *>
(ConfigKeyVal::Malloc(sizeof(val_policingprofile_entry_t)));
ikey->AppendCfgVal(IpctSt::kIpcStValPolicingprofileEntry, in_val_ppe);
temp_ppe_ckv = temp_ppe_ckv->get_next_cfg_key_val();
}
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ DELETE_IF_NOT_NULL(main_ckv);
if (ppe_ckv) {
delete ppe_ckv;
ppe_ckv = NULL;
sizeof(val_policingmap_controller_t));
ConfigKeyVal *okey = NULL;
result_code = GetChildVtnCtrlrKey(okey, ikey);
- if (UPLL_RC_SUCCESS != result_code) {
+ if (!okey || UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("GetChildVtnCtrlrKey failed ");
+ DELETE_IF_NOT_NULL(okey);
+ FREE_IF_NOT_NULL(out_val_vtn_ctrlr_pm);
return result_code;
}
okey->AppendCfgVal(IpctSt::kIpcStValPolicingmap,
reinterpret_cast<const char *>(ctrlr_id), dmi, dt_type, ppe_ckv);
if (UPLL_RC_SUCCESS != result_code) {
UPLL_LOG_DEBUG("ReadPolicingProfileEntry failed %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
return result_code;
}
temp_ppe_ckv = ppe_ckv;
ConfigVal *tmp1 = NULL;
val_policingmap_controller_t *val_pm_ctrlr = reinterpret_cast
<val_policingmap_controller_t *>(GetVal(ikey));
+ ConfigKeyVal *temp_ckv = NULL ,*capa_key = NULL;
+ result_code = GetChildVtnCtrlrKey(temp_ckv, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildVtnCtrlrKey failed %d", result_code);
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
+ return result_code;
+ }
val_policingmap_controller_t *out_val_pm_ctrlr =
reinterpret_cast<val_policingmap_controller_t *>
(ConfigKeyVal::Malloc(sizeof(val_policingmap_controller_t)));
sizeof(val_policingmap_controller_t));
tmp1 = new ConfigVal(IpctSt::kIpcStValPolicingmapController,
out_val_pm_ctrlr);
- ConfigKeyVal *temp_ckv = NULL;
- result_code = GetChildVtnCtrlrKey(temp_ckv, ikey);
+ temp_ckv->AppendCfgVal(tmp1);
+ // Adding GetUncControllerKey
+ result_code = GetRenamedControllerKey(temp_ckv, req->datatype, dmi,
+ &ctrlr_dom);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("GetRenamedControllerKey Failed %d", result_code);
+ DELETE_IF_NOT_NULL(temp_ckv);
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
+ return result_code;
+ }
+
+ //Adding capa for Read/ReadSibling/ReadSiblingBegin Commonly Here
+ result_code = GetChildVtnCtrlrKey(capa_key, ikey);
if (UPLL_RC_SUCCESS != result_code) {
- UPLL_LOG_DEBUG("GetChildVtnCtrlrKey failed %d", result_code);
+ UPLL_LOG_DEBUG("GetChildVtnCtrlrKey failed for capa_key %d", result_code);
+ DELETE_IF_NOT_NULL(temp_ckv);
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
return result_code;
}
- if (!temp_ckv) {
- UPLL_LOG_DEBUG("temp_ckv is NULL");
- delete tmp1;
- return UPLL_RC_ERR_GENERIC;
+ ConfigVal *capa_tmp = NULL;
+ val_policingmap_controller_t *capa_val_ctrlr =
+ reinterpret_cast<val_policingmap_controller_t *>
+ (ConfigKeyVal::Malloc(sizeof(val_policingmap_controller_t)));
+ memcpy(capa_val_ctrlr, val_pm_ctrlr,
+ sizeof(val_policingmap_controller_t));
+ capa_tmp = new ConfigVal(IpctSt::kIpcStValPolicingmapController,
+ capa_val_ctrlr);
+ capa_key->AppendCfgVal(capa_tmp);
+ result_code = ValidateCapability(req, capa_key, reinterpret_cast<const char *>(ctrlr_dom.ctrlr));
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Key not supported by controller IN ReadSibling");
+ DELETE_IF_NOT_NULL(capa_key);
+ DELETE_IF_NOT_NULL(temp_ckv);
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
+ return result_code;
}
- temp_ckv->AppendCfgVal(tmp1);
IpcRequest ipc_req;
memset(&ipc_req, 0, sizeof(ipc_req));
ipc_req.header.clnt_sess_id = req->clnt_sess_id;
UPLL_LOG_DEBUG("SendReqToDriver failed for Key %d controller %s",
temp_ckv->get_key_type(),
reinterpret_cast<char *>(ctrlr_dom.ctrlr));
+ DELETE_IF_NOT_NULL(capa_key);
+ DELETE_IF_NOT_NULL(temp_ckv);
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
return UPLL_RC_ERR_GENERIC;
}
UPLL_LOG_DEBUG("Driver response for Key %d controller %s result %d",
temp_ckv->get_key_type(), ctrlr_dom.ctrlr,
ipc_response->header.result_code);
+ DELETE_IF_NOT_NULL(capa_key);
+ DELETE_IF_NOT_NULL(temp_ckv);
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
return ipc_response->header.result_code;
}
+ // Check with Rakesh
+ DELETE_IF_NOT_NULL(capa_key);
+ DELETE_IF_NOT_NULL(temp_ckv);
+ FREE_IF_NOT_NULL(ctrlr_dom.ctrlr);
+ FREE_IF_NOT_NULL(ctrlr_dom.domain);
return UPLL_RC_SUCCESS;
}
UPLL_FUNC_TRACE;
upll_rc_t result_code;
controller_domain ctrlr_dom;
- if (UNC_KT_VTN_POLICINGMAP == ikey->get_key_type()) {
- result_code = ValidateMessage(req, ikey);
- if (result_code != UPLL_RC_SUCCESS) {
+ result_code = ValidateMessage(req, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
UPLL_LOG_DEBUG("ValidateMessage failed result_code %d",
result_code);
return result_code;
- }
- result_code = ReadInfoFromDB(req, ikey, dmi, &ctrlr_dom);
- if (result_code != UPLL_RC_SUCCESS) {
- UPLL_LOG_DEBUG("Read from DB failed result_code %d", result_code);
+ }
+ if (UNC_KT_VTN_POLICINGMAP == ikey->get_key_type()) {
+ if(req->datatype == UPLL_DT_STATE ||
+ req->datatype == UPLL_DT_STARTUP ||
+ req->datatype == UPLL_DT_RUNNING ||
+ req->datatype == UPLL_DT_CANDIDATE ) {
+ result_code = ReadInfoFromDB(req, ikey, dmi, &ctrlr_dom);
return result_code;
- }
- return result_code;
+ } else {
+ UPLL_LOG_DEBUG("ReadSiblingCount is not Allowed For Such datatype %d",
+ req->datatype);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
}
+ if (UNC_KT_VTN_POLICINGMAP_CONTROLLER == ikey->get_key_type())
+ if(req->datatype != UPLL_DT_STATE) {
+ UPLL_LOG_DEBUG("ReadSiblingCount is not Allowed For Such datatype %d",
+ req->datatype);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+
ConfigKeyVal *temp_vtn_pm_ckv = NULL;
ConfigKeyVal *vtn_pm_ckv = NULL;
key_vtn_policingmap_controller_t *vtn_pm_ctrlr_key = reinterpret_cast
ikey->SetCfgVal(new ConfigVal(IpctSt::kIpcStUint32, sib_count));
return UPLL_RC_SUCCESS;
}
+
+upll_rc_t VtnPolicingMapMoMgr::CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ if (NULL == ikey || NULL == dmi) {
+ UPLL_LOG_DEBUG("ikey or dmi NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ UPLL_LOG_TRACE("%s Vtn_Pm CreateAuditMoImpl ikey",
+ ikey->ToStrAll().c_str());
+ uint8_t *controller_id = reinterpret_cast<uint8_t *>(
+ const_cast<char *>(ctrlr_id));
+ result_code = GetRenamedUncKey(ikey, UPLL_DT_RUNNING, dmi,
+ controller_id);
+ if (result_code != UPLL_RC_SUCCESS &&
+ result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("GetRenamedUncKey Failed err_code %d", result_code);
+ return result_code;
+ }
+ // bool ctrl_instance = true;
+
+
+ // Check Policingmap object exists in PolicingProfileTbl CANDIDATE DB
+ // If record not exists, return error code
+ val_policingmap_t *val_pm = reinterpret_cast<val_policingmap_t *>
+ (GetVal(ikey));
+ if (NULL == val_pm) {
+ UPLL_LOG_DEBUG(" Value structure is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ if (UNC_VF_VALID == val_pm->valid[UPLL_IDX_POLICERNAME_PM]) {
+ result_code = UpdateRefCountInPPCtrlr(ikey, UPLL_DT_AUDIT, dmi,
+ UNC_OP_CREATE);
+ if (UPLL_RC_SUCCESS != result_code) {
+ if (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_DEBUG("UpdateRefCountInPPCtrlr Err in CANDIDATE DB(%d)",
+ result_code);
+ return result_code;
+ }
+ // ctrl_instance = false;
+ }
+ }
+
+ result_code = SetValidAudit(ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ return result_code;
+ }
+ DbSubOp dbop = { kOpReadExist, kOpMatchNone, kOpInOutNone };
+ result_code = UpdateConfigDB(ikey, UPLL_DT_AUDIT, UNC_OP_READ, dmi, &dbop,
+ MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code &&
+ UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code) {
+ UPLL_LOG_DEBUG("UpdateConfigDB failed ");
+ return result_code;
+ }
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ // create a record in vtnpolicingmap CANDIDATE DB
+ result_code = UpdateConfigDB(ikey, UPLL_DT_AUDIT, UNC_OP_CREATE, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Create record Err in vtnpolicingmaptbl CANDIDATE DB(%d)",
+ result_code);
+ return result_code;
+ }
+ }
+ key_vtn_t *tmp_key = reinterpret_cast<key_vtn_t *>(ikey->get_key());
+ UPLL_LOG_DEBUG("vtn name in createcand %s", tmp_key->vtn_name);
+ // Create the record in vtnpolicingmapctrltbl
+
+ //if (ctrl_instance) {
+ result_code = UpdateRecordInVtnPmCtrlr(ikey, UPLL_DT_AUDIT, UNC_OP_CREATE,
+ dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Create record Err in vtnpolicingmaptbl CANDIDATE DB(%d)",
+ result_code);
+ return result_code;
+ }
+ //}
+
+ return result_code;
+}
+
+upll_rc_t VtnPolicingMapMoMgr::DeleteChildrenPOM(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type, DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ if (NULL == ikey || NULL == dmi) {
+ UPLL_LOG_DEBUG("DeleteMo ikey and req NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+
+ // 1)Decerment the refcount and check if the refcount as 0 then remove
+ // the record and if refcount is not 0, then update the refcount in
+ // policingprofilectrltbl
+
+ // 2)Delete the record in policingprofileentryctrltbl
+ ConfigKeyVal *tempckv = NULL;
+ result_code = GetChildConfigKey(tempckv, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG(" GetChildConfigKey failed");
+ return result_code;
+ }
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone };
+ result_code = ReadConfigDB(tempckv, dt_type, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ UPLL_LOG_DEBUG("UPLL_RC_ERR_NO_SUCH_INSTANCE");
+ DELETE_IF_NOT_NULL(tempckv);
+ return UPLL_RC_SUCCESS;
+ }
+ UPLL_LOG_DEBUG(" ReadConfigDB failed ");
+ DELETE_IF_NOT_NULL(tempckv);
+ return result_code;
+ }
+ val_policingmap_t *val_pm = reinterpret_cast<val_policingmap_t *>
+ (GetVal(tempckv));
+ if (UNC_VF_VALID == val_pm->valid[UPLL_IDX_POLICERNAME_PM]) {
+ result_code = UpdateRefCountInPPCtrlr(tempckv, dt_type, dmi,
+ UNC_OP_DELETE);
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ result_code = UPLL_RC_SUCCESS;
+ } else if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DeleteMo returns (%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(tempckv);
+ return result_code;
+ }
+ }
+ DELETE_IF_NOT_NULL(tempckv);
+ ConfigKeyVal *temp_ikey = NULL;
+ result_code = GetChildConfigKey(temp_ikey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed");
+ return result_code;
+ }
+ // Delete a record in vtnpolicingmap CANDIDATE DB
+ result_code = UpdateConfigDB(temp_ikey, dt_type, UNC_OP_DELETE, dmi,
+ MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DeleteMo record Err in vtnpolicingmaptbl (%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(temp_ikey);
+ return result_code;
+ }
+
+ // Delete the record in vtnpolicingmapctrltbl
+ result_code = UpdateRecordInVtnPmCtrlr(temp_ikey, dt_type, UNC_OP_DELETE,
+ dmi);
+ if (UPLL_RC_ERR_NO_SUCH_INSTANCE == result_code) {
+ DELETE_IF_NOT_NULL(temp_ikey);
+ result_code = UPLL_RC_SUCCESS;
+ } else if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("DeleteMo record Err in vtnpolicingmapctrltbl (%d)",
+ result_code);
+ DELETE_IF_NOT_NULL(temp_ikey);
+ return result_code;
+ }
+
+ DELETE_IF_NOT_NULL(temp_ikey);
+ return result_code;
+}
+
+upll_rc_t VtnPolicingMapMoMgr::SetValidAudit(ConfigKeyVal *&ikey) {
+ UPLL_FUNC_TRACE;
+ val_policingmap_t *val = reinterpret_cast
+ <val_policingmap_t *>(GetVal(ikey));
+ if (NULL == val) {
+ UPLL_LOG_DEBUG("val is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (val->valid[0] == UNC_VF_VALID) {
+ val->cs_attr[0] = UNC_CS_APPLIED;
+ } else if (val->valid[0] == UNC_VF_INVALID) {
+ val->cs_attr[0] = UNC_CS_NOT_APPLIED;
+ }
+ val->cs_row_status = UNC_CS_APPLIED;
+ return UPLL_RC_SUCCESS;
+}
+
+bool VtnPolicingMapMoMgr::FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op) {
+ UPLL_FUNC_TRACE;
+ if (op != UNC_OP_CREATE)
+ return CompareValidValue(val1, val2, copy_to_running);
+ return false;
+}
+upll_rc_t VtnPolicingMapMoMgr::IsRenamed(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi,
+ uint8_t &rename) {
+ UPLL_FUNC_TRACE;
+ UPLL_LOG_DEBUG("VtnPolicingMapMoMgr IsRenamed");
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag | kOpInOutCtrlr
+ | kOpInOutDomain };
+ ConfigKeyVal *okey = NULL;
+ upll_rc_t result_code;
+ /* rename is set implies user wants the ikey
+ * populated with val from db */
+ if (!rename) {
+ if (UNC_KT_VTN_POLICINGMAP == ikey->get_key_type()) {
+ UPLL_LOG_DEBUG("UNC_KT_VTN_POLICINGMAP");
+ result_code = GetChildConfigKey(okey, ikey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("Returning error %d",result_code);
+ return result_code;
+ }
+ } else if (UNC_KT_VTN_POLICINGMAP_CONTROLLER == ikey->get_key_type()) {
+ UPLL_LOG_DEBUG("UNC_KT_VTN_POLICINGMAP_CONTROLLER");
+
+ key_vtn_t *out_key = reinterpret_cast<key_vtn_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn_t)));
+
+ key_vtn_policingmap_controller_t *in_key = reinterpret_cast
+ <key_vtn_policingmap_controller_t *>(ikey->get_key());
+
+ uuu::upll_strncpy(out_key->vtn_name,
+ in_key->vtn_key.vtn_name,
+ (kMaxLenVtnName + 1));
+
+ okey = new ConfigKeyVal(UNC_KT_VTN_POLICINGMAP,
+ IpctSt::kIpcStKeyVtn,
+ out_key, NULL);
+ }
+ } else {
+ okey = ikey;
+ }
+
+ result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ, dbop, dmi,
+ MAINTBL);
+ if ((result_code != UPLL_RC_SUCCESS) &&
+ (result_code != UPLL_RC_ERR_NO_SUCH_INSTANCE)) {
+ UPLL_LOG_DEBUG("Returning error code %d",result_code);
+ if (okey != ikey) delete okey;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ GET_USER_DATA_FLAGS(okey, rename);
+ controller_domain_t ctrlr_dom;
+ ctrlr_dom.ctrlr = NULL;
+ ctrlr_dom.domain = NULL;
+
+ GET_USER_DATA_CTRLR_DOMAIN(ikey,ctrlr_dom);
+ UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+ SET_USER_DATA_CTRLR_DOMAIN(okey,ctrlr_dom);
+ UPLL_LOG_DEBUG("Controller : %s; Domain : %s", ctrlr_dom.ctrlr,
+ ctrlr_dom.domain);
+
+ SET_USER_DATA(ikey,okey);
+ rename &= RENAME;
+ if (okey != ikey) delete okey;
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtnPolicingMapMoMgr::SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_policingmap_t *val_pm = reinterpret_cast
+ <val_policingmap_t *>(GetVal(ikey));
+ if (!val_pm) {
+ UPLL_LOG_DEBUG("Val is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigKeyVal *pkey = NULL;
+ if (UNC_OP_CREATE == req->operation) {
+ result_code = GetParentConfigKey(pkey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetParentConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_VTN)));
+ if (!mgr) {
+ UPLL_LOG_DEBUG("mgr is NULL");
+ DELETE_IF_NOT_NULL(pkey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t rename = 0;
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutFlag};
+ result_code = mgr->ReadConfigDB(pkey, req->datatype,
+ UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB failed %d", result_code);
+ DELETE_IF_NOT_NULL(pkey);
+ return result_code;
+ }
+ GET_USER_DATA_FLAGS(pkey, rename);
+ DELETE_IF_NOT_NULL(pkey);
+ // Check policingprofile is renamed
+ if ((UNC_VF_VALID == val_pm->valid[UPLL_IDX_POLICERNAME_PM]) &&
+ ((UNC_OP_CREATE == req->operation))) {
+ ConfigKeyVal *pp_ckv = NULL;
+ result_code = GetPolicingProfileConfigKey(reinterpret_cast<const char *>
+ (val_pm->policer_name), pp_ckv, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetPolicingProfileConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *pp_mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_POLICING_PROFILE)));
+ if (NULL == pp_mgr) {
+ UPLL_LOG_DEBUG("pp_mgr is NULL");
+ DELETE_IF_NOT_NULL(pp_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t pp_rename = 0;
+ result_code = pp_mgr->IsRenamed(pp_ckv, req->datatype, dmi, pp_rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(pp_ckv);
+ return result_code;
+ }
+ if (pp_rename & 0x01) {
+ rename |= POLICINGPROFILE_RENAME; // TODO Check for correct flag value
+ }
+ DELETE_IF_NOT_NULL(pp_ckv);
+ }
+ SET_USER_DATA_FLAGS(ikey, rename);
+ } else if (UNC_OP_UPDATE == req->operation) {
+ uint8_t rename = 0;
+ result_code = IsRenamed(ikey, req->datatype, dmi, rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ return result_code;
+ }
+ if (UNC_VF_VALID == val_pm->valid[UPLL_IDX_POLICERNAME_PM]) {
+ ConfigKeyVal *pp_ckv = NULL;
+ result_code = GetPolicingProfileConfigKey(reinterpret_cast<const char *>
+ (val_pm->policer_name), pp_ckv, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetPolicingProfileConfigKey failed %d", result_code);
+ return result_code;
+ }
+ MoMgrImpl *pp_mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_POLICING_PROFILE)));
+ if (NULL == pp_mgr) {
+ UPLL_LOG_DEBUG("pp_mgr is NULL");
+ DELETE_IF_NOT_NULL(pp_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t pp_rename = 0;
+ result_code = pp_mgr->IsRenamed(pp_ckv, req->datatype, dmi, pp_rename);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("IsRenamed failed %d", result_code);
+ DELETE_IF_NOT_NULL(pp_ckv);
+ return result_code;
+ }
+ if (pp_rename & 0x01) {
+ rename |= POLICINGPROFILE_RENAME; // TODO Check for correct flag value
+ } else {
+ UPLL_LOG_DEBUG(" In else part rename %d ", rename);
+ rename = rename & NO_POLICINGPROFILE_RENAME;
+ }
+ DELETE_IF_NOT_NULL(pp_ckv);
+ } else if (UNC_VF_VALID_NO_VALUE == val_pm->valid
+ [UPLL_IDX_POLICERNAME_PM]) {
+ rename = rename & NO_POLICINGPROFILE_RENAME;
+ }
+ SET_USER_DATA_FLAGS(ikey, rename);
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtnPolicingMapMoMgr::GetPolicingProfileConfigKey(
+ const char *pp_name, ConfigKeyVal *&okey,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_ERR_GENERIC;
+ MoMgrImpl *mgr =
+ reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_POLICING_PROFILE)));
+ result_code = mgr->GetChildConfigKey(okey, NULL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed %d", result_code);
+ return result_code;
+ }
+ key_policingprofile_t *okey_key = reinterpret_cast<key_policingprofile_t *>
+ (okey->get_key());
+ uuu::upll_strncpy(okey_key->policingprofile_name,
+ pp_name,
+ (kMaxLenPolicingProfileName+1));
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtnPolicingMapMoMgr::SetVtnPmConsolidatedStatus(ConfigKeyVal *ikey,
+ uint8_t *ctrlr_id,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ctrlr_ckv = NULL;
+ val_vtnpolicingmap_ctrl_t *ctrlr_val = NULL;
+ uint8_t *vtn_exist_on_ctrlr = NULL;
+ bool applied = false, not_applied = false, invalid = false;
+ unc_keytype_configstatus_t c_status = UNC_CS_NOT_APPLIED;
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone,
+ kOpInOutCtrlr | kOpInOutDomain | kOpInOutCs };
+ if (!ikey || !dmi) {
+ UPLL_LOG_DEBUG("Invalid Input");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = GetChildConfigKey(ctrlr_ckv, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey failed err code %d", result_code);
+ return result_code;
+ }
+ result_code = ReadConfigDB(ctrlr_ckv, UPLL_DT_RUNNING, UNC_OP_READ, dbop, dmi,
+ CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("ReadConfigDB from ctrltbl failed err code %d",
+ result_code);
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return result_code;
+ }
+
+ for (ConfigKeyVal *tmp = ctrlr_ckv; tmp != NULL;
+ tmp = tmp->get_next_cfg_key_val()) {
+ ctrlr_val = reinterpret_cast<val_vtnpolicingmap_ctrl_t *>(GetVal(tmp));
+ if (!ctrlr_val) {
+ UPLL_LOG_DEBUG("Controller Value is empty");
+ tmp = NULL;
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ GET_USER_DATA_CTRLR(tmp, vtn_exist_on_ctrlr);
+ if (!strcmp(reinterpret_cast<char *>(vtn_exist_on_ctrlr),
+ reinterpret_cast<char *>(ctrlr_id)))
+ continue; // skipping entry of deleted controller
+
+ switch (ctrlr_val->cs_row_status) {
+ case UNC_CS_APPLIED:
+ applied = true;
+ break;
+ case UNC_CS_NOT_APPLIED:
+ not_applied = true;
+ break;
+ case UNC_CS_INVALID:
+ invalid = true;
+ default:
+ UPLL_LOG_DEBUG("Invalid status");
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ // return result_code;
+ }
+ vtn_exist_on_ctrlr = NULL;
+ }
+ if (invalid) {
+ c_status = UNC_CS_INVALID;
+ } else if (applied && !not_applied) {
+ c_status = UNC_CS_APPLIED;
+ } else if (!applied && not_applied) {
+ c_status = UNC_CS_NOT_APPLIED;
+ } else if (applied && not_applied) {
+ c_status = UNC_CS_PARTIALLY_APPLIED;
+ } else {
+ c_status = UNC_CS_APPLIED;
+ }
+ // Set cs_status
+ val_vtnpolicingmap_ctrl_t *val = static_cast<val_vtnpolicingmap_ctrl_t *>
+ (GetVal(ikey));
+ val->cs_row_status = c_status;
+ val->cs_attr[0] = c_status;
+ DbSubOp dbop_update = {kOpNotRead, kOpMatchNone, kOpInOutCs};
+ result_code = UpdateConfigDB(ikey, UPLL_DT_RUNNING, UNC_OP_UPDATE, dmi,
+ &dbop_update, MAINTBL);
+ DELETE_IF_NOT_NULL(ctrlr_ckv);
+ return result_code;
+}
+
+upll_rc_t VtnPolicingMapMoMgr::SetConsolidatedStatus(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *ckv = NULL;
+ DbSubOp dbop = {kOpReadMultiple, kOpMatchNone, kOpInOutCs};
+ result_code = GetChildConfigKey(ckv, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Unable to Get the configKey");
+ return result_code;
+ }
+ result_code = ReadConfigDB(ckv,
+ UPLL_DT_RUNNING,
+ UNC_OP_READ, dbop, dmi, CTRLRTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Unable to read the configuration from CTRLR Table");
+ if (ckv != NULL) {
+ delete ckv;
+ ckv = NULL;
+ }
+ return result_code;
+ }
+ std::list< unc_keytype_configstatus_t > list_cs_row;
+ std::list< unc_keytype_configstatus_t > list_cs_attr;
+ val_vtnpolicingmap_ctrl_t *val;
+ ConfigKeyVal *temp_ckv = ckv;
+ for ( ; temp_ckv != NULL ; temp_ckv = temp_ckv->get_next_cfg_key_val()) {
+ val = reinterpret_cast<val_vtnpolicingmap_ctrl_t *>(GetVal(temp_ckv));
+ list_cs_row.push_back((unc_keytype_configstatus_t)val->cs_row_status);
+ list_cs_attr.push_back((unc_keytype_configstatus_t)val->cs_attr[0]);
+ }
+ DELETE_IF_NOT_NULL(ckv);
+ val_policingmap_t *val_temp = reinterpret_cast<val_policingmap_t *>(GetVal(ikey));
+ val_temp->cs_row_status = GetConsolidatedCsStatus(list_cs_row);
+ val_temp->cs_attr[0] = GetConsolidatedCsStatus(list_cs_attr);
+ result_code = UpdateConfigDB(ikey,
+ UPLL_DT_RUNNING,
+ UNC_OP_UPDATE, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ return result_code;
+ }
+ return result_code;
+}
} // kt_momgr
} // upll
} // unc
VTNPOLICINGMAPTBL = 0, VTNPOLICINGMAPCTRLRTBL, NVTNPOLICINGMAPTABLES
};
-#define CONFIGKEYVALCLEAN(ikey) { \
- if (ikey) { \
- delete ikey; \
- ikey = NULL; \
- } \
-}
-
/**
* @Brief VtnPolicingMapMoMgr class.
*/
static BindInfo key_vtnpm_vtn_ctrlrtbl_rename_bind_info[];
static BindInfo key_vtnpm_Policyname_maintbl_rename_bind_info[];
static BindInfo key_vtnpm_Policyname_ctrlrtbl_rename_bind_info[];
-
+ uint32_t cur_instance_count;
public:
/**
* @Brief VtnPolicingMapMoMgr Class Constructor.
upll_rc_t ValidateCapability(IpcReqRespHeader *req, ConfigKeyVal *ikey,
const char* ctrlr_name = NULL);
- /**
- * @Brief Method is used to validate the policing map value structure
- * attributes bases on the operation
- *
- * @param[in] val_policingmap Pointer to val structure
- * @param[in] req Describes IpcReqRespHeader class.
- *
- * @retval UPLL_RC_SUCCESS Successful.
- * @retval UPLL_RC_ERR_CFG_SYNTAX Syntax error.
- * @retval UPLL_RC_ERR_NO_SUCH_INSTANCE Record is not available.
- * @retval UPLL_RC_ERR_GENERIC Generic failure.
- * @retval UPLL_RC_ERR_INVALID_OPTION1 option1 is not valid.
- * @retval UPLL_RC_ERR_INVALID_OPTION2 option2 is not valid.
- */
- static upll_rc_t ValidatePolicingMapValue(val_policingmap_t *val_policingmap,
- IpcReqRespHeader *req);
-
/**
* @Brief Method is used to validate the policingmap value structure
* attributes bases on the operation
*
- * @param[in] val_policingmap Pointer to val structure
+ * @param[in] key Pointer to ConfigKeyVal.
* @param[in] operation Type of operation.
*
* @retval UPLL_RC_SUCCESS Successful.
* @retval UPLL_RC_ERR_INVALID_OPTION1 option1 is not valid.
* @retval UPLL_RC_ERR_INVALID_OPTION2 option2 is not valid.
*/
- static upll_rc_t ValidatePolicingMapValue(val_policingmap_t *val_policingmap,
+ static upll_rc_t ValidatePolicingMapValue(ConfigKeyVal *key,
uint32_t operation);
/**
* @Brief Method is used to validate the policingmap controller value
* structure attributes bases on the operation
*
- * @param[in] val_policingmap_controller Pointer to val structure
- * @param[in] operation Type of operation.
+ * @param[in] key Pointer to ConfigKeyVal.
+ * @param[in] req Describes IpcReqRespHeader class.
*
* @retval UPLL_RC_SUCCESS Successful.
* @retval UPLL_RC_ERR_CFG_SYNTAX Syntax error.
* @retval UPLL_RC_ERR_INVALID_OPTION1 option1 is not valid.
* @retval UPLL_RC_ERR_INVALID_OPTION2 option2 is not valid.
*/
- upll_rc_t ValidateVtnPolicingMapControllerValue(
- val_policingmap_controller_t *val_policingmap_controller,
- uint32_t operation);
+ upll_rc_t ValidateVtnPolicingMapControllerValue(ConfigKeyVal *key,
+ IpcReqRespHeader *req);
/**
* @Brief Checks if the specified key type(KT_VTN_POLICINGMAP) and
uint8_t* vtn_name,
controller_domain *ctrlr_dom,
unc_keytype_operation_t op,
- DalDmlIntf *dmi);
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi,
+ uint8_t flag);
+
+ /**
+ * @brief Method used for Restoring PolicingProfile in the Controller Table
+ *
+ * @param[in] ikey Pointer to ConfigKeyVal Class
+ * @param[in] dt_type Describes Configiration Information.
+ * @param[in] tbl Describe the destination table
+ * @param[in] dmi Pointer to DalDmlIntf Class.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_DB_ACCESS DB Read/Write error.
+ * @retval UPLL_RC_ERR_INSTANCE_EXISTS Record already exists
+ * @retval UPLL_RC_ERR_GENERIC Returned Generic Error.
+ */
+
+ upll_rc_t RestorePOMInCtrlTbl(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl,
+ DalDmlIntf* dmi);
bool CompareKey(void *key1, void *key2) {
return true;
upll_rc_t ValidateReadAttribute(ConfigKeyVal *ikey,
DalDmlIntf *dmi,
IpcReqRespHeader *req);
+
+ upll_rc_t CreateAuditMoImpl(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ const char *ctrlr_id);
+
+ upll_rc_t DeleteChildrenPOM(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi);
+
+ upll_rc_t SetValidAudit(ConfigKeyVal *&ikey);
+
+ upll_rc_t UpdateVnodeVal(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t data_type,
+ bool &no_rename);
+
+ bool FilterAttributes(void *&val1,
+ void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op);
+
+ upll_rc_t MergeImportToCandidate(unc_key_type_t keytype,
+ const char *ctrlr_name,
+ DalDmlIntf *dmi);
+
+ upll_rc_t IsRenamed(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi,
+ uint8_t &rename);
+
+ upll_rc_t GetPolicingProfileConfigKey(
+ const char *pp_name, ConfigKeyVal *&okey,
+ DalDmlIntf *dmi);
+
+ upll_rc_t SetRenameFlag(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req);
+
+ upll_rc_t SetVtnPmConsolidatedStatus(ConfigKeyVal *ikey,
+ uint8_t *ctrlr_id,
+ DalDmlIntf *dmi);
+
+ upll_rc_t SetConsolidatedStatus(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi);
};
typedef struct val_vtnpolicingmap_ctrl {
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 NEC Corporation
+ * All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+#include "vtunnel_if_momgr.hh"
+#include "vtunnel_momgr.hh"
+#include "ctrlr_capa_defines.hh"
+#include "capa_intf.hh"
+#include "upll_validation.hh"
+#include "uncxx/upll_log.hh"
+#define NUM_KEY_MAIN_TBL_ 5
+
+namespace unc {
+namespace upll {
+namespace kt_momgr {
+
+ BindInfo VtunnelIfMoMgr::vtunnel_if_bind_info[] = {
+ { uudst::vtunnel_interface::kDbiVtnName, CFG_KEY, offsetof(key_vtunnel_if,
+ vtunnel_key.vtn_key.vtn_name), uud::kDalChar, kMaxLenVtnName+1},
+ { uudst::vtunnel_interface::kDbiVtunnelName, CFG_KEY,
+ offsetof(key_vtunnel_if,
+ vtunnel_key.vtunnel_name), uud::kDalChar, kMaxLenVnodeName+1},
+ { uudst::vtunnel_interface::kDbiIfName, CFG_KEY, offsetof(key_vtunnel_if,
+ if_name), uud::kDalChar, kMaxLenInterfaceName+1},
+ { uudst::vtunnel_interface::kDbiDesc, CFG_VAL, offsetof(
+ val_vtunnel_if, description), uud::kDalChar, 128},
+ { uudst::vtunnel_interface::kDbiAdminStatus, CFG_VAL, offsetof(
+ val_vtunnel_if, admin_status), uud::kDalUint8, 1},
+ { uudst::vtunnel_interface::kDbiLogicalPortId, CFG_VAL, offsetof(
+ val_vtunnel_if, portmap.logical_port_id), uud::kDalChar, 320},
+ { uudst::vtunnel_interface::kDbiVlanId, CFG_VAL, offsetof(
+ val_vtunnel_if, portmap.vlan_id), uud::kDalUint16, 1},
+ { uudst::vtunnel_interface::kDbiTagged, CFG_VAL, offsetof(
+ val_vtunnel_if, portmap.tagged), uud::kDalUint8, 1},
+ { uudst::vtunnel_interface::kDbiOperStatus, ST_VAL,
+ offsetof(val_db_vtunnel_if_st,
+ vtunnel_if_val_st.oper_status), uud::kDalUint8, 1},
+ { uudst::vtunnel_interface::kDbiDownCount, ST_VAL,
+ offsetof(val_db_vtunnel_if_st,
+ down_count), uud::kDalUint32, 1 },
+ { uudst::vtunnel_interface::kDbiCtrlrName, CK_VAL, offsetof(key_user_data,
+ ctrlr_id), uud::kDalChar, 32},
+ { uudst::vtunnel_interface::kDbiDomainId, CK_VAL, offsetof(key_user_data,
+ domain_id), uud::kDalChar, 32},
+ { uudst::vtunnel_interface::kDbiFlags, CK_VAL, offsetof(key_user_data,
+ flags), uud::kDalUint8, 1},
+ { uudst::vtunnel_interface::kDbiValidDesc, CFG_META_VAL, offsetof(
+ val_vtunnel_if, valid[UPLL_IDX_DESC_VTNL_IF]), uud::kDalUint8, 1},
+ { uudst::vtunnel_interface::kDbiValidAdminStatus, CFG_DEF_VAL, offsetof(
+ val_vtunnel_if, valid[UPLL_IDX_ADMIN_ST_VTNL_IF]), uud::kDalUint8, 1},
+ { uudst::vtunnel_interface::kDbiValidPortMap, CFG_META_VAL, offsetof(
+ val_vtunnel_if, valid[UPLL_IDX_PORT_MAP_VTNL_IF]), uud::kDalUint8, 1},
+ { uudst::vtunnel_interface::kDbiValidLogicalPortId, CFG_META_VAL, offsetof
+ (val_vtunnel_if, portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM]),
+ uud::kDalUint8, 1},
+ { uudst::vtunnel_interface::kDbiValidVlanid, CFG_META_VAL, offsetof(
+ val_vtunnel_if, portmap.valid[UPLL_IDX_VLAN_ID_PM]),
+ uud::kDalUint8, 1},
+ { uudst::vtunnel_interface::kDbiValidTagged, CFG_META_VAL, offsetof(
+ val_vtunnel_if, portmap.valid[UPLL_IDX_TAGGED_PM]),
+ uud::kDalUint8, 1 },
+ { uudst::vtunnel_interface::kDbiValidOperStatus, ST_META_VAL, offsetof(
+ val_db_vtunnel_if_st,
+ vtunnel_if_val_st.valid[UPLL_IDX_IF_OPER_STATUS_VTNLI]),
+ uud::kDalUint8, 1 },
+ { uudst::vtunnel_interface::kDbiCsRowstatus, CS_VAL,
+ offsetof(val_vtunnel_if,
+ cs_row_status), uud::kDalUint8, 1},
+ { uudst::vtunnel_interface::kDbiCsDesc, CS_VAL, offsetof(val_vtunnel_if,
+ cs_attr[UPLL_IDX_DESC_VTNL_IF]), uud::kDalUint8, 1},
+ { uudst::vtunnel_interface::kDbiCsAdminStatus, CS_VAL,
+ offsetof(val_vtunnel_if,
+ cs_attr[UPLL_IDX_ADMIN_ST_VTNL_IF]), uud::kDalUint8, 1},
+ { uudst::vtunnel_interface::kDbiCsPortMap, CS_VAL, offsetof(val_vtunnel_if,
+ cs_attr[UPLL_IDX_PORT_MAP_VTNL_IF]), uud::kDalUint8, 1},
+ { uudst::vtunnel_interface::kDbiCsLogicalPortId, CS_VAL, offsetof(
+ val_vtunnel_if, portmap.cs_attr[UPLL_IDX_LOGICAL_PORT_ID_PM]),
+ uud::kDalUint8, 1 },
+ { uudst::vtunnel_interface::kDbiCsVlanid, CS_VAL, offsetof(
+ val_vtunnel_if, portmap.cs_attr[UPLL_IDX_VLAN_ID_PM]),
+ uud::kDalUint8, 1 },
+ { uudst::vtunnel_interface::kDbiCsTagged, CS_VAL, offsetof(
+ val_vtunnel_if, portmap.cs_attr[UPLL_IDX_TAGGED_PM]),
+ uud::kDalUint8, 1 }
+ };
+
+VtunnelIfMoMgr::VtunnelIfMoMgr() {
+ UPLL_FUNC_TRACE;
+ Table *tbl = new Table(uudst::kDbiVtunnelIfTbl, UNC_KT_VTUNNEL_IF,
+ vtunnel_if_bind_info,
+ IpctSt::kIpcStKeyVtunnelIf, IpctSt::kIpcStValVtunnelIf,
+ uudst::vtunnel_interface::kDbiVtunnelIfNumCols);
+ ntable = MAX_MOMGR_TBLS;
+ table = new Table *[ntable];
+ table[MAINTBL] = tbl;
+ table[RENAMETBL] = NULL;
+ table[CTRLRTBL] = NULL;
+ nchild = 0;
+ child = NULL;
+#ifdef _STANDALONE_
+ SetMoManager(UNC_KT_VTUNNEL_IF, reinterpret_cast<MoMgr *>(this));
+#endif
+}
+
+upll_rc_t VtunnelIfMoMgr::ValidateAttribute(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ if (!ikey || (ikey->get_key_type() != UNC_KT_VTUNNEL_IF)
+ || !(ikey->get_cfg_val()))
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ val_vtunnel_if *vtunnelif_val = static_cast<val_vtunnel_if *>(GetVal(ikey));
+ if (!vtunnelif_val) {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (vtunnelif_val->valid[UPLL_IDX_PORT_MAP_VTNL_IF] == UNC_VF_VALID) {
+ if (vtunnelif_val->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM]
+ == UNC_VF_VALID &&
+ vtunnelif_val->portmap.valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID) {
+ key_vtunnel_if *vtunnel_key_if = static_cast<key_vtunnel_if *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtunnel_if)));
+ val_vtunnel_if *vtunnelif_val_filter = static_cast<val_vtunnel_if *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtunnel_if)));
+ vtunnelif_val_filter->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] =
+ UNC_VF_VALID;
+ vtunnelif_val_filter->portmap.valid[UPLL_IDX_VLAN_ID_PM] = UNC_VF_VALID;
+ uuu::upll_strncpy(vtunnelif_val_filter->portmap.logical_port_id,
+ vtunnelif_val->portmap.logical_port_id,
+ kMaxLenLogicalPortId+1);
+ vtunnelif_val_filter->portmap.vlan_id = vtunnelif_val->portmap.vlan_id;
+ ConfigKeyVal *vtunnelif_ckv = new ConfigKeyVal(UNC_KT_VTUNNEL_IF,
+ IpctSt::kIpcStKeyVtunnelIf, vtunnel_key_if, NULL);
+ vtunnelif_ckv->AppendCfgVal(IpctSt::kIpcStValVtunnelIf,
+ vtunnelif_val_filter);
+
+ SET_USER_DATA(vtunnelif_ckv, ikey);
+ // Read from the DB
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchCtrlr | kOpMatchDomain,
+ kOpInOutFlag};
+ result_code = ReadConfigDB(vtunnelif_ckv, UPLL_DT_CANDIDATE, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (result_code == UPLL_RC_SUCCESS) {
+ // check different interface has the same port and lan id
+ ConfigKeyVal *tmp = vtunnelif_ckv;
+ while (tmp) {
+ if (!memcmp((ikey->get_key()), (tmp->get_key()),
+ sizeof(key_vtunnel_if))) {
+ UPLL_LOG_TRACE("Looking on the Same key");
+ } else {
+ UPLL_LOG_DEBUG("Same port Id and VlanId is used on different "
+ "Vtunnel Interface within same VTN/Controller");
+ delete vtunnelif_ckv;
+ vtunnelif_ckv = tmp = NULL;
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ tmp = tmp->get_next_cfg_key_val();
+ }
+ } else if (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ result_code = UPLL_RC_SUCCESS;
+ } else {
+ delete vtunnelif_ckv;
+ vtunnelif_ckv = NULL;
+ return result_code;
+ }
+ delete vtunnelif_ckv;
+ vtunnelif_ckv = NULL;
+ }
+ }
+ UPLL_LOG_TRACE("PortId and VlanId is not used on any Vtunnel Interface");
+ // PortMap Validation
+ uint32_t operation = req->operation;
+ if (operation == UNC_OP_UPDATE) {
+ result_code = UpdateConfigVal(ikey, UPLL_DT_CANDIDATE, dmi);
+ UPLL_LOG_TRACE("UpdateConfigVal returned %d", result_code);
+ }
+ return result_code;
+}
+
+bool VtunnelIfMoMgr::IsValidKey(void *key, uint64_t index) {
+ UPLL_FUNC_TRACE;
+ key_vtunnel_if *if_key = reinterpret_cast<key_vtunnel_if *>(key);
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ switch (index) {
+ case uudst::vtunnel_interface::kDbiVtnName:
+ ret_val = ValidateKey(reinterpret_cast<char *>
+ (if_key->vtunnel_key.vtn_key.vtn_name),
+ kMinLenVtnName, kMaxLenVtnName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("VTN Name is not valid(%d)", ret_val);
+ return false;
+ }
+ break;
+ case uudst::vtunnel_interface::kDbiVtunnelName:
+ ret_val = ValidateKey(reinterpret_cast<char *>
+ (if_key->vtunnel_key.vtunnel_name),
+ kMinLenVnodeName, kMaxLenVnodeName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("Vtunnel Name is not valid(%d)", ret_val);
+ return false;
+ }
+ break;
+ case uudst::vtunnel_interface::kDbiIfName:
+ ret_val = ValidateKey(reinterpret_cast<char *>
+ (if_key->if_name),
+ kMinLenInterfaceName, kMaxLenInterfaceName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("Vtunnel IF Name is not valid(%d)", ret_val);
+ return false;
+ }
+ break;
+ default:
+ UPLL_LOG_TRACE("Wrong Index");
+ return false;
+ }
+ return true;
+}
+
+upll_rc_t VtunnelIfMoMgr::GetValid(void *val, uint64_t indx,
+ uint8_t *&valid,
+ upll_keytype_datatype_t dt_type, MoMgrTables tbl ) {
+ UPLL_FUNC_TRACE;
+ if (val == NULL) return UPLL_RC_ERR_GENERIC;
+ if (tbl == MAINTBL) {
+ switch (indx) {
+ case uudst::vtunnel_interface::kDbiOperStatus:
+ valid = &(reinterpret_cast<val_vtunnel_if_st *>(val))->
+ valid[UPLL_IDX_IF_OPER_STATUS_VTNLI];
+ break;
+ case uudst::vtunnel_interface::kDbiDownCount:
+ valid = NULL;
+ break;
+ case uudst::vtunnel_interface::kDbiAdminStatus:
+ valid = &(reinterpret_cast<val_vtunnel_if *>(val))->
+ valid[UPLL_IDX_ADMIN_ST_VTNL_IF];
+ break;
+ case uudst::vtunnel_interface::kDbiDesc:
+ valid = &(reinterpret_cast<val_vtunnel_if *>(val))->
+ valid[UPLL_IDX_DESC_VTNL_IF];
+ break;
+ case uudst::vtunnel_interface::kDbiValidPortMap:
+ valid = &(reinterpret_cast<val_vtunnel_if *>(val))->
+ valid[UPLL_IDX_PORT_MAP_VTNL_IF];
+ break;
+ case uudst::vtunnel_interface::kDbiLogicalPortId:
+ valid = &(reinterpret_cast<val_vtunnel_if *>(val))->portmap.
+ valid[UPLL_IDX_LOGICAL_PORT_ID_PM];
+ break;
+ case uudst::vtunnel_interface::kDbiVlanId:
+ valid = &(reinterpret_cast<val_vtunnel_if *>(val))->portmap.
+ valid[UPLL_IDX_VLAN_ID_PM];
+ break;
+ case uudst::vtunnel_interface::kDbiTagged:
+ valid = &(reinterpret_cast<val_vtunnel_if *>(val))->portmap.
+ valid[UPLL_IDX_TAGGED_PM];
+ break;
+ default:
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtunnelIfMoMgr::GetChildConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *parent_key) {
+ UPLL_FUNC_TRACE;
+ bool cfgval_ctrlr = false;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ key_vtunnel_if *vtunnel_key_if = static_cast<key_vtunnel_if *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtunnel_if)));
+ if (vtunnel_key_if == NULL) return UPLL_RC_ERR_GENERIC;
+ void *pkey;
+ if (parent_key == NULL) {
+ if (okey) delete okey;
+ okey = new ConfigKeyVal(UNC_KT_VTUNNEL_IF, IpctSt::kIpcStKeyVtunnelIf,
+ vtunnel_key_if, NULL);
+ return UPLL_RC_SUCCESS;
+ } else {
+ pkey = parent_key->get_key();
+ }
+ if (!pkey) {
+ FREE_IF_NOT_NULL(vtunnel_key_if);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (okey && (okey->get_key())) {
+ FREE_IF_NOT_NULL(vtunnel_key_if);
+ if (okey->get_key_type() != UNC_KT_VTUNNEL_IF)
+ return UPLL_RC_ERR_GENERIC;
+ vtunnel_key_if = static_cast<key_vtunnel_if *>(okey->get_key());
+ } else {
+ okey = new ConfigKeyVal(UNC_KT_VTUNNEL_IF, IpctSt::kIpcStKeyVtunnelIf,
+ vtunnel_key_if, NULL);
+ if (okey == NULL) {
+ FREE_IF_NOT_NULL(vtunnel_key_if);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ unc_key_type_t keytype = parent_key->get_key_type();
+ switch (keytype) {
+ case UNC_KT_VTN:
+ uuu::upll_strncpy(vtunnel_key_if->vtunnel_key.vtn_key.vtn_name,
+ static_cast<key_vtn *>(pkey)->vtn_name, (kMaxLenVtnName+1));
+ *(vtunnel_key_if->vtunnel_key.vtunnel_name) = *"";
+ break;
+ case UNC_KT_VTUNNEL:
+ uuu::upll_strncpy(vtunnel_key_if->vtunnel_key.vtn_key.vtn_name,
+ static_cast<key_vtunnel *>
+ (pkey)->vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ uuu::upll_strncpy(vtunnel_key_if->vtunnel_key.vtunnel_name,
+ static_cast<key_vtunnel *>(pkey)->vtunnel_name,
+ (kMaxLenVnodeName+1));
+ break;
+ case UNC_KT_VTUNNEL_IF:
+ uuu::upll_strncpy(vtunnel_key_if->vtunnel_key.vtn_key.vtn_name,
+ static_cast<key_vtunnel_if *>
+ (pkey)->vtunnel_key.vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ uuu::upll_strncpy(vtunnel_key_if->vtunnel_key.vtunnel_name,
+ static_cast<key_vtunnel_if *>
+ (pkey)->vtunnel_key.vtunnel_name,
+ (kMaxLenVnodeName+1));
+ uuu::upll_strncpy(vtunnel_key_if->if_name,
+ static_cast<key_vtunnel_if *>(pkey)->if_name,
+ (kMaxLenInterfaceName+1));
+ break;
+ case UNC_KT_VLINK:
+ {
+ uint8_t *vnode_name, *if_name;
+ val_vlink *vlink_val = static_cast<val_vlink *>(GetVal(parent_key));
+ if (!vlink_val) {
+ free(vtunnel_key_if);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uint8_t flags = 0;
+ GET_USER_DATA_FLAGS(parent_key->get_cfg_val(), flags);
+ flags &= VLINK_FLAG_NODE_POS;
+ UPLL_LOG_DEBUG("Vlink flag node position %d", flags);
+ if (flags == kVlinkVnode1) {
+ vnode_name = vlink_val->vnode1_name;
+ if_name = vlink_val->vnode1_ifname;
+ } else {
+ cfgval_ctrlr = true;
+ vnode_name = vlink_val->vnode2_name;
+ if_name = vlink_val->vnode2_ifname;
+ }
+ uuu::upll_strncpy(vtunnel_key_if->vtunnel_key.vtn_key.vtn_name,
+ static_cast<key_vlink *>(pkey)->vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ if (vnode_name)
+ uuu::upll_strncpy(vtunnel_key_if->vtunnel_key.vtunnel_name,
+ vnode_name, (kMaxLenVnodeName+1));
+ if (if_name)
+ uuu::upll_strncpy(vtunnel_key_if->if_name, if_name,
+ (kMaxLenInterfaceName+1));
+ }
+ default:
+ break;
+ }
+ if (cfgval_ctrlr) {
+ SET_USER_DATA(okey, parent_key->get_cfg_val());
+ } else {
+ SET_USER_DATA(okey, parent_key);
+ }
+ return result_code;
+}
+
+upll_rc_t VtunnelIfMoMgr::GetParentConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *ikey) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ key_vtunnel_if *pkey = reinterpret_cast<key_vtunnel_if *>
+ ((ikey)?ikey->get_key():NULL);
+ if (!pkey) return UPLL_RC_ERR_GENERIC;
+
+ if (ikey->get_key_type() != UNC_KT_VTUNNEL_IF)
+ return UPLL_RC_ERR_GENERIC;
+ key_vtunnel *vtunnel_key = reinterpret_cast<key_vtunnel *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtunnel)));
+ if (!vtunnel_key) return UPLL_RC_ERR_GENERIC;
+ uuu::upll_strncpy(vtunnel_key->vtn_key.vtn_name,
+ (pkey)->vtunnel_key.vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ uuu::upll_strncpy(vtunnel_key->vtunnel_name, (pkey)->vtunnel_key.vtunnel_name,
+ (kMaxLenVnodeName+1));
+ if (okey) delete okey;
+ okey = new ConfigKeyVal(UNC_KT_VTUNNEL, IpctSt::kIpcStKeyVtunnel,
+ vtunnel_key, NULL);
+ if (okey == NULL) {
+ FREE_IF_NOT_NULL(vtunnel_key);
+ result_code = UPLL_RC_ERR_GENERIC;
+ } else {
+ SET_USER_DATA(okey, ikey);
+ }
+ return result_code;
+}
+
+
+upll_rc_t VtunnelIfMoMgr::AllocVal(ConfigVal *&ck_val,
+ upll_keytype_datatype_t dt_type, MoMgrTables tbl) {
+ UPLL_FUNC_TRACE;
+ void *val;
+ if (ck_val != NULL) return UPLL_RC_ERR_GENERIC;
+ switch (tbl) {
+ case MAINTBL:
+ val = reinterpret_cast<void *>(ConfigKeyVal::Malloc
+ (sizeof(val_vtunnel_if)));
+ if (!val) return UPLL_RC_ERR_GENERIC;
+ ck_val = new ConfigVal(IpctSt::kIpcStValVtunnelIf, val);
+ if (!ck_val) {
+ FREE_IF_NOT_NULL(reinterpret_cast<val_vtunnel_if *>(val));
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (dt_type == UPLL_DT_STATE) {
+ val = reinterpret_cast<void *>(ConfigKeyVal::Malloc
+ (sizeof(val_db_vtunnel_if_st)));
+ if (!val) {
+ delete ck_val;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ConfigVal *ck_nxtval = new ConfigVal(IpctSt::kIpcStValVtunnelIfSt, val);
+ if (!ck_nxtval) {
+ delete ck_val;
+ FREE_IF_NOT_NULL(reinterpret_cast<val_vtunnel_if_st *>(val));
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ck_val->AppendCfgVal(ck_nxtval);
+ }
+ break;
+ default:
+ val = NULL;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtunnelIfMoMgr::DupConfigKeyVal(ConfigKeyVal *&okey,
+ ConfigKeyVal *&req, MoMgrTables tbl) {
+ UPLL_FUNC_TRACE;
+ if (req == NULL) return UPLL_RC_ERR_GENERIC;
+ if (okey != NULL) return UPLL_RC_ERR_GENERIC;
+ if (req->get_key_type() != UNC_KT_VTUNNEL_IF)
+ return UPLL_RC_ERR_GENERIC;
+ ConfigVal *tmp1 = NULL, *tmp = (req)->get_cfg_val();
+
+ if (tmp) {
+ if (tbl == MAINTBL) {
+ val_vtunnel_if *ival = reinterpret_cast<val_vtunnel_if *>(GetVal(req));
+ val_vtunnel_if *vtunnel_val_if = reinterpret_cast<val_vtunnel_if *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtunnel_if)));
+ if (!vtunnel_val_if) return UPLL_RC_ERR_GENERIC;
+ memcpy(vtunnel_val_if, ival, sizeof(val_vtunnel_if));
+ tmp1 = new ConfigVal(IpctSt::kIpcStValVtunnelIf, vtunnel_val_if);
+ if (!tmp1) {
+ FREE_IF_NOT_NULL(vtunnel_val_if);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ tmp = tmp->get_next_cfg_val();
+ };
+ if (tmp) {
+ if (tbl == MAINTBL) {
+ val_db_vtunnel_if_st *ival = reinterpret_cast<val_db_vtunnel_if_st *>
+ (tmp->get_val());
+ val_db_vtunnel_if_st *val_db_vtunnel_if = reinterpret_cast<val_db_vtunnel_if_st *>
+ (ConfigKeyVal::Malloc(sizeof(val_db_vtunnel_if_st)));
+ if (!val_db_vtunnel_if) {
+ delete tmp1;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ memcpy(val_db_vtunnel_if, ival, sizeof(val_db_vtunnel_if_st));
+ ConfigVal *tmp2 = new ConfigVal(IpctSt::kIpcStValVtunnelIfSt,
+ val_db_vtunnel_if);
+ if (!tmp2) {
+ delete tmp1;
+ FREE_IF_NOT_NULL(val_db_vtunnel_if);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ tmp1->AppendCfgVal(tmp2);
+ }
+ }
+ void *tkey = (req != NULL)?(req)->get_key():NULL;
+ key_vtunnel_if *ikey = reinterpret_cast<key_vtunnel_if *>(tkey);
+ key_vtunnel_if *vtunnel_if_key = reinterpret_cast<key_vtunnel_if *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtunnel_if)));
+ memcpy(vtunnel_if_key, ikey, sizeof(key_vtunnel_if));
+ okey = new ConfigKeyVal(UNC_KT_VTUNNEL_IF, IpctSt::kIpcStKeyVtunnelIf,
+ vtunnel_if_key, tmp1);
+ if (okey) {
+ SET_USER_DATA(okey, req);
+ } else {
+ if (tmp1) delete tmp1;
+ FREE_IF_NOT_NULL(vtunnel_if_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtunnelIfMoMgr::UpdateConfigVal(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t datatype,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ ConfigKeyVal *okey = NULL;
+ uint8_t flag = 0;
+ if (!ikey || !dmi) {
+ UPLL_LOG_DEBUG("Invalid Input");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val_vtunnel_if *vtunnelif_val = static_cast<val_vtunnel_if *>
+ (GetVal(ikey));
+ if (!vtunnelif_val) {
+ UPLL_LOG_DEBUG("Value Structure is Null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ result_code = GetChildConfigKey(okey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("GetChildConfigKey Failure %d", result_code);
+ return result_code;
+ }
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag };
+ result_code = ReadConfigDB(okey, datatype, UNC_OP_READ, dbop,
+ dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Read failed %d", result_code);
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+ }
+ GET_USER_DATA_FLAGS(okey, flag);
+ if (vtunnelif_val->valid[UPLL_IDX_PORT_MAP_VTNL_IF] == UNC_VF_VALID ||
+ vtunnelif_val->valid[UPLL_IDX_PORT_MAP_VTNL_IF]
+ == UNC_VF_VALID_NO_VALUE) {
+ if (flag & VIF_TYPE) {
+ DELETE_IF_NOT_NULL(okey);
+ UPLL_LOG_DEBUG("Interface is linked/bounded with Vlink. "
+ "Could not update Portmap");
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ }
+ if (vtunnelif_val->valid[UPLL_IDX_PORT_MAP_VTNL_IF] ==
+ UNC_VF_VALID_NO_VALUE) {
+ vtunnelif_val->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] =
+ UNC_VF_VALID_NO_VALUE;
+ vtunnelif_val->portmap.valid[UPLL_IDX_VLAN_ID_PM] = UNC_VF_VALID_NO_VALUE;
+ vtunnelif_val->portmap.valid[UPLL_IDX_TAGGED_PM] = UNC_VF_VALID_NO_VALUE;
+ uuu::upll_strncpy(vtunnelif_val->portmap.logical_port_id, "\0", 1);
+ vtunnelif_val->portmap.vlan_id = 0;
+ vtunnelif_val->portmap.tagged = UPLL_VLAN_UNTAGGED;
+ }
+ DELETE_IF_NOT_NULL(okey);
+ return result_code;
+}
+
+upll_rc_t VtunnelIfMoMgr::AdaptValToVtnService(ConfigKeyVal *ikey) {
+ UPLL_FUNC_TRACE;
+ if (!ikey) {
+ UPLL_LOG_DEBUG("Invalid ikey");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ while (ikey) {
+ ConfigVal *cval = ikey->get_cfg_val();
+ if (!cval) {
+ UPLL_LOG_DEBUG("Config Val is Null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ while (cval) {
+ if (IpctSt::kIpcStValVtunnelIf == cval->get_st_num()) {
+ // set admin status to valid no value
+ val_vtunnel_if *vtunnelif_val = reinterpret_cast<val_vtunnel_if *>
+ (GetVal(ikey));
+ if (vtunnelif_val->valid[UPLL_IDX_ADMIN_ST_VTNL_IF] == UNC_VF_INVALID)
+ vtunnelif_val->valid[UPLL_IDX_ADMIN_ST_VTNL_IF] =
+ UNC_VF_VALID_NO_VALUE;
+
+ uint8_t vlink_flag = 0;
+ GET_USER_DATA_FLAGS(ikey, vlink_flag);
+ UPLL_LOG_DEBUG("Interface type %d", vlink_flag);
+ if (vlink_flag & VIF_TYPE)
+ vtunnelif_val->valid[UPLL_IDX_PORT_MAP_VTNL_IF] = UNC_VF_INVALID;
+ }
+ if (IpctSt::kIpcStValVtunnelIfSt == cval->get_st_num()) {
+ val_vtunnel_if_st *vtunnelif_stval =
+ reinterpret_cast<val_vtunnel_if_st *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtunnel_if_st)));
+ val_db_vtunnel_if_st *db_vtunnelif_stval =
+ reinterpret_cast<val_db_vtunnel_if_st *>(cval->get_val());
+ memcpy(vtunnelif_stval, &db_vtunnelif_stval->vtunnel_if_val_st,
+ sizeof(val_vtunnel_if_st));
+ cval->SetVal(IpctSt::kIpcStValVtunnelIfSt, vtunnelif_stval);
+ }
+ cval = cval->get_next_cfg_val();
+ }
+ ikey = ikey->get_next_cfg_key_val();
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+bool VtunnelIfMoMgr::FilterAttributes(void *&val1, void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op) {
+ UPLL_FUNC_TRACE;
+ val_vtunnel_if_t *val_vtunnelif1 = reinterpret_cast<val_vtunnel_if_t *>(val1);
+ /* No need to configure description in controller. */
+ val_vtunnelif1->valid[UPLL_IDX_DESC_VTNL_IF] = UNC_VF_INVALID;
+ if (op != UNC_OP_CREATE)
+ return CompareValidValue(val1, val2, copy_to_running);
+ return false;
+}
+
+bool VtunnelIfMoMgr::CompareValidValue(void *&val1, void *val2,
+ bool copy_to_running) {
+ UPLL_FUNC_TRACE;
+ bool invalid_attr = true;
+ val_vtunnel_if_t *val_vtunnelif1 = reinterpret_cast<val_vtunnel_if_t *>(val1);
+ val_vtunnel_if_t *val_vtunnelif2 = reinterpret_cast<val_vtunnel_if_t *>(val2);
+ for (unsigned int loop = 0;
+ loop < sizeof(val_vtunnelif1->valid)/sizeof(uint8_t); ++loop ) {
+ if (UNC_VF_INVALID == val_vtunnelif1->valid[loop]
+ && UNC_VF_VALID == val_vtunnelif2->valid[loop])
+ val_vtunnelif1->valid[loop] = UNC_VF_VALID_NO_VALUE;
+ }
+ if (UNC_VF_VALID == val_vtunnelif1->valid[UPLL_IDX_DESC_VTNL_IF]
+ && UNC_VF_VALID == val_vtunnelif2->valid[UPLL_IDX_DESC_VTNL_IF]) {
+ if (!strcmp(reinterpret_cast<char*>(val_vtunnelif1->description),
+ reinterpret_cast<char*>(val_vtunnelif2->description)))
+ val_vtunnelif1->valid[UPLL_IDX_DESC_VTNL_IF] = UNC_VF_INVALID;
+ }
+ if (UNC_VF_INVALID != val_vtunnelif1->valid[UPLL_IDX_ADMIN_ST_VTNL_IF]
+ && UNC_VF_INVALID != val_vtunnelif2->valid[UPLL_IDX_ADMIN_ST_VTNL_IF]) {
+ if (val_vtunnelif1->admin_status == val_vtunnelif2->admin_status)
+ val_vtunnelif1->valid[UPLL_IDX_ADMIN_ST_VTNL_IF] =
+ (copy_to_running)?UNC_VF_INVALID:
+ UNC_VF_VALUE_NOT_MODIFIED;
+ }
+ for (unsigned int loop = 0;
+ loop < sizeof(val_vtunnelif1->portmap.valid)/sizeof(uint8_t); ++loop ) {
+ if (UNC_VF_INVALID == val_vtunnelif1->portmap.valid[loop]
+ && UNC_VF_VALID == val_vtunnelif2->portmap.valid[loop])
+ val_vtunnelif1->portmap.valid[loop] = UNC_VF_VALID_NO_VALUE;
+ }
+ if (val_vtunnelif1->valid[UPLL_IDX_PORT_MAP_VTNL_IF] == UNC_VF_VALID
+ && val_vtunnelif2->valid[UPLL_IDX_PORT_MAP_VTNL_IF] == UNC_VF_VALID) {
+ if (memcmp(&(val_vtunnelif1->portmap), &(val_vtunnelif2->portmap),
+ sizeof(val_port_map_t))) {
+ if (val_vtunnelif1->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] ==
+ UNC_VF_VALID
+ && val_vtunnelif2->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM]
+ == UNC_VF_VALID) {
+ if (!strcmp(reinterpret_cast<char *>
+ (val_vtunnelif1->portmap.logical_port_id),
+ reinterpret_cast<char *>
+ (val_vtunnelif2->portmap.logical_port_id)))
+ val_vtunnelif1->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] =
+ (copy_to_running)?UNC_VF_INVALID:
+ UNC_VF_VALUE_NOT_MODIFIED;
+ }
+ if (val_vtunnelif1->portmap.valid[UPLL_IDX_VLAN_ID_PM] !=
+ UNC_VF_INVALID
+ && val_vtunnelif2->portmap.valid[UPLL_IDX_VLAN_ID_PM] !=
+ UNC_VF_INVALID) {
+ if (val_vtunnelif1->portmap.vlan_id == val_vtunnelif2->portmap.vlan_id)
+ val_vtunnelif1->portmap.valid[UPLL_IDX_VLAN_ID_PM] =
+ (copy_to_running)?UNC_VF_INVALID:
+ UNC_VF_VALUE_NOT_MODIFIED;
+ }
+ if (val_vtunnelif1->portmap.valid[UPLL_IDX_TAGGED_PM] !=
+ UNC_VF_INVALID
+ && val_vtunnelif2->portmap.valid[UPLL_IDX_TAGGED_PM] ==
+ UNC_VF_INVALID) {
+ if (val_vtunnelif1->portmap.tagged == val_vtunnelif2->portmap.tagged)
+ val_vtunnelif1->portmap.valid[UPLL_IDX_TAGGED_PM] =
+ (copy_to_running)?UNC_VF_INVALID:
+ UNC_VF_VALUE_NOT_MODIFIED;
+ }
+ } else {
+ val_vtunnelif1->valid[UPLL_IDX_PORT_MAP_VTNL_IF] =
+ (copy_to_running)?UNC_VF_INVALID:
+ UNC_VF_VALUE_NOT_MODIFIED;
+ val_vtunnelif1->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] =
+ (copy_to_running)?UNC_VF_INVALID:
+ UNC_VF_VALUE_NOT_MODIFIED;
+ val_vtunnelif1->portmap.valid[UPLL_IDX_VLAN_ID_PM] =
+ (copy_to_running)?UNC_VF_INVALID:
+ UNC_VF_VALUE_NOT_MODIFIED;
+ val_vtunnelif1->portmap.valid[UPLL_IDX_TAGGED_PM] =
+ (copy_to_running)?UNC_VF_INVALID:
+ UNC_VF_VALUE_NOT_MODIFIED;
+ }
+ }
+ if (!copy_to_running)
+ val_vtunnelif1->valid[UPLL_IDX_DESC_VTNL_IF] = UNC_VF_INVALID;
+ for (unsigned int loop = 0;
+ loop < sizeof(val_vtunnelif1->valid) / sizeof(uint8_t); ++loop) {
+ if ((UNC_VF_VALID == (uint8_t) val_vtunnelif1->valid[loop]) ||
+ (UNC_VF_VALID_NO_VALUE == (uint8_t) val_vtunnelif1->valid[loop])) {
+ if (loop == UPLL_IDX_PORT_MAP_VTNL_IF) {
+ for (unsigned int i = 0;
+ i < sizeof(val_vtunnelif1->portmap.valid) / sizeof(uint8_t); ++i) {
+ if ((UNC_VF_VALID == (uint8_t) val_vtunnelif1->portmap.valid[i]) ||
+ (UNC_VF_VALID_NO_VALUE ==
+ (uint8_t) val_vtunnelif1->portmap.valid[i])) {
+ invalid_attr = false;
+ break;
+ }
+ }
+ } else {
+ invalid_attr = false;
+ }
+ if (invalid_attr == false) break;
+ }
+ }
+ return invalid_attr;
+}
+
+upll_rc_t VtunnelIfMoMgr::UpdateConfigStatus(ConfigKeyVal *vtunnelif_keyval,
+ unc_keytype_operation_t op,
+ uint32_t driver_result,
+ ConfigKeyVal *upd_key,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ctrlr_key) {
+ UPLL_FUNC_TRACE;
+ val_vtunnel_if_t *vtunnel_if_val =
+ static_cast<val_vtunnel_if_t *>(GetVal(vtunnelif_keyval));
+ if (vtunnel_if_val == NULL) return UPLL_RC_ERR_GENERIC;
+ unc_keytype_configstatus_t cs_status = (driver_result == UPLL_RC_SUCCESS)?
+ UNC_CS_APPLIED:UNC_CS_NOT_APPLIED;
+ UPLL_LOG_TRACE("DriverResult %d, ConfigStatus %d", driver_result, cs_status);
+ UPLL_LOG_TRACE("%s", (vtunnelif_keyval->ToStrAll()).c_str());
+ val_vtunnel_if_t *val_running = static_cast<val_vtunnel_if_t *>
+ (GetVal(upd_key));
+ if (op == UNC_OP_CREATE) {
+ vtunnel_if_val->cs_row_status = cs_status;
+ val_db_vtunnel_if_st *vtunnel_db_valst = static_cast<val_db_vtunnel_if_st *>
+ (ConfigKeyVal::Malloc(sizeof(val_db_vtunnel_if_st)));
+ if (vtunnel_db_valst == NULL) return UPLL_RC_ERR_GENERIC;
+ vtunnelif_keyval->AppendCfgVal(IpctSt::kIpcStValVtunnelIfSt,
+ vtunnel_db_valst);
+#if 0
+ upll_rc_t result_code = InitOperStatus<val_vtunnel_if_st,
+ val_db_vtunnel_if_st>
+ (vtunnelif_keyval,
+ vtunnel_if_val->valid[UPLL_IDX_ADMIN_ST_VTNL_IF],
+ vtunnel_if_val->admin_status,
+ vtunnel_if_val->valid[UPLL_IDX_PORT_MAP_VTNL_IF],
+ &vtunnel_if_val->portmap);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Error settiing oper status");
+ return UPLL_RC_ERR_GENERIC;
+ }
+#else
+ val_vtunnel_if_st *vnif_st = &vtunnel_db_valst->vtunnel_if_val_st;
+ if (!vnif_st) {
+ UPLL_LOG_DEBUG("Returning error\n");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ vnif_st->oper_status = UPLL_OPER_STATUS_UP;
+ vnif_st->valid[UPLL_IDX_IF_OPER_STATUS_VTEPIS] = UNC_VF_VALID;
+#endif
+ vtunnel_db_valst->down_count = 0;
+ } else if (op == UNC_OP_UPDATE) {
+ void *val = reinterpret_cast<void *>(vtunnel_if_val);
+ CompareValidValue(val, GetVal(upd_key), true);
+ UPLL_LOG_TRACE("%s", (upd_key->ToStrAll()).c_str());
+ vtunnel_if_val->cs_row_status =
+ val_running->cs_row_status;
+ } else {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ for (unsigned int loop = 0; loop <
+ sizeof(vtunnel_if_val->valid) / sizeof(vtunnel_if_val->valid[0]);
+ ++loop) {
+ if ((UNC_VF_VALID == (uint8_t) vtunnel_if_val->valid[loop])
+ || (UNC_VF_VALID_NO_VALUE == (uint8_t) vtunnel_if_val->valid[loop])) {
+ if (loop == UPLL_IDX_DESC_VTNL_IF)
+ vtunnel_if_val->cs_attr[loop] = UNC_CS_APPLIED;
+ else
+ vtunnel_if_val->cs_attr[loop] = cs_status;
+ } else if ((UNC_VF_INVALID == vtunnel_if_val->valid[loop]) &&
+ (UNC_OP_CREATE == op)) {
+ vtunnel_if_val->cs_attr[loop] = UNC_CS_APPLIED;
+ } else if ((vtunnel_if_val->valid[loop] == UNC_VF_INVALID) &&
+ (UNC_OP_UPDATE == op)) {
+ vtunnel_if_val->cs_attr[loop] =
+ val_running->cs_attr[loop];
+ }
+ }
+ for (unsigned int loop = 0;
+ loop < sizeof(vtunnel_if_val->portmap.valid)/
+ sizeof(vtunnel_if_val->portmap.valid[0]); ++loop ) {
+ if ((UNC_VF_VALID == vtunnel_if_val->portmap.valid[loop])
+ || (UNC_VF_VALID_NO_VALUE == vtunnel_if_val->portmap.valid[loop]))
+ vtunnel_if_val->portmap.cs_attr[loop] = cs_status;
+ else if ((UNC_VF_INVALID == vtunnel_if_val->portmap.valid[loop]) &&
+ (UNC_OP_CREATE == op))
+ vtunnel_if_val->portmap.cs_attr[loop] = UNC_CS_APPLIED;
+ else if ((UNC_VF_INVALID == vtunnel_if_val->portmap.valid[loop]) &&
+ (UNC_OP_UPDATE == op))
+ vtunnel_if_val->portmap.cs_attr[loop] =
+ val_running->portmap.cs_attr[loop];
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtunnelIfMoMgr::UpdateAuditConfigStatus(
+ unc_keytype_configstatus_t cs_status,
+ uuc::UpdateCtrlrPhase phase,
+ ConfigKeyVal *&ckv_running) {
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_vtunnel_if_t *val;
+ val = (ckv_running != NULL)?reinterpret_cast<val_vtunnel_if_t *>
+ (GetVal(ckv_running)):NULL;
+ if (NULL == val) {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (uuc::kUpllUcpCreate == phase )
+ val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
+ for (unsigned int loop = 0; loop < sizeof(val->valid)/sizeof(uint8_t);
+ ++loop ) {
+ if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
+ cs_status == UNC_CS_APPLIED)
+ val->cs_attr[loop] = cs_status;
+ }
+ for (unsigned int loop = 0;
+ loop < sizeof(val->portmap.valid) / sizeof(uint8_t); ++loop) {
+ if ((cs_status == UNC_CS_INVALID &&
+ UNC_VF_VALID == val->portmap.valid[loop])
+ || cs_status == UNC_CS_APPLIED)
+ val->portmap.cs_attr[loop] = cs_status;
+ }
+ return result_code;
+}
+
+upll_rc_t VtunnelIfMoMgr::ValidateMessage(IpcReqRespHeader *req,
+ ConfigKeyVal *ikey) {
+ UPLL_FUNC_TRACE;
+
+ upll_rc_t ret_val = UPLL_RC_ERR_GENERIC;
+ if (!ikey || !req || !(ikey->get_key())) {
+ UPLL_LOG_DEBUG("IpcReqRespHeader or ConfigKeyVal is Null");
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ unc_key_type_t ktype = ikey->get_key_type();
+ if (UNC_KT_VTUNNEL_IF != ktype) {
+ UPLL_LOG_DEBUG("Invalid keytype. Keytype- %d", ktype);
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ if (ikey->get_st_num() != IpctSt::kIpcStKeyVtunnelIf) {
+ UPLL_LOG_DEBUG("Invalid structure received.Expected struct-"
+ "kIpcStKeyVtunnelIf, received struct -%s ",
+ reinterpret_cast<const char *>
+ (IpctSt::GetIpcStdef(ikey->get_st_num())));
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ key_vtunnel_if_t *key_vtunnel_if = reinterpret_cast<key_vtunnel_if_t *>
+ (ikey->get_key());
+
+ uint32_t dt_type = req->datatype;
+ uint32_t operation = req->operation;
+ uint32_t option1 = req->option1;
+ uint32_t option2 = req->option2;
+
+ ret_val = ValidateVTunnelIfKey(key_vtunnel_if, operation);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Key struct Validation failed for VTUNNEL_IF");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ } else {
+ if ((operation == UNC_OP_UPDATE) && (dt_type == UPLL_DT_CANDIDATE)) {
+ val_vtunnel_if_t *val_vtunnel_if = NULL;
+ if ((ikey->get_cfg_val()) &&
+ (ikey->get_cfg_val()->get_st_num() == IpctSt::kIpcStValVtunnelIf)) {
+ val_vtunnel_if =
+ reinterpret_cast<val_vtunnel_if_t *> (ikey->get_cfg_val()->get_val());
+ }
+ if (val_vtunnel_if != NULL) {
+ ret_val = ValidateVTunnelIfValue(val_vtunnel_if, operation);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Val struct Validation failed for UPDATE op");
+ return ret_val;
+ }
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_DEBUG("Value structure mandatory for UPDATE op");
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ } else if ((operation == UNC_OP_CREATE) &&
+ (dt_type == UPLL_DT_CANDIDATE)) {
+ val_vtunnel_if_t *val_vtunnel_if = NULL;
+ if ((ikey->get_cfg_val()) &&
+ (ikey->get_cfg_val()->get_st_num() == IpctSt::kIpcStValVtunnelIf)) {
+ val_vtunnel_if =
+ reinterpret_cast<val_vtunnel_if_t *> (ikey->get_cfg_val()->get_val());
+ }
+ if (val_vtunnel_if != NULL) {
+ ret_val = ValidateVTunnelIfValue(val_vtunnel_if, operation);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Val struct Validation failed for CREATE op");
+ return ret_val;
+ }
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_DEBUG("Value structure is an optional for CREATE op");
+ return UPLL_RC_SUCCESS;
+ }
+ } else if (((operation == UNC_OP_READ) ||
+ (operation == UNC_OP_READ_SIBLING) ||
+ (operation == UNC_OP_READ_SIBLING_BEGIN) ||
+ (operation == UNC_OP_READ_SIBLING_COUNT)) &&
+ ((dt_type == UPLL_DT_CANDIDATE) ||
+ ((dt_type == UPLL_DT_RUNNING) ||
+ (dt_type == UPLL_DT_STARTUP) ||
+ (dt_type == UPLL_DT_STATE)))) {
+ if (option1 == UNC_OPT1_NORMAL) {
+ if (option2 == UNC_OPT2_NONE) {
+ val_vtunnel_if_t *val_vtunnel_if = NULL;
+ if ((ikey->get_cfg_val()) &&
+ (ikey->get_cfg_val()->get_st_num() ==
+ IpctSt::kIpcStValVtunnelIf)) {
+ val_vtunnel_if =
+ reinterpret_cast<val_vtunnel_if_t *>
+ (ikey->get_cfg_val()->get_val());
+ }
+ if (val_vtunnel_if != NULL) {
+ ret_val = ValidateVTunnelIfValue(val_vtunnel_if);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Val struct Validation failed for READ op");
+ return ret_val;
+ }
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_DEBUG("Value structure is an optional for READ op");
+ return UPLL_RC_SUCCESS;
+ }
+ } else if ((option2 == UNC_OPT2_NEIGHBOR) &&
+ (operation == UNC_OP_READ) &&
+ (dt_type == UPLL_DT_STATE)) {
+ val_vtn_neighbor_t *val_vtn_neighbor = NULL;
+ if ((ikey->get_cfg_val()) && ((ikey->get_cfg_val())->get_st_num() ==
+ IpctSt::kIpcStValVtnNeighbor)) {
+ val_vtn_neighbor = reinterpret_cast <val_vtn_neighbor_t *>
+ (ikey->get_cfg_val()->get_val());
+ }
+ if (val_vtn_neighbor != NULL) {
+ ret_val = ValidateVtnNeighborValue(val_vtn_neighbor);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Val struct Validation failed for READ op");
+ return ret_val;
+ }
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_DEBUG("Value structure is an optional for READ op");
+ return UPLL_RC_SUCCESS;
+ }
+ } else {
+ UPLL_LOG_DEBUG("Option2 is not matching");
+ return UPLL_RC_ERR_INVALID_OPTION2;
+ }
+ } else {
+ UPLL_LOG_DEBUG("Option1 is not matching");
+ return UPLL_RC_ERR_INVALID_OPTION1;
+ }
+
+ } else if ((operation == UNC_OP_DELETE) ||
+ (operation == UNC_OP_READ_SIBLING_COUNT) ||
+ (((operation == UNC_OP_READ_NEXT) ||
+ (operation == UNC_OP_READ_BULK)) &&
+ ((dt_type == UPLL_DT_CANDIDATE) ||
+ (dt_type == UPLL_DT_RUNNING) ||
+ (dt_type == UPLL_DT_STARTUP)))) {
+ UPLL_LOG_TRACE("Value structure is none for this operation:%d",
+ operation);
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_DEBUG("Invalid datatype(%d) and operation(%d)", dt_type,
+ operation);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+upll_rc_t VtunnelIfMoMgr::ValidateVTunnelIfValue(
+ val_vtunnel_if_t *val_vtunnel_if,
+ uint32_t operation) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ if (val_vtunnel_if->valid[UPLL_IDX_DESC_VTNL_IF] == UNC_VF_VALID) {
+ if (!ValidateDesc(val_vtunnel_if->description,
+ kMinLenDescription, kMaxLenDescription)) {
+ UPLL_LOG_DEBUG(
+ "Syntax check failed.Desc- (%s)", val_vtunnel_if->description);
+ return ret_val;
+ }
+ } else if ((val_vtunnel_if->valid[UPLL_IDX_DESC_VTNL_IF] ==
+ UNC_VF_VALID_NO_VALUE) &&
+ ((operation == UNC_OP_UPDATE) || (operation == UNC_OP_CREATE))) {
+ val_vtunnel_if->description[0] = '\0';
+ }
+
+ if (val_vtunnel_if->valid[UPLL_IDX_ADMIN_ST_VTNL_IF] == UNC_VF_VALID) {
+ if (!ValidateNumericRange(val_vtunnel_if->admin_status,
+ (uint8_t) UPLL_ADMIN_ENABLE,
+ (uint8_t) UPLL_ADMIN_DISABLE, true, true)) {
+ UPLL_LOG_DEBUG(
+ "Syntax check failed.Admin_status- %d", val_vtunnel_if->admin_status);
+ return ret_val;
+ }
+ } else if ((val_vtunnel_if->valid[UPLL_IDX_ADMIN_ST_VTNL_IF] ==
+ UNC_VF_VALID_NO_VALUE) &&
+ ((operation == UNC_OP_UPDATE) || (operation == UNC_OP_CREATE))) {
+ val_vtunnel_if->admin_status = UPLL_ADMIN_ENABLE;
+ } else if (
+ (val_vtunnel_if->valid[UPLL_IDX_ADMIN_ST_VTNL_IF] == UNC_VF_INVALID)
+ && (operation == UNC_OP_CREATE)) {
+ val_vtunnel_if->valid[UPLL_IDX_ADMIN_ST_VTNL_IF] = UNC_VF_VALID_NO_VALUE;
+ val_vtunnel_if->admin_status = UPLL_ADMIN_ENABLE;
+ }
+ if (val_vtunnel_if->valid[UPLL_IDX_PORT_MAP_VTNL_IF] == UNC_VF_VALID) {
+ if (val_vtunnel_if->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM]
+ == UNC_VF_VALID) {
+ if (!ValidateStringRange(
+ reinterpret_cast<char *>(val_vtunnel_if->portmap.logical_port_id),
+ kMinLenLogicalPortId, kMaxLenLogicalPortId)) {
+ UPLL_LOG_DEBUG("Logical Port id syntax check failed."
+ "Received Logical Port Id - %s",
+ val_vtunnel_if->portmap.logical_port_id);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ if (toupper(val_vtunnel_if->portmap.logical_port_id[0]) == 'S'
+ && toupper(val_vtunnel_if->portmap.logical_port_id[1]) == 'W') {
+ UPLL_LOG_DEBUG("Invalid logical_port_id - %s",
+ val_vtunnel_if->portmap.logical_port_id);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ } else if (val_vtunnel_if->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] ==
+ UNC_VF_VALID_NO_VALUE
+ && (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE)) {
+ uuu::upll_strncpy(val_vtunnel_if->portmap.logical_port_id, " ",
+ kMaxLenLogicalPortId+1);
+ }
+ if (val_vtunnel_if->portmap.valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID) {
+ if ((val_vtunnel_if->portmap.vlan_id != 0xFFFF) &&
+ !ValidateNumericRange(val_vtunnel_if->portmap.vlan_id,
+ (uint16_t) kMinVlanId, (uint16_t) kMaxVlanId,
+ true, true)) {
+ UPLL_LOG_DEBUG("Vlan Id Number check failed."
+ "Received vlan_id - %d",
+ val_vtunnel_if->portmap.vlan_id);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ } else if (val_vtunnel_if->portmap.valid[UPLL_IDX_VLAN_ID_PM]
+ == UNC_VF_VALID_NO_VALUE
+ && (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE)) {
+ val_vtunnel_if->portmap.vlan_id = 0;
+ }
+ if (val_vtunnel_if->portmap.valid[UPLL_IDX_TAGGED_PM] == UNC_VF_VALID) {
+ if (!ValidateNumericRange((uint8_t) val_vtunnel_if->portmap.tagged,
+ (uint8_t) UPLL_VLAN_UNTAGGED,
+ (uint8_t) UPLL_VLAN_TAGGED, true, true)) {
+ UPLL_LOG_DEBUG("Tagged Numeric range check failed."
+ "Received Tag - %d",
+ val_vtunnel_if->portmap.tagged);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ } else if (((val_vtunnel_if->portmap.valid[UPLL_IDX_TAGGED_PM]
+ == UNC_VF_VALID_NO_VALUE) ||
+ (val_vtunnel_if->portmap.valid[UPLL_IDX_TAGGED_PM]
+ == UNC_VF_INVALID))
+ && (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE)) {
+ if (val_vtunnel_if->portmap.valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID)
+ val_vtunnel_if->portmap.tagged = UPLL_VLAN_TAGGED;
+ else
+ val_vtunnel_if->portmap.tagged = UPLL_VLAN_UNTAGGED;
+ val_vtunnel_if->portmap.valid[UPLL_IDX_TAGGED_PM] = UNC_VF_VALID;
+ }
+ } else if ((val_vtunnel_if->valid[UPLL_IDX_PORT_MAP_VTNL_IF] ==
+ UNC_VF_VALID_NO_VALUE)
+ && (operation == UNC_OP_UPDATE || operation == UNC_OP_CREATE)) {
+ memset(&(val_vtunnel_if->portmap), 0, sizeof(val_vtunnel_if->portmap));
+ }
+
+ return UPLL_RC_SUCCESS;
+}
+upll_rc_t VtunnelIfMoMgr::ValidateVTunnelIfKey(
+ key_vtunnel_if_t *key_vtunnel_if,
+ uint32_t operation) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ ret_val = ValidateKey(
+ reinterpret_cast<char *>(key_vtunnel_if->vtunnel_key.vtn_key.vtn_name),
+ kMinLenVtnName, kMaxLenVtnName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("Vtn Name syntax check failed."
+ "Received VTN Name - %s",
+ key_vtunnel_if->vtunnel_key.vtn_key.vtn_name);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ ret_val = ValidateKey(
+ reinterpret_cast<char *>(key_vtunnel_if->vtunnel_key.vtunnel_name),
+ kMinLenVnodeName, kMaxLenVnodeName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("Vtunnel Name syntax check failed."
+ "Received Vtunnel Name -%s",
+ key_vtunnel_if->vtunnel_key.vtunnel_name);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ if ((operation != UNC_OP_READ_SIBLING_BEGIN) &&
+ (operation != UNC_OP_READ_SIBLING_COUNT)) {
+ ret_val = ValidateKey(reinterpret_cast<char *>(key_vtunnel_if->if_name),
+ kMinLenInterfaceName, kMaxLenInterfaceName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG(
+ "Syntax check failed.if_name- (%s)", key_vtunnel_if->if_name);
+ return ret_val;
+ }
+ } else {
+ UPLL_LOG_TRACE("Operation is %d", operation);
+ StringReset(key_vtunnel_if->if_name);
+ }
+ UPLL_LOG_INFO("key structure validation successful for keytype VTUNNEL IF");
+ return ret_val;
+}
+upll_rc_t VtunnelIfMoMgr::ValidateVtnNeighborValue(
+ val_vtn_neighbor_t *val_vtn_neighbor) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+
+ if (val_vtn_neighbor->valid[UPLL_IDX_CONN_VNODE_NAME_VN] == UNC_VF_VALID) {
+ ret_val = ValidateKey(
+ reinterpret_cast<char *>(val_vtn_neighbor->connected_vnode_name),
+ kMinLenVnodeName, kMaxLenVnodeName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Syntax check failed.conn_vnode_name-(%s)",
+ val_vtn_neighbor->connected_vnode_name);
+ return ret_val;
+ }
+ }
+ if (val_vtn_neighbor->valid[UPLL_IDX_CONN_VNODE_IF_NAME_VN]
+ == UNC_VF_VALID) {
+ ret_val = ValidateKey(
+ reinterpret_cast<char *>(val_vtn_neighbor->connected_if_name),
+ kMinLenInterfaceName, kMaxLenInterfaceName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Syntax check failed. connected_if_name-%s",
+ val_vtn_neighbor->connected_if_name);
+ return ret_val;
+ }
+ }
+ if (val_vtn_neighbor->valid[UPLL_IDX_CONN_VLINK_NAME_VN] == UNC_VF_VALID) {
+ ret_val = ValidateKey(
+ reinterpret_cast<char *>(val_vtn_neighbor->connected_vlink_name),
+ kMinLenVlinkName, kMaxLenVlinkName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Syntax check failed.connected_vlink_name=%s",
+ val_vtn_neighbor->connected_vlink_name);
+ return ret_val;
+ }
+ }
+ UPLL_LOG_TRACE("value structure validation successful for vunk_If keytype");
+ return ret_val;
+}
+upll_rc_t VtunnelIfMoMgr::ValVTunnelIfAttributeSupportCheck(
+ val_vtunnel_if_t *val_vtunnel_if,
+ const uint8_t* attrs, unc_keytype_operation_t operation) {
+ UPLL_FUNC_TRACE;
+ if ((val_vtunnel_if->valid[UPLL_IDX_DESC_VTNL_IF] == UNC_VF_VALID)
+ || (val_vtunnel_if->valid[UPLL_IDX_DESC_VTNL_IF]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtunnel_if::kCapDesc] == 0) {
+ val_vtunnel_if->valid[UPLL_IDX_DESC_VTNL_IF] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("Descvtnl not supported in pfc controller");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ }
+ if ((val_vtunnel_if->valid[UPLL_IDX_ADMIN_ST_VTNL_IF] == UNC_VF_VALID)
+ || (val_vtunnel_if->valid[UPLL_IDX_ADMIN_ST_VTNL_IF]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtunnel_if::kCapAdminStatus] == 0) {
+ val_vtunnel_if->valid[UPLL_IDX_ADMIN_ST_VTNL_IF] =
+ UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("AdminStatus not supported in pfc controller");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ }
+ if ((val_vtunnel_if->valid[UPLL_IDX_PORT_MAP_VTNL_IF] == UNC_VF_VALID) ||
+ (val_vtunnel_if->valid[UPLL_IDX_PORT_MAP_VTNL_IF] ==
+ UNC_VF_VALID_NO_VALUE)) {
+ if ((val_vtunnel_if->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] ==
+ UNC_VF_VALID)
+ || (val_vtunnel_if->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtunnel_if::kCapLogicalPortId] == 0) {
+ val_vtunnel_if->portmap.valid[UPLL_IDX_LOGICAL_PORT_ID_PM] =
+ UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("portmap.swich_id attr is not supported by ctrlr ");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ }
+ if ((val_vtunnel_if->portmap.valid[UPLL_IDX_VLAN_ID_PM] == UNC_VF_VALID)
+ || (val_vtunnel_if->portmap.valid[UPLL_IDX_VLAN_ID_PM]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtunnel_if::kCapVlanId] == 0) {
+ val_vtunnel_if->portmap.valid[UPLL_IDX_VLAN_ID_PM] =
+ UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("portmap.vlanid attr is not supported by ctrlr ");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ }
+ if ((val_vtunnel_if->portmap.valid[UPLL_IDX_TAGGED_PM] == UNC_VF_VALID)
+ || (val_vtunnel_if->portmap.valid[UPLL_IDX_TAGGED_PM]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtunnel_if::kCapTagged] == 0) {
+ val_vtunnel_if->portmap.valid[UPLL_IDX_TAGGED_PM] =
+ UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_DEBUG("portmap.Tagged attr is not supported by ctrlr ");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+upll_rc_t VtunnelIfMoMgr::ValidateCapability(IpcReqRespHeader *req,
+ ConfigKeyVal *ikey, const char *ctrlr_name) {
+ UPLL_FUNC_TRACE;
+ if (!ikey || !req) {
+ UPLL_LOG_DEBUG("ConfigKeyVal / IpcReqRespHeader is Null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+
+ if (!ctrlr_name) {
+ ctrlr_name = reinterpret_cast<char*>((reinterpret_cast<key_user_data_t *>
+ (ikey->get_user_data()))->ctrlr_id);
+ if (!ctrlr_name || !strlen(ctrlr_name)) {
+ UPLL_LOG_DEBUG("Controller Name is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+
+ UPLL_LOG_TRACE("ctrlr_name(%s), operation : (%d)",
+ ctrlr_name, req->operation);
+
+ bool result_code = false;
+ uint32_t max_instance_count = 0;
+ uint32_t max_attrs = 0;
+ const uint8_t *attrs = NULL;
+
+ switch (req->operation) {
+ case UNC_OP_CREATE:
+ result_code = GetCreateCapability(ctrlr_name,
+ ikey->get_key_type(), &max_instance_count, &max_attrs, &attrs);
+ if (result_code && (max_instance_count != 0) &&
+ cur_instance_count >= max_instance_count) {
+ UPLL_LOG_DEBUG("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
+ __LINE__, __FUNCTION__, cur_instance_count, max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
+ break;
+
+ case UNC_OP_UPDATE:
+ result_code = GetUpdateCapability(ctrlr_name,
+ ikey->get_key_type(), &max_attrs, &attrs);
+ break;
+
+ case UNC_OP_READ:
+ case UNC_OP_READ_SIBLING:
+ case UNC_OP_READ_SIBLING_BEGIN:
+ case UNC_OP_READ_SIBLING_COUNT:
+ result_code = GetReadCapability(ctrlr_name,
+ ikey->get_key_type(), &max_attrs, &attrs);
+ break;
+
+ default:
+ UPLL_LOG_DEBUG("Invalid operation");
+ break;
+ }
+
+ if (!result_code) {
+ UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s) "
+ "for operation(%d)",
+ ikey->get_key_type(), ctrlr_name, req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ val_vtunnel_if_t *val_vtunnel_if = NULL;
+ if ((ikey->get_cfg_val()) &&
+ (ikey->get_cfg_val()->get_st_num() == IpctSt::kIpcStValVtunnelIf)) {
+ val_vtunnel_if =
+ reinterpret_cast<val_vtunnel_if_t *> (ikey->get_cfg_val()->get_val());
+ }
+
+ if (val_vtunnel_if) {
+ if (max_attrs > 0) {
+ return ValVTunnelIfAttributeSupportCheck(val_vtunnel_if, attrs,
+ req->operation);
+ } else {
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d",
+ req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtunnelIfMoMgr::IsReferenced(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type, DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ ConfigKeyVal *okey = NULL;
+ if (!ikey || !(ikey->get_key()) ||!dmi )
+ return UPLL_RC_ERR_GENERIC;
+ GetChildConfigKey(okey, ikey);
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutFlag };
+ upll_rc_t result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ if (okey) delete okey;
+ return result_code;
+ }
+ ConfigKeyVal *tmp = okey;
+ while (okey) {
+ uint8_t vlink_flag = 0;
+ GET_USER_DATA_FLAGS(okey, vlink_flag);
+ if (vlink_flag & VIF_TYPE) {
+ delete tmp;
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ okey = okey->get_next_cfg_key_val();
+ }
+ if (tmp) delete tmp;
+ return result_code;
+}
+
+upll_rc_t VtunnelIfMoMgr::PopulateDriverDeleteCkv(ConfigKeyVal *&vnpCkv,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t dt_type) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result = UPLL_RC_SUCCESS;
+ ConfigKeyVal *vtunnelCkv = NULL;
+ if (!vnpCkv) {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ VtunnelMoMgr *vtunnelObj = reinterpret_cast<VtunnelMoMgr*>
+ (const_cast<MoManager *>(GetMoManager(UNC_KT_VTUNNEL)));
+ if (NULL == vtunnelObj) {
+ UPLL_LOG_DEBUG("Unable to get UNC_KT_VTUNNEL object");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val_vtunnel_if *vtunnelif_val = static_cast<val_vtunnel_if *>(GetVal(vnpCkv));
+ if (!vtunnelif_val) {
+ UPLL_LOG_TRACE("Value Strucure is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ // Retrieving attribute label from Vtunnel
+ result = GetParentConfigKey(vtunnelCkv, vnpCkv);
+ if (result != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("GetParentConfigKey returned %d", result);
+ DELETE_IF_NOT_NULL(vtunnelCkv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutFlag };
+ result = vtunnelObj->ReadConfigDB(vtunnelCkv, dt_type, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if ((result != UPLL_RC_SUCCESS) || (!vtunnelCkv)
+ || (!(vtunnelCkv->get_cfg_val()))) {
+ UPLL_LOG_TRACE("Could not retrieve Vtunnel data. DB returned %d", result);
+ DELETE_IF_NOT_NULL(vtunnelCkv);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ vnpdrv_val_vtunnel_if *vnp_vtunnel_if = static_cast<vnpdrv_val_vtunnel_if *>
+ (ConfigKeyVal::Malloc(sizeof(vnpdrv_val_vtunnel_if)));
+ val_vtunnel *vtunnel_val = static_cast<val_vtunnel *>(GetVal(vtunnelCkv));
+ vnp_vtunnel_if->label = vtunnel_val->label;
+ vnp_vtunnel_if->valid[VNPDRV_IDX_LABEL_VTNL_IF] = UNC_VF_VALID;
+ vnp_vtunnel_if->vlan_id = vtunnelif_val->portmap.vlan_id;
+ vnp_vtunnel_if->valid[VNPDRV_IDX_VLAN_ID_VTNL_IF] = UNC_VF_VALID;
+
+ ConfigVal *ck_val = new ConfigVal(IpctSt::kIpcStVnpdrvValVtunnelIf,
+ vnp_vtunnel_if);
+ vnpCkv->SetCfgVal(ck_val);
+ DELETE_IF_NOT_NULL(vtunnelCkv);
+ return result;
+}
+
+} // namesapce vtn
+} // namespace upll
+} // namespace unc
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 NEC Corporation
+ * All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+#ifndef UNC_UPLL_VTUNNEL_IF_MOMGR_H
+#define UNC_UPLL_VTUNNEL_IF_MOMGR_H
+
+#include <set>
+#include "momgr_impl.hh"
+#include "vnode_child_momgr.hh"
+#include "unc/vnpdriver_ipc_enum.h"
+
+namespace unc {
+namespace upll {
+namespace kt_momgr {
+
+enum VtunnelIfMoMgrTables {
+ VTUNNELIFTBL = 0,
+ NVTUNNELIFTABLES
+};
+
+
+class VtunnelIfMoMgr : public VnodeChildMoMgr {
+ private:
+ static BindInfo vtunnel_if_bind_info[];
+
+ /* @brief Returns admin and portmap information if portmap is
+ * valid. Else returns NULL for portmap
+ *
+ * @param[in] ikey Pointer to ConfigKeyVal
+ * @param[out] valid_pm portmap is valid
+ * @param[out] pm pointer to portmap informtation if valid_pm
+ * @param[out] valid_admin admin_status valid value
+ * @param[out] admin_status value of admin_status
+ *
+ * @retval UPLL_RC_SUCCESS Completed successfully.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ *
+ **/
+ virtual upll_rc_t GetPortMap(ConfigKeyVal *ikey, uint8_t &valid_pm,
+ val_port_map_t *&pm,
+ uint8_t &valid_admin,
+ uint8_t &admin_status) {
+ UPLL_FUNC_TRACE;
+ if (ikey == NULL) return UPLL_RC_ERR_GENERIC;
+ val_vtunnel_if *ifval = reinterpret_cast<val_vtunnel_if *>
+ (GetVal(ikey));
+ if (!ifval) {
+ UPLL_LOG_DEBUG("Invalid param");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ valid_pm = ifval->valid[UPLL_IDX_PORT_MAP_VTNL_IF];
+ if (valid_pm == UNC_VF_VALID)
+ pm = &ifval->portmap;
+ else
+ pm = NULL;
+ valid_admin = ifval->valid[UPLL_IDX_ADMIN_ST_VTNL_IF];
+ admin_status = ifval->admin_status;
+ return UPLL_RC_SUCCESS;
+ }
+
+ /**
+ * @brief Gets the valid array position of the variable in the value
+ * structure from the table in the specified configuration
+ *
+ * @param[in] val pointer to the value structure
+ * @param[in] indx database index for the variable
+ * @param[out] valid position of the variable in the valid array -
+ * NULL if valid does not exist.
+ * @param[in] dt_type specifies the configuration
+ * @param[in] tbl specifies the table containing the given value
+ *
+ **/
+ upll_rc_t GetValid(void *val, uint64_t indx, uint8_t *&valid,
+ upll_keytype_datatype_t dt_type, MoMgrTables tbl);
+
+ upll_rc_t CopyToConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *ikey) {
+ return UPLL_RC_SUCCESS;
+ }
+ bool GetRenameKeyBindInfo(unc_key_type_t key_type, BindInfo *&binfo,
+ int &nattr,
+ MoMgrTables tbl) {
+ return true;
+ }
+ /**
+ * @brief Filters the attributes which need not be sent to controller
+ *
+ * @param[in/out] val1 first record value instance.
+ * @param[in] val2 second record value instance.
+ * @param[in] audit Not used for VTN
+ * @param[in] op Operation to be performed
+ *
+ **/
+ bool FilterAttributes(void *&val1, void *val2, bool copy_to_running,
+ unc_keytype_operation_t op);
+
+ /**
+ * @brief Compares the valid value between two database records.
+ * if both the values are same, update the valid flag for corresponding
+ * attribute as invalid in the first record.
+ *
+ * @param[in/out] val1 first record value instance.
+ * @param[in] val2 second record value instance.
+ * @param[in] audit if true, CompareValidValue called from audit process..
+ *
+ **/
+ bool CompareValidValue(void *&val1, void *val2, bool copy_to_running);
+
+ upll_rc_t ValidateAttribute(ConfigKeyVal *ikey,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req);
+ /**
+ * @brief Duplicates the input configkeyval including the key and val.
+ * based on the tbl specified.
+ *
+ * @param[in] okey Output Configkeyval - allocated within the function
+ * @param[in] req Input ConfigKeyVal to be duplicated.
+ * @param[in] tbl specifies if the val structure belongs to the main table/ controller table or rename table.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ upll_rc_t DupConfigKeyVal(ConfigKeyVal *&okey,
+ ConfigKeyVal *&req, MoMgrTables tbl = MAINTBL);
+
+ /* @brief To convert the value structure read from DB to
+ * VTNService during READ operations
+ * @param[in/out] ikey Pointer to the ConfigKeyVal Structure
+ *
+ * @retval UPLL_RC_SUCCESS Completed successfully.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ *
+ **/
+ upll_rc_t AdaptValToVtnService(ConfigKeyVal *ikey);
+
+ /**
+ * @brief Allocates for the specified val in the given configuration in the * specified table.
+ *
+ * @param[in/out] ck_val Reference pointer to configval structure
+ * allocated.
+ * @param[in] dt_type specifies the configuration candidate/running/
+ * state
+ * @param[in] tbl specifies if the corresponding table is the
+ * main table / controller table or rename table.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ upll_rc_t AllocVal(ConfigVal *&ck_val, upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl = MAINTBL);
+/**
+ * @brief Method to get a configkeyval of a specified keytype from an input configkeyval
+ *
+ * @param[in/out] okey pointer to output ConfigKeyVal
+ * @param[in] parent_key pointer to the configkeyval from which the output configkey val is initialized.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ */
+ upll_rc_t GetChildConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *parent_key);
+/**
+ * @brief Method to get a configkeyval of the parent keytype
+ *
+ * @param[in/out] okey pointer to parent ConfigKeyVal
+ * @param[in] ikey pointer to the child configkeyval from
+ * which the parent configkey val is obtained.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ upll_rc_t GetParentConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *ikey);
+
+ /* @brief Populate val_vtn_neighbor for the READ/READ_SIBLING operations
+ *
+ * @param[in/out] key Pointer to the ConfigKeyVal Structure
+ * @param[in] dmi Pointer to the DalDmlIntf(DB Interface)
+ *
+ * @retval UPLL_RC_SUCCESS Completed successfully.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ * @retval UPLL_RC_ERR_RESOURCE_DISCONNECTED Resource disconnected.
+ * @retval UPLL_RC_ERR_DB_ACCESS DB Read/Write error.
+ * @retval UPLL_RC_ERR_NO_SUCH_INSTANCE Given key does not exist
+ *
+ **/
+ upll_rc_t PopulateDriverDeleteCkv(ConfigKeyVal *&vnpCkv,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t dt_type);
+
+ /**
+ * @brief Update config status for commit result and vote result.
+ *
+ * @param[in/out] ckv_running ConfigKeyVal instance.
+ * @param[in] cs_status either UNC_CS_INVALID or UNC_CS_APPLIED.
+ * @param[in] phase specify the phase (CREATE,DELETE or UPDATE)
+ *
+ **/
+ upll_rc_t UpdateAuditConfigStatus(unc_keytype_configstatus_t cs_status,
+ uuc::UpdateCtrlrPhase phase,
+ ConfigKeyVal *&ckv_running);
+ upll_rc_t UpdateConfigStatus(ConfigKeyVal *vtunnelif_keyval,
+ unc_keytype_operation_t op,
+ uint32_t result,
+ ConfigKeyVal *upd_key,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ctrlr_key = NULL);
+
+ /**
+ * @Brief Validates the syntax of the specified key and value structure
+ * for KT_VTUNNEL_IF keytype
+ *
+ * @param[in] req This structure contains
+ * IpcReqRespHeader(first 8 fields of input request structure).
+ * @param[in] ikey ikey contains key and value structure.
+ *
+ * @retval UPLL_RC_SUCCESS Successful.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX Syntax error.
+ * @retval UPLL_RC_ERR_NO_SUCH_INSTANCE key struct is not available.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ * @retval UPLL_RC_ERR_INVALID_OPTION1 option1 is not valid.
+ * @retval UPLL_RC_ERR_INVALID_OPTION2 option2 is not valid.
+ */
+ upll_rc_t ValidateMessage(IpcReqRespHeader *req, ConfigKeyVal *ikey);
+
+ /**
+ * @Brief Validates the syntax for KT_VTUNNEL_IF keytype key structure.
+ *
+ * @param[in] key_vtunnel_if KT_VTUNNEL_IF key structure.
+ *
+ * @retval UPLL_RC_SUCCESS validation succeeded.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX validation failed.
+ */
+ upll_rc_t ValidateVTunnelIfKey(key_vtunnel_if_t *key_vtunnel_if,
+ uint32_t operation);
+
+ /**
+ * @Brief Validates the syntax for KT_VTUNNEL_IF keytype value structure.
+ *
+ * @param[in] val_vlink KT_VTUNNEL_IF value structure.
+ *
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ * @retval UPLL_RC_SUCCESS validation succeeded.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX validation failed.
+ */
+ upll_rc_t ValidateVTunnelIfValue(val_vtunnel_if_t *val_vtunnel_if,
+ uint32_t operation = UNC_OP_INVALID);
+
+ /**
+ * @Brief Validates the syntax for KT_VTUNNEL_IF keytype value structure.
+ *
+ * @param[in] val_vtn_neighbor KT_VTUNNEL_IF value structure.
+ *
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ * @retval UPLL_RC_SUCCESS validation succeeded.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX validation failed.
+ */
+ upll_rc_t ValidateVtnNeighborValue(val_vtn_neighbor_t *val_vtn_neighbor);
+
+ /**
+ * @Brief Checks if the specified key type(KT_VTUNNEL_IF) and
+ * associated attributes are supported on the given controller,
+ * based on the valid flag
+ *
+ * @param[in] req This structure contains
+ * IpcReqRespHeader(first 8 fields of input request structure).
+ * @param[in] ikey ikey contains key and value structure.
+ * @param[in] crtlr_name Controller name.
+ *
+ * @retval UPLL_RC_SUCCESS Validation succeeded.
+ * @retval UPLL_RC_ERR_GENERIC Validation failure.
+ * @retval UPLL_RC_ERR_INVALID_OPTION1 Option1 is not valid.
+ * @retval UPLL_RC_ERR_INVALID_OPTION2 Option2 is not valid.
+ */
+
+ upll_rc_t ValidateCapability(IpcReqRespHeader *req, ConfigKeyVal *ikey,
+ const char * crtlr_name);
+
+ /**
+ * @Brief Checks if the specified key type and
+ * associated attributes are supported on the given controller,
+ * based on the valid flag.
+ *
+ * @param[in] val_vtunnel_if Value Structure.
+ * @param[in] attr pointer to controller attribute
+ * @param[in] operation Operation Name
+ *
+ * @retval UPLL_RC_SUCCESS validation succeeded.
+ * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ */
+ upll_rc_t ValVTunnelIfAttributeSupportCheck(
+ val_vtunnel_if_t *val_vtunnel_if,
+ const uint8_t* attrs, unc_keytype_operation_t operation);
+
+ /* @brief This is semantic check for KEY_VTUNNEL_IF key type
+ * in the update operation.
+ *
+ * @param[in/out] ikey Pointer to the ConfigKeyVal Structure
+ * @param[in] datatype DB type.
+ * @param[in] dmi Pointer to the DalDmlIntf(DB Interface)
+ *
+ * @retval UPLL_RC_SUCCESS Not Referenced.
+ * @retval UPLL_RC_ERR_CFG_SEMANTIC Referenced
+ * @retval result_code Generic failure/DB error
+ */
+ upll_rc_t IsReferenced(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi);
+
+ public:
+ VtunnelIfMoMgr();
+ virtual ~VtunnelIfMoMgr() {
+ for (int i = VTUNNELIFTBL; i < NVTUNNELIFTABLES; i++)
+ if (table[i]) {
+ delete table[i];
+ }
+ delete[] table;
+ }
+ /**
+ * @brief Method to check if individual portions of a key are valid
+ *
+ * @param[in/out] ikey pointer to ConfigKeyVal referring to a UNC resource
+ * @param[in] index db index associated with the variable
+ *
+ * @retval true input key is valid
+ * @retval false input key is invalid.
+ **/
+ bool IsValidKey(void *tkey, uint64_t index);
+
+ /* @brief Updates vtunnelif structure
+ * based on valid[PORTMAP] flag.
+ *
+ * @param[in/out] ikey Pointer to the ConfigKeyVal Structure
+ * @param[in] datatype DB type.
+ * @param[in] dmi Pointer to the DalDmlIntf(DB Interface)
+ *
+ * @retval UPLL_RC_SUCCESS Completed successfully.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ *
+ **/
+ upll_rc_t UpdateConfigVal(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t datatype,
+ DalDmlIntf *dmi);
+};
+} // namesapce vtn
+} // namespace upll
+} // namespace unc
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 NEC Corporation
+ * All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+#include "vtunnel_momgr.hh"
+#include "unc/vnpdriver_ipc_enum.h"
+
+#define NUM_KEY_MAIN_TBL_ 4
+namespace unc {
+namespace upll {
+namespace kt_momgr {
+
+BindInfo VtunnelMoMgr::vtunnel_bind_info[] = {
+ { uudst::vtunnel::kDbiVtnName, CFG_KEY,
+ offsetof(key_vtunnel, vtn_key.vtn_name),
+ uud::kDalChar, kMaxLenVtnName+1 },
+ { uudst::vtunnel::kDbiVtunnelName, CFG_KEY,
+ offsetof(key_vtunnel, vtunnel_name),
+ uud::kDalChar, kMaxLenVnodeName+1 },
+ { uudst::vtunnel::kDbiDesc, CFG_VAL,
+ offsetof(val_vtunnel, description),
+ uud::kDalChar, kMaxLenDescription+1},
+ { uudst::vtunnel::kDbiCtrlrName, CFG_VAL,
+ offsetof(val_vtunnel, controller_id),
+ uud::kDalChar, kMaxLenCtrlrId+1 },
+ { uudst::vtunnel::kDbiCtrlrName, CK_VAL,
+ offsetof(key_user_data_t, ctrlr_id),
+ uud::kDalChar, kMaxLenCtrlrId+1 },
+ { uudst::vtunnel::kDbiDomainId, CFG_VAL,
+ offsetof(val_vtunnel, domain_id),
+ uud::kDalChar, kMaxLenDomainId+1 },
+ { uudst::vtunnel::kDbiDomainId, CK_VAL,
+ offsetof(key_user_data_t, domain_id),
+ uud::kDalChar, kMaxLenDomainId+1 },
+ { uudst::vtunnel::kDbiUnderlayVtnName, CFG_VAL,
+ offsetof(val_vtunnel, vtn_name),
+ uud::kDalChar, kMaxLenVtnName+1 },
+ { uudst::vtunnel::kDbiVtepgrpName, CFG_VAL,
+ offsetof(val_vtunnel, vtep_grp_name),
+ uud::kDalChar, kMaxLenVnodeName+1},
+ { uudst::vtunnel::kDbiLabel, CFG_VAL,
+ offsetof(val_vtunnel, label), uud::kDalUint32, 1},
+ { uudst::vtunnel::kDbiOperStatus, ST_VAL,
+ offsetof(val_db_vtunnel_st,
+ vtunnel_val_st.oper_status),
+ uud::kDalUint8, 1},
+ { uudst::vtunnel::kDbiDownCount, ST_VAL,
+ offsetof(val_db_vtunnel_st, down_count),
+ uud::kDalUint32, 1},
+ { uudst::vtunnel::kDbiFlags, CK_VAL,
+ offsetof(key_user_data_t, flags), uud::kDalUint8, 1},
+ { uudst::vtunnel::kDbiValidDesc, CFG_META_VAL,
+ offsetof(val_vtunnel, valid[0]), uud::kDalUint8, 1},
+ { uudst::vtunnel::kDbiValidCtrlrName, CFG_META_VAL,
+ offsetof(val_vtunnel, valid[1]), uud::kDalUint8, 1},
+ { uudst::vtunnel::kDbiValidDomainId, CFG_META_VAL,
+ offsetof(val_vtunnel, valid[2]), uud::kDalUint8, 1},
+ { uudst::vtunnel::kDbiValidUnderlayVtnName, CFG_META_VAL,
+ offsetof(val_vtunnel, valid[3]), uud::kDalUint8, 1},
+ { uudst::vtunnel::kDbiValidVtepgrpName, CFG_META_VAL,
+ offsetof(val_vtunnel, valid[4]), uud::kDalUint8, 1},
+ { uudst::vtunnel::kDbiValidLabel, CFG_META_VAL,
+ offsetof(val_vtunnel, valid[5]), uud::kDalUint8, 1},
+ { uudst::vtunnel::kDbiValidOperStatus, ST_META_VAL,
+ offsetof(val_db_vtunnel_st, vtunnel_val_st.valid[0]),
+ uud::kDalUint8, 1},
+ { uudst::vtunnel::kDbiCsRowstatus, CS_VAL,
+ offsetof(val_vtunnel, cs_row_status), uud::kDalUint8, 1},
+ { uudst::vtunnel::kDbiCsDesc, CS_VAL,
+ offsetof(val_vtunnel, cs_attr[0]), uud::kDalUint8, 1},
+ { uudst::vtunnel::kDbiCsCtrlrName, CS_VAL,
+ offsetof(val_vtunnel, cs_attr[1]), uud::kDalUint8, 1},
+ { uudst::vtunnel::kDbiCsDomainId, CS_VAL,
+ offsetof(val_vtunnel, cs_attr[2]), uud::kDalUint8, 1},
+ { uudst::vtunnel::kDbiCsUnderlayVtnName, CS_VAL,
+ offsetof(val_vtunnel, cs_attr[3]), uud::kDalUint8, 1},
+ { uudst::vtunnel::kDbiCsVtepgrpName, CS_VAL,
+ offsetof(val_vtunnel, cs_attr[4]), uud::kDalUint8, 1},
+ { uudst::vtunnel::kDbiCsLabel, CS_VAL,
+ offsetof(val_vtunnel, cs_attr[5]), uud::kDalUint8, 1}
+};
+
+unc_key_type_t VtunnelMoMgr::vtunnel_child[] = {
+ UNC_KT_VTUNNEL_IF
+};
+
+VtunnelMoMgr::VtunnelMoMgr() {
+ UPLL_FUNC_TRACE;
+ Table *tbl = new Table(uudst::kDbiVtunnelTbl, UNC_KT_VTUNNEL,
+ vtunnel_bind_info,
+ IpctSt::kIpcStKeyVtunnel, IpctSt::kIpcStValVtunnel,
+ uudst::vtunnel::kDbiVtunnelNumCols+2);
+ ntable = MAX_MOMGR_TBLS;
+ table = new Table *[ntable];
+ table[MAINTBL] = tbl;
+ table[RENAMETBL] = NULL;
+ table[CTRLRTBL] = NULL;
+ nchild = sizeof(vtunnel_child) / sizeof(*vtunnel_child);
+ child = vtunnel_child;
+#ifdef _STANDALONE_
+ SetMoManager(UNC_KT_VTUNNEL, reinterpret_cast<MoMgr *>(this));
+#endif
+}
+
+bool VtunnelMoMgr::IsValidKey(void *key, uint64_t index) {
+ UPLL_FUNC_TRACE;
+ key_vtunnel *vtun_key = reinterpret_cast<key_vtunnel *>(key);
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ switch (index) {
+ case uudst::vtunnel::kDbiVtnName:
+ ret_val = ValidateKey(reinterpret_cast<char *>
+ (vtun_key->vtn_key.vtn_name),
+ kMinLenVtnName, kMaxLenVtnName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("VTN Name is not valid(%d)", ret_val);
+ return false;
+ }
+ break;
+ case uudst::vtunnel::kDbiVtunnelName:
+ ret_val = ValidateKey(reinterpret_cast<char *>(vtun_key->vtunnel_name),
+ kMinLenVnodeName, kMaxLenVnodeName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_TRACE("Vtunnel Name is not valid(%d)", ret_val);
+ return false;
+ }
+ break;
+ default:
+ UPLL_LOG_TRACE("Invalid Key Index");
+ return false;
+ }
+ return true;
+}
+
+upll_rc_t VtunnelMoMgr::GetChildConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *parent_key) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ void *pkey;
+ key_vtunnel *vtunnel_key = static_cast<key_vtunnel *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtunnel)));
+ if (vtunnel_key == NULL) return UPLL_RC_ERR_GENERIC;
+ if (parent_key == NULL) {
+ if (okey) delete okey;
+ okey = new ConfigKeyVal(UNC_KT_VTUNNEL, IpctSt::kIpcStKeyVtunnel,
+ vtunnel_key, NULL);
+ return UPLL_RC_SUCCESS;
+ } else {
+ pkey = parent_key->get_key();
+ }
+ if (!pkey) {
+ FREE_IF_NOT_NULL(vtunnel_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (okey && (okey->get_key())) {
+ FREE_IF_NOT_NULL(vtunnel_key);
+ if (okey->get_key_type() != UNC_KT_VTUNNEL)
+ return UPLL_RC_ERR_GENERIC;
+ vtunnel_key = static_cast<key_vtunnel *>(okey->get_key());
+ } else {
+ okey = new ConfigKeyVal(UNC_KT_VTUNNEL, IpctSt::kIpcStKeyVtunnel,
+ vtunnel_key, NULL);
+ if (okey == NULL) {
+ FREE_IF_NOT_NULL(vtunnel_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ /* presumes MoMgrs receive only supported keytypes */
+ switch (parent_key->get_key_type()) {
+ case UNC_KT_VTUNNEL:
+ uuu::upll_strncpy(vtunnel_key->vtunnel_name,
+ static_cast<key_vtunnel *>
+ (pkey)->vtunnel_name, (kMaxLenVnodeName+1));
+ uuu::upll_strncpy(vtunnel_key->vtn_key.vtn_name,
+ static_cast<key_vtunnel *>(pkey)->vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ break;
+ case UNC_KT_VTN:
+ default:
+ uuu::upll_strncpy(vtunnel_key->vtn_key.vtn_name,
+ reinterpret_cast<key_vtn *>(pkey)->vtn_name,
+ (kMaxLenVtnName+1));
+ *(vtunnel_key->vtunnel_name) = ' ';
+ vtunnel_key->vtunnel_name[1] = '\0';
+ }
+ SET_USER_DATA(okey, parent_key);
+ return result_code;
+}
+
+upll_rc_t VtunnelMoMgr::GetParentConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *ikey ) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+
+ void *pkey = (ikey)?ikey->get_key():NULL;
+ if (!pkey) return UPLL_RC_ERR_GENERIC;
+ unc_key_type_t ikey_type = ikey->get_key_type();
+ if (ikey_type != UNC_KT_VTUNNEL)
+ return UPLL_RC_ERR_GENERIC;
+ key_vtn *vtn_key = static_cast<key_vtn *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn)));
+ if (!vtn_key) return UPLL_RC_ERR_GENERIC;
+ uuu::upll_strncpy(vtn_key->vtn_name,
+ reinterpret_cast<key_vtunnel *>(pkey)->vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ DELETE_IF_NOT_NULL(okey);
+ okey = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcStKeyVtn, vtn_key, NULL);
+ if (okey == NULL) {
+ FREE_IF_NOT_NULL(vtn_key);
+ result_code = UPLL_RC_ERR_GENERIC;
+ } else {
+ SET_USER_DATA(okey, ikey);
+ }
+ return result_code;
+}
+
+
+upll_rc_t VtunnelMoMgr::AllocVal(ConfigVal *&ck_val,
+ upll_keytype_datatype_t dt_type, MoMgrTables tbl) {
+ UPLL_FUNC_TRACE;
+ void *val;
+
+ if (ck_val != NULL) return UPLL_RC_ERR_GENERIC;
+ switch (tbl) {
+ case MAINTBL:
+ val = reinterpret_cast<void *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtunnel)));
+ if (!val) return UPLL_RC_ERR_GENERIC;
+ ck_val = new ConfigVal(IpctSt::kIpcStValVtunnel, val);
+ if (!ck_val) {
+ FREE_IF_NOT_NULL(reinterpret_cast<val_vtunnel *>(val));
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (dt_type == UPLL_DT_STATE) {
+ val = reinterpret_cast<void *>
+ (ConfigKeyVal::Malloc(sizeof(val_db_vtunnel_st)));
+ ConfigVal *ck_nxtval = new ConfigVal(IpctSt::kIpcStValVtunnelSt, val);
+ if (!ck_nxtval) {
+ delete ck_val;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ ck_val->AppendCfgVal(ck_nxtval);
+ }
+ break;
+ default:
+ val = NULL;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtunnelMoMgr::DupConfigKeyVal(ConfigKeyVal *&okey,
+ ConfigKeyVal *&req, MoMgrTables tbl) {
+ UPLL_FUNC_TRACE;
+ if (req == NULL) return UPLL_RC_ERR_GENERIC;
+ if (okey != NULL) return UPLL_RC_ERR_GENERIC;
+ if (req->get_key_type() != UNC_KT_VTUNNEL)
+ return UPLL_RC_ERR_GENERIC;
+ ConfigVal *tmp1 = NULL, *tmp = (req)->get_cfg_val();
+
+ if (tmp) {
+ if (tbl == MAINTBL) {
+ val_vtunnel *ival = reinterpret_cast<val_vtunnel *>(GetVal(req));
+ val_vtunnel *vtunnel_val = reinterpret_cast<val_vtunnel *>
+ (ConfigKeyVal::Malloc(sizeof(val_vtunnel)));
+ memcpy(vtunnel_val, ival, sizeof(val_vtunnel));
+ tmp1 = new ConfigVal(IpctSt::kIpcStValVtunnel, vtunnel_val);
+ if (!tmp1) {
+ FREE_IF_NOT_NULL(vtunnel_val);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ tmp = tmp->get_next_cfg_val();
+ };
+ if (tmp) {
+ if (tbl == MAINTBL) {
+ val_db_vtunnel_st *ival = static_cast<val_db_vtunnel_st *>
+ (tmp->get_val());
+ val_db_vtunnel_st *vtunnel_st = static_cast<val_db_vtunnel_st *>
+ (ConfigKeyVal::Malloc(sizeof(val_db_vtunnel_st)));
+ if (!vtunnel_st) {
+ delete tmp1;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ memcpy(vtunnel_st, ival, sizeof(val_db_vtunnel_st));
+ ConfigVal *tmp2 = new ConfigVal(IpctSt::kIpcStValVtunnelSt,
+ vtunnel_st);
+ if (!tmp2) {
+ delete tmp1;
+ FREE_IF_NOT_NULL(vtunnel_st);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ tmp1->AppendCfgVal(tmp2);
+ }
+ };
+ void *tkey = (req != NULL)?(req)->get_key():NULL;
+ key_vtunnel *ikey = static_cast<key_vtunnel *>(tkey);
+ key_vtunnel *vtunnel_key = static_cast<key_vtunnel *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtunnel)));
+ if (!vtunnel_key) {
+ delete tmp1;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ memcpy(vtunnel_key, ikey, sizeof(key_vtunnel));
+ okey = new ConfigKeyVal(UNC_KT_VTUNNEL, IpctSt::kIpcStKeyVtunnel,
+ vtunnel_key, tmp1);
+ if (okey) {
+ SET_USER_DATA(okey, req);
+ } else {
+ if (tmp1) delete tmp1;
+ FREE_IF_NOT_NULL(vtunnel_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtunnelMoMgr::UpdateConfigStatus(ConfigKeyVal *vtunnel_key,
+ unc_keytype_operation_t op,
+ uint32_t driver_result,
+ ConfigKeyVal *upd_key,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ctrlr_key) {
+ UPLL_FUNC_TRACE;
+ val_db_vtunnel_st *vtunnelst_val;
+ unc_keytype_configstatus_t cs_status =
+ (driver_result == UPLL_RC_SUCCESS) ? UNC_CS_APPLIED : UNC_CS_NOT_APPLIED;
+ UPLL_LOG_TRACE("DriverResult %d, ConfigStatus %d", driver_result, cs_status);
+ val_vtunnel *vtunnel_val = static_cast<val_vtunnel *>(GetVal(vtunnel_key));
+ if (vtunnel_val == NULL) return UPLL_RC_ERR_GENERIC;
+ UPLL_LOG_TRACE("%s", (vtunnel_key->ToStrAll()).c_str());
+ val_vtunnel *val_running = static_cast<val_vtunnel *>(GetVal(upd_key));
+ if (op == UNC_OP_CREATE) {
+ vtunnel_val->cs_row_status = cs_status;
+ vtunnelst_val = reinterpret_cast<val_db_vtunnel_st *>
+ (ConfigKeyVal::Malloc(sizeof(val_db_vtunnel_st)));
+ vtunnelst_val->vtunnel_val_st.oper_status = UPLL_OPER_STATUS_UP;
+ vtunnelst_val->vtunnel_val_st.valid[UPLL_IDX_OPER_STATUS_VTNLS] =
+ UNC_VF_VALID;
+ vtunnelst_val->down_count = 0;
+ vtunnelst_val->fault_count = 0;
+ vtunnel_key->AppendCfgVal(IpctSt::kIpcStValVtunnelSt, vtunnelst_val);
+ } else if (op == UNC_OP_UPDATE) {
+ void *val = reinterpret_cast<void *>(vtunnel_val);
+ CompareValidValue(val, GetVal(upd_key), true);
+ UPLL_LOG_TRACE("%s", (upd_key->ToStrAll()).c_str());
+ vtunnel_val->cs_row_status = val_running->cs_row_status;
+ } else {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ for (unsigned int loop = 0;
+ loop < sizeof(vtunnel_val->valid)/sizeof(vtunnel_val->valid[0]);
+ ++loop ) {
+ if ((UNC_VF_VALID == vtunnel_val->valid[loop]) ||
+ (UNC_VF_VALID_NO_VALUE == vtunnel_val->valid[loop])) {
+ if (loop == UPLL_IDX_DESC_VTNL)
+ vtunnel_val->cs_attr[loop] = UNC_CS_APPLIED;
+ else
+ vtunnel_val->cs_attr[loop] = cs_status;
+ } else if ((vtunnel_val->valid[loop] == UNC_VF_INVALID) &&
+ (UNC_OP_CREATE == op)) {
+ vtunnel_val->cs_attr[loop] = UNC_CS_APPLIED;
+ } else if ((vtunnel_val->valid[loop] == UNC_VF_INVALID) &&
+ (UNC_OP_UPDATE == op)) {
+ vtunnel_val->cs_attr[loop] = val_running->cs_attr[loop];
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+bool VtunnelMoMgr::FilterAttributes(void *&val1, void *val2,
+ bool copy_to_running,
+ unc_keytype_operation_t op) {
+ UPLL_FUNC_TRACE;
+ val_vtunnel_t *valtunnel1 = reinterpret_cast<val_vtunnel_t *>(val1);
+ /* No need to configure description in controller. */
+ valtunnel1->valid[UPLL_IDX_DESC_VTNL] = UNC_VF_INVALID;
+ if (op != UNC_OP_CREATE)
+ return CompareValidValue(val1, val2, copy_to_running);
+ return false;
+}
+
+bool VtunnelMoMgr::CompareValidValue(void *&val1, void *val2,
+ bool copy_to_running) {
+ UPLL_FUNC_TRACE;
+ bool invalid_attr = true;
+ val_vtunnel_t *valtunnel1 = reinterpret_cast<val_vtunnel_t *>(val1);
+ val_vtunnel_t *valtunnel2 = reinterpret_cast<val_vtunnel_t *>(val2);
+ for (unsigned int loop = 0;
+ loop < sizeof(valtunnel1->valid)/sizeof(uint8_t); ++loop ) {
+ if (UNC_VF_INVALID == valtunnel1->valid[loop] &&
+ UNC_VF_VALID == valtunnel2->valid[loop])
+ valtunnel1->valid[loop] = UNC_VF_VALID_NO_VALUE;
+ }
+ if (UNC_VF_VALID == valtunnel1->valid[UPLL_IDX_DESC_VTNL] &&
+ UNC_VF_VALID == valtunnel2->valid[UPLL_IDX_DESC_VTNL]) {
+ if (!strcmp(reinterpret_cast<char*>(valtunnel1->description),
+ reinterpret_cast<char*>(valtunnel2->description)))
+ valtunnel1->valid[UPLL_IDX_DESC_VTNL] = UNC_VF_INVALID;
+ }
+ if (UNC_VF_VALID == valtunnel1->valid[UPLL_IDX_CONTROLLER_ID_VTNL]
+ && UNC_VF_VALID == valtunnel2->valid[UPLL_IDX_CONTROLLER_ID_VTNL]) {
+ if (!strcmp(reinterpret_cast<char*>(valtunnel1->controller_id),
+ reinterpret_cast<char*>(valtunnel2->controller_id)))
+ valtunnel1->valid[UPLL_IDX_CONTROLLER_ID_VTNL] = UNC_VF_INVALID;
+ }
+ if (UNC_VF_VALID == valtunnel1->valid[UPLL_IDX_DOMAIN_ID_VTNL]
+ && UNC_VF_VALID == valtunnel2->valid[UPLL_IDX_DOMAIN_ID_VTNL]) {
+ if (!strcmp(reinterpret_cast<char*>(valtunnel1->domain_id),
+ reinterpret_cast<char*>(valtunnel2->domain_id)))
+ valtunnel1->valid[UPLL_IDX_DOMAIN_ID_VTNL] = UNC_VF_INVALID;
+ }
+ if (UNC_VF_VALID == valtunnel1->valid[UPLL_IDX_VTN_NAME_VTNL] &&
+ UNC_VF_VALID == valtunnel2->valid[UPLL_IDX_VTN_NAME_VTNL]) {
+ if (!strcmp(reinterpret_cast<char*>(valtunnel1->vtn_name),
+ reinterpret_cast<char*>(valtunnel2->vtn_name)))
+ valtunnel1->valid[UPLL_IDX_VTN_NAME_VTNL] =
+ (copy_to_running)?UNC_VF_INVALID:
+ UNC_VF_VALUE_NOT_MODIFIED;
+ }
+ if (UNC_VF_VALID == valtunnel1->valid[UPLL_IDX_VTEP_GRP_NAME_VTNL] &&
+ UNC_VF_VALID == valtunnel2->valid[UPLL_IDX_VTEP_GRP_NAME_VTNL]) {
+ if (!strcmp(reinterpret_cast<char*>(valtunnel1->vtep_grp_name),
+ reinterpret_cast<char*>(valtunnel2->vtep_grp_name)))
+ valtunnel1->valid[UPLL_IDX_VTEP_GRP_NAME_VTNL] =
+ (copy_to_running)?UNC_VF_INVALID:
+ UNC_VF_VALUE_NOT_MODIFIED;
+ }
+ if (UNC_VF_VALID == valtunnel1->valid[UPLL_IDX_LABEL_VTNL] &&
+ UNC_VF_VALID == valtunnel2->valid[UPLL_IDX_LABEL_VTNL]) {
+ if (valtunnel1->label == valtunnel2->label)
+ valtunnel1->valid[UPLL_IDX_LABEL_VTNL] =
+ (copy_to_running)?UNC_VF_INVALID:
+ UNC_VF_VALUE_NOT_MODIFIED;
+ }
+ if (!copy_to_running) valtunnel1->valid[UPLL_IDX_DESC_VTNL] = UNC_VF_INVALID;
+ for (unsigned int loop = 0;
+ loop < sizeof(valtunnel1->valid) / sizeof(uint8_t); ++loop) {
+ if ((UNC_VF_VALID == (uint8_t) valtunnel1->valid[loop]) ||
+ (UNC_VF_VALID_NO_VALUE == (uint8_t) valtunnel1->valid[loop])) {
+ invalid_attr = false;
+ break;
+ }
+ }
+ return invalid_attr;
+}
+
+upll_rc_t VtunnelMoMgr::UpdateAuditConfigStatus(
+ unc_keytype_configstatus_t cs_status,
+ uuc::UpdateCtrlrPhase phase,
+ ConfigKeyVal *&ckv_running) {
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ val_vtunnel_t *val = (ckv_running != NULL)?
+ reinterpret_cast<val_vtunnel_t *>
+ ((GetVal(ckv_running))):NULL;
+ if (NULL == val) {
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (uuc::kUpllUcpCreate == phase )
+ val->cs_row_status = cs_status;
+ if ((uuc::kUpllUcpUpdate == phase) &&
+ (val->cs_row_status == UNC_CS_INVALID ||
+ val->cs_row_status == UNC_CS_NOT_APPLIED))
+ val->cs_row_status = cs_status;
+ for (unsigned int loop = 0;
+ loop < sizeof(val->valid)/sizeof(uint8_t); ++loop ) {
+ if ((cs_status == UNC_CS_INVALID && UNC_VF_VALID == val->valid[loop]) ||
+ cs_status == UNC_CS_APPLIED)
+ val->cs_attr[loop] = cs_status;
+ }
+ return result_code;
+}
+
+/* Pure Virtual functions from MoMgrImpl */
+upll_rc_t VtunnelMoMgr::GetControllerDomainId(ConfigKeyVal *ikey,
+ controller_domain *ctrlr_dom) {
+ UPLL_FUNC_TRACE;
+ if (!ikey || !ctrlr_dom) {
+ UPLL_LOG_INFO("Illegal parameter");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val_vtunnel * temp_vtunnel = static_cast<val_vtunnel *>(GetVal(ikey));
+ if (!temp_vtunnel) {
+ UPLL_LOG_DEBUG("value null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (temp_vtunnel->valid[UPLL_IDX_CONTROLLER_ID_VTNL] != UNC_VF_VALID ||
+ !strlen(reinterpret_cast<char*>(temp_vtunnel->controller_id))) {
+ ctrlr_dom->ctrlr = NULL;
+ UPLL_LOG_TRACE("Ctrlr null");
+ } else {
+ SET_USER_DATA_CTRLR(ikey, temp_vtunnel->controller_id);
+ }
+ if (temp_vtunnel->valid[UPLL_IDX_DOMAIN_ID_VTNL] != UNC_VF_VALID ||
+ !strlen(reinterpret_cast<char*>(temp_vtunnel->domain_id))) {
+ ctrlr_dom->domain = NULL;
+ UPLL_LOG_TRACE("Domain null");
+ } else {
+ SET_USER_DATA_DOMAIN(ikey, temp_vtunnel->domain_id);
+ GET_USER_DATA_CTRLR_DOMAIN(ikey, *ctrlr_dom);
+ }
+ UPLL_LOG_DEBUG("ctrlr_dom %s %s", ctrlr_dom->ctrlr, ctrlr_dom->domain);
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtunnelMoMgr::GetVnodeName(ConfigKeyVal *ikey, uint8_t *&vtn_name,
+ uint8_t *&vnode_name) {
+ UPLL_FUNC_TRACE;
+ if (ikey == NULL) {
+ UPLL_LOG_DEBUG("ConfigKeyVal is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ key_vtunnel_t *vtunnel_key = static_cast<key_vtunnel_t *>
+ (ikey->get_key());
+ if (vtunnel_key == NULL)
+ return UPLL_RC_ERR_GENERIC;
+ vtn_name = vtunnel_key->vtn_key.vtn_name;
+ vnode_name = vtunnel_key->vtunnel_name;
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtunnelMoMgr::ValidateMessage(IpcReqRespHeader *req,
+ ConfigKeyVal *ikey) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t ret_val = UPLL_RC_ERR_GENERIC;
+ if (!ikey || !req || !(ikey->get_key())) {
+ UPLL_LOG_DEBUG("IpcReqRespHeader or ConfigKeyVal is Null");
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ unc_key_type_t keytype = ikey->get_key_type();
+ if (UNC_KT_VTUNNEL != keytype) {
+ UPLL_LOG_DEBUG("Invalid keytype. Keytype- %d", keytype);
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ if (ikey->get_st_num() != IpctSt::kIpcStKeyVtunnel) {
+ UPLL_LOG_DEBUG("Invalid struct received.Expected struct-kIpcStKeyVtunnel, "
+ "received struct -%s ", reinterpret_cast<const char *>
+ (IpctSt::GetIpcStdef(ikey->get_st_num())));
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ key_vtunnel_t *key_vtunnel = reinterpret_cast<key_vtunnel_t *>
+ (ikey->get_key());
+ val_vtunnel_t *val_vtunnel = NULL;
+ if ((ikey->get_cfg_val()) &&
+ ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVtunnel)) {
+ val_vtunnel = reinterpret_cast<val_vtunnel_t *>
+ (ikey->get_cfg_val()->get_val());
+ }
+ uint32_t dt_type = req->datatype;
+ uint32_t operation = req->operation;
+ uint32_t option1 = req->option1;
+ uint32_t option2 = req->option2;
+
+ ret_val = ValidateVTunnelKey(key_vtunnel, operation);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("Syntax check failed for VTUNNEL key structure");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ } else {
+ if (((operation == UNC_OP_CREATE) || (operation == UNC_OP_UPDATE)) &&
+ (dt_type == UPLL_DT_CANDIDATE)) {
+ if (val_vtunnel != NULL) {
+ ret_val = ValidateVTunnelValue(val_vtunnel, operation);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG(
+ "val struct Validation failed for CREATE/UPDATE op");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_DEBUG("Val struct is mandatory for CREATE/UPDATE op");
+ return UPLL_RC_ERR_BAD_REQUEST;
+ }
+ } else if (((operation == UNC_OP_READ) ||
+ (operation == UNC_OP_READ_SIBLING) ||
+ (operation == UNC_OP_READ_SIBLING_BEGIN)) &&
+ ((dt_type == UPLL_DT_CANDIDATE) || (dt_type == UPLL_DT_RUNNING) ||
+ (dt_type == UPLL_DT_STARTUP) || (dt_type == UPLL_DT_STATE))) {
+ if (option1 == UNC_OPT1_NORMAL) {
+ if (option2 == UNC_OPT2_NONE) {
+ if (val_vtunnel != NULL) {
+ ret_val = ValidateVTunnelValue(val_vtunnel);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG("val struct Validation failed for READ op");
+ return ret_val;
+ }
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_TRACE("Value structure is an optional for READ op");
+ return UPLL_RC_SUCCESS;
+ }
+ } else {
+ UPLL_LOG_TRACE("option2 is not matching");
+ return UPLL_RC_ERR_INVALID_OPTION2;
+ }
+ } else {
+ UPLL_LOG_TRACE("option1 is not matching");
+ return UPLL_RC_ERR_INVALID_OPTION1;
+ }
+ } else if ((operation == UNC_OP_DELETE) ||
+ (operation == UNC_OP_READ_SIBLING_COUNT) ||
+ (((operation == UNC_OP_READ_NEXT) ||
+ (operation == UNC_OP_READ_BULK)) &&
+ ((dt_type == UPLL_DT_CANDIDATE) ||
+ (dt_type == UPLL_DT_RUNNING) ||
+ (dt_type == UPLL_DT_STARTUP)))) {
+ UPLL_LOG_TRACE("Value structure is none for operation type:%d",
+ operation);
+ return UPLL_RC_SUCCESS;
+ } else {
+ UPLL_LOG_DEBUG("Invalid datatype(%d) and operation(%d)", dt_type,
+ operation);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtunnelMoMgr::ValidateAttribute(ConfigKeyVal *ikey, DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t r_code = UPLL_RC_SUCCESS;
+ if (!ikey || !(ikey->get_cfg_val()) ||
+ ((ikey->get_cfg_val())->get_st_num() != IpctSt::kIpcStValVtunnel)) {
+ UPLL_LOG_TRACE("Key or Valis null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val_vtunnel_t *val_vtunnel = static_cast<val_vtunnel_t *>(GetVal(ikey));
+ if (!val_vtunnel) return UPLL_RC_ERR_GENERIC;
+ // Validating Underlay VTN
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>
+ (GetMoManager(UNC_KT_VTN)));
+ if (!mgr) return UPLL_RC_ERR_GENERIC;
+ if (val_vtunnel->valid[UPLL_IDX_VTN_NAME_VTNL] == UNC_VF_VALID) {
+ // Validating Underlay Vtn is same as Overlay Vtn
+ key_vtunnel_t *vtunnel_key = reinterpret_cast<key_vtunnel_t *>
+ (ikey->get_key());
+ if (!strcmp(reinterpret_cast<char*>(vtunnel_key->vtn_key.vtn_name),
+ reinterpret_cast<char*>(val_vtunnel->vtn_name))) {
+ UPLL_LOG_DEBUG("UnderLay VTN is same as Overlay VTN");
+ return UPLL_RC_ERR_CFG_SEMANTIC;
+ }
+ // Existence of Underlay VTN
+ key_vtn *vtnkey = static_cast<key_vtn *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtn)));
+ uuu::upll_strncpy(vtnkey->vtn_name,
+ val_vtunnel->vtn_name,
+ (kMaxLenVtnName+1));
+ ConfigKeyVal *vtn_ck = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcStKeyVtn,
+ vtnkey, NULL);
+ if (vtn_ck == NULL) {
+ FREE_IF_NOT_NULL(vtnkey);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ r_code = mgr->UpdateConfigDB(vtn_ck, UPLL_DT_CANDIDATE, UNC_OP_READ,
+ dmi, MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS != r_code) {
+ UPLL_LOG_DEBUG("UpdateConfigDB Return Failure = %d ", r_code);
+ if (r_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)
+ UPLL_LOG_DEBUG("UnderLay Vtn does not exist");
+ delete vtn_ck;
+ r_code = (r_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
+ UPLL_RC_ERR_CFG_SEMANTIC:r_code;
+ return r_code;
+ } else {
+ r_code = UPLL_RC_SUCCESS;
+ delete vtn_ck;
+ }
+ } else {
+ if (val_vtunnel->valid[UPLL_IDX_VTEP_GRP_NAME_VTNL] == UNC_VF_VALID) {
+ UPLL_LOG_DEBUG("VTN name must be Valid for VTEP GRP");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ r_code = UPLL_RC_SUCCESS;
+ }
+ if (val_vtunnel->valid[UPLL_IDX_VTEP_GRP_NAME_VTNL] != UNC_VF_VALID) {
+ r_code = UPLL_RC_SUCCESS;
+ } else {
+ r_code = GetVtepGroup(val_vtunnel, UPLL_DT_CANDIDATE, dmi);
+ if (r_code!= UPLL_RC_ERR_INSTANCE_EXISTS) {
+ UPLL_LOG_DEBUG("Error in fetching the VtepGrp data from DB %d", r_code);
+ if (r_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)
+ UPLL_LOG_DEBUG("VtepGroup does not exist");
+ r_code = (r_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
+ UPLL_RC_ERR_CFG_SEMANTIC:r_code;
+ return r_code;
+ } else {
+ r_code = UPLL_RC_SUCCESS;
+ }
+ }
+ UPLL_LOG_TRACE("Vtunnel ValidateAttribute returned %d", r_code);
+ r_code = VnodeMoMgr::ValidateAttribute(ikey, dmi, req);
+ UPLL_LOG_TRACE("Vnode ValidateAttribute returned %d", r_code);
+ return r_code;
+}
+
+upll_rc_t VtunnelMoMgr::GetVtepGroup(val_vtunnel_t *vtunnelVal,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>
+ (GetMoManager(UNC_KT_VTEP_GRP)));
+ if (!mgr) return UPLL_RC_ERR_GENERIC;
+ key_vtep_grp *vtepgrp_key = reinterpret_cast<key_vtep_grp *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtep_grp)));
+ uuu::upll_strncpy(vtepgrp_key->vtn_key.vtn_name,
+ vtunnelVal->vtn_name,
+ (kMaxLenVtnName+1));
+ uuu::upll_strncpy(vtepgrp_key->vtepgrp_name,
+ vtunnelVal->vtep_grp_name,
+ (kMaxLenVnodeName+1));
+ ConfigKeyVal *vtepgrp_ckv = new ConfigKeyVal(UNC_KT_VTEP_GRP,
+ IpctSt::kIpcStKeyVtepGrp,
+ vtepgrp_key, NULL);
+ if (vtepgrp_ckv == NULL) {
+ FREE_IF_NOT_NULL(vtepgrp_key);
+ return UPLL_RC_ERR_GENERIC;
+ } else {
+ result_code = mgr->UpdateConfigDB(vtepgrp_ckv, dt_type, UNC_OP_READ,
+ dmi, MAINTBL);
+ if (UPLL_RC_ERR_INSTANCE_EXISTS != result_code) {
+ UPLL_LOG_DEBUG("UpdateConfigDB Return Failure = %d ", result_code);
+ delete vtepgrp_ckv;
+ return result_code;
+ }
+ }
+ delete vtepgrp_ckv;
+ return result_code;
+}
+
+upll_rc_t VtunnelMoMgr::ValidateVTunnelValue(val_vtunnel_t *val_vtunnel,
+ uint32_t operation) {
+ UPLL_FUNC_TRACE;
+ bool ret_val = false;
+
+ // Attribute syntax validation
+ for (unsigned int valid_index = 0;
+ valid_index < sizeof(val_vtunnel->valid) / sizeof(val_vtunnel->valid[0]);
+ valid_index++) {
+ if (val_vtunnel->valid[valid_index] == UNC_VF_VALID) {
+ switch (valid_index) {
+ case UPLL_IDX_CONTROLLER_ID_VTNL:
+ ret_val = ValidateString(val_vtunnel->controller_id,
+ kMinLenCtrlrId, kMaxLenCtrlrId);
+ break;
+ case UPLL_IDX_DOMAIN_ID_VTNL:
+ ret_val = ValidateDefaultStr(val_vtunnel->domain_id,
+ kMinLenDomainId, kMaxLenDomainId);
+ break;
+ case UPLL_IDX_VTN_NAME_VTNL:
+ ret_val = ValidateString(val_vtunnel->vtn_name,
+ kMinLenVtnName, kMaxLenVtnName);
+ break;
+ case UPLL_IDX_DESC_VTNL:
+ ret_val = ValidateDesc(val_vtunnel->description,
+ kMinLenDescription, kMaxLenDescription);
+ break;
+ case UPLL_IDX_VTEP_GRP_NAME_VTNL:
+ ret_val = ValidateString(val_vtunnel->vtep_grp_name,
+ kMinLenVnodeName, kMaxLenVnodeName);
+ break;
+ case UPLL_IDX_LABEL_VTNL:
+ ret_val = true;
+ break;
+ }
+ if (!ret_val) {
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ }
+ }
+
+ // Additional checks
+ for (unsigned int valid_index = 0;
+ valid_index < sizeof(val_vtunnel->valid) / sizeof(val_vtunnel->valid[0]);
+ valid_index++) {
+ uint8_t flag = val_vtunnel->valid[valid_index];
+ switch (operation) {
+ case UNC_OP_CREATE:
+ {
+ switch (valid_index) {
+ case UPLL_IDX_CONTROLLER_ID_VTNL:
+ case UPLL_IDX_DOMAIN_ID_VTNL:
+ if ((flag == UNC_VF_INVALID || flag == UNC_VF_VALID_NO_VALUE)) {
+ UPLL_LOG_DEBUG("controller_id or domain_id attribute is invalid"
+ " or valid_no_value");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ break;
+ case UPLL_IDX_DESC_VTNL:
+ case UPLL_IDX_VTN_NAME_VTNL:
+ case UPLL_IDX_VTEP_GRP_NAME_VTNL:
+ break;
+ case UPLL_IDX_LABEL_VTNL:
+ if ((flag == UNC_VF_INVALID || flag == UNC_VF_VALID_NO_VALUE)) {
+ UPLL_LOG_DEBUG("Label attribute is invalid or valid_no_value");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ case UNC_OP_UPDATE:
+ {
+ switch (valid_index) {
+ case UPLL_IDX_CONTROLLER_ID_VTNL:
+ case UPLL_IDX_DOMAIN_ID_VTNL:
+ if (flag == UNC_VF_VALID_NO_VALUE) {
+ UPLL_LOG_DEBUG("controller_id or domain_id flag is "
+ "valid_no_value");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ break;
+ case UPLL_IDX_DESC_VTNL:
+ case UPLL_IDX_VTN_NAME_VTNL:
+ case UPLL_IDX_VTEP_GRP_NAME_VTNL:
+ case UPLL_IDX_LABEL_VTNL:
+ default:
+ break;
+ }
+ }
+ break;
+ }
+ }
+
+ // Resets
+ for (unsigned int valid_index = 0;
+ valid_index < sizeof(val_vtunnel->valid) / sizeof(val_vtunnel->valid[0]);
+ valid_index++) {
+ uint8_t flag = val_vtunnel->valid[valid_index];
+ if (flag != UNC_VF_INVALID && flag != UNC_VF_VALID_NO_VALUE)
+ continue;
+
+ switch (valid_index) {
+ case UPLL_IDX_CONTROLLER_ID_VTNL:
+ StringReset(val_vtunnel->controller_id);
+ break;
+ case UPLL_IDX_DOMAIN_ID_VTNL:
+ StringReset(val_vtunnel->domain_id);
+ break;
+ case UPLL_IDX_DESC_VTNL:
+ StringReset(val_vtunnel->description);
+ break;
+ case UPLL_IDX_VTN_NAME_VTNL:
+ StringReset(val_vtunnel->vtn_name);
+ break;
+ case UPLL_IDX_VTEP_GRP_NAME_VTNL:
+ StringReset(val_vtunnel->vtep_grp_name);
+ break;
+ default:
+ UPLL_LOG_TRACE("Never here");
+ break;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+
+upll_rc_t VtunnelMoMgr::CtrlrIdAndDomainIdUpdationCheck(ConfigKeyVal *ikey,
+ ConfigKeyVal *okey) {
+ UPLL_FUNC_TRACE;
+ val_vtunnel *vtun_val = reinterpret_cast<val_vtunnel *>(GetVal(ikey));
+ val_vtunnel *vtun_val1 = reinterpret_cast<val_vtunnel *>(GetVal(okey));
+ if (vtun_val->valid[UPLL_IDX_CONTROLLER_ID_VTNL] == UNC_VF_VALID) {
+ if (strncmp(reinterpret_cast<const char *>(vtun_val->controller_id),
+ reinterpret_cast<const char *>(vtun_val1->controller_id),
+ kMaxLenCtrlrId+1)) {
+ UPLL_LOG_DEBUG("controller id comparision failed");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ }
+ if (vtun_val->valid[UPLL_IDX_DOMAIN_ID_VTNL] == UNC_VF_VALID) {
+ if (strncmp(reinterpret_cast<const char *>(vtun_val->domain_id),
+ reinterpret_cast<const char *>(vtun_val1->domain_id),
+ kMaxLenDomainId+1)) {
+ UPLL_LOG_DEBUG("domain id comparision failed");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+upll_rc_t VtunnelMoMgr::ValidateVTunnelKey(key_vtunnel_t *key_vtunnel,
+ uint32_t operation) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
+ ret_val = ValidateKey(
+ reinterpret_cast<char *>(key_vtunnel->vtn_key.vtn_name),
+ kMinLenVtnName, kMaxLenVtnName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_INFO("Vtn Name syntax check failed."
+ "Received VTN Name - %s",
+ key_vtunnel->vtn_key.vtn_name);
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ if ((operation != UNC_OP_READ_SIBLING_BEGIN) &&
+ (operation != UNC_OP_READ_SIBLING_COUNT)) {
+ UPLL_LOG_TRACE("UNC_KT_VTUNNEL: vtunnel_name (%s)",
+ key_vtunnel->vtunnel_name);
+ ret_val = ValidateKey(reinterpret_cast<char *>(key_vtunnel->vtunnel_name),
+ kMinLenVnodeName, kMaxLenVnodeName);
+ if (ret_val != UPLL_RC_SUCCESS) {
+ UPLL_LOG_DEBUG(
+ "Syntax check failed.vtunnel_name- %s", key_vtunnel->vtunnel_name);
+ return ret_val;
+ }
+ } else {
+ UPLL_LOG_TRACE("Operation is %d", operation);
+ StringReset(key_vtunnel->vtunnel_name);
+ }
+ UPLL_LOG_TRACE("key structure validation successful for VTUNNEL keytype");
+ return ret_val;
+}
+upll_rc_t VtunnelMoMgr::ValVTunnelAttributeSupportCheck(
+ val_vtunnel_t *val_vtunnel,
+ const uint8_t* attrs, unc_keytype_operation_t operation) {
+ UPLL_FUNC_TRACE;
+ /*
+ if ((val_vtunnel->valid[UPLL_IDX_DESC_VTNL] == UNC_VF_VALID)
+ || (val_vtunnel->valid[UPLL_IDX_DESC_VTNL] == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtunnel::kCapDesc] == 0) {
+ val_vtunnel->valid[UPLL_IDX_DESC_VTNL] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_INFO("Desc is not supported for PFC Controller");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ }
+ */
+ if ((val_vtunnel->valid[UPLL_IDX_VTN_NAME_VTNL] == UNC_VF_VALID)
+ || (val_vtunnel->valid[UPLL_IDX_VTN_NAME_VTNL]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtunnel::kCapVtepName] == 0) {
+ val_vtunnel->valid[UPLL_IDX_VTN_NAME_VTNL] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_INFO("VtepName is not supported for PFC Controller");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ }
+ if ((val_vtunnel->valid[UPLL_IDX_VTEP_GRP_NAME_VTNL] == UNC_VF_VALID)
+ || (val_vtunnel->valid[UPLL_IDX_VTEP_GRP_NAME_VTNL]
+ == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtunnel::kCapVtepGrpName] == 0) {
+ val_vtunnel->valid[UPLL_IDX_VTEP_GRP_NAME_VTNL] =
+ UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_INFO("VtepGrpName is not supported for PFC Controller");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ }
+ if ((val_vtunnel->valid[UPLL_IDX_LABEL_VTNL] == UNC_VF_VALID)
+ || (val_vtunnel->valid[UPLL_IDX_LABEL_VTNL] == UNC_VF_VALID_NO_VALUE)) {
+ if (attrs[unc::capa::vtunnel::kCapLabel] == 0) {
+ val_vtunnel->valid[UPLL_IDX_LABEL_VTNL] = UNC_VF_INVALID;
+ if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
+ UPLL_LOG_INFO("Label is not supported for PFC Controller");
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtunnelMoMgr::ValidateCapability(IpcReqRespHeader *req,
+ ConfigKeyVal *ikey, const char *ctrlr_name) {
+ UPLL_FUNC_TRACE;
+ if (!ikey || !req) {
+ UPLL_LOG_DEBUG("ConfigKeyVal / IpcReqRespHeader is Null");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ if (!ctrlr_name) {
+ ctrlr_name = reinterpret_cast<char*>((reinterpret_cast<key_user_data_t *>
+ (ikey->get_user_data()))->ctrlr_id);
+ if (!ctrlr_name || !strlen(ctrlr_name)) {
+ UPLL_LOG_DEBUG("Controller Name is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ UPLL_LOG_TRACE("ctrlr_name(%s), operation : (%d)",
+ ctrlr_name, req->operation);
+ bool result_code = false;
+ uint32_t max_instance_count = 0;
+ uint32_t max_attrs = 0;
+ const uint8_t *attrs = NULL;
+
+ switch (req->operation) {
+ case UNC_OP_CREATE:
+ result_code = GetCreateCapability(ctrlr_name,
+ ikey->get_key_type(), &max_instance_count, &max_attrs, &attrs);
+ if (result_code && (max_instance_count != 0) &&
+ cur_instance_count >= max_instance_count) {
+ UPLL_LOG_DEBUG("[%s:%d:%s Instance count %d exceeds %d", __FILE__,
+ __LINE__, __FUNCTION__, cur_instance_count, max_instance_count);
+ return UPLL_RC_ERR_EXCEEDS_RESOURCE_LIMIT;
+ }
+ break;
+ case UNC_OP_UPDATE:
+ result_code = GetUpdateCapability(ctrlr_name,
+ ikey->get_key_type(), &max_attrs, &attrs);
+ break;
+ case UNC_OP_READ:
+ case UNC_OP_READ_SIBLING:
+ case UNC_OP_READ_SIBLING_BEGIN:
+ case UNC_OP_READ_SIBLING_COUNT:
+ result_code = GetReadCapability(ctrlr_name,
+ ikey->get_key_type(), &max_attrs, &attrs);
+ break;
+ default:
+ UPLL_LOG_DEBUG("Invalid operation");
+ break;
+ }
+ if (!result_code) {
+ UPLL_LOG_DEBUG("keytype(%d) is not supported by controller(%s) "
+ "for operation(%d)",
+ ikey->get_key_type(), ctrlr_name, req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ val_vtunnel_t *val_vtunnel = NULL;
+ if ((ikey->get_cfg_val()) &&
+ ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVtunnel)) {
+ val_vtunnel =
+ reinterpret_cast<val_vtunnel_t *> (ikey->get_cfg_val()->get_val());
+ }
+ if (val_vtunnel) {
+ if (max_attrs > 0) {
+ return ValVTunnelAttributeSupportCheck(val_vtunnel, attrs,
+ req->operation);
+ } else {
+ UPLL_LOG_DEBUG("Attribute list is empty for operation %d",
+ req->operation);
+ return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+
+upll_rc_t VtunnelMoMgr::CreateVnodeConfigKey(ConfigKeyVal *ikey,
+ ConfigKeyVal *&okey) {
+ if (ikey == NULL)
+ return UPLL_RC_ERR_GENERIC;
+
+ key_vtunnel * temp_key_vtunnel = static_cast<key_vtunnel *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtunnel)));
+ uuu::upll_strncpy(temp_key_vtunnel->vtn_key.vtn_name,
+ static_cast<key_vtunnel*>(ikey->get_key())->
+ vtn_key.vtn_name,
+ (kMaxLenVtnName+1));
+ uuu::upll_strncpy(temp_key_vtunnel->vtunnel_name,
+ static_cast<key_vtunnel*>
+ (ikey->get_key())->vtunnel_name,
+ (kMaxLenVnodeName+1));
+
+ okey = new ConfigKeyVal(UNC_KT_VTUNNEL, IpctSt::kIpcStKeyVtunnel,
+ reinterpret_cast<void *>(temp_key_vtunnel),
+ NULL);
+ return UPLL_RC_SUCCESS;
+}
+/*
+upll_rc_t VtunnelMoMgr::CopyToConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *ikey) {
+ if ( !ikey || !(ikey->get_key()) )
+ return UPLL_RC_ERR_GENERIC;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ key_rename_vnode_info *key_rename = reinterpret_cast<key_rename_vnode_info *>
+ (ikey->get_key());
+ key_vtunnel_t* vtunnel_key = reinterpret_cast<key_vtunnel_t *>
+ (ConfigKeyVal::Malloc(sizeof(key_vtunnel_t)));
+ if (!vtunnel_key)
+ return UPLL_RC_ERR_GENERIC;
+ if (!strlen(reinterpret_cast<char *>(key_rename->old_unc_vtn_name))) {
+ FREE_IF_NOT_NULL(vtunnel_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ uuu::upll_strncpy(vtunnel_key ->vtn_key.vtn_name,
+ key_rename->old_unc_vtn_name,
+ (kMaxLenVtnName+1));
+ okey = new ConfigKeyVal(UNC_KT_VTUNNEL, IpctSt::kIpcStKeyVtunnel,
+ vtunnel_key, NULL);
+ if (!okey) {
+ FREE_IF_NOT_NULL(vtunnel_key);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ return result_code;
+}
+*/
+
+upll_rc_t VtunnelMoMgr::IsReferenced(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type, DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ if (!ikey || !(ikey->get_key()) || !dmi)
+ return UPLL_RC_ERR_GENERIC;
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>
+ (GetMoManager(UNC_KT_VTUNNEL_IF)));
+ result_code = mgr->IsReferenced(ikey, dt_type, dmi);
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
+ UPLL_RC_SUCCESS:result_code;
+ // Success / NoSuchInstance / Semantic
+ UPLL_LOG_DEBUG("IsReferenced result code (%d)", result_code);
+ return result_code;
+}
+
+/*
+upll_rc_t VtunnelMoMgr::MergeValidate(unc_key_type_t keytype,
+ const char *ctrlr_id,
+ ConfigKeyVal *ikey,
+ DalDmlIntf *dmi) {
+ return UPLL_RC_ERR_GENERIC;
+}
+*/
+
+upll_rc_t VtunnelMoMgr::PopulateDriverDeleteCkv(ConfigKeyVal *&vnpCkv,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t dt_type) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result = UPLL_RC_SUCCESS;
+ if (!vnpCkv || !vnpCkv->get_key() || (!(vnpCkv->get_cfg_val()))) {
+ UPLL_LOG_TRACE("Key or Val is NULL");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ val_vtunnel *vtunnel_val = static_cast<val_vtunnel *>(GetVal(vnpCkv));
+ vnpdrv_val_vtunnel *vnp_vtunnel = static_cast<vnpdrv_val_vtunnel *>
+ (ConfigKeyVal::Malloc(sizeof(vnpdrv_val_vtunnel)));
+ vnp_vtunnel->label = vtunnel_val->label;
+ vnp_vtunnel->valid[VNPDRV_IDX_LABEL_VTNL] = UNC_VF_VALID;
+ ConfigVal *ck_val = new ConfigVal(IpctSt::kIpcStVnpdrvValVtunnel,
+ vnp_vtunnel);
+ vnpCkv->SetCfgVal(ck_val);
+ return result;
+}
+
+
+} // namespace vtn
+} // namespace upll
+} // namespace unc
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 NEC Corporation
+ * All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+#ifndef UNC_UPLL_VTUNNEL_MOMGR_H
+#define UNC_UPLL_VTUNNEL_MOMGR_H
+
+#include <string>
+#include "momgr_impl.hh"
+#include "vnode_momgr.hh"
+#include "vtn_momgr.hh"
+
+namespace unc {
+namespace upll {
+namespace kt_momgr {
+
+
+class VtunnelMoMgr : public VnodeMoMgr {
+ private:
+ static unc_key_type_t vtunnel_child[];
+ static BindInfo vtunnel_bind_info[];
+ static BindInfo key_vtunnel_maintbl_bind_info[];
+
+ /**
+ * @brief Gets the valid array position of the variable in the value
+ * structure from the table in the specified configuration
+ *
+ * @param[in] val pointer to the value structure
+ * @param[in] indx database index for the variable
+ * @param[out] valid position of the variable in the valid array -
+ * NULL if valid does not exist.
+ * @param[in] dt_type specifies the configuration
+ * @param[in] tbl specifies the table containing the given value
+ *
+ **/
+ upll_rc_t GetValid(void *val, uint64_t indx, uint8_t *&valid,
+ upll_keytype_datatype_t dt_type, MoMgrTables tbl) {
+ UPLL_FUNC_TRACE;
+ if (val == NULL) return UPLL_RC_ERR_GENERIC;
+ if (tbl == MAINTBL) {
+ switch (indx) {
+ case uudst::vtunnel::kDbiDesc:
+ valid = &(reinterpret_cast<val_vtunnel *>(val)->
+ valid[UPLL_IDX_DESC_VTNL]);
+ break;
+ case uudst::vtunnel::kDbiCtrlrName:
+ valid = &(reinterpret_cast<val_vtunnel *>(val)->
+ valid[UPLL_IDX_CONTROLLER_ID_VTNL]);
+ break;
+ case uudst::vtunnel::kDbiDomainId:
+ valid = &(reinterpret_cast<val_vtunnel *>(val)->
+ valid[UPLL_IDX_DOMAIN_ID_VTNL]);
+ break;
+ case uudst::vtunnel::kDbiUnderlayVtnName:
+ valid = &(reinterpret_cast<val_vtunnel *>(val)->
+ valid[UPLL_IDX_VTN_NAME_VTNL]);
+ break;
+ case uudst::vtunnel::kDbiVtepgrpName:
+ valid = &(reinterpret_cast<val_vtunnel *>(val)->
+ valid[UPLL_IDX_VTEP_GRP_NAME_VTNL]);
+ break;
+ case uudst::vtunnel::kDbiLabel:
+ valid = &(reinterpret_cast<val_vtunnel *>(val)->
+ valid[UPLL_IDX_LABEL_VTNL]);
+ break;
+ case uudst::vtunnel::kDbiOperStatus:
+ valid = &(reinterpret_cast<val_vtunnel_st *>(val)->
+ valid[UPLL_IDX_OPER_STATUS_VTNLS]);
+ break;
+ case uudst::vtunnel::kDbiDownCount:
+ valid = NULL;
+ break;
+ default:
+ return UPLL_RC_ERR_GENERIC;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+ }
+ upll_rc_t UpdateConfigStatus(ConfigKeyVal *vtunnel_key,
+ unc_keytype_operation_t op,
+ uint32_t result,
+ ConfigKeyVal *upd_key,
+ DalDmlIntf *dmi,
+ ConfigKeyVal *ctrlr_key = NULL);
+ /**
+ * @brief Update config status for commit result and vote result.
+ *
+ * @param[in/out] ckv_running ConfigKeyVal instance.
+ * @param[in] cs_status either UNC_CS_INVALID or UNC_CS_APPLIED.
+ * @param[in] phase specify the phase (CREATE,DELETE or UPDATE)
+ *
+ **/
+ upll_rc_t UpdateAuditConfigStatus(unc_keytype_configstatus_t cs_status,
+ uuc::UpdateCtrlrPhase phase,
+ ConfigKeyVal *&ckv_running);
+
+ /**
+ * @brief Duplicates the input configkeyval including the key and val.
+ * based on the tbl specified.
+ *
+ * @param[in] okey Output Configkeyval - allocated within the function
+ * @param[in] req Input ConfigKeyVal to be duplicated.
+ * @param[in] tbl specifies if the val structure belongs to the main table/ controller table or rename table.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ upll_rc_t DupConfigKeyVal(ConfigKeyVal *&okey,
+ ConfigKeyVal *&req, MoMgrTables tbl = MAINTBL);
+ /**
+ * @brief Allocates for the specified val in the given configuration in the * specified table.
+ *
+ * @param[in/out] ck_val Reference pointer to configval structure
+ * allocated.
+ * @param[in] dt_type specifies the configuration candidate/running/
+ * state
+ * @param[in] tbl specifies if the corresponding table is the
+ * main table / controller table or rename table.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ upll_rc_t AllocVal(ConfigVal *&ck_val, upll_keytype_datatype_t dt_type,
+ MoMgrTables tbl = MAINTBL);
+/**
+ * @brief Method to get a configkeyval of a specified keytype from an input configkeyval
+ *
+ * @param[in/out] okey pointer to output ConfigKeyVal
+ * @param[in] parent_key pointer to the configkeyval from which the output configkey val is initialized.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ */
+ upll_rc_t GetChildConfigKey(ConfigKeyVal *&okey,
+ ConfigKeyVal *parent_key);
+/**
+ * @brief Method to get a configkeyval of the parent keytype
+ *
+ * @param[in/out] okey pointer to parent ConfigKeyVal
+ * @param[in] ikey pointer to the child configkeyval from
+ * which the parent configkey val is obtained.
+ *
+ * @retval UPLL_RC_SUCCESS Successfull completion.
+ * @retval UPLL_RC_ERR_GENERIC Failure case.
+ **/
+ upll_rc_t GetParentConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *ikey);
+ /**
+ * @brief Rename operation not needed for Overlay Keytype
+ **/
+ upll_rc_t GetRenamedControllerKey(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
+ uint8_t *ctrlr_name ) {
+ return UPLL_RC_SUCCESS;
+ }
+ /**
+ * @brief Rename operation not needed for Overlay Keytype
+ **/
+ upll_rc_t GetRenamedUncKey(ConfigKeyVal *ctrlr_key,
+ upll_keytype_datatype_t dt_type, DalDmlIntf *dmi,
+ uint8_t *ctrlr_id) {
+ return UPLL_RC_SUCCESS;
+ }
+
+ /**
+ * @brief Filters the attributes which need not be sent to controller
+ *
+ * @param[in/out] val1 first record value instance.
+ * @param[in] val2 second record value instance.
+ * @param[in] audit Not used for VTN
+ * @param[in] op Operation to be performed
+ *
+ **/
+ bool FilterAttributes(void *&val1, void *val2, bool copy_to_running,
+ unc_keytype_operation_t op);
+ /**
+ * @brief Compares the valid value between two database records.
+ * if both the values are same, update the valid flag for corresponding
+ * attribute as invalid in the first record.
+ *
+ * @param[in/out] val1 first record value instance.
+ * @param[in] val2 second record value instance.
+ * @param[in] audit if true, CompareValidValue called from audit process.
+ *
+ **/
+ bool CompareValidValue(void *&val1, void *val2, bool copy_to_running);
+
+ upll_rc_t PopulateDriverDeleteCkv(ConfigKeyVal *&vnpCkv,
+ DalDmlIntf *dmi,
+ upll_keytype_datatype_t dt_type);
+
+ /* Pure virtual from VnodeMoMgrImpl */
+ upll_rc_t GetControllerDomainId(ConfigKeyVal *ikey,
+ controller_domain_t *ctrlr_dom);
+ upll_rc_t GetVnodeName(ConfigKeyVal *ikey,
+ uint8_t *&vtn_name, uint8_t *&vnode_name);
+
+ /**
+ * @Brief Get the VtepGroupConfigKeyVal from VtepGroupTbl
+ *
+ * @param[in] vtunnelVal value structure
+ * @param[in] dt_type database type
+ * @param[in] dmi pointer to DalDmlIntf
+ *
+ * @retval UPLL_RC_SUCCESS Successful.
+ * @retval UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT Operation not allowed
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ */
+ upll_rc_t GetVtepGroup(val_vtunnel_t *vtunnelVal,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi);
+ /**
+ * @Brief Validates the syntax of the specified key and value structure
+ * for KT_VTUNNEL keytype
+ *
+ * @param[in] req This structure contains
+ * IpcReqRespHeader(first 8 fields of input request structure).
+ * @param[in] ikey ikey contains key and value structure.
+ *
+ * @retval UPLL_RC_SUCCESS Successful.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX Syntax error.
+ * @retval UPLL_RC_ERR_NO_SUCH_INSTANCE key_vlink is not available.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ * @retval UPLL_RC_ERR_INVALID_OPTION1 option1 is not valid.
+ * @retval UPLL_RC_ERR_INVALID_OPTION2 option2 is not valid.
+ */
+ upll_rc_t ValidateMessage(IpcReqRespHeader *req, ConfigKeyVal *ikey);
+ upll_rc_t ValidateAttribute(ConfigKeyVal *kval,
+ DalDmlIntf *dmi,
+ IpcReqRespHeader *req);
+ /**
+ * @Brief Validates the syntax for KT_VTUNNEL keytype value structure.
+ *
+ * @param[in] val_vtunnel KT_VTUNNEL value structure.
+ *
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ * @retval UPLL_RC_SUCCESS validation succeeded.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX validation failed.
+ */
+ upll_rc_t ValidateVTunnelValue(val_vtunnel_t *val_vtunnel,
+ uint32_t operation = UNC_OP_INVALID);
+ /**
+ * @Brief Checks if the specified key type(KT_VTUNNEL) and
+ * associated attributes are supported on the given controller,
+ * based on the valid flag
+ *
+ * @param[in] req This structure contains
+ * IpcReqRespHeader(first 8 fields of input request structure).
+ * @param[in] ikey ikey contains key and value structure.
+ * @param[in] crtlr_name Controller name.
+ *
+ * @retval UPLL_RC_SUCCESS Validation succeeded.
+ * @retval UPLL_RC_ERR_GENERIC Validation failure.
+ * @retval UPLL_RC_ERR_INVALID_OPTION1 Option1 is not valid.
+ * @retval UPLL_RC_ERR_INVALID_OPTION2 Option2 is not valid.
+ */
+
+ upll_rc_t ValidateCapability(IpcReqRespHeader *req, ConfigKeyVal *ikey,
+ const char * crtlr_name);
+ /**
+ * @Brief Checks if the specified key type and
+ * associated attributes are supported on the given controller,
+ * based on the valid flag.
+ *
+ * @param[in] val_vtunnel Value Structure.
+ * @param[in] attr pointer to controller attribute
+ * @param[in] operation Operation Name
+ *
+ * @retval UPLL_RC_SUCCESS validation succeeded.
+ * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ */
+ upll_rc_t ValVTunnelAttributeSupportCheck(
+ val_vtunnel_t *val_vtunnel,
+ const uint8_t* attrs, unc_keytype_operation_t operation);
+
+ upll_rc_t CopyToConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *ikey) {
+ return UPLL_RC_SUCCESS;
+ }
+ bool GetRenameKeyBindInfo(unc_key_type_t key_type, BindInfo *&binfo,
+ int &nattr,
+ MoMgrTables tbl) {
+ return true;
+ }
+ /* @brief This is semantic check for KEY_VTUNNEL key type
+ * in the update operation.
+ *
+ * @param[in/out] ikey Pointer to the ConfigKeyVal Structure
+ * @param[in] datatype DB type.
+ * @param[in] dmi Pointer to the DalDmlIntf(DB Interface)
+ *
+ * @retval UPLL_RC_SUCCESS Not Referenced.
+ * @retval UPLL_RC_ERR_CFG_SEMANTIC Referenced
+ * @retval result_code Generic failure/DB error
+ */
+ upll_rc_t IsReferenced(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi);
+
+ public:
+ VtunnelMoMgr();
+ virtual ~VtunnelMoMgr() {
+ for (int i = 0; i < ntable; i++)
+ if (table[i]) {
+ delete table[i];
+ }
+ delete[] table;
+ }
+ /**
+ * @brief Method to check if individual portions of a key are valid
+ *
+ * @param[in/out] ikey pointer to ConfigKeyVal referring to a UNC resource
+ * @param[in] index db index associated with the variable
+ *
+ * @retval true input key is valid
+ * @retval false input key is invalid.
+ **/
+ bool IsValidKey(void *tkey, uint64_t index);
+/**
+ * @Brief Validates the syntax for KT_VTUNNEL keytype key structure.
+ *
+ * @param[in] key_vtunnel KT_VTUNNEL key structure.
+ *
+ * @retval UPLL_RC_SUCCESS validation succeeded.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX validation failed.
+ */
+ upll_rc_t ValidateVTunnelKey(key_vtunnel_t *key_vtunnel,
+ uint32_t operation);
+
+ upll_rc_t CreateVnodeConfigKey(ConfigKeyVal *ikey, ConfigKeyVal *&okey);
+ /* @brief This method invoke when the VTN merge hapeening between
+ * Running and DT import. This will checks the vnode name
+ * unique or not.
+ *
+ * @param[in] keytype UNC KEY TYPE
+ * @param[in/out] ctrlr_id Controller ID
+ * @param[in] conflict_ckv key and value structure
+ * @param[in] dal Pointer to the DalDmlIntf(DB Interface)
+ *
+ * @retval UPLL_RC_SUCCESS Completed successfully.
+ * @retval UPLL_RC_ERR_GENERIC Generic failure.
+ * @retval UPLL_RC_ERR_RESOURCE_DISCONNECTED Resource disconnected.
+ * @retval UPLL_RC_ERR_DB_ACCESS DB Read/Write error.
+ * @retval UPLL_RC_ERR_MERGE_CONFLICT Semantic check error.
+ * @retval UPLL_RC_ERR_NO_SUCH_INSTANCE Given key does not exist
+ *
+ **/
+ upll_rc_t MergeValidate(unc_key_type_t keytype, const char *ctrlr_id,
+ ConfigKeyVal *ikey, DalDmlIntf *dmi) {
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
+ }
+
+ /**
+ * @Brief compares controller id and domain id before
+ * updating the value to DB.
+ *
+ * @param[in] ikey ikey contains key and value structure.
+ * @param[in] okey okey contains key and value structure.
+ *
+ * @retval UPLL_RC_SUCCESS Successful.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX Syntax error.
+ */
+ upll_rc_t CtrlrIdAndDomainIdUpdationCheck(ConfigKeyVal *ikey,
+ ConfigKeyVal *okey);
+};
+
+
+} // namespace vtn
+} // namespace upll
+} // namespace unc
+#endif
*/
#include "vunk_if_momgr.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "vunk_momgr.hh"
+#include "vlink_momgr.hh"
#define NUM_KEY_MAIN_TBL_ 5
#if 0
{ uudst::vunknown_interface::kDbiValidDesc, CFG_META_VAL, offsetof(
val_vunk_if, valid[UPLL_IDX_DESC_VUNI]),
uud::kDalUint8, 1 },
- { uudst::vunknown_interface::kDbiValidAdminStatus, CFG_META_VAL, offsetof(
+ { uudst::vunknown_interface::kDbiValidAdminStatus, CFG_DEF_VAL, offsetof(
val_vunk_if, valid[UPLL_IDX_ADMIN_ST_VUNI]),
uud::kDalUint8, 1 },
{ uudst::vunknown_interface::kDbiCsDesc, CS_VAL, offsetof(
nattr = NUM_KEY_MAIN_TBL_;
binfo = key_vunk_if_maintbl_update_bind_info;
} else {
- UPLL_LOG_TRACE("Invalid Table for VunknownInterface\n");
+ UPLL_LOG_TRACE("Invalid Table for VunknownInterface");
return PFC_FALSE;
}
return PFC_TRUE;
bool VunkIfMoMgr::IsValidKey(void *key, uint64_t index) {
UPLL_FUNC_TRACE;
key_vunk_if *vunk_if_key = static_cast<key_vunk_if *>(key);
- bool ret_val = UPLL_RC_SUCCESS;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
switch (index) {
case uudst::vunknown_interface::kDbiVtnName :
ret_val = ValidateKey(reinterpret_cast<char *>
(vunk_if_key->vunk_key.vtn_key.vtn_name),
kMinLenVtnName, kMaxLenVtnName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_info("VTN Name is not valid(%d)", ret_val);
+ UPLL_LOG_TRACE("VTN Name is not valid(%d)", ret_val);
return false;
}
break;
(vunk_if_key->vunk_key.vunknown_name),
kMinLenVnodeName, kMaxLenVnodeName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_info("Vunknown name is not valid(%d)", ret_val);
+ UPLL_LOG_TRACE("Vunknown name is not valid(%d)", ret_val);
return false;
}
break;
ret_val = ValidateKey(reinterpret_cast<char *>(vunk_if_key->if_name),
kMinLenInterfaceName, kMaxLenInterfaceName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_info("VBR IF Name is not valid(%d)", ret_val);
+ UPLL_LOG_TRACE("Vunknown IF Name is not valid(%d)", ret_val);
return false;
}
- pfc_log_info("VBR IF Name is valid");
break;
default:
- pfc_log_info("Invalid Key Index");
+ UPLL_LOG_INFO("Invalid Key Index");
break;
}
return true;
}
-bool VunkIfMoMgr::CompareValidValue(void *&val1, void *val2, bool audit) {
- return false;
+bool VunkIfMoMgr::CompareValidValue(void *&val1,
+ void *val2,
+ bool copy_to_running) {
+ UPLL_FUNC_TRACE;
+ bool invalid_attr = true;
+ val_vunk_if *val_vunkif1 = reinterpret_cast<val_vunk_if *>(val1);
+ val_vunk_if *val_vunkif2 = reinterpret_cast<val_vunk_if *>(val2);
+ if (!val_vunkif2) {
+ UPLL_LOG_TRACE("Invalid param");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ for (unsigned int loop = 0;
+ loop < sizeof(val_vunkif1->valid) / sizeof(uint8_t); ++loop) {
+ if (UNC_VF_INVALID == val_vunkif1->valid[loop]
+ && UNC_VF_VALID == val_vunkif2->valid[loop])
+ val_vunkif1->valid[loop] = UNC_VF_VALID_NO_VALUE;
+ }
+ /* Specify the configured ip address for
+ * PFC to clear the configured IP address
+ */
+ if ((UNC_VF_VALID == val_vunkif1->valid[UPLL_IDX_DESC_VUNI])
+ && (UNC_VF_VALID == val_vunkif2->valid[UPLL_IDX_DESC_VUNI]))
+ if (!strncmp(reinterpret_cast<char*>(val_vunkif1->description),
+ reinterpret_cast<char*>(val_vunkif2->description),
+ kMaxLenDescription))
+ val_vunkif1->valid[UPLL_IDX_DESC_VUNI] = UNC_VF_INVALID;
+
+ if ((val_vunkif2->valid[UPLL_IDX_ADMIN_ST_VUNI] ==
+ val_vunkif1->valid[UPLL_IDX_ADMIN_ST_VUNI])
+ && UNC_VF_INVALID != val_vunkif2->valid[UPLL_IDX_ADMIN_ST_VUNI]) {
+ if (val_vunkif1->admin_status == val_vunkif2->admin_status)
+ val_vunkif1->valid[UPLL_IDX_ADMIN_ST_VUNI] =
+ (copy_to_running)?UNC_VF_INVALID:UNC_VF_VALUE_NOT_MODIFIED;
+ }
+
+ for (unsigned int loop = 0;
+ loop < sizeof(val_vunkif1->valid) / sizeof(uint8_t); ++loop) {
+ if ((UNC_VF_VALID == (uint8_t) val_vunkif1->valid[loop]) ||
+ (UNC_VF_VALID_NO_VALUE == (uint8_t) val_vunkif1->valid[loop])) {
+ invalid_attr = false;
+ break;
+ }
+ }
+ return invalid_attr;
}
upll_rc_t VunkIfMoMgr::GetChildConfigKey(ConfigKeyVal *&okey,
ConfigKeyVal *parent_key) {
UPLL_FUNC_TRACE;
upll_rc_t result_code = UPLL_RC_SUCCESS;
+ bool cfgval_ctrlr = false;
key_vunk_if *vunk_key_if;
void *pkey;
if (parent_key == NULL) {
vunk_key_if = static_cast<key_vunk_if *>(malloc(sizeof(key_vunk_if)));
if (!vunk_key_if) return UPLL_RC_ERR_GENERIC;
memset(vunk_key_if, 0, sizeof(key_vunk_if));
+ if (okey) delete okey;
okey = new ConfigKeyVal(UNC_KT_VUNK_IF, IpctSt::kIpcStKeyVunkIf,
vunk_key_if, NULL);
return UPLL_RC_SUCCESS;
}
vunk_key_if = static_cast<key_vunk_if *>(okey->get_key());
} else {
- vunk_key_if = static_cast<key_vunk_if *>(malloc(sizeof(key_vunk_if)));
- if (!vunk_key_if) return UPLL_RC_ERR_GENERIC;
- memset(vunk_key_if, 0, sizeof(key_vunk_if));
+ vunk_key_if = static_cast<key_vunk_if *>
+ (ConfigKeyVal::Malloc(sizeof(key_vunk_if)));
}
unc_key_type_t keytype = parent_key->get_key_type();
switch (keytype) {
uuu::upll_strncpy(vunk_key_if->if_name,
reinterpret_cast<char *>(static_cast<key_vunk_if *>
(pkey)->if_name), kMaxLenInterfaceName+1);
+ break;
+ case UNC_KT_VLINK: {
+ uint8_t *vnode_name, *if_name;
+ uint8_t flags = 0;
+ val_vlink *vlink_val = reinterpret_cast<val_vlink *>(GetVal(parent_key));
+ if (!vlink_val) {
+ if (!okey || !(okey->get_key()))
+ free(vunk_key_if);
+ return UPLL_RC_ERR_GENERIC;
+ }
+ GET_USER_DATA_FLAGS(parent_key->get_cfg_val(), flags);
+ flags &= VLINK_FLAG_NODE_POS;
+ UPLL_LOG_DEBUG("Vlink flag node position %d",flags);
+ if (flags == kVlinkVnode2) {
+ cfgval_ctrlr = true;
+ vnode_name = vlink_val->vnode2_name;
+ if_name = vlink_val->vnode2_ifname;
+ } else {
+ vnode_name = vlink_val->vnode1_name;
+ if_name = vlink_val->vnode1_ifname;
+ }
+ uuu::upll_strncpy(vunk_key_if->vunk_key.vtn_key.vtn_name,
+ reinterpret_cast<key_vlink *>(pkey)->vtn_key.vtn_name,
+ (kMaxLenVtnName + 1));
+ if (vnode_name)
+ uuu::upll_strncpy(vunk_key_if->vunk_key.vunknown_name, vnode_name,
+ (kMaxLenVnodeName + 1));
+ if (if_name)
+ uuu::upll_strncpy(vunk_key_if->if_name, if_name,
+ (kMaxLenInterfaceName + 1));
+ }
+ break;
default:
break;
}
if (!okey)
okey = new ConfigKeyVal(UNC_KT_VUNK_IF, IpctSt::kIpcStKeyVunkIf,
vunk_key_if, NULL);
+ else if (okey->get_key() != vunk_key_if)
+ okey->SetKey(IpctSt::kIpcStKeyVunkIf, vunk_key_if);
if (okey == NULL) {
free(vunk_key_if);
result_code = UPLL_RC_ERR_GENERIC;
} else {
- SET_USER_DATA(okey, parent_key);
+ if (cfgval_ctrlr) {
+ SET_USER_DATA(okey, parent_key->get_cfg_val());
+ } else {
+ SET_USER_DATA(okey, parent_key);
+ }
}
return result_code;
}
(pkey)->vunk_key.vunknown_name),
kMaxLenVnodeName+1);
#endif
+ if (okey) delete okey;
okey = new ConfigKeyVal(UNC_KT_VUNKNOWN, IpctSt::kIpcStKeyVunknown, vunk_key,
NULL);
if (okey == NULL) {
ck_val = new ConfigVal(IpctSt::kIpcStValVunkIf, val);
break;
default:
- UPLL_LOG_TRACE("Invalid Table for VunknownInterface\n");
+ UPLL_LOG_TRACE("Invalid Table for VunknownInterface");
val = NULL;
}
return UPLL_RC_SUCCESS;
ConfigKeyVal *ctrlr_key) {
UPLL_FUNC_TRACE;
val_vunk_if_t *vunk_if_val = static_cast<val_vunk_if_t *>(GetVal(ikey));
+ val_vunk_if *vunk_if_val2 = reinterpret_cast<val_vunk_if *>(GetVal(upd_key));
- unc_keytype_configstatus_t cs_status = UNC_CS_NOT_APPLIED;
+ unc_keytype_configstatus_t cs_status = UNC_CS_APPLIED;
+ UPLL_LOG_TRACE("Key in Candidate %s",(ikey->ToStrAll()).c_str());
if (vunk_if_val == NULL) {
- UPLL_LOG_TRACE("Value of Vunknown Interface is NULL\n");
+ UPLL_LOG_TRACE("Value of Vunknown Interface is NULL");
return UPLL_RC_ERR_GENERIC;
}
if (op == UNC_OP_CREATE) {
vunk_if_val->cs_row_status = cs_status;
- }
- if ((op == UNC_OP_CREATE) || (op == UNC_OP_UPDATE)) {
- for (unsigned int loop = 0;
- loop < sizeof(vunk_if_val->valid)/sizeof(vunk_if_val->valid[0]);
- ++loop) {
- if ((UNC_VF_VALID == (uint8_t)vunk_if_val->valid[loop])
- || (UNC_VF_VALID_NO_VALUE == (uint8_t)vunk_if_val->valid[loop]))
- vunk_if_val->cs_attr[loop] = cs_status;
- else if (vunk_if_val->valid[loop] != UNC_VF_NOT_SOPPORTED)
- vunk_if_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
- }
+ } else if (op == UNC_OP_UPDATE) {
+ void *vunkifval = reinterpret_cast<void *>(vunk_if_val);
+ CompareValidValue(vunkifval, GetVal(upd_key), true);
+ UPLL_LOG_TRACE("Key in Running %s",(upd_key->ToStrAll()).c_str());
+ vunk_if_val->cs_row_status = vunk_if_val2->cs_row_status;
} else {
- UPLL_LOG_TRACE("Config Status changes not needed for this operation\n");
- return UPLL_RC_ERR_GENERIC;
+ return UPLL_RC_ERR_GENERIC;
+ }
+ for (unsigned int loop = 0;
+ loop < sizeof(vunk_if_val->valid)/sizeof(vunk_if_val->valid[0]);
+ ++loop) {
+ if ((UNC_VF_VALID == (uint8_t)vunk_if_val->valid[loop])
+ || (UNC_VF_VALID_NO_VALUE == (uint8_t)vunk_if_val->valid[loop]))
+ vunk_if_val->cs_attr[loop] = cs_status;
+ else if ((UNC_VF_INVALID == vunk_if_val->valid[loop]) &&
+ (UNC_OP_CREATE == op))
+ vunk_if_val->cs_attr[loop] = UNC_CS_APPLIED;
+ else if ((UNC_VF_INVALID == vunk_if_val->valid[loop]) &&
+ (UNC_OP_UPDATE == op))
+ vunk_if_val->cs_attr[loop] = vunk_if_val2->cs_attr[loop];
}
return UPLL_RC_SUCCESS;
}
-upll_rc_t VunkIfMoMgr::PopulateValVtnNeighbor(ConfigKeyVal *&ckv,
- DalDmlIntf *dmi) {
- pfc_log_info("Entering VunkIfMoMgr::PopulateValVtnNeighbor");
+upll_rc_t VunkIfMoMgr::PopulateValVtnNeighbor(ConfigKeyVal *&in_ckv,
+ DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
- upll_rc_t result_code = UPLL_RC_SUCCESS;
- ConfigVal *tmpcv = NULL;
- ConfigKeyVal *tmpckv = NULL;
- MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager *>
- (GetMoManager(UNC_KT_VLINK)));
- DbSubOp dbop = { kOpReadSingle, kOpMatchNone, kOpInOutNone };
- key_vunk_if_t *vunk_if_key = static_cast<key_vunk_if_t *>(ckv->get_key());
- ConfigVal *val = ckv->get_cfg_val();
- void *value = val ? val->get_val() : NULL;
- val_vtn_neighbor_t *val_vtn_neighbor =
- static_cast<val_vtn_neighbor_t *>(value);
- key_vlink_t *vlink_key = static_cast<key_vlink *>
- (malloc(sizeof(key_vlink_t)));
- if (!vlink_key) return UPLL_RC_ERR_GENERIC;
- val_vlink_t *vlink_val = static_cast<val_vlink *>
- (malloc(sizeof(val_vlink_t)));
- if (!vlink_val) { free(vlink_key); return UPLL_RC_ERR_GENERIC; }
- memcpy(&vlink_key->vtn_key, &vunk_if_key->vunk_key.vtn_key,
- sizeof(key_vtn_t));
- uuu::upll_strncpy(vlink_val->vnode1_name,
- reinterpret_cast<char *>(vunk_if_key->vunk_key.vunknown_name),
- kMaxLenVnodeName+1);
- uuu::upll_strncpy(vlink_val->vnode1_ifname,
- reinterpret_cast<char *>(vunk_if_key->if_name),
- kMaxLenInterfaceName+1);
-
- tmpcv = new ConfigVal(IpctSt::kIpcStValVlink, vlink_val);
- tmpckv = new ConfigKeyVal(UNC_KT_VLINK, IpctSt::kIpcStKeyVlink, vlink_key,
- tmpcv);
- result_code = mgr->ReadConfigDB(tmpckv, UPLL_DT_RUNNING, UNC_OP_READ, dbop,
- dmi, MAINTBL);
- if (result_code == UPLL_RC_SUCCESS) {
- ConfigVal *tmp = tmpckv->get_cfg_val();
- void *value = tmp ? tmp->get_val() : NULL;
- vlink_val = static_cast<val_vlink_t *>(value);
- uuu::upll_strncpy(val_vtn_neighbor->connected_vnode_name,
- reinterpret_cast<char *>(vlink_val->vnode2_name),
- kMaxLenVnodeName+1);
- uuu::upll_strncpy(val_vtn_neighbor->connected_if_name,
- reinterpret_cast<char *>(vlink_val->vnode2_ifname),
- kMaxLenInterfaceName+1);
- } else if (result_code != UPLL_RC_SUCCESS) {
- uuu::upll_strncpy(vlink_val->vnode2_name,
- reinterpret_cast<char *>(vunk_if_key->vunk_key.vunknown_name),
- kMaxLenVnodeName+1);
- uuu::upll_strncpy(vlink_val->vnode2_ifname,
- reinterpret_cast<char *>(vunk_if_key->if_name),
- kMaxLenInterfaceName+1);
- result_code = mgr->ReadConfigDB(tmpckv, UPLL_DT_RUNNING, UNC_OP_READ, dbop,
- dmi, MAINTBL);
- if (result_code != UPLL_RC_SUCCESS) {
- pfc_log_error("Exiting VunkIfMoMgr::PopulateValVtnNeighbor");
- delete tmpckv;
- return result_code;
+ // Read on the left side of the link
+ bool got_left_side = false;
+ ConfigKeyVal *vlink_ckv = NULL;
+ VlinkMoMgr *vlink_momgr = reinterpret_cast<VlinkMoMgr *>
+ (const_cast<MoManager*>(GetMoManager(UNC_KT_VLINK)));
+ if (!vlink_momgr) {
+ UPLL_LOG_DEBUG("Invalid Mgr");
+ return UPLL_RC_ERR_GENERIC;
+ }
+ vn_if_type iftype;
+ upll_rc_t result_code = vlink_momgr->CheckIfMemberOfVlink(in_ckv,
+ UPLL_DT_RUNNING, vlink_ckv, dmi, iftype);
+ if (!vlink_ckv || result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE) {
+ UPLL_LOG_TRACE("Not found in vlink table");
+ } else if (result_code == UPLL_RC_SUCCESS) {
+ key_vlink_t *vlink_key = reinterpret_cast<key_vlink_t *>
+ (vlink_ckv->get_key());
+ if (!vlink_key) {
+ UPLL_LOG_DEBUG("Invalid param");
+ if (vlink_ckv) delete vlink_ckv;
+ return UPLL_RC_ERR_GENERIC;
}
- ConfigVal *tmp = tmpckv->get_cfg_val();
- void *value = tmp ? tmp->get_val() : NULL;
- vlink_val = static_cast<val_vlink_t *>(value);
+ if ((iftype == kVlinkBoundaryNode1) || (iftype == kVlinkInternalNode1))
+ got_left_side = true;
+ val_vlink_t *vlink_val = reinterpret_cast<val_vlink *>
+ (GetVal(vlink_ckv));
+ val_vtn_neighbor_t *val_vtn_neighbor =
+ reinterpret_cast<val_vtn_neighbor_t *>(malloc(sizeof(val_vtn_neighbor_t)));
+ memset(val_vtn_neighbor, 0, sizeof(val_vtn_neighbor_t));
+ val_vtn_neighbor->valid[UPLL_IDX_CONN_VNODE_NAME_VN] = UNC_VF_VALID;
+ val_vtn_neighbor->valid[UPLL_IDX_CONN_VNODE_IF_NAME_VN] = UNC_VF_VALID;
+ val_vtn_neighbor->valid[UPLL_IDX_CONN_VLINK_NAME_VN] = UNC_VF_VALID;
uuu::upll_strncpy(val_vtn_neighbor->connected_vnode_name,
- reinterpret_cast<char *>(vlink_val->vnode1_name),
- kMaxLenVnodeName+1);
+ ((got_left_side) ? vlink_val->vnode2_name :
+ vlink_val->vnode1_name),
+ (kMaxLenVnodeName + 1));
uuu::upll_strncpy(val_vtn_neighbor->connected_if_name,
- reinterpret_cast<char *>(vlink_val->vnode1_ifname),
- kMaxLenInterfaceName+1);
+ ((got_left_side) ? vlink_val->vnode2_ifname :
+ vlink_val->vnode1_ifname),
+ (kMaxLenInterfaceName + 1));
+ uuu::upll_strncpy(val_vtn_neighbor->connected_vlink_name,
+ vlink_key->vlink_name, (kMaxLenVnodeName + 1));
+ in_ckv->SetCfgVal(new ConfigVal(IpctSt::kIpcStValVtnNeighbor,
+ val_vtn_neighbor));
+ } else {
+ UPLL_LOG_DEBUG("ReadConfigDB failed result_code - %d", result_code);
}
- vlink_key = static_cast<key_vlink_t *>(tmpckv->get_key());
- uuu::upll_strncpy(val_vtn_neighbor->connected_vlink_name,
- reinterpret_cast<char *>(vlink_key->vlink_name),
- kMaxLenVlinkName+1);
- pfc_log_info("Exiting VunkIfMoMgr::PopulateValVtnNeighbor");
- if (tmpckv) delete tmpckv;
+
+ if (vlink_ckv) delete vlink_ckv;
return result_code;
}
}
upll_rc_t VunkIfMoMgr::ValidateMessage(IpcReqRespHeader *req,
- ConfigKeyVal *ikey) {
+ ConfigKeyVal *ikey) {
UPLL_FUNC_TRACE;
upll_rc_t ret_val = UPLL_RC_ERR_GENERIC;
- if (NULL == req) {
- UPLL_LOG_DEBUG("IpcReqRespHeader is NULL");
- return UPLL_RC_ERR_GENERIC;
- }
- if (ikey == NULL) {
- UPLL_LOG_DEBUG("ConfigKeyVal is NULL");
- return UPLL_RC_ERR_GENERIC;
+ if (!ikey || !req || !(ikey->get_key())) {
+ UPLL_LOG_DEBUG("IpcReqRespHeader or ConfigKeyVal is Null");
+ return UPLL_RC_ERR_BAD_REQUEST;
}
unc_key_type_t keytype = ikey->get_key_type();
if (UNC_KT_VUNK_IF != keytype) {
- pfc_log_debug("Invalid keytype. Keytype- %d", keytype);
+ UPLL_LOG_DEBUG("Invalid keytype. Keytype- %d", keytype);
return UPLL_RC_ERR_BAD_REQUEST;
}
if (ikey->get_st_num() != IpctSt::kIpcStKeyVunkIf) {
- pfc_log_debug(
+ UPLL_LOG_DEBUG(
"Invalid structure received.Expected struct-kIpcStKeyVunkIf,"
"received struct -%s ",
reinterpret_cast<const char *>(IpctSt::GetIpcStdef(ikey->get_st_num())));
return UPLL_RC_ERR_BAD_REQUEST;
}
key_vunk_if_t *key_vunk_if =
- static_cast<key_vunk_if_t *>(ikey->get_key());
-
+ static_cast<key_vunk_if_t *>(ikey->get_key());
upll_keytype_datatype_t dt_type = req->datatype;
unc_keytype_operation_t operation = req->operation;
unc_keytype_option2_t option2 = req->option2;
if (key_vunk_if == NULL) {
- pfc_log_debug("Key structure is empty!!");
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ UPLL_LOG_DEBUG("Key structure is empty!!");
+ return UPLL_RC_ERR_BAD_REQUEST;
}
ret_val = ValidateVunkIfKey(key_vunk_if, operation);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("Syntax check failed for KT_VUNK_IF key structure");
+ UPLL_LOG_DEBUG("Syntax check failed for KT_VUNK_IF key structure");
return UPLL_RC_ERR_CFG_SYNTAX;
}
if ((ikey->get_cfg_val())
&& (ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVunkIf) {
val_vunk_if =
- static_cast<val_vunk_if_t *>(ikey->get_cfg_val()->get_val());
+ static_cast<val_vunk_if_t *>(ikey->get_cfg_val()->get_val());
}
if (val_vunk_if != NULL) {
- ret_val = ValidateVunkIfValue(val_vunk_if);
+ ret_val = ValidateVunkIfValue(val_vunk_if,operation);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("Syntax check failed for VUNK_IF value structure");
- return ret_val;
- } else {
- pfc_log_trace("Syntax check success for VUNK_IF value structure");
- return ret_val;
+ UPLL_LOG_DEBUG("Syntax check failed for VUNK_IF value structure");
+ return UPLL_RC_ERR_CFG_SYNTAX;
}
+ return UPLL_RC_SUCCESS;
} else {
- pfc_log_trace("Value structure optional for UNC_OP_CREATE");
- return ret_val;
+ UPLL_LOG_TRACE("Value structure optional for UNC_OP_CREATE");
+ return UPLL_RC_SUCCESS;
}
} else if ((operation == UNC_OP_UPDATE) && (dt_type == UPLL_DT_CANDIDATE)) {
if ((ikey->get_cfg_val())
&& (ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVunkIf) {
val_vunk_if =
- reinterpret_cast<val_vunk_if_t *>(ikey->get_cfg_val()->get_val());
+ reinterpret_cast<val_vunk_if_t *>(ikey->get_cfg_val()->get_val());
}
if (val_vunk_if != NULL) {
- ret_val = ValidateVunkIfValue(val_vunk_if);
+ ret_val = ValidateVunkIfValue(val_vunk_if,operation);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("Syntax check failed for VINK_IF value structure");
- return ret_val;
- } else {
- pfc_log_trace("Syntax check success for VINK_IF value structure");
- return ret_val;
+ UPLL_LOG_DEBUG("Syntax check failed for VINK_IF value structure");
+ return UPLL_RC_ERR_CFG_SYNTAX;
}
+ return UPLL_RC_SUCCESS;
} else {
- pfc_log_debug("Value structure mandatory for UNC_OP_UPDATE operation");
+ UPLL_LOG_DEBUG("Value structure mandatory for UNC_OP_UPDATE operation");
return UPLL_RC_ERR_CFG_SYNTAX;
}
- } else if (((operation == UNC_OP_READ) || (operation == UNC_OP_READ_SIBLING)
- || (operation == UNC_OP_READ_SIBLING_BEGIN))
- && (dt_type == UPLL_DT_STATE)) {
+ } else if ((operation == UNC_OP_READ) && (dt_type == UPLL_DT_STATE)) {
if (option1 == UNC_OPT1_NORMAL) {
if (option2 == UNC_OPT2_NEIGHBOR) {
val_vtn_neighbor_t *val_vtn_neighbor = NULL;
if (val_vtn_neighbor != NULL) {
ret_val = ValidateVtnNeighValue(val_vtn_neighbor);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("Syntax check failed for VtnNeighValue structure");
+ UPLL_LOG_DEBUG("Syntax check failed for VtnNeighValue structure");
return ret_val;
} else {
- pfc_log_trace("Syntax check success for VUNKIF value structure");
+ UPLL_LOG_TRACE("Syntax check success for VUNKIF value structure");
return ret_val;
}
} else {
- pfc_log_trace("Value structure is optional");
+ UPLL_LOG_TRACE("Value structure is optional");
return ret_val;
}
} else if (option2 != UNC_OPT2_NONE) {
- pfc_log_debug("option2 is not matching");
+ UPLL_LOG_DEBUG("option2 is not matching");
return UPLL_RC_ERR_INVALID_OPTION2;
}
} else {
- pfc_log_debug("option1 is not matching");
+ UPLL_LOG_DEBUG("option1 is not matching");
return UPLL_RC_ERR_INVALID_OPTION1;
}
} else if ((operation == UNC_OP_READ)
if (val_vtn_neighbor != NULL) {
ret_val = ValidateVtnNeighValue(val_vtn_neighbor);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("Syntax check failed for VtnNeighValue structure");
+ UPLL_LOG_DEBUG("Syntax check failed for VtnNeighValue structure");
return ret_val;
} else {
- pfc_log_trace("Syntax check success for VUNKIF value structure");
+ UPLL_LOG_TRACE("Syntax check success for VUNKIF value structure");
return ret_val;
}
} else {
- pfc_log_trace("Value structure is optional");
+ UPLL_LOG_TRACE("Value structure is optional");
return ret_val;
}
} else if (option2 != UNC_OPT2_NONE) {
- pfc_log_debug("option2 is not matching");
+ UPLL_LOG_DEBUG("option2 is not matching");
return UPLL_RC_ERR_INVALID_OPTION2;
}
} else {
- pfc_log_debug("option1 is not matching");
+ UPLL_LOG_DEBUG("option1 is not matching");
return UPLL_RC_ERR_INVALID_OPTION1;
}
- } else if (((operation == UNC_OP_READ) ||
- (operation == UNC_OP_READ_SIBLING)
+ } else if (((operation == UNC_OP_READ_SIBLING)
|| (operation == UNC_OP_READ_SIBLING_BEGIN)
|| (operation == UNC_OP_READ_SIBLING_COUNT))
&& ((dt_type == UPLL_DT_CANDIDATE) || (dt_type == UPLL_DT_RUNNING)
static_cast<val_vunk_if_t *>(ikey->get_cfg_val()->get_val());
}
if (val_vunk_if != NULL) {
- ret_val = ValidateVunkIfValue(val_vunk_if);
+ ret_val = ValidateVunkIfValue(val_vunk_if,operation);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("Syntax check failed for VUNK_IF value structure");
+ UPLL_LOG_DEBUG("Syntax check failed for VUNK_IF value structure");
return ret_val;
} else {
- pfc_log_trace("Syntax check success for VUNKIF value structure");
+ UPLL_LOG_TRACE("Syntax check success for VUNKIF value structure");
return ret_val;
}
} else {
- pfc_log_trace("Value structure optional for READ operations");
+ UPLL_LOG_TRACE("Value structure optional for READ operations");
return ret_val;
}
} else {
- pfc_log_debug("option2 is not matching");
+ UPLL_LOG_DEBUG("option2 is not matching");
return UPLL_RC_ERR_INVALID_OPTION2;
}
} else {
- pfc_log_debug("option1 is not matching");
+ UPLL_LOG_DEBUG("option1 is not matching");
return UPLL_RC_ERR_INVALID_OPTION1;
}
- } else if ((operation == UNC_OP_DELETE) || (operation == UNC_OP_READ_NEXT)
- || (operation == UNC_OP_READ_BULK)) {
- pfc_log_trace("Value structure is none for operation type:%d", operation);
+ } else if ((operation == UNC_OP_DELETE) && (dt_type == UPLL_DT_CANDIDATE)) {
+ UPLL_LOG_TRACE("Value structure is none for this operation :%d", operation);
+ return UPLL_RC_SUCCESS;
+ } else if (((operation == UNC_OP_READ_NEXT) ||
+ (operation == UNC_OP_READ_BULK)) &&
+ ((dt_type == UPLL_DT_CANDIDATE) ||
+ (dt_type == UPLL_DT_RUNNING) ||
+ (dt_type == UPLL_DT_STARTUP))) {
+ UPLL_LOG_TRACE("Value structure is none for this operation :%d", operation);
+ return UPLL_RC_SUCCESS;
} else {
- pfc_log_debug("Invalid datatype(%d) and operation(%d)", dt_type,
- operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ UPLL_LOG_DEBUG("Invalid datatype(%d) and operation(%d)", dt_type,
+ operation);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
return UPLL_RC_SUCCESS;
}
upll_rc_t VunkIfMoMgr::ValidateVunkIfValue(val_vunk_if_t *val_vunk_if,
- unc_keytype_operation_t operation) {
+ unc_keytype_operation_t operation) {
UPLL_FUNC_TRACE;
- upll_rc_t ret_val = UPLL_RC_SUCCESS;
if (val_vunk_if->valid[UPLL_IDX_DESC_VUNI] == UNC_VF_VALID) {
- ret_val = ValidateDesc(reinterpret_cast<char *>(val_vunk_if->description),
- kMinLenDescription, kMaxLenDescription);
-
- if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("Syntax check failed desc:(%s)", val_vunk_if->description);
- return ret_val;
+ if (!ValidateDesc(val_vunk_if->description,
+ kMinLenDescription, kMaxLenDescription)) {
+ UPLL_LOG_DEBUG("Syntax check failed desc:(%s)", val_vunk_if->description);
+ return UPLL_RC_ERR_CFG_SYNTAX;
}
} else if ((val_vunk_if->valid[UPLL_IDX_DESC_VUNI] == UNC_VF_VALID_NO_VALUE)
&& ((operation == UNC_OP_UPDATE) || (operation == UNC_OP_CREATE))) {
}
if (val_vunk_if->valid[UPLL_IDX_ADMIN_ST_VUNI] == UNC_VF_VALID) {
if (!ValidateNumericRange(val_vunk_if->admin_status,
- (uint8_t) UPLL_ADMIN_ENABLE,
- (uint8_t) UPLL_ADMIN_DISABLE, true, true)) {
- pfc_log_debug("Syntax check failed admst:%d", val_vunk_if->admin_status);
- return ret_val;
+ (uint8_t) UPLL_ADMIN_ENABLE,
+ (uint8_t) UPLL_ADMIN_DISABLE, true, true)) {
+ UPLL_LOG_DEBUG("Syntax check failed admst:%d", val_vunk_if->admin_status);
+ return UPLL_RC_ERR_CFG_SYNTAX;
}
} else if ((val_vunk_if->valid[UPLL_IDX_ADMIN_ST_VUNI]
- == UNC_VF_VALID_NO_VALUE)
+ == UNC_VF_VALID_NO_VALUE)
&& ((operation == UNC_OP_UPDATE) || (operation == UNC_OP_CREATE))) {
val_vunk_if->admin_status = UPLL_ADMIN_ENABLE;
+ } else if ((val_vunk_if->valid[UPLL_IDX_ADMIN_ST_VUNI] == UNC_VF_INVALID)
+ && (operation == UNC_OP_CREATE)) {
+ val_vunk_if->valid[UPLL_IDX_ADMIN_ST_VUNI] = UNC_VF_VALID_NO_VALUE;
+ val_vunk_if->admin_status = UPLL_ADMIN_ENABLE;
}
- pfc_log_trace("Value structure validation successful for vunk_If keytype");
- return ret_val;
+ return UPLL_RC_SUCCESS;
}
+
upll_rc_t VunkIfMoMgr::ValidateVtnNeighValue(
val_vtn_neighbor_t *val_vtn_neighbor) {
UPLL_FUNC_TRACE;
reinterpret_cast<char *>(val_vtn_neighbor->connected_vnode_name),
kMinLenVnodeName, kMaxLenVnodeName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("Syntax check failed.conn_vnode_name-(%s)",
- val_vtn_neighbor->connected_vnode_name);
+ UPLL_LOG_DEBUG("Syntax check failed.conn_vnode_name-(%s)",
+ val_vtn_neighbor->connected_vnode_name);
return ret_val;
}
}
if (val_vtn_neighbor->valid[UPLL_IDX_CONN_VNODE_IF_NAME_VN]
- == UNC_VF_VALID) {
+ == UNC_VF_VALID) {
ret_val = ValidateKey(
reinterpret_cast<char *>(val_vtn_neighbor->connected_if_name),
kMinLenInterfaceName, kMaxLenInterfaceName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("Syntax check failed. connected_if_name-%s",
- val_vtn_neighbor->connected_if_name);
+ UPLL_LOG_DEBUG("Syntax check failed. connected_if_name-%s",
+ val_vtn_neighbor->connected_if_name);
return ret_val;
}
}
reinterpret_cast<char *>(val_vtn_neighbor->connected_vlink_name),
kMinLenVlinkName, kMaxLenVlinkName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("Syntax check failed.connected_vlink_name=%s",
- val_vtn_neighbor->connected_vlink_name);
+ UPLL_LOG_DEBUG("Syntax check failed.connected_vlink_name=%s",
+ val_vtn_neighbor->connected_vlink_name);
return ret_val;
}
}
- pfc_log_trace("value structure validation successful for vunk_If keytype");
- return ret_val;
+ return UPLL_RC_SUCCESS;
}
upll_rc_t VunkIfMoMgr::ValidateVunkIfKey(key_vunk_if_t *key_vunk_if,
unc_keytype_operation_t operation) {
upll_rc_t ret_val = UPLL_RC_SUCCESS;
/** Validate vtn_key structure */
VunknownMoMgr *objvunkmgr =
- reinterpret_cast<VunknownMoMgr *>(const_cast<MoManager *>(GetMoManager(
- UNC_KT_VUNKNOWN)));
+ reinterpret_cast<VunknownMoMgr *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_VUNKNOWN)));
if (NULL == objvunkmgr) {
- pfc_log_debug("unable to get VunknownMoMgr to validate key_vunknown");
+ UPLL_LOG_DEBUG("unable to get VunknownMoMgr to validate key_vunknown");
return UPLL_RC_ERR_GENERIC;
}
ret_val = objvunkmgr->ValidateVunknownKey(&(key_vunk_if->vunk_key));
if (UPLL_RC_SUCCESS != ret_val) {
- pfc_log_debug("Syntax validation failed.Err Code- %d", ret_val);
+ UPLL_LOG_DEBUG("Syntax validation failed.Err Code- %d", ret_val);
return ret_val;
}
if ((operation != UNC_OP_READ_SIBLING_BEGIN) &&
kMinLenInterfaceName, kMaxLenInterfaceName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("Syntax check failed.if_name-(%s)", key_vunk_if->if_name);
+ UPLL_LOG_DEBUG("Syntax check failed.if_name-(%s)", key_vunk_if->if_name);
return ret_val;
}
} else {
UPLL_LOG_TRACE("Operation is %d", operation);
StringReset(key_vunk_if->if_name);
}
- pfc_log_trace("key structure validation successful for vunk_if keytype");
- return ret_val;
-}
-upll_rc_t VunkIfMoMgr::ValVunkIfAttributeSupportCheck(const char * crtlr_name,
- ConfigKeyVal *ikey,
- uint32_t operation) {
- UPLL_FUNC_TRACE;
- bool result_code = false;
- uint32_t instance_count = 0;
- uint32_t num_attrs = 0;
- const uint8_t *attrs = 0;
- if (ikey == NULL) {
- UPLL_LOG_DEBUG("ConfigKeyVal is NULL");
- return UPLL_RC_ERR_GENERIC;
- }
- val_vunk_if_t *val_vunk_if = NULL;
- if ((ikey->get_cfg_val())
- && ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVunkIf)) {
- val_vunk_if =
- reinterpret_cast<val_vunk_if_t *>(ikey->get_cfg_val()->get_val());
- }
- if (val_vunk_if != NULL) {
- switch (operation) {
- case UNC_OP_CREATE:
- result_code = GetCreateCapability(crtlr_name, ikey->get_key_type(),
- &instance_count, &num_attrs, &attrs);
- break;
-
- case UNC_OP_UPDATE:
- result_code = GetUpdateCapability(crtlr_name, ikey->get_key_type(),
- &num_attrs, &attrs);
- break;
-
- case UNC_OP_READ:
- case UNC_OP_READ_SIBLING:
- case UNC_OP_READ_SIBLING_BEGIN:
- case UNC_OP_READ_SIBLING_COUNT:
- result_code = GetReadCapability(crtlr_name, ikey->get_key_type(),
- &num_attrs, &attrs);
- break;
-
- default:
- pfc_log_debug("Invalid operation");
- break;
- }
-
- if (!result_code) {
- pfc_log_debug("key_type - %d is not supported by controller - %s",
- ikey->get_key_type(), crtlr_name);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
- }
- if ((val_vunk_if->valid[UPLL_IDX_DESC_VUNI] == UNC_VF_VALID)
- || (val_vunk_if->valid[UPLL_IDX_DESC_VUNI] == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vunk_if::kCapDesc] == 0) {
- val_vunk_if->valid[UPLL_IDX_DESC_VUN] = UNC_VF_NOT_SOPPORTED;
- pfc_log_debug(
- "Attribute UPLL_IDX_DESC_VUN is not supported for PFC Controller");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- }
-// #if 0 // CHECK
- if ((val_vunk_if->valid[UPLL_IDX_ADMIN_ST_VUNI] == UNC_VF_VALID)
- || (val_vunk_if->valid[UPLL_IDX_ADMIN_ST_VUNI] ==
- UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vunk_if::kCapAdminStatus] == 0) {
- val_vunk_if->valid[UPLL_IDX_ADMIN_ST_VUNI] = UNC_VF_NOT_SOPPORTED;
- pfc_log_debug("Attribute UPLL_IDX_ADMIN_ST_VUNI is not"
- " supported for PFC Controller");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- }
-// #endif
- } else {
- pfc_log_debug("Value structure is empty");
- return UPLL_RC_ERR_GENERIC;
- }
- pfc_log_info("Exiting KT_VUNK_IF ValVunkIfAttributeSupportCheck");
return UPLL_RC_SUCCESS;
}
-upll_rc_t VunkIfMoMgr::ValVtnNeighAttributeSupportCheck(const char * crtlr_name,
- ConfigKeyVal *ikey) {
- UPLL_FUNC_TRACE;
- bool result_code;
- uint32_t num_attrs = 0;
- const uint8_t *attrs = 0;
- if (ikey == NULL) {
- UPLL_LOG_DEBUG("ConfigKeyVal is NULL");
- return UPLL_RC_ERR_GENERIC;
- }
- val_vtn_neighbor_t *val_vtn_neighbor = NULL;
- if ((ikey->get_cfg_val())
- && ((ikey->get_cfg_val())->get_st_num() ==
- IpctSt::kIpcStValVtnNeighbor)) {
- val_vtn_neighbor =
- reinterpret_cast<val_vtn_neighbor_t *>(ikey->get_cfg_val()->get_val());
- }
- if (val_vtn_neighbor != NULL) {
- result_code = GetReadCapability(crtlr_name, ikey->get_key_type(),
- &num_attrs, &attrs);
- if (result_code != UPLL_RC_SUCCESS) {
- pfc_log_debug("GetCreateCapability error");
- return UPLL_RC_ERR_GENERIC;
- }
- if ((val_vtn_neighbor->valid[UPLL_IDX_CONN_VNODE_NAME_VN] == UNC_VF_VALID)
- || (val_vtn_neighbor->valid[UPLL_IDX_CONN_VNODE_NAME_VN]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vtn_neighbor::kCapConnectedVnodeName] == 0) {
- val_vtn_neighbor->valid[UPLL_IDX_CONN_VNODE_NAME_VN] =
- UNC_VF_NOT_SOPPORTED;
- pfc_log_debug("Attribute ConnectedVnodeName not supported");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- }
- if ((val_vtn_neighbor->valid[UPLL_IDX_CONN_VNODE_IF_NAME_VN]
- == UNC_VF_VALID)
- || (val_vtn_neighbor->valid[UPLL_IDX_CONN_VNODE_IF_NAME_VN]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vtn_neighbor::kCapConnectedIfName] == 0) {
- val_vtn_neighbor->valid[UPLL_IDX_CONN_VNODE_IF_NAME_VN] =
- UNC_VF_NOT_SOPPORTED;
- pfc_log_debug("Attribute ConnectedIfName not supported");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- }
-
- if ((val_vtn_neighbor->valid[UPLL_IDX_CONN_VLINK_NAME_VN] == UNC_VF_VALID)
- || (val_vtn_neighbor->valid[UPLL_IDX_CONN_VLINK_NAME_VN]
- == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vtn_neighbor::kCapConnectedVlinkName] == 0) {
- val_vtn_neighbor->valid[UPLL_IDX_CONN_VLINK_NAME_VN] =
- UNC_VF_NOT_SOPPORTED;
- pfc_log_debug("Attribute ConnectedVlinkName not supported");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- }
- } else {
- pfc_log_debug("Value structure is empty!!");
- return UPLL_RC_ERR_GENERIC;
- }
- pfc_log_info("Exiting KT_VUNK_IF:GetValVtnNeighAttributeSupported()");
- return UPLL_RC_SUCCESS;
-}
-upll_rc_t VunkIfMoMgr::ValidateCapability(IpcReqRespHeader *req,
- ConfigKeyVal *ikey, const char* cntrl_id) {
+upll_rc_t VunkIfMoMgr::IsReferenced(ConfigKeyVal *ikey,
+ upll_keytype_datatype_t dt_type,
+ DalDmlIntf *dmi) {
UPLL_FUNC_TRACE;
- upll_rc_t result_code;
- if (NULL == req) {
- UPLL_LOG_DEBUG("IpcReqRespHeader is NULL");
- return UPLL_RC_ERR_GENERIC;
- }
- if (ikey == NULL) {
- UPLL_LOG_DEBUG("ConfigKeyVal is NULL");
- return UPLL_RC_ERR_GENERIC;
- }
- /* controller name */
- if (cntrl_id == NULL)
- cntrl_id = reinterpret_cast<char *>(ikey->get_user_data());
-
- upll_keytype_datatype_t dt_type = req->datatype;
- unc_keytype_operation_t operation = req->operation;
- unc_keytype_option1_t option1 = req->option1;
- unc_keytype_option2_t option2 = req->option2;
- pfc_log_trace("dt_type : (%d)"
- "operation : (%d)"
- "option1 : (%d)"
- "option2 : (%d)",
- dt_type, operation, option1, option2);
-
- if ((operation == UNC_OP_UPDATE) && (dt_type == UPLL_DT_CANDIDATE)) {
- if (ikey->get_cfg_val()->get_val() != NULL) {
- result_code = ValVunkIfAttributeSupportCheck(cntrl_id, ikey, operation);
- if (result_code != UPLL_RC_SUCCESS) {
- pfc_log_debug("Attribute check failed VINK_IF value structure");
- return result_code;
- } else {
- pfc_log_trace("Attribute check success for UNC_OP_UPDATE operation");
- return UPLL_RC_SUCCESS;
- }
- } else {
- pfc_log_debug("Value structure mandatory for UNC_OP_UPDATE operation");
+ ConfigKeyVal *okey = NULL;
+ if (NULL == ikey)
+ return UPLL_RC_ERR_GENERIC;
+ GetChildConfigKey(okey, ikey);
+ DbSubOp dbop = { kOpReadMultiple, kOpMatchNone, kOpInOutFlag };
+ upll_rc_t result_code = ReadConfigDB(okey, dt_type, UNC_OP_READ,
+ dbop, dmi, MAINTBL);
+ if (result_code != UPLL_RC_SUCCESS) {
+ result_code = (result_code == UPLL_RC_ERR_NO_SUCH_INSTANCE)?
+ UPLL_RC_SUCCESS:result_code;
+ if (okey) delete okey;
+ return result_code;
+ }
+ ConfigKeyVal *temkey = okey;
+ while (temkey != NULL) {
+ uint8_t vlink_flag = 0;
+ GET_USER_DATA_FLAGS(temkey,vlink_flag);
+ if (vlink_flag & VIF_TYPE) {
+ delete okey;
return UPLL_RC_ERR_CFG_SEMANTIC;
}
- } else if ((operation == UNC_OP_CREATE) && (dt_type == UPLL_DT_CANDIDATE)) {
- if (ikey->get_cfg_val()->get_val() != NULL) {
- result_code = ValVunkIfAttributeSupportCheck(cntrl_id, ikey, operation);
- if (result_code != UPLL_RC_SUCCESS) {
- pfc_log_debug("Attribute check failed for VINK_IF value structure");
- return result_code;
- } else {
- pfc_log_trace("Attribute check success for UNC_OP_UPDATE operation");
- return UPLL_RC_SUCCESS;
- }
- } else {
- pfc_log_trace("value structure is optional for UNC_OP_CREATE operation");
- return UPLL_RC_SUCCESS;
- }
- } else if ((operation == UNC_OP_READ)
- && ((dt_type == UPLL_DT_CANDIDATE) || (dt_type == UPLL_DT_RUNNING)
- || (dt_type == UPLL_DT_STARTUP))) {
- if (option1 == UNC_OPT1_NORMAL) {
- if (option2 == UNC_OPT2_NEIGHBOR) {
- if (ikey->get_cfg_val()->get_val() != NULL) {
- result_code = ValVtnNeighAttributeSupportCheck(cntrl_id, ikey);
- if (result_code != UPLL_RC_SUCCESS) {
- pfc_log_debug("Attribute check failed for VINK_IF value structure");
- return result_code;
- } else {
- pfc_log_trace("Attribute check success for READ operation");
- return UPLL_RC_SUCCESS;
- }
- } else {
- pfc_log_trace("Value structure optional for UNC_OP_READ");
- return UPLL_RC_SUCCESS;
- }
- } else if (option2 != UNC_OPT2_NONE) {
- pfc_log_debug("option2 is not matching");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- } else {
- pfc_log_debug("option1 is not matching");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- } else if (((operation == UNC_OP_READ) || (operation == UNC_OP_READ_SIBLING)
- || (operation == UNC_OP_READ_SIBLING_BEGIN))
- && (dt_type == UPLL_DT_STATE)) {
- if (option1 == UNC_OPT1_NORMAL) {
- if (option2 == UNC_OPT2_NEIGHBOR) {
- if (ikey->get_cfg_val()->get_val() != NULL) {
- result_code = ValVtnNeighAttributeSupportCheck(cntrl_id, ikey);
- if (result_code != UPLL_RC_SUCCESS) {
- pfc_log_debug("Attribute check failed for VINK_IF value structure");
- return result_code;
- } else {
- pfc_log_trace("Attribute check success for READ operation");
- return UPLL_RC_SUCCESS;
- }
- } else {
- pfc_log_trace("Value structure optional for UNC_OP_READ");
- return UPLL_RC_SUCCESS;
- }
- } else if (option2 != UNC_OPT2_NONE) {
- pfc_log_debug("option2 is not matching");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- } else {
- pfc_log_debug("option1 is not matching");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- } else if (((operation == UNC_OP_READ) || (operation == UNC_OP_READ_SIBLING)
- || (operation == UNC_OP_READ_SIBLING_BEGIN)
- || (operation == UNC_OP_READ_SIBLING_COUNT))
- && ((dt_type == UPLL_DT_CANDIDATE) || (dt_type == UPLL_DT_RUNNING)
- || (dt_type == UPLL_DT_STARTUP) || (dt_type == UPLL_DT_STATE))) {
- if (option1 == UNC_OPT1_NORMAL) {
- if (option2 == UNC_OPT2_NONE) {
- if (ikey->get_cfg_val()->get_val() != NULL) {
- result_code = ValVunkIfAttributeSupportCheck(cntrl_id, ikey,
- operation);
- if (result_code != UPLL_RC_SUCCESS) {
- pfc_log_debug("Attrbute check failed for VINK_IF value structure");
- return result_code;
- } else {
- pfc_log_trace("Attribute validation success for READ operation");
- return UPLL_RC_SUCCESS;
- }
- } else {
- pfc_log_trace("value structure optional for READ");
- return UPLL_RC_SUCCESS;
- }
- } else {
- pfc_log_debug("option2 is not matching");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- } else {
- pfc_log_debug("option1 is not matching");
- return UPLL_RC_ERR_INVALID_OPTION1;
- }
- } else if ((operation == UNC_OP_DELETE) || (operation == UNC_OP_READ_NEXT)
- || (operation == UNC_OP_READ_BULK)) {
- pfc_log_trace("Value structure is none for operation type:%d", operation);
- } else {
- pfc_log_debug("Invalid datatype- %d and operation- %d", dt_type, operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ temkey = temkey->get_next_cfg_key_val();
}
- return UPLL_RC_SUCCESS;
-}
-
-upll_rc_t VunkIfMoMgr::IsReferenced(ConfigKeyVal *ikey,
- upll_keytype_datatype_t dt_type,
- DalDmlIntf *dmi) {
+ delete okey;
return UPLL_RC_SUCCESS;
}
static BindInfo vunk_if_bind_info[];
static BindInfo key_vunk_if_maintbl_update_bind_info[];
/**
- * @brief Gets the valid array position of the variable in the value
- * structure from the table in the specified configuration
+ * @brief Gets the valid array position of the variable in the value
+ * structure from the table in the specified configuration
*
- * @param[in] val pointer to the value structure
+ * @param[in] val pointer to the value structure
* @param[in] indx database index for the variable
- * @param[out] valid position of the variable in the valid array -
+ * @param[out] valid position of the variable in the valid array -
* NULL if valid does not exist.
* @param[in] dt_type specifies the configuration
- * @param[in] tbl specifies the table containing the given value
+ * @param[in] tbl specifies the table containing the given value
*
**/
upll_rc_t GetValid(void *val,
}
upll_rc_t UpdateConfigStatus(ConfigKeyVal *req, unc_keytype_operation_t op,
uint32_t driver_result, ConfigKeyVal *upd_key,
- DalDmlIntf *dmi,
+ DalDmlIntf *dmi,
ConfigKeyVal *ctrlr_key = NULL);
/**
* @brief Update config status for commit result and vote result.
*
* @param[in/out] ckv_running ConfigKeyVal instance.
* @param[in] cs_status either UNC_CS_INVALID or UNC_CS_APPLIED.
- * @param[in] phase specify the phase (CREATE,DELETE or UPDATE)
+ * @param[in] phase specify the phase (CREATE, DELETE or UPDATE)
*
**/
upll_rc_t UpdateAuditConfigStatus(unc_keytype_configstatus_t cs_status,
/**
* @brief Compares the valid value between two database records.
* if both the values are same, update the valid flag for corresponding
- * attribute as invalid in the first record.
+ * attribute as invalid in the first record.
*
* @param[in/out] val1 first record value instance.
* @param[in] val2 second record value instance.
*/
upll_rc_t ValidateCapability(IpcReqRespHeader *req,
ConfigKeyVal *ikey,
- const char *ctrlr_name = NULL);
-
- /**
- * @Brief Checks if the specified key type and
- * associated attributes are supported on the given controller,
- * based on the valid flag.
- *
- * @param[in] crtlr_name Controller name.
- * @param[in] ikey Corresponding key and value structure.
- * @param[in] operation Operation Name.
- *
- * @retval UPLL_RC_SUCCESS validation succeeded.
- * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
- * @retval UPLL_RC_ERR_GENERIC Generic failure.
- */
- upll_rc_t ValVunkIfAttributeSupportCheck(const char * crtlr_name,
- ConfigKeyVal *ikey,
- uint32_t operation);
-
- /**
- * @Brief Checks if the specified key type and
- * associated attributes are supported on the given controller,
- * based on the valid flag.
- *
- * @param[in] crtlr_name Controller name.
- * @param[in] ikey Corresponding key and value structure.
- *
- * @retval UPLL_RC_SUCCESS validation succeeded.
- * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
- * @retval UPLL_RC_ERR_GENERIC Generic failure.
- */
- upll_rc_t ValVtnNeighAttributeSupportCheck(const char * crtlr_name,
- ConfigKeyVal *ikey);
+ const char *ctrlr_name = NULL) {
+ return UPLL_RC_SUCCESS;
+ }
/**
- * @brief Duplicates the input configkeyval including the key and val.
+ * @brief Duplicates the input configkeyval including the key and val.
* based on the tbl specified.
*
* @param[in] okey Output Configkeyval - allocated within the function
MoMgrTables tbl = MAINTBL);
/**
* @brief Allocates for the specified val in the given configuration in the
- * specified table.
+ * specified table.
*
- * @param[in/out] ck_val Reference pointer to configval structure
- * allocated.
+ * @param[in/out] ck_val Reference pointer to configval structure
+ * allocated.
* @param[in] dt_type specifies the configuration candidate/running/
- * state
- * @param[in] tbl specifies if the corresponding table is the
+ * state
+ * @param[in] tbl specifies if the corresponding table is the
* main table / controller table or rename table.
*
* @retval UPLL_RC_SUCCESS Successfull completion.
* @brief Method to get a configkeyval of a specified keytype from an
* input configkeyval
*
- * @param[in/out] okey pointer to output ConfigKeyVal
+ * @param[in/out] okey pointer to output ConfigKeyVal
* @param[in] parent_key pointer to the configkeyval from
* which the output configkey val is initialized.
*
upll_rc_t GetChildConfigKey(ConfigKeyVal *&okey,
ConfigKeyVal *parent_key);
/**
- * @brief Method to get a configkeyval of the parent keytype
+ * @brief Method to get a configkeyval of the parent keytype
*
- * @param[in/out] okey pointer to parent ConfigKeyVal
- * @param[in] ikey pointer to the child configkeyval from
+ * @param[in/out] okey pointer to parent ConfigKeyVal
+ * @param[in] ikey pointer to the child configkeyval from
* which the parent configkey val is obtained.
*
* @retval UPLL_RC_SUCCESS Successfull completion.
BindInfo *&binfo,
int &nattr,
MoMgrTables tbl);
- upll_rc_t ValidateAttribute(ConfigKeyVal *kval,
+ upll_rc_t ValidateAttribute(ConfigKeyVal *kval,
DalDmlIntf *dmi,
IpcReqRespHeader *req = NULL) {
+ // string s(kval->ToStrAll());
+ // UPLL_LOG_DEBUG(" %s", s.c_str());
return UPLL_RC_SUCCESS;
}
}
/* @brief Populate val_vtn_neighbor for the READ/READ_SIBLING
- * operations
- *
- * @param[in/out] key Pointer to the ConfigKeyVal Structure
+ * operations
+ *
+ * @param[in/out] key Pointer to the ConfigKeyVal Structure
* @param[in] dmi Pointer to the DalDmlIntf(DB Interface)
- *
+ *
* @retval UPLL_RC_SUCCESS Completed successfully.
* @retval UPLL_RC_ERR_GENERIC Generic failure.
* @retval UPLL_RC_ERR_RESOURCE_DISCONNECTED Resource disconnected.
* @retval UPLL_RC_ERR_DB_ACCESS DB Read/Write error.
- * @retval UPLL_RC_ERR_NO_SUCH_INSTANCE Given key does not exist
+ * @retval UPLL_RC_ERR_NO_SUCH_INSTANCE Given key does not exist
*
**/
upll_rc_t PopulateValVtnNeighbor(ConfigKeyVal *&key, DalDmlIntf *dmi);
*/
#include "vunk_momgr.hh"
-#include "upll_log.hh"
+#include "uncxx/upll_log.hh"
#include "vtn_momgr.hh"
#define NUM_KEY_MAIN_TBL_ 4
bool VunknownMoMgr::IsValidKey(void *key, uint64_t index) {
UPLL_FUNC_TRACE;
key_vunknown *vunk_key = reinterpret_cast<key_vunknown *>(key);
- bool ret_val = UPLL_RC_SUCCESS;
+ upll_rc_t ret_val = UPLL_RC_SUCCESS;
switch (index) {
case uudst::vunknown::kDbiVtnName:
ret_val = ValidateKey(reinterpret_cast<char *>
(vunk_key->vtn_key.vtn_name),
kMinLenVtnName, kMaxLenVtnName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_info("VTN Name is not valid(%d)", ret_val);
+ UPLL_LOG_TRACE("VTN Name is not valid(%d)", ret_val);
return false;
}
break;
ret_val = ValidateKey(reinterpret_cast<char *>(vunk_key->vunknown_name),
kMinLenVnodeName, kMaxLenVnodeName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_info("Vunknown name is not valid(%d)", ret_val);
+ UPLL_LOG_TRACE("Vunknown name is not valid(%d)", ret_val);
return false;
}
break;
default:
- pfc_log_info("Invalid Key Index");
+ UPLL_LOG_INFO("Invalid Key Index");
break;
}
- pfc_log_info("Leaving IsValidKey");
return true;
}
void *pkey;
if (parent_key == NULL) {
+ if (okey) delete okey;
okey = new ConfigKeyVal(UNC_KT_VUNKNOWN, IpctSt::kIpcStKeyVunknown,
vunk_key, NULL);
return UPLL_RC_SUCCESS;
free(vunk_key);
result_code = UPLL_RC_ERR_GENERIC;
}
+ SET_USER_DATA(okey, parent_key);
return result_code;
}
uuu::upll_strncpy(vtn_key->vtn_name,
reinterpret_cast<key_vunknown *>(pkey)->vtn_key.vtn_name,
(kMaxLenVtnName+1) );
+ if (okey) delete okey;
okey = new ConfigKeyVal(UNC_KT_VTN, IpctSt::kIpcStKeyVtn, vtn_key, NULL);
if (okey == NULL) {
free(vtn_key);
if (tbl == MAINTBL) {
val_vunknown *ival = reinterpret_cast<val_vunknown *>(GetVal(req));
if (!ival) {
- UPLL_LOG_DEBUG("Invalid vunknown value\n");
+ UPLL_LOG_DEBUG("Invalid vunknown value");
return UPLL_RC_ERR_GENERIC;
}
val_vunknown *vunk_val = reinterpret_cast<val_vunknown *>
memcpy(vunk_key, ikey, sizeof(key_vunknown));
okey = new ConfigKeyVal(UNC_KT_VUNKNOWN, IpctSt::kIpcStKeyVunknown, vunk_key,
tmp1);
+ SET_USER_DATA(okey, req);
return UPLL_RC_SUCCESS;
}
ConfigKeyVal *ctrlr_key) {
UPLL_FUNC_TRACE;
val_vunknown *vunk_val;
- unc_keytype_configstatus_t cs_status = UNC_CS_NOT_APPLIED;
+ unc_keytype_configstatus_t cs_status = UNC_CS_APPLIED;
vunk_val = reinterpret_cast<val_vunknown *>(GetVal(vunk_key));
+ val_vunknown *vunk_val2 = reinterpret_cast<val_vunknown *>(GetVal(upd_key));
+ UPLL_LOG_TRACE("Key in Candidate %s",(vunk_key->ToStrAll()).c_str());
if (vunk_val == NULL) return UPLL_RC_ERR_GENERIC;
if (op == UNC_OP_CREATE) {
vunk_val->cs_row_status = cs_status;
- } else if (op != UNC_OP_UPDATE) {
+ } else if (op == UNC_OP_UPDATE) {
+ void *vunkval = reinterpret_cast<void *>(vunk_val);
+ CompareValidValue(vunkval, GetVal(upd_key), true);
+ UPLL_LOG_TRACE("Key in Running %s",(upd_key->ToStrAll()).c_str());
+ vunk_val->cs_row_status = vunk_val2->cs_row_status;
+ } else {
return UPLL_RC_ERR_GENERIC;
}
for (unsigned int loop = 0;
loop < sizeof(vunk_val->valid) / sizeof(vunk_val->valid[0]); ++loop) {
if ((UNC_VF_VALID == vunk_val->valid[loop])
|| (UNC_VF_VALID_NO_VALUE == vunk_val->valid[loop]))
- vunk_val->cs_attr[loop] = vunk_val->cs_row_status;
- else if (vunk_val->valid[loop] != UNC_VF_NOT_SOPPORTED)
- vunk_val->cs_attr[loop] = UNC_CS_NOT_SUPPORTED;
+ vunk_val->cs_attr[loop] = cs_status;
+ else if ((UNC_VF_INVALID == vunk_val->valid[loop]) &&
+ (UNC_OP_CREATE == op))
+ vunk_val->cs_attr[loop] = UNC_CS_APPLIED;
+ else if ((UNC_VF_INVALID == vunk_val->valid[loop]) &&
+ (UNC_OP_UPDATE == op)) {
+ vunk_val->cs_attr[loop] = vunk_val2->cs_attr[loop];
+ }
}
return UPLL_RC_SUCCESS;
}
return result_code;
}
upll_rc_t VunknownMoMgr::ValidateMessage(IpcReqRespHeader *req,
- ConfigKeyVal *ikey) {
+ ConfigKeyVal *ikey) {
UPLL_FUNC_TRACE;
upll_rc_t ret_val = UPLL_RC_ERR_GENERIC;
- if (NULL == req) {
- UPLL_LOG_DEBUG("IpcReqRespHeader is NULL");
- return UPLL_RC_ERR_GENERIC;
- }
- if (ikey == NULL) {
- UPLL_LOG_DEBUG("ConfigKeyVal is NULL");
- return UPLL_RC_ERR_GENERIC;
+ if (!ikey || !req || !(ikey->get_key())) {
+ UPLL_LOG_DEBUG("IpcReqRespHeader or ConfigKeyVal is Null");
+ return UPLL_RC_ERR_BAD_REQUEST;
}
if (ikey->get_st_num() != IpctSt::kIpcStKeyVunknown) {
- pfc_log_debug(
+ UPLL_LOG_DEBUG(
"Invalid structure received.Expected struct-kIpcStKeyVunknown"
"received struct -%s ",
- reinterpret_cast<const char *>(IpctSt::GetIpcStdef(ikey->get_st_num())));
- return UPLL_RC_ERR_GENERIC;
+ reinterpret_cast<const char *>(IpctSt::GetIpcStdef(ikey->get_st_num())));
+ return UPLL_RC_ERR_BAD_REQUEST;
}
key_vunknown_t *key_vunknown =
- reinterpret_cast<key_vunknown_t *>(ikey->get_key());
+ reinterpret_cast<key_vunknown_t *>(ikey->get_key());
val_vunknown_t *val_vunknown = NULL;
if ((ikey->get_cfg_val())
&& (ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVunknown) {
val_vunknown =
- reinterpret_cast<val_vunknown_t *>(ikey->get_cfg_val()->get_val());
+ reinterpret_cast<val_vunknown_t *>(ikey->get_cfg_val()->get_val());
}
upll_keytype_datatype_t dt_type = req->datatype;
unc_keytype_operation_t operation = req->operation;
unc_key_type_t keytype = ikey->get_key_type();
if (UNC_KT_VUNKNOWN != keytype) {
- pfc_log_debug("Invalid keytype. Keytype- %d", keytype);
- return UPLL_RC_ERR_GENERIC;
+ UPLL_LOG_DEBUG("Invalid keytype. Keytype- %d", keytype);
+ return UPLL_RC_ERR_BAD_REQUEST;
}
if (key_vunknown == NULL) {
- pfc_log_debug("KT_VUNKNOWN Key structure is empty!!");
- return UPLL_RC_ERR_NO_SUCH_INSTANCE;
+ UPLL_LOG_DEBUG("KT_VUNKNOWN Key structure is empty!!");
+ return UPLL_RC_ERR_BAD_REQUEST;
}
ret_val = ValidateVunknownKey(key_vunknown, operation);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("Syntax check failed for KT_VUNKNOWN key structure");
+ UPLL_LOG_DEBUG("Syntax check failed for KT_VUNKNOWN key structure");
return UPLL_RC_ERR_CFG_SYNTAX;
}
if (((operation == UNC_OP_CREATE) || (operation == UNC_OP_UPDATE))
&& (dt_type == UPLL_DT_CANDIDATE)) {
if (val_vunknown == NULL) {
- pfc_log_debug("Value structure mandatory for CREATE/UPDATE");
- return UPLL_RC_ERR_CFG_SYNTAX;
+ UPLL_LOG_DEBUG("Value structure mandatory for CREATE/UPDATE");
+ return UPLL_RC_ERR_BAD_REQUEST;
} else {
ret_val = ValidateVunknownValue(val_vunknown, operation);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("Syntax check failed for KT_VUNKNOWN value structure");
+ UPLL_LOG_DEBUG("Syntax check failed for KT_VUNKNOWN value structure");
return UPLL_RC_ERR_CFG_SYNTAX;
}
- pfc_log_trace("Syntax check success for KT_VUNKNOWN value structure");
return UPLL_RC_SUCCESS;
}
} else if (((operation == UNC_OP_READ) || (operation == UNC_OP_READ_SIBLING)
- || (operation == UNC_OP_READ_SIBLING_BEGIN)
- || (operation == UNC_OP_READ_SIBLING_COUNT))
- && ((dt_type == UPLL_DT_CANDIDATE) || (dt_type == UPLL_DT_RUNNING)
- || (dt_type == UPLL_DT_STARTUP) || (dt_type == UPLL_DT_STATE))) {
+ || (operation == UNC_OP_READ_SIBLING_BEGIN)
+ || (operation == UNC_OP_READ_SIBLING_COUNT))
+ && ((dt_type == UPLL_DT_CANDIDATE) || (dt_type == UPLL_DT_RUNNING)
+ || (dt_type == UPLL_DT_STARTUP) || (dt_type == UPLL_DT_STATE))) {
if (option1 == UNC_OPT1_NORMAL) {
if (option2 == UNC_OPT2_NONE) {
if (val_vunknown != NULL) {
ret_val = ValidateVunknownValue(val_vunknown);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("Syntax check failed for Vunknown value structure");
+ UPLL_LOG_DEBUG("Syntax check failed for Vunknown value structure");
return UPLL_RC_ERR_CFG_SYNTAX;
}
- pfc_log_trace("Validation success for KT_VUNKNOWN value structure");
return UPLL_RC_SUCCESS;
} else {
- pfc_log_trace("Value structure is optional for READ");
+ UPLL_LOG_TRACE("Value structure is optional for READ");
return UPLL_RC_SUCCESS;
}
} else {
- pfc_log_debug("option2 is not matching");
+ UPLL_LOG_DEBUG("option2 is not matching");
return UPLL_RC_ERR_INVALID_OPTION2;
}
} else {
- pfc_log_debug("option1 is not matching");
+ UPLL_LOG_DEBUG("option1 is not matching");
return UPLL_RC_ERR_INVALID_OPTION1;
}
- } else if ((operation == UNC_OP_DELETE) || (operation == UNC_OP_READ_NEXT)
- || (operation == UNC_OP_READ_BULK)) {
- pfc_log_trace("Value structure is none for operation type:%d", operation);
+ } else if ((operation == UNC_OP_DELETE) && (dt_type == UPLL_DT_CANDIDATE)) {
+ UPLL_LOG_TRACE("Value structure is none for this operation :%d", operation);
+ return UPLL_RC_SUCCESS;
+ } else if (((operation == UNC_OP_READ_NEXT) ||
+ (operation == UNC_OP_READ_BULK)) &&
+ ((dt_type == UPLL_DT_CANDIDATE) ||
+ (dt_type == UPLL_DT_RUNNING) ||
+ (dt_type == UPLL_DT_STARTUP))) {
+ UPLL_LOG_TRACE("Value structure is none for this operation :%d", operation);
return UPLL_RC_SUCCESS;
} else {
- pfc_log_debug("Invalid datatype(%d) and operation(%d)", dt_type,
- operation);
- return UPLL_RC_ERR_CFG_SYNTAX;
+ UPLL_LOG_DEBUG("Invalid datatype(%d) and operation(%d)", dt_type,
+ operation);
+ return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_DT;
}
}
+upll_rc_t VunknownMoMgr::ValidateAttribute(ConfigKeyVal *ikey, DalDmlIntf *dmi,
+ IpcReqRespHeader *req) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ controller_domain ctrlr_dom;
+ ctrlr_dom.ctrlr = ctrlr_dom.domain = NULL;
+ if (req->operation == UNC_OP_UPDATE) {
+ ConfigKeyVal *okey = NULL;
+ result_code = GetChildConfigKey(okey, ikey);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("Returing error %d",result_code);
+ if (okey) delete okey;
+ return result_code;
+ }
+ DbSubOp dbop = {kOpReadSingle, kOpMatchNone, kOpInOutCtrlr | kOpInOutDomain | kOpInOutFlag};
+ result_code = ReadConfigDB(okey, req->datatype, UNC_OP_READ, dbop, dmi, MAINTBL);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_ERROR("Record does Not Exists");
+ delete okey;
+ return result_code;
+ }
+ GET_USER_DATA_CTRLR_DOMAIN(okey,ctrlr_dom);
+ result_code = CtrlrIdAndDomainIdUpdationCheck(ikey, okey);
+ DELETE_IF_NOT_NULL(okey);
+ if (result_code != UPLL_RC_SUCCESS) {
+ UPLL_LOG_ERROR("Controller_id/domain_id updation check failed");
+ return result_code;
+ }
+ }
+ return result_code;
+}
+
+upll_rc_t VunknownMoMgr::CtrlrIdAndDomainIdUpdationCheck(ConfigKeyVal *ikey,
+ ConfigKeyVal *okey) {
+ UPLL_FUNC_TRACE;
+ val_vunknown *vunk_val = reinterpret_cast<val_vunknown *>(GetVal(ikey));
+ val_vunknown *vunk_val1 = reinterpret_cast<val_vunknown *>(GetVal(okey));
+ if (vunk_val->valid[UPLL_IDX_DOMAIN_ID_VUN] == UNC_VF_VALID) {
+ if (strncmp(reinterpret_cast<const char *>(vunk_val->domain_id),
+ reinterpret_cast<const char *>(vunk_val1->domain_id),
+ kMaxLenDomainId+1)) {
+ UPLL_LOG_DEBUG("domain id comparision failed");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ }
+ return UPLL_RC_SUCCESS;
+}
+
upll_rc_t VunknownMoMgr::ValidateVunknownKey(key_vunknown_t *key_vunknown,
unc_keytype_operation_t operation) {
UPLL_FUNC_TRACE;
bool ret_val = UPLL_RC_SUCCESS;
/** Validate vtn_key structure */
VtnMoMgr *objvtnmgr =
- reinterpret_cast<VtnMoMgr *>(const_cast<MoManager *>(GetMoManager(
- UNC_KT_VTN)));
+ reinterpret_cast<VtnMoMgr *>(const_cast<MoManager *>(GetMoManager(
+ UNC_KT_VTN)));
if (NULL == objvtnmgr) {
- pfc_log_debug("unable to get VtnMoMgr object to validate key_vtn");
+ UPLL_LOG_DEBUG("unable to get VtnMoMgr object to validate key_vtn");
return UPLL_RC_ERR_GENERIC;
}
ret_val = objvtnmgr->ValidateVtnKey(&(key_vunknown->vtn_key));
if (UPLL_RC_SUCCESS != ret_val) {
- pfc_log_debug("Vtn_name syntax validation failed.Err Code- %d", ret_val);
+ UPLL_LOG_DEBUG("Vtn_name syntax validation failed.Err Code- %d", ret_val);
return UPLL_RC_ERR_CFG_SYNTAX;
}
if ((operation != UNC_OP_READ_SIBLING_BEGIN) &&
(operation != UNC_OP_READ_SIBLING_COUNT)) {
- pfc_log_trace("KT_VUNKNOWN:vunknown_name (%s)", key_vunknown->vunknown_name);
+ UPLL_LOG_TRACE("KT_VUNKNOWN:vunknown_name (%s)", key_vunknown->vunknown_name);
ret_val = ValidateKey(reinterpret_cast<char *>(key_vunknown->vunknown_name),
kMinLenVnodeName, kMaxLenVnodeName);
if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("Validation failure for key_vunknown->vunknown_name");
+ UPLL_LOG_DEBUG("Validation failure for key_vunknown->vunknown_name");
return UPLL_RC_ERR_CFG_SYNTAX;
}
} else {
UPLL_LOG_TRACE("Operation is %d", operation);
StringReset(key_vunknown->vunknown_name);
}
- pfc_log_trace("key structure validation successful for vunknown keytype");
return UPLL_RC_SUCCESS;
}
-upll_rc_t VunknownMoMgr::ValidateVunknownValue(val_vunknown_t *val_vunknown,
- unc_keytype_operation_t operation) {
- UPLL_FUNC_TRACE;
- bool ret_val = UPLL_RC_SUCCESS;
- if (val_vunknown->valid[UPLL_IDX_CONTROLLER_ID_VUN] == UNC_VF_VALID) {
- ret_val = ValidateKey(reinterpret_cast<char *>(val_vunknown->controller_id),
- kMinLenCtrlrId,
- kMaxLenCtrlrId);
- if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("controller_id syntax check failed."
- "Received controller_id - %s",
- val_vunknown->controller_id);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- }
- if (val_vunknown->valid[UPLL_IDX_DOMAIN_ID_VUN] == UNC_VF_VALID) {
- ret_val = ValidateDefaultStr(reinterpret_cast<char *>(
- val_vunknown->domain_id),
- kMinLenDomainId,
- kMaxLenDomainId);
- if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("Domain_id syntax check failed."
- "Received Domain_id - %s",
- val_vunknown->domain_id);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- }
- if (val_vunknown->valid[UPLL_IDX_DESC_VUN] == UNC_VF_VALID) {
- ret_val = ValidateDesc(reinterpret_cast<char *>(val_vunknown->description),
- kMinLenDescription, kMaxLenDescription);
- if (ret_val != UPLL_RC_SUCCESS) {
- pfc_log_debug("Syntax check failed.desc - %s", val_vunknown->description);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else if ((val_vunknown->valid[UPLL_IDX_DESC_VUN] == UNC_VF_VALID_NO_VALUE)
- && ((operation == UNC_OP_UPDATE) || (operation == UNC_OP_CREATE))) {
- val_vunknown->description[0] = '\0';
- }
- if (val_vunknown->valid[UPLL_IDX_TYPE_VUN] == UNC_VF_VALID) {
- if (!ValidateNumericRange(val_vunknown->type,
- (uint8_t) VUNKNOWN_TYPE_BRIDGE,
- (uint8_t) VUNKNOWN_TYPE_ROUTER, true, true)) {
- pfc_log_debug("Syntax check failed.Type- %d", val_vunknown->type);
- return UPLL_RC_ERR_CFG_SYNTAX;
- }
- } else if ((val_vunknown->valid[UPLL_IDX_TYPE_VUN] == UNC_VF_VALID_NO_VALUE)
- && ((operation == UNC_OP_UPDATE) || (operation == UNC_OP_CREATE))) {
- val_vunknown->type = VUNKNOWN_TYPE_BRIDGE;
- }
- pfc_log_trace("value structure validation successful for vunknown keytype");
- return UPLL_RC_SUCCESS;
-}
-upll_rc_t VunknownMoMgr::ValVunknownAttributeSupportCheck(
- const char * crtlr_name, ConfigKeyVal *ikey, uint32_t operation) {
+upll_rc_t VunknownMoMgr::ValidateVunknownValue(val_vunknown_t *vunk_val,
+ uint32_t operation) {
UPLL_FUNC_TRACE;
- bool ret_val = false;
- uint32_t instance_count = 0;
- uint32_t num_attrs = 0;
- const uint8_t *attrs = 0;
- if (ikey == NULL) {
- UPLL_LOG_DEBUG("ConfigKeyVal is NULL");
- return UPLL_RC_ERR_GENERIC;
- }
- val_vunknown_t *val_vunknown = NULL;
- if ((ikey->get_cfg_val())
- && ((ikey->get_cfg_val())->get_st_num() == IpctSt::kIpcStValVunknown)) {
- val_vunknown = reinterpret_cast<val_vunknown_t *>(GetVal(ikey));
+ bool ret_val =false;
+
+ // Attribute syntax validation
+ for (unsigned int valid_index = 0;
+ valid_index < sizeof(vunk_val->valid) / sizeof(vunk_val->valid[0]);
+ valid_index++) {
+ if (vunk_val->valid[valid_index] == UNC_VF_VALID) {
+ switch(valid_index) {
+ case UPLL_IDX_DOMAIN_ID_VUN:
+ ret_val = ValidateDefaultStr(vunk_val->domain_id,
+ kMinLenDomainId, kMaxLenDomainId);
+ break;
+ case UPLL_IDX_DESC_VUN:
+ ret_val = ValidateDesc(vunk_val->description,
+ kMinLenDescription, kMaxLenDescription);
+ break;
+ case UPLL_IDX_TYPE_VUN:
+ ret_val = ValidateNumericRange(vunk_val->type,
+ (uint8_t) VUNKNOWN_TYPE_BRIDGE,
+ (uint8_t) VUNKNOWN_TYPE_ROUTER, true, true);
+ break;
+ }
+ if (!ret_val) {
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ }
}
- if (val_vunknown != NULL) {
+
+ // Additional checks
+ for (unsigned int valid_index = 0;
+ valid_index < sizeof(vunk_val->valid) / sizeof(vunk_val->valid[0]);
+ valid_index++) {
+ uint8_t flag = vunk_val->valid[valid_index];
switch (operation) {
case UNC_OP_CREATE:
- ret_val = GetCreateCapability(crtlr_name, ikey->get_key_type(),
- &instance_count, &num_attrs, &attrs);
+ {
+ switch(valid_index) {
+ case UPLL_IDX_DOMAIN_ID_VUN:
+ if ((flag == UNC_VF_INVALID || flag == UNC_VF_VALID_NO_VALUE)) {
+ UPLL_LOG_DEBUG("domain_id flag is invalid"
+ " or valid_no_value");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ break;
+ case UPLL_IDX_DESC_VUN:
+ break;
+ case UPLL_IDX_TYPE_VUN:
+ if ((flag == UNC_VF_INVALID) || (flag == UNC_VF_VALID_NO_VALUE)) {
+ vunk_val->type = VUNKNOWN_TYPE_BRIDGE;
+ }
+ break;
+ default:
+ break;
+ }
+ }
break;
-
case UNC_OP_UPDATE:
- ret_val = GetUpdateCapability(crtlr_name, ikey->get_key_type(),
- &num_attrs, &attrs);
+ {
+ switch(valid_index) {
+ case UPLL_IDX_DOMAIN_ID_VUN:
+ if (flag == UNC_VF_VALID_NO_VALUE) {
+ UPLL_LOG_DEBUG("controller_id or domain_id flag is valid_no_value");
+ return UPLL_RC_ERR_CFG_SYNTAX;
+ }
+ break;
+ case UPLL_IDX_DESC_VUN:
+ case UPLL_IDX_TYPE_VUN:
+ default:
+ break;
+ }
+ }
break;
+ }
+ }
- case UNC_OP_READ:
- case UNC_OP_READ_SIBLING:
- case UNC_OP_READ_SIBLING_BEGIN:
- case UNC_OP_READ_SIBLING_COUNT:
- ret_val = GetReadCapability(crtlr_name, ikey->get_key_type(),
- &num_attrs, &attrs);
+ // Resets
+ for (unsigned int valid_index = 0;
+ valid_index < sizeof(vunk_val->valid) / sizeof(vunk_val->valid[0]);
+ valid_index++) {
+ uint8_t flag = vunk_val->valid[valid_index];
+ if (flag != UNC_VF_INVALID && flag != UNC_VF_VALID_NO_VALUE)
+ continue;
+
+ switch(valid_index) {
+ case UPLL_IDX_DOMAIN_ID_VUN:
+ StringReset(vunk_val->domain_id);
+ break;
+ case UPLL_IDX_DESC_VUN:
+ StringReset(vunk_val->description);
+ break;
+ case UPLL_IDX_TYPE_VUN:
+ vunk_val->type = VUNKNOWN_TYPE_BRIDGE;
break;
-
default:
- pfc_log_debug("Invalid operation");
+ UPLL_LOG_TRACE("Never here");
break;
}
-
- if (!ret_val) {
- pfc_log_debug("key_type - %d is not supported by controller - %s",
- ikey->get_key_type(), crtlr_name);
- return UPLL_RC_ERR_NOT_ALLOWED_FOR_THIS_KT;
- }
- if ((val_vunknown->valid[UPLL_IDX_DESC_VUN] == UNC_VF_VALID)
- || (val_vunknown->valid[UPLL_IDX_DESC_VUN] == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vunknown::kCapDesc] == 0) {
- val_vunknown->valid[UPLL_IDX_DESC_VUN] = UNC_VF_NOT_SOPPORTED;
- pfc_log_trace("UPLL_IDX_DESC_VUN not supported in pfc controller");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- }
- if ((val_vunknown->valid[UPLL_IDX_TYPE_VUN] == UNC_VF_VALID)
- || (val_vunknown->valid[UPLL_IDX_TYPE_VUN] == UNC_VF_VALID_NO_VALUE)) {
- if (attrs[unc::capa::vunknown::kCapType] == 0) {
- val_vunknown->valid[UPLL_IDX_TYPE_VUN] = UNC_VF_NOT_SOPPORTED;
- pfc_log_debug("UPLL_IDX_TYPE_VUN not supported in pfc controller");
- return UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR;
- }
- }
- } else {
- pfc_log_debug("value structure is empty");
- return UPLL_RC_ERR_GENERIC;
}
- pfc_log_info("Exiting KT_VUNKOWN: ValVunknownAttributeSupportCheck()");
return UPLL_RC_SUCCESS;
}
-upll_rc_t VunknownMoMgr::ValidateCapability(IpcReqRespHeader *req,
- ConfigKeyVal *ikey, const char* ctrlr_name) {
- UPLL_FUNC_TRACE;
- upll_rc_t ret_val = UPLL_RC_SUCCESS;
- if (NULL == req) {
- UPLL_LOG_DEBUG("IpcReqRespHeader is NULL");
- return UPLL_RC_ERR_GENERIC;
- }
- if (ikey == NULL) {
- UPLL_LOG_DEBUG("ConfigKeyVal is NULL");
- return UPLL_RC_ERR_GENERIC;
+bool VunknownMoMgr::CompareValidValue(void *&val1,
+ void *val2,
+ bool copy_to_running) {
+ UPLL_FUNC_TRACE;
+ bool invalid_attr = true;
+ val_vunknown_t *val_vunknown1 = reinterpret_cast<val_vunknown_t *>(val1);
+ val_vunknown_t *val_vunknown2 = reinterpret_cast<val_vunknown_t *>(val2);
+ if (!val_vunknown2) {
+ UPLL_LOG_TRACE("Invalid param");
+ return UPLL_RC_ERR_GENERIC;
}
- /* controller name */
- if (!ctrlr_name) {
- ctrlr_name = reinterpret_cast<char *>(ikey->get_user_data());
- pfc_log_trace("controller Name :(%s)", ctrlr_name);
+ for (unsigned int loop = 0;
+ loop < sizeof(val_vunknown1->valid) / sizeof(uint8_t); ++loop) {
+ if (UNC_VF_INVALID == val_vunknown1->valid[loop]
+ && UNC_VF_VALID == val_vunknown2->valid[loop])
+ val_vunknown1->valid[loop] = UNC_VF_VALID_NO_VALUE;
+ }
+ /* Specify the configured ip address for
+ * PFC to clear the configured IP address
+ */
+ if ((UNC_VF_VALID == val_vunknown1->valid[UPLL_IDX_DESC_VUN])
+ && (UNC_VF_VALID == val_vunknown2->valid[UPLL_IDX_DESC_VUN]))
+ if (!strncmp(reinterpret_cast<char*>(val_vunknown1->description),
+ reinterpret_cast<char*>(val_vunknown2->description),
+ kMaxLenDescription))
+ val_vunknown1->valid[UPLL_IDX_DESC_VUN] = UNC_VF_INVALID;
+ if (UNC_VF_VALID == val_vunknown1->valid[UPLL_IDX_TYPE_VUN]
+ && UNC_VF_VALID == val_vunknown2->valid[UPLL_IDX_TYPE_VUN]) {
+ if (val_vunknown1->type == val_vunknown2->type)
+ val_vunknown1->valid[UPLL_IDX_TYPE_VUN] = UNC_VF_INVALID;
+ }
+ if (UNC_VF_VALID == val_vunknown1->valid[UPLL_IDX_CONTROLLER_ID_VUN]
+ && UNC_VF_VALID == val_vunknown2->valid[UPLL_IDX_CONTROLLER_ID_VUN]) {
+ if (!strcmp(reinterpret_cast<char*>(val_vunknown1->controller_id),
+ reinterpret_cast<char*>(val_vunknown2->controller_id)))
+ val_vunknown1->valid[UPLL_IDX_CONTROLLER_ID_VUN] = UNC_VF_INVALID;
+ }
+ if (UNC_VF_VALID == val_vunknown1->valid[UPLL_IDX_DOMAIN_ID_VUN]
+ && UNC_VF_VALID == val_vunknown2->valid[UPLL_IDX_DOMAIN_ID_VUN]) {
+ if (!strcmp(reinterpret_cast<char*>(val_vunknown1->domain_id),
+ reinterpret_cast<char*>(val_vunknown2->domain_id)))
+ val_vunknown1->valid[UPLL_IDX_DOMAIN_ID_VUN] = UNC_VF_INVALID;
}
- pfc_log_trace("controller Name :(%s)", ctrlr_name);
-
- upll_keytype_datatype_t dt_type = req->datatype;
- unc_keytype_operation_t operation = req->operation;
- unc_keytype_option1_t option1 = req->option1;
- unc_keytype_option2_t option2 = req->option2;
- pfc_log_trace("dt_type : (%d)"
- "operation : (%d)"
- "option1 : (%d)"
- "option2 : (%d)",
- dt_type, operation, option1, option2);
- if (((operation == UNC_OP_CREATE) || (operation == UNC_OP_UPDATE))
- && (dt_type == UPLL_DT_CANDIDATE)) {
- if (GetVal(ikey) != NULL) {
- ret_val = ValVunknownAttributeSupportCheck(ctrlr_name, ikey, operation);
- if (ret_val == UPLL_RC_SUCCESS) {
- pfc_log_trace("Attribute check success for KT_VUNKOWN value structure");
- return UPLL_RC_SUCCESS;
- } else {
- pfc_log_debug("Attribute check failed for KT_VUNKOWN value structure");
- return UPLL_RC_ERR_GENERIC;
- }
- } else {
- pfc_log_debug("Value structure mandatory for the UPDATE/CREATE");
- return UPLL_RC_ERR_GENERIC;
- }
- } else if (((operation == UNC_OP_READ) || (operation == UNC_OP_READ_SIBLING)
- || (operation == UNC_OP_READ_SIBLING_BEGIN)
- || (operation == UNC_OP_READ_SIBLING_COUNT))
- && ((dt_type == UPLL_DT_CANDIDATE) || (dt_type == UPLL_DT_RUNNING)
- || (dt_type == UPLL_DT_STARTUP) || (dt_type == UPLL_DT_STATE))) {
- if (option1 == UNC_OPT1_NORMAL) {
- if (option2 == UNC_OPT2_NONE) {
- if (GetVal(ikey) != NULL) {
- ret_val = ValVunknownAttributeSupportCheck(ctrlr_name, ikey,
- operation);
- if (ret_val == UPLL_RC_SUCCESS) {
- pfc_log_trace("Attribute check success for VUNKOWN value struct");
- return UPLL_RC_SUCCESS;
- } else {
- pfc_log_debug("Attribute check failed for KT_VUNKOWN value struct");
- return UPLL_RC_ERR_GENERIC;
- }
- } else {
- pfc_log_trace("Value structure is optional for READ");
- return UPLL_RC_SUCCESS;
- }
- } else {
- pfc_log_debug("option2 is not matching");
- return UPLL_RC_ERR_INVALID_OPTION2;
- }
- } else {
- pfc_log_debug("option1 is not matching");
- return UPLL_RC_ERR_INVALID_OPTION1;
+ for (unsigned int loop = 0;
+ loop < sizeof(val_vunknown1->valid) / sizeof(uint8_t); ++loop) {
+ if ((UNC_VF_VALID == (uint8_t) val_vunknown1->valid[loop]) ||
+ (UNC_VF_VALID_NO_VALUE == (uint8_t) val_vunknown1->valid[loop])) {
+ invalid_attr = false;
+ break;
}
- } else if ((operation == UNC_OP_DELETE) || (operation == UNC_OP_READ_NEXT)
- || (operation == UNC_OP_READ_BULK)) {
- pfc_log_trace("Value structure is none for operation type:%d", operation);
- return UPLL_RC_SUCCESS;
- } else {
- pfc_log_debug("Invalid datatype(%d) and operation(%d)", dt_type, operation);
- return UPLL_RC_ERR_GENERIC;
}
-}
-
-bool VunknownMoMgr::CompareValidValue(void *&val1, void *val2, bool audit) {
- return false;
+ return invalid_attr;
}
upll_rc_t VunknownMoMgr::CreateVnodeConfigKey(ConfigKeyVal *ikey,
upll_rc_t VunknownMoMgr::IsReferenced(ConfigKeyVal *ikey,
upll_keytype_datatype_t dt_type,
DalDmlIntf *dmi) {
+ UPLL_FUNC_TRACE;
+ upll_rc_t result_code = UPLL_RC_SUCCESS;
+ MoMgrImpl *mgr = reinterpret_cast<MoMgrImpl *>(const_cast<MoManager*>
+ (GetMoManager(UNC_KT_VUNK_IF)));
+ result_code = mgr->IsReferenced(ikey, dt_type, dmi);
+ if (UPLL_RC_SUCCESS != result_code) {
+ UPLL_LOG_DEBUG("UPLL_RC_ERR_NO_SUCH_INSTANCE != result_code (%d)",
+ result_code);
+ return result_code;
+ }
+ UPLL_LOG_DEBUG("IsReferenced result code (%d)", result_code);
return UPLL_RC_SUCCESS;
}
static BindInfo vunk_bind_info[];
static BindInfo key_vunk_maintbl_update_bind_info[];
/**
- * @brief Gets the valid array position of the variable in the value
- * structure from the table in the specified configuration
+ * @brief Gets the valid array position of the variable in the value
+ * structure from the table in the specified configuration
*
- * @param[in] val pointer to the value structure
+ * @param[in] val pointer to the value structure
* @param[in] indx database index for the variable
- * @param[out] valid position of the variable in the valid array -
+ * @param[out] valid position of the variable in the valid array -
* NULL if valid does not exist.
* @param[in] dt_type specifies the configuration
- * @param[in] tbl specifies the table containing the given value
+ * @param[in] tbl specifies the table containing the given value
*
**/
upll_rc_t GetValid(void *val, uint64_t indx, uint8_t *&valid,
/**
* @brief Compares the valid value between two database records.
* if both the values are same, update the valid flag for corresponding
- * attribute as invalid in the first record.
+ * attribute as invalid in the first record.
*
* @param[in/out] val1 first record value instance.
* @param[in] val2 second record value instance.
* @retval UPLL_RC_ERR_CFG_SYNTAX validation failed.
*/
upll_rc_t ValidateVunknownValue(val_vunknown_t *val_vunknown,
- unc_keytype_operation_t operation = UNC_OP_INVALID);
+ uint32_t operation = UNC_OP_INVALID);
/**
* @Brief Checks if the specified key type(KT_VUNKNOWN) and
* @retval UPLL_RC_ERR_INVALID_OPTION2 Option2 is not valid.
*/
upll_rc_t ValidateCapability(IpcReqRespHeader *req, ConfigKeyVal *ikey,
- const char * crtlr_name = NULL);
-
- /**
- * @Brief Checks if the specified key type and
- * associated attributes are supported on the given controller,
- * based on the valid flag.
- *
- * @param[in] crtlr_name Controller name.
- * @param[in] ikey Corresponding key and value structure.
- *
- * @retval UPLL_RC_SUCCESS validation succeeded.
- * @retval UPLL_RC_ERR_NOT_SUPPORTED_BY_CTRLR Attribute NOT_SUPPORTED.
- * @retval UPLL_RC_ERR_GENERIC Generic failure.
- */
- upll_rc_t ValVunknownAttributeSupportCheck(const char * crtlr_name,
- ConfigKeyVal *ikey,
- uint32_t operation);
+ const char * crtlr_name = NULL) {
+ return UPLL_RC_SUCCESS;
+ }
/**
* @brief Method to check if individual portions of a key are valid
*
**/
bool IsValidKey(void *key, uint64_t index);
/**
- * @brief Duplicates the input configkeyval including the key and val.
+ * @brief Duplicates the input configkeyval including the key and val.
* based on the tbl specified.
*
* @param[in] okey Output Configkeyval - allocated within the function
upll_rc_t DupConfigKeyVal(ConfigKeyVal *&okey, ConfigKeyVal *&req,
MoMgrTables tbl = MAINTBL);
/**
- * @brief Allocates for the specified val in the given configuration in the * specified table.
+ * @brief Allocates for the specified val in the given configuration in the * specified table.
*
- * @param[in/out] ck_val Reference pointer to configval structure
- * allocated.
+ * @param[in/out] ck_val Reference pointer to configval structure
+ * allocated.
* @param[in] dt_type specifies the configuration candidate/running/
- * state
- * @param[in] tbl specifies if the corresponding table is the
+ * state
+ * @param[in] tbl specifies if the corresponding table is the
* main table / controller table or rename table.
*
* @retval UPLL_RC_SUCCESS Successfull completion.
/**
* @brief Method to get a configkeyval of a specified keytype from an input configkeyval
*
- * @param[in/out] okey pointer to output ConfigKeyVal
+ * @param[in/out] okey pointer to output ConfigKeyVal
* @param[in] parent_key pointer to the configkeyval from which the output configkey val is initialized.
*
* @retval UPLL_RC_SUCCESS Successfull completion.
*/
upll_rc_t GetChildConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *parent_key);
/**
- * @brief Method to get a configkeyval of the parent keytype
+ * @brief Method to get a configkeyval of the parent keytype
*
- * @param[in/out] okey pointer to parent ConfigKeyVal
- * @param[in] ikey pointer to the child configkeyval from
+ * @param[in/out] okey pointer to parent ConfigKeyVal
+ * @param[in] ikey pointer to the child configkeyval from
* which the parent configkey val is obtained.
*
* @retval UPLL_RC_SUCCESS Successfull completion.
upll_rc_t CopyToConfigKey(ConfigKeyVal *&okey, ConfigKeyVal *ikey);
bool GetRenameKeyBindInfo(unc_key_type_t key_type, BindInfo *&binfo,
int &nattr, MoMgrTables tbl);
- upll_rc_t ValidateAttribute(ConfigKeyVal *kval,
+ upll_rc_t ValidateAttribute(ConfigKeyVal *kval,
DalDmlIntf *dmi,
- IpcReqRespHeader *req = NULL) {
- return UPLL_RC_SUCCESS;
- }
+ IpcReqRespHeader *req = NULL);
public:
VunknownMoMgr();
DalDmlIntf *dmi) {
return UPLL_RC_SUCCESS;
}
+
+ /**
+ * @Brief compares controller id and domain id before
+ * updating the value to DB.
+ *
+ * @param[in] ikey ikey contains key and value structure.
+ * @param[in] okey okey contains key and value structure.
+ *
+ * @retval UPLL_RC_SUCCESS Successful.
+ * @retval UPLL_RC_ERR_CFG_SYNTAX Syntax error.
+ */
+ upll_rc_t CtrlrIdAndDomainIdUpdationCheck(ConfigKeyVal *ikey,
+ ConfigKeyVal *okey);
/**
* @Brief Validates the syntax for KT_VUNKNOWN keytype key structure.
*
*
*/
+#include <cctype>
#include "physical_core.hh"
+
using std::istringstream;
namespace unc {
/**
* @Description : ControllerVersion class constructor implementation
*/
-
-ControllerVersion::ControllerVersion(string version) {
- version_ = version;
- product_version_part1_ = 0;
- product_version_part2_ = 0;
- product_version_part3_ = 0;
- UpplReturnCode return_code = ParseControllerVersion(version_);
+ControllerVersion::ControllerVersion(string version,
+ UpplReturnCode &return_code):
+ version_(version),
+ product_version_part1_(0),
+ product_version_part2_(0),
+ product_version_part3_(0) {
+ return_code = ParseControllerVersion(version_);
if (return_code != UPPL_RC_SUCCESS) {
pfc_log_error("Controller version parsing error");
}
}
+
/**
* @Description : This function parses the given controller version string and
* fills the class data members
+ *@param[in] : version - specifies the controller version
+ *@return : UPPL_RC_SUCCESS or any associated erro code
*/
UpplReturnCode ControllerVersion::ParseControllerVersion(string version) {
// String parsing of controller version
vector<string> split_version;
istringstream strversion(version);
- string temp_version;
+ string temp_version = "";
while (getline(strversion, temp_version, '.')) {
split_version.push_back(temp_version);
}
if (split_version.empty()) {
// unable to get version
- return UPPL_RC_FAILURE;
+ return UPPL_RC_ERR_CFG_SYNTAX;
}
for (unsigned int index = 0 ; index < split_version.size(); ++index) {
+ string part_version = split_version[index];
uint16_t version_part =
- static_cast<uint16_t>(atoi(split_version[index].c_str()));
+ static_cast<uint16_t>(atoi(part_version.c_str()));
+ if (version_part == 0 && isdigit(part_version[0]) == 0) {
+ pfc_log_error("Unable to parse the version part: %s",
+ part_version.c_str());
+ return UPPL_RC_ERR_CFG_SYNTAX;
+ }
switch (index) {
case 0 : {
product_version_part1_ = version_part;
*/
class ControllerVersion {
public:
- explicit ControllerVersion(string version);
+ explicit ControllerVersion(string version,
+ UpplReturnCode &return_code);
~ControllerVersion() {}
/*
@brief IPCClientConfigurationHandler header
@file ipc_client_configuration_handler.hh
- @ Desc: This header file contains the declaration of IPCClientConfigurationHandler class
+ @ Desc: This header file contains the declaration of
+ IPCClientConfigurationHandler class
*
*/
class IPCClientDriverHandler {
public:
- IPCClientDriverHandler(unc_keytype_ctrtype_t type, int &err);
+ IPCClientDriverHandler(unc_keytype_ctrtype_t type, UpplReturnCode &err);
~IPCClientDriverHandler();
IPCClientDriverHandler();
IPCClientDriverHandler(const IPCClientDriverHandler&);
/*
@brief IPCClientLogicalHandler header
@file ipc_client_logical_handler.hh
- @ Desc: This header file contains the declaration of IPCClientConfigurationHandler class
+ @ Desc: This header file contains the declaration of
+ IPCClientLogicalHandler class
*
*/
#include "ipc_server_handler.hh"
#include "ipc_client_logical_handler.hh"
#include "physical_notification_manager.hh"
+#include "odbcm_connection.hh"
using std::string;
+using std::vector;
+using std::map;
namespace unc {
namespace uppl {
void addControllerToAuditList(string);
UpplReturnCode removeControllerFromAuditList(string);
pfc_bool_t IsControllerInAudit(string controller_name);
- uint32_t StartNotificationTimer(string controller_name);
- Timer *notfn_timer_;
- TaskQueue* taskq_;
- map<string, uint32_t> notfn_timer_id_;
+ uint32_t StartNotificationTimer(OdbcmConnectionHandler *db_conn,
+ string controller_name);
void setTimeOutId(string controller_name, uint32_t notfn_timer_id) {
notfn_timer_id_[controller_name] = notfn_timer_id;
}
}
return timer_id;
}
+ UpplReturnCode CancelTimer(string);
private:
IPCServerHandler* ipc_server_handler_;
string uppl_ipc_service_name_;
// vector to denote a controller is being audited
vector<string> controller_in_audit_;
+ map<string, uint32_t> notfn_timer_id_;
+ map<string, Timer *> timer_obj_;
+ map<string, TaskQueue *> queue_obj_;
};
} // namespace uppl
} // namespace unc
public:
AuditRequest();
~AuditRequest();
- UpplReturnCode StartAudit(unc_keytype_ctrtype_t driver_id,
+ UpplReturnCode StartAudit(OdbcmConnectionHandler *db_conn,
+ unc_keytype_ctrtype_t driver_id,
string controller_id);
UpplReturnCode StartAuditTransaction(uint32_t session_id,
unc_keytype_ctrtype_t driver_id,
string controller_id,
TcDriverInfoMap& driver_info,
TcAuditResult& audit_result);
- UpplReturnCode HandleAuditVoteRequest(uint32_t session_id,
+ UpplReturnCode HandleAuditVoteRequest(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t driver_id,
string controller_id,
TcDriverInfoMap &driver_info);
UpplReturnCode EndAuditTransaction(uint32_t session_id,
unc_keytype_ctrtype_t& driver_id,
string controller_id);
- UpplReturnCode EndAudit(unc_keytype_ctrtype_t driver_id,
+ UpplReturnCode EndAudit(OdbcmConnectionHandler *db_conn,
+ unc_keytype_ctrtype_t driver_id,
string controller_id,
TcAuditResult audit_result);
- UpplReturnCode MergeAuditDbToRunning(string controller_name);
+ UpplReturnCode MergeAuditDbToRunning(OdbcmConnectionHandler *db_conn,
+ string controller_name);
private:
Kt_Base* GetClassPointerAndKey(AuditStateObjects audit_key_type,
void FreeKeyAndValueStruct(void* key_struct,
void* value_struct,
unsigned int key_type);
+ void AddToRunningDbFromImportDb(const vector<void *> &key_import,
+ const vector<void *> &val_import,
+ const vector<void *> &key_running,
+ const vector<void *> &val_running,
+ unsigned int index,
+ Kt_Base *class_pointer,
+ OdbcmConnectionHandler *db_conn,
+ uint32_t key_type);
+ void UpdateRunningDbWithImportDb(const vector<void *> &key_import,
+ const vector<void *> &val_import,
+ const vector<void *> &key_running,
+ const vector<void *> &val_running,
+ unsigned int index,
+ Kt_Base *class_pointer,
+ OdbcmConnectionHandler *db_conn,
+ uint32_t key_type);
+ void FreeKeyAndValueStruct(const vector<void *> &key_import,
+ const vector<void *> &val_import,
+ const vector<void *> &key_running,
+ const vector<void *> &val_running,
+ unsigned int index);
};
class AuditNotification : public std::unary_function < void, void > {
public:
string controller_name_;
- explicit AuditNotification() {}
- void operator() () {
- pfc_log_debug("Received Audit Notification timer out controller %s",
- controller_name_.c_str());
- AuditRequest audit_req;
- audit_req.MergeAuditDbToRunning(controller_name_);
+ explicit AuditNotification() {
}
+ void operator() ();
};
} // namespace uppl
#include "pfc/debug.h"
using unc::uppl::ITCReq;
-
+using unc::uppl::OdbcmConnectionHandler;
/*
- * It is a singleton class which will be inherited from ITCReq
+ * This Class which will be inherited from ITCReq
* class to process config req.
* For further info,see the comments in .cc file
*/
public:
ConfigurationRequest();
~ConfigurationRequest();
- UpplReturnCode ProcessReq(ServerSession &session);
- UpplReturnCode ValidateReq(ServerSession &session,
+ UpplReturnCode ProcessReq(ServerSession &session,
+ physical_request_header &obj_req_hdr);
+ UpplReturnCode ValidateReq(OdbcmConnectionHandler *db_conn,
+ ServerSession &session,
physical_request_header obj_req_hdr,
void* &key_struct,
void* &val_struct,
val_ctr_domain_t val_domain_obj;
key_boundary_t key_boundary_obj;
val_boundary_t val_boundary_obj;
- UpplReturnCode ValidateController(ServerSession &session,
+ UpplReturnCode ValidateController(OdbcmConnectionHandler *db_conn,
+ ServerSession &session,
uint32_t data_type,
uint32_t operation,
void* &key_struct,
void* &val_struct);
- UpplReturnCode ValidateDomain(ServerSession &session,
+ UpplReturnCode ValidateDomain(OdbcmConnectionHandler *db_conn,
+ ServerSession &session,
uint32_t data_type,
uint32_t operation,
void* &key_struct,
void* &val_struct);
- UpplReturnCode ValidateBoundary(ServerSession &session,
+ UpplReturnCode ValidateBoundary(OdbcmConnectionHandler *db_conn,
+ ServerSession &session,
uint32_t data_type,
uint32_t operation,
void* &key_struct,
#include <unc/uppl_common.h>
#include "physical_common_def.hh"
#include "physical_itc_req.hh"
+#include "odbcm_connection.hh"
+using unc::uppl::OdbcmConnectionHandler;
namespace unc {
namespace uppl {
public:
DBConfigurationRequest();
~DBConfigurationRequest();
- UpplReturnCode LoadAndCommitStartup();
- UpplReturnCode ClearStartUpDb();
- UpplReturnCode ClearAllDb();
- UpplReturnCode AbortCandidateDb();
- UpplReturnCode SaveCandidateToRunning();
- UpplReturnCode SaveRunningToStartUp();
- UpplReturnCode AuditStartUp();
- UpplReturnCode AuditRunningDb();
- UpplReturnCode SendDeletedControllerToLogical();
- UpplReturnCode SendCreatedControllerToLogical();
- UpplReturnCode SendUpdatedControllerToLogical();
+ UpplReturnCode LoadAndCommitStartup(OdbcmConnectionHandler *db_conn);
+ UpplReturnCode ClearStartUpDb(OdbcmConnectionHandler *db_conn);
+ UpplReturnCode AbortCandidateDb(OdbcmConnectionHandler *db_conn);
+ UpplReturnCode SaveRunningToStartUp(OdbcmConnectionHandler *db_conn);
+ UpplReturnCode SendDeletedControllerToLogical(
+ OdbcmConnectionHandler *db_conn);
+ UpplReturnCode SendCreatedControllerToLogical(
+ OdbcmConnectionHandler *db_conn);
+ UpplReturnCode SendUpdatedControllerToLogical(
+ OdbcmConnectionHandler *db_conn);
+ UpplReturnCode SendAppliedControllerToLogical(
+ OdbcmConnectionHandler *db_conn);
};
} // namespace uppl
} // namespace unc
#endif
-
public:
ImportRequest();
~ImportRequest();
- UpplReturnCode ProcessRequest(uint32_t operation,
+ UpplReturnCode ProcessRequest(OdbcmConnectionHandler *db_conn,
+ uint32_t operation,
key_ctr_t obj_key_ctr);
- UpplReturnCode StartImport(key_ctr_t obj_key_ctr);
+ UpplReturnCode StartImport(OdbcmConnectionHandler *db_conn,
+ key_ctr_t obj_key_ctr);
UpplReturnCode MergeConfiguration(key_ctr_t obj_key_ctr);
UpplReturnCode ClearImportConfig(key_ctr_t obj_key_ctr);
};
#include "unc/uppl_common.h"
#include "ipc_connection_manager.hh"
#include "odbcm_utils.hh"
+#include "odbcm_common.hh"
+#include "odbcm_connection.hh"
using std::vector;
using std::map;
using pfc::core::ipc::ServerSession;
using unc::uppl::ODBCMOperator;
using unc::uppl::DBTableSchema;
+using unc::uppl::ODBCMTableColumns;
+using unc::uppl::OdbcmConnectionHandler;
+class ReadRequest;
class Kt_Class_Attr_Syntax {
public:
string default_value;
};
-class Kt_Base {
+class OperStatusHolder {
+ private:
+ unc_key_type_t key_type_;
+ void* key_struct_;
+ uint8_t oper_status_;
public:
- Kt_Base();
+ OperStatusHolder(unc_key_type_t key_type,
+ void* key_struct,
+ uint8_t oper_status) {
+ key_type_ = key_type;
+ key_struct_ = key_struct;
+ oper_status_ = oper_status;
+ };
+ unc_key_type_t get_key_type() {return key_type_;}
+ void* get_key_struct() {return key_struct_;}
+ uint8_t get_oper_status() {return oper_status_;}
+};
+class Kt_Base {
+ public:
virtual ~Kt_Base() {
};
unc_key_type_t get_key_type() {
return UNC_KT_ROOT;
};
- virtual UpplReturnCode Create(uint32_t session_id, uint32_t configuration_id,
+ virtual UpplReturnCode Create(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id, uint32_t configuration_id,
void* key_struct, void* val_struct,
uint32_t data_type, ServerSession &sess) {
return UPPL_RC_SUCCESS;
};
- virtual UpplReturnCode CreateKeyInstance(void* key_struct,
+ virtual UpplReturnCode CreateKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t key_type) {
return UPPL_RC_SUCCESS;
};
- virtual UpplReturnCode UpdateKeyInstance(void* key_struct, void* val_struct,
+ virtual UpplReturnCode UpdateKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct, void* val_struct,
uint32_t data_type,
uint32_t key_type,
void* &old_val_struct) {
return UPPL_RC_SUCCESS;
};
- virtual UpplReturnCode Update(uint32_t session_id, uint32_t configuration_id,
+ virtual UpplReturnCode Update(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id, uint32_t configuration_id,
void* key_struct, void* val_struct,
uint32_t data_type, ServerSession &sess) {
return UPPL_RC_SUCCESS;
};
- virtual UpplReturnCode Delete(uint32_t session_id, uint32_t configuration_id,
+ virtual UpplReturnCode Delete(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id, uint32_t configuration_id,
void* key_struct, uint32_t data_type,
ServerSession &sess) {
return UPPL_RC_SUCCESS;
};
- virtual UpplReturnCode DeleteKeyInstance(void* key_struct,
+ virtual UpplReturnCode DeleteKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
uint32_t key_type) {
return UPPL_RC_SUCCESS;
};
- virtual UpplReturnCode ReadInternal(vector<void*> &key_struct,
+ virtual UpplReturnCode ReadInternal(OdbcmConnectionHandler *db_conn,
+ vector<void*> &key_struct,
vector<void*> &val_struct,
uint32_t data_type,
uint32_t operation_type) {
return UPPL_RC_SUCCESS;
};
- virtual UpplReturnCode Read(uint32_t session_id, uint32_t configuration_id,
+ virtual UpplReturnCode Read(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id, uint32_t configuration_id,
void* key_struct, void* val_struct,
uint32_t data_type, ServerSession &sess,
uint32_t option1, uint32_t option2);
- virtual UpplReturnCode ReadNext(void* key_struct,
+ virtual UpplReturnCode ReadNext(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
- uint32_t option1, uint32_t option2);
+ ReadRequest *read_req);
- virtual UpplReturnCode ReadBulk(void* key_struct,
+ virtual UpplReturnCode ReadBulk(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
- uint32_t option1,
- uint32_t option2,
uint32_t &max_rep_ct,
int child_index,
pfc_bool_t parent_call,
- pfc_bool_t is_read_next)=0;
+ pfc_bool_t is_read_next,
+ ReadRequest *read_req)=0;
- virtual UpplReturnCode ReadSiblingBegin(uint32_t session_id,
+ virtual UpplReturnCode ReadSiblingBegin(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct, void* val_struct,
uint32_t data_type,
uint32_t option1, uint32_t option2,
uint32_t &max_rep_ct);
- virtual UpplReturnCode ReadSibling(uint32_t session_id,
+ virtual UpplReturnCode ReadSibling(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct, void* val_struct,
uint32_t data_type, ServerSession &sess,
uint32_t option1, uint32_t option2,
uint32_t &max_rep_ct);
- virtual UpplReturnCode ReadSiblingCount(uint32_t session_id,
+ virtual UpplReturnCode ReadSiblingCount(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct, void* val_struct,
uint32_t key_type,
ServerSession &sess,
uint32_t option1, uint32_t option2);
- virtual UpplReturnCode PerformRead(uint32_t session_id,
+ virtual UpplReturnCode PerformRead(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct, void* val_struct,
uint32_t data_type,
ServerSession &sess, uint32_t option1,
uint32_t option2, uint32_t max_rep_ct)=0;
- virtual UpplReturnCode PerformSyntaxValidation(void* key_struct,
- void* val_struct,
- uint32_t operation,
- uint32_t data_type)=0;
+ virtual UpplReturnCode PerformSyntaxValidation(
+ OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ void* val_struct,
+ uint32_t operation,
+ uint32_t data_type)=0;
- virtual UpplReturnCode PerformSemanticValidation(void* key_struct,
- void* val_struct,
- uint32_t operation,
- uint32_t data_type)=0;
+ virtual UpplReturnCode PerformSemanticValidation(
+ OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ void* val_struct,
+ uint32_t operation,
+ uint32_t data_type)=0;
UpplReturnCode
- ValidateRequest(void* key_struct, void* val_struct, uint32_t operation,
+ ValidateRequest(OdbcmConnectionHandler *db_conn,
+ void* key_struct, void* val_struct, uint32_t operation,
uint32_t data_type, uint32_t key_type);
virtual UpplReturnCode ValidateCtrlrValueCapability(string version,
// A switch within a controller is existing
// In this case list will contain two values -
// a controller id and a switch id
- virtual UpplReturnCode IsKeyExists(unc_keytype_datatype_t data_type, vector<
- string> key_values) {
+ virtual UpplReturnCode IsKeyExists(OdbcmConnectionHandler *db_conn,
+ unc_keytype_datatype_t data_type,
+ const vector<string>& key_values) {
return UPPL_RC_SUCCESS;
};
void* old_val_struct,
void* new_val_struct);
- virtual UpplReturnCode HandleDriverAlarms(uint32_t data_type,
+ virtual UpplReturnCode HandleDriverAlarms(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
uint32_t alarm_type,
uint32_t oper_type,
void* key_struct,
return UPPL_RC_SUCCESS;
};
- virtual UpplReturnCode GetModifiedRows(vector<void *> &key_struct, vector<
- void *> &val_struct,
+ virtual UpplReturnCode GetModifiedRows(OdbcmConnectionHandler *db_conn,
+ vector<void *> &key_struct,
+ vector<void *> &val_struct,
CsRowStatus row_status) {
return UPPL_RC_SUCCESS;
};
- map<string, Kt_Class_Attr_Syntax> attr_syntax_map;
virtual void Fill_Attr_Syntax_Map() {
};
- virtual UpplReturnCode HandleOperStatus(uint32_t data_type,
+ virtual UpplReturnCode HandleOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void *key_struct,
void *value_struct) {
return UPPL_RC_SUCCESS;
};
- virtual UpplReturnCode NotifyOperStatus(uint32_t data_type,
+ virtual UpplReturnCode NotifyOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void *key_struct,
void *value_struct) {
return UPPL_RC_SUCCESS;
return UPPL_RC_SUCCESS;
};
virtual void
- PopulateDBSchemaForKtTable(DBTableSchema &kt_dbtableschema,
+ PopulateDBSchemaForKtTable(OdbcmConnectionHandler *db_conn,
+ DBTableSchema &kt_dbtableschema,
void* key_struct, void* val_struct,
- uint8_t operation_type, uint32_t option1,
- uint32_t option2,
+ uint8_t operation_type, uint32_t data_type,
+ uint32_t option1, uint32_t option2,
vector<ODBCMOperator> &vect_key_operations,
void* &old_value_struct,
CsRowStatus row_status = NOTAPPLIED,
void *new_value_struct,
void *old_value_struct);
void ClearValueStructure(uint32_t key_type,
- void *old_value_struct);
+ void *&old_value_struct);
+ static map<unc_key_type_t, map<string, Kt_Class_Attr_Syntax> >
+ attr_syntax_map_all;
+ UpplReturnCode get_oper_status(vector<OperStatusHolder> &ref_oper_status,
+ unc_key_type_t key_type,
+ void* key_struct,
+ uint8_t &oper_status);
+ void ClearOperStatusHolder(vector<OperStatusHolder> &ref_oper_status);
private:
UpplReturnCode ValidateKtRoot(uint32_t operation,
attr_name); \
} \
}
+
+#define ADD_CTRL_OPER_STATUS(controller_name, oper_status) \
+ key_ctr_t *ctlr_key = new key_ctr_t; \
+ memset(ctlr_key->controller_name, 0, 32); \
+ memcpy(ctlr_key->controller_name, controller_name.c_str(), \
+ controller_name.length()+1); \
+ OperStatusHolder obj_oper_status_ctr(UNC_KT_CONTROLLER, \
+ reinterpret_cast<void *>(ctlr_key), \
+ oper_status); \
+ ref_oper_status.push_back(obj_oper_status_ctr); \
+
+#define GET_ADD_CTRL_OPER_STATUS(controller_name) \
+ key_ctr_t *ctr_key = new key_ctr_t; \
+ memset(ctr_key->controller_name, 0, 32); \
+ memcpy(ctr_key->controller_name, controller_name.c_str(), \
+ (controller_name.length())+1); \
+ void* key_type_struct = reinterpret_cast<void*>(ctr_key); \
+ Kt_Controller controller; \
+ uint8_t ctr_oper_status = \
+ (UpplControllerOperStatus) UPPL_CONTROLLER_OPER_UP; \
+ uint32_t ctrl_data_type = data_type; \
+ if (data_type == UNC_DT_IMPORT) { \
+ ctrl_data_type = UNC_DT_RUNNING; \
+ } \
+ UpplReturnCode read_status = controller.GetOperStatus( \
+ db_conn, ctrl_data_type, key_type_struct, ctr_oper_status); \
+ pfc_log_debug("Controller's read_status %d, oper_status %d", \
+ read_status, ctr_oper_status); \
+ OperStatusHolder obj_oper_status_ctr(UNC_KT_CONTROLLER, \
+ reinterpret_cast<void *>(ctr_key), \
+ ctr_oper_status); \
+ ref_oper_status.push_back(obj_oper_status_ctr); \
+
+#define ADD_SWITCH_OPER_STATUS(sw_key, oper_status) \
+ key_switch_t *p_switch = new key_switch_t(sw_key); \
+ OperStatusHolder obj_oper_status_sw(UNC_KT_SWITCH, \
+ reinterpret_cast<void*>(p_switch), \
+ oper_status); \
+ ref_oper_status.push_back(obj_oper_status_sw);
+
+#define ADD_PORT_OPER_STATUS(port_key, oper_status) \
+ key_port_t *p_port = new key_port_t(port_key); \
+ OperStatusHolder obj_oper_status_port(UNC_KT_PORT, \
+ reinterpret_cast<void*>(p_port), \
+ oper_status); \
+ ref_oper_status.push_back(obj_oper_status_port);
+
+#define ADD_LP_PORT_OPER_STATUS(lp_key, oper_status) \
+ key_logical_port_t *p_lport = new key_logical_port_t(lp_key); \
+ OperStatusHolder obj_oper_status_lp(UNC_KT_LOGICAL_PORT, \
+ reinterpret_cast<void*>(p_lport), \
+ oper_status); \
+ ref_oper_status.push_back(obj_oper_status_lp); \
+
#endif
/*@ Boundary Class definition */
class Kt_Boundary: public Kt_Base {
- private:
- Kt_Base* parent;
-
public:
Kt_Boundary();
~Kt_Boundary();
- UpplReturnCode Create(uint32_t session_id,
+ UpplReturnCode Create(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t data_type,
ServerSession & sess);
- UpplReturnCode CreateKeyInstance(void* key_struct,
+ UpplReturnCode CreateKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t key_type);
- UpplReturnCode Update(uint32_t session_id,
+ UpplReturnCode Update(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t data_type,
ServerSession & sess);
- UpplReturnCode ReadInternal(vector<void *> &boundary_key,
+ UpplReturnCode ReadInternal(OdbcmConnectionHandler *db_conn,
+ vector<void *> &boundary_key,
vector<void *> &boundary_val,
uint32_t data_type,
uint32_t operation_type);
- UpplReturnCode Delete(uint32_t session_id,
+ UpplReturnCode Delete(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
uint32_t data_type,
ServerSession & sess);
- UpplReturnCode ReadBulk(void* key_struct,
+ UpplReturnCode ReadBulk(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
- uint32_t option1,
- uint32_t option2,
uint32_t &max_repetition_count,
int child_index,
pfc_bool_t parent_call,
- pfc_bool_t is_read_next);
+ pfc_bool_t is_read_next,
+ ReadRequest *read_req);
- UpplReturnCode PerformSyntaxValidation(void* key_struct,
+ UpplReturnCode PerformSyntaxValidation(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t operation,
uint32_t data_type);
- UpplReturnCode PerformSemanticValidation(void* key_struct,
+ UpplReturnCode PerformSemanticValidation(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t operation,
uint32_t data_type);
- UpplReturnCode GetModifiedRows(vector<void *> &key_struct,
+ UpplReturnCode GetModifiedRows(OdbcmConnectionHandler *db_conn,
+ vector<void *> &key_struct,
CsRowStatus row_status);
- UpplReturnCode IsKeyExists(unc_keytype_datatype_t data_type,
- vector<string> key_values);
+ UpplReturnCode IsKeyExists(OdbcmConnectionHandler *db_conn,
+ unc_keytype_datatype_t data_type,
+ const vector<string>& key_values);
- UpplReturnCode HandleOperStatus(uint32_t data_type,
- void *key_struct,
- void *value_struct);
+ UpplReturnCode HandleOperStatus(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ void *key_struct,
+ void *value_struct,
+ vector<OperStatusHolder> &ref_oper_status);
void Fill_Attr_Syntax_Map();
// Used by KT_CONTROLLER
- pfc_bool_t IsBoundaryReferred(unc_key_type_t keytype,
+ pfc_bool_t IsBoundaryReferred(OdbcmConnectionHandler *db_conn,
+ unc_key_type_t keytype,
void *key_struct,
uint32_t data_type);
- UpplBoundaryOperStatus getBoundaryInputOperStatus(uint32_t data_type,
- string controller_name,
- string domain_name,
- string logical_port_id);
+ UpplBoundaryOperStatus getBoundaryInputOperStatus(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ string controller_name,
+ string domain_name,
+ string logical_port_id,
+ vector<OperStatusHolder> &ref_oper_status);
private:
- void PopulateDBSchemaForKtTable(
+ void PopulateDBSchemaForKtTable(OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_dbtableschema,
void* key_struct,
void* val_struct,
uint8_t operation_type,
+ uint32_t data_type,
uint32_t option1,
uint32_t option2,
vector<ODBCMOperator> &vect_key_operations,
pfc_bool_t is_filtering= false,
pfc_bool_t is_state= PFC_FALSE);
- void FillBoundaryValueStructure(
+ void FillBoundaryValueStructure(OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_boundary_dbtableschema,
vector<key_boundary_t> &vect_obj_key_boundary,
vector<val_boundary_st_t> &vect_obj_val_boundary,
uint32_t &max_rep_ct);
- UpplReturnCode PerformRead(uint32_t session_id,
+ UpplReturnCode PerformRead(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t option2,
uint32_t max_rep_ct);
- UpplReturnCode ReadBoundaryValFromDB(
+ UpplReturnCode ReadBoundaryValFromDB(OdbcmConnectionHandler *db_conn,
void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t operation_type,
uint32_t &max_repetition_count,
vector<key_boundary_t> &vect_key_boundary,
- vector<val_boundary_t> &vect_val_boundary,
vector<val_boundary_st_t> &vect_val_boundary_st,
pfc_bool_t is_state = PFC_FALSE);
UpplReturnCode SendSemanticRequestToUPLL(void* key_struct,
uint32_t data_type);
- UpplReturnCode ReadBulkInternal(
+ UpplReturnCode ReadBulkInternal(OdbcmConnectionHandler *db_conn,
void* key_struct,
void* val_struct,
uint32_t data_type,
vector<key_boundary_t> &vect_key_boundary,
vector<val_boundary_st_t> &vect_val_boundary);
- UpplReturnCode SetOperStatus(uint32_t data_type,
+ UpplReturnCode SetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void *key_struct,
void* val_struct,
UpplBoundaryOperStatus oper_status);
- UpplReturnCode GetBoundaryValidFlag(
+ UpplReturnCode GetBoundaryValidFlag(OdbcmConnectionHandler *db_conn,
void *key_struct,
- val_boundary_st_t &val_boundary_valid_st);
+ val_boundary_st_t &val_boundary_valid_st,
+ uint32_t data_type);
void FrameValidValue(string attr_value,
val_boundary_st &obj_val_boundary_st,
val_boundary_t &obj_val_boundary);
unsigned int ctr2_valid_val,
unsigned int dmn1_valid_val,
unsigned int dmn2_valid_val);
- UpplReturnCode GetOperStatus(uint32_t data_type,
+ UpplReturnCode GetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
uint8_t &oper_status);
UpplReturnCode SendOperStatusNotification(key_boundary_t bdry_key,
uint8_t old_oper_st,
uint8_t new_oper_st);
- UpplReturnCode GetAllBoundaryOperStatus(string controller_name,
+ UpplReturnCode GetAllBoundaryOperStatus(OdbcmConnectionHandler *db_conn,
+ string controller_name,
string domain_name,
string logical_port_id,
map<string, uint8_t> &bdry_notfn,
uint32_t data_type);
+ UpplReturnCode CheckBoundaryExistence(
+ OdbcmConnectionHandler *db_conn,
+ void *key_struct,
+ void *val_struct,
+ uint32_t data_type);
};
#endif
KIdxLink
}KtControllerChildClass;
-/* typedef enum {
- KtCtrDomain = 0,
- KtLogicalPort,
- KtSwitch,
- KtPort,
- KtLink,
- KtBoundary
-}KtControllerOperStatusRef;*/
-
typedef enum {
KtSwitch = 0
}KtControllerOperStatusRef;
/* @ Controller Class definition */
class Kt_Controller: public Kt_Base {
private:
- Kt_Base *parent;
Kt_Base *child[KT_CONTROLLER_CHILD_COUNT];
public:
~Kt_Controller();
- UpplReturnCode Create(uint32_t session_id,
+ UpplReturnCode Create(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t data_type,
ServerSession &sess);
- UpplReturnCode CreateKeyInstance(void* key_struct,
+ UpplReturnCode CreateKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t key_type);
- UpplReturnCode Update(uint32_t session_id,
+ UpplReturnCode Update(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t data_type,
ServerSession &sess);
- UpplReturnCode UpdateKeyInstance(void* key_struct,
+ UpplReturnCode UpdateKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t key_type);
- UpplReturnCode Delete(uint32_t session_id,
+ UpplReturnCode Delete(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
uint32_t data_type,
ServerSession &sess);
- UpplReturnCode DeleteKeyInstance(void* key_struct,
+ UpplReturnCode DeleteKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
uint32_t key_type);
- UpplReturnCode ReadInternal(vector<void *> &ctr_key,
+ UpplReturnCode ReadInternal(OdbcmConnectionHandler *db_conn,
+ vector<void *> &ctr_key,
vector<void *> &ctr_val,
uint32_t data_type,
uint32_t operation_type);
- UpplReturnCode ReadBulk(void* key_struct,
+ UpplReturnCode ReadBulk(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
- uint32_t option1,
- uint32_t option2,
uint32_t &max_rep_ct,
int child_index,
pfc_bool_t parent_call,
- pfc_bool_t is_read_next);
+ pfc_bool_t is_read_next,
+ ReadRequest *read_req);
- UpplReturnCode PerformSyntaxValidation(void* key_struct,
+ UpplReturnCode PerformSyntaxValidation(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t operation,
uint32_t data_type);
- UpplReturnCode PerformSemanticValidation(void* key_struct,
+ UpplReturnCode PerformSemanticValidation(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t operation,
uint32_t data_type);
- UpplReturnCode HandleDriverEvents(void* key_struct,
+ UpplReturnCode HandleDriverEvents(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t oper_type,
uint32_t data_type,
void* old_val_struct,
void* new_val_struct,
pfc_bool_t is_events_done);
- UpplReturnCode HandleDriverAlarms(uint32_t data_type,
+ UpplReturnCode HandleDriverAlarms(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
uint32_t alarm_type,
uint32_t oper_type,
void* key_struct,
void* val_struct);
- UpplReturnCode IsKeyExists(unc_keytype_datatype_t data_type,
- vector<string> key_values);
+ UpplReturnCode IsKeyExists(OdbcmConnectionHandler *db_conn,
+ unc_keytype_datatype_t data_type,
+ const vector<string>& key_values);
- UpplReturnCode GetModifiedRows(vector<void *> &key_struct,
+ UpplReturnCode GetModifiedRows(OdbcmConnectionHandler *db_conn,
+ vector<void *> &key_struct,
CsRowStatus row_status);
UpplReturnCode ValidateCtrlrValueCapability(string version,
uint32_t key_type);
- UpplReturnCode ValidateCtrlrScalability(string version,
+ UpplReturnCode ValidateCtrlrScalability(OdbcmConnectionHandler *db_conn,
+ string version,
uint32_t key_type,
uint32_t data_type);
- UpplReturnCode ValidateUnknownCtrlrScalability(void *key_struct,
- uint8_t type,
- uint32_t data_type);
+ UpplReturnCode ValidateUnknownCtrlrScalability(
+ OdbcmConnectionHandler *db_conn,
+ void *key_struct,
+ uint8_t type,
+ uint32_t data_type);
void Fill_Attr_Syntax_Map();
- UpplReturnCode HandleOperStatus(uint32_t data_type,
+ UpplReturnCode HandleOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void *key_struct,
void *value_struct);
- UpplReturnCode HandleOperStatus(uint32_t data_type,
+ UpplReturnCode HandleOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void *key_struct,
void *value_struct,
bool bIsInternal);
- UpplReturnCode NotifyOperStatus(uint32_t data_type,
- void *key_struct,
- void *value_struct);
+ UpplReturnCode NotifyOperStatus(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ void *key_struct,
+ void *value_struct,
+ vector<OperStatusHolder> &ref_oper_status);
- UpplReturnCode GetOperStatus(uint32_t data_type,
+ UpplReturnCode GetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
uint8_t &oper_status);
- UpplReturnCode SetOperStatus(uint32_t data_type,
+ UpplReturnCode SetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
uint8_t oper_status);
void* val_struct);
private:
- void PopulateDBSchemaForKtTable(
+ void PopulateDBSchemaForKtTable(OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_dbtableschema,
void* key_struct,
void* val_struct,
uint8_t operation_type,
+ uint32_t data_type,
uint32_t option1,
uint32_t option2,
vector<ODBCMOperator> &vect_key_operations,
UpplReturnCode SendSemanticRequestToUPLL(void* key_struct,
uint32_t data_type);
- void FillControllerValueStructure(
+ void FillControllerValueStructure(OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_controller_dbtableschema,
vector<val_ctr_st_t> &vect_obj_val_ctr,
uint32_t &max_rep_ct,
uint32_t operation_type,
vector<string> &controller_id);
- UpplReturnCode PerformRead(uint32_t session_id,
+ UpplReturnCode PerformRead(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t option2,
uint32_t max_rep_ct);
- UpplReturnCode ReadCtrValFromDB(void* key_struct,
+ UpplReturnCode ReadCtrValFromDB(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t operation_type,
vector<val_ctr_st_t> &vect_val_ctr_st,
vector<string> &controller_id);
- UpplReturnCode ReadBulkInternal(void* key_struct,
+ UpplReturnCode ReadBulkInternal(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* value_struct,
uint32_t data_type,
uint32_t max_rep_ct,
void FreeChildKeyStruct(void* key_struct, unsigned int child_class);
void FreeKeyStruct(void* key_struct,
unsigned int key_type);
- UpplReturnCode GetCtrValidFlag(void *key_struct,
- val_ctr_st_t &val_ctr_st);
- UpplReturnCode SetActualVersion(void* key_struct, string actual_version);
+ UpplReturnCode GetCtrValidFlag(OdbcmConnectionHandler *db_conn,
+ void *key_struct,
+ val_ctr_st_t &val_ctr_st,
+ uint32_t data_type);
+ UpplReturnCode SetActualVersion(OdbcmConnectionHandler *db_conn,
+ void* key_struct, string actual_version,
+ uint32_t data_type,
+ uint32_t valid_flag);
void FrameValidValue(string attr_value, val_ctr_st &obj_val_ctr_st,
val_ctr_t &obj_val_ctr);
void FrameCsAttrValue(string attr_value, val_ctr_t &obj_val_ctr);
- UpplReturnCode ValidateTypeIpAddress(void *key_struct,
+ UpplReturnCode ValidateTypeIpAddress(OdbcmConnectionHandler *db_conn,
+ void *key_struct,
void *val_struct,
uint32_t data_type,
uint32_t ctrl_type = UNC_CT_UNKNOWN);
- UpplReturnCode ValidateControllerType(
+ UpplReturnCode ValidateControllerType(OdbcmConnectionHandler *db_conn,
uint32_t operation,
uint32_t data_type,
unc_keytype_ctrtype_t ctr_type,
UpplReturnCode ctr_type_code,
val_ctr *val_ctr);
- UpplReturnCode ValidateControllerVersion(
+ UpplReturnCode ValidateControllerVersion(OdbcmConnectionHandler *db_conn,
uint32_t operation,
uint32_t data_type,
unc_keytype_ctrtype_t ctr_type,
UpplReturnCode ctr_type_code,
val_ctr *val_ctr);
UpplReturnCode ValidateControllerDescription(
+ OdbcmConnectionHandler *db_conn,
uint32_t operation,
uint32_t data_type,
unc_keytype_ctrtype_t ctr_type,
UpplReturnCode ctr_type_code,
val_ctr *val_ctr);
UpplReturnCode ValidateControllerIpAddress(
+ OdbcmConnectionHandler *db_conn,
uint32_t operation,
uint32_t data_type,
unc_keytype_ctrtype_t ctr_type,
void *key_struct,
void *val_struct);
UpplReturnCode ValidateControllerUser(
+ OdbcmConnectionHandler *db_conn,
uint32_t operation,
uint32_t data_type,
unc_keytype_ctrtype_t ctr_type,
UpplReturnCode ctr_type_code,
val_ctr *val_ctr);
UpplReturnCode ValidateControllerPassword(
+ OdbcmConnectionHandler *db_conn,
uint32_t operation,
uint32_t data_type,
unc_keytype_ctrtype_t ctr_type,
UpplReturnCode ctr_type_code,
val_ctr *val_ctr);
UpplReturnCode ValidateControllerEnableAudit(
+ OdbcmConnectionHandler *db_conn,
uint32_t operation,
uint32_t data_type,
unc_keytype_ctrtype_t ctr_type,
UpplReturnCode SendOperStatusNotification(key_ctr_t ctr_key,
uint8_t old_oper_st,
uint8_t new_oper_st);
+ UpplReturnCode CheckIpAndClearStateDB(OdbcmConnectionHandler *db_conn,
+ void *key_struct);
+ UpplReturnCode CheckSameIp(OdbcmConnectionHandler *db_conn,
+ void *key_struct,
+ void *val_struct,
+ uint32_t data_type);
};
#endif
class Kt_Ctr_Domain : public Kt_State_Base {
private:
- Kt_Base *parent;
Kt_Base *child[KT_CTR_DOMAIN_CHILD_COUNT];
public:
Kt_Ctr_Domain();
~Kt_Ctr_Domain();
- UpplReturnCode Create(uint32_t session_id,
+ UpplReturnCode Create(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t data_type,
ServerSession &sess);
- UpplReturnCode CreateKeyInstance(void* key_struct,
+ UpplReturnCode CreateKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t key_type);
- UpplReturnCode Update(uint32_t session_id,
+ UpplReturnCode Update(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t data_type,
ServerSession &sess);
- UpplReturnCode UpdateKeyInstance(void* key_struct,
+ UpplReturnCode UpdateKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t key_type);
- UpplReturnCode Delete(uint32_t session_id,
+ UpplReturnCode Delete(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
uint32_t data_type,
ServerSession &sess);
- UpplReturnCode DeleteKeyInstance(void* key_struct,
+ UpplReturnCode DeleteKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
uint32_t key_type);
- UpplReturnCode ReadInternal(vector<void *> &key_struct,
+ UpplReturnCode ReadInternal(OdbcmConnectionHandler *db_conn,
+ vector<void *> &key_struct,
vector<void *> &val_struct,
uint32_t data_type,
uint32_t operation_type);
- UpplReturnCode ReadBulk(void* key_struct,
+ UpplReturnCode ReadBulk(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
- uint32_t option1,
- uint32_t option2,
uint32_t &max_rep_ct,
int child_index,
pfc_bool_t parent_call,
- pfc_bool_t is_read_next);
+ pfc_bool_t is_read_next,
+ ReadRequest *read_req);
- UpplReturnCode PerformSyntaxValidation(void* key_struct,
+ UpplReturnCode PerformSyntaxValidation(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t operation,
uint32_t data_type);
- UpplReturnCode PerformSemanticValidation(void* key_struct,
+ UpplReturnCode PerformSemanticValidation(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t operation,
uint32_t data_type);
- UpplReturnCode HandleDriverAlarms(uint32_t data_type,
+ UpplReturnCode HandleDriverAlarms(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
uint32_t alarm_type,
uint32_t oper_type,
void* key_struct,
void* val_struct);
- UpplReturnCode InvokeBoundaryNotifyOperStatus(uint32_t data_type,
- void *key_struct);
+ UpplReturnCode InvokeBoundaryNotifyOperStatus(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ void *key_struct);
- UpplReturnCode IsKeyExists(unc_keytype_datatype_t data_type,
- vector<string> key_values);
+ UpplReturnCode IsKeyExists(OdbcmConnectionHandler *db_conn,
+ unc_keytype_datatype_t data_type,
+ const vector<string>& key_values);
- UpplReturnCode GetModifiedRows(vector<void *> &key_struct,
+ UpplReturnCode GetModifiedRows(OdbcmConnectionHandler *db_conn,
+ vector<void *> &key_struct,
CsRowStatus row_status);
void Fill_Attr_Syntax_Map();
- UpplReturnCode HandleOperStatus(uint32_t data_type,
+ UpplReturnCode HandleOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void *key_struct,
void *value_struct);
- UpplReturnCode NotifyOperStatus(uint32_t data_type,
- void *key_struct,
- void *value_struct);
-
- UpplReturnCode GetOperStatus(uint32_t data_type,
+ UpplReturnCode GetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
uint8_t &oper_status);
domain_val2.domain.description,
sizeof(domain_val1.domain.description)) == 0 &&
domain_val1.domain.cs_row_status ==
- domain_val2.domain.cs_row_status) {
+ domain_val2.domain.cs_row_status &&
+ domain_val1.oper_status == domain_val2.oper_status) {
return PFC_TRUE;
}
return PFC_FALSE;
private:
- void PopulateDBSchemaForKtTable(
+ void PopulateDBSchemaForKtTable(OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_dbtableschema,
void* key_struct,
void* val_struct,
uint8_t operation_type,
+ uint32_t data_type,
uint32_t option1,
uint32_t option2,
vector<ODBCMOperator> &vect_key_operations,
pfc_bool_t is_filtering= false,
pfc_bool_t is_state= PFC_FALSE);
- void FillDomainValueStructure(
+ void FillDomainValueStructure(OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_ctr_domain_dbtableschema,
vector<val_ctr_domain_st> &vect_obj_val_ctr_domain_st,
uint32_t &max_rep_ct,
uint32_t operation_type,
vector<key_ctr_domain> &domain_id);
- UpplReturnCode PerformRead(uint32_t session_id,
+ UpplReturnCode PerformRead(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t option2,
uint32_t max_rep_ct);
- UpplReturnCode ReadDomainValFromDB(
+ UpplReturnCode ReadDomainValFromDB(OdbcmConnectionHandler *db_conn,
void* key_struct,
void* val_struct,
uint32_t data_type,
vector<val_ctr_domain_st> &vect_val_ctr_domain_st,
vector<key_ctr_domain> &domain_id);
- UpplReturnCode ReadBulkInternal(
+ UpplReturnCode ReadBulkInternal(OdbcmConnectionHandler *db_conn,
void* key_struct,
uint32_t data_type,
uint32_t max_rep_ct,
string controller_name);
Kt_Base* GetChildClassPointer(KtDomainChildClass KIndex);
- UpplReturnCode SetOperStatus(uint32_t data_type,
+ UpplReturnCode SetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
- UpplDomainOperStatus oper_status,
- bool is_single_key = false);
+ UpplDomainOperStatus oper_status);
void FreeChildKeyStruct(int child_class,
void *key_struct);
- UpplReturnCode GetCtrDomainValidFlag(
+ UpplReturnCode GetCtrDomainValidFlag(OdbcmConnectionHandler *db_conn,
void *key_struct,
- val_ctr_domain_st_t &val_ctr_domain_valid_st);
+ val_ctr_domain_st_t &val_ctr_domain_valid_st,
+ uint32_t data_type);
void FrameValidValue(string attr_value,
val_ctr_domain_st &obj_val_ctr_domain_st,
val_ctr_domain_t &obj_val_ctr_domain);
~Kt_Link();
- UpplReturnCode DeleteKeyInstance(void* key_struct,
+ UpplReturnCode DeleteKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
uint32_t key_type);
- UpplReturnCode ReadInternal(
+ UpplReturnCode ReadInternal(OdbcmConnectionHandler *db_conn,
vector<void *> &key_val,
vector<void *> &val_struct,
uint32_t data_type,
uint32_t operation_type);
- UpplReturnCode ReadBulk(void* key_struct,
+ UpplReturnCode ReadBulk(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
- uint32_t option1,
- uint32_t option2,
uint32_t &max_rep_ct,
int child_index,
pfc_bool_t parent_call,
- pfc_bool_t is_read_next);
+ pfc_bool_t is_read_next,
+ ReadRequest *read_req);
- UpplReturnCode PerformSyntaxValidation(void* key_struct,
+ UpplReturnCode PerformSyntaxValidation(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
-
uint32_t operation,
uint32_t data_type);
- UpplReturnCode PerformSemanticValidation(void* key_struct,
+ UpplReturnCode PerformSemanticValidation(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t operation,
uint32_t data_type);
- UpplReturnCode IsKeyExists(unc_keytype_datatype_t data_type,
- vector<string> key_values);
+ UpplReturnCode IsKeyExists(OdbcmConnectionHandler *db_conn,
+ unc_keytype_datatype_t data_type,
+ const vector<string>& key_values);
void Fill_Attr_Syntax_Map();
- UpplReturnCode HandleOperStatus(uint32_t data_type,
+ UpplReturnCode HandleOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void *key_struct,
void *value_struct);
- pfc_bool_t CheckValueStruct(void *value_struct1,
+ pfc_bool_t CompareValueStruct(void *value_struct1,
void *value_struct2) {
val_link_st_t link_val1 =
*(reinterpret_cast<val_link_st_t*>(value_struct1));
}
return PFC_FALSE;
}
- pfc_bool_t CheckKeyStruct(void *key_struct1,
+ pfc_bool_t CompareKeyStruct(void *key_struct1,
void *key_struct2) {
key_link_t link_key1 =
*(reinterpret_cast<key_link_t*>(key_struct1));
}
private:
- void PopulateDBSchemaForKtTable(
+ void PopulateDBSchemaForKtTable(OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_dbtableschema,
void* key_struct,
void* val_struct,
uint8_t operation_type,
+ uint32_t data_type,
uint32_t option1,
uint32_t option2,
vector<ODBCMOperator> &vect_key_operations,
pfc_bool_t is_filtering = false,
pfc_bool_t is_state = PFC_FALSE);
- void FillLinkValueStructure(DBTableSchema &kt_link_dbtableschema,
+ void FillLinkValueStructure(OdbcmConnectionHandler *db_conn,
+ DBTableSchema &kt_link_dbtableschema,
vector<val_link_st_t> &vect_obj_val_link,
uint32_t &max_rep_ct,
uint32_t operation_type,
vector<key_link_t> &link_id);
- UpplReturnCode PerformRead(uint32_t session_id,
+ UpplReturnCode PerformRead(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t option2,
uint32_t max_rep_ct);
- UpplReturnCode ReadLinkValFromDB(void* key_struct,
+ UpplReturnCode ReadLinkValFromDB(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t operation_type,
uint32_t option2,
pfc_bool_t is_state = PFC_FALSE);
- UpplReturnCode ReadBulkInternal(void* key_struct,
+ UpplReturnCode ReadBulkInternal(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
uint32_t max_rep_ct,
vector<val_link_st_t> &vect_val_link_st,
vector<key_link_t> &vect_link_id);
- UpplReturnCode SetOperStatus(uint32_t data_type,
+ UpplReturnCode SetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
- UpplLinkOperStatus oper_status,
- bool is_single_key = false);
- UpplReturnCode GetLinkValidFlag(
+ UpplLinkOperStatus oper_status);
+ UpplReturnCode GetLinkValidFlag(OdbcmConnectionHandler *db_conn,
void *key_struct,
- val_link_st_t &val_link_valid_st);
- UpplReturnCode GetOperStatus(uint32_t data_type,
+ val_link_st_t &val_link_valid_st,
+ uint32_t data_type);
+ UpplReturnCode GetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct, uint8_t &oper_status);
void FrameValidValue(string attr_value, val_link_st &obj_val_link);
- Kt_Base *parent;
- void PopulatePrimaryKeys(
- uint32_t operation_type,
- uint32_t option1,
- uint32_t option2,
- string switch_id1,
- string switch_id2,
- string port_id1,
- string port_id2,
- vector<string> &vect_prim_keys,
- vector<ODBCMOperator> &vect_prim_keys_operation);
+ void PopulatePrimaryKeys(uint32_t operation_type,
+ uint32_t option1,
+ uint32_t option2,
+ string switch_id1,
+ string switch_id2,
+ string port_id1,
+ string port_id2,
+ vector<string> &vect_prim_keys,
+ vector<ODBCMOperator> &vect_prim_keys_operation);
};
#endif
/* @ Logical Member Port Class definition */
class Kt_LogicalMemberPort : public Kt_State_Base {
- private:
- Kt_Base *parent;
-
public:
Kt_LogicalMemberPort();
~Kt_LogicalMemberPort();
- UpplReturnCode DeleteKeyInstance(
+ UpplReturnCode DeleteKeyInstance(OdbcmConnectionHandler *db_conn,
void* key_struct,
uint32_t data_type,
uint32_t key_type);
- UpplReturnCode ReadBulk(void* key_struct,
+ UpplReturnCode ReadBulk(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
- uint32_t option1,
- uint32_t option2,
uint32_t &max_rep_ct,
int child_index,
pfc_bool_t parent_call,
- pfc_bool_t is_read_next);
+ pfc_bool_t is_read_next,
+ ReadRequest *read_req);
- UpplReturnCode PerformSyntaxValidation(void* key_struct,
+ UpplReturnCode PerformSyntaxValidation(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t operation,
uint32_t data_type);
- UpplReturnCode PerformSemanticValidation(void* key_struct,
+ UpplReturnCode PerformSemanticValidation(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t operation,
uint32_t data_type);
- UpplReturnCode IsKeyExists(unc_keytype_datatype_t data_type,
- vector<string> key_values);
+ UpplReturnCode IsKeyExists(OdbcmConnectionHandler *db_conn,
+ unc_keytype_datatype_t data_type,
+ const vector<string>& key_values);
void Fill_Attr_Syntax_Map();
- pfc_bool_t IsLogicalMemberPortReferred(string controller_name,
- string domain_name,
- string port_id);
- UpplReturnCode ReadInternal(vector<void *> &key_val,
+ UpplReturnCode ReadInternal(OdbcmConnectionHandler *db_conn,
+ vector<void *> &key_val,
vector<void *> &val_struct,
uint32_t data_type,
uint32_t operation_type);
}
private:
- void PopulateDBSchemaForKtTable(
+ void PopulateDBSchemaForKtTable(OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_dbtableschema,
void* key_struct,
void* val_struct,
uint8_t operation_type,
+ uint32_t data_type,
uint32_t option1,
uint32_t option2,
vector<ODBCMOperator> &vect_key_operations,
pfc_bool_t is_state= PFC_FALSE);
- void FillLogicalMemberPortValueStructure(
+ void FillLogicalMemberPortValueStructure(OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_logical_member_port_dbtableschema,
uint32_t &max_rep_ct,
uint32_t operation_type,
vector<key_logical_member_port_t> &logical_mem_port);
- UpplReturnCode PerformRead(uint32_t session_id,
+ UpplReturnCode PerformRead(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* value_struct,
uint32_t option2,
uint32_t max_rep_ct);
- UpplReturnCode ReadLogicalMemberPortValFromDB(
+ UpplReturnCode ReadLogicalMemberPortValFromDB(OdbcmConnectionHandler *db_conn,
void* key_struct,
uint32_t data_type,
uint32_t operation_type,
vector<key_logical_member_port_t> &logical_mem_port,
pfc_bool_t is_state = PFC_FALSE);
- UpplReturnCode ReadBulkInternal(
+ UpplReturnCode ReadBulkInternal(OdbcmConnectionHandler *db_conn,
void* key_struct,
uint32_t data_type,
uint32_t max_rep_ct,
/* @ Loical Port Class definition */
class Kt_LogicalPort: public Kt_State_Base {
private:
- Kt_Base *parent;
Kt_Base *child[UNC_KT_LOGICAL_PORT_CHILD_COUNT];
public:
~Kt_LogicalPort();
- UpplReturnCode DeleteKeyInstance(void* key_struct,
+ UpplReturnCode DeleteKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
uint32_t key_type);
- UpplReturnCode ReadInternal(vector<void *> &key_val,
+ UpplReturnCode ReadInternal(OdbcmConnectionHandler *db_conn,
+ vector<void *> &key_val,
vector<void *> &val_struct,
uint32_t data_type,
uint32_t operation_type);
- UpplReturnCode ReadBulk(void* key_struct,
+ UpplReturnCode ReadBulk(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
- uint32_t option1,
- uint32_t option2,
uint32_t &max_rep_ct,
int child_index,
pfc_bool_t parent_call,
- pfc_bool_t is_read_next);
+ pfc_bool_t is_read_next,
+ ReadRequest *read_req);
- UpplReturnCode PerformSyntaxValidation(void* key_struct,
+ UpplReturnCode PerformSyntaxValidation(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t operation,
uint32_t data_type);
- UpplReturnCode PerformSemanticValidation(void* key_struct,
+ UpplReturnCode PerformSemanticValidation(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t operation,
uint32_t data_type);
- UpplReturnCode HandleDriverAlarms(uint32_t data_type,
+ UpplReturnCode HandleDriverAlarms(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
uint32_t alarm_type,
uint32_t oper_type,
void* key_struct,
void* val_struct);
- UpplReturnCode HandleOperStatus(uint32_t data_type,
- void *key_struct, void *value_struct);
+ UpplReturnCode HandleOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ void *key_struct,
+ void *value_struct,
+ vector<OperStatusHolder> &ref_oper_status,
+ unc_key_type_t caller_kt);
UpplReturnCode HandleOperDownCriteriaFromPortStatus(
+ OdbcmConnectionHandler *db_conn,
uint32_t data_type,
void *key_struct,
void *value_struct,
vector<uint32_t> &vectOperStatus,
pfc_bool_t is_delete_call = false);
- UpplReturnCode GetOperDownCriteria(uint32_t data_type,
+ UpplReturnCode GetOperDownCriteria(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
uint32_t &oper_down_criteria);
- UpplReturnCode InvokeBoundaryNotifyOperStatus(uint32_t data_type,
+ UpplReturnCode InvokeBoundaryNotifyOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void *key_struct);
- UpplReturnCode NotifyOperStatus(uint32_t data_type,
- void *key_struct, void *value_struct);
+ UpplReturnCode NotifyOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ void *key_struct,
+ void *value_struct,
+ vector<OperStatusHolder> &ref_oper_status);
- UpplReturnCode GetOperStatus(uint32_t data_type,
+ UpplReturnCode GetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct, uint8_t &oper_status);
- UpplReturnCode IsKeyExists(unc_keytype_datatype_t data_type,
- vector<string> key_values);
+ UpplReturnCode IsKeyExists(OdbcmConnectionHandler *db_conn,
+ unc_keytype_datatype_t data_type,
+ const vector<string>& key_values);
void Fill_Attr_Syntax_Map();
// Used by KT_CONTROLLER for PATH_FAULT Alarm
- void GetAllPortId(uint32_t data_type,
+ void GetAllPortId(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
string controller_name,
string switch_id,
+ string &domain_name,
vector <string> &logical_port_id,
pfc_bool_t is_single_logical_port);
- pfc_bool_t IsLogicalPortReferred(string controller_name,
- string domain_name);
pfc_bool_t CompareValueStruct(void *value_struct1,
void *value_struct2) {
val_logical_port_st_t logport_val1 =
}
private:
- void PopulateDBSchemaForKtTable(
+ void PopulateDBSchemaForKtTable(OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_dbtableschema,
void* key_struct,
void* val_struct,
uint8_t operation_type,
+ uint32_t data_type,
uint32_t option1,
uint32_t option2,
vector<ODBCMOperator> &vect_key_operations,
pfc_bool_t is_filtering= false,
pfc_bool_t is_state= PFC_FALSE);
- void FillLogicalPortValueStructure(
+ void FillLogicalPortValueStructure(OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_logicalport_dbtableschema,
vector<val_logical_port_st_t> &vect_obj_val_logical_port,
uint32_t &max_rep_ct,
uint32_t operation_type,
vector<key_logical_port_t> &controller_id);
- UpplReturnCode PerformRead(uint32_t session_id,
+ UpplReturnCode PerformRead(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t option2,
uint32_t max_rep_ct);
- UpplReturnCode ReadLogicalPortValFromDB(
+ UpplReturnCode ReadLogicalPortValFromDB(OdbcmConnectionHandler *db_conn,
void* key_struct,
void* val_struct,
uint32_t data_type,
vector<val_logical_port_st_t> &vect_val_logical_port_st,
vector<key_logical_port_t> &logical_port_id);
- UpplReturnCode ReadBulkInternal(
+ UpplReturnCode ReadBulkInternal(OdbcmConnectionHandler *db_conn,
void* key_struct,
void* value_struct,
uint32_t data_type,
Kt_Base* GetChildClassPointer(KtLogicalPortChildClass KIndex);
- UpplReturnCode SetOperStatus(uint32_t data_type,
+ UpplReturnCode SetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
void* val_struct,
UpplLogicalPortOperStatus oper_status);
UpplReturnCode GetOperStatusFromOperDownCriteria(
+ OdbcmConnectionHandler *db_conn,
uint32_t data_type,
void *key_struct,
void *value_struct,
UpplLogicalPortOperStatus &logical_port_oper_status);
void FreeChildKeyStruct(int child_class,
void *key_struct);
- UpplReturnCode GetLogicalPortValidFlag(
+ UpplReturnCode GetLogicalPortValidFlag(OdbcmConnectionHandler *db_conn,
void *key_struct,
- val_logical_port_st_t &val_logical_port_valid_st);
+ val_logical_port_st_t &val_logical_port_valid_st,
+ uint32_t data_type);
void FrameValidValue(string attr_value,
val_logical_port_st &obj_val_logical_port_st,
val_logical_port_t &obj_val_logical_port);
- UpplReturnCode GetValidFlag(
+ UpplReturnCode GetValidFlag(OdbcmConnectionHandler *db_conn,
uint32_t data_type,
void* key_struct,
string *valid_flag);
+ UpplReturnCode GetPortOperStatus(OdbcmConnectionHandler *db_conn,
+ key_port_t &port_key,
+ uint8_t *port_oper_status,
+ uint32_t data_type);
+ void GetAllLogicalPort(OdbcmConnectionHandler *db_conn,
+ string controller_name,
+ string domain_name,
+ string switch_id,
+ string phy_port_id,
+ vector<key_logical_port_t> &vectLogicalPortKey,
+ uint32_t data_type);
+ UpplReturnCode ValidatePortType(uint8_t port_type);
};
#endif
using unc::uppl::ODBCMOperator;
/* @ Port Class definition */
class Kt_Port: public Kt_State_Base {
- private:
- Kt_Base *parent;
-
public:
Kt_Port();
~Kt_Port();
- UpplReturnCode DeleteKeyInstance(void* key_struct,
+ UpplReturnCode DeleteKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
uint32_t key_type);
- UpplReturnCode ReadInternal(vector<void *> &key_val,
+ UpplReturnCode ReadInternal(OdbcmConnectionHandler *db_conn,
+ vector<void *> &key_val,
vector<void *> &val_struct,
uint32_t data_type,
uint32_t operation_type);
- UpplReturnCode ReadBulk(void* key_struct,
+ UpplReturnCode ReadBulk(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
- uint32_t option1,
- uint32_t option2,
uint32_t &max_rep_ct,
int child_index,
pfc_bool_t parent_call,
- pfc_bool_t is_read_next);
+ pfc_bool_t is_read_next,
+ ReadRequest *read_req);
- UpplReturnCode PerformSyntaxValidation(void* key_struct,
+ UpplReturnCode PerformSyntaxValidation(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t operation,
uint32_t data_type);
- UpplReturnCode PerformSemanticValidation(void* key_struct,
+ UpplReturnCode PerformSemanticValidation(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t operation,
uint32_t data_type);
- UpplReturnCode HandleDriverAlarms(uint32_t data_type,
+ UpplReturnCode HandleDriverAlarms(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
uint32_t alarm_type,
uint32_t oper_type,
void* key_struct,
void* val_struct);
- UpplReturnCode HandleOperStatus(uint32_t data_type,
+ UpplReturnCode HandleOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void *key_struct,
void *value_struct);
- UpplReturnCode NotifyOperStatus(uint32_t data_type,
+ UpplReturnCode NotifyOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void *key_struct,
- void *value_struct);
+ void *value_struct,
+ vector<OperStatusHolder> &ref_oper_status);
- UpplReturnCode GetOperStatus(uint32_t data_type,
+ UpplReturnCode GetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
uint8_t &oper_status);
- UpplReturnCode GetAlarmStatus(uint32_t data_type,
+ UpplReturnCode GetAlarmStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
uint64_t &alarms_status);
- UpplReturnCode IsKeyExists(unc_keytype_datatype_t data_type,
- vector<string> key_values);
+ UpplReturnCode IsKeyExists(OdbcmConnectionHandler *db_conn,
+ unc_keytype_datatype_t data_type,
+ const vector<string>& key_values);
void Fill_Attr_Syntax_Map();
- UpplReturnCode UpdatePortValidFlag(void *key_struct,
+ UpplReturnCode UpdatePortValidFlag(OdbcmConnectionHandler *db_conn,
+ void *key_struct,
void *val_struct,
val_port_st_t &val_port_valid_st,
- unc_keytype_validflag_t valid_val);
- UpplReturnCode PopulateSchemaForValidFlag(void* key_struct,
+ unc_keytype_validflag_t valid_val,
+ uint32_t data_type);
+ UpplReturnCode PopulateSchemaForValidFlag(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
- string new_val);
+ string new_val,
+ uint32_t data_type);
pfc_bool_t CompareValueStruct(void *value_struct1,
void *value_struct2) {
val_port_st_t port_val1 =
}
private:
- void PopulateDBSchemaForKtTable(
+ void PopulateDBSchemaForKtTable(OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_dbtableschema,
void* key_struct,
void* val_struct,
uint8_t operation_type,
+ uint32_t data_type,
uint32_t option1,
uint32_t option2,
vector<ODBCMOperator> &vect_key_operations,
pfc_bool_t is_filtering= false,
pfc_bool_t is_state= PFC_FALSE);
- void FillPortValueStructure(DBTableSchema &kt_port_dbtableschema,
+ void FillPortValueStructure(OdbcmConnectionHandler *db_conn,
+ DBTableSchema &kt_port_dbtableschema,
vector<val_port_st_t> &vect_obj_val_port,
uint32_t &max_rep_ct,
uint32_t operation_type,
vector<key_port_t> &port_id);
- UpplReturnCode PerformRead(uint32_t session_id,
+ UpplReturnCode PerformRead(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t option2,
uint32_t max_rep_ct);
- UpplReturnCode ReadPortValFromDB(void* key_struct,
+ UpplReturnCode ReadPortValFromDB(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t operation_type,
vector<val_port_st_t> &vect_val_port_st,
vector<key_port_t> &port_id);
- UpplReturnCode ReadBulkInternal(void* key_struct,
+ UpplReturnCode ReadBulkInternal(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* value_struct,
uint32_t data_type,
uint32_t max_rep_ct,
vector<val_port_st_t> &vect_val_port,
vector<key_port_t> &vect_port_id);
- UpplReturnCode SetOperStatus(uint32_t data_type,
+ UpplReturnCode SetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
- UpplPortOperStatus oper_status,
- bool is_single_key);
- UpplReturnCode ReadNeighbor(
+ UpplPortOperStatus oper_status);
+ UpplReturnCode ReadNeighbor(OdbcmConnectionHandler *db_conn,
void* key_struct,
void* val_struct,
uint32_t data_type,
val_port_st_neighbor &obj_neighbor);
void FrameValidValue(string attr_value, val_port_st &obj_val_port);
- void GetPortValStructure(
+ void GetPortValStructure(OdbcmConnectionHandler *db_conn,
val_port_st_t *obj_val_port,
vector<TableAttrSchema> &vect_table_attr_schema,
vector<string> &vect_prim_keys,
uint8_t operation_type,
val_port_st_t *val_port_valid_st,
stringstream &valid);
- void GetPortStateValStructure(
+ void GetPortStateValStructure(OdbcmConnectionHandler *db_conn,
val_port_st_t *obj_val_port,
vector<TableAttrSchema> &vect_table_attr_schema,
vector<string> &vect_prim_keys,
uint8_t operation_type,
val_port_st_t *val_port_valid_st,
stringstream &valid);
+ UpplReturnCode SubDomainOperStatusHandling(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ string controller_name,
+ string switch_name,
+ string physical_port_id);
};
#endif
class Kt_Root: public Kt_Base {
private:
- Kt_Base *parent;
Kt_Base *child[KT_ROOT_CHILD_COUNT];
public:
Kt_Root();
~Kt_Root();
- UpplReturnCode Create(uint32_t session_id,
+ UpplReturnCode Create(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t data_type,
ServerSession &sess);
- UpplReturnCode Update(uint32_t session_id,
+ UpplReturnCode Update(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t data_type,
ServerSession &sess);
- UpplReturnCode Delete(uint32_t session_id,
+ UpplReturnCode Delete(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
uint32_t data_type,
ServerSession &sess);
- UpplReturnCode ReadBulk(void* key_struct,
+ UpplReturnCode ReadBulk(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
- uint32_t option1,
- uint32_t option2,
uint32_t &max_rep_ct,
int child_index,
pfc_bool_t parent_call,
- pfc_bool_t is_read_next);
+ pfc_bool_t is_read_next,
+ ReadRequest *read_req);
- UpplReturnCode PerformRead(uint32_t session_id,
+ UpplReturnCode PerformRead(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t option2,
uint32_t max_rep_ct) { return UPPL_RC_SUCCESS; }
- UpplReturnCode PerformSyntaxValidation(void* key_struct,
+ UpplReturnCode PerformSyntaxValidation(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t operation,
uint32_t data_type) {
return UPPL_RC_SUCCESS;
}
- UpplReturnCode PerformSemanticValidation(void* key_struct,
+ UpplReturnCode PerformSemanticValidation(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t operation,
uint32_t data_type) {
return UPPL_RC_SUCCESS;
}
- void PopulateDBSchemaForKtTable(
+ void PopulateDBSchemaForKtTable(OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_dbtableschema,
void* key_struct,
void* val_struct,
uint8_t operation_type,
+ uint32_t data_type,
uint32_t option1,
uint32_t option2,
vector<ODBCMOperator> &vect_key_operations,
virtual ~Kt_State_Base() {
};
- UpplReturnCode Create(uint32_t session_id,
+ UpplReturnCode Create(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t key_type,
ServerSession &sess);
- UpplReturnCode CreateKeyInstance(void* key_struct,
+ UpplReturnCode CreateKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t key_type);
- UpplReturnCode UpdateKeyInstance(void* key_struct,
+ UpplReturnCode UpdateKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t key_type,
void* &old_val_struct);
- UpplReturnCode Update(uint32_t session_id,
+ UpplReturnCode Update(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t key_type,
ServerSession &sess);
- UpplReturnCode Delete(uint32_t session_id,
+ UpplReturnCode Delete(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
uint32_t data_type,
uint32_t key_type,
ServerSession &sess);
- UpplReturnCode HandleDriverEvents(void* key_struct,
+ UpplReturnCode HandleDriverEvents(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t oper_type,
uint32_t data_type,
uint32_t key_type,
void* old_val_struct,
void* new_val_struct);
+
+ private:
+ UpplReturnCode HandleOperStatus(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ uint32_t oper_type,
+ uint32_t data_type,
+ uint32_t key_type,
+ void* new_val_struct,
+ string controller_name);
};
#endif
/* @ Switch Class definition */
class Kt_Switch : public Kt_State_Base {
private:
- Kt_Base *parent;
Kt_Base *child[KT_SWITCH_CHILD_COUNT];
public:
~Kt_Switch();
- UpplReturnCode DeleteKeyInstance(void* key_struct,
+ UpplReturnCode DeleteKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
uint32_t key_type);
- UpplReturnCode ReadInternal(vector<void *> &key_struct,
+ UpplReturnCode ReadInternal(OdbcmConnectionHandler *db_conn,
+ vector<void *> &key_struct,
vector<void *> &val_struct,
uint32_t data_type,
uint32_t operation_type);
- UpplReturnCode ReadBulk(void* key_struct,
+ UpplReturnCode ReadBulk(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
- uint32_t option1,
- uint32_t option2,
uint32_t &max_rep_ct,
int child_index,
pfc_bool_t parent_call,
- pfc_bool_t is_read_next);
+ pfc_bool_t is_read_next,
+ ReadRequest *read_req);
- UpplReturnCode PerformSyntaxValidation(void* key_struct,
+ UpplReturnCode PerformSyntaxValidation(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t operation,
uint32_t data_type);
- UpplReturnCode PerformSemanticValidation(void* key_struct,
+ UpplReturnCode PerformSemanticValidation(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t operation,
uint32_t data_type);
- UpplReturnCode HandleDriverAlarms(uint32_t data_type,
+ UpplReturnCode HandleDriverAlarms(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
uint32_t alarm_type,
uint32_t oper_type,
void* key_struct,
void* val_struct);
- UpplReturnCode IsKeyExists(unc_keytype_datatype_t data_type,
- vector<string> key_values);
+ UpplReturnCode IsKeyExists(OdbcmConnectionHandler *db_conn,
+ unc_keytype_datatype_t data_type,
+ const vector<string>& key_values);
- UpplReturnCode NotifyOperStatus(uint32_t data_type,
+ UpplReturnCode NotifyOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
- void* value_struct);
+ void* value_struct,
+ vector<OperStatusHolder> &ref_oper_status);
- UpplReturnCode HandleOperStatus(uint32_t data_type,
+ UpplReturnCode HandleOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void *key_struct,
void *value_struct);
- UpplReturnCode GetOperStatus(uint32_t data_type,
+ UpplReturnCode GetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
uint8_t &oper_status);
- UpplReturnCode GetAlarmStatus(uint32_t data_type,
+ UpplReturnCode GetAlarmStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
uint64_t &alarms_status);
void Fill_Attr_Syntax_Map();
- UpplReturnCode UpdateSwitchValidFlag(void *key_struct,
+ UpplReturnCode UpdateSwitchValidFlag(OdbcmConnectionHandler *db_conn,
+ void *key_struct,
void *val_struct,
val_switch_st_t &val_switch_val_st,
- unc_keytype_validflag_t valid_val);
+ unc_keytype_validflag_t valid_val,
+ uint32_t data_type);
- UpplReturnCode PopulateSchemaForValidFlag(void* key_struct,
+ UpplReturnCode PopulateSchemaForValidFlag(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
- string valid_new);
+ string valid_new,
+ uint32_t data_type);
pfc_bool_t CompareValueStruct(void *val_struct1,
void *val_struct2) {
switch_val1.switch_val.domain_name,
switch_val2.switch_val.domain_name,
sizeof(switch_val1.switch_val.domain_name)) == 0 &&
- switch_val1.oper_status == switch_val2.oper_status &&
- memcmp(switch_val1.manufacturer,
- switch_val2.manufacturer,
- sizeof(switch_val1.manufacturer)) == 0&&
- memcmp(switch_val1.hardware,
- switch_val2.hardware,
- sizeof(switch_val1.hardware)) == 0 &&
- memcmp(
- switch_val1.software,
- switch_val2.software,
- sizeof(switch_val1.software)) == 0) {
+ memcmp(
+ switch_val1.switch_val.valid,
+ switch_val2.switch_val.valid,
+ sizeof(switch_val1.switch_val.valid)) == 0 &&
+ switch_val1.oper_status == switch_val2.oper_status
+ &&
+ memcmp(switch_val1.manufacturer,
+ switch_val2.manufacturer,
+ sizeof(switch_val1.manufacturer)) == 0&&
+ memcmp(switch_val1.hardware,
+ switch_val2.hardware,
+ sizeof(switch_val1.hardware)) == 0 &&
+ memcmp(
+ switch_val1.software,
+ switch_val2.software,
+ sizeof(switch_val1.software))
+ == 0) {
delete []ip_value1;
delete []ip_value2;
return PFC_TRUE;
};
private:
- void PopulateDBSchemaForKtTable(
+ void PopulateDBSchemaForKtTable(OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_dbtableschema,
void* key_struct,
void* val_struct,
uint8_t operation_type,
+ uint32_t data_type,
uint32_t option1,
uint32_t option2,
vector<ODBCMOperator> &vect_key_operations,
pfc_bool_t is_filtering= false,
pfc_bool_t is_state= PFC_FALSE);
- void FillSwitchValueStructure(
+ void FillSwitchValueStructure(OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_switch_dbtableschema,
vector<val_switch_st_t> &vect_obj_val_switch,
uint32_t &max_rep_ct,
uint32_t operation_type,
vector<key_switch_t> &vect_switch_id);
- UpplReturnCode PerformRead(uint32_t session_id,
+ UpplReturnCode PerformRead(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t option2,
uint32_t max_rep_ct);
- UpplReturnCode ReadSwitchValFromDB(
+ UpplReturnCode ReadSwitchValFromDB(OdbcmConnectionHandler *db_conn,
void* key_struct,
void* val_struct,
uint32_t data_type,
vector<key_switch_t> &vect_switch_id,
pfc_bool_t is_state = PFC_FALSE);
- UpplReturnCode ReadBulkInternal(void* key_struct,
+ UpplReturnCode ReadBulkInternal(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t max_rep_ct,
string controller_name);
Kt_Base* GetChildClassPointer(KtSwitchChildClass KIndex);
- UpplReturnCode SetOperStatus(uint32_t data_type,
+ UpplReturnCode SetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
- UpplSwitchOperStatus oper_status,
- bool is_single_key = false);
+ UpplSwitchOperStatus oper_status);
void FreeChildKeyStruct(int child_class,
void *key_struct);
- void FrameValidValue(string attr_value, val_switch_st &obj_val_st);
- void GetSwitchValStructure(
+ void FrameValidValue(string attr_value,
+ val_switch_st &obj_val_st);
+ void GetSwitchValStructure(OdbcmConnectionHandler *db_conn,
val_switch_st_t *obj_val_switch,
vector<TableAttrSchema> &vect_table_attr_schema,
vector<string> &vect_prim_keys,
uint8_t operation_type,
val_switch_st_t *val_switch_valid_st,
stringstream &valid);
- void GetSwitchStateValStructure(
+ void GetSwitchStateValStructure(OdbcmConnectionHandler *db_conn,
val_switch_st_t *obj_val_switch,
vector<TableAttrSchema> &vect_table_attr_schema,
vector<string> &vect_prim_keys,
#include <unc/keytype.h>
#include <string>
#include "physical_itc_req.hh"
+#include "odbcm_connection.hh"
using pfc::core::ipc::ClientSession;
+using unc::uppl::OdbcmConnectionHandler;
namespace unc {
namespace uppl {
UpplReturnCode ProcessLogicalPortEvents(ClientSession *sess,
uint32_t data_type,
uint32_t operation);
- UpplReturnCode ProcessLogicalMemeberPortEvents(ClientSession *sess,
- uint32_t data_type,
- uint32_t operation);
- void GetNotificationDT(string controller_name,
+ UpplReturnCode ProcessLogicalMemeberPortEvents(
+ ClientSession *sess,
+ uint32_t data_type,
+ uint32_t operation);
+ void GetNotificationDT(OdbcmConnectionHandler *db_conn,
+ string controller_name,
uint32_t &data_type);
/*This function process notification events*/
UpplReturnCode ProcessNotificationEvents(const IpcEvent &event);
/*This function process alarm events*/
UpplReturnCode ProcessAlarmEvents(const IpcEvent &event);
UpplReturnCode InvokeKtDriverEvent(
+ OdbcmConnectionHandler *db_conn,
uint32_t operation,
uint32_t data_type,
void *key_struct,
#define _ITC_READ_REQUEST_HH_
#include <string>
+#include <vector>
#include "physical_common_def.hh"
#include "unc/uppl_common.h"
#include "physical_itc_req.hh"
using unc::uppl::ITCReq;
+typedef enum {
+ IS_KEY = 0,
+ IS_VALUE,
+ IS_STATE_VALUE,
+ IS_SEPARATOR
+}ValueType;
+
+struct BulkReadBuffer {
+ unc_key_type_t key_type;
+ ValueType value_type;
+ void* value;
+};
+
/*
- * It is a singleton class which will be inherited from ITCReq class
+ * This class which will be inherited from ITCReq class
* to process read requests
* For further info,see the comments in .cc file
**/
public:
ReadRequest();
~ReadRequest();
- UpplReturnCode ProcessReq(ServerSession &session);
+ UpplReturnCode ProcessReq(ServerSession &session,
+ physical_request_header &obj_req_hdr);
+ void AddToBuffer(BulkReadBuffer objBuffer) {
+ vect_bulk_read_buffer.push_back(objBuffer);
+ }
+
+ vector<BulkReadBuffer>& get_readbulk_buffer() {
+ return vect_bulk_read_buffer;
+ }
+ void FlushBulkReadBuffer();
private:
key_root_t key_root_obj;
val_link_st_t val_link_obj;
key_boundary_t key_boundary_obj;
val_boundary_t val_boundary_obj;
- UpplReturnCode ProcessReadOperation(ServerSession &session,
+ vector<BulkReadBuffer> vect_bulk_read_buffer;
+ UpplReturnCode ProcessReadOperation(OdbcmConnectionHandler *db_conn,
+ ServerSession &session,
Kt_Base *KtObj,
- physical_request_header obj_req_hdr,
+ physical_request_header &obj_req_hdr,
void* key_struct,
void* val_struct,
uint32_t operation_type);
void AddBoundaryStructure(ServerSession &session,
BulkReadBuffer obj_buffer,
int &err);
+ void ClearControllerStructure(BulkReadBuffer obj_buffer);
+ void ClearDomainStructure(BulkReadBuffer obj_buffer);
+ void ClearLogicalPortStructure(BulkReadBuffer obj_buffer);
+ void ClearLogicalMemberPortStructure(BulkReadBuffer obj_buffer);
+ void ClearSwitchStructure(BulkReadBuffer obj_buffer);
+ void ClearPortStructure(BulkReadBuffer obj_buffer);
+ void ClearLinkStructure(BulkReadBuffer obj_buffer);
+ void ClearBoundaryStructure(BulkReadBuffer obj_buffer);
};
#define ADD_KEY_TO_SESSION(err, session, key_type, key_value, ipc_keytype_t) { \
if (key != NULL) { \
pfc_log_debug("Key added: %s", IpctUtil::get_string(*key).c_str()); \
err |= session.addOutput(*key); \
- delete key; \
- key = NULL; \
} \
}
if (val != NULL) { \
pfc_log_debug("Value added: %s", IpctUtil::get_string(*val).c_str()); \
err |= session.addOutput(*val); \
+ } \
+}
+
+#define CLEAR_KEY(key_value, ipc_keytype_t) { \
+ ipc_keytype_t *key = \
+ reinterpret_cast<ipc_keytype_t*>(key_value); \
+ if (key != NULL) { \
+ delete key; \
+ key = NULL; \
+ } \
+}
+
+#define CLEAR_VALUE(value, ipc_keytype_t) { \
+ ipc_keytype_t *val = \
+ reinterpret_cast<ipc_keytype_t*>(value); \
+ if (val != NULL) { \
delete val; \
val = NULL; \
} \
public:
SystemStateChangeRequest();
~SystemStateChangeRequest();
- UpplReturnCode GetControllerListFromDb(uint32_t,
- vector<string> &vec_controller_name);
- UpplReturnCode SystemStateChangeToStandBy();
- UpplReturnCode SystemStateChangeToActive();
+ UpplReturnCode SystemStateChangeToStandBy(OdbcmConnectionHandler *db_conn);
+ UpplReturnCode SystemStateChangeToActive(OdbcmConnectionHandler *db_conn);
+
+ private:
+ UpplReturnCode SendCandidateInfoToLogical(OdbcmConnectionHandler *db_conn);
};
} // namespace uppl
} // namespace unc
-#ifndef _ITC_TRANSACT_REQUEST_HH_
-#define _ITC_TRANSACT_REQUEST_HH_
+#ifndef _ITC_TRANSACTION_REQUEST_HH_
+#define _ITC_TRANSACTION_REQUEST_HH_
/*
* Copyright (c) 2012-2013 NEC Corporation
/**
* @brief Transaction Request
- * @file itc_transact_request.hh
+ * @file itc_transaction_request.hh
*
**/
#include "phy_util.hh"
#include "itc_kt_base.hh"
#include "physical_itc_req.hh"
+#include "odbcm_connection.hh"
using std::vector;
using std::set;
using unc::tclib::TcCommitPhaseType;
using unc::tclib::TcCommitPhaseResult;
using unc::tclib::TcCommitOpAbortPhase;
+using unc::tclib::TcTransEndResult;
namespace unc {
namespace uppl {
set<string>set_controller_oflow;
set<string>set_controller_vnp;
map<unc_keytype_ctrtype_t, vector<string> > driver_controller_info_map_;
- UpplReturnCode SendControllerNotification(vector<void *> vec_old_val_ctr);
+ UpplReturnCode SendControllerNotification(OdbcmConnectionHandler *db_conn,
+ vector<void *> vec_old_val_ctr);
UpplReturnCode SendDomainNotification(
+ OdbcmConnectionHandler *db_conn,
vector<void *> vec_old_val_ctr_domain);
UpplReturnCode SendBoundaryNotification(
+ OdbcmConnectionHandler *db_conn,
vector<void *> vec_old_val_boundary);
- void SendControllerInfo(uint32_t operation_type,
+ void SendControllerInfo(OdbcmConnectionHandler *db_conn,
+ uint32_t operation_type,
uint32_t session_id,
uint32_t config_id);
- UpplReturnCode GetModifiedConfiguration(uint32_t session_id,
- uint32_t config_id,
+ UpplReturnCode GetModifiedConfiguration(OdbcmConnectionHandler *db_conn,
CsRowStatus row_status);
void ClearMaps();
- UpplReturnCode GetModifiedController(CsRowStatus row_status);
- UpplReturnCode GetModifiedDomain(CsRowStatus row_status);
- UpplReturnCode GetModifiedBoundary(CsRowStatus row_status);
+ UpplReturnCode GetModifiedController(OdbcmConnectionHandler *db_conn,
+ CsRowStatus row_status);
+ UpplReturnCode GetModifiedDomain(OdbcmConnectionHandler *db_conn,
+ CsRowStatus row_status);
+ UpplReturnCode GetModifiedBoundary(OdbcmConnectionHandler *db_conn,
+ CsRowStatus row_status);
public:
TransactionRequest();
~TransactionRequest();
- UpplReturnCode StartTransaction(uint32_t session_id, uint32_t config_id);
+ UpplReturnCode StartTransaction(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id, uint32_t config_id);
UpplReturnCode HandleVoteRequest(uint32_t session_id, uint32_t config_id,
TcDriverInfoMap &driver_info);
- UpplReturnCode HandleDriverResult(uint32_t session_id,
+ UpplReturnCode HandleDriverResult(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t config_id,
TcCommitPhaseType phase,
TcCommitPhaseResult
UpplReturnCode AbortTransaction(uint32_t session_id,
uint32_t config_id,
TcCommitOpAbortPhase operation_phase);
- UpplReturnCode EndTransaction(uint32_t session_id, uint32_t config_id);
+ UpplReturnCode EndTransaction(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
+ uint32_t config_id,
+ TcTransEndResult trans_res);
};
} // namespace uppl
} // namespace unc
-#endif // _ITC_TRANSACT_REQUEST_HH_
+#endif // _ITC_TRANSACTION_REQUEST_HH_
#define UPPL_LINK_TABLE "link_table"
#define UPPL_BOUNDARY_TABLE "boundary_table"
+
+/**controller table Column names enumeration*/
+typedef enum {
+ CTR_NAME = 0,
+ CTR_TYPE,
+ CTR_VERSION,
+ CTR_DESCRIPTION,
+ CTR_IP_ADDRESS,
+ CTR_USER_NAME,
+ CTR_PASSWORD,
+ CTR_ENABLE_AUDIT,
+ CTR_ACTUAL_VERSION,
+ CTR_OPER_STATUS,
+ CTR_VALID,
+ CTR_CS_ROW_STATUS,
+ CTR_CS_ATTR = 12,
+ DOMAIN_NAME = 13,
+ DOMAIN_TYPE,
+ DOMAIN_DESCRIPTION,
+ DOMAIN_OP_STATUS,
+ DOMAIN_VALID,
+ DOMAIN_CS_ROW_STATUS,
+ DOMAIN_CS_ATTR = 19,
+ LP_PORT_ID = 20,
+ LP_DESCRIPTION,
+ LP_PORT_TYPE,
+ LP_SWITCH_ID,
+ LP_PHYSICAL_PORT_ID,
+ LP_OPER_DOWN_CRITERIA,
+ LP_OPER_STATUS,
+ LP_CTR_VALID = 27,
+ LMP_SWITCH_ID = 28,
+ LMP_PHYSICAL_PORT_ID,
+ LMP_LP_PORT_ID = 30,
+ SWITCH_ID = 31,
+ SWITCH_DESCRIPTION,
+ SWITCH_MODEL,
+ SWITCH_IP_ADDRESS,
+ SWITCH_IPV6_ADDRESS,
+ SWITCH_ADMIN_STATUS,
+ SWITCH_DOMAIN_NAME,
+ SWITCH_MANUFACTURER,
+ SWITCH_HARDWARE,
+ SWITCH_SOFTWARE,
+ SWITCH_ALARM_STATUS,
+ SWITCH_OPER_STATUS,
+ SWITCH_VALID = 43,
+ PORT_ID = 44,
+ PORT_NUMBER,
+ PORT_DESCRIPTION,
+ PORT_ADMIN_STATUS,
+ PORT_DIRECTION,
+ PORT_TRUNK_ALL_VLAN,
+ PORT_OPER_STATUS,
+ PORT_MAC_ADDRESS,
+ PORT_DUPLEX,
+ PORT_SPEED,
+ PORT_ALARM_STATUS,
+ PORT_LOGIC_PORT_ID,
+ PORT_VALID = 56,
+ LINK_SWITCH_ID1 = 57,
+ LINK_PORT_ID1,
+ LINK_SWITCH_ID2,
+ LINK_PORT_ID2,
+ LINK_DESCRIPTION,
+ LINK_OPER_STATUS,
+ LINK_VALID = 63,
+ BDRY_ID = 64,
+ BDRY_DESCRIPTION,
+ BDRY_CTR_NAME1,
+ BDRY_DM_NAME1,
+ BDRY_PORT_ID1,
+ BDRY_CTR_NAME2,
+ BDRY_DM_NAME2,
+ BDRY_PORT_ID2,
+ BDRY_OPER_STATUS,
+ BDRY_VALID,
+ BDRY_ROW_STATUS,
+ BDRY_ATTR = 75,
+ UNKNOWN_COLUMN
+}ODBCMTableColumns;
+
+/*
+* odbcm tables column name struct
+*/
+typedef struct {
+ const unc::uppl::ODBCMTableColumns column_id;
+ const std::string column_string;
+}OdbcmColumnName;
+
// UPPL tables column names
// controller_table columns
-#define CTR_NAME "controller_name"
-#define CTR_TYPE "type"
-#define CTR_VERSION "version"
-#define CTR_DESCRIPTION "description"
-#define CTR_IP_ADDRESS "ip_address"
-#define CTR_USER_NAME "user_name"
-#define CTR_PASSWORD "password"
-#define CTR_ENABLE_AUDIT "enable_audit"
-#define CTR_ACTUAL_VERSION "actual_version"
-#define CTR_OPER_STATUS "oper_status"
-#define CTR_VALID "valid"
-#define CTR_CS_ROW_STATUS "cs_row_status"
-#define CTR_CS_ATTR "cs_attr"
+#define CTR_NAME_STR "controller_name"
+#define CTR_TYPE_STR "type"
+#define CTR_VERSION_STR "version"
+#define CTR_DESCRIPTION_STR "description"
+#define CTR_IP_ADDRESS_STR "ip_address"
+#define CTR_USER_NAME_STR "user_name"
+#define CTR_PASSWORD_STR "password"
+#define CTR_ENABLE_AUDIT_STR "enable_audit"
+#define CTR_ACTUAL_VERSION_STR "actual_version"
+#define CTR_OPER_STATUS_STR "oper_status"
+#define CTR_VALID_STR "valid"
+#define CTR_CS_ROW_STATUS_STR "cs_row_status"
+#define CTR_CS_ATTR_STR "cs_attr"
// ctr_domain_table columns
-
-#define DOMAIN_NAME "domain_name"
-#define DOMAIN_TYPE "type"
-#define DOMAIN_DESCRIPTION "description"
-#define DOMAIN_OP_STATUS "oper_status"
-#define DOMAIN_VALID "valid"
-#define DOMAIN_CS_ROW_STATUS "cs_row_status"
-#define DOMAIN_CS_ATTR "cs_attr"
+#define DOMAIN_NAME_STR "domain_name"
+#define DOMAIN_TYPE_STR "type"
+#define DOMAIN_DESCRIPTION_STR "description"
+#define DOMAIN_OP_STATUS_STR "oper_status"
+#define DOMAIN_VALID_STR "valid"
+#define DOMAIN_CS_ROW_STATUS_STR "cs_row_status"
+#define DOMAIN_CS_ATTR_STR "cs_attr"
// logicalport_table columns
-#define LP_PORT_ID "port_id"
-#define LP_DESCRIPTION "description"
-#define LP_PORT_TYPE "port_type"
-#define LP_SWITCH_ID "switch_id"
-#define LP_PHYSICAL_PORT_ID "physical_port_id"
-#define LP_OPER_DOWN_CRITERIA "oper_down_criteria"
-#define LP_OPER_STATUS "oper_status"
-#define LP_CTR_VALID "valid"
+#define LP_PORT_ID_STR "port_id"
+#define LP_DESCRIPTION_STR "description"
+#define LP_PORT_TYPE_STR "port_type"
+#define LP_SWITCH_ID_STR "switch_id"
+#define LP_PHYSICAL_PORT_ID_STR "physical_port_id"
+#define LP_OPER_DOWN_CRITERIA_STR "oper_down_criteria"
+#define LP_OPER_STATUS_STR "oper_status"
+#define LP_CTR_VALID_STR "valid"
// logical_memberport_table columns
-#define LMP_SWITCH_ID "switch_id"
-#define LMP_PHYSICAL_PORT_ID "physical_port_id"
-#define LMP_LP_PORT_ID "port_id"
-
+#define LMP_SWITCH_ID_STR "switch_id"
+#define LMP_PHYSICAL_PORT_ID_STR "physical_port_id"
+#define LMP_LP_PORT_ID_STR "port_id"
// switch table columns
-#define SWITCH_ID "switch_id"
-#define SWITCH_DESCRIPTION "description"
-#define SWITCH_MODEL "model"
-#define SWITCH_IP_ADDRESS "ip_address"
-#define SWITCH_IPV6_ADDRESS "ipv6_address"
-#define SWITCH_ADMIN_STATUS "admin_status"
-#define SWITCH_DOMAIN_NAME "domain_name"
-#define SWITCH_MANUFACTURER "manufacturer"
-#define SWITCH_HARDWARE "hardware"
-#define SWITCH_SOFTWARE "software"
-#define SWITCH_ALARM_STATUS "alarms_status"
-#define SWITCH_OPER_STATUS "oper_status"
-#define SWITCH_VALID "valid"
+#define SWITCH_ID_STR "switch_id"
+#define SWITCH_DESCRIPTION_STR "description"
+#define SWITCH_MODEL_STR "model"
+#define SWITCH_IP_ADDRESS_STR "ip_address"
+#define SWITCH_IPV6_ADDRESS_STR "ipv6_address"
+#define SWITCH_ADMIN_STATUS_STR "admin_status"
+#define SWITCH_DOMAIN_NAME_STR "domain_name"
+#define SWITCH_MANUFACTURER_STR "manufacturer"
+#define SWITCH_HARDWARE_STR "hardware"
+#define SWITCH_SOFTWARE_STR "software"
+#define SWITCH_ALARM_STATUS_STR "alarms_status"
+#define SWITCH_OPER_STATUS_STR "oper_status"
+#define SWITCH_VALID_STR "valid"
-// port_table column
-// #define PORT_CTR_NAME "controller_name"
-#define PORT_ID "port_id"
-#define PORT_NUMBER "port_number"
-#define PORT_DESCRIPTION "description"
-#define PORT_ADMIN_STATUS "admin_status"
-#define PORT_DIRECTION "direction"
-#define PORT_TRUNK_ALL_VLAN "trunk_allowed_vlan"
-#define PORT_OPER_STATUS "oper_status"
-#define PORT_MAC_ADDRESS "mac_address"
-#define PORT_DUPLEX "duplex"
-#define PORT_SPEED "speed"
-#define PORT_ALARM_STATUS "alarms_status"
-#define PORT_LOGIC_PORT_ID "logical_port_id"
-#define PORT_VALID "valid"
+// port table columns
+#define PORT_ID_STR "port_id"
+#define PORT_NUMBER_STR "port_number"
+#define PORT_DESCRIPTION_STR "description"
+#define PORT_ADMIN_STATUS_STR "admin_status"
+#define PORT_DIRECTION_STR "direction"
+#define PORT_TRUNK_ALL_VLAN_STR "trunk_allowed_vlan"
+#define PORT_OPER_STATUS_STR "oper_status"
+#define PORT_MAC_ADDRESS_STR "mac_address"
+#define PORT_DUPLEX_STR "duplex"
+#define PORT_SPEED_STR "speed"
+#define PORT_ALARM_STATUS_STR "alarms_status"
+#define PORT_LOGIC_PORT_ID_STR "logical_port_id"
+#define PORT_VALID_STR "valid"
// link_table columns
-// #define LINK_CTR_NAME "controller_name"
-#define LINK_SWITCH_ID1 "switch_id1"
-#define LINK_PORT_ID1 "port_id1"
-#define LINK_SWITCH_ID2 "switch_id2"
-#define LINK_PORT_ID2 "port_id2"
-#define LINK_DESCRIPTION "description"
-#define LINK_OPER_STATUS "oper_status"
-#define LINK_VALID "valid"
+#define LINK_SWITCH_ID1_STR "switch_id1"
+#define LINK_PORT_ID1_STR "port_id1"
+#define LINK_SWITCH_ID2_STR "switch_id2"
+#define LINK_PORT_ID2_STR "port_id2"
+#define LINK_DESCRIPTION_STR "description"
+#define LINK_OPER_STATUS_STR "oper_status"
+#define LINK_VALID_STR "valid"
// boundary_table columns
-#define BDRY_ID "boundary_id"
-#define BDRY_DESCRIPTION "description"
-#define BDRY_CTR_NAME1 "controller_name1"
-#define BDRY_DM_NAME1 "domain_name1"
-#define BDRY_PORT_ID1 "logical_port_id1"
-#define BDRY_CTR_NAME2 "controller_name2"
-#define BDRY_DM_NAME2 "domain_name2"
-#define BDRY_PORT_ID2 "logical_port_id2"
-#define BDRY_OPER_STATUS "oper_status"
-#define BDRY_VALID "valid"
-#define BDRY_ROW_STATUS "cs_row_status"
-#define BDRY_ATTR "cs_attr"
+#define BDRY_ID_STR "boundary_id"
+#define BDRY_DESCRIPTION_STR "description"
+#define BDRY_CTR_NAME1_STR "controller_name1"
+#define BDRY_DM_NAME1_STR "domain_name1"
+#define BDRY_PORT_ID1_STR "logical_port_id1"
+#define BDRY_CTR_NAME2_STR "controller_name2"
+#define BDRY_DM_NAME2_STR "domain_name2"
+#define BDRY_PORT_ID2_STR "logical_port_id2"
+#define BDRY_OPER_STATUS_STR "oper_status"
+#define BDRY_VALID_STR "valid"
+#define BDRY_ROW_STATUS_STR "cs_row_status"
+#define BDRY_ATTR_STR "cs_attr"
#define PHY_FINI_READ_LOCK() \
if (PhysicalLayer::phyFiniFlag == 1) { \
/**this structure will hold the table name, column names, datatype and values
* template address.*/
struct TableAttrSchema {
- std::string table_attribute_name;
+ ODBCMTableColumns table_attribute_name;
// pointer to struct TableAttrValue
void* p_table_attribute_value;
unsigned int table_attribute_length;
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 NEC Corporation
+ * All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+/*
+ * @brief ODBC Manager
+ * @file odbcm_connection.hh
+ */
+
+#ifndef _ODBCM_DB_CONNECTION_H_
+#define _ODBCM_DB_CONNECTION_H_
+
+#include "odbcm_common.hh"
+#include "odbcm_mgr.hh"
+using unc::uppl::ODBCManager;
+namespace unc {
+namespace uppl {
+
+
+enum OdbcmConnType {
+ kOdbcmConnReadOnly = 0, // Read Only Connection
+ kOdbcmConnReadWriteNb, // Read Write Connection For Nb requests
+ kOdbcmConnReadWriteSb // Read Write Connection For Sb events
+};
+
+
+class OdbcmConnectionHandler {
+ public:
+ /*
+ * Constructor for OdbcmConnectionHandler
+ */
+ explicit OdbcmConnectionHandler(const OdbcmConnType conn_type,
+ UpplReturnCode &conn_status,
+ ODBCManager *odbc_manager) {
+ conn_type_ = conn_type;
+ odbc_manager_ = odbc_manager;
+ conn_handle_ = NULL;
+ conn_status = UPPL_RC_SUCCESS;
+ ODBCM_RC_STATUS db_ret = odbc_manager_->OpenDBConnection(this);
+ if (db_ret != ODBCM_RC_SUCCESS) {
+ conn_status = UPPL_RC_ERR_DB_ACCESS;
+ }
+ }
+ /*
+ * Destructor for OdbcmConnectionHandler
+ */
+ ~OdbcmConnectionHandler(void) {
+ ODBCM_RC_STATUS conn_ret = odbc_manager_->CloseDBConnection(this);
+ if (conn_ret != ODBCM_RC_SUCCESS) {
+ pfc_log_error(
+ "ODBCM:OdbcmConnectionHandler:Error in closing DB connection");
+ }
+ }
+
+ void set_conn_handle(SQLHDBC conn_handle) {
+ conn_handle_ = conn_handle;
+ }
+
+ OdbcmConnType get_conn_type() {
+ return conn_type_;
+ }
+
+ SQLHDBC get_conn_handle() {
+ return conn_handle_;
+ }
+
+ private:
+ OdbcmConnType conn_type_;
+ SQLHDBC conn_handle_; // Connection handler to create ODBC Connection
+ ODBCManager *odbc_manager_;
+};
+} // namespace uppl
+} // namespace unc
+#endif /*_ODBCM_DB_CONNECTION_H_*/
/*
* This corresponds to table name in db
*/
- std::string table_name_;
+ ODBCMTable table_name_;
/*
* This contains primary keys of the table
*/
*/
CsRowStatus db_return_status_;
- public:
/*
* Get the table name
*/
- std::string get_table_name();
+ ODBCMTable get_table_name();
/*
* Set the table name
*/
- void set_table_name(std::string table_name);
+ void set_table_name(ODBCMTable table_name);
/*
* Get the vector containing primary keys
*/
/*
* Get the list containing all the attribute vectors
*/
- std::list < std::vector <TableAttrSchema> > get_row_list();
+ std::list < std::vector <TableAttrSchema> >& get_row_list();
/*
* To push the primary keys in to primary_key vector
*/
* Method to print the database schema information
*/
void PrintDBTableSchema();
+
+ private:
+ /*
+ * To print the char buffer values in DBTableSchema
+ */
+ inline std::string Odbcm_PrintCharBuffer(uint8_t*, int, ODBCMTableColumns);
}; // class DBTableSchema
} // namespace uppl
#define ODBCM_SIZE_256 256
#define ODBCM_SIZE_257 257
#define ODBCM_SIZE_320 320
-
-/*
- * This if check is for fill structure
- */
-#define ODBCM_COMPARE_ATTRNAME_DATATYPE(__iv__, __dtype__, __aname__) \
- if ((__iv__.table_attribute_name.compare(__aname__) == 0) && \
- (__iv__.request_attribute_type == __dtype__) && \
- (__iv__.p_table_attribute_value != NULL))
-/*
- * This if check is for fetch structure value
- */
-#define ODBCM_COMPARE_FETCH_DATA(__iv__, __dtype__, __aname__) \
- if ((__iv__.table_attribute_name.compare(__aname__) == 0) && \
- (__iv__.request_attribute_type == __dtype__))
/*
* uppl memcpy macro
*/
#define ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(__dt__, __Tname__) \
ColumnAttrValue <__dt__> *__Tname__ = new ColumnAttrValue <__dt__>; \
ODBCM_MEMSET(__Tname__, '\0', sizeof(__dt__));
+
/*
* To bind the input datatypes
* for binding SQL_VARCHAR data type
#include <string>
#include "odbcm_common.hh"
#include "odbcm_db_tableschema.hh"
+
+
namespace unc {
namespace uppl {
/**macro for ending the current transaction with rollback or commit state*/
/**macro to create object instance from class*/
#define ODBCM_CREATE_OBJECT(__obj__, __class__) \
- __obj__ = new __class__();
+ __obj__ = new __class__(); \
+ if (__obj__ == NULL) \
+ pfc_log_fatal("ODBCM::ODBCManager:: " \
+ "Internal object memory allocation is failed");
/**macro to set odbc connection attributes
* 1. transaction flag setting - READ_COMMITTED
class QueryFactory;
class QueryProcessor;
class DBVarbind;
-
+class OdbcmConnectionHandler;
/**ODBMCManager is a class, exposes the API methods to UPPL managers and
* internal transaction coordinator (ITC)
* - Singleton class
* */
class ODBCManager {
public:
- /**constructor of ODBCManager class
- * InputParam: None*/
- ODBCManager();
/**Destructor of ODBCManager class
* InputParam: None*/
~ODBCManager();
* configuration file and update into local structure.
* */
ODBCM_RC_STATUS ODBCM_Initialize();
- /**open database connection using odbc driver, on which the configurations
- * given in the odbcm.conf file*/
- ODBCM_RC_STATUS ReconnectDB();
+
+ ODBCM_RC_STATUS OpenDBConnection(OdbcmConnectionHandler *conn_obj);
/**close the connection at the end of application, free the allocated
* handlers and environment */
- ODBCM_RC_STATUS CloseDBConnection();
+ ODBCM_RC_STATUS CloseDBConnection(OdbcmConnectionHandler *conn_obj);
/** getter method for db_table_list_map_ private member*/
- std::map<int, std::vector<std::string> > get_db_table_list_map_() const;
+ std::map<int, std::vector<std::string> >& get_db_table_list_map_();
+ /** getter method for odbcm_tables_column_map_ private member*/
+ std::map<ODBCMTableColumns, std::string>& get_odbcm_tables_column_map_();
/**passing table name string and get the id of table */
ODBCMTable get_table_id(std::string table_name);
+ /**passing table name string and get the id of table */
+ std::string GetTableName(ODBCMTable);
/**
* This method creates single key tree instance entry in the given DB table.
* When row entry is created in UNC_DT_CANDIDATE database table,
ODBCM_RC_STATUS CreateOneRow(unc_keytype_datatype_t/**Database type*/,
DBTableSchema&
/**object which carries the table
- ,pkeys,column names with data type*/);
+ ,pkeys,column names with data type*/,
+ OdbcmConnectionHandler *conn_obj);
/**
* This method updates one row of single keytree instance in the
* database table. The cs_row_status column will be set as updated. During
ODBCM_RC_STATUS UpdateOneRow(unc_keytype_datatype_t/**Database type*/,
DBTableSchema&
/**object which carries the table,pkeys,
- * column names with data type*/);
+ * column names with data type*/,
+ OdbcmConnectionHandler *conn_obj,
+ bool IsInternal = false);
/**
* This method deletes the attributes of single key tree
* instance in a row, the row entry will not be actually deleted in the case
ODBCM_RC_STATUS DeleteOneRow(unc_keytype_datatype_t/**Database type*/,
DBTableSchema&
/**object which carries the table,pkeys,
- * column names with data type*/);
+ * column names with data type*/,
+ OdbcmConnectionHandler *conn_obj);
/**
* This method fetches single row from the database table and
* return the result set (fill the table rows in the DBTableSchema ref.)and
ODBCM_RC_STATUS GetOneRow(unc_keytype_datatype_t/**Database type*/,
DBTableSchema&
/*object which carries the table,
- pkeys,column names with data type*/);
+ pkeys,column names with data type*/,
+ OdbcmConnectionHandler *conn_obj);
/**
* This method will fetch the one or more number of rows in the db table
* based upon the given max_repetition_count and condition or filter
uint32_t,
DBTableSchema&
/*object which carries the table,
- pkeys,column names with data type*/,
- unc_keytype_operation_t /**operation type*/);
+ pkeys,column names with data type*/,
+ unc_keytype_operation_t /**operation type*/,
+ OdbcmConnectionHandler *conn_obj);
/**
* To find the row value presence in the database table.
* */
ODBCM_RC_STATUS IsRowExists(unc_keytype_datatype_t/**Database type*/,
DBTableSchema&
/**object which carries the table,
- pkeys,column names with data type*/);
+ pkeys,column names with data type*/,
+ OdbcmConnectionHandler *conn_obj);
/**To get the row count of the given table*/
ODBCM_RC_STATUS GetRowCount(unc_keytype_datatype_t/**Database type*/,
std::string/** name of the table*/,
- uint32_t& /**return value count*/);
+ uint32_t& /**return value count*/,
+ OdbcmConnectionHandler *conn_obj);
/** this method clears single row in the database table,
* based on the condition given in the DBTableSchema that row will be
* identified and deleted permanently.*/
ODBCM_RC_STATUS ClearOneRow(unc_keytype_datatype_t/**Database type*/,
DBTableSchema&
/**object which carries the table,
- pkeys,column names with data type*/);
+ pkeys,column names with data type*/,
+ OdbcmConnectionHandler *conn_obj);
/**To get the sibling rows count*/
ODBCM_RC_STATUS GetSiblingCount(unc_keytype_datatype_t/**Database type*/,
DBTableSchema&
/**object which carries the
table,pkeys,column names with data type*/,
- uint32_t& /**return value count*/);
+ uint32_t& /**return value count*/,
+ OdbcmConnectionHandler *conn_obj);
/**To get the sibling rows count based upon given filter*/
ODBCM_RC_STATUS GetSiblingCount(unc_keytype_datatype_t/**Database type*/,
DBTableSchema&
std::vector<ODBCMOperator>
/**operator to decide
the filter while framing query (where
- clause) */);
+ clause) */,
+ OdbcmConnectionHandler *conn_obj);
/**To return the sibiling rows in the given table and based upon the given
* filter criteria*/
ODBCM_RC_STATUS GetSiblingRows(unc_keytype_datatype_t/**database type */,
std::vector<ODBCMOperator>
/*arithmetic operators to frame read sibling query*/,
unc_keytype_operation_t
- /**operation type siblingbegin/sibling*/);
+ /**operation type siblingbegin/sibling*/,
+ OdbcmConnectionHandler *conn_obj);
/**This method will copy one databases all contents to another database */
ODBCM_RC_STATUS CopyDatabase(unc_keytype_datatype_t /**Database type*/,
- unc_keytype_datatype_t /**Database type*/);
+ unc_keytype_datatype_t /**Database type*/,
+ OdbcmConnectionHandler *conn_obj);
/**To clear given key instance rows in all the tables in DB*/
ODBCM_RC_STATUS ClearOneInstance(unc_keytype_datatype_t /**Database type*/,
- std::string controller_name /**keyvalue*/);
+ std::string controller_name /**keyvalue*/,
+ OdbcmConnectionHandler *conn_obj);
/**clear the entries in the database tables.*/
- ODBCM_RC_STATUS ClearDatabase(unc_keytype_datatype_t /**Database type*/);
- ODBCM_RC_STATUS IsCandidateDirty();
+ ODBCM_RC_STATUS ClearDatabase(unc_keytype_datatype_t /**Database type*/,
+ OdbcmConnectionHandler *conn_obj);
+ ODBCM_RC_STATUS IsCandidateDirty(OdbcmConnectionHandler *conn_obj);
/**To get the modified rows, it will return CREATE/UPDATED/DELETED
* rows_status rows*/
ODBCM_RC_STATUS GetModifiedRows(unc_keytype_datatype_t /**Database type*/,
DBTableSchema&
/**object which carries the
- table,pkeys,column names with data type*/);
+ table,pkeys,column names with data type*/,
+ OdbcmConnectionHandler *conn_obj);
/** To commit all the configuration from candidate to
* running database.
* */
ODBCM_RC_STATUS CommitAllConfiguration(unc_keytype_datatype_t
/**Database type*/,
unc_keytype_datatype_t
- /**Database type*/);
+ /**Database type*/,
+ OdbcmConnectionHandler *conn_obj);
/**Freeing allocated memory for class object, table structure,
* statement handler*/
void ODBCMFreeingMemory(HSTMT, ODBCMTable, DBVarbind*,
QueryFactory*,
QueryProcessor*);
+ std::string GetColumnName(ODBCMTableColumns);
+ // Closes the Read Write connections
+ ODBCM_RC_STATUS CloseRwConnection();
private:
+ /**constructor of ODBCManager class
+ * InputParam: None*/
+ ODBCManager();
+ /* ODBCManager instance */
+ static ODBCManager *ODBCManager_;
db_conf_info conf_parser_; // odbcm.conf file information
uint8_t IsODBCManager_initialized;
// hold all DB table names
std::map <int, std::vector<std::string> > db_table_list_map_;
- SQLHDBC rw_conn_handle_; // Handle connection
- SQLHDBC ro_conn_handle_; // Handle connection
SQLHENV phy_conn_env_; // Handle ODBC environment
- /**return the rw_conn_handle_*/
- inline SQLHDBC get_rw_connenction_handle_() const;
- /**return the ro_conn_handle_*/
- inline SQLHDBC get_ro_connenction_handle_() const;
+ /**Collection of all uppl tables column names with id*/
+ std::map <ODBCMTableColumns, std::string> odbcm_tables_column_map_;
/**return the phy_conn_env_*/
- inline SQLHENV get_phy_connenction_env_() const;
- /**initialize the configuration map, the data will be fetched from
- * the odbcm.conf file*/
- ODBCM_RC_STATUS initialize_odbc_db_config_map_();
+ inline SQLHENV get_phy_connection_env_() const;
+
+ /**initialize the ODBCMTableColumnsMap, fill all tables columns
+ * from the static array*/
+ ODBCM_RC_STATUS initialize_odbcm_tables_column_map_(void);
/**initialize the map with database and corresponding tables on
* each database. */
- ODBCM_RC_STATUS initialize_db_table_list_map_();
+ ODBCM_RC_STATUS initialize_db_table_list_map_(void);
/**allocate connection handler for rw_conn_handle_*/
- inline ODBCM_RC_STATUS set_rw_connenction_handle_();
+ inline ODBCM_RC_STATUS set_rw_connection_handle_(SQLHDBC&);
/**allocate connection handler for ro_conn_handle_*/
- inline ODBCM_RC_STATUS set_ro_connenction_handle_();
+ inline ODBCM_RC_STATUS set_ro_connection_handle_(SQLHDBC&);
/**allocate environment handler for phy_conn_env_*/
- inline ODBCM_RC_STATUS set_phy_connenction_env_();
+ inline ODBCM_RC_STATUS set_phy_connection_env_();
/**parse the odbcm.conf file and update db_conf_info structure*/
ODBCM_RC_STATUS ParseConfigFile();
- ODBCM_RC_STATUS OpenDBConnection();
+ /**during the physical daemon initialize, allocate the connection
+ * environment which will be common for all the connection and also
+ * this method will enable the connection pooling */
+ ODBCM_RC_STATUS InitializeConnectionEnv();
+ // Connection handles to store nb and sb rw connection
+ OdbcmConnectionHandler *rw_nb_conn_obj_;
+ OdbcmConnectionHandler *rw_sb_conn_obj_;
};
} // namespace uppl
} // namespace unc
/**** Function pointers to class member functions ****/
/** Function pointer for below methods
* operation_createonerow,
- * operation_updateonerow
* operation_deleteonerow
* operation_clearonerow
* operation_isrowexists
* operation_getmodifiedrows */
std::string(QueryFactory::*GetQuery)
(unc_keytype_datatype_t, DBTableSchema&);
+ /* operation_updateonerow */
+ std::string(QueryFactory::*GetQueryWithBool)
+ (unc_keytype_datatype_t, DBTableSchema&, bool);
/** Function pointer for operation_getsiblingCount with filters */
std::string(QueryFactory::*GetFilterCountQuery)
(unc_keytype_datatype_t, DBTableSchema&, std::vector<ODBCMOperator>);
/** Function pointer for operation_copydatabase */
std::string* (QueryFactory::*GetTwoDBQuery)
(unc_keytype_datatype_t, unc_keytype_datatype_t);
- /** Function pointer for operation_mergetwodatabase */
-/*
- std::string* (QueryFactory::*GetTwoTableQuery)
- (unc_keytype_datatype_t, unc_keytype_datatype_t, std::string);
-*/
/** Function pointer for operation_cleardatabase */
std::string* (QueryFactory::*GetSingleDBQuery)
(unc_keytype_datatype_t);
/** Function pointer for operation_getbulkrows */
std::string(QueryFactory::*GetBulkRowQuery)
(unc_keytype_datatype_t, uint32_t, DBTableSchema&,
- unc_keytype_operation_t);
+ unc_keytype_operation_t);
/** Function pointer for operation_clearoneinstance */
std::string* (QueryFactory::*GetClearInstanceQuery)
(unc_keytype_datatype_t, std::string&);
+ std::string getOrderByString(ODBCMTable, std::vector <std::string>&);
private:
/** To frame query for creating a row in db */
SQLQUERY operation_createonerow
(unc_keytype_datatype_t, DBTableSchema &);
/** To frame query for updating a row in db */
SQLQUERY operation_updateonerow
- (unc_keytype_datatype_t, DBTableSchema &);
+ (unc_keytype_datatype_t, DBTableSchema &, bool);
/** To frame query for deleting a row in db
* (Change cs_row_status to DELETED) */
SQLQUERY operation_deleteonerow
/** To frame query to copy data from one to other db */
SQLQUERY* operation_copydatabase
(unc_keytype_datatype_t, unc_keytype_datatype_t);
- /** To frame query for merging two db */
- // SQLQUERY* operation_mergetwodatabase
- // (unc_keytype_datatype_t, unc_keytype_datatype_t, std::string);
/** To frame query for clearing a controller
* instance in all tables in a db */
SQLQUERY* operation_clearoneinstance
rc == SQL_STILL_EXECUTING || \
rc == SQL_NEED_DATA ) { \
ODBCMUtils::OdbcmStmtResourcesFree(hstmt); \
- odbcm_rc = (ODBCM_RC_STATUS)rc; } \
+ } \
+ odbcm_rc = (ODBCM_RC_STATUS)rc; \
}
/*
#include "physical_common_def.hh"
#include "unc/uppl_common.h"
#include "odbcm_mgr.hh"
+#include "odbcm_connection.hh"
using std::vector;
using std::string;
using unc::uppl::DBTableSchema;
using unc::uppl::ColumnAttrValue;
using unc::uppl::TableAttrSchema;
+using unc::uppl::ODBCMTableColumns;
+using unc::uppl::OdbcmConnectionHandler;
const uint16_t UPPL_NO_VAL_STRUCT = -1;
class PhyUtil {
public:
- static void printReqHeader(physical_request_header rqh);
- static void printRespHeader(physical_response_header rsh);
- static void getRespHeaderFromReqHeader(physical_request_header rqh,
+ static void printReqHeader(const physical_request_header& rqh);
+ static void printRespHeader(const physical_response_header& rsh);
+ static void getRespHeaderFromReqHeader(const physical_request_header& rqh,
physical_response_header& rsh);
static int sessOutRespHeader(ServerSession& sess,
- physical_response_header& rsh);
+ const physical_response_header& rsh);
static int sessGetReqHeader(ServerSession& sess,
physical_request_header& rqh);
static int sessOutReqHeader(ClientSession& sess,
- physical_request_header rqh);
+ const physical_request_header& rqh);
static int sessGetRespHeader(ClientSession& sess,
physical_response_header& rsh);
- static void printDriverReqHeader(driver_request_header rqh);
- static void printDriverRespHeader(driver_response_header rsh);
+ static void printDriverReqHeader(const driver_request_header& rqh);
+ static void printDriverRespHeader(const driver_response_header& rsh);
static int sessOutDriverReqHeader(ClientSession& sess,
- driver_request_header rqh);
+ const driver_request_header& rqh);
static int sessGetDriverRespHeader(ClientSession& sess,
driver_response_header& rsh);
static int sessGetDriverEventHeader(ClientSession& sess,
static int sessGetDriverAlarmHeader(ClientSession& sess,
driver_alarm_header& rsh);
static int sessOutNBEventHeader(ServerEvent& sess,
- northbound_event_header& rqh);
+ const northbound_event_header& rqh);
static int sessOutNBAlarmHeader(ServerEvent& sess,
- northbound_alarm_header& rqh);
- static string uint8tostr(uint8_t c);
- static string uint16tostr(uint16_t c);
- static string uint64tostr(uint64_t c);
- static int uint8touint(uint8_t c);
- static unsigned int strtouint(string str);
- static uint64_t strtouint64(string str);
- static void FillDbSchema(string attr_name,
+ const northbound_alarm_header& rqh);
+ static string uint8tostr(const uint8_t &c);
+ static string uint16tostr(const uint16_t &c);
+ static string uint64tostr(const uint64_t &c);
+ static int uint8touint(const uint8_t &c);
+ static unsigned int strtouint(const string &str);
+ static uint64_t strtouint64(const string &str);
+ static void FillDbSchema(ODBCMTableColumns attr_name,
string attr_value,
unsigned int attr_length,
AttributeDataType attr_type,
vector<TableAttrSchema> &vect_attr);
- static void FillDbSchema(string attr_name,
+ static void FillDbSchema(ODBCMTableColumns attr_name,
+ uint8_t* attr_value,
+ unsigned int attr_length,
+ AttributeDataType attr_type,
+ vector<TableAttrSchema> &vect_attr);
+ static void FillDbSchema(ODBCMTableColumns attr_name,
+ string attr_name_str,
string attr_value,
unsigned int attr_length,
AttributeDataType attr_type,
vector<TableAttrSchema> &vect_attr,
vector<string> &vect_prim_keys,
stringstream &out_valid_value);
- static void GetValueFromDbSchema(TableAttrSchema table_attr_schema,
+ static void FillDbSchema(ODBCMTableColumns attr_name,
+ string attr_name_str,
+ uint8_t* attr_value,
+ unsigned int attr_length,
+ AttributeDataType attr_type,
+ uint32_t operation_type,
+ uint16_t in_valid_val,
+ uint16_t prev_db_valid_val,
+ vector<TableAttrSchema> &vect_attr,
+ vector<string> &vect_prim_keys,
+ stringstream &out_valid_value);
+ static void GetValueFromDbSchema(const TableAttrSchema& table_attr_schema,
string &attr_value,
AttributeDataType attr_type);
+ static void GetValueFromDbSchemaStr(
+ const TableAttrSchema& table_attr_schema,
+ uint8_t *attr_value,
+ AttributeDataType attr_type);
static UpplReturnCode get_controller_type(
+ OdbcmConnectionHandler *db_conn,
string controller_name,
unc_keytype_ctrtype_t& controller_type,
unc_keytype_datatype_t datatype);
- static UpplReturnCode GetControllerStatus(unc_keytype_datatype_t,
- string controller_id,
- uint8_t& oper_status);
- static UpplReturnCode GetOperStatus(unc_keytype_datatype_t,
- string controller_id,
- uint16_t& oper_status);
static void reorder_col_attrs(
vector<string> vect_prim_keys,
vector<TableAttrSchema> &vect_table_attr_schema);
DATATYPE_UINT8_ARRAY_8,
DATATYPE_UINT8_ARRAY_9,
DATATYPE_UINT8_ARRAY_11,
- DATATYPE_UINT8_ARRAY_12,
DATATYPE_UINT8_ARRAY_16,
DATATYPE_UINT8_ARRAY_32,
DATATYPE_UINT8_ARRAY_128,
typedef enum {
TRANS_END = 0,
TRANS_START,
- TRANS_START_FAILURE,
TRANS_START_SUCCESS,
VOTE_BEGIN,
VOTE_WAIT_DRIVER_RESULT,
- VOTE_DRIVER_RESULT,
- VOTE_FAILURE,
VOTE_SUCCESS,
GLOBAL_COMMIT_BEGIN,
GLOBAL_COMMIT_WAIT_DRIVER_RESULT,
GLOBAL_COMMIT_DRIVER_RESULT,
- GLOBAL_COMMIT_FAILURE,
GLOBAL_COMMIT_SUCCESS
}TransState;
-/*
- * @brief Import State
- */
-
-typedef enum {
- IMPORT_END = 0,
- IMPORT_START,
- IMPORT_START_FAILURE,
- IMPORT_START_SUCCESS,
- MERGE_BEGIN,
- MERGE_FAILURE,
- MERGE_SUCCESS,
- CLEAR_IMPORT_BEGIN,
- CLEAR_IMPORT_FAILURE
-}ImportState;
-
-/*
- * @brief Audit State
- */
-
-typedef enum {
- AUDIT_END = 0,
- AUDIR_START,
- AUDIT_START_SUCCESS,
- AUDIT_START_FAILURE,
- AUDIT_TRANS_START,
- AUDIT_TRANS_START_FAILURE,
- AUDIT_TRANS_START_SUCCESS,
- AUDIT_VOTE_BEGIN,
- AUDIT_VOTE_WAIT_DRIVER_RESULT,
- AUDIT_VOTE_DRIVER_RESULT,
- AUDIT_VOTE_FAILURE,
- AUDIT_VOTE_SUCCESS,
- AUDIT_GLOBAL_COMMIT_BEGIN,
- AUDIT_GLOBAL_COMMIT_WAIT_DRIVER_RESULT,
- AUDIT_GLOBAL_COMMIT_DRIVER_RESULT,
- AUDIT_GLOBAL_COMMIT_FAILURE,
- AUDIT_GLOBAL_COMMIT_SUCCESS,
- AUDIT_TRANS_END,
- AUDIT_END_BEGIN
-}AuditState;
-
/*
* @brief Driver Response Status
*/
class PhysicalCore : public TcLibInterface, public UncStateHandler {
public:
/**
- * @Description : The function returns singleton instance of PhysicalCore class
+ * @Description : The function returns singleton instance of
+ * PhysicalCore class
*/
static PhysicalCore* get_physical_core();
/**
- * @Description : This function initializes physical core members and reads config,
- * sends event subscription to driver
+ * @Description : This function initializes physical core members and
+ * reads config, sends event subscription to driver
* @param[in] :
*/
UpplReturnCode ReadConfigFile();
/**
- * @Description : This function reads controller capability config and fills the
- * capability map
+ * @Description : This function reads controller capability config
+ * and fills the capability map
* @param[in] :
*/
UpplReturnCode CancelEventSubscripInDriver();
/**
- * @Description : This function validates the config ID by sending IPC msg to
- * TC library
+ * @Description : This function validates the config ID by sending
+ * IPC msg to TC library
* @param[in] : session_id - Session ID from the request
* @param[in] : config_id - Configuration ID
*/
UpplReturnCode ValidateConfigId(uint32_t session_id, uint32_t config_id);
/**
- * @Description : This function validates if the operation is valid in STANDBY
- * state
+ * @Description : This function validates if the operation is valid
+ * in STANDBY state
* @param[in] : operation_type - type of operation requested
*/
}
/**
- * @Description : This function returns the list of supported controller version
- * Controller version will be available in static capability file
+ * @Description : This function returns the list of supported controller
+ * version
+ * Controller version will be available in static
+ * capability file
* This function will be called from ITC
* @param[in] :
*/
list<string> GetControllerVersionList();
/**
- * @Description : This function sends CONROLLER_DISCONNECT alarm to node manager
- * This function will be called from Kt_Controller class when it
- * receives CONTROLLER notification from driver with oper_status
- * as down
+ * @Description : This function sends CONROLLER_DISCONNECT alarm to
+ * node manager
+ * This function will be called from Kt_Controller class
+ * when it receives CONTROLLER notification from driver
+ * with oper_status as down
*
* @param[in] : controller_id - Controller identification
*/
UpplReturnCode SendControllerDisconnectAlarm(string controller_id);
/**
- * @Description : This function sends CONROLLER_CONNECT alarm to node manager
+ * @Description : This function sends CONROLLER_CONNECT alarm to
+ * node manager
* This is a clearance alarm for CONTROLLER_DISCONNECT alarm
- * This function will be called from Kt_Controller class when it
- * receives CONTROLLER notification from driver with oper_status
- * as up
+ * This function will be called from Kt_Controller class
+ * when it receives CONTROLLER notification from driver
+ * with oper_status as up
*
* @param[in] : controller_id - Controller identification
*/
UpplReturnCode SendControllerConnectAlarm(string controller_id);
- /**
- * @Description : This function sends AUDIT_FAILURE alarm to node manager
- * This function will be called from audit_req class when audit
- * operation fails
- *
- * @param[in] : controller_id - Controller identification
- */
-
- UpplReturnCode SendAuditFailureAlarm(string controller_id);
-
- /**
- * @Description : This function sends AUDIT_SUCCESS alarm to node manager
- * This is a clearance alarm for AUDIT_FAILURE alarm
- *
- *
- * @param[in] : controller_id - Controller identification
- */
-
- UpplReturnCode SendAuditSuccessAlarm(string controller_id);
/**
- *@Description : This function sends EVENT_HANDLING_SUCCESS alarm to node manager
- * This is a clearance alarm for EVENT_HANDLING FAILURE alarm
+ *@Description : This function sends EVENT_HANDLING_SUCCESS alarm to
+ * node manager
+ * This is a clearance alarm for EVENT_HANDLING FAILURE alarm
*
*
*@param[in] : controller_id - Controller identification
string event_details);
/**
- *@Description : This function sends EVENT_HANDLING_FAILURE alarm to node manager
+ *@Description : This function sends EVENT_HANDLING_FAILURE alarm to
+ * node manager
*@param[in] : controller_id - Controller identification
* event_failed - Additional details about failed event handling
*
/**
* @Description : This is a dummy function. TcLibInterface has pure virtual
- * functions. All functions has to have an implementiation to
+ * functions. All functions has to have an implementation to
* avoid runtime conflicts
*/
/**
* @Description : This is a dummy function. TcLibInterface has pure virtual
- * functions. All functions has to have an implementiation to
+ * functions. All functions has to have an implementation to
* avoid runtime conflicts
*/
TcCommitPhaseResult driver_result);
/**
* @Description : This is a dummy function. TcLibInterface has pure virtual
- * functions. All functions has to have an implementiation to
+ * functions. All functions has to have an implementation to
* avoid runtime conflicts
*/
TcDriverInfoMap &driver_info);
/**
* @Description : This is a dummy function. TcLibInterface has pure virtual
- * functions. All functions has to have an implementiation to
+ * functions. All functions has to have an implementation to
* avoid runtime conflicts
*/
TcCommonRet HandleAuditVoteRequest(uint32_t session_id,
TcAuditResult& audit_result);
/**
* @Description : This is a dummy function. TcLibInterface has pure virtual
- * functions. All functions has to have an implementiation to
+ * functions. All functions has to have an implementation to
* avoid runtime conflicts
*/
/* PhysicalCore Instance */
static PhysicalCore* physical_core_;
- /* For each controller version, this map the Key types and the attributes under
- * each Key Type that would be supported by controller.
+ /* For each controller version, this map the Key types and the attributes
+ * under each Key Type that would be supported by controller.
* For each attribute the properties are stored in a map
*/
map<ControllerVersion, map<cap_key_struct, cap_value_struct > >
#define _PFC_PHYSICALINTERNALTRANSACTIONCOORDINATOR_H_
#include <string>
-#include <vector>
#include "physical_common_def.hh"
#include "unc/uppl_common.h"
#include "itc_transaction_request.hh"
class ConfigurationRequest;
class ReadRequest;
-typedef enum {
- IS_KEY = 0,
- IS_VALUE,
- IS_STATE_VALUE,
- IS_SEPARATOR
-}ValueType;
-
-struct BulkReadBuffer {
- unc_key_type_t key_type;
- ValueType value_type;
- void* value;
-};
-
/**************************************************************************
* It is a singleton class which will invoke respective configuration classes.
* For further info,see the comments in .cc file
class InternalTransactionCoordinator {
public:
- InternalTransactionCoordinator();
~InternalTransactionCoordinator();
-
+ static InternalTransactionCoordinator* get_internaltransactioncoordinator();
TransactionRequest *transaction_req();
AuditRequest *audit_req();
DBConfigurationRequest *db_config_req();
return config_request_status_;
}
- /* set_audit_state
- *
- * @Description : This function sets the audit state
- *
- * @param[in]: audit status enum value
- *
- * @return : void
- *
- * */
- inline void set_audit_state(uint16_t audit_state) {
- audit_state_= audit_state;
- }
-
- /* audit_state
- *
- * @Description : This function gets the audit state
- *
- * @param[in]: none
- *
- * @return : audit status value
- *
- * */
- inline uint16_t audit_state() {
- return audit_state_;
- }
-
- /* set_import_state
- *
- * @Description : This function sets the import status
- *
- * @param[in]: import status value
- *
- * @return : void
- *
- * */
- inline void set_import_state(uint16_t import_state) {
- import_state_ = import_state;
- }
-
- /* import_state
- *
- * @Description : This function gets the import state
- *
- * @param[in]: none
- *
- * @return : import status value
- *
- * * */
- inline uint16_t import_state() {
- return import_state_;
- }
-
/* set_trans_state
*
* @Description : This function sets the transaction status
inline uint16_t trans_state() {
return trans_state_;
}
-
- void AddToBuffer(BulkReadBuffer objBuffer) {
- vect_bulk_read_buffer.push_back(objBuffer);
- }
-
- void FlushBulkReadBuffer() {
- vect_bulk_read_buffer.clear();
- }
-
- vector<BulkReadBuffer> get_readbulk_buffer() {
- return vect_bulk_read_buffer;
+ pfc_bool_t IsControllerInImport(string controller_name) {
+ if (controller_name == controller_in_import_) {
+ return PFC_TRUE;
+ }
+ return PFC_FALSE;
}
private:
uint16_t config_request_status_;
uint16_t trans_state_;
- uint16_t import_state_;
- uint16_t audit_state_;
-
+ string controller_in_import_;
+ InternalTransactionCoordinator();
+ static InternalTransactionCoordinator* internal_transaction_coordinator_;
TransactionRequest *transaction_req_;
DBConfigurationRequest *db_config_req_;
SystemStateChangeRequest *system_state_change_req_;
AuditRequest *audit_req_;
- vector<BulkReadBuffer> vect_bulk_read_buffer;
-
UpplReturnCode ProcessConfigRequest(ServerSession &session,
- physical_request_header obj_req_hdr,
+ physical_request_header &obj_req_hdr,
physical_response_header &rsh);
UpplReturnCode ProcessReadRequest(ServerSession &session,
- physical_request_header obj_req_hdr,
+ physical_request_header &obj_req_hdr,
physical_response_header &rsh);
UpplReturnCode ProcessImportRequest(ServerSession &session,
uint32_t operation);
+ UpplReturnCode ProcessIsCandidateDirty(ServerSession &session,
+ uint32_t operation);
};
#endif
namespace unc {
namespace uppl {
/* *
-* * It is a singleton class which is the base for all the request classes.
-* * For further info,see the comments in .cc file
+* * It is a base class for all the request classes.
* */
class ITCReq {
#include <pfcxx/timer.hh>
#include <pfcxx/task_queue.hh>
-#include <vector>
#include <string>
-#include <map>
#include "physical_common_def.hh"
using pfc::core::ipc::IpcEventHandler;
using pfc::core::ipc::IpcEvent;
-using std::vector;
using std::string;
-using std::map;
using pfc::core::timer_func_t;
using pfc::core::TaskQueue;
using pfc::core::Timer;
namespace uppl {
/**
* * * @Description: Notification Manager class is responsible for all
- * notification event handling procedure
+ * events and alarms notification received from south bound
* **/
class NotificationManager:public IpcEventHandler {
public:
#include "odbcm_mgr.hh"
#include "ipc_connection_manager.hh"
#include "physical_core.hh"
+#include "odbcm_connection.hh"
using unc::uppl::PhysicalCore;
using unc::uppl::ODBCManager;
return; \
}
+#define OPEN_DB_CONNECTION_TC_REQUEST(conn_type) \
+ UpplReturnCode db_ret = UPPL_RC_SUCCESS; \
+ /* Create a new odbcm connection */ \
+ OdbcmConnectionHandler db_conn(conn_type, db_ret, \
+ PhysicalLayer::get_instance()->get_odbc_manager()); \
+ if (db_ret != UPPL_RC_SUCCESS) { \
+ /* Error in opening db connection */ \
+ pfc_log_error("Error in opening DB connection"); \
+ return unc::tclib::TC_FAILURE; \
+ }
+
+#define OPEN_DB_CONNECTION(conn_type, db_ret) \
+ /* Create a new odbcm connection */ \
+ OdbcmConnectionHandler db_conn(conn_type, db_ret, \
+ PhysicalLayer::get_instance()->get_odbc_manager());
+
namespace unc {
namespace uppl {
static ReadWriteLock* get_phy_fini_event_lock_() {
return &phy_fini_event_lock_;
}
+ static ReadWriteLock* get_events_done_lock_() {
+ return &events_done_lock_;
+ }
static Mutex physical_layer_mutex_;
static Mutex physical_core_mutex_;
static Mutex ipc_client_config_hdlr_mutex_;
static ReadWriteLock phy_fini_db_lock_;
static ReadWriteLock phy_fini_phycore_lock_;
static ReadWriteLock phy_fini_event_lock_;
+ static ReadWriteLock events_done_lock_;
static uint8_t phyFiniFlag;
private:
IPCClientDriverHandler::IPCClientDriverHandler(
- unc_keytype_ctrtype_t cntr_type, int &err) {
+ unc_keytype_ctrtype_t cntr_type, UpplReturnCode &err) {
if (cntr_type == UNC_CT_PFC ||
cntr_type == UNC_CT_VNP) {
controller_type = cntr_type;
if (cntr_type == UNC_CT_VNP) {
chn_name = VNPDRIVER_IPC_CHN_NAME;
}
- err = pfc_ipcclnt_altopen(chn_name.c_str(), &connp);
- if (err != UPPL_RC_SUCCESS) {
+ int clnt_err = pfc_ipcclnt_altopen(chn_name.c_str(), &connp);
+ if (clnt_err != 0) {
pfc_log_error("Could not open driver ipc session");
err = UPPL_RC_ERR_DRIVER_COMMUNICATION_FAILURE;
}
if (cntr_type == UNC_CT_VNP) {
service = VNPDRV_SVID_PHYSICAL;
}
- cli_session = new ClientSession(connp, driver_name, service, err);
+ cli_session = new ClientSession(connp, driver_name, service, clnt_err);
if (cli_session == NULL) {
pfc_log_error("Could not get driver ipc session");
err = UPPL_RC_ERR_DRIVER_COMMUNICATION_FAILURE;
- } else if (err != 0) {
+ } else if (clnt_err != 0) {
pfc_log_error("Could not get driver ipc session, error is %d", err);
- err = ConvertDriverErrorCode(err);
+ err = ConvertDriverErrorCode(clnt_err);
}
} else {
// Default case
controller_type = UNC_CT_UNKNOWN;
driver_name = "";
chn_name = "";
+ err = UPPL_RC_ERR_BAD_REQUEST;
}
}
ClientSession* IPCClientDriverHandler::ResetAndGetSession() {
pfc_ipcid_t service = PFCDRIVER_SVID_PHYSICAL;
+ if (controller_type == UNC_CT_VNP) {
+ service = VNPDRV_SVID_PHYSICAL;
+ }
cli_session->reset(driver_name, service);
return cli_session;
}
UpplReturnCode IPCClientDriverHandler::SendReqAndGetResp(
driver_response_header &rsp) {
- pfc_ipcresp_t resp;
+ pfc_ipcresp_t resp = 0;
uint8_t err = cli_session->invoke(resp);
pfc_log_debug("DriverHandler err = %d, resp = %d",
err, resp);
/*
@brief IPCClientLogicalHandler
@file ipc_client_logical_handler.cc
- @ Desc: This header file contains the declaration of
+ @ Desc: This file contains the definition of
IPCClientConfigurationHandler class
*
*/
const unsigned int UPLL_RESPONSE_COUNT = 3;
-/**
- *@Description : This function will be called from PhysicalCore to send message
- only to logical layer. This is needed to perform semantic
- validation during KT_CONTROLLER,KT_SWITCH and KT_BOUNDARY delete.
- *@param[in] : key_type,void pointer
- *@return : UPPL_RC_SUCCESS or any associated erro code
+/**CheckInUseInLogical
+ * @Description : This function checks that the key is used in logical by
+ * sending message only to logical layer. This is also needed
+ * to perform semantic validation during KT_CONTROLLER,
+ * KT_SWITCH and KT_BOUNDARY delete operation.
+ * @param[in] : key_type - Specifies the key instances of respective key
+ * types
+ * key_str - void pointer
+ * data_type - UNC_DT_* Specifies the datatype
+ * @return : UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not
+ * be added to session
**/
UpplReturnCode IPCClientLogicalHandler::CheckInUseInLogical(
unc_key_type_t key_type,
return return_code;
}
-/**
- *@Description : This function will be called from IPCConnectionManager
- to get the IPCClientLogicalHandler object.
- *@param[in] : none
- *@return : Pointer to IPCClientLogicalHandler
- **/
+/**get_ipc_client_logical_handler
+ * @Description : This function will be called from IPCConnectionManager
+ * to get the IPCClientLogicalHandler object.
+ * @param[in] : None
+ * @return : Returns class pointer to IPCClientLogicalHandler
+ * */
IPCClientLogicalHandler* IPCClientLogicalHandler::
get_ipc_client_logical_handler() {
PhysicalLayer* physical_layer = PhysicalLayer::get_instance();
}
-/**
- *@Description : This function will be called from IPCConnectionManager
- to release the IPCClientLogicalHandler object.
- *@param[in] : none
- *@return : void
+/**release_ipc_client_logical_handler
+ * @Description : This function will be called from IPCConnectionManager
+ to release the IPCClientLogicalHandler object.
+ * @param[in] : None
+ * @return : void
**/
void IPCClientLogicalHandler::
release_ipc_client_logical_handler() {
*@param[in] : None
*@return : None
**/
-IPCConnectionManager::IPCConnectionManager() {
- ipc_server_handler_ = NULL;
- ipc_client_logical_handler_= NULL;
- notfn_timer_ = NULL;
- taskq_ = NULL;
+IPCConnectionManager::IPCConnectionManager()
+:
+ ipc_server_handler_(NULL),
+ ipc_client_logical_handler_(NULL) {
}
/**
*@return : None
**/
IPCConnectionManager::~IPCConnectionManager() {
- if (notfn_timer_ != NULL) {
- delete notfn_timer_;
- notfn_timer_ = NULL;
+ // Clear timer and taskq if present in case of timeout
+ if (!timer_obj_.empty()) {
+ map<string, Timer *> :: iterator timer_iter = timer_obj_.begin();
+ for (; timer_iter != timer_obj_.end();) {
+ Timer * timer = (*timer_iter).second;
+ if (timer != NULL) {
+ delete timer;
+ timer = NULL;
+ }
+ timer_obj_.erase(timer_iter++);
+ }
+ } else {
+ pfc_log_debug("timer_obj_ map is empty");
}
- if (taskq_ != NULL) {
- delete taskq_;
- taskq_ = NULL;
+ if (!queue_obj_.empty()) {
+ map<string, TaskQueue *> :: iterator task_iter = queue_obj_.begin();
+ for (; task_iter != queue_obj_.end(); ) {
+ TaskQueue * task = (*task_iter).second;
+ if (task != NULL) {
+ delete task;
+ task = NULL;
+ }
+ queue_obj_.erase(task_iter++);
+ }
+ } else {
+ pfc_log_debug("queue_obj_ map is empty");
}
}
-
/**
*@Description : Initializes the IPC client and server class objects
*@param[in] : None
/**
- *@Description : Initializes the data members of IPCConnectionManager
- *@param[in] : channel name ,service name
- *@return : None
+ * @Description : Initializes the data members of IPCConnectionManager
+ * @param[in] : channel name - it contains the ipc channel name provided
+ * by UPPL
+ * service name - it contains the ipc service name provided
+ * by UPPL
**/
void IPCConnectionManager::InitIpcConnectionManager(string channel_name,
string service_name) {
}
/**
- *@Description : Returns the object of NotificationManager class
- *@param[in] : None
- *@return : Pointer to NotificationManager class
+ * @Description : Returns the object of NotificationManager class
+ * @param[in] : ctr_type - enum which indicates the controller type
+ * i.e either UNKNOWN or PFC or VNP
+ * @return : Pointer to NotificationManager class
**/
NotificationManager* IPCConnectionManager::get_notification_manager(
unc_keytype_ctrtype_t ctr_type) {
}
if (ctr_type == UNC_CT_VNP) {
return NotificationManager::get_notification_manager(
- UNC_CT_VNP);
+ UNC_CT_VNP);
}
return NULL;
}
}
/**
- *@Description : Posts the event to the client
- *@param[in] : Server event
- *@return : UPPL_RC_SUCCESS
+ * @Description : Posts the event to the client
+ * @param[in] : pointer to Serverevent
+ * @return : UPPL_RC_SUCCESS
**/
uint32_t IPCConnectionManager::SendEvent(ServerEvent *evt) {
uint32_t ret = ipc_server_handler_->SendEvent(evt);
/**
- *@Description : Frees up the allocated memory
- *@param[in] : None
- *@return : UPPL_RC_SUCCESS
+ * @Description : Frees up the allocated memory
+ * @return : UPPL_RC_SUCCESS - if the allocated memory is freed
+ * successfully
**/
UpplReturnCode IPCConnectionManager::Finalize() {
if (ipc_server_handler_ != NULL)
IPCClientLogicalHandler::release_ipc_client_logical_handler();
ipc_server_handler_ = NULL;
ipc_client_logical_handler_ = NULL;
+ notfn_timer_id_.clear();
+ controller_in_audit_.clear();
return UPPL_RC_SUCCESS;
}
/**
- * * @Description: This function is used for notification manager subscription
- * to IPC event handler
- * * * @param[in]: no argument
- * * * @return : pfc_ipcresp_t
- * */
+ * @Description : This function is used for notification manager subscription
+ * to IPC event handler
+ * @return : UPPL_RC_SUCCESS - if the IPC Event subscription notification
+ * is successful else UPPL_RC_ERR_NOTIFICATION_HANDLING_FAILED
+ * is returned if event subscription notification failed
+ **/
UpplReturnCode IPCConnectionManager::SendEventSubscription() {
// Get Physical layer instance
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
}
/**
- * * @Description: This function is used for notification manager cancel
- * subscription from IPC event handler
- * * * @param[in]: no argument
- * * * @return : pfc_ipcresp_t
- * */
+ * @Description : This function is used for notification manager cancel
+ * subscription from IPC event handler
+ * @return : UPPL_RC_SUCCESS - if event subscription is cancelled
+ * successfully from IPC Event Handler
+ * else UPPL_RC_ERR_NOTIFICATION_HANDLING_FAILED
+ * will be returned
+ **/
UpplReturnCode IPCConnectionManager::CancelEventSubscription() {
// Get Physical layer instance
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
}
/**
- * * @Description: This function is used for add controller to controller_in_audit
- * vector
- * * * @param[in]: controller_name
- * * * @return : None
+ * @Description : This function is used for add controller to
+ * controller_in_audit vector
+ * @param[in] : controller_name of type string
+ * @return : void
* */
void IPCConnectionManager::addControllerToAuditList(string controller_name) {
pfc_log_debug("Executing addControllerToAuditList");
}
/**
- * * @Description: This function is used for remove controller from controller_in_audit
- * vector
- * * * @param[in]: controller_name
- * * * @return : None
- * */
+ * @Description : This function is used for remove controller from
+ * controller_in_audit vector
+ * @param[in] : controller_name of type string
+ * @return : UPPL_RC_SUCCESS - if controller is removed successfully
+ * from audit list else UPPL_RC_ERR_AUDIT_FAILURE will be
+ * returned if controller is not available in the vector
+ **/
UpplReturnCode IPCConnectionManager::removeControllerFromAuditList(
string controller_name) {
pfc_log_debug("Executing removeControllerFromAuditList");
}
/**
- * * @Description: This function is used for check whether controller name is
- * available in controller_in_audit vector
- * * * @param[in]: controller_name
- * * * @return : PFC_TRUE or PFC_FALSE
- * */
+ * @Description : This function is used for check whether controller name is
+ * available in controller_in_audit vector
+ * @param[in] : controller_name of type string
+ * @return : PFC_TRUE - if controller is in the audit list else
+ * PFC_FALSE is returned
+ **/
pfc_bool_t IPCConnectionManager::IsControllerInAudit(string controller_name) {
pfc_log_debug("Executing IsControllerInAudit");
vector<string> :: iterator iter = find(controller_in_audit_.begin(),
}
/**
- * * @Description: This function is used for start the timer to receive
- * notification after audit end
- * * * @param[in]: controller_name
- * * * @return : Success or Failure
- * */
-uint32_t IPCConnectionManager::StartNotificationTimer(string controller_name) {
+ * @Description : This function is used for start the timer to receive
+ * notification after audit end
+ * @param[in] : controller_name of type string
+ * @return : UPPL_RC_SUCCESS if timer is started successfully for audit
+ * as well as for task queue else
+ * UPPL_RC_ERR_FATAL_RESOURCE_ALLOCATION if there is error while
+ * creating task queue or timer for task queue
+ **/
+uint32_t IPCConnectionManager::StartNotificationTimer(
+ OdbcmConnectionHandler *db_conn,
+ string controller_name) {
PhysicalCore *physical_core = PhysicalLayer::get_instance()->
get_physical_core();
uint32_t time_out = physical_core->getAuditNotfnTimeOut();
uint32_t no_tasks = 1;
+ map<string, Timer *> :: iterator timer_iter =
+ timer_obj_.find(controller_name);
+ map<string, TaskQueue *> :: iterator task_iter
+ = queue_obj_.find(controller_name);
+ if ((timer_iter != timer_obj_.end()) || (task_iter != queue_obj_.end())) {
+ pfc_log_warn("StartNotificationTimer::Timer object found for controller %s",
+ controller_name.c_str());
+ UpplReturnCode cancel_ret = CancelTimer(controller_name);
+ if (cancel_ret != UPPL_RC_SUCCESS) {
+ pfc_log_error("StartNotificationTimer::Failure in cancelling "
+ "timer for controller %s", controller_name.c_str());
+ }
+ }
+ std::pair<std::map<string, Timer*>::iterator, bool> tmap_rc;
+ std::pair<std::map<string, TaskQueue*>::iterator, bool> tqmap_rc;
+
pfc_log_debug("Starting timer with timeout %d for audit", time_out);
- taskq_ = TaskQueue::create(no_tasks);
+ TaskQueue *taskq = TaskQueue::create(no_tasks);
+ if (taskq == NULL) {
+ pfc_log_fatal("Error while creating task queue");
+ return UPPL_RC_ERR_FATAL_RESOURCE_ALLOCATION;
+ }
+ tqmap_rc = queue_obj_.insert(
+ std::pair<std::string, TaskQueue*>(controller_name, taskq));
+ if (tqmap_rc.second == false) {
+ pfc_log_error("StartNotificationTimer - Error in inserting TaskQueue object");
+ }
AuditNotification func_obj;
func_obj.controller_name_ = controller_name;
timer_func_t timer_func = func_obj;
pfc_timespec_t timeout;
timeout.tv_sec = time_out;
timeout.tv_nsec = 0;
- notfn_timer_ = pfc::core::Timer::create(taskq_->getId());
- uint32_t ret = notfn_timer_->post(&timeout, timer_func, &time_out_id);
+ Timer *notfn_timer = pfc::core::Timer::create(taskq->getId());
+ if (notfn_timer == NULL) {
+ pfc_log_fatal("Error while creating timer for the task queue");
+ return UPPL_RC_ERR_FATAL_RESOURCE_ALLOCATION;
+ }
+ tmap_rc = timer_obj_.insert(
+ std::pair<string, Timer*>(controller_name, notfn_timer));
+ if (tmap_rc.second == false) {
+ pfc_log_error("StartNotificationTimer - Error in inserting Timer object");
+ }
+ uint32_t ret = notfn_timer->post(&timeout, timer_func, &time_out_id);
if (ret != 0) {
- pfc_log_error("Failure occurred in starting notification timer");
+ pfc_log_error("StartNotificationTimer - Failure occurred in starting timer");
} else {
pfc_log_debug("Setting time_out_id %d, taskq id %d controller_name %s",
- time_out_id, taskq_->getId(), controller_name.c_str());
+ time_out_id, taskq->getId(), controller_name.c_str());
setTimeOutId(controller_name, time_out_id);
}
return ret;
}
+
+/**
+ * @Description : This function is used to cancel the timer and
+ * delete associated objects
+ * @param[in] : controller_name of type string
+ * @return : UPPL_RC_SUCCESS - if timer object and task object
+ * are deleted successfully else UPPL_RC_ERR_AUDIT_FAILURE
+ * will be returned
+ **/
+UpplReturnCode IPCConnectionManager::CancelTimer(string controller_name) {
+ pfc_log_debug("Executing CancelTimer()");
+ UpplReturnCode ret = UPPL_RC_SUCCESS;
+ uint32_t time_out_id = getTimeOutId(controller_name);
+ map<string, Timer *> :: iterator timer_iter =
+ timer_obj_.find(controller_name);
+ if (timer_iter != timer_obj_.end()) {
+ Timer * timer = (*timer_iter).second;
+ if (timer != NULL) {
+ timer->cancel(time_out_id);
+ delete timer;
+ timer = NULL;
+ pfc_log_debug("Deleted Timer object successfully");
+ }
+ timer_obj_.erase(timer_iter);
+ } else {
+ pfc_log_debug("Timer object not found ");
+ }
+ map<string, TaskQueue *> :: iterator task_iter
+ = queue_obj_.find(controller_name);
+ if (task_iter != queue_obj_.end()) {
+ TaskQueue * task = (*task_iter).second;
+ if (task != NULL) {
+ delete task;
+ task = NULL;
+ pfc_log_debug("Deleted Task object successfully");
+ }
+ queue_obj_.erase(task_iter);
+ } else {
+ pfc_log_debug("Task object not found ");
+ }
+ return ret;
+}
*/
/*
- *@brief IPCServerHandler header
- *@file ipc_server_handler.hh
- *@ Desc: This header file contains the declaration of IPCServerHandler class
+ *@brief IPC Server Handler
+ *@file ipc_server_handler.cc
+ *@ Desc: This file contains the definition of IPCServerHandler class
**
**/
/**
* @Description : This function will be called by PhysicalCore when IPC client
- * sends a message to is received for this server.This function
- * validates whether the provided service id is valid
- * @param[in] : ServerSession object, service id
- * @return : PFC_TRUE or PFC_FALSE
+ * sends a message to be received by UPPL's IPC server.
+ * This function validates whether the provided service id
+ * is valid. It sends the request to Internal Transaction
+ * Coordinator for further processing
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * service_id - service id to classify the type of request.
+ * UPPL expects 1, 2 or 3.
+ * @return : Response code back to the caller.
+ * The system/generic level errors or common errors are generally
+ * returned in this function otherwise SUCCESS(0) will be returned.
+ * When an error code is being returned in this function, the caller
+ * cannot expect more specific error in response.
+ * When SUCCESS(0) is returned, the caller should further check
+ * the operation result_code in the response for more specific error.
**/
pfc_ipcresp_t IPCServerHandler::IpcService(ServerSession &session,
/**
- * @Description :This function is used to send events via IPC post() command
+ * @Description :This function is used to send events via IPC post() command.
* This function will be called from ITC to send events to UPLL
* or VTN
* @param[in] : ServerEvent object
- * @return : Success code or any associated error code
+ * @return : 0 is returned if event is posted successfully
+ * otherwise 'non 0' is returned to denote error
**/
uint32_t IPCServerHandler::SendEvent(ServerEvent *serv_event) {
}
/**
- * @Description :This function is called by IPCConnectionMAnager to
+ * @Description :This function is called by IPCConnectionManager to
* get the IPCServerHandler object
* @param[in] :none
* @return :Pointer to IPCServerHandler
return ipc_server_handler_;
}
+/**
+ * @Description :This function is used to delete the IPCServerHandler object
+ * @param[in] :none
+ * @return :none
+ * **/
void IPCServerHandler::release_ipc_server_handler() {
PhysicalLayer* physical_layer = PhysicalLayer::get_instance();
physical_layer->ipc_server_hdlr_mutex_.lock();
using unc::uppl::ODBCMUtils;
-/*** KT_ROOT *****/
-/** get_string
- * * @Description : This function returns the root key from
- * the key structure
- * * * @param[in] : key structure
- * * * @return : root key
- * */
+/** KT_ROOT
+ * @Description : This function is used to return the root key from the
+ * key structure
+ * @param[in] : k - structure variable of type key_root_t
+ * @return : key structure elements of kt_root
+ **/
string IpctUtil::get_string(const key_root_t &k) {
stringstream ss;
ss << "KT_ROOT:[KEY: "
}
/*** KT_CONTROLLER *****/
-/** get_string
- * * @Description : This function returns the controller name from
- * the key structure
- * * * @param[in] : key structure
- * * * @return : controller name
- * */
+/**
+ * @Description : This function returns the controller name from
+ * the key structure
+ * @param[in] : k - structure variable of type key_ctr_t
+ * @return : key structure elements of kt_controller
+ **/
string IpctUtil::get_string(const key_ctr_t &k) {
stringstream ss;
ss << "KT_CONTROLLER:[KEY: "
return ss.str();
}
-/** get_string
- * * @Description : This function returns the values from the value structure
- * * * @param[in] : value structure
- * * * @return : values of each attribute in value structure
- * */
+/**
+ * @Description : This function returns the values from the value structure
+ * of kt_controller
+ * @param[in] : v - structure variable of type val_ctr_t
+ * @return : value structure elements of kt_controller
+ **/
string IpctUtil::get_string(const val_ctr_t &v) {
stringstream ss;
stringstream valid;
}
ss << "KT_CONTROLLER:[VAL: "
<< "type:" << PhyUtil::uint8tostr(v.type)
- << ", description:" << v.description
<< ", version:" << v.version
+ << ", description:" << v.description
<< ", ip_address:" << ODBCMUtils::get_ip_string(v.ip_address.s_addr)
<< ", user:" << v.user
<< ", password:" << v.password
return ss.str();
}
-/** get_string
- * * @Description : This function returns the values from the st value structure
- * * * @param[in] : st value structure
- * * * @return : values of each attribute in value structure
- * */
+/**
+ * @Description : This function returns the values from the kt_controller
+ * value structure
+ * @param[in] : val_st - structure variable of type val_ctr_st_t
+ * @return : value structure elements of val_ctr_st_t structure of
+ * kt_controller
+ **/
string IpctUtil::get_string(const val_ctr_st_t &val_st) {
stringstream ss;
val_ctr_t v = val_st.controller;
}
/***** KT_CTR_DOMAIN *****/
-/** get_string
- * * @Description : This function returns the domain name from
- * the key structure
- * * * @param[in] : key structure
- * * * @return : domain name
- * */
+/**
+ * @Description : This function returns the domain name from
+ * the key structure
+ * @param[in] : k - structure variable of type key_ctr_domain
+ * @return : key structure elements of key_ctr_domain of kt_domain are
+ * returned
+ **/
string IpctUtil::get_string(const key_ctr_domain &k) {
stringstream ss;
ss << "KT_CTR_DOMAIN:[KEY: "
return ss.str();
}
-/** get_string
- * * @Description : This function returns the values from the value structure
- * * * @param[in] : value structure
- * * * @return : values of each attribute in value structure
- * */
+/**
+ * @Description : This function returns the values from the value structure of
+ * type kt_ctr_domain
+ * @param[in] : v - structure variable of type val_ctr_domain
+ * @return : value structure elements of controller domain are returned
+ **/
string IpctUtil::get_string(const val_ctr_domain &v) {
stringstream ss;
stringstream valid;
return ss.str();
}
-/** get_string
- * * @Description : This function returns the values from the st value structure
- * * * @param[in] : st value structure
- * * * @return : values of each attribute in value structure
- * */
+/**
+ * @Description : This function returns the values from the st value structure
+ * @param[in] : val_st - structure variable of type val_ctr_domain_st
+ * @return : value structure elements of val_ctr_domain_st are returned
+ **/
string IpctUtil::get_string(const val_ctr_domain_st &val_st) {
stringstream ss;
val_ctr_domain v = val_st.domain;
}
/***** KT_LOGICALPORT ******/
-/** get_string
- * * @Description : This function returns the logicalport name from
- * the key structure
- * * * @param[in] : key structure
- * * * @return : logicalport name
- * */
+/**
+ * @Description : This function returns the logicalport name from
+ * the key structure
+ * @param[in] : k - structure variable of type key_logical_port_t
+ * @return : structure elements of key_logicalport_t are returned
+ **/
string IpctUtil::get_string(const key_logical_port_t &k) {
stringstream ss;
ss << "KT_LOGICAL_PORT[KEY: "
return ss.str();
}
-/** get_string
- * * @Description : This function returns the values from the value structure
- * * * @param[in] : value structure
- * * * @return : values of each attribute in value structure
- * */
+/**
+ * @Description : This function returns the values from the value structure
+ * @param[in] : v - structure variable of type val_logical_port_st_t
+ * @return : value structure elements of val_logical_port_st_t are returned
+ **/
string IpctUtil::get_string(const val_logical_port_st_t &v) {
stringstream ss;
stringstream st_valid;
return ss.str();
}
-/** get_string
- * * @Description : This function returns the values from the value structure
- * * * @param[in] : value structure
- * * * @return : values of each attribute in value structure
- * */
+/**
+ * @Description : This function returns the values from the value structure
+ * @param[in] : v - structure variable of type val_logical_port_t
+ * @return : value structure elements of val_logical_port_t are returned
+ **/
string IpctUtil::get_string(const val_logical_port_t &v) {
stringstream ss;
stringstream valid;
}
/***** KT_LOGICAL_MEMBER_PORT *****/
-/** get_string
- * * @Description :
- * * * @param[in] : key_logical_member_port
- * * * @return : string
- * * */
+/**
+ * @Description : This function returns the values from the value structure
+ * @param[in] : k - structure element of type key_logical_member_port_t
+ * @return : structure elements of key_logical_member_port_t are returned
+ **/
string IpctUtil::get_string(const key_logical_member_port_t &k) {
stringstream ss;
ss << "KT_LOGICAL_MEMBER_PORT[KEY: "
}
/****** KT_SWITCH ******/
-/** get_string
- * * @Description : this functions returns the switch_id and controller name
- * from the key structure
- * * @param[in] : key_struct of kt switch
- * * @return : string
- * */
+/**
+ * @Description : this functions returns the switch_id and controller name
+ * from the key structure
+ * @param[in] : k - structure variable of type key_switch_t
+ * @return : attributes in structure key_switch_t are returned
+ **/
string IpctUtil::get_string(const key_switch_t &k) {
stringstream ss;
ss << "KT_SWITCH:[KEY: "
return ss.str();
}
-/** get_string
- * * @Description : this function returns the values contained in the value
- * structure
- * * @param[in] : val_switch_t - value structure of kt switch
- * * @return : string
- * */
+/**
+ * @Description : this function returns the values contained in the value
+ * structure
+ * @param[in] : v - structure variable of type val_switch_t
+ * @return : attributes in structure val_switch_t are returned
+ **/
string IpctUtil::get_string(const val_switch_t &v) {
stringstream ss;
stringstream valid;
valid << PhyUtil::uint8tostr(v.valid[i]);
}
char ip_value[INET6_ADDRSTRLEN];
+ memset(&ip_value, '\0', INET6_ADDRSTRLEN);
inet_ntop(AF_INET6, &v.ipv6_address.s6_addr, ip_value, INET6_ADDRSTRLEN);
ss << "KT_SWITCH:[VAL: "
<< "description:" << v.description
}
/** get_string
- * * @Description : this function returns the values contained in the val_st
- * structure
- * * @param[in] : val_switch_st - val_st structure of kt switch
- * * @return : string
- * */
+ * @Description : this function returns the values contained in the val_st
+ * structure
+ * @param[in] : val_st - structure variable of type val_switch_st
+ * @return : attributes in value structure of switch are returned
+ **/
string IpctUtil::get_string(const val_switch_st &val_st) {
stringstream ss;
val_switch_t v = val_st.switch_val;
/* A string of contiguous zero fields in the
preferred form can be shown as "::" */
char ip_value[INET6_ADDRSTRLEN];
+ memset(&ip_value, '\0', INET6_ADDRSTRLEN);
inet_ntop(AF_INET6, &v.ipv6_address.s6_addr, ip_value, INET6_ADDRSTRLEN);
ss << "KT_SWITCH:[VAL: "
<< "description:" << v.description
}
/*** KT_PORT **********/
-/** get_string
- * * @Description : This function returns the key names from
- * the key structure
- * * * @param[in] : key structure
- * * * @return : controller name
- * */
+/**
+ * @Description : This function returns the key names from
+ * the key structure
+ * @param[in] : k - structure variable of type key_port_t
+ * @return : attributes in key structure of port are returned
+ **/
string IpctUtil::get_string(const key_port_t &k) {
stringstream ss;
ss << "KT_PORT:[KEY: "
return ss.str();
}
-/** get_string
- * * @Description : This function returns the values from the value structure
- * * * @param[in] : value structure
- * * * @return : values of each attribute in value structure
- * */
+/**
+ * @Description : This function returns the values from the value structure
+ * @param[in] : v - structure variable of type val_port_st_t
+ * @return : attributes in value structure of val_port_st_t are returned
+ **/
string IpctUtil::get_string(const val_port_st_t &v) {
stringstream ss;
stringstream valid;
for (unsigned int i = 0; i < 8; ++i) {
st_valid << PhyUtil::uint8tostr(v.valid[i]);
}
+ char macaddr[18];
+ memset(&macaddr, '\0', 18);
+ snprintf(macaddr, sizeof(macaddr), "%02x%02x.%02x%02x.%02x%02x",
+ v.mac_address[0], v.mac_address[1], v.mac_address[2],
+ v.mac_address[3], v.mac_address[4], v.mac_address[5]);
+
ss << "KT_PORT:[VAL: "
<< "port_number:" << v.port.port_number
- << ", description:" << v.port.description
- << ", admin_status:" << PhyUtil::uint8tostr(v.port.admin_status)
+ << ", description:" << v.port.description
+ << ", admin_status:" << PhyUtil::uint8tostr(v.port.admin_status)
<< ", trunk_allowed_vlan:" << PhyUtil::uint8tostr
(v.port.trunk_allowed_vlan)
+ << ", valid:" << valid.str()
<< ", oper_status:" << PhyUtil::uint8tostr(v.oper_status)
- << ", mac_address:" << v.mac_address
+ << ", mac_address:" << macaddr
<< ", direction:" << PhyUtil::uint8tostr(v.direction)
<< ", duplex:" << PhyUtil::uint8tostr(v.duplex)
<< ", speed:" << PhyUtil::uint64tostr(v.speed)
<< ", alarms_status:" << PhyUtil::uint64tostr(v.alarms_status)
<< ", logical_port_id:" << v.logical_port_id
- << ", valid:" << valid.str()
<< ", st_valid:" << st_valid.str()
<< "]"
<< endl;
return ss.str();
}
-/** get_string
- * * @Description : This function returns the values from the value structure
- * * * @param[in] : value structure
- * * * @return : values of each attribute in value structure
- * */
+/**
+ * @Description : This function returns the values from the value structure
+ * @param[in] : v - structure variable of type val_port_t
+ * @return : attributes in value structure of val_port_t are returned
+ **/
string IpctUtil::get_string(const val_port_t &v) {
stringstream ss;
stringstream valid;
}
ss << "KT_PORT:[VAL: "
<< "port_number:" << v.port_number
- << ", description:" << v.description
- << ", admin_status:" << PhyUtil::uint8tostr(v.admin_status)
+ << ", description:" << v.description
+ << ", admin_status:" << PhyUtil::uint8tostr(v.admin_status)
<< ", trunk_allowed_vlan:" << PhyUtil::uint8tostr
(v.trunk_allowed_vlan)
<< ", valid:" << valid.str()
return ss.str();
}
-/** get_string
- * * @Description : This function returns the values from the value structure
- * * * @param[in] : value structure
- * * * @return : values of each attribute in value structure
- * */
+/**
+ * @Description : This function returns the values from the value structure
+ * @param[in] : v - structure variable of type val_port_st_neighbor
+ * @return : attributes in value structure of val_port_st_neighbor are
+ * returned
+ *
+ **/
string IpctUtil::get_string(const val_port_st_neighbor &v) {
stringstream ss;
stringstream valid;
<< ", admin_status:" << PhyUtil::uint8tostr(v.port.admin_status)
<< ", trunk_allowed_vlan:" << PhyUtil::uint8tostr
(v.port.trunk_allowed_vlan)
+ << ", valid:" << valid.str()
<< ", connected_switch_id:" << v.connected_switch_id
<< ", connected_port_id:" << v.connected_port_id
- << ", valid:" << valid.str()
<< ", neigbour_valid:" << neigh_valid.str()
<< "]"
<< endl;
}
/***** KT_LINK ************/
-/** get_string
- * * @Description : This function returns the link name from
- * the key structure
- * * * @param[in] : key structure
- * * * @return : controller name
- * */
+/**
+ * @Description : This function returns the link name from
+ * the key structure
+ * @param[in] : k - structure variable of type key_link_t
+ * @return : attributes in key structure of link are returned
+ **/
string IpctUtil::get_string(const key_link_t &k) {
stringstream ss;
ss << "KT_LINK:[KEY: "
<< "]";
return ss.str();
}
-/** get_string
- * * @Description : This function returns the values from the value structure
- * * * @param[in] : value structure
- * * * @return : values of each attribute in value structure
- * */
+/**
+ * @Description : This function returns the values from the value structure
+ * @param[in] : v - structure variable of type val_link_t
+ * @return : attributes in value structure of val_link_t are returned
+ **/
string IpctUtil::get_string(const val_link_t &v) {
stringstream ss;
ss << "KT_LINK:[VAL: "
<< endl;
return ss.str();
}
-/** get_string
- * * @Description : This function returns the values from the value structure
- * * * @param[in] : value structure
- * * * @return : values of each attribute in value structure
- * */
+/**
+ * @Description : This function returns the values from the value structure
+ * @param[in] : v - structure variable of type val_link_st_t
+ * @return : attributes in value structure of val_link_st_t are returned
+ **/
string IpctUtil::get_string(const val_link_st_t &v) {
stringstream ss;
stringstream st_valid;
}
/***** KT_BOUNDARY *****/
-/** get_string
- * * @Description : This function returns the boundary_id from the key structure
- * * * @param[in] : key structure
- * * * @return : boundary_id
- * */
+/**
+ * @Description : This function returns the boundary_id from the key structure
+ * @param[in] : key_obj - structure variable of type key_boundary_t
+ * @return : attributes in key structure of key_boundary_t are returned
+ **/
string IpctUtil::get_string(const key_boundary_t &key_obj) {
stringstream ss;
ss << "KT_BOUNDARY:[KEY: "
return ss.str();
}
-/** get_string
- * * @Description : This function returns the values from the value structure
- * * * @param[in] : value structure
- * * * @return : values of each attribute in value structure
- * */
+/**
+ * @Description : This function returns the values from the value structure
+ * @param[in] : val_obj - structure variable of type val_boundary_t
+ * @return : attributes in value structure of val_boundary_t are returned
+ **/
string IpctUtil::get_string(const val_boundary_t &val_obj) {
stringstream ss;
stringstream valid;
return ss.str();
}
-/** get_string
- * * @Description : This function returns the values from the value structure
- * * * @param[in] : value structure
- * * * @return : values of each attribute in value structure
- * */
+/**
+ * @Description : This function returns the values from the value structure
+ * @param[in] : val_obj - structure variable of type val_boundary_st_t
+ * @return : attributes in value structure of val_boundary_st_t are
+ * returned
+ **/
string IpctUtil::get_string(const val_boundary_st_t &val_obj) {
stringstream ss;
stringstream valid;
<< ", controller_name2:" << val_obj.boundary.controller_name2
<< ", domain_name2:" << val_obj.boundary.domain_name2
<< ", logical_port_id2:" << val_obj.boundary.logical_port_id2
- << ", oper_status: " << PhyUtil::uint8tostr(val_obj.oper_status)
- << ", valid:" << valid.str()
- << ", valid_st:" << valid_st.str()
- << ", cs_row_status:" <<
- PhyUtil::uint8tostr(val_obj.boundary.cs_row_status)
+ << ", valid:" << valid.str()
+ << ", cs_row_status:" <<
+ PhyUtil::uint8tostr(val_obj.boundary.cs_row_status)
<< ", cs_attr:" << cs_attr.str()
+ << ", oper_status: " << PhyUtil::uint8tostr(val_obj.oper_status)
+ << ", valid_st:" << valid_st.str()
<< "]"
<< endl;
return ss.str();
}
/******** PATH_FAULT_ALARM ****/
-/** get_string
- * * @Description : This function returns the values from the value structure
- * * * @param[in] : value structure
- * * * @return : values of each attribute in value structure
- * */
+/**
+ * @Description : This function returns the values from the value structure of
+ * alarm type PATH_FAULT_ALARM
+ * @param[in] : v - structure variable of type val_path_fault_alarm_t
+ * @return : attributes in value structure of val_path_fault_alarm_t are
+ * returned
+ **/
string IpctUtil::get_string(const val_path_fault_alarm_t &v) {
stringstream ss;
stringstream valid;
}
/********* PHY_PATH_FAULT_ALARM ********/
-/** get_string
- * * @Description : This function returns the values from the value structure
- * * * @param[in] : value structure
- * * * @return : values of each attribute in value structure
- * */
+/**
+ * @Description : This function returns the values from the value structure of
+ * type PHY_PATH_FAULT_ALARM
+ * @param[in] : v - structure variable of type val_phys_path_fault_alarm_t
+ * @return : attributes in value structure of val_phys_path_fault_alarm_t
+ * are returned
+ **/
string IpctUtil::get_string(const val_phys_path_fault_alarm_t &v) {
stringstream ss;
stringstream valid;
}
/********* FLOW_ENTRY_FULL_ALARM ********/
-/** get_string
- * * @Description : This function returns the values from the value structure
- * * * @param[in] : value structure
- * * * @return : values of each attribute in value structure
- * */
+/**
+ * @Description : This function returns the values from the value structure of
+ * type FLOW_ENTRY_FULL_ALARM
+ * @param[in] : v - structure variable of type val_flow_entry_full_alarm_t
+ * @return : attributes in the value structure of FLOW_ENTRY_FULL_ALARM
+ * are returned
+ **/
string IpctUtil::get_string(const val_flow_entry_full_alarm_t &v) {
stringstream ss;
ss << "FLOW_ENTRY_FULL_ALARM:[VAL: "
}
/********* OFS_LACK_FEATURES_ALARM ********/
-/** get_string
- * * @Description : This function returns the values from the value structure
- * * * @param[in] : value structure
- * * * @return : values of each attribute in value structure
- * */
+/**
+ * @Description : This function returns the values from the value structure of
+ * type OFS_LACK_FEATURES_ALARM
+ * @param[in] : v - structure variable of type val_ofs_lack_features_alarm_t
+ * @return : attributes in the value structure of
+ * val_ofs_lack_features_alarm_t are returned
+ **/
string IpctUtil::get_string(const val_ofs_lack_features_alarm_t &v) {
stringstream ss;
ss << "OFS_LACK_FEATURES_ALARM:[VAL: "
}
/********* VAL_PORT_ALARM ********/
-/** get_string
- * * @Description : This function returns the values from the value structure
- * * * @param[in] : value structure
- * * * @return : values of each attribute in value structure
- * */
+/**
+ * @Description : This function returns the values from the value structure of
+ * type VAL_PORT_ALARM
+ * @param[in] : v - structure variable of type val_port_alarm_t
+ * @return : attributes in the value structure of val_port_alarm_t are
+ * returned
+ **/
string IpctUtil::get_string(const val_port_alarm_t &v) {
stringstream ss;
stringstream valid;
namespace unc {
namespace uppl {
-/**
- * * @Description : Constructor of Audit Request Class
- * * * @param[in] : No Parameters
- * * * @return : No Return Type
+/**AuditRequest
+ * @Description : This function initializes the member data
+ * @param[in] : None
+ * @return : None
* */
AuditRequest::AuditRequest() {
}
-/**
- * * @Description : Destructor of Audit Request Class
- * * @param[in] : No Parameters
- * * @return : No Return Type
+/**~AuditRequest
+ * @Description : This function releases the memory allocated to
+ * pointer member data
+ * @param[in] : None
+ * @return : None
* */
AuditRequest::~AuditRequest() {
}
-/**
- * * @Description : This function is used to perform the Start of Audit
- * * @param[in] : driver_id,controller_id
- * * @return : UpplReturnCode
+/**StartAudit
+ * @Description : This function performs the required pre condition validations
+ * such as checking of the existence of the controller and its
+ * operation status and set its value again.
+ * @param[in] : driver_id - Specifies one of the following controller type,
+ * PFC,VNP,Bypass
+ * controller_id - controller name to which the audit to start
+ * @return : UPPL_RC_SUCCESS if the Audit is success for the controller
+ * or UPPL_RC_ERR_*
* */
-UpplReturnCode AuditRequest::StartAudit(unc_keytype_ctrtype_t driver_id,
+UpplReturnCode AuditRequest::StartAudit(OdbcmConnectionHandler *db_conn,
+ unc_keytype_ctrtype_t driver_id,
string controller_id) {
- pfc_log_info("Inside StartAudit");
- PhysicalCore *physical_core = PhysicalCore::get_physical_core();
+ pfc_log_info("Processing StartAudit");
Kt_Controller KtObj;
uint8_t oper_status = 0;
key_ctr_t obj_key_ctr;
controller_id.length()+1);
/* Checks controller existence and its oper status */
- pfc_log_info("Get the oper Status");
+ pfc_log_debug("Get controller oper Status");
val_ctr_st_t obj_val_ctr_st;
UpplReturnCode read_status =
- KtObj.GetOperStatus(UNC_DT_RUNNING,
+ KtObj.GetOperStatus(db_conn, UNC_DT_RUNNING,
reinterpret_cast<void *>(&obj_key_ctr), oper_status);
if (read_status == UPPL_RC_SUCCESS) {
// Checking the audit precondition
obj_val_ctr_st.valid[kIdxOperStatus] = 1;
FN_START_TIME("Audit::HandleOperStatus", "Controller");
UpplReturnCode handle_oper_status = KtObj.HandleOperStatus(
- UNC_DT_RUNNING, reinterpret_cast<void *>(&obj_key_ctr),
+ db_conn, UNC_DT_RUNNING, reinterpret_cast<void *>(&obj_key_ctr),
reinterpret_cast<void *>(&obj_val_ctr_st),
true);
pfc_log_debug("Handle Oper Status return: %d", handle_oper_status);
}
} else {
pfc_log_error("Unable to get controller oper status");
- /* Sending the Audit failure alarm to Node Manager */
- physical_core->SendAuditFailureAlarm(controller_id);
return UPPL_RC_ERR_AUDIT_FAILURE;
}
return UPPL_RC_SUCCESS;
}
-/**
- * * @Description : This function is used to perform the Start of Audit Transaction
- * * * @param[in] : session_id,controller type and controller_id
- * * * @return : UpplReturnCode
+/**StartAuditTransaction
+ * @Description : This function is invoked when TC sends AuditTransactionStart
+ * to Physical Core
+ * @param[in] : session_id - ipc session id used for TC validation
+ * driver_id - Specifies one of the following controller type-
+ * PFC,VNP,Bypass
+ * controller_id - controller name in which the audit to start
+ * @return : UPPL_RC_SUCCESS if the AuditTransaction is success for the
+ * controller or UPPL_RC_ERR_* for audit transaction failure
* */
UpplReturnCode AuditRequest::StartAuditTransaction(
uint32_t session_id,
unc_keytype_ctrtype_t driver_id,
string controller_id) {
- pfc_log_info("Inside StartAuditTransaction");
+ pfc_log_info("Returning success for StartAuditTransaction");
return UPPL_RC_SUCCESS;
}
-/**
- * * @Description : This function is used to handle the Audit Vote Request
- * * * @param[in] : session_id,driver_id,controller_id,driver_info map
- * * * @return : UpplReturnCode
+
+/**HandleAuditVoteRequest
+ * @Description : This function is invoked when TC sends AuditVoteRequest to
+ * Physical Core and here,get the controller details for the
+ * controller where the audit occurs
+ * @param[in] : session_id - ipc session id used for TC validation
+ * driver_id - Specifies one of the following controller type-
+ * PFC,VNP,Bypass
+ * controller_id - controller name in which the audit occurs
+ * @param[out] : driver_info - contains the controller list
+ * @return : UPPL_RC_SUCCESS if the AuditVoteRequest is success or
+ * UPPL_RC_ERR_* if AuditVoteRequest is failed.
* */
UpplReturnCode AuditRequest::HandleAuditVoteRequest(
+ OdbcmConnectionHandler *db_conn,
uint32_t session_id,
uint32_t driver_id,
string controller_id,
TcDriverInfoMap &driver_info) {
- pfc_log_info("Inside HandleAuditVoteRequest");
+ pfc_log_info("Processing HandleAuditVoteRequest");
Kt_Controller KtObj;
std::vector<std::string> controllers;
controllers.push_back(controller_id);
vector<void *> vect_ctr_key, vect_ctr_val;
vect_ctr_key.push_back(reinterpret_cast<void *>(&obj_key_ctr));
UpplReturnCode read_status = KtObj.ReadInternal(
- vect_ctr_key, vect_ctr_val,
+ db_conn, vect_ctr_key, vect_ctr_val,
(unc_keytype_datatype_t)UNC_DT_RUNNING,
UNC_OP_READ);
- pfc_log_info("read_status is %d", read_status);
if (read_status != UPPL_RC_SUCCESS) {
pfc_log_error("Could not get details for controller %s",
controller_id.c_str());
- } else {
- pfc_log_info("Read operation is success");
- val_ctr_st_t *obj_val_ctr =
- (reinterpret_cast <val_ctr_st_t*>(vect_ctr_val[0]));
- if (obj_val_ctr != NULL) {
- unc_keytype_ctrtype_t controller_type =
- (unc_keytype_ctrtype_t)
- (PhyUtil::uint8touint(obj_val_ctr->controller.type));
- pfc_log_info("Type is %d", controller_type);
- if (controller_type != UNC_CT_PFC &&
- controller_type != UNC_CT_VNP) {
- // return UPPL_RC_ERR_AUDIT_FAILURE;
- pfc_log_debug("Unsupported controller type - ignoring ");
- } else {
- /* PHYSICAL SHOULD NOT SEND UPDATED CONTROLLER LIST
+ return UPPL_RC_ERR_AUDIT_FAILURE;
+ }
+ pfc_log_debug("Read operation is success");
+ val_ctr_st_t *obj_val_ctr =
+ (reinterpret_cast <val_ctr_st_t*>(vect_ctr_val[0]));
+ if (obj_val_ctr != NULL) {
+ unc_keytype_ctrtype_t controller_type =
+ (unc_keytype_ctrtype_t)
+ (PhyUtil::uint8touint(obj_val_ctr->controller.type));
+ pfc_log_debug("Controller Type is %d", controller_type);
+ if (controller_type != UNC_CT_PFC &&
+ controller_type != UNC_CT_VNP) {
+ pfc_log_debug("Unsupported controller type - ignoring ");
+ } else {
+ /* PHYSICAL SHOULD NOT SEND UPDATED CONTROLLER LIST
driver_info.insert(std::pair<unc_keytype_ctrtype_t,
std::vector<std::string > >
(controller_type, controllers));
- */
- }
- // Release memory allocated for key struct
- key_ctr_t *ctr_key = reinterpret_cast<key_ctr_t*>(vect_ctr_key[0]);
- if (ctr_key != NULL) {
- delete ctr_key;
- ctr_key = NULL;
- }
- // delete the val memory
- delete obj_val_ctr;
- obj_val_ctr = NULL;
+ */
+ }
+ // Release memory allocated for key struct
+ key_ctr_t *ctr_key = reinterpret_cast<key_ctr_t*>(vect_ctr_key[0]);
+ if (ctr_key != NULL) {
+ delete ctr_key;
+ ctr_key = NULL;
}
+ // delete the val memory
+ delete obj_val_ctr;
+ obj_val_ctr = NULL;
}
return UPPL_RC_SUCCESS;
}
-/* *
- * * @Description : This function is used to handle the Audit Global Commit
- * * * @param[in] : session_id,driver_id,controller_id,driver_info map,audit result
- * * * @return : UpplReturnCode
+/**HandleAuditGlobalCommit
+ * @Description : This function is invoked when TC sends AuditGlobalCommit
+ * to Physical Core
+ * @param[in] : session_id - ipc session id used for TC validation
+ * driver_id - Specifies one of the following controller type-
+ * PFC,VNP,Bypass
+ * controller_id - controller name in which the audit occurs
+ * driver_info - contains the controller list
+ * @param[out] : audit result - specifies the TC audit result
+ * @return : UPPL_RC_SUCCESS if the AuditGlobalCommit is success for the
+ * controller or UPPL_RC_ERR_* for the failure
* */
UpplReturnCode AuditRequest::HandleAuditGlobalCommit(
string controller_id,
TcDriverInfoMap& driver_info,
TcAuditResult& audit_result) {
- pfc_log_info("Inside HandleAuditGlobalCommit");
+ pfc_log_info("Returing Success for HandleAuditGlobalCommit");
audit_result = unc::tclib::TC_AUDIT_SUCCESS;
return UPPL_RC_SUCCESS;
}
-/**
- * * @Description : This function is used to abort the Audit Process
- * * * @param[in] : session id, controller type and controller name
- * * * @return : UpplReturnCode
+/**HandleAuditAbort
+ * @Description : This function is invoked when TC sends AuditGlobalAbort
+ * to Physical Core
+ * @param[in] : session_id - ipc session id used for TC validation
+ * driver_id - Specifies one of the following controller type-
+ * PFC,VNP,Bypass
+ * controller_id - controller name in which the audit occurs
+ * operation_phase -
+ * @return : UPPL_RC_SUCCESS if the AuditGlobalAbort is success for the
+ * controller or UPPL_RC_ERR_* for the failure
* */
UpplReturnCode AuditRequest::HandleAuditAbort(
unc_keytype_ctrtype_t driver_id,
string controller_id,
TcAuditOpAbortPhase operation_phase) {
- pfc_log_info("Inside HandleAuditAbort");
+ pfc_log_info("Returing success for HandleAuditAbort");
return UPPL_RC_SUCCESS;
}
-/**
- * * @Description : This function is used to end the Audit Transaction
- * * * @param[in] : session_id ,controller type, controller_id
- * * * @return : UpplReturnCode
+/**EndAuditTransaction
+ * @Description : This function is used to end the Audit Transaction
+ * @param[in] : session_id - ipc session id used for TC validation
+ * driver_id - Specifies one of the following controller type-
+ * PFC,VNP,Bypass
+ * controller_id - controller name in which the audit occurs
+ * @return : UPPL_RC_SUCCESS if the EndAuditTransaction is success for the
+ * controller or UPPL_RC_ERR_* for the failure
* */
UpplReturnCode AuditRequest::EndAuditTransaction(
uint32_t session_id,
unc_keytype_ctrtype_t& drivertype,
string controller_id) {
- pfc_log_info("Inside EndAuditTransaction");
+ pfc_log_info("Returning success for EndAuditTransaction");
return UPPL_RC_SUCCESS;
}
-/**
- * * @Description : This function is used to end the Audit
- * * * @param[in] : controller type, controller_id and audit result
- * * * @return : UpplReturnCode
+/**EndAudit
+ * @Description : This function is used to end the Audit and adds the
+ * controller to audit list
+ * @param[in] : driver_id - Specifies one of the following controller type-
+ * PFC,VNP,Bypass
+ * controller_id - controller name in which the audit occurs
+ * audit result - specifies the TC audit result
+ * @return : UPPL_RC_SUCCESS if the End Audit is success for the controller
+ * or returns UPPL_RC_ERR_ if the Audit is failed
* */
-UpplReturnCode AuditRequest::EndAudit(unc_keytype_ctrtype_t driver_id,
+UpplReturnCode AuditRequest::EndAudit(OdbcmConnectionHandler *db_conn,
+ unc_keytype_ctrtype_t driver_id,
string controller_id,
TcAuditResult audit_result) {
- pfc_log_info("Inside HandleEndAudit");
+ pfc_log_info("Processing HandleEndAudit");
uint8_t oper_status = 0;
- PhysicalCore *physical_core = PhysicalLayer::get_instance()->
- get_physical_core();
Kt_Controller kt_controller;
key_ctr_t key_ctr_obj;
+ memset(&key_ctr_obj, '\0', sizeof(key_ctr_t));
memcpy(key_ctr_obj.controller_name,
controller_id.c_str(), controller_id.length()+1);
void *key_ctr_prt = reinterpret_cast<void *>(&key_ctr_obj);
val_ctr_st_t obj_val_ctr_st;
+ memset(&obj_val_ctr_st, '\0', sizeof(val_ctr_st_t));
pfc_log_debug("Audit result from TC %d", audit_result);
if (audit_result == unc::tclib::TC_AUDIT_SUCCESS) {
oper_status = UPPL_CONTROLLER_OPER_UP;
obj_val_ctr_st.valid[kIdxOperStatus] = 1;
FN_START_TIME("Audit::HandleOperStatus", "Controller");
UpplReturnCode handle_oper_status = kt_controller.HandleOperStatus(
- UNC_DT_RUNNING,
+ db_conn, UNC_DT_RUNNING,
key_ctr_prt,
reinterpret_cast<void *>(&obj_val_ctr_st),
true);
controller_id.c_str());
ipc_mgr->addControllerToAuditList(controller_id);
// Start timer for processing audit notification from driver
- uint32_t ret = ipc_mgr->StartNotificationTimer(controller_id);
+ uint32_t ret = ipc_mgr->StartNotificationTimer(db_conn, controller_id);
pfc_log_debug("Start Timer return code %d for controller %s",
ret, controller_id.c_str());
} else {
- pfc_log_info("IPC Connection Manager Object is NULL");
+ pfc_log_debug("IPC Connection Manager Object is NULL");
}
- // Sending AUDIT_SUCCESS alarm to node manager
- physical_core->SendAuditSuccessAlarm(controller_id);
} else {
oper_status = UPPL_CONTROLLER_OPER_WAITING_AUDIT;
obj_val_ctr_st.oper_status = oper_status;
memset(obj_val_ctr_st.valid, '\0', sizeof(obj_val_ctr_st.valid));
obj_val_ctr_st.valid[kIdxOperStatus] = 1;
UpplReturnCode handle_oper_status = kt_controller.HandleOperStatus(
- UNC_DT_RUNNING,
+ db_conn, UNC_DT_RUNNING,
key_ctr_prt,
reinterpret_cast<void *>(&obj_val_ctr_st),
true);
pfc_log_debug("Handle Oper Status return: %d", handle_oper_status);
- // Sending the AUDIT_FAILURE alarm to Node Manager
- physical_core->SendAuditFailureAlarm(controller_id);
}
return UPPL_RC_SUCCESS;
}
-/**
- * * @Description : This function is used to Merge audit and running db at
- * end the Audit
- * * * @param[in] : controller name
- * * * @return : UpplReturnCode
+/**MergeAuditDbToRunning
+ * @Description : This function is used to Merge audit and running db at
+ * end Audit and clear the import db.
+ * @param[in] : controller name - controller name in which the audit occurs
+ * @return : UPPL_RC_SUCCESS if the updation of running DB with the
+ * imported value is success or UPPL_RC_ERR_* for failure of
+ * merging
* */
UpplReturnCode AuditRequest::MergeAuditDbToRunning(
+ OdbcmConnectionHandler *db_conn,
string controller_name) {
+ pfc_log_info("MergeAuditDbToRunning-controller_name: %s",
+ controller_name.c_str());
+ // Check for MergeImportRunning Lock
+ ScopedReadWriteLock eventDoneLock(PhysicalLayer::get_events_done_lock_(),
+ PFC_TRUE); // write lock
UpplReturnCode return_code = UPPL_RC_SUCCESS;
// Remove the controller_name from controller_in_audit list
return_code = PhysicalLayer::get_instance()->get_ipc_connection_manager()->
Kt_Base *class_pointer = GetClassPointerAndKey(
(AuditStateObjects)index, controller_name, key_struct, key_type);
if (class_pointer == NULL) {
+ if (key_struct != NULL) {
+ FreeKeyAndValueStruct(key_struct, NULL, index);
+ }
continue;
}
vector<void*> key_running, key_import;
vector<void*> val_running, val_import;
pfc_log_debug("Reading from running db for index %d", index);
UpplReturnCode read_running_status = class_pointer->ReadInternal(
- key_running,
+ db_conn, key_running,
val_running,
(uint32_t) UNC_DT_RUNNING,
(uint32_t) UNC_OP_READ_SIBLING_BEGIN);
// Read from Import DB
pfc_log_debug("Reading from import db for index %d", index);
UpplReturnCode read_import_status = class_pointer->ReadInternal(
- key_import,
+ db_conn, key_import,
val_import,
(uint32_t) UNC_DT_IMPORT,
(uint32_t) UNC_OP_READ_SIBLING_BEGIN);
pfc_log_debug(
"Reading values from both import and running db failed for index %d",
index);
+ delete class_pointer;
+ if (key_struct != NULL) {
+ FreeKeyAndValueStruct(key_struct, NULL, index);
+ }
continue;
}
pfc_log_debug("No.of entries from running db %d",
pfc_log_debug("No.of entries from import db %d",
static_cast<int>(key_import.size()));
// Iterate RUNNING and compare with IMPORT
- for (unsigned int iIndex = 0;
- iIndex < (uint32_t)key_running.size(); ++iIndex) {
- bool present_in_import = false;
- for (unsigned int jIndex = 0;
- jIndex < (uint32_t)key_import.size(); ++jIndex) {
- // check whether key is same
- pfc_bool_t is_same_key = class_pointer->CompareKeyStruct(
- key_running[iIndex],
- key_import[jIndex]);
- if (is_same_key == PFC_FALSE) {
- continue;
- }
- present_in_import = true;
- // check whether value is same
- if (index == Notfn_Logical_Member_Port) {
- continue;
- }
- pfc_bool_t is_same_value = class_pointer->CompareValueStruct(
- val_running[iIndex],
- val_import[jIndex]);
- if (is_same_value == PFC_TRUE) {
- pfc_log_debug("Values are same");
- continue;
- }
- // Update running db with import value
- pfc_log_debug("Update running db with import db value");
- void *old_val_struct;
- UpplReturnCode update_status = class_pointer->
- UpdateKeyInstance(
- reinterpret_cast<void *>(key_running[iIndex]),
- reinterpret_cast<void *>(val_import[jIndex]),
- (uint32_t)UNC_DT_STATE,
- key_type,
- old_val_struct);
- if (update_status != UPPL_RC_SUCCESS) {
- pfc_log_debug("Update failed for existing key");
- continue;
- }
- // Send value change notification to north bound - val_st
- UpplReturnCode notfn_status =
- class_pointer->ConfigurationChangeNotification(
- (uint32_t)UNC_DT_STATE,
- key_type,
- (uint32_t)UNC_OP_UPDATE,
- reinterpret_cast<void *>(key_running[iIndex]),
- reinterpret_cast<void *>(val_running[iIndex]),
- reinterpret_cast<void *>(val_import[jIndex]));
- if (notfn_status != UPPL_RC_SUCCESS) {
- pfc_log_debug("Failed sending update notification");
- }
- break;
- }
- if (present_in_import == false) {
- // Delete instance from running db
- pfc_log_debug("Delete existing entries from running db");
- UpplReturnCode delete_status = class_pointer->DeleteKeyInstance(
- reinterpret_cast<void *>(key_running[iIndex]),
- (uint32_t)UNC_DT_STATE,
- key_type);
- if (delete_status != UPPL_RC_SUCCESS) {
- pfc_log_debug("Delete failed for existing key");
- }
- // Send value change notification to north bound - val_st
- UpplReturnCode notfn_status =
- class_pointer->ConfigurationChangeNotification(
- (uint32_t)UNC_DT_STATE,
- key_type,
- (uint32_t)UNC_OP_DELETE,
- reinterpret_cast<void *>(key_running[iIndex]),
- NULL,
- NULL);
- if (notfn_status != UPPL_RC_SUCCESS) {
- pfc_log_debug("Failed sending delete notification");
- }
- }
- }
+ // Update Running if values mismatch with Import
+ // Delete entries from Running if not found in Import
+ UpdateRunningDbWithImportDb(key_import, val_import,
+ key_running, val_running,
+ index, class_pointer,
+ db_conn, key_type);
// Iterate IMPORT and compare with RUNNING
- for (unsigned int iIndex = 0;
- iIndex < (uint32_t)key_import.size(); ++iIndex) {
- bool present_in_running = false;
- for (unsigned int jIndex = 0;
- jIndex < (uint32_t)key_running.size(); ++jIndex) {
- pfc_bool_t is_same_key = class_pointer->CompareKeyStruct(
- key_import[iIndex],
- key_running[jIndex]);
- // Check if key already present in running db
- if (is_same_key == PFC_TRUE) {
- present_in_running = true;
- break;
- }
- }
- if (present_in_running == true) {
- continue;
- }
- UpplReturnCode create_status = UPPL_RC_SUCCESS;
- // Create instance in running db
- pfc_log_debug("Create new entries in db for index: %d", index);
- if (index == Notfn_Logical_Member_Port) {
- create_status = class_pointer->CreateKeyInstance(
- reinterpret_cast<void *>(key_import[iIndex]),
- NULL,
- (uint32_t)UNC_DT_STATE,
- key_type);
- } else {
- create_status = class_pointer->CreateKeyInstance(
- reinterpret_cast<void *>(key_import[iIndex]),
- reinterpret_cast<void *>(val_import[iIndex]),
- (uint32_t)UNC_DT_STATE,
- key_type);
- }
- if (create_status == UPPL_RC_SUCCESS) {
- // Send value change notification to north bound - val_st
- UpplReturnCode notfn_status = UPPL_RC_SUCCESS;
- if (index == Notfn_Logical_Member_Port) {
- notfn_status =
- class_pointer->ConfigurationChangeNotification(
- (uint32_t)UNC_DT_STATE,
- key_type,
- (uint32_t)UNC_OP_CREATE,
- reinterpret_cast<void *>(key_import[iIndex]),
- NULL,
- NULL);
- } else {
- notfn_status =
- class_pointer->ConfigurationChangeNotification(
- (uint32_t)UNC_DT_STATE,
- key_type,
- (uint32_t)UNC_OP_CREATE,
- reinterpret_cast<void *>(key_import[iIndex]),
- NULL,
- reinterpret_cast<void *>(val_import[iIndex]));
- }
- if (notfn_status != UPPL_RC_SUCCESS) {
- pfc_log_debug("Failed sending create notification");
- }
- } else {
- pfc_log_debug("Create failed for new key");
- }
- }
+ // And create entries in running db if not present
+ AddToRunningDbFromImportDb(key_import, val_import,
+ key_running, val_running,
+ index, class_pointer,
+ db_conn, key_type);
// Free the readInternal key and value structures
- for (unsigned int iIndex = 0;
- iIndex < (uint32_t)key_import.size(); ++iIndex) {
- if (index == Notfn_Logical_Member_Port) {
- FreeKeyAndValueStruct(key_import[iIndex],
- NULL,
- index);
- } else {
- FreeKeyAndValueStruct(key_import[iIndex],
- val_import[iIndex],
- index);
- }
- }
- for (unsigned int iIndex = 0;
- iIndex < (uint32_t)key_running.size(); ++iIndex) {
- if (index == Notfn_Logical_Member_Port) {
- FreeKeyAndValueStruct(key_running[iIndex],
- NULL,
- index);
- } else {
- FreeKeyAndValueStruct(key_running[iIndex],
- val_running[iIndex],
- index);
- }
- }
+ FreeKeyAndValueStruct(key_import, val_import,
+ key_running, val_running, index);
delete class_pointer;
if (key_struct != NULL) {
FreeKeyAndValueStruct(key_struct, NULL, index);
// Clear import db entries
ODBCM_RC_STATUS clear_status =
PhysicalLayer::get_instance()->get_odbc_manager()->
- ClearOneInstance(UNC_DT_IMPORT, controller_name);
+ ClearOneInstance(UNC_DT_IMPORT, controller_name, db_conn);
if (clear_status != ODBCM_RC_SUCCESS) {
pfc_log_info("Import DB clearing failed");
}
+ pfc_log_info("MergeAuditDbToRunning return code: %d", return_code);
return return_code;
}
-/**
- * * @Description : This function is used to get the key and class pointer
- * * * @param[in] : Notification class key type, controller name
- * * * @return : Kt_Base* poiner and key struct
+/**GetClassPointerAndKey
+ * @Description : This function is used to get the key and class pointer
+ * of the appropriate kt_classes
+ * @param[in] : audit_key_type -
+ * controller name - controller name in which the audit occurs
+ * key - Specifies the key of the appropriate key types
+ * key_type - specifies the appropriate key types
+ * @return : Returns the class pointer to the appropriate kt classes.
* */
Kt_Base* AuditRequest::GetClassPointerAndKey(
AuditStateObjects audit_key_type,
return class_pointer;
}
-/** FreeKeyAndValueStruct
- * * @Description : This function clears the key struct and value struct
- * * * @param[in] : key struct, value struct and key type
- * * * @return : void * key structure
+/**FreeKeyAndValueStruct
+ * @Description : This function clears the key struct and value struct
+ * of the appropriate key types
+ * @param[in] : key struct - the key for the appropriate key types
+ * value struct - the value structure for the appropriate
+ * key types
+ * key type - UNC_KT_* specifies the appropriate key types
+ * @return : returns void * key structure for the successfull deletion
+ * of key and value structures of the key types
* */
void AuditRequest::FreeKeyAndValueStruct(void* key_struct,
void* value_struct,
}
return;
}
+
+/**
+ * @Description : This overloaded function is called when audit notification
+ * time out expires
+ * @param[in] : None
+ * @return : None
+ * */
+void AuditNotification::operator() () {
+ pfc_log_debug("Received Audit Notification timer out controller %s",
+ controller_name_.c_str());
+ AuditRequest audit_req;
+ UpplReturnCode db_ret = UPPL_RC_SUCCESS;
+ OPEN_DB_CONNECTION(unc::uppl::kOdbcmConnReadWriteSb, db_ret);
+ if (db_ret != UPPL_RC_SUCCESS) {
+ pfc_log_error("Error in opening DB connection");
+ } else {
+ audit_req.MergeAuditDbToRunning(&db_conn, controller_name_);
+ }
+}
+
+/**
+ * @Description : This function compares running db and import db
+ * If values mismatch in import db and running db, running db
+ * will be updated using values from import db
+ * If key instances available in running db is not available in
+ * import db, it will be deleted from running db
+ * @param[in] : Vector of Key, Value available in running and import db
+ * @return : None
+ * */
+void AuditRequest::UpdateRunningDbWithImportDb(
+ const vector<void *> &key_import,
+ const vector<void *> &val_import,
+ const vector<void *> &key_running,
+ const vector<void *> &val_running,
+ unsigned int index,
+ Kt_Base *class_pointer,
+ OdbcmConnectionHandler *db_conn,
+ uint32_t key_type) {
+ for (unsigned int iIndex = 0;
+ iIndex < (uint32_t)key_running.size(); ++iIndex) {
+ bool present_in_import = false;
+ for (unsigned int jIndex = 0;
+ jIndex < (uint32_t)key_import.size(); ++jIndex) {
+ // check whether key is same
+ pfc_bool_t is_same_key = class_pointer->CompareKeyStruct(
+ key_running[iIndex],
+ key_import[jIndex]);
+ if (is_same_key == PFC_FALSE) {
+ continue;
+ }
+ present_in_import = true;
+ // check whether value is same
+ if (index == Notfn_Logical_Member_Port) {
+ continue;
+ }
+ pfc_bool_t is_same_value = class_pointer->CompareValueStruct(
+ val_running[iIndex],
+ val_import[jIndex]);
+ if (is_same_value == PFC_TRUE) {
+ pfc_log_debug("Values are same");
+ continue;
+ }
+ // Update running db with import value
+ pfc_log_debug("Update running db with import db value");
+ void *old_val_struct = NULL;
+ UpplReturnCode update_status = class_pointer->
+ UpdateKeyInstance(
+ db_conn, reinterpret_cast<void *>(key_running[iIndex]),
+ reinterpret_cast<void *>(val_import[jIndex]),
+ (uint32_t)UNC_DT_STATE,
+ key_type,
+ old_val_struct);
+ if (update_status != UPPL_RC_SUCCESS) {
+ pfc_log_error("Update failed for existing key");
+ continue;
+ }
+ // Send value change notification to north bound - val_st
+ UpplReturnCode notfn_status =
+ class_pointer->ConfigurationChangeNotification(
+ (uint32_t)UNC_DT_STATE,
+ key_type,
+ (uint32_t)UNC_OP_UPDATE,
+ reinterpret_cast<void *>(key_running[iIndex]),
+ reinterpret_cast<void *>(val_running[iIndex]),
+ reinterpret_cast<void *>(val_import[jIndex]));
+ if (notfn_status != UPPL_RC_SUCCESS) {
+ pfc_log_error("Failed sending update notification");
+ }
+ // Old value structure memory clean up
+ if(old_val_struct != NULL) {
+ class_pointer->ClearValueStructure(key_type,
+ old_val_struct);
+ old_val_struct = NULL;
+ }
+ break;
+ }
+ if (present_in_import == false) {
+ // Delete instance from running db
+ pfc_log_debug("Delete existing entries from running db");
+ UpplReturnCode delete_status = class_pointer->DeleteKeyInstance(
+ db_conn, reinterpret_cast<void *>(key_running[iIndex]),
+ (uint32_t)UNC_DT_STATE,
+ key_type);
+ if (delete_status != UPPL_RC_SUCCESS) {
+ pfc_log_error("Delete failed for existing key");
+ }
+ // Send value change notification to north bound - val_st
+ UpplReturnCode notfn_status =
+ class_pointer->ConfigurationChangeNotification(
+ (uint32_t)UNC_DT_STATE,
+ key_type,
+ (uint32_t)UNC_OP_DELETE,
+ reinterpret_cast<void *>(key_running[iIndex]),
+ NULL,
+ NULL);
+ if (notfn_status != UPPL_RC_SUCCESS) {
+ pfc_log_error("Failed sending delete notification");
+ }
+ }
+ }
+}
+
+/**
+ * @Description : This function compares running db and import db *
+ * If key instances available in import db is not available in
+ * running db, it will be added to running db
+ * @param[in] : Vector of Key, Value available in running and import db
+ * @return : None
+ * */
+void AuditRequest::AddToRunningDbFromImportDb(
+ const vector<void *> &key_import,
+ const vector<void *> &val_import,
+ const vector<void *> &key_running,
+ const vector<void *> &val_running,
+ unsigned int index,
+ Kt_Base *class_pointer,
+ OdbcmConnectionHandler *db_conn,
+ uint32_t key_type) {
+ for (unsigned int iIndex = 0;
+ iIndex < (uint32_t)key_import.size(); ++iIndex) {
+ bool present_in_running = false;
+ for (unsigned int jIndex = 0;
+ jIndex < (uint32_t)key_running.size(); ++jIndex) {
+ pfc_bool_t is_same_key = class_pointer->CompareKeyStruct(
+ key_import[iIndex],
+ key_running[jIndex]);
+ // Check if key already present in running db
+ if (is_same_key == PFC_TRUE) {
+ present_in_running = true;
+ break;
+ }
+ }
+ if (present_in_running == true) {
+ continue;
+ }
+ // Create instance in running db
+ UpplReturnCode create_status = UPPL_RC_SUCCESS;
+ // Validate key
+ UpplReturnCode validate_status = UPPL_RC_SUCCESS;
+ if (index == Notfn_Logical_Member_Port) {
+ validate_status = class_pointer->ValidateRequest(
+ db_conn,
+ reinterpret_cast<void *>(key_import[iIndex]),
+ NULL,
+ UNC_OP_CREATE, UNC_DT_STATE, key_type);
+ } else {
+ validate_status = class_pointer->ValidateRequest(
+ db_conn,
+ reinterpret_cast<void *>(key_import[iIndex]),
+ reinterpret_cast<void *>(val_import[iIndex]),
+ UNC_OP_CREATE, UNC_DT_STATE, key_type);
+ }
+ if (validate_status != UPPL_RC_SUCCESS) {
+ pfc_log_info("Validation failed for index %d", index);
+ continue;
+ }
+ pfc_log_debug("Create new entries in db for index: %d", index);
+ if (index == Notfn_Logical_Member_Port) {
+ create_status = class_pointer->CreateKeyInstance(
+ db_conn, reinterpret_cast<void *>(key_import[iIndex]),
+ NULL,
+ (uint32_t)UNC_DT_STATE,
+ key_type);
+ } else {
+ create_status = class_pointer->CreateKeyInstance(
+ db_conn, reinterpret_cast<void *>(key_import[iIndex]),
+ reinterpret_cast<void *>(val_import[iIndex]),
+ (uint32_t)UNC_DT_STATE,
+ key_type);
+ }
+ if (create_status == UPPL_RC_SUCCESS) {
+ // Send value change notification to north bound - val_st
+ UpplReturnCode notfn_status = UPPL_RC_SUCCESS;
+ if (index == Notfn_Logical_Member_Port) {
+ notfn_status =
+ class_pointer->ConfigurationChangeNotification(
+ (uint32_t)UNC_DT_STATE,
+ key_type,
+ (uint32_t)UNC_OP_CREATE,
+ reinterpret_cast<void *>(key_import[iIndex]),
+ NULL,
+ NULL);
+ } else {
+ notfn_status =
+ class_pointer->ConfigurationChangeNotification(
+ (uint32_t)UNC_DT_STATE,
+ key_type,
+ (uint32_t)UNC_OP_CREATE,
+ reinterpret_cast<void *>(key_import[iIndex]),
+ NULL,
+ reinterpret_cast<void *>(val_import[iIndex]));
+ }
+ if (notfn_status != UPPL_RC_SUCCESS) {
+ pfc_log_error("Failed sending create notification");
+ }
+ } else {
+ pfc_log_error("Create failed for new key");
+ }
+ }
+ return;
+}
+
+/**
+ * @Description : This function clears the internal structure contains key
+ * and values of import and running db
+ * @param[in] : Vector of Key, Value available in running and import db
+ * @return : None
+ * */
+void AuditRequest::FreeKeyAndValueStruct(
+ const vector<void *> &key_import,
+ const vector<void *> &val_import,
+ const vector<void *> &key_running,
+ const vector<void *> &val_running,
+ unsigned int index) {
+ for (unsigned int iIndex = 0;
+ iIndex < (uint32_t)key_import.size(); ++iIndex) {
+ if (index == Notfn_Logical_Member_Port) {
+ FreeKeyAndValueStruct(key_import[iIndex],
+ NULL,
+ index);
+ } else {
+ FreeKeyAndValueStruct(key_import[iIndex],
+ val_import[iIndex],
+ index);
+ }
+ }
+ for (unsigned int iIndex = 0;
+ iIndex < (uint32_t)key_running.size(); ++iIndex) {
+ if (index == Notfn_Logical_Member_Port) {
+ FreeKeyAndValueStruct(key_running[iIndex],
+ NULL,
+ index);
+ } else {
+ FreeKeyAndValueStruct(key_running[iIndex],
+ val_running[iIndex],
+ index);
+ }
+ }
+}
+
} // namespace uppl
} // namespace unc
#include "ipct_util.hh"
using unc::uppl::PhysicalLayer;
+
/* ConfigurationRequest
- * @Description : constructor function
- * @param[in]: NA
- * @return : NA
+ * @Description : This function initializes the member variables
+ * and allocates the memory for the key instances of
+ * kt_root,kt_controller,kt_domain,kt_boundary
+ * @param[in] : None
+ * @return : None
* */
ConfigurationRequest::ConfigurationRequest() {
}
/* ~ConfigurationRequest
- * @Description : Destructor function
- * @param[in]: NA
- * @return : NA
+ * @Description : This function releases the memory allocated to
+ * pointer member data
+ * @param[in] : None
+ * @param[out] : None
+ * @return : None
* */
ConfigurationRequest::~ConfigurationRequest() {
}
-/* ProcessReq
- * @Description: Creates the respective Kt class object
- * to process the config operation
- * @param[in]: ipc struct, service id, session id,
- * configuration id, session object
- * @return : config operation response success/failure.
+/* ProcessReq
+ * @Description : This function creates the respective Kt class object to
+ * process the configuration request received from north bound
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * @return : UPPL_RC_SUCCESS is returned when the response is added to
+ * ipc session successfully otherwise Common error code is
+ * returned when ipc response could not be added to session.
* */
-UpplReturnCode ConfigurationRequest::ProcessReq(ServerSession &session) {
+UpplReturnCode ConfigurationRequest::ProcessReq(
+ ServerSession &session,
+ physical_request_header &obj_req_hdr) {
Kt_Base *KtObj = NULL;
- physical_request_header obj_req_hdr;
- // populate header from ipc message
- if (0 != PhyUtil::sessGetReqHeader(session, obj_req_hdr)) {
- pfc_log_error("Unable to parse ipc structure. BAD_REQUEST error");
- return UPPL_RC_ERR_BAD_REQUEST;
+ UpplReturnCode db_ret = UPPL_RC_SUCCESS;
+ OPEN_DB_CONNECTION(unc::uppl::kOdbcmConnReadWriteNb, db_ret);
+ if (db_ret != UPPL_RC_SUCCESS) {
+ pfc_log_fatal("DB Connection failure for operation %d",
+ obj_req_hdr.operation);
+ return db_ret;
}
-
UpplReturnCode return_code = UPPL_RC_SUCCESS, resp_code = UPPL_RC_SUCCESS;
void* key_struct = NULL;
physical_response_header rsh;
PhyUtil::getRespHeaderFromReqHeader(obj_req_hdr, rsh);
- resp_code = ValidateReq(session, obj_req_hdr,
+ resp_code = ValidateReq(&db_conn, session, obj_req_hdr,
key_struct, val_struct, KtObj);
if (resp_code != UPPL_RC_SUCCESS) {
// validation failed call add output
switch (obj_req_hdr.operation) {
case UNC_OP_CREATE:
{
- resp_code = KtObj->Create(obj_req_hdr.client_sess_id,
+ resp_code = KtObj->Create(&db_conn, obj_req_hdr.client_sess_id,
obj_req_hdr.config_id,
key_struct,
val_struct,
case UNC_OP_UPDATE:
{
// Invoke Update operation for respective KT class
- resp_code = KtObj->Update(obj_req_hdr.client_sess_id,
+ resp_code = KtObj->Update(&db_conn, obj_req_hdr.client_sess_id,
obj_req_hdr.config_id,
key_struct,
val_struct,
case UNC_OP_DELETE:
{
// Invoke Delete operation for respective KT class
- resp_code = KtObj->Delete(obj_req_hdr.client_sess_id,
+ resp_code = KtObj->Delete(&db_conn, obj_req_hdr.client_sess_id,
obj_req_hdr.config_id,
key_struct,
obj_req_hdr.data_type,
// return the actual response
pfc_log_error("Config validation failed");
rsh.result_code = resp_code;
- if (PhyUtil::sessOutRespHeader(session, rsh) == 0) {
+ int err = PhyUtil::sessOutRespHeader(session, rsh);
+ err |= KtObj->AddKeyStructuretoSession(obj_req_hdr.key_type, &session,
+ key_struct);
+ if (err == 0) {
resp_code = UPPL_RC_SUCCESS;
} else {
resp_code = UPPL_RC_ERR_IPC_WRITE_ERROR;
// It's a common error code
return_code = UPPL_RC_ERR_IPC_WRITE_ERROR;
}
- pfc_log_info("Returning %d from config request handler", return_code);
+ pfc_log_debug("Returning %d from config request handler", return_code);
return return_code;
}
-
-/* ValidateReq
- * @Description : validates the request received from north bound
- * @param[in]: session, request header, key struct, value struct and
- * Base class object
- * @return : config operation response success/failure.
+/* ValidateReq
+ * @Description : This function validates the request received from north bound
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * key struct - the key instance for appropriate key types
+ * value struct - the value struct for the appropriate key types
+ * obj_req_hdr - object of physical request header
+ * KtObj - Object of the base class to invoke appropriate
+ * kt class
+ * @return : UPPL_RC_SUCCESS if validation is successful
+ * or UPPL_RC_ERR_* if validation is failed
* */
UpplReturnCode ConfigurationRequest::ValidateReq(
+ OdbcmConnectionHandler *db_conn,
ServerSession &session,
physical_request_header obj_req_hdr,
void* &key_struct, void* &val_struct,
}
case UNC_KT_CONTROLLER:
{
- resp_code = ValidateController(session,
+ resp_code = ValidateController(db_conn, session,
obj_req_hdr.data_type,
obj_req_hdr.operation,
key_struct,
}
case UNC_KT_CTR_DOMAIN:
{
- resp_code = ValidateDomain(session,
+ resp_code = ValidateDomain(db_conn, session,
obj_req_hdr.data_type,
obj_req_hdr.operation,
key_struct,
}
case UNC_KT_BOUNDARY:
{
- resp_code = ValidateBoundary(session,
+ resp_code = ValidateBoundary(db_conn, session,
obj_req_hdr.data_type,
obj_req_hdr.operation,
key_struct,
case UNC_OP_DELETE:
{
// form validate request for CREATE operation
- resp_code = KtObj->ValidateRequest(key_struct,
+ resp_code = KtObj->ValidateRequest(db_conn, key_struct,
val_struct,
obj_req_hdr.operation,
obj_req_hdr.data_type,
return return_code;
}
-UpplReturnCode ConfigurationRequest::ValidateController(ServerSession &session,
- uint32_t data_type,
- uint32_t operation,
- void* &key_struct,
- void* &val_struct) {
+/* ValidateController
+ * @Description : This function validates the value struct and the scalability
+ * and also checks the capability for UNC_KT_CONTROLLER
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * data_type - The data_type UNC_DT_CANDIDATE is only allowed
+ * operation - contains UNC_OP_CREATE or UNC_OP_UPDATE
+ * key struct - specifies key instance of KT_Controller
+ * value struct - specifies value structure of KT_CONTROLLER
+ * @return : UPPL_RC_SUCCESS if scalability number is within range
+ * or UPPL_RC_ERR_* if not
+ * * */
+UpplReturnCode ConfigurationRequest::ValidateController(
+ OdbcmConnectionHandler *db_conn,
+ ServerSession &session,
+ uint32_t data_type,
+ uint32_t operation,
+ void* &key_struct,
+ void* &val_struct) {
UpplReturnCode resp_code = UPPL_RC_SUCCESS;
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
if (data_type != UNC_DT_CANDIDATE) {
// validate scalability after basic validation
// Since it requires db call
resp_code = KtObj.ValidateCtrlrScalability(
- version,
+ db_conn, version,
(uint32_t)UNC_KT_CONTROLLER,
data_type);
if (resp_code != UPPL_RC_SUCCESS) {
return UPPL_RC_SUCCESS;
}
-UpplReturnCode ConfigurationRequest::ValidateDomain(ServerSession &session,
- uint32_t data_type,
- uint32_t operation,
- void* &key_struct,
- void* &val_struct) {
+/* ValidateDomain
+ * @Description : This function validates the value struct of the
+ * UNC_KT_DOMAIN
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * data_type - The data_type UNC_DT_CANDIDATE is only allowed
+ * operation - contains UNC_OP_CREATE or UNC_OP_UPDATE
+ * key struct - specifies key instance of KT_Domain
+ * value struct - specifies value structure of KT_Domain
+ * @return : UPPL_RC_SUCCESS if the validation is success
+ * or UPPL_RC_ERR_* if validation is failed
+ * */
+UpplReturnCode ConfigurationRequest::ValidateDomain(
+ OdbcmConnectionHandler *db_conn,
+ ServerSession &session,
+ uint32_t data_type,
+ uint32_t operation,
+ void* &key_struct,
+ void* &val_struct) {
UpplReturnCode resp_code = UPPL_RC_SUCCESS;
if (data_type != UNC_DT_CANDIDATE) {
pfc_log_info("Operation not allowed in given data type %d",
return UPPL_RC_SUCCESS;
}
-UpplReturnCode ConfigurationRequest::ValidateBoundary(ServerSession &session,
- uint32_t data_type,
- uint32_t operation,
- void* &key_struct,
- void* &val_struct) {
+/* ValidateBoundary
+ * @Description : This function validates the value struct of the
+ * UNC_KT_BOUNDARY
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * data_type - The data_type UNC_DT_CANDIDATE is only allowed
+ * operation - contains UNC_OP_CREATE or UNC_OP_UPDATE
+ * key struct - specifies key instance of KT_Boundary
+ * value struct - specifies value structure of KT_Boundary
+ * @return : UPPL_RC_SUCCESS if the validation is success
+ * or UPPL_RC_ERR_* if validation is failed
+ * */
+UpplReturnCode ConfigurationRequest::ValidateBoundary(
+ OdbcmConnectionHandler *db_conn,
+ ServerSession &session,
+ uint32_t data_type,
+ uint32_t operation,
+ void* &key_struct,
+ void* &val_struct) {
UpplReturnCode resp_code = UPPL_RC_SUCCESS;
if (data_type != UNC_DT_CANDIDATE) {
pfc_log_info("Operation not allowed in given data type %d",
*/
/**
- * @brief Itc
+ * @brief Itc DbConfig
* @file itc_db_config.cc
*
*/
#include "physicallayer.hh"
#include "itc_kt_controller.hh"
-/**DBConfigurationRequest()
- * @Description : Constructor which will initializes the member data
+/**DBConfigurationRequest
+ * @Description : This function initializes the member data
* @param[in] : None
- * @Return : void
- * **/
+ * @Return : None
+ * */
DBConfigurationRequest::DBConfigurationRequest() {
}
-/** ~DBConfigurationRequest()
- * @Description : Destructor to release any memory allocated to pointer member data
+/**~DBConfigurationRequest
+ * @Description : This function releases memory allocated
+ * to pointer member data
* @param[in] : None
- * @Return : void
- * **/
+ * @Return : None
+ * */
DBConfigurationRequest::~DBConfigurationRequest() {
}
-/**LoadAndCommitStartup()
- * @Description : This function will call the ClearDatabase() and then send
- * request to ODBCManager to copy StartUp to Candidate
- * configuration
+/**LoadAndCommitStartup
+ * @Description : This function copy the entries from StartUp to Candidate
+ * DB and from Candidate to running DB and
+ * clears State DB entries
* @param[in] : None
- * @Return : void
- * **/
-UpplReturnCode DBConfigurationRequest::LoadAndCommitStartup() {
+ * @Return : UPPL_RC_SUCCESS if Load and Commit Startup is successful
+ * or UPPL_RC_ERR_* if failure occurs
+ * */
+UpplReturnCode DBConfigurationRequest::LoadAndCommitStartup(
+ OdbcmConnectionHandler *db_conn) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
ODBCM_RC_STATUS copy_db_status = ODBCM_RC_SUCCESS;
UpplReturnCode result_code = UPPL_RC_SUCCESS;
/* copy StartUp to Candidate */
copy_db_status = physical_layer->get_odbc_manager()->
- CopyDatabase(UNC_DT_STARTUP, UNC_DT_CANDIDATE);
+ CopyDatabase(UNC_DT_STARTUP, UNC_DT_CANDIDATE, db_conn);
if (copy_db_status != ODBCM_RC_SUCCESS) {
if (copy_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log fatal error to log daemon
}
return result_code;
}
+ // Clear Running entries
+ ODBCM_RC_STATUS clear_status =
+ PhysicalLayer::get_instance()->get_odbc_manager()->
+ ClearDatabase(UNC_DT_RUNNING, db_conn);
+ if (clear_status != ODBCM_RC_SUCCESS) {
+ pfc_log_info("Running DB clearing failed");
+ result_code = UPPL_RC_ERR_CLEAR_DB;
+ }
+ // Clear Import Database entries
+ clear_status = PhysicalLayer::get_instance()->get_odbc_manager()->
+ ClearDatabase(UNC_DT_IMPORT, db_conn);
+ if (clear_status != ODBCM_RC_SUCCESS) {
+ pfc_log_info("Import DB clearing failed");
+ result_code = UPPL_RC_ERR_CLEAR_DB;
+ }
/* copy Candidate to Running */
copy_db_status = physical_layer->get_odbc_manager()->
- CopyDatabase(UNC_DT_CANDIDATE, UNC_DT_RUNNING);
+ CopyDatabase(UNC_DT_CANDIDATE, UNC_DT_RUNNING, db_conn);
if (copy_db_status != ODBCM_RC_SUCCESS) {
if (copy_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log fatal error to log daemon
return result_code;
}
// Clear State entries
- ODBCM_RC_STATUS clear_status =
+ clear_status =
PhysicalLayer::get_instance()->get_odbc_manager()->
- ClearDatabase(UNC_DT_STATE);
+ ClearDatabase(UNC_DT_STATE, db_conn);
if (clear_status != ODBCM_RC_SUCCESS) {
pfc_log_info("State DB clearing failed");
result_code = UPPL_RC_ERR_CLEAR_DB;
return result_code;
}
-/** ClearStartUpDb()
- * @Description : This function will clear the contents of clearStartup
- * Database
+/**ClearStartUpDb()
+ * @Description : This function clears the content of Startup Database
* @param[in] : None
- * @Return : UpplReturnCode(enum)
- * **/
-UpplReturnCode DBConfigurationRequest::ClearStartUpDb() {
+ * @Return : UPPL_RC_SUCCESS if Clearing the startup DB is successful
+ * or UPPL_RC_ERR_* in case of failure
+ * */
+UpplReturnCode DBConfigurationRequest::ClearStartUpDb(
+ OdbcmConnectionHandler *db_conn) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode result_code = UPPL_RC_SUCCESS;
ODBCM_RC_STATUS clear_db_status;
/* clear the StartUp db */
clear_db_status = physical_layer->get_odbc_manager()->
- ClearDatabase(UNC_DT_STARTUP);
- if (clear_db_status != ODBCM_RC_SUCCESS) {
- if (clear_db_status == ODBCM_RC_CONNECTION_ERROR) {
- // log fatal error to log daemon
- pfc_log_fatal("DB connection not available or cannot access DB");
- result_code = UPPL_RC_ERR_DB_ACCESS;
- } else {
- // log error to log daemon
- pfc_log_error("ClearStartUpDb:Clearing the StartUp database failed");
- result_code = UPPL_RC_ERR_CLEAR_DB;
- }
- }
- return result_code;
-}
-
-/**ClearAllDb()
- * @Description : This function will clear the contents of all the databases
- * @param[in] : None
- * @Return : UpplReturnCode(enum)
- * **/
-UpplReturnCode DBConfigurationRequest::ClearAllDb() {
- PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
- UpplReturnCode result_code = UPPL_RC_SUCCESS;
- ODBCM_RC_STATUS clear_db_status;
-
- /* Clear all the databases */
- clear_db_status = physical_layer->get_odbc_manager()->
- ClearDatabase(UNC_DT_CANDIDATE);
- if (clear_db_status != ODBCM_RC_SUCCESS) {
- if (clear_db_status == ODBCM_RC_CONNECTION_ERROR) {
- // log fatal error to log daemon
- pfc_log_fatal("DB connection not available or cannot access DB");
- result_code = UPPL_RC_ERR_DB_ACCESS;
- } else {
- // log error to log daemon
- pfc_log_error("ClearStartUpDb:Clearing the Candidate database failed");
- result_code = UPPL_RC_ERR_CLEAR_DB;
- }
- return result_code;
- }
- clear_db_status = physical_layer->get_odbc_manager()->
- ClearDatabase(UNC_DT_RUNNING);
- if (clear_db_status != ODBCM_RC_SUCCESS) {
- if (clear_db_status == ODBCM_RC_CONNECTION_ERROR) {
- // log fatal error to log daemon
- pfc_log_fatal("DB connection not available or cannot access DB");
- result_code = UPPL_RC_ERR_DB_ACCESS;
- } else {
- // log error to log daemon
- pfc_log_error("ClearStartUpDb:Clearing the Running database failed");
- result_code = UPPL_RC_ERR_CLEAR_DB;
- }
- return result_code;
- }
-
- clear_db_status = physical_layer->get_odbc_manager()->
- ClearDatabase(UNC_DT_IMPORT);
- if (clear_db_status != ODBCM_RC_SUCCESS) {
- if (clear_db_status == ODBCM_RC_CONNECTION_ERROR) {
- // log fatal error to log daemon
- pfc_log_fatal("DB connection not available or cannot access DB");
- result_code = UPPL_RC_ERR_DB_ACCESS;
- } else {
- // log error to log daemon
- pfc_log_error("ClearStartUpDb:Clearing the Import database failed");
- result_code = UPPL_RC_ERR_CLEAR_DB;
- }
- return result_code;
- }
-
- clear_db_status = physical_layer->get_odbc_manager()->
- ClearDatabase(UNC_DT_STARTUP);
+ ClearDatabase(UNC_DT_STARTUP, db_conn);
if (clear_db_status != ODBCM_RC_SUCCESS) {
if (clear_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log fatal error to log daemon
pfc_log_error("ClearStartUpDb:Clearing the StartUp database failed");
result_code = UPPL_RC_ERR_CLEAR_DB;
}
- return result_code;
}
return result_code;
}
-/**AbortCandidateDb()
- * @Description : This function rollbacks the uncommitted transaction
- from the candidate database.
- * @param[in] : None
- * @Return : UpplReturnCode(enum)
- * **/
-UpplReturnCode DBConfigurationRequest::AbortCandidateDb() {
+/**AbortCandidateDb
+ * @Description : This function modified controller to logical and rollbacks
+ * the uncommitted transaction from the candidate database.
+ * @param[in] : None
+ * @Return : UPPL_RC_SUCCESS if AbortCandidate database is successful
+ * or UPPL_RC_ERR_* in case of failure
+ * */
+UpplReturnCode DBConfigurationRequest::AbortCandidateDb(
+ OdbcmConnectionHandler *db_conn) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode result_code = UPPL_RC_SUCCESS;
- result_code = SendDeletedControllerToLogical();
+ result_code = SendDeletedControllerToLogical(db_conn);
if (result_code != UPPL_RC_SUCCESS) {
return result_code;
}
- result_code = SendCreatedControllerToLogical();
+ result_code = SendCreatedControllerToLogical(db_conn);
if (result_code != UPPL_RC_SUCCESS) {
return result_code;
}
- result_code = SendUpdatedControllerToLogical();
+ result_code = SendUpdatedControllerToLogical(db_conn);
if (result_code != UPPL_RC_SUCCESS) {
return result_code;
}
/* copy running database to candidate database */
ODBCM_RC_STATUS copy_db_status = physical_layer->get_odbc_manager()->
- CopyDatabase(UNC_DT_RUNNING, UNC_DT_CANDIDATE);
+ CopyDatabase(UNC_DT_RUNNING, UNC_DT_CANDIDATE, db_conn);
if (copy_db_status != ODBCM_RC_SUCCESS) {
if (copy_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log fatal error to log daemon
result_code = UPPL_RC_ERR_COPY_RUNNING_TO_CANDID;
}
}
- return result_code;
-}
-
-/**SaveCandidateToRunning()
- * @Description : This function will send request to ODBCManager to sync
- candidate with running configuration
- * @param[in] : None
- * @Return : UpplReturnCode(enum)
- * **/
-UpplReturnCode DBConfigurationRequest::SaveCandidateToRunning() {
- PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
- UpplReturnCode result_code = UPPL_RC_SUCCESS;
- ODBCM_RC_STATUS copy_db_status;
-
- /* Copy candidate database to running database */
- copy_db_status = physical_layer->get_odbc_manager()->
- CopyDatabase(UNC_DT_CANDIDATE, UNC_DT_RUNNING);
- if (copy_db_status != ODBCM_RC_SUCCESS) {
- if (copy_db_status == ODBCM_RC_CONNECTION_ERROR) {
- // log fatal error to log daemon
- pfc_log_fatal("DB connection not available or cannot access DB");
- result_code = UPPL_RC_ERR_DB_ACCESS;
- } else {
- // log error to log daemon
- pfc_log_error("copy candidate database to running database failed");
- result_code = UPPL_RC_ERR_COPY_CANDID_TO_RUNNING;
- }
+ result_code = SendAppliedControllerToLogical(db_conn);
+ if (result_code != UPPL_RC_SUCCESS) {
+ return result_code;
}
return result_code;
}
-/**SaveRunningToStartUp()
- * @Description : This function will send request to ODBCManager to sync
- running with StartUp configuration
- * @param[in] : None
- * @Return : UpplReturnCode(enum)
- * **/
-UpplReturnCode DBConfigurationRequest::SaveRunningToStartUp() {
+/**SaveRunningToStartUp
+ * @Description : This function send request to ODBCManager to sync running
+ * with StartUp configuration
+ * @param[in] : None
+ * @Return : UPPL_RC_SUCCESS if saving running to startup database is
+ * successful or UPPL_RC_ERR_* in case of failure
+ * */
+UpplReturnCode DBConfigurationRequest::SaveRunningToStartUp(
+ OdbcmConnectionHandler *db_conn) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode result_code = UPPL_RC_SUCCESS;
ODBCM_RC_STATUS copy_db_status;
/* Copy running database to StartUp database */
copy_db_status = physical_layer->get_odbc_manager()->
- CopyDatabase(UNC_DT_RUNNING, UNC_DT_STARTUP);
+ CopyDatabase(UNC_DT_RUNNING, UNC_DT_STARTUP, db_conn);
if (copy_db_status != ODBCM_RC_SUCCESS) {
if (copy_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log fatal error to log daemon
return result_code;
}
-/**AuditStartUp()
- * @Description : This function will send request to ODBCManager to copy
- StartUp to Candidate configuration
- * @param[in] : None
- * @Return : UpplReturnCode(enum)
- * **/
-UpplReturnCode DBConfigurationRequest::AuditStartUp() {
- PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
- UpplReturnCode result_code = UPPL_RC_SUCCESS;
- ODBCM_RC_STATUS copy_db_status;
-
- /* Copy startup database to candidate database */
- copy_db_status = physical_layer->get_odbc_manager()->
- CopyDatabase(UNC_DT_STARTUP, UNC_DT_CANDIDATE);
- if (copy_db_status != ODBCM_RC_SUCCESS) {
- if (copy_db_status == ODBCM_RC_CONNECTION_ERROR) {
- // log fatal error to log daemon
- pfc_log_fatal("DB connection not available or cannot access DB");
- result_code = UPPL_RC_ERR_DB_ACCESS;
- } else {
- // log error to log manager
- pfc_log_error("copy startup database to candidate database failed");
- result_code = UPPL_RC_ERR_COPY_STARTUP_TO_CANDID;
- }
- }
- return result_code;
-}
-
-/**AuditRunningDb()
- * @Description : This function will send request to ODBCManager to sync
- candidate with running configuration
- * @param[in] : None
- * @Return : UpplReturnCode(enum)
- * **/
-UpplReturnCode DBConfigurationRequest::AuditRunningDb() {
- PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
- UpplReturnCode result_code = UPPL_RC_SUCCESS;
- ODBCM_RC_STATUS copy_db_status;
-
- /* Copy candidate database to running database */
- copy_db_status = physical_layer->get_odbc_manager()->
- CopyDatabase(UNC_DT_CANDIDATE, UNC_DT_RUNNING);
- if (copy_db_status != ODBCM_RC_SUCCESS) {
- if (copy_db_status == ODBCM_RC_CONNECTION_ERROR) {
- // log fatal error to log daemon
- pfc_log_fatal("DB connection not available or cannot access DB");
- result_code = UPPL_RC_ERR_DB_ACCESS;
- } else {
- // log error to log daemon
- pfc_log_error("copy candidate database to running database failed");
- result_code = UPPL_RC_ERR_COPY_CANDID_TO_RUNNING;
- }
- }
- return result_code;
-}
-
-/**SendDeletedControllerToLogical()
- * @Description : This function will send the deleted controller
- * to logical during abort candidate db/ abort transaction
- * @param[in] : None
- * @Return : UpplReturnCode(enum)
- * **/
-UpplReturnCode DBConfigurationRequest::SendDeletedControllerToLogical() {
+/**SendDeletedControllerToLogical
+ * @Description : This function send the deleted controller to logical
+ * during abort candidate db/ abort transaction
+ * @param[in] : None
+ * @Return : UPPL_RC_SUCCESS if sending the controller information to
+ * logical is successful or UPPL_RC_ERR_* in case of failure
+ * */
+UpplReturnCode DBConfigurationRequest::SendDeletedControllerToLogical(
+ OdbcmConnectionHandler *db_conn) {
Kt_Controller kt_ctr;
vector<void*> vec_key_ctr_modified;
// Getting the created Configuration from the database
UpplReturnCode result_code = kt_ctr.GetModifiedRows(
- vec_key_ctr_modified,
+ db_conn, vec_key_ctr_modified,
CREATED);
if (result_code != UPPL_RC_SUCCESS) {
// No created controller available
return UPPL_RC_SUCCESS;
}
-/**SendCreatedControllerToLogical()
- * @Description : This function will send the created controller
- * to logical during abort candidate db/ abort transaction
- * @param[in] : None
- * @Return : UpplReturnCode(enum)
- * **/
-UpplReturnCode DBConfigurationRequest::SendCreatedControllerToLogical() {
+/**SendCreatedControllerToLogical
+ * @Description : This function send the created controller
+ * to logical during abort candidate db/ abort transaction
+ * @param[in] : None
+ * @Return : UPPL_RC_SUCCESS if sending the controller information to
+ * logical is successful or UPPL_RC_ERR_* in case of failure
+ * */
+UpplReturnCode DBConfigurationRequest::SendCreatedControllerToLogical(
+ OdbcmConnectionHandler *db_conn) {
Kt_Controller kt_ctr;
vector<void*> vec_key_ctr_modified;
// Getting the deleted Configuration from the database
UpplReturnCode result_code = kt_ctr.GetModifiedRows(
- vec_key_ctr_modified,
+ db_conn, vec_key_ctr_modified,
DELETED);
if (result_code != UPPL_RC_SUCCESS) {
// No deleted controller available
(vec_key_ctr_modified[config_count]);
pfc_log_debug("Controller Name %s", ctr_key->controller_name);
vect_ctr_key.push_back(vec_key_ctr_modified[config_count]);
- if (kt_ctr.ReadInternal(vect_ctr_key,
+ if (kt_ctr.ReadInternal(db_conn, vect_ctr_key,
vect_ctr_val,
UNC_DT_RUNNING,
UNC_OP_READ) != UPPL_RC_SUCCESS) {
+ delete ctr_key;
+ ctr_key = NULL;
continue;
}
val_ctr_st_t *val_ctr_st =
reinterpret_cast<val_ctr_st_t*>(vect_ctr_val[0]);
if (val_ctr_st == NULL) {
+ delete ctr_key;
+ ctr_key = NULL;
continue;
}
// Sending the Controller Info. to Logical Layer with CREATE Operation
}
delete val_ctr_st;
val_ctr_st = NULL;
+ delete ctr_key;
+ ctr_key = NULL;
if (result_code != UPPL_RC_SUCCESS) {
pfc_log_error("Failed to send the info to UPLL of controller");
return UPPL_RC_ERR_LOGICAL_COMMUNICATION_FAILURE;
return UPPL_RC_SUCCESS;
}
-/**SendUpdatedControllerToLogical()
- * @Description : This function will send the updated controller
- * to logical during abort candidate db/ abort transaction
- * @param[in] : None
- * @Return : UpplReturnCode(enum)
- * **/
-UpplReturnCode DBConfigurationRequest::SendUpdatedControllerToLogical() {
+/**SendUpdatedControllerToLogical
+ * @Description : This function send the updated controller to
+ * logical during abort candidate db/ abort transaction
+ * @param[in] : None
+ * @Return : UPPL_RC_SUCCESS if sending the controller information to
+ * logical is successful or UPPL_RC_ERR_* in case of failure
+ * */
+UpplReturnCode DBConfigurationRequest::SendUpdatedControllerToLogical(
+ OdbcmConnectionHandler *db_conn) {
Kt_Controller kt_ctr;
vector<void*> vec_key_ctr_modified;
// Getting the Update Configuration from the database
UpplReturnCode result_code = kt_ctr.GetModifiedRows(
- vec_key_ctr_modified,
+ db_conn, vec_key_ctr_modified,
UPDATED);
if (result_code != UPPL_RC_SUCCESS) {
// No updated controller available
(vec_key_ctr_modified[config_count]);
pfc_log_debug("Controller Name %s", ctr_key->controller_name);
vect_ctr_key.push_back(vec_key_ctr_modified[config_count]);
- if (kt_ctr.ReadInternal(vect_ctr_key,
+ if (kt_ctr.ReadInternal(db_conn, vect_ctr_key,
vect_ctr_val,
UNC_DT_RUNNING,
UNC_OP_READ) != UPPL_RC_SUCCESS) {
+ delete ctr_key;
+ ctr_key = NULL;
continue;
}
val_ctr_st_t *val_ctr_st =
reinterpret_cast<val_ctr_st_t*>(vect_ctr_val[0]);
if (val_ctr_st == NULL) {
+ delete ctr_key;
+ ctr_key = NULL;
continue;
}
// Sending the Controller Info.to Logical Layer with Update Operation
}
delete val_ctr_st;
val_ctr_st = NULL;
+ delete ctr_key;
+ ctr_key = NULL;
+ if (result_code != UPPL_RC_SUCCESS) {
+ pfc_log_error("Failed to send the info to UPLL of controller");
+ return UPPL_RC_ERR_LOGICAL_COMMUNICATION_FAILURE;
+ }
+ }
+ return UPPL_RC_SUCCESS;
+}
+
+/**SendAppliedControllerToLogical
+ * @Description : This function send the applied controller to
+ * logical during abort candidate db/ abort transaction
+ * @param[in] : None
+ * @Return : UPPL_RC_SUCCESS if sending the controller information to
+ * logical is successful or UPPL_RC_ERR_* in case of failure
+ * */
+UpplReturnCode DBConfigurationRequest::SendAppliedControllerToLogical(
+ OdbcmConnectionHandler *db_conn) {
+ Kt_Controller kt_ctr;
+ vector<void*> vec_key_ctr_modified;
+ // Getting the deleted Configuration from the database
+ UpplReturnCode result_code = kt_ctr.GetModifiedRows(
+ db_conn, vec_key_ctr_modified,
+ APPLIED);
+ if (result_code != UPPL_RC_SUCCESS) {
+ // No deleted controller available
+ return UPPL_RC_SUCCESS;
+ }
+
+ for (uint32_t config_count = 0;
+ config_count != vec_key_ctr_modified.size(); config_count++) {
+ vector<void *> vect_ctr_key, vect_ctr_val;
+ key_ctr_t *ctr_key = reinterpret_cast<key_ctr_t*>
+ (vec_key_ctr_modified[config_count]);
+ pfc_log_debug("Controller Name %s", ctr_key->controller_name);
+ vect_ctr_key.push_back(vec_key_ctr_modified[config_count]);
+ if (kt_ctr.ReadInternal(db_conn, vect_ctr_key,
+ vect_ctr_val,
+ UNC_DT_RUNNING,
+ UNC_OP_READ) != UPPL_RC_SUCCESS) {
+ delete ctr_key;
+ ctr_key = NULL;
+ continue;
+ }
+ val_ctr_st_t *val_ctr_st =
+ reinterpret_cast<val_ctr_st_t*>(vect_ctr_val[0]);
+ if (val_ctr_st == NULL) {
+ delete ctr_key;
+ ctr_key = NULL;
+ continue;
+ }
+ // Sending the Controller Info. to Logical Layer with CREATE Operation
+ result_code = kt_ctr.SendUpdatedControllerInfoToUPLL(
+ UNC_DT_CANDIDATE,
+ UNC_OP_CREATE,
+ UNC_KT_CONTROLLER,
+ vec_key_ctr_modified[config_count],
+ reinterpret_cast<void*>(&val_ctr_st->controller));
+ // Freeing the Memory allocated in controller class
+ key_ctr_t *ctr_key_val = reinterpret_cast<key_ctr_t*>
+ (vect_ctr_key[0]);
+ if (ctr_key_val != NULL) {
+ delete ctr_key_val;
+ ctr_key_val = NULL;
+ }
+ delete val_ctr_st;
+ val_ctr_st = NULL;
+ delete ctr_key;
+ ctr_key = NULL;
if (result_code != UPPL_RC_SUCCESS) {
pfc_log_error("Failed to send the info to UPLL of controller");
return UPPL_RC_ERR_LOGICAL_COMMUNICATION_FAILURE;
/**
* @brief ImportRequest
- * @file import.cc
- *
- */
+ * @file itc_import_request.cc
+ **/
#include "itc_import_request.hh"
using unc::uppl::ImportRequest;
/**ImportRequest
- * @Description : Constructor which will initializes the member data
- * @param[in] : None
- * @Return : void
- * **/
+ * @Description : This function initializes the member data
+ * @param[in] : None
+ * @Return : None
+ * */
ImportRequest::ImportRequest() {
}
-/** ~ImportRequest()
- * @Description : Destructor to release any memory allocated to pointer member data
- * @param[in] : None
- * @Return : void
- * **/
+/**~ImportRequest
+ * @Description : This function releases memory allocated to
+ * pointer member data
+ * @param[in] : None
+ * @Return : None
+ * */
ImportRequest::~ImportRequest() {
}
-/**ProcessRequest()
- * @Description : This function receives the import request and process that request
- * @param[in] : unc_keytype_operation_t, key_struct
- * @Return : UpplReturnCode(enum)
- **/
-UpplReturnCode ImportRequest::ProcessRequest(uint32_t unc_keytype_operation_t,
+/**ProcessRequest
+ * @Description : This function receives the import request from the internal
+ * transaction coordinator and returns the processing result
+ * @param[in] : unc_keytype_operation_t - UNC_OP_* operations related to
+ * import
+ * key_struct - specifies key instance of Kt_Controller
+ * @Return : UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc
+ * response could not be added to session
+ * */
+UpplReturnCode ImportRequest::ProcessRequest(OdbcmConnectionHandler *db_conn,
+ uint32_t unc_keytype_operation_t,
key_ctr_t obj_key_ctr) {
UpplReturnCode result_code = UPPL_RC_SUCCESS;
pfc_log_info("Process the import request");
switch (unc_keytype_operation_t) {
case UNC_OP_IMPORT_CONTROLLER_CONFIG:
- result_code = StartImport(obj_key_ctr);
+ result_code = StartImport(db_conn, obj_key_ctr);
if (result_code != UPPL_RC_SUCCESS) {
pfc_log_info("Import Request:Candidate is dirty");
}
return result_code;
}
-/**StartImport()
- * @Description : This function checks whether candidate is dirty
- * @param[in] : key_struct
- * @Return : UpplReturnCode(enum)
- **/
-
-UpplReturnCode ImportRequest::StartImport(key_ctr_t obj_key_ctr) {
+/**StartImport
+ * @Description : This function is invoked when the import request comes from
+ * internal transaction coordinator.It Checks the oper_status
+ * of the controller and whether candidate is dirty or not
+ * and returns the response
+ * @param[in] : key_struct - specifies key instance of KT_Controller
+ * @Return : UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc
+ * response could not be added to session
+ * */
+UpplReturnCode ImportRequest::StartImport(OdbcmConnectionHandler *db_conn,
+ key_ctr_t obj_key_ctr) {
UpplReturnCode result_code = UPPL_RC_SUCCESS;
PhysicalCore *physical_core = PhysicalLayer::get_instance()->
get_physical_core();
Kt_Controller KtObj;
uint8_t oper_status = 0;
/* Checks controller existence and its oper status */
- pfc_log_info("Get the oper Status");
+ pfc_log_debug("Get controller oper Status");
UpplReturnCode read_status = KtObj.GetOperStatus(
- UNC_DT_RUNNING, &obj_key_ctr, oper_status);
+ db_conn, UNC_DT_RUNNING, &obj_key_ctr, oper_status);
if (read_status == UPPL_RC_SUCCESS) {
pfc_log_debug("Received oper_status %d", oper_status);
if (oper_status == UPPL_CONTROLLER_OPER_AUDITING) {
}
ODBCM_RC_STATUS db_status = ODBCM_RC_SUCCESS;
db_status = PhysicalLayer::get_instance()->get_odbc_manager()->
- IsCandidateDirty();
+ IsCandidateDirty(db_conn);
pfc_log_debug("Candidate Dirty status %d", db_status);
if (itc_trans->trans_state() != TRANS_END ||
db_status == ODBCM_RC_CANDIDATE_DIRTY) {
return result_code;
}
-/**MergeConfiguration()
- * @Description : This function returns success for Merge Import Operation.
- * @param[in] : key_struct
- * @Return : UpplReturnCode(enum)
- **/
-
+/**MergeConfiguration
+ * @Description : This function returns success for Merge
+ * configuration Operation.
+ * @param[in] : key_struct - specifies key instance of KT_Controller
+ * @Return : UPPL_RC_SUCCESS if the merge is successful
+ * */
UpplReturnCode ImportRequest::MergeConfiguration(key_ctr_t obj_key_ctr) {
UpplReturnCode result_code = UPPL_RC_SUCCESS;
pfc_log_info("Returning Success for MergeConfiguration");
return result_code;
}
-/**ClearImportConfig()
- * @Description : This function returns success for Clear import configuration
- * @param[in] : key_struct
- * @Return : UpplReturnCode(enum)
- **/
+/**ClearImportConfig
+ * @Description : This function returns success for Clear import
+ * configuration
+ * @param[in] : key_struct - specifies key instance of KT_Controller
+ * @Return : UPPL_RC_SUCCESS if the clear import configuration is
+ * successful
+ * */
UpplReturnCode ImportRequest::ClearImportConfig(key_ctr_t obj_key_ctr) {
UpplReturnCode result_code = UPPL_RC_SUCCESS;
pfc_log_info("Returning Success for ClearImportConfig");
#include "physicallayer.hh"
using unc::uppl::PhysicalLayer;
-/** Constructor
- * * @Description : This function instantiates parent and child key types for
- * kt_controller
- * * * @param[in] : None
- * * * @return : None
- * */
-Kt_Base::Kt_Base() {
-}
+map<unc_key_type_t, map<string, Kt_Class_Attr_Syntax> > Kt_Base::
+attr_syntax_map_all;
/** ValidateRequest
* * @Description : This function performs syntax and semantic validation
- * for UNC_KT_CONTROLLER
- * * * @param[in] : session_id , configuratin_id, key_struct, value_struct,
- * data_type
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR_*
+ * for a specifed KT
+ * * @param[in] : key_struct - the key for the kt instance
+ * val_struct - the val for the kt instance
+ * data_type - UNC_DT_*, read allowed in
+ * candidate/running/startup/state
+ * key_type - specifies the kt instance
+ * * @return : UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response
+ * could not be added to sess.
* */
-UpplReturnCode Kt_Base::ValidateRequest(void* key_struct,
+UpplReturnCode Kt_Base::ValidateRequest(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t operation,
uint32_t data_type,
return UPPL_RC_ERR_KEYTYPE_NOT_SUPPORTED;
}
}
- if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE ||
- operation == UNC_OP_DELETE || operation == UNC_OP_READ) {
- status = PerformSyntaxValidation(key_struct,
+ if (operation == UNC_OP_READ || operation == UNC_OP_CREATE ||
+ operation == UNC_OP_UPDATE || operation == UNC_OP_DELETE) {
+ status = PerformSyntaxValidation(db_conn, key_struct,
val_struct,
operation,
data_type);
// return the actual response
return status;
}
- status = PerformSemanticValidation(key_struct,
- val_struct,
- operation,
- data_type);
- if (status != UPPL_RC_SUCCESS) {
- // log error and send error response
- pfc_log_error("Semantic validation failed");
- // return the actual response
- return status;
+ if (operation != UNC_OP_READ) {
+ status = PerformSemanticValidation(db_conn, key_struct,
+ val_struct,
+ operation,
+ data_type);
+ if (status != UPPL_RC_SUCCESS) {
+ // log error and send error response
+ pfc_log_error("Semantic validation failed");
+ // return the actual response
+ return status;
+ }
}
}
return status;
/**Read
* * @Description : This function reads a row of KT in
- * the given table of specified data type.
- * * @param[in] : session_id - ipc session id used for TC validation
- * configuration_id - configuration id used for TC validation
- * key_struct - the key for the kt instance
- * data_type - UNC_DT_*, read allowed in candidate/running/startup/state
- * sess - ipc server session where the response has to be added
- * * @return : UPPL_RC_SUCCESS is returned when the response
- * is added to ipc session successfully.
- * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
+ * the given table of specified data type.
+ * * @param[in] : session_id - ipc session id used for TC validation
+ * configuration_id - configuration id used for TC validation
+ * key_struct - the key for the kt instance
+ * data_type - UNC_DT_*, read allowed in
+ * candidate/running/startup/state
+ * sess - ipc server session where the
+ * response has to be added
+ * option1/option2 - specifies any additional
+ * * @return : UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not
+ * be added to sess.
* */
-UpplReturnCode Kt_Base::Read(uint32_t session_id,
+UpplReturnCode Kt_Base::Read(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
ServerSession &sess,
uint32_t option1,
uint32_t option2) {
- pfc_log_debug("Inside Read of Kt_Base DT:%d", data_type);
- return PerformRead(session_id,
+ return PerformRead(db_conn, session_id,
configuration_id,
key_struct,
val_struct,
/**ReadNext
* * @Description : This function reads a next row of key instance in
- * corresponding table of specified data type.
- * * @param[in] : session_id - ipc session id used for TC validation
- * configuration_id - configuration id used for TC validation
- * key_struct - key instance
- * data_type - UNC_DT_* , readnext allowed in candidate/running/startup/state
- * sess - ipc server session where the response has to be added
- * option1/option2 - specifies any additional condition for read operation
- * * @return : UPPL_RC_SUCCESS is returned when the response
- * is added to ipc session successfully.
- * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
+ * corresponding table of specified data type.
+ * * @param[in] : session_id - ipc session id used for TC validation
+ * configuration_id - configuration id used for TC validation
+ * key_struct - key instance
+ * data_type - UNC_DT_* ,
+ * readnext allowed in candidate/running/startup/state
+ * sess - ipc server session
+ * where the response has to be added
+ * * @return : UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc
+ * response could not be added to sess.
* */
-UpplReturnCode Kt_Base::ReadNext(void* key_struct,
+UpplReturnCode Kt_Base::ReadNext(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
- uint32_t option1,
- uint32_t option2) {
+ ReadRequest *read_req) {
uint32_t max_rep_ct = 1;
- // bool is_header_added = false;
- pfc_log_info("Calling ReadBulk with max_rep_ct set as 1");
- UpplReturnCode read_status = ReadBulk(key_struct,
- data_type,
- option1,
- option2,
- max_rep_ct,
- -1,
- false,
- true);
- return read_status;
+ return ReadBulk(db_conn, key_struct,
+ data_type,
+ max_rep_ct,
+ -1,
+ false,
+ true,
+ read_req);
}
/**ReadSiblingBegin
- * * @Description : This function reads sibling rows of KT_Link in
- * link table of specified data type from the first instance
- * * @param[in] : session_id - ipc session id used for TC validation
- * configuration_id - configuration id used for TC validation
- * key_struct - the key for the kt link instance
- * data_type - UNC_DT_*, readsibling allowed in candidate/running/startup/state
- * sess - ipc server session where the response has to be added
- * option1/option2 - specifies any additional condition for read operation
- * max_rep_ct - specifies number of rows to be returned
- * * @return : UPPL_RC_SUCCESS is returned when the response
- * is added to ipc session successfully.
- * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
+ * * @Description : This function reads sibling rows of given KT object
+ * for a specified data type from the first instance
+ * * @param[in] : session_id - ipc session id used for TC validation
+ * configuration_id - configuration id used for TC validation
+ * key_struct - the key for the kt link instance
+ * data_type - UNC_DT_*, readsibling allowed in
+ * candidate/running/startup/state
+ * sess - ipc server session where the response
+ * has to be added
+ * option1/option2 - specifies any additional
+ * condition for read operation
+ * max_rep_ct - specifies number of rows to be returned
+ * * @return : UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc
+ * response could not be added to sess.
* */
-UpplReturnCode Kt_Base::ReadSiblingBegin(uint32_t session_id,
+UpplReturnCode Kt_Base::ReadSiblingBegin(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t option1,
uint32_t option2,
uint32_t &max_rep_ct) {
- UpplReturnCode read_status = UPPL_RC_SUCCESS;
- read_status = PerformRead(session_id,
- configuration_id,
- key_struct,
- val_struct,
- data_type,
- UNC_OP_READ_SIBLING_BEGIN,
- sess,
- option1,
- option2,
- max_rep_ct);
+ UpplReturnCode read_status = PerformRead(db_conn, session_id,
+ configuration_id,
+ key_struct,
+ val_struct,
+ data_type,
+ UNC_OP_READ_SIBLING_BEGIN,
+ sess,
+ option1,
+ option2,
+ max_rep_ct);
pfc_log_info("Read Sibling Begin operation return %d", read_status);
return read_status;
}
/**ReadSibling
* * @Description : This function reads sibling rows of KT in
- * the given table of specified data type.
- * * @param[in] : session_id - ipc session id used for TC validation
- * configuration_id - configuration id used for TC validation
- * key_struct - the key for the kt instance
- * data_type - UNC_DT_* , read sibling begin allowed in candidate/running/startup/state
- * sess - ipc server session where the response has to be added
- * option1/option2 - specifies any additional condition for read operation
- * max_rep_ct - specifies number of rows to be returned
- * * @return : UPPL_RC_SUCCESS is returned when the response
- * is added to ipc session successfully.
- * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
+ * the given table of specified data type.
+ * * @param[in] : session_id - ipc session id used for TC validation
+ * configuration_id - configuration id used for TC validation
+ * key_struct - the key for the kt instance
+ * data_type - UNC_DT_* , read sibling begin allowed
+ * in candidate/running/startup/state
+ * sess - ipc server session where the response has to be added
+ * option1/option2 - specifies any additional
+ * condition for read operation
+ * max_rep_ct - specifies number of rows to be returned
+ * * @return : UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response
+ * could not be added to sess.
* */
-UpplReturnCode Kt_Base::ReadSibling(uint32_t session_id,
+UpplReturnCode Kt_Base::ReadSibling(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t option1,
uint32_t option2,
uint32_t &max_rep_ct) {
- UpplReturnCode read_status = UPPL_RC_SUCCESS;
- read_status = PerformRead(session_id,
- configuration_id,
- key_struct,
- val_struct,
- data_type,
- UNC_OP_READ_SIBLING,
- sess,
- option1,
- option2,
- max_rep_ct);
+ UpplReturnCode read_status = PerformRead(db_conn, session_id,
+ configuration_id,
+ key_struct,
+ val_struct,
+ data_type,
+ UNC_OP_READ_SIBLING,
+ sess,
+ option1,
+ option2,
+ max_rep_ct);
pfc_log_info("Read Sibling operation return %d", read_status);
return read_status;
}
/**ReadSiblingCount
* * @Description : This function reads number of KT instances in
- * the given table of specified data type.
- * * @param[in] : session_id - ipc session id used for TC validation
- * configuration_id - configuration id used for TC validation
- * key_struct - the key for the kt instance
- * data_type - UNC_DT_* , read sibling count allowed in candidate/running/startup/state
- * sess - ipc server session where the response has to be added
- * option1/option2 - specifies any additional condition for read operation
- * max_rep_ct - specifies number of rows to be returned
- * * @return : UPPL_RC_SUCCESS is returned when the response
- * is added to ipc session successfully.
- * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
+ * the given table of specified data type.
+ * * @param[in] : session_id - ipc session id used for TC validation
+ * configuration_id - configuration id used for TC validation
+ * key_struct - the key for the kt instance
+ * data_type - UNC_DT_* , read sibling count allowed
+ * in candidate/running/startup/state
+ * sess - ipc server session where the response has to be added
+ * option1/option2 - specifies any additional condition
+ * for read operation
+ * max_rep_ct - specifies number of rows to be returned
+ * * @return : UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response
+ * could not be added to sess.
* */
-UpplReturnCode Kt_Base::ReadSiblingCount(uint32_t session_id,
+UpplReturnCode Kt_Base::ReadSiblingCount(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
DBTableSchema kt_dbtableschema;
vector<ODBCMOperator> vect_prim_key_operations;
void* old_value;
- PopulateDBSchemaForKtTable(kt_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_dbtableschema,
key_struct,
val_struct,
- UNC_OP_READ_SIBLING_COUNT,
+ UNC_OP_READ_SIBLING_COUNT, data_type,
option1, option2,
vect_prim_key_operations,
old_value);
read_db_status = physical_layer->get_odbc_manager()->
GetSiblingCount((unc_keytype_datatype_t)data_type,
kt_dbtableschema, count,
- vect_prim_key_operations);
+ vect_prim_key_operations, db_conn);
} else {
read_db_status = physical_layer->get_odbc_manager()-> \
GetSiblingCount((unc_keytype_datatype_t)data_type,
- kt_dbtableschema, count);
+ kt_dbtableschema, count, db_conn);
}
// count
if (read_db_status != ODBCM_RC_SUCCESS) {
/** ConfigurationChangeNotification
* * @Description : This function frames notification to be sent to NB for
- * the configuration changes done
- * * @param[in] : operation_type - UNC_OP*
- * key_struct - specifies the key instance of KT
- * old_val_struct - old value struct of kt
- * new_val_struct - new value struct of kt
- * * @return : UPPL_RC_SUCCESS is notified to northbound successfully or
- * UPPL_RC_ERR*
+ * the configuration changes done
+ * * @param[in] : date_type - UNC_DT_*
+ * operation_type - UNC_OP*
+ * key_struct - specifies the key instance of KT
+ * old_val_struct - old value struct of kt
+ * new_val_struct - new value struct of kt
+ * * @return : UPPL_RC_SUCCESS is notified to northbound successfully or
+ * UPPL_RC_ERR*
* */
UpplReturnCode Kt_Base::ConfigurationChangeNotification(
uint32_t data_type,
int err = 0;
pfc_ipcevtype_t event_type = GetEventType(key_type);
// Create ServerEvent object to be sent to NB
- ServerEvent ser_evt(event_type, err);
- err = ser_evt.addOutput(oper_type);
- err |= ser_evt.addOutput(data_type);
- err |= ser_evt.addOutput(key_type);
+ ServerEvent ser_evt((pfc_ipcevtype_t)event_type, err);
+ northbound_event_header rsh = {oper_type,
+ data_type,
+ key_type};
+ err = PhyUtil::sessOutNBEventHeader(ser_evt, rsh);
err |= AddKeyStructuretoSession(key_type,
ser_evt,
key_struct);
/** GetEventType
* * @Description : This function gets the notification type for the given kt
- * * @param[in] : key type - UNC_KT*
- * * @return : event_type - pfc_ipcevtype_t
+ * * @param[in] : key type - UNC_KT*
+ * * @return : event_type - pfc_ipcevtype_t
* */
pfc_ipcevtype_t Kt_Base::GetEventType(uint32_t key_type) {
pfc_ipcevtype_t event_type = 0;
/** AddKeyStructuretoSession
* * @Description : This function adds key structure to sever session
- * for the given kt
- * * @param[in] : key type - UNC_KT*
- * ServerSession - sess
- * key_struct - void*
- * * @return : Server Session addOutput return value
+ * for the given kt
+ * * @param[in] : key type - UNC_KT*
+ * key_struct - void*
+ * * @param[out] : ServerSession - sess
+ * * @return : Server Session addOutput return value
* */
int Kt_Base::AddKeyStructuretoSession(uint32_t key_type,
ServerSession *sess,
void *key_struct) {
- int err = 0;
- sess->addOutput((uint32_t)key_type);
+ int err = sess->addOutput((uint32_t)key_type);
switch (key_type) {
case UNC_KT_CONTROLLER: {
key_ctr_t *obj_key = reinterpret_cast<key_ctr_t*>(key_struct);
/** AddKeyStructuretoSession
* * @Description : This function adds key structure to sever event
- * for the given kt
- * * @param[in] : key type - UNC_KT*
- * ServerEvent - ser_evt
- * key_struct - void*
- * * @return : Server Event add Output return
+ * for the given kt
+ * * @param[in] : key type - UNC_KT*
+ * key_struct - void*
+ * * @param[out] : ServerSession - sess
+ * * @return : Server Event add Output return
* */
int Kt_Base::AddKeyStructuretoSession(uint32_t key_type,
ServerEvent &ser_evt,
/** AddValueStructuretoSession
* * @Description : This function adds value structure to sever event
- * for the given kt
- * * @param[in] : key type - UNC_KT*
- * operation_type - UNC_OP*
- * ServerEvent - ser_evt
- * old_val_struct - void*
- * new_val_struct - void*
- * * @return : Server Event add Output return
+ * for the given kt
+ * * @param[in] : key type - UNC_KT*
+ * operation_type - UNC_OP*
+ * old_val_struct - void*
+ * new_val_struct - void*
+ * * @param[out] : ServerEvent - ser_evt
+ * * @return : Server Event add Output return
* */
int Kt_Base::AddValueStructuretoSession(uint32_t key_type,
uint32_t oper_type,
if (oper_type == UNC_OP_CREATE) {
val_ctr_st_t new_val_st =
*(reinterpret_cast<val_ctr_st_t*>(new_val_struct));
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_ctr_t*>(&new_val_st.controller)));
} else if (oper_type == UNC_OP_UPDATE) {
val_ctr_st_t new_val_st =
*(reinterpret_cast<val_ctr_st_t*>(new_val_struct));
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_ctr_t*>(&new_val_st.controller)));
val_ctr_st_t old_val_st =
*(reinterpret_cast<val_ctr_st_t*>(old_value_struct));
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_ctr_t*>(&old_val_st.controller)));
}
break;
if (oper_type == UNC_OP_CREATE && data_type == UNC_DT_RUNNING) {
val_ctr_domain_st_t new_val_st =
*(reinterpret_cast<val_ctr_domain_st_t*>(new_val_struct));
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_ctr_domain_t*>(&new_val_st.domain)));
} else if (oper_type == UNC_OP_CREATE) {
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_ctr_domain_st_t*>(new_val_struct)));
}
if (oper_type == UNC_OP_UPDATE && data_type == UNC_DT_RUNNING) {
val_ctr_domain_st_t new_val_st =
*(reinterpret_cast<val_ctr_domain_st_t*>(new_val_struct));
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_ctr_domain_t*>(&new_val_st.domain)));
val_ctr_domain_st_t old_val_st =
*(reinterpret_cast<val_ctr_domain_st_t*>(old_value_struct));
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_ctr_domain_t*>(&old_val_st.domain)));
} else if (oper_type == UNC_OP_UPDATE) {
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_ctr_domain_st_t*>(new_val_struct)));
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_ctr_domain_st_t*>(old_value_struct)));
}
break;
}
case UNC_KT_LOGICAL_PORT: {
if (oper_type == UNC_OP_CREATE) {
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_logical_port_st_t*>(new_val_struct)));
} else if (oper_type == UNC_OP_UPDATE) {
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_logical_port_st_t*>(new_val_struct)));
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_logical_port_st_t*>(old_value_struct)));
}
break;
}
case UNC_KT_LOGICAL_MEMBER_PORT: {
if (oper_type == UNC_OP_CREATE) {
- err = ser_evt.addOutput(); // new value structure
+ err |= ser_evt.addOutput(); // new value structure
} else if (oper_type == UNC_OP_UPDATE) {
- err = ser_evt.addOutput(); // new value structure
- err = ser_evt.addOutput(); // old value structure
+ err |= ser_evt.addOutput(); // new value structure
+ err |= ser_evt.addOutput(); // old value structure
}
break;
}
case UNC_KT_SWITCH: {
if (oper_type == UNC_OP_CREATE) {
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_switch_st_t*>(new_val_struct)));
} else if (oper_type == UNC_OP_UPDATE) {
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_switch_st_t*>(new_val_struct)));
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_switch_st_t*>(old_value_struct)));
}
break;
}
case UNC_KT_PORT: {
if (oper_type == UNC_OP_CREATE) {
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_port_st_t*>(new_val_struct)));
} else if (oper_type == UNC_OP_UPDATE) {
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_port_st_t*>(new_val_struct)));
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_port_st_t*>(old_value_struct)));
}
break;
}
case UNC_KT_LINK: {
if (oper_type == UNC_OP_CREATE) {
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_link_st_t*>(new_val_struct)));
} else if (oper_type == UNC_OP_UPDATE) {
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_link_st_t*>(new_val_struct)));
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_link_st_t*>(old_value_struct)));
}
break;
if (oper_type == UNC_OP_CREATE) {
val_boundary_st_t new_val_st =
*(reinterpret_cast<val_boundary_st_t*>(new_val_struct));
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_boundary_t*>(&new_val_st.boundary)));
} else if (oper_type == UNC_OP_UPDATE) {
val_boundary_st_t new_val_st =
*(reinterpret_cast<val_boundary_st_t*>(new_val_struct));
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_boundary_t*>(&new_val_st.boundary)));
val_boundary_st_t old_val_st =
*(reinterpret_cast<val_boundary_st_t*>(old_value_struct));
- err = ser_evt.addOutput(
+ err |= ser_evt.addOutput(
*(reinterpret_cast<val_boundary_t*>(&old_val_st.boundary)));
}
break;
/** ClearValueStructure
* * @Description : This function clears value structure created in read process
- * * @param[in] : key type - UNC_KT*
- * old_val_struct - void*
- * * @return : None
+ * * @param[in] : key type - UNC_KT*
+ * old_val_struct - void*
+ * * @return : void
* */
void Kt_Base::ClearValueStructure(uint32_t key_type,
- void *old_value_struct) {
+ void *&old_value_struct) {
switch (key_type) {
case UNC_KT_CONTROLLER: {
val_ctr_st_t *old_val_kt =
UpplReturnCode Kt_Base::ValidateKtState(uint32_t operation,
uint32_t data_type) {
- if ( (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE ||
- operation == UNC_OP_DELETE) && data_type != UNC_DT_STATE &&
- data_type != UNC_DT_IMPORT) {
- pfc_log_error("Configuration operation only allowed in STATE DB");
- return UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
- } else if (operation >= UNC_OP_READ && data_type != UNC_DT_STATE) {
+ if (operation >= UNC_OP_READ && data_type != UNC_DT_STATE) {
pfc_log_error(
"Read operations are not allowed in requested data type");
return UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
- } else if (!(operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE ||
- operation == UNC_OP_DELETE || operation >= UNC_OP_READ)) {
+ } else if ( data_type != UNC_DT_STATE &&
+ (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE ||
+ operation == UNC_OP_DELETE) &&
+ data_type != UNC_DT_IMPORT) {
+ pfc_log_error("Configuration operation only allowed in STATE DB");
+ return UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
+ } else if (!(operation >= UNC_OP_READ ||
+ operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE ||
+ operation == UNC_OP_DELETE)) {
pfc_log_error("Invalid operation type");
return UPPL_RC_ERR_OPERATION_NOT_SUPPORTED;
}
return UPPL_RC_SUCCESS;
}
+
+UpplReturnCode Kt_Base::get_oper_status(
+ vector<OperStatusHolder> &ref_oper_status,
+ unc_key_type_t key_type,
+ void* key_struct,
+ uint8_t &oper_status) {
+ size_t key_struct_size = 0;
+ switch (key_type) {
+ case UNC_KT_CONTROLLER:
+ key_struct_size = sizeof(key_ctr_t);
+ break;
+ case UNC_KT_CTR_DOMAIN:
+ key_struct_size = sizeof(key_ctr_domain_t);
+ break;
+ case UNC_KT_LOGICAL_PORT:
+ key_struct_size = sizeof(key_logical_port_t);
+ break;
+ case UNC_KT_SWITCH:
+ key_struct_size = sizeof(key_switch_t);
+ break;
+ case UNC_KT_PORT:
+ key_struct_size = sizeof(key_port_t);
+ break;
+ case UNC_KT_LINK:
+ key_struct_size = sizeof(key_link_t);
+ break;
+ case UNC_KT_BOUNDARY:
+ key_struct_size = sizeof(key_boundary_t);
+ break;
+ default:
+ break;
+ }
+ vector<OperStatusHolder>::iterator iter = ref_oper_status.begin();
+ for (; iter != ref_oper_status.end(); ++iter) {
+ OperStatusHolder kt_oper_status = (*iter);
+ if (kt_oper_status.get_key_type() == key_type &&
+ (memcmp(kt_oper_status.get_key_struct(),
+ key_struct, key_struct_size) == 0) ) {
+ oper_status = kt_oper_status.get_oper_status();
+ pfc_log_debug("Returning oper_status from internal structure %d",
+ oper_status);
+ return UPPL_RC_SUCCESS;
+ }
+ }
+ pfc_log_debug("oper_status not found in internal structure");
+ return UPPL_RC_ERR_NO_SUCH_INSTANCE;
+}
+
+void Kt_Base::ClearOperStatusHolder(vector<OperStatusHolder> &ref_oper_status) {
+ vector<OperStatusHolder>::iterator iter = ref_oper_status.begin();
+ for (; iter != ref_oper_status.end(); ++iter) {
+ OperStatusHolder kt_oper_status = (*iter);
+ switch (kt_oper_status.get_key_type()) {
+ case UNC_KT_CONTROLLER: {
+ key_ctr_t *ctr_key =
+ reinterpret_cast<key_ctr_t*>(kt_oper_status.get_key_struct());
+ if (ctr_key != NULL) {
+ delete ctr_key;
+ ctr_key = NULL;
+ }
+ }
+ break;
+ case UNC_KT_CTR_DOMAIN: {
+ key_ctr_domain_t *ctr_domain_key =
+ reinterpret_cast<key_ctr_domain_t*>
+ (kt_oper_status.get_key_struct());
+ if (ctr_domain_key != NULL) {
+ delete ctr_domain_key;
+ ctr_domain_key = NULL;
+ }
+ }
+ break;
+ case UNC_KT_LOGICAL_PORT: {
+ key_logical_port_t *log_port_key =
+ reinterpret_cast<key_logical_port_t*>
+ (kt_oper_status.get_key_struct());
+ if (log_port_key != NULL) {
+ delete log_port_key;
+ log_port_key = NULL;
+ }
+ }
+ break;
+ case UNC_KT_SWITCH: {
+ key_switch_t *switch_key = reinterpret_cast<key_switch_t*>
+ (kt_oper_status.get_key_struct());
+ if (switch_key != NULL) {
+ delete switch_key;
+ switch_key = NULL;
+ }
+ }
+ break;
+ case UNC_KT_PORT: {
+ key_port_t *port_key = reinterpret_cast<key_port_t*>
+ (kt_oper_status.get_key_struct());
+ if (port_key != NULL) {
+ delete port_key;
+ port_key = NULL;
+ }
+ }
+ break;
+ case UNC_KT_LINK: {
+ key_link_t *link_key = reinterpret_cast<key_link_t*>
+ (kt_oper_status.get_key_struct());
+ if (link_key != NULL) {
+ delete link_key;
+ link_key = NULL;
+ }
+ }
+ break;
+ case UNC_KT_BOUNDARY: {
+ key_boundary_t *bdry_key = reinterpret_cast<key_boundary_t*>
+ (kt_oper_status.get_key_struct());
+ if (bdry_key != NULL) {
+ delete bdry_key;
+ bdry_key = NULL;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ ref_oper_status.clear();
+ return;
+}
#include "itc_kt_logicalport.hh"
#include "odbcm_db_varbind.hh"
#include "ipct_util.hh"
+#include "itc_read_request.hh"
using unc::uppl::PhysicalLayer;
+#define DEFAULT_DOMAIN "(DEFAULT)"
+
/** Constructor
* * @Description : This function fills the syntax map used for validation
* * @param[in] : None
* * @return : None
**/
Kt_Boundary::Kt_Boundary() {
- /* Parent will be initialized inside member functions whenever required */
- parent = NULL;
- // Populate structure to be used for syntax validation
- Fill_Attr_Syntax_Map();
+ if (attr_syntax_map_all.find(UNC_KT_BOUNDARY) ==
+ attr_syntax_map_all.end()) {
+ // Populate structure to be used for syntax validation
+ Fill_Attr_Syntax_Map();
+ }
}
/** Destructor
- * * @Description : This function frees the parent
+ * * @Description : Empty Destructor
* * @param[in] : None
* * @return : None
**/
Kt_Boundary::~Kt_Boundary() {
- if (parent != NULL)
- delete parent;
- parent = NULL;
}
/** Create
* is added to ipc session successfully.
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_Boundary::Create(uint32_t session_id,
+UpplReturnCode Kt_Boundary::Create(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
data_type);
create_status = UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
} else {
- create_status = CreateKeyInstance(key_struct, val_struct, data_type,
- UNC_KT_BOUNDARY);
+ create_status = CreateKeyInstance(db_conn, key_struct, val_struct,
+ data_type, UNC_KT_BOUNDARY);
pfc_log_debug("Calling CreateKeyInstance, returned %d", create_status);
}
/** CreateKeyInstance
* * @Description : This function creates a new row of KT_Boundary in
* candidate boundary table.
- * key_struct - the key for the new kt boundary instance
+ * param[in]:key_struct - the key for the new kt boundary instance
* value_struct - the values for the new kt boundary instance
* data_type - UNC_DT_* , Create only allowed in candidate
- * * @return : UPPL_RC_SUCCESS is returned when the create is success
+ * key_type-UNC_KT_BOUNDARY,value of unc_key_type_t
+ * @return : UPPL_RC_SUCCESS is returned when the create is success
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_Boundary::CreateKeyInstance(void* key_struct,
+UpplReturnCode Kt_Boundary::CreateKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t key_type) {
vector<ODBCMOperator> vect_key_operations;
void* old_val_struct;
// Create DBSchema structure for boundary table
- PopulateDBSchemaForKtTable(kt_boundary_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_boundary_dbtableschema,
key_struct,
val_struct,
- UNC_OP_CREATE, 0, 0,
+ UNC_OP_CREATE, data_type, 0, 0,
vect_key_operations, old_val_struct);
// Send request to ODBC for boundary_table create
ODBCM_RC_STATUS create_db_status = physical_layer->get_odbc_manager()->\
CreateOneRow((unc_keytype_datatype_t)data_type,
- kt_boundary_dbtableschema);
- pfc_log_info("CreateOneRow response from DB is %d", create_db_status);
+ kt_boundary_dbtableschema, db_conn);
if (create_db_status != ODBCM_RC_SUCCESS) {
if (create_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log fatal error to log daemon
}
/** Update
- * * @Description : This function updates a row of KT_Boundary in
+ * @Description : This function updates a row of KT_Boundary in
* candidate boundary table.
- * * @param[in] : session_id - ipc session id used for TC validation
+ * @param[in] : session_id - ipc session id used for TC validation
* configuration_id - configuration id used for TC validation
* key_struct - the key for the kt boundary instance
* value_struct - the values for the kt boundary instance
* data_type - UNC_DT_* , Update only allowed in candidate
* sess - ipc server session where the response has to be added
- * * @return : UPPL_RC_SUCCESS is returned when the response
+ * @return : UPPL_RC_SUCCESS is returned when the response
* is added to ipc session successfully.
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_Boundary::Update(uint32_t session_id,
+UpplReturnCode Kt_Boundary::Update(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
// Create DBSchema structure for boundary_table
vector<ODBCMOperator> vect_key_operations;
void* old_val_struct;
- PopulateDBSchemaForKtTable(kt_boundary_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_boundary_dbtableschema,
key_struct,
val_struct,
- UNC_OP_UPDATE, 0, 0,
+ UNC_OP_UPDATE, data_type, 0, 0,
vect_key_operations, old_val_struct);
if (!((kt_boundary_dbtableschema.get_row_list()).empty())) {
// Send request to ODBC for Boundary_common_table update
ODBCM_RC_STATUS update_db_status = physical_layer->get_odbc_manager()->
UpdateOneRow((unc_keytype_datatype_t)data_type,
- kt_boundary_dbtableschema);
- pfc_log_info("UpdateOneRow response from DB is %d", update_db_status);
+ kt_boundary_dbtableschema, db_conn);
if (update_db_status != ODBCM_RC_SUCCESS &&
update_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log fatal error to log daemon
* is added to ipc session successfully.
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_Boundary::Delete(uint32_t session_id,
+UpplReturnCode Kt_Boundary::Delete(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
uint32_t data_type,
// Construct Primary key list
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(BDRY_ID);
+ vect_prim_keys.push_back(BDRY_ID_STR);
// construct TableAttrSchema structure
// TableAttrSchema holds table_name, primary key, attr_name
- TableAttrSchema kt_boundary_table_attr_schema;
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
// boundary_id
- PhyUtil::FillDbSchema(BDRY_ID, boundary_id, boundary_id.length(),
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_ID, boundary_id, boundary_id.length(),
DATATYPE_UINT8_ARRAY_32, vect_table_attr_schema);
// Send request to ODBC for Boundary_common_table delete
- kt_boundary_dbtableschema.set_table_name(UPPL_BOUNDARY_TABLE);
+ kt_boundary_dbtableschema.set_table_name(unc::uppl::BOUNDARY_TABLE);
kt_boundary_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_boundary_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS delete_db_status = physical_layer->get_odbc_manager()->
DeleteOneRow((unc_keytype_datatype_t)data_type,
- kt_boundary_dbtableschema);
- pfc_log_info("DeleteOneRow response from DB is %d", delete_db_status);
+ kt_boundary_dbtableschema, db_conn);
if (delete_db_status != ODBCM_RC_SUCCESS) {
if (delete_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log fatal error to log daemon
} else {
pfc_log_info("Delete of a boundary in data_type(%d) is success",
data_type);
+ delete_status = UPPL_RC_SUCCESS;
}
}
// Populate the response to be sent in ServerSession
}
/** ReadInternal
- * * @Description : This function reads the given instance of KT_Boundary
- ** * @param[in] : session_id - ipc session id used for TC validation
- * key_struct - the key for the kt boundary instance
- * value_struct - the value for the kt boundary instance
+ * @Description : This function reads the given instance of KT_Boundary
+ * @param[in] :
+ * boundary_key - vector of void* to the key for the kt boundary instance
+ * boundary_val - vector of void* to the value for the kt boundary instance
* data_type - UNC_DT_* , read allowed in candidate/running/startup/state
- * * @return : UPPL_RC_SUCCESS is returned when the response
+ * operation_type-UNC_OP_*,type of operation
+ * @return : UPPL_RC_SUCCESS is returned when the response
* is added to ipc session successfully.
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_Boundary::ReadInternal(vector<void *> &boundary_key,
+UpplReturnCode Kt_Boundary::ReadInternal(OdbcmConnectionHandler *db_conn,
+ vector<void *> &boundary_key,
vector<void *> &boundary_val,
uint32_t data_type,
uint32_t operation_type) {
pfc_log_debug("Processing Kt_Boundary::ReadInternal");
vector<key_boundary_t> vect_boundary_id;
vector<val_boundary_st_t> vect_val_boundary_st;
- vector<val_boundary_t> vect_val_boundary;
uint32_t max_rep_ct = 1;
if (operation_type != UNC_OP_READ) {
// Get read response from database
}
// Get read response from database
- UpplReturnCode read_status = ReadBoundaryValFromDB(key_struct,
+ UpplReturnCode read_status = ReadBoundaryValFromDB(db_conn,
+ key_struct,
val_struct,
data_type,
operation_type,
max_rep_ct,
vect_boundary_id,
- vect_val_boundary,
vect_val_boundary_st);
boundary_key.clear();
boundary_val.clear();
}
/** ReadBulk
- * * @Description : This function reads bulk rows of KT_Boundary in
+ * @Description : This function reads bulk rows of KT_Boundary in
* boundary table of specified data type.
- * * @param[in] :
+ * @param[in] :
* key_struct - the key for the kt boundary instance
* data_type - UNC_DT_* , read allowed in candidate/running/startup/state
- * option1/option2 - specifies any additional condition for read operation
* max_rep_ct - specifies number of rows to be returned
* parent_call - indicates whether parent has called this readbulk
* is_read_next - indicates whether this function is invoked from readnext
- * * @return : UPPL_RC_SUCCESS is returned when the response
+ * @return : UPPL_RC_SUCCESS is returned when the response
* is added to ipc session successfully.
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_Boundary::ReadBulk(void* key_struct,
+UpplReturnCode Kt_Boundary::ReadBulk(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
- uint32_t option1,
- uint32_t option2,
uint32_t &max_rep_ct,
int child_index,
pfc_bool_t parent_call,
- pfc_bool_t is_read_next) {
+ pfc_bool_t is_read_next,
+ ReadRequest *read_req) {
pfc_log_info("Processing ReadBulk of Kt_Boundary");
UpplReturnCode read_status = UPPL_RC_SUCCESS;
if (data_type != UNC_DT_CANDIDATE && data_type != UNC_DT_RUNNING &&
void *val_struct = NULL;
vector<key_boundary_t> vect_key_boundary;
read_status = ReadBulkInternal(
- key_struct,
+ db_conn, key_struct,
val_struct,
data_type,
max_rep_ct,
pfc_log_debug("read_status from ReadBulkInternal is %d with key size %d",
read_status, static_cast<int>(vect_key_boundary.size()));
if (read_status != UPPL_RC_SUCCESS) {
- pfc_log_debug("Boundary read internal is not success");
+ pfc_log_debug("Boundary read bulk internal is not success");
+ if (read_status == UPPL_RC_ERR_DB_ACCESS) {
+ pfc_log_debug("KtBoundary ReadBulk - Returning DB Access Error");
+ return read_status;
+ }
return UPPL_RC_SUCCESS;
}
- PhysicalCore *physical_core = PhysicalLayer::get_instance()->
- get_physical_core();
- InternalTransactionCoordinator *itc_trans =
- physical_core->get_internal_transaction_coordinator();
vector<key_boundary_t> ::iterator boundary_iter =
vect_key_boundary.begin();
vector<val_boundary_st_t> ::iterator vect_iter =
UNC_KT_BOUNDARY, IS_KEY,
reinterpret_cast<void *>(key_buffer)
};
- itc_trans->AddToBuffer(obj_key_buffer);
+ read_req->AddToBuffer(obj_key_buffer);
if ((unc_keytype_datatype_t)data_type == UNC_DT_STATE) {
val_boundary_st_t *val_buffer =
new val_boundary_st_t(*vect_iter);
UNC_KT_BOUNDARY, IS_STATE_VALUE,
reinterpret_cast<void *>(val_buffer)
};
- itc_trans->AddToBuffer(obj_value_buffer);
+ read_req->AddToBuffer(obj_value_buffer);
} else {
val_boundary_t *val_buffer =
new val_boundary_t((*vect_iter).boundary);
UNC_KT_BOUNDARY, IS_VALUE,
reinterpret_cast<void *>(val_buffer)
};
- itc_trans->AddToBuffer(obj_value_buffer);
+ read_req->AddToBuffer(obj_value_buffer);
}
BulkReadBuffer obj_sep_buffer = {
UNC_KT_BOUNDARY, IS_SEPARATOR, NULL
};
- itc_trans->AddToBuffer(obj_sep_buffer);
+ read_req->AddToBuffer(obj_sep_buffer);
--max_rep_ct;
if (max_rep_ct == 0) {
return UPPL_RC_SUCCESS;
}
/** ReadBulkInternal
- * * @Description : This function reads bulk rows of KT_Boundary in
+ * @Description : This function reads bulk rows of KT_Boundary in
* bounndary table of specified data type.
- * * @param[in] :
+ * @param[in] :
* key_struct - the key for the kt boundary instance
* val_struct - the value struct for kt_boundary instance
* max_rep_ct - specifies number of rows to be returned
+ * vect_key_boundary-indicates the fetched keys from db of val_boundary type
* vect_val_boundary - indicates the fetched values
* from db of val_boundary type
- * * @return : UPPL_RC_SUCCESS is returned when the response
+ * @return : UPPL_RC_SUCCESS is returned when the response
* is added to ipc session successfully.
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
UpplReturnCode Kt_Boundary::ReadBulkInternal(
+ OdbcmConnectionHandler *db_conn,
void* key_struct,
void *val_struct,
uint32_t data_type,
vector<ODBCMOperator> vect_key_operations;
void* old_val_struct;
// Populate DBSchema for boundary_table
- PopulateDBSchemaForKtTable(kt_boundary_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_boundary_dbtableschema,
key_struct,
val_struct,
- UNC_OP_READ_BULK, 0, 0,
+ UNC_OP_READ_BULK, data_type, 0, 0,
vect_key_operations, old_val_struct);
// Read rows from DB
read_db_status = physical_layer->get_odbc_manager()-> \
GetBulkRows((unc_keytype_datatype_t)data_type, max_rep_ct,
kt_boundary_dbtableschema,
- (unc_keytype_operation_t)UNC_OP_READ_BULK);
+ (unc_keytype_operation_t)UNC_OP_READ_BULK, db_conn);
if (read_db_status == ODBCM_RC_RECORD_NOT_FOUND) {
pfc_log_debug("No record found");
read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
return read_status;
+ } else if (read_db_status == ODBCM_RC_CONNECTION_ERROR) {
+ read_status = UPPL_RC_ERR_DB_ACCESS;
+ pfc_log_error("Read operation has failed with error %d", read_db_status);
+ return read_status;
} else if (read_db_status != ODBCM_RC_SUCCESS) {
// log error to log daemon
- pfc_log_error("Read operation has failed");
+ pfc_log_error("Read operation has failed with error %d", read_db_status);
read_status = UPPL_RC_ERR_DB_GET;
return read_status;
}
// From the values received from DB, populate val_boundary structure
- FillBoundaryValueStructure(kt_boundary_dbtableschema,
+ FillBoundaryValueStructure(db_conn, kt_boundary_dbtableschema,
vect_key_boundary,
vect_val_boundary,
max_rep_ct);
}
/** PerformSyntaxValidation
- * * @Description : This function performs syntax validation for
+ * @Description : This function performs syntax validation for
* UNC_KT_BOUNDARY
- * * * @param[in]
+ * @param[in]
* key_struct - the key for the kt boundary instance
* value_struct - the value for the kt boundary instance
- * data_type - UNC_DT_*
- * operation_type - UNC_OP*
- * * @return : UPPL_RC_SUCCESS is returned when the validation is successful
- * UPPL_RC_ERR_* is returned when validtion is failure
+ * data_type - UNC_DT_*,type of database
+ * operation_type - UNC_OP*,type of operation
+ * @return : UPPL_RC_SUCCESS is returned when the validation is successful
+ * UPPL_RC_ERR_* is returned when validation is failure
* */
-UpplReturnCode Kt_Boundary::PerformSyntaxValidation(void* key_struct,
- void* val_struct,
- uint32_t operation,
- uint32_t data_type) {
+UpplReturnCode Kt_Boundary::PerformSyntaxValidation(
+ OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ void* val_struct,
+ uint32_t operation,
+ uint32_t data_type) {
pfc_log_info("Performing Syntax Validation of KT_BOUNDARY");
UpplReturnCode ret_code = UPPL_RC_SUCCESS;
// Validate key structure
key_boundary_t *key = reinterpret_cast<key_boundary_t*>(key_struct);
string value = reinterpret_cast<char*>(key->boundary_id);
- IS_VALID_STRING_KEY(BDRY_ID, value, operation, ret_code, mandatory);
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map =
+ attr_syntax_map_all[UNC_KT_BOUNDARY];
+ IS_VALID_STRING_KEY(BDRY_ID_STR, value, operation, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
valid_val =
PhyUtil::uint8touint(val_bdry->valid[kIdxBoundaryDescription]);
string value = reinterpret_cast<char*>(val_bdry->description);
- IS_VALID_STRING_VALUE(BDRY_DESCRIPTION, value, operation,
+ IS_VALID_STRING_VALUE(BDRY_DESCRIPTION_STR, value, operation,
valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
unsigned int ctr1_valid_val =
PhyUtil::uint8touint(val_bdry->valid[kIdxBoundaryControllerName1]);
value = reinterpret_cast<char*>(val_bdry->controller_name1);
- IS_VALID_STRING_VALUE(BDRY_CTR_NAME1, value, operation,
+ IS_VALID_STRING_VALUE(BDRY_CTR_NAME1_STR, value, operation,
ctr1_valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
unsigned int dmn1_valid_val =
PhyUtil::uint8touint(val_bdry->valid[kIdxBoundaryDomainName1]);
value = reinterpret_cast<char*>(val_bdry->domain_name1);
- IS_VALID_STRING_VALUE(BDRY_DM_NAME1, value, operation,
+ IS_VALID_STRING_VALUE(BDRY_DM_NAME1_STR, value, operation,
dmn1_valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
valid_val =
PhyUtil::uint8touint(val_bdry->valid[kIdxBoundaryLogicalPortId1]);
value = reinterpret_cast<char*>(val_bdry->logical_port_id1);
- IS_VALID_STRING_VALUE(BDRY_PORT_ID1, value, operation,
+ IS_VALID_STRING_VALUE(BDRY_PORT_ID1_STR, value, operation,
valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
unsigned int ctr2_valid_val =
PhyUtil::uint8touint(val_bdry->valid[kIdxBoundaryControllerName2]);
value = reinterpret_cast<char*>(val_bdry->controller_name2);
- IS_VALID_STRING_VALUE(BDRY_CTR_NAME2, value, operation,
+ IS_VALID_STRING_VALUE(BDRY_CTR_NAME2_STR, value, operation,
ctr2_valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
unsigned int dmn2_valid_val =
PhyUtil::uint8touint(val_bdry->valid[kIdxBoundaryDomainName2]);
value = reinterpret_cast<char*>(val_bdry->domain_name2);
- IS_VALID_STRING_VALUE(BDRY_DM_NAME2, value, operation,
+ IS_VALID_STRING_VALUE(BDRY_DM_NAME2_STR, value, operation,
dmn2_valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
valid_val =
PhyUtil::uint8touint(val_bdry->valid[kIdxBoundaryLogicalPortId2]);
value = reinterpret_cast<char*>(val_bdry->logical_port_id2);
- IS_VALID_STRING_VALUE(BDRY_PORT_ID2, value, operation,
+ IS_VALID_STRING_VALUE(BDRY_PORT_ID2_STR, value, operation,
valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
/** PerformSemanticValidation
- * * @Description : This function performs semantic validation
+ * @Description : This function performs semantic validation
* for UNC_KT_BOUNDARY
- * * * @param[in] : key_struct - specifies key instance of KT_Boundary
- * , value_struct - specifies value of KT_BOUNDARY
- * operation - UNC_OP*
- * data_type - UNC_DT*
- * * * @return : UPPL_RC_SUCCESS if semantic valition is successful
+ * @param[in] : key_struct - specifies key instance of KT_Boundary
+ * value_struct - specifies value of KT_BOUNDARY
+ * operation - UNC_OP*,type of operation
+ * data_type - UNC_DT*,type of database
+ * @return : UPPL_RC_SUCCESS if semantic valition is successful
* or UPPL_RC_ERR_* if failed
* */
-UpplReturnCode Kt_Boundary::PerformSemanticValidation(void* key_struct,
- void* val_struct,
- uint32_t operation,
- uint32_t data_type) {
+UpplReturnCode Kt_Boundary::PerformSemanticValidation(
+ OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ void* val_struct,
+ uint32_t operation,
+ uint32_t data_type) {
UpplReturnCode status = UPPL_RC_SUCCESS;
pfc_log_debug("Inside PerformSemanticValidation of KT_BOUNDARY");
key_boundary_t *obj_key_boundary
string boundary_id = (const char*)obj_key_boundary->boundary_id;
vector<string> boundary_vect_key_value;
boundary_vect_key_value.push_back(boundary_id);
- UpplReturnCode key_status = IsKeyExists((unc_keytype_datatype_t)data_type,
+ UpplReturnCode key_status = IsKeyExists(db_conn,
+ (unc_keytype_datatype_t)data_type,
boundary_vect_key_value);
pfc_log_debug("IsKeyExists status %d", key_status);
// In case of create operation, key should not exist
unsigned int ctr1_valid_val =
PhyUtil::uint8touint(obj_boundary_val->
valid[kIdxBoundaryControllerName1]);
- string controller_name1;
+ unsigned int lp1_valid_val =
+ PhyUtil::uint8touint(obj_boundary_val->
+ valid[kIdxBoundaryLogicalPortId1]);
+ unsigned int dmn1_valid_val =
+ PhyUtil::uint8touint(obj_boundary_val->
+ valid[kIdxBoundaryDomainName1]);
+ string controller_name1 = "";
if (ctr1_valid_val == UNC_VF_VALID) {
controller_name1 = (const char*)obj_boundary_val->controller_name1;
unc_keytype_ctrtype_t type = UNC_CT_UNKNOWN;
UpplReturnCode ctr_type_status =
- PhyUtil::get_controller_type(controller_name1,
+ PhyUtil::get_controller_type(db_conn, controller_name1,
type,
(unc_keytype_datatype_t) data_type);
if (ctr_type_status != UPPL_RC_SUCCESS) {
}
pfc_log_debug("Controller1 type: %d", type);
if (type != (unc_keytype_ctrtype_t) UNC_CT_UNKNOWN) {
- unsigned int valid_val =
- PhyUtil::uint8touint(obj_boundary_val->
- valid[kIdxBoundaryLogicalPortId1]);
- pfc_log_debug("logical port valid %d", valid_val);
+ pfc_log_debug("logical port valid %d", lp1_valid_val);
string logical_port_id1 =
(const char*)obj_boundary_val->logical_port_id1;
- if (valid_val == UNC_VF_INVALID || logical_port_id1.empty()) {
- pfc_log_debug("logical port not valid/null for controller %s",
- controller_name1.c_str());
+ if (lp1_valid_val == UNC_VF_INVALID || logical_port_id1.empty()) {
+ pfc_log_info("logical port not valid/null for controller %s",
+ controller_name1.c_str());
+ return UPPL_RC_ERR_CFG_SEMANTIC;
+ }
+ } else {
+ // validate domain name
+ pfc_log_debug("Domain1 valid %d", dmn1_valid_val);
+ string domain_name1 =
+ (const char*)obj_boundary_val->domain_name1;
+ if (dmn1_valid_val == UNC_VF_VALID && domain_name1 == DEFAULT_DOMAIN) {
+ pfc_log_info("Default domain cannot be given for bypass controller %s",
+ controller_name1.c_str());
return UPPL_RC_ERR_CFG_SEMANTIC;
}
}
unsigned int ctr2_valid_val =
PhyUtil::uint8touint(obj_boundary_val->
valid[kIdxBoundaryControllerName2]);
+ unsigned int lp2_valid_val =
+ PhyUtil::uint8touint(obj_boundary_val->
+ valid[kIdxBoundaryLogicalPortId2]);
+ unsigned int dmn2_valid_val =
+ PhyUtil::uint8touint(obj_boundary_val->
+ valid[kIdxBoundaryDomainName2]);
string controller_name2;
if (ctr2_valid_val == UNC_VF_VALID) {
controller_name2 = (const char*)obj_boundary_val->controller_name2;
unc_keytype_ctrtype_t type = UNC_CT_UNKNOWN;
UpplReturnCode ctr_type_status =
- PhyUtil::get_controller_type(controller_name2,
+ PhyUtil::get_controller_type(db_conn, controller_name2,
type,
(unc_keytype_datatype_t) data_type);
if (ctr_type_status != UPPL_RC_SUCCESS) {
}
pfc_log_debug("Controller2 type :%d ", type);
if (type != (unc_keytype_ctrtype_t) UNC_CT_UNKNOWN) {
- unsigned int valid_val =
- PhyUtil::uint8touint(obj_boundary_val->
- valid[kIdxBoundaryLogicalPortId2]);
- pfc_log_debug("logical port valid %d", valid_val);
+ pfc_log_debug("logical port valid %d", lp2_valid_val);
string logical_port_id2 =
(const char*)obj_boundary_val->logical_port_id2;
- if (valid_val == UNC_VF_INVALID || logical_port_id2.empty()) {
- pfc_log_debug("logicalport2 not valid/null for controller %s",
- controller_name2.c_str());
+ if (lp2_valid_val == UNC_VF_INVALID || logical_port_id2.empty()) {
+ pfc_log_info("logicalport2 not valid/null for controller %s",
+ controller_name2.c_str());
+ return UPPL_RC_ERR_CFG_SEMANTIC;
+ }
+ } else {
+ // validate domain name
+ pfc_log_debug("Domain2 valid %d", dmn2_valid_val);
+ string domain_name2 =
+ (const char*)obj_boundary_val->domain_name2;
+ if (dmn2_valid_val == UNC_VF_VALID && domain_name2 == DEFAULT_DOMAIN) {
+ pfc_log_info("Default domain cannot be given for bypass controller %s",
+ controller_name2.c_str());
return UPPL_RC_ERR_CFG_SEMANTIC;
}
}
}
- unsigned int dmn1_valid_val =
- PhyUtil::uint8touint(obj_boundary_val->
- valid[kIdxBoundaryDomainName1]);
+
string domain_name1;
if (dmn1_valid_val == UNC_VF_VALID) {
domain_name1 = (const char*)obj_boundary_val->domain_name1;
}
-
- unsigned int dmn2_valid_val =
- PhyUtil::uint8touint(obj_boundary_val->
- valid[kIdxBoundaryDomainName2]);
string domain_name2;
if (dmn2_valid_val == UNC_VF_VALID) {
domain_name2 = (const char*)obj_boundary_val->domain_name2;
"Controller name1, Controller name2 "
"and domain name1, domain name2 are same");
status = UPPL_RC_ERR_CFG_SEMANTIC;
+ pfc_log_debug("Return Code SemanticValidation: %d", status);
+ return status;
}
+ status = CheckBoundaryExistence(db_conn, key_struct, val_struct, data_type);
pfc_log_debug("Return Code SemanticValidation: %d", status);
return status;
}
/** PopulateDBSchemaForKtTable
* @Description : This function populates the DBAttrSchema to be used to
* send request to ODBC
- * * @param[in] : DBTableSchema, key_struct, val_struct, operation_type
- * * * *@return : void
+ * @param[in] :
+ * kt_boundary_dbtableschema-DBTableSchema instance of Boundary to be filled
+ * key_struct-void* to bdry key structure
+ * val_struct-void* to bdry val structure
+ * operation_type-UNC_OP_*,type of operation
+ * option1,option2-UNC_OPT1/OPT2_*,additional options for read operation
+ * vect_key_operations-vector<ODBCMOperator> instance
+ * row_status-CsRowStatus value
+ * is_filtering-flag to indicate whether filter option enabled
+ * is_state-flag to indicate whether datatype is ST_STATE
+ * @return : void
**/
void Kt_Boundary::PopulateDBSchemaForKtTable(
+ OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_boundary_dbtableschema,
void* key_struct,
void* val_struct,
uint8_t operation_type,
+ uint32_t data_type,
uint32_t option1,
uint32_t option2,
vector<ODBCMOperator> &vect_key_operations,
// Construct Primary key list
vector<string> vect_prim_keys;
- // construct TableAttrSchema structuree
+ // construct TableAttrSchema structure
// TableAttrSchema holds table_name, primary key, attr_name
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
if (operation_type == UNC_OP_UPDATE) {
// get valid array for update request
pfc_log_debug("Get Valid value from DB");
- GetBoundaryValidFlag(key_struct, val_boundary_valid_st);
+ GetBoundaryValidFlag(db_conn, key_struct, val_boundary_valid_st, data_type);
}
string value;
// description
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(BDRY_DESCRIPTION, value,
- value.length(), DATATYPE_UINT8_ARRAY_128,
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_DESCRIPTION, BDRY_DESCRIPTION_STR,
+ value, value.length(), DATATYPE_UINT8_ARRAY_128,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
value.clear();
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(BDRY_CTR_NAME1, value,
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_CTR_NAME1, BDRY_CTR_NAME1_STR, value,
value.length(), DATATYPE_UINT8_ARRAY_32,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(BDRY_DM_NAME1, value,
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_DM_NAME1, BDRY_DM_NAME1_STR, value,
value.length(), DATATYPE_UINT8_ARRAY_32,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(BDRY_PORT_ID1, value,
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_PORT_ID1, BDRY_PORT_ID1_STR, value,
value.length(), DATATYPE_UINT8_ARRAY_320,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(BDRY_CTR_NAME2, value,
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_CTR_NAME2, BDRY_CTR_NAME2_STR, value,
value.length(), DATATYPE_UINT8_ARRAY_32,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(BDRY_DM_NAME2, value,
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_DM_NAME2, BDRY_DM_NAME2_STR, value,
value .length(), DATATYPE_UINT8_ARRAY_32,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(BDRY_PORT_ID2, value,
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_PORT_ID2, BDRY_PORT_ID2_STR, value,
value.length(), DATATYPE_UINT8_ARRAY_320,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
- vect_prim_keys.push_back(BDRY_ID);
- PhyUtil::FillDbSchema(BDRY_ID, boundary_id, boundary_id.length(),
+ vect_prim_keys.push_back(BDRY_ID_STR);
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_ID, boundary_id, boundary_id.length(),
DATATYPE_UINT8_ARRAY_32, vect_table_attr_schema);
// oper status
value = "";
prev_db_val = 0;
}
- PhyUtil::FillDbSchema(BDRY_OPER_STATUS, value,
- value.length(), DATATYPE_UINT16,
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_OPER_STATUS, BDRY_OPER_STATUS_STR,
+ value, value.length(), DATATYPE_UINT16,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
valid_val = UPPL_NO_VAL_STRUCT;
prev_db_val = 0;
stringstream dummy_valid;
- PhyUtil::FillDbSchema(BDRY_VALID, valid.str(),
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_VALID, BDRY_VALID_STR, valid.str(),
valid.str().length(), DATATYPE_UINT8_ARRAY_8,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, dummy_valid);
for (unsigned int index = 0; index < ODBCM_SIZE_8; ++index) {
attr_status << CREATED;
}
- PhyUtil::FillDbSchema(BDRY_ATTR, attr_status.str(),
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_ATTR, BDRY_ATTR_STR, attr_status.str(),
attr_status.str().length(), DATATYPE_UINT8_ARRAY_8,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, dummy_valid);
// cs_row status
if (is_filtering == true) {
- vect_prim_keys.push_back(BDRY_ROW_STATUS);
+ vect_prim_keys.push_back(BDRY_ROW_STATUS_STR);
}
value = PhyUtil::uint8tostr(row_status);
if (operation_type >= UNC_OP_READ) {
- PhyUtil::FillDbSchema(BDRY_ROW_STATUS, value,
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_ROW_STATUS, value,
value.length(), DATATYPE_UINT16,
vect_table_attr_schema);
}
PhyUtil::reorder_col_attrs(vect_prim_keys, vect_table_attr_schema);
- kt_boundary_dbtableschema.set_table_name(UPPL_BOUNDARY_TABLE);
+ kt_boundary_dbtableschema.set_table_name(unc::uppl::BOUNDARY_TABLE);
kt_boundary_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_boundary_dbtableschema.set_row_list(row_list);
}
/** FillBoundaryValueStructure
- * *@Description : This function populates val_boundary_t by values retrieved
+ * @Description : This function populates val_boundary_t by values retrieved
* from database
- * * * @param[in]: boundary table dbtable schema,
- * value structure and max_rep_ct
- * * * * @return : Filled val_boundary
+ * @param[in]: kt_boundary_dbtableschema-boundary table dbtable schema
+ * to be filled
+ * vect_obj_key_boundary-vector<key_boundary_t> instance
+ * vect_obj_val_boundary-vector<val_boundary_st_t> instance
+ * max_rep_ct-max no of records to be read
+ * @return : void
**/
void Kt_Boundary::FillBoundaryValueStructure(
+ OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_boundary_dbtableschema,
vector<key_boundary_t> &vect_obj_key_boundary,
vector<val_boundary_st_t> &vect_obj_val_boundary,
uint32_t &max_rep_ct) {
- // populate IPC value structure based on the response recevied from DB
- list < vector<TableAttrSchema> > res_boundary_row_list =
+ // populate IPC value structure based on the response received from DB
+ list < vector<TableAttrSchema> >& res_boundary_row_list =
kt_boundary_dbtableschema.get_row_list();
list < vector<TableAttrSchema> > :: iterator res_boundary_iter =
res_boundary_row_list.begin();
max_rep_ct = res_boundary_row_list.size();
pfc_log_debug("res_boundary_row_list.size: %d", max_rep_ct);
- // populate IPC value structure based on the response recevied from DB
+ // populate IPC value structure based on the response received from DB
for (; res_boundary_iter != res_boundary_row_list.end();
++res_boundary_iter) {
vector<TableAttrSchema> res_boundary_table_attr_schema =
++vect_boundary_iter) {
// Populate values from boundary_table
TableAttrSchema tab_schema = (*vect_boundary_iter);
- string attr_name = tab_schema.table_attribute_name;
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
string attr_value;
- if (attr_name == BDRY_ID) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_key_boundary.boundary_id, attr_value.c_str(),
- attr_value.length()+1);
- vect_obj_key_boundary.push_back(obj_key_boundary);
- pfc_log_debug("boundary_id: %s", attr_value.c_str());
- }
- if (attr_name == BDRY_DESCRIPTION) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_128);
- memcpy(obj_val_boundary.description, attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("description: %s", attr_value.c_str());
- }
- if (attr_name == BDRY_CTR_NAME1) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_val_boundary.controller_name1,
- attr_value.c_str(), attr_value.length()+1);
- pfc_log_debug("controller_name1: %s", attr_value.c_str());
- }
- if (attr_name == BDRY_DM_NAME1) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_val_boundary.domain_name1,
- attr_value.c_str(), attr_value.length()+1);
- pfc_log_debug("domain_name1: %s", attr_value.c_str());
- }
- if (attr_name == BDRY_PORT_ID1) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_320);
- memcpy(obj_val_boundary.logical_port_id1,
- attr_value.c_str(), attr_value.length()+1);
- pfc_log_debug("logical_port_id1: %s", attr_value.c_str());
- }
- if (attr_name == BDRY_CTR_NAME2) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_val_boundary.controller_name2,
- attr_value.c_str(), attr_value.length()+1);
- pfc_log_debug("controller_name2: %s", attr_value.c_str());
- }
- if (attr_name == BDRY_DM_NAME2) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_val_boundary.domain_name2,
- attr_value.c_str(), attr_value.length()+1);
- pfc_log_debug("domain_name2: %s", attr_value.c_str());
- }
- if (attr_name == BDRY_PORT_ID2) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_320);
- memcpy(obj_val_boundary.logical_port_id2,
- attr_value.c_str(), attr_value.length()+1);
- pfc_log_debug("logical_port_id2: %s", attr_value.c_str());
- }
- if (attr_name == BDRY_VALID) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_8);
- memset(obj_val_boundary.valid, '\0', 7);
- FrameValidValue(attr_value, obj_val_boundary_st, obj_val_boundary);
- pfc_log_debug("valid: %s", attr_value.c_str());
- }
- if (attr_name == BDRY_ATTR) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_8);
- memset(obj_val_boundary.cs_attr, '\0', 7);
- FrameCsAttrValue(attr_value, obj_val_boundary);
- pfc_log_debug("cs_attr: %s", attr_value.c_str());
- }
- if (attr_name == BDRY_ROW_STATUS) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- obj_val_boundary.cs_row_status = atoi(attr_value.c_str());
- pfc_log_debug("row_status: %s", attr_value.c_str());
- }
- if (attr_name == BDRY_OPER_STATUS) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- obj_val_boundary_st.oper_status = atoi(attr_value.c_str());
- pfc_log_debug("oper_status: %s", attr_value.c_str());
+ switch (attr_name) {
+ case unc::uppl::BDRY_ID:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_key_boundary.boundary_id,
+ DATATYPE_UINT8_ARRAY_32);
+ vect_obj_key_boundary.push_back(obj_key_boundary);
+ pfc_log_debug("boundary_id: %s",
+ obj_key_boundary.boundary_id);
+ break;
+
+ case unc::uppl::BDRY_DESCRIPTION:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_val_boundary.description,
+ DATATYPE_UINT8_ARRAY_128);
+ pfc_log_debug("description: %s", obj_val_boundary.description);
+ break;
+
+ case unc::uppl::BDRY_CTR_NAME1:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_val_boundary.controller_name1,
+ DATATYPE_UINT8_ARRAY_32);
+ pfc_log_debug("controller_name1: %s",
+ obj_val_boundary.controller_name1);
+ break;
+
+ case unc::uppl::BDRY_DM_NAME1:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_val_boundary.domain_name1,
+ DATATYPE_UINT8_ARRAY_32);
+ pfc_log_debug("domain_name1: %s", obj_val_boundary.domain_name1);
+ break;
+
+ case unc::uppl::BDRY_PORT_ID1:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_val_boundary.logical_port_id1,
+ DATATYPE_UINT8_ARRAY_320);
+ pfc_log_debug("logical_port_id1: %s",
+ obj_val_boundary.logical_port_id1);
+ break;
+
+ case unc::uppl::BDRY_CTR_NAME2:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_val_boundary.controller_name2,
+ DATATYPE_UINT8_ARRAY_32);
+ pfc_log_debug("controller_name2: %s",
+ obj_val_boundary.controller_name2);
+ break;
+
+ case unc::uppl::BDRY_DM_NAME2:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_val_boundary.domain_name2,
+ DATATYPE_UINT8_ARRAY_32);
+ pfc_log_debug("domain_name2: %s", obj_val_boundary.domain_name2);
+ break;
+
+ case unc::uppl::BDRY_PORT_ID2:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_val_boundary.logical_port_id2,
+ DATATYPE_UINT8_ARRAY_320);
+ pfc_log_debug("logical_port_id2: %s"
+ , obj_val_boundary.logical_port_id2);
+ break;
+
+ case unc::uppl::BDRY_VALID:
+ uint8_t bdr_valid[ODBCM_SIZE_8];
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema, bdr_valid,
+ DATATYPE_UINT8_ARRAY_8);
+ memset(obj_val_boundary.valid, '\0', 7);
+ FrameValidValue(reinterpret_cast<const char*> (bdr_valid),
+ obj_val_boundary_st, obj_val_boundary);
+ pfc_log_debug("valid: %s", bdr_valid);
+ break;
+
+ case unc::uppl::BDRY_ATTR:
+ uint8_t bdr_attr[ODBCM_SIZE_8];
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema, bdr_attr,
+ DATATYPE_UINT8_ARRAY_8);
+ memset(obj_val_boundary.cs_attr, '\0', 7);
+ FrameCsAttrValue(reinterpret_cast<const char*> (bdr_attr),
+ obj_val_boundary);
+ pfc_log_debug("cs_attr: %s", bdr_attr);
+ break;
+
+ case unc::uppl::BDRY_ROW_STATUS:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT16);
+ obj_val_boundary.cs_row_status = atoi(attr_value.c_str());
+ pfc_log_debug("row_status: %s", attr_value.c_str());
+ break;
+
+ case unc::uppl::BDRY_OPER_STATUS:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT16);
+ obj_val_boundary_st.oper_status = atoi(attr_value.c_str());
+ pfc_log_debug("oper_status: %s", attr_value.c_str());
+ break;
+
+ default:
+ pfc_log_info("Ignoring Boundary attribute %d", attr_name);
+ break;
}
}
obj_val_boundary_st.boundary = obj_val_boundary;
* @Description : This function reads the instance of KT_Boundary based on
* operation type - UNC_OP_READ, UNC_OP_READ_SIBLING_BEGIN,
* UNC_OP_READ_SIBLING
- * * @param[in] : key_struct, value_struct, ipc session id, configuration id,
- * option1, option2, data_type, operation type, max_rep_ct
- * * *@return : Success or associated error code
+ * @param[in] : key_struct-void* to bdry key structure
+ * value_struct-void* to bdry value structure
+ * session_id-ipc session id used for TC validation
+ * configuration_id -ipc configuration id used for TC validation
+ * operation_type-UNC_OP_*
+ * sess-object of ServerSession
+ * option1,option2-additional info for read opeartions,UNC_OPT1/OPT2_*
+ * max_rep_ct-max no of records to be read
+ * @return : Success or associated error code
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
**/
-UpplReturnCode Kt_Boundary::PerformRead(uint32_t session_id,
+UpplReturnCode Kt_Boundary::PerformRead(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t option1,
uint32_t option2,
uint32_t max_rep_ct) {
- pfc_log_info("Inside PerformRead option1=%d option2=%d max_rep_ct=%d",
- option1, option2, max_rep_ct);
pfc_log_info("Inside PerformRead operation_type=%d data_type=%d",
operation_type, data_type);
key_boundary_t *obj_boundary = reinterpret_cast<key_boundary_t*>(key_struct);
return UPPL_RC_SUCCESS;
}
vector<key_boundary_t> vect_key_boundary;
- vector<val_boundary_t> vect_val_boundary;
vector<val_boundary_st_t> vect_val_boundary_st;
- read_status = ReadBoundaryValFromDB(key_struct,
+ read_status = ReadBoundaryValFromDB(db_conn,
+ key_struct,
val_struct,
data_type,
operation_type,
max_rep_ct,
vect_key_boundary,
- vect_val_boundary,
vect_val_boundary_st);
rsh.result_code = read_status;
rsh.max_rep_count = max_rep_ct;
if (rsh.max_rep_count == 0) {
rsh.result_code = UPPL_RC_ERR_NO_SUCH_INSTANCE;
int err = PhyUtil::sessOutRespHeader(sess, rsh);
- err |= sess.addOutput((uint32_t)UNC_KT_CONTROLLER);
+ err |= sess.addOutput((uint32_t)UNC_KT_BOUNDARY);
err |= sess.addOutput(*obj_boundary);
if (err != 0) {
pfc_log_error("addOutput failed for physical_response_header");
sess.addOutput(vect_val_boundary_st[index].boundary);
}
if (index < vect_key_boundary.size()-1) {
- sess.addOutput(); // Seperator
+ sess.addOutput(); // Separator
}
}
} else {
return UPPL_RC_ERR_IPC_WRITE_ERROR;
}
}
- pfc_log_info("Return value for read operation %d", read_status);
+ pfc_log_debug("Return value for read operation %d", read_status);
return read_status;
}
/** ReadBoundaryValFromDB
- * * @Description : This function reads the instance of KT_Boundary based on
+ * @Description : This function reads the instance of KT_Boundary based on
* operation type - UNC_OP_READ, UNC_OP_READ_SIBLING_BEGIN,
* UNC_OP_READ_SIBLING
- * * * @param[in] : key_struct, value_struct, ipc session id, configuration id,
- * option1, option2, data_type, operation type, max_rep_ct
- * * * @return : Success or associated error code
+ * @param[in] : key_struct-void* to bdry key structure
+ * value_struct-void* to bdry val structure
+ * option1,option2-UNC_OPT1/OPT2_*,additional info for read operation
+ * data_type-UNC_DT_*,type of database
+ * operation type-UNC_OP_*,type of operation
+ * max_rep_ct-max no of records to be read
+ * vect_key_boundary-instance of vector<key_boundary_t>
+ * vect_val_boundary-instance of vector<val_boundary_t>
+ * vect_val_boundary_st-instance of vector<val_boundary_st_t>
+ * is_state-flag to indicate whether data type is DT_STATE
+ * @return : Success or associated error code
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
**/
UpplReturnCode Kt_Boundary::ReadBoundaryValFromDB(
+ OdbcmConnectionHandler *db_conn,
void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t operation_type,
uint32_t &max_rep_ct,
vector<key_boundary_t> &vect_key_boundary,
- vector<val_boundary_t> &vect_val_boundary,
vector<val_boundary_st_t> &vect_val_boundary_st,
pfc_bool_t is_state) {
+ if (operation_type < UNC_OP_READ) {
+ // Unsupported operation type for this function
+ return UPPL_RC_SUCCESS;
+ }
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode read_status = UPPL_RC_SUCCESS;
ODBCM_RC_STATUS read_db_status = ODBCM_RC_SUCCESS;
DBTableSchema kt_boundary_dbtableschema;
// construct TableAttrSchema structure
// TableAttrSchema holds table_name, primary key, attr_name
- TableAttrSchema kt_boundary_table_attr_schema;
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
vector<ODBCMOperator> vect_key_operations;
void* old_val_struct;
- PopulateDBSchemaForKtTable(kt_boundary_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_boundary_dbtableschema,
key_struct,
val_struct,
- operation_type, 0, 0,
+ operation_type, data_type, 0, 0,
vect_key_operations, old_val_struct);
if (operation_type == UNC_OP_READ) {
read_db_status = physical_layer->get_odbc_manager()->
GetOneRow((unc_keytype_datatype_t)data_type,
- kt_boundary_dbtableschema);
+ kt_boundary_dbtableschema, db_conn);
} else {
read_db_status = physical_layer->get_odbc_manager()->
GetBulkRows((unc_keytype_datatype_t)data_type, max_rep_ct,
kt_boundary_dbtableschema,
- (unc_keytype_operation_t)operation_type);
+ (unc_keytype_operation_t)operation_type, db_conn);
}
if (read_db_status == ODBCM_RC_RECORD_NOT_FOUND) {
pfc_log_debug("No record found");
read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
return read_status;
+ } else if (read_db_status == ODBCM_RC_CONNECTION_ERROR) {
+ read_status = UPPL_RC_ERR_DB_ACCESS;
+ pfc_log_error("Read operation has failed with error %d", read_db_status);
+ return read_status;
} else if (read_db_status != ODBCM_RC_SUCCESS) {
read_status = UPPL_RC_ERR_DB_GET;
// log error to log daemon
pfc_log_info("Read operation has failed with error %d", read_db_status);
return read_status;
}
- FillBoundaryValueStructure(kt_boundary_dbtableschema,
+ FillBoundaryValueStructure(db_conn, kt_boundary_dbtableschema,
vect_key_boundary,
vect_val_boundary_st,
max_rep_ct);
read_status = UPPL_RC_ERR_DB_GET;
// log error to log daemon
pfc_log_info("Read operation has failed, after reading response");
- return read_status;
- }
-
- if (is_state != true) {
- return read_status;
- }
- for (unsigned int index = 0; index < vect_val_boundary_st.size(); ++index) {
- val_boundary_st_t obj_boundary = vect_val_boundary_st[index];
- val_boundary_st_t obj_boundary_st;
- // populate val_boundary_st_t
- memcpy(&obj_boundary_st.boundary,
- &obj_boundary.boundary,
- sizeof(val_boundary_t));
- obj_boundary_st.valid[kIdxBoundaryStBoundary] = UNC_VF_VALID;
-
- // populate IPC value structure based on the response recevied from DB
- vector<TableAttrSchema> res_table_attr_schema =
- kt_boundary_dbtableschema.get_row_list().front();
- vector<TableAttrSchema> ::iterator vect_iter =
- res_table_attr_schema.begin();
- for (; vect_iter != res_table_attr_schema.end(); ++vect_iter) {
- TableAttrSchema tab_schema = (*vect_iter);
- string attr_name = tab_schema.table_attribute_name;
- string attr_value;
- if (attr_name == BDRY_OPER_STATUS) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- obj_boundary_st.oper_status = atoi(attr_value.c_str());
- obj_boundary_st.valid[kIdxBoundaryStOperStatus] = UNC_VF_VALID;
- }
- }
- vect_val_boundary_st.push_back(obj_boundary_st);
}
return read_status;
}
/** GetModifiedRows
- * * @Description : This function reads all KT_Boundary with given row_status
- * * * @param[in] : key_struct, value_struct, row_status
- * * * @return : Success or associated error code
+ * @Description : This function reads all KT_Boundary with given row_status
+ * @param[in] : obj_key_struct-vector of void* to bdry key structures
+ * row_status-CsRowStatus value
+ * @return : Success or associated error code
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_Boundary::GetModifiedRows(vector<void *> &obj_key_struct,
+UpplReturnCode Kt_Boundary::GetModifiedRows(OdbcmConnectionHandler *db_conn,
+ vector<void *> &obj_key_struct,
CsRowStatus row_status) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
uint32_t max_rep_ct = 0;
DBTableSchema kt_boundary_dbtableschema;
vector<ODBCMOperator> vect_key_operations;
void* old_val_struct;
- PopulateDBSchemaForKtTable(kt_boundary_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_boundary_dbtableschema,
boundary_key,
boundary_val,
- UNC_OP_READ, 0, 0,
+ UNC_OP_READ, UNC_DT_CANDIDATE, 0, 0,
vect_key_operations, old_val_struct,
row_status,
true);
read_db_status = physical_layer->get_odbc_manager()->
- GetModifiedRows(UNC_DT_CANDIDATE, kt_boundary_dbtableschema);
+ GetModifiedRows(UNC_DT_CANDIDATE, kt_boundary_dbtableschema, db_conn);
if (read_db_status == ODBCM_RC_RECORD_NOT_FOUND) {
pfc_log_debug("No record to read");
return read_status;
}
- FillBoundaryValueStructure(kt_boundary_dbtableschema,
+ FillBoundaryValueStructure(db_conn, kt_boundary_dbtableschema,
vect_obj_key_struct,
vect_obj_value_struct,
max_rep_ct);
/** IsKeyExists
* @Description : This function checks whether the boundary_id exists in DB
- * * @param[in] : data_type, key
- * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR* based on operation type
+ * @param[in] : data_type-UNC_DT_*,type of database
+ * key_values-vector of keys ins string
+ * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR* based on operation type
* * */
-UpplReturnCode Kt_Boundary::IsKeyExists(unc_keytype_datatype_t data_type,
- vector<string> key_values) {
+UpplReturnCode Kt_Boundary::IsKeyExists(OdbcmConnectionHandler *db_conn,
+ unc_keytype_datatype_t data_type,
+ const vector<string> &key_values) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode check_status = UPPL_RC_SUCCESS;
// Construct Primary key list
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(BDRY_ID);
+ vect_prim_keys.push_back(BDRY_ID_STR);
// Construct TableAttrSchema structure
// TableAttrSchema holds table_name, primary key, attr_name
vector<TableAttrSchema> vect_table_attr_schema;
- TableAttrSchema kt_boundary_table_attr_schema;
list< vector<TableAttrSchema> > row_list;
// boundary_id
- PhyUtil::FillDbSchema(BDRY_ID, boundary_id, boundary_id.length(),
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_ID, boundary_id, boundary_id.length(),
DATATYPE_UINT8_ARRAY_32, vect_table_attr_schema);
- kt_boundary_dbtableschema.set_table_name(UPPL_BOUNDARY_TABLE);
+ kt_boundary_dbtableschema.set_table_name(unc::uppl::BOUNDARY_TABLE);
kt_boundary_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_boundary_dbtableschema.set_row_list(row_list);
// Send request to ODBC for Boundary_common_table
ODBCM_RC_STATUS check_db_status = physical_layer->get_odbc_manager()->\
- IsRowExists(data_type, kt_boundary_dbtableschema);
+ IsRowExists(data_type, kt_boundary_dbtableschema, db_conn);
if (check_db_status == ODBCM_RC_CONNECTION_ERROR) {
pfc_log_error("DB connection not available or cannot access DB");
check_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
}
} else {
- pfc_log_error("DB Returned failure for IsRowExists");
+ pfc_log_info("DB Returned failure for IsRowExists");
check_status = UPPL_RC_ERR_DB_GET;
}
return check_status;
* * @return : void
*****/
void Kt_Boundary::Fill_Attr_Syntax_Map() {
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map;
Kt_Class_Attr_Syntax a0 = { PFC_IPCTYPE_STRING, 0, 0, 1, 32, true, "" };
- attr_syntax_map[BDRY_ID] = a0;
+ attr_syntax_map[BDRY_ID_STR] = a0;
- Kt_Class_Attr_Syntax a1 = { PFC_IPCTYPE_STRING, 0, 0, 0, 128, false, "" };
- attr_syntax_map[BDRY_DESCRIPTION] = a1;
+ Kt_Class_Attr_Syntax a1 = { PFC_IPCTYPE_STRING, 0, 0, 1, 128, false, "" };
+ attr_syntax_map[BDRY_DESCRIPTION_STR] = a1;
Kt_Class_Attr_Syntax a2 = { PFC_IPCTYPE_STRING, 0, 0, 1, 32, true, "" };
- attr_syntax_map[BDRY_CTR_NAME1] = a2;
+ attr_syntax_map[BDRY_CTR_NAME1_STR] = a2;
Kt_Class_Attr_Syntax a3 = { PFC_IPCTYPE_STRING, 0, 0, 1, 32, true, "" };
- attr_syntax_map[BDRY_DM_NAME1] = a3;
+ attr_syntax_map[BDRY_DM_NAME1_STR] = a3;
- Kt_Class_Attr_Syntax a5 = { PFC_IPCTYPE_STRING, 0, 0, 0, 320, false, "" };
- attr_syntax_map[BDRY_PORT_ID1] = a5;
+ Kt_Class_Attr_Syntax a5 = { PFC_IPCTYPE_STRING, 0, 0, 4, 320, false, "" };
+ attr_syntax_map[BDRY_PORT_ID1_STR] = a5;
Kt_Class_Attr_Syntax a6 = { PFC_IPCTYPE_STRING, 0, 0, 1, 32, true, "" };
- attr_syntax_map[BDRY_CTR_NAME2] = a6;
+ attr_syntax_map[BDRY_CTR_NAME2_STR] = a6;
Kt_Class_Attr_Syntax a7 = { PFC_IPCTYPE_STRING, 0, 0, 1, 32, true, "" };
- attr_syntax_map[BDRY_DM_NAME2] = a7;
+ attr_syntax_map[BDRY_DM_NAME2_STR] = a7;
- Kt_Class_Attr_Syntax a9 = { PFC_IPCTYPE_STRING, 0, 0, 0, 320, false, "" };
- attr_syntax_map[BDRY_PORT_ID2] = a9;
+ Kt_Class_Attr_Syntax a9 = { PFC_IPCTYPE_STRING, 0, 0, 4, 320, false, "" };
+ attr_syntax_map[BDRY_PORT_ID2_STR] = a9;
Kt_Class_Attr_Syntax a10 = { PFC_IPCTYPE_STRING, 0, 0, 0, 7, false, "" };
- attr_syntax_map[BDRY_VALID] = a10;
+ attr_syntax_map[BDRY_VALID_STR] = a10;
Kt_Class_Attr_Syntax a11 = { PFC_IPCTYPE_STRING, 0, 3, 0, 0, false, "" };
- attr_syntax_map[BDRY_ROW_STATUS] = a11;
+ attr_syntax_map[BDRY_ROW_STATUS_STR] = a11;
Kt_Class_Attr_Syntax a12 = { PFC_IPCTYPE_STRING, 0, 0, 0, 7, false, "" };
- attr_syntax_map[BDRY_ATTR] = a12;
+ attr_syntax_map[BDRY_ATTR_STR] = a12;
+ attr_syntax_map_all[UNC_KT_BOUNDARY] = attr_syntax_map;
}
/** SendSemanticRequestToUPLL
* @Description : This functions calls IPC to check whether UNC_KT_BOUNDARY
* is being referred in Logical
- * * @param[in] : key_boundary - specifies key instance of KT_BOUNDARY
- * * @return : UPPL_RC_SUCCESS if boundary is not referred
+ * @param[in] : key_boundary - specifies key instance of KT_BOUNDARY
+ * data_type-UNC_DT_*,type of database
+ * @return : UPPL_RC_SUCCESS if boundary is not referred
* or UPPL_RC_ERR_* if boundary is referred in logical
**/
UpplReturnCode Kt_Boundary::SendSemanticRequestToUPLL(void* key_struct,
/** getBoundaryInputOperStatus
* @Description : This function gets the oper status
- * * @param[in] : Controller Name, Domain Name and Logical port id
- * * @return : Oper status
+ * @param[in] : data_type-UNC_DT_*,type of database
+ * controller_name-Controller Name referred by this boundary
+ * domain_name-Domain Name referred by this boundary
+ * logical_port_id-Logical port id referred by this boundary
+ * @return : oper status of boundary
*/
UpplBoundaryOperStatus Kt_Boundary::getBoundaryInputOperStatus(
+ OdbcmConnectionHandler *db_conn,
uint32_t data_type,
string controller_name,
string domain_name,
- string logical_port_id) {
+ string logical_port_id,
+ vector<OperStatusHolder> &ref_oper_status) {
pfc_log_debug("getBoundaryInputOperStatus() - controller name: %s",
controller_name.c_str());
UpplBoundaryOperStatus boundary_oper_status = UPPL_BOUNDARY_OPER_UNKNOWN;
if (controller_name.empty())
return boundary_oper_status;
key_ctr_t ctr_key;
+ memset(&ctr_key, 0, sizeof(key_ctr_t));
memcpy(ctr_key.controller_name, controller_name.c_str(),
(controller_name.length())+1);
void* key_type_struct = reinterpret_cast<void*>(&ctr_key);
(UpplControllerOperStatus) UPPL_CONTROLLER_OPER_UP;
uint8_t logical_port_oper_status =
(UpplLogicalPortOperStatus) UPPL_LOGICAL_PORT_OPER_UP;
+ uint32_t ctrl_data_type = data_type;
+ if (data_type == UNC_DT_IMPORT) {
+ ctrl_data_type = UNC_DT_RUNNING;
+ }
// Get the controller's oper status and decide on the oper_status
- UpplReturnCode read_status = controller.GetOperStatus(
- data_type, key_type_struct, ctr_oper_status);
- pfc_log_info("Controller's oper_status %d", ctr_oper_status);
+ UpplReturnCode read_oper_status = get_oper_status(
+ ref_oper_status,
+ UNC_KT_CONTROLLER,
+ reinterpret_cast<void*>(&ctr_key),
+ ctr_oper_status);
+ UpplReturnCode read_status = UPPL_RC_SUCCESS;
+ if (read_oper_status != UPPL_RC_SUCCESS) {
+ read_status = controller.GetOperStatus(
+ db_conn, ctrl_data_type, key_type_struct, ctr_oper_status);
+ pfc_log_info("Controller's oper_status %d", ctr_oper_status);
+ ADD_CTRL_OPER_STATUS(controller_name, ctr_oper_status);
+ }
if (read_status == UPPL_RC_SUCCESS &&
- ctr_oper_status == UPPL_CONTROLLER_OPER_UP) {
+ ctr_oper_status != UPPL_CONTROLLER_OPER_DOWN) {
+ // Boundary oper status does not depends on domain
if (domain_name.empty()) {
+ boundary_oper_status = UPPL_BOUNDARY_OPER_UP;
+ pfc_log_info("Returning boundary_oper_status %d", boundary_oper_status);
return boundary_oper_status;
}
- // Boundary oper status does not depends on domain
- if (!logical_port_id.empty()) {
- key_logical_port_t logical_port_key;
- memset(logical_port_key.domain_key.ctr_key.controller_name,
- '\0', 32);
- memset(logical_port_key.domain_key.domain_name,
- '\0', 32);
- memset(logical_port_key.port_id,
- '\0', 320);
- memcpy(logical_port_key.domain_key.ctr_key.controller_name,
- controller_name.c_str(),
- controller_name.length()+1);
- memcpy(logical_port_key.domain_key.domain_name,
- domain_name.c_str(),
- domain_name.length()+1);
- memcpy(logical_port_key.port_id,
- logical_port_id.c_str(),
- logical_port_id.length()+1);
+ if (logical_port_id.empty()) {
+ boundary_oper_status = UPPL_BOUNDARY_OPER_UP;
+ pfc_log_info("Returning boundary_oper_status %d", boundary_oper_status);
+ return boundary_oper_status;
+ }
+ unc_keytype_ctrtype_t ctrl_type = UNC_CT_UNKNOWN;
+ uint32_t ctr_data_type = data_type;
+ if (data_type == UNC_DT_IMPORT) {
+ ctr_data_type = UNC_DT_RUNNING;
+ }
+ UpplReturnCode ctr_type_status =
+ PhyUtil::get_controller_type(db_conn, controller_name,
+ ctrl_type,
+ (unc_keytype_datatype_t) ctr_data_type);
+ if (ctr_type_status == UPPL_RC_SUCCESS &&
+ ctrl_type == (unc_keytype_ctrtype_t) UNC_CT_UNKNOWN) {
+ boundary_oper_status = UPPL_BOUNDARY_OPER_UP;
+ pfc_log_info(
+ "LP need not be considered for bypass controller."
+ " Returning boundary_oper_status %d", boundary_oper_status);
+ return boundary_oper_status;
+ }
+ key_logical_port_t logical_port_key;
+ memset(&logical_port_key, '\0', sizeof(logical_port_key));
+ memcpy(logical_port_key.domain_key.ctr_key.controller_name,
+ controller_name.c_str(),
+ controller_name.length()+1);
+ memcpy(logical_port_key.domain_key.domain_name,
+ domain_name.c_str(),
+ domain_name.length()+1);
+ memcpy(logical_port_key.port_id,
+ logical_port_id.c_str(),
+ logical_port_id.length()+1);
+ UpplReturnCode read_oper_status = get_oper_status(
+ ref_oper_status,
+ UNC_KT_LOGICAL_PORT,
+ reinterpret_cast<void*>(&logical_port_key),
+ logical_port_oper_status);
+ if (read_oper_status != UPPL_RC_SUCCESS) {
key_type_struct = reinterpret_cast<void*>(&logical_port_key);
Kt_LogicalPort logical_port;
// Get the logical_port's oper status and decide on the oper_status
- read_status = logical_port.GetOperStatus(data_type,
+ read_status = logical_port.GetOperStatus(db_conn, data_type,
key_type_struct,
logical_port_oper_status);
- pfc_log_info("Logical_Port's oper_status %d", logical_port_oper_status);
- if (read_status == UPPL_RC_SUCCESS && logical_port_oper_status ==
- UPPL_LOGICAL_PORT_OPER_UP) {
- boundary_oper_status = UPPL_BOUNDARY_OPER_UP;
+ if (read_status != UPPL_RC_SUCCESS) {
+ if (data_type == UNC_DT_IMPORT) {
+ // Check in running db as well
+ read_status = logical_port.GetOperStatus(db_conn, UNC_DT_RUNNING,
+ key_type_struct,
+ logical_port_oper_status);
+ pfc_log_info("Logical_Port's oper_status %d",
+ logical_port_oper_status);
+ }
+ if (read_status != UPPL_RC_SUCCESS) {
+ pfc_log_info("Returning boundary_oper_status %d",
+ boundary_oper_status);
+ return boundary_oper_status;
+ } else {
+ pfc_log_info("Logical_Port's oper_status %d",
+ logical_port_oper_status);
+ ADD_LP_PORT_OPER_STATUS(logical_port_key, logical_port_oper_status);
+ }
} else {
- boundary_oper_status = UPPL_BOUNDARY_OPER_DOWN;
+ pfc_log_info("Logical_Port's oper_status %d", logical_port_oper_status);
+ ADD_LP_PORT_OPER_STATUS(logical_port_key, logical_port_oper_status);
}
}
+ if (logical_port_oper_status == UPPL_LOGICAL_PORT_OPER_UP) {
+ boundary_oper_status = UPPL_BOUNDARY_OPER_UP;
+ } else if (logical_port_oper_status == UPPL_LOGICAL_PORT_OPER_UNKNOWN) {
+ boundary_oper_status = UPPL_BOUNDARY_OPER_UNKNOWN;
+ } else {
+ boundary_oper_status = UPPL_BOUNDARY_OPER_DOWN;
+ }
}
+ pfc_log_info("Returning boundary_oper_status %d", boundary_oper_status);
return boundary_oper_status;
}
/** HandleOperStatus
* @Description : This function performs the required actions
* when oper status changes in controller/domain/logical_port
- * * @param[in] : Key and value struct
- * * @return : Success or associated error code
+ * @param[in] : data_type-UNC_DT_*,type of database
+ * key_struct-void* to bdry key structure
+ * value_struct-void* to bdry val structure
+ * @return : Success or associated error code
*/
-UpplReturnCode Kt_Boundary::HandleOperStatus(uint32_t data_type,
- void *key_struct,
- void *value_struct) {
+UpplReturnCode Kt_Boundary::HandleOperStatus(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ void *key_struct,
+ void *value_struct,
+ vector<OperStatusHolder> &ref_oper_status) {
FN_START_TIME("HandleOperStatus", "Boundary");
UpplReturnCode return_code = UPPL_RC_SUCCESS;
UpplBoundaryOperStatus boundary_oper_status = UPPL_BOUNDARY_OPER_UNKNOWN;
FN_END_TIME("HandleOperStatus", "Boundary");
return return_code;
}
+ string controller_name = "";
+ string domain_name = "";
+ string port_id = "";
val_boundary_t *obj_val_boundary =
reinterpret_cast<val_boundary_t*>(value_struct);
+ if (obj_val_boundary->valid[kIdxBoundaryControllerName1] != UNC_VF_VALID &&
+ obj_val_boundary->valid[kIdxBoundaryControllerName2] != UNC_VF_VALID) {
+ pfc_log_info("Controller name not valid- Returning SUCCESS");
+ FN_END_TIME("HandleOperStatus", "Boundary");
+ return return_code;
+ }
+ bool ctr1_valid = false;
if (obj_val_boundary->valid[kIdxBoundaryControllerName1] == UNC_VF_VALID) {
- string controller_name =
- (const char*) obj_val_boundary->controller_name1;
+ ctr1_valid = true;
+ controller_name = (const char*) obj_val_boundary->controller_name1;
pfc_log_debug("Kt_Boundary::HandleOperStatus() - controller1 name: %s",
controller_name.c_str());
- string domain_name =
- (const char*) obj_val_boundary->domain_name1;
- string port_id =
- (const char*) obj_val_boundary->logical_port_id1;
- boundary_oper_status = getBoundaryInputOperStatus(data_type,
- controller_name,
- domain_name, port_id);
- } else if (obj_val_boundary->valid[kIdxBoundaryControllerName2] ==
- UNC_VF_VALID) {
- string controller_name =
- (const char*) obj_val_boundary->controller_name2;
+ domain_name = (const char*) obj_val_boundary->domain_name1;
+ port_id = (const char*) obj_val_boundary->logical_port_id1;
+ } else {
+ controller_name = (const char*) obj_val_boundary->controller_name2;
pfc_log_debug("Kt_Boundary::HandleOperStatus() - controller2 name: %s",
controller_name.c_str());
- string domain_name =
- (const char*) obj_val_boundary->domain_name2;
- string port_id =
- (const char*) obj_val_boundary->logical_port_id2;
- boundary_oper_status = getBoundaryInputOperStatus(data_type,
- controller_name,
- domain_name, port_id);
+ domain_name = (const char*) obj_val_boundary->domain_name2;
+ port_id = (const char*) obj_val_boundary->logical_port_id2;
}
+ boundary_oper_status = getBoundaryInputOperStatus(db_conn, data_type,
+ controller_name,
+ domain_name, port_id,
+ ref_oper_status);
- if (boundary_oper_status == UPPL_BOUNDARY_OPER_DOWN) {
- pfc_log_info("Set Boundary oper status as down");
+ if (boundary_oper_status == UPPL_BOUNDARY_OPER_DOWN ||
+ boundary_oper_status == UPPL_BOUNDARY_OPER_UNKNOWN) {
+ pfc_log_info("Set Boundary oper status as down/unknown");
// Update oper_status in boundary table
- return_code = SetOperStatus(data_type, NULL, value_struct,
+ return_code = SetOperStatus(db_conn, UNC_DT_STATE, NULL, value_struct,
boundary_oper_status);
pfc_log_info("Set Boundary oper status status %d", return_code);
FN_END_TIME("HandleOperStatus", "Boundary");
return return_code;
}
pfc_log_debug("Check the secondary controller/domain/lp set");
- if (obj_val_boundary->valid[kIdxBoundaryControllerName1] ==
- UNC_VF_VALID) {
- vector<key_boundary_t> vect_key_boundary;
- vector<val_boundary_t> vect_val_boundary;
- vector<val_boundary_st_t> vect_val_boundary_st;
- memset(obj_val_boundary->valid, '\0', sizeof(obj_val_boundary->valid));
- obj_val_boundary->valid[kIdxBoundaryControllerName1] = 1;
- obj_val_boundary->valid[kIdxBoundaryDomainName1] = 1;
- obj_val_boundary->valid[kIdxBoundaryLogicalPortId1] = 1;
- uint32_t max_rep_cnt = UPPL_MAX_REP_CT;
- UpplReturnCode read_status = ReadBoundaryValFromDB(
- NULL,
- value_struct,
- UNC_DT_STATE,
- UNC_OP_READ_SIBLING_BEGIN,
- max_rep_cnt,
- vect_key_boundary,
- vect_val_boundary,
- vect_val_boundary_st);
- if (read_status != UPPL_RC_SUCCESS) {
- pfc_log_debug("No boundaries associated with controller name1");
- FN_END_TIME("HandleOperStatus", "Boundary");
- return return_code;
+
+ vector<key_boundary_t> vect_key_boundary;
+ vector<val_boundary_st_t> vect_val_boundary_st;
+ uint32_t max_rep_cnt = UPPL_MAX_REP_CT;
+ UpplReturnCode read_status = ReadBoundaryValFromDB(
+ db_conn, NULL,
+ value_struct,
+ UNC_DT_STATE,
+ UNC_OP_READ_SIBLING_BEGIN,
+ max_rep_cnt,
+ vect_key_boundary,
+ vect_val_boundary_st);
+ if (read_status != UPPL_RC_SUCCESS) {
+ pfc_log_debug("No boundaries associated with given controller name");
+ FN_END_TIME("HandleOperStatus", "Boundary");
+ return return_code;
+ }
+ pfc_log_debug("From db, vect_boundary size is %d",
+ static_cast<int>(vect_key_boundary.size()));
+ for (unsigned int index = 0;
+ index < vect_key_boundary.size();
+ ++index) {
+ if (vect_val_boundary_st[index].oper_status ==
+ UPPL_BOUNDARY_OPER_UP) {
+ continue;
}
- pfc_log_debug("From db, vect_boundary size is %d",
- static_cast<int>(vect_key_boundary.size()));
- for (unsigned int index = 0;
- index < vect_key_boundary.size();
- ++index) {
- if (vect_val_boundary_st[index].oper_status ==
- UPPL_BOUNDARY_OPER_UP) {
- continue;
- }
- string controller_name =
- (const char*) vect_val_boundary_st[index].\
+ if (ctr1_valid == true) {
+ controller_name = (const char*) vect_val_boundary_st[index].\
boundary.controller_name2;
pfc_log_info(
"Kt_Boundary::HandleOperStatus() controller2 name: %s",
controller_name.c_str());
- string domain_name =
- (const char*) vect_val_boundary_st[index].\
+ domain_name = (const char*) vect_val_boundary_st[index].\
boundary.domain_name2;
- string port_id =
- (const char*) vect_val_boundary_st[index].\
+ port_id = (const char*) vect_val_boundary_st[index].\
boundary.logical_port_id2;
- UpplBoundaryOperStatus second_oper_status =
- getBoundaryInputOperStatus(data_type, controller_name,
- domain_name, port_id);
- pfc_log_info("oper status for set2 %d", second_oper_status);
- if (second_oper_status == UPPL_BOUNDARY_OPER_UP) {
- SetOperStatus(data_type,
- reinterpret_cast<void*>(&vect_key_boundary[index]),
- reinterpret_cast<void*>(NULL), UPPL_BOUNDARY_OPER_UP);
- }
- }
- } else if (obj_val_boundary->valid[kIdxBoundaryControllerName2] ==
- UNC_VF_VALID) {
- vector<key_boundary_t> vect_key_boundary;
- vector<val_boundary_t> vect_val_boundary;
- vector<val_boundary_st_t> vect_val_boundary_st;
- memset(obj_val_boundary->valid, '\0', sizeof(obj_val_boundary->valid));
- obj_val_boundary->valid[kIdxBoundaryControllerName2] = 1;
- obj_val_boundary->valid[kIdxBoundaryDomainName2] = 1;
- obj_val_boundary->valid[kIdxBoundaryLogicalPortId2] = 1;
- uint32_t max_rep_cnt = UPPL_MAX_REP_CT;
- UpplReturnCode read_status = ReadBoundaryValFromDB(
- NULL,
- value_struct,
- UNC_DT_STATE,
- UNC_OP_READ_SIBLING_BEGIN,
- max_rep_cnt,
- vect_key_boundary,
- vect_val_boundary,
- vect_val_boundary_st);
- if (read_status != UPPL_RC_SUCCESS) {
- pfc_log_debug("No boundaries associated with controller name2");
- }
- pfc_log_debug("From db, vect_boundary size is %d",
- static_cast<int>(vect_key_boundary.size()));
- for (unsigned int index = 0;
- index < vect_key_boundary.size();
- ++index) {
- if (vect_val_boundary_st[index].oper_status ==
- UPPL_BOUNDARY_OPER_UP) {
- continue;
- }
- string controller_name =
- (const char*) vect_val_boundary_st[index].\
+ } else {
+ controller_name = (const char*) vect_val_boundary_st[index].\
boundary.controller_name1;
pfc_log_info(
- "Kt_Boundary::HandleOperStatus() - controller1 name: %s",
+ "Kt_Boundary::HandleOperStatus() controller1 name: %s",
controller_name.c_str());
- string domain_name =
- (const char*) vect_val_boundary_st[index].\
+ domain_name = (const char*) vect_val_boundary_st[index].\
boundary.domain_name1;
- string port_id =
- (const char*) vect_val_boundary_st[index].\
+ port_id = (const char*) vect_val_boundary_st[index].\
boundary.logical_port_id1;
- UpplBoundaryOperStatus second_oper_status =
- getBoundaryInputOperStatus(data_type, controller_name,
- domain_name, port_id);
- pfc_log_info("oper status for set1 %d", second_oper_status);
- if (second_oper_status == UPPL_BOUNDARY_OPER_UP) {
- SetOperStatus(data_type,
- reinterpret_cast<void*>(&vect_key_boundary[index]),
- reinterpret_cast<void*>(NULL), UPPL_BOUNDARY_OPER_UP);
- }
}
+ UpplBoundaryOperStatus second_oper_status =
+ getBoundaryInputOperStatus(db_conn, data_type, controller_name,
+ domain_name, port_id,
+ ref_oper_status);
+ pfc_log_info("oper status for set2 %d", second_oper_status);
+ SetOperStatus(db_conn, UNC_DT_STATE,
+ reinterpret_cast<void*>(&vect_key_boundary[index]),
+ reinterpret_cast<void*>
+ (&vect_val_boundary_st[index].boundary),
+ second_oper_status);
}
FN_END_TIME("HandleOperStatus", "Boundary");
return return_code;
/** SetOperStatus
* @Description : This function updates the oper status in db
- * * @param[in] : val and oper_status
- * * @return : Success or associated error code
+ * @param[in] :data_type
+ * key_struct-void* to bdry key structure
+ * value_struct-void* to bdry value structure
+ * oper_status-oper status of boundary
+ * @return : Success or associated error code,
+ * UPPL_RC_SUCCESS/ERR*
*/
-UpplReturnCode Kt_Boundary::SetOperStatus(uint32_t data_type,
- void* key_struct, void* value_struct,
+UpplReturnCode Kt_Boundary::SetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ void* key_struct,
+ void* value_struct,
UpplBoundaryOperStatus oper_status) {
- UpplReturnCode set_status_1 = UPPL_RC_SUCCESS, set_status_2 = UPPL_RC_SUCCESS;
+ UpplReturnCode set_status_1 = UPPL_RC_SUCCESS;
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
- TableAttrSchema kt_boundary_table_attr_schema;
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
vector<string> vect_prim_keys;
- string empty, controller_name, domain_name, logical_port_id;
+ string empty = "";
+ string controller_name = "";
+ string domain_name = "";
+ string logical_port_id = "";
map<string, uint8_t> bdry_notfn;
- if (key_struct != NULL) {
- key_boundary_t *obj_key_boundary=
- reinterpret_cast<key_boundary_t*>(key_struct);
- string boun_id = (const char *)obj_key_boundary->boundary_id;
- // boundary_id
- vect_prim_keys.push_back(BDRY_ID);
- PhyUtil::FillDbSchema(BDRY_ID, boun_id.c_str(),
- boun_id.length()+1, DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
- uint8_t oper_status_in_db = 0;
- UpplReturnCode get_status = GetOperStatus(data_type,
- key_struct,
- oper_status_in_db);
- if (get_status == UPPL_RC_SUCCESS) {
- bdry_notfn[boun_id] = oper_status_in_db;
- }
- } else if (value_struct != NULL) {
+ bool ctr1_valid = false;
+ if (value_struct != NULL) {
val_boundary *obj_val_boundary=
reinterpret_cast<val_boundary_t*>(value_struct);
if (obj_val_boundary->valid[kIdxBoundaryControllerName1] == UNC_VF_VALID) {
- if (obj_val_boundary->valid[kIdxBoundaryDomainName1] == UNC_VF_VALID &&
- obj_val_boundary->valid[kIdxBoundaryLogicalPortId1] == UNC_VF_VALID) {
- controller_name = (const char*)obj_val_boundary->controller_name1;
+ controller_name = (const char*)obj_val_boundary->controller_name1;
+ ctr1_valid = true;
+ if (obj_val_boundary->valid[kIdxBoundaryDomainName1] == UNC_VF_VALID) {
domain_name = (const char*)obj_val_boundary->domain_name1;
+ }
+ if (obj_val_boundary->valid[kIdxBoundaryLogicalPortId1] == UNC_VF_VALID) {
logical_port_id = (const char*)obj_val_boundary->logical_port_id1;
- } else {
- pfc_log_info("domain/logical_port's invalid flag, for set 1");
- return UPPL_RC_ERR_BAD_REQUEST;
}
} else if (obj_val_boundary->valid[kIdxBoundaryControllerName2]
== UNC_VF_VALID) {
- if (obj_val_boundary->valid[kIdxBoundaryDomainName2] == UNC_VF_VALID &&
- obj_val_boundary->valid[kIdxBoundaryLogicalPortId2] == UNC_VF_VALID) {
- controller_name = (const char*)obj_val_boundary->controller_name2;
+ controller_name = (const char*)obj_val_boundary->controller_name2;
+ if (obj_val_boundary->valid[kIdxBoundaryDomainName2] == UNC_VF_VALID) {
domain_name = (const char*)obj_val_boundary->domain_name2;
+ }
+ if (obj_val_boundary->valid[kIdxBoundaryLogicalPortId2] == UNC_VF_VALID) {
logical_port_id = (const char*)obj_val_boundary->logical_port_id2;
- } else {
- pfc_log_error("domain/logical_port's invalid flag, for set 2");
- return UPPL_RC_ERR_BAD_REQUEST;
}
} else {
pfc_log_info("controller_name1/2 flag is not valid");
return UPPL_RC_ERR_BAD_REQUEST;
}
-
- // controller_name1
- vect_prim_keys.push_back(BDRY_CTR_NAME1);
- PhyUtil::FillDbSchema(BDRY_CTR_NAME1, controller_name,
- controller_name.length(), DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
-
- // domain_name1
- vect_prim_keys.push_back(BDRY_DM_NAME1);
- PhyUtil::FillDbSchema(BDRY_DM_NAME1, domain_name,
- domain_name.length(), DATATYPE_UINT8_ARRAY_32,
+ }
+ if (key_struct != NULL) {
+ key_boundary_t *obj_key_boundary=
+ reinterpret_cast<key_boundary_t*>(key_struct);
+ string boun_id = (const char *)obj_key_boundary->boundary_id;
+ // boundary_id
+ vect_prim_keys.push_back(BDRY_ID_STR);
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_ID, boun_id.c_str(),
+ boun_id.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
+ uint8_t oper_status_in_db = 0;
+ UpplReturnCode get_status = GetOperStatus(db_conn, data_type,
+ key_struct,
+ oper_status_in_db);
+ if (get_status == UPPL_RC_SUCCESS) {
+ bdry_notfn[boun_id] = oper_status_in_db;
+ }
+ } else if (value_struct != NULL) {
+ if (ctr1_valid == true) {
+ // controller_name1
+ vect_prim_keys.push_back(BDRY_CTR_NAME1_STR);
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_CTR_NAME1, controller_name,
+ controller_name.length(), DATATYPE_UINT8_ARRAY_32,
+ vect_table_attr_schema);
+
+ if (!domain_name.empty()) {
+ // domain_name1
+ vect_prim_keys.push_back(BDRY_DM_NAME1_STR);
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_DM_NAME1, domain_name,
+ domain_name.length(), DATATYPE_UINT8_ARRAY_32,
+ vect_table_attr_schema);
+ }
- // logical_port_id1
- vect_prim_keys.push_back(BDRY_PORT_ID1);
- PhyUtil::FillDbSchema(BDRY_PORT_ID1, logical_port_id,
- logical_port_id.length(), DATATYPE_UINT8_ARRAY_320,
- vect_table_attr_schema);
+ if (!logical_port_id.empty()) {
+ // logical_port_id1
+ vect_prim_keys.push_back(BDRY_PORT_ID1_STR);
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_PORT_ID1, logical_port_id,
+ logical_port_id.length(),
+ DATATYPE_UINT8_ARRAY_320,
+ vect_table_attr_schema);
+ }
+ } else {
+ // controller_name2
+ vect_prim_keys.push_back(BDRY_CTR_NAME2_STR);
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_CTR_NAME2, controller_name,
+ controller_name.length(), DATATYPE_UINT8_ARRAY_32,
+ vect_table_attr_schema);
+
+ if (!domain_name.empty()) {
+ // domain_name2
+ vect_prim_keys.push_back(BDRY_DM_NAME2_STR);
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_DM_NAME2, domain_name,
+ domain_name.length(), DATATYPE_UINT8_ARRAY_32,
+ vect_table_attr_schema);
+ }
- UpplReturnCode get_status = GetAllBoundaryOperStatus(controller_name,
+ if (!logical_port_id.empty()) {
+ // logical_port_id2
+ vect_prim_keys.push_back(BDRY_PORT_ID2_STR);
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_PORT_ID2, logical_port_id,
+ logical_port_id.length(),
+ DATATYPE_UINT8_ARRAY_320,
+ vect_table_attr_schema);
+ }
+ }
+ UpplReturnCode get_status = GetAllBoundaryOperStatus(db_conn,
+ controller_name,
domain_name,
logical_port_id,
bdry_notfn,
// oper_status
string oper_value = PhyUtil::uint8tostr(oper_status);
- PhyUtil::FillDbSchema(BDRY_OPER_STATUS, oper_value,
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_OPER_STATUS, oper_value,
oper_value.length(), DATATYPE_UINT16,
vect_table_attr_schema);
DBTableSchema kt_boundary_dbtableschema;
- kt_boundary_dbtableschema.set_table_name(UPPL_BOUNDARY_TABLE);
+ kt_boundary_dbtableschema.set_table_name(unc::uppl::BOUNDARY_TABLE);
kt_boundary_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_boundary_dbtableschema.set_row_list(row_list);
// Call ODBCManager and update
// Send request to ODBC for boundary_table
ODBCM_RC_STATUS update_db_status = physical_layer->get_odbc_manager()->
- UpdateOneRow(UNC_DT_RUNNING, kt_boundary_dbtableschema);
+ UpdateOneRow((unc_keytype_datatype_t)data_type,
+ kt_boundary_dbtableschema, db_conn);
if (update_db_status != ODBCM_RC_SUCCESS) {
- // log error
- pfc_log_error("oper_status update operation failed");
- pfc_log_error("for controller/domain/logical_port set 1");
+ pfc_log_info(
+ "oper_status update operation not success"
+ " for controller/domain/logical_port set 1");
set_status_1 = UPPL_RC_ERR_DB_UPDATE;
}
- if (value_struct != NULL) {
- vect_prim_keys.clear();
- vect_table_attr_schema.clear();
- row_list.clear();
- // controller_name2
- vect_prim_keys.push_back(BDRY_CTR_NAME2);
- PhyUtil::FillDbSchema(BDRY_CTR_NAME2, controller_name,
- controller_name.length(), DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
- // domain_name2
- vect_prim_keys.push_back(BDRY_DM_NAME2);
- PhyUtil::FillDbSchema(BDRY_DM_NAME2, domain_name,
- domain_name.length(), DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
-
- // logical_port_id2
- vect_prim_keys.push_back(BDRY_PORT_ID2);
- PhyUtil::FillDbSchema(BDRY_PORT_ID2, logical_port_id,
- logical_port_id.length(), DATATYPE_UINT8_ARRAY_320,
- vect_table_attr_schema);
- // oper_status
- oper_value = PhyUtil::uint8tostr(oper_status);
- PhyUtil::FillDbSchema(BDRY_OPER_STATUS, oper_value,
- oper_value.length(), DATATYPE_UINT16,
- vect_table_attr_schema);
-
- kt_boundary_dbtableschema.set_table_name(UPPL_BOUNDARY_TABLE);
- kt_boundary_dbtableschema.set_primary_keys(vect_prim_keys);
- row_list.push_back(vect_table_attr_schema);
- kt_boundary_dbtableschema.set_row_list(row_list);
-
- // Call ODBCManager and update
- // Send request to ODBC for boundary_table
- update_db_status = physical_layer->get_odbc_manager()->
- UpdateOneRow(UNC_DT_RUNNING, kt_boundary_dbtableschema);
- if (update_db_status != ODBCM_RC_SUCCESS) {
- // log error
- pfc_log_error(
- "oper_status update operation failed"
- "for controller/domain/logical_port set 2");
- set_status_2 = UPPL_RC_ERR_DB_UPDATE;
- }
- }
- if (set_status_1 == UPPL_RC_SUCCESS ||
- set_status_2 == UPPL_RC_SUCCESS) {
+ if (set_status_1 == UPPL_RC_SUCCESS) {
+ pfc_log_debug("Sending boundary oper status notification");
// Send notification
map<string, uint8_t> :: iterator iter = bdry_notfn.begin();
for (; iter != bdry_notfn.end(); ++iter) {
key_boundary_t bdry_key;
string bdry_id = (*iter).first;
+ if (bdry_id.empty()) {
+ continue;
+ }
uint8_t oper_status_db = (*iter).second;
memcpy(bdry_key.boundary_id, bdry_id.c_str(),
bdry_id.length()+1);
+ pfc_log_debug("Oper_status in db %d, new oper_status %d",
+ oper_status_db, oper_status);
if (oper_status_db != oper_status) {
UpplReturnCode oper_notfn = SendOperStatusNotification(bdry_key,
oper_status_db,
}
/** IsBoundaryReferred
- * * @Description : This function returns true if given key_struct
+ * @Description : This function returns true if given key_struct
* value is referred in boundary table
- * * * @param[in] : keytype, key_struct
- * * * @return : PFC_TRUE/PFC_FALSE
+ * @param[in] : keytype-UNC_KT_BOUNDARY,value od unc_key_type_t
+ * key_struct-void* to bdry key structure
+ * data_type-UNC_DT_*,type of database
+ * @return : PFC_TRUE/PFC_FALSE
*/
-pfc_bool_t Kt_Boundary::IsBoundaryReferred(unc_key_type_t keytype,
+pfc_bool_t Kt_Boundary::IsBoundaryReferred(OdbcmConnectionHandler *db_conn,
+ unc_key_type_t keytype,
void *key_struct,
uint32_t data_type) {
pfc_bool_t is_ref = PFC_FALSE;
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
DBTableSchema kt_dbtableschema;
vector<TableAttrSchema> vect_table_attr_schema;
- TableAttrSchema kt_boundary_table_attr_schema;
list< vector<TableAttrSchema> > row_list;
vector<string> vect_prim_keys;
- string controller_name, domain_name;
+ string controller_name = "";
+ string domain_name = "";
if (keytype == UNC_KT_CONTROLLER) {
// Check whether controller_name1 is referred
key_ctr_t *ctr_key = reinterpret_cast<key_ctr_t*>(key_struct);
controller_name = (const char*)ctr_key->controller_name;
- vect_prim_keys.push_back(BDRY_CTR_NAME1);
+ vect_prim_keys.push_back(BDRY_CTR_NAME1_STR);
// controller_name1
- PhyUtil::FillDbSchema(BDRY_CTR_NAME1, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_CTR_NAME1, controller_name,
controller_name.length(),
DATATYPE_UINT8_ARRAY_32, vect_table_attr_schema);
} else if (keytype == UNC_KT_CTR_DOMAIN) {
controller_name = (const char*)ctr_domain_key->ctr_key.controller_name;
domain_name = (const char*)ctr_domain_key->domain_name;
- vect_prim_keys.push_back(BDRY_CTR_NAME1);
+ vect_prim_keys.push_back(BDRY_CTR_NAME1_STR);
// controller_name1
- PhyUtil::FillDbSchema(BDRY_CTR_NAME1, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_CTR_NAME1, controller_name,
controller_name.length(),
DATATYPE_UINT8_ARRAY_32, vect_table_attr_schema);
- vect_prim_keys.push_back(BDRY_DM_NAME1);
+ vect_prim_keys.push_back(BDRY_DM_NAME1_STR);
// domain_name1
- PhyUtil::FillDbSchema(BDRY_DM_NAME1, domain_name,
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_DM_NAME1, domain_name,
domain_name.length(),
DATATYPE_UINT8_ARRAY_32, vect_table_attr_schema);
} else {
pfc_log_info("unknown key type to check in boundary table");
return is_ref;
}
- kt_dbtableschema.set_table_name(UPPL_BOUNDARY_TABLE);
+ kt_dbtableschema.set_table_name(unc::uppl::BOUNDARY_TABLE);
kt_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_dbtableschema.set_row_list(row_list);
// Send request to ODBC for boundary_table
ODBCM_RC_STATUS read_db_status = physical_layer->
get_odbc_manager()->IsRowExists((unc_keytype_datatype_t)data_type,
- kt_dbtableschema);
+ kt_dbtableschema, db_conn);
if (read_db_status == ODBCM_RC_ROW_EXISTS &&
kt_dbtableschema.db_return_status_ != DELETED) {
pfc_log_info("Given controller/domain is referred in boundary");
key_ctr_t *ctr_key = reinterpret_cast<key_ctr_t*>(key_struct);
controller_name = (const char*)ctr_key->controller_name;
- vect_prim_keys.push_back(BDRY_CTR_NAME2);
+ vect_prim_keys.push_back(BDRY_CTR_NAME2_STR);
// controller_name2
- PhyUtil::FillDbSchema(BDRY_CTR_NAME2, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_CTR_NAME2, controller_name,
controller_name.length(),
DATATYPE_UINT8_ARRAY_32, vect_table_attr_schema);
} else if (keytype == UNC_KT_CTR_DOMAIN) {
controller_name = (const char*)ctr_domain_key->ctr_key.controller_name;
domain_name = (const char*)ctr_domain_key->domain_name;
- vect_prim_keys.push_back(BDRY_CTR_NAME2);
+ vect_prim_keys.push_back(BDRY_CTR_NAME2_STR);
// controller_name2
- PhyUtil::FillDbSchema(BDRY_CTR_NAME2, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_CTR_NAME2, controller_name,
controller_name.length(),
DATATYPE_UINT8_ARRAY_32, vect_table_attr_schema);
- vect_prim_keys.push_back(BDRY_DM_NAME2);
+ vect_prim_keys.push_back(BDRY_DM_NAME2_STR);
// domain_name2
- PhyUtil::FillDbSchema(BDRY_DM_NAME2, domain_name,
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_DM_NAME2, domain_name,
domain_name.length(),
DATATYPE_UINT8_ARRAY_32, vect_table_attr_schema);
}
DBTableSchema kt_dbtableschemaboundary;
- kt_dbtableschemaboundary.set_table_name(UPPL_BOUNDARY_TABLE);
+ kt_dbtableschemaboundary.set_table_name(unc::uppl::BOUNDARY_TABLE);
kt_dbtableschemaboundary.set_primary_keys(vect_prim_keys);
row_list.clear();
row_list.push_back(vect_table_attr_schema);
// Send request to ODBC for boundary_table
read_db_status = physical_layer->
get_odbc_manager()->IsRowExists((unc_keytype_datatype_t)data_type,
- kt_dbtableschemaboundary);
+ kt_dbtableschemaboundary, db_conn);
if (read_db_status == ODBCM_RC_ROW_EXISTS &&
kt_dbtableschemaboundary.db_return_status_ != DELETED) {
pfc_log_info("Given controller/domain is referred in boundary");
}
/** GetBoundaryValidFlag
- * * @Description : This function gets the valid flag from db
- * * * @param[in] : Key, value structure and new valid value
- * * * @return : Success or associated error code
+ * @Description : This function gets the valid flag from db
+ * @param[in] : key_struct-void* to bdry key structure
+ * val_boundary_valid_st-instance of val_boundary_st_t
+ * @return : Success or associated error code,UPPL_RC_SUCCESS/ERR*
* */
UpplReturnCode Kt_Boundary::GetBoundaryValidFlag(
+ OdbcmConnectionHandler *db_conn,
void *key_struct,
- val_boundary_st_t &val_boundary_valid_st) {
+ val_boundary_st_t &val_boundary_valid_st,
+ uint32_t data_type) {
UpplReturnCode return_code = UPPL_RC_SUCCESS;
vector<void *> vect_key_boundary;
vect_key_boundary.push_back(key_struct);
vector<void *> vect_val_boundary;
- return_code = ReadInternal(vect_key_boundary, vect_val_boundary,
- UNC_DT_CANDIDATE, UNC_OP_READ);
+ return_code = ReadInternal(db_conn, vect_key_boundary, vect_val_boundary,
+ data_type, UNC_OP_READ);
if (return_code == UPPL_RC_SUCCESS) {
val_boundary_st_t *val_boundary_new_valid_st =
reinterpret_cast<val_boundary_st_t*>(vect_val_boundary[0]);
}
/** FrameValidValue
- * * @Description : This function converts the string value from db to uint8
- * * * @param[in] : Attribute value and val_ctr_st
- * * * @return : Success or associated error code
+ * @Description : This function converts the string value from db to uint8
+ * @param[in] : attr_value-Attribute value in string
+ * obj_val_boundary_st-object of val_boundary_st
+ * obj_val_boundary-object of val_boundary_t
+ * @return : void
* */
void Kt_Boundary::FrameValidValue(string attr_value,
val_boundary_st &obj_val_boundary_st,
}
/** FrameCsAttrValue
- * * @Description : This function converts the string value from db to uint8
- * * * @param[in] : Attribute value and val_ctr_st
- * * * @return : Success or associated error code
+ * @Description : This function converts the string value from db to uint8
+ * @param[in] : attr_value-Attribute value in string
+ * obj_val_boundary-instance of val_boundary_t
+ * @return :undo
* */
void Kt_Boundary::FrameCsAttrValue(string attr_value,
val_boundary_t &obj_val_boundary) {
}
/** ValidateSiblingFiltering
- * * @Description : This function validates the read sibling filtering conditions
- * * * @param[in] : valid_value of controller_name and domain_name
- * * * @return : Success or associated error code
+ * @Description : This function validates the read sibling filtering conditions
+ * @param[in] : ctr1_valid_val,ctr2_valid_val-valid_value of controller_name
+ * dmn1_valid_val,dmn2_valid_val-valid_value of domain_name
+ * @return : Success or associated error code,UPPL_RC_SUCCESS/ERR*
* */
UpplReturnCode Kt_Boundary::ValidateSiblingFiltering(
unsigned int ctr1_valid_val,
/** GetOperStatus
- * * @Description : This function reads the oper_status value of the boundary
- * * @param[in] : key_struct, data type
- * * @return : oper_status
+ * @Description : This function reads the oper_status value of the boundary
+ * @param[in] : key_struct-void* to bdry key structure
+ * data type-UNC_DT_*,type of database
+ * param[out]:oper_status-oper status of boundary
+ * @return : Success or associated error code,UPPL_RC_SUCCESS/ERR*
*/
-UpplReturnCode Kt_Boundary::GetOperStatus(uint32_t data_type,
+UpplReturnCode Kt_Boundary::GetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
uint8_t &oper_status) {
pfc_log_debug("Begin GetOperStatus");
reinterpret_cast<key_boundary_t*>(key_struct);
string boundary_id = (const char*)obj_key_boundary->boundary_id;
- vect_prim_keys.push_back(BDRY_ID);
- PhyUtil::FillDbSchema(BDRY_ID, boundary_id, boundary_id.length(),
+ vect_prim_keys.push_back(BDRY_ID_STR);
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_ID, boundary_id, boundary_id.length(),
DATATYPE_UINT8_ARRAY_32, vect_table_attr_schema);
- string value;
+ string value = "";
unsigned int valid_val = 0, prev_db_val = 0;
stringstream valid;
- PhyUtil::FillDbSchema(BDRY_OPER_STATUS, value,
- value.length(), DATATYPE_UINT16,
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_OPER_STATUS, BDRY_OPER_STATUS_STR,
+ value, value.length(), DATATYPE_UINT16,
(uint32_t) UNC_OP_READ, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
DBTableSchema kt_boundary_dbtableschema;
- kt_boundary_dbtableschema.set_table_name(UPPL_BOUNDARY_TABLE);
+ kt_boundary_dbtableschema.set_table_name(unc::uppl::BOUNDARY_TABLE);
kt_boundary_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_boundary_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS read_db_status = physical_layer->get_odbc_manager()->
- GetOneRow((unc_keytype_datatype_t)data_type, kt_boundary_dbtableschema);
+ GetOneRow((unc_keytype_datatype_t)data_type, kt_boundary_dbtableschema,
+ db_conn);
if (read_db_status == ODBCM_RC_SUCCESS) {
vector<TableAttrSchema> res_table_attr_schema =
kt_boundary_dbtableschema.get_row_list().front();
res_table_attr_schema.begin();
for (; vect_iter != res_table_attr_schema.end(); ++vect_iter) {
TableAttrSchema tab_schema = (*vect_iter);
- string attr_name = tab_schema.table_attribute_name;
- string attr_value;
- if (attr_name == BDRY_OPER_STATUS) {
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
+ string attr_value = "";
+ if (attr_name == unc::uppl::BDRY_OPER_STATUS) {
PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
DATATYPE_UINT16);
oper_status = atoi(attr_value.c_str());
}
/** SendOperStatusNotification
- * * @Description : This function sends oper status change as notification to
+ * @Description : This function sends oper status change as notification to
* north bound
- * * * @param[in] : key_ctr, old oper status and new oper status
- * * * @return : Success or associated error code
+ * @param[in] : bdry_key-object of bdry key structure
+ * old_oper_st-old oper status
+ * new_oper_st-new oper status
+ * @return : Success or associated error code,UPPL_RC_SUCCESS/ERR*
* */
-UpplReturnCode Kt_Boundary::SendOperStatusNotification(key_boundary_t bdry_key,
- uint8_t old_oper_st,
- uint8_t new_oper_st) {
+UpplReturnCode Kt_Boundary::SendOperStatusNotification(
+ key_boundary_t bdry_key,
+ uint8_t old_oper_st,
+ uint8_t new_oper_st) {
UpplReturnCode status = UPPL_RC_SUCCESS;
int err = 0;
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UNC_DT_STATE,
UNC_KT_BOUNDARY};
err = PhyUtil::sessOutNBEventHeader(ser_evt, rsh);
- pfc_log_debug("%s", (IpctUtil::get_string(bdry_key)).c_str());
- pfc_log_debug("%s", (IpctUtil::get_string(new_val_bdry)).c_str());
- pfc_log_debug("%s", (IpctUtil::get_string(old_val_bdry)).c_str());
err |= ser_evt.addOutput(bdry_key);
err |= ser_evt.addOutput(new_val_bdry);
err |= ser_evt.addOutput(old_val_bdry);
"Server Event addOutput failed, return IPC_WRITE_ERROR");
status = UPPL_RC_ERR_IPC_WRITE_ERROR;
} else {
+ pfc_log_debug("%s", (IpctUtil::get_string(bdry_key)).c_str());
+ pfc_log_debug("%s", (IpctUtil::get_string(new_val_bdry)).c_str());
+ pfc_log_debug("%s", (IpctUtil::get_string(old_val_bdry)).c_str());
// Call IPC server to post the event
status = (UpplReturnCode) physical_layer
->get_ipc_connection_manager()->SendEvent(&ser_evt);
}
/** GetAllBoundaryOperStatus
- * * @Description : This function reads the oper_status value all the boundaries
+ * @Description : This function reads the oper_status value all the boundaries
* provided in the request
- * * @param[in] : DBSchema
- * * @return : all boundary id and oper_status
+ * @param[in] : controller_name-controller id in string
+ * domain_name-domain id in string
+ * logical_port_id-logical port id in string
+ * bdry_notfn-instance of map<string, uint8_t>
+ * data_type-UNC_DT_*,type of database
+ * @return :Success or associated error code
*/
UpplReturnCode Kt_Boundary::GetAllBoundaryOperStatus(
+ OdbcmConnectionHandler *db_conn,
string controller_name,
string domain_name,
string logical_port_id,
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode return_code = UPPL_RC_SUCCESS;
uint32_t max_rep_ct = UPPL_MAX_REP_CT;
- TableAttrSchema kt_boundary_table_attr_schema;
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
vector<string> vect_prim_keys;
// controller_name1
- vect_prim_keys.push_back(BDRY_CTR_NAME1);
- PhyUtil::FillDbSchema(BDRY_CTR_NAME1, controller_name,
+ vect_prim_keys.push_back(BDRY_CTR_NAME1_STR);
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_CTR_NAME1, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- // domain_name1
- vect_prim_keys.push_back(BDRY_DM_NAME1);
- PhyUtil::FillDbSchema(BDRY_DM_NAME1, domain_name,
- domain_name.length(), DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
+ if (!domain_name.empty()) {
+ // domain_name1
+ vect_prim_keys.push_back(BDRY_DM_NAME1_STR);
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_DM_NAME1, domain_name,
+ domain_name.length(), DATATYPE_UINT8_ARRAY_32,
+ vect_table_attr_schema);
+ }
- // logical_port_id1
- vect_prim_keys.push_back(BDRY_PORT_ID1);
- PhyUtil::FillDbSchema(BDRY_PORT_ID1, logical_port_id,
- logical_port_id.length(), DATATYPE_UINT8_ARRAY_320,
+ if (!logical_port_id.empty()) {
+ // logical_port_id1
+ vect_prim_keys.push_back(BDRY_PORT_ID1_STR);
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_PORT_ID1, logical_port_id,
+ logical_port_id.length(), DATATYPE_UINT8_ARRAY_320,
+ vect_table_attr_schema);
+ }
+
+ // boundary_id
+ string boun_id = "";
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_ID, boun_id.c_str(),
+ boun_id.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
+ vect_prim_keys.push_back(BDRY_ID_STR);
// oper_status
- string oper_value;
- PhyUtil::FillDbSchema(BDRY_OPER_STATUS, oper_value,
+ string oper_value = "";
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_OPER_STATUS, oper_value,
oper_value.length(), DATATYPE_UINT16,
vect_table_attr_schema);
- // boundary_id
- string boun_id;
- PhyUtil::FillDbSchema(BDRY_ID, boun_id.c_str(),
- boun_id.length()+1, DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
- vect_prim_keys.push_back(BDRY_ID);
DBTableSchema kt_boundary_dbtableschema;
- kt_boundary_dbtableschema.set_table_name(UPPL_BOUNDARY_TABLE);
+ kt_boundary_dbtableschema.set_table_name(unc::uppl::BOUNDARY_TABLE);
kt_boundary_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_boundary_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS read_db_status = physical_layer->get_odbc_manager()->
GetBulkRows((unc_keytype_datatype_t)data_type, max_rep_ct,
kt_boundary_dbtableschema,
- (unc_keytype_operation_t)UNC_OP_READ_BULK);
- if (read_db_status == ODBCM_RC_SUCCESS) {
- list < vector<TableAttrSchema> > res_boundary_row_list =
- kt_boundary_dbtableschema.get_row_list();
- list < std::vector <TableAttrSchema> > :: iterator iter =
- res_boundary_row_list.begin();
- for (; iter != res_boundary_row_list.end(); ++iter) {
- vector<TableAttrSchema> res_table_attr_schema = (*iter);
- vector<TableAttrSchema> ::iterator vect_iter =
- res_table_attr_schema.begin();
- uint8_t oper_status = 0;
- string bdry_id;
- for (; vect_iter != res_table_attr_schema.end(); ++vect_iter) {
- TableAttrSchema tab_schema = (*vect_iter);
- string attr_name = tab_schema.table_attribute_name;
- string attr_value;
- if (attr_name == BDRY_OPER_STATUS) {
+ (unc_keytype_operation_t)UNC_OP_READ_BULK, db_conn);
+ pfc_log_debug("GetBulk return %d", read_db_status);
+ if (read_db_status != ODBCM_RC_SUCCESS) {
+ return_code = UPPL_RC_ERR_DB_GET;
+ }
+ list < vector<TableAttrSchema> >& res_boundary_row_list =
+ kt_boundary_dbtableschema.get_row_list();
+ list < std::vector <TableAttrSchema> > :: iterator iter =
+ res_boundary_row_list.begin();
+ for (; iter != res_boundary_row_list.end(); ++iter) {
+ vector<TableAttrSchema> res_table_attr_schema = (*iter);
+ vector<TableAttrSchema> ::iterator vect_iter =
+ res_table_attr_schema.begin();
+ uint8_t oper_status = 0;
+ string bdry_id = "";
+ for (; vect_iter != res_table_attr_schema.end(); ++vect_iter) {
+ TableAttrSchema tab_schema = (*vect_iter);
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
+ string attr_value = "";
+ switch (attr_name) {
+ case unc::uppl::BDRY_OPER_STATUS:
PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
DATATYPE_UINT16);
oper_status = atoi(attr_value.c_str());
pfc_log_info("oper_status from DB: %d", oper_status);
break;
- }
- if (attr_name == BDRY_ID) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- bdry_id = atoi(attr_value.c_str());
- pfc_log_info("bdry_id from DB: %s", bdry_id.c_str());
+ case unc::uppl::BDRY_ID:
+ uint8_t bdr_id[ODBCM_SIZE_32];
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema, bdr_id,
+ DATATYPE_UINT8_ARRAY_32);
+ bdry_id = reinterpret_cast<const char*> (bdr_id);
+ pfc_log_info("bdry_id from DB: %s", bdr_id);
+ break;
+ default :
break;
- }
}
- bdry_notfn[bdry_id] = oper_status;
}
- } else {
- return_code = UPPL_RC_ERR_DB_GET;
+ bdry_notfn[bdry_id] = oper_status;
}
-
- vect_prim_keys.clear();
- vect_table_attr_schema.clear();
- row_list.clear();
+ return_code = UPPL_RC_SUCCESS;
+ vector<TableAttrSchema> vect_table_attr_schema_1;
+ list < vector<TableAttrSchema> > row_list_1;
+ vector<string> vect_prim_keys_1;
// controller_name2
- vect_prim_keys.push_back(BDRY_CTR_NAME2);
- PhyUtil::FillDbSchema(BDRY_CTR_NAME2, controller_name,
+ vect_prim_keys_1.push_back(BDRY_CTR_NAME2_STR);
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_CTR_NAME2, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
- // domain_name2
- vect_prim_keys.push_back(BDRY_DM_NAME2);
- PhyUtil::FillDbSchema(BDRY_DM_NAME2, domain_name,
- domain_name.length(), DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
+ vect_table_attr_schema_1);
+ if (!domain_name.empty()) {
+ // domain_name2
+ vect_prim_keys_1.push_back(BDRY_DM_NAME2_STR);
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_DM_NAME2, domain_name,
+ domain_name.length(), DATATYPE_UINT8_ARRAY_32,
+ vect_table_attr_schema_1);
+ }
+
+ if (!logical_port_id.empty()) {
+ // logical_port_id2
+ vect_prim_keys_1.push_back(BDRY_PORT_ID2_STR);
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_PORT_ID2, logical_port_id,
+ logical_port_id.length(), DATATYPE_UINT8_ARRAY_320,
+ vect_table_attr_schema_1);
+ }
- // logical_port_id2
- vect_prim_keys.push_back(BDRY_PORT_ID2);
- PhyUtil::FillDbSchema(BDRY_PORT_ID2, logical_port_id,
- logical_port_id.length(), DATATYPE_UINT8_ARRAY_320,
- vect_table_attr_schema);
- // oper_status
- oper_value.clear();
- PhyUtil::FillDbSchema(BDRY_OPER_STATUS, oper_value,
- oper_value.length(), DATATYPE_UINT16,
- vect_table_attr_schema);
// boundary_id
boun_id.clear();
- PhyUtil::FillDbSchema(BDRY_ID, boun_id.c_str(),
- boun_id.length()+1, DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
- vect_prim_keys.push_back(BDRY_ID);
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_ID, boun_id.c_str(),
+ boun_id.length(), DATATYPE_UINT8_ARRAY_32,
+ vect_table_attr_schema_1);
+ vect_prim_keys_1.push_back(BDRY_ID_STR);
- kt_boundary_dbtableschema.set_table_name(UPPL_BOUNDARY_TABLE);
- kt_boundary_dbtableschema.set_primary_keys(vect_prim_keys);
- row_list.push_back(vect_table_attr_schema);
- kt_boundary_dbtableschema.set_row_list(row_list);
+ // oper_status
+ oper_value.clear();
+ PhyUtil::FillDbSchema(unc::uppl::BDRY_OPER_STATUS, oper_value,
+ oper_value.length(), DATATYPE_UINT16,
+ vect_table_attr_schema_1);
+ DBTableSchema kt_dbtableschema;
+ kt_dbtableschema.set_table_name(unc::uppl::BOUNDARY_TABLE);
+ kt_dbtableschema.set_primary_keys(vect_prim_keys_1);
+ row_list_1.push_back(vect_table_attr_schema_1);
+ kt_dbtableschema.set_row_list(row_list_1);
read_db_status = physical_layer->get_odbc_manager()->
GetBulkRows((unc_keytype_datatype_t)data_type, max_rep_ct,
- kt_boundary_dbtableschema,
- (unc_keytype_operation_t)UNC_OP_READ_BULK);
- if (read_db_status == ODBCM_RC_SUCCESS) {
- list < vector<TableAttrSchema> > res_boundary_row_list =
- kt_boundary_dbtableschema.get_row_list();
- list < std::vector <TableAttrSchema> > :: iterator iter =
- res_boundary_row_list.begin();
- for (; iter != res_boundary_row_list.end(); ++iter) {
- vector<TableAttrSchema> res_table_attr_schema = (*iter);
- vector<TableAttrSchema> ::iterator vect_iter =
- res_table_attr_schema.begin();
- uint8_t oper_status = 0;
- string bdry_id;
- for (; vect_iter != res_table_attr_schema.end(); ++vect_iter) {
- TableAttrSchema tab_schema = (*vect_iter);
- string attr_name = tab_schema.table_attribute_name;
- string attr_value;
- if (attr_name == BDRY_OPER_STATUS) {
+ kt_dbtableschema,
+ (unc_keytype_operation_t)UNC_OP_READ_BULK, db_conn);
+ pfc_log_debug("GetBulk return %d", read_db_status);
+ if (read_db_status != ODBCM_RC_SUCCESS) {
+ return_code = UPPL_RC_ERR_DB_GET;
+ }
+ list < vector<TableAttrSchema> >& res_boundary_row_list_1 =
+ kt_dbtableschema.get_row_list();
+ iter = res_boundary_row_list_1.begin();
+ for (; iter != res_boundary_row_list_1.end(); ++iter) {
+ vector<TableAttrSchema> res_table_attr_schema = (*iter);
+ vector<TableAttrSchema> ::iterator vect_iter =
+ res_table_attr_schema.begin();
+ uint8_t oper_status = 0;
+ string bdry_id = "";
+ for (; vect_iter != res_table_attr_schema.end(); ++vect_iter) {
+ TableAttrSchema tab_schema = (*vect_iter);
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
+ string attr_value = "";
+ switch (attr_name) {
+ case unc::uppl::BDRY_OPER_STATUS:
PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
DATATYPE_UINT16);
oper_status = atoi(attr_value.c_str());
pfc_log_info("oper_status from DB: %d", oper_status);
break;
- }
- if (attr_name == BDRY_ID) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- bdry_id = atoi(attr_value.c_str());
- pfc_log_info("bdry_id from DB: %s", bdry_id.c_str());
+ case unc::uppl::BDRY_ID:
+ uint8_t bdr_id[ODBCM_SIZE_32];
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema, bdr_id,
+ DATATYPE_UINT8_ARRAY_32);
+ bdry_id = reinterpret_cast<const char*> (bdr_id);
+ pfc_log_info("bdry_id from DB: %s", bdr_id);
+ break;
+ default:
break;
- }
}
- bdry_notfn[bdry_id] = oper_status;
}
- } else {
- return_code = UPPL_RC_ERR_DB_GET;
+ bdry_notfn[bdry_id] = oper_status;
}
return return_code;
}
+
+/** CheckBoundaryExistence
+ * @Description : This function checks whether boundary already exists with
+ * given value structure
+ * @param[in] : key struct - boundary key structure
+ * value_struct - boundary value structure
+ * data_type-UNC_DT_*,type of database
+ * @return :Success or associated error code
+ */
+UpplReturnCode Kt_Boundary::CheckBoundaryExistence(
+ OdbcmConnectionHandler *db_conn,
+ void *key_struct,
+ void *val_struct,
+ uint32_t data_type) {
+ UpplReturnCode status = UPPL_RC_SUCCESS;
+ // Check whether same boundary exists already
+ vector<void *> vect_key, vect_val;
+ vect_key.push_back(key_struct);
+ vect_val.push_back(val_struct);
+ UpplReturnCode read_status = ReadInternal(db_conn, vect_key,
+ vect_val,
+ data_type,
+ UNC_OP_READ_SIBLING_BEGIN);
+ if (read_status == UPPL_RC_SUCCESS) {
+ for (unsigned int index = 0; index < vect_key.size(); ++index) {
+ // Clear the memory
+ val_boundary_st_t *boundary_val_st =
+ reinterpret_cast<val_boundary_st_t*>(vect_val[index]);
+ if (boundary_val_st != NULL) {
+ if (boundary_val_st->boundary.cs_row_status != DELETED) {
+ pfc_log_info(
+ "Already a boundary exists with same domain/logicalport");
+ status = UPPL_RC_ERR_CFG_SEMANTIC;
+ }
+ delete boundary_val_st;
+ boundary_val_st = NULL;
+ }
+ key_boundary_t *bdry_key = reinterpret_cast<key_boundary_t*>
+ (vect_key[index]);
+ if (bdry_key != NULL) {
+ delete bdry_key;
+ bdry_key = NULL;
+ }
+ }
+ }
+ if (status != UPPL_RC_SUCCESS) {
+ return status;
+ }
+ // Check with reverse combination as well
+ val_boundary_t val_new_bdry;
+ memset(&val_new_bdry, 0, sizeof(val_new_bdry));
+ val_boundary_t *obj_boundary_val =
+ reinterpret_cast<val_boundary_t*>(val_struct);
+ memcpy(val_new_bdry.description, obj_boundary_val->description,
+ sizeof(val_new_bdry.description));
+ memcpy(val_new_bdry.controller_name1, obj_boundary_val->controller_name2,
+ sizeof(val_new_bdry.controller_name1));
+ memcpy(val_new_bdry.domain_name1, obj_boundary_val->domain_name2,
+ sizeof(val_new_bdry.domain_name1));
+ memcpy(val_new_bdry.logical_port_id1, obj_boundary_val->logical_port_id2,
+ sizeof(val_new_bdry.logical_port_id1));
+ memcpy(val_new_bdry.controller_name2, obj_boundary_val->controller_name1,
+ sizeof(val_new_bdry.controller_name2));
+ memcpy(val_new_bdry.domain_name2, obj_boundary_val->domain_name1,
+ sizeof(val_new_bdry.domain_name2));
+ memcpy(val_new_bdry.logical_port_id2, obj_boundary_val->logical_port_id1,
+ sizeof(val_new_bdry.logical_port_id2));
+ stringstream new_valid;
+ new_valid << obj_boundary_val->valid[kIdxBoundaryDescription] <<
+ obj_boundary_val->valid[kIdxBoundaryControllerName2] <<
+ obj_boundary_val->valid[kIdxBoundaryDomainName2] <<
+ obj_boundary_val->valid[kIdxBoundaryLogicalPortId2] <<
+ obj_boundary_val->valid[kIdxBoundaryControllerName1] <<
+ obj_boundary_val->valid[kIdxBoundaryDomainName1] <<
+ obj_boundary_val->valid[kIdxBoundaryLogicalPortId1];
+ memcpy(val_new_bdry.valid, (new_valid.str()).c_str(),
+ sizeof(val_new_bdry.valid));
+ val_new_bdry.cs_row_status = obj_boundary_val->cs_row_status;
+ memcpy(val_new_bdry.cs_attr, obj_boundary_val->cs_attr,
+ sizeof(val_new_bdry.cs_attr));
+ vect_key.clear();
+ vect_val.clear();
+ vect_key.push_back(key_struct);
+ vect_val.push_back(reinterpret_cast<void*>(&val_new_bdry));
+ read_status = ReadInternal(db_conn, vect_key,
+ vect_val,
+ data_type,
+ UNC_OP_READ_SIBLING_BEGIN);
+ if (read_status == UPPL_RC_SUCCESS) {
+ for (unsigned int index = 0; index < vect_key.size(); ++index) {
+ // Clear the memory
+ val_boundary_st_t *boundary_val_st =
+ reinterpret_cast<val_boundary_st_t*>(vect_val[index]);
+ if (boundary_val_st != NULL) {
+ if (boundary_val_st->boundary.cs_row_status != DELETED) {
+ pfc_log_info(
+ "Already a boundary exists with same domain/logicalport");
+ status = UPPL_RC_ERR_CFG_SEMANTIC;
+ }
+ delete boundary_val_st;
+ boundary_val_st = NULL;
+ }
+ key_boundary_t *bdry_key = reinterpret_cast<key_boundary_t*>
+ (vect_key[index]);
+ if (bdry_key != NULL) {
+ delete bdry_key;
+ bdry_key = NULL;
+ }
+ }
+ }
+ return status;
+}
#include "unc/upll_svc.h"
#include "unc/upll_errno.h"
#include "ipct_util.hh"
+#include "itc_read_request.hh"
using unc::uppl::PhysicalLayer;
using unc::uppl::ODBCMUtils;
+using unc::uppl::ODBCMTableColumns;
+#define IPCT_USER "user" // attribute name in val_ctr is "user"
+// and field name in database is "user_name"
/** Constructor
- * * @Description : This function initializes member variables
+ * @Description : This function initializes member variables
* and fills the attribute syntax map used for validation
- * * * @param[in] : None
- * * * @return : None
+ * @param[in] : None
+ * @return : None
* */
Kt_Controller::Kt_Controller() {
// Populate structure to be used for syntax validation
- Fill_Attr_Syntax_Map();
- /* Parent and child instances will be initialized inside
+ if (attr_syntax_map_all.find(UNC_KT_CONTROLLER) ==
+ attr_syntax_map_all.end()) {
+ Fill_Attr_Syntax_Map();
+ }
+ /* Child instances will be initialized inside
* member functions whenever required */
- parent = NULL;
for (int i = 0; i < KT_CONTROLLER_CHILD_COUNT; ++i) {
child[i] = NULL;
}
}
/** Destructor
- * * @Description : This function frees the parent and child key types
+ * @Description : This function frees the child key instances
* instances for kt_controller
- * * * @param[in] : None
- * * * @return : None
+ * @param[in] : None
+ * @return : None
* */
Kt_Controller::~Kt_Controller() {
- if (parent != NULL) {
- delete parent;
- parent = NULL;
- }
for (int i = 0; i < KT_CONTROLLER_CHILD_COUNT; ++i) {
if (child[i] != NULL) {
delete child[i];
}
/** GetChildClassPointer
- * * @Description : This function creates a new child class instance
+ * @Description : This function creates a new child class instance
* class of KtController based on index passed
- * * @param[in] : KIndex - Child class index enum
- * * @return : Kt_Base* - The child class pointer
+ * @param[in] : KIndex - Child class index enum
+ * @return : Kt_Base* - The child class pointer
*/
Kt_Base* Kt_Controller::GetChildClassPointer(KtControllerChildClass KIndex) {
switch (KIndex) {
/** Create
- * * @Description : This function creates a new row of KT_Controller in
+ * @Description : This function creates a new row of KT_Controller in
* candidate controller table.
- * * @param[in] : session_id - ipc session id used for TC validation
+ * @param[in] : session_id - ipc session id used for TC validation
* configuration_id - configuration id used for TC validation
* key_struct - the key for the new kt controller instance
* value_struct - the values for the new kt controller instance
* data_type - UNC_DT_* , Create only allowed in candidate
* sess - ipc server session where the response has to be added
- * * @return : UPPL_RC_SUCCESS is returned when the response
+ * @return : UPPL_RC_SUCCESS is returned when the response
* is added to ipc session successfully.
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_Controller::Create(uint32_t session_id,
+UpplReturnCode Kt_Controller::Create(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
} else {
val_ctr_t obj_val_ctr = *(reinterpret_cast<val_ctr_t*>(val_struct));
if (obj_val_ctr.type == UNC_CT_UNKNOWN) {
- create_status = ValidateUnknownCtrlrScalability(key_struct,
+ create_status = ValidateUnknownCtrlrScalability(db_conn, key_struct,
obj_val_ctr.type,
data_type);
}
if (create_status == UPPL_RC_SUCCESS) {
- create_status = CreateKeyInstance(key_struct,
+ create_status = CreateKeyInstance(db_conn, key_struct,
val_struct,
data_type,
UNC_KT_CONTROLLER);
}
/** CreateKeyInstance
- * * @Description : This function creates a new row of KT_Controller in
+ * @Description : This function creates a new row of KT_Controller in
* candidate controller table.
* key_struct - the key for the new kt controller instance
* value_struct - the values for the new kt controller instance
* data_type - UNC_DT_* , Create only allowed in candidate
- * * @return : UPPL_RC_SUCCESS is returned when the create is success
+ * key_type-UNC_KT_CONTROLLER,value of unc_key_type_t
+ * @return : UPPL_RC_SUCCESS is returned when the create is success
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_Controller::CreateKeyInstance(void* key_struct,
+UpplReturnCode Kt_Controller::CreateKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t key_type) {
// Create DBSchema structure for controller_table
void *old_val_struct;
vector<ODBCMOperator> vect_key_operations;
- PopulateDBSchemaForKtTable(kt_controller_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_controller_dbtableschema,
key_struct,
val_struct,
- UNC_OP_CREATE, 0, 0,
+ UNC_OP_CREATE, data_type, 0, 0,
vect_key_operations, old_val_struct);
// Send request to ODBC for controller_table create
ODBCM_RC_STATUS create_db_status = physical_layer->get_odbc_manager()->\
CreateOneRow((unc_keytype_datatype_t)data_type,
- kt_controller_dbtableschema);
- pfc_log_info("CreateOneRow error response from DB is %d",
- create_db_status);
+ kt_controller_dbtableschema, db_conn);
if (create_db_status != ODBCM_RC_SUCCESS) {
if (create_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log fatal error to log daemon
}
/** Update
- * * @Description : This function updates a row of KT_Controller in
+ * @Description : This function updates a row of KT_Controller in
* candidate controller table.
- * * @param[in] : session_id - ipc session id used for TC validation
+ * @param[in] : session_id - ipc session id used for TC validation
* configuration_id - configuration id used for TC validation
* key_struct - the key for the kt controller instance
* value_struct - the values for the kt controller instance
* data_type - UNC_DT_* , Update only allowed in candidate
* sess - ipc server session where the response has to be added
- * * @return : UPPL_RC_SUCCESS is returned when the response
+ * @return : UPPL_RC_SUCCESS is returned when the response
* is added to ipc session successfully.
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_Controller::Update(uint32_t session_id,
+UpplReturnCode Kt_Controller::Update(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
data_type);
update_status = UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
} else {
- update_status = UpdateKeyInstance(key_struct,
+ update_status = UpdateKeyInstance(db_conn, key_struct,
val_struct,
data_type,
UNC_KT_CONTROLLER);
}
/** UpdateKeyInstance
- * * @Description : This function updates a row of KT_Controller in
+ * @Description : This function updates a row of KT_Controller in
* candidate controller table.
- * * @param[in] :
+ * @param[in] :
* key_struct - the key for the new kt controller instance
* value_struct - the values for the new kt controller instance
* data_type - UNC_DT_* , update only allowed in candidate
- * * @return : UPPL_RC_SUCCESS is returned when the update
+ * key_type-UNC_KT_CONTROLLER,value of unc_key_type_t
+ * @return : UPPL_RC_SUCCESS is returned when the update
* is done successfully.
* UPPL_RC_ERR_* is returned when the update is error
* */
-UpplReturnCode Kt_Controller::UpdateKeyInstance(void* key_struct,
+UpplReturnCode Kt_Controller::UpdateKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t key_type) {
// Create DBSchema structure for controller_table
void *old_val_struct;
vector<ODBCMOperator> vect_key_operations;
- PopulateDBSchemaForKtTable(kt_controller_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_controller_dbtableschema,
key_struct,
val_struct,
- UNC_OP_UPDATE, 0, 0,
+ UNC_OP_UPDATE, data_type, 0, 0,
vect_key_operations, old_val_struct);
if (!((kt_controller_dbtableschema.get_row_list()).empty())) {
// Send request to ODBC for controller_table update
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
ODBCM_RC_STATUS update_db_status = physical_layer->get_odbc_manager()-> \
UpdateOneRow((unc_keytype_datatype_t)data_type,
- kt_controller_dbtableschema);
- pfc_log_info("UpdateOneRow response from DB is %d", update_db_status);
+ kt_controller_dbtableschema, db_conn);
if (update_db_status != ODBCM_RC_SUCCESS) {
if (update_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log fatal error to log daemon
}
/**Delete
- * * @Description : This function deletes a row of KT_Controller in
+ * @Description : This function deletes a row of KT_Controller in
* candidate controller table.
- * * @param[in] : session_id - ipc session id used for TC validation
+ * @param[in] : session_id - ipc session id used for TC validation
* configuration_id - configuration id used for TC validation
* key_struct - the key for the kt controller instance
* data_type - UNC_DT_* , delete only allowed in candidate
* sess - ipc server session where the response has to be added
- * * @return : UPPL_RC_SUCCESS is returned when the response
+ * @return : UPPL_RC_SUCCESS is returned when the response
* is added to ipc session successfully.
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_Controller::Delete(uint32_t session_id,
+UpplReturnCode Kt_Controller::Delete(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
uint32_t data_type,
UpplReturnCode delete_status = UPPL_RC_SUCCESS;
key_ctr_t *obj_key_ctr = reinterpret_cast<key_ctr_t*>(key_struct);
string controller_name = (const char*)obj_key_ctr->controller_name;
+ // Check whether the controller is being imported
+ PhysicalCore *physical_core = PhysicalLayer::get_instance()->
+ get_physical_core();
+ InternalTransactionCoordinator *itc_trans =
+ physical_core->get_internal_transaction_coordinator();
+ if (itc_trans->IsControllerInImport(controller_name) == PFC_TRUE) {
+ pfc_log_info("Import is in progress for controller %s, Delete not allowed",
+ controller_name.c_str());
+ delete_status = UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
+ // Populate the response to be sent in ServerSession
+ physical_response_header rsh = {session_id,
+ configuration_id,
+ UNC_OP_DELETE,
+ 0,
+ 0,
+ 0,
+ data_type,
+ delete_status};
+ int err = PhyUtil::sessOutRespHeader(sess, rsh);
+ err |= sess.addOutput((uint32_t)UNC_KT_CONTROLLER);
+ err |= sess.addOutput(*obj_key_ctr);
+ if (err != 0) {
+ pfc_log_debug(
+ "Server session addOutput failed, so return IPC_WRITE_ERROR");
+ delete_status = UPPL_RC_ERR_IPC_WRITE_ERROR;
+ } else {
+ delete_status = UPPL_RC_SUCCESS;
+ }
+ return delete_status;
+ }
Kt_Boundary boundary_class;
// Check whether any boundary is referring controller
pfc_bool_t is_bdry_referred = PFC_FALSE;
is_bdry_referred = boundary_class.IsBoundaryReferred(
- UNC_KT_CONTROLLER, key_struct, data_type);
+ db_conn, UNC_KT_CONTROLLER, key_struct, data_type);
if (is_bdry_referred == PFC_TRUE) {
// Boundary is referring controller
pfc_log_error(
(KtControllerChildClass)child_class);
if (child[child_class] != NULL) {
UpplReturnCode ch_delete_status =
- child[child_class]->DeleteKeyInstance(
- child_key_struct,
- data_type,
- UNC_KT_CTR_DOMAIN);
+ child[child_class]->DeleteKeyInstance(db_conn,
+ child_key_struct,
+ data_type,
+ UNC_KT_CTR_DOMAIN);
delete child[child_class];
child[child_class] = NULL;
FreeChildKeyStruct(child_key_struct, child_class);
}
// Delete the controller now
if (delete_status == UPPL_RC_SUCCESS) {
- delete_status = DeleteKeyInstance(key_struct, data_type,
+ delete_status = DeleteKeyInstance(db_conn, key_struct, data_type,
UNC_KT_CONTROLLER);
}
}
}
/**DeleteKeyInstance
- * * @Description : This function deletes a row of KT_Controller in
+ * @Description : This function deletes a row of KT_Controller in
* candidate controller table.
- * * @param[in] :
+ * @param[in] :
* key_struct - the key for the new kt controller instance
* data_type - UNC_DT_* , delete only allowed in candidate
- * * @return : UPPL_RC_SUCCESS is returned when the delete
+ * key_type-UNC_DT_CONTROLLER,value of unc_keytype_t
+ * @return : UPPL_RC_SUCCESS is returned when the delete
* is done successfully.
* UPPL_RC_ERR_* is returned when the delete is error
* */
-UpplReturnCode Kt_Controller::DeleteKeyInstance(void* key_struct,
+UpplReturnCode Kt_Controller::DeleteKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
uint32_t key_type) {
UpplReturnCode delete_status = UPPL_RC_SUCCESS;
// Construct Primary key list
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
// Construct TableAttrSchema structure
// TableAttrSchema holds table_name, primary key, attr_name
list< vector<TableAttrSchema> > row_list;
// Controller_name
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// Send request to ODBC for controller_table delete
- kt_controller_dbtableschema.set_table_name(UPPL_CTR_TABLE);
+ kt_controller_dbtableschema.set_table_name(unc::uppl::CTR_TABLE);
kt_controller_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_controller_dbtableschema.set_row_list(row_list);
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
ODBCM_RC_STATUS delete_db_status = physical_layer->get_odbc_manager()-> \
DeleteOneRow((unc_keytype_datatype_t)data_type,
- kt_controller_dbtableschema);
- pfc_log_info("DeleteOneRow error response from DB is %d",
- delete_db_status);
+ kt_controller_dbtableschema, db_conn);
if (delete_db_status != ODBCM_RC_SUCCESS) {
if (delete_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log fatal error to log daemon
}
/** ReadInternal
- * * @Description : This function reads the given instance of KT_Controller
- ** * @param[in] : session_id - ipc session id used for TC validation
+ * @Description : This function reads the given instance of KT_Controller
+ * @param[in] : session_id - ipc session id used for TC validation
* key_struct - the key for the kt controller instance
* value_struct - the value for the kt controller instance
* data_type - UNC_DT_* , read allowed in candidate/running/startup/state
- * * @return : UPPL_RC_SUCCESS is returned when the response
+ * operation_type-UNC_OP_*,type of operation
+ * @return : UPPL_RC_SUCCESS is returned when the response
* is added to ipc session successfully.
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_Controller::ReadInternal(vector<void *> &ctr_key,
+UpplReturnCode Kt_Controller::ReadInternal(OdbcmConnectionHandler *db_conn,
+ vector<void *> &ctr_key,
vector<void *> &ctr_val,
uint32_t data_type,
uint32_t operation_type) {
val_struct = reinterpret_cast<void *>(&st_ctr_val.controller);
}
// Get read response from database
- UpplReturnCode read_status = ReadCtrValFromDB(key_struct,
+ UpplReturnCode read_status = ReadCtrValFromDB(db_conn, key_struct,
val_struct,
data_type,
operation_type,
for (unsigned int iIndex = 0 ; iIndex < vect_controller_id.size();
++iIndex) {
key_ctr_t *key_ctr = new key_ctr_t;
+ memset(key_ctr->controller_name, 0, sizeof(key_ctr->controller_name));
memcpy(key_ctr->controller_name,
vect_controller_id[iIndex].c_str(),
vect_controller_id[iIndex].length()+1);
}
/**ReadBulk
- * * @Description : This function reads bulk rows of KT_Controller in
+ * @Description : This function reads bulk rows of KT_Controller in
* controller table of specified data type.
* Order of ReadBulk response
* val_ctr -> val_ctr_domain -> val_logical_port ->
* val_logical_member_port -> val_switch -> val_port ->
* val_link -> val_boundary
- * * @param[in] :
+ * @param[in] :
* key_struct - the key for the kt controller instance
* data_type - UNC_DT_* , read allowed in candidate/running/startup/state
- * option1/option2 - specifies any additional condition for read operation
* max_rep_ct - specifies number of rows to be returned
+ * child_index-index indicating the children of Controller
* parent_call - indicates whether parent has called this readbulk
* is_read_next - indicates whether this function is invoked from readnext
- * * @return : UPPL_RC_SUCCESS is returned when the response
+ * @return : UPPL_RC_SUCCESS is returned when the response
* is added to ipc session successfully.
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_Controller::ReadBulk(void* key_struct,
+UpplReturnCode Kt_Controller::ReadBulk(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
- uint32_t option1,
- uint32_t option2,
uint32_t &max_rep_ct,
int child_index,
pfc_bool_t parent_call,
- pfc_bool_t is_read_next) {
+ pfc_bool_t is_read_next,
+ ReadRequest *read_req) {
pfc_log_info("Processing ReadBulk of Kt_Controller");
UpplReturnCode read_status = UPPL_RC_SUCCESS;
key_ctr_t* obj_key_ctr= reinterpret_cast<key_ctr_t*>(key_struct);
vector<string> vect_ctr_key_value;
vect_ctr_key_value.push_back(str_controller_name);
UpplReturnCode key_exist_status = IsKeyExists(
+ db_conn,
(unc_keytype_datatype_t)data_type,
vect_ctr_key_value);
if (key_exist_status == UPPL_RC_SUCCESS) {
}
void *val_struct = NULL;
// Read the controller values based on given key structure
- read_status = ReadBulkInternal(
- key_struct,
- val_struct,
- data_type,
- max_rep_ct+1,
- vect_val_ctr,
- vect_ctr_id);
+ read_status = ReadBulkInternal(db_conn,
+ key_struct,
+ val_struct,
+ data_type,
+ max_rep_ct+1,
+ vect_val_ctr,
+ vect_ctr_id);
if (ctr_exists == PFC_TRUE) {
vect_ctr_id.insert(vect_ctr_id.begin(), str_controller_name);
val_ctr_st_t dummy_val_ctr;
}
if (read_status == UPPL_RC_SUCCESS ||
ctr_exists == PFC_TRUE) {
- PhysicalCore *physical_core = PhysicalLayer::get_instance()->
- get_physical_core();
- InternalTransactionCoordinator *itc_trans =
- physical_core->get_internal_transaction_coordinator();
// For each controller, read the child's attributes
vector<val_ctr_st_t> ::iterator vect_iter = vect_val_ctr.begin();
vector<string> ::iterator controller_iter = vect_ctr_id.begin();
UNC_KT_CONTROLLER, IS_KEY,
reinterpret_cast<void *>(ctr_key)
};
- itc_trans->AddToBuffer(obj_key_buffer);
+ read_req->AddToBuffer(obj_key_buffer);
if ((unc_keytype_datatype_t)data_type == UNC_DT_STATE) {
val_ctr_st_t *val_buffer = new val_ctr_st_t(*vect_iter);
BulkReadBuffer obj_value_buffer = {
UNC_KT_CONTROLLER, IS_STATE_VALUE,
reinterpret_cast<void *>(val_buffer)
};
- itc_trans->AddToBuffer(obj_value_buffer);
+ read_req->AddToBuffer(obj_value_buffer);
} else {
val_ctr_t *val_buffer = new val_ctr_t((*vect_iter).controller);
BulkReadBuffer obj_value_buffer = {
UNC_KT_CONTROLLER, IS_VALUE,
reinterpret_cast<void *>(val_buffer)
};
- itc_trans->AddToBuffer(obj_value_buffer);
+ read_req->AddToBuffer(obj_value_buffer);
}
BulkReadBuffer obj_sep_buffer = {
UNC_KT_CONTROLLER, IS_SEPARATOR, NULL
};
- itc_trans->AddToBuffer(obj_sep_buffer);
+ read_req->AddToBuffer(obj_sep_buffer);
--max_rep_ct;
if (max_rep_ct == 0) {
pfc_log_debug("Controller - max_rep_ct reached zero...");
}
pfc_log_debug("Controller Calling child %d read bulk", kIdx);
UpplReturnCode ch_read_status = child[kIdx]->ReadBulk(
- child_key_struct,
+ db_conn, child_key_struct,
data_type,
- option1,
- option2,
max_rep_ct,
-1,
true,
- is_read_next);
+ is_read_next,
+ read_req);
pfc_log_debug("ReadBulk response from child %d is %d",
kIdx, ch_read_status);
delete child[kIdx];
// reset child index
child_index = -1;
}
+ } else if (read_status == UPPL_RC_ERR_DB_ACCESS) {
+ pfc_log_debug("KtController ReadBulk - Returning DB Access Error");
+ return read_status;
}
if (max_rep_ct > 0 && parent_call == false) {
pfc_log_debug("max_rep_ct is %d and parent_call is %d, calling parent",
Kt_Root nextKin;
key_root_t nextkin_key_struct;
read_status = nextKin.ReadBulk(
- reinterpret_cast<void *>(&nextkin_key_struct),
+ db_conn, reinterpret_cast<void *>(&nextkin_key_struct),
data_type,
- option1,
- option2,
max_rep_ct,
0,
false,
- is_read_next);
+ is_read_next,
+ read_req);
pfc_log_debug("read status from next kin Kt_Root is %d",
read_status);
return UPPL_RC_SUCCESS;
}
/**ReadBulkInternal
- * * @Description : This function reads bulk rows of KT_Controller in
+ * @Description : This function reads bulk rows of KT_Controller in
* controller table of specified data type.
- * * @param[in] :
+ * @param[in] :
* key_struct - the key for the kt controller instance
+ * data_type-UNC_DT_*
* val_struct - the value struct for kt_controller instance
* max_rep_ct - specifies number of rows to be returned
* vect_val_ctr - indicates the fetched values from db of val_ctr type
* vect_ctr_id - indicates the fetched contoller names from db
- * * @return : UPPL_RC_SUCCESS is returned when the response
+ * @return : UPPL_RC_SUCCESS is returned when the response
* is added to ipc session successfully.
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
UpplReturnCode Kt_Controller::ReadBulkInternal(
+ OdbcmConnectionHandler *db_conn,
void* key_struct,
void* val_struct,
uint32_t data_type,
// Populate DBSchema for controller_table
void *old_val_struct;
vector<ODBCMOperator> vect_key_operations;
- PopulateDBSchemaForKtTable(kt_controller_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_controller_dbtableschema,
key_struct,
val_struct,
- UNC_OP_READ_BULK, 0, 0,
+ UNC_OP_READ_BULK, data_type, 0, 0,
vect_key_operations, old_val_struct);
// Read rows from DB
read_db_status = physical_layer->get_odbc_manager()-> \
GetBulkRows((unc_keytype_datatype_t)data_type, max_rep_ct,
kt_controller_dbtableschema,
- (unc_keytype_operation_t)UNC_OP_READ_BULK);
+ (unc_keytype_operation_t)UNC_OP_READ_BULK, db_conn);
if (read_db_status == ODBCM_RC_RECORD_NOT_FOUND) {
pfc_log_debug("No record to read");
read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
return read_status;
+ } else if (read_db_status == ODBCM_RC_CONNECTION_ERROR) {
+ read_status = UPPL_RC_ERR_DB_ACCESS;
+ pfc_log_error("ReadBulk operation has failed with %d", read_db_status);
+ return read_status;
} else if (read_db_status != ODBCM_RC_SUCCESS) {
read_status = UPPL_RC_ERR_DB_GET;
pfc_log_error("ReadBulk operation has failed with %d", read_db_status);
}
// From the values received from DB, populate val_ctr structure
- FillControllerValueStructure(kt_controller_dbtableschema,
+ FillControllerValueStructure(db_conn, kt_controller_dbtableschema,
vect_val_ctr,
max_rep_ct,
UNC_OP_READ_BULK,
}
/** PerformSyntaxValidation
- * * @Description : This function performs syntax validation for
+ * @Description : This function performs syntax validation for
* UNC_KT_CONTROLLER
- * * * @param[in]
+ * @param[in]
* key_struct - the key for the kt controller instance
* value_struct - the value for the kt controller instance
- * data_type - UNC_DT_*
- * operation_type - UNC_OP*
- * * @return : UPPL_RC_SUCCESS is returned when the validation is successful
- * UPPL_RC_ERR_* is returned when validtion is failure
+ * data_type - UNC_DT_*,type of database
+ * operation_type - UNC_OP*,type of operation
+ * @return : UPPL_RC_SUCCESS is returned when the validation is successful
+ * UPPL_RC_ERR_* is returned when validation is failure
* */
-UpplReturnCode Kt_Controller::PerformSyntaxValidation(void* key_struct,
- void* val_struct,
- uint32_t operation,
- uint32_t data_type) {
+UpplReturnCode Kt_Controller::PerformSyntaxValidation(
+ OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ void* val_struct,
+ uint32_t operation,
+ uint32_t data_type) {
UpplReturnCode ret_code = UPPL_RC_SUCCESS;
pfc_bool_t mandatory = PFC_TRUE;
-
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map =
+ attr_syntax_map_all[UNC_KT_CONTROLLER];
// Validate key structure
key_ctr *key = reinterpret_cast<key_ctr_t*>(key_struct);
string value = reinterpret_cast<char*>(key->controller_name);
- IS_VALID_STRING_KEY(CTR_NAME, value, operation, ret_code, mandatory);
+ IS_VALID_STRING_KEY(CTR_NAME_STR, value, operation, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
UpplReturnCode ctr_type_code = UPPL_RC_SUCCESS;
if (operation == UNC_OP_UPDATE) {
ctr_type_code = PhyUtil::get_controller_type(
- value,
+ db_conn, value,
ctr_type,
(unc_keytype_datatype_t)data_type);
pfc_log_debug("Controller type - return code %d, value %s",
if (val_struct != NULL) {
val_ctr *val_ctr = reinterpret_cast<val_ctr_t*>(val_struct);
ret_code = ValidateControllerType(
- operation,
+ db_conn, operation,
data_type,
ctr_type,
ctr_type_code,
return UPPL_RC_ERR_CFG_SYNTAX;
}
ret_code = ValidateControllerVersion(
- operation,
+ db_conn, operation,
data_type,
ctr_type,
ctr_type_code,
return UPPL_RC_ERR_CFG_SYNTAX;
}
ret_code = ValidateControllerDescription(
- operation,
+ db_conn, operation,
data_type,
ctr_type,
ctr_type_code,
return UPPL_RC_ERR_CFG_SYNTAX;
}
ret_code = ValidateControllerIpAddress(
- operation,
+ db_conn, operation,
data_type,
ctr_type,
ctr_type_code,
return UPPL_RC_ERR_CFG_SYNTAX;
}
ret_code = ValidateControllerUser(
- operation,
+ db_conn, operation,
data_type,
ctr_type,
ctr_type_code,
return UPPL_RC_ERR_CFG_SYNTAX;
}
ret_code = ValidateControllerPassword(
- operation,
+ db_conn, operation,
data_type,
ctr_type,
ctr_type_code,
return UPPL_RC_ERR_CFG_SYNTAX;
}
ret_code = ValidateControllerEnableAudit(
- operation,
+ db_conn, operation,
data_type,
ctr_type,
ctr_type_code,
}
/** ValidateCtrlrValueCapability
- * * @Description : This function checks capability for UNC_KT_CONTROLLER
- * * * @param[in] : version - specifies the version to be used for validation
- * key type - specifies UNC_KT_CONTROLLER
- * * * @return : UPPL_RC_SUCCESS if validation is successful
+ * @Description : This function checks capability for UNC_KT_CONTROLLER
+ * @param[in] : version - specifies the version to be used for validation
+ * key type - specifies UNC_KT_CONTROLLER,value of unc_key_type_t
+ * @return : UPPL_RC_SUCCESS if validation is successful
* or UPPL_RC_ERR_* if validation is failed
* */
UpplReturnCode Kt_Controller::ValidateCtrlrValueCapability(string version,
UpplReturnCode resp_code = UPPL_RC_SUCCESS;
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
map<string, Kt_Class_Attr_Syntax>::iterator itVal;
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map =
+ attr_syntax_map_all[UNC_KT_CONTROLLER];
for (itVal = attr_syntax_map.begin();
itVal != attr_syntax_map.end();
++itVal) {
string attribute_name = itVal->first;
- if (attribute_name != CTR_NAME &&
- attribute_name != CTR_VALID &&
- attribute_name != CTR_CS_ROW_STATUS &&
- attribute_name != CTR_CS_ATTR) {
+ if (attribute_name != CTR_NAME_STR &&
+ attribute_name != CTR_VALID_STR &&
+ attribute_name != CTR_CS_ROW_STATUS_STR &&
+ attribute_name != CTR_CS_ATTR_STR) {
resp_code = physical_layer->get_physical_core()->
ValidateAttribInCtrlrCap(version,
key_type,
}
/** ValidateCtrlrScalability
- * * @Description : This function checks scalability for UNC_KT_CONTROLLER
- * * * @param[in] : version - specifies the controller version
- * key type - contains UNC_KT_CONTROLLER
- * data_type - UNC_DT_*, scalability number and data_type
- * * * @return : UPPL_RC_SUCCESS if scalability number is within range
+ * @Description : This function checks scalability for UNC_KT_CONTROLLER
+ * @param[in] : version - specifies the controller version
+ * key type - contains UNC_KT_CONTROLLER,value of unc_key_type_t
+ * data_type - UNC_DT_*, type of database
+ * @return : UPPL_RC_SUCCESS if scalability number is within range
* or UPPL_RC_ERR_* if not
* */
-UpplReturnCode Kt_Controller::ValidateCtrlrScalability(string version,
- uint32_t key_type,
- uint32_t data_type) {
+UpplReturnCode Kt_Controller::ValidateCtrlrScalability(
+ OdbcmConnectionHandler *db_conn,
+ string version,
+ uint32_t key_type,
+ uint32_t data_type) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
// Structure used to send request to ODBC
// Send request to ODBC for controller_table create
string table_name = UPPL_CTR_TABLE;
response_status = physical_layer->get_odbc_manager()->\
GetRowCount((unc_keytype_datatype_t)data_type,
- table_name, response_count);
+ table_name, response_count, db_conn);
if (response_status == ODBCM_RC_CONNECTION_ERROR) {
// log error to log daemon
pfc_log_error("DB connection not available or cannot access DB");
}
/** ValidateUnKnownCtrlrScalability
- * * @Description : This function checks scalability for unknown controller
- * * * @param[in] : type - specifies the controller type
- * key type - contains UNC_KT_CONTROLLER
+ * @Description : This function checks scalability for unknown controller
+ * @param[in] : type - specifies the controller type
+ * key_struct - contains UNC_KT_CONTROLLER key structure
* data_type - UNC_DT_*, unknown controler scalability number and data_type
- * * * @return : UPPL_RC_SUCCESS if unknown controler scalability number
+ * @return : UPPL_RC_SUCCESS if unknown controler scalability number
* is within range or UPPL_RC_ERR_* if not
* */
UpplReturnCode Kt_Controller::ValidateUnknownCtrlrScalability(
+ OdbcmConnectionHandler *db_conn,
void *key_struct,
uint8_t type,
uint32_t data_type) {
DBTableSchema kt_controller_dbtableschema;
// Construct Primary key list
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_TYPE);
+ vect_prim_keys.push_back(CTR_TYPE_STR);
std::vector<ODBCMOperator> vect_filter_operators;
vect_filter_operators.push_back(unc::uppl::EQUAL);
// TableAttrSchema holds table_name, primary key, attr_name
vector<TableAttrSchema> vect_table_attr_schema;
list< vector<TableAttrSchema> > row_list;
- PhyUtil::FillDbSchema(CTR_TYPE, value,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_TYPE, value,
value.length(), DATATYPE_UINT16,
vect_table_attr_schema);
- kt_controller_dbtableschema.set_table_name(UPPL_CTR_TABLE);
+ kt_controller_dbtableschema.set_table_name(unc::uppl::CTR_TABLE);
kt_controller_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_controller_dbtableschema.set_row_list(row_list);
response_status = physical_layer->get_odbc_manager()-> \
GetSiblingCount((unc_keytype_datatype_t)data_type,
kt_controller_dbtableschema, count,
- vect_filter_operators);
+ vect_filter_operators, db_conn);
if (response_status == ODBCM_RC_CONNECTION_ERROR) {
// log error to log daemon
}
/** PerformSemanticValidation
- * * @Description : This function performs semantic validation
+ * @Description : This function performs semantic validation
* for UNC_KT_CONTROLLER
- * * * @param[in] : key_struct - specifies key instance of KT_Controller
- * , value_struct - specifies value of KT_CONTROLLER
- * operation - UNC_OP*
- * data_type - UNC_DT*
- * * * @return : UPPL_RC_SUCCESS if semantic valition is successful
+ * @param[in] : key_struct - specifies key instance of KT_Controller
+ * value_struct - specifies value of KT_CONTROLLER,value of unc_key_type_t
+ * operation - UNC_OP*,type of operation
+ * data_type - UNC_DT*,type of database
+ * @return : UPPL_RC_SUCCESS if semantic valition is successful
* or UPPL_RC_ERR_* if failed
* */
-UpplReturnCode Kt_Controller::PerformSemanticValidation(void* key_struct,
- void* val_struct,
- uint32_t operation,
- uint32_t data_type) {
+UpplReturnCode Kt_Controller::PerformSemanticValidation(
+ OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ void* val_struct,
+ uint32_t operation,
+ uint32_t data_type) {
UpplReturnCode status = UPPL_RC_SUCCESS;
// Check whether the given instance of controller exists in DB
string controller_name = (const char*)obj_key_ctr->controller_name;
vector<string> ctr_vect_key_value;
ctr_vect_key_value.push_back(controller_name);
- UpplReturnCode key_status = IsKeyExists((unc_keytype_datatype_t)data_type,
+ UpplReturnCode key_status = IsKeyExists(db_conn,
+ (unc_keytype_datatype_t)data_type,
ctr_vect_key_value);
// In case of create operation, key should not exist
if (operation == UNC_OP_CREATE) {
} else if (key_status == UPPL_RC_ERR_DB_GET) {
pfc_log_debug("Key does not exist. Validate Ip Address/ Type");
// Check whether any controller with same type and ip address exists
- status = ValidateTypeIpAddress(key_struct,
+ status = ValidateTypeIpAddress(db_conn, key_struct,
val_struct,
data_type);
+ if (status == UPPL_RC_SUCCESS) {
+ pfc_log_debug("Validating Type and Ip Address in Running Db");
+ status = ValidateTypeIpAddress(db_conn, key_struct,
+ val_struct,
+ UNC_DT_RUNNING);
+ }
}
} else if (operation == UNC_OP_UPDATE || operation == UNC_OP_DELETE ||
operation == UNC_OP_READ) {
}
/** SendSemanticRequestToUPLL
- * * @Description : This functions calls IPC to check whether UNC_KT_CONTROLLER
+ * @Description : This functions calls IPC to check whether UNC_KT_CONTROLLER
* is being referred in Logical
- * * * @param[in] : key_ctr - specifies key instance of KT_CONTROLLER
- * * * @return : UPPL_RC_SUCCESS if controller is not referred
+ * @param[in] : key_ctr - specifies key instance of KT_CONTROLLER
+ * data_type-UNC_DT_*,type of database
+ * @return : UPPL_RC_SUCCESS if controller is not referred
* or UPPL_RC_ERR_* if controller is referred in logical
* */
UpplReturnCode Kt_Controller::SendSemanticRequestToUPLL(void* key_struct,
}
/** HandleDriverEvents
- * * @Description : This function processes the notification received from
+ * @Description : This function processes the notification received from
* driver
- * * * @param[in] : key_struct - specifies the key instance of KT_CONTROLLER
+ * @param[in] : key_struct - specifies the key instance of KT_CONTROLLER
+ * oper_type-UNC_OP_*,type of operation
+ * data_type-UNC_DT_*,type ,of database
+ * is_events_done-flag to indicate whether event is processed
* old_value_struct - old value of KT_CONTROLLER
* new_value_struct - new value of KT_CONTROLLER
- * * * @return : UPPL_RC_SUCCESS if events are handled successfully or
+ * @return : UPPL_RC_SUCCESS if events are handled successfully or
* UPPL_RC_ERR*
* */
-UpplReturnCode Kt_Controller::HandleDriverEvents(void* key_struct,
- uint32_t oper_type,
- uint32_t data_type,
- void* old_val_struct,
- void* new_val_struct,
- pfc_bool_t is_events_done) {
+UpplReturnCode Kt_Controller::HandleDriverEvents(
+ OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ uint32_t oper_type,
+ uint32_t data_type,
+ void* old_val_struct,
+ void* new_val_struct,
+ pfc_bool_t is_events_done) {
key_ctr *obj_key_ctr= reinterpret_cast<key_ctr_t*>(key_struct);
val_ctr_st *obj_old_val_ctr = reinterpret_cast<val_ctr_st*>(old_val_struct);
val_ctr_st *obj_new_val_ctr = reinterpret_cast<val_ctr_st*>(new_val_struct);
valid_val = PhyUtil::uint8touint(obj_new_val_ctr->valid[kIdxActualVersion]);
if (PhyUtil::IsValidValue(oper_type, valid_val) == true) {
string act_version = (const char*)obj_new_val_ctr->actual_version;
- status = SetActualVersion(key_struct, act_version);
+ status = SetActualVersion(db_conn, key_struct, act_version,
+ UNC_DT_RUNNING, UNC_VF_VALID);
+ if (status != UPPL_RC_SUCCESS) {
+ // log error
+ pfc_log_error("act_version update operation failed for running");
+ }
+ status = SetActualVersion(db_conn, key_struct,
+ act_version, UNC_DT_CANDIDATE, UNC_VF_VALID);
if (status != UPPL_RC_SUCCESS) {
// log error
- pfc_log_error("act_version update operation failed");
+ pfc_log_error("act_version update operation failed for candidate");
}
}
// Read old_oper_status from DB
uint8_t oper_status_db = 0;
- UpplReturnCode read_status = GetOperStatus(data_type,
+ UpplReturnCode read_status = GetOperStatus(db_conn, data_type,
key_struct,
oper_status_db);
- if (read_status == UPPL_RC_SUCCESS) {
- uint8_t new_oper_status = UPPL_CONTROLLER_OPER_DOWN;
- // CONTROLLER_OPER_UP from driver
- // Its same as enum UPPL_CONTROLLER_OPER_UP
- if (obj_new_val_ctr->oper_status == UPPL_CONTROLLER_OPER_UP) {
- if (is_events_done == false) {
- new_oper_status = UPPL_CONTROLLER_OPER_WAITING_AUDIT;
- } else {
- new_oper_status = UPPL_CONTROLLER_OPER_UP;
+ if (read_status != UPPL_RC_SUCCESS) {
+ return read_status;
+ }
+ uint8_t new_oper_status = UPPL_CONTROLLER_OPER_DOWN;
+ // CONTROLLER_OPER_UP from driver
+ // Its same as enum UPPL_CONTROLLER_OPER_UP
+ if (obj_new_val_ctr->oper_status == UPPL_CONTROLLER_OPER_UP) {
+ if (is_events_done == false) {
+ new_oper_status = UPPL_CONTROLLER_OPER_WAITING_AUDIT;
+ } else {
+ new_oper_status = UPPL_CONTROLLER_OPER_UP;
+ }
+ }
+ if (obj_new_val_ctr->oper_status == UPPL_CONTROLLER_OPER_DOWN) {
+ // If controller is in audit list perform required action
+ IPCConnectionManager *ipc_mgr = PhysicalLayer::get_instance()->
+ get_ipc_connection_manager();
+ pfc_bool_t is_controller_in_audit = ipc_mgr->
+ IsControllerInAudit(controller_name);
+ if (is_controller_in_audit == PFC_TRUE) {
+ pfc_log_debug("Calling MergeAuditDbToRunning");
+ // To cancel the already running timer in Audit
+ UpplReturnCode cancel_ret = ipc_mgr->CancelTimer(controller_name);
+ if (cancel_ret != UPPL_RC_SUCCESS) {
+ pfc_log_info("Failure in cancelling timer for controller %s",
+ controller_name.c_str());
}
- }
- if (obj_new_val_ctr->oper_status == UPPL_CONTROLLER_OPER_DOWN) {
- // If controller is in audit list perform required action
- IPCConnectionManager *ipc_mgr = PhysicalLayer::get_instance()->
- get_ipc_connection_manager();
- pfc_bool_t is_controller_in_audit = ipc_mgr->
- IsControllerInAudit(controller_name);
- if (is_controller_in_audit == PFC_TRUE) {
- pfc_log_debug("Calling MergeAuditDbToRunning");
- // To cancel the already running timer in Audit
- uint32_t time_out_id = ipc_mgr->getTimeOutId(controller_name);
- ipc_mgr->notfn_timer_->cancel(time_out_id);
- AuditRequest audit_req;
- UpplReturnCode merge_auditdb =
- audit_req.MergeAuditDbToRunning(controller_name);
- if (merge_auditdb != UPPL_RC_SUCCESS) {
- pfc_log_info("Merge of audit and running db failed");
- }
+ AuditRequest audit_req;
+ UpplReturnCode merge_auditdb =
+ audit_req.MergeAuditDbToRunning(db_conn, controller_name);
+ if (merge_auditdb != UPPL_RC_SUCCESS) {
+ pfc_log_info("Merge of audit and running db failed");
}
}
- pfc_log_info("New Oper_status to be set is: %d", new_oper_status);
- if (new_oper_status != oper_status_db) {
- status = HandleOperStatus(data_type, key_struct, obj_new_val_ctr);
- pfc_log_debug("HandleOperStatus return %d", status);
- // Send notification to Northbound
- if (new_oper_status == UPPL_CONTROLLER_OPER_UP ||
- new_oper_status == UPPL_CONTROLLER_OPER_DOWN) {
- status = SendOperStatusNotification(*obj_key_ctr,
- oper_status_db,
- new_oper_status);
- }
+ // Check for Ip Address and remove state db if no ip address is found
+ UpplReturnCode state_status = CheckIpAndClearStateDB(db_conn, key_struct);
+ pfc_log_debug("Ip and state db processing status : %d", state_status);
+ }
+ pfc_log_info("New Oper_status to be set is: %d", new_oper_status);
+ if (new_oper_status != oper_status_db) {
+ if (is_events_done == true) {
+ // To avoid changing back to audit_waiting
+ status = HandleOperStatus(db_conn, data_type,
+ key_struct, obj_new_val_ctr, true);
+ } else {
+ status = HandleOperStatus(db_conn, data_type,
+ key_struct, obj_new_val_ctr);
+ }
+ pfc_log_debug("HandleOperStatus return %d", status);
+ // Send notification to Northbound
+ if (new_oper_status == UPPL_CONTROLLER_OPER_UP ||
+ new_oper_status == UPPL_CONTROLLER_OPER_DOWN) {
+ status = SendOperStatusNotification(*obj_key_ctr,
+ oper_status_db,
+ new_oper_status);
}
}
return status;
}
/** HandleDriverAlarms
- * * @Description : This function processes the alarm notification
+ * @Description : This function processes the alarm notification
* received from driver
- * * * @param[in] : alarm type - contains type to indicate PATH_FAULT alarm
+ * @param[in] : alarm type - contains type to indicate PATH_FAULT alarm
* operation - contains UNC_OP_CREATE or UNC_OP_DELETE\
* key_struct - indicates the key instance of KT_CONTROLLER
* value_struct - indicates the alarm values structure
- * * * @return : UPPL_RC_SUCCESS if alarm is handled successfully or
+ * data_type-UNC_DT_*,type of database
+ * alarm_type-type of alarm raised
+ * oper_type-UNC_OP_*,type of operation
+ * @return : UPPL_RC_SUCCESS if alarm is handled successfully or
* UPPL_RC_ERR*
* */
-UpplReturnCode Kt_Controller::HandleDriverAlarms(uint32_t data_type,
- uint32_t alarm_type,
- uint32_t oper_type,
- void* key_struct,
- void* val_struct) {
+UpplReturnCode Kt_Controller::HandleDriverAlarms(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ uint32_t alarm_type,
+ uint32_t oper_type,
+ void* key_struct,
+ void* val_struct) {
UpplReturnCode status = UPPL_RC_SUCCESS;
// Following alarms are sent for kt_controller
if (alarm_type == UNC_PHYS_PATH_FAULT) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
key_ctr_t *obj_key_ctr= reinterpret_cast<key_ctr_t*>(key_struct);
string controller_name = (const char*)obj_key_ctr->controller_name;
+ string temp_domain_name = "";
+ string domain_name = "";
int err = 0;
Kt_LogicalPort logical_port_class;
Kt_Port port_class;
(obj_val.ingress_ofs_dpid);
string egress_switch_id = reinterpret_cast<char *>
(obj_val.egress_ofs_dpid);
- string phy_port_id;
+ string phy_port_id = "";
vector<string> ingress_logical_port_id, egress_logical_port_id;
// Get the associated logical_port_id for ingress switch
- logical_port_class.GetAllPortId(data_type,
+ logical_port_class.GetAllPortId(db_conn, data_type,
controller_name,
ingress_switch_id,
+ temp_domain_name,
ingress_logical_port_id,
true);
- memset(obj_path_fault_alarm.ingress_logical_port, 0, 320);
+ memset(&obj_path_fault_alarm, 0, sizeof(obj_path_fault_alarm));
if (!ingress_logical_port_id.empty()) {
memcpy(obj_path_fault_alarm.ingress_logical_port,
ingress_logical_port_id[0].c_str(),
(ingress_logical_port_id[0].length())+1);
pfc_log_debug("Ingress Logical Port: %s",
obj_path_fault_alarm.ingress_logical_port);
+ domain_name = temp_domain_name;
} else {
pfc_log_info("No logical port associated with ingress switch id");
}
// Get the associated logical_port_id for egress switch
- logical_port_class.GetAllPortId(data_type,
+ logical_port_class.GetAllPortId(db_conn, data_type,
controller_name,
egress_switch_id,
+ temp_domain_name,
egress_logical_port_id,
true);
- memset(obj_path_fault_alarm.egress_logical_port, 0, 320);
if (!egress_logical_port_id.empty()) {
memcpy(obj_path_fault_alarm.egress_logical_port,
egress_logical_port_id[0].c_str(),
egress_logical_port_id[0].length()+1);
pfc_log_debug("Egress Logical Port: %s",
obj_path_fault_alarm.egress_logical_port);
+ domain_name = temp_domain_name;
} else {
pfc_log_info("No logical port associated with egress switch id");
}
egress_logical_port_id.clear();
pfc_log_debug("Get LogPortIds for corresponding ingress switch PhyPorts");
// Get all logical ports associated with ingress switch
- logical_port_class.GetAllPortId(data_type,
+ logical_port_class.GetAllPortId(db_conn, data_type,
controller_name,
ingress_switch_id,
+ temp_domain_name,
ingress_logical_port_id,
false);
pfc_log_debug("Get LogPortIds for corresponding egress switch PhyPorts");
// Get all logical ports associated with egress switch
- logical_port_class.GetAllPortId(data_type,
+ logical_port_class.GetAllPortId(db_conn, data_type,
controller_name,
egress_switch_id,
+ temp_domain_name,
egress_logical_port_id,
false);
obj_path_fault_alarm.ingress_num_of_ports = static_cast<uint16_t>
ServerEvent ser_evt((pfc_ipcevtype_t)UPPL_ALARMS_PHYS_PATH_FAULT, err);
northbound_alarm_header rsh = { oper_type,
data_type,
- UNC_KT_CONTROLLER,
+ UNC_KT_CTR_DOMAIN,
UPPL_ALARMS_PHYS_PATH_FAULT};
err = PhyUtil::sessOutNBAlarmHeader(ser_evt, rsh);
- err |= ser_evt.addOutput(*obj_key_ctr);
+ key_ctr_domain_t ctr_dmn_key;
+ memset(&ctr_dmn_key, '\0', sizeof(ctr_dmn_key));
+ memcpy(ctr_dmn_key.ctr_key.controller_name,
+ (const char *)controller_name.c_str(), controller_name.length()+1);
+ if (!domain_name.empty()) {
+ memcpy(ctr_dmn_key.domain_name,
+ (const char *)domain_name.c_str(), domain_name.length()+1);
+ }
+ err |= ser_evt.addOutput(ctr_dmn_key);
+ pfc_log_info("%s", (IpctUtil::get_string(ctr_dmn_key)).c_str());
err |= ser_evt.addOutput(obj_path_fault_alarm);
// N number of UINT8 logical_port[320] has to be added
// Get all logical_port_ids associated with switch and physical port
}
/** IsKeyExists
- * * @Description : This function checks whether the controller_id exists in DB
- * * * @param[in] : data type - UNC_DT_*
+ * @Description : This function checks whether the controller_id exists in DB
+ * @param[in] : data type - UNC_DT_*,type of database
* key value - Contains controller_id
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR* based on operation type
+ * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR* based on operation type
* */
-UpplReturnCode Kt_Controller::IsKeyExists(unc_keytype_datatype_t data_type,
- vector<string> key_values) {
+UpplReturnCode Kt_Controller::IsKeyExists(
+ OdbcmConnectionHandler *db_conn,
+ unc_keytype_datatype_t data_type,
+ const vector<string> &key_values) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode check_status = UPPL_RC_SUCCESS;
if (key_values.empty()) {
// Construct Primary key list
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
// Construct TableAttrSchema structure
// TableAttrSchema holds table_name, primary key, attr_name
list< vector<TableAttrSchema> > row_list;
// Controller_name
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- kt_controller_dbtableschema.set_table_name(UPPL_CTR_TABLE);
+ kt_controller_dbtableschema.set_table_name(unc::uppl::CTR_TABLE);
kt_controller_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_controller_dbtableschema.set_row_list(row_list);
// Send request to ODBC for controlle_common_table
ODBCM_RC_STATUS check_db_status = physical_layer->get_odbc_manager()->\
- IsRowExists(data_type, kt_controller_dbtableschema);
+ IsRowExists(data_type, kt_controller_dbtableschema, db_conn);
if (check_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log error to log daemon
pfc_log_error("DB connection not available or cannot access DB");
}
/** HandleOperStatus
- * * @Description : This function performs the required actions when oper status
+ * @Description : This function performs the required actions when oper status
* changes
- * * * @param[in] : Key and value struct
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
+ * @param[in] : key_struct-void* to CTR key structure
+ * value_struct-void* to CTR val structure
+ * data_type-UNC_DT_*,type of database
+ * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
* */
-UpplReturnCode Kt_Controller::HandleOperStatus(uint32_t data_type,
- void *key_struct,
- void *value_struct) {
+UpplReturnCode Kt_Controller::HandleOperStatus(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ void *key_struct,
+ void *value_struct) {
UpplReturnCode return_code = UPPL_RC_SUCCESS;
- return_code = HandleOperStatus(data_type,
+ return_code = HandleOperStatus(db_conn, data_type,
key_struct,
value_struct,
false);
}
/** HandleOperStatus
- * * @Description : This function performs the required actions when oper status
+ * @Description : This function performs the required actions when oper status
* changes
- * * * @param[in] : Key struct - identifies the controller key instance
- * value struct - identifies the controller value structure
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
+ * @param[in] : key_struct - identifies the controller key instance
+ * value_struct - identifies the controller value structure
+ * data_type-UNC_DT_*,type of database
+ * bIsInternal-based on this flag,oper status is updated
+ * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
* */
-UpplReturnCode Kt_Controller::HandleOperStatus(uint32_t data_type,
- void *key_struct,
- void *value_struct,
- bool bIsInternal) {
+UpplReturnCode Kt_Controller::HandleOperStatus(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ void *key_struct,
+ void *value_struct,
+ bool bIsInternal) {
FN_START_TIME("HandleOperStatus", "Controller");
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode return_code = UPPL_RC_SUCCESS;
oper_value = UPPL_CONTROLLER_OPER_WAITING_AUDIT;
}
}
- UpplReturnCode read_status = GetOperStatus(data_type,
+ UpplReturnCode read_status = GetOperStatus(db_conn, data_type,
key_struct,
oper_status_db);
pfc_log_debug("Get OperStatus return: %d", read_status);
// Update oper_status in controller_table
- return_code = SetOperStatus(data_type, key_struct, oper_value);
+ return_code = SetOperStatus(db_conn, data_type, key_struct, oper_value);
if (return_code != UPPL_RC_SUCCESS) {
- // log error
- pfc_log_error("oper_status update operation failed");
+ pfc_log_info("oper_status update operation failed %d", return_code);
return return_code;
}
physical_layer->get_physical_core()->
SendControllerDisconnectAlarm(controller_name);
pfc_log_info("Alarm status: %d", alarms_status);
- return_code = NotifyOperStatus(UNC_DT_RUNNING,
+ vector<OperStatusHolder> ref_oper_status;
+ ADD_CTRL_OPER_STATUS(controller_name, obj_val_ctr->oper_status);
+ return_code = NotifyOperStatus(db_conn, UNC_DT_RUNNING,
key_struct,
- value_struct);
+ value_struct,
+ ref_oper_status);
+ ClearOperStatusHolder(ref_oper_status);
} else if (obj_val_ctr->oper_status == UPPL_CONTROLLER_OPER_UP) {
// Send clearance for CONTROLLER_DISCONNECT alarm
// Send CONTROLLER_CONNECT alarm
}
/** NotifyOperStatus
- * * @Description : This function performs the notifies other associated
+ * @Description : This function performs the notifies other associated
* key types when oper status changes
- * * * @param[in] : Key and value struct
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
+ * @param[in] : data_type-UNC_DT_*,type of database
+ * key_struct-void* to CTR key structure
+ * value_struct-void* to CTR val structure
+ * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
* */
-UpplReturnCode Kt_Controller::NotifyOperStatus(uint32_t data_type,
- void *key_struct,
- void *value_struct) {
+UpplReturnCode Kt_Controller::NotifyOperStatus(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ void *key_struct,
+ void *value_struct,
+ vector<OperStatusHolder> &ref_oper_status) {
UpplReturnCode return_code = UPPL_RC_SUCCESS;
key_ctr *key = reinterpret_cast<key_ctr_t*>(key_struct);
string controller_name = reinterpret_cast<char*>(key->controller_name);
void *ref_key_struct = NULL;
Kt_Base *class_pointer = GetClassPointerAndKey(
(KtControllerOperStatusRef)index, controller_name, ref_key_struct);
- return_code = class_pointer->HandleOperStatus(data_type, ref_key_struct,
+ return_code = class_pointer->HandleOperStatus(db_conn, data_type,
+ ref_key_struct,
NULL);
pfc_log_info("HandleOperStatus for %d child class %d",
index, return_code);
delete class_pointer;
FreeKeyStruct(ref_key_struct, index);
}
- /* Construct UNC_KT_BOUNDARY value struct
+ // Notify Boundary to change oper status
Kt_Boundary boundary;
val_boundary_t obj_val_boundary1;
+ memset(&obj_val_boundary1, 0, sizeof(obj_val_boundary1));
memcpy(obj_val_boundary1.controller_name1,
controller_name.c_str(), controller_name.length()+1);
- memset(obj_val_boundary1.domain_name1, 0, 32);
- memset(obj_val_boundary1.logical_port_id1, 0, 320);
- memset(obj_val_boundary1.valid, 0, 7);
obj_val_boundary1.valid[kIdxBoundaryControllerName1] = UNC_VF_VALID;
return_code = boundary.HandleOperStatus(
- NULL, reinterpret_cast<void *> (&obj_val_boundary1));
- pfc_log_info("HandleOperStatus for boundary class %d", return_code);
+ db_conn,
+ UNC_DT_RUNNING, NULL,
+ reinterpret_cast<void *> (&obj_val_boundary1),
+ ref_oper_status);
+ pfc_log_info("HandleOperStatus for boundary C1 class %d", return_code);
val_boundary_t obj_val_boundary2;
+ memset(&obj_val_boundary2, 0, sizeof(obj_val_boundary2));
memcpy(obj_val_boundary2.controller_name2,
controller_name.c_str(), controller_name.length()+1);
- memset(obj_val_boundary2.domain_name2, 0, 32);
- memset(obj_val_boundary2.logical_port_id2, 0, 320);
- memset(obj_val_boundary2.valid, 0, 7);
obj_val_boundary2.valid[kIdxBoundaryControllerName2] = UNC_VF_VALID;
- return_code = boundary.HandleOperStatus(data_type,
- NULL, reinterpret_cast<void *> (&obj_val_boundary2));
- pfc_log_info("HandleOperStatus for boundary class %d", return_code);*/
+ return_code = boundary.HandleOperStatus(
+ db_conn,
+ UNC_DT_RUNNING, NULL,
+ reinterpret_cast<void *> (&obj_val_boundary2),
+ ref_oper_status);
+ pfc_log_info("HandleOperStatus for boundary C2 class %d", return_code);
+
return return_code;
}
/** PopulateDBSchemaForKtTable
- * * @Description : This function populates the DBAttrSchema to be used to send
+ * @Description : This function populates the DBAttrSchema to be used to send
* request to ODBC
- * * * @param[in] : DBTableSchema, key_struct, val_struct, operation_type
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
+ * @param[in] : kt_controller_dbtableschema-DBTableSchema instance associated
+ * with Controller
+ * key_struct-void* to CTR key structure
+ * val_struct-void* to CTR value structure
+ * operation_type-UNC_OP_*,type of operation
+ * option1,option2-UNC_OPT1/OPT2_*,additional info for read operations
+ * vect_key_operations-instance of vector<ODBCMOperator>
+ * old_value_struct-void* to old value strcuture of CTR
+ * row_status-CsRowStatus value
+ * is_filtering-flag to indicate whether filter option is enabled or not
+ * is_state-flag to indicate whether data type is DT_STATE
+ * @return : void
* */
void Kt_Controller::PopulateDBSchemaForKtTable(
+ OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_controller_dbtableschema,
void* key_struct,
void* val_struct,
uint8_t operation_type,
+ uint32_t data_type,
uint32_t option1,
uint32_t option2,
vector<ODBCMOperator> &vect_key_operations,
key_ctr_t *obj_key_ctr = reinterpret_cast<key_ctr_t*>(key_struct);
val_ctr_t *obj_val_ctr = reinterpret_cast<val_ctr_t*>(val_struct);
- vect_prim_keys.push_back(CTR_NAME);
+
stringstream valid;
pfc_log_info("operation: %d", operation_type);
// Controller_name
controller_name = "";
}
pfc_log_info("controller name: %s", controller_name.c_str());
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
if (operation_type == UNC_OP_UPDATE) {
// get valid array for update req
pfc_log_debug("Get Valid value from DB");
- GetCtrValidFlag(key_struct, val_ctr_valid_st);
+ GetCtrValidFlag(db_conn, key_struct, val_ctr_valid_st, data_type);
}
uint16_t valid_val = 0, prev_db_val = 0;
- string value;
+ string value = "";
unc_keytype_ctrtype_t ctr_type = UNC_CT_UNKNOWN;
// Type
if (obj_val_ctr != NULL) {
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(CTR_TYPE, value,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_TYPE, CTR_TYPE_STR, value,
value.length(), DATATYPE_UINT16,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(CTR_VERSION, value,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_VERSION, CTR_VERSION_STR, value,
value.length(), DATATYPE_UINT8_ARRAY_32,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(CTR_DESCRIPTION, value,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_DESCRIPTION, CTR_DESCRIPTION_STR, value,
value.length(), DATATYPE_UINT8_ARRAY_128,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
// Ip_address
char *ip_value = new char[16];
+ memset(ip_value, '\0', 16);
if (obj_val_ctr != NULL) {
valid_val = PhyUtil::uint8touint(obj_val_ctr->valid[kIdxIpAddress]);
inet_ntop(AF_INET, &obj_val_ctr->ip_address, ip_value, INET_ADDRSTRLEN);
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(CTR_IP_ADDRESS, ip_value,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_IP_ADDRESS, CTR_IP_ADDRESS_STR, ip_value,
strlen(ip_value), DATATYPE_IPV4,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(CTR_USER_NAME, value,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_USER_NAME, CTR_USER_NAME_STR, value,
value.length(), DATATYPE_UINT8_ARRAY_32,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(CTR_PASSWORD, value,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_PASSWORD, CTR_PASSWORD_STR, value,
value.length(), DATATYPE_UINT8_ARRAY_257,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
value.clear();
// enable_audit
if (obj_val_ctr != NULL) {
- valid_val = PhyUtil::uint8touint(obj_val_ctr->valid[kIdxEnableAudit]);
+ if (operation_type == UNC_OP_CREATE) {
+ valid_val = UNC_VF_VALID;
+ } else {
+ valid_val = PhyUtil::uint8touint(obj_val_ctr->valid[kIdxEnableAudit]);
+ }
value = PhyUtil::uint8tostr(obj_val_ctr->enable_audit);
prev_db_val =
PhyUtil::uint8touint(
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(CTR_ENABLE_AUDIT, value,
- value.length(), DATATYPE_UINT16,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_ENABLE_AUDIT, CTR_ENABLE_AUDIT_STR,
+ value, value.length(), DATATYPE_UINT16,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
value.clear();
// actual_version
valid_val = UNC_VF_INVALID;
- prev_db_val = 0;
+ if (operation_type == UNC_OP_UPDATE) {
+ prev_db_val =
+ PhyUtil::uint8touint(
+ val_ctr_valid_st.valid[kIdxActualVersion]);
+ } else {
+ prev_db_val = 0;
+ }
value.clear();
- PhyUtil::FillDbSchema(CTR_ACTUAL_VERSION, value,
- value.length(), DATATYPE_UINT8_ARRAY_32,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_ACTUAL_VERSION, CTR_ACTUAL_VERSION_STR,
+ value, value.length(), DATATYPE_UINT8_ARRAY_32,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
- valid_val = UPPL_NO_VAL_STRUCT;
// oper_status
+ if (operation_type == UNC_OP_UPDATE) {
+ valid_val = UNC_VF_INVALID;
+ prev_db_val =
+ PhyUtil::uint8touint(
+ val_ctr_valid_st.valid[kIdxOperStatus]);
+ } else {
+ valid_val = UPPL_NO_VAL_STRUCT;
+ prev_db_val = 0;
+ }
if (operation_type == UNC_OP_CREATE &&
(ctr_type == UNC_CT_UNKNOWN)) {
// Oper_status for Unknown will be always up
value = oper_value.str();
valid_val = UNC_VF_VALID;
}
- PhyUtil::FillDbSchema(CTR_OPER_STATUS, value,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_OPER_STATUS, CTR_OPER_STATUS_STR, value,
value.length(), DATATYPE_UINT16,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
// valid
+ valid_val = UPPL_NO_VAL_STRUCT;
stringstream dummy_valid;
- PhyUtil::FillDbSchema(CTR_VALID, valid.str(),
+ PhyUtil::FillDbSchema(unc::uppl::CTR_VALID, CTR_VALID_STR, valid.str(),
valid.str().length(), DATATYPE_UINT8_ARRAY_9,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, dummy_valid);
// cs_attr_status
+ if (operation_type == UNC_OP_UPDATE) {
+ valid_val = UNC_VF_INVALID;
+ }
stringstream attr_status;
for (unsigned int index = 0; index < ODBCM_SIZE_9; ++index) {
attr_status << CREATED;
}
- PhyUtil::FillDbSchema(CTR_CS_ATTR, attr_status.str(),
+ PhyUtil::FillDbSchema(unc::uppl::CTR_CS_ATTR, CTR_CS_ATTR_STR,
+ attr_status.str(),
attr_status.str().length(), DATATYPE_UINT8_ARRAY_9,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, dummy_valid);
// cs_row status
if (is_filtering == true) {
- vect_prim_keys.push_back(CTR_CS_ROW_STATUS);
+ vect_prim_keys.push_back(CTR_CS_ROW_STATUS_STR);
}
value = PhyUtil::uint8tostr(row_status);
if (operation_type >= UNC_OP_READ) {
- PhyUtil::FillDbSchema(CTR_CS_ROW_STATUS, value,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_CS_ROW_STATUS, value,
value.length(), DATATYPE_UINT16,
vect_table_attr_schema);
}
+ vect_prim_keys.push_back(CTR_NAME_STR);
PhyUtil::reorder_col_attrs(vect_prim_keys, vect_table_attr_schema);
- kt_controller_dbtableschema.set_table_name(UPPL_CTR_TABLE);
+ kt_controller_dbtableschema.set_table_name(unc::uppl::CTR_TABLE);
kt_controller_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_controller_dbtableschema.set_row_list(row_list);
}
/**
- * * @Description : This function populates val_ctr_t by values retrieved
+ * @Description : This function populates val_ctr_t by values retrieved
* from database
- * * * @param[in] : controller common table dbtable schema,
- * value structure and max_rep_ct, operation type
- * * * @return : Filled val_ctr and controller id
+ * @param[in] : kt_controller_dbtableschema-DBTableSchema instance to be filled
+ * vect_obj_val_ctr-vector of CTR value structures
+ * max_rep_ct-max. no. of records to be read
+ * operation_type-type of operation,UNC_OP_*
+ * controller_id-vector of strings containg the controller names
+ * @return : void
* */
void Kt_Controller::FillControllerValueStructure(
+ OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_controller_dbtableschema,
vector<val_ctr_st_t> &vect_obj_val_ctr,
uint32_t &max_rep_ct,
uint32_t operation_type,
vector<string> &controller_id) {
- // populate IPC value structure based on the response recevied from DB
- list < vector<TableAttrSchema> > res_ctr_row_list =
+ // populate IPC value structure based on the response received from DB
+ list < vector<TableAttrSchema> >& res_ctr_row_list =
kt_controller_dbtableschema.get_row_list();
list < vector<TableAttrSchema> > :: iterator res_ctr_iter =
res_ctr_row_list.begin();
max_rep_ct = res_ctr_row_list.size();
pfc_log_debug("res_ctr_row_list.size: %d", max_rep_ct);
- // populate IPC value structure based on the response recevied from DB
+ // populate IPC value structure based on the response received from DB
for (; res_ctr_iter != res_ctr_row_list.end(); ++res_ctr_iter) {
vector<TableAttrSchema> res_ctr_table_attr_schema = (*res_ctr_iter);
vector<TableAttrSchema> :: iterator vect_ctr_iter =
res_ctr_table_attr_schema.begin();
val_ctr_st_t obj_val_ctr_st;
- memset(obj_val_ctr_st.valid, '\0', 3);
+ memset(&obj_val_ctr_st, '\0', sizeof(val_ctr_st_t));
val_ctr_t obj_val_ctr;
memset(&obj_val_ctr, 0, sizeof(val_ctr_t));
- memset(obj_val_ctr.valid, '\0', 7);
- memset(obj_val_ctr.cs_attr, '\0', 7);
// Read all attributes
vector<int> valid_flag, cs_attr;
for (; vect_ctr_iter != res_ctr_table_attr_schema.end();
++vect_ctr_iter) {
// populate values from controller_table
TableAttrSchema tab_schema = (*vect_ctr_iter);
- string attr_name = tab_schema.table_attribute_name;
- string attr_value;
- if (attr_name == CTR_NAME) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- controller_id.push_back(attr_value);
- pfc_log_info("controller_name: %s", attr_value.c_str());
- }
- if (attr_name == CTR_TYPE) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- obj_val_ctr.type = atoi(attr_value.c_str());
- }
- if (attr_name == CTR_DESCRIPTION) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_128);
- memcpy(obj_val_ctr.description,
- attr_value.c_str(),
- attr_value.length()+1);
- }
- if (attr_name == CTR_IP_ADDRESS) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_IPV4);
- inet_pton(AF_INET, (const char *)attr_value.c_str(),
- &obj_val_ctr.ip_address.s_addr);
- }
- if (attr_name == CTR_USER_NAME) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_val_ctr.user,
- attr_value.c_str(),
- attr_value.length()+1);
- }
- if (attr_name == CTR_PASSWORD) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_257);
- memcpy(obj_val_ctr.password,
- attr_value.c_str(),
- attr_value.length()+1);
- }
- if (attr_name == CTR_VALID) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_9);
- memset(obj_val_ctr.valid, '\0', 7);
- FrameValidValue(attr_value, obj_val_ctr_st, obj_val_ctr);
- }
- if (attr_name == CTR_CS_ATTR) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_9);
- memset(obj_val_ctr.cs_attr, '\0', 7);
- FrameCsAttrValue(attr_value, obj_val_ctr);
- }
- if (attr_name == CTR_CS_ROW_STATUS) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- obj_val_ctr.cs_row_status = atoi(attr_value.c_str());
- }
- if (attr_name == CTR_ENABLE_AUDIT) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- obj_val_ctr.enable_audit = atoi(attr_value.c_str());
- }
- if (attr_name == CTR_VERSION) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_val_ctr.version,
- attr_value.c_str(),
- attr_value.length()+1);
- }
- if (attr_name == CTR_OPER_STATUS) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- obj_val_ctr_st.oper_status = atoi(attr_value.c_str());
- }
- if (attr_name == CTR_ACTUAL_VERSION) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_val_ctr_st.actual_version,
- attr_value.c_str(),
- attr_value.length()+1);
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
+ string attr_value = "";
+ switch (attr_name) {
+ case unc::uppl::CTR_NAME :
+ uint8_t ctr_name[ODBCM_SIZE_32];
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema, ctr_name,
+ DATATYPE_UINT8_ARRAY_32);
+ controller_id.push_back(reinterpret_cast<const char*>(ctr_name));
+ pfc_log_debug("controller_name: %s", ctr_name);
+ break;
+
+ case unc::uppl::CTR_TYPE :
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT16);
+ obj_val_ctr.type = atoi(attr_value.c_str());
+ break;
+
+ case unc::uppl::CTR_DESCRIPTION :
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema, obj_val_ctr.description,
+ DATATYPE_UINT8_ARRAY_128);
+ break;
+
+ case unc::uppl::CTR_IP_ADDRESS:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_IPV4);
+ inet_pton(AF_INET, (const char *)attr_value.c_str(),
+ &obj_val_ctr.ip_address.s_addr);
+ break;
+
+ case unc::uppl::CTR_USER_NAME:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema, obj_val_ctr.user,
+ DATATYPE_UINT8_ARRAY_32);
+ break;
+
+ case unc::uppl::CTR_PASSWORD:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema, obj_val_ctr.password,
+ DATATYPE_UINT8_ARRAY_257);
+ break;
+
+ case unc::uppl::CTR_VALID:
+ uint8_t ctr_valid[ODBCM_SIZE_9];
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema, ctr_valid,
+ DATATYPE_UINT8_ARRAY_9);
+ memset(obj_val_ctr.valid, '\0', 7);
+ FrameValidValue(reinterpret_cast<const char*>(ctr_valid),
+ obj_val_ctr_st, obj_val_ctr);
+ break;
+
+ case unc::uppl::CTR_CS_ATTR:
+ uint8_t ctr_cs_attr[ODBCM_SIZE_9];
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema, ctr_cs_attr,
+ DATATYPE_UINT8_ARRAY_9);
+ memset(obj_val_ctr.cs_attr, '\0', 7);
+ FrameCsAttrValue(reinterpret_cast<const char*>(ctr_cs_attr),
+ obj_val_ctr);
+ break;
+
+ case unc::uppl::CTR_CS_ROW_STATUS:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT16);
+ obj_val_ctr.cs_row_status = atoi(attr_value.c_str());
+ break;
+
+ case unc::uppl::CTR_ENABLE_AUDIT:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT16);
+ obj_val_ctr.enable_audit = atoi(attr_value.c_str());
+ break;
+
+ case unc::uppl::CTR_VERSION:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema, obj_val_ctr.version,
+ DATATYPE_UINT8_ARRAY_32);
+ break;
+
+ case unc::uppl::CTR_OPER_STATUS:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT16);
+ obj_val_ctr_st.oper_status = atoi(attr_value.c_str());
+ break;
+
+ case unc::uppl::CTR_ACTUAL_VERSION:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_val_ctr_st.actual_version,
+ DATATYPE_UINT8_ARRAY_32);
+ break;
+
+ default:
+ pfc_log_info("Ignoring Controller attribute %d", attr_name);
+ break;
}
}
memcpy(&obj_val_ctr_st.controller, &obj_val_ctr, sizeof(val_ctr_t));
}
/** PerformRead
- * * @Description : This function reads the instance of KT_Controller based on
+ * @Description : This function reads the instance of KT_Controller based on
* operation type - READ, READ_SIBLING_BEGIN, READ_SIBLING
- * * * @param[in] : ipc session id, configuration id, key_struct, value_struct,
- * data_type, operation type, ServerSession, option1, option2,
- * max_rep_ct
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
+ * @param[in] : session_id-ipc session id used for TC validation
+ * configuration_id-ipc configuration id used for TC validation
+ * key_struct-void* to ctr key structure
+ * value_struct-void* to ctr value structure
+ * data_type-UNC_DT_*,type of database
+ * operation _type-UNC_OP_*,type of database
+ * sess- object of ServerSession
+ * option1,option2-UNC_OPT1/OPT2_*,additional infor read operations
+ * max_rep_ct-max. no of records to be read
+ * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*,
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_Controller::PerformRead(uint32_t session_id,
+UpplReturnCode Kt_Controller::PerformRead(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t option1,
uint32_t option2,
uint32_t max_rep_ct) {
- pfc_log_info("Inside PerformRead option1=%d option2=%d max_rep_ct=%d",
- option1, option2, max_rep_ct);
pfc_log_info("Inside PerformRead operation_type=%d data_type=%d",
operation_type, data_type);
key_ctr_t *obj_key_ctr= reinterpret_cast<key_ctr_t*>(key_struct);
// Read from DB directly for all data types
vector<string> vect_controller_id;
vector<val_ctr_st_t> vect_val_ctr_st;
- read_status = ReadCtrValFromDB(key_struct,
+ read_status = ReadCtrValFromDB(db_conn, key_struct,
val_struct,
data_type,
operation_type,
}
for (unsigned int index = 0; index < vect_val_ctr_st.size(); ++index) {
key_ctr_t obj_ctr;
+ memset(&obj_ctr, '\0', sizeof(key_ctr_t));
string controller_name = vect_controller_id[index];
if (data_type == UNC_DT_CANDIDATE &&
vect_val_ctr_st[index].controller.cs_row_status == DELETED) {
return UPPL_RC_ERR_IPC_WRITE_ERROR;
}
}
- pfc_log_info("Return value for read operation %d", read_status);
+ pfc_log_debug("Return value for read operation %d", read_status);
return read_status;
}
/** ReadCtrValFromDB
- * * @Description : This function reads the instance of KT_Controller based on
+ * @Description : This function reads the instance of KT_Controller based on
* operation type - READ, READ_SIBLING_BEGIN, READ_SIBLING
* from data base
- * * * @param[in] : key_struct, value_struct, ipc session id, configuration id,
- * data_type, operation type, max_rep_ct
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
+ * @param[in] : key_struct-void* to CTR key structure
+ * value_struct-void* to CTR val structure
+ * data_type-UNC_DT_*,type of database
+ * operation type-UNC_OP_*,type of operation
+ * max_rep_ct-max no of records to be read
+ * vect_val_ctr_st-instance of vector<val_ctr_st_t>
+ * controller_id-instance of vector<string> containing ctr keys
+ * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
UpplReturnCode Kt_Controller::ReadCtrValFromDB(
+ OdbcmConnectionHandler *db_conn,
void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t &max_rep_ct,
vector<val_ctr_st_t> &vect_val_ctr_st,
vector<string> &controller_id) {
+ if (operation_type < UNC_OP_READ) {
+ // Unsupported operation type for this function
+ return UPPL_RC_SUCCESS;
+ }
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode read_status = UPPL_RC_SUCCESS;
ODBCM_RC_STATUS read_db_status = ODBCM_RC_SUCCESS;
// Common structures that will be used to send query to ODBC
// Structure used to send request to ODBC
DBTableSchema kt_controller_dbtableschema;
- void *old_val_struct;
+ void *old_val_struct = NULL;
vector<ODBCMOperator> vect_key_operations;
- PopulateDBSchemaForKtTable(kt_controller_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_controller_dbtableschema,
key_struct,
val_struct,
- operation_type, 0, 0,
+ operation_type, data_type, 0, 0,
vect_key_operations, old_val_struct);
if (operation_type == UNC_OP_READ) {
read_db_status = physical_layer->get_odbc_manager()->
GetOneRow((unc_keytype_datatype_t)data_type,
- kt_controller_dbtableschema);
+ kt_controller_dbtableschema, db_conn);
} else {
read_db_status = physical_layer->get_odbc_manager()->
GetBulkRows((unc_keytype_datatype_t)data_type, max_rep_ct,
kt_controller_dbtableschema,
- (unc_keytype_operation_t)operation_type);
+ (unc_keytype_operation_t)operation_type, db_conn);
}
if (read_db_status == ODBCM_RC_RECORD_NOT_FOUND) {
pfc_log_debug("No record found");
read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
return read_status;
+ } else if (read_db_status == ODBCM_RC_CONNECTION_ERROR) {
+ read_status = UPPL_RC_ERR_DB_ACCESS;
+ pfc_log_error("Read operation has failed with error %d", read_db_status);
+ return read_status;
} else if (read_db_status != ODBCM_RC_SUCCESS) {
read_status = UPPL_RC_ERR_DB_GET;
// log error to log daemon
pfc_log_error("Read operation has failed with error %d", read_db_status);
return read_status;
}
- FillControllerValueStructure(kt_controller_dbtableschema,
+ FillControllerValueStructure(db_conn, kt_controller_dbtableschema,
vect_val_ctr_st,
max_rep_ct,
operation_type,
}
/** getChildKeyStruct
- * * @Description : This function returns the void * of child key structures
- * * * @param[in] : child class index and controller name
- * * * @return : void * key structure
+ * @Description : This function returns the void * of child key structures
+ * @param[in] : child_class-child class index indicating children of Controller
+ * controller_name-controller id
+ * @return : void * key structure
* */
void* Kt_Controller::getChildKeyStruct(unsigned int child_class,
string controller_name) {
}
/** FreeChildKeyStruct
- * * @Description : This function clearsthe void * of child key structures
- * * * @param[in] : child class index and key_struct
- * * * @return : None
+ * @Description : This function clearsthe void * of child key structures
+ * @param[in] : child_class-child class index indicating children of Controller
+ * key_struct-void* to ctr key structure
+ * @return : void
* */
void Kt_Controller::FreeChildKeyStruct(void* key_struct,
unsigned int child_class) {
}
/** GetModifiedRows
- * * @Description : This function reads all KT_Controller with given row_status
- * * * @param[in] : key_struct, value_struct, row_status
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
+ * @Description : This function reads all KT_Controller with given row_status
+ * @param[in] : obj_key_struct-vector of void* to ctr key structure
+ * row_status-CsRowStatus value
+ * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_Controller::GetModifiedRows(vector<void *> &obj_key_struct,
+UpplReturnCode Kt_Controller::GetModifiedRows(OdbcmConnectionHandler *db_conn,
+ vector<void *> &obj_key_struct,
CsRowStatus row_status) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
uint32_t max_rep_ct = 0;
DBTableSchema kt_controller_dbtableschema;
void *old_val_struct;
vector<ODBCMOperator> vect_key_operations;
- PopulateDBSchemaForKtTable(kt_controller_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_controller_dbtableschema,
ctr_key, ctr_val,
- UNC_OP_READ, 0, 0,
+ UNC_OP_READ, UNC_DT_CANDIDATE, 0, 0,
vect_key_operations, old_val_struct,
row_status,
true);
read_db_status = physical_layer->get_odbc_manager()->
- GetModifiedRows(UNC_DT_CANDIDATE, kt_controller_dbtableschema);
+ GetModifiedRows(UNC_DT_CANDIDATE, kt_controller_dbtableschema, db_conn);
if (read_db_status == ODBCM_RC_RECORD_NOT_FOUND) {
pfc_log_debug("No record to read");
read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
}
vector<string> controller_id;
- FillControllerValueStructure(kt_controller_dbtableschema,
+ FillControllerValueStructure(db_conn, kt_controller_dbtableschema,
obj_value_struct,
max_rep_ct,
UNC_OP_READ,
}
/** Fill_Attr_Syntax_Map
- * * @Description : This function populates the values to be used for attribute
+ * @Description : This function populates the values to be used for attribute
* validation
- * * * @param[in] : None
- * * * @return : None
+ * @param[in] : None
+ * @return : void
* */
void Kt_Controller::Fill_Attr_Syntax_Map() {
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map;
Kt_Class_Attr_Syntax objKeyAttrSyntax =
{ PFC_IPCTYPE_UINT8, 0, 0, 1, 32, true, "" };
- attr_syntax_map[CTR_NAME] = objKeyAttrSyntax;
+ attr_syntax_map[CTR_NAME_STR] = objKeyAttrSyntax;
Kt_Class_Attr_Syntax objAttrTypeSyntax =
- { PFC_IPCTYPE_UINT8, 0, 3, 0, 0, true, "" };
- attr_syntax_map[CTR_TYPE] = objAttrTypeSyntax;
+ { PFC_IPCTYPE_UINT8, 0, 2, 0, 0, true, "" };
+ attr_syntax_map[CTR_TYPE_STR] = objAttrTypeSyntax;
Kt_Class_Attr_Syntax objAttrVersionSyntax =
{ PFC_IPCTYPE_STRING, 0, 0, 1, 32, true, "" };
- attr_syntax_map[CTR_VERSION] = objAttrVersionSyntax;
+ attr_syntax_map[CTR_VERSION_STR] = objAttrVersionSyntax;
Kt_Class_Attr_Syntax objAttrDescSyntax =
- { PFC_IPCTYPE_STRING, 0, 0, 0, 128, false, "" };
- attr_syntax_map[CTR_DESCRIPTION] = objAttrDescSyntax;
+ { PFC_IPCTYPE_STRING, 0, 0, 1, 128, false, "" };
+ attr_syntax_map[CTR_DESCRIPTION_STR] = objAttrDescSyntax;
Kt_Class_Attr_Syntax objAttrIpSyntax =
{ PFC_IPCTYPE_IPV4, 0, 4294967295LL, 0, 0, false, "" };
- attr_syntax_map[CTR_IP_ADDRESS] = objAttrIpSyntax;
+ attr_syntax_map[CTR_IP_ADDRESS_STR] = objAttrIpSyntax;
Kt_Class_Attr_Syntax objAttrUserSyntax =
- { PFC_IPCTYPE_STRING, 0, 0, 0, 32, false, "" };
- attr_syntax_map["user"] = objAttrUserSyntax;
+ { PFC_IPCTYPE_STRING, 0, 0, 1, 32, false, "" };
+ attr_syntax_map[IPCT_USER] = objAttrUserSyntax;
Kt_Class_Attr_Syntax objAttrPswdSyntax =
- { PFC_IPCTYPE_STRING, 0, 0, 0, 257, false, "" };
- attr_syntax_map[CTR_PASSWORD] = objAttrPswdSyntax;
+ { PFC_IPCTYPE_STRING, 0, 0, 1, 257, false, "" };
+ attr_syntax_map[CTR_PASSWORD_STR] = objAttrPswdSyntax;
Kt_Class_Attr_Syntax objAttrAuditSyntax =
{ PFC_IPCTYPE_UINT8, 0, 1, 0, 0, false, "" };
- attr_syntax_map[CTR_ENABLE_AUDIT] = objAttrAuditSyntax;
+ attr_syntax_map[CTR_ENABLE_AUDIT_STR] = objAttrAuditSyntax;
Kt_Class_Attr_Syntax objAttrValidSyntax =
{ PFC_IPCTYPE_STRING, 0, 0, 0, 8, false, "" };
- attr_syntax_map[CTR_VALID] = objAttrValidSyntax;
+ attr_syntax_map[CTR_VALID_STR] = objAttrValidSyntax;
Kt_Class_Attr_Syntax objAttrCsRowSyntax =
{ PFC_IPCTYPE_STRING, 0, 3, 0, 0, false, "" };
- attr_syntax_map[CTR_CS_ROW_STATUS] = objAttrCsRowSyntax;
+ attr_syntax_map[CTR_CS_ROW_STATUS_STR] = objAttrCsRowSyntax;
Kt_Class_Attr_Syntax objAttrCsAttrSyntax =
{ PFC_IPCTYPE_STRING, 0, 0, 0, 8, false, "" };
- attr_syntax_map[CTR_CS_ATTR] = objAttrCsAttrSyntax;
+ attr_syntax_map[CTR_CS_ATTR_STR] = objAttrCsAttrSyntax;
+ attr_syntax_map_all[UNC_KT_CONTROLLER] = attr_syntax_map;
}
/** GetClassPointerAndKey
- * * @Description : This function returns the void * of requested key structures
- * * and class pointer
- * * * @param[in] : key type and controller name
- * * * @return : void * key structure
+ * @Description : This function returns the void * of requested key structures
+ * and class pointer
+ * @param[in] : key_type-any value of KtControllerOperStatusRef
+ * controller name-controller id
+ * key-void* to ctr key structure
+ * @return : KtBase* key structure
* */
Kt_Base* Kt_Controller::GetClassPointerAndKey(
KtControllerOperStatusRef key_type,
void* &key) {
Kt_Base* class_pointer = NULL;
switch (key_type) {
- /* case KtCtrDomain: {
- class_pointer = new Kt_Ctr_Domain();
- key_ctr_domain_t *obj_key = new key_ctr_domain_t;
- memcpy(obj_key->ctr_key.controller_name,
- controller_name.c_str(),
- controller_name.length()+1);
- memset(obj_key->domain_name, 0, 32);
- key = reinterpret_cast<void *>(obj_key);
- break;
- } */
case KtSwitch: {
class_pointer = new Kt_Switch();
key_switch_t *obj_key = new key_switch_t;
key = reinterpret_cast<void *>(obj_key);
break;
}
- /* case KtLink: {
- class_pointer = new Kt_Link();
- key_link_t *obj_key = new key_link_t;
- memcpy(obj_key->ctr_key.controller_name,
- controller_name.c_str(),
- controller_name.length()+1);
- memset(obj_key->switch_id1, 0, 256);
- memset(obj_key->switch_id2, 0, 256);
- memset(obj_key->port_id1, 0, 32);
- memset(obj_key->port_id2, 0, 32);
- key = reinterpret_cast<void *>(obj_key);
- break;
- }
- case KtPort: {
- class_pointer = new Kt_Port();
- key_port_t *obj_key = new key_port_t;
- memcpy(obj_key->sw_key.ctr_key.controller_name,
- controller_name.c_str(),
- controller_name.length()+1);
- memset(obj_key->sw_key.switch_id, 0, 256);
- memset(obj_key->port_id, 0, 32);
- key = reinterpret_cast<void *>(obj_key);
- break;
- }
- case KtLogicalPort: {
- class_pointer = new Kt_LogicalPort();
- key_logical_port_t *obj_key = new key_logical_port_t;
- memcpy(obj_key->domain_key.ctr_key.controller_name,
- controller_name.c_str(),
- controller_name.length()+1);
- memset(obj_key->domain_key.domain_name, 0, 32);
- memset(obj_key->port_id, 0, 320);
- key = reinterpret_cast<void *>(obj_key);
- break;
- }
- case KtBoundary: {
- // Do nothing
- pfc_log_info("GetClassPointerAndKey - Boundary cannot be handled");
- PFC_ASSERT(PFC_FALSE);
- break;
- } */
}
return class_pointer;
}
/** FreeKeyStruct
- * * @Description : This function clears the key struct
- * * * @param[in] : key type and controller name
- * * * @return : void * key structure
+ * @Description : This function clears the key struct
+ * @param[in] : key type-any child kt of Controller
+ * key_struct-void* to any controller's child key structure
+ * @return : void
* */
void Kt_Controller::FreeKeyStruct(void* key_struct,
unsigned int key_type) {
switch (key_type) {
- /* case KtCtrDomain: {
- key_ctr_domain_t *obj_key = reinterpret_cast<key_ctr_domain_t *>
- (key_struct);
- if (obj_key != NULL) {
- delete obj_key;
- obj_key = NULL;
- }
- break;
- } */
case KtSwitch: {
key_switch_t *obj_key = reinterpret_cast<key_switch_t *>
(key_struct);
}
break;
}
- /* case KtLink: {
- key_link_t *obj_key = reinterpret_cast<key_link_t *>
- (key_struct);
- if (obj_key != NULL) {
- delete obj_key;
- obj_key = NULL;
- }
- break;
- }
- case KtPort: {
- key_port_t *obj_key = reinterpret_cast<key_port_t *>
- (key_struct);
- if (obj_key != NULL) {
- delete obj_key;
- obj_key = NULL;
- }
- break;
- }
- case KtLogicalPort: {
- key_logical_port_t *obj_key = reinterpret_cast<key_logical_port_t *>
- (key_struct);
- if (obj_key != NULL) {
- delete obj_key;
- obj_key = NULL;
- }
- break;
- }
- case KtBoundary: {
- // Do nothing
- pfc_log_info("FreeKeyStruct - Boundary cannot be handled");
- PFC_ASSERT(PFC_FALSE);
- break;
- } */
}
return;
}
/** GetOperStatus
- * * @Description : This function reads the oper_status value of the controller
- * * @param[in] : key_struct
- * * @return : oper_status
+ * @Description : This function reads the oper_status value of the controller
+ * @param[in] : key_struct
+ * data_type-UNC_DT_*,type of database
+ * param[out]:oper_status-oper status of Controller whether up/down/auditing
+ * @return : Success or associated error code
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
*/
-UpplReturnCode Kt_Controller::GetOperStatus(uint32_t data_type,
+UpplReturnCode Kt_Controller::GetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
uint8_t &oper_status) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode return_code = UPPL_RC_SUCCESS;
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
// Controller_name
string controller_name = (const char*)obj_key_ctr->controller_name;
pfc_log_info("controller name: %s", controller_name.c_str());
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// oper_status
- string value;
- PhyUtil::FillDbSchema(CTR_OPER_STATUS, value,
+ string value = "";
+ PhyUtil::FillDbSchema(unc::uppl::CTR_OPER_STATUS, value,
value.length(), DATATYPE_UINT16,
vect_table_attr_schema);
- kt_controller_dbtableschema.set_table_name(UPPL_CTR_TABLE);
+ kt_controller_dbtableschema.set_table_name(unc::uppl::CTR_TABLE);
kt_controller_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_controller_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS read_db_status = physical_layer->get_odbc_manager()->
- GetOneRow(UNC_DT_RUNNING, kt_controller_dbtableschema);
+ GetOneRow(UNC_DT_RUNNING, kt_controller_dbtableschema, db_conn);
if (read_db_status == ODBCM_RC_SUCCESS) {
- // populate IPC value structure based on the response recevied from DB
+ // populate IPC value structure based on the response received from DB
vector<TableAttrSchema> res_table_attr_schema =
kt_controller_dbtableschema.get_row_list().front();
vector<TableAttrSchema> ::iterator vect_iter =
res_table_attr_schema.begin();
for (; vect_iter != res_table_attr_schema.end(); ++vect_iter) {
TableAttrSchema tab_schema = (*vect_iter);
- string attr_name = tab_schema.table_attribute_name;
- string attr_value;
- if (attr_name == CTR_OPER_STATUS) {
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
+ string attr_value = "";
+ if (attr_name == unc::uppl::CTR_OPER_STATUS) {
PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
DATATYPE_UINT16);
oper_status = atoi(attr_value.c_str());
}
/** SetOperStatus
- * * @Description : This function updates the oper_status value
+ * @Description : This function updates the oper_status value
* of the controller
- * * @param[in] : key_struct
- * * @return : oper_status
+ * @param[in] : key_struct-void* to ctr key structure
+ * data_type-UNC_DT_*,type of database
+ * oper_status-oper status of Controller
+ * @return : Success or associated error code
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
*/
-UpplReturnCode Kt_Controller::SetOperStatus(uint32_t data_type,
+UpplReturnCode Kt_Controller::SetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
uint8_t oper_status) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode return_code = UPPL_RC_SUCCESS;
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
// Controller_name
string controller_name = (const char*)obj_key_ctr->controller_name;
pfc_log_info("controller name: %s", controller_name.c_str());
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// oper_status
string value = PhyUtil::uint8tostr(oper_status);
- PhyUtil::FillDbSchema(CTR_OPER_STATUS, value,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_OPER_STATUS, value,
value.length(), DATATYPE_UINT16,
vect_table_attr_schema);
- kt_controller_dbtableschema.set_table_name(UPPL_CTR_TABLE);
+ kt_controller_dbtableschema.set_table_name(unc::uppl::CTR_TABLE);
kt_controller_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_controller_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS update_db_status = physical_layer->get_odbc_manager()->
- UpdateOneRow(UNC_DT_RUNNING, kt_controller_dbtableschema);
+ UpdateOneRow(UNC_DT_RUNNING, kt_controller_dbtableschema, db_conn);
if (update_db_status == ODBCM_RC_SUCCESS) {
pfc_log_info("oper_status updated in DB successfully");
+ } else if (update_db_status == ODBCM_RC_CONNECTION_ERROR) {
+ pfc_log_fatal("DB connection issue during set oper status");
+ return_code = UPPL_RC_ERR_DB_ACCESS;
} else {
pfc_log_info("oper_status update failed in DB");
return_code = UPPL_RC_ERR_DB_UPDATE;
}
/** SetActualVersion
- * * @Description : This function updates the actual_version value
+ * @Description : This function updates the actual_version value
* of the controller
- * * @param[in] : key_struct
- * * @return : oper_status
+ * @param[in] : key_struct-void* to ctr key structure
+ * actual_version-version of controller
+ * data_type-UNC_DT_*,type of database
+ * @return : Success or associated error code
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
*/
-UpplReturnCode Kt_Controller::SetActualVersion(void* key_struct,
- string actual_version) {
+UpplReturnCode Kt_Controller::SetActualVersion(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ string actual_version,
+ uint32_t data_type,
+ uint32_t valid_flag) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode return_code = UPPL_RC_SUCCESS;
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
val_ctr_st_t val_ctr_valid_st;
memset(&val_ctr_valid_st, 0, sizeof(val_ctr_st_t));
pfc_log_debug("Get Valid value from DB");
- GetCtrValidFlag(key_struct, val_ctr_valid_st);
+ GetCtrValidFlag(db_conn, key_struct, val_ctr_valid_st, data_type);
stringstream str_valid;
for (unsigned int index = 0; index < ODBCM_SIZE_7;
++index) {
}
str_valid << valid;
}
- str_valid << UNC_VF_VALID; // Actual Version
+ str_valid << valid_flag; // Actual Version
str_valid << UNC_VF_VALID; // Oper Status
pfc_log_debug("str_valid %s", str_valid.str().c_str());
// Controller_name
string controller_name = (const char*)obj_key_ctr->controller_name;
pfc_log_debug("controller name: %s", controller_name.c_str());
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// actual_version_update
- PhyUtil::FillDbSchema(CTR_ACTUAL_VERSION, actual_version,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_ACTUAL_VERSION, actual_version,
actual_version.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- PhyUtil::FillDbSchema(CTR_VALID, str_valid.str(),
+ PhyUtil::FillDbSchema(unc::uppl::CTR_VALID, str_valid.str(),
str_valid.str().length(), DATATYPE_UINT8_ARRAY_9,
vect_table_attr_schema);
- kt_controller_dbtableschema.set_table_name(UPPL_CTR_TABLE);
+ kt_controller_dbtableschema.set_table_name(unc::uppl::CTR_TABLE);
kt_controller_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_controller_dbtableschema.set_row_list(row_list);
-
- ODBCM_RC_STATUS update_db_status = physical_layer->get_odbc_manager()->
- UpdateOneRow(UNC_DT_RUNNING, kt_controller_dbtableschema);
+ ODBCM_RC_STATUS update_db_status = ODBCM_RC_SUCCESS;
+ if (data_type == UNC_DT_CANDIDATE) {
+ update_db_status = physical_layer->get_odbc_manager()->
+ UpdateOneRow((unc_keytype_datatype_t)data_type,
+ kt_controller_dbtableschema, db_conn, true);
+ } else {
+ update_db_status = physical_layer->get_odbc_manager()->
+ UpdateOneRow((unc_keytype_datatype_t)data_type,
+ kt_controller_dbtableschema, db_conn);
+ }
if (update_db_status == ODBCM_RC_SUCCESS) {
pfc_log_info("actual version updated in DB successfully");
} else {
* key_struct:- key struct for updated controller
* val_struct:- val struct for updated controller
* @return : Success or associated error code
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response
+ * could not be added to sess.
* */
UpplReturnCode Kt_Controller::SendUpdatedControllerInfoToUPLL(
}
/** GetCtrValidFlag
- * * @Description : This function reads the valid flag from DB
- * * * @param[in] : Key, value struct and newvalid val
- * * * @return : Success or associated error code
+ * @Description : This function reads the valid flag from DB
+ * @param[in] : key_struct-void* to ctr key structure
+ * val_ctr_valid_st-instance of val_ctr_st_t
+ * @return : Success or associated error code
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_Controller::GetCtrValidFlag(
- void *key_struct,
- val_ctr_st_t &val_ctr_valid_st) {
+UpplReturnCode Kt_Controller::GetCtrValidFlag(OdbcmConnectionHandler *db_conn,
+ void *key_struct,
+ val_ctr_st_t &val_ctr_valid_st,
+ uint32_t data_type) {
UpplReturnCode return_code = UPPL_RC_SUCCESS;
vector<void *> vect_key_ctr;
vect_key_ctr.push_back(key_struct);
- vector<void *> vect_val_port;
- return_code = ReadInternal(vect_key_ctr, vect_val_port,
- UNC_DT_CANDIDATE, UNC_OP_READ);
+ vector<void *> vect_val_ctr;
+ return_code = ReadInternal(db_conn, vect_key_ctr, vect_val_ctr,
+ data_type, UNC_OP_READ);
if (return_code == UPPL_RC_SUCCESS) {
val_ctr_st_t *val_ctr_new_valid_st =
- reinterpret_cast<val_ctr_st_t*>(vect_val_port[0]);
+ reinterpret_cast<val_ctr_st_t*>(vect_val_ctr[0]);
if (val_ctr_new_valid_st != NULL) {
val_ctr_valid_st = *val_ctr_new_valid_st;
delete val_ctr_new_valid_st;
}
/** FrameValidValue
- * * @Description : This function converts the string value from db to uint8
- * * * @param[in] : Attribute value and val_ctr_st
- * * * @return : Success or associated error code
+ * @Description : This function converts the string value from db to uint8
+ * @param[in] : attr_value-attribute value in string
+ * obj_val_ctr_st-instance of val_ctr_st
+ * obj_val_ctr-instance of val_ctr_t
+ * @return : void
* */
void Kt_Controller::FrameValidValue(string attr_value,
val_ctr_st &obj_val_ctr_st,
}
/** FrameCsAttrValue
- * * @Description : This function converts the string value from db to uint8
- * * * @param[in] : Attribute value and val_ctr_st
- * * * @return : Success or associated error code
+ * @Description : This function converts the string value from db to uint8
+ * @param[in] : attr_value-Attribute value in string
+ * obj_val_ctr-instance of val_ctr_st
+ * @return : void
* */
void Kt_Controller::FrameCsAttrValue(string attr_value,
val_ctr_t &obj_val_ctr) {
}
/** ValidateTypeIpAddress
- * * @Description : This function checks whether controller exists with same
+ * @Description : This function checks whether controller exists with same
* type and ip address
- * * * @param[in] : Key and Value Struct
- * * * @return : Success or associated error code
+ * @param[in] : key_struct-void* to ctr key structure
+ * val_struct-void* to ctr val structure
+ * data_type-UNC_DT_*,type of datatype
+ * ctrl_type-type of controller,value of unc_keytype_ctrtype_t
+ * @return : Success or associated error code
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_Controller::ValidateTypeIpAddress(void *key_struct,
- void *val_struct,
- uint32_t data_type,
- uint32_t ctrl_type) {
+UpplReturnCode Kt_Controller::ValidateTypeIpAddress(
+ OdbcmConnectionHandler *db_conn,
+ void *key_struct,
+ void *val_struct,
+ uint32_t data_type,
+ uint32_t ctrl_type) {
UpplReturnCode status = UPPL_RC_SUCCESS;
val_ctr_t *obj_val_ctr = reinterpret_cast<val_ctr_t*>(val_struct);
if (obj_val_ctr == NULL) {
void *old_val_struct;
vector<ODBCMOperator> vect_key_operations;
- PopulateDBSchemaForKtTable(kt_controller_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_controller_dbtableschema,
key_struct,
NULL,
- UNC_OP_READ_SIBLING_BEGIN, 0, 0,
+ UNC_OP_READ_SIBLING_BEGIN, data_type, 0, 0,
vect_key_operations, old_val_struct);
ODBCM_RC_STATUS read_db_status = physical_layer->get_odbc_manager()->
GetBulkRows((unc_keytype_datatype_t)data_type, count,
kt_controller_dbtableschema,
- UNC_OP_READ_SIBLING_BEGIN);
+ UNC_OP_READ_SIBLING_BEGIN, db_conn);
pfc_log_debug("Return of GetBulkRows:%d", read_db_status);
if (read_db_status != ODBCM_RC_SUCCESS) {
return status;
}
- FillControllerValueStructure(kt_controller_dbtableschema,
+ FillControllerValueStructure(db_conn, kt_controller_dbtableschema,
vect_val_ctr_st,
count,
UNC_OP_READ_SIBLING_BEGIN,
}
/** ValidateControllerType
- * * @Description : This function checks whether the given controller type
+ * @Description : This function checks whether the given controller type
* is valid
- * * * @param[in] : operation, data_type, ctr_type, val_ctr
- * * * @return : Success or associated error code
+ * @param[in] : operation-UNC_OP_*,type of operation
+ * data_type-UNC_DT_*,type of database
+ * ctr_type-type of controller(unc_keytype_ctrtype_t)
+ * val_ctr-pointer to val_ctr_t
+ * param[out]:ctr_type_code-Success or associated error code
+ * @return : Success or associated error code
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
UpplReturnCode Kt_Controller::ValidateControllerType(
+ OdbcmConnectionHandler *db_conn,
uint32_t operation,
uint32_t data_type,
unc_keytype_ctrtype_t ctr_type,
unsigned int valid_val = 0;
// validate type
valid_val = PhyUtil::uint8touint(val_ctr->valid[kIdxType]);
- IS_VALID_INT_VALUE(CTR_TYPE, val_ctr->type, operation,
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map =
+ attr_syntax_map_all[UNC_KT_CONTROLLER];
+ IS_VALID_INT_VALUE(CTR_TYPE_STR, val_ctr->type, operation,
valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
/** ValidateControllerVersion
- * * @Description : This function checks whether the given controller version
+ * @Description : This function checks whether the given controller version
* is valid
- * * * @param[in] : operation, data_type, ctr_type, val_ctr
- * * * @return : Success or associated error code
+ * @param[in] : operation-UNC_OP_*,type of operation
+ * data_type-UNC_DT_*,type of database
+ * ctr_type-type of controller,value of unc_keytype_ctrtype_t
+ * val_ctr-pointer ctr value structure
+ * param[out]:ctr_type_code-Success or associated error code
+ * @return : Success or associated error code
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
UpplReturnCode Kt_Controller::ValidateControllerVersion(
+ OdbcmConnectionHandler *db_conn,
uint32_t operation,
uint32_t data_type,
unc_keytype_ctrtype_t ctr_type,
ctr_type == UNC_CT_PFC) ||
(operation == UNC_OP_CREATE && val_ctr->type == UNC_CT_PFC)) {
// validate version
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map =
+ attr_syntax_map_all[UNC_KT_CONTROLLER];
valid_val = PhyUtil::uint8touint(val_ctr->valid[kIdxVersion]);
string value = reinterpret_cast<char*>(val_ctr->version);
- IS_VALID_STRING_VALUE(CTR_VERSION, value, operation,
+ IS_VALID_STRING_VALUE(CTR_VERSION_STR, value, operation,
valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
/** ValidateControllerDescription
- * * @Description : This function checks whether the given controller description
+ * @Description : This function checks whether the given controller description
* is valid
- * * * @param[in] : operation, data_type, ctr_type, val_ctr
- * * * @return : Success or associated error code
+ * @param[in] : operation-UNC_OP_*,type of operation
+ * data_type-UNC_DT_*,type of database
+ * ctr_type-type of controller
+ * val_ctr-pointer to ctr val structure
+ * param[out]:ctr_type_code-Success or associated error code
+ * @return : Success or associated error code
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
UpplReturnCode Kt_Controller::ValidateControllerDescription(
+ OdbcmConnectionHandler *db_conn,
uint32_t operation,
uint32_t data_type,
unc_keytype_ctrtype_t ctr_type,
// validate description
valid_val = PhyUtil::uint8touint(val_ctr->valid[kIdxDescription]);
string value = reinterpret_cast<char*>(val_ctr->description);
- IS_VALID_STRING_VALUE(CTR_DESCRIPTION, value, operation,
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map =
+ attr_syntax_map_all[UNC_KT_CONTROLLER];
+ IS_VALID_STRING_VALUE(CTR_DESCRIPTION_STR, value, operation,
valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
/** ValidateControllerIpAddress
- * * @Description : This function checks whether the given controller ip address
+ * @Description : This function checks whether the given controller ip address
* is valid
- * * * @param[in] : operation, data_type, ctr_type, val_ctr
- * * * @return : Success or associated error code
+ * @param[in] : operation-UNC_OP_*,type of operation
+ * data_type-UNC_DT_*,type of database
+ * ctr_type-type of controller,value of unc_keytype_ctrtype_t
+ * val_ctr-pointer to ctr val structure
+ * param[out]:ctr_type_code-Success or associated error code
+ * @return : Success or associated error code
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
UpplReturnCode Kt_Controller::ValidateControllerIpAddress(
+ OdbcmConnectionHandler *db_conn,
uint32_t operation,
uint32_t data_type,
unc_keytype_ctrtype_t ctr_type,
}
if (operation == UNC_OP_UPDATE && ctr_type_code == UPPL_RC_SUCCESS &&
valid_val == UNC_VF_VALID) {
- UpplReturnCode validate_status = ValidateTypeIpAddress(key_struct,
+ UpplReturnCode validate_status = ValidateTypeIpAddress(db_conn, key_struct,
val_struct,
data_type,
ctr_type);
if (validate_status != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
+ pfc_log_debug("Validating Type and Ip Address in Running Db");
+ validate_status = ValidateTypeIpAddress(db_conn, key_struct,
+ val_struct,
+ UNC_DT_RUNNING,
+ ctr_type);
+ if (validate_status != UPPL_RC_SUCCESS) {
+ return UPPL_RC_ERR_CFG_SYNTAX;
+ }
}
- IS_VALID_IPV4_VALUE(CTR_IP_ADDRESS, val_ctr->ip_address, operation,
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map =
+ attr_syntax_map_all[UNC_KT_CONTROLLER];
+ IS_VALID_IPV4_VALUE(CTR_IP_ADDRESS_STR, val_ctr->ip_address, operation,
valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
/** ValidateControllerUser
- * * @Description : This function checks whether the given controller user
+ * @Description : This function checks whether the given controller user
* is valid
- * * * @param[in] : operation, data_type, ctr_type, val_ctr
- * * * @return : Success or associated error code
+ * @param[in] : operation-UNC_OP_*,type of operation
+ * data_type-UNC_DT_*,type of database
+ * ctr_type-type of controller,value of unc_keytype_ctrtype_t
+ * val_ctr-pointer to ctr val structure
+ * param[out]:ctr_type_code-Success or associated error code
+ * @return : Success or associated error code
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
UpplReturnCode Kt_Controller::ValidateControllerUser(
+ OdbcmConnectionHandler *db_conn,
uint32_t operation,
uint32_t data_type,
unc_keytype_ctrtype_t ctr_type,
return UPPL_RC_ERR_CFG_SYNTAX;
}
string value = reinterpret_cast<char*>(val_ctr->user);
- IS_VALID_STRING_VALUE("user", value, operation,
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map =
+ attr_syntax_map_all[UNC_KT_CONTROLLER];
+ IS_VALID_STRING_VALUE(IPCT_USER, value, operation,
valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
/** ValidateControllerPassword
- * * @Description : This function checks whether the given controller password
+ * @Description : This function checks whether the given controller password
* is valid
- * * * @param[in] : operation, data_type, ctr_type, val_ctr
- * * * @return : Success or associated error code
+ * @param[in] :operation-UNC_OP_*,type of operation
+ * data_type-UNC_DT_*,type of database
+ * ctr_type-type of controller,value of unc_keytype_ctrtype_t
+ * val_ctr-pointer to ctr val structure
+ * param[out]:ctr_type_code-Success or associated error code
+ * @return : Success or associated error code,UPPL_RC_SUCCESS/ERR*
* */
UpplReturnCode Kt_Controller::ValidateControllerPassword(
+ OdbcmConnectionHandler *db_conn,
uint32_t operation,
uint32_t data_type,
unc_keytype_ctrtype_t ctr_type,
return UPPL_RC_ERR_CFG_SYNTAX;
}
string value = reinterpret_cast<char*>(val_ctr->password);
- IS_VALID_STRING_VALUE(CTR_PASSWORD, value, operation,
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map =
+ attr_syntax_map_all[UNC_KT_CONTROLLER];
+ IS_VALID_STRING_VALUE(CTR_PASSWORD_STR, value, operation,
valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
/** ValidateControllerEnableAudit
- * * @Description : This function checks whether the given controller enable audit
+ * @Description : This function checks whether the given controller enable audit
* is valid
- * * * @param[in] : operation, data_type, ctr_type, val_ctr
- * * * @return : Success or associated error code
+ * @param[in] : operation-UNC_OP_*,type of operation
+ * data_type-UNC_DT_*,type of database
+ * ctr_type-type of controller, value of unc_keytype_ctrtype_t
+ * val_ctr-pointer to ctr val structure
+ * param[out]:ctr_type_code-Success or associated error code
+ * @return : Success or associated error code,UPPL_RC_SUCCESS/ERR*
* */
UpplReturnCode Kt_Controller::ValidateControllerEnableAudit(
+ OdbcmConnectionHandler *db_conn,
uint32_t operation,
uint32_t data_type,
unc_keytype_ctrtype_t ctr_type,
"Enable audit cannot be modified for unknown controller type");
return UPPL_RC_ERR_CFG_SYNTAX;
}
- IS_VALID_INT_VALUE(CTR_ENABLE_AUDIT, val_ctr->enable_audit, operation,
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map =
+ attr_syntax_map_all[UNC_KT_CONTROLLER];
+ IS_VALID_INT_VALUE(CTR_ENABLE_AUDIT_STR, val_ctr->enable_audit, operation,
valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
/** SendOperStatusNotification
- * * @Description : This function sends oper status change as notification to
+ * @Description : This function sends oper status change as notification to
* north bound
- * * * @param[in] : key_ctr, old oper status and new oper status
- * * * @return : Success or associated error code
+ * @param[in] : ctr_key pointer to ctr key structure
+ * old_oper_st-old oper status of controller
+ * new_oper_st-new oper status of controller
+ * @return : Success or associated error code,UPPL_RC_SUCESS/ERR*
* */
UpplReturnCode Kt_Controller::SendOperStatusNotification(key_ctr_t ctr_key,
uint8_t old_oper_st,
UNC_DT_STATE,
UNC_KT_CONTROLLER};
err = PhyUtil::sessOutNBEventHeader(ser_evt, rsh);
- pfc_log_debug("%s", (IpctUtil::get_string(ctr_key)).c_str());
- pfc_log_debug("%s", (IpctUtil::get_string(new_val_ctr)).c_str());
- pfc_log_debug("%s", (IpctUtil::get_string(old_val_ctr)).c_str());
err |= ser_evt.addOutput(ctr_key);
err |= ser_evt.addOutput(new_val_ctr);
err |= ser_evt.addOutput(old_val_ctr);
"Server Event addOutput failed, return IPC_WRITE_ERROR");
status = UPPL_RC_ERR_IPC_WRITE_ERROR;
} else {
+ pfc_log_debug("%s", (IpctUtil::get_string(ctr_key)).c_str());
+ pfc_log_debug("%s", (IpctUtil::get_string(new_val_ctr)).c_str());
+ pfc_log_debug("%s", (IpctUtil::get_string(old_val_ctr)).c_str());
// Call IPC server to post the event
status = (UpplReturnCode) physical_layer
->get_ipc_connection_manager()->SendEvent(&ser_evt);
}
return status;
}
+
+/** CheckIpAndClearStateDB
+ * @Description : This function checks the ip address and clears state db
+ * if ip address is empty
+ * @param[in] : key_struct of controller
+ * @return : Success or associated error code,UPPL_RC_SUCESS/ERR*
+ * */
+UpplReturnCode Kt_Controller::CheckIpAndClearStateDB(
+ OdbcmConnectionHandler *db_conn,
+ void *key_struct) {
+ UpplReturnCode state_status = UPPL_RC_SUCCESS;
+ vector<void *> vect_ctr_key, vect_ctr_val;
+ vect_ctr_key.push_back(key_struct);
+ state_status = ReadInternal(db_conn,
+ vect_ctr_key,
+ vect_ctr_val,
+ UNC_DT_RUNNING,
+ UNC_OP_READ);
+ if (state_status != UPPL_RC_SUCCESS) {
+ pfc_log_debug("Read Internal Failed");
+ return state_status;
+ }
+ val_ctr_st_t *ctr_val =
+ reinterpret_cast<val_ctr_st_t*>(vect_ctr_val[0]);
+ key_ctr_t *ctr_key = reinterpret_cast<key_ctr_t*>(vect_ctr_key[0]);
+ string controller_name = "";
+ if (ctr_key != NULL) {
+ controller_name = reinterpret_cast<char*>(ctr_key->controller_name);
+ delete ctr_key;
+ ctr_key = NULL;
+ }
+ if (ctr_val != NULL) {
+ if (ctr_val->controller.ip_address.s_addr == 0) {
+ // Release all associated entries in state db
+ pfc_log_info("Removing State entries for controller %s",
+ controller_name.c_str());
+ ODBCM_RC_STATUS clear_status =
+ PhysicalLayer::get_instance()->get_odbc_manager()->
+ ClearOneInstance(UNC_DT_STATE, controller_name, db_conn);
+ if (clear_status != ODBCM_RC_SUCCESS) {
+ pfc_log_info("State DB clearing failed");
+ }
+ // Reset actual version as empty
+ string act_version = "";
+ UpplReturnCode status = SetActualVersion(db_conn, key_struct, act_version,
+ UNC_DT_RUNNING, UNC_VF_INVALID);
+ if (status != UPPL_RC_SUCCESS) {
+ // log error
+ pfc_log_error("act_version reset operation failed for running");
+ }
+ status = SetActualVersion(db_conn, key_struct,
+ act_version, UNC_DT_CANDIDATE, UNC_VF_INVALID);
+ if (status != UPPL_RC_SUCCESS) {
+ // log error
+ pfc_log_error("act_version reset operation failed for candidate");
+ }
+ }
+ delete ctr_val;
+ ctr_val = NULL;
+ }
+ return state_status;
+}
+
+/** CheckSameIp
+ * @Description : This function checks whether same ip is given
+ * @param[in] : key_struct-void* to ctr key structure
+ * val_ctr_valid_st-instance of val_ctr_st_t
+ * @return : Success or associated error code
+ * */
+UpplReturnCode Kt_Controller::CheckSameIp(OdbcmConnectionHandler *db_conn,
+ void *key_struct,
+ void *val_struct,
+ uint32_t data_type) {
+ UpplReturnCode return_code = UPPL_RC_SUCCESS;
+ vector<void *> vect_key_ctr;
+ vect_key_ctr.push_back(key_struct);
+ vector<void *> vect_val_ctr;
+ val_ctr_t ctr_val = *reinterpret_cast<val_ctr_t*>(val_struct);
+ uint32_t existing_ip = ctr_val.ip_address.s_addr;
+ return_code = ReadInternal(db_conn, vect_key_ctr, vect_val_ctr,
+ data_type, UNC_OP_READ);
+ if (return_code == UPPL_RC_SUCCESS) {
+ val_ctr_st_t *val_ctr_new_valid_st =
+ reinterpret_cast<val_ctr_st_t*>(vect_val_ctr[0]);
+ if (val_ctr_new_valid_st != NULL) {
+ uint32_t in_ip = val_ctr_new_valid_st->controller.ip_address.s_addr;
+ if (existing_ip == in_ip) {
+ pfc_log_info("Same Ip given - Ignore");
+ } else {
+ pfc_log_info("Different Ip given - Throw Error");
+ return_code = UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
+ }
+ delete val_ctr_new_valid_st;
+ val_ctr_new_valid_st = NULL;
+ key_ctr_t *ctr_key = reinterpret_cast<key_ctr_t*>
+ (vect_key_ctr[0]);
+ if (ctr_key != NULL) {
+ delete ctr_key;
+ ctr_key = NULL;
+ }
+ }
+ }
+ return return_code;
+}
#include "itc_kt_switch.hh"
#include "itc_kt_logicalport.hh"
#include "odbcm_db_varbind.hh"
+#include "itc_read_request.hh"
using unc::uppl::PhysicalLayer;
#define DEFAULT_DOMAIN "(DEFAULT)"
-/** Constructor
- * * @Description : This function instantiates parent and child key types for
- * kt_ctr_domain
- * * * @param[in] : None
- * * * @return : None
- * */
+/**
+ * @Description : This function initializes member variables
+ * and fills the attribute syntax map used for validation
+ * @param[in] : None
+ * @return : None
+ **/
Kt_Ctr_Domain::Kt_Ctr_Domain() {
- parent = NULL;
for (int i = 0; i < KT_CTR_DOMAIN_CHILD_COUNT; ++i) {
child[i] = NULL;
}
// Populate structure to be used for syntax validation
- Fill_Attr_Syntax_Map();
+ if (attr_syntax_map_all.find(UNC_KT_CTR_DOMAIN) ==
+ attr_syntax_map_all.end()) {
+ Fill_Attr_Syntax_Map();
+ }
}
-/** Destructor
- * * @Description : This function clears the parent and child key types
- * instances for kt_ctr_domain
- * * * @param[in] : None
- * * * @return : None
- * */
+/**
+ * @Description : This function frees child key instances
+ * instances for kt_ctr_domain
+ * @param[in] : None
+ * @return : None
+ **/
Kt_Ctr_Domain::~Kt_Ctr_Domain() {
- // Delete parent object
- if (parent != NULL)
- delete parent;
- parent = NULL;
// Delete all child objects
for (int i = 0; i < KT_CTR_DOMAIN_CHILD_COUNT; ++i) {
if (child[i] != NULL) {
/** GetChildClassPointer
- * * @Description : This function creates a new child class instance
- * class of KtDomain based on index passed
- * * @param[in] : KtDomainChildClass
- * * @return : Kt_Base*
- */
+ * @Description : This function creates a new child class instance
+ * class of KtDomain based on index passed
+ * @param[in] : KtDomainChildClass
+ * @return : Kt_Base*
+ **/
Kt_Base* Kt_Ctr_Domain::GetChildClassPointer(KtDomainChildClass KIndex) {
switch (KIndex) {
case KIdxLogicalPort: {
return child[KIndex];
}
-/** Create
- * * @Description : This function creates a new row of KT_Domain in
- * candidate domain table.
- * * @param[in] : session_id - ipc session id used for TC validation
- * configuration_id - configuration id used for TC validation
- * key_struct - the key for the new kt domain instance
- * value_struct - the values for the new kt domain instance
- * data_type - UNC_DT_* , Create only allowed in candidate from VTN
- * sess - ipc server session where the response has to be added
- * * @return : UPPL_RC_SUCCESS is returned when the response
- * is added to ipc session successfully.
- * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
- * */
-
-UpplReturnCode Kt_Ctr_Domain::Create(uint32_t session_id,
+/**
+ * @Description : This function creates a new row of KT_Domain in
+ * candidate domain table.
+ * @param[in] : session_id - ipc session id used for TC validation
+ * configuration_id - configuration id used for TC validation
+ * key_struct - the key for the new kt domain instance
+ * value_struct - the values for the new kt domain instance
+ * data_type - UNC_DT_* , Create only allowed in candidate from
+ * VTN
+ * sess - ipc server session where the response has to be added
+ * @return : UPPL_RC_SUCCESS is returned when the response is added to ipc
+ * session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be
+ * added to sess.
+ **/
+
+UpplReturnCode Kt_Ctr_Domain::Create(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
ctr_key.controller_name;
unc_keytype_ctrtype_t controller_type;
UpplReturnCode retcode = PhyUtil::get_controller_type(
- controller_name,
+ db_conn, controller_name,
controller_type,
(unc_keytype_datatype_t)data_type);
// Check whether operation is allowed on the given DT type
pfc_log_error("is not supported from VTN");
create_status = UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
} else {
- create_status = CreateKeyInstance(key_struct,
+ create_status = CreateKeyInstance(db_conn, key_struct,
val_struct,
data_type,
UNC_KT_CTR_DOMAIN);
}
/** CreateKeyInstance
- * * @Description : This function creates a new row of KT_Domain in
- * candidate Domain table.
- * key_struct - the key for the new kt Domain instance
- * value_struct - the values for the new kt Domain instance
- * data_type - UNC_DT_* , Create only allowed in candidate if request is
- * from VTN and allowed in state if request is from southbound
+ * @Description : This function creates a new row of KT_Domain in
+ * candidate Domain table.
+ * param[in] : key_struct - the key for the new kt Domain instance
+ * value_struct - the values for the new kt Domain instance
+ * data_type - UNC_DT_* , Create only allowed in candidate if
+ * request is from VTN and allowed in state if request is from
+ * south bound
+ * key_type - indicates the key type class
* * @return : UPPL_RC_SUCCESS is returned when the create is success
- * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
+ * UPPL_RC_ERR_* is returned when ipc response could not be
+ * added to sess.
* */
-UpplReturnCode Kt_Ctr_Domain::CreateKeyInstance(void* key_struct,
+UpplReturnCode Kt_Ctr_Domain::CreateKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t key_type) {
void *old_val_struct;
vector<ODBCMOperator> vect_key_operations;
if ((unc_keytype_datatype_t)data_type == UNC_DT_CANDIDATE) {
- PopulateDBSchemaForKtTable(kt_ctr_domain_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_ctr_domain_dbtableschema,
key_struct,
val_struct,
- UNC_OP_CREATE, 0, 0,
+ UNC_OP_CREATE, data_type, 0, 0,
vect_key_operations, old_val_struct);
} else if ((unc_keytype_datatype_t)data_type == UNC_DT_STATE ||
(unc_keytype_datatype_t)data_type == UNC_DT_IMPORT) {
- PopulateDBSchemaForKtTable(kt_ctr_domain_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_ctr_domain_dbtableschema,
key_struct,
val_struct,
- UNC_OP_CREATE, 0, 0,
+ UNC_OP_CREATE, data_type, 0, 0,
vect_key_operations, old_val_struct,
NOTAPPLIED,
false,
// Send request to ODBC for ctr_domain_table create
ODBCM_RC_STATUS create_db_status = physical_layer->get_odbc_manager()->\
CreateOneRow((unc_keytype_datatype_t)data_type,
- kt_ctr_domain_dbtableschema);
- pfc_log_info("CreateOneRow response from DB is %d", create_db_status);
+ kt_ctr_domain_dbtableschema, db_conn);
if (create_db_status != ODBCM_RC_SUCCESS) {
if (create_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log fatal error to log daemon
return create_status;
}
-/** Update
- * * @Description : This function updates a row of KT_Domain in
- * candidate Domain table.
- * * @param[in] : session_id - ipc session id used for TC validation
- * configuration_id - configuration id used for TC validation
- * key_struct - the key for the kt Domain instance
- * value_struct - the values for the kt Domain instance
- * data_type - UNC_DT_* , Update only allowed in candidate from VTN
- * sess - ipc server session where the response has to be added
- * * @return : UPPL_RC_SUCCESS is returned when the response
- * is added to ipc session successfully.
- * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
- * */
-UpplReturnCode Kt_Ctr_Domain::Update(uint32_t session_id,
+/**
+ * @Description : This function updates a row of KT_Domain in
+ * candidate Domain table.
+ * @param[in] : session_id - ipc session id used for TC validation
+ * configuration_id - configuration id used for TC validation
+ * key_struct - the key for the kt Domain instance
+ * value_struct - the values for the kt Domain instance
+ * data_type - UNC_DT_* , Update only allowed in candidate from
+ * VTN
+ * sess - ipc server session where the response has to be added
+ * @return : UPPL_RC_SUCCESS is returned when the response is added to ipc
+ * session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be
+ * added to sess.
+ **/
+UpplReturnCode Kt_Ctr_Domain::Update(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
ctr_key.controller_name;
unc_keytype_ctrtype_t controller_type;
UpplReturnCode retcode = PhyUtil::get_controller_type(
- controller_name,
+ db_conn, controller_name,
controller_type,
(unc_keytype_datatype_t)data_type);
// Check whether operation is allowed on the given DT type
pfc_log_error("is not supported from VTN");
update_status = UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
} else {
- update_status = UpdateKeyInstance(key_struct,
+ update_status = UpdateKeyInstance(db_conn, key_struct,
val_struct,
data_type,
UNC_KT_CTR_DOMAIN);
}
/** UpdateKeyInstance
- * * @Description : This function updates a row of KT_Domain in
- * Domain table.
- * * @param[in] :
- * key_struct - the key for the new kt Domain instance
- * value_struct - the values for the new kt Domain instance
- * data_type - UNC_DT_* , update only allowed in candidate if request is
- * from VTN and allowed in state if request is from southbound
+ * @Description : This function updates a row of KT_Domain in Domain table.
+ * @param[in] : key_struct - the key for the new kt Domain instance
+ * value_struct - the values for the new kt Domain instance
+ * data_type - UNC_DT_* , update only allowed in candidate if
+ * request is from VTN and allowed in state if request is from
+ * southbound
+ * key_type - indicates the key type class
* * @return : UPPL_RC_SUCCESS is returned when the update
* is done successfully.
* UPPL_RC_ERR_* is returned when the update is error
* */
-UpplReturnCode Kt_Ctr_Domain::UpdateKeyInstance(void* key_struct,
+UpplReturnCode Kt_Ctr_Domain::UpdateKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t key_type) {
vector<ODBCMOperator> vect_key_operations;
// Create DBSchema structure for ctr_domain_table
if ((unc_keytype_datatype_t)data_type == UNC_DT_CANDIDATE) {
- PopulateDBSchemaForKtTable(kt_ctr_domain_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_ctr_domain_dbtableschema,
key_struct,
val_struct,
- UNC_OP_UPDATE, 0, 0,
+ UNC_OP_UPDATE, data_type, 0, 0,
vect_key_operations, old_val_struct);
} else if ((unc_keytype_datatype_t)data_type == UNC_DT_STATE ||
(unc_keytype_datatype_t)data_type == UNC_DT_IMPORT) {
- PopulateDBSchemaForKtTable(kt_ctr_domain_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_ctr_domain_dbtableschema,
key_struct,
val_struct,
- UNC_OP_UPDATE, 0, 0,
+ UNC_OP_UPDATE, data_type, 0, 0,
vect_key_operations, old_val_struct,
NOTAPPLIED,
false,
// Send request to ODBC for ctr_domain_table update
ODBCM_RC_STATUS update_db_status = physical_layer->get_odbc_manager()-> \
UpdateOneRow((unc_keytype_datatype_t)data_type,
- kt_ctr_domain_dbtableschema);
- pfc_log_info("UpdateOneRow response from DB is %d", update_db_status);
+ kt_ctr_domain_dbtableschema, db_conn);
if (update_db_status != ODBCM_RC_SUCCESS) {
if (update_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log fatal error to log daemon
/**Delete
* * @Description : This function deletes a row of KT_Domain in
- * candidate Domain table.
- * * @param[in] : session_id - ipc session id used for TC validation
- * configuration_id - configuration id used for TC validation
- * key_struct - the key for the kt Domain instance
- * data_type - UNC_DT_* , delete only allowed in candidate if request is
- * from VTN and allowed in state if request is from southbound
- * sess - ipc server session where the response has to be added
- * * @return : UPPL_RC_SUCCESS is returned when the response
- * is added to ipc session successfully.
- * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
- * */
-UpplReturnCode Kt_Ctr_Domain::Delete(uint32_t session_id,
+ * candidate Domain table.
+ * * @param[in] : session_id - ipc session id used for TC validation
+ * configuration_id - configuration id used for TC validation
+ * key_struct - the key for the kt Domain instance
+ * data_type - UNC_DT_* , delete only allowed in candidate if
+ * request is from VTN and allowed in state if request is from
+ * southbound
+ * sess - ipc server session where the response has to be added
+ * * @return : UPPL_RC_SUCCESS is returned when the response is added to
+ * ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be
+ * added to sess.
+ **/
+UpplReturnCode Kt_Ctr_Domain::Delete(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
uint32_t data_type,
ctr_key.controller_name;
unc_keytype_ctrtype_t controller_type;
UpplReturnCode retcode = PhyUtil::get_controller_type(
- controller_name, controller_type, (unc_keytype_datatype_t)data_type);
+ db_conn, controller_name, controller_type,
+ (unc_keytype_datatype_t)data_type);
// Check whether operation is allowed on the given DT type
if (retcode != UPPL_RC_SUCCESS) {
pfc_log_error("Error getting the controller type");
} else if (retcode == UPPL_RC_SUCCESS) {
// Check whether any boundary is referring domain
Kt_Boundary boundary_class;
- if (boundary_class.IsBoundaryReferred(UNC_KT_CTR_DOMAIN,
+ if (boundary_class.IsBoundaryReferred(db_conn, UNC_KT_CTR_DOMAIN,
key_struct,
data_type) == PFC_TRUE) {
// Boundary is referring Domain
delete_status = UPPL_RC_ERR_CFG_SEMANTIC;
} else {
// Delete domain
- delete_status = DeleteKeyInstance(key_struct, data_type,
+ delete_status = DeleteKeyInstance(db_conn, key_struct, data_type,
UNC_KT_CTR_DOMAIN);
}
}
}
/**DeleteKeyInstance
- * * @Description : This function deletes a row of KT_Domain in
- * candidate domain table.
- * * @param[in] :
- * key_struct - the key for the new kt domain instance
- * data_type - UNC_DT_* , delete only allowed in candidate if request is
- * from VTN and allowed in state if request is from southbound
- * * @return : UPPL_RC_SUCCESS is returned when the delete
- * is done successfully.
- * UPPL_RC_ERR_* is returned when the delete is error
- * */
-UpplReturnCode Kt_Ctr_Domain::DeleteKeyInstance(void* key_struct,
+ * @Description : This function deletes a row of KT_Domain in
+ * candidate domain table.
+ * @param[in] : key_struct - the key for the new kt domain instance
+ * data_type - UNC_DT_* , delete only allowed in candidate if
+ * request is from VTN and allowed in state if request is from
+ * southbound
+ * key_type - indicates the key type class
+ * @return : UPPL_RC_SUCCESS is returned when the delete is done
+ * successfully.
+ * UPPL_RC_ERR_* is returned when the delete is error
+ **/
+UpplReturnCode Kt_Ctr_Domain::DeleteKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
uint32_t key_type) {
// Check whether operation is allowed on the given DT type
vector<key_ctr_domain_t> vect_ctr_domain_id;
if (domain_name.length() == 0) {
- delete_status = ReadBulkInternal(key_struct, data_type, UPPL_MAX_REP_CT,
+ delete_status = ReadBulkInternal(db_conn, key_struct, data_type,
+ UPPL_MAX_REP_CT,
vect_val_ctr_domain, vect_ctr_domain_id);
} else {
vect_ctr_domain_id.push_back(*obj_key_ctr_domain);
}
- // Delete child classes and then delete switch
+ // Delete child classes and then delete domain
vector<key_ctr_domain_t> ::iterator ctr_domain_iter =
vect_ctr_domain_id.begin();
for (; ctr_domain_iter != vect_ctr_domain_id.end(); ++ctr_domain_iter) {
domain_name);
Kt_LogicalPort logical_port;
UpplReturnCode ch_delete_status = logical_port.DeleteKeyInstance(
+ db_conn,
child_key_struct,
data_type,
UNC_KT_LOGICAL_PORT);
// construct TableAttrSchema structure
// TableAttrSchema holds table_name, primary key, attr_name
vector<TableAttrSchema> vect_table_attr_schema;
- TableAttrSchema kt_ctr_domain_table_attr_schema;
list< vector<TableAttrSchema> > row_list;
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
// controller_name
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
if (domain_name.length() != 0) {
- vect_prim_keys.push_back(DOMAIN_NAME);
+ vect_prim_keys.push_back(DOMAIN_NAME_STR);
// domain_name
- PhyUtil::FillDbSchema(DOMAIN_NAME, domain_name,
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_NAME, domain_name,
domain_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
}
// Send request to ODBC for ctr_domain_table delete
- kt_ctr_domain_dbtableschema.set_table_name(UPPL_CTR_DOMAIN_TABLE);
+ kt_ctr_domain_dbtableschema.set_table_name(unc::uppl::CTR_DOMAIN_TABLE);
kt_ctr_domain_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_ctr_domain_dbtableschema.set_row_list(row_list);
// Send request to ODBC for ctr_domain_table delete
ODBCM_RC_STATUS delete_db_status = physical_layer->get_odbc_manager()->
DeleteOneRow((unc_keytype_datatype_t)data_type,
- kt_ctr_domain_dbtableschema);
+ kt_ctr_domain_dbtableschema, db_conn);
pfc_log_debug("DeleteOneRow status is %d", delete_db_status);
if (delete_db_status != ODBCM_RC_SUCCESS) {
if (delete_db_status == ODBCM_RC_CONNECTION_ERROR) {
pfc_log_error("Delete operation has failed in domain common table");
delete_status = UPPL_RC_ERR_DB_DELETE;
}
- } else {
+ } else if (data_type != UNC_DT_CANDIDATE) {
// Boundary operstatus to be changed only after running db sync
// Notify switch to update domainid as invalid
+ delete_status = UPPL_RC_SUCCESS;
Kt_Switch switch_obj;
key_switch_t obj_key_switch;
memset(&obj_key_switch, '\0', sizeof(key_switch_t));
// call switch function to set domain id valid status as invalid
val_switch_st_t obj_val_switch;
- // set obj_val_switch valid as invalid
- memset(obj_val_switch.valid, UNC_VF_INVALID, 6);
-
+ memset(&obj_val_switch, 0, sizeof(obj_val_switch));
+ obj_val_switch.valid[kIdxSwitch] = UNC_VF_VALID;
memcpy(obj_val_switch.switch_val.domain_name,
domain_name.c_str(),
domain_name.length()+1);
- obj_val_switch.valid[kIdxSwitchDomainName] = UNC_VF_VALID;
+ obj_val_switch.switch_val.valid[kIdxSwitchDomainName] = UNC_VF_VALID;
UpplReturnCode read_status = switch_obj.UpdateSwitchValidFlag(
- reinterpret_cast<void*>(&obj_key_switch),
+ db_conn, reinterpret_cast<void*>(&obj_key_switch),
reinterpret_cast<void*>(&obj_val_switch),
obj_val_switch,
- UNC_VF_INVALID);
+ UNC_VF_INVALID, data_type);
pfc_log_debug("UpdateSwitchValidFlag returned %d", read_status);
+ } else {
+ pfc_log_info("Delete of a ctr_domain in data_type(%d) is success",
+ data_type);
+ delete_status = UPPL_RC_SUCCESS;
}
}
return delete_status;
}
-/** ReadInternal
- * * @Description : This function reads the given instance of KT_Domain
- ** * @param[in] : session_id - ipc session id used for TC validation
- * key_struct - the key for the kt Domain instance
- * value_struct - the value for the kt Domain instance
- * data_type - UNC_DT_* , read allowed in candidate/running/startup/state
- * * @return : UPPL_RC_SUCCESS is returned when the response
- * is added to ipc session successfully.
- * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
- * */
-UpplReturnCode Kt_Ctr_Domain::ReadInternal(
- vector<void *> &key_val,
- vector<void *> &val_struct,
- uint32_t data_type,
- uint32_t operation_type) {
+/**
+ * @Description : This function reads the given instance of KT_Domain
+ * @param[in] : session_id - ipc session id used for TC validation
+ * key_struct - the key for the kt Domain instance
+ * val_struct - the value for the kt Domain instance
+ * data_type - UNC_DT_* , read allowed in
+ * candidate/running/startup/state
+ * operation_type - indicates the operation type - UNC_OP_*.
+ * @return : UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be
+ * added to sess.
+ **/
+UpplReturnCode Kt_Ctr_Domain::ReadInternal(OdbcmConnectionHandler *db_conn,
+ vector<void *> &key_val,
+ vector<void *> &val_struct,
+ uint32_t data_type,
+ uint32_t operation_type) {
pfc_log_debug("Inside ReadInternal of KT_CTR_DOMAIN");
vector<key_ctr_domain> vect_domain_id;
vector<val_ctr_domain> vect_val_ctr_domain;
void_val_struct = val_struct[0];
}
// Get read response from database
- UpplReturnCode read_status = ReadDomainValFromDB(key_struct,
+ UpplReturnCode read_status = ReadDomainValFromDB(db_conn, key_struct,
void_val_struct,
data_type,
operation_type,
vect_domain_id);
key_val.clear();
val_struct.clear();
- if (read_status != UPPL_RC_SUCCESS) {
- pfc_log_info("ReadValFromDB returned %d with response size %d",
- read_status,
- static_cast<int>(vect_val_ctr_domain_st.size()));
- } else {
+ pfc_log_info("ReadDomainValFromDB returned %d with response size %d",
+ read_status,
+ static_cast<int>(vect_val_ctr_domain_st.size()));
+ if (read_status == UPPL_RC_SUCCESS) {
pfc_log_debug("Read operation is success");
for (unsigned int iIndex = 0 ; iIndex < vect_val_ctr_domain_st.size();
++iIndex) {
return read_status;
}
-/**ReadBulk
- * * @Description : This function reads bulk rows of KT_Domain in
- * Domain table of specified data type.
- ** @param[in] :
- * key_struct - the key for the kt Domain instance
- * data_type - UNC_DT_* , read allowed in candidate/running/startup/state
- * option1/option2 - specifies any additional condition for read operation
- * max_rep_ct - specifies number of rows to be returned
- * parent_call - indicates whether parent has called this readbulk
- * is_read_next - indicates whether this function is invoked from readnext
- * * @return : UPPL_RC_SUCCESS is returned when the response
- * is added to ipc session successfully.
- * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
- * */
-UpplReturnCode Kt_Ctr_Domain::ReadBulk(void* key_struct,
+/**
+ * @Description : This function reads bulk rows of KT_Domain in
+ * Domain table of specified data type.
+ * @param[in] : key_struct - the key for the kt Domain instance
+ * data_type - UNC_DT_* , read allowed in
+ * candidate/running/startup/state
+ * max_rep_ct - specifies number of rows to be returned
+ * parent_call - indicates whether parent has called this
+ * readbulk
+ * is_read_next - indicates whether this function is invoked
+ * from readnext
+ * @return : UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be
+ * added to sess.
+ **/
+UpplReturnCode Kt_Ctr_Domain::ReadBulk(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
- uint32_t option1,
- uint32_t option2,
uint32_t &max_rep_ct,
int child_index,
pfc_bool_t parent_call,
- pfc_bool_t is_read_next) {
+ pfc_bool_t is_read_next,
+ ReadRequest *read_req) {
pfc_log_info("Processing ReadBulk of Kt_Domain");
key_ctr_domain obj_key_ctr_domain=
*(reinterpret_cast<key_ctr_domain*>(key_struct));
unc_keytype_ctrtype_t controller_type = UNC_CT_UNKNOWN;
pfc_bool_t invalid_parent = false;
UpplReturnCode retcode = PhyUtil::get_controller_type(
- str_controller_name, controller_type,
+ db_conn, str_controller_name, controller_type,
(unc_keytype_datatype_t)data_type);
if (retcode != UPPL_RC_SUCCESS) {
pfc_log_error("Error getting the controller type");
vect_key_value.push_back(str_controller_name);
vect_key_value.push_back(str_domain_name);
UpplReturnCode key_exist_status = IsKeyExists(
- (unc_keytype_datatype_t)data_type,
+ db_conn, (unc_keytype_datatype_t)data_type,
vect_key_value);
if (key_exist_status == UPPL_RC_SUCCESS) {
domain_exists = PFC_TRUE;
}
}
// Read the domain values based on given key structure
- read_status = ReadBulkInternal(key_struct,
+ read_status = ReadBulkInternal(db_conn, key_struct,
data_type,
max_rep_ct,
vect_val_ctr_domain_st,
pfc_log_debug("read status from Kt_Ctr_Domain is %d", read_status);
if (invalid_parent == false && (read_status == UPPL_RC_SUCCESS ||
domain_exists == PFC_TRUE)) {
- PhysicalCore *physical_core = PhysicalLayer::get_instance()->
- get_physical_core();
- InternalTransactionCoordinator *itc_trans =
- physical_core->get_internal_transaction_coordinator();
// For each domain, read the child's attributes
vector<val_ctr_domain_st> ::iterator vect_iter =
vect_val_ctr_domain_st.begin();
UNC_KT_CTR_DOMAIN, IS_KEY,
reinterpret_cast<void *>(key_buffer)
};
- itc_trans->AddToBuffer(obj_key_buffer);
+ read_req->AddToBuffer(obj_key_buffer);
if ((unc_keytype_datatype_t)data_type == UNC_DT_STATE) {
val_ctr_domain_st_t *val_buffer =
new val_ctr_domain_st_t(*vect_iter);
UNC_KT_CTR_DOMAIN, IS_STATE_VALUE,
reinterpret_cast<void *>(val_buffer)
};
- itc_trans->AddToBuffer(obj_value_buffer);
+ read_req->AddToBuffer(obj_value_buffer);
} else {
val_ctr_domain_t *val_buffer =
new val_ctr_domain_t((*vect_iter).domain);
UNC_KT_CTR_DOMAIN, IS_VALUE,
reinterpret_cast<void *>(val_buffer)
};
- itc_trans->AddToBuffer(obj_value_buffer);
+ read_req->AddToBuffer(obj_value_buffer);
}
BulkReadBuffer obj_sep_buffer = {
UNC_KT_CTR_DOMAIN, IS_SEPARATOR, NULL
};
- itc_trans->AddToBuffer(obj_sep_buffer);
+ read_req->AddToBuffer(obj_sep_buffer);
--max_rep_ct;
if (max_rep_ct == 0) {
pfc_log_debug("CtrDomain - max_rep_ct reached zero...");
pfc_log_debug("child_index %d", child_index);
str_domain_name =
reinterpret_cast<char *>((*domain_iter).domain_name);
- int st_child_index =
+ int st_child_index = KIdxLogicalPort;
+/*
(child_index >= 0 && child_index <= KIdxLogicalPort) \
? child_index+1 : KIdxLogicalPort;
+*/
pfc_log_debug("st_child_index %d", st_child_index);
for (int kIdx = st_child_index; kIdx <= KIdxLogicalPort; ++kIdx) {
pfc_log_debug("Domain Iterating child %d", kIdx);
}
pfc_log_debug("Domain = Calling child %d read bulk", kIdx);
UpplReturnCode ch_read_status = child[kIdx]->ReadBulk(
- child_key_struct,
+ db_conn, child_key_struct,
data_type,
- option1,
- option2,
max_rep_ct,
-1,
true,
- is_read_next);
+ is_read_next,
+ read_req);
pfc_log_debug("read status from child %d is %d",
kIdx, ch_read_status);
delete child[kIdx];
// reset child index
child_index = -1;
}
+ } else if (read_status == UPPL_RC_ERR_DB_ACCESS) {
+ pfc_log_debug("KtCtrDomain ReadBulk - Returning DB Access Error");
+ return read_status;
}
} else if (max_rep_ct == 0) {
return UPPL_RC_SUCCESS;
str_controller_name.c_str(),
str_controller_name.length()+1);
read_status = nextKin.ReadBulk(
- reinterpret_cast<void *>(&nextkin_key_struct),
+ db_conn, reinterpret_cast<void *>(&nextkin_key_struct),
data_type,
- option1,
- option2,
max_rep_ct,
0,
false,
- is_read_next);
+ is_read_next,
+ read_req);
pfc_log_debug("read status from Kt_Controller kin is %d", read_status);
return UPPL_RC_SUCCESS;
}
return UPPL_RC_SUCCESS;
}
-/**ReadBulkInternal
- * * @Description : This function reads bulk rows of KT_Domain in
- * Domain table of specified data type.
- * * @param[in] :
- * key_struct - the key for the kt Domain instance
- * val_struct - the value struct for kt_Domain instance
- * max_rep_ct - specifies number of rows to be returned
- * vect_val_ctr_domain - indicates the fetched values from db of val_ctr_domain
- * type
- * vect_domain_id - indicates the fetched domain names from db
- * * @return : UPPL_RC_SUCCESS is returned when the response
- * is added to ipc session successfully.
- * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
- * */
+/**
+ * @Description : This function reads bulk rows of KT_Domain in
+ * Domain table of specified data type.
+ * @param[in] : key_struct - the key for the kt Domain instance
+ * val_struct - the value struct for kt_Domain instance
+ * max_rep_ct - specifies number of rows to be returned
+ * vect_val_ctr_domain - indicates the fetched values from db of
+ * val_ctr_domain type
+ * vect_domain_id - indicates the fetched domain names from db
+ * @return : UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be
+ * added to sess.
+ **/
UpplReturnCode Kt_Ctr_Domain::ReadBulkInternal(
+ OdbcmConnectionHandler *db_conn,
void* key_struct,
uint32_t data_type,
uint32_t max_rep_ct,
// Populate DBSchema for ctr_domain_table
void *old_val_struct;
vector<ODBCMOperator> vect_key_operations;
- PopulateDBSchemaForKtTable(kt_ctr_domain_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_ctr_domain_dbtableschema,
key_struct,
val_struct,
- UNC_OP_READ_BULK, 0, 0,
+ UNC_OP_READ_BULK, data_type, 0, 0,
vect_key_operations, old_val_struct);
// Read rows from DB
read_db_status = physical_layer->get_odbc_manager()-> \
GetBulkRows((unc_keytype_datatype_t)data_type, max_rep_ct,
kt_ctr_domain_dbtableschema,
- (unc_keytype_operation_t)UNC_OP_READ_BULK);
+ (unc_keytype_operation_t)UNC_OP_READ_BULK, db_conn);
if (read_db_status == ODBCM_RC_RECORD_NOT_FOUND) {
pfc_log_debug("No record found");
read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
return read_status;
+ } else if (read_db_status == ODBCM_RC_CONNECTION_ERROR) {
+ read_status = UPPL_RC_ERR_DB_ACCESS;
+ pfc_log_error("Read operation has failed with error %d", read_db_status);
+ return read_status;
} else if (read_db_status != ODBCM_RC_SUCCESS) {
read_status = UPPL_RC_ERR_DB_GET;
// log error to log daemon
return read_status;
}
// From the values received from DB, populate val_ctr_domain structure
- FillDomainValueStructure(kt_ctr_domain_dbtableschema,
+ FillDomainValueStructure(db_conn, kt_ctr_domain_dbtableschema,
vect_val_ctr_domain_st,
max_rep_ct,
UNC_OP_READ_BULK,
return read_status;
}
-/** PerformSyntaxValidation
- * * @Description : This function performs syntax validation for
- * UNC_KT_DOMAIN
- * * * @param[in]
- * key_struct - the key for the kt Domain instance
- * value_struct - the value for the kt Domain instance
- * data_type - UNC_DT_*
- * operation_type - UNC_OP*
- * * @return : UPPL_RC_SUCCESS is returned when the validation is successful
- * UPPL_RC_ERR_* is returned when validtion is failure
- * */
-UpplReturnCode Kt_Ctr_Domain::PerformSyntaxValidation(void* key_struct,
- void* val_struct,
- uint32_t operation,
- uint32_t data_type) {
+/**
+ * @Description : This function performs syntax validation for UNC_KT_DOMAIN
+ * @param[in] : key_struct - the key for the kt Domain instance
+ * value_struct - the value for the kt Domain instance
+ * data_type - UNC_DT_* - indicates the data base type
+ * operation_type - UNC_OP* - indicates the operation type
+ * @return : UPPL_RC_SUCCESS is returned when the validation is successful
+ * UPPL_RC_ERR_* is returned when validation is failure
+ **/
+UpplReturnCode Kt_Ctr_Domain::PerformSyntaxValidation(
+ OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ void* val_struct,
+ uint32_t operation,
+ uint32_t data_type) {
pfc_log_info("Syntax Validation of KT_CTR_DOMAIN");
UpplReturnCode ret_code = UPPL_RC_SUCCESS;
pfc_bool_t mandatory = PFC_TRUE;
// Validate key structure
key_ctr_domain *key = reinterpret_cast<key_ctr_domain_t*>(key_struct);
string domain_name = reinterpret_cast<char*>(key->domain_name);
- IS_VALID_STRING_KEY(DOMAIN_NAME, domain_name, operation, ret_code, mandatory);
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map =
+ attr_syntax_map_all[UNC_KT_CTR_DOMAIN];
+ IS_VALID_STRING_KEY(DOMAIN_NAME_STR, domain_name, operation, ret_code,
+ mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
string value = reinterpret_cast<char*>(key->ctr_key.controller_name);
- IS_VALID_STRING_KEY(CTR_NAME, value, operation, ret_code, mandatory);
+ IS_VALID_STRING_KEY(CTR_NAME_STR, value, operation, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
// Validate value structure
- if (val_struct != NULL) {
- unsigned int valid_val = 0;
-
- // validate type
- val_ctr_domain *domain_value =
- reinterpret_cast<val_ctr_domain_t*>(val_struct);
- valid_val = PhyUtil::uint8touint(domain_value->valid[kIdxDomainType]);
- IS_VALID_INT_VALUE(DOMAIN_TYPE, domain_value->type, operation,
- valid_val, ret_code, mandatory);
- if (ret_code != UPPL_RC_SUCCESS) {
- return UPPL_RC_ERR_CFG_SYNTAX;
- }
- if (data_type == UNC_DT_CANDIDATE) {
- if (operation == UNC_OP_CREATE) {
- if (domain_value->type != UPPL_DOMAIN_TYPE_NORMAL) {
- pfc_log_info(
- "Only normal controller domain can be created from northbound");
- return UPPL_RC_ERR_CFG_SYNTAX;
- }
- if (domain_name == DEFAULT_DOMAIN) {
- pfc_log_info("Default Domain name cannot be used");
- return UPPL_RC_ERR_CFG_SYNTAX;
- }
+ if (val_struct == NULL) {
+ return ret_code;
+ }
+ unsigned int valid_val = 0;
+
+ // validate type
+ val_ctr_domain *domain_value =
+ reinterpret_cast<val_ctr_domain_t*>(val_struct);
+ valid_val = PhyUtil::uint8touint(domain_value->valid[kIdxDomainType]);
+ IS_VALID_INT_VALUE(DOMAIN_TYPE_STR, domain_value->type, operation,
+ valid_val, ret_code, mandatory);
+ if (ret_code != UPPL_RC_SUCCESS) {
+ return UPPL_RC_ERR_CFG_SYNTAX;
+ }
+ if (data_type == UNC_DT_CANDIDATE) {
+ if (operation == UNC_OP_CREATE) {
+ if (domain_value->type != UPPL_DOMAIN_TYPE_NORMAL) {
+ pfc_log_info(
+ "Only normal controller domain can be created from northbound");
+ return UPPL_RC_ERR_CFG_SYNTAX;
}
- if (operation == UNC_OP_UPDATE) {
- if (valid_val == UNC_VF_VALID) {
- pfc_log_info("Domain type cannot be modified from northbound");
- return UPPL_RC_ERR_CFG_SYNTAX;
- }
+ if (domain_name == DEFAULT_DOMAIN) {
+ pfc_log_info("Default Domain name cannot be used");
+ return UPPL_RC_ERR_CFG_SYNTAX;
}
}
- // validate description
- valid_val =
- PhyUtil::uint8touint(domain_value->valid[kIdxDomainDescription]);
- string value = reinterpret_cast<char*>(domain_value->description);
- IS_VALID_STRING_VALUE(DOMAIN_DESCRIPTION, value, operation,
- valid_val, ret_code, mandatory);
- if (ret_code != UPPL_RC_SUCCESS) {
- return UPPL_RC_ERR_CFG_SYNTAX;
+ if (operation == UNC_OP_UPDATE) {
+ if (valid_val == UNC_VF_VALID) {
+ pfc_log_info("Domain type cannot be modified from northbound");
+ return UPPL_RC_ERR_CFG_SYNTAX;
+ }
}
}
+ // validate description
+ valid_val =
+ PhyUtil::uint8touint(domain_value->valid[kIdxDomainDescription]);
+ value = reinterpret_cast<char*>(domain_value->description);
+ IS_VALID_STRING_VALUE(DOMAIN_DESCRIPTION_STR, value, operation,
+ valid_val, ret_code, mandatory);
+ if (ret_code != UPPL_RC_SUCCESS) {
+ return UPPL_RC_ERR_CFG_SYNTAX;
+ }
return ret_code;
}
-/** PerformSemanticValidation
- * * @Description : This function performs semantic validation
- * for UNC_KT_DOMAIN
- * * * @param[in] : key_struct - specifies key instance of KT_DOMAIN
- * , value_struct - specifies value of KT_DOMAIN
- * operation - UNC_OP*
- * data_type - UNC_DT*
- * * * @return : UPPL_RC_SUCCESS if semantic valition is successful
- * or UPPL_RC_ERR_* if failed
- * */
-UpplReturnCode Kt_Ctr_Domain::PerformSemanticValidation(void* key_struct,
- void* val_struct,
- uint32_t operation,
- uint32_t data_type) {
+/**
+ * @Description : This function performs semantic validation for UNC_KT_DOMAIN
+ * @param[in] : key_struct - specifies key instance of KT_DOMAIN
+ * val_struct - specifies value of KT_DOMAIN
+ * operation - UNC_OP* - indicates the operation type
+ * data_type - UNC_DT* - indicates the data base type
+ * @return : UPPL_RC_SUCCESS if semantic valition is successful
+ * or UPPL_RC_ERR_* if failed
+ **/
+UpplReturnCode Kt_Ctr_Domain::PerformSemanticValidation(
+ OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ void* val_struct,
+ uint32_t operation,
+ uint32_t data_type) {
UpplReturnCode status = UPPL_RC_SUCCESS;
pfc_log_debug("Inside PerformSemanticValidation of KT_CTR_DOMAIN");
// Check whether the given instance of domain exists in DB
vector<string> domain_vect_key_value;
domain_vect_key_value.push_back(controller_name);
domain_vect_key_value.push_back(domain_name);
- UpplReturnCode key_status = IsKeyExists((unc_keytype_datatype_t)data_type,
+ UpplReturnCode key_status = IsKeyExists(db_conn,
+ (unc_keytype_datatype_t)data_type,
domain_vect_key_value);
pfc_log_debug("IsKeyExists status %d", key_status);
// In case of create operation, key should not exist
parent_data_type = UNC_DT_RUNNING;
}
UpplReturnCode parent_key_status = KtObj.IsKeyExists(
+ db_conn,
(unc_keytype_datatype_t)parent_data_type, parent_vect_key_value);
pfc_log_debug("Parent IsKeyExists status %d", parent_key_status);
if (parent_key_status != UPPL_RC_SUCCESS) {
return status;
}
-/** HandleDriverAlarms
- * * @Description : This function processes the alarm notification
- * received from driver
- * * * @param[in] : alarm type - contains type to indicate PATH_FAULT alarm
- * operation - contains UNC_OP_CREATE or UNC_OP_DELETE\
- * key_struct - indicates the key instance of KT_DOMAIN
- * value_struct - indicates the alarm values structure
- * * * @return : UPPL_RC_SUCCESS if alarm is handled successfully or
- * UPPL_RC_ERR*
- * */
-UpplReturnCode Kt_Ctr_Domain::HandleDriverAlarms(uint32_t data_type,
- uint32_t alarm_type,
- uint32_t oper_type,
- void* key_struct,
- void* val_struct) {
+/**
+ * @Description : This function processes the alarm notification received
+ * from driver
+ * @param[in] : data_type - indicates the data base type
+ * alarm type - contains type to indicate PATH_FAULT alarm
+ * oper_type - operation - contains UNC_OP_CREATE or
+ * UNC_OP_DELETE
+ * key_struct - indicates the key instance of KT_DOMAIN
+ * value_struct - indicates the alarm values structure
+ * @return : UPPL_RC_SUCCESS if alarm is handled successfully or
+ * UPPL_RC_ERR* if incase of failure
+ **/
+UpplReturnCode Kt_Ctr_Domain::HandleDriverAlarms(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ uint32_t alarm_type,
+ uint32_t oper_type,
+ void* key_struct,
+ void* val_struct) {
UpplReturnCode status = UPPL_RC_SUCCESS;
if (alarm_type != UNC_COREDOMAIN_SPLIT) {
pfc_log_warn("%d alarm received for domain is ignored", alarm_type);
return status;
}
uint8_t oper_status_db = 0;
- UpplReturnCode read_status = GetOperStatus(data_type,
+ UpplReturnCode read_status = GetOperStatus(db_conn, data_type,
key_struct,
oper_status_db);
if (read_status != UPPL_RC_SUCCESS) {
pfc_log_info("New Oper_status to be set is: %d", new_oper_status);
if (new_oper_status != old_oper_status) {
// Set oper_status update in DB
- status = SetOperStatus(data_type, key_struct, new_oper_status);
+ status = SetOperStatus(db_conn, data_type, key_struct, new_oper_status);
pfc_log_info("Update oper_status return: %d", status);
}
return status;
}
/** HandleOperStatus
- * * @Description : This function performs the required actions when oper status
- * changes
- * * * @param[in] : Key and value struct
- * * * @return : Success or associated error code
- * */
-UpplReturnCode Kt_Ctr_Domain::HandleOperStatus(uint32_t data_type,
- void *key_struct,
- void *value_struct) {
+ * @Description : This function performs the required actions when
+ * oper status changes
+ * @param[in] : data_type - indicates the data base type
+ * key_struct - indicates the key instance of KT_DOMAIN
+ * value_struct - indicates the value structure of KT_DOMAIN
+ * @return : UPPL_RC_SUCCESS - if oper status update in DB is successful
+ * else UPPL_RC_ERR_* is returned
+ **/
+UpplReturnCode Kt_Ctr_Domain::HandleOperStatus(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ void *key_struct,
+ void *value_struct) {
UpplReturnCode return_code = UPPL_RC_SUCCESS;
if (key_struct != NULL) {
UpplDomainOperStatus domain_oper_status = UPPL_CTR_DOMAIN_OPER_UNKNOWN;
Kt_Controller controller;
UpplReturnCode read_status = controller.GetOperStatus(
- data_type, reinterpret_cast<void*>(&ctr_key), ctrl_oper_status);
+ db_conn, data_type, reinterpret_cast<void*>(&ctr_key),
+ ctrl_oper_status);
if (read_status == UPPL_RC_SUCCESS) {
pfc_log_info("Controller's oper_status %d", ctrl_oper_status);
if (ctrl_oper_status ==
pfc_log_info("Controller's oper_status read returned failure");
}
// Update oper_status in domain table
- return_code = SetOperStatus(data_type, key_struct,
- domain_oper_status, true);
+ return_code = SetOperStatus(db_conn, data_type, key_struct,
+ domain_oper_status);
pfc_log_info("Set Domain oper status status %d", return_code);
} else {
return return_code;
}
-/** InvokeBoundaryNotifyOperStatus
- * * @Description : This function invokes the notifyoperstatus of boundary
- * * * @param[in] : Key and value struct
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
- * */
-UpplReturnCode Kt_Ctr_Domain::InvokeBoundaryNotifyOperStatus(uint32_t data_type,
- void *key_struct) {
+/**
+ * @Description : This function invokes the notifyoperstatus of boundary
+ * @param[in] : data_type - indicates the data base type
+ * key_struct - indicates the key instance of kt domain
+ * @return : UPPL_RC_SUCCESS -if oper status is handled properly in
+ * boundary
+ * or UPPL_RC_ERR* in case of failure
+ **/
+UpplReturnCode Kt_Ctr_Domain::InvokeBoundaryNotifyOperStatus(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ void *key_struct) {
+ // Get controller and domain oper status
UpplReturnCode return_code = UPPL_RC_SUCCESS;
key_ctr_domain_t *obj_key_ctr_domain =
reinterpret_cast<key_ctr_domain_t*>(key_struct);
(const char*)obj_key_ctr_domain->ctr_key.controller_name;
string domain_name =
(const char*)obj_key_ctr_domain->domain_name;
-
+ vector<OperStatusHolder> ref_oper_status;
+ GET_ADD_CTRL_OPER_STATUS(controller_name);
Kt_Boundary boundary;
val_boundary_t obj_val_boundary1;
+ memset(&obj_val_boundary1, 0, sizeof(obj_val_boundary1));
memcpy(obj_val_boundary1.controller_name1,
controller_name.c_str(), controller_name.length()+1);
obj_val_boundary1.valid[kIdxBoundaryControllerName1] = UNC_VF_VALID;
domain_name.c_str(), domain_name.length()+1);
obj_val_boundary1.valid[kIdxBoundaryDomainName1] = UNC_VF_VALID;
return_code = boundary.HandleOperStatus(
- data_type, NULL, reinterpret_cast<void *> (&obj_val_boundary1));
+ db_conn,
+ data_type, NULL,
+ reinterpret_cast<void *> (&obj_val_boundary1),
+ ref_oper_status);
pfc_log_info("HandleOperStatus for boundary C1D1 class %d", return_code);
+ val_boundary_t obj_val_boundary2;
+ memset(&obj_val_boundary2, 0, sizeof(obj_val_boundary2));
+ memcpy(obj_val_boundary2.controller_name2,
+ controller_name.c_str(), controller_name.length()+1);
+ obj_val_boundary2.valid[kIdxBoundaryControllerName2] = UNC_VF_VALID;
+ memcpy(obj_val_boundary2.domain_name2,
+ domain_name.c_str(), domain_name.length()+1);
+ obj_val_boundary2.valid[kIdxBoundaryDomainName2] = UNC_VF_VALID;
+ return_code = boundary.HandleOperStatus(
+ db_conn,
+ data_type, NULL,
+ reinterpret_cast<void *> (&obj_val_boundary2),
+ ref_oper_status);
+ pfc_log_info("HandleOperStatus for boundary C2D2 class %d", return_code);
+ ClearOperStatusHolder(ref_oper_status);
return return_code;
}
-/** NotifyOperStatus
- * * @Description : This function performs the notifies other associated
- * key types when oper status changes
- * * * @param[in] : Key and value struct
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
- * */
-UpplReturnCode Kt_Ctr_Domain::NotifyOperStatus(uint32_t data_type,
- void *key_struct,
- void *value_struct) {
- UpplReturnCode return_code = UPPL_RC_SUCCESS;
- key_ctr_domain *obj_key_ctr_domain =
- reinterpret_cast<key_ctr_domain_t*>(key_struct);
- string controller_name =
- (const char*)obj_key_ctr_domain->ctr_key.controller_name;
- string domain_name =
- (const char*)obj_key_ctr_domain->domain_name;
-
- key_logical_port logical_port_key;
- memcpy(logical_port_key.domain_key.ctr_key.controller_name,
- controller_name.c_str(),
- controller_name.length()+1);
- memcpy(logical_port_key.domain_key.domain_name,
- domain_name.c_str(),
- domain_name.length()+1);
- memset(logical_port_key.port_id, '\0', 320);
- Kt_LogicalPort logical_port;
- return_code = logical_port.HandleOperStatus(
- data_type, reinterpret_cast<void *> (&logical_port_key),
- NULL);
- pfc_log_info("HandleOperStatus for logical_port class %d",
- return_code);
-
- // Call UNC_KT_SWITCH
- key_switch_t switch_key;
- memcpy(switch_key.ctr_key.controller_name,
- controller_name.c_str(),
- controller_name.length()+1);
- Kt_Switch switch_class;
- val_switch switch_val;
- memcpy(switch_val.domain_name,
- domain_name.c_str(),
- domain_name.length()+1);
- switch_val.valid[kIdxSwitchDomainName] = UNC_VF_VALID;
- return_code = switch_class.HandleOperStatus(
- data_type, reinterpret_cast<void *> (&switch_key),
- reinterpret_cast<void *> (&switch_val));
- pfc_log_info("HandleOperStatus for switch class %d", return_code);
-
- // Call UNC_KT_BOUNDARY
- return_code = InvokeBoundaryNotifyOperStatus(data_type, key_struct);
- return return_code;
-}
-
-
-/** GetOperStatus
- * * @Description : This function updates the oper status in db
- * * * @param[in] : Key and oper_status
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
- * */
-UpplReturnCode Kt_Ctr_Domain::GetOperStatus(uint32_t data_type,
+/**
+ * @Description : This function updates the oper status in db
+ * @param[in] : data_type - indicates the data base type
+ * key_struct - key instance of KT_DOMAIN
+ * oper_status - reference variable to store the oper status
+ * from DB
+ * @return : UPPL_RC_SUCCESS - if oper status is read successfully else
+ * UPPL_RC_ERR* is returned
+ **/
+UpplReturnCode Kt_Ctr_Domain::GetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
uint8_t &oper_status) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
key_ctr_domain *obj_key_ctr_domain =
reinterpret_cast<key_ctr_domain_t*>(key_struct);
- TableAttrSchema kt_ctr_domain_table_attr_schema;
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
vector<string> vect_prim_keys;
ctr_key.controller_name;
string domain_name = (const char*)obj_key_ctr_domain->domain_name;
if (!controller_name.empty()) {
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
}
- if (!controller_name.empty()) {
- vect_prim_keys.push_back(DOMAIN_NAME);
+ if (!domain_name.empty()) {
+ vect_prim_keys.push_back(DOMAIN_NAME_STR);
}
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- PhyUtil::FillDbSchema(DOMAIN_NAME, domain_name,
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_NAME, domain_name,
domain_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
string oper_value;
- PhyUtil::FillDbSchema(DOMAIN_OP_STATUS, oper_value,
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_OP_STATUS, oper_value,
oper_value.length(), DATATYPE_UINT16,
vect_table_attr_schema);
DBTableSchema kt_ctr_domain_dbtableschema;
- kt_ctr_domain_dbtableschema.set_table_name(UPPL_CTR_DOMAIN_TABLE);
+ kt_ctr_domain_dbtableschema.set_table_name(unc::uppl::CTR_DOMAIN_TABLE);
kt_ctr_domain_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_ctr_domain_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS read_db_status =
physical_layer->get_odbc_manager()->GetOneRow(
(unc_keytype_datatype_t)data_type,
- kt_ctr_domain_dbtableschema);
- if (read_db_status != ODBCM_RC_SUCCESS) {
+ kt_ctr_domain_dbtableschema, db_conn);
+ if (read_db_status != ODBCM_RC_SUCCESS &&
+ read_db_status != ODBCM_RC_RECORD_NOT_FOUND) {
// log error
pfc_log_error("oper_status read operation failed");
return UPPL_RC_ERR_DB_GET;
}
// read the oper_status value
- list < vector<TableAttrSchema> > res_domain_row_list =
+ list < vector<TableAttrSchema> >& res_domain_row_list =
kt_ctr_domain_dbtableschema.get_row_list();
list < vector<TableAttrSchema> > :: iterator res_domain_iter =
res_domain_row_list.begin();
- // populate IPC value structure based on the response recevied from DB
+ // populate IPC value structure based on the response received from DB
for (; res_domain_iter!= res_domain_row_list.end(); ++res_domain_iter) {
vector<TableAttrSchema> res_ctr_domain_table_attr_schema =
(*res_domain_iter);
++vect_domain_iter) {
// populate values from ctr_domain_table
TableAttrSchema tab_schema = (*vect_domain_iter);
- string attr_name = tab_schema.table_attribute_name;
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
string attr_value;
- if (attr_name == "oper_status") {
+ if (attr_name == unc::uppl::DOMAIN_OP_STATUS) {
PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
DATATYPE_UINT16);
oper_status = atoi(attr_value.c_str());
return UPPL_RC_SUCCESS;
}
-/** SetOperStatus
- * * @Description : This function updates the oper status in db
- * * * @param[in] : Key and oper_status
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
- * */
-UpplReturnCode Kt_Ctr_Domain::SetOperStatus(uint32_t data_type,
+/**
+ * @Description : This function updates the oper status in db
+ * @param[in] : data_type - indicates the data base type
+ * key_struct - key instance of kt domain
+ * oper_status - oper status value to be updated in DB
+ * @return : UPPL_RC_SUCCESS - if the oper status is updation in db is
+ * success or UPPL_RC_ERR*
+ **/
+UpplReturnCode Kt_Ctr_Domain::SetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
- UpplDomainOperStatus oper_status,
- bool is_single_key) {
+ UpplDomainOperStatus oper_status) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
key_ctr_domain *obj_key_ctr_domain=
reinterpret_cast<key_ctr_domain_t*>(key_struct);
- TableAttrSchema kt_ctr_domain_table_attr_schema;
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
string controller_name = (const char*)obj_key_ctr_domain->
ctr_key.controller_name;
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- if (is_single_key == false) {
- vect_prim_keys.push_back(DOMAIN_NAME);
- string domain_name = (const char*)obj_key_ctr_domain->domain_name;
- PhyUtil::FillDbSchema(DOMAIN_NAME, domain_name,
+ string domain_name = (const char*)obj_key_ctr_domain->domain_name;
+ if (!domain_name.empty()) {
+ vect_prim_keys.push_back(DOMAIN_NAME_STR);
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_NAME, domain_name,
domain_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
}
string oper_value = PhyUtil::uint8tostr(oper_status);
- PhyUtil::FillDbSchema(DOMAIN_OP_STATUS, oper_value,
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_OP_STATUS, oper_value,
oper_value.length(), DATATYPE_UINT16,
vect_table_attr_schema);
DBTableSchema kt_ctr_domain_dbtableschema;
- kt_ctr_domain_dbtableschema.set_table_name(UPPL_CTR_DOMAIN_TABLE);
+ kt_ctr_domain_dbtableschema.set_table_name(unc::uppl::CTR_DOMAIN_TABLE);
kt_ctr_domain_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_ctr_domain_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS update_db_status =
physical_layer->get_odbc_manager()->UpdateOneRow(
(unc_keytype_datatype_t)data_type,
- kt_ctr_domain_dbtableschema);
- if (update_db_status != ODBCM_RC_SUCCESS) {
+ kt_ctr_domain_dbtableschema, db_conn);
+ if (update_db_status == ODBCM_RC_ROW_NOT_EXISTS) {
+ pfc_log_info("No instance available for update");
+ } else if (update_db_status != ODBCM_RC_SUCCESS) {
// log error
pfc_log_error("oper_status update operation failed");
return UPPL_RC_ERR_DB_UPDATE;
} else {
// Notify operstatus change to northbound
- val_ctr_domain_st old_val_ctr_domain, new_val_ctr_domain;
uint8_t old_oper_status = 0;
- UpplReturnCode read_status = GetOperStatus(data_type,
+ UpplReturnCode read_status = GetOperStatus(db_conn, data_type,
key_struct,
old_oper_status);
if (read_status == UPPL_RC_SUCCESS && data_type != UNC_DT_IMPORT) {
- memset(old_val_ctr_domain.valid, 0, 2);
+ val_ctr_domain_st old_val_ctr_domain, new_val_ctr_domain;
+ memset(&old_val_ctr_domain, 0, sizeof(old_val_ctr_domain));
+ memset(&new_val_ctr_domain, 0, sizeof(new_val_ctr_domain));
old_val_ctr_domain.oper_status = old_oper_status;
old_val_ctr_domain.valid[kIdxDomainStOperStatus] = UNC_VF_VALID;
- memset(new_val_ctr_domain.valid, 0, 2);
new_val_ctr_domain.oper_status = oper_status;
new_val_ctr_domain.valid[kIdxDomainStOperStatus] = UNC_VF_VALID;
int err = 0;
// Send notification to Northbound
ServerEvent ser_evt((pfc_ipcevtype_t)UPPL_EVENTS_KT_CTR_DOMAIN, err);
- ser_evt.addOutput((uint32_t)UNC_OP_UPDATE);
- ser_evt.addOutput(data_type);
- ser_evt.addOutput((uint32_t)UPPL_EVENTS_KT_CTR_DOMAIN);
- ser_evt.addOutput(*obj_key_ctr_domain);
- ser_evt.addOutput(new_val_ctr_domain);
- ser_evt.addOutput(old_val_ctr_domain);
- PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
- // Notify operstatus modifications
- UpplReturnCode status = (UpplReturnCode) physical_layer
- ->get_ipc_connection_manager()->SendEvent(&ser_evt);
- pfc_log_debug("Event notification status %d", status);
+ northbound_event_header rsh = {UNC_OP_UPDATE,
+ data_type,
+ UNC_KT_CTR_DOMAIN};
+ err = PhyUtil::sessOutNBEventHeader(ser_evt, rsh);
+ err |= ser_evt.addOutput(*obj_key_ctr_domain);
+ err |= ser_evt.addOutput(new_val_ctr_domain);
+ err |= ser_evt.addOutput(old_val_ctr_domain);
+ if (err == 0) {
+ PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
+ // Notify operstatus modifications
+ UpplReturnCode status = (UpplReturnCode) physical_layer
+ ->get_ipc_connection_manager()->SendEvent(&ser_evt);
+ pfc_log_debug("Event notification status %d", status);
+ } else {
+ pfc_log_error("Server Event addOutput failed");
+ }
}
}
return UPPL_RC_SUCCESS;
}
-/** IsKeyExists
- * * @Description : This function checks whether the DOMAIN_id exists in DB
- * * * @param[in] : data type - UNC_DT_*
- * key value - Contains domain_id
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR* based on operation type
- * */
-UpplReturnCode Kt_Ctr_Domain::IsKeyExists(unc_keytype_datatype_t data_type,
- vector<string> key_values) {
+/**
+ * @Description : This function checks whether the DOMAIN_id exists in DB
+ * @param[in] : data type - UNC_DT_* - indicates the data base type
+ * key values - vector of type string to store the primary
+ * key values
+ * @return : UPPL_RC_SUCCESS - incase the row exists in domain table or
+ * UPPL_RC_ERR* is returned
+ **/
+UpplReturnCode Kt_Ctr_Domain::IsKeyExists(OdbcmConnectionHandler *db_conn,
+ unc_keytype_datatype_t data_type,
+ const vector<string> &key_values) {
pfc_log_debug("Inside IsKeyExists");
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode check_status = UPPL_RC_SUCCESS;
// Construct Primary key list
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
- vect_prim_keys.push_back(DOMAIN_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
+ vect_prim_keys.push_back(DOMAIN_NAME_STR);
// Construct TableAttrSchema structure
// TableAttrSchema holds table_name, primary key, attr_name
vector<TableAttrSchema> vect_table_attr_schema;
- TableAttrSchema kt_ctr_domain_table_attr_schema;
list< vector<TableAttrSchema> > row_list;
-
// controller_name
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(),
DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// Domain_name
- PhyUtil::FillDbSchema(DOMAIN_NAME, domain_name,
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_NAME, domain_name,
domain_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- kt_ctr_domain_dbtableschema.set_table_name(UPPL_CTR_DOMAIN_TABLE);
+ kt_ctr_domain_dbtableschema.set_table_name(unc::uppl::CTR_DOMAIN_TABLE);
kt_ctr_domain_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_ctr_domain_dbtableschema.set_row_list(row_list);
// Send request to ODBC for ctr_domain_table
ODBCM_RC_STATUS check_db_status = physical_layer->get_odbc_manager()->\
- IsRowExists(data_type, kt_ctr_domain_dbtableschema);
+ IsRowExists(data_type, kt_ctr_domain_dbtableschema, db_conn);
if (check_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log error to log daemon
pfc_log_error("DB connection not available or cannot access DB");
}
-/** PopulateDBSchemaForKtTable
- * * @Description : This function populates the DBAttrSchema to be used to send
- * request to ODBC
- * * * @param[in] : DBTableSchema, key_struct, val_struct, operation_type
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
- * */
+/**
+ * @Description : This function is used to populate the db schema using the
+ * given key struct, value struct, data_type, operation,
+ * option1 and option
+ * @param[in] : kt_ctr_domain_dbtableschema - object of type DBTableSchema
+ * key_struct - key instance of ctr domain type
+ * val_struct - value structure of ctr domain type
+ * operation_type - specifies the operation type i.e
+ * UNC_OP_READ or UNC_OP_READ_SIBLING_BEGIN etc
+ * option1/option2 - specifies any additional option for
+ * populating in DB
+ * vect_key_operations - vector of type ODBCMOperator
+ * old_value_struct - holds the old value structure of the
+ * ctr domain key type
+ * row_status - enum indicating the row status of controller
+ * domain type entries in db
+ * is_filtering/is_state - bool variables
+ * @return : None
+ **/
+
void Kt_Ctr_Domain::PopulateDBSchemaForKtTable(
+ OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_ctr_domain_dbtableschema,
void* key_struct,
void* val_struct,
uint8_t operation_type,
+ uint32_t data_type,
uint32_t option1,
uint32_t option2,
vector<ODBCMOperator> &vect_key_operations,
pfc_log_debug("Inside PopulateDBSchemaForKtTable for Kt_ctr_domain");
// Construct Primary key list
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
// Construct TableAttrSchema structuree
// TableAttrSchema holds table_name, primary key, attr_name
string controller_name = (const char*)obj_key_ctr_domain->
ctr_key.controller_name;
pfc_log_info("controller name: %s", controller_name.c_str());
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(),
DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
}
pfc_log_info("domain_name: %s", domain_name.c_str());
- PhyUtil::FillDbSchema(DOMAIN_NAME, domain_name,
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_NAME, domain_name,
domain_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
val_ctr_domain_st_t val_ctr_domain_valid_st;
if (operation_type == UNC_OP_UPDATE) {
// get valid array for update req
pfc_log_debug("Get Valid value from Update Valid Flag");
- GetCtrDomainValidFlag(key_struct, val_ctr_domain_valid_st);
+ GetCtrDomainValidFlag(db_conn, key_struct,
+ val_ctr_domain_valid_st, data_type);
}
uint16_t valid_val = 0, prev_db_val = 0;
string value;
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(DOMAIN_TYPE, value,
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_TYPE, DOMAIN_TYPE_STR, value,
value.length(), DATATYPE_UINT16,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(DOMAIN_DESCRIPTION, value,
- value.length(), DATATYPE_UINT8_ARRAY_128,
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_DESCRIPTION, DOMAIN_DESCRIPTION_STR,
+ value, value.length(), DATATYPE_UINT8_ARRAY_128,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
prev_db_val = 0;
value = "1";
}
valid_val = UPPL_NO_VAL_STRUCT;
- // Add oper_status as well if state value structure is passed
- if (is_state == PFC_TRUE) {
+ if (operation_type == UNC_OP_UPDATE && is_state == PFC_TRUE &&
+ obj_val_ctr_domain_st != NULL) {
+ valid_val = PhyUtil::uint8touint(obj_val_ctr_domain_st->
+ valid[kIdxDomainStOperStatus]);
+ value = PhyUtil::uint8tostr(obj_val_ctr_domain_st->oper_status);
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_OP_STATUS, DOMAIN_OP_STATUS_STR,
+ value, value.length(), DATATYPE_UINT16,
+ operation_type, valid_val, prev_db_val,
+ vect_table_attr_schema, vect_prim_keys, valid);
+ } else if (is_state == PFC_TRUE) {
+ // Add oper_status as well if state value structure is passed
valid_val = UNC_VF_VALID;
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_OP_STATUS, DOMAIN_OP_STATUS_STR,
+ value, value.length(), DATATYPE_UINT16,
+ operation_type, valid_val, prev_db_val,
+ vect_table_attr_schema, vect_prim_keys, valid);
+ } else if (operation_type >= UNC_OP_READ) {
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_OP_STATUS, DOMAIN_OP_STATUS_STR,
+ value, value.length(), DATATYPE_UINT16,
+ operation_type, valid_val, prev_db_val,
+ vect_table_attr_schema, vect_prim_keys, valid);
+ } else {
+ valid << UNC_VF_VALID;
}
- PhyUtil::FillDbSchema(DOMAIN_OP_STATUS, value,
- value.length(), DATATYPE_UINT16,
- operation_type, valid_val, prev_db_val,
- vect_table_attr_schema, vect_prim_keys, valid);
stringstream dummy_valid;
valid_val = UPPL_NO_VAL_STRUCT;
// valid
- PhyUtil::FillDbSchema(DOMAIN_VALID, valid.str(),
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_VALID, DOMAIN_VALID_STR, valid.str(),
ODBCM_SIZE_3, DATATYPE_UINT8_ARRAY_3,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, dummy_valid);
for (unsigned int index = 0; index < ODBCM_SIZE_3; ++index) {
attr_status << CREATED;
}
- PhyUtil::FillDbSchema(DOMAIN_CS_ATTR, attr_status.str(),
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_CS_ATTR, attr_status.str(),
ODBCM_SIZE_3, DATATYPE_UINT8_ARRAY_3,
vect_table_attr_schema);
// cs_row status
if (is_filtering == true) {
- vect_prim_keys.push_back(DOMAIN_CS_ROW_STATUS);
+ vect_prim_keys.push_back(DOMAIN_CS_ROW_STATUS_STR);
}
value = PhyUtil::uint8tostr(row_status);
if (operation_type >= UNC_OP_READ) {
- PhyUtil::FillDbSchema(DOMAIN_CS_ROW_STATUS, value,
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_CS_ROW_STATUS, value,
value.length(), DATATYPE_UINT16,
vect_table_attr_schema);
}
- vect_prim_keys.push_back(DOMAIN_NAME);
+ vect_prim_keys.push_back(DOMAIN_NAME_STR);
PhyUtil::reorder_col_attrs(vect_prim_keys, vect_table_attr_schema);
- kt_ctr_domain_dbtableschema.set_table_name(UPPL_CTR_DOMAIN_TABLE);
+ kt_ctr_domain_dbtableschema.set_table_name(unc::uppl::CTR_DOMAIN_TABLE);
kt_ctr_domain_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_ctr_domain_dbtableschema.set_row_list(row_list);
return;
}
-/** PerformRead
- * * @Description : This function reads the instance of kt_ctr_domain based on
- * operation type - READ, READ_SIBLING_BEGIN, READ_SIBLING
- * * * @param[in] : key_struct, value_struct, ipc session id, configuration id,
- * option1, option2, data_type, operation type, max_rep_ct
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
- * */
-UpplReturnCode Kt_Ctr_Domain::PerformRead(uint32_t session_id,
+/**
+ * @Description : This function is used to read KT_CTR_DOMAIN instance in
+ * database table using key_ctr provided in IPC request
+ * The IPC response would be filled in IPC session
+ * @param[in] : ipc session id - ipc session id used for TC validation
+ * configuration id - configuration id used for TC validation
+ * key_struct - key instance of ctr domain
+ * value_struct - value structure instance of ctr domain type
+ * data_type - specifies the data base type i.e UNC_DT_STATE
+ * or UNC_DT_IMPORT
+ * operation type - indicates the operation type
+ * sess - ipc server session where the response has to be added
+ * option1,option2 - specifies any additional condition for
+ * read operation
+ * max_rep_ct - indicates the maximum repetition count
+ * @return : UPPL_RC_SUCCESS - if the read operation is successful
+ * UPPL_RC_ERR_* - read operation failed
+ **/
+UpplReturnCode Kt_Ctr_Domain::PerformRead(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t option1,
uint32_t option2,
uint32_t max_rep_ct) {
- pfc_log_info("Inside PerformRead option1=%d option2=%d max_rep_ct=%d",
- option1, option2, max_rep_ct);
pfc_log_info("Inside PerformRead operation_type=%d data_type=%d",
operation_type, data_type);
key_ctr_domain *obj_key_ctr_domain=
// Read from DB directly for all data types
vector<key_ctr_domain> vect_domain_id;
vector<val_ctr_domain_st> vect_val_ctr_domain_st;
- read_status = ReadDomainValFromDB(key_struct,
+ read_status = ReadDomainValFromDB(db_conn, key_struct,
val_struct,
data_type,
operation_type,
return read_status;
}
-/** ReadDomainValFromDB
- * * @Description : This function reads the instance of kt_ctr_domain based on
- * operation type - READ, READ_SIBLING_BEGIN, READ_SIBLING
- * from data base
- * * * @param[in] : key_struct, value_struct, ipc session id, configuration id,
- * data_type, operation type, max_rep_ct
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
- * */
+/**
+ * @Description : This function is used to read KT_CTR_DOMAIN instance in
+ * database table using key_ctr provided in IPC request and
+ * operation_type
+ * @param[in] : key_struct - key instance of ctr domain
+ * value_struct - value structure of ctr domain type
+ * data_type - indicates the data base type
+ * operation_type - indicates the operation type UNC_OP*
+ * max_rep_ct - indicates the maximum repetition count
+ * vect_val_ctr_domain_st- vector to store the
+ * val_ctr_domain_st_t structure
+ * domain_id - vector of type key_ctr_domain to store the
+ * domain id
+ * @return : UPPL_RC_SUCCESS - read operation is success
+ * UPPL_RC_ERR_DB_GET - read operation is failure
+ **/
UpplReturnCode Kt_Ctr_Domain::ReadDomainValFromDB(
+ OdbcmConnectionHandler *db_conn,
void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t &max_rep_ct,
vector<val_ctr_domain_st> &vect_val_ctr_domain_st,
vector<key_ctr_domain> &domain_id) {
+ if (operation_type < UNC_OP_READ) {
+ // Unsupported operation type for this function
+ return UPPL_RC_SUCCESS;
+ }
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode read_status = UPPL_RC_SUCCESS;
ODBCM_RC_STATUS read_db_status = ODBCM_RC_SUCCESS;
DBTableSchema kt_ctr_domain_dbtableschema;
void *old_val_struct;
vector<ODBCMOperator> vect_key_operations;
- PopulateDBSchemaForKtTable(kt_ctr_domain_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_ctr_domain_dbtableschema,
key_struct,
val_struct,
- operation_type, 0, 0,
+ operation_type, data_type, 0, 0,
vect_key_operations, old_val_struct);
if (operation_type == UNC_OP_READ) {
read_db_status = physical_layer->get_odbc_manager()->
GetOneRow((unc_keytype_datatype_t)data_type,
- kt_ctr_domain_dbtableschema);
+ kt_ctr_domain_dbtableschema, db_conn);
} else {
read_db_status = physical_layer->get_odbc_manager()->
GetBulkRows((unc_keytype_datatype_t)data_type, max_rep_ct,
kt_ctr_domain_dbtableschema,
- (unc_keytype_operation_t)operation_type);
+ (unc_keytype_operation_t)operation_type, db_conn);
}
if (read_db_status == ODBCM_RC_RECORD_NOT_FOUND) {
pfc_log_debug("No record found");
read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
return read_status;
+ } else if (read_db_status == ODBCM_RC_CONNECTION_ERROR) {
+ read_status = UPPL_RC_ERR_DB_ACCESS;
+ pfc_log_error("Read operation has failed with error %d", read_db_status);
+ return read_status;
} else if (read_db_status != ODBCM_RC_SUCCESS) {
read_status = UPPL_RC_ERR_DB_GET;
// log error to log daemon
return read_status;
}
pfc_log_debug("Read operation result: %d", read_status);
- FillDomainValueStructure(kt_ctr_domain_dbtableschema,
+ FillDomainValueStructure(db_conn, kt_ctr_domain_dbtableschema,
vect_val_ctr_domain_st,
max_rep_ct,
operation_type,
return read_status;
}
-/** getChildKeyStruct
- * * @Description : This function returns the void * of child key structures
- * * * @param[in] : child class index and domain name
- * * * @return : void * key structure
- * */
+/**
+ * @Description : This function returns the void * of child key structures
+ * @param[in] : child class index - stores the child class index enum
+ * controller_name - string type to store the controller name
+ * domain name - string type to store the domain name
+ * @return : void * key structure
+ */
void* Kt_Ctr_Domain::getChildKeyStruct(int child_class,
string controller_name,
string domain_name) {
}
}
-/** FreeChildKeyStruct
- * * @Description : This function frees the void * of child key structures
- * * * @param[in] : child class index and void * key_struct
- * * * @return : None
- * */
+/**
+ * @Description : This function frees the void * of child key structures
+ * @param[in] : child class index - stores the child class index enum
+ * key_struct - key instance of the child class Logical port
+ * @return : None
+ **/
void Kt_Ctr_Domain::FreeChildKeyStruct(int child_class,
void *key_struct) {
switch (child_class) {
}
}
-/** FillDomainValueStructure
- * * @Description : This function populates val_ctr_domain by values retrieved
- * from database
- * * * @param[in] : domain common table dbtable schema, openflow domain
- * db schema, value structure and max_rep_ct, operation type
- * * * @return : Filled val_ctr_domain and domain id
- * */
+/**
+ * @Description : This function populates val_ctr_domain by values retrieved
+ * from database
+ * @param[in] : kt_ctr_domain_dbtableschema - object of type DBTableSchema
+ * vect_obj_val_ctr_domain - vector of type val_ctr_domain_st
+ * max_rep_ct - indicates the maximum repetition count
+ * operation_type - indicates the operation type
+ * vect_domain_id - vectpor of type vect_domain_id to store the
+ * domain id
+ * @return : None
+ **/
void Kt_Ctr_Domain::FillDomainValueStructure(
+ OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_ctr_domain_dbtableschema,
vector<val_ctr_domain_st> &vect_obj_val_ctr_domain,
uint32_t &max_rep_ct,
uint32_t operation_type,
vector<key_ctr_domain> &vect_domain_id) {
- // populate IPC value structure based on the response recevied from DB
- list < vector<TableAttrSchema> > res_domain_row_list =
+ // populate IPC value structure based on the response received from DB
+ list < vector<TableAttrSchema> >& res_domain_row_list =
kt_ctr_domain_dbtableschema.get_row_list();
list < vector<TableAttrSchema> > :: iterator res_domain_iter =
res_domain_row_list.begin();
pfc_log_debug("res_domain_row_list.size: %d", max_rep_ct);
key_ctr_domain obj_key_ctr_domain;
- // populate IPC value structure based on the response recevied from DB
+ // populate IPC value structure based on the response received from DB
for (; res_domain_iter != res_domain_row_list.end(); ++res_domain_iter) {
vector<TableAttrSchema> res_ctr_domain_table_attr_schema =
(*res_domain_iter);
++vect_domain_iter) {
// populate values from ctr_domain_table
TableAttrSchema tab_schema = (*vect_domain_iter);
- string attr_name = tab_schema.table_attribute_name;
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
string attr_value;
- if (attr_name == DOMAIN_NAME) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_key_ctr_domain.domain_name,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("domain_name: %s", reinterpret_cast<char *>
- (&obj_key_ctr_domain.domain_name));
- }
- if (attr_name == CTR_NAME) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_key_ctr_domain.ctr_key.controller_name,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("controller_name: %s", reinterpret_cast<char *>
- (&obj_key_ctr_domain.ctr_key.controller_name));
- }
- if (attr_name == DOMAIN_TYPE) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- obj_val_ctr_domain.type = atoi(attr_value.c_str());
- pfc_log_debug("type: %d", obj_val_ctr_domain.type);
- }
- if (attr_name == DOMAIN_DESCRIPTION) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_128);
- memcpy(obj_val_ctr_domain.description,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("description: %s", attr_value.c_str());
- }
- if (attr_name == DOMAIN_OP_STATUS) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- obj_val_ctr_domain_st.oper_status = atoi(attr_value.c_str());
- pfc_log_debug("oper_status: %s", attr_value.c_str());
- }
- if (attr_name == DOMAIN_VALID) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_3);
- memset(obj_val_ctr_domain.valid, 0, 2);
- FrameValidValue(attr_value, obj_val_ctr_domain_st, obj_val_ctr_domain);
- pfc_log_debug("valid: %s", attr_value.c_str());
- }
- if (attr_name == DOMAIN_CS_ATTR) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_3);
- memset(obj_val_ctr_domain.cs_attr, 0, 2);
- FrameCsAttrValue(attr_value, obj_val_ctr_domain);
- pfc_log_debug("cs_attr: %s", attr_value.c_str());
- }
- if (attr_name == DOMAIN_CS_ROW_STATUS) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- obj_val_ctr_domain.cs_row_status = atoi(attr_value.c_str());
- pfc_log_debug("row_status: %s", attr_value.c_str());
+ switch (attr_name) {
+ case unc::uppl::DOMAIN_NAME:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_key_ctr_domain.domain_name,
+ DATATYPE_UINT8_ARRAY_32);
+ pfc_log_debug("domain_name: %s", reinterpret_cast<char *>
+ (&obj_key_ctr_domain.domain_name));
+ break;
+
+ case unc::uppl::CTR_NAME:
+ PhyUtil::GetValueFromDbSchemaStr(
+ tab_schema,
+ obj_key_ctr_domain.ctr_key.controller_name,
+ DATATYPE_UINT8_ARRAY_32);
+ pfc_log_debug("controller_name: %s", reinterpret_cast<char *>
+ (&obj_key_ctr_domain.ctr_key.controller_name));
+ break;
+
+ case unc::uppl::DOMAIN_TYPE:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT16);
+ obj_val_ctr_domain.type = atoi(attr_value.c_str());
+ pfc_log_debug("type: %d", obj_val_ctr_domain.type);
+ break;
+
+ case unc::uppl::DOMAIN_DESCRIPTION:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_val_ctr_domain.description,
+ DATATYPE_UINT8_ARRAY_128);
+ pfc_log_debug("description: %s", attr_value.c_str());
+ break;
+
+ case unc::uppl::DOMAIN_OP_STATUS:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT16);
+ obj_val_ctr_domain_st.oper_status = atoi(attr_value.c_str());
+ pfc_log_debug("oper_status: %s", attr_value.c_str());
+ break;
+
+ case unc::uppl::DOMAIN_VALID:
+ uint8_t dmn_valid[ODBCM_SIZE_3];
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema, dmn_valid,
+ DATATYPE_UINT8_ARRAY_3);
+ memset(obj_val_ctr_domain.valid, 0, 2);
+ FrameValidValue(reinterpret_cast<const char*> (dmn_valid),
+ obj_val_ctr_domain_st,
+ obj_val_ctr_domain);
+ break;
+
+ case unc::uppl::DOMAIN_CS_ATTR:
+ uint8_t dmn_cs_attr[ODBCM_SIZE_3];
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema, dmn_cs_attr,
+ DATATYPE_UINT8_ARRAY_3);
+ memset(obj_val_ctr_domain.cs_attr, 0, 2);
+ FrameCsAttrValue(reinterpret_cast<const char*> (dmn_cs_attr),
+ obj_val_ctr_domain);
+ break;
+
+ case unc::uppl::DOMAIN_CS_ROW_STATUS:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT16);
+ obj_val_ctr_domain.cs_row_status = atoi(attr_value.c_str());
+ pfc_log_debug("row_status: %s", attr_value.c_str());
+ break;
+
+ default:
+ pfc_log_info("Ignoring Domain Attribute %d", attr_name);
+ break;
}
}
obj_val_ctr_domain_st.domain = obj_val_ctr_domain;
return;
}
-/** GetModifiedRows
- * * @Description : This function reads all kt_ctr_domain with given row_status
- * * * @param[in] : key_struct, value_struct, row_status
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
- * */
-UpplReturnCode Kt_Ctr_Domain::GetModifiedRows(vector<void *> &obj_key_struct,
+/**
+ * @Description : This function reads all kt_ctr_domain with given row_status
+ * @param[in] : obj_key_struct - vector to hold the key structure of ctr
+ * domain key type
+ * row_status - indicates the row status to be queried in DB with
+ * @return : UPPL_RC_SUCCESS - if the row exists in DB or UPPL_RC_ERR*
+ * if the row doesn't exists in DB
+ **/
+UpplReturnCode Kt_Ctr_Domain::GetModifiedRows(OdbcmConnectionHandler *db_conn,
+ vector<void *> &obj_key_struct,
CsRowStatus row_status) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
uint32_t max_rep_ct = 0;
DBTableSchema kt_ctr_domain_dbtableschema;
void *old_val_struct;
vector<ODBCMOperator> vect_key_operations;
- PopulateDBSchemaForKtTable(kt_ctr_domain_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_ctr_domain_dbtableschema,
domain_key,
domain_val,
- UNC_OP_READ, 0, 0,
+ UNC_OP_READ, UNC_DT_CANDIDATE, 0, 0,
vect_key_operations, old_val_struct,
row_status,
true);
read_db_status = physical_layer->get_odbc_manager()->
- GetModifiedRows(UNC_DT_CANDIDATE, kt_ctr_domain_dbtableschema);
+ GetModifiedRows(UNC_DT_CANDIDATE, kt_ctr_domain_dbtableschema, db_conn);
if (read_db_status == ODBCM_RC_RECORD_NOT_FOUND) {
pfc_log_debug("No record to read");
}
vector<key_ctr_domain> vect_domain_id;
- FillDomainValueStructure(kt_ctr_domain_dbtableschema,
+ FillDomainValueStructure(db_conn, kt_ctr_domain_dbtableschema,
obj_value_struct,
max_rep_ct,
UNC_OP_READ_BULK,
return read_status;
}
-/** Fill_Attr_Syntax_Map
- * * @Description : This function populates the values to be used for attribute
- * validation
- * * * @param[in] : None
- * * * @return : None
- * */
+/**
+ * @Description : This function populates the values to be used for attribute
+ * validation
+ * @param[in] : None
+ * @return : None
+ **/
void Kt_Ctr_Domain::Fill_Attr_Syntax_Map() {
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map;
Kt_Class_Attr_Syntax objKeyAttrSyntax =
{ PFC_IPCTYPE_UINT8, 0, 0, 1, 32, true, "" };
- attr_syntax_map[DOMAIN_NAME] = objKeyAttrSyntax;
+ attr_syntax_map[DOMAIN_NAME_STR] = objKeyAttrSyntax;
Kt_Class_Attr_Syntax objKeyAttrSyntax1 =
{ PFC_IPCTYPE_UINT8, 0, 0, 1, 32, true, "" };
- attr_syntax_map[CTR_NAME] = objKeyAttrSyntax1;
+ attr_syntax_map[CTR_NAME_STR] = objKeyAttrSyntax1;
Kt_Class_Attr_Syntax objAttrTypeSyntax =
{ PFC_IPCTYPE_UINT8, 0, 1, 0, 0, true, "" };
- attr_syntax_map[DOMAIN_TYPE] = objAttrTypeSyntax;
+ attr_syntax_map[DOMAIN_TYPE_STR] = objAttrTypeSyntax;
Kt_Class_Attr_Syntax objAttrDescSyntax =
{ PFC_IPCTYPE_STRING, 0, 0, 0, 128, false, "" };
- attr_syntax_map[DOMAIN_DESCRIPTION] = objAttrDescSyntax;
+ attr_syntax_map[DOMAIN_DESCRIPTION_STR] = objAttrDescSyntax;
Kt_Class_Attr_Syntax objAttrValidSyntax =
{ PFC_IPCTYPE_STRING, 0, 0, 0, 2, false, "" };
- attr_syntax_map[DOMAIN_VALID] = objAttrValidSyntax;
+ attr_syntax_map[DOMAIN_VALID_STR] = objAttrValidSyntax;
Kt_Class_Attr_Syntax objAttrCsRowSyntax =
{ PFC_IPCTYPE_STRING, 0, 3, 0, 0, false, "" };
- attr_syntax_map[DOMAIN_CS_ROW_STATUS] = objAttrCsRowSyntax;
+ attr_syntax_map[DOMAIN_CS_ROW_STATUS_STR] = objAttrCsRowSyntax;
Kt_Class_Attr_Syntax objAttrCsAttrSyntax =
{ PFC_IPCTYPE_STRING, 0, 0, 1, 2, false, "" };
- attr_syntax_map[DOMAIN_CS_ATTR] = objAttrCsAttrSyntax;
+ attr_syntax_map[DOMAIN_CS_ATTR_STR] = objAttrCsAttrSyntax;
+ attr_syntax_map_all[UNC_KT_CTR_DOMAIN] = attr_syntax_map;
}
-/** GetCtrDomainValidFlag
- * * @Description : This function reads the valid flag from DB
- * * * @param[in] : Key, value struct and newvalid val
- * * * @return : Success or associated error code
- * */
+/**
+ * @Description : This function reads the valid flag from DB
+ * @param[in] : key_struct - key instanc of ctr domain
+ * val_ctr_domain_valid_st - structure variable of type
+ * val_ctr_domain_st_t
+ * @return : UPPL_RC_SUCCESS - if the ctr domain valid flag read is
+ * success else UPPL_RC_ERR_*
+ **/
UpplReturnCode Kt_Ctr_Domain::GetCtrDomainValidFlag(
+ OdbcmConnectionHandler *db_conn,
void *key_struct,
- val_ctr_domain_st_t &val_ctr_domain_valid_st) {
+ val_ctr_domain_st_t &val_ctr_domain_valid_st,
+ uint32_t data_type) {
UpplReturnCode return_code = UPPL_RC_SUCCESS;
vector<void *> vect_key_ctr_domain;
vect_key_ctr_domain.push_back(key_struct);
vector<void *> vect_val_ctr_domain;
- return_code = ReadInternal(vect_key_ctr_domain, vect_val_ctr_domain,
- UNC_DT_CANDIDATE, UNC_OP_READ);
+ return_code = ReadInternal(db_conn, vect_key_ctr_domain, vect_val_ctr_domain,
+ data_type, UNC_OP_READ);
if (return_code == UPPL_RC_SUCCESS) {
val_ctr_domain_st_t *obj_new_ctr_domain_val =
reinterpret_cast<val_ctr_domain_st_t*>(vect_val_ctr_domain[0]);
return return_code;
}
-/** FrameValidValue
- * * @Description : This function converts the string value from db to uint8
- * * * @param[in] : Attribute value and val_ctr_st
- * * * @return : Success or associated error code
- * */
+/**
+ * @Description : This function converts the valid value from db to uint8
+ * @param[in] : attr_value - string to store attribute value
+ * obj_val_ctr_domain_st/obj_val_ctr_domain - struct variables
+ * of the ctr domain val structure
+ * @return : None
+ **/
void Kt_Ctr_Domain::FrameValidValue(string attr_value,
val_ctr_domain_st &obj_val_ctr_domain_st,
val_ctr_domain_t &obj_val_ctr_domain) {
return;
}
-/** FrameCsAttrValue
- * * @Description : This function converts the string value from db to uint8
- * * * @param[in] : Attribute value and val_ctr_st
- * * * @return : Success or associated error code
- * */
+/**
+ * @Description : This function converts the CsAttr value value from db to uint8
+ * @param[in] : attr_value - string to store attribute value
+ * obj_val_ctr_domain - struct variables of the
+ * ctr domain val structure
+ * @return : None
+ **/
void Kt_Ctr_Domain::FrameCsAttrValue(string attr_value,
val_ctr_domain_t &obj_val_ctr_domain) {
for (unsigned int i = 0; i < 2 ; ++i) {
#include "itc_kt_link.hh"
#include "itc_kt_controller.hh"
+#include "itc_read_request.hh"
+#include "odbcm_db_varbind.hh"
using unc::uppl::PhysicalLayer;
/** Constructor
- * * @Description : This function instantiates parent and child key types for
+ * @Description : This function instantiates attr map
* kt_link
- * * * @param[in] : None
- * * * @return : None
+ * @param[in] : None
+ * @return : None
* */
Kt_Link::Kt_Link() {
// Populate structure to be used for syntax validation
- parent = NULL;
- Fill_Attr_Syntax_Map();
+ if (attr_syntax_map_all.find(UNC_KT_LINK) ==
+ attr_syntax_map_all.end()) {
+ Fill_Attr_Syntax_Map();
+ }
}
/** Destructor
- * * @Description : This function clears the parent and child key types
+ * @Description : Empty Destructor
* instances for kt_link
- * * * @param[in] : None
- * * * @return : None
+ * @param[in] : None
+ * @return : None
* */
Kt_Link::~Kt_Link() {
}
/**DeleteKeyInstance
- * * @Description : This function deletes a row of KT_Link in
+ * @Description : This function deletes a row of KT_Link in
* state link table.
- * * @param[in] :
+ * @param[in] :
* key_struct - the key for the new kt link instance
* data_type - UNC_DT_* , delete only allowed in state
- * * @return : UPPL_RC_SUCCESS is returned when the delete
+ * key_type - UNC_KT_LINK,value of unc_key_type_t
+ * @return : UPPL_RC_SUCCESS is returned when the delete
* is done successfully.
* UPPL_RC_ERR_* is returned when the delete is error
* */
-UpplReturnCode Kt_Link::DeleteKeyInstance(void* key_struct,
+UpplReturnCode Kt_Link::DeleteKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
uint32_t key_type) {
UpplReturnCode delete_status = UPPL_RC_SUCCESS;
vector<ODBCMOperator> operator_vector;
// Populate DBSchema for link_table
void* old_value;
- PopulateDBSchemaForKtTable(kt_link_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_link_dbtableschema,
key_struct,
NULL,
- UNC_OP_DELETE,
+ UNC_OP_DELETE, data_type,
UNC_OPT1_NORMAL,
UNC_OPT2_NONE,
operator_vector,
old_value);
ODBCM_RC_STATUS delete_db_status = physical_layer->get_odbc_manager()-> \
DeleteOneRow((unc_keytype_datatype_t)data_type,
- kt_link_dbtableschema);
- pfc_log_info("DeleteOneRow response from DB is %d", delete_db_status);
+ kt_link_dbtableschema, db_conn);
if (delete_db_status != ODBCM_RC_SUCCESS) {
if (delete_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log fatal error to log daemon
}
/** ReadInternal
- * * @Description : This function reads the given instance of KT_Link
- ** * @param[in] : session_id - ipc session id used for TC validation
+ * @Description : This function reads the given instance of KT_Link
+ * @param[in] :
* key_struct - the key for the kt link instance
* value_struct - the value for the kt link instance
* data_type - UNC_DT_* , read allowed in state
- * * @return : UPPL_RC_SUCCESS is returned when the response
+ * operation_type-UNC_OP_*,type of operation
+ * @return : UPPL_RC_SUCCESS is returned when the response
* is added to ipc session successfully.
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_Link::ReadInternal(vector<void *> &key_val,
+UpplReturnCode Kt_Link::ReadInternal(OdbcmConnectionHandler *db_conn,
+ vector<void *> &key_val,
vector<void *> &val_struct,
uint32_t data_type,
uint32_t operation_type) {
void_val_struct = val_struct[0];
}
uint32_t option = 0;
- UpplReturnCode read_status = ReadLinkValFromDB(key_struct,
+ UpplReturnCode read_status = ReadLinkValFromDB(db_conn, key_struct,
void_val_struct,
data_type,
operation_type,
option);
key_val.clear();
val_struct.clear();
- if (read_status != UPPL_RC_SUCCESS) {
- pfc_log_error("Read operation has failed");
- } else {
+ if (read_status == UPPL_RC_SUCCESS) {
pfc_log_debug("Read operation is success");
for (unsigned int iIndex = 0 ; iIndex < vect_val_link_st.size();
++iIndex) {
}
/**ReadBulk
- * * @Description : This function reads bulk rows of KT_Link in
+ * @Description : This function reads bulk rows of KT_Link in
* link table of specified data type.
* Order of ReadBulk response
* val_link -> val_boundary
- * * @param[in] :
+ * @param[in] :
* key_struct - the key for the kt link instance
* data_type - UNC_DT_* , read allowed in state
- * option1/option2 - specifies any additional condition for read operation
* max_rep_ct - specifies number of rows to be returned
* parent_call - indicates whether parent has called this readbulk
* is_read_next - indicates whether this function is invoked from readnext
- * * @return : UPPL_RC_SUCCESS is returned when the response
+ * @return : UPPL_RC_SUCCESS is returned when the response
* is added to ipc session successfully.
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_Link::ReadBulk(void* key_struct,
+UpplReturnCode Kt_Link::ReadBulk(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
- uint32_t option1,
- uint32_t option2,
uint32_t &max_rep_ct,
int child_index,
pfc_bool_t parent_call,
- pfc_bool_t is_read_next) {
+ pfc_bool_t is_read_next,
+ ReadRequest *read_req) {
UpplReturnCode read_status = UPPL_RC_SUCCESS;
key_link_t* obj_key_link=
reinterpret_cast<key_link_t*>(key_struct);
vector<val_link_st_t> vect_val_link_st;
vector<key_link_t> vect_link_id;
// Read the link values based on given key structure
- read_status = ReadBulkInternal(key_struct,
+ read_status = ReadBulkInternal(db_conn, key_struct,
data_type,
max_rep_ct,
vect_val_link_st,
vect_link_id);
pfc_log_debug("read_status from kt_link is %d", read_status);
if (read_status == UPPL_RC_SUCCESS) {
- PhysicalCore *physical_core = PhysicalLayer::get_instance()->
- get_physical_core();
- InternalTransactionCoordinator *itc_trans =
- physical_core->get_internal_transaction_coordinator();
// For each link , read the values
vector<val_link_st_t> ::iterator vect_iter = vect_val_link_st.begin();
vector<key_link_t> ::iterator link_iter = vect_link_id.begin();
UNC_KT_LINK, IS_KEY,
reinterpret_cast<void*>(key_buffer)
};
- itc_trans->AddToBuffer(obj_key_buffer);
+ read_req->AddToBuffer(obj_key_buffer);
val_link_st_t *val_buffer = new val_link_st_t(*vect_iter);
BulkReadBuffer obj_value_buffer = {
UNC_KT_LINK, IS_STATE_VALUE,
reinterpret_cast<void*>(val_buffer)
};
- itc_trans->AddToBuffer(obj_value_buffer);
+ read_req->AddToBuffer(obj_value_buffer);
BulkReadBuffer obj_sep_buffer = {
UNC_KT_LINK, IS_SEPARATOR, NULL
};
- itc_trans->AddToBuffer(obj_sep_buffer);
+ read_req->AddToBuffer(obj_sep_buffer);
--max_rep_ct;
if (max_rep_ct == 0) {
return UPPL_RC_SUCCESS;
}
}
+ } else if (read_status == UPPL_RC_ERR_DB_ACCESS) {
+ pfc_log_debug("Ktlink ReadBulk - Returning DB Access Error");
+ return read_status;
}
if (max_rep_ct >0 && parent_call == false) {
// Filling key_struct corresponding to the key type
str_controller_name.c_str(),
str_controller_name.length() +1);
read_status = nextKin.ReadBulk(
- reinterpret_cast<void *>(&nextkin_key_struct),
+ db_conn, reinterpret_cast<void *>(&nextkin_key_struct),
data_type,
- option1,
- option2,
max_rep_ct,
2,
false,
- is_read_next);
+ is_read_next,
+ read_req);
pfc_log_debug("read_status from next kin Kt_Port is %d", read_status);
return UPPL_RC_SUCCESS;
}
}
/**ReadBulkInternal
- * * @Description : This function reads bulk rows of KT_Link in
+ * @Description : This function reads bulk rows of KT_Link in
* link table of specified data type.
- * * @param[in] :
+ * @param[in] :
* key_struct - the key for the kt link instance
- * val_struct - the value struct for kt_link instance
- * max_rep_ct - specifies number of rows to be returned
+ * data_type-UNC_DT_*,type of database
+ * max_rep_ct- specifies number of rows to be returned
* vect_val_link - indicates the fetched values from db of val_link type
* vect_link_id - indicates the fetched link names from db
- * * @return : UPPL_RC_SUCCESS is returned when the response
+ * @return : UPPL_RC_SUCCESS is returned when the response
* is added to ipc session successfully.
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
UpplReturnCode Kt_Link::ReadBulkInternal(
+ OdbcmConnectionHandler *db_conn,
void* key_struct,
uint32_t data_type,
uint32_t max_rep_ct,
vector<ODBCMOperator> operator_vector;
// Populate DBSchema for link_table
void* old_value;
- PopulateDBSchemaForKtTable(kt_link_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_link_dbtableschema,
key_struct,
val_struct,
- UNC_OP_READ_BULK,
+ UNC_OP_READ_BULK, data_type,
UNC_OPT1_NORMAL,
UNC_OPT2_NONE,
operator_vector,
pfc_log_debug("Multiple query to be sent to DB till we get a match");
no_of_query = 4; // Link has 4 primary keys other than controller
}
- for (uint32_t index = 0; index < no_of_query; ++index) {
+ uint32_t index = 0;
+ for (; index < no_of_query ; ++index) {
+ if (kt_link_dbtableschema.primary_keys_.size() <2) {
+ pfc_log_debug("No record found");
+ read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
+ break;
+ }
// Read rows from DB
read_db_status = physical_layer->get_odbc_manager()-> \
GetBulkRows((unc_keytype_datatype_t)data_type, max_rep_ct,
kt_link_dbtableschema,
- (unc_keytype_operation_t)UNC_OP_READ_BULK);
+ (unc_keytype_operation_t)UNC_OP_READ_BULK, db_conn);
pfc_log_debug("GetBulkRows return: %d", read_db_status);
if (read_db_status == ODBCM_RC_RECORD_NOT_FOUND) {
pfc_log_debug("No record found");
pfc_log_debug(
"Primary key vector size %d",
static_cast<int>(kt_link_dbtableschema.primary_keys_.size()));
- // return read_status;
+ } else if (read_db_status == ODBCM_RC_CONNECTION_ERROR) {
+ read_status = UPPL_RC_ERR_DB_ACCESS;
+ pfc_log_error("Read operation has failed with error %d", read_db_status);
+ break;
} else if (read_db_status == ODBCM_RC_SUCCESS) {
read_status = UPPL_RC_SUCCESS;
pfc_log_debug("Received success response from db");
- break;
+ uint32_t max_rep_ct_new = 0;
+ FillLinkValueStructure(db_conn, kt_link_dbtableschema,
+ vect_val_link_st,
+ max_rep_ct_new,
+ UNC_OP_READ,
+ vect_link_id);
+ pfc_log_debug("max_rep_ct_new=%d max_rep_ct=%d",
+ max_rep_ct_new, max_rep_ct);
+ for (uint32_t uindex = 1; uindex < max_rep_ct_new; uindex++) {
+ pfc_log_debug("Ktlink:Row list Removed");
+ kt_link_dbtableschema.row_list_.pop_front();
+ }
+ max_rep_ct -= max_rep_ct_new;
+
+ kt_link_dbtableschema.primary_keys_.pop_back();
} else {
read_status = UPPL_RC_ERR_DB_GET;
+ break;
}
- }
- if (read_status == UPPL_RC_SUCCESS) {
- // From the values received from DB, populate val_link structure
- FillLinkValueStructure(kt_link_dbtableschema,
- vect_val_link_st,
- max_rep_ct,
- UNC_OP_READ,
- vect_link_id);
- }
+ } // for loop end
+ if (vect_val_link_st.empty() && index == 4) {
+ pfc_log_debug("No record found");
+ read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
+ } else if (!vect_val_link_st.empty()) {
+ read_status = UPPL_RC_SUCCESS;
+ }
+
return read_status;
}
/** PerformSyntaxValidation
- * * @Description : This function performs syntax validation for
+ * @Description : This function performs syntax validation for
* UNC_KT_LINK
- * * * @param[in]
+ * @param[in]
* key_struct - the key for the kt link instance
* value_struct - the value for the kt link instance
- * data_type - UNC_DT_*
- * operation_type - UNC_OP*
- * * @return : UPPL_RC_SUCCESS is returned when the validation is successful
- * UPPL_RC_ERR_* is returned when validtion is failure
+ * data_type - UNC_DT_*,type of database
+ * operation_type - UNC_OP*,type of operation
+ * @return : UPPL_RC_SUCCESS is returned when the validation is successful
+ * UPPL_RC_ERR_* is returned when validation is failure
* */
-UpplReturnCode Kt_Link::PerformSyntaxValidation(void* key_struct,
+UpplReturnCode Kt_Link::PerformSyntaxValidation(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t operation,
uint32_t data_type) {
// Validate key structure
key_link *key = reinterpret_cast<key_link_t*>(key_struct);
string value = reinterpret_cast<char*>(key->ctr_key.controller_name);
- IS_VALID_STRING_KEY(CTR_NAME, value, operation, ret_code, mandatory);
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map =
+ attr_syntax_map_all[UNC_KT_LINK];
+ IS_VALID_STRING_KEY(CTR_NAME_STR, value, operation, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
value = reinterpret_cast<char*>(key->switch_id1);
- IS_VALID_STRING_KEY(LINK_SWITCH_ID1, value, operation, ret_code, mandatory);
+ IS_VALID_STRING_KEY(LINK_SWITCH_ID1_STR, value, operation,
+ ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
value = reinterpret_cast<char*>(key->port_id1);
- IS_VALID_STRING_KEY(LINK_PORT_ID1, value, operation, ret_code, mandatory);
+ IS_VALID_STRING_KEY(LINK_PORT_ID1_STR, value, operation, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
value = reinterpret_cast<char*>(key->switch_id2);
- IS_VALID_STRING_KEY(LINK_SWITCH_ID2, value, operation, ret_code, mandatory);
+ IS_VALID_STRING_KEY(LINK_SWITCH_ID2_STR, value, operation,
+ ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
value = reinterpret_cast<char*>(key->port_id2);
- IS_VALID_STRING_KEY(LINK_PORT_ID2, value, operation, ret_code, mandatory);
+ IS_VALID_STRING_KEY(LINK_PORT_ID2_STR, value, operation, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
val_link *link_value = reinterpret_cast<val_link_t*>(val_struct);
valid_val = PhyUtil::uint8touint(link_value->valid[kIdxLinkDescription]);
string value = reinterpret_cast<char*>(link_value->description);
- IS_VALID_STRING_VALUE(LINK_DESCRIPTION, value, operation,
+ IS_VALID_STRING_VALUE(LINK_DESCRIPTION_STR, value, operation,
valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
/** PerformSemanticValidation
- * * @Description : This function performs semantic validation
+ * @Description : This function performs semantic validation
* for UNC_KT_LINK
- * * * @param[in] : key_struct - specifies key instance of KT_Link
- * , value_struct - specifies value of KT_LINK
- * operation - UNC_OP*
- * data_type - UNC_DT*
- * * * @return : UPPL_RC_SUCCESS if semantic valition is successful
+ * @param[in] : key_struct - specifies key instance of KT_Link
+ * value_struct - specifies value of KT_LINK
+ * operation - UNC_OP*,type of operation
+ * data_type - UNC_DT*,type of database
+ * @return : UPPL_RC_SUCCESS if semantic valition is successful
* or UPPL_RC_ERR_* if failed
* */
-UpplReturnCode Kt_Link::PerformSemanticValidation(void* key_struct,
- void* val_struct,
- uint32_t operation,
- uint32_t data_type) {
+UpplReturnCode Kt_Link::PerformSemanticValidation(
+ OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ void* val_struct,
+ uint32_t operation,
+ uint32_t data_type) {
UpplReturnCode status = UPPL_RC_SUCCESS;
pfc_log_debug("Inside PerformSemanticValidation of KT_LINK");
// Check whether the given instance of link exists in DB
link_vect_key_value.push_back(port_id1);
link_vect_key_value.push_back(switch_id2);
link_vect_key_value.push_back(port_id2);
- UpplReturnCode key_status = IsKeyExists((unc_keytype_datatype_t)data_type,
+ UpplReturnCode key_status = IsKeyExists(db_conn,
+ (unc_keytype_datatype_t)data_type,
link_vect_key_value);
pfc_log_debug("IsKeyExists status %d", key_status);
// In case of Create operation, key should not exist
parent_data_type = UNC_DT_RUNNING;
}
UpplReturnCode parent_key_status = KtObj.IsKeyExists(
- (unc_keytype_datatype_t)parent_data_type, parent_vect_key_value);
+ db_conn, (unc_keytype_datatype_t)parent_data_type,
+ parent_vect_key_value);
pfc_log_debug("Parent IsKeyExists status %d", parent_key_status);
if (parent_key_status != UPPL_RC_SUCCESS) {
status = UPPL_RC_ERR_PARENT_DOES_NOT_EXIST;
}
/** HandleOperStatus
- * * @Description : This function performs the required actions when oper status
+ * @Description : This function performs the required actions when oper status
* changes
- * * * @param[in] : Key and value struct
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
+ * @param[in] : data_type-UNC_DT_*,type of database
+ * key_struct-void* to kt key structure
+ * value_struct-void* to kt value structure
+ * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*,
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_Link::HandleOperStatus(uint32_t data_type,
+UpplReturnCode Kt_Link::HandleOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void *key_struct,
void *value_struct) {
- FN_START_TIME("HandleOperStatus", "Link");
- // PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
- UpplReturnCode return_code = UPPL_RC_SUCCESS;
-
if (key_struct != NULL) {
+ FN_START_TIME("HandleOperStatus", "Link");
key_link_t *obj_key_link =
reinterpret_cast<key_link_t*>(key_struct);
string controller_name = (const char*)obj_key_link->ctr_key.controller_name;
- string switch_id1 = (const char*)obj_key_link->switch_id1;
- string port_id1 = (const char*)obj_key_link->port_id1;
- string switch_id2 = (const char*)obj_key_link->switch_id2;
- string port_id2 = (const char*)obj_key_link->port_id2;
// Get the controller's oper status and decide on the oper_status
key_ctr_t ctr_key;
memcpy(ctr_key.controller_name, controller_name.c_str(),
UpplLinkOperStatus link_oper_status = UPPL_LINK_OPER_UNKNOWN;
Kt_Controller controller;
UpplReturnCode read_status = controller.GetOperStatus(
- data_type, reinterpret_cast<void*>(&ctr_key), ctrl_oper_status);
+ db_conn, data_type, reinterpret_cast<void*>(&ctr_key),
+ ctrl_oper_status);
if (read_status == UPPL_RC_SUCCESS) {
pfc_log_info("Controller's oper_status %d", ctrl_oper_status);
if (ctrl_oper_status ==
pfc_log_info("Controller's oper_status read returned failure");
}
// Update oper_status in link table
- return_code = SetOperStatus(data_type, key_struct,
- link_oper_status, true);
- if (return_code != UPPL_RC_SUCCESS) {
+ read_status = SetOperStatus(db_conn, data_type, key_struct,
+ link_oper_status);
+ if (read_status != UPPL_RC_SUCCESS &&
+ read_status != UPPL_RC_ERR_NO_SUCH_INSTANCE) {
// log error
pfc_log_error("oper_status update operation failed");
FN_END_TIME("HandleOperStatus", "Link");
return UPPL_RC_ERR_DB_ACCESS;
}
+ FN_END_TIME("HandleOperStatus", "Link");
}
- FN_END_TIME("HandleOperStatus", "Link");
return UPPL_RC_SUCCESS;
}
/** SetOperStatus
- * * @Description : This function updates the oper_status value
+ * @Description : This function updates the oper_status value
* of the controller
- * * @param[in] : key_struct
- * * @return : oper_status
+ * @param[in] : key_struct-void* to link key strcuture
+ * data_type-UNC_DT_*,type of database
+ * oper_status-any value of UpplLinkOperStatus
+ * @return : UPPL_RC_SUCCESS/ERR*, UPPL_RC_SUCCESS is returned when the
+ * response is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
*/
-UpplReturnCode Kt_Link::SetOperStatus(uint32_t data_type,
+UpplReturnCode Kt_Link::SetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
- UpplLinkOperStatus oper_status,
- bool is_single_key) {
+ UpplLinkOperStatus oper_status) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
key_link *obj_key_link=
reinterpret_cast<key_link_t*>(key_struct);
- TableAttrSchema kt_link_table_attr_schema;
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
vector<string> vect_prim_keys;
string switch_id2 = (const char*)obj_key_link->switch_id2;
string port_id2 = (const char*)obj_key_link->port_id2;
if (!controller_name.empty()) {
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
}
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- if (is_single_key == false) {
- if (!switch_id1.empty()) {
- vect_prim_keys.push_back(LINK_SWITCH_ID1);
- PhyUtil::FillDbSchema(LINK_SWITCH_ID1, switch_id1,
- switch_id1.length(), DATATYPE_UINT8_ARRAY_256,
- vect_table_attr_schema);
- }
- if (!port_id1.empty()) {
- vect_prim_keys.push_back(LINK_PORT_ID1);
- PhyUtil::FillDbSchema(LINK_PORT_ID1, port_id1,
- port_id1.length(), DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
- }
- if (!switch_id2.empty()) {
- vect_prim_keys.push_back(LINK_SWITCH_ID2);
- PhyUtil::FillDbSchema(LINK_SWITCH_ID2, switch_id2,
- switch_id2.length(), DATATYPE_UINT8_ARRAY_256,
- vect_table_attr_schema);
- }
- if (!port_id2.empty()) {
- vect_prim_keys.push_back(LINK_PORT_ID2);
- PhyUtil::FillDbSchema(LINK_PORT_ID2, port_id2,
- port_id2.length(), DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
- }
+ if (!switch_id1.empty()) {
+ vect_prim_keys.push_back(LINK_SWITCH_ID1_STR);
+ PhyUtil::FillDbSchema(unc::uppl::LINK_SWITCH_ID1, switch_id1,
+ switch_id1.length(), DATATYPE_UINT8_ARRAY_256,
+ vect_table_attr_schema);
+ }
+ if (!port_id1.empty()) {
+ vect_prim_keys.push_back(LINK_PORT_ID1_STR);
+ PhyUtil::FillDbSchema(unc::uppl::LINK_PORT_ID1, port_id1,
+ port_id1.length(), DATATYPE_UINT8_ARRAY_32,
+ vect_table_attr_schema);
+ }
+ if (!switch_id2.empty()) {
+ vect_prim_keys.push_back(LINK_SWITCH_ID2_STR);
+ PhyUtil::FillDbSchema(unc::uppl::LINK_SWITCH_ID2, switch_id2,
+ switch_id2.length(), DATATYPE_UINT8_ARRAY_256,
+ vect_table_attr_schema);
+ }
+ if (!port_id2.empty()) {
+ vect_prim_keys.push_back(LINK_PORT_ID2_STR);
+ PhyUtil::FillDbSchema(unc::uppl::LINK_PORT_ID2, port_id2,
+ port_id2.length(), DATATYPE_UINT8_ARRAY_32,
+ vect_table_attr_schema);
}
string oper_value = PhyUtil::uint8tostr(oper_status);
- PhyUtil::FillDbSchema(LINK_OPER_STATUS, oper_value,
+ PhyUtil::FillDbSchema(unc::uppl::LINK_OPER_STATUS, oper_value,
oper_value.length(), DATATYPE_UINT16,
vect_table_attr_schema);
DBTableSchema kt_link_dbtableschema;
- kt_link_dbtableschema.set_table_name(UPPL_LINK_TABLE);
+ kt_link_dbtableschema.set_table_name(unc::uppl::LINK_TABLE);
kt_link_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_link_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS update_db_status =
physical_layer->get_odbc_manager()->UpdateOneRow(
(unc_keytype_datatype_t)data_type,
- kt_link_dbtableschema);
- if (update_db_status != ODBCM_RC_SUCCESS) {
+ kt_link_dbtableschema, db_conn);
+ if (update_db_status == ODBCM_RC_ROW_NOT_EXISTS) {
+ pfc_log_info("No instance available for update");
+ return UPPL_RC_ERR_NO_SUCH_INSTANCE;
+ } else if (update_db_status != ODBCM_RC_SUCCESS) {
// log error
pfc_log_error("oper_status update operation failed");
return UPPL_RC_ERR_DB_UPDATE;
} else {
// Notify operstatus change to northbound
- val_link_st old_val_link, new_val_link;
uint8_t old_oper_status = 0;
- UpplReturnCode read_status = GetOperStatus(data_type,
+ UpplReturnCode read_status = GetOperStatus(db_conn, data_type,
key_struct,
old_oper_status);
if (read_status == UPPL_RC_SUCCESS) {
- memset(old_val_link.valid, 0, 2);
+ val_link_st old_val_link, new_val_link;
+ memset(&old_val_link, 0, sizeof(old_val_link));
+ memset(&new_val_link, 0, sizeof(new_val_link));
old_val_link.oper_status = old_oper_status;
old_val_link.valid[kIdxLinkStOperStatus] = UNC_VF_VALID;
- memset(new_val_link.valid, 0, 2);
new_val_link.oper_status = oper_status;
new_val_link.valid[kIdxLinkStOperStatus] = UNC_VF_VALID;
int err = 0;
// Send notification to Northbound
ServerEvent ser_evt((pfc_ipcevtype_t)UPPL_EVENTS_KT_LINK, err);
- ser_evt.addOutput((uint32_t)UNC_OP_UPDATE);
- ser_evt.addOutput(data_type);
- ser_evt.addOutput((uint32_t)UPPL_EVENTS_KT_LINK);
- ser_evt.addOutput(*obj_key_link);
- ser_evt.addOutput(new_val_link);
- ser_evt.addOutput(old_val_link);
- PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
- // Notify operstatus modifications
- UpplReturnCode status = (UpplReturnCode) physical_layer
- ->get_ipc_connection_manager()->SendEvent(&ser_evt);
- pfc_log_debug("Event notification status %d", status);
+ northbound_event_header rsh = {UNC_OP_UPDATE,
+ data_type,
+ UNC_KT_LINK};
+ err = PhyUtil::sessOutNBEventHeader(ser_evt, rsh);
+ err |= ser_evt.addOutput(*obj_key_link);
+ err |= ser_evt.addOutput(new_val_link);
+ err |= ser_evt.addOutput(old_val_link);
+ if (err == 0) {
+ PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
+ // Notify operstatus modifications
+ UpplReturnCode status = (UpplReturnCode) physical_layer
+ ->get_ipc_connection_manager()->SendEvent(&ser_evt);
+ pfc_log_debug("Event notification status %d", status);
+ } else {
+ pfc_log_error("Server Event addOutput failed");
+ }
}
}
return UPPL_RC_SUCCESS;
}
/** IsKeyExists
- * * @Description : This function checks whether the link_id exists in DB
- * * * @param[in] : data type - UNC_DT_*
+ * @Description : This function checks whether the link_id exists in DB
+ * @param[in] : data type - UNC_DT_*,type of database
* key value - Contains link_id
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR* based on operation type
+ * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR* based on operation type
* */
-UpplReturnCode Kt_Link::IsKeyExists(unc_keytype_datatype_t data_type,
- vector<string> key_values) {
+UpplReturnCode Kt_Link::IsKeyExists(OdbcmConnectionHandler *db_conn,
+ unc_keytype_datatype_t data_type,
+ const vector<string> &key_values) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
// void* key_struct;
// key_link_t *obj_key_link = reinterpret_cast<key_link_t*>(key_struct);
// construct TableAttrSchema structure
// TableAttrSchema holds table_name, primary key, attr_name
vector<TableAttrSchema> vect_table_attr_schema;
- TableAttrSchema kt_link_table_attr_schema;
list< vector<TableAttrSchema> > row_list;
// Controller_name
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
if (!controller_name.empty()) {
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
}
// switch_id1
- PhyUtil::FillDbSchema(LINK_SWITCH_ID1, switch_id1,
+ PhyUtil::FillDbSchema(unc::uppl::LINK_SWITCH_ID1, switch_id1,
switch_id1.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
if (!switch_id1.empty()) {
- vect_prim_keys.push_back(LINK_SWITCH_ID1);
+ vect_prim_keys.push_back(LINK_SWITCH_ID1_STR);
}
// port_id1
- PhyUtil::FillDbSchema(LINK_PORT_ID1, port_id1,
+ PhyUtil::FillDbSchema(unc::uppl::LINK_PORT_ID1, port_id1,
port_id1.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
if (!port_id1.empty()) {
- vect_prim_keys.push_back(LINK_PORT_ID1);
+ vect_prim_keys.push_back(LINK_PORT_ID1_STR);
}
// switch_id2
- PhyUtil::FillDbSchema(LINK_SWITCH_ID2, switch_id2,
+ PhyUtil::FillDbSchema(unc::uppl::LINK_SWITCH_ID2, switch_id2,
switch_id2.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
if (!switch_id2.empty()) {
- vect_prim_keys.push_back(LINK_SWITCH_ID2);
+ vect_prim_keys.push_back(LINK_SWITCH_ID2_STR);
}
// port_id2
- PhyUtil::FillDbSchema(LINK_PORT_ID2, port_id2,
+ PhyUtil::FillDbSchema(unc::uppl::LINK_PORT_ID2, port_id2,
port_id2.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
if (!port_id2.empty()) {
- vect_prim_keys.push_back(LINK_PORT_ID2);
+ vect_prim_keys.push_back(LINK_PORT_ID2_STR);
}
- kt_link_dbtableschema.set_table_name(UPPL_LINK_TABLE);
+ kt_link_dbtableschema.set_table_name(unc::uppl::LINK_TABLE);
kt_link_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_link_dbtableschema.set_row_list(row_list);
// Send request to ODBC for link_table
ODBCM_RC_STATUS check_db_status = physical_layer->get_odbc_manager()->
- IsRowExists(data_type, kt_link_dbtableschema);
+ IsRowExists(data_type, kt_link_dbtableschema, db_conn);
if (check_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log error to log daemon
pfc_log_error("DB connection not available or cannot access DB");
}
/** PopulateDBSchemaForKtTable
- * * @Description : This function populates the DBAttrSchema to be used to send
+ * @Description : This function populates the DBAttrSchema to be used to send
* request to ODBC
- * * * @param[in] : DBTableSchema, key_struct, val_struct, operation_type
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
+ * @param[in] :
+ * kt_link_dbtableschema-DBTableSchema instance to be filled
+ * key_struct-void* top link's key structure
+ * val_struct-void* to link's value structure
+ * operation_type-UNC_OP_*,type of operation
+ * option1,option2-UNC_OPT1/OPT2_*, additional info for read operations
+ * vect_prim_keys_operation- value of vector<ODBCMOperator>
+ * old_value_struct-void* to link's value structure
+ * row_status-CsRowStatus value
+ * is_filtering-flag to indicate whether filter option is enabled
+ * is_state-flag to indicate whether data type is DT_STATE
+ * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
* */
void Kt_Link::PopulateDBSchemaForKtTable(
+ OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_link_dbtableschema,
void *key_struct,
void *val_struct,
uint8_t operation_type,
+ uint32_t data_type,
uint32_t option1,
uint32_t option2,
vector<ODBCMOperator> &vect_prim_keys_operation,
// Controller_name
string controller_name = (const char*)obj_key_link->ctr_key.controller_name;
pfc_log_info("controller name: %s", controller_name.c_str());
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
vect_prim_keys_operation.push_back(unc::uppl::EQUAL);
// switch_id1
switch_id1 = "";
}
pfc_log_info("switch_id1: %s", switch_id1.c_str());
- PhyUtil::FillDbSchema(LINK_SWITCH_ID1, switch_id1,
+ PhyUtil::FillDbSchema(unc::uppl::LINK_SWITCH_ID1, switch_id1,
switch_id1.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
// switch_id2
switch_id2 = "";
}
pfc_log_info("switch_id2: %s", switch_id2.c_str());
- PhyUtil::FillDbSchema(LINK_SWITCH_ID2, switch_id2,
+ PhyUtil::FillDbSchema(unc::uppl::LINK_SWITCH_ID2, switch_id2,
switch_id2.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
port_id1 = "";
}
pfc_log_info("port_id1: %s", port_id1.c_str());
- PhyUtil::FillDbSchema(LINK_PORT_ID1, port_id1,
+ PhyUtil::FillDbSchema(unc::uppl::LINK_PORT_ID1, port_id1,
port_id1.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
port_id2 = "";
}
pfc_log_info("port_id2: %s", port_id2.c_str());
- PhyUtil::FillDbSchema(LINK_PORT_ID2, port_id2,
+ PhyUtil::FillDbSchema(unc::uppl::LINK_PORT_ID2, port_id2,
port_id2.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
PopulatePrimaryKeys(
// get valid array for update req
pfc_log_debug("Get link valid value from update valid flag");
val_link_valid_st = new val_link_st_t();
- GetLinkValidFlag(key_struct, *val_link_valid_st);
+ GetLinkValidFlag(db_conn, key_struct, *val_link_valid_st, data_type);
old_value_struct = reinterpret_cast<void *>(val_link_valid_st);
}
unsigned int valid_value_struct = UNC_VF_VALID;
valid_value_struct = PhyUtil::uint8touint(
obj_val_link->valid[kIdxLinkStLink]);
}
- string value;
+ string value = "";
uint32_t valid_val = 0, prev_db_val = 0;
// Description
if (obj_val_link != NULL &&
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(LINK_DESCRIPTION, value,
- value.length(), DATATYPE_UINT8_ARRAY_128,
+ PhyUtil::FillDbSchema(unc::uppl::LINK_DESCRIPTION, LINK_DESCRIPTION_STR,
+ value, value.length(), DATATYPE_UINT8_ARRAY_128,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
value.clear();
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(LINK_OPER_STATUS, value,
- value.length(), DATATYPE_UINT16,
+ PhyUtil::FillDbSchema(unc::uppl::LINK_OPER_STATUS, LINK_OPER_STATUS_STR,
+ value, value.length(), DATATYPE_UINT16,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
valid_val = UPPL_NO_VAL_STRUCT;
prev_db_val = 0;
stringstream dummy_valid;
// valid
- PhyUtil::FillDbSchema(LINK_VALID, valid.str(),
+ PhyUtil::FillDbSchema(unc::uppl::LINK_VALID, LINK_VALID_STR, valid.str(),
valid.str().length(), DATATYPE_UINT8_ARRAY_2,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, dummy_valid);
PhyUtil::reorder_col_attrs(vect_prim_keys, vect_table_attr_schema);
- kt_link_dbtableschema.set_table_name(UPPL_LINK_TABLE);
+ kt_link_dbtableschema.set_table_name(unc::uppl::LINK_TABLE);
kt_link_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_link_dbtableschema.set_row_list(row_list);
}
/** FillLinkValueStructure
- * * @Description : This function populates val_link_st_t by values retrieved
+ * @Description : This function populates val_link_st_t by values retrieved
* from database
- * * * @param[in] : controller common table dbtable schema,
- * value structure and max_rep_ct, operation type
- * * * @return : Filled val_link and controller id
+ * @param[in] : kt_link_dbtableschema-DBTableSchema instance to be filled
+ * vect_obj_val_link -vector of link value structure
+ * max_rep_ct-max. no. of records to be read
+ * operation_type-UNC_OP_*,type of operation
+ * link_id-instance of vector<key_link_t>
+ * @return : Filled val_link and controller id
* */
void Kt_Link::FillLinkValueStructure(
+ OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_link_dbtableschema,
vector<val_link_st_t> &vect_obj_val_link,
uint32_t &max_rep_ct,
uint32_t operation_type,
vector<key_link_t> &link_id) {
- // populate IPC value structure based on the response recevied from DB
- list < vector<TableAttrSchema> > res_link_row_list =
+ // populate IPC value structure based on the response received from DB
+ list < vector<TableAttrSchema> >& res_link_row_list =
kt_link_dbtableschema.get_row_list();
list < vector<TableAttrSchema> > :: iterator res_link_iter =
res_link_row_list.begin();
max_rep_ct = res_link_row_list.size();
pfc_log_debug("res_link_row_list.size: %d", max_rep_ct);
- // populate IPC value structure based on the response recevied from DB
+ // populate IPC value structure based on the response received from DB
for (; res_link_iter != res_link_row_list.end(); ++res_link_iter) {
vector<TableAttrSchema> res_link_table_attr_schema =
(*res_link_iter);
uint32_t attr_size = res_link_table_attr_schema.size();
pfc_log_debug("res_link_table_attr_schema size: %d", attr_size);
val_link_st_t obj_val_link;
+ memset(&obj_val_link, '\0', sizeof(val_link_st_t));
memset(obj_val_link.valid, '\0', 2);
key_link_t obj_key_link;
+ memset(&obj_key_link, '\0', sizeof(key_link_t));
// Read all attributes
vector<int> valid_flag, cs_attr;
for (; vect_link_iter != res_link_table_attr_schema.end();
++vect_link_iter) {
// Populate values from link_table
TableAttrSchema tab_schema = (*vect_link_iter);
- string attr_name = tab_schema.table_attribute_name;
- string attr_value;
- if (attr_name == CTR_NAME) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_key_link.ctr_key.controller_name,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("controller_name: %s", reinterpret_cast<char *>
- (&obj_key_link.ctr_key.controller_name));
- }
- if (attr_name == LINK_SWITCH_ID1) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_256);
- memcpy(obj_key_link.switch_id1,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("switch_id1: %s", reinterpret_cast<char *>
- (&obj_key_link.switch_id1));
- }
- if (attr_name == LINK_PORT_ID1) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_key_link.port_id1,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("port_id1: %s", reinterpret_cast<char *>
- (&obj_key_link.port_id1));
- }
- if (attr_name == LINK_SWITCH_ID2) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_256);
- memcpy(obj_key_link.switch_id2,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("switch_id2: %s", reinterpret_cast<char *>
- (&obj_key_link.switch_id2));
- }
- if (attr_name == LINK_PORT_ID2) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_key_link.port_id2,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("port_id2: %s", reinterpret_cast<char *>
- (&obj_key_link.port_id2));
- }
- if (attr_name == LINK_DESCRIPTION) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_128);
- memcpy(obj_val_link.link.description,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("description: %s", obj_val_link.link.description);
- }
- if (attr_name == LINK_OPER_STATUS) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- obj_val_link.oper_status = atoi(attr_value.c_str());
- pfc_log_debug("oper status : %d", obj_val_link.oper_status);
- }
- if (attr_name == LINK_VALID) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_2);
- memset(obj_val_link.link.valid, 0, 1);
- FrameValidValue(attr_value, obj_val_link);
- pfc_log_debug("valid: %s", attr_value.c_str());
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
+ string attr_value = "";
+ switch (attr_name) {
+ case unc::uppl::CTR_NAME:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_key_link.ctr_key.controller_name,
+ DATATYPE_UINT8_ARRAY_32);
+ pfc_log_debug("controller_name: %s", reinterpret_cast<char *>
+ (&obj_key_link.ctr_key.controller_name));
+ break;
+
+ case unc::uppl::LINK_SWITCH_ID1:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_key_link.switch_id1,
+ DATATYPE_UINT8_ARRAY_256);
+ pfc_log_debug("switch_id1: %s", reinterpret_cast<char *>
+ (&obj_key_link.switch_id1));
+ break;
+
+ case unc::uppl::LINK_PORT_ID1:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_key_link.port_id1,
+ DATATYPE_UINT8_ARRAY_32);
+ pfc_log_debug("port_id1: %s", reinterpret_cast<char *>
+ (&obj_key_link.port_id1));
+ break;
+
+ case unc::uppl::LINK_SWITCH_ID2:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_key_link.switch_id2,
+ DATATYPE_UINT8_ARRAY_256);
+ pfc_log_debug("switch_id2: %s", reinterpret_cast<char *>
+ (&obj_key_link.switch_id2));
+ break;
+
+ case unc::uppl::LINK_PORT_ID2:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_key_link.port_id2,
+ DATATYPE_UINT8_ARRAY_32);
+ pfc_log_debug("port_id2: %s", reinterpret_cast<char *>
+ (&obj_key_link.port_id2));
+ break;
+
+ case unc::uppl::LINK_DESCRIPTION:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_val_link.link.description,
+ DATATYPE_UINT8_ARRAY_128);
+ pfc_log_debug("description: %s", obj_val_link.link.description);
+ break;
+
+ case unc::uppl::LINK_OPER_STATUS:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT16);
+ obj_val_link.oper_status = atoi(attr_value.c_str());
+ pfc_log_debug("oper status : %d", obj_val_link.oper_status);
+ break;
+
+ case unc::uppl::LINK_VALID:
+ uint8_t link_val[ODBCM_SIZE_2];
+ memset(&link_val, '\0', ODBCM_SIZE_2);
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema, link_val,
+ DATATYPE_UINT8_ARRAY_2);
+ memset(obj_val_link.link.valid, 0, 1);
+ FrameValidValue(reinterpret_cast<const char*>(link_val),
+ obj_val_link);
+ pfc_log_debug("valid: %s", link_val);
+ break;
+
+ default:
+ pfc_log_info("Ignoring Link attribute %d", attr_name);
+ break;
}
}
vect_obj_val_link.push_back(obj_val_link);
}
/** PerformRead
- * * @Description : This function reads the instance of KT_Link based on
+ * @Description : This function reads the instance of KT_Link based on
* operation type - READ, READ_SIBLING_BEGIN, READ_SIBLING
- * * * @param[in] : ipc session id, configuration id, key_struct, value_struct,
- * data_type, operation type, ServerSession, option1, option2,
- * max_rep_ct
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
+ * @param[in] :
+ * session_id-ipc session id used for TC validation
+ * configuration_id-ipc configuration id used for TC validation
+ * key_struct-void* to link key structure
+ * value_struct-void * link value structure
+ * data_type-UNC_DT_*,type of database
+ * operation type-UNC_OP_*,type of operation requested
+ * sess-object of ServerSession where the arguments present
+ * option1,option2-UNC_OPT1,OPT2_*,additional info for read operations
+ * max_rep_ct-max no. of records to be read
+ * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
* */
-UpplReturnCode Kt_Link::PerformRead(uint32_t session_id,
+UpplReturnCode Kt_Link::PerformRead(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t option1,
uint32_t option2,
uint32_t max_rep_ct) {
- pfc_log_info("Inside PerformRead option1=%d option2=%d max_rep_ct=%d",
- option1, option2, max_rep_ct);
pfc_log_info("Inside PerformRead operation_type=%d data_type=%d",
operation_type, data_type);
vector<key_link_t> vect_link_id;
vector<val_link_t> vect_val_link;
vector<val_link_st_t> vect_val_link_st;
- read_status = ReadLinkValFromDB(key_struct,
+ read_status = ReadLinkValFromDB(db_conn, key_struct,
val_struct,
data_type,
operation_type,
}
/** ReadLinkValFromDB
- * * @Description : This function reads the instance of KT_Link based on
+ * @Description : This function reads the instance of KT_Link based on
* operation type - READ, READ_SIBLING_BEGIN, READ_SIBLING
* from data base
- * * * @param[in] : key_struct, value_struct, ipc session id, configuration id,
- * data_type, operation type, max_rep_ct
- * * * @return : Success or associated error code
+ * @param[in] : key_struct-void* to kink key structure
+ * value_struct-void* to kink value structure
+ * data_type-UNC_DT_*,type of database
+ * operation_type-UNC_OP_*,type of operation
+ * max_rep_ct-max no of records to be read
+ * vect_val_link_st-vector<val_link_st_t> instance
+ * link_id-instance of vector<key_link_t>
+ * option1,option2-additional info for read operations,UNC_OPT1/OPT2_*
+ * is_state-flag to indicate whether data type is DT_STATE
+ * @return : Success or associated error code,
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
UpplReturnCode Kt_Link::ReadLinkValFromDB(
+ OdbcmConnectionHandler *db_conn,
void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t option1,
uint32_t option2,
pfc_bool_t is_state) {
+ if (operation_type < UNC_OP_READ) {
+ // Unsupported operation type for this function
+ return UPPL_RC_SUCCESS;
+ }
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode read_status = UPPL_RC_SUCCESS;
ODBCM_RC_STATUS read_db_status = ODBCM_RC_SUCCESS;
DBTableSchema kt_link_dbtableschema;
vector<ODBCMOperator> vect_prim_key_operations;
void* old_value;
- PopulateDBSchemaForKtTable(kt_link_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_link_dbtableschema,
key_struct,
val_struct,
- operation_type,
+ operation_type, data_type,
option1, option2,
vect_prim_key_operations,
old_value);
if (operation_type == UNC_OP_READ) {
read_db_status = physical_layer->get_odbc_manager()->
GetOneRow((unc_keytype_datatype_t)data_type,
- kt_link_dbtableschema);
+ kt_link_dbtableschema, db_conn);
} else if ((operation_type == UNC_OP_READ_SIBLING_BEGIN ||
operation_type == UNC_OP_READ_SIBLING) &&
(option1 == UNC_OPT1_NORMAL &&
GetSiblingRows((unc_keytype_datatype_t)data_type, max_rep_ct,
kt_link_dbtableschema,
vect_prim_key_operations,
- (unc_keytype_operation_t)operation_type);
+ (unc_keytype_operation_t)operation_type, db_conn);
+ } else if (operation_type == UNC_OP_READ_SIBLING) {
+ pfc_log_debug("Ktlink:Primarykeysize: %d",
+ (uint32_t)kt_link_dbtableschema.primary_keys_.size());
+ pfc_log_debug("Inside READ SIBLING part");
+ uint32_t index = 0;
+ uint32_t no_of_query = 4; // Link has 4 primary keys other than controller
+ for (; index < no_of_query ; ++index) {
+ if (kt_link_dbtableschema.primary_keys_.size() < 2) {
+ pfc_log_debug("No record found");
+ read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
+ break;
+ }
+ read_db_status = physical_layer->get_odbc_manager()-> \
+ GetBulkRows((unc_keytype_datatype_t)data_type, max_rep_ct,
+ kt_link_dbtableschema,
+ (unc_keytype_operation_t)UNC_OP_READ_BULK,
+ db_conn);
+ kt_link_dbtableschema.primary_keys_.pop_back();
+ if (read_db_status == ODBCM_RC_RECORD_NOT_FOUND) {
+ read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
+ } else if (read_db_status == ODBCM_RC_CONNECTION_ERROR) {
+ read_status = UPPL_RC_ERR_DB_ACCESS;
+ pfc_log_error("Read operation has failed with error %d",
+ read_db_status);
+ return read_status;
+ } else if (read_db_status == ODBCM_RC_SUCCESS) {
+ read_status = UPPL_RC_SUCCESS;
+ uint32_t max_rep_ct_new = 0;
+ pfc_log_debug("Received success response from db");
+ FillLinkValueStructure(db_conn, kt_link_dbtableschema,
+ vect_val_link_st,
+ max_rep_ct_new,
+ operation_type,
+ link_id);
+ pfc_log_debug("max_rep_ct_new=%d max_rep_ct=%d",
+ max_rep_ct_new, max_rep_ct);
+ for (uint32_t uindex = 1; uindex < max_rep_ct_new; uindex++) {
+ kt_link_dbtableschema.row_list_.pop_front();
+ }
+ max_rep_ct -= max_rep_ct_new;
+ } else {
+ read_status = UPPL_RC_ERR_DB_GET;
+ return read_status;
+ }
+ } // for end
+ if (vect_val_link_st.empty() && index == 4) {
+ pfc_log_debug("No record found");
+ read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
+ } else if (!vect_val_link_st.empty()) {
+ max_rep_ct = vect_val_link_st.size();
+ read_status = UPPL_RC_SUCCESS;
+ }
+ return read_status;
} else {
+ pfc_log_debug("Inside READ SIBLING BEGIN part ");
read_db_status = physical_layer->get_odbc_manager()->
- GetBulkRows((unc_keytype_datatype_t)data_type, max_rep_ct,
- kt_link_dbtableschema,
- (unc_keytype_operation_t)operation_type);
+ GetBulkRows((unc_keytype_datatype_t)data_type, max_rep_ct,
+ kt_link_dbtableschema,
+ (unc_keytype_operation_t)operation_type, db_conn);
}
+ // except read sibling - all other reads following block will fill the values
if (read_db_status == ODBCM_RC_RECORD_NOT_FOUND) {
pfc_log_debug("No record found");
read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
return read_status;
+ } else if (read_db_status == ODBCM_RC_CONNECTION_ERROR) {
+ read_status = UPPL_RC_ERR_DB_ACCESS;
+ pfc_log_error("Read operation has failed with error %d", read_db_status);
+ return read_status;
} else if (read_db_status != ODBCM_RC_SUCCESS) {
read_status = UPPL_RC_ERR_DB_GET;
// log error to log daemon
return read_status;
}
pfc_log_debug("Read operation result: %d", read_status);
- FillLinkValueStructure(kt_link_dbtableschema,
+ FillLinkValueStructure(db_conn, kt_link_dbtableschema,
vect_val_link_st,
max_rep_ct,
operation_type,
}
/** Fill_Attr_Syntax_Map
- * * @Description : This function populates the values to be used for attribute
+ * @Description : This function populates the values to be used for attribute
* validation
- * * * @param[in] : None
- * * * @return : None
+ * @param[in] : None
+ * @return : None
* */
void Kt_Link::Fill_Attr_Syntax_Map() {
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map;
Kt_Class_Attr_Syntax objKeyAttrSyntax =
{ PFC_IPCTYPE_UINT8, 0, 0, 1, 32, true, "" };
- attr_syntax_map[CTR_NAME] = objKeyAttrSyntax;
+ attr_syntax_map[CTR_NAME_STR] = objKeyAttrSyntax;
Kt_Class_Attr_Syntax objKeyAttrSyntax1 =
{ PFC_IPCTYPE_STRING, 0, 0, 1, 256, true, "" };
- attr_syntax_map[LINK_SWITCH_ID1] = objKeyAttrSyntax1;
+ attr_syntax_map[LINK_SWITCH_ID1_STR] = objKeyAttrSyntax1;
Kt_Class_Attr_Syntax objKeyAttrSyntax2 =
{ PFC_IPCTYPE_STRING, 0, 0, 1, 32, true, "" };
- attr_syntax_map[LINK_PORT_ID1] = objKeyAttrSyntax2;
+ attr_syntax_map[LINK_PORT_ID1_STR] = objKeyAttrSyntax2;
Kt_Class_Attr_Syntax objKeyAttrSyntax3 =
{ PFC_IPCTYPE_STRING, 0, 0, 1, 256, true, "" };
- attr_syntax_map[LINK_SWITCH_ID2] = objKeyAttrSyntax3;
+ attr_syntax_map[LINK_SWITCH_ID2_STR] = objKeyAttrSyntax3;
Kt_Class_Attr_Syntax objKeyAttrSyntax4 =
{ PFC_IPCTYPE_STRING, 0, 0, 1, 32, true, "" };
- attr_syntax_map[LINK_PORT_ID2] = objKeyAttrSyntax4;
+ attr_syntax_map[LINK_PORT_ID2_STR] = objKeyAttrSyntax4;
Kt_Class_Attr_Syntax objAttrDescSyntax =
{ PFC_IPCTYPE_STRING, 0, 0, 0, 128, false, "" };
- attr_syntax_map[LINK_DESCRIPTION] = objAttrDescSyntax;
+ attr_syntax_map[LINK_DESCRIPTION_STR] = objAttrDescSyntax;
Kt_Class_Attr_Syntax objAttrValidSyntax =
{ PFC_IPCTYPE_STRING, 0, 0, 0, 2, false, "" };
- attr_syntax_map[LINK_VALID] = objAttrValidSyntax;
+ attr_syntax_map[LINK_VALID_STR] = objAttrValidSyntax;
+ attr_syntax_map_all[UNC_KT_LINK] = attr_syntax_map;
}
/** GetLinkValidFlag
- * * @Description : This function reads the valid flag from DB
- * * * @param[in] : Key, value struct and newvalid val
- * * * @return : Success or associated error code
+ * @Description : This function reads the valid flag from DB
+ * @param[in] : key_struct-void* to link key structure
+ * val_link_valid_st-instance of val_link_st_t
+ * @return : Success or associated error code
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
UpplReturnCode Kt_Link::GetLinkValidFlag(
+ OdbcmConnectionHandler *db_conn,
void *key_struct,
- val_link_st_t &val_link_valid_st) {
+ val_link_st_t &val_link_valid_st,
+ uint32_t data_type) {
UpplReturnCode return_code = UPPL_RC_SUCCESS;
vector<void *> vectVal_link;
vector<void *> vectkey_link;
vectkey_link.push_back(key_struct);
- return_code = ReadInternal(vectkey_link,
+ return_code = ReadInternal(db_conn, vectkey_link,
vectVal_link,
- UNC_DT_STATE, UNC_OP_READ);
+ data_type, UNC_OP_READ);
if (return_code == UPPL_RC_SUCCESS) {
val_link_st_t *obj_new_link_val_vect =
reinterpret_cast<val_link_st_t*> (vectVal_link[0]);
}
/** GetOperStatus
- * * @Description : This function reads the oper_status value of the link
- * * @param[in] : key_struct
- * * @return : oper_status
+ * @Description : This function reads the oper_status value of the link
+ * @param[in] : key_struct-void* to link key structure
+ * data_type-UNC_DT_*,type of database
+ * param[out]:
+ * oper_status-indicates the oper status of link whether up or down
+ * @return : Success or associated error code
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
*/
-UpplReturnCode Kt_Link::GetOperStatus(uint32_t data_type,
+UpplReturnCode Kt_Link::GetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
uint8_t &oper_status) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
string switch_id2 = (const char*)obj_key_link->switch_id2;
string port_id2 = (const char*)obj_key_link->port_id2;
// Controller_name
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
if (!controller_name.empty()) {
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
}
// switch_id1
- PhyUtil::FillDbSchema(LINK_SWITCH_ID1, switch_id1,
+ PhyUtil::FillDbSchema(unc::uppl::LINK_SWITCH_ID1, switch_id1,
switch_id1.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
if (!switch_id1.empty()) {
- vect_prim_keys.push_back(LINK_SWITCH_ID1);
+ vect_prim_keys.push_back(LINK_SWITCH_ID1_STR);
}
// port_id1
- PhyUtil::FillDbSchema(LINK_PORT_ID1, port_id1,
+ PhyUtil::FillDbSchema(unc::uppl::LINK_PORT_ID1, port_id1,
port_id1.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
if (!port_id1.empty()) {
- vect_prim_keys.push_back(LINK_PORT_ID1);
+ vect_prim_keys.push_back(LINK_PORT_ID1_STR);
}
// switch_id2
- PhyUtil::FillDbSchema(LINK_SWITCH_ID2, switch_id2,
+ PhyUtil::FillDbSchema(unc::uppl::LINK_SWITCH_ID2, switch_id2,
switch_id2.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
if (!switch_id2.empty()) {
- vect_prim_keys.push_back(LINK_SWITCH_ID2);
+ vect_prim_keys.push_back(LINK_SWITCH_ID2_STR);
}
// port_id2
- PhyUtil::FillDbSchema(LINK_PORT_ID2, port_id2,
+ PhyUtil::FillDbSchema(unc::uppl::LINK_PORT_ID2, port_id2,
port_id2.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
if (!port_id2.empty()) {
- vect_prim_keys.push_back(LINK_PORT_ID2);
+ vect_prim_keys.push_back(LINK_PORT_ID2_STR);
}
- string oper_value;
- PhyUtil::FillDbSchema(LINK_OPER_STATUS, oper_value,
+ string oper_value = "";
+ PhyUtil::FillDbSchema(unc::uppl::LINK_OPER_STATUS, oper_value,
oper_value.length(), DATATYPE_UINT16,
vect_table_attr_schema);
DBTableSchema kt_link_dbtableschema;
PhyUtil::reorder_col_attrs(vect_prim_keys, vect_table_attr_schema);
- kt_link_dbtableschema.set_table_name(UPPL_LINK_TABLE);
+ kt_link_dbtableschema.set_table_name(unc::uppl::LINK_TABLE);
kt_link_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_link_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS update_db_status =
physical_layer->get_odbc_manager()->GetOneRow(
(unc_keytype_datatype_t)data_type,
- kt_link_dbtableschema);
+ kt_link_dbtableschema, db_conn);
if (update_db_status != ODBCM_RC_SUCCESS) {
- // log error
- pfc_log_info("oper_status read operation failed");
+ pfc_log_info("oper_status read operation failed %d", update_db_status);
return UPPL_RC_ERR_DB_GET;
}
// read the oper_status value
- list < vector<TableAttrSchema> > res_row_list =
+ list < vector<TableAttrSchema> >& res_row_list =
kt_link_dbtableschema.get_row_list();
list < vector<TableAttrSchema> >::iterator res_iter =
res_row_list.begin();
++vect_iter) {
// populate values from port_table
TableAttrSchema tab_schema = (*vect_iter);
- string attr_name = tab_schema.table_attribute_name;
- string attr_value;
- if (attr_name == LINK_OPER_STATUS) {
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
+ string attr_value = "";
+ if (attr_name == unc::uppl::LINK_OPER_STATUS) {
PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
DATATYPE_UINT16);
oper_status = atoi(attr_value.c_str());
}
/** FrameValidValue
- * * @Description : This function converts the string value from db to uint8
- * * * @param[in] : Attribute value and val_ctr_st
- * * * @return : Success or associated error code
+ * @Description : This function converts the string value from db to uint8
+ * @param[in] : attr_value-attribute value in string
+ * obj_val_link-object of val_link_st
+ * @return : Success or associated error code
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
void Kt_Link::FrameValidValue(string attr_value,
val_link_st &obj_val_link) {
}
/** PopulatePrimaryKeys
- * * @Description : This function decides the primary key based on option
- * * * @param[in] : Attribute value and val_ctr_st
- * * * @return : Success or associated error code
+ * @Description : This function decides the primary key based on option
+ * @param[in] : operation_type-UNC_OP_*
+ * option1,option2-UNC_OPT1/OPT2_*,additional info for read operations
+ * switch_id1,switch_id2-switch names that connected by the link through ports
+ * port_id1,port_id2-port numbers thatare connected by the link
+ * vect_prim_keys-vector<string> conatining link keys
+ * vect_prim_keys_operation-instance of vector<ODBCMOperator>
+ * @return : Success or associated error code
+ * UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
void Kt_Link::PopulatePrimaryKeys(
uint32_t operation_type,
vector<string> &vect_prim_keys,
vector<ODBCMOperator> &vect_prim_keys_operation) {
if (option1 == UNC_OPT1_NORMAL && option2 == UNC_OPT2_MATCH_SWITCH1) {
- vect_prim_keys.push_back(LINK_SWITCH_ID1);
+ vect_prim_keys.push_back(LINK_SWITCH_ID1_STR);
vect_prim_keys_operation.push_back(unc::uppl::EQUAL);
}
if (option1 == UNC_OPT1_NORMAL && option2 == UNC_OPT2_MATCH_SWITCH2) {
- vect_prim_keys.push_back(LINK_SWITCH_ID2);
+ vect_prim_keys.push_back(LINK_SWITCH_ID2_STR);
vect_prim_keys_operation.push_back(unc::uppl::EQUAL);
}
if (option1 == UNC_OPT1_NORMAL &&
option2 == UNC_OPT2_MATCH_BOTH_SWITCH) {
- vect_prim_keys.push_back(LINK_SWITCH_ID1);
+ vect_prim_keys.push_back(LINK_SWITCH_ID1_STR);
vect_prim_keys_operation.push_back(unc::uppl::EQUAL);
- vect_prim_keys.push_back(LINK_SWITCH_ID2);
+ vect_prim_keys.push_back(LINK_SWITCH_ID2_STR);
vect_prim_keys_operation.push_back(unc::uppl::EQUAL);
}
if (option1 == UNC_OPT1_NORMAL && (option2 != UNC_OPT2_MATCH_SWITCH1 &&
}
// Need not check empty condition
// Another key required for getbulk operation
- vect_prim_keys.push_back(LINK_SWITCH_ID1);
+ vect_prim_keys.push_back(LINK_SWITCH_ID1_STR);
+ if (!port_id1.empty()) {
+ vect_prim_keys.push_back(LINK_PORT_ID1_STR);
+ }
if (!switch_id2.empty()) {
- vect_prim_keys.push_back(LINK_SWITCH_ID2);
+ vect_prim_keys.push_back(LINK_SWITCH_ID2_STR);
}
+ if (!port_id2.empty()) {
+ vect_prim_keys.push_back(LINK_PORT_ID2_STR);
}
- if (!port_id1.empty()) {
- vect_prim_keys.push_back(LINK_PORT_ID1);
- if (option2 == UNC_OPT2_MATCH_SWITCH1 ||
- option2 == UNC_OPT2_MATCH_SWITCH2 ||
- option2 == UNC_OPT2_MATCH_BOTH_SWITCH) {
- vect_prim_keys_operation.push_back(unc::uppl::GREATER);
+ } else {
+ if (!port_id1.empty()) {
+ vect_prim_keys.push_back(LINK_PORT_ID1_STR);
+ if (option2 == UNC_OPT2_MATCH_SWITCH1 ||
+ option2 == UNC_OPT2_MATCH_SWITCH2 ||
+ option2 == UNC_OPT2_MATCH_BOTH_SWITCH) {
+ vect_prim_keys_operation.push_back(unc::uppl::GREATER);
+ }
}
- }
- if (!port_id2.empty()) {
- vect_prim_keys.push_back(LINK_PORT_ID2);
- if (option2 == UNC_OPT2_MATCH_SWITCH1 ||
- option2 == UNC_OPT2_MATCH_SWITCH2 ||
- option2 == UNC_OPT2_MATCH_BOTH_SWITCH) {
- vect_prim_keys_operation.push_back(unc::uppl::GREATER);
+
+ if (!port_id2.empty()) {
+ vect_prim_keys.push_back(LINK_PORT_ID2_STR);
+ if (option2 == UNC_OPT2_MATCH_SWITCH1 ||
+ option2 == UNC_OPT2_MATCH_SWITCH2 ||
+ option2 == UNC_OPT2_MATCH_BOTH_SWITCH) {
+ vect_prim_keys_operation.push_back(unc::uppl::GREATER);
+ }
}
}
}
#include "itc_kt_logical_member_port.hh"
#include "itc_kt_logicalport.hh"
+#include "itc_read_request.hh"
using unc::uppl::PhysicalLayer;
/** Constructor
- * * @Description : This function initializes member variables
+ * @Description : This function initializes member variables
* and fills the attribute syntax map used for validation
- * * * @param[in] : None
- * * * @return : None
+ * @param[in] : None
+ * @return : None
* */
Kt_LogicalMemberPort::Kt_LogicalMemberPort() {
- parent = NULL;
+ if (attr_syntax_map_all.find(UNC_KT_LOGICAL_MEMBER_PORT) ==
+ attr_syntax_map_all.end()) {
Fill_Attr_Syntax_Map();
+ }
}
/** Destructor
- * * @Description : This function frees the parent and child key types
+ * @Description : This function frees child key types
* instances for kt_logical_member_port
- * * * @param[in] : None
- * * * @return : None
+ * @param[in] : None
+ * @return : None
* */
Kt_LogicalMemberPort::~Kt_LogicalMemberPort() {
- // Delete parent object
- if (parent != NULL) {
- delete parent;
- parent = NULL;
- }
}
/**DeleteKeyInstance
- * * @Description : This function deletes a row of KT_LogicalMemberPort in
+ * @Description : This function deletes a row of KT_LogicalMemberPort in
* state logicalmemberport table.
- * * @param[in] :
+ * @param[in] :
* key_struct - the key for the new kt logicalmemberport instance
* data_type - UNC_DT_* , delete only allowed in state
- * * @return : UPPL_RC_SUCCESS is returned when the delete
+ * key_type-UNC_KT_LOGICAL_MEMBER_PORT,value of unc_key_type_t
+ * @return : UPPL_RC_SUCCESS is returned when the delete
* is done successfully.
* UPPL_RC_ERR_* is returned when the delete is error
* */
-UpplReturnCode Kt_LogicalMemberPort::DeleteKeyInstance(void* key_struct,
- uint32_t data_type,
- uint32_t key_type) {
+UpplReturnCode Kt_LogicalMemberPort::DeleteKeyInstance(
+ OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ uint32_t data_type,
+ uint32_t key_type) {
UpplReturnCode delete_status = UPPL_RC_SUCCESS;
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
// Check whether operation is allowed on the given DT type
// Construct Primary key list
vector<string> vect_prim_keys;
if (!controller_name.empty())
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
if (!domain_name.empty())
- vect_prim_keys.push_back(DOMAIN_NAME);
+ vect_prim_keys.push_back(DOMAIN_NAME_STR);
if (!port_id.empty())
- vect_prim_keys.push_back(LMP_LP_PORT_ID);
+ vect_prim_keys.push_back(LMP_LP_PORT_ID_STR);
if (!switch_id.empty())
- vect_prim_keys.push_back(LMP_SWITCH_ID);
+ vect_prim_keys.push_back(LMP_SWITCH_ID_STR);
if (!physical_port_id.empty())
- vect_prim_keys.push_back(LMP_PHYSICAL_PORT_ID);
+ vect_prim_keys.push_back(LMP_PHYSICAL_PORT_ID_STR);
// Construct TableAttrSchema structure
// TableAttrSchema holds table_name, primary key, attr_name
vector<TableAttrSchema> vect_table_attr_schema;
list< vector<TableAttrSchema> > row_list;
// controller_name
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// domain_name
- PhyUtil::FillDbSchema(DOMAIN_NAME, domain_name,
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_NAME, domain_name,
domain_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// port_id
- PhyUtil::FillDbSchema(LMP_LP_PORT_ID, port_id,
+ PhyUtil::FillDbSchema(unc::uppl::LMP_LP_PORT_ID, port_id,
port_id.length(), DATATYPE_UINT8_ARRAY_320,
vect_table_attr_schema);
// switch_id
- PhyUtil::FillDbSchema(LMP_SWITCH_ID, switch_id,
+ PhyUtil::FillDbSchema(unc::uppl::LMP_SWITCH_ID, switch_id,
switch_id.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
// physical_port_id
- PhyUtil::FillDbSchema(LMP_PHYSICAL_PORT_ID, physical_port_id,
+ PhyUtil::FillDbSchema(unc::uppl::LMP_PHYSICAL_PORT_ID, physical_port_id,
physical_port_id.length(),
DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// Send request to ODBC for logical_member_port_table delete
- kt_logical_member_port_dbtableschema.set_table_name(
- UPPL_LOGICAL_MEMBER_PORT_TABLE);
+ kt_logical_member_port_dbtableschema.set_table_name(unc::uppl::
+ LOGICAL_MEMBERPORT_TABLE);
kt_logical_member_port_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_logical_member_port_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS delete_db_status = physical_layer->get_odbc_manager()-> \
DeleteOneRow((unc_keytype_datatype_t)data_type,
- kt_logical_member_port_dbtableschema);
+ kt_logical_member_port_dbtableschema, db_conn);
if (delete_db_status != ODBCM_RC_SUCCESS) {
if (delete_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log fatal error to log daemon
}
/** ReadBulk
- * * @Description : This function reads the max_rep_ct number of instances of
+ * @Description : This function reads the max_rep_ct number of instances of
* the KT_LogicalMemberPort
* Order of ReadBulk response
* val_ctr -> val_ctr_domain -> val_logical_port ->
* val_logical_member_port -> val_switch -> val_port ->
* val_link -> val_boundary
- * * * @param[in] :
+ * @param[in] :
* key_struct - the key for the kt logicalmemberport instance
* data_type - UNC_DT_* , read allowed in state
- * option1/option2 - specifies any additional condition for read operation
* max_rep_ct - specifies number of rows to be returned
* parent_call - indicates whether parent has called this readbulk
* is_read_next - indicates whether this function is invoked from readnext
- * * @return : UPPL_RC_SUCCESS is returned when the response
+ * @return : UPPL_RC_SUCCESS is returned when the response
* is added to ipc session successfully.
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-
-UpplReturnCode Kt_LogicalMemberPort::ReadBulk(void* key_struct,
- uint32_t data_type,
- uint32_t option1,
- uint32_t option2,
- uint32_t &max_rep_ct,
- int child_index,
- pfc_bool_t parent_call,
- pfc_bool_t is_read_next) {
+UpplReturnCode Kt_LogicalMemberPort::ReadBulk(
+ OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ uint32_t data_type,
+ uint32_t &max_rep_ct,
+ int child_index,
+ pfc_bool_t parent_call,
+ pfc_bool_t is_read_next,
+ ReadRequest *read_req) {
UpplReturnCode read_status = UPPL_RC_SUCCESS;
key_logical_member_port_t* obj_key_logical_member_port =
reinterpret_cast<key_logical_member_port_t*>(key_struct);
}
vector<key_logical_member_port_t> vect_logical_mem_port;
// Read the controller values based on given key structure
- read_status = ReadBulkInternal(key_struct,
+ read_status = ReadBulkInternal(db_conn, key_struct,
data_type,
max_rep_ct,
vect_logical_mem_port);
pfc_log_debug("read_status from _logical_member_port is %d", read_status);
if (read_status == UPPL_RC_SUCCESS) {
- PhysicalCore *physical_core = PhysicalLayer::get_instance()->
- get_physical_core();
- InternalTransactionCoordinator *itc_trans =
- physical_core->get_internal_transaction_coordinator();
vector<key_logical_member_port_t> ::iterator logical_mem_port_iter =
vect_logical_mem_port.begin();
for (; logical_mem_port_iter != vect_logical_mem_port.end();
UNC_KT_LOGICAL_MEMBER_PORT, IS_KEY,
reinterpret_cast<void *>(key_buffer)
};
- itc_trans->AddToBuffer(obj_key_buffer);
+ read_req->AddToBuffer(obj_key_buffer);
BulkReadBuffer obj_sep_buffer = {
UNC_KT_LOGICAL_MEMBER_PORT, IS_SEPARATOR, NULL
};
- itc_trans->AddToBuffer(obj_sep_buffer);
+ read_req->AddToBuffer(obj_sep_buffer);
--max_rep_ct;
if (max_rep_ct == 0) {
pfc_log_debug("max_rep_ct reached zero, so returning");
return read_status;
}
}
+ } else if (read_status == UPPL_RC_ERR_DB_ACCESS) {
+ pfc_log_debug("KtLogicalMemberPort ReadBulk - Returning DB Access Error");
+ return read_status;
}
if (max_rep_ct > 0 && parent_call == false) {
pfc_log_debug("max_rep_ct is %d and parent_call is %d, calling parent",
controller_name.c_str(),
controller_name.length()+1);
read_status = nextKin.ReadBulk(
- reinterpret_cast<void *>(&nextkin_key_struct),
+ db_conn, reinterpret_cast<void *>(&nextkin_key_struct),
data_type,
- option1,
- option2,
max_rep_ct,
0,
false,
- is_read_next);
+ is_read_next,
+ read_req);
pfc_log_debug("read status from next kin Kt_LogicalPort is %d",
read_status);
return UPPL_RC_SUCCESS;
}
/**ReadBulkInternal
- * * @Description : This function reads bulk rows of KT_LogicalMemberPort in
+ * @Description : This function reads bulk rows of KT_LogicalMemberPort in
* logicalmemberport table of specified data type.
- * * @param[in] :
+ * @param[in] :
* key_struct - the key for the kt logicalmemberport instance
- * val_struct - the value struct for kt_logicalmemberport instance
* max_rep_ct - specifies number of rows to be returned
- * vect_ctr_id - indicates the fetched contoller names from db
- * * @return : UPPL_RC_SUCCESS is returned when the response
+ * data_type-UNC_DT_*,type of database
+ * vect_logical_mem_port-instance of vector<key_logical_member_port_t>
+ * @return : UPPL_RC_SUCCESS is returned when the response
* is added to ipc session successfully.
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
UpplReturnCode Kt_LogicalMemberPort::ReadBulkInternal(
+ OdbcmConnectionHandler *db_conn,
void* key_struct,
uint32_t data_type,
uint32_t max_rep_ct,
vector<ODBCMOperator> primary_key_operation_list;
void *old_val_struct;
PopulateDBSchemaForKtTable(
- kt_logical_member_port_dbtableschema,
+ db_conn, kt_logical_member_port_dbtableschema,
key_struct, NULL,
- UNC_OP_READ_BULK, 0, 0,
+ UNC_OP_READ_BULK, data_type, 0, 0,
primary_key_operation_list, old_val_struct);
uint32_t no_of_query = 1;
vector<ODBCMOperator>:: iterator iter =
pfc_log_debug("Multiple query to be sent to DB till we get a match");
no_of_query = 2; // LMP has 2 primary keys other than LP
}
- for (uint32_t index = 0; index < no_of_query; ++index) {
+ uint32_t index = 0;
+ for (; index < no_of_query; ++index) {
+ if (kt_logical_member_port_dbtableschema.primary_keys_.size() < 3) {
+ pfc_log_debug("No record found");
+ read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
+ break;
+ }
// Read rows from DB
read_db_status = physical_layer->get_odbc_manager()-> \
GetBulkRows((unc_keytype_datatype_t)data_type, max_rep_ct,
kt_logical_member_port_dbtableschema,
- (unc_keytype_operation_t)UNC_OP_READ_BULK);
+ (unc_keytype_operation_t)UNC_OP_READ_BULK, db_conn);
if (read_db_status == ODBCM_RC_RECORD_NOT_FOUND) {
pfc_log_debug("No record found");
read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
"Primary key vector size %d",
static_cast<int>
(kt_logical_member_port_dbtableschema.primary_keys_.size()));
- // return read_status;
+ } else if (read_db_status == ODBCM_RC_CONNECTION_ERROR) {
+ read_status = UPPL_RC_ERR_DB_ACCESS;
+ pfc_log_error("Read operation has failed with error %d",
+ read_db_status);
+ break;
} else if (read_db_status == ODBCM_RC_SUCCESS) {
read_status = UPPL_RC_SUCCESS;
+ uint32_t max_rep_ct_new = 0;
pfc_log_debug("Received success response from db");
- break;
+ // From the values received from DB, populate val structure
+ FillLogicalMemberPortValueStructure(db_conn,
+ kt_logical_member_port_dbtableschema,
+ max_rep_ct_new,
+ UNC_OP_READ_BULK,
+ vect_logical_mem_port);
+ pfc_log_debug("max_rep_ct_new=%d max_rep_ct=%d",
+ max_rep_ct_new, max_rep_ct);
+ for (uint32_t uindex = 1; uindex < max_rep_ct_new; uindex++) {
+ pfc_log_debug("Ktlink:Row list Removed");
+ kt_logical_member_port_dbtableschema.row_list_.pop_front();
+ }
+ max_rep_ct -= max_rep_ct_new;
+ kt_logical_member_port_dbtableschema.primary_keys_.pop_back();
} else {
read_status = UPPL_RC_ERR_DB_GET;
// log error to log daemon
pfc_log_error("Read operation has failed");
- // return read_status;
+ break;
}
- }
- if (read_status == UPPL_RC_SUCCESS) {
- // From the values received from DB, populate val structure
- FillLogicalMemberPortValueStructure(kt_logical_member_port_dbtableschema,
- max_rep_ct,
- UNC_OP_READ_BULK,
- vect_logical_mem_port);
+ } // for end
+ if (vect_logical_mem_port.empty() && index == 2) {
+ pfc_log_debug("No record found");
+ read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
+ } else if (!vect_logical_mem_port.empty()) {
+ read_status = UPPL_RC_SUCCESS;
}
return read_status;
}
/** PerformSyntaxValidation
- * * @Description : This function performs syntax validation for
+ * @Description : This function performs syntax validation for
* UNC_KT_LOGICAL_MEMBER_PORT
- * * * @param[in]
+ * @param[in]
* key_struct - the key for the kt logicalmemberport instance
* value_struct - the value for the kt logicalmemberport instance
- * data_type - UNC_DT_*
- * operation_type - UNC_OP*
- * * @return : UPPL_RC_SUCCESS is returned when the validation is successful
- * UPPL_RC_ERR_* is returned when validtion is failure
+ * data_type - UNC_DT_*,type of database
+ * operation_type - UNC_OP*,type of operation
+ * @return : UPPL_RC_SUCCESS is returned when the validation is successful
+ * UPPL_RC_ERR_* is returned when validation is failure
* */
UpplReturnCode Kt_LogicalMemberPort::PerformSyntaxValidation(
+ OdbcmConnectionHandler *db_conn,
void* key_struct,
void* val_struct,
uint32_t operation,
reinterpret_cast<key_logical_member_port_t*>(key_struct);
string value = reinterpret_cast<char*>(key->switch_id);
- IS_VALID_STRING_KEY(LMP_SWITCH_ID, value, operation, ret_code, mandatory);
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map =
+ attr_syntax_map_all[UNC_KT_LOGICAL_MEMBER_PORT];
+ IS_VALID_STRING_KEY(LMP_SWITCH_ID_STR, value, operation, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
value = reinterpret_cast<char*>(key->physical_port_id);
- IS_VALID_STRING_KEY(LMP_PHYSICAL_PORT_ID, value, operation,
+ IS_VALID_STRING_KEY(LMP_PHYSICAL_PORT_ID_STR, value, operation,
ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
value = reinterpret_cast<char*>(key->logical_port_key.port_id);
- IS_VALID_STRING_KEY(LMP_LP_PORT_ID, value, operation,
+ IS_VALID_STRING_KEY(LMP_LP_PORT_ID_STR, value, operation,
ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
value = reinterpret_cast<char*>
(key->logical_port_key.domain_key.domain_name);
- IS_VALID_STRING_KEY(DOMAIN_NAME, value, operation,
+ IS_VALID_STRING_KEY(DOMAIN_NAME_STR, value, operation,
ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
value = reinterpret_cast<char*>(key->
logical_port_key.domain_key.ctr_key.controller_name);
- IS_VALID_STRING_KEY(CTR_NAME, value, operation,
+ IS_VALID_STRING_KEY(CTR_NAME_STR, value, operation,
ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
/** PerformSemanticValidation
- * * @Description : This function performs semantic validation
+ * @Description : This function performs semantic validation
* for UNC_KT_LOGICAL_MEMBER_PORT
- * * * @param[in] : key_struct - specifies key instance of KTLogicalMemberPort
- * , value_struct - specifies value of KTLOGICAL_MEMBER_PORT
- * operation - UNC_OP*
- * data_type - UNC_DT*
- * * * @return : UPPL_RC_SUCCESS if semantic valition is successful
+ * @param[in] : key_struct - specifies key instance of KTLogicalMemberPort
+ * value_struct - specifies value of KTLOGICAL_MEMBER_PORT
+ * operation - UNC_OP*,type of operation
+ * data_type - UNC_DT*,type of database
+ * @return : UPPL_RC_SUCCESS if semantic valition is successful
* or UPPL_RC_ERR_* if failed
* */
UpplReturnCode Kt_LogicalMemberPort::PerformSemanticValidation(
+ OdbcmConnectionHandler *db_conn,
void* key_struct,
void* val_struct,
uint32_t operation,
vect_key_value.push_back(switch_id);
vect_key_value.push_back(physical_port_id);
- UpplReturnCode KeyStatus = IsKeyExists((unc_keytype_datatype_t)data_type,
+ UpplReturnCode KeyStatus = IsKeyExists(db_conn,
+ (unc_keytype_datatype_t)data_type,
vect_key_value);
- pfc_log_info("return value of IsKeyExists:%d", KeyStatus);
+ pfc_log_debug("return value of IsKeyExists:%d", KeyStatus);
// KeyStatus = UPPL_RC_SUCCESS; //to be removed
if (operation == UNC_OP_UPDATE || operation == UNC_OP_DELETE ||
operation == UNC_OP_READ) {
pfc_log_info("calling KtLogicalPort IsKeyExists function");
Kt_LogicalPort KtObj;
UpplReturnCode parent_key_status = KtObj.IsKeyExists(
- (unc_keytype_datatype_t)data_type, parent_vect_key_value);
+ db_conn, (unc_keytype_datatype_t)data_type, parent_vect_key_value);
pfc_log_debug("Parent IsKeyExists status %d", parent_key_status);
if (parent_key_status != UPPL_RC_SUCCESS) {
status = UPPL_RC_ERR_PARENT_DOES_NOT_EXIST;
}
/** IsKeyExists
- * * @Description : This function checks whether the
+ * @Description : This function checks whether the
* logicalmemberport_id exists in DB
- * * * @param[in] : key_struct
- * * * @return : Success or associated error code
+ * @param[in] : data_type-UNC_DT_*,type of database
+ * key_values-vector of strings containing key values
+ * @return : Success or associated error code,UPPL_RC_SUCCESS/UPPL_RC_ERR*
* */
UpplReturnCode Kt_LogicalMemberPort::IsKeyExists(
+ OdbcmConnectionHandler *db_conn,
unc_keytype_datatype_t data_type,
- vector<string> key_values) {
+ const vector<string> &key_values) {
PhysicalLayer* physical_layer = PhysicalLayer::get_instance();
UpplReturnCode check_status = UPPL_RC_SUCCESS;
// Construct Primary key list
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
- vect_prim_keys.push_back(DOMAIN_NAME);
- vect_prim_keys.push_back(LP_PORT_ID);
- vect_prim_keys.push_back(LMP_SWITCH_ID);
- vect_prim_keys.push_back(LMP_PHYSICAL_PORT_ID);
+ vect_prim_keys.push_back(CTR_NAME_STR);
+ vect_prim_keys.push_back(DOMAIN_NAME_STR);
+ vect_prim_keys.push_back(LP_PORT_ID_STR);
+ vect_prim_keys.push_back(LMP_SWITCH_ID_STR);
+ vect_prim_keys.push_back(LMP_PHYSICAL_PORT_ID_STR);
// Construct TableAttrSchema structure
// TableAttrSchema holds table_name, primary key, attr_name
vector<TableAttrSchema> vect_table_attr_schema;
list< vector<TableAttrSchema> > row_list;
// controller_name
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// domain_name
- PhyUtil::FillDbSchema(DOMAIN_NAME, domain_name,
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_NAME, domain_name,
domain_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// port_id
- PhyUtil::FillDbSchema(LP_PORT_ID, port_id,
+ PhyUtil::FillDbSchema(unc::uppl::LMP_LP_PORT_ID, port_id,
port_id.length(), DATATYPE_UINT8_ARRAY_320,
vect_table_attr_schema);
// switch_id
- PhyUtil::FillDbSchema(LMP_SWITCH_ID, switch_id,
+ PhyUtil::FillDbSchema(unc::uppl::LMP_SWITCH_ID, switch_id,
switch_id.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
// physical_port_id
- PhyUtil::FillDbSchema(LMP_PHYSICAL_PORT_ID, physical_port_id,
+ PhyUtil::FillDbSchema(unc::uppl::LMP_PHYSICAL_PORT_ID, physical_port_id,
physical_port_id.length(),
DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- kt_logical_member_port_dbtableschema.set_table_name(
- UPPL_LOGICAL_MEMBER_PORT_TABLE);
+ kt_logical_member_port_dbtableschema.set_table_name(unc::uppl::
+ LOGICAL_MEMBERPORT_TABLE);
kt_logical_member_port_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_logical_member_port_dbtableschema.set_row_list(row_list);
// Send request to ODBC for controlle_common_table
ODBCM_RC_STATUS check_db_status = physical_layer->get_odbc_manager()->
- IsRowExists(data_type, kt_logical_member_port_dbtableschema);
+ IsRowExists(data_type, kt_logical_member_port_dbtableschema, db_conn);
if (check_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log error to log daemon
pfc_log_error("DB connection not available or cannot access DB");
}
/** PopulateDBSchemaForKtTable
- * * @Description : This function populates the DBAttrSchema to be used to
+ * @Description : This function populates the DBAttrSchema to be used to
* send request to ODBC
- * * * @param[in] : DBTableSchema, key_struct, operation_type
- * * * @return : Success or associated error code
+ * @param[in] : kt_dbtableschema- instance of DBTableSchema to be filled
+ * key_struct-void* to LMP key structure
+ * operation_type-UNC_OP_*
+ * val_struct-void* to kt val structure
+ * option1,option2-additional options for read operations,UNC_OPT1/OPT2_*
+ * vect_key_operations- instance of vector<ODBCMOperator>
+ * old_value_struct-void* to kt val structure
+ * row_status- value of CsRowStatus
+ * is_filtering-flag to indicate whether filter option is enabled
+ * is_state-flag to indicate whether datatype is DT_STATE
+ * @return : Success or associated error code,UPPL_RC_SUCCESS/ERR*
* */
void Kt_LogicalMemberPort::PopulateDBSchemaForKtTable(
+ OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_dbtableschema,
void* key_struct,
void* val_struct,
uint8_t operation_type,
+ uint32_t data_type,
uint32_t option1,
uint32_t option2,
vector<ODBCMOperator> &vect_key_operations,
obj_key_logical_member_port
->logical_port_key.domain_key.ctr_key.controller_name);
pfc_log_debug("controller_name: %s", controller_name.c_str());
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
vect_key_operations.push_back(unc::uppl::EQUAL);
// domain name
string domain_name = reinterpret_cast<const char*>(obj_key_logical_member_port
->logical_port_key.domain_key.domain_name);
pfc_log_debug("domain_name: %s", domain_name.c_str());
- PhyUtil::FillDbSchema(DOMAIN_NAME, domain_name,
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_NAME, domain_name,
domain_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
if (!domain_name.empty()) {
- vect_prim_keys.push_back(DOMAIN_NAME);
+ vect_prim_keys.push_back(DOMAIN_NAME_STR);
vect_key_operations.push_back(unc::uppl::EQUAL);
}
string port_id = reinterpret_cast<const char*>(obj_key_logical_member_port
->logical_port_key.port_id);
pfc_log_info("port_id: %s", port_id.c_str());
- PhyUtil::FillDbSchema(LMP_LP_PORT_ID, port_id,
+ PhyUtil::FillDbSchema(unc::uppl::LMP_LP_PORT_ID, port_id,
port_id.length(), DATATYPE_UINT8_ARRAY_320,
vect_table_attr_schema);
if (!port_id.empty()) {
- vect_prim_keys.push_back(LMP_LP_PORT_ID);
+ vect_prim_keys.push_back(LMP_LP_PORT_ID_STR);
vect_key_operations.push_back(unc::uppl::EQUAL);
}
// only parent key has to be considered for read_sibling_begin
if (operation_type == UNC_OP_READ_SIBLING_BEGIN ||
operation_type == UNC_OP_READ_SIBLING_COUNT) {
- vect_prim_keys.push_back(LMP_SWITCH_ID);
+ vect_prim_keys.push_back(LMP_SWITCH_ID_STR);
vect_key_operations.push_back(unc::uppl::GREATER);
switch_id = "";
} else if (!switch_id.empty()) {
- vect_prim_keys.push_back(LMP_SWITCH_ID);
+ vect_prim_keys.push_back(LMP_SWITCH_ID_STR);
vect_key_operations.push_back(unc::uppl::EQUAL);
}
pfc_log_info("switch_id: %s ", switch_id.c_str());
- PhyUtil::FillDbSchema(LMP_SWITCH_ID, switch_id,
+ PhyUtil::FillDbSchema(unc::uppl::LMP_SWITCH_ID, switch_id,
switch_id.length(),
DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
string physical_port_id = reinterpret_cast<const char*>(
obj_key_logical_member_port->physical_port_id);
pfc_log_info("physical_port_id: %s ", physical_port_id.c_str());
- PhyUtil::FillDbSchema(LMP_PHYSICAL_PORT_ID, physical_port_id,
+ PhyUtil::FillDbSchema(unc::uppl::LMP_PHYSICAL_PORT_ID, physical_port_id,
physical_port_id.length(),
DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
if (!physical_port_id.empty() &&
(operation_type != UNC_OP_READ_SIBLING_BEGIN &&
operation_type != UNC_OP_READ_SIBLING_COUNT)) {
- vect_prim_keys.push_back(LMP_PHYSICAL_PORT_ID);
+ vect_prim_keys.push_back(LMP_PHYSICAL_PORT_ID_STR);
vect_key_operations.push_back(unc::uppl::GREATER);
}
if (physical_port_id.empty() &&
operation_type > UNC_OP_READ &&
vect_prim_keys.size() >= 1) { // Key apart from controller
- vect_prim_keys.push_back(LMP_PHYSICAL_PORT_ID);
+ vect_prim_keys.push_back(LMP_PHYSICAL_PORT_ID_STR);
vect_key_operations.push_back(unc::uppl::GREATER);
}
if ((operation_type == UNC_OP_READ_NEXT ||
vect_key_operations.push_back(unc::uppl::MULTIPLE_QUERY);
}
PhyUtil::reorder_col_attrs(vect_prim_keys, vect_table_attr_schema);
- kt_dbtableschema.set_table_name(UPPL_LOGICAL_MEMBER_PORT_TABLE);
+ kt_dbtableschema.set_table_name(unc::uppl::LOGICAL_MEMBERPORT_TABLE);
kt_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_dbtableschema.set_row_list(row_list);
}
/** FillLogicalMemberPortValueStructure
- * * @Description : This function populates val_ctr by querying database
- * * * @param[in] : switch common table dbtable schema, openflow switch
- * db schema, value structure and max_rep_ct, operation type
- * * * @return : Success or associated error code
+ * @Description : This function populates val_ctr by querying database
+ * @param[in] :
+ * kt_logical_member_port_dbtableschema-DBTableSchema instance to be filled
+ * max_rep_ct-maximum no. of records to be read
+ * operation_type-UNC_OP_*,type of database
+ * logical_mem_port-instance of vector<key_logical_member_port_t>
+ * @return : Success or associated error code,UPPL_RC_SUCCESS/ERR*
* */
void Kt_LogicalMemberPort::FillLogicalMemberPortValueStructure(
+ OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_logical_member_port_dbtableschema,
uint32_t &max_rep_ct,
uint32_t operation_type,
vector<key_logical_member_port_t> &logical_mem_port) {
- // populate IPC value structure based on the response recevied from DB
- list < vector<TableAttrSchema> > res_logical_member_port_row_list =
+ // populate IPC value structure based on the response received from DB
+ list < vector<TableAttrSchema> >& res_logical_member_port_row_list =
kt_logical_member_port_dbtableschema.get_row_list();
list < vector<TableAttrSchema> > :: iterator res_logical_member_port_iter =
res_logical_member_port_row_list.begin();
++vect_logical_member_port_iter) {
// populate values from controller_common_table
TableAttrSchema tab_schema = (*vect_logical_member_port_iter);
- string attr_name = tab_schema.table_attribute_name;
- string attr_value;
- if (attr_name == LMP_SWITCH_ID) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_256);
- memcpy(obj_key_logical_mem_port.switch_id,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("switch_id : %s", attr_value.c_str());
- }
- if (attr_name == LMP_PHYSICAL_PORT_ID) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_key_logical_mem_port.physical_port_id,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("physical_port_id: %s", attr_value.c_str());
- }
- if (attr_name == LMP_LP_PORT_ID) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_320);
- memcpy(obj_key_logical_mem_port.logical_port_key.port_id,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("port_id: %s", attr_value.c_str());
- }
- if (attr_name == DOMAIN_NAME) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_key_logical_mem_port.logical_port_key.domain_key.domain_name,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("domain_name: %s", attr_value.c_str());
- }
- if (attr_name == CTR_NAME) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_key_logical_mem_port.logical_port_key.domain_key.
- ctr_key.controller_name,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("controller_name: %s", attr_value.c_str());
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
+ switch (attr_name) {
+ case unc::uppl::LMP_SWITCH_ID:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_key_logical_mem_port.switch_id,
+ DATATYPE_UINT8_ARRAY_256);
+ pfc_log_debug("switch_id : %s", obj_key_logical_mem_port.switch_id);
+ break;
+
+ case unc::uppl::LMP_PHYSICAL_PORT_ID:
+ PhyUtil::GetValueFromDbSchemaStr(
+ tab_schema,
+ obj_key_logical_mem_port.physical_port_id,
+ DATATYPE_UINT8_ARRAY_32);
+ pfc_log_debug("physical_port_id: %s",
+ obj_key_logical_mem_port.physical_port_id);
+ break;
+
+ case unc::uppl::LMP_LP_PORT_ID:
+ PhyUtil::GetValueFromDbSchemaStr(
+ tab_schema,
+ obj_key_logical_mem_port.logical_port_key.port_id,
+ DATATYPE_UINT8_ARRAY_320);
+ pfc_log_debug("port_id: %s",
+ obj_key_logical_mem_port.logical_port_key.port_id);
+ break;
+
+ case unc::uppl::DOMAIN_NAME:
+ PhyUtil::GetValueFromDbSchemaStr(
+ tab_schema,
+ obj_key_logical_mem_port.logical_port_key.domain_key.domain_name,
+ DATATYPE_UINT8_ARRAY_32);
+ pfc_log_debug(
+ "domain_name: %s",
+ obj_key_logical_mem_port.logical_port_key.domain_key.domain_name);
+ break;
+
+ case unc::uppl::CTR_NAME:
+ PhyUtil::GetValueFromDbSchemaStr(
+ tab_schema,
+ obj_key_logical_mem_port.logical_port_key.domain_key.
+ ctr_key.controller_name,
+ DATATYPE_UINT8_ARRAY_32);
+ pfc_log_debug("controller_name: %s",
+ obj_key_logical_mem_port.logical_port_key.domain_key.
+ ctr_key.controller_name);
+ break;
+
+ default:
+ pfc_log_info("Ignoring LogicalMemberPort attribute %d", attr_name);
+ break;
}
}
logical_mem_port.push_back(obj_key_logical_mem_port);
/** PerformRead
- * * @Description : This function reads the instance of
+ * @Description : This function reads the instance of
* KT_LogicalMemberPort based on operation type -
* READ, READ_SIBLING_BEGIN, READ_SIBLING
- * * * @param[in] : key_struct, value_struct, ipc session id,
- * configuration id, option1, option2, data_type,
- * operation type, max_rep_ct
- * * * @return : Success or associated error code
+ * @param[in] : key_struct-void* to LMP key structure
+ * value_struct-void* to kt value structure
+ * session_id-ipc session id used for TC validation
+ * configuration_id-ipcconfiguration id used for TC validation
+ * option1,option2-UNC_OPT1/OPT2_*,additional info for read operations
+ * data_type-UNC_DT_*,type of database
+ * operation_type-type of operation,UNC_OP_READ*
+ * max_rep_ct-max.no of records to be read
+ * @param[out]: sess-ServerSession object where the arguments present
+ * @return : Success or associated error code,UPPL_RC_SUCCESS/ERR*
* */
-UpplReturnCode Kt_LogicalMemberPort::PerformRead(uint32_t session_id,
- uint32_t configuration_id,
- void* key_struct,
- void* value_struct,
- uint32_t data_type,
- uint32_t operation_type,
- ServerSession &sess,
- uint32_t option1,
- uint32_t option2,
- uint32_t max_rep_ct) {
- pfc_log_info("Inside PerformRead option1=%d option2=%d max_rep_ct=%d",
- option1, option2, max_rep_ct);
+UpplReturnCode Kt_LogicalMemberPort::PerformRead(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
+ uint32_t configuration_id,
+ void* key_struct,
+ void* value_struct,
+ uint32_t data_type,
+ uint32_t operation_type,
+ ServerSession &sess,
+ uint32_t option1,
+ uint32_t option2,
+ uint32_t max_rep_ct) {
pfc_log_info("Inside PerformRead operation_type=%d data_type=%d",
operation_type, data_type);
physical_response_header rsh = {session_id,
return UPPL_RC_SUCCESS;
}
vector<key_logical_member_port_t> vect_logical_mem_port;
- read_status = ReadLogicalMemberPortValFromDB(key_struct,
+ read_status = ReadLogicalMemberPortValFromDB(db_conn,
+ key_struct,
data_type,
operation_type,
max_rep_ct,
}
/** ReadLogicalMemberPortValFromDB
- * * @Description : This function reads the instance of Kt_LogicalMemberPortbased on
- * operation type - READ, READ_SIBLING_BEGIN, READ_SIBLING
- * from data_base
- * * * @param[in] : key_struct, value_struct, ipc session id,
- * configuration id,data_type, operation type, max_rep_ct
- * * * @return : Success or associated error code
+ * @Description : This function reads the instance of Kt_LogicalMemberPort
+ * based on operation type - READ, READ_SIBLING_BEGIN,
+ * READ_SIBLING from data_base
+ * @param[in] : key_struct-void* to LMP key structure
+ * data_type-UNC_DT_*,type of database
+ * operation_type-UNC_OP_*,type of operation
+ * max_rep_ct-max. no of records to be read
+ * logical_mem_port-instance of vector<key_logical_member_port_t>
+ * is_state-flag to indicate whether datatype is DT_STATE
+ * @return : Success or associated error code,UPPL_RC_SUCCESS/ERR*
* */
UpplReturnCode Kt_LogicalMemberPort::ReadLogicalMemberPortValFromDB(
+ OdbcmConnectionHandler *db_conn,
void* key_struct,
uint32_t data_type,
uint32_t operation_type,
uint32_t &max_rep_ct,
vector<key_logical_member_port_t> &logical_mem_port,
pfc_bool_t is_state) {
+ if (operation_type < UNC_OP_READ) {
+ // Unsupported operation type for this function
+ return UPPL_RC_SUCCESS;
+ }
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode read_status = UPPL_RC_SUCCESS;
ODBCM_RC_STATUS read_db_status = ODBCM_RC_SUCCESS;
vector<ODBCMOperator> prim_keys_operator;
void *old_val_struct;
PopulateDBSchemaForKtTable(
- kt_logical_member_port_dbtableschema,
+ db_conn, kt_logical_member_port_dbtableschema,
key_struct, NULL,
- operation_type, 0, 0,
+ operation_type, data_type, 0, 0,
prim_keys_operator, old_val_struct);
-
+ pfc_log_debug("Operation type is %d", operation_type);
if (operation_type == UNC_OP_READ) {
read_db_status = physical_layer->get_odbc_manager()->
GetOneRow((unc_keytype_datatype_t)data_type,
- kt_logical_member_port_dbtableschema);
+ kt_logical_member_port_dbtableschema, db_conn);
} else if (prim_keys_operator.empty()) {
+ pfc_log_debug("LMP:Read Bulk");
read_db_status = physical_layer->get_odbc_manager()->
GetBulkRows((unc_keytype_datatype_t)data_type, max_rep_ct,
kt_logical_member_port_dbtableschema,
- (unc_keytype_operation_t)operation_type);
- } else if (!prim_keys_operator.empty()) {
- read_db_status = physical_layer->get_odbc_manager()->
+ (unc_keytype_operation_t)operation_type, db_conn);
+ } else if (!prim_keys_operator.empty() &&
+ operation_type == UNC_OP_READ_SIBLING) {
+ uint32_t no_of_query = 2; // LMP has 2 primary keys other than LP
+ uint32_t index = 0;
+ for (; index < no_of_query; ++index) {
+ if (kt_logical_member_port_dbtableschema.primary_keys_.size() < 3) {
+ pfc_log_debug("No record found");
+ read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
+ break;
+ }
+ pfc_log_debug("LMP:Read Sibling");
+ read_db_status = physical_layer->get_odbc_manager()-> \
+ GetBulkRows((unc_keytype_datatype_t)data_type, max_rep_ct,
+ kt_logical_member_port_dbtableschema,
+ (unc_keytype_operation_t)UNC_OP_READ_BULK,
+ db_conn);
+ if (read_db_status == ODBCM_RC_SUCCESS) {
+ uint32_t max_rep_ct_new = 0;
+ FillLogicalMemberPortValueStructure(db_conn,
+ kt_logical_member_port_dbtableschema,
+ max_rep_ct_new,
+ operation_type,
+ logical_mem_port);
+ pfc_log_debug("max_rep_ct_new=%d max_rep_ct=%d",
+ max_rep_ct_new, max_rep_ct);
+ for (uint32_t uindex = 1; uindex < max_rep_ct_new; uindex++) {
+ pfc_log_debug("Ktlink:Row list Removed");
+ kt_logical_member_port_dbtableschema.row_list_.pop_front();
+ }
+ max_rep_ct -= max_rep_ct_new;
+ // Update the primary key vector
+ kt_logical_member_port_dbtableschema.primary_keys_.pop_back();
+ read_status = UPPL_RC_SUCCESS;
+ } else if (read_db_status == ODBCM_RC_CONNECTION_ERROR) {
+ read_status = UPPL_RC_ERR_DB_ACCESS;
+ pfc_log_error("Read operation has failed with error %d",
+ read_db_status);
+ return read_status;
+ } else if (read_db_status == ODBCM_RC_RECORD_NOT_FOUND) {
+ pfc_log_debug("No record found");
+ read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
+ // Update the primary key vector
+ kt_logical_member_port_dbtableschema.primary_keys_.pop_back();
+ }
+ } // for end
+ if (logical_mem_port.empty() && index == 2) {
+ pfc_log_debug("No record found");
+ read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
+ } else if (!logical_mem_port.empty()) {
+ max_rep_ct = logical_mem_port.size();
+ read_status = UPPL_RC_SUCCESS;
+ }
+ return read_status;
+ } else if (operation_type == UNC_OP_READ_SIBLING_BEGIN) {
+ pfc_log_debug("LMP:Read Sibling Begin");
+ read_db_status = physical_layer->get_odbc_manager()->
GetSiblingRows((unc_keytype_datatype_t)data_type, max_rep_ct,
kt_logical_member_port_dbtableschema,
prim_keys_operator,
- (unc_keytype_operation_t)operation_type);
+ (unc_keytype_operation_t)operation_type, db_conn);
}
if (read_db_status == ODBCM_RC_RECORD_NOT_FOUND) {
pfc_log_debug("No record found");
read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
return read_status;
+ } else if (read_db_status == ODBCM_RC_CONNECTION_ERROR) {
+ read_status = UPPL_RC_ERR_DB_ACCESS;
+ pfc_log_error("Read operation has failed with error %d", read_db_status);
+ return read_status;
} else if (read_db_status != ODBCM_RC_SUCCESS) {
read_status = UPPL_RC_ERR_DB_GET;
// log error to log daemon
pfc_log_info("Read operation has failed with error %d", read_db_status);
return read_status;
}
- FillLogicalMemberPortValueStructure(kt_logical_member_port_dbtableschema,
+ FillLogicalMemberPortValueStructure(db_conn,
+ kt_logical_member_port_dbtableschema,
max_rep_ct,
operation_type,
logical_mem_port);
}
/** Fill_Attr_Syntax_Map
- * * @Description : This function fills the attributes associated
+ * @Description : This function fills the attributes associated
* with the class
- * * * @param[in] : void
- * * * @return : void
+ * @param[in] : void
+ * @return : void
* */
void Kt_LogicalMemberPort::Fill_Attr_Syntax_Map() {
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map;
Kt_Class_Attr_Syntax objKeyAttrSyntax1 =
{ PFC_IPCTYPE_STRING, 0, 0, 1, 256, true, ""};
- attr_syntax_map[LMP_SWITCH_ID] = objKeyAttrSyntax1;
+ attr_syntax_map[LMP_SWITCH_ID_STR] = objKeyAttrSyntax1;
Kt_Class_Attr_Syntax objKeyAttrSyntax2 =
{ PFC_IPCTYPE_STRING, 0, 0, 1, 32, true, ""};
- attr_syntax_map[LMP_PHYSICAL_PORT_ID] = objKeyAttrSyntax2;
+ attr_syntax_map[LMP_PHYSICAL_PORT_ID_STR] = objKeyAttrSyntax2;
Kt_Class_Attr_Syntax objKeyAttrSyntax3 =
{ PFC_IPCTYPE_STRING, 0, 0, 1, 291, true, ""};
- attr_syntax_map[LMP_LP_PORT_ID] = objKeyAttrSyntax3;
+ attr_syntax_map[LMP_LP_PORT_ID_STR] = objKeyAttrSyntax3;
Kt_Class_Attr_Syntax objKeyAttr1Syntax4 =
{ PFC_IPCTYPE_UINT8, 0, 0, 1, 32, true, "" };
- attr_syntax_map[DOMAIN_NAME] = objKeyAttr1Syntax4;
+ attr_syntax_map[DOMAIN_NAME_STR] = objKeyAttr1Syntax4;
Kt_Class_Attr_Syntax objKeyAttr1Syntax5 =
{ PFC_IPCTYPE_UINT8, 0, 0, 1, 32, true, "" };
- attr_syntax_map[CTR_NAME] = objKeyAttr1Syntax5;
-}
-
-/** IsLogicalMemberPortReferred
- * * @Description : This function returns true if given controller_name,
- * domain and port_id are referred in logical member port table
- * * @param[in] : controller_name, domain_name, port_id
- * * @return : PFC_TRUE/PFC_FALSE
- */
-pfc_bool_t Kt_LogicalMemberPort::IsLogicalMemberPortReferred(
- string controller_name,
- string domain_name,
- string port_id) {
- pfc_bool_t is_ref = PFC_FALSE;
- PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
- DBTableSchema kt_dbtableschema;
- vector<TableAttrSchema> vect_table_attr_schema;
- TableAttrSchema kt_logical_port_table_attr_schema;
- list< vector<TableAttrSchema> > row_list;
- vector<string> vect_prim_keys;
-
- // Check whether controller_name1 is reffered
- vect_prim_keys.push_back("controller_name");
- vect_prim_keys.push_back("domain_name");
- vect_prim_keys.push_back("port_id");
- // controller_name
- PhyUtil::FillDbSchema("controller_name", controller_name,
- controller_name.length(),
- DATATYPE_UINT8_ARRAY_32, vect_table_attr_schema);
- PhyUtil::FillDbSchema("domain_name", domain_name,
- domain_name.length(),
- DATATYPE_UINT8_ARRAY_32, vect_table_attr_schema);
- PhyUtil::FillDbSchema("port_id", port_id,
- port_id.length(),
- DATATYPE_UINT8_ARRAY_320, vect_table_attr_schema);
- kt_dbtableschema.set_table_name("logical_member_port_table");
- kt_dbtableschema.set_primary_keys(vect_prim_keys);
- row_list.push_back(vect_table_attr_schema);
- kt_dbtableschema.set_row_list(row_list);
-
- // Send request to ODBC for logical_member_port_table
- ODBCM_RC_STATUS read_db_status = physical_layer->
- get_odbc_manager()->IsRowExists(UNC_DT_STATE,
- kt_dbtableschema);
- if (read_db_status == ODBCM_RC_ROW_EXISTS) {
- // read count
- pfc_log_debug("Given logical_port id is referred in memberport - 1");
- is_ref = PFC_TRUE;
- }
- return is_ref;
+ attr_syntax_map[CTR_NAME_STR] = objKeyAttr1Syntax5;
+ attr_syntax_map_all[UNC_KT_LOGICAL_MEMBER_PORT] = attr_syntax_map;
}
/** ReadInternal
- * * @Description : This function reads the given instance of KT_Port
- ** * @param[in] : session_id - ipc session id used for TC validation
- * key_struct - the key for the kt port instance
- * data_type - UNC_DT_* , read allowed in state
- * * @return : UPPL_RC_SUCCESS is returned when the response
+ * @Description : This function reads the given instance of KT_Port
+ * @param[in] : session_id - ipc session id used for TC validation
+ * key_struct - the key for the ktLMP instance
+ * val_struct - NULL
+ * operation_type-UNC_OP_READ*,type of read operation
+ * data_type - UNC_DT_* , read allowed in state,type of database
+ * @return : UPPL_RC_SUCCESS is returned when the response
* is added to ipc session successfully.
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
UpplReturnCode Kt_LogicalMemberPort::ReadInternal(
+ OdbcmConnectionHandler *db_conn,
vector<void *> &key_val,
vector<void *> &val_struct,
uint32_t data_type,
// Get read response from database
void *key_struct = key_val[0];
vector<key_logical_member_port_t> logical_mem_port;
- UpplReturnCode read_status = ReadLogicalMemberPortValFromDB(key_struct,
+ UpplReturnCode read_status = ReadLogicalMemberPortValFromDB(db_conn,
+ key_struct,
data_type,
operation_type,
max_rep_ct,
logical_mem_port);
+ pfc_log_info(
+ "ReadLogicalMemberPortValFromDB returned %d with response size %d",
+ read_status, static_cast<int>(logical_mem_port.size()));
key_val.clear();
- if (read_status != UPPL_RC_SUCCESS) {
- pfc_log_error("ReadValFromDB returned %d with response size %d",
- read_status,
- static_cast<int>(logical_mem_port.size()));
- } else {
- pfc_log_debug(
- "ReadLogicalMemberPortValFromDB returned %d with response size %d",
- read_status, static_cast<int>(logical_mem_port.size()));
+ if (read_status == UPPL_RC_SUCCESS) {
for (unsigned int iIndex = 0 ; iIndex < logical_mem_port.size();
++iIndex) {
key_logical_member_port_t *key_mem_port = new
#include "itc_kt_boundary.hh"
#include "itc_kt_switch.hh"
#include "odbcm_db_varbind.hh"
+#include "ipct_util.hh"
+#include "itc_read_request.hh"
using unc::uppl::PhysicalLayer;
using unc::uppl::ODBCMOperator;
-/** Constructor
- * * @Description : This function instantiates parent and child key types for
- * kt_logicalport
- * * * @param[in] : None
- * * * @return : None
- * */
+/**
+ * @Description : This function initializes member variables
+ * and fills the attribute syntax map used for validation
+ * @param[in] : None
+ * @return : None
+ **/
Kt_LogicalPort::Kt_LogicalPort() {
- parent = NULL;
for (int i = 0; i < UNC_KT_LOGICAL_PORT_CHILD_COUNT; ++i) {
child[i] = NULL;
}
// Populate structure to be used for syntax validation
- Fill_Attr_Syntax_Map();
+ if (attr_syntax_map_all.find(UNC_KT_LOGICAL_PORT) ==
+ attr_syntax_map_all.end()) {
+ Fill_Attr_Syntax_Map();
+ }
}
-/** Destructor
- * * @Description : This function clears the parent and child key types
- * instances for kt_logicalport
- * * * @param[in] : None
- * * * @return : None
- * */
+/**
+ * @Description : This function frees the child key instances
+ * instances for kt_logicalport
+ * @param[in] : None
+ * @return : None
+ **/
Kt_LogicalPort::~Kt_LogicalPort() {
- if (parent != NULL) {
- delete parent;
- parent = NULL;
- }
// Delete all child objects
for (int i = 0; i < UNC_KT_LOGICAL_PORT_CHILD_COUNT; ++i) {
if (child[i] != NULL) {
}
}
-/** GetChildClassPointer
- * * @Description : This function creates a new child class instance
- * class of KtLogicalPort based on index passed
- * * @param[in] : KtLogicalPortChildClass
- * * @return : Kt_Base*
- */
+/**
+ * @Description : This function creates a new child class instance
+ * class of KtLogicalPort based on index passed
+ * @param[in] : KIndex - child class index enum
+ * @return : Kt_Base* - The child class pointer
+ **/
Kt_Base* Kt_LogicalPort::GetChildClassPointer(KtLogicalPortChildClass KIndex) {
switch (KIndex) {
case KIdxLogicalMemberPort: {
return child[KIndex];
}
-/**DeleteKeyInstance
- * * @Description : This function deletes given instance of UNC_KT_LOGICAL_PORT
- * * * @param[in] : key_struct and data type
- * * * @return : Success or associated error code
- * */
-UpplReturnCode Kt_LogicalPort::DeleteKeyInstance(void* key_struct,
- uint32_t data_type,
- uint32_t key_type) {
+/**
+ * @Description : This function is used to delete KT_LOGICAL_PORT instance in
+ * database table using key_ctr provided in IPC request
+ * @param[in] : key_struct - void pointer to be cast into required key type
+ * data type - UNC_DT_*,delete allowed only in STATE and IMPORT
+ * key_type - indicates the key type
+ * @return : indicates the delete status of the row -
+ * UPPL_RC_SUCCESS is returned when delete is done successfully.
+ * UPPL_RC_ERR_* is returned when delete is failed
+ **/
+UpplReturnCode Kt_LogicalPort::DeleteKeyInstance(
+ OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ uint32_t data_type,
+ uint32_t key_type) {
UpplReturnCode delete_status = UPPL_RC_SUCCESS;
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
} else {
pfc_log_debug("Delete instance for logical port is supported");
}
-
+ // Notify port to update logicalportid as invalid
+ void *value_struct = NULL;
+ vector<uint32_t> vectOperStatus;
+ // call below function to fill port and switch id and call port function
+ // to update logicalport id as invalid PFC_TRUE is to mention call is
+ // from deletekeyinstance
+ HandleOperDownCriteriaFromPortStatus(db_conn, data_type,
+ key_struct,
+ value_struct,
+ vectOperStatus,
+ PFC_TRUE);
key_logical_port_t *obj_key_logical_port=
reinterpret_cast<key_logical_port_t*>(key_struct);
string controller_name =
(const char*)obj_key_logical_port->domain_key.ctr_key.controller_name;
- pfc_log_info("controller name: %s", controller_name.c_str());
string domain_name= (const char*)obj_key_logical_port->domain_key.domain_name;
string logical_port_id = (const char*)obj_key_logical_port->port_id;
(KtLogicalPortChildClass)child_class);
if (child[child_class] != NULL) {
UpplReturnCode ch_delete_status = child[child_class]->DeleteKeyInstance(
- child_key_struct,
+ db_conn, child_key_struct,
data_type,
UNC_KT_LOGICAL_MEMBER_PORT);
delete child[child_class];
FreeChildKeyStruct(child_class, child_key_struct);
}
}
- // Structure used to send request to ODBC
+
DBTableSchema kt_logicalport_dbtableschema;
// Construct Primary key list
vector<string> vect_prim_keys;
if (!controller_name.empty()) {
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
}
if (!domain_name.empty()) {
- vect_prim_keys.push_back(DOMAIN_NAME);
+ vect_prim_keys.push_back(DOMAIN_NAME_STR);
}
if (!logical_port_id.empty()) {
- vect_prim_keys.push_back(LP_PORT_ID);
+ vect_prim_keys.push_back(LP_PORT_ID_STR);
}
- // Construct TableAttrSchema structure
- // TableAttrSchema holds table_name, primary key, attr_name
vector<TableAttrSchema> vect_table_attr_schema;
- TableAttrSchema kt_logicalport_table_attr_schema;
list< vector<TableAttrSchema> > row_list;
// controller_name
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// domain_name
- pfc_log_info("domain name: %s", domain_name.c_str());
- PhyUtil::FillDbSchema(DOMAIN_NAME, domain_name,
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_NAME, domain_name,
domain_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// port_id
- PhyUtil::FillDbSchema(LP_PORT_ID, logical_port_id,
+ PhyUtil::FillDbSchema(unc::uppl::LP_PORT_ID, logical_port_id,
logical_port_id.length(), DATATYPE_UINT8_ARRAY_320,
vect_table_attr_schema);
// Send request to ODBC for logicalport_table delete
- kt_logicalport_dbtableschema.set_table_name(UPPL_LOGICALPORT_TABLE);
+ kt_logicalport_dbtableschema.set_table_name(unc::uppl::LOGICALPORT_TABLE);
kt_logicalport_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_logicalport_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS delete_db_status = physical_layer->get_odbc_manager()-> \
DeleteOneRow((unc_keytype_datatype_t)data_type,
- kt_logicalport_dbtableschema);
- pfc_log_info("DeleteOneRow response from DB is %d", delete_db_status);
+ kt_logicalport_dbtableschema, db_conn);
if (delete_db_status != ODBCM_RC_SUCCESS) {
if (delete_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log fatal error to log daemon
} else {
// deletion success send notification to boundary to
// update operstatus to invalid
- int err = InvokeBoundaryNotifyOperStatus(data_type, key_struct);
+ delete_status = UPPL_RC_SUCCESS;
+ int err = InvokeBoundaryNotifyOperStatus(db_conn, data_type, key_struct);
if (err != UPPL_RC_SUCCESS) {
pfc_log_error(
"Delete instance: notify request for boundary is failed %d", err);
}
- // Notify port to update logicalportid as invalid
- void *value_struct = NULL;
- vector<uint32_t> vectOperStatus;
- // call below function to fill port and switch id and call port function
- // to update logicalport id as invalid PFC_TRUE is to mention call is
- // from deletekeyinstance
- HandleOperDownCriteriaFromPortStatus(data_type,
- key_struct,
- value_struct,
- vectOperStatus,
- PFC_TRUE);
}
return delete_status;
}
-/** ReadInternal
- * * @Description :This function reads the given instance of UNC_KT_LOGICAL_PORT
- * * * @param[in] : key_struct, value_struct, data_type
- * * * @return : Success or associated error code
+/**
+ * @Description : This function is used to read KT_LOGICAL_PORT instance
+ * in database table using key_ctr provided in IPC request
+ * @param[in] : key_val - vector to hold the key struct
+ * val_struct - vector to hold the val struct
+ * data_type - indicates the data base type i.e. UNC_DT_STATE
+ * or UNC_DT_IMPORT etc
+ * operation_type - indicates the operation type supported i.e.
+ * UNC_OP_READ
+ * @return : It returns the read status of a row in logical port table
+ * UPPL_RC_SUCCESS - if read operation is success
+ * UPPL_RC_ERR_* - if read operation is a failure
* */
-UpplReturnCode Kt_LogicalPort::ReadInternal(
- vector<void *> &key_val,
- vector<void *> &val_struct,
- uint32_t data_type,
- uint32_t operation_type) {
+UpplReturnCode Kt_LogicalPort::ReadInternal(OdbcmConnectionHandler *db_conn,
+ vector<void *> &key_val,
+ vector<void *> &val_struct,
+ uint32_t data_type,
+ uint32_t operation_type) {
pfc_log_debug("Inside ReadInternal of UNC_KT_LOGICAL_PORT");
vector<key_logical_port_t> vect_logicalport_id;
vector<val_logical_port_t> vect_val_logical_port;
}
// Get read response from database
UpplReturnCode read_status = ReadLogicalPortValFromDB(
- key_struct,
+ db_conn, key_struct,
void_val_struct,
data_type,
operation_type,
vect_logicalport_id);
key_val.clear();
val_struct.clear();
- if (read_status != UPPL_RC_SUCCESS) {
- pfc_log_error("Read operation has failed");
- } else {
+ if (read_status == UPPL_RC_SUCCESS) {
pfc_log_debug("Read operation is success");
for (unsigned int iIndex = 0 ; iIndex < vect_val_logical_port_st.size();
++iIndex) {
return read_status;
}
-/** ReadBulk
- * * @Description : This function reads the max_rep_ct number of instances of
- * the UNC_KT_LOGICAL_PORT
- * * * @param[in] : configuration id, key_struct, value_struct,
- * data_type, option1, option2 and max_rep_ct
- * * * @return : Success or associated error code
- * */
-UpplReturnCode Kt_LogicalPort::ReadBulk(void* key_struct,
+/**
+ * @Description : This function reads rows from running logical port table
+ * depending on the max_rep_ct number of instances specified
+ * @param[in] : key_struct - void pointer to be cast into logical port type
+ * data_type - indicates the data base type - read is supported
+ * on UNC_DT_STATE and UNC_DT_IMPORT
+ * max_rep_ct - specifies the maximum repetition count for read
+ * bulk operation
+ * child_index - specifies the child index
+ * parent_call - bool variable to check whether parent call
+ * is made
+ * is_read_next - bool variable to indicate whether this
+ * function is invoked from readnext
+ * @return : It returns the read bulk operation status in
+ * logical port table
+ * UPPL_RC_SUCCESS - if read operation is success
+ * UPPL_RC_ERR_* - if read operation is a failure
+ **/
+UpplReturnCode Kt_LogicalPort::ReadBulk(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
- uint32_t option1,
- uint32_t option2,
uint32_t &max_rep_ct,
int child_index,
pfc_bool_t parent_call,
- pfc_bool_t is_read_next) {
+ pfc_bool_t is_read_next,
+ ReadRequest *read_req) {
UpplReturnCode read_status = UPPL_RC_SUCCESS;
key_logical_port_t obj_key_logical_port=
*(reinterpret_cast<key_logical_port_t*>(key_struct));
}
string str_controller_name = reinterpret_cast<char *>(obj_key_logical_port.
domain_key.ctr_key.controller_name);
- pfc_log_info("controller name: %s", str_controller_name.c_str());
+ pfc_log_debug("controller name: %s", str_controller_name.c_str());
string str_domain_name = reinterpret_cast<char *>(obj_key_logical_port.
domain_key.domain_name);
string str_logicalport_id =
vect_key_value.push_back(str_domain_name);
vect_key_value.push_back(str_logicalport_id);
UpplReturnCode key_exist_status = IsKeyExists(
- (unc_keytype_datatype_t)data_type,
+ db_conn, (unc_keytype_datatype_t)data_type,
vect_key_value);
if (key_exist_status == UPPL_RC_SUCCESS) {
log_port_exists = PFC_TRUE;
}
void *val_struct = NULL;
// Read the logical port values based on given key structure
- read_status = ReadBulkInternal(key_struct, val_struct, data_type,
+ read_status = ReadBulkInternal(db_conn, key_struct, val_struct, data_type,
max_rep_ct, vect_val_logical_port_st,
vect_logicalport_id);
for (; logicalport_iter != vect_logicalport_id.end();
++logicalport_iter, ++vect_iter) {
pfc_log_debug("Iterating value entries...");
- PhysicalCore *physical_core = PhysicalLayer::get_instance()->
- get_physical_core();
- InternalTransactionCoordinator *itc_trans =
- physical_core->get_internal_transaction_coordinator();
if (log_port_exists == PFC_FALSE) {
pfc_log_debug(
"Adding logical_port - '%s' to session",
UNC_KT_LOGICAL_PORT, IS_KEY,
reinterpret_cast<void*>(key_buffer)
};
- itc_trans->AddToBuffer(obj_key_buffer);
+ read_req->AddToBuffer(obj_key_buffer);
val_logical_port_st_t *val_buffer = new val_logical_port_st_t
(*vect_iter);
BulkReadBuffer obj_value_buffer = {
UNC_KT_LOGICAL_PORT, IS_STATE_VALUE,
reinterpret_cast<void*>(val_buffer)
};
- itc_trans->AddToBuffer(obj_value_buffer);
+ read_req->AddToBuffer(obj_value_buffer);
BulkReadBuffer obj_sep_buffer = {
UNC_KT_LOGICAL_PORT, IS_SEPARATOR, NULL
};
- itc_trans->AddToBuffer(obj_sep_buffer);
+ read_req->AddToBuffer(obj_sep_buffer);
--max_rep_ct;
if (max_rep_ct == 0) {
pfc_log_debug("max_rep_ct reached zero, so returning");
log_port_exists = PFC_FALSE;
str_logicalport_id =
reinterpret_cast<char *>((*logicalport_iter).port_id);
- int st_child_index =
+ int st_child_index = KIdxLogicalMemberPort;
+ pfc_log_debug("child_index=%d st_child_index=%d", child_index, st_child_index);
+/*
(child_index >= 0 && child_index <= KIdxLogicalMemberPort) \
? child_index+1 : KIdxLogicalMemberPort;
+*/
for (int kIdx = st_child_index; kIdx <= KIdxLogicalMemberPort;
++kIdx) {
pfc_log_debug("Iterating Logical port child %d", kIdx);
}
pfc_log_debug("Calling child %d read bulk", kIdx);
UpplReturnCode ch_read_status = child[kIdx]->ReadBulk(
- child_key_struct,
+ db_conn, child_key_struct,
data_type,
- option1,
- option2,
max_rep_ct,
-1,
true,
- is_read_next);
+ is_read_next,
+ read_req);
pfc_log_debug("ReadBulk response from child %d is %d",
kIdx, ch_read_status);
delete child[kIdx];
// reset child index
child_index = -1;
}
+ } else if (read_status == UPPL_RC_ERR_DB_ACCESS) {
+ pfc_log_debug("KtLogicalPort ReadBulk - Returning DB Access Error");
+ return read_status;
}
if (max_rep_ct > 0 && parent_call == false) {
pfc_log_debug("max_rep_ct is %d and parent_call is %d, calling parent",
str_controller_name.c_str(),
str_controller_name.length()+1);
read_status = nextKin.ReadBulk(
- reinterpret_cast<void *>(&nextkin_key_struct),
+ db_conn, reinterpret_cast<void *>(&nextkin_key_struct),
data_type,
- option1, option2, max_rep_ct,
+ max_rep_ct,
0,
false,
- is_read_next);
+ is_read_next,
+ read_req);
pfc_log_debug("read status from next kin Kt_Domain is %d",
read_status);
return UPPL_RC_SUCCESS;
return read_status;
}
-/** ReadBulkInternal
- * * @Description : This function reads the max_rep_ct number of instances of
- * the UNC_KT_LOGICAL_PORT
- * * * @param[in] : key_struct, value_struct, data_type, max_rep_ct
- * * * @return : Success or associated error code
- * */
+/**
+ * @Description : This function reads the max_rep_ct number of instances of
+ * the UNC_KT_LOGICAL_PORT
+ * @param[in] : key_struct - void pointer to be cast into logical port key
+ * type
+ * val_struct - void pointer to be cast into logical port value
+ * type
+ * data_type - indicates the data base type i.e UNC_DT_STATE
+ * or UNC_DT_IMPORT
+ * max_rep_ct - specifies the maximum repetition count for
+ * read bulk operation
+ * vect_val_logical_port - vector to store the value structure
+ * of logical port
+ * vect_logical_port_id - vector to store the logical port id
+ * of logical port
+ * @return : It returns the read bulk operation status in logical port
+ * table
+ * UPPL_RC_SUCCESS - if read operation is success
+ * UPPL_RC_ERR_* - if read operation is a failure
+ **/
UpplReturnCode Kt_LogicalPort::ReadBulkInternal(
+ OdbcmConnectionHandler *db_conn,
void* key_struct,
void* val_struct,
uint32_t data_type,
// Populate DBSchema for logicalport_table
void* old_value_struct;
vector<ODBCMOperator> vect_key_operations;
- PopulateDBSchemaForKtTable(kt_logicalport_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_logicalport_dbtableschema,
key_struct,
val_struct,
- UNC_OP_READ_BULK, 0, 0,
+ UNC_OP_READ_BULK, data_type, 0, 0,
vect_key_operations, old_value_struct);
// Read rows from DB
read_db_status = physical_layer->get_odbc_manager()-> \
GetBulkRows((unc_keytype_datatype_t)data_type, max_rep_ct,
kt_logicalport_dbtableschema,
- (unc_keytype_operation_t)UNC_OP_READ_BULK);
+ (unc_keytype_operation_t)UNC_OP_READ_BULK, db_conn);
if (read_db_status == ODBCM_RC_RECORD_NOT_FOUND) {
pfc_log_debug("No record found");
read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
return read_status;
+ } else if (read_db_status == ODBCM_RC_CONNECTION_ERROR) {
+ read_status = UPPL_RC_ERR_DB_ACCESS;
+ pfc_log_error("Read operation has failed with error %d", read_db_status);
+ return read_status;
} else if (read_db_status != ODBCM_RC_SUCCESS) {
read_status = UPPL_RC_ERR_DB_GET;
// log error to log daemon
return read_status;
}
// From the values received from DB, populate val_logical_port structure
- FillLogicalPortValueStructure(kt_logicalport_dbtableschema,
+ FillLogicalPortValueStructure(db_conn, kt_logicalport_dbtableschema,
vect_val_logical_port,
max_rep_ct,
UNC_OP_READ_BULK,
return read_status;
}
-/** PerformSyntaxValidation
- * * @Description : This function performs syntax validation for
- * UNC_KT_LOGICAL_PORT
- * * * @param[in] : key_struct, value_struct, operation and data_type
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR_*
+/**
+ * @Description : This function performs syntax validation of logical port key
+ * type of the request received
+ * @param[in] : key_struct - void pointer to be cast into logical port key
+ * type
+ * val_struct - void pointer to be cast into logical port value
+ * type
+ * operation - indicates the type of operation to be performed
+ * that can be UNC_OP_CREATE or UNC_OP_DELETE etc
+ * data_type - indicates the data base type i.e UNC_DT_STATE
+ * or UNC_DT_IMPORT
+ * @return : Return code of the syntax validation will be sent
+ * UPPL_RC_SUCCESS - if Syntax Validation is success
+ * UPPL_RC_ERR_CFG_SYNTAX - if syntax validation fails
* */
-UpplReturnCode Kt_LogicalPort::PerformSyntaxValidation(void* key_struct,
- void* val_struct,
- uint32_t operation,
- uint32_t data_type) {
+UpplReturnCode Kt_LogicalPort::PerformSyntaxValidation(
+ OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ void* val_struct,
+ uint32_t operation,
+ uint32_t data_type) {
pfc_log_info("Syntax Validation of UNC_KT_LOGICAL_PORT");
UpplReturnCode ret_code = UPPL_RC_SUCCESS;
pfc_ipcresp_t mandatory = PFC_TRUE;
-
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map =
+ attr_syntax_map_all[UNC_KT_LOGICAL_PORT];
// Validate key structure
key_logical_port *key = reinterpret_cast<key_logical_port_t*>(key_struct);
string value =
reinterpret_cast<char*>(key->domain_key.ctr_key.controller_name);
- IS_VALID_STRING_KEY(CTR_NAME, value, operation, ret_code, mandatory);
+ IS_VALID_STRING_KEY(CTR_NAME_STR, value, operation, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
value = reinterpret_cast<char*>(key->domain_key.domain_name);
- IS_VALID_STRING_KEY(DOMAIN_NAME, value, operation, ret_code, mandatory);
+ IS_VALID_STRING_KEY(DOMAIN_NAME_STR, value, operation, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
value = reinterpret_cast<char*>(key->port_id);
- IS_VALID_STRING_KEY(LP_PORT_ID, value, operation, ret_code, mandatory);
+ IS_VALID_STRING_KEY(LP_PORT_ID_STR, value, operation, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
// validate description
valid_val = PhyUtil::uint8touint(val_lp->valid[kIdxLogicalPortDescription]);
string value = reinterpret_cast<char*>(val_lp->description);
- IS_VALID_STRING_VALUE(LP_DESCRIPTION, value, operation,
+ IS_VALID_STRING_VALUE(LP_DESCRIPTION_STR, value, operation,
valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
// Validate port_type
valid_val = PhyUtil::uint8touint(val_lp->valid[kIdxLogicalPortType]);
- IS_VALID_INT_VALUE(LP_PORT_TYPE, val_lp->port_type, operation,
- valid_val, ret_code, mandatory);
- if (ret_code != UPPL_RC_SUCCESS) {
- return UPPL_RC_ERR_CFG_SYNTAX;
+ if (valid_val == UNC_VF_VALID) {
+ ret_code = ValidatePortType(val_lp->port_type);
+ if (ret_code != UPPL_RC_SUCCESS) {
+ return UPPL_RC_ERR_CFG_SYNTAX;
+ }
}
// validate switch_id
value = reinterpret_cast<char*>(val_lp->switch_id);
valid_val = PhyUtil::uint8touint(val_lp->valid[kIdxLogicalPortSwitchId]);
- IS_VALID_STRING_VALUE(LP_SWITCH_ID, value, operation,
+ IS_VALID_STRING_VALUE(LP_SWITCH_ID_STR, value, operation,
valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
valid_val = PhyUtil::uint8touint(val_lp->
valid[kIdxLogicalPortPhysicalPortId]);
value = reinterpret_cast<char*>(val_lp->physical_port_id);
- IS_VALID_STRING_VALUE(LP_PHYSICAL_PORT_ID, value, operation,
+ IS_VALID_STRING_VALUE(LP_PHYSICAL_PORT_ID_STR, value, operation,
valid_val, ret_code, mandatory);
// Validate oper_down_criteria
valid_val = PhyUtil::uint8touint(val_lp->
valid[kIdxLogicalPortOperDownCriteria]);
- IS_VALID_INT_VALUE(LP_OPER_DOWN_CRITERIA, val_lp->oper_down_criteria,
+ IS_VALID_INT_VALUE(LP_OPER_DOWN_CRITERIA_STR, val_lp->oper_down_criteria,
operation, valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
return ret_code;
}
-/** PerformSemanticValidation
- * * @Description : This function performs semantic validation
- * for UNC_KT_LOGICAL_PORT
- * * * @param[in] : key_struct, value_struct, operation and data_type
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR_*
- * */
-UpplReturnCode Kt_LogicalPort::PerformSemanticValidation(void* key_struct,
- void* val_struct,
- uint32_t operation,
- uint32_t data_type) {
+/**
+ * @Description : This function performs semantic validation of the request
+ * received
+ * @param[in] : key_struct - void pointer to be cast into logical port key
+ * type
+ * val_struct - void pointer to be cast into logical port value
+ * type
+ * operation - specifies the operation to be performed
+ * that can be UNC_OP_CREATE orn UNC_OP_DELETE etc
+ * data_type - indicates the data base type i.e UNC_DT_STATE
+ * or UNC_DT_IMPORT
+ * @return : return code of the semantic validation will be returned
+ * UPPL_RC_SUCCESS - if Semantic Validation is success
+ * UPPL_RC_ERR_* - if semantic validation is failure
+ **/
+UpplReturnCode Kt_LogicalPort::PerformSemanticValidation(
+ OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ void* val_struct,
+ uint32_t operation,
+ uint32_t data_type) {
pfc_log_info("Inside PerformSemanticValidation of KT_LOGICAL_PORT");
UpplReturnCode status = UPPL_RC_SUCCESS;
key_logical_port *obj_key =
sw_vect_key_value.push_back(port_id);
UpplReturnCode KeyStatus = IsKeyExists(
- (unc_keytype_datatype_t)data_type,
+ db_conn, (unc_keytype_datatype_t)data_type,
sw_vect_key_value);
pfc_log_debug("IsKeyExists status %d", KeyStatus);
parent_vect_key_value.push_back(domain_name);
Kt_Ctr_Domain KtObj;
UpplReturnCode parent_key_status = KtObj.IsKeyExists(
- (unc_keytype_datatype_t)data_type, parent_vect_key_value);
+ db_conn, (unc_keytype_datatype_t)data_type, parent_vect_key_value);
pfc_log_debug("Parent IsKeyExists status %d", parent_key_status);
if (parent_key_status != UPPL_RC_SUCCESS) {
status = UPPL_RC_ERR_PARENT_DOES_NOT_EXIST;
return status;
}
-/** HandleDriverAlarms
- * * @Description : This function processes the alarm notification
- * received from driver
- * * * @param[in] : alarm type, operation, key_struct and value_struct
- * * * @return : Success or Failure
- * */
-UpplReturnCode Kt_LogicalPort::HandleDriverAlarms(uint32_t data_type,
- uint32_t alarm_type,
- uint32_t oper_type,
- void* key_struct,
- void* val_struct) {
+/**
+ * @Description : This function processes the alarm notification
+ * sent by driver for logical port key type
+ * @param[in] : data_type - indicates the data base type i.e UNC_DT_STATE
+ * or UNC_DT_IMPORT
+ * alarm type - indicates the alarm type sent by the driver
+ * oper_type - indicates the operation type i.e. UNC_OP_CREATE
+ * key_struct - void pointer to be type cast to logical port
+ * key type
+ * value_struct - void pointer to be type cast into logical
+ * port value structure type
+ * @return : the oper status result from db will be returned
+ * UPPL_RC_SUCCESS - in case oper status is received from DB
+ * UPPL_RC_ERR_* - if unable to receive oper status from DB
+ **/
+UpplReturnCode Kt_LogicalPort::HandleDriverAlarms(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ uint32_t alarm_type,
+ uint32_t oper_type,
+ void* key_struct,
+ void* val_struct) {
UpplReturnCode status = UPPL_RC_SUCCESS;
// Following alarms are sent for kt_logicalport
if (alarm_type != UNC_SUBDOMAIN_SPLIT) {
return UPPL_RC_ERR_BAD_REQUEST;
}
pfc_log_info("UNC_SUBDOMAIN_SPLIT alarm sent by driver");
- pfc_log_info("operation type: %d", oper_type);
uint8_t oper_status_db = 0;
- UpplReturnCode read_status = GetOperStatus(data_type,
+ UpplReturnCode read_status = GetOperStatus(db_conn, data_type,
key_struct,
oper_status_db);
if (read_status != UPPL_RC_SUCCESS) {
} else {
new_oper_status = UPPL_LOGICAL_PORT_OPER_UP;
}
- pfc_log_info("Oper_status received from db: %d", old_oper_status);
+ pfc_log_debug("Oper_status received from db: %d", old_oper_status);
pfc_log_info("Oper_status to be set to db: %d", new_oper_status);
if (new_oper_status == old_oper_status) {
pfc_log_debug("Old and new oper status are same, so do nothing");
return UPPL_RC_SUCCESS;
}
if (new_oper_status == UPPL_LOGICAL_PORT_OPER_UP) {
- GetOperStatusFromOperDownCriteria(data_type,
+ GetOperStatusFromOperDownCriteria(db_conn, data_type,
key_struct,
val_struct,
new_oper_status);
return UPPL_RC_SUCCESS;
}
// Set oper_status update in DB
- status = SetOperStatus(data_type, key_struct, NULL, new_oper_status);
+ status = SetOperStatus(db_conn, data_type, key_struct, NULL, new_oper_status);
pfc_log_debug("Update oper_status return: %d", status);
if (status == UPPL_RC_SUCCESS) {
// Call NotifyOperStatus of referred key types
- status = NotifyOperStatus(data_type, key_struct, val_struct);
+ key_logical_port_t *key_lp = reinterpret_cast<key_logical_port_t*>
+ (key_struct);
+ string controller_name =
+ (const char*)(key_lp->domain_key.ctr_key.controller_name);
+ vector<OperStatusHolder> ref_oper_status;
+ GET_ADD_CTRL_OPER_STATUS(controller_name);
+ ADD_LP_PORT_OPER_STATUS(*key_lp,
+ new_oper_status);
+ status = NotifyOperStatus(db_conn, data_type,
+ key_struct, val_struct, ref_oper_status);
pfc_log_debug("Notify oper_status return: %d", status);
+ ClearOperStatusHolder(ref_oper_status);
}
return status;
}
-/** HandleOperStatus
- * * @Description : This function performs the required actions when oper status
- * changes
- * * * @param[in] : Key and value struct
- * * * @return : Success or associated error code
- * */
-UpplReturnCode Kt_LogicalPort::HandleOperStatus(uint32_t data_type,
- void *key_struct,
- void *value_struct) {
+/**
+ * @Description : This function handles the oper status changes in logical port
+ * @param[in] : data_type - indicates the data base type i.e UNC_DT_STATE
+ * or UNC_DT_IMPORT
+ * key_struct - void pointer to be cast into logical port key
+ * type
+ * value struct - void pointer to be cast into logical port
+ * value type
+ * @return : UPPL_RC_SUCCESS - if oper status update in db is successful
+ * UPPL_RC_ERR_* - if oper status update in db is failure
+ **/
+UpplReturnCode Kt_LogicalPort::HandleOperStatus(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ void *key_struct,
+ void *value_struct,
+ vector<OperStatusHolder> &ref_oper_status,
+ unc_key_type_t caller_kt) {
FN_START_TIME("HandleOperStatus", "LogicalPort");
- PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode return_code = UPPL_RC_SUCCESS;
pfc_log_debug("LogicalPort Handle Oper Status Enter");
(const char*) obj_key_logical_port->domain_key.ctr_key.controller_name;
string domain_name =
(const char*) obj_key_logical_port->domain_key.domain_name;
- string port_id =
+ string log_port_id =
(const char*) obj_key_logical_port->port_id;
string switch_id;
string phy_port_id;
}
}
val_logical_port_st_t obj_val_logical_port_st;
- memset(obj_val_logical_port_st.logical_port.switch_id, '\0', 256);
- memset(obj_val_logical_port_st.logical_port.physical_port_id, '\0', 32);
- memset(obj_val_logical_port_st.logical_port.valid, UNC_VF_INVALID, 5);
- memset(obj_val_logical_port_st.valid, UNC_VF_INVALID, 2);
+ memset(&obj_val_logical_port_st, '\0', sizeof(obj_val_logical_port_st));
stringstream ss;
ss << "Handle operstatus ctr_name:" << controller_name
<< "\tdomain_name:" << domain_name
- << "\tlogical_port_id:" << port_id
+ << "\tlogical_port_id:" << log_port_id
<< "\tswitch_id:" << switch_id
<< "\tphy_port_id:" << phy_port_id;
string strName = ss.str();
pfc_log_debug("Handle operstatus ip vals:%s", strName.c_str());
vector<key_logical_port_t> vectLogicalPortKey;
// Get the controller's oper status and decide on the oper_status
+ uint8_t ctrl_oper_status = 0;
key_ctr_t ctr_key;
+ memset(&ctr_key, '\0', sizeof(key_ctr_t));
memcpy(ctr_key.controller_name, controller_name.c_str(),
(controller_name.length())+1);
- uint8_t ctrl_oper_status = 0;
+ UpplReturnCode read_oper_status = get_oper_status(
+ ref_oper_status,
+ UNC_KT_CONTROLLER,
+ reinterpret_cast<void*>(&ctr_key),
+ ctrl_oper_status);
+ if (read_oper_status != UPPL_RC_SUCCESS) {
+ Kt_Controller controller;
+ UpplReturnCode read_status = controller.GetOperStatus(
+ db_conn, data_type, reinterpret_cast<void*>(&ctr_key),
+ ctrl_oper_status);
+ if (read_status != UPPL_RC_SUCCESS) {
+ pfc_log_info("Controller's oper_status read returned failure");
+ FN_END_TIME("HandleOperStatus", "LogicalPort");
+ return return_code;
+ }
+ }
UpplLogicalPortOperStatus logical_port_oper_status =
UPPL_LOGICAL_PORT_OPER_UNKNOWN;
- Kt_Controller controller;
- UpplReturnCode read_status = controller.GetOperStatus(
- data_type, reinterpret_cast<void*>(&ctr_key), ctrl_oper_status);
- if (read_status != UPPL_RC_SUCCESS) {
- pfc_log_info("Controller's oper_status read returned failure");
- FN_END_TIME("HandleOperStatus", "LogicalPort");
- return return_code;
- }
if (ctrl_oper_status ==
(UpplControllerOperStatus) UPPL_CONTROLLER_OPER_DOWN) {
// set oper status to unknown
logical_port_oper_status = UPPL_LOGICAL_PORT_OPER_UNKNOWN;
return_code = SetOperStatus(
- data_type,
+ db_conn, data_type,
key_struct,
reinterpret_cast<void*>(&obj_val_logical_port_st),
logical_port_oper_status);
+ // Notify referred classes
+ return_code = NotifyOperStatus(db_conn, data_type, key_struct,
+ NULL, ref_oper_status);
FN_END_TIME("HandleOperStatus", "LogicalPort");
return return_code;
}
pfc_log_info("Controller's oper_status %d", ctrl_oper_status);
- if (ctrl_oper_status !=
- (UpplControllerOperStatus) UPPL_CONTROLLER_OPER_UP) {
- pfc_log_info("Controller oper status is not up, returning");
- FN_END_TIME("HandleOperStatus", "LogicalPort");
- return return_code;
- }
- pfc_log_info("Set logical port oper status as up");
+ pfc_log_info("Decide logical port oper status as from switch/port");
logical_port_oper_status = UPPL_LOGICAL_PORT_OPER_UP;
- // get switch oper status:
- key_switch_t switch_key;
- memcpy(switch_key.ctr_key.controller_name, controller_name.c_str(),
- (controller_name.length())+1);
+ uint8_t switch_oper_status = 0;
if (!switch_id.empty()) {
- pfc_log_debug("Sending switch key");
+ key_switch_t switch_key;
+ memset(&switch_key, 0, sizeof(switch_key));
+ memcpy(switch_key.ctr_key.controller_name, controller_name.c_str(),
+ (controller_name.length())+1);
+ pfc_log_debug("switch key %s", switch_id.c_str());
memcpy(switch_key.switch_id, switch_id.c_str(),
(switch_id.length())+1);
- } else {
- memset(switch_key.switch_id, 0, 256);
- }
- uint8_t switch_oper_status = 0;
- logical_port_oper_status =
- UPPL_LOGICAL_PORT_OPER_UNKNOWN;
- Kt_Switch switch_obj;
- read_status = switch_obj.GetOperStatus(
- data_type, reinterpret_cast<void*>(&switch_key), switch_oper_status);
- if (read_status == UPPL_RC_SUCCESS) {
- pfc_log_info("switch oper_status %d", switch_oper_status);
- if (switch_oper_status ==
- (UpplSwitchOperStatus) UPPL_SWITCH_OPER_UP) {
- pfc_log_debug("Set logical port oper status as up");
- logical_port_oper_status = UPPL_LOGICAL_PORT_OPER_UP;
- if (value_struct != NULL) {
- obj_val_logical_port_st =
- *(reinterpret_cast<val_logical_port_st_t*>(value_struct));
- }
- } else if (switch_oper_status ==
- (UpplSwitchOperStatus) UPPL_SWITCH_OPER_DOWN) {
- logical_port_oper_status = UPPL_LOGICAL_PORT_OPER_DOWN;
- if (value_struct != NULL) {
- obj_val_logical_port_st =
- *(reinterpret_cast<val_logical_port_st_t*>(value_struct));
+ read_oper_status = get_oper_status(ref_oper_status,
+ UNC_KT_SWITCH,
+ reinterpret_cast<void*>(&switch_key),
+ switch_oper_status);
+ UpplReturnCode read_status = UPPL_RC_SUCCESS;
+ if (read_oper_status != UPPL_RC_SUCCESS) {
+ // get switch oper status:
+ logical_port_oper_status =
+ UPPL_LOGICAL_PORT_OPER_UNKNOWN;
+ Kt_Switch switch_obj;
+ read_status = switch_obj.GetOperStatus(
+ db_conn, data_type,
+ reinterpret_cast<void*>(&switch_key), switch_oper_status);
+ }
+ if (read_oper_status == UPPL_RC_SUCCESS ||
+ read_status == UPPL_RC_SUCCESS) {
+ pfc_log_info("switch oper_status %d", switch_oper_status);
+ if (switch_oper_status ==
+ (UpplSwitchOperStatus) UPPL_SWITCH_OPER_UP) {
+ logical_port_oper_status = UPPL_LOGICAL_PORT_OPER_UP;
+ } else if (switch_oper_status ==
+ (UpplSwitchOperStatus) UPPL_SWITCH_OPER_DOWN) {
+ logical_port_oper_status = UPPL_LOGICAL_PORT_OPER_DOWN;
}
+ } else {
+ pfc_log_error("switch oper_status read returned failure");
}
- } else {
- pfc_log_error("switch oper_status read returned failure");
}
// check oper down criteria
pfc_log_debug("iterate all logical port in handle oper status");
- port_id.clear();
// Get all logical ports associated with controller and operdowncriteria
- while (true) {
- DBTableSchema kt_ctr_domain_dbtableschema;
- vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
- vect_prim_keys.push_back(DOMAIN_NAME);
-
- vector<TableAttrSchema> vect_table_attr_schema;
- list< vector<TableAttrSchema> > row_list;
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
- controller_name.length(), DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
- PhyUtil::FillDbSchema(DOMAIN_NAME, domain_name,
- domain_name.length(), DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
- if (!switch_id.empty()) {
- vect_prim_keys.push_back(LP_SWITCH_ID);
- PhyUtil::FillDbSchema(LP_SWITCH_ID, switch_id,
- switch_id.length(), DATATYPE_UINT8_ARRAY_256,
- vect_table_attr_schema);
- }
-
- if (!phy_port_id.empty()) {
- vect_prim_keys.push_back(LP_PHYSICAL_PORT_ID);
- PhyUtil::FillDbSchema(LP_PHYSICAL_PORT_ID, phy_port_id,
- phy_port_id.length(), DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
- }
-
- vect_prim_keys.push_back(LP_PORT_ID);
- PhyUtil::FillDbSchema(LP_PORT_ID, port_id,
- port_id.length(), DATATYPE_UINT8_ARRAY_320,
- vect_table_attr_schema);
-
- kt_ctr_domain_dbtableschema.set_table_name(UPPL_LOGICALPORT_TABLE);
- kt_ctr_domain_dbtableschema.set_primary_keys(vect_prim_keys);
- row_list.push_back(vect_table_attr_schema);
- kt_ctr_domain_dbtableschema.set_row_list(row_list);
- ODBCM_RC_STATUS db_status = physical_layer->get_odbc_manager()->
- GetBulkRows((unc_keytype_datatype_t)data_type, UPPL_MAX_REP_CT,
- kt_ctr_domain_dbtableschema,
- (unc_keytype_operation_t)UNC_OP_READ_SIBLING_BEGIN);
- if (db_status != ODBCM_RC_SUCCESS) {
- // No other logical port available
- pfc_log_debug("No other logical port available - HandleOperStatus End");
- break;
- }
- list<vector<TableAttrSchema> > ::iterator iter_list;
- for (iter_list = kt_ctr_domain_dbtableschema.row_list_.begin();
- iter_list != kt_ctr_domain_dbtableschema.row_list_.end();
- ++iter_list) {
- vector<TableAttrSchema> attributes_vector = *iter_list;
- vector<TableAttrSchema> :: iterator iter_vector;
- key_logical_port_t logical_port;
- for (iter_vector = attributes_vector.begin();
- iter_vector != attributes_vector.end();
- ++iter_vector) {
- /* Get attribute name of a row */
- TableAttrSchema tab_att_schema = (*iter_vector);
-
- if (tab_att_schema.table_attribute_name == CTR_NAME) {
- PhyUtil::GetValueFromDbSchema(tab_att_schema,
- controller_name,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(logical_port.domain_key.ctr_key.controller_name,
- controller_name.c_str(),
- controller_name.length()+1);
- }
- if (tab_att_schema.table_attribute_name ==
- DOMAIN_NAME) {
- PhyUtil::GetValueFromDbSchema(tab_att_schema,
- domain_name,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(logical_port.domain_key.domain_name,
- domain_name.c_str(),
- domain_name.length()+1);
- }
- if (tab_att_schema.table_attribute_name == LP_PORT_ID) {
- PhyUtil::GetValueFromDbSchema(tab_att_schema, port_id,
- DATATYPE_UINT8_ARRAY_320);
- memcpy(logical_port.port_id, port_id.c_str(),
- port_id.length()+1);
- }
- }
- vectLogicalPortKey.push_back(logical_port);
- }
- }
+ GetAllLogicalPort(db_conn, controller_name, domain_name, switch_id,
+ phy_port_id, vectLogicalPortKey, data_type);
vector<key_logical_port_t>::iterator keyItr =
vectLogicalPortKey.begin();
- for (; keyItr != vectLogicalPortKey.end(); ++keyItr) {
- // key_logical_port_t objKeyLogicalPort;
+ for (; keyItr != vectLogicalPortKey.end();) {
// handle operstatus criteria
string port_id = (const char*)((*keyItr).port_id);
+ if (!log_port_id.empty() && log_port_id != port_id) {
+ keyItr = vectLogicalPortKey.erase(keyItr);
+ continue;
+ }
pfc_log_debug("Port_Id: %s", port_id.c_str());
unsigned trunk_port = port_id.find("TP-");
unsigned sd_port = port_id.find("SD-");
if (trunk_port == 0 || sd_port == 0) {
pfc_log_debug("Call oper down criteria function");
return_code = GetOperStatusFromOperDownCriteria(
- data_type,
+ db_conn, data_type,
reinterpret_cast<void *> (&(*keyItr)),
value_struct,
logical_port_oper_status);
if (return_code != UPPL_RC_SUCCESS) {
+ ++keyItr;
continue;
}
pfc_log_debug("Handle logical port oper status val: %d",
logical_port_oper_status);
+ } else if (caller_kt != UNC_KT_SWITCH) {
+ // Check oper_status of associated port
+ uint8_t port_oper_status = 0;
+ UpplReturnCode port_status = UPPL_RC_SUCCESS;
+ key_port_t obj_key_port;
+ memset(&obj_key_port, '\0', sizeof(key_port_t));
+ memcpy(obj_key_port.sw_key.ctr_key.controller_name,
+ controller_name.c_str(),
+ (controller_name.length())+1);
+ memcpy(obj_key_port.sw_key.switch_id,
+ switch_id.c_str(),
+ (switch_id.length())+1);
+ memcpy(obj_key_port.port_id,
+ phy_port_id.c_str(),
+ (phy_port_id.length())+1);
+ read_oper_status = get_oper_status(ref_oper_status,
+ UNC_KT_PORT,
+ reinterpret_cast<void*>(&obj_key_port),
+ port_oper_status);
+ if (read_oper_status != UPPL_RC_SUCCESS) {
+ port_status = GetPortOperStatus(
+ db_conn, obj_key_port,
+ &port_oper_status, data_type);
+ }
+ if ((read_oper_status == UPPL_RC_SUCCESS ||
+ port_status == UPPL_RC_SUCCESS) &&
+ port_oper_status == UPPL_PORT_OPER_DOWN) {
+ logical_port_oper_status = UPPL_LOGICAL_PORT_OPER_DOWN;
+ }
}
pfc_log_debug("Set logical port oper status: %d",
logical_port_oper_status);
- return_code = SetOperStatus(data_type,
+ return_code = SetOperStatus(db_conn, data_type,
reinterpret_cast<void *> (&(*keyItr)), NULL,
logical_port_oper_status);
- pfc_log_debug("Set logical port oper retrun code: %d",
+ pfc_log_debug("Set logical port oper return code: %d",
return_code);
+ ++keyItr;
}
// notify operstatus using logical port siblings as key
if (!vectLogicalPortKey.empty()) {
vector<key_logical_port_t>::iterator keyItr =
vectLogicalPortKey.begin();
for (; keyItr != vectLogicalPortKey.end(); ++keyItr) {
- pfc_log_debug("Set logical port oper stat ret code: %d", return_code);
if (return_code == UPPL_RC_SUCCESS) {
// Call referred classes' notify oper_status functions
+ key_logical_port_t key_lp = (*keyItr);
+ ADD_LP_PORT_OPER_STATUS(key_lp, logical_port_oper_status);
return_code = NotifyOperStatus(
- data_type, reinterpret_cast<void *> (&(*keyItr)), NULL);
+ db_conn, data_type, reinterpret_cast<void *> (&(*keyItr)),
+ NULL, ref_oper_status);
pfc_log_debug("logicalport Notify Operstatus ret: %d", return_code);
} else {
pfc_log_error("operstatus update failure");
}
}
} else {
- pfc_log_info("Logicalport sibling count is 0");
+ pfc_log_debug("Logicalport sibling count is 0");
}
pfc_log_debug("LogicalPort Handle Oper Status End");
FN_END_TIME("HandleOperStatus", "LogicalPort");
return return_code;
}
-/** GetOperStatusFromOperDownCriteria
- * * @Description : This function retrieves the oper status of port based on
- * operdown criteria
- * * * @param[in] : Key and value struct
- * * * @return : Success or associated error code
- * */
+/**
+ * @Description : This function retrieves the oper status of port based on
+ * operdown criteria
+ * @param[in] : data_type - indicates the data base type i.e UNC_DT_STATE
+ * or UNC_DT_IMPORT
+ * key_struct - void pointer to be cast into logical port key
+ * type
+ * value struct - void pointer to be cast into logical port
+ * value type
+ * logical_port_oper_status - indicates the logical port oper
+ * status i.e. either UP or DOWN
+ * @return : UPPL_RC_SUCCESS - if port oper status is retrieved correctly
+ * UPPL_RC_ERR_* - if port oper status cannot be retrieved
+ **/
UpplReturnCode Kt_LogicalPort::GetOperStatusFromOperDownCriteria(
+ OdbcmConnectionHandler *db_conn,
uint32_t data_type,
void *key_struct,
void *value_struct,
- UpplLogicalPortOperStatus &logical_port_oper_status ) {
+ UpplLogicalPortOperStatus &logical_port_oper_status) {
uint32_t oper_down_criteria;
vector<uint32_t> vectOperStatus;
// get port oper status,PFC_FALSE as call is not from deletekeyinstance
pfc_log_debug("Enter GetOperStatusFromOperDownCriteria");
- HandleOperDownCriteriaFromPortStatus(data_type, key_struct, value_struct,
+ HandleOperDownCriteriaFromPortStatus(db_conn, data_type, key_struct,
+ value_struct,
vectOperStatus, PFC_FALSE);
// get oper down from DB
UpplReturnCode return_code = UPPL_RC_SUCCESS;
- return_code = GetOperDownCriteria(data_type, key_struct, oper_down_criteria);
+ return_code = GetOperDownCriteria(db_conn, data_type,
+ key_struct, oper_down_criteria);
if (return_code != UPPL_RC_SUCCESS) {
pfc_log_info("Logicalport OperStatusFromOperDownCriteria read error");
return return_code;
// then set status to down else oper status to up
if ((*operstatus_itr) == 0 || (*operstatus_itr) == 2) {
logical_port_oper_status = UPPL_LOGICAL_PORT_OPER_DOWN;
- break;
} else if ((*operstatus_itr) == 1) {
logical_port_oper_status = UPPL_LOGICAL_PORT_OPER_UP;
+ break;
}
}
pfc_log_debug("Logical port OperStatusFromOperDownCriteria status: %d",
// then set status to up else oper status to down
if ((*operstatus_itr) == 1) {
logical_port_oper_status = UPPL_LOGICAL_PORT_OPER_UP;
- break;
} else if ((*operstatus_itr) == 0 || (*operstatus_itr) == 2) {
logical_port_oper_status = UPPL_LOGICAL_PORT_OPER_DOWN;
+ break;
}
}
pfc_log_debug("Logicalport OperStatusFromOperDownCriteria Any status:%d",
return return_code;
}
-/** HandleOperDownCriteriaFromPortStatus
- * * @Description : This function retrieves the oper status of port based on
- * logical member port key values
- * * * @param[in] : Key and value struct
- * * * @return : Success or associated error code
- * */
+/**
+ * @Description : This function retrieves the oper status of port based on
+ * logical member port key values
+ * @param[in] : data_type - indicates the data base type i.e UNC_DT_STATE
+ * or UNC_DT_IMPORT
+ * key_struct - void pointer to be cast into logical port key
+ * type
+ * valu_struct - void pointer to be cast into logical port
+ * value type
+ * vectOperStatus - vector to hold the oper status of port
+ * is_delete_call - bool variable to check whether delete call
+ * is madwe by the parent class
+ * @return : UPPL_RC_SUCCESS - if port oper status is read correctly
+ * UPPL_RC_ERR_* - if port oper status read returned failure
+ **/
UpplReturnCode Kt_LogicalPort::HandleOperDownCriteriaFromPortStatus(
+ OdbcmConnectionHandler *db_conn,
uint32_t data_type,
void *key_struct,
void *value_struct,
<< "\tdomain_name:" << domain_name
<< "\tlogical_port_id:" << port_id;
string strName = ss.str();
+ string switch_id;
+ string physical_port_id;
pfc_log_debug("Handle operdowncriteria ip vals: %s", strName.c_str());
// Call referred classes' notify oper_status functions
// Get all domains associated with controller
- port_id.clear();
while (true) {
DBTableSchema kt_logicalport_dbtableschema;
vector<string> vect_prim_keys;
vector<TableAttrSchema> vect_table_attr_schema;
list< vector<TableAttrSchema> > row_list;
- vect_prim_keys.push_back(CTR_NAME);
- vect_prim_keys.push_back(DOMAIN_NAME);
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ vect_prim_keys.push_back(CTR_NAME_STR);
+ vect_prim_keys.push_back(DOMAIN_NAME_STR);
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- PhyUtil::FillDbSchema(DOMAIN_NAME, domain_name,
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_NAME, domain_name,
domain_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- // if (!port_id.empty()) {
- vect_prim_keys.push_back(LP_PORT_ID);
- // }
- PhyUtil::FillDbSchema(LP_PORT_ID, port_id,
+ vect_prim_keys.push_back(LP_PORT_ID_STR);
+ PhyUtil::FillDbSchema(unc::uppl::LMP_LP_PORT_ID, port_id,
port_id.length(), DATATYPE_UINT8_ARRAY_320,
vect_table_attr_schema);
- vect_prim_keys.push_back(LP_SWITCH_ID);
- string switch_id;
- PhyUtil::FillDbSchema(LP_SWITCH_ID, switch_id,
+ vect_prim_keys.push_back(LP_SWITCH_ID_STR);
+ PhyUtil::FillDbSchema(unc::uppl::LMP_SWITCH_ID, switch_id,
switch_id.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
- string physical_port_id;
- PhyUtil::FillDbSchema(LP_PHYSICAL_PORT_ID, physical_port_id,
+ PhyUtil::FillDbSchema(unc::uppl::LMP_PHYSICAL_PORT_ID, physical_port_id,
physical_port_id.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- kt_logicalport_dbtableschema.set_table_name("logical_member_port_table");
+ kt_logicalport_dbtableschema.set_table_name(
+ unc::uppl::LOGICAL_MEMBERPORT_TABLE);
kt_logicalport_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
GetBulkRows((unc_keytype_datatype_t)data_type,
UPPL_MAX_REP_CT,
kt_logicalport_dbtableschema,
- (unc_keytype_operation_t)UNC_OP_READ_SIBLING_BEGIN);
+ (unc_keytype_operation_t)UNC_OP_READ_SIBLING_BEGIN,
+ db_conn);
if (db_status != ODBCM_RC_SUCCESS) {
pfc_log_info("ReadBulk failure in HandleOperDownCriteria");
break;
++iter_vector) {
/* Get attribute name of a row */
TableAttrSchema tab_att_schema = (*iter_vector);
- if (tab_att_schema.table_attribute_name == CTR_NAME) {
- PhyUtil::GetValueFromDbSchema(tab_att_schema, controller_name,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(logical_memeber_port.logical_port_key.domain_key.ctr_key.
- controller_name, controller_name.c_str(),
- controller_name.length()+1);
- } else if (tab_att_schema.table_attribute_name == LP_SWITCH_ID) {
- string switch_id;
- PhyUtil::GetValueFromDbSchema(tab_att_schema, switch_id,
- DATATYPE_UINT8_ARRAY_256);
- // key_logical_port_t logical_port;
- memcpy(logical_memeber_port.switch_id,
- switch_id.c_str(),
- switch_id.length()+1);
- } else if (tab_att_schema.table_attribute_name ==
- LP_PHYSICAL_PORT_ID) {
- string physical_port_id;
- PhyUtil::GetValueFromDbSchema(tab_att_schema, physical_port_id,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(logical_memeber_port.physical_port_id,
- physical_port_id.c_str(),
- physical_port_id.length()+1);
- } else if (tab_att_schema.table_attribute_name == LP_PORT_ID) {
- PhyUtil::GetValueFromDbSchema(tab_att_schema, port_id,
- DATATYPE_UINT8_ARRAY_320);
+ switch (tab_att_schema.table_attribute_name) {
+ case unc::uppl::CTR_NAME:
+ PhyUtil::GetValueFromDbSchemaStr(
+ tab_att_schema,
+ logical_memeber_port.logical_port_key.domain_key.\
+ ctr_key.controller_name,
+ DATATYPE_UINT8_ARRAY_32);
+ break;
+ case unc::uppl::LMP_SWITCH_ID:
+ PhyUtil::GetValueFromDbSchemaStr(tab_att_schema,
+ logical_memeber_port.switch_id,
+ DATATYPE_UINT8_ARRAY_256);
+ switch_id = (const char*)logical_memeber_port.switch_id;
+ break;
+ case unc::uppl::LMP_PHYSICAL_PORT_ID:
+ PhyUtil::GetValueFromDbSchemaStr(
+ tab_att_schema,
+ logical_memeber_port.physical_port_id,
+ DATATYPE_UINT8_ARRAY_32);
+ physical_port_id =
+ (const char*)logical_memeber_port.physical_port_id;
+ break;
+ case unc::uppl::LMP_LP_PORT_ID:
+ uint8_t lp_id[ODBCM_SIZE_320];
+ PhyUtil::GetValueFromDbSchemaStr(tab_att_schema, lp_id,
+ DATATYPE_UINT8_ARRAY_320);
+ port_id = reinterpret_cast<const char*> (lp_id);
+ break;
+ default:
+ break;
}
}
// call port function to set logicalport id valid status as invalid
if (is_delete_call == PFC_TRUE) {
val_port_st_t obj_val_port;
-
- // set obj_val_port.port valid as invalid
- memset(obj_val_port.port.valid, UNC_VF_INVALID, 4);
- // set obj_val_port valid as invalid
- memset(obj_val_port.valid, UNC_VF_INVALID, 7);
+ memset(&obj_val_port, 0, sizeof(obj_val_port));
string logical_port_id = (const char*)obj_key_logical_port->port_id;
memcpy(obj_val_port.logical_port_id,
obj_val_port.valid[kIdxPortLogicalPortId] = UNC_VF_VALID;
read_status = port.UpdatePortValidFlag(
- reinterpret_cast<void*>(&obj_key_port),
+ db_conn, reinterpret_cast<void*>(&obj_key_port),
reinterpret_cast<void*>(&obj_val_port),
obj_val_port,
- UNC_VF_INVALID);
+ UNC_VF_INVALID, data_type);
+ continue;
+ }
+ // get the port oper_status
+ uint8_t port_oper_status = 0;
+
+ pfc_log_debug("Logicalport get CriteriaFromPortStatus");
+ read_status = port.GetOperStatus(
+ db_conn, data_type, reinterpret_cast<void*>(&obj_key_port),
+ port_oper_status);
+ if (read_status == UPPL_RC_SUCCESS) {
+ pfc_log_debug("port oper_status in logport: %d", port_oper_status);
+ vectOperStatus.push_back(port_oper_status);
} else {
- // get the port oper_status
- uint8_t port_oper_status = 0;
-
- pfc_log_debug("Logicalport get CriteriaFromPortStatus");
- read_status = port.GetOperStatus(
- data_type, reinterpret_cast<void*>(&obj_key_port),
- port_oper_status);
- if (read_status == UPPL_RC_SUCCESS) {
- pfc_log_debug("port oper_status in logport: %d", port_oper_status);
- vectOperStatus.push_back(port_oper_status);
- } else {
- pfc_log_info("port oper_status read returned failure");
- }
- return_code = read_status;
+ pfc_log_info("port oper_status read returned failure");
}
+ return_code = read_status;
+ }
+ if (kt_logicalport_dbtableschema.row_list_.size() < UPPL_MAX_REP_CT) {
+ pfc_log_info("Further ReadBulk not required in HandleOperDownCriteria");
+ break;
}
}
pfc_log_debug("Exit Logicalport Handle OperDownCriteriaFromPortStatus");
return return_code;
}
-/** GetOperDownCriteria
- * * @Description : This function retrieves the oper down criteria from db
- * * * @param[in] : Key and oper_status
- * * * @return : Success or associated error code
- * */
+/**
+ * @Description : This function reads the oper down criteria from db
+ * @param[in] : data_type - indicates the data base type i.e UNC_DT_STATE
+ * or UNC_DT_IMPORT
+ * key_struct - void pointer to be cast into logical port key
+ * type
+ * oper_down_criteria - specifies the oper down criteria
+ * @return : UPPL_RC_SUCCESS - if oper down read criteria from db is
+ * success
+ * UPPL_RC_ERR_* - if oper down read criteria from db is failure
+ **/
UpplReturnCode Kt_LogicalPort::GetOperDownCriteria(
+ OdbcmConnectionHandler *db_conn,
uint32_t data_type,
void* key_struct,
uint32_t &oper_down_criteria) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
key_logical_port_t *obj_key_logical_port =
reinterpret_cast<key_logical_port_t*>(key_struct);
- TableAttrSchema kt_logical_port_table_attr_schema;
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
vector<string> vect_prim_keys;
ctr_key.controller_name;
if (!controller_name.empty()) {
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
}
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
domain_key.domain_name;
if (!domain_name.empty()) {
- vect_prim_keys.push_back(DOMAIN_NAME);
+ vect_prim_keys.push_back(DOMAIN_NAME_STR);
}
- PhyUtil::FillDbSchema(DOMAIN_NAME, domain_name,
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_NAME, domain_name,
domain_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
string port_id = (const char*)obj_key_logical_port->port_id;
if (!port_id.empty()) {
- vect_prim_keys.push_back(LP_PORT_ID);
+ vect_prim_keys.push_back(LP_PORT_ID_STR);
}
- PhyUtil::FillDbSchema(LP_PORT_ID, port_id,
+ PhyUtil::FillDbSchema(unc::uppl::LP_PORT_ID, port_id,
port_id.length(), DATATYPE_UINT8_ARRAY_320,
vect_table_attr_schema);
string oper_down_criteria_value;
- PhyUtil::FillDbSchema(LP_OPER_DOWN_CRITERIA, oper_down_criteria_value,
+ PhyUtil::FillDbSchema(unc::uppl::LP_OPER_DOWN_CRITERIA,
+ oper_down_criteria_value,
oper_down_criteria_value.length(),
DATATYPE_UINT16,
vect_table_attr_schema);
DBTableSchema kt_logicalport_dbtableschema;
- kt_logicalport_dbtableschema.set_table_name(UPPL_LOGICALPORT_TABLE);
+ kt_logicalport_dbtableschema.set_table_name(unc::uppl::LOGICALPORT_TABLE);
kt_logicalport_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_logicalport_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS read_db_status =
physical_layer->get_odbc_manager()->GetOneRow(
(unc_keytype_datatype_t)data_type,
- kt_logicalport_dbtableschema);
+ kt_logicalport_dbtableschema, db_conn);
if (read_db_status != ODBCM_RC_SUCCESS) {
// log error
pfc_log_error("oper down criteria read operation failed");
}
// read the oper_down_criteria value
- list < vector<TableAttrSchema> > res_logicalport_row_list =
+ list < vector<TableAttrSchema> >& res_logicalport_row_list =
kt_logicalport_dbtableschema.get_row_list();
list < vector<TableAttrSchema> >::iterator res_logicalport_iter =
res_logicalport_row_list.begin();
- // populate IPC value structure based on the response recevied from DB
+ // populate IPC value structure based on the response received from DB
for (; res_logicalport_iter!= res_logicalport_row_list.end();
++res_logicalport_iter) {
vector<TableAttrSchema> res_logicalport_table_attr_schema =
++vect_logicalport_iter) {
// populate values from logicalport_table
TableAttrSchema tab_schema = (*vect_logicalport_iter);
- string attr_name = tab_schema.table_attribute_name;
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
string attr_value;
- if (attr_name == LP_OPER_DOWN_CRITERIA) {
+ if (attr_name == unc::uppl::LP_OPER_DOWN_CRITERIA) {
PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
DATATYPE_UINT16);
oper_down_criteria = atoi(attr_value.c_str());
return UPPL_RC_SUCCESS;
}
-/** IsLogicalPortReferred
- * * @Description : This function returns true if given controller_name,
- * domain and port_id are referred in logical port table
- * * @param[in] : controller_name, domain_name, port_id
- * * @return : PFC_TRUE/PFC_FALSE
- */
-pfc_bool_t Kt_LogicalPort::IsLogicalPortReferred(
- string controller_name,
- string domain_name) {
- pfc_bool_t is_ref = PFC_FALSE;
- PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
- DBTableSchema kt_dbtableschema;
- vector<TableAttrSchema> vect_table_attr_schema;
- TableAttrSchema kt_ctr_domain_table_attr_schema;
- list< vector<TableAttrSchema> > row_list;
- vector<string> vect_prim_keys;
-
- // Check whether controller_name1 is reffered
- vect_prim_keys.push_back(CTR_NAME);
- vect_prim_keys.push_back(DOMAIN_NAME);
-
- // controller_name
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
- controller_name.length(),
- DATATYPE_UINT8_ARRAY_32, vect_table_attr_schema);
- PhyUtil::FillDbSchema(DOMAIN_NAME, domain_name,
- domain_name.length(),
- DATATYPE_UINT8_ARRAY_32, vect_table_attr_schema);
- kt_dbtableschema.set_table_name("logical_port_table");
- kt_dbtableschema.set_primary_keys(vect_prim_keys);
- row_list.push_back(vect_table_attr_schema);
- kt_dbtableschema.set_row_list(row_list);
-
- // Send request to ODBC for logical_member_port_table
- ODBCM_RC_STATUS read_db_status = physical_layer->
- get_odbc_manager()->IsRowExists(UNC_DT_STATE,
- kt_dbtableschema);
- if (read_db_status == ODBCM_RC_ROW_EXISTS) {
- // read count
- is_ref = PFC_TRUE;
- }
- return is_ref;
-}
-
-/** InvokeBoundaryNotifyOperStatus
- * * @Description : This function invokes the notifyoperstatus of boundary
- * * * @param[in] : Key and value struct
- * * * @return : Success or associated error code
- * */
+/**
+ * @Description : This function invokes the notifyoperstatus of boundary
+ * @param[in] : data_type - indicates the data base type i.e UNC_DT_STATE
+ * or UNC_DT_IMPORT
+ * key_struct - void pointer to be type cast into logical port
+ * key type
+ * @return : UPPL_RC_SUCCESS - if boundary oper status is changed in DB
+ * UPPL_RC_ERR_* - if there are no boundaries associated with
+ * the controller name
+ **/
UpplReturnCode Kt_LogicalPort::InvokeBoundaryNotifyOperStatus(
+ OdbcmConnectionHandler *db_conn,
uint32_t data_type,
void *key_struct) {
UpplReturnCode return_code = UPPL_RC_SUCCESS;
(const char*)obj_key_logical_port->domain_key.domain_name;
string port_id =
(const char*)obj_key_logical_port->port_id;
+ vector<OperStatusHolder> ref_oper_status;
+ // Get controller oper status
+ GET_ADD_CTRL_OPER_STATUS(controller_name);
+ uint8_t lp_oper_status = 0;
+ read_status = GetOperStatus(
+ db_conn, data_type, key_struct, lp_oper_status);
+ ADD_LP_PORT_OPER_STATUS(*obj_key_logical_port, lp_oper_status);
// Notify UNC_KT_BOUNDARY
Kt_Boundary boundary;
val_boundary_t obj_val_boundary1;
memcpy(obj_val_boundary1.logical_port_id1,
port_id.c_str(), port_id.length()+1);
obj_val_boundary1.valid[kIdxBoundaryLogicalPortId1] = UNC_VF_VALID;
- memset(obj_val_boundary1.controller_name2, 0, 32);
- memset(obj_val_boundary1.domain_name2, 0, 32);
- memset(obj_val_boundary1.logical_port_id2, 0, 320);
return_code = boundary.HandleOperStatus(
- data_type, NULL, reinterpret_cast<void *> (&obj_val_boundary1));
- pfc_log_debug("Invoke Notify for boundary class %d", return_code);
+ db_conn, data_type, NULL, reinterpret_cast<void *> (&obj_val_boundary1),
+ ref_oper_status);
+ pfc_log_debug("Invoke Notify for boundary class C1D1L1 %d", return_code);
- // Boundary takes care of filling name2 values
+ val_boundary_t obj_val_boundary2;
+ memset(&obj_val_boundary2, 0, sizeof(val_boundary_t));
+ memset(obj_val_boundary2.valid, 0, 7);
+ memcpy(obj_val_boundary2.controller_name2,
+ controller_name.c_str(), controller_name.length()+1);
+ obj_val_boundary2.valid[kIdxBoundaryControllerName2] = UNC_VF_VALID;
+ memcpy(obj_val_boundary2.domain_name2,
+ domain_name.c_str(), domain_name.length()+1);
+ obj_val_boundary2.valid[kIdxBoundaryDomainName2] = UNC_VF_VALID;
+ memcpy(obj_val_boundary2.logical_port_id2,
+ port_id.c_str(), port_id.length()+1);
+ obj_val_boundary2.valid[kIdxBoundaryLogicalPortId2] = UNC_VF_VALID;
+ return_code = boundary.HandleOperStatus(
+ db_conn, data_type, NULL, reinterpret_cast<void *> (&obj_val_boundary2),
+ ref_oper_status);
+ pfc_log_debug("Invoke Notify for boundary class C2D2L2 %d", return_code);
+ ClearOperStatusHolder(ref_oper_status);
return return_code;
}
-/** NotifyOperStatus
- * * @Description : This function performs the notifies other associated
- * key types when oper status changes
- * * * @param[in] : Key and value struct
- * * * @return : Success or associated error code
- * */
-UpplReturnCode Kt_LogicalPort::NotifyOperStatus(uint32_t data_type,
- void *key_struct,
- void *value_struct) {
+/**
+ * @Description : This function notifies key type boundary when oper status of
+ * logical port changes
+ * @param[in] : data_type - specifies the data base type i.e UNC_DT_STATE
+ * or UNC_DT_IMPORT
+ * key_struct - void pointer type to be type cast into logical
+ * port key type
+ * value_struct - void pointer type to be type cast into logical
+ * port key type
+ * @return : UPPL_RC_SUCCESS - if the oper status notification in key type
+ * boundary is changed successfully
+ * UPPL_RC_ERR_* - if the oper status notification in key type
+ * boundary fails
+ **/
+UpplReturnCode Kt_LogicalPort::NotifyOperStatus(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ void *key_struct,
+ void *value_struct,
+ vector<OperStatusHolder> &ref_oper_status) {
UpplReturnCode return_code = UPPL_RC_SUCCESS;
key_logical_port_t *obj_key_logical_port =
reinterpret_cast<key_logical_port_t*>(key_struct);
(const char*)obj_key_logical_port->domain_key.domain_name;
string port_id =
(const char*)obj_key_logical_port->port_id;
-
+ pfc_log_debug(
+ "NotifyOperStatus: controller_name: %s, domain_name: %s, port_id: %s",
+ controller_name.c_str(), domain_name.c_str(), port_id.c_str());
// Notify UNC_KT_BOUNDARY
Kt_Boundary boundary;
val_boundary_t obj_val_boundary1;
(domain_name.length())+1);
memcpy(obj_val_boundary1.logical_port_id1,
port_id.c_str(), port_id.length()+1);
- memset(obj_val_boundary1.controller_name2, '\0', 32);
- memset(obj_val_boundary1.domain_name2, '\0', 32);
- memset(obj_val_boundary1.logical_port_id2, '\0', 320);
- obj_val_boundary1.valid[kIdxBoundaryLogicalPortId1] = UNC_VF_VALID;
+ if (!port_id.empty()) {
+ obj_val_boundary1.valid[kIdxBoundaryLogicalPortId1] = UNC_VF_VALID;
+ }
obj_val_boundary1.valid[kIdxBoundaryControllerName1] = UNC_VF_VALID;
- obj_val_boundary1.valid[kIdxBoundaryDomainName1] = UNC_VF_VALID;
+ if (!domain_name.empty()) {
+ obj_val_boundary1.valid[kIdxBoundaryDomainName1] = UNC_VF_VALID;
+ pfc_log_debug("Domain Name1 is set as Valid");
+ }
return_code = boundary.HandleOperStatus(
- data_type, NULL, reinterpret_cast<void *> (&obj_val_boundary1));
+ db_conn, data_type, NULL,
+ reinterpret_cast<void *> (&obj_val_boundary1), ref_oper_status);
pfc_log_info("HandleOperStatus C1D1L1 from boundary returned %d",
return_code);
-
val_boundary_t obj_val_boundary2;
- memset(obj_val_boundary2.controller_name1, '\0', 32);
- memset(obj_val_boundary2.domain_name1, '\0', 32);
- memset(obj_val_boundary2.logical_port_id1, '\0', 320);
+ memset(&obj_val_boundary2, 0, sizeof(val_boundary_t));
memcpy(obj_val_boundary2.controller_name2,
controller_name.c_str(),
(controller_name.length())+1);
(domain_name.length())+1);
memcpy(obj_val_boundary2.logical_port_id2,
port_id.c_str(), port_id.length()+1);
- obj_val_boundary2.valid[kIdxBoundaryLogicalPortId2] = UNC_VF_VALID;
+ if (!port_id.empty()) {
+ obj_val_boundary2.valid[kIdxBoundaryLogicalPortId2] = UNC_VF_VALID;
+ }
obj_val_boundary2.valid[kIdxBoundaryControllerName2] = UNC_VF_VALID;
- obj_val_boundary2.valid[kIdxBoundaryDomainName2] = UNC_VF_VALID;
+ if (!domain_name.empty()) {
+ obj_val_boundary2.valid[kIdxBoundaryDomainName2] = UNC_VF_VALID;
+ pfc_log_debug("Domain Name2 is set as Valid");
+ }
return_code = boundary.HandleOperStatus(
- data_type, NULL, reinterpret_cast<void *> (&obj_val_boundary2));
+ db_conn, data_type, NULL,
+ reinterpret_cast<void *> (&obj_val_boundary2), ref_oper_status);
pfc_log_info("HandleOperStatus C2D2L2 from boundary returned %d",
return_code);
-
return return_code;
}
-/** GetOperStatus
- * * @Description : This function updates the oper status in db
- * * * @param[in] : Key and oper_status
- * * * @return : Success or associated error code
- * */
-UpplReturnCode Kt_LogicalPort::GetOperStatus(uint32_t data_type,
+/**
+ * @Description : This function gets the oper status of logical port key type
+ * from DB
+ * @param[in] : data_type - indicates the data base type i.e UNC_DT_STATE
+ * or UNC_DT_IMPORT
+ * key_struct - void pointer type to be type cast into logical
+ * port key type
+ * oper_status - Stores the oper status received from DB
+ * @return : UPPL_RC_SUCCESS - if oper status is reads successfully from
+ * the DB
+ * UPPL_RC_ERR_DB_GET if oper staus read operation failed from DB
+ **/
+UpplReturnCode Kt_LogicalPort::GetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
uint8_t &oper_status) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
key_logical_port *obj_key_logical_port =
reinterpret_cast<key_logical_port_t*>(key_struct);
- TableAttrSchema kt_logical_port_table_attr_schema;
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
vector<string> vect_prim_keys;
domain_key.domain_name;
string port_id = (const char*)obj_key_logical_port->port_id;
if (!controller_name.empty()) {
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
+ controller_name.length(), DATATYPE_UINT8_ARRAY_32,
+ vect_table_attr_schema);
}
if (!domain_name.empty()) {
- vect_prim_keys.push_back(DOMAIN_NAME);
+ vect_prim_keys.push_back(DOMAIN_NAME_STR);
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_NAME, domain_name,
+ domain_name.length(), DATATYPE_UINT8_ARRAY_32,
+ vect_table_attr_schema);
}
if (!port_id.empty()) {
- vect_prim_keys.push_back(LP_PORT_ID);
+ vect_prim_keys.push_back(LP_PORT_ID_STR);
+ PhyUtil::FillDbSchema(unc::uppl::LP_PORT_ID, port_id,
+ port_id.length(), DATATYPE_UINT8_ARRAY_320,
+ vect_table_attr_schema);
}
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
- controller_name.length(), DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
-
- PhyUtil::FillDbSchema(DOMAIN_NAME, domain_name,
- domain_name.length(), DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
-
-
- PhyUtil::FillDbSchema(LP_PORT_ID, port_id,
- port_id.length(), DATATYPE_UINT8_ARRAY_320,
- vect_table_attr_schema);
-
string oper_value;
- PhyUtil::FillDbSchema(LP_OPER_STATUS, oper_value,
+ PhyUtil::FillDbSchema(unc::uppl::LP_OPER_STATUS, oper_value,
oper_value.length(), DATATYPE_UINT16,
vect_table_attr_schema);
DBTableSchema kt_logicalport_dbtableschema;
- kt_logicalport_dbtableschema.set_table_name(UPPL_LOGICALPORT_TABLE);
+ kt_logicalport_dbtableschema.set_table_name(unc::uppl::LOGICALPORT_TABLE);
kt_logicalport_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_logicalport_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS read_db_status =
physical_layer->get_odbc_manager()->GetOneRow(
(unc_keytype_datatype_t)data_type,
- kt_logicalport_dbtableschema);
+ kt_logicalport_dbtableschema, db_conn);
if (read_db_status != ODBCM_RC_SUCCESS) {
// log error
pfc_log_error("oper_status read operation failed");
}
// read the oper_status value
- list < vector<TableAttrSchema> > res_logicalport_row_list =
+ list < vector<TableAttrSchema> >& res_logicalport_row_list =
kt_logicalport_dbtableschema.get_row_list();
list < vector<TableAttrSchema> >::iterator res_logicalport_iter =
res_logicalport_row_list.begin();
++vect_logicalport_iter) {
// populate values from logicalport_table
TableAttrSchema tab_schema = (*vect_logicalport_iter);
- string attr_name = tab_schema.table_attribute_name;
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
string attr_value;
- if (attr_name == LP_OPER_STATUS) {
+ if (attr_name == unc::uppl::LP_OPER_STATUS) {
PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
DATATYPE_UINT16);
oper_status = atoi(attr_value.c_str());
return UPPL_RC_SUCCESS;
}
-/** SetOperStatus
- * * @Description : This function updates the oper status in db
- * * * @param[in] : Key and oper_status
- * * * @return : Success or associated error code
- * */
+/**
+ * @Description : This function updates the oper status in logical port db and
+ * notifies the change to northbound
+ * @param[in] : data_type - specifies the data base type i.e UNC_DT_STATE
+ * or UNC_DT_IMPORT
+ * key_struct - void pointer type to be type casted in logical
+ * port key type
+ * val_struct - void pointer type to be type cast in logical
+ * port value type
+ * oper_statuus - value of oper status to be updated in DB
+ * @return : Success or associated error code
+ **/
UpplReturnCode Kt_LogicalPort::SetOperStatus(
+ OdbcmConnectionHandler *db_conn,
uint32_t data_type,
void* key_struct,
void* val_struct,
reinterpret_cast<key_logical_port_t*>(key_struct);
val_logical_port_st_t *obj_val_logical_port=
reinterpret_cast<val_logical_port_st_t*>(val_struct);
+ // Get existing oper_status
+ uint8_t old_oper_status = 0;
+ UpplReturnCode read_status = GetOperStatus(db_conn, data_type,
+ key_struct,
+ old_oper_status);
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
vector<string> vect_prim_keys;
ctr_key.controller_name;
pfc_log_debug("logical port set oper_status");
if (!controller_name.empty()) {
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
}
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
(const char*) obj_val_logical_port->logical_port.physical_port_id;
}
-
if (!domain_name.empty()) {
- vect_prim_keys.push_back(DOMAIN_NAME);
- PhyUtil::FillDbSchema(DOMAIN_NAME, domain_name,
+ vect_prim_keys.push_back(DOMAIN_NAME_STR);
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_NAME, domain_name,
domain_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
}
if (!port_id.empty()) {
- vect_prim_keys.push_back(LP_PORT_ID);
- PhyUtil::FillDbSchema(LP_PORT_ID, port_id,
+ vect_prim_keys.push_back(LP_PORT_ID_STR);
+ PhyUtil::FillDbSchema(unc::uppl::LP_PORT_ID, port_id,
port_id.length(), DATATYPE_UINT8_ARRAY_320,
vect_table_attr_schema);
}
if (!switch_id.empty()) {
- vect_prim_keys.push_back(LP_SWITCH_ID);
- PhyUtil::FillDbSchema(LP_SWITCH_ID, switch_id,
+ vect_prim_keys.push_back(LP_SWITCH_ID_STR);
+ PhyUtil::FillDbSchema(unc::uppl::LP_SWITCH_ID, switch_id,
switch_id.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
}
if (!phy_port_id.empty()) {
- vect_prim_keys.push_back(LP_PHYSICAL_PORT_ID);
- PhyUtil::FillDbSchema(LP_PHYSICAL_PORT_ID, phy_port_id,
+ vect_prim_keys.push_back(LP_PHYSICAL_PORT_ID_STR);
+ PhyUtil::FillDbSchema(unc::uppl::LP_PHYSICAL_PORT_ID, phy_port_id,
phy_port_id.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
}
string oper_value = PhyUtil::uint8tostr(oper_status);
- PhyUtil::FillDbSchema(LP_OPER_STATUS, oper_value,
+ PhyUtil::FillDbSchema(unc::uppl::LP_OPER_STATUS, oper_value,
oper_value.length(), DATATYPE_UINT16,
vect_table_attr_schema);
string valid_flag;
// Update valid flag as well
- UpplReturnCode get_ret = GetValidFlag(data_type, key_struct, &valid_flag);
+ UpplReturnCode get_ret = GetValidFlag(db_conn, data_type,
+ key_struct, &valid_flag);
if (get_ret == UPPL_RC_SUCCESS) {
string new_valid = valid_flag.substr(0, 5);
new_valid += "1";
pfc_log_debug("New Valid to be set: %s", new_valid.c_str());
- PhyUtil::FillDbSchema(LP_CTR_VALID, new_valid,
+ PhyUtil::FillDbSchema(unc::uppl::LP_CTR_VALID, new_valid,
new_valid.length(), DATATYPE_UINT8_ARRAY_6,
vect_table_attr_schema);
}
DBTableSchema kt_logicalport_dbtableschema;
- kt_logicalport_dbtableschema.set_table_name(UPPL_LOGICALPORT_TABLE);
+ kt_logicalport_dbtableschema.set_table_name(unc::uppl::LOGICALPORT_TABLE);
kt_logicalport_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_logicalport_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS update_db_status =
physical_layer->get_odbc_manager()->UpdateOneRow(
(unc_keytype_datatype_t)data_type,
- kt_logicalport_dbtableschema);
- if (update_db_status != ODBCM_RC_SUCCESS) {
+ kt_logicalport_dbtableschema, db_conn);
+ if (update_db_status == ODBCM_RC_ROW_NOT_EXISTS) {
+ pfc_log_info("No instance available for update");
+ } else if (update_db_status != ODBCM_RC_SUCCESS) {
// log error
pfc_log_error("oper_status update operation failed");
return UPPL_RC_ERR_DB_UPDATE;
- } else {
+ } else if (old_oper_status != oper_status) {
// Notify operstatus change to northbound
- val_logical_port_st old_val_logical_port, new_val_logical_port;
- uint8_t old_oper_status = 0;
- UpplReturnCode read_status = GetOperStatus(data_type,
- key_struct,
- old_oper_status);
if (read_status == UPPL_RC_SUCCESS && data_type != UNC_DT_IMPORT) {
- memset(old_val_logical_port.valid, 0, 2);
+ val_logical_port_st old_val_logical_port, new_val_logical_port;
+ memset(&old_val_logical_port, 0, sizeof(val_logical_port_st));
+ memset(&new_val_logical_port, 0, sizeof(val_logical_port_st));
old_val_logical_port.oper_status = old_oper_status;
old_val_logical_port.valid[kIdxLogicalPortStOperStatus] = UNC_VF_VALID;
- memset(new_val_logical_port.valid, 0, 2);
new_val_logical_port.oper_status = oper_status;
new_val_logical_port.valid[kIdxLogicalPortStOperStatus] = UNC_VF_VALID;
int err = 0;
// Send notification to Northbound
- ServerEvent ser_evt(
- (pfc_ipcevtype_t)UPPL_EVENTS_KT_LOGICAL_PORT, err);
- ser_evt.addOutput((uint32_t)UNC_OP_UPDATE);
- ser_evt.addOutput(data_type);
- ser_evt.addOutput((uint32_t)UPPL_EVENTS_KT_LOGICAL_PORT);
- ser_evt.addOutput(*obj_key_logical_port);
- ser_evt.addOutput(new_val_logical_port);
- ser_evt.addOutput(old_val_logical_port);
- PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
- // Notify operstatus modifications
- UpplReturnCode status = (UpplReturnCode) physical_layer
- ->get_ipc_connection_manager()->SendEvent(&ser_evt);
- pfc_log_debug("Event notification status %d", status);
+ ServerEvent ser_evt((pfc_ipcevtype_t)UPPL_EVENTS_KT_LOGICAL_PORT, err);
+ northbound_event_header rsh = {UNC_OP_UPDATE,
+ data_type,
+ UNC_KT_LOGICAL_PORT};
+ err = PhyUtil::sessOutNBEventHeader(ser_evt, rsh);
+ err |= ser_evt.addOutput(*obj_key_logical_port);
+ err |= ser_evt.addOutput(new_val_logical_port);
+ err |= ser_evt.addOutput(old_val_logical_port);
+ if (err == 0) {
+ pfc_log_debug("%s",
+ (IpctUtil::get_string(*obj_key_logical_port)).c_str());
+ pfc_log_debug("%s",
+ (IpctUtil::get_string(new_val_logical_port)).c_str());
+ pfc_log_debug("%s",
+ (IpctUtil::get_string(old_val_logical_port)).c_str());
+ PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
+ // Notify operstatus modifications
+ UpplReturnCode status = (UpplReturnCode) physical_layer
+ ->get_ipc_connection_manager()->SendEvent(&ser_evt);
+ pfc_log_debug("Event notification status %d", status);
+ } else {
+ pfc_log_error("Server Event addOutput failed");
+ }
}
}
return UPPL_RC_SUCCESS;
}
-/** IsKeyExists
- * * @Description : This function checks whether the logicalport_id exists in DB
- * * * @param[in] : data type and key value
- * * * @return : Success or associated error code
- * */
-UpplReturnCode Kt_LogicalPort::IsKeyExists(unc_keytype_datatype_t data_type,
- vector<string> key_values) {
+/**
+ * @Description : This function checks whether the logicalport_id exists in DB
+ * @param[in] : data type - specifies the data base type i.e UNC_DT_STATE
+ * or UNC_DT_IMPORT
+ * key value - vector to hold the key structure values to be
+ * checked in DB
+ * @return : UPPL_RC_SUCCESS - if the row exist in DB
+ * UPPL_RC_NO_SUCH_INSTANCE - if the row doesnt exist in DB
+ **/
+UpplReturnCode Kt_LogicalPort::IsKeyExists(
+ OdbcmConnectionHandler *db_conn,
+ unc_keytype_datatype_t data_type,
+ const vector<string> &key_values) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode check_status = UPPL_RC_SUCCESS;
if (key_values.empty()) {
// Construct Primary key list
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
if (!domain_name.empty()) {
- vect_prim_keys.push_back(DOMAIN_NAME);
+ vect_prim_keys.push_back(DOMAIN_NAME_STR);
}
if (!logicalport_id.empty()) {
- vect_prim_keys.push_back(LP_PORT_ID);
+ vect_prim_keys.push_back(LP_PORT_ID_STR);
}
// Construct TableAttrSchema structure
// TableAttrSchema holds table_name, primary key, attr_name
vector<TableAttrSchema> vect_table_attr_schema;
- TableAttrSchema kt_logicalport_table_attr_schema;
list< vector<TableAttrSchema> > row_list;
// controller_name
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// domain_name
- pfc_log_info("domain name: %s", domain_name.c_str());
- PhyUtil::FillDbSchema(DOMAIN_NAME, domain_name,
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_NAME, domain_name,
domain_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// port_id
- PhyUtil::FillDbSchema(LP_PORT_ID, logicalport_id,
+ PhyUtil::FillDbSchema(unc::uppl::LP_PORT_ID, logicalport_id,
logicalport_id.length(), DATATYPE_UINT8_ARRAY_320,
vect_table_attr_schema);
- kt_logicalport_dbtableschema.set_table_name(UPPL_LOGICALPORT_TABLE);
+ kt_logicalport_dbtableschema.set_table_name(unc::uppl::LOGICALPORT_TABLE);
kt_logicalport_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_logicalport_dbtableschema.set_row_list(row_list);
// Send request to ODBC for controlle_table
ODBCM_RC_STATUS check_db_status = physical_layer->get_odbc_manager()->\
- IsRowExists(data_type, kt_logicalport_dbtableschema);
+ IsRowExists(data_type, kt_logicalport_dbtableschema, db_conn);
if (check_db_status == ODBCM_RC_ROW_EXISTS) {
pfc_log_debug("DB returned success for Row exists");
} else {
- pfc_log_error("DB Returned failure for IsRowExists");
+ pfc_log_info("DB Returned failure for IsRowExists");
check_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
}
return check_status;
}
-/** PopulateDBSchemaForKtTable
- * * @Description : This function populates the DBAttrSchema to be used to send
- * request to ODBC
- * * * @param[in] : DBTableSchema, key_struct, val_struct, operation_type
- * * * @return : Success or associated error code
+/**
+ * @Description : This function is used to populate the db schema using the
+ * given key struct, value struct, data_type, operation,
+ * option1 and option
+ * @param[in] : kt_logicalport_dbtableschema - object of type DBTableSchema
+ * key_struct - void pointer to be type cast into logical port key type
+ * val_struct - void pointer to be type cast into logical port value type
+ * operation_type - specifies the operation type i.e
+ * UNC_OP_READ or
+ * UNC_OP_READ_SIBLING_BEGIN etc
+ * option1/option2 - specifies any additional option for populating in DB
+ * vect_key_operations - vector of type ODBCMOperator
+ * old_value_struct - holds the old value structure of the
+ * logical port key type
+ * row_status - enum indicating the row status of logicalport
+ * type entries in db
+ * is_filtering/is_state - bool variables
+ * @return : None
* */
void Kt_LogicalPort::PopulateDBSchemaForKtTable(
+ OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_logicalport_dbtableschema,
void* key_struct,
void* val_struct,
uint8_t operation_type,
+ uint32_t data_type,
uint32_t option1,
uint32_t option2,
vector<ODBCMOperator> &vect_key_operations,
// controller_name
string controller_name =
(const char*)obj_key_logical_port->domain_key.ctr_key.controller_name;
- pfc_log_info("controller name: %s", controller_name.c_str());
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ pfc_log_debug("controller name: %s", controller_name.c_str());
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// domain_name
string domain_name =
(const char*)obj_key_logical_port->domain_key.domain_name;
- pfc_log_info("domain name: %s", domain_name.c_str());
- PhyUtil::FillDbSchema(DOMAIN_NAME, domain_name,
+ pfc_log_debug("domain name: %s", domain_name.c_str());
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_NAME, domain_name,
domain_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// port_id
// ignore port_id
port_id = "";
}
- pfc_log_info("port_id : %s", port_id.c_str());
- PhyUtil::FillDbSchema(LP_PORT_ID, port_id,
+ pfc_log_debug("port_id : %s", port_id.c_str());
+ PhyUtil::FillDbSchema(unc::uppl::LP_PORT_ID, port_id,
port_id.length(), DATATYPE_UINT8_ARRAY_320,
vect_table_attr_schema);
if (!controller_name.empty()) {
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
}
if (!domain_name.empty()) {
- vect_prim_keys.push_back(DOMAIN_NAME);
+ vect_prim_keys.push_back(DOMAIN_NAME_STR);
}
val_logical_port_st_t *val_logical_port_valid_st = NULL;
if (operation_type == UNC_OP_UPDATE) {
// get valid array for update req
pfc_log_debug("Get Valid value from logicalport Update Valid Flag");
val_logical_port_valid_st = new val_logical_port_st_t();
- GetLogicalPortValidFlag(key_struct, *val_logical_port_valid_st);
+ GetLogicalPortValidFlag(db_conn, key_struct, *val_logical_port_valid_st,
+ data_type);
old_value_struct = reinterpret_cast<void*>(val_logical_port_valid_st);
}
uint16_t valid_val = 0, prev_db_val = 0;
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(LP_DESCRIPTION, value,
+ PhyUtil::FillDbSchema(unc::uppl::LP_DESCRIPTION, LP_DESCRIPTION_STR, value,
value.length(), DATATYPE_UINT8_ARRAY_128,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(LP_PORT_TYPE, value,
+ PhyUtil::FillDbSchema(unc::uppl::LP_PORT_TYPE, LP_PORT_TYPE_STR, value,
value.length(), DATATYPE_UINT16,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(LP_SWITCH_ID, value,
+ PhyUtil::FillDbSchema(unc::uppl::LP_SWITCH_ID, LP_SWITCH_ID_STR, value,
value.length(), DATATYPE_UINT8_ARRAY_256,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(LP_PHYSICAL_PORT_ID, value,
- value.length(), DATATYPE_UINT8_ARRAY_32,
+ PhyUtil::FillDbSchema(unc::uppl::LP_PHYSICAL_PORT_ID, LP_PHYSICAL_PORT_ID_STR,
+ value, value.length(), DATATYPE_UINT8_ARRAY_32,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
value.clear();
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(LP_OPER_DOWN_CRITERIA, value,
+ PhyUtil::FillDbSchema(unc::uppl::LP_OPER_DOWN_CRITERIA,
+ LP_OPER_DOWN_CRITERIA_STR, value,
value.length(), DATATYPE_UINT16,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(LP_OPER_STATUS, value,
+ PhyUtil::FillDbSchema(unc::uppl::LP_OPER_STATUS, LP_OPER_STATUS_STR, value,
value.length(), DATATYPE_UINT16,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
stringstream dummy_valid;
valid_val = UPPL_NO_VAL_STRUCT;
prev_db_val = 0;
- PhyUtil::FillDbSchema(LP_CTR_VALID, valid.str(),
+ PhyUtil::FillDbSchema(unc::uppl::LP_CTR_VALID, LP_CTR_VALID_STR, valid.str(),
ODBCM_SIZE_6, DATATYPE_UINT8_ARRAY_6,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, dummy_valid);
// For read_bulk/ read_next port_id is required
if ((operation_type == UNC_OP_READ && !port_id.empty()) ||
operation_type != UNC_OP_READ) {
- vect_prim_keys.push_back(LP_PORT_ID);
+ vect_prim_keys.push_back(LP_PORT_ID_STR);
}
PhyUtil::reorder_col_attrs(vect_prim_keys, vect_table_attr_schema);
- kt_logicalport_dbtableschema.set_table_name(UPPL_LOGICALPORT_TABLE);
+ kt_logicalport_dbtableschema.set_table_name(unc::uppl::LOGICALPORT_TABLE);
kt_logicalport_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_logicalport_dbtableschema.set_row_list(row_list);
return;
}
/**
- * * @Description : This function populate val_logical_port_t by value retrieved
- * from database
- * * * @param[in] : logicalportcommon table dbtable schema, openflow logicalport
- * db schema, value structure and max_rep_ct, operation type
- * * * @return : Filled val_logical_port and logicalport id
- * */
+ * @Description : This function is used to fill the ipc response structure
+ * based on the db schema retrieved from DB
+ * @param[in] : kt_logicalport_dbtableschema - object of type DBTableSchema
+ * vect_obj_val_logical_port - vector to store the value
+ * structure of logical port
+ * max_rep_ct - specifies the maximum repetition count
+ * operation_type - indicates the operation type
+ * vect_logical_port_id - vector to store the logical port id
+ * @return : None
+ **/
void Kt_LogicalPort::FillLogicalPortValueStructure(
+ OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_logicalport_dbtableschema,
vector<val_logical_port_st_t> &vect_obj_val_logical_port,
uint32_t &max_rep_ct,
uint32_t operation_type,
vector<key_logical_port_t> &vect_logical_port_id) {
- // populate IPC value structure based on the response recevied from DB
- list < vector<TableAttrSchema> > res_logical_port_row_list =
+ // populate IPC value structure based on the response received from DB
+ list < vector<TableAttrSchema> >& res_logical_port_row_list =
kt_logicalport_dbtableschema.get_row_list();
list < vector<TableAttrSchema> > :: iterator res_logical_port_iter =
max_rep_ct = res_logical_port_row_list.size();
pfc_log_debug("res_logical_port_row_list.size: %d", max_rep_ct);
key_logical_port_t obj_key_logical_port;
+ memset(&obj_key_logical_port, '\0', sizeof(obj_key_logical_port));
for (; res_logical_port_iter != res_logical_port_row_list.end();
++res_logical_port_iter) {
++vect_logical_port_iter) {
// populate values from logicalport_table
TableAttrSchema tab_schema = (*vect_logical_port_iter);
- string attr_name = tab_schema.table_attribute_name;
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
string attr_value;
- if (attr_name == LP_PORT_ID) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_320);
- memcpy(obj_key_logical_port.port_id,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("logical_port id: %s", reinterpret_cast<char *>
- (&obj_key_logical_port.port_id));
- }
- if (attr_name == DOMAIN_NAME) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_key_logical_port.domain_key.domain_name,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("domain_name: %s", reinterpret_cast<char *>
- (&obj_key_logical_port.domain_key.domain_name));
- }
- if (attr_name == CTR_NAME) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_key_logical_port.domain_key.ctr_key.controller_name,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("controller_name: %s", reinterpret_cast<char *>
- (&obj_key_logical_port.domain_key.ctr_key.controller_name));
- }
- if (attr_name == LP_DESCRIPTION) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_128);
- memcpy(obj_val_logical_port.description,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("description: %s", attr_value.c_str());
- }
- if (attr_name == LP_PORT_TYPE) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- obj_val_logical_port.port_type = atoi(attr_value.c_str());
- pfc_log_debug("port_type: %s", attr_value.c_str());
- }
- if (attr_name == LP_SWITCH_ID) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_256);
- memcpy(obj_val_logical_port.switch_id,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("switch_id: %s", attr_value.c_str());
- }
- if (attr_name == LP_PHYSICAL_PORT_ID) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_val_logical_port.physical_port_id,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("physical_port_id: %s", attr_value.c_str());
- }
- if (attr_name == LP_OPER_DOWN_CRITERIA) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- obj_val_logical_port.oper_down_criteria =
- atoi(attr_value.c_str());
- pfc_log_debug("oper_down_criteria: %s", attr_value.c_str());
- }
- if (attr_name == LP_OPER_STATUS) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- obj_val_logical_port_st.oper_status =
- atoi(attr_value.c_str());
- pfc_log_debug("oper_status: %s", attr_value.c_str());
- }
- if (attr_name == LP_CTR_VALID) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_6);
- memset(obj_val_logical_port_st.valid, 0, 2);
- memset(obj_val_logical_port.valid, 0, 5);
- FrameValidValue(attr_value, obj_val_logical_port_st,
- obj_val_logical_port);
- pfc_log_debug("valid: %s", attr_value.c_str());
+ switch (attr_name) {
+ case unc::uppl::LP_PORT_ID:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_key_logical_port.port_id,
+ DATATYPE_UINT8_ARRAY_320);
+ pfc_log_debug("logical_port id: %s", reinterpret_cast<char *>
+ (&obj_key_logical_port.port_id));
+ break;
+
+ case unc::uppl::DOMAIN_NAME:
+ PhyUtil::GetValueFromDbSchemaStr(
+ tab_schema,
+ obj_key_logical_port.domain_key.domain_name,
+ DATATYPE_UINT8_ARRAY_32);
+ pfc_log_debug("domain_name: %s", reinterpret_cast<char *>
+ (&obj_key_logical_port.domain_key.domain_name));
+ break;
+
+ case unc::uppl::CTR_NAME:
+ PhyUtil::GetValueFromDbSchemaStr(
+ tab_schema,
+ obj_key_logical_port.domain_key.ctr_key.controller_name,
+ DATATYPE_UINT8_ARRAY_32);
+ pfc_log_debug("controller_name: %s", reinterpret_cast<char *>
+ (&obj_key_logical_port.domain_key.ctr_key.controller_name));
+ break;
+
+ case unc::uppl::LP_DESCRIPTION:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_val_logical_port.description,
+ DATATYPE_UINT8_ARRAY_128);
+ pfc_log_debug("description: %s", attr_value.c_str());
+ break;
+
+ case unc::uppl::LP_PORT_TYPE:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT16);
+ obj_val_logical_port.port_type = atoi(attr_value.c_str());
+ pfc_log_debug("port_type: %s", attr_value.c_str());
+ break;
+
+ case unc::uppl::LP_SWITCH_ID:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_val_logical_port.switch_id,
+ DATATYPE_UINT8_ARRAY_256);
+ pfc_log_debug("switch_id: %s", attr_value.c_str());
+ break;
+
+ case unc::uppl::LP_PHYSICAL_PORT_ID:
+ PhyUtil::GetValueFromDbSchemaStr(
+ tab_schema,
+ obj_val_logical_port.physical_port_id,
+ DATATYPE_UINT8_ARRAY_32);
+ pfc_log_debug("physical_port_id: %s", attr_value.c_str());
+ break;
+
+ case unc::uppl::LP_OPER_DOWN_CRITERIA:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT16);
+ obj_val_logical_port.oper_down_criteria =
+ atoi(attr_value.c_str());
+ pfc_log_debug("oper_down_criteria: %s", attr_value.c_str());
+ break;
+
+ case unc::uppl::LP_OPER_STATUS:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT16);
+ obj_val_logical_port_st.oper_status =
+ atoi(attr_value.c_str());
+ pfc_log_debug("oper_status: %s", attr_value.c_str());
+ break;
+
+ case unc::uppl::LP_CTR_VALID:
+ uint8_t lp_valid[ODBCM_SIZE_6];
+ memset(lp_valid, '\0', sizeof(lp_valid));
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema, lp_valid,
+ DATATYPE_UINT8_ARRAY_6);
+ memset(obj_val_logical_port_st.valid, '\0', sizeof(obj_val_logical_port_st.valid));
+ memset(obj_val_logical_port.valid, '\0', sizeof(obj_val_logical_port.valid));
+ FrameValidValue(reinterpret_cast<const char*> (lp_valid),
+ obj_val_logical_port_st,
+ obj_val_logical_port);
+ pfc_log_debug("valid: %s", lp_valid);
+ break;
+
+ default:
+ pfc_log_info("Ignoring LogicalPort attribute %d", attr_name);
+ break;
}
}
// copy val_t to val_st_t structure
return;
}
-/** PerformRead
- * * @Description : This function reads the instance of UNC_KT_LOGICAL_PORT
- * based on operation type - READ, READ_SIBLING_BEGIN,
- * READ_SIBLING
- * * * @param[in] : ipc session id, configuration id, key_struct, value_struct,
- * data_type, operation type, ServerSession, option1, option2,
- * max_rep_ct
- * * * @return : Success or associated error code
- * */
-UpplReturnCode Kt_LogicalPort::PerformRead(uint32_t session_id,
- uint32_t configuration_id,
- void* key_struct,
- void* val_struct,
- uint32_t data_type,
- uint32_t operation_type,
- ServerSession &sess,
- uint32_t option1,
- uint32_t option2,
- uint32_t max_rep_ct) {
+/**
+ * @Description : This function is used to read KT_LOGICAL_PORT instance in
+ * database table using key_ctr provided in IPC request
+ * The IPC response would be filled in IPC session
+ * @param[in] : ipc session id - ipc session id used for TC validation
+ * configuration id - configuration id used for TC validation
+ * key_struct - void pointer to be type cast into logical port
+ * key type
+ * value_struct - void pointer to be type cast into logical port
+ * value structure
+ * data_type - specifies the data base type i.e UNC_DT_STATE
+ * or UNC_DT_IMPORT
+ * operation type - indicates the operation type
+ * sess - ipc server session where the response has to be added
+ * option1,option2 - specifies any additional condition for read
+ * operation
+ * max_rep_ct - indicates the maximum repetition count
+ * @return : UPPL_RC_SUCCESS - if the read operation is successful
+ * UPPL_RC_ERR_* - read operation failed
+ **/
+UpplReturnCode Kt_LogicalPort::PerformRead(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
+ uint32_t configuration_id,
+ void* key_struct,
+ void* val_struct,
+ uint32_t data_type,
+ uint32_t operation_type,
+ ServerSession &sess,
+ uint32_t option1,
+ uint32_t option2,
+ uint32_t max_rep_ct) {
pfc_log_debug("Inside PerformRead");
key_logical_port_t *obj_key_logical_port =
reinterpret_cast<key_logical_port_t*>(key_struct);
vector<key_logical_port_t> vect_logicalport_id;
vector<val_logical_port_t> vect_val_logical_port;
vector<val_logical_port_st_t> vect_val_logical_port_st;
- read_status = ReadLogicalPortValFromDB(key_struct,
+ read_status = ReadLogicalPortValFromDB(db_conn,
+ key_struct,
val_struct,
data_type,
operation_type,
return UPPL_RC_SUCCESS;
}
/** ReadLogicalPortValFromDB
- * * @Description : This function reads the instance of UNC_KT_LOGICAL_PORT
- * based on operation type - READ, READ_SIBLING_BEGIN,
- * READ_SIBLING from data base
- * * * @param[in] : key_struct, value_struct, ipc session id, configuration id,
- * data_type, operation type, max_rep_ct
- * * * @return : Success or associated error code
- * */
+ * @Description : This function is used to read KT_LOGICAL_PORT instance in
+ * database table using key_ctr provided in IPC request
+ * and operation_type
+ * @param[in] : key_struct - void pointer to be type cast into logical
+ * port key structure
+ * value_struct - void pointer to be type cast into logical port
+ * value structure
+ * data_type - indicates the data base type
+ * operation_type - indicates the operation type UNC_OP*
+ * max_rep_ct - indicates the maximum repetition count
+ * vect_val_logical_port - vector to store the val_logical_port_t
+ * structure
+ * vect_val_logical_port_st - vector to store the
+ * val_logical_port_st_t structure
+ * logicalport_id - vector of type key_logical_port_t to store
+ * the logical port id
+ * @return : UPPL_RC_SUCCESS - read operation is success
+ * UPPL_RC_ERR_DB_GET - read operation is failure
+ **/
UpplReturnCode Kt_LogicalPort::ReadLogicalPortValFromDB(
+ OdbcmConnectionHandler *db_conn,
void* key_struct,
void* val_struct,
uint32_t data_type,
vector<val_logical_port_t> &vect_val_logical_port,
vector<val_logical_port_st_t> &vect_val_logical_port_st,
vector<key_logical_port_t> &logicalport_id) {
- PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
-
- UpplReturnCode read_status = UPPL_RC_SUCCESS;
- ODBCM_RC_STATUS read_db_status = ODBCM_RC_SUCCESS;
if (operation_type < UNC_OP_READ) {
// Unsupported operation type for this function
return UPPL_RC_SUCCESS;
}
+ PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
+ UpplReturnCode read_status = UPPL_RC_SUCCESS;
+ ODBCM_RC_STATUS read_db_status = ODBCM_RC_SUCCESS;
DBTableSchema kt_logicalport_dbtableschema;
void* old_value_struct;
vector<ODBCMOperator> vect_key_operations;
- PopulateDBSchemaForKtTable(kt_logicalport_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_logicalport_dbtableschema,
key_struct,
val_struct,
- operation_type, 0, 0, vect_key_operations,
+ operation_type, data_type,
+ 0, 0, vect_key_operations,
old_value_struct);
if (operation_type == UNC_OP_READ) {
read_db_status = physical_layer->get_odbc_manager()->
GetOneRow((unc_keytype_datatype_t)data_type,
- kt_logicalport_dbtableschema);
+ kt_logicalport_dbtableschema, db_conn);
} else {
read_db_status = physical_layer->get_odbc_manager()->
GetBulkRows((unc_keytype_datatype_t)data_type, max_rep_ct,
kt_logicalport_dbtableschema,
- (unc_keytype_operation_t)operation_type);
+ (unc_keytype_operation_t)operation_type, db_conn);
}
if (read_db_status == ODBCM_RC_RECORD_NOT_FOUND) {
pfc_log_debug("No record found");
read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
return read_status;
+ } else if (read_db_status == ODBCM_RC_CONNECTION_ERROR) {
+ read_status = UPPL_RC_ERR_DB_ACCESS;
+ pfc_log_error("Read operation has failed with error %d", read_db_status);
+ return read_status;
} else if (read_db_status != ODBCM_RC_SUCCESS) {
read_status = UPPL_RC_ERR_DB_GET;
// log error to log daemon
pfc_log_error("Read operation has failed with error %d", read_db_status);
return read_status;
}
- FillLogicalPortValueStructure(kt_logicalport_dbtableschema,
+ FillLogicalPortValueStructure(db_conn, kt_logicalport_dbtableschema,
vect_val_logical_port_st,
max_rep_ct,
operation_type,
return read_status;
}
-/** getChildKeyStruct
- * * @Description : This function returns the void * of child key structures
- * * * @param[in] : child class index and logicalport name
- * * * @return : void * key structure
+/**
+ * @Description : This function returns the pointer to the child key structures
+ * @param[in] : child_class - variable to store the child class enum
+ * logicalport_id - string to store the logical port id
+ * controller_name - string to store the controller name
+ * domain_name - string to store the domain name
+ * @return : returns the pointer to the child key structure
* */
void* Kt_LogicalPort::getChildKeyStruct(int child_class,
string logicalport_id,
}
}
-/** FreeChildKeyStruct
- * * @Description : This function clears the void* of child key structures
- * * * @param[in] : child class index and logicalport name
- * * * @return : void * key structure
- * */
+/**
+ * @Description : This function clears the pointer to the child key structures
+ * @param[in] : child class - indicates the child class
+ * key_struct - void pointer to be type cast to the child
+ * key type
+ * @return : void
+ **/
void Kt_LogicalPort::FreeChildKeyStruct(int child_class,
void *key_struct) {
switch (child_class) {
}
}
-/** Fill_Attr_Syntax_Map
- * * @Description : This function populates the values to be used for attribute
- * validation
- * * * @param[in] : None
- * * * @return : None
- * */
+/**
+ * @Description : This function populates the values to be used for attribute
+ * validation
+ * @param[in] : None
+ * @return : None
+ **/
void Kt_LogicalPort::Fill_Attr_Syntax_Map() {
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map;
Kt_Class_Attr_Syntax objKeyAttrSyntax =
{ PFC_IPCTYPE_STRING, 0, 0, 1, 320, true, "" };
- attr_syntax_map[LP_PORT_ID] = objKeyAttrSyntax;
+ attr_syntax_map[LP_PORT_ID_STR] = objKeyAttrSyntax;
Kt_Class_Attr_Syntax objKeyAttr1Syntax4 =
{ PFC_IPCTYPE_UINT8, 0, 0, 1, 32, true, "" };
- attr_syntax_map[DOMAIN_NAME] = objKeyAttr1Syntax4;
+ attr_syntax_map[DOMAIN_NAME_STR] = objKeyAttr1Syntax4;
Kt_Class_Attr_Syntax objKeyAttr1Syntax5 =
{ PFC_IPCTYPE_UINT8, 0, 0, 1, 32, true, "" };
- attr_syntax_map[CTR_NAME] = objKeyAttr1Syntax5;
+ attr_syntax_map[CTR_NAME_STR] = objKeyAttr1Syntax5;
Kt_Class_Attr_Syntax objAttrDescSyntax =
{ PFC_IPCTYPE_STRING, 0, 0, 0, 128, false, "" };
- attr_syntax_map[LP_DESCRIPTION] = objAttrDescSyntax;
-
- Kt_Class_Attr_Syntax objAttrPortTypeSyntax =
- { PFC_IPCTYPE_UINT8, 0, 4, 0, 0, true, "" };
- attr_syntax_map[LP_PORT_TYPE] = objAttrPortTypeSyntax;
+ attr_syntax_map[LP_DESCRIPTION_STR] = objAttrDescSyntax;
Kt_Class_Attr_Syntax objAttrSwitchIdSyntax =
{ PFC_IPCTYPE_STRING, 0, 0, 0, 256, false, "" };
- attr_syntax_map[LP_SWITCH_ID] = objAttrSwitchIdSyntax;
+ attr_syntax_map[LP_SWITCH_ID_STR] = objAttrSwitchIdSyntax;
Kt_Class_Attr_Syntax objAttrPhyPortIdSyntax =
{ PFC_IPCTYPE_STRING, 0, 0, 0, 32, false, "" };
- attr_syntax_map[LP_PHYSICAL_PORT_ID] = objAttrPhyPortIdSyntax;
+ attr_syntax_map[LP_PHYSICAL_PORT_ID_STR] = objAttrPhyPortIdSyntax;
Kt_Class_Attr_Syntax objAttrOpDownCriteriaSyntax =
{ PFC_IPCTYPE_UINT8, 0, 1, 0, 0, false, "" };
- attr_syntax_map[LP_OPER_DOWN_CRITERIA] = objAttrOpDownCriteriaSyntax;
+ attr_syntax_map[LP_OPER_DOWN_CRITERIA_STR] = objAttrOpDownCriteriaSyntax;
Kt_Class_Attr_Syntax objAttrValidSyntax =
{ PFC_IPCTYPE_STRING, 0, 0, 0, 5, false, "" };
- attr_syntax_map[LP_CTR_VALID] = objAttrValidSyntax;
+ attr_syntax_map[LP_CTR_VALID_STR] = objAttrValidSyntax;
+ attr_syntax_map_all[UNC_KT_LOGICAL_PORT] = attr_syntax_map;
}
-/** GetAllPortId
- * * @Description : This function returns all the associated physical/logical
- * port ids for a given switch
- * * @param[in] : controller_name, switch_id, port_id flag
- * * @return : vector of logical_port_id
- */
-void Kt_LogicalPort::GetAllPortId(uint32_t data_type,
+/**
+ * @Description : This function returns all the associated physical/logical
+ * port ids for a given switch
+ * @param[in] : data_type - indicates the data type
+ * controller_name - string to store the controller_name
+ * switch_id - string to store the switch_id
+ * logical_port_id - vector of type string to store the
+ * logical port id
+ * is_single_logical_port - indicates type of logical port -
+ * true - UPPL_LP_SWITCH
+ * false - UPPL_LP_PHYSICAL_PORT
+ * @return : None
+ **/
+void Kt_LogicalPort::GetAllPortId(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
string controller_name,
string switch_id,
+ string &domain_name,
vector <string> &logical_port_id,
pfc_bool_t is_single_logical_port) {
DBTableSchema kt_logicalport_dbtableschema;
vector<TableAttrSchema> vect_table_attr_schema;
- list < vector<TableAttrSchema> > row_list;
vector<string> vect_prim_keys;
vector<ODBCMOperator> vect_operators;
- vect_prim_keys.push_back(CTR_NAME);
- vect_prim_keys.push_back(LP_SWITCH_ID);
- vect_prim_keys.push_back(LP_PORT_TYPE);
+ list < vector<TableAttrSchema> > row_list_in;
+ vect_prim_keys.push_back(CTR_NAME_STR);
+ vect_prim_keys.push_back(LP_SWITCH_ID_STR);
+ vect_prim_keys.push_back(LP_PORT_TYPE_STR);
vect_operators.push_back(unc::uppl::EQUAL);
vect_operators.push_back(unc::uppl::EQUAL);
vect_operators.push_back(unc::uppl::EQUAL);
// controller_name
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// switch_id
- PhyUtil::FillDbSchema(LP_SWITCH_ID, switch_id,
+ PhyUtil::FillDbSchema(unc::uppl::LP_SWITCH_ID, switch_id,
switch_id.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
// port_type
string port_type = "";
if (is_single_logical_port == true) {
- port_type = "0"; // UPPL_LP_SWITCH;
+ port_type = "1"; // UPPL_LP_SWITCH;
} else {
- port_type = "1"; // UPPL_LP_PHYSICAL_PORT;
+ port_type = "2"; // UPPL_LP_PHYSICAL_PORT;
}
pfc_log_debug(
"GetAllPortId is called with is_single_logical_port:%d, port_type:%s",
static_cast<int>(is_single_logical_port), port_type.c_str());
- PhyUtil::FillDbSchema(LP_PORT_TYPE, port_type,
+ PhyUtil::FillDbSchema(unc::uppl::LP_PORT_TYPE, port_type,
port_type.length(), DATATYPE_UINT16,
vect_table_attr_schema);
string empty_id="";
// logical_port_id - to be fetched
- PhyUtil::FillDbSchema(LP_PORT_ID, empty_id,
+ PhyUtil::FillDbSchema(unc::uppl::LP_PORT_ID, empty_id,
empty_id.length(), DATATYPE_UINT8_ARRAY_320,
vect_table_attr_schema);
- kt_logicalport_dbtableschema.set_table_name(UPPL_LOGICALPORT_TABLE);
+ // domain_name - to be fetched
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_NAME, empty_id,
+ empty_id.length(), DATATYPE_UINT8_ARRAY_32,
+ vect_table_attr_schema);
+ kt_logicalport_dbtableschema.set_table_name(unc::uppl::LOGICALPORT_TABLE);
kt_logicalport_dbtableschema.set_primary_keys(vect_prim_keys);
- row_list.push_back(vect_table_attr_schema);
- kt_logicalport_dbtableschema.set_row_list(row_list);
+ row_list_in.push_back(vect_table_attr_schema);
+ kt_logicalport_dbtableschema.set_row_list(row_list_in);
// Call GetSibling Rows with operator specification
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
ODBCM_RC_STATUS read_db_status = physical_layer->get_odbc_manager()->
GetSiblingRows((unc_keytype_datatype_t)data_type, UPPL_MAX_REP_CT,
kt_logicalport_dbtableschema,
vect_operators,
- (unc_keytype_operation_t)UNC_OP_READ_SIBLING);
+ (unc_keytype_operation_t)UNC_OP_READ_SIBLING, db_conn);
if (read_db_status != ODBCM_RC_SUCCESS) {
pfc_log_debug("Get Sibling is not success");
return;
}
// Read all the logical port values
- row_list = kt_logicalport_dbtableschema.get_row_list();
+ list < vector<TableAttrSchema> >& row_list =
+ kt_logicalport_dbtableschema.get_row_list();
list < vector<TableAttrSchema> > :: iterator res_logical_port_iter =
row_list.begin();
uint32_t row_ct = row_list.size();
for (; vect_logical_port_iter != res_logical_port_table_attr_schema.end();
++vect_logical_port_iter) {
TableAttrSchema tab_schema = (*vect_logical_port_iter);
- string attr_name = tab_schema.table_attribute_name;
- string attr_value;
- if (attr_name == LP_PORT_ID) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_320);
- logical_port_id.push_back(attr_value);
- pfc_log_debug("logical_port id: %s", attr_value.c_str());
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
+ uint8_t port_id[ODBCM_SIZE_320];
+ uint8_t domain_val[ODBCM_SIZE_32];
+ switch (attr_name) {
+ case unc::uppl::LP_PORT_ID:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema, port_id,
+ DATATYPE_UINT8_ARRAY_320);
+ logical_port_id.push_back(reinterpret_cast<const char*> (port_id));
+ pfc_log_debug("logical_port id: %s", port_id);
+ break;
+ case unc::uppl::DOMAIN_NAME:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema, domain_val,
+ DATATYPE_UINT8_ARRAY_32);
+ domain_name = reinterpret_cast<const char*> (domain_val);
+ pfc_log_debug("domain_name: %s", domain_val);
+ break;
+ default:
+ break;
}
}
}
return;
}
-/** GetLogicalPortValidFlag
- * * @Description : This function reads the valid flag from DB
- * * * @param[in] : Key, value struct and newvalid val
- * * * @return : Success or associated error code
- * */
+/**
+ * @Description : This function reads the valid flag from DB
+ * @param[in] : key_struct - void pointer to be type cast to
+ * logical port key type
+ * val_logical_port_valid_st - value structure of logical port
+ * key type
+ * @return : UPPL_RC_SUCCESS - value structure read from DB is success
+ * UPPL_RC_ERR_* - value structure read from DB is failure
+ **/
UpplReturnCode Kt_LogicalPort::GetLogicalPortValidFlag(
+ OdbcmConnectionHandler *db_conn,
void *key_struct,
- val_logical_port_st_t &val_logical_port_valid_st) {
+ val_logical_port_st_t &val_logical_port_valid_st,
+ uint32_t data_type) {
UpplReturnCode return_code = UPPL_RC_SUCCESS;
// read the value structure from db
vector<void *> vectVal_logicalport;
vector<void *> vectkey_logicalport;
vectkey_logicalport.push_back(key_struct);
- return_code = ReadInternal(vectkey_logicalport,
+ return_code = ReadInternal(db_conn, vectkey_logicalport,
vectVal_logicalport,
- UNC_DT_STATE, UNC_OP_READ);
+ data_type, UNC_OP_READ);
if (return_code == UPPL_RC_SUCCESS) {
val_logical_port_st_t *obj_new_logicalport_val_vect =
reinterpret_cast<val_logical_port_st_t*> (vectVal_logicalport[0]);
logicalport_key = NULL;
}
} else {
- pfc_log_info("update logicalport valid ret null val");
+ pfc_log_debug("update logicalport valid ret null val");
}
}
return return_code;
}
-/** FrameValidValue
- * * @Description : This function converts the string value from db to uint8
- * * * @param[in] : Attribute value and val_ctr_st
- * * * @return : Success or associated error code
- * */
+/**
+ * @Description : This function converts the string value from db to uint8
+ * @param[in] : attr_value - string to store attribute value
+ * obj_val_logical_port_st/obj_val_logical_portt
+ * - struct variables of the logical port val structure
+ * @return : None
+ **/
void Kt_LogicalPort::FrameValidValue(
string attr_value,
val_logical_port_st &obj_val_logical_port_st,
return;
}
-/** GetValidFlag
- * * @Description : This function retrieves the valid flag from DB
- * * * @param[in] : Key and valid_flag
- * * * @return : Success or associated error code
- * */
+/**
+ * @Description : This function gets the valid flag value from DB
+ * @param[in] : data_type - indicates the data base type
+ * key_struct - void pointer type to be type cast to logical port
+ * key structure
+ * valid_flag - string pointer to hold the valid flag
+ * @return : UPPL_RC_SUCCESS - if valid flag is received from db
+ * UPPL_RC_DB_GET - if there is error in receiving the valid
+ * flag from DB
+ **/
UpplReturnCode Kt_LogicalPort::GetValidFlag(
+ OdbcmConnectionHandler *db_conn,
uint32_t data_type,
void* key_struct,
string *valid_flag) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
key_logical_port_t *obj_key_logical_port =
reinterpret_cast<key_logical_port_t*>(key_struct);
- TableAttrSchema kt_logical_port_table_attr_schema;
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
vector<string> vect_prim_keys;
ctr_key.controller_name;
if (!controller_name.empty()) {
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
+ controller_name.length(), DATATYPE_UINT8_ARRAY_32,
+ vect_table_attr_schema);
}
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
- controller_name.length(), DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
-
string domain_name = (const char*)obj_key_logical_port->
domain_key.domain_name;
if (!domain_name.empty()) {
- vect_prim_keys.push_back(DOMAIN_NAME);
+ vect_prim_keys.push_back(DOMAIN_NAME_STR);
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_NAME, domain_name,
+ domain_name.length(), DATATYPE_UINT8_ARRAY_32,
+ vect_table_attr_schema);
}
-
- PhyUtil::FillDbSchema(DOMAIN_NAME, domain_name,
- domain_name.length(), DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
string port_id = (const char*)obj_key_logical_port->port_id;
if (!port_id.empty()) {
- vect_prim_keys.push_back(LP_PORT_ID);
+ vect_prim_keys.push_back(LP_PORT_ID_STR);
+ PhyUtil::FillDbSchema(unc::uppl::LP_PORT_ID, port_id,
+ port_id.length(), DATATYPE_UINT8_ARRAY_320,
+ vect_table_attr_schema);
}
- PhyUtil::FillDbSchema(LP_PORT_ID, port_id,
- port_id.length(), DATATYPE_UINT8_ARRAY_320,
- vect_table_attr_schema);
-
string valid_empty;
- PhyUtil::FillDbSchema(LP_CTR_VALID, valid_empty,
+ PhyUtil::FillDbSchema(unc::uppl::LP_CTR_VALID, valid_empty,
valid_empty.length(),
DATATYPE_UINT8_ARRAY_6,
vect_table_attr_schema);
DBTableSchema kt_logicalport_dbtableschema;
- kt_logicalport_dbtableschema.set_table_name(UPPL_LOGICALPORT_TABLE);
+ kt_logicalport_dbtableschema.set_table_name(unc::uppl::LOGICALPORT_TABLE);
kt_logicalport_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_logicalport_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS read_db_status =
physical_layer->get_odbc_manager()->GetOneRow(
(unc_keytype_datatype_t)data_type,
- kt_logicalport_dbtableschema);
+ kt_logicalport_dbtableschema, db_conn);
if (read_db_status != ODBCM_RC_SUCCESS) {
// log error
pfc_log_error("valid flag read operation failed");
}
// read the valid value
- list < vector<TableAttrSchema> > res_logicalport_row_list =
+ list < vector<TableAttrSchema> >& res_logicalport_row_list =
kt_logicalport_dbtableschema.get_row_list();
list < vector<TableAttrSchema> >::iterator res_logicalport_iter =
res_logicalport_row_list.begin();
for (; vect_logicalport_iter != res_logicalport_table_attr_schema.end();
++vect_logicalport_iter) {
TableAttrSchema tab_schema = (*vect_logicalport_iter);
- string attr_name = tab_schema.table_attribute_name;
- if (attr_name == LP_CTR_VALID) {
- PhyUtil::GetValueFromDbSchema(tab_schema, *valid_flag,
- DATATYPE_UINT8_ARRAY_6);
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
+ if (attr_name == unc::uppl::LP_CTR_VALID) {
+ uint8_t valid_val[ODBCM_SIZE_6];
+ memset(valid_val, '\0', sizeof(valid_val));
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema, valid_val,
+ DATATYPE_UINT8_ARRAY_6);
+ *valid_flag = reinterpret_cast<const char*> (valid_val);
pfc_log_debug("valid_flag from db: %s", valid_flag->c_str());
break;
}
return UPPL_RC_SUCCESS;
}
+/**
+ * @Description : This function gets the oper status for the assicated
+ * physical port
+ * @param[in] : logical_port_key - structure variable of type
+ * key_logical_port_t
+ * port_oper_status - poiter to store the oper status
+ * data_type - indicates the data base type
+ * @return : UPPL_RC_SUCCESS - if oper status value is received from DB
+ * UPPL_RC_ERR_* - if there is failure in receiving oper status
+ * value from DB
+ **/
+UpplReturnCode Kt_LogicalPort::GetPortOperStatus(
+ OdbcmConnectionHandler *db_conn,
+ key_port_t &obj_key_port,
+ uint8_t *port_oper_status,
+ uint32_t data_type) {
+ pfc_log_debug("Decide oper_status based on physical port oper_status");
+ Kt_Port port;
+ UpplReturnCode read_status = port.GetOperStatus(
+ db_conn, data_type, reinterpret_cast<void*>(&obj_key_port),
+ *port_oper_status);
+ pfc_log_debug("Oper Status return %d, value %d", read_status,
+ PhyUtil::uint8touint(*port_oper_status));
+ return read_status;
+}
+
+/**
+ * @Description : This function gets all the logical ports associated with
+ * given controller/domain/switch
+ * @param[in] : controller_name - string to store the controller_name
+ * domain_name - string to store the domain_name
+ * switch_id - string to store the switch_id
+ * phy_port_id - string to store the physical port id
+ * vectLogicalPortKey - vector of type key_logical_port_t
+ * data_type - indicates the data base type UNC_DT_*
+ * @return : None
+ **/
+void Kt_LogicalPort::GetAllLogicalPort(
+ OdbcmConnectionHandler *db_conn,
+ string controller_name,
+ string domain_name,
+ string switch_id,
+ string phy_port_id,
+ vector<key_logical_port_t> &vectLogicalPortKey,
+ uint32_t data_type) {
+ PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
+ string port_id;
+ while (true) {
+ DBTableSchema kt_ctr_domain_dbtableschema;
+ vector<string> vect_prim_keys;
+ vect_prim_keys.push_back(CTR_NAME_STR);
+
+ vector<TableAttrSchema> vect_table_attr_schema;
+ list< vector<TableAttrSchema> > row_list;
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
+ controller_name.length(), DATATYPE_UINT8_ARRAY_32,
+ vect_table_attr_schema);
+ if (!domain_name.empty()) {
+ vect_prim_keys.push_back(DOMAIN_NAME_STR);
+ }
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_NAME, domain_name,
+ domain_name.length(), DATATYPE_UINT8_ARRAY_32,
+ vect_table_attr_schema);
+ if (!switch_id.empty()) {
+ vect_prim_keys.push_back(LP_SWITCH_ID_STR);
+ }
+ PhyUtil::FillDbSchema(unc::uppl::LP_SWITCH_ID, switch_id,
+ switch_id.length(), DATATYPE_UINT8_ARRAY_256,
+ vect_table_attr_schema);
+
+ if (!phy_port_id.empty()) {
+ vect_prim_keys.push_back(LP_PHYSICAL_PORT_ID_STR);
+ }
+ PhyUtil::FillDbSchema(unc::uppl::LP_PHYSICAL_PORT_ID, phy_port_id,
+ phy_port_id.length(), DATATYPE_UINT8_ARRAY_32,
+ vect_table_attr_schema);
+ vect_prim_keys.push_back(LP_PORT_ID_STR);
+ PhyUtil::FillDbSchema(unc::uppl::LP_PORT_ID, port_id,
+ port_id.length(), DATATYPE_UINT8_ARRAY_320,
+ vect_table_attr_schema);
+ PhyUtil::reorder_col_attrs(vect_prim_keys, vect_table_attr_schema);
+ kt_ctr_domain_dbtableschema.set_table_name(unc::uppl::LOGICALPORT_TABLE);
+ kt_ctr_domain_dbtableschema.set_primary_keys(vect_prim_keys);
+ row_list.push_back(vect_table_attr_schema);
+ kt_ctr_domain_dbtableschema.set_row_list(row_list);
+ ODBCM_RC_STATUS db_status = physical_layer->get_odbc_manager()->
+ GetBulkRows((unc_keytype_datatype_t)data_type, UPPL_MAX_REP_CT,
+ kt_ctr_domain_dbtableschema,
+ (unc_keytype_operation_t)UNC_OP_READ_SIBLING_BEGIN,
+ db_conn);
+ if (db_status != ODBCM_RC_SUCCESS) {
+ // No other logical port available
+ pfc_log_debug("No other logical port available");
+ break;
+ }
+ list<vector<TableAttrSchema> > ::iterator iter_list;
+ for (iter_list = kt_ctr_domain_dbtableschema.row_list_.begin();
+ iter_list != kt_ctr_domain_dbtableschema.row_list_.end();
+ ++iter_list) {
+ vector<TableAttrSchema> attributes_vector = *iter_list;
+ vector<TableAttrSchema> :: iterator iter_vector;
+ key_logical_port_t logical_port;
+ memset(&logical_port, '\0', sizeof(key_logical_port_t));
+ for (iter_vector = attributes_vector.begin();
+ iter_vector != attributes_vector.end();
+ ++iter_vector) {
+ /* Get attribute name of a row */
+ TableAttrSchema tab_att_schema = (*iter_vector);
+ switch (tab_att_schema.table_attribute_name) {
+ case unc::uppl::CTR_NAME:
+ PhyUtil::GetValueFromDbSchemaStr(
+ tab_att_schema,
+ logical_port.domain_key.ctr_key.controller_name,
+ DATATYPE_UINT8_ARRAY_32);
+ controller_name = reinterpret_cast<const char*>
+ (logical_port.domain_key.ctr_key.controller_name);
+ break;
+ case unc::uppl::DOMAIN_NAME:
+ PhyUtil::GetValueFromDbSchemaStr(
+ tab_att_schema,
+ logical_port.domain_key.domain_name,
+ DATATYPE_UINT8_ARRAY_32);
+ domain_name = reinterpret_cast<const char*>
+ (logical_port.domain_key.domain_name);
+ break;
+ case unc::uppl::LP_PORT_ID:
+ PhyUtil::GetValueFromDbSchemaStr(tab_att_schema,
+ logical_port.port_id,
+ DATATYPE_UINT8_ARRAY_320);
+ port_id = reinterpret_cast<const char*> (logical_port.port_id);
+ break;
+ default:
+ break;
+ }
+ }
+ vectLogicalPortKey.push_back(logical_port);
+ }
+ if (kt_ctr_domain_dbtableschema.row_list_.size() < UPPL_MAX_REP_CT) {
+ // No other logical port available
+ pfc_log_debug("No other logical port available");
+ break;
+ }
+ }
+}
+
+/**
+ * @Description : This function validates the logical port type
+ * @param[in] : port_type - Logical Port's type
+ * @return : Success if port type is within allowed values or
+ * else return failure
+ **/
+UpplReturnCode Kt_LogicalPort::ValidatePortType(uint8_t port_type) {
+ if (port_type == UPPL_LP_SWITCH ||
+ port_type == UPPL_LP_PHYSICAL_PORT ||
+ port_type == UPPL_LP_TRUNK_PORT ||
+ port_type == UPPL_LP_SUBDOMAIN ||
+ port_type == UPPL_LP_TUNNEL_ENDPOINT) {
+ return UPPL_RC_SUCCESS;
+ }
+ pfc_log_info("Invalid Logical Port Type provided %d", port_type);
+ return UPPL_RC_ERR_CFG_SYNTAX;
+}
#include "itc_kt_logicalport.hh"
#include "itc_kt_link.hh"
#include "odbcm_utils.hh"
+#include "itc_read_request.hh"
+#include "odbcm_db_varbind.hh"
using unc::uppl::PhysicalLayer;
-/** Constructor
- * * @Description : This function initializes member variables
- * and fills the attribute syntax map used for validation
- * * * @param[in] : None
- * * * @return : None
- * */
+/**
+ * @Description : This function initializes member variables
+ * and fills the attribute syntax map used for validation
+ * @param[in] : None
+ * @return : None
+ **/
Kt_Port::Kt_Port() {
- parent = NULL;
// Populate structure to be used for syntax validation
- Fill_Attr_Syntax_Map();
+ if (attr_syntax_map_all.find(UNC_KT_PORT) == attr_syntax_map_all.end()) {
+ Fill_Attr_Syntax_Map();
+ }
}
-/** Destructor
- * * @Description : This function frees the parent and child key types
- * instances for Kt_Port
- * * * @param[in] : None
- * * * @return : None
- * */
+/**
+ * @Description : This function does nothing
+ * @param[in] : None
+ * @return : None
+ **/
Kt_Port::~Kt_Port() {
- // Delete parent object
- if (parent != NULL) {
- delete parent;
- parent = NULL;
- }
}
-/** DeleteKeyInstance
- * * @Description : This function deletes the given instance of KT_Port
- * * @param[in] : key_struct - key for the port instance
- * data_type - UNC_DT_* , delete only allowed in STATE
- * * @return : UPPL_RC_SUCCESS is returned when the delete
- * is done successfully.
- * * UPPL_RC_ERR_* is returned when the delete is error
+/**
+ * @Description : This function deletes the given instance of KT_Port from
+ * running port table
+ * @param[in] : key_struct - void pointer to be type cast into port key type
+ * data_type - indicates the data base type,UNC_DT_* delete only
+ * allowed in STATE
+ * key_type - indicates the Key Type Class
+ * @return : UPPL_RC_SUCCESS is returned when the delete of a port in
+ * running db is successful
+ * UPPL_RC_ERR_* is returned when the delete is failure
* */
-UpplReturnCode Kt_Port::DeleteKeyInstance(void* key_struct,
+UpplReturnCode Kt_Port::DeleteKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
uint32_t key_type) {
UpplReturnCode delete_status = UPPL_RC_SUCCESS;
// Port delete corresponding logical port
Kt_LogicalPort logical_port_obj;
key_logical_port_t logical_port_key_obj;
+ memset(&logical_port_key_obj, '\0',
+ sizeof(logical_port_key_obj));
val_logical_port_t logical_port_val_obj;
memset(&logical_port_val_obj, 0, sizeof(logical_port_val_obj));
val_logical_port_st_t logical_port_st_val_obj;
controller_name.c_str(),
controller_name.length()+1);
- memset(logical_port_key_obj.domain_key.domain_name, '\0',
- sizeof(logical_port_key_obj.domain_key.domain_name));
-
- memset(logical_port_key_obj.port_id, 0,
- sizeof(logical_port_key_obj.port_id));
-
memset(logical_port_val_obj.valid, 0,
sizeof(logical_port_val_obj.valid));
key_val.push_back(reinterpret_cast<void *>(&logical_port_key_obj));
val_struct.push_back(reinterpret_cast<void *>(&logical_port_st_val_obj));
UpplReturnCode lp_read_status = logical_port_obj.ReadInternal(
- key_val, val_struct, UNC_DT_STATE, UNC_OP_READ);
+ db_conn, key_val, val_struct, data_type, UNC_OP_READ);
if (lp_read_status == UPPL_RC_SUCCESS) {
// form key struct with all required primary keys and call delete
logical_port_obj.DeleteKeyInstance(
- key_val[0],
- UNC_DT_STATE,
+ db_conn, key_val[0],
+ data_type,
UNC_KT_LOGICAL_PORT);
// Clear key and value struct
key_logical_port_t *key_log_port = reinterpret_cast<key_logical_port_t*>
// Construct Primary key list
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
- vect_prim_keys.push_back(SWITCH_ID);
+ vect_prim_keys.push_back(CTR_NAME_STR);
+ vect_prim_keys.push_back(SWITCH_ID_STR);
// Construct TableAttrSchema structure
// TableAttrSchema holds table_name, primary key, attr_name
list< vector<TableAttrSchema> > row_list;
// controller_name
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// switch_id
- PhyUtil::FillDbSchema(SWITCH_ID, switch_id,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_ID, switch_id,
switch_id.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
// port_id
if (port_id.length() > 0) {
- vect_prim_keys.push_back(PORT_ID);
- PhyUtil::FillDbSchema(PORT_ID, port_id,
+ vect_prim_keys.push_back(PORT_ID_STR);
+ PhyUtil::FillDbSchema(unc::uppl::PORT_ID, port_id,
port_id.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
}
// Send request to ODBC for port_table delete
- kt_port_dbtableschema.set_table_name(UPPL_PORT_TABLE);
+ kt_port_dbtableschema.set_table_name(unc::uppl::PORT_TABLE);
kt_port_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_port_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS delete_db_status = physical_layer->get_odbc_manager()-> \
DeleteOneRow((unc_keytype_datatype_t)data_type,
- kt_port_dbtableschema);
- pfc_log_info("DeleteOneRow response from DB is %d", delete_db_status);
+ kt_port_dbtableschema, db_conn);
if (delete_db_status != ODBCM_RC_SUCCESS) {
if (delete_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log fatal error to log daemon
return delete_status;
}
-/** ReadInternal
- * * @Description : This function reads the given instance of KT_Port
- ** * @param[in] : session_id - ipc session id used for TC validation
- * key_struct - the key for the kt port instance
- * value_struct - the value for the kt port instance
- * data_type - UNC_DT_* , read allowed in state
- * * @return : UPPL_RC_SUCCESS is returned when the response
- * is added to ipc session successfully.
- * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
- * */
-UpplReturnCode Kt_Port::ReadInternal(vector<void *> &key_val,
+/**
+ * @Description : This function reads the given instance of KT_Port
+ * @param[in] : key_val - vector to hold the primary key values
+ * val_struct - vector to hold the value structure
+ * data_type - indicates the data base type, UNC_DT_* ,
+ * read allowed in DT_STATE
+ * operation_type - indicates the operation type for
+ * read operation
+ * @return : UPPL_RC_SUCCESS is returned when read operation is success on
+ * DT_STATE db
+ * UPPL_RC_ERR_* is returned when read operation is failure
+ **/
+UpplReturnCode Kt_Port::ReadInternal(OdbcmConnectionHandler *db_conn,
+ vector<void *> &key_val,
vector<void *> &val_struct,
uint32_t data_type,
uint32_t operation_type) {
if (!val_struct.empty()) {
void_val_struct = val_struct[0];
}
- UpplReturnCode read_status = ReadPortValFromDB(key_struct,
+ UpplReturnCode read_status = ReadPortValFromDB(db_conn,
+ key_struct,
void_val_struct,
data_type,
operation_type,
vect_port_id);
key_val.clear();
val_struct.clear();
- if (read_status != UPPL_RC_SUCCESS) {
- pfc_log_error("ReadPortValFromDB returned %d with response size %d",
- read_status,
- static_cast<int>(vect_val_port_st.size()));
- } else {
+ pfc_log_info("ReadPortValFromDB returned %d with response size %d",
+ read_status,
+ static_cast<int>(vect_val_port_st.size()));
+ if (read_status == UPPL_RC_SUCCESS) {
pfc_log_debug("ReadPortValFromDB returned %d with response size %d",
read_status, static_cast<int>(vect_val_port_st.size()));
for (unsigned int iIndex = 0 ; iIndex < vect_val_port_st.size();
return read_status;
}
-/**ReadBulk
- * * @Description : This function reads bulk rows of KT_Port in
- * port table of specified data type.
- * Order of ReadBulk response
- * val_port -> val_link -> val_boundary
- * * @param[in] :
- * key_struct - the key for the kt port instance
- * data_type - UNC_DT_* , read allowed in state
- * option1/option2 - specifies any additional condition for read operation
- * max_rep_ct - specifies number of rows to be returned
- * parent_call - indicates whether parent has called this readbulk
- * is_read_next - indicates whether this function is invoked from readnext
- * * @return : UPPL_RC_SUCCESS is returned when the response
- * is added to ipc session successfully.
- * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
- * */
-UpplReturnCode Kt_Port::ReadBulk(void* key_struct,
+/**
+ * @Description : This function reads bulk rows of KT_Port in running port table
+ * of specified data type as well as its parent class.
+ * Order of ReadBulk response
+ * val_port -> val_link -> val_boundary
+ * @param[in] : key_struct - void pointer to be type cast into port key type
+ * data_type - UNC_DT_* , read allowed in state
+ * max_rep_ct - specifies number of rows to be returned
+ * parent_call - indicates whether parent has called this
+ * readbulk
+ * is_read_next - indicates whether this function is invoked
+ * from readnext
+ * @return : UPPL_RC_SUCCESS is returned when the read bulk operation is
+ * success.
+ * UPPL_RC_ERR_* is returned when read bulk operation is failure.
+ **/
+UpplReturnCode Kt_Port::ReadBulk(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
- uint32_t option1,
- uint32_t option2,
uint32_t &max_rep_ct,
int child_index,
pfc_bool_t parent_call,
- pfc_bool_t is_read_next) {
+ pfc_bool_t is_read_next,
+ ReadRequest *read_req) {
pfc_log_info("Processing ReadBulk of Kt_Port");
UpplReturnCode read_status = UPPL_RC_SUCCESS;
key_port_t *obj_key_port= reinterpret_cast<key_port_t*>(key_struct);
// Read the port values based on given key structure
read_status = ReadBulkInternal(
- key_struct,
+ db_conn, key_struct,
val_struct,
data_type,
max_rep_ct,
pfc_log_debug("Read status from port is %d with result size %d",
read_status, static_cast<int>(vect_port_id.size()));
if (read_status == UPPL_RC_SUCCESS) {
- PhysicalCore *physical_core = PhysicalLayer::get_instance()->
- get_physical_core();
- InternalTransactionCoordinator *itc_trans =
- physical_core->get_internal_transaction_coordinator();
- // For each switch , read the child's attributes
vector<val_port_st_t>::iterator vect_iter =
vect_val_port_st.begin();
vector<key_port_t> ::iterator port_iter =
UNC_KT_PORT, IS_KEY,
reinterpret_cast<void*>(key_buffer)
};
- itc_trans->AddToBuffer(obj_key_buffer);
+ read_req->AddToBuffer(obj_key_buffer);
val_port_st_t *val_buffer = new val_port_st_t(*vect_iter);
BulkReadBuffer obj_value_buffer = {
UNC_KT_PORT, IS_STATE_VALUE,
reinterpret_cast<void*>(val_buffer)
};
- itc_trans->AddToBuffer(obj_value_buffer);
+ read_req->AddToBuffer(obj_value_buffer);
BulkReadBuffer obj_sep_buffer = {
UNC_KT_PORT, IS_SEPARATOR, NULL
};
- itc_trans->AddToBuffer(obj_sep_buffer);
+ read_req->AddToBuffer(obj_sep_buffer);
--max_rep_ct;
if (max_rep_ct == 0) {
pfc_log_debug("max_rep_ct reached zero, so returning");
return read_status;
}
}
+ } else if (read_status == UPPL_RC_ERR_DB_ACCESS) {
+ pfc_log_debug("KtPort ReadBulk - Returning DB Access Error");
+ return read_status;
}
if (max_rep_ct > 0 && parent_call == false) {
pfc_log_debug("port is called directly, so go to parent");
Kt_Switch nextKin;
key_switch_t nextkin_key_struct;
- memset(nextkin_key_struct.switch_id, '\0',
- sizeof(nextkin_key_struct.switch_id));
- memset(nextkin_key_struct.ctr_key.controller_name,
- '\0', sizeof(nextkin_key_struct.ctr_key.controller_name));
+ memset(&nextkin_key_struct, '\0',
+ sizeof(nextkin_key_struct));
memcpy(nextkin_key_struct.switch_id,
str_switch_id.c_str(),
str_switch_id.length() +1);
str_controller_name.c_str(),
str_controller_name.length() +1);
read_status = nextKin.ReadBulk(
- reinterpret_cast<void *>(&nextkin_key_struct),
+ db_conn, reinterpret_cast<void *>(&nextkin_key_struct),
data_type,
- option1,
- option2,
max_rep_ct,
0,
false,
- is_read_next);
+ is_read_next,
+ read_req);
pfc_log_debug("read status from next kin Kt_Switch is %d", read_status);
return UPPL_RC_SUCCESS;
}
}
/**ReadBulkInternal
- * * @Description : This function reads bulk rows of KT_Port in
- * port table of specified data type.
- * * @param[in] :
- * key_struct - the key for the kt port instance
- * val_struct - the value struct for kt_port instance
- * max_rep_ct - specifies number of rows to be returned
- * vect_val_port - indicates the fetched values from db of val_port type
- * vect_port_id - indicates the fetched port names from db
- * * @return : UPPL_RC_SUCCESS is returned when the response
- * is added to ipc session successfully.
- * UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
- * */
+ * @Description : This function reads bulk rows of KT_Port in
+ * port table of specified data type.
+ * @param[in] : key_struct - void pointer to be type cast into port key type
+ * val_struct - void pointer to be type cast into port value
+ * structure type
+ * max_rep_ct - specifies number of rows to be returned
+ * vect_val_port - store the structure elements of type
+ * val_port_st_t from db
+ * vect_port_id - stores the port_id values from the key
+ * structure of kt port
+ * @return : UPPL_RC_SUCCESS is returned when the read bulk operation is
+ * successful.
+ * UPPL_RC_ERR_* is returned when the read bulk operation is
+ * failure
+ **/
UpplReturnCode Kt_Port::ReadBulkInternal(
+ OdbcmConnectionHandler *db_conn,
void* key_struct,
void* val_struct,
uint32_t data_type,
void *old_struct;
// Populate DBSchema for port_table
vector<ODBCMOperator> vect_key_operations;
- PopulateDBSchemaForKtTable(kt_port_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_port_dbtableschema,
key_struct,
val_struct,
- UNC_OP_READ_BULK, 0, 0,
+ UNC_OP_READ_BULK, data_type, 0, 0,
vect_key_operations, old_struct);
pfc_log_debug("Calling GetBulkRows");
// Read rows from DB
read_db_status = physical_layer->get_odbc_manager()-> \
GetBulkRows((unc_keytype_datatype_t)data_type, max_rep_ct,
kt_port_dbtableschema,
- (unc_keytype_operation_t)UNC_OP_READ_BULK);
+ (unc_keytype_operation_t)UNC_OP_READ_BULK, db_conn);
pfc_log_debug("GetBulkRows return: %d", read_db_status);
if (read_db_status == ODBCM_RC_RECORD_NOT_FOUND) {
pfc_log_debug("No record found");
read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
return read_status;
+ } else if (read_db_status == ODBCM_RC_CONNECTION_ERROR) {
+ read_status = UPPL_RC_ERR_DB_ACCESS;
+ pfc_log_error("Read operation has failed with error %d", read_db_status);
+ return read_status;
} else if (read_db_status != ODBCM_RC_SUCCESS) {
read_status = UPPL_RC_ERR_DB_GET;
// log error to log daemon
- pfc_log_error("Read operation has failed");
+ pfc_log_error("Read operation has failed with error %d", read_db_status);
return read_status;
}
// From the values received from DB, populate val_port structure
- FillPortValueStructure(kt_port_dbtableschema,
+ FillPortValueStructure(db_conn, kt_port_dbtableschema,
vect_val_port,
max_rep_ct,
UNC_OP_READ_BULK,
return read_status;
}
-/** PerformSyntaxValidation
- * * @Description : This function performs syntax validation for
- * UNC_KT_PORT
- * * * @param[in]
- * key_struct - the key for the kt port instance
- * value_struct - the value for the kt port instance
- * data_type - UNC_DT_*
- * operation_type - UNC_OP*
- * * @return : UPPL_RC_SUCCESS is returned when the validation is successful
- * UPPL_RC_ERR_* is returned when validtion is failure
- * */
-UpplReturnCode Kt_Port::PerformSyntaxValidation(void* key_struct,
+/**
+ * @Description : This function performs syntax validation for key type kt_port
+ * @param[in] : key_struct - void pointer to be type cast into port key type
+ * val_struct - void pointer to be type cast into va structure of
+ * key type port
+ * operation_type - UNC_OP* - indicates the operation type
+ * data_type - UNC_DT_* - indicates the data base type
+ * @return : UPPL_RC_SUCCESS is returned when the validation is successful
+ * UPPL_RC_ERR_* is returned when validation is failure
+ **/
+UpplReturnCode Kt_Port::PerformSyntaxValidation(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t operation,
uint32_t data_type) {
pfc_log_info("Performing Syntax Validation of KT_PORT");
UpplReturnCode ret_code = UPPL_RC_SUCCESS;
pfc_bool_t mandatory = PFC_TRUE;
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map =
+ attr_syntax_map_all[UNC_KT_PORT];
// Validate key structure
// validate controller_name
key_port *key = reinterpret_cast<key_port_t*>(key_struct);
string value = reinterpret_cast<char*>(key->sw_key.ctr_key.controller_name);
- IS_VALID_STRING_KEY(CTR_NAME, value, operation, ret_code, mandatory);
+ IS_VALID_STRING_KEY(CTR_NAME_STR, value, operation, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
// validate switch_id
value = reinterpret_cast<char*>(key->sw_key.switch_id);
- IS_VALID_STRING_KEY(SWITCH_ID, value, operation, ret_code, mandatory);
+ IS_VALID_STRING_KEY(SWITCH_ID_STR, value, operation, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
// validate port_id
value = reinterpret_cast<char*>(key->port_id);
- IS_VALID_STRING_KEY(PORT_ID, value, operation, ret_code, mandatory);
+ IS_VALID_STRING_KEY(PORT_ID_STR, value, operation, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
// validate port_number
valid_val = PhyUtil::uint8touint(value_port->valid[kIdxPortNumber]);
- IS_VALID_INT_VALUE(PORT_NUMBER, value_port->port_number, operation,
+ IS_VALID_INT_VALUE(PORT_NUMBER_STR, value_port->port_number, operation,
valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
// validate description
valid_val = PhyUtil::uint8touint(value_port->valid[kIdxPortDescription]);
string value = reinterpret_cast<char*>(value_port->description);
- IS_VALID_STRING_VALUE(PORT_DESCRIPTION, value, operation,
+ IS_VALID_STRING_VALUE(PORT_DESCRIPTION_STR, value, operation,
valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
// validate admin_status
valid_val = PhyUtil::uint8touint(value_port->valid[kIdxPortAdminStatus]);
- IS_VALID_INT_VALUE(PORT_ADMIN_STATUS, value_port->admin_status, operation,
- valid_val, ret_code, mandatory);
+ IS_VALID_INT_VALUE(PORT_ADMIN_STATUS_STR, value_port->admin_status,
+ operation, valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
// validate trunk_allowed_vlan
valid_val =
PhyUtil::uint8touint(value_port->valid[kIdxPortTrunkAllowedVlan]);
- IS_VALID_INT_VALUE(PORT_TRUNK_ALL_VLAN, value_port->trunk_allowed_vlan,
+ IS_VALID_INT_VALUE(PORT_TRUNK_ALL_VLAN_STR, value_port->trunk_allowed_vlan,
operation, valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
return ret_code;
}
-/** PerformSemanticValidation
- * * @Description : This function performs semantic validation
- * for UNC_KT_PORT
- * * * @param[in] : key_struct - specifies key instance of KT_Port
- * , value_struct - specifies value of KT_PORT
- * operation - UNC_OP*
- * data_type - UNC_DT*
- * * * @return : UPPL_RC_SUCCESS if semantic valition is successful
- * or UPPL_RC_ERR_* if failed
+/**
+ * @Description : This function performs semantic validation
+ * for UNC_KT_PORT
+ * @param[in] : key_struct - void pointer to be type cast into port key type
+ * val_struct - void pointer to be type cast into val structure
+ * of key type port
+ * operation_type - UNC_OP* - indicates the operation type
+ * data_type - UNC_DT_* - indicates the data base type
+ * @return : UPPL_RC_SUCCESS is returned when the semantic validation is
+ * successful
+ * UPPL_RC_ERR_* is returned when semantic validation is failure
* */
-UpplReturnCode Kt_Port::PerformSemanticValidation(void* key_struct,
- void* val_struct,
- uint32_t operation,
- uint32_t data_type) {
+UpplReturnCode Kt_Port::PerformSemanticValidation(
+ OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ void* val_struct,
+ uint32_t operation,
+ uint32_t data_type) {
UpplReturnCode status = UPPL_RC_SUCCESS;
pfc_log_debug("Inside PerformSemanticValidation of KT_PORT");
// Check whether the given instance of port exists in DB
pfc_log_debug("switch id: %s", switch_id.c_str());
key_switch_t obj_key_switch;
- memset(obj_key_switch.switch_id, '\0', 32);
+ memset(&obj_key_switch, '\0', sizeof(obj_key_switch));
memcpy(obj_key_switch.switch_id,
switch_id.c_str(),
switch_id.length()+1);
pfc_log_debug("controller name in validate: %s", obj_key_port->
sw_key.ctr_key.controller_name);
- memset(&obj_key_switch.ctr_key.controller_name, '\0', 32);
memcpy(&obj_key_switch.ctr_key.controller_name,
obj_key_port->sw_key.ctr_key.controller_name,
sizeof(obj_key_port->sw_key.ctr_key.controller_name));
vect_key_value.push_back(port_id);
UpplReturnCode key_status = IsKeyExists(
- (unc_keytype_datatype_t)data_type, vect_key_value);
+ db_conn, (unc_keytype_datatype_t)data_type, vect_key_value);
pfc_log_debug("IsKeyExists status %d", key_status);
// In case of create operation, key should not exist
if (operation == UNC_OP_CREATE) {
parent_vect_key_value.push_back(switch_id);
Kt_Switch KtObj;
UpplReturnCode parent_key_status = KtObj.IsKeyExists(
- (unc_keytype_datatype_t)data_type, parent_vect_key_value);
+ db_conn, (unc_keytype_datatype_t)data_type, parent_vect_key_value);
pfc_log_debug("Parent IsKeyExists status %d", parent_key_status);
if (parent_key_status != UPPL_RC_SUCCESS) {
status = UPPL_RC_ERR_PARENT_DOES_NOT_EXIST;
return status;
}
-/** HandleDriverAlarms
- * * @Description : This function processes the alarm notification
- * received from driver
- * * * @param[in] : alarm type - contains type to indicate which alarm
- * operation - contains UNC_OP_CREATE or UNC_OP_DELETE
- * key_struct - indicates the key instance of KT_PORT
- * value_struct - indicates the alarm values structure
- * * * @return : UPPL_RC_SUCCESS if alarm is handled successfully or
- * UPPL_RC_ERR*
- * */
-UpplReturnCode Kt_Port::HandleDriverAlarms(uint32_t data_type,
+/**
+ * @Description : This function processes the alarm notification
+ * sent by driver for port key type and sends the notification
+ * to northbound
+ * @param[in] : data_type - indicates the data base type i.e UNC_DT_STATE
+ * or UNC_DT_IMPORT
+ * alarm type - indicates the alarm type sent by the driver
+ * oper_type - indicates the operation type i.e. UNC_OP_CREATE
+ * key_struct - void pointer type to be type cast to port
+ * key type
+ * value_struct - void pointer to be type cast to port value
+ * structure type
+ * @return : the oper status result from db will be returned
+ * UPPL_RC_SUCCESS - in case oper status is received from DB
+ * UPPL_RC_ERR_* - in case unable to receive oper status from DB
+ **/
+
+UpplReturnCode Kt_Port::HandleDriverAlarms(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
uint32_t alarm_type,
uint32_t oper_type,
void* key_struct,
controller_name.c_str(),
controller_name.length()+1);
pfc_log_info("alarm sent by driver is: %d", alarm_type);
- pfc_log_info("operation type: %d", oper_type);
uint64_t alarm_status_db = 0;
- UpplReturnCode read_alarm_status = GetAlarmStatus(data_type,
+ UpplReturnCode read_alarm_status = GetAlarmStatus(db_conn, data_type,
key_struct,
alarm_status_db);
// Read old_alarm_status from db
obj_val_port_st.alarms_status = new_alarm_status;
void *old_val_struct;
// Calling UPDATE KEY INSTANCE for update in DB
- status = UpdateKeyInstance(obj_key_port,
+ status = UpdateKeyInstance(db_conn, obj_key_port,
reinterpret_cast<void *>(&obj_val_port_st),
data_type,
UNC_KT_PORT,
int err = 0;
// Send notification to Northbound
ServerEvent ser_evt((pfc_ipcevtype_t)UPPL_EVENTS_KT_PORT, err);
- ser_evt.addOutput((uint32_t)UNC_OP_UPDATE);
- ser_evt.addOutput(data_type);
- ser_evt.addOutput((uint32_t)UPPL_EVENTS_KT_PORT);
- ser_evt.addOutput(*obj_key_port);
- ser_evt.addOutput(new_val_port);
- ser_evt.addOutput(old_val_port);
- PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
- // Notify operstatus modifications
- status = (UpplReturnCode) physical_layer
- ->get_ipc_connection_manager()->SendEvent(&ser_evt);
+ northbound_event_header rsh = {UNC_OP_UPDATE,
+ data_type,
+ UNC_KT_PORT};
+ err = PhyUtil::sessOutNBEventHeader(ser_evt, rsh);
+ err |= ser_evt.addOutput(*obj_key_port);
+ err |= ser_evt.addOutput(new_val_port);
+ err |= ser_evt.addOutput(old_val_port);
+ if (err == 0) {
+ PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
+ // Notify operstatus modifications
+ status = (UpplReturnCode) physical_layer
+ ->get_ipc_connection_manager()->SendEvent(&ser_evt);
+ } else {
+ pfc_log_error("Server Event addOutput failed");
+ status = UPPL_RC_ERR_IPC_WRITE_ERROR;
+ }
} else {
- pfc_log_info("Update alarm status in db status %d", status);
+ pfc_log_debug("Update alarm status in db status %d", status);
}
val_port_st_t *val_port =
reinterpret_cast<val_port_st_t*>(old_val_struct);
return status;
}
-/** IsKeyExists
- * * @Description : This function checks whether the port_id exists in DB
- * * * @param[in] : data type and key value
- * * * @return : Success or associated error code
- * */
-UpplReturnCode Kt_Port::IsKeyExists(unc_keytype_datatype_t data_type,
- vector<string> key_values) {
+/**
+ * @Description : This function checks whether the port_id exists in specified
+ * data base
+ * @param[in] : data type - indicates the database type
+ * key values - vector to store the primary key values of port
+ * key type
+ * @return : UPPL_RC_SUCCESS - if the row exists in db with the key value
+ * specified
+ * UPPL_RC_ERR_* - if the row doesn't exists in the specified DB
+ **/
+UpplReturnCode Kt_Port::IsKeyExists(OdbcmConnectionHandler *db_conn,
+ unc_keytype_datatype_t data_type,
+ const vector<string> &key_values) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode check_status = UPPL_RC_SUCCESS;
if (key_values.empty()) {
// Construct Primary key list
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
- vect_prim_keys.push_back(SWITCH_ID);
- vect_prim_keys.push_back(PORT_ID);
+ vect_prim_keys.push_back(CTR_NAME_STR);
+ vect_prim_keys.push_back(SWITCH_ID_STR);
+ vect_prim_keys.push_back(PORT_ID_STR);
// Construct TableAttrSchema structure
// TableAttrSchema holds table_name, primary key, attr_name
list< vector<TableAttrSchema> > row_list;
// controller_name
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(),
DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// switch_id
- PhyUtil::FillDbSchema(SWITCH_ID, switch_id,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_ID, switch_id,
switch_id.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
// port_id
- PhyUtil::FillDbSchema(PORT_ID, port_id,
+ PhyUtil::FillDbSchema(unc::uppl::PORT_ID, port_id,
port_id.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- kt_port_dbtableschema.set_table_name(UPPL_PORT_TABLE);
+ kt_port_dbtableschema.set_table_name(unc::uppl::PORT_TABLE);
kt_port_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_port_dbtableschema.set_row_list(row_list);
// Send request to ODBC for port_table
ODBCM_RC_STATUS check_db_status = physical_layer->get_odbc_manager()->\
- IsRowExists(data_type, kt_port_dbtableschema);
+ IsRowExists(data_type, kt_port_dbtableschema, db_conn);
if (check_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log error to log daemon
pfc_log_error("DB connection not available or cannot access DB");
return check_status;
}
-/** HandleOperStatus
- * * @Description : This function performs the required actions when oper status
- * changes
- * * * @param[in] : Key and value struct
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
- * */
-UpplReturnCode Kt_Port::HandleOperStatus(uint32_t data_type,
+/**
+ * @Description : This function performs the required actions when oper status
+ * of its parent class
+ * changes i.e. when controller/switch oper status is down
+ * @param[in] : data_type - indicates the data base type
+ * key_struct - void pointer to be type cast to port key type
+ * value_struct - void pointer to be type cast to port value
+ * structure type
+ * @return : UPPL_RC_SUCCESS - if the update operation of oper status
+ * change in db is successful
+ * UPPL_RC_ERR* - if the update operation of oper status in db
+ * is failure
+ **/
+UpplReturnCode Kt_Port::HandleOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void *key_struct,
void *value_struct) {
FN_START_TIME("HandleOperStatus", "Port");
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode return_code = UPPL_RC_SUCCESS;
-
if (key_struct == NULL) {
FN_END_TIME("HandleOperStatus", "Port");
return UPPL_RC_ERR_BAD_REQUEST;
UpplPortOperStatus port_oper_status = UPPL_PORT_OPER_UNKNOWN;
Kt_Controller controller;
UpplReturnCode read_status = controller.GetOperStatus(
- data_type, reinterpret_cast<void*>(&ctr_key), ctrl_oper_status);
- if (read_status == UPPL_RC_SUCCESS) {
- pfc_log_debug("Controller's oper_status %d", ctrl_oper_status);
- if (ctrl_oper_status ==
- (UpplControllerOperStatus) UPPL_CONTROLLER_OPER_UP) {
- pfc_log_info("Set Port oper status as up");
- port_oper_status = UPPL_PORT_OPER_UP;
- }
- } else {
+ db_conn, data_type, reinterpret_cast<void*>(&ctr_key), ctrl_oper_status);
+ if (read_status != UPPL_RC_SUCCESS) {
pfc_log_info("Controller's oper_status read returned failure");
+ return read_status;
+ }
+ pfc_log_debug("Controller's oper_status %d", ctrl_oper_status);
+ vector<OperStatusHolder> ref_oper_status;
+ ADD_CTRL_OPER_STATUS(controller_name, ctrl_oper_status);
+ if (ctrl_oper_status ==
+ (UpplControllerOperStatus) UPPL_CONTROLLER_OPER_UP) {
+ pfc_log_info("Set Port oper status as up");
+ port_oper_status = UPPL_PORT_OPER_UP;
}
// Get the switch oper status and decide on the oper_status
key_switch_t sw_key;
uint8_t switch_oper_status = 0;
Kt_Switch switch1;
read_status = switch1.GetOperStatus(
- data_type, reinterpret_cast<void*>(&sw_key), switch_oper_status);
+ db_conn, data_type, reinterpret_cast<void*>(&sw_key), switch_oper_status);
if (read_status == UPPL_RC_SUCCESS) {
pfc_log_debug("Switch's oper_status %d", switch_oper_status);
+ ADD_SWITCH_OPER_STATUS(sw_key, switch_oper_status);
if (switch_oper_status ==
(UpplSwitchOperStatus) UPPL_SWITCH_OPER_UP) {
pfc_log_info("Set Port oper status as up");
pfc_log_debug("Switch oper_status read returned failure");
}
// Update oper_status in port table
- return_code = SetOperStatus(data_type,
+ return_code = SetOperStatus(db_conn, data_type,
key_struct,
- port_oper_status, true);
+ port_oper_status);
pfc_log_debug("Set Port oper status status %d", return_code);
// Call referred classes' notify oper_status functions
vector<TableAttrSchema> vect_table_attr_schema;
list< vector<TableAttrSchema> > row_list;
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
- vect_prim_keys.push_back(SWITCH_ID);
+ vect_prim_keys.push_back(CTR_NAME_STR);
+ vect_prim_keys.push_back(SWITCH_ID_STR);
if (!switch_id.empty()) {
// one more primary key is required
- vect_prim_keys.push_back(PORT_ID);
+ vect_prim_keys.push_back(PORT_ID_STR);
}
pfc_log_debug(
"Get Bulk Rows called with controller_name %s, switch_id %s"
"port_id %s", controller_name.c_str(), switch_id.c_str(),
port_id.c_str());
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- PhyUtil::FillDbSchema(SWITCH_ID, switch_id,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_ID, switch_id,
switch_id.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
- PhyUtil::FillDbSchema(PORT_ID, port_id,
+ PhyUtil::FillDbSchema(unc::uppl::PORT_ID, port_id,
port_id.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- kt_port_dbtableschema.set_table_name(UPPL_PORT_TABLE);
+ kt_port_dbtableschema.set_table_name(unc::uppl::PORT_TABLE);
kt_port_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_port_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS db_status = physical_layer->get_odbc_manager()->
- GetBulkRows((unc_keytype_datatype_t)UNC_DT_STATE, UPPL_MAX_REP_CT,
+ GetBulkRows((unc_keytype_datatype_t)data_type, UPPL_MAX_REP_CT,
kt_port_dbtableschema,
- (unc_keytype_operation_t)UNC_OP_READ_SIBLING_BEGIN);
+ (unc_keytype_operation_t)UNC_OP_READ_SIBLING_BEGIN,
+ db_conn);
if (db_status != ODBCM_RC_SUCCESS) {
- pfc_log_info("ReadBulk failure");
+ pfc_log_info("No other port available");
break;
}
list<vector<TableAttrSchema> > ::iterator iter_list;
vector<TableAttrSchema> attributes_vector = *iter_list;
vector<TableAttrSchema> :: iterator iter_vector;
key_port_t port;
- memset(port.sw_key.ctr_key.controller_name, '\0', 32);
- memset(port.sw_key.switch_id, '\0', 256);
- memset(port.port_id, '\0', 32);
+ memset(&port, '\0', sizeof(port));
for (iter_vector = attributes_vector.begin();
iter_vector != attributes_vector.end();
++iter_vector) {
// Get attribute name of a row
TableAttrSchema tab_att_schema = (*iter_vector);
- if (tab_att_schema.table_attribute_name == CTR_NAME) {
- PhyUtil::GetValueFromDbSchema(tab_att_schema,
- controller_name,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(port.sw_key.ctr_key.controller_name,
- controller_name.c_str(),
- controller_name.length()+1);
- } else if (tab_att_schema.table_attribute_name == SWITCH_ID) {
- PhyUtil::GetValueFromDbSchema(tab_att_schema, switch_id,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(port.sw_key.switch_id,
- switch_id.c_str(),
- switch_id.length()+1);
- } else if (tab_att_schema.table_attribute_name == PORT_ID) {
- PhyUtil::GetValueFromDbSchema(tab_att_schema, port_id,
- DATATYPE_UINT8_ARRAY_320);
- memcpy(port.port_id, port_id.c_str(),
- port_id.length()+1);
+ switch (tab_att_schema.table_attribute_name) {
+ case unc::uppl::CTR_NAME:
+ PhyUtil::GetValueFromDbSchemaStr(
+ tab_att_schema,
+ port.sw_key.ctr_key.controller_name,
+ DATATYPE_UINT8_ARRAY_32);
+ controller_name = reinterpret_cast<const char*>
+ (port.sw_key.ctr_key.controller_name);
+ break;
+ case unc::uppl::SWITCH_ID:
+ PhyUtil::GetValueFromDbSchemaStr(tab_att_schema,
+ port.sw_key.switch_id,
+ DATATYPE_UINT8_ARRAY_256);
+ switch_id = reinterpret_cast<const char*>
+ (port.sw_key.switch_id);
+ break;
+ case unc::uppl::PORT_ID:
+ PhyUtil::GetValueFromDbSchemaStr(tab_att_schema, port.port_id,
+ DATATYPE_UINT8_ARRAY_320);
+ port_id = reinterpret_cast<const char*>(port.port_id);
+ break;
+ default:
+ break;
}
}
vectPortKey.push_back(port);
}
+ if (kt_port_dbtableschema.row_list_.size() < UPPL_MAX_REP_CT) {
+ pfc_log_info("No other port available");
+ break;
+ }
}
vector<key_port_t>::iterator keyItr =
vectPortKey.begin();
for (; keyItr != vectPortKey.end(); ++keyItr) {
- // key_port_t objKeyPort;
+ key_port_t key_port = (*keyItr);
+ ADD_PORT_OPER_STATUS(
+ key_port,
+ port_oper_status);
return_code = NotifyOperStatus(
- data_type, reinterpret_cast<void *> (&(*keyItr)), NULL);
+ db_conn, data_type, reinterpret_cast<void *> (&(*keyItr)), NULL,
+ ref_oper_status);
pfc_log_debug("Notify Oper status return %d", return_code);
}
FN_END_TIME("HandleOperStatus", "Port");
+ ClearOperStatusHolder(ref_oper_status);
return return_code;
}
-/** NotifyOperStatus
- * * @Description : This function performs the notifies other associated
- * key types when oper status changes
- * * * @param[in] : Key and value struct
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
- * */
-UpplReturnCode Kt_Port::NotifyOperStatus(uint32_t data_type,
- void *key_struct,
- void *value_struct) {
+/**
+ * @Description : This function performs the notifies other associated
+ * key types when port oper status changes
+ * @param[in] : data_type - indicates the data base type
+ * key_struct - void pointer to be type cast into respective
+ * key type's key structure
+ * value_struct - void pointer to be type cast into respective
+ * key type's value structure
+ * @return : UPPL_RC_SUCCESS - if the updation of oper status change in
+ * other key type is success
+ * UPPL_RC_ERR* - if the updation of oper status change in db
+ * is failure
+ **/
+UpplReturnCode Kt_Port::NotifyOperStatus(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ void *key_struct,
+ void *value_struct,
+ vector<OperStatusHolder> &ref_oper_status) {
UpplReturnCode return_code = UPPL_RC_SUCCESS;
key_port_t *obj_key_port =
reinterpret_cast<key_port_t*>(key_struct);
memcpy(logical_port_key.domain_key.ctr_key.controller_name,
controller_name.c_str(),
controller_name.length()+1);
- memset(logical_port_key.domain_key.domain_name, '\0', 32);
- memset(logical_port_key.port_id, '\0', 320);
- Kt_LogicalPort port_obj;
+ Kt_LogicalPort log_port_obj;
val_logical_port_st_t port_val_obj;
memset(&port_val_obj, 0, sizeof(val_logical_port_st_t));
memset(port_val_obj.logical_port.valid, 0, 5);
port_val_obj.logical_port.valid[kIdxLogicalPortSwitchId] = UNC_VF_VALID;
memcpy(port_val_obj.logical_port.physical_port_id, port_id.c_str(),
(port_id.length())+1);
- port_val_obj.logical_port.valid[kIdxLogicalPortPhysicalPortId] = UNC_VF_VALID;
- return_code = port_obj.HandleOperStatus(
- data_type, reinterpret_cast<void *> (&logical_port_key),
- reinterpret_cast<void *> (&port_val_obj));
- pfc_log_info("HandleOperStatus for port class %d",
- return_code);
+ port_val_obj.logical_port.valid[kIdxLogicalPortPhysicalPortId] =
+ UNC_VF_VALID;
+ return_code = log_port_obj.HandleOperStatus(
+ db_conn, data_type, reinterpret_cast<void *> (&logical_port_key),
+ reinterpret_cast<void *> (&port_val_obj), ref_oper_status,
+ UNC_KT_PORT);
+ pfc_log_debug("HandleOperStatus for port class %d",
+ return_code);
+
+ // Perform SubDomain operstatus handling as well
+ return_code = SubDomainOperStatusHandling(db_conn, data_type,
+ controller_name,
+ switch_id, port_id);
// Notify UNC_KT_LINK
Kt_Link link;
key_link link_key;
+ memset(&link_key, 0, sizeof(link_key));
memcpy(link_key.ctr_key.controller_name,
controller_name.c_str(),
controller_name.length()+1);
memcpy(link_key.port_id1,
port_id.c_str(),
port_id.length()+1);
- memset(link_key.port_id2, 0, 32);
memcpy(link_key.switch_id1,
switch_id.c_str(),
switch_id.length()+1);
- memset(link_key.switch_id2, 0, 256);
return_code = link.HandleOperStatus(
- data_type, reinterpret_cast<void *> (&link_key),
+ db_conn, data_type, reinterpret_cast<void *> (&link_key),
NULL);
- pfc_log_info("HandleOperStatus for link class %d",
- return_code);
+ pfc_log_debug("HandleOperStatus for link class %d",
+ return_code);
key_link link_key1;
+ memset(&link_key1, 0, sizeof(link_key1));
memcpy(link_key1.ctr_key.controller_name,
controller_name.c_str(),
controller_name.length()+1);
memcpy(link_key1.port_id2,
port_id.c_str(),
port_id.length()+1);
- memset(link_key1.port_id1, 0, 32);
memcpy(link_key1.switch_id2,
switch_id.c_str(),
switch_id.length()+1);
- memset(link_key1.switch_id1, 0, 256);
return_code = link.HandleOperStatus(
- data_type, reinterpret_cast<void *> (&link_key1),
+ db_conn, data_type, reinterpret_cast<void *> (&link_key1),
NULL);
- pfc_log_info("HandleOperStatus for link class %d",
- return_code);
+ pfc_log_debug("HandleOperStatus for link class %d",
+ return_code);
return return_code;
}
-/** GetOperStatus
- * * @Description : This function reads the oper_status value of the port
- * * @param[in] : key_struct
- * * @return : oper_status
- */
-UpplReturnCode Kt_Port::GetOperStatus(uint32_t data_type,
+/**
+ * @Description : This function reads the oper_status value of the port from
+ * the specified data type
+ * @param[in] : data_type - indicates the data base type i.e. DT_STATE
+ * key_struct - void pointer to be type cast to port key type
+ * structure
+ * @return : oper_status - it stores the oper status returned from DB
+ **/
+UpplReturnCode Kt_Port::GetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
uint8_t &oper_status) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
key_port *obj_key_port =
reinterpret_cast<key_port_t*>(key_struct);
- TableAttrSchema kt_port_table_attr_schema;
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
vector<string> vect_prim_keys;
ctr_key.controller_name;
if (!controller_name.empty()) {
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
}
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
string switch_id = (const char*)obj_key_port->
sw_key.switch_id;
- pfc_log_info("switch_id: %s", switch_id.c_str());
if (!switch_id.empty()) {
- vect_prim_keys.push_back(SWITCH_ID);
+ vect_prim_keys.push_back(SWITCH_ID_STR);
}
- PhyUtil::FillDbSchema(SWITCH_ID, switch_id,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_ID, switch_id,
switch_id.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
string port_id = (const char*)obj_key_port->port_id;
if (!port_id.empty()) {
- vect_prim_keys.push_back(PORT_ID);
+ vect_prim_keys.push_back(PORT_ID_STR);
}
- PhyUtil::FillDbSchema(PORT_ID, port_id,
+ PhyUtil::FillDbSchema(unc::uppl::PORT_ID, port_id,
port_id.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- string oper_value;
- PhyUtil::FillDbSchema(PORT_OPER_STATUS, oper_value,
+ string oper_value = "";
+ PhyUtil::FillDbSchema(unc::uppl::PORT_OPER_STATUS, oper_value,
oper_value.length(), DATATYPE_UINT16,
vect_table_attr_schema);
DBTableSchema kt_port_dbtableschema;
- kt_port_dbtableschema.set_table_name(UPPL_PORT_TABLE);
+ kt_port_dbtableschema.set_table_name(unc::uppl::PORT_TABLE);
kt_port_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_port_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS update_db_status =
physical_layer->get_odbc_manager()->GetOneRow(
(unc_keytype_datatype_t)data_type,
- kt_port_dbtableschema);
+ kt_port_dbtableschema, db_conn);
if (update_db_status != ODBCM_RC_SUCCESS) {
- // log error
- pfc_log_error("oper_status read operation failed");
+ pfc_log_info("oper_status read operation failed %d", update_db_status);
return UPPL_RC_ERR_DB_GET;
}
// read the oper_status value
- list < vector<TableAttrSchema> > res_port_row_list =
+ list < vector<TableAttrSchema> >& res_port_row_list =
kt_port_dbtableschema.get_row_list();
list < vector<TableAttrSchema> >::iterator res_port_iter =
res_port_row_list.begin();
++vect_port_iter) {
// populate values from port_table
TableAttrSchema tab_schema = (*vect_port_iter);
- string attr_name = tab_schema.table_attribute_name;
- string attr_value;
- if (attr_name == PORT_OPER_STATUS) {
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
+ string attr_value = "";
+ if (attr_name == unc::uppl::PORT_OPER_STATUS) {
PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
DATATYPE_UINT16);
oper_status = atoi(attr_value.c_str());
return UPPL_RC_SUCCESS;
}
-/** GetAlarmStatus
- * * @Description: This function updates the alarm status in db
- * * @param[in]: key_struct - key structure of kt Port
- * alarm status - specifies the alarm status
- * * @return: UPPL_RC_SUCCESS or UPPL_RC_ERR*
- * */
-
-UpplReturnCode Kt_Port::GetAlarmStatus(uint32_t data_type,
+/**
+ * @Description : This function updates the alarm status in db
+ * @param[in] : data_type - indicates the data base type
+ * key_struct - void pointer type to be type cast to port key
+ * type structure
+ * alarm status - stores the alarm status received from DB
+ * @return : UPPL_RC_SUCCESS - if the alarm status is received
+ * successfully from db
+ * UPPL_RC_ERR* - if there is failure in reading the value
+ * from DB
+ **/
+
+UpplReturnCode Kt_Port::GetAlarmStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
uint64_t &alarms_status) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
key_port *obj_key_port =
reinterpret_cast<key_port_t*>(key_struct);
- TableAttrSchema kt_port_table_attr_schema;
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
- vect_prim_keys.push_back(SWITCH_ID);
- vect_prim_keys.push_back(PORT_ID);
+ vect_prim_keys.push_back(CTR_NAME_STR);
+ vect_prim_keys.push_back(SWITCH_ID_STR);
+ vect_prim_keys.push_back(PORT_ID_STR);
string controller_name =
(const char*)obj_key_port->sw_key.ctr_key.controller_name;
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
string switch_id = (const char*)obj_key_port->sw_key.switch_id;
- PhyUtil::FillDbSchema(SWITCH_ID, switch_id,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_ID, switch_id,
switch_id.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
string port_id = (const char*)obj_key_port->port_id;
- PhyUtil::FillDbSchema(PORT_ID, port_id,
+ PhyUtil::FillDbSchema(unc::uppl::PORT_ID, port_id,
port_id.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- string empty_alarms_status;
- PhyUtil::FillDbSchema(PORT_ALARM_STATUS, empty_alarms_status,
+ string empty_alarms_status = "";
+ PhyUtil::FillDbSchema(unc::uppl::PORT_ALARM_STATUS, empty_alarms_status,
empty_alarms_status.length(), DATATYPE_UINT64,
vect_table_attr_schema);
DBTableSchema kt_port_dbtableschema;
- kt_port_dbtableschema.set_table_name(UPPL_PORT_TABLE);
+ kt_port_dbtableschema.set_table_name(unc::uppl::PORT_TABLE);
kt_port_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_port_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS update_db_status =
physical_layer->get_odbc_manager()->GetOneRow(
(unc_keytype_datatype_t)data_type,
- kt_port_dbtableschema);
+ kt_port_dbtableschema, db_conn);
if (update_db_status != ODBCM_RC_SUCCESS) {
- // log error
- pfc_log_error("oper_status read operation failed");
+ pfc_log_info("oper_status read operation failed %d", update_db_status);
return UPPL_RC_ERR_DB_GET;
}
// read the oper status value
- list < vector<TableAttrSchema> > res_port_row_list =
+ list < vector<TableAttrSchema> >& res_port_row_list =
kt_port_dbtableschema.get_row_list();
list < vector<TableAttrSchema> >::iterator res_port_iter =
res_port_row_list.begin();
- // populate IPC value structure based on the response recevied from DB
+ // populate IPC value structure based on the response received from DB
for (; res_port_iter!= res_port_row_list.end(); ++res_port_iter) {
vector<TableAttrSchema> res_port_table_attr_schema = (*res_port_iter);
vector<TableAttrSchema>:: iterator vect_port_iter =
++vect_port_iter) {
// populate values from port_table
TableAttrSchema tab_schema = (*vect_port_iter);
- string attr_name = tab_schema.table_attribute_name;
- string attr_value;
- if (attr_name == "alarms_status") {
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
+ string attr_value = "";
+ if (attr_name == unc::uppl::PORT_ALARM_STATUS) {
PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
DATATYPE_UINT64);
alarms_status = atol(attr_value.c_str());
return UPPL_RC_SUCCESS;
}
-/** SetOperStatus
- * * @Description : This function updates the oper_status value
- * of the controller
- * * @param[in] : key_struct
- * * @return : oper_status
- */
-UpplReturnCode Kt_Port::SetOperStatus(uint32_t data_type,
+/**
+ * @Description : This function updates the oper_status value of the port in DB
+ * @param[in] : data_type - indicates the data base type
+ * key_struct - void pointer to be type cast into port key
+ * type structure
+ * oper_status - stores the oper status value to be updated in db
+ * @return : oper_status
+ **/
+UpplReturnCode Kt_Port::SetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
- UpplPortOperStatus oper_status,
- bool is_single_key) {
+ UpplPortOperStatus oper_status) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
key_port_t *obj_key_port=
reinterpret_cast<key_port_t*>(key_struct);
- TableAttrSchema kt_port_table_attr_schema;
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
vector<string> vect_prim_keys;
string port_id = (const char*)obj_key_port->port_id;
if (!controller_name.empty()) {
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
}
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- if (is_single_key == false) {
- if (!switch_id.empty()) {
- vect_prim_keys.push_back(SWITCH_ID);
- PhyUtil::FillDbSchema(SWITCH_ID, switch_id,
- switch_id.length(), DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
- }
+ if (!switch_id.empty()) {
+ vect_prim_keys.push_back(SWITCH_ID_STR);
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_ID, switch_id,
+ switch_id.length(), DATATYPE_UINT8_ARRAY_256,
+ vect_table_attr_schema);
+ }
- if (!port_id.empty()) {
- vect_prim_keys.push_back(PORT_ID);
- PhyUtil::FillDbSchema(PORT_ID, port_id,
- port_id.length(), DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
- }
+ if (!port_id.empty()) {
+ vect_prim_keys.push_back(PORT_ID_STR);
+ PhyUtil::FillDbSchema(unc::uppl::PORT_ID, port_id,
+ port_id.length(), DATATYPE_UINT8_ARRAY_32,
+ vect_table_attr_schema);
}
string oper_value = PhyUtil::uint8tostr(oper_status);
- PhyUtil::FillDbSchema(PORT_OPER_STATUS, oper_value,
+ PhyUtil::FillDbSchema(unc::uppl::PORT_OPER_STATUS, oper_value,
oper_value.length(), DATATYPE_UINT16,
vect_table_attr_schema);
DBTableSchema kt_port_dbtableschema;
- kt_port_dbtableschema.set_table_name(UPPL_PORT_TABLE);
+ kt_port_dbtableschema.set_table_name(unc::uppl::PORT_TABLE);
kt_port_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_port_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS update_db_status =
physical_layer->get_odbc_manager()->UpdateOneRow(
(unc_keytype_datatype_t)data_type,
- kt_port_dbtableschema);
- if (update_db_status != ODBCM_RC_SUCCESS) {
+ kt_port_dbtableschema, db_conn);
+ if (update_db_status == ODBCM_RC_ROW_NOT_EXISTS) {
+ pfc_log_info("No instance available for update");
+ } else if (update_db_status != ODBCM_RC_SUCCESS) {
// log error
pfc_log_error("oper_status update operation failed");
return UPPL_RC_ERR_DB_UPDATE;
} else {
// Notify operstatus change to northbound
- val_port_st old_val_port, new_val_port;
uint8_t old_oper_status = 0;
- UpplReturnCode read_status = GetOperStatus(data_type,
+ UpplReturnCode read_status = GetOperStatus(db_conn, data_type,
key_struct,
old_oper_status);
if (read_status == UPPL_RC_SUCCESS) {
- memset(old_val_port.valid, 0, 3);
+ val_port_st old_val_port, new_val_port;
+ memset(&old_val_port, 0, sizeof(old_val_port));
+ memset(&new_val_port, 0, sizeof(new_val_port));
old_val_port.oper_status = old_oper_status;
old_val_port.valid[kIdxPortOperStatus] = UNC_VF_VALID;
- memset(new_val_port.valid, 0, 3);
new_val_port.oper_status = oper_status;
new_val_port.valid[kIdxPortOperStatus] = UNC_VF_VALID;
int err = 0;
// Send notification to Northbound
ServerEvent ser_evt((pfc_ipcevtype_t)UPPL_EVENTS_KT_PORT, err);
- ser_evt.addOutput((uint32_t)UNC_OP_UPDATE);
- ser_evt.addOutput(data_type);
- ser_evt.addOutput((uint32_t)UPPL_EVENTS_KT_PORT);
- ser_evt.addOutput(*obj_key_port);
- ser_evt.addOutput(new_val_port);
- ser_evt.addOutput(old_val_port);
- PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
- // Notify operstatus modifications
- UpplReturnCode status = (UpplReturnCode) physical_layer
- ->get_ipc_connection_manager()->SendEvent(&ser_evt);
- pfc_log_debug("Event notification status %d", status);
+ northbound_event_header rsh = {UNC_OP_UPDATE,
+ data_type,
+ UNC_KT_PORT};
+ err = PhyUtil::sessOutNBEventHeader(ser_evt, rsh);
+ err |= ser_evt.addOutput(*obj_key_port);
+ err |= ser_evt.addOutput(new_val_port);
+ err |= ser_evt.addOutput(old_val_port);
+ if (err == 0) {
+ PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
+ // Notify operstatus modifications
+ UpplReturnCode status = (UpplReturnCode) physical_layer
+ ->get_ipc_connection_manager()->SendEvent(&ser_evt);
+ pfc_log_debug("Event notification status %d", status);
+ } else {
+ pfc_log_error("Server Event addOutput failed");
+ }
}
}
return UPPL_RC_SUCCESS;
}
-/** PopulateDBSchemaForKtTable
- * * @Description : This function populates the DBAttrSchema to be used to send
- * request to ODBC
- * * * @param[in] : DBTableSchema, key_struct, val_struct, operation_type
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
- * */
+/**
+ * @Description : This function is used to populate the db schema using the
+ * given key struct, value struct, data_type, operation,
+ * option1 and option
+ * @param[in] : kt_port_dbtableschema - object of type DBTableSchema
+ * key_struct - void pointer to be type cast into port key type
+ * val_struct - void pointer to be type cast into port value type
+ * operation_type - specifies the operation type i.e
+ * UNC_OP_READ or UNC_OP_READ_SIBLING_BEGIN etc
+ * option1/option2 - specifies any additional option for
+ * populating in DB
+ * vect_key_operations - vector of type ODBCMOperator
+ * old_value_struct - holds the old value structure of the
+ * port key type
+ * row_status - enum indicating the row status of port type
+ * entries in db
+ * is_filtering/is_state - bool variables
+ * @return : None
+ **/
void Kt_Port::PopulateDBSchemaForKtTable(
+ OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_port_dbtableschema,
void* key_struct,
void* val_struct,
uint8_t operation_type,
+ uint32_t data_type,
uint32_t option1,
uint32_t option2,
vector<ODBCMOperator> &vect_key_operations,
// controller_name
string controller_name = (const char*)obj_key_port
->sw_key.ctr_key.controller_name;
- pfc_log_info("controller name: %s", controller_name.c_str());
+ pfc_log_debug("controller name: %s", controller_name.c_str());
if (!controller_name.empty()) {
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
}
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// switch_id
string switch_id = (const char*)obj_key_port->sw_key.switch_id;
- pfc_log_info("switch id: %s", switch_id.c_str());
+ pfc_log_debug("switch id: %s", switch_id.c_str());
if (!switch_id.empty()) {
- vect_prim_keys.push_back(SWITCH_ID);
+ vect_prim_keys.push_back(SWITCH_ID_STR);
}
- PhyUtil::FillDbSchema(SWITCH_ID, switch_id,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_ID, switch_id,
switch_id.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
// port_id
port_id = "";
}
- pfc_log_info("port id: %s", port_id.c_str());
- PhyUtil::FillDbSchema(PORT_ID, port_id,
+ pfc_log_debug("port id: %s", port_id.c_str());
+ PhyUtil::FillDbSchema(unc::uppl::PORT_ID, port_id,
port_id.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
pfc_log_debug("Get Valid value from Update Valid Flag");
val_port_valid_st = new val_port_st_t();
unc_keytype_validflag_t new_valid_val = UNC_VF_VALID;
- UpdatePortValidFlag(key_struct, val_struct,
+ UpdatePortValidFlag(db_conn, key_struct, val_struct,
*val_port_valid_st,
- new_valid_val);
+ new_valid_val, data_type);
old_val_struct = reinterpret_cast<void *>(val_port_valid_st);
}
GetPortValStructure(
- obj_val_port,
+ db_conn, obj_val_port,
vect_table_attr_schema,
vect_prim_keys,
operation_type,
val_port_valid_st,
valid);
GetPortStateValStructure(
- obj_val_port,
+ db_conn, obj_val_port,
vect_table_attr_schema,
vect_prim_keys,
operation_type,
val_port_valid_st,
valid);
- vect_prim_keys.push_back(PORT_ID);
+ vect_prim_keys.push_back(PORT_ID_STR);
PhyUtil::reorder_col_attrs(vect_prim_keys, vect_table_attr_schema);
- kt_port_dbtableschema.set_table_name(UPPL_PORT_TABLE);
+ kt_port_dbtableschema.set_table_name(unc::uppl::PORT_TABLE);
kt_port_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_port_dbtableschema.set_row_list(row_list);
return;
}
-/** FillPortValueStructure
- * * @Description : This function populates val_port_st_t by values retrieved
- * from database
- * * * @param[in] : port table dbtable schema,
- * value structure and max_rep_ct, operation type
- * * * @return : Filled val_port_st and port id
- * */
+/**
+ * @Description : This function populates val_port_st_t by values retrieved
+ * from database
+ * @param[in] : kt_port table dbtable schema - object of type DBTableSchema
+ * vect_obj_val_port - vector to store the val_port_st structure
+ * values
+ * max_rep_ct - specifies number of rows to be returned
+ * operation_type - indicates the operation type
+ * port_id - vector of type key_port_t to store the port id
+ * @return : None
+ **/
void Kt_Port::FillPortValueStructure(
+ OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_port_dbtableschema,
vector<val_port_st_t> &vect_obj_val_port,
uint32_t &max_rep_ct,
uint32_t operation_type,
vector<key_port_t> &port_id) {
- // populate IPC value structure based on the response recevied from DB
- list < vector<TableAttrSchema> > res_port_row_list =
+ // populate IPC value structure based on the response received from DB
+ list < vector<TableAttrSchema> >& res_port_row_list =
kt_port_dbtableschema.get_row_list();
list < vector<TableAttrSchema> > :: iterator res_port_iter =
res_port_row_list.begin();
max_rep_ct = res_port_row_list.size();
pfc_log_debug("res_port_row_list.size: %d", max_rep_ct);
- // populate IPC value structure based on the response recevied from DB
+ // populate IPC value structure based on the response received from DB
for (; res_port_iter != res_port_row_list.end(); ++res_port_iter) {
vector<TableAttrSchema> res_port_table_attr_schema =
(*res_port_iter);
res_port_table_attr_schema.begin();
val_port_st_t obj_val_port;
memset(&obj_val_port, 0, sizeof(val_port_st_t));
- memset(&obj_val_port.port, 0, sizeof(val_port_t));
key_port_t obj_key_port;
memset(&obj_key_port, '\0', sizeof(obj_key_port));
// Read all attributes
++vect_port_iter) {
// Populate values from port_table
TableAttrSchema tab_schema = (*vect_port_iter);
- string attr_name = tab_schema.table_attribute_name;
- string attr_value;
- if (attr_name == CTR_NAME) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_key_port.sw_key.ctr_key.controller_name,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("controller_name: %s", reinterpret_cast<char *>
- (&obj_key_port.sw_key.ctr_key.controller_name));
- }
- if (attr_name == SWITCH_ID) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_256);
- memcpy(obj_key_port.sw_key.switch_id,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("switch_id: %s", reinterpret_cast<char *>
- (&obj_key_port.sw_key.switch_id));
- }
- if (attr_name == PORT_ID) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_key_port.port_id,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("port_id: %s", reinterpret_cast<char *>
- (&obj_key_port.port_id));
- }
- if (attr_name == PORT_NUMBER) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT32);
- obj_val_port.port.port_number = atoi(attr_value.c_str());
- pfc_log_debug("port_number: %d", obj_val_port.port.port_number);
- }
- if (attr_name == PORT_DESCRIPTION) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_128);
- memcpy(obj_val_port.port.description,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("description: %s", obj_val_port.port.description);
- }
- if (attr_name == PORT_ADMIN_STATUS) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- obj_val_port.port.admin_status = atoi(attr_value.c_str());
- pfc_log_debug("admin_status: %d", obj_val_port.port.admin_status);
- }
- if (attr_name == PORT_TRUNK_ALL_VLAN) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- obj_val_port.port.trunk_allowed_vlan =
- atoi((const char*)attr_value.c_str());
- pfc_log_debug("trunk_allowed_vlan: %s", attr_value.c_str());
- }
- if (attr_name == PORT_OPER_STATUS) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- obj_val_port.oper_status = atoi(attr_value.c_str());
- pfc_log_debug("oper status : %d", obj_val_port.oper_status);
- }
- if (attr_name == PORT_MAC_ADDRESS) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_6);
- memcpy(obj_val_port.mac_address,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("Mac_address: %s", obj_val_port.mac_address);
- }
- if (attr_name == PORT_DIRECTION) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- obj_val_port.direction = atoi(attr_value.c_str());
- pfc_log_debug("direction: %d", obj_val_port.direction);
- }
- if (attr_name == PORT_DUPLEX) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- obj_val_port.duplex = atoi(attr_value.c_str());
- pfc_log_debug("duplex : %d", obj_val_port.duplex);
- }
- if (attr_name == PORT_SPEED) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT64);
- pfc_log_debug("speed from DB : %s", attr_value.c_str());
- obj_val_port.speed = atol(attr_value.c_str());
- pfc_log_debug("speed : %" PFC_PFMT_u64, obj_val_port.speed);
- pfc_log_debug("speed PFC_PFMT_u64 : %" PFC_PFMT_u64 "...",
- obj_val_port.speed);
- }
- if (attr_name == PORT_ALARM_STATUS) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT64);
- obj_val_port.alarms_status = atol(attr_value.c_str());
- pfc_log_debug("alarms_status : %" PFC_PFMT_u64,
- obj_val_port.alarms_status);
- }
- if (attr_name == PORT_LOGIC_PORT_ID) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_320);
- memcpy(obj_val_port.logical_port_id,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("Logical_port_id: %s", obj_val_port.logical_port_id);
- }
- if (attr_name == PORT_VALID) {
- memset(obj_val_port.valid, 0, 8);
- obj_val_port.valid[kIdxPortSt] = UNC_VF_VALID;
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_11);
- memset(obj_val_port.port.valid, '\0', 4);
- FrameValidValue(attr_value, obj_val_port);
- pfc_log_debug("valid: %s", attr_value.c_str());
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
+ string attr_value = "";
+ switch (attr_name) {
+ case unc::uppl::CTR_NAME:
+ PhyUtil::GetValueFromDbSchemaStr(
+ tab_schema,
+ obj_key_port.sw_key.ctr_key.controller_name,
+ DATATYPE_UINT8_ARRAY_32);
+ pfc_log_debug("controller_name: %s", reinterpret_cast<char *>
+ (&obj_key_port.sw_key.ctr_key.controller_name));
+ break;
+
+ case unc::uppl::SWITCH_ID:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_key_port.sw_key.switch_id,
+ DATATYPE_UINT8_ARRAY_256);
+ pfc_log_debug("switch_id: %s", reinterpret_cast<char *>
+ (&obj_key_port.sw_key.switch_id));
+ break;
+
+ case unc::uppl::PORT_ID:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_key_port.port_id,
+ DATATYPE_UINT8_ARRAY_32);
+ pfc_log_debug("port_id: %s", reinterpret_cast<char *>
+ (&obj_key_port.port_id));
+ break;
+
+ case unc::uppl::PORT_NUMBER:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT32);
+ obj_val_port.port.port_number = atoi(attr_value.c_str());
+ pfc_log_debug("port_number: %d", obj_val_port.port.port_number);
+ break;
+
+ case unc::uppl::PORT_DESCRIPTION:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_val_port.port.description,
+ DATATYPE_UINT8_ARRAY_128);
+ pfc_log_debug("description: %s", obj_val_port.port.description);
+ break;
+
+ case unc::uppl::PORT_ADMIN_STATUS:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT16);
+ obj_val_port.port.admin_status = atoi(attr_value.c_str());
+ pfc_log_debug("admin_status: %d", obj_val_port.port.admin_status);
+ break;
+
+ case unc::uppl::PORT_TRUNK_ALL_VLAN:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT16);
+ obj_val_port.port.trunk_allowed_vlan =
+ atoi((const char*)attr_value.c_str());
+ pfc_log_debug("trunk_allowed_vlan: %s", attr_value.c_str());
+ break;
+
+ case unc::uppl::PORT_OPER_STATUS:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT16);
+ obj_val_port.oper_status = atoi(attr_value.c_str());
+ pfc_log_debug("oper status : %d", obj_val_port.oper_status);
+ break;
+
+ case unc::uppl::PORT_MAC_ADDRESS:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_val_port.mac_address,
+ DATATYPE_UINT8_ARRAY_6);
+ pfc_log_info(""
+ "FillPortValueStructure:mac_address %02x%02x.%02x%02x.%02x%02x",
+ obj_val_port.mac_address[0], obj_val_port.mac_address[1],
+ obj_val_port.mac_address[2], obj_val_port.mac_address[3],
+ obj_val_port.mac_address[4], obj_val_port.mac_address[5]);
+ break;
+
+ case unc::uppl::PORT_DIRECTION:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT16);
+ obj_val_port.direction = atoi(attr_value.c_str());
+ pfc_log_debug("direction: %d", obj_val_port.direction);
+ break;
+
+ case unc::uppl::PORT_DUPLEX:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT16);
+ obj_val_port.duplex = atoi(attr_value.c_str());
+ pfc_log_debug("duplex : %d", obj_val_port.duplex);
+ break;
+
+ case unc::uppl::PORT_SPEED:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT64);
+ pfc_log_debug("speed from DB : %s", attr_value.c_str());
+ obj_val_port.speed = atol(attr_value.c_str());
+ pfc_log_debug("speed : %" PFC_PFMT_u64, obj_val_port.speed);
+ pfc_log_debug("speed PFC_PFMT_u64 : %" PFC_PFMT_u64 "...",
+ obj_val_port.speed);
+ break;
+
+ case unc::uppl::PORT_ALARM_STATUS:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT64);
+ obj_val_port.alarms_status = atol(attr_value.c_str());
+ pfc_log_debug("alarms_status : %" PFC_PFMT_u64,
+ obj_val_port.alarms_status);
+ break;
+
+ case unc::uppl::PORT_LOGIC_PORT_ID:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_val_port.logical_port_id,
+ DATATYPE_UINT8_ARRAY_320);
+ pfc_log_debug("Logical_port_id: %s", obj_val_port.logical_port_id);
+ break;
+
+ case unc::uppl::PORT_VALID:
+ uint8_t port_valid[ODBCM_SIZE_11];
+ memset(obj_val_port.valid, 0, 8);
+ obj_val_port.valid[kIdxPortSt] = UNC_VF_VALID;
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema, port_valid,
+ DATATYPE_UINT8_ARRAY_11);
+ memset(obj_val_port.port.valid, '\0', 4);
+ FrameValidValue(reinterpret_cast<const char*> (port_valid),
+ obj_val_port);
+ pfc_log_debug("valid: %s", port_valid);
+ break;
+
+ default:
+ pfc_log_info("Ignoring Port attribute %d", attr_name);
+ break;
}
}
vect_obj_val_port.push_back(obj_val_port);
return;
}
-/** PerformRead
- * * @Description : This function reads the instance of KT_Port based on
- * operation type - READ, READ_SIBLING_BEGIN, READ_SIBLING
- * * * @param[in] : ipc session id, configuration id, key_struct, value_struct,
- * data_type, operation type, ServerSession, option1, option2,
- * max_rep_ct
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
- * */
-UpplReturnCode Kt_Port::PerformRead(uint32_t session_id,
+/**
+ * @Description : This function is used to read KT_PORT instance in database
+ * table using key_ctr provided in IPC request
+ * The IPC response would be filled in IPC session
+ * @param[in] : ipc session id - ipc session id used for TC validation
+ * configuration id - configuration id used for TC validation
+ * key_struct - void pointer to be type cast into port key type
+ * value_struct - void pointer to be type cast into port value
+ * structure
+ * data_type - specifies the data base type i.e UNC_DT_STATE
+ * or UNC_DT_IMPORT
+ * operation type - indicates the operation type
+ * sess - ipc server session where the response has to be added
+ * option1,option2 - specifies any additional condition for
+ * read operation
+ * max_rep_ct - indicates the maximum repetition count
+ * @return : UPPL_RC_SUCCESS - if the read operation is successful
+ * UPPL_RC_ERR_* - read operation failed
+ **/
+UpplReturnCode Kt_Port::PerformRead(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t option1,
uint32_t option2,
uint32_t max_rep_ct) {
- pfc_log_info("Inside PerformRead option1=%d option2=%d max_rep_ct=%d",
- option1, option2, max_rep_ct);
pfc_log_info("Inside PerformRead operation_type=%d data_type=%d",
operation_type, data_type);
key_port_t *obj_key_port =
pfc_log_debug("Populating val_port_st from DB");
vector<key_port_t> vect_port_id;
vector<val_port_st_t> vect_val_port_st;
- read_status = ReadPortValFromDB(key_struct,
+ read_status = ReadPortValFromDB(db_conn, key_struct,
val_struct,
data_type,
operation_type,
vect_port_id);
rsh.result_code = read_status;
rsh.max_rep_count = max_rep_ct;
- pfc_log_info("read status val in performread = %d", read_status);
+ pfc_log_debug("read status val in performread = %d", read_status);
if (read_status != UPPL_RC_SUCCESS) {
rsh.max_rep_count = 0;
int err = PhyUtil::sessOutRespHeader(sess, rsh);
}
} else if (option2 == UNC_OPT2_NEIGHBOR) {
- pfc_log_info("Read neighbor details from DB");
+ pfc_log_debug("Read neighbor details from DB");
val_port_st_neighbor obj_neighbor;
+ memset(&obj_neighbor, '\0', sizeof(val_port_st_neighbor));
read_status = ReadNeighbor(
- key_struct,
+ db_conn, key_struct,
val_struct,
data_type,
obj_neighbor);
- pfc_log_info("Return value for read operation %d", read_status);
+ pfc_log_debug("Return value for read operation %d", read_status);
rsh.result_code = read_status;
int err = PhyUtil::sessOutRespHeader(sess, rsh);
err |= sess.addOutput((uint32_t)UNC_KT_PORT);
return UPPL_RC_SUCCESS;
}
-/** ReadPortValFromDB
- * * @Description : This function reads the instance of KT_Port based on
- * operation type - READ, READ_SIBLING_BEGIN, READ_SIBLING
- * from data base
- * * * @param[in] : key_struct, value_struct, ipc session id, configuration id,
- * data_type, operation type, max_rep_ct
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
- * */
+/**
+ * @Description : This function is used to read KT_PORT instance in database
+ * table using key_ctr provided in IPC request and operation_type
+ * @param[in] : key_struct - void pointer to be type cast into port key
+ * structure
+ * value_struct - void pointer to be type cast into port value
+ * structure
+ * data_type - indicates the data base type
+ * operation_type - indicates the operation type UNC_OP*
+ * max_rep_ct - indicates the maximum repetition count
+ * vect_val_port - vector to store the val_port_st_t structure
+ * port_id - vector of type key_port_t to store the
+ * logical port id
+ * @return : UPPL_RC_SUCCESS - read operation is success
+ * UPPL_RC_ERR_DB_GET - read operation is failure
+ **/
UpplReturnCode Kt_Port::ReadPortValFromDB(
+ OdbcmConnectionHandler *db_conn,
void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t &max_rep_ct,
vector<val_port_st_t> &vect_val_port_st,
vector<key_port_t> &port_id) {
+ if (operation_type < UNC_OP_READ) {
+ // Unsupported operation type for this function
+ return UPPL_RC_SUCCESS;
+ }
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode read_status = UPPL_RC_SUCCESS;
ODBCM_RC_STATUS read_db_status = ODBCM_RC_SUCCESS;
-
// Common structures that will be used to send query to ODBC
// Structure used to send request to ODBC
DBTableSchema kt_port_dbtableschema;
void *old_struct;
vector<ODBCMOperator> vect_key_operations;
- PopulateDBSchemaForKtTable(kt_port_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_port_dbtableschema,
key_struct,
val_struct,
- operation_type, 0, 0,
+ operation_type, data_type, 0, 0,
vect_key_operations, old_struct);
if (operation_type == UNC_OP_READ) {
read_db_status = physical_layer->get_odbc_manager()->
GetOneRow((unc_keytype_datatype_t)data_type,
- kt_port_dbtableschema);
+ kt_port_dbtableschema, db_conn);
} else {
read_db_status = physical_layer->get_odbc_manager()->
GetBulkRows((unc_keytype_datatype_t)data_type, max_rep_ct,
kt_port_dbtableschema,
- (unc_keytype_operation_t)operation_type);
+ (unc_keytype_operation_t)operation_type, db_conn);
}
if (read_db_status == ODBCM_RC_RECORD_NOT_FOUND) {
pfc_log_debug("No record found");
}
pfc_log_debug("Read operation Success result: %d", read_status);
- FillPortValueStructure(kt_port_dbtableschema,
+ FillPortValueStructure(db_conn, kt_port_dbtableschema,
vect_val_port_st,
max_rep_ct,
UNC_OP_READ,
}
/** ReadNeighbor
- * * @Description : This function reads the Neighbor information from driver
- * * * @param[in] : Session id, configuration id, key_struct, value_struct,
- * data_type, operation type
- * * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
- * */
+ * @Description : This function reads the Neighbor information from driver
+ * @param[in] : key_struct - void pointer to be type cast to port key type
+ * val_struct - void pointer to be type cast to port val
+ * structure type
+ * data_type - indicates the data base type
+ * neighbor_obj - structure variable of type val_port_st_neighbor
+ * @return : UPPL_RC_SUCCESS - is returned if the read neighbor operation
+ * is success
+ * UPPL_RC_ERR* - is returned if the read neighbor operation is
+ * failure
+ **/
UpplReturnCode Kt_Port::ReadNeighbor(
+ OdbcmConnectionHandler *db_conn,
void* key_struct,
void* val_struct,
uint32_t data_type,
sw_key.ctr_key.controller_name;
string switch_id = (const char*)obj_key_port->sw_key.switch_id;
string port_id = (const char*)obj_key_port->port_id;
- string switch_id2, port_id2;
+ string switch_id2 = "";
+ string port_id2 = "";
// Read Port value from DB
vector<void *> vect_key_port;
vect_key_port.push_back(reinterpret_cast<void *>(obj_key_port));
vector<void *> vect_val_port;
- read_status = ReadInternal(vect_key_port,
+ read_status = ReadInternal(db_conn, vect_key_port,
vect_val_port,
data_type,
UNC_OP_READ);
val_port_t obj_val_port = obj_val_st_port->port;
DBTableSchema kt_port_dbtableschema;
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
- vect_prim_keys.push_back(LINK_SWITCH_ID1);
- vect_prim_keys.push_back(LINK_PORT_ID1);
+ vect_prim_keys.push_back(CTR_NAME_STR);
+ vect_prim_keys.push_back(LINK_SWITCH_ID1_STR);
+ vect_prim_keys.push_back(LINK_PORT_ID1_STR);
vector<TableAttrSchema> vect_table_attr_schema;
list< vector<TableAttrSchema> > row_list;
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- PhyUtil::FillDbSchema(LINK_SWITCH_ID1, switch_id,
+ PhyUtil::FillDbSchema(unc::uppl::LINK_SWITCH_ID1, switch_id,
switch_id.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
- PhyUtil::FillDbSchema(LINK_PORT_ID1, port_id,
+ PhyUtil::FillDbSchema(unc::uppl::LINK_PORT_ID1, port_id,
port_id.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- PhyUtil::FillDbSchema(LINK_SWITCH_ID2, switch_id2,
+ PhyUtil::FillDbSchema(unc::uppl::LINK_SWITCH_ID2, switch_id2,
switch_id2.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
- PhyUtil::FillDbSchema(LINK_PORT_ID2, port_id2,
+ PhyUtil::FillDbSchema(unc::uppl::LINK_PORT_ID2, port_id2,
port_id2.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- kt_port_dbtableschema.set_table_name(UPPL_LINK_TABLE);
+ kt_port_dbtableschema.set_table_name(unc::uppl::LINK_TABLE);
kt_port_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_port_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS read_db_status = physical_layer->get_odbc_manager()->
- GetOneRow((unc_keytype_datatype_t)data_type, kt_port_dbtableschema);
+ GetOneRow((unc_keytype_datatype_t)data_type, kt_port_dbtableschema,
+ db_conn);
if (read_db_status == ODBCM_RC_SUCCESS) {
read_status = UPPL_RC_SUCCESS;
- // populate IPC value structure based on the response recevied from DB
+ // populate IPC value structure based on the response received from DB
vector<TableAttrSchema> res_table_attr_schema =
kt_port_dbtableschema.get_row_list().front();
vector<TableAttrSchema> ::iterator vect_iter =
neighbor_obj.port = obj_val_port;
for (; vect_iter != res_table_attr_schema.end(); ++vect_iter) {
TableAttrSchema tab_schema = (*vect_iter);
- string attr_name = tab_schema.table_attribute_name;
- if (attr_name == LINK_SWITCH_ID2) {
- string switch_id2;
- PhyUtil::GetValueFromDbSchema(tab_schema, switch_id2,
- DATATYPE_UINT8_ARRAY_256);
- memcpy(neighbor_obj.connected_switch_id,
- switch_id2.c_str(), switch_id2.length()+1);
- pfc_log_debug("Connected switch id: %s", switch_id2.c_str());
- } else if (attr_name == LINK_PORT_ID2) {
- string port_id2;
- PhyUtil::GetValueFromDbSchema(tab_schema, port_id2,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(neighbor_obj.connected_port_id,
- port_id2.c_str(), port_id2.length()+1);
- pfc_log_debug("Connected port id: %s", port_id2.c_str());
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
+ if (attr_name == unc::uppl::LINK_SWITCH_ID2) {
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ neighbor_obj.connected_switch_id,
+ DATATYPE_UINT8_ARRAY_256);
+ pfc_log_debug("Connected switch id: %s",
+ neighbor_obj.connected_switch_id);
+ } else if (attr_name == unc::uppl::LINK_PORT_ID2) {
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ neighbor_obj.connected_port_id,
+ DATATYPE_UINT8_ARRAY_32);
+ pfc_log_debug("Connected port id: %s", neighbor_obj.connected_port_id);
}
}
} else {
return read_status;
}
-/** Fill_Attr_Syntax_Map
- * * @Description : This function populates the values to be used for attribute
- * validation
- * * * @param[in] : None
- * * * @return : None
- * */
+/**
+ * @Description : This function populates the values to be used for attribute
+ * validation
+ * @param[in] : None
+ * @return : None
+ **/
void Kt_Port::Fill_Attr_Syntax_Map() {
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map;
+
Kt_Class_Attr_Syntax objKeyAttrCtrSyntax =
{ PFC_IPCTYPE_UINT8, 0, 0, 1, 32, true, "" };
- attr_syntax_map[CTR_NAME] = objKeyAttrCtrSyntax;
+ attr_syntax_map[CTR_NAME_STR] = objKeyAttrCtrSyntax;
Kt_Class_Attr_Syntax objKeyAttrSwitchSyntax =
{ PFC_IPCTYPE_UINT8, 0, 0, 1, 32, true, "" };
- attr_syntax_map[SWITCH_ID] = objKeyAttrSwitchSyntax;
+ attr_syntax_map[SWITCH_ID_STR] = objKeyAttrSwitchSyntax;
Kt_Class_Attr_Syntax objKeyAttrPortSyntax =
{ PFC_IPCTYPE_UINT8, 0, 0, 1, 32, true, "" };
- attr_syntax_map[PORT_ID] = objKeyAttrPortSyntax;
+ attr_syntax_map[PORT_ID_STR] = objKeyAttrPortSyntax;
Kt_Class_Attr_Syntax objAttrPortNumberSyntax =
- { PFC_IPCTYPE_UINT32, 0, 100000, 0, 0, false, "" };
- attr_syntax_map[PORT_NUMBER] = objAttrPortNumberSyntax;
+ { PFC_IPCTYPE_UINT32, 1, 4294967295LL, 0, 0, false, "" };
+ attr_syntax_map[PORT_NUMBER_STR] = objAttrPortNumberSyntax;
Kt_Class_Attr_Syntax objAttrDescSyntax =
{ PFC_IPCTYPE_STRING, 0, 0, 0, 128, false, "" };
- attr_syntax_map[PORT_DESCRIPTION] = objAttrDescSyntax;
+ attr_syntax_map[PORT_DESCRIPTION_STR] = objAttrDescSyntax;
Kt_Class_Attr_Syntax objAttrAdminStatusSyntax =
{ PFC_IPCTYPE_UINT8, 0, 1, 0, 0, false, "" };
- attr_syntax_map[PORT_ADMIN_STATUS] = objAttrAdminStatusSyntax;
+ attr_syntax_map[PORT_ADMIN_STATUS_STR] = objAttrAdminStatusSyntax;
Kt_Class_Attr_Syntax objAttrDirectionSyntax =
{ PFC_IPCTYPE_UINT8, 0, 2, 0, 0, false, "" };
- attr_syntax_map[PORT_DIRECTION] = objAttrDirectionSyntax;
+ attr_syntax_map[PORT_DIRECTION_STR] = objAttrDirectionSyntax;
Kt_Class_Attr_Syntax objAttrTrunkAVlanSyntax =
{ PFC_IPCTYPE_UINT16, 0, 65536, 0, 0, false, "" };
- attr_syntax_map[PORT_TRUNK_ALL_VLAN] = objAttrTrunkAVlanSyntax;
+ attr_syntax_map[PORT_TRUNK_ALL_VLAN_STR] = objAttrTrunkAVlanSyntax;
Kt_Class_Attr_Syntax objAttrOperStatusSyntax =
{ PFC_IPCTYPE_UINT8, 0, 2, 0, 0, false, "" };
- attr_syntax_map[PORT_OPER_STATUS] = objAttrOperStatusSyntax;
+ attr_syntax_map[PORT_OPER_STATUS_STR] = objAttrOperStatusSyntax;
Kt_Class_Attr_Syntax objAttrMacAddressSyntax =
{ PFC_IPCTYPE_STRING, 0, 0, 0, 6, false, "" };
- attr_syntax_map[PORT_MAC_ADDRESS] = objAttrMacAddressSyntax;
+ attr_syntax_map[PORT_MAC_ADDRESS_STR] = objAttrMacAddressSyntax;
Kt_Class_Attr_Syntax objAttrDuplexSyntax =
{ PFC_IPCTYPE_UINT8, 0, 1, 0, 0, false, "" };
- attr_syntax_map[PORT_DUPLEX] = objAttrDuplexSyntax;
+ attr_syntax_map[PORT_DUPLEX_STR] = objAttrDuplexSyntax;
Kt_Class_Attr_Syntax objAttrSpeedSyntax =
{ PFC_IPCTYPE_UINT64, 0, 0, 0, 0, false, "" };
- attr_syntax_map[PORT_SPEED] = objAttrSpeedSyntax;
+ attr_syntax_map[PORT_SPEED_STR] = objAttrSpeedSyntax;
Kt_Class_Attr_Syntax objAttrAlarmsStatusSyntax =
{ PFC_IPCTYPE_UINT64, 1, 3, 0, 0, false, "" };
- attr_syntax_map[PORT_ALARM_STATUS] = objAttrAlarmsStatusSyntax;
+ attr_syntax_map[PORT_ALARM_STATUS_STR] = objAttrAlarmsStatusSyntax;
Kt_Class_Attr_Syntax objAttrLogicalPortIdSyntax =
{ PFC_IPCTYPE_STRING, 0, 0, 0, 320, false, "" };
- attr_syntax_map[PORT_LOGIC_PORT_ID] = objAttrLogicalPortIdSyntax;
+ attr_syntax_map[PORT_LOGIC_PORT_ID_STR] = objAttrLogicalPortIdSyntax;
Kt_Class_Attr_Syntax objAttrValidSyntax =
{ PFC_IPCTYPE_STRING, 0, 0, 0, 12, false, "" };
- attr_syntax_map[PORT_VALID] = objAttrValidSyntax;
+ attr_syntax_map[PORT_VALID_STR] = objAttrValidSyntax;
+
+ attr_syntax_map_all[UNC_KT_PORT] = attr_syntax_map;
}
-/** UpdatePortValidFlag
- * * @Description : This function forms the valid flag based on update req
- * * * @param[in] : Key, value struct and newvalid val
- * * * @return : Success or associated error code
- * */
+/**
+ * @Description : This function forms the valid flag based on update req
+ * @param[in] : key_struct - void pointer to be type cast to port key type
+ * val_struct - void pointer to be type cast to port value
+ * structure type
+ * val_port_valid_st - structure variable of type
+ * val_port_valid_st
+ * new_valid_val - enum for valid flag
+ * @return : UPPL_RC_SUCCESS - if valid flag update is success
+ * UPL_RC_ERR_* - if valid flag update is failure
+ **/
UpplReturnCode Kt_Port::UpdatePortValidFlag(
+ OdbcmConnectionHandler *db_conn,
void *key_struct,
void *val_struct,
val_port_st_t &val_port_valid_st,
- unc_keytype_validflag_t new_valid_val) {
+ unc_keytype_validflag_t new_valid_val,
+ uint32_t data_type) {
UpplReturnCode return_code = UPPL_RC_SUCCESS;
// read the value structure from db
void *obj_key_port_orig = key_struct;
vector<void *> vect_key_port;
vect_key_port.push_back(key_struct);
vector<void *> vect_val_port;
- return_code = ReadInternal(vect_key_port, vect_val_port,
- UNC_DT_STATE, UNC_OP_READ);
+ return_code = ReadInternal(db_conn, vect_key_port, vect_val_port,
+ data_type, UNC_OP_READ);
if (return_code != UPPL_RC_SUCCESS) {
pfc_log_info("Read is not success");
return return_code;
uint32_t operation_type = UNC_OP_UPDATE;
// Get the valid value from req received, verify the valid status
- // For all valid attribs update stream to valid, for invalid attribs
+ // For all valid attributes update stream to valid, for invalid attributes
// update stream with valid value read from db.
// store the final valid val to stream
stringstream ss_new;
unsigned int valid_val =
PhyUtil::uint8touint(obj_val_port->port.valid[kIdxPortNumber]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- pfc_log_debug("valid value port_number: %d", valid_val);
ss_new << new_valid_val;
} else {
- ss_new << obj_new_val_port->port.valid[kIdxPortNumber];
+ ss_new << PhyUtil::uint8touint(
+ obj_new_val_port->port.valid[kIdxPortNumber]);
pfc_log_debug("invalid value for port_number ignore the value");
}
valid_val =
PhyUtil::uint8touint(obj_val_port->port.valid[kIdxPortDescription]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- pfc_log_debug("valid val desc: %d", valid_val);
ss_new << new_valid_val;
} else {
- ss_new << obj_new_val_port->port.valid[kIdxPortDescription];
+ ss_new << PhyUtil::uint8touint(
+ obj_new_val_port->port.valid[kIdxPortDescription]);
pfc_log_debug("invalid value for desc ignore the value");
}
valid_val =
PhyUtil::uint8touint(obj_val_port->port.valid[kIdxPortAdminStatus]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- pfc_log_debug("valid value admin_status: %d", valid_val);
ss_new << new_valid_val;
} else {
- ss_new << obj_new_val_port->port.valid[kIdxPortAdminStatus];
+ ss_new << PhyUtil::uint8touint(
+ obj_new_val_port->port.valid[kIdxPortAdminStatus]);
pfc_log_debug("invalid value for admin_status ignore the value");
}
PhyUtil::uint8touint(
obj_val_port->port.valid[kIdxPortTrunkAllowedVlan]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- pfc_log_debug("valid value trunkallowed: %d", valid_val);
ss_new << new_valid_val;
} else {
- ss_new << obj_new_val_port->port.valid[kIdxPortTrunkAllowedVlan];
+ ss_new << PhyUtil::uint8touint(
+ obj_new_val_port->port.valid[kIdxPortTrunkAllowedVlan]);
pfc_log_debug("invalid value for trunkallowed ignore the value");
}
valid_val =
PhyUtil::uint8touint(obj_val_port->valid[kIdxPortOperStatus]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- pfc_log_debug("valid value operstatus: %d", valid_val);
ss_new << new_valid_val;
} else {
- ss_new << obj_new_val_port->valid[kIdxPortOperStatus];
+ ss_new << PhyUtil::uint8touint(
+ obj_new_val_port->valid[kIdxPortOperStatus]);
pfc_log_debug("invalid value for operstatus ignore the value");
}
valid_val =
PhyUtil::uint8touint(obj_val_port->valid[kIdxPortMacAddress]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- pfc_log_debug("valid value macaddress: %d", valid_val);
ss_new << new_valid_val;
} else {
- ss_new << obj_new_val_port->valid[kIdxPortMacAddress];
+ ss_new << PhyUtil::uint8touint(
+ obj_new_val_port->valid[kIdxPortMacAddress]);
pfc_log_debug("invalid value for macaddress ignore the value");
}
valid_val =
PhyUtil::uint8touint(obj_val_port->valid[kIdxPortDirection]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- pfc_log_debug("valid value portdirection: %d", valid_val);
ss_new << new_valid_val;
} else {
- ss_new << obj_new_val_port->valid[kIdxPortDirection];
+ ss_new << PhyUtil::uint8touint(
+ obj_new_val_port->valid[kIdxPortDirection]);
pfc_log_debug("invalid value for portdirection ignore the value");
}
// valid val of portduplex
valid_val = PhyUtil::uint8touint(obj_val_port->valid[kIdxPortDuplex]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- pfc_log_debug("valid value portduplex: %d", valid_val);
ss_new << new_valid_val;
} else {
- ss_new << obj_new_val_port->valid[kIdxPortDuplex];
+ ss_new << PhyUtil::uint8touint(obj_new_val_port->valid[kIdxPortDuplex]);
pfc_log_debug("invalid value for portduplex ignore the value");
}
// valid val of portspeed
valid_val = PhyUtil::uint8touint(obj_val_port->valid[kIdxPortSpeed]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- pfc_log_debug("valid value portspeed: %d", valid_val);
ss_new << new_valid_val;
} else {
- ss_new << obj_new_val_port->valid[kIdxPortSpeed];
+ ss_new << PhyUtil::uint8touint(obj_new_val_port->valid[kIdxPortSpeed]);
pfc_log_debug("invalid value for portspeed ignore the value");
}
- // valid val of alrmstatus
+ // valid val of alarmstatus
valid_val =
PhyUtil::uint8touint(obj_val_port->valid[kIdxPortAlarmsStatus]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- pfc_log_debug("valid value alrmstatus: %d", valid_val);
ss_new << new_valid_val;
} else {
- ss_new << obj_new_val_port->valid[kIdxPortAlarmsStatus];
+ ss_new << PhyUtil::uint8touint(
+ obj_new_val_port->valid[kIdxPortAlarmsStatus]);
pfc_log_debug("invalid value for alrmstatus ignore the value");
}
valid_val =
PhyUtil::uint8touint(obj_val_port->valid[kIdxPortLogicalPortId]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- pfc_log_debug("valid value logicalportid: %d", valid_val);
ss_new << new_valid_val;
} else {
- ss_new << obj_new_val_port->valid[kIdxPortLogicalPortId];
+ ss_new << PhyUtil::uint8touint(
+ obj_new_val_port->valid[kIdxPortLogicalPortId]);
pfc_log_debug("invalid value for logicalportid ignore the value");
}
- pfc_log_debug("updateport final valid val:%s", ss_new.str().c_str());
+ pfc_log_debug("update port final valid val:%s", ss_new.str().c_str());
// call populate schema for valid update
return_code = PopulateSchemaForValidFlag(
- // key_struct,
+ db_conn,
obj_key_port_orig,
reinterpret_cast<void*> (&obj_new_val_port),
- ss_new.str().c_str());
+ ss_new.str().c_str(), data_type);
delete obj_new_val_port;
obj_new_val_port = NULL;
key_port_t *key_port = reinterpret_cast<key_port_t*>(vect_key_port[0]);
return return_code;
}
-/** PopulateSchemaForValidFlag
- * * @Description : This function updates the valid flag value
- * of the port
- * * @param[in] : key_struct, value_struct, valid val
- * * @return : success/failure
- */
-UpplReturnCode Kt_Port::PopulateSchemaForValidFlag(void* key_struct,
- void* val_struct,
- string valid_new) {
+/**
+ * @Description : This function updates the valid flag value
+ * of the port
+ * @param[in] : key_struct - void pointer to be type cast to port key type
+ * structure
+ * val_struct - void pointer to be type cast to port value type
+ * structure
+ * valid_new - stores the valid flag to be updated in Db
+ * @return : UPPL_RC_SUCCESS - if port valid update operation is success
+ * UPPL_RC_ERR_* - if port valid update operation is failure
+ **/
+UpplReturnCode Kt_Port::PopulateSchemaForValidFlag(
+ OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ void* val_struct,
+ string valid_new,
+ uint32_t data_type) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
key_port_t *obj_key_port=
reinterpret_cast<key_port_t*>(key_struct);
- TableAttrSchema kt_port_table_attr_schema;
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
- vect_prim_keys.push_back(SWITCH_ID);
- vect_prim_keys.push_back(PORT_ID);
+ vect_prim_keys.push_back(CTR_NAME_STR);
+ vect_prim_keys.push_back(SWITCH_ID_STR);
+ vect_prim_keys.push_back(PORT_ID_STR);
string controller_name = (const char*)obj_key_port->sw_key.
sw_key.switch_id;
string port_id = (const char*)obj_key_port->port_id;
if (!controller_name.empty()) {
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
(controller_name.length()+1), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
}
if (!switch_id.empty()) {
- PhyUtil::FillDbSchema(SWITCH_ID, switch_id,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_ID, switch_id,
(switch_id.length()+1), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
}
if (!port_id.empty()) {
- PhyUtil::FillDbSchema(PORT_ID, port_id,
+ PhyUtil::FillDbSchema(unc::uppl::PORT_ID, port_id,
(port_id.length()+1), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
}
pfc_log_debug("valid new val:%s", valid_new.c_str());
- PhyUtil::FillDbSchema(PORT_VALID, valid_new.c_str(),
+ PhyUtil::FillDbSchema(unc::uppl::PORT_VALID, valid_new.c_str(),
11, DATATYPE_UINT8_ARRAY_11,
vect_table_attr_schema);
DBTableSchema kt_port_dbtableschema;
- kt_port_dbtableschema.set_table_name(UPPL_PORT_TABLE);
+ kt_port_dbtableschema.set_table_name(unc::uppl::PORT_TABLE);
kt_port_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_port_dbtableschema.set_row_list(row_list);
// Call ODBCManager and update
ODBCM_RC_STATUS update_db_status =
- physical_layer->get_odbc_manager()->UpdateOneRow(UNC_DT_STATE,
- kt_port_dbtableschema);
+ physical_layer->get_odbc_manager()->UpdateOneRow(
+ unc_keytype_datatype_t(data_type),
+ kt_port_dbtableschema,
+ db_conn);
if (update_db_status != ODBCM_RC_SUCCESS) {
// log error
pfc_log_error("port valid update operation failed");
return UPPL_RC_SUCCESS;
}
-/** FrameValidValue
- * * @Description : This function converts the string value from db to uint8
- * * * @param[in] : Attribute value and val_ctr_st
- * * * @return : Success or associated error code
- * */
+/**
+ * @Description : This function converts the string value from db to uint8
+ * @param[in] : attr_value - string to store attribute value
+ * obj_val_port - struct variables of val_port_st structure
+ * @return : None
+ **/
+
void Kt_Port::FrameValidValue(string attr_value,
val_port_st &obj_val_port) {
for (unsigned int index = 0; index < attr_value.length(); ++index) {
return;
}
-/** GetPortValStructure
- * * @Description : This function reads the values given in val_port structure
- * * @param[in] : DBTableSchema - DBtableschema associated with KT_Port
- * key_struct - key instance of Kt_Switch
- * val_struct - val instance of Kt_Switch
- * operation_type - UNC_OP*
- * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
- * */
+/**
+ * @Description : This function reads the values given in val_port structure
+ * @param[in] : obj_val_port - pointer to structure val_port_st_t
+ * vect_table_attr_schema - vector to store the db table
+ * attribute schema
+ * vect_prim_keys - vector to store the primary keys of port key
+ * type
+ * operation_type - indicates the operation type
+ * val_port_valid_st - pointer to the structure val_port_st_t
+ * valid - reference variable to store the valid flags of port
+ * value structure
+ * @return : None
+ **/
void Kt_Port::GetPortValStructure(
+ OdbcmConnectionHandler *db_conn,
val_port_st_t *obj_val_port,
vector<TableAttrSchema> &vect_table_attr_schema,
vector<string> &vect_prim_keys,
valid_value_struct = PhyUtil::uint8touint(
obj_val_port->valid[kIdxPortSt]);
}
- string value;
+ string value = "";
// Port_number
if (obj_val_port != NULL && valid_value_struct == UNC_VF_VALID) {
valid_val = PhyUtil::uint8touint(
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(PORT_NUMBER, value,
+ PhyUtil::FillDbSchema(unc::uppl::PORT_NUMBER, PORT_NUMBER_STR, value,
value.length(), DATATYPE_UINT32,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(PORT_DESCRIPTION, value,
- value.length(), DATATYPE_UINT8_ARRAY_128,
+ PhyUtil::FillDbSchema(unc::uppl::PORT_DESCRIPTION, PORT_DESCRIPTION_STR,
+ value, value.length(), DATATYPE_UINT8_ARRAY_128,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
value.clear();
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(PORT_ADMIN_STATUS, value,
- value.length(), DATATYPE_UINT16,
+ PhyUtil::FillDbSchema(unc::uppl::PORT_ADMIN_STATUS, PORT_ADMIN_STATUS_STR,
+ value, value.length(), DATATYPE_UINT16,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
value.clear();
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(PORT_TRUNK_ALL_VLAN, value,
- value.length(), DATATYPE_UINT16,
+ PhyUtil::FillDbSchema(unc::uppl::PORT_TRUNK_ALL_VLAN, PORT_TRUNK_ALL_VLAN_STR,
+ value, value.length(), DATATYPE_UINT16,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
return;
}
-/** GetPortStateValStructure
- * * @Description : This function reads the values given in val_port_st structure
- * * @param[in] : DBTableSchema - DBtableschema associated with KT_Port
- * key_struct - key instance of Kt_Switch
- * val_struct - val instance of Kt_Switch
- * operation_type - UNC_OP*
- * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
- * */
+/**
+ * @Description : This function reads the values given in val_port_st structure
+ * @param[in] : obj_val_port - pointer to structure val_port_st_t
+ * vect_table_attr_schema - vector to store the table attribute
+ * schema of key type port
+ * vect_prim_keys - vector to store the primary keys of port key
+ * type
+ * operation_type - indicates the operation type
+ * val_port_valid_st - pointer to the structure val_port_st_t
+ * valid - reference variable to store the valid flags of port
+ * value structure
+ * @return : None
+ **/
void Kt_Port::GetPortStateValStructure(
+ OdbcmConnectionHandler *db_conn,
val_port_st_t *obj_val_port,
vector<TableAttrSchema> &vect_table_attr_schema,
vector<string> &vect_prim_keys,
uint8_t operation_type,
val_port_st_t *val_port_valid_st,
stringstream &valid) {
- string value;
+ string value = "";
uint16_t valid_val = 0, prev_db_val = 0;
// oper status
if (obj_val_port != NULL) {
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(PORT_OPER_STATUS, value,
- value.length(), DATATYPE_UINT16,
+ PhyUtil::FillDbSchema(unc::uppl::PORT_OPER_STATUS, PORT_OPER_STATUS_STR,
+ value, value.length(), DATATYPE_UINT16,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
value.clear();
// Mac_address
if (obj_val_port != NULL) {
valid_val = PhyUtil::uint8touint(obj_val_port->valid[kIdxPortMacAddress]);
- if (valid_val == UNC_VF_VALID) {
- value = (const char*)obj_val_port->mac_address;
- }
if (operation_type == UNC_OP_UPDATE) {
prev_db_val =
PhyUtil::uint8touint(
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(PORT_MAC_ADDRESS, value,
- value.length(), DATATYPE_UINT8_ARRAY_6,
- operation_type, valid_val, prev_db_val,
- vect_table_attr_schema, vect_prim_keys, valid);
+ if (valid_val == UNC_VF_VALID) {
+ PhyUtil::FillDbSchema(unc::uppl::PORT_MAC_ADDRESS, PORT_MAC_ADDRESS_STR,
+ obj_val_port->mac_address, ODBCM_SIZE_6,
+ DATATYPE_UINT8_ARRAY_6,
+ operation_type, valid_val, prev_db_val,
+ vect_table_attr_schema, vect_prim_keys, valid);
+ } else {
+ PhyUtil::FillDbSchema(unc::uppl::PORT_MAC_ADDRESS, PORT_MAC_ADDRESS_STR,
+ value, value.length(), DATATYPE_UINT8_ARRAY_6,
+ operation_type, valid_val, prev_db_val,
+ vect_table_attr_schema, vect_prim_keys, valid);
+ }
+
value.clear();
// direction
if (obj_val_port != NULL) {
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(PORT_DIRECTION, value,
+ PhyUtil::FillDbSchema(unc::uppl::PORT_DIRECTION, PORT_DIRECTION_STR, value,
value.length(), DATATYPE_UINT16,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(PORT_DUPLEX, value,
+ PhyUtil::FillDbSchema(unc::uppl::PORT_DUPLEX, PORT_DUPLEX_STR, value,
value.length(), DATATYPE_UINT16,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(PORT_SPEED, value,
+ PhyUtil::FillDbSchema(unc::uppl::PORT_SPEED, PORT_SPEED_STR, value,
value.length(), DATATYPE_UINT64,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
if (operation_type == UNC_OP_CREATE) {
valid_val = UNC_VF_VALID;
}
- PhyUtil::FillDbSchema(PORT_ALARM_STATUS, value,
- value.length(), DATATYPE_UINT64,
+ PhyUtil::FillDbSchema(unc::uppl::PORT_ALARM_STATUS, PORT_ALARM_STATUS_STR,
+ value, value.length(), DATATYPE_UINT64,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
value.clear();
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(PORT_LOGIC_PORT_ID, value,
- value.length(), DATATYPE_UINT8_ARRAY_320,
+ PhyUtil::FillDbSchema(unc::uppl::PORT_LOGIC_PORT_ID, PORT_LOGIC_PORT_ID_STR,
+ value, value.length(), DATATYPE_UINT8_ARRAY_320,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
stringstream dummy_valid;
valid_val = UPPL_NO_VAL_STRUCT;
prev_db_val = 0;
// valid
- PhyUtil::FillDbSchema(PORT_VALID, valid.str(),
+ PhyUtil::FillDbSchema(unc::uppl::PORT_VALID, valid.str(),
valid.str().length(), DATATYPE_UINT8_ARRAY_11,
vect_table_attr_schema);
return;
}
+
+/**
+ * @Description : This function performs oper status handling for sub domain
+ * @param[in] : data_type - indicates the data base type
+ * controller_name, switch_name and physical_port id
+ * @return : UPPL_RC_SUCCESS
+ **/
+UpplReturnCode Kt_Port::SubDomainOperStatusHandling(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ string controller_name,
+ string switch_id,
+ string physical_port_id) {
+ PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
+ DBTableSchema kt_logicalport_dbtableschema;
+ vector<string> vect_prim_keys;
+ vector<TableAttrSchema> vect_table_attr_schema;
+ list< vector<TableAttrSchema> > row_list;
+ vect_prim_keys.push_back(CTR_NAME_STR);
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
+ controller_name.length(), DATATYPE_UINT8_ARRAY_32,
+ vect_table_attr_schema);
+ vect_prim_keys.push_back(LP_SWITCH_ID_STR);
+ PhyUtil::FillDbSchema(unc::uppl::LMP_SWITCH_ID, switch_id,
+ switch_id.length(), DATATYPE_UINT8_ARRAY_256,
+ vect_table_attr_schema);
+ vect_prim_keys.push_back(LMP_PHYSICAL_PORT_ID_STR);
+ PhyUtil::FillDbSchema(unc::uppl::LMP_PHYSICAL_PORT_ID, physical_port_id,
+ physical_port_id.length(), DATATYPE_UINT8_ARRAY_32,
+ vect_table_attr_schema);
+ string log_port_id = "";
+ vect_prim_keys.push_back(LMP_LP_PORT_ID_STR);
+ PhyUtil::FillDbSchema(unc::uppl::LMP_LP_PORT_ID, log_port_id,
+ log_port_id.length(), DATATYPE_UINT8_ARRAY_320,
+ vect_table_attr_schema);
+ string domain_name = "";
+ PhyUtil::FillDbSchema(unc::uppl::DOMAIN_NAME, domain_name,
+ domain_name.length(), DATATYPE_UINT8_ARRAY_32,
+ vect_table_attr_schema);
+ kt_logicalport_dbtableschema.set_table_name(
+ unc::uppl::LOGICAL_MEMBERPORT_TABLE);
+ kt_logicalport_dbtableschema.set_primary_keys(vect_prim_keys);
+
+ row_list.push_back(vect_table_attr_schema);
+ kt_logicalport_dbtableschema.set_row_list(row_list);
+
+ ODBCM_RC_STATUS db_status = physical_layer->get_odbc_manager()->
+ GetBulkRows((unc_keytype_datatype_t)data_type, UPPL_MAX_REP_CT,
+ kt_logicalport_dbtableschema,
+ (unc_keytype_operation_t)UNC_OP_READ_SIBLING_BEGIN,
+ db_conn);
+ if (db_status != ODBCM_RC_SUCCESS) {
+ pfc_log_debug("No associated logical member port");
+ return UPPL_RC_SUCCESS;
+ }
+ // To traverse the list
+ list<vector<TableAttrSchema> > ::iterator iter_list;
+ for (iter_list = kt_logicalport_dbtableschema.row_list_.begin();
+ iter_list != kt_logicalport_dbtableschema.row_list_.end();
+ ++iter_list) {
+ vector<TableAttrSchema> &attributes_vector = *iter_list;
+ vector<TableAttrSchema> :: iterator iter_vector;
+ for (iter_vector = attributes_vector.begin();
+ iter_vector != attributes_vector.end();
+ ++iter_vector) {
+ /* Get attribute name of a row */
+ TableAttrSchema tab_att_schema = (*iter_vector);
+ switch (tab_att_schema.table_attribute_name) {
+ case unc::uppl::LMP_LP_PORT_ID:
+ uint8_t lp_id[ODBCM_SIZE_320];
+ PhyUtil::GetValueFromDbSchemaStr(tab_att_schema, lp_id,
+ DATATYPE_UINT8_ARRAY_320);
+ log_port_id = reinterpret_cast<const char*> (lp_id);
+ break;
+ case unc::uppl::DOMAIN_NAME:
+ uint8_t lp_domain_name[ODBCM_SIZE_32];
+ PhyUtil::GetValueFromDbSchemaStr(tab_att_schema, lp_domain_name,
+ DATATYPE_UINT8_ARRAY_32);
+ domain_name = reinterpret_cast<const char*> (lp_domain_name);
+ break;
+ default:
+ break;
+ }
+ }
+ // Call LogicalPort Handle Oper status
+ // Notify Kt_Logical_Port
+ key_logical_port_t logical_port_key;
+ memset(&logical_port_key, 0, sizeof(key_logical_port_t));
+ memcpy(logical_port_key.domain_key.ctr_key.controller_name,
+ controller_name.c_str(),
+ controller_name.length()+1);
+ memcpy(logical_port_key.domain_key.domain_name,
+ domain_name.c_str(),
+ domain_name.length()+1);
+ memcpy(logical_port_key.port_id,
+ log_port_id.c_str(),
+ log_port_id.length()+1);
+ vector<OperStatusHolder> ref_oper_status;
+ GET_ADD_CTRL_OPER_STATUS(controller_name);
+ Kt_LogicalPort log_port_obj;
+ UpplReturnCode return_code = log_port_obj.HandleOperStatus(
+ db_conn, data_type, reinterpret_cast<void *> (&logical_port_key),
+ NULL, ref_oper_status, UNC_KT_PORT);
+ pfc_log_debug("HandleOperStatus for logical port class %d",
+ return_code);
+ ClearOperStatusHolder(ref_oper_status);
+ }
+ return UPPL_RC_SUCCESS;
+}
/** Constructor
- * * @Description : This function instantiates parent key type for
+ * @Description : This function instantiates child key instances for
* kt_Root
- * * * @param[in] : None
- * * * @return : None
+ * @param[in] : None
+ * @return : None
* */
Kt_Root::Kt_Root() {
- parent = NULL;
for (int i = 0; i < KT_ROOT_CHILD_COUNT; ++i) {
child[i] = NULL;
}
/** Destructor
- * * @Description : This function clears the parent and child key types
- * instances for Kt_Root
- * * * @param[in] : None
- * * * @return : None
+ * @Description : This function frees the child key instances
+ * for Kt_Root
+ * @param[in] : None
+ * @return : None
* */
Kt_Root::~Kt_Root() {
- if (parent != NULL) {
- delete parent;
- parent = NULL;
- }
for (int i = 0; i < KT_ROOT_CHILD_COUNT; ++i) {
if (child[i] != NULL) {
delete child[i];
}
/** GetChildClassPointer
- *@Description : This function creates the instances of child classes of KtRoot.
- *@param[in] : KtRootChildClass
- *@return : Kt_Base*
+ * @Description : This function creates the instances of child classes of KtRoot
+ * @param[in] : KIndex-any value of KtRootChildClass
+ * @return : Kt_Base*
** */
Kt_Base* Kt_Root::GetChildClassPointer(KtRootChildClass KIndex) {
switch (KIndex) {
/** Create
- * * @Description : This function is not supported on KT_ROOT
- * * * @param[in] : key_struct, value_struct, ipc session id, configuration id,
- * data_type, option1 and option2
- * * * @return : UPPL_RC_ERR_OPERATION_NOT_ALLOWED
+ * @Description : This function is not supported on KT_ROOT
+ * @param[in] : key_struct-void * to kt key structure
+ * value_struct-void* to kt value structure
+ * session_id -ipc session id used for TC validation
+ * configuration_id-ipc configuration id used for TC validation
+ * data_type-UNC_DT_*,type of database
+ * sess-ServerSession object where the request argument present
+ * @return : UPPL_RC_ERR_OPERATION_NOT_ALLOWED
* */
-UpplReturnCode Kt_Root::Create(uint32_t session_id,
+UpplReturnCode Kt_Root::Create(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
/** Update
- * * @Description : This function is not supported on KT_ROOT
- * * * @param[in] : key_struct, value_struct, ipc session id, configuration id,
- * data_type, option1 and option2
- * * * @return : UPPL_RC_ERR_OPERATION_NOT_ALLOWED
+ * @Description : This function is not supported on KT_ROOT
+ * @param[in] : key_struct-void* to ket key structure
+ * value_struct-void* to kt value structure
+ * session_id-ipc session id used for TC validation
+ * configuration_id-ipc configuration id used for TC validation
+ * data_type-UNC_DT_*,type of database
+ * sess-ServerSession object where the request argument present
+ * @return : UPPL_RC_ERR_OPERATION_NOT_ALLOWED
* */
-UpplReturnCode Kt_Root::Update(uint32_t session_id,
+UpplReturnCode Kt_Root::Update(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
/** Delete
- * * @Description : This function is not supported on KT_ROOT
- * * * @param[in] : key_struct, value_struct, ipc session id, configuration id,
- * data_type, option1 and option2
- * * * @return : UPPL_RC_ERR_OPERATION_NOT_ALLOWED
+ * @Description : This function is not supported on KT_ROOT
+ * @param[in] : key_struct-void* to ket key structure
+ * value_struct-void* to kt value structure
+ * session_id-ipc session id used for TC validation
+ * configuration_id-ipc configuration id used for TC validation
+ * data_type-UNC_DT_*,type of database
+ * sess-ServerSession object where the request argument present
+ * @return : UPPL_RC_ERR_OPERATION_NOT_ALLOWED
* */
-UpplReturnCode Kt_Root::Delete(uint32_t session_id,
+UpplReturnCode Kt_Root::Delete(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
uint32_t data_type,
}
/**ReadBulk
- * * @Description : This function reads a bulk rows of KT_Controller in
+ * @Description : This function reads a bulk rows of KT_Controller in
* Controller table of specified data type.
* Order of ReadBulk response
* val_ctr -> val_ctr_domain -> val_logical_port ->
* val_logical_member_port -> val_switch -> val_port ->
* val_link -> val_boundary
- * * @param[in] :
+ * @param[in] :
* key_struct - no key for the kt Root instance
* data_type - UNC_DT_* , read allowed in candidate/running/startup/state
- * option1/option2 - specifies any additional condition for read operation
- * * @return : UPPL_RC_SUCCESS is returned when the response
+ * max_rep_ct-maximum repetition count
+ * child_index-index indicating children of KtController
+ * bool parent_call-flag to indicate whether function called by parent
+ * bool is_read_next-flag to indicate whether requested operation is
+ * UNC_OP_READ_NEXT
+ * @return : UPPL_RC_SUCCESS is returned when the response
* is added to ipc session successfully.
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-
-UpplReturnCode Kt_Root::ReadBulk(void* key_struct,
+UpplReturnCode Kt_Root::ReadBulk(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
- uint32_t option1,
- uint32_t option2,
uint32_t &max_rep_ct,
int child_index,
pfc_bool_t parent_call,
- pfc_bool_t is_read_next) {
+ pfc_bool_t is_read_next,
+ ReadRequest *read_req) {
pfc_log_debug("Inside ReadBulk of Kt_ROOT");
UpplReturnCode read_status = UPPL_RC_SUCCESS;
if (max_rep_ct == 0) {
FreeKeyStruct(child_key_struct, kIdx);
continue;
}
- read_status = child[kIdx]->ReadBulk(child_key_struct,
+ read_status = child[kIdx]->ReadBulk(db_conn, child_key_struct,
data_type,
- option1,
- option2,
max_rep_ct,
-1,
true,
- is_read_next);
+ is_read_next,
+ read_req);
pfc_log_debug(
"KT_ROOT - read status from child %d is %d",
kIdx, read_status);
}
/** getChildKeyStruct
- * * @Description : This function returns the void * of child key structures
- * * * @param[in] : child class index
- * * * @return : void * key structure
+ * @Description : This function returns the void * of child key structures
+ * @param[in] : child_class-index indicating children of Controller
+ * @return : void * key structure
* */
void* Kt_Root::getChildKeyStruct(uint32_t child_class) {
}
/** FreeKeyStruct
- * * @Description : This function clears the void * of child key structures
- * * * @param[in] : child class index
- * * * @return : void * key structure
+ * @Description : This function clears the void * of child key structures
+ * @param[in] : child_class index indicating the children of KtController
+ * key_struct-void* to any child's key structure
+ * @return : void
* */
void Kt_Root::FreeKeyStruct(void *key_struct,
#include "itc_kt_state_base.hh"
#include "physicallayer.hh"
#include "itc_kt_logicalport.hh"
+#include "itc_kt_port.hh"
+#include "itc_kt_switch.hh"
+#include "itc_kt_link.hh"
+#include "itc_kt_controller.hh"
using unc::uppl::PhysicalLayer;
/** Constructor
- * * @Description : This function instantiates parent and child key types for
- * kt
- * * * @param[in] : None
- * * * @return : None
+ * @Description : Empty Constructor
+ * @param[in] : None
+ * @return : None
* */
Kt_State_Base::Kt_State_Base() {
}
/** Create
- * * @Description : This function returns error when CREATE request is sent for State
- * Objects from north bound
- * * @param[in] : session_id - ipc session id used for TC validation
+ * @Description : This function returns error when CREATE request is sent
+ * for State Objects from north bound
+ * @param[in] : session_id - ipc session id used for TC validation
* configuration_id - configuration id used for TC validation
* key_struct - the key for the new kt instance
* value_struct - the values for the new kt instance
* data_type - UNC_DT_* , Create only allowed in running/state/import
+ * key_type-UNC_KT_*,any value of unc_key_type_t
* sess - ipc server session where the response has to be added
- * * @return : UPPL_RC_ERR_* is returned.
+ * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR_* is returned.
* */
-UpplReturnCode Kt_State_Base::Create(uint32_t session_id,
+UpplReturnCode Kt_State_Base::Create(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
}
/** CreateKeyInstance
- * * @Description : This function creates a new row of KT in
+ * @Description : This function creates a new row of KT in
* candidate table.
- * key_struct - the key for the new kt instance
+ * @param[in]:key_struct - the key for the new kt instance
* value_struct - the values for the new kt instance
* data_type - UNC_DT_* , Create only allowed in running/state/import
- * * @return : UPPL_RC_SUCCESS is returned when the create is success
+ * key_type-UNC_KT_*,any value of unc_key_type_t
+ * @return : UPPL_RC_SUCCESS is returned when the create is success
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_State_Base::CreateKeyInstance(void* key_struct,
+UpplReturnCode Kt_State_Base::CreateKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t key_type) {
void* old_value_struct;
vector<ODBCMOperator> vect_key_operations;
// Create DBSchema structure for kt_table
- PopulateDBSchemaForKtTable(kt_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_dbtableschema,
key_struct,
val_struct,
- UNC_OP_CREATE, 0, 0,
+ UNC_OP_CREATE, data_type, 0, 0,
vect_key_operations, old_value_struct);
// Send request to ODBC for kt_table create
ODBCM_RC_STATUS create_db_status = physical_layer->get_odbc_manager()->
- CreateOneRow((unc_keytype_datatype_t)data_type, kt_dbtableschema);
-
- pfc_log_info("Response from DB: %d", create_db_status);
-
+ CreateOneRow((unc_keytype_datatype_t)data_type,
+ kt_dbtableschema, db_conn);
if (create_db_status != ODBCM_RC_SUCCESS) {
if (create_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log fatal error to log daemon
}
/** Update
- * * @Description : This function updates a row of KT in
+ * @Description : This function updates a row of KT in
* candidate table.
- * * @param[in] : session_id - ipc session id used for TC validation
+ * @param[in] : session_id - ipc session id used for TC validation
* configuration_id - configuration id used for TC validation
* key_struct - the key for the kt instance
* value_struct - the values for the kt instance
* data_type - UNC_DT_* , Update only allowed in running/state/import
+ * key_type-UNC_KT_*,any value of unc_key_type_t
* sess - ipc server session where the response has to be added
- * * @return : UPPL_RC_SUCCESS is returned when the response
+ * @return : UPPL_RC_SUCCESS is returned when the response
* is added to ipc session successfully.
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_State_Base::Update(uint32_t session_id,
+UpplReturnCode Kt_State_Base::Update(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
}
/** UpdateKeyInstance
- * * @Description : This function updates a row of KT in
+ * @Description : This function updates a row of KT in
* candidate table.
- * * @param[in] :
+ * @param[in] :
* key_struct - the key for the new kt instance
* value_struct - the values for the new kt instance
* data_type - UNC_DT_* , update only allowed in running/state/import
- * * @return : UPPL_RC_SUCCESS is returned when the update
+ * key_type-UNC_KT_*,any value of unc_key_type_t
+ * old_val_struct-void * to switch value structure
+ * @return : UPPL_RC_SUCCESS is returned when the update
* is done successfully.
* UPPL_RC_ERR_* is returned when the update is error
* */
-UpplReturnCode Kt_State_Base::UpdateKeyInstance(void* key_struct,
+UpplReturnCode Kt_State_Base::UpdateKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
void* val_struct,
uint32_t data_type,
uint32_t key_type,
void* &old_val_struct) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode update_status = UPPL_RC_SUCCESS;
- if (key_type == UNC_KT_LOGICAL_PORT ||
- key_type == UNC_KT_LOGICAL_MEMBER_PORT) {
- pfc_log_error("Update operation is provided on unsupported key type %d",
- key_type);
- update_status = UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
- return update_status;
- }
// Check whether operation is allowed on the given DT type
if (((unc_keytype_datatype_t)data_type != UNC_DT_STATE) &&
((unc_keytype_datatype_t)data_type != UNC_DT_IMPORT)) {
update_status = UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
return update_status;
}
-
+ pfc_bool_t is_state = PFC_FALSE;
+ if (key_type == UNC_KT_CTR_DOMAIN) {
+ is_state = PFC_TRUE;
+ }
// Structure used to send request to ODBC
DBTableSchema kt_dbtableschema;
vector<ODBCMOperator> vect_key_operations;
// Create DBSchema structure for table
- PopulateDBSchemaForKtTable(kt_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_dbtableschema,
key_struct,
val_struct,
- UNC_OP_UPDATE, 0, 0,
- vect_key_operations, old_val_struct);
+ UNC_OP_UPDATE, data_type, 0, 0,
+ vect_key_operations, old_val_struct,
+ NOTAPPLIED, false, is_state);
if (!((kt_dbtableschema.get_row_list()).empty())) {
// Send request to ODBC for kt_table update
ODBCM_RC_STATUS update_db_status = physical_layer->get_odbc_manager()-> \
UpdateOneRow((unc_keytype_datatype_t)data_type,
- kt_dbtableschema);
- pfc_log_info("UpdateOneRow response from DB is %d", update_db_status);
+ kt_dbtableschema, db_conn);
if (update_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log fatal error to log daemon
pfc_log_fatal("DB connection not available or cannot access DB");
}
/**Delete
- * * @Description : This function deletes a row of KT in
+ * @Description : This function deletes a row of KT in
* candidate table.
- * * @param[in] : session_id - ipc session id used for TC validation
+ * @param[in] : session_id - ipc session id used for TC validation
* configuration_id - configuration id used for TC validation
* key_struct - the key for the kt instance
- * data_type - UNC_DT_* , delete only allowed in running/state/import
+ * data_type - UNC_DT_* , delete only allowed in running/state/import,
+ * key_type-UNC_KT_*,any value of unc_key_type_t
* sess - ipc server session where the response has to be added
- * * @return : UPPL_RC_SUCCESS is returned when the response
+ * @return : UPPL_RC_SUCCESS is returned when the response
* is added to ipc session successfully.
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_State_Base::Delete(uint32_t session_id,
+UpplReturnCode Kt_State_Base::Delete(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
uint32_t data_type,
}
/** HandleDriverEvents
- * * @Description : This function processes the notification received from
+ * @Description : This function processes the notification received from
* driver
- * * * @param[in] : key_struct - specifies the key instance of KT
+ * @param[in] : key_struct - specifies the key instance of KT
* old_value_struct - old value of KT
* new_value_struct - new value of KT
- * * * @return : UPPL_RC_SUCCESS if events are handled successfully or
+ * oper_type-UNC_OP_*,type of operation
+ * data_type-UNC_DT_*,type of database
+ * key_type-UNC_KT_*,any value of unc_key_type_t
+ * @return : UPPL_RC_SUCCESS if events are handled successfully or
* UPPL_RC_ERR*
* */
-UpplReturnCode Kt_State_Base::HandleDriverEvents(void* key_struct,
- uint32_t oper_type,
- uint32_t data_type,
- uint32_t key_type,
- void* old_val_struct,
- void* new_val_struct) {
+UpplReturnCode Kt_State_Base::HandleDriverEvents(
+ OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ uint32_t oper_type,
+ uint32_t data_type,
+ uint32_t key_type,
+ void* old_val_struct,
+ void* new_val_struct) {
UpplReturnCode status = UPPL_RC_SUCCESS;
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
- string controller_name;
- string event_details; // for sending event handling alarm
+ string controller_name = "";
+ string event_details = ""; // for sending event handling alarm
// Validate the given request
switch (key_type) {
case UNC_KT_CTR_DOMAIN: {
}
unc_keytype_ctrtype_t controller_type;
UpplReturnCode retcode = PhyUtil::get_controller_type(
- controller_name, controller_type,
+ db_conn, controller_name, controller_type,
(unc_keytype_datatype_t)parent_data_type);
// Check whether operation is allowed on the given DT type
if (retcode != UPPL_RC_SUCCESS) {
pfc_log_error("Unknown domain cannot be operated from driver");
return UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
}
- event_details = "KT_CONTROLLER";
+ event_details = "KT_CTR_DOMAIN";
break;
}
case UNC_KT_LOGICAL_PORT: {
break;
}
}
- status = ValidateRequest(key_struct, new_val_struct,
+ status = ValidateRequest(db_conn, key_struct, new_val_struct,
oper_type, data_type, key_type);
if (status != UPPL_RC_SUCCESS) {
- pfc_log_error(
- "HandleDriverEvents failed with %d "
+ pfc_log_info(
+ "HandleDriverEvents validation failed with %d "
"for operation %d with data type %d", status, oper_type, data_type);
- UpplReturnCode alarm_status = physical_layer->get_physical_core()->
- RaiseEventHandlingAlarm(controller_name);
- if (alarm_status == UPPL_RC_SUCCESS) {
- alarm_status = physical_layer->get_physical_core()->
- SendEventHandlingFailureAlarm(controller_name,
- event_details);
- pfc_log_debug("Failure alarm sent to nodemanager - status %d",
- alarm_status);
+ if ((oper_type == UNC_OP_CREATE && status != UPPL_RC_ERR_INSTANCE_EXISTS) ||
+ ((oper_type == UNC_OP_UPDATE || oper_type == UNC_OP_DELETE) &&
+ status != UPPL_RC_ERR_NO_SUCH_INSTANCE)) {
+ // Raise validation failure alarm
+ UpplReturnCode alarm_status = physical_layer->get_physical_core()->
+ RaiseEventHandlingAlarm(controller_name);
+ if (alarm_status == UPPL_RC_SUCCESS) {
+ alarm_status = physical_layer->get_physical_core()->
+ SendEventHandlingFailureAlarm(controller_name,
+ event_details);
+ pfc_log_info("Event Handling Validation Failure alarm sent - status %d",
+ alarm_status);
+ }
}
return status;
}
// Call CreateKeyInstance, UpdateKeyInstance and DeleteKeyInstance based
// on operation type
// Create the kt instance in DB
- void* old_value_struct;
+ void* old_value_struct = NULL;
if (oper_type == UNC_OP_CREATE) {
- pfc_log_info("Call CreateKeyInstance to create kt in DB");
- status = CreateKeyInstance(key_struct, new_val_struct,
+ pfc_log_debug("Call CreateKeyInstance to create kt in DB");
+ status = CreateKeyInstance(db_conn, key_struct, new_val_struct,
data_type, key_type);
- pfc_log_info("CreateKeyInstance status: %d" , status);
} else if (oper_type == UNC_OP_UPDATE) {
+ if (key_type == UNC_KT_LOGICAL_PORT ||
+ key_type == UNC_KT_LOGICAL_MEMBER_PORT) {
+ pfc_log_error("Update operation is provided on unsupported key type %d",
+ key_type);
+ status = UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
+ return status;
+ }
// Call UpdateKeyInstance to update kt value in DB
- pfc_log_info("Call UpdateKeyInstance to update kt in DB");
- status = UpdateKeyInstance(key_struct, new_val_struct,
+ pfc_log_debug("Call UpdateKeyInstance to update kt in DB");
+ status = UpdateKeyInstance(db_conn, key_struct, new_val_struct,
data_type, key_type,
old_value_struct);
- pfc_log_info("UpdateKeyInstance status: %d" , status);
} else if (oper_type == UNC_OP_DELETE) {
// Call DeleteKeyInstance to Delete kt from DB
- pfc_log_info("Call DeleteKeyInstance to delete kt in DB");
- status = DeleteKeyInstance(key_struct, data_type, key_type);
- pfc_log_info("DeleteKeyInstance status: %d" , status);
+ pfc_log_debug("Call DeleteKeyInstance to delete kt in DB");
+ status = DeleteKeyInstance(db_conn, key_struct, data_type, key_type);
}
- // logical port oper status handling
- if (key_type == UNC_KT_LOGICAL_MEMBER_PORT &&
- (oper_type == UNC_OP_CREATE || oper_type == UNC_OP_DELETE) &&
- status == UPPL_RC_SUCCESS) {
- key_logical_member_port_t *obj_key =
- reinterpret_cast<key_logical_member_port_t*>(key_struct);
- string domain_name = reinterpret_cast<const char*>(
- obj_key->logical_port_key.domain_key.domain_name);
- string port_id = reinterpret_cast<const char*>(obj_key
- ->logical_port_key.port_id);
-
- key_logical_port logical_port_key;
- memcpy(logical_port_key.domain_key.ctr_key.controller_name,
- controller_name.c_str(),
- controller_name.length()+1);
- memcpy(logical_port_key.domain_key.domain_name,
- domain_name.c_str(),
- domain_name.length()+1);
- memcpy(logical_port_key.port_id,
- port_id.c_str(),
- port_id.length()+1);
-
- Kt_LogicalPort logical_port;
- UpplReturnCode return_code = logical_port.HandleOperStatus(
- data_type, reinterpret_cast<void *> (&logical_port_key),
- NULL);
- pfc_log_info("HandleOperStatus for logical_port class %d",
- return_code);
- }
-
if (status != UPPL_RC_SUCCESS) {
UpplReturnCode alarm_status = physical_layer->get_physical_core()->
RaiseEventHandlingAlarm(controller_name);
alarm_status = physical_layer->get_physical_core()->
SendEventHandlingFailureAlarm(controller_name,
event_details);
- pfc_log_debug("Failure alarm sent to node manager - status %d",
- alarm_status);
+ pfc_log_info("Failure alarm sent to node manager - status %d",
+ alarm_status);
}
} else {
UpplReturnCode alarm_status = physical_layer->get_physical_core()->
alarm_status = physical_layer->get_physical_core()->
SendEventHandlingSuccessAlarm(controller_name,
event_details);
- pfc_log_debug("Success alarm sent to node manager - status %d",
- alarm_status);
+ pfc_log_info("Success alarm sent to node manager - status %d",
+ alarm_status);
}
if (data_type != UNC_DT_IMPORT) {
pfc_ipcevtype_t event_type = GetEventType(key_type);
->get_ipc_connection_manager()->SendEvent(&ser_evt);
}
}
- // Old value structure memory clean up
- if (oper_type == UNC_OP_UPDATE) {
+ // Perform for oper_status handling
+ UpplReturnCode oper_status_handle = HandleOperStatus(db_conn, key_struct,
+ oper_type,
+ data_type,
+ key_type,
+ new_val_struct,
+ controller_name);
+ pfc_log_debug("Oper Status Handling Status %d", oper_status_handle);
+ }
+ // Old value structure memory clean up
+ if (oper_type == UNC_OP_UPDATE) {
+ if(old_value_struct != NULL) {
ClearValueStructure(key_type,
old_value_struct);
+ old_value_struct = NULL;
}
}
return status;
}
+
+/** HandleOperStatus
+ * @Description : This function calls oper status handling of associated
+ * key types
+ * @param[in] : key_struct - specifies the key instance of KT
+ * new_value_struct - new value of KT
+ * oper_type-UNC_OP_*,type of operation
+ * data_type-UNC_DT_*,type of database
+ * key_type-UNC_KT_*,any value of unc_key_type_t
+ * controller_name-controller id
+ * @return : UPPL_RC_SUCCESS if oper status changes are handled
+ * successfully or UPPL_RC_ERR*
+ * */
+UpplReturnCode Kt_State_Base::HandleOperStatus(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ uint32_t oper_type,
+ uint32_t data_type,
+ uint32_t key_type,
+ void* new_val_struct,
+ string controller_name) {
+ UpplReturnCode oper_return = UPPL_RC_SUCCESS;
+ // logical port oper status handling
+ if (key_type == UNC_KT_LOGICAL_MEMBER_PORT &&
+ (oper_type == UNC_OP_CREATE || oper_type == UNC_OP_DELETE)) {
+ key_logical_member_port_t *obj_key =
+ reinterpret_cast<key_logical_member_port_t*>(key_struct);
+ string domain_name = reinterpret_cast<const char*>(
+ obj_key->logical_port_key.domain_key.domain_name);
+ string port_id = reinterpret_cast<const char*>(obj_key
+ ->logical_port_key.port_id);
+
+ key_logical_port logical_port_key;
+ memset(&logical_port_key, '\0', sizeof(key_logical_port));
+ memcpy(logical_port_key.domain_key.ctr_key.controller_name,
+ controller_name.c_str(),
+ controller_name.length()+1);
+ memcpy(logical_port_key.domain_key.domain_name,
+ domain_name.c_str(),
+ domain_name.length()+1);
+ memcpy(logical_port_key.port_id,
+ port_id.c_str(),
+ port_id.length()+1);
+ vector<OperStatusHolder> ref_oper_status;
+ GET_ADD_CTRL_OPER_STATUS(controller_name);
+ Kt_LogicalPort logical_port;
+ oper_return = logical_port.HandleOperStatus(
+ db_conn,
+ data_type,
+ reinterpret_cast<void *> (&logical_port_key),
+ NULL,
+ ref_oper_status, UNC_KT_LOGICAL_MEMBER_PORT);
+ pfc_log_debug("HandleOperStatus for logical_port class %d",
+ oper_return);
+ ClearOperStatusHolder(ref_oper_status);
+ } else if (key_type == UNC_KT_PORT && oper_type == UNC_OP_UPDATE) {
+ // Port oper status changes
+ Kt_Port kt_port;
+ val_port_st_t port_st = *(reinterpret_cast<val_port_st_t*>(new_val_struct));
+ unsigned int valid_val =
+ PhyUtil::uint8touint(port_st.valid[kIdxPortOperStatus]);
+ if (valid_val == UNC_VF_VALID) {
+ key_port_t port_key = *(reinterpret_cast<key_port_t*>(key_struct));
+ vector<OperStatusHolder> ref_oper_status;
+ GET_ADD_CTRL_OPER_STATUS(controller_name);
+ // Get Switch oper status
+ key_switch_t switch_key;
+ Kt_Switch kt_switch;
+ memcpy(switch_key.ctr_key.controller_name, controller_name.c_str(),
+ (controller_name.length())+1);
+ memcpy(switch_key.switch_id, port_key.sw_key.switch_id,
+ sizeof(port_key.sw_key.switch_id));
+ uint8_t switch_oper_status = 0;
+ read_status = kt_switch.GetOperStatus(
+ db_conn, data_type,
+ reinterpret_cast<void*>(&switch_key), switch_oper_status);
+ pfc_log_debug("Switch read_status %d, oper_status %d",
+ read_status, switch_oper_status);
+ ADD_SWITCH_OPER_STATUS(switch_key, switch_oper_status);
+ // Get port oper status
+ uint8_t port_oper_status = 0;
+ read_status = kt_port.GetOperStatus(
+ db_conn, data_type,
+ key_struct, port_oper_status);
+ pfc_log_debug("Port read_status %d, oper_status %d",
+ read_status, port_oper_status);
+ ADD_PORT_OPER_STATUS(
+ port_key, port_oper_status);
+ oper_return = kt_port.NotifyOperStatus(db_conn, data_type,
+ key_struct,
+ new_val_struct,
+ ref_oper_status);
+ pfc_log_debug("Port notify oper status return %d", oper_return);
+ ClearOperStatusHolder(ref_oper_status);
+ }
+ } else if (key_type == UNC_KT_SWITCH && oper_type == UNC_OP_UPDATE) {
+ // Switch oper status changes
+ Kt_Switch kt_switch;
+ val_switch_st_t switch_st =
+ *(reinterpret_cast<val_switch_st_t*>(new_val_struct));
+ unsigned int valid_val =
+ PhyUtil::uint8touint(switch_st.valid[kIdxSwitchOperStatus]);
+ if (valid_val == UNC_VF_VALID) {
+ key_switch_t switch_key =
+ *(reinterpret_cast<key_switch_t*>(key_struct));
+ vector<OperStatusHolder> ref_oper_status;
+ GET_ADD_CTRL_OPER_STATUS(controller_name);
+ // Get Switch oper status
+ uint8_t switch_oper_status = 0;
+ read_status = kt_switch.GetOperStatus(
+ db_conn, data_type,
+ key_struct, switch_oper_status);
+ pfc_log_debug("Switch read_status %d, oper_status %d",
+ read_status, switch_oper_status);
+ ADD_SWITCH_OPER_STATUS(switch_key,
+ switch_oper_status);
+ oper_return = kt_switch.NotifyOperStatus(db_conn, data_type,
+ key_struct,
+ new_val_struct,
+ ref_oper_status);
+ pfc_log_debug("Switch notify oper status return %d", oper_return);
+ ClearOperStatusHolder(ref_oper_status);
+ }
+ } else if (key_type == UNC_KT_LINK && oper_type == UNC_OP_UPDATE) {
+ // Link oper status changes
+ Kt_Link kt_link;
+ val_link_st_t link_st =
+ *(reinterpret_cast<val_link_st_t*>(new_val_struct));
+ unsigned int valid_val =
+ PhyUtil::uint8touint(link_st.valid[kIdxLinkStOperStatus]);
+ if (valid_val == UNC_VF_VALID) {
+ oper_return = kt_link.NotifyOperStatus(db_conn, data_type,
+ key_struct,
+ new_val_struct);
+ pfc_log_debug("Link notify oper status return %d", oper_return);
+ }
+ }
+ return oper_return;
+}
#include "itc_kt_port.hh"
#include "itc_kt_link.hh"
#include "odbcm_utils.hh"
+#include "itc_read_request.hh"
+#include "odbcm_db_varbind.hh"
using unc::uppl::PhysicalLayer;
using unc::uppl::ODBCMUtils;
/** Constructor
- * * @Description : This function instantiates parent and child key types for
+ * @Description : This function instantiates child key instances for
* kt_switch
- * * * @param[in] : None
- * * * @return : None
+ * @param[in] : None
+ * @return : None
* */
Kt_Switch::Kt_Switch() {
- parent = NULL;
for (int i = 0; i < KT_SWITCH_CHILD_COUNT; ++i) {
child[i] = NULL;
}
- // Populate Structure to be used for syntax validation
- Fill_Attr_Syntax_Map();
+ if (attr_syntax_map_all.find(UNC_KT_SWITCH) ==
+ attr_syntax_map_all.end()) {
+ // Populate Structure to be used for syntax validation
+ Fill_Attr_Syntax_Map();
+ }
}
/** Destructor
- * * @Description : This function clears the parent and child key types for
+ * @Description : This function frees the child key
* instances for kt_switch
- * * * @param[in] : None
- * * * @return : None
+ * @param[in] : None
+ * @return : None
* */
Kt_Switch::~Kt_Switch() {
- // Delete parent object
- if (parent != NULL) {
- delete parent;
- parent = NULL;
- }
// Delete all child objects
for (int i = 0; i < KT_SWITCH_CHILD_COUNT; ++i) {
if (child[i] != NULL) {
}
/** GetChildClassPointer
- * * @Description : This function creates a new child class instance
+ * @Description : This function creates a new child class instance
* of KtSwitch based on index passed.
- * * @param[in] : KtSwitchChildClass - Child class index enum
- * * @return : Kt_Base* - child class pointer
+ * @param[in] : KIndex-any value of KtSwitchChildClass,Child class index enum
+ * @return : Kt_Base* - child class pointer
* */
Kt_Base* Kt_Switch::GetChildClassPointer(KtSwitchChildClass KIndex) {
switch (KIndex) {
}
/** DeleteKeyInstance
- * * @Description : This function deletes the given instance of KT_Switch
- * * @param[in] : key_struct - key for the switch instance
+ * @Description : This function deletes the given instance of KT_Switch
+ * using key_switch given in the instance
+ * @param[in] : key_struct - key for the switch instance
* data_type - UNC_DT_* , delete only allowed in STATE
- * * @return : UPPL_RC_SUCCESS is returned when the delete
+ * key_type-UNC_KT_SWITCH,value of unc_key_type_t
+ * @return : UPPL_RC_SUCCESS is returned when the delete
* is done successfully.
- * * UPPL_RC_ERR_* is returned when the delete is error
+ * UPPL_RC_ERR_* is returned when the delete is error
* */
-UpplReturnCode Kt_Switch::DeleteKeyInstance(void* key_struct,
+UpplReturnCode Kt_Switch::DeleteKeyInstance(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
uint32_t key_type) {
UpplReturnCode delete_status = UPPL_RC_SUCCESS;
vector<key_switch_t> vect_switch_id;
if (switch_id.length() == 0) {
- delete_status = ReadBulkInternal(key_struct, NULL,
+ delete_status = ReadBulkInternal(db_conn, key_struct, NULL,
data_type, UPPL_MAX_REP_CT,
vect_val_switch, vect_switch_id);
} else {
FreeChildKeyStruct(child_class, child_key_struct);
continue;
}
- delete_status = child[child_class]->DeleteKeyInstance(child_key_struct,
+ delete_status = child[child_class]->DeleteKeyInstance(db_conn,
+ child_key_struct,
data_type,
UNC_KT_PORT);
delete child[child_class];
key_logical_port_t logical_port_key_obj;
val_logical_port_st_t logical_port_val_obj;
- memset(logical_port_key_obj.domain_key.domain_name, '\0',
- sizeof(logical_port_key_obj.domain_key.domain_name));
-
- memset(logical_port_key_obj.port_id, 0,
- sizeof(logical_port_key_obj.port_id));
+ memset(&logical_port_key_obj, '\0',
+ sizeof(logical_port_key_obj));
+ memset(&logical_port_val_obj, '\0',
+ sizeof(val_logical_port_st_t));
memset(logical_port_val_obj.logical_port.valid, UNC_VF_INVALID,
sizeof(logical_port_val_obj.logical_port.valid));
key_val.push_back(reinterpret_cast<void *>(&logical_port_key_obj));
val_struct.push_back(reinterpret_cast<void *>(&logical_port_val_obj));
UpplReturnCode lp_read_status = logical_port_obj.ReadInternal(
- key_val, val_struct, UNC_DT_STATE, UNC_OP_READ);
+ db_conn, key_val, val_struct, data_type, UNC_OP_READ);
if (lp_read_status == UPPL_RC_SUCCESS) {
// form key struct with all required primary keys and call delete
logical_port_obj.DeleteKeyInstance(
- key_val[0],
- UNC_DT_STATE,
+ db_conn, key_val[0],
+ data_type,
UNC_KT_LOGICAL_PORT);
// Clear key and value struct
key_logical_port_t *key_log_port = reinterpret_cast<key_logical_port_t*>
// Construct Primary key list
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
// Construct TableAttrSchema structure
// TableAttrSchema holds table_name, primary key, attr_name
vector<TableAttrSchema> vect_table_attr_schema;
- TableAttrSchema kt_switch_table_attr_schema;
list< vector<TableAttrSchema> > row_list;
// controller_name
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
if (switch_id.length() > 0) {
// switch_id
- vect_prim_keys.push_back(SWITCH_ID);
- PhyUtil::FillDbSchema(SWITCH_ID, switch_id,
+ vect_prim_keys.push_back(SWITCH_ID_STR);
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_ID, switch_id,
switch_id.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
}
// Send request to ODBC for switch_table delete
- kt_switch_dbtableschema.set_table_name(UPPL_SWITCH_TABLE);
+ kt_switch_dbtableschema.set_table_name(unc::uppl::SWITCH_TABLE);
kt_switch_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_switch_dbtableschema.set_row_list(row_list);
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
ODBCM_RC_STATUS delete_db_status = physical_layer->get_odbc_manager()-> \
DeleteOneRow((unc_keytype_datatype_t)data_type,
- kt_switch_dbtableschema);
+ kt_switch_dbtableschema, db_conn);
if (delete_db_status != ODBCM_RC_SUCCESS) {
if (delete_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log fatal error to log daemon
pfc_log_error("Delete operation has failed in switch common table");
delete_status = UPPL_RC_ERR_DB_DELETE;
}
+ } else {
+ pfc_log_info("Delete of a switch in data_type(%d) is success",
+ data_type);
+ delete_status = UPPL_RC_SUCCESS;
}
return delete_status;
}
/* * ReadInternal
- * * @Description : This function reads the given instance of Kt Switch
- * * @param[in] : key_struct - key for kt switch instance
+ * @Description : This function reads the given instance of Kt Switch
+ * @param[in] : key_struct - key for kt switch instance
* value_struct - value for kt switch instance
* data_type - UNC_DT_* , read allowed in STATE
- * * @return : UPPL_RC_SUCCESS is returned when the response is added to
+ * operation_type-type of operation,can be UNC_OP_READ*
+ * @return : UPPL_RC_SUCCESS is returned when the response is added to
* ipc session successfully
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess.
* */
-UpplReturnCode Kt_Switch::ReadInternal(vector<void *> &key_val,
+UpplReturnCode Kt_Switch::ReadInternal(OdbcmConnectionHandler *db_conn,
+ vector<void *> &key_val,
vector<void *> &val_struct,
uint32_t data_type,
uint32_t operation_type) {
if (!val_struct.empty()) {
void_val_struct = val_struct[0];
}
- UpplReturnCode read_status = ReadSwitchValFromDB(key_struct,
+ UpplReturnCode read_status = ReadSwitchValFromDB(db_conn,
+ key_struct,
void_val_struct,
data_type,
operation_type,
vect_switch_id);
key_val.clear();
val_struct.clear();
- if (read_status != UPPL_RC_SUCCESS) {
- pfc_log_error("Read operation has failed");
- } else {
+ if (read_status == UPPL_RC_SUCCESS) {
for (unsigned int iIndex = 0 ; iIndex < vect_val_switch_st.size();
++iIndex) {
key_switch_t *key_switch = new key_switch_t(vect_switch_id[iIndex]);
}
/** ReadBulk
- * * @Description : This function reads the max_rep_ct number of instances
+ * @Description : This function reads the max_rep_ct number of instances
* of the KT_Switch
- * * @param[in] :
+ * @param[in] :
* key_struct - key for switch instance
* data_type - UNC_DT_* , ReadBulk supported for STATE
- * option1,option2 - specifies any additional condition for read operation
* max_rep_ct - specifies no of rows to be returned
* parent_call - indicates whether parent has called this read bulk
* is_read_next - indicates whether this function is invoked from read_next
- * * @return : UPPL_RC_SUCCESS is returned when the response is added to
+ * @return : UPPL_RC_SUCCESS is returned when the response is added to
* ipc session successfully
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess
* */
-UpplReturnCode Kt_Switch::ReadBulk(void* key_struct,
+UpplReturnCode Kt_Switch::ReadBulk(OdbcmConnectionHandler *db_conn,
+ void* key_struct,
uint32_t data_type,
- uint32_t option1,
- uint32_t option2,
uint32_t &max_rep_ct,
int child_index,
pfc_bool_t parent_call,
- pfc_bool_t is_read_next) {
+ pfc_bool_t is_read_next,
+ ReadRequest *read_req) {
pfc_log_info("Processing ReadBulk of Kt_Switch");
UpplReturnCode read_status = UPPL_RC_SUCCESS;
key_switch_t obj_key_switch =
vect_key_value.push_back(str_controller_name);
vect_key_value.push_back(str_switch_id);
UpplReturnCode key_exist_status = IsKeyExists(
- (unc_keytype_datatype_t)data_type,
+ db_conn, (unc_keytype_datatype_t)data_type,
vect_key_value);
if (key_exist_status == UPPL_RC_SUCCESS) {
switch_exists = PFC_TRUE;
}
void *val_struct = NULL;
// Read the switch values based on given key structure
- read_status = ReadBulkInternal(key_struct,
+ read_status = ReadBulkInternal(db_conn, key_struct,
val_struct,
data_type,
max_rep_ct,
}
if (read_status == UPPL_RC_SUCCESS ||
switch_exists == PFC_TRUE) {
- PhysicalCore *physical_core = PhysicalLayer::get_instance()->
- get_physical_core();
- InternalTransactionCoordinator *itc_trans =
- physical_core->get_internal_transaction_coordinator();
// For each switch , read the child's attributes
vector<val_switch_st_t> ::iterator vect_iter = vect_val_switch.begin();
vector<key_switch_t> ::iterator switch_iter = vect_switch_id.begin();
UNC_KT_SWITCH, IS_KEY,
reinterpret_cast<void *>(key_buffer)
};
- itc_trans->AddToBuffer(obj_key_buffer);
+ read_req->AddToBuffer(obj_key_buffer);
val_switch_st_t *val_buffer = new val_switch_st_t(*vect_iter);
BulkReadBuffer obj_value_buffer = {
UNC_KT_SWITCH, IS_STATE_VALUE,
reinterpret_cast<void *>(val_buffer)
};
- itc_trans->AddToBuffer(obj_value_buffer);
+ read_req->AddToBuffer(obj_value_buffer);
BulkReadBuffer obj_sep_buffer = {
UNC_KT_SWITCH, IS_SEPARATOR, NULL
};
- itc_trans->AddToBuffer(obj_sep_buffer);
+ read_req->AddToBuffer(obj_sep_buffer);
--max_rep_ct;
if (max_rep_ct == 0) {
return UPPL_RC_SUCCESS;
}
}
switch_exists = PFC_FALSE;
- int st_child_index =
+ int st_child_index = KIdxPort;
+ pfc_log_debug("child_index=%d KIdxPort=%d", child_index, KIdxPort);
+/*
(child_index >= 0 && child_index <= KIdxPort)
? child_index+1 : KIdxPort;
+*/
for (int kIdx = st_child_index; kIdx <= KIdxPort; ++kIdx) {
pfc_log_debug("Switch Iterating child %d", kIdx);
void *child_key_struct = getChildKeyStruct(kIdx, fKey,
}
pfc_log_debug("Switch Calling child %d read bulk", kIdx);
UpplReturnCode ch_read_status = child[kIdx]->ReadBulk(
- child_key_struct,
+ db_conn, child_key_struct,
data_type,
- option1,
- option2,
max_rep_ct,
-1,
true,
- is_read_next);
+ is_read_next,
+ read_req);
pfc_log_debug("ReadBulk response from child %d is %d",
kIdx, ch_read_status);
delete child[kIdx];
pfc_log_debug("Calling parent Kt_Controller read bulk");
Kt_Controller nextKin;
key_ctr_t nextkin_key_struct;
- memset(nextkin_key_struct.controller_name,
- '\0',
- sizeof(nextkin_key_struct.controller_name));
+ memset(&nextkin_key_struct, '\0', sizeof(nextkin_key_struct));
memcpy(nextkin_key_struct.controller_name,
str_controller_name.c_str(),
str_controller_name.length() +1);
read_status = nextKin.ReadBulk(
- reinterpret_cast<void *>(&nextkin_key_struct),
+ db_conn, reinterpret_cast<void *>(&nextkin_key_struct),
data_type,
- option1,
- option2,
max_rep_ct,
1,
false,
- is_read_next);
+ is_read_next,
+ read_req);
pfc_log_debug("read_status from next kin Kt_Ctr is %d", read_status);
return UPPL_RC_SUCCESS;
+ } else if (read_status == UPPL_RC_ERR_DB_ACCESS) {
+ pfc_log_debug("KtSwitch ReadBulk - Returning DB Access Error");
+ return read_status;
}
pfc_log_debug("switch reached end of table");
pfc_log_debug("read_status=%d", read_status);
}
/** ReadBulkInternal
- * * @Description : This function reads bulk rows of KtSwitch in switch table
- * * of specified data type
- * * @param[in] : key_struct - key for switch instance
+ * @Description : This function reads bulk rows of KtSwitch in switch table
+ * of specified data type
+ * @param[in] : key_struct - key for switch instance
* value_struct - value struct for kt switch instance
* data_type - UNC_DT_*, Read supported for STATE
* max_rep_ct - specified no of rows to be returned
* vect_val_switch - indicated the fetched values from db of val_switch type
* vect_switch_id - indicated the fetched switch id from db
- * * @return : UPPL_RC_SUCCESS is returned when the response is added to
+ * @return : UPPL_RC_SUCCESS is returned when the response is added to
* ipc session successfully
* UPPL_RC_ERR_* is returned when ipc response could not be added to sess
* */
UpplReturnCode Kt_Switch::ReadBulkInternal(
+ OdbcmConnectionHandler *db_conn,
void* key_struct,
void* val_struct,
uint32_t data_type,
// Populate DBSchema for switch_table
void* old_value_struct;
vector<ODBCMOperator> vect_key_operations;
- PopulateDBSchemaForKtTable(kt_switch_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_switch_dbtableschema,
key_struct,
val_struct,
- UNC_OP_READ_BULK, 0, 0,
+ UNC_OP_READ_BULK, data_type, 0, 0,
vect_key_operations, old_value_struct);
pfc_log_debug("Calling GetBulkRows");
// Read rows from DB
read_db_status = physical_layer->get_odbc_manager()-> \
GetBulkRows((unc_keytype_datatype_t)data_type, max_rep_ct,
kt_switch_dbtableschema,
- (unc_keytype_operation_t)UNC_OP_READ_BULK);
+ (unc_keytype_operation_t)UNC_OP_READ_BULK, db_conn);
pfc_log_debug("GetBulkRows return: %d", read_db_status);
if (read_db_status == ODBCM_RC_RECORD_NOT_FOUND) {
pfc_log_debug("No record found");
read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
return read_status;
+ } else if (read_db_status == ODBCM_RC_CONNECTION_ERROR) {
+ read_status = UPPL_RC_ERR_DB_ACCESS;
+ pfc_log_error("Read operation has failed with error %d", read_db_status);
+ return read_status;
} else if (read_db_status != ODBCM_RC_SUCCESS) {
read_status = UPPL_RC_ERR_DB_GET;
// log error to log daemon
return read_status;
}
// From the values received from DB, populate val_switch structure
- FillSwitchValueStructure(kt_switch_dbtableschema,
+ FillSwitchValueStructure(db_conn, kt_switch_dbtableschema,
vect_val_switch,
max_rep_ct,
UNC_OP_READ_BULK,
}
/** PerformSyntaxValidation
- * * @Description : This function performs syntax validation for KT_SWITCH
- * * @param[in] : key_struct - key for kt switch instance
+ * @Description : This function performs syntax validation for KT_SWITCH
+ * @param[in] : key_struct - key for kt switch instance
* value_struct - value for kt switch instance
- * operation - UNC_OP_*
- * data_type - UNC_DT_*
- * * @return : UPPL_RC_SUCCESS is returned when the validation is successful
+ * operation - UNC_OP_*,type of operation
+ * data_type - UNC_DT_*,type of database
+ * @return : UPPL_RC_SUCCESS is returned when the validation is successful
* UPPL_RC_ERR_* is returned when validation is failure or associated error code
* */
-UpplReturnCode Kt_Switch::PerformSyntaxValidation(void* key_struct,
- void* val_struct,
- uint32_t operation,
- uint32_t data_type) {
+UpplReturnCode Kt_Switch::PerformSyntaxValidation(
+ OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ void* val_struct,
+ uint32_t operation,
+ uint32_t data_type) {
pfc_log_info("Inside PerformSyntax Validation of KT_SWITCH");
UpplReturnCode ret_code = UPPL_RC_SUCCESS;
pfc_ipcresp_t mandatory = PFC_TRUE;
// Validate Key Structure
key_switch *key = reinterpret_cast<key_switch_t*>(key_struct);
string value = reinterpret_cast<char*>(key->ctr_key.controller_name);
- IS_VALID_STRING_KEY(CTR_NAME, value, operation, ret_code, mandatory);
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map =
+ attr_syntax_map_all[UNC_KT_SWITCH];
+ IS_VALID_STRING_KEY(CTR_NAME_STR, value, operation, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
value = reinterpret_cast<char*>(key->switch_id);
- IS_VALID_STRING_KEY(SWITCH_ID, value, operation, ret_code, mandatory);
+ IS_VALID_STRING_KEY(SWITCH_ID_STR, value, operation, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
valid_val =
PhyUtil::uint8touint(value_switch->valid[kIdxSwitchDescription]);
string value = reinterpret_cast<char*>(value_switch->description);
- IS_VALID_STRING_VALUE(SWITCH_DESCRIPTION, value, operation,
+ IS_VALID_STRING_VALUE(SWITCH_DESCRIPTION_STR, value, operation,
valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
// validate model
valid_val = PhyUtil::uint8touint(value_switch->valid[kIdxSwitchModel]);
value = reinterpret_cast<char*>(value_switch->model);
- IS_VALID_STRING_VALUE(SWITCH_MODEL, value, operation,
+ IS_VALID_STRING_VALUE(SWITCH_MODEL_STR, value, operation,
valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
// validate IP Address
valid_val = PhyUtil::uint8touint(value_switch->valid[kIdxSwitchIPAddress]);
- IS_VALID_IPV4_VALUE(SWITCH_IP_ADDRESS, value_switch->ip_address, operation,
- valid_val, ret_code, mandatory);
+ IS_VALID_IPV4_VALUE(SWITCH_IP_ADDRESS_STR, value_switch->ip_address,
+ operation, valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
// validate ipv6 Address
valid_val =
PhyUtil::uint8touint(value_switch->valid[kIdxSwitchIPV6Address]);
- IS_VALID_IPV6_VALUE(SWITCH_IPV6_ADDRESS, value_switch->ipv6_address,
+ IS_VALID_IPV6_VALUE(SWITCH_IPV6_ADDRESS_STR, value_switch->ipv6_address,
operation, valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
// validate admin_status
valid_val =
PhyUtil::uint8touint(value_switch->valid[kIdxSwitchAdminStatus]);
- IS_VALID_INT_VALUE(SWITCH_ADMIN_STATUS, value_switch->admin_status,
+ IS_VALID_INT_VALUE(SWITCH_ADMIN_STATUS_STR, value_switch->admin_status,
operation, valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
// validate domain Name
valid_val = PhyUtil::uint8touint(value_switch->valid[kIdxSwitchDomainName]);
value = reinterpret_cast<char*>(value_switch->domain_name);
- IS_VALID_STRING_VALUE(SWITCH_DOMAIN_NAME, value, operation,
+ IS_VALID_STRING_VALUE(SWITCH_DOMAIN_NAME_STR, value, operation,
valid_val, ret_code, mandatory);
if (ret_code != UPPL_RC_SUCCESS) {
return UPPL_RC_ERR_CFG_SYNTAX;
}
/** PerformSemanticValidation
- * * @Description : This function performs semantic validation
+ * @Description : This function performs semantic validation
* for UNC_KT_SWITCH
- * * @param[in] : key_struct - specifies key instance of KT_SWITCH
+ * @param[in] : key_struct - specifies key instance of KT_SWITCH
* value_struct - specifies value of KT_SWITCH
- * operation - UNC_OP*
- * data_type - UNC_DT*
- * * @return : UPPL_RC_SUCCESS if semantic validation is successful
+ * operation - UNC_OP*,type of operation
+ * data_type - UNC_DT*,type of database
+ * @return : UPPL_RC_SUCCESS if semantic validation is successful
* or UPPL_RC_ERR_* if failed
* */
-UpplReturnCode Kt_Switch::PerformSemanticValidation(void* key_struct,
- void* val_struct,
- uint32_t operation,
- uint32_t data_type) {
+UpplReturnCode Kt_Switch::PerformSemanticValidation(
+ OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ void* val_struct,
+ uint32_t operation,
+ uint32_t data_type) {
UpplReturnCode status = UPPL_RC_SUCCESS;
pfc_log_debug("Inside PerformSemanticValidation of KT_SWITCH");
// Check whether the given instance of switch in DB
vector<string> switch_vect_key_value;
switch_vect_key_value.push_back(controller_name);
switch_vect_key_value.push_back(switch_id);
- UpplReturnCode key_status = IsKeyExists((unc_keytype_datatype_t)data_type,
+ UpplReturnCode key_status = IsKeyExists(db_conn,
+ (unc_keytype_datatype_t)data_type,
switch_vect_key_value);
pfc_log_debug("IsKeyExists status %d", key_status);
parent_data_type = UNC_DT_RUNNING;
}
UpplReturnCode parent_key_status = KtObj.IsKeyExists(
- (unc_keytype_datatype_t)parent_data_type, parent_vect_key_value);
+ db_conn, (unc_keytype_datatype_t)parent_data_type,
+ parent_vect_key_value);
pfc_log_debug("Parent IsKeyExists status %d", parent_key_status);
if (parent_key_status != UPPL_RC_SUCCESS) {
status = UPPL_RC_ERR_PARENT_DOES_NOT_EXIST;
}
/** HandleDriverAlarms
- * * @Description : This function processes the alarm notification
+ * @Description : This function processes the alarm notification
* received from driver
- * * @param[in] : alarm type - contains type to indicate PATH_FAULT alarm
+ * @param[in] :data_type
+ * alarm type - contains type to indicate PATH_FAULT alarm
* operation - contains UNC_OP_CREATE or UNC_OP_DELETE
* key_struct - indicate key instance of KT_SWITCH
* value_struct - indicates the alarm value structure
- * * @return : UPPL_RC_SUCCESS if alarm is handled successfully or
+ * @return : UPPL_RC_SUCCESS if alarm is handled successfully or
* UPPL_RC_ERR*
* */
-UpplReturnCode Kt_Switch::HandleDriverAlarms(uint32_t data_type,
+UpplReturnCode Kt_Switch::HandleDriverAlarms(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
uint32_t alarm_type,
uint32_t oper_type,
void* key_struct,
controller_name.c_str(),
controller_name.length()+1);
pfc_log_info("alarm sent by driver is: %d", alarm_type);
- pfc_log_info("operation type: %d", oper_type);
// Read old_alarm_status from db
uint64_t alarm_status_db = 0;
- UpplReturnCode read_alarm_status = GetAlarmStatus(data_type,
+ UpplReturnCode read_alarm_status = GetAlarmStatus(db_conn,
+ data_type,
key_struct,
alarm_status_db);
- if (read_alarm_status == UPPL_RC_SUCCESS) {
- uint64_t new_alarm_status = 0;
- uint64_t old_alarm_status = alarm_status_db;
- pfc_log_info("alarm_status received from db: %" PFC_PFMT_u64,
- old_alarm_status);
- if (alarm_type == UNC_FLOW_ENT_FULL) {
- if (oper_type == UNC_OP_CREATE) {
- // Set flow entry full alarm
- new_alarm_status = old_alarm_status |
- ALARM_UPPL_ALARMS_FLOW_ENT_FULL; // 0000 0001
- } else if (oper_type == UNC_OP_DELETE) {
- // clear flow entry full alarm
- new_alarm_status = old_alarm_status & 0xFFFE; // 1111 1111 1111 1110
- }
- }
- if (alarm_type == UNC_OFS_LACK_FEATURES) {
- if (oper_type == UNC_OP_CREATE) {
- // Set OFS_LACK_FEATURES alarm
- new_alarm_status = old_alarm_status |
- ALARM_UPPL_ALARMS_OFS_LACK_FEATURES; // 0000 0010
- } else if (oper_type == UNC_OP_DELETE) {
- // Clear OFS_LACK_FEATURES alarm
- new_alarm_status = old_alarm_status & 0xFFFD; // 1111 1111 1111 1101
- }
- }
- if (old_alarm_status == new_alarm_status) {
- pfc_log_info("old and new alarms status are same, so return");
- return UPPL_RC_SUCCESS;
- }
- // Call UpdateKeyInstance to update the new alarm status and
- // new oper status value in DB
- val_switch_st obj_val_switch_st;
- memset(obj_val_switch_st.valid, '\0',
- sizeof(obj_val_switch_st.valid));
- memset(obj_val_switch_st.switch_val.valid, '\0',
- sizeof(obj_val_switch_st.switch_val.valid));
- obj_val_switch_st.valid[kIdxSwitchAlarmStatus] = UNC_VF_VALID;
- obj_val_switch_st.alarms_status = new_alarm_status;
- // Calling UPDATE KEY INSTANCE for update in DB
- void* old_value_struct;
- status = UpdateKeyInstance(obj_key_switch,
- reinterpret_cast<void*> (&obj_val_switch_st),
- data_type,
- UNC_KT_SWITCH,
- old_value_struct);
- if (status == UPPL_RC_SUCCESS && data_type != UNC_DT_IMPORT) {
- // Send oper_status notification to north bound
- // From value_struct
- val_switch_st old_val_switch, new_val_switch;
-
- old_val_switch.alarms_status = old_alarm_status;
- old_val_switch.valid[kIdxSwitch] = UNC_VF_INVALID;
- old_val_switch.valid[kIdxSwitchOperStatus] = UNC_VF_INVALID;
- old_val_switch.valid[kIdxSwitchAlarmStatus] = UNC_VF_VALID;
-
- new_val_switch.alarms_status = new_alarm_status;
- new_val_switch.valid[kIdxSwitch] = UNC_VF_INVALID;
- new_val_switch.valid[kIdxSwitchOperStatus] = UNC_VF_INVALID;
- new_val_switch.valid[kIdxSwitchAlarmStatus] = UNC_VF_VALID;
- int err = 0;
- ServerEvent ser_evt((pfc_ipcevtype_t)UPPL_EVENTS_KT_SWITCH, err);
- ser_evt.addOutput((uint32_t)UNC_OP_UPDATE);
- ser_evt.addOutput(data_type);
- ser_evt.addOutput((uint32_t)UPPL_EVENTS_KT_SWITCH);
- ser_evt.addOutput(*obj_key_switch);
- ser_evt.addOutput(new_val_switch);
- ser_evt.addOutput(old_val_switch);
+ if (read_alarm_status != UPPL_RC_SUCCESS) {
+ pfc_log_info("Reading alarm status from db failed with %d",
+ read_alarm_status);
+ return status;
+ }
+ uint64_t new_alarm_status = 0;
+ uint64_t old_alarm_status = alarm_status_db;
+ pfc_log_info("alarm_status received from db: %" PFC_PFMT_u64,
+ old_alarm_status);
+ if (alarm_type == UNC_FLOW_ENT_FULL) {
+ if (oper_type == UNC_OP_CREATE) {
+ // Set flow entry full alarm
+ new_alarm_status = old_alarm_status |
+ ALARM_UPPL_ALARMS_FLOW_ENT_FULL; // 0000 0001
+ } else if (oper_type == UNC_OP_DELETE) {
+ // clear flow entry full alarm
+ new_alarm_status = old_alarm_status & 0xFFFE; // 1111 1111 1111 1110
+ }
+ }
+ if (alarm_type == UNC_OFS_LACK_FEATURES) {
+ if (oper_type == UNC_OP_CREATE) {
+ // Set OFS_LACK_FEATURES alarm
+ new_alarm_status = old_alarm_status |
+ ALARM_UPPL_ALARMS_OFS_LACK_FEATURES; // 0000 0010
+ } else if (oper_type == UNC_OP_DELETE) {
+ // Clear OFS_LACK_FEATURES alarm
+ new_alarm_status = old_alarm_status & 0xFFFD; // 1111 1111 1111 1101
+ }
+ }
+ if (old_alarm_status == new_alarm_status) {
+ pfc_log_info("old and new alarms status are same, so return");
+ return UPPL_RC_SUCCESS;
+ }
+ // Call UpdateKeyInstance to update the new alarm status and
+ // new oper status value in DB
+ val_switch_st obj_val_switch_st;
+ memset(&obj_val_switch_st, 0, sizeof(obj_val_switch_st));
+ memset(obj_val_switch_st.valid, '\0',
+ sizeof(obj_val_switch_st.valid));
+ memset(obj_val_switch_st.switch_val.valid, '\0',
+ sizeof(obj_val_switch_st.switch_val.valid));
+ obj_val_switch_st.valid[kIdxSwitchAlarmStatus] = UNC_VF_VALID;
+ obj_val_switch_st.alarms_status = new_alarm_status;
+ // Calling UPDATE KEY INSTANCE for update in DB
+ void* old_value_struct;
+ status = UpdateKeyInstance(db_conn,
+ obj_key_switch,
+ reinterpret_cast<void*> (&obj_val_switch_st),
+ data_type,
+ UNC_KT_SWITCH,
+ old_value_struct);
+ if (status == UPPL_RC_SUCCESS && data_type != UNC_DT_IMPORT) {
+ // Send oper_status notification to north bound
+ // From value_struct
+ val_switch_st old_val_switch, new_val_switch;
+ memset(&old_val_switch, 0, sizeof(old_val_switch));
+ memset(&new_val_switch, 0, sizeof(new_val_switch));
+ old_val_switch.alarms_status = old_alarm_status;
+ old_val_switch.valid[kIdxSwitchAlarmStatus] = UNC_VF_VALID;
+
+ new_val_switch.alarms_status = new_alarm_status;
+ new_val_switch.valid[kIdxSwitchAlarmStatus] = UNC_VF_VALID;
+ int err = 0;
+ ServerEvent ser_evt((pfc_ipcevtype_t)UPPL_EVENTS_KT_SWITCH, err);
+ northbound_event_header rsh = {UNC_OP_UPDATE,
+ data_type,
+ UNC_KT_SWITCH};
+ err = PhyUtil::sessOutNBEventHeader(ser_evt, rsh);
+ err |= ser_evt.addOutput(*obj_key_switch);
+ err |= ser_evt.addOutput(new_val_switch);
+ err |= ser_evt.addOutput(old_val_switch);
+ if (err == 0) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
// Notify operstatus modifications
status = (UpplReturnCode) physical_layer
->get_ipc_connection_manager()->SendEvent(&ser_evt);
- if (status != UPPL_RC_SUCCESS) {
- pfc_log_info("Update alarm status could not be sent to NB, error %d",
- status);
- }
+ pfc_log_info("Update alarm send status to NB: %d",
+ status);
} else {
- pfc_log_info("Update alarm status in db status %d", status);
- }
- val_switch_st_t *val_switch =
- reinterpret_cast<val_switch_st_t*>(old_value_struct);
- if (val_switch != NULL) {
- delete val_switch;
- val_switch = NULL;
+ pfc_log_info("Error creating ServerEvent object");
+ status = UPPL_RC_ERR_IPC_WRITE_ERROR;
}
} else {
- pfc_log_info("Reading alarm status from db failed with %d",
- read_alarm_status);
+ pfc_log_info("Update alarm status in db status %d", status);
+ }
+ val_switch_st_t *val_switch =
+ reinterpret_cast<val_switch_st_t*>(old_value_struct);
+ if (val_switch != NULL) {
+ delete val_switch;
+ val_switch = NULL;
}
return status;
}
/** IsKeyExists
- * * @Description : This function checks whether the controller_id exists in DB
- * * @param[in] : data_type - UNC_DT_*
+ * @Description : This function checks whether the controller_id exists in DB
+ * @param[in] : data_type - UNC_DT_*,type of database
* key_values - contains switch_id
- * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR* based in operation type
+ * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR* based in operation type
* */
-UpplReturnCode Kt_Switch::IsKeyExists(unc_keytype_datatype_t data_type,
- vector<string> key_values) {
+UpplReturnCode Kt_Switch::IsKeyExists(OdbcmConnectionHandler *db_conn,
+ unc_keytype_datatype_t data_type,
+ const vector<string> &key_values) {
pfc_log_debug("Inside IsKeyExists");
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
UpplReturnCode check_status = UPPL_RC_SUCCESS;
// Construct Primary key list
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
- vect_prim_keys.push_back(SWITCH_ID);
+ vect_prim_keys.push_back(CTR_NAME_STR);
+ vect_prim_keys.push_back(SWITCH_ID_STR);
// Construct TableAttrSchema structure
// TableAttrSchema holds table_name, primary key, attr_name
vector<TableAttrSchema> vect_table_attr_schema;
- TableAttrSchema kt_switch_table_attr_schema;
list< vector<TableAttrSchema> > row_list;
// controller_name
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// switch_id
- PhyUtil::FillDbSchema(SWITCH_ID, switch_id,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_ID, switch_id,
switch_id.length(),
DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
- kt_switch_dbtableschema.set_table_name(UPPL_SWITCH_TABLE);
+ kt_switch_dbtableschema.set_table_name(unc::uppl::SWITCH_TABLE);
kt_switch_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_switch_dbtableschema.set_row_list(row_list);
// Send request to ODBC for switch_table
ODBCM_RC_STATUS check_db_status = physical_layer->get_odbc_manager()->
- IsRowExists(data_type, kt_switch_dbtableschema);
+ IsRowExists(data_type, kt_switch_dbtableschema, db_conn);
if (check_db_status == ODBCM_RC_CONNECTION_ERROR) {
// log error to log daemon
pfc_log_error("DB connection not available or cannot access DB");
}
/** PopulateDBSchemaForKtTable
- * * @Description : This function populates the DBAttrSchema to be used to
+ * @Description : This function populates the DBAttrSchema to be used to
* send request to ODBC
- * * @param[in] : DBTableSchema - DBtableschema associated with KT_Switch
+ * @param[in] : DBTableSchema - DBtableschema associated with KT_Switch
* key_struct - key instance of Kt_Switch
* val_struct - val instance of Kt_Switch
- * operation_type - UNC_OP*
- * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
+ * operation_type - UNC_OP*,type of operation
+ * option1,option2-any one of UNC_OPT1/OPT2_*,additional options for read op
+ * vect_key_operations- an instance of vector<ODBCMOperator>
+ * old_value_struct-val instance of Kt_Switch
+ * row_status- value of CsRowStatus
+ * is_filtering-flag to indicate whether filter option enabled
+ * is_state-flag to indicate whether data_type is DT_STATE
+ * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
* */
void Kt_Switch::PopulateDBSchemaForKtTable(
+ OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_switch_dbtableschema,
void* key_struct,
void* val_struct,
uint8_t operation_type,
+ uint32_t data_type,
uint32_t option1,
uint32_t option2,
vector<ODBCMOperator> &vect_key_operations,
pfc_bool_t is_state) {
// Construct Primary key list
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
// construct TableAttrSchema structure
// TableAttrSchema holds table_name, primary key, attr_name
- TableAttrSchema kt_switch_table_attr_schema;
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
// controller_name
string controller_name = (const char*)obj_key_switch
->ctr_key.controller_name;
- pfc_log_info("controller name: %s", controller_name.c_str());
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ pfc_log_debug("controller name: %s", controller_name.c_str());
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
// switch_id
+ bool read_sibling = false;
string switch_id = (const char*) obj_key_switch->switch_id;
if (operation_type == UNC_OP_READ_SIBLING_BEGIN ||
operation_type == UNC_OP_READ_SIBLING_COUNT) {
switch_id = "";
+ read_sibling = true;
}
- pfc_log_info("switch_id: %s ", switch_id.c_str());
- PhyUtil::FillDbSchema(SWITCH_ID, switch_id,
+ pfc_log_debug("switch_id: %s ", switch_id.c_str());
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_ID, switch_id,
switch_id.length(),
DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
val_switch_st_t *val_switch_valid_st = NULL;
if (operation_type == UNC_OP_UPDATE) {
// get valid array for update req
- pfc_log_debug("Get Valid value from port Update Valid Flag");
+ pfc_log_debug("Read switch to update valid flag");
unc_keytype_validflag_t new_valid_val = UNC_VF_VALID;
val_switch_valid_st = new val_switch_st_t();
- UpdateSwitchValidFlag(key_struct, val_struct,
- *val_switch_valid_st, new_valid_val);
+ void *empty_val_struct = NULL;
+ UpdateSwitchValidFlag(db_conn, key_struct, empty_val_struct,
+ *val_switch_valid_st, new_valid_val, data_type);
old_value_struct = reinterpret_cast<void*>(val_switch_valid_st);
}
GetSwitchValStructure(
- obj_val_switch,
+ db_conn, obj_val_switch,
vect_table_attr_schema,
vect_prim_keys,
operation_type,
val_switch_valid_st,
valid);
GetSwitchStateValStructure(
- obj_val_switch,
+ db_conn, obj_val_switch,
vect_table_attr_schema,
vect_prim_keys,
operation_type,
val_switch_valid_st,
valid);
- vect_prim_keys.push_back(SWITCH_ID);
+ if (read_sibling == true || (!switch_id.empty())) {
+ vect_prim_keys.push_back(SWITCH_ID_STR);
+ } else if(read_sibling == false)
+ vect_prim_keys.push_back(SWITCH_ID_STR);
+ pfc_log_debug("operation_type=%d read_sibling=%d vect_prim_keys.size=%d", operation_type, read_sibling, (uint32_t)vect_prim_keys.size());
PhyUtil::reorder_col_attrs(vect_prim_keys, vect_table_attr_schema);
- kt_switch_dbtableschema.set_table_name(UPPL_SWITCH_TABLE);
+ kt_switch_dbtableschema.set_table_name(unc::uppl::SWITCH_TABLE);
kt_switch_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_switch_dbtableschema.set_row_list(row_list);
}
/** FillSwitchValueStructure
- * * @Description : This function populates val_switch by values retrieved
+ * @Description : This function populates val_switch by values retrieved
* from DB
- * * * @param[in] : switch dbtable schema - dbtableschema associated with
+ * @param[in] : kt_switch_dbtableschema - dbtableschema associated with
* Kt_Switch
* vect_obj_val_switch - vector of type val_switch_st
* max_rep_ct - specifies no of rows to be returned
- * operation_type - UNC_OP*
+ * operation_type - UNC_OP*,type of operation
* switch_id - vector of key structure of switch
- * * @return : void
+ * @return : void
* */
void Kt_Switch::FillSwitchValueStructure(
+ OdbcmConnectionHandler *db_conn,
DBTableSchema &kt_switch_dbtableschema,
vector<val_switch_st_t> &vect_obj_val_switch,
uint32_t &max_rep_ct,
uint32_t operation_type,
vector<key_switch_t> &switch_id) {
- // populate IPC value structure based on the response recevied from DB
- list < vector<TableAttrSchema> > res_switch_row_list =
+ // populate IPC value structure based on the response received from DB
+ list < vector<TableAttrSchema> >& res_switch_row_list =
kt_switch_dbtableschema.get_row_list();
list < vector<TableAttrSchema> > :: iterator res_switch_iter =
res_switch_row_list.begin();
max_rep_ct = res_switch_row_list.size();
pfc_log_debug("res_switch_row_list.size: %d", max_rep_ct);
- // populate IPC value structure based on the response recevied from DB
+ // populate IPC value structure based on the response received from DB
for (; res_switch_iter != res_switch_row_list.end(); ++res_switch_iter) {
vector<TableAttrSchema> res_switch_table_attr_schema = (*res_switch_iter);
vector<TableAttrSchema> :: iterator vect_switch_iter =
val_switch_st_t obj_val_switch;
memset(&obj_val_switch, 0, sizeof(val_switch_st_t));
- memset(&obj_val_switch.switch_val, 0, sizeof(val_switch_t));
key_switch_t obj_key_switch;
memset(&obj_key_switch, 0, sizeof(obj_key_switch));
// Read all attributes
++vect_switch_iter) {
// populate values from switch_table
TableAttrSchema tab_schema = (*vect_switch_iter);
- string attr_name = tab_schema.table_attribute_name;
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
string attr_value;
- if (attr_name == SWITCH_ID) {
- memset(obj_key_switch.switch_id, '\0',
- sizeof(obj_key_switch.switch_id));
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_256);
- memcpy(obj_key_switch.switch_id, attr_value.c_str(),
- attr_value.length()+1);
- switch_id.push_back(obj_key_switch);
- pfc_log_debug("switch_id : %s", attr_value.c_str());
- }
- if (attr_name == CTR_NAME) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- pfc_log_debug("controller_name: %s", attr_value.c_str());
- memcpy(obj_key_switch.ctr_key.controller_name, attr_value.c_str(),
- attr_value.length()+1);
- }
- if (attr_name == SWITCH_DESCRIPTION) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_128);
- memcpy(obj_val_switch.switch_val.description,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("Description: %s",
- obj_val_switch.switch_val.description);
- }
- if (attr_name == SWITCH_MODEL) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_16);
- memcpy(obj_val_switch.switch_val.model,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("Model: %s", obj_val_switch.switch_val.model);
- }
- if (attr_name == SWITCH_IP_ADDRESS) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_IPV4);
- inet_pton(AF_INET, (const char *)attr_value.c_str(),
- &obj_val_switch.switch_val.ip_address.s_addr);
- pfc_log_debug("ip_address :%s", attr_value.c_str());
- }
- if (attr_name == SWITCH_IPV6_ADDRESS) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_IPV6);
- inet_pton(AF_INET6, (const char *)attr_value.c_str(),
- &obj_val_switch.switch_val.ipv6_address.s6_addr);
- pfc_log_debug("ipv6_address :%s", attr_value.c_str());
- char str[INET6_ADDRSTRLEN];
- // Checking filled up value
- inet_ntop(AF_INET6, &obj_val_switch.switch_val.ipv6_address.s6_addr,
- str, INET6_ADDRSTRLEN);
- pfc_log_debug("ipv6_address :%s", str);
- }
- if (attr_name == SWITCH_ADMIN_STATUS) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- obj_val_switch.switch_val.admin_status = atoi(attr_value.c_str());
- pfc_log_debug("admin status : %d",
- obj_val_switch.switch_val.admin_status);
- }
- if (attr_name == SWITCH_DOMAIN_NAME) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_32);
- memcpy(obj_val_switch.switch_val.domain_name,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("Domain Name: %s",
- obj_val_switch.switch_val.domain_name);
- }
- if (attr_name == SWITCH_OPER_STATUS) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- obj_val_switch.oper_status = atoi(attr_value.c_str());
- pfc_log_debug("oper status : %d", obj_val_switch.oper_status);
- }
- if (attr_name == SWITCH_MANUFACTURER) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_256);
- memcpy(obj_val_switch.manufacturer,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("Manufacturer: %s", obj_val_switch.manufacturer);
- }
- if (attr_name == SWITCH_HARDWARE) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_256);
- memcpy(obj_val_switch.hardware,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("Hardware: %s", obj_val_switch.hardware);
- }
- if (attr_name == SWITCH_SOFTWARE) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_256);
- memcpy(obj_val_switch.software,
- attr_value.c_str(),
- attr_value.length()+1);
- pfc_log_debug("Software: %s", obj_val_switch.software);
- }
- if (attr_name == SWITCH_ALARM_STATUS) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT64);
- obj_val_switch.alarms_status = atol(attr_value.c_str());
- pfc_log_debug("alarms status : %" PFC_PFMT_u64,
- obj_val_switch.alarms_status);
- }
- if (attr_name == SWITCH_VALID) {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT8_ARRAY_11);
- memset(obj_val_switch.valid, 0, 6);
- memset(obj_val_switch.switch_val.valid, 0, 6);
- FrameValidValue(attr_value, obj_val_switch);
- pfc_log_debug("valid: %s", attr_value.c_str());
+ switch (attr_name) {
+ case unc::uppl::SWITCH_ID:
+ memset(obj_key_switch.switch_id, '\0',
+ sizeof(obj_key_switch.switch_id));
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema, obj_key_switch.switch_id,
+ DATATYPE_UINT8_ARRAY_256);
+ switch_id.push_back(obj_key_switch);
+ pfc_log_debug("switch_id : %s", obj_key_switch.switch_id);
+ break;
+ case unc::uppl::CTR_NAME:
+ PhyUtil::GetValueFromDbSchemaStr(
+ tab_schema,
+ obj_key_switch.ctr_key.controller_name,
+ DATATYPE_UINT8_ARRAY_32);
+ pfc_log_debug("controller_name: %s",
+ obj_key_switch.ctr_key.controller_name);
+ break;
+ case unc::uppl::SWITCH_DESCRIPTION:
+ PhyUtil::GetValueFromDbSchemaStr(
+ tab_schema,
+ obj_val_switch.switch_val.description,
+ DATATYPE_UINT8_ARRAY_128);
+ pfc_log_debug("Description: %s",
+ obj_val_switch.switch_val.description);
+ break;
+ case unc::uppl::SWITCH_MODEL:
+ PhyUtil::GetValueFromDbSchemaStr(
+ tab_schema,
+ obj_val_switch.switch_val.model,
+ DATATYPE_UINT8_ARRAY_16);
+ pfc_log_debug("Model: %s", obj_val_switch.switch_val.model);
+ break;
+ case unc::uppl::SWITCH_IP_ADDRESS:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_IPV4);
+ inet_pton(AF_INET, (const char *)attr_value.c_str(),
+ &obj_val_switch.switch_val.ip_address.s_addr);
+ pfc_log_debug("ip_address :%s", attr_value.c_str());
+ break;
+ case unc::uppl::SWITCH_IPV6_ADDRESS:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_IPV6);
+ inet_pton(AF_INET6, (const char *)attr_value.c_str(),
+ &obj_val_switch.switch_val.ipv6_address.s6_addr);
+ pfc_log_debug("ipv6_address :%s", attr_value.c_str());
+ char str[INET6_ADDRSTRLEN];
+ memset(&str, '\0', INET6_ADDRSTRLEN);
+ // Checking filled up value
+ inet_ntop(AF_INET6, &obj_val_switch.switch_val.ipv6_address.s6_addr,
+ str, INET6_ADDRSTRLEN);
+ pfc_log_debug("ipv6_address :%s", str);
+ break;
+ case unc::uppl::SWITCH_ADMIN_STATUS:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT16);
+ obj_val_switch.switch_val.admin_status = atoi(attr_value.c_str());
+ pfc_log_debug("admin status : %d",
+ obj_val_switch.switch_val.admin_status);
+ break;
+ case unc::uppl::SWITCH_DOMAIN_NAME:
+ PhyUtil::GetValueFromDbSchemaStr(
+ tab_schema,
+ obj_val_switch.switch_val.domain_name,
+ DATATYPE_UINT8_ARRAY_32);
+ pfc_log_debug("Domain Name: %s",
+ obj_val_switch.switch_val.domain_name);
+ break;
+ case unc::uppl::SWITCH_OPER_STATUS:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT16);
+ obj_val_switch.oper_status = atoi(attr_value.c_str());
+ pfc_log_debug("oper status : %d", obj_val_switch.oper_status);
+ break;
+ case unc::uppl::SWITCH_MANUFACTURER:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_val_switch.manufacturer,
+ DATATYPE_UINT8_ARRAY_256);
+ pfc_log_debug("Manufacturer: %s", obj_val_switch.manufacturer);
+ break;
+ case unc::uppl::SWITCH_HARDWARE:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_val_switch.hardware,
+ DATATYPE_UINT8_ARRAY_256);
+ pfc_log_debug("Hardware: %s", obj_val_switch.hardware);
+ break;
+ case unc::uppl::SWITCH_SOFTWARE:
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema,
+ obj_val_switch.software,
+ DATATYPE_UINT8_ARRAY_256);
+ pfc_log_debug("Software: %s", obj_val_switch.software);
+ break;
+ case unc::uppl::SWITCH_ALARM_STATUS:
+ PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
+ DATATYPE_UINT64);
+ obj_val_switch.alarms_status = atol(attr_value.c_str());
+ pfc_log_debug("alarms status : %" PFC_PFMT_u64,
+ obj_val_switch.alarms_status);
+ break;
+ case unc::uppl::SWITCH_VALID:
+ uint8_t sw_valid[ODBCM_SIZE_11];
+ memset(&sw_valid, 0, ODBCM_SIZE_11);
+ PhyUtil::GetValueFromDbSchemaStr(tab_schema, sw_valid,
+ DATATYPE_UINT8_ARRAY_11);
+ memset(obj_val_switch.valid, 0, 6);
+ memset(obj_val_switch.switch_val.valid, 0, 6);
+ FrameValidValue(reinterpret_cast<const char*> (sw_valid),
+ obj_val_switch);
+ pfc_log_debug("valid: %s", sw_valid);
+ break;
+ default:
+ pfc_log_info("Ignoring Switch attribute %d", attr_name);
+ break;
}
}
vect_obj_val_switch.push_back(obj_val_switch);
}
/** PerformRead
- * * @Description : This function reads the instance of KT_Switch based on
+ * @Description : This function reads the instance of KT_Switch based on
* operation type - READ, READ_SIBLING_BEGIN, READ_SIBLING
- * * @param[in] : ipc session id - ipc session id used for TC validation
+ * @param[in] : ipc session id - ipc session id used for TC validation
* configuration id - configuration id used for TC validation
* key_struct - key instance of KT_Switch
* value_struct - value instance of Kt_Switch
- * data_type - UNC_DT_* , read allowed in STATE
- * operation_type - specifies the operation type
+ * data_type - UNC_DT_* , read allowed in STATE,UNC_DT_*
+ * operation_type - specifies the operation type,UNC_OP_*
* sess - ipc server session where the response has to be added
* option1, option2 - additional condition associated with read operation
* max_rep_ct - specifies no of rows to be returned
- * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR_*
+ * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR_*
* */
-UpplReturnCode Kt_Switch::PerformRead(uint32_t session_id,
+UpplReturnCode Kt_Switch::PerformRead(OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
uint32_t configuration_id,
void* key_struct,
void* val_struct,
uint32_t option1,
uint32_t option2,
uint32_t max_rep_ct) {
- pfc_log_info("Inside PerformRead option1=%d option2=%d max_rep_ct=%d",
- option1, option2, max_rep_ct);
pfc_log_info("Inside PerformRead operation_type=%d data_type=%d",
operation_type, data_type);
vector<key_switch_t> vect_switch_id;
vector<val_switch_st_t> vect_val_switch_st;
- read_status = ReadSwitchValFromDB(key_struct,
+ read_status = ReadSwitchValFromDB(db_conn, key_struct,
val_struct,
data_type,
operation_type,
}
/** ReadSwitchValFromDB
- * * @Description : This function reads the instance of Kt_Switch based on
+ * @Description : This function reads the instance of Kt_Switch based on
* operation type - READ, READ_SIBLING_BEGIN, READ_SIBLING from data_base
- * * @param[in] : key_struct - key instance of kt Switch
+ * @param[in] : key_struct - key instance of kt Switch
* value_struct - value struct of kt switch
- * data_type - Specifies the data type for read operation
- * operation type - specifies the operation_type
+ * data_type - Specifies the data type for read operation,UNC_DT_*
+ * operation type - specifies the operation_type,UNC_OP_*
* max_rep_ct - max no of rows to be returned
* vect_val_switch_st - vector of type val_switch_st
* switch_id - vector of type key_switch
* is_state - bool variable to specify the state
- * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR_*
+ * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR_*
* */
UpplReturnCode Kt_Switch::ReadSwitchValFromDB(
+ OdbcmConnectionHandler *db_conn,
void* key_struct,
void* val_struct,
uint32_t data_type,
vector<val_switch_st_t> &vect_val_switch_st,
vector<key_switch_t> &vect_switch_id,
pfc_bool_t is_state) {
+ if (operation_type < UNC_OP_READ) {
+ // Unsupported operation type for this function
+ return UPPL_RC_SUCCESS;
+ }
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
- // key_switch_t *obj_key_switch =
- // reinterpret_cast<key_switch_t*>(key_struct);
-
UpplReturnCode read_status = UPPL_RC_SUCCESS;
ODBCM_RC_STATUS read_db_status = ODBCM_RC_SUCCESS;
DBTableSchema kt_switch_dbtableschema;
void* old_value_struct;
vector<ODBCMOperator> vect_key_operations;
- PopulateDBSchemaForKtTable(kt_switch_dbtableschema,
+ PopulateDBSchemaForKtTable(db_conn, kt_switch_dbtableschema,
key_struct,
val_struct,
- operation_type, 0, 0,
+ operation_type, data_type, 0, 0,
vect_key_operations, old_value_struct);
if (operation_type == UNC_OP_READ) {
read_db_status = physical_layer->get_odbc_manager()->
GetOneRow((unc_keytype_datatype_t)data_type,
- kt_switch_dbtableschema);
+ kt_switch_dbtableschema, db_conn);
} else {
read_db_status = physical_layer->get_odbc_manager()->
GetBulkRows((unc_keytype_datatype_t)data_type, max_rep_ct,
kt_switch_dbtableschema,
- (unc_keytype_operation_t)operation_type);
+ (unc_keytype_operation_t)operation_type, db_conn);
}
if (read_db_status == ODBCM_RC_RECORD_NOT_FOUND) {
pfc_log_debug("No record found");
read_status = UPPL_RC_ERR_NO_SUCH_INSTANCE;
return read_status;
+ } else if (read_db_status == ODBCM_RC_CONNECTION_ERROR) {
+ read_status = UPPL_RC_ERR_DB_ACCESS;
+ pfc_log_error("Read operation has failed with error %d", read_db_status);
+ return read_status;
} else if (read_db_status != ODBCM_RC_SUCCESS) {
read_status = UPPL_RC_ERR_DB_GET;
pfc_log_info("Read operation status from odbcm = %d", read_db_status);
}
pfc_log_debug("Read operation result: %d", read_status);
- FillSwitchValueStructure(kt_switch_dbtableschema,
+ FillSwitchValueStructure(db_conn, kt_switch_dbtableschema,
vect_val_switch_st,
max_rep_ct,
operation_type,
}
/** getChildKeyStruct
- * * @Description : This function returns the void * of child key structures
- * * @param[in] : child class index - specifies the enum associated with
+ * @Description : This function returns the void * of child key structures
+ * @param[in] : child class index - specifies the enum associated with
* child class of switch
* switch id - switch id associated with KtSwitch
* controller_name - controller name associated with ktswitch
- * * @return : void * key structure
+ * @return : void * key structure
* */
void* Kt_Switch::getChildKeyStruct(int child_class,
string switch_id,
}
/** FreeChildKeyStruct
- * * @Description : This function clears the void * of child key structures
- * * @param[in] : child class index - specifies the enum associated with
- * child class of switch
- * key_struct of child
- * * @return : return void
+ * @Description : This function clears the void * of child key structures
+ * @param[in] : child class index - specifies the enum associated with
+ * child_class-child class of switch
+ * key_struct-void * to key_struct of child
+ * @return : return void
* */
void Kt_Switch::FreeChildKeyStruct(int child_class,
void *key_struct) {
}
/** Fill_Attr_Syntax_Map
- * * @Description : This function fills the attributes associated
+ * @Description : This function fills the attributes associated
* with the class
- * * @param[in] : void
- * * @return : void
+ * @param[in] : none
+ * @return : none
* */
void Kt_Switch::Fill_Attr_Syntax_Map() {
+ map<string, Kt_Class_Attr_Syntax> attr_syntax_map;
Kt_Class_Attr_Syntax objKeyAttr1Syntax =
{ PFC_IPCTYPE_UINT8, 0, 0, 1, 32, true, "" };
- attr_syntax_map[CTR_NAME] = objKeyAttr1Syntax;
+ attr_syntax_map[CTR_NAME_STR] = objKeyAttr1Syntax;
Kt_Class_Attr_Syntax objKeyAttrSyntax =
{ PFC_IPCTYPE_UINT8, 0, 0, 1, 256, true, ""};
- attr_syntax_map[SWITCH_ID] = objKeyAttrSyntax;
+ attr_syntax_map[SWITCH_ID_STR] = objKeyAttrSyntax;
Kt_Class_Attr_Syntax objAttrDescSyntax =
{ PFC_IPCTYPE_STRING, 0, 0, 0, 128, false, "" };
- attr_syntax_map[SWITCH_DESCRIPTION] = objAttrDescSyntax;
+ attr_syntax_map[SWITCH_DESCRIPTION_STR] = objAttrDescSyntax;
Kt_Class_Attr_Syntax objAttrModelSyntax =
{ PFC_IPCTYPE_STRING, 0, 0, 0, 16, false, "" };
- attr_syntax_map[SWITCH_MODEL] = objAttrModelSyntax;
+ attr_syntax_map[SWITCH_MODEL_STR] = objAttrModelSyntax;
Kt_Class_Attr_Syntax objAttrIpSyntax =
{ PFC_IPCTYPE_IPV4, 0, 4294967295LL, 0, 0, false, "" };
- attr_syntax_map[SWITCH_IP_ADDRESS] = objAttrIpSyntax;
+ attr_syntax_map[SWITCH_IP_ADDRESS_STR] = objAttrIpSyntax;
Kt_Class_Attr_Syntax objAttrIPV6Syntax =
{ PFC_IPCTYPE_IPV6, 0, 4294967295LL, 0, 0, false, "" };
- attr_syntax_map[SWITCH_IPV6_ADDRESS] = objAttrIPV6Syntax;
+ attr_syntax_map[SWITCH_IPV6_ADDRESS_STR] = objAttrIPV6Syntax;
Kt_Class_Attr_Syntax objAttrAdminStatusSyntax =
{ PFC_IPCTYPE_UINT8, 0, 1, 0, 0, false, "" };
- attr_syntax_map[SWITCH_ADMIN_STATUS] = objAttrAdminStatusSyntax;
+ attr_syntax_map[SWITCH_ADMIN_STATUS_STR] = objAttrAdminStatusSyntax;
Kt_Class_Attr_Syntax objAttrDomainNameSyntax =
{ PFC_IPCTYPE_STRING, 0, 0, 0, 32, false, "" };
- attr_syntax_map[SWITCH_DOMAIN_NAME] = objAttrDomainNameSyntax;
+ attr_syntax_map[SWITCH_DOMAIN_NAME_STR] = objAttrDomainNameSyntax;
Kt_Class_Attr_Syntax objAttrValidSyntax =
{ PFC_IPCTYPE_STRING, 0, 0, 0, 6, false, "" };
- attr_syntax_map[SWITCH_VALID] = objAttrValidSyntax;
+ attr_syntax_map[SWITCH_VALID_STR] = objAttrValidSyntax;
+ attr_syntax_map_all[UNC_KT_SWITCH] = attr_syntax_map;
}
/** HandleOperStatus
- * * @Description: This function perform the required actions
+ * @Description: This function perform the required actions
* when oper status changes
- * * @param[in]: key_struct - key structure of kt switch
+ * @param[in]: data_type-type of database,UNC_DT_*
+ * key_struct - key structure of kt switch
* value_struct - value structure of kt switch
- * * @return: UPPL_RC_SUCCESS or UPPL_RC_ERR*
+ * @return: UPPL_RC_SUCCESS or UPPL_RC_ERR*,Success or associated error code
* */
-UpplReturnCode Kt_Switch::HandleOperStatus(uint32_t data_type,
+UpplReturnCode Kt_Switch::HandleOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void *key_struct,
void *value_struct) {
FN_START_TIME("HandleOperStatus", "Switch");
UpplSwitchOperStatus switch_oper_status = UPPL_SWITCH_OPER_UNKNOWN;
Kt_Controller controller;
UpplReturnCode read_status = controller.
- GetOperStatus(data_type, reinterpret_cast<void*>(&ctr_key),
+ GetOperStatus(db_conn, data_type, reinterpret_cast<void*>(&ctr_key),
ctrl_oper_status);
- if (read_status == UPPL_RC_SUCCESS) {
- pfc_log_info("Controller's oper_status %d", ctrl_oper_status);
- if (ctrl_oper_status ==
- (UpplControllerOperStatus) UPPL_CONTROLLER_OPER_UP) {
- pfc_log_info("Set Switch oper status as up");
- switch_oper_status = UPPL_SWITCH_OPER_UP;
- }
- } else {
+ if (read_status != UPPL_RC_SUCCESS) {
pfc_log_info("Controller's oper_status read returned failure");
+ return read_status;
}
+ vector<OperStatusHolder> ref_oper_status;
+ ADD_CTRL_OPER_STATUS(controller_name, ctrl_oper_status);
+ pfc_log_info("Controller's oper_status %d", ctrl_oper_status);
+ if (ctrl_oper_status ==
+ (UpplControllerOperStatus) UPPL_CONTROLLER_OPER_UP) {
+ pfc_log_info("Set Switch oper status as up");
+ switch_oper_status = UPPL_SWITCH_OPER_UP;
+ }
+
// Update oper_status in switch table
- return_code = SetOperStatus(data_type,
+ return_code = SetOperStatus(db_conn, data_type,
key_struct,
- switch_oper_status, true);
- pfc_log_info("Set Switch oper status %d", return_code);
+ switch_oper_status);
+ pfc_log_debug("Set Switch oper status %d", return_code);
// Call referred classes notify oper status functions
// Get all switch associated with controller
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
- vect_prim_keys.push_back(SWITCH_ID);
+ vect_prim_keys.push_back(CTR_NAME_STR);
+ vect_prim_keys.push_back(SWITCH_ID_STR);
// To traverse the list
vector<key_switch_t> vectSwitchKey;
list<vector<TableAttrSchema> > ::iterator iter_list;
pfc_log_debug(
"GetBulkRows called with controller_name %s, switch_id %s",
controller_name.c_str(), switch_id.c_str());
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- PhyUtil::FillDbSchema(SWITCH_ID, switch_id,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_ID, switch_id,
switch_id.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
- kt_switch_dbtableschema.set_table_name(UPPL_SWITCH_TABLE);
+ kt_switch_dbtableschema.set_table_name(unc::uppl::SWITCH_TABLE);
kt_switch_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_switch_dbtableschema.set_row_list(row_list);
GetBulkRows((unc_keytype_datatype_t)data_type,
UPPL_MAX_REP_CT,
kt_switch_dbtableschema,
- (unc_keytype_operation_t)UNC_OP_READ_SIBLING_BEGIN);
+ (unc_keytype_operation_t)UNC_OP_READ_SIBLING_BEGIN,
+ db_conn);
if (db_status != ODBCM_RC_SUCCESS) {
- pfc_log_info("ReadBulk failure");
+ pfc_log_info("No other switch available");
break;
}
for (iter_list = kt_switch_dbtableschema.row_list_.begin();
++iter_vector) {
/* Get attribute name of a row */
TableAttrSchema tab_attr_schema = (*iter_vector);
- if (tab_attr_schema.table_attribute_name == "controller_name") {
- PhyUtil::GetValueFromDbSchema(tab_attr_schema, controller_name,
- DATATYPE_UINT8_ARRAY_32);
- pfc_log_debug("Controller Name From GetValueFromDbSchema is %s",
- controller_name.c_str());
- memcpy(key_switch.ctr_key.controller_name,
- controller_name.c_str(),
- controller_name.length() +1);
- } else if (tab_attr_schema.table_attribute_name == "switch_id") {
- PhyUtil::GetValueFromDbSchema(tab_attr_schema, switch_id,
- DATATYPE_UINT8_ARRAY_256);
- pfc_log_debug("Switch_id from GetValueFromDbSchema is %s",
- switch_id.c_str());
- memcpy(key_switch.switch_id,
- switch_id.c_str(),
- switch_id.length() +1);
+ switch (tab_attr_schema.table_attribute_name) {
+ case unc::uppl::CTR_NAME:
+ PhyUtil::GetValueFromDbSchemaStr(tab_attr_schema,
+ key_switch.ctr_key.controller_name,
+ DATATYPE_UINT8_ARRAY_32);
+ pfc_log_debug("Controller Name is %s",
+ key_switch.ctr_key.controller_name);
+ controller_name = reinterpret_cast<const char*>
+ (key_switch.ctr_key.controller_name);
+ break;
+ case unc::uppl::SWITCH_ID:
+ PhyUtil::GetValueFromDbSchemaStr(tab_attr_schema,
+ key_switch.switch_id,
+ DATATYPE_UINT8_ARRAY_256);
+ pfc_log_debug("Switch_id from is %s", key_switch.switch_id);
+ switch_id = reinterpret_cast<const char*>
+ (key_switch.switch_id);
+ break;
+ default:
+ break;
}
}
vectSwitchKey.push_back(key_switch);
}
+ if (kt_switch_dbtableschema.row_list_.size() < UPPL_MAX_REP_CT) {
+ pfc_log_info("No other switch available");
+ break;
+ }
}
vector<key_switch_t>::iterator keyItr =
vectSwitchKey.begin();
for (; keyItr != vectSwitchKey.end(); ++keyItr) {
- // key_switch_t objKeySwitch;
- return_code = NotifyOperStatus(data_type,
- reinterpret_cast<void *> (&(*keyItr)), NULL);
+ key_switch_t objKeySwitch = *keyItr;
+ ADD_SWITCH_OPER_STATUS(objKeySwitch, switch_oper_status);
+ return_code = NotifyOperStatus(db_conn, data_type,
+ reinterpret_cast<void *> (&objKeySwitch),
+ NULL, ref_oper_status);
pfc_log_debug("Notify Oper status return %d", return_code);
}
FN_END_TIME("HandleOperStatus", "Switch");
+ ClearOperStatusHolder(ref_oper_status);
return return_code;
}
/** NotifyOperStatus
- * * @Description: This function notifies the other key types
+ * @Description: This function notifies the other key types
* when the oper status changes
- * * @param[in] : key_struct - key structure of kt switch
+ * @param[in] : key_struct - key structure of kt switch
* values_struct - value structure of kt switch
- * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
+ * data_type-UNC_DT_*,type of database
+ * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*,Success or associated error code
* */
-UpplReturnCode Kt_Switch::NotifyOperStatus(uint32_t data_type,
- void* key_struct,
- void* value_struct) {
+UpplReturnCode Kt_Switch::NotifyOperStatus(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
+ void* key_struct,
+ void* value_struct,
+ vector<OperStatusHolder> &ref_oper_status) {
UpplReturnCode return_code = UPPL_RC_SUCCESS;
key_switch_t *obj_key_switch = reinterpret_cast<key_switch_t*>(key_struct);
// Notify Kt_Ctr_Domain
Kt_Ctr_Domain ctr_domain_obj;
key_ctr_domain_t ctr_domain_key_obj;
+ memset(&ctr_domain_key_obj, 0, sizeof(key_ctr_domain_t));
memcpy(ctr_domain_key_obj.ctr_key.controller_name,
controller_name.c_str(),
controller_name.length()+1);
return_code = ctr_domain_obj.HandleOperStatus(
- data_type,
+ db_conn, data_type,
reinterpret_cast<void *> (&ctr_domain_key_obj), NULL);
- pfc_log_info("HandleOperStatus for ctr domain class %d",
- return_code);
+ pfc_log_debug("HandleOperStatus for ctr domain class %d",
+ return_code);
// Notify Kt_Logical_Port
key_logical_port obj_key_logical_port;
+ memset(&obj_key_logical_port, 0, sizeof(obj_key_logical_port));
memcpy(obj_key_logical_port.domain_key.ctr_key.controller_name,
controller_name.c_str(), (controller_name.length())+1);
- memset(obj_key_logical_port.domain_key.domain_name, 0, 32);
- memset(obj_key_logical_port.port_id, 0, 320);
Kt_LogicalPort logical_port;
val_logical_port_st_t obj_val_logical_port;
memset(&obj_val_logical_port, 0, sizeof(val_logical_port_st_t));
obj_val_logical_port.logical_port.valid[kIdxLogicalPortSwitchId] =
UNC_VF_VALID;
return_code = logical_port.HandleOperStatus(
- data_type,
+ db_conn, data_type,
reinterpret_cast<void*>(&obj_key_logical_port),
- reinterpret_cast<void*>(&obj_val_logical_port));
- pfc_log_info("Switch:Handle Oper Status for Logical Port Class %d",
- return_code);
+ reinterpret_cast<void*>(&obj_val_logical_port),
+ ref_oper_status, UNC_KT_SWITCH);
+ pfc_log_debug("Switch:Handle Oper Status for Logical Port Class %d",
+ return_code);
// Notify Kt_Port
Kt_Port port;
key_port_t obj_key_port;
+ memset(&obj_key_port, 0, sizeof(obj_key_port));
memcpy(obj_key_port.sw_key.ctr_key.controller_name,
controller_name.c_str(),
controller_name.length()+1);
memcpy(obj_key_port.sw_key.switch_id,
switch_id.c_str(),
switch_id.length()+1);
- memset(obj_key_port.port_id, 0, 32);
pfc_log_debug("HandleOperStatus for port with sw id: %s", switch_id.c_str());
return_code = port.HandleOperStatus(
- data_type,
+ db_conn, data_type,
reinterpret_cast<void *>(&obj_key_port),
NULL);
- pfc_log_info("Switch:HandleOperStatus for port class %d", return_code);
-
- /* Notify Kt_Link
- Kt_Link link;
- key_link_t obj_key_link1;
- memcpy(obj_key_link1.ctr_key.controller_name,
- controller_name.c_str(),
- controller_name.length() +1);
- memcpy(obj_key_link1.switch_id1,
- switch_id.c_str(),
- switch_id.length() +1);
- memset(obj_key_link1.switch_id2, 0, 256);
- memset(obj_key_link1.port_id1, 0, 32);
- memset(obj_key_link1.port_id2, 0, 32);
- return_code = link.HandleOperStatus(reinterpret_cast<void *>(&obj_key_link1),
- NULL);
- pfc_log_info("HandleOperStatus for Link class %d", return_code);
-
- key_link_t obj_key_link2;
- memcpy(obj_key_link2.ctr_key.controller_name,
- controller_name.c_str(),
- controller_name.length() +1);
- memcpy(obj_key_link2.switch_id2,
- switch_id.c_str(),
- switch_id.length() +1);
- memset(obj_key_link2.switch_id1, 0, 256);
- memset(obj_key_link2.port_id1, 0, 32);
- memset(obj_key_link2.port_id2, 0, 32);
- return_code = link.HandleOperStatus(
- data_type, reinterpret_cast<void*>(&obj_key_link2), NULL);
- pfc_log_info("HandleOperStatus for link class %d", return_code);*/
-
+ pfc_log_debug("Switch:HandleOperStatus for port class %d", return_code);
return return_code;
}
/** GetOperStatus
- * * @Description: This function updates the oper status in db
- * * @param[in]: key_struct - key structure of kt switch
+ * @Description: This function updates the oper status in db
+ * @param[in]: key_struct - key structure of kt switch
* oper_status - specifies the oper status
- * * @return: UPPL_RC_SUCCESS or UPPL_RC_ERR*
+ * data_type-UNC_DT_*,type of database
+ * @return: UPPL_RC_SUCCESS or UPPL_RC_ERR*,Success or associated error code
* */
-UpplReturnCode Kt_Switch::GetOperStatus(uint32_t data_type,
+UpplReturnCode Kt_Switch::GetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
uint8_t &oper_status) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
key_switch *obj_key_switch =
reinterpret_cast<key_switch_t*>(key_struct);
- TableAttrSchema kt_switch_table_attr_schema;
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
vector<string> vect_prim_keys;
string controller_name = (const char*)obj_key_switch->ctr_key.controller_name;
string switch_id = (const char*)obj_key_switch->switch_id;
if (!controller_name.empty()) {
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
}
if (!switch_id.empty()) {
- vect_prim_keys.push_back(SWITCH_ID);
+ vect_prim_keys.push_back(SWITCH_ID_STR);
}
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- PhyUtil::FillDbSchema(SWITCH_ID, switch_id,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_ID, switch_id,
switch_id.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
string oper_value;
- PhyUtil::FillDbSchema(SWITCH_OPER_STATUS, oper_value,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_OPER_STATUS, oper_value,
oper_value.length(), DATATYPE_UINT16,
vect_table_attr_schema);
DBTableSchema kt_switch_dbtableschema;
- kt_switch_dbtableschema.set_table_name(UPPL_SWITCH_TABLE);
+ kt_switch_dbtableschema.set_table_name(unc::uppl::SWITCH_TABLE);
kt_switch_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_switch_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS update_db_status =
physical_layer->get_odbc_manager()->GetOneRow(
(unc_keytype_datatype_t)data_type,
- kt_switch_dbtableschema);
+ kt_switch_dbtableschema, db_conn);
if (update_db_status != ODBCM_RC_SUCCESS) {
- // log error
- pfc_log_error("oper_status read operation failed");
+ pfc_log_info("oper_status read operation failed %d", update_db_status);
return UPPL_RC_ERR_DB_GET;
}
// read the oper status value
- list < vector<TableAttrSchema> > res_switch_row_list =
+ list < vector<TableAttrSchema> >& res_switch_row_list =
kt_switch_dbtableschema.get_row_list();
list < vector<TableAttrSchema> >::iterator res_switch_iter =
res_switch_row_list.begin();
- // populate IPC value structure based on the response recevied from DB
+ // populate IPC value structure based on the response received from DB
for (; res_switch_iter!= res_switch_row_list.end(); ++res_switch_iter) {
vector<TableAttrSchema> res_switch_table_attr_schema = (*res_switch_iter);
vector<TableAttrSchema>:: iterator vect_switch_iter =
++vect_switch_iter) {
// populate values from switch_table
TableAttrSchema tab_schema = (*vect_switch_iter);
- string attr_name = tab_schema.table_attribute_name;
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
string attr_value;
- if (attr_name == "oper_status") {
+ if (attr_name == unc::uppl::SWITCH_OPER_STATUS) {
PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
DATATYPE_UINT16);
oper_status = atoi(attr_value.c_str());
}
/** SetOperStatus
- * * @Description: This function updates the oper status in db
- * * *@param[in]: key_struct - key structure of kt switch
+ * @Description: This function updates the oper status in db
+ * @param[in]: key_struct - key structure of kt switch
* oper_status - specifies the oper status of kt switch
- * is_single_key - bool variable
- * *@return: UPPL_RC_SUCCESS or UPPL_RC_ERR*
+ * data_type-UNC_DT_*,type of database
+ * @return: UPPL_RC_SUCCESS or UPPL_RC_ERR*,Success or associated error code
* */
-UpplReturnCode Kt_Switch::SetOperStatus(uint32_t data_type,
+UpplReturnCode Kt_Switch::SetOperStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void *key_struct,
- UpplSwitchOperStatus oper_status,
- bool is_single_key) {
+ UpplSwitchOperStatus oper_status) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
key_switch_t *obj_key_switch =
reinterpret_cast<key_switch_t*>(key_struct);
- // TableAttrSchema kt_logical_port_table_attr_schema;
+ uint8_t old_oper_status = 0;
+ UpplReturnCode read_status = GetOperStatus(db_conn, data_type,
+ key_struct,
+ old_oper_status);
+ if (read_status != UPPL_RC_SUCCESS) {
+ pfc_log_info("Unable to get the old oper status of switch");
+ return read_status;
+ }
+
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
vector<string> vect_prim_keys;
string switch_id = (const char*)obj_key_switch->switch_id;
string controller_name = (const char*)obj_key_switch->ctr_key.controller_name;
if (!controller_name.empty()) {
- vect_prim_keys.push_back(CTR_NAME);
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ vect_prim_keys.push_back(CTR_NAME_STR);
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
}
- if (is_single_key == false) {
- if (!switch_id.empty()) {
- vect_prim_keys.push_back(SWITCH_ID);
- PhyUtil::FillDbSchema(SWITCH_ID, switch_id,
- switch_id.length(), DATATYPE_UINT8_ARRAY_256,
- vect_table_attr_schema);
- }
+ if (!switch_id.empty()) {
+ vect_prim_keys.push_back(SWITCH_ID_STR);
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_ID, switch_id,
+ switch_id.length(), DATATYPE_UINT8_ARRAY_256,
+ vect_table_attr_schema);
}
string oper_value = PhyUtil::uint8tostr(oper_status);
- PhyUtil::FillDbSchema(SWITCH_OPER_STATUS, oper_value,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_OPER_STATUS, oper_value,
oper_value.length(), DATATYPE_UINT16,
vect_table_attr_schema);
DBTableSchema kt_switch_dbtableschema;
- kt_switch_dbtableschema.set_table_name(UPPL_SWITCH_TABLE);
+ kt_switch_dbtableschema.set_table_name(unc::uppl::SWITCH_TABLE);
kt_switch_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_switch_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS update_db_status =
physical_layer->get_odbc_manager()->UpdateOneRow(
(unc_keytype_datatype_t)data_type,
- kt_switch_dbtableschema);
- if (update_db_status != ODBCM_RC_SUCCESS) {
+ kt_switch_dbtableschema, db_conn);
+ if (update_db_status == ODBCM_RC_ROW_NOT_EXISTS) {
+ pfc_log_info("No instance available for update");
+ } else if (update_db_status != ODBCM_RC_SUCCESS) {
// log error
pfc_log_error("oper_status update operation failed");
return UPPL_RC_ERR_DB_UPDATE;
} else {
// Notify operstatus change to northbound
val_switch_st old_val_switch, new_val_switch;
- uint8_t old_oper_status = 0;
- UpplReturnCode read_status = GetOperStatus(data_type,
- key_struct,
- old_oper_status);
- if (read_status == UPPL_RC_SUCCESS) {
- memset(old_val_switch.valid, 0, 6);
- old_val_switch.oper_status = old_oper_status;
- old_val_switch.valid[kIdxSwitchOperStatus] = UNC_VF_VALID;
- memset(new_val_switch.valid, 0, 6);
- new_val_switch.oper_status = oper_status;
- new_val_switch.valid[kIdxSwitchOperStatus] = UNC_VF_VALID;
- int err = 0;
- // Send notification to Northbound
- ServerEvent ser_evt((pfc_ipcevtype_t)UPPL_EVENTS_KT_SWITCH, err);
- ser_evt.addOutput((uint32_t)UNC_OP_UPDATE);
- ser_evt.addOutput(data_type);
- ser_evt.addOutput((uint32_t)UPPL_EVENTS_KT_SWITCH);
- ser_evt.addOutput(*obj_key_switch);
- ser_evt.addOutput(new_val_switch);
- ser_evt.addOutput(old_val_switch);
+ memset(old_val_switch.valid, 0, 6);
+ old_val_switch.oper_status = old_oper_status;
+ old_val_switch.valid[kIdxSwitchOperStatus] = UNC_VF_VALID;
+ memset(new_val_switch.valid, 0, 6);
+ new_val_switch.oper_status = oper_status;
+ new_val_switch.valid[kIdxSwitchOperStatus] = UNC_VF_VALID;
+ int err = 0;
+ // Send notification to Northbound
+ ServerEvent ser_evt((pfc_ipcevtype_t)UPPL_EVENTS_KT_SWITCH, err);
+ northbound_event_header rsh = {UNC_OP_UPDATE,
+ data_type,
+ UNC_KT_SWITCH};
+ err = PhyUtil::sessOutNBEventHeader(ser_evt, rsh);
+ err |= ser_evt.addOutput(*obj_key_switch);
+ err |= ser_evt.addOutput(new_val_switch);
+ err |= ser_evt.addOutput(old_val_switch);
+ if (err == 0) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
// Notify operstatus modifications
UpplReturnCode status = (UpplReturnCode) physical_layer
->get_ipc_connection_manager()->SendEvent(&ser_evt);
pfc_log_debug("Event notification status %d", status);
+ } else {
+ pfc_log_info("Error creating ServerEvent object");
}
}
return UPPL_RC_SUCCESS;
}
/** GetAlarmStatus
- * * @Description: This function updates the alarm status in db
- * * @param[in]: key_struct - key structure of kt switch
+ * @Description: This function updates the alarm status in db
+ * @param[in]: key_struct - key structure of kt switch
* alarm status - specifies the alarm status
- * * @return: UPPL_RC_SUCCESS or UPPL_RC_ERR*
+ * data_type - UNC_DT_*,type of database
+ * @return: UPPL_RC_SUCCESS or UPPL_RC_ERR*,Success or associated error code
* */
-UpplReturnCode Kt_Switch::GetAlarmStatus(uint32_t data_type,
+UpplReturnCode Kt_Switch::GetAlarmStatus(OdbcmConnectionHandler *db_conn,
+ uint32_t data_type,
void* key_struct,
uint64_t &alarms_status) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
key_switch *obj_key_switch =
reinterpret_cast<key_switch_t*>(key_struct);
- TableAttrSchema kt_switch_table_attr_schema;
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
string controller_name = (const char*)obj_key_switch->ctr_key.controller_name;
string switch_id = (const char*)obj_key_switch->switch_id;
vector<string> vect_prim_keys;
if (!controller_name.empty()) {
- vect_prim_keys.push_back(CTR_NAME);
+ vect_prim_keys.push_back(CTR_NAME_STR);
}
if (!switch_id.empty()) {
- vect_prim_keys.push_back(SWITCH_ID);
+ vect_prim_keys.push_back(SWITCH_ID_STR);
}
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- PhyUtil::FillDbSchema(SWITCH_ID, switch_id,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_ID, switch_id,
switch_id.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
string value;
- PhyUtil::FillDbSchema(SWITCH_ALARM_STATUS, value,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_ALARM_STATUS, value,
value.length(), DATATYPE_UINT64,
vect_table_attr_schema);
DBTableSchema kt_switch_dbtableschema;
- kt_switch_dbtableschema.set_table_name(UPPL_SWITCH_TABLE);
+ kt_switch_dbtableschema.set_table_name(unc::uppl::SWITCH_TABLE);
kt_switch_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_switch_dbtableschema.set_row_list(row_list);
ODBCM_RC_STATUS update_db_status =
physical_layer->get_odbc_manager()->GetOneRow(
(unc_keytype_datatype_t)data_type,
- kt_switch_dbtableschema);
+ kt_switch_dbtableschema, db_conn);
if (update_db_status != ODBCM_RC_SUCCESS) {
- // log error
- pfc_log_error("oper_status read operation failed");
+ pfc_log_info("oper_status read operation failed %d", update_db_status);
return UPPL_RC_ERR_DB_GET;
}
// read the oper status value
- list < vector<TableAttrSchema> > res_switch_row_list =
+ list < vector<TableAttrSchema> >& res_switch_row_list =
kt_switch_dbtableschema.get_row_list();
list < vector<TableAttrSchema> >::iterator res_switch_iter =
res_switch_row_list.begin();
- // populate IPC value structure based on the response recevied from DB
+ // populate IPC value structure based on the response received from DB
for (; res_switch_iter!= res_switch_row_list.end(); ++res_switch_iter) {
vector<TableAttrSchema> res_switch_table_attr_schema = (*res_switch_iter);
vector<TableAttrSchema>:: iterator vect_switch_iter =
++vect_switch_iter) {
// populate values from switch_table
TableAttrSchema tab_schema = (*vect_switch_iter);
- string attr_name = tab_schema.table_attribute_name;
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
string attr_value;
- if (attr_name == "alarms_status") {
+ if (attr_name == unc::uppl::SWITCH_ALARM_STATUS) {
PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
DATATYPE_UINT64);
alarms_status = atol(attr_value.c_str());
return UPPL_RC_SUCCESS;
}
+/** UpdateSwitchValidFlag
+ * @Description: This function updates the valid flag of switch
+ * @param[in]: key_struct-key instance for KT_SWICTH
+ * val_struct-value instance for KT_SWITCH
+ * val_switch_valid_st-pointer to val_switch_st_t
+ * @param[out]: new_valid_val-any value of unc_keytype_validflag_t
+ * @return: UPPL_RC_SUCCESS or UPPL_RC_ERR*,Success or associated error code
+ * */
UpplReturnCode Kt_Switch::UpdateSwitchValidFlag(
+ OdbcmConnectionHandler *db_conn,
void *key_struct, void *val_struct,
val_switch_st_t &val_switch_valid_st,
- unc_keytype_validflag_t new_valid_val) {
+ unc_keytype_validflag_t new_valid_val,
+ uint32_t data_type) {
UpplReturnCode return_code = UPPL_RC_SUCCESS;
vector<void *> vect_switch_key;
vector<void *> vect_switch_val;
vect_switch_key.push_back(key_struct);
- return_code = ReadInternal(vect_switch_key, vect_switch_val,
- UNC_DT_STATE, UNC_OP_READ);
+ vect_switch_val.push_back(val_struct);
+ return_code = ReadInternal(db_conn, vect_switch_key, vect_switch_val,
+ data_type, UNC_OP_READ);
if (return_code != UPPL_RC_SUCCESS) {
return return_code;
}
reinterpret_cast<val_switch_st_t *>(val_struct);
val_switch_st_t *obj_new_val_switch =
reinterpret_cast<val_switch_st_t *>(vect_switch_val[0]);
+ key_switch_t *switch_key =
+ reinterpret_cast<key_switch_t *>(vect_switch_key[0]);
if (obj_new_val_switch == NULL) {
pfc_log_debug("update switch valid ret null val");
return return_code;
// new_valid is valid then return the val st with valid arr
val_switch_valid_st = *obj_new_val_switch;
delete obj_new_val_switch;
- key_switch_t *switch_key =
- reinterpret_cast<key_switch_t*> (vect_switch_key[0]);
- if (switch_key != NULL) {
- delete switch_key;
- }
+ obj_new_val_switch = NULL;
+ delete switch_key;
+ switch_key = NULL;
return return_code;
}
// new_valid is invalid update the particular attribute
uint32_t operation_type = UNC_OP_UPDATE;
stringstream ss_new_valid;
-
// desc
unsigned int valid_val = PhyUtil::uint8touint(
obj_val_switch->switch_val.valid[kIdxSwitchDescription]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- ss_new_valid << new_valid_val;
+ ss_new_valid << PhyUtil::uint8touint(new_valid_val);
} else {
pfc_log_debug(
"invalid value for switch_description ignore the value");
- ss_new_valid <<
- obj_new_val_switch->switch_val.valid[kIdxSwitchDescription];
+ ss_new_valid << PhyUtil::uint8touint(
+ obj_new_val_switch->switch_val.valid[kIdxSwitchDescription]);
}
// valid val of model
valid_val = PhyUtil::uint8touint(
obj_val_switch->switch_val.valid[kIdxSwitchModel]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- ss_new_valid << new_valid_val;
+ ss_new_valid << PhyUtil::uint8touint(new_valid_val);
} else {
pfc_log_debug("invalid value for model ignore the value");
- ss_new_valid << obj_new_val_switch->switch_val.valid[kIdxSwitchModel];
+ ss_new_valid << PhyUtil::uint8touint(
+ obj_new_val_switch->switch_val.valid[kIdxSwitchModel]);
}
// valid val of ip
valid_val = PhyUtil::uint8touint(
obj_val_switch->switch_val.valid[kIdxSwitchIPAddress]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- ss_new_valid << new_valid_val;
+ ss_new_valid << PhyUtil::uint8touint(new_valid_val);
} else {
pfc_log_debug("invalid value for ip ignore the value");
- ss_new_valid <<
- obj_new_val_switch->switch_val.valid[kIdxSwitchIPAddress];
+ ss_new_valid << PhyUtil::uint8touint(
+ obj_new_val_switch->switch_val.valid[kIdxSwitchIPAddress]);
}
// valid val of ipv6
valid_val = PhyUtil::uint8touint(
obj_val_switch->switch_val.valid[kIdxSwitchIPV6Address]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- ss_new_valid << new_valid_val;
+ ss_new_valid << PhyUtil::uint8touint(new_valid_val);
} else {
pfc_log_debug("invalid value for ipv6 ignore the value");
- ss_new_valid <<
- obj_new_val_switch->switch_val.valid[kIdxSwitchIPV6Address];
+ ss_new_valid << PhyUtil::uint8touint(
+ obj_new_val_switch->switch_val.valid[kIdxSwitchIPV6Address]);
}
// valid val of SwitchAdminStatus
valid_val = PhyUtil::uint8touint(
obj_val_switch->switch_val.valid[kIdxSwitchAdminStatus]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- ss_new_valid << new_valid_val;
+ ss_new_valid << PhyUtil::uint8touint(new_valid_val);
} else {
pfc_log_debug("invalid value for adminstatus ignore the value");
- ss_new_valid <<
- obj_new_val_switch->switch_val.valid[kIdxSwitchAdminStatus];
+ ss_new_valid << PhyUtil::uint8touint(
+ obj_new_val_switch->switch_val.valid[kIdxSwitchAdminStatus]);
}
// valid val of domain name
valid_val = PhyUtil::uint8touint(
obj_val_switch->switch_val.valid[kIdxSwitchDomainName]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- ss_new_valid << new_valid_val;
+ ss_new_valid << PhyUtil::uint8touint(new_valid_val);
} else {
- ss_new_valid <<
- obj_new_val_switch->switch_val.valid[kIdxSwitchDomainName];
+ ss_new_valid << PhyUtil::uint8touint(
+ obj_new_val_switch->switch_val.valid[kIdxSwitchDomainName]);
pfc_log_debug("invalid value for DomainName ignore the value");
}
// valid val of oper_Status
valid_val = PhyUtil::uint8touint(
obj_val_switch->valid[kIdxSwitchOperStatus]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- ss_new_valid << new_valid_val;
+ ss_new_valid << PhyUtil::uint8touint(new_valid_val);
} else {
- ss_new_valid << obj_new_val_switch->valid[kIdxSwitchOperStatus];
+ ss_new_valid << PhyUtil::uint8touint(
+ obj_new_val_switch->valid[kIdxSwitchOperStatus]);
pfc_log_debug("invalid value for operstatus ignore the value");
}
// valid val of manufacturer
valid_val = PhyUtil::uint8touint(
obj_val_switch->valid[kIdxSwitchManufacturer]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- ss_new_valid << new_valid_val;
+ ss_new_valid << PhyUtil::uint8touint(new_valid_val);
} else {
- ss_new_valid << obj_new_val_switch->valid[kIdxSwitchManufacturer];
+ ss_new_valid << PhyUtil::uint8touint(
+ obj_new_val_switch->valid[kIdxSwitchManufacturer]);
pfc_log_debug("invalid value for manufacturer ignore the value");
}
// valid val of hardware
valid_val = PhyUtil::uint8touint(
obj_val_switch->valid[kIdxSwitchHardware]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- ss_new_valid << new_valid_val;
+ ss_new_valid << PhyUtil::uint8touint(new_valid_val);
} else {
- ss_new_valid << obj_new_val_switch->valid[kIdxSwitchHardware];
+ ss_new_valid << PhyUtil::uint8touint(
+ obj_new_val_switch->valid[kIdxSwitchHardware]);
pfc_log_debug("invalid value for hardware ignore the value");
}
// valid val of software
valid_val = PhyUtil::uint8touint(
obj_val_switch->valid[kIdxSwitchSoftware]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- ss_new_valid << new_valid_val;
+ ss_new_valid << PhyUtil::uint8touint(new_valid_val);
} else {
- ss_new_valid << obj_new_val_switch->valid[kIdxSwitchSoftware];
+ ss_new_valid << PhyUtil::uint8touint(
+ obj_new_val_switch->valid[kIdxSwitchSoftware]);
pfc_log_debug("invalid value for software ignore the value");
}
// valid val of alarmstatus
valid_val = PhyUtil::uint8touint(
obj_val_switch->valid[kIdxSwitchAlarmStatus]);
if (PhyUtil::IsValidValue(operation_type, valid_val) == true) {
- ss_new_valid << new_valid_val;
+ ss_new_valid << PhyUtil::uint8touint(new_valid_val);
} else {
- ss_new_valid << obj_new_val_switch->valid[kIdxSwitchAlarmStatus];
+ ss_new_valid << PhyUtil::uint8touint(
+ obj_new_val_switch->valid[kIdxSwitchAlarmStatus]);
pfc_log_debug("invalid value for alarmstatus ignore the value");
}
+ pfc_log_debug("valid value to be set: %s", (ss_new_valid.str()).c_str());
return_code = PopulateSchemaForValidFlag(
- key_struct,
+ db_conn, reinterpret_cast<void*> (switch_key),
reinterpret_cast<void*> (&obj_new_val_switch),
- ss_new_valid.str().c_str());
+ ss_new_valid.str(), data_type);
delete obj_new_val_switch;
obj_new_val_switch = NULL;
- key_switch_t *switch_key = reinterpret_cast<key_switch_t*>
- (vect_switch_key[0]);
- if (switch_key != NULL) {
- delete switch_key;
- switch_key = NULL;
- }
+ delete switch_key;
+ switch_key = NULL;
}
return return_code;
}
/** PopulateSchemaForValidFlag
- * * @Description : This function updates the valid flag value
+ * @Description : This function updates the valid flag value
* of the port
- * * @param[in] : key_struct, value_struct
- * * @return : success/failure
+ * @param[in] : key_struct-void* to switch key instance
+ * value_struct-void* to switch value instance
+ * valid_new-string indicating the valid flag
+ * @return :Success or associated error code,UPPL_RC_SUCCESS/UPPL_RC_ERR_*
*/
-UpplReturnCode Kt_Switch::PopulateSchemaForValidFlag(void* key_struct,
- void* val_struct,
- string valid_new) {
+UpplReturnCode Kt_Switch::PopulateSchemaForValidFlag(
+ OdbcmConnectionHandler *db_conn,
+ void* key_struct,
+ void* val_struct,
+ string valid_new,
+ uint32_t data_type) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
key_switch_t *obj_key_switch=
reinterpret_cast<key_switch_t*>(key_struct);
- TableAttrSchema kt_switch_table_attr_schema;
vector<TableAttrSchema> vect_table_attr_schema;
list < vector<TableAttrSchema> > row_list;
vector<string> vect_prim_keys;
- vect_prim_keys.push_back(CTR_NAME);
- vect_prim_keys.push_back(SWITCH_ID);
+ vect_prim_keys.push_back(CTR_NAME_STR);
+ vect_prim_keys.push_back(SWITCH_ID_STR);
string switch_id = (const char*)obj_key_switch->switch_id;
string controller_name = (const char*)obj_key_switch->ctr_key.controller_name;
- PhyUtil::FillDbSchema(CTR_NAME, controller_name,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- PhyUtil::FillDbSchema(SWITCH_ID, switch_id,
- switch_id.length(), DATATYPE_UINT8_ARRAY_32,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_ID, switch_id,
+ switch_id.length(), DATATYPE_UINT8_ARRAY_256,
vect_table_attr_schema);
- pfc_log_debug("valid new val:%s", valid_new.c_str());
- PhyUtil::FillDbSchema(SWITCH_VALID, valid_new.c_str(),
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_VALID, valid_new.c_str(),
11, DATATYPE_UINT8_ARRAY_11,
vect_table_attr_schema);
DBTableSchema kt_switch_dbtableschema;
- kt_switch_dbtableschema.set_table_name(UPPL_SWITCH_TABLE);
+ kt_switch_dbtableschema.set_table_name(unc::uppl::SWITCH_TABLE);
kt_switch_dbtableschema.set_primary_keys(vect_prim_keys);
row_list.push_back(vect_table_attr_schema);
kt_switch_dbtableschema.set_row_list(row_list);
// Call ODBCManager and update
ODBCM_RC_STATUS update_db_status =
physical_layer->get_odbc_manager()->UpdateOneRow(
- UNC_DT_STATE, kt_switch_dbtableschema);
+ (unc_keytype_datatype_t)data_type, kt_switch_dbtableschema, db_conn);
if (update_db_status != ODBCM_RC_SUCCESS) {
// log error
pfc_log_error("domain id update operation failed");
}
/** FrameValidValue
- * * @Description : This function converts the string value from db to uint8
- * * * @param[in] : Attribute value and val_ctr_st
- * * * @return : Success or associated error code
+ * @Description : This function converts the string value from db to uint8
+ * @param[in] : attr_value-string containg the attribute value
+ * obj_val_switch- object of val_switch_st
+ * @return : Success or associated error code,UPPL_RC_SUCCESS/UPPL_RC_ERR_*
* */
void Kt_Switch::FrameValidValue(string attr_value,
val_switch_st &obj_val_switch) {
}
/** GetSwitchValStructure
- * * @Description : This function reads the values given in val_switch structure
- * * @param[in] : DBTableSchema - DBtableschema associated with KT_Switch
- * key_struct - key instance of Kt_Switch
- * val_struct - val instance of Kt_Switch
- * operation_type - UNC_OP*
- * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
+ * @Description : This function reads the values given in
+ * val_switch structure
+ * @param[in] : obj_val_switch-instance of val_switch_st_t
+ * vect_table_attr_schema- instance of vector<TableAttrSchema>
+ * vect_prim_keys-vector of string containing keys
+ * val_switch_valid_st-instance of val_switch_st_t
+ * valid-stringstream instance
+ * operation_type - UNC_OP*,type of operation requested
+ * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*,Success or associated error code
* */
void Kt_Switch::GetSwitchValStructure(
+ OdbcmConnectionHandler *db_conn,
val_switch_st_t *obj_val_switch,
vector<TableAttrSchema> &vect_table_attr_schema,
vector<string> &vect_prim_keys,
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(SWITCH_DESCRIPTION, value,
- value.length(), DATATYPE_UINT8_ARRAY_128,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_DESCRIPTION, SWITCH_DESCRIPTION_STR,
+ value, value.length(), DATATYPE_UINT8_ARRAY_128,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
value.clear();
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(SWITCH_MODEL, value,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_MODEL, SWITCH_MODEL_STR, value,
value.length(), DATATYPE_UINT8_ARRAY_16,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
value.clear();
// Ip_address
char *ip_value = new char[16];
+ memset(ip_value, '\0', 16);
if (obj_val_switch != NULL && valid_value_struct == UNC_VF_VALID) {
valid_val = PhyUtil::uint8touint(
obj_val_switch->switch_val.
valid[kIdxSwitchIPAddress]);
- pfc_log_info("ip_address : %d",
- obj_val_switch->switch_val.ip_address.s_addr);
+ pfc_log_debug("ip_address : %d",
+ obj_val_switch->switch_val.ip_address.s_addr);
inet_ntop(AF_INET, &obj_val_switch->switch_val.ip_address,
ip_value, INET_ADDRSTRLEN);
- pfc_log_info("ip_address: %s", ip_value);
+ pfc_log_debug("ip_address: %s", ip_value);
if (operation_type == UNC_OP_UPDATE) {
prev_db_val =
PhyUtil::uint8touint(
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(SWITCH_IP_ADDRESS, ip_value,
- strlen(ip_value), DATATYPE_IPV4,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_IP_ADDRESS, SWITCH_IP_ADDRESS_STR,
+ ip_value, strlen(ip_value), DATATYPE_IPV4,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
delete []ip_value;
// IPV6 Address
ip_value = new char[16];
+ memset(ip_value, '\0', 16);
if (obj_val_switch != NULL && valid_value_struct == UNC_VF_VALID) {
valid_val = PhyUtil::uint8touint(obj_val_switch->switch_val.
valid[kIdxSwitchIPV6Address]);
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(SWITCH_IPV6_ADDRESS, ip_value,
- strlen(ip_value), DATATYPE_IPV6,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_IPV6_ADDRESS, SWITCH_IPV6_ADDRESS_STR,
+ ip_value, strlen(ip_value), DATATYPE_IPV6,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
delete []ip_value;
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(SWITCH_ADMIN_STATUS, value,
- value.length(), DATATYPE_UINT16,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_ADMIN_STATUS, SWITCH_ADMIN_STATUS_STR,
+ value, value.length(), DATATYPE_UINT16,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
value.clear();
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(SWITCH_DOMAIN_NAME, value,
- value.length(), DATATYPE_UINT8_ARRAY_32,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_DOMAIN_NAME, SWITCH_DOMAIN_NAME_STR,
+ value, value.length(), DATATYPE_UINT8_ARRAY_32,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
return;
}
/** GetSwitchStateValStructure
- * * @Description : This function reads the values given in val_switch_st structure
- * * @param[in] : DBTableSchema - DBtableschema associated with KT_Switch
- * key_struct - key instance of Kt_Switch
- * val_struct - val instance of Kt_Switch
- * operation_type - UNC_OP*
- * * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*
+ * @Description : This function reads the values given in val_switch_st
+ * structure
+ * @param[in] : obj_val_switch-instance of val_switch_st_t
+ * vect_table_attr_schema- instance of vector<TableAttrSchema>
+ * vect_prim_keys-vector of string containing keys
+ * val_switch_valid_st-instance of val_switch_st_t
+ * valid-stringstream instance
+ * operation_type - UNC_OP*,type of operation
+ * @return : UPPL_RC_SUCCESS or UPPL_RC_ERR*,Success or associated error code
* */
void Kt_Switch::GetSwitchStateValStructure(
+ OdbcmConnectionHandler *db_conn,
val_switch_st_t *obj_val_switch,
vector<TableAttrSchema> &vect_table_attr_schema,
vector<string> &vect_prim_keys,
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(SWITCH_OPER_STATUS, value,
- value.length(), DATATYPE_UINT16,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_OPER_STATUS, SWITCH_OPER_STATUS_STR,
+ value, value.length(), DATATYPE_UINT16,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
value.clear();
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(SWITCH_MANUFACTURER, value,
- value.length(), DATATYPE_UINT8_ARRAY_256,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_MANUFACTURER, SWITCH_MANUFACTURER_STR,
+ value, value.length(), DATATYPE_UINT8_ARRAY_256,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
value.clear();
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(SWITCH_HARDWARE, value,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_HARDWARE, SWITCH_HARDWARE_STR, value,
value.length(), DATATYPE_UINT8_ARRAY_256,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
} else {
valid_val = UPPL_NO_VAL_STRUCT;
}
- PhyUtil::FillDbSchema(SWITCH_SOFTWARE, value,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_SOFTWARE, SWITCH_SOFTWARE_STR, value,
value.length(), DATATYPE_UINT8_ARRAY_256,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
if (operation_type == UNC_OP_CREATE) {
valid_val = UNC_VF_VALID;
}
- PhyUtil::FillDbSchema(SWITCH_ALARM_STATUS, value,
- value.length(), DATATYPE_UINT64,
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_ALARM_STATUS, SWITCH_ALARM_STATUS_STR,
+ value, value.length(), DATATYPE_UINT64,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, valid);
// valid
valid_val = UPPL_NO_VAL_STRUCT;
stringstream dummy_valid;
- PhyUtil::FillDbSchema(SWITCH_VALID, valid.str(),
+ PhyUtil::FillDbSchema(unc::uppl::SWITCH_VALID, SWITCH_VALID_STR, valid.str(),
valid.str().length(), DATATYPE_UINT8_ARRAY_11,
operation_type, valid_val, prev_db_val,
vect_table_attr_schema, vect_prim_keys, dummy_valid);
using unc::uppl::NotificationRequest;
-/**
+/**NotificationRequest
* @Description:NotificationRequest constructor
- * * @param[in]:void
- * * @return :void
+ * @param[in]:none
+ * @return :none
**/
NotificationRequest::NotificationRequest() {
}
-/**
+/**NotificationRequest
* @Description:NotificationRequest destructor
- * * @param[in]:void
- * * @return :void
+ * @param[in]:none
+ * @return :none
**/
NotificationRequest::~NotificationRequest() {
}
-/**
- * @Description:This function invoke ProcessNotificationEvents() and
- * ProcessAlarmEvents
- * * @param[in]:const IpcEvent &event
- * * @return :pfc_bool_t
+/**ProcessEvent
+ * @Description:ITC triggers this function when notification request is
+ * received.This function invoke ProcessNotificationEvents() and
+ * ProcessAlarmEvents
+ * @param[in]:event-an object of IpcEvent
+ * @return :pfc_bool_t.PFC_TRUE is returned if this module is initialized
+ * successfully otherwise PFC_FALSE is returned to denote error
**/
pfc_bool_t NotificationRequest::ProcessEvent(const IpcEvent &event) {
- pfc_log_info("Inside ProcessEvent of NotificationRequest");
pfc_ipcevtype_t event_type(event.getType());
if (event_type == UNC_PHYSICAL_EVENTS ||
event_type == UNC_CTLR_STATE_EVENTS) {
return PFC_TRUE;
}
+/**InvokeKtDriverEvent
+ * @Description:This function invokes HandleDriverEvents() based
+ * on the keytype and operation
+ * @param[in]:
+ * operation-type of operation which can be UNC_OP_CREATE/DELETE/UPDATE
+ * data_type-type of database,UNC_DT_*
+ * key_struct-void pointer that will point to any kt's key structure
+ * new_val_struct-void pointer that will point to any kt's value structure
+ * old_val_struct-void pointer that will point to any kt's value structure
+ * key_type-any one of unc_key_type_t
+ * @return :Success or associated error code
+ **/
+
UpplReturnCode NotificationRequest::InvokeKtDriverEvent(
+ OdbcmConnectionHandler *db_conn,
uint32_t operation,
uint32_t data_type,
void *key_struct,
}
switch (operation) {
case UNC_OP_CREATE: {
- status = ObjStateNotify->HandleDriverEvents(key_struct, operation,
+ status = ObjStateNotify->HandleDriverEvents(db_conn, key_struct,
+ operation,
data_type, key_type, NULL,
new_val_struct);
- pfc_log_info(
+ pfc_log_debug(
"Return status of KT create HandleDriverEvents: %d", status);
delete ObjStateNotify;
break;
}
case UNC_OP_UPDATE: {
- status = ObjStateNotify->HandleDriverEvents(key_struct, operation,
+ status = ObjStateNotify->HandleDriverEvents(db_conn, key_struct,
+ operation,
data_type, key_type,
old_val_struct,
new_val_struct);
- pfc_log_info(
+ pfc_log_debug(
"Return status of update HandleDriverEvents: %d", status);
delete ObjStateNotify;
break;
}
case UNC_OP_DELETE: {
- status = ObjStateNotify->HandleDriverEvents(key_struct, operation,
+ status = ObjStateNotify->HandleDriverEvents(db_conn, key_struct,
+ operation,
data_type, key_type,
NULL, NULL);
- pfc_log_info(
+ pfc_log_debug(
"Return status of delete HandleDriverEvents: %d", status);
delete ObjStateNotify;
break;
return status;
}
-/**
- * @Description:This function process Notification events
- * * @param[in]:const IpcEvent &event
- * * @return :pfc_bool_t
+/**ProcessNotificationEvents
+ * @Description:This function process Notification events recieved
+ * for various key types
+ * @param[in]:event- an object of IpcEvent,contains the event posted by driver.
+ * @return :Success or associated error code
**/
-UpplReturnCode NotificationRequest::
-ProcessNotificationEvents(const IpcEvent &event) {
+UpplReturnCode NotificationRequest::ProcessNotificationEvents(
+ const IpcEvent &event) {
pfc_log_info("Inside ProcessNotificationEvents of NotificationRequest");
UpplReturnCode status = UPPL_RC_SUCCESS;
ClientSession sess(event.getSession());
return status;
}
-/***
- * * @Description:This function checks whether audit in progress for the controller
- * and use IMPORT db to store the notifications received from driver
- * * * @param[in]:controller_name, datatype
- * * * @return :void
+/***GetNotificationDT
+ * @Description:This function checks whether audit in progress for the
+ * controller and use IMPORT db to store the notifications received from driver
+ * @param[in]:controller_name-controller id
+ * @param[out]:datatype-type of database,UNC_DT_*
+ * @return :void
**/
-void NotificationRequest::GetNotificationDT(string controller_name,
+void NotificationRequest::GetNotificationDT(OdbcmConnectionHandler *db_conn,
+ string controller_name,
uint32_t &data_type) {
- unc_keytype_ctrtype_t ctr_type = UNC_CT_UNKNOWN;
- if (PhyUtil::get_controller_type(
- controller_name,
- ctr_type,
- (unc_keytype_datatype_t)data_type) == UPPL_RC_SUCCESS) {
- pfc_log_debug("Received Controller Type %d", ctr_type);
- }
- NotificationManager *nfn_mgr = PhysicalLayer::get_instance()->
+ pfc_bool_t is_controller_in_audit = PhysicalLayer::get_instance()->
get_ipc_connection_manager()->
- get_notification_manager(ctr_type);
- if (nfn_mgr != NULL) {
- pfc_bool_t is_controller_in_audit = PhysicalLayer::get_instance()->
- get_ipc_connection_manager()->
- IsControllerInAudit(controller_name);
- if (is_controller_in_audit == PFC_TRUE) {
- data_type = (uint32_t)UNC_DT_IMPORT;
- }
+ IsControllerInAudit(controller_name);
+ if (is_controller_in_audit == PFC_TRUE) {
+ data_type = (uint32_t)UNC_DT_IMPORT;
}
pfc_log_debug("GetNotificationDT data_type %d", data_type);
}
-/***
- * * @Description:This function Process alarm events
- * * * @param[in]:const IpcEvent &event
- * * * @return :pfc_bool_t
+/***ProcessAlarmEvents
+ * @Description:This function Process alarm events recieved for various
+ * key types
+ * @param[in]:event-an object of IpcEvent,contains the event posted by driver
+ * @return :Success or associated error code
**/
UpplReturnCode NotificationRequest::ProcessAlarmEvents(const IpcEvent &event) {
pfc_log_info("Inside ProcessAlarmEvents of NotificationRequest");
+ // Check for MergeImportRunning Lock
+ ScopedReadWriteLock eventDoneLock(
+ PhysicalLayer::get_events_done_lock_(), PFC_FALSE); // read lock
+ UpplReturnCode db_ret = UPPL_RC_SUCCESS;
+ OPEN_DB_CONNECTION(unc::uppl::kOdbcmConnReadWriteSb, db_ret);
+ if (db_ret != UPPL_RC_SUCCESS) {
+ pfc_log_error("Error in opening DB connection");
+ return UPPL_RC_ERR_DB_ACCESS;
+ }
UpplReturnCode status = UPPL_RC_SUCCESS;
ClientSession sess(event.getSession());
if (alarm_header.key_type == UNC_KT_CONTROLLER) {
/*process controller related alarm*/
key_ctr key_ctr;
+ memset(&key_ctr, '\0', sizeof(key_ctr));
int read_err = sess.getResponse((uint32_t)6, key_ctr);
if (read_err != 0) {
pfc_log_error("Key not received for controller");
}
string controller_name = reinterpret_cast<char *>
(key_ctr.controller_name);
- GetNotificationDT(controller_name, data_type);
+ GetNotificationDT(&db_conn, controller_name, data_type);
Kt_Controller NotifyController;
status = NotifyController.HandleDriverAlarms(
- data_type, alarm_header.alarm_type, alarm_header.operation,
+ &db_conn, data_type, alarm_header.alarm_type, alarm_header.operation,
reinterpret_cast<void*>(&key_ctr),
reinterpret_cast<void*>(&val_ctr_alarm_struct));
- pfc_log_info(
+ pfc_log_debug(
"Return status of controller HandleDriverAlarms: %d", status);
} else {
pfc_log_info("Invalid alarm type for UNC_KT_CONTROLLER: %d",
} else if (alarm_header.key_type == UNC_KT_CTR_DOMAIN) {
/*process domain related alarm*/
key_ctr_domain_t key_ctr_domain;
+ memset(&key_ctr_domain, '\0', sizeof(key_ctr_domain_t));
int read_err = sess.getResponse((uint32_t)6, key_ctr_domain);
if (read_err != 0) {
pfc_log_error("Key not received for ctr domain");
if (alarm_header.alarm_type == UNC_COREDOMAIN_SPLIT) {
string controller_name = reinterpret_cast<char *>
(key_ctr_domain.ctr_key.controller_name);
- GetNotificationDT(controller_name, data_type);
+ GetNotificationDT(&db_conn, controller_name, data_type);
status = NotifyDomain->HandleDriverAlarms(
- data_type, alarm_header.alarm_type, alarm_header.operation,
+ &db_conn, data_type, alarm_header.alarm_type, alarm_header.operation,
reinterpret_cast<void*>(&key_ctr_domain), NULL);
- pfc_log_info(
+ pfc_log_debug(
"Return status of domain HandleDriverAlarms: %d", status);
delete NotifyDomain;
} else {
} else if (alarm_header.key_type == UNC_KT_LOGICAL_PORT) {
/*process logical port related alarm*/
key_logical_port_t key_logicalport;
+ memset(&key_logicalport, '\0', sizeof(key_logical_port_t));
int read_err = sess.getResponse((uint32_t)6, key_logicalport);
if (read_err != 0) {
pfc_log_error("Key not received for logical port");
if (alarm_header.alarm_type == UNC_SUBDOMAIN_SPLIT) {
string controller_name = reinterpret_cast<char *>
(key_logicalport.domain_key.ctr_key.controller_name);
- GetNotificationDT(controller_name, data_type);
+ GetNotificationDT(&db_conn, controller_name, data_type);
status = NotifyLogicalPort->HandleDriverAlarms(
- data_type, alarm_header.alarm_type, alarm_header.operation,
+ &db_conn, data_type, alarm_header.alarm_type, alarm_header.operation,
reinterpret_cast<void*>(&key_logicalport), NULL);
- pfc_log_info(
+ pfc_log_debug(
"Return status of sub_domain HandleDriverAlarms: %d", status);
delete NotifyLogicalPort;
} else {
} else if (alarm_header.key_type == UNC_KT_PORT) {
/*process port related alarm*/
key_port_t port_key;
+ memset(&port_key, '\0', sizeof(key_port_t));
int read_err = sess.getResponse((uint32_t)6, port_key);
if (read_err != 0) {
pfc_log_error("Key not received for port");
(alarm_header.alarm_type == UNC_PORT_CONGES)) {
string controller_name = reinterpret_cast<char *>
(port_key.sw_key.ctr_key.controller_name);
- GetNotificationDT(controller_name, data_type);
+ GetNotificationDT(&db_conn, controller_name, data_type);
status = NotifyPort->HandleDriverAlarms(
- data_type, alarm_header.alarm_type, alarm_header.operation,
+ &db_conn, data_type, alarm_header.alarm_type, alarm_header.operation,
reinterpret_cast<void*>(&port_key), NULL);
- pfc_log_info(
+ pfc_log_debug(
"Return status of port HandleDriverAlarms: %d", status);
delete NotifyPort;
} else {
} else if (alarm_header.key_type == UNC_KT_SWITCH) {
/*process controller related alarm*/
key_switch_t switch_key;
+ memset(&switch_key, '\0', sizeof(key_switch_t));
int read_err = sess.getResponse((uint32_t)6, switch_key);
if (read_err != 0) {
pfc_log_error("Key not received for switch");
(alarm_header.alarm_type == UNC_OFS_LACK_FEATURES)) {
string controller_name = reinterpret_cast<char *>
(switch_key.ctr_key.controller_name);
- GetNotificationDT(controller_name, data_type);
+ GetNotificationDT(&db_conn, controller_name, data_type);
status = NotifySwitch->HandleDriverAlarms(
- data_type, alarm_header.alarm_type, alarm_header.operation,
+ &db_conn, data_type, alarm_header.alarm_type, alarm_header.operation,
reinterpret_cast<void*>(&switch_key), NULL);
- pfc_log_info(
+ pfc_log_debug(
"Return status of switch HandleDriverAlarms: %d", status);
delete NotifySwitch;
} else {
return status;
}
+/**ProcessPortEvents
+ * @Description:This function processes events recieved for port
+ * @param[in]:
+ * sess-ClientSession object used to retrieve the response arguments
+ * data_type-type of database,UNC_DT_*
+ * operation-type of operation UNC_OP_CREATE/UPDATE/DELETE
+ * @return :Success or associated error code
+ **/
UpplReturnCode NotificationRequest::ProcessPortEvents(
ClientSession *sess,
uint32_t data_type,
uint32_t operation) {
+ // Check for MergeImportRunning Lock
+ ScopedReadWriteLock eventDoneLock(
+ PhysicalLayer::get_events_done_lock_(), PFC_FALSE); // read lock
+ UpplReturnCode db_ret = UPPL_RC_SUCCESS;
+ OPEN_DB_CONNECTION(unc::uppl::kOdbcmConnReadWriteSb, db_ret);
+ if (db_ret != UPPL_RC_SUCCESS) {
+ pfc_log_error("Error in opening DB connection");
+ return UPPL_RC_ERR_DB_ACCESS;
+ }
UpplReturnCode status = UPPL_RC_SUCCESS;
key_port_t port_key;
+ memset(&port_key, '\0', sizeof(key_port_t));
int read_err = sess->getResponse((uint32_t)5, port_key);
if (read_err != 0) {
pfc_log_error("Key not received for port");
pfc_log_info("%s", IpctUtil::get_string(port_key).c_str());
string controller_name = reinterpret_cast<char *>
(port_key.sw_key.ctr_key.controller_name);
- GetNotificationDT(controller_name, data_type);
+ GetNotificationDT(&db_conn, controller_name, data_type);
val_port_st old_val_port, new_val_port;
// val
if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
pfc_log_error("New value not received for port");
return UPPL_RC_ERR_BAD_REQUEST;
}
- pfc_log_info("%s", IpctUtil::get_string(new_val_port).c_str());
+ pfc_log_info("NEWVAL: %s", IpctUtil::get_string(new_val_port).c_str());
}
// old val
if (operation == UNC_OP_UPDATE) {
IpctUtil::get_string(old_val_port).c_str());
}
// call driver event
- status = InvokeKtDriverEvent(operation, data_type,
+ status = InvokeKtDriverEvent(&db_conn, operation, data_type,
reinterpret_cast<void*>(&port_key),
reinterpret_cast<void*>(&new_val_port),
reinterpret_cast<void*>(&old_val_port),
return status;
}
+/***ProcessSwitchEvents
+ * @Description:This function processes events recieved for switch
+ * @param[in]:
+ * sess-ClientSession object used to retrieve the response arguments
+ * data_type-type of database,UNC_DT_*
+ * operation-type of operation UNC_OP_CREATE/UPDATE/DELETE
+ * @return :Success or associated error code
+ **/
UpplReturnCode NotificationRequest::ProcessSwitchEvents(
ClientSession *sess,
uint32_t data_type,
uint32_t operation) {
+ // Check for MergeImportRunning Lock
+ ScopedReadWriteLock eventDoneLock(
+ PhysicalLayer::get_events_done_lock_(), PFC_FALSE); // read lock
+ UpplReturnCode db_ret = UPPL_RC_SUCCESS;
+ OPEN_DB_CONNECTION(unc::uppl::kOdbcmConnReadWriteSb, db_ret);
+ if (db_ret != UPPL_RC_SUCCESS) {
+ pfc_log_error("Error in opening DB connection");
+ return UPPL_RC_ERR_DB_ACCESS;
+ }
UpplReturnCode status = UPPL_RC_SUCCESS;
/*process switch add, switch update and switch delete events*/
key_switch_t switch_key;
+ memset(&switch_key, '\0', sizeof(key_switch_t));
int read_err = sess->getResponse((uint32_t)5, switch_key);
if (read_err != 0) {
pfc_log_error("Key not received for switch");
pfc_log_info("%s", IpctUtil::get_string(switch_key).c_str());
string controller_name = reinterpret_cast<char *>
(switch_key.ctr_key.controller_name);
- GetNotificationDT(controller_name, data_type);
+ GetNotificationDT(&db_conn, controller_name, data_type);
val_switch_st old_val_switch, new_val_switch;
+ memset(&old_val_switch, '\0', sizeof(val_switch_st));
+ memset(&new_val_switch, '\0', sizeof(val_switch_st));
if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
read_err = sess->getResponse((uint32_t)6, new_val_switch);
if (read_err != 0) {
pfc_log_info("OLDVAL: %s",
IpctUtil::get_string(old_val_switch).c_str());
}
- status = InvokeKtDriverEvent(operation, data_type,
+ status = InvokeKtDriverEvent(&db_conn, operation, data_type,
reinterpret_cast<void*>(&switch_key),
reinterpret_cast<void*>(&new_val_switch),
reinterpret_cast<void*>(&old_val_switch),
return status;
}
+
+/***ProcessLinkEvents
+ * @Description:This function processes events recieved for link
+ * @param[in]:
+ * sess-ClientSession object used to retrieve the resposne arguments
+ * data_type-type of database,UNC_DT_*
+ * operation-type of operation UNC_OP_CREATE/UPDATE/DELETE
+ * @return :Success or associated error code
+ **/
UpplReturnCode NotificationRequest:: ProcessLinkEvents(
ClientSession *sess,
uint32_t data_type,
uint32_t operation) {
+ // Check for MergeImportRunning Lock
+ ScopedReadWriteLock eventDoneLock(
+ PhysicalLayer::get_events_done_lock_(), PFC_FALSE); // read lock
+ UpplReturnCode db_ret = UPPL_RC_SUCCESS;
+ OPEN_DB_CONNECTION(unc::uppl::kOdbcmConnReadWriteSb, db_ret);
+ if (db_ret != UPPL_RC_SUCCESS) {
+ pfc_log_error("Error in opening DB connection");
+ return UPPL_RC_ERR_DB_ACCESS;
+ }
UpplReturnCode status = UPPL_RC_SUCCESS;
/*process link add, link update and link delete events*/
key_link_t key_link;
+ memset(&key_link, '\0', sizeof(key_link_t));
int read_err = sess->getResponse((uint32_t)5, key_link);
if (read_err != 0) {
pfc_log_error("Key not received for link");
pfc_log_info("%s", IpctUtil::get_string(key_link).c_str());
string controller_name = reinterpret_cast<char *>
(key_link.ctr_key.controller_name);
- GetNotificationDT(controller_name, data_type);
+ GetNotificationDT(&db_conn, controller_name, data_type);
val_link_st old_val_link, new_val_link;
if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
read_err = sess->getResponse((uint32_t)6, new_val_link);
pfc_log_info("OLDVAL: %s",
IpctUtil::get_string(old_val_link).c_str());
}
- status = InvokeKtDriverEvent(operation, data_type,
+ status = InvokeKtDriverEvent(&db_conn, operation, data_type,
reinterpret_cast<void*>(&key_link),
reinterpret_cast<void*>(&new_val_link),
reinterpret_cast<void*>(&old_val_link),
return status;
}
+/***ProcessControllerEvents
+ * @Description:This function processes events recieved for Controller
+ * @param[in]:
+ * sess-ClientSession object used to retrieve the response arguments
+ * data_type-type of database,UNC_DT_*
+ * operation-type of operation UNC_OP_CREATE/UPDATE/DELETE
+ * @return :Success or associated error code
+ **/
UpplReturnCode NotificationRequest:: ProcessControllerEvents(
ClientSession *sess,
uint32_t data_type,
uint32_t operation) {
UpplReturnCode status = UPPL_RC_SUCCESS;
/*process controller add, controller update and controller delete events*/
- key_ctr key_ctr;
+ key_ctr_t key_ctr;
+ memset(&key_ctr, '\0', sizeof(key_ctr_t));
val_ctr_st old_val_ctr, new_val_ctr;
int read_err = sess->getResponse((uint32_t)5, key_ctr);
if (read_err != 0) {
pfc_log_info("OLDVAL: %s", IpctUtil::get_string(old_val_ctr).c_str());
pfc_bool_t is_events_done = PFC_FALSE;
uint8_t driver_oper_status = new_val_ctr.oper_status;
+ UpplReturnCode db_ret = UPPL_RC_SUCCESS;
+ OPEN_DB_CONNECTION(unc::uppl::kOdbcmConnReadWriteSb, db_ret);
+ if (db_ret != UPPL_RC_SUCCESS) {
+ pfc_log_error("Error in opening DB connection");
+ return UPPL_RC_ERR_DB_ACCESS;
+ }
if (driver_oper_status == CONTROLLER_EVENTS_DONE) {
// CONTROLLER_OPER_UP can be set
// Its same as enum UPPL_CONTROLLER_OPER_UP
if (is_controller_in_audit == PFC_TRUE) {
pfc_log_debug("Calling MergeAuditDbToRunning");
// To cancel the already running timer in Audit
- uint32_t time_out_id = ipc_mgr->getTimeOutId(controller_name);
- ipc_mgr->notfn_timer_->cancel(time_out_id);
+ UpplReturnCode cancel_ret = ipc_mgr->CancelTimer(controller_name);
+ if (cancel_ret != UPPL_RC_SUCCESS) {
+ pfc_log_info("Failure in cancelling timer for controller %s",
+ controller_name.c_str());
+ }
AuditRequest audit_req;
UpplReturnCode merge_auditdb =
- audit_req.MergeAuditDbToRunning(reinterpret_cast<char *>
+ audit_req.MergeAuditDbToRunning(&db_conn, reinterpret_cast<char *>
(key_ctr.controller_name));
if (merge_auditdb != UPPL_RC_SUCCESS) {
pfc_log_info("Merge of audit and running db failed");
} else {
pfc_log_info("End of events received non-audit controller %s",
controller_name.c_str());
+ return UPPL_RC_ERR_BAD_REQUEST;
}
is_events_done = PFC_TRUE;
}
status = NotifyController.HandleDriverEvents(
- reinterpret_cast<void*>(&key_ctr),
+ &db_conn, reinterpret_cast<void*>(&key_ctr),
operation,
data_type,
reinterpret_cast<void*>(&old_val_ctr),
return status;
}
+/***ProcessDomainEvents
+ * @Description:This function processes events recieved for domain
+ * @param[in]:
+ * sess-ClientSession object used to retrieve reposne arguments
+ * data_type-type of database,UNC_DT_*
+ * operation-type of operation UNC_OP_CREATE/UPDATE/DELETE
+ * @return :Success or associated error code
+ **/
UpplReturnCode NotificationRequest:: ProcessDomainEvents(
ClientSession *sess,
uint32_t data_type,
uint32_t operation) {
+ // Check for MergeImportRunning Lock
+ ScopedReadWriteLock eventDoneLock(
+ PhysicalLayer::get_events_done_lock_(), PFC_FALSE); // read lock
+ UpplReturnCode db_ret = UPPL_RC_SUCCESS;
+ OPEN_DB_CONNECTION(unc::uppl::kOdbcmConnReadWriteSb, db_ret);
+ if (db_ret != UPPL_RC_SUCCESS) {
+ pfc_log_error("Error in opening DB connection");
+ return UPPL_RC_ERR_DB_ACCESS;
+ }
UpplReturnCode status = UPPL_RC_SUCCESS;
/*process domain add, domain update and domain delete events*/
key_ctr_domain_t key_ctr_domain;
+ memset(&key_ctr_domain, '\0', sizeof(key_ctr_domain_t));
int read_err = sess->getResponse((uint32_t)5, key_ctr_domain);
if (read_err != 0) {
pfc_log_error("Key not received for controller");
pfc_log_info("%s", IpctUtil::get_string(key_ctr_domain).c_str());
string controller_name = reinterpret_cast<char *>
(key_ctr_domain.ctr_key.controller_name);
- GetNotificationDT(controller_name, data_type);
+ GetNotificationDT(&db_conn, controller_name, data_type);
val_ctr_domain_st new_val_ctr_domain_t;
if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
read_err = sess->getResponse((uint32_t)6, new_val_ctr_domain_t);
IpctUtil::get_string(new_val_ctr_domain_t).c_str());
}
status = InvokeKtDriverEvent(
- operation, data_type,
+ &db_conn, operation, data_type,
reinterpret_cast<void*>(&key_ctr_domain),
reinterpret_cast<void*>(&new_val_ctr_domain_t),
NULL, UNC_KT_CTR_DOMAIN);
return status;
}
+/***ProcessLogicalPortEvents
+ * @Description:This function processes events recieved for LogicalPort
+ * @param[in]:
+ * sess-ClientSession object,used to retrieve the response arguments
+ * data_type-type of database,UNC_DT_*
+ * operation-type of operation UNC_OP_CREATE/UPDATE/DELETE
+ * @return :Success or associated error code
+ **/
UpplReturnCode NotificationRequest:: ProcessLogicalPortEvents(
ClientSession *sess,
uint32_t data_type,
uint32_t operation) {
+ // Check for MergeImportRunning Lock
+ ScopedReadWriteLock eventDoneLock(
+ PhysicalLayer::get_events_done_lock_(), PFC_FALSE); // read lock
+ UpplReturnCode db_ret = UPPL_RC_SUCCESS;
+ OPEN_DB_CONNECTION(unc::uppl::kOdbcmConnReadWriteSb, db_ret);
+ if (db_ret != UPPL_RC_SUCCESS) {
+ pfc_log_error("Error in opening DB connection");
+ return UPPL_RC_ERR_DB_ACCESS;
+ }
UpplReturnCode status = UPPL_RC_SUCCESS;
key_logical_port_t key_logical_port;
+ memset(&key_logical_port, '\0', sizeof(key_logical_port_t));
int read_err = sess->getResponse((uint32_t)5, key_logical_port);
if (read_err != 0) {
pfc_log_error("Key not received for logical port");
pfc_log_info("%s", IpctUtil::get_string(key_logical_port).c_str());
string controller_name = reinterpret_cast<char *>
(key_logical_port.domain_key.ctr_key.controller_name);
- GetNotificationDT(controller_name, data_type);
+ GetNotificationDT(&db_conn, controller_name, data_type);
val_logical_port_st new_val_logical_port_t;
if (operation == UNC_OP_CREATE || operation == UNC_OP_UPDATE) {
read_err = sess->getResponse((uint32_t)6, new_val_logical_port_t);
IpctUtil::get_string(new_val_logical_port_t).c_str());
}
status = InvokeKtDriverEvent(
- operation, data_type,
+ &db_conn, operation, data_type,
reinterpret_cast<void*>(&key_logical_port),
reinterpret_cast<void*>(&new_val_logical_port_t),
NULL, UNC_KT_LOGICAL_PORT);
return status;
}
+/***ProcessLogicalMemeberPortEvents
+ * @Description:This function processes events recieved for
+ * LogicalMemeberPort
+ * @param[in]:
+ * sess-ClientSession object,used to retrieve the response arguments
+ * data_type-type of database,UNC_DT_*
+ * operation-type of operation UNC_OP_CREATE/UPDATE/DELETE
+ * @return :Success or associated error code
+ **/
UpplReturnCode NotificationRequest:: ProcessLogicalMemeberPortEvents(
ClientSession *sess,
uint32_t data_type,
uint32_t operation) {
+ // Check for MergeImportRunning Lock
+ ScopedReadWriteLock eventDoneLock(
+ PhysicalLayer::get_events_done_lock_(), PFC_FALSE); // read lock
+ UpplReturnCode db_ret = UPPL_RC_SUCCESS;
+ OPEN_DB_CONNECTION(unc::uppl::kOdbcmConnReadWriteSb, db_ret);
+ if (db_ret != UPPL_RC_SUCCESS) {
+ pfc_log_error("Error in opening DB connection");
+ return UPPL_RC_ERR_DB_ACCESS;
+ }
UpplReturnCode status = UPPL_RC_SUCCESS;
key_logical_member_port_t logical_member_port_key;
+ memset(&logical_member_port_key, '\0', sizeof(key_logical_member_port_t));
int read_err = sess->getResponse((uint32_t)5, logical_member_port_key);
if (read_err != 0) {
pfc_log_error("Key not received for logical port");
reinterpret_cast<char *>
(logical_member_port_key.logical_port_key.
domain_key.ctr_key.controller_name);
- GetNotificationDT(controller_name, data_type);
+ GetNotificationDT(&db_conn, controller_name, data_type);
Kt_State_Base *NotifyLogicalMemberPort = new Kt_LogicalMemberPort();
if (NotifyLogicalMemberPort == NULL) {
pfc_log_error("Memory not allocated for NotifyLogicalMemberPort_\n");
return UPPL_RC_ERR_FATAL_RESOURCE_ALLOCATION;
}
status = NotifyLogicalMemberPort->HandleDriverEvents(
- reinterpret_cast<void*>(&logical_member_port_key),
+ &db_conn, reinterpret_cast<void*>(&logical_member_port_key),
operation,
data_type, UNC_KT_LOGICAL_MEMBER_PORT, NULL, NULL);
pfc_log_info(
/**
* @brief ITC Read Req
- * @file itc_Read_request.cc
+ * @file itc_read_request.cc
*
*/
#include "ipct_util.hh"
using unc::uppl::PhysicalLayer;
-/* ReadRequest
- * @Description : constructor function
- * @param[in]: NA
- * @return : NA
+/**ReadRequest
+ * @Description : This function initializes the member data
+ * @param[in] : None
+ * @return : None
* */
-
ReadRequest::ReadRequest() {
- memset(&key_root_obj, 0, sizeof(key_root_t));
- memset(&key_ctr_obj, 0, sizeof(key_ctr_t));
- memset(&val_ctr_obj, 0, sizeof(val_ctr_t));
- memset(&key_domain_obj, 0, sizeof(key_ctr_domain_t));
- memset(&val_domain_obj, 0, sizeof(val_ctr_domain_t));
- memset(&key_logical_port_obj, 0, sizeof(key_logical_port_t));
- memset(&val_logical_port_obj, 0, sizeof(val_logical_port_st_t));
- memset(&key_logical_member_port_obj, 0, sizeof(key_logical_member_port_t));
- memset(&key_switch_obj, 0, sizeof(key_switch_t));
- memset(&val_switch_obj, 0, sizeof(val_switch_st_t));
- memset(&key_port_obj, 0, sizeof(key_port_t));
- memset(&val_port_obj, 0, sizeof(val_port_st_t));
- memset(&key_link_obj, 0, sizeof(key_link_t));
- memset(&val_link_obj, 0, sizeof(val_link_st_t));
- memset(&key_boundary_obj, 0, sizeof(key_boundary_t));
- memset(&val_boundary_obj, 0, sizeof(val_boundary_t));
+ // The class member structures are initialized
+ // based on request received
}
-/* ~ReadRequest
- * @Description : Destructor function
- * @param[in]: NA
- * @return : NA
+/**~ReadRequest
+ * @Description : This function releases the memory allocated to
+ * pointer member data
+ * @param[in] : None
+ * @return : None
* */
ReadRequest::~ReadRequest() {
- // destructor functionality
+ FlushBulkReadBuffer();
}
-/* ProcessReq
- * @Description : Creates the respective Kt class object to
- * process the readreq operation
- * @param[in]: ipc struct, service id, session id, configuration id,
- * session object
- * @return : read operation response success/failure.
+/**ProcessReq
+ * @Description : This function receives the message from internal transaction
+ * coordinator and frames the database request for Read
+ * operation.Creates the respective Kt class object to process
+ * the read operation
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * @return : UPPL_RC_SUCCESS if processing the Read request is successful
+ * or UPPL_RC_ERR_* in case of failure
* */
-UpplReturnCode ReadRequest::ProcessReq(ServerSession &session) {
+UpplReturnCode ReadRequest::ProcessReq(ServerSession &session,
+ physical_request_header &obj_req_hdr) {
Kt_Base *KtObj = NULL;
-
- physical_request_header obj_req_hdr;
-
- // populate header from ipc message
- int parse_ret = PhyUtil::sessGetReqHeader(session, obj_req_hdr);
- if (parse_ret != 0) {
- pfc_log_error("Unable to parse ipc structure. BAD_REQUEST error");
- return UPPL_RC_ERR_BAD_REQUEST;
- }
-
UpplReturnCode resp_code = UPPL_RC_SUCCESS, return_code = UPPL_RC_SUCCESS;
physical_response_header rsh;
PhyUtil::getRespHeaderFromReqHeader(obj_req_hdr, rsh);
-
+ OPEN_DB_CONNECTION(unc::uppl::kOdbcmConnReadOnly, resp_code);
+ if (resp_code != UPPL_RC_SUCCESS) {
+ pfc_log_error("DB Connection failure for operation %d",
+ obj_req_hdr.operation);
+ int err = PhyUtil::sessOutRespHeader(session, rsh);
+ if (err != 0) {
+ pfc_log_error("Error writing response to session");
+ }
+ return resp_code;
+ }
void* key_struct = NULL;
void* val_struct = NULL;
- uint32_t operation_type = obj_req_hdr.operation;
- uint32_t key_type = obj_req_hdr.key_type;
// get KeyType and create the respective object to invoke appropriate Kt class
- switch (key_type) {
+ switch (obj_req_hdr.key_type) {
case UNC_KT_ROOT:
- {
- if (operation_type == UNC_OP_READ ||
- operation_type == UNC_OP_READ_SIBLING ||
- operation_type == UNC_OP_READ_SIBLING_BEGIN ||
- operation_type == UNC_OP_READ_SIBLING_COUNT) {
+ if (obj_req_hdr.operation == UNC_OP_READ ||
+ obj_req_hdr.operation == UNC_OP_READ_SIBLING ||
+ obj_req_hdr.operation == UNC_OP_READ_SIBLING_BEGIN ||
+ obj_req_hdr.operation == UNC_OP_READ_SIBLING_COUNT) {
rsh.result_code = UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
}
KtObj = new Kt_Root();
// The root key in request is not considered
key_struct = static_cast<void*> (&key_root_obj);
break;
- }
case UNC_KT_CONTROLLER:
- {
KtObj = new Kt_Controller();
if (KtObj == NULL) {
pfc_log_error("Memory not allocated for Kt_Controller");
}
GetControllerStructure(session, key_struct, val_struct, rsh);
break;
- }
case UNC_KT_CTR_DOMAIN:
- {
KtObj = new Kt_Ctr_Domain();
if (KtObj == NULL) {
pfc_log_error("Memory not allocated for Kt_Ctr_Domain");
}
GetDomainStructure(session, key_struct, val_struct, rsh);
break;
- }
case UNC_KT_LOGICAL_PORT:
- {
KtObj = new Kt_LogicalPort();
if (KtObj == NULL) {
pfc_log_error("Memory not allocated for Kt_LogicalPort");
}
GetLogicalPortStructure(session, key_struct, val_struct, rsh);
break;
- }
case UNC_KT_LOGICAL_MEMBER_PORT:
- {
KtObj = new Kt_LogicalMemberPort();
if (KtObj == NULL) {
pfc_log_error("Memory not allocated for Kt_LogicalMemberPort");
}
GetLogicalMemberPortStructure(session, key_struct, val_struct, rsh);
break;
- }
case UNC_KT_SWITCH:
- {
KtObj = new Kt_Switch();
if (KtObj == NULL) {
pfc_log_error("Memory not allocated for Kt_Switch");
}
GetSwitchStructure(session, key_struct, val_struct, rsh);
break;
- }
case UNC_KT_PORT:
- {
KtObj = new Kt_Port();
if (KtObj == NULL) {
pfc_log_error("Memory not allocated for Kt_Port");
}
GetPortStructure(session, key_struct, val_struct, rsh);
break;
- }
case UNC_KT_LINK:
- {
KtObj = new Kt_Link();
if (KtObj == NULL) {
pfc_log_error("Memory not allocated for Kt_Link");
}
GetLinkStructure(session, key_struct, val_struct, rsh);
break;
- }
case UNC_KT_BOUNDARY:
- {
KtObj = new Kt_Boundary();
if (KtObj == NULL) {
pfc_log_error("Memory not allocated for Kt_Boundary");
}
GetBoundaryStructure(session, key_struct, val_struct, rsh);
break;
- }
default:
- {
rsh.result_code = UPPL_RC_ERR_KEYTYPE_NOT_SUPPORTED;
- }
+ break;
}
if (rsh.result_code != UPPL_RC_SUCCESS) {
if (KtObj != NULL) {
}
return return_code;
}
- switch (operation_type) {
+ switch (obj_req_hdr.operation) {
case UNC_OP_READ:
case UNC_OP_READ_NEXT:
case UNC_OP_READ_BULK:
case UNC_OP_READ_SIBLING_BEGIN:
case UNC_OP_READ_SIBLING:
case UNC_OP_READ_SIBLING_COUNT:
- {
// form validate request for READ operation
- resp_code = KtObj->ValidateRequest(key_struct,
+ resp_code = KtObj->ValidateRequest(&db_conn,
+ key_struct,
NULL,
- operation_type,
+ obj_req_hdr.operation,
obj_req_hdr.data_type,
- key_type);
+ obj_req_hdr.key_type);
break;
- }
default:
resp_code = UPPL_RC_ERR_OPERATION_NOT_SUPPORTED;
break;
return_code = UPPL_RC_SUCCESS;
}
} else {
- return_code = ProcessReadOperation(session, KtObj, obj_req_hdr,
+ return_code = ProcessReadOperation(&db_conn, session, KtObj, obj_req_hdr,
key_struct, val_struct,
- operation_type);
+ obj_req_hdr.operation);
}
if (KtObj != NULL) {
delete KtObj;
return return_code;
}
-
-/* ProcessReq
- * @Description : Creates the respective Kt class object
- * to process the readreq operation
- * @param[in]: ipc struct, service id, session id, configuration id,
- * session object
- * @return : read operation response success/failure.
+/**ProcessReq
+ * @Description : Function processes various Read types of operation by
+ * Creating the respective Kt class object and returns
+ * the processing result.
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * key_struct - the key instance for appropriate key types
+ * val_struct - the value struct for the appropriate key types
+ * operation_type - UNC_OP_* specifies the operation type
+ * KtObj - Object of the base class to invoke appropriate
+ * Kt class
+ * obj_req_hdr - object of physical request header
+ * @return : UPPL_RC_SUCCESS if processing the Read request is successful
+ * or UPPL_RC_ERR_* in case of failure
* */
UpplReturnCode ReadRequest::ProcessReadOperation(
+ OdbcmConnectionHandler *db_conn,
ServerSession &session,
Kt_Base *KtObj,
- physical_request_header obj_req_hdr,
+ physical_request_header &obj_req_hdr,
void* key_struct,
void* val_struct,
uint32_t operation_type) {
UpplReturnCode resp_code = UPPL_RC_SUCCESS, return_code = UPPL_RC_SUCCESS;
- physical_response_header rsh;
- PhyUtil::getRespHeaderFromReqHeader(obj_req_hdr, rsh);
pfc_bool_t response_sent = PFC_FALSE;
+ uint32_t max_rep_ct = obj_req_hdr.max_rep_count;
switch (operation_type) {
case UNC_OP_READ:
- {
// Invoke Read operation for respective KT class
- resp_code = KtObj->Read(obj_req_hdr.client_sess_id,
+ resp_code = KtObj->Read(db_conn,
+ obj_req_hdr.client_sess_id,
obj_req_hdr.config_id,
key_struct,
val_struct,
obj_req_hdr.option2);
response_sent = PFC_TRUE;
break;
- }
case UNC_OP_READ_NEXT:
- {
// Invoke Read Next operation for respective KT class
- resp_code = KtObj->ReadNext(key_struct,
+ resp_code = KtObj->ReadNext(db_conn,
+ key_struct,
obj_req_hdr.data_type,
- obj_req_hdr.option1,
- obj_req_hdr.option2);
+ this);
if (resp_code == UPPL_RC_SUCCESS) {
response_sent = PFC_TRUE;
return_code = FrameReadBulkResponse(session,
pfc_log_debug("Session framing response %d", return_code);
}
break;
- }
case UNC_OP_READ_BULK:
- {
- // bool is_header_added = false;
- uint32_t max_rep_ct = obj_req_hdr.max_rep_count;
if (max_rep_ct > UPPL_MAX_REP_CT) {
- pfc_log_info("User requested more than 10000 records!!");
+ pfc_log_info("User requested more than %d records!!", UPPL_MAX_REP_CT);
max_rep_ct = UPPL_MAX_REP_CT;
}
// Invoke Read Bulk operation for respective KT class
- resp_code = KtObj->ReadBulk(key_struct,
+ resp_code = KtObj->ReadBulk(db_conn,
+ key_struct,
obj_req_hdr.data_type,
- obj_req_hdr.option1,
- obj_req_hdr.option2,
max_rep_ct,
-1,
false,
- false);
+ false,
+ this);
if (resp_code == UPPL_RC_SUCCESS) {
response_sent = PFC_TRUE;
return_code = FrameReadBulkResponse(session,
pfc_log_debug("Session framing response %d", return_code);
}
break;
- }
case UNC_OP_READ_SIBLING_BEGIN:
- {
// Invoke Read Sibling Begin operation for respective KT class
- resp_code = KtObj->ReadSiblingBegin(obj_req_hdr.client_sess_id,
+ resp_code = KtObj->ReadSiblingBegin(db_conn,
+ obj_req_hdr.client_sess_id,
obj_req_hdr.config_id,
key_struct,
val_struct,
obj_req_hdr.max_rep_count);
response_sent = PFC_TRUE;
break;
- }
case UNC_OP_READ_SIBLING:
- {
// Invoke Read Sibling operation for respective KT class
- resp_code = KtObj->ReadSibling(obj_req_hdr.client_sess_id,
+ resp_code = KtObj->ReadSibling(db_conn,
+ obj_req_hdr.client_sess_id,
obj_req_hdr.config_id,
key_struct,
val_struct,
obj_req_hdr.max_rep_count);
response_sent = PFC_TRUE;
break;
- }
case UNC_OP_READ_SIBLING_COUNT:
- {
// Invoke Read Sibling Count operation for respective KT class
- resp_code = KtObj->ReadSiblingCount(obj_req_hdr.client_sess_id,
+ resp_code = KtObj->ReadSiblingCount(db_conn,
+ obj_req_hdr.client_sess_id,
obj_req_hdr.config_id,
key_struct,
val_struct,
obj_req_hdr.option2);
response_sent = PFC_TRUE;
break;
- }
default:
resp_code = UPPL_RC_ERR_OPERATION_NOT_SUPPORTED;
+ break;
}
if (!response_sent) {
+ physical_response_header rsh;
+ PhyUtil::getRespHeaderFromReqHeader(obj_req_hdr, rsh);
rsh.result_code = resp_code;
- pfc_log_error("read validation failed");
+ pfc_log_error("read operation failed: %d", resp_code);
int err = PhyUtil::sessOutRespHeader(session, rsh);
+ err |= KtObj->AddKeyStructuretoSession(obj_req_hdr.key_type, &session,
+ key_struct);
if (err != 0) {
return_code = UPPL_RC_ERR_IPC_WRITE_ERROR;
} else {
return return_code;
}
+/**FrameReadBulkResponse
+ * @Description : This function is to frame the ReadBulk response for
+ * the respective key types
+ * @param[in] : &session - Object of ServerSession where the request
+ * argument present
+ * session_id - ipc session id used for TC validation
+ * config_id - configuration id used for TC validation
+ * operation - UNC_OP_* specifies the operation
+ * data_type - UNC_DT_* specifies the database type
+ * option1,option2 - specifies any additional
+ * condition for read operation
+ * @return : UPPL_RC_SUCCESS is returned when the response is added
+ * to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not
+ * be added to sess.
+ * */
UpplReturnCode ReadRequest::FrameReadBulkResponse(ServerSession &session,
uint32_t session_id,
uint32_t config_id,
option2,
data_type,
0};
- PhysicalCore *physical_core = PhysicalLayer::get_instance()->
- get_physical_core();
- InternalTransactionCoordinator *itc_trans =
- physical_core->get_internal_transaction_coordinator();
- vector<BulkReadBuffer> bulk_read_buffer = itc_trans->get_readbulk_buffer();
- vector<BulkReadBuffer> :: iterator iter = bulk_read_buffer.begin();
- for (; iter != bulk_read_buffer.end(); ++iter) {
+ vector<BulkReadBuffer> :: iterator iter = vect_bulk_read_buffer.begin();
+ for (; iter != vect_bulk_read_buffer.end(); ++iter) {
if ((*iter).value_type == IS_KEY) { ++max_rep_ct;}
}
rsh.max_rep_count = max_rep_ct;
- if (bulk_read_buffer.empty()) {
+ if (vect_bulk_read_buffer.empty()) {
pfc_log_debug("No instances available to read");
rsh.result_code = UPPL_RC_ERR_NO_SUCH_INSTANCE;
}
int err = PhyUtil::sessOutRespHeader(session, rsh);
- iter = bulk_read_buffer.begin();
- int vect_size = bulk_read_buffer.size();
- for (; iter != bulk_read_buffer.end(); ++iter, --vect_size) {
+ iter = vect_bulk_read_buffer.begin();
+ int vect_size = vect_bulk_read_buffer.size();
+ for (; iter != vect_bulk_read_buffer.end(); ++iter, --vect_size) {
BulkReadBuffer obj_buffer = (*iter);
unc_key_type_t key_type = obj_buffer.key_type;
ValueType value_type = obj_buffer.value_type;
- if (key_type == UNC_KT_CONTROLLER) {
- AddControllerStructure(session, obj_buffer, err);
- }
- if (key_type == UNC_KT_CTR_DOMAIN) {
- AddDomainStructure(session, obj_buffer, err);
- }
- if (key_type == UNC_KT_LOGICAL_PORT) {
- AddLogicalPortStructure(session, obj_buffer, err);
- }
- if (key_type == UNC_KT_LOGICAL_MEMBER_PORT) {
- AddLogicalMemberPortStructure(session, obj_buffer, err);
- }
- if (key_type == UNC_KT_SWITCH) {
- AddSwitchStructure(session, obj_buffer, err);
- }
- if (key_type == UNC_KT_PORT) {
- AddPortStructure(session, obj_buffer, err);
- }
- if (key_type == UNC_KT_LINK) {
- AddLinkStructure(session, obj_buffer, err);
- }
- if (key_type == UNC_KT_BOUNDARY) {
- AddBoundaryStructure(session, obj_buffer, err);
+ switch (key_type) {
+ case UNC_KT_CONTROLLER:
+ AddControllerStructure(session, obj_buffer, err);
+ break;
+ case UNC_KT_CTR_DOMAIN:
+ AddDomainStructure(session, obj_buffer, err);
+ break;
+ case UNC_KT_LOGICAL_PORT:
+ AddLogicalPortStructure(session, obj_buffer, err);
+ break;
+ case UNC_KT_LOGICAL_MEMBER_PORT:
+ AddLogicalMemberPortStructure(session, obj_buffer, err);
+ break;
+ case UNC_KT_SWITCH:
+ AddSwitchStructure(session, obj_buffer, err);
+ break;
+ case UNC_KT_PORT:
+ AddPortStructure(session, obj_buffer, err);
+ break;
+ case UNC_KT_LINK:
+ AddLinkStructure(session, obj_buffer, err);
+ break;
+ case UNC_KT_BOUNDARY:
+ AddBoundaryStructure(session, obj_buffer, err);
+ break;
+ default:
+ break;
}
if (vect_size != 1 && value_type == IS_SEPARATOR) {
err |= session.addOutput(); // NULL
return UPPL_RC_ERR_IPC_WRITE_ERROR;
}
}
- itc_trans->FlushBulkReadBuffer();
return UPPL_RC_SUCCESS;
}
+/**GetControllerStructure
+ * @Description : This function is to get the value structure of the controller
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * key_struct - the key for the kt_controller instance
+ * val_struct - the value structure for the kt_controller
+ * &rsh - object of the physical response header
+ * @return : void
+ * */
void ReadRequest::GetControllerStructure(ServerSession &session,
void * &key_struct,
void * &val_struct,
key_struct = static_cast<void*> (&key_ctr_obj);
// populate val_ctr structure
memset(&val_ctr_obj, 0, sizeof(val_ctr_obj));
- pfc_log_debug("%s", IpctUtil::get_string(key_ctr_obj).c_str());
+ pfc_log_info("%s", IpctUtil::get_string(key_ctr_obj).c_str());
int val_read = session.getArgument(9, val_ctr_obj);
- val_struct = static_cast<void*> (&val_ctr_obj);
- if (val_read != 0) {
- pfc_log_debug("%s", IpctUtil::get_string(val_ctr_obj).c_str());
+ if (val_read == 0) {
+ val_struct = static_cast<void*> (&val_ctr_obj);
+ pfc_log_info("%s", IpctUtil::get_string(val_ctr_obj).c_str());
} else {
pfc_log_debug("No value structure provided in read request");
}
return;
}
+/**GetDomainStructure
+ * @Description : This function is to get the value structure of the domain
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * key_struct - the key for the kt_domain instance
+ * val_struct - the value structure for the kt_domain
+ * &rsh - object of the physical response header
+ * @return : void
+ * */
void ReadRequest::GetDomainStructure(ServerSession &session,
void * &key_struct,
void * &val_struct,
physical_response_header &rsh) {
// populate key_domain_obj structure
+ memset(&key_domain_obj, 0, sizeof(key_domain_obj));
rsh.result_code = session.getArgument(8, key_domain_obj);
key_struct = static_cast<void*> (&key_domain_obj);
- pfc_log_debug("%s", IpctUtil::get_string(key_domain_obj).c_str());
+ pfc_log_info("%s", IpctUtil::get_string(key_domain_obj).c_str());
// populate val_domain_obj structure
memset(&val_domain_obj, 0, sizeof(val_domain_obj));
int val_read = session.getArgument(9, val_domain_obj);
- val_struct = static_cast<void*> (&val_domain_obj);
- if (val_read != 0) {
- pfc_log_debug("%s", IpctUtil::get_string(val_domain_obj).c_str());
+ if (val_read == 0) {
+ val_struct = static_cast<void*> (&val_domain_obj);
+ pfc_log_info("%s", IpctUtil::get_string(val_domain_obj).c_str());
} else {
pfc_log_debug("No value structure provided in read request");
}
return;
}
+/**GetLogicalPortStructure
+ * @Description : This function is to get the value structure of the
+ * logical port
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * key_struct - the key for the kt_logicalport instance
+ * val_struct - the value structure for the kt_logicalport
+ * &rsh - object of the physical response header
+ * @return : void
+ * */
void ReadRequest::GetLogicalPortStructure(ServerSession &session,
void * &key_struct,
void * &val_struct,
physical_response_header &rsh) {
// populate key_logical_port structure
+ memset(&key_logical_port_obj, 0, sizeof(key_logical_port_t));
session.getArgument(8, key_logical_port_obj);
key_struct = static_cast<void*> (&key_logical_port_obj);
- pfc_log_debug("%s", IpctUtil::get_string(key_logical_port_obj).c_str());
+ pfc_log_info("%s", IpctUtil::get_string(key_logical_port_obj).c_str());
// populate val_logical_port structure
memset(&val_logical_port_obj, 0, sizeof(val_logical_port_obj));
int val_read = session.getArgument(9, val_logical_port_obj);
- val_struct = static_cast<void*> (&val_logical_port_obj);
- if (val_read != 0) {
- pfc_log_debug("%s", IpctUtil::get_string(val_logical_port_obj).c_str());
+ if (val_read == 0) {
+ val_struct = static_cast<void*> (&val_logical_port_obj);
+ pfc_log_info("%s", IpctUtil::get_string(val_logical_port_obj).c_str());
} else {
pfc_log_debug("No value structure provided in read request");
}
return;
}
+/**GetLogicalMemberPortStructure
+ * @Description : This function is to get the value structure of the
+ * logical member port
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * key_struct - the key for the kt_logical_member_port instance
+ * val_struct - the value structure for the
+ * kt_logical_member_port
+ * &rsh - object of the physical response header
+ * @return : void
+ * */
void ReadRequest::GetLogicalMemberPortStructure(ServerSession &session,
void * &key_struct,
void * &val_struct,
physical_response_header &rsh) {
// populate key_logical_member_port structure
+ memset(&key_logical_member_port_obj, 0, sizeof(key_logical_member_port_t));
rsh.result_code = session.getArgument(8, key_logical_member_port_obj);
key_struct = static_cast<void*> (&key_logical_member_port_obj);
pfc_log_debug("%s",
return;
}
+/**GetSwitchStructure
+ * @Description : This function is to get the value structure of the switch
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * key_struct - the key for the kt_switch instance
+ * val_struct - the value structure for the kt_switch
+ * &rsh - object of the physical response header
+ * @return : void
+ * */
void ReadRequest::GetSwitchStructure(ServerSession &session,
void * &key_struct,
void * &val_struct,
physical_response_header &rsh) {
// populate key_switch_obj structure
+ memset(&key_switch_obj, 0, sizeof(key_switch_t));
rsh.result_code = session.getArgument(8, key_switch_obj);
key_struct = static_cast<void*> (&key_switch_obj);
- pfc_log_debug("%s", IpctUtil::get_string(key_switch_obj).c_str());
+ pfc_log_info("%s", IpctUtil::get_string(key_switch_obj).c_str());
// populate val_switch structure
memset(&val_switch_obj, 0, sizeof(val_switch_obj));
int val_read = session.getArgument(9, val_switch_obj);
- val_struct = static_cast<void*> (&val_switch_obj);
- if (val_read != 0) {
- pfc_log_debug("%s", IpctUtil::get_string(val_switch_obj).c_str());
+ if (val_read == 0) {
+ val_struct = static_cast<void*> (&val_switch_obj);
+ pfc_log_info("%s", IpctUtil::get_string(val_switch_obj).c_str());
} else {
pfc_log_debug("No value structure provided in read request");
}
return;
}
+/**GetPortStructure
+ * @Description : This function is to get the value structure of the port
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * key_struct - the key for the kt_port instance
+ * val_struct - the value structure for the kt_port
+ * &rsh - object of the physical response header
+ * @return : void
+ * */
void ReadRequest::GetPortStructure(ServerSession &session,
void * &key_struct,
void * &val_struct,
physical_response_header &rsh) {
// populate key_port structure
+ memset(&key_port_obj, 0, sizeof(key_port_t));
rsh.result_code = session.getArgument(8, key_port_obj);
key_struct = static_cast<void*> (&key_port_obj);
- pfc_log_debug("%s", IpctUtil::get_string(key_port_obj).c_str());
+ pfc_log_info("%s", IpctUtil::get_string(key_port_obj).c_str());
// populate val_port structure
memset(&val_port_obj, 0, sizeof(val_port_obj));
int val_read = session.getArgument(9, val_port_obj);
- val_struct = static_cast<void*> (&val_port_obj);
- if (val_read != 0) {
- pfc_log_debug("%s", IpctUtil::get_string(val_port_obj).c_str());
+ if (val_read == 0) {
+ val_struct = static_cast<void*> (&val_port_obj);
+ pfc_log_info("%s", IpctUtil::get_string(val_port_obj).c_str());
} else {
pfc_log_debug("No value structure provided in read request");
}
return;
}
+/**GetLinkStructure
+ * @Description : This function is to get the value structure of the link
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * key_struct - the key for the kt_link instance
+ * val_struct - the value structure for the kt_link
+ * &rsh - object of the physical response header
+ * @return : void
+ * */
void ReadRequest::GetLinkStructure(ServerSession &session,
void * &key_struct,
void * &val_struct,
physical_response_header &rsh) {
// populate key_link_obj structure
+ memset(&key_link_obj, 0, sizeof(key_link_t));
rsh.result_code = session.getArgument(8, key_link_obj);
key_struct = static_cast<void*> (&key_link_obj);
- pfc_log_debug("%s", IpctUtil::get_string(key_link_obj).c_str());
+ pfc_log_info("%s", IpctUtil::get_string(key_link_obj).c_str());
// populate val_link structure
memset(&val_link_obj, 0, sizeof(val_link_obj));
int val_read = session.getArgument(9, val_link_obj);
- val_struct = static_cast<void*> (&val_link_obj);
- if (val_read != 0) {
- pfc_log_debug("%s", IpctUtil::get_string(val_link_obj).c_str());
+ if (val_read == 0) {
+ val_struct = static_cast<void*> (&val_link_obj);
+ pfc_log_info("%s", IpctUtil::get_string(val_link_obj).c_str());
} else {
pfc_log_debug("No value structure provided in read request");
}
return;
}
+/**GetBoundaryStructure
+ * @Description : This function is to get the value structure of the boundary
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * key_struct - the key for the kt_boundary instance
+ * val_struct - the value structure for the kt_boundary
+ * &rsh - object of the physical response header
+ * @return : void
+ * */
void ReadRequest::GetBoundaryStructure(ServerSession &session,
void * &key_struct,
void * &val_struct,
physical_response_header &rsh) {
// populate key_boundary_obj structure
+ memset(&key_boundary_obj, 0, sizeof(key_boundary_t));
rsh.result_code = session.getArgument(8, key_boundary_obj);
key_struct = static_cast<void*> (&key_boundary_obj);
- pfc_log_debug("%s", IpctUtil::get_string(key_boundary_obj).c_str());
+ pfc_log_info("%s", IpctUtil::get_string(key_boundary_obj).c_str());
// populate val_boundary_obj structure
memset(&val_boundary_obj, 0, sizeof(val_boundary_obj));
int val_read = session.getArgument(9, val_boundary_obj);
- val_struct = static_cast<void*> (&val_boundary_obj);
- if (val_read != 0) {
- pfc_log_debug("%s", IpctUtil::get_string(val_boundary_obj).c_str());
+ if (val_read == 0) {
+ val_struct = static_cast<void*> (&val_boundary_obj);
+ pfc_log_info("%s", IpctUtil::get_string(val_boundary_obj).c_str());
} else {
pfc_log_debug("No value structure provided in read request");
}
return;
}
+/**AddControllerStructure
+ * @Description : This function is to add the value structure of the controller
+ * @param[in] : &session - Object of ServerSession where the request
+ * argument present
+ * obj_buffer - object of the read buffer
+ * &err - refers to the error value
+ * @return : Void
+ * */
void ReadRequest::AddControllerStructure(ServerSession &session,
BulkReadBuffer obj_buffer,
int &err) {
unc_key_type_t key_type = obj_buffer.key_type;
ValueType value_type = obj_buffer.value_type;
- if (value_type == IS_KEY) {
- ADD_KEY_TO_SESSION(err, session,
- (uint32_t)key_type,
- reinterpret_cast<key_ctr_t*>(obj_buffer.value),
- key_ctr_t);
- }
- if (value_type == IS_VALUE) {
- ADD_VALUE_TO_SESSION(err, session,
- reinterpret_cast<val_ctr_t*>(obj_buffer.value),
- val_ctr_t);
- }
- if (value_type == IS_STATE_VALUE) {
- ADD_VALUE_TO_SESSION(err, session,
- reinterpret_cast<val_ctr_st_t*>(obj_buffer.value),
- val_ctr_st_t);
+ switch (value_type) {
+ case IS_KEY :
+ ADD_KEY_TO_SESSION(err, session,
+ (uint32_t)key_type,
+ reinterpret_cast<key_ctr_t*>(obj_buffer.value),
+ key_ctr_t);
+ break;
+ case IS_VALUE:
+ ADD_VALUE_TO_SESSION(err, session,
+ reinterpret_cast<val_ctr_t*>(obj_buffer.value),
+ val_ctr_t);
+ break;
+ case IS_STATE_VALUE:
+ ADD_VALUE_TO_SESSION(err, session,
+ reinterpret_cast<val_ctr_st_t*>(obj_buffer.value),
+ val_ctr_st_t);
+ break;
+ default:
+ break;
}
return;
}
+/**AddDomainStructure
+ * @Description : This function is to add the value structure of the domain
+ * @param[in] : &session - Object of ServerSession where the request
+ * argument present
+ * obj_buffer - object of the read buffer
+ * &err - refers to the error value
+ * @return : Void
+ * */
void ReadRequest::AddDomainStructure(ServerSession &session,
BulkReadBuffer obj_buffer,
int &err) {
unc_key_type_t key_type = obj_buffer.key_type;
ValueType value_type = obj_buffer.value_type;
- if (value_type == IS_KEY) {
- ADD_KEY_TO_SESSION(err, session,
- (uint32_t)key_type,
- reinterpret_cast<key_ctr_domain_t*>(obj_buffer.value),
- key_ctr_domain_t);
- }
- if (value_type == IS_VALUE) {
- ADD_VALUE_TO_SESSION(
- err, session,
- reinterpret_cast<val_ctr_domain_t*>(obj_buffer.value),
- val_ctr_domain_t);
- }
- if (value_type == IS_STATE_VALUE) {
- ADD_VALUE_TO_SESSION(
- err, session,
- reinterpret_cast<val_ctr_domain_st_t*>(obj_buffer.value),
- val_ctr_domain_st_t);
+ switch (value_type) {
+ case IS_KEY:
+ ADD_KEY_TO_SESSION(err, session,
+ (uint32_t)key_type,
+ reinterpret_cast<key_ctr_domain_t*>(obj_buffer.value),
+ key_ctr_domain_t);
+ break;
+ case IS_VALUE:
+ ADD_VALUE_TO_SESSION(
+ err, session,
+ reinterpret_cast<val_ctr_domain_t*>(obj_buffer.value),
+ val_ctr_domain_t);
+ break;
+ case IS_STATE_VALUE:
+ ADD_VALUE_TO_SESSION(
+ err, session,
+ reinterpret_cast<val_ctr_domain_st_t*>(obj_buffer.value),
+ val_ctr_domain_st_t);
+ break;
+ default:
+ break;
}
return;
}
+/**AddLogicalPortStructure
+ * @Description : This function is to add the value structure of the
+ * logical port
+ * @param[in] : &session - Object of ServerSession where the request
+ * argument present
+ * obj_buffer - object of the read buffer
+ * &err - refers to the error value
+ * @return : Void
+ * */
void ReadRequest::AddLogicalPortStructure(ServerSession &session,
BulkReadBuffer obj_buffer,
int &err) {
unc_key_type_t key_type = obj_buffer.key_type;
ValueType value_type = obj_buffer.value_type;
- if (value_type == IS_KEY) {
- ADD_KEY_TO_SESSION(
- err, session,
- (uint32_t)key_type,
- reinterpret_cast<key_logical_port_t*>(obj_buffer.value),
- key_logical_port_t);
- }
- if (value_type == IS_VALUE) {
- ADD_VALUE_TO_SESSION(
- err, session,
- reinterpret_cast<val_logical_port_t*>(obj_buffer.value),
- val_logical_port_t);
- }
- if (value_type == IS_STATE_VALUE) {
- ADD_VALUE_TO_SESSION(
- err, session,
- reinterpret_cast<val_logical_port_st_t*>(obj_buffer.value),
- val_logical_port_st_t);
+ switch (value_type) {
+ case IS_KEY:
+ ADD_KEY_TO_SESSION(
+ err, session,
+ (uint32_t)key_type,
+ reinterpret_cast<key_logical_port_t*>(obj_buffer.value),
+ key_logical_port_t);
+ break;
+ case IS_VALUE:
+ ADD_VALUE_TO_SESSION(
+ err, session,
+ reinterpret_cast<val_logical_port_t*>(obj_buffer.value),
+ val_logical_port_t);
+ break;
+ case IS_STATE_VALUE:
+ ADD_VALUE_TO_SESSION(
+ err, session,
+ reinterpret_cast<val_logical_port_st_t*>(obj_buffer.value),
+ val_logical_port_st_t);
+ break;
+ default:
+ break;
}
return;
}
+/**AddLogicalMemberPortStructure
+ * @Description : This function is to add the value structure of the
+ * logical member port
+ * @param[in] : &session - Object of ServerSession where the request
+ * argument present
+ * obj_buffer - object of the read buffer
+ * &err - refers to the error value
+ * @return : Void
+ * */
void ReadRequest::AddLogicalMemberPortStructure(ServerSession &session,
BulkReadBuffer obj_buffer,
int &err) {
return;
}
+/**AddSwitchStructure
+ * @Description : This function is to add the value structure of the switch
+ * @param[in] : &session - Object of ServerSession where the request
+ * argument present
+ * obj_buffer - object of the read buffer
+ * &err - refers to the error value
+ * @return : Void
+ * */
void ReadRequest::AddSwitchStructure(ServerSession &session,
BulkReadBuffer obj_buffer,
int &err) {
unc_key_type_t key_type = obj_buffer.key_type;
ValueType value_type = obj_buffer.value_type;
-
- if (value_type == IS_KEY) {
- ADD_KEY_TO_SESSION(
- err, session,
- (uint32_t)key_type,
- reinterpret_cast<key_switch_t*>(obj_buffer.value),
- key_switch_t);
- }
- if (value_type == IS_VALUE) {
- ADD_VALUE_TO_SESSION(
- err, session,
- reinterpret_cast<val_switch_t*>(obj_buffer.value),
- val_switch_t);
- }
- if (value_type == IS_STATE_VALUE) {
- ADD_VALUE_TO_SESSION(
- err, session,
- reinterpret_cast<val_switch_st_t*>(obj_buffer.value),
- val_switch_st_t);
+ switch (value_type) {
+ case IS_KEY:
+ ADD_KEY_TO_SESSION(
+ err, session,
+ (uint32_t)key_type,
+ reinterpret_cast<key_switch_t*>(obj_buffer.value),
+ key_switch_t);
+ break;
+ case IS_VALUE:
+ ADD_VALUE_TO_SESSION(
+ err, session,
+ reinterpret_cast<val_switch_t*>(obj_buffer.value),
+ val_switch_t);
+ break;
+ case IS_STATE_VALUE:
+ ADD_VALUE_TO_SESSION(
+ err, session,
+ reinterpret_cast<val_switch_st_t*>(obj_buffer.value),
+ val_switch_st_t);
+ break;
+ default:
+ break;
}
return;
}
+/**AddPortStructure
+ * @Description : This function is to add the value structure of the port
+ * @param[in] : &session - Object of ServerSession where the request
+ * argument present
+ * obj_buffer - object of the read buffer
+ * &err - refers to the error value
+ * @return : Void
+ * */
void ReadRequest::AddPortStructure(ServerSession &session,
BulkReadBuffer obj_buffer,
int &err) {
unc_key_type_t key_type = obj_buffer.key_type;
ValueType value_type = obj_buffer.value_type;
-
- if (value_type == IS_KEY) {
- ADD_KEY_TO_SESSION(
- err, session,
- (uint32_t)key_type,
- reinterpret_cast<key_port_t*>(obj_buffer.value),
- key_port_t);
- }
- if (value_type == IS_VALUE) {
- ADD_VALUE_TO_SESSION(
- err, session,
- reinterpret_cast<val_port_t*>(obj_buffer.value),
- val_port_t);
- }
- if (value_type == IS_STATE_VALUE) {
- ADD_VALUE_TO_SESSION(
- err, session,
- reinterpret_cast<val_port_st_t*>(obj_buffer.value),
- val_port_st_t);
+ switch (value_type) {
+ case IS_KEY:
+ ADD_KEY_TO_SESSION(
+ err, session,
+ (uint32_t)key_type,
+ reinterpret_cast<key_port_t*>(obj_buffer.value),
+ key_port_t);
+ break;
+ case IS_VALUE:
+ ADD_VALUE_TO_SESSION(
+ err, session,
+ reinterpret_cast<val_port_t*>(obj_buffer.value),
+ val_port_t);
+ break;
+ case IS_STATE_VALUE:
+ ADD_VALUE_TO_SESSION(
+ err, session,
+ reinterpret_cast<val_port_st_t*>(obj_buffer.value),
+ val_port_st_t);
+ break;
+ default:
+ break;
}
return;
}
+/**AddLinkStructure
+ * @Description : This function is to add the value structure of the link
+ * @param[in] : &session - Object of ServerSession where the request
+ * argument present
+ * obj_buffer - object of the read buffer
+ * &err - refers to the error value
+ * @return : Void
+ * */
void ReadRequest::AddLinkStructure(ServerSession &session,
BulkReadBuffer obj_buffer,
int &err) {
unc_key_type_t key_type = obj_buffer.key_type;
ValueType value_type = obj_buffer.value_type;
- if (value_type == IS_KEY) {
- ADD_KEY_TO_SESSION(
- err, session,
- (uint32_t)key_type,
- reinterpret_cast<key_link_t*>(obj_buffer.value),
- key_link_t);
- }
- if (value_type == IS_VALUE) {
- ADD_VALUE_TO_SESSION(
- err, session,
- reinterpret_cast<val_link_t*>(obj_buffer.value),
- val_link_t);
- }
- if (value_type == IS_STATE_VALUE) {
- ADD_VALUE_TO_SESSION(
- err, session,
- reinterpret_cast<val_link_st_t*>(obj_buffer.value),
- val_link_st_t);
+ switch (value_type) {
+ case IS_KEY:
+ ADD_KEY_TO_SESSION(
+ err, session,
+ (uint32_t)key_type,
+ reinterpret_cast<key_link_t*>(obj_buffer.value),
+ key_link_t);
+ break;
+ case IS_VALUE:
+ ADD_VALUE_TO_SESSION(
+ err, session,
+ reinterpret_cast<val_link_t*>(obj_buffer.value),
+ val_link_t);
+ break;
+ case IS_STATE_VALUE:
+ ADD_VALUE_TO_SESSION(
+ err, session,
+ reinterpret_cast<val_link_st_t*>(obj_buffer.value),
+ val_link_st_t);
+ break;
+ default:
+ break;
}
return;
}
+/**AddBoundaryStructure
+ * @Description : This function is to add the value structure of the boundary
+ * @param[in] : &session - Object of ServerSession where the request
+ * argument present
+ * obj_buffer - object of the read buffer
+ * &err - refers to the error value
+ * @return : Void
+ * */
void ReadRequest::AddBoundaryStructure(ServerSession &session,
BulkReadBuffer obj_buffer,
int &err) {
unc_key_type_t key_type = obj_buffer.key_type;
+ ValueType value_type = obj_buffer.value_type;
+ switch (value_type) {
+ case IS_KEY:
+ ADD_KEY_TO_SESSION(
+ err, session,
+ (uint32_t)key_type,
+ reinterpret_cast<key_boundary_t*>(obj_buffer.value),
+ key_boundary_t);
+ break;
+ case IS_VALUE:
+ ADD_VALUE_TO_SESSION(
+ err, session,
+ reinterpret_cast<val_boundary_t*>(obj_buffer.value),
+ val_boundary_t);
+ break;
+ case IS_STATE_VALUE:
+ ADD_VALUE_TO_SESSION(
+ err, session,
+ reinterpret_cast<val_boundary_st_t*>(obj_buffer.value),
+ val_boundary_st_t);
+ break;
+ default:
+ break;
+ }
+ return;
+}
+
+/**FlushBulkReadBuffer
+ * @Description : This function is clears the internal buffer used for
+ * Read Bulk
+ * @param[in] : None
+ * @return : None
+ * */
+void ReadRequest::FlushBulkReadBuffer() {
+ vector<BulkReadBuffer> :: iterator iter = vect_bulk_read_buffer.begin();
+ // Delete the memory
+ for (; iter != vect_bulk_read_buffer.end(); ++iter) {
+ BulkReadBuffer obj_buffer = (*iter);
+ unc_key_type_t key_type = obj_buffer.key_type;
+ switch (key_type) {
+ case UNC_KT_CONTROLLER:
+ ClearControllerStructure(obj_buffer);
+ break;
+ case UNC_KT_CTR_DOMAIN:
+ ClearDomainStructure(obj_buffer);
+ break;
+ case UNC_KT_LOGICAL_PORT:
+ ClearLogicalPortStructure(obj_buffer);
+ break;
+ case UNC_KT_LOGICAL_MEMBER_PORT:
+ ClearLogicalMemberPortStructure(obj_buffer);
+ break;
+ case UNC_KT_SWITCH:
+ ClearSwitchStructure(obj_buffer);
+ break;
+ case UNC_KT_PORT:
+ ClearPortStructure(obj_buffer);
+ break;
+ case UNC_KT_LINK:
+ ClearLinkStructure(obj_buffer);
+ break;
+ case UNC_KT_BOUNDARY:
+ ClearBoundaryStructure(obj_buffer);
+ break;
+ default:
+ break;
+ }
+ }
+ // Clear the vector
+ vect_bulk_read_buffer.clear();
+}
+
+/**ClearControllerStructure
+ * @Description : This function is to clear the value structure
+ * of the controller
+ * @param[in] : obj_buffer - object of the read buffer
+ * @return : Void
+ * */
+void ReadRequest::ClearControllerStructure(BulkReadBuffer obj_buffer) {
+ ValueType value_type = obj_buffer.value_type;
+ switch (value_type) {
+ case IS_KEY:
+ CLEAR_KEY(reinterpret_cast<key_ctr_t*>(obj_buffer.value),
+ key_ctr_t);
+ break;
+ case IS_VALUE:
+ CLEAR_VALUE(reinterpret_cast<val_ctr_t*>(obj_buffer.value),
+ val_ctr_t);
+ break;
+ case IS_STATE_VALUE:
+ CLEAR_VALUE(reinterpret_cast<val_ctr_st_t*>(obj_buffer.value),
+ val_ctr_st_t);
+ break;
+ default:
+ break;
+ }
+ return;
+}
+
+/**ClearDomainStructure
+ * @Description : This function is to clear the value structure of the domain
+ * @param[in] : obj_buffer - object of the read buffer
+ * @return : Void
+ * */
+void ReadRequest::ClearDomainStructure(BulkReadBuffer obj_buffer) {
+ ValueType value_type = obj_buffer.value_type;
+ switch (value_type) {
+ case IS_KEY:
+ CLEAR_KEY(reinterpret_cast<key_ctr_domain_t*>(obj_buffer.value),
+ key_ctr_domain_t);
+ break;
+ case IS_VALUE:
+ CLEAR_VALUE(
+ reinterpret_cast<val_ctr_domain_t*>(obj_buffer.value),
+ val_ctr_domain_t);
+ break;
+ case IS_STATE_VALUE:
+ CLEAR_VALUE(
+ reinterpret_cast<val_ctr_domain_st_t*>(obj_buffer.value),
+ val_ctr_domain_st_t);
+ break;
+ default:
+ break;
+ }
+ return;
+}
+
+/**ClearLogicalPortStructure
+ * @Description : This function is to clear the value structure of the
+ * logical port
+ * @param[in] : obj_buffer - object of the read buffer
+ * @return : Void
+ * */
+void ReadRequest::ClearLogicalPortStructure(BulkReadBuffer obj_buffer) {
+ ValueType value_type = obj_buffer.value_type;
+ switch (value_type) {
+ case IS_KEY:
+ CLEAR_KEY(reinterpret_cast<key_logical_port_t*>(obj_buffer.value),
+ key_logical_port_t);
+ break;
+ case IS_VALUE:
+ CLEAR_VALUE(
+ reinterpret_cast<val_logical_port_t*>(obj_buffer.value),
+ val_logical_port_t);
+ break;
+ case IS_STATE_VALUE:
+ CLEAR_VALUE(
+ reinterpret_cast<val_logical_port_st_t*>(obj_buffer.value),
+ val_logical_port_st_t);
+ break;
+ default:
+ break;
+ }
+ return;
+}
+
+/**ClearLogicalMemberPortStructure
+ * @Description : This function is to clear the value structure of the
+ * logical member port
+ * @param[in] : obj_buffer - object of the read buffer
+ * @return : Void
+ * */
+void ReadRequest::ClearLogicalMemberPortStructure(BulkReadBuffer obj_buffer) {
ValueType value_type = obj_buffer.value_type;
if (value_type == IS_KEY) {
- ADD_KEY_TO_SESSION(
- err, session,
- (uint32_t)key_type,
- reinterpret_cast<key_boundary_t*>(obj_buffer.value),
- key_boundary_t);
+ CLEAR_KEY(reinterpret_cast<key_logical_member_port_t*>(obj_buffer.value),
+ key_logical_member_port_t);
}
- if (value_type == IS_VALUE) {
- ADD_VALUE_TO_SESSION(
- err, session,
- reinterpret_cast<val_boundary_t*>(obj_buffer.value),
- val_boundary_t);
+ return;
+}
+
+/**ClearSwitchStructure
+ * @Description : This function is to clear the value structure of the switch
+ * @param[in] : obj_buffer - object of the read buffer
+ * @return : Void
+ * */
+void ReadRequest::ClearSwitchStructure(BulkReadBuffer obj_buffer) {
+ ValueType value_type = obj_buffer.value_type;
+ switch (value_type) {
+ case IS_KEY:
+ CLEAR_KEY(reinterpret_cast<key_switch_t*>(obj_buffer.value),
+ key_switch_t);
+ break;
+ case IS_VALUE:
+ CLEAR_VALUE(
+ reinterpret_cast<val_switch_t*>(obj_buffer.value),
+ val_switch_t);
+ break;
+ case IS_STATE_VALUE:
+ CLEAR_VALUE(
+ reinterpret_cast<val_switch_st_t*>(obj_buffer.value),
+ val_switch_st_t);
+ break;
+ default:
+ break;
}
- if (value_type == IS_STATE_VALUE) {
- ADD_VALUE_TO_SESSION(
- err, session,
- reinterpret_cast<val_boundary_st_t*>(obj_buffer.value),
- val_boundary_st_t);
+ return;
+}
+
+/**ClearPortStructure
+ * @Description : This function is to clear the value structure of the port
+ * @param[in] : obj_buffer - object of the read buffer
+ * @return : Void
+ * */
+void ReadRequest::ClearPortStructure(BulkReadBuffer obj_buffer) {
+ ValueType value_type = obj_buffer.value_type;
+ switch (value_type) {
+ case IS_KEY:
+ CLEAR_KEY(reinterpret_cast<key_port_t*>(obj_buffer.value),
+ key_port_t);
+ break;
+ case IS_VALUE:
+ CLEAR_VALUE(
+ reinterpret_cast<val_port_t*>(obj_buffer.value),
+ val_port_t);
+ break;
+ case IS_STATE_VALUE:
+ CLEAR_VALUE(
+ reinterpret_cast<val_port_st_t*>(obj_buffer.value),
+ val_port_st_t);
+ break;
+ default:
+ break;
+ }
+ return;
+}
+
+/**ClearLinkStructure
+ * @Description : This function is to clear the value structure of the link
+ * @param[in] : obj_buffer - object of the read buffer
+ * @return : Void
+ * */
+void ReadRequest::ClearLinkStructure(BulkReadBuffer obj_buffer) {
+ ValueType value_type = obj_buffer.value_type;
+ switch (value_type) {
+ case IS_KEY:
+ CLEAR_KEY(reinterpret_cast<key_link_t*>(obj_buffer.value),
+ key_link_t);
+ break;
+ case IS_VALUE:
+ CLEAR_VALUE(
+ reinterpret_cast<val_link_t*>(obj_buffer.value),
+ val_link_t);
+ break;
+ case IS_STATE_VALUE:
+ CLEAR_VALUE(
+ reinterpret_cast<val_link_st_t*>(obj_buffer.value),
+ val_link_st_t);
+ break;
+ default:
+ break;
}
return;
}
+/**ClearBoundaryStructure
+ * @Description : This function is to clear the value structure of the boundary
+ * @param[in] : obj_buffer - object of the read buffer
+ * @return : Void
+ * */
+void ReadRequest::ClearBoundaryStructure(BulkReadBuffer obj_buffer) {
+ ValueType value_type = obj_buffer.value_type;
+ switch (value_type) {
+ case IS_KEY:
+ CLEAR_KEY(reinterpret_cast<key_boundary_t*>(obj_buffer.value),
+ key_boundary_t);
+ break;
+ case IS_VALUE:
+ CLEAR_VALUE(
+ reinterpret_cast<val_boundary_t*>(obj_buffer.value),
+ val_boundary_t);
+ break;
+ case IS_STATE_VALUE:
+ CLEAR_VALUE(
+ reinterpret_cast<val_boundary_st_t*>(obj_buffer.value),
+ val_boundary_st_t);
+ break;
+ default:
+ break;
+ }
+ return;
+}
#include "unc/upll_svc.h"
#include "unc/upll_errno.h"
#include "ipc_client_configuration_handler.hh"
+#include "odbcm_db_varbind.hh"
namespace unc {
namespace uppl {
-/*SystemStateChangeRequest()
- * @Description : SystemStateChangeRequest constructor
+/**SystemStateChangeRequest
+ * @Description : This function initializes the member data
* @param[in] : None
- * @return : void
+ * @return : None
*/
SystemStateChangeRequest::SystemStateChangeRequest() {
}
-/*~SystemStateChangeRequest()
- * @Description : SystemStateChangeRequest destructor
+/**~SystemStateChangeRequest
+ * @Description : This function releases memory allocated to
+ * pointer member data
* @param[in] : None
- * @return : void
+ * @return : None
*/
SystemStateChangeRequest::~SystemStateChangeRequest() {
}
-/** SystemStateChangeToStandBy()
- * @Description : Active state to Standby
- * @param[in] : none
- * @return : Success or associated error code
+/**SystemStateChangeToStandBy
+ * @Description : This function change the system state from Active to Standby
+ * Gets the controller list from database and send the DELETE
+ * request to driver
+ * @param[in] : None
+ * @return : UPPL_RC_SUCCESS if the system state is changed to standby
+ * or UPPL_RC_ERR_* if the switchover fails
* */
-UpplReturnCode SystemStateChangeRequest::SystemStateChangeToStandBy() {
- PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
- PhysicalCore* physical_core_ = physical_layer->get_physical_core();
+UpplReturnCode SystemStateChangeRequest::SystemStateChangeToStandBy(
+ OdbcmConnectionHandler *db_conn) {
+ pfc_log_info("Start SystemStateChangeToStandBy");
Kt_Controller kt_ctr;
- UpplReturnCode read_status;
- UpplReturnCode result_code = UPPL_RC_SUCCESS;
- unc_keytype_ctrtype_t controller_type = UNC_CT_PFC;
-
- vector<string> vec_controller_name;
- // Calling the function GetControllerListFromDB
- result_code = GetControllerListFromDb(UNC_DT_RUNNING, vec_controller_name);
-
- if (result_code != UPPL_RC_SUCCESS) {
- pfc_log_info("Getting controller list failed with %d", result_code);
- return UPPL_RC_SUCCESS;
+ vector<void *> vect_ctr_key, vect_ctr_val;
+ key_ctr_t key_ctr_obj;
+ memset(&key_ctr_obj, 0, sizeof(key_ctr_obj));
+ vect_ctr_key.push_back(reinterpret_cast<void *>(&key_ctr_obj));
+ UpplReturnCode read_status = kt_ctr.ReadInternal(db_conn, vect_ctr_key,
+ vect_ctr_val,
+ UNC_DT_RUNNING,
+ UNC_OP_READ_SIBLING_BEGIN);
+ if (read_status != UPPL_RC_SUCCESS) {
+ pfc_log_info("read from running db is %d", read_status);
+ // Check for entries in candidate db
+ return read_status;
}
-
- key_ctr_t obj_key_ctr;
- int err = 0;
+ UpplReturnCode err = UPPL_RC_SUCCESS;
IPCClientDriverHandler pfc_drv_handler(UNC_CT_PFC, err);
+ if (err != UPPL_RC_SUCCESS) {
+ pfc_log_error("Cannot open session to PFC driver");
+ return err;
+ }
+ err = UPPL_RC_SUCCESS;
IPCClientDriverHandler vnp_drv_handler(UNC_CT_VNP, err);
- memset(obj_key_ctr.controller_name,
- '\0',
- sizeof(obj_key_ctr.controller_name));
- // Filling the key structure of KT_CONTROLLER
- for (uint32_t ctrIndex = 0; ctrIndex < vec_controller_name.size();
+ if (err != UPPL_RC_SUCCESS) {
+ pfc_log_error("Cannot open session to VNP driver");
+ return err;
+ }
+ for (uint32_t ctrIndex = 0; ctrIndex < vect_ctr_key.size();
ctrIndex ++) {
- memcpy(obj_key_ctr.controller_name, vec_controller_name[ctrIndex].c_str(),
- vec_controller_name[ctrIndex].length()+1);
- string controller_name = vec_controller_name[ctrIndex].c_str();
- pfc_log_info("vec_controller_name %s",
- controller_name.c_str());
- /* Calling the ReadInternal function of KT_controller to get the
- val structure of related controller */
- vector<void *> vect_ctr_key, vect_ctr_val;
- vect_ctr_key.push_back(reinterpret_cast<void*>(&obj_key_ctr));
- read_status = kt_ctr.ReadInternal(vect_ctr_key, vect_ctr_val,
- (unc_keytype_datatype_t)UNC_DT_RUNNING,
- UNC_OP_READ);
- if (read_status != UPPL_RC_SUCCESS) {
- pfc_log_debug("read_status is %d", read_status);
- pfc_log_error("Could not get details for controller %s",
- controller_name.c_str());
+ key_ctr_t *ctr_key =
+ reinterpret_cast<key_ctr_t*>(vect_ctr_key[ctrIndex]);
+ string controller_name = (const char*)ctr_key->controller_name;
+ pfc_log_debug("controller_name: %s", controller_name.c_str());
+ val_ctr_st_t *obj_val_ctr =
+ reinterpret_cast<val_ctr_st_t*>(vect_ctr_val[ctrIndex]);
+ unc_keytype_ctrtype_t controller_type =
+ (unc_keytype_ctrtype_t)
+ (PhyUtil::uint8touint(obj_val_ctr->controller.type));
+ // Sending the Delete Request to Driver through IPC Framework
+ // construct IPC structure with DELETE operation
+ ClientSession *cli_session = NULL;
+ if (controller_type == UNC_CT_PFC) {
+ pfc_log_debug("Send controller info to PFC driver");
+ cli_session = pfc_drv_handler.ResetAndGetSession();
+ } else if (controller_type == UNC_CT_VNP) {
+ pfc_log_debug("Send controller info to VNP driver");
+ cli_session = vnp_drv_handler.ResetAndGetSession();
} else {
- val_ctr_st_t obj_val_ctr =
- *(reinterpret_cast<val_ctr_st_t*>(&vect_ctr_val[0]));
- controller_type =
- (unc_keytype_ctrtype_t)
- (PhyUtil::uint8touint(obj_val_ctr.controller.type));
- // Sending the Delete Request to Driver through IPC Framework
- // construct IPC structure with DELETE operation
- ClientSession *cli_session = NULL;
- if (controller_type == UNC_CT_PFC) {
- pfc_log_info("PFC Controller Type");
- cli_session = pfc_drv_handler.ResetAndGetSession();
- } else if (controller_type == UNC_CT_VNP) {
- pfc_log_info("VNP Controller Type");
- cli_session = vnp_drv_handler.ResetAndGetSession();
- } else {
- pfc_log_info("DRIVER SUPPORT NOT ADDED YET FOR"
- " UNKNOWN type");
- continue;
- }
- string domain_id;
- driver_request_header rqh = {0, 0, controller_name, domain_id,
- UNC_OP_DELETE, 0, (uint32_t)0, (uint32_t)0,
- UNC_DT_RUNNING, UNC_KT_CONTROLLER};
- err = PhyUtil::sessOutDriverReqHeader(*cli_session, rqh);
- err |= cli_session->addOutput(obj_key_ctr);
- if (err != UPPL_RC_SUCCESS) {
- pfc_log_info("Could not open driver ipc session");
- continue;
- }
- // Send the request to driver
- UpplReturnCode driver_response = UPPL_RC_SUCCESS;
- driver_response_header rsp;
- if (controller_type == UNC_CT_PFC) {
- driver_response = pfc_drv_handler.SendReqAndGetResp(rsp);
- }
- if (controller_type == UNC_CT_VNP) {
- driver_response = vnp_drv_handler.SendReqAndGetResp(rsp);
- }
-
- pfc_log_info("driver_response is %d", driver_response);
- if (driver_response != UPPL_RC_SUCCESS) {
- pfc_log_info(
- "Controller disconnect request failed at "
- "driver with error %d", driver_response);
- }
+ pfc_log_info("Driver support not yet added for unknown controller");
// Release memory allocated for key struct
- key_ctr_t *ctr_key = reinterpret_cast<key_ctr_t*>(vect_ctr_key[0]);
- val_ctr_st_t *ctr_val = reinterpret_cast<val_ctr_st_t*>(vect_ctr_val[0]);
- if (ctr_key != NULL) {
- delete ctr_key;
- ctr_key = NULL;
- }
+ delete ctr_key;
+ ctr_key = NULL;
// delete the val memory
- if (ctr_val != NULL) {
- delete ctr_val;
- ctr_val = NULL;
- }
+ delete obj_val_ctr;
+ obj_val_ctr = NULL;
+ continue;
}
- }
- physical_core_->set_system_state(UPPL_SYSTEM_ST_STANDBY);
- pfc_log_info("SystemStateChangeToStandby returned");
- return result_code;
-}
-
-
-/** GetControllerListFromDb()
- * @Description : Gets the controller list from the database
- * @param[in] : none
- * @return : Success or associated error code
- * */
-UpplReturnCode SystemStateChangeRequest::GetControllerListFromDb
-(uint32_t data_type, vector<string> &vec_controller_name) {
- UpplReturnCode result_code = UPPL_RC_SUCCESS;
- /* Structure used to send request to ODBC */
- DBTableSchema dbtableschema_obj;
- /* Construct Primary key list */
- vector<string> vect_prim_keys;
- vect_prim_keys.push_back("controller_name");
- /* construct TableAttrSchema structure
- TableAttrSchema holds table_name, primary key, attr_name */
- vector<TableAttrSchema> vect_table_attr_schema;
- TableAttrSchema table_attr_schema_obj;
- list< vector<TableAttrSchema> > row_list;
- dbtableschema_obj.set_table_name("controller_table");
- dbtableschema_obj.set_primary_keys(vect_prim_keys);
-
- string controller_name;
- /* controller_name */
- PhyUtil::FillDbSchema("controller_name", controller_name,
- controller_name.length(), DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
-
- dbtableschema_obj.PushBackToRowList(vect_table_attr_schema);
- PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
- string table_name = "controller_table";
-
- ODBCM_RC_STATUS db_status = physical_layer->get_odbc_manager()->
- GetBulkRows((unc_keytype_datatype_t)data_type, UPPL_MAX_REP_CT,
- dbtableschema_obj, UNC_OP_READ_SIBLING);
- if (db_status != ODBCM_RC_SUCCESS) {
- if (db_status == ODBCM_RC_CONNECTION_ERROR) {
- /* log fatal error to log daemon */
- pfc_log_fatal(
- "DB connection not available or cannot access DB, error=%d",
- db_status);
- result_code = UPPL_RC_ERR_DB_ACCESS;
- } else {
- /* log error to log daemon */
- pfc_log_info("GetControllerListFromDb :DB error %d", db_status);
- result_code = UPPL_RC_ERR_DB_GET;
+ string domain_id = "";
+ driver_request_header rqh = {0, 0, controller_name, domain_id,
+ UNC_OP_DELETE, 0, (uint32_t)0, (uint32_t)0,
+ UNC_DT_RUNNING, UNC_KT_CONTROLLER};
+ int err = PhyUtil::sessOutDriverReqHeader(*cli_session, rqh);
+ err |= cli_session->addOutput(*ctr_key);
+ if (err != UPPL_RC_SUCCESS) {
+ pfc_log_info("Could not open driver ipc session");
+ // Release memory allocated for key struct
+ delete ctr_key;
+ ctr_key = NULL;
+ // delete the val memory
+ delete obj_val_ctr;
+ obj_val_ctr = NULL;
+ continue;
}
- return result_code;
- }
- pfc_log_debug("Traversing the list");
- // To traverse the list
- list<vector<TableAttrSchema> > ::iterator iter_list;
- vector<TableAttrSchema> :: iterator iter_vector; // To traverse the vector
- unsigned int list_of_row, attr_vector;
- for (list_of_row = 0, iter_list = dbtableschema_obj.row_list_.begin();
- iter_list != dbtableschema_obj.row_list_.end();
- iter_list++, list_of_row++) {
- pfc_log_debug("Traversing the dbtableschema_obj.row_list");
- /* This vector contains all attributes of a row in a table */
- vector<TableAttrSchema> attributes_vector = *iter_list;
- TableAttrSchema attribute;
- /* Get the column names and values */
- for (attr_vector = 0, iter_vector = attributes_vector.begin();
- iter_vector != attributes_vector.end();
- attr_vector++, iter_vector++) {
- /* Get attribute name of a row */
- pfc_log_debug("Traversing the Attributes vector");
- attribute = (*iter_vector);
- pfc_log_debug("Getting the attribute: %s",
- attribute.table_attribute_name.c_str());
- if (attribute.table_attribute_name == "controller_name") {
- string *pattr_value =
- reinterpret_cast<string*>(&attribute.p_table_attribute_value);
- string controller_name = *pattr_value;
- pfc_log_info("controller_name: %s", controller_name.c_str());
- vec_controller_name.push_back(controller_name.c_str());
- }
+ // Send the request to driver
+ UpplReturnCode driver_response = UPPL_RC_SUCCESS;
+ driver_response_header rsp;
+ if (controller_type == UNC_CT_PFC) {
+ driver_response = pfc_drv_handler.SendReqAndGetResp(rsp);
}
+ if (controller_type == UNC_CT_VNP) {
+ driver_response = vnp_drv_handler.SendReqAndGetResp(rsp);
+ }
+
+ pfc_log_debug("driver_response is %d", driver_response);
+ if (driver_response != UPPL_RC_SUCCESS) {
+ pfc_log_info(
+ "Controller disconnect request failed at "
+ "driver with error %d", driver_response);
+ }
+ // Release memory allocated for key struct
+ delete ctr_key;
+ ctr_key = NULL;
+ // delete the val memory
+ delete obj_val_ctr;
+ obj_val_ctr = NULL;
}
- pfc_log_info("GetContrllerListFrom db result code is %d", result_code);
- return result_code;
+ PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
+ PhysicalCore* physical_core = physical_layer->get_physical_core();
+ physical_core->set_system_state(UPPL_SYSTEM_ST_STANDBY);
+ pfc_log_info("SystemStateChangeToStandby returned SUCCESS");
+ return UPPL_RC_SUCCESS;
}
-/** SystemStateChangeToStandBy()
- * @Description : Standby state to Active
- * @param[in] : none
- * @return : Success or associated error code
+/**SystemStateChangeToActive
+ * @Description : This function change the system state from Standby to active.
+ * Gets the controller list from database and send the CREATE
+ * request to driver
+ * @param[in] : None
+ * @return : UPPL_RC_SUCCESS if the system state is changed to active
+ * or UPPL_RC_ERR_* if the switchover fails
* */
-UpplReturnCode SystemStateChangeRequest::SystemStateChangeToActive() {
- Kt_Controller kt_ctr;
- UpplReturnCode read_status, operation_status;
- UpplReturnCode controller_status;
- UpplReturnCode result_code = UPPL_RC_SUCCESS;
- uint8_t oper_status;
- unc_keytype_ctrtype_t controller_type;
-
+UpplReturnCode SystemStateChangeRequest::SystemStateChangeToActive(
+ OdbcmConnectionHandler *db_conn) {
pfc_log_info("Start SystemStateChangeToActive");
-
- vector<string> vec_controller_name;
- /* Calling the function GetControllerListFromDB */
- controller_status = GetControllerListFromDb(UNC_DT_RUNNING,
- vec_controller_name);
- if (controller_status != UPPL_RC_SUCCESS) {
- pfc_log_info("Getting controller list failed with %d", controller_status);
- return UPPL_RC_SUCCESS;
+ /* Get all the controller entry from running db */
+ Kt_Controller kt_ctr;
+ vector<void *> vect_ctr_key, vect_ctr_val;
+ key_ctr_t key_ctr_obj;
+ memset(&key_ctr_obj, '\0', sizeof(key_ctr_t));
+ vect_ctr_key.push_back(reinterpret_cast<void *>(&key_ctr_obj));
+ UpplReturnCode read_status = kt_ctr.ReadInternal(db_conn, vect_ctr_key,
+ vect_ctr_val,
+ UNC_DT_RUNNING,
+ UNC_OP_READ_SIBLING_BEGIN);
+ if (read_status != UPPL_RC_SUCCESS) {
+ pfc_log_info("read from running db is %d", read_status);
+ // Check for entries in candidate db
+ return SendCandidateInfoToLogical(db_conn);
}
- key_ctr_t obj_key_ctr;
- int err = 0;
+ UpplReturnCode err = UPPL_RC_SUCCESS;
IPCClientDriverHandler pfc_drv_handler(UNC_CT_PFC, err);
+ if (err != UPPL_RC_SUCCESS) {
+ pfc_log_error("Cannot open session to PFC driver");
+ return err;
+ }
+ err = UPPL_RC_SUCCESS;
IPCClientDriverHandler vnp_drv_handler(UNC_CT_VNP, err);
-
- /* Filling the key structure of KT_CONTROLLER */
- for (uint32_t ctrIndex = 0; ctrIndex < vec_controller_name.size();
+ if (err != UPPL_RC_SUCCESS) {
+ pfc_log_error("Cannot open session to VNP driver");
+ return err;
+ }
+ for (uint32_t ctrIndex = 0; ctrIndex < vect_ctr_key.size();
ctrIndex ++) {
- memset(obj_key_ctr.controller_name, '\0',
- sizeof(obj_key_ctr.controller_name));
- memcpy(obj_key_ctr.controller_name, vec_controller_name[ctrIndex].c_str(),
- vec_controller_name[ctrIndex].length()+1);
- pfc_log_info("obj_key_ctr.controller_name %s",
- obj_key_ctr.controller_name);
- pfc_log_info("vec_controller_name %s",
- vec_controller_name[ctrIndex].c_str());
-
- /* Getting the Oper Status of the controller*/
- pfc_log_info("Set the oper Status of controller as DOWN");
- oper_status = UPPL_CONTROLLER_OPER_DOWN;
- operation_status = kt_ctr.SetOperStatus(UNC_DT_RUNNING,
- &obj_key_ctr, oper_status);
- if (operation_status != UPPL_RC_SUCCESS) {
- pfc_log_info("Unable to set the oper status of controller as DOWN");
- }
- /* Calling the ReadInternal function of KT_controller to get the
- val structure of related controller */
- vector<void *> vect_ctr_key, vect_ctr_val;
- vect_ctr_key.push_back(reinterpret_cast<void*>(&obj_key_ctr));
- read_status = kt_ctr.ReadInternal(vect_ctr_key, vect_ctr_val,
- UNC_DT_RUNNING,
- UNC_OP_READ);
- string controller_name = vec_controller_name[ctrIndex].c_str();
- if (read_status != UPPL_RC_SUCCESS) {
- pfc_log_info("read_status is %d", read_status);
- pfc_log_error("Read operation has failed");
- read_status = UPPL_RC_ERR_DB_ACCESS;
- return read_status;
- } else {
- val_ctr_st_t obj_val_ctr =
- *(reinterpret_cast<val_ctr_st_t*>(vect_ctr_val[0]));
- controller_type =
- (unc_keytype_ctrtype_t)
- (PhyUtil::uint8touint(obj_val_ctr.controller.type));
-
- // Sending the Controller Update Information to Logical Layer
- UpplReturnCode upll_result = kt_ctr.SendUpdatedControllerInfoToUPLL(
- UNC_DT_CANDIDATE,
- UNC_OP_CREATE,
- UNC_KT_CONTROLLER,
- &obj_key_ctr,
- &obj_val_ctr.controller);
- if (upll_result != UPPL_RC_SUCCESS) {
- pfc_log_info("Failed to send the info to UPLL of controller %s",
- controller_name.c_str());
- }
- upll_result = kt_ctr.SendUpdatedControllerInfoToUPLL(
+ key_ctr_t *ctr_key =
+ reinterpret_cast<key_ctr_t*>(vect_ctr_key[ctrIndex]);
+ string controller_name = (const char*)ctr_key->controller_name;
+ pfc_log_debug("controller_name: %s", controller_name.c_str());
+ val_ctr_st_t *obj_val_ctr =
+ reinterpret_cast<val_ctr_st_t*>(vect_ctr_val[ctrIndex]);
+ unc_keytype_ctrtype_t controller_type =
+ (unc_keytype_ctrtype_t)
+ (PhyUtil::uint8touint(obj_val_ctr->controller.type));
+ if (controller_type != UNC_CT_UNKNOWN) {
+ pfc_log_info("Set the oper Status of controller as down %s",
+ controller_name.c_str());
+ uint8_t oper_status = UPPL_CONTROLLER_OPER_DOWN;
+ UpplReturnCode operation_status = kt_ctr.SetOperStatus(
+ db_conn,
UNC_DT_RUNNING,
- UNC_OP_CREATE,
- UNC_KT_CONTROLLER,
- &obj_key_ctr,
- &obj_val_ctr.controller);
- if (upll_result != UPPL_RC_SUCCESS) {
- pfc_log_info("Failed to send the info to UPLL of controller %s",
- controller_name.c_str());
+ vect_ctr_key[ctrIndex],
+ oper_status);
+ if (operation_status != UPPL_RC_SUCCESS) {
+ pfc_log_error("Unable to set the oper status of controller as down");
}
- /* Sending the Create Request to Driver through IPC Framework
+ }
+ // Sending the Controller Update Information to Logical Layer
+ UpplReturnCode upll_result = kt_ctr.SendUpdatedControllerInfoToUPLL(
+ UNC_DT_CANDIDATE,
+ UNC_OP_CREATE,
+ UNC_KT_CONTROLLER,
+ vect_ctr_key[ctrIndex],
+ reinterpret_cast<void*>(&obj_val_ctr->controller));
+ if (upll_result != UPPL_RC_SUCCESS) {
+ pfc_log_info("Failed to send the controller %s in candidate to UPLL",
+ controller_name.c_str());
+ }
+ upll_result = kt_ctr.SendUpdatedControllerInfoToUPLL(
+ UNC_DT_RUNNING,
+ UNC_OP_CREATE,
+ UNC_KT_CONTROLLER,
+ vect_ctr_key[ctrIndex],
+ reinterpret_cast<void*>(&obj_val_ctr->controller));
+ if (upll_result != UPPL_RC_SUCCESS) {
+ pfc_log_info("Failed to send the controller %s in running to UPLL",
+ controller_name.c_str());
+ }
+ /* Sending the Create Request to Driver through IPC Framework
construct IPC structure with CREATE operation */
- ClientSession *cli_session = NULL;
- if (controller_type == UNC_CT_PFC) {
- pfc_log_info("PFC Controller Type");
- cli_session = pfc_drv_handler.ResetAndGetSession();
- } else if (controller_type == UNC_CT_VNP) {
- pfc_log_info("VNP Controller Type");
- cli_session = vnp_drv_handler.ResetAndGetSession();
- } else {
- pfc_log_info("DRIVER SUPPORT NOT ADDED YET FOR UNKNOWN type");
- continue;
- }
- string domain_id;
- driver_request_header rqh = {0, 0, controller_name, domain_id,
- UNC_OP_CREATE, 0, (uint32_t)0, (uint32_t)0,
- UNC_DT_RUNNING, UNC_KT_CONTROLLER};
- int err = PhyUtil::sessOutDriverReqHeader(*cli_session, rqh);
- err |= cli_session->addOutput(obj_key_ctr);
- err |= cli_session->addOutput(obj_val_ctr.controller);
- if (err != UPPL_RC_SUCCESS) {
- pfc_log_error("Could not add objects to driver ipc session");
- continue;
- }
- pfc_log_info("Sending connect request to driver");
- // Send the request to driver
- UpplReturnCode driver_response = UPPL_RC_SUCCESS;
- driver_response_header rsp;
- if (controller_type == UNC_CT_PFC) {
- driver_response = pfc_drv_handler.SendReqAndGetResp(rsp);
- }
- if (controller_type == UNC_CT_VNP) {
- driver_response = vnp_drv_handler.SendReqAndGetResp(rsp);
- }
-
- pfc_log_info("driver_response is %d", driver_response);
- if (err !=0 || driver_response != UPPL_RC_SUCCESS) {
- pfc_log_error(
- "Could not connect to controller %s, driver returned error %d",
- controller_name.c_str(), driver_response);
- }
+ ClientSession *cli_session = NULL;
+ if (controller_type == UNC_CT_PFC) {
+ pfc_log_debug("Send controller info to PFC driver");
+ cli_session = pfc_drv_handler.ResetAndGetSession();
+ } else if (controller_type == UNC_CT_VNP) {
+ pfc_log_debug("Send controller info to VNP driver");
+ cli_session = vnp_drv_handler.ResetAndGetSession();
+ } else {
+ pfc_log_info("Driver support not yet added for unknown controller");
// Release memory allocated for key struct
- key_ctr_t *ctr_key = reinterpret_cast<key_ctr_t*>(vect_ctr_key[0]);
- val_ctr_st_t *ctr_val = reinterpret_cast<val_ctr_st_t*>(vect_ctr_val[0]);
- if (ctr_key != NULL) {
- delete ctr_key;
- ctr_key = NULL;
- }
+ delete ctr_key;
+ ctr_key = NULL;
// delete the val memory
- if (ctr_val != NULL) {
- delete ctr_val;
- ctr_val = NULL;
- }
+ delete obj_val_ctr;
+ obj_val_ctr = NULL;
+ continue;
+ }
+ string domain_id = "";
+ driver_request_header rqh = {0, 0, controller_name, domain_id,
+ UNC_OP_CREATE, 0, (uint32_t)0, (uint32_t)0,
+ UNC_DT_RUNNING, UNC_KT_CONTROLLER};
+ int err = PhyUtil::sessOutDriverReqHeader(*cli_session, rqh);
+ err |= cli_session->addOutput(*ctr_key);
+ err |= cli_session->addOutput(obj_val_ctr->controller);
+ if (err != UPPL_RC_SUCCESS) {
+ pfc_log_error("Could not add objects to driver ipc session");
+ // Release memory allocated for key struct
+ delete ctr_key;
+ ctr_key = NULL;
+ // delete the val memory
+ delete obj_val_ctr;
+ obj_val_ctr = NULL;
+ continue;
+ }
+ pfc_log_info("Sending connect request to driver");
+ // Send the request to driver
+ UpplReturnCode driver_response = UPPL_RC_SUCCESS;
+ driver_response_header rsp;
+ if (controller_type == UNC_CT_PFC) {
+ driver_response = pfc_drv_handler.SendReqAndGetResp(rsp);
+ }
+ if (controller_type == UNC_CT_VNP) {
+ driver_response = vnp_drv_handler.SendReqAndGetResp(rsp);
+ }
+
+ pfc_log_debug("driver_response is %d", driver_response);
+ if (err !=0 || driver_response != UPPL_RC_SUCCESS) {
+ pfc_log_error(
+ "Could not connect to controller %s, driver returned error %d",
+ controller_name.c_str(), driver_response);
+ }
+ // Release memory allocated for key struct
+ delete ctr_key;
+ ctr_key = NULL;
+ // delete the val memory
+ delete obj_val_ctr;
+ obj_val_ctr = NULL;
+ }
+ pfc_log_info("SystemStateChangeToActive returned SUCCESS");
+ return UPPL_RC_SUCCESS;
+}
+
+/**SendCandidateInfoToLogical
+ * @Description : This function gets the controller list from candidate database
+ * and send the update request to logical
+ * @param[in] : None
+ * @return : UPPL_RC_SUCCESS if the logical is updated
+ * or UPPL_RC_ERR_* if the update fails
+ * */
+UpplReturnCode SystemStateChangeRequest::SendCandidateInfoToLogical(
+ OdbcmConnectionHandler *db_conn) {
+ /* Get all the controller entry from candidate db */
+ Kt_Controller kt_ctr;
+ vector<void *> vect_ctr_key, vect_ctr_val;
+ key_ctr_t key_ctr_obj;
+ memset(&key_ctr_obj, '\0', sizeof(key_ctr_t));
+ vect_ctr_key.push_back(reinterpret_cast<void *>(&key_ctr_obj));
+ UpplReturnCode read_status = kt_ctr.ReadInternal(db_conn, vect_ctr_key,
+ vect_ctr_val,
+ UNC_DT_CANDIDATE,
+ UNC_OP_READ_SIBLING_BEGIN);
+ if (read_status != UPPL_RC_SUCCESS) {
+ pfc_log_info("read from candidate db is %d", read_status);
+ return UPPL_RC_SUCCESS;
+ }
+
+ for (uint32_t ctrIndex = 0; ctrIndex < vect_ctr_key.size();
+ ctrIndex ++) {
+ key_ctr_t *ctr_key =
+ reinterpret_cast<key_ctr_t*>(vect_ctr_key[ctrIndex]);
+ string controller_name = (const char*)ctr_key->controller_name;
+ pfc_log_debug("controller_name: %s", controller_name.c_str());
+ val_ctr_st_t *obj_val_ctr =
+ reinterpret_cast<val_ctr_st_t*>(vect_ctr_val[ctrIndex]);
+ // Sending the Controller Update Information to Logical Layer
+ UpplReturnCode upll_result = kt_ctr.SendUpdatedControllerInfoToUPLL(
+ UNC_DT_CANDIDATE,
+ UNC_OP_CREATE,
+ UNC_KT_CONTROLLER,
+ vect_ctr_key[ctrIndex],
+ reinterpret_cast<void*>(&obj_val_ctr->controller));
+ if (upll_result != UPPL_RC_SUCCESS) {
+ pfc_log_info("Failed to send the controller %s in candidate to UPLL",
+ controller_name.c_str());
}
+ // Release memory allocated for key struct
+ delete ctr_key;
+ ctr_key = NULL;
+ // delete the val memory
+ delete obj_val_ctr;
+ obj_val_ctr = NULL;
}
- pfc_log_info("SystemStateChangeToActive returned %d", result_code);
- return result_code;
+ return UPPL_RC_SUCCESS;
}
} // namespace uppl
} // namespace unc
#include "itc_kt_ctr_domain.hh"
#include "tclib_module.hh"
#include "ipc_client_configuration_handler.hh"
+#include "ipct_util.hh"
-/** TransactionRequest
- * * @Description : This function is used to initialise the member data.
- * * * @param[in] : None
- * * * @return : void
+/**TransactionRequest
+ * @Description : This function initializes the member data
+ * @param[in] : None
+ * @return : None
* */
TransactionRequest::TransactionRequest() {
}
-/** ~TransactionRequest
- * * @Description : This function is used to release any memory
- allocated to a pointer member data.
- * * * @param[in] : None
- * * * @return : void
+
+/**~TransactionRequest
+ * @Description : This function release any memory allocated to a
+ * pointer member data.
+ * @param[in] : None
+ * @return : None
* */
TransactionRequest::~TransactionRequest() {
}
-/** GetModifiedConfiguration : This function is used to get the modified
- * configurations from the Candidate Database.
- * @param[in] : None
- * @return : Success or associated error code
+/** GetModifiedConfiguration
+ * @Description : This function is used to get the modified configurations
+ * from the Candidate Database with respect to row status
+ * @param[in] : row_status - Denotes the row status of the kt_controller,
+ * kt_domain and kt_boundary
+ * @return : UPPL_RC_SUCCESS if the modified configuration obtained or
+ * UPPL_RC_ERR_* for failure
*/
UpplReturnCode TransactionRequest::GetModifiedConfiguration(
- uint32_t session_id,
- uint32_t config_id,
+ OdbcmConnectionHandler *db_conn,
CsRowStatus row_status) {
UpplReturnCode ret_code = UPPL_RC_SUCCESS;
- ret_code = GetModifiedController(row_status);
+ ret_code = GetModifiedController(db_conn, row_status);
if (ret_code != UPPL_RC_SUCCESS) {
return ret_code;
}
- ret_code = GetModifiedDomain(row_status);
+ ret_code = GetModifiedDomain(db_conn, row_status);
if (ret_code != UPPL_RC_SUCCESS) {
return ret_code;
}
- ret_code = GetModifiedBoundary(row_status);
+ ret_code = GetModifiedBoundary(db_conn, row_status);
if (ret_code != UPPL_RC_SUCCESS) {
return ret_code;
}
}
/** StartTransaction
- * * @Description : This function is used to start transaction as soon as
- it is received from TC.
- * * * @param[in] : config_id and session_id
- * * * @return : Success or associated error code
+ * @Description : This function is called when Transaction Start is received
+ * from TC. The trans_state_ will be initialized to TRANS_START
+ * if the current trans_state is TRANS_END, audit state is
+ * AUDIT_END and import_state is IMPORT_END.If not, error will
+ * be returned to TC.Then get the modified configuration from
+ * the candidate database and send the configuration to driver
+ * @param[in] : session_id - ipc session id used for TC validation
+ * config_id - configuration id used for TC validation
+ * @return : UPPL_RC_SUCCESS if the start Transaction is success and set
+ * the trans_state as TRANS_START_SUCCESS or returns
+ * UPPL_RC_ERR_* if the start transaction is failed and set
+ * the trans_state as TRANS_START_FAILURE
* */
-UpplReturnCode TransactionRequest::StartTransaction(uint32_t session_id,
- uint32_t config_id) {
+UpplReturnCode TransactionRequest::StartTransaction(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
+ uint32_t config_id) {
PhysicalCore *physical_core = PhysicalLayer::get_instance()->
get_physical_core();
InternalTransactionCoordinator *itc_trans =
itc_trans->set_trans_state(TRANS_START);
ClearMaps();
// Getting the Created configurations
- if ((GetModifiedConfiguration(session_id,
- config_id,
+ if ((GetModifiedConfiguration(db_conn,
CREATED) != UPPL_RC_SUCCESS)) {
pfc_log_debug("Inside GetCreatedUpdatedConfiguration CREATE !="
"UPPL_RC_SUCCESS");
return UPPL_RC_ERR_TRANSACTION_START;
}
// Getting the Updated configurations and sending to driver
- if ((GetModifiedConfiguration(session_id,
- config_id, UPDATED) != UPPL_RC_SUCCESS)) {
+ if ((GetModifiedConfiguration(db_conn,
+ UPDATED) != UPPL_RC_SUCCESS)) {
pfc_log_debug("Inside GetCreatedUpdatedConfiguration UPDATE !="
"UPPL_RC_SUCCESS");
itc_trans->set_trans_state(TRANS_END);
return UPPL_RC_ERR_TRANSACTION_START;
}
// Getting the Deleted configurations and sending to driver
- if ((GetModifiedConfiguration(session_id,
- config_id,
+ if ((GetModifiedConfiguration(db_conn,
DELETED) != UPPL_RC_SUCCESS)) {
pfc_log_debug("Inside GetDeletedConfiguration != UPPL_RC_SUCCESS");
itc_trans->set_trans_state(TRANS_END);
return UPPL_RC_SUCCESS;
}
-/** HandleVoteRequest
- * * @Description : This function is used to handle the vote Request.
- * * * @param[in] : config_id, session_id and driver_info
- * * * @return : Success or associated error code
+/**HandleVoteRequest
+ * @Description : This function is invoked when the HandleVoteRequest is
+ * received from TC. This function checks whether trans_state_
+ * has the TRANS_START_SUCCESS as precondition, and sets the
+ * trans_state_ to VOTE_WAIT_DRIVER_RESULT .Sends the updated
+ * Controllers list to TC. In case of error, returns error to TC
+ * @param[in] : session_id - ipc session id used for TC validation
+ * config_id - configuration id used for TC validation
+ * @param[out] : driver_info - map that contains the updated controller list
+ * @return : UPPL_RC_SUCCESS if VoteRequest is successfull or
+ * UPPL_RC_ERR_* if VoteRequest is failed
* */
UpplReturnCode TransactionRequest::HandleVoteRequest(uint32_t session_id,
uint32_t config_id,
pfc_log_debug("Inside itc_trans->trans_state() == TRANS_START_SUCCESS");
// Function will check whether any audit/import is going on
itc_trans->set_trans_state(VOTE_BEGIN);
- /* Check the map and store it in the driver info */
- /* PHYSICAL SHOULD NOT SEND UPDATED CONTROLLER LIST
- driver_info = driver_controller_info_map_;
- */
itc_trans->set_trans_state(VOTE_WAIT_DRIVER_RESULT);
} else {
pfc_log_debug("Inside itc_trans->trans_state() != TRANS_START_SUCCESS");
return UPPL_RC_SUCCESS;
}
-/** HandleDriverVoteResult
- * * @Description : This function is used to handle Driver vote result.
- * * * @param[in] : config_id, session_id and driver_id,TcCommitPhaseResult,
- * TcControllerTypeRetMap
- * * * @return : Success or associated error code
- *
- */
+/** HandleDriverResult
+ * @Description : This function is invoked when HandleDriverResult is received
+ * from TC.This function used to handle Driver vote result based
+ * on CommitPhase type. Transction is committed if the phase is
+ * TC_COMMIT_GLOBAL_COMMIT_PHASE and sets the trans_state to
+ * GLOBAL_COMMIT_SUCCESS
+ * @param[in] : session_id - ipc session id used for TC validation
+ * config_id - configuration id used for TC validation
+ * phase - specifies the TC commit phase type.Its a enum value
+ * driver_result - specifies the TC commit phase result.
+ * Its a enum value
+ * @return : UPPL_RC_SUCCESS if the HandleDriverResult is successful or
+ * returns UPPL_RC_ERR_* if HandleDriverResult is failed
+ **/
UpplReturnCode TransactionRequest::HandleDriverResult(
+ OdbcmConnectionHandler *db_conn,
uint32_t session_id,
uint32_t config_id,
TcCommitPhaseType phase,
if (phase == unc::tclib::TC_COMMIT_GLOBAL_COMMIT_PHASE &&
itc_trans->trans_state() == GLOBAL_COMMIT_WAIT_DRIVER_RESULT) {
itc_trans->set_trans_state(GLOBAL_COMMIT_DRIVER_RESULT);
+
+ // Checking whether there is any modified configuration
+ if (controller_created.empty() && controller_deleted.empty() &&
+ controller_updated.empty() && domain_created.empty()&&
+ domain_deleted.empty() && domain_updated.empty() &&
+ boundary_created.empty() && boundary_deleted.empty() &&
+ boundary_updated.empty()) {
+ itc_trans->set_trans_state(GLOBAL_COMMIT_SUCCESS);
+ pfc_log_info("CommitPhase:There are no modified configurations\n");
+ return UPPL_RC_SUCCESS;
+ }
+
/* Storing the Old values of updated controller */
vector<key_ctr_t> :: iterator it_controller =
controller_updated.begin();
pfc_log_debug("Updated Controller is %s ", key_ctr_obj.controller_name);
vector<void *> vect_ctr_key, vect_ctr_val;
vect_ctr_key.push_back(reinterpret_cast<void *>(&key_ctr_obj));
- if (kt_controller.ReadInternal(vect_ctr_key, vect_ctr_val,
+ if (kt_controller.ReadInternal(db_conn, vect_ctr_key, vect_ctr_val,
UNC_DT_RUNNING,
UNC_OP_READ) != UPPL_RC_SUCCESS) {
// Remove the updated key from updated vector
- controller_updated.erase(it_controller++);
+ it_controller = controller_updated.erase(it_controller);
continue;
}
vec_old_val_ctr.push_back(vect_ctr_val[0]);
vector<void *> vect_domain_key;
vector<void *> vect_domain_val_st;
vect_domain_key.push_back(reinterpret_cast<void*>(&key_ctr_domain_obj));
- if (kt_domain.ReadInternal(vect_domain_key,
+ if (kt_domain.ReadInternal(db_conn, vect_domain_key,
vect_domain_val_st,
UNC_DT_RUNNING,
UNC_OP_READ) != UPPL_RC_SUCCESS) {
// Remove the updated key from updated vector
- domain_updated.erase(it_domain++);
+ it_domain = domain_updated.erase(it_domain);
continue;
}
vec_old_val_ctr_domain.push_back(vect_domain_val_st[0]);
vector<void *> vect_boundary_key;
vector<void *> vect_boundary_val_st;
vect_boundary_key.push_back(reinterpret_cast<void*>(&key_boundary_obj));
- if (kt_boundary.ReadInternal(vect_boundary_key, vect_boundary_val_st,
+ if (kt_boundary.ReadInternal(db_conn, vect_boundary_key,
+ vect_boundary_val_st,
UNC_DT_RUNNING,
UNC_OP_READ) != UPPL_RC_SUCCESS) {
// Remove the updated key from updated vector
- boundary_updated.erase(it_boundary++);
+ it_boundary = boundary_updated.erase(it_boundary);
continue;
}
vec_old_val_boundary.push_back(vect_boundary_val_st[0]);
}
ODBCM_RC_STATUS db_commit_status = PhysicalLayer::get_instance()->
get_odbc_manager()->
- CommitAllConfiguration(UNC_DT_CANDIDATE, UNC_DT_RUNNING);
+ CommitAllConfiguration(UNC_DT_CANDIDATE, UNC_DT_RUNNING, db_conn);
if (db_commit_status == ODBCM_RC_SUCCESS) {
pfc_log_info("Configuration Committed Successfully");
+ } else if (db_commit_status == ODBCM_RC_CONNECTION_ERROR) {
+ pfc_log_fatal("Committing Configuration Failed - DB Access Error");
+ return UPPL_RC_ERR_FATAL_COPYDB_CANDID_RUNNING;
} else {
pfc_log_fatal("Committing Configuration Failed");
return UPPL_RC_ERR_FATAL_COPYDB_CANDID_RUNNING;
controller_name.c_str());
ODBCM_RC_STATUS clear_status =
PhysicalLayer::get_instance()->get_odbc_manager()->
- ClearOneInstance(UNC_DT_STATE, controller_name);
+ ClearOneInstance(UNC_DT_STATE, controller_name, db_conn);
if (clear_status != ODBCM_RC_SUCCESS) {
pfc_log_info("State DB clearing failed");
}
pfc_log_debug("TransactionRequest::HandleDriverResult:trans_state()= %d",
itc_trans->trans_state());
pfc_log_debug(" Transaction is Committed !!!");
+ // Update Boundary oper status
+ it_boundary = boundary_created.begin();
+ for (; it_boundary != boundary_created.end();) {
+ key_boundary_obj = *it_boundary;
+ pfc_log_debug("TxnClass:Created Boundary: %s ",
+ key_boundary_obj.boundary_id);
+ vector<void *> vect_boundary_key;
+ vector<void *> vect_boundary_val_st;
+ vect_boundary_key.push_back(reinterpret_cast<void*>(&key_boundary_obj));
+ if (kt_boundary.ReadInternal(db_conn, vect_boundary_key,
+ vect_boundary_val_st,
+ UNC_DT_RUNNING,
+ UNC_OP_READ) != UPPL_RC_SUCCESS) {
+ continue;
+ }
+ vector<OperStatusHolder> ref_oper_status;
+ UpplReturnCode operstatus_return =
+ kt_boundary.HandleOperStatus(
+ db_conn, UNC_DT_RUNNING,
+ reinterpret_cast<void*>(&key_boundary_obj),
+ vect_boundary_val_st[0],
+ ref_oper_status);
+ pfc_log_debug("HandleOperStatus in Create: %d", operstatus_return);
+ kt_boundary.ClearOperStatusHolder(ref_oper_status);
+ // Release memory allocated for key struct
+ key_boundary_t *boundary_key =
+ reinterpret_cast<key_boundary_t*>(vect_boundary_key[0]);
+ if (boundary_key != NULL) {
+ delete boundary_key;
+ boundary_key = NULL;
+ }
+ // Release memory for val structure
+ val_boundary_st_t *bdry_st = reinterpret_cast<val_boundary_st*>
+ (vect_boundary_val_st[0]);
+ if (bdry_st != NULL) {
+ delete bdry_st;
+ bdry_st = NULL;
+ }
+ ++it_boundary;
+ }
pfc_log_info("Starting to send the Notification after"
" committing configuration");
- UpplReturnCode notfn_status = SendControllerNotification(vec_old_val_ctr);
+ UpplReturnCode notfn_status = SendControllerNotification(db_conn,
+ vec_old_val_ctr);
if (notfn_status != UPPL_RC_SUCCESS) {
return notfn_status;
}
- notfn_status = SendDomainNotification(vec_old_val_ctr_domain);
+ notfn_status = SendDomainNotification(db_conn, vec_old_val_ctr_domain);
if (notfn_status != UPPL_RC_SUCCESS) {
return notfn_status;
}
- notfn_status = SendBoundaryNotification(vec_old_val_boundary);
+ notfn_status = SendBoundaryNotification(db_conn, vec_old_val_boundary);
if (notfn_status != UPPL_RC_SUCCESS) {
return notfn_status;
}
return UPPL_RC_SUCCESS;
}
-/** HandleGlobalCommitRequest
- * * @Description : This function is used to handle Global Commit Request.
- * * * @param[in] : config_id, session_id and driver_info
- * * * @return : void
+/**HandleGlobalCommitRequest
+ * @Description : This function handles the Global Commit Request sent by TC.
+ * Checks whether the transaction state is VOTE_SUCCESS as a
+ * precondition and Set the transaction state to
+ * GLOBAL_COMMIT_WAIT_DRIVER_RESULT
+ * @param[in] : session_id - ipc session id used for TC validation
+ * config_id - configuration id used for TC validation
+ * @param[out] : driver_info - contains the controller list
+ * @return : UPPL_RC_SUCCESS if the HandleGlobalCommitRequest is
+ * successful or returns UPPL_RC_ERR_* if
+ * HandleGlobalCommitRequest is failed
* */
UpplReturnCode TransactionRequest::HandleGlobalCommitRequest(
uint32_t session_id,
if (itc_trans->trans_state() == VOTE_SUCCESS) {
pfc_log_debug("itc_trans->trans_state() == VOTE_SUCCESS");
itc_trans->set_trans_state(GLOBAL_COMMIT_BEGIN);
- /* Local validation : and send the list to TC */
- // Set the map with the stored list in the UpdatePhase
- /* PHYSICAL SHOULD NOT SEND UPDATED CONTROLLER LIST
- driver_info = driver_controller_info_map_;
- */
itc_trans->set_trans_state(GLOBAL_COMMIT_WAIT_DRIVER_RESULT);
} else {
pfc_log_debug("itc_trans->trans_state() != VOTE_SUCCESS");
}
/** AbortTransaction
- * * @Description : This function is used to abort the transaction.
- * * * @param[in] : config_id, session_id , driver_info and operation_phase
- * * * @return : Success or associated error code
+ * @Description : This function is used to abort the transaction
+ * Sets the transaction state to TRANS_END
+ * @param[in] : session_id - ipc session id used for TC validation
+ * config_id - configuration id used for TC validation
+ * operation_phase - denotes the TC commit operation phase
+ * @return : UPPL_RC_SUCCESS if the AbortTransaction is successful or
+ * returns UPPL_RC_ERR_* if AbortTransaction is failed
* */
UpplReturnCode TransactionRequest::AbortTransaction(uint32_t session_id,
uint32_t config_id,
get_physical_core();
InternalTransactionCoordinator *itc_trans =
physical_core->get_internal_transaction_coordinator();
- UpplReturnCode result_code = UPPL_RC_SUCCESS;
pfc_log_info("TransactionRequest::AbortTxn called with opn phase %d",
operation_phase);
pfc_log_debug("trans_state()= %d", itc_trans->trans_state());
- DBConfigurationRequest dbconfig;
- // Send the controller info to logical
- result_code = dbconfig.SendDeletedControllerToLogical();
- if (result_code != UPPL_RC_SUCCESS) {
- return result_code;
- }
- result_code = dbconfig.SendCreatedControllerToLogical();
- if (result_code != UPPL_RC_SUCCESS) {
- return result_code;
- }
- result_code = dbconfig.SendUpdatedControllerToLogical();
- if (result_code != UPPL_RC_SUCCESS) {
- return result_code;
- }
ClearMaps();
if (operation_phase == unc::tclib::COMMIT_TRANSACTION_START) {
pfc_log_info("AbortTxn COMMIT_TXN_START - Nothing to do");
}
/** EndTransaction
- * * @Description : This function is used to end the transaction.
- * * * @param[in] : None
- * * * @return : void
+ * @Description : This function is used to end the transaction.Checks whether
+ * whether there is any modified controller configuration and if
+ * its there send notification to driver and set the transaction
+ * state as TRANS_END
+ * @param[in] : session_id - ipc session id used for TC validation
+ * config_id - configuration id used for TC validation
+ * trans_res - specifies the TC transaction end result
+ * @return : UPPL_RC_SUCCESS if the EndTransaction is successful or
+ * returns UPPL_RC_ERR_* if EndTransaction is failed
* */
-UpplReturnCode TransactionRequest::EndTransaction(uint32_t session_id,
- uint32_t config_id) {
+UpplReturnCode TransactionRequest::EndTransaction(
+ OdbcmConnectionHandler *db_conn,
+ uint32_t session_id,
+ uint32_t config_id,
+ TcTransEndResult trans_res ) {
UpplReturnCode ret_code = UPPL_RC_SUCCESS;
PhysicalCore *physical_core = PhysicalLayer::get_instance()->
get_physical_core();
physical_core->get_internal_transaction_coordinator();
pfc_log_info("TransactionRequest::EndTransaction-------");
pfc_log_debug("trans_state()= %d", itc_trans->trans_state());
- string controller_name, driver_name;
+ // Checking the result of the Transaction
+ if (trans_res == unc::tclib::TRANS_END_FAILURE) {
+ itc_trans->set_trans_state(TRANS_END);
+ pfc_log_info("End Transaction:FailureResponse from TC\n");
+ ClearMaps();
+ return UPPL_RC_SUCCESS;
+ }
+ // Checking whether there is any modified controller configuration
+ if (controller_deleted.empty() && controller_created.empty() &&
+ controller_updated.empty()) {
+ itc_trans->set_trans_state(TRANS_END);
+ pfc_log_info("End Transaction:No Modified configurations\n");
+ return UPPL_RC_SUCCESS;
+ }
+ string controller_name = "";
+ string driver_name = "";
unc_keytype_ctrtype_t controller_type;
key_ctr_t key_ctr_obj;
Kt_Controller kt_controller;
- int err = 0;
- IPCClientDriverHandler vnp_drv_handler(UNC_CT_VNP, err);
+ UpplReturnCode err = UPPL_RC_SUCCESS;
IPCClientDriverHandler pfc_drv_handler(UNC_CT_PFC, err);
- if (err != 0) {
- pfc_log_error("Error in getting driver client session");
- return UPPL_RC_ERR_COMMIT_UPDATE_DRIVER_FAILURE;
+ if (err != UPPL_RC_SUCCESS) {
+ pfc_log_fatal("Cannot open session to PFC driver");
+ return err;
+ }
+ err = UPPL_RC_SUCCESS;
+ IPCClientDriverHandler vnp_drv_handler(UNC_CT_VNP, err);
+ if (err != UPPL_RC_SUCCESS) {
+ pfc_log_fatal("Cannot open session to VNP driver");
+ return err;
}
// Sending the 'Delete' Controller Request to Driver
vector<key_ctr_t> :: iterator it_controller = controller_deleted.begin();
"UNKNOWN type");
continue;
}
- string domain_id;
+ string domain_id = "";
driver_request_header rqh = {uint32_t(0), uint32_t(0), controller_name,
domain_id, UNC_OP_DELETE, uint32_t(0),
(uint32_t)0, (uint32_t)0, UNC_DT_RUNNING,
UNC_KT_CONTROLLER};
int err = PhyUtil::sessOutDriverReqHeader(*cli_session, rqh);
err |= cli_session->addOutput(key_ctr_obj);
+ pfc_log_info("%s", IpctUtil::get_string(key_ctr_obj).c_str());
// Send the request to driver
UpplReturnCode driver_response = UPPL_RC_SUCCESS;
driver_response_header rsp;
}
pfc_log_debug("End Trans:Deleted Controller Iterated ");
// Sending the 'Created' Controller Configuration Notification
- SendControllerInfo(UNC_OP_CREATE, session_id, config_id);
+ SendControllerInfo(db_conn, UNC_OP_CREATE, session_id, config_id);
pfc_log_debug("End Trans:Created Controller Iterated ");
// Sending the 'Updated' Controller Request to Driver
- SendControllerInfo(UNC_OP_UPDATE, session_id, config_id);
+ SendControllerInfo(db_conn, UNC_OP_UPDATE, session_id, config_id);
pfc_log_debug("End Trans:Updated Controller Iterated ");
itc_trans->set_trans_state(TRANS_END);
pfc_log_debug("End Trans:Response Code = %d", ret_code);
}
/** ClearMaps
- * * @Description : Clear all maps and vectors
- * * * @param[in] : None
- * * * @return : void
+ * @Description : Clear all maps and vectors that contains controller ,domain
+ * and boundary lists
+ * @param[in] : None
+ * @return : void
* */
void TransactionRequest::ClearMaps() {
/* Clearing the contents of the previously stored controller */
if (!set_controller_vnp.empty())set_controller_vnp.clear();
}
-/** SendControllerNotification
- * * @Description : Send notification to north bound for the modified
- * controllers
- * * * @param[in] : vector of old value structures
- * * * @return : void
+/**SendControllerNotification
+ * @Description : This function is to send notification to north bound for
+ * the modified controllers
+ * @param[in] : vec_old_val_ctr - Vector for storing the old value struct
+ * of the controller
+ * @return : UPPL_RC_SUCCESS if the notification of modified controllers
+ * success or returns UPPL_RC_ERR_* if its failed
* */
UpplReturnCode TransactionRequest::SendControllerNotification(
+ OdbcmConnectionHandler *db_conn,
vector<void *> vec_old_val_ctr) {
// Sending the notification of deleted controllers
uint32_t oper_type = UNC_OP_DELETE;
key_ctr_obj.controller_name);
vector<void *> vect_ctr_key, vect_ctr_val;
vect_ctr_key.push_back(reinterpret_cast<void *>(&key_ctr_obj));
- UpplReturnCode retCode = kt_controller.ReadInternal(vect_ctr_key,
+ UpplReturnCode retCode = kt_controller.ReadInternal(db_conn,
+ vect_ctr_key,
vect_ctr_val,
UNC_DT_CANDIDATE,
UNC_OP_READ);
key_ctr_obj.controller_name);
vector<void *> vect_ctr_key, vect_ctr_val;
vect_ctr_key.push_back(reinterpret_cast<void *>(&key_ctr_obj));
- UpplReturnCode retCode = kt_controller.ReadInternal(vect_ctr_key,
+ UpplReturnCode retCode = kt_controller.ReadInternal(db_conn,
+ vect_ctr_key,
vect_ctr_val,
UNC_DT_CANDIDATE,
UNC_OP_READ);
delete ctr_val;
ctr_val = NULL;
}
+ // delete the old value
+ val_ctr_st_t *ctr_old_val =
+ reinterpret_cast<val_ctr_st_t*>(*it_ctr_old);
+ if (ctr_old_val != NULL) {
+ delete ctr_old_val;
+ ctr_old_val = NULL;
+ }
} else if (retCode == UPPL_RC_ERR_NO_SUCH_INSTANCE) {
// Do nothing
} else {
return UPPL_RC_SUCCESS;
}
-/** SendDomainNotification
- * * @Description : Send notification to north bound for the modified domain
- * * * @param[in] : vector of old value structures
- * * * @return : void
+/**SendDomainNotification
+ * @Description : This function is to send notification to north bound for
+ * the modified domain
+ * @param[in] : vec_old_val_ctr - Vector for storing the old value struct
+ * of the domain
+ * @return : UPPL_RC_SUCCESS if the notification of modified domain
+ * success or returns UPPL_RC_ERR_* if its failed
* */
UpplReturnCode TransactionRequest::SendDomainNotification(
+ OdbcmConnectionHandler *db_conn,
vector<void *> vec_old_val_ctr_domain) {
/*Sending the notification of deleted unknown domain */
uint32_t oper_type = UNC_OP_DELETE;
(&key_ctr_domain_obj);
// For deleted domain, update the oper status in boundary
int ret_notfn = kt_domain.InvokeBoundaryNotifyOperStatus(
- UNC_DT_RUNNING, key_ctr_domain_ptr);
+ db_conn, UNC_DT_RUNNING, key_ctr_domain_ptr);
pfc_log_debug("Boundary Invoke Operation return %d", ret_notfn);
UpplReturnCode nofn_status =
kt_domain.ConfigurationChangeNotification(
vect_key_struct.push_back(key_ctr_domain_ptr);
pfc_log_debug("TxnClass:Controllername: %s",
key_ctr_domain_obj.ctr_key.controller_name);
- UpplReturnCode retCode = kt_domain.ReadInternal(vect_key_struct,
+ UpplReturnCode retCode = kt_domain.ReadInternal(db_conn, vect_key_struct,
vect_new_val,
UNC_DT_CANDIDATE,
UNC_OP_READ);
vect_key_domain.push_back(reinterpret_cast<void*>(&key_ctr_domain_obj));
// For created domain, update the oper status in boundary
int ret_notfn = kt_domain.InvokeBoundaryNotifyOperStatus(
- UNC_DT_RUNNING, reinterpret_cast<void *>(&key_ctr_domain_obj));
+ db_conn, UNC_DT_RUNNING, reinterpret_cast<void *>(&key_ctr_domain_obj));
pfc_log_debug("Domain Invoke Operation return %d", ret_notfn);
- UpplReturnCode retCode = kt_domain.ReadInternal(vect_key_domain,
+ UpplReturnCode retCode = kt_domain.ReadInternal(db_conn, vect_key_domain,
vect_val_domain,
UNC_DT_CANDIDATE,
UNC_OP_READ);
return UPPL_RC_SUCCESS;
}
-/** SendBoundaryNotification
- * * @Description : Send notification to north bound for the modified
- * boundaries
- * * * @param[in] : vector of old value structures
- * * * @return : void
+/**SendBoundaryNotification
+ * @Description : This function is to send notification to north bound for
+ * the modified boundary
+ * @param[in] : vec_old_val_ctr - Vector for storing the old value struct
+ * of the boundary
+ * @return : UPPL_RC_SUCCESS if the notification of modified boundary
+ * success or returns UPPL_RC_ERR_* if its failed
* */
UpplReturnCode TransactionRequest::SendBoundaryNotification(
+ OdbcmConnectionHandler *db_conn,
vector<void *> vec_old_val_boundary) {
/*Sending the notification of deleted boundary */
Kt_Boundary kt_boundary;
vector<void *> vect_boundary_val_st;
vect_boundary_key.push_back(reinterpret_cast<void*>(&key_boundary_obj));
- UpplReturnCode retCode = kt_boundary.ReadInternal(vect_boundary_key,
+ UpplReturnCode retCode = kt_boundary.ReadInternal(db_conn,
+ vect_boundary_key,
vect_boundary_val_st,
UNC_DT_CANDIDATE,
UNC_OP_READ);
vector<void *> vect_boundary_val_st;
key_boundary_t key_boundary_obj = *it_boundary;
vect_boundary_key.push_back(reinterpret_cast<void*>(&key_boundary_obj));
- UpplReturnCode retCode = kt_boundary.ReadInternal(vect_boundary_key,
+ UpplReturnCode retCode = kt_boundary.ReadInternal(db_conn,
+ vect_boundary_key,
vect_boundary_val_st,
UNC_DT_CANDIDATE,
UNC_OP_READ);
return UPPL_RC_SUCCESS;
}
-/** SendControllerInfo
- * * @Description : Send controller information to driver
- * * * @param[in] : operation type
- * * * @return : void
+/**SendControllerInfo
+ * @Description : This function is to send controller information
+ * to driver by creating the ipc session with PFC driver
+ * handler and VNP driver handler
+ * @param[in] : session_id - ipc session id used for TC validation
+ * config_id - configuration id used for TC validation
+ * operation_type - UNC_OP_* specifies the operation
+ * @return : void
* */
-void TransactionRequest::SendControllerInfo(uint32_t operation_type,
+void TransactionRequest::SendControllerInfo(OdbcmConnectionHandler *db_conn,
+ uint32_t operation_type,
uint32_t session_id,
uint32_t config_id) {
vector<key_ctr_t> controller_info;
- int err = 0;
+ UpplReturnCode err = UPPL_RC_SUCCESS;
IPCClientDriverHandler pfc_drv_handler(UNC_CT_PFC, err);
+ if (err != UPPL_RC_SUCCESS) {
+ pfc_log_error("Cannot open session to PFC driver");
+ return;
+ }
+ err = UPPL_RC_SUCCESS;
IPCClientDriverHandler vnp_drv_handler(UNC_CT_VNP, err);
+ if (err != UPPL_RC_SUCCESS) {
+ pfc_log_error("Cannot open session to VNP driver");
+ return;
+ }
PhysicalCore *physical_core = PhysicalLayer::get_instance()->
get_physical_core();
if (operation_type == UNC_OP_CREATE) {
controller_name.c_str());
vector<void *> vect_key_ctr, vect_ctr_val;
vect_key_ctr.push_back(reinterpret_cast<void *>(&key_ctr_obj));
- UpplReturnCode retCode = kt_controller.ReadInternal(vect_key_ctr,
+ UpplReturnCode retCode = kt_controller.ReadInternal(db_conn,
+ vect_key_ctr,
vect_ctr_val,
UNC_DT_CANDIDATE,
UNC_OP_READ);
continue;
}
unc_keytype_ctrtype_t controller_type = UNC_CT_UNKNOWN;
- string driver_name;
+ string driver_name = "";
val_ctr_st_t *val_ctr_new = reinterpret_cast<val_ctr_st_t*>
(vect_ctr_val[0]);
if (val_ctr_new == NULL) {
continue;
}
- string domain_id;
+ string domain_id = "";
driver_request_header rqh = {uint32_t(0), uint32_t(0), controller_name,
domain_id, operation_type, uint32_t(0),
(uint32_t)0, (uint32_t)0, UNC_DT_RUNNING,
int err = PhyUtil::sessOutDriverReqHeader(*cli_session, rqh);
err |= cli_session->addOutput(key_ctr_obj);
err |= cli_session->addOutput(val_ctr_new->controller);
+ pfc_log_info("%s", IpctUtil::get_string(key_ctr_obj).c_str());
+ pfc_log_info("%s", IpctUtil::get_string(*val_ctr_new).c_str());
// Send the request to driver
UpplReturnCode driver_response = UPPL_RC_SUCCESS;
driver_response_header rsp;
}
}
-/** GetModifiedController : This function is used to get the modified
- * controllers from the Candidate Database.
- * @param[in] : row_status
- * @return : Success or associated error code
- */
+/**GetModifiedController
+ * @Description : This function is used to get the modified controllers
+ * from the Candidate Database.
+ * @param[in] : row_status - specifies the row status of modified
+ * row of kt_controller
+ * @return : UPPL_RC_SUCCESS if GetModifiedControllers is successful or
+ * UPPL_RC_ERR_* in case of failure
+ * */
UpplReturnCode TransactionRequest::GetModifiedController(
+ OdbcmConnectionHandler *db_conn,
CsRowStatus row_status) {
UpplReturnCode ret_code = UPPL_RC_SUCCESS;
unc_keytype_ctrtype_t controller_type;
Kt_Controller kt_controller;
vector<void*> vec_key_ctr_modified;
ret_code = kt_controller.GetModifiedRows(
- vec_key_ctr_modified,
+ db_conn, vec_key_ctr_modified,
row_status);
pfc_log_debug("Controller:GetModifiedRows return code = %d", ret_code);
if (ret_code == UPPL_RC_ERR_DB_ACCESS) {
vector<string> vect_ctr_key_value;
vect_ctr_key_value.push_back(controller_name);
UpplReturnCode key_exist_running = kt_controller.IsKeyExists(
- UNC_DT_RUNNING,
+ db_conn, UNC_DT_RUNNING,
vect_ctr_key_value);
if (key_exist_running == UPPL_RC_ERR_DB_ACCESS) {
// Error retrieving information from database, send failure
delete ptr_key_ctr;
ptr_key_ctr = NULL;
if (PhyUtil::get_controller_type(
- controller_name,
+ db_conn, controller_name,
controller_type, UNC_DT_CANDIDATE) == UPPL_RC_SUCCESS) {
if (controller_type == UNC_CT_PFC) {
set_controller_oflow.insert(controller_name);
if (is_controller_recreated == PFC_TRUE) {
// Get existing controller type from RUNNING
if (PhyUtil::get_controller_type(
- controller_name,
+ db_conn, controller_name,
controller_type, UNC_DT_RUNNING) == UPPL_RC_SUCCESS) {
pfc_log_debug(
"Controller %s of type %d is marked for RECREATION",
return UPPL_RC_SUCCESS;
}
-/** GetModifiedDomain : This function is used to get the modified
- * domain from the Candidate Database.
- * @param[in] : row_status
- * @return : Success or associated error code
- */
+/**GetModifiedDomain
+ * @Description : This function is used to get the modified domains
+ * from the Candidate Database.
+ * @param[in] : row_status - specifies the row status of modified
+ * row of kt_domain
+ * @return : UPPL_RC_SUCCESS if GetModifiedDomain is successful or
+ * UPPL_RC_ERR_* in case of failure
+ * */
UpplReturnCode TransactionRequest::GetModifiedDomain(
+ OdbcmConnectionHandler *db_conn,
CsRowStatus row_status) {
UpplReturnCode ret_code = UPPL_RC_SUCCESS;
pfc_log_info("Get Modified Domain for Row Status: %d", row_status);
Kt_Ctr_Domain kt_ctr_domain;
vector<void*> vec_key_ctr_domain_modified;
ret_code = kt_ctr_domain.GetModifiedRows(
- vec_key_ctr_domain_modified,
+ db_conn, vec_key_ctr_domain_modified,
row_status);
pfc_log_debug("Domain:GetModifiedRows return code = %d", ret_code);
if (ret_code == UPPL_RC_ERR_DB_ACCESS) {
(const char*)ptr_key_ctr_domain->ctr_key.controller_name);
vect_domain_key_value.push_back(domain_name);
UpplReturnCode key_exist_running = kt_ctr_domain.IsKeyExists(
- UNC_DT_RUNNING,
+ db_conn, UNC_DT_RUNNING,
vect_domain_key_value);
if (key_exist_running == UPPL_RC_SUCCESS) {
domain_deleted.push_back(*ptr_key_ctr_domain);
return UPPL_RC_SUCCESS;
}
-/** GetModifiedBoundary : This function is used to get the modified
- * boundary from the Candidate Database.
- * @param[in] : row_status
- * @return : Success or associated error code
- */
+/**GetModifiedBoundary
+ * @Description : This function is used to get the modified boundary
+ * from the Candidate Database.
+ * @param[in] : row_status - specifies the row status of modified
+ * row of kt_boundary
+ * @return : UPPL_RC_SUCCESS if GetModifiedBoundary is successful or
+ * UPPL_RC_ERR_* in case of failure
+ * */
UpplReturnCode TransactionRequest::GetModifiedBoundary(
+ OdbcmConnectionHandler *db_conn,
CsRowStatus row_status) {
UpplReturnCode ret_code = UPPL_RC_SUCCESS;
pfc_log_info("Get Modified Boundary for Row Status: %d", row_status);
Kt_Boundary kt_boundary;
vector<void*> vec_key_boundary_modified;
ret_code = kt_boundary.GetModifiedRows(
- vec_key_boundary_modified,
+ db_conn, vec_key_boundary_modified,
row_status);
pfc_log_debug("Controller:GetModifiedRows return code = %d", ret_code);
if (ret_code == UPPL_RC_ERR_DB_ACCESS) {
vect_bdry_key_value.push_back(
(const char*)ptr_key_boundary->boundary_id);
UpplReturnCode key_exist_running = kt_boundary.IsKeyExists(
- UNC_DT_RUNNING,
+ db_conn, UNC_DT_RUNNING,
vect_bdry_key_value);
if (key_exist_running == UPPL_RC_SUCCESS) {
boundary_deleted.push_back(*ptr_key_boundary);
#include "odbcm_common.hh"
#include "odbcm_utils.hh"
#include "odbcm_db_tableschema.hh"
+#include "odbcm_mgr.hh"
using unc::uppl::DBVarbind;
/**
* @Description : Function to bind input parameter of boundary_table
- * @param[in] : vector<TableAttrSchema> &column_attr, HSTMT &r_hstmt
- * @return : ODBCM_RC_STATUS
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * r_hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::bind_boundary_table_input(
- std::vector<TableAttrSchema>& column_attr/*DBTableSchema->rowlist_ entrt*/,
+ std::vector<TableAttrSchema>& column_attr/*DBTableSchema->rowlist_entry*/,
HSTMT &r_hstmt/**statement handler which carries the SQL Query*/) {
SQLRETURN odbc_rc = SQL_SUCCESS; // odbc API's return code initialize with 0
SQLUSMALLINT col_no = 0; // column number
* table_attribute_name value will be compared and corresponding
* structure member will be binded here*/
for (v_iter = column_attr.begin(); v_iter != column_attr.end(); ++v_iter) {
- /*In case of bind failure return the parameter bind error */
- if (odbc_rc == SQL_ERROR||odbc_rc == SQL_INVALID_HANDLE) {
- pfc_log_error("ODBCM::DBVarbind::bind_boundary_table_input"
- "bind parameter error");
- /**in case of error while binding return to application caller with the
- * error code */
- return ODBCM_RC_PARAM_BIND_ERROR;
+ if ((*v_iter).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
}
-
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- BDRY_ID/*attribute name MACRO*/) {
- /**binding structure buffer member for boundart id input,
- * column size is ODBCM_SIZE_32,
- * Data type CHAR[32],
- * and buffer size will passed as length of value */
- odbc_rc = BindInputParameter_SQL_VARCHAR(
+ switch ((*v_iter).table_attribute_name) {
+ case BDRY_ID:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**binding structure buffer member for boundart id input,
+ * column size is ODBCM_SIZE_32,
+ * Data type CHAR[32],
+ * and buffer size will passed as length of value */
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
r_hstmt/**sql statement handler*/,
++col_no/*parameter number (sequential order)*/,
ODBCM_SIZE_32/*column size in DB table*/,
p_boundary_table->szboundary_id/*buffer to carry values*/,
sizeof(p_boundary_table->szboundary_id)-1/**buffer length*/,
NULL/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128/**data type char(128)*/,
- BDRY_DESCRIPTION/*attribute name MACRO*/) {
- /**binding structure buffer member for description input,
- * column size is ODBCM_SIZE_128,
- * Data type CHAR[128], this char data will be converted into
- * binary before store into database table.*/
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/,
- ODBCM_SIZE_128/*column size in DB table*/,
- 0/**decimal point */,
- p_boundary_table->szdescription/*buffer to carry values*/,
- sizeof(p_boundary_table->szdescription)-1,
- NULL/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- BDRY_CTR_NAME1/*attribute name MACRO*/) {
- /**binding structure buffer member for controller name,
- * column size is ODBCM_SIZE_32,
- * data type CHAR[32]*/
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_32,
- 0,
- p_boundary_table->szcontroller_name1,
- sizeof(p_boundary_table->szcontroller_name1)-1,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- BDRY_DM_NAME1/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_VARCHAR(
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_DESCRIPTION:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ /**binding structure buffer member for description input,
+ * column size is ODBCM_SIZE_128,
+ * Data type CHAR[128], this char data will be converted into
+ * binary before store into database table.*/
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/,
+ ODBCM_SIZE_128/*column size in DB table*/,
+ 0/**decimal point */,
+ p_boundary_table->szdescription/*buffer to carry values*/,
+ sizeof(p_boundary_table->szdescription)-1,
+ NULL/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_CTR_NAME1:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**binding structure buffer member for controller name,
+ * column size is ODBCM_SIZE_32,
+ * data type CHAR[32]*/
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_32,
+ 0,
+ p_boundary_table->szcontroller_name1,
+ sizeof(p_boundary_table->szcontroller_name1)-1,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_DM_NAME1:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
r_hstmt,
++col_no,
ODBCM_SIZE_32,
p_boundary_table->szdomain_name1,
sizeof(p_boundary_table-> szdomain_name1)-1,
NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_320/**data type char(320)*/,
- BDRY_PORT_ID1/*attribute name MACRO*/) {
- *p_logicalport_id1_len =
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_PORT_ID1:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_320) {
+ *p_logicalport_id1_len =
strlen((const char*)p_boundary_table->szlogical_port_id1);
- odbc_rc = BindInputParameter_SQL_BINARY(
+ odbc_rc = BindInputParameter_SQL_BINARY(
r_hstmt,
++col_no,
ODBCM_SIZE_320,
p_boundary_table->szlogical_port_id1,
sizeof(p_boundary_table->szlogical_port_id1)-1,
p_logicalport_id1_len);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- BDRY_CTR_NAME2/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_VARCHAR(
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_CTR_NAME2:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
r_hstmt,
++col_no,
ODBCM_SIZE_32,
p_boundary_table->szcontroller_name2,
sizeof(p_boundary_table-> szcontroller_name2)-1,
NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- BDRY_DM_NAME2/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_VARCHAR(
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_DM_NAME2:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
r_hstmt,
++col_no,
ODBCM_SIZE_32,
p_boundary_table->szdomain_name2,
sizeof(p_boundary_table-> szdomain_name2)-1,
NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_320/**data type char(320)*/,
- BDRY_PORT_ID2/*attribute name MACRO*/) {
- *p_logicalport_id2_len =
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_PORT_ID2:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_320) {
+ *p_logicalport_id2_len =
strlen((const char*)p_boundary_table->szlogical_port_id2);
- odbc_rc = BindInputParameter_SQL_BINARY(
+ odbc_rc = BindInputParameter_SQL_BINARY(
r_hstmt,
++col_no,
ODBCM_SIZE_320,
p_boundary_table->szlogical_port_id2,
sizeof(p_boundary_table->szlogical_port_id2)-1,
p_logicalport_id2_len);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT16/**data type char(16)*/,
- BDRY_OPER_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_SMALLINT(
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_OPER_STATUS:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindInputParameter_SQL_SMALLINT(
r_hstmt,
++col_no,
0,
reinterpret_cast<SQLSMALLINT*>(&p_boundary_table->soper_status),
0,
NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_8/**data type char(8)*/,
- BDRY_VALID/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_CHAR(
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_VALID:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_8) {
+ odbc_rc = BindInputParameter_SQL_CHAR(
r_hstmt,
++col_no,
ODBCM_SIZE_8,
p_boundary_table->svalid,
sizeof(p_boundary_table->svalid)-1,
NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT16/**data type char(16)*/,
- BDRY_ROW_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_SMALLINT(
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_ROW_STATUS:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindInputParameter_SQL_SMALLINT(
r_hstmt,
++col_no,
0,
reinterpret_cast<SQLSMALLINT*>(&p_boundary_table->scs_row_status),
0,
NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_8/**data type char(8)*/,
- BDRY_ATTR/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_CHAR(
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_ATTR:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_8) {
+ odbc_rc = BindInputParameter_SQL_CHAR(
r_hstmt,
++col_no,
ODBCM_SIZE_8,
p_boundary_table->scs_attr,
sizeof(p_boundary_table->scs_attr)-1,
NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ default:
+ break;
+ }
+ /*In case of bind failure return the parameter bind error */
+ if (odbc_rc == SQL_ERROR||odbc_rc == SQL_INVALID_HANDLE) {
+ pfc_log_error("ODBCM::DBVarbind::bind_boundary_table_input"
+ "bind parameter error");
+ /**in case of error while binding return to application caller with the
+ * error code */
+ return ODBCM_RC_PARAM_BIND_ERROR;
}
-
if ((*v_iter).p_table_attribute_value != NULL && log_flag == 0) {
if (odbc_rc != SQL_SUCCESS)
ODBCMUtils::OdbcmHandleDiagnosticsPrint(SQL_HANDLE_STMT, r_hstmt);
/**reset flag value 1 */
log_flag = 1;
} else {
- pfc_log_info("ODBCM::**NO bind**i/p:BOUNDARY_TABLE:%s:datatype=%d:",
- ((*v_iter).table_attribute_name).c_str(),
+ pfc_log_debug("ODBCM::**NO bind**i/p:BOUNDARY_TABLE:%s:datatype=%d:",
+ ODBCManager::get_ODBCManager()->GetColumnName(
+ ((*v_iter).table_attribute_name)).c_str(),
(*v_iter).request_attribute_type);
}
} // for loop
/**
* @Description : Output binding function for boundary_table
- * @param[in] : std::vector<<TableAttrSchema>&column_attr, HSTMT &r_hstmt
- * @return : ODBCM_RC_STATUS
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * r_hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::bind_boundary_table_output(
- std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_ entry*/,
+ std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_entry*/,
HSTMT &r_hstmt/**statement handler which carries the SQL Query*/) {
SQLRETURN odbc_rc = SQL_SUCCESS; // odbc APIs return code
SQLINTEGER indptr = 0; // Pointer to value that indicates the number of
* table_attribute_name value will be compared and corresponding
* structure member will be binded here*/
for (v_iter = column_attr.begin(); v_iter != column_attr.end(); ++v_iter) {
- /*In case of bind failure return the parameter bind error */
- if (odbc_rc == SQL_ERROR||odbc_rc == SQL_INVALID_HANDLE) {
- pfc_log_error("ODBCM::DBVarbind::bind_boundary_table_output"
- "bind parameter error");
- /**in case of error while binding return to application caller with the
- * error code */
- return ODBCM_RC_PARAM_BIND_ERROR;
+ if ((*v_iter).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
}
- /**binding structure buffer member for boundary id output,
- * column size is ODBCM_SIZE_32,
- * Data type CHAR[32],
- * and buffer size will passed as length of value,
- * ptr to indicates available no. of bytes return */
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- BDRY_ID/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
+
+ switch ((*v_iter).table_attribute_name) {
+ case BDRY_ID:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**binding structure buffer member for boundary id output,
+ * column size is ODBCM_SIZE_32,
+ * Data type CHAR[32],
+ * and buffer size will passed as length of value,
+ * ptr to indicates available no. of bytes return */
+ odbc_rc = BindCol_SQL_VARCHAR(
r_hstmt/**sql statement handler*/,
++col_no/*parameter number (sequential order)*/,
p_boundary_table->szboundary_id/*buffer to fetch values*/,
ODBCM_SIZE_32+1,
/**no.of bytes available to return*/
reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128,
- BDRY_DESCRIPTION/*attribute name MACRO*/) {
- /**binding structure buffer member for description output,
- * column size is ODBCM_SIZE_128,
- * Data type CHAR[128],
- * and buffer size will passed as length of value,
- * ptr to indicates available no. of bytes return,
- * Binary type values will be converted and stored into char buffer */
- odbc_rc = BindCol_SQL_VARCHAR(
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_DESCRIPTION:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ /**binding structure buffer member for description output,
+ * column size is ODBCM_SIZE_128,
+ * Data type CHAR[128],
+ * and buffer size will passed as length of value,
+ * ptr to indicates available no. of bytes return,
+ * Binary type values will be converted and stored into char buffer */
+ odbc_rc = BindCol_SQL_VARCHAR(
r_hstmt,
++col_no,
p_boundary_table->szdescription,
ODBCM_SIZE_128+1,
reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- BDRY_CTR_NAME1/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_CTR_NAME1:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindCol_SQL_VARCHAR(
r_hstmt,
++col_no,
p_boundary_table->szcontroller_name1,
ODBCM_SIZE_32+1,
reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- BDRY_DM_NAME1/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_DM_NAME1:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindCol_SQL_VARCHAR(
r_hstmt,
++col_no,
p_boundary_table->szdomain_name1,
ODBCM_SIZE_32+1,
reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_320,
- BDRY_PORT_ID1/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_BINARY(
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_PORT_ID1:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_320) {
+ odbc_rc = BindCol_SQL_BINARY(
r_hstmt,
++col_no,
p_boundary_table->szlogical_port_id1,
sizeof(p_boundary_table->szlogical_port_id1)-1,
p_logicalport_id1_len /*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- BDRY_CTR_NAME2/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_CTR_NAME2:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindCol_SQL_VARCHAR(
r_hstmt,
++col_no,
p_boundary_table->szcontroller_name2,
ODBCM_SIZE_32+1,
reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- BDRY_DM_NAME2/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_DM_NAME2:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindCol_SQL_VARCHAR(
r_hstmt,
++col_no,
p_boundary_table->szdomain_name2,
ODBCM_SIZE_32+1,
reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_320,
- BDRY_PORT_ID2/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_BINARY(
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_PORT_ID2:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_320) {
+ odbc_rc = BindCol_SQL_BINARY(
r_hstmt,
++col_no,
p_boundary_table->szlogical_port_id2,
sizeof(p_boundary_table->szlogical_port_id2)-1,
p_logicalport_id2_len /*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- BDRY_OPER_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_SMALLINT(
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_OPER_STATUS:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindCol_SQL_SMALLINT(
r_hstmt,
++col_no,
reinterpret_cast<SQLSMALLINT*>(&p_boundary_table->soper_status),
sizeof(SQLSMALLINT),
reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_8,
- BDRY_VALID/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_VALID:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_8) {
+ odbc_rc = BindCol_SQL_VARCHAR(
r_hstmt,
++col_no,
p_boundary_table->svalid,
ODBCM_SIZE_8+1,
reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- BDRY_ROW_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_SMALLINT(
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_ROW_STATUS:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindCol_SQL_SMALLINT(
r_hstmt,
++col_no,
reinterpret_cast<SQLSMALLINT*>(&p_boundary_table->scs_row_status),
sizeof(SQLSMALLINT),
reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_8,
- BDRY_ATTR/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case BDRY_ATTR:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_8) {
+ odbc_rc = BindCol_SQL_VARCHAR(
r_hstmt,
++col_no,
p_boundary_table->scs_attr,
ODBCM_SIZE_8+1,
reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ default:
+ break;
+ }
+ /*In case of bind failure return the parameter bind error */
+ if (odbc_rc == SQL_ERROR||odbc_rc == SQL_INVALID_HANDLE) {
+ pfc_log_error("ODBCM::DBVarbind::bind_boundary_table_output"
+ "bind parameter error");
+ /**in case of error while binding return to application caller with the
+ * error code */
+ return ODBCM_RC_PARAM_BIND_ERROR;
}
if (log_flag == 0) {
log_flag = 1;
/**
* @Description : To fill the boundary_table values into structure.
- * @param[in] : std::std::vector<TableAttrSchema>&column_attr
- * @return : ODBCM_RC_STATUS
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::fill_boundary_table(
std::vector<TableAttrSchema> &column_attr
- /*DBTableSchema->rowlist_ entry*/) {
+ /*DBTableSchema->rowlist_entry*/) {
/**Vector iterator to take the TableAttrSchema structures*/
std::vector< TableAttrSchema >::iterator v_iter;
/**Loop for iterate all the elements in the vector, the TableAttrSchema
* table_attribute_name value will be compared and corresponding
* structure member will be filled*/
for (v_iter = column_attr.begin(); v_iter != column_attr.end(); ++v_iter) {
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- BDRY_ID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for controller_name CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> bi_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
- ((*v_iter).p_table_attribute_value));
- /**clear the allocated buffer memory to receive the controller_name
- * from caller*/
- ODBCM_MEMSET(p_boundary_table->szboundary_id, 0,
+ if ((*v_iter).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
+ }
+ switch ((*v_iter).table_attribute_name) {
+ case BDRY_ID:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for controller_name CHAR[32]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> bi_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ ((*v_iter).p_table_attribute_value));
+ /**clear the allocated buffer memory to receive the controller_name
+ * from caller*/
+ ODBCM_MEMSET(p_boundary_table->szboundary_id, 0,
sizeof(p_boundary_table->szboundary_id));
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_boundary_table->szboundary_id,
- &bi_value.value,
- (*v_iter).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE: "
- "szboundary_id= %s", p_boundary_table->szboundary_id);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128,
- BDRY_DESCRIPTION/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for description CHAR[128]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_128]> desc_value =
- *((ColumnAttrValue <uint8_t[128]>*)
- ((*v_iter).p_table_attribute_value));
- ODBCM_MEMSET(p_boundary_table->szdescription, 0,
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_boundary_table->szboundary_id,
+ &bi_value.value,
+ (*v_iter).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE: "
+ "szboundary_id= %s", p_boundary_table->szboundary_id);
+ }
+ break;
+ case BDRY_DESCRIPTION:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for description CHAR[128]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_128]> desc_value =
+ *((ColumnAttrValue <uint8_t[128]>*)
+ ((*v_iter).p_table_attribute_value));
+ ODBCM_MEMSET(p_boundary_table->szdescription, 0,
sizeof(p_boundary_table->szdescription));
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_boundary_table->szdescription,
- &desc_value.value,
- (*v_iter).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE: "
- "szdescription = %s", p_boundary_table->szdescription);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- BDRY_CTR_NAME1/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for controller name1 CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> cn_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
- ((*v_iter).p_table_attribute_value));
- ODBCM_MEMSET(p_boundary_table->szcontroller_name1, 0,
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_boundary_table->szdescription,
+ &desc_value.value,
+ (*v_iter).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE: "
+ "szdescription = %s", p_boundary_table->szdescription);
+ }
+ break;
+ case BDRY_CTR_NAME1:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for controller name1 CHAR[32]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> cn_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ ((*v_iter).p_table_attribute_value));
+ ODBCM_MEMSET(p_boundary_table->szcontroller_name1, 0,
sizeof(p_boundary_table->szcontroller_name1));
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_boundary_table->szcontroller_name1,
- &cn_value.value,
- (*v_iter).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE: "
- "szcontroller_name1= %s", p_boundary_table->szcontroller_name1);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- BDRY_DM_NAME1/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for domain name1 CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> dn_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
- ((*v_iter).p_table_attribute_value));
- ODBCM_MEMSET(p_boundary_table->szdomain_name1, 0,
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_boundary_table->szcontroller_name1,
+ &cn_value.value,
+ (*v_iter).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE: "
+ "szcontroller_name1= %s", p_boundary_table->szcontroller_name1);
+ }
+ break;
+ case BDRY_DM_NAME1:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for domain name1 CHAR[32]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> dn_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ ((*v_iter).p_table_attribute_value));
+ ODBCM_MEMSET(p_boundary_table->szdomain_name1, 0,
sizeof(p_boundary_table->szdomain_name1));
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_boundary_table->szdomain_name1,
- &dn_value.value,
- (*v_iter).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE: "
- "szdomain_name1= %s", p_boundary_table->szdomain_name1);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_320,
- BDRY_PORT_ID1/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for port id1 CHAR[320]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_320]> pi_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_320]>*)
- ((*v_iter).p_table_attribute_value));
- ODBCM_MEMSET(p_boundary_table->szlogical_port_id1, 0,
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_boundary_table->szdomain_name1,
+ &dn_value.value,
+ (*v_iter).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE: "
+ "szdomain_name1= %s", p_boundary_table->szdomain_name1);
+ }
+ break;
+ case BDRY_PORT_ID1:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_320) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for port id1 CHAR[320]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_320]> pi_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_320]>*)
+ ((*v_iter).p_table_attribute_value));
+ ODBCM_MEMSET(p_boundary_table->szlogical_port_id1, 0,
sizeof(p_boundary_table->szlogical_port_id1));
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_boundary_table->szlogical_port_id1,
- &pi_value.value,
- (*v_iter).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE:"
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_boundary_table->szlogical_port_id1,
+ &pi_value.value,
+ (*v_iter).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE:"
" szlogical_port_id1= %s", p_boundary_table->szlogical_port_id1);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- BDRY_CTR_NAME2/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for controller name2 CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> cn2_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
- ((*v_iter).p_table_attribute_value));
- ODBCM_MEMSET(p_boundary_table->szcontroller_name2, 0,
+ }
+ break;
+ case BDRY_CTR_NAME2:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for controller name2 CHAR[32]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> cn2_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ ((*v_iter).p_table_attribute_value));
+ ODBCM_MEMSET(p_boundary_table->szcontroller_name2, 0,
sizeof(p_boundary_table->szcontroller_name2));
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_boundary_table->szcontroller_name2,
- &cn2_value.value,
- (*v_iter).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE: "
- "szcontroller_name2= %s", p_boundary_table->szcontroller_name2);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- BDRY_DM_NAME2/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for domain name2 CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> dn2_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
- ((*v_iter).p_table_attribute_value));
- ODBCM_MEMSET(p_boundary_table->szdomain_name2, 0,
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_boundary_table->szcontroller_name2,
+ &cn2_value.value,
+ (*v_iter).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE: "
+ "szcontroller_name2= %s", p_boundary_table->szcontroller_name2);
+ }
+ break;
+ case BDRY_DM_NAME2:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for domain name2 CHAR[32]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> dn2_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ ((*v_iter).p_table_attribute_value));
+ ODBCM_MEMSET(p_boundary_table->szdomain_name2, 0,
sizeof(p_boundary_table->szdomain_name2));
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_boundary_table->szdomain_name2,
- &dn2_value.value,
- (*v_iter).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE: "
- "szdomain_name2= %s", p_boundary_table->szdomain_name2);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_320,
- BDRY_PORT_ID2/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for port id2 CHAR[320]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_320]> pi2_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_320]>*)
- ((*v_iter).p_table_attribute_value));
- ODBCM_MEMSET(p_boundary_table->szlogical_port_id2, 0,
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_boundary_table->szdomain_name2,
+ &dn2_value.value,
+ (*v_iter).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE: "
+ "szdomain_name2= %s", p_boundary_table->szdomain_name2);
+ }
+ break;
+ case BDRY_PORT_ID2:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_320) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for port id2 CHAR[320]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_320]> pi2_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_320]>*)
+ ((*v_iter).p_table_attribute_value));
+ ODBCM_MEMSET(p_boundary_table->szlogical_port_id2, 0,
sizeof(p_boundary_table->szlogical_port_id2));
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_boundary_table->szlogical_port_id2,
- &pi2_value.value,
- (*v_iter).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE:"
- " szlogical_port_id2= %s", p_boundary_table->szlogical_port_id2);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- BDRY_OPER_STATUS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for oper status uint16_t*/
- ColumnAttrValue <uint16_t> rs_value =
- *((ColumnAttrValue <uint16_t>*)((*v_iter).p_table_attribute_value));
- ODBCM_MEMSET(&p_boundary_table->soper_status, 0,
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_boundary_table->szlogical_port_id2,
+ &pi2_value.value,
+ (*v_iter).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE:"
+ " szlogical_port_id2= %s", p_boundary_table->szlogical_port_id2);
+ }
+ break;
+ case BDRY_OPER_STATUS:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for oper status uint16_t*/
+ ColumnAttrValue <uint16_t> rs_value =
+ *((ColumnAttrValue <uint16_t>*)((*v_iter).p_table_attribute_value));
+ ODBCM_MEMSET(&p_boundary_table->soper_status, 0,
sizeof(p_boundary_table->soper_status));
- /**copying the value from template to binded buffer */
- p_boundary_table->soper_status = rs_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE: "
- "soper_status= %d", p_boundary_table->soper_status);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_8,
- BDRY_VALID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for valid CHAR[8]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_8]> valid_value =
- *((ColumnAttrValue<uint8_t[ODBCM_SIZE_8]>*)
- ((*v_iter).p_table_attribute_value));
- ODBCM_MEMSET(p_boundary_table->svalid, 0,
+ /**copying the value from template to binded buffer */
+ p_boundary_table->soper_status = rs_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE: "
+ "soper_status= %d", p_boundary_table->soper_status);
+ }
+ break;
+ case BDRY_VALID:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_8) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for valid CHAR[8]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_8]> valid_value =
+ *((ColumnAttrValue<uint8_t[ODBCM_SIZE_8]>*)
+ ((*v_iter).p_table_attribute_value));
+ ODBCM_MEMSET(p_boundary_table->svalid, 0,
sizeof(p_boundary_table->svalid));
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_boundary_table->svalid,
- &valid_value.value,
- (*v_iter).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE: "
- "sValid = %s", p_boundary_table->svalid);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- BDRY_ROW_STATUS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for row status uint16_t*/
- ColumnAttrValue <uint16_t> rs_value =
- *((ColumnAttrValue <uint16_t>*)((*v_iter).p_table_attribute_value));
- ODBCM_MEMSET(&p_boundary_table->scs_row_status, 0,
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_boundary_table->svalid,
+ &valid_value.value,
+ (*v_iter).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE: "
+ "sValid = %s", p_boundary_table->svalid);
+ }
+ break;
+ case BDRY_ROW_STATUS:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for row status uint16_t*/
+ ColumnAttrValue <uint16_t> rs_value =
+ *((ColumnAttrValue <uint16_t>*)((*v_iter).p_table_attribute_value));
+ ODBCM_MEMSET(&p_boundary_table->scs_row_status, 0,
sizeof(p_boundary_table->scs_row_status));
- p_boundary_table->scs_row_status = rs_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE: "
- "scs_row_status = %d", p_boundary_table->scs_row_status);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_8,
- BDRY_ATTR/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for attr CHAR[8]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_8]> csa_value =
- *((ColumnAttrValue<uint8_t[ODBCM_SIZE_8]>*)
- ((*v_iter).p_table_attribute_value));
- ODBCM_MEMSET(p_boundary_table->scs_attr, 0,
+ p_boundary_table->scs_row_status = rs_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE: "
+ "scs_row_status = %d", p_boundary_table->scs_row_status);
+ }
+ break;
+ case BDRY_ATTR:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_8) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for attr CHAR[8]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_8]> csa_value =
+ *((ColumnAttrValue<uint8_t[ODBCM_SIZE_8]>*)
+ ((*v_iter).p_table_attribute_value));
+ ODBCM_MEMSET(p_boundary_table->scs_attr, 0,
sizeof(p_boundary_table->scs_attr));
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_boundary_table->scs_attr,
- &csa_value.value,
- (*v_iter).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE: "
- "scs_attr = %s", p_boundary_table->scs_attr);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_boundary_table->scs_attr,
+ &csa_value.value,
+ (*v_iter).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:BOUNDARY_TABLE: "
+ "scs_attr = %s", p_boundary_table->scs_attr);
+ }
+ break;
+ default:
+ break;
}
}
return ODBCM_RC_SUCCESS;
/**
* @Description : To fetch the boundary_table values
- * (which are stored in binded buffer) and store into TableAttSchema
- * @param[in] : std::vector<TableAttrSchema>&column_attr
- * @return : ODBCM_RC_STATUS
+ * (which are stored in binded buffer)
+ * and store into TableAttSchema
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::fetch_boundary_table(
std::vector<TableAttrSchema> &column_attr
- /*DBTableSchema->rowlist_ entry*/) {
+ /*DBTableSchema->rowlist_entry*/) {
/**Vector iterator to take the TableAttrSchema structures*/
std::vector< TableAttrSchema >::iterator v_iter;
/**Loop for iterate all the elements in the vector, the TableAttrSchema
* table_attribute_name value will be compared and corresponding
* structure member will be fetched */
for (v_iter = column_attr.begin(); v_iter != column_attr.end(); ++v_iter) {
- ODBCM_COMPARE_FETCH_DATA((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- BDRY_ID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_32+1],
- val_boundary_id);
- ODBCM_MEMCPY(
- val_boundary_id->value,
- p_boundary_table->szboundary_id,
- sizeof(p_boundary_table->szboundary_id));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
- "boundary_id = %s" , val_boundary_id->value);
- (*v_iter).p_table_attribute_value = val_boundary_id;
- } ODBCM_COMPARE_FETCH_DATA((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128,
- BDRY_DESCRIPTION/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_128+1], desc_value);
- ODBCM_MEMCPY(
- desc_value->value,
- p_boundary_table->szdescription,
- sizeof(p_boundary_table->szdescription));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
- "description = %s", desc_value->value);
- (*v_iter).p_table_attribute_value = desc_value;
- } ODBCM_COMPARE_FETCH_DATA((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- BDRY_CTR_NAME1/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_32+1],
- val_controller_name1);
- ODBCM_MEMCPY(
- val_controller_name1->value,
- p_boundary_table->szcontroller_name1,
- sizeof(p_boundary_table->szcontroller_name1));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
- "controller_name1= %s" , val_controller_name1->value);
- (*v_iter).p_table_attribute_value = val_controller_name1;
- } ODBCM_COMPARE_FETCH_DATA((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- BDRY_DM_NAME1/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_32+1],
- val_domain_name1);
- ODBCM_MEMCPY(
- val_domain_name1->value,
- p_boundary_table->szdomain_name1,
- sizeof(p_boundary_table->szdomain_name1));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
- "domain_name1= %s" , val_domain_name1->value);
- (*v_iter).p_table_attribute_value = val_domain_name1;
- } ODBCM_COMPARE_FETCH_DATA((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_320,
- BDRY_PORT_ID1/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_320+1],
- val_logical_port_id1);
- ODBCM_MEMCPY(
- val_logical_port_id1->value,
- p_boundary_table->szlogical_port_id1,
- *p_logicalport_id1_len);
- odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
- "logical_port_id1= %s" , val_logical_port_id1->value);
- (*v_iter).p_table_attribute_value = val_logical_port_id1;
- } ODBCM_COMPARE_FETCH_DATA((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- BDRY_CTR_NAME2/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_32+1],
- val_controller_name2);
- ODBCM_MEMCPY(
- val_controller_name2->value,
- p_boundary_table->szcontroller_name2,
- sizeof(p_boundary_table->szcontroller_name2));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
- "controller_name2= %s" , val_controller_name2->value);
- (*v_iter).p_table_attribute_value = val_controller_name2;
- } ODBCM_COMPARE_FETCH_DATA((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- BDRY_DM_NAME2/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_32+1],
- val_domain_name2);
- ODBCM_MEMCPY(
- val_domain_name2->value,
- p_boundary_table->szdomain_name2,
- sizeof(p_boundary_table->szdomain_name2));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
- "domain_name2= %s" , val_domain_name2->value);
- (*v_iter).p_table_attribute_value = val_domain_name2;
- } ODBCM_COMPARE_FETCH_DATA((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_320,
- BDRY_PORT_ID2/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_320+1],
- val_logical_port_id2);
- ODBCM_MEMCPY(
- val_logical_port_id2->value,
- p_boundary_table->szlogical_port_id2,
- *p_logicalport_id2_len);
- odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
- "logical_port_id2= %s" , val_logical_port_id2->value);
- (*v_iter).p_table_attribute_value = val_logical_port_id2;
- } ODBCM_COMPARE_FETCH_DATA((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- BDRY_OPER_STATUS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, rs_value);
- rs_value->value = p_boundary_table->soper_status;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
- "oper_status= %d", rs_value->value);
- (*v_iter).p_table_attribute_value = rs_value;
- } ODBCM_COMPARE_FETCH_DATA((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_8,
- BDRY_VALID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_8+1], valid_value);
- ODBCM_MEMCPY(
- valid_value->value,
- p_boundary_table->svalid,
- sizeof(p_boundary_table->svalid));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
- "valid = %s", valid_value->value);
- (*v_iter).p_table_attribute_value = valid_value;
- } ODBCM_COMPARE_FETCH_DATA((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- BDRY_ROW_STATUS/*attribute name MACRO*/) {
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, rs_value);
- rs_value->value = p_boundary_table->scs_row_status;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
- "cs_row_status = %d", rs_value->value);
- (*v_iter).p_table_attribute_value = rs_value;
- } ODBCM_COMPARE_FETCH_DATA((*v_iter)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_8,
- BDRY_ATTR/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_8+1], cs_value);
- ODBCM_MEMCPY(
- cs_value->value,
- p_boundary_table->scs_attr,
- sizeof(p_boundary_table->scs_attr));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
- "cs_attr = %s", cs_value->value);
- (*v_iter).p_table_attribute_value = cs_value;
- }
+ switch ((*v_iter).table_attribute_name) {
+ case BDRY_ID:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_32+1],
+ val_boundary_id);
+ ODBCM_MEMCPY(
+ val_boundary_id->value,
+ p_boundary_table->szboundary_id,
+ sizeof(p_boundary_table->szboundary_id));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
+ "boundary_id = %s" , val_boundary_id->value);
+ (*v_iter).p_table_attribute_value = val_boundary_id;
+ }
+ break;
+ case BDRY_DESCRIPTION:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_128+1],
+ desc_value);
+ ODBCM_MEMCPY(
+ desc_value->value,
+ p_boundary_table->szdescription,
+ sizeof(p_boundary_table->szdescription));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
+ "description = %s", desc_value->value);
+ (*v_iter).p_table_attribute_value = desc_value;
+ }
+ break;
+ case BDRY_CTR_NAME1:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_32+1],
+ val_controller_name1);
+ ODBCM_MEMCPY(
+ val_controller_name1->value,
+ p_boundary_table->szcontroller_name1,
+ sizeof(p_boundary_table->szcontroller_name1));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
+ "controller_name1= %s" , val_controller_name1->value);
+ (*v_iter).p_table_attribute_value = val_controller_name1;
+ }
+ break;
+ case BDRY_DM_NAME1:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_32+1],
+ val_domain_name1);
+ ODBCM_MEMCPY(
+ val_domain_name1->value,
+ p_boundary_table->szdomain_name1,
+ sizeof(p_boundary_table->szdomain_name1));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
+ "domain_name1= %s" , val_domain_name1->value);
+ (*v_iter).p_table_attribute_value = val_domain_name1;
+ }
+ break;
+ case BDRY_PORT_ID1:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_320) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_320+1],
+ val_logical_port_id1);
+ ODBCM_MEMCPY(
+ val_logical_port_id1->value,
+ p_boundary_table->szlogical_port_id1,
+ *p_logicalport_id1_len);
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
+ "logical_port_id1= %s" , val_logical_port_id1->value);
+ (*v_iter).p_table_attribute_value = val_logical_port_id1;
+ }
+ break;
+ case BDRY_CTR_NAME2:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_32+1],
+ val_controller_name2);
+ ODBCM_MEMCPY(
+ val_controller_name2->value,
+ p_boundary_table->szcontroller_name2,
+ sizeof(p_boundary_table->szcontroller_name2));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
+ "controller_name2= %s" , val_controller_name2->value);
+ (*v_iter).p_table_attribute_value = val_controller_name2;
+ }
+ break;
+ case BDRY_DM_NAME2:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_32+1],
+ val_domain_name2);
+ ODBCM_MEMCPY(
+ val_domain_name2->value,
+ p_boundary_table->szdomain_name2,
+ sizeof(p_boundary_table->szdomain_name2));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
+ "domain_name2= %s" , val_domain_name2->value);
+ (*v_iter).p_table_attribute_value = val_domain_name2;
+ }
+ break;
+ case BDRY_PORT_ID2:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_320) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_320+1],
+ val_logical_port_id2);
+ ODBCM_MEMCPY(
+ val_logical_port_id2->value,
+ p_boundary_table->szlogical_port_id2,
+ *p_logicalport_id2_len);
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
+ "logical_port_id2= %s" , val_logical_port_id2->value);
+ (*v_iter).p_table_attribute_value = val_logical_port_id2;
+ }
+ break;
+ case BDRY_OPER_STATUS:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, rs_value);
+ rs_value->value = p_boundary_table->soper_status;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
+ "oper_status= %d", rs_value->value);
+ (*v_iter).p_table_attribute_value = rs_value;
+ }
+ break;
+ case BDRY_VALID:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_8) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_8+1],
+ valid_value);
+ ODBCM_MEMCPY(
+ valid_value->value,
+ p_boundary_table->svalid,
+ sizeof(p_boundary_table->svalid));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
+ "valid = %s", valid_value->value);
+ (*v_iter).p_table_attribute_value = valid_value;
+ }
+ break;
+ case BDRY_ROW_STATUS:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT16) {
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, rs_value);
+ rs_value->value = p_boundary_table->scs_row_status;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
+ "cs_row_status = %d", rs_value->value);
+ (*v_iter).p_table_attribute_value = rs_value;
+ }
+ break;
+ case BDRY_ATTR:
+ if ((*v_iter).request_attribute_type == DATATYPE_UINT8_ARRAY_8) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_8+1], cs_value);
+ ODBCM_MEMCPY(
+ cs_value->value,
+ p_boundary_table->scs_attr,
+ sizeof(p_boundary_table->scs_attr));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:BOUNDARY_TABLE: "
+ "cs_attr = %s", cs_value->value);
+ (*v_iter).p_table_attribute_value = cs_value;
+ }
+ break;
+ default:
+ break;
+ }
}
return ODBCM_RC_SUCCESS;
}
#include "odbcm_common.hh"
#include "odbcm_utils.hh"
#include "odbcm_db_tableschema.hh"
+#include "odbcm_mgr.hh"
using unc::uppl::DBVarbind;
/**
- * @Description : Input binding function for controller_common_table
- * @param[in] : vector<TableAttrSchema> &column_attr, HSTMT &r_hstmt
- * @return : ODBCM_RC_STATUS
+ * @Description : Function to bind input parameter of controller_table
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * r_hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::bind_controller_table_input(
- std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_ entry*/,
+ std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_entry*/,
HSTMT &r_hstmt/**statement handler which carries the SQL Query*/) {
SQLRETURN odbc_rc = SQL_SUCCESS; // odbc API's return code initialize with 0
SQLUSMALLINT col_no = 0; // column number
* table_attribute_name value will be compared and corresponding
* structure member will be binded here*/
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
+ if ((*i).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
+ }
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**binding structure buffer member for controller name input,
+ * column size is ODBCM_SIZE_32,
+ * Data type CHAR[32],
+ * and buffer size will passed as length of value */
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/,
+ ODBCM_SIZE_32/*column size in DB table*/,
+ 0/**decimal point */,
+ p_ctr_table->szcontroller_name/*buffer to carry values*/,
+ sizeof(p_ctr_table->szcontroller_name)-1/**buffer length*/,
+ NULL/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_TYPE:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindInputParameter_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ reinterpret_cast<SQLSMALLINT*> (&p_ctr_table->stype),
+ 0,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_VERSION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_32,
+ 0,
+ p_ctr_table->szversion,
+ sizeof(p_ctr_table->szversion)-1,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_128+1,
+ 0,
+ p_ctr_table->szdescription,
+ sizeof(p_ctr_table->szdescription),
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_IP_ADDRESS:
+ if ((*i).request_attribute_type == DATATYPE_IPV4) {
+ odbc_rc = BindInputParameter_SQL_BIGINT(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ reinterpret_cast<SQLBIGINT*>(&p_ctr_table->szip_address),
+ 0,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_USER_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_32,
+ 0,
+ p_ctr_table->szuser_name,
+ sizeof(p_ctr_table->szuser_name)-1,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_PASSWORD:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_257) {
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_257,
+ 0,
+ p_ctr_table->szpassword,
+ sizeof(p_ctr_table->szpassword)-1,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_ENABLE_AUDIT:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindInputParameter_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ reinterpret_cast<SQLSMALLINT*>(&p_ctr_table->senable_audit),
+ 0,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_ACTUAL_VERSION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_32,
+ 0,
+ p_ctr_table->szactual_version,
+ sizeof(p_ctr_table->szactual_version)-1,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_OPER_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindInputParameter_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ reinterpret_cast<SQLSMALLINT*>(&p_ctr_table->soper_status),
+ 0,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_9) {
+ odbc_rc = BindInputParameter_SQL_CHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_9,
+ 0,
+ p_ctr_table->svalid,
+ sizeof(p_ctr_table->svalid)-1,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_CS_ROW_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindInputParameter_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ reinterpret_cast<SQLSMALLINT*>(&p_ctr_table->scs_row_status),
+ 0,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_CS_ATTR:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_9) {
+ odbc_rc = BindInputParameter_SQL_CHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_9,
+ 0,
+ p_ctr_table->scs_attr,
+ sizeof(p_ctr_table->scs_attr)-1,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ default:
+ break;
+ }
/*In case of bind failure return the parameter bind error */
if (odbc_rc == SQL_ERROR||odbc_rc == SQL_INVALID_HANDLE) {
pfc_log_error("ODBCM::DBVarbind::bind_controller_table_input: "
* error code */
return ODBCM_RC_PARAM_BIND_ERROR;
}
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- CTR_NAME/*attribute name MACRO*/) {
- /**binding structure buffer member for controller name input,
-
- * column size is ODBCM_SIZE_32,
- * Data type CHAR[32],
- * and buffer size will passed as length of value */
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/,
- ODBCM_SIZE_32/*column size in DB table*/,
- 0/**decimal point */,
- p_ctr_table->szcontroller_name/*buffer to carry values*/,
- sizeof(p_ctr_table->szcontroller_name)-1/**buffer length*/,
- NULL/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16/**data type char(16)*/,
- CTR_TYPE/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- reinterpret_cast<SQLSMALLINT*> (&p_ctr_table->stype),
- 0,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32 /**data type char(32)*/,
- CTR_VERSION/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_32,
- 0,
- p_ctr_table->szversion,
- sizeof(p_ctr_table->szversion)-1,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128/**data type char(128)*/,
- CTR_DESCRIPTION/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_128+1,
- 0,
- p_ctr_table->szdescription,
- sizeof(p_ctr_table->szdescription),
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_IPV4 /**data type ipv4*/,
- CTR_IP_ADDRESS/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_BIGINT(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- reinterpret_cast<SQLBIGINT*>(&p_ctr_table->szip_address),
- 0,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- CTR_USER_NAME/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_32,
- 0,
- p_ctr_table->szuser_name,
- sizeof(p_ctr_table->szuser_name)-1,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_257/**data type char(257)*/,
- CTR_PASSWORD/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_257,
- 0,
- p_ctr_table->szpassword,
- sizeof(p_ctr_table->szpassword)-1,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16/**data type char(16)*/,
- CTR_ENABLE_AUDIT/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- reinterpret_cast<SQLSMALLINT*>(&p_ctr_table->senable_audit),
- 0,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- CTR_ACTUAL_VERSION/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_32,
- 0,
- p_ctr_table->szactual_version,
- sizeof(p_ctr_table->szactual_version)-1,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16/**data type unit16_t*/,
- CTR_OPER_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- reinterpret_cast<SQLSMALLINT*>(&p_ctr_table->soper_status),
- 0,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_9/**data type char(9)*/,
- CTR_VALID/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_CHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_9,
- 0,
- p_ctr_table->svalid,
- sizeof(p_ctr_table->svalid)-1,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16/**data type unit16_t*/,
- CTR_CS_ROW_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- reinterpret_cast<SQLSMALLINT*>(&p_ctr_table->scs_row_status),
- 0,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_9/**data type char(9)*/,
- CTR_CS_ATTR/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_CHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_9,
- 0,
- p_ctr_table->scs_attr,
- sizeof(p_ctr_table->scs_attr)-1,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- }
if ((*i).p_table_attribute_value != NULL && log_flag == 0) {
if (odbc_rc != SQL_SUCCESS)
ODBCMUtils::OdbcmHandleDiagnosticsPrint(SQL_HANDLE_STMT, r_hstmt);
/**reset flag value 1 */
log_flag = 1;
} else {
- pfc_log_info("ODBCM::DBVarbind::**NO bind**i/p:CTR_TABLE:%s:datatype=%d:"
- , ((*i).table_attribute_name).c_str(),
+ pfc_log_debug("ODBCM::DBVarbind::**NO bind**i/p:CTR_TABLE:%s:datatype=%d:"
+ , ODBCManager::get_ODBCManager()->GetColumnName(
+ ((*i).table_attribute_name)).c_str(),
(*i).request_attribute_type);
}
} // for loop end
return ODBCM_RC_SUCCESS;
}
+
/**
- * @Description : Output binding function for controller_common_table
- * @param[in] : vector<TableAttrSchema> &column_attr, HSTMT &r_hstmt
- * @return : ODBCM_RC_STATUS
+ * @Description : Output binding function for controller_table
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * r_hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::bind_controller_table_output(
- std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_ entry*/,
+ std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_entry*/,
HSTMT &r_hstmt/**statement handler which carries the SQL Query*/) {
SQLRETURN odbc_rc = SQL_SUCCESS; // odbc APIs return code
SQLINTEGER indptr = 0; // Pointer to value that indicates the number of
* table_attribute_name value will be compared and corresponding
* structure member will be binded here*/
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
+ if ((*i).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
+ }
+ /**binding structure buffer member for controller name output,
+ * column size is ODBCM_SIZE_32,
+ * Data type CHAR[32],
+ * and buffer size will passed as length of value,
+ * ptr to indicates available no. of bytes return */
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/,
+ p_ctr_table->szcontroller_name/*buffer to fetch values*/,
+ ODBCM_SIZE_32+1,
+ /**no.of bytes available to return*/
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_TYPE:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindCol_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ reinterpret_cast<SQLSMALLINT*>(&p_ctr_table->stype),
+ sizeof(SQLSMALLINT),
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_VERSION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ p_ctr_table->szversion,
+ ODBCM_SIZE_32+1,
+ reinterpret_cast<SQLLEN*>(&indptr));
+ }
+ break;
+ case CTR_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ p_ctr_table->szdescription,
+ ODBCM_SIZE_128+1,
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_IP_ADDRESS:
+ if ((*i).request_attribute_type == DATATYPE_IPV4) {
+ odbc_rc = BindCol_SQL_BIGINT(
+ r_hstmt,
+ ++col_no,
+ reinterpret_cast<SQLBIGINT*>(&p_ctr_table->szip_address),
+ sizeof(SQLBIGINT),
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_USER_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ p_ctr_table->szuser_name,
+ ODBCM_SIZE_32+1,
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_PASSWORD:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_257) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ p_ctr_table->szpassword,
+ ODBCM_SIZE_257+1,
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_ENABLE_AUDIT:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindCol_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ reinterpret_cast<SQLSMALLINT*>(&p_ctr_table->senable_audit),
+ sizeof(SQLSMALLINT),
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_ACTUAL_VERSION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ p_ctr_table->szactual_version,
+ ODBCM_SIZE_32+1,
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_OPER_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindCol_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ reinterpret_cast<SQLSMALLINT*>(&p_ctr_table->soper_status),
+ sizeof(SQLSMALLINT),
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_9) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ p_ctr_table->svalid,
+ ODBCM_SIZE_9+1,
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_CS_ROW_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindCol_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ reinterpret_cast<SQLSMALLINT*>(&p_ctr_table->scs_row_status),
+ sizeof(SQLSMALLINT),
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case CTR_CS_ATTR:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_9) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ p_ctr_table->scs_attr,
+ ODBCM_SIZE_9+1,
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ default:
+ break;
+ }
/*In case of bind failure return the parameter bind error */
if (odbc_rc == SQL_ERROR||odbc_rc == SQL_INVALID_HANDLE) {
pfc_log_error("ODBCM::DBVarbind::bind_controller_com_table_output"
* error code */
return ODBCM_RC_PARAM_BIND_ERROR;
}
- /**binding structure buffer member for controller name output,
- * column size is ODBCM_SIZE_32,
- * Data type CHAR[32],
- * and buffer size will passed as length of value,
- * ptr to indicates available no. of bytes return */
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- CTR_NAME/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/,
- p_ctr_table->szcontroller_name/*buffer to fetch values*/,
- ODBCM_SIZE_32+1,
- /**no.of bytes available to return*/
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- CTR_TYPE/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- reinterpret_cast<SQLSMALLINT*>(&p_ctr_table->stype),
- sizeof(SQLSMALLINT),
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- CTR_VERSION/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- p_ctr_table->szversion,
- ODBCM_SIZE_32+1,
- reinterpret_cast<SQLLEN*>(&indptr));
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i/**TableAttrSchema structure*/),
- DATATYPE_UINT8_ARRAY_128,
- CTR_DESCRIPTION/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- p_ctr_table->szdescription,
- ODBCM_SIZE_128+1,
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_IPV4,
- CTR_IP_ADDRESS/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_BIGINT(
- r_hstmt,
- ++col_no,
- reinterpret_cast<SQLBIGINT*>(&p_ctr_table->szip_address),
- sizeof(SQLBIGINT),
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- CTR_USER_NAME/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- p_ctr_table->szuser_name,
- ODBCM_SIZE_32+1,
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_257,
- CTR_PASSWORD/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- p_ctr_table->szpassword,
- ODBCM_SIZE_257+1,
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- CTR_ENABLE_AUDIT/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- reinterpret_cast<SQLSMALLINT*>(&p_ctr_table->senable_audit),
- sizeof(SQLSMALLINT),
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- CTR_ACTUAL_VERSION/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- p_ctr_table->szactual_version,
- ODBCM_SIZE_32+1,
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- CTR_OPER_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- reinterpret_cast<SQLSMALLINT*>(&p_ctr_table->soper_status),
- sizeof(SQLSMALLINT),
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_9,
- CTR_VALID/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- p_ctr_table->svalid,
- ODBCM_SIZE_9+1,
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- CTR_CS_ROW_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- reinterpret_cast<SQLSMALLINT*>(&p_ctr_table->scs_row_status),
- sizeof(SQLSMALLINT),
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_9,
- CTR_CS_ATTR/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- p_ctr_table->scs_attr,
- ODBCM_SIZE_9+1,
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- }
if (log_flag == 0) {
/**reset flag value 1*/
log_flag = 1;
}
/**
- * @Description : To fill the controller_common_table
- * values into bind controller_common_table_ structure.
- * @param[in] : vector<TableAttrSchema> &column_attr
- * @return : ODBCM_RC_STATUS
+ * @Description : To fill the controller_table values into structure.
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::fill_controller_table(
std::vector<TableAttrSchema> &column_attr
- /*DBTableSchema->rowlist_ entry*/) {
+ /*DBTableSchema->rowlist_entry*/) {
/**Vector iterator to take the TableAttrSchema structures*/
std::vector< TableAttrSchema >::iterator i;
/**Loop for iterate all the elements in the vector, the TableAttrSchema
* table_attribute_name value will be compared and corresponding
* structure member will be filled*/
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- CTR_NAME/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for controller_name CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> cn_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
- ((*i).p_table_attribute_value));
- /**clear the allocated buffer memory to receive the controller_name
- * from caller*/
- ODBCM_MEMSET(p_ctr_table->szcontroller_name, 0, ODBCM_SIZE_32+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_ctr_table->szcontroller_name,
- &cn_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
- "szController_name = %s",
- p_ctr_table->szcontroller_name);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- CTR_TYPE/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for type uint8*/
- ColumnAttrValue <uint16_t> type_value =
- *((ColumnAttrValue <uint16_t>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_ctr_table->stype, 0, sizeof(SQLSMALLINT));
- p_ctr_table->stype = type_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: sType= %d",
- p_ctr_table->stype);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- CTR_VERSION/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for version CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> ver_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ if ((*i).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
+ }
+ switch ((const uint32_t)(*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for controller_name CHAR[32]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> cn_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_ctr_table->szversion, 0, ODBCM_SIZE_32+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(p_ctr_table->szversion,
- &ver_value.value, (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
- "szversion = %s", p_ctr_table->szversion);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128,
- CTR_DESCRIPTION/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for description CHAR[128]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_128]> desc_value =
- *((ColumnAttrValue <uint8_t[128]>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_ctr_table->szdescription, 0, ODBCM_SIZE_128+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(p_ctr_table->szdescription, &desc_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
- "szDescription = %s", p_ctr_table->szdescription);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_IPV4,
- CTR_IP_ADDRESS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for ip_address SQLBIGINT*/
- ColumnAttrValue <uint32_t> ipv4_value =
- *((ColumnAttrValue <uint32_t>*)((*i).p_table_attribute_value));
+ /**clear the allocated buffer memory to receive the controller_name
+ * from caller*/
+ ODBCM_MEMSET(p_ctr_table->szcontroller_name, 0, ODBCM_SIZE_32+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_ctr_table->szcontroller_name,
+ &cn_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
+ "szController_name = %s",
+ p_ctr_table->szcontroller_name);
+ }
+ break;
+ case CTR_TYPE:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for type uint8*/
+ ColumnAttrValue <uint16_t> type_value =
+ *((ColumnAttrValue <uint16_t>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(&p_ctr_table->stype, 0, sizeof(SQLSMALLINT));
+ p_ctr_table->stype = type_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: sType= %d",
+ p_ctr_table->stype);
+ }
+ break;
+ case CTR_VERSION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for version CHAR[32]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> ver_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_ctr_table->szversion, 0, ODBCM_SIZE_32+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(p_ctr_table->szversion,
+ &ver_value.value, (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
+ "szversion = %s", p_ctr_table->szversion);
+ }
+ break;
+ case CTR_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for description CHAR[128]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_128]> desc_value =
+ *((ColumnAttrValue <uint8_t[128]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_ctr_table->szdescription, 0, ODBCM_SIZE_128+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(p_ctr_table->szdescription, &desc_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
+ "szDescription = %s", p_ctr_table->szdescription);
+ }
+ break;
+ case CTR_IP_ADDRESS:
+ if ((*i).request_attribute_type == DATATYPE_IPV4) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for ip_address SQLBIGINT*/
+ ColumnAttrValue <uint32_t> ipv4_value =
+ *((ColumnAttrValue <uint32_t>*)((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_ctr_table->szip_address, 0, sizeof(SQLBIGINT));
- p_ctr_table->szip_address = ipv4_value.value;
-/*
- struct sockaddr_in IPV4;
- IPV4.sin_addr.s_addr = inet_addr("10.0.0.1");
- p_ctr_table->szip_address = IPV4.sin_addr.s_addr;
-*/
- odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: szIp_address = %s",
- ODBCMUtils::get_ip_string(p_ctr_table->szip_address).c_str());
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- CTR_USER_NAME/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for user_name CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> user_value =
- *((ColumnAttrValue <uint8_t[32]>*)
+ ODBCM_MEMSET(&p_ctr_table->szip_address, 0, sizeof(SQLBIGINT));
+ p_ctr_table->szip_address = ipv4_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE:"
+ " szIp_address = %s", ODBCMUtils::get_ip_string(
+ p_ctr_table->szip_address).c_str());
+ }
+ break;
+ case CTR_USER_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for user_name CHAR[32]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> user_value =
+ *((ColumnAttrValue <uint8_t[32]>*)
((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_ctr_table->szuser_name, 0, ODBCM_SIZE_32+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(p_ctr_table->szuser_name, &user_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
- "szUser_name = %s", p_ctr_table->szuser_name);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_257,
- CTR_PASSWORD/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for password CHAR[256]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_257]> pass_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_257]>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_ctr_table->szpassword, 0, ODBCM_SIZE_257+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(p_ctr_table->szpassword, &pass_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
- "szPassword = %s", p_ctr_table->szpassword);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- CTR_ENABLE_AUDIT/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for enable_audit unit16_t*/
- ColumnAttrValue <uint16_t> audit_value =
- *((ColumnAttrValue <uint16_t>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_ctr_table->senable_audit, 0, sizeof(SQLSMALLINT));
- p_ctr_table->senable_audit = audit_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
- "enable_audit = %d", p_ctr_table->senable_audit);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- CTR_ACTUAL_VERSION/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for actual_version CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> actual_version_value =
- *((ColumnAttrValue <uint8_t[32]>*)
+ ODBCM_MEMSET(p_ctr_table->szuser_name, 0, ODBCM_SIZE_32+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(p_ctr_table->szuser_name, &user_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
+ "szUser_name = %s", p_ctr_table->szuser_name);
+ }
+ break;
+ case CTR_PASSWORD:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_257) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for password CHAR[256]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_257]> pass_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_257]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_ctr_table->szpassword, 0, ODBCM_SIZE_257+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(p_ctr_table->szpassword, &pass_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
+ "szPassword = %s", p_ctr_table->szpassword);
+ }
+ break;
+ case CTR_ENABLE_AUDIT:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for enable_audit unit16_t*/
+ ColumnAttrValue <uint16_t> audit_value =
+ *((ColumnAttrValue <uint16_t>*)
((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_ctr_table->szactual_version, 0, ODBCM_SIZE_32+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(p_ctr_table->szactual_version, &actual_version_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
- "szactual_version = %s", p_ctr_table->szactual_version);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- CTR_OPER_STATUS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for oper_status unit16_t*/
- ColumnAttrValue <uint16_t> oper_value =
- *((ColumnAttrValue <uint16_t>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_ctr_table->soper_status, 0, sizeof(SQLSMALLINT));
- /**copying the value from template to binded buffer */
- p_ctr_table->soper_status = oper_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
- "soper_status = %d", p_ctr_table->soper_status);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_9,
- CTR_VALID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for valid CHAR[9]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_9]> valid_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_9]>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_ctr_table->svalid, 0, ODBCM_SIZE_9+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(p_ctr_table->svalid, &valid_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
- "sValid = %s", p_ctr_table->svalid);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- CTR_CS_ROW_STATUS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for cs_row_status unit16_t*/
- ColumnAttrValue <uint16_t> rs_value =
- *((ColumnAttrValue <uint16_t>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_ctr_table->scs_row_status, 0, sizeof(SQLSMALLINT));
- p_ctr_table->scs_row_status = rs_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
- "sCs_row_status = %d", p_ctr_table->scs_row_status);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_9,
- CTR_CS_ATTR/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for cs_attr CHAR[9]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_9]> csa_value =
- *((ColumnAttrValue<uint8_t[ODBCM_SIZE_9]>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_ctr_table->scs_attr, 0, ODBCM_SIZE_9+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(p_ctr_table->scs_attr, &csa_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
- "sCs_attr = %s", p_ctr_table->scs_attr);
+ ODBCM_MEMSET(&p_ctr_table->senable_audit, 0, sizeof(SQLSMALLINT));
+ p_ctr_table->senable_audit = audit_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
+ "enable_audit = %d", p_ctr_table->senable_audit);
+ }
+ break;
+ case CTR_ACTUAL_VERSION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for actual_version CHAR[32]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> actual_version_value =
+ *((ColumnAttrValue <uint8_t[32]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_ctr_table->szactual_version, 0, ODBCM_SIZE_32+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(p_ctr_table->szactual_version,
+ &actual_version_value.value, (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
+ "szactual_version = %s", p_ctr_table->szactual_version);
+ }
+ break;
+ case CTR_OPER_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for oper_status unit16_t*/
+ ColumnAttrValue <uint16_t> oper_value =
+ *((ColumnAttrValue <uint16_t>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(&p_ctr_table->soper_status, 0, sizeof(SQLSMALLINT));
+ /**copying the value from template to binded buffer */
+ p_ctr_table->soper_status = oper_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
+ "soper_status = %d", p_ctr_table->soper_status);
+ }
+ break;
+ case CTR_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_9) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for valid CHAR[9]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_9]> valid_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_9]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_ctr_table->svalid, 0, ODBCM_SIZE_9+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(p_ctr_table->svalid, &valid_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
+ "sValid = %s", p_ctr_table->svalid);
+ }
+ break;
+ case CTR_CS_ROW_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for cs_row_status unit16_t*/
+ ColumnAttrValue <uint16_t> rs_value =
+ *((ColumnAttrValue <uint16_t>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(&p_ctr_table->scs_row_status, 0, sizeof(SQLSMALLINT));
+ p_ctr_table->scs_row_status = rs_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
+ "sCs_row_status = %d", p_ctr_table->scs_row_status);
+ }
+ break;
+ case CTR_CS_ATTR:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_9) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for cs_attr CHAR[9]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_9]> csa_value =
+ *((ColumnAttrValue<uint8_t[ODBCM_SIZE_9]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_ctr_table->scs_attr, 0, ODBCM_SIZE_9+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(p_ctr_table->scs_attr, &csa_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:CTR_TABLE: "
+ "sCs_attr = %s", p_ctr_table->scs_attr);
+ }
+ break;
+ default:
+ break;
}
}
return ODBCM_RC_SUCCESS;
}
/**
- * @Description : Function to fetch the controller_common_table
- * values(which is stored in controller_common_table_ struct )
- * and store into TableAttSchema
- * @param[in] : vector<TableAttrSchema> &column_attr
- * @return : ODBCM_RC_STATUS
+ * @Description : To fetch the controller_table values
+ * (which are stored in binded buffer)
+ * and store into TableAttSchema
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::fetch_controller_table(
std::vector<TableAttrSchema> &column_attr
- /*DBTableSchema->rowlist_ entry*/) {
+ /*DBTableSchema->rowlist_entry*/) {
/**Vector iterator to take the TableAttrSchema structures*/
std::vector< TableAttrSchema >::iterator i;
/**Loop for iterate all the elements in the vector, the TableAttrSchema
* table_attribute_name value will be compared and corresponding
* structure member will be fetched */
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
- ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- CTR_NAME/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_32+1],
- val_controller_name);
- ODBCM_MEMCPY(
- val_controller_name->value,
- p_ctr_table->szcontroller_name,
- sizeof(p_ctr_table->szcontroller_name));/* sizeof will return 32+1 */
- odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
- "controller_name = %s" , val_controller_name->value);
- (*i).p_table_attribute_value = val_controller_name;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- CTR_TYPE/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint16_t,
- type_value);
- type_value->value = p_ctr_table->stype;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
- "type = %d", type_value->value);
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_32+1],
+ val_controller_name);
+ ODBCM_MEMCPY(
+ val_controller_name->value,
+ p_ctr_table->szcontroller_name,
+ sizeof(p_ctr_table->szcontroller_name));
+ /* sizeof will return 32+1 */
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
+ "controller_name = %s" , val_controller_name->value);
+ (*i).p_table_attribute_value = val_controller_name;
+ }
+ break;
+ case CTR_TYPE:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint16_t,
+ type_value);
+ type_value->value = p_ctr_table->stype;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
+ "type = %d", type_value->value);
- (*i).p_table_attribute_value = type_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- CTR_VERSION/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_32+1],
- val_version);
- ODBCM_MEMCPY(
- val_version->value,
- p_ctr_table->szversion,
- sizeof(p_ctr_table->szversion));
- (*i).p_table_attribute_value = val_version;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: ""szversion = %s",
- val_version->value);
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128,
- CTR_DESCRIPTION/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_128+1],
- desc_value);
- ODBCM_MEMCPY(
- desc_value->value,
- p_ctr_table->szdescription,
- sizeof(p_ctr_table->szdescription));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
- "description = %s", desc_value->value);
- (*i).p_table_attribute_value = desc_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_IPV4,
- CTR_IP_ADDRESS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint32_t,
- ip_value);
- ip_value->value = p_ctr_table->szip_address;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
- "from db ip_address = %s",
- ODBCMUtils::get_ip_string(p_ctr_table->szip_address).c_str());
- odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
- "ip_address = %s",
- ODBCMUtils::get_ip_string(ip_value->value).c_str());
- (*i).p_table_attribute_value = ip_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- CTR_USER_NAME/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_32+1],
- user_value);
- ODBCM_MEMCPY(
- user_value->value,
- p_ctr_table->szuser_name,
- sizeof(p_ctr_table->szuser_name));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
- "user_name = %s", user_value->value);
- (*i).p_table_attribute_value = user_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_257,
- CTR_PASSWORD/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_257+1],
- pass_value);
- ODBCM_MEMCPY(
- pass_value->value,
- p_ctr_table->szpassword,
- sizeof(p_ctr_table->szpassword));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
- "password = %s", pass_value->value);
- (*i).p_table_attribute_value = pass_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- CTR_ENABLE_AUDIT/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, ad_value);
- ad_value->value = p_ctr_table->senable_audit;
+ (*i).p_table_attribute_value = type_value;
+ }
+ break;
+ case CTR_VERSION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_32+1],
+ val_version);
+ ODBCM_MEMCPY(
+ val_version->value,
+ p_ctr_table->szversion,
+ sizeof(p_ctr_table->szversion));
+ (*i).p_table_attribute_value = val_version;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
+ "szversion = %s", val_version->value);
+ }
+ break;
+ case CTR_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_128+1],
+ desc_value);
+ ODBCM_MEMCPY(
+ desc_value->value,
+ p_ctr_table->szdescription,
+ sizeof(p_ctr_table->szdescription));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
+ "description = %s", desc_value->value);
+ (*i).p_table_attribute_value = desc_value;
+ }
+ break;
+ case CTR_IP_ADDRESS:
+ if ((*i).request_attribute_type == DATATYPE_IPV4) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint32_t,
+ ip_value);
+ ip_value->value = p_ctr_table->szip_address;
+ // odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
+ // "from db ip_address = %s",
+ // ODBCMUtils::get_ip_string(p_ctr_table->szip_address).c_str());
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
+ "ip_address = %s",
+ ODBCMUtils::get_ip_string(ip_value->value).c_str());
+ (*i).p_table_attribute_value = ip_value;
+ }
+ break;
+ case CTR_USER_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_32+1],
+ user_value);
+ ODBCM_MEMCPY(
+ user_value->value,
+ p_ctr_table->szuser_name,
+ sizeof(p_ctr_table->szuser_name));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
+ "user_name = %s", user_value->value);
+ (*i).p_table_attribute_value = user_value;
+ }
+ break;
+ case CTR_PASSWORD:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_257) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_257+1],
+ pass_value);
+ ODBCM_MEMCPY(
+ pass_value->value,
+ p_ctr_table->szpassword,
+ sizeof(p_ctr_table->szpassword));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
+ "password = %s", pass_value->value);
+ (*i).p_table_attribute_value = pass_value;
+ }
+ break;
+ case CTR_ENABLE_AUDIT:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, ad_value);
+ ad_value->value = p_ctr_table->senable_audit;
- (*i).p_table_attribute_value = ad_value;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: senable_audit = %d",
- ad_value->value);
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- CTR_ACTUAL_VERSION/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_32+1],
- av_value);
- ODBCM_MEMCPY(
- av_value->value,
- p_ctr_table->szactual_version,
- sizeof(p_ctr_table->szactual_version));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
- "actual_version = %s", av_value->value);
- (*i).p_table_attribute_value = av_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- CTR_OPER_STATUS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, rs_value);
- rs_value->value = p_ctr_table->soper_status;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
- "oper_status = %d", rs_value->value);
- (*i).p_table_attribute_value = rs_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_9,
- CTR_VALID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_9+1],
- valid_value);
- ODBCM_MEMCPY(
- valid_value->value,
- p_ctr_table->svalid,
- sizeof(p_ctr_table->svalid));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
- "valid = %s", valid_value->value);
- (*i).p_table_attribute_value = valid_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- CTR_CS_ROW_STATUS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, rs_value);
- rs_value->value = p_ctr_table->scs_row_status;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
- "cs_row_status = %d", rs_value->value);
+ (*i).p_table_attribute_value = ad_value;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE:"
+ " senable_audit = %d", ad_value->value);
+ }
+ break;
+ case CTR_ACTUAL_VERSION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_32+1],
+ av_value);
+ ODBCM_MEMCPY(
+ av_value->value,
+ p_ctr_table->szactual_version,
+ sizeof(p_ctr_table->szactual_version));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
+ "actual_version = %s", av_value->value);
+ (*i).p_table_attribute_value = av_value;
+ }
+ break;
+ case CTR_OPER_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, rs_value);
+ rs_value->value = p_ctr_table->soper_status;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
+ "oper_status = %d", rs_value->value);
+ (*i).p_table_attribute_value = rs_value;
+ }
+ break;
+ case CTR_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_9) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_9+1],
+ valid_value);
+ ODBCM_MEMCPY(
+ valid_value->value,
+ p_ctr_table->svalid,
+ sizeof(p_ctr_table->svalid));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
+ "valid = %s", valid_value->value);
+ (*i).p_table_attribute_value = valid_value;
+ }
+ break;
+ case CTR_CS_ROW_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, rs_value);
+ rs_value->value = p_ctr_table->scs_row_status;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
+ "cs_row_status = %d", rs_value->value);
- (*i).p_table_attribute_value = rs_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_9,
- CTR_CS_ATTR/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_9+1],
- cs_value);
- ODBCM_MEMCPY(
- cs_value->value,
- p_ctr_table->scs_attr,
- sizeof(p_ctr_table->scs_attr));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
- "cs_attr = %s", cs_value->value);
- (*i).p_table_attribute_value = cs_value;
+ (*i).p_table_attribute_value = rs_value;
+ }
+ break;
+ case CTR_CS_ATTR:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_9) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_9+1],
+ cs_value);
+ ODBCM_MEMCPY(
+ cs_value->value,
+ p_ctr_table->scs_attr,
+ sizeof(p_ctr_table->scs_attr));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:CTR_TABLE: "
+ "cs_attr = %s", cs_value->value);
+ (*i).p_table_attribute_value = cs_value;
+ }
+ break;
+ default:
+ break;
}
}
return ODBCM_RC_SUCCESS;
#include "odbcm_common.hh"
#include "odbcm_utils.hh"
#include "odbcm_db_tableschema.hh"
+#include "odbcm_mgr.hh"
using unc::uppl::DBVarbind;
/*
- * @Description : Function to bind input param of domain_common_table
- * @param[in] : None
- * @return : ODBCM_RC_STATUS
+ * @Description : Function to bind input parameter of Domain_table
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * r_hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::bind_domain_table_input(
std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_ entry*/,
* table_attribute_name value will be compared and corresponding
* structure member will be binded here*/
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
+ if ((*i).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
+ }
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**binding structure buffer member for controller name input,
+ * column size is ODBCM_SIZE_32,
+ * Data type CHAR[32],
+ * and buffer size will passed as length of value */
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/,
+ ODBCM_SIZE_32/*column size in DB table*/,
+ 0/**decimal point */,
+ p_domain_table->szcontroller_name/*buffer to carry values*/,
+ sizeof(p_domain_table->szcontroller_name)-1/**buffer length*/,
+ NULL/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case DOMAIN_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_32,
+ 0,
+ p_domain_table->szdomain_name,
+ sizeof(p_domain_table->szdomain_name)-1,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case DOMAIN_TYPE:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindInputParameter_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ reinterpret_cast<SQLSMALLINT*>
+ (&p_domain_table->stype),
+ 0,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case DOMAIN_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_128,
+ 0,
+ p_domain_table->szdescription,
+ sizeof(p_domain_table->szdescription)-1,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case DOMAIN_OP_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindInputParameter_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ reinterpret_cast<SQLSMALLINT*>(&p_domain_table->soper_status),
+ 0,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case DOMAIN_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_3) {
+ odbc_rc = BindInputParameter_SQL_CHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_3,
+ 0,
+ p_domain_table->svalid,
+ sizeof(p_domain_table->svalid)-1,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case DOMAIN_CS_ROW_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindInputParameter_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ reinterpret_cast<SQLSMALLINT*>(&p_domain_table->scs_row_status),
+ 0,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case DOMAIN_CS_ATTR:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_3) {
+ odbc_rc = BindInputParameter_SQL_CHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_3,
+ 0,
+ p_domain_table->scs_attr,
+ sizeof(p_domain_table->scs_row_status),
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ default:
+ break;
+ }
/*In case of bind failure return the parameter bind error */
if (odbc_rc == SQL_ERROR||odbc_rc == SQL_INVALID_HANDLE) {
pfc_log_error("ODBCM::DBVarbind::ctr_domain_table"
* error code */
return ODBCM_RC_PARAM_BIND_ERROR;
}
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,/**data type char(32)*/
- CTR_NAME/*attribute name MACRO*/) {
- /**binding structure buffer member for controller name input,
- * column size is ODBCM_SIZE_32,
- * Data type CHAR[32],
- * and buffer size will passed as length of value */
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/,
- ODBCM_SIZE_32/*column size in DB table*/,
- 0/**decimal point */,
- p_domain_table->szcontroller_name/*buffer to carry values*/,
- sizeof(p_domain_table->szcontroller_name)-1/**buffer length*/,
- NULL/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- DOMAIN_NAME/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_32,
- 0,
- p_domain_table->szdomain_name,
- sizeof(p_domain_table->szdomain_name)-1,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16/**data type unit16*/,
- DOMAIN_TYPE/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- reinterpret_cast<SQLSMALLINT*>
- (&p_domain_table->stype),
- 0,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128/**data type char(128)*/,
- DOMAIN_DESCRIPTION/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_128,
- 0,
- p_domain_table->szdescription,
- sizeof(p_domain_table->szdescription)-1,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16/**data type unit16*/,
- DOMAIN_OP_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- reinterpret_cast<SQLSMALLINT*>(&p_domain_table->soper_status),
- 0,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_3/**data type char(3)*/,
- DOMAIN_VALID/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_CHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_3,
- 0,
- p_domain_table->svalid,
- sizeof(p_domain_table->svalid)-1,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16/**data type unit16*/,
- DOMAIN_CS_ROW_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- reinterpret_cast<SQLSMALLINT*>(&p_domain_table->scs_row_status),
- 0,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_3/**data type char(3)*/,
- DOMAIN_CS_ATTR/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_CHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_3,
- 0,
- p_domain_table->scs_attr,
- sizeof(p_domain_table->scs_row_status),
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- }
-
if ((*i).p_table_attribute_value != NULL && log_flag == 0) {
if (odbc_rc != SQL_SUCCESS)
ODBCMUtils::OdbcmHandleDiagnosticsPrint(SQL_HANDLE_STMT, r_hstmt);
/**reset flag value 1 */
log_flag = 1;
} else {
- pfc_log_info("ODBCM::DBVarbind::No bind i/p:DOMAIN_TABLE:%s:datatype=%d:"
- , ((*i).table_attribute_name).c_str(),
- (*i).request_attribute_type);
+ pfc_log_debug("ODBCM::DBVarbind::No bind i/p:DOMAIN_TABLE:%s:datatype=%d:"
+ , ODBCManager::get_ODBCManager()-> \
+ GetColumnName((*i).table_attribute_name).c_str(),
+ (*i).request_attribute_type);
}
} // for loop end
- if (odbc_rc == SQL_ERROR||odbc_rc == SQL_INVALID_HANDLE) {
- pfc_log_info("ODBCM::DBVarbind:: domain_common_table "
- "bind parameter error :: %d", odbc_rc);
- return ODBCM_RC_PARAM_BIND_ERROR;
- }
return ODBCM_RC_SUCCESS;
}
/**
- * @Description :Function to bind output param of domain_common_table
- * @param[in] : None
- * @return : ODBCM_RC_STATUS
+ * @Description : Output binding function for Domain_table
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * r_hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::bind_domain_table_output(
- std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_ entry*/,
+ std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_entry*/,
HSTMT &r_hstmt/**statement handler which carries the SQL Query*/) {
int64_t odbc_rc = SQL_SUCCESS; // odbc APIs return code
uint16_t col_no = 0; // column number
* table_attribute_name value will be compared and corresponding
* structure member will be binded here*/
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
- /*In case of bind failure return the parameter bind error */
- if (odbc_rc == SQL_ERROR||odbc_rc == SQL_INVALID_HANDLE) {
- pfc_log_error("ODBCM::DBVarbind:: ctr_domain_table: "
- "bind parameter error :: %" PFC_PFMT_d64, odbc_rc);
- /**in case of error while binding return to application caller with the
- * error code */
- return ODBCM_RC_PARAM_BIND_ERROR;
+ if ((*i).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
}
/**binding structure buffer member for controller name output,
* column size is ODBCM_SIZE_32,
* and buffer size will passed as length of value,
* ptr to indicates available no. of bytes return */
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- CTR_NAME/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/,
- p_domain_table->szcontroller_name/*buffer to fetch values*/,
- ODBCM_SIZE_32+1,
- /**no.of bytes available to return*/
- reinterpret_cast<SQLLEN*>(&cbNumericType));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- DOMAIN_NAME/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- p_domain_table->szdomain_name,
- ODBCM_SIZE_32+1,
- reinterpret_cast<SQLLEN*>(&cbNumericType));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- DOMAIN_TYPE/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- reinterpret_cast<SQLSMALLINT*>(&p_domain_table->stype),
- sizeof(SQLSMALLINT),
- reinterpret_cast<SQLLEN*>(&cbNumericType));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128,
- DOMAIN_DESCRIPTION/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- p_domain_table->szdescription,
- ODBCM_SIZE_128+1,
- reinterpret_cast<SQLLEN*>(&cbNumericType));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- DOMAIN_OP_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- reinterpret_cast<SQLSMALLINT*>
- (&p_domain_table->soper_status),
- sizeof(SQLSMALLINT),
- reinterpret_cast<SQLLEN*>(&cbNumericType));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_3,
- DOMAIN_VALID/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- p_domain_table->svalid,
- ODBCM_SIZE_3+1,
- reinterpret_cast<SQLLEN*>(&cbNumericType));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- DOMAIN_CS_ROW_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- reinterpret_cast<SQLSMALLINT*>(&p_domain_table->scs_row_status),
- sizeof(SQLSMALLINT),
- reinterpret_cast<SQLLEN*>(&cbNumericType));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_3,
- DOMAIN_CS_ATTR/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- p_domain_table->scs_attr,
- ODBCM_SIZE_3+1,
- reinterpret_cast<SQLLEN*>(&cbNumericType));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/,
+ p_domain_table->szcontroller_name/*buffer to fetch values*/,
+ ODBCM_SIZE_32+1,
+ /**no.of bytes available to return*/
+ reinterpret_cast<SQLLEN*>(&cbNumericType));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case DOMAIN_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ p_domain_table->szdomain_name,
+ ODBCM_SIZE_32+1,
+ reinterpret_cast<SQLLEN*>(&cbNumericType));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case DOMAIN_TYPE:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindCol_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ reinterpret_cast<SQLSMALLINT*>(&p_domain_table->stype),
+ sizeof(SQLSMALLINT),
+ reinterpret_cast<SQLLEN*>(&cbNumericType));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case DOMAIN_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ p_domain_table->szdescription,
+ ODBCM_SIZE_128+1,
+ reinterpret_cast<SQLLEN*>(&cbNumericType));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case DOMAIN_OP_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindCol_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ reinterpret_cast<SQLSMALLINT*>
+ (&p_domain_table->soper_status),
+ sizeof(SQLSMALLINT),
+ reinterpret_cast<SQLLEN*>(&cbNumericType));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case DOMAIN_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_3) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ p_domain_table->svalid,
+ ODBCM_SIZE_3+1,
+ reinterpret_cast<SQLLEN*>(&cbNumericType));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case DOMAIN_CS_ROW_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindCol_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ reinterpret_cast<SQLSMALLINT*>(&p_domain_table->scs_row_status),
+ sizeof(SQLSMALLINT),
+ reinterpret_cast<SQLLEN*>(&cbNumericType));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case DOMAIN_CS_ATTR:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_3) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ p_domain_table->scs_attr,
+ ODBCM_SIZE_3+1,
+ reinterpret_cast<SQLLEN*>(&cbNumericType));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ default:
+ break;
+ }
+ /*In case of bind failure return the parameter bind error */
+ if (odbc_rc == SQL_ERROR||odbc_rc == SQL_INVALID_HANDLE) {
+ pfc_log_error("ODBCM::DBVarbind:: ctr_domain_table: "
+ "bind parameter error :: %" PFC_PFMT_d64, odbc_rc);
+ /**in case of error while binding return to application caller with the
+ * error code */
+ return ODBCM_RC_PARAM_BIND_ERROR;
}
if (log_flag == 0) {
/**reset flag value 1*/
}
/**
- * @Description : Function to fill the domain_common_table
- * values into bind p_domain_table structure.
- * @param[in] : None
- * @return : ODBCM_RC_STATUS
+ * @Description : To fill the Domain_table values into structure.
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::fill_domain_table(
std::vector<TableAttrSchema>&column_attr
- /*DBTableSchema->rowlist_ entry*/) {
+ /*DBTableSchema->rowlist_entry*/) {
/**Vector iterator to take the TableAttrSchema structures*/
std::vector< TableAttrSchema >::iterator i;
/**Loop for iterate all the elements in the vector, the TableAttrSchema
* table_attribute_name value will be compared and corresponding
* structure member will be filled*/
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- CTR_NAME/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for controller_name CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> domain_cn_value;
- domain_cn_value = *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
- ((*i).p_table_attribute_value));
- /**clear the allocated buffer memory to receive the controller_name
- * from caller*/
- ODBCM_MEMSET(p_domain_table->szcontroller_name, 0, ODBCM_SIZE_32+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_domain_table->szcontroller_name,
- &domain_cn_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:DOMAIN_TABLE:"
- "szController_name = %s", p_domain_table->szcontroller_name);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- DOMAIN_NAME/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for domain_name CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> domain_dn_value;
- domain_dn_value = *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_domain_table->szdomain_name, 0, ODBCM_SIZE_32+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_domain_table->szdomain_name,
- &domain_dn_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:DOMAIN_TABLE:"
- "szdomain_name = %s", p_domain_table->szdomain_name);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- DOMAIN_TYPE/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for type unit16_t*/
- ColumnAttrValue <uint16_t> type_value;
- type_value =
- *((ColumnAttrValue <uint16_t>*)((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_domain_table->stype, 0,
- sizeof(SQLSMALLINT));
- p_domain_table->stype = type_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:DOMAIN_TABLE:"
- "stype = %d", p_domain_table->stype);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128,
- DOMAIN_DESCRIPTION/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for description CHAR[128]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_128]> desc_value =
- *((ColumnAttrValue <uint8_t[128]>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_domain_table->szdescription, 0, ODBCM_SIZE_128+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_domain_table->szdescription,
- &desc_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:DOMAIN_TABLE: "
- "szDescription = %s", p_domain_table->szdescription);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- DOMAIN_OP_STATUS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for oper_status unit16_t*/
- ColumnAttrValue <uint16_t> oper_value;
- oper_value =
- *((ColumnAttrValue <uint16_t>*)((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_domain_table->soper_status, 0,
- sizeof(SQLSMALLINT));
- p_domain_table->soper_status = oper_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:DOMAIN_TABLE:"
- "soper_status = %d", p_domain_table->soper_status);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_3,
- DOMAIN_VALID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for valid CHAR[3]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_3]> domain_valid_val;
- domain_valid_val =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_3]>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_domain_table->svalid, 0, ODBCM_SIZE_3+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_domain_table->svalid,
- &domain_valid_val.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:DOMAIN_TABLE:"
- "sValid = %s", p_domain_table->svalid);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- DOMAIN_CS_ROW_STATUS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for cs_row_status unit16_t*/
- ColumnAttrValue <uint16_t> cs_row_value;
- cs_row_value =
- *((ColumnAttrValue <uint16_t>*)
+ if ((*i).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
+ }
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for controller_name CHAR[32]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> domain_cn_value;
+ domain_cn_value = *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ ((*i).p_table_attribute_value));
+ /**clear the allocated buffer memory to receive the controller_name
+ * from caller*/
+ ODBCM_MEMSET(p_domain_table->szcontroller_name, 0, ODBCM_SIZE_32+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_domain_table->szcontroller_name,
+ &domain_cn_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:DOMAIN_TABLE:"
+ "szController_name = %s", p_domain_table->szcontroller_name);
+ }
+ break;
+ case DOMAIN_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for domain_name CHAR[32]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> domain_dn_value;
+ domain_dn_value = *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_domain_table->scs_row_status, 0,
- sizeof(SQLSMALLINT));
- p_domain_table->scs_row_status = cs_row_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:DOMAIN_TABLE:"
- "scs_row_status = %d", p_domain_table->scs_row_status);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_3,
- DOMAIN_CS_ATTR/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for cs_attr CHAR[3]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_3]> domain_attr_val;
- domain_attr_val =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_3]>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_domain_table->scs_attr, 0, ODBCM_SIZE_3+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_domain_table->scs_attr,
- &domain_attr_val.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:DOMAIN_TABLE:"
- "scs_attr = %s", p_domain_table->scs_attr);
+ ODBCM_MEMSET(p_domain_table->szdomain_name, 0, ODBCM_SIZE_32+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_domain_table->szdomain_name,
+ &domain_dn_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:DOMAIN_TABLE:"
+ "szdomain_name = %s", p_domain_table->szdomain_name);
+ }
+ break;
+ case DOMAIN_TYPE:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for type unit16_t*/
+ ColumnAttrValue <uint16_t> type_value;
+ type_value =
+ *((ColumnAttrValue <uint16_t>*)((*i).p_table_attribute_value));
+ ODBCM_MEMSET(&p_domain_table->stype, 0,
+ sizeof(SQLSMALLINT));
+ p_domain_table->stype = type_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:DOMAIN_TABLE:"
+ "stype = %d", p_domain_table->stype);
+ }
+ break;
+ case DOMAIN_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for description CHAR[128]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_128]> desc_value =
+ *((ColumnAttrValue <uint8_t[128]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_domain_table->szdescription, 0, ODBCM_SIZE_128+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_domain_table->szdescription,
+ &desc_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:DOMAIN_TABLE: "
+ "szDescription = %s", p_domain_table->szdescription);
+ }
+ break;
+ case DOMAIN_OP_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for oper_status unit16_t*/
+ ColumnAttrValue <uint16_t> oper_value;
+ oper_value =
+ *((ColumnAttrValue <uint16_t>*)((*i).p_table_attribute_value));
+ ODBCM_MEMSET(&p_domain_table->soper_status, 0,
+ sizeof(SQLSMALLINT));
+ p_domain_table->soper_status = oper_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:DOMAIN_TABLE:"
+ "soper_status = %d", p_domain_table->soper_status);
+ }
+ break;
+ case DOMAIN_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_3) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for valid CHAR[3]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_3]> domain_valid_val;
+ domain_valid_val =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_3]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_domain_table->svalid, 0, ODBCM_SIZE_3+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_domain_table->svalid,
+ &domain_valid_val.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:DOMAIN_TABLE:"
+ "sValid = %s", p_domain_table->svalid);
+ }
+ break;
+ case DOMAIN_CS_ROW_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for cs_row_status unit16_t*/
+ ColumnAttrValue <uint16_t> cs_row_value;
+ cs_row_value =
+ *((ColumnAttrValue <uint16_t>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(&p_domain_table->scs_row_status, 0,
+ sizeof(SQLSMALLINT));
+ p_domain_table->scs_row_status = cs_row_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:DOMAIN_TABLE:"
+ "scs_row_status = %d", p_domain_table->scs_row_status);
+ }
+ break;
+ case DOMAIN_CS_ATTR:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_3) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for cs_attr CHAR[3]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_3]> domain_attr_val;
+ domain_attr_val =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_3]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_domain_table->scs_attr, 0, ODBCM_SIZE_3+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_domain_table->scs_attr,
+ &domain_attr_val.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:DOMAIN_TABLE:"
+ "scs_attr = %s", p_domain_table->scs_attr);
+ }
+ break;
+ default:
+ break;
}
}
return ODBCM_RC_SUCCESS;
}
/**
- * @Description : Function to fetch the domain_common_table
- * values(which is stored in p_sp_table struct )
- * and store into TableAttSchema
- * @param[in] : None
- * @return : ODBCM_RC_STATUS
+ * @Description : To fetch the Domain_table values
+ * (which are stored in binded buffer)
+ * and store into TableAttSchema
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::fetch_domain_table(
std::vector<TableAttrSchema> &column_attr
- /*DBTableSchema->rowlist_ entry*/) {
+ /*DBTableSchema->rowlist_entry*/) {
/**Vector iterator to take the TableAttrSchema structures*/
std::vector< TableAttrSchema >::iterator i;
/**Loop for iterate all the elements in the vector, the TableAttrSchema
* table_attribute_name value will be compared and corresponding
* structure member will be fetched */
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
- ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- CTR_NAME/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- *caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_32+1],
- val_controller_name);
- ODBCM_MEMCPY(val_controller_name->value,
- p_domain_table->szcontroller_name,
- sizeof(p_domain_table->szcontroller_name));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:DOMAIN_TABLE: "
- "szController_name = %s", val_controller_name->value);
- (*i).p_table_attribute_value = val_controller_name;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- DOMAIN_NAME/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- *caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_32+1],
- val_domain_name);
- ODBCM_MEMCPY(
- val_domain_name->value,
- p_domain_table->szdomain_name,
- sizeof(p_domain_table->szdomain_name));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:DOMAIN_TABLE: "
- "szdomain_name = %s", val_domain_name->value);
- (*i).p_table_attribute_value = val_domain_name;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- DOMAIN_TYPE/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- *caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, type_value);
- type_value->value = p_domain_table->stype;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:DOMAIN_TABLE: "
- "type = %d", type_value->value);
- (*i).p_table_attribute_value = type_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128,
- DOMAIN_DESCRIPTION/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- *caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_128+1],
- val_description);
- ODBCM_MEMCPY(
- val_description->value,
- p_domain_table->szdescription,
- sizeof(p_domain_table->szdescription));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:DOMAIN_TABLE: "
- "szdescription = %s", val_description->value);
- (*i).p_table_attribute_value = val_description;
- // reinterpret_cast<void*>(val_description);
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- DOMAIN_OP_STATUS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- *caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, oper_status_value);
- oper_status_value->value = p_domain_table->soper_status;
- // reinterpret_cast<void*>(oper_status_value);
- odbcm_debug_info("ODBCM::DBVarbind::fetch:DOMAIN_TABLE: "
- "soper_status = %d", oper_status_value->value);
- (*i).p_table_attribute_value = oper_status_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_3,
- DOMAIN_VALID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- *caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_3+1],
- domain_valid_value);
- ODBCM_MEMCPY(
- domain_valid_value->value,
- &p_domain_table->svalid,
- sizeof(p_domain_table->svalid));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:DOMAIN_TABLE: svalid = %s",
- domain_valid_value->value);
- (*i).p_table_attribute_value = domain_valid_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- DOMAIN_CS_ROW_STATUS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- *caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, cs_row_status_value);
- cs_row_status_value->value = p_domain_table->scs_row_status;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:DOMAIN_TABLE: "
- "scs_row_status = %d", cs_row_status_value->value);
- (*i).p_table_attribute_value = cs_row_status_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_3,
- DOMAIN_CS_ATTR/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- *caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_3+1],
- domain_attr_value);
- ODBCM_MEMCPY(
- domain_attr_value->value,
- &p_domain_table->scs_attr,
- sizeof(p_domain_table->scs_attr));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:DOMAIN_TABLE: scs_attr = %s",
- domain_attr_value->value);
- (*i).p_table_attribute_value = domain_attr_value;
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ *caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_32+1],
+ val_controller_name);
+ ODBCM_MEMCPY(val_controller_name->value,
+ p_domain_table->szcontroller_name,
+ sizeof(p_domain_table->szcontroller_name));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:DOMAIN_TABLE: "
+ "szController_name = %s", val_controller_name->value);
+ (*i).p_table_attribute_value = val_controller_name;
+ }
+ break;
+ case DOMAIN_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ *caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_32+1],
+ val_domain_name);
+ ODBCM_MEMCPY(
+ val_domain_name->value,
+ p_domain_table->szdomain_name,
+ sizeof(p_domain_table->szdomain_name));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:DOMAIN_TABLE: "
+ "szdomain_name = %s", val_domain_name->value);
+ (*i).p_table_attribute_value = val_domain_name;
+ }
+ break;
+ case DOMAIN_TYPE:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ *caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, type_value);
+ type_value->value = p_domain_table->stype;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:DOMAIN_TABLE: "
+ "type = %d", type_value->value);
+ (*i).p_table_attribute_value = type_value;
+ }
+ break;
+ case DOMAIN_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ *caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_128+1],
+ val_description);
+ ODBCM_MEMCPY(
+ val_description->value,
+ p_domain_table->szdescription,
+ sizeof(p_domain_table->szdescription));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:DOMAIN_TABLE: "
+ "szdescription = %s", val_description->value);
+ (*i).p_table_attribute_value = val_description;
+ }
+ break;
+ case DOMAIN_OP_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ // reinterpret_cast<void*>(val_description);
+ /**ColumnAttrValue is a template to send the fetched values to
+ *caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, oper_status_value);
+ oper_status_value->value = p_domain_table->soper_status;
+ // reinterpret_cast<void*>(oper_status_value);
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:DOMAIN_TABLE: "
+ "soper_status = %d", oper_status_value->value);
+ (*i).p_table_attribute_value = oper_status_value;
+ }
+ break;
+ case DOMAIN_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_3) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ *caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_3+1],
+ domain_valid_value);
+ ODBCM_MEMCPY(
+ domain_valid_value->value,
+ &p_domain_table->svalid,
+ sizeof(p_domain_table->svalid));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:DOMAIN_TABLE: svalid = %s",
+ domain_valid_value->value);
+ (*i).p_table_attribute_value = domain_valid_value;
+ }
+ break;
+ case DOMAIN_CS_ROW_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ *caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, cs_row_status_value);
+ cs_row_status_value->value = p_domain_table->scs_row_status;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:DOMAIN_TABLE: "
+ "scs_row_status = %d", cs_row_status_value->value);
+ (*i).p_table_attribute_value = cs_row_status_value;
+ }
+ break;
+ case DOMAIN_CS_ATTR:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_3) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ *caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_3+1],
+ domain_attr_value);
+ ODBCM_MEMCPY(
+ domain_attr_value->value,
+ &p_domain_table->scs_attr,
+ sizeof(p_domain_table->scs_attr));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:DOMAIN_TABLE: scs_attr = %s",
+ domain_attr_value->value);
+ (*i).p_table_attribute_value = domain_attr_value;
+ }
+ break;
+ default:
+ break;
}
}
return ODBCM_RC_SUCCESS;
#include "odbcm_common.hh"
#include "odbcm_utils.hh"
#include "odbcm_db_tableschema.hh"
+#include "odbcm_mgr.hh"
using unc::uppl::DBVarbind;
/**
- * @Description : Function to bind input parameter of link_common_table
- * @param[in] : vector<TableAttrSchema> &column_attr, HSTMT &r_hstmt
- * @return : ODBCM_RC_STATUS
+ * @Description : Function to bind input parameter of link_table
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * r_hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::bind_link_table_input(
- std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_ entry*/,
+ std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_entry*/,
HSTMT &r_hstmt/**statement handler which carries the SQL Query*/) {
SQLRETURN odbc_rc = SQL_SUCCESS; // odbc API's return code initialize with 0
* table_attribute_name value will be compared and corresponding
* structure member will be binded here*/
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
+ if ((*i).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
+ }
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**binding structure buffer member for controller name input,
+ * column size is ODBCM_SIZE_32,
+ * Data type CHAR[32],
+ * and buffer size will passed as length of value */
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/,
+ ODBCM_SIZE_32/*column size in DB table*/,
+ 0/**decimal point */,
+ p_link_table->szcontroller_name/*buffer to carry values*/,
+ sizeof(p_link_table->szcontroller_name)-1/**buffer length*/,
+ NULL/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LINK_SWITCH_ID1:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ /**binding structure buffer member for switch_id1 input,
+ * column size is ODBCM_SIZE_256,
+ * Data type CHAR[256], this char data will be converted into
+ * binary before store into database table. switch_id may have non
+ * printable characters as well, To allow non printable character
+ * from 0-255, the binary is chose*/
+ *p_switch_id1_len = strlen((const char*)p_link_table->szswitch_id1);
+ odbc_rc = BindInputParameter_SQL_BINARY(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/,
+ ODBCM_SIZE_256/*column size in DB table*/,
+ 0/**decimal point */,
+ p_link_table->szswitch_id1/*buffer to carry values*/,
+ sizeof(p_link_table->szswitch_id1)-1,
+ p_switch_id1_len/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LINK_PORT_ID1:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**binding structure buffer member for port_id1,
+ * column size is ODBCM_SIZE_32,
+ * data type CHAR[32]*/
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_32,
+ 0,
+ p_link_table->szport_id1,
+ sizeof(p_link_table->szport_id1)-1,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LINK_SWITCH_ID2:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ *p_switch_id2_len = strlen((const char*)p_link_table->szswitch_id2);
+ odbc_rc = BindInputParameter_SQL_BINARY(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_256,
+ 0,
+ p_link_table->szswitch_id2,
+ ODBCM_SIZE_256,
+ p_switch_id2_len);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LINK_PORT_ID2:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_32,
+ 0,
+ p_link_table->szport_id2,
+ sizeof(p_link_table->szport_id2)-1,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LINK_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_128,
+ 0,
+ p_link_table->szdescription,
+ sizeof(p_link_table->szdescription)-1,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LINK_OPER_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindInputParameter_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ reinterpret_cast<SQLSMALLINT*>(&p_link_table->soper_status),
+ 0,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LINK_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_2) {
+ odbc_rc = BindInputParameter_SQL_CHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_2,
+ 0,
+ p_link_table->svalid,
+ sizeof(p_link_table->svalid)-1,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ default:
+ break;
+ }
/*In case of bind failure return the parameter bind error */
if (odbc_rc == SQL_ERROR || odbc_rc == SQL_INVALID_HANDLE) {
pfc_log_error("ODBCM::DBVarbind::bind_link_table_input"
* error code */
return ODBCM_RC_PARAM_BIND_ERROR;
}
-
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- CTR_NAME/*attribute name MACRO*/) {
- /**binding structure buffer member for controller name input,
- * column size is ODBCM_SIZE_32,
- * Data type CHAR[32],
- * and buffer size will passed as length of value */
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/,
- ODBCM_SIZE_32/*column size in DB table*/,
- 0/**decimal point */,
- p_link_table->szcontroller_name/*buffer to carry values*/,
- sizeof(p_link_table->szcontroller_name)-1/**buffer length*/,
- NULL/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256/**data type char(256)*/,
- LINK_SWITCH_ID1/*attribute name MACRO*/) {
- /**binding structure buffer member for switch_id1 input,
- * column size is ODBCM_SIZE_256,
- * Data type CHAR[256], this char data will be converted into
- * binary before store into database table. switch_id may have non
- * printable characters as well, To allow non printable character
- * from 0-255, the binary is chose*/
- *p_switch_id1_len = strlen((const char*)p_link_table->szswitch_id1);
- odbc_rc = BindInputParameter_SQL_BINARY(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/,
- ODBCM_SIZE_256/*column size in DB table*/,
- 0/**decimal point */,
- p_link_table->szswitch_id1/*buffer to carry values*/,
- sizeof(p_link_table->szswitch_id1)-1,
- p_switch_id1_len/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- LINK_PORT_ID1/*attribute name MACRO*/) {
- /**binding structure buffer member for port_id1,
- * column size is ODBCM_SIZE_32,
- * data type CHAR[32]*/
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_32,
- 0,
- p_link_table->szport_id1,
- sizeof(p_link_table->szport_id1)-1,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256/**data type char(256)*/,
- LINK_SWITCH_ID2/*attribute name MACRO*/) {
- *p_switch_id2_len = strlen((const char*)p_link_table->szswitch_id2);
- odbc_rc = BindInputParameter_SQL_BINARY(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_256,
- 0,
- p_link_table->szswitch_id2,
- ODBCM_SIZE_256,
- p_switch_id2_len);
-
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- LINK_PORT_ID2/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_32,
- 0,
- p_link_table->szport_id2,
- sizeof(p_link_table->szport_id2)-1,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128/**data type char(128)*/,
- LINK_DESCRIPTION/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_128,
- 0,
- p_link_table->szdescription,
- sizeof(p_link_table->szdescription)-1,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16/**data type char(16)*/,
- LINK_OPER_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- reinterpret_cast<SQLSMALLINT*>(&p_link_table->soper_status),
- 0,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_2/**data type char(2)*/,
- LINK_VALID/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_CHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_2,
- 0,
- p_link_table->svalid,
- sizeof(p_link_table->svalid)-1,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- }
if ((*i).p_table_attribute_value != NULL && log_flag == 0) {
if (odbc_rc != SQL_SUCCESS)
ODBCMUtils::OdbcmHandleDiagnosticsPrint(SQL_HANDLE_STMT, r_hstmt);
/**reset flag value 1 */
log_flag = 1;
} else {
- pfc_log_info("ODBCM::**NO bind**i/p:LINK_TABLE:%s:datatype=%d:"
- , ((*i).table_attribute_name).c_str(),
+ pfc_log_debug("ODBCM::**NO bind**i/p:LINK_TABLE:%s:datatype=%d:"
+ , ODBCManager::get_ODBCManager()->GetColumnName(
+ ((*i).table_attribute_name)).c_str(),
(*i).request_attribute_type);
}
} // for loop end
/**
* @Description : Output binding function for link_table
- * @param[in] : vector<TableAttrSchema> &column_attr, HSTMT &r_hstmt
- * @return : ODBCM_RC_STATUS
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * r_hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::bind_link_table_output(
std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_ entry*/,
* table_attribute_name value will be compared and corresponding
* structure member will be binded here*/
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
+ if ((*i).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
+ }
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**binding structure buffer member for controller name output,
+ * column size is ODBCM_SIZE_32,
+ * Data type CHAR[32],
+ * and buffer size will passed as length of value,
+ * ptr to indicates available no. of bytes return */
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/,
+ p_link_table->szcontroller_name/*buffer to fetch values*/,
+ ODBCM_SIZE_32+1,
+ /**no.of bytes available to return*/
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LINK_SWITCH_ID1:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ /**binding structure buffer member for controller name output,
+ * column size is ODBCM_SIZE_256,
+ * Data type CHAR[246],
+ * and buffer size will passed as length of value,
+ * ptr to indicates available no. of bytes return,
+ * Binary type values will be converted and stored into char buffer */
+ *p_switch_id1_len = strlen((const char*)p_link_table->szswitch_id1);
+ odbc_rc = BindCol_SQL_BINARY(
+ r_hstmt,
+ ++col_no,
+ p_link_table->szswitch_id1,
+ sizeof(p_link_table->szswitch_id1),
+ p_switch_id1_len/*buffer to fetch values*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LINK_PORT_ID1:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ p_link_table->szport_id1, ODBCM_SIZE_32+1,
+ reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LINK_SWITCH_ID2:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ *p_switch_id2_len = strlen((const char*)p_link_table->szswitch_id2);
+ odbc_rc = BindCol_SQL_BINARY(
+ r_hstmt,
+ ++col_no,
+ p_link_table->szswitch_id2,
+ sizeof(p_link_table->szswitch_id2),
+ p_switch_id2_len/*buffer to fetch values*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LINK_PORT_ID2:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ p_link_table->szport_id2,
+ ODBCM_SIZE_32+1,
+ reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LINK_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ p_link_table->szdescription,
+ ODBCM_SIZE_128+1,
+ reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LINK_OPER_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindCol_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ reinterpret_cast<SQLSMALLINT*>(&p_link_table->soper_status),
+ sizeof(SQLSMALLINT),
+ reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LINK_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_2) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ p_link_table->svalid,
+ ODBCM_SIZE_2+1,
+ reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ default:
+ break;
+ }
/*In case of bind failure return the parameter bind error */
if (odbc_rc == SQL_ERROR || odbc_rc == SQL_INVALID_HANDLE) {
pfc_log_error("ODBCM::DBVarbind::bind_link_table_output"
* error code */
return ODBCM_RC_PARAM_BIND_ERROR;
}
- /**binding structure buffer member for controller name output,
- * column size is ODBCM_SIZE_32,
- * Data type CHAR[32],
- * and buffer size will passed as length of value,
- * ptr to indicates available no. of bytes return */
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- CTR_NAME/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/,
- p_link_table->szcontroller_name/*buffer to fetch values*/,
- ODBCM_SIZE_32+1,
- /**no.of bytes available to return*/
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- LINK_SWITCH_ID1/*attribute name MACRO*/) {
- /**binding structure buffer member for controller name output,
- * column size is ODBCM_SIZE_256,
- * Data type CHAR[246],
- * and buffer size will passed as length of value,
- * ptr to indicates available no. of bytes return,
- * Binary type values will be converted and stored into char buffer */
- *p_switch_id1_len = strlen((const char*)p_link_table->szswitch_id1);
- odbc_rc = BindCol_SQL_BINARY(
- r_hstmt,
- ++col_no,
- p_link_table->szswitch_id1,
- sizeof(p_link_table->szswitch_id1),
- p_switch_id1_len/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- LINK_PORT_ID1/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- p_link_table->szport_id1, ODBCM_SIZE_32+1,
- reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- LINK_SWITCH_ID2/*attribute name MACRO*/) {
- *p_switch_id2_len = strlen((const char*)p_link_table->szswitch_id2);
- odbc_rc = BindCol_SQL_BINARY(
- r_hstmt,
- ++col_no,
- p_link_table->szswitch_id2,
- sizeof(p_link_table->szswitch_id2),
- p_switch_id2_len/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- LINK_PORT_ID2/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- p_link_table->szport_id2,
- ODBCM_SIZE_32+1,
- reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128,
- LINK_DESCRIPTION/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- p_link_table->szdescription,
- ODBCM_SIZE_128+1,
- reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- LINK_OPER_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- reinterpret_cast<SQLSMALLINT*>(&p_link_table->soper_status),
- sizeof(SQLSMALLINT),
- reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_2,
- LINK_VALID/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- p_link_table->svalid,
- ODBCM_SIZE_2+1,
- reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- }
if (log_flag == 0) {
/**reset flag value 1*/
log_flag = 1;
}
/**
- * @Description : To fill the link_common_table values into structure.
- * @param[in] : std::vector<TableAttrSchema> &column_attr
- * @return : ODBCM_RC_STATUS
+ * @Description : To fill the link_table values into structure.
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::fill_link_table(
std::vector<TableAttrSchema> &column_attr
- /*DBTableSchema->rowlist_ entry*/) {
+ /*DBTableSchema->rowlist_entry*/) {
/**Vector iterator to take the TableAttrSchema structures*/
std::vector< TableAttrSchema >::iterator i;
/**Loop for iterate all the elements in the vector, the TableAttrSchema
* table_attribute_name value will be compared and corresponding
* structure member will be filled*/
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- CTR_NAME/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for controller_name CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> cn_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
- ((*i).p_table_attribute_value));
- /**clear the allocated buffer memory to receive the controller_name
- * from caller*/
- ODBCM_MEMSET(p_link_table->szcontroller_name, 0, ODBCM_SIZE_32+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_link_table->szcontroller_name,
- &cn_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:LINK_TABLE: "
- "szController_name = %s", p_link_table->szcontroller_name);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- LINK_SWITCH_ID1/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for switch_id1 CHAR[256]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_256]> sid1_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_256]>*)
+ if ((*i).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
+ }
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for controller_name CHAR[32]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> cn_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_link_table->szswitch_id1, 0, ODBCM_SIZE_256+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_link_table->szswitch_id1,
- &sid1_value.value,
- (*i).table_attribute_length+1);
- odbcm_debug_info("ODBCM::DBVarbind::fill:LINK_TABLE: szswitch_id1 = %s",
- p_link_table->szswitch_id1);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- LINK_PORT_ID1/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for port_id1 CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> pn1_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ /**clear the allocated buffer memory to receive the controller_name
+ * from caller*/
+ ODBCM_MEMSET(p_link_table->szcontroller_name, 0, ODBCM_SIZE_32+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_link_table->szcontroller_name,
+ &cn_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LINK_TABLE: "
+ "szController_name = %s", p_link_table->szcontroller_name);
+ }
+ break;
+ case LINK_SWITCH_ID1:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for switch_id1 CHAR[256]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_256]> sid1_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_256]>*)
((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_link_table->szport_id1, 0, ODBCM_SIZE_32+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_link_table->szport_id1,
- &pn1_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:LINK_TABLE: szport_id1 = %s",
- p_link_table->szport_id1);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- LINK_SWITCH_ID2/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for switch_id2 CHAR[256]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_256]> sid2_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_256]>*)
+ ODBCM_MEMSET(p_link_table->szswitch_id1, 0, ODBCM_SIZE_256+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_link_table->szswitch_id1,
+ &sid1_value.value,
+ (*i).table_attribute_length+1);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LINK_TABLE:"
+ "szswitch_id1 = %s", p_link_table->szswitch_id1);
+ }
+ break;
+ case LINK_PORT_ID1:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for port_id1 CHAR[32]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> pn1_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_link_table->szport_id1, 0, ODBCM_SIZE_32+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_link_table->szport_id1,
+ &pn1_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LINK_TABLE: szport_id1 = %s",
+ p_link_table->szport_id1);
+ }
+ break;
+ case LINK_SWITCH_ID2:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for switch_id2 CHAR[256]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_256]> sid2_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_256]>*)
((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_link_table->szswitch_id2, 0, ODBCM_SIZE_256+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_link_table->szswitch_id2,
- &sid2_value.value,
- (*i).table_attribute_length+1);
- odbcm_debug_info("ODBCM::DBVarbind::fill:LINK_TABLE: szswitch_id2 = %s",
- p_link_table->szswitch_id2);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- LINK_PORT_ID2/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for port_id2 CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> pn2_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ ODBCM_MEMSET(p_link_table->szswitch_id2, 0, ODBCM_SIZE_256+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_link_table->szswitch_id2,
+ &sid2_value.value,
+ (*i).table_attribute_length+1);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LINK_TABLE: szswitch_id2 = %s",
+ p_link_table->szswitch_id2);
+ }
+ break;
+ case LINK_PORT_ID2:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for port_id2 CHAR[32]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> pn2_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_link_table->szport_id2, 0, ODBCM_SIZE_32+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_link_table->szport_id2,
- &pn2_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:LINK_TABLE: szport_id2 = %s",
- p_link_table->szport_id2);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128,
- LINK_DESCRIPTION/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for description CHAR[128]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_128]> desc_value =
- *((ColumnAttrValue <uint8_t[128]>*)((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_link_table->szdescription, 0, ODBCM_SIZE_128+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_link_table->szdescription,
- &desc_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:LINK_TABLE: "
- "szDescription = %s", p_link_table->szdescription);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- LINK_OPER_STATUS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for oper_status uint16_t*/
- ColumnAttrValue <uint16_t> oper_st_value =
- *((ColumnAttrValue <uint16_t>*)((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_link_table->soper_status, 0, sizeof(SQLSMALLINT));
- /**copying the value from template to binded buffer */
- p_link_table->soper_status = oper_st_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:LINK_TABLE:soper_status=%d",
+ ODBCM_MEMSET(p_link_table->szport_id2, 0, ODBCM_SIZE_32+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_link_table->szport_id2,
+ &pn2_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LINK_TABLE: szport_id2 = %s",
+ p_link_table->szport_id2);
+ }
+ break;
+ case LINK_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for description CHAR[128]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_128]> desc_value =
+ *((ColumnAttrValue <uint8_t[128]>*)((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_link_table->szdescription, 0, ODBCM_SIZE_128+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_link_table->szdescription,
+ &desc_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LINK_TABLE: "
+ "szDescription = %s", p_link_table->szdescription);
+ }
+ break;
+ case LINK_OPER_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for oper_status uint16_t*/
+ ColumnAttrValue <uint16_t> oper_st_value =
+ *((ColumnAttrValue <uint16_t>*)((*i).p_table_attribute_value));
+ ODBCM_MEMSET(&p_link_table->soper_status, 0, sizeof(SQLSMALLINT));
+ /**copying the value from template to binded buffer */
+ p_link_table->soper_status = oper_st_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LINK_TABLE:soper_status=%d",
p_link_table->soper_status);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_2,
- LINK_VALID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for valid CHAR[2]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_2]> valid_value = *((ColumnAttrValue
- <uint8_t[ODBCM_SIZE_2]>*)((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_link_table->svalid, 0, ODBCM_SIZE_2+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_link_table->svalid,
- &valid_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:LINK_TABLE: "
- "sValid = %s", p_link_table->svalid);
+ }
+ break;
+ case LINK_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_2) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for valid CHAR[2]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_2]> valid_value =
+ *((ColumnAttrValue
+ <uint8_t[ODBCM_SIZE_2]>*)((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_link_table->svalid, 0, ODBCM_SIZE_2+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_link_table->svalid,
+ &valid_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LINK_TABLE: "
+ "sValid = %s", p_link_table->svalid);
+ }
+ break;
+ default:
+ break;
}
}
/*return the final status to caller*/
}
/**
- * @Description : To fetch the link_common_table values
- * (which are stored in binded buffer) and store into TableAttSchema
- * @param[in] : vector<TableAttrSchema> &column_attr
- * @return : ODBCM_RC_STATUS
+ * @Description : To fetch the link_table values
+ * (which are stored in binded buffer)
+ * and store into TableAttSchema
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::fetch_link_table(
std::vector<TableAttrSchema> &column_attr
- /*DBTableSchema->rowlist_ entry*/) {
+ /*DBTableSchema->rowlist_entry*/) {
/**Vector iterator to take the TableAttrSchema structures*/
std::vector< TableAttrSchema >::iterator i;
/**Loop for iterate all the elements in the vector, the TableAttrSchema
* table_attribute_name value will be compared and corresponding
* structure member will be fetched */
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
- ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- CTR_NAME/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_32+1],
- val_controller_name);
- ODBCM_MEMCPY(
- val_controller_name->value,
- p_link_table->szcontroller_name,
- sizeof(p_link_table->szcontroller_name));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LINK_TABLE: "
- "controller_name = %s" , val_controller_name->value);
- (*i).p_table_attribute_value = val_controller_name;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- LINK_SWITCH_ID1/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_256+1],
- val_switch_id1);
- ODBCM_MEMCPY(
- val_switch_id1->value,
- p_link_table->szswitch_id1,
- *p_switch_id1_len);
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LINK_TABLE: "
- "switch_id1 = %s" , val_switch_id1->value);
- (*i).p_table_attribute_value = val_switch_id1;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- LINK_PORT_ID1/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_32+1],
- val_port_name1);
- ODBCM_MEMCPY(
- val_port_name1->value,
- p_link_table->szport_id1,
- sizeof(p_link_table->szport_id1));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LINK_TABLE: "
- "port_name1 = %s" , val_port_name1->value);
- (*i).p_table_attribute_value = val_port_name1;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- LINK_SWITCH_ID2/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_256+1],
- val_switch_id2);
- ODBCM_MEMCPY(
- val_switch_id2->value,
- p_link_table->szswitch_id2,
- *p_switch_id2_len);
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LINK_TABLE: "
- "switch_id2 = %s" , val_switch_id2->value);
- (*i).p_table_attribute_value = val_switch_id2;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- LINK_PORT_ID2/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_32+1],
- val_port_name2);
- ODBCM_MEMCPY(
- val_port_name2->value,
- p_link_table->szport_id2,
- sizeof(p_link_table->szport_id2));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LINK_TABLE: "
- "port_name2 = %s" , val_port_name2->value);
- (*i).p_table_attribute_value = val_port_name2;
- }
- ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128,
- LINK_DESCRIPTION/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_128+1],
- desc_value);
- ODBCM_MEMCPY(
- desc_value->value,
- p_link_table->szdescription,
- sizeof(p_link_table->szdescription));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LINK_TABLE: "
- "description = %s", desc_value->value);
- (*i).p_table_attribute_value = desc_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- LINK_OPER_STATUS/*attribute name MACRO*/) {
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, oper_status_value);
- oper_status_value->value = p_link_table->soper_status;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LINK_TABLE: "
- "soper_status = %d", oper_status_value->value);
- (*i).p_table_attribute_value = oper_status_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_2,
- LINK_VALID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_2+1], valid_value);
- ODBCM_MEMCPY(
- valid_value->value,
- p_link_table->svalid,
- sizeof(p_link_table->svalid));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LINK_TABLE: "
- "valid = %s", valid_value->value);
- (*i).p_table_attribute_value = valid_value;
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_32+1],
+ val_controller_name);
+ ODBCM_MEMCPY(
+ val_controller_name->value,
+ p_link_table->szcontroller_name,
+ sizeof(p_link_table->szcontroller_name));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LINK_TABLE: "
+ "controller_name = %s" , val_controller_name->value);
+ (*i).p_table_attribute_value = val_controller_name;
+ }
+ break;
+ case LINK_SWITCH_ID1:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_256+1],
+ val_switch_id1);
+ ODBCM_MEMCPY(
+ val_switch_id1->value,
+ p_link_table->szswitch_id1,
+ *p_switch_id1_len);
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LINK_TABLE: "
+ "switch_id1 = %s" , val_switch_id1->value);
+ (*i).p_table_attribute_value = val_switch_id1;
+ }
+ break;
+ case LINK_PORT_ID1:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_32+1],
+ val_port_name1);
+ ODBCM_MEMCPY(
+ val_port_name1->value,
+ p_link_table->szport_id1,
+ sizeof(p_link_table->szport_id1));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LINK_TABLE: "
+ "port_name1 = %s" , val_port_name1->value);
+ (*i).p_table_attribute_value = val_port_name1;
+ }
+ break;
+ case LINK_SWITCH_ID2:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_256+1],
+ val_switch_id2);
+ ODBCM_MEMCPY(
+ val_switch_id2->value,
+ p_link_table->szswitch_id2,
+ *p_switch_id2_len);
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LINK_TABLE: "
+ "switch_id2 = %s" , val_switch_id2->value);
+ (*i).p_table_attribute_value = val_switch_id2;
+ }
+ break;
+ case LINK_PORT_ID2:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_32+1],
+ val_port_name2);
+ ODBCM_MEMCPY(
+ val_port_name2->value,
+ p_link_table->szport_id2,
+ sizeof(p_link_table->szport_id2));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LINK_TABLE: "
+ "port_name2 = %s" , val_port_name2->value);
+ (*i).p_table_attribute_value = val_port_name2;
+ }
+ break;
+ case LINK_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_128+1],
+ desc_value);
+ ODBCM_MEMCPY(
+ desc_value->value,
+ p_link_table->szdescription,
+ sizeof(p_link_table->szdescription));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LINK_TABLE: "
+ "description = %s", desc_value->value);
+ (*i).p_table_attribute_value = desc_value;
+ }
+ break;
+ case LINK_OPER_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, oper_status_value);
+ oper_status_value->value = p_link_table->soper_status;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LINK_TABLE: "
+ "soper_status = %d", oper_status_value->value);
+ (*i).p_table_attribute_value = oper_status_value;
+ }
+ break;
+ case LINK_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_2) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_2+1], valid_value);
+ ODBCM_MEMCPY(
+ valid_value->value,
+ p_link_table->svalid,
+ sizeof(p_link_table->svalid));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LINK_TABLE: "
+ "valid = %s", valid_value->value);
+ (*i).p_table_attribute_value = valid_value;
+ }
+ break;
+ default:
+ break;
}
}
return ODBCM_RC_SUCCESS;
#include "odbcm_common.hh"
#include "odbcm_utils.hh"
#include "odbcm_db_tableschema.hh"
+#include "odbcm_mgr.hh"
using unc::uppl::DBVarbind;
/**
- * @Description : function to bind input param of LOGICAL_MEMBERPORT_TABLE
- * @param[in] : vector<TableAttrSchema> &column_attr, HSTMT &r_hstmt
- * @return : ODBCM_RC_STATUS
+ * @Description : Function to bind input parameter of logicalmemberport_table
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * r_hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::bind_logical_memberport_table_input(
- std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_ entry*/,
+ std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_entry*/,
HSTMT &r_hstmt/**statement handler which carries the SQL Query*/) {
SQLRETURN odbc_rc = SQL_SUCCESS; // odbc API's return code initialize with 0
* table_attribute_name value will be compared and corresponding
* structure member will be binded here*/
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
+ if ((*i).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
+ }
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**binding structure buffer member for controller name input,
+ * column size is ODBCM_SIZE_32,
+ * Data type CHAR[32],
+ * and buffer size will passed as length of value */
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt/**sql statement handler*/,
+ ++col_no /*parameter number (sequential order)*/,
+ ODBCM_SIZE_32/*column size in DB table*/,
+ 0/**decimal point */,
+ p_logical_memberport_table->szController_name
+ /*buffer to carry values*/,
+ sizeof(p_logical_memberport_table->szController_name)-1
+ /*buffer length*/,
+ NULL/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case DOMAIN_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**binding structure buffer member for domain name input,
+ * column size is ODBCM_SIZE_32,
+ * Data type CHAR[32],
+ * and buffer size will passed as length of value */
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt/**sql statement handler*/,
+ ++col_no /*parameter number (sequential order)*/,
+ ODBCM_SIZE_32/*column size in DB table*/,
+ 0/**decimal point */,
+ p_logical_memberport_table->szDomain_name
+ /*buffer to carry values*/,
+ sizeof(p_logical_memberport_table->szDomain_name)-1
+ /*buffer length*/,
+ NULL/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LMP_LP_PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_320) {
+ /**binding structure buffer member for port_id input,
+ * column size is ODBCM_SIZE_320,
+ * Data type CHAR[320], this char data will be converted into
+ * binary before store into database table. switch_id may have non
+ * printable characters as well, To allow non printable character
+ * from 0-320, the binary is chose*/
+ *p_logicalport_id1_len =
+ strlen((const char*)
+ p_logical_memberport_table->szlogical_port_id);
+ odbc_rc = BindInputParameter_SQL_BINARY(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/,
+ ODBCM_SIZE_320/*column size in DB table*/,
+ 0/**decimal point */,
+ p_logical_memberport_table->szlogical_port_id
+ /*buffer to carry values*/,
+ sizeof(p_logical_memberport_table->szlogical_port_id)-1,
+ p_logicalport_id1_len/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LMP_SWITCH_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ *p_switch_id1_len = strlen((const char*)
+ p_logical_memberport_table->szswitch_id);
+ odbc_rc = BindInputParameter_SQL_BINARY(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_256,
+ 0,
+ p_logical_memberport_table->szswitch_id,
+ sizeof(p_logical_memberport_table->szswitch_id)-1,
+ p_switch_id1_len);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LMP_PHYSICAL_PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_32,
+ 0,
+ p_logical_memberport_table->szphysical_port_id,
+ sizeof(p_logical_memberport_table->szphysical_port_id)-1,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ default:
+ break;
+ }
/*In case of bind failure return the parameter bind error */
if (odbc_rc == SQL_ERROR || odbc_rc == SQL_INVALID_HANDLE) {
pfc_log_error("ODBCM::DBVarbind::bind_logical_memberport_table_input"
* error code */
return ODBCM_RC_PARAM_BIND_ERROR;
}
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- CTR_NAME /*attribute name MACRO*/) {
- /**binding structure buffer member for controller name input,
- * column size is ODBCM_SIZE_32,
- * Data type CHAR[32],
- * and buffer size will passed as length of value */
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt/**sql statement handler*/,
- ++col_no /*parameter number (sequential order)*/,
- ODBCM_SIZE_32/*column size in DB table*/,
- 0/**decimal point */,
- p_logical_memberport_table->szController_name /*buffer to carry values*/,
- sizeof(p_logical_memberport_table->szController_name)-1/*buffer length*/,
- NULL/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- DOMAIN_NAME /*attribute name MACRO*/) {
- /**binding structure buffer member for domain name input,
- * column size is ODBCM_SIZE_32,
- * Data type CHAR[32],
- * and buffer size will passed as length of value */
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt/**sql statement handler*/,
- ++col_no /*parameter number (sequential order)*/,
- ODBCM_SIZE_32/*column size in DB table*/,
- 0/**decimal point */,
- p_logical_memberport_table->szDomain_name /*buffer to carry values*/,
- sizeof(p_logical_memberport_table->szDomain_name)-1/**buffer length*/,
- NULL/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_320/**data type char(320)*/,
- LMP_LP_PORT_ID/*attribute name MACRO*/) {
- /**binding structure buffer member for port_id input,
- * column size is ODBCM_SIZE_320,
- * Data type CHAR[320], this char data will be converted into
- * binary before store into database table. switch_id may have non
- * printable characters as well, To allow non printable character
- * from 0-320, the binary is chose*/
- *p_logicalport_id1_len = strlen((const char*)
- p_logical_memberport_table->szlogical_port_id);
- odbc_rc = BindInputParameter_SQL_BINARY(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/,
- ODBCM_SIZE_320/*column size in DB table*/,
- 0/**decimal point */,
- p_logical_memberport_table->szlogical_port_id/*buffer to carry values*/,
- sizeof(p_logical_memberport_table->szlogical_port_id)-1,
- p_logicalport_id1_len/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256/**data type char(256)*/,
- SWITCH_ID/*attribute name MACRO*/) {
- *p_switch_id1_len = strlen((const char*)
- p_logical_memberport_table->szswitch_id);
- odbc_rc = BindInputParameter_SQL_BINARY(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_256,
- 0,
- p_logical_memberport_table->szswitch_id,
- sizeof(p_logical_memberport_table->szswitch_id)-1,
- p_switch_id1_len);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- LMP_PHYSICAL_PORT_ID/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_32,
- 0,
- p_logical_memberport_table->szphysical_port_id,
- sizeof(p_logical_memberport_table->szphysical_port_id)-1,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- }
if ((*i).p_table_attribute_value != NULL && log_flag == 0) {
if (odbc_rc != SQL_SUCCESS)
ODBCMUtils::OdbcmHandleDiagnosticsPrint(SQL_HANDLE_STMT, r_hstmt);
/**reset flag value 1 */
log_flag = 1;
} else {
- pfc_log_info("ODBCM::**No bind**i/p:LOGICAL_MEMBERPORT_TABLE:%s:"
- "datatype=%d:", ((*i).table_attribute_name).c_str(),
- (*i).request_attribute_type);
+ pfc_log_debug("ODBCM::**No bind**i/p:LOGICAL_MEMBERPORT_TABLE:%s:"
+ "datatype=%d:", ODBCManager::get_ODBCManager()->GetColumnName(
+ ((*i).table_attribute_name)).c_str(),
+ (*i).request_attribute_type);
}
} // for loop
return ODBCM_RC_SUCCESS;
}
/**
- * @Description : Output binding function for LOGICAL_MEMBERPORT_TABLE
- * +1 is added where ever the char array is used to store '\0'.
- * @param[in] : vector<TableAttrSchema> &column_attr, HSTMT &r_hstmt
- * @return : ODBCM_RC_STATUS
+ * @Description : Output binding function for logicalmemberport_table
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * r_hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::bind_logical_memberport_table_output(
- std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_ entry*/,
+ std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_entry*/,
HSTMT &r_hstmt/**statement handler which carries the SQL Query*/) {
SQLRETURN odbc_rc = SQL_SUCCESS; // odbc APIs return code
uint16_t col_no = 0; // column number
* table_attribute_name value will be compared and corresponding
* structure member will be binded here*/
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
- /*In case of bind failure return the parameter bind error */
- if (odbc_rc == SQL_ERROR || odbc_rc == SQL_INVALID_HANDLE) {
- pfc_log_error("ODBCM::DBVarbind::bind_logical_memberport_table_output"
- "logical_memberport_table bind parameter error");
- /**in case of error while binding return to application caller with the
- * error code */
- return ODBCM_RC_PARAM_BIND_ERROR;
+ if ((*i).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
}
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
/**binding structure buffer member for controller name output,
* column size is ODBCM_SIZE_32,
* Data type CHAR[32],
* and buffer size will passed as length of value,
* ptr to indicates available no. of bytes return */
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- CTR_NAME/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/,
- p_logical_memberport_table->szController_name/*buffer to fetch values*/,
- ODBCM_SIZE_32+1,
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/,
+ p_logical_memberport_table->szController_name
+ /*buffer to fetch values*/,
+ ODBCM_SIZE_32+1,
/**no.of bytes available to return*/
- reinterpret_cast<SQLLEN*>(&indptr));
+ reinterpret_cast<SQLLEN*>(&indptr));
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- DOMAIN_NAME/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/,
- p_logical_memberport_table->szDomain_name/*buffer to fetch values*/,
- ODBCM_SIZE_32+1,
+ log_flag = 0;
+ }
+ break;
+ case DOMAIN_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/,
+ p_logical_memberport_table->szDomain_name
+ /*buffer to fetch values*/,
+ ODBCM_SIZE_32+1,
/**no.of bytes available to return*/
- reinterpret_cast<SQLLEN*>(&indptr));
+ reinterpret_cast<SQLLEN*>(&indptr));
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_320,
- LMP_LP_PORT_ID/*attribute name MACRO*/) {
+ log_flag = 0;
+ }
+ break;
+ case LMP_LP_PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_320) {
/**binding structure buffer member for portid output,
* column size is ODBCM_SIZE_320,
* Data type CHAR[320],
* and buffer size will passed as length of value,
* ptr to indicates available no. of bytes return,
* Binary type values will be converted and stored into char buffer */
- odbc_rc = BindCol_SQL_BINARY(
- r_hstmt,
- ++col_no,
- p_logical_memberport_table->szlogical_port_id,
- sizeof(p_logical_memberport_table->szlogical_port_id)-1,
- p_logicalport_id1_len/*buffer to fetch values*/);
+ odbc_rc = BindCol_SQL_BINARY(
+ r_hstmt,
+ ++col_no,
+ p_logical_memberport_table->szlogical_port_id,
+ sizeof(p_logical_memberport_table->szlogical_port_id)-1,
+ p_logicalport_id1_len/*buffer to fetch values*/);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- SWITCH_ID/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_BINARY(
- r_hstmt,
- ++col_no,
- p_logical_memberport_table->szswitch_id,
- sizeof(p_logical_memberport_table->szswitch_id)-1,
- p_switch_id1_len/*buffer to fetch values*/);
+ log_flag = 0;
+ }
+ break;
+ case LMP_SWITCH_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ odbc_rc = BindCol_SQL_BINARY(
+ r_hstmt,
+ ++col_no,
+ p_logical_memberport_table->szswitch_id,
+ sizeof(p_logical_memberport_table->szswitch_id)-1,
+ p_switch_id1_len/*buffer to fetch values*/);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- LMP_PHYSICAL_PORT_ID /*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(r_hstmt,
- ++col_no,
- p_logical_memberport_table->szphysical_port_id,
- ODBCM_SIZE_32+1,
- reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
+ log_flag = 0;
+ }
+ break;
+ case LMP_PHYSICAL_PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindCol_SQL_VARCHAR(r_hstmt,
+ ++col_no,
+ p_logical_memberport_table->szphysical_port_id,
+ ODBCM_SIZE_32+1,
+ reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
/**set flag value 0 to print column binding details */
- log_flag = 0;
+ log_flag = 0;
+ }
+ break;
+ default:
+ break;
+ }
+ /*In case of bind failure return the parameter bind error */
+ if (odbc_rc == SQL_ERROR || odbc_rc == SQL_INVALID_HANDLE) {
+ pfc_log_error("ODBCM::DBVarbind::bind_logical_memberport_table_output"
+ "logical_memberport_table bind parameter error");
+ /**in case of error while binding return to application caller with the
+ * error code */
+ return ODBCM_RC_PARAM_BIND_ERROR;
}
if (log_flag == 0) {
/**reset flag value 1*/
}
/**
- * @Description : To fill the logical_memberport_table values into structure.
- * @param[in] : std::vector<TableAttrSchema> &column_attr
- * @return : ODBCM_RC_STATUS
+ * @Description : To fill the logicalmemberport_table values into structure.
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::fill_logical_memberport_table(
std::vector<TableAttrSchema> &column_attr
- /*DBTableSchema->rowlist_ entry*/) {
+ /*DBTableSchema->rowlist_entry*/) {
/**Vector iterator to take the TableAttrSchema structures*/
std::vector< TableAttrSchema >::iterator i;
/**Loop for iterate all the elements in the vector, the TableAttrSchema
* table_attribute_name value will be compared and corresponding
* structure member will be filled*/
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- CTR_NAME/*attribute name MACRO*/) {
+ if ((*i).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
+ }
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
/**ColumnAttrValue is a template to receive the void* values from
* caller and typecast it into appropriate data type,
* for controller_name CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> cn_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
- ((*i).p_table_attribute_value));
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> cn_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ ((*i).p_table_attribute_value));
/**clear the allocated buffer memory to receive the controller_name
* from caller*/
- ODBCM_MEMSET(p_logical_memberport_table->szController_name, 0,
- ODBCM_SIZE_32+1);
+ ODBCM_MEMSET(p_logical_memberport_table->szController_name, 0,
+ ODBCM_SIZE_32+1);
/**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_logical_memberport_table->szController_name,
- &cn_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICAL_MEMBERPORT_TABLE: "
- "szController_name = %s",
- p_logical_memberport_table->szController_name);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- DOMAIN_NAME/*attribute name MACRO*/) {
+ ODBCM_MEMCPY(
+ p_logical_memberport_table->szController_name,
+ &cn_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICAL_MEMBERPORT_TABLE: "
+ "szController_name = %s",
+ p_logical_memberport_table->szController_name);
+ }
+ break;
+ case DOMAIN_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
/**ColumnAttrValue is a template to receive the void* values from
* caller and typecast it into appropriate data type,
* for domain_name CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> dn_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
- ((*i).p_table_attribute_value));
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> dn_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ ((*i).p_table_attribute_value));
/**clear the allocated buffer memory to receive the domain_name
* from caller*/
- ODBCM_MEMSET(p_logical_memberport_table->szDomain_name, 0,
- ODBCM_SIZE_32+1);
+ ODBCM_MEMSET(p_logical_memberport_table->szDomain_name, 0,
+ ODBCM_SIZE_32+1);
/**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_logical_memberport_table->szDomain_name,
- &dn_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICAL_MEMBERPORT_TABLE: "
- "szdomain_name = %s", p_logical_memberport_table->szDomain_name);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_320,
- LMP_LP_PORT_ID/*attribute name MACRO*/) {
+ ODBCM_MEMCPY(
+ p_logical_memberport_table->szDomain_name,
+ &dn_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICAL_MEMBERPORT_TABLE: "
+ "szdomain_name = %s", p_logical_memberport_table->szDomain_name);
+ }
+ break;
+ case LMP_LP_PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_320) {
/**ColumnAttrValue is a template to receive the void* values from
* caller and typecast it into appropriate data type,
* for port_id CHAR[320]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_320]> port_id_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_320]>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_logical_memberport_table->szlogical_port_id, 0,
- ODBCM_SIZE_320+1);
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_320]> port_id_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_320]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_logical_memberport_table->szlogical_port_id, 0,
+ ODBCM_SIZE_320+1);
/**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_logical_memberport_table->szlogical_port_id,
- &port_id_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICAL_MEMBERPORT_TABLE: "
- "szlogical_port_id = %s",
- p_logical_memberport_table->szlogical_port_id);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- SWITCH_ID/*attribute name MACRO*/) {
+ ODBCM_MEMCPY(
+ p_logical_memberport_table->szlogical_port_id,
+ &port_id_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICAL_MEMBERPORT_TABLE: "
+ "szlogical_port_id = %s",
+ p_logical_memberport_table->szlogical_port_id);
+ }
+ break;
+ case LMP_SWITCH_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
/**ColumnAttrValue is a template to receive the void* values from
* caller and typecast it into appropriate data type,
* for switch_id CHAR[256]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_256]> sid_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_256]>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_logical_memberport_table->szswitch_id, 0,
- ODBCM_SIZE_256+1);
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_256]> sid_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_256]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_logical_memberport_table->szswitch_id, 0,
+ ODBCM_SIZE_256+1);
/**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_logical_memberport_table->szswitch_id,
- &sid_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICAL_MEMBERPORT_TABLE: "
- "szswitch_id = %s",
- p_logical_memberport_table->szswitch_id);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- LMP_PHYSICAL_PORT_ID/*attribute name MACRO*/) {
+ ODBCM_MEMCPY(
+ p_logical_memberport_table->szswitch_id,
+ &sid_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICAL_MEMBERPORT_TABLE: "
+ "szswitch_id = %s",
+ p_logical_memberport_table->szswitch_id);
+ }
+ break;
+ case LMP_PHYSICAL_PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
/**ColumnAttrValue is a template to receive the void* values from
* caller and typecast it into appropriate data type,
* for physical_port_id CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> pid_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_logical_memberport_table->szphysical_port_id, 0,
- ODBCM_SIZE_32+1);
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> pid_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_logical_memberport_table->szphysical_port_id, 0,
+ ODBCM_SIZE_32+1);
/**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_logical_memberport_table->szphysical_port_id,
- &pid_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICAL_MEMBERPORT_TABLE:"
- "szphysical_port_id = %s",
- p_logical_memberport_table->szphysical_port_id);
+ ODBCM_MEMCPY(
+ p_logical_memberport_table->szphysical_port_id,
+ &pid_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICAL_MEMBERPORT_TABLE:"
+ "szphysical_port_id = %s",
+ p_logical_memberport_table->szphysical_port_id);
+ }
+ break;
+ default:
+ break;
}
}
/*return the final status to caller*/
return ODBCM_RC_SUCCESS;
}
-
/**
- * @Description : To fetch the logical_memberport_table values
- * (which are stored in binded buffer) and store into TableAttSchema
- * @param[in] : vector<TableAttrSchema> &column_attr
- * @return : ODBCM_RC_STATUS
+ * @Description : To fetch the logicalmemberport_table values
+ * (which are stored in binded buffer) and
+ * store into TableAttSchema
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::fetch_logical_memberport_table(
std::vector<TableAttrSchema> &column_attr
- /*DBTableSchema->rowlist_ entry*/) {
+ /*DBTableSchema->rowlist_entry*/) {
/**Vector iterator to take the TableAttrSchema structures*/
std::vector< TableAttrSchema >::iterator i;
/**Loop for iterate all the elements in the vector, the TableAttrSchema
* table_attribute_name value will be compared and corresponding
* structure member will be fetched */
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
- ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- CTR_NAME/*attribute name MACRO*/) {
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
/**ColumnAttrValue is a template to send the fetched values to
* caller. typecast it into void*, memory will be allocated
* for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_32+1],
- val_controller_name);
- ODBCM_MEMCPY(
- val_controller_name->value,
- p_logical_memberport_table->szController_name,
- sizeof(p_logical_memberport_table->szController_name));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICAL_MEMBERPORT_TABLE: "
- "controller_name = %s" , val_controller_name->value);
- (*i).p_table_attribute_value = val_controller_name;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- DOMAIN_NAME/*attribute name MACRO*/) {
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_32+1],
+ val_controller_name);
+ ODBCM_MEMCPY(
+ val_controller_name->value,
+ p_logical_memberport_table->szController_name,
+ sizeof(p_logical_memberport_table->szController_name));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICAL_MEMBERPORT_TABLE: "
+ "controller_name = %s" , val_controller_name->value);
+ (*i).p_table_attribute_value = val_controller_name;
+ }
+ break;
+ case DOMAIN_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
/**ColumnAttrValue is a template to send the fetched values to
* caller. typecast it into void*, memory will be allocated
* for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_32+1],
- val_domain_name);
- ODBCM_MEMCPY(
- val_domain_name->value,
- p_logical_memberport_table->szDomain_name,
- sizeof(p_logical_memberport_table->szDomain_name));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICAL_MEMBERPORT_TABLE: "
- "szdomain_name = %s" , val_domain_name->value);
- (*i).p_table_attribute_value =val_domain_name;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_320,
- LMP_LP_PORT_ID/*attribute name MACRO*/) {
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_32+1],
+ val_domain_name);
+ ODBCM_MEMCPY(
+ val_domain_name->value,
+ p_logical_memberport_table->szDomain_name,
+ sizeof(p_logical_memberport_table->szDomain_name));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICAL_MEMBERPORT_TABLE: "
+ "szdomain_name = %s" , val_domain_name->value);
+ (*i).p_table_attribute_value =val_domain_name;
+ }
+ break;
+ case LMP_LP_PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_320) {
/**ColumnAttrValue is a template to send the fetched values to
* caller. typecast it into void*, memory will be allocated
* for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_320+1],
- val_port_id);
- ODBCM_MEMCPY(
- val_port_id->value,
- p_logical_memberport_table->szlogical_port_id,
- *p_logicalport_id1_len);
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICAL_MEMBERPORT_TABLE: "
- "port_id = %s" , val_port_id->value);
- (*i).p_table_attribute_value = val_port_id;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- LP_SWITCH_ID/*attribute name MACRO*/) {
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_320+1],
+ val_port_id);
+ ODBCM_MEMCPY(
+ val_port_id->value,
+ p_logical_memberport_table->szlogical_port_id,
+ *p_logicalport_id1_len);
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICAL_MEMBERPORT_TABLE: "
+ "port_id = %s" , val_port_id->value);
+ (*i).p_table_attribute_value = val_port_id;
+ }
+ break;
+ case LMP_SWITCH_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
/**ColumnAttrValue is a template to send the fetched values to
* caller. typecast it into void*, memory will be allocated
* for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_256+1],
- val_switch_id);
- ODBCM_MEMCPY(
- val_switch_id->value,
- p_logical_memberport_table->szswitch_id,
- *p_switch_id1_len);
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICAL_MEMBERPORT_TABLE: "
- "switch_id = %s" , val_switch_id->value);
- (*i).p_table_attribute_value = val_switch_id;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- LP_PHYSICAL_PORT_ID/*attribute name MACRO*/) {
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_256+1],
+ val_switch_id);
+ ODBCM_MEMCPY(
+ val_switch_id->value,
+ p_logical_memberport_table->szswitch_id,
+ *p_switch_id1_len);
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICAL_MEMBERPORT_TABLE: "
+ "switch_id = %s" , val_switch_id->value);
+ (*i).p_table_attribute_value = val_switch_id;
+ }
+ break;
+ case LMP_PHYSICAL_PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
/**ColumnAttrValue is a template to send the fetched values to
* caller. typecast it into void*, memory will be allocated
* for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_32+1],
- val_physical_port_id);
- ODBCM_MEMCPY(
- val_physical_port_id->value,
- &p_logical_memberport_table->szphysical_port_id,
- sizeof(p_logical_memberport_table->szphysical_port_id));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICAL_MEMBERPORT_TABLE: "
- "physical_port_id = %s" , val_physical_port_id->value);
- (*i).p_table_attribute_value = val_physical_port_id;
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_32+1],
+ val_physical_port_id);
+ ODBCM_MEMCPY(
+ val_physical_port_id->value,
+ &p_logical_memberport_table->szphysical_port_id,
+ sizeof(p_logical_memberport_table->szphysical_port_id));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICAL_MEMBERPORT_TABLE: "
+ "physical_port_id = %s" , val_physical_port_id->value);
+ (*i).p_table_attribute_value = val_physical_port_id;
+ }
+ break;
+ default:
+ break;
}
}
return ODBCM_RC_SUCCESS;
#include "odbcm_common.hh"
#include "odbcm_utils.hh"
#include "odbcm_db_tableschema.hh"
+#include "odbcm_mgr.hh"
using unc::uppl::DBVarbind;
/**
- * @Description : function to bind input param of logicalport_table
- * +1 is added where ever the char array is used to store '\0'.
- * @param[in] : vector<TableAttrSchema> &column_attr, HSTMT &r_hstmt
- * @return : ODBCM_RC_STATUS
+ * @Description : Function to bind input parameter of logicalport_table
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * r_hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::bind_logicalport_table_input(
- std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_ entry*/,
+ std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_entry*/,
HSTMT &r_hstmt/**statement handler which carries the SQL Query*/) {
SQLRETURN odbc_rc = SQL_SUCCESS; // odbc API's return code initialize with 0
* structure member will be binded here*/
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
- /*In case of bind failure return the parameter bind error */
+ if ((*i).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
+ }
+
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**binding structure buffer member for controller name input,
+ * column size is ODBCM_SIZE_32,
+ * Data type CHAR[32],
+ * and buffer size will passed as length of value */
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt/**sql statement handler*/,
+ ++col_no /*parameter number (sequential order)*/,
+ ODBCM_SIZE_32/*column size in DB table*/,
+ 0/**decimal point */,
+ p_logicalport_table->szController_name /*buffer to carry values*/,
+ sizeof(p_logicalport_table->szController_name)-1/**buffer length*/,
+ NULL/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case DOMAIN_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**binding structure buffer member for domain name input,
+ * column size is ODBCM_SIZE_32,
+ * Data type CHAR[32],
+ * and buffer size will passed as length of value */
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt/**sql statement handler*/,
+ ++col_no /*parameter number (sequential order)*/,
+ ODBCM_SIZE_32/*column size in DB table*/,
+ 0/**decimal point */,
+ p_logicalport_table->szdomain_name /*buffer to carry values*/,
+ sizeof(p_logicalport_table->szdomain_name)-1/**buffer length*/,
+ NULL/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LP_PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_320) {
+ /**binding structure buffer member for port_id input,
+ * column size is ODBCM_SIZE_320,
+ * Data type CHAR[320], this char data will be converted into
+ * binary before store into database table. switch_id may have non
+ * printable characters as well, To allow non printable character
+ * from 0-320, the binary is chose*/
+ *p_logicalport_id1_len =
+ strlen((const char*)p_logicalport_table->szport_id);
+ odbc_rc = BindInputParameter_SQL_BINARY(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/,
+ ODBCM_SIZE_320/*column size in DB table*/,
+ 0/**decimal point */,
+ p_logicalport_table->szport_id/*buffer to carry values*/,
+ sizeof(p_logicalport_table->szport_id)-1,
+ p_logicalport_id1_len /**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LP_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_128,
+ 0,
+ p_logicalport_table->szdescription,
+ sizeof(p_logicalport_table->szdescription)-1,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LP_PORT_TYPE:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindInputParameter_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ reinterpret_cast<SQLSMALLINT*>(&p_logicalport_table->sport_type),
+ 0,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LP_SWITCH_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ *p_switch_id1_len = strlen((const char*)p_logicalport_table-> \
+ szswitch_id);
+ odbc_rc = BindInputParameter_SQL_BINARY(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_256,
+ 0,
+ p_logicalport_table->szswitch_id,
+ sizeof(p_logicalport_table->szswitch_id)-1,
+ p_switch_id1_len);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LP_PHYSICAL_PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_32,
+ 0,
+ p_logicalport_table->szphysical_port_id,
+ sizeof(p_logicalport_table->szphysical_port_id)-1,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LP_OPER_DOWN_CRITERIA:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindInputParameter_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ reinterpret_cast<SQLSMALLINT*>
+ (&p_logicalport_table->soper_down_criteria),
+ 0,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LP_OPER_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindInputParameter_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ reinterpret_cast<SQLSMALLINT*>
+ (&p_logicalport_table->soper_status),
+ 0,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LP_CTR_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_6) {
+ odbc_rc = BindInputParameter_SQL_CHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_6,
+ 0,
+ p_logicalport_table->svalid,
+ sizeof(p_logicalport_table->svalid)-1,
+ NULL);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ default:
+ break;
+ }
+ /*In case of bind failure return the parameter bind error */
if (odbc_rc == SQL_ERROR||odbc_rc == SQL_INVALID_HANDLE) {
pfc_log_error("ODBCM::DBVarbind::logicalport_common_table"
"bind parameter error ");
* error code */
return ODBCM_RC_PARAM_BIND_ERROR;
}
-
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- CTR_NAME /*attribute name MACRO*/) {
- /**binding structure buffer member for controller name input,
- * column size is ODBCM_SIZE_32,
- * Data type CHAR[32],
- * and buffer size will passed as length of value */
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt/**sql statement handler*/,
- ++col_no /*parameter number (sequential order)*/,
- ODBCM_SIZE_32/*column size in DB table*/,
- 0/**decimal point */,
- p_logicalport_table->szController_name /*buffer to carry values*/,
- sizeof(p_logicalport_table->szController_name)-1/**buffer length*/,
- NULL/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- DOMAIN_NAME /*attribute name MACRO*/) {
- /**binding structure buffer member for domain name input,
- * column size is ODBCM_SIZE_32,
- * Data type CHAR[32],
- * and buffer size will passed as length of value */
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt/**sql statement handler*/,
- ++col_no /*parameter number (sequential order)*/,
- ODBCM_SIZE_32/*column size in DB table*/,
- 0/**decimal point */,
- p_logicalport_table->szdomain_name /*buffer to carry values*/,
- sizeof(p_logicalport_table->szdomain_name)-1/**buffer length*/,
- NULL/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_320/**data type char(320)*/,
- LP_PORT_ID/*attribute name MACRO*/) {
- /**binding structure buffer member for port_id input,
- * column size is ODBCM_SIZE_320,
- * Data type CHAR[320], this char data will be converted into
- * binary before store into database table. switch_id may have non
- * printable characters as well, To allow non printable character
- * from 0-320, the binary is chose*/
- *p_logicalport_id1_len =
- strlen((const char*)p_logicalport_table->szport_id);
- odbc_rc = BindInputParameter_SQL_BINARY(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/,
- ODBCM_SIZE_320/*column size in DB table*/,
- 0/**decimal point */,
- p_logicalport_table->szport_id/*buffer to carry values*/,
- sizeof(p_logicalport_table->szport_id)-1,
- p_logicalport_id1_len /**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128/**data type char(128)*/,
- LP_DESCRIPTION/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_128,
- 0,
- p_logicalport_table->szdescription,
- sizeof(p_logicalport_table->szdescription)-1,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16/**data type char(16)*/,
- LP_PORT_TYPE/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- reinterpret_cast<SQLSMALLINT*>(&p_logicalport_table->sport_type),
- 0,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256/**data type char(256)*/,
- LP_SWITCH_ID/*attribute name MACRO*/) {
- *p_switch_id1_len = strlen((const char*)p_logicalport_table->szswitch_id);
- odbc_rc = BindInputParameter_SQL_BINARY(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_256,
- 0,
- p_logicalport_table->szswitch_id,
- sizeof(p_logicalport_table->szswitch_id)-1,
- p_switch_id1_len);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- LP_PHYSICAL_PORT_ID/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_32,
- 0,
- p_logicalport_table->szphysical_port_id,
- sizeof(p_logicalport_table->szphysical_port_id)-1,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16/**data type char(16)*/,
- LP_OPER_DOWN_CRITERIA/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- reinterpret_cast<SQLSMALLINT*>
- (&p_logicalport_table->soper_down_criteria),
- 0,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16/**data type char(16)*/,
- LP_OPER_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- reinterpret_cast<SQLSMALLINT*>(&p_logicalport_table->soper_status),
- 0,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_6/**data type char(6)*/,
- LP_CTR_VALID/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_CHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_6,
- 0,
- p_logicalport_table->svalid,
- sizeof(p_logicalport_table->svalid)-1,
- NULL);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- }
if ((*i).p_table_attribute_value != NULL && log_flag == 0) {
if (odbc_rc != SQL_SUCCESS)
ODBCMUtils::OdbcmHandleDiagnosticsPrint(SQL_HANDLE_STMT, r_hstmt);
/**reset flag value 1 */
log_flag = 1;
} else {
- pfc_log_info("ODBCM::**NO bind**i/p:LOGICALPORT_TABLE:%s:datatype=%d:"
- , ((*i).table_attribute_name).c_str(),
- (*i).request_attribute_type);
+ pfc_log_debug("ODBCM::DBVarbind::No bind i/p:LOGICALPORT_TABLE:%s:"
+ "datatype=%d:", ODBCManager::get_ODBCManager()-> \
+ GetColumnName((*i).table_attribute_name).c_str(),
+ (*i).request_attribute_type);
}
} // for loop
return ODBCM_RC_SUCCESS;
/**
* @Description : Output binding function for logicalport_table
- * +1 is added where ever the char array is used to store '\0'.
- * @param[in] : vector<TableAttrSchema> &column_attr, HSTMT &r_hstmt
- * @return : ODBCM_RC_STATUS
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * r_hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::bind_logicalport_table_output(
- std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_ entry*/,
+ std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_entry*/,
HSTMT &r_hstmt/**statement handler which carries the SQL Query*/) {
SQLRETURN odbc_rc = SQL_SUCCESS; // odbc APIs return code
uint16_t col_no = 0; // column number
* table_attribute_name value will be compared and corresponding
* structure member will be binded here*/
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
- /*In case of bind failure return the parameter bind error */
- if (odbc_rc == SQL_ERROR || odbc_rc == SQL_INVALID_HANDLE) {
- pfc_log_error("ODBCM::DBVarbind::bind_logicalport_table_output"
- "logicalport_table bind parameter error");
- /**in case of error while binding return to application caller with the
- * error code */
- return ODBCM_RC_PARAM_BIND_ERROR;
- }
/**binding structure buffer member for controller name output,
* column size is ODBCM_SIZE_32,
* Data type CHAR[32],
* and buffer size will passed as length of value,
* ptr to indicates available no. of bytes return */
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- CTR_NAME/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
+ if ((*i).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
+ }
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindCol_SQL_VARCHAR(
r_hstmt/**sql statement handler*/,
++col_no/*parameter number (sequential order)*/,
p_logicalport_table->szController_name/*buffer to fetch values*/,
ODBCM_SIZE_32+1,
/**no.of bytes available to return*/
reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- DOMAIN_NAME/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case DOMAIN_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindCol_SQL_VARCHAR(
r_hstmt/**sql statement handler*/,
++col_no/*parameter number (sequential order)*/,
p_logicalport_table->szdomain_name/*buffer to fetch values*/,
ODBCM_SIZE_32+1,
/**no.of bytes available to return*/
reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_320,
- LP_PORT_ID/*attribute name MACRO*/) {
- /**binding structure buffer member for controller name output,
- * column size is ODBCM_SIZE_320,
- * Data type CHAR[320],
- * and buffer size will passed as length of value,
- * ptr to indicates available no. of bytes return,
- * Binary type values will be converted and stored into char buffer */
- odbc_rc = BindCol_SQL_BINARY(
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LP_PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_320) {
+ /**binding structure buffer member for controller name output,
+ * column size is ODBCM_SIZE_320,
+ * Data type CHAR[320],
+ * and buffer size will passed as length of value,
+ * ptr to indicates available no. of bytes return,
+ * Binary type values will be converted and stored into char buffer */
+ odbc_rc = BindCol_SQL_BINARY(
r_hstmt,
++col_no,
p_logicalport_table->szport_id,
p_logicalport_id1_len/*buffer to fetch values*/);
/**set flag value 0 to print column binding details */
log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128,
- LP_DESCRIPTION/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
+ }
+ break;
+ case LP_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ odbc_rc = BindCol_SQL_VARCHAR(
r_hstmt,
++col_no,
p_logicalport_table->szdescription,
ODBCM_SIZE_128+1,
reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- LP_PORT_TYPE/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_SMALLINT(r_hstmt,
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LP_PORT_TYPE:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindCol_SQL_SMALLINT(r_hstmt,
++col_no,
reinterpret_cast<SQLSMALLINT*>(&p_logicalport_table->sport_type),
sizeof(SQLSMALLINT),
reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- LP_SWITCH_ID/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_BINARY(
+ log_flag = 0;
+ }
+ break;
+ case LP_SWITCH_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ odbc_rc = BindCol_SQL_BINARY(
r_hstmt,
++col_no,
p_logicalport_table->szswitch_id,
sizeof(p_logicalport_table->szswitch_id)-1,
p_switch_id1_len/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- LP_PHYSICAL_PORT_ID /*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(r_hstmt,
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LP_PHYSICAL_PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindCol_SQL_VARCHAR(r_hstmt,
++col_no,
p_logicalport_table->szphysical_port_id,
ODBCM_SIZE_32+1,
reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
/**set flag value 0 to print column binding details */
log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- LP_OPER_DOWN_CRITERIA/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_SMALLINT(r_hstmt,
+ }
+ break;
+ case LP_OPER_DOWN_CRITERIA:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindCol_SQL_SMALLINT(r_hstmt,
++col_no,
reinterpret_cast<SQLSMALLINT*>
(&p_logicalport_table->soper_down_criteria),
sizeof(SQLSMALLINT),
reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- LP_OPER_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_SMALLINT(r_hstmt,
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LP_OPER_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindCol_SQL_SMALLINT(r_hstmt,
++col_no,
reinterpret_cast<SQLSMALLINT*>(&p_logicalport_table->soper_status),
sizeof(SQLSMALLINT),
reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_6,
- LP_CTR_VALID/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(r_hstmt,
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case LP_CTR_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_6) {
+ odbc_rc = BindCol_SQL_VARCHAR(r_hstmt,
++col_no,
p_logicalport_table->svalid,
ODBCM_SIZE_6+1,
reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ default:
+ break;
+ }
+ /*In case of bind failure return the parameter bind error */
+ if (odbc_rc == SQL_ERROR || odbc_rc == SQL_INVALID_HANDLE) {
+ pfc_log_error("ODBCM::DBVarbind::bind_logicalport_table_output"
+ "logicalport_table bind parameter error");
+ /**in case of error while binding return to application caller with the
+ * error code */
+ return ODBCM_RC_PARAM_BIND_ERROR;
}
if (log_flag == 0) {
/**reset flag value 1*/
}
/**
* @Description : To fill the logicalport_table values into structure.
- * @param[in] : std::vector<TableAttrSchema> &column_attr
- * @return : ODBCM_RC_STATUS
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::fill_logicalport_table(
std::vector<TableAttrSchema> &column_attr
- /*DBTableSchema->rowlist_ entry*/) {
+ /*DBTableSchema->rowlist_entry*/) {
/**Vector iterator to take the TableAttrSchema structures*/
std::vector< TableAttrSchema >::iterator i;
/**Loop for iterate all the elements in the vector, the TableAttrSchema
* table_attribute_name value will be compared and corresponding
* structure member will be filled*/
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- CTR_NAME/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for controller_name CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> cn_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
- ((*i).p_table_attribute_value));
- /**clear the allocated buffer memory to receive the controller_name
- * from caller*/
- ODBCM_MEMSET(p_logicalport_table->szController_name, 0, ODBCM_SIZE_32+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_logicalport_table->szController_name,
- &cn_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICALPORT_TABLE: "
- "szController_name = %s", p_logicalport_table->szController_name);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- DOMAIN_NAME/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for domain_name CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> dn_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
- ((*i).p_table_attribute_value));
- /**clear the allocated buffer memory to receive the domain_name
- * from caller*/
- ODBCM_MEMSET(p_logicalport_table->szdomain_name, 0, ODBCM_SIZE_32+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_logicalport_table->szdomain_name,
- &dn_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICALPORT_TABLE: "
- "szdomain_name=%s", p_logicalport_table->szdomain_name);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_320,
- LP_PORT_ID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for port_id CHAR[320]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_320]> port_id_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_320]>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_logicalport_table->szport_id, 0, ODBCM_SIZE_320+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_logicalport_table->szport_id,
- &port_id_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICALPORT_TABLE: "
- "szport_id = %s", p_logicalport_table->szport_id);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128,
- LP_DESCRIPTION/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for description CHAR[128]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_128]> desc_value =
- *((ColumnAttrValue <uint8_t[128]>*)((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_logicalport_table->szdescription, 0, ODBCM_SIZE_128+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_logicalport_table->szdescription,
- &desc_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICALPORT_TABLE: "
- "szDescription = %s", p_logicalport_table->szdescription);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- LP_PORT_TYPE/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for port_type uint16_t*/
- ColumnAttrValue <uint16_t> port_type_value =
- *((ColumnAttrValue <uint16_t>*)((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_logicalport_table->sport_type, 0, sizeof(SQLSMALLINT));
- /**copying the value from template to binded buffer */
- p_logicalport_table->sport_type = port_type_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICALPORT_TABLE:sport_type=%d",
- p_logicalport_table->sport_type);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- LP_SWITCH_ID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for switch_id CHAR[256]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_256]> sid_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_256]>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_logicalport_table->szswitch_id, 0, ODBCM_SIZE_256+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_logicalport_table->szswitch_id,
- &sid_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICALPORT_TABLE: "
- "szswitch_id = %s", p_logicalport_table->szswitch_id);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- LP_PHYSICAL_PORT_ID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for physical_port_id CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> pid_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_logicalport_table->szphysical_port_id, 0, ODBCM_SIZE_32+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_logicalport_table->szphysical_port_id,
- &pid_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICALPORT_TABLE:"
- "szphysical_port_id = %s", p_logicalport_table->szphysical_port_id);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- LP_OPER_DOWN_CRITERIA/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for oper_down_criteria uint16_t*/
- ColumnAttrValue <uint16_t> oper_down_criteria_value =
- *((ColumnAttrValue <uint16_t>*)((*i).p_table_attribute_value));
- /**copying the value from template to binded buffer */
- p_logicalport_table->soper_down_criteria =
- oper_down_criteria_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICALPORT_TABLE:"
- "oper_down_criteria =%d",
- p_logicalport_table->soper_down_criteria);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- LP_OPER_STATUS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for oper_status uint16_t*/
- ColumnAttrValue <uint16_t> oper_st_value =
- *((ColumnAttrValue <uint16_t>*)((*i).p_table_attribute_value));
- /**copying the value from template to binded buffer */
- p_logicalport_table->soper_status = oper_st_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICALPORT_TABLE:"
- "soper_status=%d", p_logicalport_table->soper_status);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_6,
- LP_CTR_VALID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for valid CHAR[6]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_6]> valid_value = *((ColumnAttrValue
- <uint8_t[ODBCM_SIZE_6]>*)((*i).p_table_attribute_value));
- /**copying the value from template to binded buffer */
- ODBCM_MEMSET(p_logicalport_table->svalid, 0, ODBCM_SIZE_6+1);
- ODBCM_MEMCPY(p_logicalport_table->svalid, &valid_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICALPORT_TABLE: "
- "sValid = %s", p_logicalport_table->svalid);
+ if ((*i).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
+ }
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for controller_name CHAR[32]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> cn_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ ((*i).p_table_attribute_value));
+ /**clear the allocated buffer memory to receive the controller_name
+ * from caller*/
+ ODBCM_MEMSET(p_logicalport_table->szController_name, 0,
+ ODBCM_SIZE_32+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_logicalport_table->szController_name,
+ &cn_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICALPORT_TABLE: "
+ "szController_name = %s", p_logicalport_table->szController_name);
+ }
+ break;
+ case DOMAIN_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for domain_name CHAR[32]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> dn_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ ((*i).p_table_attribute_value));
+ /**clear the allocated buffer memory to receive the domain_name
+ * from caller*/
+ ODBCM_MEMSET(p_logicalport_table->szdomain_name, 0, ODBCM_SIZE_32+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_logicalport_table->szdomain_name,
+ &dn_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICALPORT_TABLE: "
+ "szdomain_name=%s", p_logicalport_table->szdomain_name);
+ }
+ break;
+ case LP_PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_320) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for port_id CHAR[320]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_320]> port_id_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_320]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_logicalport_table->szport_id, 0, ODBCM_SIZE_320+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_logicalport_table->szport_id,
+ &port_id_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICALPORT_TABLE: "
+ "szport_id = %s", p_logicalport_table->szport_id);
+ }
+ break;
+ case LP_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for description CHAR[128]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_128]> desc_value =
+ *((ColumnAttrValue <uint8_t[128]>*)((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_logicalport_table->szdescription, 0, ODBCM_SIZE_128+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_logicalport_table->szdescription,
+ &desc_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICALPORT_TABLE: "
+ "szDescription = %s", p_logicalport_table->szdescription);
+ }
+ break;
+ case LP_PORT_TYPE:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for port_type uint16_t*/
+ ColumnAttrValue <uint16_t> port_type_value =
+ *((ColumnAttrValue <uint16_t>*)((*i).p_table_attribute_value));
+ ODBCM_MEMSET(&p_logicalport_table->sport_type, 0,
+ sizeof(SQLSMALLINT));
+ /**copying the value from template to binded buffer */
+ p_logicalport_table->sport_type = port_type_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICALPORT_TABLE:"
+ "sport_type=%d", p_logicalport_table->sport_type);
+ }
+ break;
+ case LP_SWITCH_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for switch_id CHAR[256]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_256]> sid_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_256]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_logicalport_table->szswitch_id, 0, ODBCM_SIZE_256+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_logicalport_table->szswitch_id,
+ &sid_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICALPORT_TABLE: "
+ "szswitch_id = %s", p_logicalport_table->szswitch_id);
+ }
+ break;
+ case LP_PHYSICAL_PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for physical_port_id CHAR[32]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> pid_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_logicalport_table->szphysical_port_id, 0,
+ ODBCM_SIZE_32+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_logicalport_table->szphysical_port_id,
+ &pid_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICALPORT_TABLE:"
+ "szphysical_port_id = %s",
+ p_logicalport_table->szphysical_port_id);
+ }
+ break;
+ case LP_OPER_DOWN_CRITERIA:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for oper_down_criteria uint16_t*/
+ ColumnAttrValue <uint16_t> oper_down_criteria_value =
+ *((ColumnAttrValue <uint16_t>*)((*i).p_table_attribute_value));
+ /**copying the value from template to binded buffer */
+ p_logicalport_table->soper_down_criteria =
+ oper_down_criteria_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICALPORT_TABLE:"
+ "oper_down_criteria =%d",
+ p_logicalport_table->soper_down_criteria);
+ }
+ break;
+ case LP_OPER_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for oper_status uint16_t*/
+ ColumnAttrValue <uint16_t> oper_st_value =
+ *((ColumnAttrValue <uint16_t>*)((*i).p_table_attribute_value));
+ /**copying the value from template to binded buffer */
+ p_logicalport_table->soper_status = oper_st_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICALPORT_TABLE:"
+ "soper_status=%d", p_logicalport_table->soper_status);
+ }
+ break;
+ case LP_CTR_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_6) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for valid CHAR[6]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_6]> valid_value =
+ *((ColumnAttrValue<uint8_t[ODBCM_SIZE_6]>*)
+ ((*i).p_table_attribute_value));
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMSET(p_logicalport_table->svalid, 0, ODBCM_SIZE_6+1);
+ ODBCM_MEMCPY(p_logicalport_table->svalid, &valid_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:LOGICALPORT_TABLE: "
+ "sValid = %s", p_logicalport_table->svalid);
+ }
+ break;
+ default:
+ break;
}
}
/*return the final status to caller*/
return ODBCM_RC_SUCCESS;
}
-
-
/**
- * @Description : To fetch the logicalport_common_table values
- * (which are stored in binded buffer) and store into TableAttSchema
- * @param[in] : vector<TableAttrSchema> &column_attr
- * @return : ODBCM_RC_STATUS
+ * @Description : To fetch the logicalport_table values
+ * (which are stored in binded buffer) and
+ * store into TableAttSchema
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::fetch_logicalport_table(
std::vector<TableAttrSchema> &column_attr
- /*DBTableSchema->rowlist_ entry*/) {
+ /*DBTableSchema->rowlist_entry*/) {
/**Vector iterator to take the TableAttrSchema structures*/
std::vector< TableAttrSchema >::iterator i;
/**Loop for iterate all the elements in the vector, the TableAttrSchema
* table_attribute_name value will be compared and corresponding
* structure member will be fetched */
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
- ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- CTR_NAME/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_32+1],
- val_controller_name);
- ODBCM_MEMCPY(
- val_controller_name->value,
- p_logicalport_table->szController_name,
- sizeof(p_logicalport_table->szController_name));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICALPORT_TABLE: "
- "controller_name = %s" , val_controller_name->value);
- (*i).p_table_attribute_value = val_controller_name;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- DOMAIN_NAME/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_32+1],
- val_domain_name);
- ODBCM_MEMCPY(
- val_domain_name->value,
- p_logicalport_table->szdomain_name,
- sizeof(p_logicalport_table->szdomain_name));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICALPORT_TABLE: "
- "szdomain_name = %s" , val_domain_name->value);
- (*i).p_table_attribute_value =val_domain_name;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_320,
- LP_PORT_ID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_320+1],
- val_port_id);
- ODBCM_MEMCPY(
- val_port_id->value,
- p_logicalport_table->szport_id,
- *p_logicalport_id1_len);
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICALPORT_TABLE: "
- "port_id = %s" , val_port_id->value);
- (*i).p_table_attribute_value = val_port_id;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128,
- LP_DESCRIPTION/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_128+1],
- desc_value);
- ODBCM_MEMCPY(
- desc_value->value,
- p_logicalport_table->szdescription,
- sizeof(p_logicalport_table->szdescription));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICALPORT_TABLE: "
- "description = %s", desc_value->value);
- (*i).p_table_attribute_value = desc_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- LP_PORT_TYPE/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, port_type_value);
- port_type_value->value = p_logicalport_table->sport_type;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICALPORT_TABLE: "
- "port_type = %d", port_type_value->value);
- (*i).p_table_attribute_value = port_type_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- LP_SWITCH_ID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_256+1],
- val_switch_id);
- ODBCM_MEMCPY(
- val_switch_id->value,
- p_logicalport_table->szswitch_id,
- *p_switch_id1_len);
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICALPORT_TABLE: "
- "switch_id = %s" , val_switch_id->value);
- (*i).p_table_attribute_value = val_switch_id;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- LP_PHYSICAL_PORT_ID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_32+1],
- val_physical_port_id);
- ODBCM_MEMCPY(
- val_physical_port_id->value,
- &p_logicalport_table->szphysical_port_id,
- sizeof(p_logicalport_table->szphysical_port_id));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICALPORT_TABLE: "
- "physical_port_id = %s" , val_physical_port_id->value);
- (*i).p_table_attribute_value = val_physical_port_id;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- LP_OPER_DOWN_CRITERIA/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, oper_down_criteria_value);
- oper_down_criteria_value->value =
- p_logicalport_table->soper_down_criteria;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICALPORT_TABLE: "
- "oper_down_criteria = %d", oper_down_criteria_value->value);
- (*i).p_table_attribute_value = oper_down_criteria_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- LP_OPER_STATUS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, oper_status_value);
- oper_status_value->value = p_logicalport_table->soper_status;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICALPORT_TABLE: "
- "soper_status = %d", oper_status_value->value);
- (*i).p_table_attribute_value = oper_status_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_6,
- LP_CTR_VALID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_6+1], valid_value);
- ODBCM_MEMCPY(
- valid_value->value,
- &p_logicalport_table->svalid,
- sizeof(p_logicalport_table->svalid));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICALPORT_TABLE: "
- "valid = %s", valid_value->value);
- (*i).p_table_attribute_value = valid_value;
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_32+1],
+ val_controller_name);
+ ODBCM_MEMCPY(
+ val_controller_name->value,
+ p_logicalport_table->szController_name,
+ sizeof(p_logicalport_table->szController_name));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICALPORT_TABLE: "
+ "controller_name = %s" , val_controller_name->value);
+ (*i).p_table_attribute_value = val_controller_name;
+ }
+ break;
+ case DOMAIN_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_32+1],
+ val_domain_name);
+ ODBCM_MEMCPY(
+ val_domain_name->value,
+ p_logicalport_table->szdomain_name,
+ sizeof(p_logicalport_table->szdomain_name));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICALPORT_TABLE: "
+ "szdomain_name = %s" , val_domain_name->value);
+ (*i).p_table_attribute_value =val_domain_name;
+ }
+ break;
+ case LP_PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_320) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_320+1],
+ val_port_id);
+ ODBCM_MEMCPY(
+ val_port_id->value,
+ p_logicalport_table->szport_id,
+ *p_logicalport_id1_len);
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICALPORT_TABLE: "
+ "port_id = %s" , val_port_id->value);
+ (*i).p_table_attribute_value = val_port_id;
+ }
+ break;
+ case LP_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_128+1],
+ desc_value);
+ ODBCM_MEMCPY(
+ desc_value->value,
+ p_logicalport_table->szdescription,
+ sizeof(p_logicalport_table->szdescription));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICALPORT_TABLE: "
+ "description = %s", desc_value->value);
+ (*i).p_table_attribute_value = desc_value;
+ }
+ break;
+ case LP_PORT_TYPE:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, port_type_value);
+ port_type_value->value = p_logicalport_table->sport_type;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICALPORT_TABLE: "
+ "port_type = %d", port_type_value->value);
+ (*i).p_table_attribute_value = port_type_value;
+ }
+ break;
+ case LP_SWITCH_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_256+1],
+ val_switch_id);
+ ODBCM_MEMCPY(
+ val_switch_id->value,
+ p_logicalport_table->szswitch_id,
+ *p_switch_id1_len);
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICALPORT_TABLE: "
+ "switch_id = %s" , val_switch_id->value);
+ (*i).p_table_attribute_value = val_switch_id;
+ }
+ break;
+ case LP_PHYSICAL_PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_32+1],
+ val_physical_port_id);
+ ODBCM_MEMCPY(
+ val_physical_port_id->value,
+ &p_logicalport_table->szphysical_port_id,
+ sizeof(p_logicalport_table->szphysical_port_id));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICALPORT_TABLE: "
+ "physical_port_id = %s" , val_physical_port_id->value);
+ (*i).p_table_attribute_value = val_physical_port_id;
+ }
+ break;
+ case LP_OPER_DOWN_CRITERIA:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, oper_down_criteria_value);
+ oper_down_criteria_value->value =
+ p_logicalport_table->soper_down_criteria;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICALPORT_TABLE: "
+ "oper_down_criteria = %d", oper_down_criteria_value->value);
+ (*i).p_table_attribute_value = oper_down_criteria_value;
+ }
+ break;
+ case LP_OPER_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, oper_status_value);
+ oper_status_value->value = p_logicalport_table->soper_status;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICALPORT_TABLE: "
+ "soper_status = %d", oper_status_value->value);
+ (*i).p_table_attribute_value = oper_status_value;
+ }
+ break;
+ case LP_CTR_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_6) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_6+1],
+ valid_value);
+ ODBCM_MEMCPY(
+ valid_value->value,
+ &p_logicalport_table->svalid,
+ sizeof(p_logicalport_table->svalid));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:LOGICALPORT_TABLE: "
+ "valid = %s", valid_value->value);
+ (*i).p_table_attribute_value = valid_value;
+ }
+ break;
+ default:
+ break;
}
}
return ODBCM_RC_SUCCESS;
#include "odbcm_common.hh"
#include "odbcm_utils.hh"
#include "odbcm_db_tableschema.hh"
+#include "odbcm_mgr.hh"
using unc::uppl::DBVarbind;
-
+SQLLEN *p_switch_id1_len = NULL;
+SQLLEN *p_switch_id2_len = NULL;
+SQLLEN *p_logicalport_id1_len = NULL;
+SQLLEN *p_logicalport_id2_len = NULL;
+SQLLEN *p_ipv6_len = NULL;
+SQLLEN *p_alarms_status_len = NULL;
+SQLLEN *p_mac_len = NULL;
+SQLLEN *p_speed_len = NULL;
/**
* @Description : Function to bind input parameter of port_table
- * @param[in] : vector<TableAttrSchema> &column_attr, HSTMT &r_hstmt
- * @return : ODBCM_RC_STATUS
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * r_hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::bind_port_table_input(
- std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_ entry*/,
+ std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_entry*/,
HSTMT &r_hstmt/**statement handler which carries the SQL Query*/) {
SQLRETURN odbc_rc = SQL_SUCCESS; // odbc API's return code initialize with 0
SQLUSMALLINT col_no = 0; // column number
* table_attribute_name value will be compared and corresponding
* structure member will be binded here*/
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
- /*In case of bind failure return the parameter bind error */
- if (odbc_rc == SQL_ERROR||odbc_rc == SQL_INVALID_HANDLE) {
- pfc_log_error("ODBCM::DBVarbind::port_table"
- "bind parameter error");
- /**in case of error while binding return to application caller with the
- * error code */
- return ODBCM_RC_PARAM_BIND_ERROR;
+ if ((*i).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
}
-
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- CTR_NAME/*attribute name MACRO*/) {
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
/**binding structure buffer member for controller name input,
* column size is ODBCM_SIZE_32,
* Data type CHAR[32],
* and buffer size will passed as length of value */
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/,
- ODBCM_SIZE_32/*column size in DB table*/,
- 0/**decimal point */,
- p_port_table->szcontroller_name/*buffer to carry values*/,
- sizeof(p_port_table->szcontroller_name)-1/**buffer length*/,
- NULL/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256/**data type char(256)*/,
- SWITCH_ID/*attribute name MACRO*/) {
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/,
+ ODBCM_SIZE_32/*column size in DB table*/,
+ 0/**decimal point */,
+ p_port_table->szcontroller_name/*buffer to carry values*/,
+ sizeof(p_port_table->szcontroller_name)-1/**buffer length*/,
+ NULL/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
/**binding structure buffer member for switch_id1 input,
* column size is ODBCM_SIZE_256,
* Data type CHAR[256], this char data will be converted into
* binary before store into database table. switch_id may have non
* printable characters as well, To allow non printable character
* from 0-255, the binary is chose*/
- *p_switch_id1_len = strlen((const char*)p_port_table->szswitch_id);
- odbc_rc = BindInputParameter_SQL_BINARY(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/,
- ODBCM_SIZE_256/*column size in DB table*/,
- 0/**decimal point */,
- p_port_table->szswitch_id/*buffer to carry values*/,
- sizeof(p_port_table->szswitch_id)-1/**buffer length*/,
- p_switch_id1_len/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- PORT_ID/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_32,
- 0,
- p_port_table->szport_id,
- sizeof(p_port_table->szport_id)-1,
- NULL);
+ *p_switch_id1_len = strlen((const char*)p_port_table->szswitch_id);
+ odbc_rc = BindInputParameter_SQL_BINARY(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/,
+ ODBCM_SIZE_256/*column size in DB table*/,
+ 0/**decimal point */,
+ p_port_table->szswitch_id/*buffer to carry values*/,
+ sizeof(p_port_table->szswitch_id)-1/**buffer length*/,
+ p_switch_id1_len/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_32,
+ 0,
+ p_port_table->szport_id,
+ sizeof(p_port_table->szport_id)-1,
+ NULL);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT32/**data type char(32)*/,
- PORT_NUMBER/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_BIGINT(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- reinterpret_cast<SQLBIGINT*>(&p_port_table->sport_number),
- 0,
- NULL);
+ log_flag = 0;
+ }
+ break;
+ case PORT_NUMBER:
+ if ((*i).request_attribute_type == DATATYPE_UINT32) {
+ odbc_rc = BindInputParameter_SQL_BIGINT(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ reinterpret_cast<SQLBIGINT*>(&p_port_table->sport_number),
+ 0,
+ NULL);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128/**data type char(128)*/,
- PORT_DESCRIPTION/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_128,
- 0,
- p_port_table->szdescription,
- sizeof(p_port_table->szdescription)-1,
- NULL);
+ log_flag = 0;
+ }
+ break;
+ case PORT_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_128,
+ 0,
+ p_port_table->szdescription,
+ sizeof(p_port_table->szdescription)-1,
+ NULL);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16/**data type char(16)*/,
- PORT_ADMIN_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- reinterpret_cast<SQLSMALLINT*>(&p_port_table->sadmins_status),
- 0,
- NULL);
+ log_flag = 0;
+ }
+ break;
+ case PORT_ADMIN_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindInputParameter_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ reinterpret_cast<SQLSMALLINT*>(&p_port_table->sadmins_status),
+ 0,
+ NULL);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16/**data type char(16)*/,
- PORT_DIRECTION/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- reinterpret_cast<SQLSMALLINT*>(&p_port_table->sdirection),
- 0,
- NULL);
+ log_flag = 0;
+ }
+ break;
+ case PORT_DIRECTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindInputParameter_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ reinterpret_cast<SQLSMALLINT*>(&p_port_table->sdirection),
+ 0,
+ NULL);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16/**data type char(16)*/,
- PORT_TRUNK_ALL_VLAN/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_INTEGER(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- reinterpret_cast<SQLINTEGER*>(&p_port_table->strunk_allowed_vlan),
- 0,
- NULL);
+ log_flag = 0;
+ }
+ break;
+ case PORT_TRUNK_ALL_VLAN:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindInputParameter_SQL_INTEGER(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ reinterpret_cast<SQLINTEGER*>(&p_port_table->strunk_allowed_vlan),
+ 0,
+ NULL);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16/**data type char(16)*/,
- PORT_OPER_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- reinterpret_cast<SQLSMALLINT*>(&p_port_table->soper_status),
- 0,
- NULL);
+ log_flag = 0;
+ }
+ break;
+ case PORT_OPER_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindInputParameter_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ reinterpret_cast<SQLSMALLINT*>(&p_port_table->soper_status),
+ 0,
+ NULL);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_6/**data type char(6)*/,
- PORT_MAC_ADDRESS/*attribute name MACRO*/) {
- *p_mac_len = strlen((const char*)p_port_table->smac_address);
- odbc_rc = BindInputParameter_SQL_BINARY(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_6,
- 0,
- p_port_table->smac_address,
- sizeof(p_port_table->smac_address)-1,
- p_mac_len);
+ log_flag = 0;
+ }
+ break;
+ case PORT_MAC_ADDRESS:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_6) {
+ *p_mac_len = ODBCM_SIZE_6;
+ odbc_rc = BindInputParameter_SQL_BINARY(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_6,
+ 0,
+ p_port_table->smac_address,
+ sizeof(p_port_table->smac_address)-1,
+ p_mac_len);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16/**data type char(16)*/,
- PORT_DUPLEX/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- reinterpret_cast<SQLSMALLINT*>(&p_port_table->sduplex),
- 0,
- NULL);
+ log_flag = 0;
+ }
+ break;
+ case PORT_DUPLEX:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindInputParameter_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ reinterpret_cast<SQLSMALLINT*>(&p_port_table->sduplex),
+ 0,
+ NULL);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT64/**data type char(64)*/,
- PORT_SPEED/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_BINARY(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- &p_port_table->sspeed,
- sizeof(p_port_table->sspeed)-1,
- p_speed_len);
+ log_flag = 0;
+ }
+ break;
+ case PORT_SPEED:
+ if ((*i).request_attribute_type == DATATYPE_UINT64) {
+ odbc_rc = BindInputParameter_SQL_BINARY(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ &p_port_table->sspeed,
+ sizeof(p_port_table->sspeed)-1,
+ p_speed_len);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT64/**data type char(64)*/,
- PORT_ALARM_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_BINARY(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- &p_port_table->salarms_status,
- sizeof(p_port_table->salarms_status),
- p_alarms_status_len);
+ log_flag = 0;
+ }
+ break;
+ case PORT_ALARM_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT64) {
+ odbc_rc = BindInputParameter_SQL_BINARY(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ &p_port_table->salarms_status,
+ sizeof(p_port_table->salarms_status),
+ p_alarms_status_len);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_320/**data type char(320)*/,
- PORT_LOGIC_PORT_ID/*attribute name MACRO*/) {
- *p_logicalport_id1_len =
+ log_flag = 0;
+ }
+ break;
+ case PORT_LOGIC_PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_320) {
+ *p_logicalport_id1_len =
strlen((const char*)p_port_table->slogical_port_id);
- odbc_rc = BindInputParameter_SQL_BINARY(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- p_port_table->slogical_port_id,
- sizeof(p_port_table->slogical_port_id)-1,
- p_logicalport_id1_len);
+ odbc_rc = BindInputParameter_SQL_BINARY(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ p_port_table->slogical_port_id,
+ sizeof(p_port_table->slogical_port_id)-1,
+ p_logicalport_id1_len);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_11/**data type char(11)*/,
- PORT_VALID/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_CHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_11,
- 0,
- p_port_table->svalid,
- sizeof(p_port_table->svalid)-1,
- NULL);
+ log_flag = 0;
+ }
+ break;
+ case PORT_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_11) {
+ odbc_rc = BindInputParameter_SQL_CHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_11,
+ 0,
+ p_port_table->svalid,
+ sizeof(p_port_table->svalid)-1,
+ NULL);
/**set flag value 0 to print column binding details */
- log_flag = 0;
+ log_flag = 0;
+ }
+ break;
+ default:
+ break;
+ }
+ /*In case of bind failure return the parameter bind error */
+ if (odbc_rc == SQL_ERROR||odbc_rc == SQL_INVALID_HANDLE) {
+ pfc_log_error("ODBCM::DBVarbind::port_table"
+ "bind parameter error");
+ /**in case of error while binding return to application caller with the
+ * error code */
+ return ODBCM_RC_PARAM_BIND_ERROR;
}
if ((*i).p_table_attribute_value != NULL && log_flag == 0) {
if (odbc_rc != SQL_SUCCESS || odbc_rc != SQL_SUCCESS_WITH_INFO)
/**reset flag value 1 */
log_flag = 1;
} else {
- pfc_log_info("ODBCM::**NO bind**i/p:PORT_TABLE:%s:datatype=%d:",
- ((*i).table_attribute_name).c_str(),
+ pfc_log_debug("ODBCM::**NO bind**i/p:PORT_TABLE:%s:datatype=%d:",
+ ODBCManager::get_ODBCManager()->GetColumnName(
+ ((*i).table_attribute_name)).c_str(),
(*i).request_attribute_type);
}
} // for loop
/**
* @Description : Output binding function for port_table
- * @param[in] : vector<TableAttrSchema> &column_attr, HSTMT &r_hstmt
- * @return : ODBCM_RC_STATUS
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * r_hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::bind_port_table_output(
std:: vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_ entry*/,
* table_attribute_name value will be compared and corresponding
* structure member will be binded here*/
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
- /*In case of bind failure return the parameter bind error */
- if (odbc_rc == SQL_ERROR||odbc_rc == SQL_INVALID_HANDLE) {
- pfc_log_error("ODBCM::DBVarbind:: port_table_output: "
- "port_table bind parameter error ");
- /**in case of error while binding return to application caller with the
- * error code */
- return ODBCM_RC_PARAM_BIND_ERROR;
+ if ((*i).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
}
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
/**binding structure buffer member for controller name output,
* column size is ODBCM_SIZE_32,
* Data type CHAR[32],
* and buffer size will passed as length of value,
* ptr to indicates available no. of bytes return */
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- CTR_NAME/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/,
- p_port_table->szcontroller_name/*buffer to fetch values*/,
- ODBCM_SIZE_32+1,
- reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/,
+ p_port_table->szcontroller_name/*buffer to fetch values*/,
+ ODBCM_SIZE_32+1,
+ reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- SWITCH_ID/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_BINARY(
- r_hstmt,
- ++col_no,
- p_port_table->szswitch_id,
- ODBCM_SIZE_256,
- p_switch_id1_len/*buffer to fetch values*/);
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ odbc_rc = BindCol_SQL_BINARY(
+ r_hstmt,
+ ++col_no,
+ p_port_table->szswitch_id,
+ ODBCM_SIZE_256,
+ p_switch_id1_len/*buffer to fetch values*/);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- PORT_ID/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- p_port_table->szport_id,
- ODBCM_SIZE_32+1,
- reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
+ log_flag = 0;
+ }
+ break;
+ case PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ p_port_table->szport_id,
+ ODBCM_SIZE_32+1,
+ reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT32,
- PORT_NUMBER/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_BIGINT(
- r_hstmt,
- ++col_no,
- reinterpret_cast<SQLBIGINT*>(&p_port_table->sport_number),
- sizeof(SQLBIGINT),
- reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
+ log_flag = 0;
+ }
+ break;
+ case PORT_NUMBER:
+ if ((*i).request_attribute_type == DATATYPE_UINT32) {
+ odbc_rc = BindCol_SQL_BIGINT(
+ r_hstmt,
+ ++col_no,
+ reinterpret_cast<SQLBIGINT*>(&p_port_table->sport_number),
+ sizeof(SQLBIGINT),
+ reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128,
- PORT_DESCRIPTION/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- p_port_table->szdescription,
- ODBCM_SIZE_128+1,
- reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
+ log_flag = 0;
+ }
+ break;
+ case PORT_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ p_port_table->szdescription,
+ ODBCM_SIZE_128+1,
+ reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- PORT_ADMIN_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- reinterpret_cast<SQLSMALLINT*>(&p_port_table->sadmins_status),
- sizeof(SQLSMALLINT),
- reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
+ log_flag = 0;
+ }
+ break;
+ case PORT_ADMIN_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindCol_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ reinterpret_cast<SQLSMALLINT*>(&p_port_table->sadmins_status),
+ sizeof(SQLSMALLINT),
+ reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- PORT_DIRECTION/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- reinterpret_cast<SQLSMALLINT*>(&p_port_table->sdirection),
- sizeof(SQLSMALLINT),
- reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
+ log_flag = 0;
+ }
+ break;
+ case PORT_DIRECTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindCol_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ reinterpret_cast<SQLSMALLINT*>(&p_port_table->sdirection),
+ sizeof(SQLSMALLINT),
+ reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- PORT_TRUNK_ALL_VLAN/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_INTEGER(
- r_hstmt,
- ++col_no,
- reinterpret_cast<SQLINTEGER*>(&p_port_table->strunk_allowed_vlan),
- sizeof(SQLINTEGER),
- reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
+ log_flag = 0;
+ }
+ break;
+ case PORT_TRUNK_ALL_VLAN:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindCol_SQL_INTEGER(
+ r_hstmt,
+ ++col_no,
+ reinterpret_cast<SQLINTEGER*>(&p_port_table->strunk_allowed_vlan),
+ sizeof(SQLINTEGER),
+ reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- PORT_OPER_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- reinterpret_cast<SQLSMALLINT*>(&p_port_table->soper_status),
- sizeof(SQLSMALLINT),
- reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
+ log_flag = 0;
+ }
+ break;
+ case PORT_OPER_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindCol_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ reinterpret_cast<SQLSMALLINT*>(&p_port_table->soper_status),
+ sizeof(SQLSMALLINT),
+ reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_6,
- PORT_MAC_ADDRESS/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_BINARY(
- r_hstmt,
- ++col_no,
- p_port_table->smac_address,
- ODBCM_SIZE_6,
- p_mac_len/*buffer to fetch values*/);
+ log_flag = 0;
+ }
+ break;
+ case PORT_MAC_ADDRESS:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_6) {
+ odbc_rc = BindCol_SQL_BINARY(
+ r_hstmt,
+ ++col_no,
+ p_port_table->smac_address,
+ ODBCM_SIZE_6,
+ p_mac_len/*buffer to fetch values*/);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- PORT_DUPLEX/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- reinterpret_cast<SQLSMALLINT*>(&p_port_table->sduplex),
- sizeof(SQLSMALLINT),
- reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
+ log_flag = 0;
+ }
+ break;
+ case PORT_DUPLEX:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindCol_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ reinterpret_cast<SQLSMALLINT*>(&p_port_table->sduplex),
+ sizeof(SQLSMALLINT),
+ reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT64,
- PORT_SPEED/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_BINARY(
- r_hstmt,
- ++col_no,
- &p_port_table->sspeed,
- sizeof(p_port_table->sspeed),
- p_speed_len/*buffer to fetch values*/);
+ log_flag = 0;
+ }
+ break;
+ case PORT_SPEED:
+ if ((*i).request_attribute_type == DATATYPE_UINT64) {
+ odbc_rc = BindCol_SQL_BINARY(
+ r_hstmt,
+ ++col_no,
+ &p_port_table->sspeed,
+ sizeof(p_port_table->sspeed),
+ p_speed_len/*buffer to fetch values*/);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT64,
- PORT_ALARM_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_BINARY(
- r_hstmt,
- ++col_no,
- &p_port_table->salarms_status,
- sizeof(p_port_table->salarms_status),
- p_alarms_status_len/*buffer to fetch values*/);
+ log_flag = 0;
+ }
+ break;
+ case PORT_ALARM_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT64) {
+ odbc_rc = BindCol_SQL_BINARY(
+ r_hstmt,
+ ++col_no,
+ &p_port_table->salarms_status,
+ sizeof(p_port_table->salarms_status),
+ p_alarms_status_len/*buffer to fetch values*/);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_320,
- PORT_LOGIC_PORT_ID/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_BINARY(
- r_hstmt,
- ++col_no,
- p_port_table->slogical_port_id,
- sizeof(p_port_table->slogical_port_id)-1,
- p_logicalport_id1_len/*buffer to fetch values*/);
+ log_flag = 0;
+ }
+ break;
+ case PORT_LOGIC_PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_320) {
+ odbc_rc = BindCol_SQL_BINARY(
+ r_hstmt,
+ ++col_no,
+ p_port_table->slogical_port_id,
+ sizeof(p_port_table->slogical_port_id)-1,
+ p_logicalport_id1_len/*buffer to fetch values*/);
/**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_11,
- PORT_VALID/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- p_port_table->svalid,
- ODBCM_SIZE_11+1,
- reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
+ log_flag = 0;
+ }
+ break;
+ case PORT_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_11) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ p_port_table->svalid,
+ ODBCM_SIZE_11+1,
+ reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
/**set flag value 0 to print column binding details */
- log_flag = 0;
+ log_flag = 0;
+ }
+ break;
+ default:
+ break;
+ }
+ /*In case of bind failure return the parameter bind error */
+ if (odbc_rc == SQL_ERROR||odbc_rc == SQL_INVALID_HANDLE) {
+ pfc_log_error("ODBCM::DBVarbind:: port_table_output: "
+ "port_table bind parameter error ");
+ /**in case of error while binding return to application caller with the
+ * error code */
+ return ODBCM_RC_PARAM_BIND_ERROR;
}
if (log_flag == 0) {
/**reset flag value 1*/
}
/**
- * @Description : To fill the port_table values into structure
- * @param[in] : std::vector<TableAttrSchema> &column_attr
- * @return : ODBCM_RC_STATUS
+ * @Description : To fill the port_table values into structure.
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::fill_port_table(
std::vector<TableAttrSchema> &column_attr
- /*DBTableSchema->rowlist_ entry*/) {
+ /*DBTableSchema->rowlist_entry*/) {
/**Vector iterator to take the TableAttrSchema structures*/
std::vector< TableAttrSchema >::iterator i;
/**Loop for iterate all the elements in the vector, the TableAttrSchema
* table_attribute_name value will be compared and corresponding
* structure member will be filled*/
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- CTR_NAME/*attribute name MACRO*/) {
+ if ((*i).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
+ }
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
/**ColumnAttrValue is a template to receive the void* values from
* caller and typecast it into appropriate data type,
* for controller name CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> cn_value;
- cn_value = *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
- ((*i).p_table_attribute_value));
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> cn_value;
+ cn_value = *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ ((*i).p_table_attribute_value));
/**clear the allocated buffer memory to receive the controller_name
* from caller*/
- ODBCM_MEMSET(p_port_table->szcontroller_name, 0, ODBCM_SIZE_32+1);
+ ODBCM_MEMSET(p_port_table->szcontroller_name, 0, ODBCM_SIZE_32+1);
/**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_port_table->szcontroller_name,
- &cn_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
- "szcontroller_name = %s", p_port_table->szcontroller_name);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- SWITCH_ID/*attribute name MACRO*/) {
+ ODBCM_MEMCPY(
+ p_port_table->szcontroller_name,
+ &cn_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
+ "szcontroller_name = %s", p_port_table->szcontroller_name);
+ }
+ break;
+ case SWITCH_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
/**ColumnAttrValue is a template to receive the void* values from
* caller and typecast it into appropriate data type,
* for switch id CHAR[256]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_256]> switchid_value;
- switchid_value = *((ColumnAttrValue <uint8_t[ODBCM_SIZE_256]>*)
- ((*i).p_table_attribute_value));
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_256]> switchid_value;
+ switchid_value = *((ColumnAttrValue <uint8_t[ODBCM_SIZE_256]>*)
+ ((*i).p_table_attribute_value));
/**clear the allocated buffer memory to receive the controller_name
* from caller*/
- ODBCM_MEMSET(p_port_table->szswitch_id, 0, ODBCM_SIZE_256+1);
+ ODBCM_MEMSET(p_port_table->szswitch_id, 0, ODBCM_SIZE_256+1);
/**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_port_table->szswitch_id,
- &switchid_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
- "szswitch_id = %s", p_port_table->szswitch_id);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- PORT_ID/*attribute name MACRO*/) {
+ ODBCM_MEMCPY(
+ p_port_table->szswitch_id,
+ &switchid_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
+ "szswitch_id = %s", p_port_table->szswitch_id);
+ }
+ break;
+ case PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
/**ColumnAttrValue is a template to receive the void* values from
* caller and typecast it into appropriate data type,
* for port id CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> id_value;
- id_value = *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_port_table->szport_id, 0, ODBCM_SIZE_32+1);
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> id_value;
+ id_value = *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_port_table->szport_id, 0, ODBCM_SIZE_32+1);
/**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_port_table->szport_id,
- &id_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
- "szport_id = %s", p_port_table->szport_id);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT32,
- PORT_NUMBER/*attribute name MACRO*/) {
+ ODBCM_MEMCPY(
+ p_port_table->szport_id,
+ &id_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
+ "szport_id = %s", p_port_table->szport_id);
+ }
+ break;
+ case PORT_NUMBER:
+ if ((*i).request_attribute_type == DATATYPE_UINT32) {
/**ColumnAttrValue is a template to receive the void* values from
* caller and typecast it into appropriate data type,
* for port number CHAR[32]*/
- ColumnAttrValue <uint32_t> pn_value =
- *((ColumnAttrValue <uint32_t>*)((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_port_table->sport_number, 0, sizeof(SQLBIGINT));
- p_port_table->sport_number = pn_value.value;
- odbcm_debug_info(
- "ODBCM::DBVarbind::fill:PORT_TABLE:sport_number=%"PFC_PFMT_d64,
- p_port_table->sport_number);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128,
- PORT_DESCRIPTION/*attribute name MACRO*/) {
+ ColumnAttrValue <uint32_t> pn_value =
+ *((ColumnAttrValue <uint32_t>*)((*i).p_table_attribute_value));
+ ODBCM_MEMSET(&p_port_table->sport_number, 0, sizeof(SQLBIGINT));
+ p_port_table->sport_number = pn_value.value;
+ odbcm_debug_info(
+ "ODBCM::DBVarbind::fill:PORT_TABLE:sport_number=%"PFC_PFMT_d64,
+ p_port_table->sport_number);
+ }
+ break;
+ case PORT_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
/**ColumnAttrValue is a template to receive the void* values from
* caller and typecast it into appropriate data type,
* for description CHAR[128]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_128]> desc_value =
- *((ColumnAttrValue <uint8_t[128]>*)((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_port_table->szdescription, 0, ODBCM_SIZE_128+1);
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_128]> desc_value =
+ *((ColumnAttrValue <uint8_t[128]>*)((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_port_table->szdescription, 0, ODBCM_SIZE_128+1);
/**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_port_table->szdescription,
- &desc_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE: "
- "szDescription = %s", p_port_table->szdescription);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- PORT_ADMIN_STATUS/*attribute name MACRO*/) {
+ ODBCM_MEMCPY(
+ p_port_table->szdescription,
+ &desc_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE: "
+ "szDescription = %s", p_port_table->szdescription);
+ }
+ break;
+ case PORT_ADMIN_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
/**ColumnAttrValue is a template to receive the void* values from
* caller and typecast it into appropriate data type,
* for admin status CHAR[16]*/
- ColumnAttrValue <uint16_t> admin_value;
- admin_value =
- *((ColumnAttrValue <uint16_t>*)((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_port_table->sadmins_status, 0,
- sizeof(p_port_table->sadmins_status));
- p_port_table->sadmins_status = admin_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
- "sadmins_status = %d", p_port_table->sadmins_status);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- PORT_DIRECTION/*attribute name MACRO*/) {
+ ColumnAttrValue <uint16_t> admin_value;
+ admin_value =
+ *((ColumnAttrValue <uint16_t>*)((*i).p_table_attribute_value));
+ ODBCM_MEMSET(&p_port_table->sadmins_status, 0,
+ sizeof(p_port_table->sadmins_status));
+ p_port_table->sadmins_status = admin_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
+ "sadmins_status = %d", p_port_table->sadmins_status);
+ }
+ break;
+ case PORT_DIRECTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
/**ColumnAttrValue is a template to receive the void* values from
* caller and typecast it into appropriate data type,
* for direction CHAR[16]*/
- ColumnAttrValue <uint16_t> port_direction_value;
- port_direction_value = *((ColumnAttrValue <uint16_t>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_port_table->sdirection, 0,
- sizeof(p_port_table->sdirection));
- p_port_table->sdirection = port_direction_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
- "sdirection = %d", p_port_table->sdirection);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- PORT_TRUNK_ALL_VLAN/*attribute name MACRO*/) {
+ ColumnAttrValue <uint16_t> port_direction_value;
+ port_direction_value = *((ColumnAttrValue <uint16_t>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(&p_port_table->sdirection, 0,
+ sizeof(p_port_table->sdirection));
+ p_port_table->sdirection = port_direction_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
+ "sdirection = %d", p_port_table->sdirection);
+ }
+ break;
+ case PORT_TRUNK_ALL_VLAN:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
/**ColumnAttrValue is a template to receive the void* values from
* caller and typecast it into appropriate data type,
* for trunk allowed vlan CHAR[16]*/
- ColumnAttrValue <uint16_t> trunk_allowed_vlan_value;
- trunk_allowed_vlan_value = *((ColumnAttrValue <uint16_t>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_port_table->strunk_allowed_vlan, 0,
- sizeof(p_port_table->strunk_allowed_vlan));
- p_port_table->strunk_allowed_vlan = trunk_allowed_vlan_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
- "strunk_allowed_vlan = %d",
- static_cast<int> (p_port_table->strunk_allowed_vlan));
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- PORT_OPER_STATUS/*attribute name MACRO*/) {
+ ColumnAttrValue <uint16_t> trunk_allowed_vlan_value;
+ trunk_allowed_vlan_value = *((ColumnAttrValue <uint16_t>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(&p_port_table->strunk_allowed_vlan, 0,
+ sizeof(p_port_table->strunk_allowed_vlan));
+ p_port_table->strunk_allowed_vlan = trunk_allowed_vlan_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
+ "strunk_allowed_vlan = %d",
+ static_cast<int> (p_port_table->strunk_allowed_vlan));
+ }
+ break;
+ case PORT_OPER_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
/**ColumnAttrValue is a template to receive the void* values from
* caller and typecast it into appropriate data type,
* for oper status CHAR[16]*/
- ColumnAttrValue <uint16_t> oper_value;
- oper_value =
- *((ColumnAttrValue <uint16_t>*)((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_port_table->soper_status, 0,
- sizeof(p_port_table->soper_status));
- p_port_table->soper_status = oper_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
- "soper_status = %d", p_port_table->soper_status);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_6,
- PORT_MAC_ADDRESS/*attribute name MACRO*/) {
+ ColumnAttrValue <uint16_t> oper_value;
+ oper_value =
+ *((ColumnAttrValue <uint16_t>*)((*i).p_table_attribute_value));
+ ODBCM_MEMSET(&p_port_table->soper_status, 0,
+ sizeof(p_port_table->soper_status));
+ p_port_table->soper_status = oper_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
+ "soper_status = %d", p_port_table->soper_status);
+ }
+ break;
+ case PORT_MAC_ADDRESS:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_6) {
/**ColumnAttrValue is a template to receive the void* values from
* caller and typecast it into appropriate data type,
* for mac address CHAR[6]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_6]> ma_value;
- ma_value = *((ColumnAttrValue <uint8_t[ODBCM_SIZE_6]>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_port_table->smac_address, 0, ODBCM_SIZE_6+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_port_table->smac_address,
- &ma_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
- "smac_address = %s", p_port_table->smac_address);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- PORT_DUPLEX/*attribute name MACRO*/) {
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_6]> ma_value;
+ ma_value = *((ColumnAttrValue <uint8_t[ODBCM_SIZE_6]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_port_table->smac_address, 0, ODBCM_SIZE_6+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_port_table->smac_address,
+ &ma_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
+ "smac_address = %02x:%02x:%02x:%02x:%02x:%02x ",
+ p_port_table->smac_address[0], p_port_table->smac_address[1],
+ p_port_table->smac_address[2], p_port_table->smac_address[3],
+ p_port_table->smac_address[4], p_port_table->smac_address[5]);
+ }
+ break;
+ case PORT_DUPLEX:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
/**ColumnAttrValue is a template to receive the void* values from
* caller and typecast it into appropriate data type,
* for duplex CHAR[16]*/
- ColumnAttrValue <uint16_t> duplex_value;
- duplex_value = *((ColumnAttrValue <uint16_t>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_port_table->sduplex, 0,
- sizeof(p_port_table->sduplex));
- p_port_table->sduplex = duplex_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
- "sduplex = %d", p_port_table->sduplex);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT64,
- PORT_SPEED/*attribute name MACRO*/) {
+ ColumnAttrValue <uint16_t> duplex_value;
+ duplex_value = *((ColumnAttrValue <uint16_t>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(&p_port_table->sduplex, 0,
+ sizeof(p_port_table->sduplex));
+ p_port_table->sduplex = duplex_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
+ "sduplex = %d", p_port_table->sduplex);
+ }
+ break;
+ case PORT_SPEED:
+ if ((*i).request_attribute_type == DATATYPE_UINT64) {
/**ColumnAttrValue is a template to receive the void* values from
* caller and typecast it into appropriate data type,
* for speed CHAR[64]*/
- ColumnAttrValue <uint64_t> speed_value;
- speed_value = *((ColumnAttrValue <uint64_t>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_port_table->sspeed, 0,
- sizeof(p_port_table->sspeed));
- p_port_table->sspeed = speed_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
- "sspeed = %"PFC_PFMT_d64, p_port_table->sspeed);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT64,
- PORT_ALARM_STATUS/*attribute name MACRO*/) {
+ ColumnAttrValue <uint64_t> speed_value;
+ speed_value = *((ColumnAttrValue <uint64_t>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(&p_port_table->sspeed, 0,
+ sizeof(p_port_table->sspeed));
+ p_port_table->sspeed = speed_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
+ "sspeed = %"PFC_PFMT_d64, p_port_table->sspeed);
+ }
+ break;
+ case PORT_ALARM_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT64) {
/**ColumnAttrValue is a template to receive the void* values from
* caller and typecast it into appropriate data type,
* for alarm status CHAR[64]*/
- ColumnAttrValue <uint64_t> alarm_value;
- alarm_value = *((ColumnAttrValue <uint64_t>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_port_table->salarms_status, 0,
- sizeof(p_port_table->salarms_status));
- p_port_table->salarms_status = alarm_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
- "salarms_status = %" PFC_PFMT_d64, p_port_table->salarms_status);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_320,
- PORT_LOGIC_PORT_ID/*attribute name MACRO*/) {
+ ColumnAttrValue <uint64_t> alarm_value;
+ alarm_value = *((ColumnAttrValue <uint64_t>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(&p_port_table->salarms_status, 0,
+ sizeof(p_port_table->salarms_status));
+ p_port_table->salarms_status = alarm_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
+ "salarms_status = %" PFC_PFMT_d64, p_port_table->salarms_status);
+ }
+ break;
+ case PORT_LOGIC_PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_320) {
/**ColumnAttrValue is a template to receive the void* values from
* caller and typecast it into appropriate data type,
* for logical port id CHAR[320]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_320]> log_id_value;
- log_id_value = *((ColumnAttrValue <uint8_t[ODBCM_SIZE_320]>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_port_table->slogical_port_id, 0, ODBCM_SIZE_320+1);
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_320]> log_id_value;
+ log_id_value = *((ColumnAttrValue <uint8_t[ODBCM_SIZE_320]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_port_table->slogical_port_id, 0, ODBCM_SIZE_320+1);
/**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_port_table->slogical_port_id,
- &log_id_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
- "slogical_port_id = %s", p_port_table->slogical_port_id);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_11,
- PORT_VALID/*attribute name MACRO*/) {
+ ODBCM_MEMCPY(
+ p_port_table->slogical_port_id,
+ &log_id_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
+ "slogical_port_id = %s", p_port_table->slogical_port_id);
+ }
+ break;
+ case PORT_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_11) {
/**ColumnAttrValue is a template to receive the void* values from
* caller and typecast it into appropriate data type,
* for valid CHAR[11]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_11]> valid_val;
- valid_val =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_11]>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_port_table->svalid, 0, ODBCM_SIZE_11+1);
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_11]> valid_val;
+ valid_val =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_11]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_port_table->svalid, 0, ODBCM_SIZE_11+1);
/**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_port_table->svalid,
- &valid_val.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
- "sValid = %s", p_port_table->svalid);
+ ODBCM_MEMCPY(
+ p_port_table->svalid,
+ &valid_val.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:PORT_TABLE:"
+ "sValid = %s", p_port_table->svalid);
+ }
+ break;
+ default:
+ break;
}
}
/*return the final status to caller*/
/**
* @Description : To fetch the port_table values
- * (which are stored in binded buffer) and store into TableAttSchema
- * @param[in] : vector<TableAttrSchema> &column_attr
- * @return : ODBCM_RC_STATUS
+ * (which are stored in binded buffer)
+ * and store into TableAttSchema
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::fetch_port_table(
std::vector<TableAttrSchema> &column_attr
- /*DBTableSchema->rowlist_ entry*/) {
+ /*DBTableSchema->rowlist_entry*/) {
/**Vector iterator to take the TableAttrSchema structures*/
std::vector< TableAttrSchema >::iterator i;
/**Loop for iterate all the elements in the vector, the TableAttrSchema
* table_attribute_name value will be compared and corresponding
* structure member will be fetched */
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
- ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- CTR_NAME/*attribute name MACRO*/) {
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
/**ColumnAttrValue is a template to send the fetched values to
* caller. typecast it into void*, memory will be allocated
* for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_32+1],
- val_controller_name);
- ODBCM_MEMCPY(
- val_controller_name->value,
- p_port_table->szcontroller_name,
- sizeof(p_port_table->szcontroller_name));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
- "szcontroller_name = %s", val_controller_name->value);
- (*i).p_table_attribute_value = val_controller_name;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- SWITCH_ID/*attribute name MACRO*/) {
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_32+1],
+ val_controller_name);
+ ODBCM_MEMCPY(
+ val_controller_name->value,
+ p_port_table->szcontroller_name,
+ sizeof(p_port_table->szcontroller_name));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
+ "szcontroller_name = %s", val_controller_name->value);
+ (*i).p_table_attribute_value = val_controller_name;
+ }
+ break;
+ case SWITCH_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
/**ColumnAttrValue is a template to send the fetched values to
* caller. typecast it into void*, memory will be allocated
* for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_256+1],
- val_switch_id);
- ODBCM_MEMCPY(
- val_switch_id->value,
- p_port_table->szswitch_id,
- *p_switch_id1_len);
- odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
- "szswitch_id = %s", val_switch_id->value);
- (*i).p_table_attribute_value =val_switch_id;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- PORT_ID/*attribute name MACRO*/) {
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_256+1],
+ val_switch_id);
+ ODBCM_MEMCPY(
+ val_switch_id->value,
+ p_port_table->szswitch_id,
+ *p_switch_id1_len);
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
+ "szswitch_id = %s", val_switch_id->value);
+ (*i).p_table_attribute_value =val_switch_id;
+ }
+ break;
+ case PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
/**ColumnAttrValue is a template to send the fetched values to
* caller. typecast it into void*, memory will be allocated
* for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_32+1], val_port_id);
- ODBCM_MEMCPY(
- val_port_id->value,
- p_port_table->szport_id,
- sizeof(p_port_table->szport_id));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
- "szport_id = %s", val_port_id->value);
- (*i).p_table_attribute_value = val_port_id;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT32,
- PORT_NUMBER/*attribute name MACRO*/) {
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_32+1],
+ val_port_id);
+ ODBCM_MEMCPY(
+ val_port_id->value,
+ p_port_table->szport_id,
+ sizeof(p_port_table->szport_id));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
+ "szport_id = %s", val_port_id->value);
+ (*i).p_table_attribute_value = val_port_id;
+ }
+ break;
+ case PORT_NUMBER:
+ if ((*i).request_attribute_type == DATATYPE_UINT32) {
/**ColumnAttrValue is a template to send the fetched values to
* caller. typecast it into void*, memory will be allocated
* for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint32_t, no_value);
- no_value->value = p_port_table->sport_number;
- (*i).p_table_attribute_value = no_value;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: ""port_number = %d",
- no_value->value);
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128,
- PORT_DESCRIPTION/*attribute name MACRO*/) {
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint32_t, no_value);
+ no_value->value = p_port_table->sport_number;
+ (*i).p_table_attribute_value = no_value;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
+ "port_number = %d", no_value->value);
+ }
+ break;
+ case PORT_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
/**ColumnAttrValue is a template to send the fetched values to
* caller. typecast it into void*, memory will be allocated
* for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_128+1],
- val_description);
- ODBCM_MEMCPY(
- val_description->value,
- p_port_table->szdescription,
- sizeof(p_port_table->szdescription));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
- "szdescription = %s", val_description->value);
- (*i).p_table_attribute_value = val_description;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- PORT_ADMIN_STATUS/*attribute name MACRO*/) {
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_128+1],
+ val_description);
+ ODBCM_MEMCPY(
+ val_description->value,
+ p_port_table->szdescription,
+ sizeof(p_port_table->szdescription));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
+ "szdescription = %s", val_description->value);
+ (*i).p_table_attribute_value = val_description;
+ }
+ break;
+ case PORT_ADMIN_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
/**ColumnAttrValue is a template to send the fetched values to
* caller. typecast it into void*, memory will be allocated
* for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, admin_status_value);
- admin_status_value->value = p_port_table->sadmins_status;
- (*i).p_table_attribute_value = admin_status_value;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
- "sadmins_status = %d", admin_status_value->value);
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- PORT_DIRECTION/*attribute name MACRO*/) {
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, admin_status_value);
+ admin_status_value->value = p_port_table->sadmins_status;
+ (*i).p_table_attribute_value = admin_status_value;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
+ "sadmins_status = %d", admin_status_value->value);
+ }
+ break;
+ case PORT_DIRECTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
/**ColumnAttrValue is a template to send the fetched values to
* caller. typecast it into void*, memory will be allocated
* for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, port_direction_value);
- port_direction_value->value = p_port_table->sdirection;
- (*i).p_table_attribute_value = port_direction_value;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
- "sport_direction= %d", port_direction_value->value);
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- PORT_TRUNK_ALL_VLAN/*attribute name MACRO*/) {
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, port_direction_value);
+ port_direction_value->value = p_port_table->sdirection;
+ (*i).p_table_attribute_value = port_direction_value;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
+ "sport_direction= %d", port_direction_value->value);
+ }
+ break;
+ case PORT_TRUNK_ALL_VLAN:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
/**ColumnAttrValue is a template to send the fetched values to
* caller. typecast it into void*, memory will be allocated
* for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, trunk_allowed_vlan_value);
- trunk_allowed_vlan_value->value = p_port_table->strunk_allowed_vlan;
- (*i).p_table_attribute_value = trunk_allowed_vlan_value;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
- "strunk_allowed_vlan= %d", trunk_allowed_vlan_value->value);
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- PORT_OPER_STATUS/*attribute name MACRO*/) {
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, trunk_allowed_vlan_value);
+ trunk_allowed_vlan_value->value = p_port_table->strunk_allowed_vlan;
+ (*i).p_table_attribute_value = trunk_allowed_vlan_value;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
+ "strunk_allowed_vlan= %d", trunk_allowed_vlan_value->value);
+ }
+ break;
+ case PORT_OPER_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
/**ColumnAttrValue is a template to send the fetched values to
* caller. typecast it into void*, memory will be allocated
* for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, oper_status_value);
- oper_status_value->value = p_port_table->soper_status;
- (*i).p_table_attribute_value = oper_status_value;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
- "soper_status = %d", oper_status_value->value);
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_6,
- PORT_MAC_ADDRESS/*attribute name MACRO*/) {
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, oper_status_value);
+ oper_status_value->value = p_port_table->soper_status;
+ (*i).p_table_attribute_value = oper_status_value;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
+ "soper_status = %d", oper_status_value->value);
+ }
+ break;
+ case PORT_MAC_ADDRESS:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_6) {
/**ColumnAttrValue is a template to send the fetched values to
* caller. typecast it into void*, memory will be allocated
* for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_6], val_mac_address);
- ODBCM_MEMCPY(
- val_mac_address->value,
- &p_port_table->smac_address,
- *p_mac_len);
- odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
- "smac_address = %s", val_mac_address->value);
- (*i).p_table_attribute_value = val_mac_address;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- PORT_DUPLEX/*attribute name MACRO*/) {
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_6+1],
+ val_mac_address);
+ ODBCM_MEMCPY(
+ val_mac_address->value,
+ p_port_table->smac_address,
+ sizeof(p_port_table->smac_address));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
+ "smac_address = %02x:%02x:%02x:%02x:%02x:%02x ",
+ p_port_table->smac_address[0], p_port_table->smac_address[1],
+ p_port_table->smac_address[2], p_port_table->smac_address[3],
+ p_port_table->smac_address[4], p_port_table->smac_address[5]);
+ (*i).p_table_attribute_value = val_mac_address;
+ }
+ break;
+ case PORT_DUPLEX:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
/**ColumnAttrValue is a template to send the fetched values to
* caller. typecast it into void*, memory will be allocated
* for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, duplex_value);
- duplex_value->value = p_port_table->sduplex;
- (*i).p_table_attribute_value = duplex_value;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
- "sduplex= %d", duplex_value->value);
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT64,
- PORT_SPEED/*attribute name MACRO*/) {
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, duplex_value);
+ duplex_value->value = p_port_table->sduplex;
+ (*i).p_table_attribute_value = duplex_value;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
+ "sduplex= %d", duplex_value->value);
+ }
+ break;
+ case PORT_SPEED:
+ if ((*i).request_attribute_type == DATATYPE_UINT64) {
/**ColumnAttrValue is a template to send the fetched values to
* caller. typecast it into void*, memory will be allocated
* for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint64_t, speed_value);
- speed_value->value = p_port_table->sspeed;
- (*i).p_table_attribute_value = speed_value;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
- "sspeed= %" PFC_PFMT_u64, speed_value->value);
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT64,
- PORT_ALARM_STATUS/*attribute name MACRO*/) {
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint64_t, speed_value);
+ speed_value->value = p_port_table->sspeed;
+ (*i).p_table_attribute_value = speed_value;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
+ "sspeed= %" PFC_PFMT_u64, speed_value->value);
+ }
+ break;
+ case PORT_ALARM_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT64) {
/**ColumnAttrValue is a template to send the fetched values to
* caller. typecast it into void*, memory will be allocated
* for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint64_t, alarm_value);
- alarm_value->value = p_port_table->salarms_status;
- (*i).p_table_attribute_value = alarm_value;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
- "salarms_status= %" PFC_PFMT_u64, alarm_value->value);
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_320,
- PORT_LOGIC_PORT_ID/*attribute name MACRO*/) {
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint64_t, alarm_value);
+ alarm_value->value = p_port_table->salarms_status;
+ (*i).p_table_attribute_value = alarm_value;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
+ "salarms_status= %" PFC_PFMT_u64, alarm_value->value);
+ }
+ break;
+ case PORT_LOGIC_PORT_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_320) {
/**ColumnAttrValue is a template to send the fetched values to
* caller. typecast it into void*, memory will be allocated
* for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_320], val_log_id);
- ODBCM_MEMCPY(
- val_log_id->value,
- p_port_table->slogical_port_id,
- *p_logicalport_id1_len);
- odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
- "slogical_port_id = %s", val_log_id->value);
- (*i).p_table_attribute_value = val_log_id;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_11,
- PORT_VALID/*attribute name MACRO*/) {
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_320],
+ val_log_id);
+ ODBCM_MEMCPY(
+ val_log_id->value,
+ p_port_table->slogical_port_id,
+ *p_logicalport_id1_len);
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
+ "slogical_port_id = %s", val_log_id->value);
+ (*i).p_table_attribute_value = val_log_id;
+ }
+ break;
+ case PORT_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_11) {
/**ColumnAttrValue is a template to send the fetched values to
* caller. typecast it into void*, memory will be allocated
* for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_11+1],
- valid_value);
- ODBCM_MEMCPY(
- valid_value->value,
- p_port_table->svalid,
- sizeof(p_port_table->svalid));
- (*i).p_table_attribute_value = valid_value;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
- "svalid = %s", valid_value->value);
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint8_t[ODBCM_SIZE_11+1],
+ valid_value);
+ ODBCM_MEMCPY(
+ valid_value->value,
+ p_port_table->svalid,
+ sizeof(p_port_table->svalid));
+ (*i).p_table_attribute_value = valid_value;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:PORT_TABLE: "
+ "svalid = %s", valid_value->value);
+ }
+ break;
+ default:
+ break;
}
}
return ODBCM_RC_SUCCESS;
#include "odbcm_common.hh"
#include "odbcm_utils.hh"
#include "odbcm_db_tableschema.hh"
+#include "odbcm_mgr.hh"
using unc::uppl::DBVarbind;
/**
* @Description : Function to bind input parameter of switch_table
- * @param[in] : vector<TableAttrSchema> &column_attr, HSTMT &r_hstmt
- * @return : ODBCM_RC_STATUS
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * r_hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::bind_switch_table_input(
- std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_ entry*/,
+ std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_entry*/,
HSTMT &r_hstmt/**statement handler which carries the SQL Query*/) {
SQLRETURN odbc_rc = SQL_SUCCESS; // odbc API's return code initialize with 0
* table_attribute_name value will be compared and corresponding
* structure member will be binded here*/
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
+ /**binding structure buffer member for controller name input,
+ * column size is ODBCM_SIZE_32,
+ * Data type CHAR[32],
+ * and buffer size will passed as length of value */
+ if ((*i).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
+ }
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/ ,
+ ODBCM_SIZE_32/*column size in DB table*/,
+ 0/**decimal point */,
+ p_switch_table->szController_name/*buffer to carry values*/,
+ sizeof(p_switch_table->szController_name)-1/**buffer length*/,
+ NULL/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ /**binding structure buffer member for switch_id input,
+ * column size is ODBCM_SIZE_256,
+ * Data type CHAR[256], this char data will be converted into
+ * binary before store into database table. switch_id may have non
+ * printable characters as well, To allow non printable character
+ * from 0-255, the binary is chose*/
+ *p_switch_id1_len = strlen((const char*)p_switch_table->szswitch_id);
+ odbc_rc = BindInputParameter_SQL_BINARY(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/,
+ ODBCM_SIZE_256/*column size in DB table*/,
+ 0/**decimal point */,
+ p_switch_table->szswitch_id/*buffer to carry values*/,
+ sizeof(p_switch_table->szswitch_id)-1,
+ p_switch_id1_len/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ /**binding structure buffer member for description,
+ * column size is ODBCM_SIZE_128,
+ * data type CHAR[128]*/
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no ,
+ ODBCM_SIZE_128,
+ 0,
+ p_switch_table->szdescription,
+ sizeof(p_switch_table->szdescription)-1,
+ NULL/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_MODEL:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_16) {
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no ,
+ ODBCM_SIZE_16,
+ 0,
+ p_switch_table->szmodel,
+ sizeof(p_switch_table->szmodel)-1,
+ NULL/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_IP_ADDRESS:
+ if ((*i).request_attribute_type == DATATYPE_IPV4) {
+ // DATATYPE_UINT32
+ odbc_rc = BindInputParameter_SQL_BIGINT(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ reinterpret_cast<SQLBIGINT*>(&p_switch_table->szip_address),
+ 0,
+ NULL/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_IPV6_ADDRESS:
+ if ((*i).request_attribute_type == DATATYPE_IPV6) {
+ *p_ipv6_len = strlen((const char*)p_switch_table->szipv6_address);
+ odbc_rc = BindInputParameter_SQL_BINARY(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ p_switch_table->szipv6_address,
+ sizeof(p_switch_table->szipv6_address)-1,
+ p_ipv6_len/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_ADMIN_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindInputParameter_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ reinterpret_cast<SQLSMALLINT*>(&p_switch_table->sadmin_status),
+ 0,
+ NULL/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_DOMAIN_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**binding structure buffer member for domainname,
+ * column size is ODBCM_SIZE_32,
+ * data type CHAR[32]*/
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no,
+ ODBCM_SIZE_32,
+ 0,
+ p_switch_table->szdomain_name,
+ sizeof(p_switch_table->szdomain_name)-1,
+ NULL/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_OPER_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindInputParameter_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ reinterpret_cast<SQLSMALLINT*>(&p_switch_table->soper_status),
+ 0,
+ NULL/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_MANUFACTURER:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ /**binding structure buffer member for manufacturer,
+ * column size is ODBCM_SIZE_256,
+ * data type CHAR[256]*/
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no ,
+ ODBCM_SIZE_256,
+ 0,
+ p_switch_table->szmanufacturer/*buffer to carry values*/,
+ sizeof(p_switch_table->szmanufacturer)-1,
+ NULL/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_HARDWARE:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ /**binding structure buffer member for hardware,
+ * column size is ODBCM_SIZE_256,
+ * data type CHAR[256]*/
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no ,
+ ODBCM_SIZE_256,
+ 0,
+ p_switch_table->szhardware/*buffer to carry values*/,
+ sizeof(p_switch_table->szhardware)-1,
+ NULL/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_SOFTWARE:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ /**binding structure buffer member for software,
+ * column size is ODBCM_SIZE_256,
+ * data type CHAR[256]*/
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no ,
+ ODBCM_SIZE_256,
+ 0,
+ p_switch_table->szsoftware/*buffer to carry values*/,
+ sizeof(p_switch_table->szsoftware)-1,
+ NULL/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_ALARM_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT64) {
+ odbc_rc = BindInputParameter_SQL_BINARY(
+ r_hstmt,
+ ++col_no,
+ 0,
+ 0,
+ &p_switch_table->salarms_status/*buffer to carry values*/,
+ sizeof(p_switch_table->salarms_status),
+ p_alarms_status_len/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_11) {
+ odbc_rc = BindInputParameter_SQL_VARCHAR(
+ r_hstmt/**sql statement handler*/,
+ ++col_no ,
+ ODBCM_SIZE_11,
+ 0,
+ p_switch_table->svalid/*buffer to carry values*/,
+ sizeof(p_switch_table->svalid)-1,
+ NULL/**strlen or NULL*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ default:
+ break;
+ }
if (odbc_rc == SQL_ERROR || odbc_rc == SQL_INVALID_HANDLE) {
pfc_log_error("ODBCM::DBVarbind::bind_switch_table_input"
"bind parameter error :: SQL_ERROR or SQL_INVALID_HANDLE");
* error code */
return ODBCM_RC_PARAM_BIND_ERROR;
}
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32 /**data type char(32)*/,
- CTR_NAME/*attribute name MACRO*/) {
- /**binding structure buffer member for controller name input,
- * column size is ODBCM_SIZE_32,
- * Data type CHAR[32],
- * and buffer size will passed as length of value */
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/ ,
- ODBCM_SIZE_32/*column size in DB table*/,
- 0/**decimal point */,
- p_switch_table->szController_name/*buffer to carry values*/,
- sizeof(p_switch_table->szController_name)-1/**buffer length*/,
- NULL/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256/**data type char(256)*/,
- SWITCH_ID/*attribute name MACRO*/) {
- /**binding structure buffer member for switch_id input,
- * column size is ODBCM_SIZE_256,
- * Data type CHAR[256], this char data will be converted into
- * binary before store into database table. switch_id may have non
- * printable characters as well, To allow non printable character
- * from 0-255, the binary is chose*/
- *p_switch_id1_len = strlen((const char*)p_switch_table->szswitch_id);
- odbc_rc = BindInputParameter_SQL_BINARY(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/,
- ODBCM_SIZE_256/*column size in DB table*/,
- 0/**decimal point */,
- p_switch_table->szswitch_id/*buffer to carry values*/,
- sizeof(p_switch_table->szswitch_id)-1,
- p_switch_id1_len/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128/**data type char(128)*/,
- SWITCH_DESCRIPTION/*attribute name MACRO*/) {
- /**binding structure buffer member for description,
- * column size is ODBCM_SIZE_128,
- * data type CHAR[128]*/
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no ,
- ODBCM_SIZE_128,
- 0,
- p_switch_table->szdescription,
- sizeof(p_switch_table->szdescription)-1,
- NULL/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_16,
- SWITCH_MODEL/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no ,
- ODBCM_SIZE_16,
- 0,
- p_switch_table->szmodel,
- sizeof(p_switch_table->szmodel)-1,
- NULL/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- // DATATYPE_UINT32
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_IPV4,
- SWITCH_IP_ADDRESS/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_BIGINT(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- reinterpret_cast<SQLBIGINT*>(&p_switch_table->szip_address),
- 0,
- NULL/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_IPV6,
- SWITCH_IPV6_ADDRESS/*attribute name MACRO*/) {
- *p_ipv6_len = strlen((const char*)p_switch_table->szipv6_address);
- odbc_rc = BindInputParameter_SQL_BINARY(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- p_switch_table->szipv6_address,
- sizeof(p_switch_table->szipv6_address)-1,
- p_ipv6_len/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- SWITCH_ADMIN_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- reinterpret_cast<SQLSMALLINT*>(&p_switch_table->sadmin_status),
- 0,
- NULL/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- SWITCH_DOMAIN_NAME/*attribute name MACRO*/) {
- /**binding structure buffer member for domainname,
- * column size is ODBCM_SIZE_32,
- * data type CHAR[32]*/
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no,
- ODBCM_SIZE_32,
- 0,
- p_switch_table->szdomain_name,
- sizeof(p_switch_table->szdomain_name)-1,
- NULL/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- SWITCH_OPER_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_SMALLINT(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- reinterpret_cast<SQLSMALLINT*>(&p_switch_table->soper_status),
- 0,
- NULL/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256/**data type char(256)*/,
- SWITCH_MANUFACTURER/*attribute name MACRO*/) {
- /**binding structure buffer member for manufacturer,
- * column size is ODBCM_SIZE_256,
- * data type CHAR[256]*/
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no ,
- ODBCM_SIZE_256,
- 0,
- p_switch_table->szmanufacturer/*buffer to carry values*/,
- sizeof(p_switch_table->szmanufacturer)-1,
- NULL/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256/**data type char(256)*/,
- SWITCH_HARDWARE/*attribute name MACRO*/) {
- /**binding structure buffer member for hardware,
- * column size is ODBCM_SIZE_256,
- * data type CHAR[256]*/
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no ,
- ODBCM_SIZE_256,
- 0,
- p_switch_table->szhardware/*buffer to carry values*/,
- sizeof(p_switch_table->szhardware)-1,
- NULL/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256/**data type char(256)*/,
- SWITCH_SOFTWARE/*attribute name MACRO*/) {
- /**binding structure buffer member for software,
- * column size is ODBCM_SIZE_256,
- * data type CHAR[256]*/
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt,
- ++col_no ,
- ODBCM_SIZE_256,
- 0,
- p_switch_table->szsoftware/*buffer to carry values*/,
- sizeof(p_switch_table->szsoftware)-1,
- NULL/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT64/**data type unit64*/,
- SWITCH_ALARM_STATUS/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_BINARY(
- r_hstmt,
- ++col_no,
- 0,
- 0,
- &p_switch_table->salarms_status/*buffer to carry values*/,
- sizeof(p_switch_table->salarms_status),
- p_alarms_status_len/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_11/**data type char(11)*/,
- SWITCH_VALID/*attribute name MACRO*/) {
- odbc_rc = BindInputParameter_SQL_VARCHAR(
- r_hstmt/**sql statement handler*/,
- ++col_no ,
- ODBCM_SIZE_11,
- 0,
- p_switch_table->svalid/*buffer to carry values*/,
- sizeof(p_switch_table->svalid)-1,
- NULL/**strlen or NULL*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- }
-
if ((*i).p_table_attribute_value != NULL && log_flag == 0) {
if (odbc_rc != SQL_SUCCESS)
ODBCMUtils::OdbcmHandleDiagnosticsPrint(SQL_HANDLE_STMT, r_hstmt);
/**reset flag value 1 */
log_flag = 1;
} else {
- pfc_log_info("ODBCM::DBVarbind::**NO bind**i/p:SWITCH_TABLE:%s:"
- "datatype=%d:", ((*i).table_attribute_name).c_str(),
+ pfc_log_debug("ODBCM::DBVarbind::**NO bind**i/p:SWITCH_TABLE:%s:"
+ "datatype=%d:", ODBCManager::get_ODBCManager()->GetColumnName(
+ ((*i).table_attribute_name)).c_str(),
(*i).request_attribute_type);
}
} // for loop
}
/**
* @Description : Output binding function for link_table
- * @param[in] : vector<TableAttrSchema> &column_attr, HSTMT &r_hstmt
- * @return : ODBCM_RC_STATUS
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * r_hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::bind_switch_table_output(
- std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_ entry*/,
+ std::vector<TableAttrSchema> &column_attr/*DBTableSchema->rowlist_entry*/,
HSTMT &r_hstmt/**statement handler which carries the SQL Query*/) {
SQLRETURN odbc_rc = SQL_SUCCESS; // odbc APIs return code
SQLINTEGER indptr = 0; // Pointer to value that indicates the number of
* table_attribute_name value will be compared and corresponding
* structure member will be binded here*/
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
+ /**binding structure buffer member for controller name output,
+ * column size is ODBCM_SIZE_32,
+ * Data type CHAR[32],
+ * and buffer size will passed as length of value,
+ * ptr to indicates available no. of bytes return */
+ if ((*i).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
+ }
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/,
+ p_switch_table->szController_name/*buffer to fetch values*/,
+ ODBCM_SIZE_32+1,
+ /**no.of bytes available to return*/
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ odbc_rc = BindCol_SQL_BINARY(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/,
+ p_switch_table->szswitch_id,
+ sizeof(p_switch_table->szswitch_id)-1,
+ p_switch_id1_len/*buffer to fetch values*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/,
+ p_switch_table->szdescription,
+ ODBCM_SIZE_128+1,
+ reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_MODEL:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_16) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/,
+ p_switch_table->szmodel,
+ ODBCM_SIZE_16+1,
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_IP_ADDRESS:
+ if ((*i).request_attribute_type == DATATYPE_IPV4) {
+ odbc_rc = BindCol_SQL_BIGINT(
+ r_hstmt,
+ ++col_no/*parameter number (sequential order)*/,
+ reinterpret_cast<SQLBIGINT*>(&p_switch_table->szip_address),
+ sizeof(SQLBIGINT),
+ reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_IPV6_ADDRESS:
+ if ((*i).request_attribute_type == DATATYPE_IPV6) {
+ odbc_rc = BindCol_SQL_BINARY(
+ r_hstmt,
+ ++col_no/*parameter number (sequential order)*/,
+ reinterpret_cast<SQLCHAR*>(p_switch_table->szipv6_address),
+ sizeof(p_switch_table->szipv6_address)-1,
+ p_ipv6_len);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_ADMIN_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindCol_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no/*parameter number (sequential order)*/,
+ reinterpret_cast<SQLSMALLINT*>(&p_switch_table->sadmin_status),
+ sizeof(SQLSMALLINT),
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_DOMAIN_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt/**sql statement handler*/,
+ ++col_no/*parameter number (sequential order)*/,
+ p_switch_table->szdomain_name,
+ ODBCM_SIZE_32+1,
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_OPER_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ odbc_rc = BindCol_SQL_SMALLINT(
+ r_hstmt,
+ ++col_no/*parameter number (sequential order)*/,
+ reinterpret_cast<SQLSMALLINT*>(&p_switch_table->soper_status),
+ sizeof(SQLSMALLINT),
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_MANUFACTURER:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ odbc_rc = BindCol_SQL_VARCHAR(
+ r_hstmt,
+ ++col_no/*parameter number (sequential order)*/,
+ p_switch_table->szmanufacturer,
+ ODBCM_SIZE_256+1,
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_HARDWARE:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ odbc_rc = BindCol_SQL_VARCHAR(r_hstmt,
+ ++col_no/*parameter number (sequential order)*/,
+ p_switch_table->szhardware,
+ ODBCM_SIZE_256+1,
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_SOFTWARE:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ odbc_rc = BindCol_SQL_VARCHAR(r_hstmt,
+ ++col_no/*parameter number (sequential order)*/,
+ p_switch_table->szsoftware,
+ ODBCM_SIZE_256+1,
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_ALARM_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT64) {
+ odbc_rc = BindCol_SQL_BINARY(
+ r_hstmt,
+ ++col_no/*parameter number (sequential order)*/,
+ &p_switch_table->salarms_status,
+ sizeof(p_switch_table->salarms_status),
+ p_alarms_status_len);
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ case SWITCH_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_11) {
+ odbc_rc = BindCol_SQL_VARCHAR(r_hstmt,
+ ++col_no/*parameter number (sequential order)*/,
+ p_switch_table->svalid,
+ ODBCM_SIZE_11+1,
+ reinterpret_cast<SQLLEN*>(&indptr));
+ /**set flag value 0 to print column binding details */
+ log_flag = 0;
+ }
+ break;
+ default:
+ break;
+ }
/*In case of bind failure return the parameter bind error */
if (odbc_rc == SQL_ERROR || odbc_rc == SQL_INVALID_HANDLE) {
pfc_log_error("ODBCM::DBVarbind::bind_switch_table_output"
* error code */
return ODBCM_RC_PARAM_BIND_ERROR;
}
- /**binding structure buffer member for controller name output,
- * column size is ODBCM_SIZE_32,
- * Data type CHAR[32],
- * and buffer size will passed as length of value,
- * ptr to indicates available no. of bytes return */
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- CTR_NAME/*attribute name MACRO*/) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/,
- p_switch_table->szController_name/*buffer to fetch values*/,
- ODBCM_SIZE_32+1,
- /**no.of bytes available to return*/
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- SWITCH_ID) {
- odbc_rc = BindCol_SQL_BINARY(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/,
- p_switch_table->szswitch_id,
- sizeof(p_switch_table->szswitch_id)-1,
- p_switch_id1_len/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128,
- SWITCH_DESCRIPTION) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/,
- p_switch_table->szdescription,
- ODBCM_SIZE_128+1,
- reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_16,
- SWITCH_MODEL) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/,
- p_switch_table->szmodel,
- ODBCM_SIZE_16+1,
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_IPV4,
- SWITCH_IP_ADDRESS) {
- odbc_rc = BindCol_SQL_BIGINT(
- r_hstmt,
- ++col_no/*parameter number (sequential order)*/,
- reinterpret_cast<SQLBIGINT*>(&p_switch_table->szip_address),
- sizeof(SQLBIGINT),
- reinterpret_cast<SQLLEN*>(&indptr)/*buffer to fetch values*/);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_IPV6,
- SWITCH_IPV6_ADDRESS) {
- odbc_rc = BindCol_SQL_BINARY(
- r_hstmt,
- ++col_no/*parameter number (sequential order)*/,
- reinterpret_cast<SQLCHAR*>(p_switch_table->szipv6_address),
- sizeof(p_switch_table->szipv6_address)-1,
- p_ipv6_len);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- SWITCH_ADMIN_STATUS) {
- odbc_rc = BindCol_SQL_SMALLINT(
- r_hstmt,
- ++col_no/*parameter number (sequential order)*/,
- reinterpret_cast<SQLSMALLINT*>(&p_switch_table->sadmin_status),
- sizeof(SQLSMALLINT),
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- SWITCH_DOMAIN_NAME) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt/**sql statement handler*/,
- ++col_no/*parameter number (sequential order)*/,
- p_switch_table->szdomain_name,
- ODBCM_SIZE_32+1,
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- SWITCH_OPER_STATUS) {
- odbc_rc = BindCol_SQL_SMALLINT(
- r_hstmt,
- ++col_no/*parameter number (sequential order)*/,
- reinterpret_cast<SQLSMALLINT*>(&p_switch_table->soper_status),
- sizeof(SQLSMALLINT),
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- SWITCH_MANUFACTURER) {
- odbc_rc = BindCol_SQL_VARCHAR(
- r_hstmt,
- ++col_no/*parameter number (sequential order)*/,
- p_switch_table->szmanufacturer,
- ODBCM_SIZE_256+1,
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- SWITCH_HARDWARE) {
- odbc_rc = BindCol_SQL_VARCHAR(r_hstmt,
- ++col_no/*parameter number (sequential order)*/,
- p_switch_table->szhardware,
- ODBCM_SIZE_256+1,
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- SWITCH_SOFTWARE) {
- odbc_rc = BindCol_SQL_VARCHAR(r_hstmt,
- ++col_no/*parameter number (sequential order)*/,
- p_switch_table->szsoftware,
- ODBCM_SIZE_256+1,
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT64,
- SWITCH_ALARM_STATUS) {
- odbc_rc = BindCol_SQL_BINARY(
- r_hstmt,
- ++col_no/*parameter number (sequential order)*/,
- &p_switch_table->salarms_status,
- sizeof(p_switch_table->salarms_status),
- p_alarms_status_len);
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_11,
- SWITCH_VALID) {
- odbc_rc = BindCol_SQL_VARCHAR(r_hstmt,
- ++col_no/*parameter number (sequential order)*/,
- p_switch_table->svalid,
- ODBCM_SIZE_11+1,
- reinterpret_cast<SQLLEN*>(&indptr));
- /**set flag value 0 to print column binding details */
- log_flag = 0;
- }
if (log_flag == 0) {
/**reset flag value 1*/
log_flag = 1;
return ODBCM_RC_SUCCESS;
}
-
-
/**
* @Description : To fill the switch_table values into structure.
- * @param[in] : std::vector<TableAttrSchema> &column_attr
- * @return : ODBCM_RC_STATUS
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::fill_switch_table(
std::vector<TableAttrSchema> &column_attr
- /*DBTableSchema->rowlist_ entry*/) {
+ /*DBTableSchema->rowlist_entry*/) {
/**Vector iterator to take the TableAttrSchema structures*/
std::vector< TableAttrSchema >::iterator i;
/**Loop for iterate all the elements in the vector, the TableAttrSchema
* table_attribute_name value will be compared and corresponding
* structure member will be filled*/
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
- ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- CTR_NAME/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for controller_name CHAR[32]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> cn_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
- ((*i).p_table_attribute_value));
- /**clear the allocated buffer memory to receive the controller_name
- * from caller*/
- ODBCM_MEMSET(p_switch_table->szController_name, 0, ODBCM_SIZE_32+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_switch_table->szController_name,
- &cn_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE: "
- "szController_name=%s", p_switch_table->szController_name);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- SWITCH_ID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for switch id*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_256]> sw_value =
- *((ColumnAttrValue <uint8_t[256]>*)
- ((*i).p_table_attribute_value));
- /**copying the value from template to binded buffer */
- ODBCM_MEMSET(p_switch_table->szswitch_id, 0, ODBCM_SIZE_256+1);
- ODBCM_MEMCPY(
- p_switch_table->szswitch_id,
- &sw_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE: "
- "szswitch_id = %s", p_switch_table->szswitch_id);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128,
- SWITCH_DESCRIPTION/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- */
- ColumnAttrValue <uint8_t[ODBCM_SIZE_128]> desc_value =
- *((ColumnAttrValue <uint8_t[128]>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_switch_table->szdescription, 0, ODBCM_SIZE_128+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_switch_table->szdescription,
- &desc_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE: "
- "szdescription = %s", p_switch_table->szdescription);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_16,
- SWITCH_MODEL/*attribute name MACRO*/) {
- ColumnAttrValue <uint8_t[ODBCM_SIZE_16]> model_value =
- *((ColumnAttrValue <uint8_t[16]>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_switch_table->szmodel, 0, ODBCM_SIZE_16+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_switch_table->szmodel,
- &model_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE: "
- "szmodel= %s", p_switch_table->szmodel);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_IPV4,
- SWITCH_IP_ADDRESS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for ivp4*/
- ColumnAttrValue <uint32_t> ipv4_value =
- *((ColumnAttrValue <uint32_t>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_switch_table->szip_address, 0, sizeof(SQLBIGINT));
- p_switch_table->szip_address = ipv4_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE:szIp_address"
- " = %s", ODBCMUtils::get_ip_string(
- p_switch_table->szip_address).c_str());
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i),
- DATATYPE_IPV6,
- SWITCH_IPV6_ADDRESS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for ipv6 */
- ColumnAttrValue <char[ODBCM_SIZE_16]> *ipv6_value =
- ((ColumnAttrValue<char[ODBCM_SIZE_16]>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_switch_table->szipv6_address, 0, ODBCM_SIZE_16+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_switch_table->szipv6_address,
- &ipv6_value->value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE:szIpv6_address = %s"
- , ODBCMUtils::get_ipv6_string(p_switch_table->szipv6_address).c_str());
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- SWITCH_ADMIN_STATUS) {
- ColumnAttrValue <uint16_t> admin_status_value =
- *((ColumnAttrValue <uint16_t>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_switch_table->sadmin_status, 0, sizeof(SQLSMALLINT));
- p_switch_table->sadmin_status = admin_status_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE:"
- "sadmin_status=%d", p_switch_table->sadmin_status);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- SWITCH_DOMAIN_NAME/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- */
- ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> dn_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ if ((*i).p_table_attribute_value == NULL) {
+ pfc_log_debug("ODBCM::DBVarbind::bind value structure is empty ");
+ continue;
+ }
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for controller_name CHAR[32]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> cn_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ ((*i).p_table_attribute_value));
+ /**clear the allocated buffer memory to receive the controller_name
+ * from caller*/
+ ODBCM_MEMSET(p_switch_table->szController_name, 0, ODBCM_SIZE_32+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_switch_table->szController_name,
+ &cn_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE: "
+ "szController_name=%s", p_switch_table->szController_name);
+ }
+ break;
+ case SWITCH_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for switch id*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_256]> sw_value =
+ *((ColumnAttrValue <uint8_t[256]>*)
+ ((*i).p_table_attribute_value));
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMSET(p_switch_table->szswitch_id, 0, ODBCM_SIZE_256+1);
+ ODBCM_MEMCPY(
+ p_switch_table->szswitch_id,
+ &sw_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE: "
+ "szswitch_id = %s", p_switch_table->szswitch_id);
+ }
+ break;
+ case SWITCH_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ */
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_128]> desc_value =
+ *((ColumnAttrValue <uint8_t[128]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_switch_table->szdescription, 0, ODBCM_SIZE_128+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_switch_table->szdescription,
+ &desc_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE: "
+ "szdescription = %s", p_switch_table->szdescription);
+ }
+ break;
+ case SWITCH_MODEL:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_16) {
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_16]> model_value =
+ *((ColumnAttrValue <uint8_t[16]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_switch_table->szmodel, 0, ODBCM_SIZE_16+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_switch_table->szmodel,
+ &model_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE: "
+ "szmodel= %s", p_switch_table->szmodel);
+ }
+ break;
+ case SWITCH_IP_ADDRESS:
+ if ((*i).request_attribute_type == DATATYPE_IPV4) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for ivp4*/
+ ColumnAttrValue <uint32_t> ipv4_value =
+ *((ColumnAttrValue <uint32_t>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(&p_switch_table->szip_address, 0, sizeof(SQLBIGINT));
+ p_switch_table->szip_address = ipv4_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE:szIp_address"
+ " = %s", ODBCMUtils::get_ip_string(
+ p_switch_table->szip_address).c_str());
+ }
+ break;
+ case SWITCH_IPV6_ADDRESS:
+ if ((*i).request_attribute_type == DATATYPE_IPV6) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for ipv6 */
+ ColumnAttrValue <char[ODBCM_SIZE_16]> *ipv6_value =
+ ((ColumnAttrValue<char[ODBCM_SIZE_16]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_switch_table->szipv6_address, 0, ODBCM_SIZE_16+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_switch_table->szipv6_address,
+ &ipv6_value->value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE:"
+ "szIpv6_address = %s", ODBCMUtils::get_ipv6_string(
+ p_switch_table->szipv6_address).c_str());
+ }
+ break;
+ case SWITCH_ADMIN_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ ColumnAttrValue <uint16_t> admin_status_value =
+ *((ColumnAttrValue <uint16_t>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(&p_switch_table->sadmin_status, 0, sizeof(SQLSMALLINT));
+ p_switch_table->sadmin_status = admin_status_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE:"
+ "sadmin_status=%d", p_switch_table->sadmin_status);
+ }
+ break;
+ case SWITCH_DOMAIN_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ */
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> dn_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_32]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_switch_table->szdomain_name, 0, ODBCM_SIZE_32+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_switch_table->szdomain_name,
+ &dn_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE:"
+ "szdomain_name = %s", p_switch_table->szdomain_name);
+ }
+ break;
+ case SWITCH_OPER_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ */
+ ColumnAttrValue <uint16_t> oper_status_value =
+ *((ColumnAttrValue <uint16_t>*)
((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_switch_table->szdomain_name, 0, ODBCM_SIZE_32+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_switch_table->szdomain_name,
- &dn_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE:"
- "szdomain_name = %s", p_switch_table->szdomain_name);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- SWITCH_OPER_STATUS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- */
- ColumnAttrValue <uint16_t> oper_status_value =
- *((ColumnAttrValue <uint16_t>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_switch_table->soper_status, 0, sizeof(SQLSMALLINT));
- p_switch_table->soper_status = oper_status_value.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE:soper_status=%d",
- p_switch_table->soper_status);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- SWITCH_MANUFACTURER/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for manufacturer CHAR[256]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_256]> manufacturer_value =
- *((ColumnAttrValue <uint8_t[256]>*)((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_switch_table->szmanufacturer, 0, ODBCM_SIZE_256+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_switch_table->szmanufacturer,
- &manufacturer_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE: "
- "szmanufacturer = %s", p_switch_table->szmanufacturer);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- SWITCH_HARDWARE/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for hardware CHAR[256]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_256]> hardware_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_256]>*)
+ ODBCM_MEMSET(&p_switch_table->soper_status, 0, sizeof(SQLSMALLINT));
+ p_switch_table->soper_status = oper_status_value.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE:"
+ "soper_status=%d", p_switch_table->soper_status);
+ }
+ break;
+ case SWITCH_MANUFACTURER:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for manufacturer CHAR[256]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_256]> manufacturer_value =
+ *((ColumnAttrValue <uint8_t[256]>*)
((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_switch_table->szhardware, 0, ODBCM_SIZE_256+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_switch_table->szhardware,
- &hardware_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE: "
- "szhardware = %s", p_switch_table->szhardware);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- SWITCH_SOFTWARE/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for software CHAR[256]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_256]> software_value =
- *((ColumnAttrValue <uint8_t[ODBCM_SIZE_256]>*)
+ ODBCM_MEMSET(p_switch_table->szmanufacturer, 0, ODBCM_SIZE_256+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_switch_table->szmanufacturer,
+ &manufacturer_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE: "
+ "szmanufacturer = %s", p_switch_table->szmanufacturer);
+ }
+ break;
+ case SWITCH_HARDWARE:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for hardware CHAR[256]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_256]> hardware_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_256]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_switch_table->szhardware, 0, ODBCM_SIZE_256+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_switch_table->szhardware,
+ &hardware_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE: "
+ "szhardware = %s", p_switch_table->szhardware);
+ }
+ break;
+ case SWITCH_SOFTWARE:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for software CHAR[256]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_256]> software_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_256]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_switch_table->szsoftware, 0, ODBCM_SIZE_256+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_switch_table->szsoftware,
+ &software_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE: "
+ "szsoftware = %s", p_switch_table->szsoftware);
+ }
+ break;
+ case SWITCH_ALARM_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT64) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for alarm_status uint64_t*/
+ ColumnAttrValue <uint64_t> alarms_status;
+ alarms_status = *((ColumnAttrValue <uint64_t>*)
((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_switch_table->szsoftware, 0, ODBCM_SIZE_256+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_switch_table->szsoftware,
- &software_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE: "
- "szsoftware = %s", p_switch_table->szsoftware);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT64,
- SWITCH_ALARM_STATUS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for alarm_status uint64_t*/
- ColumnAttrValue <uint64_t> alarms_status;
- alarms_status = *((ColumnAttrValue <uint64_t>*)
- ((*i).p_table_attribute_value));
- ODBCM_MEMSET(&p_switch_table->salarms_status, 0,
- sizeof(p_switch_table->salarms_status));
- p_switch_table->salarms_status = alarms_status.value;
- odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE: "
- "salarms_status = %"PFC_PFMT_d64, p_switch_table->salarms_status);
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_11,
- SWITCH_VALID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to receive the void* values from
- * caller and typecast it into appropriate data type,
- * for valid CHAR[11]*/
- ColumnAttrValue <uint8_t[ODBCM_SIZE_11]> valid_value = *((ColumnAttrValue
- <uint8_t[ODBCM_SIZE_11]>*)((*i).p_table_attribute_value));
- ODBCM_MEMSET(p_switch_table->svalid, 0, ODBCM_SIZE_11+1);
- /**copying the value from template to binded buffer */
- ODBCM_MEMCPY(
- p_switch_table->svalid,
- &valid_value.value,
- (*i).table_attribute_length);
- odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE: "
- "sValid = %s", p_switch_table->svalid);
+ ODBCM_MEMSET(&p_switch_table->salarms_status, 0,
+ sizeof(p_switch_table->salarms_status));
+ p_switch_table->salarms_status = alarms_status.value;
+ odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE: "
+ "salarms_status = %"PFC_PFMT_d64, p_switch_table->salarms_status);
+ }
+ break;
+ case SWITCH_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_11) {
+ /**ColumnAttrValue is a template to receive the void* values from
+ * caller and typecast it into appropriate data type,
+ * for valid CHAR[11]*/
+ ColumnAttrValue <uint8_t[ODBCM_SIZE_11]> valid_value =
+ *((ColumnAttrValue <uint8_t[ODBCM_SIZE_11]>*)
+ ((*i).p_table_attribute_value));
+ ODBCM_MEMSET(p_switch_table->svalid, 0, ODBCM_SIZE_11+1);
+ /**copying the value from template to binded buffer */
+ ODBCM_MEMCPY(
+ p_switch_table->svalid,
+ &valid_value.value,
+ (*i).table_attribute_length);
+ odbcm_debug_info("ODBCM::DBVarbind::fill:SWITCH_TABLE: "
+ "sValid = %s", p_switch_table->svalid);
+ }
+ break;
+ default:
+ break;
}
}
/*return the final status to caller*/
}
/**
- * @Description : Function to fetch the switch_common_table
- * values(which is stored in SWITCH_TABLE_ struct )
- * and store into TableAttSchema
- * @param[in] : vector<TableAttrSchema> &column_attr
- * @return : ODBCM_RC_STATUS
+ * @Description : To fetch the switch_table values
+ * (which is stored in SWITCH_TABLE_ struct)
+ * and store into TableAttSchema
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * @return : ODBCM_RC_SUCCESS - All bind operations success
+ * ODBCM_RC_PARAM_BIND_ERROR - Any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::fetch_switch_table(
std::vector<TableAttrSchema> &column_attr
- /*DBTableSchema->rowlist_ entry*/) {
+ /*DBTableSchema->rowlist_entry*/) {
/**Vector iterator to take the TableAttrSchema structures*/
std::vector< TableAttrSchema >::iterator i;
/**Loop for iterate all the elements in the vector, the TableAttrSchema
* table_attribute_name value will be compared and corresponding
* structure member will be fetched */
for (i = column_attr.begin(); i != column_attr.end(); ++i) {
- ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32/**data type char(32)*/,
- CTR_NAME/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_32+1],
- val_controller_name);
- ODBCM_MEMCPY(
- val_controller_name->value,
- p_switch_table->szController_name,
- sizeof(p_switch_table->szController_name));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
- "controller_name = %s" , val_controller_name->value);
- (*i).p_table_attribute_value = val_controller_name;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- SWITCH_ID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_256+1],
- sw_value);
- ODBCM_MEMCPY(
- sw_value->value,
- p_switch_table->szswitch_id,
- *p_switch_id1_len);
- odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
- "switch_id = %s", sw_value->value);
- (*i).p_table_attribute_value = sw_value;
- }
- ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_128,
- SWITCH_DESCRIPTION/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_128+1],
- desc_value);
- ODBCM_MEMCPY(
- desc_value->value,
- p_switch_table->szdescription,
- sizeof(p_switch_table->szdescription));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
- "description = %s", desc_value->value);
- (*i).p_table_attribute_value = desc_value;
- }
- ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_16,
- SWITCH_MODEL/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_16+1],
- model_value);
- ODBCM_MEMCPY(
- model_value->value,
- p_switch_table->szmodel,
- sizeof(p_switch_table->szmodel));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
- "model = %s", model_value->value);
- (*i).p_table_attribute_value = model_value;
- }
- ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_IPV4,
- SWITCH_IP_ADDRESS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint32_t, ip_value);
- ip_value->value = p_switch_table->szip_address;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
- "from db ip_address = %s",
- ODBCMUtils::get_ip_string(p_switch_table->szip_address).c_str());
- odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
- "ip_address = %s",
- ODBCMUtils::get_ip_string(ip_value->value).c_str());
- (*i).p_table_attribute_value = ip_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_IPV6,
- SWITCH_IPV6_ADDRESS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_16+1],
- ipv6_value);
- ODBCM_MEMCPY(
- ipv6_value->value,
- p_switch_table->szipv6_address,
- *p_ipv6_len);
- odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE:szIpv6_address=%s"
- , (ODBCMUtils::get_ipv6_string(
- p_switch_table->szipv6_address)).c_str());
- (*i).p_table_attribute_value = ipv6_value;
- } ODBCM_COMPARE_ATTRNAME_DATATYPE((*i),
- DATATYPE_UINT16,
- SWITCH_ADMIN_STATUS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, admin_status);
- admin_status->value = p_switch_table->sadmin_status;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
- "sadmin_status = %d", admin_status->value);
- (*i).p_table_attribute_value = admin_status;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_32,
- SWITCH_DOMAIN_NAME/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_32+1],
- val_domain_name);
- ODBCM_MEMCPY(
- val_domain_name->value,
- p_switch_table->szdomain_name,
- sizeof(p_switch_table->szdomain_name));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
- "domain_name = %s" , val_domain_name->value);
- (*i).p_table_attribute_value = val_domain_name;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT16,
- SWITCH_OPER_STATUS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, oper_status_value);
- oper_status_value->value = p_switch_table->soper_status;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
- "oper_status = %d", oper_status_value->value);
- (*i).p_table_attribute_value = oper_status_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- SWITCH_MANUFACTURER/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_256+1],
- manufacturer_value);
- ODBCM_MEMCPY(
- manufacturer_value->value,
- p_switch_table->szmanufacturer,
- sizeof(p_switch_table->szmanufacturer));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
- "manufacturer = %s", manufacturer_value->value);
- (*i).p_table_attribute_value = manufacturer_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- SWITCH_HARDWARE/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_256+1],
- hardware_value);
- ODBCM_MEMCPY(
- hardware_value->value,
- p_switch_table->szhardware,
- sizeof(p_switch_table->szhardware));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
- "hardware = %s", hardware_value->value);
- (*i).p_table_attribute_value = hardware_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_256,
- SWITCH_SOFTWARE/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_256+1],
- software_value);
- ODBCM_MEMCPY(
- software_value->value,
- p_switch_table->szsoftware,
- sizeof(p_switch_table->szsoftware));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
- "software = %s", software_value->value);
- (*i).p_table_attribute_value = software_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT64,
- SWITCH_ALARM_STATUS/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint64_t,
- alarms_status_value);
- alarms_status_value->value = p_switch_table->salarms_status;
- odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
- "alarms_status = %" PFC_PFMT_u64, alarms_status_value->value);
- (*i).p_table_attribute_value = alarms_status_value;
- } ODBCM_COMPARE_FETCH_DATA((*i)/**TableAttrSchema structure*/,
- DATATYPE_UINT8_ARRAY_11,
- SWITCH_VALID/*attribute name MACRO*/) {
- /**ColumnAttrValue is a template to send the fetched values to
- * caller. typecast it into void*, memory will be allocated
- * for the template to send to caller*/
- ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
- uint8_t[ODBCM_SIZE_11+1],
- valid_value);
- ODBCM_MEMCPY(
- valid_value->value,
- p_switch_table->svalid,
- sizeof(p_switch_table->svalid));
- odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
- "valid = %s", valid_value->value);
- (*i).p_table_attribute_value = valid_value;
+ switch ((*i).table_attribute_name) {
+ case CTR_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_32+1],
+ val_controller_name);
+ ODBCM_MEMCPY(
+ val_controller_name->value,
+ p_switch_table->szController_name,
+ sizeof(p_switch_table->szController_name));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
+ "controller_name = %s" , val_controller_name->value);
+ (*i).p_table_attribute_value = val_controller_name;
+ }
+ break;
+ case SWITCH_ID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_256+1],
+ sw_value);
+ ODBCM_MEMCPY(
+ sw_value->value,
+ p_switch_table->szswitch_id,
+ *p_switch_id1_len);
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
+ "switch_id = %s", sw_value->value);
+ (*i).p_table_attribute_value = sw_value;
+ }
+ break;
+ case SWITCH_DESCRIPTION:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_128+1],
+ desc_value);
+ ODBCM_MEMCPY(
+ desc_value->value,
+ p_switch_table->szdescription,
+ sizeof(p_switch_table->szdescription));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
+ "description = %s", desc_value->value);
+ (*i).p_table_attribute_value = desc_value;
+ }
+ break;
+ case SWITCH_MODEL:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_16) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_16+1],
+ model_value);
+ ODBCM_MEMCPY(
+ model_value->value,
+ p_switch_table->szmodel,
+ sizeof(p_switch_table->szmodel));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
+ "model = %s", model_value->value);
+ (*i).p_table_attribute_value = model_value;
+ }
+ break;
+ case SWITCH_IP_ADDRESS:
+ if ((*i).request_attribute_type == DATATYPE_IPV4) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint32_t, ip_value);
+ ip_value->value = p_switch_table->szip_address;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
+ "from db ip_address = %s",
+ ODBCMUtils::get_ip_string(p_switch_table->szip_address).c_str());
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
+ "ip_address = %s",
+ ODBCMUtils::get_ip_string(ip_value->value).c_str());
+ (*i).p_table_attribute_value = ip_value;
+ }
+ break;
+ case SWITCH_IPV6_ADDRESS:
+ if ((*i).request_attribute_type == DATATYPE_IPV6) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_16+1],
+ ipv6_value);
+ ODBCM_MEMCPY(
+ ipv6_value->value,
+ p_switch_table->szipv6_address,
+ *p_ipv6_len);
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE:"
+ "szIpv6_address=%s", (ODBCMUtils::get_ipv6_string(
+ p_switch_table->szipv6_address)).c_str());
+ (*i).p_table_attribute_value = ipv6_value;
+ }
+ break;
+ case SWITCH_ADMIN_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, admin_status);
+ admin_status->value = p_switch_table->sadmin_status;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
+ "sadmin_status = %d", admin_status->value);
+ (*i).p_table_attribute_value = admin_status;
+ }
+ break;
+ case SWITCH_DOMAIN_NAME:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_32+1],
+ val_domain_name);
+ ODBCM_MEMCPY(
+ val_domain_name->value,
+ p_switch_table->szdomain_name,
+ sizeof(p_switch_table->szdomain_name));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
+ "domain_name = %s" , val_domain_name->value);
+ (*i).p_table_attribute_value = val_domain_name;
+ }
+ break;
+ case SWITCH_OPER_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT16) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(uint16_t, oper_status_value);
+ oper_status_value->value = p_switch_table->soper_status;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
+ "oper_status = %d", oper_status_value->value);
+ (*i).p_table_attribute_value = oper_status_value;
+ }
+ break;
+ case SWITCH_MANUFACTURER:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_256+1],
+ manufacturer_value);
+ ODBCM_MEMCPY(
+ manufacturer_value->value,
+ p_switch_table->szmanufacturer,
+ sizeof(p_switch_table->szmanufacturer));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
+ "manufacturer = %s", manufacturer_value->value);
+ (*i).p_table_attribute_value = manufacturer_value;
+ }
+ break;
+ case SWITCH_HARDWARE:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_256+1],
+ hardware_value);
+ ODBCM_MEMCPY(
+ hardware_value->value,
+ p_switch_table->szhardware,
+ sizeof(p_switch_table->szhardware));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
+ "hardware = %s", hardware_value->value);
+ (*i).p_table_attribute_value = hardware_value;
+ }
+ break;
+ case SWITCH_SOFTWARE:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_256+1],
+ software_value);
+ ODBCM_MEMCPY(
+ software_value->value,
+ p_switch_table->szsoftware,
+ sizeof(p_switch_table->szsoftware));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
+ "software = %s", software_value->value);
+ (*i).p_table_attribute_value = software_value;
+ }
+ break;
+ case SWITCH_ALARM_STATUS:
+ if ((*i).request_attribute_type == DATATYPE_UINT64) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint64_t,
+ alarms_status_value);
+ alarms_status_value->value = p_switch_table->salarms_status;
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
+ "alarms_status = %" PFC_PFMT_u64, alarms_status_value->value);
+ (*i).p_table_attribute_value = alarms_status_value;
+ }
+ break;
+ case SWITCH_VALID:
+ if ((*i).request_attribute_type == DATATYPE_UINT8_ARRAY_11) {
+ /**ColumnAttrValue is a template to send the fetched values to
+ * caller. typecast it into void*, memory will be allocated
+ * for the template to send to caller*/
+ ODBCM_ALLOCATE_COLUMN_ATTRVALUE_T(
+ uint8_t[ODBCM_SIZE_11+1],
+ valid_value);
+ ODBCM_MEMCPY(
+ valid_value->value,
+ p_switch_table->svalid,
+ sizeof(p_switch_table->svalid));
+ odbcm_debug_info("ODBCM::DBVarbind::fetch:SWITCH_TABLE: "
+ "valid = %s", valid_value->value);
+ (*i).p_table_attribute_value = valid_value;
+ }
+ break;
+ default:
+ break;
}
}
return ODBCM_RC_SUCCESS;
#include "odbcm_query_processor.hh"
#include "odbcm_utils.hh"
#include "physicallayer.hh"
-
+#include "odbcm_connection.hh"
using unc::uppl::ODBCManager;
using unc::uppl::ODBCMTable;
using unc::uppl::QueryFactory;
using unc::uppl::DBVarbind;
extern pfc_cfdef_t odbcm_cfdef;
-/* ODBCManager instance */
-static ODBCManager *ODBCManager_ = NULL;
+/* static variable initialization */
+ODBCManager *ODBCManager::ODBCManager_ = NULL;
/**
* @Description : Constructor function which creates/initializes
* @param[in] : None
* @return : void
**/
-ODBCManager::ODBCManager() {
- pfc_log_info("ODBCM::ODBCManager:: Constructor to initialize the members");
- /** Initialize the ODBCManager members */
- rw_conn_handle_ = NULL, ro_conn_handle_ = NULL, phy_conn_env_ = NULL;
- // initialize the ODBCMInit flag
- IsODBCManager_initialized = 0;
+ODBCManager::ODBCManager()
+:
+ // initialize the ODBCMInit flag
+ IsODBCManager_initialized(0),
+ /** Initialize the ODBCManager members */
+ phy_conn_env_(NULL) {
+ rw_nb_conn_obj_ = NULL;
+ rw_sb_conn_obj_ = NULL;
}
/**
**/
ODBCManager::~ODBCManager() {
pfc_log_info("ODBCM::~ODBCManager: Destructor to free resources");
- /** Close the db connection */
- if (ODBCM_RC_SUCCESS != CloseDBConnection())
- pfc_log_error("ODBCM::~ODBCManager:: Error in CloseDBConnection");
- else
- pfc_log_info("ODBCM::~ODBCManager:: DB connection closed successfully");
-
/** Clear all the vector inside the map */
((get_db_table_list_map_().find(UNC_DT_STARTUP))->second).clear();
((get_db_table_list_map_().find(UNC_DT_CANDIDATE))->second).clear();
db_table_list_map_.clear();
/**to clear the OdbcmSQLStateMap elements*/
ODBCMUtils::ClearOdbcmSQLStateMap();
+ /** Free the uppl db connection and environments */
+ ODBCM_RC_STATUS rw_disconn_status = CloseRwConnection();
+ pfc_log_debug("ODBCM::ODBCManager::CloseRwConnection Status %d",
+ rw_disconn_status);
+ if (NULL != phy_conn_env_) {
+ SQLFreeHandle(SQL_HANDLE_ENV, phy_conn_env_);
+ pfc_log_info("ODBCM::ODBCManager:: Disconnect phy_conn_env_");
+ phy_conn_env_ = NULL;
+ }
}
/**
* @Description : This function will return the ODBC read-write,
- * read-only connection environment and it's a const method.
+ * read-only connection environment and it's a const method.
* @param[in] : None
- * @return : SQLHENV
+ * @return : SQLHENV - It will calls SQLAllocHandle and passes the address
+ * of the variable and the SQL_HANDLE_ENV option.
**/
-inline SQLHENV ODBCManager::get_phy_connenction_env_() const {
+inline SQLHENV ODBCManager::get_phy_connection_env_() const {
return phy_conn_env_;
}
-/**
- * @Description : This function will return the ODBC read-write connection
- * handle and it's a const method.
- * @param[in] : None
- * @return : SQLHDBC
- **/
-inline SQLHDBC ODBCManager::get_rw_connenction_handle_() const {
- return rw_conn_handle_;
-}
-/**
- * @Description : This function will return the ODBC read-only
- * connection handle and it's a const method.
- * @param[in] : None
- * @return : SQLHENV
- **/
-inline SQLHDBC ODBCManager::get_ro_connenction_handle_() const {
- return ro_conn_handle_;
-}
+
/**
* @Description : This static method will return the singleton
- * ODBCManager instance if exists else create new one and return.
+ * ODBCManager instance if exists else create new one and return.
* @param[in] : None
- * @return : ODBCManager*
+ * @return : ODBCManager* - the singleton instance if exists
+ * else create new one and return.
**/
ODBCManager* ODBCManager::get_ODBCManager() {
/*Allocate the memory for ODBCManager only if its NULL*/
/**
* @Description : function to get table list stored in DB
* @param[in] : None
- * @return : db_table_list_map_
+ * @return : db_table_list_map_ - return table list stored in Database
**/
-std::map<int, std::vector<std::string> >
- ODBCManager::get_db_table_list_map_() const {
+std::map<int, std::vector<std::string> >&
+ODBCManager::get_db_table_list_map_() {
return db_table_list_map_;
}
+
+/**
+ * @Description : function to get table columns list in map
+ * @param[in] : None
+ * @return : odbcm_tables_column_map_
+ **/
+std::map<ODBCMTableColumns, std::string>&
+ODBCManager::get_odbcm_tables_column_map_() {
+ return odbcm_tables_column_map_;
+}
+
/**
* @Description : function to set read-write ODBC connection handle
* @param[in] : None
- * @return : ODBCM_RC_STATUS
+ * @return : ODBCM_RC_SUCCESS - read-write ODBC connection handle
+ * is set to success
+ * ODBCM_RC_* - read-write ODBC connection handle failed
**/
-inline ODBCM_RC_STATUS ODBCManager::set_rw_connenction_handle_() {
+inline ODBCM_RC_STATUS ODBCManager::set_rw_connection_handle_(
+ SQLHDBC& rw_conn_handle) {
// 2. allocate rw connection handle
SQLRETURN odbc_rc = SQLAllocHandle(SQL_HANDLE_DBC, phy_conn_env_,
- &rw_conn_handle_);
+ &rw_conn_handle);
ODBCM_DBC_HANDLE_CHECK(phy_conn_env_, odbc_rc);
if (odbc_rc != ODBCM_RC_SUCCESS && odbc_rc != ODBCM_RC_SUCCESS_WITH_INFO) {
- pfc_log_fatal("ODBCM::ODBCManager::set_rw_connenction_handle_:"
+ pfc_log_error("ODBCM::ODBCManager::set_rw_connection_handle_:"
" Error in SQLAllocHandle %s",
ODBCMUtils::get_RC_Details(odbc_rc).c_str());
return (ODBCM_RC_STATUS) odbc_rc;
}
- pfc_log_info("ODBCM::ODBCManager::set_rw_connenction_handle_: Success");
+ pfc_log_info("ODBCM::ODBCManager::set_rw_connection_handle_: Success");
return ODBCM_RC_SUCCESS;
}
/**
* @Description : function to set read ODBC connection handle
* @param[in] : None
- * @return : ODBCM_RC_STATUS
+ * @return : ODBCM_RC_SUCCESS - read ODBC connection handle is set
+ * to success
+ * ODBCM_RC_* - read ODBC connection handle failed
**/
-inline ODBCM_RC_STATUS ODBCManager::set_ro_connenction_handle_() {
+inline ODBCM_RC_STATUS ODBCManager::set_ro_connection_handle_(
+ SQLHDBC& ro_conn_handle) {
// 2. allocate ro connection handle
SQLRETURN odbc_rc = SQLAllocHandle(SQL_HANDLE_DBC, phy_conn_env_,
- &ro_conn_handle_);
+ &ro_conn_handle);
ODBCM_DBC_HANDLE_CHECK(phy_conn_env_, odbc_rc);
if (odbc_rc != ODBCM_RC_SUCCESS && odbc_rc != ODBCM_RC_SUCCESS_WITH_INFO) {
- pfc_log_fatal("ODBCM::ODBCManager::set_ro_connenction_handle_:"
+ pfc_log_error("ODBCM::ODBCManager::set_ro_connection_handle_:"
" Error in SQLAllocHandle %s",
ODBCMUtils::get_RC_Details(odbc_rc).c_str());
return (ODBCM_RC_STATUS) odbc_rc;
}
- pfc_log_info("ODBCM::ODBCManager::set_ro_connenction_handle_: Success");
+ pfc_log_debug("ODBCM::ODBCManager::set_ro_connection_handle_: Success");
return ODBCM_RC_SUCCESS;
}
/**
- * @Description : function to set read-write ODBC connection environment
+ * @Description : function to set physical ODBC connection environment
* @param[in] : None
- * @return : ODBCM_RC_STATUS
+ * @return : ODBCM_RC_SUCCESS - physical ODBC connection handle is set
+ * to success
+ * ODBCM_RC_* - physicall ODBC connection handle failed
**/
-inline ODBCM_RC_STATUS ODBCManager::set_phy_connenction_env_() {
+inline ODBCM_RC_STATUS ODBCManager::set_phy_connection_env_() {
// 1. allocate Environment handle and register version
SQLRETURN odbc_rc = ODBCM_RC_SUCCESS;
odbc_rc = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &phy_conn_env_);
ODBCM_ENV_HANDLE_CHECK(phy_conn_env_, odbc_rc);
if (odbc_rc != ODBCM_RC_SUCCESS && odbc_rc != ODBCM_RC_SUCCESS_WITH_INFO) {
- pfc_log_fatal("ODBCM::ODBCManager::set_phy_connenction_env_: "
+ pfc_log_error("ODBCM::ODBCManager::set_phy_connection_env_: "
"Error in phy_conn_env_ %s",
ODBCMUtils::get_RC_Details(odbc_rc).c_str());
return (ODBCM_RC_STATUS) odbc_rc;
}
- pfc_log_info("ODBCM::ODBCManager::set_phy_connenction_env_: "
- "phy_conn_env_ is allocated");
+ pfc_log_debug("ODBCM::ODBCManager::set_phy_connection_env_: "
+ "phy_conn_env_ is allocated");
odbc_rc = SQLSetEnvAttr(phy_conn_env_, SQL_ATTR_ODBC_VERSION,
reinterpret_cast<void*>(SQL_OV_ODBC3), 0);
ODBCM_ENV_HANDLE_CHECK(phy_conn_env_, odbc_rc);
if (odbc_rc != ODBCM_RC_SUCCESS && odbc_rc != ODBCM_RC_SUCCESS_WITH_INFO) {
- pfc_log_fatal("ODBCM::ODBCManager::set_phy_connenction_env_:"
+ pfc_log_error("ODBCM::ODBCManager::set_phy_connection_env_:"
" Error in SQLSetEnvAttr %s",
ODBCMUtils::get_RC_Details(odbc_rc).c_str());
return (ODBCM_RC_STATUS) odbc_rc;
}
- pfc_log_info("ODBCM::ODBCManager::set_phy_connenction_env_: Success");
+ pfc_log_info("ODBCM::ODBCManager::set_phy_connection_env_: Success");
return ODBCM_RC_SUCCESS;
}
/**
* @Description : Function to initialize the DB table list map
* @param[in] : None
- * @return : ODBCM_RC_STATUS
+ * @return : ODBCM_RC_SUCCESS - initialize database table list map is set
+ * to success
+ * ODBCM_RC_* - initialize failed in database table map
**/
-ODBCM_RC_STATUS ODBCManager::initialize_db_table_list_map_() {
+ODBCM_RC_STATUS ODBCManager::initialize_db_table_list_map_(void) {
uint16_t loop1 = 0; // To loop the tables
vector<string> startup_vector; // To store startup tables
vector<string> candidate_vector; // To store candidate tables
/** Below tables are present in Startup, Candidate, running */
string uppl_tables[ODBCM_MAX_UPPL_TABLES] =
{ UPPL_CTR_TABLE,
- UPPL_CTR_DOMAIN_TABLE,
- UPPL_BOUNDARY_TABLE
+ UPPL_CTR_DOMAIN_TABLE,
+ UPPL_BOUNDARY_TABLE
};
/** Below tables are present only in running to support dt_state */
string state_tables[ODBCM_MAX_STATE_TABLES] =
{ UPPL_LOGICALPORT_TABLE,
- UPPL_LOGICAL_MEMBER_PORT_TABLE,
- UPPL_SWITCH_TABLE,
- UPPL_PORT_TABLE,
- UPPL_LINK_TABLE
+ UPPL_LOGICAL_MEMBER_PORT_TABLE,
+ UPPL_SWITCH_TABLE,
+ UPPL_PORT_TABLE,
+ UPPL_LINK_TABLE
};
/** Below tables are present import tables */
string import_tables[ODBCM_MAX_IMPORT_TABLES] =
{ UPPL_CTR_DOMAIN_TABLE,
- UPPL_LOGICALPORT_TABLE,
- UPPL_LOGICAL_MEMBER_PORT_TABLE,
- UPPL_SWITCH_TABLE,
- UPPL_PORT_TABLE,
- UPPL_LINK_TABLE
+ UPPL_LOGICALPORT_TABLE,
+ UPPL_LOGICAL_MEMBER_PORT_TABLE,
+ UPPL_SWITCH_TABLE,
+ UPPL_PORT_TABLE,
+ UPPL_LINK_TABLE
};
/** Push table names into startup and candidate vector */
for (loop1 = 0; loop1 < ODBCM_MAX_UPPL_TABLES; loop1++) {
}
/** Push vectors into table list map */
db_table_list_map_.insert(map<int, vector<string> >::
- value_type(UNC_DT_STARTUP, startup_vector));
+ value_type(UNC_DT_STARTUP, startup_vector));
db_table_list_map_.insert(map<int, vector<string> >::
- value_type(UNC_DT_CANDIDATE, candidate_vector));
+ value_type(UNC_DT_CANDIDATE, candidate_vector));
db_table_list_map_.insert(map<int, vector<string> >::
- value_type(UNC_DT_RUNNING, running_vector));
+ value_type(UNC_DT_RUNNING, running_vector));
db_table_list_map_.insert(map<int, vector<string> >::
- value_type(UNC_DT_STATE, state_vector));
+ value_type(UNC_DT_STATE, state_vector));
db_table_list_map_.insert(map<int, vector<string> >::
- value_type(UNC_DT_IMPORT, import_vector));
+ value_type(UNC_DT_IMPORT, import_vector));
return ODBCM_RC_SUCCESS;
}
/**
- @Description : This function will parse the configuration file and
- * update the local structure db_conf_info. this structure will be used
- * during connection establishment.
+ @Description : This function will parse the configuration file and
+ * update the local structure db_conf_info. This structure
+ * will be used during connection establishment.
* @param[in] : None
- * @return : ODBCM_RC_STATUS
+ * @return : ODBCM_RC_SUCCESS - if the ParseConfigFile function is set to
+ * success
+ * ODBCM_RC_* - if the ParseConfigFile function is set to
+ * failure
**/
ODBCM_RC_STATUS ODBCManager::ParseConfigFile() {
- std::string conf_file_path;
+ std::string conf_file_path = "";
conf_file_path.append(UNC_MODULEDIR);
conf_file_path.append(ODBCM_CONF_FILE_PATH);
conf_file_path.append(ODBCM_CONF_FILE);
pfc::core::ConfHandle conf_handle(conf_file_path, &odbcm_cfdef);
int32_t err = conf_handle.getError();
pfc_log_debug("ODBCM::ODBCManager::ParseConfigFile: "
- "path: %s ", conf_file_path.c_str());
+ "path: %s ", conf_file_path.c_str());
if (err != 0) {
pfc_log_error("ODBCM::ODBCManager::ParseConfigFile: "
- "Err:%d, path: %s ", err, conf_file_path.c_str());
+ "Err:%d, path: %s ", err, conf_file_path.c_str());
return ODBCM_RC_FAILED;
}
pfc::core::ConfBlock logblock(conf_handle, "odbcm_params");
/**
* @Description : This function will establish the connection between
- * odbcmanager and RDBMS system
+ * odbcmanager and RDBMS system
* @param[in] : None
- * @return : ODBCM_RC_STATUS
+ * @return : ODBCM_RC_SUCCESS - if the connection between odbcmanager
+ * and RDBMS system is set to success.
+ * ODBCM_RC_* -if the connection between odbcmanager
+ * and RDBMS system is set to failure.
**/
-ODBCM_RC_STATUS ODBCManager::OpenDBConnection() {
+ODBCM_RC_STATUS ODBCManager::InitializeConnectionEnv() {
SQLRETURN odbc_rc = ODBCM_RC_SUCCESS;
/* Configuring Pooling using ODBC API
- SQL_CP_ONE_PER_HENV - Single pool for each hEnv (Environment handle)
odbc_rc = SQLSetEnvAttr(NULL, SQL_ATTR_CONNECTION_POOLING,
(SQLPOINTER) SQL_CP_ONE_PER_DRIVER, SQL_IS_INTEGER);
if (odbc_rc != ODBCM_RC_SUCCESS && odbc_rc != ODBCM_RC_SUCCESS_WITH_INFO) {
- pfc_log_debug("ODBCM::ODBCManager::OpenDBConnection: Error in "
- "SQLSetEnvAttr in connection pooling activation");
+ pfc_log_error("ODBCM::ODBCManager::InitializeConnectionEnv: Error in "
+ "SQLSetEnvAttr in connection pooling activation");
return ODBCM_RC_CONNECTION_ERROR;
}
- if (set_phy_connenction_env_() != ODBCM_RC_SUCCESS) {
- pfc_log_fatal("ODBCM::ODBCManager::OpenDBConnection: "
- "Error in set_phy_connenction_env_ ");
- return ODBCM_RC_CONN_ENV_ERROR;
- }
-
- if (set_rw_connenction_handle_() != ODBCM_RC_SUCCESS) {
- pfc_log_fatal("ODBCM::ODBCManager::OpenDBConnection: "
- "Error in set_rw_connenction_handle_ ");
- return ODBCM_RC_CONNECTION_ERROR;
- }
- if (set_ro_connenction_handle_() != ODBCM_RC_SUCCESS) {
- pfc_log_fatal("ODBCM::ODBCManager::OpenDBConnection: "
- "Error in set_ro_connenction_handle_ ");
+ if (set_phy_connection_env_() != ODBCM_RC_SUCCESS) {
+ pfc_log_error("ODBCM::ODBCManager::InitializeConnectionEnv: "
+ "Error in set_phy_connection_env_ ");
return ODBCM_RC_CONNECTION_ERROR;
}
+ return ODBCM_RC_SUCCESS;
+}
+/**
+ * @Description : This function will establish the connection between
+ * odbcmanager and RDBMS system
+ * @param[in] : None
+ * @return : ODBCM_RC_STATUS
+ **/
+ODBCM_RC_STATUS ODBCManager::OpenDBConnection(
+ OdbcmConnectionHandler *conn_obj) {
+ SQLRETURN odbc_rc = ODBCM_RC_SUCCESS;
+ SQLHDBC conn_handle = conn_obj->get_conn_handle();
+ switch (conn_obj->get_conn_type()) {
+ case kOdbcmConnReadWriteNb:
+ // Check if connection already exists
+ if (rw_nb_conn_obj_ != NULL &&
+ rw_nb_conn_obj_->get_conn_handle() != NULL) {
+ // Connection already exists
+ pfc_log_debug("Using existing Nb db connection request");
+ conn_obj->set_conn_handle(rw_nb_conn_obj_->get_conn_handle());
+ return ODBCM_RC_SUCCESS;
+ }
+ if (set_rw_connection_handle_(conn_handle) != ODBCM_RC_SUCCESS) {
+ pfc_log_error("ODBCM::ODBCManager::OpenDBConnection: "
+ "Error in set_rw_connection_handle_ ");
+ return ODBCM_RC_CONNECTION_ERROR;
+ }
+ /** setting SQL_ATTR_ACCESS_MODE for RW connection is not required
+ * SQL_MODE_READ_WRITE is default */
+ break;
+ case kOdbcmConnReadWriteSb:
+ // Check if connection already exists
+ if (rw_sb_conn_obj_ != NULL &&
+ rw_sb_conn_obj_->get_conn_handle() != NULL) {
+ // Connection already exists
+ pfc_log_debug("Using existing Sb db connection request");
+ conn_obj->set_conn_handle(rw_sb_conn_obj_->get_conn_handle());
+ return ODBCM_RC_SUCCESS;
+ }
+ if (set_rw_connection_handle_(conn_handle) != ODBCM_RC_SUCCESS) {
+ pfc_log_error("ODBCM::ODBCManager::OpenDBConnection: "
+ "Error in set_rw_connection_handle_ ");
+ return ODBCM_RC_CONNECTION_ERROR;
+ }
+ /** setting SQL_ATTR_ACCESS_MODE for RW connection is not required
+ * SQL_MODE_READ_WRITE is default */
+ break;
+ case kOdbcmConnReadOnly:
+ if (set_ro_connection_handle_(conn_handle) != ODBCM_RC_SUCCESS) {
+ pfc_log_error("ODBCM::ODBCManager::OpenDBConnection: "
+ "Error in set_ro_connection_handle_ ");
+ return ODBCM_RC_CONNECTION_ERROR;
+ }
+ odbc_rc = SQLSetConnectAttr(conn_handle, SQL_ATTR_ACCESS_MODE,
+ (SQLPOINTER)SQL_MODE_READ_ONLY, 0);
+ ODBCM_DBC_HANDLE_CHECK(conn_handle, odbc_rc);
+ if (odbc_rc != ODBCM_RC_SUCCESS &&
+ odbc_rc != ODBCM_RC_SUCCESS_WITH_INFO) {
+ pfc_log_debug("ODBCM::ODBCManager::OpenDBConnection: "
+ "Error in SQLSetConnectAttr");
+ return ODBCM_RC_CONNECTION_ERROR;
+ }
+ break;
+ default:
+ pfc_log_error("ODBCM::ODBCManager::OpenDBConnection: "
+ "Invalid connection type %d !! ",
+ conn_obj->get_conn_type());
+ break;
+ }
// *************************************************************************
// Set the matching condition for using an existing connection in the pool
odbc_rc = SQLSetEnvAttr(phy_conn_env_, SQL_ATTR_CP_MATCH,
- (SQLPOINTER)SQL_CP_RELAXED_MATCH, SQL_IS_INTEGER);
+ (SQLPOINTER)SQL_CP_RELAXED_MATCH, SQL_IS_INTEGER);
if (odbc_rc != ODBCM_RC_SUCCESS && odbc_rc != ODBCM_RC_SUCCESS_WITH_INFO) {
pfc_log_debug("ODBCM::ODBCManager::OpenDBConnection: "
- "Error in SQLSetEnvAttr during connec. pooling activation");
+ "Error in SQLSetEnvAttr during connec. pooling activation");
return ODBCM_RC_CONNECTION_ERROR;
}
// create and pool the connections.
- /*********************RW Connection **************************************/
std::ostringstream conn_string_stream;
conn_string_stream << "DSN=" << conf_parser_.dsn <<
- ";TIMEOUT=" << conf_parser_.time_out;
+ ";TIMEOUT=" << conf_parser_.time_out;
std::string conn_string = conn_string_stream.str();
- pfc_log_info("ODBCM::ODBCManager::OpenDBConnection: "
- "rw connection string = %s", conn_string.c_str());
+ pfc_log_debug("ODBCM::ODBCManager::OpenDBConnection: "
+ "connection string = %s", conn_string.c_str());
// 3. Connect to the datasource
- if (NULL != rw_conn_handle_)
- odbc_rc = SQLDriverConnect(rw_conn_handle_, NULL,
- (unsigned char*)(conn_string.c_str()),
- SQL_NTS, NULL, 0, NULL, SQL_DRIVER_NOPROMPT);
+ if (NULL != conn_handle)
+ odbc_rc = SQLDriverConnect(conn_handle, NULL,
+ (unsigned char*)(conn_string.c_str()),
+ SQL_NTS, NULL, 0, NULL, SQL_DRIVER_NOPROMPT);
// SQL_DRIVER_COMPLETE
- ODBCM_DBC_HANDLE_CHECK(rw_conn_handle_, odbc_rc);
+ ODBCM_DBC_HANDLE_CHECK(conn_handle, odbc_rc);
if (odbc_rc != ODBCM_RC_SUCCESS &&
odbc_rc != ODBCM_RC_SUCCESS_WITH_INFO) {
- pfc_log_fatal("ODBCM::ODBCManager::OpenDBConnection:"
- "Could not establish RW connection !!");
+ pfc_log_error("ODBCM::ODBCManager::OpenDBConnection:"
+ "Could not establish connection type = %d !!",
+ conn_obj->get_conn_type());
return ODBCM_RC_CONNECTION_ERROR;
}
- // print connection information
- ODBCMUtils::print_odbc_details(rw_conn_handle_);
/** setting connection attributes */
/** Attribute - Set before or after connection
* Either before or after
*/
/** setting SQL_ATTR_ACCESS_MODE for RW connection is not required
- * SQL_MODE_READ_WRITE is default */
- odbc_rc = SQLSetConnectAttr(rw_conn_handle_, SQL_ATTR_TXN_ISOLATION,
- (SQLPOINTER)SQL_TXN_READ_COMMITTED, 0);
- ODBCM_DBC_HANDLE_CHECK(rw_conn_handle_, odbc_rc);
+ * SQL_MODE_READ_WRITE is default */
+ odbc_rc = SQLSetConnectAttr(conn_handle, SQL_ATTR_TXN_ISOLATION,
+ (SQLPOINTER)SQL_TXN_READ_COMMITTED, 0);
+ ODBCM_DBC_HANDLE_CHECK(conn_handle, odbc_rc);
if (odbc_rc != ODBCM_RC_SUCCESS &&
odbc_rc != ODBCM_RC_SUCCESS_WITH_INFO) {
pfc_log_debug("ODBCM::ODBCManager::OpenDBConnection: "
- "Error in SQLSetConnectAttr");
+ "Error in SQLSetConnectAttr");
return ODBCM_RC_CONNECTION_ERROR;
}
- odbc_rc = SQLSetConnectAttr(rw_conn_handle_, SQL_ATTR_AUTOCOMMIT,
- (SQLPOINTER)SQL_AUTOCOMMIT_OFF, SQL_NTS);
- ODBCM_DBC_HANDLE_CHECK(rw_conn_handle_, odbc_rc);
+ odbc_rc = SQLSetConnectAttr(conn_handle, SQL_ATTR_AUTOCOMMIT,
+ (SQLPOINTER)SQL_AUTOCOMMIT_OFF, SQL_NTS);
+ ODBCM_DBC_HANDLE_CHECK(conn_handle, odbc_rc);
if (odbc_rc != ODBCM_RC_SUCCESS &&
odbc_rc != ODBCM_RC_SUCCESS_WITH_INFO) {
pfc_log_debug("ODBCM::ODBCManager::OpenDBConnection: "
- "Error in SQLSetConnectAttr");
+ "Error in SQLSetConnectAttr");
return ODBCM_RC_CONNECTION_ERROR;
}
- odbc_rc = SQLSetConnectAttr(rw_conn_handle_, SQL_ATTR_TRACE,
- (SQLPOINTER)SQL_OPT_TRACE_ON, SQL_NTS);
- ODBCM_DBC_HANDLE_CHECK(rw_conn_handle_, odbc_rc);
- if (odbc_rc != ODBCM_RC_SUCCESS &&
- odbc_rc != ODBCM_RC_SUCCESS_WITH_INFO) {
- pfc_log_debug("ODBCM::ODBCManager::OpenDBConnection: "
- "Error in SQLSetConnectAttr");
- return ODBCM_RC_CONNECTION_ERROR;
+ /**to set the created connection handle into OdbcmConnectionHanlder
+ * object reference*/
+ conn_obj->set_conn_handle(conn_handle);
+ if (rw_nb_conn_obj_ == NULL &&
+ conn_obj->get_conn_type() == kOdbcmConnReadWriteNb) {
+ rw_nb_conn_obj_ = new OdbcmConnectionHandler(*conn_obj);
+ } else if (rw_sb_conn_obj_ == NULL &&
+ conn_obj->get_conn_type() == kOdbcmConnReadWriteSb) {
+ rw_sb_conn_obj_ = new OdbcmConnectionHandler(*conn_obj);
}
pfc_log_info("ODBCM::ODBCManager::OpenDBConnection: "
- "rw database connection creation success");
- /*********************RW Connection End************************************/
-
- /*********************RO Connection**************************************/
- conn_string_stream.str("");
- conn_string_stream << "DSN=" << conf_parser_.dsn <<
- ";TIMEOUT=" << conf_parser_.time_out;
- conn_string = "";
- conn_string = conn_string_stream.str();
- pfc_log_info("ODBCM::ODBCManager::OpenDBConnection: "
- "ro connection string = %s", conn_string.c_str());
-
- if (NULL != ro_conn_handle_)
- odbc_rc = SQLDriverConnect(ro_conn_handle_, NULL,
- (unsigned char*)(conn_string.c_str()),
- SQL_NTS, NULL, 0, NULL, SQL_DRIVER_NOPROMPT);
- ODBCM_DBC_HANDLE_CHECK(ro_conn_handle_, odbc_rc);
- if (odbc_rc != ODBCM_RC_SUCCESS &&
- odbc_rc != ODBCM_RC_SUCCESS_WITH_INFO) {
- pfc_log_fatal("ODBCM::ODBCManager::OpenDBConnection: "
- "Could not establish RW connection !!");
- return ODBCM_RC_CONNECTION_ERROR;
- }
- /** print connection information */
- ODBCMUtils::print_odbc_details(ro_conn_handle_);
-
- odbc_rc = SQLSetConnectAttr(ro_conn_handle_, SQL_ATTR_TXN_ISOLATION,
- (SQLPOINTER)SQL_TXN_READ_COMMITTED, 0);
- ODBCM_DBC_HANDLE_CHECK(ro_conn_handle_, odbc_rc);
- if (odbc_rc != ODBCM_RC_SUCCESS &&
- odbc_rc != ODBCM_RC_SUCCESS_WITH_INFO) {
- pfc_log_debug("ODBCM::ODBCManager::OpenDBConnection: "
- "Error in ro SQLSetConnectAttr");
- return ODBCM_RC_CONNECTION_ERROR;
- }
-
- odbc_rc = SQLSetConnectAttr(ro_conn_handle_, SQL_ATTR_TRACE,
- (SQLPOINTER)SQL_OPT_TRACE_ON, SQL_NTS);
- ODBCM_DBC_HANDLE_CHECK(ro_conn_handle_, odbc_rc);
- if (odbc_rc != ODBCM_RC_SUCCESS &&
- odbc_rc != ODBCM_RC_SUCCESS_WITH_INFO) {
- pfc_log_debug("ODBCM::ODBCManager::OpenDBConnection: "
- "Error in SQLSetConnectAttr");
- return ODBCM_RC_CONNECTION_ERROR;
- }
- /**********************RO Connection End***********************************/
- pfc_log_info("ODBCM::ODBCManager::OpenDBConnection: "
- "ro database connection creation success");
+ "type %d database connection creation success",
+ conn_obj->get_conn_type());
return ODBCM_RC_SUCCESS;
}
+
/**
* @Description : This function will close the existing database connection
- * and reconnect the db connection
* @param[in] : None
- * @return : ODBCM_RC_STATUS
+ * @return : ODBCM_RC_SUCCESS - if the connection close the existing
+ * database is set to success.
+ * ODBCM_RC_* - if the existing connection of database
+ * is not close it set to failure.
**/
-ODBCM_RC_STATUS ODBCManager::ReconnectDB() {
- if (CloseDBConnection() != ODBCM_RC_SUCCESS) {
- pfc_log_info("ODBCM::ODBCManager::ReconnectDB:"
- "Error on CloseDBConnection");
+ODBCM_RC_STATUS ODBCManager::CloseDBConnection(
+ OdbcmConnectionHandler *conn_obj) {
+ SQLHDBC conn_handle = conn_obj->get_conn_handle();
+ if (conn_obj->get_conn_type() == kOdbcmConnReadWriteNb ||
+ conn_obj->get_conn_type() == kOdbcmConnReadWriteSb) {
+ if (PhysicalLayer::phyFiniFlag == 1) {
+ // Connection is already released in destructor
+ return ODBCM_RC_SUCCESS;
+ }
+ pfc_log_debug("Read Write connection will not be closed now");
+ ODBCM_RC_STATUS status = ODBCM_RC_SUCCESS;
+ ODBCM_END_TRANSACTION(conn_handle, SQL_ROLLBACK);
+ return status;
}
- /* Establish the database connection */
- if (ODBCM_RC_SUCCESS != OpenDBConnection()) {
- pfc_log_fatal("ODBCM::ODBCManager::ReconnectDB: "
- "Could not establish Database Connection !!");
- return ODBCM_RC_CONNECTION_ERROR;
- } else {
- pfc_log_info("ODBCM::ODBCManager::ReconnectDB:"
- "Database is reconnected successfully");
+ /* to disconnect */
+ if (NULL != conn_handle) {
+ SQLRETURN odbc_rc = 0;
+ odbc_rc = SQLDisconnect(conn_handle);
+ odbc_rc = SQLFreeHandle(SQL_HANDLE_DBC, conn_handle);
+ conn_handle = NULL;
+ conn_obj->set_conn_handle(conn_handle);
+ if (odbc_rc != ODBCM_RC_SUCCESS) {
+ pfc_log_error("ODBCM::ODBCManager::CloseDBConnection: "
+ "Error on Disconnect conn_handle");
+ return (ODBCM_RC_STATUS) odbc_rc;
+ }
+ pfc_log_debug("Read Only Connection is closed");
}
+ pfc_log_debug("ODBCM::ODBCManager::CloseDBConnection: "
+ "Now, the connection is disconnected...");
return ODBCM_RC_SUCCESS;
}
/**
- * @Description : This function will close the existing database connection
+ * @Description : This function will close the existing database rw connection
* @param[in] : None
- * @return : ODBCM_RC_STATUS
+ * @return : ODBCM_RC_SUCCESS - if the connection close the existing
+ * database is set to success.
+ * ODBCM_RC_* - if the existing connection of database
+ * is not close it set to failure.
**/
-ODBCM_RC_STATUS ODBCManager::CloseDBConnection() {
- SQLRETURN odbc_rc = 0;
- /* free handler */
- pfc_log_info("ODBCM::ODBCManager::CloseDBConnection: "
- "Freeing handler");
- /* to disconnect */
- if (NULL != rw_conn_handle_) {
- odbc_rc = SQLDisconnect(rw_conn_handle_);
- odbc_rc = SQLFreeHandle(SQL_HANDLE_DBC, rw_conn_handle_);
- pfc_log_info("ODBCM::ODBCManager::CloseDBConnection: "
- "Disconnect rw_conn_handle_");
- rw_conn_handle_ = NULL;
- if (odbc_rc != ODBCM_RC_SUCCESS) {
- pfc_log_error("ODBCM::ODBCManager::CloseDBConnection: "
- "Error on Disconnect rw_conn_handle_");
- return (ODBCM_RC_STATUS) odbc_rc;
+ODBCM_RC_STATUS ODBCManager::CloseRwConnection() {
+ if (rw_nb_conn_obj_ != NULL) {
+ SQLHDBC conn_handle = rw_nb_conn_obj_->get_conn_handle();
+ /* disconnect nb conn handle*/
+ if (NULL != conn_handle) {
+ SQLRETURN odbc_rc = 0;
+ odbc_rc = SQLDisconnect(conn_handle);
+ odbc_rc = SQLFreeHandle(SQL_HANDLE_DBC, conn_handle);
+ conn_handle = NULL;
+ rw_nb_conn_obj_->set_conn_handle(NULL);
+ delete rw_nb_conn_obj_;
+ rw_nb_conn_obj_ = NULL;
+ if (odbc_rc != ODBCM_RC_SUCCESS) {
+ pfc_log_error("ODBCM::ODBCManager::CloseRwConnection: "
+ "Error on Disconnect rw_nb_conn_handle");
+ return (ODBCM_RC_STATUS) odbc_rc;
+ }
}
}
- if (NULL != ro_conn_handle_) {
- odbc_rc = SQLDisconnect(ro_conn_handle_);
- odbc_rc = SQLFreeHandle(SQL_HANDLE_DBC, ro_conn_handle_);
- pfc_log_info("ODBCM::ODBCManager::CloseDBConnection: "
- "Disconnect ro_conn_handle_");
- ro_conn_handle_ = NULL;
- if (odbc_rc != ODBCM_RC_SUCCESS) {
- pfc_log_error("ODBCM::ODBCManager::CloseDBConnection: "
- "Error on Disconnect ro_conn_handle_");
- return (ODBCM_RC_STATUS) odbc_rc;
+ if (rw_sb_conn_obj_ != NULL) {
+ SQLHDBC conn_handle = rw_sb_conn_obj_->get_conn_handle();
+ /* disconnect sb conn handle*/
+ if (NULL != conn_handle) {
+ SQLRETURN odbc_rc = 0;
+ odbc_rc = SQLDisconnect(conn_handle);
+ odbc_rc = SQLFreeHandle(SQL_HANDLE_DBC, conn_handle);
+ conn_handle = NULL;
+ rw_sb_conn_obj_->set_conn_handle(NULL);
+ delete rw_sb_conn_obj_;
+ rw_sb_conn_obj_ = NULL;
+ if (odbc_rc != ODBCM_RC_SUCCESS) {
+ pfc_log_error("ODBCM::ODBCManager::CloseRwConnection: "
+ "Error on Disconnect rw_sb_conn_handle");
+ return (ODBCM_RC_STATUS) odbc_rc;
+ }
}
}
- if (NULL != phy_conn_env_) {
- odbc_rc = SQLFreeHandle(SQL_HANDLE_ENV, phy_conn_env_);
- pfc_log_info("ODBCM::ODBCManager:: Disconnect phy_conn_env_");
- phy_conn_env_ = NULL;
- }
- pfc_log_info("ODBCM::ODBCManager::CloseDBConnection: "
- "Now, database disconnected...");
+ pfc_log_debug("ODBCM::ODBCManager::CloseRwConnection: "
+ "Now, the rw connections are disconnected...");
return ODBCM_RC_SUCCESS;
}
/**
* @Description : Get the table id from table name
- * @param[in] : string table_name
- * @return : ODBCMTable
+ * @param[in] : table_name - name of the tables
+ * @return : ODBCMTable - returns the table name
**/
ODBCMTable ODBCManager::get_table_id(string table_name) {
if (table_name.compare(UPPL_CTR_TABLE) == 0) {
return BOUNDARY_TABLE;
} else {
pfc_log_debug("ODBCM::ODBCManager::get_table_id: "
- "Invalid table");
+ "Invalid table");
return UNKNOWN_TABLE;
}
}
/**
* @Description : clear the allocated memory
- * @param[in] : STMT , ODBCMTable ,DBVarbind ,QueryFactory ,QueryProcessor
- * @return : ODBCM_RC_STATUS
+ * @param[in] : stmt - which carries the SQL Query
+ * table_id - enum of the tables
+ * dbvarbindobj - database varbind object
+ * qfactoryobj - query factory object
+ * qprocessorobj - query processor object
+ * @return : void
**/
void ODBCManager::ODBCMFreeingMemory(HSTMT stmt,
- ODBCMTable table_id,
- DBVarbind *dbvarbindobj,
- QueryFactory *qfactoryobj,
- QueryProcessor *qprocessorobj) {
+ ODBCMTable table_id,
+ DBVarbind *dbvarbindobj,
+ QueryFactory *qfactoryobj,
+ QueryProcessor *qprocessorobj) {
SQLRETURN odbc_rc = 0;
/** statement handler free */
- // ODBCM_FREE_STMT(stmt);
if (NULL != stmt) {
odbc_rc = SQLFreeHandle(SQL_HANDLE_STMT, stmt);
stmt = NULL;
if (odbc_rc != ODBCM_RC_SUCCESS) {
pfc_log_error("ODBCM::ODBCManager::ODBCMFreeingMemory: Error while "
"Freeing resources");
- return;
}
/** Freeing allocated memory */
dbvarbindobj->FreeingBindedStructure(table_id);
qprocessorobj = NULL;
return;
}
+
+/**
+ * @Description : To get the column name using column id (enum)
+ * @param[in] : col_id - specifies the column id enum value
+ * @return : function returns corresponding column name string for the
+ * given column id (enum)
+ **/
+std::string ODBCManager::GetColumnName(ODBCMTableColumns col_id) {
+ std::map< ODBCMTableColumns, std::string>& ODBCMTableColumnsMap =
+ get_odbcm_tables_column_map_();
+ std::map< ODBCMTableColumns, std::string>::iterator column_iter =
+ ODBCMTableColumnsMap.find(col_id);
+ if (column_iter == ODBCMTableColumnsMap.end()) {
+ pfc_log_debug("ODBCM::ODBCManager:GetColumnName"
+ "column name does not exists ");
+ return ""; /*return null string*/
+ }
+ return column_iter->second;
+}
+
+/**
+ * @Description : Function to initialize the DB table list map
+ * @param[in] : None
+ * @return : ODBCM_RC_STATUS
+ **/
+ODBCM_RC_STATUS ODBCManager::initialize_odbcm_tables_column_map_(void) {
+ OdbcmColumnName odbcm_table_columns[] = {
+ {CTR_NAME, std::string(CTR_NAME_STR)},
+ {CTR_TYPE, std::string(CTR_TYPE_STR)},
+ {CTR_VERSION, std::string(CTR_VERSION_STR)},
+ {CTR_DESCRIPTION, std::string(CTR_DESCRIPTION_STR)},
+ {CTR_IP_ADDRESS, std::string(CTR_IP_ADDRESS_STR)},
+ {CTR_USER_NAME, std::string(CTR_USER_NAME_STR)},
+ {CTR_PASSWORD, std::string(CTR_PASSWORD_STR)},
+ {CTR_ENABLE_AUDIT, std::string(CTR_ENABLE_AUDIT_STR)},
+ {CTR_ACTUAL_VERSION, std::string(CTR_ACTUAL_VERSION_STR)},
+ {CTR_OPER_STATUS, std::string(CTR_OPER_STATUS_STR)},
+ {CTR_VALID, std::string(CTR_VALID_STR)},
+ {CTR_CS_ROW_STATUS, std::string(CTR_CS_ROW_STATUS_STR)},
+ {CTR_CS_ATTR, std::string(CTR_CS_ATTR_STR)},
+ {DOMAIN_NAME, std::string(DOMAIN_NAME_STR)},
+ {DOMAIN_TYPE, std::string(DOMAIN_TYPE_STR)},
+ {DOMAIN_DESCRIPTION, std::string(DOMAIN_DESCRIPTION_STR)},
+ {DOMAIN_OP_STATUS, std::string(DOMAIN_OP_STATUS_STR)},
+ {DOMAIN_VALID, std::string(DOMAIN_VALID_STR)},
+ {DOMAIN_CS_ROW_STATUS, std::string(DOMAIN_CS_ROW_STATUS_STR)},
+ {DOMAIN_CS_ATTR, std::string(DOMAIN_CS_ATTR_STR)},
+ {LP_PORT_ID, std::string(LP_PORT_ID_STR)},
+ {LP_DESCRIPTION, std::string(LP_DESCRIPTION_STR)},
+ {LP_PORT_TYPE, std::string(LP_PORT_TYPE_STR)},
+ {LP_SWITCH_ID, std::string(LP_SWITCH_ID_STR)},
+ {LP_PHYSICAL_PORT_ID, std::string(LP_PHYSICAL_PORT_ID_STR)},
+ {LP_OPER_DOWN_CRITERIA, std::string(LP_OPER_DOWN_CRITERIA_STR)},
+ {LP_OPER_STATUS, std::string(LP_OPER_STATUS_STR)},
+ {LP_CTR_VALID, std::string(LP_CTR_VALID_STR)},
+ {LMP_SWITCH_ID, std::string(LMP_SWITCH_ID_STR)},
+ {LMP_PHYSICAL_PORT_ID, std::string(LMP_PHYSICAL_PORT_ID_STR)},
+ {LMP_LP_PORT_ID, std::string(LMP_LP_PORT_ID_STR)},
+ {SWITCH_ID, std::string(SWITCH_ID_STR)},
+ {SWITCH_DESCRIPTION, std::string(SWITCH_DESCRIPTION_STR)},
+ {SWITCH_MODEL, std::string(SWITCH_MODEL_STR)},
+ {SWITCH_IP_ADDRESS, std::string(SWITCH_IP_ADDRESS_STR)},
+ {SWITCH_IPV6_ADDRESS, std::string(SWITCH_IPV6_ADDRESS_STR)},
+ {SWITCH_ADMIN_STATUS, std::string(SWITCH_ADMIN_STATUS_STR)},
+ {SWITCH_DOMAIN_NAME, std::string(SWITCH_DOMAIN_NAME_STR)},
+ {SWITCH_MANUFACTURER, std::string(SWITCH_MANUFACTURER_STR)},
+ {SWITCH_HARDWARE, std::string(SWITCH_HARDWARE_STR)},
+ {SWITCH_SOFTWARE, std::string(SWITCH_SOFTWARE_STR)},
+ {SWITCH_ALARM_STATUS, std::string(SWITCH_ALARM_STATUS_STR)},
+ {SWITCH_OPER_STATUS, std::string(SWITCH_OPER_STATUS_STR)},
+ {SWITCH_VALID, std::string(SWITCH_VALID_STR)},
+ {PORT_ID, std::string(PORT_ID_STR)},
+ {PORT_NUMBER, std::string(PORT_NUMBER_STR)},
+ {PORT_DESCRIPTION, std::string(PORT_DESCRIPTION_STR)},
+ {PORT_ADMIN_STATUS, std::string(PORT_ADMIN_STATUS_STR)},
+ {PORT_DIRECTION, std::string(PORT_DIRECTION_STR)},
+ {PORT_TRUNK_ALL_VLAN, std::string(PORT_TRUNK_ALL_VLAN_STR)},
+ {PORT_OPER_STATUS, std::string(PORT_OPER_STATUS_STR)},
+ {PORT_MAC_ADDRESS, std::string(PORT_MAC_ADDRESS_STR)},
+ {PORT_DUPLEX, std::string(PORT_DUPLEX_STR)},
+ {PORT_SPEED, std::string(PORT_SPEED_STR)},
+ {PORT_ALARM_STATUS, std::string(PORT_ALARM_STATUS_STR)},
+ {PORT_LOGIC_PORT_ID, std::string(PORT_LOGIC_PORT_ID_STR)},
+ {PORT_VALID , std::string(PORT_VALID_STR)},
+ {LINK_SWITCH_ID1, std::string(LINK_SWITCH_ID1_STR)},
+ {LINK_PORT_ID1, std::string(LINK_PORT_ID1_STR)},
+ {LINK_SWITCH_ID2, std::string(LINK_SWITCH_ID2_STR)},
+ {LINK_PORT_ID2, std::string(LINK_PORT_ID2_STR)},
+ {LINK_DESCRIPTION, std::string(LINK_DESCRIPTION_STR)},
+ {LINK_OPER_STATUS, std::string(LINK_OPER_STATUS_STR)},
+ {LINK_VALID, std::string(LINK_VALID_STR)},
+ {BDRY_ID, std::string(BDRY_ID_STR)},
+ {BDRY_DESCRIPTION, std::string(BDRY_DESCRIPTION_STR)},
+ {BDRY_CTR_NAME1, std::string(BDRY_CTR_NAME1_STR)},
+ {BDRY_DM_NAME1, std::string(BDRY_DM_NAME1_STR)},
+ {BDRY_PORT_ID1, std::string(BDRY_PORT_ID1_STR)},
+ {BDRY_CTR_NAME2, std::string(BDRY_CTR_NAME2_STR)},
+ {BDRY_DM_NAME2, std::string(BDRY_DM_NAME2_STR)},
+ {BDRY_PORT_ID2, std::string(BDRY_PORT_ID2_STR)},
+ {BDRY_OPER_STATUS, std::string(BDRY_OPER_STATUS_STR)},
+ {BDRY_VALID, std::string(BDRY_VALID_STR)},
+ {BDRY_ROW_STATUS, std::string(BDRY_ROW_STATUS_STR)},
+ {BDRY_ATTR, std::string(BDRY_ATTR_STR)}
+ };
+ /** Initialise the local variables */
+ uint32_t loop = 0;
+ uint32_t count = 0;
+ std::pair<std::map<ODBCMTableColumns,
+ std::string>::iterator, bool> table_column_names;
+ /** Check map is empty or not */
+ if (ODBCManager::odbcm_tables_column_map_.empty()) {
+ count = sizeof(odbcm_table_columns)/sizeof(OdbcmColumnName);
+ pfc_log_debug("ODBCM::ODBCManager:%s : count %d", __func__, count);
+ /** Traverse and insert in the map */
+ for (loop = 0; loop < count; loop++) {
+ table_column_names = odbcm_tables_column_map_.insert(
+ std::pair<ODBCMTableColumns, std::string>
+ (odbcm_table_columns[loop].column_id,
+ odbcm_table_columns[loop].column_string));
+ if (table_column_names.second == false) {
+ pfc_log_debug("ODBCM::ODBCManager:%s "
+ "Error in inserting odbcm_tables_column_map_ %s", __func__,
+ odbcm_table_columns[loop].column_string.c_str());
+ return ODBCM_RC_FAILED;
+ } // if
+ } // for
+ } // if
+ return ODBCM_RC_SUCCESS;
+}
/**EOF*/
#include <sstream>
#include "odbcm_db_tableschema.hh"
#include "odbcm_utils.hh"
+#include "odbcm_mgr.hh"
+#include "odbcm_common.hh"
namespace unc {
namespace uppl {
/**
- * @Description :
+ * @Description :Constructor to create/initialize the instance of
+ * DBTableSchema
* @param[in] : None
- * @return :
+ * @return : void
**/
-DBTableSchema::DBTableSchema() {
- /** Initialize all the members */
- db_return_status_ = ROW_VALID;
+DBTableSchema::DBTableSchema()
+:
+ /** Initialize all the members */
+ db_return_status_(ROW_VALID) {
+ table_name_ = UNKNOWN_TABLE;
}
/**
- * @Description :
+ * @Description :This function is automatically invoked when
+ * DBTableSchema object is destroyed
* @param[in] : None
- * @return :
+ * @return : void
**/
DBTableSchema::~DBTableSchema() {
FreeDBTableSchema();
}
/**
- * @Description :
+ * @Description : To get the table name from DBTableSchema
* @param[in] : None
- * @return :
+ * @return : ODBCMTable
**/
-std::string DBTableSchema::get_table_name() {
+ODBCMTable DBTableSchema::get_table_name() {
return table_name_;
}
/**
- * @Description :
- * @param[in] : None
- * @return :
+ * @Description : To set the table name in DBTableSchema
+ * @param[in] : ODBCMTable table_name
+ * @return : void
**/
-void DBTableSchema::set_table_name(std::string table_name) {
+void DBTableSchema::set_table_name(unc::uppl::ODBCMTable table_name) {
table_name_ = table_name;
}
/**
- * @Description :
+ * @Description : To get the primarykeys filled in DBTableSchema
* @param[in] : None
- * @return :
+ * @return : vector
**/
std::vector <std::string> DBTableSchema::get_primary_keys() {
return primary_keys_;
}
/**
- * @Description :
+ * @Description : To get the DBTableSchema row_list
* @param[in] : None
- * @return :
+ * @return : list
**/
-std::list < std::vector <TableAttrSchema> > DBTableSchema::get_row_list() {
+std::list < std::vector <TableAttrSchema> >& DBTableSchema::get_row_list() {
return row_list_;
}
/**
- * @Description :
- * @param[in] : None
- * @return :
+ * @Description : To fill the DBTableSchema row_list
+ * @param[in] : attributes_vector - vector object specifies the
+ * column attributes on the table
+ * @return : void
**/
void DBTableSchema::PushBackToRowList(
std::vector <TableAttrSchema>
}
/**
- * @Description :
- * @param[in] : None
- * @return :
+ * @Description : To fill the DBTableSchema primarykey vector
+ * @param[in] : attribute_name - specifies the attribute name
+ * @return : void
**/
void DBTableSchema::PushBackToPrimaryKeysVector(
std::string attribute_name) {
}
/**
- * @Description :
- * @param[in] : None
- * @return :
+ * @Description : To set the DBTableSchema primarykey vector
+ * @param[in] : primary_keys - vector holds the primarykeys
+ * of the specified table
+ * @return : void
**/
void DBTableSchema::set_primary_keys(
std::vector <std::string> primary_keys) {
}
/**
- * @Description :
- * @param[in] : None
- * @return :
+ * @Description : To set the DBTableSchema row_list
+ * @param[in] : row_list - specifies rows and each row column
+ * attributes on the table
+ * @return : void
**/
void DBTableSchema::set_row_list(
std::list <std::vector<TableAttrSchema> > row_list) {
/**
*@Description : To free the allocated memory in DBTableSchema
-*@param[in] : DBTableSchema*
+*@param[in] : none
*@return : void
**/
void DBTableSchema::FreeDBTableSchema() {
/** Clear the list after the traversal */
row_list_.clear();
}
+/**
+ * *@Description : To print the char buffer values in DBTableSchema
+ * *@param[in] : buffer - to print the column attribute values,
+ * length - specifies the of the buffer
+ * column_name - specifies the column name
+ * *@return : char*
+ * **/
+inline std::string DBTableSchema::Odbcm_PrintCharBuffer(uint8_t* buffer,
+ int length, ODBCMTableColumns column_name) {
+ int index = 0;
+ std::ostringstream buffer_stream;
+ buffer_stream.str("");
+ buffer_stream << "| " << std::setw(20) <<
+ ODBCManager::get_ODBCManager()->
+ GetColumnName(column_name).c_str() << ": ";
+ while (index < length) {
+ if ('\0' != buffer[index])
+ buffer_stream << buffer[index];
+ index++;
+ }
+ buffer = NULL;
+ return buffer_stream.str();
+}
/**
*@Description : To print the values in DBTableSchema
-*@param[in] : DBTableSchema*
+*@param[in] : None
*@return : void
**/
void DBTableSchema::PrintDBTableSchema() {
uint32_t row_count = 0;
- uint32_t index = 0;
std::vector<TableAttrSchema> attr_vector;
std::vector<std::string> :: iterator iter_primarykey;
std::vector< TableAttrSchema >::iterator iter_vector;
std::list <std::vector<TableAttrSchema> >::iterator iter_list;
/** Print the contents of DBTableSchema object */
- pfc_log_info("+---------------------------------------+");
- pfc_log_info("| Table : %s", (get_table_name()).c_str());
+ pfc_log_debug("+---------------------------------------+");
+ pfc_log_debug("| Table : %s",
+ ODBCManager::get_ODBCManager()->
+ GetTableName(get_table_name()).c_str());
/** Traverse the primary key vector to display pkeys */
std::ostringstream primary_key;
primary_key << "| Primary keys : ";
iter_primarykey++) {
primary_key << (*iter_primarykey).c_str() << ";";
} // for
- pfc_log_info("%s", (primary_key.str()).c_str());
- pfc_log_info("+---------------------------------------+");
- /*
- * Macro to print the char buffer
- */
-#define ODBCM_PRINT_CHAR_BUFFER(buffer, length) \
- index = 0; \
- while (index < length) { \
- if ('\0' != buffer[index]) \
- row_values << buffer[index]; \
- index++; }
+ pfc_log_debug("%s", (primary_key.str()).c_str());
+ pfc_log_debug("+---------------------------------------+");
+ ColumnAttrValue <uint16_t> *rs_value16 = NULL;
+ ColumnAttrValue <uint32_t> *rs_value32 = NULL;
+ ColumnAttrValue <uint32_t> *iprs_value = NULL;
+ ColumnAttrValue <uint64_t> *rs_value64 = NULL;
+ ColumnAttrValue <uint8_t[16]> *ip6rs_value = NULL;
+ ColumnAttrValue <uint8_t[2]> *rs_valuea2 = NULL;
+ ColumnAttrValue <uint8_t[3]> *rs_valuea3 = NULL;
+ ColumnAttrValue <uint8_t[6]> *rs_valuea6 = NULL;
+ ColumnAttrValue <uint8_t[8]> *rs_valuea8 = NULL;
+ ColumnAttrValue <uint8_t[9]> *rs_valuea9 = NULL;
+ ColumnAttrValue <uint8_t[11]> *rs_valuea11 = NULL;
+ ColumnAttrValue <uint8_t[16]> *rs_valuea16 = NULL;
+ ColumnAttrValue <uint8_t[32]> *rs_valuea32 = NULL;
+ ColumnAttrValue <uint8_t[128]> *rs_valuea128 = NULL;
+ ColumnAttrValue <uint8_t[256]> *rs_valuea256 = NULL;
+ ColumnAttrValue <uint8_t[257]> *rs_valuea257 = NULL;
+ ColumnAttrValue <uint8_t[320]> *rs_valuea320 = NULL;
/** Traverse the list to get the attribute vector */
- std::ostringstream row_values;
for (row_count = 1, iter_list = row_list_.begin();
iter_list != row_list_.end(); ++iter_list, row_count++) {
attr_vector = *iter_list;
- pfc_log_info("| ROW : %d", row_count);
+ pfc_log_debug("| ROW : %d", row_count);
/** Traverse the vector to get attribute information */
+ std::ostringstream row_values;
for (iter_vector = attr_vector.begin();
iter_vector != attr_vector.end(); ++iter_vector) {
+ rs_value16 = NULL;
+ rs_value32 = NULL;
+ iprs_value = NULL;
+ rs_value64 = NULL;
+ ip6rs_value = NULL;
+ rs_valuea2 = NULL;
+ rs_valuea3 = NULL;
+ rs_valuea6 = NULL;
+ rs_valuea8 = NULL;
+ rs_valuea9 = NULL;
+ rs_valuea11 = NULL;
+ rs_valuea16 = NULL;
+ rs_valuea32 = NULL;
+ rs_valuea128 = NULL;
+ rs_valuea256 = NULL;
+ rs_valuea257 = NULL;
+ rs_valuea320 = NULL;
row_values.str("");
- row_values << "| " << std::setw(20) <<
- (*iter_vector).table_attribute_name.c_str() << ": ";
- /** If attribute datatype is DATATYPE_UINT8_ARRAY_9 */
- if ((*iter_vector).request_attribute_type == DATATYPE_UINT8_ARRAY_9) {
- ColumnAttrValue <uint8_t[9]> *rs_value =
- ((ColumnAttrValue<uint8_t[9]>*)
- ((*iter_vector).p_table_attribute_value));
- ODBCM_PRINT_CHAR_BUFFER(rs_value->value, 9);
- }
- /** If attribute datatype is DATATYPE_UINT8_ARRAY_8 */
- if ((*iter_vector).request_attribute_type == DATATYPE_UINT8_ARRAY_8) {
- ColumnAttrValue <uint8_t[8]> *rs_value =
- ((ColumnAttrValue<uint8_t[8]>*)
- ((*iter_vector).p_table_attribute_value));
- ODBCM_PRINT_CHAR_BUFFER(rs_value->value, 8);
- }
- /** If attribute datatype is DATATYPE_UINT8_ARRAY_6 */
- if ((*iter_vector).request_attribute_type == DATATYPE_UINT8_ARRAY_6) {
- ColumnAttrValue <uint8_t[6]> *rs_value =
- ((ColumnAttrValue<uint8_t[6]>*)
- ((*iter_vector).p_table_attribute_value));
- ODBCM_PRINT_CHAR_BUFFER(rs_value->value, 6);
- }
- /** If attribute datatype is DATATYPE_UINT8_ARRAY_3 */
- if ((*iter_vector).request_attribute_type == DATATYPE_UINT8_ARRAY_3) {
- ColumnAttrValue <uint8_t[3]> *rs_value =
- ((ColumnAttrValue<uint8_t[3]>*)
- ((*iter_vector).p_table_attribute_value));
- ODBCM_PRINT_CHAR_BUFFER(rs_value->value, 3);
- }
- /** If attribute datatype is DATATYPE_UINT8_ARRAY_2 */
- if ((*iter_vector).request_attribute_type == DATATYPE_UINT8_ARRAY_2) {
- ColumnAttrValue <uint8_t[2]> *rs_value =
- ((ColumnAttrValue<uint8_t[2]>*)
- ((*iter_vector).p_table_attribute_value));
- ODBCM_PRINT_CHAR_BUFFER(rs_value->value, 2);
- }
- /** If attribute datatype is DATATYPE_UINT8_ARRAY_11 */
- if ((*iter_vector).request_attribute_type == DATATYPE_UINT8_ARRAY_11) {
- ColumnAttrValue <uint8_t[11]> *rs_value =
- ((ColumnAttrValue<uint8_t[11]>*)
- ((*iter_vector).p_table_attribute_value));
- ODBCM_PRINT_CHAR_BUFFER(rs_value->value, 11);
- }
- /** If attribute datatype is DATATYPE_UINT8_ARRAY_16 */
- if ((*iter_vector).request_attribute_type == DATATYPE_UINT8_ARRAY_16) {
- ColumnAttrValue <uint8_t[16]> *rs_value =
- ((ColumnAttrValue<uint8_t[16]>*)
- ((*iter_vector).p_table_attribute_value));
- ODBCM_PRINT_CHAR_BUFFER(rs_value->value, 16);
- }
- /** If attribute datatype is DATATYPE_IPV4 */
- if (((*iter_vector).request_attribute_type == DATATYPE_IPV4)) {
- ColumnAttrValue <uint32_t> *rs_value =
- ((ColumnAttrValue<uint>*)
- ((*iter_vector).p_table_attribute_value));
- struct sockaddr_in saddr;
- saddr.sin_addr.s_addr = rs_value->value;
- row_values << inet_ntoa(saddr.sin_addr);
- }
- /** If attribute datatype is DATATYPE_IPV6 */
- if ((*iter_vector).request_attribute_type == DATATYPE_IPV6) {
- ColumnAttrValue <uint8_t[16]> *rs_value =
- ((ColumnAttrValue<uint8_t[16]>*)
- ((*iter_vector).p_table_attribute_value));
- // ODBCM_PRINT_CHAR_BUFFER(rs_value->value, 16);
- row_values << ODBCMUtils::get_ipv6_string(rs_value->value);
- }
- /** If attribute datatype is DATATYPE_UINT8_ARRAY_32 */
- if ((*iter_vector).request_attribute_type == DATATYPE_UINT8_ARRAY_32) {
- ColumnAttrValue <uint8_t[32]> *rs_value =
- ((ColumnAttrValue<uint8_t[32]>*)
- ((*iter_vector).p_table_attribute_value));
- ODBCM_PRINT_CHAR_BUFFER(rs_value->value, 32);
- }
- /** If attribute datatype is DATATYPE_UINT8_ARRAY_128 */
- if ((*iter_vector).request_attribute_type == DATATYPE_UINT8_ARRAY_128) {
- ColumnAttrValue <uint8_t[128]> *rs_value =
- ((ColumnAttrValue<uint8_t[128]>*)
- ((*iter_vector).p_table_attribute_value));
- ODBCM_PRINT_CHAR_BUFFER(rs_value->value, 128);
- }
- /** If attribute datatype is DATATYPE_UINT8_ARRAY_257 */
- if ((*iter_vector).request_attribute_type == DATATYPE_UINT8_ARRAY_257) {
- ColumnAttrValue <uint8_t[257]> *rs_value =
- ((ColumnAttrValue<uint8_t[257]>*)
- ((*iter_vector).p_table_attribute_value));
- ODBCM_PRINT_CHAR_BUFFER(rs_value->value, 257);
- }
- /** If attribute datatype is DATATYPE_UINT8_ARRAY_256 */
- if ((*iter_vector).request_attribute_type == DATATYPE_UINT8_ARRAY_256) {
- ColumnAttrValue <uint8_t[256]> *rs_value =
- ((ColumnAttrValue<uint8_t[256]>*)
- ((*iter_vector).p_table_attribute_value));
- ODBCM_PRINT_CHAR_BUFFER(rs_value->value, 256);
- }
- /** If attribute datatype is DATATYPE_UINT8_ARRAY_320 */
- if ((*iter_vector).request_attribute_type == DATATYPE_UINT8_ARRAY_320) {
- ColumnAttrValue <uint8_t[320]> *rs_value =
- ((ColumnAttrValue<uint8_t[320]>*)
- ((*iter_vector).p_table_attribute_value));
- ODBCM_PRINT_CHAR_BUFFER(rs_value->value, 320);
- }
- /** If attribute datatype is DATATYPE_UINT16 */
- if ((*iter_vector).request_attribute_type == DATATYPE_UINT16) {
- ColumnAttrValue <uint16_t> *rs_value =
- ((ColumnAttrValue<uint16_t>*)
- ((*iter_vector).p_table_attribute_value));
- row_values << rs_value-> value;
- }
- /** If attribute datatype is DATATYPE_UINT32 */
- if ((*iter_vector).request_attribute_type == DATATYPE_UINT32) {
- ColumnAttrValue <uint32_t> *rs_value =
- ((ColumnAttrValue<uint32_t>*)
- ((*iter_vector).p_table_attribute_value));
- row_values << rs_value->value;
- }
- /** If attribute datatype is DATATYPE_UINT64 */
- if ((*iter_vector).request_attribute_type == DATATYPE_UINT64) {
- ColumnAttrValue <uint64_t> *rs_value =
- ((ColumnAttrValue<uint64_t>*)
- ((*iter_vector).p_table_attribute_value));
- row_values << rs_value->value;
+ row_values << "| " << std::setw(20) << ODBCManager::get_ODBCManager()->
+ GetColumnName((*iter_vector).table_attribute_name).c_str() << ": ";
+ ODBCMTableColumns attr_name((*iter_vector).table_attribute_name);
+
+ switch ((*iter_vector).request_attribute_type) {
+ case DATATYPE_UINT16:
+ rs_value16 = ((ColumnAttrValue<uint16_t>*)
+ ((*iter_vector).p_table_attribute_value));
+ row_values << rs_value16->value;
+ pfc_log_debug("%s", row_values.str().c_str());
+ break;
+ case DATATYPE_UINT32:
+ rs_value32 = ((ColumnAttrValue<uint32_t>*)
+ ((*iter_vector).p_table_attribute_value));
+ row_values << rs_value32->value;
+ pfc_log_debug("%s", row_values.str().c_str());
+ break;
+ case DATATYPE_UINT64:
+ rs_value64 = ((ColumnAttrValue<uint64_t>*)
+ ((*iter_vector).p_table_attribute_value));
+ row_values << rs_value64->value;
+ pfc_log_debug("%s", row_values.str().c_str());
+ break;
+ case DATATYPE_IPV4:
+ iprs_value = ((ColumnAttrValue<uint>*)
+ ((*iter_vector).p_table_attribute_value));
+ struct sockaddr_in saddr;
+ saddr.sin_addr.s_addr = iprs_value->value;
+ row_values << inet_ntoa(saddr.sin_addr);
+ pfc_log_debug("%s", row_values.str().c_str());
+ break;
+ case DATATYPE_IPV6:
+ ip6rs_value = ((ColumnAttrValue<uint8_t[16]>*)
+ ((*iter_vector).p_table_attribute_value));
+ row_values << ODBCMUtils::get_ipv6_string(ip6rs_value->value);
+ pfc_log_debug("%s", row_values.str().c_str());
+ break;
+ case DATATYPE_UINT8_ARRAY_2:
+ rs_valuea2 = ((ColumnAttrValue<uint8_t[2]>*)
+ ((*iter_vector).p_table_attribute_value));
+ pfc_log_debug("%s", Odbcm_PrintCharBuffer(rs_valuea2->value, 2,
+ attr_name).c_str());
+ break;
+ case DATATYPE_UINT8_ARRAY_3:
+ rs_valuea3 = ((ColumnAttrValue<uint8_t[3]>*)
+ ((*iter_vector).p_table_attribute_value));
+ pfc_log_debug("%s", Odbcm_PrintCharBuffer(rs_valuea3->value, 3,
+ attr_name).c_str());
+ break;
+ case DATATYPE_UINT8_ARRAY_6:
+ rs_valuea6 = ((ColumnAttrValue<uint8_t[6]>*)
+ ((*iter_vector).p_table_attribute_value));
+ pfc_log_debug("%s", Odbcm_PrintCharBuffer(rs_valuea6->value, 6,
+ attr_name).c_str());
+ break;
+ case DATATYPE_UINT8_ARRAY_8:
+ rs_valuea8 = ((ColumnAttrValue<uint8_t[8]>*)
+ ((*iter_vector).p_table_attribute_value));
+ pfc_log_debug("%s", Odbcm_PrintCharBuffer(rs_valuea8->value, 8,
+ attr_name).c_str());
+ break;
+ case DATATYPE_UINT8_ARRAY_9:
+ rs_valuea9 = ((ColumnAttrValue<uint8_t[9]>*)
+ ((*iter_vector).p_table_attribute_value));
+ pfc_log_debug("%s", Odbcm_PrintCharBuffer(rs_valuea9->value, 9,
+ attr_name).c_str());
+ break;
+ case DATATYPE_UINT8_ARRAY_11:
+ rs_valuea11 = ((ColumnAttrValue<uint8_t[11]>*)
+ ((*iter_vector).p_table_attribute_value));
+ pfc_log_debug("%s", Odbcm_PrintCharBuffer(rs_valuea11->value, 11,
+ attr_name).c_str());
+ break;
+ case DATATYPE_UINT8_ARRAY_16:
+ rs_valuea16 = ((ColumnAttrValue<uint8_t[16]>*)
+ ((*iter_vector).p_table_attribute_value));
+ pfc_log_debug("%s", Odbcm_PrintCharBuffer(rs_valuea16->value, 16,
+ attr_name).c_str());
+ break;
+ case DATATYPE_UINT8_ARRAY_32:
+ rs_valuea32 = ((ColumnAttrValue<uint8_t[32]>*)
+ ((*iter_vector).p_table_attribute_value));
+ pfc_log_debug("%s", Odbcm_PrintCharBuffer(rs_valuea32->value, 32,
+ attr_name).c_str());
+ break;
+ case DATATYPE_UINT8_ARRAY_128:
+ rs_valuea128 = ((ColumnAttrValue<uint8_t[128]>*)
+ ((*iter_vector).p_table_attribute_value));
+ pfc_log_debug("%s", Odbcm_PrintCharBuffer(rs_valuea128->value, 128,
+ attr_name).c_str());
+ break;
+ case DATATYPE_UINT8_ARRAY_256:
+ rs_valuea256 = ((ColumnAttrValue<uint8_t[256]>*)
+ ((*iter_vector).p_table_attribute_value));
+ pfc_log_debug("%s", Odbcm_PrintCharBuffer(rs_valuea256->value, 256,
+ attr_name).c_str());
+ break;
+ case DATATYPE_UINT8_ARRAY_257:
+ rs_valuea257 = ((ColumnAttrValue<uint8_t[257]>*)
+ ((*iter_vector).p_table_attribute_value));
+ pfc_log_debug("%s", Odbcm_PrintCharBuffer(rs_valuea257->value, 257,
+ attr_name).c_str());
+ break;
+ case DATATYPE_UINT8_ARRAY_320:
+ rs_valuea320 = ((ColumnAttrValue<uint8_t[320]>*)
+ ((*iter_vector).p_table_attribute_value));
+ pfc_log_debug("%s", Odbcm_PrintCharBuffer(rs_valuea320->value, 320,
+ attr_name).c_str());
+ break;
+ default:
+ row_values.str("");
+ break;
}
- pfc_log_info("%s", (row_values.str()).c_str());
}
- pfc_log_info("+---------------------------------------+");
+ pfc_log_debug("+---------------------------------------+");
} // for
}
* @param[in] : None
* @return : None
**/
-DBVarbind::DBVarbind() {
- /** Initialize the pointers in DBVarbind */
- FillINPUTValues = NULL;
- FetchOUTPUTValues = NULL;
- BindINParameter = NULL;
- BindOUTParameter = NULL;
- p_ctr_table = NULL;
- p_domain_table = NULL;
- p_logicalport_table = NULL;
- p_logical_memberport_table = NULL;
- p_switch_table = NULL;
- p_port_table = NULL;
- p_link_table = NULL;
- p_boundary_table = NULL;
- p_isrowexists = NULL;
-
+DBVarbind::DBVarbind()
+: /** Initialize the pointers in DBVarbind */
+ BindINParameter(NULL),
+ BindOUTParameter(NULL),
+ FillINPUTValues(NULL),
+ FetchOUTPUTValues(NULL),
+ p_ctr_table(NULL),
+ p_domain_table(NULL),
+ p_logicalport_table(NULL),
+ p_logical_memberport_table(NULL),
+ p_switch_table(NULL),
+ p_port_table(NULL),
+ p_link_table(NULL),
+ p_boundary_table(NULL),
+ p_isrowexists(NULL) {
/** SQL Binary buffer length ptr to use in
* database binding apis */
p_switch_id1_len = new SQLLEN;
- if (p_switch_id1_len != NULL )
- *p_switch_id1_len = 0;
- else
- pfc_log_debug("ODBCM::DBVarbind:: Error in new: p_switch_id1_len");
+ if (p_switch_id1_len == NULL )
+ pfc_log_fatal("ODBCM::DBVarbind:: Error in new: p_switch_id1_len");
+ *p_switch_id1_len = 0;
p_switch_id2_len = new SQLLEN;
- if (p_switch_id2_len != NULL )
- *p_switch_id2_len = 0;
- else
- pfc_log_debug("ODBCM::DBVarbind:: Error in new: p_switch_id2_len");
+ if (p_switch_id2_len == NULL )
+ pfc_log_fatal("ODBCM::DBVarbind:: Error in new: p_switch_id2_len");
+ *p_switch_id2_len = 0;
p_logicalport_id1_len = new SQLLEN;
- if (p_logicalport_id1_len != NULL )
- *p_logicalport_id1_len = 0;
- else
- pfc_log_debug("ODBCM::DBVarbind:: Error in new: p_logicalport_id1_len");
+ if (p_logicalport_id1_len == NULL )
+ pfc_log_fatal("ODBCM::DBVarbind:: Error in new: p_logicalport_id1_len");
+ *p_logicalport_id1_len = 0;
p_logicalport_id2_len = new SQLLEN;
- if (p_logicalport_id2_len != NULL )
- *p_logicalport_id2_len = 0;
- else
- pfc_log_debug("ODBCM::DBVarbind:: Error in new: p_logicalport_id2_len");
+ if (p_logicalport_id2_len == NULL )
+ pfc_log_fatal("ODBCM::DBVarbind:: Error in new: p_logicalport_id2_len");
+ *p_logicalport_id2_len = 0;
p_ipv6_len = new SQLLEN;
- if (p_ipv6_len != NULL )
- *p_ipv6_len = 0;
- else
- pfc_log_debug("ODBCM::DBVarbind:: Error in new: p_ipv6_len");
+ if (p_ipv6_len == NULL )
+ pfc_log_fatal("ODBCM::DBVarbind:: Error in new: p_ipv6_len");
+ *p_ipv6_len = 0;
p_alarms_status_len = new SQLLEN;
- if (p_alarms_status_len != NULL )
- *p_alarms_status_len = 0;
- else
- pfc_log_debug("ODBCM::DBVarbind:: Error in new: p_alarms_status_len");
+ if (p_alarms_status_len == NULL )
+ pfc_log_fatal("ODBCM::DBVarbind:: Error in new: p_alarms_status_len");
+ *p_alarms_status_len = 0;
p_mac_len = new SQLLEN;
- if (p_mac_len != NULL )
- *p_mac_len = 0;
- else
- pfc_log_debug("ODBCM::DBVarbind:: Error in new: p_mac_len");
+ if (p_mac_len == NULL )
+ pfc_log_fatal("ODBCM::DBVarbind:: Error in new: p_mac_len");
+ *p_mac_len = 0;
p_speed_len = new SQLLEN;
- if (p_speed_len != NULL )
- *p_speed_len = 0;
- else
- pfc_log_debug("ODBCM::DBVarbind:: Error in new: p_speed_len");
+ if (p_speed_len == NULL )
+ pfc_log_fatal("ODBCM::DBVarbind:: Error in new: p_speed_len");
+ *p_speed_len = 0;
}
/**
/**
* @Description : To free the allocated memory in bind struct pointers
- * @param[in] : const uint32_t table_id, DBVarbind db_varbind
+ * @param[in] : table_id - enum of the tables
* @return : void
**/
void DBVarbind::FreeingBindedStructure(
const uint32_t table_id) {
switch (table_id) {
case UNKNOWN_TABLE:
- pfc_log_info("ODBCM::DBVarbind::FreeingBindedStructure: "
- "No table structure found ");
+ pfc_log_debug("ODBCM::DBVarbind::FreeingBindedStructure: "
+ "No table structure found id:%d", table_id);
break;
case CTR_TABLE:
if (NULL != p_ctr_table) {
case IS_ROW_EXISTS:
break;
default:
- pfc_log_info("ODBCM::DBVarbind::FreeingBindedStructure: "
+ pfc_log_debug("ODBCM::DBVarbind::FreeingBindedStructure: "
"Invalid table_id: %d", table_id);
}
}
/**
* @Description : To set the fptr with i/p or o/p binding functions
- * @param[in] : int table_id, int stream
+ * @param[in] : table_id - enum of the tables
+ * stream - Binding input/output
* @return : void
**/
void DBVarbind::SetBinding(int table_id, int stream) {
/**
* @Description : To set the fptr with i/p binding functions
- * @param[in] : int table_id
+ * @param[in] : table_id - enum of the tables
* @return : void
**/
void DBVarbind::BindingInput(int table_id) {
/**
* @Description : To set the fptr with o/p binding functions
- * @param[in] : int table_id
+ * @param[in] : table_id - enum of the tables
* @return : void
**/
void DBVarbind::BindingOutput(int table_id) {
}
/**
* @Description : To set the value struct for filling and fetching
- * @param[in] : int table_id, int stream
+ * @param[in] : table_id - enum of the tables
+ * stream - Binding input/output
* @return : void
**/
void DBVarbind::SetValueStruct(int table_id, int stream) {
}
}
-
/**
* @Description : This is special case - No table mapping
- * @param[in] : vector<TableAttrSchema> &column_attr
- * @return : ODBCM_RC_STATUS
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * @return : ODBCM_RC_ROW_EXISTS - if the row appears in the table
+ * ODBCM_RC_ROW_NOT_EXISTS - if there is no particular row
+ * in the table
**/
ODBCM_RC_STATUS DBVarbind::fetch_is_row_exists_status(
std::vector<TableAttrSchema> &column_attr) {
/**
* @Description : This is special case - No table mapping
- * @param[in] : vector<TableAttrSchema> &column_attr, HSTMT &r_hstmt
- * @return : ODBCM_RC_STATUS
+ * @param[in] : column_attr - DBTableSchema->rowlist_entry
+ * r_hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS - if all bind opertions success
+ * ODBCM_RC_PARAM_BIND_ERROR - if any one of the bind got failed
**/
ODBCM_RC_STATUS DBVarbind::bind_is_row_exists_output(
std::vector<TableAttrSchema> &column_attr, HSTMT &r_hstmt) {
* @file odbcm_mgr.cc
*
*/
-
#include "odbcm_mgr.hh"
#include "odbcm_db_tableschema.hh"
#include "odbcm_utils.hh"
#include "odbcm_query_factory.hh"
#include "odbcm_query_processor.hh"
#include "odbcm_db_varbind.hh"
+#include "odbcm_connection.hh"
using unc::uppl::ODBCManager;
extern pfc_cfdef_t odbcm_cfdef;
/** Initialize the SQLStateMap */
ODBCM_RC_STATUS rc = ODBCMUtils::Initialize_OdbcmSQLStateMap();
// rc = ODBCMUtils::Intialize_RCode_String();
- pfc_log_info("ODBCM::ODBCManager::Initialize: "
+ pfc_log_debug("ODBCM::ODBCManager::Initialize: "
"OdbcmSQLStateMap initialized:%s", ODBCMUtils::get_RC_Details(rc).c_str());
if (rc != ODBCM_RC_SUCCESS) {
pfc_log_error("ODBCM::ODBCManager::Initialize: "
"Error in db_table_list_map_ initialization ");
return ODBCM_RC_GENERAL_ERROR;
}
- pfc_log_info("ODBCM::ODBCManager::Initialize: "
+ pfc_log_debug("ODBCM::ODBCManager::Initialize: "
"db_table_list_map_ is initialized ");
+ /** Initialise the table columns name map */
+ if (ODBCM_RC_SUCCESS != initialize_odbcm_tables_column_map_()) {
+ pfc_log_error("ODBCM::ODBCManager::Initialize: "
+ "Error in odbcm_tables_column_map_ initialization ");
+ return ODBCM_RC_GENERAL_ERROR;
+ }
+ pfc_log_debug("ODBCM::ODBCManager::Initialize: "
+ "odbcm_tables_column_map_ is initialized ");
/** Parse the odbcm.conf to get odbc config information */
if (ODBCM_RC_SUCCESS != ParseConfigFile()) {
"Could not parse odbcm.conf !!");
return ODBCM_RC_GENERAL_ERROR;
}
- pfc_log_info("ODBCM::ODBCManager::Initialize: "
+ pfc_log_debug("ODBCM::ODBCManager::Initialize: "
"db_conf_info is updated");
-
/* Establish the database connection */
- if (ODBCM_RC_SUCCESS != OpenDBConnection()) {
+ if (ODBCM_RC_SUCCESS != InitializeConnectionEnv()) {
pfc_log_fatal("ODBCM::ODBCManager::Initialize: "
- "Could not establish Database Connection !!");
+ "Could not allocate connection environment !!");
return ODBCM_RC_CONNECTION_ERROR;
}
+
pfc_log_info("ODBCM::ODBCManager::Initialize: "
"ODBCM initialized !!!");
/**set Flag for the status of init*/
* During commit phase the row will be created in
* running configuration and the cs_row_status
* will be set accordingly.
- * @param[in] : unc_keytype_datatype_t , DBTableSchema &
- * @return : ODBCM_RC_STATUS
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * @return : ODBCM_RC_SUCCESS is returned when the row is created
+ * ODBCM_RC_* is returned when the row is not created
+ *
**/
ODBCM_RC_STATUS ODBCManager::CreateOneRow(unc_keytype_datatype_t db_name,
- DBTableSchema &db_table_schema ) {
+ DBTableSchema &db_table_schema,
+ OdbcmConnectionHandler *conn_obj) {
PHY_FINI_READ_LOCK();
/** Initialize all local variables */
- string insert_query; /* To store the db query */
+ string insert_query = ""; /* To store the db query */
SQLRETURN odbc_rc = ODBCM_RC_SUCCESS; /* SQL API rc */
ODBCM_RC_STATUS status = ODBCM_RC_SUCCESS; /* other method rc */
ODBCMTable table_id = UNKNOWN_TABLE;
- std::list < std::vector <TableAttrSchema> > rlist;
std::list < std::vector <TableAttrSchema> >::iterator iter_list;
/** Check the requested row already exists in database */
- status = IsRowExists(db_name, db_table_schema);
+ status = IsRowExists(db_name, db_table_schema, conn_obj);
pfc_log_info("ODBCM::ODBCManager::CreateOneRow: IsRowExists "
"returns: %s", ODBCMUtils::get_RC_Details(status).c_str());
if (status != ODBCM_RC_ROW_EXISTS &&
/** Allocate memory for statement, queryfactory,
* query processor and db_varbind objects */
HSTMT create_stmt = NULL;
- ODBCM_STATEMENT_CREATE(rw_conn_handle_, create_stmt);
+ SQLHDBC rw_conn_handle = conn_obj->get_conn_handle();
+ ODBCM_STATEMENT_CREATE(rw_conn_handle, create_stmt);
QueryFactory *query_factory = NULL;
ODBCM_CREATE_OBJECT(query_factory, QueryFactory);
QueryProcessor *query_processor = NULL;
"create row which is already exists but deleted in"
"previous transaction, clear will be called and "
"row creation will be allowed ");
- status = ClearOneRow(db_name, db_table_schema);
+ status = ClearOneRow(db_name, db_table_schema, conn_obj);
if (status != ODBCM_RC_SUCCESS) {
pfc_log_error("ODBCM::ODBCManager::CreateOneRow: "
"Error in Clearonerow so create not continued");
break;
case ROW_INVALID:
/* worst and corner case handling*/
- status = ClearOneRow(db_name, db_table_schema);
+ status = ClearOneRow(db_name, db_table_schema, conn_obj);
if (status != ODBCM_RC_SUCCESS) {
pfc_log_error("ODBCM::ODBCManager::CreateOneRow: "
"Error in Clearonerow so create not continued");
}
query_factory->SetOperation(CREATEONEROW);
/** Get table id enum value */
- table_id = get_table_id(db_table_schema.get_table_name());
+ table_id = db_table_schema.get_table_name();
if (table_id == UNKNOWN_TABLE) {
- pfc_log_error("ODBCM::ODBCManager::CreateOneRow: Unknown table: %s",
- db_table_schema.get_table_name().c_str());
+ pfc_log_error("ODBCM::ODBCManager::CreateOneRow: Unknown table: %d",
+ db_table_schema.get_table_name());
status = ODBCM_RC_TABLE_NOT_FOUND;
ODBCMFreeingMemory(create_stmt, table_id, db_varbind, query_factory,
query_processor);
query_processor);
return status;
}
- rlist = db_table_schema.get_row_list();
+ std::list < std::vector <TableAttrSchema> >& rlist =
+ db_table_schema.get_row_list();
/**to print the entire DBTableSchema object*/
- db_table_schema.PrintDBTableSchema();
+ // db_table_schema.PrintDBTableSchema();
/** Traverse the list to bind and execute */
if (rlist.size() > 1) {
- pfc_log_info("ODBCM::ODBCManager::CreateOneRow: "
+ pfc_log_debug("ODBCM::ODBCManager::CreateOneRow: "
"> 1 rows are received for DB operation, But 1st row only will be pushed"
"to Database");
}
CREATEONEROW, create_stmt);
if (status == ODBCM_RC_SUCCESS) {
/** Commit all active transactions on this connection */
- ODBCM_END_TRANSACTION(rw_conn_handle_, SQL_COMMIT);
- pfc_log_info("ODBCM::ODBCManager::CreateOneRow:row is created");
+ ODBCM_END_TRANSACTION(rw_conn_handle, SQL_COMMIT);
+ pfc_log_debug("ODBCM::ODBCManager::CreateOneRow:row is created");
} else {
/** Rollback all active transactions on this connection */
- ODBCM_END_TRANSACTION(rw_conn_handle_, SQL_ROLLBACK);
- pfc_log_info("ODBCM::ODBCManager::CreateOneRow:row is not created");
+ ODBCM_END_TRANSACTION(rw_conn_handle, SQL_ROLLBACK);
+ pfc_log_debug("ODBCM::ODBCManager::CreateOneRow:row is not created");
}
} else {
pfc_log_info("ODBCM::ODBCManager::CreateOneRow: No Data Received !");
* the row will be cleared out. In other databases,
* the entry will be deleted in this method and the
* transaction will be committed.
- * @param[in] : unc_keytype_datatype_t db_name, DBTableSchema db_table_schema
- * @return : ODBCM_RC_STATUS
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * @return : ODBCM_RC_SUCCESS is returned when the row is deleted
+ * ODBCM_RC_* is returned when the row is not deleted
**/
ODBCM_RC_STATUS ODBCManager::DeleteOneRow(unc_keytype_datatype_t db_name,
- DBTableSchema &db_table_schema ) {
+ DBTableSchema &db_table_schema,
+ OdbcmConnectionHandler *conn_obj ) {
PHY_FINI_READ_LOCK();
- string delete_query; // receiving the query from queryfactory
+ string delete_query = ""; // receiving the query from queryfactory
SQLRETURN odbc_rc = ODBCM_RC_SUCCESS; // SQL API rc
ODBCM_RC_STATUS status = ODBCM_RC_SUCCESS; // other method rc
ODBCMTable table_id = UNKNOWN_TABLE;
- std::list < std::vector <TableAttrSchema> > rlist;
std::list < std::vector <TableAttrSchema> >::iterator iter_list;
/* To check the row exists */
- status = IsRowExists(db_name, db_table_schema);
+ status = IsRowExists(db_name, db_table_schema, conn_obj);
if (status == ODBCM_RC_ROW_NOT_EXISTS ||
(status != ODBCM_RC_ROW_EXISTS &&
status != ODBCM_RC_ROW_NOT_EXISTS &&
/** Allocate memory for statement, queryfactory,
* query processor and db_varbind objects */
HSTMT delete_stmt = NULL;
- ODBCM_STATEMENT_CREATE(rw_conn_handle_, delete_stmt);
+ SQLHDBC rw_conn_handle = conn_obj->get_conn_handle();
+ ODBCM_STATEMENT_CREATE(rw_conn_handle, delete_stmt);
QueryFactory *query_factory = NULL;
ODBCM_CREATE_OBJECT(query_factory, QueryFactory);
QueryProcessor *query_processor = NULL;
DBVarbind *db_varbind = NULL;
ODBCM_CREATE_OBJECT(db_varbind, DBVarbind);
- rlist = db_table_schema.get_row_list();
- pfc_log_info("ODBCM::ODBCManager::DeleteOneRow: "
+ std::list < std::vector <TableAttrSchema> > & rlist =
+ db_table_schema.get_row_list();
+ pfc_log_debug("ODBCM::ODBCManager::DeleteOneRow: "
"IsRowExists status %s",
ODBCMUtils::get_RC_Details(status).c_str());
/** Fetch the cs_row_status value to compare further */
if (rs_value == DELETED) {
pfc_log_info("ODBCM::ODBCManager::DeleteOneRow: "
"Row exists but already in DELETED state ");
- ODBCM_RC_STATUS status = ClearOneRow(db_name, db_table_schema);
+ ODBCM_RC_STATUS status = ClearOneRow(db_name, db_table_schema, conn_obj);
if (status != ODBCM_RC_SUCCESS) {
pfc_log_error("ODBCM::ODBCManager::DeleteOneRow: "
"Error in ClearOneRow so delete not continued");
} // if
query_factory->SetOperation(DELETEONEROW);
/** Validate the table */
- table_id = get_table_id(db_table_schema.get_table_name());
+ table_id = db_table_schema.get_table_name();
if (table_id == UNKNOWN_TABLE) {
- pfc_log_error("ODBCM::ODBCManager::DeleteOneRow: Unknown table: %s",
- db_table_schema.get_table_name().c_str());
+ pfc_log_error("ODBCM::ODBCManager::DeleteOneRow: Unknown table: %d",
+ db_table_schema.get_table_name());
status = ODBCM_RC_TABLE_NOT_FOUND;
/** Freeing all allocated memory*/
ODBCMFreeingMemory(delete_stmt, table_id, db_varbind, query_factory,
query_processor);
return status;
}
- pfc_log_info("ODBCM::ODBCManager::DeleteOneRow: "
+ pfc_log_debug("ODBCM::ODBCManager::DeleteOneRow: "
"row_list size : %d ", static_cast<int>(rlist.size()));
- db_table_schema.PrintDBTableSchema();
+ // db_table_schema.PrintDBTableSchema();
if (rlist.size() > 1) {
- pfc_log_info("ODBCM::ODBCManager::DeleteOneRow: "
+ pfc_log_debug("ODBCM::ODBCManager::DeleteOneRow: "
"> 1 rows are received for DB operation,But 1st row only will be pushed"
"to Database");
}
}
if (status == ODBCM_RC_SUCCESS) {
/** Commit all active transactions on this connection*/
- ODBCM_END_TRANSACTION(rw_conn_handle_, SQL_COMMIT);
- pfc_log_info("ODBCM::ODBCManager::DeleteOneRow:row is deleted");
+ ODBCM_END_TRANSACTION(rw_conn_handle, SQL_COMMIT);
+ pfc_log_debug("ODBCM::ODBCManager::DeleteOneRow:row is deleted");
} else {
/** Rollback all active transactions on this connection*/
- ODBCM_END_TRANSACTION(rw_conn_handle_, SQL_ROLLBACK);
- pfc_log_info("ODBCM::ODBCManager::DeleteOneRow:row is not deleted");
+ ODBCM_END_TRANSACTION(rw_conn_handle, SQL_ROLLBACK);
+ pfc_log_debug("ODBCM::ODBCManager::DeleteOneRow:row is not deleted");
}
} else {
pfc_log_info("ODBCM::ODBCManager::DeleteOneRow: No Data Received !");
* During commit phase the update will be moved to
* running configuration and the row_status will be
* set accordingly.
- * @param[in] : unc_keytype_datatype_t db_name, DBTableSchema db_table_schema
- * @return : ODBCM_RC_STATUS
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * @return : ODBCM_RC_SUCCESS is returned when the row is updated
+ * ODBCM_RC_* is returned when the row is not updated
**/
ODBCM_RC_STATUS ODBCManager::UpdateOneRow(unc_keytype_datatype_t db_name,
- DBTableSchema &db_table_schema ) {
+ DBTableSchema &db_table_schema,
+ OdbcmConnectionHandler *conn_obj,
+ bool IsInternal) {
PHY_FINI_READ_LOCK();
/** Initialize all local variables */
- string update_query; // to store the query
+ string update_query = ""; // to store the query
SQLRETURN odbc_rc = ODBCM_RC_SUCCESS; // SQL API rc
ODBCM_RC_STATUS status = ODBCM_RC_SUCCESS; // other methods rc
ODBCMTable table_id = UNKNOWN_TABLE;
- std::list < std::vector <TableAttrSchema> > rlist;
std::list < std::vector <TableAttrSchema> >::iterator iter;
/** To check the row exists */
- status = IsRowExists(db_name, db_table_schema);
+ status = IsRowExists(db_name, db_table_schema, conn_obj);
if (status == ODBCM_RC_ROW_NOT_EXISTS ||
(status != ODBCM_RC_ROW_EXISTS &&
status != ODBCM_RC_ROW_NOT_EXISTS &&
}
/** Allocation for sql stmt */
HSTMT update_stmt = NULL;
- ODBCM_STATEMENT_CREATE(rw_conn_handle_, update_stmt);
+ SQLHDBC rw_conn_handle = conn_obj->get_conn_handle();
+ ODBCM_STATEMENT_CREATE(rw_conn_handle, update_stmt);
/** Create query_factory, query processor, dbvarbind obj */
QueryFactory *query_factory = NULL;
ODBCM_CREATE_OBJECT(query_factory, QueryFactory);
DBVarbind *db_varbind = NULL;
ODBCM_CREATE_OBJECT(db_varbind, DBVarbind);
- rlist = db_table_schema.get_row_list();
+ std::list < std::vector <TableAttrSchema> >& rlist =
+ db_table_schema.get_row_list();
pfc_log_info("ODBCM::ODBCManager::UpdateOneRow: "
"IsRowExists returns: %s",
ODBCMUtils::get_RC_Details(status).c_str());
if (rs_value == DELETED) {
pfc_log_info("ODBCM::ODBCManager::UpdateOneRow: Row exists with"
"DELETED state so ClearOneRow will be called");
- ODBCM_RC_STATUS status = ClearOneRow(db_name, db_table_schema);
+ ODBCM_RC_STATUS status = ClearOneRow(db_name, db_table_schema, conn_obj);
if (status != ODBCM_RC_SUCCESS) {
pfc_log_debug("ODBCM::ODBCManager::UpdateOneRow: "
"ClearOneRow is not succeeded, update not continued");
query_factory->SetOperation(UPDATEONEROW);
/** Prepare the sql command */
- update_query = (query_factory->*query_factory->GetQuery)(
- db_name, db_table_schema);
+ update_query = (query_factory->*query_factory->GetQueryWithBool)(
+ db_name, db_table_schema, IsInternal);
if (update_query.empty()) {
pfc_log_error("ODBCM::ODBCManager::UpdateOneRow: "
"Error in framing the SQL query");
return status;
}
/** Get table id enum value*/
- table_id = get_table_id(db_table_schema.get_table_name());
+ table_id = db_table_schema.get_table_name();
if (table_id == UNKNOWN_TABLE) {
pfc_log_error("ODBCM::ODBCManager::UpdateOneRow: "
- "Unknown table:%s",
- db_table_schema.get_table_name().c_str());
+ "Unknown table:%d",
+ db_table_schema.get_table_name());
status = ODBCM_RC_TABLE_NOT_FOUND;
/* Freeing all allocated memory */
ODBCMFreeingMemory(update_stmt, table_id, db_varbind, query_factory,
return status;
}
if (rlist.size() > 1) {
- pfc_log_info("ODBCM::ODBCManager::UpdateOneRow: "
+ pfc_log_debug("ODBCM::ODBCManager::UpdateOneRow: "
"> 1 rows are received for DB operation,But 1st row only will be pushed"
"to Database");
}
- db_table_schema.PrintDBTableSchema();
+ // db_table_schema.PrintDBTableSchema();
iter = rlist.begin();
if (iter != rlist.end()) {
/** Removing the primarykey values from vector */
iter_vector = (*iter).begin();
for (uint32_t loop = 0; loop < (*iter).size(); loop++) {
- pfc_log_debug("ODBCM::ODBCManager::UpdateOneRow: %s",
- (*iter_vector).table_attribute_name.c_str());
+ pfc_log_debug("ODBCM::ODBCManager::UpdateOneRow: %d",
+ (*iter_vector).table_attribute_name);
iter_vector++;
}
if ((*iter).size() < pkey_size) {
} else {
pfc_log_debug("ODBCM::ODBCManager::UpdateOneRow: "
"Vector size with pkeys %d", static_cast<int>((*iter).size()));
- if ((*iter).size() >= pkey_size)
- (*iter).erase((*iter).begin(), (*iter).begin() + pkey_size);
- pfc_log_debug("ODBCM::ODBCManager::UpdateOneRow: primary keys"
- " value are removed from attributes_vector to skip from update."
- " vector size = %d", static_cast<int>((*iter).size()));
+ if ((*iter).size() >= pkey_size) {
+ uint32_t index = 0;
+ for (iter_vector = (*iter).begin();
+ iter_vector != (*iter).end(), index < pkey_size;
+ ++index) {
+ if ((*iter_vector).p_table_attribute_value != NULL) {
+ ::operator delete((*iter_vector).p_table_attribute_value);
+ (*iter_vector).p_table_attribute_value = NULL;
+ }
+ iter_vector = (*iter).erase(iter_vector);
+ }
+ pfc_log_debug("ODBCM::ODBCManager::UpdateOneRow: primary keys"
+ " value are removed from attributes_vector to skip from update."
+ " vector size = %d", static_cast<int>((*iter).size()));
+ }
}
} else {
pfc_log_debug("ODBCM::ODBCManager::UpdateOneRow: No Data Received !");
CREATEONEROW, update_stmt);
if (status == ODBCM_RC_SUCCESS) {
/** Commit all active transactions on this connection*/
- ODBCM_END_TRANSACTION(rw_conn_handle_, SQL_COMMIT);
+ ODBCM_END_TRANSACTION(rw_conn_handle, SQL_COMMIT);
pfc_log_info("ODBCM::ODBCManager::UpdateOneRow:row is updated");
} else {
/** Rollback all active transactions on this connection*/
- ODBCM_END_TRANSACTION(rw_conn_handle_, SQL_ROLLBACK);
+ ODBCM_END_TRANSACTION(rw_conn_handle, SQL_ROLLBACK);
pfc_log_info("ODBCM::ODBCManager::UpdateOneRow:row is not updated");
}
} else {
* database table and return the result set
* (fill the table rows in the DBTableSchema ref)
* and return the status to caller
- * @param[in] : unc_keytype_datatype_t db_name, DBTableSchema db_table_schema
- * @return : ODBCM_RC_STATUS
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * @param[out] : DBTableSchema db_table_schema
+ * @return : ODBCM_RC_SUCCESS is returned when the GetOneRow is
+ * success otherwise DB related error code will be
+ * returned
**/
ODBCM_RC_STATUS ODBCManager::GetOneRow(
unc_keytype_datatype_t db_name,
- DBTableSchema &db_table_schema) {
+ DBTableSchema &db_table_schema, OdbcmConnectionHandler *conn_obj) {
PHY_FINI_READ_LOCK();
/** Initialise the local variables */
- string getone_query; /* to receive the query from queryfactory */
+ string getone_query = ""; /* to receive the query from queryfactory */
SQLRETURN odbc_rc = ODBCM_RC_SUCCESS; // SQL API rc
ODBCM_RC_STATUS status = ODBCM_RC_SUCCESS; // Other method rc
ODBCMTable table_id = UNKNOWN_TABLE;
- std::list < std::vector <TableAttrSchema> > rlist;
std::list < std::vector <TableAttrSchema> >::iterator iter_list;
HSTMT read_stmt = NULL; /* statement for getonerow */
- ODBCM_STATEMENT_CREATE(ro_conn_handle_, read_stmt);
+ SQLHDBC ro_conn_handle = conn_obj->get_conn_handle();
+ ODBCM_STATEMENT_CREATE(ro_conn_handle, read_stmt);
/** DBTableSchema row_list - get from parameter */
- rlist = db_table_schema.get_row_list();
+ std::list < std::vector <TableAttrSchema> >& rlist =
+ db_table_schema.get_row_list();
/** iterate all rows in vector */
/** Create query_factory and query processor objects */
return status;
}
/** Get table id */
- table_id = get_table_id(db_table_schema.get_table_name());
+ table_id = db_table_schema.get_table_name();
if (table_id == UNKNOWN_TABLE) {
pfc_log_error("ODBCM::ODBCManager::GetOneRow: "
- "Unknown table: %s",
- db_table_schema.get_table_name().c_str());
+ "Unknown table: %d",
+ db_table_schema.get_table_name());
status = ODBCM_RC_TABLE_NOT_FOUND;
/* Freeing all allocated memory */
ODBCMFreeingMemory(read_stmt, table_id, db_varbind, query_factory,
pfc_log_error("ODBCM::ODBCManager::GetOneRow:No input data Received!");
}
db_table_schema.set_row_list(rlist);
- db_table_schema.PrintDBTableSchema();
+ // db_table_schema.PrintDBTableSchema();
/* Freeing all allocated memory */
ODBCMFreeingMemory(read_stmt, table_id, db_varbind, query_factory,
query_processor);
* table, based on the condition given in the
* DBTableSchema the row will be identified
* and deleted permanently.
- * @param[in] : unc_keytype_datatype_t db_name, DBTableSchema db_table_schema
- * @return : ODBCM_RC_STATUS
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * @return : ODBCM_RC_SUCCESS is returned when the ClearOneRow is
+ * success otherwise DB related error code will be
+ * returned
**/
ODBCM_RC_STATUS ODBCManager::ClearOneRow(unc_keytype_datatype_t db_name,
- DBTableSchema &db_table_schema) {
+ DBTableSchema &db_table_schema,
+ OdbcmConnectionHandler *conn_obj) {
PHY_FINI_READ_LOCK();
- string clearone_query; // to store the query
+ string clearone_query = ""; // to store the query
SQLRETURN odbc_rc = ODBCM_RC_SUCCESS; // SQL API rc
ODBCM_RC_STATUS status = ODBCM_RC_SUCCESS; // other methods rc
ODBCMTable table_id = UNKNOWN_TABLE;
- std::list < std::vector <TableAttrSchema> > rlist;
std::list < std::vector <TableAttrSchema> >::iterator iter_list;
/** statement for clearonerow */
HSTMT clearone_stmt = NULL;
- ODBCM_STATEMENT_CREATE(rw_conn_handle_, clearone_stmt);
+ SQLHDBC rw_conn_handle = conn_obj->get_conn_handle();
+ ODBCM_STATEMENT_CREATE(rw_conn_handle, clearone_stmt);
/** Create query_factory and query processor objects */
QueryFactory *query_factory = NULL;
ODBCM_CREATE_OBJECT(query_factory, QueryFactory);
ODBCM_CREATE_OBJECT(db_varbind, DBVarbind);
/** DBTableSchema row_list - get from parameter */
- rlist = db_table_schema.get_row_list();
+ std::list < std::vector <TableAttrSchema> >& rlist =
+ db_table_schema.get_row_list();
/** To iterate entire vector */
/** Set function ptr to construct the query in queryfactory */
query_factory->SetOperation(CLEARONEROW);
return status;
}
/** Get table id enum value */
- table_id = get_table_id(db_table_schema.get_table_name());
+ table_id = db_table_schema.get_table_name();
if (table_id == UNKNOWN_TABLE) {
pfc_log_error("ODBCM::ODBCManager::ClearOneRow:: "
- "Unknown table: %s", db_table_schema.get_table_name().c_str());
+ "Unknown table: %d", db_table_schema.get_table_name());
status = ODBCM_RC_TABLE_NOT_FOUND;
/* Freeing all allocated memory */
ODBCMFreeingMemory(clearone_stmt, table_id, db_varbind, query_factory,
return status;
}
- db_table_schema.PrintDBTableSchema();
+ // db_table_schema.PrintDBTableSchema();
iter_list = rlist.begin();
if (iter_list != rlist.end()) {
/** to filling the values into binded structure variables */
CLEARONEROW, clearone_stmt);
if (status == ODBCM_RC_SUCCESS) {
/** Commit all active transactions on this connection*/
- ODBCM_END_TRANSACTION(rw_conn_handle_, SQL_COMMIT);
+ ODBCM_END_TRANSACTION(rw_conn_handle, SQL_COMMIT);
pfc_log_info("ODBCM::ODBCManager::ClearOneRow:row is cleared");
} else {
/** Rollback all active transactions on this connection*/
- ODBCM_END_TRANSACTION(rw_conn_handle_, SQL_ROLLBACK);
+ ODBCM_END_TRANSACTION(rw_conn_handle, SQL_ROLLBACK);
pfc_log_info("ODBCM::ODBCManager::ClearOneRow:row is not cleared");
}
} else {
* table. Database name is the first parameter,
* other key, primary key details are must be
* provided in DBTableSchema
- * @param[in] : unc_keytype_datatype_t db_name,
- * DBTableSchema db_table_schema
- * @return : ODBCM_RC_STATUS
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * @return : ODBCM_RC_SUCCESS is returned when the row is exits in DB
+ * success otherwise DB related error code will be
+ * returned
**/
ODBCM_RC_STATUS ODBCManager::IsRowExists(
unc_keytype_datatype_t db_name,
- DBTableSchema &db_table_schema) {
+ DBTableSchema &db_table_schema, OdbcmConnectionHandler *conn_obj) {
PHY_FINI_READ_LOCK();
/** Initialise the local variables */
- string query; // to store the query
+ string query = ""; // to store the query
ODBCM_RC_STATUS status = ODBCM_RC_SUCCESS; // other methods rc
SQLRETURN odbc_rc = ODBCM_RC_SUCCESS; // SQL APIs rc
ODBCMTable table_id = UNKNOWN_TABLE;
}
/** Statement for isrowexists */
HSTMT rowexists_stmt = NULL;
- ODBCM_STATEMENT_CREATE(ro_conn_handle_, rowexists_stmt);
+ SQLHDBC ro_conn_handle = conn_obj->get_conn_handle();
+ ODBCM_STATEMENT_CREATE(ro_conn_handle, rowexists_stmt);
/** Create query_factory and query processor objects */
QueryFactory *query_factory = NULL;
ODBCM_CREATE_OBJECT(query_factory, QueryFactory);
return status;
}
/** Get table id enum value */
- table_id = get_table_id(db_table_schema.get_table_name());
+ table_id = db_table_schema.get_table_name();
if (table_id == UNKNOWN_TABLE) {
pfc_log_error("ODBCM::ODBCManager::IsRowExists: "
- "Unknown table: %s", db_table_schema.get_table_name().c_str());
+ "Unknown table: %d", db_table_schema.get_table_name());
status = ODBCM_RC_TABLE_NOT_FOUND;
/* Freeing all allocated memory */
ODBCMFreeingMemory(rowexists_stmt, table_id, db_varbind, query_factory,
db_varbind->SetBinding(IS_ROW_EXISTS, BIND_OUT);
db_varbind->SetValueStruct(IS_ROW_EXISTS, BIND_OUT);
- db_table_schema.PrintDBTableSchema();
+ // db_table_schema.PrintDBTableSchema();
/** To fill the values into binded structure variables */
status = (db_varbind->*db_varbind->FillINPUTValues)((*iter_list));
if (status != ODBCM_RC_SUCCESS) {
/* Freeing all allocated memory */
if (NULL != db_varbind->p_isrowexists) {
delete db_varbind->p_isrowexists;
- pfc_log_info("ODBCM::ODBCManager::IsRowExists: p_isrowexists is freed");
+ pfc_log_debug("ODBCM::ODBCManager::IsRowExists: p_isrowexists is freed");
}
ODBCMFreeingMemory(rowexists_stmt, table_id, db_varbind, query_factory,
query_processor);
/* Freeing all allocated memory */
if (NULL != db_varbind->p_isrowexists) {
delete db_varbind->p_isrowexists;
- pfc_log_info("ODBCM::ODBCManager::IsRowExists: p_isrowexists is freed");
+ pfc_log_debug("ODBCM::ODBCManager::IsRowExists: p_isrowexists is freed");
}
ODBCMFreeingMemory(rowexists_stmt, table_id, db_varbind, query_factory,
query_processor);
// Output bind structure free
if (NULL != db_varbind->p_isrowexists) {
delete db_varbind->p_isrowexists;
- pfc_log_info("ODBCM::ODBCManager::IsRowExists: p_isrowexists is freed");
+ pfc_log_debug("ODBCM::ODBCManager::IsRowExists: p_isrowexists is freed");
}
ODBCMFreeingMemory(rowexists_stmt, table_id, db_varbind, query_factory,
query_processor);
default:
break;
}
- pfc_log_info("ODBCM::ODBCManager::IsRowExists: "
+ pfc_log_debug("ODBCM::ODBCManager::IsRowExists: "
"db_table_schema.db_return_status_ = %d ",
db_table_schema.db_return_status_);
}
// Output bind structure free
if (NULL != db_varbind->p_isrowexists) {
delete db_varbind->p_isrowexists;
- pfc_log_info("ODBCM::ODBCManager::IsRowExists: p_isrowexists is freed");
+ pfc_log_debug("ODBCM::ODBCManager::IsRowExists: p_isrowexists is freed");
}
ODBCMFreeingMemory(rowexists_stmt, table_id, db_varbind, query_factory,
query_processor);
* @Description : This method will fetch the one or more number of
* rows in the db table based upon the given
* max_repetition_count & condition or filter criteria.
- * @param[in] : unc_data_type_t db_name,
- * uint32_t max_repetition_count,
- * DBTableSchema &db_table_schema,
- * unc_keytype_operation_t op_type
- * @return : ODBCM_RC_STATUS
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * max_repetition_count -specifies number of rows to be returned
+ * unc_keytype_operation_t - specifies any additional
+ * condition for GetBulkRows operation
+ * @param[out] : DBTableSchema &db_table_schema,
+ * @return : ODBCM_RC_SUCCESS is returned when the rows are read from DB
+ * otherwise DB related error code will be returned
**/
ODBCM_RC_STATUS ODBCManager::GetBulkRows(
unc_keytype_datatype_t db_name,
uint32_t max_repetition_count,
DBTableSchema &db_table_schema,
- unc_keytype_operation_t op_type) {
+ unc_keytype_operation_t op_type, OdbcmConnectionHandler *conn_obj) {
PHY_FINI_READ_LOCK();
/** Initialize the local variables */
- string getbulk_query; // to store query
+ string getbulk_query = ""; // to store query
SQLRETURN odbc_rc = ODBCM_RC_SUCCESS; // SQL API rc
ODBCM_RC_STATUS status = ODBCM_RC_SUCCESS; // other methods rc
SQLLEN row_count = 0;
ODBCMTable table_id = UNKNOWN_TABLE;
- std::list < std::vector <TableAttrSchema> > rlist;
std::list < std::vector <TableAttrSchema> >::iterator it_vect;
- rlist = db_table_schema.get_row_list();
+ std::list < std::vector <TableAttrSchema> > & rlist =
+ db_table_schema.get_row_list();
it_vect = rlist.begin();
if (it_vect == rlist.end()) {
pfc_log_info("ODBCM::ODBCManager::GetBulkRows:No input data received !");
/** Allocate stmt handle only if the connection
* was successfully created */
HSTMT read_stmt = NULL;
- ODBCM_STATEMENT_CREATE(ro_conn_handle_, read_stmt);
+ SQLHDBC ro_conn_handle = conn_obj->get_conn_handle();
+ ODBCM_STATEMENT_CREATE(ro_conn_handle, read_stmt);
/** Create query_factory and query processor objects */
QueryFactory *query_factory = NULL;
ODBCM_CREATE_OBJECT(query_factory, QueryFactory);
/** Set the operation for GETBULKROWS */
query_factory->SetOperation(GETBULKROWS);
- pfc_log_info("ODBCM::ODBCManager: GetBulkRows: "
+ pfc_log_debug("ODBCM::ODBCManager: GetBulkRows: "
"Request with max_repetition_count: %d, op_type: %d",
max_repetition_count, op_type);
return status;
}
/** Get table id */
- table_id = get_table_id(db_table_schema.get_table_name());
+ table_id = db_table_schema.get_table_name();
if (table_id == UNKNOWN_TABLE) {
pfc_log_error("ODBCM::ODBCManager::GetBulkRows: "
- "Unknown table: %s", db_table_schema.get_table_name().c_str());
+ "Unknown table: %d", db_table_schema.get_table_name());
status = ODBCM_RC_TABLE_NOT_FOUND;
/* Freeing all allocated memory */
ODBCMFreeingMemory(read_stmt, table_id, db_varbind, query_factory,
query_processor);
return status;
}
- pfc_log_info("ODBCM::ODBCManager::GetBulkRows: "
+ pfc_log_debug("ODBCM::ODBCManager::GetBulkRows: "
"Row count = %ld", row_count);
if (row_count < 0) {
pfc_log_debug("ODBCM::ODBCManager::GetBulkRows: "
}
}
db_table_schema.set_row_list(rlist);
- pfc_log_info("ODBCM::ODBCManager::GetBulkRows:dbtableschema list size: %d",
+ pfc_log_debug("ODBCM::ODBCManager::GetBulkRows:dbtableschema list size: %d",
static_cast<int>(db_table_schema.row_list_.size()));
status = ODBCM_RC_SUCCESS;
- db_table_schema.PrintDBTableSchema();
+ // db_table_schema.PrintDBTableSchema();
/* Freeing all allocated memory */
ODBCMFreeingMemory(read_stmt, table_id, db_varbind, query_factory,
query_processor);
* rows after Ctr2 i.e 2 if the given row does
* not exists, the next row will be identified
* and process accordingly.
- * @param[in] : unc_keytype_datatype_t , DBTableSchema , [out]count
- * @return : ODBCM_RC_STATUS
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * @param[in] : unc_keytype_datatype_t , DBTableSchema
+ * @param[out] : uint32_t count
+ * @return : ODBCM_RC_SUCCESS is returned when the siblingcount
+ * received from DB
+ * otherwise DB related error code will be
+ * returned
**/
ODBCM_RC_STATUS ODBCManager::GetSiblingCount(
unc_keytype_datatype_t db_name,
DBTableSchema& db_table_schema,
- uint32_t& count) {
+ uint32_t& count, OdbcmConnectionHandler *conn_obj) {
PHY_FINI_READ_LOCK();
// Initialise the local variables
std::string QUERY("\0"); // to receive the query from queryfactory
ODBCMTable table_id = UNKNOWN_TABLE;
HSTMT stmt = NULL; // statement for getsiblingcount
+ SQLHDBC ro_conn_handle = conn_obj->get_conn_handle();
/* Do sql allocate for sql stmt */
- ODBCM_STATEMENT_CREATE(ro_conn_handle_, stmt);
+ ODBCM_STATEMENT_CREATE(ro_conn_handle, stmt);
/** Create query_factory and query processor objects */
QueryFactory *query_factory = NULL;
return status;
}
/** Validate the table information */
- table_id = get_table_id(db_table_schema.get_table_name());
+ table_id = db_table_schema.get_table_name();
if (table_id == UNKNOWN_TABLE) {
pfc_log_error("ODBCM::ODBCManager::GetSiblingCount: "
- "Error unknown table: %s", db_table_schema.get_table_name().c_str());
+ "Error Unknown table: %d", db_table_schema.get_table_name());
status = ODBCM_RC_TABLE_NOT_FOUND;
/* Freeing all allocated memory */
ODBCMFreeingMemory(stmt, table_id, db_varbind, query_factory,
/**
* @Description : This method will get the row count of the given table
- * @param[in] : unc_data_type_t ,string ctr_name, [out] count
- * @return : ODBCM_RC_STATUS
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * table_name - specifies the table name in DB
+ * @param[out] : count - specifies the row count
+ * @return : ODBCM_RC_SUCCESS is returned when the row count
+ * received from DB otherwise DB related error
+ * code will be returned
**/
ODBCM_RC_STATUS ODBCManager::GetRowCount(
unc_keytype_datatype_t db_name,
string table_name,
- uint32_t &count) {
+ uint32_t &count, OdbcmConnectionHandler *conn_obj) {
PHY_FINI_READ_LOCK();
/** Initialize the local variables */
SQLLEN row_count = 0; // to store rowcount
SQLRETURN odbc_rc = ODBCM_RC_SUCCESS; // SQL API rc
- std::string query; // query from queryfactory
+ std::string query = ""; // query from queryfactory
ODBCM_RC_STATUS status = ODBCM_RC_SUCCESS; // other method rc
HSTMT stmt = NULL; // statement for getrowcount
QueryFactory *query_factory = NULL;
/** Initialise the count value */
count = 0;
+ SQLHDBC ro_conn_handle = conn_obj->get_conn_handle();
/** Do sql allocate for sql stmt */
- ODBCM_STATEMENT_CREATE(ro_conn_handle_, stmt);
+ ODBCM_STATEMENT_CREATE(ro_conn_handle, stmt);
/** Create query_factory and query processor objects */
ODBCM_CREATE_OBJECT(query_factory, QueryFactory);
ODBCM_CREATE_OBJECT(query_processor, QueryProcessor);
* We get a request: GetModifiedRows(DBTableSchema(CREATED));
* The database output will be filled in DBTableSchema
*
- * @param[in] : unc_keytype_datatype_t db_name, DBTableSchema db_table_schema
- * @return : ODBCM_RC_STATUS
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * @param[out] : DBTableSchema db_table_schema
+ * @return : ODBCM_RC_SUCCESS is returned when the modified rows
+ * received from DB otherwise DB related error
+ * code will be returned
**/
ODBCM_RC_STATUS ODBCManager::GetModifiedRows(
unc_keytype_datatype_t db_name,
- DBTableSchema& db_table_schema) {
+ DBTableSchema& db_table_schema, OdbcmConnectionHandler *conn_obj) {
PHY_FINI_READ_LOCK();
std::string QUERY("\0");
SQLRETURN odbc_rc = ODBCM_RC_SUCCESS;
SQLLEN iRow_count = 0;
std::list <std::vector<TableAttrSchema> >::iterator i_list;
std::vector<TableAttrSchema> :: iterator iter_vector;
- std::list < std::vector <TableAttrSchema> > rlist;
if (db_name != UNC_DT_CANDIDATE) {
pfc_log_debug("ODBCM::ODBCManager::GetModifiedRows: "
- "This operation does not supported for %s ",
- db_table_schema.table_name_.c_str());
+ "This operation does not supported for %d ",
+ db_table_schema.table_name_);
return ODBCM_RC_TABLE_NOT_FOUND;
}
- rlist = db_table_schema.get_row_list();
+ std::list < std::vector <TableAttrSchema> >& rlist =
+ db_table_schema.get_row_list();
i_list = rlist.begin();
if (i_list == rlist.end()) {
pfc_log_info("ODBCM::ODBCManager::GetModifiedRows:"
}
HSTMT get_stmt = NULL;
+ SQLHDBC ro_conn_handle = conn_obj->get_conn_handle();
/* Do sql allocate for sql stmt */
- ODBCM_STATEMENT_CREATE(ro_conn_handle_, get_stmt);
+ ODBCM_STATEMENT_CREATE(ro_conn_handle, get_stmt);
QueryFactory *query_factory = NULL;
ODBCM_CREATE_OBJECT(query_factory, QueryFactory);
}
/* Validate the table information */
- table_id = get_table_id(db_table_schema.get_table_name());
+ table_id = db_table_schema.get_table_name();
if (table_id == UNKNOWN_TABLE) {
pfc_log_error("ODBCM::ODBCManager::GetModifiedRows: "
- "Error unknown table: %s",
- db_table_schema.get_table_name().c_str());
+ "Error Unknown table: %d",
+ db_table_schema.get_table_name());
status = ODBCM_RC_TABLE_NOT_FOUND;
/* Freeing all allocated memory */
ODBCMFreeingMemory(get_stmt, table_id, db_varbind, query_factory,
}
db_table_schema.set_row_list(rlist);
- pfc_log_info("ODBCM::ODBCManager::GetModifiedRows:"
+ pfc_log_debug("ODBCM::ODBCManager::GetModifiedRows:"
"dbtableschema list size: %d",
static_cast<int>(db_table_schema.row_list_.size()));
status = ODBCM_RC_SUCCESS;
- db_table_schema.PrintDBTableSchema();
+ // db_table_schema.PrintDBTableSchema();
/** Freeing all allocated memory */
ODBCMFreeingMemory(get_stmt, table_id, db_varbind, query_factory,
query_processor);
/**
* @Description : To get the sibling rows count based upon given filter
- * @param[in] : unc_keytype_datatype_t db_name, string controller_name
- * @return : ODBCM_RC_STATUS
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * filter_operators - vector to decide the filter while
+ * framing query
+ * @param[out] : count - To return the sibling row count
+ * @return : ODBCM_RC_SUCCESS is returned when the row count
+ * received from DB otherwise DB related error
+ * code will be returned
**/
ODBCM_RC_STATUS ODBCManager::GetSiblingCount(
- unc_keytype_datatype_t db_name /**Database type*/,
- DBTableSchema& db_table_schema /**table,pkeys,column names with data type*/,
- uint32_t& count/**return value count*/,
- std::vector<ODBCMOperator> filter_operators
- /** Operator to decide the filter while framing query (where clause) */) {
+ unc_keytype_datatype_t db_name,
+ DBTableSchema& db_table_schema,
+ uint32_t& count,
+ std::vector<ODBCMOperator> filter_operators,
+ OdbcmConnectionHandler *conn_obj) {
PHY_FINI_READ_LOCK();
/** To receive the query from queryfactory*/
std::string QUERY("\0");
ODBCMTable table_id = UNKNOWN_TABLE;
/**Statement handler*/
HSTMT stmt = NULL;
+ SQLHDBC ro_conn_handle = conn_obj->get_conn_handle();
/* sql handle allocate for sql stmt */
- ODBCM_STATEMENT_CREATE(ro_conn_handle_, stmt);
+ ODBCM_STATEMENT_CREATE(ro_conn_handle, stmt);
/** Create query_factory object */
QueryFactory *query_factory = NULL;
ODBCM_CREATE_OBJECT(query_factory, QueryFactory);
return status;
}
/** Validate the table information */
- table_id = get_table_id(db_table_schema.get_table_name());
+ table_id = db_table_schema.get_table_name();
if (table_id == UNKNOWN_TABLE) {
pfc_log_error("ODBCM::ODBCManager::GetSiblingCount(with filter): "
- "Error unknown table: %s",
- db_table_schema.get_table_name().c_str());
+ "Error Unknown table: %d",
+ db_table_schema.get_table_name());
status = ODBCM_RC_TABLE_NOT_FOUND;
/* Freeing all allocated memory */
ODBCMFreeingMemory(stmt, table_id, db_varbind, query_factory,
/**
* @Description : To return the sibiling rows in the given table and
* based upon the given filter criteria
- * @param[in] : unc_keytype_datatype_t db_name, string controller_name
- * @return : ODBCM_RC_STATUS
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * max_repetition_count - specifies the number of rows
+ * to return
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * filter_operators - vector to decide the filter while
+ * framing query
+ * op_type - specifies Operation type siblingbegin/sibling
+ * @param[out] : DBTableSchema& db_table_schema
+ * @return : ODBCM_RC_SUCCESS is returned when the siblingrows
+ * received from DB otherwise DB related error
+ * code will be returned
**/
ODBCM_RC_STATUS ODBCManager::GetSiblingRows(
- unc_keytype_datatype_t db_name, // database type */
- uint32_t max_repetition_count, // maximum repetition count*/
- DBTableSchema& db_table_schema, // table,pkeys,column names with data type
+ unc_keytype_datatype_t db_name,
+ uint32_t max_repetition_count,
+ DBTableSchema& db_table_schema,
std::vector<ODBCMOperator> filter_operators,
- /** Arithmetic operators to frame read sibling query*/
- unc_keytype_operation_t op_type
- /** Operation type siblingbegin/sibling*/) {
+ unc_keytype_operation_t op_type,
+ OdbcmConnectionHandler *conn_obj) {
PHY_FINI_READ_LOCK();
/** To receive the query from query factory*/
std::string QUERY("\0");
/** To traverse the row list in db_table_schmea */
std::list <std::vector<TableAttrSchema> >::iterator it_vect;
/** To traverse the row lists vectors in db_table_schmea */
- std::list < std::vector <TableAttrSchema> > rlist =
+ std::list < std::vector <TableAttrSchema> >& rlist =
db_table_schema.get_row_list();
it_vect = rlist.begin();
if (it_vect == rlist.end()) {
return ODBCM_RC_FAILED;
}
HSTMT get_stmt = NULL;
+ SQLHDBC ro_conn_handle = conn_obj->get_conn_handle();
/* Do sql allocate for sql stmt */
- ODBCM_STATEMENT_CREATE(ro_conn_handle_, get_stmt);
+ ODBCM_STATEMENT_CREATE(ro_conn_handle, get_stmt);
QueryFactory *query_factory = NULL;
ODBCM_CREATE_OBJECT(query_factory, QueryFactory);
return status;
}
/** Validate the table information */
- table_id = get_table_id(db_table_schema.get_table_name());
+ table_id = db_table_schema.get_table_name();
if (table_id == UNKNOWN_TABLE) {
pfc_log_error("ODBCM::ODBCManager::GetSiblingRows: "
- "Unknown table: %s",
- db_table_schema.get_table_name().c_str());
+ "Unknown table: %d",
+ db_table_schema.get_table_name());
status = ODBCM_RC_TABLE_NOT_FOUND;
/* Freeing all allocated memory */
ODBCMFreeingMemory(get_stmt, table_id, db_varbind, query_factory,
return status;
}
/** Get table id */
- table_id = get_table_id(db_table_schema.get_table_name());
+ table_id = db_table_schema.get_table_name();
if (table_id == UNKNOWN_TABLE) {
pfc_log_error("ODBCM::ODBCManager::GetSiblingRows: "
- "Error Unknown table: %s",
- db_table_schema.get_table_name().c_str());
+ "Error Unknown table: %d",
+ db_table_schema.get_table_name());
status = ODBCM_RC_TABLE_NOT_FOUND;
/* Freeing all allocated memory */
ODBCMFreeingMemory(get_stmt, table_id, db_varbind, query_factory,
}
pfc_log_info("ODBCM::ODBCManager::GetSiblingRows: "
"Row count = %ld", iRow_count);
- if (iRow_count < 0) {
+ if (iRow_count <= 0) {
pfc_log_debug("ODBCM::ODBCManager::GetSiblingRows: "
"No more record found ");
status = ODBCM_RC_RECORD_NO_MORE;
}
db_table_schema.set_row_list(rlist);
- pfc_log_info("ODBCM::ODBCManager::GetSiblingRows: "
+ pfc_log_debug("ODBCM::ODBCManager::GetSiblingRows: "
"dbtableschema list size:%d",
static_cast<int>(db_table_schema.row_list_.size()));
status = ODBCM_RC_SUCCESS;
- db_table_schema.PrintDBTableSchema();
+ // db_table_schema.PrintDBTableSchema();
/* Freeing all allocated memory */
ODBCMFreeingMemory(get_stmt, table_id, db_varbind, query_factory,
query_processor);
#include "odbcm_db_varbind.hh"
#include "odbcm_utils.hh"
#include "physicallayer.hh"
+#include "odbcm_connection.hh"
using unc::uppl::ODBCManager;
using std::string;
+using unc::uppl::OdbcmConnectionHandler;
+
+/**
+ * @Description : Function to get the table name using table_id
+ * @param[in] : ODBCMTable
+ * @return : std::string
+ **/
+std::string ODBCManager::GetTableName(ODBCMTable table_id) {
+ switch (table_id) {
+ case CTR_TABLE:
+ return UPPL_CTR_TABLE;
+ case CTR_DOMAIN_TABLE:
+ return UPPL_CTR_DOMAIN_TABLE;
+ case LOGICALPORT_TABLE:
+ return UPPL_LOGICALPORT_TABLE;
+ case LOGICAL_MEMBERPORT_TABLE:
+ return UPPL_LOGICAL_MEMBER_PORT_TABLE;
+ case SWITCH_TABLE:
+ return UPPL_SWITCH_TABLE;
+ case PORT_TABLE:
+ return UPPL_PORT_TABLE;
+ case LINK_TABLE:
+ return UPPL_LINK_TABLE;
+ case BOUNDARY_TABLE:
+ return UPPL_BOUNDARY_TABLE;
+ default:
+ return "";
+ }
+}
/**
* @Description : clear the entries in the database tables.
- * @param[in] : unc_keytype_datatype_t
- * @return : ODBCM_RC_STATUS
+ * @param[in] : db_name - specifies the configuration
+ * i.e. candidate/running/startup
+ * @return : ODBCM_RC_SUCCESS - if the database is cleared successfully
+ * ODBCM_RC_* - if the database is not cleared
**/
-ODBCM_RC_STATUS ODBCManager::ClearDatabase(unc_keytype_datatype_t db_name) {
+ODBCM_RC_STATUS ODBCManager::ClearDatabase(unc_keytype_datatype_t db_name,
+ OdbcmConnectionHandler *conn_obj) {
PHY_FINI_READ_LOCK();
string *cleardb_query = NULL; // to store query
SQLRETURN odbc_rc = ODBCM_RC_SUCCESS; // SQL APIs rc
QueryFactory *query_factory = NULL;
QueryProcessor *query_processor = NULL;
+ SQLHDBC rw_conn_handle = conn_obj->get_conn_handle();
/** Allocate for db statement handle */
- ODBCM_STATEMENT_CREATE(rw_conn_handle_, clear_stmt);
+ ODBCM_STATEMENT_CREATE(rw_conn_handle, clear_stmt);
/** Create query_factory and query processor objects */
ODBCM_CREATE_OBJECT(query_factory, QueryFactory);
ODBCM_CREATE_OBJECT(query_processor, QueryProcessor);
CLEARDATABASE, cleardb_query, clear_stmt);
if (status == ODBCM_RC_SUCCESS) {
/** Commit all active transactions on this connection*/
- ODBCM_END_TRANSACTION(rw_conn_handle_, SQL_COMMIT);
+ ODBCM_END_TRANSACTION(rw_conn_handle, SQL_COMMIT);
pfc_log_info("ODBCM::ODBCManager::ClearDatabase:database is cleared");
} else {
/** Rollback all active transactions on this connection*/
- ODBCM_END_TRANSACTION(rw_conn_handle_, SQL_ROLLBACK);
+ ODBCM_END_TRANSACTION(rw_conn_handle, SQL_ROLLBACK);
pfc_log_info("ODBCM::ODBCManager::ClearDatabase:database is not cleared");
}
/* Freeing all allocated memory */
/**
* @Description : This method will copy databases, copy all
* contents from src db table to dst db table.
- * @param[in] : unc_keytype_datatype_t , unc_keytype_datatype_t
- * @return : ODBCM_RC_STATUS
+ * @param[in] : src_db_name - specifies the source configuration
+ * i.e. candidate/running/startup
+ * dst_db_name - specifies the destination configuration
+ * i.e. candidate/running/startup
+ * @return : ODBCM_RC_SUCCESS - if the copy databases is success
+ * ODBCM_RC_* - if any error occured while copying
+ * databases
**/
ODBCM_RC_STATUS ODBCManager::CopyDatabase(
unc_keytype_datatype_t src_db_name,
- unc_keytype_datatype_t dst_db_name) {
+ unc_keytype_datatype_t dst_db_name,
+ OdbcmConnectionHandler *conn_obj) {
PHY_FINI_READ_LOCK();
/** Initialise the local variables */
string *p_copydb_query = NULL;
" %s->%s", g_log_db_name[src_db_name], g_log_db_name[dst_db_name]);
return ODBCM_RC_INVALID_DB_OPERATION;
}
+ SQLHDBC rw_conn_handle = conn_obj->get_conn_handle();
/** Create p_query_factory and query processor objects */
- ODBCM_STATEMENT_CREATE(rw_conn_handle_, copy_stmt);
+ ODBCM_STATEMENT_CREATE(rw_conn_handle, copy_stmt);
ODBCM_CREATE_OBJECT(p_query_factory, QueryFactory);
ODBCM_CREATE_OBJECT(query_processor, QueryProcessor);
/** Set the FPTR */
COPYDATABASE, p_copydb_query, copy_stmt);
if (status == ODBCM_RC_SUCCESS) {
/** Commit all active transactions on this connection*/
- ODBCM_END_TRANSACTION(rw_conn_handle_, SQL_COMMIT);
+ ODBCM_END_TRANSACTION(rw_conn_handle, SQL_COMMIT);
pfc_log_info("ODBCM::ODBCManager::CopyDatabase:database is copied");
} else {
/** Rollback all active transactions on this connection*/
- ODBCM_END_TRANSACTION(rw_conn_handle_, SQL_ROLLBACK);
+ ODBCM_END_TRANSACTION(rw_conn_handle, SQL_ROLLBACK);
pfc_log_info("ODBCM::ODBCManager::CopyDatabase:database is not copied");
}
/* Freeing all allocated memory */
* uncommited rows are present in candiate config.
* other than APPLIED row status are treated as dirty.
* @param[in] : None
- * @return : ODBCM_RC_STATUS
+ * @return : ODBCM_RC_SUCCESS - if the candidate databases is dirty
+ * ODBCM_RC_* - if the candidate databases as any
+ * uncommited rows
**/
-ODBCM_RC_STATUS ODBCManager::IsCandidateDirty() {
+ODBCM_RC_STATUS ODBCManager::IsCandidateDirty(
+ OdbcmConnectionHandler *conn_obj) {
PHY_FINI_READ_LOCK();
string *query = NULL; // to receive the query from queryfactory
SQLRETURN odbc_rc = ODBCM_RC_SUCCESS; // SQL APIs rc
QueryFactory *query_factory = NULL;
QueryProcessor *query_processor = NULL;
+ SQLHDBC ro_conn_handle = conn_obj->get_conn_handle();
/** Allocate for db statement handle */
- ODBCM_STATEMENT_CREATE(ro_conn_handle_, isdirty_stmt);
+ ODBCM_STATEMENT_CREATE(ro_conn_handle, isdirty_stmt);
/** Create query_factory and query processor objects */
ODBCM_CREATE_OBJECT(query_factory, QueryFactory);
ODBCM_CREATE_OBJECT(query_processor, QueryProcessor);
* STEP2: TRUNCATE all the tables in Running db
* STEP3: Copy Candidate->Running if above steps are success
* copydatabase will be reused for step3.
- * @param[in] : unc_data_type_t src_db,unc_data_type_t dst_db
- * @return : ODBCM_RC_STATUS
+ * @param[in] : src_db - specifies the source configuration as
+ * candidate database
+ * dst_db - specifies the destination configuration
+ * as running database
+ * @return : ODBCM_RC_SUCCESS - if the commit is success
+ * ODBCM_RC_* - if the commit is failed
**/
ODBCM_RC_STATUS ODBCManager::CommitAllConfiguration(
unc_keytype_datatype_t src_db,
- unc_keytype_datatype_t dst_db) {
+ unc_keytype_datatype_t dst_db,
+ OdbcmConnectionHandler *conn_obj) {
PHY_FINI_READ_LOCK();
HSTMT commit_stmt = NULL;
string *p_commit_query = NULL;
g_log_db_name[src_db], g_log_db_name[dst_db]);
return ODBCM_RC_INVALID_DB_OPERATION;
}
+ SQLHDBC rw_conn_handle = conn_obj->get_conn_handle();
/** Create query_factory and query processor objects */
- ODBCM_STATEMENT_CREATE(rw_conn_handle_, commit_stmt);
+ ODBCM_STATEMENT_CREATE(rw_conn_handle, commit_stmt);
ODBCM_CREATE_OBJECT(query_factory, QueryFactory);
ODBCM_CREATE_OBJECT(query_processor, QueryProcessor);
/** Fptr for queryfactory to construct COMMITALLCONFIG query */
}
if (status == ODBCM_RC_SUCCESS) {
/** Commit all active transactions on this connection*/
- ODBCM_END_TRANSACTION(rw_conn_handle_, SQL_COMMIT);
+ ODBCM_END_TRANSACTION(rw_conn_handle, SQL_COMMIT);
pfc_log_info("ODBCM::ODBCManager::CommitAllConfiguration: "
"ODBCM level commit is completed");
} else {
/** Rollback all active transactions on this connection*/
- ODBCM_END_TRANSACTION(rw_conn_handle_, SQL_ROLLBACK);
+ ODBCM_END_TRANSACTION(rw_conn_handle, SQL_ROLLBACK);
pfc_log_info("ODBCM::ODBCManager::CommitAllConfiguration: "
"ODBCM level commit is not completed");
}
}
/**
* @Description : To clear controller_name instance in all the tables in DB
- * @param[in] : unc_keytype_datatype_t db_name, string controller_name
- * @return : ODBCM_RC_STATUS
+ * @param[in] : db_name - specifies the configuration
+ * i.e. candidate/running/startup
+ * controller_name - controller_id
+ * @return : ODBCM_RC_SUCCESS - if the ClearOneInstance function is success
+ * ODBCM_RC_* - if the ClearOneInstance function is failed
**/
ODBCM_RC_STATUS ODBCManager::ClearOneInstance(
unc_keytype_datatype_t db_name,
- string controller_name) {
+ string controller_name, OdbcmConnectionHandler *conn_obj) {
PHY_FINI_READ_LOCK();
/** Initialise the local variables */
std::string *QUERY = NULL;
QueryFactory *query_factory = NULL;
QueryProcessor *query_processor = NULL;
+ SQLHDBC rw_conn_handle = conn_obj->get_conn_handle();
/** Do sql allocate for sql stmt */
- ODBCM_STATEMENT_CREATE(rw_conn_handle_, stmt);
+ ODBCM_STATEMENT_CREATE(rw_conn_handle, stmt);
/** Create query_factory and query processor objects */
ODBCM_CREATE_OBJECT(query_factory, QueryFactory);
ODBCM_CREATE_OBJECT(query_processor, QueryProcessor);
status = query_processor->ExecuteTransaction(
CLEARONEINSTANCE, QUERY, stmt);
if (status == ODBCM_RC_SUCCESS) {
- ODBCM_END_TRANSACTION(rw_conn_handle_, SQL_COMMIT);
+ ODBCM_END_TRANSACTION(rw_conn_handle, SQL_COMMIT);
pfc_log_info("ODBCM::ODBCManager::ClearOneInstance: "
"given one instance is cleared");
} else {
- ODBCM_END_TRANSACTION(rw_conn_handle_, SQL_ROLLBACK);
+ ODBCM_END_TRANSACTION(rw_conn_handle, SQL_ROLLBACK);
pfc_log_info("ODBCM::ODBCManager::ClearOneInstance: "
"given one instance is not cleared");
}
* @Description :Constructor function which will create/initialize
* the instance of QueryFactory.
* @param[in] : None
- * @return : None
+ * @return : void
**/
-QueryFactory::QueryFactory() {
- GetQuery = NULL;
- GetDBSpecificQuery = NULL;
- GetTwoDBQuery = NULL;
- GetSingleDBQuery = NULL;
- GetIsDBQuery = NULL;
- GetClearInstanceQuery = NULL;
-// GetTwoTableQuery = NULL;
- GetBulkRowQuery = NULL;
- CommitTableQuery = NULL;
- GetCountQuery = NULL;
- GetFilterCountQuery = NULL;
- GetSiblingFilterQuery = NULL;
+QueryFactory::QueryFactory()
+: GetQuery(NULL),
+ GetQueryWithBool(NULL),
+ GetFilterCountQuery(NULL),
+ GetSiblingFilterQuery(NULL),
+ GetCountQuery(NULL),
+ GetDBSpecificQuery(NULL),
+ GetTwoDBQuery(NULL),
+ GetSingleDBQuery(NULL),
+ GetIsDBQuery(NULL),
+ CommitTableQuery(NULL),
+ GetBulkRowQuery(NULL),
+ GetClearInstanceQuery(NULL) {
}
/**
* @Description :This function is automatically invoked when
* QueryFactory object is destroyed
* @param[in] : None
- * @return : None
+ * @return : void
**/
QueryFactory::~QueryFactory() {
}
/**
* @Description : This function gets the query statement handler
* for creating a row in the database
- * @param[in] : unc_keytype_datatype_t, DBTableSchema&
- * @return : SQLQUERY
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * @return : SQLQUERY - framed query will be returned
**/
SQLQUERY QueryFactory::operation_createonerow(
unc_keytype_datatype_t db_name,
DBTableSchema &db_table_schema) {
- std::string prefix;
+ std::string prefix = "";
uint16_t loop1 = 0, loop2 = 0;
std::ostringstream create_query, values;
std::vector<TableAttrSchema> :: iterator iter_vector;
std::list<std::vector<TableAttrSchema> > ::iterator iter_list;
/** Get the table name prefix */
- if (db_name == UNC_DT_CANDIDATE)
+ switch (db_name) {
+ /** Get the table name prefix */
+ case UNC_DT_CANDIDATE:
prefix = "c_";
- else if (db_name == UNC_DT_RUNNING)
+ break;
+ case UNC_DT_RUNNING:
prefix = "r_";
- else if (db_name == UNC_DT_STARTUP)
+ break;
+ case UNC_DT_STARTUP:
prefix = "s_";
- else if (db_name == UNC_DT_IMPORT)
+ break;
+ case UNC_DT_IMPORT:
prefix = "i_";
- else if (db_name == UNC_DT_STATE)
+ break;
+ case UNC_DT_STATE:
prefix = "r_";
- else
+ break;
+ default:
return ODBCM_NULL_STRING;
- create_query << "INSERT INTO " << prefix << db_table_schema.table_name_<< " ";
+ }
+ create_query << "INSERT INTO " << prefix <<
+ ODBCManager::get_ODBCManager()->
+ GetTableName(db_table_schema.table_name_) << " ";
/** Traverse the list to get the Attribute vector */
/** In this case, this traversal will be only once since list
* contains only one row info */
for (loop2 = 0, iter_vector = attributes_vector.begin();
iter_vector != attributes_vector.end(); iter_vector++, loop2++) {
/** Get attribute name of a row */
- create_query << (*iter_vector).table_attribute_name;
+ create_query << ODBCManager::get_ODBCManager()->GetColumnName(
+ (*iter_vector).table_attribute_name);
/** For the last attribute comma is not required*/
if (loop2 != attributes_vector.size()-1) {
create_query << ",";
/**
* @Description : This method gets the query statement handler
* for updating a row in the database.
- * @param[in] : unc_keytype_datatype_t, DBTableSchema&
- * @return : SQLQUERY
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * @return : SQLQUERY - framed query will be retuned
**/
SQLQUERY QueryFactory::operation_updateonerow(
- unc_keytype_datatype_t db_name, DBTableSchema &db_table_schema) {
+ unc_keytype_datatype_t db_name, DBTableSchema &db_table_schema,
+ bool IsInternal) {
uint16_t loop1 = 0;
uint16_t loop2 = 0;
uint16_t loop3 = 0;
- std::string prefix;
+ std::string prefix = "";
std::ostringstream update_query;
std::ostringstream where_query;
std::vector<std::string> :: iterator iter_keys;
std::vector<TableAttrSchema> :: iterator iter_vector;
std::list<std::vector<TableAttrSchema> > ::iterator iter_list;
/** Get the table name prefix */
- if (db_name == UNC_DT_CANDIDATE)
+ switch (db_name) {
+ /** Get the table name prefix */
+ case UNC_DT_CANDIDATE:
prefix = "c_";
- else if (db_name == UNC_DT_RUNNING)
+ break;
+ case UNC_DT_RUNNING:
prefix = "r_";
- else if (db_name == UNC_DT_STARTUP)
+ break;
+ case UNC_DT_STARTUP:
prefix = "s_";
- else if (db_name == UNC_DT_IMPORT)
+ break;
+ case UNC_DT_IMPORT:
prefix = "i_";
- else if (db_name == UNC_DT_STATE)
+ break;
+ case UNC_DT_STATE:
prefix = "r_";
- else
+ break;
+ default:
return ODBCM_NULL_STRING;
+ }
/** Start framing the update query */
- if (db_name == UNC_DT_CANDIDATE) {
+ if (db_name == UNC_DT_CANDIDATE && IsInternal == false) {
if (db_table_schema.db_return_status_ == CREATED) {
/**to keep the immediate created rows status as created*/
update_query << "UPDATE " << prefix << \
- db_table_schema.table_name_<< " SET cs_row_status = " << CREATED << ",";
+ ODBCManager::get_ODBCManager()->
+ GetTableName(db_table_schema.table_name_)
+ << " SET cs_row_status = " << CREATED << ",";
} else {
update_query << "UPDATE " << prefix << \
- db_table_schema.table_name_<< " SET cs_row_status = " << UPDATED << ",";
+ ODBCManager::get_ODBCManager()->
+ GetTableName(db_table_schema.table_name_)
+ << " SET cs_row_status = " << UPDATED << ",";
}
} else {
+ /**cs_row_status will not be updated other than candidate configurations,
+ *db_name == UNC_DT_CANDIDATE && IsInternal == true */
update_query << "UPDATE " << prefix << \
- db_table_schema.table_name_<< " " <<" SET ";
+ ODBCManager::get_ODBCManager()->
+ GetTableName(db_table_schema.table_name_)
+ << " " <<" SET ";
}
/** Get the primary keys. Needed since its not required to SET the pk */
std::vector <std::string> primarykeys = db_table_schema.get_primary_keys();
iter_vector != attributes_vector.end(); iter_vector++, loop2++) {
for (loop3 = 0, iter_keys = primarykeys.begin();
iter_keys != primarykeys.end(); iter_keys++, loop3++) {
- if (((*iter_keys).compare((*iter_vector).table_attribute_name) == 0) &&
+ if (((*iter_keys).compare(ODBCManager::get_ODBCManager()->GetColumnName(
+ (*iter_vector).table_attribute_name)) == 0) &&
((*iter_vector).request_attribute_type ==
DATATYPE_UINT8_ARRAY_32)) {
ColumnAttrValue <uint8_t[ODBCM_SIZE_32]> column_value;
ODBCM_MEMCPY(&temp, &column_value.value, ODBCM_SIZE_32);
uint16_t len = strlen((const char*)temp);
temp[len+1] = '\0';
- pfc_log_info("ODBCM::QueryFactory::UpdateQuery():"
+ pfc_log_debug("ODBCM::QueryFactory::UpdateQuery():"
" (*iter_vector).length %d value = %s\n",
(*iter_vector).table_attribute_length,
temp);
where_query << (*iter_keys).c_str() << " = '" <<
temp << "'";
- } else if (
- ((*iter_keys).compare((*iter_vector).table_attribute_name) == 0) &&
+ } else if (((*iter_keys).compare(ODBCManager::get_ODBCManager()->
+ GetColumnName((*iter_vector).table_attribute_name)) == 0) &&
((*iter_vector).request_attribute_type ==
- DATATYPE_UINT8_ARRAY_320)) {
+ DATATYPE_UINT8_ARRAY_320)) {
ColumnAttrValue <uint8_t[ODBCM_SIZE_320]> column_value;
column_value = *((ColumnAttrValue <uint8_t[ODBCM_SIZE_320]>*)
((*iter_vector).p_table_attribute_value));
ODBCM_MEMCPY(&btemp, &column_value.value, ODBCM_SIZE_320);
uint16_t len = strlen((const char*)btemp);
btemp[len+1] = '\0';
- pfc_log_info("ODBCM::QueryFactory::UpdateQuery():"
+ pfc_log_debug("ODBCM::QueryFactory::UpdateQuery():"
" (*iter_vector).length %d value = %s\n",
(*iter_vector).table_attribute_length,
btemp);
where_query << (*iter_keys).c_str() << " = '" <<
btemp << "'";
} else if (
- ((*iter_keys).compare((*iter_vector).table_attribute_name) == 0) &&
+ ((*iter_keys).compare(ODBCManager::get_ODBCManager()->GetColumnName(
+ (*iter_vector).table_attribute_name)) ==0) &&
((*iter_vector).request_attribute_type ==
DATATYPE_UINT8_ARRAY_256)) {
ColumnAttrValue <uint8_t[ODBCM_SIZE_256]> column_value;
ODBCM_MEMCPY(&stemp, &column_value.value, ODBCM_SIZE_256);
uint16_t len = strlen((const char*)stemp);
stemp[len+1] = '\0';
- pfc_log_info("ODBCM::QueryFactory::UpdateQuery():"
+ pfc_log_debug("ODBCM::QueryFactory::UpdateQuery():"
"(*iter_vector).length %d value = %s\n",
(*iter_vector).table_attribute_length,
column_value.value);
stemp << "'";
}
- if (((*iter_keys).compare((*iter_vector).table_attribute_name) == 0)
+ if (((*iter_keys).compare(ODBCManager::get_ODBCManager()->\
+ GetColumnName((*iter_vector).table_attribute_name)) == 0)
&& loop3 != primarykeys.size()-1) {
where_query << " AND ";
}
/** Get the column names and values */
for (loop2 = 0, iter_vector = attributes_vector.begin() + pkey_size;
iter_vector != attributes_vector.end(); iter_vector++, loop2++) {
- update_query << (*iter_vector).table_attribute_name <<"= ?";
+ update_query << ODBCManager::get_ODBCManager()->GetColumnName(
+ (*iter_vector).table_attribute_name) <<"= ?";
if (loop2 != attributes_vector.size()-(pkey_size+1))
update_query << ",";
} // for list of rows
/**
* @Description : This method will get the query statement handler
* for deleting a row in the database.
- * @param[in] : unc_keytype_datatype_t, DBTableSchema&
- * @return : SQLQUERY
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * @return : SQLQUERY - framed query will be retuned
**/
SQLQUERY QueryFactory::operation_deleteonerow(unc_keytype_datatype_t db_name,
DBTableSchema &db_table_schema) {
uint16_t loop1 = 0;
- std::string prefix;
+ std::string prefix = "";
std::ostringstream delete_query;
std::vector <std::string> primarykeys;
std::vector<std::string> :: iterator iter_vector;
/** Get the table name prefix */
- if (db_name == UNC_DT_CANDIDATE)
+ switch (db_name) {
+ /** Get the table name prefix */
+ case UNC_DT_CANDIDATE:
prefix = "c_";
- else if (db_name == UNC_DT_RUNNING)
+ break;
+ case UNC_DT_RUNNING:
prefix = "r_";
- else if (db_name == UNC_DT_STARTUP)
+ break;
+ case UNC_DT_STARTUP:
prefix = "s_";
- else if (db_name == UNC_DT_IMPORT)
+ break;
+ case UNC_DT_IMPORT:
prefix = "i_";
- else if (db_name == UNC_DT_STATE)
+ break;
+ case UNC_DT_STATE:
prefix = "r_";
- else
+ break;
+ default:
return ODBCM_NULL_STRING;
+ }
+
if (db_name == UNC_DT_CANDIDATE) {
- delete_query << "UPDATE " << prefix << db_table_schema.table_name_;
+ delete_query << "UPDATE " << prefix << ODBCManager::get_ODBCManager()->
+ GetTableName(db_table_schema.table_name_);
delete_query << " SET cs_row_status = " << DELETED << " WHERE ";
} else {
- delete_query << "DELETE FROM " << prefix << db_table_schema.table_name_;
+ delete_query << "DELETE FROM " << prefix <<
+ ODBCManager::get_ODBCManager()->
+ GetTableName(db_table_schema.table_name_);
delete_query << " WHERE ";
}
/** Use only primary keys after WHERE in the sql query */
/**
* @Description : To frame the query for deleting a row in a db table
- * @param[in] : unc_keytype_datatype_t, DBTableSchema&
- * @return : SQLQUERY
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * @return : SQLQUERY - framed query will be retuned
**/
SQLQUERY QueryFactory::operation_clearonerow(unc_keytype_datatype_t db_name,
DBTableSchema &db_table_schema) {
uint16_t loop1 = 0;
- std::string prefix;
+ std::string prefix = "";
std::ostringstream clearone_query;
std::vector<std::string> :: iterator iter_keys;
/** Get the table name prefix */
- if (db_name == UNC_DT_CANDIDATE)
+ switch (db_name) {
+ /** Get the table name prefix */
+ case UNC_DT_CANDIDATE:
prefix = "c_";
- else if (db_name == UNC_DT_RUNNING)
+ break;
+ case UNC_DT_RUNNING:
prefix = "r_";
- else if (db_name == UNC_DT_STARTUP)
+ break;
+ case UNC_DT_STARTUP:
prefix = "s_";
- else if (db_name == UNC_DT_IMPORT)
+ break;
+ case UNC_DT_IMPORT:
prefix = "i_";
- else if (db_name == UNC_DT_STATE)
+ break;
+ case UNC_DT_STATE:
prefix = "r_";
- else
+ break;
+ default:
return ODBCM_NULL_STRING;
+ }
- clearone_query << "DELETE FROM " << prefix << db_table_schema.table_name_;
+ clearone_query << "DELETE FROM " << prefix <<
+ ODBCManager::get_ODBCManager()->GetTableName(db_table_schema.table_name_);
clearone_query << " WHERE ";
/** Use only primary keys after WHERE in the sql query */
std::vector <std::string> primarykeys = db_table_schema.get_primary_keys();
/**
* @Description : This function will get the query statement handler for
* fetching a row in the database
- * @param[in] : unc_keytype_datatype_t, DBTableSchema&
- * @return : SQLQUERY
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * @return : SQLQUERY - framed query will be retuned
**/
SQLQUERY QueryFactory::operation_getonerow(unc_keytype_datatype_t db_name,
DBTableSchema &db_table_schema) {
- uint16_t loop1 = 0;
uint16_t loop2 = 0;
uint16_t loop3 = 0;
- std::string prefix;
+ std::string prefix = "";
std::ostringstream get_query; // stream to store the query
std::ostringstream get_columns; // stream to store the query
std::vector<std::string> :: iterator iter_keys;
std::vector<TableAttrSchema> :: iterator iter_vector;
std::list<std::vector<TableAttrSchema> > ::iterator iter_list;
+ switch (db_name) {
/** Get the table name prefix */
- if (db_name == UNC_DT_CANDIDATE)
+ case UNC_DT_CANDIDATE:
prefix = "c_";
- else if (db_name == UNC_DT_RUNNING)
+ break;
+ case UNC_DT_RUNNING:
prefix = "r_";
- else if (db_name == UNC_DT_STARTUP)
+ break;
+ case UNC_DT_STARTUP:
prefix = "s_";
- else if (db_name == UNC_DT_IMPORT)
+ break;
+ case UNC_DT_IMPORT:
prefix = "i_";
- else if (db_name == UNC_DT_STATE)
+ break;
+ case UNC_DT_STATE:
prefix = "r_";
- else
+ break;
+ default:
return ODBCM_NULL_STRING;
+ }
get_query << "SELECT ";
/** Traverse the list to get the Attribute vector */
/** In this case, this traversal will be only once since list
* contains only one row info */
- for (loop1 = 0, iter_list = db_table_schema.row_list_.begin();
- iter_list != db_table_schema.row_list_.end(); iter_list++, loop1++) {
+ for (iter_list = db_table_schema.row_list_.begin();
+ iter_list != db_table_schema.row_list_.end(); iter_list++) {
/** This vector contains all attributes of a row in a table */
std::vector<TableAttrSchema>attributes_vector = *iter_list;
+ if (attributes_vector.size() == 0)
+ return ODBCM_NULL_STRING;
/** Get the column names and values */
for (loop2 = 0, iter_vector = attributes_vector.begin();
iter_vector != attributes_vector.end(); iter_vector++, loop2++) {
- get_query << (*iter_vector).table_attribute_name;
+ get_query << ODBCManager::get_ODBCManager()->GetColumnName(
+ (*iter_vector).table_attribute_name);
if (loop2 != attributes_vector.size()-1) {
get_query << " ,";
}
get_columns << " AND ";
}
} // for
- get_query << " FROM " << prefix << db_table_schema.table_name_ << " WHERE "
- << get_columns.str() << " ORDER BY " << primarykeys.front() <<";";
+ get_query << " FROM " << prefix << ODBCManager::get_ODBCManager()->
+ GetTableName(db_table_schema.table_name_);
+ if (primarykeys.size() != 0) {
+ get_query << " WHERE " << get_columns.str();
+ }
+ get_query << getOrderByString(db_table_schema.table_name_,
+ primarykeys);
+ get_query << ";";
pfc_log_info("ODBCM::QueryFactory::GetOneRow: Query: \"%s\"",
(get_query.str()).c_str());
/**
* @Description : This function will check whether the given
* row exists in the given table
- * @param[in] : unc_keytype_datatype_t, DBTableSchema&
- * @return : SQLQUERY
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * @return : SQLQUERY - framed query will be retuned
**/
SQLQUERY QueryFactory::operation_isrowexists(unc_keytype_datatype_t db_name,
DBTableSchema &db_table_schema) {
uint16_t loop1 = 0;
- std::string prefix;
+ std::string prefix = "";
std::ostringstream exists_query;
+ std::ostringstream exists_pkeys;
std::vector <std::string> primarykeys;
std::vector<std::string> :: iterator iter_keys;
-
- if (db_name == UNC_DT_CANDIDATE) {
- prefix = "c_";
- exists_query << "SELECT EXISTS(SELECT * FROM "<< prefix
- << db_table_schema.table_name_ << "), cs_row_status";
- } else if (db_name == UNC_DT_RUNNING) {
- prefix = "r_";
- exists_query << "SELECT EXISTS(SELECT * FROM "<< prefix
- << db_table_schema.table_name_ << ")";
- } else if (db_name == UNC_DT_STARTUP) {
- prefix = "s_";
- exists_query << "SELECT EXISTS(SELECT * FROM "<< prefix
- << db_table_schema.table_name_ << ")";
- } else if (db_name == UNC_DT_IMPORT) {
- prefix = "i_";
- exists_query << "SELECT EXISTS(SELECT * FROM "<< prefix
- << db_table_schema.table_name_ << ")";
- } else if (db_name == UNC_DT_STATE) {
- prefix = "r_";
- exists_query << "SELECT EXISTS(SELECT * FROM "<< prefix
- << db_table_schema.table_name_ << ")";
- } else {
- pfc_log_info("ODBCM::QueryFactory::operation_isrowexists:"
- "unc_keytype_datatype_t does not match ");
+ switch (db_name) {
+ /** Get the table name prefix */
+ case UNC_DT_CANDIDATE:
+ prefix = "c_";
+ exists_query << "SELECT EXISTS(SELECT * FROM "<< prefix
+ << ODBCManager::get_ODBCManager()->
+ GetTableName(db_table_schema.table_name_) << "), cs_row_status";
+ break;
+ case UNC_DT_RUNNING:
+ prefix = "r_";
+ exists_query << "SELECT EXISTS(SELECT * FROM "<< prefix
+ << ODBCManager::get_ODBCManager()->
+ GetTableName(db_table_schema.table_name_) << ")";
+ break;
+ case UNC_DT_STARTUP:
+ prefix = "s_";
+ exists_query << "SELECT EXISTS(SELECT * FROM "<< prefix
+ << ODBCManager::get_ODBCManager()->
+ GetTableName(db_table_schema.table_name_) << ")";
+ break;
+ case UNC_DT_IMPORT:
+ prefix = "i_";
+ exists_query << "SELECT EXISTS(SELECT * FROM "<< prefix
+ << ODBCManager::get_ODBCManager()->
+ GetTableName(db_table_schema.table_name_) << ")";
+ break;
+ case UNC_DT_STATE:
+ prefix = "r_";
+ exists_query << "SELECT EXISTS(SELECT * FROM "<< prefix
+ << ODBCManager::get_ODBCManager()->
+ GetTableName(db_table_schema.table_name_) << ")";
+ break;
+ default:
return ODBCM_NULL_STRING;
}
exists_query << " from "<< prefix <<
- db_table_schema.table_name_ << " WHERE ";
+ ODBCManager::get_ODBCManager()->
+ GetTableName(db_table_schema.table_name_);
/** Use only primary keys after WHERE in the sql query */
primarykeys = db_table_schema.get_primary_keys();
for (loop1 = 0, iter_keys = primarykeys.begin();
iter_keys != primarykeys.end(); iter_keys++, loop1++) {
- exists_query << (*iter_keys).c_str() << " = ?";
+ exists_pkeys << (*iter_keys).c_str() << " = ?";
if (loop1 != primarykeys.size()-1) {
- exists_query << " AND ";
+ exists_pkeys << " AND ";
}
} // for
+ if (primarykeys.size() != 0) {
+ exists_query << " WHERE " << exists_pkeys.str();
+ }
exists_query << ";";
pfc_log_info("ODBCM::QueryFactory::IsRowExists: Query: \"%s\"",
(exists_query.str()).c_str());
/**
* @Description : This function will get the query for fetching
* the modified rows in the table.
- * @param[in] : unc_keytype_datatype_t, DBTableSchema&
- * @return : SQLQUERY
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * @return : SQLQUERY - framed query will be retuned
**/
SQLQUERY QueryFactory::operation_getmodifiedrows
(unc_keytype_datatype_t db_name,
DBTableSchema &db_table_schema) {
uint16_t loop1 = 0;
uint16_t loop2 = 0;
- std::string prefix;
+ std::string prefix = "";
std::ostringstream get_query, where_query; // stream to store the query
std::ostringstream get_columns; // stream to store the query
std::vector<std::string> :: iterator iter_keys;
std::vector<TableAttrSchema> :: iterator iter_vector;
std::list<std::vector<TableAttrSchema> > ::iterator iter_list;
/** Get the prefix for tablenaem based on db_tpe */
- if (db_name == UNC_DT_CANDIDATE)
+ switch (db_name) {
+ /** Get the table name prefix */
+ case UNC_DT_CANDIDATE:
prefix = "c_";
- else if (db_name == UNC_DT_RUNNING)
+ break;
+ case UNC_DT_RUNNING:
prefix = "r_";
- else if (db_name == UNC_DT_STARTUP)
+ break;
+ case UNC_DT_STARTUP:
prefix = "s_";
- else if (db_name == UNC_DT_IMPORT)
+ break;
+ case UNC_DT_IMPORT:
prefix = "i_";
- else if (db_name == UNC_DT_STATE)
+ break;
+ case UNC_DT_STATE:
prefix = "r_";
- else
+ break;
+ default:
return ODBCM_NULL_STRING;
+ }
+
/** Start framing the query */
get_query << "SELECT ";
/** Traverse the list to get the Attribute vector */
iter_list != db_table_schema.row_list_.end(); iter_list++, loop1++) {
/** This vector contains all attributes of a row in a table */
std::vector<TableAttrSchema>attributes_vector = *iter_list;
+ if (attributes_vector.size() == 0)
+ return ODBCM_NULL_STRING;
/** Get the column names and values */
for (loop2 = 0, iter_vector = attributes_vector.begin();
iter_vector != attributes_vector.end(); iter_vector++, loop2++) {
/** Get attribute name of a row */
- get_query << (*iter_vector).table_attribute_name;
+ get_query << ODBCManager::get_ODBCManager()->GetColumnName(
+ (*iter_vector).table_attribute_name);
if (loop2 != attributes_vector.size()-1)
get_query << " ,";
/** Frame where query part using row_status in db_table_schema */
- if (attributes_vector[loop2].table_attribute_name.
- compare("cs_row_status") == 0) {
+ if (ODBCManager::get_ODBCManager()->GetColumnName(
+ attributes_vector[loop2].table_attribute_name).
+ compare("cs_row_status") == 0) {
ColumnAttrValue <uint16_t> *rs_value =
((ColumnAttrValue <uint16_t>*)
((*iter_vector).p_table_attribute_value));
} // for list of rows
// get primary key (first key) for order by clause
std::vector <std::string> p_key = db_table_schema.get_primary_keys();
- std::string key_value = p_key.front();
get_query << " FROM " << prefix
- << db_table_schema.table_name_
- << " WHERE " << where_query.str()
- << " order by " << key_value << ";";
+ << ODBCManager::get_ODBCManager()->
+ GetTableName(db_table_schema.table_name_)
+ << " WHERE " << where_query.str();
+ get_query << getOrderByString(db_table_schema.table_name_,
+ p_key);
+ get_query << ";";
pfc_log_info("ODBCM::QueryFactory::GetModifiedRows(): Query: \"%s\"",
(get_query.str()).c_str());
return get_query.str();
* 1. During bootup: Startup --> Candidate
* 2. During backup: Running --> Startup
* 3. During commit: Candidate --> Running
- * @param[in] : unc_keytype_datatype_t, unc_keytype_datatype_t
- * @return : SQLQUERY*
+ * @param[in] : src_db_name - specifies the configuration
+ * i.e.candidate/running/startup,
+ * dst_db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * @return : SQLQUERY* - list of framed query will be retuned
**/
SQLQUERY* QueryFactory::operation_copydatabase(
unc_keytype_datatype_t src_db_name,
p_odbc_mgr = ODBCManager::get_ODBCManager();
/** Allocate memory to store the queries. For all the scenarios
- * in copy db, the number of tables involved is 3
+ * in copy db, the number of tables involved is 3
* Totally 6 queries (3 for clear dst_db and 3 for copying)*/
p_copy_db = new std::string[2*ODBCM_MAX_UPPL_TABLES + 1];
/** Null validation */
iter_dstvector != dst_vector.end(); iter_dstvector++, loop1++ ) {
if ((*iter_dstvector).compare("r_"UPPL_CTR_DOMAIN_TABLE) == 0) {
copy_query << "DELETE FROM " << (*iter_dstvector) <<
- " WHERE " << CTR_NAME << " IN (SELECT " << CTR_NAME <<
- " FROM r_" << UPPL_CTR_TABLE << " WHERE " << CTR_TYPE <<
+ " WHERE " << CTR_NAME_STR << " IN (SELECT " << CTR_NAME_STR <<
+ " FROM r_" << UPPL_CTR_TABLE << " WHERE " << CTR_TYPE_STR <<
"=" << UNC_CT_UNKNOWN << ");";
} else {
- copy_query << "TRUNCATE " << (*iter_dstvector) << ";";
+ copy_query << "DELETE FROM " << (*iter_dstvector) << ";";
}
pfc_log_info("ODBCM::QueryFactory::CopyDatabase: "
"Clear Query:%d is \"%s\"", loop1, (copy_query.str()).c_str());
strcmp(p_dst_table, "_"UPPL_CTR_DOMAIN_TABLE) == 0) {
copy_query << "INSERT INTO " << (*iter_dstvector) <<
" SELECT * FROM " << (*iter_srcvector) <<
- " WHERE " << CTR_NAME << " IN (SELECT " << CTR_NAME << " from " <<
- ctr_table.c_str() << " WHERE " << CTR_TYPE << "=" <<
+ " WHERE " << CTR_NAME_STR << " IN (SELECT " << CTR_NAME_STR <<
+ " from " << ctr_table.c_str() << " WHERE " << CTR_TYPE_STR << "=" <<
UNC_CT_UNKNOWN << ");";
/*Unknown domain type = 0 (UNC_CT_UNKNOWN)*/
} else {
}
/**
* @Description : This function will be called by PhysicalCore when IPC client
- * @param[in] : unc_keytype_datatype_t
- * @return : SQLQUERY*
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup,
+ * @return : SQLQUERY* - list of framed query will be retuned
**/
SQLQUERY* QueryFactory::operation_cleardatabase
(unc_keytype_datatype_t db_name) {
std::vector<std::string> :: iterator iter_vector;
std::map <int, std::vector<std::string> > db_table_list_map;
/** Allocate memory for query based on the db_type */
- if (db_name == UNC_DT_STARTUP) {
- table_count = ODBCM_MAX_STARTUP_TABLES;
- } else if (db_name == UNC_DT_CANDIDATE) {
- table_count = ODBCM_MAX_CANDIDATE_TABLES;
- } else if (db_name == UNC_DT_RUNNING) {
- table_count = ODBCM_MAX_RUNNING_TABLES;
- } else if (db_name == UNC_DT_STATE) {
- table_count = ODBCM_MAX_STATE_TABLES+1;
+ switch (db_name) {
+ case UNC_DT_STARTUP:
+ table_count = ODBCM_MAX_STARTUP_TABLES;
+ break;
+ case UNC_DT_CANDIDATE:
+ table_count = ODBCM_MAX_CANDIDATE_TABLES;
+ break;
+ case UNC_DT_RUNNING:
+ table_count = ODBCM_MAX_RUNNING_TABLES;
+ break;
+ case UNC_DT_STATE:
+ table_count = ODBCM_MAX_STATE_TABLES+1;
+ break;
/*UNC_DT_CANDIDATE - CTR_DOMAIN table*/
- } else if (db_name == UNC_DT_IMPORT) {
- table_count = ODBCM_MAX_IMPORT_TABLES;
- } else {
- pfc_log_error("ODBCM::QueryFactory::ClearDatabase: "
- "Invalid request. db_name: %s", g_log_db_name[db_name]);
- return NULL;
+ case UNC_DT_IMPORT:
+ table_count = ODBCM_MAX_IMPORT_TABLES;
+ break;
+ default:
+ return NULL;
}
+
p_odbc_mgr = ODBCManager::get_ODBCManager();
p_clear_db = new std::string[table_count+1];
/** Null validation */
if (db_name == UNC_DT_STATE) {
clear_query << "DELETE FROM " << "r_"UPPL_CTR_DOMAIN_TABLE <<
- " WHERE " << CTR_NAME << " IN (SELECT " << CTR_NAME <<
- " FROM r_" << UPPL_CTR_TABLE << " WHERE " << CTR_TYPE <<
+ " WHERE " << CTR_NAME_STR << " IN (SELECT " << CTR_NAME_STR <<
+ " FROM r_" << UPPL_CTR_TABLE << " WHERE " << CTR_TYPE_STR <<
"!=" << UNC_CT_UNKNOWN << ");";
pfc_log_info("ODBCM::QueryFactory::ClearDatabase: "
"CTR_DOMAIN Query is:%d \"%s\"", loop, (clear_query.str()).c_str());
/**
* @Description : To clear all controller entries from in db
- * @param[in] : unc_keytype_datatype_t, string&
- * @return : SQLQUERY*
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup,
+ * controller_name - specifies the controller name
+ * @return : SQLQUERY* - list of framed query will be retuned
**/
SQLQUERY* QueryFactory::operation_clearoneinstance(
unc_keytype_datatype_t db_name, std::string& controller_name) {
std::vector<std::string> :: iterator iter_srcvector;
std::map <int, std::vector<std::string> > db_table_list_map;
/** Get the number of tables in the given db */
- if (db_name == UNC_DT_STARTUP) {
- table_count = ODBCM_MAX_STARTUP_TABLES;
- } else if (db_name == UNC_DT_CANDIDATE) {
- table_count = ODBCM_MAX_CANDIDATE_TABLES;
- } else if (db_name == UNC_DT_RUNNING) {
- table_count = ODBCM_MAX_RUNNING_TABLES;
- } else if (db_name == UNC_DT_STATE) {
- table_count = ODBCM_MAX_STATE_TABLES + 1;
- /*+1 to add the DT_STATE ctr_domain_table delete*/
- } else if (db_name == UNC_DT_IMPORT) {
- table_count = ODBCM_MAX_IMPORT_TABLES;
- } else {
- pfc_log_error("ODBCM::QueryFactory::ClearOneInstance: "
- "Invalid request. db_name: %s", g_log_db_name[db_name]);
- return NULL;
+ switch (db_name) {
+ case UNC_DT_STARTUP:
+ table_count = ODBCM_MAX_STARTUP_TABLES;
+ break;
+ case UNC_DT_CANDIDATE:
+ table_count = ODBCM_MAX_CANDIDATE_TABLES;
+ break;
+ case UNC_DT_RUNNING:
+ table_count = ODBCM_MAX_RUNNING_TABLES;
+ break;
+ case UNC_DT_STATE:
+ table_count = ODBCM_MAX_STATE_TABLES+1;
+ break;
+ /*UNC_DT_CANDIDATE - CTR_DOMAIN table*/
+ case UNC_DT_IMPORT:
+ table_count = ODBCM_MAX_IMPORT_TABLES;
+ break;
+ default:
+ return NULL;
}
+
p_odbc_mgr = ODBCManager::get_ODBCManager();
/** Allocate memory for storing the query */
p_clear_inst_query = new std::string[table_count+1];
* entry with cs_row_status != APPLIED in db.
* cs_row_status
* @param[in] : None
- * @return : SQLQUERY*
+ * @return : SQLQUERY* - framed query will be retuned
**/
SQLQUERY* QueryFactory::operation_iscandidatedirty() {
uint16_t loop1 = 0;
* 4. If VTN queries without any value for Controller
* primary key, DB can return from first controller instance
* i.e Controller1
- * @param[in] : unc_keytype_datatype_t,
- * uint32_t,
- * DBTableSchema,
- * unc_keytype_operation_t
- * @return : SQLQUERY
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * max_repetition_count -specifies number of rows to be returned
+ * unc_keytype_operation_t - specifies any additional
+ * condition for GetBulkRows operation
+ * @return : SQLQUERY - framed query will be retuned
**/
SQLQUERY QueryFactory::operation_getbulkrows(unc_keytype_datatype_t db_name,
uint32_t max_repetition_count,
uint32_t loop1 = 0;
uint32_t loop2 = 0;
uint32_t loop3 = 0;
- std::string prefix;
+ std::string prefix = "";
std::ostringstream getbulk_query;
std::ostringstream getbulk_primarykey;
std::ostringstream getbulk_where;
std::vector<std::string> :: iterator iter_primarykey;
std::vector<TableAttrSchema> :: iterator iter_vector;
std::list<std::vector<TableAttrSchema> > ::iterator iter_list;
+ std::vector<std::string>::iterator iter_okey;
/** Get the prefix for tablenaem based on db_tpe */
- if (db_name == UNC_DT_CANDIDATE) {
- prefix = "c_";
- } else if (db_name == UNC_DT_RUNNING) {
- prefix = "r_";
- } else if (db_name == UNC_DT_STARTUP) {
- prefix = "s_";
- } else if (db_name == UNC_DT_IMPORT) {
- prefix = "i_";
- } else if (db_name == UNC_DT_STATE) {
- prefix = "r_";
- } else {
+ switch (db_name) {
+ /** Get the table name prefix */
+ case UNC_DT_CANDIDATE:
+ prefix = "c_";
+ break;
+ case UNC_DT_RUNNING:
+ prefix = "r_";
+ break;
+ case UNC_DT_STARTUP:
+ prefix = "s_";
+ break;
+ case UNC_DT_IMPORT:
+ prefix = "i_";
+ break;
+ case UNC_DT_STATE:
+ prefix = "r_";
+ break;
+ default:
return ODBCM_NULL_STRING;
}
getbulk_query << "SELECT ";
iter_list != db_table_schema.row_list_.end(); iter_list++, loop1++) {
/** This vector contains all attributes of a row in a table */
std::vector<TableAttrSchema>attributes_vector = *iter_list;
+ if (attributes_vector.size() == 0)
+ return ODBCM_NULL_STRING;
/** Get the column names and values */
for (loop2 = 0, iter_vector = attributes_vector.begin();
iter_vector != attributes_vector.end(); iter_vector++, loop2++) {
- getbulk_query << (*iter_vector).table_attribute_name;
+ getbulk_query << ODBCManager::get_ODBCManager()->GetColumnName(
+ (*iter_vector).table_attribute_name);
if (loop2 != attributes_vector.size()-1)
getbulk_query << ",";
} // for attribute vectors
} // for primarykey vector
} // for list of rows
- getbulk_query << " FROM " << prefix << db_table_schema.table_name_ <<
- getbulk_where.str() << " ORDER BY " << getbulk_primarykey.str()
- << " ASC LIMIT " << max_repetition_count;
+ getbulk_query << " FROM " << prefix << ODBCManager::get_ODBCManager()->
+ GetTableName(db_table_schema.table_name_);
+ if (db_table_schema.primary_keys_.size() != 0) {
+ getbulk_query << getbulk_where.str();
+ }
+ getbulk_query << getOrderByString(db_table_schema.table_name_,
+ db_table_schema.primary_keys_) << " ASC ";
+ getbulk_query << " LIMIT " << max_repetition_count << ";";
pfc_log_info("ODBCM::QueryFactory::GetBulkRows: Query is \"%s\"",
(getbulk_query.str()).c_str());
-
return getbulk_query.str();
}
/**
* @Description : This method is invoked when getsiblingcount
* request comes, this will fetch the sibling count from table
- * @param[in] : unc_keytype_datatype_t, DBTableSchema&
- * @return : SQLQUERY
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * @return : SQLQUERY - framed query will be retuned
**/
SQLQUERY QueryFactory::operation_getsiblingcount(
unc_keytype_datatype_t db_name,
DBTableSchema &db_table_schema) {
/** Initialise the local variables */
uint32_t loop1 = 0;
- uint8_t orderby_flag = 0, speccondition_flag = 0;
- std::string prefix;
- std::ostringstream query, orderby_query, special_condition;
+ uint8_t speccondition_flag = 0;
+ std::string prefix = "";
+ std::ostringstream query, where_query, special_condition;
std::vector <std::string> primarykeys;
std::vector<std::string> :: iterator iter_keys;
/** Based on the db type, get the prefix for table name */
- if (db_name == UNC_DT_CANDIDATE) {
- prefix = "c_";
- special_condition << " AND cs_row_status != " << DELETED << " ";
- speccondition_flag = 1;
- } else if (db_name == UNC_DT_RUNNING) {
- prefix = "r_";
- if (db_table_schema.table_name_.compare(UPPL_CTR_TABLE) == 0 ||
- db_table_schema.table_name_.compare(UPPL_CTR_DOMAIN_TABLE) == 0 ||
- db_table_schema.table_name_.compare(UPPL_BOUNDARY_TABLE) ==0) {
+ switch (db_name) {
+ /** Get the table name prefix */
+ case UNC_DT_CANDIDATE:
+ prefix = "c_";
special_condition << " AND cs_row_status != " << DELETED << " ";
speccondition_flag = 1;
- }
- } else if (db_name == UNC_DT_STARTUP) {
- prefix = "s_";
- } else if (db_name == UNC_DT_IMPORT) {
- prefix = "i_";
- } else if (db_name == UNC_DT_STATE) {
- prefix = "r_";
- } else {
- return ODBCM_NULL_STRING;
+ break;
+ case UNC_DT_RUNNING:
+ prefix = "r_";
+ if (db_table_schema.table_name_ == CTR_TABLE ||
+ db_table_schema.table_name_ == CTR_DOMAIN_TABLE ||
+ db_table_schema.table_name_ == BOUNDARY_TABLE) {
+ special_condition << " AND cs_row_status != " << DELETED << " ";
+ speccondition_flag = 1;
+ }
+ break;
+ case UNC_DT_STARTUP:
+ prefix = "s_";
+ break;
+ case UNC_DT_IMPORT:
+ prefix = "i_";
+ break;
+ case UNC_DT_STATE:
+ prefix = "r_";
+ break;
+ default:
+ return ODBCM_NULL_STRING;
}
- query << "SELECT * FROM " << prefix << db_table_schema.table_name_
- << " WHERE ";
+ query << "SELECT * FROM " << prefix << ODBCManager::get_ODBCManager()->
+ GetTableName(db_table_schema.table_name_);
/** Get the primary keys */
primarykeys = db_table_schema.get_primary_keys();
+ where_query << " WHERE ";
for (loop1 = 0, iter_keys = primarykeys.begin();
iter_keys != primarykeys.end(); iter_keys++, loop1++) {
/** Fill the primary keys in the query */
if (loop1 != db_table_schema.primary_keys_.size()-1) {
- query << (*iter_keys).c_str() << " = ? ";
- query << " AND ";
+ where_query << (*iter_keys).c_str() << " = ? ";
+ where_query << " AND ";
} else {
- query << (*iter_keys).c_str() << " > ? ";
- }
- /** In ORDER BY, we always take the first primary key */
- if (0 == orderby_flag) {
- orderby_query << " ORDER BY " << (*iter_keys).c_str() << " ;";
- orderby_flag = 1;
+ where_query << (*iter_keys).c_str() << " > ? ";
}
}
/* Fill the table name in the query */
/* Example: Query should as below */
/* SELECT controller_name FROM c_controller_common_table WHERE
* controller_name > ? ORDER BY controller_name */
- if (speccondition_flag == 1) {
- query << special_condition.str();
+ if (primarykeys.size() != 0) {
+ query << where_query.str();
+ if (speccondition_flag == 1) {
+ query << special_condition.str();
+ }
}
- query << orderby_query.str();
+ query << getOrderByString(db_table_schema.table_name_,
+ db_table_schema.primary_keys_);
+ query << ";";
pfc_log_info("ODBCM::QueryFactory::GetSiblingCount:: "
"Query is \"%s\"", (query.str()).c_str());
return query.str();
/**
* @Description : To frame query for getting the sibling count based upon
* filter options in request.
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * filter_operators - vector to decide the filter while
+ * framing query
* @param[in] : unc_keytype_datatype_t, DBTableSchema&, vector<ODBCMOperator>
- * @return : SQLQUERY
+ * @return : SQLQUERY - framed query will be retuned
**/
SQLQUERY QueryFactory::operation_getsiblingcount_with_filter(
unc_keytype_datatype_t db_name,
DBTableSchema& db_table_schema,
std::vector<ODBCMOperator> filter_operators) {
- std::string prefix;
+ std::string prefix = "";
uint8_t speccondition_flag = 0;
/**stream to store the query*/
- std::ostringstream query, orderby_query, special_condition;
+ std::ostringstream query, where_query, special_condition;
uint32_t loop1 = 0;
/**To traverse the primary key vector*/
std::vector<std::string> :: iterator iter_keys;
/**To traverse the primary key vector*/
std::vector<ODBCMOperator> :: iterator iter_operators;
- uint8_t orderby_flag = 0;
/* Based on the db type, get the prefix for table name */
- if (db_name == UNC_DT_CANDIDATE) {
+ switch (db_name) {
+ /** Get the table name prefix */
+ case UNC_DT_CANDIDATE:
prefix = "c_";
special_condition << " AND cs_row_status != " << DELETED << " ";
speccondition_flag = 1;
- } else if (db_name == UNC_DT_RUNNING) {
+ break;
+ case UNC_DT_RUNNING:
prefix = "r_";
- if (db_table_schema.table_name_.compare(UPPL_CTR_TABLE) == 0 ||
- db_table_schema.table_name_.compare(UPPL_CTR_DOMAIN_TABLE) == 0 ||
- db_table_schema.table_name_.compare(UPPL_BOUNDARY_TABLE) ==0) {
+ if (db_table_schema.table_name_ == CTR_TABLE ||
+ db_table_schema.table_name_ == CTR_DOMAIN_TABLE ||
+ db_table_schema.table_name_ == BOUNDARY_TABLE) {
special_condition << " AND cs_row_status != " << DELETED << " ";
speccondition_flag = 1;
}
- } else if (db_name == UNC_DT_STARTUP) {
+ break;
+ case UNC_DT_STARTUP:
prefix = "s_";
- } else if (db_name == UNC_DT_IMPORT) {
+ break;
+ case UNC_DT_IMPORT:
prefix = "i_";
- } else if (db_name == UNC_DT_STATE) {
+ break;
+ case UNC_DT_STATE:
prefix = "r_";
- } else {
+ break;
+ default:
return ODBCM_NULL_STRING;
}
- query << "SELECT * FROM " << prefix << db_table_schema.table_name_
- << " WHERE ";
+ query << "SELECT * FROM " << prefix << ODBCManager::get_ODBCManager()->
+ GetTableName(db_table_schema.table_name_);
+ where_query << " WHERE ";
/* Get the primary keys */
std::vector <std::string> primarykeys = db_table_schema.get_primary_keys();
for (loop1 = 0, iter_keys = primarykeys.begin(),
const int op = static_cast<int>(*iter_operators);
switch (op) {
case UNKNOWN_OPERATOR:
- query << (*iter_keys).c_str() << " = ? ";
+ where_query << (*iter_keys).c_str() << " = ? ";
pfc_log_debug("ODBCM::QueryFactory::GetSiblingCount(filter)::"
"invalid operator found");
return ODBCM_NULL_STRING;
break;
case EQUAL:
- query << (*iter_keys).c_str() << " = ? ";
+ where_query << (*iter_keys).c_str() << " = ? ";
break;
case NOT_EQUAL:
- query << (*iter_keys).c_str() << " != ? ";
+ where_query << (*iter_keys).c_str() << " != ? ";
break;
case GREATER:
- query << (*iter_keys).c_str() << " > ? ";
+ where_query << (*iter_keys).c_str() << " > ? ";
break;
case GREATER_EQUAL:
- query << (*iter_keys).c_str() << " >= ? ";
+ where_query << (*iter_keys).c_str() << " >= ? ";
break;
case LESSER:
- query << (*iter_keys).c_str() << " < ? ";
+ where_query << (*iter_keys).c_str() << " < ? ";
break;
case LESSER_EQUAL:
- query << (*iter_keys).c_str() << " <= ? ";
+ where_query << (*iter_keys).c_str() << " <= ? ";
break;
default:
- query << (*iter_keys).c_str() << " = ? ";
+ // where_query << (*iter_keys).c_str() << " = ? ";
pfc_log_debug("ODBCM::QueryFactory::GetSiblingCount(filter)::"
"invalid operator found");
return ODBCM_NULL_STRING;
break;
}
- /* In ORDER BY, we always take the first primary key */
- if (0 == orderby_flag) {
- orderby_query << " ORDER BY " << (*iter_keys).c_str() << " ;";
- orderby_flag = 1;
- }
if (loop1 != primarykeys.size()-1) {
- query << " AND ";
+ where_query << " AND ";
}
}
/** Fill the table name in the query */
/** Example: Query should as below */
/** SELECT controller_name FROM c_controller_common_table WHERE
* controller_name > ? ORDER BY controller_name */
- if (speccondition_flag == 1) {
- query << special_condition.str();
+ if (primarykeys.size() != 0) {
+ query << where_query.str();
+ if (speccondition_flag == 1) {
+ query << special_condition.str();
+ }
}
- query << orderby_query.str();
+ query << " " << getOrderByString(db_table_schema.table_name_,
+ db_table_schema.primary_keys_);
+ query << ";";
pfc_log_info("ODBCM::QueryFactory::GetSiblingCount:: "
"Query is \"%s\"", (query.str()).c_str());
return query.str();
/**
* @Description : To frame query for getting the sibling rows based upon
* filter options in request.
- * @param[in] : unc_keytype_datatype_t, DBTableSchema&, vector<ODBCMOperator>
- * @return : SQLQUERY
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup
+ * max_repetition_count - specifies the number of rows
+ * to return
+ * db_table_schema - object holds the key and value struct
+ * of specified KT instance
+ * filter_operators - vector to decide the filter while
+ * framing query
+ * op_type - specifies Operation type siblingbegin/sibling
+ * @return : SQLQUERY - framed query will be retuned
**/
SQLQUERY QueryFactory::operation_getsiblingrows(
unc_keytype_datatype_t db_name,
uint32_t max_repetition_count,
std::vector<ODBCMOperator> filter_operators,
unc_keytype_operation_t op_type) {
- std::string prefix;
+ std::string prefix = "";
std::ostringstream getsibling_query;
uint32_t loop1, loop2, loop3;
std::ostringstream getsibling_primarykey;
std::vector<TableAttrSchema> :: iterator iter_vector;
std::list <std::vector<TableAttrSchema> > ::iterator iter_list;
- if (db_name == UNC_DT_CANDIDATE) {
- prefix = "c_";
- } else if (db_name == UNC_DT_RUNNING) {
- prefix = "r_";
- } else if (db_name == UNC_DT_STARTUP) {
- prefix = "s_";
- } else if (db_name == UNC_DT_IMPORT) {
- prefix = "i_";
- } else if (db_name == UNC_DT_STATE) {
- prefix = "r_";
- } else {
+ switch (db_name) {
+ /** Get the table name prefix */
+ case UNC_DT_CANDIDATE:
+ prefix = "c_";
+ break;
+ case UNC_DT_RUNNING:
+ prefix = "r_";
+ break;
+ case UNC_DT_STARTUP:
+ prefix = "s_";
+ break;
+ case UNC_DT_IMPORT:
+ prefix = "i_";
+ break;
+ case UNC_DT_STATE:
+ prefix = "r_";
+ break;
+ default:
return ODBCM_NULL_STRING;
}
+
getsibling_query << "SELECT ";
getsibling_where << " where ";
/** Traverse the list to get the Attribute vector In this case,
iter_list != db_table_schema.row_list_.end(); iter_list++, loop1++) {
/* This vector contains all attributes of a row in a table */
std::vector<TableAttrSchema>attributes_vector = *iter_list;
+ if (attributes_vector.size() == 0)
+ return ODBCM_NULL_STRING;
/* Get the column names and values */
for (loop2 = 0, iter_vector = attributes_vector.begin();
iter_vector != attributes_vector.end(); iter_vector++, loop2++) {
- getsibling_query << (*iter_vector).table_attribute_name;
+ getsibling_query << ODBCManager::get_ODBCManager()->GetColumnName(
+ (*iter_vector).table_attribute_name);
if (loop2 != attributes_vector.size()-1)
getsibling_query << ",";
} // for attribute vectors
getsibling_where << (*iter_primarykey) << " <= ? ";
break;
default:
- getsibling_where << (*iter_primarykey) << " = ? ";
+ // getsibling_where << (*iter_primarykey) << " = ? ";
pfc_log_debug("ODBCM::QueryFactory::GetSiblingRows(filter)::"
"invalid operator found");
return ODBCM_NULL_STRING;
} // for primarykey vector
} // for list of rows
- getsibling_query << " FROM " << prefix << db_table_schema.table_name_ <<
- getsibling_where.str() << " ORDER BY " << getsibling_primarykey.str()
- << " ASC LIMIT " << max_repetition_count;
+ getsibling_query << " FROM " << prefix << ODBCManager::get_ODBCManager()->
+ GetTableName(db_table_schema.table_name_);
+ if (db_table_schema.primary_keys_.size() != 0) {
+ getsibling_query << getsibling_where.str();
+ }
+ getsibling_query << getOrderByString(db_table_schema.table_name_,
+ db_table_schema.primary_keys_);
+ getsibling_query << " ASC LIMIT " << max_repetition_count << ";";
pfc_log_info("ODBCM::QueryFactory::GetSiblingRows: Query is \"%s\"",
(getsibling_query.str()).c_str());
return getsibling_query.str();
/**
* @Description : This method is invoked when getsiblingcount
* request comes, this will fetch the sibling count from table
- * @param[in] : unc_keytype_datatype_t, std::string
- * @return : SQLQUERY
+ * @param[in] : db_name - specifies the configuration
+ * i.e.candidate/running/startup,
+ * table_name - specifies the table name
+ * @return : SQLQUERY - framed query will be retuned
**/
SQLQUERY QueryFactory::operation_getrowcount(unc_keytype_datatype_t db_name,
std::string table_name) {
- std::string prefix;
+ std::string prefix = "";
std::ostringstream query;
/** Based on the db type, get the prefix for table name */
- if (db_name == UNC_DT_CANDIDATE)
+ switch (db_name) {
+ /** Get the table name prefix */
+ case UNC_DT_CANDIDATE:
prefix = "c_";
- else if (db_name == UNC_DT_RUNNING)
+ break;
+ case UNC_DT_RUNNING:
prefix = "r_";
- else if (db_name == UNC_DT_STARTUP)
+ break;
+ case UNC_DT_STARTUP:
prefix = "s_";
- else if (db_name == UNC_DT_IMPORT)
+ break;
+ case UNC_DT_IMPORT:
prefix = "i_";
- else if (db_name == UNC_DT_STATE)
+ break;
+ case UNC_DT_STATE:
prefix = "r_";
- else
+ break;
+ default:
return ODBCM_NULL_STRING;
+ }
+
query << "SELECT * FROM " << prefix << table_name;
pfc_log_info("ODBCM::QueryFactory::GetRowCount:: "
"Query is \"%s\"", (query.str()).c_str());
* STEP3: Copy Candidate->Running if above steps are success
* copydatabase will be reused for step3.
*
- * @param[in] : unc_data_type_t src_db,
- * unc_data_type_t dst_db,
- * uint32_t query_type
- * @return : SQLQUERY
+ * @param[in] : src_db - To specifies the source DB,
+ * dst_db - To specifies the destination DB
+ * query_type - To specifies the type query to
+ * be framed
+ * @return : SQLQUERY - framed query will be retuned
**/
SQLQUERY* QueryFactory::operation_commit_all_config(
unc_keytype_datatype_t src_db_name,
/**copy the actual_version, oper_status STATE details into
* candidate controller_table*/
commit_query << "UPDATE " << "c_"UPPL_CTR_TABLE <<
- " SET " << CTR_ACTUAL_VERSION << " = " << "r_"UPPL_CTR_TABLE << "." <<
- CTR_ACTUAL_VERSION << ", " << CTR_OPER_STATUS << " = " <<
- "r_"UPPL_CTR_TABLE << "." << CTR_OPER_STATUS << " from " <<
+ " SET " << CTR_ACTUAL_VERSION_STR << " = " << "r_"UPPL_CTR_TABLE << "." <<
+ CTR_ACTUAL_VERSION_STR << ", " << CTR_OPER_STATUS_STR << " = " <<
+ "r_"UPPL_CTR_TABLE << "." << CTR_OPER_STATUS_STR << " from " <<
"r_"UPPL_CTR_TABLE << " where " << "c_"UPPL_CTR_TABLE <<
- "." << CTR_NAME << " = " << "r_"UPPL_CTR_TABLE << "." <<
- CTR_NAME << ";";
+ "." << CTR_NAME_STR << " = " << "r_"UPPL_CTR_TABLE << "." <<
+ CTR_NAME_STR << ";";
p_commit_db[loop] = commit_query.str();
pfc_log_info("ODBCM::QueryFactory::CommitAllConfiguration: "
"COPY_STATE_INFO:Query:%d is \"%s\"", loop,
loop++;
/**copy oper_status STATE details into candidate ctr_domain_table*/
commit_query << "UPDATE " << "c_"UPPL_CTR_DOMAIN_TABLE <<
- " SET " << CTR_OPER_STATUS << " = " <<
- "r_"UPPL_CTR_DOMAIN_TABLE << "." << CTR_OPER_STATUS << " from " <<
+ " SET " << CTR_OPER_STATUS_STR << " = " <<
+ "r_"UPPL_CTR_DOMAIN_TABLE << "." << CTR_OPER_STATUS_STR << " from " <<
"r_"UPPL_CTR_DOMAIN_TABLE << " where " << "c_"UPPL_CTR_DOMAIN_TABLE <<
- "." << CTR_NAME << " = " << "r_"UPPL_CTR_DOMAIN_TABLE << "." <<
- CTR_NAME << ";";
+ "." << CTR_NAME_STR << " = " << "r_"UPPL_CTR_DOMAIN_TABLE << "." <<
+ CTR_NAME_STR << ";";
p_commit_db[loop] = commit_query.str();
pfc_log_info("ODBCM::QueryFactory::CommitAllConfiguration: "
"COPY_STATE_INFO:Query:%d is \"%s\"", loop,
loop++;
/**copy oper_status STATE details into candidate boundary_table*/
commit_query << "UPDATE " << "c_"UPPL_BOUNDARY_TABLE <<
- " SET " << CTR_OPER_STATUS << " = " <<
- "r_"UPPL_BOUNDARY_TABLE << "." << CTR_OPER_STATUS << " from " <<
+ " SET " << CTR_OPER_STATUS_STR << " = " <<
+ "r_"UPPL_BOUNDARY_TABLE << "." << CTR_OPER_STATUS_STR << " from " <<
"r_"UPPL_BOUNDARY_TABLE << " where " << "c_"UPPL_BOUNDARY_TABLE <<
- "." << BDRY_ID << " = " << "r_"UPPL_BOUNDARY_TABLE<< "." <<
- BDRY_ID << ";";
+ "." << BDRY_ID_STR << " = " << "r_"UPPL_BOUNDARY_TABLE<< "." <<
+ BDRY_ID_STR << ";";
p_commit_db[loop] = commit_query.str();
pfc_log_info("ODBCM::QueryFactory::CommitAllConfiguration: "
"COPY_STATE_INFO:Query:%d is \"%s\"", loop,
char *p_table = const_cast <char*>((*iter_dstvector).c_str());
if (strcmp(p_table, "r_"UPPL_CTR_DOMAIN_TABLE) == 0) {
commit_query << "DELETE FROM " << (*iter_dstvector) <<
- " WHERE " << CTR_NAME << " IN (SELECT " << CTR_NAME <<
- " FROM r_" << UPPL_CTR_TABLE <<" WHERE " << CTR_TYPE <<
+ " WHERE " << CTR_NAME_STR << " IN (SELECT " << CTR_NAME_STR <<
+ " FROM r_" << UPPL_CTR_TABLE <<" WHERE " << CTR_TYPE_STR <<
"=" << UNC_CT_UNKNOWN << ");";
}
if ((strcmp(p_table, "r_"UPPL_CTR_TABLE) == 0) ||
(strcmp(p_table, "r_"UPPL_BOUNDARY_TABLE) == 0)) {
- commit_query << "TRUNCATE " << (*iter_dstvector) << ";";
+ commit_query << "DELETE FROM " << (*iter_dstvector) << ";";
}
if (index >= ODBCM_MAX_UPPL_TABLES) {
delete []p_commit_db;
/**
* @Description : This function set the function pointer with
* appropriate method to frame thw query
- * @param[in] : int
- * @return : None
+ * @param[in] : operation_type - specifies the operation type
+ * @return : void
**/
void QueryFactory::SetOperation(int operation_type) {
switch (operation_type) {
GetQuery = &QueryFactory::operation_createonerow;
break;
case UPDATEONEROW:
- GetQuery = &QueryFactory::operation_updateonerow;
+ GetQueryWithBool = &QueryFactory::operation_updateonerow;
break;
case DELETEONEROW:
GetQuery = &QueryFactory::operation_deleteonerow;
break;
}
}
+
+/**
+ * @Description : This function is to return the primary keys string
+ * @param[in] : ODBCMTable , std::vector <std::string> - primary key vector
+ * @return : std:string
+ **/
+std::string QueryFactory::getOrderByString(ODBCMTable table_id,
+ std::vector <std::string>& p_keys) {
+ std::ostringstream query;
+ uint32_t loop;
+ std::vector <std::string>::iterator iter_keys;
+ query << " ORDER BY ";
+ switch (table_id) {
+ case CTR_TABLE:
+ query << "controller_name";
+ return query.str();
+ case CTR_DOMAIN_TABLE:
+ query << "controller_name, domain_name";
+ return query.str();
+ case LOGICALPORT_TABLE:
+ query << "controller_name, domain_name, port_id";
+ return query.str();
+ case LOGICAL_MEMBERPORT_TABLE:
+ query <<
+ "controller_name, domain_name, port_id,switch_id, physical_port_id";
+ return query.str();
+ case SWITCH_TABLE:
+ query << "controller_name, switch_id";
+ return query.str();
+ case PORT_TABLE:
+ query << "controller_name, switch_id, port_id";
+ return query.str();
+ case LINK_TABLE:
+ query << "controller_name, switch_id1, port_id1, switch_id2, port_id2";
+ return query.str();
+ case BOUNDARY_TABLE:
+ query << "boundary_id";
+ return query.str();
+ default:
+ if (p_keys.size() == 0)
+ return ODBCM_NULL_STRING;
+ for (loop = 0, iter_keys = p_keys.begin();
+ iter_keys != p_keys.end(); iter_keys++, loop++) {
+ query << (*iter_keys).c_str();
+ if (loop != p_keys.size()-1) {
+ query << ",";
+ }
+ } // for
+ return query.str();
+ }
+}
+
} // namespace uppl
} // namespace unc
* @Description : This invokes SQLPrepare method, the query generated by
* QueryFactory will be given to SQLPrepare ODBC API to
* prepare the statement
- * @param[in] : string sql_edit_query, HSTMT &hstmt
- * @return : ODBCM_RC_STATUS
+ * @param[in] : sql_edit_query - specifies the framed query
+ * hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS is returned when SQLPrepare is success
+ * otherwise DB related error code will be returned
**/
ODBCM_RC_STATUS QueryProcessor::PrepareQueryStatement(
std::string sql_edit_query, HSTMT &hstmt) {
/**
* @Description : This method invokes SQLExecute for write operation
- * @param[in] : UpplDbOperationType, const HSTMT &
- * @return : ODBCM_RC_STATUS
+ * @param[in] : operation_type - specifies the db related operation
+ * i.e CREATE/DELETE/UPDATE/GETONEROW/GETBULK*
+ * hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS is returned when SQLExecute is success
+ * otherwise DB related error code will be returned
**/
ODBCM_RC_STATUS QueryProcessor::ExecuteEditDBQuery(
UpplDbOperationType operation_type, const HSTMT &hstmt) {
/**
* @Description : This method invokes SQLExecute for read operation
- * @param[in] : UpplDbOperationType, HSTMT&
- * @return : ODBCM_RC_STATUS
+ * @param[in] : operation_type - specifies the db related operation
+ * i.e CREATE/DELETE/UPDATE/GETONEROW/GETBULK*
+ * hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS is returned when SQLExecute is success
+ * otherwise DB related error code will be returned
**/
ODBCM_RC_STATUS QueryProcessor::ExecuteReadDBQuery(
UpplDbOperationType operation_type, HSTMT &hstmt) {
/** Initialize the local variables */
SQLLEN row_count = 0;
- SQLINTEGER col_count = 0;
RETCODE odbc_rc = ODBCM_RC_SUCCESS;
/** Execute the query */
odbc_rc = SQLExecute(hstmt);
if (odbc_rc != ODBCM_RC_SUCCESS &&
odbc_rc != ODBCM_RC_SUCCESS_WITH_INFO) {
pfc_log_error("ODBCM::QueryProcessor::ExecuteReadDBQuery: "
- "Error in SQLExecute: %s",
+ "Error in SQLExecute: %d, %s", odbc_rc,
ODBCMUtils::get_RC_Details(odbc_rc).c_str());
return (ODBCM_RC_STATUS)odbc_rc;
}
"Row count = %ld", row_count);
if (row_count <= 0) {
return ODBCM_RC_RECORD_NOT_FOUND;
- }
- /** Get the column result count */
- odbc_rc = SQLNumResultCols(hstmt,
- reinterpret_cast<SQLSMALLINT*>(&col_count));
- ODBCM_PROCESS_HANDLE_CHECK(hstmt, odbc_rc);
- if (odbc_rc != ODBCM_RC_SUCCESS &&
- odbc_rc != ODBCM_RC_SUCCESS_WITH_INFO) {
- pfc_log_error("ODBCM::QueryProcessor::ExecuteReadDBQuery:"
- "SQLNumResultCols Error : %s",
- ODBCMUtils::get_RC_Details(odbc_rc).c_str());
- return (ODBCM_RC_STATUS)odbc_rc;
- }
- /** If no column found for the read query */
- pfc_log_info("ODBCM::QueryProcessor::ExecuteReadDBQuery: "
- "Column count = %d", static_cast<int> (col_count));
- if (col_count <= 0) {
- pfc_log_info("ODBCM::QueryProcessor::ExecuteReadDBQuery: "
- "No record found !!!");
- return ODBCM_RC_RECORD_NOT_FOUND;
- }
- if (row_count > 0) {
- // odbc_rc = SQLFetch(hstmt);
+ } else {
ODBCM_PROCESS_HANDLE_CHECK(hstmt, odbc_rc);
if (odbc_rc != ODBCM_RC_SUCCESS &&
odbc_rc != ODBCM_RC_SUCCESS_WITH_INFO) {
/**
* @Description : This method is invoked for db group operations
- * @param[in] : UpplDbOperationType, const HSTMT&
- * @return : ODBCM_RC_STATUS
+ * @param[in] : operation_type - specifies the db related operation
+ * i.e CREATE/DELETE/UPDATE/GETONEROW/GETBULK*
+ * hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS is returned when SQLExecute is success
+ * otherwise DB related error code will be returned
**/
ODBCM_RC_STATUS QueryProcessor::ExecuteGroupOperationQuery(
UpplDbOperationType operation_type, const HSTMT &hstmt) {
pfc_log_info("ODBCM::QueryProcessor::ExecuteGroupOperationQuery: "
"No of rows in last executed query: %ld", row_count);
if (row_count <= 0) {
- pfc_log_info("ODBCM::QueryProcessor::ExecuteGroupOperationQuery: "
+ pfc_log_debug("ODBCM::QueryProcessor::ExecuteGroupOperationQuery: "
"No record exists !!!");
return ODBCM_RC_ROW_NOT_EXISTS;
} else {
- pfc_log_info("ODBCM::QueryProcessor::ExecuteGroupOperationQuery: "
+ pfc_log_debug("ODBCM::QueryProcessor::ExecuteGroupOperationQuery: "
"ODBCM_RC_ROW_EXISTS");
/** If row exists, fetch data from database */
odbc_rc = SQLFetch(hstmt);
/**
* @Description : To invoke SQLExecDirect
- * @param[in] : UpplDbOperationType, string, const HSTMT&
- * @return : ODBCM_RC_STATUS
+ * @param[in] : operation_type - specifies the db related operation
+ * i.e CREATE/DELETE/UPDATE/GETONEROW/GETBULK*
+ * query - specifies the framed query
+ * hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS is returned when SQLExecDirect is success
+ * otherwise DB related error code will be returned
**/
ODBCM_RC_STATUS QueryProcessor::ExecuteQueryDirect(
UpplDbOperationType operation_type,
/**
* @Description : This method will be invoked for executing a transaction
- * @param[in] : UpplDbOperationType, string *, const HSTMT&
- * @return : ODBCM_RC_STATUS
+ * @param[in] : operation_type - specifies the db related operation
+ * i.e CREATE/DELETE/UPDATE/GETONEROW/GETBULK*
+ * query - specifies the framed query
+ * hstmt - statement handler which carries the SQL Query
+ * @return : ODBCM_RC_SUCCESS is returned when ExecuteTransaction is
+ * success otherwise DB related error code will be returned
**/
ODBCM_RC_STATUS QueryProcessor::ExecuteTransaction(
- UpplDbOperationType operation_type, // Type of operation
- std::string *query, // Pointer to db query
- const HSTMT &hstmt) { // statment handler
+ UpplDbOperationType operation_type,
+ std::string *query,
+ const HSTMT &hstmt) {
/** Initialise the local variables */
uint8_t loop = 0;
uint8_t is_exists_false = 0;
for (loop = 0; loop < ODBCM_MAX_CANDIDATE_TABLES; loop++) {
/** If the query is NULL */
if (NULL == query[loop].c_str()) {
- pfc_log_info("ODBCM::QueryProcessor::ExecuteTransaction: "
+ pfc_log_error("ODBCM::QueryProcessor::ExecuteTransaction: "
"IsCandidateDiry Query:%d string is empty", loop);
return ODBCM_RC_ERROR_IN_FRAMEQUERY;
}
ODBCMUtils::get_RC_Details(odbc_rc).c_str());
return (ODBCM_RC_STATUS)odbc_rc;
}
- pfc_log_info("ODBCM::QueryProcessor::ExecuteTransaction: "
+ pfc_log_debug("ODBCM::QueryProcessor::ExecuteTransaction: "
"%ld rows with cs_row_status not as APPLIED", row_count);
/* Close the cursor */
odbc_rc = SQLCloseCursor(hstmt);
* Clear the structure and map
*/
}
-/** Return code string map structure array
- * */
+/**
+ * Return code string map structure array
+ **/
ReturnCodes ODBCMUtils::rcode_string[] = {
{ODBCM_RC_SUCCESS, "ODBCM_RC_SUCCESS"},
{ODBCM_RC_SUCCESS_WITH_INFO, "ODBCM_RC_SUCCESS_WITH_INFO"},
/**
* @Description : This method will Initialize OdbcmSQLStateMap,
* with the values from OdbcmReturnCode structure array
- * @param[in] : None
- * @return : ODBCM_RC_STATUS
+ * @param[in] : void
+ * @return : ODBCM_RC_SUCCESS - is returned when the initialize
+ * is done successfully.
+ * ODBCM_RC_* - is returned when the initialize is error
**/
ODBCM_RC_STATUS ODBCMUtils::Initialize_OdbcmSQLStateMap(void) {
/*
{"HY111", ODBCM_RC_GENERAL_ERROR},
{"HYC00", ODBCM_RC_GENERAL_ERROR},
{"HYT00", ODBCM_RC_QUERY_TIMEOUT},
- {"HYT01", ODBCM_RC_CONNECTION_TIMEOUT}
+ {"HYT01", ODBCM_RC_CONNECTION_TIMEOUT},
+ /**database access problem due to connection dead*/
+ {"57P01", ODBCM_RC_CONNECTION_ERROR}
};
/** Initialise the local variables */
uint32_t loop = 0;
/**
* @Description : Clear the OdbcmSQLStateMap if it is not empty
- * @param[in] : None
- * @return : ODBCM_RC_STATUS
+ * @param[in] : void
+ * @return : ODBCM_RC_SUCCESS - is returned when the Clearing of
+ * OdbcmSQLStateMap is done successfully.
**/
ODBCM_RC_STATUS ODBCMUtils::ClearOdbcmSQLStateMap(void) {
/** Check map is empty or not */
/**
* @Description : This method returns odbcm rc with respect to the
* sql_state string value
- * @param[in] : const std::string
- * @return : None
+ * @param[in] : odbcm_sqlstate - sql statement
+ * @return : ODBCM_RC_SUCCESS - is returned when the iterator
+ * is done successfully.
+ * ODBCM_RC_FAILED - is returned when the iterator is fails
**/
ODBCM_RC_STATUS ODBCMUtils::get_odbc_rc(const std::string odbcm_sqlstate) {
std::map<std::string, ODBCM_RC_STATUS>::iterator iter;
/**
* @Description : Print odbc info which are collected by SQLGetInfo()
- * @param[in] : SQLHDBC
+ * @param[in] : conn_handle - ODBC connection handle
* @return : None
**/
void ODBCMUtils::print_odbc_details(SQLHDBC conn_handle) {
/**
* @Description : return the ip address version 4
- * @param[in] : uint32_t
- * @return : string
+ * @param[in] : ip_address - ip address type i.e. IPV4
+ * @return : string - The conversion of ip adress to asci format
**/
std::string ODBCMUtils::get_ip_string(uint32_t ip_address) {
struct sockaddr_in ip;
/**
* @Description : return the ipv6 address string
- * @param[in] : uint8_t *ipv6_address
- * @return : string
+ * @param[in] : ipv6_address - ip address type i.e. IPV6
+ * @return : string - The conversion of ip adress to asci format
**/
std::string ODBCMUtils::get_ipv6_string(uint8_t *ipv6_address) {
sockaddr_in6 addr;
+ memset(&addr, 0, sizeof(sockaddr_in6));
char str[INET6_ADDRSTRLEN];
ODBCM_MEMSET(&str, '\0', INET6_ADDRSTRLEN);
ODBCM_MEMSET(&addr.sin6_addr, 0, sizeof addr.sin6_addr);
/**
* @Description : return the return code string if return code enum is given
- * @param[in] : int32_t error
- * @return : string
+ * @param[in] : error - error code
+ * @return : string - corresponding error code string
**/
-
-
std::string ODBCMUtils::get_RC_Details(int32_t error) {
int length;
if (error == ODBCM_RC_SQL_INVALID_HANDLE)
return std::string(rcode_string[error].rc_string);
else
return std::string("");
- /*
- if (error == ODBCM_RC_SQL_INVALID_HANDLE)
- return std::string("ODBCM_RC_SQL_INVALID_HANDLE");
- else if (error == ODBCM_RC_QUERY_FAILED)
- return std::string("ODBCM_RC_QUERY_FAILED");
- enum ODBCM_RC_STATUS rc_status;
-
- std::string rc_details = ODBCM_RC_STATUS_NAME_TABLE[error];
- pfc_log_info("ODBCM::ODBCMUtils::get_RC_Details:rc_details=%s",
- rc_details.c_str());
- if ("" != rc_details)
- return rc_details;
- else
- return std::string("");
-}
-
- switch (error) {
- case ODBCM_RC_SQL_INVALID_HANDLE:
- return "ODBCM_RC_SQL_INVALID_HANDLE";
- case ODBCM_RC_QUERY_FAILED:
- return "ODBCM_RC_QUERY_FAILED";
- case ODBCM_RC_SUCCESS:
- return "ODBCM_RC_SUCCESS";
- case ODBCM_RC_SUCCESS_WITH_INFO:
- return "ODBCM_RC_SUCCESS_WITH_INFO";
- case ODBCM_RC_QUERY_STILL_EXECUTING:
- return "ODBCM_RC_QUERY_STILL_EXECUTING";
- case ODBCM_RC_FAILED:
- return "ODBCM_RC_FAILED";
- case ODBCM_RC_COMMON_LINK_FAILURE:
- return "ODBCM_RC_COMMON_LINK_FAILURE";
- case ODBCM_RC_CONNECTION_ERROR:
- return "ODBCM_RC_CONNECTION_ERROR";
- case ODBCM_RC_CONNECTION_TIMEOUT:
- return "ODBCM_RC_CONNECTION_TIMEOUT";
- case ODBCM_RC_CONNECTION_IN_USE:
- return "ODBCM_RC_CONNECTION_IN_USE";
- // case ODBCM_RC_TRANSACTION_ERROR:
- // return "ODBCM_RC_TRANSACTION_ERROR";
- case ODBCM_RC_SERIALIZATION_ERROR:
- return "ODBCM_RC_SERIALIZATION_ERROR";
- case ODBCM_RC_INVALID_CONN_HANDLE:
- return "ODBCM_RC_INVALID_CONN_HANDLE";
- case ODBCM_RC_QUERY_TIMEOUT:
- return "ODBCM_RC_QUERY_TIMEOUT";
- case ODBCM_RC_ERROR_IN_FRAMEQUERY:
- return "ODBCM_RC_ERROR_IN_FRAMEQUERY";
- case ODBCM_RC_INVALID_TABLE_NAME:
- return "ODBCM_RC_INVALID_TABLE_NAME";
- case ODBCM_RC_INVALID_DB_OPERATION:
- return "ODBCM_RC_INVALID_DB_OPERATION";
- case ODBCM_RC_PKEY_VIOLATION:
- return "ODBCM_RC_PKEY_VIOLATION";
- case ODBCM_RC_MEMORY_ERROR:
- return "ODBCM_RC_MEMORY_ERROR";
- case ODBCM_RC_TABLE_NOT_FOUND:
- return "ODBCM_RC_TABLE_NOT_FOUND";
- case ODBCM_RC_RECORD_NOT_FOUND:
- return "ODBCM_RC_RECORD_NOT_FOUND";
- case ODBCM_RC_DATA_ERROR:
- return "ODBCM_RC_DATA_ERROR";
- case ODBCM_RC_RECORD_NO_MORE:
- return "ODBCM_RC_RECORD_NO_MORE";
- case ODBCM_RC_NO_RECORD:
- return "ODBCM_RC_NO_RECORD";
- case ODBCM_RC_ERROR_FETCHING_ROW:
- return "ODBCM_RC_ERROR_FETCHING_ROW";
- case ODBCM_RC_STMT_ERROR:
- return "ODBCM_RC_STMT_ERROR";
- case ODBCM_RC_DISCONNECT_ERROR:
- return "ODBCM_RC_DISCONNECT_ERROR";
- case ODBCM_RC_RECORD_ALREADY_EXISTS:
- return "ODBCM_RC_RECORD_ALREADY_EXISTS";
- case ODBCM_RC_CONN_ENV_ERROR:
- return "ODBCM_RC_CONN_ENV_ERROR";
- case ODBCM_RC_CONN_HANDLE_ERROR:
- return "ODBCM_RC_CONN_HANDLE_ERROR";
- case ODBCM_RC_GENERAL_ERROR:
- return "ODBCM_RC_GENERAL_ERROR";
- case ODBCM_RC_PARAM_BIND_ERROR:
- return "ODBCM_RC_PARAM_BIND_ERROR";
- case ODBCM_RC_WRONG_PARAM:
- return "ODBCM_RC_WRONG_PARAM";
- case ODBCM_RC_MORE_ROWS_FOUND:
- return "ODBCM_RC_MORE_ROWS_FOUND";
- case ODBCM_RC_ROW_EXISTS:
- return "ODBCM_RC_ROW_EXISTS";
- case ODBCM_RC_ROW_NOT_EXISTS:
- return "ODBCM_RC_ROW_NOT_EXISTS";
- case ODBCM_RC_CANDIDATE_DIRTY:
- return "ODBCM_RC_CANDIDATE_DIRTY";
- case ODBCM_RC_CANDIDATE_NO_DIRTY:
- return "ODBCM_RC_CANDIDATE_NO_DIRTY";
- case ODBCM_RC_SQL_ERROR:
- return "ODBCM_RC_SQL_ERROR";
- case ODBCM_RC_SQL_NEED_DATA:
- return "ODBCM_RC_SQL_NEED_DATA";
- case ODBCM_RC_ROW_STATUS_NOT_FOUND:
- return "ODBCM_RC_ROW_STATUS_NOT_FOUND";
- case ODBCM_RC_COLUMN_DOES_NOT_MATCH:
- return "ODBCM_RC_COLUMN_DOES_NOT_MATCH";
- case ODBCM_RC_PREPARED_STMT_ERROR:
- return "ODBCM_RC_PREPARED_STMT_ERROR";
- case ODBCM_RC_TYPE_ATTR_VIOLATION:
- return "ODBCM_RC_TYPE_ATTR_VIOLATION";
- case ODBCM_RC_INVALID_DESC:
- return "ODBCM_RC_INVALID_DESC";
- case ODBCM_RC_UNABLE_ESTABLISH_CONN:
- return "ODBCM_RC_UNABLE_ESTABLISH_CONN";
- case ODBCM_RC_CONNECTION_REJECTED:
- return "ODBCM_RC_CONNECTION_REJECTED";
- case ODBCM_RC_INSERT_VAL_LIST_NOT_MATCHED:
- return "ODBCM_RC_INSERT_VAL_LIST_NOT_MATCHED";
- case ODBCM_RC_DATA_TRUNCATION_ERROR:
- return "ODBCM_RC_DATA_TRUNCATION_ERROR";
- case ODBCM_RC_VARIABLE_NOT_SUPPLIED:
- return "ODBCM_RC_VARIABLE_NOT_SUPPLIED";
- case ODBCM_RC_VALUE_OUT_OF_RANGE:
- return "ODBCM_RC_VALUE_OUT_OF_RANGE";
- case ODBCM_RC_DATETIME_ERROR:
- return "ODBCM_RC_DATETIME_ERROR";
- case ODBCM_RC_DIVISIBLE_ERROR:
- return "ODBCM_RC_DIVISIBLE_ERROR";
- case ODBCM_RC_FIELD_OVERFLOW:
- return "ODBCM_RC_FIELD_OVERFLOW";
- case ODBCM_RC_INVALID_CHAR_SPEC:
- return "ODBCM_RC_INVALID_CHAR_SPEC";
- case ODBCM_RC_CURSOR_STATE:
- return "ODBCM_RC_CURSOR_STATE";
- case ODBCM_RC_INVALID_CURSOR:
- return "ODBCM_RC_INVALID_CURSOR";
- case ODBCM_RC_SYNTAX_ERROR:
- return "ODBCM_RC_SYNTAX_ERROR";
- case ODBCM_RC_INDEX_NOT_FOUND:
- return "ODBCM_RC_INDEX_NOT_FOUND";
- case ODBCM_RC_COLUMN_ALREADY_EXISTS:
- return "ODBCM_RC_COLUMN_ALREADY_EXISTS";
- case ODBCM_RC_COLUMN_NOT_FOUND:
- return "ODBCM_RC_COLUMN_NOT_FOUND";
- case ODBCM_RC_NULL_POINTER_ERROR:
- return "ODBCM_RC_NULL_POINTER_ERROR";
- case ODBCM_RC_FUNC_SEQUENCE_ERROR:
- return "ODBCM_RC_FUNC_SEQUENCE_ERROR";
- case ODBCM_RC_TRANSACTION_ERROR:
- return "ODBCM_RC_TRANSACTION_ERROR";
- case ODBCM_RC_TABLE_EXISTS:
- return "ODBCM_RC_TABLE_EXISTS";
- case ODBCM_RC_COLUMN_ALREADY:
- return "ODBCM_RC_COLUMN_ALREADY";
- case ODBCM_RC_SQL_NO_DATA:
- return "ODBCM_RC_SQL_NO_DATA";
- default:
- pfc_log_debug("ODBCM::ODBCMUtils::get_RC_Details: "
- "Unknown error:%d", error);
- return "UNKNOWN TYPE";
- break;
- }
- */
}
/**
- *@Description : To print the error location
- *@param[in] : SQLRETURN odbcm_rc, sint32_t line, string file
- *@return : None
+ * @Description : To print the error location
+ * @param[in] : odbcm_rc - return code of ODBCM api
+ line - specify the line number
+ file - specify the file name
+ * @return : None
**/
void ODBCMUtils::OdbcmHandleLocationPrint(SQLRETURN odbcm_rc,
int32_t line, std::string file) {
}
/**
-*@Description : To print the return values
-*@param[in] : SQLSMALLINT htype, SQLHANDLE hndl
-*@return : ODBCM_RC_STATUS
+* @Description : To print the return values
+* @param[in] : htype - handle type
+ hndl - handle
+* @return : ODBCM_RC_SUCCESS - if the OdbcmHandleDiagnosticsPrint is
+* success
+* ODBCM_RC_* - if the OdbcmHandleDiagnosticsPrint is
+* failed
**/
ODBCM_RC_STATUS ODBCMUtils::OdbcmHandleDiagnosticsPrint(
- SQLSMALLINT htype, /* handle type */
- SQLHANDLE hndl /* handle */ ) {
+ SQLSMALLINT htype,
+ SQLHANDLE hndl) {
/** Initialise the local variables */
SQLCHAR message[SQL_MAX_MESSAGE_LENGTH + 1];
SQLCHAR sqlstate[SQL_SQLSTATE_SIZE + 1];
rc = ODBCMUtils::get_odbc_rc(std::string((const char*)sqlstate));
if (rc != ODBCM_RC_FAILED) {
if (rc == ODBCM_RC_COMMON_LINK_FAILURE) {
- pfc_log_fatal("ODBCM::ODBCMUtills:: ODBCM_RC_COMMON_LINK_FAILURE");
+ pfc_log_error("ODBCM::ODBCMUtills:: ODBCM_RC_COMMON_LINK_FAILURE");
+ return ODBCM_RC_CONNECTION_ERROR;
}
- pfc_log_debug("ODBCM::ODBCMUtils::SQLGetDiagRec: SQLState: %s,"
+ pfc_log_debug("ODBCM::ODBCMUtils::SQLGetDiagRec: SQLState: %s,"
"OdbcmReturnCode: %d(%s)", sqlstate, rc,
ODBCMUtils::get_RC_Details(rc).c_str());
return (ODBCM_RC_STATUS) rc;
} /* OdbcmHandleDiagnosticsPrint */
/**
-*@Description : To print the debug information - outputs to screen
- unexpected occurrences with ODBCM functions
-*@param[in] : SQLSMALLINT, SQLHANDLE, SQLRETURN, int32_t, string
-*@return : ODBCM_RC_STATUS
+* @Description : To print the debug information - outputs to screen
+* unexpected occurrences with ODBCM functions
+* @param[in] : htype - handle type
+* hndl - handle
+* odbcm_rc - return code of ODBCM api
+* line - specify the line number
+* file - specify the file name
+* @return : ODBCM_RC_SUCCESS - if the OdbcmHandleInfoPrint is success
+* ODBCM_RC_* - if the OdbcmHandleInfoPrint is failed
**/
ODBCM_RC_STATUS ODBCMUtils::OdbcmHandleInfoPrint(
- SQLSMALLINT htype, /* handle type */
+ SQLSMALLINT htype,
SQLHANDLE hndl,
- SQLRETURN odbcm_rc, /*return code of ODBCM api */
+ SQLRETURN odbcm_rc,
int32_t line,
std::string file) {
/** Initialize the local variables */
} /* OdbcmHandleInfoPrint */
/**
-*@Description : To handle the sql cancel statment
-*@param[in] : SQLHANDLE htype
-*@return : int
+* @Description : To handle the sql cancel statment
+* @param[in] : htype - handle type
+* @return : int - returns a numeric value based on the
+* OdbcmHandleSqlCancel function
**/
int ODBCMUtils::OdbcmHandleSqlCancel(SQLHANDLE htype) {
/** Initialise the local variables */
} /*OdbcmHandleSqlCancel(htype) */
/**
-*@Description : To free stmt handles & print unexpected occurrences
-*@param[in] : SQLHANDLE htype
-*@return : int
+* @Description : To free stmt handles & print unexpected occurrences
+* @param[in] : hstmt - handle statement
+* @return : int - returns a numeric value based on the
+* OdbcmStmtResourcesFree function
**/
int ODBCMUtils::OdbcmStmtResourcesFree(SQLHANDLE hstmt) {
/** Initialise the local variables */
odbcm_rc = SQLFreeStmt(hstmt, SQL_UNBIND);
rc = OdbcmHandleInfoPrint(
SQL_HANDLE_STMT, hstmt, odbcm_rc, __LINE__, __FILE__);
- if (rc != 0)
- return 1;
/** Free the statement handle */
odbcm_rc = SQLFreeStmt(hstmt, SQL_RESET_PARAMS);
rc = OdbcmHandleInfoPrint(
SQL_HANDLE_STMT, hstmt, odbcm_rc, __LINE__, __FILE__);
- if (rc != 0)
- return 1;
/** Free the statement handle */
odbcm_rc = SQLFreeStmt(hstmt, SQL_CLOSE);
rc = OdbcmHandleInfoPrint(
SQL_HANDLE_STMT, hstmt, odbcm_rc, __LINE__, __FILE__);
+ if (NULL != hstmt)
+ SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
if (rc != 0)
return 1;
/**
*@Description : To rollback transactions on a single connection
-*@param[in] : SQLHANDLE hdbc
+*@param[in] : hdbc - handler database connection
*@return : void
**/
void ODBCMUtils::OdbcmTransRollback(SQLHANDLE hdbc) {
using unc::uppl::PhysicalLayer;
using unc::uppl::ODBCMUtils;
+using unc::uppl::ODBCMTableColumns;
-// For giving response to logical using serversession object
-void PhyUtil::getRespHeaderFromReqHeader(physical_request_header rqh,
+/**getRespHeaderFromReqHeader
+ * @Description : This function is for giving response to logical using
+ * serversession object
+ * @param[in] : rqh - object of the physical request header structure
+ * @param[out] : &rsh - object of the physical response header structure
+ * @return : void
+ * */
+void PhyUtil::getRespHeaderFromReqHeader(const physical_request_header& rqh,
physical_response_header& rsh) {
rsh.client_sess_id = rqh.client_sess_id;
rsh.config_id = rqh.config_id;
rsh.result_code = 0;
}
-// For giving response to logical using serversession object
+/**sessOutRespHeader
+ * @Description : This function is for giving response to logical using
+ * serversession object
+ * @param[in] : sess - Object of ServerSession where the request
+ * argument present
+ * @param[out] : &rsh - object of the physical response header structure
+ * @return : void
+ * */
int PhyUtil::sessOutRespHeader(ServerSession& sess,
- physical_response_header& rsh) {
+ const physical_response_header& rsh) {
int err = 0;
err = sess.addOutput(rsh.client_sess_id);
if (err != UPPL_RC_SUCCESS) return err;
return err;
}
-void PhyUtil::printReqHeader(physical_request_header rqh) {
+/**printReqHeader
+ * @Description : This function prints the attributes that are present in
+ * physical request header structure
+ * @param[in] : rqh - object of the physical request header structure
+ * @return : void
+ * */
+void PhyUtil::printReqHeader(const physical_request_header& rqh) {
stringstream ss;
ss << "Request to UPPL : " << endl
<< " session_id : " << rqh.client_sess_id << endl
pfc_log_info((const char*)(ss.str().c_str()));
}
-void PhyUtil::printRespHeader(physical_response_header rsh) {
+/**printRespHeader
+ * @Description : This function prints the attributes that are present in
+ * physical response header structure
+ * @param[in] : rsh - object of the physical response header structure
+ * @return : void
+ * */
+void PhyUtil::printRespHeader(const physical_response_header& rsh) {
stringstream ss;
ss << "Response from UPPL: "<< endl
<< " session_id : " << rsh.client_sess_id << endl
pfc_log_info((const char*)(ss.str().c_str()));
}
-// For getting the request from logical using serversession object.
+/**sessGetReqHeader
+ * @Description : This function is for getting the request from logical using
+ * serversession object.
+ * @param[in] : sess - Object of ServerSession where the request
+ * argument present
+ * @param[out] : rqh - object of the physical request header structure
+ * @return : void
+ * */
int PhyUtil::sessGetReqHeader(ServerSession& sess,
physical_request_header& rqh) {
int err = 0;
return err;
}
-// For sending request to driver using clientsessioin object
+/**sessOutReqHeader
+ * @Description : This function is for sending request to driver using
+ * clientsessioin object
+ * @param[in] : cli_sess - Object of ClientSession where the request
+ * argument present
+ * @param[out] : rqh - object of the physical request header structure
+ * @return : void
+ * */
int PhyUtil::sessOutReqHeader(ClientSession& cli_sess,
- physical_request_header rqh) {
+ const physical_request_header& rqh) {
int err = 0;
err = cli_sess.addOutput(rqh.client_sess_id);
if (err != UPPL_RC_SUCCESS) return err;
return err;
}
-// For getting the repsonse from driver
+/**sessGetRespHeader
+ * @Description : This function is for getting the repsonse from driver using
+ * clientsessioin object
+ * @param[in] : cli_sess - Object of ClientSession where the request
+ * argument present
+ * @param[out] : rsh - object of the physical response header structure
+ * @return : void
+ * */
int PhyUtil::sessGetRespHeader(ClientSession& cli_sess,
physical_response_header& rsh) {
int err = 0;
return err;
}
-void PhyUtil::printDriverReqHeader(driver_request_header rqh) {
+/**printDriverReqHeader
+ * @Description : This function prints the attributes that are present in
+ * driver request header structure
+ * @param[in] : rqh - object of the driver request header structure
+ * @return : void
+ * */
+void PhyUtil::printDriverReqHeader(const driver_request_header& rqh) {
stringstream ss;
ss << "Request to Driver : " << endl
<< " client_sess_id: " << rqh.client_sess_id << endl
pfc_log_info((const char*)(ss.str().c_str()));
}
-void PhyUtil::printDriverRespHeader(driver_response_header rsh) {
+/**printDriverRespHeader
+ * @Description : This function prints the attributes that are present in
+ * driver response header structure
+ * @param[in] : rsh - object of the driver response header structure
+ * @return : void
+ * */
+void PhyUtil::printDriverRespHeader(const driver_response_header& rsh) {
stringstream ss;
ss << "Response from Driver: "<< endl
<< " client_sess_id: " << rsh.client_sess_id << endl
pfc_log_info((const char*)(ss.str().c_str()));
}
-// For sending request to driver using clientsessioin object
+/**sessOutDriverReqHeader
+ * @Description : This function is for sending request to driver using
+ * clientsessioin object
+ * @param[in] : cli_sess - Object of ClientSession where the request
+ * argument present
+ * @param[out] : rqh - object of the driver request header structure
+ * @return : void
+ * */
int PhyUtil::sessOutDriverReqHeader(ClientSession& cli_sess,
- driver_request_header rqh) {
+ const driver_request_header& rqh) {
int err = 0;
err = cli_sess.addOutput(rqh.client_sess_id);
if (err != UPPL_RC_SUCCESS) return err;
return err;
}
-// For getting the repsonse from driver
+/**sessGetDriverRespHeader
+ * @Description : This function is for getting the repsonse from driver using
+ * clientsessioin object
+ * @param[in] : cli_sess - Object of ClientSession where the request
+ * argument present
+ * @param[out] : rsh - object of the driver response header structure
+ * @return : void
+ * */
int PhyUtil::sessGetDriverRespHeader(ClientSession& cli_sess,
driver_response_header& rsh) {
int err = 0;
return err;
}
-// For getting the event header from driver
+/**sessGetDriverEventHeader
+ * @Description : This function is for getting the event header from driver
+ * using clientsessioin object
+ * @param[in] : cli_sess - Object of ClientSession where the request
+ * argument present
+ * @param[out] : &rsh - object of the driver event header structure
+ * @return : void
+ * */
int PhyUtil::sessGetDriverEventHeader(ClientSession& cli_sess,
driver_event_header& rsh) {
int err = 0;
return err;
}
-// For getting the alarm header from driver
+/**sessGetDriverAlarmHeader
+ * @Description : This function is for getting the alarm header from driver
+ * using clientsessioin object
+ * @param[in] : cli_sess - Object of ClientSession where the request
+ * argument present
+ * @param[out] : &rsh - object of the driver alarm header structure
+ * @return : void
+ * */
int PhyUtil::sessGetDriverAlarmHeader(ClientSession& cli_sess,
driver_alarm_header& rsh) {
int err = 0;
<< " data_type : " << rsh.data_type << endl
<< " key_type : " << rsh.key_type << endl
<< " alarm_type : " << rsh.alarm_type;
- pfc_log_debug((const char*)(ss.str().c_str()));
+ pfc_log_info((const char*)(ss.str().c_str()));
return err;
}
-// For sending the event header to northbound
+/**sessOutNBEventHeader
+ * @Description : This function is for sending the event header to northbound
+ * using ServerEvent object
+ * @param[in] : cli_sess - Object of ServerEvent where the request
+ * argument present
+ * @param[out] : &rqh - object of the northbound event header structure
+ * @return : void
+ * */
int PhyUtil::sessOutNBEventHeader(ServerEvent& cli_sess,
- northbound_event_header& rqh) {
+ const northbound_event_header& rqh) {
int err = 0;
err = cli_sess.addOutput(rqh.operation);
if (err != UPPL_RC_SUCCESS) return err;
<< " operation : " << rqh.operation << endl
<< " data_type : " << rqh.data_type << endl
<< " key_type : " << rqh.key_type;
- pfc_log_debug((const char*)(ss.str().c_str()));
+ pfc_log_info((const char*)(ss.str().c_str()));
return err;
}
-// For sending the alarm header to northbound
+/**sessOutNBAlarmHeader
+ * @Description : This function is for sending the alarm header to northbound
+ * using ServerEvent object
+ * @param[in] : cli_sess - Object of ServerEvent where the request
+ * argument present
+ * @param[out] : &rqh - object of the northbound alarm header structure
+ * @return : void
+ * */
int PhyUtil::sessOutNBAlarmHeader(ServerEvent& cli_sess,
- northbound_alarm_header& rqh) {
+ const northbound_alarm_header& rqh) {
int err = 0;
err = cli_sess.addOutput(rqh.operation);
if (err != UPPL_RC_SUCCESS) return err;
<< " data_type : " << rqh.data_type << endl
<< " key_type : " << rqh.key_type << endl
<< " alarm_type : " << rqh.alarm_type;
- pfc_log_debug((const char*)(ss.str().c_str()));
+ pfc_log_info((const char*)(ss.str().c_str()));
return err;
}
-/* Following function checks the controller status and gives the oper status
- * , audit status and audit_import state */
-
-UpplReturnCode PhyUtil::GetControllerStatus(unc_keytype_datatype_t dt_type,
- string controller_id,
- uint8_t& oper_status) {
- // Structure used to send request to ODBC
- DBTableSchema dbtableschema_obj;
- // Construct Primary key list
- vector<string> vect_prim_keys;
- vect_prim_keys.push_back("controller_name");
-
- dbtableschema_obj.set_primary_keys(vect_prim_keys);
- dbtableschema_obj.set_table_name("controller_common_table");
-
- // TableAttrSchema holds table_name, primary key, attr_name
- vector<TableAttrSchema> vect_table_attr_schema;
- TableAttrSchema table_attr_schema_obj;
-
-
- // controller_name
- PhyUtil::FillDbSchema("controller_name", controller_id,
- controller_id.length(), DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
-
- // oper_status
- string oper_status_value = PhyUtil::uint8tostr(oper_status);
- PhyUtil::FillDbSchema("oper_status", oper_status_value,
- oper_status_value.length(), DATATYPE_UINT16,
- vect_table_attr_schema);
-
- dbtableschema_obj.PushBackToRowList(vect_table_attr_schema);
-
- ODBCM_RC_STATUS read_db_status =
- ODBCManager::get_ODBCManager()->GetOneRow(dt_type, dbtableschema_obj);
-
- if (read_db_status == ODBCM_RC_SUCCESS) {
- list< vector<TableAttrSchema> > lvTas = dbtableschema_obj.get_row_list();
- list< vector<TableAttrSchema> >::iterator vIter = lvTas.begin();
- vector<TableAttrSchema> ::iterator tIter = (*vIter).begin();
- for ( ; tIter != (*vIter).end(); ++tIter) {
- TableAttrSchema tab_schema = (*tIter);
- string attr_name = tab_schema.table_attribute_name;
- string attr_value;
- if (attr_name == "oper_status") {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- oper_status = attr_value[0];
- }
- }
- } else {
- pfc_log_error("Unable to read from db");
- }
- return UPPL_RC_SUCCESS;
-}
-
-UpplReturnCode PhyUtil::GetOperStatus(unc_keytype_datatype_t dt_type,
- string controller_name,
- uint16_t& oper_status) {
- // Structure used to send request to ODBC
- DBTableSchema dbtableschema_obj;
- // Construct Primary key list
- vector<string> vect_prim_keys;
- vect_prim_keys.push_back("controller_name");
-
- dbtableschema_obj.set_primary_keys(vect_prim_keys);
- dbtableschema_obj.set_table_name("controller_table");
-
- // TableAttrSchema holds table_name, primary key, attr_name
- vector<TableAttrSchema> vect_table_attr_schema;
- TableAttrSchema table_attr_schema_obj;
-
-
- // controller_name
- PhyUtil::FillDbSchema("controller_name", controller_name,
- controller_name.length(), DATATYPE_UINT8_ARRAY_32,
- vect_table_attr_schema);
-
- // oper_status
- string oper_status_value = PhyUtil::uint16tostr(oper_status);
- PhyUtil::FillDbSchema("oper_status", oper_status_value,
- oper_status_value.length(), DATATYPE_UINT16,
- vect_table_attr_schema);
-
- dbtableschema_obj.PushBackToRowList(vect_table_attr_schema);
-
- ODBCM_RC_STATUS read_db_status =
- ODBCManager::get_ODBCManager()->GetOneRow(dt_type, dbtableschema_obj);
- if (read_db_status == ODBCM_RC_SUCCESS) {
- list< vector<TableAttrSchema> > lvTas = dbtableschema_obj.get_row_list();
- list< vector<TableAttrSchema> >::iterator vIter = lvTas.begin();
- vector<TableAttrSchema> ::iterator tIter = (*vIter).begin();
- for ( ; tIter != (*vIter).end(); ++tIter) {
- TableAttrSchema tab_schema = (*tIter);
- string attr_name = tab_schema.table_attribute_name;
- string attr_value;
- pfc_log_info("PhyUtil: attr name is %s\n", attr_name.c_str());
-
- if (attr_name == "oper_status") {
- PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
- DATATYPE_UINT16);
- pfc_log_info("PhyUtil:Attribute value is %c\n", attr_value[0]);
- oper_status = attr_value[0];
-
- pfc_log_info("PhyUtil: oper_status is %d\n", oper_status);
- }
- pfc_log_info("PhyUtil: Iterating the loop\n");
- }
- } else {
- pfc_log_error("Unable to read from db");
- }
- return UPPL_RC_SUCCESS;
-}
-string PhyUtil::uint8tostr(uint8_t c) {
+/**uint8tostr
+ * @Description : This function does the conversion of type uint8 to string
+ * @param[in] : c - varaiable of type uint8
+ * @return : string
+ * */
+string PhyUtil::uint8tostr(const uint8_t& c) {
char str[20];
+ memset(&str, '\0', 20);
snprintf(str, sizeof(str), "%d", c);
string str1 = str;
return str1;
}
-string PhyUtil::uint16tostr(uint16_t c) {
+/**uint16tostr
+ * @Description : This function does the conversion of type uint16 to string
+ * @param[in] : c - varaiable of type uint16
+ * @return : string
+ * */
+string PhyUtil::uint16tostr(const uint16_t& c) {
char str[20];
snprintf(str, sizeof(str), "%d", c);
string str1 = str;
return str1;
}
-string PhyUtil::uint64tostr(uint64_t c) {
+/**uint64tostr
+ * @Description : This function does the conversion of type uint64 to string
+ * @param[in] : c - varaiable of type uint64
+ * @return : string
+ * */
+string PhyUtil::uint64tostr(const uint64_t& c) {
char str[20];
snprintf(str, sizeof(str), "%"PFC_PFMT_u64, c);
string str1 = str;
return str1;
}
-
-int PhyUtil::uint8touint(uint8_t c) {
+/**uint8touint
+ * @Description : This function does the conversion of type uint8 to uint
+ * @param[in] : c - varaiable of type uint8
+ * @return : integer
+ * */
+int PhyUtil::uint8touint(const uint8_t& c) {
stringstream stream;
stream << c;
return stream.get();
}
-unsigned int PhyUtil::strtouint(string str) {
- unsigned int value;
- value = atoi((const char*)(str.c_str()));
- return value;
+/**strtouint
+ * @Description : This function does the conversion of type string to uint
+ * @param[in] : str - varaiable of type string
+ * @return : unsigned integer
+ * */
+unsigned int PhyUtil::strtouint(const string& str) {
+ return atoi((const char*)(str.c_str()));
}
-uint64_t PhyUtil::strtouint64(string str) {
- uint64_t value;
- value = atol((const char*)(str.c_str()));
- return value;
+/**strtouint64
+ * @Description : This function does the conversion of type string to uint64
+ * @param[in] : str - varaiable of type string
+ * @return : uint64
+ * */
+uint64_t PhyUtil::strtouint64(const string& str) {
+ return atol((const char*)(str.c_str()));
}
-void PhyUtil::FillDbSchema(string attr_name, string attr_value,
+/**FillDbSchema
+ * @Description : This function fills the database schema with the attribute
+ * names ,attribute values ,attribute length and attribute type
+ * @param[in] : attr_name - Name of the attribute
+ * attr_value - Value of the attribute
+ * attr_length - length of the attribute
+ * attr_type - DATATYPE_* datatype of the attribute
+ * @param[out] : vect_attr - vector that contains all details of attributes
+ * @return : void
+ * */
+void PhyUtil::FillDbSchema(ODBCMTableColumns attr_name, string attr_value,
unsigned int attr_length,
AttributeDataType attr_type,
vector<TableAttrSchema> &vect_attr) {
case DATATYPE_UINT16:
{
ColumnAttrValue <uint16_t> *value = new ColumnAttrValue <uint16_t>;
- value->value = 0;
- uint16_t uint_val = strtouint(attr_value);
- value->value = uint_val;
+ value->value = strtouint(attr_value);
table_attr_schema.p_table_attribute_value = value;
break;
}
case DATATYPE_UINT64:
{
ColumnAttrValue <uint64_t> *value = new ColumnAttrValue <uint64_t>;
- value->value = 0;
- uint64_t uint_val = strtouint64(attr_value);
- value->value = uint_val;
+ value->value = strtouint64(attr_value);
table_attr_schema.p_table_attribute_value = value;
break;
}
case DATATYPE_UINT32:
{
ColumnAttrValue <uint32_t> *value = new ColumnAttrValue <uint32_t>;
- value->value = 0;
- uint32_t uint_val = strtouint(attr_value);
- value->value = uint_val;
+ value->value = strtouint(attr_value);
table_attr_schema.p_table_attribute_value = value;
break;
}
{
ColumnAttrValue <uint32_t> *value=
new ColumnAttrValue <uint32_t>;
- uint32_t uint_val = 0;
+ value->value = 0;
if (!attr_value.empty()) {
- uint_val = inet_addr(attr_value.c_str());
+ value->value = inet_addr(attr_value.c_str());
}
- pfc_log_debug("ip address to db: %d", uint_val);
- value->value = uint_val;
+ pfc_log_debug("ip address to db: %d", value->value);
table_attr_schema.p_table_attribute_value = value;
break;
}
table_attr_schema.table_attribute_length = attr_length;
break;
}
- case DATATYPE_UINT8_ARRAY_12:
- {
- ColumnAttrValue <unsigned char[12+1]> *value=
- new ColumnAttrValue <unsigned char[12+1]>;
- memset(&value->value, '\0', sizeof(value->value));
- memcpy(value->value,
- attr_value.c_str(), attr_length+1);
- table_attr_schema.p_table_attribute_value = value;
- table_attr_schema.table_attribute_length = attr_length;
- break;
- }
case DATATYPE_UINT8_ARRAY_16:
{
ColumnAttrValue <unsigned char[16+1]> *value=
{
ColumnAttrValue <unsigned char[257+1]> *value=
new ColumnAttrValue <unsigned char[257+1]>;
- memset(value->value, '\0', sizeof(value->value));
+ memset(&value->value, '\0', sizeof(value->value));
memcpy(value->value,
attr_value.c_str(), attr_length+1);
table_attr_schema.p_table_attribute_value = value;
new ColumnAttrValue <unsigned char[320+1]>;
memset(&value->value, '\0', sizeof(value->value));
memcpy(value->value,
- attr_value.c_str(), attr_length);
+ attr_value.c_str(), attr_length+1);
table_attr_schema.p_table_attribute_value = value;
table_attr_schema.table_attribute_length = attr_length;
break;
vect_attr.push_back(table_attr_schema);
}
-void PhyUtil::FillDbSchema(string attr_name,
+/**FillDbSchema
+ * @Description : This function fills the database schema with the attribute
+ * names ,attribute values ,attribute length and attribute type
+ * @param[in] : attr_name - Name of the attribute
+ * attr_value - Value of the attribute
+ * attr_length - length of the attribute
+ * attr_type - DATATYPE_* datatype of the attribute
+ * @param[out] : vect_attr - vector that contains all details of attributes
+ * @return : void
+ * */
+void PhyUtil::FillDbSchema(ODBCMTableColumns attr_name, uint8_t* attr_value,
+ unsigned int attr_length,
+ AttributeDataType attr_type,
+ vector<TableAttrSchema> &vect_attr) {
+ TableAttrSchema table_attr_schema;
+ table_attr_schema.table_attribute_name = attr_name;
+ switch (attr_type) {
+ case DATATYPE_UINT8_ARRAY_6: {
+ ColumnAttrValue <unsigned char[6+1]> *value=
+ new ColumnAttrValue <unsigned char[6+1]>;
+ pfc_log_info("Fill mac_address %02x:%02x:%02x:%02x:%02x:%02x ",
+ attr_value[0], attr_value[1],
+ attr_value[2], attr_value[3],
+ attr_value[4], attr_value[5]);
+ memset(&value->value, '\0', sizeof(value->value));
+ memcpy(value->value,
+ attr_value, attr_length+1);
+ table_attr_schema.p_table_attribute_value = value;
+ table_attr_schema.table_attribute_length = attr_length;
+ }
+ break;
+ default:
+ break;
+ }
+ table_attr_schema.request_attribute_type = attr_type;
+ vect_attr.push_back(table_attr_schema);
+}
+
+/**FillDbSchema
+ * @Description : This function fills the database schema with the attribute
+ * names ,attribute values ,attribute length and attribute type
+ * Validates the attributes with respect to operation type and
+ * valid_value
+ * @param[in] : attr_name - Name of the attribute
+ * attr_value - Value of the attribute
+ * attr_length - length of the attribute
+ * attr_type - DATATYPE_* datatype of the attribute
+ * operation_type - UNC_OP_* specifies the type of operation
+ * in_valid_val - specifies the valid flag.Its a enum value
+ * prev_db_valid_val - specifies the db valid flag.
+ * Its a enum value
+ * @param[out] : vect_attr - vector that contains all details of attributes
+ * vect_prim_keys -vector that contains the primary keys
+ * out_valid_value - string that has the valid value
+ * @return : void
+ * */
+void PhyUtil::FillDbSchema(ODBCMTableColumns attr_name,
+ string attr_name_str,
string attr_value,
unsigned int attr_length,
AttributeDataType attr_type,
out_valid_value << UNC_VF_VALID;
if (PhyUtil::IsFilteringOperation(operation_type, in_valid_val) == true) {
// To be used as filter and add in vect_primary_key
- vect_prim_keys.push_back(attr_name);
+ vect_prim_keys.push_back(attr_name_str);
}
+ } else if (operation_type >= UNC_OP_READ) {
+ string empty = "";
+ PhyUtil::FillDbSchema(attr_name, empty,
+ empty.length(), attr_type,
+ vect_attr);
} else if (operation_type == UNC_OP_CREATE &&
in_valid_val == UNC_VF_INVALID) {
pfc_log_debug("Attribute '%s' is not given in create request",
- attr_name.c_str());
+ attr_name_str.c_str());
out_valid_value << UNC_VF_INVALID;
} else if ((operation_type == UNC_OP_CREATE ||
operation_type == UNC_OP_UPDATE) &&
in_valid_val == UPPL_NO_VAL_STRUCT) {
- pfc_log_debug("Attribute '%s' is not given in create/update request",
- attr_name.c_str());
out_valid_value << UNC_VF_VALID;
PhyUtil::FillDbSchema(attr_name, attr_value,
attr_value.length(), attr_type,
in_valid_val == UNC_VF_VALID_NO_VALUE) {
// empty value - value to be deleted
pfc_log_debug("Attribute '%s' value is to be deleted in update request",
- attr_name.c_str());
- string empty;
+ attr_name_str.c_str());
+ string empty = "";
PhyUtil::FillDbSchema(attr_name, empty,
empty.length(), attr_type,
vect_attr);
- out_valid_value << UNC_VF_VALID_NO_VALUE;
+ if(attr_name==unc::uppl::CTR_ENABLE_AUDIT) {
+ out_valid_value << UNC_VF_VALID;
+ } else {
+ out_valid_value << UNC_VF_INVALID;
+ }
} else if (operation_type == UNC_OP_CREATE) {
out_valid_value << in_valid_val;
} else if (operation_type == UNC_OP_UPDATE &&
in_valid_val == UNC_VF_INVALID) {
pfc_log_debug(
"Attribute '%s' not given in Update Request. Retain db valid",
- attr_name.c_str());
+ attr_name_str.c_str());
out_valid_value << prev_db_valid_val;
- } else if (operation_type >= UNC_OP_READ) {
- string empty;
+ }
+}
+
+/**FillDbSchema
+ * @Description : This function fills the database schema with the attribute
+ * names ,attribute values ,attribute length and attribute type
+ * Validates the attributes with respect to operation type and
+ * valid_value
+ * @param[in] : attr_name - Name of the attribute
+ * attr_value - Value of the attribute
+ * attr_length - length of the attribute
+ * attr_type - DATATYPE_* datatype of the attribute
+ * operation_type - UNC_OP_* specifies the type of operation
+ * in_valid_val - specifies the valid flag.Its a enum value
+ * prev_db_valid_val - specifies the db valid flag.
+ * Its a enum value
+ * @param[out] : vect_attr - vector that contains all details of attributes
+ * vect_prim_keys -vector that contains the primary keys
+ * out_valid_value - string that has the valid value
+ * @return : void
+ * */
+void PhyUtil::FillDbSchema(ODBCMTableColumns attr_name,
+ string attr_name_str,
+ uint8_t* attr_value,
+ unsigned int attr_length,
+ AttributeDataType attr_type,
+ uint32_t operation_type,
+ uint16_t in_valid_val,
+ uint16_t prev_db_valid_val,
+ vector<TableAttrSchema> &vect_attr,
+ vector<string> &vect_prim_keys,
+ stringstream &out_valid_value) {
+ if (PhyUtil::IsValidValue(operation_type, in_valid_val) == true) {
+ PhyUtil::FillDbSchema(attr_name, attr_value,
+ attr_length, attr_type,
+ vect_attr);
+ out_valid_value << UNC_VF_VALID;
+ if (PhyUtil::IsFilteringOperation(operation_type, in_valid_val) == true) {
+ // To be used as filter and add in vect_primary_key
+ vect_prim_keys.push_back(attr_name_str);
+ }
+ } else if (operation_type >= UNC_OP_READ) {
+ string empty = "";
PhyUtil::FillDbSchema(attr_name, empty,
empty.length(), attr_type,
vect_attr);
+ } else if (operation_type == UNC_OP_CREATE &&
+ in_valid_val == UNC_VF_INVALID) {
+ pfc_log_debug("Attribute '%s' is not given in create request",
+ attr_name_str.c_str());
+ out_valid_value << UNC_VF_INVALID;
+ } else if ((operation_type == UNC_OP_CREATE ||
+ operation_type == UNC_OP_UPDATE) &&
+ in_valid_val == UPPL_NO_VAL_STRUCT) {
+ pfc_log_debug("Attribute '%s' is not given in create/update request",
+ attr_name_str.c_str());
+ out_valid_value << UNC_VF_VALID;
+ PhyUtil::FillDbSchema(attr_name, attr_value,
+ attr_length, attr_type,
+ vect_attr);
+ } else if (operation_type == UNC_OP_UPDATE &&
+ in_valid_val == UNC_VF_VALID_NO_VALUE) {
+ // empty value - value to be deleted
+ pfc_log_debug("Attribute '%s' value is to be deleted in update request",
+ attr_name_str.c_str());
+ string empty = "";
+ PhyUtil::FillDbSchema(attr_name, empty,
+ empty.length(), attr_type,
+ vect_attr);
+ out_valid_value << UNC_VF_INVALID;
+ } else if (operation_type == UNC_OP_CREATE) {
+ out_valid_value << in_valid_val;
+ } else if (operation_type == UNC_OP_UPDATE &&
+ in_valid_val == UNC_VF_INVALID) {
+ pfc_log_debug(
+ "Attribute '%s' not given in Update Request. Retain db valid",
+ attr_name_str.c_str());
+ out_valid_value << prev_db_valid_val;
}
}
-void PhyUtil::GetValueFromDbSchema(TableAttrSchema table_attr_schema,
+/**GetValueFromDbSchema
+ * @Description : This function gets the attribute values thats stored in
+ * database schema
+ * @param[in] : table_attr_schema - Structure that contains the
+ * attribute values
+ * attr_type - DATATYPE_* datatype of the attribute
+ * @param[out] : attr_value - string that has Value of the attribute
+ * @return : void
+ * */
+void PhyUtil::GetValueFromDbSchema(const TableAttrSchema& table_attr_schema,
string &attr_value,
AttributeDataType attr_type) {
stringstream ss;
pfc_log_debug("Received ip value from DB: %d", value->value);
if (value->value > 0) {
struct sockaddr_in ipv4_addr;
+ memset(&ipv4_addr, 0, sizeof(sockaddr_in));
ipv4_addr.sin_addr.s_addr = value->value;
ss << inet_ntoa(ipv4_addr.sin_addr);
pfc_log_debug("ip address from db: %d", ipv4_addr.sin_addr.s_addr);
} else {
- string empty;
+ string empty = "";
ss << empty;
}
break;
ss << value->value;
break;
}
+ default:
+ break;
+ }
+ attr_value = ss.str();
+}
+
+/**GetValueFromDbSchemaStr
+ * @Description : This function gets the attribute values thats stored in
+ * database schema
+ * @param[in] : table_attr_schema - Structure that contains the
+ * attribute values
+ * attr_type - DATATYPE_* datatype of the attribute
+ * @param[out] : attr_value - string that has Value of the attribute
+ * @return : void
+ * */
+void PhyUtil::GetValueFromDbSchemaStr(const TableAttrSchema& table_attr_schema,
+ uint8_t *attr_value,
+ AttributeDataType attr_type) {
+ switch (attr_type) {
case DATATYPE_UINT8_ARRAY_2:
{
ColumnAttrValue <unsigned char[2+1]> *value =
(ColumnAttrValue <unsigned char[2+1]>*)
table_attr_schema.p_table_attribute_value;
- ss << value->value;
+ memcpy(attr_value, value->value, strlen((const char*)value->value)+1);
break;
}
case DATATYPE_UINT8_ARRAY_3:
ColumnAttrValue <unsigned char[3+1]> *value =
(ColumnAttrValue <unsigned char[3+1]>*)
table_attr_schema.p_table_attribute_value;
- ss << value->value;
+ memcpy(attr_value, value->value, strlen((const char*)value->value)+1);
break;
}
case DATATYPE_UINT8_ARRAY_6:
ColumnAttrValue <unsigned char[6+1]> *value =
(ColumnAttrValue <unsigned char[6+1]>*)
table_attr_schema.p_table_attribute_value;
- ss << value->value;
+ memcpy(attr_value, value->value, strlen((const char*)value->value)+1);
+ memcpy(attr_value, value->value, 6);
break;
}
case DATATYPE_UINT8_ARRAY_8:
ColumnAttrValue <unsigned char[8+1]> *value =
(ColumnAttrValue <unsigned char[8+1]>*)
table_attr_schema.p_table_attribute_value;
- ss << value->value;
+ memcpy(attr_value, value->value, strlen((const char*)value->value)+1);
break;
}
case DATATYPE_UINT8_ARRAY_9:
ColumnAttrValue <unsigned char[9+1]> *value =
(ColumnAttrValue <unsigned char[9+1]>*)
table_attr_schema.p_table_attribute_value;
- ss << value->value;
+ memcpy(attr_value, value->value, strlen((const char*)value->value)+1);
break;
}
case DATATYPE_UINT8_ARRAY_11:
ColumnAttrValue <unsigned char[11+1]> *value =
(ColumnAttrValue <unsigned char[11+1]>*)
table_attr_schema.p_table_attribute_value;
- ss << value->value;
- break;
- }
- case DATATYPE_UINT8_ARRAY_12:
- {
- ColumnAttrValue <unsigned char[12+1]> *value =
- (ColumnAttrValue <unsigned char[12+1]>*)
- table_attr_schema.p_table_attribute_value;
- ss << value->value;
+ memcpy(attr_value, value->value, strlen((const char*)value->value)+1);
break;
}
case DATATYPE_UINT8_ARRAY_16:
ColumnAttrValue <unsigned char[16+1]> *value =
(ColumnAttrValue <unsigned char[16+1]>*)
table_attr_schema.p_table_attribute_value;
- ss << value->value;
+ memcpy(attr_value, value->value, strlen((const char*)value->value)+1);
break;
}
case DATATYPE_UINT8_ARRAY_32:
ColumnAttrValue <unsigned char[32+1]> *value =
(ColumnAttrValue <unsigned char[32+1]>*)
table_attr_schema.p_table_attribute_value;
- ss << value->value;
+ memcpy(attr_value, value->value, strlen((const char*)value->value)+1);
break;
}
case DATATYPE_UINT8_ARRAY_128:
ColumnAttrValue <unsigned char[128+1]> *value =
(ColumnAttrValue <unsigned char[128+1]>*)
table_attr_schema.p_table_attribute_value;
- ss << value->value;
+ memcpy(attr_value, value->value, strlen((const char*)value->value)+1);
break;
}
case DATATYPE_UINT8_ARRAY_256:
ColumnAttrValue <unsigned char[256+1]> *value =
(ColumnAttrValue <unsigned char[256+1]>*)
table_attr_schema.p_table_attribute_value;
- ss << value->value;
+ memcpy(attr_value, value->value, strlen((const char*)value->value)+1);
break;
}
case DATATYPE_UINT8_ARRAY_257:
ColumnAttrValue <unsigned char[257+1]> *value =
(ColumnAttrValue <unsigned char[257+1]>*)
table_attr_schema.p_table_attribute_value;
- ss << value->value;
+ memcpy(attr_value, value->value, strlen((const char*)value->value)+1);
break;
}
case DATATYPE_UINT8_ARRAY_320:
ColumnAttrValue <unsigned char[320+1]> *value =
(ColumnAttrValue <unsigned char[320+1]>*)
table_attr_schema.p_table_attribute_value;
- ss << value->value;
+ memcpy(attr_value, value->value, strlen((const char*)value->value)+1);
break;
}
+ default:
+ break;
}
- attr_value = ss.str();
- ss.str("");
}
+/**get_controller_type
+ * @Description : This function gets the controller type of the specified
+ * controller by sending the request to odbc manager
+ * @param[in] : controller_name - name of the controller
+ * datatype - UNC_DT_* specifies the datatype
+ * @param[out] : controller_type - UNC_CT_* Type of the controller(UNKNOWN,
+ * PFC,VNP)
+ * @return : UPPL_RC_SUCCESS is returned when the response
+ * is added to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not
+ * be added to session.
+ * */
UpplReturnCode PhyUtil::get_controller_type(
+ OdbcmConnectionHandler *db_conn,
string controller_name,
unc_keytype_ctrtype_t& controller_type,
unc_keytype_datatype_t datatype) {
UpplReturnCode ret_code = UPPL_RC_SUCCESS;
- string type;
+ string type = "";
// Creating the Physical Layer instance
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
// Creating the object that consists of vectors of Table Atrr Schema
vector<TableAttrSchema> vect_table_attr_schema;
vector<string> vect_prim_keys; // Construct Primary key list
- vect_prim_keys.push_back("controller_name");
- pfc_log_info("PhyUtil::controller_name is %s\n", controller_name.c_str());
- PhyUtil::FillDbSchema("controller_name", controller_name,
+ vect_prim_keys.push_back(CTR_NAME_STR);
+ pfc_log_debug("PhyUtil::controller_name is %s", controller_name.c_str());
+ PhyUtil::FillDbSchema(unc::uppl::CTR_NAME, controller_name,
controller_name.length(), DATATYPE_UINT8_ARRAY_32,
vect_table_attr_schema);
- PhyUtil::FillDbSchema("type", type,
+ PhyUtil::FillDbSchema(unc::uppl::CTR_TYPE, type,
type.length(), DATATYPE_UINT16,
vect_table_attr_schema);
// Structure used to send request to ODBC
DBTableSchema dbtableschema_obj;
dbtableschema_obj.set_primary_keys(vect_prim_keys);
- dbtableschema_obj.set_table_name("controller_table");
+ dbtableschema_obj.set_table_name(unc::uppl::CTR_TABLE);
dbtableschema_obj.PushBackToRowList(vect_table_attr_schema);
ODBCM_RC_STATUS db_status = physical_layer->get_odbc_manager()-> \
- GetOneRow(datatype, dbtableschema_obj);
+ GetOneRow(datatype, dbtableschema_obj, db_conn);
if (db_status == ODBCM_RC_CONNECTION_ERROR) {
// log fatal error to log daemon
pfc_log_fatal("DB connection not available or cannot access DB");
ret_code = UPPL_RC_ERR_DB_GET;
return ret_code;
}
- list< vector<TableAttrSchema> > row_list_iter =
+ list< vector<TableAttrSchema> >& row_list_iter =
dbtableschema_obj.get_row_list();
list< vector<TableAttrSchema> >::iterator vect_iter =
row_list_iter.begin();
vector<TableAttrSchema> ::iterator tab_iter = (*vect_iter).begin();
for ( ; tab_iter != (*vect_iter).end(); ++tab_iter) {
TableAttrSchema tab_schema = (*tab_iter);
- string attr_name = tab_schema.table_attribute_name;
- string attr_value;
- if (attr_name == "type") {
+ ODBCMTableColumns attr_name = tab_schema.table_attribute_name;
+ string attr_value = "";
+ if (attr_name == unc::uppl::CTR_TYPE) {
PhyUtil::GetValueFromDbSchema(tab_schema, attr_value,
DATATYPE_UINT16);
controller_type = (unc_keytype_ctrtype_t)(atoi(attr_value.c_str()));
return ret_code;
}
+/**reorder_col_attrs
+ * @Description : This function reorders the attributes present in the column
+ * attribute table in table attribute schema
+ * @param[in] : vect_prim_keys - vector that contains the primary keys
+ * vect_table_attr_schema - vector that contains the table
+ * attribute schema structure
+ * @return : void
+ * */
void PhyUtil::reorder_col_attrs(
vector<string> vect_prim_keys,
vector<TableAttrSchema> &vect_table_attr_schema) {
vect_table_attr_schema.begin();
for ( ; tab_iter != vect_table_attr_schema.end(); ++tab_iter) {
TableAttrSchema col_attr = (*tab_iter);
- if (key_attr_name == col_attr.table_attribute_name) {
+ if (key_attr_name == ODBCManager::get_ODBCManager()->GetColumnName(
+ col_attr.table_attribute_name)) {
vect_table_attr_schema.erase(tab_iter);
vect_table_attr_schema.insert(vect_table_attr_schema.begin(),
col_attr);
}
}
-/** IsValidValue
- * * @Description : This function checks whether the value in value
- * structure can be considered
- * * * @param[in] : operation type and valid flag
- * * * @return : True of false
+/**IsValidValue
+ * @Description : This function checks whether the value in value
+ * structure can be considered
+ * @param[in] : operation type - UNC_OP_* specifies the type of operation
+ * valid - speicifies the valid flag
+ * @return : PFC_TRUE is returned if value is considered otherwise
+ * PFC_FALSE is returned to denote error
* */
bool PhyUtil::IsValidValue(uint32_t operation_type,
unsigned int valid) {
if (valid == UPPL_NO_VAL_STRUCT) {
return false;
}
- if ((operation_type == UNC_OP_CREATE && valid == UNC_VF_VALID) ||
- (operation_type == UNC_OP_UPDATE && valid == UNC_VF_VALID) ||
- (operation_type == UNC_OP_READ) ||
+ if ((operation_type == UNC_OP_READ) ||
(operation_type == UNC_OP_READ_SIBLING_BEGIN) ||
(operation_type == UNC_OP_READ_SIBLING) ||
- (operation_type == UNC_OP_READ_SIBLING_COUNT)) {
+ (operation_type == UNC_OP_READ_SIBLING_COUNT) ||
+ (operation_type == UNC_OP_CREATE && valid == UNC_VF_VALID) ||
+ (operation_type == UNC_OP_UPDATE && valid == UNC_VF_VALID)) {
return true;
} else {
return false;
}
}
-/** IsFilteringOperation
- * * @Description : This function checks whether the value in value
- * structure has to be used for filertering
- * * * @param[in] : operation type and valid flag
- * * * @return : True of false
+/**IsFilteringOperation
+ * @Description : This function checks whether the value in value
+ * structure has to be used for filertering
+ * @param[in] : operation type - UNC_OP_* specifies the type of operation
+ * valid - speicifies the valid flag
+ * @return : PFC_TRUE is returned if value in value structure is used for
+ * filertering otherwise PFC_FALSE is returned to denote error
* */
bool PhyUtil::IsFilteringOperation(uint32_t operation_type,
unsigned int valid) {
#include "physical_core.hh"
#include "physicallayer.hh"
#include "tclib_module.hh"
+
using unc::tclib::TcApiCommonRet;
using unc::tclib::TcLibModule;
UpplReturnCode PhysicalCore::InitializePhysical() {
// initialize the class member data
// Create new internal transaction coordinator object
- internal_transaction_coordinator_ = new InternalTransactionCoordinator();
+ internal_transaction_coordinator_ = InternalTransactionCoordinator::
+ get_internaltransactioncoordinator();
+ if (internal_transaction_coordinator_ == NULL) {
+ pfc_log_error("Memory not allocated for internal_transaction_coordinator_");
+ return UPPL_RC_ERR_FATAL_RESOURCE_ALLOCATION;
+ }
// Read config from file
UpplReturnCode ret = ReadConfigFile();
return UPPL_RC_ERR_ALARM_API;
} else {
// clear all alarms
- pfc::alarm::pfc_alarm_clear(0);
+ pfc::alarm::pfc_alarm_clear(UNCCID_PHYSICAL);
}
pfc_bool_t event_ret = RegisterStateHandlers();
TcLibModule* tclib_ptr = static_cast<TcLibModule*>
(TcLibModule::getInstance(TCLIB_MODULE_NAME));
if (tclib_ptr != NULL) {
- pfc_log_info("Calling TcLibRegisterHandler");
ret_code = tclib_ptr->TcLibRegisterHandler(this);
pfc_log_info("TcLibRegisterHandler returned %u.", ret_code);
if (ret_code != unc::tclib::TC_API_COMMON_SUCCESS) {
string conf_file_path = string(UNC_MODULEDIR) +
string("/uppl_ctr_capability.conf");
- string version;
+ string version = "";
attribute_struct attr_var;
cap_value_struct vals;
cap_key_struct keys;
int kVersArraySize = cObjs[iter].arraySize("version_supported");
for (int idx = 0; idx < kVersArraySize; ++idx) {
version = cObjs[iter].getStringAt("version_supported", idx, 0);
- ControllerVersion ctr_obj(version);
+ UpplReturnCode parse_ret = UPPL_RC_SUCCESS;
+ ControllerVersion ctr_obj(version, parse_ret);
+ if (parse_ret != UPPL_RC_SUCCESS) {
+ return parse_ret;
+ }
int kAttribArraySize = cObjs[iter].arraySize("attribute_name");
vals.attrs.clear();
for (int i =0; i < kAttribArraySize; ++i) {
if (physical_layer == NULL) {
return UPPL_RC_ERR_FATAL_RESOURCE_ALLOCATION;
}
- ControllerVersion obj(version);
+ UpplReturnCode parse_ret = UPPL_RC_SUCCESS;
+ ControllerVersion obj(version, parse_ret);
+ if (parse_ret != UPPL_RC_SUCCESS) {
+ return parse_ret;
+ }
cap_key_struct keystructvar;
keystructvar.key_type = key_type;
- // map<ControllerVersion, map<cap_key_struct, cap_value_struct > >::iterator
- // iter_cap_map = ctr_cap_map_.find(obj);
cap_iter iter_cap_map = GetVersionIterator(obj);
if (iter_cap_map != ctr_cap_map_.end()) {
pfc_log_debug("ValidateKeyTypeInCtrlrCap ret = %d\n", ret);
return ret;
}
- ControllerVersion obj(version);
+ UpplReturnCode parse_ret = UPPL_RC_SUCCESS;
+ ControllerVersion obj(version, parse_ret);
+ if (parse_ret != UPPL_RC_SUCCESS) {
+ return parse_ret;
+ }
cap_iter iter_cap_map = GetVersionIterator(obj);
pfc_log_debug("Controller Version = %s\n",
(iter_cap_map->first.version_).c_str());
UpplReturnCode PhysicalCore::GetScalabilityNumber(string version,
uint32_t key_type,
uint32_t &scalability_num) {
- ControllerVersion obj(version);
+ UpplReturnCode parse_ret = UPPL_RC_SUCCESS;
+ ControllerVersion obj(version, parse_ret);
+ if (parse_ret != UPPL_RC_SUCCESS) {
+ return parse_ret;
+ }
- // map<ControllerVersion, map<cap_key_struct, cap_value_struct > >::iterator
- // iter_cap_map = ctr_cap_map_.find(obj);
cap_iter iter_cap_map = GetVersionIterator(obj);
map<cap_key_struct, cap_value_struct > key_type_map;
pfc_log_error("Operation Not allowed: System is in standby\n");
return unc::tclib::TC_FAILURE;
}
+ OPEN_DB_CONNECTION_TC_REQUEST(unc::uppl::kOdbcmConnReadWriteNb);
// Call ITC transaction handler function
UpplReturnCode resp = internal_transaction_coordinator_->transaction_req()->
- StartTransaction(session_id, config_id);
+ StartTransaction(&db_conn, session_id, config_id);
pfc_log_debug("HandleCommitTransactionStart return code %d", resp);
// convert the error code returned by ITC to TC error code
if (resp == UPPL_RC_SUCCESS) {
pfc_log_error("Operation Not allowed: System is in standby\n");
return unc::tclib::TC_FAILURE;
}
+ OPEN_DB_CONNECTION_TC_REQUEST(unc::uppl::kOdbcmConnReadWriteNb);
// Call ITC transaction handler function
UpplReturnCode resp = internal_transaction_coordinator_->transaction_req()->
- EndTransaction(session_id,
- config_id);
+ EndTransaction(&db_conn, session_id,
+ config_id,
+ trans_res);
pfc_log_debug("HandleCommitTransactionEnd response %d", resp);
// convert the error code returned by ITC to TC error code
if (resp == UPPL_RC_SUCCESS) {
pfc_log_error("Operation Not allowed: System is in standby\n");
return unc::tclib::TC_FAILURE;
}
+ OPEN_DB_CONNECTION_TC_REQUEST(unc::uppl::kOdbcmConnReadWriteNb);
pfc_log_debug("Received HandleAuditVoteRequest from TC");
// Call ITC transaction handler function
UpplReturnCode resp = internal_transaction_coordinator_->audit_req()->
- HandleAuditVoteRequest(session_id,
+ HandleAuditVoteRequest(&db_conn, session_id,
driver_id,
controller_id,
driver_info);
pfc_log_error("Operation Not allowed: System is in standby\n");
return unc::tclib::TC_FAILURE;
}
+ // Check for Events Lock
+ ScopedReadWriteLock eventDoneLock(PhysicalLayer::get_events_done_lock_(),
+ PFC_TRUE); // write lock
+ OPEN_DB_CONNECTION_TC_REQUEST(unc::uppl::kOdbcmConnReadWriteNb);
// Call ITC transaction handler function
UpplReturnCode resp = internal_transaction_coordinator_->transaction_req()->
- HandleDriverResult(session_id,
+ HandleDriverResult(&db_conn, session_id,
config_id,
commitphase,
driver_result);
pfc_log_error("Operation Not allowed: System is in standby\n");
return unc::tclib::TC_FAILURE;
}
+ OPEN_DB_CONNECTION_TC_REQUEST(unc::uppl::kOdbcmConnReadWriteNb);
pfc_log_debug("Received HandleAuditStart from TC");
// Call ITC transaction handler function
UpplReturnCode resp = internal_transaction_coordinator_->audit_req()->
- StartAudit(ctrl_type,
+ StartAudit(&db_conn, ctrl_type,
controller_id);
// convert the error code returned by ITC to TC error code
return unc::tclib::TC_FAILURE;
}
pfc_log_debug("Received HandleAuditEnd from TC");
+ OPEN_DB_CONNECTION_TC_REQUEST(unc::uppl::kOdbcmConnReadWriteNb);
// Call ITC transaction handler function
UpplReturnCode resp = internal_transaction_coordinator_->audit_req()->
- EndAudit(ctrl_type,
+ EndAudit(&db_conn, ctrl_type,
controller_id,
audit_result);
pfc_log_error("Operation Not allowed: System is in standby\n");
return unc::tclib::TC_FAILURE;
}
+ OPEN_DB_CONNECTION_TC_REQUEST(unc::uppl::kOdbcmConnReadWriteNb);
// Call ITC transaction handler function
UpplReturnCode resp = internal_transaction_coordinator_->db_config_req()->
- SaveRunningToStartUp();
+ SaveRunningToStartUp(&db_conn);
// convert the error code returned by ITC to TC error code
if (resp == UPPL_RC_SUCCESS) {
pfc_log_error("Operation Not allowed: System is in standby\n");
return unc::tclib::TC_FAILURE;
}
+ OPEN_DB_CONNECTION_TC_REQUEST(unc::uppl::kOdbcmConnReadWriteNb);
// Call ITC transaction handler function
UpplReturnCode resp = internal_transaction_coordinator_->db_config_req()->
- ClearStartUpDb();
+ ClearStartUpDb(&db_conn);
// convert the error code returned by ITC to TC error code
if (resp == UPPL_RC_SUCCESS) {
pfc_log_error("Operation Not allowed: System is in standby\n");
return unc::tclib::TC_FAILURE;
}
+ OPEN_DB_CONNECTION_TC_REQUEST(unc::uppl::kOdbcmConnReadWriteNb);
// Call ITC transaction handler function
uint8_t resp = internal_transaction_coordinator_->db_config_req()->
- AbortCandidateDb();
+ AbortCandidateDb(&db_conn);
// convert the error code returned by ITC to TC error code
if (resp == UPPL_RC_SUCCESS) {
pfc_log_error("Operation Not allowed: System is in standby\n");
return unc::tclib::TC_FAILURE;
}
- pfc_log_debug("Recieved HandleAuditConfig from TC");
+ // Check for Events Lock
+ ScopedReadWriteLock eventDoneLock(PhysicalLayer::get_events_done_lock_(),
+ PFC_TRUE); // write lock
+ OPEN_DB_CONNECTION_TC_REQUEST(unc::uppl::kOdbcmConnReadWriteNb);
+ pfc_log_debug("Received HandleAuditConfig from TC");
// Call ITC transaction handler function
UpplReturnCode resp = UPPL_RC_SUCCESS;
if (fail_oper == TC_OP_CANDIDATE_COMMIT) {
TcDriverInfoMap driver_info;
TransactionRequest *txn_req =
internal_transaction_coordinator_->transaction_req();
- resp = txn_req->StartTransaction(session_id, config_id);
+ resp = txn_req->StartTransaction(&db_conn, session_id, config_id);
if (resp != UPPL_RC_SUCCESS) {
pfc_log_error("HandleAuditConfig - StartTransaction failed with %d",
resp);
TcCommitPhaseType phase = unc::tclib::TC_COMMIT_VOTE_PHASE;
TcCommitPhaseResult driver_result;
- resp = txn_req->HandleDriverResult(session_id,
+ resp = txn_req->HandleDriverResult(&db_conn, session_id,
config_id, phase, driver_result);
if (resp != UPPL_RC_SUCCESS) {
pfc_log_error("HandleAuditConfig - DriverResult VOTE PH failed with %d",
}
phase = unc::tclib::TC_COMMIT_GLOBAL_COMMIT_PHASE;
- resp = txn_req->HandleDriverResult(session_id,
+ resp = txn_req->HandleDriverResult(&db_conn, session_id,
config_id, phase, driver_result);
if (resp != UPPL_RC_SUCCESS) {
pfc_log_error("HandleAuditConfig - DriverResult COM PH failed with %d",
resp);
return unc::tclib::TC_FAILURE;
}
-
- resp = txn_req->EndTransaction(session_id, config_id);
+ TcTransEndResult trans_res = unc::tclib::TRANS_END_SUCCESS;
+ resp = txn_req->EndTransaction(&db_conn, session_id, config_id, trans_res);
if (resp != UPPL_RC_SUCCESS) {
pfc_log_error("HandleAuditConfig - EndTransaction COM PH failed with %d",
resp);
} else if (fail_oper == TC_OP_CLEAR_STARTUP) {
resp = internal_transaction_coordinator_->db_config_req()->
- ClearStartUpDb();
+ ClearStartUpDb(&db_conn);
} else if (fail_oper == TC_OP_RUNNING_SAVE) {
// Copy running to startup
resp = internal_transaction_coordinator_->db_config_req()->
- SaveRunningToStartUp();
+ SaveRunningToStartUp(&db_conn);
} else if (fail_oper == TC_OP_CANDIDATE_ABORT) {
resp = internal_transaction_coordinator_->db_config_req()->
- AbortCandidateDb();
+ AbortCandidateDb(&db_conn);
} else if (fail_oper == TC_OP_USER_AUDIT ||
fail_oper == TC_OP_DRIVER_AUDIT) {
// Do nothing
pfc_log_error("Operation Not allowed: System is in standby\n");
return unc::tclib::TC_FAILURE;
}
+ OPEN_DB_CONNECTION_TC_REQUEST(unc::uppl::kOdbcmConnReadWriteNb);
// Call ITC transaction handler function
// Copy startup to candidate and running and commit
UpplReturnCode resp = internal_transaction_coordinator_->db_config_req()->
- LoadAndCommitStartup();
+ LoadAndCommitStartup(&db_conn);
// convert the error code returned by ITC to TC error code
if (resp == UPPL_RC_SUCCESS) {
pfc_log_error("Operation Not allowed: System is in standby\n");
return unc::tclib::TC_FAILURE;
}
+ OPEN_DB_CONNECTION_TC_REQUEST(unc::uppl::kOdbcmConnReadWriteNb);
// Call ITC transaction handler function
// Copy startup to candidate and running and commit
UpplReturnCode resp = internal_transaction_coordinator_->
- system_state_change_req()->SystemStateChangeToActive();
+ system_state_change_req()->SystemStateChangeToActive(&db_conn);
pfc_log_debug("ReturnCode of SystemStateChangeToActive %d", resp);
// convert the error code returned by ITC to TC error code
if (resp == UPPL_RC_SUCCESS) {
unc_keytype_ctrtype_t PhysicalCore::HandleGetControllerType(
string controller_id) {
// call util function to get controller type
- unc_keytype_ctrtype_t controller_type;
- UpplReturnCode resp = PhyUtil::get_controller_type(controller_id,
+ unc_keytype_ctrtype_t controller_type = UNC_CT_UNKNOWN;
+ UpplReturnCode db_ret = UPPL_RC_SUCCESS;
+ OPEN_DB_CONNECTION(unc::uppl::kOdbcmConnReadWriteNb, db_ret);
+ if (db_ret != UPPL_RC_SUCCESS) {
+ return controller_type;
+ }
+ UpplReturnCode resp = PhyUtil::get_controller_type(&db_conn,
+ controller_id,
controller_type,
UNC_DT_CANDIDATE);
// convert the error code returned by ITC to TC error code
}
/**
- * @Description : This function sends CONROLLER_DISCONNECT alarm to node manager
+ * @Description : This function sends CONROLLER_DISCONNECT alarm to node
+ * manager
* This function will be called from Kt_Controller class when it
* receives CONTROLLER notification from driver with oper_status
* as down
return UPPL_RC_SUCCESS;
}
string vtn_name = "";
- const std::string& alm_msg = "Controller disconnected";
+ const std::string& alm_msg = "Controller disconnected - " + controller_id;
const std::string& alm_msg_summary = "Controller disconnected";
pfc::alarm::alarm_info_with_key_t* data =
new pfc::alarm::alarm_info_with_key_t;
}
delete []data->alarm_key;
delete data;
+ pfc_log_info("Sent Controller Disconnected alarm - %s",
+ controller_id.c_str());
return UPPL_RC_SUCCESS;
}
return UPPL_RC_SUCCESS;
}
string vtn_name = "";
- const std::string& alm_msg = "Controller connected";
+ const std::string& alm_msg = "Controller connected - " + controller_id;
const std::string& alm_msg_summary = "Controller connected";
pfc::alarm::alarm_info_with_key_t* data =
new pfc::alarm::alarm_info_with_key_t;
}
delete []data->alarm_key;
delete data;
+ pfc_log_info("Sent Controller Connected alarm - %s",
+ controller_id.c_str());
return UPPL_RC_SUCCESS;
}
-/**
- * @Description : This function sends AUDIT_FAILURE alarm to node manager
- * This function will be called from audit_req class when audit
- * operation fails
- */
-
-UpplReturnCode PhysicalCore::SendAuditFailureAlarm(string controller_id) {
- if (get_system_state() == UPPL_SYSTEM_ST_STANDBY) {
- // system is in standby
- pfc_log_info("System is in standby");
- pfc_log_info("AuditFailure alarm not sent to node manager");
- return UPPL_RC_SUCCESS;
- }
- string vtn_name = "";
- const std::string& alm_msg =
- "Controller audit failure due to Invalid Configuration";
- const std::string& alm_msg_summary =
- "Controller audit failure";
- pfc::alarm::alarm_info_with_key_t* data =
- new pfc::alarm::alarm_info_with_key_t;
- data->alarm_class = pfc::alarm::ALM_WARNING;
- data->apl_No = UNCCID_PHYSICAL;
- data->alarm_category = 2;
- data->alarm_key_size = controller_id.length();
- data->alarm_key = new uint8_t[controller_id.length()+1];
- memcpy(data->alarm_key,
- controller_id.c_str(),
- controller_id.length()+1);
- data->alarm_kind = 1;
-
- pfc::alarm::alarm_return_code_t ret = pfc::alarm::pfc_alarm_send_with_key(
- vtn_name,
- alm_msg,
- alm_msg_summary,
- data, fd);
- if (ret != pfc::alarm::ALM_OK) {
- delete []data->alarm_key;
- delete data;
- return UPPL_RC_ERR_ALARM_API;
- }
- delete []data->alarm_key;
- delete data;
- return UPPL_RC_SUCCESS;
-}
-
-/**
- * @Description : This function sends AUDIT_SUCCESS alarm to node manager
- * This is a clearance alarm for AUDIT_FAILURE alarm
- */
-
-UpplReturnCode PhysicalCore::SendAuditSuccessAlarm(string controller_id) {
- if (get_system_state() == UPPL_SYSTEM_ST_STANDBY) {
- // system is in standby
- pfc_log_info("System is in standby");
- pfc_log_info("AuditSuccess alarm not sent to node manager");
- return UPPL_RC_SUCCESS;
- }
- string vtn_name = "";
- const std::string& alm_msg = "Controller audit success";
- const std::string& alm_msg_summary = "Controller audit success";
- pfc::alarm::alarm_info_with_key_t* data =
- new pfc::alarm::alarm_info_with_key_t;
- data->alarm_class = pfc::alarm::ALM_NOTICE;
- data->apl_No = UNCCID_PHYSICAL;
- data->alarm_category = 2;
- data->alarm_key_size = controller_id.length();
- data->alarm_key = new uint8_t[controller_id.length()+1];
- memcpy(data->alarm_key,
- controller_id.c_str(),
- controller_id.length()+1);
- data->alarm_kind = 0;
- pfc::alarm::alarm_return_code_t ret = pfc::alarm::pfc_alarm_send_with_key(
- vtn_name,
- alm_msg,
- alm_msg_summary,
- data, fd);
- if (ret != pfc::alarm::ALM_OK) {
- delete []data->alarm_key;
- delete data;
- return UPPL_RC_ERR_ALARM_API;
- }
- delete []data->alarm_key;
- delete data;
- return UPPL_RC_SUCCESS;
-}
/**
- * @Description : This function sends EVENT_HANDLING FAILURE alarm to node manager
- * This function will be called from kt classes when event handling fails
+ * @Description : This function sends EVENT_HANDLING FAILURE alarm to
+ * node manager
+ * This function will be called from kt classes when event
+ * handling fails
*/
UpplReturnCode
}
delete []data->alarm_key;
delete data;
+ pfc_log_info("Sent Event Handling Failure alarm - %s , %s",
+ controller_id.c_str(), event_details.c_str());
return UPPL_RC_SUCCESS;
}
/**
- * @Description : This function sends EVENT_HANDLING_SUCCESS alarm to node manager
+ * @Description : This function sends EVENT_HANDLING_SUCCESS alarm to
+ * node manager
* This is a clearance alarm for EVENT_HANDLING_FAILURE alarm
*/
}
delete []data->alarm_key;
delete data;
+ pfc_log_info("Sent Event Handling Success alarm - %s , %s",
+ controller_id.c_str(), event_details.c_str());
return UPPL_RC_SUCCESS;
}
using unc::uppl::PhysicalLayer;
using unc::uppl::ImportRequest;
using unc::uppl::NotificationRequest;
+// static variable initialization
+InternalTransactionCoordinator* InternalTransactionCoordinator::
+internal_transaction_coordinator_ = NULL;
-/* InternalTransactionCoordinator
- * @Description : constructor function
- * @param[in]: NA
- * @return : NA
- * */
-InternalTransactionCoordinator::InternalTransactionCoordinator() {
- // physical_core_= NULL;
- transaction_req_= NULL;
- db_config_req_= NULL;
- system_state_change_req_= NULL;
- audit_req_= NULL;
- audit_state_ = AUDIT_END;
- import_state_ = IMPORT_END;
- trans_state_ = TRANS_END;
- config_request_status_ = false;
+/**InternalTransactionCoordinator
+ * @Description : Constructor which will invoke the respective configuration
+ * classes
+ * variables
+ * @param[in] : None
+ * @return : None
+ **/
+InternalTransactionCoordinator::InternalTransactionCoordinator()
+:
+ config_request_status_(false),
+ trans_state_(TRANS_END),
+ transaction_req_(NULL),
+ db_config_req_(NULL),
+ system_state_change_req_(NULL),
+ audit_req_(NULL) {
+}
+
+/**
+ * @Description : The function returns singleton instance of
+ * PhysicalCore class
+ */
+InternalTransactionCoordinator* InternalTransactionCoordinator::
+get_internaltransactioncoordinator() {
+ if (internal_transaction_coordinator_ == NULL) {
+ internal_transaction_coordinator_ = new InternalTransactionCoordinator();
+ }
+ return internal_transaction_coordinator_;
}
-/* ~InternalTransactionCoordinator
- * @Description : Destructor function
- * @param[in]: NA
- * @return : NA
- * */
+/**~InternalTransactionCoordinator
+ * @Description : Destructor which delete all the pointers to the
+ * configuration classes
+ * @param[in] : None
+ * @return : None
+ **/
InternalTransactionCoordinator::~InternalTransactionCoordinator() {
if (transaction_req_ != NULL) {
delete transaction_req_;
}
}
-/* transaction_req
- * @Description : This function creates a new instance of TransactionRequest
- * @param[in]: NA
- * @return : TransactionRequest
- * */
+/**transaction_req
+ * @Description : This function creates a new instance of TransactionRequest
+ * @param[in] : None
+ * @return : Pointer to TransactionRequest class is returned
+ **/
TransactionRequest *InternalTransactionCoordinator::transaction_req() {
if (transaction_req_ == NULL)
transaction_req_= new TransactionRequest();
return transaction_req_;
}
-/* audit_req
- * @Description : This function creates a new instance of AuditRequest
- * @param[in]: NA
- * @return : AuditRequest
- * */
+/**audit_req
+ * @Description : This function creates a new instance of AuditRequest
+ * @param[in] : None
+ * @return : Pointer to the AuditRequest class is returned
+ **/
AuditRequest *InternalTransactionCoordinator::audit_req() {
// create AuditReq object
if (audit_req_== NULL)
return audit_req_;
}
-/* db_config_req
- * @Description : This function creates a new instance of DBConfigurationRequest
- * @param[in]: NA
- * @return : DBConfigurationRequest
- * */
+/**db_config_req
+ * @Description : This function creates a new instance of
+ * DBConfigurationRequest
+ * @param[in] : None
+ * @return : Pointer to the DBConfigurationRequest class is returned
+ **/
DBConfigurationRequest *InternalTransactionCoordinator::db_config_req() {
// create DBConfigReq object
if (db_config_req_== NULL)
return db_config_req_;
}
-/* system_state_change_req
- * @Description : This function creates a new instance of SystemStateChangeRequest
- * @param[in]: NA
- * @return : SystemStateChangeRequest
- * */
+/**system_state_change_req
+ * @Description : This function creates a new instance of
+ * SystemStateChangeRequest
+ * @param[in] : None
+ * @return : Pointer to the SystemStateChangeRequest class is returned
+ **/
SystemStateChangeRequest
*InternalTransactionCoordinator::system_state_change_req() {
if (system_state_change_req_== NULL)
return system_state_change_req_;
}
-/* PerformConfigIdValidation
- * @Description : This function calls the validate funciton in physical core
- * @param[in]: sesssion argument, config id, session id
- * @return : Success or associated error code
- * */
+/**PerformConfigIdValidation
+ * @Description : This function validates the config id received in the
+ * message by calling the validate funciton in physical core
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * session_id - ipc session id used for TC validation
+ * config_id - configuration id used for TC validation
+ * @return : UPPL_RC_SUCCESS - will be returned if the config ID
+ * and session ID are valid
+ * UPPL_RC_ERR_INVALID_CONFIGID will be returned if
+ * config id is invalid or UPPL_RC_ERR_INVALID_SESSIONID
+ * will be returned if session id is invalid
+ **/
UpplReturnCode InternalTransactionCoordinator::PerformConfigIdValidation(
ServerSession &session,
uint32_t sessionId,
return validation_status;
}
-/* ProcessReq
- * @Description : This function gets the request type and invokes request obj
- * @param[in]: ipc session id, configuration id and session
- * @return : Success or associated error code
- * */
+/**ProcessReq
+ * @Description : This function validates the request based on the service id
+ * specified. For CREATE/UPDATE/DELETE operations the service
+ * id must be 0. For READ operations the service id must be 1
+ * @param[in] : session - Object of ServerSession
+ service_id - type of ipc service id
+ * @return : UPPL_RC_SUCCESS - will be returned if service id validation
+ * is success for appropriate operation type else UPPL_RC_ERR_*
+ * will be returned.
+ **/
UpplReturnCode InternalTransactionCoordinator::ProcessReq(
ServerSession &session,
pfc_ipcid_t service_id) {
UpplReturnCode resp_code = UPPL_RC_SUCCESS;
- if (service_id == 0 || service_id == 1) {
+ int err = 0;
+ if (service_id == 1 || service_id == 0) {
// create request header object to get arguments from session
physical_request_header obj_req_hdr;
int parse_ret = PhyUtil::sessGetReqHeader(session, obj_req_hdr);
if (standby_status != UPPL_RC_SUCCESS) {
rsh.result_code = UPPL_RC_ERR_NOT_SUPPORTED_BY_STANDBY;
pfc_log_error("Config not allowed in standby");
- int err = PhyUtil::sessOutRespHeader(session, rsh);
+ err = PhyUtil::sessOutRespHeader(session, rsh);
if (err != 0) {
return UPPL_RC_ERR_IPC_WRITE_ERROR;
}
obj_req_hdr.data_type > UNC_DT_AUDIT) {
rsh.result_code = UPPL_RC_ERR_DATATYPE_NOT_SUPPORTED;
pfc_log_error("datatype not supported");
- int err = PhyUtil::sessOutRespHeader(session, rsh);
+ err = PhyUtil::sessOutRespHeader(session, rsh);
if (err != 0) {
return UPPL_RC_ERR_IPC_WRITE_ERROR;
}
case UNC_OP_CREATE:
case UNC_OP_DELETE:
case UNC_OP_UPDATE:
- {
if (service_id != 0) {
pfc_log_error(
"Config Operation is provided with ServiceId other than 0");
}
resp_code = ProcessConfigRequest(session, obj_req_hdr, rsh);
break;
- }
case UNC_OP_CONTROL:
- {
pfc_log_info("Inside control request request - NOT_SUPPORTED");
rsh.result_code = UPPL_RC_ERR_OPERATION_NOT_SUPPORTED;
- int err = PhyUtil::sessOutRespHeader(session, rsh);
+ err = PhyUtil::sessOutRespHeader(session, rsh);
if (err != 0) {
return UPPL_RC_ERR_IPC_WRITE_ERROR;
}
break;
- }
case UNC_OP_READ:
case UNC_OP_READ_NEXT:
case UNC_OP_READ_BULK:
case UNC_OP_READ_SIBLING_BEGIN:
case UNC_OP_READ_SIBLING:
case UNC_OP_READ_SIBLING_COUNT:
- {
if (service_id != 1) {
pfc_log_error(
"Read Operation is provided with ServiceId other than 1");
}
resp_code = ProcessReadRequest(session, obj_req_hdr, rsh);
break;
- }
default:
rsh.result_code = UPPL_RC_ERR_OPERATION_NOT_SUPPORTED;
pfc_log_error("Operation not supported");
- int err = PhyUtil::sessOutRespHeader(session, rsh);
+ err = PhyUtil::sessOutRespHeader(session, rsh);
if (err != 0) {
return UPPL_RC_ERR_IPC_WRITE_ERROR;
}
operation, service_id);
switch (operation) {
case UNC_OP_IS_CANDIDATE_DIRTY:
- {
- uint8_t dirty_status = 0;
- ODBCM_RC_STATUS db_status = ODBCM_RC_SUCCESS;
- resp_code = UPPL_RC_SUCCESS;
- db_status = PhysicalLayer::get_instance()->get_odbc_manager()->
- IsCandidateDirty();
- if (db_status == ODBCM_RC_CANDIDATE_DIRTY) {
- dirty_status = 1;
- } else if (db_status != ODBCM_RC_SUCCESS) {
- resp_code = UPPL_RC_ERR_DB_GET;
- }
- session.addOutput(operation);
- session.addOutput((uint32_t)resp_code);
- session.addOutput(dirty_status);
+ resp_code = ProcessIsCandidateDirty(session, operation);
break;
- }
case UNC_OP_IMPORT_CONTROLLER_CONFIG:
case UNC_OP_MERGE_CONTROLLER_CONFIG:
case UNC_OP_CLEAR_IMPORT_CONFIG:
- {
resp_code = ProcessImportRequest(session, operation);
break;
- }
default:
pfc_log_error("Operation not allowed due to bad request type");
session.addOutput(operation);
return resp_code;
}
-/* ProcessEvent
- * @Description : This function process the received notification event
- * by creating notify req object
- * @param[in]: ipc event
- * @return : response code
+/**ProcessEvent
+ * @Description : This function process the received notification event
+ * by creating notify req object
+ * @param[in] : object of IpcEvent class
+ * @return : UPPL_RC_SUCCESS is returned when the response is added
+ * to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not
+ * be added to sess.
**/
UpplReturnCode InternalTransactionCoordinator::ProcessEvent(
const IpcEvent &event) {
return resp_code;
}
-/* ProcessConfigRequest
- * @Description : This function process the received configuration
- * requests from north bound
- * @param[in]: ipc session, parsed request header and response header
- * @return : response code and response header
+/**ProcessConfigRequest
+ * @Description : This function process the received configuration
+ * requests from north bound
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * obj_req_hdr - object of physical request header
+ * &rsh - object of the physical response header
+ * @return : UPPL_RC_SUCCESS if validation of config_id is success
+ * or UPPL_RC_ERR_* if validation fails.
**/
UpplReturnCode InternalTransactionCoordinator::ProcessConfigRequest(
ServerSession &session,
- physical_request_header obj_req_hdr,
+ physical_request_header &obj_req_hdr,
physical_response_header &rsh) {
UpplReturnCode resp_code = UPPL_RC_SUCCESS;
UpplReturnCode validate_status = PerformConfigIdValidation(
obj_req_hdr.client_sess_id,
obj_req_hdr.config_id);
if (validate_status != UPPL_RC_SUCCESS) {
- if (validate_status != UPPL_RC_ERR_INVALID_CONFIGID) {
+ if (validate_status == UPPL_RC_ERR_INVALID_CONFIGID) {
pfc_log_error("ITC::Process Req:: Config id validation failed");
}
- if (validate_status != UPPL_RC_ERR_INVALID_SESSIONID) {
+ if (validate_status == UPPL_RC_ERR_INVALID_SESSIONID) {
pfc_log_error("ITC::Process Req:: Session id validation failed");
}
rsh.result_code = validate_status;
}
return resp_code;
}
-
- pfc_log_info("Inside configuration request");
- if ((audit_state() != AUDIT_END) || (import_state() != IMPORT_END)) {
- rsh.result_code = UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
- pfc_log_error("Config not allowed- operation in progress");
- int err = PhyUtil::sessOutRespHeader(session, rsh);
- if (err != 0) {
- return UPPL_RC_ERR_IPC_WRITE_ERROR;
- }
- return resp_code;
- }
-
if (config_request_status() == false) {
set_config_request_status(true);
// create configuration req object to invoke processreq function.
ConfigurationRequest configuration_req;
- resp_code = (UpplReturnCode) configuration_req.ProcessReq(session);
+ resp_code = (UpplReturnCode) configuration_req.ProcessReq(session,
+ obj_req_hdr);
set_config_request_status(false);
} else {
rsh.result_code = UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
return resp_code;
}
-/* ProcessReadRequest
- * @Description : This function process the received read
- * requests from north bound
- * @param[in]: ipc session, parsed request header and response header
- * @return : response code and response header
+/**ProcessReadRequest
+ * @Description : This function process the received read
+ * requests from north bound
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * obj_req_hdr - object of physical request header
+ * &rsh - object of the physical response header
+ * @return : UPPL_RC_SUCCESS if validation of config_id is success
+ * or UPPL_RC_ERR_* if validation fails.
**/
UpplReturnCode InternalTransactionCoordinator::ProcessReadRequest(
ServerSession &session,
- physical_request_header obj_req_hdr,
+ physical_request_header &obj_req_hdr,
physical_response_header &rsh) {
- UpplReturnCode resp_code = UPPL_RC_SUCCESS;
- if ((obj_req_hdr.data_type != UNC_DT_STATE) &&
- (obj_req_hdr.data_type != UNC_DT_CANDIDATE) &&
- (obj_req_hdr.data_type != UNC_DT_RUNNING) &&
- (obj_req_hdr.data_type != UNC_DT_STARTUP)) {
+ if (!(obj_req_hdr.data_type == UNC_DT_STATE ||
+ obj_req_hdr.data_type == UNC_DT_RUNNING ||
+ obj_req_hdr.data_type == UNC_DT_CANDIDATE ||
+ obj_req_hdr.data_type == UNC_DT_STARTUP)) {
rsh.result_code = UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
pfc_log_error("operation not allowed for this dt state");
int err = PhyUtil::sessOutRespHeader(session, rsh);
obj_req_hdr.client_sess_id,
obj_req_hdr.config_id);
if (validate_status != UPPL_RC_SUCCESS) {
- if (validate_status != UPPL_RC_ERR_INVALID_CONFIGID) {
+ if (validate_status == UPPL_RC_ERR_INVALID_CONFIGID) {
pfc_log_error("ITC::Process Req:: Config id validation failed");
}
- if (validate_status != UPPL_RC_ERR_INVALID_SESSIONID) {
+ if (validate_status == UPPL_RC_ERR_INVALID_SESSIONID) {
pfc_log_error("ITC::Process Req:: Session id validation failed");
}
rsh.result_code = validate_status;
}
// Form read request object to invoke process request function
ReadRequest read_req;
- resp_code = (UpplReturnCode) read_req.ProcessReq(session);
- return resp_code;
+ return (UpplReturnCode) read_req.ProcessReq(session, obj_req_hdr);
}
-/* ProcessImportRequest
- * @Description : This function process the received import
- * requests from north bound
- * @param[in]: ipc session and import operation type
- * @return : response code
+/**ProcessImportRequest
+ * @Description : This function process the received import
+ * requests from north bound
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * operation - UNC_OP_* specifies the operation
+ * @return : UPPL_RC_SUCCESS is returned when the response is added
+ * to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not
+ * be added to sess.
**/
UpplReturnCode InternalTransactionCoordinator::ProcessImportRequest(
ServerSession &session,
pfc_log_debug("Controller name received %s", ctr_name);
memcpy(obj_key_ctr.controller_name, ctr_name, strlen(ctr_name)+1);
}
- if ((audit_state() != AUDIT_END) || (import_state() != IMPORT_END) ||
- (config_request_status() == true)) {
+ if (config_request_status() == true) {
ret_code = UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
pfc_log_error("Import not allowed- operation in progress");
} else {
+ UpplReturnCode db_ret = UPPL_RC_SUCCESS;
+ OPEN_DB_CONNECTION(unc::uppl::kOdbcmConnReadWriteNb, db_ret);
+ if (db_ret != UPPL_RC_SUCCESS) {
+ pfc_log_fatal("DB Connection failure for operation %d",
+ operation);
+ return db_ret;
+ }
// create import request object to invoke processreq
ImportRequest import_req;
- ret_code = import_req.ProcessRequest(operation,
+ ret_code = import_req.ProcessRequest(&db_conn, operation,
obj_key_ctr);
+ if (ret_code == UPPL_RC_SUCCESS) {
+ if (operation == UNC_OP_IMPORT_CONTROLLER_CONFIG) {
+ controller_in_import_ = (const char*) obj_key_ctr.controller_name;
+ } else if (operation == UNC_OP_CLEAR_IMPORT_CONFIG) {
+ controller_in_import_.clear();
+ }
+ }
}
session.addOutput(operation);
session.addOutput((uint32_t)ret_code);
return UPPL_RC_SUCCESS;
}
+
+/**ProcessIsCandidateDirty
+ * @Description : This function process the IsCandidateDirty
+ * request from north bound
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * operation - UNC_OP_* specifies the operation
+ * @return : UPPL_RC_SUCCESS is returned when the response is added
+ * to ipc session successfully.
+ * UPPL_RC_ERR_* is returned when ipc response could not
+ * be added to sess.
+ **/
+UpplReturnCode InternalTransactionCoordinator::ProcessIsCandidateDirty(
+ ServerSession &session,
+ uint32_t operation) {
+ UpplReturnCode db_ret = UPPL_RC_SUCCESS, resp_code = UPPL_RC_SUCCESS;
+ OPEN_DB_CONNECTION(unc::uppl::kOdbcmConnReadWriteNb, db_ret);
+ if (db_ret != UPPL_RC_SUCCESS) {
+ pfc_log_fatal("DB Connection failure for operation %d",
+ operation);
+ return db_ret;
+ }
+ uint8_t dirty_status = 0;
+ ODBCM_RC_STATUS db_status =
+ PhysicalLayer::get_instance()->get_odbc_manager()->
+ IsCandidateDirty(&db_conn);
+ if (db_status == ODBCM_RC_CANDIDATE_DIRTY) {
+ dirty_status = 1;
+ } else if (db_status != ODBCM_RC_SUCCESS) {
+ resp_code = UPPL_RC_ERR_DB_GET;
+ }
+ int err = session.addOutput(operation);
+ err |= session.addOutput((uint32_t)resp_code);
+ err |= session.addOutput(dirty_status);
+ if (err != 0) {
+ pfc_log_info("Error in sending IsCandidateDirty response");
+ resp_code = UPPL_RC_ERR_IPC_WRITE_ERROR;
+ }
+ return resp_code;
+}
NotificationManager* NotificationManager::vnp_notification_manager_ = NULL;
/**
- * * @Description: This function is used for handling different notification
- * events
- * * * @param[in]: IpcEvent
- * * * @return : void
+ * @Description : This function is used for handling different
+ * notification events
+ * @param[in] : event - object of IPC event
+ * @return : void
* */
void NotificationManager::eventHandler(const IpcEvent &event) {
// Get Physical layer instance
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
pfc_log_info("NotificationManager - An event is received");
- pfc_log_info("Event:[Serial:%d , Type:%d , ChannelName:%s]",
- event.getSerial(), event.getType(), \
- event.getChannelName());
- pfc_log_info("Event:[ServiceName:%s,isStateChangeEvent:%d]",
- event.getServiceName(), \
- event.isStateChangeEvent());
+ pfc_log_info(
+ "Event:[Serial:%d , Type:%d , ChannelName:%s, "
+ "ServiceName:%s, isStateChangeEvent:%d]",
+ event.getSerial(), event.getType(),
+ event.getChannelName(),
+ event.getServiceName(),
+ event.isStateChangeEvent());
PHY_FINI_EVENT_LOCK();
// Ignore notifications, if system state is standby
if (physical_layer->get_physical_core()->get_system_state() == \
pfc_log_warn("Event is ignored due to standby system state\n");
return;
}
-
// Call itc to process the events
- physical_layer->get_physical_core()->get_internal_transaction_coordinator()
- ->ProcessEvent(event);
+ physical_layer->get_physical_core()->
+ get_internal_transaction_coordinator()->ProcessEvent(event);
}
const char* NotificationManager::getName(void) {
}
/**
- * * @Description: This function is used for get notification manager instance
- * * * @param[in]: controller type
- * * * @return : NotificationManager
+ * @Description : Returns NotificationManager instance pointer for PFC and VNP
+ * controller type. For other types it returns NULL. This
+ * function make sure only one instance is created for each
+ * type(PFC/VNP) of controller.
+ * @param[in] : ctr_type - controller type
+ * @return : NotificationManager instance pointer for PFC and VNP
+ * controller type. For other types it returns NULL
* */
NotificationManager* NotificationManager::get_notification_manager(
unc_keytype_ctrtype_t ctr_type) {
}
physical_layer->notification_manager_mutex_.unlock();
return pfc_notification_manager_;
- }
- if (ctr_type == UNC_CT_VNP) {
+ } else if (ctr_type == UNC_CT_VNP) {
if (vnp_notification_manager_ == NULL) {
vnp_notification_manager_ = new NotificationManager();
}
physical_layer->notification_manager_mutex_.unlock();
return vnp_notification_manager_;
+ } else {
+ physical_layer->notification_manager_mutex_.unlock();
}
return NULL;
}
/**
- * * @Description: This function is used for release notification manager instances
- * * * @param[in]: None
- * * * @return : None
+ * @Description : This function is used for release notification
+ * manager instances
+ * @param[in] : None
+ * @return : void
* */
void NotificationManager::release_notification_manager() {
pfc_notification_manager_ = NULL;
*@file physical_layer.cc
*
* Desc:
- * This header file contains the definition of PhysicalLayer class
+ * This file contains the definition of PhysicalLayer class
* which is the base class for all other classes
*/
ReadWriteLock PhysicalLayer::phy_fini_db_lock_;
ReadWriteLock PhysicalLayer::phy_fini_phycore_lock_;
ReadWriteLock PhysicalLayer::phy_fini_event_lock_;
+ReadWriteLock PhysicalLayer::events_done_lock_;
uint8_t PhysicalLayer::phyFiniFlag = 0;
framework.This is the module initialization function which
invokes IntializePhysicalSubModules.
*@param[in] : None
- *@return : PFC_TRUE or PFC_FALSE
+ *@return : PFC_TRUE is returned if this module is initialized successfully
+ * otherwise PFC_FALSE is returned to denote error
**/
pfc_bool_t PhysicalLayer::init() {
- pfc_log_debug("Physical Layer's init called");
+ pfc_log_info("Physical Layer init() called");
uint8_t init_status = InitializePhysicalSubModules();
- pfc_log_info("Initialising physical sub mobules");
if (init_status != UPPL_RC_SUCCESS) {
- pfc_log_debug("Init failed");
+ pfc_log_warn("Init failed with %d", init_status);
return PFC_FALSE;
}
- pfc_log_info("Init() is Successful");
+ pfc_log_debug("Physical Layer init() is Successful");
return PFC_TRUE;
}
*@Description : The fini() function will be called automatically by PFC core
framework when UPPL module is to be terminated.
*@param[in] : None
- *@return : PFC_TRUE or PFC_FALSE
+ *@return : PFC_TRUE is returned if this module is finalized successfully
+ * otherwise PFC_FALSE is returned to denote error
**/
pfc_bool_t PhysicalLayer::fini() {
pfc_log_info("Physical Layer's fini called");
PFC_TRUE);
}
UpplReturnCode fini_status = FinalizePhysicalSubModules();
- pfc_log_debug("Finalising all physical sub modules");
if (fini_status != UPPL_RC_SUCCESS) {
- pfc_log_debug("Finish failed");
+ pfc_log_warn("Fini failed with %d", fini_status);
return PFC_FALSE;
}
if (physical_layer_ != NULL) delete physical_layer_;
/**
- *@Description : This function instantiates objects for the classes PhysicalCore,
- IPCConnectionManager, ODBCManager and LogManager.
+ *@Description : This function instantiates objects for the classes
+ * PhysicalCore, IPCConnectionManager and ODBCManager.
*@param[in] : None
- *@return : UPPL_RC_SUCCESS or any associated error code
+ *@return : UPPL_RC_SUCCESS is returned if all sub modules are initialized
+ * successfully
+ * otherwise UPPL_RC_ERR* is returned to denote error
+
**/
UpplReturnCode PhysicalLayer::InitializePhysicalSubModules() {
UpplReturnCode ret = UPPL_RC_SUCCESS;
UpplReturnCode resp = UPPL_RC_SUCCESS;
- pfc_log_info("Initialising IPCConnectionManager submodule");
+ pfc_log_debug("Initialising IPCConnectionManager submodule");
ipc_connection_manager_= new IPCConnectionManager();
if (ipc_connection_manager_ == NULL) {
pfc_log_error("Memory not allocated for ipc_connection_manager_");
pfc_log_error("Memory not allocated for physical_core_");
return UPPL_RC_ERR_FATAL_RESOURCE_ALLOCATION;
}
- pfc_log_info("Initialising PhysicalCore submodule");
+ pfc_log_debug("Initialising PhysicalCore submodule");
ret = physical_core_->InitializePhysical();
if (ret != UPPL_RC_SUCCESS) {
pfc_log_error("Physical core initialise failed");
return ret;
}
pfc_log_info("Physical Core initialised");
- pfc_log_info("Initialising ODBCManger submodule");
+ pfc_log_debug("Initialising ODBCManger submodule");
odbc_manager_= ODBCManager::get_ODBCManager();
if (odbc_manager_ == NULL) {
pfc_log_error("Memory not allocated for odbc_manager_");
/**
*@Description : This function releases the objects instantiated for the
- classes PhysicalCore,IPCConnectionManager,
- ODBCManager and LogManager
+ classes PhysicalCore, IPCConnectionManager and
+ ODBCManager
*@param[in] : None
- *@return : UPPL_RC_SUCCESS or any associated error code
+ *@return : UPPL_RC_SUCCESS is returned if all sub modules are finalized
+ * successfully
+ * otherwise UPPL_RC_ERR* is returned to denote error
**/
UpplReturnCode PhysicalLayer::FinalizePhysicalSubModules() {
UpplReturnCode response = UPPL_RC_SUCCESS;
PFC_TRUE);
if (NULL != (odbc_manager_ = ODBCManager::get_ODBCManager())) {
delete odbc_manager_;
- pfc_log_info("odbc_manager_ is freed");
} else {
pfc_log_error("odbc_manager_ is already freed or NULL");
}
*@Description : This is a call back function provided in IPC framework.
This function will be called by IPC library when IPC Server
receives a message corresponding to the registered services.
- *@param[in] : session, service_id
- *@return : ipc response
+ * @param[in] : session - Object of ServerSession where the request
+ * argument present
+ * service_id - service id to classify the type of request.
+ * UPPL expects 1, 2 or 3.
+ * @return : Response code back to the caller.
+ * The system/generic level errors or common errors are generally
+ * returned in this function otherwise SUCCESS(0) will be returned.
+ * When an error code is being returned in this function, the caller
+ * cannot expect more specific error in response.
+ * When SUCCESS(0) is returned, the caller should further check
+ * the operation result_code in the response for more specific error.
+
**/
pfc_ipcresp_t PhysicalLayer::ipcService(ServerSession &session,
pfc_ipcid_t service_id) {
pfc_log_info("PhysicalLayer::ipcService is called with service id %d",
service_id);
PHY_FINI_IPC_LOCK(UPPL_RC_ERR_SHUTTING_DOWN);
- pfc_ipcresp_t resp = 0;
- resp = ipc_connection_manager_->get_ipc_server_handler()->
+ return ipc_connection_manager_->get_ipc_server_handler()->
IpcService(session, service_id);
- return resp;
}
return odbc_manager_;
}
-PFC_MODULE_IPC_DECL(unc::uppl::PhysicalLayer, 5); // This macro
+PFC_MODULE_IPC_DECL(unc::uppl::PhysicalLayer, 3); // This macro
// registers the service handler
namespace unc {
namespace uppl {
+/* @Description : Constructor function used to initialize the system state
+ * to StandBy and other event handler ID's.
+ * @param[in] : None
+ * @return : None
+ **/
UncStateHandler::UncStateHandler()
: lock_(),
system_state_(UPPL_SYSTEM_ST_STANDBY),
unc_act_ev_id_(EVHANDLER_ID_INVALID),
unc_act_ev_handler_(std::bind1st(
- std::mem_fun(&UncStateHandler::unc_act_event_handler_fn), this)) {}
+ std::mem_fun(&UncStateHandler::unc_act_event_handler_fn), this)) {
+}
+/* @Description : This function is used for active state event handling from
+ * StandBy mode and updates the event subscription to driver.
+ * @param[in] : Event pointer to pfc core event
+ * @return : None
+ **/
void UncStateHandler::unc_act_event_handler_fn(pfc::core::Event* Event) {
lock_.lock();
pfc_log_info("State change to Active received from Daemon");
if (system_state_ == UPPL_SYSTEM_ST_STANDBY) {
+ // Close the existing rw connections if any after switch over
+ ODBCM_RC_STATUS close_rw_handle =
+ PhysicalLayer::get_instance()->get_odbc_manager()->CloseRwConnection();
+ pfc_log_debug("Rw Connection Handle Free status %d", close_rw_handle);
set_system_state(UPPL_SYSTEM_ST_ACTIVE);
- // ReConnect the DB
- ODBCM_RC_STATUS odbc_ret = ODBCManager::get_ODBCManager()->ReconnectDB();
- if (odbc_ret != ODBCM_RC_SUCCESS) {
- pfc_log_error("Unable to reconnect to DB");
- return;
- }
// Send event subscription to driver
UpplReturnCode ret = PhysicalCore::get_physical_core()->
SendEventSubscripToDriver();
pfc_log_debug("Event subscription return %d", ret);
+ // clear all alarms
+ pfc::alarm::pfc_alarm_clear(UNCCID_PHYSICAL);
} else {
pfc_log_info("System is already in Active");
}
return;
}
+/* @Description : This function is used for registering event handler for
+ * active and standby states
+ * @param[in] : None
+ * @return : PFC_TRUE - if active event and standby event
+ * registering response is 0 else PFC_FALSE will be returned
+ **/
pfc_bool_t UncStateHandler::RegisterStateHandlers() {
lock_.lock();
// Register event handler for active
return (ret == 0) ? PFC_TRUE : PFC_FALSE;
}
+/* @Description : This function is used for removing event handler status for
+ * active and standby event
+ * @param[in] : None
+ * @return : PFC_TRUE - if active event and standby event
+ * handler status after removing is 0 else PFC_FALSE
+ * will be returned
+ **/
pfc_bool_t UncStateHandler::UnRegisterStateHandlers() {
int ret = 0;
if (EVHANDLER_ID_INVALID != unc_act_ev_id_) {
// set configration status.
tc_rtn = tc_instance->TcGetConfigSession(&session_id, &config_id);
RETURN_IF((tc_rtn != tc::TC_API_COMMON_SUCCESS &&
- tc_rtn != tc::TC_NO_CONFIG_SESSION), USESS_E_NG,
+ tc_rtn != tc::TC_NO_CONFIG_SESSION &&
+ tc_rtn != tc::TC_INVALID_UNC_STATE), USESS_E_NG,
"Get configuration session to TC. err=%d", tc_rtn);
- if (session_id == target.id) {
+ if (tc_rtn == tc::TC_API_COMMON_SUCCESS && session_id == target.id) {
info_list[0].config_status = CONFIG_STATUS_TCLOCK;
}
// set configration status.
tc_rtn = tc_instance->TcGetConfigSession(&session_id, &config_id);
RETURN_IF((tc_rtn != tc::TC_API_COMMON_SUCCESS &&
- tc_rtn != tc::TC_NO_CONFIG_SESSION), USESS_E_NG,
+ tc_rtn != tc::TC_NO_CONFIG_SESSION &&
+ tc_rtn != tc::TC_INVALID_UNC_STATE), USESS_E_NG,
"Get configuration session to TC. err=%d", tc_rtn);
// list clear.
// list set.
for (it = table_.begin(); it != table_.end(); ++it) {
info_list.push_back(it->second.sess());
- if (session_id == it->second.sess().sess.id) {
+ if (tc_rtn == tc::TC_API_COMMON_SUCCESS &&
+ session_id == it->second.sess().sess.id) {
info_list[info_list.size() - 1].config_status = CONFIG_STATUS_TCLOCK;
}
}
actual_version varchar(32),
oper_status smallint default 0,
valid char(9),
- cs_row_status smallint,
+ cs_row_status smallint default 5,
cs_attr char(9)
);
description varchar(128) ,
oper_status smallint default 1 ,
valid char(3),
- cs_row_status smallint,
+ cs_row_status smallint default 5,
cs_attr char(3),
primary key(controller_name,domain_name)
);
logical_port_id2 bytea,
oper_status smallint default 1,
valid char(8),
- cs_row_status smallint,
+ cs_row_status smallint default 5,
cs_attr char(8)
);
description varchar(128) ,
oper_status smallint default 1 ,
valid char(3),
- cs_row_status smallint,
+ cs_row_status smallint default 5,
cs_attr char(3),
primary key(controller_name,domain_name)
);
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
unc_vtn_name varchar(32) default ' ',
- PRIMARY KEY(ctrlr_vtn_name, controller_name, domain_id),
- UNIQUE(unc_vtn_name));
+ PRIMARY KEY(ctrlr_vtn_name, controller_name, domain_id));
CREATE TABLE su_vbr_tbl (
vtn_name varchar(32) default ' ',
valid_logical_port_id smallint default 0,
valid_vlanid smallint default 0,
valid_tagged smallint default 0,
+ valid_vex_name smallint default 0,
+ valid_vex_if_name smallint default 0,
+ valid_vex_link_name smallint default 0,
valid_oper_status smallint default 0,
cs_rowstatus smallint default 3,
cs_admin_status smallint default 3,
domain_id varchar(32) default ' ',
unc_vtn_name varchar(32) default ' ',
unc_vnode_name varchar(32) default ' ',
- PRIMARY KEY(ctrlr_vtn_name, ctrlr_vnode_name, controller_name, domain_id),
- UNIQUE(unc_vtn_name, unc_vnode_name));
+ PRIMARY KEY(ctrlr_vtn_name, ctrlr_vnode_name, controller_name, domain_id));
CREATE TABLE su_vlink_tbl (
vtn_name varchar(32) default ' ',
controller2_name varchar(32) default ' ',
domain1_id varchar(32) default ' ',
domain2_id varchar(32) default ' ',
- flags smallint default 0,
+ key_flags smallint default 0,
+ val_flags smallint default 0,
valid_admin_status smallint default 0,
valid_vnode1_name smallint default 0,
valid_vnode1_ifname smallint default 0,
domain_id varchar(32) default ' ',
unc_vtn_name varchar(32) default ' ',
unc_vlink_name varchar(32) default ' ',
- PRIMARY KEY(ctrlr_vtn_name, ctrlr_vlink_name, controller_name, domain_id),
- UNIQUE(unc_vtn_name, unc_vlink_name));
+ PRIMARY KEY(ctrlr_vtn_name, ctrlr_vlink_name, controller_name, domain_id));
CREATE TABLE su_static_ip_route_tbl (
vtn_name varchar(32) default ' ',
vrouter_name varchar(32) default ' ',
dst_ip_addr bytea default '\000\000\000\000',
mask smallint default 0,
- nwm_name varchar(32) default ' ',
next_hop_addr bytea default '\000\000\000\000',
+ nwm_name varchar(32) default ' ',
metric integer default 0,
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
valid_metric smallint default 0,
cs_rowstatus smallint default 3,
cs_metric smallint default 3,
- PRIMARY KEY(vtn_name, vrouter_name, dst_ip_addr, mask, nwm_name, next_hop_addr));
+ PRIMARY KEY(vtn_name, vrouter_name, dst_ip_addr, mask, next_hop_addr, nwm_name));
CREATE TABLE su_dhcp_relay_server_tbl (
vtn_name varchar(32) default ' ',
logical_port_id varchar(320) default ' ',
vlanid integer default 0,
tagged smallint default 0,
- vex_name varchar(32) default ' ',
- vex_if_name varchar(32) default ' ',
- vex_link_name varchar(32) default ' ',
oper_status smallint default 0,
down_count bigint default 0,
controller_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
description varchar(128) default ' ',
flags smallint default 0,
- valid_controller_name varchar(32) default 0,
- valid_description varchar(32) default 0,
+ valid_controller_name smallint default 0,
+ valid_description smallint default 0,
cs_rowstatus smallint default 3,
- cs_controller_name varchar(32) default 3,
- cs_description varchar(32) default 3,
+ cs_controller_name smallint default 3,
+ cs_description smallint default 3,
PRIMARY KEY(vtn_name, vtepgrp_name));
CREATE TABLE su_vtep_grp_mem_tbl (
domain_id varchar(32) default ' ',
underlay_vtn_name varchar(32) default ' ',
vtepgrp_name varchar(32) default ' ',
- label integer default 0,
+ label bigint default 0,
oper_status smallint default 0,
down_count bigint default 0,
flags smallint default 0,
logical_port_id varchar(320) default ' ',
vlanid integer default 0,
tagged smallint default 0,
- vex_name varchar(32) default ' ',
- vex_if_name varchar(32) default ' ',
- vex_link_name varchar(32) default ' ',
oper_status smallint default 0,
down_count bigint default 0,
controller_name varchar(32) default ' ',
ctrlr_flowlist_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
unc_flowlist_name varchar(33) default ' ',
- PRIMARY KEY(ctrlr_flowlist_name, ctrlr_name),
- UNIQUE(unc_flowlist_name));
+ PRIMARY KEY(ctrlr_flowlist_name, ctrlr_name));
CREATE TABLE su_flowlist_entry_tbl (
flowlist_name varchar(33) default ' ',
ctrlr_policingprofile_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
unc_policingprofile_name varchar(33) default ' ',
- PRIMARY KEY(ctrlr_policingprofile_name, ctrlr_name),
- UNIQUE(unc_policingprofile_name));
+ PRIMARY KEY(ctrlr_policingprofile_name, ctrlr_name));
CREATE TABLE su_policingprofile_entry_tbl (
policingprofile_name varchar(33) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
unc_vtn_name varchar(32) default ' ',
- PRIMARY KEY(ctrlr_vtn_name, controller_name, domain_id),
- UNIQUE(unc_vtn_name));
+ PRIMARY KEY(ctrlr_vtn_name, controller_name, domain_id));
CREATE TABLE ca_vbr_tbl (
vtn_name varchar(32) default ' ',
valid_logical_port_id smallint default 0,
valid_vlanid smallint default 0,
valid_tagged smallint default 0,
+ valid_vex_name smallint default 0,
+ valid_vex_if_name smallint default 0,
+ valid_vex_link_name smallint default 0,
valid_oper_status smallint default 0,
cs_rowstatus smallint default 3,
cs_admin_status smallint default 3,
domain_id varchar(32) default ' ',
unc_vtn_name varchar(32) default ' ',
unc_vnode_name varchar(32) default ' ',
- PRIMARY KEY(ctrlr_vtn_name, ctrlr_vnode_name, controller_name, domain_id),
- UNIQUE(unc_vtn_name, unc_vnode_name));
+ PRIMARY KEY(ctrlr_vtn_name, ctrlr_vnode_name, controller_name, domain_id));
CREATE TABLE ca_vlink_tbl (
vtn_name varchar(32) default ' ',
controller2_name varchar(32) default ' ',
domain1_id varchar(32) default ' ',
domain2_id varchar(32) default ' ',
- flags smallint default 0,
+ key_flags smallint default 0,
+ val_flags smallint default 0,
valid_admin_status smallint default 0,
valid_vnode1_name smallint default 0,
valid_vnode1_ifname smallint default 0,
domain_id varchar(32) default ' ',
unc_vtn_name varchar(32) default ' ',
unc_vlink_name varchar(32) default ' ',
- PRIMARY KEY(ctrlr_vtn_name, ctrlr_vlink_name, controller_name, domain_id),
- UNIQUE(unc_vtn_name, unc_vlink_name));
+ PRIMARY KEY(ctrlr_vtn_name, ctrlr_vlink_name, controller_name, domain_id));
CREATE TABLE ca_static_ip_route_tbl (
vtn_name varchar(32) default ' ',
vrouter_name varchar(32) default ' ',
dst_ip_addr bytea default '\000\000\000\000',
mask smallint default 0,
- nwm_name varchar(32) default ' ',
next_hop_addr bytea default '\000\000\000\000',
+ nwm_name varchar(32) default ' ',
metric integer default 0,
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
valid_metric smallint default 0,
cs_rowstatus smallint default 3,
cs_metric smallint default 3,
- PRIMARY KEY(vtn_name, vrouter_name, dst_ip_addr, mask, nwm_name, next_hop_addr));
+ PRIMARY KEY(vtn_name, vrouter_name, dst_ip_addr, mask, next_hop_addr, nwm_name));
CREATE TABLE ca_dhcp_relay_server_tbl (
vtn_name varchar(32) default ' ',
logical_port_id varchar(320) default ' ',
vlanid integer default 0,
tagged smallint default 0,
- vex_name varchar(32) default ' ',
- vex_if_name varchar(32) default ' ',
- vex_link_name varchar(32) default ' ',
oper_status smallint default 0,
down_count bigint default 0,
controller_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
description varchar(128) default ' ',
flags smallint default 0,
- valid_controller_name varchar(32) default 0,
- valid_description varchar(32) default 0,
+ valid_controller_name smallint default 0,
+ valid_description smallint default 0,
cs_rowstatus smallint default 3,
- cs_controller_name varchar(32) default 3,
- cs_description varchar(32) default 3,
+ cs_controller_name smallint default 3,
+ cs_description smallint default 3,
PRIMARY KEY(vtn_name, vtepgrp_name));
CREATE TABLE ca_vtep_grp_mem_tbl (
domain_id varchar(32) default ' ',
underlay_vtn_name varchar(32) default ' ',
vtepgrp_name varchar(32) default ' ',
- label integer default 0,
+ label bigint default 0,
oper_status smallint default 0,
down_count bigint default 0,
flags smallint default 0,
logical_port_id varchar(320) default ' ',
vlanid integer default 0,
tagged smallint default 0,
- vex_name varchar(32) default ' ',
- vex_if_name varchar(32) default ' ',
- vex_link_name varchar(32) default ' ',
oper_status smallint default 0,
down_count bigint default 0,
controller_name varchar(32) default ' ',
ctrlr_flowlist_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
unc_flowlist_name varchar(33) default ' ',
- PRIMARY KEY(ctrlr_flowlist_name, ctrlr_name),
- UNIQUE(unc_flowlist_name));
+ PRIMARY KEY(ctrlr_flowlist_name, ctrlr_name));
CREATE TABLE ca_flowlist_entry_tbl (
flowlist_name varchar(33) default ' ',
ctrlr_policingprofile_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
unc_policingprofile_name varchar(33) default ' ',
- PRIMARY KEY(ctrlr_policingprofile_name, ctrlr_name),
- UNIQUE(unc_policingprofile_name));
+ PRIMARY KEY(ctrlr_policingprofile_name, ctrlr_name));
CREATE TABLE ca_policingprofile_entry_tbl (
policingprofile_name varchar(33) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
unc_vtn_name varchar(32) default ' ',
- PRIMARY KEY(ctrlr_vtn_name, controller_name, domain_id),
- UNIQUE(unc_vtn_name));
+ PRIMARY KEY(ctrlr_vtn_name, controller_name, domain_id));
CREATE TABLE ru_vbr_tbl (
vtn_name varchar(32) default ' ',
valid_logical_port_id smallint default 0,
valid_vlanid smallint default 0,
valid_tagged smallint default 0,
+ valid_vex_name smallint default 0,
+ valid_vex_if_name smallint default 0,
+ valid_vex_link_name smallint default 0,
valid_oper_status smallint default 0,
cs_rowstatus smallint default 3,
cs_admin_status smallint default 3,
cs_tagged smallint default 3,
PRIMARY KEY(vtn_name, vbridge_name, if_name));
+CREATE INDEX index_for_show_perf ON ru_vbr_if_tbl (vtn_name, vex_name, valid_vex_name);
+
CREATE TABLE ru_vrt_tbl (
vtn_name varchar(32) default ' ',
vrouter_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
unc_vtn_name varchar(32) default ' ',
unc_vnode_name varchar(32) default ' ',
- PRIMARY KEY(ctrlr_vtn_name, ctrlr_vnode_name, controller_name, domain_id),
- UNIQUE(unc_vtn_name, unc_vnode_name));
+ PRIMARY KEY(ctrlr_vtn_name, ctrlr_vnode_name, controller_name, domain_id));
CREATE TABLE ru_vlink_tbl (
vtn_name varchar(32) default ' ',
controller2_name varchar(32) default ' ',
domain1_id varchar(32) default ' ',
domain2_id varchar(32) default ' ',
- flags smallint default 0,
+ key_flags smallint default 0,
+ val_flags smallint default 0,
valid_admin_status smallint default 0,
valid_vnode1_name smallint default 0,
valid_vnode1_ifname smallint default 0,
domain_id varchar(32) default ' ',
unc_vtn_name varchar(32) default ' ',
unc_vlink_name varchar(32) default ' ',
- PRIMARY KEY(ctrlr_vtn_name, ctrlr_vlink_name, controller_name, domain_id),
- UNIQUE(unc_vtn_name, unc_vlink_name));
+ PRIMARY KEY(ctrlr_vtn_name, ctrlr_vlink_name, controller_name, domain_id));
CREATE TABLE ru_static_ip_route_tbl (
vtn_name varchar(32) default ' ',
vrouter_name varchar(32) default ' ',
dst_ip_addr bytea default '\000\000\000\000',
mask smallint default 0,
- nwm_name varchar(32) default ' ',
next_hop_addr bytea default '\000\000\000\000',
+ nwm_name varchar(32) default ' ',
metric integer default 0,
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
valid_metric smallint default 0,
cs_rowstatus smallint default 3,
cs_metric smallint default 3,
- PRIMARY KEY(vtn_name, vrouter_name, dst_ip_addr, mask, nwm_name, next_hop_addr));
+ PRIMARY KEY(vtn_name, vrouter_name, dst_ip_addr, mask, next_hop_addr, nwm_name));
CREATE TABLE ru_dhcp_relay_server_tbl (
vtn_name varchar(32) default ' ',
logical_port_id varchar(320) default ' ',
vlanid integer default 0,
tagged smallint default 0,
- vex_name varchar(32) default ' ',
- vex_if_name varchar(32) default ' ',
- vex_link_name varchar(32) default ' ',
oper_status smallint default 0,
down_count bigint default 0,
controller_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
description varchar(128) default ' ',
flags smallint default 0,
- valid_controller_name varchar(32) default 0,
- valid_description varchar(32) default 0,
+ valid_controller_name smallint default 0,
+ valid_description smallint default 0,
cs_rowstatus smallint default 3,
- cs_controller_name varchar(32) default 3,
- cs_description varchar(32) default 3,
+ cs_controller_name smallint default 3,
+ cs_description smallint default 3,
PRIMARY KEY(vtn_name, vtepgrp_name));
CREATE TABLE ru_vtep_grp_mem_tbl (
domain_id varchar(32) default ' ',
underlay_vtn_name varchar(32) default ' ',
vtepgrp_name varchar(32) default ' ',
- label integer default 0,
+ label bigint default 0,
oper_status smallint default 0,
down_count bigint default 0,
flags smallint default 0,
logical_port_id varchar(320) default ' ',
vlanid integer default 0,
tagged smallint default 0,
- vex_name varchar(32) default ' ',
- vex_if_name varchar(32) default ' ',
- vex_link_name varchar(32) default ' ',
oper_status smallint default 0,
down_count bigint default 0,
controller_name varchar(32) default ' ',
ctrlr_flowlist_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
unc_flowlist_name varchar(33) default ' ',
- PRIMARY KEY(ctrlr_flowlist_name, ctrlr_name),
- UNIQUE(unc_flowlist_name));
+ PRIMARY KEY(ctrlr_flowlist_name, ctrlr_name));
CREATE TABLE ru_flowlist_entry_tbl (
flowlist_name varchar(33) default ' ',
ctrlr_policingprofile_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
unc_policingprofile_name varchar(33) default ' ',
- PRIMARY KEY(ctrlr_policingprofile_name, ctrlr_name),
- UNIQUE(unc_policingprofile_name));
+ PRIMARY KEY(ctrlr_policingprofile_name, ctrlr_name));
CREATE TABLE ru_policingprofile_entry_tbl (
policingprofile_name varchar(33) default ' ',
valid_alarm_status smallint default 0,
valid_creation_time smallint default 0,
valid_last_updated_time smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
PRIMARY KEY(vtn_name));
CREATE TABLE im_vtn_ctrlr_tbl (
flags smallint default 0,
valid_oper_status smallint default 0,
valid_alarm_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
PRIMARY KEY(vtn_name, controller_name, domain_id));
CREATE TABLE im_vtn_rename_tbl (
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
unc_vtn_name varchar(32) default ' ',
- PRIMARY KEY(ctrlr_vtn_name, controller_name, domain_id),
- UNIQUE(unc_vtn_name));
+ PRIMARY KEY(ctrlr_vtn_name, controller_name, domain_id));
CREATE TABLE im_vbr_tbl (
vtn_name varchar(32) default ' ',
valid_host_addr smallint default 0,
valid_host_addr_mask smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_controller_name smallint default 3,
- cs_domain_id smallint default 3,
- cs_vbr_description smallint default 3,
- cs_host_addr smallint default 3,
- cs_host_addr_mask smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_controller_name smallint default 1,
+ cs_domain_id smallint default 1,
+ cs_vbr_description smallint default 1,
+ cs_host_addr smallint default 1,
+ cs_host_addr_mask smallint default 1,
flags smallint default 0,
PRIMARY KEY(vtn_name, vbridge_name));
domain_id varchar(32) default ' ',
flags smallint default 0,
valid_vlanid smallint default 0,
- cs_rowstatus smallint default 3,
- cs_vlanid smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_vlanid smallint default 1,
PRIMARY KEY(vtn_name, vbridge_name, logical_port_id, logical_port_id_valid));
CREATE TABLE im_vbr_if_tbl (
valid_logical_port_id smallint default 0,
valid_vlanid smallint default 0,
valid_tagged smallint default 0,
+ valid_vex_name smallint default 0,
+ valid_vex_if_name smallint default 0,
+ valid_vex_link_name smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_admin_status smallint default 3,
- cs_description smallint default 3,
- cs_portmap smallint default 3,
- cs_logical_port_id smallint default 3,
- cs_vlanid smallint default 3,
- cs_tagged smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_admin_status smallint default 1,
+ cs_description smallint default 1,
+ cs_portmap smallint default 1,
+ cs_logical_port_id smallint default 1,
+ cs_vlanid smallint default 1,
+ cs_tagged smallint default 1,
PRIMARY KEY(vtn_name, vbridge_name, if_name));
CREATE TABLE im_vrt_tbl (
valid_vrt_description smallint default 0,
valid_dhcprelay_admin_status smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_controller_name smallint default 3,
- cs_domain_id smallint default 3,
- cs_vrt_description smallint default 3,
- cs_dhcprelay_admin_status smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_controller_name smallint default 1,
+ cs_domain_id smallint default 1,
+ cs_vrt_description smallint default 1,
+ cs_dhcprelay_admin_status smallint default 1,
PRIMARY KEY(vtn_name, vrouter_name));
CREATE TABLE im_vrt_if_tbl (
valid_mac_addr smallint default 0,
valid_admin_status smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_ip_addr smallint default 3,
- cs_mask smallint default 3,
- cs_mac_addr smallint default 3,
- cs_admin_status smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_ip_addr smallint default 1,
+ cs_mask smallint default 1,
+ cs_mac_addr smallint default 1,
+ cs_admin_status smallint default 1,
PRIMARY KEY(vtn_name, vrouter_name, if_name));
CREATE TABLE im_vnode_rename_tbl (
domain_id varchar(32) default ' ',
unc_vtn_name varchar(32) default ' ',
unc_vnode_name varchar(32) default ' ',
- PRIMARY KEY(ctrlr_vtn_name, ctrlr_vnode_name, controller_name, domain_id),
- UNIQUE(unc_vtn_name, unc_vnode_name));
+ PRIMARY KEY(ctrlr_vtn_name, ctrlr_vnode_name, controller_name, domain_id));
CREATE TABLE im_vlink_tbl (
vtn_name varchar(32) default ' ',
controller2_name varchar(32) default ' ',
domain1_id varchar(32) default ' ',
domain2_id varchar(32) default ' ',
- flags smallint default 0,
+ key_flags smallint default 0,
+ val_flags smallint default 0,
valid_admin_status smallint default 0,
valid_vnode1_name smallint default 0,
valid_vnode1_ifname smallint default 0,
valid_vlanid smallint default 0,
valid_description smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_admin_status smallint default 3,
- cs_vnode1_name smallint default 3,
- cs_vnode1_ifname smallint default 3,
- cs_vnode2_name smallint default 3,
- cs_vnode2_ifname smallint default 3,
- cs_boundary_name smallint default 3,
- cs_vlanid smallint default 3,
- cs_description smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_admin_status smallint default 1,
+ cs_vnode1_name smallint default 1,
+ cs_vnode1_ifname smallint default 1,
+ cs_vnode2_name smallint default 1,
+ cs_vnode2_ifname smallint default 1,
+ cs_boundary_name smallint default 1,
+ cs_vlanid smallint default 1,
+ cs_description smallint default 1,
PRIMARY KEY(vtn_name, vlink_name));
CREATE TABLE im_vlink_rename_tbl (
domain_id varchar(32) default ' ',
unc_vtn_name varchar(32) default ' ',
unc_vlink_name varchar(32) default ' ',
- PRIMARY KEY(ctrlr_vtn_name, ctrlr_vlink_name, controller_name, domain_id),
- UNIQUE(unc_vtn_name, unc_vlink_name));
+ PRIMARY KEY(ctrlr_vtn_name, ctrlr_vlink_name, controller_name, domain_id));
CREATE TABLE im_static_ip_route_tbl (
vtn_name varchar(32) default ' ',
vrouter_name varchar(32) default ' ',
dst_ip_addr bytea default '\000\000\000\000',
mask smallint default 0,
- nwm_name varchar(32) default ' ',
next_hop_addr bytea default '\000\000\000\000',
+ nwm_name varchar(32) default ' ',
metric integer default 0,
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
valid_metric smallint default 0,
- cs_rowstatus smallint default 3,
- cs_metric smallint default 3,
- PRIMARY KEY(vtn_name, vrouter_name, dst_ip_addr, mask, nwm_name, next_hop_addr));
+ cs_rowstatus smallint default 1,
+ cs_metric smallint default 1,
+ PRIMARY KEY(vtn_name, vrouter_name, dst_ip_addr, mask, next_hop_addr, nwm_name));
CREATE TABLE im_dhcp_relay_server_tbl (
vtn_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
+ cs_rowstatus smallint default 1,
PRIMARY KEY(vtn_name, vrouter_name, server_ip_addr));
CREATE TABLE im_dhcp_relay_if_tbl (
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
+ cs_rowstatus smallint default 1,
PRIMARY KEY(vtn_name, vrouter_name, if_name));
CREATE TABLE im_vbr_nwmon_grp_tbl (
flags smallint default 0,
valid_admin_status smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_admin_status smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_admin_status smallint default 1,
PRIMARY KEY(vtn_name, vbridge_name, nwm_name));
CREATE TABLE im_vbr_nwmon_host_tbl (
valid_failure_count smallint default 0,
valid_recovery_count smallint default 0,
valid_wait_time smallint default 0,
- cs_rowstatus smallint default 3,
- cs_health_interval smallint default 3,
- cs_recovery_interval smallint default 3,
- cs_failure_count smallint default 3,
- cs_recovery_count smallint default 3,
- cs_wait_time smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_health_interval smallint default 1,
+ cs_recovery_interval smallint default 1,
+ cs_failure_count smallint default 1,
+ cs_recovery_count smallint default 1,
+ cs_wait_time smallint default 1,
PRIMARY KEY(vtn_name, vbridge_name, nwm_name, host_address));
CREATE TABLE im_vunknown_tbl (
valid_description smallint default 0,
valid_type smallint default 0,
valid_domain_id smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_type smallint default 3,
- cs_domain_id smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_type smallint default 1,
+ cs_domain_id smallint default 1,
PRIMARY KEY(vtn_name, vunknown_name));
CREATE TABLE im_vunknown_if_tbl (
flags smallint default 0,
valid_description smallint default 0,
valid_admin_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_admin_status smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_admin_status smallint default 1,
PRIMARY KEY(vtn_name, vunknown_name, if_name));
CREATE TABLE im_vtep_tbl (
valid_controller_name smallint default 0,
valid_domain_id smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_controller_name smallint default 3,
- cs_domain_id smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_controller_name smallint default 1,
+ cs_domain_id smallint default 1,
PRIMARY KEY(vtn_name, vtep_name));
CREATE TABLE im_vtep_if_tbl (
logical_port_id varchar(320) default ' ',
vlanid integer default 0,
tagged smallint default 0,
- vex_name varchar(32) default ' ',
- vex_if_name varchar(32) default ' ',
- vex_link_name varchar(32) default ' ',
oper_status smallint default 0,
down_count bigint default 0,
controller_name varchar(32) default ' ',
valid_vlanid smallint default 0,
valid_tagged smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_admin_status smallint default 3,
- cs_portmap smallint default 3,
- cs_logical_port_id smallint default 3,
- cs_vlanid smallint default 3,
- cs_tagged smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_admin_status smallint default 1,
+ cs_portmap smallint default 1,
+ cs_logical_port_id smallint default 1,
+ cs_vlanid smallint default 1,
+ cs_tagged smallint default 1,
PRIMARY KEY(vtn_name, vtep_name, if_name));
CREATE TABLE im_vtep_grp_tbl (
controller_name varchar(32) default ' ',
description varchar(128) default ' ',
flags smallint default 0,
- valid_controller_name varchar(32) default 0,
- valid_description varchar(32) default 0,
- cs_rowstatus smallint default 3,
- cs_controller_name varchar(32) default 3,
- cs_description varchar(32) default 3,
+ valid_controller_name smallint default 0,
+ valid_description smallint default 0,
+ cs_rowstatus smallint default 1,
+ cs_controller_name smallint default 1,
+ cs_description smallint default 1,
PRIMARY KEY(vtn_name, vtepgrp_name));
CREATE TABLE im_vtep_grp_mem_tbl (
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
+ cs_rowstatus smallint default 1,
PRIMARY KEY(vtn_name, vtepgrp_name, vtepgrp_member_name));
CREATE TABLE im_vtunnel_tbl (
domain_id varchar(32) default ' ',
underlay_vtn_name varchar(32) default ' ',
vtepgrp_name varchar(32) default ' ',
- label integer default 0,
+ label bigint default 0,
oper_status smallint default 0,
down_count bigint default 0,
flags smallint default 0,
valid_vtepgrp_name smallint default 0,
valid_label smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_controller_name smallint default 3,
- cs_domain_id smallint default 3,
- cs_underlay_vtn_name smallint default 3,
- cs_vtepgrp_name smallint default 3,
- cs_label smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_controller_name smallint default 1,
+ cs_domain_id smallint default 1,
+ cs_underlay_vtn_name smallint default 1,
+ cs_vtepgrp_name smallint default 1,
+ cs_label smallint default 1,
PRIMARY KEY(vtn_name, vtunnel_name));
CREATE TABLE im_vtunnel_if_tbl (
logical_port_id varchar(320) default ' ',
vlanid integer default 0,
tagged smallint default 0,
- vex_name varchar(32) default ' ',
- vex_if_name varchar(32) default ' ',
- vex_link_name varchar(32) default ' ',
oper_status smallint default 0,
down_count bigint default 0,
controller_name varchar(32) default ' ',
valid_vlanid smallint default 0,
valid_tagged smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_admin_status smallint default 3,
- cs_portmap smallint default 3,
- cs_logical_port_id smallint default 3,
- cs_vlanid smallint default 3,
- cs_tagged smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_admin_status smallint default 1,
+ cs_portmap smallint default 1,
+ cs_logical_port_id smallint default 1,
+ cs_vlanid smallint default 1,
+ cs_tagged smallint default 1,
PRIMARY KEY(vtn_name, vtunnel_name, if_name));
CREATE TABLE im_flowlist_tbl (
ip_type smallint default 0,
flags smallint default 0,
valid_ip_type smallint default 0,
- cs_rowstatus smallint default 3,
- cs_ip_type smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_ip_type smallint default 1,
PRIMARY KEY(flowlist_name));
CREATE TABLE im_flowlist_ctrlr_tbl (
ref_count bigint default 0,
flags smallint default 0,
valid_ip_type smallint default 0,
- cs_rowstatus smallint default 3,
- cs_ip_type smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_ip_type smallint default 1,
PRIMARY KEY(flowlist_name, ctrlr_name));
CREATE TABLE im_flowlist_rename_tbl (
ctrlr_flowlist_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
unc_flowlist_name varchar(33) default ' ',
- PRIMARY KEY(ctrlr_flowlist_name, ctrlr_name),
- UNIQUE(unc_flowlist_name));
+ PRIMARY KEY(ctrlr_flowlist_name, ctrlr_name));
CREATE TABLE im_flowlist_entry_tbl (
flowlist_name varchar(33) default ' ',
valid_icmp_code smallint default 0,
valid_icmpv6_type smallint default 0,
valid_icmpv6_code smallint default 0,
- cs_rowstatus smallint default 3,
- cs_mac_dst smallint default 3,
- cs_mac_src smallint default 3,
- cs_mac_eth_type smallint default 3,
- cs_dst_ip smallint default 3,
- cs_dst_ip_prefix smallint default 3,
- cs_src_ip smallint default 3,
- cs_src_ip_prefix smallint default 3,
- cs_vlan_priority smallint default 3,
- cs_dst_ipv6 smallint default 3,
- cs_dst_ipv6_prefix smallint default 3,
- cs_src_ipv6 smallint default 3,
- cs_src_ipv6_prefix smallint default 3,
- cs_ip_protocol smallint default 3,
- cs_ip_dscp smallint default 3,
- cs_l4_dst_port smallint default 3,
- cs_l4_dst_port_endpt smallint default 3,
- cs_l4_src_port smallint default 3,
- cs_l4_src_port_endpt smallint default 3,
- cs_icmp_type smallint default 3,
- cs_icmp_code smallint default 3,
- cs_icmpv6_type smallint default 3,
- cs_icmpv6_code smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_mac_dst smallint default 1,
+ cs_mac_src smallint default 1,
+ cs_mac_eth_type smallint default 1,
+ cs_dst_ip smallint default 1,
+ cs_dst_ip_prefix smallint default 1,
+ cs_src_ip smallint default 1,
+ cs_src_ip_prefix smallint default 1,
+ cs_vlan_priority smallint default 1,
+ cs_dst_ipv6 smallint default 1,
+ cs_dst_ipv6_prefix smallint default 1,
+ cs_src_ipv6 smallint default 1,
+ cs_src_ipv6_prefix smallint default 1,
+ cs_ip_protocol smallint default 1,
+ cs_ip_dscp smallint default 1,
+ cs_l4_dst_port smallint default 1,
+ cs_l4_dst_port_endpt smallint default 1,
+ cs_l4_src_port smallint default 1,
+ cs_l4_src_port_endpt smallint default 1,
+ cs_icmp_type smallint default 1,
+ cs_icmp_code smallint default 1,
+ cs_icmpv6_type smallint default 1,
+ cs_icmpv6_code smallint default 1,
PRIMARY KEY(flowlist_name, sequence_num));
CREATE TABLE im_flowlist_entry_ctrlr_tbl (
valid_icmp_code smallint default 0,
valid_icmpv6_type smallint default 0,
valid_icmpv6_code smallint default 0,
- cs_rowstatus smallint default 3,
- cs_mac_dst smallint default 3,
- cs_mac_src smallint default 3,
- cs_mac_eth_type smallint default 3,
- cs_dst_ip smallint default 3,
- cs_dst_ip_prefix smallint default 3,
- cs_src_ip smallint default 3,
- cs_src_ip_prefix smallint default 3,
- cs_vlan_priority smallint default 3,
- cs_dst_ipv6 smallint default 3,
- cs_dst_ipv6_prefix smallint default 3,
- cs_src_ipv6 smallint default 3,
- cs_src_ipv6_prefix smallint default 3,
- cs_ip_protocol smallint default 3,
- cs_ip_dscp smallint default 3,
- cs_l4_dst_port smallint default 3,
- cs_l4_dst_port_endpt smallint default 3,
- cs_l4_src_port smallint default 3,
- cs_l4_src_port_endpt smallint default 3,
- cs_icmp_type smallint default 3,
- cs_icmp_code smallint default 3,
- cs_icmpv6_type smallint default 3,
- cs_icmpv6_code smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_mac_dst smallint default 1,
+ cs_mac_src smallint default 1,
+ cs_mac_eth_type smallint default 1,
+ cs_dst_ip smallint default 1,
+ cs_dst_ip_prefix smallint default 1,
+ cs_src_ip smallint default 1,
+ cs_src_ip_prefix smallint default 1,
+ cs_vlan_priority smallint default 1,
+ cs_dst_ipv6 smallint default 1,
+ cs_dst_ipv6_prefix smallint default 1,
+ cs_src_ipv6 smallint default 1,
+ cs_src_ipv6_prefix smallint default 1,
+ cs_ip_protocol smallint default 1,
+ cs_ip_dscp smallint default 1,
+ cs_l4_dst_port smallint default 1,
+ cs_l4_dst_port_endpt smallint default 1,
+ cs_l4_src_port smallint default 1,
+ cs_l4_src_port_endpt smallint default 1,
+ cs_icmp_type smallint default 1,
+ cs_icmp_code smallint default 1,
+ cs_icmpv6_type smallint default 1,
+ cs_icmpv6_code smallint default 1,
PRIMARY KEY(flowlist_name, sequence_num, ctrlr_name));
CREATE TABLE im_policingprofile_tbl (
policingprofile_name varchar(33) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
+ cs_rowstatus smallint default 1,
PRIMARY KEY(policingprofile_name));
CREATE TABLE im_policingprofile_ctrlr_tbl (
ctrlr_name varchar(32) default ' ',
ref_count bigint default 0,
flags smallint default 0,
- cs_rowstatus smallint default 3,
+ cs_rowstatus smallint default 1,
PRIMARY KEY(policingprofile_name, ctrlr_name));
CREATE TABLE im_policingprofile_rename_tbl (
ctrlr_policingprofile_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
unc_policingprofile_name varchar(33) default ' ',
- PRIMARY KEY(ctrlr_policingprofile_name, ctrlr_name),
- UNIQUE(unc_policingprofile_name));
+ PRIMARY KEY(ctrlr_policingprofile_name, ctrlr_name));
CREATE TABLE im_policingprofile_entry_tbl (
policingprofile_name varchar(33) default ' ',
valid_red_priority smallint default 0,
valid_red_dscp smallint default 0,
valid_red_drop smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist smallint default 3,
- cs_rate smallint default 3,
- cs_cir smallint default 3,
- cs_cbs smallint default 3,
- cs_pir smallint default 3,
- cs_pbs smallint default 3,
- cs_green_action smallint default 3,
- cs_green_priority smallint default 3,
- cs_green_dscp smallint default 3,
- cs_green_drop smallint default 3,
- cs_yellow_action smallint default 3,
- cs_yellow_priority smallint default 3,
- cs_yellow_dscp smallint default 3,
- cs_yellow_drop smallint default 3,
- cs_red_action smallint default 3,
- cs_red_priority smallint default 3,
- cs_red_dscp smallint default 3,
- cs_red_drop smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_flowlist smallint default 1,
+ cs_rate smallint default 1,
+ cs_cir smallint default 1,
+ cs_cbs smallint default 1,
+ cs_pir smallint default 1,
+ cs_pbs smallint default 1,
+ cs_green_action smallint default 1,
+ cs_green_priority smallint default 1,
+ cs_green_dscp smallint default 1,
+ cs_green_drop smallint default 1,
+ cs_yellow_action smallint default 1,
+ cs_yellow_priority smallint default 1,
+ cs_yellow_dscp smallint default 1,
+ cs_yellow_drop smallint default 1,
+ cs_red_action smallint default 1,
+ cs_red_priority smallint default 1,
+ cs_red_dscp smallint default 1,
+ cs_red_drop smallint default 1,
PRIMARY KEY(policingprofile_name, sequence_num));
CREATE TABLE im_policingprofile_entry_ctrlr_tbl (
valid_red_priority smallint default 0,
valid_red_dscp smallint default 0,
valid_red_drop smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist smallint default 3,
- cs_rate smallint default 3,
- cs_cir smallint default 3,
- cs_cbs smallint default 3,
- cs_pir smallint default 3,
- cs_pbs smallint default 3,
- cs_green_action smallint default 3,
- cs_green_priority smallint default 3,
- cs_green_dscp smallint default 3,
- cs_green_drop smallint default 3,
- cs_yellow_action smallint default 3,
- cs_yellow_priority smallint default 3,
- cs_yellow_dscp smallint default 3,
- cs_yellow_drop smallint default 3,
- cs_red_action smallint default 3,
- cs_red_priority smallint default 3,
- cs_red_dscp smallint default 3,
- cs_red_drop smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_flowlist smallint default 1,
+ cs_rate smallint default 1,
+ cs_cir smallint default 1,
+ cs_cbs smallint default 1,
+ cs_pir smallint default 1,
+ cs_pbs smallint default 1,
+ cs_green_action smallint default 1,
+ cs_green_priority smallint default 1,
+ cs_green_dscp smallint default 1,
+ cs_green_drop smallint default 1,
+ cs_yellow_action smallint default 1,
+ cs_yellow_priority smallint default 1,
+ cs_yellow_dscp smallint default 1,
+ cs_yellow_drop smallint default 1,
+ cs_red_action smallint default 1,
+ cs_red_priority smallint default 1,
+ cs_red_dscp smallint default 1,
+ cs_red_drop smallint default 1,
PRIMARY KEY(policingprofile_name, sequence_num, ctrlr_name));
CREATE TABLE im_vtn_flowfilter_tbl (
vtn_name varchar(32) default ' ',
direction smallint default 0,
flags smallint default 0,
- cs_rowstatus smallint default 3,
+ cs_rowstatus smallint default 1,
PRIMARY KEY(vtn_name, direction));
CREATE TABLE im_vtn_flowfilter_ctrlr_tbl (
ctrlr_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
+ cs_rowstatus smallint default 1,
PRIMARY KEY(vtn_name, direction, ctrlr_name, domain_id));
CREATE TABLE im_vtn_flowfilter_entry_tbl (
valid_nwn_name smallint default 0,
valid_dscp smallint default 0,
valid_priority smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist_name smallint default 3,
- cs_action smallint default 3,
- cs_nwn_name smallint default 3,
- cs_dscp smallint default 3,
- cs_priority smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_flowlist_name smallint default 1,
+ cs_action smallint default 1,
+ cs_nwn_name smallint default 1,
+ cs_dscp smallint default 1,
+ cs_priority smallint default 1,
PRIMARY KEY(vtn_name, direction, sequence_num));
CREATE TABLE im_vtn_flowfilter_entry_ctrlr_tbl (
valid_nwn_name smallint default 0,
valid_dscp smallint default 0,
valid_priority smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist_name smallint default 3,
- cs_action smallint default 3,
- cs_nwn_name smallint default 3,
- cs_dscp smallint default 3,
- cs_priority smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_flowlist_name smallint default 1,
+ cs_action smallint default 1,
+ cs_nwn_name smallint default 1,
+ cs_dscp smallint default 1,
+ cs_priority smallint default 1,
PRIMARY KEY(vtn_name, direction, sequence_num, ctrlr_name, domain_id));
CREATE TABLE im_vbr_flowfilter_tbl (
ctrlr_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
+ cs_rowstatus smallint default 1,
PRIMARY KEY(vtn_name, vbr_name, direction));
CREATE TABLE im_vbr_flowfilter_entry_tbl (
valid_nwn_name smallint default 0,
valid_dscp smallint default 0,
valid_priority smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist_name smallint default 3,
- cs_action smallint default 3,
- cs_redirect_node smallint default 3,
- cs_redirect_port smallint default 3,
- cs_modify_dst_mac smallint default 3,
- cs_modify_src_mac smallint default 3,
- cs_nwm_name smallint default 3,
- cs_dscp smallint default 3,
- cs_priority smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_flowlist_name smallint default 1,
+ cs_action smallint default 1,
+ cs_redirect_node smallint default 1,
+ cs_redirect_port smallint default 1,
+ cs_modify_dst_mac smallint default 1,
+ cs_modify_src_mac smallint default 1,
+ cs_nwm_name smallint default 1,
+ cs_dscp smallint default 1,
+ cs_priority smallint default 1,
PRIMARY KEY(vtn_name, vbr_name, direction, sequence_num));
CREATE TABLE im_vbr_if_flowfilter_tbl (
ctrlr_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
+ cs_rowstatus smallint default 1,
PRIMARY KEY(vtn_name, vbr_name, vbr_if_name, direction));
CREATE TABLE im_vbr_if_flowfilter_entry_tbl (
valid_nwn_name smallint default 0,
valid_dscp smallint default 0,
valid_priority smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist_name smallint default 3,
- cs_action smallint default 3,
- cs_redirect_node smallint default 3,
- cs_redirect_port smallint default 3,
- cs_modify_dst_mac smallint default 3,
- cs_modify_src_mac smallint default 3,
- cs_nwm_name smallint default 3,
- cs_dscp smallint default 3,
- cs_priority smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_flowlist_name smallint default 1,
+ cs_action smallint default 1,
+ cs_redirect_node smallint default 1,
+ cs_redirect_port smallint default 1,
+ cs_modify_dst_mac smallint default 1,
+ cs_modify_src_mac smallint default 1,
+ cs_nwm_name smallint default 1,
+ cs_dscp smallint default 1,
+ cs_priority smallint default 1,
PRIMARY KEY(vtn_name, vbr_name, vbr_if_name, direction, sequence_num));
CREATE TABLE im_vrt_if_flowfilter_tbl (
ctrlr_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
+ cs_rowstatus smallint default 1,
PRIMARY KEY(vtn_name, vrt_name, vrt_if_name, direction));
CREATE TABLE im_vrt_if_flowfilter_entry_tbl (
valid_nwn_name smallint default 0,
valid_dscp smallint default 0,
valid_priority smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist_name smallint default 3,
- cs_action smallint default 3,
- cs_redirect_node smallint default 3,
- cs_redirect_port smallint default 3,
- cs_modify_dst_mac smallint default 3,
- cs_modify_src_mac smallint default 3,
- cs_nwm_name smallint default 3,
- cs_dscp smallint default 3,
- cs_priority smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_flowlist_name smallint default 1,
+ cs_action smallint default 1,
+ cs_redirect_node smallint default 1,
+ cs_redirect_port smallint default 1,
+ cs_modify_dst_mac smallint default 1,
+ cs_modify_src_mac smallint default 1,
+ cs_nwm_name smallint default 1,
+ cs_dscp smallint default 1,
+ cs_priority smallint default 1,
PRIMARY KEY(vtn_name, vrt_name, vrt_if_name, direction, sequence_num));
CREATE TABLE im_vtn_policingmap_tbl (
policername varchar(33) default ' ',
flags smallint default 0,
valid_policername smallint default 0,
- cs_rowstatus smallint default 3,
- cs_policername smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_policername smallint default 1,
PRIMARY KEY(vtn_name));
CREATE TABLE im_vtn_policingmap_ctrlr_tbl (
policername varchar(33) default ' ',
flags smallint default 0,
valid_policername smallint default 0,
- cs_rowstatus smallint default 3,
- cs_policername smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_policername smallint default 1,
PRIMARY KEY(vtn_name, ctrlr_name, domain_id));
CREATE TABLE im_vbr_policingmap_tbl (
policername varchar(33) default ' ',
flags smallint default 0,
valid_policername smallint default 0,
- cs_rowstatus smallint default 3,
- cs_policername smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_policername smallint default 1,
PRIMARY KEY(vtn_name, vbr_name));
CREATE TABLE im_vbr_if_policingmap_tbl (
policername varchar(33) default ' ',
flags smallint default 0,
valid_policername smallint default 0,
- cs_rowstatus smallint default 3,
- cs_policername smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_policername smallint default 1,
PRIMARY KEY(vtn_name, vbr_name, vbr_if_name));
CREATE TABLE au_vtn_tbl (
valid_alarm_status smallint default 0,
valid_creation_time smallint default 0,
valid_last_updated_time smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
PRIMARY KEY(vtn_name));
CREATE TABLE au_vtn_ctrlr_tbl (
flags smallint default 0,
valid_oper_status smallint default 0,
valid_alarm_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
PRIMARY KEY(vtn_name, controller_name, domain_id));
CREATE TABLE au_vtn_rename_tbl (
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
unc_vtn_name varchar(32) default ' ',
- PRIMARY KEY(ctrlr_vtn_name, controller_name, domain_id),
- UNIQUE(unc_vtn_name));
+ PRIMARY KEY(ctrlr_vtn_name, controller_name, domain_id));
CREATE TABLE au_vbr_tbl (
vtn_name varchar(32) default ' ',
valid_host_addr smallint default 0,
valid_host_addr_mask smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_controller_name smallint default 3,
- cs_domain_id smallint default 3,
- cs_vbr_description smallint default 3,
- cs_host_addr smallint default 3,
- cs_host_addr_mask smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_controller_name smallint default 1,
+ cs_domain_id smallint default 1,
+ cs_vbr_description smallint default 1,
+ cs_host_addr smallint default 1,
+ cs_host_addr_mask smallint default 1,
flags smallint default 0,
PRIMARY KEY(vtn_name, vbridge_name));
domain_id varchar(32) default ' ',
flags smallint default 0,
valid_vlanid smallint default 0,
- cs_rowstatus smallint default 3,
- cs_vlanid smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_vlanid smallint default 1,
PRIMARY KEY(vtn_name, vbridge_name, logical_port_id, logical_port_id_valid));
CREATE TABLE au_vbr_if_tbl (
valid_logical_port_id smallint default 0,
valid_vlanid smallint default 0,
valid_tagged smallint default 0,
+ valid_vex_name smallint default 0,
+ valid_vex_if_name smallint default 0,
+ valid_vex_link_name smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_admin_status smallint default 3,
- cs_description smallint default 3,
- cs_portmap smallint default 3,
- cs_logical_port_id smallint default 3,
- cs_vlanid smallint default 3,
- cs_tagged smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_admin_status smallint default 1,
+ cs_description smallint default 1,
+ cs_portmap smallint default 1,
+ cs_logical_port_id smallint default 1,
+ cs_vlanid smallint default 1,
+ cs_tagged smallint default 1,
PRIMARY KEY(vtn_name, vbridge_name, if_name));
CREATE TABLE au_vrt_tbl (
valid_vrt_description smallint default 0,
valid_dhcprelay_admin_status smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_controller_name smallint default 3,
- cs_domain_id smallint default 3,
- cs_vrt_description smallint default 3,
- cs_dhcprelay_admin_status smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_controller_name smallint default 1,
+ cs_domain_id smallint default 1,
+ cs_vrt_description smallint default 1,
+ cs_dhcprelay_admin_status smallint default 1,
PRIMARY KEY(vtn_name, vrouter_name));
CREATE TABLE au_vrt_if_tbl (
valid_mac_addr smallint default 0,
valid_admin_status smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_ip_addr smallint default 3,
- cs_mask smallint default 3,
- cs_mac_addr smallint default 3,
- cs_admin_status smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_ip_addr smallint default 1,
+ cs_mask smallint default 1,
+ cs_mac_addr smallint default 1,
+ cs_admin_status smallint default 1,
PRIMARY KEY(vtn_name, vrouter_name, if_name));
CREATE TABLE au_vnode_rename_tbl (
domain_id varchar(32) default ' ',
unc_vtn_name varchar(32) default ' ',
unc_vnode_name varchar(32) default ' ',
- PRIMARY KEY(ctrlr_vtn_name, ctrlr_vnode_name, controller_name, domain_id),
- UNIQUE(unc_vtn_name, unc_vnode_name));
+ PRIMARY KEY(ctrlr_vtn_name, ctrlr_vnode_name, controller_name, domain_id));
CREATE TABLE au_vlink_tbl (
vtn_name varchar(32) default ' ',
controller2_name varchar(32) default ' ',
domain1_id varchar(32) default ' ',
domain2_id varchar(32) default ' ',
- flags smallint default 0,
+ key_flags smallint default 0,
+ val_flags smallint default 0,
valid_admin_status smallint default 0,
valid_vnode1_name smallint default 0,
valid_vnode1_ifname smallint default 0,
valid_vlanid smallint default 0,
valid_description smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_admin_status smallint default 3,
- cs_vnode1_name smallint default 3,
- cs_vnode1_ifname smallint default 3,
- cs_vnode2_name smallint default 3,
- cs_vnode2_ifname smallint default 3,
- cs_boundary_name smallint default 3,
- cs_vlanid smallint default 3,
- cs_description smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_admin_status smallint default 1,
+ cs_vnode1_name smallint default 1,
+ cs_vnode1_ifname smallint default 1,
+ cs_vnode2_name smallint default 1,
+ cs_vnode2_ifname smallint default 1,
+ cs_boundary_name smallint default 1,
+ cs_vlanid smallint default 1,
+ cs_description smallint default 1,
PRIMARY KEY(vtn_name, vlink_name));
CREATE TABLE au_vlink_rename_tbl (
domain_id varchar(32) default ' ',
unc_vtn_name varchar(32) default ' ',
unc_vlink_name varchar(32) default ' ',
- PRIMARY KEY(ctrlr_vtn_name, ctrlr_vlink_name, controller_name, domain_id),
- UNIQUE(unc_vtn_name, unc_vlink_name));
+ PRIMARY KEY(ctrlr_vtn_name, ctrlr_vlink_name, controller_name, domain_id));
CREATE TABLE au_static_ip_route_tbl (
vtn_name varchar(32) default ' ',
vrouter_name varchar(32) default ' ',
dst_ip_addr bytea default '\000\000\000\000',
mask smallint default 0,
- nwm_name varchar(32) default ' ',
next_hop_addr bytea default '\000\000\000\000',
+ nwm_name varchar(32) default ' ',
metric integer default 0,
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
valid_metric smallint default 0,
- cs_rowstatus smallint default 3,
- cs_metric smallint default 3,
- PRIMARY KEY(vtn_name, vrouter_name, dst_ip_addr, mask, nwm_name, next_hop_addr));
+ cs_rowstatus smallint default 1,
+ cs_metric smallint default 1,
+ PRIMARY KEY(vtn_name, vrouter_name, dst_ip_addr, mask, next_hop_addr, nwm_name));
CREATE TABLE au_dhcp_relay_server_tbl (
vtn_name varchar(32) default ' ',
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
+ cs_rowstatus smallint default 1,
PRIMARY KEY(vtn_name, vrouter_name, server_ip_addr));
CREATE TABLE au_dhcp_relay_if_tbl (
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
+ cs_rowstatus smallint default 1,
PRIMARY KEY(vtn_name, vrouter_name, if_name));
CREATE TABLE au_vbr_nwmon_grp_tbl (
flags smallint default 0,
valid_admin_status smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_admin_status smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_admin_status smallint default 1,
PRIMARY KEY(vtn_name, vbridge_name, nwm_name));
CREATE TABLE au_vbr_nwmon_host_tbl (
valid_failure_count smallint default 0,
valid_recovery_count smallint default 0,
valid_wait_time smallint default 0,
- cs_rowstatus smallint default 3,
- cs_health_interval smallint default 3,
- cs_recovery_interval smallint default 3,
- cs_failure_count smallint default 3,
- cs_recovery_count smallint default 3,
- cs_wait_time smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_health_interval smallint default 1,
+ cs_recovery_interval smallint default 1,
+ cs_failure_count smallint default 1,
+ cs_recovery_count smallint default 1,
+ cs_wait_time smallint default 1,
PRIMARY KEY(vtn_name, vbridge_name, nwm_name, host_address));
CREATE TABLE au_vunknown_tbl (
valid_description smallint default 0,
valid_type smallint default 0,
valid_domain_id smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_type smallint default 3,
- cs_domain_id smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_type smallint default 1,
+ cs_domain_id smallint default 1,
PRIMARY KEY(vtn_name, vunknown_name));
CREATE TABLE au_vunknown_if_tbl (
flags smallint default 0,
valid_description smallint default 0,
valid_admin_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_admin_status smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_admin_status smallint default 1,
PRIMARY KEY(vtn_name, vunknown_name, if_name));
CREATE TABLE au_vtep_tbl (
valid_controller_name smallint default 0,
valid_domain_id smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_controller_name smallint default 3,
- cs_domain_id smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_controller_name smallint default 1,
+ cs_domain_id smallint default 1,
PRIMARY KEY(vtn_name, vtep_name));
CREATE TABLE au_vtep_if_tbl (
logical_port_id varchar(320) default ' ',
vlanid integer default 0,
tagged smallint default 0,
- vex_name varchar(32) default ' ',
- vex_if_name varchar(32) default ' ',
- vex_link_name varchar(32) default ' ',
oper_status smallint default 0,
down_count bigint default 0,
controller_name varchar(32) default ' ',
valid_vlanid smallint default 0,
valid_tagged smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_admin_status smallint default 3,
- cs_portmap smallint default 3,
- cs_logical_port_id smallint default 3,
- cs_vlanid smallint default 3,
- cs_tagged smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_admin_status smallint default 1,
+ cs_portmap smallint default 1,
+ cs_logical_port_id smallint default 1,
+ cs_vlanid smallint default 1,
+ cs_tagged smallint default 1,
PRIMARY KEY(vtn_name, vtep_name, if_name));
CREATE TABLE au_vtep_grp_tbl (
controller_name varchar(32) default ' ',
description varchar(128) default ' ',
flags smallint default 0,
- valid_controller_name varchar(32) default 0,
- valid_description varchar(32) default 0,
- cs_rowstatus smallint default 3,
- cs_controller_name varchar(32) default 3,
- cs_description varchar(32) default 3,
+ valid_controller_name smallint default 0,
+ valid_description smallint default 0,
+ cs_rowstatus smallint default 1,
+ cs_controller_name smallint default 1,
+ cs_description smallint default 1,
PRIMARY KEY(vtn_name, vtepgrp_name));
CREATE TABLE au_vtep_grp_mem_tbl (
controller_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
+ cs_rowstatus smallint default 1,
PRIMARY KEY(vtn_name, vtepgrp_name, vtepgrp_member_name));
CREATE TABLE au_vtunnel_tbl (
domain_id varchar(32) default ' ',
underlay_vtn_name varchar(32) default ' ',
vtepgrp_name varchar(32) default ' ',
- label integer default 0,
+ label bigint default 0,
oper_status smallint default 0,
down_count bigint default 0,
flags smallint default 0,
valid_vtepgrp_name smallint default 0,
valid_label smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_controller_name smallint default 3,
- cs_domain_id smallint default 3,
- cs_underlay_vtn_name smallint default 3,
- cs_vtepgrp_name smallint default 3,
- cs_label smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_controller_name smallint default 1,
+ cs_domain_id smallint default 1,
+ cs_underlay_vtn_name smallint default 1,
+ cs_vtepgrp_name smallint default 1,
+ cs_label smallint default 1,
PRIMARY KEY(vtn_name, vtunnel_name));
CREATE TABLE au_vtunnel_if_tbl (
logical_port_id varchar(320) default ' ',
vlanid integer default 0,
tagged smallint default 0,
- vex_name varchar(32) default ' ',
- vex_if_name varchar(32) default ' ',
- vex_link_name varchar(32) default ' ',
oper_status smallint default 0,
down_count bigint default 0,
controller_name varchar(32) default ' ',
valid_vlanid smallint default 0,
valid_tagged smallint default 0,
valid_oper_status smallint default 0,
- cs_rowstatus smallint default 3,
- cs_description smallint default 3,
- cs_admin_status smallint default 3,
- cs_portmap smallint default 3,
- cs_logical_port_id smallint default 3,
- cs_vlanid smallint default 3,
- cs_tagged smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_description smallint default 1,
+ cs_admin_status smallint default 1,
+ cs_portmap smallint default 1,
+ cs_logical_port_id smallint default 1,
+ cs_vlanid smallint default 1,
+ cs_tagged smallint default 1,
PRIMARY KEY(vtn_name, vtunnel_name, if_name));
CREATE TABLE au_flowlist_tbl (
ip_type smallint default 0,
flags smallint default 0,
valid_ip_type smallint default 0,
- cs_rowstatus smallint default 3,
- cs_ip_type smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_ip_type smallint default 1,
PRIMARY KEY(flowlist_name));
CREATE TABLE au_flowlist_ctrlr_tbl (
ref_count bigint default 0,
flags smallint default 0,
valid_ip_type smallint default 0,
- cs_rowstatus smallint default 3,
- cs_ip_type smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_ip_type smallint default 1,
PRIMARY KEY(flowlist_name, ctrlr_name));
CREATE TABLE au_flowlist_rename_tbl (
ctrlr_flowlist_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
unc_flowlist_name varchar(33) default ' ',
- PRIMARY KEY(ctrlr_flowlist_name, ctrlr_name),
- UNIQUE(unc_flowlist_name));
+ PRIMARY KEY(ctrlr_flowlist_name, ctrlr_name));
CREATE TABLE au_flowlist_entry_tbl (
flowlist_name varchar(33) default ' ',
valid_icmp_code smallint default 0,
valid_icmpv6_type smallint default 0,
valid_icmpv6_code smallint default 0,
- cs_rowstatus smallint default 3,
- cs_mac_dst smallint default 3,
- cs_mac_src smallint default 3,
- cs_mac_eth_type smallint default 3,
- cs_dst_ip smallint default 3,
- cs_dst_ip_prefix smallint default 3,
- cs_src_ip smallint default 3,
- cs_src_ip_prefix smallint default 3,
- cs_vlan_priority smallint default 3,
- cs_dst_ipv6 smallint default 3,
- cs_dst_ipv6_prefix smallint default 3,
- cs_src_ipv6 smallint default 3,
- cs_src_ipv6_prefix smallint default 3,
- cs_ip_protocol smallint default 3,
- cs_ip_dscp smallint default 3,
- cs_l4_dst_port smallint default 3,
- cs_l4_dst_port_endpt smallint default 3,
- cs_l4_src_port smallint default 3,
- cs_l4_src_port_endpt smallint default 3,
- cs_icmp_type smallint default 3,
- cs_icmp_code smallint default 3,
- cs_icmpv6_type smallint default 3,
- cs_icmpv6_code smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_mac_dst smallint default 1,
+ cs_mac_src smallint default 1,
+ cs_mac_eth_type smallint default 1,
+ cs_dst_ip smallint default 1,
+ cs_dst_ip_prefix smallint default 1,
+ cs_src_ip smallint default 1,
+ cs_src_ip_prefix smallint default 1,
+ cs_vlan_priority smallint default 1,
+ cs_dst_ipv6 smallint default 1,
+ cs_dst_ipv6_prefix smallint default 1,
+ cs_src_ipv6 smallint default 1,
+ cs_src_ipv6_prefix smallint default 1,
+ cs_ip_protocol smallint default 1,
+ cs_ip_dscp smallint default 1,
+ cs_l4_dst_port smallint default 1,
+ cs_l4_dst_port_endpt smallint default 1,
+ cs_l4_src_port smallint default 1,
+ cs_l4_src_port_endpt smallint default 1,
+ cs_icmp_type smallint default 1,
+ cs_icmp_code smallint default 1,
+ cs_icmpv6_type smallint default 1,
+ cs_icmpv6_code smallint default 1,
PRIMARY KEY(flowlist_name, sequence_num));
CREATE TABLE au_flowlist_entry_ctrlr_tbl (
valid_icmp_code smallint default 0,
valid_icmpv6_type smallint default 0,
valid_icmpv6_code smallint default 0,
- cs_rowstatus smallint default 3,
- cs_mac_dst smallint default 3,
- cs_mac_src smallint default 3,
- cs_mac_eth_type smallint default 3,
- cs_dst_ip smallint default 3,
- cs_dst_ip_prefix smallint default 3,
- cs_src_ip smallint default 3,
- cs_src_ip_prefix smallint default 3,
- cs_vlan_priority smallint default 3,
- cs_dst_ipv6 smallint default 3,
- cs_dst_ipv6_prefix smallint default 3,
- cs_src_ipv6 smallint default 3,
- cs_src_ipv6_prefix smallint default 3,
- cs_ip_protocol smallint default 3,
- cs_ip_dscp smallint default 3,
- cs_l4_dst_port smallint default 3,
- cs_l4_dst_port_endpt smallint default 3,
- cs_l4_src_port smallint default 3,
- cs_l4_src_port_endpt smallint default 3,
- cs_icmp_type smallint default 3,
- cs_icmp_code smallint default 3,
- cs_icmpv6_type smallint default 3,
- cs_icmpv6_code smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_mac_dst smallint default 1,
+ cs_mac_src smallint default 1,
+ cs_mac_eth_type smallint default 1,
+ cs_dst_ip smallint default 1,
+ cs_dst_ip_prefix smallint default 1,
+ cs_src_ip smallint default 1,
+ cs_src_ip_prefix smallint default 1,
+ cs_vlan_priority smallint default 1,
+ cs_dst_ipv6 smallint default 1,
+ cs_dst_ipv6_prefix smallint default 1,
+ cs_src_ipv6 smallint default 1,
+ cs_src_ipv6_prefix smallint default 1,
+ cs_ip_protocol smallint default 1,
+ cs_ip_dscp smallint default 1,
+ cs_l4_dst_port smallint default 1,
+ cs_l4_dst_port_endpt smallint default 1,
+ cs_l4_src_port smallint default 1,
+ cs_l4_src_port_endpt smallint default 1,
+ cs_icmp_type smallint default 1,
+ cs_icmp_code smallint default 1,
+ cs_icmpv6_type smallint default 1,
+ cs_icmpv6_code smallint default 1,
PRIMARY KEY(flowlist_name, sequence_num, ctrlr_name));
CREATE TABLE au_policingprofile_tbl (
policingprofile_name varchar(33) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
+ cs_rowstatus smallint default 1,
PRIMARY KEY(policingprofile_name));
CREATE TABLE au_policingprofile_ctrlr_tbl (
ctrlr_name varchar(32) default ' ',
ref_count bigint default 0,
flags smallint default 0,
- cs_rowstatus smallint default 3,
+ cs_rowstatus smallint default 1,
PRIMARY KEY(policingprofile_name, ctrlr_name));
CREATE TABLE au_policingprofile_rename_tbl (
ctrlr_policingprofile_name varchar(33) default ' ',
ctrlr_name varchar(32) default ' ',
unc_policingprofile_name varchar(33) default ' ',
- PRIMARY KEY(ctrlr_policingprofile_name, ctrlr_name),
- UNIQUE(unc_policingprofile_name));
+ PRIMARY KEY(ctrlr_policingprofile_name, ctrlr_name));
CREATE TABLE au_policingprofile_entry_tbl (
policingprofile_name varchar(33) default ' ',
valid_red_priority smallint default 0,
valid_red_dscp smallint default 0,
valid_red_drop smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist smallint default 3,
- cs_rate smallint default 3,
- cs_cir smallint default 3,
- cs_cbs smallint default 3,
- cs_pir smallint default 3,
- cs_pbs smallint default 3,
- cs_green_action smallint default 3,
- cs_green_priority smallint default 3,
- cs_green_dscp smallint default 3,
- cs_green_drop smallint default 3,
- cs_yellow_action smallint default 3,
- cs_yellow_priority smallint default 3,
- cs_yellow_dscp smallint default 3,
- cs_yellow_drop smallint default 3,
- cs_red_action smallint default 3,
- cs_red_priority smallint default 3,
- cs_red_dscp smallint default 3,
- cs_red_drop smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_flowlist smallint default 1,
+ cs_rate smallint default 1,
+ cs_cir smallint default 1,
+ cs_cbs smallint default 1,
+ cs_pir smallint default 1,
+ cs_pbs smallint default 1,
+ cs_green_action smallint default 1,
+ cs_green_priority smallint default 1,
+ cs_green_dscp smallint default 1,
+ cs_green_drop smallint default 1,
+ cs_yellow_action smallint default 1,
+ cs_yellow_priority smallint default 1,
+ cs_yellow_dscp smallint default 1,
+ cs_yellow_drop smallint default 1,
+ cs_red_action smallint default 1,
+ cs_red_priority smallint default 1,
+ cs_red_dscp smallint default 1,
+ cs_red_drop smallint default 1,
PRIMARY KEY(policingprofile_name, sequence_num));
CREATE TABLE au_policingprofile_entry_ctrlr_tbl (
valid_red_priority smallint default 0,
valid_red_dscp smallint default 0,
valid_red_drop smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist smallint default 3,
- cs_rate smallint default 3,
- cs_cir smallint default 3,
- cs_cbs smallint default 3,
- cs_pir smallint default 3,
- cs_pbs smallint default 3,
- cs_green_action smallint default 3,
- cs_green_priority smallint default 3,
- cs_green_dscp smallint default 3,
- cs_green_drop smallint default 3,
- cs_yellow_action smallint default 3,
- cs_yellow_priority smallint default 3,
- cs_yellow_dscp smallint default 3,
- cs_yellow_drop smallint default 3,
- cs_red_action smallint default 3,
- cs_red_priority smallint default 3,
- cs_red_dscp smallint default 3,
- cs_red_drop smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_flowlist smallint default 1,
+ cs_rate smallint default 1,
+ cs_cir smallint default 1,
+ cs_cbs smallint default 1,
+ cs_pir smallint default 1,
+ cs_pbs smallint default 1,
+ cs_green_action smallint default 1,
+ cs_green_priority smallint default 1,
+ cs_green_dscp smallint default 1,
+ cs_green_drop smallint default 1,
+ cs_yellow_action smallint default 1,
+ cs_yellow_priority smallint default 1,
+ cs_yellow_dscp smallint default 1,
+ cs_yellow_drop smallint default 1,
+ cs_red_action smallint default 1,
+ cs_red_priority smallint default 1,
+ cs_red_dscp smallint default 1,
+ cs_red_drop smallint default 1,
PRIMARY KEY(policingprofile_name, sequence_num, ctrlr_name));
CREATE TABLE au_vtn_flowfilter_tbl (
vtn_name varchar(32) default ' ',
direction smallint default 0,
flags smallint default 0,
- cs_rowstatus smallint default 3,
+ cs_rowstatus smallint default 1,
PRIMARY KEY(vtn_name, direction));
CREATE TABLE au_vtn_flowfilter_ctrlr_tbl (
ctrlr_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
+ cs_rowstatus smallint default 1,
PRIMARY KEY(vtn_name, direction, ctrlr_name, domain_id));
CREATE TABLE au_vtn_flowfilter_entry_tbl (
valid_nwn_name smallint default 0,
valid_dscp smallint default 0,
valid_priority smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist_name smallint default 3,
- cs_action smallint default 3,
- cs_nwn_name smallint default 3,
- cs_dscp smallint default 3,
- cs_priority smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_flowlist_name smallint default 1,
+ cs_action smallint default 1,
+ cs_nwn_name smallint default 1,
+ cs_dscp smallint default 1,
+ cs_priority smallint default 1,
PRIMARY KEY(vtn_name, direction, sequence_num));
CREATE TABLE au_vtn_flowfilter_entry_ctrlr_tbl (
valid_nwn_name smallint default 0,
valid_dscp smallint default 0,
valid_priority smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist_name smallint default 3,
- cs_action smallint default 3,
- cs_nwn_name smallint default 3,
- cs_dscp smallint default 3,
- cs_priority smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_flowlist_name smallint default 1,
+ cs_action smallint default 1,
+ cs_nwn_name smallint default 1,
+ cs_dscp smallint default 1,
+ cs_priority smallint default 1,
PRIMARY KEY(vtn_name, direction, sequence_num, ctrlr_name, domain_id));
CREATE TABLE au_vbr_flowfilter_tbl (
ctrlr_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
+ cs_rowstatus smallint default 1,
PRIMARY KEY(vtn_name, vbr_name, direction));
CREATE TABLE au_vbr_flowfilter_entry_tbl (
valid_nwn_name smallint default 0,
valid_dscp smallint default 0,
valid_priority smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist_name smallint default 3,
- cs_action smallint default 3,
- cs_redirect_node smallint default 3,
- cs_redirect_port smallint default 3,
- cs_modify_dst_mac smallint default 3,
- cs_modify_src_mac smallint default 3,
- cs_nwm_name smallint default 3,
- cs_dscp smallint default 3,
- cs_priority smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_flowlist_name smallint default 1,
+ cs_action smallint default 1,
+ cs_redirect_node smallint default 1,
+ cs_redirect_port smallint default 1,
+ cs_modify_dst_mac smallint default 1,
+ cs_modify_src_mac smallint default 1,
+ cs_nwm_name smallint default 1,
+ cs_dscp smallint default 1,
+ cs_priority smallint default 1,
PRIMARY KEY(vtn_name, vbr_name, direction, sequence_num));
CREATE TABLE au_vbr_if_flowfilter_tbl (
ctrlr_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
+ cs_rowstatus smallint default 1,
PRIMARY KEY(vtn_name, vbr_name, vbr_if_name, direction));
CREATE TABLE au_vbr_if_flowfilter_entry_tbl (
valid_nwn_name smallint default 0,
valid_dscp smallint default 0,
valid_priority smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist_name smallint default 3,
- cs_action smallint default 3,
- cs_redirect_node smallint default 3,
- cs_redirect_port smallint default 3,
- cs_modify_dst_mac smallint default 3,
- cs_modify_src_mac smallint default 3,
- cs_nwm_name smallint default 3,
- cs_dscp smallint default 3,
- cs_priority smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_flowlist_name smallint default 1,
+ cs_action smallint default 1,
+ cs_redirect_node smallint default 1,
+ cs_redirect_port smallint default 1,
+ cs_modify_dst_mac smallint default 1,
+ cs_modify_src_mac smallint default 1,
+ cs_nwm_name smallint default 1,
+ cs_dscp smallint default 1,
+ cs_priority smallint default 1,
PRIMARY KEY(vtn_name, vbr_name, vbr_if_name, direction, sequence_num));
CREATE TABLE au_vrt_if_flowfilter_tbl (
ctrlr_name varchar(32) default ' ',
domain_id varchar(32) default ' ',
flags smallint default 0,
- cs_rowstatus smallint default 3,
+ cs_rowstatus smallint default 1,
PRIMARY KEY(vtn_name, vrt_name, vrt_if_name, direction));
CREATE TABLE au_vrt_if_flowfilter_entry_tbl (
valid_nwn_name smallint default 0,
valid_dscp smallint default 0,
valid_priority smallint default 0,
- cs_rowstatus smallint default 3,
- cs_flowlist_name smallint default 3,
- cs_action smallint default 3,
- cs_redirect_node smallint default 3,
- cs_redirect_port smallint default 3,
- cs_modify_dst_mac smallint default 3,
- cs_modify_src_mac smallint default 3,
- cs_nwm_name smallint default 3,
- cs_dscp smallint default 3,
- cs_priority smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_flowlist_name smallint default 1,
+ cs_action smallint default 1,
+ cs_redirect_node smallint default 1,
+ cs_redirect_port smallint default 1,
+ cs_modify_dst_mac smallint default 1,
+ cs_modify_src_mac smallint default 1,
+ cs_nwm_name smallint default 1,
+ cs_dscp smallint default 1,
+ cs_priority smallint default 1,
PRIMARY KEY(vtn_name, vrt_name, vrt_if_name, direction, sequence_num));
CREATE TABLE au_vtn_policingmap_tbl (
policername varchar(33) default ' ',
flags smallint default 0,
valid_policername smallint default 0,
- cs_rowstatus smallint default 3,
- cs_policername smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_policername smallint default 1,
PRIMARY KEY(vtn_name));
CREATE TABLE au_vtn_policingmap_ctrlr_tbl (
policername varchar(33) default ' ',
flags smallint default 0,
valid_policername smallint default 0,
- cs_rowstatus smallint default 3,
- cs_policername smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_policername smallint default 1,
PRIMARY KEY(vtn_name, ctrlr_name, domain_id));
CREATE TABLE au_vbr_policingmap_tbl (
policername varchar(33) default ' ',
flags smallint default 0,
valid_policername smallint default 0,
- cs_rowstatus smallint default 3,
- cs_policername smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_policername smallint default 1,
PRIMARY KEY(vtn_name, vbr_name));
CREATE TABLE au_vbr_if_policingmap_tbl (
policername varchar(33) default ' ',
flags smallint default 0,
valid_policername smallint default 0,
- cs_rowstatus smallint default 3,
- cs_policername smallint default 3,
+ cs_rowstatus smallint default 1,
+ cs_policername smallint default 1,
PRIMARY KEY(vtn_name, vbr_name, vbr_if_name));