Oberon || Library || Module Index || Search Engine || Definition || Module


Ulm's Oberon Library:
IPv4Addresses


NAME

IPv4Addresses - support of IPv4 addresses

SYNOPSIS

TYPE PortNumber = Types.Int16;    (* 2-byte-integer *)
TYPE Address = Types.Int32;       (* 4-byte-integer *)
TYPE SocketAddress =
      RECORD
         (Objects.ObjectRec)
         (* in network order *)
         host: Address;
         portnum: PortNumber;
      END;


CONST addrlen = 16; (* size of struct sockaddr in <sys/socket.h> *) TYPE SysAddress = ARRAY addrlen OF BYTE;

PROCEDURE GetPort(address: SocketAddress) : INTEGER; PROCEDURE SetPort(VAR address: SocketAddress; portnum: INTEGER);

PROCEDURE ConvertToSys(address: SocketAddress; VAR sysaddr: SysAddress); PROCEDURE ConvertFromSys(sysaddr: SysAddress; VAR address: SocketAddress);

PROCEDURE ReadText(s: Streams.Stream; VAR ipaddr: Address) : BOOLEAN; PROCEDURE WriteText(s: Streams.Stream; ipaddr: Address); PROCEDURE CreateAddress(VAR ipaddr: Address; dotteddec: ARRAY OF CHAR);

DESCRIPTION

IPv4Addresses provides support for IPv4 addresses. SocketAddress represents IPv4 addresses in an easily accessible way. Note however, that the fields host and portnum must be kept or are to be interpreted in network order, i.e. in big-endian byte order. The routines GetPort and SetPort can be used to convert the port number from and to network order.

SysAddress represents IPv4 addresses in an internal form which can be passed to the operations of SysSockets. ConvertToSys and ConvertFromSys allow IPv4 addresses to be converted to and from the internal form.

IPv4 addresses in a textual so-called ``dotted decimal'' representation (for example ``127.0.0.1'') can be read by ReadText. WriteText prints ipaddr in ``dotted decimal'' notation to s. CreateAddress allows to create an IPv4 address directly from a string which begins with a valid dotted decimal.

DIAGNOSTICS

IPv4Addresses does not generate error events by itself. ReadText returns FALSE in case of input or syntax errors. CreateAddress asserts that dotteddec is a syntactically valid ``dotted decimal'' number.

SEE ALSO

IPv6Addresses
support of IPv6 addresses
IPv4TCPSockets
TCP sockets with IPv4 addresses
SysSockets
system calls for sockets

Edited by: borchert, last change: 2004/03/04, revision: 1.1, converted to HTML: 2004/03/04

Oberon || Library || Module Index || Search Engine || Definition || Module