Skip to content

Commit

Permalink
Add support for IPv6
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkobak committed Apr 15, 2024
1 parent 4f278a7 commit 5a78572
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/net/if_arp.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#define ARPHRD_CSLIP6 129
#define ARPHRD_PPP 130
#define ARPHRD_LOOPBACK 131
#define ARPHRD_SIT 132 /* sit0 device - IPv6-in-IPv4. */

struct arphdr {
unsigned short int ar_hrd; /* Format of hardware address. */
Expand Down
38 changes: 38 additions & 0 deletions include/net/ip6_route.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Phoenix-RTOS
*
* libphoenix
*
* net/ip6_route.h
*
* Copyright 2024 Phoenix Systems
* Author: Mateusz Kobak
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/


#ifndef _NET_IP6_ROUTE_H_
#define _NET_IP6_ROUTE_H_

#include <netinet/in.h>

/* Needed by route.c in busybox */
struct in6_rtmsg
{
struct in6_addr rtmsg_dst;
struct in6_addr rtmsg_src;
struct in6_addr rtmsg_gateway;
uint32_t rtmsg_type;
uint16_t rtmsg_dst_len;
uint16_t rtmsg_src_len;
uint32_t rtmsg_metric;
unsigned long int rtmsg_info;
uint32_t rtmsg_flags;
int rtmsg_ifindex;
};


#endif /* _NET_IP6_ROUTE_H_ */
3 changes: 3 additions & 0 deletions include/net/route.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#define RTF_WINDOW 0x0080
#define RTF_IRTT 0x0100
#define RTF_REJECT 0x0200
#define RTF_DEFAULT 0x0400
#define RTF_ADDRCONF 0x0800
#define RTF_CACHE 0x1000
#define RTF_NONEXTHOP 0x00200000


Expand Down
64 changes: 64 additions & 0 deletions include/netinet/icmp6.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Phoenix-RTOS
*
* libphoenix
*
* netinet/icmp6.h
*
* Copyright 2024 Phoenix Systems
* Author: Mateusz Kobak
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#ifndef _NETINET_ICMP6_H
#define _NETINET_ICMP6_H

#include <stdint.h>


struct icmp6_hdr {
uint8_t icmp6_type; /* type field */
uint8_t icmp6_code; /* code field */
uint16_t icmp6_cksum; /* checksum field */
union {
uint32_t icmp6_un_data32[1]; /* type-specific field */
uint16_t icmp6_un_data16[2]; /* type-specific field */
uint8_t icmp6_un_data8[4]; /* type-specific field */
} icmp6_dataun;
};

#define icmp6_data32 icmp6_dataun.icmp6_un_data32
#define icmp6_data16 icmp6_dataun.icmp6_un_data16
#define icmp6_data8 icmp6_dataun.icmp6_un_data8
#define icmp6_pptr icmp6_data32[0] /* parameter prob */
#define icmp6_mtu icmp6_data32[0] /* packet too big */
#define icmp6_id icmp6_data16[0] /* echo request/reply */
#define icmp6_seq icmp6_data16[1] /* echo request/reply */
#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */

#define ICMP6_DST_UNREACH 1
#define ICMP6_PACKET_TOO_BIG 2
#define ICMP6_TIME_EXCEEDED 3
#define ICMP6_PARAM_PROB 4

#define ICMP6_ECHO_REQUEST 128
#define ICMP6_ECHO_REPLY 129
#define MLD_LISTENER_QUERY 130
#define MLD_LISTENER_REPORT 131
#define MLD_LISTENER_REDUCTION 132

#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
#define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */

#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
#define ICMP6_DST_UNREACH_NOPORT 4 /* bad port */

#define ICMP6_TIME_EXCEED_TRANSIT 0 /* Hop Limit == 0 in transit */
#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* Reassembly time out */


#endif /* _NETINET_ICMP6_H */
1 change: 1 addition & 0 deletions include/netinet/in.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ enum {
IPPROTO_GRE = 47,
IPPROTO_ESP = 50,
IPPROTO_AH = 51,
IPPROTO_ICMPV6 = 58,
IPPROTO_SCTP = 132,
IPPROTO_UDPLITE = 136,
IPPROTO_RAW = 255,
Expand Down
9 changes: 9 additions & 0 deletions include/sys/sockdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,13 @@
#define SOCK_NONBLOCK 0x8000
#define SOCK_CLOEXEC 0x4000

#define SOL_IPV6 41 /* IPPROTO_IPV6 */
#define SOL_RAW 255 /* IPPROTO_RAW */

/*
* Options for level IPPROTO_IPV6
*/
#define IPV6_CHECKSUM 7
#define IPV6_V6ONLY 27

#endif

0 comments on commit 5a78572

Please sign in to comment.