Commit 02baf1c0 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Add net->ipv4.

parent c6feeaed
......@@ -52,7 +52,7 @@ THE SOFTWARE.
struct timeval now;
unsigned char myid[16];
unsigned char *myipv4 = NULL;
unsigned char do_ipv4 = 0;
int debug = 0;
static int maxmtu;
......@@ -193,12 +193,7 @@ main(int argc, char **argv)
SHIFTE();
debug = atoi(*arg);
} else if(strcmp(*arg, "-4") == 0) {
SHIFTE();
myipv4 = malloc(16);
if(myipv4 == NULL) goto syntax;
rc = parse_address(*arg, myipv4);
if(rc < 0) goto syntax;
if(!v4mapped(myipv4)) goto syntax;
do_ipv4 = 1;
} else {
goto syntax;
}
......@@ -681,11 +676,7 @@ dump_tables(FILE *out)
fprintf(out, "\n");
fprintf(out, "My id %s%s%s seqno %d\n",
format_address(myid),
myipv4 ? " IPv4 " : "",
myipv4 ? format_address(myipv4) : "",
myseqno);
fprintf(out, "My id %s seqno %d\n", format_address(myid), myseqno);
for(i = 0; i < numneighs; i++) {
if(neighs[i].id[0] == 0xFF)
......@@ -742,6 +733,8 @@ struct network *
add_network(char *ifname, int ifindex, int mtu, int wired, unsigned int cost)
{
void *p;
char ipv4[4];
int rc;
if(numnets >= MAXNETS) {
fprintf(stderr, "Too many networks.\n");
......@@ -750,6 +743,16 @@ add_network(char *ifname, int ifindex, int mtu, int wired, unsigned int cost)
memset(nets + numnets, 0, sizeof(struct network));
nets[numnets].ifindex = ifindex;
nets[numnets].ipv4 = NULL;
if(do_ipv4) {
rc = kernel_interface_ipv4(ifname, ifindex, ipv4);
if(rc >= 0) {
nets[numnets].ipv4 = malloc(4);
if(nets[numnets].ipv4)
memcpy(nets[numnets].ipv4, ipv4, 4);
}
}
nets[numnets].wired = wired;
nets[numnets].cost = cost;
nets[numnets].activity_time = now.tv_sec;
......
......@@ -69,6 +69,7 @@ struct network {
int update_time;
int ihu_time;
char ifname[IF_NAMESIZE];
unsigned char *ipv4;
int buffered;
struct timeval flush_time;
int bufsize;
......@@ -87,7 +88,6 @@ extern int debug;
extern int reboot_time;
extern unsigned char myid[16];
extern unsigned char *myipv4;
extern struct network nets[MAXNETS];
extern int numnets;
......
......@@ -217,7 +217,7 @@ parse_packet(const unsigned char *from, struct network *net,
neigh, neigh->address);
} else if(type == 5) {
unsigned char p4[16], prefix[16], nh[16];
if(!myipv4)
if(!net->ipv4)
continue;
v4tov6(p4, message + 20);
v4tov6(nh, message + 16);
......@@ -550,10 +550,10 @@ really_send_update(struct network *net,
if(plen >= 96 && v4mapped(prefix)) {
const unsigned char *sid;
unsigned char v4route[16];
if(!myipv4)
if(!net->ipv4)
return;
memset(v4route, 0, 8);
memcpy(v4route + 8, myipv4 + 12, 4);
memcpy(v4route + 8, net->ipv4, 4);
memcpy(v4route + 12, prefix + 12, 4);
start_message(net, 48);
sid = message_source_id(net);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment