MityDSP Documentation Index
Classes | Functions | Variables
net_iface.cpp File Reference

This file defines the net_iface functions, which sit between the MityDSP network drivers and the lwIP stack. More...

#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include "core/DspError.h"
#include "net/net_drvr/net_drvr.h"
#include "net/net_iface.h"
#include "netif/etharp.h"
#include "netif_access.h"

Classes

struct  tsPbufQueue
struct  tsMbxData

Functions

static int net_iface_rx_thread (struct netif *apNetif)
static err_t net_iface_output (struct netif *apNetif, struct pbuf *apPbuf, struct ip_addr *apIpAddr)
static err_t net_iface_linkoutput (struct netif *apNetif, struct pbuf *apPbuf)
static err_t net_iface_mac_filter (struct netif *apNetif, struct ip_addr *apIp, unsigned char anAdd)
void net_iface_set_defaults (tsNetIface *apNetIface, tcNetDrvr *apNetDrvr)
void net_iface_copy_pbuff (tsNetIface *apNetIfaceDst, tsNetIface *apNetIfaceSrc)
err_t net_iface_init (struct netif *apNetif)
void net_iface_rx_cb (void *apBuffer, int anLen, void *apUser, bool abInIsr)
void * net_iface_buf_alloc (int anLen, void *apUser)

Variables

struct eth_addr ethbroadcast

Detailed Description

This file defines the net_iface functions, which sit between the MityDSP network drivers and the lwIP stack.

o 0 | / Copyright (c) 2005-2009 (CL)—o Critical Link, LLC \ O


Function Documentation

int net_iface_rx_thread ( struct netif *  apNetif)
static

This function is started as a thread by net_iface_init. It pends on a mailbox which is filled by net_iface_rx_cb with packet data. The payload retrieved via the mailbox is compared to the queue of pbufs allocated by net_iface_buf_alloc. When a match is found, the underlying pbuf is passed directly to the network stack.

Parameters:
[in]apNetifPointer to the netif structure.
Returns:
Zero.
err_t net_iface_output ( struct netif *  apNetif,
struct pbuf *  apPbuf,
struct ip_addr *  apIpAddr 
)
static

This function is called by the TCP/IP stack when an IP packet should be sent. It calls the function etharp_output() to resolve the MAC address, which eventually calls net_iface_linkoutput() to do the actual transmission of the packet.

Parameters:
[in]apNetifPointer to the netif structure.
[in]apPbufPointer to the pbuf containing the packet.
[in]apIpAddrPointer to the IP address of the destination.
Returns:
Zero on success, non-zero if an error occurred.
err_t net_iface_linkoutput ( struct netif *  apNetif,
struct pbuf *  apPbuf 
)
static

This function is called to direct the actual transmission of the packet. The packet is contained in a pbuf (or chain of pbufs), which must be passed to the network driver transmit routine.

Parameters:
[in]apNetifPointer to the netif structure.
[in]apPbufPointer to the pbuf containing the packet.
Returns:
Zero on success, non-zero if an error occurred.
err_t net_iface_mac_filter ( struct netif *  apNetif,
struct ip_addr *  apIp,
unsigned char  anAdd 
)
static

This function is called to add or remove a particular MAC address to/from the interface's multicast filter list.

Parameters:
[in]apNetifPointer to the netif structure.
[in]apIpPointer to an ip_addr structure.
[in]anAddZero to remove the filter, non-zero to add.
Returns:
Zero on success, non-zero if an error occurred.
void net_iface_set_defaults ( tsNetIface apNetIface,
tcNetDrvr apNetDrvr 
)

This function provides defaults for the tsNetIface structure.

Parameters:
[in]apNetIfacePointer to the tsNetIface structure to set to default values.
[in]apNetDrvrPointer to the network driver to associate with the provided tsNetIface.
Returns:
None.
void net_iface_copy_pbuff ( tsNetIface apNetIfaceDst,
tsNetIface apNetIfaceSrc 
)
err_t net_iface_init ( struct netif *  apNetif)

This function should be registered as the lwIP network interface (netif) initialization function. When activated, it sets up the interface, starts the receiver thread, and initializes the network hardware.

Parameters:
[in]apNetifPointer to the netif structure for the interface being initialized.
Returns:
Zero upon success, -1 for failure
void net_iface_rx_cb ( void *  apBuffer,
int  anLen,
void *  apUser,
bool  abInIsr 
)

This function is registered as the receive packet callback for the network driver by the "open" call in net_iface_init. When activated, it posts the pointer to the received data to the net_iface_rx_thread.

Parameters:
[in]apBufferPointer to the received packet.
[in]anLenThe length of the received packet.
[in]apUserPointer to the netif structure.
[in]abInIsrTrue if called from ISR (not used).
Returns:
None.
void* net_iface_buf_alloc ( int  anLen,
void *  apUser 
)

This function is registered as the buffer allocation callback for the network driver by the "open" call in net_iface_init. When activated, it provides a valid location where the next packet is to be written.

Note:
The pbuf size must be set greater or equal to the max packet size in lwipopts.h.
Parameters:
[in]anLenThe length of the buffer to allocate.
[in]apUserPointer to the netif structure.
Returns:
Payload area of an allocated pbuf.

Variable Documentation

struct eth_addr ethbroadcast

  
Generated on Mon Apr 22 2013 11:33:32 for MityDSP Net by  Doxygen Version 1.8.1.1
Copyright © 2009, Critical Link LLC, All rights reserved.