iPXE
ipv6.h File Reference

IPv6 protocol. More...

#include <stdint.h>
#include <string.h>
#include <byteswap.h>
#include <ipxe/in.h>
#include <ipxe/list.h>
#include <ipxe/netdevice.h>

Go to the source code of this file.

Data Structures

struct  ipv6_header
 IPv6 header. More...
struct  ipv6_extension_header_common
 IPv6 extension header common fields. More...
struct  ipv6_option
 IPv6 type-length-value options. More...
struct  ipv6_options_header
 IPv6 option-based extension header. More...
struct  ipv6_routing_header
 IPv6 routing header. More...
struct  ipv6_fragment_header
 IPv6 fragment header. More...
union  ipv6_extension_header
 IPv6 extension header. More...
struct  ipv6_pseudo_header
 IPv6 pseudo-header. More...
struct  ipv6_miniroute
 An IPv6 address/routing table entry. More...

Macros

#define IPV6_VER   0x60000000UL
 IPv6 version.
#define IPV6_MASK_VER   0xf0000000UL
 IPv6 version mask.
#define IPV6_HOP_LIMIT   0xff
 IPv6 maximum hop limit.
#define IPV6_DEFAULT_PREFIX_LEN   64
 IPv6 default prefix length.
#define IPV6_MAX_PREFIX_LEN   128
 IPv6 maximum prefix length.
#define IPV6_CAN_IGNORE_OPT(type)
 Test if IPv6 option can be safely ignored.
#define IPV6_MASK_OFFSET   0xfff8
 Fragment offset mask.
#define IPV6_MASK_MOREFRAGS   0x0001
 More fragments.
#define IPV6_SETTINGS_NAME   "link"
 IPv6 link-local address settings block name.

Enumerations

enum  ipv6_option_type { IPV6_OPT_PAD1 = 0x00 , IPV6_OPT_PADN = 0x01 }
 IPv6 option types. More...
enum  ipv6_header_type {
  IPV6_HOPBYHOP = 0 , IPV6_ROUTING = 43 , IPV6_FRAGMENT = 44 , IPV6_NO_HEADER = 59 ,
  IPV6_DESTINATION = 60
}
 IPv6 header types. More...
enum  ipv6_address_scope {
  IPV6_SCOPE_INTERFACE_LOCAL = 0x1 , IPV6_SCOPE_LINK_LOCAL = 0x2 , INV6_SCOPE_ADMIN_LOCAL = 0x4 , IPV6_SCOPE_SITE_LOCAL = 0x5 ,
  IPV6_SCOPE_ORGANISATION_LOCAL = 0x8 , IPV6_SCOPE_GLOBAL = 0xe , IPV6_SCOPE_MAX = 0xf
}
 IPv6 address scopes. More...
enum  ipv6_miniroute_flags { IPV6_HAS_ADDRESS = 0x0001 , IPV6_HAS_ROUTER = 0x0002 }
 IPv6 address/routing table entry flags. More...
enum  ipv6_settings_order { IPV6_ORDER_PREFIX_ONLY = -4 , IPV6_ORDER_LINK_LOCAL = -3 , IPV6_ORDER_SLAAC = -2 , IPV6_ORDER_DHCPV6 = -1 }
 IPv6 settings sibling order. More...

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
static int ipv6_eui64 (struct in6_addr *addr, struct net_device *netdev)
 Construct local IPv6 address via EUI-64.
static int ipv6_link_local (struct in6_addr *addr, struct net_device *netdev)
 Construct link-local address via EUI-64.
static void ipv6_solicited_node (struct in6_addr *addr, const struct in6_addr *unicast)
 Construct solicited-node multicast address.
static void ipv6_all_routers (struct in6_addr *addr)
 Construct all-routers multicast address.
static unsigned int ipv6_multicast_scope (const struct in6_addr *addr)
 Get multicast address scope.
int ipv6_has_addr (struct net_device *netdev, struct in6_addr *addr)
 Check if network device has a specific IPv6 address.
int ipv6_add_miniroute (struct net_device *netdev, struct in6_addr *address, unsigned int prefix_len, struct in6_addr *router)
 Add IPv6 routing table entry.
void ipv6_del_miniroute (struct ipv6_miniroute *miniroute)
 Delete IPv6 minirouting table entry.
struct ipv6_minirouteipv6_route (unsigned int scope_id, struct in6_addr **dest)
 Perform IPv6 routing.
int parse_ipv6_setting (const struct setting_type *type, const char *value, void *buf, size_t len)
int format_ipv6_setting (const struct setting_type *type, const void *raw, size_t raw_len, char *buf, size_t len)

Variables

struct list_head ipv6_miniroutes
 List of IPv6 miniroutes.
struct net_protocol ipv6_protocol __net_protocol
 AoE protocol.

Detailed Description

IPv6 protocol.

Definition in file ipv6.h.

Macro Definition Documentation

◆ IPV6_VER

#define IPV6_VER   0x60000000UL

IPv6 version.

Definition at line 21 of file ipv6.h.

Referenced by ipv6_rx(), and ipv6_tx().

◆ IPV6_MASK_VER

#define IPV6_MASK_VER   0xf0000000UL

IPv6 version mask.

Definition at line 24 of file ipv6.h.

Referenced by ipv6_rx().

◆ IPV6_HOP_LIMIT

#define IPV6_HOP_LIMIT   0xff

IPv6 maximum hop limit.

Definition at line 27 of file ipv6.h.

Referenced by ipv6_tx().

◆ IPV6_DEFAULT_PREFIX_LEN

#define IPV6_DEFAULT_PREFIX_LEN   64

IPv6 default prefix length.

Definition at line 30 of file ipv6.h.

Referenced by ipv6_add_miniroute().

◆ IPV6_MAX_PREFIX_LEN

#define IPV6_MAX_PREFIX_LEN   128

IPv6 maximum prefix length.

Definition at line 33 of file ipv6.h.

Referenced by dhcpv6_fetch_len6(), ipv6_add_miniroute(), and ipv6_create_routes().

◆ IPV6_CAN_IGNORE_OPT

#define IPV6_CAN_IGNORE_OPT ( type)
Value:
( ( (type) & 0xc0 ) == 0x00 )
uint32_t type
Operating system type.
Definition ena.h:1

Test if IPv6 option can be safely ignored.

Definition at line 78 of file ipv6.h.

Referenced by ipv6_check_options().

◆ IPV6_MASK_OFFSET

#define IPV6_MASK_OFFSET   0xfff8

Fragment offset mask.

Definition at line 111 of file ipv6.h.

Referenced by ipv6_fragment_offset().

◆ IPV6_MASK_MOREFRAGS

#define IPV6_MASK_MOREFRAGS   0x0001

More fragments.

Definition at line 114 of file ipv6.h.

Referenced by ipv6_more_fragments().

◆ IPV6_SETTINGS_NAME

#define IPV6_SETTINGS_NAME   "link"

IPv6 link-local address settings block name.

Definition at line 293 of file ipv6.h.

Referenced by ipv6_register_settings().

Enumeration Type Documentation

◆ ipv6_option_type

IPv6 option types.

Enumerator
IPV6_OPT_PAD1 

Pad1.

IPV6_OPT_PADN 

PadN.

Definition at line 70 of file ipv6.h.

70 {
71 /** Pad1 */
72 IPV6_OPT_PAD1 = 0x00,
73 /** PadN */
74 IPV6_OPT_PADN = 0x01,
75};
@ IPV6_OPT_PAD1
Pad1.
Definition ipv6.h:72
@ IPV6_OPT_PADN
PadN.
Definition ipv6.h:74

◆ ipv6_header_type

IPv6 header types.

Enumerator
IPV6_HOPBYHOP 

IPv6 hop-by-hop options header type.

IPV6_ROUTING 

IPv6 routing header type.

IPV6_FRAGMENT 

IPv6 fragment header type.

IPV6_NO_HEADER 

IPv6 no next header type.

IPV6_DESTINATION 

