mirror of
https://gitlab.com/qemu-project/SLOF.git
synced 2024-06-25 11:36:33 +08:00
net-snk: Move global variable definition out of the header file
The IPv6 code declares a bunch of global variables (without "extern" keyword!) in the ipv6.h header file. This is bad style and does not work when linking with "-fno-common" for example. So let's move the variables to the files where they are used instead. Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
This commit is contained in:

committed by
Alexey Kardashevskiy

parent
a9aa48d28a
commit
9308463cfd
@ -27,6 +27,8 @@ static uint8_t tid[3];
|
|||||||
static uint32_t dhcpv6_state = -1;
|
static uint32_t dhcpv6_state = -1;
|
||||||
static filename_ip_t *my_fn_ip;
|
static filename_ip_t *my_fn_ip;
|
||||||
|
|
||||||
|
static struct ip6addr_list_entry all_dhcpv6_ll; /* All DHCPv6 servers address */
|
||||||
|
|
||||||
void
|
void
|
||||||
dhcpv6_generate_transaction_id(void)
|
dhcpv6_generate_transaction_id(void)
|
||||||
{
|
{
|
||||||
@ -115,6 +117,9 @@ dhcpv6 ( char *ret_buffer, void *fn_ip)
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
|
all_dhcpv6_ll.addr.part.prefix = 0xff02000000000000ULL;
|
||||||
|
all_dhcpv6_ll.addr.part.interface_id = 0x10002ULL;
|
||||||
|
|
||||||
my_fn_ip = (filename_ip_t *) fn_ip;
|
my_fn_ip = (filename_ip_t *) fn_ip;
|
||||||
fd = my_fn_ip->fd;
|
fd = my_fn_ip->fd;
|
||||||
|
|
||||||
|
@ -40,9 +40,8 @@ send_router_solicitation (int fd)
|
|||||||
sizeof(struct ip6hdr));
|
sizeof(struct ip6hdr));
|
||||||
|
|
||||||
/* Destination is "All routers multicast address" (link-local) */
|
/* Destination is "All routers multicast address" (link-local) */
|
||||||
dest_addr.part.prefix = all_routers_ll.addr.part.prefix;
|
dest_addr.part.prefix = 0xff02000000000000ULL;
|
||||||
dest_addr.part.interface_id = all_routers_ll.addr.part.interface_id;
|
dest_addr.part.interface_id = 2;
|
||||||
|
|
||||||
|
|
||||||
/* Fill IPv6 header */
|
/* Fill IPv6 header */
|
||||||
fill_ip6hdr (ether_packet + sizeof(struct ethhdr),
|
fill_ip6hdr (ether_packet + sizeof(struct ethhdr),
|
||||||
|
@ -37,15 +37,23 @@ static int ip6_is_multicast (ip6_addr_t * ip);
|
|||||||
|
|
||||||
/****************************** LOCAL VARIABLES **************************/
|
/****************************** LOCAL VARIABLES **************************/
|
||||||
|
|
||||||
|
/* List of Ipv6 Addresses */
|
||||||
|
static struct ip6addr_list_entry *first_ip6;
|
||||||
|
static struct ip6addr_list_entry *last_ip6;
|
||||||
|
|
||||||
/* Own IPv6 address */
|
/* Own IPv6 address */
|
||||||
static struct ip6addr_list_entry *own_ip6;
|
static struct ip6addr_list_entry *own_ip6;
|
||||||
|
|
||||||
|
/* All nodes link-local address */
|
||||||
|
struct ip6addr_list_entry all_nodes_ll;
|
||||||
|
|
||||||
/* Null IPv6 address */
|
/* Null IPv6 address */
|
||||||
static ip6_addr_t null_ip6;
|
static ip6_addr_t null_ip6;
|
||||||
|
|
||||||
/* helper variables */
|
/* helper variables */
|
||||||
static uint8_t null_mac[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
static uint8_t null_mac[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||||
|
|
||||||
|
struct ip6_config ip6_state;
|
||||||
|
|
||||||
/****************************** IMPLEMENTATION ***************************/
|
/****************************** IMPLEMENTATION ***************************/
|
||||||
|
|
||||||
@ -365,21 +373,9 @@ ipv6_init (int fd)
|
|||||||
/* Multicast addresses */
|
/* Multicast addresses */
|
||||||
all_nodes_ll.addr.part.prefix = 0xff02000000000000;
|
all_nodes_ll.addr.part.prefix = 0xff02000000000000;
|
||||||
all_nodes_ll.addr.part.interface_id = 1;
|
all_nodes_ll.addr.part.interface_id = 1;
|
||||||
all_dhcpv6_ll.addr.part.prefix = 0xff02000000000000ULL;
|
|
||||||
all_dhcpv6_ll.addr.part.interface_id = 0x10002ULL;
|
|
||||||
all_routers_ll.addr.part.prefix = 0xff02000000000000;
|
|
||||||
all_routers_ll.addr.part.interface_id = 2;
|
|
||||||
|
|
||||||
ip6addr_add(&all_nodes_ll);
|
ip6addr_add(&all_nodes_ll);
|
||||||
/* ... */
|
|
||||||
|
|
||||||
/* Router list */
|
ndp_init();
|
||||||
first_router = NULL;
|
|
||||||
last_router = first_router;
|
|
||||||
|
|
||||||
/* Init Neighbour cache */
|
|
||||||
first_neighbor = NULL;
|
|
||||||
last_neighbor = first_neighbor;
|
|
||||||
|
|
||||||
send_router_solicitation (fd);
|
send_router_solicitation (fd);
|
||||||
for(i=0; i < 4 && !is_ra_received(); i++) {
|
for(i=0; i < 4 && !is_ra_received(); i++) {
|
||||||
|
@ -127,28 +127,13 @@ struct ip6_config {
|
|||||||
uint8_t managed_mode:1,
|
uint8_t managed_mode:1,
|
||||||
other_config:1,
|
other_config:1,
|
||||||
reserved:6;
|
reserved:6;
|
||||||
} ip6_state;
|
};
|
||||||
|
|
||||||
/******************** VARIABLES **********************************************/
|
/******************** VARIABLES **********************************************/
|
||||||
/* Function pointer send_ip. Points either to send_ipv4() or send_ipv6() */
|
/* Function pointer send_ip. Points either to send_ipv4() or send_ipv6() */
|
||||||
extern int (*send_ip) (int fd, void *, int);
|
extern int (*send_ip) (int fd, void *, int);
|
||||||
|
|
||||||
/* IPv6 link-local multicast addresses */
|
extern struct ip6_config ip6_state;
|
||||||
struct ip6addr_list_entry all_routers_ll; // Routers
|
|
||||||
struct ip6addr_list_entry all_dhcpv6_ll; // DHCPv6 servers
|
|
||||||
struct ip6addr_list_entry all_nodes_ll; // All IPv6 nodes
|
|
||||||
|
|
||||||
/* List of Ipv6 Addresses */
|
|
||||||
struct ip6addr_list_entry *first_ip6;
|
|
||||||
struct ip6addr_list_entry *last_ip6;
|
|
||||||
|
|
||||||
/* Neighbor cache */
|
|
||||||
struct neighbor *first_neighbor;
|
|
||||||
struct neighbor *last_neighbor;
|
|
||||||
|
|
||||||
/* Router list */
|
|
||||||
struct router *first_router;
|
|
||||||
struct router *last_router;
|
|
||||||
|
|
||||||
/******************** FUNCTIONS *********************************************/
|
/******************** FUNCTIONS *********************************************/
|
||||||
/* Handles IPv6-packets that are detected by receive_ether. */
|
/* Handles IPv6-packets that are detected by receive_ether. */
|
||||||
|
@ -17,6 +17,14 @@
|
|||||||
#include <netlib/icmpv6.h>
|
#include <netlib/icmpv6.h>
|
||||||
#include <netlib/ndp.h>
|
#include <netlib/ndp.h>
|
||||||
|
|
||||||
|
/* Neighbor cache */
|
||||||
|
static struct neighbor *first_neighbor;
|
||||||
|
static struct neighbor *last_neighbor;
|
||||||
|
|
||||||
|
/* Router list */
|
||||||
|
static struct router *first_router;
|
||||||
|
static struct router *last_router;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NET: add new router to list
|
* NET: add new router to list
|
||||||
* @param struct router nghb - new router
|
* @param struct router nghb - new router
|
||||||
@ -145,3 +153,14 @@ find_neighbor (ip6_addr_t *ip)
|
|||||||
|
|
||||||
return NULL; /* neighbor is unknown */
|
return NULL; /* neighbor is unknown */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ndp_init(void)
|
||||||
|
{
|
||||||
|
/* Router list */
|
||||||
|
first_router = NULL;
|
||||||
|
last_router = first_router;
|
||||||
|
|
||||||
|
/* Init Neighbour cache */
|
||||||
|
first_neighbor = NULL;
|
||||||
|
last_neighbor = first_neighbor;
|
||||||
|
}
|
||||||
|
@ -59,6 +59,7 @@ struct neighbor {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/******************** FUNCTIONS *********************************************/
|
/******************** FUNCTIONS *********************************************/
|
||||||
|
void ndp_init(void);
|
||||||
int8_t neighbor_add (struct neighbor *);
|
int8_t neighbor_add (struct neighbor *);
|
||||||
void * neighbor_create (uint8_t *packet, struct packeth *headers);
|
void * neighbor_create (uint8_t *packet, struct packeth *headers);
|
||||||
struct neighbor * find_neighbor (ip6_addr_t *);
|
struct neighbor * find_neighbor (ip6_addr_t *);
|
||||||
|
Reference in New Issue
Block a user