116 .net_proto =
htons ( 0x6950 ),
158 printf (
"\nLength mismatch: sent %zd, received %zd",
162 DBG (
"Received:\n" );
170 printf (
"\nContent mismatch" );
173 DBG (
"Received:\n" );
195 size_t mtu,
int broadcast ) {
201 unsigned int successes;
207 if ( (
rc =
ifopen ( receiver ) ) != 0 )
217 if (
mtu <
sizeof ( *
seq ) )
218 mtu =
sizeof ( *seq );
222 seq = ( (
void * ) buf );
225 ll_dest = ( broadcast ?
sender->ll_broadcast : receiver->
ll_addr );
228 printf (
"Performing %sloopback test from %s to %s with %zd byte MTU\n",
229 ( broadcast ?
"broadcast " :
"" ),
sender->name,
239 for ( successes = 0 ; ; successes++ ) {
242 printf (
"\r%d", successes );
246 for ( i =
sizeof ( *
seq ) ; i <
mtu ; i++ )
250 printf (
"\nFailed to allocate I/O buffer" );
259 &lotest_protocol, ll_dest,
260 sender->ll_addr ) ) != 0 ) {
261 printf (
"\nFailed to transmit packet: %s",
#define EINVAL
Invalid argument.
static struct net_device * lotest_receiver
Current loopback test receiver.
struct arbelprm_rc_send_wqe rc
const char * name
Protocol name.
#define iob_put(iobuf, len)
int printf(const char *fmt,...)
Write a formatted string to the console.
void net_poll(void)
Poll the network stack.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static void lotest_flush(void)
Discard all received loopback test packets.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
#define ECANCELED
Operation canceled.
u16 seq
802.11 Sequence Control field
int loopback_test(struct net_device *sender, struct net_device *receiver, size_t mtu, int broadcast)
Perform loopback test between two network devices.
int iflinkwait(struct net_device *netdev, unsigned long timeout, int verbose)
Wait for link-up, with status indication.
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
#define list_del(list)
Delete an entry from a list.
#define ENOMEM
Not enough space.
#define iob_disown(iobuf)
Disown an I/O buffer.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define __unused
Declare a variable or data structure as unused.
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
static LIST_HEAD(lotest_queue)
Loopback testing received packets.
static int loopback_wait(void *data, size_t len)
Wait for packet to be received.
static struct net_device * netdev
#define MAX_LL_HEADER_LEN
Maximum length of a link-layer header.
static struct io_buffer * lotest_dequeue(void)
Dequeue received packet.
static int lotest_rx(struct io_buffer *iobuf, struct net_device *netdev, const void *ll_dest __unused, const void *ll_source __unused, unsigned int flags __unused)
Process received packet.
static const char * lotest_ntoa(const void *net_addr __unused)
Transcribe network-layer address.
int getchar(void)
Read a single character from any console.
char * strerror(int errno)
Retrieve string representation of error number.
static void(* free)(struct refcnt *refcnt))
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
long int random(void)
Generate a pseudo-random number between 0 and 2147483647L or 2147483562?
void * malloc(size_t size)
Allocate memory.
struct stp_switch sender
Sender switch.
int ifopen(struct net_device *netdev)
Open network device.
A network-layer protocol.
Network device management.
#define iob_reserve(iobuf, len)
char name[NETDEV_NAME_LEN]
Name of this network device.
struct list_head list
List of which this buffer is a member.
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.
void * data
Start of data.
uint8_t data[48]
Additional event data.
Network interface management.
void ifstat(struct net_device *netdev)
Print status of network device.
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
#define DBG(...)
Print a debugging message.
static struct net_protocol lotest_protocol __net_protocol
Loopback test network-layer protocol.
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
#define NULL
NULL pointer (VOID *)
int iskey(void)
Check for available input on any console.