1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-28 12:44:25 +01:00

Added enum to identify PDU type. ARP is being sent but not well implemented

This commit is contained in:
Santiago Alessandri
2011-08-15 19:14:31 -03:00
parent 835229f104
commit 6e801011c2
13 changed files with 235 additions and 175 deletions

View File

@@ -1,19 +1,19 @@
/*
* libtins is a net packet wrapper library for crafting and
* libtins is a net packet wrapper library for crafting and
* interpreting sniffed packets.
*
*
* Copyright (C) 2011 Nasel
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -138,17 +138,17 @@ void Tins::TCP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PD
for(unsigned i(0); i < _options.size(); ++i)
buffer = _options[i].write(buffer);
if(_options_size < _total_options_size) {
if(_options_size < _total_options_size) {
uint8_t padding = _total_options_size;
while(padding < _options_size) {
*(buffer++) = 1;
padding++;
}
}
const IP *ip_packet = dynamic_cast<const IP*>(parent);
const Tins::IP *ip_packet = dynamic_cast<const Tins::IP*>(parent);
if(!_tcp.check && ip_packet) {
uint32_t checksum = PDU::pseudoheader_checksum(ip_packet->source_address(), ip_packet->dest_address(), size(), IPPROTO_TCP) +
uint32_t checksum = PDU::pseudoheader_checksum(ip_packet->source_address(), ip_packet->dest_address(), size(), IPPROTO_TCP) +
PDU::do_checksum(tcp_start + sizeof(tcphdr), tcp_start + total_sz) + PDU::do_checksum((uint8_t*)&_tcp, ((uint8_t*)&_tcp) + sizeof(tcphdr));
while (checksum >> 16)
checksum = (checksum & 0xffff) + (checksum >> 16);