Using a Write-Data Structure
transmission over the Ethernet network, you provide a pointer to a write-data
structure (Figure, below). A write-data structure contains a series of pairs of
length shorts and pointers. Each pair indicates the length and location of a
portion of the data that constitutes the packet to be sent over the network. The
first length-pointer pair points to a 14-byte header block, which starts with
the destination node hardware address. Note that this is not the AppleTalk
address, but is the hardware address of the destination node. If you are calling
destination node yourself; AppleTalk cannot provide it.
These bytes are followed by the 2-byte Ethernet protocol type. Data may follow
the header block; all other length-pointer pairs point to data. The write-data
structure terminates with a 0 short.
it uses for transmitting data packets. This buffer is large enough to hold the
largest EtherTalk packet, which is 621 bytes in size. If you want to transmit
data packets larger than 768 bytes, call the ESetGeneral function. up to 1514 bytes in size.
An Ethernet write-data structure
The following code example defines an Ethernet write-data structure and then
calls the EWrite function to send a data packet over Ethernet. //Listing Sending a data packet over Ethernet
// Assuming inclusion of
#include <ENET.h>
#define size1 100
# define size2 333
typedef struct{ // write-data structure
short length; // length of nth entry
Ptr aptr; // pointer to nth entry } WDS;
void DoError (OSErr err);
WDS myWDS[4];
// set up the write header
w header[0] = 0x02; // dest node ID
w header[1] = 0x60;
w header[2] = 0x8C;
w header[3] = 0x04;
w header[4] = 0x05;
w header[5] = 0x06;
// bytes 7-12 are reserved
w header[12] = 0x08; // protocol type
w header[13] = 0x00;
myWDS[0].length = 14; // the write header is always 14 bytes
myWDS[0].aptr = (Ptr) w header;
myWDS[1].length = size1;
myWDS[1].aptr = (Ptr) stuff1;
myWDS[2].length = size2;
myWDS[2].aptr = (Ptr) stuff2;
myWDS[3].length = 0; Í// terminator
myPB.EParms1.ePointer = (Ptr) &myWDS;// pointer to write-data structure
myErr = EWrite(&myPB, FALSE); // send something if ( myErr)
DoError( myErr);