IPv6 destination options header type.

Definition at line 135 of file ipv6.h.

135 {
136 /** IPv6 hop-by-hop options header type */
137 IPV6_HOPBYHOP = 0,
138 /** IPv6 routing header type */
139 IPV6_ROUTING = 43,
140 /** IPv6 fragment header type */
141 IPV6_FRAGMENT = 44,
142 /** IPv6 no next header type */
143 IPV6_NO_HEADER = 59,
144 /** IPv6 destination options header type */
145 IPV6_DESTINATION = 60,
146};
@ IPV6_NO_HEADER
IPv6 no next header type.
Definition ipv6.h:143
@ IPV6_HOPBYHOP
IPv6 hop-by-hop options header type.
Definition ipv6.h:137
@ IPV6_FRAGMENT
IPv6 fragment header type.
Definition ipv6.h:141
@ IPV6_DESTINATION
IPv6 destination options header type.
Definition ipv6.h:145
@ IPV6_ROUTING
IPv6 routing header type.
Definition ipv6.h:139

◆ ipv6_address_scope

IPv6 address scopes.

Enumerator
IPV6_SCOPE_INTERFACE_LOCAL 

Interface-local address scope.

IPV6_SCOPE_LINK_LOCAL 

Link-local address scope.

INV6_SCOPE_ADMIN_LOCAL 

Admin-local address scope.

IPV6_SCOPE_SITE_LOCAL 

Site-local address scope.

IPV6_SCOPE_ORGANISATION_LOCAL 

Organisation-local address scope.

IPV6_SCOPE_GLOBAL 

Global address scope.

IPV6_SCOPE_MAX 

Maximum scope.

Definition at line 163 of file ipv6.h.

163 {
164 /** Interface-local address scope */
166 /** Link-local address scope */
168 /** Admin-local address scope */
170 /** Site-local address scope */
172 /** Organisation-local address scope */
174 /** Global address scope */
175 IPV6_SCOPE_GLOBAL = 0xe,
176 /** Maximum scope */
177 IPV6_SCOPE_MAX = 0xf,
178};
@ IPV6_SCOPE_SITE_LOCAL
Site-local address scope.
Definition ipv6.h:171
@ IPV6_SCOPE_GLOBAL
Global address scope.
Definition ipv6.h:175
@ IPV6_SCOPE_MAX
Maximum scope.
Definition ipv6.h:177
@ IPV6_SCOPE_ORGANISATION_LOCAL
Organisation-local address scope.
Definition ipv6.h:173
@ IPV6_SCOPE_LINK_LOCAL
Link-local address scope.
Definition ipv6.h:167
@ INV6_SCOPE_ADMIN_LOCAL
Admin-local address scope.
Definition ipv6.h:169
@ IPV6_SCOPE_INTERFACE_LOCAL
Interface-local address scope.
Definition ipv6.h:165

◆ ipv6_miniroute_flags

IPv6 address/routing table entry flags.

Enumerator
IPV6_HAS_ADDRESS 

Routing table entry address is valid.

IPV6_HAS_ROUTER 

Routing table entry router address is valid.

Definition at line 203 of file ipv6.h.

203 {
204 /** Routing table entry address is valid */
205 IPV6_HAS_ADDRESS = 0x0001,
206 /** Routing table entry router address is valid */
207 IPV6_HAS_ROUTER = 0x0002,
208};
@ IPV6_HAS_ROUTER
Routing table entry router address is valid.
Definition ipv6.h:207
@ IPV6_HAS_ADDRESS
Routing table entry address is valid.
Definition ipv6.h:205

◆ ipv6_settings_order

IPv6 settings sibling order.

Enumerator
IPV6_ORDER_PREFIX_ONLY 

No address.

IPV6_ORDER_LINK_LOCAL 

Link-local address.

IPV6_ORDER_SLAAC 

Address assigned via SLAAC.

IPV6_ORDER_DHCPV6 

Address assigned via DHCPv6.

Definition at line 281 of file ipv6.h.

