}
#if VPP_API_TEST_BUILTIN == 0
-static void vl_api_sw_interface_set_flags_t_handler
- (vl_api_sw_interface_set_flags_t * mp)
+static void vl_api_sw_interface_event_t_handler
+ (vl_api_sw_interface_event_t * mp)
{
vat_main_t *vam = &vat_main;
if (vam->interface_event_display)
}
#endif
-static void vl_api_sw_interface_set_flags_t_handler_json
- (vl_api_sw_interface_set_flags_t * mp)
+static void vl_api_sw_interface_event_t_handler_json
+ (vl_api_sw_interface_event_t * mp)
{
/* JSON output not supported */
}
_(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply)
#define foreach_standalone_reply_msg \
-_(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
+_(SW_INTERFACE_EVENT, sw_interface_event) \
_(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
_(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
_(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
vl_api_sw_interface_set_flags_t *mp;
u32 sw_if_index;
u8 sw_if_index_set = 0;
- u8 admin_up = 0, link_up = 0;
+ u8 admin_up = 0;
int ret;
/* Parse args required to build the message */
admin_up = 1;
else if (unformat (i, "admin-down"))
admin_up = 0;
- else if (unformat (i, "link-up"))
- link_up = 1;
- else if (unformat (i, "link-down"))
- link_up = 0;
else
if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
sw_if_index_set = 1;
M (SW_INTERFACE_SET_FLAGS, mp);
mp->sw_if_index = ntohl (sw_if_index);
mp->admin_up_down = admin_up;
- mp->link_up_down = link_up;
/* send it... */
S (mp);
* WARNING: replicated pending api refactor completion
*/
static void
-send_sw_interface_flags_deleted (vpe_api_main_t * am,
+send_sw_interface_event_deleted (vpe_api_main_t * am,
unix_shared_memory_queue_t * q,
u32 sw_if_index)
{
- vl_api_sw_interface_set_flags_t *mp;
+ vl_api_sw_interface_event_t *mp;
mp = vl_msg_api_alloc (sizeof (*mp));
memset (mp, 0, sizeof (*mp));
return;
vnet_clear_sw_interface_tag (vnm, sw_if_index);
- send_sw_interface_flags_deleted (vam, q, sw_if_index);
+ send_sw_interface_event_deleted (vam, q, sw_if_index);
}
}
@param sw_if_index - index of the interface to set flags on
@param admin_up_down - set the admin state, 1 = up, 0 = down
@param link_up_down - Oper state sent on change event, not used in config.
- @param deleted - interface was deleted
*/
autoreply define sw_interface_set_flags
{
u32 sw_if_index;
/* 1 = up, 0 = down */
u8 admin_up_down;
- u8 link_up_down;
- u8 deleted;
};
/** \brief Set interface MTU
u16 mtu;
};
+/** \brief Interface Event generated by want_interface_events
+ @param context - sender context, to match reply w/ request
+ @param sw_if_index - index of the interface of the event
+ @param admin_up_down - The administrative state; 1 = up, 0 = down
+ @param link_up_down - The operational state; 1 = up, 0 = down
+ @param deleted - interface was deleted
+*/
+define sw_interface_event
+{
+ u32 context;
+ u32 sw_if_index;
+ u8 admin_up_down;
+ u8 link_up_down;
+ u8 deleted;
+};
+
/** \brief Register for interface events
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
}
static void
-send_sw_interface_flags (vpe_api_main_t * am,
+send_sw_interface_event (vpe_api_main_t * am,
unix_shared_memory_queue_t * q,
vnet_sw_interface_t * swif)
{
- vl_api_sw_interface_set_flags_t *mp;
+ vl_api_sw_interface_event_t *mp;
vnet_main_t *vnm = am->vnet_main;
vnet_hw_interface_t *hi = vnet_get_sup_hw_interface (vnm,
swif->sw_if_index);
mp = vl_msg_api_alloc (sizeof (*mp));
memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_SET_FLAGS);
+ mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_EVENT);
mp->sw_if_index = ntohl (swif->sw_if_index);
mp->admin_up_down = (swif->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? 1 : 0;
event_data[i]))
{
swif = vnet_get_sw_interface (vnm, event_data[i]);
- send_sw_interface_flags (vam, q, swif);
+ send_sw_interface_event (vam, q, swif);
}
}
}));
* WARNING: replicated pending api refactor completion
*/
static void
-send_sw_interface_flags_deleted (vpe_api_main_t * am,
+send_sw_interface_event_deleted (vpe_api_main_t * am,
unix_shared_memory_queue_t * q,
u32 sw_if_index)
{
- vl_api_sw_interface_set_flags_t *mp;
+ vl_api_sw_interface_event_t *mp;
mp = vl_msg_api_alloc (sizeof (*mp));
memset (mp, 0, sizeof (*mp));
vl_msg_api_send_shmem (q, (u8 *) & rmp);
if (!rv)
- send_sw_interface_flags_deleted (vam, q, sw_if_index);
+ send_sw_interface_event_deleted (vam, q, sw_if_index);
}
static void
System.out.println("Successfully connected to VPP");
final AutoCloseable notificationListenerReg =
- jvppCallbackFacade.getNotificationRegistry().registerSwInterfaceSetFlagsNotificationCallback(
+ jvppCallbackFacade.getNotificationRegistry().registerSwInterfaceEventNotificationCallback(
NotificationUtils::printNotification
);
import io.fd.vpp.jvpp.JVppRegistryImpl;
import io.fd.vpp.jvpp.VppCallbackException;
import io.fd.vpp.jvpp.core.JVppCoreImpl;
-import io.fd.vpp.jvpp.core.callback.SwInterfaceSetFlagsCallback;
-import io.fd.vpp.jvpp.core.callback.SwInterfaceSetFlagsNotificationCallback;
+import io.fd.vpp.jvpp.core.callback.SwInterfaceEventNotificationCallback;
import io.fd.vpp.jvpp.core.callback.WantInterfaceEventsCallback;
-import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlagsNotification;
+import io.fd.vpp.jvpp.core.dto.SwInterfaceEventNotification;
import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlagsReply;
import io.fd.vpp.jvpp.core.dto.WantInterfaceEventsReply;
testCallbackApi();
}
- private static class TestCallback implements SwInterfaceSetFlagsNotificationCallback,
- WantInterfaceEventsCallback, SwInterfaceSetFlagsCallback {
+ private static class TestCallback implements SwInterfaceEventNotificationCallback,
+ WantInterfaceEventsCallback {
@Override
- public void onSwInterfaceSetFlagsNotification(
- final SwInterfaceSetFlagsNotification msg) {
+ public void onSwInterfaceEventNotification(
+ final SwInterfaceEventNotification msg) {
printNotification(msg);
}
System.out.println("Interface notification stream updated");
}
- @Override
- public void onSwInterfaceSetFlagsReply(final SwInterfaceSetFlagsReply swInterfaceSetFlagsReply) {
- System.out.println("Interface flags set successfully");
- }
-
@Override
public void onError(VppCallbackException ex) {
System.out.printf("Received onError exception in getNodeIndexCallback: call=%s, reply=%d, context=%d%n",
final FutureJVppCoreFacade jvppFacade = new FutureJVppCoreFacade(registry, new JVppCoreImpl());
final AutoCloseable notificationListenerReg =
jvppFacade.getNotificationRegistry()
- .registerSwInterfaceSetFlagsNotificationCallback(NotificationUtils::printNotification)) {
+ .registerSwInterfaceEventNotificationCallback(NotificationUtils::printNotification)) {
System.out.println("Successfully connected to VPP");
jvppFacade.wantInterfaceEvents(getEnableInterfaceNotificationsReq()).toCompletableFuture().get();
System.out.println("Interface events started");
import java.io.PrintStream;
import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlags;
-import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlagsNotification;
+import io.fd.vpp.jvpp.core.dto.SwInterfaceEventNotification;
import io.fd.vpp.jvpp.core.dto.WantInterfaceEvents;
final class NotificationUtils {
private NotificationUtils() {}
- static PrintStream printNotification(final SwInterfaceSetFlagsNotification msg) {
+ static PrintStream printNotification(final SwInterfaceEventNotification msg) {
return System.out.printf("Received interface notification: ifc: %s%n", msg);
}
final SwInterfaceSetFlags swInterfaceSetFlags = new SwInterfaceSetFlags();
swInterfaceSetFlags.swIfIndex = 0;
swInterfaceSetFlags.adminUpDown = 1;
- swInterfaceSetFlags.deleted = 0;
return swInterfaceSetFlags;
}
#
# FIXME no convention in the naming of events (notifications) in vpe.api
notifications_message_suffixes = ("event", "counters")
-notification_messages_reused = ["sw_interface_set_flags"]
# messages that must be ignored. These messages are INSUFFICIENTLY marked as disabled in vpe.api
# FIXME
def is_notification(name):
""" Returns true if the structure is a notification regardless of its no other use """
- return is_just_notification(name) or name.lower() in notification_messages_reused
+ return is_just_notification(name)
def is_just_notification(name):
s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
+ if (mp->admin_up_down)
+ s = format (s, "admin-up ");
+ else
+ s = format (s, "admin-down ");
+
+ FINISH;
+}
+
+static void *vl_api_sw_interface_event_t_print
+ (vl_api_sw_interface_event_t * mp, void *handle)
+{
+ u8 *s;
+ s = format (0, "SCRIPT: sw_interface_event ");
+
+ s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
+
if (mp->admin_up_down)
s = format (s, "admin-up ");
else
else
s = format (s, "link-down");
+ if (mp->deleted)
+ s = format (s, " deleted");
+
FINISH;
}
_(CREATE_LOOPBACK, create_loopback) \
_(CREATE_LOOPBACK_INSTANCE, create_loopback_instance) \
_(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
+_(SW_INTERFACE_EVENT, sw_interface_event) \
_(SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address) \
_(SW_INTERFACE_SET_TABLE, sw_interface_set_table) \
_(SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable) \
'tag1': tag1,
'tag2': tag2})
- def sw_interface_set_flags(self, sw_if_index, admin_up_down,
- link_up_down=0, deleted=0):
+ def sw_interface_set_flags(self, sw_if_index, admin_up_down):
"""
:param admin_up_down:
:param sw_if_index:
- :param link_up_down: (Default value = 0)
- :param deleted: (Default value = 0)
"""
return self.api(self.papi.sw_interface_set_flags,
{'sw_if_index': sw_if_index,
- 'admin_up_down': admin_up_down,
- 'link_up_down': link_up_down,
- 'deleted': deleted})
+ 'admin_up_down': admin_up_down})
def create_subif(self, sw_if_index, sub_id, outer_vlan, inner_vlan,
no_tags=0, one_tag=0, two_tags=0, dot1ad=0, exact_match=0,