From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 27-APR-1993 22:02:21.58
To:	Info-VAX@KL.SRI.COM
CC:	
Subj:	MOP structure definitions...


  I stated that I'd post a header file with my understanding
of MOP stuff, and here it is. I make no claims that this
is comprehensive or even 100% correct. It does seem to 
work just fine for the terminal server code that it is 
implemented in for both the downloader and remote console
(which are actually different protocols). 
  The remote console stuff is *very* simple. The instigator
simply sends a MopRsvCon packet and the target verifies
that it has access rights. At this point the instigator
sends a MopConData with the payload of data he wants to
send to the target. The target replies with an acknowledgement
and any data he has to send. The RC is completely poll
driven by the host, there are no sliding windows or anything
else like that.
  When the host is done, it sends a MopRelCon command and
that's it.

-- mop.h --
/*
 *		    Copyright (c) 1989 Gordian Inc.
 *	  Created Thu Jun  8 16:29:48 1989 By Michael Thomas
 */


/*
 * define the intrinsics of DEC's MOP protocol
 */

#define uchar unsigned char
#define ushort unsigned short

#define PROTO_MOP	0x160		/* 60-01 */
#define PROTO_RC	0x260		/* 60-02 */
#define PROTO_LOOP	0x90		/* 90-00 */

/*
 * Various opcodes
 */
#define MOP_OPDUMPDONE	1	/* done pooping */
#define MOP_OPSNDMEM	2	/* host sends data */
#define MOP_OPVOL	3	/* somebody volunteering */
#define MOP_OPGETMEM	4	/* host asks for upload data */
#define MOP_REQID	5	/* request the ID of RC target */
#define MOP_BOOT	6	/* boot buddy... */
#define MOP_SYSID	7	/* system id/type */
#define MOP_OPPROG	8	/* program request */
#define MOP_OPACKMEM	10	/* we ack host */
#define MOP_OPRQDUMP	12	/* we request toilet service */
#define MOP_RESVCON	13	/* reserve console */
#define MOP_OPDUMPMEM	14	/* we send our guts to host */
#define MOP_CONRELEASE	15	/* release console */
#define MOP_CONCMD	17	/* console command & poll */
#define MOP_CONRPLY	19	/* console reply */
#define MOP_OPSNDPARAM	20	/* parameter + xfer address */

/*
 * These are for MOP downloading
 */

struct MopReq {
    ushort len;			/* data frame length */
    uchar  code;		/* request code */
    uchar  devtype;		/* device type */
#define MOP_DEUNA	1	/* a DEUNA we emulate (yech!) */
    uchar version;		/* format version */
#define MOP_VERSION1	1
    uchar prgtype;		/* a system image plz */
#define MOP_PTYPESYS	2
    uchar data;
    /* the following goes:
    	   ascic ("program file name");
	   uchar procval;		= 0
	   ushort type;			= 400
	   uchar  len;			= 1
	   uchar  datalink;		= 1
	   ushort type;			= 401;
	   uchar  len;			= 2;
	   ushort bfsize;		= 1500;
	   ushort type;			= 0 (end of list)
	   uchar  len;			= 0;
    */
};

struct MopVolunteer {
    ushort len;			/* data frame length */
    uchar  code;		/* request code */
};


struct MopRqID {		/* request ID */
    ushort len;
    uchar code;
    uchar rsvd;			/* reserved? */
    ushort recnum;		/* receipt number */
};

