linklayerprotocols/ethernetnif/IRLAN/IRLANDLL.CPP
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Interface to IR-LAN 
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20 */
       
    21 
       
    22 #include <nifman.h>
       
    23 #include <nifvar.h>
       
    24 #include <nifutl.h>
       
    25 #include <es_mbuf.h>
       
    26 #include "ETHINTER.H"
       
    27 #include "PKTDRV.H"
       
    28 #include "IRLAN.H"
       
    29 #include "IRLANUTL.H"
       
    30 #include "INTSOCK.H"
       
    31 #include "irlantimer.h"
       
    32 
       
    33 #ifdef __TRACEWIN__
       
    34   #include <log.h>
       
    35 #else
       
    36   #define LOG(a)
       
    37 #endif
       
    38 
       
    39 
       
    40 //#####################################################################
       
    41 
       
    42 /**
       
    43 Global Factory Function.
       
    44 @internalComponent
       
    45 */
       
    46 extern "C"
       
    47 {
       
    48     IMPORT_C CPktDrvFactory * NewIrlanPktDrvFactoryL();	// Force export
       
    49 }
       
    50 
       
    51 /**
       
    52 All PktDrv's export as their first Ordinal this global 'C' function.
       
    53 This function is called to create construct and return a pointer to an instance of the 
       
    54 Ethint specific factory class CLANLinkFactory derived from CPktDrvFactory 
       
    55 @return A pointer to CNifFactory object.
       
    56 @internalComponent
       
    57 */
       
    58 EXPORT_C CPktDrvFactory* NewIrlanPktDrvFactoryL()
       
    59 {
       
    60 	CPktDrvFactory *f=new (ELeave) CIrlanPktDrvFactory;
       
    61 	LOG(Log::Printf(_L("IRLAN	Creating instance of CIrlanPktDrvFactory\r\n")));
       
    62 	return f;
       
    63 }
       
    64 
       
    65 
       
    66 /**
       
    67 Need to switch here on the name and open the according driver DLL.
       
    68 @param aParent Pointer to the parent Ethint NIF class.
       
    69 @return A pointer to CPktDrvBase object.
       
    70 */
       
    71 CPktDrvBase* CIrlanPktDrvFactory::NewDriverL(CLANLinkCommon* aParent)
       
    72 {
       
    73 #ifdef __TRACEWIN__
       
    74 	LOG(Log::Printf(_L("IRLAN	CREATING A PKT DRV: CPktDrvFactory::NewDriverL\r\n")));
       
    75 #endif
       
    76 	CPktDrvBase *drv = new (ELeave) CIrlanPktDrv(*this);
       
    77 	CleanupStack::PushL(drv);
       
    78 	drv->ConstructL(aParent);
       
    79 	CleanupStack::Pop();
       
    80 	return drv;
       
    81 }
       
    82 
       
    83 
       
    84 /**
       
    85 Packet Driver version number.
       
    86 @return The client side version number
       
    87 */
       
    88 TVersion CIrlanPktDrvFactory::Version() const
       
    89 {
       
    90 	return(TVersion(KIrlanMajorVersionNumber,KIrlanMinorVersionNumber,KIrlanBuildVersionNumber));
       
    91 }
       
    92 
       
    93 
       
    94 //#####################################################################
       
    95 
       
    96 /**
       
    97 Constructor.
       
    98 */
       
    99 CIrlanPktDrv::CIrlanPktDrv(CPktDrvFactory& aFactory) : CPktDrvBase(aFactory)
       
   100 {
       
   101 #ifdef __TRACEWIN__
       
   102 	LOG(Log::Printf(_L("IRLAN	CIrlanPktDrv constructor\r\n")));
       
   103 #endif
       
   104 	__DECLARE_NAME(_S("CIrlanPktDrv"));
       
   105 }
       
   106 
       
   107 /**
       
   108 Destructor.
       
   109 */
       
   110 CIrlanPktDrv::~CIrlanPktDrv()
       
   111 {
       
   112 #ifdef __TRACEWIN__
       
   113 	LOG(Log::Printf(_L("IRLAN	~CIrlanPktDrv\r\n")));
       
   114 #endif
       
   115 	delete iControl;
       
   116 }
       
   117 
       
   118 /**
       
   119 Find and load protocol
       
   120 Pure Virtual Construction of the CPktDrvBase object.
       
   121 @param aParent Pointer to the CLANLinkCommon class.
       
   122 @bug unhandled error codes
       
   123 */
       
   124 void CIrlanPktDrv::ConstructL(CLANLinkCommon* aParent)
       
   125 {
       
   126 #ifdef __TRACEWIN__
       
   127 	LOG(Log::Printf(_L("IRLAN	CIrlanPktDrv::ConstructL\r\n")));
       
   128 #endif
       
   129 	TInt ret;
       
   130 	iParent=aParent;
       
   131 	// Creating the Irlan state machine
       
   132 	TRAP(ret,iControl=CIrlanControlEngine::NewL(this));
       
   133 	// Now kick off the Irlan state machine active object
       
   134   	TRAP(ret,iControl->StartL());
       
   135 }
       
   136 
       
   137 /**
       
   138 Downstack - Supplies the caller with information on the NIF written to the TNifIfInfo class 
       
   139 defined in nifman.h.
       
   140 @param aInfo  Class for returning information on the NIF
       
   141 @param aIndex PPP Specific
       
   142 */
       
   143 TInt CIrlanPktDrv::Info(TNifIfInfo& /*aInfo*/, TInt /*aIndex*/) const
       
   144 {
       
   145 	return KErrNone;
       
   146 }
       
   147 
       
   148 /**
       
   149 This method is only for use when an interface does not have the correct MAC address when ARP 
       
   150 is started
       
   151 */
       
   152 void CIrlanPktDrv::FoundMACAddr()
       
   153 {
       
   154 	TRAPD(ret,iParent->FoundMACAddrL());
       
   155 	if (KErrNone != ret)
       
   156 		{
       
   157 #ifdef __TRACEWIN__
       
   158 		LOG(Log::Printf(_L("IRLAN	CIrlanPktDrv::FoundMACAddrL Failure: %d\r\n"),ret));
       
   159 #endif		
       
   160 		}
       
   161 }
       
   162 
       
   163 
       
   164 /**
       
   165 Called after we have managed to get a reply to GetFilterConfigCmd
       
   166 */
       
   167 void CIrlanPktDrv::LinkLayerUp()
       
   168 {
       
   169 #ifdef __TRACEWIN__
       
   170 	LOG(Log::Printf(_L("IRLAN	CIrlanPktDrv::LinkLayerUp!\r\n")));
       
   171 #endif
       
   172 	iParent->LinkLayerUp();
       
   173 }
       
   174 
       
   175 
       
   176 /**
       
   177 This is where we would send out the first ethernet packets.
       
   178 @return KErrNone		 if Successful 
       
   179 		KErrNotSupported LAN Device does not support.
       
   180 		Implementation specific Error Code  Failure
       
   181 */
       
   182 TInt CIrlanPktDrv::StartInterface()
       
   183 {
       
   184 #ifdef __TRACEWIN__
       
   185 	LOG(Log::Printf(_L("IRLAN	PKTDRV:StartInterface\r\n")));
       
   186 #endif
       
   187 	return KErrNone;
       
   188 }
       
   189 
       
   190 /**
       
   191 Call to LDD or subordinate object to stop/de-initialise the Physical device
       
   192 @return KErrNone		 if Successful 
       
   193 		KErrNotSupported LAN Device does not support.
       
   194 		Implementation specific Error Code  Failure
       
   195 */
       
   196 TInt CIrlanPktDrv::StopInterface()
       
   197 {
       
   198 #ifdef __TRACEWIN__
       
   199 	LOG(Log::Printf(_L("IRLAN	PKTDRV:StopInterface\r\n")));
       
   200 #endif
       
   201 
       
   202 	return KErrNone;
       
   203 }
       
   204 
       
   205 /**
       
   206 Call to LDD or subordinate object to reset/re-initialise the Physical device
       
   207 @return KErrNone		 if Successful 
       
   208 		KErrNotSupported LAN Device does not support.
       
   209 		Implementation specific Error Code  Failure
       
   210 */
       
   211 TInt CIrlanPktDrv::ResetInterface()
       
   212 {
       
   213 #ifdef __TRACEWIN__
       
   214 	LOG(Log::Printf(_L("IRLAN	PKTDRV:ResetInterface\r\n")));
       
   215 #endif
       
   216 	return KErrNone;
       
   217 }
       
   218 
       
   219 
       
   220 /**
       
   221 Tx flow control stuff
       
   222 Sender Class is generic and does not want to know about RMBuf's
       
   223 Copy to a Heap Buffer and Free the packet. EtherII MAC layer comments
       
   224 Say we should free the packet buffer
       
   225 RMBuf could contain a chain so get into a contiguous buffer
       
   226 @param aPacket Reference to a chain of data buffers to be passed to the line.
       
   227 @return 0 Tells the higher layer to send no more data.
       
   228 		1 Tells higher layer that it can send more data.
       
   229 */
       
   230 TInt CIrlanPktDrv::Send(RMBufChain &aPacket)
       
   231 {
       
   232 	TInt ret = KErrNone;
       
   233 	TRAPD(err,ret = iControl->Send(aPacket));
       
   234 	if(err != KErrNone)
       
   235 		{
       
   236 		ret = err;
       
   237 		}
       
   238 	return ret;
       
   239 }
       
   240 
       
   241 /**
       
   242 Here what the pkt drv must do is go thro' it's list of MAC layers and
       
   243 keep trying to process until it gets back a KErrNone.
       
   244 @param aPdu A reference to the Packet to process.
       
   245 */
       
   246 void CIrlanPktDrv::Process(RMBufChain& aPdu)
       
   247 {
       
   248 	iParent->Process(aPdu);
       
   249 }
       
   250 
       
   251 /**
       
   252 Call to LDD or subordinate object to set the receive mode of the LAN Device
       
   253 @param aMode The mode to be set for the LAN Device.			
       
   254 @return KErrNotSupported LAN Device does not support.
       
   255 */
       
   256 TInt CIrlanPktDrv::SetRxMode(TRxMode /*AMode*/)
       
   257 {
       
   258 	return KErrNotSupported;
       
   259 }
       
   260 
       
   261 /**
       
   262 Call to LDD or subordinate object to Get the receive mode of the LAN Device
       
   263 @return KErrNotSupported LAN Device does not support.
       
   264 */
       
   265 TInt CIrlanPktDrv::GetRxMode() const
       
   266 {
       
   267 	return KErrNotSupported;
       
   268 }
       
   269 
       
   270 /**
       
   271 Specifies the AccessType.
       
   272 @return KErrNotSupported LAN Device does not support.
       
   273 */
       
   274 TInt CIrlanPktDrv::AccessType()
       
   275 {
       
   276 	return KErrNotSupported;
       
   277 }
       
   278 
       
   279 /**
       
   280 Specifies the ReleaseType.
       
   281 @return KErrNotSupported LAN Device does not support.
       
   282 */
       
   283 TInt CIrlanPktDrv::ReleaseType()
       
   284 {
       
   285 	return KErrNotSupported;
       
   286 }
       
   287 
       
   288 /**
       
   289 Call to LDD or subordinate object to get the Hardware address of the LAN Device
       
   290 @return NULL Failure.
       
   291 		(NULL Terminated Binary String) The Hardware Address of the interface. LAN Device 
       
   292 		Specific
       
   293 */
       
   294 TUint8* CIrlanPktDrv::GetInterfaceAddress()const
       
   295 {
       
   296 	return (iControl->GetInterfaceAddress());
       
   297 }
       
   298 
       
   299 /**
       
   300 Call to LDD or subordinate object to set the Hardware address of the LAN Device.
       
   301 @param THWAddr Address of where the Multicast list should be written.
       
   302 @return KErrNone		 if Successful 
       
   303 		KErrNotSupported LAN Device does not support.
       
   304 		Implementation specific Error Code  Failure
       
   305 */
       
   306 TInt CIrlanPktDrv::SetInterfaceAddress(const THWAddr&)
       
   307 {
       
   308 	return KErrNotSupported;
       
   309 }
       
   310 
       
   311 /**
       
   312 This corresponds to getting the relevant values from IrLAN data model
       
   313 @param aAddr Address of where the Multicast list should be written.
       
   314 @param n Output Parameter , number of Addresses written
       
   315 @return KErrNone		 if Successful 
       
   316 		KErrNotSupported LAN Device does not support.
       
   317 		Implementation specific Error Code  Failure
       
   318 */
       
   319 TInt CIrlanPktDrv::GetMulticastList(const THWAddr* /*aAddr*/, TInt& /*n*/) const
       
   320 {
       
   321 	return KErrNotSupported;
       
   322 }
       
   323 
       
   324 /**
       
   325 This corresponds to setting the relevant values from IrLAN data model
       
   326 @param aAddr Address of where the Multicast list should be written.
       
   327 @param n Output Parameter , number of Addresses written
       
   328 @return KErrNone		 if Successful 
       
   329 		KErrNotSupported LAN Device does not support.
       
   330 		Implementation specific Error Code  Failure
       
   331 */
       
   332 TInt CIrlanPktDrv::SetMulticastList(const THWAddr* /*aAddr*/, TInt /*n*/)
       
   333 {
       
   334 	return KErrNotSupported;
       
   335 }
       
   336 
       
   337 /**
       
   338 Call to LDD or subordinate object to power up the LAN Device.
       
   339 @return KErrNone		 if Successful 
       
   340 		KErrNotSupported LAN Device does not support.
       
   341 		Implementation specific Error Code  Failure
       
   342 */
       
   343 TInt CIrlanPktDrv::InterfacePowerUp()
       
   344 {
       
   345 	return KErrNotSupported;
       
   346 }
       
   347 
       
   348 /**
       
   349 Call to LDD or subordinate object to power down the LAN Device
       
   350 @return KErrNone		 if Successful 
       
   351 		KErrNotSupported LAN Device does not support.
       
   352 		Implementation specific Error Code  Failure
       
   353 */
       
   354 TInt CIrlanPktDrv::InterfacePowerDown()
       
   355 {
       
   356 	return KErrNotSupported;
       
   357 }
       
   358 
       
   359 /**
       
   360 Call to LDD or subordinate object to suspend the LAN Device.
       
   361 @return KErrNone		 if Successful 
       
   362 		KErrNotSupported LAN Device does not support.
       
   363 		Implementation specific Error Code  Failure
       
   364 */
       
   365 TInt CIrlanPktDrv::InterfaceSleep()
       
   366 {
       
   367 	return KErrNotSupported;
       
   368 }
       
   369 
       
   370 /**
       
   371 Call to LDD or subordinate object to resume the LAN Device.
       
   372 @return KErrNone		 if Successful 
       
   373 		KErrNotSupported LAN Device does not support.
       
   374 		Implementation specific Error Code  Failure
       
   375 */
       
   376 TInt CIrlanPktDrv::InterfaceResume()
       
   377 {
       
   378 	return KErrNotSupported;
       
   379 }
       
   380 
       
   381 /**
       
   382 Receive notifications from agent
       
   383 */
       
   384 TInt CIrlanPktDrv::Notification(enum TAgentToNifEventType /*aEvent*/, void* /*aInfo*/)
       
   385 {
       
   386 	return KErrNotSupported;	
       
   387 }
       
   388 	
       
   389 /**
       
   390 Receive Control() calls from agent/nifman/connection
       
   391 */
       
   392 TInt CIrlanPktDrv::Control(TUint /*aLevel*/,TUint /*aName*/,TDes8& /*aOption*/, TAny* /*aSource*/)
       
   393 {
       
   394 	return KErrNotSupported;	
       
   395 }