281 {
282 /** No address */
284 /** Link-local address */
286 /** Address assigned via SLAAC */
287 IPV6_ORDER_SLAAC = -2,
288 /** Address assigned via DHCPv6 */
290};
@ IPV6_ORDER_PREFIX_ONLY
No address.
Definition ipv6.h:283
@ IPV6_ORDER_SLAAC
Address assigned via SLAAC.
Definition ipv6.h:287
@ IPV6_ORDER_DHCPV6
Address assigned via DHCPv6.
Definition ipv6.h:289
@ IPV6_ORDER_LINK_LOCAL
Link-local address.
Definition ipv6.h:285

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ ipv6_eui64()

int ipv6_eui64 ( struct in6_addr * addr,
struct net_device * netdev )
inlinestatic

Construct local IPv6 address via EUI-64.

Parameters
addrPrefix to be completed
netdevNetwork device
Return values
prefix_lenPrefix length, or negative error

Definition at line 217 of file ipv6.h.

218 {
219 struct ll_protocol *ll_protocol = netdev->ll_protocol;
220 const void *ll_addr = netdev->ll_addr;
221 int rc;
222
223 if ( ( rc = ll_protocol->eui64 ( ll_addr, &addr->s6_addr[8] ) ) != 0 )
224 return rc;
225 addr->s6_addr[8] ^= 0x02;
226 return 64;
227}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
uint32_t addr
Buffer address.
Definition dwmac.h:9
static struct net_device * netdev
Definition gdbudp.c:53
A link-layer protocol.
Definition netdevice.h:115
int(* eui64)(const void *ll_addr, void *eui64)
Generate EUI-64 address.
Definition netdevice.h:190

References addr, ll_protocol::eui64, netdev, and rc.

Referenced by ipv6_link_local(), and ndp_prefix_fetch_ip6().

◆ ipv6_link_local()

int ipv6_link_local ( struct in6_addr * addr,
struct net_device * netdev )
inlinestatic

Construct link-local address via EUI-64.

Parameters
addrZeroed address to construct
netdevNetwork device
Return values
prefix_lenPrefix length, or negative error

Definition at line 236 of file ipv6.h.

237 {
238
239 addr->s6_addr16[0] = htons ( 0xfe80 );
240 return ipv6_eui64 ( addr, netdev );
241}
#define htons(value)
Definition byteswap.h:136
static int ipv6_eui64(struct in6_addr *addr, struct net_device *netdev)
Construct local IPv6 address via EUI-64.
Definition ipv6.h:217

References addr, htons, ipv6_eui64(), and netdev.

Referenced by ipv6_fetch().

◆ ipv6_solicited_node()

void ipv6_solicited_node ( struct in6_addr * addr,
const struct in6_addr * unicast )
inlinestatic

Construct solicited-node multicast address.

Parameters
addrZeroed address to construct
unicastUnicast address

Definition at line 249 of file ipv6.h.

250 {
251
252 addr->s6_addr16[0] = htons ( 0xff02 );
253 addr->s6_addr[11] = 1;
254 addr->s6_addr[12] = 0xff;
255 memcpy ( &addr->s6_addr[13], &unicast->s6_addr[13], 3 );
256}
void * memcpy(void *dest, const void *src, size_t len) __nonnull

References addr, htons, and memcpy().

Referenced by ndp_tx_request().

◆ ipv6_all_routers()

void ipv6_all_routers ( struct in6_addr * addr)
inlinestatic

Construct all-routers multicast address.

Parameters
addrZeroed address to construct

Definition at line 263 of file ipv6.h.

263 {
264 addr->s6_addr16[0] = htons ( 0xff02 );
265 addr->s6_addr[15] = 2;
266}

References addr, and htons.

Referenced by ndp_tx_router_solicitation().

◆ ipv6_multicast_scope()

unsigned int ipv6_multicast_scope ( const struct in6_addr * addr)
inlinestatic

Get multicast address scope.

Parameters
addrMulticast address
Return values
scopeAddress scope

Definition at line 275 of file ipv6.h.

