diff -ru ACCOUNT/linux-2.6/net/ipv4/netfilter/ipt_ACCOUNT.c ACCOUNT.byteorder/linux-2.6/net/ipv4/netfilter/ipt_ACCOUNT.c --- ACCOUNT/linux-2.6/net/ipv4/netfilter/ipt_ACCOUNT.c 2009-04-08 15:35:42.000000000 +0200 +++ ACCOUNT.byteorder/linux-2.6/net/ipv4/netfilter/ipt_ACCOUNT.c 2009-10-13 15:11:52.000000000 +0200 @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -362,8 +363,15 @@ } /* Calculate array positions */ +#if defined(__LITTLE_ENDIAN_BITFIELD) src_slot = (unsigned char)((src_ip&0xFF000000) >> 24); dst_slot = (unsigned char)((dst_ip&0xFF000000) >> 24); +#elif defined(__BIG_ENDIAN_BITFIELD) + src_slot = (unsigned char)(src_ip&0x000000FF); + dst_slot = (unsigned char)(dst_ip&0x000000FF); +#else +#error "Please fix " +#endif /* Increase size counters */ if (is_src) { @@ -414,7 +422,13 @@ { /* Do we need to process src IP? */ if ((net_ip&netmask) == (src_ip&netmask)) { +#if defined(__LITTLE_ENDIAN_BITFIELD) unsigned char slot = (unsigned char)((src_ip&0x00FF0000) >> 16); +#elif defined(__BIG_ENDIAN_BITFIELD) + unsigned char slot = (unsigned char)((src_ip&0x0000FF00) >> 8); +#else +#error "Please fix " +#endif DEBUGP("ACCOUNT: Calculated SRC 16 bit network slot: %d\n", slot); /* Do we need to create a new mask_24 bucket? */ @@ -430,7 +444,13 @@ /* Do we need to process dst IP? */ if ((net_ip&netmask) == (dst_ip&netmask)) { +#if defined(__LITTLE_ENDIAN_BITFIELD) unsigned char slot = (unsigned char)((dst_ip&0x00FF0000) >> 16); +#elif defined(__BIG_ENDIAN_BITFIELD) + unsigned char slot = (unsigned char)((dst_ip&0x0000FF00) >> 8); +#else +#error "Please fix " +#endif DEBUGP("ACCOUNT: Calculated DST 16 bit network slot: %d\n", slot); /* Do we need to create a new mask_24 bucket? */ @@ -452,7 +472,13 @@ { /* Do we need to process src IP? */ if ((net_ip&netmask) == (src_ip&netmask)) { +#if defined(__LITTLE_ENDIAN_BITFIELD) unsigned char slot = (unsigned char)((src_ip&0x0000FF00) >> 8); +#elif defined(__BIG_ENDIAN_BITFIELD) + unsigned char slot = (unsigned char)((src_ip&0x00FF0000) >> 16); +#else +#error "Please fix " +#endif DEBUGP("ACCOUNT: Calculated SRC 24 bit network slot: %d\n", slot); /* Do we need to create a new mask_24 bucket? */ @@ -468,7 +494,13 @@ /* Do we need to process dst IP? */ if ((net_ip&netmask) == (dst_ip&netmask)) { +#if defined(__LITTLE_ENDIAN_BITFIELD) unsigned char slot = (unsigned char)((dst_ip&0x0000FF00) >> 8); +#elif defined(__BIG_ENDIAN_BITFIELD) + unsigned char slot = (unsigned char)((dst_ip&0x00FF0000) >> 16); +#else +#error "Please fix " +#endif DEBUGP("ACCOUNT: Calculated DST 24 bit network slot: %d\n", slot); /* Do we need to create a new mask_24 bucket? */ @@ -789,7 +821,13 @@ for (i = 0; i <= 255; i++) { if (data->ip[i].src_packets || data->ip[i].dst_packets) { +#if defined(__LITTLE_ENDIAN_BITFIELD) handle_ip.ip = net_ip | net_OR_mask | (i<<24); +#elif defined(__BIG_ENDIAN_BITFIELD) + handle_ip.ip = net_ip | net_OR_mask | i; +#else +#error "Please fix " +#endif handle_ip.src_packets = data->ip[i].src_packets; handle_ip.src_bytes = data->ip[i].src_bytes; @@ -862,7 +900,15 @@ struct ipt_acc_mask_24 *network = (struct ipt_acc_mask_24*)network_16->mask_24[b]; if (ipt_acc_handle_copy_data(to_user, &to_user_pos, - &tmpbuf_pos, network, net_ip, (b << 16))) + &tmpbuf_pos, network, net_ip, +#if defined(__LITTLE_ENDIAN_BITFIELD) + (b << 16) +#elif defined(__BIG_ENDIAN_BITFIELD) + (b << 8) +#else +#error "Please fix " +#endif + )) return -1; } } @@ -890,7 +936,15 @@ (struct ipt_acc_mask_24*)network_16->mask_24[b]; if (ipt_acc_handle_copy_data(to_user, &to_user_pos, &tmpbuf_pos, - network, net_ip, (a << 8) | (b << 16))) + network, net_ip, +#if defined(__LITTLE_ENDIAN_BITFIELD) + (a << 8) | (b << 16) +#elif defined(__BIG_ENDIAN_BITFIELD) + (a << 16) | (b << 8) +#else +#error "Please fix " +#endif + )) return -1; } }