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