Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sbkclient
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李定达
sbkclient
Commits
1745af69
Commit
1745af69
authored
Aug 10, 2017
by
李定达
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.添加mac字段
parent
e9eaf7dc
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
85 additions
and
3 deletions
+85
-3
ZH_Client.suo
+0
-0
ZH_Client/filesystem.h
+2
-1
ZH_Client/fmglobal.h
+1
-0
ZH_Client/fmtool.h
+47
-1
ZH_Client/sbk_client.cpp
+35
-1
No files found.
ZH_Client.suo
View file @
1745af69
No preview for this file type
ZH_Client/filesystem.h
View file @
1745af69
...
...
@@ -4,9 +4,10 @@
#include <string>
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <Winbase.h>
#include <winsock.h>
#include <winsock
2
.h>
#include <DbgHelp.h>
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "fmcrypt.lib")
...
...
ZH_Client/fmglobal.h
View file @
1745af69
...
...
@@ -22,6 +22,7 @@
#define DES3_KEY "ABCD@#9876DFSAAWKLDEOPDD"
#define CRET_FILE_NAME "client.p12"
#define JSON_KEY_ONLY "partnerOrderId"
#define JSON_KEY_MAC "mac"
#define JSON_KEY_FMTEST "test"
#define CFG_KEY "template"
...
...
ZH_Client/fmtool.h
View file @
1745af69
...
...
@@ -3,15 +3,61 @@
#include <jansson.h>
#include <jansson_private.h>
#include <Windows.h>
#include "fmglobal.h"
#include "fmlog.h"
#include "filesystem.h"
#include <winsock2.h>
#include <iphlpapi.h>
#pragma comment(lib, "IPHLPAPI.lib")
class
Tool
{
public
:
static
int
GetMacByGetAdaptersAddresses
(
std
::
string
&
macOUT
)
{
bool
ret
=
0
;
ULONG
outBufLen
=
sizeof
(
IP_ADAPTER_ADDRESSES
);
PIP_ADAPTER_ADDRESSES
pAddresses
=
(
IP_ADAPTER_ADDRESSES
*
)
malloc
(
outBufLen
);
if
(
pAddresses
==
NULL
)
return
0
;
// Make an initial call to GetAdaptersAddresses to get the necessary size into the ulOutBufLen variable
if
(
GetAdaptersAddresses
(
AF_UNSPEC
,
0
,
NULL
,
pAddresses
,
&
outBufLen
)
==
ERROR_BUFFER_OVERFLOW
)
{
free
(
pAddresses
);
pAddresses
=
(
IP_ADAPTER_ADDRESSES
*
)
malloc
(
outBufLen
);
if
(
pAddresses
==
NULL
)
return
0
;
}
if
(
GetAdaptersAddresses
(
AF_UNSPEC
,
0
,
NULL
,
pAddresses
,
&
outBufLen
)
==
NO_ERROR
)
{
// If successful, output some information from the data we received
for
(
PIP_ADAPTER_ADDRESSES
pCurrAddresses
=
pAddresses
;
pCurrAddresses
!=
NULL
;
pCurrAddresses
=
pCurrAddresses
->
Next
)
{
// ȷMACַijΪ 00-00-00-00-00-00
if
(
pCurrAddresses
->
PhysicalAddressLength
!=
6
)
continue
;
char
acMAC
[
32
];
sprintf
(
acMAC
,
"%02X-%02X-%02X-%02X-%02X-%02X"
,
int
(
pCurrAddresses
->
PhysicalAddress
[
0
]),
int
(
pCurrAddresses
->
PhysicalAddress
[
1
]),
int
(
pCurrAddresses
->
PhysicalAddress
[
2
]),
int
(
pCurrAddresses
->
PhysicalAddress
[
3
]),
int
(
pCurrAddresses
->
PhysicalAddress
[
4
]),
int
(
pCurrAddresses
->
PhysicalAddress
[
5
]));
macOUT
=
acMAC
;
ret
=
1
;
break
;
}
}
free
(
pAddresses
);
return
ret
;
}
static
int
ReadTMPForType
(
char
*
tplt
,
int
reqType
)
{
char
tmp
[
MAX_BUF_LEN
]
=
{
0
};
...
...
ZH_Client/sbk_client.cpp
View file @
1745af69
...
...
@@ -302,6 +302,30 @@ void DeleteTableForDate()
}
int
GetEncodeMac
(
std
::
string
&
mac
)
{
std
::
string
tmp
;
if
(
Tool
::
GetMacByGetAdaptersAddresses
(
tmp
)
!=
1
)
return
0
;
LOG
()
<<
"get mac : "
<<
tmp
;
char
outmsg
[
4096
]
=
{
0
};
if
(
DataProcess
::
DES3Encode
((
const
unsigned
char
*
)
DES3_KEY
,
tmp
.
data
(),
strlen
(
tmp
.
data
()),
(
unsigned
char
*
)
outmsg
,
4096
)
==
0
)
{
LOG
()
<<
"DES3 encode failed"
;
return
0
;
}
mac
=
std
::
string
(
outmsg
);
LOG
()
<<
"encode mac(base64) : "
<<
mac
;
return
1
;
}
int
ProcessPosReqData
(
const
char
*
indata
,
string
&
in
,
int
*
needrbk
,
int
*
reqType_i
)
{
int
type
,
rlt
=
0
;
...
...
@@ -312,6 +336,7 @@ int ProcessPosReqData(const char *indata, string &in, int *needrbk, int *reqType
string
codestr
;
string
transIdstr
;
string
date
;
string
mac
;
*
needrbk
==
0
;
...
...
@@ -413,6 +438,10 @@ int ProcessPosReqData(const char *indata, string &in, int *needrbk, int *reqType
datastm
<<
t
->
tm_year
+
1900
<<
"-"
<<
std
::
setw
(
2
)
<<
std
::
setfill
(
'0'
)
<<
t
->
tm_mon
+
1
<<
"-"
;
datastm
<<
std
::
setw
(
2
)
<<
std
::
setfill
(
'0'
)
<<
t
->
tm_mday
;
//add mac
Tool
::
GetMacByGetAdaptersAddresses
(
mac
);
json_object_set
(
root
,
JSON_KEY_MAC
,
json_string
(
mac
.
data
()));
LOG
()
<<
"partnerOrderId code : "
<<
tmps
.
str
();
if
(
type
!=
3
)
...
...
@@ -475,6 +504,7 @@ int GetRealJson(std::string &out, const std::string &in)
json_t
*
root
,
*
reqtype
;
json_error_t
error
;
char
*
tmp
;
string
mac
;
root
=
json_loads
(
in
.
c_str
(),
0
,
&
error
);
...
...
@@ -484,6 +514,10 @@ int GetRealJson(std::string &out, const std::string &in)
return
0
;
}
//add mac
GetEncodeMac
(
mac
);
json_object_set
(
root
,
JSON_KEY_MAC
,
json_string
(
mac
.
data
()));
tmp
=
json_dumps
(
root
,
JSON_COMPACT
|
JSON_SORT_KEYS
);
out
=
std
::
string
(
tmp
);
...
...
@@ -1130,7 +1164,7 @@ int CheckCret()
extern
"C"
{
int
_stdcall
GetRSACret
(
int
partnerId
,
const
char
*
storeID
,
const
char
*
posNo
)
__declspec
(
dllexport
)
int
_stdcall
GetRSACret
(
int
partnerId
,
const
char
*
storeID
,
const
char
*
posNo
)
{
if
(
storeID
==
NULL
||
posNo
==
NULL
||
strlen
(
storeID
)
==
0
||
strlen
(
posNo
)
==
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