OSDN Git Service

update libMiMic
[mimic/MiMicSDK.git] / lib / src / netif / mimicip / NyLPC_cIPv4Payload_protected.h
1 /*********************************************************************************
2  * PROJECT: MiMic
3  * --------------------------------------------------------------------------------
4  *
5  * This file is part of MiMic
6  * Copyright (C)2011 Ryo Iizuka
7  *
8  * MiMic is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published
10  * by the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  *
21  * For further information please contact.
22  *  http://nyatla.jp/
23  *  <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
24  *
25  *
26  * Parts of this file were leveraged from uIP:
27  *
28  * Copyright (c) 2001-2003, Adam Dunkels.
29  * All rights reserved.
30  *
31  * Redistribution and use in source and binary forms, with or without
32  * modification, are permitted provided that the following conditions
33  * are met:
34  * 1. Redistributions of source code must retain the above copyright
35  *    notice, this list of conditions and the following disclaimer.
36  * 2. Redistributions in binary form must reproduce the above copyright
37  *    notice, this list of conditions and the following disclaimer in the
38  *    documentation and/or other materials provided with the distribution.
39  * 3. The name of the author may not be used to endorse or promote
40  *    products derived from this software without specific prior
41  *    written permission.
42  *
43  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
44  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
45  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
47  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
49  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
50  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
51  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
52  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
53  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54  */
55 #ifndef NYLPC_CIPV4PAYLOAD_PROTECTED_H_
56 #define NYLPC_CIPV4PAYLOAD_PROTECTED_H_
57
58 #include "NyLPC_cIPv4Payload.h"
59 #include "NyLPC_cIPv4.h"
60 #include "NyLPC_cMiMicIpUdpSocket.h"
61
62 #ifdef __cplusplus
63 extern "C" {
64 #endif /* __cplusplus */
65
66 #define TCP_FIN 0x01
67 #define TCP_SYN 0x02
68 #define TCP_RST 0x04
69 #define TCP_PSH 0x08
70 #define TCP_ACK 0x10
71 #define TCP_URG 0x20
72 #define TCP_CTL 0x3f
73
74
75
76
77 void NyLPC_cIPv4Payload_initialize(NyLPC_TcIPv4Payload_t* i_inst);
78 #define NyLPC_cIPv4Payload_finalize(i)
79
80 /**
81  * アタッチされているバッファを返します。
82  */
83 #define NyLPC_cIPv4Payload_getBuf(i) ((i)->header)
84
85
86
87 void NyLPC_cIPv4Payload_attachTxBuf(NyLPC_TcIPv4Payload_t* i_inst,void* i_buf);
88 const void* NyLPC_cIPv4Payload_detachBuf(NyLPC_TcIPv4Payload_t* i_inst);
89
90 NyLPC_TBool NyLPC_cIPv4Payload_attachRxBuf(NyLPC_TcIPv4Payload_t* i_inst,const void* i_buf,NyLPC_TUInt16 i_flagment_size);
91 void NyLPC_cIPv4Payload_setTcpReverseRstAck(
92     NyLPC_TcIPv4Payload_t* i_inst);
93 void NyLPC_cIPv4Payload_setTcpReverseRstAck2(
94     NyLPC_TcIPv4Payload_t* i_inst,
95     const NyLPC_TcIPv4Payload_t* i_src);
96
97
98
99
100 /**
101  * UDPの送信バッファを初期化します。
102  */
103 void* NyLPC_cIPv4Payload_initUdpTx(NyLPC_TcIPv4Payload_t* i_inst,NyLPC_TUInt8 i_iph_word,NyLPC_TUInt16 i_tcp_payload_size);
104 /**
105  * UDPの送信情報を設定します。
106  */
107 void NyLPC_cIPv4Payload_setUdpTxHeaderByConnection(NyLPC_TcIPv4Payload_t* i_inst,const struct uip_udp_conn* i_conn,const struct NyLPC_TIPv4Addr* i_dest_ip,NyLPC_TUInt16 i_dest_port);
108
109 void NyLPC_cIPv4Payload_closeUdpTxPacket(
110     NyLPC_TcIPv4Payload_t* i_inst);
111
112
113 void NyLPC_TcIPv4TxPacket_initialize_icomp(NyLPC_TcIPv4Payload_t* i_inst,void* i_buf,NyLPC_TUInt8 i_iph_word,NyLPC_TUInt16 i_tcp_payload_size);
114
115
116
117 #ifdef __cplusplus
118 }
119 #endif /* __cplusplus */
120
121 #endif /* NYLPC_CIPV4PAYLOAD_PROTECTED_H_ */
122