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
a349e291
Commit
a349e291
authored
Feb 19, 2014
by
Daniele Lacamera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Experimental inclusion of ipv6 branch elements
parent
faaf2011
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
128 additions
and
18 deletions
+128
-18
Makefile
Makefile
+10
-0
include/pico_constants.h
include/pico_constants.h
+3
-0
include/pico_device.h
include/pico_device.h
+4
-0
include/pico_frame.h
include/pico_frame.h
+14
-0
modules/pico_ipv6.h
modules/pico_ipv6.h
+82
-12
modules/pico_socket_tcp.c
modules/pico_socket_tcp.c
+12
-4
stack/pico_socket.c
stack/pico_socket.c
+2
-2
stack/pico_stack.c
stack/pico_stack.c
+1
-0
No files found.
Makefile
View file @
a349e291
...
...
@@ -34,6 +34,10 @@ ZMQ?=1
OLSR
?=
1
SLAACV4
?=
1
#IPv6 related
IPV6
?=
0
ICMP6
?=
0
CFLAGS
=
-Iinclude
-Imodules
-Wall
-Wdeclaration-after-statement
-W
-Wextra
-Wshadow
-Wcast-qual
-Wwrite-strings
-Wmissing-field-initializers
$(EXTRA_CFLAGS)
# extra flags recommanded by TIOBE TICS framework to score an A on compiler warnings
CFLAGS
+=
-Wconversion
...
...
@@ -186,6 +190,12 @@ endif
ifneq
($(SLAACV4),0)
include
rules/slaacv4.mk
endif
ifneq
($(IPV6),0)
include
rules/ipv6.mk
endif
ifneq
($(ICMP6),0)
include
rules/icmp6.mk
endif
all
:
mod core lib
...
...
include/pico_constants.h
View file @
a349e291
...
...
@@ -115,6 +115,9 @@ static inline uint64_t long_long_be(uint64_t le)
/*** *** *** *** *** *** ***
*** ARP CONFIG ***
*** *** *** *** *** *** ***/
#include "pico_addressing.h"
/* Maximum amount of accepted ARP requests per burst interval */
#define PICO_ARP_MAX_RATE 1
/* Duration of the burst interval in milliseconds */
...
...
include/pico_device.h
View file @
a349e291
...
...
@@ -9,6 +9,7 @@
#include "pico_frame.h"
#include "pico_addressing.h"
#include "pico_tree.h"
#include "pico_ipv6_nd.h"
#define MAX_DEVICE_NAME 16
...
...
@@ -30,6 +31,9 @@ struct pico_device {
int
__serving_interrupt
;
/* used to signal the upper layer the number of events arrived since the last processing */
volatile
int
eventCnt
;
#ifdef PICO_SUPPORT_IPV6
struct
pico_nd_hostvars
hostvars
;
#endif
};
int
pico_device_init
(
struct
pico_device
*
dev
,
const
char
*
name
,
uint8_t
*
mac
);
...
...
include/pico_frame.h
View file @
a349e291
...
...
@@ -94,4 +94,18 @@ static inline int pico_is_digit(char c)
return
1
;
}
static
inline
int
pico_is_hex
(
char
c
)
{
if
(
c
>=
'0'
&&
c
<=
'9'
)
return
1
;
if
(
c
>=
'a'
&&
c
<=
'f'
)
return
1
;
if
(
c
>=
'A'
&&
c
<=
'F'
)
return
1
;
return
0
;
}
#endif
modules/pico_ipv6.h
View file @
a349e291
...
...
@@ -5,26 +5,96 @@
.
*********************************************************************/
#ifndef INCLUDE_PICO_IPV6
#define INCLUDE_PICO_IPV6
#ifndef
_
INCLUDE_PICO_IPV6
#define
_
INCLUDE_PICO_IPV6
#include "pico_addressing.h"
#include "pico_protocol.h"
#define PICO_SIZE_IP6HDR ((sizeof(struct pico_ipv6_hdr)))
#define PICO_IPV6_DEFAULT_HOP 64
#define PICO_IPV6_MIN_MTU 1280
extern
const
uint8_t
PICO_IP6_ANY
[
PICO_SIZE_IP6
];
extern
struct
pico_protocol
pico_proto_ipv6
;
extern
const
uint8_t
PICO_IPV6_ANY
[
PICO_SIZE_IP6
];
struct
__attribute__
((
packed
))
pico_ipv6_hdr
{
uint32_t
vtf
;
uint16_t
len
;
uint8_t
nxthdr
;
uint8_t
hop
;
struct
pico_ip6
src
;
struct
pico_ip6
dst
;
uint8_t
extensions
[
0
];
};
struct
__attribute__
((
packed
))
pico_ipv6_pseudo_hdr
{
struct
pico_ip6
src
;
struct
pico_ip6
dst
;
uint32_t
len
;
uint8_t
zero
[
3
];
uint8_t
nxthdr
;
};
struct
pico_ipv6_link
{
struct
pico_device
*
dev
;
struct
pico_ip6
address
;
struct
pico_ip6
netmask
;
uint8_t
istentative
:
1
;
uint8_t
isduplicate
:
1
;
};
struct
__attribute__
((
packed
))
pico_ipv6_exthdr
{
uint8_t
nxthdr
;
union
{
struct
{
uint8_t
len
;
uint8_t
options
[
0
];
}
hopbyhop
;
struct
{
uint8_t
len
;
uint8_t
options
[
0
];
}
destopt
;
/* This module is responsible for routing outgoing packets and
* delivering incoming packets to other layers
*/
struct
{
uint8_t
len
;
uint8_t
routtype
;
uint8_t
segleft
;
}
routing
;
/* Interface for processing incoming ipv6 packets (decap/deliver) */
int
pico_ipv6_process_in
(
struct
pico_frame
*
f
);
struct
{
uint8_t
res
;
uint8_t
frm
[
2
];
uint8_t
id
[
4
];
}
fragm
;
}
ext
;
};
/* Interface for processing outgoing ipv6 frames (encap/push) */
int
pico_ipv6_process_out
(
struct
pico_frame
*
f
);
int
pico_string_to_ipv6
(
const
char
*
ipstr
,
uint8_t
*
ip
);
int
pico_ipv6_to_string
(
char
*
ipbuf
,
const
uint8_t
ip
[
PICO_SIZE_IP6
]);
int
pico_ipv6_is_unicast
(
const
uint8_t
addr
[
PICO_SIZE_IP6
]);
int
pico_ipv6_is_multicast
(
const
uint8_t
addr
[
PICO_SIZE_IP6
]);
int
pico_ipv6_is_global
(
const
uint8_t
addr
[
PICO_SIZE_IP6
]);
int
pico_ipv6_is_uniquelocal
(
const
uint8_t
addr
[
PICO_SIZE_IP6
]);
int
pico_ipv6_is_sitelocal
(
const
uint8_t
addr
[
PICO_SIZE_IP6
]);
int
pico_ipv6_is_linklocal
(
const
uint8_t
addr
[
PICO_SIZE_IP6
]);
int
pico_ipv6_is_solicited
(
const
uint8_t
addr
[
PICO_SIZE_IP6
]);
int
pico_ipv6_is_unspecified
(
const
uint8_t
addr
[
PICO_SIZE_IP6
]);
/* Return estimated overhead for ipv6 frames to define allocation */
int
pico_ipv6_overhead
(
struct
pico_frame
*
f
);
int
pico_ipv6_frame_push
(
struct
pico_frame
*
f
,
struct
pico_ip6
*
dst
,
uint8_t
proto
);
int
pico_ipv6_rebound
(
struct
pico_frame
*
f
);
int
pico_ipv6_route_add
(
struct
pico_ip6
address
,
struct
pico_ip6
netmask
,
struct
pico_ip6
gateway
,
int
metric
,
struct
pico_ipv6_link
*
link
);
void
pico_ipv6_unreachable
(
struct
pico_frame
*
f
,
uint8_t
code
);
int
pico_ipv6_link_add
(
struct
pico_device
*
dev
,
struct
pico_ip6
address
,
struct
pico_ip6
netmask
);
int
pico_ipv6_link_del
(
struct
pico_device
*
dev
,
struct
pico_ip6
address
);
int
pico_ipv6_cleanup_links
(
struct
pico_device
*
dev
);
struct
pico_ipv6_link
*
pico_ipv6_link_istentative
(
struct
pico_ip6
*
address
);
struct
pico_ipv6_link
*
pico_ipv6_link_get
(
struct
pico_ip6
*
address
);
struct
pico_device
*
pico_ipv6_link_find
(
struct
pico_ip6
*
address
);
struct
pico_ip6
pico_ipv6_route_get_gateway
(
struct
pico_ip6
*
addr
);
struct
pico_ip6
*
pico_ipv6_source_find
(
const
struct
pico_ip6
*
dst
);
#endif
modules/pico_socket_tcp.c
View file @
a349e291
#include <stdint.h>
#include "pico_socket.h"
#include "pico_ipv4.h"
#include "pico_ipv6.h"
#include "pico_tcp.h"
int
pico_getsockopt_tcp
(
struct
pico_socket
*
s
,
int
option
,
void
*
value
)
...
...
@@ -104,16 +105,23 @@ int pico_socket_tcp_deliver(struct pico_sockport *sp, struct pico_frame *f)
#endif
#ifdef PICO_SUPPORT_IPV6
if
(
IS_IPV6
(
f
))
{
struct
pico_ipv6_hdr
*
ip6hdr
=
(
struct
pico_ipv6_hdr
*
)(
f
->
net_hdr
);
if
((
s
->
remote_port
==
localport
))
{
struct
pico_ip6
s_local
=
{{
0
}},
s_remote
=
{{
0
}},
p_src
=
{{
0
}},
p_dst
=
{{
0
}};
struct
pico_ipv6_hdr
*
ip6hdr
=
(
struct
pico_ipv6_hdr
*
)(
f
->
net_hdr
);
s_local
=
s
->
local_addr
.
ip6
;
s_remote
=
s
->
remote_addr
.
ip6
;
p_src
=
ip6hdr
->
src
;
p_dst
=
ip6hdr
->
dst
;
if
((
s
->
remote_port
==
tr
->
sport
)
&&
(
!
memcmp
(
s_remote
.
addr
,
p_src
.
addr
,
PICO_SIZE_IP6
))
&&
((
!
memcmp
(
s_local
.
addr
,
PICO_IP6_ANY
,
PICO_SIZE_IP6
))
||
(
!
memcmp
(
s_local
.
addr
,
p_dst
.
addr
,
PICO_SIZE_IP6
))))
{
found
=
s
;
break
;
}
else
if
(
s
->
remote_port
==
0
)
{
}
else
if
((
s
->
remote_port
==
0
)
&&
/* not connected... listening */
((
!
memcmp
(
s_local
.
addr
,
PICO_IP6_ANY
,
PICO_SIZE_IP6
))
||
(
!
memcmp
(
s_local
.
addr
,
p_dst
.
addr
,
PICO_SIZE_IP6
))))
{
/* listen socket */
found
=
s
;
}
}
#endif
}
/* FOREACH */
if
(
found
!=
NULL
)
{
...
...
stack/pico_socket.c
View file @
a349e291
...
...
@@ -92,7 +92,7 @@ static int32_t socket_cmp_ipv6(struct pico_socket *a, struct pico_socket *b)
(
void
)
a
;
(
void
)
b
;
#ifdef PICO_SUPPORT_IPV6
if
((
memcmp
(
a
->
local_addr
.
ip6
.
addr
,
PICO_IP6_ANY
,
PICO_SIZE_IP6
)
==
0
)
||
memcmp
(
(
b
->
local_addr
.
ip6
.
addr
,
PICO_IP6_ANY
,
PICO_SIZE_IP6
)
==
0
))
if
((
memcmp
(
a
->
local_addr
.
ip6
.
addr
,
PICO_IP6_ANY
,
PICO_SIZE_IP6
)
==
0
)
||
(
memcmp
(
b
->
local_addr
.
ip6
.
addr
,
PICO_IP6_ANY
,
PICO_SIZE_IP6
)
==
0
))
ret
=
0
;
else
ret
=
memcmp
(
a
->
local_addr
.
ip6
.
addr
,
b
->
local_addr
.
ip6
.
addr
,
PICO_SIZE_IP6
);
...
...
@@ -874,7 +874,7 @@ static struct pico_remote_endpoint *pico_socket_sendto_destination_ipv6(struct p
return
NULL
;
}
memcpy
(
ep
->
remote_addr
.
ip6
,
dst
,
sizeof
(
struct
pico_ip6
));
memcpy
(
&
ep
->
remote_addr
.
ip6
,
dst
,
sizeof
(
struct
pico_ip6
));
ep
->
remote_port
=
port
;
#endif
return
ep
;
...
...
stack/pico_stack.c
View file @
a349e291
...
...
@@ -21,6 +21,7 @@
#include "pico_ipv4.h"
#include "pico_ipv6.h"
#include "pico_icmp4.h"
#include "pico_icmp6.h"
#include "pico_igmp.h"
#include "pico_udp.h"
#include "pico_tcp.h"
...
...
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