parent
366d25ae38
commit
a3b754b662
@ -1,96 +1,96 @@
|
||||
/* Copyright (C) 2005, 2006, 2007, 2008 by Thomas Hillebrandt and Heiko Will
|
||||
|
||||
This file is part of the Micro-mesh SensorWeb Firmware.
|
||||
|
||||
Micro-Mesh is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
Micro-Mesh is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Micro-Mesh; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef __ARM_COMMON_H
|
||||
#define __ARM_COMMON_H
|
||||
|
||||
/**
|
||||
* @ingroup arm_common
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define I_Bit 0x80
|
||||
#define F_Bit 0x40
|
||||
|
||||
#define SYS32Mode 0x1F
|
||||
#define IRQ32Mode 0x12
|
||||
#define FIQ32Mode 0x11
|
||||
|
||||
#define INTMode (FIQ32Mode | IRQ32Mode)
|
||||
|
||||
|
||||
/**
|
||||
* @name IRQ Priority Mapping
|
||||
*/
|
||||
//@{
|
||||
#define HIGHEST_PRIORITY 0x01
|
||||
#define IRQP_RTIMER 1 // FIQ_PRIORITY // TODO: investigate problems with rtimer and FIQ
|
||||
#define IRQP_TIMER1 1
|
||||
#define IRQP_WATCHDOG 1
|
||||
#define IRQP_CLOCK 3
|
||||
#define IRQP_GPIO 4
|
||||
#define IRQP_RTC 8
|
||||
#define LOWEST_PRIORITY 0x0F
|
||||
// @}
|
||||
|
||||
|
||||
#define WDT_INT 0
|
||||
#define SWI_INT 1
|
||||
#define ARM_CORE0_INT 2
|
||||
#define ARM_CORE1_INT 3
|
||||
#define TIMER0_INT 4
|
||||
#define TIMER1_INT 5
|
||||
#define UART0_INT 6
|
||||
#define UART1_INT 7
|
||||
#define PWM0_1_INT 8
|
||||
#define I2C0_INT 9
|
||||
#define SPI0_INT 10 /* SPI and SSP0 share VIC slot */
|
||||
#define SSP0_INT 10
|
||||
#define SSP1_INT 11
|
||||
#define PLL_INT 12
|
||||
#define RTC_INT 13
|
||||
#define EINT0_INT 14
|
||||
#define EINT1_INT 15
|
||||
#define EINT2_INT 16
|
||||
#define EINT3_INT 17
|
||||
#define ADC0_INT 18
|
||||
#define I2C1_INT 19
|
||||
#define BOD_INT 20
|
||||
#define EMAC_INT 21
|
||||
#define USB_INT 22
|
||||
#define CAN_INT 23
|
||||
#define MCI_INT 24
|
||||
#define GPDMA_INT 25
|
||||
#define TIMER2_INT 26
|
||||
#define TIMER3_INT 27
|
||||
#define UART2_INT 28
|
||||
#define UART3_INT 29
|
||||
#define I2C2_INT 30
|
||||
#define I2S_INT 31
|
||||
|
||||
#define VECT_ADDR_INDEX 0x100
|
||||
#define VECT_CNTL_INDEX 0x200
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "cpu.h"
|
||||
|
||||
bool cpu_install_irq(int IntNumber, void *HandlerAddr, int Priority);
|
||||
|
||||
/** @} */
|
||||
#endif /*ARMVIC_H_*/
|
||||
/* Copyright (C) 2005, 2006, 2007, 2008 by Thomas Hillebrandt and Heiko Will
|
||||
|
||||
This file is part of the Micro-mesh SensorWeb Firmware.
|
||||
|
||||
Micro-Mesh is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
Micro-Mesh is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Micro-Mesh; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef __ARM_COMMON_H
|
||||
#define __ARM_COMMON_H
|
||||
|
||||
/**
|
||||
* @ingroup arm_common
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define I_Bit 0x80
|
||||
#define F_Bit 0x40
|
||||
|
||||
#define SYS32Mode 0x1F
|
||||
#define IRQ32Mode 0x12
|
||||
#define FIQ32Mode 0x11
|
||||
|
||||
#define INTMode (FIQ32Mode | IRQ32Mode)
|
||||
|
||||
|
||||
/**
|
||||
* @name IRQ Priority Mapping
|
||||
*/
|
||||
//@{
|
||||
#define HIGHEST_PRIORITY 0x01
|
||||
#define IRQP_RTIMER 1 // FIQ_PRIORITY // TODO: investigate problems with rtimer and FIQ
|
||||
#define IRQP_TIMER1 1
|
||||
#define IRQP_WATCHDOG 1
|
||||
#define IRQP_CLOCK 3
|
||||
#define IRQP_GPIO 4
|
||||
#define IRQP_RTC 8
|
||||
#define LOWEST_PRIORITY 0x0F
|
||||
// @}
|
||||
|
||||
|
||||
#define WDT_INT 0
|
||||
#define SWI_INT 1
|
||||
#define ARM_CORE0_INT 2
|
||||
#define ARM_CORE1_INT 3
|
||||
#define TIMER0_INT 4
|
||||
#define TIMER1_INT 5
|
||||
#define UART0_INT 6
|
||||
#define UART1_INT 7
|
||||
#define PWM0_1_INT 8
|
||||
#define I2C0_INT 9
|
||||
#define SPI0_INT 10 /* SPI and SSP0 share VIC slot */
|
||||
#define SSP0_INT 10
|
||||
#define SSP1_INT 11
|
||||
#define PLL_INT 12
|
||||
#define RTC_INT 13
|
||||
#define EINT0_INT 14
|
||||
#define EINT1_INT 15
|
||||
#define EINT2_INT 16
|
||||
#define EINT3_INT 17
|
||||
#define ADC0_INT 18
|
||||
#define I2C1_INT 19
|
||||
#define BOD_INT 20
|
||||
#define EMAC_INT 21
|
||||
#define USB_INT 22
|
||||
#define CAN_INT 23
|
||||
#define MCI_INT 24
|
||||
#define GPDMA_INT 25
|
||||
#define TIMER2_INT 26
|
||||
#define TIMER3_INT 27
|
||||
#define UART2_INT 28
|
||||
#define UART3_INT 29
|
||||
#define I2C2_INT 30
|
||||
#define I2S_INT 31
|
||||
|
||||
#define VECT_ADDR_INDEX 0x100
|
||||
#define VECT_CNTL_INDEX 0x200
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "cpu.h"
|
||||
|
||||
bool cpu_install_irq(int IntNumber, void *HandlerAddr, int Priority);
|
||||
|
||||
/** @} */
|
||||
#endif /*ARMVIC_H_*/
|
||||
|
@ -1,96 +1,96 @@
|
||||
@-----------------------------------------------------------@
|
||||
@ Fast Block Copy (declared in diskio.h)
|
||||
@-----------------------------------------------------------@
|
||||
|
||||
.global Copy_un2al
|
||||
.arm
|
||||
Copy_un2al:
|
||||
STMFD SP!, {R4-R8}
|
||||
ANDS IP, R1, #3
|
||||
BEQ lb_align
|
||||
|
||||
BIC R1, #3
|
||||
MOV IP, IP, LSL #3
|
||||
RSB R8, IP, #32
|
||||
LDMIA R1!, {R7}
|
||||
lb_l1: MOV R3, R7
|
||||
LDMIA R1!, {R4-R7}
|
||||
MOV R3, R3, LSR IP
|
||||
ORR R3, R3, R4, LSL R8
|
||||
MOV R4, R4, LSR IP
|
||||
ORR R4, R4, R5, LSL R8
|
||||
MOV R5, R5, LSR IP
|
||||
ORR R5, R5, R6, LSL R8
|
||||
MOV R6, R6, LSR IP
|
||||
ORR R6, R6, R7, LSL R8
|
||||
SUBS R2, R2, #16
|
||||
STMIA R0!, {R3-R6}
|
||||
BNE lb_l1
|
||||
LDMFD SP!, {R4-R8}
|
||||
BX LR
|
||||
|
||||
lb_align:
|
||||
LDMIA R1!, {R3-R6}
|
||||
SUBS R2, R2, #16
|
||||
STMIA R0!, {R3-R6}
|
||||
BNE lb_align
|
||||
LDMFD SP!, {R4-R8}
|
||||
BX LR
|
||||
|
||||
|
||||
.global Copy_al2un
|
||||
.arm
|
||||
Copy_al2un:
|
||||
STMFD SP!, {R4-R8}
|
||||
ANDS IP, R0, #3
|
||||
BEQ sb_align
|
||||
|
||||
MOV IP, IP, LSL #3
|
||||
RSB R8, IP, #32
|
||||
|
||||
LDMIA R1!, {R4-R7}
|
||||
sb_p1: STRB R4, [R0], #1
|
||||
MOV R4, R4, LSR #8
|
||||
TST R0, #3
|
||||
BNE sb_p1
|
||||
ORR R4, R4, R5, LSL IP
|
||||
MOV R5, R5, LSR R8
|
||||
ORR R5, R5, R6, LSL IP
|
||||
MOV R6, R6, LSR R8
|
||||
ORR R6, R6, R7, LSL IP
|
||||
SUBS R2, R2, #16
|
||||
STMIA R0!, {R4-R6}
|
||||
|
||||
sb_l1: MOV R3, R7
|
||||
LDMIA R1!, {R4-R7}
|
||||
MOV R3, R3, LSR R8
|
||||
ORR R3, R3, R4, LSL IP
|
||||
MOV R4, R4, LSR R8
|
||||
ORR R4, R4, R5, LSL IP
|
||||
MOV R5, R5, LSR R8
|
||||
ORR R5, R5, R6, LSL IP
|
||||
MOV R6, R6, LSR R8
|
||||
ORR R6, R6, R7, LSL IP
|
||||
SUBS R2, R2, #16
|
||||
STMIA R0!, {R3-R6}
|
||||
BNE sb_l1
|
||||
|
||||
MOV R7, R7, LSR R8
|
||||
sb_p2: SUBS IP, IP, #8
|
||||
STRB R7, [R0], #1
|
||||
MOV R7, R7, LSR #8
|
||||
BNE sb_p2
|
||||
|
||||
LDMFD SP!, {R4-R8}
|
||||
BX LR
|
||||
|
||||
sb_align:
|
||||
LDMIA R1!, {R3-R6}
|
||||
SUBS R2, #16
|
||||
STMIA R0!, {R3-R6}
|
||||
BNE sb_align
|
||||
LDMFD SP!, {R4-R8}
|
||||
BX LR
|
||||
|
||||
.end
|
||||
|
||||
@-----------------------------------------------------------@
|
||||
@ Fast Block Copy (declared in diskio.h)
|
||||
@-----------------------------------------------------------@
|
||||
|
||||
.global Copy_un2al
|
||||
.arm
|
||||
Copy_un2al:
|
||||
STMFD SP!, {R4-R8}
|
||||
ANDS IP, R1, #3
|
||||
BEQ lb_align
|
||||
|
||||
BIC R1, #3
|
||||
MOV IP, IP, LSL #3
|
||||
RSB R8, IP, #32
|
||||
LDMIA R1!, {R7}
|
||||
lb_l1: MOV R3, R7
|
||||
LDMIA R1!, {R4-R7}
|
||||
MOV R3, R3, LSR IP
|
||||
ORR R3, R3, R4, LSL R8
|
||||
MOV R4, R4, LSR IP
|
||||
ORR R4, R4, R5, LSL R8
|
||||
MOV R5, R5, LSR IP
|
||||
ORR R5, R5, R6, LSL R8
|
||||
MOV R6, R6, LSR IP
|
||||
ORR R6, R6, R7, LSL R8
|
||||
SUBS R2, R2, #16
|
||||
STMIA R0!, {R3-R6}
|
||||
BNE lb_l1
|
||||
LDMFD SP!, {R4-R8}
|
||||
BX LR
|
||||
|
||||
lb_align:
|
||||
LDMIA R1!, {R3-R6}
|
||||
SUBS R2, R2, #16
|
||||
STMIA R0!, {R3-R6}
|
||||
BNE lb_align
|
||||
LDMFD SP!, {R4-R8}
|
||||
BX LR
|
||||
|
||||
|
||||
.global Copy_al2un
|
||||
.arm
|
||||
Copy_al2un:
|
||||
STMFD SP!, {R4-R8}
|
||||
ANDS IP, R0, #3
|
||||
BEQ sb_align
|
||||
|
||||
MOV IP, IP, LSL #3
|
||||
RSB R8, IP, #32
|
||||
|
||||
LDMIA R1!, {R4-R7}
|
||||
sb_p1: STRB R4, [R0], #1
|
||||
MOV R4, R4, LSR #8
|
||||
TST R0, #3
|
||||
BNE sb_p1
|
||||
ORR R4, R4, R5, LSL IP
|
||||
MOV R5, R5, LSR R8
|
||||
ORR R5, R5, R6, LSL IP
|
||||
MOV R6, R6, LSR R8
|
||||
ORR R6, R6, R7, LSL IP
|
||||
SUBS R2, R2, #16
|
||||
STMIA R0!, {R4-R6}
|
||||
|
||||
sb_l1: MOV R3, R7
|
||||
LDMIA R1!, {R4-R7}
|
||||
MOV R3, R3, LSR R8
|
||||
ORR R3, R3, R4, LSL IP
|
||||
MOV R4, R4, LSR R8
|
||||
ORR R4, R4, R5, LSL IP
|
||||
MOV R5, R5, LSR R8
|
||||
ORR R5, R5, R6, LSL IP
|
||||
MOV R6, R6, LSR R8
|
||||
ORR R6, R6, R7, LSL IP
|
||||
SUBS R2, R2, #16
|
||||
STMIA R0!, {R3-R6}
|
||||
BNE sb_l1
|
||||
|
||||
MOV R7, R7, LSR R8
|
||||
sb_p2: SUBS IP, IP, #8
|
||||
STRB R7, [R0], #1
|
||||
MOV R7, R7, LSR #8
|
||||
BNE sb_p2
|
||||
|
||||
LDMFD SP!, {R4-R8}
|
||||
BX LR
|
||||
|
||||
sb_align:
|
||||
LDMIA R1!, {R3-R6}
|
||||
SUBS R2, #16
|
||||
STMIA R0!, {R3-R6}
|
||||
BNE sb_align
|
||||
LDMFD SP!, {R4-R8}
|
||||
BX LR
|
||||
|
||||
.end
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,2 +1,2 @@
|
||||
</body>
|
||||
</html>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* destiny.h
|
||||
*
|
||||
* Created on: 03.09.2011
|
||||
* Author: Oliver
|
||||
*/
|
||||
|
||||
#ifndef DESTINY_H_
|
||||
#define DESTINY_H_
|
||||
|
||||
void init_transport_layer(void);
|
||||
|
||||
#endif /* DESTINY_H_ */
|
||||
/*
|
||||
* destiny.h
|
||||
*
|
||||
* Created on: 03.09.2011
|
||||
* Author: Oliver
|
||||
*/
|
||||
|
||||
#ifndef DESTINY_H_
|
||||
#define DESTINY_H_
|
||||
|
||||
void init_transport_layer(void);
|
||||
|
||||
#endif /* DESTINY_H_ */
|
||||
|
@ -1,133 +1,133 @@
|
||||
/*
|
||||
* in.h
|
||||
*
|
||||
* Created on: 16.09.2011
|
||||
* Author: Oliver
|
||||
*/
|
||||
|
||||
#ifndef IN_H_
|
||||
#define IN_H_
|
||||
/*
|
||||
* Constants and structures defined by the internet system,
|
||||
* Per RFC 790, September 1981, and numerous additions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Protocols (RFC 1700)
|
||||
*/
|
||||
#define IPPROTO_IP (0) /* dummy for IP */
|
||||
#define IPPROTO_HOPOPTS (0) /* IP6 hop-by-hop options */
|
||||
#define IPPROTO_ICMP (1) /* control message protocol */
|
||||
#define IPPROTO_IGMP (2) /* group mgmt protocol */
|
||||
#define IPPROTO_GGP (3) /* gateway^2 (deprecated) */
|
||||
#define IPPROTO_IPV4 (4) /* IPv4 encapsulation */
|
||||
#define IPPROTO_IPIP IPPROTO_IPV4 /* for compatibility */
|
||||
#define IPPROTO_TCP (6) /* tcp */
|
||||
#define IPPROTO_ST (7) /* Stream protocol II */
|
||||
#define IPPROTO_EGP (8) /* exterior gateway protocol */
|
||||
#define IPPROTO_PIGP (9) /* private interior gateway */
|
||||
#define IPPROTO_RCCMON (10) /* BBN RCC Monitoring */
|
||||
#define IPPROTO_NVPII (11) /* network voice protocol*/
|
||||
#define IPPROTO_PUP (12) /* pup */
|
||||
#define IPPROTO_ARGUS (13) /* Argus */
|
||||
#define IPPROTO_EMCON (14) /* EMCON */
|
||||
#define IPPROTO_XNET (15) /* Cross Net Debugger */
|
||||
#define IPPROTO_CHAOS (16) /* Chaos*/
|
||||
#define IPPROTO_UDP (17) /* user datagram protocol */
|
||||
#define IPPROTO_MUX (18) /* Multiplexing */
|
||||
#define IPPROTO_MEAS (19) /* DCN Measurement Subsystems */
|
||||
#define IPPROTO_HMP (20) /* Host Monitoring */
|
||||
#define IPPROTO_PRM (21) /* Packet Radio Measurement */
|
||||
#define IPPROTO_IDP (22) /* xns idp */
|
||||
#define IPPROTO_TRUNK1 (23) /* Trunk-1 */
|
||||
#define IPPROTO_TRUNK2 (24) /* Trunk-2 */
|
||||
#define IPPROTO_LEAF1 (25) /* Leaf-1 */
|
||||
#define IPPROTO_LEAF2 (26) /* Leaf-2 */
|
||||
#define IPPROTO_RDP (27) /* Reliable Data */
|
||||
#define IPPROTO_IRTP (28) /* Reliable Transaction */
|
||||
#define IPPROTO_TP (29) /* tp-4 w/ class negotiation */
|
||||
#define IPPROTO_BLT (30) /* Bulk Data Transfer */
|
||||
#define IPPROTO_NSP (31) /* Network Services */
|
||||
#define IPPROTO_INP (32) /* Merit Internodal */
|
||||
#define IPPROTO_SEP (33) /* Sequential Exchange */
|
||||
#define IPPROTO_3PC (34) /* Third Party Connect */
|
||||
#define IPPROTO_IDPR (35) /* InterDomain Policy Routing */
|
||||
#define IPPROTO_XTP (36) /* XTP */
|
||||
#define IPPROTO_DDP (37) /* Datagram Delivery */
|
||||
#define IPPROTO_CMTP (38) /* Control Message Transport */
|
||||
#define IPPROTO_TPXX (39) /* TP++ Transport */
|
||||
#define IPPROTO_IL (40) /* IL transport protocol */
|
||||
#define IPPROTO_IPV6 (41) /* IP6 header */
|
||||
#define IPPROTO_SDRP (42) /* Source Demand Routing */
|
||||
#define IPPROTO_ROUTING (43) /* IP6 routing header */
|
||||
#define IPPROTO_FRAGMENT (44) /* IP6 fragmentation header */
|
||||
#define IPPROTO_IDRP (45) /* InterDomain Routing*/
|
||||
#define IPPROTO_RSVP (46) /* resource reservation */
|
||||
#define IPPROTO_GRE (47) /* General Routing Encap. */
|
||||
#define IPPROTO_MHRP (48) /* Mobile Host Routing */
|
||||
#define IPPROTO_BHA (49) /* BHA */
|
||||
#define IPPROTO_ESP (50) /* IP6 Encap Sec. Payload */
|
||||
#define IPPROTO_AH (51) /* IP6 Auth Header */
|
||||
#define IPPROTO_INLSP (52) /* Integ. Net Layer Security */
|
||||
#define IPPROTO_SWIPE (53) /* IP with encryption */
|
||||
#define IPPROTO_NHRP (54) /* Next Hop Resolution */
|
||||
/* 55-57: Unassigned */
|
||||
#define IPPROTO_ICMPV6 (58) /* ICMP6 */
|
||||
#define IPPROTO_NONE (59) /* IP6 no next header */
|
||||
#define IPPROTO_DSTOPTS (60) /* IP6 destination option */
|
||||
#define IPPROTO_AHIP (61) /* any host internal protocol */
|
||||
#define IPPROTO_CFTP (62) /* CFTP */
|
||||
#define IPPROTO_HELLO (63) /* "hello" routing protocol */
|
||||
#define IPPROTO_SATEXPAK (64) /* SATNET/Backroom EXPAK */
|
||||
#define IPPROTO_KRYPTOLAN (65) /* Kryptolan */
|
||||
#define IPPROTO_RVD (66) /* Remote Virtual Disk */
|
||||
#define IPPROTO_IPPC (67) /* Pluribus Packet Core */
|
||||
#define IPPROTO_ADFS (68) /* Any distributed FS */
|
||||
#define IPPROTO_SATMON (69) /* Satnet Monitoring */
|
||||
#define IPPROTO_VISA (70) /* VISA Protocol */
|
||||
#define IPPROTO_IPCV (71) /* Packet Core Utility */
|
||||
#define IPPROTO_CPNX (72) /* Comp. Prot. Net. Executive */
|
||||
#define IPPROTO_CPHB (73) /* Comp. Prot. HeartBeat */
|
||||
#define IPPROTO_WSN (74) /* Wang Span Network */
|
||||
#define IPPROTO_PVP (75) /* Packet Video Protocol */
|
||||
#define IPPROTO_BRSATMON (76) /* BackRoom SATNET Monitoring */
|
||||
#define IPPROTO_ND (77) /* Sun net disk proto (temp.) */
|
||||
#define IPPROTO_WBMON (78) /* WIDEBAND Monitoring */
|
||||
#define IPPROTO_WBEXPAK (79) /* WIDEBAND EXPAK */
|
||||
#define IPPROTO_EON (80) /* ISO cnlp */
|
||||
#define IPPROTO_VMTP (81) /* VMTP */
|
||||
#define IPPROTO_SVMTP (82) /* Secure VMTP */
|
||||
#define IPPROTO_VINES (83) /* Banyon VINES */
|
||||
#define IPPROTO_TTP (84) /* TTP */
|
||||
#define IPPROTO_IGP (85) /* NSFNET-IGP */
|
||||
#define IPPROTO_DGP (86) /* dissimilar gateway prot. */
|
||||
#define IPPROTO_TCF (87) /* TCF */
|
||||
#define IPPROTO_IGRP (88) /* Cisco/GXS IGRP */
|
||||
#define IPPROTO_OSPFIGP (89) /* OSPFIGP */
|
||||
#define IPPROTO_SRPC (90) /* Strite RPC protocol */
|
||||
#define IPPROTO_LARP (91) /* Locus Address Resoloution */
|
||||
#define IPPROTO_MTP (92) /* Multicast Transport */
|
||||
#define IPPROTO_AX25 (93) /* AX.25 Frames */
|
||||
#define IPPROTO_IPEIP (94) /* IP encapsulated in IP */
|
||||
#define IPPROTO_MICP (95) /* Mobile Int.ing control */
|
||||
#define IPPROTO_SCCSP (96) /* Semaphore Comm. security */
|
||||
#define IPPROTO_ETHERIP (97) /* Ethernet IP encapsulation */
|
||||
#define IPPROTO_ENCAP (98) /* encapsulation header */
|
||||
#define IPPROTO_APES (99) /* any private encr. scheme */
|
||||
#define IPPROTO_GMTP (100) /* GMTP*/
|
||||
#define IPPROTO_IPCOMP (108) /* payload compression (IPComp) */
|
||||
/* 101-254: Partly Unassigned */
|
||||
#define IPPROTO_PIM (103) /* Protocol Independent Mcast */
|
||||
#define IPPROTO_PGM (113) /* PGM */
|
||||
/* 255: Reserved */
|
||||
/* BSD Private, local use, namespace incursion */
|
||||
#define IPPROTO_DIVERT (254) /* divert pseudo-protocol */
|
||||
#define IPPROTO_RAW (255) /* raw IP packet */
|
||||
#define IPPROTO_MAX (256)
|
||||
|
||||
/* last return value of *_input(), meaning "all job for this pkt is done". */
|
||||
#define IPPROTO_DONE (257)
|
||||
|
||||
#define IN_LOOPBACKNET (127) /* official! */
|
||||
|
||||
#endif /* IN_H_ */
|
||||
/*
|
||||
* in.h
|
||||
*
|
||||
* Created on: 16.09.2011
|
||||
* Author: Oliver
|
||||
*/
|
||||
|
||||
#ifndef IN_H_
|
||||
#define IN_H_
|
||||
/*
|
||||
* Constants and structures defined by the internet system,
|
||||
* Per RFC 790, September 1981, and numerous additions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Protocols (RFC 1700)
|
||||
*/
|
||||
#define IPPROTO_IP (0) /* dummy for IP */
|
||||
#define IPPROTO_HOPOPTS (0) /* IP6 hop-by-hop options */
|
||||
#define IPPROTO_ICMP (1) /* control message protocol */
|
||||
#define IPPROTO_IGMP (2) /* group mgmt protocol */
|
||||
#define IPPROTO_GGP (3) /* gateway^2 (deprecated) */
|
||||
#define IPPROTO_IPV4 (4) /* IPv4 encapsulation */
|
||||
#define IPPROTO_IPIP IPPROTO_IPV4 /* for compatibility */
|
||||
#define IPPROTO_TCP (6) /* tcp */
|
||||
#define IPPROTO_ST (7) /* Stream protocol II */
|
||||
#define IPPROTO_EGP (8) /* exterior gateway protocol */
|
||||
#define IPPROTO_PIGP (9) /* private interior gateway */
|
||||
#define IPPROTO_RCCMON (10) /* BBN RCC Monitoring */
|
||||
#define IPPROTO_NVPII (11) /* network voice protocol*/
|
||||
#define IPPROTO_PUP (12) /* pup */
|
||||
#define IPPROTO_ARGUS (13) /* Argus */
|
||||
#define IPPROTO_EMCON (14) /* EMCON */
|
||||
#define IPPROTO_XNET (15) /* Cross Net Debugger */
|
||||
#define IPPROTO_CHAOS (16) /* Chaos*/
|
||||
#define IPPROTO_UDP (17) /* user datagram protocol */
|
||||
#define IPPROTO_MUX (18) /* Multiplexing */
|
||||
#define IPPROTO_MEAS (19) /* DCN Measurement Subsystems */
|
||||
#define IPPROTO_HMP (20) /* Host Monitoring */
|
||||
#define IPPROTO_PRM (21) /* Packet Radio Measurement */
|
||||
#define IPPROTO_IDP (22) /* xns idp */
|
||||
#define IPPROTO_TRUNK1 (23) /* Trunk-1 */
|
||||
#define IPPROTO_TRUNK2 (24) /* Trunk-2 */
|
||||
#define IPPROTO_LEAF1 (25) /* Leaf-1 */
|
||||
#define IPPROTO_LEAF2 (26) /* Leaf-2 */
|
||||
#define IPPROTO_RDP (27) /* Reliable Data */
|
||||
#define IPPROTO_IRTP (28) /* Reliable Transaction */
|
||||
#define IPPROTO_TP (29) /* tp-4 w/ class negotiation */
|
||||
#define IPPROTO_BLT (30) /* Bulk Data Transfer */
|
||||
#define IPPROTO_NSP (31) /* Network Services */
|
||||
#define IPPROTO_INP (32) /* Merit Internodal */
|
||||
#define IPPROTO_SEP (33) /* Sequential Exchange */
|
||||
#define IPPROTO_3PC (34) /* Third Party Connect */
|
||||
#define IPPROTO_IDPR (35) /* InterDomain Policy Routing */
|
||||
#define IPPROTO_XTP (36) /* XTP */
|
||||
#define IPPROTO_DDP (37) /* Datagram Delivery */
|
||||
#define IPPROTO_CMTP (38) /* Control Message Transport */
|
||||
#define IPPROTO_TPXX (39) /* TP++ Transport */
|
||||
#define IPPROTO_IL (40) /* IL transport protocol */
|
||||
#define IPPROTO_IPV6 (41) /* IP6 header */
|
||||
#define IPPROTO_SDRP (42) /* Source Demand Routing */
|
||||
#define IPPROTO_ROUTING (43) /* IP6 routing header */
|
||||
#define IPPROTO_FRAGMENT (44) /* IP6 fragmentation header */
|
||||
#define IPPROTO_IDRP (45) /* InterDomain Routing*/
|
||||
#define IPPROTO_RSVP (46) /* resource reservation */
|
||||
#define IPPROTO_GRE (47) /* General Routing Encap. */
|
||||
#define IPPROTO_MHRP (48) /* Mobile Host Routing */
|
||||
#define IPPROTO_BHA (49) /* BHA */
|
||||
#define IPPROTO_ESP (50) /* IP6 Encap Sec. Payload */
|
||||
#define IPPROTO_AH (51) /* IP6 Auth Header */
|
||||
#define IPPROTO_INLSP (52) /* Integ. Net Layer Security */
|
||||
#define IPPROTO_SWIPE (53) /* IP with encryption */
|
||||
#define IPPROTO_NHRP (54) /* Next Hop Resolution */
|
||||
/* 55-57: Unassigned */
|
||||
#define IPPROTO_ICMPV6 (58) /* ICMP6 */
|
||||
#define IPPROTO_NONE (59) /* IP6 no next header */
|
||||
#define IPPROTO_DSTOPTS (60) /* IP6 destination option */
|
||||
#define IPPROTO_AHIP (61) /* any host internal protocol */
|
||||
#define IPPROTO_CFTP (62) /* CFTP */
|
||||
#define IPPROTO_HELLO (63) /* "hello" routing protocol */
|
||||
#define IPPROTO_SATEXPAK (64) /* SATNET/Backroom EXPAK */
|
||||
#define IPPROTO_KRYPTOLAN (65) /* Kryptolan */
|
||||
#define IPPROTO_RVD (66) /* Remote Virtual Disk */
|
||||
#define IPPROTO_IPPC (67) /* Pluribus Packet Core */
|
||||
#define IPPROTO_ADFS (68) /* Any distributed FS */
|
||||
#define IPPROTO_SATMON (69) /* Satnet Monitoring */
|
||||
#define IPPROTO_VISA (70) /* VISA Protocol */
|
||||
#define IPPROTO_IPCV (71) /* Packet Core Utility */
|
||||
#define IPPROTO_CPNX (72) /* Comp. Prot. Net. Executive */
|
||||
#define IPPROTO_CPHB (73) /* Comp. Prot. HeartBeat */
|
||||
#define IPPROTO_WSN (74) /* Wang Span Network */
|
||||
#define IPPROTO_PVP (75) /* Packet Video Protocol */
|
||||
#define IPPROTO_BRSATMON (76) /* BackRoom SATNET Monitoring */
|
||||
#define IPPROTO_ND (77) /* Sun net disk proto (temp.) */
|
||||
#define IPPROTO_WBMON (78) /* WIDEBAND Monitoring */
|
||||
#define IPPROTO_WBEXPAK (79) /* WIDEBAND EXPAK */
|
||||
#define IPPROTO_EON (80) /* ISO cnlp */
|
||||
#define IPPROTO_VMTP (81) /* VMTP */
|
||||
#define IPPROTO_SVMTP (82) /* Secure VMTP */
|
||||
#define IPPROTO_VINES (83) /* Banyon VINES */
|
||||
#define IPPROTO_TTP (84) /* TTP */
|
||||
#define IPPROTO_IGP (85) /* NSFNET-IGP */
|
||||
#define IPPROTO_DGP (86) /* dissimilar gateway prot. */
|
||||
#define IPPROTO_TCF (87) /* TCF */
|
||||
#define IPPROTO_IGRP (88) /* Cisco/GXS IGRP */
|
||||
#define IPPROTO_OSPFIGP (89) /* OSPFIGP */
|
||||
#define IPPROTO_SRPC (90) /* Strite RPC protocol */
|
||||
#define IPPROTO_LARP (91) /* Locus Address Resoloution */
|
||||
#define IPPROTO_MTP (92) /* Multicast Transport */
|
||||
#define IPPROTO_AX25 (93) /* AX.25 Frames */
|
||||
#define IPPROTO_IPEIP (94) /* IP encapsulated in IP */
|
||||
#define IPPROTO_MICP (95) /* Mobile Int.ing control */
|
||||
#define IPPROTO_SCCSP (96) /* Semaphore Comm. security */
|
||||
#define IPPROTO_ETHERIP (97) /* Ethernet IP encapsulation */
|
||||
#define IPPROTO_ENCAP (98) /* encapsulation header */
|
||||
#define IPPROTO_APES (99) /* any private encr. scheme */
|
||||
#define IPPROTO_GMTP (100) /* GMTP*/
|
||||
#define IPPROTO_IPCOMP (108) /* payload compression (IPComp) */
|
||||
/* 101-254: Partly Unassigned */
|
||||
#define IPPROTO_PIM (103) /* Protocol Independent Mcast */
|
||||
#define IPPROTO_PGM (113) /* PGM */
|
||||
/* 255: Reserved */
|
||||
/* BSD Private, local use, namespace incursion */
|
||||
#define IPPROTO_DIVERT (254) /* divert pseudo-protocol */
|
||||
#define IPPROTO_RAW (255) /* raw IP packet */
|
||||
#define IPPROTO_MAX (256)
|
||||
|
||||
/* last return value of *_input(), meaning "all job for this pkt is done". */
|
||||
#define IPPROTO_DONE (257)
|
||||
|
||||
#define IN_LOOPBACKNET (127) /* official! */
|
||||
|
||||
#endif /* IN_H_ */
|
||||
|
@ -1,248 +1,248 @@
|
||||
/**
|
||||
* Destiny socket API
|
||||
*
|
||||
* Copyright (C) 2013 INRIA.
|
||||
*
|
||||
* This file subject to the terms and conditions of the GNU Lesser General
|
||||
* Public License. See the file LICENSE in the top level directory for more
|
||||
* details.
|
||||
*
|
||||
* @ingroup destiny
|
||||
* @{
|
||||
* @file socket.h
|
||||
* @brief header for BSD socket API
|
||||
* @author Oliver Gesch <oliver.gesch@googlemail.com>
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SOCKET_H_
|
||||
#define SOCKET_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "tcp.h"
|
||||
#include "udp.h"
|
||||
#include "in.h"
|
||||
#include "../sixlowpan/sixlowip.h"
|
||||
|
||||
/*
|
||||
* POSIX compatibility
|
||||
*/
|
||||
typedef uint8_t sa_family_t;
|
||||
typedef uint32_t socklen_t;
|
||||
|
||||
/*
|
||||
* Types
|
||||
*/
|
||||
#define SOCK_STREAM 1 /* stream socket */
|
||||
#define SOCK_DGRAM 2 /* datagram socket */
|
||||
#define SOCK_RAW 3 /* raw-protocol interface */
|
||||
#define SOCK_RDM 4 /* reliably-delivered message */
|
||||
#define SOCK_SEQPACKET 5 /* sequenced packet stream */
|
||||
|
||||
/*
|
||||
* Address families.
|
||||
*/
|
||||
#define AF_UNSPEC 0 /* unspecified */
|
||||
#define AF_LOCAL 1 /* local to host (pipes, portals) */
|
||||
#define AF_UNIX AF_LOCAL /* backward compatibility */
|
||||
#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
|
||||
#define AF_IMPLINK 3 /* arpanet imp addresses */
|
||||
#define AF_PUP 4 /* pup protocols: e.g. BSP */
|
||||
#define AF_CHAOS 5 /* mit CHAOS protocols */
|
||||
#define AF_NS 6 /* XEROX NS protocols */
|
||||
#define AF_ISO 7 /* ISO protocols */
|
||||
#define AF_OSI AF_ISO
|
||||
#define AF_ECMA 8 /* European computer manufacturers */
|
||||
#define AF_DATAKIT 9 /* datakit protocols */
|
||||
#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
|
||||
#define AF_SNA 11 /* IBM SNA */
|
||||
#define AF_DECnet 12 /* DECnet */
|
||||
#define AF_DLI 13 /* DEC Direct data link interface */
|
||||
#define AF_LAT 14 /* LAT */
|
||||
#define AF_HYLINK 15 /* NSC Hyperchannel */
|
||||
#define AF_APPLETALK 16 /* Apple Talk */
|
||||
#define AF_ROUTE 17 /* Internal Routing Protocol */
|
||||
#define AF_LINK 18 /* Link layer interface */
|
||||
#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */
|
||||
#define AF_COIP 20 /* connection-oriented IP, aka ST II */
|
||||
#define AF_CNT 21 /* Computer Network Technology */
|
||||
#define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */
|
||||
#define AF_IPX 23 /* Novell Internet Protocol */
|
||||
#define AF_SIP 24 /* Simple Internet Protocol */
|
||||
#define pseudo_AF_PIP 25 /* Help Identify PIP packets */
|
||||
#define AF_ISDN 26 /* Integrated Services Digital Network*/
|
||||
#define AF_E164 AF_ISDN /* CCITT E.164 recommendation */
|
||||
#define pseudo_AF_KEY 27 /* Internal key-management function */
|
||||
#define AF_INET6 28 /* IPv6 */
|
||||
#define AF_NATM 29 /* native ATM access */
|
||||
#define AF_ATM 30 /* ATM */
|
||||
#define pseudo_AF_HDRCMPLT 31 /* Used by BPF to not rewrite headers
|
||||
* in interface output routine
|
||||
*/
|
||||
#define AF_NETGRAPH 32 /* Netgraph sockets */
|
||||
#define AF_MAX 33
|
||||
|
||||
/*
|
||||
* Protocol families, same as address families for now.
|
||||
*/
|
||||
#define PF_UNSPEC AF_UNSPEC
|
||||
#define PF_LOCAL AF_LOCAL
|
||||
#define PF_UNIX PF_LOCAL /* backward compatibility */
|
||||
#define PF_INET AF_INET
|
||||
#define PF_IMPLINK AF_IMPLINK
|
||||
#define PF_PUP AF_PUP
|
||||
#define PF_CHAOS AF_CHAOS
|
||||
#define PF_NS AF_NS
|
||||
#define PF_ISO AF_ISO
|
||||
#define PF_OSI AF_ISO
|
||||
#define PF_ECMA AF_ECMA
|
||||
#define PF_DATAKIT AF_DATAKIT
|
||||
#define PF_CCITT AF_CCITT
|
||||
#define PF_SNA AF_SNA
|
||||
#define PF_DECnet AF_DECnet
|
||||
#define PF_DLI AF_DLI
|
||||
#define PF_LAT AF_LAT
|
||||
#define PF_HYLINK AF_HYLINK
|
||||
#define PF_APPLETALK AF_APPLETALK
|
||||
#define PF_ROUTE AF_ROUTE
|
||||
#define PF_LINK AF_LINK
|
||||
#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */
|
||||
#define PF_COIP AF_COIP
|
||||
#define PF_CNT AF_CNT
|
||||
#define PF_SIP AF_SIP
|
||||
#define PF_IPX AF_IPX /* same format as AF_NS */
|
||||
#define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */
|
||||
#define PF_PIP pseudo_AF_PIP
|
||||
#define PF_ISDN AF_ISDN
|
||||
#define PF_KEY pseudo_AF_KEY
|
||||
#define PF_INET6 AF_INET6
|
||||
#define PF_NATM AF_NATM
|
||||
#define PF_ATM AF_ATM
|
||||
#define PF_NETGRAPH AF_NETGRAPH
|
||||
#define PF_MAX AF_MAX
|
||||
|
||||
#define MAX_SOCKETS 5
|
||||
// #define MAX_QUEUED_SOCKETS 2
|
||||
|
||||
#define EPHEMERAL_PORTS 49152
|
||||
|
||||
#define STATIC_MSS 48
|
||||
#define STATIC_WINDOW 1 * STATIC_MSS
|
||||
#define MAX_TCP_BUFFER 1 * STATIC_WINDOW
|
||||
|
||||
#define INC_PACKET 0
|
||||
#define OUT_PACKET 1
|
||||
|
||||
#define SEND_MSG_BUF_SIZE 64
|
||||
|
||||
typedef struct socka6 {
|
||||
uint8_t sin6_family; /* AF_INET6 */
|
||||
uint16_t sin6_port; /* transport layer port # */
|
||||
uint32_t sin6_flowinfo; /* IPv6 flow information */
|
||||
ipv6_addr_t sin6_addr; /* IPv6 address */
|
||||
} sockaddr6_t;
|
||||
|
||||
typedef struct tcp_hc_con {
|
||||
uint16_t context_id;
|
||||
uint32_t seq_rcv; // Last received packet values
|
||||
uint32_t ack_rcv;
|
||||
uint16_t wnd_rcv;
|
||||
uint32_t seq_snd; // Last sent packet values
|
||||
uint32_t ack_snd;
|
||||
uint16_t wnd_snd;
|
||||
uint8_t hc_type;
|
||||
} tcp_hc_context_t;
|
||||
|
||||
typedef struct tcp_control_block {
|
||||
uint32_t send_una;
|
||||
uint32_t send_nxt;
|
||||
uint16_t send_wnd;
|
||||
uint32_t send_iss;
|
||||
|
||||
uint32_t rcv_nxt;
|
||||
uint16_t rcv_wnd;
|
||||
uint32_t rcv_irs;
|
||||
|
||||
timex_t last_packet_time;
|
||||
uint8_t no_of_retries;
|
||||
uint16_t mss;
|
||||
|
||||
uint8_t state;
|
||||
|
||||
double srtt;
|
||||
double rttvar;
|
||||
double rto;
|
||||
|
||||
#ifdef TCP_HC
|
||||
tcp_hc_context_t tcp_context;
|
||||
#endif
|
||||
|
||||
} tcp_cb_t;
|
||||
|
||||
typedef struct sock_t {
|
||||
uint8_t domain;
|
||||
uint8_t type;
|
||||
uint8_t protocol;
|
||||
tcp_cb_t tcp_control;
|
||||
sockaddr6_t local_address;
|
||||
sockaddr6_t foreign_address;
|
||||
} socket_t;
|
||||
|
||||
typedef struct socket_in_t {
|
||||
uint8_t socket_id;
|
||||
uint8_t recv_pid;
|
||||
uint8_t send_pid;
|
||||
uint8_t tcp_input_buffer_end;
|
||||
mutex_t tcp_buffer_mutex;
|
||||
socket_t socket_values;
|
||||
uint8_t tcp_input_buffer[MAX_TCP_BUFFER];
|
||||
} socket_internal_t;
|
||||
|
||||
extern socket_internal_t sockets[MAX_SOCKETS];
|
||||
|
||||
int socket(int domain, int type, int protocol);
|
||||
int connect(int socket, sockaddr6_t *addr, socklen_t addrlen);
|
||||
socket_internal_t *getWaitingConnectionSocket(int socket,
|
||||
ipv6_hdr_t *ipv6_header,
|
||||
tcp_hdr_t *tcp_header);
|
||||
void close_socket(socket_internal_t *current_socket);
|
||||
int32_t recvfrom(int s, void *buf, uint32_t len, int flags, sockaddr6_t *from,
|
||||
socklen_t *fromlen);
|
||||
int32_t sendto(int s, const void *msg, uint32_t len, int flags,
|
||||
sockaddr6_t *to, socklen_t tolen);
|
||||
int32_t send(int s, void *msg, uint32_t len, int flags);
|
||||
int recv(int s, void *buf, uint32_t len, int flags);
|
||||
int close(int s);
|
||||
int bind(int s, sockaddr6_t *name, int namelen);
|
||||
int listen(int s, int backlog);
|
||||
int accept(int s, sockaddr6_t *addr, socklen_t *addrlen);
|
||||
void socket_init(void);
|
||||
socket_internal_t *get_udp_socket(ipv6_hdr_t *ipv6_header, udp_hdr_t *udp_header);
|
||||
socket_internal_t *get_tcp_socket(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header);
|
||||
socket_internal_t *getSocket(uint8_t s);
|
||||
void print_sockets(void);
|
||||
void print_internal_socket(socket_internal_t *current_socket_internal);
|
||||
void print_socket(socket_t *current_socket);
|
||||
void printf_tcp_context(tcp_hc_context_t *current_tcp_context);
|
||||
bool exists_socket(uint8_t socket);
|
||||
socket_internal_t *new_tcp_queued_socket(ipv6_hdr_t *ipv6_header,
|
||||
tcp_hdr_t *tcp_header);
|
||||
void print_tcp_status(int in_or_out, ipv6_hdr_t *ipv6_header,
|
||||
tcp_hdr_t *tcp_header, socket_t *tcp_socket);
|
||||
void set_socket_address(sockaddr6_t *sockaddr, sa_family_t sin6_family,
|
||||
uint16_t sin6_port, uint32_t sin6_flowinfo,
|
||||
ipv6_addr_t *sin6_addr);
|
||||
void set_tcp_cb(tcp_cb_t *tcp_control, uint32_t rcv_nxt, uint16_t rcv_wnd,
|
||||
uint32_t send_nxt, uint32_t send_una, uint16_t send_wnd);
|
||||
void set_tcp_packet(tcp_hdr_t *tcp_hdr, uint16_t src_port, uint16_t dst_port,
|
||||
uint32_t seq_nr, uint32_t ack_nr,
|
||||
uint8_t dataOffset_reserved, uint8_t reserved_flags,
|
||||
uint16_t window, uint16_t checksum, uint16_t urg_pointer);
|
||||
int check_tcp_consistency(socket_t *current_tcp_socket, tcp_hdr_t *tcp_header);
|
||||
void switch_tcp_packet_byte_order(tcp_hdr_t *current_tcp_packet);
|
||||
int send_tcp(socket_internal_t *current_socket, tcp_hdr_t *current_tcp_packet,
|
||||
ipv6_hdr_t *temp_ipv6_header, uint8_t flags,
|
||||
uint8_t payload_length);
|
||||
bool isTCPSocket(uint8_t s);
|
||||
#endif /* SOCKET_H_ */
|
||||
/**
|
||||
* Destiny socket API
|
||||
*
|
||||
* Copyright (C) 2013 INRIA.
|
||||
*
|
||||
* This file subject to the terms and conditions of the GNU Lesser General
|
||||
* Public License. See the file LICENSE in the top level directory for more
|
||||
* details.
|
||||
*
|
||||
* @ingroup destiny
|
||||
* @{
|
||||
* @file socket.h
|
||||
* @brief header for BSD socket API
|
||||
* @author Oliver Gesch <oliver.gesch@googlemail.com>
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SOCKET_H_
|
||||
#define SOCKET_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "tcp.h"
|
||||
#include "udp.h"
|
||||
#include "in.h"
|
||||
#include "../sixlowpan/sixlowip.h"
|
||||
|
||||
/*
|
||||
* POSIX compatibility
|
||||
*/
|
||||
typedef uint8_t sa_family_t;
|
||||
typedef uint32_t socklen_t;
|
||||
|
||||
/*
|
||||
* Types
|
||||
*/
|
||||
#define SOCK_STREAM 1 /* stream socket */
|
||||
#define SOCK_DGRAM 2 /* datagram socket */
|
||||
#define SOCK_RAW 3 /* raw-protocol interface */
|
||||
#define SOCK_RDM 4 /* reliably-delivered message */
|
||||
#define SOCK_SEQPACKET 5 /* sequenced packet stream */
|
||||
|
||||
/*
|
||||
* Address families.
|
||||
*/
|
||||
#define AF_UNSPEC 0 /* unspecified */
|
||||
#define AF_LOCAL 1 /* local to host (pipes, portals) */
|
||||
#define AF_UNIX AF_LOCAL /* backward compatibility */
|
||||
#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
|
||||
#define AF_IMPLINK 3 /* arpanet imp addresses */
|
||||
#define AF_PUP 4 /* pup protocols: e.g. BSP */
|
||||
#define AF_CHAOS 5 /* mit CHAOS protocols */
|
||||
#define AF_NS 6 /* XEROX NS protocols */
|
||||
#define AF_ISO 7 /* ISO protocols */
|
||||
#define AF_OSI AF_ISO
|
||||
#define AF_ECMA 8 /* European computer manufacturers */
|
||||
#define AF_DATAKIT 9 /* datakit protocols */
|
||||
#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
|
||||
#define AF_SNA 11 /* IBM SNA */
|
||||
#define AF_DECnet 12 /* DECnet */
|
||||
#define AF_DLI 13 /* DEC Direct data link interface */
|
||||
#define AF_LAT 14 /* LAT */
|
||||
#define AF_HYLINK 15 /* NSC Hyperchannel */
|
||||
#define AF_APPLETALK 16 /* Apple Talk */
|
||||
#define AF_ROUTE 17 /* Internal Routing Protocol */
|
||||
#define AF_LINK 18 /* Link layer interface */
|
||||
#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */
|
||||
#define AF_COIP 20 /* connection-oriented IP, aka ST II */
|
||||
#define AF_CNT 21 /* Computer Network Technology */
|
||||
#define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */
|
||||
#define AF_IPX 23 /* Novell Internet Protocol */
|
||||
#define AF_SIP 24 /* Simple Internet Protocol */
|
||||
#define pseudo_AF_PIP 25 /* Help Identify PIP packets */
|
||||
#define AF_ISDN 26 /* Integrated Services Digital Network*/
|
||||
#define AF_E164 AF_ISDN /* CCITT E.164 recommendation */
|
||||
#define pseudo_AF_KEY 27 /* Internal key-management function */
|
||||
#define AF_INET6 28 /* IPv6 */
|
||||
#define AF_NATM 29 /* native ATM access */
|
||||
#define AF_ATM 30 /* ATM */
|
||||
#define pseudo_AF_HDRCMPLT 31 /* Used by BPF to not rewrite headers
|
||||
* in interface output routine
|
||||
*/
|
||||
#define AF_NETGRAPH 32 /* Netgraph sockets */
|
||||
#define AF_MAX 33
|
||||
|
||||
/*
|
||||
* Protocol families, same as address families for now.
|
||||
*/
|
||||
#define PF_UNSPEC AF_UNSPEC
|
||||
#define PF_LOCAL AF_LOCAL
|
||||
#define PF_UNIX PF_LOCAL /* backward compatibility */
|
||||
#define PF_INET AF_INET
|
||||
#define PF_IMPLINK AF_IMPLINK
|
||||
#define PF_PUP AF_PUP
|
||||
#define PF_CHAOS AF_CHAOS
|
||||
#define PF_NS AF_NS
|
||||
#define PF_ISO AF_ISO
|
||||
#define PF_OSI AF_ISO
|
||||
#define PF_ECMA AF_ECMA
|
||||
#define PF_DATAKIT AF_DATAKIT
|
||||
#define PF_CCITT AF_CCITT
|
||||
#define PF_SNA AF_SNA
|
||||
#define PF_DECnet AF_DECnet
|
||||
#define PF_DLI AF_DLI
|
||||
#define PF_LAT AF_LAT
|
||||
#define PF_HYLINK AF_HYLINK
|
||||
#define PF_APPLETALK AF_APPLETALK
|
||||
#define PF_ROUTE AF_ROUTE
|
||||
#define PF_LINK AF_LINK
|
||||
#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */
|
||||
#define PF_COIP AF_COIP
|
||||
#define PF_CNT AF_CNT
|
||||
#define PF_SIP AF_SIP
|
||||
#define PF_IPX AF_IPX /* same format as AF_NS */
|
||||
#define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */
|
||||
#define PF_PIP pseudo_AF_PIP
|
||||
#define PF_ISDN AF_ISDN
|
||||
#define PF_KEY pseudo_AF_KEY
|
||||
#define PF_INET6 AF_INET6
|
||||
#define PF_NATM AF_NATM
|
||||
#define PF_ATM AF_ATM
|
||||
#define PF_NETGRAPH AF_NETGRAPH
|
||||
#define PF_MAX AF_MAX
|
||||
|
||||
#define MAX_SOCKETS 5
|
||||
// #define MAX_QUEUED_SOCKETS 2
|
||||
|
||||
#define EPHEMERAL_PORTS 49152
|
||||
|
||||
#define STATIC_MSS 48
|
||||
#define STATIC_WINDOW 1 * STATIC_MSS
|
||||
#define MAX_TCP_BUFFER 1 * STATIC_WINDOW
|
||||
|
||||
#define INC_PACKET 0
|
||||
#define OUT_PACKET 1
|
||||
|
||||
#define SEND_MSG_BUF_SIZE 64
|
||||
|
||||
typedef struct socka6 {
|
||||
uint8_t sin6_family; /* AF_INET6 */
|
||||
uint16_t sin6_port; /* transport layer port # */
|
||||
uint32_t sin6_flowinfo; /* IPv6 flow information */
|
||||
ipv6_addr_t sin6_addr; /* IPv6 address */
|
||||
} sockaddr6_t;
|
||||
|
||||
typedef struct tcp_hc_con {
|
||||
uint16_t context_id;
|
||||
uint32_t seq_rcv; // Last received packet values
|
||||
uint32_t ack_rcv;
|
||||
uint16_t wnd_rcv;
|
||||
uint32_t seq_snd; // Last sent packet values
|
||||
uint32_t ack_snd;
|
||||
uint16_t wnd_snd;
|
||||
uint8_t hc_type;
|
||||
} tcp_hc_context_t;
|
||||
|
||||
typedef struct tcp_control_block {
|
||||
uint32_t send_una;
|
||||
uint32_t send_nxt;
|
||||
uint16_t send_wnd;
|
||||
uint32_t send_iss;
|
||||
|
||||
uint32_t rcv_nxt;
|
||||
uint16_t rcv_wnd;
|
||||
uint32_t rcv_irs;
|
||||
|
||||
timex_t last_packet_time;
|
||||
uint8_t no_of_retries;
|
||||
uint16_t mss;
|
||||
|
||||
uint8_t state;
|
||||
|
||||
double srtt;
|
||||
double rttvar;
|
||||
double rto;
|
||||
|
||||
#ifdef TCP_HC
|
||||
tcp_hc_context_t tcp_context;
|
||||
#endif
|
||||
|
||||
} tcp_cb_t;
|
||||
|
||||
typedef struct sock_t {
|
||||
uint8_t domain;
|
||||
uint8_t type;
|
||||
uint8_t protocol;
|
||||
tcp_cb_t tcp_control;
|
||||
sockaddr6_t local_address;
|
||||
sockaddr6_t foreign_address;
|
||||
} socket_t;
|
||||
|
||||
typedef struct socket_in_t {
|
||||
uint8_t socket_id;
|
||||
uint8_t recv_pid;
|
||||
uint8_t send_pid;
|
||||
uint8_t tcp_input_buffer_end;
|
||||
mutex_t tcp_buffer_mutex;
|
||||
socket_t socket_values;
|
||||
uint8_t tcp_input_buffer[MAX_TCP_BUFFER];
|
||||
} socket_internal_t;
|
||||
|
||||
extern socket_internal_t sockets[MAX_SOCKETS];
|
||||
|
||||
int socket(int domain, int type, int protocol);
|
||||
int connect(int socket, sockaddr6_t *addr, socklen_t addrlen);
|
||||
socket_internal_t *getWaitingConnectionSocket(int socket,
|
||||
ipv6_hdr_t *ipv6_header,
|
||||
tcp_hdr_t *tcp_header);
|
||||
void close_socket(socket_internal_t *current_socket);
|
||||
int32_t recvfrom(int s, void *buf, uint32_t len, int flags, sockaddr6_t *from,
|
||||
socklen_t *fromlen);
|
||||
int32_t sendto(int s, const void *msg, uint32_t len, int flags,
|
||||
sockaddr6_t *to, socklen_t tolen);
|
||||
int32_t send(int s, void *msg, uint32_t len, int flags);
|
||||
int recv(int s, void *buf, uint32_t len, int flags);
|
||||
int close(int s);
|
||||
int bind(int s, sockaddr6_t *name, int namelen);
|
||||
int listen(int s, int backlog);
|
||||
int accept(int s, sockaddr6_t *addr, socklen_t *addrlen);
|
||||
void socket_init(void);
|
||||
socket_internal_t *get_udp_socket(ipv6_hdr_t *ipv6_header, udp_hdr_t *udp_header);
|
||||
socket_internal_t *get_tcp_socket(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header);
|
||||
socket_internal_t *getSocket(uint8_t s);
|
||||
void print_sockets(void);
|
||||
void print_internal_socket(socket_internal_t *current_socket_internal);
|
||||
void print_socket(socket_t *current_socket);
|
||||
void printf_tcp_context(tcp_hc_context_t *current_tcp_context);
|
||||
bool exists_socket(uint8_t socket);
|
||||
socket_internal_t *new_tcp_queued_socket(ipv6_hdr_t *ipv6_header,
|
||||
tcp_hdr_t *tcp_header);
|
||||
void print_tcp_status(int in_or_out, ipv6_hdr_t *ipv6_header,
|
||||
tcp_hdr_t *tcp_header, socket_t *tcp_socket);
|
||||
void set_socket_address(sockaddr6_t *sockaddr, sa_family_t sin6_family,
|
||||
uint16_t sin6_port, uint32_t sin6_flowinfo,
|
||||
ipv6_addr_t *sin6_addr);
|
||||
void set_tcp_cb(tcp_cb_t *tcp_control, uint32_t rcv_nxt, uint16_t rcv_wnd,
|
||||
uint32_t send_nxt, uint32_t send_una, uint16_t send_wnd);
|
||||
void set_tcp_packet(tcp_hdr_t *tcp_hdr, uint16_t src_port, uint16_t dst_port,
|
||||
uint32_t seq_nr, uint32_t ack_nr,
|
||||
uint8_t dataOffset_reserved, uint8_t reserved_flags,
|
||||
uint16_t window, uint16_t checksum, uint16_t urg_pointer);
|
||||
int check_tcp_consistency(socket_t *current_tcp_socket, tcp_hdr_t *tcp_header);
|
||||
void switch_tcp_packet_byte_order(tcp_hdr_t *current_tcp_packet);
|
||||
int send_tcp(socket_internal_t *current_socket, tcp_hdr_t *current_tcp_packet,
|
||||
ipv6_hdr_t *temp_ipv6_header, uint8_t flags,
|
||||
uint8_t payload_length);
|
||||
bool isTCPSocket(uint8_t s);
|
||||
#endif /* SOCKET_H_ */
|
||||
|
@ -1,114 +1,114 @@
|
||||
/**
|
||||
* Destiny TCP header
|
||||
*
|
||||
* Copyright (C) 2013 INRIA.
|
||||
*
|
||||
* This file subject to the terms and conditions of the GNU Lesser General
|
||||
* Public License. See the file LICENSE in the top level directory for more
|
||||
* details.
|
||||
*
|
||||
* @ingroup destiny
|
||||
* @{
|
||||
* @file tcp.c
|
||||
* @brief TCP data structs and prototypes
|
||||
* @author Oliver Gesch <oliver.gesch@googlemail.com>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef TCP_H_
|
||||
#define TCP_H_
|
||||
|
||||
#define TCP_HDR_LEN 20
|
||||
|
||||
#define TCP_EOO_OPTION 0x00 // End of option list
|
||||
#define TCP_NOP_OPTION 0x01 // No operation
|
||||
#define TCP_MSS_OPTION 0x02 // Maximum segment size
|
||||
#define TCP_WSF_OPTION 0x03 // Window scale factor
|
||||
#define TCP_TS_OPTION 0x08 // Timestamp
|
||||
|
||||
enum tcp_flags {
|
||||
TCP_ACK = 0x08,
|
||||
TCP_URG_PSH = 0x14,
|
||||
TCP_RST = 0x20,
|
||||
TCP_SYN = 0x40,
|
||||
TCP_SYN_ACK = 0x48,
|
||||
TCP_FIN = 0x80,
|
||||
TCP_FIN_ACK = 0x88
|
||||
};
|
||||
|
||||
enum tcp_states {
|
||||
CLOSED = 0,
|
||||
LISTEN = 1,
|
||||
SYN_SENT = 2,
|
||||
SYN_RCVD = 3,
|
||||
ESTABLISHED = 4,
|
||||
FIN_WAIT_1 = 5,
|
||||
FIN_WAIT_2 = 6,
|
||||
CLOSE_WAIT = 7,
|
||||
CLOSING = 8,
|
||||
LAST_ACK = 9,
|
||||
TIME_WAIT = 10,
|
||||
UNKNOWN = 11
|
||||
};
|
||||
|
||||
enum tcp_codes {
|
||||
UNDEFINED = 0,
|
||||
PACKET_OK = 1,
|
||||
CLOSE_CONN = 2,
|
||||
SEQ_NO_TOO_SMALL = 3,
|
||||
ACK_NO_TOO_SMALL = 4,
|
||||
ACK_NO_TOO_BIG = 5
|
||||
};
|
||||
|
||||
#define REMOVE_RESERVED 0xFC
|
||||
|
||||
#define IS_TCP_ACK(a) ((a & TCP_ACK) == TCP_ACK) // Test for ACK flag only, ignore URG und PSH flag
|
||||
#define IS_TCP_RST(a) ((a & TCP_RST) == TCP_RST)
|
||||
#define IS_TCP_SYN(a) ((a & TCP_SYN) == TCP_SYN)
|
||||
#define IS_TCP_SYN_ACK(a) ((a & TCP_SYN_ACK) == TCP_SYN_ACK)
|
||||
#define IS_TCP_FIN(a) ((a & TCP_FIN) == TCP_FIN)
|
||||
#define IS_TCP_FIN_ACK(a) ((a & TCP_FIN_ACK) == TCP_FIN_ACK)
|
||||
|
||||
#define SET_TCP_ACK(a) a = ((a & 0x00) | TCP_ACK)
|
||||
#define SET_TCP_RST(a) a = ((a & 0x00) | TCP_RST)
|
||||
#define SET_TCP_SYN(a) a = ((a & 0x00) | TCP_SYN)
|
||||
#define SET_TCP_SYN_ACK(a) a = ((a & 0x00) | TCP_SYN_ACK)
|
||||
#define SET_TCP_FIN(a) a = ((a & 0x00) | TCP_FIN)
|
||||
#define SET_TCP_FIN_ACK(a) a = ((a & 0x00) | TCP_FIN_ACK)
|
||||
|
||||
#define TCP_STACK_SIZE 1024
|
||||
|
||||
#include "../sixlowpan/sixlowip.h"
|
||||
|
||||
typedef struct __attribute__((packed)) tcp_mms_o_t {
|
||||
uint8_t kind;
|
||||
uint8_t len;
|
||||
uint16_t mss;
|
||||
} tcp_mss_option_t;
|
||||
|
||||
typedef struct __attribute__((packed)) tcp_h_t {
|
||||
uint16_t src_port;
|
||||
uint16_t dst_port;
|
||||
uint32_t seq_nr;
|
||||
uint32_t ack_nr;
|
||||
uint8_t dataOffset_reserved;
|
||||
uint8_t reserved_flags;
|
||||
uint16_t window;
|
||||
uint16_t checksum;
|
||||
uint16_t urg_pointer;
|
||||
} tcp_hdr_t;
|
||||
|
||||
#ifdef TCP_HC
|
||||
mutex_t global_context_counter_mutex;
|
||||
uint8_t global_context_counter;
|
||||
#endif
|
||||
|
||||
mutex_t global_sequence_clunter_mutex;
|
||||
uint32_t global_sequence_counter;
|
||||
|
||||
void tcp_packet_handler(void);
|
||||
uint16_t tcp_csum(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header);
|
||||
void printTCPHeader(tcp_hdr_t *tcp_header);
|
||||
void printArrayRange_tcp(uint8_t *udp_header, uint16_t len);
|
||||
|
||||
#endif /* TCP_H_ */
|
||||
/**
|
||||
* Destiny TCP header
|
||||
*
|
||||
* Copyright (C) 2013 INRIA.
|
||||
*
|
||||
* This file subject to the terms and conditions of the GNU Lesser General
|
||||
* Public License. See the file LICENSE in the top level directory for more
|
||||
* details.
|
||||
*
|
||||
* @ingroup destiny
|
||||
* @{
|
||||
* @file tcp.c
|
||||
* @brief TCP data structs and prototypes
|
||||
* @author Oliver Gesch <oliver.gesch@googlemail.com>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef TCP_H_
|
||||
#define TCP_H_
|
||||
|
||||
#define TCP_HDR_LEN 20
|
||||
|
||||
#define TCP_EOO_OPTION 0x00 // End of option list
|
||||
#define TCP_NOP_OPTION 0x01 // No operation
|
||||
#define TCP_MSS_OPTION 0x02 // Maximum segment size
|
||||
#define TCP_WSF_OPTION 0x03 // Window scale factor
|
||||
#define TCP_TS_OPTION 0x08 // Timestamp
|
||||
|
||||
enum tcp_flags {
|
||||
TCP_ACK = 0x08,
|
||||
TCP_URG_PSH = 0x14,
|
||||
TCP_RST = 0x20,
|
||||
TCP_SYN = 0x40,
|
||||
TCP_SYN_ACK = 0x48,
|
||||
TCP_FIN = 0x80,
|
||||
TCP_FIN_ACK = 0x88
|
||||
};
|
||||
|
||||
enum tcp_states {
|
||||
CLOSED = 0,
|
||||
LISTEN = 1,
|
||||
SYN_SENT = 2,
|
||||
SYN_RCVD = 3,
|
||||
ESTABLISHED = 4,
|
||||
FIN_WAIT_1 = 5,
|
||||
FIN_WAIT_2 = 6,
|
||||
CLOSE_WAIT = 7,
|
||||
CLOSING = 8,
|
||||
LAST_ACK = 9,
|
||||
TIME_WAIT = 10,
|
||||
UNKNOWN = 11
|
||||
};
|
||||
|
||||
enum tcp_codes {
|
||||
UNDEFINED = 0,
|
||||
PACKET_OK = 1,
|
||||
CLOSE_CONN = 2,
|
||||
SEQ_NO_TOO_SMALL = 3,
|
||||
ACK_NO_TOO_SMALL = 4,
|
||||
ACK_NO_TOO_BIG = 5
|
||||
};
|
||||
|
||||
#define REMOVE_RESERVED 0xFC
|
||||
|
||||
#define IS_TCP_ACK(a) ((a & TCP_ACK) == TCP_ACK) // Test for ACK flag only, ignore URG und PSH flag
|
||||
#define IS_TCP_RST(a) ((a & TCP_RST) == TCP_RST)
|
||||
#define IS_TCP_SYN(a) ((a & TCP_SYN) == TCP_SYN)
|
||||
#define IS_TCP_SYN_ACK(a) ((a & TCP_SYN_ACK) == TCP_SYN_ACK)
|
||||
#define IS_TCP_FIN(a) ((a & TCP_FIN) == TCP_FIN)
|
||||
#define IS_TCP_FIN_ACK(a) ((a & TCP_FIN_ACK) == TCP_FIN_ACK)
|
||||
|
||||
#define SET_TCP_ACK(a) a = ((a & 0x00) | TCP_ACK)
|
||||
#define SET_TCP_RST(a) a = ((a & 0x00) | TCP_RST)
|
||||
#define SET_TCP_SYN(a) a = ((a & 0x00) | TCP_SYN)
|
||||
#define SET_TCP_SYN_ACK(a) a = ((a & 0x00) | TCP_SYN_ACK)
|
||||
#define SET_TCP_FIN(a) a = ((a & 0x00) | TCP_FIN)
|
||||
#define SET_TCP_FIN_ACK(a) a = ((a & 0x00) | TCP_FIN_ACK)
|
||||
|
||||
#define TCP_STACK_SIZE 1024
|
||||
|
||||
#include "../sixlowpan/sixlowip.h"
|
||||
|
||||
typedef struct __attribute__((packed)) tcp_mms_o_t {
|
||||
uint8_t kind;
|
||||
uint8_t len;
|
||||
uint16_t mss;
|
||||
} tcp_mss_option_t;
|
||||
|
||||
typedef struct __attribute__((packed)) tcp_h_t {
|
||||
uint16_t src_port;
|
||||
uint16_t dst_port;
|
||||
uint32_t seq_nr;
|
||||
uint32_t ack_nr;
|
||||
uint8_t dataOffset_reserved;
|
||||
uint8_t reserved_flags;
|
||||
uint16_t window;
|
||||
uint16_t checksum;
|
||||
uint16_t urg_pointer;
|
||||
} tcp_hdr_t;
|
||||
|
||||
#ifdef TCP_HC
|
||||
mutex_t global_context_counter_mutex;
|
||||
uint8_t global_context_counter;
|
||||
#endif
|
||||
|
||||
mutex_t global_sequence_clunter_mutex;
|
||||
uint32_t global_sequence_counter;
|
||||
|
||||
void tcp_packet_handler(void);
|
||||
uint16_t tcp_csum(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header);
|
||||
void printTCPHeader(tcp_hdr_t *tcp_header);
|
||||
void printArrayRange_tcp(uint8_t *udp_header, uint16_t len);
|
||||
|
||||
#endif /* TCP_H_ */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,25 +1,25 @@
|
||||
/*
|
||||
* tcp_hc.h
|
||||
*
|
||||
* Created on: 01.02.2012
|
||||
* Author: Oliver
|
||||
*/
|
||||
|
||||
#ifndef TCP_HC_H_
|
||||
#define TCP_HC_H_
|
||||
|
||||
#include "tcp.h"
|
||||
#include "../sixlowpan/sixlowip.h"
|
||||
#include "socket.h"
|
||||
|
||||
#ifdef TCP_HC
|
||||
|
||||
#define FULL_HEADER 1
|
||||
#define MOSTLY_COMPRESSED_HEADER 2
|
||||
#define COMPRESSED_HEADER 3
|
||||
|
||||
void update_tcp_hc_context(bool incoming, socket_internal_t *current_socket, tcp_hdr_t *current_tcp_packet);
|
||||
uint16_t compress_tcp_packet(socket_internal_t *current_socket, uint8_t *current_tcp_packet, ipv6_hdr_t *temp_ipv6_header, uint8_t flags, uint8_t payload_length);
|
||||
socket_internal_t *decompress_tcp_packet(ipv6_hdr_t *temp_ipv6_header);
|
||||
#endif
|
||||
#endif /* TCP_HC_H_ */
|
||||
/*
|
||||
* tcp_hc.h
|
||||
*
|
||||
* Created on: 01.02.2012
|
||||
* Author: Oliver
|
||||
*/
|
||||
|
||||
#ifndef TCP_HC_H_
|
||||
#define TCP_HC_H_
|
||||
|
||||
#include "tcp.h"
|
||||
#include "../sixlowpan/sixlowip.h"
|
||||
#include "socket.h"
|
||||
|
||||
#ifdef TCP_HC
|
||||
|
||||
#define FULL_HEADER 1
|
||||
#define MOSTLY_COMPRESSED_HEADER 2
|
||||
#define COMPRESSED_HEADER 3
|
||||
|
||||
void update_tcp_hc_context(bool incoming, socket_internal_t *current_socket, tcp_hdr_t *current_tcp_packet);
|
||||
uint16_t compress_tcp_packet(socket_internal_t *current_socket, uint8_t *current_tcp_packet, ipv6_hdr_t *temp_ipv6_header, uint8_t flags, uint8_t payload_length);
|
||||
socket_internal_t *decompress_tcp_packet(ipv6_hdr_t *temp_ipv6_header);
|
||||
#endif
|
||||
#endif /* TCP_HC_H_ */
|
||||
|
@ -1,156 +1,156 @@
|
||||
/**
|
||||
* Destiny TCP timer implementation
|
||||
*
|
||||
* Copyright (C) 2013 INRIA.
|
||||
*
|
||||
* This file subject to the terms and conditions of the GNU Lesser General
|
||||
* Public License. See the file LICENSE in the top level directory for more
|
||||
* details.
|
||||
*
|
||||
* @ingroup destiny
|
||||
* @{
|
||||
* @file tcp_timer.c
|
||||
* @brief TCP timer
|
||||
* @author Oliver Gesch <oliver.gesch@googlemail.com>
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#include <thread.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "tcp_timer.h"
|
||||
#include "vtimer.h"
|
||||
#include "thread.h"
|
||||
#include "destiny.h"
|
||||
#include "socket.h"
|
||||
#include "net_help/msg_help.h"
|
||||
#include "../sixlowpan/sixlowpan.h"
|
||||
|
||||
void handle_synchro_timeout(socket_internal_t *current_socket)
|
||||
{
|
||||
msg_t send;
|
||||
|
||||
if (thread_getstatus(current_socket->recv_pid) == STATUS_RECEIVE_BLOCKED) {
|
||||
timex_t now;
|
||||
vtimer_now(&now);
|
||||
|
||||
if ((current_socket->socket_values.tcp_control.no_of_retries == 0) &&
|
||||
(timex_sub(now,
|
||||
current_socket->socket_values.tcp_control.last_packet_time).microseconds >
|
||||
TCP_SYN_INITIAL_TIMEOUT)) {
|
||||
current_socket->socket_values.tcp_control.no_of_retries++;
|
||||
net_msg_send(&send, current_socket->recv_pid, 0, TCP_RETRY);
|
||||
}
|
||||
else if ((current_socket->socket_values.tcp_control.no_of_retries > 0) &&
|
||||
(timex_sub(now,
|
||||
current_socket->socket_values.tcp_control.last_packet_time).microseconds >
|
||||
(current_socket->socket_values.tcp_control.no_of_retries *
|
||||
TCP_SYN_TIMEOUT + TCP_SYN_INITIAL_TIMEOUT))) {
|
||||
current_socket->socket_values.tcp_control.no_of_retries++;
|
||||
|
||||
if (current_socket->socket_values.tcp_control.no_of_retries >
|
||||
TCP_MAX_SYN_RETRIES) {
|
||||
net_msg_send(&send, current_socket->recv_pid, 0, TCP_TIMEOUT);
|
||||
}
|
||||
else {
|
||||
net_msg_send(&send, current_socket->recv_pid, 0, TCP_RETRY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void handle_established(socket_internal_t *current_socket)
|
||||
{
|
||||
msg_t send;
|
||||
double current_timeout = current_socket->socket_values.tcp_control.rto;
|
||||
|
||||
if (current_timeout < SECOND) {
|
||||
current_timeout = SECOND;
|
||||
}
|
||||