00001 // //////////////////////////////////////////////////////////////////////////// 00002 // //////////////////////////////////////////////////////////////////////////// 00026 /********************************************************************* 00027 * Software License Agreement 00028 * 00029 * Copyright (C) 2002-2008 Microchip Technology Inc. All rights 00030 * reserved. 00031 * 00032 * Microchip licenses to you the right to use, modify, copy, and 00033 * distribute: 00034 * (i) the Software when embedded on a Microchip microcontroller or 00035 * digital signal controller product ("Device") which is 00036 * integrated into Licensee's product; or 00037 * (ii) ONLY the Software driver source files ENC28J60.c and 00038 * ENC28J60.h ported to a non-Microchip device used in 00039 * conjunction with a Microchip ethernet controller for the 00040 * sole purpose of interfacing with the ethernet controller. 00041 * 00042 * You should refer to the license agreement accompanying this 00043 * Software for additional information regarding your rights and 00044 * obligations. 00045 * 00046 * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT 00047 * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT 00048 * LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A 00049 * PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL 00050 * MICROCHIP BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR 00051 * CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF 00052 * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS 00053 * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE 00054 * THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER 00055 * SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT 00056 * (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE. 00057 * 00058 * 00059 * Author Date Comment 00060 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00061 * Howard Schlunder 02/22/07 Original 00062 ********************************************************************/ 00063 #define __REBOOT_C 00064 00065 #include "TCPIP.h" 00066 00067 #define REBOOT_PORT 69 // UDP TFTP port 00068 00069 00070 // For improved security, you might want to limit reboot capabilities 00071 // to only users on the same IP subnet. Define REBOOT_SAME_SUBNET_ONLY 00072 // to enable this access restriction. 00073 #define REBOOT_SAME_SUBNET_ONLY 00074 00075 00076 /********************************************************************* 00077 * Function: void RebootTask(void) 00078 * 00079 * PreCondition: Stack is initialized() 00080 * 00081 * Input: None 00082 * 00083 * Output: None 00084 * 00085 * Side Effects: None 00086 * 00087 * Overview: Checks for incomming traffic on port 69. 00088 * 00089 * Note: This module is primarily for use with the 00090 * Ethernet bootloader. By resetting, the Ethernet 00091 * bootloader can take control for a second and let 00092 * a firmware upgrade take place. 00093 ********************************************************************/ 00094 void RebootTask(void) 00095 { 00096 static UDP_SOCKET MySocket = INVALID_UDP_SOCKET; 00097 00098 if(MySocket == INVALID_UDP_SOCKET) 00099 MySocket = UDPOpen(REBOOT_PORT, NULL, INVALID_UDP_PORT); 00100 00101 if(MySocket == INVALID_UDP_SOCKET) 00102 return; 00103 00104 // Do nothing if no data is waiting 00105 if(!UDPIsGetReady(MySocket)) 00106 { 00107 return; 00108 } 00109 00110 u16GlobalFlags |= BOOTLOADER_MASK; 00111 ApplRestart(FALSE); 00112 }
1.5.5