@@ -17,7 +17,7 @@ namespace datagram
17
17
{
18
18
}
19
19
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 )
21
21
{
22
22
uint8_t buf[MAX_DATAGRAM_SIZE];
23
23
auto identityLen = m_Owner.GetIdentity ().ToBuffer (buf, MAX_DATAGRAM_SIZE);
@@ -36,7 +36,7 @@ namespace datagram
36
36
else
37
37
m_Owner.Sign (buf1, len, signature);
38
38
39
- auto msg = CreateDataMessage (buf, len + headerLen);
39
+ auto msg = CreateDataMessage (buf, len + headerLen, fromPort, toPort );
40
40
auto remote = m_Owner.FindLeaseSet (ident);
41
41
if (remote)
42
42
m_Owner.GetService ().post (std::bind (&DatagramDestination::SendMsg, this , msg, remote));
@@ -132,7 +132,7 @@ namespace datagram
132
132
133
133
}
134
134
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 )
136
136
{
137
137
I2NPMessage * msg = NewI2NPMessage ();
138
138
CryptoPP::Gzip compressor; // default level
@@ -143,7 +143,8 @@ namespace datagram
143
143
htobe32buf (buf, size); // length
144
144
buf += 4 ;
145
145
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
147
148
buf[9 ] = i2p::client::PROTOCOL_TYPE_DATAGRAM; // datagram protocol
148
149
msg->len += size + 4 ;
149
150
FillI2NPMessageHeader (msg, eI2NPData);
0 commit comments