MityDSP Documentation Index
Classes | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
tcDspNetIFConfigUtil Class Reference

#include <arch/DspNetIFConfigUtil.h>

List of all members.

Classes

struct  tsDspNetConfig
union  tuDspNetConfigBlock

Public Member Functions

 tcDspNetIFConfigUtil (MityDSP::tcDspFlash *apFlash, MityDSP::tcDspConfig *apConfig, unsigned int anFlashOffset)
 tcDspNetIFConfigUtil (MityDSP::tcDspConfig *apConfig, tsDspNetConfig *apNetConfig)
 ~tcDspNetIFConfigUtil (void)
int UpdateConfig (tsDspNetConfig *apConfig)
 Update the config block.
int RunQueryServer (struct netif *apIF, unsigned int anTaskPri=3, unsigned short anPortNo=NETIFCFG_POLL_PORT)
 Start the MityDSP discovery server.
int GetConfig (tsDspNetConfig *apConfig)
 Get a copy of the config block for this interface.
struct netif * GetNetIf ()
 Get a pointer to the lwip netif structure for this interface.
bool IsUp ()
 is interface up?

Protected Member Functions

int QueryServer (struct netif *apIF, unsigned short anPortNo)
void WaitForDHCP (struct netif *apIF)

Static Protected Member Functions

static int DispatchQueryServer (struct netif *apIF, unsigned short anPortNo, void *apThis)

Protected Attributes

volatile tuDspNetConfigBlockmpData
MityDSP::tcDspFlash * mpFlash
MityDSP::tcDspConfig * mpConfig
bool mbStoredInFlash
volatile bool mbStopQuery
volatile bool mbQueryRunning
unsigned int mnFlashOffset
struct netif msNetif

Detailed Description

Utility class to provide access/storage of Network Interface configuration data. This class will manage FLASH storage and updates to network interface configuration data. The class is designed to support (through multiple instances) more than one network interface structure.

The class also provides a mechanism to launch a NetWork Query Server to respond to MityDSP network configuration requests from the MityDSPLocator PC application.

The code below shows a simple example of usage. Check the lwip stack initialization page for a full example that includes use of this class.

Warning:
this class is not re-entrant
const unsigned int BANK_SEL_ADDR = 0xB0000004;
const unsigned int FLASH_BASE_ADDR = 0x90000000;
{
void *myAppFwOffset = 0x00020000;
unsigned int myAppFwSize = 0x80000;
void *myAppSwOffset = 0x000A0000;
unsigned int myAppSwSize = 0x100000;
tcDspBankSelect *myBankSel =
new tcDspBankSelect((void *)BANK_SEL_ADDR);
tcDspFlash *myFlash =
new tcDspFlash((void *)FLASH_BASE_ADDR, myBankSel);
tcDspNetIFConfigUtil *lpNetIFConfigUtil = tcDspConfig::GetInstance(lpFlash);
lpNetIFConfigUtil->GetConfig(&lsConfig);
// use lsConfig structure for initiatizing stack init data....
...
//
// launch MityDSP Locator service after network is up and running
mpNetIFConfigUtil->RunQueryServer(&msNetIf);
}

Constructor & Destructor Documentation

tcDspNetIFConfigUtil::tcDspNetIFConfigUtil ( MityDSP::tcDspFlash *  apFlash,
MityDSP::tcDspConfig *  apConfig,
unsigned int  anFlashOffset 
)

Constructor.

Call this constructor if Network Interface data is to be read/stored in FLASH memory. This constructor will populate the necessary configuration data from the location offset specified in the constructor arguements. If invalid data is found in the FLASH (e.g., the FLASH was previously unconfigured) then the information will be iniatialized from the apConfig structure.

Parameters:
[in]apFlashValid pointer to the MityDSP FLASH object
[in]apConfigValid pointer to the MityDSP Configuration Object
[in]anFlashOffsetOffset from base of FLASH where configuration data is stored.
Returns:
none
Note:
The FLASH configuration size is defined by DSP_NETIF_BLOCKSIZE bytes.
tcDspNetIFConfigUtil::tcDspNetIFConfigUtil ( MityDSP::tcDspConfig *  apConfig,
tsDspNetConfig apNetConfig 
)

Constructor.

Call this constructor if Network IF data is simply managed in RAM and not stored in FLASH.

Parameters:
[in]apConfigPointer to a valid tcDspConfig block
[in]apNetConfigPointer to Configuration block data to copy as reference
Returns:
none.
tcDspNetIFConfigUtil::~tcDspNetIFConfigUtil ( void  )

Destructor.

This destructor will terminate an associated MityDSPLocator Query response thread if it is running.


Member Function Documentation

int tcDspNetIFConfigUtil::UpdateConfig ( tsDspNetConfig apConfig)

Update the config block.

Update Configuration

This routine will copy the configuration in apConfig to the local copy. If this instance is associated to FLASH memory, then the FLASH memory will be updated.

Parameters:
[in]apConfigPointer to configuration data.
Returns:
0 on success
int tcDspNetIFConfigUtil::RunQueryServer ( struct netif *  apIF,
unsigned int  anTaskPri = 3,
unsigned short  anPortNo = NETIFCFG_POLL_PORT 
)

Start the MityDSP discovery server.

Run MityDSPLocator Query Server thread.

This method will spawn a thread that will monitor broadcast Poll Requests and repond appropriately. Threads started are destroyed by the destructor of the class.

Parameters:
[in]apIFPointer to LWIP network interface structure to respond on.
[in]anTaskPriTask priority of monitor thread, default 4
[in]anPortNoPort number of monitor thread, default NETIFCFG_POLL_PORT
Returns:
0 on success
Note:
task name will be QUERY_XXXXXXXX where XXXXXXXX is the hex of the IPv4 address
int tcDspNetIFConfigUtil::GetConfig ( tsDspNetConfig apConfig)

Get a copy of the config block for this interface.

Get Configuration

This routine will copy the current configuration to apConfig.

Parameters:
[out]apConfigPointer to configuration data to be filled.
Returns:
0 on success
struct netif* tcDspNetIFConfigUtil::GetNetIf ( )
inlineread

Get a pointer to the lwip netif structure for this interface.

bool tcDspNetIFConfigUtil::IsUp ( )

is interface up?

int tcDspNetIFConfigUtil::DispatchQueryServer ( struct netif *  apIF,
unsigned short  anPortNo,
void *  apThis 
)
staticprotected

Utility Method to launch class scoped Query Server

Parameters:
[in]apIFPointer to LWIP network interface structure to respond on.
[in]anPortNoPort number of monitor thread
[in]apThisPointer to valid tcDspNetIFConfigUtil class
Returns:
0 on success
int tcDspNetIFConfigUtil::QueryServer ( struct netif *  apIF,
unsigned short  anPortNo 
)
protected

Query Server

Responds to tsPollReq Messages from MityDSP Locator.

Parameters:
[in]apIFPointer to LWIP network interface structure to respond on.
[in]anPortNoPort number of monitor thread
Returns:
Zero on success.
void tcDspNetIFConfigUtil::WaitForDHCP ( struct netif *  apIF)
protected

Utility Method to ensure LWIP network interface is bound to an address

Note:
if DHCP is not running, will return immediately
Parameters:
[in]apIFPointer to the network interface to check.
Returns:
when bound

Member Data Documentation

volatile tuDspNetConfigBlock* tcDspNetIFConfigUtil::mpData
protected
MityDSP::tcDspFlash* tcDspNetIFConfigUtil::mpFlash
protected
MityDSP::tcDspConfig* tcDspNetIFConfigUtil::mpConfig
protected
bool tcDspNetIFConfigUtil::mbStoredInFlash
protected
volatile bool tcDspNetIFConfigUtil::mbStopQuery
protected
volatile bool tcDspNetIFConfigUtil::mbQueryRunning
protected
unsigned int tcDspNetIFConfigUtil::mnFlashOffset
protected
struct netif tcDspNetIFConfigUtil::msNetif
protected

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