128 if (
iob_len ( iob ) <
sizeof ( *udphdr ) ) {
142 payload_len =
ntohs ( udphdr->
len );
143 if ( payload_len <
sizeof ( *udphdr ) || payload_len >
iob_len ( iob ) ) {
146 payload_len -=
sizeof ( *udphdr );
147 iob_pull ( iob,
sizeof ( *udphdr ) );
148 if ( payload_len >
len ) {
186 udphdr =
iob_push ( iob,
sizeof ( *udphdr ) );
231 if (
addr &&
addr->sin_addr.s_addr ) {
243 return &udp_gdb_transport;
248 printf (
"udp: missing <interface> argument\n" );
253 printf (
"%s: device does not exist or has no IP address\n", argv[0] );
void * memswap(void *first, void *second, size_t len)
Swap memory regions.
static void gdbudp_send(const char *buf, size_t len)
uint16_t h_protocol
Protocol ID.
static void * arp_sender_pa(struct arphdr *arphdr)
ARP packet sender protocol address.
#define iob_pull(iobuf, len)
#define iob_put(iobuf, len)
int printf(const char *fmt,...)
Write a formatted string to the console.
static void * arp_target_ha(struct arphdr *arphdr)
ARP packet target hardware address.
static void * arp_target_pa(struct arphdr *arphdr)
ARP packet target protocol address.
#define iob_push(iobuf, len)
int fetch_ipv4_setting(struct settings *settings, const struct setting *setting, struct in_addr *inp)
Fetch value of IPv4 address setting.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
const char * name
Transport name.
static uint8_t dest_eth[ETH_ALEN]
uint8_t ar_hln
Link-layer address length.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
static struct settings * netdev_settings(struct net_device *netdev)
Get per-netdevice configuration settings block.
Address Resolution Protocol constants and types.
uint16_t ar_hrd
Link-layer protocol.
uint8_t h_dest[ETH_ALEN]
Destination MAC address.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static void gdbudp_ensure_netdev_open(struct net_device *netdev)
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
struct gdb_transport udp_gdb_transport __gdb_transport
#define ARPOP_REQUEST
ARP request.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static struct net_device * netdev
void netdev_poll(struct net_device *netdev)
Poll for completed and received packets on network device.
uint16_t sin_port
TCP/IP port (part of struct sockaddr_tcpip)
uint16_t ar_op
ARP opcode.
static int gdbudp_init(int argc, char **argv)
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
#define ARPOP_REPLY
ARP reply.
int netdev_tx(struct net_device *netdev, struct io_buffer *iobuf)
Transmit raw packet via network device.
static struct net_device * netdev_get(struct net_device *netdev)
Get reference to network device.
uint8_t h_source[ETH_ALEN]
Source MAC address.
static void * arp_sender_ha(struct arphdr *arphdr)
ARP packet sender hardware address.
struct gdb_transport * gdbudp_configure(const char *name, struct sockaddr_in *addr)
static struct sockaddr_in source_addr
Network device management.
struct in_addr sin_addr
IPv4 address.
#define iob_reserve(iobuf, len)
void cpu_nap(void)
Sleep with interrupts enabled until next CPU interrupt.
struct net_device * find_netdev(const char *name)
Get network device by name.
void * data
Start of data.
uint16_t ar_pro
Network-layer protocol.
uint8_t ar_pln
Network-layer address length.
static size_t gdbudp_recv(char *buf, size_t len)
GDB remote debugging over UDP.
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
#define ARPHRD_ETHER
Ethernet 10Mbps.
uint16_t tcpip_chksum(const void *data, size_t len)
Calculate TCP/IP checkum.
An Ethernet link-layer header.
#define NULL
NULL pointer (VOID *)
A transport mechanism for the GDB protocol.
int netdev_open(struct net_device *netdev)
Open network device.
void * memset(void *dest, int character, size_t len) __nonnull
struct io_buffer * netdev_rx_dequeue(struct net_device *netdev)
Remove packet from device's receive queue.
static struct sockaddr_in dest_addr