* Re: Packet Transmit Amateur progammer!!
2006-04-17 13:31 Packet Transmit Amateur progammer!! Felipe Maya
@ 2006-04-17 12:33 ` Al Viro
2006-04-17 19:26 ` Valdis.Kletnieks
1 sibling, 0 replies; 3+ messages in thread
From: Al Viro @ 2006-04-17 12:33 UTC (permalink / raw)
To: Felipe Maya; +Cc: linux mailing-list
On Mon, Apr 17, 2006 at 09:31:59AM -0400, Felipe Maya wrote:
> Hi, I am trying to send one packet in one Congestion Agent. I am
> Amateur kernel programmer, I want to know what is wrong in this
How about
a) 0.7Kb on stach, for starters
b) the only occurences of "data" below being
> unsigned char data[700];
and
> tcp_header_size = MAX_TCP_HEADER + sizeof(data);
Is that really what you meant to do there?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Packet Transmit Amateur progammer!!
@ 2006-04-17 13:31 Felipe Maya
2006-04-17 12:33 ` Al Viro
2006-04-17 19:26 ` Valdis.Kletnieks
0 siblings, 2 replies; 3+ messages in thread
From: Felipe Maya @ 2006-04-17 13:31 UTC (permalink / raw)
To: linux mailing-list
Hi, I am trying to send one packet in one Congestion Agent. I am
Amateur kernel programmer, I want to know what is wrong in this
source??
Thanks for Help.
int packet_probe(struct sock *sk){
const struct inet_connection_sock *icsk = inet_csk(sk);
struct inet_sock *inet = inet_sk(sk);
struct tcp_sock *tp = tcp_sk(sk);
struct sk_buff *skb;
struct tcphdr *tcph;
struct iphdr *iph;
size_t tcp_header_size, tlen;
unsigned char data[700];
switch(sk->sk_state){
case TCP_LISTEN:
case TCP_ESTABLISHED:
break;
default:
goto out;
break;
}
tcp_header_size = MAX_TCP_HEADER + sizeof(data);
//skb = alloc_skb(sizeof(*pack), sk->sk_allocation);
skb = alloc_skb(MAX_TCP_HEADER, GFP_ATOMIC);
if (skb == NULL){
return -1;
}
// Reserve space for headers and prepare control bits
skb_reserve(skb, MAX_TCP_HEADER);
skb->csum = 0;
TCP_SKB_CB(skb)->flags = TCPCB_FLAG_PSH;//(TCPCB_FLAG_ACK | TCPCB_FLAG_RST);
TCP_SKB_CB(skb)->sacked = 0;
skb_shinfo(skb)->tso_segs = 1;
skb_shinfo(skb)->tso_size = 0;
//Acceptable Sequence
if (!before(tp->snd_una+tp->snd_wnd, tp->snd_nxt)){
TCP_SKB_CB(skb)->seq = tp->snd_nxt;
}
else{
TCP_SKB_CB(skb)->seq = tp->snd_una+tp->snd_wnd;
}
TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(skb)->seq;
TCP_SKB_CB(skb)->when = tcp_time_stamp;
tp->retrans_stamp = TCP_SKB_CB(skb)->when;
skb_header_release(skb);
__skb_queue_tail(&sk->sk_write_queue, skb);
sk_charge_skb(sk, skb);
//Number of segments in one skb (No. packs)
tp->packets_out += skb_shinfo(skb)->tso_segs;
//++++++Send packet//////////////////
if (icsk->icsk_ca_ops->rtt_sample){
__net_timestamp(skb);
}
//Clone skb if is necesary make retranmit
//if (unlikely(skb_cloned(skb))) skb = pskb_copy(skb, GFP_ATOMIC);
//else skb = skb_clone(skb, GFP_ATOMIC);
//if (unlikely(!skb)) return -ENOBUFS;
// Build TCP header and checksum it
tcph = (struct tcphdr *) skb_push(skb, MAX_TCP_HEADER);
skb->h.th = tcph;
skb_set_owner_w(skb, sk);
tcph->source = inet->sport;
tcph->dest = inet->dport;
tcph->seq = htonl(TCP_SKB_CB(skb)->seq);
tcph->ack_seq = htonl(tp->rcv_nxt);
//*(((__u16 *)tcph) + 6) = htons(((MAX_TCP_HEADER >> 2) << 12) | tcb->flags);
tcph->check = 0;
tcph->urg_ptr = 0;
tcph->urg = 0;
//IP header
tlen = sizeof(struct iphdr);
iph = (struct iphdr *) __skb_put(skb, tlen);
iph->version = 4;
iph->ihl = 5;
iph->tos = inet->tos;
iph->frag_off = 0;
//iph->ttl = inet->ttl;
iph->daddr = inet->daddr;
iph->saddr = inet->saddr;
iph->protocol = sk->sk_protocol;
iph->tot_len = htons(tlen);
skb->nh.iph = iph;
TCP_ECN_send(sk, tp, skb, tcp_header_size);
/////////////////////////////////////
TCP_INC_STATS(TCP_MIB_ACTIVEOPENS);
// Timer for repeating the packet probe until an answer
//inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
// inet_csk(sk)->icsk_rto, TCP_RTO_MAX);
return 1;
out:
return 0;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Packet Transmit Amateur progammer!!
2006-04-17 13:31 Packet Transmit Amateur progammer!! Felipe Maya
2006-04-17 12:33 ` Al Viro
@ 2006-04-17 19:26 ` Valdis.Kletnieks
1 sibling, 0 replies; 3+ messages in thread
From: Valdis.Kletnieks @ 2006-04-17 19:26 UTC (permalink / raw)
To: Felipe Maya; +Cc: linux mailing-list
[-- Attachment #1: Type: text/plain, Size: 482 bytes --]
On Mon, 17 Apr 2006 09:31:59 EDT, Felipe Maya said:
> Hi, I am trying to send one packet in one Congestion Agent. I am
> Amateur kernel programmer, I want to know what is wrong in this
> source??
First, convince us that something *is* wrong. Compiler error messages?
Runtime messages? A tcpdump of the results? An explanation of what you
think *should* happen? The command you used to compile this, and tell us
whether you intended to do this in kernel or userspace, and why?
[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-04-17 19:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-17 13:31 Packet Transmit Amateur progammer!! Felipe Maya
2006-04-17 12:33 ` Al Viro
2006-04-17 19:26 ` Valdis.Kletnieks
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox