Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.package
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Boxiang Sun
slapos.package
Commits
2811db0f
Commit
2811db0f
authored
May 02, 2013
by
Jondy Zhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch babeld for cygwin
parent
a1b68b4d
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
4187 additions
and
3 deletions
+4187
-3
windows/babeld/Makefile
windows/babeld/Makefile
+20
-1
windows/babeld/babeld.c
windows/babeld/babeld.c
+19
-1
windows/babeld/configuration.c
windows/babeld/configuration.c
+8
-0
windows/babeld/cyginet.c
windows/babeld/cyginet.c
+3176
-0
windows/babeld/cyginet.h
windows/babeld/cyginet.h
+234
-0
windows/babeld/interface.c
windows/babeld/interface.c
+4
-0
windows/babeld/interface.h
windows/babeld/interface.h
+5
-0
windows/babeld/kernel.c
windows/babeld/kernel.c
+2
-0
windows/babeld/kernel_cygwin.c
windows/babeld/kernel_cygwin.c
+712
-0
windows/babeld/net.c
windows/babeld/net.c
+7
-1
No files found.
windows/babeld/Makefile
View file @
2811db0f
...
...
@@ -14,6 +14,20 @@ SRCS = babeld.c net.c kernel.c util.c interface.c source.c neighbour.c \
OBJS
=
babeld.o net.o kernel.o util.o interface.o source.o neighbour.o
\
route.o xroute.o message.o resend.o configuration.o local.o
ifneq
"$(WINVER)" ""
SRCS
+=
cyginet.c
OBJS
+=
cyginet.o
LDLIBS
+=
-liphlpapi
-lws2_32
-lwlanapi
-lole32
-lsetupapi
ifeq
"$(WINVER)" "XP"
CFLAGS
+=
-D_WIN32_WINNT
=
0x0503
else
CLFAGS
+=
-D_WIN32_WINNT
=
0x0600
endif
endif
babeld
:
$(OBJS)
$(CC)
$(CFLAGS)
$(LDFLAGS)
-o
babeld
$(OBJS)
$(LDLIBS)
...
...
@@ -48,4 +62,9 @@ uninstall:
clean
:
-
rm
-f
babeld babeld.html
*
.o
*
~ core TAGS gmon.out
kernel.o
:
kernel_netlink.c kernel_socket.c
kernel.o
:
kernel_netlink.c kernel_socket.c kernel_cygwin.c
# Usage: ./test.exe
# Verify most of the functions in the cyginet.c
test.exe
:
cyginet.c
$(CC)
$(CFLAGS)
$(LDFLAGS)
-DTEST_CYGINET
-o
$@
$<
$(LDLIBS)
windows/babeld/babeld.c
View file @
2811db0f
...
...
@@ -96,6 +96,8 @@ static void init_signals(void);
static
void
dump_tables
(
FILE
*
out
);
static
int
reopen_logfile
(
void
);
int
cyginet_set_interface_forwards
(
const
char
*
ifname
,
int
value
);
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -371,13 +373,17 @@ main(int argc, char **argv)
FOR_ALL_INTERFACES
(
ifp
)
{
/* ifp->ifindex is not necessarily valid at this point */
#if defined (_WIN32_WINNT)
int
ifindex
=
if_nametoindex
(
cyginet_guidname
(
ifp
->
name
));
#else
int
ifindex
=
if_nametoindex
(
ifp
->
name
);
#endif
if
(
ifindex
>
0
)
{
unsigned
char
eui
[
8
];
rc
=
if_eui64
(
ifp
->
name
,
ifindex
,
eui
);
if
(
rc
<
0
)
continue
;
memcpy
(
myid
,
eui
,
8
);
memcpy
(
myid
,
eui
,
8
);
goto
have_id
;
}
}
...
...
@@ -390,7 +396,11 @@ main(int argc, char **argv)
ifname
=
if_indextoname
(
i
,
buf
);
if
(
ifname
==
NULL
)
continue
;
#if defined (_WIN32_WINNT)
rc
=
if_eui64
(
cyginet_ifname
(
ifname
),
i
,
eui
);
#else
rc
=
if_eui64
(
ifname
,
i
,
eui
);
#endif
if
(
rc
<
0
)
continue
;
memcpy
(
myid
,
eui
,
8
);
...
...
@@ -479,6 +489,14 @@ main(int argc, char **argv)
if
(
receive_buffer
==
NULL
)
goto
fail
;
#if defined (_WIN32_WINNT)
FOR_ALL_INTERFACES
(
ifp
)
if
(
cyginet_set_interface_forwards
(
ifp
->
name
,
1
)
==
-
1
)
{
fprintf
(
stderr
,
"Cannot enable IPv6 forwarding.
\n
"
);
goto
fail
;
}
#endif
rc
=
check_xroutes
(
0
);
if
(
rc
<
0
)
fprintf
(
stderr
,
"Warning: couldn't check exported routes.
\n
"
);
...
...
windows/babeld/configuration.c
View file @
2811db0f
...
...
@@ -348,7 +348,11 @@ parse_filter(gnc_t gnc, void *closure)
if
(
c
<
-
1
)
goto
error
;
filter
->
ifname
=
interface
;
#if defined (_WIN32_WINNT)
filter
->
ifindex
=
if_nametoindex
(
cyginet_guidname
(
interface
));
#else
filter
->
ifindex
=
if_nametoindex
(
interface
);
#endif
}
else
if
(
strcmp
(
token
,
"allow"
)
==
0
)
{
filter
->
result
=
0
;
}
else
if
(
strcmp
(
token
,
"deny"
)
==
0
)
{
...
...
@@ -644,7 +648,11 @@ renumber_filter(struct filter *filter)
{
while
(
filter
)
{
if
(
filter
->
ifname
)
#if defined (_WIN32_WINNT)
filter
->
ifindex
=
if_nametoindex
(
cyginet_guidname
(
filter
->
ifname
));
#else
filter
->
ifindex
=
if_nametoindex
(
filter
->
ifname
);
#endif
filter
=
filter
->
next
;
}
}
...
...
windows/babeld/cyginet.c
0 → 100644
View file @
2811db0f
This diff is collapsed.
Click to expand it.
windows/babeld/cyginet.h
0 → 100644
View file @
2811db0f
/*
Reference List in the MSDN.
NDIS 6.0 Interfaces for Window Vista later
http://msdn.microsoft.com/en-us/library/windows/hardware/ff565740(v=vs.85).aspx
NDIS Versions in Network Drivers (Windows Drivers)
http://msdn.microsoft.com/en-us/library/windows/hardware/ff567893(v=vs.85).aspx
For Windows XP, NDIS 5.0
http://msdn.microsoft.com/en-us/library/windows/hardware/ff565849(v=vs.85).aspx
NDIS General-use Interfaces (NDIS 5.1) (Windows Drivers)
http://msdn.microsoft.com/en-us/library/windows/hardware/ff556983(v=vs.85).aspx
Routing Protocol Interface Functions (Windows)
http://msdn.microsoft.com/en-us/library/windows/desktop/aa446772(v=vs.85).aspx
Networking (Windows)
http://msdn.microsoft.com/en-us/library/windows/desktop/ee663286(v=vs.85).aspx
NDIS Protocol Drivers (NDIS 5.1) (Windows Drivers)
http://msdn.microsoft.com/en-us/library/windows/hardware/ff557149(v=vs.85).aspx
Winsock IOCTLs (Windows)
http://msdn.microsoft.com/zh-cn/library/windows/desktop/bb736550(v=vs.85).aspx
Creating a Basic IP Helper Application (Windows)
http://msdn.microsoft.com/zh-cn/library/windows/desktop/aa365872(v=vs.85).aspx
Network Awareness in Windows XP
http://msdn.microsoft.com/en-us/library/ms700657(v=vs.85).aspx
System-Defined Device Setup Classes (Windows Drivers)
http://msdn.microsoft.com/en-us/library/windows/hardware/ff553419(v=vs.85).aspx
Device Information Sets (Windows Drivers)
http://msdn.microsoft.com/en-us/library/windows/hardware/ff541247(v=vs.85).aspx
Accessing Device Instance SPDRP_Xxx Properties (Windows Drivers)
http://msdn.microsoft.com/en-us/library/windows/hardware/ff537737(v=vs.85).aspx
IOCTL_NDIS_QUERY_GLOBAL_STATS (Windows Drivers)
http://msdn.microsoft.com/en-us/library/windows/hardware/ff548975(v=vs.85).aspx
IPv6 RFCs and Standards Working Groups
http://www.ipv6now.com.au/RFC.php
Routing Table Manager Version 2
http://msdn.microsoft.com/en-us/library/windows/desktop/bb404201(v=vs.85).aspx
Using Routing Table Manager Version 2, this section contains sample
code that can be used when developing clients such as routing
protocols.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa382335(v=vs.85).aspx
An introduction to the IPv6 protocol along with overviews on
deployment and IPv6 transitioning technologies is available on
Technet at Microsoft Internet Protocol Version 6 (IPv6).
http://go.microsoft.com/fwlink/p/?linkid=194338
http://technet.microsoft.com/en-us/network/bb530961.aspx
Internet Protocol Version 6 (IPv6)
http://msdn.microsoft.com/en-us//library/windows/desktop/ms738570(v=vs.85).aspx
IPv6 Link-local and Site-local Addresses
http://msdn.microsoft.com/zh-cn/library/windows/desktop/ms739166(v=vs.85).aspx
Recommended Configurations for IPv6
http://msdn.microsoft.com/en-us/library/windows/desktop/ms740117(v=vs.85).aspx
IPv6 Support in Home Routers, It looks like a windows re6stnet.
http://msdn.microsoft.com/en-us/windows/hardware/gg463251.aspx
Neighbor Discovery in IPv6
http://tools.ietf.org/html/rfc4861
Default Address Selection for Internet Protocol version 6 (IPv6)
http://tools.ietf.org/html/rfc3484
Path MTU Discovery
http://tools.ietf.org/html/rfc1191
IPv6 Traffic Between Nodes on Different Subnets of an IPv4 Internetwork (6to4)
http://msdn.microsoft.com/zh-cn/library/windows/desktop/ms737598(v=vs.85).aspx
Multicast Listener Discovery (MLD)
http://msdn.microsoft.com/en-us/library/aa916334.aspx
IPv6 Addresses, it explains the relation between link-local address
and interface id
http://msdn.microsoft.com/en-us/library/aa921042.aspx
TCP/IP (v4 and v6) Technical Reference, it shows ipv4 and ipv6 how
to work in the windows. (Recommended)
http://technet.microsoft.com/en-us/library/dd379473(v=ws.10).aspx
*/
#ifndef __CYGIFNET_H__
#define __CYGIFNET_H__
#ifndef IN_LOOPBACK
#define IN_LOOPBACK(a) ((((long int) (a)) & 0xff000000) == 0x7f000000)
#endif
/* Missing defines in the Cygwin */
#define RTM_ADD 0x1
/* Add Route */
#define RTM_DELETE 0x2
/* Delete Route */
#define RTM_CHANGE 0x3
/* Change Metrics or flags */
#define RTM_GET 0x4
/* Report Metrics */
#define IFF_RUNNING 0x40
/*
* Structure of a Link-Level sockaddr:
*/
struct
sockaddr_dl
{
u_char
sdl_len
;
/* Total length of sockaddr */
u_char
sdl_family
;
/* AF_LINK */
u_short
sdl_index
;
/* if != 0, system given index for interface */
u_char
sdl_type
;
/* interface type */
u_char
sdl_nlen
;
/* interface name length, no trailing 0 reqd. */
u_char
sdl_alen
;
/* link level address length */
u_char
sdl_slen
;
/* link layer selector length */
char
sdl_data
[
46
];
/* minimum work area, can be larger;
contains both if name and ll address */
};
struct
cyginet_route
{
struct
sockaddr_storage
prefix
;
int
plen
;
int
metric
;
unsigned
int
ifindex
;
int
proto
;
struct
sockaddr_storage
gateway
;
};
#if defined(INSIDE_BABELD_CYGINET)
struct
ifaddrs
{
struct
ifaddrs
*
ifa_next
;
char
*
ifa_name
;
unsigned
int
ifa_flags
;
struct
sockaddr
*
ifa_addr
;
union
{
struct
sockaddr
*
ifa_netmask
;
struct
sockaddr
*
ifa_dstaddr
;
};
void
*
ifa_data
;
};
struct
if_nameindex
{
unsigned
if_index
;
char
*
if_name
;
};
typedef
struct
_LIBWINET_INTERFACE_MAP_TABLE
{
PCHAR
FriendlyName
;
PCHAR
AdapterName
;
BYTE
PhysicalAddress
[
MAX_ADAPTER_ADDRESS_LENGTH
];
DWORD
PhysicalAddressLength
;
DWORD
IfType
;
int
RouteFlags
;
DWORD
IfIndex
;
DWORD
Ipv6IfIndex
;
VOID
*
next
;
}
LIBWINET_INTERFACE_MAP_TABLE
,
*
PLIBWINET_INTERFACE_MAP_TABLE
;
typedef
struct
_LIBWINET_INTERFACE
{
DWORD
IfType
;
IF_OPER_STATUS
OperStatus
;
DWORD
Mtu
;
SOCKADDR
Address
;
}
LIBWINET_INTERFACE
,
*
PLIBWINET_INTERFACE
;
extern
unsigned
if_nametoindex
(
const
char
*
);
extern
char
*
if_indextoname
(
unsigned
,
char
*
);
extern
struct
if_nameindex
*
if_nameindex
(
void
);
extern
void
if_freenameindex
(
struct
if_nameindex
*
);
extern
const
char
*
inet_ntop
(
int
,
const
void
*
,
char
*
,
socklen_t
);
extern
int
inet_pton
(
int
,
const
char
*
,
void
*
);
extern
int
getifaddrs
(
struct
ifaddrs
**
);
extern
void
freeifaddrs
(
struct
ifaddrs
*
);
#define MALLOC(x) HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,x)
#define FREE(p) \
if
(
NULL
!=
p
)
{
HeapFree
(
GetProcessHeap
(),
0
,
p
);
p
=
NULL
;}
#define CLOSESOCKET(s) \
if
(
INVALID_SOCKET
!=
s
)
{
closesocket
(
s
);
s
=
INVALID_SOCKET
;}
#define CLOSESOCKEVENT(h) \
if
(
WSA_INVALID_EVENT
!=
h
)
{
WSACloseEvent
(
h
);
h
=
WSA_INVALID_EVENT
;}
#define SOCKETERR(e) \
{
\
printf
(
"%s:%s failed: %d [%s@%d]
\n
"
,
\
__FUNCTION__
,
\
e
,
\
WSAGetLastError
(),
\
__FILE__
,
\
__LINE__
\
);
\
}
#endif
/* INSIDE_BABELD_CYGINET */
/* Export functions from cyginet */
int
cyginet_startup
();
void
cyginet_cleanup
();
int
cyginet_start_monitor_route_changes
(
int
);
int
cyginet_stop_monitor_route_changes
();
int
cyginet_set_icmp6_redirect_accept
(
int
);
int
cyginet_set_interface_forwards
(
const
char
*
ifname
,
int
value
);
int
cyginet_interface_sdl
(
struct
sockaddr_dl
*
,
char
*
);
int
cyginet_interface_wireless
(
const
char
*
,
int
);
int
cyginet_interface_mtu
(
const
char
*
,
int
);
int
cyginet_interface_operational
(
const
char
*
,
int
);
int
cyginet_interface_ipv4
(
const
char
*
,
int
,
unsigned
char
*
);
int
cyginet_dump_route_table
(
struct
cyginet_route
*
,
int
);
int
cyginet_loopback_index
(
int
);
int
cyginet_add_route_entry
(
const
struct
sockaddr
*
,
unsigned
short
,
const
struct
sockaddr
*
,
int
,
unsigned
int
);
int
cyginet_delete_route_entry
(
const
struct
sockaddr
*
,
unsigned
short
,
const
struct
sockaddr
*
,
int
,
unsigned
int
);
int
cyginet_update_route_entry
(
const
struct
sockaddr
*
,
unsigned
short
,
const
struct
sockaddr
*
,
int
,
unsigned
int
);
char
*
cyginet_ifname
(
const
char
*
);
char
*
cyginet_guidname
(
const
char
*
);
int
cyginet_refresh_interface_table
();
int
cyginet_getifaddresses
(
char
*
,
struct
cyginet_route
*
,
int
);
#endif
/* __CYGIFNET_H__ */
windows/babeld/interface.c
View file @
2811db0f
...
...
@@ -409,7 +409,11 @@ check_interfaces(void)
unsigned
int
ifindex
;
FOR_ALL_INTERFACES
(
ifp
)
{
#if defined (_WIN32_WINNT)
ifindex
=
if_nametoindex
(
cyginet_guidname
(
ifp
->
name
));
#else
ifindex
=
if_nametoindex
(
ifp
->
name
);
#endif
if
(
ifindex
!=
ifp
->
ifindex
)
{
debugf
(
"Noticed ifindex change for %s.
\n
"
,
ifp
->
name
);
ifp
->
ifindex
=
0
;
...
...
windows/babeld/interface.h
View file @
2811db0f
...
...
@@ -111,3 +111,8 @@ void set_timeout(struct timeval *timeout, int msecs);
int
interface_up
(
struct
interface
*
ifp
,
int
up
);
int
interface_ll_address
(
struct
interface
*
ifp
,
const
unsigned
char
*
address
);
void
check_interfaces
(
void
);
#if defined (_WIN32_WINNT)
char
*
cyginet_ifname
(
const
char
*
);
char
*
cyginet_guidname
(
const
char
*
);
#endif
windows/babeld/kernel.c
View file @
2811db0f
...
...
@@ -28,6 +28,8 @@ THE SOFTWARE.
#ifdef __linux
#include "kernel_netlink.c"
#elif defined(__CYGWIN__)
#include "kernel_cygwin.c"
#else
#include "kernel_socket.c"
#endif
...
...
windows/babeld/kernel_cygwin.c
0 → 100644
View file @
2811db0f
This diff is collapsed.
Click to expand it.
windows/babeld/net.c
View file @
2811db0f
...
...
@@ -19,7 +19,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
...
...
@@ -50,9 +49,16 @@ babel_socket(int port)
if
(
s
<
0
)
return
-
1
;
/* When this value is nonzero (the default on Windows), a socket
created for the AF_INET6 address family can be used to send and
receive IPv6 packets only. So it's not require to set in the
Windows XP. Actualy, this socket option is only supported on
Windows Vista or later. */
#if !defined(_WIN32_WINNT) || _WIN32_WINNT >= 0x0600
rc
=
setsockopt
(
s
,
IPPROTO_IPV6
,
IPV6_V6ONLY
,
&
one
,
sizeof
(
one
));
if
(
rc
<
0
)
goto
fail
;
#endif
rc
=
setsockopt
(
s
,
SOL_SOCKET
,
SO_REUSEADDR
,
&
one
,
sizeof
(
one
));
if
(
rc
<
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment