105 miniroute =
malloc (
sizeof ( *miniroute ) );
107 DBGC (
netdev,
"IPv4 could not add miniroute\n" );
349 &next_hop ) ) !=
NULL ) ) {
380 DBGC2 ( sin_dest->
sin_addr,
"%s len %d proto %d id %04x csum %04x\n",
386 if ( ( ( ~next_hop.
s_addr ) & hostmask.
s_addr ) == 0 ) {
394 ll_dest_buf ) ) !=0){
396 "multicast %s: %s\n",
400 ll_dest = ll_dest_buf;
415 "packet via %s: %s\n",
423 "packet via %s: %s\n",
490 unsigned int flags ) {
516 DBGC (
iphdr->
src,
"IPv4 packet too short at %zd bytes (min " 521 DBGC (
iphdr->
src,
"IPv4 version %#02x not supported\n",
526 if ( hdrlen <
sizeof ( *
iphdr ) ) {
527 DBGC (
iphdr->
src,
"IPv4 header too short at %zd bytes (min " 528 "%zd bytes)\n", hdrlen, sizeof ( *
iphdr ) );
531 if ( hdrlen >
iob_len ( iobuf ) ) {
533 "(packet is %zd bytes)\n", hdrlen,
iob_len ( iobuf ) );
538 "including checksum field, should be 0000)\n", csum );
542 if (
len < hdrlen ) {
543 DBGC (
iphdr->
src,
"IPv4 length too short at %zd bytes " 544 "(header is %zd bytes)\n",
len, hdrlen );
549 "(packet is %zd bytes)\n",
len,
iob_len ( iobuf ) );
559 DBGC2 (
iphdr->
src,
"%s len %d proto %d id %04x csum %04x\n",
568 DBGC (
iphdr->
src,
"IPv4 discarding non-local unicast packet " 599 DBGC (
src.sin.sin_addr,
"IPv4 received packet rejected by " 642 const char *separator =
"...";
649 if (
string == endp )
654 if ( *endp != *separator )
656 if ( ! *(separator++) )
658 string = ( endp + 1 );
683 static const char *
ipv4_ntoa (
const void *net_addr ) {
721 .net_addr_len =
sizeof (
struct in_addr ),
730 .header_len =
sizeof (
struct iphdr ),
766 const char *
value,
void *buf,
size_t len ) {
774 if (
len >
sizeof ( ipv4 ) )
775 len =
sizeof ( ipv4 );
778 return (
sizeof ( ipv4 ) );
796 if (
raw_len <
sizeof ( *ipv4 ) )
804 .description =
"IP address",
806 .type = &setting_type_ipv4,
812 .description =
"Subnet mask",
814 .type = &setting_type_ipv4,
820 .description =
"Default gateway",
822 .type = &setting_type_ipv4,
845 DBGC (
netdev,
"IPv4 sending gratuitous ARP for %s via %s\n",
849 DBGC (
netdev,
"IPv4 could not transmit gratuitous ARP: %s\n",
870 struct in_addr netmask = { 0 };
871 struct in_addr gateway = { 0 };
#define LL_MULTICAST
Packet is a multicast (including broadcast) packet.
#define SETTING_IP4
IPv4 settings.
#define iob_pull(iobuf, len)
Address Resolution Protocol.
struct in_addr netmask
Subnet mask.
#define EINVAL
Invalid argument.
struct arbelprm_rc_send_wqe rc
struct sockaddr_converter ipv4_sockaddr_converter __sockaddr_converter
IPv4 socket address converter.
#define IN_IS_CLASSA(addr)
const char * name
Protocol name.
static const char * ipv4_sock_ntoa(struct sockaddr *sa)
Transcribe IPv4 socket address.
Dynamic Host Configuration Protocol.
struct net_protocol ipv4_protocol __net_protocol
IPv4 protocol.
static int ipv4_has_addr(struct net_device *netdev, struct in_addr addr)
Check if network device has a specific IPv4 address.
unsigned long in_receives
ipSystemStatsInReceives
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
struct list_head list
List of miniroutes.
static void del_ipv4_miniroute(struct ipv4_miniroute *miniroute)
Delete IPv4 minirouting table entry.
An IP system statistics family.
#define TCPIP_EMPTY_CSUM
Empty checksum value.
#define list_add(new, head)
Add a new entry to the head of a list.
#define IP_STATISTICS_IPV4
unsigned long in_addr_errors
ipSystemStatsInAddrErrors
#define iob_push(iobuf, len)
#define DHCP_ROUTERS
Routers.
int fetch_ipv4_setting(struct settings *settings, const struct setting *setting, struct in_addr *inp)
Fetch value of IPv4 address setting.
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.
A fragment reassembly buffer.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
REQUIRING_SYMBOL(ipv4_protocol)
uint64_t address
Base address.
const struct setting ip_setting __setting(SETTING_IP4, ip)
IPv4 address setting.
uint32_t type
Operating system type.
#define sprintf(buf, fmt,...)
Write a formatted string to a buffer.
uint8_t tcpip_proto
Transport-layer protocol number.
struct net_device * netdev
Network device.
#define IN_IS_CLASSB(addr)
struct settings_applicator ipv4_settings_applicator __settings_applicator
IPv4 settings applicator.
#define ENOENT
No such file or directory.
const uint8_t * ll_broadcast
Link-layer broadcast address.
static struct ipv4_miniroute * ipv4_route(unsigned int scope_id, struct in_addr *dest)
Perform IPv4 routing.
A data structure for storing profiling information.
static int ipv4_create_routes(void)
Create IPv4 routing table based on configured settings.
static void profile_stop(struct profiler *profiler)
Stop profiling.
int format_ipv4_setting(const struct setting_type *type __unused, const void *raw, size_t raw_len, char *buf, size_t len)
Format IPv4 address setting value.
struct in_addr address
IPv4 address.
unsigned int scope_id
Scope ID.
static struct settings * netdev_settings(struct net_device *netdev)
Get per-netdevice configuration settings block.
struct in_addr hostmask
Host mask.
A doubly-linked list entry (or list head)
static int ipv4_arp_check(struct net_device *netdev, const void *net_addr)
Check existence of IPv4 address for ARP.
static int arp_tx(struct io_buffer *iobuf, struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest, const void *net_source, const void *ll_source)
Transmit packet, determining link-layer address via ARP.
#define IN_IS_SMALL(mask)
static const char * ipv4_ntoa(const void *net_addr)
Transcribe IPv4 address.
static int ipv4_gratuitous_arp(struct net_device *netdev, struct in_addr address, struct in_addr netmask __unused, struct in_addr gateway __unused)
Send gratuitous ARP, if applicable.
struct ip_statistics_family ipv4_stats_family __ip_statistics_family(IP_STATISTICS_IPV4)
IPv4 statistics family.
A network-layer protocol that relies upon ARP.
uint16_t sin_scope_id
Scope ID (part of struct sockaddr_tcpip)
struct tcpip_net_protocol ipv4_tcpip_protocol __tcpip_net_protocol
IPv4 TCPIP net protocol.
#define list_del(list)
Delete an entry from a list.
#define ENOMEM
Not enough space.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static int ipv4_more_fragments(struct io_buffer *iobuf, size_t hdrlen __unused)
Check if more fragments exist.
unsigned long in_mcast_pkts
ipSystemStatsInMcastPkts
static size_t ipv4_fragment_offset(struct io_buffer *iobuf, size_t hdrlen __unused)
Get IPv4 fragment offset.
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
unsigned int version
IP version.
int ipv4_has_any_addr(struct net_device *netdev)
Check if network device has any IPv4 address.
#define MAX_LL_ADDR_LEN
Maximum length of a link-layer address.
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.
unsigned long out_no_routes
ipSystemStatsOutNoRoutes
Socket address converter.
An IPv4 address/routing table entry.
static int ipv4_settings(int(*apply)(struct net_device *netdev, struct in_addr address, struct in_addr netmask, struct in_addr gateway))
Process IPv4 network device settings.
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
pseudo_bit_t value[0x00020]
#define __unused
Declare a variable or data structure as unused.
struct in_addr gateway
Gateway address, or zero for no gateway.
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
struct net_protocol * net_protocol
Network-layer protocol.
#define INADDR_NET_CLASSC
unsigned long in_truncated_pkts
ipSystemStatsInTruncatedPkts
static struct net_device * netdev
static struct fragment_reassembler ipv4_reassembler
IPv4 fragment reassembler.
struct io_buffer * iobuf
Reassembled packet.
Transport-network layer interface.
#define IP_MASK_MOREFRAGS
static void profile_start(struct profiler *profiler)
Start profiling.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static uint16_t ipv4_pshdr_chksum(struct io_buffer *iobuf, uint16_t csum)
Add IPv4 pseudo-header checksum to existing checksum.
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
int arp_tx_request(struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest, const void *net_source)
Transmit ARP request.
#define DHCP_SUBNET_MASK
Subnet mask.
static struct profiler ipv4_tx_profiler __profiler
Transmit profiler.
Generalized socket address structure.
#define iob_unput(iobuf, len)
char * strerror(int errno)
Retrieve string representation of error number.
static void(* free)(struct refcnt *refcnt))
#define for_each_netdev(netdev)
Iterate over all network devices.
struct net_device_stats rx_stats
RX statistics.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
static struct net_device * ipv4_netdev(struct sockaddr_tcpip *st_dest)
Determine transmitting network device.
static struct ip_statistics ipv4_stats
IPv4 statistics.
unsigned int bad
Count of error completions.
int inet_aton(const char *string, struct in_addr *in)
Parse IPv4 address.
struct arp_net_protocol ipv4_arp_protocol __arp_net_protocol
IPv4 ARP protocol.
IP4_t ip
Destination IP address.
char * inet_ntoa(struct in_addr in)
Convert IPv4 address to dotted-quad notation.
sa_family_t family
Socket address family.
unsigned long out_mcast_pkts
ipSystemStatsOutMcastPkts
static struct net_device * netdev_get(struct net_device *netdev)
Get reference to network device.
static int ipv4_rx(struct io_buffer *iobuf, struct net_device *netdev, const void *ll_dest __unused, const void *ll_source __unused, unsigned int flags)
Process incoming packets.
void * malloc(size_t size)
Allocate memory.
int(* mc_hash)(unsigned int af, const void *net_addr, void *ll_addr)
Hash multicast address.
struct list_head ipv4_miniroutes
List of IPv4 miniroutes.
static int add_ipv4_miniroute(struct net_device *netdev, struct in_addr address, struct in_addr netmask, struct in_addr gateway)
Add IPv4 minirouting table entry.
#define LL_BROADCAST
Packet is a broadcast packet.
A network-layer protocol.
A transport-layer protocol of the TCP/IP stack (eg.
Network device management.
unsigned long out_bcast_pkts
ipSystemStatsOutBcastPkts
uint16_t zero_csum
Preferred zero checksum value.
struct in_addr sin_addr
IPv4 address.
static int ipv4_is_fragment(struct fragment *fragment, struct io_buffer *iobuf, size_t hdrlen __unused)
Check if IPv4 fragment matches fragment reassembly buffer.
unsigned int good
Count of successful completions.
char name[NETDEV_NAME_LEN]
Name of this network device.
#define DHCP_EB_YIADDR
"Your" IP address
int parse_ipv4_setting(const struct setting_type *type __unused, const char *value, void *buf, size_t len)
Parse IPv4 address setting value.
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.
#define INADDR_NET_CLASSA
unsigned long out_requests
ipSystemStatsOutRequests
void * data
Start of data.
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
static int ipv4_sock_aton(const char *string, struct sockaddr *sa)
Parse IPv4 socket address.
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
#define INADDR_NET_CLASSB
int(* apply)(void)
Apply updated settings.
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
A network-layer protocol of the TCP/IP stack (eg.
#define IN_IS_MULTICAST(addr)
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
#define IN_IS_CLASSC(addr)
#define LIST_HEAD_INIT(list)
Initialise a static list head.
static uint8_t next_ident_high
uint16_t tcpip_chksum(const void *data, size_t len)
Calculate TCP/IP checkum.
static int ipv4_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 IP packet.
#define ENETUNREACH
Network unreachable.
unsigned long in_hdr_errors
ipSystemStatsInHdrErrors
const char * name
Protocol name.
#define NULL
NULL pointer (VOID *)
unsigned long in_bcast_pkts
ipSystemStatsInBcastPkts
#define AF_INET
IPv4 Internet addresses.
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 ll_protocol * ll_protocol
Link-layer protocol.
unsigned long out_transmits
ipSystemStatsOutTransmits
unsigned long in_octets
ipSystemStatsInOctets
struct list_head list
List of fragment reassembly buffers.
void * memset(void *dest, int character, size_t len) __nonnull