Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
labs
BIRD Internet Routing Daemon
Commits
67a2eb91
Commit
67a2eb91
authored
Dec 10, 2017
by
Ondřej Zajíček
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lib: Check size of nets
parent
a32a7b58
Pipeline
#28100
failed with stages
in 6 minutes and 7 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
2 deletions
+23
-2
lib/net.c
lib/net.c
+18
-0
lib/net.h
lib/net.h
+4
-2
sysdep/unix/main.c
sysdep/unix/main.c
+1
-0
No files found.
lib/net.c
View file @
67a2eb91
...
...
@@ -288,3 +288,21 @@ net_in_netX(const net_addr *a, const net_addr *n)
return
(
net_pxlen
(
n
)
<=
net_pxlen
(
a
))
&&
ipa_in_netX
(
net_prefix
(
a
),
n
);
}
#define CHECK_NET(T,S) \
({ if (sizeof(T) != S) die("sizeof %s is %d/%d", #T, (int) sizeof(T), S); })
void
net_init
(
void
)
{
CHECK_NET
(
net_addr
,
24
);
CHECK_NET
(
net_addr_ip4
,
8
);
CHECK_NET
(
net_addr_ip6
,
20
);
CHECK_NET
(
net_addr_vpn4
,
16
);
CHECK_NET
(
net_addr_vpn6
,
32
);
CHECK_NET
(
net_addr_roa4
,
16
);
CHECK_NET
(
net_addr_roa6
,
28
);
CHECK_NET
(
net_addr_flow4
,
8
);
CHECK_NET
(
net_addr_flow6
,
20
);
CHECK_NET
(
net_addr_mpls
,
8
);
}
lib/net.h
View file @
67a2eb91
...
...
@@ -45,7 +45,7 @@ typedef struct net_addr {
u8
type
;
u8
pxlen
;
u16
length
;
u8
data
[
16
];
u8
data
[
20
];
u64
align
[
0
];
}
net_addr
;
...
...
@@ -76,6 +76,7 @@ typedef struct net_addr_vpn6 {
u8
pxlen
;
u16
length
;
ip6_addr
prefix
;
u32
padding
;
u64
rd
;
}
net_addr_vpn6
;
...
...
@@ -152,7 +153,7 @@ extern const u16 net_max_text_length[];
((net_addr_vpn4) { NET_VPN4, pxlen, sizeof(net_addr_vpn4), prefix, rd })
#define NET_ADDR_VPN6(prefix,pxlen,rd) \
((net_addr_vpn6) { NET_VPN6, pxlen, sizeof(net_addr_vpn6), prefix, rd })
((net_addr_vpn6) { NET_VPN6, pxlen, sizeof(net_addr_vpn6), prefix,
0,
rd })
#define NET_ADDR_ROA4(prefix,pxlen,max_pxlen,asn) \
((net_addr_roa4) { NET_ROA4, pxlen, sizeof(net_addr_roa4), prefix, max_pxlen, asn })
...
...
@@ -544,5 +545,6 @@ static inline int net_in_net_ip6(const net_addr_ip6 *a, const net_addr_ip6 *b)
int
ipa_in_netX
(
const
ip_addr
A
,
const
net_addr
*
N
);
int
net_in_netX
(
const
net_addr
*
A
,
const
net_addr
*
N
);
void
net_init
(
void
);
#endif
sysdep/unix/main.c
View file @
67a2eb91
...
...
@@ -820,6 +820,7 @@ main(int argc, char **argv)
log_init_debug
(
""
);
log_switch
(
debug_flag
,
NULL
,
NULL
);
net_init
();
resource_init
();
timer_init
();
olock_init
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment