@@ -17,7 +17,7 @@ namespace datagram
1717 {
1818 }
1919
20- void DatagramDestination::SendDatagramTo (const uint8_t * payload, size_t len, const i2p::data::IdentHash& ident)
20+ void DatagramDestination::SendDatagramTo (const uint8_t * payload, size_t len, const i2p::data::IdentHash& ident, uint16_t fromPort, uint16_t toPort )
2121 {
2222 uint8_t buf[MAX_DATAGRAM_SIZE];
2323 auto identityLen = m_Owner.GetIdentity ().ToBuffer (buf, MAX_DATAGRAM_SIZE);
@@ -36,7 +36,7 @@ namespace datagram
3636 else
3737 m_Owner.Sign (buf1, len, signature);
3838
39- auto msg = CreateDataMessage (buf, len + headerLen);
39+ auto msg = CreateDataMessage (buf, len + headerLen, fromPort, toPort );
4040 auto remote = m_Owner.FindLeaseSet (ident);
4141 if (remote)
4242 m_Owner.GetService ().post (std::bind (&DatagramDestination::SendMsg, this , msg, remote));
@@ -132,7 +132,7 @@ namespace datagram
132132
133133 }
134134
135- I2NPMessage * DatagramDestination::CreateDataMessage (const uint8_t * payload, size_t len)
135+ I2NPMessage * DatagramDestination::CreateDataMessage (const uint8_t * payload, size_t len, uint16_t fromPort, uint16_t toPort )
136136 {
137137 I2NPMessage * msg = NewI2NPMessage ();
138138 CryptoPP::Gzip compressor; // default level
@@ -143,7 +143,8 @@ namespace datagram
143143 htobe32buf (buf, size); // length
144144 buf += 4 ;
145145 compressor.Get (buf, size);
146- memset (buf + 4 , 0 , 4 ); // source and destination are zeroes
146+ htobe16buf (buf + 4 , fromPort); // source port
147+ htobe16buf (buf + 6 , toPort); // destination port
147148 buf[9 ] = i2p::client::PROTOCOL_TYPE_DATAGRAM; // datagram protocol
148149 msg->len += size + 4 ;
149150 FillI2NPMessageHeader (msg, eI2NPData);
0 commit comments