Commit 6ce36056 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[1186] Advertise is now sent properly.

parent 8dbb407b
......@@ -103,8 +103,6 @@ Dhcpv6Srv::run() {
// TODO add support for config session (see src/bin/auth/main.cc)
// so this daemon can be controlled from bob
sleep(1);
}
return (true);
......@@ -165,15 +163,15 @@ Dhcpv6Srv::processSolicit(boost::shared_ptr<Pkt6> solicit) {
reply->addOption(clientid);
// add server-id
// reply->addOption(getServerID());
reply->addOption(getServerID());
return reply;
}
boost::shared_ptr<Pkt6>
Dhcpv6Srv::processRequest(boost::shared_ptr<Pkt6> request) {
boost::shared_ptr<Pkt6> reply(new Pkt6(DHCPV6_REPLY,
request->getTransid(),
Pkt6::UDP));
/// TODO: Implement processRequest() for real
boost::shared_ptr<Pkt6> reply = processSolicit(request);
reply->setType(DHCPV6_REPLY);
return reply;
}
......
......@@ -87,7 +87,7 @@ Option::pack6(boost::shared_array<char> buf,
ptr += 2;
*(uint16_t*)ptr = htons(data_len_);
ptr += 2;
memcpy(ptr, &data_[0], data_len_);
memcpy(ptr, &data_[offset_], data_len_);
return offset + len();
}
......
......@@ -134,15 +134,24 @@ Pkt6::packUDP() {
try {
// DHCPv6 header: message-type (1 octect) + transaction id (3 octets)
data_[0] = msg_type_;
// that's elegant, but it doesn't work
data_[1] = (transid_ >> 16) & 0xff;
data_[2] = (transid_ >> 8) & 0xff;
data_[3] = (transid_) & 0xff;
// that's ugly, but it does work
int tmp = transid_;
data_[3] = tmp%256; tmp /=256;
data_[2] = tmp%256; tmp /=256;
data_[1] = tmp%256; tmp /=256;
// the rest are options
unsigned short offset = LibDHCP::packOptions6(data_, length,
4/*offset*/,
options_);
// sanity check
if (offset != length) {
isc_throw(OutOfRange, "Packet build failed: expected size="
......@@ -205,7 +214,8 @@ Pkt6::unpackUDP() {
return (false);
}
msg_type_ = data_[0];
transid_ = (data_[1] << 16) + (data_[2] << 8) + data_[3];
transid_ = ((unsigned int)data_[1] << 16) + ((unsigned int)data_[2] << 8) + (unsigned int)data_[3];
transid_ = transid_ & 0xffffff;
unsigned int offset = LibDHCP::unpackOptions6(data_,
data_len_,
......
......@@ -49,6 +49,7 @@ namespace isc {
unsigned short len();
unsigned char getType();
void setType(unsigned char type) { msg_type_=type; };
unsigned int getTransid() { return transid_; };
/// TODO need getter/setter wrappers
......@@ -97,7 +98,7 @@ namespace isc {
DHCPv6Proto_ proto_; // UDP (most) or TCP (bulk leasequery or failover)
int msg_type_; // DHCPv6 message type
int transid_; // DHCPv6 transaction-id
unsigned int transid_; // DHCPv6 transaction-id
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment