mib_common.c File Reference

Common definitions for MIB modules. More...

#include "core/net.h"
#include "mibs/mib_common.h"
#include "encoding/oid.h"
#include "debug.h"

Go to the source code of this file.

Functions

error_t mibEncodeIndex (uint8_t *oid, size_t maxOidLen, size_t *pos, uint_t index)
 Encode instance identifier (index) More...
 
error_t mibDecodeIndex (const uint8_t *oid, size_t oidLen, size_t *pos, uint_t *index)
 Decode instance identifier (index) More...
 
error_t mibEncodeUnsigned32 (uint8_t *oid, size_t maxOidLen, size_t *pos, uint32_t value)
 Encode instance identifier (unsigned 32-bit integer) More...
 
error_t mibDecodeUnsigned32 (const uint8_t *oid, size_t oidLen, size_t *pos, uint32_t *value)
 Decode instance identifier (unsigned 32-bit integer) More...
 
error_t mibEncodeString (uint8_t *oid, size_t maxOidLen, size_t *pos, const char_t *string, bool_t implied)
 Encode instance identifier (string) More...
 
error_t mibDecodeString (const uint8_t *oid, size_t oidLen, size_t *pos, char_t *string, size_t maxStringLen, bool_t implied)
 Decode instance identifier (string) More...
 
error_t mibEncodeOctetString (uint8_t *oid, size_t maxOidLen, size_t *pos, const uint8_t *data, size_t dataLen, bool_t implied)
 Encode instance identifier (octet string) More...
 
error_t mibDecodeOctetString (const uint8_t *oid, size_t oidLen, size_t *pos, uint8_t *data, size_t maxDataLen, size_t *dataLen, bool_t implied)
 Decode instance identifier (octet string) More...
 
error_t mibEncodeObjectIdentifier (uint8_t *oid, size_t maxOidLen, size_t *pos, const uint8_t *objectId, size_t objectIdLen, bool_t implied)
 Encode instance identifier (object identifier) More...
 
error_t mibDecodeObjectIdentifier (const uint8_t *oid, size_t oidLen, size_t *pos, uint8_t *objectId, size_t maxObjectIdLen, size_t *objectIdLen, bool_t implied)
 Decode instance identifier (object identifier) More...
 
error_t mibEncodePort (uint8_t *oid, size_t maxOidLen, size_t *pos, uint16_t port)
 Encode instance identifier (port number) More...
 
error_t mibDecodePort (const uint8_t *oid, size_t oidLen, size_t *pos, uint16_t *port)
 Decode instance identifier (port number) More...
 
error_t mibEncodeMacAddr (uint8_t *oid, size_t maxOidLen, size_t *pos, const MacAddr *macAddr)
 Encode instance identifier (MAC address) More...
 
error_t mibDecodeMacAddr (const uint8_t *oid, size_t oidLen, size_t *pos, MacAddr *macAddr)
 Decode instance identifier (MAC address) More...
 
error_t mibEncodeIpv4Addr (uint8_t *oid, size_t maxOidLen, size_t *pos, Ipv4Addr ipAddr)
 Encode instance identifier (IPv4 address) More...
 
error_t mibDecodeIpv4Addr (const uint8_t *oid, size_t oidLen, size_t *pos, Ipv4Addr *ipAddr)
 Decode instance identifier (IPv4 address) More...
 
error_t mibEncodeIpv6Addr (uint8_t *oid, size_t maxOidLen, size_t *pos, const Ipv6Addr *ipAddr)
 Encode instance identifier (IPv6 address) More...
 
error_t mibDecodeIpv6Addr (const uint8_t *oid, size_t oidLen, size_t *pos, Ipv6Addr *ipAddr)
 Decode instance identifier (IPv6 address) More...
 
error_t mibEncodeIpAddr (uint8_t *oid, size_t maxOidLen, size_t *pos, const IpAddr *ipAddr)
 Encode instance identifier (IP address) More...
 
error_t mibDecodeIpAddr (const uint8_t *oid, size_t oidLen, size_t *pos, IpAddr *ipAddr)
 Decode instance identifier (IP address) More...
 
