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
Lisa Casino
slapos.package
Commits
c72b3ecf
Commit
c72b3ecf
authored
Jul 13, 2013
by
Jondy Zhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use API to get/set ipv6 route later Windows Vista, otherwise ipv6 route
couldn't work in the Non-English platforms.
parent
2506b328
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
3437 additions
and
3424 deletions
+3437
-3424
windows/babeld/Makefile
windows/babeld/Makefile
+5
-0
windows/babeld/README.cygwin
windows/babeld/README.cygwin
+5
-3
windows/babeld/cyginet.c
windows/babeld/cyginet.c
+3177
-3176
windows/babeld/cyginet.h
windows/babeld/cyginet.h
+239
-234
windows/docs/using-slapos-in-windows.xml
windows/docs/using-slapos-in-windows.xml
+11
-11
No files found.
windows/babeld/Makefile
View file @
c72b3ecf
...
...
@@ -19,7 +19,12 @@ ifneq "$(WINVER)" ""
SRCS
+=
cyginet.c
OBJS
+=
cyginet.o
LDLIBS
+=
-liphlpapi
-lws2_32
-lwlanapi
-lole32
-lsetupapi
ifeq
"$(WINVER)" "XP"
CFLAGS
+=
-D_WIN32_WINNT
=
0x0503
else
CFLAGS
+=
-D_WIN32_WINNT
=
0x0600
endif
endif
...
...
windows/babeld/README.cygwin
View file @
c72b3ecf
...
...
@@ -31,12 +31,14 @@ Later Windows Vista,
$ WINVER=VISTA make
WINVER could be XP, VISTA, WIN7, WIN8.
It will generate babeld.exe in the current directory.
Build test
c
.exe, it's used to verify the functions in the cyginet.c
Build test.exe, it's used to verify the functions in the cyginet.c
$ WINVER=XP make test
c
.exe
$ ./test
c
.exe
$ WINVER=XP make test.exe
$ ./test.exe
Interface Names
===============
...
...
windows/babeld/cyginet.c
View file @
c72b3ecf
...
...
@@ -953,13 +953,13 @@ libwinet_edit_route_entry(const struct sockaddr *dest,
char
sgate
[
INET6_ADDRSTRLEN
];
if
(
NULL
==
inet_ntop
(
AF_INET6
,
(
const
void
*
)(
&
(((
SOCKADDR_IN6
*
)
dest
)
->
sin6_addr
)),
(
PVOID
)(
&
(((
SOCKADDR_IN6
*
)
dest
)
->
sin6_addr
)),
sdest
,
INET6_ADDRSTRLEN
))
return
-
1
;
if
(
NULL
==
inet_ntop
(
AF_INET6
,
(
const
void
*
)(
&
(((
SOCKADDR_IN6
*
)
gate
)
->
sin6_addr
)),
(
PVOID
)(
&
(((
SOCKADDR_IN6
*
)
gate
)
->
sin6_addr
)),
sgate
,
INET6_ADDRSTRLEN
))
...
...
@@ -1086,13 +1086,14 @@ libwinet_edit_route_entry(const struct sockaddr *dest,
#endif /* if 0 */
#else
do
{
/* Add route entry after Windows Vista */
MIB_IPFORWARD
ROW2
Row2
;
MIB_IPFORWARD
_ROW2
Row2
;
unsigned
long
Res
;
memset
(
&
Row2
,
0
,
sizeof
(
MIB_IPFORWARD
ROW2
));
memset
(
&
Row2
,
0
,
sizeof
(
MIB_IPFORWARD
_ROW2
));
Row2
.
InterfaceLuid
=
NULL
;
/* Row2.InterfaceLuid = 0; */
/* Maybe in the Vista, both of indexs are same. */
Row2
.
InterfaceIndex
=
dest
->
sa_family
==
AF_INET6
?
ifindex
:
libwinet_map_ifindex
(
AF_INET6
,
ifindex
);
...
...
@@ -1106,7 +1107,7 @@ libwinet_edit_route_entry(const struct sockaddr *dest,
Row2
.
Protocol
=
MIB_IPPROTO_NETMGMT
;
Row2
.
Loopback
=
gate
->
sa_family
==
AF_INET6
?
IN6_IS_ADDR_LOOPBACK
(
&
(((
SOCKADDR_IN6
*
)
gate
)
->
sin6_addr
))
:
IN_LOOPBACK
(
ntohl
((
(
SOCKADDR_IN
*
)
gate
)
->
sin_addr
.
S_un
.
S_addr
));
IN_LOOPBACK
(
ntohl
((
u_long
)((
SOCKADDR_IN
*
)
gate
)
->
sin_addr
.
S_un
.
S_addr
));
Row2
.
AutoconfigureAddress
=
FALSE
;
Row2
.
Publish
=
FALSE
;
Row2
.
Immortal
=
0
;
...
...
@@ -1115,19 +1116,19 @@ libwinet_edit_route_entry(const struct sockaddr *dest,
switch
(
cmdflag
)
{
case
0
:
Res
=
CreateIpForwardEntry2
(
&
Row
);
Res
=
CreateIpForwardEntry2
(
&
Row
2
);
break
;
case
1
:
Res
=
SetIpForwardEntry2
(
&
Row
);
Res
=
SetIpForwardEntry2
(
&
Row
2
);
break
;
case
2
:
Res
=
DeleteIpForwardEntry2
(
&
Row
);
Res
=
DeleteIpForwardEntry2
(
&
Row
2
);
break
;
}
if
(
Res
!=
NO_ERROR
)
return
-
1
;
}
}
while
(
0
);
#endif
/* _WIN32_WINNT < _WIN32_WINNT_VISTA */
...
...
@@ -1671,18 +1672,18 @@ cyginet_dump_route_table(struct cyginet_route *routes, int maxroutes)
PMIB_IPFORWARD_ROW2
pRow2
;
/* From Windows Vista later, use GetIpForwardTable2 instead */
if
(
NO_ERROR
==
GetIpForwardTable2
(
family
,
pIpForwardTable2
0
))
{
if
(
NO_ERROR
==
GetIpForwardTable2
(
AF_UNSPEC
,
&
pIpForwardTable2
))
{
NumEntries
=
pIpForwardTable2
->
dwNumEntries
;
NumEntries
=
pIpForwardTable2
->
NumEntries
;
if
((
routes
==
NULL
)
||
(
NumEntries
>
maxroutes
))
{
FreeMibTable
(
pIpForwardTable2
);
return
NumEntries
;
}
proute
=
routes
;
NumEntries
=
pIpForwardTable2
->
dwNumEntries
;
NumEntries
=
pIpForwardTable2
->
NumEntries
;
pRow2
=
pIpForwardTable2
->
Table
;
for
(
i
=
0
;
i
<
NumEntries
;
i
++
,
proute
++
,
pRow2
++
)
{
...
...
@@ -1690,12 +1691,12 @@ cyginet_dump_route_table(struct cyginet_route *routes, int maxroutes)
proute
->
metric
=
pRow2
->
Metric
;
proute
->
proto
=
pRow2
->
Protocol
;
proute
->
plen
=
(
pRow2
->
DestinationPrefix
).
PrefixLength
;
memcpy
(
proute
->
prefix
,
(
pRow2
->
DestinationPrefix
).
DestinationPrefix
,
memcpy
(
&
proute
->
prefix
,
&
(
pRow2
->
DestinationPrefix
).
Prefix
,
sizeof
(
SOCKADDR_INET
)
);
memcpy
(
proute
->
gateway
,
pRow2
->
NextHop
,
memcpy
(
&
proute
->
gateway
,
&
pRow2
->
NextHop
,
sizeof
(
SOCKADDR_INET
)
);
}
...
...
@@ -2616,6 +2617,8 @@ DWORD GetConnectedNetworks()
/* ------------------------------------------------------------- */
#ifdef TEST_CYGINET
#define MAX_ROUTES 200
VOID
PrintAllInterfaces
()
{
IP_ADAPTER_ADDRESSES
*
pAdaptAddr
=
NULL
;
...
...
@@ -2895,7 +2898,6 @@ runTestCases()
printf
(
"
\n\n
Test cyginet_dump_route_table:
\n\n
"
);
do
{
#define MAX_ROUTES 120
struct
cyginet_route
routes
[
MAX_ROUTES
];
memset
(
routes
,
0
,
sizeof
(
struct
cyginet_route
)
*
MAX_ROUTES
);
int
n
=
cyginet_dump_route_table
(
routes
,
MAX_ROUTES
);
...
...
@@ -2968,7 +2970,6 @@ runTestCases()
printf
(
"
\n\n
Test cyginet_dump_route_table:
\n\n
"
);
do
{
#define MAX_ROUTES 120
struct
cyginet_route
routes
[
MAX_ROUTES
];
memset
(
routes
,
0
,
sizeof
(
struct
cyginet_route
)
*
MAX_ROUTES
);
int
n
=
cyginet_dump_route_table
(
routes
,
MAX_ROUTES
);
...
...
@@ -3157,7 +3158,7 @@ int main(int argc, char* argv[])
}
}
while
(
0
);
// runTestCases();
runTestCases
();
/* printf("\n\nTest libwinet_init_ipv6_interface:\n\n"); */
/* libwinet_init_ipv6_interface(); */
...
...
windows/babeld/cyginet.h
View file @
c72b3ecf
...
...
@@ -172,12 +172,17 @@ typedef struct _LIBWINET_INTERFACE {
SOCKADDR
Address
;
}
LIBWINET_INTERFACE
,
*
PLIBWINET_INTERFACE
;
#if _WIN32_WINNT < _WIN32_WINNT_VISTA
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
*
);
#else
WINSOCK_API_LINKAGE
u_long
WSAAPI
ntohl
(
u_long
netlong
);
#endif
extern
struct
if_nameindex
*
if_nameindex
(
void
);
extern
void
if_freenameindex
(
struct
if_nameindex
*
);
extern
int
getifaddrs
(
struct
ifaddrs
**
);
extern
void
freeifaddrs
(
struct
ifaddrs
*
);
...
...
windows/docs/using-slapos-in-windows.xml
View file @
c72b3ecf
...
...
@@ -285,7 +285,8 @@ mv slapos.tar.gz slapos/
Then build babeld and openvpn for cygwin, we need use the sources in the slapos.package.git, they are patched for cygwin:
<programlisting>
cd /opt/git/slapos.package/windows/babeld
make WINVER=XP
# WINVER could be XP, VISTA, WIN7, WIN8
WINVER=XP make
cp babeld.exe /usr/bin
cd /opt/git/slapos.package/windows/openvpn
...
...
@@ -544,4 +545,3 @@ The following packages are requied by re6stnet
-->
</appendix>
</book>
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