275 {
276
277 return ( addr->s6_addr[1] & 0x0f );
278}

References addr.

Referenced by ipv6_scope().

◆ ipv6_has_addr()

int ipv6_has_addr ( struct net_device * netdev,
struct in6_addr * addr )
extern

Check if network device has a specific IPv6 address.

Parameters
netdevNetwork device
addrIPv6 address
Return values
has_addrNetwork device has this IPv6 address

Definition at line 142 of file ipv6.c.

142 {
143 struct ipv6_miniroute *miniroute;
144
145 list_for_each_entry ( miniroute, &ipv6_miniroutes, list ) {
146 if ( ( miniroute->netdev == netdev ) &&
147 ( miniroute->flags & IPV6_HAS_ADDRESS ) &&
148 ( memcmp ( &miniroute->address, addr,
149 sizeof ( miniroute->address ) ) == 0 ) ) {
150 /* Found matching address */
151 return 1;
152 }
153 }
154 return 0;
155}
struct list_head ipv6_miniroutes
List of IPv6 miniroutes.
Definition ipv6.c:61
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition list.h:432
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition string.c:115
An IPv6 address/routing table entry.
Definition ipv6.h:181
struct net_device * netdev
Network device.
Definition ipv6.h:186
struct list_head list
List of miniroutes.
Definition ipv6.h:183
unsigned int flags
Flags.
Definition ipv6.h:199
struct in6_addr address
IPv6 address (or prefix if no address is defined)
Definition ipv6.h:189

References addr, ipv6_miniroute::address, ipv6_miniroute::flags, IPV6_HAS_ADDRESS, ipv6_miniroutes, ipv6_miniroute::list, list_for_each_entry, memcmp(), ipv6_miniroute::netdev, and netdev.

Referenced by ipv6_rx(), and ndp_rx_neighbour_solicitation_ll_source().

◆ ipv6_add_miniroute()

int ipv6_add_miniroute ( struct net_device * netdev,
struct in6_addr * address,
unsigned int prefix_len,
struct in6_addr * router )
extern

Add IPv6 routing table entry.

Parameters
netdevNetwork device
addressIPv6 address (or prefix)
prefix_lenPrefix length
routerRouter address (if any)
Return values
rcReturn status code

Definition at line 218 of file ipv6.c.

