码迷,mamicode.com
首页 > 其他好文 > 详细

握手3

时间:2019-03-25 01:03:12      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:ued   value   hat   +=   修改   char   str   cross   客户   

最后看一下这个函数

/* Send a crossed SYN-ACK during socket establishment.
 * WARNING: This routine must only be called when we have already sent
 * a SYN packet that crossed the incoming SYN that caused this routine
 * to get called. If this assumption fails then the initial rcv_wnd
 * and rcv_wscale values will not be correct.
 */
int tcp_send_synack(struct sock *sk)
{
    struct sk_buff *skb;

    skb = tcp_write_queue_head(sk);
    if (skb == NULL || !(TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN)) {
        pr_debug("%s: wrong queue state\n", __func__);
        return -EFAULT;
    }
    if (!(TCP_SKB_CB(skb)->tcp_flags & TCPHDR_ACK)) {
        if (skb_cloned(skb)) {
            struct sk_buff *nskb = skb_copy(skb, GFP_ATOMIC);
            if (nskb == NULL)
                return -ENOMEM;
            tcp_unlink_write_queue(skb, sk);
            __skb_header_release(nskb);
            __tcp_add_write_queue_head(sk, nskb);
            sk_wmem_free_skb(sk, skb);
            sk->sk_wmem_queued += nskb->truesize;
            sk_mem_charge(sk, nskb->truesize);
            skb = nskb;
        }

        TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_ACK;
        tcp_ecn_send_synack(sk, skb);
    }
    return tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC);
}

将客户端发起连接请求的报文修改一下,发回给客户端。

握手3

标签:ued   value   hat   +=   修改   char   str   cross   客户   

原文地址:https://www.cnblogs.com/guoyu1024/p/10591421.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!