* How do i change UDP ?
@ 2003-09-03 18:01 박유찬
0 siblings, 0 replies; only message in thread
From: 박유찬 @ 2003-09-03 18:01 UTC (permalink / raw)
To: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 423 bytes --]
Hi there..
I want to change UDP communication to unix-like..
that is linux send UDP packet as 4, 3, 2, 1 but i want to send it as 1 2 3 4
the attached file is icmp.c, ip_output.c and upd.c having GENIE_IP_PATCH
but if i apply this patched then it occures BAD CHECKSUM..but the sending sequence is sent which i want to.
I don't know why BAD CHECKSUM is occurred.
anyone give me some advice??
Thanks...
[-- Attachment #2: patched-sequence --]
[-- Type: application/octet-stream, Size: 7596 bytes --]
diff -uNr orginal/icmp.c patched/icmp.c
--- orginal/icmp.c Thu Aug 28 21:38:10 2003
+++ patched/icmp.c Thu Sep 4 02:52:24 2003
@@ -91,6 +91,7 @@
#include <asm/uaccess.h>
#include <net/checksum.h>
+#define GENIE_IP_PATCH
/*
* Build xmit assembly blocks
*/
@@ -319,39 +320,37 @@
* the other fragments first, so that we get the checksum
* for the whole packet here.
*/
-
- /*
+#ifndef GENIE_IP_PATCH
+ csum = csum_partial_copy_nocheck((void *)&icmp_param->data,
+ to, icmp_param->head_len,
+ icmp_param->csum);
csum=skb_copy_and_csum_bits(icmp_param->skb,
icmp_param->offset,
to+icmp_param->head_len,
fraglen-icmp_param->head_len,
csum);
- csum = csum_partial_copy_nocheck((void *)&icmp_param->data,
- to, icmp_param->head_len,
- icmp_param->csum);
-
-
- */
- {
- csum = skb_copy_and_csum_bits(icmp_param->skb,
+#else
+ csum=skb_copy_and_csum_bits(icmp_param->skb,
+ icmp_param->offset,
+ to+icmp_param->head_len,
+ fraglen-icmp_param->head_len,
+ 0);
+ csum = 0;
+ icmp_param->csum = 0;
+ icmp_param->csum = skb_checksum(icmp_param->skb,
icmp_param->offset,
- to+icmp_param->head_len,
fraglen-icmp_param->head_len,
- 0);
- csum = 0 ;
- icmp_param->csum = 0;
+ csum);
- csum = csum_partial(icmp_param->skb,
- icmp_param->data_len, 0);
+// icmp_param->csum = skb_copy_bits(icmp_param->skb,
+// icmp_param->offset, to+icmp_param->head_len, csum);
csum = csum_partial_copy_nocheck((void *)&icmp_param->data,
to, icmp_param->head_len,
icmp_param->csum);
-
+#endif
icmph=(struct icmphdr *)to;
icmph->checksum = csum_fold(csum);
- }
-
return 0;
}
@@ -415,7 +414,9 @@
struct icmp_bxm icmp_param;
struct rtable *rt = (struct rtable*)skb_in->dst;
struct ipcm_cookie ipc;
+#ifdef GENIE_IP_PATCH
unsigned int offset;
+#endif
u32 saddr;
u8 tos;
@@ -541,13 +542,19 @@
room -= sizeof(struct iphdr) + icmp_param.replyopts.optlen;
room -= sizeof(struct icmphdr);
+#ifndef GENIE_IP_PATCH
+ icmp_param.data_len=skb_in->len-icmp_param.offset;
+#else
+
if( skb_in->data > skb_in->nh.raw)
offset = (skb_in->data - skb_in->nh.raw);
else
offset = 0;
- icmp_param.data_len=skb_in->len-icmp_param.offset+offset;
+ icmp_param.data_len=skb_in->len+offset;
+// icmp_param.data_len=skb_in->len+icmp_param.offset;
+#endif
if (icmp_param.data_len > room)
icmp_param.data_len = room;
icmp_param.head_len = sizeof(struct icmphdr);
diff -uNr orginal/ip_output.c patched/ip_output.c
--- orginal/ip_output.c Thu Aug 28 21:38:10 2003
+++ patched/ip_output.c Thu Sep 4 01:27:47 2003
@@ -78,7 +78,9 @@
#include <linux/mroute.h>
#include <linux/netlink.h>
+
#define GENIE_IP_PATCH
+
/*
* Shall we try to damage output packets if routing dev changes?
*/
@@ -472,9 +474,7 @@
ip_local_error(sk, EMSGSIZE, rt->rt_dst, sk->dport, mtu);
return -EMSGSIZE;
}
-
#ifndef GENIE_IP_PATCH
-
/*
* Start at the end of the frame by handling the remainder.
*/
@@ -492,45 +492,42 @@
offset -= maxfraglen-fragheaderlen;
}
#else
- /* Patch for skt.
- */
offset = 0;
- if(length < (maxfraglen - fragheaderlen))
+ if ( length < ( maxfraglen - fragheaderlen) ) {
fraglen = length + fragheaderlen;
- else
+ } else {
fraglen = maxfraglen;
+ }
+ //printk( KERN_INFO "\n\nbeyond while first : length : %d", length);
+ //printk( KERN_INFO "\tfraglen : %d", fraglen);
+ //printk( KERN_INFO "\toffset : %d", offset);
+ //printk( KERN_INFO "\tfragheaderlen: %d", fragheaderlen);
#endif
-#ifndef GENIE_IP_PATH
+
/*
* The last fragment will not have MF (more fragments) set.
*/
-
+#ifndef GENIE_IP_PATCH
mf = 0;
#else
- /* the first fragment will have MFset
- */
- if( length < (maxfraglen - fragheaderlen))
+ if( length < (maxfraglen - fragheaderlen) )
mf = 0;
- else
+ else
mf = htons(IP_MF);
+ printk(KERN_INFO "\n\nmf value is %d\n", mf);
#endif
-
-#ifndef GENIE_IP_PATCH
/*
* Don't fragment packets for path mtu discovery.
*/
-
+#ifndef GENIE_IP_PATCH
if (offset > 0 && sk->protinfo.af_inet.pmtudisc==IP_PMTUDISC_DO) {
- ip_local_error(sk, EMSGSIZE, rt->rt_dst, sk->dport, mtu);
- return -EMSGSIZE;
- }
#else
- if( length > (maxfraglen - fragheaderlen) &&
- sk->protinfo.af_inet.pmtudisc==IP_PMTUDISC_DO) {
+ if( length > (maxfraglen - fragheaderlen ) && sk->protinfo.af_inet.pmtudisc==IP_PMTUDISC_DO ) {
+
+#endif
ip_local_error(sk, EMSGSIZE, rt->rt_dst, sk->dport, mtu);
return -EMSGSIZE;
}
-#endif
if (flags&MSG_PROBE)
goto out;
@@ -542,8 +539,9 @@
#ifndef GENIE_IP_PATCH
do {
#else
- while( offset < length ) {
+ while(offset < length ) {
#endif
+
char *data;
struct sk_buff * skb;
@@ -629,13 +627,17 @@
offset -= (maxfraglen-fragheaderlen);
fraglen = maxfraglen;
#else
- offset = offset + ( maxfraglen - fragheaderlen);
- if( length < offset + ( maxfraglen - fragheaderlen)) {
+ offset += (maxfraglen - fragheaderlen);
+ if( length <= offset + (maxfraglen - fragheaderlen )) {
fraglen = length - offset + fragheaderlen;
mf = 0;
} else {
fraglen = maxfraglen;
}
+
+ //printk(KERN_INFO "\nupper offset size : %d", offset );
+ //printk(KERN_INFO "\tupper fragheaderlen size : %d", fragheaderlen);
+ //printk(KERN_INFO "\tupper length size : %d", length);
#endif
nfrags++;
@@ -651,9 +653,11 @@
#ifndef GENIE_IP_PATCH
} while (offset >= 0);
#else
+ //printk(KERN_INFO "\noffset size : %d", offset );
+ //printk(KERN_INFO "\tfraglen size : %d", fraglen);
+ //printk(KERN_INFO "\tmaxfraglen size : %d", maxfraglen);
}
#endif
-
if (nfrags>1)
ip_statistics[smp_processor_id()*2 + !in_softirq()].IpFragCreates += nfrags;
out:
diff -uNr orginal/udp.c patched/udp.c
--- orginal/udp.c Thu Aug 28 21:38:10 2003
+++ patched/udp.c Thu Sep 4 02:35:04 2003
@@ -94,6 +94,8 @@
#include <net/inet_common.h>
#include <net/checksum.h>
+#define GENIE_IP_PATCH
+
/*
* Snmp MIB for the UDP layer
*/
@@ -380,18 +382,23 @@
if (csum_partial_copy_fromiovecend(to+sizeof(struct udphdr), ufh->iov, offset,
fraglen-sizeof(struct udphdr), &ufh->wcheck))
return -EFAULT;
+#ifndef GENIE_IP_PATCH
+ ufh->wcheck = csum_partial((char *)ufh, sizeof(struct udphdr),
+ ufh->wcheck);
+ ufh->uh.check = csum_tcpudp_magic(ufh->saddr, ufh->daddr,
+ ntohs(ufh->uh.len),
+ IPPROTO_UDP, ufh->wcheck);
+#else
+ ufh->wcheck =0;
+ ufh->wcheck = csum_partial((char*) ufh->iov->iov_base, ufh->iov->iov_len,0);
+ ufh->wcheck = csum_partial((char *)ufh, sizeof(struct udphdr), 0);
+ ufh->uh.check = csum_tcpudp_magic(ufh->saddr, ufh->daddr,
+ ntohs(ufh->uh.len),
+ IPPROTO_UDP, ufh->wcheck);
+
+#endif
+
- ufh->wcheck = 0;
- ufh->wcheck = csum_partial((char *)ufh->iov->iov_base, ufh->iov->iov_len, 0);
- ufh->wcheck = csum_partial((char *)ufh, sizeof(struct udphdr), ufh->wcheck);
- ufh->uh.check = csum_tcpudp_magic(ufh->saddr, ufh->daddr, ntohs(ufh->uh.len),
- IPPROTO_UDP, ufh->wcheck);
-
- //ufh->wcheck = csum_partial((char *)ufh, sizeof(struct udphdr),
- // ufh->wcheck);
- //ufh->uh.check = csum_tcpudp_magic(ufh->saddr, ufh->daddr,
- // ntohs(ufh->uh.len),
- // IPPROTO_UDP, ufh->wcheck);
if (ufh->uh.check == 0)
ufh->uh.check = -1;
memcpy(to, ufh, sizeof(struct udphdr));
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-09-03 18:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-03 18:01 How do i change UDP ? 박유찬
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®