100 hostmask.
s_addr = ~netmask.s_addr;
114 miniroute =
malloc (
sizeof ( *miniroute ) );
116 DBGC (
netdev,
"IPv4 could not add miniroute\n" );
148 const void *routes,
size_t len ) {
156 unsigned int masklen;
162 for (
data = routes, remaining =
len ; remaining ; ) {
168 masklen = ( ( width + 7 ) / 8 );
171 if ( ( masklen +
sizeof ( gateway ) ) > remaining ) {
172 DBGC (
netdev,
"IPv4 invalid static route:\n" );
186 network.
s_addr = ( encoded->address.s_addr & netmask.
s_addr );
188 remaining -= masklen;
192 gateway.
s_addr = encoded->address.s_addr;
193 data +=
sizeof ( gateway );
194 remaining -=
sizeof ( gateway );
198 netmask, gateway ) ) != 0 )
255 }
else if ( gateway.
s_addr ) {
495 &next_hop ) ) !=
NULL ) ) {
513 ( (
netdev->rx_stats.bad & 0xf ) << 4 ) |
514 ( (
netdev->rx_stats.good & 0xf ) << 0 ) );
526 DBGC2 ( sin_dest->
sin_addr,
"%s len %d proto %d id %04x csum %04x\n",
532 if ( ( ( ~next_hop.
s_addr ) & hostmask.
s_addr ) == 0 ) {
535 ll_dest =
netdev->ll_broadcast;
540 ll_dest_buf ) ) !=0){
542 "multicast %s: %s\n",
546 ll_dest = ll_dest_buf;
559 netdev->ll_addr ) ) != 0 ) {
561 "packet via %s: %s\n",
569 "packet via %s: %s\n",
636 unsigned int flags ) {
662 DBGC (
iphdr->
src,
"IPv4 packet too short at %zd bytes (min "
667 DBGC (
iphdr->
src,
"IPv4 version %#02x not supported\n",
672 if ( hdrlen <
sizeof ( *
iphdr ) ) {
673 DBGC (
iphdr->
src,
"IPv4 header too short at %zd bytes (min "
674 "%zd bytes)\n", hdrlen, sizeof ( *
iphdr ) );
677 if ( hdrlen >
iob_len ( iobuf ) ) {
679 "(packet is %zd bytes)\n", hdrlen,
iob_len ( iobuf ) );
684 "including checksum field, should be 0000)\n", csum );
688 if (
len < hdrlen ) {
689 DBGC (
iphdr->
src,
"IPv4 length too short at %zd bytes "
690 "(header is %zd bytes)\n",
len, hdrlen );
695 "(packet is %zd bytes)\n",
len,
iob_len ( iobuf ) );
705 DBGC2 (
iphdr->
src,
"%s len %d proto %d id %04x csum %04x\n",
714 DBGC (
iphdr->
src,
"IPv4 discarding non-local unicast packet "
745 DBGC (
src.sin.sin_addr,
"IPv4 received packet rejected by "
788 const char *separator =
"...";
795 if (
string == endp )
800 if ( *endp != *separator )
802 if ( ! *(separator++) )
804 string = ( endp + 1 );
867 .net_addr_len =
sizeof (
struct in_addr ),
876 .header_len =
sizeof (
struct iphdr ),
884 .net_protocol = &ipv4_protocol,
912 const char *
value,
void *buf,
size_t len ) {
920 if (
len >
sizeof ( ipv4 ) )
921 len =
sizeof ( ipv4 );
924 return (
sizeof ( ipv4 ) );
942 if (
raw_len <
sizeof ( *ipv4 ) )
950 .description =
"IP address",
952 .type = &setting_type_ipv4,
958 .description =
"Subnet mask",
960 .type = &setting_type_ipv4,
966 .description =
"Default gateway",
968 .type = &setting_type_ipv4,
974 .name =
"static-routes",
975 .description =
"Static routes",
977 .type = &setting_type_hex,
996 DBGC (
netdev,
"IPv4 sending gratuitous ARP for %s via %s\n",
1000 DBGC (
netdev,
"IPv4 could not transmit gratuitous ARP: %s\n",
#define NULL
NULL pointer (VOID *)
struct arbelprm_rc_send_wqe rc
pseudo_bit_t value[0x00020]
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" retur dest)
int arp_tx_request(struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest, const void *net_source)
Transmit ARP request.
Address Resolution Protocol.
#define __arp_net_protocol
Declare an ARP protocol.
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)
Transmit packet, determining link-layer address via ARP.
struct bofm_section_header done
uint32_t addr
Buffer address.
const struct setting ip_setting
const struct setting netmask_setting
const struct setting gateway_setting
uint32_t type
Operating system type.
uint8_t data[48]
Additional event data.
uint64_t address
Base address.
struct io_buffer * fragment_reassemble(struct fragment_reassembler *fragments, struct io_buffer *iobuf, size_t *hdrlen)
Reassemble packet.
static struct net_device * netdev
#define AF_INET
IPv4 Internet addresses.
#define __unused
Declare a variable or data structure as unused.
#define DHCP_STATIC_ROUTES
Classless static routes.
#define DHCP_SUBNET_MASK
Subnet mask.
#define DHCP_EB_YIADDR
"Your" IP address
#define DHCP_ROUTERS
Routers.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
#define REQUIRE_OBJECT(object)
Require an object.
#define ENOENT
No such file or directory.
#define EINVAL
Invalid argument.
#define ENETUNREACH
Network unreachable.
#define ENOMEM
Not enough space.
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
#define SETTING_IP4
IPv4 settings.
#define REQUIRING_SYMBOL(symbol)
Specify the file's requiring symbol.
#define IN_IS_CLASSB(addr)
#define IN_IS_CLASSA(addr)
#define INADDR_NET_CLASSC
#define IN_IS_SMALL(mask)
#define IN_IS_CLASSC(addr)
#define INADDR_NET_CLASSB
#define INADDR_NET_CLASSA
#define IN_IS_MULTICAST(addr)
Dynamic Host Configuration Protocol.
#define __profiler
Declare a profiler.
static void profile_stop(struct profiler *profiler)
Stop profiling.
static void profile_start(struct profiler *profiler)
Start profiling.
#define __setting(setting_order, name)
Declare a configuration setting.
#define __settings_applicator
Declare a settings applicator.
Transport-network layer interface.
#define TCPIP_EMPTY_CSUM
Empty checksum value.
#define __tcpip_net_protocol
Declare a TCP/IP network-layer protocol.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * memset(void *dest, int character, size_t len) __nonnull
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
#define iob_push(iobuf, len)
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
#define iob_pull(iobuf, len)
#define iob_unput(iobuf, len)
#define IP_MASK_MOREFRAGS
int ipv4_has_any_addr(struct net_device *netdev)
Check if network device has any IPv4 address.
static size_t ipv4_fragment_offset(struct io_buffer *iobuf, size_t hdrlen __unused)
Get IPv4 fragment offset.
int parse_ipv4_setting(const struct setting_type *type __unused, const char *value, void *buf, size_t len)
Parse IPv4 address setting value.
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.
static int ipv4_arp_check(struct net_device *netdev, const void *net_addr)
Check existence of IPv4 address for ARP.
static uint8_t next_ident_high
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.
static uint16_t ipv4_pshdr_chksum(struct io_buffer *iobuf, uint16_t csum)
Add IPv4 pseudo-header checksum to existing checksum.
static struct fragment_reassembler ipv4_reassembler
IPv4 fragment reassembler.
static int ipv4_add_miniroute(struct net_device *netdev, struct in_addr address, struct in_addr network, struct in_addr netmask, struct in_addr gateway)
Add IPv4 minirouting table entry.
static int ipv4_settings(int(*apply)(struct net_device *netdev, struct in_addr address))
Process IPv4 network device settings.
static const char * ipv4_ntoa(const void *net_addr)
Transcribe IPv4 address.
static int ipv4_more_fragments(struct io_buffer *iobuf, size_t hdrlen __unused)
Check if more fragments exist.
static int ipv4_is_fragment(struct fragment *fragment, struct io_buffer *iobuf, size_t hdrlen __unused)
Check if IPv4 fragment matches fragment reassembly buffer.
static int ipv4_sock_aton(const char *string, struct sockaddr *sa)
Parse IPv4 socket address.
static int ipv4_gratuitous_arp(struct net_device *netdev, struct in_addr address)
Send gratuitous ARP, if applicable.
static int ipv4_add_static(struct net_device *netdev, struct in_addr address, const void *routes, size_t len)
Add static route minirouting table entries.
struct ipv4_miniroute * ipv4_route(unsigned int scope_id, struct in_addr *dest)
Perform IPv4 routing.
char * inet_ntoa(struct in_addr in)
Convert IPv4 address to dotted-quad notation.
static void ipv4_del_miniroute(struct ipv4_miniroute *miniroute)
Delete IPv4 minirouting table entry.
struct list_head ipv4_miniroutes
List of IPv4 miniroutes.
static struct net_device * ipv4_netdev(struct sockaddr_tcpip *st_dest)
Determine transmitting network device.
static int ipv4_has_addr(struct net_device *netdev, struct in_addr addr)
Check if network device has a specific IPv4 address.
int inet_aton(const char *string, struct in_addr *in)
Parse IPv4 address.
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.
static void ipv4_del_miniroutes(void)
Delete IPv4 minirouting table entries.
static int ipv4_apply_routes(void)
Create IPv4 routing table based on configured settings.
static struct ip_statistics ipv4_stats
IPv4 statistics.
static int ipv4_add_miniroutes(struct net_device *netdev, struct in_addr address)
Add IPv4 minirouting table entries.
static const char * ipv4_sock_ntoa(struct sockaddr *sa)
Transcribe IPv4 socket address.
#define IP_STATISTICS_IPV4
#define __ip_statistics_family(order)
Declare an IP system statistics family.
#define LIST_HEAD_INIT(list)
Initialise a static list head.
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
#define list_del(list)
Delete an entry from a list.
void * malloc(size_t size)
Allocate memory.
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.
Network device management.
#define for_each_netdev(netdev)
Iterate over all network devices.
static struct net_device * netdev_get(struct net_device *netdev)
Get reference to network device.
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
#define LL_MULTICAST
Packet is a multicast (including broadcast) packet.
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
#define LL_BROADCAST
Packet is a broadcast packet.
#define __net_protocol
Declare a network-layer protocol.
#define MAX_LL_ADDR_LEN
Maximum length of a link-layer address.
static struct settings * netdev_settings(struct net_device *netdev)
Get per-netdevice configuration settings block.
IP4_t ip
Destination IP address.
static void(* free)(struct refcnt *refcnt))
int fetch_raw_setting_copy(struct settings *settings, const struct setting *setting, void **data)
Fetch value of setting.
int fetch_ipv4_setting(struct settings *settings, const struct setting *setting, struct in_addr *inp)
Fetch value of IPv4 address setting.
#define __sockaddr_converter
Declare a socket address converter.
#define sprintf(buf, fmt,...)
Write a formatted string to a buffer.
char * strerror(int errno)
Retrieve string representation of error number.
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
A network-layer protocol that relies upon ARP.
A fragment reassembly buffer.
struct io_buffer * iobuf
Reassembled packet.
void * data
Start of data.
An IP system statistics family.
An IPv4 address/routing table entry.
struct in_addr gateway
Gateway address, or zero.
struct in_addr network
Subnet network address.
struct in_addr netmask
Subnet mask.
struct list_head list
List of miniroutes.
struct net_device * netdev
Network device.
struct in_addr address
IPv4 address.
struct in_addr hostmask
Host mask.
A doubly-linked list entry (or list head)
char name[NETDEV_NAME_LEN]
Name of this network device.
unsigned int scope_id
Scope ID.
A network-layer protocol.
A data structure for storing profiling information.
Socket address converter.
uint16_t sin_scope_id
Scope ID (part of struct sockaddr_tcpip)
struct in_addr sin_addr
IPv4 address.
Generalized socket address structure.
A network-layer protocol of the TCP/IP stack (eg.
A transport-layer protocol of the TCP/IP stack (eg.
uint8_t tcpip_proto
Transport-layer protocol number.
uint16_t zero_csum
Preferred zero checksum value.
uint16_t tcpip_chksum(const void *data, size_t len)
Calculate TCP/IP checkum.
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.
int32_t before
Initial microcode version.
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
uint16_t tcpip_continue_chksum(uint16_t partial, const void *data, size_t len)
Calculate continued TCP/IP checkum.