zoukankan      html  css  js  c++  java
  • 握手3

    最后看一下这个函数

    /* 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
    ", __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);
    }

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

  • 相关阅读:
    什么是web框架
    编写CGI程序步骤
    web开发 c/s结构 和 b/s结构
    python自带的web服务器
    自制计算器
    条件判断
    模版继承
    参数传递
    异常处理
    【uoj#244】[UER #7]短路 CDQ分治+斜率优化dp
  • 原文地址:https://www.cnblogs.com/guoyu1024/p/10591421.html
Copyright © 2011-2022 走看看