Fragmentation fields of IPv4 header need to be converted from network
byte ordering to host byte ordering to be compatible with IP_MASK_*
constants.
Signed-off-by: Michal Kubecek <mku...@su...>
---
src/net/ipv4.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/net/ipv4.c b/src/net/ipv4.c
index bd41978..a63738f 100644
--- a/src/net/ipv4.c
+++ b/src/net/ipv4.c
@@ -166,6 +166,7 @@ static void free_fragbuf ( struct frag_buffer *fragbuf ) {
*/
static struct io_buffer * ipv4_reassemble ( struct io_buffer * iobuf ) {
struct iphdr *iphdr = iobuf->data;
+ uint16_t pkt_frags = ntohs ( iphdr->frags );
struct frag_buffer *fragbuf;
struct frag_buffer *fragtmp;
@@ -183,7 +184,7 @@ static struct io_buffer * ipv4_reassemble ( struct io_buffer * iobuf ) {
* the reassembled I/O buffer
*/
if ( iob_len ( fragbuf->frag_iob ) ==
- ( iphdr->frags & IP_MASK_OFFSET ) ) {
+ ( pkt_frags & IP_MASK_OFFSET ) ) {
/**
* Append the contents of the fragment to the
* reassembled I/O buffer
@@ -203,7 +204,7 @@ static struct io_buffer * ipv4_reassemble ( struct io_buffer * iobuf ) {
free_iob ( iobuf );
/** Check if the fragment series is over */
- if ( ! ( iphdr->frags & IP_MASK_MOREFRAGS ) ) {
+ if ( ! ( pkt_frags & IP_MASK_MOREFRAGS ) ) {
iobuf = fragbuf->frag_iob;
free_fragbuf ( fragbuf );
return iobuf;
@@ -219,8 +220,8 @@ static struct io_buffer * ipv4_reassemble ( struct io_buffer * iobuf ) {
}
/** Check if the fragment is the first in the fragment series */
- if ( iphdr->frags & IP_MASK_MOREFRAGS &&
- ( ( iphdr->frags & IP_MASK_OFFSET ) == 0 ) ) {
+ if ( ( pkt_frags & IP_MASK_MOREFRAGS ) &&
+ ( ( pkt_frags & IP_MASK_OFFSET ) == 0 ) ) {
/** Create a new fragment buffer */
fragbuf = ( struct frag_buffer* ) malloc ( sizeof( *fragbuf ) );
--
1.7.7
|