GTEST_SRCROOT := ../../../..
include ../../defs.mk
+COMMON_STUB_PATH = ../..
+
EXEC_NAME := odcdriver_ut
MODULE_SRCROOT = $(GTEST_SRCROOT)/modules
-RESTJSONUTIL_STUBDIR = stub/restjsonutil
-VTNDRVINTF_STUBDIR = stub/vtndrvintf
-TCLIB_STUBDIR = stub/tclib_module
-MISC_STUBDIR = stub/misc
-STUBDIR = stub
+RESTJSONUTIL_STUBDIR = $(COMMON_STUB_PATH)/stub/restjsonutil
+VTNDRVINTF_STUBDIR = $(COMMON_STUB_PATH)/stub/ContrllerFrameworkStub
+TCLIB_STUBDIR = $(COMMON_STUB_PATH)/stub/tclib_module
+MISC_STUBDIR = $(COMMON_STUB_PATH)/stub/misc
ODCDRIVER_SRCDIR = $(MODULE_SRCROOT)/odcdriver
VTNCACHEUTIL_SRCDIR = $(MODULE_SRCROOT)/vtncacheutil
-RESTJSONUTIL_SRCDIR = $(MODULE_SRCROOT)/restjsonutil
-TCLIB_SRCDIR = $(MODULE_SRCROOT)/tclib
ALARM_SRCDIR = $(MODULE_SRCROOT)/alarm
# Define a list of directories that contain source files.
ALT_SRCDIRS = $(ODCDRIVER_SRCDIR) $(VTNCACHEUTIL_SRCDIR) $(RESTJSONUTIL_STUBDIR) $(VTNDRVINTF_STUBDIR)
ALT_SRCDIRS += $(TCLIB_STUBDIR) $(MISC_STUBDIR)
-UT_INCDIRS_PREP = stub/include stub/include/core_include
+CXX_INCDIRS += core/libs/
+UT_INCDIRS_PREP = ${COMMON_STUB_PATH} $(COMMON_STUB_PATH)/stub/include $(COMMON_STUB_PATH)/stub/include/core_include $(COMMON_STUB_PATH)/stub/include/cxx
+
+UTXX_INCDIRS_PREP = $(VTNDRVINTF_STUBDIR)/driver
EXTRA_CXX_INCDIRS = $(MODULE_SRCROOT)
-EXTRA_CXX_INCDIRS += $(STUBDIR)
EXTRA_CXX_INCDIRS += $(VTNDRVINTF_STUBDIR)
EXTRA_CXX_INCDIRS += $(RESTJSONUTIL_STUBDIR)
EXTRA_CXX_INCDIRS += $(ODCDRIVER_SRCDIR)/include
EXTRA_CXX_INCDIRS += $(VTNCACHEUTIL_SRCDIR)/include
-EXTRA_CXX_INCDIRS += $(TCLIB_SRCDIR)/include
+EXTRA_CXX_INCDIRS += $(TCLIB_STUBDIR)
EXTRA_CXX_INCDIRS += $(ALARM_SRCDIR)/include
CPPFLAGS += -include ut_stub.h
VTNCACHEUTIL_SOURCES = keytree.cc
VTNCACHEUTIL_SOURCES += confignode.cc
+VTNDRVINTF_STUB_SOURCES += controller_fw.cc
TCLIB_SOURCES = tclib_module.cc
MISC_SOURCES = ipc_client.cc ipc_server.cc module.cc
UT_SOURCES += odc_vbr_vlanmap_ut.cc
CXX_SOURCES += $(UT_SOURCES)
-CXX_SOURCES += $(ODCDRIVER_SOURCES) $(VTNCACHEUTIL_SOURCES) $(TCLIB_SOURCES)
+CXX_SOURCES += $(ODCDRIVER_SOURCES) $(VTNCACHEUTIL_SOURCES) $(TCLIB_SOURCES) $(VTNDRVINTF_STUB_SOURCES)
CXX_SOURCES += $(MISC_SOURCES)
EXTRA_CXXFLAGS += -fprofile-arcs -ftest-coverage
+++ /dev/null
-/*
- * Copyright (c) 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 _PFC_IPC_CLIENT_H
-#define _PFC_IPC_CLIENT_H
-
-/*
- * Common definition for PFC Inter-Process Communication framework client.
- */
-
-#include <pfc/base.h>
-#include <pfc/ipc.h>
-#include <pfc/clock.h>
-#include <pfc/hostaddr.h>
-#include <netinet/in.h>
-
-PFC_C_BEGIN_DECL
-
-/*
- * Invalid connection handle.
- */
-#define PFC_IPCCONN_INVALID PFC_CONST_U(0)
-
-/*
- * Handle of alternative connection pool.
- */
-typedef uint32_t pfc_ipccpool_t;
-
-/*
- * Invalid connection pool handle.
- */
-#define PFC_IPCCPOOL_INVALID PFC_CONST_U(0)
-
-/*
- * Global connection pool handle.
- */
-#define PFC_IPCCPOOL_GLOBAL PFC_CONST_U(1)
-
-/*
- * Maximum capacity of the connection pool.
- */
-#define PFC_IPCCPOOL_MAX_CAPACITY PFC_CONST_U(0x7fffffff)
-
-/*
- * Flags for pfc_ipcclnt_cpool_close().
- */
-
-/* Force to close connection in the pool. */
-#define PFC_IPCPLF_C_FORCE PFC_CONST_U(0x1)
-
-/*
- * Flags for pfc_ipcclnt_sess_create4() and pfc_ipcclnt_sess_altcreate5().
- */
-
-/* Enable session-specific cancellation. */
-#define PFC_IPCSSF_CANCELABLE PFC_CONST_U(0x00000001)
-
-/*
- * Disable global cancellation by the call of pfc_ipcclnt_cancel(PFC_FALSE).
- * This flag implies PFC_IPCSF_CANCELABLE.
- */
-#define PFC_IPCSSF_NOGLOBCANCEL PFC_CONST_U(0x00000002)
-
-/*
- * IPC channel monitor option.
- */
-static int result_;
-
-typedef struct {
- /*
- * Interval, in milliseconds, between keep-alive probes on the remote
- * IPC monitor session. Default value is 30 seconds.
- */
- uint32_t mon_keep_interval;
-
- /*
- * Timeout, in milliseconds, of keep-alive probe on the remote IPC
- * monitor session. Default is 10 seconds.
- */
- uint32_t mon_keep_timeout;
-} pfc_ipcmonopt_t;
-
-/*
- * IPC event object.
- */
-struct __pfc_ipcevent;
-typedef struct __pfc_ipcevent pfc_ipcevent_t;
-
-/*
- * Prototype of IPC event handler function.
- */
-typedef void (*pfc_ipcevfunc_t)(pfc_ipcevent_t *event, pfc_ptr_t arg);
-
-/*
- * Prototype of destructor of IPC event handler's argument.
- */
-typedef void (*pfc_ipcevdtor_t)(pfc_ptr_t arg);
-
-/*
- * IPC event handler's attributes.
- */
-#ifdef PFC_LP64
-#define __PFC_IPCEVATTR_SIZE PFC_CONST_U(56)
-#else /* !PFC_LP64 */
-#define __PFC_IPCEVATTR_SIZE PFC_CONST_U(32)
-#endif /* PFC_LP64 */
-
-typedef union {
- uint8_t attr[__PFC_IPCEVATTR_SIZE];
- uint64_t align;
-} pfc_ipcevattr_t;
-
-/*
- * Identifier of IPC event handler.
- */
-typedef uint32_t pfc_ipcevhdlr_t;
-
-/*
- * Invalid ID of IPC event handler.
- */
-#define PFC_IPCEVHDLR_INVALID ((pfc_ipcevhdlr_t)0)
-
-/*
- * Event type for IPC channel state change event.
- */
-#define PFC_IPCCHSTATE_UP PFC_CONST_U(0) /* IPC channel is up */
-#define PFC_IPCCHSTATE_DOWN PFC_CONST_U(1) /* IPC channel is down */
-#define PFC_IPCCHSTATE_NOTIFY PFC_CONST_U(2) /* state notification */
-
-
-#define PFC_IPCCHDOWN_REFUSED PFC_CONST_U(1) /* connection refused */
-#define PFC_IPCCHDOWN_RESET PFC_CONST_U(2) /* reset by peer */
-#define PFC_IPCCHDOWN_HANGUP PFC_CONST_U(3) /* hang up */
-#define PFC_IPCCHDOWN_TIMEDOUT PFC_CONST_U(4) /* timed out */
-#define PFC_IPCCHDOWN_AUTHFAIL PFC_CONST_U(5) /* authentication failed */
-#define PFC_IPCCHDOWN_TOOMANY PFC_CONST_U(6) /* too many connections */
-#define PFC_IPCCHDOWN_ERROR PFC_CONST_U(7) /* closed due to error */
-
-#define PFC_IPCCHNOTIFY_DOWN PFC_CONST_U(0) /* IPC channel is down */
-#define PFC_IPCCHNOTIFY_UP PFC_CONST_U(1) /* IPC channel is up */
-
-static inline void
-pfc_ipcevent_mask_empty(pfc_ipcevmask_t *mask) {
- *mask = PFC_IPC_EVENT_MASK_EMPTY;
-}
-
-static inline void
-pfc_ipcevent_mask_fill(pfc_ipcevmask_t *mask) {
- *mask = PFC_IPC_EVENT_MASK_FILL;
-}
-
-static inline int
-pfc_ipcevent_mask_add(pfc_ipcevmask_t *mask, pfc_ipcevtype_t type) {
- if (PFC_EXPECT_FALSE(!PFC_IPC_EVTYPE_IS_VALID(type))) {
- return EINVAL;
- }
-
- *mask |= PFC_IPC_EVENT_MASK_BIT(type);
-
- return 0;
-}
-
-static inline int
-pfc_ipcevent_mask_remove(pfc_ipcevmask_t *mask, pfc_ipcevtype_t type) {
- if (PFC_EXPECT_FALSE(!PFC_IPC_EVTYPE_IS_VALID(type))) {
- return EINVAL;
- }
-
- *mask &= ~PFC_IPC_EVENT_MASK_BIT(type);
-
- return 0;
-}
-
-static inline pfc_bool_t
-pfc_ipcevent_mask_test(const pfc_ipcevmask_t *mask, pfc_ipcevtype_t type) {
- if (PFC_EXPECT_FALSE(!PFC_IPC_EVTYPE_IS_VALID(type))) {
- return PFC_FALSE;
- }
-
- return (*mask & PFC_IPC_EVENT_MASK_BIT(type)) ? PFC_TRUE : PFC_FALSE;
-}
-
-#define PFC_IPCCLNT_OUTPUT_STRUCT(sess, stname, data) \
- __pfc_ipcclnt_output_struct((sess), (const uint8_t *)(data), \
- __PFC_IPC_STRUCT_SIZE(stname), \
- __PFC_IPC_STRUCT_STRINGIFY(stname), \
- __PFC_IPC_STRUCT_SIGNATURE(stname))
-
-#define PFC_IPCCLNT_GETRES_STRUCT(sess, index, stname, datap) \
- __pfc_ipcclnt_getres_struct((sess), (index), (uint8_t *)(datap), \
- __PFC_IPC_STRUCT_SIZE(stname), \
- __PFC_IPC_STRUCT_STRINGIFY(stname), \
- __PFC_IPC_STRUCT_SIGNATURE(stname))
-
-extern int pfc_ipcclnt_sess_create(pfc_ipcsess_t **PFC_RESTRICT sessp,
- const char *PFC_RESTRICT name,
- pfc_ipcid_t service);
-extern int pfc_ipcclnt_sess_create4(pfc_ipcsess_t **PFC_RESTRICT sessp,
- const char *PFC_RESTRICT name,
- pfc_ipcid_t service, uint32_t flags);
-extern int pfc_ipcclnt_sess_reset(pfc_ipcsess_t *PFC_RESTRICT sess,
- const char *PFC_RESTRICT name,
- pfc_ipcid_t service);
-extern int pfc_ipcclnt_sess_settimeout(pfc_ipcsess_t *PFC_RESTRICT sess,
- const pfc_timespec_t *PFC_RESTRICT
- timeout);
-extern int pfc_ipcclnt_sess_invoke(pfc_ipcsess_t *PFC_RESTRICT sess,
- pfc_ipcresp_t *PFC_RESTRICT respp);
-extern int pfc_ipcclnt_sess_cancel(pfc_ipcsess_t *sess,
- pfc_bool_t discard);
-extern int pfc_ipcclnt_sess_destroy(pfc_ipcsess_t *sess);
-extern void __pfc_ipcclnt_sess_destroy(pfc_ipcsess_t *sess);
-
-extern int pfc_ipcclnt_output_int8(pfc_ipcsess_t *sess, int8_t data);
-extern int pfc_ipcclnt_output_uint8(pfc_ipcsess_t *sess, uint8_t data);
-extern int pfc_ipcclnt_output_int16(pfc_ipcsess_t *sess, int16_t data);
-extern int pfc_ipcclnt_output_uint16(pfc_ipcsess_t *sess, uint16_t data);
-extern int pfc_ipcclnt_output_int32(pfc_ipcsess_t *sess, int32_t data);
-extern int pfc_ipcclnt_output_uint32(pfc_ipcsess_t *sess, uint32_t data);
-extern int pfc_ipcclnt_output_int64(pfc_ipcsess_t *sess, int64_t data);
-extern int pfc_ipcclnt_output_uint64(pfc_ipcsess_t *sess, uint64_t data);
-extern int pfc_ipcclnt_output_float(pfc_ipcsess_t *sess, float data);
-extern int pfc_ipcclnt_output_double(pfc_ipcsess_t *sess, double data);
-extern int pfc_ipcclnt_output_ipv4(pfc_ipcsess_t *PFC_RESTRICT sess,
- struct in_addr *PFC_RESTRICT data);
-extern int pfc_ipcclnt_output_ipv6(pfc_ipcsess_t *PFC_RESTRICT sess,
- struct in6_addr *PFC_RESTRICT data);
-extern int pfc_ipcclnt_output_string(pfc_ipcsess_t *PFC_RESTRICT sess,
- const char *PFC_RESTRICT data);
-extern int pfc_ipcclnt_output_binary(pfc_ipcsess_t *PFC_RESTRICT sess,
- const uint8_t *PFC_RESTRICT data,
- uint32_t length);
-extern int pfc_ipcclnt_output_null(pfc_ipcsess_t *sess);
-extern int pfc_ipcclnt_output_stdef(pfc_ipcsess_t *PFC_RESTRICT sess,
- const pfc_ipcstdef_t *PFC_RESTRICT
- defp, pfc_cptr_t data);
-
-extern int pfc_ipcclnt_getres_int8(pfc_ipcsess_t *PFC_RESTRICT sess,
- uint32_t index,
- int8_t *PFC_RESTRICT datap);
-extern int pfc_ipcclnt_getres_uint8(pfc_ipcsess_t *PFC_RESTRICT sess,
- uint32_t index,
- uint8_t *PFC_RESTRICT datap);
-extern int pfc_ipcclnt_getres_int16(pfc_ipcsess_t *PFC_RESTRICT sess,
- uint32_t index,
- int16_t *PFC_RESTRICT datap);
-extern int pfc_ipcclnt_getres_uint16(pfc_ipcsess_t *PFC_RESTRICT sess,
- uint32_t index,
- uint16_t *PFC_RESTRICT datap);
-extern int pfc_ipcclnt_getres_int32(pfc_ipcsess_t *PFC_RESTRICT sess,
- uint32_t index,
- int32_t *PFC_RESTRICT datap);
-extern int pfc_ipcclnt_getres_uint32(pfc_ipcsess_t *PFC_RESTRICT sess,
- uint32_t index,
- uint32_t *PFC_RESTRICT datap);
-extern int pfc_ipcclnt_getres_int64(pfc_ipcsess_t *PFC_RESTRICT sess,
- uint32_t index,
- int64_t *PFC_RESTRICT datap);
-extern int pfc_ipcclnt_getres_uint64(pfc_ipcsess_t *PFC_RESTRICT sess,
- uint32_t index,
- uint64_t *PFC_RESTRICT datap);
-extern int pfc_ipcclnt_getres_float(pfc_ipcsess_t *PFC_RESTRICT sess,
- uint32_t index,
- float *PFC_RESTRICT datap);
-extern int pfc_ipcclnt_getres_double(pfc_ipcsess_t *PFC_RESTRICT sess,
- uint32_t index,
- double *PFC_RESTRICT datap);
-extern int pfc_ipcclnt_getres_ipv4(pfc_ipcsess_t *PFC_RESTRICT sess,
- uint32_t index,
- struct in_addr *PFC_RESTRICT datap);
-extern int pfc_ipcclnt_getres_ipv6(pfc_ipcsess_t *PFC_RESTRICT sess,
- uint32_t index,
- struct in6_addr *PFC_RESTRICT datap);
-extern int pfc_ipcclnt_getres_string(pfc_ipcsess_t *PFC_RESTRICT sess,
- uint32_t index,
- const char **PFC_RESTRICT datapp);
-extern int pfc_ipcclnt_getres_binary(pfc_ipcsess_t *PFC_RESTRICT sess,
- uint32_t index,
- const uint8_t **PFC_RESTRICT datapp,
- uint32_t *PFC_RESTRICT lengthp);
-extern int pfc_ipcclnt_getres_stdef(pfc_ipcsess_t *PFC_RESTRICT sess,
- uint32_t index,
- const pfc_ipcstdef_t *PFC_RESTRICT
- defp, pfc_ptr_t datap);
-
-extern uint32_t pfc_ipcclnt_getrescount(pfc_ipcsess_t *sess);
-extern int pfc_ipcclnt_getrestype(pfc_ipcsess_t *PFC_RESTRICT sess,
- uint32_t index,
- pfc_ipctype_t *PFC_RESTRICT typep);
-extern int pfc_ipcclnt_getres_structname(pfc_ipcsess_t *PFC_RESTRICT sess,
- uint32_t index,
- const char **PFC_RESTRICT namepp);
-
-extern int pfc_ipcclnt_setdefault(const char *name);
-
-extern pfc_bool_t pfc_ipcclnt_isdisabled(void);
-
-// int pfc_ipcclnt_altopen(const char *PFC_RESTRICT name,
-// pfc_ipcconn_t *PFC_RESTRICT connp);
-
-// int pfc_ipcclnt_altclose(pfc_ipcconn_t conn);
-
-extern int pfc_ipcclnt_cpool_create(pfc_ipccpool_t *poolp,
- uint32_t capacity);
-extern int pfc_ipcclnt_cpool_destroy(pfc_ipccpool_t pool);
-extern int pfc_ipcclnt_cpool_open(pfc_ipccpool_t pool,
- const char *PFC_RESTRICT name,
- pfc_ipcconn_t *PFC_RESTRICT connp);
-extern int pfc_ipcclnt_cpool_close(pfc_ipccpool_t pool,
- pfc_ipcconn_t conn, uint32_t flags);
-extern uint32_t pfc_ipcclnt_cpool_getsize(pfc_ipccpool_t pool);
-extern uint32_t pfc_ipcclnt_cpool_getcapacity(pfc_ipccpool_t pool);
-
-extern int pfc_ipcclnt_sess_altcreate(pfc_ipcsess_t **PFC_RESTRICT sessp,
- pfc_ipcconn_t conn,
- const char *PFC_RESTRICT name,
- pfc_ipcid_t service);
-extern int pfc_ipcclnt_sess_altcreate5(pfc_ipcsess_t **PFC_RESTRICT sessp,
- pfc_ipcconn_t conn,
- const char *PFC_RESTRICT name,
- pfc_ipcid_t service,
- uint32_t flags);
-
-extern int pfc_ipcclnt_forward(pfc_ipcsess_t *PFC_RESTRICT dsess,
- pfc_ipcsess_t *PFC_RESTRICT ssess,
- uint32_t begin, uint32_t end);
-extern int pfc_ipcclnt_forward_fromsrv(pfc_ipcsess_t *PFC_RESTRICT dsess,
- pfc_ipcsrv_t *PFC_RESTRICT ssrv,
- uint32_t begin, uint32_t end);
-extern int pfc_ipcclnt_forward_tosrv(pfc_ipcsrv_t *PFC_RESTRICT dsrv,
- pfc_ipcsess_t *PFC_RESTRICT ssess,
- uint32_t begin, uint32_t end);
-
-extern int pfc_ipcclnt_monitor(const char *PFC_RESTRICT name,
- pfc_bool_t *PFC_RESTRICT connected,
- const pfc_timespec_t *PFC_RESTRICT
- conn_timeout);
-extern int pfc_ipcclnt_monitor4(const char *PFC_RESTRICT name,
- pfc_bool_t *PFC_RESTRICT connected,
- const pfc_timespec_t *PFC_RESTRICT
- conn_timeout,
- const pfc_ipcmonopt_t *PFC_RESTRICT opts);
-extern int pfc_ipcclnt_monitor_cancel(const char *name);
-extern void pfc_ipcclnt_monitor_cancelall(void);
-
-extern int pfc_ipcclnt_hostset_create(const char *name);
-extern int pfc_ipcclnt_hostset_destroy(const char *name);
-extern int pfc_ipcclnt_hostset_exists(const char *name);
-extern int pfc_ipcclnt_hostset_add(const char *PFC_RESTRICT name,
- const pfc_hostaddr_t *PFC_RESTRICT
- addr);
-extern int pfc_ipcclnt_hostset_remove(const char *PFC_RESTRICT name,
- const pfc_hostaddr_t *PFC_RESTRICT
- addr);
-extern int pfc_ipcclnt_hostset_contains(const char *PFC_RESTRICT name,
- const pfc_hostaddr_t *PFC_RESTRICT
- addr);
-
-extern int pfc_ipcevent_attr_init(pfc_ipcevattr_t *attr);
-extern void pfc_ipcevent_attr_destroy(pfc_ipcevattr_t *attr);
-extern int pfc_ipcevent_attr_gethostset(const pfc_ipcevattr_t
- *PFC_RESTRICT attr,
- const char **PFC_RESTRICT namep);
-extern int pfc_ipcevent_attr_sethostset(pfc_ipcevattr_t *PFC_RESTRICT attr,
- const char *PFC_RESTRICT name);
-extern int pfc_ipcevent_attr_gettarget(const pfc_ipcevattr_t *PFC_RESTRICT
- attr,
- const char *PFC_RESTRICT service,
- pfc_ipcevmask_t *PFC_RESTRICT mask);
-extern int pfc_ipcevent_attr_addtarget(pfc_ipcevattr_t *PFC_RESTRICT attr,
- const char *PFC_RESTRICT service,
- const pfc_ipcevmask_t *PFC_RESTRICT
- mask);
-extern int pfc_ipcevent_attr_resettarget(pfc_ipcevattr_t *attr);
-extern int pfc_ipcevent_attr_getpriority(const pfc_ipcevattr_t
- *PFC_RESTRICT attr,
- uint32_t *PFC_RESTRICT prip);
-extern int pfc_ipcevent_attr_setpriority(pfc_ipcevattr_t *attr,
- uint32_t pri);
-extern int pfc_ipcevent_attr_getarg(const pfc_ipcevattr_t *PFC_RESTRICT
- attr,
- pfc_ptr_t *PFC_RESTRICT argp);
-extern int pfc_ipcevent_attr_setarg(pfc_ipcevattr_t *PFC_RESTRICT attr,
- pfc_ptr_t arg);
-extern int pfc_ipcevent_attr_getargdtor(const pfc_ipcevattr_t
- *PFC_RESTRICT attr,
- pfc_ipcevdtor_t *PFC_RESTRICT
- dtorp);
-extern int pfc_ipcevent_attr_setargdtor(pfc_ipcevattr_t *PFC_RESTRICT attr,
- pfc_ipcevdtor_t dtor);
-extern int pfc_ipcevent_attr_getlog(const pfc_ipcevattr_t *PFC_RESTRICT
- attr,
- pfc_bool_t *PFC_RESTRICT logp);
-extern int pfc_ipcevent_attr_setlog(pfc_ipcevattr_t *PFC_RESTRICT attr,
- pfc_bool_t log);
-
-extern int pfc_ipcevent_isconnected(const char *PFC_RESTRICT channel,
- const pfc_hostaddr_t *PFC_RESTRICT
- addr);
-extern int pfc_ipcevent_notifystate(pfc_ipcevhdlr_t id);
-
-extern pfc_ipcevid_t pfc_ipcevent_getserial(pfc_ipcevent_t *event);
-extern pfc_ipcevtype_t pfc_ipcevent_gettype(pfc_ipcevent_t *event);
-extern void pfc_ipcevent_gettime(pfc_ipcevent_t *PFC_RESTRICT event,
- pfc_timespec_t *PFC_RESTRICT tsp);
-extern const char *pfc_ipcevent_getchannelname(pfc_ipcevent_t *event);
-extern const pfc_hostaddr_t *pfc_ipcevent_gethostaddr(pfc_ipcevent_t
- *event);
-extern const char *pfc_ipcevent_getservicename(pfc_ipcevent_t *event);
-extern pfc_ipcsess_t *pfc_ipcevent_getsess(pfc_ipcevent_t *event);
-extern pfc_bool_t pfc_ipcevent_isstatechange(pfc_ipcevent_t *event);
-//void set_pfc_ipcclnt_altopen(int result);
-
-typedef struct {
- uint32_t evopt_idle_timeout;
- uint32_t evopt_maxthreads;
- uint32_t evopt_conn_interval;
- uint32_t evopt_keep_interval;
- uint32_t evopt_keep_timeout;
- uint32_t evopt_timeout;
- int (*evopt_thread_create)(void *(*func)(void *), void *arg);
-} pfc_ipcevopts_t;
-
-extern int pfc_ipcclnt_event_init(const pfc_ipcevopts_t *opts);
-extern int pfc_ipcclnt_event_shutdown(void);
-extern int pfc_ipcclnt_event_fini(void);
-
-extern int pfc_ipcevent_add_handler(pfc_ipcevhdlr_t *PFC_RESTRICT idp,
- const char *PFC_RESTRICT channel,
- pfc_ipcevfunc_t func,
- const pfc_ipcevattr_t *PFC_RESTRICT
- attr,
- const char *PFC_RESTRICT name);
-extern int pfc_ipcevent_remove_handler(pfc_ipcevhdlr_t id);
-
-extern void pfc_ipcclnt_cancel(pfc_bool_t permanent);
-extern void pfc_ipcclnt_cpool_reap(pfc_bool_t forced);
-extern void pfc_ipcclnt_enable_log(pfc_bool_t enable);
-
-extern int __pfc_ipcclnt_output_struct(pfc_ipcsess_t *PFC_RESTRICT sess,
- const uint8_t *PFC_RESTRICT data,
- uint32_t length,
- const char *PFC_RESTRICT stname,
- const char *PFC_RESTRICT sig);
-extern int __pfc_ipcclnt_getres_struct(pfc_ipcsess_t *PFC_RESTRICT sess,
- uint32_t index,
- uint8_t *PFC_RESTRICT datap,
- uint32_t length,
- const char *PFC_RESTRICT stname,
- const char *PFC_RESTRICT sig);
-
-
-
-inline int
-pfc_ipcclnt_altopen(const char *PFC_RESTRICT name,
- pfc_ipcconn_t *PFC_RESTRICT connp)
-{
- return result_;
-}
-
-inline void
-set_pfc_ipcclnt_altopen(int result)
-{
- result_ = result;
-}
-
-inline int
-pfc_ipcclnt_altclose(pfc_ipcconn_t conn)
-{
- return 1;
-}
-
-PFC_C_END_DECL
-
-#endif /* !_PFC_IPC_CLIENT_H */
+++ /dev/null
-/*
- * Copyright (c) 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 _PFC_MODULE_H
-#define _PFC_MODULE_H
-
-/*
- * Definitions for PFC module management.
- */
-
-#include <pfc/base.h>
-#include <pfc/synch.h>
-#include <pfc/conf.h>
-#include <pfc/event.h>
-#include <pfc/moddefs.h>
-#include <pfc/modconst.h>
-#include <pfc/modevent.h>
-#include <pfc/modipc_server.h>
-#include <pfc/modipc_client.h>
-#include <pfc/debug.h>
-
-PFC_C_BEGIN_DECL
-
-/*
- * Suffix of module filename.
- */
-#define PFC_MODULE_LIB_SUFFIX "so"
-
-/*
- * Suffix of module configuration file.
- */
-#define PFC_MODULE_CONF_SUFFIX ".conf"
-#define PFC_MODULE_CONF_SUFFIX_LEN PFC_CONST_U(5)
-
-/*
- * Prototypes.
- */
-extern pfc_module_t pfc_module_register(const pfc_modattr_t
- *PFC_RESTRICT mattr,
- pfc_cptr_t PFC_RESTRICT data);
-extern pfc_module_t pfc_module_c_register(const pfc_modattr_t
- *PFC_RESTRICT mattr,
- pfc_modfunc_t init,
- pfc_modfunc_t fini);
-
-extern void __pfc_module_bootstrap(const char *name,
- pfc_modboot_t func);
-
-extern pfc_bool_t pfc_module_is_started(void);
-extern pfc_bool_t pfc_module_hold(pfc_module_t module);
-extern void pfc_module_release(pfc_module_t module);
-extern pfc_cfblk_t __pfc_module_conf_getblock(pfc_module_t module,
- const char *bname);
-extern pfc_cfblk_t __pfc_module_conf_getmap(pfc_module_t module,
- const char *mname,
- const char *key);
-extern int __pfc_module_conf_getmapkeys(pfc_module_t module,
- const char *mname,
- pfc_listm_t *keysp);
-extern int __pfc_module_conf_reload(pfc_module_t module);
-
-extern int __pfc_module_event_add(pfc_module_t module,
- pfc_evhandler_t *PFC_RESTRICT idp,
- pfc_evfunc_t handler,
- pfc_ptr_t PFC_RESTRICT arg,
- const pfc_evmask_t *PFC_RESTRICT evmask,
- uint32_t priority,
- const char *PFC_RESTRICT hname);
-extern int __pfc_module_event_post(pfc_module_t module,
- const char *target, pfc_evtype_t type);
-
-extern int __pfc_module_addhook(pfc_module_t module, pfc_modhook_t hook,
- uint32_t pri);
-
-/*
- * PFC_MODULE_BUILD is defined by the build system only for PFC module build.
- */
-#ifdef PFC_MODULE_BUILD
-
-/*
- * static inline pfc_cfblk_t PFC_FATTR_ALWAYS_INLINE
- * pfc_module_conf_getblock(const char *bname)
- * Return parameter block handle associated with the parameter block,
- * which is defined in the module configuration file, specified by
- * the name.
- *
- * Calling/Exit State:
- * A valid block handle is returned on success.
- * On error, PFC_CFBLK_INVALID is returned.
- */
-static inline pfc_cfblk_t PFC_FATTR_ALWAYS_INLINE
-pfc_module_conf_getblock(const char *bname)
-{
- return __pfc_module_conf_getblock(PFC_MODULE_THIS_ID, bname);
-}
-
-/*
- * static inline pfc_cfblk_t PFC_FATTR_ALWAYS_INLINE
- * pfc_module_conf_getmap(const char *mname, const char *key)
- * Return parameter map handle associated with the parameter map block,
- * which is defined in the module configuration file, specified by
- * the map name and key.
- *
- * Calling/Exit State:
- * A valid block handle is returned on success.
- * On error, PFC_CFBLK_INVALID is returned.
- */
-static inline pfc_cfblk_t PFC_FATTR_ALWAYS_INLINE
-pfc_module_conf_getmap(const char *mname, const char *key)
-{
- return __pfc_module_conf_getmap(PFC_MODULE_THIS_ID, mname, key);
-}
-
-/*
- * static inline int PFC_FATTR_ALWAYS_INLINE
- * pfc_module_conf_getmapkeys(const char *mname, pfc_listm_t *keysp)
- * Create a list model instance which contains all map keys of the
- * parameter map specified by `mname' in the module configuration file.
- *
- * Calling/Exit State:
- * Upon successful completion, the list model instance is set to the
- * buffer pointed by `keysp', and zero is returned.
- * Otherwise error number which indicates the cause of error is returned.
- */
-static inline int PFC_FATTR_ALWAYS_INLINE
-pfc_module_conf_getmapkeys(const char *mname, pfc_listm_t *keysp)
-{
- return __pfc_module_conf_getmapkeys(PFC_MODULE_THIS_ID, mname, keysp);
-}
-
-/*
- * static inline int PFC_FATTR_ALWAYS_INLINE
- * pfc_module_conf_reload(void)
- * Reload module configuration file.
- * Note that all parameter block handles obtained by
- * pfc_module_conf_getblock() and pfc_module_conf_getmap() are discarded.
- * You must re-obtain parameter block handles again.
- *
- * Calling/Exit State:
- * Zero is returned on success.
- * Otherwise error number which indicates the cause of error is returned.
- */
-static inline int PFC_FATTR_ALWAYS_INLINE
-pfc_module_conf_reload(void)
-{
- return __pfc_module_conf_reload(PFC_MODULE_THIS_ID);
-}
-
-/*
- * static inline int PFC_FATTR_ALWAYS_INLINE
- * pfc_module_event_add(pfc_evhandler_t *PFC_RESTRICT idp,
- * pfc_evfunc_t handler, pfc_ptr_t PFC_RESTRICT arg,
- * const pfc_evmask_t *PFC_RESTRICT evmask,
- * uint32_t priority)
- * Register module-specific event handler.
- *
- * `handler' is a pointer to event handler, and `arg' is an arbitrary
- * value passed to the handler. If a module-specific event is posted
- * to this module, and its type is contained in the event mask specified
- * by `evmask', the handler is called with specifying the event.
- * If NULL is specified to `evmask', all events posted to this module
- * are delivered to the handler.
- *
- * Calling/Exit State:
- * Upon successful completion, event handler ID is set to `*idp',
- * and zero is returned.
- * Otherwise error number which indicates the cause of error is returned.
- */
-static inline int PFC_FATTR_ALWAYS_INLINE
-pfc_module_event_add(pfc_evhandler_t *PFC_RESTRICT idp, pfc_evfunc_t handler,
- pfc_ptr_t PFC_RESTRICT arg,
- const pfc_evmask_t *PFC_RESTRICT evmask, uint32_t priority)
-{
- return __pfc_module_event_add(PFC_MODULE_THIS_ID, idp, handler,
- arg, evmask, priority, NULL);
-}
-
-/*
- * static inline int PFC_FATTR_ALWAYS_INLINE
- * pfc_module_event_add_named(pfc_evhandler_t *PFC_RESTRICT idp,
- * pfc_evfunc_t handler, pfc_ptr_t PFC_RESTRICT arg,
- * const pfc_evmask_t *PFC_RESTRICT evmask,
- * uint32_t priority, const char *PFC_RESTRICT hname)
- * Register module-specific event handler, with specifying handler's name.
- *
- * `handler' is a pointer to event handler, and `arg' is an arbitrary
- * value passed to the handler. If a module-specific event is posted
- * to this module, and its type is contained in the event mask specified
- * by `evmask', the handler is called with specifying the event.
- * If NULL is specified to `evmask', all events posted to this module
- * are delivered to the handler.
- *
- * `hname' is a user-defined name of event handler.
- * Currently, it is used only for event delivery logging.
- * If NULL is specified, module name is used as handler's name.
- *
- * Calling/Exit State:
- * Upon successful completion, event handler ID is set to `*idp',
- * and zero is returned.
- * Otherwise error number which indicates the cause of error is returned.
- */
-static inline int PFC_FATTR_ALWAYS_INLINE
-pfc_module_event_add_named(pfc_evhandler_t *PFC_RESTRICT idp,
- pfc_evfunc_t handler, pfc_ptr_t PFC_RESTRICT arg,
- const pfc_evmask_t *PFC_RESTRICT evmask,
- uint32_t priority, const char *PFC_RESTRICT hname)
-{
- return __pfc_module_event_add(PFC_MODULE_THIS_ID, idp, handler,
- arg, evmask, priority, hname);
-}
-
-/*
- * static inline int PFC_FATTR_ALWAYS_INLINE
- * pfc_module_event_remove(pfc_evhandler_t id, const pfc_timespec_t *timeout)
- * Remove the module-specific event handler added by the call of
- * pfc_module_event_add().
- *
- * `id' must be an ID of module-specific event handler.
- * If the handler specified by `id' is being called, the calling thread
- * will block until the handler returns. If it does not return within
- * the period specified by `timeout', ETIMEDOUT is returned.
- *
- * Calling/Exit State:
- * Upon successful completion, zero is returned.
- * Otherwise error number which indicates the cause of error is returned.
- *
- * Remarks:
- * The event handler may not be able to reuse even if this function
- * returns error, except for EINVAL.
- */
-static inline int PFC_FATTR_ALWAYS_INLINE
-pfc_module_event_remove(pfc_evhandler_t id, const pfc_timespec_t *timeout)
-{
- return pfc_event_remove_handler(id, timeout);
-}
-
-/*
- * static inline int PFC_FATTR_ALWAYS_INLINE
- * pfc_module_event_post(const char *target, pfc_evtype_t type)
- * Post a module-specific event of the type specified by `type'.
- *
- * The event is delivered to only handlers added by the module specified
- * by `target'.
- *
- * Calling/Exit State:
- * Upon successful completion, zero is returned.
- *
- * ENOENT is returned if an invalid module name is specified to `target'.
- * EPERM is returned if the module specified by `target' is not loaded.
- *
- * Otherwise error number which indicates the cause of error is returned.
- */
-static inline int PFC_FATTR_ALWAYS_INLINE
-pfc_module_event_post(const char *target, pfc_evtype_t type)
-{
- return __pfc_module_event_post(PFC_MODULE_THIS_ID, target, type);
-}
-
-/*
- * static inline int PFC_FATTR_ALWAYS_INLINE
- * pfc_module_addhook(pfc_modhook_t hook, uint32_t pri)
- * Register module unload hook.
- *
- * `hook' is a hook function to be called.
- * `pri' is an uint32_t value which determines order of hook calls.
- * Hook functions are called in ascending order of priority.
- *
- * Module unload hook takes a boolean argument.
- * PFC_TRUE is passed if the module is about to be unloaded in the PFC
- * daemon shutdown sequence.
- * PFC_FALSE is passed if the module is about to be unloaded by user
- * request.
- *
- * Calling/Exit State:
- * Upon successful completion, zero is returned.
- * Otherwise error number which indicates the cause of error is returned.
- */
-static inline int PFC_FATTR_ALWAYS_INLINE
-pfc_module_addhook(pfc_modhook_t hook, uint32_t pri)
-{
- return __pfc_module_addhook(PFC_MODULE_THIS_ID, hook, pri);
-}
-
-#endif /* PFC_MODULE_BUILD */
-
-PFC_C_END_DECL
-
-#endif /* !_PFC_MODULE_H */
+++ /dev/null
-/*
- * Copyright (c) 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 <pfc/ipc.h>
-#include <netinet/in.h>
-#include <string>
-#include <map>
-#include <list>
-#include <pfc/ipc_client.h>
-#include <pfcxx/ipc_server.hh>
-
-#ifndef _PFCXX_IPC_CLIENT_HH
-#define _PFCXX_IPC_CLIENT_HH
-
-namespace pfc {
-namespace core {
-namespace ipc {
-
-class ClientSession
-{
- friend class ::pfc::core::ipc::ServerSession;
-
-public:
- /*
- * Constructors.
- */
- ClientSession(const char *name, pfc_ipcid_t service, int &err);
- ClientSession(const char *name, pfc_ipcid_t service, int &err,
- uint32_t flags);
- ClientSession(const std::string &name, pfc_ipcid_t service, int &err);
- ClientSession(const std::string &name, pfc_ipcid_t service, int &err,
- uint32_t flags);
- ClientSession(pfc_ipcconn_t conn, const char *name, pfc_ipcid_t service,
- int &err);
- ClientSession(pfc_ipcconn_t conn, const char *name, pfc_ipcid_t service,
- int &err, uint32_t flags);
- ClientSession(pfc_ipcconn_t conn, const std::string &name,
- pfc_ipcid_t service, int &err);
- ClientSession(pfc_ipcconn_t conn, const std::string &name,
- pfc_ipcid_t service, int &err, uint32_t flags);
- ClientSession(pfc_ipcsess_t *sess);
- explicit ClientSession();
-
- /*
- * Destructor.
- */
- ~ClientSession();
-
- /*
- * Instance methods.
- */
- int reset(const char *name, pfc_ipcid_t service);
- int reset(const std::string &name, pfc_ipcid_t service);
-
- int setTimeout(const pfc_timespec_t *timeout=NULL);
- int invoke(pfc_ipcresp_t &response);
- int cancel(pfc_bool_t discard=PFC_FALSE);
- int forward(ClientSession &sess, uint32_t begin = 0,
- uint32_t end = UINT32_MAX);
- int forward(ServerSession &sess, uint32_t begin = 0,
- uint32_t end = UINT32_MAX);
- int forwardTo(ServerSession &sess, uint32_t begin = 0,
- uint32_t end = UINT32_MAX);
-
- int addOutput(int8_t data);
- int addOutputInt8(int8_t data);
- int addOutput(uint8_t data);
- int addOutputUint8(uint8_t data);
- int addOutput(int16_t data);
- int addOutputInt16(int16_t data);
- int addOutput(uint16_t data);
- int addOutputUint16(uint16_t data);
- int addOutput(int32_t data);
- int addOutputInt32(int32_t data);
- int addOutput(uint32_t data);
- int addOutputUint32(uint32_t data);
- int addOutput(int64_t data);
- int addOutputInt64(int64_t data);
- int addOutput(uint64_t data);
- int addOutputUint64(uint64_t data);
- int addOutput(float data);
- int addOutputFloat(float data);
- int addOutput(double data);
- int addOutputDouble(double data);
- int addOutput(struct in_addr &data);
- int addOutput(struct in6_addr &data);
- int addOutput(const char *data);
- int addOutput(const std::string &data);
- int addOutput(const uint8_t *data, uint32_t length);
- int addOutput(const pfc_ipcstdef_t &def, pfc_cptr_t data);
- int addOutput(void);
- int addOutput(key_ctr& data);
- int addOutput(val_ctr& data);
- int addOutput(key_boundary_t& data);
- int addOutput(key_logical_port data);
- int addOutput(val_logical_port& data);
- int addOutput(val_logical_port_st& data);
-
- int getResponse(uint32_t index, int8_t &data);
- int getResponse(uint32_t index, uint8_t &data);
- int getResponse(uint32_t index, int16_t &data);
- int getResponse(uint32_t index, uint16_t &data);
- int getResponse(uint32_t index, int32_t &data);
- int getResponse(uint32_t index, uint32_t &data);
- int getResponse(uint32_t index, int64_t &data);
- int getResponse(uint32_t index, uint64_t &data);
- int getResponse(uint32_t index, float &data);
- int getResponse(uint32_t index, double &data);
- int getResponse(uint32_t index, struct in_addr &data);
- int getResponse(uint32_t index, struct in6_addr &data);
- int getResponse(uint32_t index, const char *&data);
- int getResponse(uint32_t index, const uint8_t *&data, uint32_t &length);
- int getResponse(uint32_t index, const pfc_ipcstdef_t &def,
- pfc_ptr_t datap);
- int getResponse(uint32_t index, key_ctr& data);
- int getResponse(uint32_t index, val_phys_path_fault_alarm_t& data);
- int getResponse(uint32_t index, key_ctr_domain_t& data);
- int getResponse(uint32_t index, key_switch_t& data);
- int getResponse(uint32_t index, key_port_t& data);
- int getResponse(uint32_t index, val_port_st& data);
- int getResponse(uint32_t index, val_switch_st& data);
- int getResponse(uint32_t index, key_link_t& data);
- int getResponse(uint32_t index, val_link_st& data);
- int getResponse(uint32_t index, val_ctr_st& data);
- int getResponse(uint32_t index, val_ctr_domain_st& data);
- int getResponse(uint32_t index, key_logical_port_t& data);
- int getResponse(uint32_t index, val_logical_port_st& data);
- int getResponse(uint32_t index, key_logical_member_port_t& data);
-
- uint32_t getResponseCount(void);
- int getResponseType(uint32_t index, pfc_ipctype_t& type);
-
- int getResponseStructName(uint32_t index, const char *&name);
- int getResponseStructName(uint32_t index, std::string &name);
-
- //stubs
- static void stub_setResponseStructName(uint32_t index, std::string &name);
- static void clearStubData(void);
- static void stub_setResponse(int result);
- static void stub_setResponsetype(uint32_t index,pfc_ipctype_t ipctype );
- static void stub_setClientSessionErrorCode(int result);
- static void stub_setAddOutput(int result);
- static void stub_setAddOutput(uint32_t result);
- static void stub_setAddOutput(const char* data);
- static void stub_setResponseCount(int argCount);
- static void stub_setResponse( uint32_t index,uint32_t value );
- static void stub_setinvoke(pfc_ipcresp_t ipcresp,int err);
-
-private:
- static std::map<uint32_t,pfc_ipctype_t > arg_parameters;
- static std::map<uint32_t,std::string> structNameMap;//<index,structname>
- static std::map<uint32_t,uint32_t> arg_map;
- static std::list<uint32_t> add_output_list;//list of addoutput values
- static int addOutPut_;
- static int responseResult_;
- static int ClientsesErrorCode_;
- static int argCount_;
- static pfc_ipcresp_t ipcresp_;
- static int err_;
- static std::list<const char*> add_output_str;
-};
-
-class IpcEventMask
-{
-
-public:
- /* Create an event mask which contains all IPC event types. */
- IpcEventMask(): _mask(PFC_IPC_EVENT_MASK_FILL) {}
-
- /* Create an event mask which contains the specified IPC event type. */
- explicit IpcEventMask(pfc_ipcevtype_t type)
- : _mask(PFC_IPC_EVENT_MASK_BIT(type)) {}
-
- /* Copy constructor. */
- explicit IpcEventMask(const IpcEventMask &mask) : _mask(mask._mask) {}
-
-
- inline void
- empty(void)
- {
-
- }
-
-
- inline void
- fill(void)
- {
-
- }
-
- inline int
- add(pfc_ipcevtype_t type)
- {
- return 0;
- }
-
- inline int
- remove(pfc_ipcevtype_t type)
- {
- return 0;
- }
-
- inline pfc_bool_t
- test(pfc_ipcevtype_t type) const
- {
- return true;
- }
- inline const pfc_ipcevmask_t *
- getMask(void) const
- {
- return &_mask;
- }
-
-private:
- /* Event mask value. */
- pfc_ipcevmask_t _mask;
-};
-
-class IpcEventAttr
-{
-public:
- IpcEventAttr()
- {
-
- }
-
-
- ~IpcEventAttr()
- {
-
- }
-
-
- inline void
- getHostSet(const char *&name) const
- {
-
-
- }
-
-
- inline int
- setHostSet(const char *name)
- {
- return 0;
- }
-
- inline void
- getTarget(const char *service, IpcEventMask &mask) const
- {
-
-
- }
-
- inline int
- addTarget(const char *service)
- {
- return 0;
- }
-
- inline int
- addTarget(const char *service, const IpcEventMask &mask)
- {
- return 0;
- }
-
-
- inline void
- resetTarget(void)
- {
-
- }
-
- inline void
- getPriority(uint32_t &priority) const
- {
-
- }
-
- inline void
- setPriority(uint32_t priority)
- {
-
- }
-
- inline void
- getLog(pfc_bool_t &log) const
- {
-
- }
-
-
- inline void
- setLog(pfc_bool_t log)
- {
-
- }
-
-private:
- pfc_ipcevattr_t _attr;
-};
-
-class IpcEvent
-{
-public:
- inline pfc_ipcevid_t
- getSerial(void) const
- {
- return pfc_ipcevid_t();
- }
-
- inline pfc_ipcevtype_t
- getType(void) const
- {
- return pfc_ipcevtype_t();
- }
-
- inline void
- getTime(pfc_timespec_t &ts) const
- {
- ts=pfc_timespec_t();
- }
-
- inline const char *
- getChannelName(void) const
- {
- return "channelName";
- }
-
-
- inline const pfc_hostaddr_t *
- getHostAddress(void) const
- {
- pfc_hostaddr_t* host((pfc_hostaddr_t*)malloc(sizeof( pfc_hostaddr_t)));
- return host;
- }
-
- inline const char *
- getServiceName(void) const
- {
- return "serviceName";
- }
-
- inline pfc_ipcsess_t *
- getSession(void) const
- {
- pfc_ipcsess_t* dummy;
- return dummy;
- }
-
- inline pfc_bool_t
- isStateChangeEvent(void) const
- {
- return true;
- }
-
-private:
- explicit IpcEvent(pfc_ipcevent_t *event) : _event(event) {}
- pfc_ipcevent_t *_event;
-};
-
-class IpcEventHandler
-{
-public:
- IpcEventHandler() : _id() {}
- virtual ~IpcEventHandler();
- inline pfc_ipcevhdlr_t
- getId(void) const
- {
- return _id;
- }
-
- virtual void eventHandler(const IpcEvent &event) = 0;
- virtual const char *getName(void);
-
-private:
- pfc_ipcevhdlr_t _id;
-};
-
-extern int add_event_handler(const char *channel, IpcEventHandler *handler,
- const IpcEventAttr *attr = NULL);
-extern int remove_event_handler(pfc_ipcevhdlr_t id);
-static inline int
-remove_event_handler(IpcEventHandler *handler)
-{
- return 0;
-}
-
-}
-}
-}
-#endif /* !_PFCXX_IPC_CLIENT_HH */
+++ /dev/null
-/*
- * Copyright (c) 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 <pfc/ipc.h>
-#include <netinet/in.h>
-#include <string>
-#include <map>
-#include <list>
-#include <vector>
-#include<iostream>
-
-#ifndef _PFCXX_IPC_SERVER_HH
-#define _PFCXX_IPC_SERVER_HH
-
-//#define uint32_t int
-
-
-namespace pfc {
-namespace core {
-namespace ipc {
-
-class ClientSession;
-class ServerCallback;
-class ServerEvent;
-
-/*
- * C++ wrapper for IPC server session instance.
- */
-class ServerSession
-{
- friend class ::pfc::core::ipc::ClientSession;
- friend class ::pfc::core::ipc::ServerEvent;
-
-public:
- /*
- * Constructor.
- */
- ServerSession();
-
- /*
- * Destructor.
- */
- virtual ~ServerSession(){
-
- }
-
- /*
- * Instance methods.
- */
- int setTimeout(const pfc_timespec_t *timeout=NULL);
- int getClientAddress(pfc_ipccladdr_t &claddr);
-
- int addOutput(int8_t data);
- int addOutputInt8(int8_t data);
- int addOutput(uint8_t data);
- int addOutputUint8(uint8_t data);
- int addOutput(int16_t data);
- int addOutputInt16(int16_t data);
- int addOutput(uint16_t data);
- int addOutputUint16(uint16_t data);
- int addOutput(int32_t data);
- int addOutputInt32(int32_t data);
- int addOutput(uint32_t data);
- int addOutputUint32(uint32_t data);
- int addOutput(int64_t data);
- int addOutputInt64(int64_t data);
- int addOutput(uint64_t data);
- int addOutputUint64(uint64_t data);
- int addOutput(float data);
- int addOutputFloat(float data);
- int addOutput(double data);
- int addOutputDouble(double data);
- int addOutput(struct in_addr &data);
- int addOutput(struct in6_addr &data);
- int addOutput(const char *data);
- int addOutput(const std::string &data);
- int addOutput(const uint8_t *data, uint32_t length);
- int addOutput(const pfc_ipcstdef_t &def, pfc_cptr_t data);
- int addOutput(void);
-
- int addOutput(val_ctr_st& data);
- int addOutput(val_ctr_domain_st& data);
- int addOutput(val_logical_port& data);
- int addOutput(val_switch& data);
- int addOutput(val_port& data);
- int addOutput(val_link& data);
- int addOutput(val_boundary_st& data);
- int addOutput(key_ctr& data);
- int addOutput(val_ctr& data);
- int addOutput(key_ctr_domain& data);
- int addOutput(val_ctr_domain& data);
- int addOutput(key_logical_port data);
- int addOutput(val_logical_port_st& data);
- int addOutput(key_logical_member_port data);
- int addOutput(key_switch& data);
- int addOutput(val_switch_st& data);
- int addOutput(key_port data);
- int addOutput(val_port_st& data);
- int addOutput(key_link data);
- int addOutput(val_link_st data);
- int addOutput(key_boundary data);
- int addOutput(val_boundary& data);
- int addOutput(key_root& data);
- int addOutput(val_path_fault_alarm_t& data);
- int addOutput(val_port_st_neighbor& data);
-
- int addOutput(key_vbr_if&);
- int addOutput(pfcdrv_val_vbr_if&);
- int addOutput(key_vbr&);
- int addOutput(val_vbr&);
- int addOutput(key_vtn&);
- int addOutput(val_vtn&);
-
-
- //int addOutput(key_logical_port);
-
-
-
- int getArgument(uint32_t index, int8_t &data);
- int getArgument(uint32_t index, uint8_t &data);
- int getArgument(uint32_t index, int16_t &data);
- int getArgument(uint32_t index, uint16_t &data);
- int getArgument(uint32_t index, int32_t &data);
- int getArgument(uint32_t index, uint32_t &data);
- int getArgument(uint32_t index, int64_t &data);
- int getArgument(uint32_t index, uint64_t &data);
- int getArgument(uint32_t index, float &data);
- int getArgument(uint32_t index, double &data);
- int getArgument(uint32_t index, struct in_addr &data);
- int getArgument(uint32_t index, struct in6_addr &data);
- int getArgument(uint32_t index, const char *&data);
- int getArgument(uint32_t index, const uint8_t *&data, uint32_t &length);
- int getArgument(uint32_t index, const pfc_ipcstdef_t &def,pfc_ptr_t datap);
-
- int getArgument(int index, key_ctr_t& key);
- int getArgument(int index, val_ctr_t& key);
- int getArgument(int index, key_ctr_domain_t& key);
- int getArgument(int index, key_boundary_t& key);
- int getArgument(int index, val_boundary_t& key);
- int getArgument(int index, val_ctr_domain_t& key);
- int getArgument(int index, key_logical_port_t& key);
- int getArgument(int index, val_logical_port_st_t& key);
- int getArgument(int index, key_logical_member_port_t& key);
- int getArgument(int index, key_switch_t& key);
- int getArgument(int index, val_switch_st_t& key);
- int getArgument(int index, key_port_t& key);
- int getArgument(int index, val_port_st_t& key);
- int getArgument(int index, key_link_t& key);
- int getArgument(int index, val_link_st_t& key);
- int getArgument(int, key_vbr_if&);
- int getArgument(int, pfcdrv_val_vbr_if&);
- int getArgument(int, key_vbr&);
- int getArgument(int, val_vbr&);
- int getArgument(int, key_vtn&);
- int getArgument(int, val_vtn&);
-
- uint32_t getArgCount(void);
- int getArgType(uint32_t index, pfc_ipctype_t &type);
- int getArgStructName(uint32_t index, const char *&name);
- int getArgStructName(uint32_t index, std::string &name);
-
- int setCallback(pfc_ipcsrvcb_type_t type, ServerCallback *cbp);
- void unsetCallback(pfc_ipcsrvcb_type_t type);
- void clearCallbacks(void);
-
- //stub functions
- static void stub_setArgCount(uint32_t argCount);
- static void stub_setArgStructName(uint32_t index, std::string &name);
- static void stub_setArgument(int result);
- static void stub_setArgument( uint32_t index,uint32_t value );
- static void clearStubData();
- static void stub_setArgType(uint32_t index, pfc_ipctype_t ipctype);
- static void stub_setAddOutput(int result);
- static void stub_setAddOutput(uint32_t value);
-
-private:
- static std::map<uint32_t,pfc_ipctype_t > arg_parameters;
- static std::map<uint32_t,std::string> structNameMap;
- static std::map<uint32_t,uint32_t> arg_map;
- static std::vector<uint32_t> add_output_list;
- static bool addOutPut_;
- static int result_;
- static uint32_t argCount_;
-};
-
-class ServerEvent
-: public ServerSession
-{
- public:
- ServerEvent(const char *name, pfc_ipcevtype_t type, int &err)
- : ServerSession()
- {
- std::cout<<" ServerEvent(const char *name, pfc_ipcevtype_t type, int &err) "<<std::endl;
- err = serverEventErr_;
- }
-
- ServerEvent(std::string &name, pfc_ipcevtype_t type, int &err)
- : ServerSession()
- {
- std::cout<<" ServerEvent(std::string &name, pfc_ipcevtype_t type, int &err)"<<std::endl;
- err = serverEventErr_;
- }
-
- ServerEvent(uint8_t type, int &err)
- : ServerSession()
- {
- err = serverEventErr_;
- }
-
- ~ServerEvent()
- {
-
- }
-
- inline int
- post(void)
- {
- std::cout<<" post(void) "<<std::endl;
- return postResult_;
- }
-
- inline int
- postTo(pfc_ipccladdr_t &claddr)
- {
-
- return 0;
- }
-
- static void clearStubData();
- static void stub_setserverEventErr(int err);
- static void stub_setPostResult(int result);
-private:
- static int serverEventErr_;
- static int postResult_;
-};
-
-class ServerCallback
-{
-public:
-
- ServerCallback(ServerSession &sess) : _sess(&sess), _refcnt(0) {}
- virtual ~ServerCallback();
- virtual void callback(pfc_ipcsrvcb_type_t type) = 0;
- inline ServerSession &
- getSession(void)
- {
- return *_sess;
- }
-
-private:
- ServerSession *_sess;
- uint32_t _refcnt;
-};
-
-}
-}
-}
-
-#endif /* !_PFCXX_IPC_SERVER_HH */
+++ /dev/null
-/*
- * Copyright (c) 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 _PFCXX_MODULE_HH
-#define _PFCXX_MODULE_HH
-
-#include <pfc/module.h>
-#include <pfc/log.h>
-#include <cxx/pfcxx/conf.hh>
-#include <cxx/pfcxx/event.hh>
-#include<string>
-#include "cxx/pfcxx/ipc_client.hh"
-
-
-namespace pfc {
-namespace core {
-
-class Module {
- public:
- explicit Module(const pfc_modattr_t *attr) {
- }
- virtual ~Module(void) {
- }
-
- static Module *getInstance(const char *name) {
- return getModule(name);
- }
-
- static Module *getInstanceByType(const char *tname) {
- return capaModule;
- }
-
- static inline pfc_bool_t
- isModuleEvent(Event *eobj) {
- return true;
- }
-
-
- static inline const char *
- getEventSender(Event *eobj) {
- return "Event";
- }
-
- virtual pfc_bool_t init(void)= 0;
-
- virtual pfc_bool_t fini(void)= 0;
-
- template <class T>
-inline void getInstance(T *&ptr) {
- Module *m(Module::getInstanceByType(typeid(ptr).name()));
-
- ptr = static_cast<T *>(m);
-}
-
-inline const char *name(void) const {
- return _attr->pma_name;
-}
-
-inline std::string getName(void) const {
- return _name;
-}
-
-inline pfc_module_t getModuleId(void) const {
- return _module;
-}
-
-inline uint8_t getVersion(void) const {
- return _attr->pma_version;
-}
-
-
-inline uint8_t getSystemVersion(void) const {
- return _attr->pma_sysversion;
-}
-
-
-inline const pfc_modattr_t *getAttribute(void) const {
- return _attr;
-}
-
-
-inline int
-reloadConf(void) {
- return 0;
-}
-
-inline int
-addEventHandler(pfc_evhandler_t &id, event_handler_t &handler,
- uint32_t priority ,
- const char *hname = PFC_LOG_IDENT) {
- return 0;
-}
-
-inline int
-addEventHandler(pfc_evhandler_t &id, event_handler_t &handler,
- EventMask &mask,
- uint32_t priority,
- const char *hname = PFC_LOG_IDENT) {
- return 0;
-}
-
-inline int
-removeEventHandler(pfc_evhandler_t id,
- const pfc_timespec_t *timeout = NULL) {
- return 0;
-}
-
-inline int postEvent(const char* /*target*/, pfc_evtype_t /*type*/) {
- return 0;
-}
-
-inline int
-postEvent(std::string &target, pfc_evtype_t type) {
- return 0;
-}
-
-inline int addIpcEventHandler(const char* /*channel*/,
- ipc::IpcEventHandler* /**handler*/,
- const ipc::IpcEventAttr *attr = NULL) {
- return 0;
-}
-
-int removeIpcEventHandler(pfc_ipcevhdlr_t /*id*/) {
- return 0;
-}
-
-inline int
-removeIpcEventHandler(ipc::IpcEventHandler* /**handler*/) {
- return 0;
-}
-virtual pfc_ipcresp_t ipcService(ipc::ServerSession&, pfc_ipcid_t) {
- return pfc_ipcresp_t();
-}
-
-static Module* getModule(const char* moduleName);
-
- private:
-const pfc_modattr_t *_attr;
-std::string _name;
-pfc_module_t _module;
-
- protected:
-static Module* capaModule;
-static Module* tcLib;
-};
-
-class ModuleConfBlock {
- public:
- /*
- * Create a block handle instance associated with a parameter block
- * in the module configuration file, specified by the block name.
- */
- explicit ModuleConfBlock(const char *bname)
- {}
-
- explicit ModuleConfBlock(const std::string &bname)
- {}
-
- /*
- * Create a block handle instance associated with a parameter map block
- * in the module configuration file, specified by the map name and its key.
- */
- ModuleConfBlock(const char *mname, const char *key)
- {}
-
- ModuleConfBlock(const std::string &mname, const std::string &key)
- {}
- inline uint8_t
- getByte(const char *name, uint8_t defvalue) {
- return static_cast<uint8_t>(0);
- }
-
- inline uint8_t
- getByte(const std::string &name, uint8_t defvalue) {
- return static_cast<uint8_t>(0);
- }
-
- /*
- * Return a C-styled string value.
- */
- inline const char *
- getString(const char *name, const char *defvalue) {
- return "dummy";
- }
-
- inline const char *
- getString(const std::string &name, const char *defvalue) {
- return "dummy";
- }
- inline int
- arraySize(const char *name) {
- return 0;
- }
-
- inline int
- arraySize(const std::string &name) {
- return 0;
- }
-
- inline uint32_t
- getUint32(const char *name, uint32_t defvalue) {
- return static_cast<uint32_t>(0);
- }
-
- inline uint32_t
- getUint32(const std::string &name, uint32_t defvalue) {
- return static_cast<uint32_t>(0);
- }
-
- inline uint8_t
- getByteAt(const char *name, uint32_t index, uint8_t defvalue) {
- return static_cast<uint8_t>(0);
- }
-
- inline uint8_t
- getByteAt(const std::string &name, uint32_t index, uint8_t defvalue) {
- return static_cast<uint8_t>(0);
- }
- inline uint32_t
- getBlock(void) const {
- return static_cast<uint32_t>(0);
- }
-};
-
-extern pfc_module_t module_register(const pfc_modattr_t *mattr,
- pfc_modfac_t factory,
- const char *tname);
-#define PFC_MODULE_IPC_DECL(module_classi, physical)
-
-} // namespace core
-} // namespace pfc
-#endif
-
+++ /dev/null
-/*
- * Copyright (c) 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 ODC_LOG_HH_
-#define ODC_LOG_HH_
-#include <string.h>
-
-#include "pfc/log.h"
-
-#define FILESTR (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
-
-#define ODC_LOG(level, fmt, ...) do { \
- pfc_log_##level("%s:%d:%s: " fmt, FILESTR, __LINE__, \
- __FUNCTION__, ##__VA_ARGS__); \
-} while (0);
-
-#ifdef PFC_VERBOSE_DEBUG
-class LogFuncTrace {
- public:
- inline LogFuncTrace(const char *file_name, int line_no, const char *fn_name) {
- file_ = file_name;
- line_ = line_no;
- func_ = fn_name;
- pfc_log_trace("%s:%d: Entering function %s", file_, line_, func_);
- }
- inline ~LogFuncTrace() {
- pfc_log_trace("%s:%d: Leaving function %s", file_, line_, func_);
- }
- const char *file_, *func_;
- int line_;
-};
-
-#define ODC_FUNC_TRACE \
- LogFuncTrace func_trace___(FILESTR, __LINE__, __FUNCTION__);
-#else
-#define ODC_FUNC_TRACE
-#endif // ODC_VERBOSE_DEBUG
-
-#endif // ODC_LOG_HH_
+++ /dev/null
-/*
- * Copyright (c) 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
- */
-
-/*
- * C++ utilities for PFC IPC client.
- */
-
-#include <string>
-#include <pfc/ipc.h>
-#include <pfcxx/ipc_client.hh>
-#include <iostream>
-#include <pfc/ipc_client.h>
-
-namespace pfc {
-namespace core {
-namespace ipc {
-
-std::map<uint32_t,pfc_ipctype_t > ClientSession::arg_parameters;
-std::map<uint32_t,std::string> ClientSession::structNameMap;
-std::map<uint32_t,uint32_t> ClientSession::arg_map;
-std::list<uint32_t> ClientSession::add_output_list;
-int ClientSession::addOutPut_;
-int ClientSession::responseResult_;
-int ClientSession::ClientsesErrorCode_;
-int ClientSession::argCount_;
-pfc_ipcresp_t ClientSession::ipcresp_;
-int ClientSession::err_;
-std::list<const char*> ClientSession::add_output_str;
-
-
-ClientSession::ClientSession(const char* /*name*/, pfc_ipcid_t /*service*/, int &err)
-{
- err = 0;
-}
-
-
-ClientSession::ClientSession(const char* /*name*/, pfc_ipcid_t /*service*/, int &err,
- uint32_t /*flags*/)
-{
- err = 0;
-}
-
-ClientSession::ClientSession(const std::string& /*name*/, pfc_ipcid_t /*service*/,
- int &err)
-{
- err = 0;
-}
-
-ClientSession::ClientSession(const std::string& /*name*/, pfc_ipcid_t /*service*/,
- int &err, uint32_t /*flags*/)
-{
- err = 0;
-}
-
-ClientSession::ClientSession(pfc_ipcconn_t /*conn*/, const char* /*name*/,
- pfc_ipcid_t service, int &err)
-{
- if(service > 0 && service <=3 )
- {
- err = 0;
- } else { err = 1; }
-}
-
-ClientSession::ClientSession(pfc_ipcconn_t /*conn*/, const char* /*name*/,
- pfc_ipcid_t /*service*/, int &err, uint32_t /*flags*/)
-{
- err = 0;
-}
-
-ClientSession::ClientSession(pfc_ipcconn_t /*conn*/, const std::string& /*name*/,
- pfc_ipcid_t /*service*/, int &err)
-{
- err = 0;
-}
-
-
-ClientSession::ClientSession(pfc_ipcconn_t /*conn*/, const std::string& /*name*/,
- pfc_ipcid_t /*service*/, int &err, uint32_t /*flags*/)
-{
- err = 0;
-}
-
-void
-ClientSession::stub_setClientSessionErrorCode(int result)
-{
- ClientsesErrorCode_ = result;
-}
-
-
-ClientSession::ClientSession()
-{
-}
-
-ClientSession::ClientSession(pfc_ipcsess_t *sess)
-{
-}
-
-/*
- * Destructor of the IPC client session instance.
- */
-
-ClientSession::~ClientSession()
-{
- arg_parameters.clear();
-}
-
-int
-ClientSession::reset(const char* /*name*/, pfc_ipcid_t /*service*/)
-{
- return 0;
-}
-
-int
-ClientSession::reset(const std::string& /*name*/, pfc_ipcid_t /*service*/)
-{
- return 0;
-}
-
-int
-ClientSession::setTimeout(const pfc_timespec_t* /*timeout*/)
-{
- return 0;
-}
-
-int
-ClientSession::invoke(pfc_ipcresp_t& response)
-{
- response=ipcresp_;
- return err_;
-}
-
-void ClientSession::stub_setinvoke(pfc_ipcresp_t ipcresp,int err)
-{
- ipcresp_=ipcresp;
- err_=err;
-}
-int
-ClientSession::cancel(pfc_bool_t /*discard*/)
-{
- return 0;
-}
-
-int
-ClientSession::forward(ClientSession &sess, uint32_t begin, uint32_t end)
-{
- return 0;
-}
-
-int
-ClientSession::forward(ServerSession &sess, uint32_t begin, uint32_t end)
-{
- return 0;
-}
-
-int
-ClientSession::forwardTo(ServerSession &sess, uint32_t begin, uint32_t end)
-{
- return 0;
-}
-
-// Signed 8-bit value.
-int
-ClientSession::addOutput(int8_t /*data*/)
-{
- return addOutPut_;
-}
-int
-ClientSession::addOutput(void)
-{
- return addOutPut_;
-}
-int
-ClientSession::addOutputInt8(int8_t /*data*/)
-{
- return addOutPut_;
-}
-
-// Unsigned 8-bit value.
-int
-ClientSession::addOutput(uint8_t /*data*/)
-{
- return addOutPut_;
-}
-
-int
-ClientSession::addOutputUint8(uint8_t /*data*/)
-{
- return addOutPut_;
-}
-
-// Signed 16-bit value.
-int
-ClientSession::addOutput(int16_t /*data*/)
-{
- return addOutPut_;
-}
-
-int
-ClientSession::addOutputInt16(int16_t /*data*/)
-{
- return addOutPut_;
-}
-
-// Unsigned 16-bit value.
-int
-ClientSession::addOutput(uint16_t /*data*/)
-{
- return addOutPut_;
-}
-
-int
-ClientSession::addOutputUint16(uint16_t /*data*/)
-{
- return addOutPut_;
-}
-
-// Signed 32-bit value.
-int
-ClientSession::addOutput(int32_t /*data*/)
-{
- return addOutPut_;
-}
-
-int
-ClientSession::addOutputInt32(int32_t /*data*/)
-{
- return addOutPut_;
-}
-
-// Unsigned 32-bit value.
-int
-ClientSession::addOutput(uint32_t data)
-{
- for (std::list<uint32_t>::iterator it=add_output_list.begin(); it != add_output_list.end(); ++it)
- {
- uint32_t data_l = *it;
- if( data == data_l )
- {
- return 0;
- }
- }
- return 1;
-}
-
-
-int
-ClientSession::addOutput(key_ctr&)
-{
- return addOutPut_;
-}
-
-int
-ClientSession::addOutput(val_ctr&)
-{
- return addOutPut_;
-}
-
-int
-ClientSession::addOutput(key_boundary_t&)
-{
- return addOutPut_;
-}
-
-int
-ClientSession::addOutput(key_logical_port)
-{
- return addOutPut_;
-}
-
-int
-ClientSession::addOutput(val_logical_port&)
-{
- return addOutPut_;
-}
-
-int
-ClientSession::addOutput(val_logical_port_st&)
-{
- return addOutPut_;
-}
-
-void
-ClientSession::stub_setAddOutput(uint32_t data)
-{
- add_output_list.push_front(data);
-}
-
-
-int
-ClientSession::addOutputUint32(uint32_t /*data*/)
-{
- return addOutPut_;
-}
-
-// Signed 64-bit value.
-int
-ClientSession::addOutput(int64_t /*data*/)
-{
- return addOutPut_;
-}
-
-int
-ClientSession::addOutputInt64(int64_t /*data*/)
-{
- return addOutPut_;
-}
-
-// Unsigned 64-bit value.
-int
-ClientSession::addOutput(uint64_t /*data*/)
-{
- return addOutPut_;
-}
-
-int
-ClientSession::addOutputUint64(uint64_t /*data*/)
-{
- return addOutPut_;
-}
-
-// Single precision floating point.
-int
-ClientSession::addOutput(float /*data*/)
-{
- return addOutPut_;
-}
-
-int
-ClientSession::addOutputFloat(float /*data*/)
-{
- return addOutPut_;
-}
-
-// Double precision floating point.
-int
-ClientSession::addOutput(double /*data*/)
-{
- return addOutPut_;
-}
-
-int
-ClientSession::addOutputDouble(double /*data*/)
-{
- return addOutPut_;
-}
-
-// IPv4 address.
-int
-ClientSession::addOutput(struct in_addr& /*data*/)
-{
- return addOutPut_;
-}
-
-// IPv6 address.
-int
-ClientSession::addOutput(struct in6_addr& /*data*/)
-{
- return addOutPut_;
-}
-
-// String. (pointer)
-int
-ClientSession::addOutput(const char* data)
-{
- for (std::list<const char*>::iterator it=add_output_str.begin(); it != add_output_str.end(); ++it)
- {
- const char* data_l = *it;
- std::string str(data);
- if( 0 == str.compare(data_l) )
- {
- return 0;
- }
- }
- return 1;
-}
-
-
-void ClientSession::stub_setAddOutput(const char* data)
-{
- add_output_str.push_front(data);
-}
-
-// String. (std::string)
-int
-ClientSession::addOutput(const std::string& /*data*/)
-{
- return addOutPut_;
-}
-
-// Binary data.
-int
-ClientSession::addOutput(const uint8_t* /**data*/, uint32_t /*length*/)
-{
- return addOutPut_;
-}
-
-// IPC structure specified by pfc_ipcstdef_t.
-int
-ClientSession::addOutput(const pfc_ipcstdef_t& /*def*/, pfc_cptr_t /*data*/)
-{
- return addOutPut_;
-}
-
-void
-ClientSession::stub_setAddOutput( int result)
-{
- addOutPut_ = result;
-}
-
-// Signed 8-bit integer.
-int
-ClientSession::getResponse(uint32_t /*index*/, int8_t& /*data*/)
-{
- return responseResult_;
-}
-
-// Unsigned 8-bit integer.
-int
-ClientSession::getResponse(uint32_t /*index*/, uint8_t& /*data*/)
-{
- return responseResult_;
-}
-
-// Signed 16-bit integer.
-int
-ClientSession::getResponse(uint32_t /*index*/, int16_t& /*data*/)
-{
- return responseResult_;
-}
-
-// Unsigned 16-bit integer.
-int
-ClientSession::getResponse(uint32_t /*index*/, uint16_t& /*data*/)
-{
- return responseResult_;
-}
-
-// Signed 32-bit integer.
-int
-ClientSession::getResponse(uint32_t /*index*/, int32_t& /*data*/)
-{
- return responseResult_;
-}
-
-// Unsigned 32-bit integer.
-int
-ClientSession::getResponse(uint32_t index, uint32_t& data)
-{
- if (0 != arg_map.count(index))
- {
- data = arg_map[index];
- return 0;
- }
- return 1;
-}
-
-// Signed 64-bit integer.
-int
-ClientSession::getResponse(uint32_t /*index*/, int64_t& /*data*/)
-{
- return responseResult_;
-}
-
-// Unsigned 64-bit integer.
-int
-ClientSession::getResponse(uint32_t /*index*/, uint64_t& /*data*/)
-{
- return responseResult_;
-}
-
-// Single precision floating point.
-int
-ClientSession::getResponse(uint32_t /*index*/, float& /*data*/)
-{
- return responseResult_;
-}
-
-// Double precision floating point.
-int
-ClientSession::getResponse(uint32_t /*index*/, double& /*data*/)
-{
- return responseResult_;
-}
-
-// IPv4 address.
-int
-ClientSession::getResponse(uint32_t /*index*/, struct in_addr& /*data*/)
-{
- return responseResult_;
-}
-
-// IPv6 address.
-int
-ClientSession::getResponse(uint32_t /*index*/, struct in6_addr& /*data*/)
-{
- return responseResult_;
-}
-
-int
-ClientSession::getResponse(uint32_t /*index*/, const char*& /*data*/)
-{
- return responseResult_;
-}
-
-int
-ClientSession::getResponse(uint32_t /*index*/, const uint8_t*& /*data*/,
- uint32_t& /*length*/)
-{
- return responseResult_;
-}
-
-int
-ClientSession::getResponse(uint32_t /*index*/, const pfc_ipcstdef_t& /*def*/,
- pfc_ptr_t /*datap*/)
-{
- return responseResult_;
-}
-int
-ClientSession::getResponse(uint32_t /*index*/, key_ctr& /*data*/)
-{
- return responseResult_;
-}
-int
-ClientSession::getResponse(uint32_t /*index*/, val_phys_path_fault_alarm_t& /*data*/) {
- return responseResult_;
-}
-int
-ClientSession::getResponse(uint32_t /*index*/, key_ctr_domain_t& /*data*/) {
- return responseResult_;
-}
-int
-ClientSession::getResponse(uint32_t /*index*/, key_switch_t& /*data*/) {
- return responseResult_;
-}
-int
-ClientSession::getResponse(uint32_t /*index*/, key_port_t& /*data*/) {
- return responseResult_;
-}
-int
-ClientSession::getResponse(uint32_t /*index*/, val_port_st& /*data*/) {
- return responseResult_;
-}
-int
-ClientSession::getResponse(uint32_t /*index*/, val_switch_st& /*data*/) {
- return responseResult_;
-}
-int
-ClientSession::getResponse(uint32_t /*index*/, key_link_t& /*data*/) {
- return responseResult_;
-}
-int
-ClientSession::getResponse(uint32_t /*index*/, val_link_st& /*data*/) {
- return responseResult_;
-}
-int
-ClientSession::getResponse(uint32_t /*index*/, val_ctr_st& /*data*/) {
- return responseResult_;
-}
-int
-ClientSession::getResponse(uint32_t /*index*/, val_ctr_domain_st& /*data*/) {
- return responseResult_;
-}
-int
-ClientSession::getResponse(uint32_t /*index*/, key_logical_port_t& /*data*/) {
- return responseResult_;
-}
-int
-ClientSession::getResponse(uint32_t /*index*/, val_logical_port_st& /*data*/) {
- return responseResult_;
-}
-int
-ClientSession::getResponse(uint32_t /*index*/, key_logical_member_port_t& /*data*/) {
- return responseResult_;
-}
-
-void
-ClientSession::stub_setResponse(int result) {
- responseResult_ = result;
-}
-
-void
-ClientSession::stub_setResponse( uint32_t index,uint32_t value ) {
- arg_map.insert(std::make_pair(index,value) );
-}
-
-uint32_t
-ClientSession::getResponseCount(void) {
- return argCount_ ;
-}
-
-void
-ClientSession::stub_setResponseCount(int argCount) {
- argCount_=argCount;
-}
-
-int
-ClientSession::getResponseType(uint32_t index, pfc_ipctype_t& type) {
- if (0 != arg_parameters.count(index)) {
- type = arg_parameters[index];
- return 0;
- }
- return 1;
-}
-
-void
-ClientSession::stub_setResponsetype(uint32_t index,pfc_ipctype_t ipctype ) {
- arg_parameters.insert(std::make_pair(index,ipctype) );
-}
-
-int
-ClientSession::getResponseStructName(uint32_t index, const char*& name) {
- if (0 != structNameMap.count(index)) {
- name = structNameMap[index].c_str();
- return 0;
- }
- return 1;
-}
-
-int
-ClientSession::getResponseStructName(uint32_t index, std::string& name) {
- if (0 != structNameMap.count(index)) {
- name = structNameMap[index];
- return 0;
- }
- return 1;
-}
-
-void
-ClientSession::stub_setResponseStructName(uint32_t index, std::string& name) {
- structNameMap.insert(std::make_pair(index,name));
-}
-
-void
-ClientSession::clearStubData(void) {
- arg_parameters.clear();
- structNameMap.clear();
- arg_map.clear();
- add_output_list.clear();
- add_output_str.clear();
-}
-} // ipc
-} // core
-} // pfc
+++ /dev/null
-/*
- * Copyright (c) 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
- */
-
-/*
- * C++ utilities for PFC IPC server.
- */
-
-#include <string>
-#include <pfc/ipc.h>
-#include <pfcxx/ipc_server.hh>
-#include <iostream>
-
-namespace pfc {
-namespace core {
-namespace ipc {
-
-std::map<uint32_t,pfc_ipctype_t > ServerSession::arg_parameters;
-std::map<uint32_t,std::string> ServerSession::structNameMap;
-std::map<uint32_t,uint32_t> ServerSession::arg_map;
-std::vector<uint32_t> ServerSession::add_output_list;
-bool ServerSession::addOutPut_;
-int ServerSession::result_;
-uint32_t ServerSession::argCount_;
-
-
-ServerSession::ServerSession()
-{
-
-}
-
-int
-ServerSession::setTimeout(const pfc_timespec_t* /*timeout*/)
-{
- return 0;
-}
-
-int
-ServerSession::getClientAddress(pfc_ipccladdr_t& /*&claddr*/)
-{
- return 0;
-}
-
-// Signed 8-bit value.
-int
-ServerSession::addOutput(int8_t /*data*/)
-{
- return addOutPut_;
-}
-
-int
-ServerSession::addOutput( )
-{
- return addOutPut_;
-}
-
-int
-ServerSession::addOutputInt8(int8_t /*data*/)
-{
- return addOutPut_;
-}
-
-// Unsigned 8-bit value.
-int
-ServerSession::addOutput(uint8_t /*data*/)
-{
- return addOutPut_;
-}
-
-int
-ServerSession::addOutputUint8(uint8_t /*data*/)
-{
- return addOutPut_;
-}
-
-// Signed 16-bit value.
-int
-ServerSession::addOutput(int16_t /*data*/)
-{
- return addOutPut_;
-}
-
-int
-ServerSession::addOutputInt16(int16_t /*data*/)
-{
- return addOutPut_;
-}
-
-// Unsigned 16-bit value.
-int
-ServerSession::addOutput(uint16_t /*data*/)
-{
- return addOutPut_;
-}
-
-int
-ServerSession::addOutputUint16(uint16_t /*data*/)
-{
- return addOutPut_;
-}
-
-// Signed 32-bit value.
-int
-ServerSession::addOutput(int32_t /*data*/)
-{
- return addOutPut_;
-}
-
-int
-ServerSession::addOutputInt32(int32_t /*data*/)
-{
- return addOutPut_;
-}
-
-// Unsigned 32-bit value.
-int
-ServerSession::addOutput(uint32_t data)
-{
- for (std::vector<uint32_t>::iterator it=add_output_list.begin(); it != add_output_list.end(); ++it)
- {
- if( data == *it )
- {
- return 0;
- }
- }
- return 1;
-
-}
-
-void
-ServerSession::stub_setAddOutput(uint32_t data)
-{
- add_output_list.push_back(data);
-}
-
-int
-ServerSession::addOutputUint32(uint32_t /*data*/)
-{
- return addOutPut_;
-}
-
-// Signed 64-bit value.
-int
-ServerSession::addOutput(int64_t /*data*/)
-{
- return addOutPut_;
-}
-
-int
-ServerSession::addOutputInt64(int64_t /*data*/)
-{
- return addOutPut_;
-}
-
-// Unsigned 64-bit value.
-int
-ServerSession::addOutput(uint64_t /*data*/)
-{
- return addOutPut_;
-}
-
-int
-ServerSession::addOutputUint64(uint64_t /*data*/)
-{
- return addOutPut_;
-}
-
-// Single precision floating point.
-int
-ServerSession::addOutput(float /*data*/)
-{
- return addOutPut_;
-}
-
-int
-ServerSession::addOutputFloat(float /*data*/)
-{
- return addOutPut_;
-}
-
-// Double precision floating point.
-int
-ServerSession::addOutput(double /*data*/)
-{
- return addOutPut_;
-}
-
-int
-ServerSession::addOutputDouble(double /*data*/)
-{
- return addOutPut_;
-}
-
-// IPv4 address.
-int
-ServerSession::addOutput(struct in_addr& /*data*/)
-{
- return addOutPut_;
-}
-
-// IPv6 address.
-int
-ServerSession::addOutput(struct in6_addr& /*data*/)
-{
- return addOutPut_;
-}
-
-// String. (pointer)
-int
-ServerSession::addOutput(const char* /*data*/)
-{
- return addOutPut_;
-}
-
-// String. (std::string)
-int
-ServerSession::addOutput(const std::string& /*data*/)
-{
- return addOutPut_;
-}
-
-// Binary data.
-int
-ServerSession::addOutput(const uint8_t* /*data*/, uint32_t /*length*/)
-{
- return addOutPut_;
-}
-
-// IPC structure specified by pfc_ipcstdef_t.
-int
-ServerSession::addOutput(const pfc_ipcstdef_t& /*def*/, pfc_cptr_t /*data*/)
-{
- return addOutPut_;
-}
-
-
-int
-ServerSession::addOutput(val_ctr_st&)
-{
- return addOutPut_;
-}
-
-int
-ServerSession::addOutput(val_ctr_domain_st&)
-{
- return addOutPut_;
-}
-
-int
-ServerSession::addOutput(val_logical_port&)
-{
- return addOutPut_;
-}
-
-int
-ServerSession::addOutput(val_switch&)
-{
- return addOutPut_;
-}
-int
-ServerSession::addOutput(val_port&)
-{
- return addOutPut_;
-}
-int
-ServerSession::addOutput(val_link&)
-{
- return addOutPut_;
-}
-int
-ServerSession::addOutput(val_boundary_st&)
-{
- return addOutPut_;
-}
-int
-ServerSession::addOutput(key_ctr&)
-{
- return addOutPut_;
-}
-int
-ServerSession::addOutput(val_ctr&)
-{
- return addOutPut_;
-}
-int
-ServerSession::addOutput(key_ctr_domain&)
-{
- return addOutPut_;
-}
-int
-ServerSession::addOutput(val_ctr_domain&)
-{
- return addOutPut_;
-}
-int
-ServerSession::addOutput(key_logical_port)
-{
- return addOutPut_;
-}
-int
-ServerSession::addOutput(val_logical_port_st&)
-{
- return addOutPut_;
-}
-int
-ServerSession::addOutput(key_logical_member_port)
-{
- return addOutPut_;
-}
-int
-ServerSession::addOutput(key_switch&)
-{
- return addOutPut_;
-}
-int
-ServerSession::addOutput(val_switch_st&)
-{
- return addOutPut_;
-}
-int
-ServerSession::addOutput(key_port)
-{
- return addOutPut_;
-}
-int
-ServerSession::addOutput(val_port_st&)
-{
- return addOutPut_;
-}
-int
-ServerSession::addOutput(key_link)
-{
- return addOutPut_;
-}
-int
-ServerSession::addOutput(val_link_st)
-{
- return addOutPut_;
-}
-int
-ServerSession::addOutput(key_boundary)
-{
- return addOutPut_;
-}
-int
-ServerSession::addOutput(val_boundary&)
-{
- return addOutPut_;
-}
-int
-ServerSession::addOutput(key_root&)
-{
- return addOutPut_;
-}
-int
-ServerSession::addOutput(val_path_fault_alarm_t&)
-{
- return addOutPut_;
-}
-int
-ServerSession::addOutput(val_port_st_neighbor&)
-{
- return addOutPut_;
-}
-
-int ServerSession:: addOutput(key_vbr_if&) {
- return addOutPut_;
-}
-int ServerSession::addOutput(pfcdrv_val_vbr_if&) {
- return addOutPut_;
-
-}
-int ServerSession::addOutput(key_vbr&) {
- return addOutPut_;
-
-}
-int ServerSession::addOutput(val_vbr&) {
- return addOutPut_;
-
-}
-int ServerSession::addOutput(key_vtn&) {
- return addOutPut_;
-
-}
-int ServerSession::addOutput(val_vtn&) {
- return addOutPut_;
-
-}
-
-void
-ServerSession::stub_setAddOutput(int result)
-{
- addOutPut_ = result;
-}
-// Signed 8-bit integer.
-int
-ServerSession::getArgument(uint32_t /*index*/, int8_t& /*&data*/)
-{
- return result_;
-}
-
-// Unsigned 8-bit integer.
-int
-ServerSession::getArgument(uint32_t /*index*/, uint8_t& /*data*/)
-{
- return result_;
-}
-
-// Signed 16-bit integer.
-int
-ServerSession::getArgument(uint32_t /*index*/, int16_t& /*&data*/)
-{
- return result_;
-}
-
-// Unsigned 16-bit integer.
-int
-ServerSession::getArgument(uint32_t /*index*/, uint16_t& /*&data*/)
-{
- return result_;
-}
-
-// Signed 32-bit integer.
-int
-ServerSession::getArgument(uint32_t /*index*/, int32_t& /*&data*/)
-{
- return result_;
-}
-
-// Unsigned 32-bit integer.
-int
-ServerSession::getArgument(uint32_t index, uint32_t &data)
-{
- if (0 != arg_map.count(index))
- {
- data = arg_map[index];
- return 0;
- }
- return 1;
-}
-
-// Signed 64-bit integer.
-int
-ServerSession::getArgument(uint32_t /*index*/, int64_t& /*data*/)
-{
- return result_;
-}
-
-// Unsigned 64-bit integer.
-int
-ServerSession::getArgument(uint32_t /*index*/, uint64_t& /*data*/)
-{
- return result_;
-}
-
-// Single precision floating point.
-int
-ServerSession::getArgument(uint32_t /*index*/, float& /*data*/)
-{
- return result_;
-}
-
-// Double precision floating point.
-int
-ServerSession::getArgument(uint32_t /*index*/, double& /*data*/)
-{
- return result_;
-}
-
-// IPv4 address.
-int
-ServerSession::getArgument(uint32_t /*index*/, struct in_addr& /*data*/)
-{
- return result_;
-}
-
-// IPv6 address.
-int
-ServerSession::getArgument(uint32_t /*index*/, struct in6_addr& /*data*/)
-{
- return result_;
-}
-
-int
-ServerSession::getArgument(uint32_t /*index*/, const char*& /*data*/)
-{
- return result_;
-}
-
-
-int
-ServerSession::getArgument(uint32_t /*index*/, const uint8_t*& /*data*/,
- uint32_t& /*length*/)
-{
- return result_;
-}
-
-int
-ServerSession::getArgument(uint32_t /*index*/, const pfc_ipcstdef_t& /*def*/,
- pfc_ptr_t /*datap*/)
-{
- return result_;
-}
-int
-ServerSession::getArgument(int /*index*/, key_ctr_t& /*data*/)
-{
- return result_;
-}
-int
-ServerSession::getArgument(int /*index*/, val_ctr_t& /*data*/)
-{
- return result_;
-}
-int
-ServerSession::getArgument(int /*index*/, key_ctr_domain_t& /*data*/)
-{
- return result_;
-}
-int
-ServerSession::getArgument(int /*index*/, key_boundary_t& /*data*/)
-{
- return result_;
-}
-int
-ServerSession::getArgument(int /*index*/, val_boundary_t& /*data*/)
-{
- return result_;
-}
-int
-ServerSession::getArgument(int /*index*/, val_ctr_domain_t& /*data*/)
-{
- return result_;
-}
-int
-ServerSession::getArgument(int /*index*/, key_logical_port_t& /*data*/)
-{
- return result_;
-}
-int
-ServerSession::getArgument(int /*index*/, val_logical_port_st_t& /*data*/)
-{
- return result_;
-}
-int
-ServerSession::getArgument(int /*index*/, key_logical_member_port_t& /*data*/)
-{
- return result_;
-}
-int
-ServerSession::getArgument(int /*index*/, key_switch_t& /*data*/)
-{
- return result_;
-}
-int
-ServerSession::getArgument(int /*index*/, val_switch_st_t& /*data*/)
-{
- return result_;
-}
-int
-ServerSession::getArgument(int /*index*/, key_port_t& /*data*/)
-{
- return result_;
-}
-int
-ServerSession::getArgument(int /*index*/, val_port_st_t& /*data*/)
-{
- return result_;
-}
-int
-ServerSession::getArgument(int /*index*/, key_link_t& /*data*/)
-{
- return result_;
-}
-int
-ServerSession::getArgument(int /*index*/, val_link_st_t& /*data*/)
-{
- return result_;
-}
-
-
-
-int ServerSession:: getArgument(int, key_vbr_if&) {
- return result_;
-}
-int ServerSession::getArgument(int, pfcdrv_val_vbr_if&) {
- return result_;
-
-}
-int ServerSession::getArgument(int, key_vbr&) {
- return result_;
-
-}
-int ServerSession::getArgument(int, val_vbr&) {
- return result_;
-
-}
-int ServerSession::getArgument(int, key_vtn&) {
- return result_;
-
-}
-int ServerSession::getArgument(int, val_vtn&) {
- return result_;
-
-}
-
-void
-ServerSession::stub_setArgument( uint32_t index,uint32_t value )
-{
- arg_map.insert(std::make_pair(index,value) );
-}
-
-void
-ServerSession::stub_setArgument(int result)
-{
- result_= result;
-}
-
-uint32_t
-ServerSession::getArgCount(void)
-{
- return argCount_;
-}
-
-void
-ServerSession::stub_setArgCount(uint32_t argCount)
-{
- argCount_ = argCount ;
-}
-
-int
-ServerSession::getArgType(uint32_t index, pfc_ipctype_t& type)
-{
- if (0 != arg_parameters.count(index))
- {
- type =arg_parameters[index];
- return 0;
- }
- return 1;
-}
-
-void
-ServerSession::stub_setArgType(uint32_t index,pfc_ipctype_t ipctype )
-{
- arg_parameters.insert(std::make_pair(index,ipctype) );
-}
-
-int
-ServerSession::getArgStructName(uint32_t index, const char*& name)
-{
- if (0 != structNameMap.count(index))
- {
- name = structNameMap[index].c_str();
- return 0;
- }
- return 1;
-}
-
-int
-ServerSession::getArgStructName(uint32_t index, std::string &name)
-{
- if (0 != structNameMap.count(index))
- {
- name = structNameMap[index];
- return 0;
- }
- return 1;
-}
-
-void
-ServerSession::stub_setArgStructName(uint32_t index, std::string &name)
-{
- structNameMap.insert(std::make_pair(index,name));
-}
-
-void
-ServerSession::unsetCallback(pfc_ipcsrvcb_type_t type)
-{
-
-}
-
-void
-ServerSession::clearCallbacks(void)
-{
-
-}
-void
-ServerSession::clearStubData(void)
-{
- arg_parameters.clear();
- structNameMap.clear();
- arg_map.clear();
- add_output_list.clear();
-}
-
-int ServerEvent::serverEventErr_=0;
-int ServerEvent::postResult_=1;
-
-void ServerEvent::stub_setserverEventErr(int err)
-{
- serverEventErr_ = err;
-}
-
-void ServerEvent::clearStubData()
-{
- ServerSession::clearStubData();
-}
-
-void ServerEvent::stub_setPostResult(int result)
-{
- postResult_=result;
-}
-
-}
-}
-}
-
+++ /dev/null
-/*
- * Copyright (c) 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 <cxx/pfcxx/module.hh>
-
-namespace pfc {
-namespace core {
-
-Module* Module::capaModule = NULL;
-Module* Module::tcLib = NULL;
-
-
-Module* Module::getModule(const char* moduleName) {
- if (!strcmp(moduleName, "tclib")) {
- return tcLib;
- } else {
- return NULL;
- }
-}
-} // namespace core
-} // namespace pfc
+++ /dev/null
-/*
- * Copyright (c) 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 RESTJSON_JSON_BUILD_PARSE_H_
-#define RESTJSON_JSON_BUILD_PARSE_H_
-
-#include <uncxx/odc_log.hh>
-#include <json_type_util.hh>
-#include <rest_common_defs.hh>
-#include <pfc/log.h>
-#include <string>
-
-namespace unc {
-namespace restjson {
-
-class JsonBuildParse {
- public:
- template < typename T >
- static int build
- (const std::string & key, T data, json_object * jparent);
-
- template < typename T >
- static int parse(json_object * jobj, const std::string & key,
- int arrindex, T & val);
-
-static json_object* create_json_obj() {
-ODC_FUNC_TRACE;
- return json_object_new_object();
-}
-
-// Converts Json Obj to Json String
-static const char* get_string(json_object* jobj) {
- ODC_FUNC_TRACE;
- if (json_object_is_type(jobj, json_type_null)) {
- pfc_log_error("json object is NULL");
- return NULL;
- }
- return json_object_to_json_string(jobj);
-}
-
-// Converts String to Json Object
-static json_object* get_json_object(char *data) {
- ODC_FUNC_TRACE;
- return json_tokener_parse(data);
-}
-
-// Gets the array length of the value
-static int get_array_length(json_object* jobj,
- const std::string &key) {
- ODC_FUNC_TRACE;
- if (json_object_is_type(jobj, json_type_null)) {
- pfc_log_error("json object is NULL");
- return ZERO_ARRAY_LENGTH;
- }
-
- json_object *jobj_value = json_object_object_get(jobj, key.c_str());
- if (json_object_is_type(jobj_value, json_type_null)) {
- pfc_log_error("json object value is NULL");
- return ZERO_ARRAY_LENGTH;
- }
-
- // If the json object is not of type array return ZERO as longth
- if (!(json_object_is_type(jobj_value, json_type_array))) {
- pfc_log_error("json object is not of type array");
- return ZERO_ARRAY_LENGTH;
- }
- int arr_length = json_object_array_length(jobj_value);
- pfc_log_debug("%d array length", arr_length);
- return arr_length;
-}
-};
-
-template < typename T > int
-JsonBuildParse::build(const std::string & key, T data, json_object * jparent) {
- if (json_object_is_type(jparent, json_type_null)) {
- return REST_OP_FAILURE;
- }
-
- if (json_object_is_type(jparent, json_type_object)) {
- json_object *jobj;
- JsonTypeUtil jsonutil_obj(data);
- jobj = jsonutil_obj.get_json_data();
- if (json_object_is_type(jobj, json_type_null)) {
- return REST_OP_FAILURE;
- }
- json_object_object_add(jparent, key.c_str(), jobj);
- return REST_OP_SUCCESS;
- }
- return REST_OP_FAILURE;
-}
-
-template < typename T > int
-JsonBuildParse::parse(json_object * jobj, const std::string & key,
- int arrindex, T & val) {
- if (json_object_is_type(jobj, json_type_null)) {
- return REST_OP_FAILURE;
- }
- json_object * jobj_getval;
-
- if (-1 != arrindex) {
- json_object *jobj_array = json_object_array_get_idx(jobj, arrindex);
- jobj_getval = json_object_object_get(jobj_array, key.c_str());
- } else {
- jobj_getval = json_object_object_get(jobj, key.c_str());
- }
- if (json_object_is_type(jobj_getval, json_type_null)) {
- return REST_OP_SUCCESS;
- }
-
- JsonTypeUtil::get_value(jobj_getval, val);
-
-
- return REST_OP_SUCCESS;
-}
-
-} // namespace restjson
-} // namespace unc
-#endif // RESTJSON_JSON_BUILD_PARSE_H_
+++ /dev/null
-/*
- * Copyright (c) 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 RESTJSON_JSON_TYPE_H_
-#define RESTJSON_JSON_TYPE_H_
-
-#include <json.h>
-#include <string>
-
-namespace unc {
-namespace restjson {
-class JsonType {
- private:
- /*
- * json object
- */
- json_object* jobj_;
-
- public:
- explicit JsonType(std::string strdata) {
- jobj_ = json_object_new_string(strdata.c_str());
- }
- explicit JsonType(int intdata) {
- jobj_ = json_object_new_int(intdata);
- }
- explicit JsonType(json_object* jsondata) {
- jobj_ = jsondata;
- }
-
- static void get_value(json_object* jobjval, std::string &val) {
- val = json_object_get_string(jobjval);
- }
- static void get_value(json_object* jobjval, int &val) {
- val = json_object_get_int(jobjval);
- }
- static void get_value(json_object* jobjval, json_object*& jobjgetval) {
- jobjgetval = jobjval;
- }
-
- json_object* get_json_data() {
- return jobj_;
- }
-};
-} // namespace restjson
-} // namespace unc
-#endif // RESTJSON_JSON_TYPE_H_
+++ /dev/null
-/*
- * Copyright (c) 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 JSON_TYPE_UTIL_H_
-#define JSON_TYPE_UTIL_H_
-
-#include <uncxx/odc_log.hh>
-#include <json.h>
-#include <string>
-
-namespace unc {
-namespace restjson {
-class JsonTypeUtil {
- private:
- /**
- * json object
- */
- json_object* jobj_;
-
- public:
- /**
- * @brief - parametrised constructor takes arg as string
- * - creates json object of type string
- * @param[in] strdata - string value
- */
- explicit JsonTypeUtil(std::string strdata) {
- ODC_FUNC_TRACE;
- jobj_ = json_object_new_string(strdata.c_str());
- }
-
- /**
- * @brief - parametrised constructor takes arg as int
- * - creates json object of type int
- * @param[in] intdata - integer value
- */
- explicit JsonTypeUtil(int intdata) {
- ODC_FUNC_TRACE;
- jobj_ = json_object_new_int(intdata);
- }
-
- /**
- * @brief - Parametrised constructor takes arg as json object
- * - Creates json object of type json object
- * @param[in] jsondata - json object
- */
- explicit JsonTypeUtil(json_object* jsondata) {
- ODC_FUNC_TRACE;
- jobj_ = jsondata;
- }
-
- /**
- * @brief - Function overloading getValue - returns the value
- * of type string
- * @param[in] jobjval - json object from which the value to be retrieved
- * @param[out] val - the value stored in this string reference
- * return - None
- */
- static void get_value(json_object* jobjval, std::string &val) {
- ODC_FUNC_TRACE;
- val = json_object_get_string(jobjval);
- }
-
- /**
- * @brief - Function overloading getValue - returns the
- * value of type int
- * @param[in] jobjval - json object from which the value to be retrieved
- * @param[out] val - the value stored in this int reference
- * return - None
- */
- static void get_value(json_object* jobjval, int &val) {
- ODC_FUNC_TRACE;
- val = json_object_get_int(jobjval);
- }
-
- /**
- * @brief - Function overloading getValue - returns the
- * value of type json_object
- * @param[in] jobjval - json obj from which the value to be retrive
- * @param[out] val - the value stored in this json_object reference
- * return - None
- */
-
- static void get_value(json_object* jobjval, json_object*& jobjgetval) {
- ODC_FUNC_TRACE;
- jobjgetval = jobjval;
- }
-
- /**
- * @brief - gets the JsonData
- * @return json_object* - json_object
- */
- json_object* get_json_data() {
- ODC_FUNC_TRACE;
- return jobj_;
- }
-};
-} // namespace restjson
-} // namespace unc
-#endif // RESTJSON_JSON_TYPE_H_
+++ /dev/null
-/*
- * Copyright (c) 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 RESTJSON_REST_COMMON_DEFS_H_
-#define RESTJSON_REST_COMMON_DEFS_H_
-
-#include <string>
-
-#define CONTENT_TYPE "Content-type: application/json"
-#define ACCEPT_TYPE "Accept: application/json"
-
-namespace unc {
-namespace restjson {
-
-const char PROTOCOL[] = "http://";
-const char COLON[] = ":";
-const size_t SIZE_NULL = 0;
-const int ZERO_ARRAY_LENGTH = 0;
-const int CURLOPT_ENABLE = 1;
-const int CURLOPT_DISABLE = 0;
-
-typedef enum {
- HTTP_METHOD_POST = 1,
- HTTP_METHOD_PUT,
- HTTP_METHOD_DELETE,
- HTTP_METHOD_GET,
-} HttpMethod;
-
-typedef struct {
- char *memory;
- int size;
-} HttpContent_t;
-
-typedef struct {
- int code;
- HttpContent_t *write_data;
-} HttpResponse_t;
-
-typedef enum {
- REST_OP_SUCCESS = 0,
- REST_OP_FAILURE
-} rest_resp_code_t;
-
-typedef struct {
- uint32_t odc_port;
- uint32_t request_time_out;
- uint32_t connection_time_out;
- std::string user_name;
- std::string password;
-} ConfFileValues_t;
-
-
-} // namespace restjson
-} // namespace unc
-#endif // RESTJSON_REST_COMMON_DEFS_H_
+++ /dev/null
-/*
- * Copyright (c) 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 RESTJSON_REST_CLIENT_H_
-#define RESTJSON_REST_CLIENT_H_
-
-#include <stdio.h>
-#include <rest_common_defs.hh>
-
-#include <string>
-
-namespace unc {
-namespace restjson {
-
-class RestUtil {
- public:
- RestUtil(const std::string& ipaddress,
- const std::string& username,
- const std::string& pass)
- : ip_address_(ipaddress) {
- response_ = new HttpResponse_t;
- response_->code = 0;
- response_->write_data = new HttpContent_t;
- }
-
- ~RestUtil() {
- if (response_ != NULL) {
- if (response_->write_data != NULL) {
- delete response_->write_data;
- response_->write_data = NULL;
- }
- delete response_;
- response_ = NULL;
- }
- }
-
- HttpResponse_t* send_http_request(const std::string &url,
- const unc::restjson::HttpMethod method,
- const char* request,
- const ConfFileValues_t &conf_file_values_) {
- url_ = url;
- std::string NULL_RESPONSE = "172.16.0.0";
- std::string INVALID_RESPONSE = "172.0.0.0";
- std::string CREATE_201 = "172.16.0.1";
- std::string UPDATE_DELETE_200 = "172.16.0.2";
- std::string READ_VTN_NULL_DATA = "172.16.0.3";
- std::string CREATE_VBRIF_PORTMAP = "172.16.0.4";
- std::string UPDATE_DELETE_VBRIF_PORTMAP = "172.16.0.5";
-
- std::string VBRIF_GET_RESP = "172.16.0.6";
- std::string VBRIF_GET_RESP_EMPTY = "172.16.0.7";
- std::string VBRIF_GET_RESP_PORT_MAP = "172.16.0.10";
- std::string READ_VBR_VALID = "172.16.0.8";
- std::string READ_VBR_NULL_DATA = "172.16.0.9";
-
- std::string VBRIF_GET_RESP_PORT_MAP_NO_VLAN = "172.16.0.11";
-
- std::string NOT_FOUND_404 = "172.16.0.12";
- std::string SERVICE_UNAVAILABLE_503 = "172.16.0.13";
- std::string VLAN_MAP_EMPTY = "172.16.0.14";
- std::string VLAN_MAP_RESP = "172.16.0.15";
- std::string VLAN_MAP_INCORRECT_RESP = "172.16.0.16";
- std::string VLAN_MAP_VLAN_INCORRECT_RESP = "172.16.0.17";
- std::string VLAN_MAP_RESP_ANY_0 = "172.16.0.18";
- std::string NULL_RESP_DATA = "172.16.0.19";
-
- std::string port_map_url_create_valid = "";
- port_map_url_create_valid.append
- ("/controller/nb/v2/vtn/default/vtns/vtn1/vbridges/");
- port_map_url_create_valid.append
- ("vbr1/interfaces/if_valid_create/portmap");
-
- std::string port_map_url_update_valid = "";
- port_map_url_update_valid.append
- ("/controller/nb/v2/vtn/default/vtns/vtn1/vbridges/");
- port_map_url_update_valid.append
- ("vbr1/interfaces/if_valid_update/portmap");
-
-
- std::string port_map_url_invalid = "";
- port_map_url_invalid.append
- ("/controller/nb/v2/vtn/default/vtns/vtn1/vbridges/");
- port_map_url_invalid.append
- ("vbr1/interfaces/if_invalid/portmap");
- std::string port_map_null_resp = "";
- port_map_null_resp.append
- ("/controller/nb/v2/vtn/default/vtns/vtn1/vbridges/");
- port_map_null_resp.append
- ("vbr1/interfaces/if_invalid/portmap");
-
- if (ip_address_.compare(CREATE_201) == 0) {
- response_->code = 201;
- return response_;
- } else if (ip_address_.compare(NULL_RESPONSE) == 0) {
- clear_http_response();
- return NULL;
- } else if (ip_address_.compare(INVALID_RESPONSE) == 0) {
- response_->code = 1;
- return response_;
- } else if (ip_address_.compare(NOT_FOUND_404) == 0) {
- response_->code = 404;
- return response_;
- } else if (ip_address_.compare(NOT_FOUND_404) == 0) {
- response_->code = 404;
- return response_;
- } else if (ip_address_.compare(SERVICE_UNAVAILABLE_503) == 0) {
- response_->code = 503;
- return response_;
- } else if (ip_address_.compare(UPDATE_DELETE_200) == 0) {
- response_->write_data->memory =
- const_cast<char *>("{\"vtn\": [ { \"name\": \"vtn_1\",\"description\": \"1\" }, {\"name\": \"vtn_2\" } ] }");
- response_->code = 200;
- return response_;
- } else if (ip_address_.compare(READ_VTN_NULL_DATA) == 0) {
- response_->write_data->memory = const_cast<char *>("{\"vtn\":[]}");
- response_->code = 200;
- return response_;
- } else if (ip_address_.compare(CREATE_VBRIF_PORTMAP) == 0) {
- if (url_.compare(port_map_url_update_valid) == 0) {
- response_->code = 200;
- return response_;
- } else if (url_.compare(port_map_null_resp) == 0) {
- return NULL;
- }
- response_->code = 201;
- return response_;
- } else if (ip_address_.compare(UPDATE_DELETE_VBRIF_PORTMAP) == 0) {
- if (url_.compare(port_map_url_update_valid) == 0) {
- response_->code = 200;
- return response_;
- } else if (url_.compare(port_map_url_invalid) == 0) {
- response_->code = 1;
- return response_;
- } else if (url_.compare(port_map_null_resp) == 0) {
- return NULL;
- }
- response_->code = 200;
- return response_;
- } else if (ip_address_.compare(VBRIF_GET_RESP) == 0) {
- if (url_.compare(port_map_url_update_valid) != 0) {
- response_->code = 200;
- response_->write_data->memory = const_cast<char *>("{\"interface\": [ { \"name\": \"if_valid_update\",\"description\": \"1\" } ] }");
- return response_;
- }
- response_->code = 204;
- return response_;
- } else if (ip_address_.compare(VBRIF_GET_RESP_EMPTY) == 0) {
- if (url_.compare(port_map_url_update_valid) != 0) {
- response_->code = 200;
- response_->write_data->memory =
- const_cast<char *>("{\"interface\": [ { \"name\": \"if_valid_update\" } ] }");
- return response_;
- }
- response_->code = 200;
- response_->write_data = NULL;
- return response_;
- } else if (ip_address_.compare(VBRIF_GET_RESP_PORT_MAP) == 0) {
- if (url_.compare(port_map_url_update_valid) != 0) {
- response_->code = 200;
- response_->write_data->memory = const_cast<char *>("{\"interface\": [ { \"name\": \"if_valid_update\",\"description\": \"1\" } ] }");
- return response_;
- }
- response_->code = 200;
- response_->write_data->memory = const_cast<char *>("{\"vlan\": \"100\",\"node\" : {\"type\": \"OF\",\"id\": \"00:00:00:00:00:00:00:03\" }, \"port\" : {\"name\": \"port\" } }");
- return response_;
- } else if (ip_address_.compare(VBRIF_GET_RESP_PORT_MAP_NO_VLAN) == 0) {
- if (url_.compare(port_map_url_update_valid) != 0) {
- response_->code = 200;
- response_->write_data->memory = const_cast<char *>("{\"interface\": [ { \"name\": \"if_valid_update\",\"description\": \"1\" } ] }");
- return response_;
- }
- response_->code = 200;
- response_->write_data->memory = const_cast<char *>("{\"vlan\": \"0\",\"node\" : {\"type\": \"OF\",\"id\": \"00:00:00:00:00:00:00:03\" }, \"port\" : {\"name\": \"port\" } }");
- return response_;
- } else if (ip_address_.compare(READ_VBR_VALID) == 0) {
- response_->code = 200;
- response_->write_data->memory = const_cast<char *>("{\"vbridge\": [ { \"name\": \"vbridge_1\",\"description\": \"1\" }, {\"name\": \"vbridge_2\" } ] }");
- return response_;
- } else if (ip_address_.compare(READ_VBR_NULL_DATA) == 0) {
- response_->code = 200;
- response_->write_data->memory = const_cast<char *>("{\"vbridge\":[]}");
- return response_;
- } else if (ip_address_.compare(VLAN_MAP_EMPTY) == 0) {
- response_->code = 200;
- response_->write_data->memory = const_cast<char *>("{\"vlanmap\":[]}");
- return response_;
- } else if (ip_address_.compare(VLAN_MAP_INCORRECT_RESP) == 0) {
- response_->code = 200;
- response_->write_data->memory = const_cast<char *>("{\"vlanmap:[]}");
- return response_;
-
- } else if (ip_address_.compare (VLAN_MAP_VLAN_INCORRECT_RESP) == 0) {
- response_->code = 200;
- response_->write_data->memory = const_cast<char *>("{\"vlanmap\":[{ \"id\":\"23}]}");
- return response_;
- } else if (ip_address_.compare (VLAN_MAP_RESP) == 0) {
- response_->code = 200;
- response_->write_data->memory = const_cast<char *>("{\"vlanmap\":[{ \"id\":\"OF-00:00:00:00:00:00:00:03.0\", \"vlan\":\"0\",\"node\": {\"type\":\"OF\", \"id\": \"00:00:00:00:00:00:00:03\"}}, {\"id\":\"ANY.7\", \"vlan\":\"7\"}]}");
- return response_;
- } else if (ip_address_.compare (VLAN_MAP_RESP_ANY_0) == 0) {
- response_->code = 200;
- response_->write_data->memory = const_cast<char *>("{\"vlanmap\":[{ \"id\":\"OF-00:00:00:00:00:00:00:03.10\", \"vlan\":\"10\",\"node\": {\"type\":\"OF\", \"id\": \"00:00:00:00:00:00:00:03\"}}, {\"id\":\"ANY.0\", \"vlan\":\"0\"}]}");
- return response_;
- } else if(ip_address_.compare(NULL_RESP_DATA) == 0) {
- response_->code = 200;
- delete response_->write_data;
- response_->write_data = NULL;
- return response_;
- }
-
-
- return NULL;
- }
-
- void clear_http_response() {
- if (response_ != NULL) {
- if (response_->write_data != NULL) {
- delete response_->write_data;
- response_->write_data = NULL;
- }
- delete response_;
- response_ = NULL;
- }
- }
-
- private:
- restjson::HttpResponse_t* response_;
- std::string ip_address_;
- std::string url_;
-};
-} // namespace restjson
-} // namespace unc
-#endif // RESTJSON_REST_CLIENT_H_
+++ /dev/null
-/*
- * Copyright (c) 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_TCLIB_DEFS_HH_
-#define _UNC_TCLIB_DEFS_HH_
-
-
-#include<map>
-#include<list>
-#include<vector>
-#include<string>
-#include<stdint.h>
-#include <unc/keytype.h>
-
-namespace unc {
-namespace tclib {
-
-/* default argument count */
-#define IPC_DEFAULT_ARG_COUNT 0
- /* supported tclib services */
-#define TCLIB_IPC_SERVICES 17
-
- /*
- * All Virtual Functions of TcLibInterface returns with
- * this type. Based on this actions will be taken care in TC
- */
- typedef enum {
- TC_SUCCESS = 0,
- TC_FAILURE
- }TcCommonRet;
-
- /*
- * Message oper types filled from tc towards tclib
- * This oper types decides the which handle tclib interface
- * function to be invoked.
- */
- typedef enum {
- MSG_NONE = 0,
- MSG_NOTIFY_CONFIGID,
- MSG_SETUP,
- MSG_SETUP_COMPLETE,
- MSG_COMMIT_TRANS_START,
- MSG_COMMIT_VOTE,
- MSG_COMMIT_DRIVER_VOTE,
- MSG_COMMIT_VOTE_DRIVER_RESULT,
- MSG_COMMIT_GLOBAL,
- MSG_COMMIT_DRIVER_GLOBAL,
- MSG_COMMIT_GLOBAL_DRIVER_RESULT,
- MSG_COMMIT_TRANS_END,
- MSG_AUDIT_START,
- MSG_AUDIT_TRANS_START,
- MSG_AUDIT_VOTE,
- MSG_AUDIT_DRIVER_VOTE,
- MSG_AUDIT_VOTE_DRIVER_RESULT,
- MSG_AUDIT_GLOBAL,
- MSG_AUDIT_DRIVER_GLOBAL,
- MSG_AUDIT_GLOBAL_DRIVER_RESULT,
- MSG_AUDIT_TRANS_END,
- MSG_AUDIT_END,
- MSG_SAVE_CONFIG,
- MSG_CLEAR_CONFIG,
- MSG_ABORT_CANDIDATE,
- MSG_AUDITDB,
- MSG_COMMIT_ABORT,
- MSG_AUDIT_ABORT,
- MSG_GET_DRIVERID,
- MSG_CONTROLLER_TYPE,
- MSG_MAX
- }TcMsgOperType;
-
- /*
- * services provided in tclib
- * some services are combination of multiple operations.
- * For example:
- * TCLIB_COMMIT_TRANSACTION combination of transaction start, transaction end
- * for all channels and vote request, global commit for UPLL and UPPL.
- */
- typedef enum {
- TCLIB_NOTIFY_SESSION_CONFIG = 0,
- TCLIB_COMMIT_TRANSACTION,
- TCLIB_COMMIT_DRV_VOTE_GLOBAL,
- TCLIB_COMMIT_DRV_RESULT,
- TCLIB_COMMIT_GLOBAL_ABORT,
- TCLIB_AUDIT_TRANSACTION,
- TCLIB_AUDIT_DRV_VOTE_GLOBAL,
- TCLIB_AUDIT_DRV_RESULT,
- TCLIB_AUDIT_GLOBAL_ABORT,
- TCLIB_SAVE_CONFIG,
- TCLIB_CLEAR_STARTUP,
- TCLIB_USER_ABORT,
- TCLIB_SETUP,
- TCLIB_SETUP_COMPLETE,
- TCLIB_GET_DRIVERID,
- TCLIB_AUDIT_CONFIG,
- TCLIB_CONTROLLER_TYPE
- }TcLibServiceId;
-
- /*
- * Enum used for handle driver result
- * phase type indicates in which phase the handle driver result
- * has invoked for UPLL and UPPL for both commit and audit operations
- */
- typedef enum {
- TC_COMMIT_VOTE_PHASE = 0,
- TC_COMMIT_GLOBAL_COMMIT_PHASE,
- TC_AUDIT_VOTE_PHASE,
- TC_AUDIT_GLOBAL_COMMIT_PHASE
- }TcCommitPhaseType;
-
- /*
- * phase in which abort operation has invoked
- * currently, only in vote request phase abort operation
- * will be invoked.
- */
- typedef enum {
- COMMIT_TRANSACTION_START = 0,
- COMMIT_VOTE_REQUEST
- }TcCommitOpAbortPhase;
-
- /*
- * phase in which abort operation has invoked
- * currently, only in vote request phase abort operation
- * will be invoked.
- */
- typedef enum {
- AUDIT_START = 0,
- AUDIT_TRANSACTION_START,
- AUDIT_VOTE_REQUEST
- }TcAuditOpAbortPhase;
-
- /*
- * audit result will be sent from tc in audit end oper type
- * This will be decided tc based on audit operations
- */
- typedef enum {
- TC_AUDIT_FAILURE = 0,
- TC_AUDIT_SUCCESS
- }TcAuditResult;
-
- /*
- * end result will be sent from tc in transaction end oper type
- * This will be decided tc based on transaction operations
- */
- typedef enum {
- TRANS_END_FAILURE = 0,
- TRANS_END_SUCCESS
- }TcTransEndResult;
-
- // API related definitions
- /*
- * used by tclib api functions
- * based on this actions will be taken care in
- * respective invoked areas
- */
- typedef enum {
- TC_API_COMMON_SUCCESS = 0,
- TC_API_COMMON_FAILURE,
- TC_INVALID_PARAM,
- TC_HANDLER_ALREADY_ACTIVE,
- TC_INVALID_SESSION_ID,
- TC_INVALID_CONFIG_ID,
- TC_INVALID_CONTROLLER_ID,
- TC_INVALID_OPER_STATE,
- TC_INVALID_KEY_TYPE,
- TC_INVALID_KEY_DATA,
- TC_INVALID_VALUE_DATA,
- TC_INVALID_KEY_STDEF,
- TC_INVALID_VALUE_STDEF,
- TC_API_FATAL
- }TcApiCommonRet;
-
- /*
- * handle driver result function uses this structure
- * tclib constructs this structure based on the driver result
- * message request from tc
- */
- typedef struct {
- std::string controller_id;
- uint32_t resp_code;
- uint32_t num_of_errors;
- std::list<uint32_t> key_list;
- }TcControllerResult;
-
- /*
- * Driver info map is combination of controller type and its assosciated
- * controllers. Filled from UPLL and UPPL in vote request and global commit
- * phases
- */
- typedef std::map<unc_keytype_ctrtype_t, std::vector<std::string> >
- TcDriverInfoMap;
-
- /*
- * list of controllers.
- */
- typedef std::list<std::string> TcControllerList;
-
- /*
- * vector of controller results.
- * For handle driver result to UPLL and UPPL, this vector will be filled and
- * sent in handler functions.
- */
- typedef std::vector<TcControllerResult> TcCommitPhaseResult;
-
- /*
- * keytype and its assosciated index in session
- * This map filled for handle driver result request.
- * based on request to keytype, index will be retrieved.
- */
- typedef std::map<uint32_t, uint32_t>TcKeyTypeIndexMap;
-
- /*
- * controllerid and assosciated keyindex map
- * based on request to controllerid, keytypeindex map will be retrieved
- */
- typedef std::map<std::string, TcKeyTypeIndexMap> TcControllerKeyTypeMap;
-} // tclib
-} // unc
-
-#endif /* _TCLIB_DEFS_HH */
+++ /dev/null
-/*
- * Copyright (c) 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_TCLIB_INTERFACE_H_
-#define _UNC_TCLIB_INTERFACE_H_
-
-#include <uncxx/tclib/tclib_defs.hh>
-#include <unc/tc/external/tc_services.h>
-#include <string>
-
-namespace unc {
-namespace tclib {
-
-class TcLibInterface {
- public:
- /* commit related interfaces */
- /**
- * @brief Handling of transaction start in commit operation
- * @param[in] session_id session on which commit request sent
- * @param[in] config_id config id generated on acquire config mode for
- * session_id
- * @retval TC_SUCCESS Transaction start success
- * @retval TC_FAILURE Transaction start failed
- */
- virtual TcCommonRet HandleCommitTransactionStart(uint32_t session_id,
- uint32_t config_id)=0;
-
- /**
- * @brief Handling of transaction end in commit operation
- * @param[in] session_id session on which commit request sent
- * @param[in] config_id config id generated on acquire config mode for
- * session_id
- * @retval TC_SUCCESS Transaction end success
- * @retval TC_FAILURE Transaction end failed
- */
- virtual TcCommonRet HandleCommitTransactionEnd(uint32_t session_id,
- uint32_t config_id,
- TcTransEndResult end_result)=0;
-
- /**
- * @brief Handling of vote request for UPLL/UPPL in commit operation
- * @param[in] session_id session on which commit request sent
- * @param[in] config_id config id generated on acquire config mode for
- * session_id
- * @param[out] driver_info map which contains the controller type and their
- * assosciated controller ids
- * @retval TC_SUCCESS vote request success
- * @retval TC_FAILURE vote request failed
- */
- virtual TcCommonRet HandleCommitVoteRequest(uint32_t session_id,
- uint32_t config_id,
- TcDriverInfoMap& driver_info)=0;
-
- /**
- * @brief Handling of vote request for driver modules in commit operation
- * @param[in] session_id session on which commit request sent
- * @param[in] config_id config id generated on acquire config mode for
- * session_id
- * @param[in] controllers list of controllers involved in commit operation
- * @retval TC_SUCCESS vote request success
- * @retval TC_FAILURE vote request failed
- */
- virtual TcCommonRet HandleCommitVoteRequest(uint32_t session_id,
- uint32_t config_id,
- TcControllerList controllers)=0;
-
- /**
- * @brief Handling of global commit for UPLL/UPPL in commit operation
- * @param[in] session_id session on which commit request sent
- * @param[in] config_id config id generated on acquire config mode for
- * session_id
- * @param[out] driver_info map which contains the controller type and their
- * assosciated controller ids
- * @retval TC_SUCCESS global commit success
- * @retval TC_FAILURE global commit failed
- */
- virtual TcCommonRet HandleCommitGlobalCommit(uint32_t session_id,
- uint32_t config_id,
- TcDriverInfoMap& driver_info)=0;
-
- /**
- * @brief Handling of global commit for driver modules in commit operation
- * @param[in] session_id session on which commit request sent
- * @param[in] config_id config id generated on acquire config mode for
- * session_id
- * @param[in] controllers list of controllers involved in commit operation
- * @retval TC_SUCCESS global commit success
- * @retval TC_FAILURE global commit failed
- */
- virtual TcCommonRet HandleCommitGlobalCommit(uint32_t session_id,
- uint32_t config_id,
- TcControllerList controllers)=0;
-
- /**
- * @brief Handling of driver result for UPLL/UPPL in commit operation
- * @param[in] session_id session on which commit request sent
- * @param[in] config_id config id generated on acquire config mode for
- * session_id
- * @param[in] phase commit phase type of vote/global commit
- * @param[in] driver_result driver result from either vote/global commit
- * phase
- * @retval TC_SUCCESS driver result handling success
- * @retval TC_FAILURE driver result handling failed
- */
- virtual TcCommonRet HandleCommitDriverResult(uint32_t session_id,
- uint32_t config_id,
- TcCommitPhaseType phase,
- TcCommitPhaseResult
- driver_result)=0;
-
- /**
- * @brief Handling of global abort in commit operation
- * @param[in] session_id session on which commit request sent
- * @param[in] config_id config id generated on acquire config mode for
- * session_id
- * @param[in] fail_phase phase at which transaction got failed transaction
- * start or vote request
- * @retval TC_SUCCESS global abort handling success
- * @retval TC_FAILURE global abort handling failed
- */
- virtual TcCommonRet HandleCommitGlobalAbort(uint32_t session_id,
- uint32_t config_id,
- TcCommitOpAbortPhase fail_phase)
- =0;
-
-
- /* audit related interfaces */
- /**
- * @brief Handling of audit start in audit operation
- * @param[in] session_id
- * session on which audit request sent (user audit)
- * session id will be 0 for driver audit
- * @param[in] ctr_type controller type openflow/overlay/legacy
- * @param[in] controller_id controller id intended for audit
- * @retval TC_SUCCESS audit start success
- * @retval TC_FAILURE audit start failed
- */
- virtual TcCommonRet HandleAuditStart(uint32_t session_id,
- unc_keytype_ctrtype_t ctr_type,
- std::string controller_id)=0;
-
- /**
- * @brief Handling of audit end in audit operation
- * @param[in] session_id
- * session on which audit request sent (user audit)
- * session id will be 0 for driver audit
- * @param[in] ctr_type controller type openflow/overlay/legacy
- * @param[in] controller_id controller id intended for audit
- * @param[in] audit_result contains the consolidated audit result of
- * global commit and driver reult functions from UPLL/UPPL
- * @retval TC_SUCCESS audit end success
- * @retval TC_FAILURE audit end failed
- */
- virtual TcCommonRet HandleAuditEnd(uint32_t session_id,
- unc_keytype_ctrtype_t ctr_type,
- std::string controller_id,
- TcAuditResult audit_result)=0;
-
- /**
- * @brief Handling of transaction start in audit operation
- * @param[in] session_id
- * session on which audit request sent (user audit)
- * session id will be 0 for driver audit
- * @param[in] ctr_type controller type openflow/overlay/legacy
- * @param[in] controller_id controller id intended for audit
- * @retval TC_SUCCESS transaction start success
- * @retval TC_FAILURE transaction start failed
- */
- virtual TcCommonRet HandleAuditTransactionStart(uint32_t session_id,
- unc_keytype_ctrtype_t ctr_type,
- std::string controller_id)=0;
-
- /**
- * @brief Handling of transaction end in audit operation
- * @param[in] session_id
- * session on which audit request sent (user audit)
- * session id will be 0 for driver audit
- * @param[in] ctr_type controller type openflow/overlay/legacy
- * @param[in] controller_id controller id intended for audit
- * @retval TC_SUCCESS transaction end success
- * @retval TC_FAILURE transaction end failed
- */
- virtual TcCommonRet HandleAuditTransactionEnd(uint32_t session_id,
- unc_keytype_ctrtype_t ctr_type,
- std::string controller_id,
- TcTransEndResult end_result)=0;
-
- /**
- * @brief Handling of vote request for UPLL/UPPL in audit operation
- * @param[in] session_id
- * session on which audit request sent (user audit)
- * session id will be 0 for driver audit
- * @param[in] ctr_type controller type openflow/overlay/legacy
- * @param[in] controller_id controller id intended for audit
- * @param[out] driver_info map which contains the controller type and their
- * assosciated controller ids
- * @retval TC_SUCCESS vote request success
- * @retval TC_FAILURE vote request failed
- */
- virtual TcCommonRet HandleAuditVoteRequest(uint32_t session_id,
- uint32_t ctr_type,
- std::string controller_id,
- TcDriverInfoMap& driver_info)=0;
-
- /**
- * @brief Handling of vote request for driver modules in audit operation
- * @param[in] session_id
- * session on which audit request sent (user audit)
- * session id will be 0 for driver audit
- * @param[in] controller_id controller id intended for audit
- * @param[in] controllers list of controllers involved in commit operation
- * @retval TC_SUCCESS vote request success
- * @retval TC_FAILURE vote request failed
- */
- virtual TcCommonRet HandleAuditVoteRequest(uint32_t session_id,
- std::string controller_id,
- TcControllerList controllers)=0;
-
- /**
- * @brief Handling of global commit for UPLL/UPPL in audit operation
- * @param[in] session_id
- * session on which audit request sent (user audit)
- * session id will be 0 for driver audit
- * @param[in] ctr_type controller type openflow/overlay/legacy
- * @param[in] controller_id controller id intended for audit
- * @param[out] driver_info map which contains the controller type and their
- * assosciated controller ids
- * @param[out] audit_result result of the audit operation to be filled by both
- * UPLL and UPPL (TC_AUDIT_SUCCESS/TC_AUDIT_FAILURE)
- * @retval TC_SUCCESS global commit success
- * @retval TC_FAILURE global commit failed
- */
- virtual TcCommonRet HandleAuditGlobalCommit(uint32_t session_id,
- uint32_t ctr_type,
- std::string controller_id,
- TcDriverInfoMap& driver_info,
- TcAuditResult& audit_result)=0;
-
- /**
- * @brief Handling of global commit for driver modules in audit operation
- * @param[in] session_id
- * session on which audit request sent (user audit)
- * session id will be 0 for driver audit
- * @param[in] controller_id controller id intended for audit
- * @param[in] controllers list of controllers involved in commit operation
- * @retval TC_SUCCESS global commit success
- * @retval TC_FAILURE global commit failed
- */
- virtual TcCommonRet HandleAuditGlobalCommit(uint32_t session_id,
- std::string controller_id,
- TcControllerList controllers)=0;
-
- /**
- * @brief Handling of driver result for UPLL/UPPL in audit operation
- * @param[in] session_id
- * session on which audit request sent (user audit)
- * session id will be 0 for driver audit
- * @param[in] controller_id controller id intended for audit
- * @param[in] phase commit phase type of vote/global commit
- * @param[in] driver_result driver result from either vote/global commit
- * phase
- * @param[out] audit_result result of the audit operation to be filled by both
- * UPLL and UPPL (TC_AUDIT_SUCCESS/TC_AUDIT_FAILURE)
- * @retval TC_SUCCESS driver result handling success
- * @retval TC_FAILURE driver result handling failed
- */
- virtual TcCommonRet HandleAuditDriverResult(uint32_t session_id,
- std::string controller_id,
- TcCommitPhaseType phase,
- TcCommitPhaseResult
- driver_result,
- TcAuditResult& audit_result)=0;
-
- /**
- * @brief Handling of global abort in audit operation
- * @param[in] session_id
- * session on which audit request sent (user audit)
- * session id will be 0 for driver audit
- * @param[in] ctr_type controller type openflow/overlay/legacy
- * @param[in] controller_id controller id intended for audit
- * @param[in] fail_phase phase at which transaction got failed audit start/
- * transaction start/vote request
- * @retval TC_SUCCESS global abort handling success
- * @retval TC_FAILURE global abort handling failed
- */
- virtual TcCommonRet HandleAuditGlobalAbort(uint32_t session_id,
- unc_keytype_ctrtype_t ctr_type,
- std::string controller_id,
- TcAuditOpAbortPhase fail_phase)=0;
-
- /**
- * @brief Save configuration
- * @param[in] session_id session on which save configuration request sent
- * @retval TC_SUCCESS save configuration handling success
- * @retval TC_FAILURE save configuration handling failed
- */
- virtual TcCommonRet HandleSaveConfiguration(uint32_t session_id)=0;
-
- /**
- * @brief Abort candidate configuration
- * @param[in] session_id session on which abort configuration request sent
- * @param[in] config_id config id generated on acquire config mode for
- * session_id
- * @retval TC_SUCCESS abort candidate handling success
- * @retval TC_FAILURE abort candidate handling failed
- */
- virtual TcCommonRet HandleAbortCandidate(uint32_t session_id,
- uint32_t config_id)=0;
-
- /**
- * @brief Clear Startup Configuration
- * @param[in] session_id session on which clear startup request sent
- * @retval TC_SUCCESS clear startup handling success
- * @retval TC_FAILURE clear startup handling failed
- */
- virtual TcCommonRet HandleClearStartup(uint32_t session_id)=0;
-
- /**
- * @brief HandleAuditConfig DB
- * @param[in] db_target db on which action to be taken
- * @param[in] fail_oper phase of failure on either commit/audit
- * @retval TC_SUCCESS clear startup handling success
- * @retval TC_FAILURE clear startup handling failed
- */
- virtual TcCommonRet HandleAuditConfig(unc_keytype_datatype_t db_target,
- TcServiceType fail_oper)=0;
-
- /**
- * @brief Setup Configuration Message sent to UPPL at the end of startup
- * operation to send messages to driver
- * @retval TC_SUCCESS clear startup handling success
- * @retval TC_FAILURE clear startup handling failed
- */
- virtual TcCommonRet HandleSetup()=0;
-
- /**
- * @brief Setup Complete Message sent to UPPL during state changes
- * @retval TC_SUCCESS clear startup handling success
- * @retval TC_FAILURE clear startup handling failed
- */
- virtual TcCommonRet HandleSetupComplete()=0;
-
- /**
- * @brief Get controller type invoked from TC to detect the controller type
- * for a controller
- * @param[in] controller_id controller id intended for audit
- * @retval openflow/overlay/legacy if controller id matches
- * @retval UNC_CT_UNKNOWN if controller id does not belong to
- * any of controller type
- */
- virtual unc_keytype_ctrtype_t HandleGetControllerType
- (std::string controller_id)=0;
-
- /**
- * @brief Get Controller Type
- * Invoked from TC to detect the type of the controller
- * Intended for the driver modules
- * @retval openflow/overlay/legacy if controller id matches
- * @retval none if requested for other than driver modules
- * UPPL/UPLL modules should return UNC_CT_UNKNOWN
- */
- virtual unc_keytype_ctrtype_t HandleGetControllerType()=0;
-
- virtual ~TcLibInterface() {}
-};
-} // tclib
-} // unc
-
-
-#endif /* _TCLIB_INTERFACE_HH */
+++ /dev/null
-/*
- * Copyright (c) 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 "tclib_module.hh"
-
-namespace unc {
-namespace tclib {
-
-std::map<TcLibModule::TCCommonRet, TcCommonRet>
- TcLibModule::method_tccommon_map;
-std::map<TcLibModule::TCApiCommonRet, TcApiCommonRet>
- TcLibModule::method_tcapi_map;
-unc_keytype_ctrtype_t TcLibModule::driverId;
-unc_keytype_ctrtype_t TcLibModule::controllerType;
-uint32_t TcLibModule::keyIndex;
-TcLibInterface* TcLibModule::pTcLibInterface_= 0;
-
-static TcLibModule theInstance(NULL);
-
-void
- TcLibModule::stub_loadtcLibModule(void) {
- pfc::core::Module::tcLib = &theInstance;
- }
-
-void
- TcLibModule::stub_unloadtcLibModule(void) {
- pfc::core::Module::tcLib = NULL;
- }
-
-TcApiCommonRet TcLibModule::TcLibRegisterHandler(TcLibInterface* handler) {
- pTcLibInterface_ = handler;
- return stub_getMappedResultCode(TcLibModule::REGISTER);
-}
-
-TcApiCommonRet TcLibModule::TcLibAuditControllerRequest
- (std::string controller_id) {
- return stub_getMappedResultCode(TcLibModule::AUDIT_CONTROLLER);
-}
-
-
-TcApiCommonRet TcLibModule::TcLibValidateUpdateMsg
- (uint32_t sessionid, uint32_t configid) {
- return stub_getMappedResultCode(TcLibModule::VALIDATE_UPDATE);
-}
-
-TcApiCommonRet TcLibModule::TcLibReadKeyValueDataInfo(std::string controller_id,
- uint32_t err_pos,
- uint32_t key_type,
- pfc_ipcstdef_t key_def,
- pfc_ipcstdef_t value_def,
- void* key_data,
- void* value_data) {
- return stub_getMappedResultCode(TcLibModule::READ_KEY_VAL);
-}
-
-TcApiCommonRet TcLibModule::TcLibWriteControllerInfo(std::string controller_id,
- uint32_t response_code,
- uint32_t num_of_errors) {
- return stub_getMappedResultCode(TcLibModule::WRITE_CONTROLLER);
-}
-
-TcApiCommonRet TcLibModule::TcLibWriteKeyValueDataInfo(std::string
- controller_id,
- uint32_t key_type,
- pfc_ipcstdef_t key_def,
- pfc_ipcstdef_t value_def,
- void* key_data,
- void* value_data) {
- return stub_getMappedResultCode(TcLibModule::WRITE_KEY_VALUE);
-}
-
-TcCommonRet TcLibModule::ValidateOperTypeSequence(TcMsgOperType oper_type) {
- return stub_getMappedResultCode(TcLibModule::VALIDATE_OPER_TYPE);
-}
-
-
-TcCommonRet TcLibModule::ValidateCommitOperSequence(TcMsgOperType oper_type) {
- return stub_getMappedResultCode(TcLibModule::VALIDATE_COMMIT_OPER);
-}
-
-
-TcCommonRet TcLibModule::TcLibModule::ValidateAuditOperSequence
- (TcMsgOperType oper_type) {
- return stub_getMappedResultCode(TcLibModule::VALIDATE_AUDIT_OPER);
-}
-
-
-TcCommonRet TcLibModule::ValidateUpllUpplCommitSequence
- (TcMsgOperType oper_type) {
- return stub_getMappedResultCode(TcLibModule::VALIDATE_UPLL_COMMIT);
-}
-
-
-TcCommonRet TcLibModule::ValidateDriverCommitSequence(TcMsgOperType oper_type) {
- return stub_getMappedResultCode(TcLibModule::VALIDATE_DRIVER_COMMIT);
-}
-
-
-TcCommonRet TcLibModule::ValidateUpllUpplAuditSequence
- (TcMsgOperType oper_type) {
- return stub_getMappedResultCode(TcLibModule::VALIDATE_UPLL_AUDIT);
-}
-
-
-TcCommonRet TcLibModule::ValidateDriverAuditSequence(TcMsgOperType oper_type) {
- return stub_getMappedResultCode(TcLibModule::VALIDATE_DRIVER_AUDIT);
-}
-
-
-TcApiCommonRet TcLibModule::IsReadKeyValueAllowed() {
- return stub_getMappedResultCode(TcLibModule::IS_READ_KEY);
-}
-
-TcApiCommonRet TcLibModule::IsWriteKeyValueAllowed() {
- return stub_getMappedResultCode(TcLibModule::IS_WRITE_KEY);
-}
-
-
-TcCommonRet TcLibModule::UpdateControllerKeyList() {
- return stub_getMappedResultCode(TcLibModule::UPDATE_CONTROLLER_KEY);
-}
-
-TcCommonRet TcLibModule::NotifySessionConfig() {
- return stub_getMappedResultCode(TcLibModule::NOTIFY_SESSION_CONFIG);
-}
-
-
-TcCommonRet TcLibModule::CommitTransStartEnd(TcMsgOperType oper_type,
- TcCommitTransactionMsg commit_trans_msg) {
- return stub_getMappedResultCode(TcLibModule::COMMIT_TRANS_START);
-}
-
-
-TcCommonRet TcLibModule::CommitVoteGlobal(TcMsgOperType oper_type,
- TcCommitTransactionMsg commit_trans_msg) {
- return stub_getMappedResultCode(TcLibModule::COMMIT_VOTE_GLOBAL);
-}
-
-
-TcCommonRet TcLibModule::CommitTransaction() {
- return stub_getMappedResultCode(TcLibModule::COMMIT_TRANS);
-}
-
-
-TcCommonRet TcLibModule::CommitDriverVoteGlobal() {
- return stub_getMappedResultCode(TcLibModule::COMMIT_DRIVER_VOTE);
-}
-
-
-TcCommonRet TcLibModule::CommitDriverResult() {
- return stub_getMappedResultCode(TcLibModule::COMMIT_DRIVER_RESULT);
-}
-
-
-TcCommonRet TcLibModule::CommitGlobalAbort() {
- return stub_getMappedResultCode(TcLibModule::COMMIT_GLOBAL_ABORT);
-}
-
-TcCommonRet TcLibModule::AuditTransStartEnd(TcMsgOperType oper_type,
- TcAuditTransactionMsg audit_trans_msg) {
- return stub_getMappedResultCode(TcLibModule::AUDIT_TRANS_START);
-}
-
-TcCommonRet TcLibModule::AuditVoteGlobal(TcMsgOperType oper_type,
- TcAuditTransactionMsg audit_trans_msg) {
- return stub_getMappedResultCode(TcLibModule::AUDIT_VOTE_GLOBAL);
-}
-
-TcCommonRet TcLibModule::AuditTransaction() {
- return stub_getMappedResultCode(TcLibModule::AUDIT_TRANS);
-}
-
-TcCommonRet TcLibModule::AuditDriverVoteGlobal() {
- return stub_getMappedResultCode(TcLibModule::AUDIT_DRIVER_VOTE);
-}
-
-TcCommonRet TcLibModule::AuditDriverResult() {
- return stub_getMappedResultCode(TcLibModule::AUDIT_DRIVER_RESULT);
-}
-
-TcCommonRet TcLibModule::AuditGlobalAbort() {
- return stub_getMappedResultCode(TcLibModule::AUDIT_GLOBAL_ABORT);
-}
-
-void ReleaseTransactionResources() {
-}
-
-TcCommonRet TcLibModule::SaveConfiguaration() {
- return stub_getMappedResultCode(TcLibModule::SAVE_CONFIGURATION);
-}
-
-
-TcCommonRet TcLibModule::ClearStartup() {
- return stub_getMappedResultCode(TcLibModule::CLEAR_START_UP);
-}
-
-TcCommonRet TcLibModule::AbortCandidate() {
- return stub_getMappedResultCode(TcLibModule::ABORT_CANDIDATE);
-}
-
-TcCommonRet TcLibModule::AuditConfig() {
- return stub_getMappedResultCode(TcLibModule::AUDIT_CONFIG);
-}
-
-TcCommonRet TcLibModule::Setup() {
- return stub_getMappedResultCode(TcLibModule::SET_UP);
-}
-
-TcCommonRet TcLibModule::SetupComplete() {
- return stub_getMappedResultCode(TcLibModule::SET_UP_COMPLETE);
-}
-
-unc_keytype_ctrtype_t TcLibModule::GetDriverId() {
- return driverId;
-}
-
-unc_keytype_ctrtype_t TcLibModule::GetControllerType() {
- return controllerType;
-}
-
-TcApiCommonRet TcLibModule::GetKeyIndex(std::string controller_id,
- uint32_t err_pos,
- uint32_t &key_index) {
- return stub_getMappedResultCode(TcLibModule::KEY_INDEX);
-}
-
-TcApiCommonRet TcLibModule::stub_getMappedResultCode
- (TcLibModule::TCApiCommonRet methodType) {
- if (0 != method_tcapi_map.count(methodType)) {
- return method_tcapi_map[methodType];
- }
- return TC_API_COMMON_FAILURE;
-}
-
-TcCommonRet TcLibModule::stub_getMappedResultCode
- (TcLibModule::TCCommonRet methodType) {
- if (0 != method_tccommon_map.count(methodType)) {
- return method_tccommon_map[methodType];
- }
- return TC_FAILURE;
-}
-} // namespace tclib
-} // namespace unc
+++ /dev/null
-/*
- * Copyright (c) 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_TCLIB_MODULE_HH_
-#define _UNC_TCLIB_MODULE_HH_
-
-#include <pfcxx/module.hh>
-#include <pfcxx/synch.hh>
-#include <uncxx/tclib/tclib_interface.hh>
-#include <tclib_struct_defs.hh>
-#include <string>
-#include <map>
-
-namespace unc {
-namespace tclib {
-
-class TcLibInterface;
-
-class TcLibModule : public pfc::core::Module {
- public:
- enum TCApiCommonRet {
- REGISTER,
- AUDIT_CONTROLLER,
- VALIDATE_UPDATE,
- READ_KEY_VAL,
- WRITE_CONTROLLER,
- WRITE_KEY_VALUE,
- IS_READ_KEY,
- IS_WRITE_KEY,
- KEY_INDEX,
- };
-
- enum TCCommonRet {
- VALIDATE_OPER_TYPE,
- VALIDATE_COMMIT_OPER,
- VALIDATE_AUDIT_OPER,
- VALIDATE_UPLL_COMMIT,
- VALIDATE_DRIVER_COMMIT,
- VALIDATE_UPLL_AUDIT,
- VALIDATE_DRIVER_AUDIT,
- UPDATE_CONTROLLER_KEY,
- NOTIFY_SESSION_CONFIG,
- COMMIT_TRANS_START,
- COMMIT_VOTE_GLOBAL,
- COMMIT_TRANS,
- COMMIT_DRIVER_VOTE,
- COMMIT_DRIVER_RESULT,
- COMMIT_GLOBAL_ABORT,
- AUDIT_TRANS_START,
- AUDIT_VOTE_GLOBAL,
- AUDIT_TRANS,
- AUDIT_DRIVER_VOTE,
- AUDIT_DRIVER_RESULT,
- AUDIT_GLOBAL_ABORT,
- SAVE_CONFIGURATION,
- CLEAR_START_UP,
- ABORT_CANDIDATE,
- AUDIT_CONFIG,
- SET_UP,
- SET_UP_COMPLETE,
- };
-
- explicit TcLibModule(const pfc_modattr_t *mattr) : pfc::core::Module(mattr) {
- }
-
- ~TcLibModule() {
- }
-
- pfc_bool_t init() {
- return true;
- }
-
- pfc_bool_t fini() {
- return true;
- }
-
- pfc_ipcresp_t ipcService(pfc::core::ipc::ServerSession& sess,
- pfc_ipcid_t service) {
- return pfc_ipcresp_t();
- }
-
- TcApiCommonRet TcLibRegisterHandler(TcLibInterface* handler);
-
- TcApiCommonRet TcLibAuditControllerRequest(std::string controller_id);
-
- TcApiCommonRet TcLibValidateUpdateMsg(uint32_t sessionid, uint32_t configid);
-
- TcApiCommonRet TcLibReadKeyValueDataInfo(std::string controller_id,
- uint32_t err_pos,
- uint32_t key_type,
- pfc_ipcstdef_t key_def,
- pfc_ipcstdef_t value_def,
- void* key_data,
- void* value_data);
-
- TcApiCommonRet TcLibWriteControllerInfo(std::string controller_id,
- uint32_t response_code,
- uint32_t num_of_errors);
- TcApiCommonRet TcLibWriteKeyValueDataInfo(std::string controller_id,
- uint32_t key_type,
- pfc_ipcstdef_t key_def,
- pfc_ipcstdef_t value_def,
- void* key_data,
- void* value_data);
-
- private:
- TcCommonRet ValidateOperTypeSequence(TcMsgOperType oper_type);
-
- TcCommonRet ValidateCommitOperSequence(TcMsgOperType oper_type);
-
- TcCommonRet ValidateAuditOperSequence(TcMsgOperType oper_type);
-
- TcCommonRet ValidateUpllUpplCommitSequence(TcMsgOperType oper_type);
-
- TcCommonRet ValidateDriverCommitSequence(TcMsgOperType oper_type);
-
- TcCommonRet ValidateUpllUpplAuditSequence(TcMsgOperType oper_type);
-
- TcCommonRet ValidateDriverAuditSequence(TcMsgOperType oper_type);
-
- TcApiCommonRet IsReadKeyValueAllowed();
-
- TcApiCommonRet IsWriteKeyValueAllowed();
-
- TcCommonRet UpdateControllerKeyList();
-
- TcCommonRet NotifySessionConfig();
-
- TcCommonRet CommitTransStartEnd(TcMsgOperType oper_type,
- TcCommitTransactionMsg commit_trans_msg);
-
- TcCommonRet CommitVoteGlobal(TcMsgOperType oper_type,
- TcCommitTransactionMsg commit_trans_msg);
-
- TcCommonRet CommitTransaction();
-
- TcCommonRet CommitDriverVoteGlobal();
-
- TcCommonRet CommitDriverResult();
-
- TcCommonRet CommitGlobalAbort();
-
- TcCommonRet AuditTransStartEnd(TcMsgOperType oper_type,
- TcAuditTransactionMsg audit_trans_msg);
-
- TcCommonRet AuditVoteGlobal(TcMsgOperType oper_type,
- TcAuditTransactionMsg audit_trans_msg);
-
- TcCommonRet AuditTransaction();
-
- TcCommonRet AuditDriverVoteGlobal();
-
- TcCommonRet AuditDriverResult();
-
- TcCommonRet AuditGlobalAbort();
-
- void ReleaseTransactionResources();
-
- TcCommonRet SaveConfiguaration();
-
- TcCommonRet ClearStartup();
-
- TcCommonRet AbortCandidate();
-
- TcCommonRet AuditConfig();
-
- TcCommonRet Setup();
-
- TcCommonRet SetupComplete();
-
- unc_keytype_ctrtype_t GetDriverId();
-
- unc_keytype_ctrtype_t GetControllerType();
-
- TcApiCommonRet GetKeyIndex(std::string controller_id,
- uint32_t err_pos,
- uint32_t &key_index);
-
- static inline void Stub_setDriverId(unc_keytype_ctrtype_t driverid ) {
- driverId = driverid;
- }
-
- static inline void stub_setControllerType(unc_keytype_ctrtype_t cntrlrType) {
- controllerType = cntrlrType;
- }
-
- static inline void stub_setKeyIndex(uint32_t index) {
- keyIndex = index;
- }
-
- static void stub_setTcCommonRetcode(TcLibModule::TCCommonRet methodType,
- TcCommonRet res_code) {
- method_tccommon_map.insert(std::make_pair(methodType, res_code));
- }
-
- static void stub_setTCApiCommonRetcode(TcLibModule::TCApiCommonRet methodType,
- TcApiCommonRet res_code) {
- method_tcapi_map.insert(std::make_pair(methodType, res_code));
- }
-
- static void stub_loadtcLibModule(void);
- static void stub_unloadtcLibModule(void);
-
- static void stub_clearTcLibStubData() {
- method_tccommon_map.clear();
- method_tcapi_map.clear();
- }
-
- static TcApiCommonRet stub_getMappedResultCode(TcLibModule::TCApiCommonRet);
- static TcCommonRet stub_getMappedResultCode(TcLibModule::TCCommonRet);
-
- static std::map<TcLibModule::TCCommonRet, TcCommonRet> method_tccommon_map;
- static std::map<TcLibModule::TCApiCommonRet, TcApiCommonRet> method_tcapi_map;
-
- static TcLibInterface *pTcLibInterface_;
-
- static unc_keytype_ctrtype_t driverId;
- static unc_keytype_ctrtype_t controllerType;
- static uint32_t keyIndex;
-};
-} // namespace tclib
-} // namespace unc
-
-#endif /* _UNC_TCLIB_MODULE_HH_ */
+++ /dev/null
-/*
- * Copyright (c) 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 "../../../../../../../modules/tclib/include/tclib_struct_defs.hh"
-
+++ /dev/null
-/*
- * Copyright (c) 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 __CONTROLLER_INTERFACE_HH__
-#define __CONTROLLER_INTERFACE_HH__
-
-#include <unc/keytype.h>
-#include <pfcxx/timer.hh>
-#include <keytree.hh>
-#include <string>
-
-namespace unc {
-namespace driver {
-
-typedef enum {
- CONNECTION_UP = 0,
- CONNECTION_DOWN
-}ConnectionStatus;
-
-
-class controller {
- public:
- /**
- * @brief - Constructor of controller class
- */
- controller() :controller_cache(NULL),
- timed_(NULL),
- connection_status_(CONNECTION_DOWN) {}
- /**
- * @brief - Destructor of controller class
- */
- virtual ~controller() {}
-
- /**
- * @brief - Method to get the type of controller
- * @retval - unc_keytype_ctrtype_t Controller type
- */
- virtual unc_keytype_ctrtype_t get_controller_type() = 0;
-
- /**
- * @brief - Method to get the controller ID
- * @retval - string - Controller ID
- */
- virtual std::string get_controller_id() = 0;
-
- /**
- * @brief - Method Invoked on global commit failure
- * @retval - PFC_TRUE/PFC_FALSE
- */
- virtual pfc_bool_t reset_connect() = 0;
-
- virtual pfc_bool_t update_ctr(const key_ctr_t& key_ctr,
- const val_ctr_t& val_ctr) = 0;
-
-
- /**
- * @brief - Method to get the host address
- * @retval - string - hostaddress
- */
- virtual std::string get_host_address() = 0;
-
- /**
- * @brief - Method to get the audit status
- * @retval - PFC_TRUE/PFC_FALSE
- */
- virtual pfc_bool_t get_audit_status() = 0;
-
- /**
- * @brief - Method to get the user name
- * @retval - string - username configured
- */
- virtual std::string get_user_name() = 0;
-
- /**
- * @brief - Method to get the password
- * @retval - string - password configured
- */
- virtual std::string get_pass_word() = 0;
-
- /**
- * @brief - Method to return connection status of controller
- * @retval - CONNECTION_UP/CONNECTION_DOWN
- */
- ConnectionStatus get_connection_status() {
- return connection_status_;
- }
- /**
- * @brief - Method to set connection status of controller
- * @param[in] - ConnectionStatus - CONNECTION_UP/CONNECTION_DOWN
- */
- void set_connection_status(ConnectionStatus conn_status) {
- connection_status_ = conn_status;
- }
-
- /**
- * @brief - Keytree pointer to access cache manager
- */
- unc::vtndrvcache::KeyTree *controller_cache;
-
- /**
- * @brief - Timer Instance
- */
- pfc::core::Timer* timed_;
-
- private:
- ConnectionStatus connection_status_;
-};
-} // namespace driver
-} // namespace unc
-#endif
+++ /dev/null
-/*
- * Copyright (c) 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 __CDF_DRIVER_COMMANDS_HH__
-#define __CDF_DRIVER_COMMANDS_HH__
-
-#include <driver/controller_interface.hh>
-#include <pfc/ipc_struct.h>
-#include <unc/unc_base.h>
-#include <confignode.hh>
-#include <tclib_module.hh>
-#include <vector>
-#include <string>
-
-namespace unc {
-namespace driver {
-
-typedef struct val_root {
- uint8_t root_key;
-} val_root_t;
-
-/*
- * @desc:Base Class For Driver Commands
- */
-class driver_command {
- public:
- virtual ~driver_command() {}
- virtual unc_key_type_t get_key_type()=0;
-
- /**
- * @brief - Method to revoke the commit with triggring audit for any
- failed Operation
- * @param[in]- controller pointer
- * @retval - DRVAPI_RESPONSE_SUCCESS
- */
- virtual drv_resp_code_t revoke(unc::driver::controller* ctr_ptr) {
- pfc_log_debug("%s Entering function", PFC_FUNCNAME);
-
- // Send start audit notification to TC
- unc::tclib::TcLibModule* ptr_tclib_key_data = NULL;
- ptr_tclib_key_data = static_cast<unc::tclib::TcLibModule*>
- (unc::tclib::TcLibModule::getInstance("tclib"));
-
- PFC_ASSERT(ptr_tclib_key_data != NULL);
-
- std::string controller_name = ctr_ptr->get_controller_id();
- pfc_log_debug("revoke controller_name:%s", controller_name.c_str());
- ptr_tclib_key_data->TcLibAuditControllerRequest(controller_name);
-
- pfc_log_debug("%s Exiting function", PFC_FUNCNAME);
- return DRVAPI_RESPONSE_SUCCESS;
- }
- /**
- * @brief - Method to fetch child configurations for the parent kt
- * @param[in] - controller pointer
- * @param[in] - parent key type pointer
- * @param[out] - list of configurations
- * @retval - DRVAPI_RESPONSE_SUCCESS / DRVAPI_RESPONSE_FAILURE
- */
- virtual drv_resp_code_t fetch_config(unc::driver::controller* ctr,
- void* parent_key,
- std::vector<unc::vtndrvcache::ConfigNode *>&) = 0;
-};
-
-/*
- * @desc:Abstract base Class to be extended for VTN Commands
- */
-class vtn_driver_command: public driver_command {
- public:
- /**
- * @brief - Method to create VTN in the controller
- * @param[in]- key_vtn_t, val_vtn_t, controller*
- * @retval - DRVAPI_RESPONSE_SUCCESS/DRVAPI_RESPONSE_FAILURE
- */
- virtual drv_resp_code_t create_cmd(key_vtn_t& keyvtn_, val_vtn_t& valvtn_,
- unc::driver::controller*)=0;
- /**
- * @brief - Method to update VTN in the controller
- * @param[in]- key_vtn_t, val_vtn_t, controller*
- * @retval - DRVAPI_RESPONSE_SUCCESS/DRVAPI_RESPONSE_FAILURE
- */
- virtual drv_resp_code_t update_cmd(key_vtn_t& keyvtn_, val_vtn_t& valvtn_,
- unc::driver::controller*)=0;
- /**
- * @brief - Method to delete VTN in the controller
- * @param[in]- key_vtn_t, val_vtn_t, controller*
- * @retval - DRVAPI_RESPONSE_SUCCESS/DRVAPI_RESPONSE_FAILURE
- */
- virtual drv_resp_code_t delete_cmd(key_vtn_t& keyvtn_, val_vtn_t& valvtn_,
- unc::driver::controller*)=0;
- /**
- * @brief - Method to return the Keytype
- * @param[in]- None
- * @retval - unc_key_type_t - UNC_KT_VTN
- */
- unc_key_type_t get_key_type() {
- return UNC_KT_VTN;
- }
-};
-
-/*
- * @desc:Abstract base Class to be extended for VBR Commands
- */
-class vbr_driver_command: public driver_command {
- public:
- /**
- * @brief - Method to create Vbridge in the controller
- * @param[in]- key_vbr_t, val_vbr_t, controller*
- * @retval - DRVAPI_RESPONSE_SUCCESS/DRVAPI_RESPONSE_FAILURE
- */
- virtual drv_resp_code_t create_cmd(key_vbr_t& keyvbr_, val_vbr_t& valvbr_,
- unc::driver::controller*) = 0;
- /**
- * @brief - Method to update Vbridge in the controller
- * @param[in]- key_vbr_t, val_vbr_t, controller*
- * @retval - DRVAPI_RESPONSE_SUCCESS/DRVAPI_RESPONSE_FAILURE
- */
- virtual drv_resp_code_t update_cmd(key_vbr_t& keyvbr_, val_vbr_t& valvbr_,
- unc::driver::controller*) = 0;
-
- /**
- * @brief - Method to delete Vbridge in the controller
- * @param[in]- key_vbr_t, val_vbr_t, controller*
- * @retval - DRVAPI_RESPONSE_SUCCESS/DRVAPI_RESPONSE_FAILURE
- */
- virtual drv_resp_code_t delete_cmd(key_vbr_t& keyvbr_, val_vbr_t& valvbr_,
- unc::driver::controller*)=0;
- /**
- * @brief - Method to return the Keytype
- * @param[in]- None
- * @retval - unc_key_type_t - UNC_KT_VBRIDGE
- */
- unc_key_type_t get_key_type() {
- return UNC_KT_VBRIDGE;
- }
-};
-
-/*
- * @desc:Abstract base Class to be extended for VBRIf Commands
- */
-class vbrif_driver_command: public driver_command {
- public:
- /**
- * @brief - Method to create Vbr Interface in the controller
- * @param[in]- key_vbr_if_t, pfcdrv_val_vbr_if_t, controller*
- * @retval - DRVAPI_RESPONSE_SUCCESS/DRVAPI_RESPONSE_FAILURE
- */
- virtual drv_resp_code_t create_cmd(key_vbr_if_t& key,
- pfcdrv_val_vbr_if_t& val,
- unc::driver::controller *conn)=0;
-
- /**
- * @brief - Method to update Vbr Interface in the controller
- * @param[in]- key_vbr_if_t, pfcdrv_val_vbr_if_t, controller*
- * @retval - DRVAPI_RESPONSE_SUCCESS/DRVAPI_RESPONSE_FAILURE
- */
- virtual drv_resp_code_t update_cmd(key_vbr_if_t& key,
- pfcdrv_val_vbr_if_t& val,
- unc::driver::controller *conn) = 0;
-
- /**
- * @brief - Method to delete Vbr Interface in the controller
- * @param[in]- key_vbr_if_t, pfcdrv_val_vbr_if_t, controller*
- * @retval - DRVAPI_RESPONSE_SUCCESS/DRVAPI_RESPONSE_FAILURE
- */
- virtual drv_resp_code_t delete_cmd(key_vbr_if_t& key,
- pfcdrv_val_vbr_if_t& val,
- unc::driver::controller *conn) = 0;
-
- /**
- * @brief - Method to return the Keytype
- * @param[in]- None
- * @retval - unc_key_type_t - UNC_KT_VBR_IF
- */
- unc_key_type_t get_key_type() {
- return UNC_KT_VBR_IF;
- }
-};
-
-class vbrvlanmap_driver_command: public driver_command {
- public:
- /**
- * @brief - Method to create Vbr VLAN-Map in the controller
- * @param[in]- key_vlan_map_t, val_vlan_map_t, controller*
- * @retval - DRVAPI_RESPONSE_SUCCESS/DRVAPI_RESPONSE_FAILURE
- */
- virtual drv_resp_code_t create_cmd(key_vlan_map_t& key,
- val_vlan_map_t& val,
- unc::driver::controller *conn)=0;
-
- /**
- * @brief - Method to update Vbr VLAN-Map in the controller
- * @param[in]- key_vlan_map_t, val_vlan_map_t, controller*
- * @retval - DRVAPI_RESPONSE_SUCCESS/DRVAPI_RESPONSE_FAILURE
- */
- virtual drv_resp_code_t update_cmd(key_vlan_map_t& key,
- val_vlan_map_t& val,
- unc::driver::controller *conn) = 0;
-
- /**
- * @brief - Method to delete Vbr VLAN-Map in the controller
- * @param[in]- key_vlan_map_t, val_vlan_map_t, controller*
- * @retval - DRVAPI_RESPONSE_SUCCESS/DRVAPI_RESPONSE_FAILURE
- */
- virtual drv_resp_code_t delete_cmd(key_vlan_map_t& key,
- val_vlan_map_t& val,
- unc::driver::controller *conn) = 0;
-
- /**
- * @brief - Method to return the Keytype
- * @param[in]- None
- * @retval - unc_key_type_t - UNC_KT_VBR_VLANMAP
- */
- unc_key_type_t get_key_type() {
- return UNC_KT_VBR_VLANMAP;
- }
-};
-
-/*
- * @desc:Abstract base Class to be extended for VBRIf Commands
- */
-class controller_command: public driver_command {
- public:
- /**
- * @brief - Method to create controller configuration
- * @param[in]- key_ctr_t, val_ctr_t, controller*
- * @retval - DRVAPI_RESPONSE_FAILURE
- */
- drv_resp_code_t create_cmd(key_ctr_t& key,
- val_ctr_t & val, unc::driver::controller *conn) {
- return DRVAPI_RESPONSE_FAILURE;
- }
-
- /**
- * @brief - Method to update controller configuration
- * @param[in]- key_ctr_t, val_ctr_t, controller*
- * @retval - DRVAPI_RESPONSE_FAILURE
- */
- drv_resp_code_t update_cmd(key_ctr_t & key,
- val_ctr_t& val, unc::driver::controller *conn) {
- return DRVAPI_RESPONSE_FAILURE;
- }
-
- /**
- * @brief - Method to update controller configuration
- * @param[in]- key_ctr_t, val_ctr_t, controller*
- * @retval - DRVAPI_RESPONSE_FAILURE
- */
- drv_resp_code_t delete_cmd(key_ctr_t & key,
- val_ctr_t & val, unc::driver::controller *conn) {
- return DRVAPI_RESPONSE_FAILURE;
- }
-
- /**
- * @brief - Method to return the Keytype
- * @param[in]- None
- * @retval - unc_key_type_t - UNC_KT_CONTROLLER
- */
- unc_key_type_t get_key_type() {
- return UNC_KT_CONTROLLER;
- }
-};
-
-/*
- * @desc:Abstract base Class to be extended for Audit KT_ROOT Commands
- */
-class root_driver_command : public driver_command {
- public:
- /**
- * @brief - Method to form the create command for Audit
- * @param[in]- key_root_t, val_root_t, controller*
- * @retval - DRVAPI_RESPONSE_SUCCESS/DRVAPI_RESPONSE_FAILURE
- */
- virtual drv_resp_code_t
- create_cmd(key_root_t& key,
- val_root_t & val,
- unc::driver::controller *conn) = 0;
-
- /**
- * @brief - Method to form the KT_ROOT update oommand
- * @param[in]- key_root_t, val_root_t, controller*
- * @retval - DRVAPI_RESPONSE_SUCCESS/DRVAPI_RESPONSE_FAILURE
- */
- virtual drv_resp_code_t
- update_cmd(key_root_t& key,
- val_root_t & val,
- unc::driver::controller *conn) = 0;
-
- /**
- * @brief - Method to form the KT_ROOT delete oommand
- * @param[in]- key_root_t, val_root_t, controller*
- * @retval - DRVAPI_RESPONSE_SUCCESS/DRVAPI_RESPONSE_FAILURE
- */
- virtual drv_resp_code_t
- delete_cmd(key_root_t& key,
- val_root_t & val,
- unc::driver::controller *conn)=0;
-
- /**
- * @brief - Method to read configurations during Audit
- * @param[in]- vector<unc::vtndrvcache::ConfigNode*>, controller*
- * @retval - DRVAPI_RESPONSE_SUCCESS/DRVAPI_RESPONSE_FAILURE
- */
- virtual drv_resp_code_t
- read_root_child(std::vector<unc::vtndrvcache::ConfigNode*>&,
- unc::driver::controller*) = 0;
-
- /**
- * @brief - Method to read configurations from controller during Audit
- * @param[in]- vector<unc::vtndrvcache::ConfigNode*>, controller*
- * @retval - DRVAPI_RESPONSE_SUCCESS/DRVAPI_RESPONSE_FAILURE
- */
- virtual drv_resp_code_t
- read_all_child(unc::vtndrvcache::ConfigNode*,
- std::vector<unc::vtndrvcache::ConfigNode*>&,
- unc::driver::controller*)=0;
- /**
- * @brief - Method to return the Keytype
- * @param[in]- None
- * @retval - unc_key_type_t - UNC_KT_ROOT
- */
- unc_key_type_t get_key_type() {
- return UNC_KT_ROOT;
- }
-};
-} // namespace driver
-} // namespace unc
-#endif
+++ /dev/null
-/*
- * Copyright (c) 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 __DRIVER_INTERFACE_HH__
-#define __DRIVER_INTERFACE_HH__
-
-#include <driver/controller_interface.hh>
-#include <driver/driver_command.hh>
-#include <pfc/ipc_struct.h>
-#include <unc/keytype.h>
-#include <uncxx/tclib/tclib_defs.hh>
-
-namespace unc {
-namespace driver {
-
-class driver {
- public:
- /**
- * @brief - Method to check if two phase commit support is needed
- * @retval - PFC_TRUE/PFC_FALSE
- */
- virtual pfc_bool_t is_2ph_commit_support_needed() =0;
-
- /**
- * @brief - Method to check if needs driver needs audit support
- * @retval - PFC_TRUE/PFC_FALSE
- */
- virtual pfc_bool_t is_audit_collection_needed() =0;
-
- /**
- * @brief - Method to add controller
- * @param[in] - key_ctr_t,val_ctr_t
- * @retval - controller* - Instance of controller
- */
- virtual controller* add_controller(const key_ctr_t& key_ctr,
- const val_ctr_t& val_ctr)=0;
- /**
- * @brief - Method to update controller
- * @param[in] - key_ctr_t,val_ctr_t,controller*
- * @retval - controller* - Instance of controller
- */
- virtual pfc_bool_t update_controller(const key_ctr_t& key_ctr,
- const val_ctr_t& val_ctr,
- controller* ctrl_inst)=0;
-
- /**
- * @brief - Method to retrieve the type of Controller supported by driver
- * @retval - unc_keytype_ctrtype_t - Type of controller
- */
- virtual unc_keytype_ctrtype_t get_controller_type() =0;
-
- /**
- * @brief - Method to delete controller
- * @param[in] - controller* - Instance of controller
- * @retval - PFC_TRUE/PFC_FALSE
- */
- virtual pfc_bool_t delete_controller(controller* delete_inst)=0;
-
- /**
- * @brief - Method to get the driver command ptr for particular KT
- * @param[in] - key_type
- * @retval - driver_command* - command pointer of Keytype
- */
- virtual driver_command* create_driver_command(unc_key_type_t key_type)=0;
-
- /**
- * @brief - Method to handle vote request of transaction
- * @param[in] - controller* -Instance of controller
- * @retval - TcCommonRet - TC return code
- */
- virtual unc::tclib::TcCommonRet HandleVote(controller* ctlptr)=0;
- /**
- * @brief - Method to handle global commit request of transaction
- * @param[in] - controller* -Instance of controller
- * @retval - TcCommonRet - TC return code
- */
- virtual unc::tclib::TcCommonRet HandleCommit(controller* ctlptr)=0;
-
- /**
- * @brief - Method to get the abort request of transaction
- * @param[in] - controller* -Instance of controller
- * @retval - TcCommonRet - TC return code
- */
- virtual unc::tclib::TcCommonRet HandleAbort(controller* ctlptr)=0;
-
- /**
- * @brief - Method to check if ping is needed by the controller
- * @retval - PFC_TRUE/PFC_FALSE
- */
- virtual pfc_bool_t is_ping_needed() = 0;
-
- /**
- * @brief - Method to retrive the ping Interval
- * @retval - uint32_t - ping Interval in secs
- */
- virtual uint32_t get_ping_interval() = 0;
-
- /**
- * @brief - Method to retrive the Ping Retry Count
- * @retval - uint32_t - ping retry count
- */
- virtual uint32_t get_ping_fail_retry_count() = 0;
-
- /**
- * @brief - Method to ping the controller
- * @param[in] - controller* -Instance of controller
- * @retval - PFC_TRUE/PFC_FALSE
- */
- virtual pfc_bool_t ping_controller(unc::driver::controller*) = 0;
-
- /**
- * @brief - Virtual destructort
- */
- virtual ~driver() {}
-};
-} // namespace driver
-} // namespace unc
-#endif
+++ /dev/null
-/*
- * Copyright (c) 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 __VTNDRVMOD_STUB_HH__
-#define __VTNDRVMOD_STUB_HH__
-#include <driver/driver_command.hh>
-#include <driver/driver_interface.hh>
-#include <pfcxx/module.hh>
-
-typedef enum {
- VTN_DRV_RET_SUCCESS = 0,
- VTN_DRV_RET_FAILURE
-}VtnDrvRetEnum;
-
-using namespace pfc::core;
-
-namespace unc {
-namespace driver {
-
-class VtnDrvIntf :public pfc::core::Module {
- public:
- /**
- * @brief : Constructor
- * @param[in] : pfc_modattr_t*
- **/
- explicit VtnDrvIntf(const pfc_modattr_t* attr): Module(attr) {}
-
- /**
- * @brief : Destructor
- **/
- ~VtnDrvIntf() {}
-
- /**
- * @brief : This Function is called to load the
- * vtndrvintf module
- * @return : PFC_TRUE/PFC_FALSE
- **/
- inline pfc_bool_t init(void) {
- return PFC_FALSE;
- }
-
- /**
- * @brief : This Function is called to unload the
- * vtndrvintf module
- * @return : PFC_TRUE/PFC_FALSE
- **/
- inline pfc_bool_t fini(void) {
- return PFC_FALSE;
- }
-
- /**
- * @brief : This Function is called to register the driver handler
- * with respect to the controller type
- * @param[in] : driver *
- * @return : VTN_DRV_RET_FAILURE /VTN_DRV_RET_SUCCESS
- **/
- inline VtnDrvRetEnum register_driver(driver *drv_obj) {
- return VTN_DRV_RET_SUCCESS;
- }
-};
-} // namespace driver
-} // namespace unc
-#endif
+++ /dev/null
-/*
- * Copyright (c) 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 _VTNDRVINTF_DEFS_H_
-#define _VTNDRVINTF_DEFS_H_
-
-typedef enum {
- VTN_DRV_RET_SUCCESS = 0,
- VTN_DRV_RET_FAILURE
-}VtnDrvRetEnum;
-#endif // _VTNDRVINTF_DEFS_H_
* Include stub header files.
*/
-#include "stub/include/core_include/pfc/module.h"
-#include "stub/include/core_include/pfc/ipc_client.h"
-
#ifdef __cplusplus
+#include "stub/tclib_module/tclib_module.hh"
#include "stub/include/cxx/pfcxx/ipc_server.hh"
#include "stub/include/cxx/pfcxx/ipc_client.hh"
#include "stub/include/cxx/pfcxx/module.hh"
-#include "stub/tclib_module/tclib_module.hh"
-#include "stub/restjsonutil/rest_util.hh"
#include "stub/restjsonutil/json_build_parse.hh"
+#include "stub/restjsonutil/rest_util.hh"
#include "stub/restjsonutil/json_type_util.hh"
#include "stub/restjsonutil/rest_common_defs.hh"
-#include "stub/vtndrvintf/vtn_drv_module.hh"
+#include "stub/ContrllerFrameworkStub/vtn_drv_module.hh"
+#include "stub/ContrllerFrameworkStub/controller_fw.hh"
#endif /*cplusplus */
#endif // _UT_STUB_H_