Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added DHCPINFORM response for testing WPAD. #75

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions lib/dhcp.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ function Server(config, listenOnly) {
case DHCPREQUEST: // 3.
self.handleRequest(req);
break;
case DHCPINFORM: // 8.
self.handleInform(req);
break;
default:
console.error("Not implemented method", req.options[53]);
}
Expand Down Expand Up @@ -410,6 +413,36 @@ Server.prototype = {

this.sendAck(req);
},
handleInform: function(req) {
//console.log('Handle Inform', req);

// Formulate the response object
const ans = {
op: BOOTREPLY,
htype: 1, // RFC1700, hardware types: 1=Ethernet, 2=Experimental, 3=AX25, 4=ProNET Token Ring, 5=Chaos, 6=Tokenring, 7=Arcnet, 8=FDDI, 9=Lanstar (keep it constant)
hlen: 6, // Mac addresses are 6 byte
hops: 0,
xid: req.xid, // 'xid' from client DHCPREQUEST message
secs: 0,
flags: req.flags, // 'flags' from client DHCPREQUEST message
ciaddr: INADDR_ANY,
yiaddr: INADDR_ANY,
siaddr: this.config('server'), // server ip, that's us
giaddr: req.giaddr, // 'giaddr' from client DHCPREQUEST message
chaddr: req.chaddr, // 'chaddr' from client DHCPREQUEST message
sname: '',
file: '',
options: this._getOptions({
53: DHCPACK
}, [
1, 3, 51, 54, 6
], req.options[55])
};

// Send the actual data
// INADDR_BROADCAST : 68 <- SERVER_IP : 67
this._send(INADDR_BROADCAST, ans);
},
sendAck: function(req) {
//console.log('Send ACK');
// Formulate the response object
Expand Down