Subversion Repositories HomeAutomation

Rev

Rev 363 | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. /*********************************************************************
  2.  *
  3.  *                  DHCP Defs for Microchip TCP/IP Stack
  4.  *
  5.  *********************************************************************
  6.  * FileName:        DHCP.h
  7.  * Dependencies:    StackTsk.h
  8.  *                  UDP.h
  9.  * Processor:       PIC18, PIC24F, PIC24H, dsPIC30F, dsPIC33F
  10.  * Complier:        Microchip C18 v3.02 or higher
  11.  *                  Microchip C30 v2.01 or higher
  12.  * Company:         Microchip Technology, Inc.
  13.  *
  14.  * Software License Agreement
  15.  *
  16.  * This software is owned by Microchip Technology Inc. ("Microchip")
  17.  * and is supplied to you for use exclusively as described in the
  18.  * associated software agreement.  This software is protected by
  19.  * software and other intellectual property laws.  Any use in
  20.  * violation of the software license may subject the user to criminal
  21.  * sanctions as well as civil liability.  Copyright 2006 Microchip
  22.  * Technology Inc.  All rights reserved.
  23.  *
  24.  * This software is provided "AS IS."  MICROCHIP DISCLAIMS ALL
  25.  * WARRANTIES, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, NOT LIMITED
  26.  * TO MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
  27.  * INFRINGEMENT.  Microchip shall in no event be liable for special,
  28.  * incidental, or consequential damages.
  29.  *
  30.  *
  31.  * Author               Date    Comment
  32.  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  33.  * Nilesh Rajbharti     3/21/01  Original        (Rev 1.0)
  34.  ********************************************************************/
  35. #ifndef DHCP_H
  36. #define DHCP_H
  37.  
  38. #include "..\Include\StackTsk.h"
  39.  
  40.  
  41. typedef enum _SM_DHCP
  42. {
  43.     SM_DHCP_INIT_FIRST_TIME,
  44.     SM_DHCP_INIT,
  45.     SM_DHCP_RESET_WAIT,
  46.     SM_DHCP_BROADCAST,
  47.     SM_DHCP_DISCOVER,
  48.     SM_DHCP_REQUEST,
  49.     SM_DHCP_BIND,
  50.     SM_DHCP_BOUND,
  51.     SM_DHCP_DISABLED,
  52. } SM_DHCP;
  53.  
  54. #if !defined(THIS_IS_DHCP)
  55.     extern SM_DHCP smDHCPState;
  56. #endif
  57.  
  58. /*********************************************************************
  59.  * Macro:           void DHCPDisable(void)
  60.  *
  61.  * PreCondition:    None
  62.  *
  63.  * Input:           None
  64.  *
  65.  * Output:          None
  66.  *
  67.  * Side Effects:    None
  68.  *
  69.  * Overview:        Puts DHCPTask into unhandled state "SM_DHCP_DISABLED"
  70.  *                  and hence DHCP is effictively disabled.
  71.  *
  72.  * Note:            This macro should be called before DHCPTask is called
  73.  *                  or else a UDP port will be kept open and there will
  74.  *                  be no task to process it.
  75.  ********************************************************************/
  76. #define DHCPDisable()       (smDHCPState = SM_DHCP_DISABLED)
  77.  
  78.  
  79. /*********************************************************************
  80.  * Function:        void DHCPTask(void)
  81.  *
  82.  * PreCondition:    DHCPInit() is already called AND
  83.  *                  IPGetHeader() is called with
  84.  *                  IPFrameType == IP_PROT_UDP
  85.  *
  86.  * Input:           None
  87.  *
  88.  * Output:          None
  89.  *
  90.  * Side Effects:    None
  91.  *
  92.  * Overview:        Fetches pending UDP packet from MAC receive buffer
  93.  *                  and dispatches it appropriate UDP socket.
  94.  *                  If not UDP socket is matched, UDP packet is
  95.  *                  silently discarded.
  96.  *
  97.  * Note:            Caller must make sure that MAC receive buffer
  98.  *                  access pointer is set to begining of UDP packet.
  99.  *                  Required steps before calling this function is:
  100.  *
  101.  *                  If ( MACIsRxReady() )
  102.  *                  {
  103.  *                      MACGetHeader()
  104.  *                      If MACFrameType == IP
  105.  *                          IPGetHeader()
  106.  *                          if ( IPFrameType == IP_PROT_UDP )
  107.  *                              Call DHCPTask()
  108.  *                  ...
  109.  ********************************************************************/
  110. void DHCPTask(void);
  111.  
  112.  
  113. /*********************************************************************
  114.  * Macro:           BOOL DHCPIsBound(void)
  115.  *
  116.  * PreCondition:    None
  117.  *
  118.  * Input:           None
  119.  *
  120.  * Output:          TRUE if DHCP is bound to given configuration
  121.  *                  FALSE if DHCP has yet to be bound.
  122.  *
  123.  * Side Effects:    None
  124.  *
  125.  * Overview:        None
  126.  *
  127.  * Note:
  128.  ********************************************************************/
  129. #define DHCPIsBound()       (DHCPState.bits.bIsBound)
  130.  
  131. typedef union _DHCP_STATE
  132. {
  133.     struct
  134.     {
  135.         unsigned char bIsBound : 1;
  136.         unsigned char bOfferReceived : 1;
  137.     } bits;
  138.     BYTE Val;
  139. } DHCP_STATE;
  140.  
  141. #if !defined(THIS_IS_DHCP)
  142.     extern DHCP_STATE DHCPState;
  143. #endif
  144.  
  145. /*********************************************************************
  146.  * Macro:           void DHCPReset(void)
  147.  *
  148.  * PreCondition:    None
  149.  *
  150.  * Input:           None
  151.  *
  152.  * Output:          None
  153.  *
  154.  * Side Effects:    None
  155.  *
  156.  * Overview:        Closes any previously opened DHCP socket
  157.  *                  and resets DHCP state machine so that on next
  158.  *                  call to DHCPTask will result in new DHCP request.
  159.  *
  160.  * Note:            None
  161.  ********************************************************************/
  162. void DHCPReset(void);
  163.  
  164.  
  165.  
  166.  
  167. #endif
  168.