46 #define EINVAL_LEN __einfo_error ( EINFO_EINVAL_LEN ) 47 #define EINFO_EINVAL_LEN \ 48 __einfo_uniqify ( EINFO_EINVAL, 0x01, "Invalid length" ) 49 #define ENOTSUP_VER __einfo_error ( EINFO_ENOTSUP_VER ) 50 #define EINFO_ENOTSUP_VER \ 51 __einfo_uniqify ( EINFO_ENOTSUP, 0x01, "Unsupported version" ) 52 #define ENOTSUP_HDR __einfo_error ( EINFO_ENOTSUP_HDR ) 53 #define EINFO_ENOTSUP_HDR \ 54 __einfo_uniqify ( EINFO_ENOTSUP, 0x02, "Unsupported header type" ) 55 #define ENOTSUP_OPT __einfo_error ( EINFO_ENOTSUP_OPT ) 56 #define EINFO_ENOTSUP_OPT \ 57 __einfo_uniqify ( EINFO_ENOTSUP, 0x03, "Unsupported option" ) 127 "address" :
"prefix" ),
148 sizeof ( miniroute->
address ) ) == 0 ) ) {
165 unsigned int match_len = 0;
169 for ( i = 0 ; i < (
sizeof (
address->s6_addr32 ) /
170 sizeof (
address->s6_addr32[0] ) ) ; i++ ) {
173 miniroute->
address.s6_addr32[i] ) )
177 match_len -=
flsl ( diff );
195 unsigned int match_len;
221 unsigned int remaining;
234 miniroute =
zalloc (
sizeof ( *miniroute ) );
239 sizeof ( miniroute->
address ) );
261 for ( i = 0 ; i < (
sizeof (
address->s6_addr32 ) /
262 sizeof (
address->s6_addr32[0] ) ) ; i++ ) {
266 sizeof ( miniroute->
address ) );
279 sizeof ( miniroute->
router ) );
311 unsigned int best = 0;
312 unsigned int match_len;
361 if ( score > best ) {
413 "option type %#02x:\n",
option->type );
436 struct io_buffer *iobuf,
size_t hdrlen ) {
440 sizeof ( *frag_fhdr ) );
443 ( iobuf->
data + hdrlen -
sizeof ( *fhdr ) );
459 ( iobuf->
data + hdrlen -
sizeof ( *fhdr ) );
473 ( iobuf->
data + hdrlen -
sizeof ( *fhdr ) );
558 &next_hop ) ) !=
NULL ) {
594 ll_dest_buf ) ) !=0){
596 "multicast %s: %s\n",
inet6_ntoa ( next_hop ),
600 ll_dest = ll_dest_buf;
615 "transmit packet via %s: %s\n",
623 "transmit packet via %s: %s\n",
679 "bytes (min %zd bytes)\n",
iob_len ( iobuf ),
687 "supported\n",
ntohl (
iphdr->ver_tc_label ) );
696 "bytes (packet is %zd bytes)\n",
len,
iob_len ( iobuf ));
702 hdrlen =
sizeof ( *iphdr );
721 next_header =
iphdr->next_header;
725 this_header = next_header;
726 ext = ( iobuf->
data + hdrlen );
727 extlen =
sizeof (
ext->pad );
728 if (
iob_len ( iobuf ) < ( hdrlen + extlen ) ) {
730 "extension header type %d at %zd bytes (min " 731 "%zd bytes)\n", this_header,
732 (
iob_len ( iobuf ) - hdrlen ), extlen );
742 extlen +=
ext->common.len;
749 if (
iob_len ( iobuf ) < ( hdrlen + extlen ) ) {
751 "extension header type %d at %zd bytes (min " 752 "%zd bytes)\n", this_header,
753 (
iob_len ( iobuf ) - hdrlen ), extlen );
758 next_header =
ext->common.next_header;
763 extlen, next_header );
791 sizeof (
src.sin6.sin6_addr ) );
796 sizeof (
dest.sin6.sin6_addr ) );
827 sizeof (
in->s6_addr16[0] ) ) );
829 const char *nptr =
string;
840 if (
value > 0xffff ) {
841 DBG (
"IPv6 invalid word value %#lx in \"%s\"\n",
850 if ( *endptr !=
':' ) {
851 DBG (
"IPv6 invalid separator '%c' in \"%s\"\n",
855 if ( ( endptr == nptr ) && ( nptr !=
string ) ) {
857 DBG (
"IPv6 invalid multiple \"::\" in " 858 "\"%s\"\n",
string );
863 nptr = ( endptr + 1 );
867 DBG (
"IPv6 too many words in \"%s\"\n",
string );
874 move_len = ( ( (
void * )
word ) - ( (
void * )
pad ) );
879 DBG (
"IPv6 underlength address \"%s\"\n",
string );
897 char *longest_start =
NULL;
906 for ( i = 0 ; i < (
sizeof (
in->s6_addr16 ) /
907 sizeof (
in->s6_addr16[0] ) ) ; i++ ) {
912 if (
len > longest_len ) {
913 longest_start =
start;
923 if ( longest_start ) {
925 ( longest_start + ( 2 * longest_len ) ) );
926 if (
dest[0] ==
'\0' )
930 return ( ( longest_start == buf ) ? buf : ( buf + 1 ) );
940 static const char *
ipv6_ntoa (
const void *net_addr ) {
951 static char buf[ 39 +
956 const char *netdev_name;
968 ( netdev_name ?
"%" :
"" ),
969 ( netdev_name ? netdev_name :
"" ) );
1000 if ( ( in_string[0] ==
'[' ) && ( in_string[
len - 1 ] ==
']' ) ) {
1001 in_string[
len - 1 ] =
'\0';
1006 netdev_string =
strchr ( in_string,
'%' );
1007 if ( netdev_string )
1008 *(netdev_string++) =
'\0';
1012 goto err_inet6_aton;
1015 if ( netdev_string ) {
1021 goto err_find_netdev;
1051 .net_addr_len =
sizeof (
struct in6_addr ),
1083 const char *
value,
void *buf,
size_t len ) {
1092 if (
len >
sizeof ( ipv6 ) )
1093 len =
sizeof ( ipv6 );
1096 return (
sizeof ( ipv6 ) );
1114 if (
raw_len <
sizeof ( *ipv6 ) )
1125 .description =
"IPv6 address",
1126 .type = &setting_type_ipv6,
1133 .description =
"IPv6 prefix length",
1134 .type = &setting_type_int8,
1141 .description =
"IPv6 gateway",
1142 .type = &setting_type_ipv6,
1179 memset ( &ip6, 0,
sizeof ( ip6 ) );
1181 if ( prefix_len < 0 ) {
1190 if (
len >
sizeof ( ip6 ) )
1191 len =
sizeof ( ip6 );
1193 return sizeof ( ip6 );
1202 return sizeof ( *len6 );
1241 .priv_len =
sizeof (
struct settings ),
1259 struct in6_addr *gateway6 = &gateway6_buf;
1274 ip6,
sizeof ( *ip6 ) );
1280 &len6,
sizeof ( len6 ) );
1288 gateway6,
sizeof ( *gateway6 ) );
1294 DBGC (
netdev,
"IPv6 %s could not add route: %s\n",
#define LL_MULTICAST
Packet is a multicast (including broadcast) packet.
#define IPV6_DEFAULT_PREFIX_LEN
IPv6 default prefix length.
static int ipv6_applies(struct settings *settings __unused, const struct setting *setting)
Check applicability of IPv6 link-local address setting.
#define iob_pull(iobuf, len)
static struct ip_statistics ipv6_stats
IPv6 statistics.
#define EINVAL
Invalid argument.
struct arbelprm_rc_send_wqe rc
const char * name
Protocol name.
#define AF_INET6
IPv6 Internet addresses.
unsigned long in_receives
ipSystemStatsInReceives
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
An IP system statistics family.
char * inet6_ntoa(const struct in6_addr *in)
Convert IPv6 address to standard notation.
struct net_protocol ipv6_protocol __net_protocol
IPv6 protocol.
#define TCPIP_EMPTY_CSUM
Empty checksum value.
#define list_add(new, head)
Add a new entry to the head of a list.
static struct net_device * ipv6_netdev(struct sockaddr_tcpip *st_dest)
Determine transmitting network device.
static int ipv6_sock_aton(const char *string, struct sockaddr *sa)
Parse IPv6 socket address.
IPv6 hop-by-hop options header type.
unsigned long in_addr_errors
ipSystemStatsInAddrErrors
struct settings * parent
Parent settings block.
#define iob_push(iobuf, len)
int tcpip_rx(struct io_buffer *iobuf, struct net_device *netdev, uint8_t tcpip_proto, struct sockaddr_tcpip *st_src, struct sockaddr_tcpip *st_dest, uint16_t pshdr_csum, struct ip_statistics *stats)
Process a received TCP/IP packet.
struct ipv6_miniroute * ipv6_route(unsigned int scope_id, struct in6_addr **dest)
Perform IPv6 routing.
#define IPV6_MAX_PREFIX_LEN
IPv6 maximum prefix length.
A fragment reassembly buffer.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
static unsigned int ipv6_scope(const struct in6_addr *addr)
Determine IPv6 address scope.
uint64_t address
Base address.
uint32_t type
Operating system type.
#define sprintf(buf, fmt,...)
Write a formatted string to a buffer.
Link-local address scope.
static int ipv6_rx(struct io_buffer *iobuf, struct net_device *netdev, const void *ll_dest __unused, const void *ll_source __unused, unsigned int flags __unused)
Process incoming IPv6 packets.
#define IN6_IS_ADDR_SITELOCAL(addr)
#define EPIPE
Broken pipe.
uint8_t tcpip_proto
Transport-layer protocol number.
#define IPV6_CAN_IGNORE_OPT(type)
Test if IPv6 option can be safely ignored.
static uint32_t ipv6col(struct in6_addr *in)
Determine debugging colour for IPv6 debug messages.
static uint16_t ipv6_pshdr_chksum(struct ipv6_header *iphdr, size_t len, int next_header, uint16_t csum)
Calculate IPv6 pseudo-header checksum.
IPv6 type-length-value options.
#define ENOENT
No such file or directory.
int ipv6_add_miniroute(struct net_device *netdev, struct in6_addr *address, unsigned int prefix_len, struct in6_addr *router)
Add IPv6 routing table entry.
int parse_ipv6_setting(const struct setting_type *type __unused, const char *value, void *buf, size_t len)
Parse IPv6 address setting value.
static int ipv6_register_settings(struct net_device *netdev, void *priv)
Register IPv6 link-local address settings.
IPv6 destination options header type.
uint16_t sin6_scope_id
Scope ID (part of struct sockaddr_tcpip)
struct sockaddr_converter ipv6_sockaddr_converter __sockaddr_converter
IPv6 socket address converter.
static const char * ipv6_ntoa(const void *net_addr)
Transcribe IPv6 address.
#define IP_STATISTICS_IPV6
REQUIRING_SYMBOL(ipv6_protocol)
#define NETDEV_NAME_LEN
Maximum length of a network device name.
unsigned int scope_id
Scope ID.
A network upper-layer driver.
static struct settings * netdev_settings(struct net_device *netdev)
Get per-netdevice configuration settings block.
int inet6_aton(const char *string, struct in6_addr *in)
Parse IPv6 address.
Organisation-local address scope.
static void settings_init(struct settings *settings, struct settings_operations *op, struct refcnt *refcnt, const struct settings_scope *default_scope)
Initialise a settings block.
A doubly-linked list entry (or list head)
An IPv6 address/routing table entry.
static int ipv6_fetch(struct settings *settings, struct setting *setting, void *data, size_t len)
Fetch IPv6 link-local address setting.
u32 crc32_le(u32 seed, const void *data, size_t len)
Calculate 32-bit little-endian CRC checksum.
uint32_t start
Starting offset.
struct in6_addr router
Router address.
static int ipv6_is_fragment(struct fragment *fragment, struct io_buffer *iobuf, size_t hdrlen)
Check if fragment matches fragment reassembly buffer.
const struct setting ip6_setting __setting(SETTING_IP6, ip6)
IPv6 address setting.
#define list_del(list)
Delete an entry from a list.
void ipv6_del_miniroute(struct ipv6_miniroute *miniroute)
Delete IPv6 minirouting table entry.
#define ENOMEM
Not enough space.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
unsigned long in_mcast_pkts
ipSystemStatsInMcastPkts
#define __unused
Declare a variable or data structure as unused.
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
unsigned int version
IP version.
#define MAX_LL_ADDR_LEN
Maximum length of a link-layer address.
IPv6 fragment header type.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
struct io_buffer * fragment_reassemble(struct fragment_reassembler *fragments, struct io_buffer *iobuf, size_t *hdrlen)
Reassemble packet.
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
#define container_of(ptr, type, field)
Get containing structure.
unsigned long out_no_routes
ipSystemStatsOutNoRoutes
Socket address converter.
A long option, as used for getopt_long()
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
static struct fragment_reassembler ipv6_reassembler
Fragment reassembler.
pseudo_bit_t value[0x00020]
static int ipv6_create_all_routes(void)
Create IPv6 routing table based on configured settings.
#define IPV6_SETTINGS_NAME
IPv6 link-local address settings block name.
#define list_for_each_entry_reverse(pos, head, member)
Iterate over entries in a list in reverse order.
static size_t ipv6_fragment_offset(struct io_buffer *iobuf, size_t hdrlen)
Get fragment offset.
unsigned long in_truncated_pkts
ipSystemStatsInTruncatedPkts
static struct net_device * netdev
struct net_device * last_opened_netdev(void)
Get most recently opened network device.
struct io_buffer * iobuf
Reassembled packet.
Transport-network layer interface.
char * strcpy(char *dest, const char *src)
Copy string.
#define IPV6_HOP_LIMIT
IPv6 maximum hop limit.
struct list_head list
List of miniroutes.
IPv6 routing header type.
#define IN6_IS_ADDR_LINKLOCAL(addr)
#define IN6_IS_ADDR_UNSPECIFIED(addr)
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
Generalized socket address structure.
#define iob_unput(iobuf, len)
int fetch_setting(struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, void *data, size_t len)
Fetch setting.
char * strerror(int errno)
Retrieve string representation of error number.
struct refcnt refcnt
Reference counter.
static void(* free)(struct refcnt *refcnt))
void * zalloc(size_t size)
Allocate cleared memory.
#define for_each_netdev(netdev)
Iterate over all network devices.
char * strchr(const char *src, int character)
Find character within a string.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
#define IPV6_MASK_VER
IPv6 version mask.
char * strdup(const char *src)
Duplicate string.
static struct settings_operations ipv6_settings_operations
IPv6 link-local address settings operations.
struct list_head ipv6_miniroutes
List of IPv6 miniroutes.
#define ENODEV
No such device.
size_t strlen(const char *src)
Get length of string.
struct net_driver ipv6_driver __net_driver
IPv6 network device driver.
Settings block operations.
sa_family_t family
Socket address family.
unsigned long out_mcast_pkts
ipSystemStatsOutMcastPkts
struct net_device * netdev
Network device.
static struct net_device * netdev_get(struct net_device *netdev)
Get reference to network device.
static const char * ipv6_sock_ntoa(struct sockaddr *sa)
Transcribe IPv6 socket address.
static void ipv6_dump_miniroute(struct ipv6_miniroute *miniroute)
Dump IPv6 routing table entry.
Site-local address scope.
struct net_device * find_netdev_by_scope_id(unsigned int scope_id)
Get network device by scope ID.
int(* mc_hash)(unsigned int af, const void *net_addr, void *ll_addr)
Hash multicast address.
struct settings_applicator ipv6_settings_applicator __settings_applicator
IPv6 settings applicator.
void * memmove(void *dest, const void *src, size_t len) __nonnull
static int ipv6_more_fragments(struct io_buffer *iobuf, size_t hdrlen)
Check if more fragments exist.
static int ipv6_check_options(struct ipv6_header *iphdr, struct ipv6_options_header *options, size_t len)
Check that received options can be safely ignored.
uint16_t ext
Extended status.
#define LL_BROADCAST
Packet is a broadcast packet.
A network-layer protocol.
static unsigned int ipv6_match_len(struct ipv6_miniroute *miniroute, struct in6_addr *address)
Count matching bits of an IPv6 routing table entry prefix.
A transport-layer protocol of the TCP/IP stack (eg.
static int ipv6_tx(struct io_buffer *iobuf, struct tcpip_protocol *tcpip_protocol, struct sockaddr_tcpip *st_src, struct sockaddr_tcpip *st_dest, struct net_device *netdev, uint16_t *trans_csum)
Transmit IPv6 packet.
uint16_t zero_csum
Preferred zero checksum value.
static int ipv6_create_routes(struct net_device *netdev, struct settings *settings)
Create IPv6 routing table based on configured settings.
#define IPV6_VER
IPv6 version.
int order
Sibling ordering.
int format_ipv6_setting(const struct setting_type *type __unused, const void *raw, size_t raw_len, char *buf, size_t len)
Format IPv6 address setting value.
char name[NETDEV_NAME_LEN]
Name of this network device.
int net_tx(struct io_buffer *iobuf, struct net_device *netdev, struct net_protocol *net_protocol, const void *ll_dest, const void *ll_source)
Transmit network-layer packet.
static struct tlan_private * priv
struct net_device * find_netdev(const char *name)
Get network device by name.
unsigned long out_requests
ipSystemStatsOutRequests
void * data
Start of data.
#define IPV6_MASK_MOREFRAGS
More fragments.
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
static int ndp_tx(struct io_buffer *iobuf, struct net_device *netdev, const void *net_dest, const void *net_source, const void *ll_source)
Transmit packet, determining link-layer address via NDP.
Routing table entry address is valid.
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" return dest
uint32_t end
Ending offset.
uint8_t data[48]
Additional event data.
int ipv6_has_addr(struct net_device *netdev, struct in6_addr *addr)
Check if network device has a specific IPv6 address.
#define IN6_IS_ADDR_MULTICAST(addr)
Neighbour discovery protocol.
static int ipv6_link_local(struct in6_addr *addr, struct net_device *netdev)
Construct link-local address via EUI-64.
Routing table entry router address is valid.
int(* apply)(void)
Apply updated settings.
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
int(* applies)(struct settings *settings, const struct setting *setting)
Check applicability of setting.
struct list_head children
Child settings blocks.
int register_settings(struct settings *settings, struct settings *parent, const char *name)
Register settings block.
#define IPV6_MASK_OFFSET
Fragment offset mask.
#define IN6_IS_ADDR_ULA(addr)
A network-layer protocol of the TCP/IP stack (eg.
#define flsl(x)
Find last (i.e.
FILE_LICENCE(GPL2_OR_LATER)
unsigned int prefix_len
Prefix length.
const struct settings_scope ipv6_settings_scope
IPv6 settings scope.
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
#define SETTING_IP6
IPv6 settings.
#define DBG(...)
Print a debugging message.
#define LIST_HEAD_INIT(list)
Initialise a static list head.
const struct settings_scope * scope
Setting scope (or NULL)
#define ENETUNREACH
Network unreachable.
unsigned long in_hdr_errors
ipSystemStatsInHdrErrors
struct ip_statistics_family ipv6_statistics_family __ip_statistics_family(IP_STATISTICS_IPV6)
IPv6 statistics family.
int setting_cmp(const struct setting *a, const struct setting *b)
Compare two settings.
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
const char * name
Protocol name.
#define NULL
NULL pointer (VOID *)
struct in6_addr address
IPv6 address (or prefix if no address is defined)
unsigned long in_bcast_pkts
ipSystemStatsInBcastPkts
static struct ipv6_miniroute * ipv6_miniroute(struct net_device *netdev, struct in6_addr *address)
Find IPv6 routing table entry for a given address.
struct in6_addr prefix_mask
IPv6 prefix mask (derived from prefix length)
unsigned long out_octets
ipSystemStatsOutOctets
uint16_t tcpip_continue_chksum(uint16_t partial, const void *data, size_t len)
Calculate continued TCP/IP checkum.
struct in6_addr sin6_addr
IPv6 address.
struct ll_protocol * ll_protocol
Link-layer protocol.
unsigned long out_transmits
ipSystemStatsOutTransmits
static unsigned int ipv6_multicast_scope(const struct in6_addr *addr)
Get multicast address scope.
unsigned long in_octets
ipSystemStatsInOctets
struct tcpip_net_protocol ipv6_tcpip_protocol __tcpip_net_protocol
IPv6 TCPIP net protocol.
struct list_head list
List of fragment reassembly buffers.
void * memset(void *dest, int character, size_t len) __nonnull
size_t hdrlen
Length of non-fragmentable portion of reassembled packet.