Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
P
picotcp
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
insane-adding-machines
picotcp
Commits
674e20db
Commit
674e20db
authored
Feb 20, 2014
by
Daniele Lacamera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed some coding style violations in ipv6
parent
9211f572
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
28 deletions
+32
-28
modules/pico_ipv6.c
modules/pico_ipv6.c
+31
-27
modules/pico_ipv6.h
modules/pico_ipv6.h
+1
-1
No files found.
modules/pico_ipv6.c
View file @
674e20db
...
...
@@ -71,19 +71,34 @@ struct pico_ipv6_route
uint32_t
metric
;
};
static
int
ipv6_
link_compare
(
void
*
ka
,
void
*
k
b
)
static
int
ipv6_
compare
(
struct
pico_ip6
*
a
,
struct
pico_ip6
*
b
)
{
struct
pico_ipv6_link
*
a
=
ka
,
*
b
=
kb
;
uint32_t
*
b_addr
=
(
uint32_t
*
)
b
->
address
.
addr
,
*
a_addr
=
(
uint32_t
*
)
a
->
address
.
addr
;
uint32_t
*
b_addr
=
(
uint32_t
*
)
b
->
addr
,
*
a_addr
=
(
uint32_t
*
)
a
->
addr
;
uint32_t
la
,
lb
;
int
i
;
for
(
i
=
0
;
i
<
4
;
++
i
)
{
if
(
long_be
(
a_addr
[
i
])
<
long_be
(
b_addr
[
i
]))
la
=
long_be
(
a_addr
[
i
]);
lb
=
long_be
(
b_addr
[
i
]);
if
(
la
<
lb
)
return
-
1
;
if
(
long_be
(
a_addr
[
i
])
>
long_be
(
b_addr
[
i
]))
if
(
la
>
lb
)
return
1
;
}
return
0
;
}
static
int
ipv6_link_compare
(
void
*
ka
,
void
*
kb
)
{
struct
pico_ipv6_link
*
a
=
ka
,
*
b
=
kb
;
struct
pico_ip6
*
a_addr
,
*
b_addr
;
int
ret
;
a_addr
=
&
a
->
address
;
b_addr
=
&
b
->
address
;
ret
=
ipv6_compare
(
a_addr
,
b_addr
);
if
(
ret
)
return
ret
;
/* zero can be assigned multiple times (e.g. for DHCP) */
if
(
a
->
dev
!=
NULL
&&
b
->
dev
!=
NULL
&&
!
memcmp
(
a
->
address
.
addr
,
PICO_IP6_ANY
,
PICO_SIZE_IP6
)
&&
!
memcmp
(
b
->
address
.
addr
,
PICO_IP6_ANY
,
PICO_SIZE_IP6
))
{
/* XXX change PICO_IP6_ANY */
...
...
@@ -100,28 +115,17 @@ static int ipv6_link_compare(void *ka, void *kb)
static
int
ipv6_route_compare
(
void
*
ka
,
void
*
kb
)
{
struct
pico_ipv6_route
*
a
=
ka
,
*
b
=
kb
;
uint32_t
*
b_addr
,
*
a_addr
=
NULL
;
int
i
;
int
ret
;
/* Routes are sorted by (host side) netmask len, then by addr, then by metric. */
a_addr
=
(
uint32_t
*
)
a
->
netmask
.
addr
;
b_addr
=
(
uint32_t
*
)
b
->
netmask
.
addr
;
for
(
i
=
0
;
i
<
4
;
++
i
)
{
if
(
long_be
(
a_addr
[
i
])
<
long_be
(
b_addr
[
i
]))
return
-
1
;
ret
=
ipv6_compare
(
&
a
->
netmask
,
&
b
->
netmask
);
if
(
ret
)
return
ret
;
if
(
long_be
(
a_addr
[
i
])
>
long_be
(
b_addr
[
i
]))
return
1
;
}
a_addr
=
(
uint32_t
*
)
a
->
dest
.
addr
;
b_addr
=
(
uint32_t
*
)
b
->
dest
.
addr
;
for
(
i
=
0
;
i
<
4
;
++
i
)
{
if
(
long_be
(
a_addr
[
i
])
<
long_be
(
b_addr
[
i
]))
return
-
1
;
ret
=
ipv6_compare
(
&
a
->
dest
,
&
b
->
dest
);
if
(
ret
)
return
ret
;
if
(
long_be
(
a_addr
[
i
])
>
long_be
(
b_addr
[
i
]))
return
1
;
}
if
(
a
->
metric
<
b
->
metric
)
return
-
1
;
...
...
@@ -661,7 +665,7 @@ int pico_ipv6_process_out(struct pico_protocol *self, struct pico_frame *f)
*/
static
struct
pico_frame
*
pico_ipv6_alloc
(
struct
pico_protocol
*
self
,
uint16_t
size
)
{
struct
pico_frame
*
f
=
pico_frame_alloc
((
uint32_t
)
size
+
PICO_SIZE_IP6HDR
+
PICO_SIZE_ETHHDR
);
struct
pico_frame
*
f
=
pico_frame_alloc
((
uint32_t
)
(
size
+
PICO_SIZE_IP6HDR
+
PICO_SIZE_ETHHDR
)
);
IGNORE_PARAMETER
(
self
);
...
...
@@ -674,7 +678,7 @@ static struct pico_frame *pico_ipv6_alloc(struct pico_protocol *self, uint16_t s
f
->
transport_hdr
=
f
->
net_hdr
+
PICO_SIZE_IP6HDR
;
f
->
transport_len
=
(
uint16_t
)
size
;
/* PICO_SIZE_ETHHDR is accounted for in pico_ethernet_send */
f
->
len
=
(
uint32_t
)
size
+
PICO_SIZE_IP6HDR
;
f
->
len
=
(
uint32_t
)
(
size
+
PICO_SIZE_IP6HDR
)
;
return
f
;
}
...
...
modules/pico_ipv6.h
View file @
674e20db
...
...
@@ -10,7 +10,7 @@
#include "pico_addressing.h"
#include "pico_protocol.h"
#define PICO_SIZE_IP6HDR ((sizeof(struct pico_ipv6_hdr)))
#define PICO_SIZE_IP6HDR ((
uint32_t)(
sizeof(struct pico_ipv6_hdr)))
#define PICO_IPV6_DEFAULT_HOP 64
#define PICO_IPV6_MIN_MTU 1280
...
...
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