From 91a03c5c8cf08719a213570cfcd7f73feb8b1002 Mon Sep 17 00:00:00 2001 From: "James R. Leu" Date: Fri, 5 Sep 2003 23:10:10 -0600 Subject: [PATCH] Mirror the interface changes from ldp to lsr: -no name -no localaddress -allow sets with index or handle as the key [git-p4: depot-paths = "//depot/ldp-portable/": change = 406] --- lsr/lsr_cfg.c | 44 ++++++++++++++++++++++++-------------------- lsr/lsr_cfg.h | 1 + lsr/lsr_global.c | 2 +- lsr/lsr_global.h | 2 +- lsr/lsr_struct.h | 1 - 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/lsr/lsr_cfg.c b/lsr/lsr_cfg.c index df2a1b0..a8ce6ab 100644 --- a/lsr/lsr_cfg.c +++ b/lsr/lsr_cfg.c @@ -783,15 +783,17 @@ mpls_return_enum lsr_cfg_if_get(mpls_cfg_handle handle, lsr_if * i, uint32_t fla mpls_lock_get(global->global_lock); /* LOCK */ - if (lsr_global_find_if_index(global, i->index, &iff) != MPLS_SUCCESS) + if (flag & LSR_IF_CFG_BY_INDEX) { + lsr_global_find_if_index(global, i->index, &iff); + } else { + iff = lsr_global_find_if_handle(global, i->handle); + } + if (!iff) goto lsr_cfg_if_get_end; if (LSR_IF_CFG_INDEX & flag) { i->index = iff->index; } - if (LSR_IF_CFG_NAME & flag) { - strncpy(i->name, iff->name, MPLS_MAX_IF_NAME); - } if (LSR_IF_CFG_OPER_STATE & flag) { i->oper_state = iff->oper_state; } @@ -891,41 +893,43 @@ mpls_return_enum lsr_cfg_if_set(mpls_cfg_handle handle, lsr_if * i, uint32_t fla mpls_lock_get(global->global_lock); /* LOCK */ if (flag & LSR_CFG_ADD) { - if ((iff = lsr_if_create()) == NULL) { + if (mpls_if_handle_verify(global->ifmgr_handle, i->handle) == + MPLS_BOOL_FALSE) { + /* ADDs must supply a valid handle */ goto lsr_cfg_if_set_end; } - i->handle = mpls_ifmgr_open_if(global->ifmgr_handle, i->name); - if (mpls_if_handle_verify(global->ifmgr_handle, i->handle) == MPLS_BOOL_FALSE) { - lsr_if_delete(iff); + if ((iff = lsr_if_create()) == NULL) { goto lsr_cfg_if_set_end; } + + /* ADDs must supply the handle */ iff->handle = i->handle; - i->index = iff->index; - strncpy(iff->name, i->name, MPLS_MAX_IF_NAME); _lsr_global_add_if(global, iff); + + /* return the newly allocated index to the user */ + i->index = iff->index; } else { - lsr_global_find_if_index(global, i->index, &iff); + if (flag & LSR_IF_CFG_BY_INDEX) { + lsr_global_find_if_index(global, i->index, &iff); + } else { + iff = lsr_global_find_if_handle(global, i->handle); + } } if ((iff == NULL) || ((flag & LSR_IF_CFG_WHEN_DOWN) && (iff->oper_state == MPLS_OPER_UP))) goto lsr_cfg_if_set_end; - if (flag & LSR_CFG_DEL) { + if (LSR_IF_CFG_OPER_STATE & flag) { + iff->oper_state = i->oper_state; + } + if (flag & LSR_CFG_DEL) { _lsr_global_del_if(global, iff); - retval = MPLS_SUCCESS; goto lsr_cfg_if_set_end; } - if (LSR_IF_CFG_NAME & flag) { - strncpy(iff->name, i->name, MPLS_MAX_IF_NAME); - } - if (LSR_IF_CFG_OPER_STATE & flag) { - iff->oper_state = i->oper_state; - } - retval = MPLS_SUCCESS; lsr_cfg_if_set_end: diff --git a/lsr/lsr_cfg.h b/lsr/lsr_cfg.h index e9fbbb8..e57a6eb 100644 --- a/lsr/lsr_cfg.h +++ b/lsr/lsr_cfg.h @@ -62,6 +62,7 @@ #define LSR_IF_CFG_INDEX 0x00000002 #define LSR_IF_CFG_OPER_STATE 0x00000004 #define LSR_IF_CFG_NAME 0x00000008 +#define LSR_IF_CFG_BY_INDEX 0x00000010 #define LSR_IF_CFG_WHEN_DOWN (LSR_CFG_DEL|\ LSR_IF_CFG_NAME) diff --git a/lsr/lsr_global.c b/lsr/lsr_global.c index 83b4e95..3dac889 100644 --- a/lsr/lsr_global.c +++ b/lsr/lsr_global.c @@ -169,7 +169,7 @@ mpls_return_enum lsr_global_find_if_index(lsr_global * g, uint32_t index, return MPLS_FAILURE; } -lsr_if * lsr_global_find_if_ifhandle(lsr_global * g, mpls_if_handle ifhandle) +lsr_if * lsr_global_find_if_handle(lsr_global * g, mpls_if_handle ifhandle) { lsr_if *i = NULL; diff --git a/lsr/lsr_global.h b/lsr/lsr_global.h index ee3072f..1cacb87 100644 --- a/lsr/lsr_global.h +++ b/lsr/lsr_global.h @@ -44,7 +44,7 @@ extern mpls_return_enum lsr_global_find_if_index(lsr_global * g, uint32_t index, lsr_if **); extern mpls_return_enum _lsr_global_add_if(lsr_global * g, lsr_if * i); extern mpls_return_enum _lsr_global_del_if(lsr_global * g, lsr_if * i); -extern lsr_if * lsr_global_find_if_ifhandle(lsr_global * g, mpls_if_handle ifhandle); +extern lsr_if * lsr_global_find_if_handle(lsr_global * g, mpls_if_handle ifhandle); extern mpls_return_enum lsr_global_find_ftn_index(lsr_global *, uint32_t, lsr_ftn **); diff --git a/lsr/lsr_struct.h b/lsr/lsr_struct.h index b6afd72..de14a5b 100644 --- a/lsr/lsr_struct.h +++ b/lsr/lsr_struct.h @@ -89,7 +89,6 @@ typedef struct lsr_if { struct lsr_outsegment_list outsegment_root; uint32_t index; - char name[MPLS_MAX_IF_NAME]; mpls_oper_state_enum oper_state; mpls_if_handle handle; -- 2.11.4.GIT