gdbudp.c revision a734c64bff58bda2fa48c2795453e092167b0ff7
/*
* Copyright (C) 2008 Stefan Hajnoczi <stefanha@gmail.com>.
*
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <string.h>
#include <byteswap.h>
#include <ipxe/if_ether.h>
#include <ipxe/netdevice.h>
/** @file
*
* GDB over UDP transport
*
*/
enum {
};
static struct net_device *netdev;
static struct sockaddr_in dest_addr;
static struct sockaddr_in source_addr;
/* The device may have been closed between breakpoints */
netdev_open ( netdev );
/* Strictly speaking, we may need to close the device when leaving the interrupt handler */
}
struct udp_header *udphdr;
for ( ; ; ) {
netdev_poll ( netdev );
/* Ethernet header */
goto bad_packet;
}
/* Handle ARP requests so the client can find our MAC */
goto bad_packet;
}
/* Generate an ARP reply */
/* Fix up ethernet header */
continue; /* no need to free iob */
}
goto bad_packet;
}
/* IP header */
goto bad_packet;
}
goto bad_packet;
}
/* UDP header */
goto bad_packet;
}
goto bad_packet;
}
/* Learn the remote connection details */
/* Payload */
goto bad_packet;
}
payload_len -= sizeof ( *udphdr );
if ( payload_len > len ) {
goto bad_packet;
}
return payload_len;
}
cpu_nap();
}
}
struct udp_header *udphdr;
/* Check that we are connected */
return;
}
if ( !iob ) {
return;
}
/* Payload */
/* UDP header */
/* IP header */
/* Ethernet header */
}
/* Release old network device */
netdev_put ( netdev );
if ( !netdev ) {
return NULL;
}
/* Hold network device */
netdev_get ( netdev );
/* Source UDP port */
/* Source IP address */
} else {
netdev_put ( netdev );
return NULL;
}
}
return &udp_gdb_transport;
}
if ( argc != 1 ) {
printf ( "udp: missing <interface> argument\n" );
return 1;
}
return 1;
}
return 0;
}
.name = "udp",
.init = gdbudp_init,
.send = gdbudp_send,
.recv = gdbudp_recv,
};