lwres revision 2358fd9353e91bc2291c165a679af9b3a1b7fb3a
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt$Id: lwres,v 1.1 2000/02/29 20:10:49 explorer Exp $
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt
67adc03ef81fb610f8df093b17f55275ee816754Evan HuntGeneral design:
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt
67adc03ef81fb610f8df093b17f55275ee816754Evan HuntThe lwres library converts structures into wire-format packets for
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunttransmission, and unmarshalls them on receive.
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt
67adc03ef81fb610f8df093b17f55275ee816754Evan HuntMarshalling and unmarshalling:
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt
67adc03ef81fb610f8df093b17f55275ee816754Evan HuntEach structure will have two functions defined, one to take a
67adc03ef81fb610f8df093b17f55275ee816754Evan Huntwire-format packet and convert it into a structure, and another to
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunttake a structure and convert it into a wire-format packet. There
67adc03ef81fb610f8df093b17f55275ee816754Evan Huntis a structure cleanup function that will take the unmarshalled
67adc03ef81fb610f8df093b17f55275ee816754Evan Huntstructure and free any dynamically allocated elements.
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt
67adc03ef81fb610f8df093b17f55275ee816754Evan HuntWire formats:
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt
67adc03ef81fb610f8df093b17f55275ee816754Evan HuntAll integer values are in network byte order.
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt
67adc03ef81fb610f8df093b17f55275ee816754Evan HuntAll addresses are in network byte order. That is, they are directly
67adc03ef81fb610f8df093b17f55275ee816754Evan Huntusable and do not need to be byte swapped, at least for ipv4 and ipv6.
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt
67adc03ef81fb610f8df093b17f55275ee816754Evan HuntAll character strings are prefixed with a length, and are NUL
67adc03ef81fb610f8df093b17f55275ee816754Evan Huntterminated C strings. This is a concession for structure handling on
67adc03ef81fb610f8df093b17f55275ee816754Evan Huntthe receive side, and allows a mapping structure to point to data
67adc03ef81fb610f8df093b17f55275ee816754Evan Huntcontained in the actual receive buffer, eliminating copying.
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt
67adc03ef81fb610f8df093b17f55275ee816754Evan HuntNOOP (aka ping) packet format:
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt lwres_lwpacket_t header;
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt isc_uint16_t datalength;
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt < datalength bytes >
The server simply returns the entire data region in the reply. This
allows the client to determine if the server is operational.
GETADDRSBYNAME:
lwres_lwpacket_t header;
isc_uint16_t naliases;
isc_uint16_t naddrs;
isc_uint16_t real_name_len;
< real_name_len bytes of name >
isc_uint8_t \0
< naliases of
isc_uint16_t len;
< len bytes of name >
isc_uint8_t \0
>
< naddrs of
isc_uint32_t family;
isc_uint16_t len;
< len bytes of address >
>
GETNAMEBYADDR:
lwres_lwpacket_t header;
isc_uint16_t naliases;
isc_uint16_t real_name_len;
< real_name_len bytes of name >
isc_uint8_t \0
< naliases of
isc_uint16_t len;
< len bytes of name >
isc_uint8_t \0
>