int_t mibCompIpAddr (const IpAddr *ipAddr1, const IpAddr *ipAddr2)
 Compare IP addresses. More...
 
error_t mibTestAndIncSpinLock (int32_t *spinLock, int32_t value, bool_t commit)
 Test and increment spin lock. More...
 

Detailed Description

Common definitions for MIB modules.

License

Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
1.9.0

Definition in file mib_common.c.

Function Documentation

◆ mibCompIpAddr()

int_t mibCompIpAddr ( const IpAddr ipAddr1,
const IpAddr ipAddr2 
)

Compare IP addresses.

Parameters
[in]ipAddr1First IP address
[in]ipAddr2Second IP address
Returns
Comparison result

Definition at line 901 of file mib_common.c.

◆ mibDecodeIndex()

error_t mibDecodeIndex ( const uint8_t *  oid,
size_t  oidLen,
size_t *  pos,
uint_t index 
)

Decode instance identifier (index)

Parameters
[in]oidPointer to the object identifier
[in]oidLenLength of the OID, in bytes
[in,out]posOffset where to read the instance identifier
[out]indexIndex value
Returns
Error code

Definition at line 62 of file mib_common.c.

◆ mibDecodeIpAddr()

error_t mibDecodeIpAddr ( const uint8_t *  oid,
size_t  oidLen,
size_t *  pos,
IpAddr ipAddr 
)

Decode instance identifier (IP address)

Parameters
[in]oidPointer to the object identifier
[in]oidLenLength of the OID, in bytes
[in,out]posOffset where to read the instance identifier
[out]ipAddrIP address
Returns
Error code

Definition at line 833 of file mib_common.c.

◆ mibDecodeIpv4Addr()

error_t mibDecodeIpv4Addr ( const uint8_t *  oid,
size_t  oidLen,
size_t *  pos,
Ipv4Addr ipAddr 
)

Decode instance identifier (IPv4 address)

Parameters
[in]oidPointer to the object identifier
[in]oidLenLength of the OID, in bytes
[in,out]posOffset where to read the instance identifier
[out]ipAddrIPv4 address
Returns
Error code

Definition at line 645 of file mib_common.c.

◆ mibDecodeIpv6Addr()

error_t mibDecodeIpv6Addr ( const uint8_t *  oid,
size_t  oidLen,
size_t *  pos,
Ipv6Addr ipAddr 
)

Decode instance identifier (IPv6 address)

Parameters
[in]oidPointer to the object identifier
[in]oidLenLength of the OID, in bytes
[in,out]posOffset where to read the instance identifier
[out]ipAddrIPv6 address
Returns
Error code

Definition at line 717 of file mib_common.c.

◆ mibDecodeMacAddr()

error_t mibDecodeMacAddr ( const uint8_t *  oid,
size_t  oidLen,
size_t *  pos,
MacAddr macAddr 
)

Decode instance identifier (MAC address)

Parameters
[in]oidPointer to the object identifier
[in]oidLenLength of the OID, in bytes
[in,out]posOffset where to read the instance identifier
[out]macAddrMAC address
Returns
Error code

Definition at line 562 of file mib_common.c.

◆ mibDecodeObjectIdentifier()

error_t mibDecodeObjectIdentifier ( const uint8_t *  oid,
size_t  oidLen,
size_t *  pos,
uint8_t *  objectId,
size_t  maxObjectIdLen,
size_t *  objectIdLen,
bool_t  implied 
)

Decode instance identifier (object identifier)

Parameters
[in]oidPointer to the object identifier
[in]oidLenLength of the OID, in bytes
[in,out]posOffset where to read the instance identifier
[out]objectIdBuffer where to store the object identifier
[in]maxObjectIdLenMaximum number of bytes the buffer can hold
[out]objectIdLenLength of the object identifier, in bytes
[in]impliedSpecifies whether the index is preceded by the IMPLIED keyword
Returns
Error code

Definition at line 375 of file mib_common.c.

◆ mibDecodeOctetString()

