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
Kasra Jamshidi
slapos.package
Commits
a6f041e1
Commit
a6f041e1
authored
Jul 29, 2013
by
Jondy Zhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ipwin: add command 'name'
ip: fix format_interface_name always return re6stnet-lo
parent
4a7bbe97
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
149 additions
and
21 deletions
+149
-21
windows/ipwin/ipwin/ipwin.cpp
windows/ipwin/ipwin/ipwin.cpp
+62
-12
windows/ipwin/ipwin/netcfg.cpp
windows/ipwin/ipwin/netcfg.cpp
+81
-2
windows/scripts/ip
windows/scripts/ip
+6
-7
No files found.
windows/ipwin/ipwin/ipwin.cpp
View file @
a6f041e1
...
...
@@ -7,6 +7,10 @@
*
* ipwin guid *MSLOOP re6stnet-lo
*
* Get connection name by interface guid:
*
* ipwin name {610B0F3F-06A7-47EF-A38D-EF55503C481F}
*
* Install network adapter and rename connection
*
* ipwin install "OemWin2k.inf" tap0901 re6stnet-tcp
...
...
@@ -48,26 +52,62 @@ HRESULT SlaposNetCfgGetNetworkInterfaceGuid(IN LPCWSTR pHwid,
OUT
BSTR
*
pGUID
,
OUT
BSTR
*
pErrMsg
);
HRESULT
SlaposNetCfgGetNetworkConnectionName
(
IN
LPCWSTR
pGUID
,
OUT
BSTR
*
pName
,
OUT
BSTR
*
pErrMsg
);
void
Usage
()
{
printf
(
"Usage: ipwin [command] [options]
\n\n
\
Get guid of interface:
\n
\
ipwin guid HWID CONNECTION-NAME
\n\n
\
For example,
\n
\
ipwin guid *MSLOOP re6stnet-lo
\n
\
printf
(
"Usage: ipwin [command] [options]
\n
\
\n
\
Available command:
\n
\
install Install network adapter
\n
\
remove Remove network adapter
\n
\
guid Get GUID of interface by name
\n
\
name Get name by GUID
\n
\
codepage Get Windows CodePage
\n
\
\n
\
*install
\n
\
\n
\
Install network adapter and rename connection:
\n
\
\n
\
ipwin install INF-FILE HWID CONNECTION-NAME
\n
\
\n
\
Install network adapter and rename connection:
\n
\
ipwin install INF-FILE HWID CONNECTION-NAME
\n\n
\
For example,
\n
\
For example,
\n
\
ipwin install
\"
OemWin2k.inf
\"
tap0901 re6stnet-tcp
\n
\
\n
\
ipwin install
\"
netloop.inf
\"
*MSLOOP re6stnet-lo
\n
\
\n
\
Remove network adapter:
\n
\
ipwin remove HWID CONNECTIION-NAME
\n\n
\
For example,
\n
\
*remove
\n
\
\n
\
Remove network adapter:
\n
\
ipwin remove HWID CONNECTIION-NAME
\n
\
\n
\
For example,
\n
\
ipwin remove tap0901 re6stnet-tcp
\n
\
\n\n
\
\n
\
*guid
\n
\
\n
\
Get guid of interface:
\n
\
ipwin guid HWID CONNECTION-NAME
\n
\
\n
\
For example,
\n
\
ipwin guid *MSLOOP re6stnet-lo
\n
\
\n
\
*name
\n
\
\n
\
Get connection name by GUID:
\n
\
ipwin name GUID
\n
\
\n
\
For example,
\n
\
ipwin name {610B0F3F-06A7-47EF-A38D-EF55503C481F}
\n
\
\n
\
*codepage
\n
\
\n
\
Get codepage of Windows:
\n
\
ipwin codepage
\n
\
\n
\
\n
\
Exit status:
\n
\
0 if OK,
\n
\
other value if problems
\n
\
...
...
@@ -276,6 +316,16 @@ int _tmain(int argc, TCHAR * argv[])
printf
(
"%s"
,
hr
==
S_OK
?
pGUID
:
pErrMsg
);
}
}
else
if
(
wcscmp
(
argv
[
1
],
L"name"
)
==
0
)
{
if
(
argc
!=
3
)
{
Usage
();
hr
=
E_FAIL
;
}
else
{
hr
=
SlaposNetCfgGetNetworkConnectionName
(
argv
[
2
],
pGUID
,
pErrMsg
);
printf
(
"%s"
,
hr
==
S_OK
?
pGUID
:
pErrMsg
);
}
}
else
if
(
wcscmp
(
argv
[
1
],
L"codepage"
)
==
0
)
{
hr
=
PrintCodePage
(
0
);
}
...
...
windows/ipwin/ipwin/netcfg.cpp
View file @
a6f041e1
...
...
@@ -1022,7 +1022,7 @@ HRESULT SlaposNetCfgWinRemoveNetworkInterface(IN LPCWSTR pHwid,
// int length = StringFromGUID2(*pGUID, wszGuid, RT_ELEMENTS(wszGuid));
// if (!length)
// SetErrBreak(("Failed to create a Guid string"));
swprintf
(
strRegLocation
,
L"SYSTEM
\\
CurrentControlSet
\\
Control
\\
Network
\\
"
L"{4D36E972-E325-11CE-BFC1-08002BE10318}
\\
%s"
,
...
...
@@ -1212,7 +1212,7 @@ HRESULT SlaposNetCfgGetNetworkInterfaceGuid(IN LPCWSTR pHwid,
OUT
BSTR
*
pErrMsg
)
{
HRESULT
hrc
=
S_OK
;
HRESULT
hrc
=
E_FAIL
;
IP_ADAPTER_ADDRESSES
*
pAdaptAddr
=
NULL
;
IP_ADAPTER_ADDRESSES
*
pTmpAdaptAddr
=
NULL
;
...
...
@@ -1249,6 +1249,85 @@ HRESULT SlaposNetCfgGetNetworkInterfaceGuid(IN LPCWSTR pHwid,
if
(
wcscmp
(
pConnectionName
,
pTmpAdaptAddr
->
FriendlyName
)
==
0
)
{
memcpy
(
pGUID
,
pTmpAdaptAddr
->
AdapterName
,
strlen
(
pTmpAdaptAddr
->
AdapterName
));
// memcpy(pGUID, &(pTmpAdaptAddr -> NetworkGuid), sizeof(pTmpAdaptAddr -> NetworkGuid));
hrc
=
S_OK
;
break
;
}
pTmpAdaptAddr
=
pTmpAdaptAddr
->
Next
;
}
}
FREE
(
pAdaptAddr
);
return
hrc
;
}
HRESULT
SlaposNetCfgGetNetworkConnectionName
(
IN
LPCWSTR
pGUID
,
OUT
BSTR
*
pName
,
OUT
BSTR
*
pErrMsg
)
{
HRESULT
hrc
=
E_FAIL
;
IP_ADAPTER_ADDRESSES
*
pAdaptAddr
=
NULL
;
IP_ADAPTER_ADDRESSES
*
pTmpAdaptAddr
=
NULL
;
DWORD
dwRet
=
0
;
DWORD
dwSize
=
0x10000
;
CHAR
guid
[
256
]
=
{
0
};
if
(
WideCharToMultiByte
(
CP_ACP
,
0
,
pGUID
,
-
1
,
guid
,
256
,
NULL
,
NULL
)
==
0
)
{
sprintf
((
char
*
)
pErrMsg
,
"%s"
,
"WideCharToMultiByte error"
);
return
E_FAIL
;
}
dwRet
=
GetAdaptersAddresses
(
AF_UNSPEC
,
GAA_FLAG_SKIP_UNICAST
\
|
GAA_FLAG_SKIP_ANYCAST
\
|
GAA_FLAG_SKIP_MULTICAST
\
|
GAA_FLAG_SKIP_DNS_SERVER
,
NULL
,
pAdaptAddr
,
&
dwSize
);
if
(
ERROR_BUFFER_OVERFLOW
==
dwRet
)
{
FREE
(
pAdaptAddr
);
if
(
NULL
==
(
pAdaptAddr
=
(
IP_ADAPTER_ADDRESSES
*
)
MALLOC
(
dwSize
)))
return
E_FAIL
;
dwRet
=
GetAdaptersAddresses
(
AF_UNSPEC
,
GAA_FLAG_SKIP_UNICAST
\
|
GAA_FLAG_SKIP_ANYCAST
\
|
GAA_FLAG_SKIP_MULTICAST
\
|
GAA_FLAG_SKIP_DNS_SERVER
,
NULL
,
pAdaptAddr
,
&
dwSize
);
}
if
(
NO_ERROR
==
dwRet
)
{
pTmpAdaptAddr
=
pAdaptAddr
;
while
(
pTmpAdaptAddr
)
{
if
((
strcmp
(
pTmpAdaptAddr
->
AdapterName
,
guid
)
==
0
)
&&
pTmpAdaptAddr
->
FriendlyName
)
{
hrc
=
S_OK
;
if
(
WideCharToMultiByte
(
CP_ACP
,
0
,
pTmpAdaptAddr
->
FriendlyName
,
-
1
,
(
char
*
)
pName
,
256
,
NULL
,
NULL
)
==
0
)
{
sprintf
((
char
*
)
pErrMsg
,
"%s"
,
"WideCharToMultiByte error"
);
hrc
=
ERROR_BUFFER_OVERFLOW
;
}
break
;
}
pTmpAdaptAddr
=
pTmpAdaptAddr
->
Next
;
...
...
windows/scripts/ip
View file @
a6f041e1
...
...
@@ -300,15 +300,14 @@ function prefix_to_netmask()
#
function
format_interface_name
()
{
if
[[
"
$1
"
==
""
]]
;
then
return
1
fi
[[
-z
"
$1
"
]]
&&
return
1
[[
-x
/usr/bin/ipwin.exe
]]
||
return
1
local
guid
=
"
$1
"
if
!
[[
"
${
guid
:0:1
}
"
==
"{"
]]
;
then
echo
$
1
if
[[
${
guid
}
==
{
*
}
]]
;
then
echo
$
(
ipwin name
${
guid
}
)
else
echo
"re6stnet-lo"
echo
${
guid
}
fi
}
...
...
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