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_IF_H_
00045 #define FIP_IF_H_
00046
00047 #include "fip_ds6.h"
00048
00049
00050 typedef struct
00051 {
00052 uint32_t linkMTU;
00053 uint8_t curHopLimit;
00054 fip_nd6_if_t nd6;
00055
00056
00057
00058
00059
00060
00061
00062
00063 unsigned char myDefaultGlobalAddress;
00064 unsigned char myDefaultLinkLocalAddress;
00065 fip_myip6addr_t myUniIpAddr[FIP_CONF_MAX_IPADDRS_UNI];
00066 fip_myip6addr_t myMultiIpAddr[FIP_CONF_MAX_IPADDRS_MUL];
00067 fip_myip6prefix_t myPrefixs[FIP_CONF_MAX_PREFIXES];
00068 fip_mydefrouter_t myDefRouters[FIP_CONF_MAX_DEFROUTES];
00069 } fip_if_ipv6_t;
00070
00071 typedef struct
00072 {
00073
00074 unsigned char ipv6Enabled : 1;
00075 unsigned char ipv4Enabled : 1;
00076 unsigned char forwardingEnabled : 1;
00077 unsigned char amIRouter : 1;
00078 char name[FIP_CONF_MAX_IFNAME+1];
00079 void (*ifProcess)(void);
00080
00081
00082 uint16_t defaultPacketBufSizes[FIP_NUMBUFS];
00083 unsigned char defaultSrcLLAddrOffset;
00084 unsigned char defaultDestLLAddrOffset;
00085
00086
00087 unsigned char numberLLAddresses;
00088 unsigned char defaultLLAddress;
00089 unsigned char validLLengths[FIP_CONF_MAX_LLADDRS];
00090 fip_mylladdr_t linkLayerAddr[FIP_CONF_MAX_LLADDRS];
00091
00092
00093 fip_if_ipv6_t v6;
00094
00095
00096
00097
00098 } fip_if_t;
00099
00100
00101 typedef fip_ds6_index_t fip_if6_index_t;
00102
00103 typedef fip_ds6_searchStatus_t fip_if6_searchStatus_t;
00104
00105 extern fip_if_t fip_if[FIP_CONF_MAX_INTERFACES];
00106
00107
00108
00109
00110 void fip_if_init(fip_ifnum_t ifnum,
00111 fip_llptraddr_t lladdr,
00112 uint16_t defaultPacketBufSizes[],
00113 unsigned char LLHdrSrcOffset,
00114 unsigned char LLHdrDestOffset,
00115 char * name,
00116 void (*ifProcess)(void),
00117 const fip_nd6_if_t * nd6ptr,
00118 const unsigned char validLLLengths[]);
00119 void fip_if6_periodic(fip_ifnum_t ifnum);
00120
00121
00122 fip_return_t fip_if_addLLAddress(fip_ifnum_t ifnum, fip_llptraddr_t lladdr,
00123 fip_bool_t preferred, fip_bool_t validForGPAutoconf);
00124 fip_return_t fip_if6_addAutoconfAddress(fip_ifnum_t ifnum, unsigned char prefixIndex, unsigned char LLIndex);
00125 fip_return_t fip_if6_addMulticastAddress(fip_ifnum_t ifnum, const fip_ip6addr_t * addr,
00126 fip_vlifetime_t validUntil,
00127 unsigned char PreferredLLAddrIndex, fip_bool_t hasPreferredLLAddr);
00128 fip_return_t fip_if6_addUnicastAddress(fip_ifnum_t ifnum, const fip_ip6addr_t * addr,
00129 fip_vlifetime_t validUntil, fip_addrtype_t addrtype,
00130 unsigned char PreferredLLAddrIndex, fip_bool_t hasPreferredLLAddr);
00131 fip_return_t fip_if6_addPrefix(fip_ifnum_t ifnum, const fip_ip6addr_t * prefix,
00132 unsigned char length, fip_vlifetime_t vlifetime,
00133 fip_bool_t advPrefix, fip_bool_t onLink);
00134 void fip_if6_addUpdateDefaultRouter(fip_ifnum_t ifnum, uint16_t routerLifetime, const fip_ip6addr_t * ipaddr);
00135 void fip_if6_setForwarding(fip_ifnum_t ifnum, fip_bool_t enabled);
00136 void fip_if6_setRouter(fip_ifnum_t ifnum, fip_bool_t enabled, unsigned int defLifetime);
00137
00138
00139 void fip_if_newPacketSetup(void);
00140 fip_bool_t fip_if6_isDestMyUnicast(fip_ifnum_t ifnum);
00141 fip_bool_t fip_if6_isDestMyMulticast(fip_ifnum_t ifnum);
00142 unsigned char fip_if6_shortenLLAOLength(unsigned char paddedLength);
00143 fip_llptraddr_t fip_if6_getMyLL(unsigned char indexToMyUnicast);
00144 void fip_if6_selectSrcAddress(void);
00145 fip_bool_t fip_if6_isDestOnLink(fip_ifnum_t ifnum);
00146 const fip_ip6addr_t * fip_if6_getDefaultRouter(fip_ifnum_t ifnum);
00147
00148
00149
00150
00151
00152
00153 #define fip_if_isForwardingEnabled() fip_if[fip_packet_getIfNum()].forwardingEnabled
00154 #define fip_if_amIRouter() fip_if[fip_packet_getIfNum()].amIRouter
00155
00156 #define fip_if_isIPv6Enabled() fip_if[fip_packet_getIfNum()].ipv6Enabled
00157
00158 #define fip_ifn_isIPv6Enabled(x) fip_if[x].ipv6Enabled
00159
00160 #define fip_if6_isMyUnicast(address) fip_ds6_searchList( \
00161 (unsigned char *) &(fip_if[fip_packet_getIfNum()].v6.myUniIpAddr[0]), \
00162 sizeof(fip_myip6addr_t), \
00163 FIP_CONF_MAX_IPADDRS_UNI, \
00164 \
00165 \
00166 offsetof(fip_myip6addr_t, addr), \
00167 (unsigned char *)(address), 16) \
00168
00169
00170 #define fip_if6_isMyPrefix(ptrPref) fip_ds6_searchList( \
00171 (unsigned char *) &(fip_if[fip_packet_getIfNum()].v6.myPrefixs[0]), \
00172 sizeof(fip_myip6prefix_t), \
00173 FIP_CONF_MAX_PREFIXES, \
00174 \
00175 \
00176 offsetof(fip_myip6prefix_t, prefix), \
00177 (unsigned char *)(ptrPref), 16) \
00178
00179
00180 #define fip_if6_getPtrToND6Struct(ifnum) &(fip_if[ifnum].v6.nd6)
00181
00182 #define fip_if6_getAttr(ifnum, attr) fip_if[ifnum].v6.attr
00183 #define fip_if6_setAttr(ifnum, attr, value) fip_if[ifnum].v6.attr = value
00184
00185 #define fip_if6_getUnicastState(index) fip_if[fip_packet_getIfNum()].v6.myUniIpAddr[index].state
00186 #define fip_if6_getUnicastPtrToAddr(index) fip_if[fip_packet_getIfNum()].v6.myUniIpAddr[index].addr.addr
00187 #define fip_if6_getUnicastPtrToStruct(ifnum, index) &(fip_if[ifnum].v6.myUniIpAddr[index])
00188
00189 #define fip_if6_setUnicastState(index,news) fip_if[fip_packet_getIfNum()].v6.myUniIpAddr[index].state = news
00190
00191 #define fip_if6_getDefaultRouterPtrToAddr(ifnum, index) &(fip_if[ifnum].v6.myDefRouters[index].router)
00192
00193 #define fip_if6_getMyDefaultAddrIndex() fip_if[fip_packet_getIfNum()].v6.myDefaultGlobalAddress
00194 #define fip_if6_getMyDefaultLinkLocalAddrIndex() fip_if[fip_packet_getIfNum()].v6.myDefaultLinkLocalAddress
00195
00196 #define fip_if6_getPrefixAttr(index, attr) fip_if[fip_packet_getIfNum()].v6.myPrefixs[index].attr
00197 #define fip_if6_setPrefixAttr(index, attr, value) fip_if[fip_packet_getIfNum()].v6.myPrefixs[index].attr = value
00198 #define fip_if6_setPrefixValidLifetime(index, lifetime) {fip_if[fip_packet_getIfNum()].v6.myPrefixs[index].validUntil = fip_timer_getExpireTime32S(lifetime); \
00199 fip_if[fip_packet_getIfNum()].v6.myPrefixs[index].validLifetime = lifetime;}
00200 #define fip_if6_setPrefixValidUntil(index, lifetime) fip_if[fip_packet_getIfNum()].v6.myPrefixs[index].validUntil = lifetime
00201
00202 #endif
00203
00204
00205