Path: blob/a-new-beginning/SharedDependencies/Sources/libslirp/include/tcpip.h
2 views
/* SPDX-License-Identifier: BSD-3-Clause */1/*2* Copyright (c) 1982, 1986, 19933* The Regents of the University of California. All rights reserved.4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13* 3. Neither the name of the University nor the names of its contributors14* may be used to endorse or promote products derived from this software15* without specific prior written permission.16*17* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND18* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE19* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE20* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE21* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL22* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS23* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)24* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT25* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY26* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF27* SUCH DAMAGE.28*29* @(#)tcpip.h 8.1 (Berkeley) 6/10/9330* tcpip.h,v 1.3 1994/08/21 05:27:40 paul Exp31*/3233#ifndef TCPIP_H34#define TCPIP_H3536/*37* Tcp+ip header, after ip options removed.38*/39struct tcpiphdr {40struct mbuf_ptr ih_mbuf; /* backpointer to mbuf */41union {42struct {43struct in_addr ih_src; /* source internet address */44struct in_addr ih_dst; /* destination internet address */45uint8_t ih_x1; /* (unused) */46uint8_t ih_pr; /* protocol */47} ti_i4;48struct {49struct in6_addr ih_src;50struct in6_addr ih_dst;51uint8_t ih_x1;52uint8_t ih_nh;53} ti_i6;54} ti;55uint16_t ti_x0;56uint16_t ti_len; /* protocol length */57struct tcphdr ti_t; /* tcp header */58};59#define ti_mbuf ih_mbuf.mptr60#define ti_pr ti.ti_i4.ih_pr61#define ti_src ti.ti_i4.ih_src62#define ti_dst ti.ti_i4.ih_dst63#define ti_src6 ti.ti_i6.ih_src64#define ti_dst6 ti.ti_i6.ih_dst65#define ti_nh6 ti.ti_i6.ih_nh66#define ti_sport ti_t.th_sport67#define ti_dport ti_t.th_dport68#define ti_seq ti_t.th_seq69#define ti_ack ti_t.th_ack70#define ti_x2 ti_t.th_x271#define ti_off ti_t.th_off72#define ti_flags ti_t.th_flags73#define ti_win ti_t.th_win74#define ti_sum ti_t.th_sum75#define ti_urp ti_t.th_urp7677#define tcpiphdr2qlink(T) \78((struct qlink *)(((char *)(T)) - sizeof(struct qlink)))79#define qlink2tcpiphdr(Q) \80((struct tcpiphdr *)(((char *)(Q)) + sizeof(struct qlink)))81#define tcpiphdr_next(T) qlink2tcpiphdr(tcpiphdr2qlink(T)->next)82#define tcpiphdr_prev(T) qlink2tcpiphdr(tcpiphdr2qlink(T)->prev)83#define tcpfrag_list_first(T) qlink2tcpiphdr((T)->seg_next)84#define tcpfrag_list_end(F, T) (tcpiphdr2qlink(F) == (struct qlink *)(T))85#define tcpfrag_list_empty(T) ((T)->seg_next == (struct tcpiphdr *)(T))8687/* This is the difference between the size of a tcpiphdr structure, and the88* size of actual ip+tcp headers, rounded up since we need to align data. */89#define TCPIPHDR_DELTA \90(MAX(0, ((int) sizeof(struct qlink) + \91(int) sizeof(struct tcpiphdr) - (int) sizeof(struct ip) - \92(int) sizeof(struct tcphdr) + 7) & \93~7))9495/*96* Just a clean way to get to the first byte97* of the packet98*/99struct tcpiphdr_2 {100struct tcpiphdr dummy;101char first_char;102};103104#endif105106107