ASP Internal Header file

This file contains the declarations which are used by the ASP implementation file, asp.c. As such, it's much more detailed than the external header file.
/*     
 * $RCSfile: asp_internal.h,v $
 *
 * x-kernel v3.3
 *
 * Copyright (c) 1993,1991,1990,1996  Arizona Board of Regents
 */

#include "xkernel.h"
#include "ip.h"
#include "asp.h"

/* ASP message header definition */

typedef struct header {
    ASPport sport;  /* source port      */
    ASPport dport;  /* destination port */
    u_short ulen;   /* ASP length       */
} ASPhdr;
Examine the header structure carefully. This is the information which the transmitting end of an ASP connection attaches to the data which it is sending to the receiving end. For this simple protocol, we send only the source and destination port addresses and ulen, the data length of the ASP message itself.
#define HLEN (sizeof(ASPhdr))

/* protocol and session states */

typedef struct pstate {
    Map activemap;
    Map passivemap;
} ProtlState;
In order for a connection to be established between sender and receiver, two things have to happen in this order:
  1. First, the receiver must indicate that it is willing to accept a connection. This operation is called a passive open or open enable.
  2. Then, the sender actively opens a connection to that port.
The ASP protocol object stores a list of all the passively opened ports in its passive map, and a list of all the actually open connections in its active map, as shown in the ProtlState structure above.
typedef struct sstate {
    ASPhdr hdr;
} SessnState;
The Session State object is the only place where you can store information which persists over the lifetime of a connection. For example, if you wanted a counter which showed the number of the next message which you were going to send, or a queue of messages waiting to be sent, it would go here.

The ASP session state consists of a template header file, with the source and destination port filled in and the data length, ulen, left blank. Note that all the messages sent through a given session will always have the same source and destination addresses, but may have different message lengths.

/* active and passive maps */

typedef struct {
    Sessn   lls;
    ASPport localport;
    ASPport remoteport;
} ActiveId;

typedef ASPport PassiveId;

This shows the information contained in the active and passive maps. The "lls" member of ActiveID is the lower-level session. From the viewpoint of ASP, "lls" is the entry point into an IP connection.

A passive map entry (PassiveId) is just the port number of an ASP port which has been enabled for some remote participant to open an ASP connection to it.

#define ACTIVE_MAP_SIZE  101
#define PASSIVE_MAP_SIZE 23
These numbers for the size of the respective maps appear to have been chosen at random.
/* UPI function declarations */

void            asp_init(Protl);
static Sessn    aspOpen(Protl, Protl, Protl, Part *);
static XkReturn aspOpenEnable(Protl, Protl, Protl, Part *);
static XkReturn aspDemux(Protl, Sessn, Msg *);
static XkHandle aspPush(Sessn, Msg *);
static XkReturn aspPop(Sessn, Sessn, Msg *, void *);
static Sessn    aspCreateSessn(Protl, Protl, Protl, ActiveId *);
static XkReturn aspClose(Sessn);
static int      aspControlProtl(Protl, int, char *, int) ;
static int      aspControlSessn(Sessn, int, char *, int) ;
static Part    *aspGetParticipants(Sessn);
These are the functions, implemented in asp.c, which are called by the HLP which wants to use ASP. In other words, they are the Service Access Points (SAP) of ASP.
/* internal function declarations */

static void     getproc_protl(Protl);
static void     getproc_sessn(Sessn);
static long     aspHdrLoad(ASPhdr *, char *, long);
static void     aspHdrStore(ASPhdr *, char *, long);
These "internal" functions are called only within asp.c, and are not exposed to the outside world.
/* trace variable used in conjunction with xTrace stmts */
int traceaspp;
This variable controls the level of detail of the debugging output statements which xkernel generates internally. A recommended initial setting is TR_MAJOR_EVENTS. See the X-kernel manual for more detail.

Next: The asp implementation file, asp.c