xref: /inferno-os/module/dhcp.m (revision 46439007cf417cbd9ac8049bb4122c890097a0fa)
1*46439007SCharles.ForsythDhcpclient: module
2*46439007SCharles.Forsyth{
3*46439007SCharles.Forsyth	PATH: con "/dis/lib/dhcpclient.dis";
4*46439007SCharles.Forsyth
5*46439007SCharles.Forsyth	Bootconf: adt {
6*46439007SCharles.Forsyth		ip:	string;
7*46439007SCharles.Forsyth		ipgw:	string;
8*46439007SCharles.Forsyth		ipmask:	string;
9*46439007SCharles.Forsyth		bootf:	string;
10*46439007SCharles.Forsyth		bootip:	string;
11*46439007SCharles.Forsyth		dhcpip:	string;
12*46439007SCharles.Forsyth		siaddr:	string;
13*46439007SCharles.Forsyth		serverid:	string;
14*46439007SCharles.Forsyth		sys:	string;
15*46439007SCharles.Forsyth		dom:	string;
16*46439007SCharles.Forsyth		lease:	int;
17*46439007SCharles.Forsyth		options:	array of array of byte;
18*46439007SCharles.Forsyth		vendor:	array of array of byte;
19*46439007SCharles.Forsyth
20*46439007SCharles.Forsyth		new:	fn(): ref Bootconf;
21*46439007SCharles.Forsyth		get:	fn(c: self ref Bootconf, n: int): array of byte;
22*46439007SCharles.Forsyth		getint:	fn(c: self ref Bootconf, n: int): int;
23*46439007SCharles.Forsyth		getip:	fn(c: self ref Bootconf, n: int): string;
24*46439007SCharles.Forsyth		getips:	fn(c: self ref Bootconf, n: int): list of string;
25*46439007SCharles.Forsyth		gets:	fn(c: self ref Bootconf, n: int): string;
26*46439007SCharles.Forsyth		put:	fn(c: self ref Bootconf, n: int, a: array of byte);
27*46439007SCharles.Forsyth		putint:	fn(c: self ref Bootconf, n: int, v: int);
28*46439007SCharles.Forsyth		putips:	fn(c: self ref Bootconf, n: int, ips: list of string);
29*46439007SCharles.Forsyth		puts:	fn(c: self ref Bootconf, n: int, s: string);
30*46439007SCharles.Forsyth	};
31*46439007SCharles.Forsyth
32*46439007SCharles.Forsyth	Lease: adt {
33*46439007SCharles.Forsyth		pid:	int;
34*46439007SCharles.Forsyth		configs:	chan of (ref Bootconf, string);
35*46439007SCharles.Forsyth
36*46439007SCharles.Forsyth		release:	fn(l: self ref Lease);
37*46439007SCharles.Forsyth	};
38*46439007SCharles.Forsyth
39*46439007SCharles.Forsyth	init:	fn();
40*46439007SCharles.Forsyth	tracing:	fn(debug: int);
41*46439007SCharles.Forsyth	bootp:	fn(net: string, ctlifc: ref Sys->FD, device: string, init: ref Bootconf): (ref Bootconf, string);
42*46439007SCharles.Forsyth	dhcp:	fn(net: string, ctlifc: ref Sys->FD, device: string, init: ref Bootconf, options: array of int): (ref Bootconf, ref Lease, string);
43*46439007SCharles.Forsyth
44*46439007SCharles.Forsyth	applycfg:	fn(net: string, ctlifc: ref Sys->FD, conf: ref Bootconf): string;
45*46439007SCharles.Forsyth	removecfg:	fn(net: string, ctlifc: ref Sys->FD, conf: ref Bootconf): string;
46*46439007SCharles.Forsyth
47*46439007SCharles.Forsyth	# bootp options used here
48*46439007SCharles.Forsyth	Opad: con 0;
49*46439007SCharles.Forsyth	Oend: con 255;
50*46439007SCharles.Forsyth	Omask: con 1;
51*46439007SCharles.Forsyth	Orouter: con 3;
52*46439007SCharles.Forsyth	Odnsserver: con 6;
53*46439007SCharles.Forsyth	Ocookieserver: con 8;
54*46439007SCharles.Forsyth	Ohostname: con 12;
55*46439007SCharles.Forsyth	Odomainname: con 15;
56*46439007SCharles.Forsyth	Ontpserver: con 42;
57*46439007SCharles.Forsyth	Ovendorinfo: con 43;
58*46439007SCharles.Forsyth	Onetbiosns: con 44;
59*46439007SCharles.Forsyth	Osmtpserver: con 69;
60*46439007SCharles.Forsyth	Opop3server: con 70;
61*46439007SCharles.Forsyth	Owwwserver: con 72;
62*46439007SCharles.Forsyth
63*46439007SCharles.Forsyth	# dhcp options
64*46439007SCharles.Forsyth	Oipaddr: con 50;
65*46439007SCharles.Forsyth	Olease: con 51;
66*46439007SCharles.Forsyth	Ooverload: con 52;
67*46439007SCharles.Forsyth	Otype: con 53;
68*46439007SCharles.Forsyth	Oserverid: con 54;
69*46439007SCharles.Forsyth	Oparams: con 55;
70*46439007SCharles.Forsyth	Omessage: con 56;
71*46439007SCharles.Forsyth	Omaxmsg: con 57;
72*46439007SCharles.Forsyth	Orenewaltime: con 58;
73*46439007SCharles.Forsyth	Orebindingtime: con 59;
74*46439007SCharles.Forsyth	Ovendorclass: con 60;
75*46439007SCharles.Forsyth	Oclientid: con 61;
76*46439007SCharles.Forsyth	Otftpserver: con 66;
77*46439007SCharles.Forsyth	Obootfile: con 67;
78*46439007SCharles.Forsyth
79*46439007SCharles.Forsyth	Ovendor:	con (1<<8);
80*46439007SCharles.Forsyth	OP9fs: con Ovendor|128;	# plan 9 file server
81*46439007SCharles.Forsyth	OP9auth:	con Ovendor|129;	# plan 9 auth server
82*46439007SCharles.Forsyth
83*46439007SCharles.Forsyth	Infinite:	con ~0;	# lease
84*46439007SCharles.Forsyth};
85