middleware/netware/etherneticmp.c File Reference

Go to the source code of this file.

Functions

void F_EthernetIcmpInit (void)
void F_EthernetIcmpSvc (void)
INT8U F_EthernetIcmpEchoSend (ETHBUFFER *pBuffer)
INT8U F_EthernetIcmpEchoReceive (ETHBUFFER *pBuffer)
INT8U F_EthernetIcmpPacketReceive (ETHBUFFER *pBuffer)

Variables

ICMP_CONTROL IcmpCtrl


Function Documentation

INT8U F_EthernetIcmpEchoReceive ( ETHBUFFER *  pBuffer  ) 

Definition at line 58 of file etherneticmp.c.

00058                                                    {
00059     memcpy(IcmpCtrl.ClientIp,F_EthernetIpSourceIpGet(pBuffer),ETHERNET_IP_LENGTH);
00060     F_EthernetIcmpEchoSend(pBuffer);
00061     return TRUE;
00062 }

INT8U F_EthernetIcmpEchoSend ( ETHBUFFER *  pBuffer  ) 

Definition at line 29 of file etherneticmp.c.

00029                                                 {
00030     ICMP_HEAD *pIcmpHead,*pIcmpEcho;
00031     INT32U Temp,Sum,Counter,i;
00032         
00033     Counter=pBuffer->Length; // keep icmp packet data length in Counter
00034     if(Counter%2) Counter++; // ?? Counter must be a even number
00035     #if(DEBUG_ETHERNET_ICMP==1)
00036         printf(" echo length %4x",Counter);
00037     #endif
00038     pIcmpHead=(ICMP_HEAD *)pBuffer->pData;
00039     pBuffer=F_EthernetBufferAllocate();
00040     F_EthernetIpBufferReserve(pBuffer); // reserve IP_HEAD space 
00041     pIcmpEcho=(ICMP_HEAD *)F_EthernetBufferPut(pBuffer,Counter);    
00042     pIcmpEcho->Type=0;
00043     pIcmpEcho->Code=0;
00044     Sum=0;
00045     for(i=2;i<(Counter/2);i++){
00046         Temp=*((INT16U *)(&pIcmpHead->Type)+i);
00047         *((INT16U *)(&pIcmpEcho->Type)+i)=Temp;
00048         Sum+=Temp;
00049     }
00050     i=Sum>>16;
00051     pIcmpEcho->Check=0x0000ffff-(Sum&0x0000ffff)-i;
00052     #if(DEBUG_ETHERNET_ICMP==1)
00053         printf(" length2 %4x",pBuffer->Length);
00054     #endif
00055     F_EthernetIpSend(pBuffer,IcmpCtrl.ClientIp,ICMP);
00056     return TRUE;
00057 }

void F_EthernetIcmpInit ( void   ) 

Definition at line 20 of file etherneticmp.c.

00020                              {
00021     IcmpCtrl.ClientIp[0]=0;    
00022     IcmpCtrl.ClientIp[1]=0;    
00023     IcmpCtrl.ClientIp[2]=0;    
00024     IcmpCtrl.ClientIp[3]=0;   
00025     IcmpCtrl.Status=0;
00026     IcmpCtrl.State=EthernetIcmpIdleState; 
00027 }

INT8U F_EthernetIcmpPacketReceive ( ETHBUFFER *  pBuffer  ) 

Definition at line 63 of file etherneticmp.c.

00063                                                      {
00064     ICMP_HEAD *pIcmpHead=(ICMP_HEAD *)pBuffer->pData;
00065     
00066     #if(DEBUG_ETHERNET_ICMP==1)
00067         printf("\n ICMP rx");
00068     #endif
00069     switch(pIcmpHead->Type){
00070         case 8:
00071             F_EthernetIcmpEchoReceive(pBuffer);    
00072     }
00073     return TRUE;
00074 }

void F_EthernetIcmpSvc ( void   ) 

Definition at line 28 of file etherneticmp.c.

00028 {}


Variable Documentation

ICMP_CONTROL IcmpCtrl

Definition at line 13 of file etherneticmp.c.


Generated on Tue Sep 2 08:45:41 2008 for A Simple operation System using S3C2410 by  doxygen 1.5.6