00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 
00044 #ifndef FIP_SIXLOWPAN_H_
00045 #define FIP_SIXLOWPAN_H_
00046 
00047 
00048 
00049 
00050 typedef enum
00051 {
00052     SL_UNKNOWN = 0,                         
00053     SL_DONE,
00054     SL_TXINPROCESS,
00055     SL_RXINPROCESS,                         
00056     SL_FRAG1,
00057     SL_FRAGN,
00058 } fip_sixlowpan_state_t;
00059 
00060 
00061 typedef struct
00062 {
00063     uint16_t                datagramTag;    
00064     uint16_t                datagramSize;   
00065     uint8_t                 datagramOffset; 
00066     fip_sixlowpan_state_t   state;          
00067     unsigned char           maxSize;        
00068     unsigned int            paddingPresent; 
00069     uint32_t                expireTime32mS; 
00070 }fip_sixlowpan_attr_t;
00071 
00072 _PACKSTART
00073 typedef struct
00074 {
00075     uint16_t    dispatchSize;               
00076     uint16_t    tag;                        
00077 } _PS fip_sixlowpan_frag1_t;
00078 _PACKEND
00079 
00080 _PACKSTART
00081 typedef struct
00082 {
00083     uint16_t    dispatchSize;               
00084     uint16_t    tag;                        
00085     uint8_t     offset;                     
00086 } _PS fip_sixlowpan_fragn_t;
00087 _PACKEND
00088 
00089 
00090 typedef enum
00091 {
00092     CONTEXT_UNUSED = 0,             
00093     CONTEXT_COMPRESS_DECOMPRESS,    
00094     CONTEXT_DECOMPRESSONLY,         
00095 } fip_sixlowpan_contextState_t;
00096 
00097 typedef struct
00098 {
00099     fip_sixlowpan_contextState_t    state;
00100     uint8_t                         length;
00101     uint8_t                         context[16];
00102     uint32_t                        expireTime32S;
00103 } fip_sixlowpan_context_t;
00104 
00105 
00106 
00107 #define FIP_6LP_MAX_CONTEXTS 16
00108 
00109 
00110 
00111 
00112 #define fip_sixlowpan_Attr(type)            (fip_packet_spGetPtr(fip_sixlowpan_attr_t)->type)
00113 
00114 
00115 unsigned int fip_sixlowpanhc_compress(uint8_t * srcAddr,
00116                                       unsigned char srcLength,
00117                                       uint8_t * destAddr,
00118                                       unsigned char destLength);
00119 
00120 unsigned char fip_sixlowpanhc_uncompress(uint8_t * srcAddr,
00121                                          unsigned char srcLength,
00122                                          uint8_t * destAddr,
00123                                          unsigned char destLength,
00124                                          uint8_t * payload,
00125                                          unsigned char payloadLen,
00126                                          uint16_t  totalLen);
00127 
00128 
00129 
00130 extern fip_sixlowpan_context_t fip_6lowpan_contextList[FIP_6LP_MAX_CONTEXTS];
00131 #define fip_sixlowpan_getContextAttr(CID, attr) fip_6lowpan_contextList[CID].attr
00132 unsigned char fip_sixlowpan_copyContext(uint8_t * dest, unsigned char minLength, uint8_t CID);
00133 void fip_sixlowpan_addUpdateContext(const uint8_t * context, unsigned char length,
00134                                     uint16_t  lifetime, uint8_t CID, unsigned char validCompression);
00135 #define fip_sixlowpan_lookupContext(address) \
00136         fip_ds6_searchList( (unsigned char *)fip_6lowpan_contextList, \
00137                              \
00138                             sizeof(fip_sixlowpan_context_t), \
00139                             FIP_6LP_MAX_CONTEXTS, \
00140                              \
00141                             offsetof(fip_sixlowpan_context_t, context), \
00142                              \
00143                             address, 8)
00144 
00145 
00146 
00147 void fip_sixlowpan_process(void);
00148 fip_return_t fip_sixlowpan_llInput(uint8_t * srcAddr, unsigned char srcAddrLen,
00149                                    uint8_t * destAddr, unsigned char destAddrLen,
00150                                    uint8_t * payloadPtr, unsigned char payloadLen);
00151 
00152 
00153 
00154 
00155 
00156 
00157 
00158 
00159 
00160 
00161 
00162 
00163 
00164 
00165 
00166 
00167 unsigned char fip_hostInterface_sixGetPayLoadLength(unsigned char destLen, unsigned char srcLen);
00168 
00169 
00170 
00171 
00172 
00173 
00174 
00175 
00176 
00177 
00178 
00179 unsigned char fip_hostInterface_sixSendSetup(uint8_t * srcAddr, unsigned char srcLen,
00180                                              uint8_t * destAddr, unsigned char destLen,
00181                                              fip_bool_t isDestBroadcast);
00182 
00183 
00184 
00185 
00186 
00187 
00188 
00189 
00190 void fip_hostInterface_sixSendCopyPayload(uint8_t * data, unsigned char dataLen);
00191 
00192 
00193 
00194 
00195 void fip_hostInterface_sixSendFinish(void);
00196 
00197 
00198 void fip_nd6_6lowpan_periodicUnicast(fip_ifnum_t ifnum, unsigned char indexToUnicast);
00199 
00200 _PACKSTART
00201 typedef struct
00202 {
00203     uint8_t     type;               
00204     uint8_t     code;               
00205     uint16_t    checksum;           
00206     uint8_t     status;             
00207     uint8_t     reserved;           
00208     uint16_t    lifetime;           
00209     uint8_t     eui64[8];           
00210     uint8_t     raddr[16];          
00211 } _PS fip_nd6_6lowpan_da_t;
00212 _PACKEND
00213 
00214 typedef enum
00215 {
00216     FIP_ND6_6LP_HOST,
00217     FIP_ND6_6LP_ROUTER,
00218     FIP_ND6_6LP_BORDERROUTER,
00219 } fip_nd6_6lowpan_mode_t;
00220 
00221 typedef struct
00222 {
00223     uint8_t                 shortMatch: 1;  
00224     uint8_t                 euiMatch:  1;   
00225     unsigned char           index;          
00226 }fip_nd6_6lowpan_return_t;
00227 
00228 unsigned int fip_nd6_6lowpan_addRAOptions(unsigned int upperLength);
00229 fip_nd6_6lowpan_return_t fip_nd6_6lowpan_LBRTableSearch(const uint8_t * shortAddr, const uint8_t * eui64);
00230 void fip_nd6_6lowpan_LBRTableUpdateEntry(const uint8_t * shortAddr, uint16_t lifetime, unsigned char index);
00231 fip_return_t fip_nd6_6lowpan_LBRTableNewEntry(const uint8_t * shortAddr, const uint8_t * eui64, uint16_t lifetime);
00232 void fip_nd6_6lowpan_setMode(fip_nd6_6lowpan_mode_t mode);
00233 fip_nd6_6lowpan_mode_t fip_nd6_6lowpan_getMode(void);
00234 void fip_nd6_6lowpan_setABR(const fip_ip6addr_t * addr, uint16_t version);
00235 
00236 #include "fip_nd6_ds6.h"
00237 
00238 fip_nd6_searchStatus_t fip_nd6_6lowpan_neighbourCacheLookupByIp(const fip_ip6addr_t * ipaddr);
00239 void fip_nd6_6lowpan_LBRTableGetShort(uint8_t * shortAddr, unsigned char index);
00240 
00241 void fip_nd6_6lowpan_processNS(const fip_nd6_optionStruct_t * optionStruct);
00242 void fip_nd6_6lowpan_processNA(const fip_nd6_optionStruct_t * optionStruct);
00243 
00244 void fip_nd6_6lowpan_daGenerate(uint8_t type,
00245                                 uint8_t status,
00246                                 uint16_t lifetime,
00247                                 uint8_t * eui64,
00248                                 uint8_t * raddr);
00249 
00250 void fip_nd6_6lowpan_generateNA(fip_nd6_aro_t * aroCopy);
00251 
00252 void fip_nd6_6lowpan_processDAR(void);
00253 void fip_nd6_6lowpan_processDAC(void);
00254 
00255 
00256 extern uint16_t abroVersionNumber;
00257 
00258 extern fip_ip6addr_t abroAddress;
00259 
00260 #endif //FIP_SIXLOWPAN_H_
00261 
00262