219 {
220 struct ipv6_miniroute *miniroute;
222 unsigned int remaining;
223 unsigned int i;
224
225 /* Find or create routing table entry */
226 miniroute = ipv6_miniroute ( netdev, address );
227 if ( miniroute ) {
228
229 /* Remove from existing position in routing table */
230 list_del ( &miniroute->list );
231
232 } else {
233
234 /* Create new routing table entry */
235 miniroute = zalloc ( sizeof ( *miniroute ) );
236 if ( ! miniroute )
237 return -ENOMEM;
238 miniroute->netdev = netdev_get ( netdev );
239 memcpy ( &miniroute->address, address,
240 sizeof ( miniroute->address ) );
241
242 /* Default to prefix length of 64 if none specified */
243 if ( ! prefix_len )
245 miniroute->prefix_len = prefix_len;
247
248 /* Construct prefix mask */
249 remaining = prefix_len;
250 for ( prefix_mask = miniroute->prefix_mask.s6_addr ;
251 remaining >= 8 ; prefix_mask++, remaining -= 8 ) {
252 *prefix_mask = 0xff;
253 }
254 if ( remaining )
255 *prefix_mask = ( 0xff << ( 8 - remaining ) );
256 }
257
258 /* Add to start of routing table */
259 list_add ( &miniroute->list, &ipv6_miniroutes );
260
261 /* Set or update address, if applicable */
262 for ( i = 0 ; i < ( sizeof ( address->s6_addr32 ) /
263 sizeof ( address->s6_addr32[0] ) ) ; i++ ) {
264 if ( ( address->s6_addr32[i] &
265 ~miniroute->prefix_mask.s6_addr32[i] ) != 0 ) {
266 memcpy ( &miniroute->address, address,
267 sizeof ( miniroute->address ) );
268 miniroute->flags |= IPV6_HAS_ADDRESS;
269 }
270 }
271 if ( miniroute->prefix_len == IPV6_MAX_PREFIX_LEN )
272 miniroute->flags |= IPV6_HAS_ADDRESS;
273
274 /* Update scope */
275 miniroute->scope = ipv6_scope ( &miniroute->address );
276
277 /* Set or update router, if applicable */
278 if ( router ) {
279 memcpy ( &miniroute->router, router,
280 sizeof ( miniroute->router ) );
281 miniroute->flags |= IPV6_HAS_ROUTER;
282 }
283
284 ipv6_dump_miniroute ( miniroute );
285 return 0;
286}
unsigned char uint8_t
Definition stdint.h:10
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:50
uint64_t address
Base address.
Definition ena.h:13
#define ENOMEM
Not enough space.
Definition errno.h:535
static unsigned int ipv6_scope(const struct in6_addr *addr)
Determine IPv6 address scope.
Definition ipv6.c:89
static void ipv6_dump_miniroute(struct ipv6_miniroute *miniroute)
Dump IPv6 routing table entry.
Definition ipv6.c:123
static struct ipv6_miniroute * ipv6_miniroute(struct net_device *netdev, struct in6_addr *address)
Find IPv6 routing table entry for a given address.
Definition ipv6.c:193
#define IPV6_MAX_PREFIX_LEN
IPv6 maximum prefix length.
Definition ipv6.h:33
#define IPV6_DEFAULT_PREFIX_LEN
IPv6 default prefix length.
Definition ipv6.h:30
#define list_del(list)
Delete an entry from a list.
Definition list.h:120
#define list_add(new, head)
Add a new entry to the head of a list.
Definition list.h:70
void * zalloc(size_t size)
Allocate cleared memory.
Definition malloc.c:662
static struct net_device * netdev_get(struct net_device *netdev)
Get reference to network device.
Definition netdevice.h:565
unsigned int scope
Scope.
Definition ipv6.h:197
unsigned int prefix_len
Prefix length.
Definition ipv6.h:191
struct in6_addr router
Router address.
Definition ipv6.h:195
struct in6_addr prefix_mask
IPv6 prefix mask (derived from prefix length)
Definition ipv6.h:193

References address, ipv6_miniroute::address, assert, ENOMEM, ipv6_miniroute::flags, IPV6_DEFAULT_PREFIX_LEN, ipv6_dump_miniroute(), IPV6_HAS_ADDRESS, IPV6_HAS_ROUTER, IPV6_MAX_PREFIX_LEN, ipv6_miniroute(), ipv6_miniroutes, ipv6_scope(), ipv6_miniroute::list, list_add, list_del, memcpy(), ipv6_miniroute::netdev, netdev, netdev_get(), ipv6_miniroute::prefix_len, ipv6_miniroute::prefix_mask, ipv6_miniroute::router, ipv6_miniroute::scope, and zalloc().

Referenced by ipv6_create_routes(), and ipv6_table_okx().

◆ ipv6_del_miniroute()

void ipv6_del_miniroute ( struct ipv6_miniroute * miniroute)
extern

Delete IPv6 minirouting table entry.

Parameters
minirouteRouting table entry

Definition at line 293 of file ipv6.c.

293 {
294
295 netdev_put ( miniroute->netdev );
296 list_del ( &miniroute->list );
297 free ( miniroute );
298}
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition netdevice.h:576
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55

References free, ipv6_miniroute::list, list_del, ipv6_miniroute::netdev, and netdev_put().

Referenced by ipv6_create_all_routes(), and ipv6_table_del().

◆ ipv6_route()

struct ipv6_miniroute * ipv6_route ( unsigned int scope_id,
struct in6_addr ** dest )
extern

Perform IPv6 routing.

Parameters
scope_idDestination address scope ID (for link-local addresses)
destFinal destination address
Return values
destNext hop destination address
minirouteRouting table entry to use, or NULL if no route

Definition at line 308 of file ipv6.c.

309 {
310 struct ipv6_miniroute *miniroute;
311 struct ipv6_miniroute *chosen = NULL;
312 unsigned int best = 0;
313 unsigned int match_len;
314 unsigned int score;
315 unsigned int scope;
316
317 /* Calculate destination address scope */
318 scope = ipv6_scope ( *dest );
319
320 /* Find first usable route in routing table */
321 list_for_each_entry ( miniroute, &ipv6_miniroutes, list ) {
322
323 /* Skip closed network devices */
324 if ( ! netdev_is_open ( miniroute->netdev ) )
325 continue;
326
327 /* Skip entries with no usable source address */
328 if ( ! ( miniroute->flags & IPV6_HAS_ADDRESS ) )
329 continue;
330
331 /* Skip entries with a non-matching scope ID, if
332 * destination specifies a scope ID.
333 */
334 if ( scope_id && ( miniroute->netdev->scope_id != scope_id ) )
335 continue;
336
337 /* Skip entries that are out of scope */
338 if ( miniroute->scope < scope )
339 continue;
340
341 /* Calculate match length */
342 match_len = ipv6_match_len ( miniroute, *dest );
343
344 /* If destination is on-link, then use this route */
345 if ( match_len >= miniroute->prefix_len )
346 return miniroute;
347
348 /* If destination is unicast, then skip off-link
349 * entries with no router.
350 */
351 if ( ! ( IN6_IS_ADDR_MULTICAST ( *dest ) ||
352 ( miniroute->flags & IPV6_HAS_ROUTER ) ) )
353 continue;
354
355 /* Choose best route, defined as being the route with
356 * the smallest viable scope. If two routes both have
357 * the same scope, then prefer the route with the
358 * longest match length.
359 */
360 score = ( ( ( IPV6_SCOPE_MAX + 1 - miniroute->scope ) << 8 )
361 + match_len );
362 if ( score > best ) {
363 chosen = miniroute;
364 best = score;
365 }
366 }
367
368 /* Return chosen route, if any */
369 if ( chosen ) {
370 if ( ! IN6_IS_ADDR_MULTICAST ( *dest ) )
371 *dest = &chosen->router;
372 return chosen;
373 }
374
375 return NULL;
376}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" retur dest)
Definition string.h:151
uint8_t scope
Scope.
Definition ena.h:7
#define IN6_IS_ADDR_MULTICAST(addr)
Definition in.h:68
static unsigned int ipv6_match_len(struct ipv6_miniroute *miniroute, struct in6_addr *address)
Count matching bits of an IPv6 routing table entry prefix.
Definition ipv6.c:164
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
Definition netdevice.h:662
unsigned int scope_id
Scope ID.
Definition netdevice.h:361

References dest, ipv6_miniroute::flags, IN6_IS_ADDR_MULTICAST, IPV6_HAS_ADDRESS, IPV6_HAS_ROUTER, ipv6_match_len(), ipv6_miniroutes, ipv6_scope(), IPV6_SCOPE_MAX, ipv6_miniroute::list, list_for_each_entry, ipv6_miniroute::netdev, netdev_is_open(), NULL, ipv6_miniroute::prefix_len, ipv6_miniroute::router, ipv6_miniroute::scope, scope, and net_device::scope_id.

Referenced by ipv6_netdev(), ipv6_route_okx(), and ipv6_tx().

◆ parse_ipv6_setting()

int parse_ipv6_setting ( const struct setting_type * type,
const char * value,
void * buf,
size_t len )
extern

References len, type, and value.

◆ format_ipv6_setting()

int format_ipv6_setting ( const struct setting_type * type,
const void * raw,
size_t raw_len,
char * buf,
size_t len )
extern

References len, raw, raw_len, and type.

Variable Documentation

◆ ipv6_miniroutes

struct list_head ipv6_miniroutes
extern

◆ __net_protocol

struct net_protocol ipv6_protocol __net_protocol
extern

AoE protocol.

AoE protocol.

AoE protocol.

FIP protocol.

Definition at line 56 of file aoe.c.