error_t mibDecodeOctetString ( const uint8_t *  oid,
size_t  oidLen,
size_t *  pos,
uint8_t *  data,
size_t  maxDataLen,
size_t *  dataLen,
bool_t  implied 
)

Decode instance identifier (octet string)

Parameters
[in]oidPointer to the object identifier
[in]oidLenLength of the OID, in bytes
[in,out]posOffset where to read the instance identifier
[out]dataBuffer where to store the octet string
[in]maxDataLenMaximum number of bytes the buffer can hold
[out]dataLenLength of the octet string, in bytes
[in]impliedSpecifies whether the index is preceded by the IMPLIED keyword
Returns
Error code

Definition at line 223 of file mib_common.c.

◆ mibDecodePort()

error_t mibDecodePort ( const uint8_t *  oid,
size_t  oidLen,
size_t *  pos,
uint16_t *  port 
)

Decode instance identifier (port number)

Parameters
[in]oidPointer to the object identifier
[in]oidLenLength of the OID, in bytes
[in,out]posOffset where to read the instance identifier
[out]portPort number
Returns
Error code

Definition at line 493 of file mib_common.c.

◆ mibDecodeString()

error_t mibDecodeString ( const uint8_t *  oid,
size_t  oidLen,
size_t *  pos,
char_t string,
size_t  maxStringLen,
bool_t  implied 
)

Decode instance identifier (string)

Parameters
[in]oidPointer to the object identifier
[in]oidLenLength of the OID, in bytes
[in,out]posOffset where to read the instance identifier
[out]stringNULL-terminated string
[in]maxStringLenMaximum number of characters the string can hold
[in]impliedSpecifies whether the index is preceded by the IMPLIED keyword
Returns
Error code

Definition at line 147 of file mib_common.c.

◆ mibDecodeUnsigned32()

error_t mibDecodeUnsigned32 ( const uint8_t *  oid,
size_t  oidLen,
size_t *  pos,
uint32_t *  value 
)

Decode instance identifier (unsigned 32-bit integer)

Parameters
[in]oidPointer to the object identifier
[in]oidLenLength of the OID, in bytes
[in,out]posOffset where to read the instance identifier
[out]valueUnsigned 32-bit integer
Returns
Error code

Definition at line 109 of file mib_common.c.

◆ mibEncodeIndex()

error_t mibEncodeIndex ( uint8_t *  oid,
size_t  maxOidLen,
size_t *  pos,
uint_t  index 
)

Encode instance identifier (index)

Parameters
[in]oidPointer to the object identifier
[in]maxOidLenMaximum number of bytes the OID can hold
[in,out]posOffset where to write the instance identifier
[in]indexIndex value
Returns
Error code

Definition at line 45 of file mib_common.c.

◆ mibEncodeIpAddr()

error_t mibEncodeIpAddr ( uint8_t *  oid,
size_t  maxOidLen,
size_t *  pos,
const IpAddr ipAddr 
)

Encode instance identifier (IP address)

Parameters
[in]oidPointer to the object identifier
[in]maxOidLenMaximum number of bytes the OID can hold
[in,out]posOffset where to write the instance identifier
[in]ipAddrIP address
Returns
Error code

Definition at line 755 of file mib_common.c.

◆ mibEncodeIpv4Addr()

error_t mibEncodeIpv4Addr ( uint8_t *  oid,
size_t  maxOidLen,
size_t *  pos,
Ipv4Addr  ipAddr 
)

Encode instance identifier (IPv4 address)

Parameters
[in]oidPointer to the object identifier
[in]maxOidLenMaximum number of bytes the OID can hold
[in,out]posOffset where to write the instance identifier
[in]ipAddrIPv4 address
Returns
Error code

Definition at line 611 of file mib_common.c.

◆ mibEncodeIpv6Addr()

error_t mibEncodeIpv6Addr ( uint8_t *  oid,
size_t  maxOidLen,
size_t *  pos,
const Ipv6Addr ipAddr 
)

Encode instance identifier (IPv6 address)

