gxSocket Utilities


Conditional Directives
Type Definitions
Data Structures


The gxSocket utilities are a collection of data structures and standalone functions used for low-level network operations.


// ICMP Constants
const int gxsECHO_REQ_DATASIZE =  32; // Echo Request Data size
const int gxsICMP_ECHO_REPLY = 0;     // ICMP echo reply
const int gxsICMP_ECHO_REQUEST = 8;   // ICMP echo request

gxSocket Constants

Data Structures

IP Header in accordance with RFC 791: http://www.faqs.org/rfcs/rfc791.html

struct gxsIPHeader
  u_char version_and_ihl;     // Version and Internet header length
  u_char type_of_service;     // Type of service
  short	total_length;         // Total length
  short	sender_id;            // Identification
  short	flag_and_frag_offset; // Flags and fragment offset
  u_char time_to_live;        // Time to live
  u_char protocol;            // Protocol
  u_short checksum;           // Checksum
  gxsInternetAddress ia_source;	     // Internet Address - Source
  gxsInternetAddress ia_destination; // Internet Address - Destination

ICMP Header in accordance with RFC 792: http://www.faqs.org/rfcs/rfc792.html

struct gxsICMPHeader
  u_char type;        // Type (8 for echo message / 0 for echo reply message)
  u_char code;        // Code
  u_short checksum;   // Checksum
  u_short identifier; // Identifier
  u_short sequence;   // Sequence
  char data;          // Data

ICMP echo request packet.

struct gxsEchoRequest
  gxsICMPHeader icmp_header;
  int time_sent;
  char data[gxsECHO_REQ_DATASIZE];

ICMP echo reply packet.

struct gxsEchoReply
  gxsIPHeader ip_header;
  gxsEchoRequest echo_request;
  char data[gxsECHO_REQ_DATASIZE];

Standalone Functions

u_short InChecksum16(u_short *addr, int len) - C++ checksum routine for Internet protocol family headers taken from Mike Muuss' in_cksum() function and his comments from the original ping program.

Author: Mike Muuss
U. S. Army Ballistic Research Laboratory
December, 1983

int ParseServiceFileEntry(char *entry, char *service, int *port, char *protocol, char *aliases, char *comment) - Standalone function used to parse a single line of a services file. Returns true if no error were encountered or false if the line does not contain a valid service, port, and protocol entry. Services file format:

<service name> <port number>/<protocol> [aliases...] [#<comment>]

End Of Document