Files
m241Neelima/components/ip_net2-6.9/iplite2/src/iplite_sysctl.c
T
2026-07-30 11:19:44 +05:30

198 lines
6.3 KiB
C

/*
******************************************************************************
* SOURCE FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: iplite_sysctl.c,v $ $Revision: 1.5 $
* $Source: /home/interpeak/CVSRoot/iplite2/src/iplite_sysctl.c,v $
* $Author: hxie $
* $State: Exp $ $Locker: $
*
* INTERPEAK_COPYRIGHT_STRING
* Design and implementation by Kenneth Jonsson <kenneth@interpeak.se>
******************************************************************************
*/
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
* Implementation of ipcom_sysctl().
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
#ifndef IPCOM_KERNEL
#define IPCOM_KERNEL
#endif
#include "iplite_config.h"
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#define IPCOM_USE_CLIB_PROTO
#include <ipcom_clib.h>
#include <ipcom_sock.h>
#include <ipcom_sock2.h>
#include <ipcom_os.h>
#include <ipcom_sysctl.h>
#include <ipcom_errno.h>
#include "iplite_h.h"
#include "ipcom_sysctl.h"
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
/*
****************************************************************************
* 6 EXTERN PROTOTYPES
****************************************************************************
*/
/*
****************************************************************************
* 7 LOCAL PROTOTYPES
****************************************************************************
*/
/*
****************************************************************************
* 8 DATA
****************************************************************************
*/
/*
****************************************************************************
* 9 STATIC FUNCTIONS
****************************************************************************
*/
/*
****************************************************************************
* 10 GLOBAL FUNCTIONS
****************************************************************************
*/
/*
****************************************************************************
* 11 PUBLIC FUNCTIONS
****************************************************************************
*/
/*
*===========================================================================
* ipcom_sysctl
*===========================================================================
* Description: System control for IPLITE.
* Parameters: name - the hierarchical sysctl name.
* namelen - the size of the 'name' array.
* oldp - buffer to where the route entries will be copied
* oldlenp - [in] the length of 'oldp' buffer
* [out] the number of bytes copied to 'oldp' buffer or
* the number of bytes needed (if 'oldp' is IP_NULL).
* newp - the new value for the variable
* newlen - the length of the 'newp' buffer.
* Returns: 0 == success, <0 == error code.
*
*/
IP_PUBLIC int
ipcom_sysctl(int *name, unsigned int namelen,
void *oldp, Ip_size_t *oldlenp,
void *newp, Ip_size_t newlen)
{
(void)name;
(void)namelen;
(void)oldp;
(void)oldlenp;
(void)newp;
(void)newlen;
(void)ipcom_errno_set(IP_ERRNO_ENOSUPPORT);
return IP_SOCKERR;
}
/*
*===========================================================================
* iplite_getifaddrs
*===========================================================================
* Description: get all addresses.
* Parameters: ifa - used to store addresses.
* Returns: 0 == success, <0 == error code.
*
*/
#ifdef IP_PORT_VXWORKS
IP_PUBLIC int
iplite_getifaddrs(struct Ip_ifaddrs **ifa)
{
#ifdef IPCOM_USE_INET6
int i;
struct Ip_ifaddrs *faHead = IP_NULL;
struct Ip_ifaddrs *faNew = IP_NULL;
struct Ip_sockaddr_in6 * sin6Addr = IP_NULL;
struct Iplite_ip6_addr_entry_struct *addrList = IP_NULL;
IPLITE_CODE_LOCK();
for (i=0; i<IPLITE_CONF_MAX_NETIF; i++)
{
if ((iplite.netifs[i] == IP_NULL)
|| (iplite.netifs[i]->inet6_addr_list == IP_NULL))
{
continue;
}
addrList = iplite.netifs[i]->inet6_addr_list;
while (addrList != IP_NULL)
{
faNew = (struct Ip_ifaddrs *)ipcom_malloc(sizeof(struct Ip_ifaddrs));
ip_assert(faNew != IP_NULL);
ipcom_memset(faNew, 0x00, sizeof(struct Ip_ifaddrs));
faNew->ifa_next = faHead;
faHead = faNew;
faHead->ifa_addr = (struct Ip_sockaddr *)ipcom_malloc(sizeof(struct Ip_sockaddr_in6));
memset(faHead->ifa_addr, 0x00, sizeof(struct Ip_sockaddr_in6));
ip_assert(faNew != IP_NULL);
faHead->ifa_addr->sa_family = IP_AF_INET6;
faHead->ifa_name = ipcom_strdup(iplite.netifs[i]->ipcom.name);
sin6Addr = (struct Ip_sockaddr_in6 *)faHead->ifa_addr;
ipcom_memcpy(&sin6Addr->sin6_addr,
&addrList->addr,
sizeof(struct Ip_in6_addr));
sin6Addr->sin6_family = IP_AF_INET6;
addrList = addrList->next;
}
}
IPLITE_CODE_UNLOCK();
*ifa = faHead;
return 0;
#endif
return IP_SOCKERR;
}
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/