Parameters
[in]oidPointer to the object identifier
[in]maxOidLenMaximum number of bytes the OID can hold
[in,out]posOffset where to write the instance identifier
[in]ipAddrIPv6 address
Returns
Error code

Definition at line 687 of file mib_common.c.

◆ mibEncodeMacAddr()

error_t mibEncodeMacAddr ( uint8_t *  oid,
size_t  maxOidLen,
size_t *  pos,
const MacAddr macAddr 
)

Encode instance identifier (MAC address)

Parameters
[in]oidPointer to the object identifier
[in]maxOidLenMaximum number of bytes the OID can hold
[in,out]posOffset where to write the instance identifier
[in]macAddrMAC address
Returns
Error code

Definition at line 526 of file mib_common.c.

◆ mibEncodeObjectIdentifier()

error_t mibEncodeObjectIdentifier ( uint8_t *  oid,
size_t  maxOidLen,
size_t *  pos,
const uint8_t *  objectId,
size_t  objectIdLen,
bool_t  implied 
)

Encode instance identifier (object identifier)

Parameters
[in]oidPointer to the object identifier
[in]maxOidLenMaximum number of bytes the OID can hold
[in,out]posOffset where to write the instance identifier
[in]objectIdObject identifier to be encoded
[in]objectIdLenLength of the object identifier, in bytes
[in]impliedSpecifies whether the index is preceded by the IMPLIED keyword
Returns
Error code

Definition at line 295 of file mib_common.c.

◆ mibEncodeOctetString()

error_t mibEncodeOctetString ( uint8_t *  oid,
size_t  maxOidLen,
size_t *  pos,
const uint8_t *  data,
size_t  dataLen,
bool_t  implied 
)

Encode instance identifier (octet string)

Parameters
[in]oidPointer to the object identifier
[in]maxOidLenMaximum number of bytes the OID can hold
[in,out]posOffset where to write the instance identifier
[in]dataPointer to the octet string
[in]dataLenLength of the octet string, in bytes
[in]impliedSpecifies whether the index is preceded by the IMPLIED keyword
Returns
Error code

Definition at line 180 of file mib_common.c.

◆ mibEncodePort()

error_t mibEncodePort ( uint8_t *  oid,
size_t  maxOidLen,
size_t *  pos,
uint16_t  port 
)

Encode instance identifier (port number)

Parameters
[in]oidPointer to the object identifier
[in]maxOidLenMaximum number of bytes the OID can hold
[in,out]posOffset where to write the instance identifier
[in]portPort number
Returns
Error code

Definition at line 476 of file mib_common.c.

◆ mibEncodeString()

error_t mibEncodeString ( uint8_t *  oid,
size_t  maxOidLen,
size_t *  pos,
const char_t string,
bool_t  implied 
)

Encode instance identifier (string)

Parameters
[in]oidPointer to the object identifier
[in]maxOidLenMaximum number of bytes the OID can hold
[in,out]posOffset where to write the instance identifier
[in]stringNULL-terminated string
[in]impliedSpecifies whether the index is preceded by the IMPLIED keyword
Returns
Error code

Definition at line 127 of file mib_common.c.

◆ mibEncodeUnsigned32()

error_t mibEncodeUnsigned32 ( uint8_t *  oid,
size_t  maxOidLen,
size_t *  pos,
uint32_t  value 
)

Encode instance identifier (unsigned 32-bit integer)

Parameters
[in]oidPointer to the object identifier
[in]maxOidLenMaximum number of bytes the OID can hold
[in,out]posOffset where to write the instance identifier
[in]valueUnsigned 32-bit integer
Returns
Error code

Definition at line 92 of file mib_common.c.

◆ mibTestAndIncSpinLock()

error_t mibTestAndIncSpinLock ( int32_t *  spinLock,
int32_t  value,
bool_t  commit 
)

Test and increment spin lock.

Parameters
[in,out]spinLockPointer to the spin lock
[in]valueNew value supplied via the management protocol
[in]commitThis flag indicates the current phase (validation phase or write phase if the validation was successful)
Returns
Comparison result

Definition at line 939 of file mib_common.c.