dispatcher.h

Go to the documentation of this file.
00001 /*##############################################################################
00002 
00003 nIP - nano IP stack
00004 
00005 File        : dispatcher.h
00006 
00007 Description : Internetstack State Machine
00008 
00009 Copyright notice:
00010 
00011 Copyright (C) 2005 -
00012 Andreas Dittrich, dittrich@informatik.hu-berlin.de
00013 Jon Kowal, kowal@informatik.hu-berlin.de
00014 
00015 This program is free software; you can redistribute it and/or
00016 modify it under the terms of the GNU General Public License
00017 as published by the Free Software Foundation; either version 2
00018 of the License, or (at your option) any later version.
00019 
00020 This program is distributed in the hope that it will be useful,
00021 but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00023 GNU General Public License for more details.
00024 
00025 You should have received a copy of the GNU General Public License
00026 along with this program; if not, write to the Free Software
00027 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00028 
00029 ##############################################################################*/
00030 
00031 #ifndef _NIP_DISPATCHER_H
00032 #define _NIP_DISPATCHER_H
00033 
00034 #include "net/ip.h"
00035 #include "net/net_if.h"
00036 #include "net/tcp.h"
00037 
00038 /** Commands to be executed by the dispatcher.
00039  * @note this list is currently not in use but may replace the func-pointer
00040  * in the nip_disp_params_t choice at some time in future. */
00041 typedef enum
00042 {
00043         NIP_DC_NONE,     /** command to indicate empty unused structure */
00044         NIP_DC_IP_SEND,
00045         NIP_DC_TCP_SEND, /** */
00046         NIP_DC_HARD_RECV,
00047         NIP_DC_IP_RECV,
00048         NIP_DC_ARP_RECV,
00049         NIP_DC_ICMP_RECV,
00050         NIP_DC_TCP_RECV,
00051         NIP_DC_CUSTOM    /** custom command */
00052 }
00053 #ifndef DOXYGEN
00054 __attribute__((packed))
00055 #endif
00056 nip_disp_cmd_t;
00057 
00058 /** @name Dispatcher status flags*/
00059 //@{
00060 #define NIP_DISP_RUNNING     0x01 /**< Dispatcher is running. Do not allow another instance. */
00061 #define NIP_DISP_CHECK_IF    0x02 /**< Some network interface flag changed */
00062 #define NIP_DISP_CHECK_UDP   0x04 /**< Check UDP sockets */
00063 #define NIP_DISP_CHECK_TCP   0x08 /**< TCP connections need to be checked. */
00064 #define NIP_DISP_TIMER       0x10 /**< Check stack timer */
00065 #define NIP_DISP_CHECK_TRANS 0x20 /**< check transmissions. same as timer, currently*/
00066 #define NIP_DISP_CHECK_MDNS  0x40 /**< perform mDNS checks */
00067 //@}
00068 
00069 /** @name Dispatcher network interface event flags */
00070 //@{
00071 #define NIP_DISP_IF_ETH_R  0x01 /**< Missed Eth Receive Call because Dispatcher was busy. */
00072 // #define NIP_DISP_IF_IP     0x02 /**< IP transmission is waiting for ARP response. */
00073 #define NIP_DISP_IF_TIMER  0x04 /**< check interface timers. */
00074 #define NIP_DISP_IF_DHCP   0x08 /**< check DHCP status for interface, currently same as timer */
00075 #define NIP_DISP_IF_AUTOIP 0x10 /**< check autoIP implementation */
00076 #define NIP_DISP_IF_GROUP  0x20 /**< check host group memberships */
00077 //@}
00078 /** Dispatcher Command Parameters
00079  *      @todo switch from function pointers to the above nip_disp_cmd_t and have
00080  *            one global table to be set up in nip_init() which resolves commands
00081  *            to functions. Benefit: Protocolls are easy exchangable, even IP.
00082  **/
00083 typedef union
00084 {
00085         struct
00086         {
00087                 void               (*func)(void); /**< pointer to custom function */
00088                 nip_net_if_id_t    net_if_id;     /**< Network Interface. */
00089                 nip_net_if_trans_t *trans;        /**< pointer to current transmission */
00090                 uint8_t remote_hw_addr[ NIP_MAX_HW_ADDR_SIZE  ]; /**< remote hardware address */
00091         }
00092         #ifndef DOXYGEN
00093         __attribute__((packed))
00094         #endif
00095         common; /**< parameter included in all calls. */
00096 
00097         struct
00098         {
00099                 // --- union head --
00100                 void               (*func)(void); /**< pointer to custom function */
00101                 nip_net_if_id_t    net_if_id;     /**< Network Interface. */
00102                 nip_net_if_trans_t *trans;        /**< pointer to current transmission */
00103                 uint8_t remote_hw_addr[ NIP_MAX_HW_ADDR_SIZE  ]; /**< remote hardware address */
00104                 // ---
00105 
00106                 nip_tcp_sock_id_t  sockid;
00107                 uint8_t            flags;
00108 //              uint8_t  local_nw_addr[ NIP_MAX_NET_ADDR_SIZE ]; /**< target network address */
00109         }
00110         #ifndef DOXYGEN
00111         __attribute__((packed))
00112         #endif
00113         tcp;
00114 
00115 }
00116 #ifndef DOXYGEN
00117 __attribute__((packed))
00118 #endif
00119 nip_disp_params_t;
00120 
00121 /** Information needed to manage the dispatcher state machine. */
00122 typedef struct
00123 {
00124         nip_disp_params_t next; /**< Next Dispatcher Call */
00125         uint8_t           flags;/**< Dispatcher flags. */
00126         uint8_t           if_flags[ NIP_NET_IF_COUNT ]; /** Interface flags */
00127 
00128 }
00129 #ifndef DOXYGEN
00130 __attribute__((packed))
00131 #endif
00132 nip_disp_state_t;
00133 
00134 /** @name Macros for easier access to dispatcher variables */
00135 //@{
00136 #define NIP_CURR_CMD nip_disp.next.common.func
00137 
00138 #if NIP_NET_IF_COUNT > 1
00139         #define NIP_CURR_IF     nip_disp.next.common.net_if_id
00140         #define SET_CURR_IF(id) nip_disp.next.common.net_if_id = id;
00141 #else
00142         #define NIP_CURR_IF 0
00143         #define SET_CURR_IF(id)
00144 #endif
00145 
00146 //@}
00147 
00148 extern nip_disp_state_t nip_disp;
00149 
00150 #define nip_disp_notify( events ) nip_disp.flags |= events
00151 void nip_disp_notify_if( nip_net_if_id_t net_if_id, uint8_t event );
00152 // void nip_disp_notify( uint8_t flags );
00153 nip_error_t nip_dispatcher( void );
00154 
00155 #endif /* _NIP_DISPATCHER_H */

Generated on Thu Jul 10 01:09:29 2008 for NIP by  doxygen 1.5.5