Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cellframe-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
18
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cellframe
cellframe-sdk
Commits
29e989cc
Commit
29e989cc
authored
5 years ago
by
Station
Browse files
Options
Downloads
Patches
Plain Diff
ipv6 win fixed
parent
8283da5c
No related branches found
Branches containing commit
No related tags found
1 merge request
!24
Support 3689
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
dap_chain_net.h
+11
-0
11 additions, 0 deletions
dap_chain_net.h
dap_chain_node.h
+10
-0
10 additions, 0 deletions
dap_chain_node.h
dap_chain_node_cli.c
+3
-0
3 additions, 0 deletions
dap_chain_node_cli.c
win32/ip.h
+301
-0
301 additions, 0 deletions
win32/ip.h
win32/iphdr.h
+112
-0
112 additions, 0 deletions
win32/iphdr.h
with
437 additions
and
0 deletions
dap_chain_net.h
+
11
−
0
View file @
29e989cc
...
...
@@ -23,10 +23,21 @@
along with any DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#ifndef _WIN32
#include
<sys/socket.h>
#include
<netinet/in.h>
#else
#include
<winsock2.h>
#include
<windows.h>
#include
<mswsock.h>
#include
<ws2tcpip.h>
#include
"win32/ip.h"
#include
"win32/iphdr.h"
#endif
#include
<stdint.h>
#include
<string.h>
#include
"dap_strfuncs.h"
...
...
This diff is collapsed.
Click to expand it.
dap_chain_node.h
+
10
−
0
View file @
29e989cc
...
...
@@ -28,7 +28,17 @@
#ifndef _WIN32
#include
<sys/socket.h>
#include
<netinet/in.h>
#else
#include
<winsock2.h>
#include
<windows.h>
#include
<mswsock.h>
#include
<ws2tcpip.h>
#include
"win32/ip.h"
#include
"win32/iphdr.h"
#endif
#include
"dap_common.h"
#include
"dap_chain_common.h"
#include
"dap_chain_global_db.h"
...
...
This diff is collapsed.
Click to expand it.
dap_chain_node_cli.c
+
3
−
0
View file @
29e989cc
...
...
@@ -764,7 +764,10 @@ int dap_chain_node_cli_init(dap_config_t * g_config)
struct
sockaddr_un
l_server_addr
=
{
0
};
l_server_addr
.
sun_family
=
AF_UNIX
;
snprintf
(
l_server_addr
.
sun_path
,
sizeof
(
l_server_addr
.
sun_path
),
dap_config_get_item_str
(
g_config
,
"conserver"
,
"listen_unix_socket_path"
)
);
#else
pthread_t
threadId
;
#endif
struct
sockaddr_in
server_addr
;
SOCKET
sockfd
=
-
1
;
...
...
This diff is collapsed.
Click to expand it.
win32/ip.h
0 → 100644
+
301
−
0
View file @
29e989cc
#pragma once
/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef __NETINET_IP_H
#define __NETINET_IP_H 1
//#include <features.h>
//#include <sys/types.h>
//#include <netinet/in.h>
struct
timestamp
{
uint8_t
len
;
uint8_t
ptr
;
#if __BYTE_ORDER == __LITTLE_ENDIAN
unsigned
int
flags
:
4
;
unsigned
int
overflow
:
4
;
#elif __BYTE_ORDER == __BIG_ENDIAN
unsigned
int
overflow
:
4
;
unsigned
int
flags
:
4
;
#else
# error "Please fix <bits/endian.h>"
#endif
uint32_t
data
[
9
];
};
struct
iphdr
{
#if __BYTE_ORDER == __LITTLE_ENDIAN
unsigned
int
ihl
:
4
;
unsigned
int
version
:
4
;
#elif __BYTE_ORDER == __BIG_ENDIAN
unsigned
int
version
:
4
;
unsigned
int
ihl
:
4
;
#else
# error "Please fix <bits/endian.h>"
#endif
uint8_t
tos
;
uint16_t
tot_len
;
uint16_t
id
;
uint16_t
frag_off
;
uint8_t
ttl
;
uint8_t
protocol
;
uint16_t
check
;
uint32_t
saddr
;
uint32_t
daddr
;
/*The options start here. */
};
#ifdef __USE_MISC
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)ip.h 8.1 (Berkeley) 6/10/93
*/
/*
* Definitions for internet protocol version 4.
* Per RFC 791, September 1981.
*/
/*
* Structure of an internet header, naked of options.
*/
struct
ip
{
#if __BYTE_ORDER == __LITTLE_ENDIAN
unsigned
int
ip_hl
:
4
;
/* header length */
unsigned
int
ip_v
:
4
;
/* version */
#endif
#if __BYTE_ORDER == __BIG_ENDIAN
unsigned
int
ip_v
:
4
;
/* version */
unsigned
int
ip_hl
:
4
;
/* header length */
#endif
uint8_t
ip_tos
;
/* type of service */
unsigned
short
ip_len
;
/* total length */
unsigned
short
ip_id
;
/* identification */
unsigned
short
ip_off
;
/* fragment offset field */
#define IP_RF 0x8000
/* reserved fragment flag */
#define IP_DF 0x4000
/* dont fragment flag */
#define IP_MF 0x2000
/* more fragments flag */
#define IP_OFFMASK 0x1fff
/* mask for fragmenting bits */
uint8_t
ip_ttl
;
/* time to live */
uint8_t
ip_p
;
/* protocol */
unsigned
short
ip_sum
;
/* checksum */
struct
in_addr
ip_src
,
ip_dst
;
/* source and dest address */
};
/*
* Time stamp option structure.
*/
struct
ip_timestamp
{
uint8_t
ipt_code
;
/* IPOPT_TS */
uint8_t
ipt_len
;
/* size of structure (variable) */
uint8_t
ipt_ptr
;
/* index of current entry */
#if __BYTE_ORDER == __LITTLE_ENDIAN
unsigned
int
ipt_flg
:
4
;
/* flags, see below */
unsigned
int
ipt_oflw
:
4
;
/* overflow counter */
#endif
#if __BYTE_ORDER == __BIG_ENDIAN
unsigned
int
ipt_oflw
:
4
;
/* overflow counter */
unsigned
int
ipt_flg
:
4
;
/* flags, see below */
#endif
uint32_t
data
[
9
];
};
#endif
/* __USE_MISC */
#define IPVERSION 4
/* IP version number */
#define IP_MAXPACKET 65535
/* maximum packet size */
/*
* Definitions for Explicit Congestion Notification (ECN)
*
* Taken from RFC-3168, Section 5.
*/
#define IPTOS_ECN_MASK 0x03
#define IPTOS_ECN(x) ((x) & IPTOS_ECN_MASK)
#define IPTOS_ECN_NOT_ECT 0x00
#define IPTOS_ECN_ECT1 0x01
#define IPTOS_ECN_ECT0 0x02
#define IPTOS_ECN_CE 0x03
/*
* Definitions for IP differentiated services code points (DSCP)
*
* Taken from RFC-2597, Section 6 and RFC-2598, Section 2.3.
*/
#define IPTOS_DSCP_MASK 0xfc
#define IPTOS_DSCP(x) ((x) & IPTOS_DSCP_MASK)
#define IPTOS_DSCP_AF11 0x28
#define IPTOS_DSCP_AF12 0x30
#define IPTOS_DSCP_AF13 0x38
#define IPTOS_DSCP_AF21 0x48
#define IPTOS_DSCP_AF22 0x50
#define IPTOS_DSCP_AF23 0x58
#define IPTOS_DSCP_AF31 0x68
#define IPTOS_DSCP_AF32 0x70
#define IPTOS_DSCP_AF33 0x78
#define IPTOS_DSCP_AF41 0x88
#define IPTOS_DSCP_AF42 0x90
#define IPTOS_DSCP_AF43 0x98
#define IPTOS_DSCP_EF 0xb8
/*
* In RFC 2474, Section 4.2.2.1, the Class Selector Codepoints subsume
* the old ToS Precedence values.
*/
#define IPTOS_CLASS_MASK 0xe0
#define IPTOS_CLASS(class) ((class) & IPTOS_CLASS_MASK)
#define IPTOS_CLASS_CS0 0x00
#define IPTOS_CLASS_CS1 0x20
#define IPTOS_CLASS_CS2 0x40
#define IPTOS_CLASS_CS3 0x60
#define IPTOS_CLASS_CS4 0x80
#define IPTOS_CLASS_CS5 0xa0
#define IPTOS_CLASS_CS6 0xc0
#define IPTOS_CLASS_CS7 0xe0
#define IPTOS_CLASS_DEFAULT IPTOS_CLASS_CS0
/*
* Definitions for IP type of service (ip_tos) [deprecated; use DSCP
* and CS definitions above instead.]
*/
#define IPTOS_TOS_MASK 0x1E
#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
#define IPTOS_LOWDELAY 0x10
#define IPTOS_THROUGHPUT 0x08
#define IPTOS_RELIABILITY 0x04
#define IPTOS_LOWCOST 0x02
#define IPTOS_MINCOST IPTOS_LOWCOST
/*
* Definitions for IP precedence (also in ip_tos) [also deprecated.]
*/
#define IPTOS_PREC_MASK IPTOS_CLASS_MASK
#define IPTOS_PREC(tos) IPTOS_CLASS(tos)
#define IPTOS_PREC_NETCONTROL IPTOS_CLASS_CS7
#define IPTOS_PREC_INTERNETCONTROL IPTOS_CLASS_CS6
#define IPTOS_PREC_CRITIC_ECP IPTOS_CLASS_CS5
#define IPTOS_PREC_FLASHOVERRIDE IPTOS_CLASS_CS4
#define IPTOS_PREC_FLASH IPTOS_CLASS_CS3
#define IPTOS_PREC_IMMEDIATE IPTOS_CLASS_CS2
#define IPTOS_PREC_PRIORITY IPTOS_CLASS_CS1
#define IPTOS_PREC_ROUTINE IPTOS_CLASS_CS0
/*
* Definitions for options.
*/
#define IPOPT_COPY 0x80
#define IPOPT_CLASS_MASK 0x60
#define IPOPT_NUMBER_MASK 0x1f
#define IPOPT_COPIED(o) ((o) & IPOPT_COPY)
#define IPOPT_CLASS(o) ((o) & IPOPT_CLASS_MASK)
#define IPOPT_NUMBER(o) ((o) & IPOPT_NUMBER_MASK)
#define IPOPT_CONTROL 0x00
#define IPOPT_RESERVED1 0x20
#define IPOPT_DEBMEAS 0x40
#define IPOPT_MEASUREMENT IPOPT_DEBMEAS
#define IPOPT_RESERVED2 0x60
#define IPOPT_EOL 0
/* end of option list */
#define IPOPT_END IPOPT_EOL
#define IPOPT_NOP 1
/* no operation */
#define IPOPT_NOOP IPOPT_NOP
#define IPOPT_RR 7
/* record packet route */
#define IPOPT_TS 68
/* timestamp */
#define IPOPT_TIMESTAMP IPOPT_TS
#define IPOPT_SECURITY 130
/* provide s,c,h,tcc */
#define IPOPT_SEC IPOPT_SECURITY
#define IPOPT_LSRR 131
/* loose source route */
#define IPOPT_SATID 136
/* satnet id */
#define IPOPT_SID IPOPT_SATID
#define IPOPT_SSRR 137
/* strict source route */
#define IPOPT_RA 148
/* router alert */
/*
* Offsets to fields in options other than EOL and NOP.
*/
#define IPOPT_OPTVAL 0
/* option ID */
#define IPOPT_OLEN 1
/* option length */
#define IPOPT_OFFSET 2
/* offset within option */
#define IPOPT_MINOFF 4
/* min value of above */
#define MAX_IPOPTLEN 40
/* flag bits for ipt_flg */
#define IPOPT_TS_TSONLY 0
/* timestamps only */
#define IPOPT_TS_TSANDADDR 1
/* timestamps and addresses */
#define IPOPT_TS_PRESPEC 3
/* specified modules only */
/* bits for security (not byte swapped) */
#define IPOPT_SECUR_UNCLASS 0x0000
#define IPOPT_SECUR_CONFID 0xf135
#define IPOPT_SECUR_EFTO 0x789a
#define IPOPT_SECUR_MMMM 0xbc4d
#define IPOPT_SECUR_RESTR 0xaf13
#define IPOPT_SECUR_SECRET 0xd788
#define IPOPT_SECUR_TOPSECRET 0x6bc5
/*
* Internet implementation parameters.
*/
#define MAXTTL 255
/* maximum time to live (seconds) */
#define IPDEFTTL 64
/* default ttl, from RFC 1340 */
#define IPFRAGTTL 60
/* time to live for frags, slowhz */
#define IPTTLDEC 1
/* subtracted when forwarding */
#define IP_MSS 576
/* default maximum segment size */
#endif
/* netinet/ip.h */
This diff is collapsed.
Click to expand it.
win32/iphdr.h
0 → 100644
+
112
−
0
View file @
29e989cc
#pragma once
// Align on a 1-byte boundary
//#include <pshpack1.h>
#pragma pack(push,1)
// IPv4 header
typedef
struct
ip_hdr
{
unsigned
char
ip_verlen
;
// 4-bit IPv4 version
// 4-bit header length (in 32-bit words)
unsigned
char
ip_tos
;
// IP type of service
unsigned
short
ip_totallength
;
// Total length
unsigned
short
ip_id
;
// Unique identifier
unsigned
short
ip_offset
;
// Fragment offset field
unsigned
char
ip_ttl
;
// Time to live
unsigned
char
ip_protocol
;
// Protocol(TCP,UDP etc)
unsigned
short
ip_checksum
;
// IP checksum
unsigned
int
ip_srcaddr
;
// Source address
unsigned
int
ip_destaddr
;
// Source address
}
IPV4_HDR
,
*
PIPV4_HDR
,
FAR
*
LPIPV4_HDR
;
// IPv4 option header
typedef
struct
ipv4_option_hdr
{
unsigned
char
opt_code
;
// option type
unsigned
char
opt_len
;
// length of the option header
unsigned
char
opt_ptr
;
// offset into options
unsigned
long
opt_addr
[
9
];
// list of IPv4 addresses
}
IPV4_OPTION_HDR
,
*
PIPV4_OPTION_HDR
,
FAR
*
LPIPV4_OPTION_HDR
;
// ICMP header
typedef
struct
icmp_hdr
{
unsigned
char
icmp_type
;
unsigned
char
icmp_code
;
unsigned
short
icmp_checksum
;
unsigned
short
icmp_id
;
unsigned
short
icmp_sequence
;
}
ICMP_HDR
,
*
PICMP_HDR
,
FAR
*
LPICMP_HDR
;
// IPv6 protocol header
typedef
struct
ipv6_hdr
{
unsigned
long
ipv6_vertcflow
;
// 4-bit IPv6 version
// 8-bit traffic class
// 20-bit flow label
unsigned
short
ipv6_payloadlen
;
// payload length
unsigned
char
ipv6_nexthdr
;
// next header protocol value
unsigned
char
ipv6_hoplimit
;
// TTL
struct
in6_addr
ipv6_srcaddr
;
// Source address
struct
in6_addr
ipv6_destaddr
;
// Destination address
}
IPV6_HDR
,
*
PIPV6_HDR
,
FAR
*
LPIPV6_HDR
;
// IPv6 fragment header
typedef
struct
ipv6_fragment_hdr
{
unsigned
char
ipv6_frag_nexthdr
;
unsigned
char
ipv6_frag_reserved
;
unsigned
short
ipv6_frag_offset
;
unsigned
long
ipv6_frag_id
;
}
IPV6_FRAGMENT_HDR
,
*
PIPV6_FRAGMENT_HDR
,
FAR
*
LPIPV6_FRAGMENT_HDR
;
// ICMPv6 header
typedef
struct
icmpv6_hdr
{
unsigned
char
icmp6_type
;
unsigned
char
icmp6_code
;
unsigned
short
icmp6_checksum
;
}
ICMPV6_HDR
;
// ICMPv6 echo request body
typedef
struct
icmpv6_echo_request
{
unsigned
short
icmp6_echo_id
;
unsigned
short
icmp6_echo_sequence
;
}
ICMPV6_ECHO_REQUEST
;
// Define the UDP header
typedef
struct
udp_hdr
{
unsigned
short
src_portno
;
// Source port no.
unsigned
short
dst_portno
;
// Dest. port no.
unsigned
short
udp_length
;
// Udp packet length
unsigned
short
udp_checksum
;
// Udp checksum (optional)
}
UDP_HDR
,
*
PUDP_HDR
;
// IPv4 option for record route
#define IP_RECORD_ROUTE 0x7
// ICMP6 protocol value (used in the socket call and IPv6 header)
#define IPPROTO_ICMP6 58
// ICMP types and codes
#define ICMPV4_ECHO_REQUEST_TYPE 8
#define ICMPV4_ECHO_REQUEST_CODE 0
#define ICMPV4_ECHO_REPLY_TYPE 0
#define ICMPV4_ECHO_REPLY_CODE 0
#define ICMPV4_MINIMUM_HEADER 8
// ICPM6 types and codes
#define ICMPV6_ECHO_REQUEST_TYPE 128
#define ICMPV6_ECHO_REQUEST_CODE 0
#define ICMPV6_ECHO_REPLY_TYPE 129
#define ICMPV6_ECHO_REPLY_CODE 0
#pragma pack(pop)
// Restore byte alignment back to default
//#include <poppack.h>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment