Re: arcane changling
Re: arcane changling
- Subject: Re: arcane changling
- From: "Peter Sichel" <email@hidden>
- Date: Mon, 24 Jul 2006 20:57:35 -0400
On 7/24/06, email@hidden wrote:
>What is there after tcpdump that could change an IP packet?
If you're modifying packets at the NKE level, you have to reset the
hardware checksum flags. This is not well documented and a little
clumbsy, but here's how I do it.
Kind Regards,
- Peter Sichel
Sustainable Softworks
// ----------------------------------
-----------------------------------------------
// ? PROJECT_modifyReadyPacket
// ----------------------------------
-----------------------------------------------
// Tiger: prepare packet to be modified by finalizing and setting
appropriate mbuf flags, return 0
// Panther: return 1 if outbound hardware TCP checksum is enabled so
calculation should be skipped
// (no easy way to "finalize" in Panther)
int PROJECT_modifyReadyPacket(KFT_packetData_t* packet)
{
int returnValue = 0;
mbuf_t mbuf_ref;
#if TIGER
if (packet->modifyReady == 0) {
mbuf_ref = *(packet->mbuf_ptr);
if (packet->direction == kDirectionInbound) {
mbuf_inbound_modified(mbuf_ref); // mbuf->m_pkthdr.csum_flags = 0;
mbuf_clear_csum_requested(mbuf_ref); // mbuf->m_pkthdr.csum_data = 0;
}
else {
mbuf_outbound_finalize(mbuf_ref, AF_INET, packet->ipOffset);
// might have done m_pullup
packet->datagram = (u_int8_t*)mbuf_data(*packet->mbuf_ptr);
packet->datagram = &packet->datagram[packet->ipOffset];
// clear csum flags
mbuf_inbound_modified(mbuf_ref); // mbuf->m_pkthdr.csum_flags = 0;
mbuf_clear_csum_requested(mbuf_ref); // mbuf->m_pkthdr.csum_data = 0;
#if 0
mbuf_csum_request_flags_t request;
u_int32_t value;
mbuf_get_csum_requested(mbuf_ref, &request, &value);
// work around bug in 10.4.2
if (request & 0x1000) returnValue = 1;
if (request & MBUF_CSUM_REQ_TCP) returnValue = 1;
//KFT_logText("csum_requested ", &request);
#endif
}
// remember what we did
packet->modifyReady = 1;
}
#else
mbuf_ref = *(packet->mbuf_ptr);
if (packet->direction == kDirectionInbound) {
// invalidate HW generated checksum flags
mbuf_ref->m_pkthdr.csum_data = 0;
mbuf_ref->m_pkthdr.csum_flags = 0;
//if ((mbuf_ref->m_pkthdr.csum_flags & CSUM_TCP_SUM16) &&
// (mbuf_ref->m_pkthdr.csum_flags & CSUM_DATA_VALID)) returnValue = 1;
}
else {
// Notice for outgoing packets the tcp checksum may not include the
TCP header yet
if (mbuf_ref->m_pkthdr.csum_flags & CSUM_TCP_SUM16) returnValue = 1;
}
#endif
return returnValue;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden