original files of m241
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/* 00comp_ipnet_mpls.cdf - IPNet MPLS configuration file */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Wind River Systems, Inc.
|
||||
*
|
||||
* The right to copy, distribute or otherwise make use of this software
|
||||
* may be licensed only pursuant to the terms of an applicable Wind River
|
||||
* license agreement. No license to Wind River intellectual property rights
|
||||
* is granted herein. All rights not licensed by Wind River are reserved
|
||||
* by Wind River.
|
||||
*/
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01a,22sep06,kch created.
|
||||
*/
|
||||
|
||||
#ifdef _WRS_CONFIG_COMPONENT_IPMPLS
|
||||
|
||||
Folder FOLDER_MPLS {
|
||||
NAME MPLS Components
|
||||
SYNOPSIS MPLS Components
|
||||
CHILDREN INCLUDE_IPMPLS \
|
||||
INCLUDE_IPMPLS_CMD
|
||||
}
|
||||
|
||||
#endif /* _WRS_CONFIG_COMPONENT_IPMPLS */
|
||||
@@ -0,0 +1,66 @@
|
||||
/* 00comp_ipnet_mpls.cdf - IPNet MPLS configuration file */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007 Wind River Systems, Inc.
|
||||
*
|
||||
* The right to copy, distribute or otherwise make use of this software
|
||||
* may be licensed only pursuant to the terms of an applicable Wind River
|
||||
* license agreement. No license to Wind River intellectual property rights
|
||||
* is granted herein. All rights not licensed by Wind River are reserved
|
||||
* by Wind River.
|
||||
*/
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01e,19sep07,rme Added missing backslash
|
||||
01d,08jan07,kch Fixed INCLUDE_IPMPLS_TUNNEL dependencies.
|
||||
01c,14dec06,kch Replaced MPLS_FWCONF_CMD_LIST with IPMPLS_FWCONF_SYSVAR.
|
||||
01b,27sep06,kch Added MPLS configuration parameters.
|
||||
01a,22sep06,kch created.
|
||||
*/
|
||||
|
||||
#ifdef _WRS_CONFIG_COMPONENT_IPMPLS
|
||||
|
||||
Component INCLUDE_IPMPLS_TUNNEL {
|
||||
NAME MPLS Tunnel Interface support
|
||||
SYNOPSIS MPLS Tunnel Interface support.
|
||||
MODULES ipnet_mpls.o
|
||||
LINK_SYMS ipcom_mpls_ioevent
|
||||
REQUIRES INCLUDE_IPNET
|
||||
_CHILDREN FOLDER_MPLS
|
||||
}
|
||||
|
||||
Component INCLUDE_IPMPLS {
|
||||
NAME MPLS
|
||||
SYNOPSIS MPLS
|
||||
MODULES ipmpls.o
|
||||
LINK_SYMS ipmpls_create
|
||||
REQUIRES INCLUDE_IPMPLS_TUNNEL INCLUDE_IPCOM_SHELL_CMD
|
||||
CONFIGLETTES ipmpls_config.c
|
||||
CFG_PARAMS IPMPLS_FWCONF_SYSVAR
|
||||
}
|
||||
|
||||
/******************** Configuration Parameters *****************************/
|
||||
|
||||
/* INCLUDE_IPMPLS configuration parameters */
|
||||
Parameter IPMPLS_FWCONF_SYSVAR {
|
||||
NAME MPLS network pre-configuration
|
||||
SYNOPSIS The MPLS network pre-configuration array is used to \
|
||||
statically configure MPLS forwarding with an initial setup \
|
||||
when IPMPLS is initialized. Each system variable in this \
|
||||
array must be named according to the rule \
|
||||
ipmpls.fwconf.<index>, where <index> is a unique line \
|
||||
indicator. The value of each system variable must be composed \
|
||||
of the IPMPLS shell command mplsctl together with the \
|
||||
flags/paramters that normally are invoked from the IPCOM \
|
||||
shell. The commands are executed in the order they are \
|
||||
defined. It is important that the "silent" flag "-s" is \
|
||||
included on each statement. See the ipmpls_fwdconf_sysvar \
|
||||
Ipcom_sysvar array in the ipmpls_config.c configlette for \
|
||||
the example usage.
|
||||
TYPE void *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
#endif /* _WRS_CONFIG_COMPONENT_IPMPLS */
|
||||
@@ -0,0 +1,11 @@
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: common.vxconfig,v $ $Revision: 1.7 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipmpls/config/common.vxconfig,v $
|
||||
# $Author: jonas $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
|
||||
#hidden option that enables IPMPLS
|
||||
config SUPPORTS_MPLS
|
||||
bool
|
||||
default y
|
||||
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK CONFIGURATION SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmpls_config.c,v $ $Revision: 1.9 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmpls/config/ipmpls_config.c,v $
|
||||
* $Author: jonas $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* Copyright 2000-2010 Interpeak AB (http://www.interpeak.se). All rights reserved.
|
||||
*
|
||||
* Design and implementation by Jonas Rendel <Jonas.Rendel@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01d,30sep10,jre Merged with the ipmpls_config.c adapted for VxWorks.
|
||||
01c,03jan07,kch Updated CVS revision log entry for Jan 03 code drop.
|
||||
01b,14dec06,kch Reverted to the original implementation - use Ipcom_sysvar
|
||||
instead of Ipcom_sysvar_ext and replaced MPLS_FWCONF_CMD_LIST
|
||||
with IPMPLS_FWCONF_SYSVAR.
|
||||
01a,22sep06,kch Integrated to VxWorks build mechanism.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmpls_config.h"
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
#include <ipcom_err.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
IP_PUBLIC Ip_err ipmpls_configure(void);
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* ipmpls_fwdconf_sysvar - example implementation of MPLS network
|
||||
* pre-configuration
|
||||
*
|
||||
* MPLS network pre-configuration array is used to statically configure
|
||||
* MPLS forwarding with an initial setup when IPMPLS is initialized. Each
|
||||
* system variable in this array must be named according to the rule
|
||||
* ipmpls.fwconf.<index>, where <index> is a unique line indicator. The value
|
||||
* of each system variable must be composed of the IPMPLS shell command
|
||||
* mplsctl together with the flags/paramters that normally are invoked from
|
||||
* the IPCOM shell. The commands are executed in the order they are defined.
|
||||
* It is important that the "silent" flag "-s" is included on each statement.
|
||||
*
|
||||
* To use the ipmpls_fwdconf_sysvar, defines the INCLUDE_IPMPLS_USE_EXAMPLE
|
||||
* and set the configuration macro IPMPLS_FWCONF_SYSVAR in your bsp config.h
|
||||
* (or in your VxWorks Image Project) to ipmpls_fwdconf_sysvar.
|
||||
*
|
||||
* IPMPLS_INCLUDE_CMD is defined in ipmpls_config.h. If changing that define,
|
||||
* the <ipmpls> directory must be recompiled
|
||||
*
|
||||
*/
|
||||
#if defined(IPMPLS_INCLUDE_CMD) && defined(INCLUDE_IPMPLS_USE_EXAMPLE)
|
||||
IP_STATIC IP_CONST Ipcom_sysvar ipmpls_fwdconf_sysvar[] =
|
||||
{
|
||||
{"ipmpls.fwdconf.00", "mplsctl -s -a -n 1"},
|
||||
{"ipmpls.fwdconf.01", "mplsctl -s -a -n 1 -o push,123,push,234,set,eth0,10.1.1.239"},
|
||||
{"ipmpls.fwdconf.02", "mplsctl -s -a -I mpls0"},
|
||||
{"ipmpls.fwdconf.03", "mplsctl -s -b -n 1 -I mpls0"},
|
||||
{"ipmpls.fwdconf.04", "mplsctl -s -a -i 4711 -p ipv4"},
|
||||
{"ipmpls.fwdconf.05", "mplsctl -s -a -i 4711 -o pop,setrx,mpls0,dlv"},
|
||||
|
||||
/* End of configuration - DO NOT REMOVE! */
|
||||
{IP_NULL, IP_NULL}
|
||||
};
|
||||
#endif /* IPMPLS_INCLUDE_CMD && INCLUDE_IPMPLS_USE_EXAMPLE */
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmpls_configure
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
ipmpls_configure(void)
|
||||
{
|
||||
#if defined (IPMPLS_INCLUDE_CMD) && defined (IPMPLS_USE_EXAMPLE)
|
||||
#ifdef IP_PORT_VXWORKS
|
||||
/*
|
||||
* Note: IPMPLS_INCLUDE_CMD is defined in ipmpls_config.h. If
|
||||
* changing that define, the <ipmpls> directory must be
|
||||
* recompiled
|
||||
*/
|
||||
Ipcom_sysvar *entries;
|
||||
|
||||
if ((entries = (Ipcom_sysvar *)IPMPLS_FWCONF_SYSVAR) != NULL)
|
||||
{
|
||||
/* initialize IPMPLS network preconfiguration */
|
||||
(void)ipcom_sysvar_setv(entries, IPCOM_SYSVAR_FLAG_OVERWRITE);
|
||||
}
|
||||
#else
|
||||
(void)ipcom_sysvar_setv(ipmpls_fwdconf_sysvar, IPCOM_SYSVAR_FLAG_OVERWRITE);
|
||||
#endif /* IP_PORT_VXWORKS */
|
||||
#endif /* IPMPLS_INCLUDE_CMD && IPMPLS_USE_EXAMPLE */
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK CONFIGURATION HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmpls_config.h,v $ $Revision: 1.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmpls/config/ipmpls_config.h,v $
|
||||
* $Author: jonas $ $Date: 2006-08-21 08:48:13 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Dusan Stevanovic <dule@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMPLS_CONFIG_H
|
||||
#define IPMPLS_CONFIG_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef IP_PORT_LKM
|
||||
#define IPMPLS_INCLUDE_CMD
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPMPLS_RECURSION_LIMIT
|
||||
*===========================================================================
|
||||
* MPLS label operations of type forward (FWD) and peek (PEEK) are handled by
|
||||
* IPMPLS in a recursive manner.
|
||||
* This configuration option prevents IPMPLS to perform a too deep recursion
|
||||
* which could result in a stack overflow.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#define IPMPLS_RECURSION_LIMIT 20
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,10 @@
|
||||
IPTARGETS := lib
|
||||
ifneq ($(IPMAKEFILE),)
|
||||
include $(IPMAKEFILE)
|
||||
else
|
||||
include $(IPCOM_ROOT)/Makefile
|
||||
endif
|
||||
include ipmpls.mk
|
||||
include $(IPCOM_ROOT)/gmake/ipcom_make.mk
|
||||
|
||||
lib: dirs $(IPLIBFILE)
|
||||
@@ -0,0 +1,100 @@
|
||||
#############################################################################
|
||||
# IPTCP.MK
|
||||
#
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmpls.mk,v $ $Revision: 1.8 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipmpls/gmake/ipmpls.mk,v $
|
||||
# $Author: jonas $ $Date: 2009-03-12 11:51:30 $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
|
||||
#############################################################################
|
||||
# PRODUCT
|
||||
###########################################################################
|
||||
|
||||
IPPROD ?= ipmpls
|
||||
|
||||
|
||||
#############################################################################
|
||||
# DEFINE
|
||||
###########################################################################
|
||||
|
||||
IPDEFINE += -DIPMPLS
|
||||
IPDEFINE += -DIPMPLS_MULTIPLE_ROUTE_TABLES
|
||||
|
||||
#############################################################################
|
||||
# INCLUDE
|
||||
###########################################################################
|
||||
|
||||
IPINCLUDE += -I$(IPMPLS_ROOT)/config
|
||||
IPINCLUDE += -I$(IPMPLS_ROOT)/include
|
||||
IPINCLUDE += -I$(IPMPLS_ROOT)/src
|
||||
|
||||
|
||||
#############################################################################
|
||||
# OBJECTS
|
||||
###########################################################################
|
||||
ifneq ($(IPPORT),las)
|
||||
# Configuration
|
||||
IPLIBOBJECTS_C += ipmpls_config.o
|
||||
|
||||
# Main
|
||||
|
||||
IPLIBOBJECTS += ipmpls.o
|
||||
IPLIBOBJECTS += ipmpls_ioctl.o
|
||||
|
||||
endif
|
||||
ifneq ($(IPPORT),lkm)
|
||||
IPLIBOBJECTS += ipmpls_cmd_mplsctl.o
|
||||
endif
|
||||
|
||||
# Compiles the xxx_config.o if the $SKIP_CONFIG macro is either not defined
|
||||
# or set to anything other than true.
|
||||
ifneq ($(SKIP_CONFIG),true)
|
||||
IPLIBOBJECTS += $(IPLIBOBJECTS_C)
|
||||
endif
|
||||
|
||||
|
||||
#############################################################################
|
||||
# VPATH
|
||||
###########################################################################
|
||||
|
||||
IPSRCDIRS += $(IPMPLS_ROOT)/src $(IPMPLS_ROOT)/config
|
||||
|
||||
|
||||
#############################################################################
|
||||
# LIB
|
||||
###########################################################################
|
||||
|
||||
IPLIBS += $(IPLIBROOT)/libipmpls.a
|
||||
|
||||
#############################################################################
|
||||
# BINARIES
|
||||
#############################################################################
|
||||
|
||||
ifeq ($(IPPORT),las)
|
||||
# Path to binaries
|
||||
IPCMDDIR := $(IPOBJDIR)/bin
|
||||
|
||||
# List of shell commands to build
|
||||
IPMPLSSHELLCMDS = mplsctl
|
||||
_IPMPLSSHELLCMDS = $(addprefix $(IPCMDDIR)/,$(IPMPLSSHELLCMDS))
|
||||
|
||||
bin: $(_IPMPLSSHELLCMDS)
|
||||
|
||||
|
||||
$(IPOBJDIR)/ipmpls_cmd_%.o: $(IPMPLS_ROOT)/src/ipmpls_cmd_%.c
|
||||
@$(IPECHO) "+++ Compiling IPMPLS shell command $<"
|
||||
$(IPVERB)$(IPCC) -Dipmpls_cmd_$*=ipcom_cmd_entry_point $(IPCFLAGS) -o $@ $<
|
||||
|
||||
$(IPCMDDIR)/%: $(IPOBJDIR)/ipmpls_cmd_%.o $(IPOBJDIR)/ipcom_shell_cmd_stub.o
|
||||
@$(IPECHO) "+++ Linking IPMPLS shell command $@"
|
||||
$(IPVERB)$(IPLD) -o $@ $(IPLDFLAGS) $^ $(IPLIBS) $(IPLIBS) $(IPLIBS) $(IPLASTLIBS)
|
||||
endif
|
||||
|
||||
###########################################################################
|
||||
# END OF IPMPLS.MK
|
||||
###########################################################################
|
||||
@@ -0,0 +1,319 @@
|
||||
/******************************************************************************
|
||||
* INTERPEAK API HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmpls.h,v $ $Revision: 1.26.10.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmpls/include/ipmpls.h,v $
|
||||
* $Author: hxie $ $Date: 2012-11-26 08:00:33 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Jonas Rendel <Jonas.Rendel@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMPLS_H
|
||||
#define IPMPLS_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmpls_config.h"
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_netif.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
/* IPMPLS release XYyZz,
|
||||
X = major version
|
||||
Yy = minor version (two different versions might be incompatible)
|
||||
Zz = patch version (two different versions are always compatible) */
|
||||
|
||||
#define IPMPLS_RELEASE 60900
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPMPLS ioctls
|
||||
*===========================================================================
|
||||
* IO controls handled by the IPMPLS module
|
||||
*/
|
||||
#ifndef IPMPLS_PORT_IOCTL
|
||||
#define IPMPLS_SIOCGLABELSPACEMPLS IP_IOR(MPLS, 1, R, struct Ipmpls_labelspace_req) /* Get MPLS label space for a certain interface */
|
||||
#define IPMPLS_SIOCSLABELSPACEMPLS IP_IOW(MPLS, 2, R, struct Ipmpls_labelspace_req) /* Set MPLS label space for a certain interface */
|
||||
#define IPMPLS_SIOCMPLSTUNNELADD IP_IOW(MPLS, 3, R, struct Ip_ifreq) /* Create a MPLS tunnel interface */
|
||||
#define IPMPLS_SIOCMPLSTUNNELDEL IP_IOW(MPLS, 4, R, struct Ip_ifreq) /* Delete a MPLS tunnel interface */
|
||||
|
||||
#define IPMPLS_SIOCMPLSNHLFESETMTU IP_IOW(MPLS, 5, R, struct Ipmpls_out_label_req) /* Change MTU for a certain NHLFE */
|
||||
#define IPMPLS_SIOCMPLSNHLFEADD IP_IOW(MPLS, 6, R, struct Ipmpls_out_label_req) /* Add a NHLFE entry */
|
||||
#define IPMPLS_SIOCMPLSNHLFEDEL IP_IOW(MPLS, 7, R, struct Ipmpls_out_label_req) /* Delete a NHLFE entry */
|
||||
#define IPMPLS_SIOCMPLSNHLFEGET IP_IOR(MPLS, 8, R, struct Ipmpls_out_label_req) /* Get info about a NHLFE entry */
|
||||
#define IPMPLS_SIOCMPLSILMADD IP_IOW(MPLS, 9, R, struct Ipmpls_in_label_req) /* Add an ILM entry */
|
||||
#define IPMPLS_SIOCMPLSILMDEL IP_IOW(MPLS,10, R, struct Ipmpls_in_label_req) /* Delete an ILM entry */
|
||||
#define IPMPLS_SIOCMPLSILMGET IP_IOR(MPLS,11, R, struct Ipmpls_in_label_req) /* Get info about an ILM entry */
|
||||
|
||||
#define IPMPLS_SIOCMPLSXCADD IP_IOW(MPLS,12, R, struct Ipmpls_xconnect_req) /* Add a cross-connect reference */
|
||||
#define IPMPLS_SIOCMPLSXCDEL IP_IOW(MPLS,13, R, struct Ipmpls_xconnect_req) /* Delete a cross-connect reference */
|
||||
#define IPMPLS_SIOCMPLSXCGET IP_IOR(MPLS,14, R, struct Ipmpls_xconnect_req) /* Get info about a cross-connect reference */
|
||||
#define IPMPLS_SIOCMPLSILMFLUSH IP_IOW(MPLS,15, R, void*) /* Flush the IPMPLS ILM table */
|
||||
#define IPMPLS_SIOCMPLSNHLFEFLUSH IP_IOW(MPLS,16, R, void*) /* Flush the IPMPLS NHLFE table */
|
||||
#define IPMPLS_SIOCSMPLSININSTR IP_IOW(MPLS,17, R, struct Ipmpls_instr_req) /* Set MPLS label operations on an ILM entry */
|
||||
#define IPMPLS_SIOCGMPLSININSTR IP_IOR(MPLS,18, R, struct Ipmpls_instr_req) /* Get MPLS label operations that are defined on an ILM entry */
|
||||
#define IPMPLS_SIOCSMPLSOUTINSTR IP_IOW(MPLS,19, R, struct Ipmpls_instr_req) /* Set MPLS label operations on a NHLFE entry */
|
||||
#define IPMPLS_SIOCGMPLSOUTINSTR IP_IOR(MPLS,20, R, struct Ipmpls_instr_req) /* Get MPLS label operations that are defined on an NHLFE entry */
|
||||
|
||||
#define IPMPLS_SIOCMPLSTUNNELMAP IP_IOW(MPLS,21, R, struct Ip_ifreq) /* Map a ILM to a certain tunnel interface */
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPMPLS ioctls
|
||||
*===========================================================================
|
||||
* IO controls handled by the IPMPLS tunnel interface
|
||||
*/
|
||||
#define IPMPLS_SIOCMPLSTUNNELADDOUT IP_IOW(NETIF, 200, R, struct Ip_ifreq)
|
||||
#define IPMPLS_SIOCMPLSTUNNELDELOUT IP_IOW(NETIF, 201, R, struct Ip_ifreq)
|
||||
#define IPMPLS_SIOCMPLSTUNNELGETOUT IP_IOW(NETIF, 202, R, struct Ip_ifreq)
|
||||
|
||||
#endif /* IPMPLS_PORT_IOCTL */
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPMPLS label operation codes
|
||||
*===========================================================================
|
||||
*/
|
||||
#define IPMPLS_OP_BASE 0
|
||||
#define IPMPLS_OP_NOP (IPMPLS_OP_BASE + 0) /* No operation */
|
||||
#define IPMPLS_OP_POP (IPMPLS_OP_BASE + 1) /* Pop the top label from the label stack */
|
||||
#define IPMPLS_OP_PEEK (IPMPLS_OP_BASE + 2) /* Lookup the top label of the label stack, perform actions according to the associated ILM */
|
||||
#define IPMPLS_OP_PUSH (IPMPLS_OP_BASE + 3) /* Push a new label on to the label stack */
|
||||
#define IPMPLS_OP_DLV (IPMPLS_OP_BASE + 4) /* Deliver the PDU to IPNET.*/
|
||||
#define IPMPLS_OP_FWD (IPMPLS_OP_BASE + 5) /* Apply a given NHLFE and forward the packet further */
|
||||
#define IPMPLS_OP_SET (IPMPLS_OP_BASE + 10) /* Set outgoing interface and next hop destination before transmision. */
|
||||
#define IPMPLS_OP_SET_RX (IPMPLS_OP_BASE + 11) /* Set specific receiving interface on a rx packet */
|
||||
#define IPMPLS_OP_SET_VR (IPMPLS_OP_BASE + 12) /* Set specific virtual route table index on a rx packet */
|
||||
#define IPMPLS_OP_SET_RTAB IPMPLS_OP_SET_VR
|
||||
#define IPMPLS_OP_MAX IPMPLS_OP_SET_RTAB
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPMPLS label directions
|
||||
*===========================================================================
|
||||
* Describes the direction of the label operations. Used in the
|
||||
* struct Ipmpls_instr_elem and struct Ipmpls_instr_req.
|
||||
*/
|
||||
#define IPMPLS_IN 0x10
|
||||
#define IPMPLS_OUT 0x20
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPMPLS label types
|
||||
*===========================================================================
|
||||
* MPLS label types supported by IPMPLS
|
||||
*/
|
||||
#define IPMPLS_LABEL_TYPE_GEN 1
|
||||
#define IPMPLS_LABEL_TYPE_KEY 4
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPMPLS label types
|
||||
*===========================================================================
|
||||
* MPLS label types supported by IPMPLS
|
||||
*/
|
||||
#define IPMPLS_NUM_OPS 8
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_label
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipmpls_label
|
||||
{
|
||||
int __refcnt;
|
||||
int ml_type;
|
||||
union {
|
||||
Ip_u32 ml_gen;
|
||||
Ip_u32 ml_key;
|
||||
} u;
|
||||
int ml_index;
|
||||
}
|
||||
Ipmpls_label;
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_nexthop_info
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipmpls_nexthop_info
|
||||
{
|
||||
Ip_u32 mni_if;
|
||||
union
|
||||
{
|
||||
struct Ip_sockaddr sa;
|
||||
#ifdef IPCOM_USE_INET
|
||||
struct Ip_sockaddr_in sin;
|
||||
#endif /* IPCOM_USE_INET */
|
||||
#ifdef IPCOM_USE_INET6
|
||||
struct Ip_sockaddr_in6 sin6;
|
||||
#endif /* IPCOM_USE_INET6 */
|
||||
struct Ip_sockaddr_ll sll;
|
||||
} a;
|
||||
}
|
||||
Ipmpls_nexthop_info;
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_instr_elem
|
||||
*===========================================================================
|
||||
*/
|
||||
struct Ipmpls_nhlfe;
|
||||
typedef struct Ipmpls_instr_elem
|
||||
{
|
||||
Ip_u16 mir_opcode;
|
||||
Ip_u8 mir_direction;
|
||||
union {
|
||||
Ipmpls_label push;
|
||||
Ipmpls_label fwd;
|
||||
Ipmpls_nexthop_info set;
|
||||
Ip_u32 set_rx;
|
||||
Ip_u32 set_rtab;
|
||||
} mir_data;
|
||||
}
|
||||
Ipmpls_instr_elem;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_instr_req
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipmpls_instr_req
|
||||
{
|
||||
Ip_u16 mir_family;
|
||||
Ipmpls_instr_elem mir_instr[IPMPLS_NUM_OPS];
|
||||
Ip_u8 mir_instr_length;
|
||||
Ip_u8 mir_direction;
|
||||
int mir_index;
|
||||
Ipmpls_label mir_label;
|
||||
} Ipmpls_instr_req;
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_labelspace_req
|
||||
*===========================================================================
|
||||
*/
|
||||
struct Ipmpls_labelspace_req
|
||||
{
|
||||
int mls_family;
|
||||
int mls_ifindex;
|
||||
int mls_labelspace;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_out_label_req
|
||||
*===========================================================================
|
||||
*/
|
||||
struct Ipmpls_out_label_req
|
||||
{
|
||||
Ip_u16 mol_family;
|
||||
Ip_u32 mol_age;
|
||||
Ipmpls_label mol_label;
|
||||
Ip_u32 mol_mtu;
|
||||
Ip_u8 mol_propagate_ttl;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_label_req
|
||||
*===========================================================================
|
||||
*/
|
||||
struct Ipmpls_in_label_req
|
||||
{
|
||||
Ip_u16 mil_family;
|
||||
Ip_u32 mil_age;
|
||||
Ip_u32 mil_proto;
|
||||
Ipmpls_label mil_label;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_xconnect_req
|
||||
*===========================================================================
|
||||
*/
|
||||
struct Ipmpls_xconnect_req
|
||||
{
|
||||
Ip_u16 mx_family;
|
||||
Ipmpls_label mx_in;
|
||||
Ipmpls_label mx_out;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC int ipmpls_create(void);
|
||||
IP_PUBLIC Ip_err ipmpls_start(void);
|
||||
IP_PUBLIC const char* ipmpls_version(void);
|
||||
IP_PUBLIC Ip_err ipmpls_configure(void);
|
||||
IP_PUBLIC int ipmpls_ioctl(unsigned long request, void *data);
|
||||
IP_PUBLIC int ipmpls_input(Ipcom_netif *netif, Ipcom_pkt *pkt, Ip_bool peeked);
|
||||
#ifdef IPCOM_USE_INET
|
||||
IP_PUBLIC int ipmpls_ip4_output(Ipcom_netif *netif, Ipcom_pkt *pkt);
|
||||
#endif
|
||||
#ifdef IPCOM_USE_INET6
|
||||
IP_PUBLIC int ipmpls_ip6_output(Ipcom_netif *netif, Ipcom_pkt *pkt);
|
||||
#endif
|
||||
#ifdef IP_PORT_LKM
|
||||
IP_PUBLIC int ipmpls_route_proc_info(char *buffer, char **start,
|
||||
Ip_u32 offset, int length,
|
||||
Ip_bool is_ilm);
|
||||
#endif /* IP_PORT_LKM */
|
||||
|
||||
IP_PUBLIC void ipmpls_route_table_notify(Ip_u16 vr, Ip_bool is_added);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmpls_ipstack.h,v $ $Revision: 1.15 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmpls/include/ipmpls_ipstack.h,v $
|
||||
* $Author: jonas $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Dusan Stevanovic <dule@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMPLS_IPSTACK_H
|
||||
#define IPMPLS_IPSTACK_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmpls_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock2.h>
|
||||
#include <ipcom_sock6.h>
|
||||
#include <ipcom_netif.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* PPP I/O events
|
||||
*===========================================================================
|
||||
* IO events are passed from MPLS to -> TCP/IP stack.
|
||||
*/
|
||||
#define IPMPLS_EIOXBLOCKOK 0x4001 /* IP_NULL; Ok to block? */
|
||||
#define IPMPLS_EIOXDRVIOCTL 0x4002 /* Ipmpls_eio_ioctl; Driver ioctl */
|
||||
#define IPMPLS_EIOXOUTPUT_IF 0x4003 /* Ipcom_pkt; Output packet to if. */
|
||||
#define IPMPLS_EIOXINDEXTONETIF 0x4004 /* int; Get Ipcom_netif pointer from index. */
|
||||
#define IPMPLS_EIOXCODE_LOCK 0x4005 /* -; Lock IPNET/IPLITE code. */
|
||||
#define IPMPLS_EIOXCODE_UNLOCK 0x4006 /* -; Unlock IPNET/IPLITE code. */
|
||||
#define IPMPLS_EIOXIF_LOCK 0x4007 /* -; Lock interface. */
|
||||
#define IPMPLS_EIOXIF_UNLOCK 0x4008 /* -; Unlock interface. */
|
||||
#define IPMPLS_EIOXPUBINDEXTONETIF 0x4009 /* int; Get Ipcom_netif pointer from public index. */
|
||||
#define IPMPLS_EIOXNAMETONETIF 0x400A /* char*; Get Ipcom_netif pointer from name */
|
||||
#define IPMPLS_EIOXIF_OPEN 0x400B /* -; Open interface */
|
||||
#define IPMPLS_EIOXIF_RUNNING 0x4070 /* -; Running interface */
|
||||
#define IPMPLS_EIOXIF_CLOSE 0x400C /* -; Close interface */
|
||||
#define IPMPLS_EIOXIF_STOP 0x4071 /* -; Stop interface */
|
||||
#define IPMPLS_EIOXFOREACHNETIF 0x400D /* Perform callback on each interface */
|
||||
#define IPMPLS_EIOXRTABTONETIF 0x400E /* int; Fetch the MPLS FIB interface that
|
||||
corresponds to a certain route table */
|
||||
#define IPMPLS_EIOXGET_TTL 0x400F /* Extract ttl/hlim from IP header */
|
||||
|
||||
#define IPMPLS_EIOXUP_IN 0x4011 /* Ipmpls_eio_in; IPv4 UP */
|
||||
#define IPMPLS_EIOXDOWN_IN 0x4012 /* Ipmpls_eio_in; IPv4 DOWN */
|
||||
#define IPMPLS_EIOXINPUT_IN 0x4013 /* Ipcom_pkt; IPv4 input packet */
|
||||
#define IPMPLS_EIOXDSTADDR_IN 0x4014 /* struct Ip_in_addr *; Check for IPv4 dstaddr (host endian) */
|
||||
|
||||
#define IPMPLS_EIOXUP_IN6 0x4021 /* Ipmpls_eio_in6; IPv6 UP */
|
||||
#define IPMPLS_EIOXDOWN_IN6 0x4022 /* Ipmpls_eio_in6; IPv6 DOWN */
|
||||
#define IPMPLS_EIOXINPUT_IN6 0x4023 /* Ipcom_pkt; IPv6 input packet */
|
||||
#define IPMPLS_EIOXADDETHHDR 0x4030 /* struct Ip_sockaddr_ll * */
|
||||
#define IPMPLS_EIOXGATEWAYREQ 0x4031 /* struct Ip_sockaddr_ll * */
|
||||
|
||||
#define IPMPLS_EIOXFLUSHSHORTCUTROUTES 0x4040 /* Ip_u32, Flush all pseudo routes referencing
|
||||
a certain NHLFE */
|
||||
#ifdef IPCOM_USE_INET
|
||||
#define IPMPLS_EIOXARPPROBE 0x4050 /* Probe for an ARP entry */
|
||||
#endif
|
||||
#ifdef IPCOM_USE_INET6
|
||||
#define IPMPLS_EIOXNDPROBE 0x4051 /* Probe for an ND entry */
|
||||
#endif
|
||||
#define IPMPLS_EIOXGET_USER_VR 0x4060
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
struct Ipmpls_link_struct; /* dummy */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_eio_ioctl
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipmpls_eio_ioctl_struct
|
||||
{
|
||||
int command;
|
||||
void *data;
|
||||
}
|
||||
Ipmpls_eio_ioctl;
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_eio_in
|
||||
*===========================================================================
|
||||
* IO event type used with IPMPLS_EIOXUP_IN and IPMPLS_EIOXDOWN_IN.
|
||||
*/
|
||||
#ifdef IPCOM_USE_INET
|
||||
typedef struct Ipmpls_eio_in_struct
|
||||
{
|
||||
Ip_u32 local_addr_n;
|
||||
Ip_u32 peer_addr_n;
|
||||
}
|
||||
Ipmpls_eio_in;
|
||||
#endif /* IPCOM_USE_INET */
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_eio_in6
|
||||
*===========================================================================
|
||||
* IO event type used with IPMPLS_EIOXUP_IN6 and IPMPLS_EIOXDOWN_IN6.
|
||||
*/
|
||||
#ifdef IPCOM_USE_INET6
|
||||
typedef struct Ipmpls_eio_in6_struct
|
||||
{
|
||||
struct Ip_in6_addr local_addr;
|
||||
struct Ip_in6_addr peer_addr;
|
||||
}
|
||||
Ipmpls_eio_in6;
|
||||
#endif /* IPCOM_USE_INET6 */
|
||||
|
||||
typedef void (*Ipmpls_netif_foreach_cb)(Ipcom_netif *netif, Ip_u16 vr, void *data);
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
IP_PUBLIC void ipmpls_tick(Ipcom_netif *netif);
|
||||
|
||||
IP_PUBLIC int ipmpls_ioevent(Ipcom_netif *netif, int command, void *data);
|
||||
IP_PUBLIC int ipmpls_input(Ipcom_netif *netif, Ipcom_pkt *pkt, Ip_bool peeked);
|
||||
|
||||
IP_PUBLIC int ipmpls_tunnel_ioctl(Ipcom_netif *netif, Ip_u32 cmd, void *data);
|
||||
|
||||
IP_PUBLIC Ip_bool
|
||||
ipmpls_sysvar_get_conf_string(Ipcom_netif *netif, struct Ipmpls_link_struct *link, const char *name, const char *string);
|
||||
|
||||
IP_PUBLIC int ipmpls_if_init(Ipcom_netif *netif);
|
||||
IP_PUBLIC int ipmpls_tunnel_output(Ipcom_netif *netif, Ipcom_pkt *pkt);
|
||||
IP_PUBLIC int ipmpls_shortcut_route_output(Ip_u32 key, Ipcom_pkt *pkt);
|
||||
IP_PUBLIC int ipmpls_shortcut_route_nhlfe_lookup(struct Ip_sockaddr_mpls *sa_mpls);
|
||||
|
||||
IP_PUBLIC int ipcom_mpls_ioevent(Ipcom_netif *netif, int command,
|
||||
void *data, void *more, void* cookie);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmpls_netlink.h,v $ $Revision: 1.2 $
|
||||
* $Source:
|
||||
* $Author: jonas $ $Date: 2006-06-01 11:58:53 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Kenneth Jonsson <kenneth@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef IPMPLS_NETLINK_H
|
||||
#define IPMPLS_NETLINK_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* This is the IPMPLS header file for the Linux compatible NETLINK interface
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmpls.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPMPLS_NETLINK_XXX
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
#define IPMPLS_NETLINK_ROUTE 0 /* Routing/device hook */
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPMPLS_RTN_XXX
|
||||
*===========================================================================
|
||||
* IPMPLS message sub types for NETLINK RULE messages
|
||||
*/
|
||||
#define IPMPLS_RTN_ILM 1
|
||||
#define IPMPLS_RTN_NHLFE 2
|
||||
#define IPMPLS_RTN_XC 3
|
||||
#define IPMPLS_RTN_LABELSPACE 4
|
||||
#define IPMPLS_RTN_ILMFLUSH 5
|
||||
#define IPMPLS_RTN_NHLFEFLUSH 6
|
||||
#define IPMPLS_RTN_TUNNEL 7
|
||||
|
||||
#define IPMPLS_RTN_MAX 8
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPMPLS_RTA_XXX
|
||||
*===========================================================================
|
||||
* IPMPLS route message attribute values
|
||||
*/
|
||||
#define IPMPLS_RTA_ILM 1
|
||||
#define IPMPLS_RTA_NHLFE 2
|
||||
#define IPMPLS_RTA_XC 3
|
||||
#define IPMPLS_RTA_LABELSPACE 4
|
||||
#define IPMPLS_RTA_INSTR 5
|
||||
#define IPMPLS_RTA_TUNNEL_NAME 7
|
||||
#define IPMPLS_RTA_TUNNEL_DATA 8
|
||||
#define IPMPLS_RTA_VR 9
|
||||
#define IPMPLS_RTA_COOKIE 10
|
||||
|
||||
#define IPMPLS_RTA_MAX IPMPLS_RTA_COOKIE
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmpls_nlmsghdr
|
||||
*===========================================================================
|
||||
*/
|
||||
struct Ipmpls_nlmsghdr
|
||||
{
|
||||
Ip_u32 nlmsg_len; /* Length of message including header */
|
||||
Ip_u16 nlmsg_type; /* Message content */
|
||||
Ip_u16 nlmsg_flags; /* Additional flags */
|
||||
Ip_u32 nlmsg_seq; /* Sequence number */
|
||||
Ip_pid_t nlmsg_pid; /* Sending process id */
|
||||
};
|
||||
|
||||
/* Flags values */
|
||||
#define IPMPLS_NLM_F_REQUEST 1 /* It is request message */
|
||||
#define IPMPLS_NLM_F_MULTI 2 /* Multipart message, terminated by NLMSG_DONE */
|
||||
#define IPMPLS_NLM_F_ACK 4 /* Reply with ack, with zero or error code */
|
||||
#define IPMPLS_NLM_F_ECHO 8 /* Echo this request */
|
||||
#define IPMPLS_NLM_F_ROOT 0x100 /* Specify tree root */
|
||||
|
||||
/* Modifiers to GET request */
|
||||
#define IPMPLS_NLM_F_ROOT 0x100 /* Specify tree root */
|
||||
#define IPMPLS_NLM_F_MATCH 0x200 /* Return all matching */
|
||||
#define IPMPLS_NLM_F_ATOMIC 0x400 /* Atomic GET */
|
||||
#define IPMPLS_NLM_F_DUMP (IPMPLS_NLM_F_ROOT | IPMPLS_NLM_F_MATCH)
|
||||
|
||||
/* Modifiers to NEW request */
|
||||
#define IPMPLS_NLM_F_REPLACE 0x100 /* Override existing */
|
||||
#define IPMPLS_NLM_F_EXCL 0x200 /* Do not touch, if it exists */
|
||||
#define IPMPLS_NLM_F_CREATE 0x400 /* Create, if it does not exist */
|
||||
#define IPMPLS_NLM_F_APPEND 0x800 /* Add to end of list */
|
||||
|
||||
#define IPMPLS_NLMSG_ALIGNTO 4
|
||||
#define IPMPLS_NLMSG_ALIGN(len) (((len)+IPMPLS_NLMSG_ALIGNTO-1) & ~(IPMPLS_NLMSG_ALIGNTO-1))
|
||||
#define IPMPLS_NLMSG_LENGTH(len) ((len)+IPMPLS_NLMSG_ALIGN(sizeof(struct Ipmpls_nlmsghdr)))
|
||||
#define IPMPLS_NLMSG_SPACE(len) IPMPLS_NLMSG_ALIGN(IPMPLS_NLMSG_LENGTH(len))
|
||||
#define IPMPLS_NLMSG_DATA(nlh) ((void*)(((char*)nlh) + IPMPLS_NLMSG_LENGTH(0)))
|
||||
#define IPMPLS_NLMSG_NEXT(nlh,len) ((len) -= IPMPLS_NLMSG_ALIGN((nlh)->nlmsg_len), \
|
||||
(struct Ipmpls_nlmsghdr*)(((char*)(nlh)) + IPMPLS_NLMSG_ALIGN((nlh)->nlmsg_len)))
|
||||
#define IPMPLS_NLMSG_OK(nlh,len) ((len) > 0 \
|
||||
&& (nlh)->nlmsg_len >= sizeof(struct Ipmpls_nlmsghdr) \
|
||||
&& (nlh)->nlmsg_len <= (len))
|
||||
#define IPMPLS_NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - IPMPLS_NLMSG_SPACE((len)))
|
||||
|
||||
#define IPMPLS_NLMSG_NOOP 0x1 /* Nothing */
|
||||
#define IPMPLS_NLMSG_ERROR 0x2 /* Error */
|
||||
#define IPMPLS_NLMSG_DONE 0x3 /* End of a dump */
|
||||
#define IPMPLS_NLMSG_OVERRUN 0x4 /* Data lost */
|
||||
|
||||
#define IPMPLS_RTM_NEWRULE 32
|
||||
#define IPMPLS_RTM_DELRULE 33
|
||||
#define IPMPLS_RTM_GETRULE 34
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmpls_netlink_callback
|
||||
*===========================================================================
|
||||
*/
|
||||
struct Ipmpls_netlink_callback
|
||||
{
|
||||
Ip_u8 *buf;
|
||||
struct Ipmpls_nlmsghdr *nlh;
|
||||
int (*dump)(Ip_u8 *buf, Ip_size_t len, struct Ipmpls_netlink_callback *cb);
|
||||
int (*done)(struct Ipmpls_netlink_callback *cb);
|
||||
int family;
|
||||
Ip_ptrdiff_t args[4];
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmpls_rtattr
|
||||
*===========================================================================
|
||||
*/
|
||||
struct Ipmpls_rtattr
|
||||
{
|
||||
Ip_u16 rta_len;
|
||||
Ip_u16 rta_type;
|
||||
};
|
||||
|
||||
#define IPMPLS_RTA_ALIGNTO 4
|
||||
|
||||
#define IPMPLS_RTA_ALIGN(len) (((len)+IPMPLS_RTA_ALIGNTO-1) & ~(IPMPLS_RTA_ALIGNTO-1))
|
||||
#define IPMPLS_RTA_OK(rta,len) ((len) > 0 \
|
||||
&& (rta)->rta_len >= sizeof(struct Ipmpls_rtattr) \
|
||||
&& (rta)->rta_len <= (len))
|
||||
#define IPMPLS_RTA_NEXT(rta,attrlen) \
|
||||
((attrlen) -= IPMPLS_RTA_ALIGN((rta)->rta_len), \
|
||||
(struct Ipmpls_rtattr *)(((char *)(rta)) + IPMPLS_RTA_ALIGN((rta)->rta_len)))
|
||||
|
||||
#define IPMPLS_RTA_LENGTH(len) (IPMPLS_RTA_ALIGN(sizeof(struct Ipmpls_rtattr)) + (len))
|
||||
#define IPMPLS_RTA_SPACE(len) IPMPLS_RTA_ALIGN(IPMPLS_RTA_LENGTH(len))
|
||||
#define IPMPLS_RTA_DATA(rta) ((void*)(((char*)(rta)) + IPMPLS_RTA_LENGTH(0)))
|
||||
#define IPMPLS_RTA_PAYLOAD(rta) ((int)((rta)->rta_len) - IPMPLS_RTA_LENGTH(0))
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmpls_rtmsg
|
||||
*===========================================================================
|
||||
*/
|
||||
struct Ipmpls_rtmsg
|
||||
{
|
||||
Ip_u8 rtm_family;
|
||||
Ip_u8 rtm_dst_len;
|
||||
Ip_u8 rtm_src_len;
|
||||
Ip_u8 rtm_tos;
|
||||
|
||||
Ip_u8 rtm_table;
|
||||
Ip_u8 rtm_protocol;
|
||||
Ip_u8 rtm_scope;
|
||||
Ip_u8 rtm_type;
|
||||
|
||||
Ip_u32 rtm_flags;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define IPMPLS_RTM_RTA(r) ((struct Ipmpls_rtattr *)(((char *)(r)) + IPMPLS_NLMSG_ALIGN(sizeof(struct Ipmpls_rtmsg))))
|
||||
#define IPMPLS_RTM_PAYLOAD(n) IPMPLS_NLMSG_PAYLOAD(n,sizeof(struct Ipmpls_rtmsg))
|
||||
|
||||
|
||||
IP_PUBLIC void ipcom_netlink_post(int unit, void *data, Ip_size_t len, int msg_group, Ip_u16 vr);
|
||||
|
||||
IP_PUBLIC int ipmpls_netlink_rtm_new(Ip_u8 *data, Ip_size_t len, struct Ipmpls_nlmsghdr *nlh, void *arg, int vr);
|
||||
IP_PUBLIC int ipmpls_netlink_rtm_del(Ip_u8 *data, Ip_size_t len, struct Ipmpls_nlmsghdr *nlh, void *arg, int vr);
|
||||
IP_PUBLIC int ipmpls_netlink_rtm_get(Ip_u8 *data, Ip_size_t len, struct Ipmpls_nlmsghdr *nlh,
|
||||
void *arg, void **out_msg, int s_vr);
|
||||
IP_PUBLIC int ipmpls_netlink_rtm_dump(Ip_u8 *data, Ip_size_t len, struct Ipmpls_netlink_callback *cb, int vr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* IPMPL_NETLINK_H */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,322 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK INTERNAL API HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmpls_h.h,v $ $Revision: 1.18 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmpls/src/ipmpls_h.h,v $
|
||||
* $Author: jonas $ $Date: 2010-11-01 06:25:14 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Jonas Rendel <Jonas.Rendel@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMPLS_H_H
|
||||
#define IPMPLS_H_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmpls_config.h"
|
||||
#include <ipcom_netif.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_time.h>
|
||||
#include <ipcom_route.h>
|
||||
#include <ipcom_hash.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_sock.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMPLS_LABEL_BITS 32
|
||||
#define IPMPLS_OUT_BITS 32
|
||||
#define IPMPLS_DEFAULT_MTU 1280
|
||||
#define IPMPLS_ILM 0
|
||||
#define IPMPLS_NHLFE 1
|
||||
|
||||
#define IPMPLS_ERROUT(r) do {ret = (r); goto errout;} while(0)
|
||||
|
||||
/* Known labnel types */
|
||||
#define IPMPLS_LABEL_IPV4_EXPLICIT_NULL 0 /* Pop label, deliver */
|
||||
#define IPMPLS_LABEL_ROUTER_ALERT 1 /* Process by LSR */
|
||||
#define IPMPLS_LABEL_IPV6_EXPLICIT_NULL 2 /* Pop label, deliver */
|
||||
#define IPMPLS_LABEL_IMPLICIT_NULL 3 /* Used only by LDP */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
struct Ipmpls_opcode_elem; /* forward declaration */
|
||||
struct Ipmpls_route_struct;
|
||||
|
||||
typedef struct Ipmpls_route_struct Ipmpls_nhlfe;
|
||||
typedef struct Ipmpls_route_struct Ipmpls_ilm;
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* MPLS label from RFC3032
|
||||
*===========================================================================
|
||||
*
|
||||
* 0 1 2 3
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Label
|
||||
* | Label | Exp |S| TTL | Stack
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Entry
|
||||
*
|
||||
* Label: Label Value, 20 bits
|
||||
* Exp: Experimental Use, 3 bits
|
||||
* S: Bottom of Stack, 1 bit
|
||||
* TTL: Time to Live, 8 bits
|
||||
*
|
||||
*/
|
||||
typedef Ip_u32 Ipmpls_label_hdr;
|
||||
|
||||
#define IPMPLS_LABEL_SIZE 4 /* # of bytes in MPLS label */
|
||||
#define IPMPLS_LABEL_S_BIT 0x00000100
|
||||
|
||||
#define IPMPLS_LABEL_SET_LABEL(b, v) ((b) |= (((v) & 0xfffff) << 12))
|
||||
#define IPMPLS_LABEL_SET_S(b) ((b) |= (0x1 << 8))
|
||||
#define IPMPLS_LABEL_SET_TTL(b, v) ((b) |= ((v) & 0xff))
|
||||
|
||||
#define IPMPLS_LABEL_GET_LABEL(b) (((b) >> 12) & 0xfffff)
|
||||
#define IPMPLS_LABEL_GET_S(b) (((b) >> 8) & 0x1)
|
||||
#define IPMPLS_LABEL_GET_TTL(b, v) ((b) & 0xff)
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_key_gen;
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef Ip_u32 Ipmpls_key;
|
||||
|
||||
#define IPMPLS_KEY_GET_TYPE(k) (((k) >> 29) & 0x7)
|
||||
#define IPMPLS_KEY_GET_LABELSPACE(k) (((k) >> 20) & 0x1ff)
|
||||
#define IPMPLS_KEY_GET_LABEL(k) ((k) & 0xfffff)
|
||||
|
||||
#define IPMPLS_KEY_SET_TYPE(k, v) ((k) | (((v) & 0x7) << 29))
|
||||
#define IPMPLS_KEY_SET_LABELSPACE(k, v) ((k) | (((v) & 0x1ff) << 20))
|
||||
#define IPMPLS_KEY_SET_LABEL(k, v) ((k) | (((v) & 0xfffff)))
|
||||
|
||||
#define IPMPLS_KEY_BITS 32
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_opcode_nexthop
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipmpls_opcode_nexthop_struct
|
||||
{
|
||||
Ip_u32 ifindex;
|
||||
union
|
||||
{
|
||||
struct Ip_sockaddr sa;
|
||||
#ifdef IPCOM_USE_INET
|
||||
struct Ip_sockaddr_in sin;
|
||||
#endif /* IPCOM_USE_INET */
|
||||
#ifdef IPCOM_USE_INET6
|
||||
struct Ip_sockaddr_in6 sin6;
|
||||
#endif /* IPCOM_USE_INET6 */
|
||||
struct Ip_sockaddr_ll sll;
|
||||
} a;
|
||||
} Ipmpls_opcode_nexthop;
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_opcode_fwd
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_rt_cookie
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipmpsls_rt_cookie_struct
|
||||
{
|
||||
Ip_u32 d1;
|
||||
Ip_u32 d2;
|
||||
} Ipmpls_rt_cookie;
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_opcode_elem
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipmpls_opcode_elem_struct
|
||||
{
|
||||
Ip_u16 opcode;
|
||||
Ip_u8 dir;
|
||||
union {
|
||||
Ipmpls_label push;
|
||||
Ipmpls_key fwd;
|
||||
Ipmpls_opcode_nexthop set;
|
||||
Ipmpls_nhlfe *nhlfe;
|
||||
void *ptr;
|
||||
} data;
|
||||
} Ipmpls_opcode_elem;
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_opcode_list
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipmpls_opcode_list_struct
|
||||
{
|
||||
Ipmpls_opcode_elem opcodes[IPMPLS_NUM_OPS];
|
||||
Ip_u8 num_opcodes;
|
||||
|
||||
} Ipmpls_opcode_list;
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_route
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipmpls_route_struct
|
||||
{
|
||||
Ipcom_route_entry hdr; /* The header required by the radix package */
|
||||
Ipcom_route *head; /* Head of the route table */
|
||||
int refcnt;/* Reference counter */
|
||||
Ipmpls_key key; /* Used as key in RADIX */
|
||||
Ip_time_t age; /* Time stamp */
|
||||
Ip_u32 ttl; /* used for push opcodes */
|
||||
Ip_u32 data; /* Used for MTU on NHLFEs */
|
||||
/* and protocol descriptor on ILMs */
|
||||
Ip_u16 vr; /* Used for ILMs */
|
||||
Ipmpls_opcode_list *oplist;/* List of mpls instructions */
|
||||
Ip_pid_t netlink_pid;
|
||||
Ipmpls_rt_cookie cookie;
|
||||
} Ipmpls_route;
|
||||
|
||||
|
||||
|
||||
#define IPMPLS_ILM_PROTO(i) ((i)->data)
|
||||
#define IPMPLS_NHLFE_MTU(n) ((n)->data)
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_eth_if_mpls_data
|
||||
*===========================================================================
|
||||
*/
|
||||
struct Ipmpls_eth_if_mpls_data
|
||||
{
|
||||
Ip_u32 mpls_labelspace;
|
||||
Ip_u32 mpls_route_tree_ix;
|
||||
};
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_netif
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipmpls_netif_struct
|
||||
{
|
||||
Ipmpls_nhlfe *nhlfe;
|
||||
Ipmpls_key key;
|
||||
} Ipmpls_netif;
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_data
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipmpls_data_struct
|
||||
{
|
||||
int name_index;
|
||||
Ip_u16 ipmpls_last_nhlfe_label;
|
||||
Ipcom_hash *label_tables;
|
||||
} Ipmpls_data;
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmpls_ifreq_data
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipmpls_ifreq_data_struct
|
||||
{
|
||||
int mtu;
|
||||
Ip_u16 vr;
|
||||
Ip_u32 label;
|
||||
} Ipmpls_ifreq_data;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
IP_GLOBAL Ipmpls_key* ipmpls_key_create(int labelspace, Ipmpls_label *label, Ipmpls_key *key);
|
||||
IP_GLOBAL int ipmpls_nhlfe_key_autogenerate(Ipmpls_key *key);
|
||||
|
||||
IP_GLOBAL Ipmpls_route* ipmpls_route_lookup(Ip_u16 ix, Ipmpls_key *key);
|
||||
IP_GLOBAL int ipmpls_route_add(Ip_u16 ix, Ipmpls_key *key, Ipmpls_route *route);
|
||||
IP_GLOBAL int ipmpls_route_remove(Ipmpls_route *route);
|
||||
IP_GLOBAL int ipmpls_route_flush_tree(Ip_u16 ix, Ip_u32 type);
|
||||
|
||||
IP_GLOBAL int ipmpls_labelspace_set(Ipcom_netif *netif, int labelspace);
|
||||
IP_GLOBAL int ipmpls_labelspace_get(Ipcom_netif *netif, int *labelspace);
|
||||
|
||||
IP_GLOBAL void ipmpls_oplist_remove(Ipmpls_opcode_list *list);
|
||||
IP_GLOBAL Ipmpls_opcode_list *ipmpls_oplist_create(Ip_u8 n_elem);
|
||||
IP_GLOBAL int ipmpls_opcode_setup(Ipmpls_opcode_elem *dst, Ipmpls_instr_elem *src, Ip_u8 n_elem);
|
||||
IP_GLOBAL int ipmpls_opcode_copy(Ipmpls_opcode_list *src, Ipmpls_instr_elem *dst, Ip_u8 *n_elem);
|
||||
IP_GLOBAL Ipmpls_opcode_elem *ipmpls_opcode_get_last(Ipmpls_opcode_list *list);
|
||||
|
||||
|
||||
IP_GLOBAL int ipmpls_ioctl_tunnel(unsigned long request, Ip_u16 vr, char *name, void *data);
|
||||
IP_GLOBAL int ipmpls_do_ioctl(unsigned long request, Ip_u16 vr, void *data);
|
||||
|
||||
|
||||
#ifdef IPMPLS_INCLUDE_CMD
|
||||
IP_GLOBAL int ipmpls_cmd_mplsctl(int argc, char **argv);
|
||||
#endif
|
||||
|
||||
IP_PUBLIC int ipmpls_if_init(Ipcom_netif *netif);
|
||||
IP_PUBLIC int ipmpls_if_free(Ipcom_netif *netif);
|
||||
|
||||
IP_GLOBAL int ipmpls_ilm_to_tunnel_map (Ipcom_netif *netif, Ip_u16 vr, Ip_u32 data);
|
||||
IP_GLOBAL int ipmpls_set_cookie(Ipmpls_label *l, Ip_u16 vr, void* data);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,736 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmpls_ioctl.c,v $ $Revision: 1.27.10.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmpls/src/ipmpls_ioctl.c,v $
|
||||
* $Author: hsun $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Jonas Rendel <Jonas.Rendel@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmpls_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmpls_config.h"
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
|
||||
#include <ipcom.h>
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_route.h>
|
||||
|
||||
#include "ipcom_netif.h"
|
||||
|
||||
#include "ipmpls.h"
|
||||
#include "ipmpls_h.h"
|
||||
#include "ipmpls_ipstack.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmpls_ioctl_labelspace
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters: [in] request - The reqeust id.
|
||||
* [in, out] data - The reqeust data.
|
||||
* Returns: 0 = success, <0 = error code.
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipmpls_ioctl_labelspace(unsigned long request, void *data)
|
||||
{
|
||||
struct Ipmpls_labelspace_req *lsreq = (struct Ipmpls_labelspace_req*)data;
|
||||
Ipcom_netif *netif = IP_NULL;
|
||||
int ret = -IP_ERRNO_ENODEV;
|
||||
|
||||
(void)ipcom_mpls_ioevent(IP_NULL,
|
||||
IPMPLS_EIOXINDEXTONETIF,
|
||||
&lsreq->mls_ifindex,
|
||||
&netif,
|
||||
IP_NULL);
|
||||
|
||||
if (netif)
|
||||
{
|
||||
switch(request)
|
||||
{
|
||||
case IPMPLS_SIOCSLABELSPACEMPLS:
|
||||
/* Set label space on external interface */
|
||||
ret = ipmpls_labelspace_set(netif, lsreq->mls_labelspace);
|
||||
break;
|
||||
case IPMPLS_SIOCGLABELSPACEMPLS:
|
||||
/* Get label space on external interface */
|
||||
ret = ipmpls_labelspace_get(netif, &lsreq->mls_labelspace);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmpls_ioctl_nhlfe
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters: [in] request - The reqeust id.
|
||||
* [in, out] data - The reqeust data.
|
||||
* Returns: 0 = success, <0 = error code.
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipmpls_ioctl_nhlfe(unsigned long request, Ip_u16 vr, void *data)
|
||||
{
|
||||
struct Ipmpls_out_label_req *olreq = (struct Ipmpls_out_label_req*)data;
|
||||
Ipmpls_nhlfe *nhlfe;
|
||||
Ipmpls_key key;
|
||||
int ret = -IP_ERRNO_ENOENT;
|
||||
|
||||
if (olreq->mol_label.ml_type == IPMPLS_LABEL_TYPE_KEY)
|
||||
{
|
||||
nhlfe = ipmpls_route_lookup(vr, ipmpls_key_create(0, &olreq->mol_label, &key));
|
||||
|
||||
switch(request)
|
||||
{
|
||||
case IPMPLS_SIOCMPLSNHLFEADD:
|
||||
|
||||
if (!nhlfe)
|
||||
{
|
||||
nhlfe = ipcom_calloc(1, sizeof(Ipmpls_nhlfe));
|
||||
|
||||
if (nhlfe)
|
||||
{
|
||||
IPMPLS_NHLFE_MTU(nhlfe) = olreq->mol_mtu ? olreq->mol_mtu : IPMPLS_DEFAULT_MTU;
|
||||
nhlfe->ttl = olreq->mol_propagate_ttl;
|
||||
|
||||
if (olreq->mol_label.u.ml_key == 0)
|
||||
ipmpls_nhlfe_key_autogenerate(&key);
|
||||
else
|
||||
ipmpls_key_create(0, &olreq->mol_label, &key);
|
||||
|
||||
ret = ipmpls_route_add(vr,
|
||||
&key,
|
||||
nhlfe);
|
||||
|
||||
olreq->mol_label.u.ml_key = IPMPLS_KEY_GET_LABEL(key);
|
||||
olreq->mol_label.ml_index = IPMPLS_KEY_GET_LABELSPACE(key);
|
||||
olreq->mol_label.ml_type = IPMPLS_KEY_GET_TYPE(key);
|
||||
}
|
||||
else
|
||||
ret = -IP_ERRNO_ENOMEM;
|
||||
}
|
||||
else
|
||||
ret = -IP_ERRNO_EEXIST;
|
||||
break;
|
||||
case IPMPLS_SIOCMPLSNHLFEDEL:
|
||||
|
||||
if (nhlfe)
|
||||
ret = ipmpls_route_remove(nhlfe);
|
||||
break;
|
||||
case IPMPLS_SIOCMPLSNHLFEGET:
|
||||
|
||||
if (nhlfe)
|
||||
{
|
||||
olreq->mol_family = 0;
|
||||
olreq->mol_mtu = IPMPLS_NHLFE_MTU(nhlfe);
|
||||
olreq->mol_age = (Ip_u32)nhlfe->age;
|
||||
olreq->mol_propagate_ttl = (Ip_u8)nhlfe->ttl;
|
||||
ret = 0;
|
||||
}
|
||||
break;
|
||||
case IPMPLS_SIOCMPLSNHLFESETMTU:
|
||||
|
||||
if (nhlfe)
|
||||
{
|
||||
IPMPLS_NHLFE_MTU(nhlfe) = olreq->mol_mtu;
|
||||
ret = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Wrong label type */
|
||||
ret = -IP_ERRNO_EINVAL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmpls_ioctl_ilm
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters: [in] request - The reqeust id.
|
||||
* [in, out] data - The reqeust data.
|
||||
* Returns: 0 = success, <0 = error code.
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipmpls_ioctl_ilm(unsigned long request, Ip_u16 vr, void *data)
|
||||
{
|
||||
struct Ipmpls_in_label_req *ilreq = (struct Ipmpls_in_label_req*)data;
|
||||
Ipmpls_ilm *ilm;
|
||||
Ipmpls_key key;
|
||||
int ret = -IP_ERRNO_ENOENT;
|
||||
|
||||
if (ilreq->mil_label.ml_type == IPMPLS_LABEL_TYPE_GEN)
|
||||
{
|
||||
(void)ipmpls_key_create(ilreq->mil_label.ml_index, &ilreq->mil_label, &key);
|
||||
ilm = ipmpls_route_lookup(vr, &key);
|
||||
|
||||
switch(request)
|
||||
{
|
||||
case IPMPLS_SIOCMPLSILMADD:
|
||||
|
||||
if (!ilm)
|
||||
{
|
||||
ilm = ipcom_calloc(1, sizeof(Ipmpls_ilm));
|
||||
|
||||
if (ilm)
|
||||
{
|
||||
IPMPLS_ILM_PROTO(ilm) = ilreq->mil_proto;
|
||||
ilm->vr = vr;
|
||||
|
||||
/* Add to ILM tree */
|
||||
(void)ipmpls_key_create(ilreq->mil_label.ml_index, &ilreq->mil_label, &key);
|
||||
ret = ipmpls_route_add(vr, &key, ilm);
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
ipcom_free(ilm);
|
||||
ret = -IP_ERRNO_ENOMEM;
|
||||
}
|
||||
else if (!ilm->oplist)
|
||||
{
|
||||
(void)ipmpls_route_remove(ilm);
|
||||
ipcom_free(ilm);
|
||||
ret = -IP_ERRNO_ENOMEM;
|
||||
}
|
||||
}
|
||||
else
|
||||
ret = -IP_ERRNO_ENOMEM;
|
||||
}
|
||||
else
|
||||
ret = -IP_ERRNO_EEXIST;
|
||||
break;
|
||||
case IPMPLS_SIOCMPLSILMDEL:
|
||||
|
||||
if (ilm)
|
||||
ret = ipmpls_route_remove(ilm);
|
||||
break;
|
||||
case IPMPLS_SIOCMPLSILMGET:
|
||||
|
||||
if (ilm)
|
||||
{
|
||||
ilreq->mil_family = 0;
|
||||
ilreq->mil_proto = IPMPLS_ILM_PROTO(ilm);
|
||||
ilreq->mil_age = (Ip_u32)ilm->age;
|
||||
ret = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Wrong label type */
|
||||
ret = -IP_ERRNO_EINVAL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmpls_ioctl_xconnect
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters: [in] request - The reqeust id.
|
||||
* [in, out] data - The reqeust data.
|
||||
* Returns: 0 = success, <0 = error code.
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipmpls_ioctl_xconnect(unsigned long request, Ip_u16 vr, void *data)
|
||||
{
|
||||
struct Ipmpls_xconnect_req *xcreq = (struct Ipmpls_xconnect_req*)data;
|
||||
Ipmpls_key key;
|
||||
Ipmpls_ilm *ilm;
|
||||
Ipmpls_nhlfe *nhlfe;
|
||||
Ipmpls_opcode_elem *op;
|
||||
int ret = -IP_ERRNO_ENOENT;
|
||||
|
||||
/* Lookup ILM entry */
|
||||
(void)ipmpls_key_create(xcreq->mx_in.ml_index, &xcreq->mx_in, &key);
|
||||
ilm = ipmpls_route_lookup(vr, &key);
|
||||
|
||||
/* Lookup NHLFE entry */
|
||||
(void)ipmpls_key_create(0, &xcreq->mx_out, &key);
|
||||
nhlfe = ipmpls_route_lookup(vr, &key);
|
||||
|
||||
switch (request)
|
||||
{
|
||||
case IPMPLS_SIOCMPLSXCADD:
|
||||
|
||||
if (ilm && nhlfe && ilm->oplist)
|
||||
{
|
||||
op = ipmpls_opcode_get_last(ilm->oplist);
|
||||
|
||||
if (op)
|
||||
{
|
||||
op->opcode = IPMPLS_OP_FWD;
|
||||
op->data.nhlfe = nhlfe;
|
||||
|
||||
nhlfe->refcnt++;
|
||||
ret = 0;
|
||||
}
|
||||
else
|
||||
ret = -IP_ERRNO_ENOMEM;
|
||||
}
|
||||
break;
|
||||
|
||||
case IPMPLS_SIOCMPLSXCDEL:
|
||||
|
||||
if (ilm && ilm->oplist)
|
||||
{
|
||||
op = ipmpls_opcode_get_last(ilm->oplist);
|
||||
|
||||
if (op)
|
||||
{
|
||||
op->opcode = IPMPLS_OP_PEEK;
|
||||
op->data.nhlfe = IP_NULL;
|
||||
|
||||
if (nhlfe)
|
||||
nhlfe->refcnt--;
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case IPMPLS_SIOCMPLSXCGET:
|
||||
{
|
||||
/* To be done */
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmpls_ioctl_ilm_op
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters: [in] request - The reqeust id.
|
||||
* [in, out] data - The reqeust data.
|
||||
* Returns: 0 = success, <0 = error code.
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipmpls_ioctl_ilm_op(unsigned long request, Ip_u16 vr, void *data)
|
||||
{
|
||||
struct Ipmpls_instr_req *opreq = (struct Ipmpls_instr_req*)data;
|
||||
Ipmpls_ilm *ilm;
|
||||
Ipmpls_key key;
|
||||
int ret = -IP_ERRNO_ENOENT;
|
||||
|
||||
(void)ipmpls_key_create(opreq->mir_label.ml_index, &opreq->mir_label, &key);
|
||||
ilm = ipmpls_route_lookup(vr, &key);
|
||||
|
||||
if (ilm)
|
||||
{
|
||||
switch (request)
|
||||
{
|
||||
case IPMPLS_SIOCSMPLSININSTR:
|
||||
|
||||
if (ilm->oplist)
|
||||
ipmpls_oplist_remove(ilm->oplist);
|
||||
|
||||
ilm->oplist = ipmpls_oplist_create(opreq->mir_instr_length);
|
||||
|
||||
if (ilm->oplist)
|
||||
{
|
||||
ret = ipmpls_opcode_setup(ilm->oplist->opcodes,
|
||||
opreq->mir_instr,
|
||||
opreq->mir_instr_length);
|
||||
}
|
||||
else
|
||||
ret = -IP_ERRNO_ENOMEM;
|
||||
|
||||
break;
|
||||
|
||||
case IPMPLS_SIOCGMPLSININSTR:
|
||||
|
||||
opreq->mir_family = (Ip_u16)IPMPLS_ILM_PROTO(ilm);
|
||||
|
||||
if (ilm->oplist)
|
||||
ret = ipmpls_opcode_copy(ilm->oplist,
|
||||
opreq->mir_instr,
|
||||
&opreq->mir_instr_length);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmpls_ioctl_nhlfe_op
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters: [in] request - The reqeust id.
|
||||
* [in, out] data - The reqeust data.
|
||||
* Returns: 0 = success, <0 = error code.
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipmpls_ioctl_nhlfe_op(unsigned long request, Ip_u16 vr, void *data)
|
||||
{
|
||||
Ip_bool op_valid = IP_TRUE;
|
||||
Ip_u8 i, j;
|
||||
Ipmpls_key key;
|
||||
Ipmpls_nhlfe *nhlfe;
|
||||
int ret = -IP_ERRNO_ENOENT;
|
||||
struct Ipmpls_instr_req *opreq = (struct Ipmpls_instr_req*)data;
|
||||
Ip_u16 valid_ops[] = {IPMPLS_OP_PUSH,
|
||||
IPMPLS_OP_POP,
|
||||
IPMPLS_OP_SET_RTAB,
|
||||
IPMPLS_OP_FWD,
|
||||
IPMPLS_OP_SET};
|
||||
|
||||
|
||||
(void)ipmpls_key_create(0, &opreq->mir_label, &key);
|
||||
nhlfe = ipmpls_route_lookup(vr, &key);
|
||||
|
||||
if (nhlfe)
|
||||
{
|
||||
Ipmpls_opcode_list *tmp = nhlfe->oplist;
|
||||
|
||||
switch (request)
|
||||
{
|
||||
case IPMPLS_SIOCSMPLSOUTINSTR:
|
||||
|
||||
/* Verify that all opcodes are valid for as out instructions*/
|
||||
for(i = 0; i < opreq->mir_instr_length && op_valid; i++)
|
||||
{
|
||||
op_valid = IP_FALSE;
|
||||
for(j = 0; j < (sizeof(valid_ops)/2); j++)
|
||||
{
|
||||
if (opreq->mir_instr[i].mir_opcode == valid_ops[j])
|
||||
{
|
||||
op_valid = IP_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (op_valid)
|
||||
{
|
||||
nhlfe->oplist = ipmpls_oplist_create(opreq->mir_instr_length);
|
||||
|
||||
if (nhlfe->oplist)
|
||||
{
|
||||
ret = ipmpls_opcode_setup(nhlfe->oplist->opcodes,
|
||||
opreq->mir_instr,
|
||||
opreq->mir_instr_length);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Could not allocate new list */
|
||||
ret = -IP_ERRNO_ENOMEM;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Bad option list */
|
||||
ret = -IP_ERRNO_EINVAL;
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
nhlfe->oplist = tmp;
|
||||
else if (tmp)
|
||||
ipmpls_oplist_remove(tmp);
|
||||
|
||||
break;
|
||||
case IPMPLS_SIOCGMPLSOUTINSTR:
|
||||
|
||||
if (nhlfe->oplist)
|
||||
ret = ipmpls_opcode_copy(nhlfe->oplist,
|
||||
opreq->mir_instr,
|
||||
&opreq->mir_instr_length);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmpls_ioctl_tunnel
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters: [in] request - The reqeust id.
|
||||
* [in, out] data - The reqeust data.
|
||||
* Returns: 0 = success, <0 = error code.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
ipmpls_ioctl_tunnel(unsigned long request, Ip_u16 vr, char *name, void *data)
|
||||
{
|
||||
int ret = 0;
|
||||
Ipcom_netif *netif = IP_NULL;
|
||||
Ipmpls_ifreq_data *idata = (Ipmpls_ifreq_data*)data;;
|
||||
|
||||
(void)ipcom_mpls_ioevent(IP_NULL,
|
||||
IPMPLS_EIOXNAMETONETIF,
|
||||
name,
|
||||
&netif,
|
||||
&vr);
|
||||
switch (request)
|
||||
{
|
||||
case IPMPLS_SIOCMPLSTUNNELADD:
|
||||
if (netif)
|
||||
IPMPLS_ERROUT(-IP_ERRNO_EEXIST);
|
||||
|
||||
netif = ipcom_if_malloc(IP_IFT_MPLS_TUNNEL);
|
||||
|
||||
if (!netif)
|
||||
IPMPLS_ERROUT(-IP_ERRNO_ENOMEM);
|
||||
|
||||
if (ipcom_strlen(name) >= IP_IFNAMSIZ)
|
||||
{
|
||||
ipcom_if_free(netif);
|
||||
IPMPLS_ERROUT(-IP_ERRNO_EINVAL);
|
||||
}
|
||||
ipcom_strcpy(netif->name,name);
|
||||
|
||||
if (idata)
|
||||
{
|
||||
if (idata->mtu)
|
||||
netif->mtu = idata->mtu;
|
||||
|
||||
if (idata->label != 0)
|
||||
(void)ipmpls_ilm_to_tunnel_map(netif, vr, idata->label);
|
||||
}
|
||||
|
||||
ret = ipcom_if_attach(netif);
|
||||
break;
|
||||
|
||||
case IPMPLS_SIOCMPLSTUNNELDEL:
|
||||
if (!netif)
|
||||
IPMPLS_ERROUT(-IP_ERRNO_ENODEV);
|
||||
|
||||
if ((ret = ipcom_if_detach(netif)) != 0)
|
||||
IPMPLS_ERROUT(ret);
|
||||
|
||||
if ((ret = ipmpls_if_free(netif)) != 0)
|
||||
IPMPLS_ERROUT(ret);
|
||||
|
||||
if ((ret = ipcom_if_free(netif)) != 0)
|
||||
IPMPLS_ERROUT(ret);
|
||||
break;
|
||||
|
||||
case IPMPLS_SIOCMPLSTUNNELMAP:
|
||||
if (!netif)
|
||||
IPMPLS_ERROUT(-IP_ERRNO_ENODEV);
|
||||
|
||||
if (idata)
|
||||
{
|
||||
if (idata->mtu)
|
||||
netif->mtu = idata->mtu;
|
||||
|
||||
if (idata->label != 0)
|
||||
(void)ipmpls_ilm_to_tunnel_map(netif, vr, idata->label);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
errout:
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmpls_do_ioctl
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters: [in] request - The reqeust id.
|
||||
* [in, out] data - The reqeust data.
|
||||
* Returns: 0 = success, <0 = error code.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
ipmpls_do_ioctl(unsigned long request, Ip_u16 vr, void *data)
|
||||
{
|
||||
int ret = -IP_ERRNO_EINVAL;
|
||||
|
||||
switch (request)
|
||||
{
|
||||
case IPMPLS_SIOCGLABELSPACEMPLS:
|
||||
case IPMPLS_SIOCSLABELSPACEMPLS:
|
||||
if (data)
|
||||
ret = ipmpls_ioctl_labelspace(request, data);
|
||||
break;
|
||||
case IPMPLS_SIOCMPLSTUNNELADD:
|
||||
case IPMPLS_SIOCMPLSTUNNELDEL:
|
||||
case IPMPLS_SIOCMPLSTUNNELMAP:
|
||||
if (data)
|
||||
{
|
||||
struct Ip_ifreq *ifreq = (struct Ip_ifreq*)data;
|
||||
Ipmpls_ifreq_data idata;
|
||||
|
||||
ipcom_memcpy(&idata, ifreq->ip_ifr_data, sizeof(idata));
|
||||
|
||||
ret = ipmpls_ioctl_tunnel(request, vr, ifreq->ifr_name, &idata);
|
||||
}
|
||||
break;
|
||||
case IPMPLS_SIOCMPLSNHLFESETMTU:
|
||||
case IPMPLS_SIOCMPLSNHLFEADD:
|
||||
case IPMPLS_SIOCMPLSNHLFEDEL:
|
||||
case IPMPLS_SIOCMPLSNHLFEGET:
|
||||
if (data)
|
||||
ret = ipmpls_ioctl_nhlfe(request, vr, data);
|
||||
break;
|
||||
case IPMPLS_SIOCMPLSILMADD:
|
||||
case IPMPLS_SIOCMPLSILMDEL:
|
||||
case IPMPLS_SIOCMPLSILMGET:
|
||||
if (data)
|
||||
ret = ipmpls_ioctl_ilm(request, vr, data);
|
||||
break;
|
||||
case IPMPLS_SIOCMPLSXCADD:
|
||||
case IPMPLS_SIOCMPLSXCDEL:
|
||||
case IPMPLS_SIOCMPLSXCGET:
|
||||
if (data)
|
||||
ret = ipmpls_ioctl_xconnect(request, vr ,data);
|
||||
break;
|
||||
case IPMPLS_SIOCMPLSILMFLUSH:
|
||||
ret = ipmpls_route_flush_tree(vr, IPMPLS_LABEL_TYPE_GEN);
|
||||
break;
|
||||
case IPMPLS_SIOCMPLSNHLFEFLUSH:
|
||||
ret = ipmpls_route_flush_tree(vr, IPMPLS_LABEL_TYPE_KEY);
|
||||
break;
|
||||
case IPMPLS_SIOCSMPLSININSTR:
|
||||
case IPMPLS_SIOCGMPLSININSTR:
|
||||
if (data)
|
||||
ret = ipmpls_ioctl_ilm_op(request, vr, data);
|
||||
break;
|
||||
case IPMPLS_SIOCSMPLSOUTINSTR:
|
||||
case IPMPLS_SIOCGMPLSOUTINSTR:
|
||||
if (data)
|
||||
ret = ipmpls_ioctl_nhlfe_op(request, vr, data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
ipcom_errno_set(-ret);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmpls_ioctl
|
||||
*===========================================================================
|
||||
* Description: IO control for IPMPLS
|
||||
* Parameters: [in] request - The reqeust id.
|
||||
* [in, out] data - The reqeust data.
|
||||
* Returns: 0 = success, <0 = error code.
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipmpls_ioctl(unsigned long request, void *data)
|
||||
{
|
||||
Ip_u16 vr = 0;
|
||||
|
||||
(void)ipcom_mpls_ioevent(IP_NULL,IPMPLS_EIOXGET_USER_VR, &vr,IP_NULL,IP_NULL);
|
||||
|
||||
return ipmpls_do_ioctl(request, vr, data);
|
||||
}
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,902 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmpls_netlink.c,v $ $Revision: 1.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmpls/src/ipmpls_netlink.c,v $
|
||||
* $Author: jonas $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Jonas Rendel <Jonas.Rendel@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if defined(IPMPLS) && defined(IP_PORT_LKM)
|
||||
#include "ipmpls_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <ipcom.h>
|
||||
#include <ipcom_os.h>
|
||||
|
||||
#ifdef IP_PORT_LKM
|
||||
#include <ipcom_lkm.h>
|
||||
#endif
|
||||
|
||||
#include "ipmpls.h"
|
||||
#include "ipmpls_h.h"
|
||||
#include "ipmpls_ipstack.h"
|
||||
#include "ipmpls_netlink.h"
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPMPLS_NETLINK_DUMP_FIRST_ENTRY 0
|
||||
#define IPMPLS_NETLINK_DUMP_FINISHED 1
|
||||
#define IPMPLS_NETLINK_DUMP_DONT_FIT 2
|
||||
#define IPMPLS_NETLINK_DUMP_TRAILER 3
|
||||
|
||||
#define IPMPLS_NETLINK_DEF_BUF_SZ 1024
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
typedef struct Ipmpls_netlink_foreach_cb_data_struct
|
||||
{
|
||||
Ip_u8 status; /* Message status */
|
||||
Ip_u32 seq; /* Message sequence number */
|
||||
Ip_pid_t pid; /* Message receiver pid */
|
||||
int vr; /* Caller specified vr */
|
||||
int type ; /* Requested object type (ilm/nhlfe) */
|
||||
Ip_ptrdiff_t args[4]; /* Various callback data */
|
||||
Ip_size_t offset; /* Message buffer offset */
|
||||
Ip_size_t len; /* Message buffer length */
|
||||
Ip_u8 *data; /* Message buffer */
|
||||
}
|
||||
Ipmpls_netlink_foreach_cb_data;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_EXTERN Ipmpls_data *ipmpls;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmpls_netlink_rta_put
|
||||
*===========================================================================
|
||||
* Description: Add a NETLINK route attribute to a NETLINK message.
|
||||
* Parameters: buf - Message buffer
|
||||
* attrtype - Attribute type
|
||||
* attrlen - Lenght of attribute
|
||||
* data - Attribute data
|
||||
*
|
||||
* Returns: Length of attribute incuding header.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
ipmpls_netlink_rta_put(void *buf, int attrtype, int attrlen, IP_CONST void *data)
|
||||
{
|
||||
struct Ipmpls_rtattr *rta = (struct Ipmpls_rtattr *)buf;
|
||||
|
||||
rta->rta_type = (Ip_u16) attrtype;
|
||||
rta->rta_len = (Ip_u16) IPMPLS_RTA_LENGTH (attrlen);
|
||||
|
||||
if (data)
|
||||
ipcom_memcpy(IPMPLS_RTA_DATA(rta), data, attrlen);
|
||||
|
||||
return (rta->rta_len);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmpls_netlink_fill
|
||||
*===========================================================================
|
||||
* Description: Fill a NETLINK message with info about a MPLS object.
|
||||
* Parameters: data - Message buffer
|
||||
* obj - Pointer to MPLS object
|
||||
* op - Pointer to MPLS operations object
|
||||
* pid - NETLINK caller pid.
|
||||
* seq - NETLINK caller sequence number.
|
||||
* msg_type - Message type.
|
||||
* len - Available buffer length.
|
||||
*
|
||||
* Returns: > 0 Success (number of bytes consumed)
|
||||
* < 0 Failure
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipmpls_netlink_fill(Ip_u8 *data, void *obj, void *op, void *cookie, Ip_pid_t pid,
|
||||
int seq, Ip_u8 msg_type, Ip_u16 vr, Ip_size_t *len)
|
||||
{
|
||||
Ip_size_t objlen;
|
||||
Ip_size_t oplen;
|
||||
Ip_size_t size;
|
||||
Ip_u32 vr32 = (Ip_u32)vr;
|
||||
int objattr = 0;
|
||||
int opattr = 0;
|
||||
struct Ipmpls_nlmsghdr *nlh;
|
||||
struct Ipmpls_rtmsg *rtm;
|
||||
|
||||
switch (msg_type)
|
||||
{
|
||||
case IPMPLS_RTN_ILM:
|
||||
objlen = sizeof(struct Ipmpls_instr_req);
|
||||
objattr = IPMPLS_RTA_ILM;
|
||||
opattr = IPMPLS_RTA_INSTR;
|
||||
oplen = sizeof(struct Ipmpls_instr_req);
|
||||
break;
|
||||
case IPMPLS_RTN_NHLFE:
|
||||
objlen = sizeof(struct Ipmpls_out_label_req);
|
||||
objattr = IPMPLS_RTA_NHLFE;
|
||||
opattr = IPMPLS_RTA_INSTR;
|
||||
oplen = sizeof(struct Ipmpls_instr_req);
|
||||
break;
|
||||
case IPMPLS_RTN_XC:
|
||||
objlen = sizeof(struct Ipmpls_xconnect_req);
|
||||
objattr = IPMPLS_RTA_XC;
|
||||
opattr = 0;
|
||||
oplen = 0;
|
||||
case IPMPLS_RTN_TUNNEL:
|
||||
objlen = ipcom_strlen(obj) + 1;
|
||||
objattr = IPMPLS_RTA_TUNNEL_NAME;
|
||||
opattr = IPMPLS_RTA_NHLFE;
|
||||
oplen = sizeof(struct Ipmpls_out_label_req);
|
||||
break;
|
||||
case IPMPLS_RTN_LABELSPACE:
|
||||
objlen = sizeof(struct Ipmpls_labelspace_req);
|
||||
objattr = IPMPLS_RTA_LABELSPACE;
|
||||
opattr = 0;
|
||||
oplen = 0;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
size = sizeof(*nlh) + sizeof(*rtm) + IPMPLS_RTA_LENGTH(objlen) + IPMPLS_RTA_LENGTH(oplen);
|
||||
|
||||
/* Check if entry fits */
|
||||
if (*len < size)
|
||||
return -1;
|
||||
|
||||
/* Add netlink header */
|
||||
nlh = (struct Ipmpls_nlmsghdr *)data;
|
||||
nlh->nlmsg_type = IPMPLS_RTM_NEWRULE;
|
||||
nlh->nlmsg_len = IPMPLS_NLMSG_LENGTH(sizeof (*rtm));
|
||||
nlh->nlmsg_flags = 0;
|
||||
nlh->nlmsg_pid = pid;
|
||||
nlh->nlmsg_seq = seq;
|
||||
|
||||
/* Add route message header */
|
||||
rtm = IPMPLS_NLMSG_DATA(nlh);
|
||||
ipcom_memset(rtm, 0, sizeof(*rtm));
|
||||
|
||||
rtm->rtm_family = IP_AF_MPLS;
|
||||
rtm->rtm_type = msg_type;
|
||||
|
||||
/* Add VR as attribute */
|
||||
nlh->nlmsg_len += ipmpls_netlink_rta_put(&data[nlh->nlmsg_len],
|
||||
IPMPLS_RTA_VR,
|
||||
sizeof(Ip_u32),
|
||||
&vr32);
|
||||
|
||||
/* Add object as attribute */
|
||||
(void)ipmpls_netlink_rta_put(&data[nlh->nlmsg_len],
|
||||
objattr,
|
||||
objlen,
|
||||
obj);
|
||||
|
||||
nlh->nlmsg_len += IPMPLS_RTA_SPACE(objlen);
|
||||
|
||||
if (op)
|
||||
{
|
||||
/* Add object operations as attribute */
|
||||
(void)ipmpls_netlink_rta_put(&data[nlh->nlmsg_len],
|
||||
opattr,
|
||||
oplen,
|
||||
op);
|
||||
|
||||
nlh->nlmsg_len += IPMPLS_RTA_SPACE(oplen);
|
||||
}
|
||||
|
||||
if (cookie)
|
||||
{
|
||||
/* Add MPLS route cookie as attribute */
|
||||
(void)ipmpls_netlink_rta_put(&data[nlh->nlmsg_len],
|
||||
IPMPLS_RTA_COOKIE,
|
||||
sizeof(Ipmpls_rt_cookie),
|
||||
cookie);
|
||||
|
||||
nlh->nlmsg_len += IPMPLS_RTA_SPACE(sizeof(Ipmpls_rt_cookie));
|
||||
|
||||
}
|
||||
|
||||
*len -= nlh->nlmsg_len;
|
||||
return nlh->nlmsg_len;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmpls_netlink_route_foreach_vr
|
||||
*===========================================================================
|
||||
* Description: Hash table foreach callback. Called once for each virtual
|
||||
* router that exists in the system.
|
||||
* Parameters: rtab - route table
|
||||
* param - callback parameters.
|
||||
* Returns: -
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmpls_netlink_route_foreach_vr(Ipmpls_route *rtab, Ipmpls_netlink_foreach_cb_data *param)
|
||||
{
|
||||
int new_offs;
|
||||
Ip_u16 vr = rtab->vr;
|
||||
Ipmpls_route *rt = (Ipmpls_route*)param->args[2];
|
||||
int type = param->type == IPMPLS_RTN_ILM ? IPMPLS_LABEL_TYPE_GEN : IPMPLS_LABEL_TYPE_KEY;
|
||||
|
||||
/* Check if specific VR shall be dumped */
|
||||
if ((param->vr != IPCOM_VR_ANY) && (param->vr != vr))
|
||||
return;
|
||||
|
||||
/* Skip if message is already full */
|
||||
if (param->status == IPMPLS_NETLINK_DUMP_DONT_FIT)
|
||||
return;
|
||||
|
||||
/*
|
||||
* If this is a trailer message buffer, make sure it
|
||||
* starts dumping where the last message ended
|
||||
*/
|
||||
if ((param->status == IPMPLS_NETLINK_DUMP_TRAILER) && (vr != (Ip_u16)param->args[0]))
|
||||
return;
|
||||
|
||||
/* Verify that route entry is still valid */
|
||||
if (rt)
|
||||
rt = rt->netlink_pid == ipcom_getpid() ? rt : IP_NULL;
|
||||
|
||||
if (rt == IP_NULL)
|
||||
rt = (Ipmpls_route*)ipcom_route_first_entry(rtab->head);
|
||||
|
||||
while (rt)
|
||||
{
|
||||
|
||||
if (IPMPLS_KEY_GET_TYPE(rt->key) == type)
|
||||
{
|
||||
union {
|
||||
struct Ipmpls_in_label_req il;
|
||||
struct Ipmpls_out_label_req ol;
|
||||
Ipmpls_rt_cookie cookie;
|
||||
} u;
|
||||
struct Ipmpls_instr_req op;
|
||||
int ret;
|
||||
unsigned long req;
|
||||
unsigned long opreq;
|
||||
|
||||
ipcom_memset(&op,0,sizeof(op));
|
||||
ipcom_memset(&u, 0,sizeof(u));
|
||||
|
||||
switch(IPMPLS_KEY_GET_TYPE(rt->key))
|
||||
{
|
||||
case IPMPLS_LABEL_TYPE_GEN:
|
||||
req = IPMPLS_SIOCMPLSILMGET;
|
||||
opreq = IPMPLS_SIOCGMPLSININSTR;
|
||||
u.il.mil_label.ml_type = IPMPLS_KEY_GET_TYPE(rt->key);
|
||||
u.il.mil_label.u.ml_gen = IPMPLS_KEY_GET_LABEL(rt->key);
|
||||
break;
|
||||
case IPMPLS_LABEL_TYPE_KEY:
|
||||
req = IPMPLS_SIOCMPLSNHLFEGET;
|
||||
opreq = IPMPLS_SIOCGMPLSOUTINSTR;
|
||||
u.ol.mol_label.ml_type = IPMPLS_KEY_GET_TYPE(rt->key);
|
||||
u.ol.mol_label.u.ml_key = IPMPLS_KEY_GET_LABEL(rt->key);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
/* Fetch info about the object */
|
||||
(void)ipmpls_do_ioctl(req, vr, &u);
|
||||
|
||||
/* Fetch info about the object operations */
|
||||
op.mir_label.ml_type = IPMPLS_KEY_GET_TYPE(rt->key);
|
||||
op.mir_label.u.ml_key = IPMPLS_KEY_GET_LABEL(rt->key);
|
||||
|
||||
ret = ipmpls_do_ioctl(opreq, vr, &op);
|
||||
|
||||
ipcom_memset(&u.cookie,0, sizeof(u.cookie));
|
||||
|
||||
new_offs = ipmpls_netlink_fill(¶m->data[param->offset],
|
||||
&u,
|
||||
ret == 0 ? &op : IP_NULL,
|
||||
ipcom_memcmp(&rt->cookie,&u.cookie,sizeof(rt->cookie)) == 0 ? IP_NULL : &rt->cookie,
|
||||
param->pid,
|
||||
param->seq,
|
||||
param->type,
|
||||
vr,
|
||||
¶m->len);
|
||||
|
||||
if (new_offs < 0)
|
||||
goto dont_fit;
|
||||
|
||||
param->offset += (Ip_size_t)new_offs;
|
||||
}
|
||||
|
||||
rt = (Ipmpls_route*)ipcom_route_next_entry(&rt->hdr);
|
||||
}
|
||||
|
||||
param->status = IPMPLS_NETLINK_DUMP_FINISHED;
|
||||
return;
|
||||
|
||||
dont_fit:
|
||||
/* Set status to full */
|
||||
param->status = IPMPLS_NETLINK_DUMP_DONT_FIT;
|
||||
param->args[0] = (Ip_ptrdiff_t)vr;
|
||||
param->args[1] = (Ip_ptrdiff_t)rt;
|
||||
|
||||
if (rt)
|
||||
rt->netlink_pid = ipcom_getpid();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmpls_netlink_neitf_foreach
|
||||
*===========================================================================
|
||||
* Description: Netif table foreach callback. Called once for each interface
|
||||
* that exists in the system.
|
||||
* Parameters: netif - interface descriptor
|
||||
* param - callback parameters.
|
||||
* Returns: -
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmpls_netlink_netif_foreach(Ipcom_netif *s_netif, Ip_u16 vr, Ipmpls_netlink_foreach_cb_data *param)
|
||||
{
|
||||
int new_offs;
|
||||
Ipcom_netif *netif = (Ipcom_netif*)param->args[1];
|
||||
void *obj;
|
||||
void *extra;
|
||||
int ret;
|
||||
unsigned long req;
|
||||
union {
|
||||
struct Ipmpls_out_label_req ol;
|
||||
struct Ipmpls_labelspace_req ls;
|
||||
} u;
|
||||
|
||||
/* Check if specific VR shall be dumped */
|
||||
if ((param->vr != IPCOM_VR_ANY) && (param->vr != vr))
|
||||
return;
|
||||
|
||||
/* Skip if message is already full */
|
||||
if (param->status == IPMPLS_NETLINK_DUMP_DONT_FIT)
|
||||
return;
|
||||
|
||||
/*
|
||||
* If this is a trailer message buffer, make sure it
|
||||
* starts dumping where the last message ended
|
||||
*/
|
||||
if ((param->status == IPMPLS_NETLINK_DUMP_TRAILER) && (vr != (Ip_u16)param->args[0]))
|
||||
return;
|
||||
|
||||
if (netif == IP_NULL)
|
||||
netif = s_netif;
|
||||
|
||||
ipcom_memset(&u, 0,sizeof(u));
|
||||
|
||||
switch (param->type)
|
||||
{
|
||||
case IPMPLS_RTN_TUNNEL:
|
||||
{
|
||||
Ipmpls_netif *mplsif = (Ipmpls_netif*)netif->plink;
|
||||
|
||||
if ((netif->type != IP_IFT_MPLS_TUNNEL) || (mplsif == IP_NULL))
|
||||
return;
|
||||
|
||||
req = IPMPLS_SIOCMPLSNHLFEGET;
|
||||
u.ol.mol_label.ml_type = IPMPLS_KEY_GET_TYPE(mplsif->key);
|
||||
u.ol.mol_label.u.ml_key = IPMPLS_KEY_GET_LABEL(mplsif->key);
|
||||
obj = netif->name;
|
||||
extra = &u;
|
||||
}
|
||||
break;
|
||||
case IPMPLS_RTN_LABELSPACE:
|
||||
|
||||
if ((netif->type != IP_IFT_ETHER) && (netif->type != IP_IFT_L2VLAN))
|
||||
return;
|
||||
|
||||
req = IPMPLS_SIOCGLABELSPACEMPLS;
|
||||
u.ls.mls_ifindex = netif->ifindex;
|
||||
obj = &u;
|
||||
extra = IP_NULL;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
/* Fetch info about the object */
|
||||
ret = ipmpls_do_ioctl(req, vr, &u);
|
||||
|
||||
new_offs = ipmpls_netlink_fill(¶m->data[param->offset],
|
||||
obj,
|
||||
ret == 0 ? extra : IP_NULL,
|
||||
IP_NULL,
|
||||
param->pid,
|
||||
param->seq,
|
||||
param->type,
|
||||
vr,
|
||||
¶m->len);
|
||||
|
||||
if (new_offs < 0)
|
||||
goto dont_fit;
|
||||
|
||||
param->offset += (Ip_size_t)new_offs;
|
||||
|
||||
|
||||
param->status = IPMPLS_NETLINK_DUMP_FINISHED;
|
||||
return;
|
||||
|
||||
dont_fit:
|
||||
/* Set status to full */
|
||||
param->status = IPMPLS_NETLINK_DUMP_DONT_FIT;
|
||||
param->args[0] = (Ip_ptrdiff_t)vr;
|
||||
param->args[1] = (Ip_ptrdiff_t)netif;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
*===========================================================================
|
||||
*
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipmpls_netlink_rtm_new(Ip_u8 *data, Ip_size_t len,
|
||||
struct Ipmpls_nlmsghdr *nlh, void *arg, int vr)
|
||||
{
|
||||
int ret = 0;
|
||||
struct Ipmpls_rtmsg *rtm = IPMPLS_NLMSG_DATA(nlh);
|
||||
struct Ipmpls_rtattr **rta = arg;
|
||||
|
||||
(void)data;
|
||||
(void)len;
|
||||
|
||||
switch (rtm->rtm_type)
|
||||
{
|
||||
case IPMPLS_RTN_ILM:
|
||||
if (rta[IPMPLS_RTA_ILM - 1])
|
||||
{
|
||||
struct Ipmpls_in_label_req *il =
|
||||
(struct Ipmpls_in_label_req*)IPMPLS_RTA_DATA(rta[IPMPLS_RTA_ILM -1]);
|
||||
|
||||
ret = ipmpls_do_ioctl(IPMPLS_SIOCMPLSILMADD,vr, il);
|
||||
|
||||
if (rta[IPMPLS_RTA_INSTR - 1] && ((ret == 0) || ret == -IP_ERRNO_EEXIST))
|
||||
{
|
||||
ret = ipmpls_do_ioctl(IPMPLS_SIOCSMPLSININSTR,
|
||||
vr,
|
||||
IPMPLS_RTA_DATA(rta[IPMPLS_RTA_INSTR - 1]));
|
||||
}
|
||||
|
||||
if (rta[IPMPLS_RTA_COOKIE - 1] && (ret == 0))
|
||||
{
|
||||
|
||||
if (IPMPLS_RTA_PAYLOAD(rta[IPMPLS_RTA_COOKIE - 1]) > sizeof(Ipmpls_rt_cookie))
|
||||
return -IP_ERRNO_EINVAL;
|
||||
|
||||
ret = ipmpls_set_cookie(&il->mil_label,
|
||||
vr,
|
||||
IPMPLS_RTA_DATA(rta[IPMPLS_RTA_COOKIE - 1]));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IPMPLS_RTN_NHLFE:
|
||||
if (rta[IPMPLS_RTA_NHLFE - 1])
|
||||
{
|
||||
struct Ipmpls_out_label_req *ol =
|
||||
(struct Ipmpls_out_label_req*)IPMPLS_RTA_DATA(rta[IPMPLS_RTA_NHLFE -1]);
|
||||
|
||||
ret = ipmpls_do_ioctl(IPMPLS_SIOCMPLSNHLFEADD,vr, ol);
|
||||
|
||||
if (rta[IPMPLS_RTA_INSTR - 1] && ((ret == 0) || ret == -IP_ERRNO_EEXIST))
|
||||
{
|
||||
ret = ipmpls_do_ioctl(IPMPLS_SIOCSMPLSOUTINSTR,
|
||||
vr,
|
||||
IPMPLS_RTA_DATA(rta[IPMPLS_RTA_INSTR - 1]));
|
||||
}
|
||||
|
||||
if (rta[IPMPLS_RTA_COOKIE - 1] && (ret == 0))
|
||||
{
|
||||
|
||||
if (IPMPLS_RTA_PAYLOAD(rta[IPMPLS_RTA_COOKIE - 1]) > sizeof(Ipmpls_rt_cookie))
|
||||
return -IP_ERRNO_EINVAL;
|
||||
|
||||
ret = ipmpls_set_cookie(&ol->mol_label,
|
||||
vr,
|
||||
IPMPLS_RTA_DATA(rta[IPMPLS_RTA_COOKIE - 1]));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IPMPLS_RTN_XC:
|
||||
if (rta[IPMPLS_RTA_XC - 1])
|
||||
{
|
||||
ret = ipmpls_do_ioctl(IPMPLS_SIOCMPLSXCADD,
|
||||
vr,
|
||||
IPMPLS_RTA_DATA(rta[IPMPLS_RTA_XC -1]));
|
||||
}
|
||||
break;
|
||||
case IPMPLS_RTN_LABELSPACE:
|
||||
if (rta[IPMPLS_RTA_LABELSPACE - 1])
|
||||
{
|
||||
ret = ipmpls_do_ioctl(IPMPLS_SIOCSLABELSPACEMPLS,
|
||||
vr,
|
||||
IPMPLS_RTA_DATA(rta[IPMPLS_RTA_LABELSPACE -1]));
|
||||
}
|
||||
break;
|
||||
|
||||
case IPMPLS_RTN_TUNNEL:
|
||||
{
|
||||
void* idata = IP_NULL;
|
||||
|
||||
if (rta[IPMPLS_RTA_TUNNEL_DATA - 1])
|
||||
idata = IPMPLS_RTA_DATA(rta[IPMPLS_RTA_TUNNEL_DATA - 1]);
|
||||
#if 0
|
||||
if (rta[IPMPLS_RTA_TUNNEL_NAME - 1])
|
||||
{
|
||||
ret = ipcom_mpls_tunnel_create(IPMPLS_RTA_DATA(rta[IPMPLS_RTA_TUNNEL_NAME - 1]),
|
||||
vr,
|
||||
idata);
|
||||
}
|
||||
#endif
|
||||
if (rta[IPMPLS_RTA_NHLFE - 1] && ((ret == 0) || (ret == -IP_ERRNO_EEXIST)))
|
||||
{
|
||||
struct Ipmpls_out_label_req ol;
|
||||
Ipcom_netif *netif;
|
||||
Ipmpls_netif *mplsif;
|
||||
|
||||
ipcom_memcpy(&ol, IPMPLS_RTA_DATA(rta[IPMPLS_RTA_NHLFE -1]), sizeof(ol));
|
||||
|
||||
netif = (Ipcom_netif*)ipcom_mpls_ioevent(IP_NULL,
|
||||
IPMPLS_EIOXNAMETONETIF,
|
||||
(void *)IPMPLS_RTA_DATA(rta[IPMPLS_RTA_TUNNEL_NAME - 1]),
|
||||
(void *)&vr,
|
||||
IP_NULL);
|
||||
if (netif == IP_NULL)
|
||||
return -IP_ERRNO_ENOTFOUND;
|
||||
|
||||
mplsif = netif->plink;
|
||||
|
||||
if (mplsif == IP_NULL)
|
||||
return -IP_ERRNO_EINVAL;
|
||||
|
||||
ipmpls_key_create(0, &ol.mol_label, &mplsif->key);
|
||||
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ret = -IP_ERRNO_EINVAL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
IP_PUBLIC int
|
||||
ipmpls_netlink_rtm_del(Ip_u8 *data, Ip_size_t len,
|
||||
struct Ipmpls_nlmsghdr *nlh, void *arg, int vr)
|
||||
{
|
||||
int ret = -IP_ERRNO_EINVAL;
|
||||
unsigned long req;
|
||||
struct Ipmpls_rtmsg *rtm = IPMPLS_NLMSG_DATA(nlh);
|
||||
struct Ipmpls_rtattr **rta = arg;
|
||||
void *d;
|
||||
|
||||
(void)data;
|
||||
(void)len;
|
||||
|
||||
switch (rtm->rtm_type)
|
||||
{
|
||||
case IPMPLS_RTN_ILM:
|
||||
if (rta[IPMPLS_RTA_ILM - 1])
|
||||
{
|
||||
req = IPMPLS_SIOCMPLSILMDEL;
|
||||
d = IPMPLS_RTA_DATA(rta[IPMPLS_RTA_ILM -1]);
|
||||
goto do_ioctl;
|
||||
}
|
||||
break;
|
||||
case IPMPLS_RTN_NHLFE:
|
||||
if (rta[IPMPLS_RTA_NHLFE - 1])
|
||||
{
|
||||
req = IPMPLS_SIOCMPLSNHLFEDEL;
|
||||
d = IPMPLS_RTA_DATA(rta[IPMPLS_RTA_NHLFE -1]);
|
||||
goto do_ioctl;
|
||||
}
|
||||
break;
|
||||
case IPMPLS_RTN_XC:
|
||||
if (rta[IPMPLS_RTA_XC - 1])
|
||||
{
|
||||
req = IPMPLS_SIOCMPLSXCDEL;
|
||||
d = IPMPLS_RTA_DATA(rta[IPMPLS_RTA_XC -1]);
|
||||
goto do_ioctl;
|
||||
}
|
||||
break;
|
||||
case IPMPLS_RTN_ILMFLUSH:
|
||||
req = IPMPLS_SIOCMPLSILMFLUSH;
|
||||
d = IP_NULL;
|
||||
goto do_ioctl;
|
||||
case IPMPLS_RTN_NHLFEFLUSH:
|
||||
req = IPMPLS_SIOCMPLSNHLFEFLUSH;
|
||||
d = IP_NULL;
|
||||
goto do_ioctl;
|
||||
case IPMPLS_RTN_TUNNEL:
|
||||
if (rta[IPMPLS_RTA_TUNNEL_NAME - 1])
|
||||
{
|
||||
#if defined(IP_PORT_LKM) && defined(IPCOM_LKM_HAS_MPLS_TUNNEL_UTILS)
|
||||
ret = ipcom_mpls_tunnel_destroy(IPMPLS_RTA_DATA(rta[IPMPLS_RTA_TUNNEL_NAME - 1]), vr);
|
||||
#else
|
||||
ret = ipmpls_ioctl_tunnel(IPMPLS_SIOCMPLSTUNNELDEL,
|
||||
vr,
|
||||
IPMPLS_RTA_DATA(rta[IPMPLS_RTA_TUNNEL_NAME - 1]),
|
||||
IP_NULL);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
do_ioctl:
|
||||
|
||||
return ipmpls_do_ioctl(req, vr, d);
|
||||
}
|
||||
|
||||
|
||||
IP_PUBLIC int
|
||||
ipmpls_netlink_rtm_get(Ip_u8 *data, Ip_size_t len, struct Ipmpls_nlmsghdr *nlh,
|
||||
void *arg, void **out_msg, int vr)
|
||||
{
|
||||
Ip_size_t totlen = IPMPLS_NETLINK_DEF_BUF_SZ;
|
||||
Ip_u8 *buf;
|
||||
unsigned long req = IP_NULL;
|
||||
unsigned long xreq = 0;
|
||||
void *obj = IP_NULL;
|
||||
void *extra;
|
||||
struct Ipmpls_rtattr **rta = arg;
|
||||
struct Ipmpls_rtmsg *rtm = IPMPLS_NLMSG_DATA(nlh);
|
||||
union {
|
||||
struct Ipmpls_instr_req op;
|
||||
struct Ipmpls_out_label_req ol;
|
||||
} u;
|
||||
int ret;
|
||||
|
||||
ipcom_memset(&u, 0, sizeof(u));
|
||||
|
||||
switch (rtm->rtm_type)
|
||||
{
|
||||
case IPMPLS_RTN_ILM:
|
||||
if (rta[IPMPLS_RTA_ILM - 1])
|
||||
{
|
||||
req = IPMPLS_SIOCMPLSILMGET;
|
||||
obj = IPMPLS_RTA_DATA(rta[IPMPLS_RTA_ILM -1]);
|
||||
xreq = IPMPLS_SIOCGMPLSININSTR;
|
||||
ipcom_memcpy(&u.op.mir_label,
|
||||
&((struct Ipmpls_in_label_req*)obj)->mil_label,
|
||||
sizeof(Ipmpls_label));
|
||||
}
|
||||
break;
|
||||
case IPMPLS_RTN_NHLFE:
|
||||
if (rta[IPMPLS_RTA_NHLFE - 1])
|
||||
{
|
||||
req = IPMPLS_SIOCMPLSNHLFEGET;
|
||||
obj = IPMPLS_RTA_DATA(rta[IPMPLS_RTA_NHLFE -1]);
|
||||
xreq = IPMPLS_SIOCGMPLSOUTINSTR;
|
||||
ipcom_memcpy(&u.op.mir_label,
|
||||
&((struct Ipmpls_out_label_req*)obj)->mol_label,
|
||||
sizeof(Ipmpls_label));
|
||||
}
|
||||
break;
|
||||
case IPMPLS_RTN_TUNNEL:
|
||||
if (rta[IPMPLS_RTA_TUNNEL_NAME - 1])
|
||||
{
|
||||
Ipcom_netif *netif;
|
||||
Ipmpls_netif *mplsif;
|
||||
|
||||
netif = (Ipcom_netif*)ipcom_mpls_ioevent(IP_NULL,
|
||||
IPMPLS_EIOXNAMETONETIF,
|
||||
(void *)IPMPLS_RTA_DATA(rta[IPMPLS_RTA_TUNNEL_NAME - 1]),
|
||||
(void *)&vr,
|
||||
IP_NULL);
|
||||
if (netif == IP_NULL)
|
||||
return -IP_ERRNO_ENOTFOUND;
|
||||
|
||||
mplsif = netif->plink;
|
||||
|
||||
if (mplsif == IP_NULL)
|
||||
return -IP_ERRNO_EINVAL;
|
||||
|
||||
u.ol.mol_label.ml_type = IPMPLS_KEY_GET_TYPE(mplsif->key);
|
||||
u.ol.mol_label.u.ml_key = IPMPLS_KEY_GET_LABEL(mplsif->key);
|
||||
|
||||
obj = IPMPLS_RTA_DATA(rta[IPMPLS_RTA_TUNNEL_NAME - 1]);
|
||||
xreq = IPMPLS_SIOCMPLSNHLFEGET;
|
||||
goto do_xreq;
|
||||
}
|
||||
break;
|
||||
case IPMPLS_RTN_LABELSPACE:
|
||||
if (rta[IPMPLS_RTA_LABELSPACE - 1])
|
||||
{
|
||||
req = IPMPLS_SIOCGLABELSPACEMPLS;
|
||||
obj = IPMPLS_RTA_DATA(rta[IPMPLS_RTA_LABELSPACE - 1]);
|
||||
xreq = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return -IP_ERRNO_EINVAL;
|
||||
}
|
||||
|
||||
/* Fetch info about the object */
|
||||
ret = ipmpls_do_ioctl(req, vr, obj);
|
||||
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
do_xreq:
|
||||
/* Fetch info about the object operations */
|
||||
if (xreq)
|
||||
{
|
||||
ret = ipmpls_do_ioctl(xreq, vr, &u);
|
||||
|
||||
if (ret == 0)
|
||||
extra = &u;
|
||||
}
|
||||
|
||||
buf = ipcom_malloc(IPMPLS_NETLINK_DEF_BUF_SZ);
|
||||
|
||||
if (buf == IP_NULL)
|
||||
return -IP_ERRNO_ENOMEM;
|
||||
|
||||
ipmpls_netlink_fill(buf,
|
||||
obj,
|
||||
extra,
|
||||
IP_NULL,
|
||||
nlh->nlmsg_pid,
|
||||
nlh->nlmsg_seq,
|
||||
rtm->rtm_type,
|
||||
vr,
|
||||
&totlen);
|
||||
|
||||
totlen = IPMPLS_NETLINK_DEF_BUF_SZ - totlen;
|
||||
*out_msg = buf;
|
||||
|
||||
return totlen;
|
||||
}
|
||||
|
||||
IP_PUBLIC int
|
||||
ipmpls_netlink_rtm_dump(Ip_u8 *data, Ip_size_t len,
|
||||
struct Ipmpls_netlink_callback *cb, int vr)
|
||||
{
|
||||
Ipmpls_netlink_foreach_cb_data *param = (Ipmpls_netlink_foreach_cb_data*)cb->args[0];
|
||||
struct Ipmpls_rtmsg *rtm = IPMPLS_NLMSG_DATA(cb->nlh);
|
||||
|
||||
if (param == IP_NULL)
|
||||
{
|
||||
/* First dump. Create a param */
|
||||
param = ipcom_calloc(1, sizeof(*param));
|
||||
|
||||
if (param == IP_NULL)
|
||||
return 0;
|
||||
|
||||
param->status = IPMPLS_NETLINK_DUMP_FIRST_ENTRY;
|
||||
}
|
||||
else if (param->status == IPMPLS_NETLINK_DUMP_FINISHED)
|
||||
{
|
||||
/* No more entries to dump */
|
||||
ipcom_free(param);
|
||||
cb->args[0] = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
param->len = len;
|
||||
param->offset = 0;
|
||||
param->data = data;
|
||||
param->type = rtm->rtm_type;
|
||||
param->vr = vr;
|
||||
param->pid = cb->nlh->nlmsg_pid;
|
||||
param->seq = cb->nlh->nlmsg_seq;
|
||||
|
||||
switch (rtm->rtm_type)
|
||||
{
|
||||
case IPMPLS_RTN_ILM:
|
||||
case IPMPLS_RTN_NHLFE:
|
||||
ipcom_hash_for_each(ipmpls->label_tables,
|
||||
(Ipcom_hash_foreach_cb_func)ipmpls_netlink_route_foreach_vr,
|
||||
param);
|
||||
break;
|
||||
case IPMPLS_RTN_TUNNEL:
|
||||
case IPMPLS_RTN_LABELSPACE:
|
||||
ipcom_mpls_ioevent(IP_NULL,
|
||||
IPMPLS_EIOXFOREACHNETIF,
|
||||
(void*)ipmpls_netlink_netif_foreach,
|
||||
param,
|
||||
IP_NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
if (param->status == IPMPLS_NETLINK_DUMP_DONT_FIT)
|
||||
param->status = IPMPLS_NETLINK_DUMP_TRAILER;
|
||||
|
||||
cb->args[0] = (Ip_ptrdiff_t)param;
|
||||
|
||||
return (int)param->offset;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
#else
|
||||
int ipmpls_netlink_empty_file = 1;
|
||||
#endif
|
||||
@@ -0,0 +1,272 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmpls_procfs.c,v $ $Revision: 1.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmpls/src/ipmpls_procfs.c,v $
|
||||
* $Author: jonas $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Jonas Rendel <Jonas.Rendel@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if defined(IPMPLS) && defined(IP_PORT_LKM)
|
||||
#include "ipmpls_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <ipcom.h>
|
||||
|
||||
#include "ipmpls.h"
|
||||
#include "ipmpls_h.h"
|
||||
#include "ipmpls_ipstack.h"
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_EXTERN Ipmpls_data *ipmpls;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmpls_route_proc_info
|
||||
*===========================================================================
|
||||
* Description: Prints MPLS route info
|
||||
*
|
||||
* Parameters: buffer - pointer to print buffer
|
||||
* start - current head of print buffer
|
||||
* offset - offset in print buffer.
|
||||
* length - length of print buffer.
|
||||
*
|
||||
* Returns: Number of bytes printed.
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipmpls_route_proc_info(char *buffer, char **start, Ip_u32 offset, int length, Ip_bool is_ilm)
|
||||
{
|
||||
Ipmpls_route *rt;
|
||||
Ipmpls_route *tree;
|
||||
Ipcom_netif *netif;
|
||||
Ip_u16 vr = ipcom_get_user_vr();
|
||||
char addr_buf[50];
|
||||
int i = 0;
|
||||
int type;
|
||||
int len = 0;
|
||||
Ip_u32 pos = 0;
|
||||
Ip_u32 begin = 0;
|
||||
|
||||
tree = ipcom_hash_get(ipmpls->label_tables, &vr);
|
||||
|
||||
if (tree == IP_NULL)
|
||||
goto out;
|
||||
|
||||
type = is_ilm ? IPMPLS_LABEL_TYPE_GEN : IPMPLS_LABEL_TYPE_KEY;
|
||||
|
||||
rt = (Ipmpls_route*)ipcom_route_first_entry(tree->head);
|
||||
|
||||
while (rt != IP_NULL)
|
||||
{
|
||||
if (type == (int)IPMPLS_KEY_GET_TYPE(rt->key))
|
||||
{
|
||||
len += ipcom_sprintf(buffer + len,
|
||||
"%d:%d:%d %x",
|
||||
type,
|
||||
IPMPLS_KEY_GET_LABELSPACE(rt->key),
|
||||
IPMPLS_KEY_GET_LABEL(rt->key),
|
||||
rt->age);
|
||||
if (is_ilm)
|
||||
len += ipcom_sprintf(buffer + len,
|
||||
" %s ",
|
||||
IPMPLS_ILM_PROTO(rt) == 0 ? "ipv4" : "ipv6");
|
||||
else
|
||||
len += ipcom_sprintf(buffer + len,
|
||||
" %d ",
|
||||
IPMPLS_NHLFE_MTU(rt));
|
||||
|
||||
for (i = 0; rt->oplist && i < rt->oplist->num_opcodes; i++)
|
||||
{
|
||||
switch (rt->oplist->opcodes[i].opcode)
|
||||
{
|
||||
case IPMPLS_OP_POP:
|
||||
len += ipcom_sprintf(buffer + len,"pop");
|
||||
break;
|
||||
case IPMPLS_OP_PEEK:
|
||||
len += ipcom_sprintf(buffer + len,"peek");
|
||||
break;
|
||||
case IPMPLS_OP_DLV:
|
||||
len += ipcom_sprintf(buffer + len,"dlv");
|
||||
break;
|
||||
case IPMPLS_OP_SET_RX:
|
||||
{
|
||||
netif = (Ipcom_netif *) ipcom_mpls_ioevent(IP_NULL,
|
||||
IPMPLS_EIOXINDEXTONETIF,
|
||||
(void *)rt->oplist->opcodes[i].data.set.ifindex,
|
||||
IP_NULL,
|
||||
IP_NULL);
|
||||
|
||||
len += ipcom_sprintf(buffer + len,"setrx");
|
||||
|
||||
if(netif)
|
||||
len += ipcom_sprintf(buffer + len,",%s",netif->name);
|
||||
}
|
||||
break;
|
||||
case IPMPLS_OP_SET_RTAB:
|
||||
len += ipcom_sprintf(buffer + len,"setvr,%d", rt->oplist->opcodes[i].data.set.ifindex);
|
||||
break;
|
||||
case IPMPLS_OP_PUSH:
|
||||
len += ipcom_sprintf(buffer + len,"push,%d", rt->oplist->opcodes[i].data.push.u.ml_gen);
|
||||
break;
|
||||
case IPMPLS_OP_FWD:
|
||||
len += ipcom_sprintf(buffer + len,"fwd,%d:%d:%d",
|
||||
IPMPLS_KEY_GET_TYPE(rt->oplist->opcodes[i].data.fwd),
|
||||
IPMPLS_KEY_GET_LABELSPACE(rt->oplist->opcodes[i].data.fwd),
|
||||
IPMPLS_KEY_GET_LABEL(rt->oplist->opcodes[i].data.fwd));
|
||||
break;
|
||||
case IPMPLS_OP_SET:
|
||||
netif = (Ipcom_netif *) ipcom_mpls_ioevent(IP_NULL,
|
||||
IPMPLS_EIOXINDEXTONETIF,
|
||||
(void *)rt->oplist->opcodes[i].data.set.ifindex,
|
||||
IP_NULL,
|
||||
IP_NULL);
|
||||
|
||||
len += ipcom_sprintf(buffer + len,"set");
|
||||
|
||||
if (netif)
|
||||
len += ipcom_sprintf(buffer + len,",%s",netif->name);
|
||||
|
||||
switch(rt->oplist->opcodes[i].data.set.sa->sa_family)
|
||||
{
|
||||
#ifdef IPCOM_USE_INET
|
||||
case IP_AF_INET:
|
||||
{
|
||||
struct Ip_sockaddr_in *sin = (struct Ip_sockaddr_in*)rt->oplist->opcodes[i].data.set.sa;
|
||||
|
||||
(void)ipcom_inet_ntop(IP_AF_INET, &sin->sin_addr, addr_buf, sizeof(addr_buf));
|
||||
len += ipcom_sprintf(buffer + len,",%s", addr_buf);
|
||||
break;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef IPCOM_USE_INET6
|
||||
case IP_AF_INET6:
|
||||
{
|
||||
struct Ip_sockaddr_in6 *sin6 = (struct Ip_sockaddr_in6*)rt->oplist->opcodes[i].data.set.sa;
|
||||
|
||||
(void)ipcom_inet_ntop(IP_AF_INET6, &sin6->sin6_addr, addr_buf, sizeof(addr_buf));
|
||||
len += ipcom_sprintf(buffer + len,",%s", addr_buf);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
len += ipcom_sprintf(buffer + len,",unknown");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case IPMPLS_OP_NOP:
|
||||
len += ipcom_sprintf(buffer + len, "nop");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
len += ipcom_sprintf(buffer + len, ",");
|
||||
}
|
||||
|
||||
len += ipcom_sprintf(buffer + len,"\n");
|
||||
|
||||
pos = begin + len;
|
||||
if (pos < offset)
|
||||
{
|
||||
len = 0;
|
||||
begin = pos;
|
||||
}
|
||||
|
||||
if (pos > offset + length)
|
||||
goto out;
|
||||
}
|
||||
|
||||
rt = (Ipmpls_route*)ipcom_route_next_entry(&rt->hdr);
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
*start = buffer + (offset - begin);
|
||||
len -= (offset - begin);
|
||||
if (len > length)
|
||||
len = length;
|
||||
if (len < 0)
|
||||
len = 0;
|
||||
|
||||
return (len);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
#else
|
||||
int ipmpls_procfs_empty_file = 1;
|
||||
#endif
|
||||
Reference in New Issue
Block a user