Line 162... |
Line 162... |
@return The length if successful, a negative value otherwise. */
|
@return The length if successful, a negative value otherwise. */
|
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
static ssize_t
|
static ssize_t
|
eth_write_file_packet (struct eth_device *eth,
|
eth_write_file_packet (struct eth_device *eth,
|
unsigned char *buf,
|
unsigned char *buf,
|
unsigned long int length)
|
int32_t length)
|
{
|
{
|
ssize_t nwritten;
|
ssize_t nwritten;
|
|
|
/* Write length to file. */
|
/* Write length to file. */
|
nwritten = write (eth->txfd, &(length), sizeof (length));
|
nwritten = write (eth->txfd, &(length), sizeof (length));
|
Line 441... |
Line 441... |
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
static ssize_t
|
static ssize_t
|
eth_read_file_packet (struct eth_device *eth,
|
eth_read_file_packet (struct eth_device *eth,
|
unsigned char *buf)
|
unsigned char *buf)
|
{
|
{
|
ssize_t packet_length;
|
int32_t packet_length;
|
ssize_t nread;
|
ssize_t nread;
|
|
|
/* Read packet length. We may be at EOF. */
|
/* Read packet length. We may be at EOF. */
|
nread = read (eth->rxfd, &(packet_length), sizeof (packet_length));
|
nread = read (eth->rxfd, &(packet_length), sizeof (packet_length));
|
|
|
Line 460... |
Line 460... |
}
|
}
|
|
|
/* Packet must be big enough to hold a header */
|
/* Packet must be big enough to hold a header */
|
if (packet_length < ETHER_HDR_LEN)
|
if (packet_length < ETHER_HDR_LEN)
|
{
|
{
|
fprintf (stderr, "Warning: Ethernet packet length %zd too small.\n",
|
fprintf (stderr, "Warning: Ethernet packet length %d too small.\n",
|
packet_length);
|
packet_length);
|
return -1;
|
return -1;
|
}
|
}
|
|
|
/* Read the packet proper. */
|
/* Read the packet proper. */
|
Line 474... |
Line 474... |
{
|
{
|
fprintf (stderr, "ERROR: Failed to read packet from file.\n");
|
fprintf (stderr, "ERROR: Failed to read packet from file.\n");
|
return -1;
|
return -1;
|
}
|
}
|
|
|
return packet_length;
|
return (ssize_t)packet_length;
|
|
|
} /* eth_read_file_packet () */
|
} /* eth_read_file_packet () */
|
|
|
|
|
#if HAVE_LINUX_IF_TUN_H==1
|
#if HAVE_LINUX_IF_TUN_H==1
|