MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / TcpFormatNetbuf

Function TcpFormatNetbuf

NetworkPkg/TcpDxe/TcpMisc.c:683–722  ·  view source on GitHub ↗

Translate the information from the head of the received TCP segment Nbuf contents and fill it into a TCP_SEG structure. @param[in] Tcb Pointer to the TCP_CB of this TCP instance. @param[in, out] Nbuf Pointer to the buffer contains the TCP segment. @return Pointer to the TCP_SEG that contains the translated TCP head information. **/

Source from the content-addressed store, hash-verified

681
682**/
683TCP_SEG *
684TcpFormatNetbuf (
685 IN TCP_CB *Tcb,
686 IN OUT NET_BUF *Nbuf
687 )
688{
689 TCP_SEG *Seg;
690 TCP_HEAD *Head;
691
692 Seg = TCPSEG_NETBUF (Nbuf);
693 Head = (TCP_HEAD *) NetbufGetByte (Nbuf, 0, NULL);
694 ASSERT (Head != NULL);
695
696 Nbuf->Tcp = Head;
697
698 Seg->Seq = NTOHL (Head->Seq);
699 Seg->Ack = NTOHL (Head->Ack);
700 Seg->End = Seg->Seq + (Nbuf->TotalSize - (Head->HeadLen << 2));
701
702 Seg->Urg = NTOHS (Head->Urg);
703 Seg->Wnd = (NTOHS (Head->Wnd) << Tcb->SndWndScale);
704 Seg->Flag = Head->Flag;
705
706 //
707 // SYN and FIN flag occupy one sequence space each.
708 //
709 if (TCP_FLG_ON (Seg->Flag, TCP_FLG_SYN)) {
710 //
711 // RFC requires that the initial window not be scaled.
712 //
713 Seg->Wnd = NTOHS (Head->Wnd);
714 Seg->End++;
715 }
716
717 if (TCP_FLG_ON (Seg->Flag, TCP_FLG_FIN)) {
718 Seg->End++;
719 }
720
721 return Seg;
722}
723
724/**
725 Initialize an active connection.

Callers 1

TcpInputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected