blob: d0db198bf96fe05a1b67cbf2b5d63d35869c7926 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/******************************************************************************
* Copyright (c) 2013 IBM Corporation
* All rights reserved.
* This program and the accompanying materials
* are made available under the terms of the BSD License
* which accompanies this distribution, and is available at
* http://www.opensource.org/licenses/bsd-license.php
*
* Contributors:
* IBM Corporation - initial implementation
*****************************************************************************/
#ifndef _NDP_H_
#define _NDP_H_
#include "ipv6.h"
#define __NDP_DEBUG__
#ifdef __NDP_DEBUG__
#define NDP_DEBUG_PRINT(format, ...) do { printf(format, ## __VA_ARGS__); } while (0)
#else
#define NDP_DEBUG_PRINT(format, ...)
#endif
#define ND_OPTION_SOURCE_LL_ADDR 1
#define ND_OPTION_TARGET_LL_ADDR 2
#define ND_OPTION_PREFIX_INFO 3
#define ND_OPTION_REDIRECT_HDR 4
#define ND_OPTION_MTU 5
/* Default Router List */
struct router {
uint8_t mac[6];
ip6_addr_t ip;
uint32_t lifetime;
uint32_t reachable_time;
uint32_t retrans_timer;
struct router *next;
};
/* Neighbor cache */
struct neighbor {
uint8_t mac[6];
ip6_addr_t ip;
uint8_t is_router;
uint8_t status;
uint8_t times_asked;
/* ... */
struct neighbor *next;
uint8_t eth_frame[ETH_MTU_SIZE];
uint32_t eth_len;
#define NB_INCOMPLETE 1
#define NB_REACHABLE 2
#define NB_STALE 3
#define NB_DELAY 4
#define NB_PROBE 5
};
/******************** FUNCTIONS *********************************************/
void ndp_init(void);
int8_t neighbor_add (struct neighbor *);
void * neighbor_create (uint8_t *packet, struct packeth *headers);
struct neighbor *find_neighbor(ip6_addr_t ip);
int8_t router_add(struct router*);
void *router_create(uint8_t *mac, ip6_addr_t ip);
struct router *find_router(ip6_addr_t ip);
struct router *ipv6_get_default_router(ip6_addr_t ip);
#endif //_NDP_H_
|