Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
babeld
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
babeld
Commits
77a68bb9
Commit
77a68bb9
authored
Mar 24, 2016
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move initialisation of channel information into parse_update_subtlv.
parent
90b61797
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
48 deletions
+34
-48
message.c
message.c
+34
-48
No files found.
message.c
View file @
77a68bb9
...
@@ -120,11 +120,26 @@ network_prefix(int ae, int plen, unsigned int omitted,
...
@@ -120,11 +120,26 @@ network_prefix(int ae, int plen, unsigned int omitted,
}
}
static
void
static
void
parse_update_subtlv
(
const
unsigned
char
*
a
,
int
alen
,
parse_update_subtlv
(
struct
interface
*
ifp
,
int
metric
,
const
unsigned
char
*
a
,
int
alen
,
unsigned
char
*
channels
)
unsigned
char
*
channels
)
{
{
int
type
,
len
,
i
=
0
;
int
type
,
len
,
i
=
0
;
if
((
ifp
->
flags
&
IF_FARAWAY
))
{
channels
[
0
]
=
0
;
}
else
{
/* This will be overwritten if there's a DIVERSITY_HOPS sub-TLV. */
if
(
metric
<
256
)
{
/* Assume non-interfering (wired) link. */
channels
[
0
]
=
0
;
}
else
{
/* Assume interfering. */
channels
[
0
]
=
IF_CHANNEL_INTERFERING
;
channels
[
1
]
=
0
;
}
}
while
(
i
<
alen
)
{
while
(
i
<
alen
)
{
type
=
a
[
i
];
type
=
a
[
i
];
if
(
type
==
SUBTLV_PAD1
)
{
if
(
type
==
SUBTLV_PAD1
)
{
...
@@ -145,19 +160,21 @@ parse_update_subtlv(const unsigned char *a, int alen,
...
@@ -145,19 +160,21 @@ parse_update_subtlv(const unsigned char *a, int alen,
if
(
type
==
SUBTLV_PADN
)
{
if
(
type
==
SUBTLV_PADN
)
{
/* Nothing. */
/* Nothing. */
}
else
if
(
type
==
SUBTLV_DIVERSITY
)
{
}
else
if
(
type
==
SUBTLV_DIVERSITY
)
{
if
(
len
>
DIVERSITY_HOPS
)
{
if
(
!
(
ifp
->
flags
&
IF_FARAWAY
))
{
fprintf
(
stderr
,
if
(
len
>
DIVERSITY_HOPS
)
{
"Received overlong channel information (%d > %d).
\n
"
,
fprintf
(
stderr
,
len
,
DIVERSITY_HOPS
);
"Received overlong channel information (%d > %d).
\n
"
,
len
=
DIVERSITY_HOPS
;
len
,
DIVERSITY_HOPS
);
}
len
=
DIVERSITY_HOPS
;
if
(
memchr
(
a
+
i
+
2
,
0
,
len
)
!=
NULL
)
{
}
/* 0 is reserved. */
if
(
memchr
(
a
+
i
+
2
,
0
,
len
)
!=
NULL
)
{
fprintf
(
stderr
,
"Channel information contains 0!"
);
/* 0 is reserved. */
return
;
fprintf
(
stderr
,
"Channel information contains 0!"
);
return
;
}
memset
(
channels
,
0
,
DIVERSITY_HOPS
);
memcpy
(
channels
,
a
+
i
+
2
,
len
);
}
}
memset
(
channels
,
0
,
DIVERSITY_HOPS
);
memcpy
(
channels
,
a
+
i
+
2
,
len
);
}
else
{
}
else
{
debugf
(
"Received unknown update sub-TLV %d.
\n
"
,
type
);
debugf
(
"Received unknown update sub-TLV %d.
\n
"
,
type
);
}
}
...
@@ -523,24 +540,8 @@ parse_packet(const unsigned char *from, struct interface *ifp,
...
@@ -523,24 +540,8 @@ parse_packet(const unsigned char *from, struct interface *ifp,
goto
done
;
goto
done
;
}
}
if
((
ifp
->
flags
&
IF_FARAWAY
))
{
parse_update_subtlv
(
ifp
,
metric
,
message
+
2
+
parsed_len
,
channels
[
0
]
=
0
;
len
-
parsed_len
,
channels
);
}
else
{
/* This will be overwritten by parse_update_subtlv below. */
if
(
metric
<
256
)
{
/* Assume non-interfering (wired) link. */
channels
[
0
]
=
0
;
}
else
{
/* Assume interfering. */
channels
[
0
]
=
IF_CHANNEL_INTERFERING
;
channels
[
1
]
=
0
;
}
if
(
parsed_len
<
len
)
parse_update_subtlv
(
message
+
2
+
parsed_len
,
len
-
parsed_len
,
channels
);
}
update_route
(
router_id
,
prefix
,
plen
,
zeroes
,
0
,
seqno
,
update_route
(
router_id
,
prefix
,
plen
,
zeroes
,
0
,
seqno
,
metric
,
interval
,
neigh
,
nh
,
metric
,
interval
,
neigh
,
nh
,
channels
,
channels_len
(
channels
));
channels
,
channels_len
(
channels
));
...
@@ -652,23 +653,8 @@ parse_packet(const unsigned char *from, struct interface *ifp,
...
@@ -652,23 +653,8 @@ parse_packet(const unsigned char *from, struct interface *ifp,
goto
done
;
goto
done
;
}
}
if
((
ifp
->
flags
&
IF_FARAWAY
))
{
parse_update_subtlv
(
ifp
,
metric
,
message
+
2
+
parsed_len
,
channels
[
0
]
=
0
;
len
-
parsed_len
,
channels
);
}
else
{
/* This will be overwritten by parse_update_subtlv below. */
if
(
metric
<
256
)
{
/* Assume non-interfering (wired) link. */
channels
[
0
]
=
0
;
}
else
{
/* Assume interfering. */
channels
[
0
]
=
IF_CHANNEL_INTERFERING
;
channels
[
1
]
=
0
;
}
if
(
parsed_len
<
len
)
parse_update_subtlv
(
message
+
2
+
parsed_len
,
len
-
parsed_len
,
channels
);
}
update_route
(
router_id
,
prefix
,
plen
,
src_prefix
,
src_plen
,
update_route
(
router_id
,
prefix
,
plen
,
src_prefix
,
src_plen
,
seqno
,
metric
,
interval
,
neigh
,
nh
,
seqno
,
metric
,
interval
,
neigh
,
nh
,
...
...
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