XDR
(require xdr) | package: XDR |
This package provides a Racket implementation of the XDR (External Data Representation) protocol.
The process for leveraging XDR (RFC 4506) is as follows:
- Define XDR configuration files. As an example, the Stellar Blockchain network uses XDR to define the structure of its messages. An XDR enum might look like:
- Use the xdr-parse function to parse the XDR configuration files and generate Racket code.
(xdr-parse "path/to/xdr/file")
- Use the generated Racket code to encode and decode XDR data.
(xdr-enum-colors RED) (xdr-enum-colors 2)
1 XDR Data Types
This implementation provides the following XDR data types as defined in RFC 4506:
xdr-int: 32-bit signed integers in two’s complement notation, range [-2147483648, 2147483647]
xdr-uint: 32-bit unsigned integers, range [0, 4294967295]
xdr-hyper: 64-bit signed integers in two’s complement notation
xdr-uhyper: 64-bit unsigned integers, range [0, 18446744073709551615]
xdr-boolean: Boolean values encoded as 32-bit integers (0 for FALSE, 1 for TRUE)
xdr-string: Variable-length ASCII strings with length prefix and padding
xdr-opaque: Variable-length opaque data with length prefix and padding
xdr-fixed-opaque: Fixed-length opaque data with padding to 4-byte boundaries
xdr-float: Single-precision floating-point numbers in IEEE 754 format
xdr-double: Double-precision floating-point numbers in IEEE 754 format
xdr-union: Union data type
xdr-quadruple: Quadruple-precision floating-point numbers in IEEE 754 format
Each type includes encoding and decoding functions following the pattern xdr-encode-TYPE and xdr-decode-TYPE.
2 XDR in the Wild
Stellar Blockchain Network stellar-xdr
Network File System (NFS) protocol
ZFS (Zettabyte File System)
Network Data Management Protocol (NDMP)
Open Network Computing Remote Procedure Call (Sun RPC)
EMC NetWorker backup software
NetCDF scientific data format
R language and environment for statistical computing
HTTP-NG binary wire protocol
SpiderMonkey JavaScript engine (for serializing compiled JavaScript code)
Ganglia distributed monitoring system
sFlow network monitoring standard
libvirt virtualization library API
Firebird database server (remote binary wire protocol)
Sun Microsystems (original developer in the 1980s)
3 License
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.