ethernet_misc.h File Reference

Helper functions for Ethernet. More...

#include "core/net.h"
#include "core/ethernet.h"

Go to the source code of this file.

Functions

error_t ethPadFrame (NetBuffer *buffer, size_t *length)
 Ethernet frame padding. More...
 
error_t ethEncodeVlanTag (NetBuffer *buffer, size_t *offset, uint16_t vlanId, int8_t vlanPcp, int8_t vlanDei, uint16_t type)
 VLAN tag encoding. More...
 
error_t ethDecodeVlanTag (const uint8_t *frame, size_t length, uint16_t *vlanId, uint16_t *type)
 VLAN tag decoding. More...
 
error_t ethCheckDestAddr (NetInterface *interface, const MacAddr *macAddr)
 Destination MAC address filtering. More...
 
bool_t ethTrapIgmpPacket (EthHeader *header, uint8_t *data, size_t length)
 Trap IGMP packets. More...
 
void ethUpdateInStats (NetInterface *interface, const MacAddr *destMacAddr)
 Update Ethernet input statistics. More...
 
void ethUpdateOutStats (NetInterface *interface, const MacAddr *destMacAddr, size_t length)
 Update Ethernet output statistics. More...
 
void ethUpdateErrorStats (NetInterface *interface, error_t error)
 Update Ethernet error statistics. More...
 
uint32_t ethCalcCrc (const void *data, size_t length)
 Ethernet CRC calculation. More...
 
uint32_t ethCalcCrcEx (const NetBuffer *buffer, size_t offset, size_t length)
 Calculate CRC over a multi-part buffer. More...
 
error_t ethCheckCrc (NetInterface *interface, const uint8_t *frame, size_t length)
 Ethernet CRC verification. More...
 

Variables

const uint8_t ethPadding [64]
 

Detailed Description

Helper functions for Ethernet.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 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
2.4.4

Definition in file ethernet_misc.h.

Function Documentation

◆ ethCalcCrc()

uint32_t ethCalcCrc ( const void *  data,
size_t  length 
)

Ethernet CRC calculation.

Parameters
[in]dataPointer to the data over which to calculate the CRC
[in]lengthNumber of bytes to process
Returns
Resulting CRC value

Definition at line 502 of file ethernet_misc.c.

◆ ethCalcCrcEx()

uint32_t ethCalcCrcEx ( const NetBuffer buffer,
size_t  offset,
size_t  length 
)

Calculate CRC over a multi-part buffer.

Parameters
[in]bufferPointer to the multi-part buffer
[in]offsetOffset from the beginning of the buffer
[in]lengthNumber of bytes to process
Returns
Resulting CRC value

Definition at line 567 of file ethernet_misc.c.

◆ ethCheckCrc()

error_t ethCheckCrc ( NetInterface interface,
const uint8_t *  frame,
size_t  length 
)

Ethernet CRC verification.

Parameters
[in]interfaceUnderlying network interface
[in]framePointer to the received Ethernet frame
[in]lengthLength of the frame, in bytes
Returns
Error code

Definition at line 644 of file ethernet_misc.c.

◆ ethCheckDestAddr()

error_t ethCheckDestAddr ( NetInterface interface,
const MacAddr macAddr 
)

Destination MAC address filtering.

Parameters
[in]interfaceUnderlying network interface
[in]macAddrDestination MAC address to be checked
Returns
Error code

Definition at line 279 of file ethernet_misc.c.

◆ ethDecodeVlanTag()

error_t ethDecodeVlanTag ( const uint8_t *  frame,
size_t  length,
uint16_t *  vlanId,
uint16_t *  type 
)

VLAN tag decoding.

Parameters
[in]framePointer to the received Ethernet frame
[in]lengthLength of the frame, in bytes
[out]vlanIdVLAN identifier
[out]typeEthernet type
Returns
Error code

Definition at line 243 of file ethernet_misc.c.

◆ ethEncodeVlanTag()

error_t ethEncodeVlanTag ( NetBuffer buffer,
size_t *  offset,
uint16_t  vlanId,
int8_t  vlanPcp,
int8_t  vlanDei,
uint16_t  type 
)

VLAN tag encoding.

Parameters
[in]bufferMulti-part buffer containing the payload
[in,out]offsetOffset to the first payload byte
[in]vlanIdVLAN identifier
[in]vlanPcpVLAN priority
[in]vlanDeiDrop eligible indicator
[in]typeEthernet type
Returns
Error code

Definition at line 190 of file ethernet_misc.c.

◆ ethPadFrame()

error_t ethPadFrame ( NetBuffer buffer,
size_t *  length 
)

Ethernet frame padding.

Parameters
[in]bufferMulti-part buffer containing the Ethernet frame
[in,out]lengthLength of the Ethernet frame, in bytes
Returns
Error code

Definition at line 147 of file ethernet_misc.c.

◆ ethTrapIgmpPacket()

bool_t ethTrapIgmpPacket ( EthHeader header,
uint8_t *  data,
size_t  length 
)

Trap IGMP packets.

Parameters
[in]headerPointer to the Ethernet header
[in]dataPointer to the payload data
[in]lengthLength of the payload data, in bytes
Returns
TRUE if the Ethernet frame contains an IGMP message, else FALSE

Definition at line 351 of file ethernet_misc.c.

◆ ethUpdateErrorStats()

void ethUpdateErrorStats ( NetInterface interface,
error_t  error 
)

Update Ethernet error statistics.

Parameters
[in]interfaceUnderlying network interface
[in]errorStatus code describing the error

Definition at line 464 of file ethernet_misc.c.

◆ ethUpdateInStats()

void ethUpdateInStats ( NetInterface interface,
const MacAddr destMacAddr 
)

Update Ethernet input statistics.

Parameters
[in]interfaceUnderlying network interface
[in]destMacAddrDestination MAC address

Definition at line 383 of file ethernet_misc.c.

◆ ethUpdateOutStats()

void ethUpdateOutStats ( NetInterface interface,
const MacAddr destMacAddr,
size_t  length 
)

Update Ethernet output statistics.

Parameters
[in]interfaceUnderlying network interface
[in]destMacAddrDestination MAC address
[in]lengthLength of the Ethernet frame, in bytes

Definition at line 421 of file ethernet_misc.c.

Variable Documentation

◆ ethPadding

const uint8_t ethPadding[64]
extern

Definition at line 54 of file ethernet_misc.c.