struct MopSysId {
    ushort len;
    uchar  code;
    uchar  rsvd;
    ushort recnum;
    uchar  data;
    /* the rest of the string goes:
    	 ushort type;		type of item
	 uchar  len;		length to follow
	 { uchar data }
     */
#define MOPID_VERSION	1		/* MOP ECO levels */
#define MOPID_FUNCTION	2		/* MOP functions supported */
#define MOPID_CONUSER	3		/* current console user */
#define MOPID_RSVTIMER	4		/* reservation timer */
#define MOPID_RCVBUFF	5		/* console command buffer */
#define MOPID_XMTBUFF	6		/* xmit buffer size */
#define MOPID_HARDADDR	7		/* ethernet address */
#define MOPID_COMMDEV	100		/* comm device type */
#define MOPID_COMMUNK	101		/* string of eight bytes (pwd?) */
#define MOPID_COMMID	102		/* device type */
#define MOPID_COMMID2	103		/* same again... */
#define MOPID_COMMID3	104		/* null string.. */
#define MOPID_NODENAME	105		/* ascic string of nodename */
#define MOPID_PRODNAME	106		/* ascic string of prodname */
#define MOPID_DATALINK	400		/* datalink type */
#define MOPID_DLBFSZ	401		/* datalink buffer size */

/* MOP functionality codes */
#define MOPFN_CONRSV	0x80		/* can take console reserves */
#define MOPFN_DLCCOUNT	0x40		/* can do datalink counters */
#define MOPFN_CONCARY	0x20		/* can support a RC (?) */
#define MOPFN_BOOT	0x10		/* can boot a node */
#define MOPFN_MULTILDR	0x08		/* multiblock loader */
#define MOPFN_PRIMLDR	0x04		/* primary loader */
#define MOPFN_DUMP	0x02		/* can accept dumps */
#define MOPFN_LOOP	0x01		/* accepts loopback requests */
};




struct MopLoad {
    ushort len;			/* length of data */
    uchar  code;		/* type code */
    uchar  loadnum;		/* load number */
    long   loadaddr;		/* load address */
    uchar data;			/* start of data */
};

struct MopDumpReq {		/* target asks for dump service */
    ushort len;			/* length of data */
    uchar  code;		/* type code */
    uchar devtype;		/* device type code */
    uchar version;		/* format version */
    uchar dumpsize [4];		/* number of bytes to upload */
    uchar flags;		/* some flag byte */
    uchar data;			/* start of data item field */
    /* this needs to be followed by a data link buffer size item (see sysid) */
};

struct MopDumpPoll {		/* host dump data request */
    ushort len;			/* length of data to follow */
    uchar code;
    uchar addr [4];		/* address to dump */
    uchar nbytes[2];		/* number of bytes to dump */
};


struct MopDump {
    ushort len;			/* length of data */
    uchar  code;		/* type code */
    uchar addr [4];		/* address of data */
    uchar data;			/* start of data to follow */
};

struct MopBootMsg {
    ushort len;			/* length of data */
    uchar  code;		/* type code */
    uchar  vfy [8];		/* verification code */
};


struct MopLoadAck {
    ushort len;			/* length of data */
    uchar  code;		/* type code */
    uchar  loadnum;		/* load number */
    uchar  error;
};

struct MopParamXfer {		/* parameter+transfer address */
    ushort len;
    uchar  code;
    uchar  loadnum;
    uchar data;			/* parameter values */
    /* the parameter list seems to go like:
    	uchar 	pnum;
	uchar   plen;
	uchar  [plen];
	[ repeat till pnum == 0];
	ulong   xferaddress;
     */
};

/*
 * These are specfically for the remote console
 */

struct MopRsvCon {		/* reserve the console */
    ushort len;		
    uchar code;
    uchar vfy [8];		/* verification string */
};


struct MopConCmd {
    ushort len;
    uchar code;
    uchar flags;		/* console command flags */
#define MOPCON_MSG	1	/* message number (?) */
#define MOPCON_BREAK	2	/* command data, break */
    uchar data;			/* address of data to follow */
};

struct MopRelCon {
    ushort len;
    uchar code;			
};

-- 

		Michael Thomas	(mike@gordian.com)
	"I don't think Bambi Eyes will get you that flame thrower..."  
		-- Hobbes to Calvin
		USnail: 20361 Irvine Ave Santa Ana Heights, Ca,	92707-5637
		PaBell: (714) 850-0205 (714) 850-0533 (fax)

