|
@@ -43,7 +43,7 @@ Pkt6::Pkt6(const uint8_t* buf, uint32_t buf_len, DHCPv6Proto proto /* = UDP */)
|
|
remote_addr_("::"),
|
|
remote_addr_("::"),
|
|
local_port_(0),
|
|
local_port_(0),
|
|
remote_port_(0),
|
|
remote_port_(0),
|
|
- bufferOut_(0) {
|
|
|
|
|
|
+ buffer_out_(0) {
|
|
data_.resize(buf_len);
|
|
data_.resize(buf_len);
|
|
memcpy(&data_[0], buf, buf_len);
|
|
memcpy(&data_[0], buf, buf_len);
|
|
}
|
|
}
|
|
@@ -58,7 +58,7 @@ Pkt6::Pkt6(uint8_t msg_type, uint32_t transid, DHCPv6Proto proto /*= UDP*/) :
|
|
remote_addr_("::"),
|
|
remote_addr_("::"),
|
|
local_port_(0),
|
|
local_port_(0),
|
|
remote_port_(0),
|
|
remote_port_(0),
|
|
- bufferOut_(0) {
|
|
|
|
|
|
+ buffer_out_(0) {
|
|
}
|
|
}
|
|
|
|
|
|
uint16_t Pkt6::len() {
|
|
uint16_t Pkt6::len() {
|
|
@@ -199,6 +199,8 @@ Pkt6::pack() {
|
|
void
|
|
void
|
|
Pkt6::packUDP() {
|
|
Pkt6::packUDP() {
|
|
try {
|
|
try {
|
|
|
|
+ // Make sure that the buffer is empty before we start writting to it.
|
|
|
|
+ buffer_out_.clear();
|
|
|
|
|
|
// is this a relayed packet?
|
|
// is this a relayed packet?
|
|
if (!relay_info_.empty()) {
|
|
if (!relay_info_.empty()) {
|
|
@@ -215,11 +217,11 @@ Pkt6::packUDP() {
|
|
relay != relay_info_.end(); ++relay) {
|
|
relay != relay_info_.end(); ++relay) {
|
|
|
|
|
|
// build relay-forw/relay-repl header (see RFC3315, section 7)
|
|
// build relay-forw/relay-repl header (see RFC3315, section 7)
|
|
- bufferOut_.writeUint8(relay->msg_type_);
|
|
|
|
- bufferOut_.writeUint8(relay->hop_count_);
|
|
|
|
- bufferOut_.writeData(&(relay->linkaddr_.toBytes()[0]),
|
|
|
|
|
|
+ buffer_out_.writeUint8(relay->msg_type_);
|
|
|
|
+ buffer_out_.writeUint8(relay->hop_count_);
|
|
|
|
+ buffer_out_.writeData(&(relay->linkaddr_.toBytes()[0]),
|
|
isc::asiolink::V6ADDRESS_LEN);
|
|
isc::asiolink::V6ADDRESS_LEN);
|
|
- bufferOut_.writeData(&relay->peeraddr_.toBytes()[0],
|
|
|
|
|
|
+ buffer_out_.writeData(&relay->peeraddr_.toBytes()[0],
|
|
isc::asiolink::V6ADDRESS_LEN);
|
|
isc::asiolink::V6ADDRESS_LEN);
|
|
|
|
|
|
// store every option in this relay scope. Usually that will be
|
|
// store every option in this relay scope. Usually that will be
|
|
@@ -230,28 +232,28 @@ Pkt6::packUDP() {
|
|
for (OptionCollection::const_iterator opt =
|
|
for (OptionCollection::const_iterator opt =
|
|
relay->options_.begin();
|
|
relay->options_.begin();
|
|
opt != relay->options_.end(); ++opt) {
|
|
opt != relay->options_.end(); ++opt) {
|
|
- (opt->second)->pack(bufferOut_);
|
|
|
|
|
|
+ (opt->second)->pack(buffer_out_);
|
|
}
|
|
}
|
|
|
|
|
|
// and include header relay-msg option. Its payload will be
|
|
// and include header relay-msg option. Its payload will be
|
|
// generated in the next iteration (if there are more relays)
|
|
// generated in the next iteration (if there are more relays)
|
|
// or outside the loop (if there are no more relays and the
|
|
// or outside the loop (if there are no more relays and the
|
|
// payload is a direct message)
|
|
// payload is a direct message)
|
|
- bufferOut_.writeUint16(D6O_RELAY_MSG);
|
|
|
|
- bufferOut_.writeUint16(relay->relay_msg_len_);
|
|
|
|
|
|
+ buffer_out_.writeUint16(D6O_RELAY_MSG);
|
|
|
|
+ buffer_out_.writeUint16(relay->relay_msg_len_);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// DHCPv6 header: message-type (1 octect) + transaction id (3 octets)
|
|
// DHCPv6 header: message-type (1 octect) + transaction id (3 octets)
|
|
- bufferOut_.writeUint8(msg_type_);
|
|
|
|
|
|
+ buffer_out_.writeUint8(msg_type_);
|
|
// store 3-octet transaction-id
|
|
// store 3-octet transaction-id
|
|
- bufferOut_.writeUint8( (transid_ >> 16) & 0xff );
|
|
|
|
- bufferOut_.writeUint8( (transid_ >> 8) & 0xff );
|
|
|
|
- bufferOut_.writeUint8( (transid_) & 0xff );
|
|
|
|
|
|
+ buffer_out_.writeUint8( (transid_ >> 16) & 0xff );
|
|
|
|
+ buffer_out_.writeUint8( (transid_ >> 8) & 0xff );
|
|
|
|
+ buffer_out_.writeUint8( (transid_) & 0xff );
|
|
|
|
|
|
// the rest are options
|
|
// the rest are options
|
|
- LibDHCP::packOptions(bufferOut_, options_);
|
|
|
|
|
|
+ LibDHCP::packOptions(buffer_out_, options_);
|
|
}
|
|
}
|
|
catch (const Exception& e) {
|
|
catch (const Exception& e) {
|
|
// An exception is thrown and message will be written to Logger
|
|
// An exception is thrown and message will be written to Logger
|
|
@@ -502,7 +504,7 @@ Pkt6::delOption(uint16_t type) {
|
|
}
|
|
}
|
|
|
|
|
|
void Pkt6::repack() {
|
|
void Pkt6::repack() {
|
|
- bufferOut_.writeData(&data_[0], data_.size());
|
|
|
|
|
|
+ buffer_out_.writeData(&data_[0], data_.size());
|
|
}
|
|
}
|
|
|
|
|
|
void
|
|
void
|