MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / WriteBytes

Method WriteBytes

pcsx2/DEV9/PacketReader/IP/UDP/DHCP/DHCP_Packet.cpp:173–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171 }
172
173 void DHCP_Packet::WriteBytes(u8* buffer, int* offset)
174 {
175 const int start = *offset;
176 NetLib::WriteByte08(buffer, offset, op);
177 NetLib::WriteByte08(buffer, offset, hardwareType);
178 NetLib::WriteByte08(buffer, offset, hardwareAddressLength);
179 NetLib::WriteByte08(buffer, offset, hops);
180
181 NetLib::WriteUInt32(buffer, offset, transactionID);
182
183 NetLib::WriteUInt16(buffer, offset, seconds);
184 NetLib::WriteUInt16(buffer, offset, flags);
185
186 NetLib::WriteIPAddress(buffer, offset, clientIP);
187 NetLib::WriteIPAddress(buffer, offset, yourIP);
188 NetLib::WriteIPAddress(buffer, offset, serverIP);
189 NetLib::WriteIPAddress(buffer, offset, gatewayIP);
190
191 NetLib::WriteByteArray(buffer, offset, 16, clientHardwareAddress);
192 //empty bytes
193 memset(buffer + *offset, 0, 64 + 128);
194 *offset += 64 + 128;
195
196 NetLib::WriteUInt32(buffer, offset, magicCookie);
197
198 int len = 240;
199 for (size_t i = 0; i < options.size(); i++)
200 {
201 if (len + options[i]->GetLength() < maxLength)
202 {
203 len += options[i]->GetLength();
204 options[i]->WriteBytes(buffer, offset);
205 }
206 else
207 {
208 Console.Error("DEV9: DHCP_Packet: Oversized DHCP packet not handled");
209 //We need space for DHCP End
210 if (len == maxLength)
211 {
212 i -= 1;
213 const int pastLength = options[i]->GetLength();
214 len -= pastLength;
215 *offset -= pastLength;
216 }
217
218 DHCPopEND end;
219 end.WriteBytes(buffer, offset);
220 break;
221 }
222 }
223
224 const int end = start + GetLength();
225 const int delta = end - *offset;
226
227 memset(&buffer[*offset], 0, delta);
228 *offset = start + GetLength();
229 }
230

Callers

nothing calls this directly

Calls 9

WriteByte08Function · 0.85
WriteUInt32Function · 0.85
WriteUInt16Function · 0.85
WriteIPAddressFunction · 0.85
WriteByteArrayFunction · 0.85
GetLengthFunction · 0.85
sizeMethod · 0.45
GetLengthMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected