Plan 9 from Bell Labs’s /usr/web/sources/contrib/axel/8021x/v215/dat.h

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


enum
{
	STACK = 8*1024,
	SMALLSTACK = STACK,
//	SMALLSTACK = 2*1024,
	Pktlen = 1514,
	Npkt = 3,
	Buflen = 9600,
	Nbuf = 3,
	Blen = 256,

	ETHERMINTU=60,
	ETHERMAXTU=1514,
};

enum {
	ETEAPOL	= 0x888e,

	EapolTpEap	= 0,
	EapolTpStart	= 1,
	EapolTpLogoff	= 2,
	EapolTpKey	= 3,
	EapolTpAsf	= 4,

	EapolVersion	= 2,

	EapRequest	= 1,
	EapResponse	= 2,
	EapSuccess	= 3,
	EapFailure	= 4,

	EapTpIdentity	= 1,
	EapTpNotification	= 2,
	EapTpNak		= 3,
	EapTpMd5	= 4,
	EapTpOtp		= 5,	// one time password
	EapTpGtc		= 6,	// generic token card
	EapTpTtls		= 21,
	EapTpExtp	= 254,	// expanded types
	EapTpExus	= 255,	// experimental use
};

typedef struct Ether
{
	uchar	d[6];
	uchar	s[6];
	uchar	t[2];
	uchar	data[1];
} Ether;

enum {
	ETHERHDR = 14,
};

typedef struct Eapol
{
	uchar	ver;
	uchar	tp;
	uchar	ln[2];
	uchar	data[1];
} Eapol;

enum {
	EAPOLHDR = 4,
};

typedef struct Eap
{
	uchar	code;
	uchar	id;
	uchar	ln[2];
	uchar	data[1];
} Eap;

enum {
	EAPHDR = 4,
};

typedef struct KeyDesc
{
	uchar	tp;
	uchar	data[1]; //  min 1016
} KeyDesc;
enum
{
	KeyDescHlen = 1,
	KeyTpRC4 =	1,
};

typedef struct RC4KeyDesc
{
	uchar	ln[2];
	uchar	rpc[8];
	uchar	iv[16];
	uchar	idx;
	uchar	md[16];
	uchar	data[1];
} RC4KeyDesc;

enum
{
	RC4KeyDescHlen = 43,

	RC4KeyUnicast = 1<<7,
	RC4KeyIdx = (~0^1<<7),
};

typedef struct Buf {
	uchar *b;		// the data (Buflen or bigger)
	uchar *p;		// reassemble/fragment pointer in b
	uchar *e;		// end of data (e-b == length)
	uchar *end;	// end of allocated space
} Buf;

typedef struct Packet {
	uchar *b;		// the data (Pktlen)
	uchar *e; 		// end of data (e-b == length)
	uchar *end;	// end of allocated space
	Ether *ether;	// points to start of Ether in b
	Eapol *eapol;	// points to start of Eapol in b
	Eap *eap;		// points to start of Eapl in b
	uchar *p;		// read/write pointer in b
	int n;		// amount available at p
} Packet;

typedef struct ReadBuf {
	char *data;	// the data
	int ndata;		// how much is in use
	int sz;		// size of data
} ReadBuf;

// Ether
typedef struct Etherstate {
	int fd, cfd;
	char *dir;
	uchar ourmac[6];
	uchar apmac[6];

	int lastEapId;

	Channel *packetc;
	Channel *statusc;

	vlong verdictTime;
	int eapSuccess;
	int eapFail;

	int keyDone;
	int keyRun;
	vlong keyTime;

	Packet *pktr[Npkt], *pktt;
	int pkgidx;
} Etherstate;

// Phases
typedef struct Phasestate {
	vlong startTime;
	vlong doneTime;
	char *type;
	int success;
} Phasestate;


// Timers
enum {
	Off = 0,
	Ticking,
	Expired,

	TickPerSec = 10,
	Tick = 1000/TickPerSec,
};

typedef struct Timer {
	int counter;
	char *name;
	int state;
} Timer;

typedef struct Timers {
	Timer **timer;
	int ntimer;
	Channel *chan;
} Timers;

// Netlog

enum {
	Nlog		= 4*8*1024,
};

typedef struct Netlog {
	char*	name;
	int	size;
	int	opens;
	char*	buf;
	char	*end;
	char	*rptr;
	int	len;
	vlong offset; // stuff of the past that scrolled of the buffer
	Channel *ping; // to inform readers there is new stuff

	QLock;
	Rendez;
} Netlog;

// file types

enum {
	Qroot = 0,
	Qdir,
	Qctl,
	Qkeys,
	Qlog,
	Qnote,
	Qstats,
	Qstatus,
	Qtlslog,
	Qn,
};


// 802.1x state

typedef struct PAEstate PAEstate;

// Globals

uchar theSessionKey[64]; 
char *myId;
char *myPasswd;
int debug;
int debugTLS;
char *logname;

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].