Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jlib
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
jlib
Commits
58c8344c
Commit
58c8344c
authored
Aug 12, 2017
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix vs2017 warnings
parent
6225f0bb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
90 deletions
+99
-90
icmp_header.hpp
net/icmp_header.hpp
+56
-49
ipv4_header.hpp
net/ipv4_header.hpp
+41
-39
FileOper.h
win32/mfc/FileOper.h
+2
-2
No files found.
net/icmp_header.hpp
View file @
58c8344c
...
...
@@ -33,62 +33,69 @@
class
icmp_header
{
public
:
enum
{
echo_reply
=
0
,
destination_unreachable
=
3
,
source_quench
=
4
,
redirect
=
5
,
echo_request
=
8
,
time_exceeded
=
11
,
parameter_problem
=
12
,
timestamp_request
=
13
,
timestamp_reply
=
14
,
info_request
=
15
,
info_reply
=
16
,
address_request
=
17
,
address_reply
=
18
};
icmp_header
()
{
std
::
fill
(
rep_
,
rep_
+
sizeof
(
rep_
),
0
);
}
unsigned
char
type
()
const
{
return
rep_
[
0
];
}
unsigned
char
code
()
const
{
return
rep_
[
1
];
}
unsigned
short
checksum
()
const
{
return
decode
(
2
,
3
);
}
unsigned
short
identifier
()
const
{
return
decode
(
4
,
5
);
}
unsigned
short
sequence_number
()
const
{
return
decode
(
6
,
7
);
}
void
type
(
unsigned
char
n
)
{
rep_
[
0
]
=
n
;
}
void
code
(
unsigned
char
n
)
{
rep_
[
1
]
=
n
;
}
void
checksum
(
unsigned
short
n
)
{
encode
(
2
,
3
,
n
);
}
void
identifier
(
unsigned
short
n
)
{
encode
(
4
,
5
,
n
);
}
void
sequence_number
(
unsigned
short
n
)
{
encode
(
6
,
7
,
n
);
}
friend
std
::
istream
&
operator
>>
(
std
::
istream
&
is
,
icmp_header
&
header
)
{
return
is
.
read
(
reinterpret_cast
<
char
*>
(
header
.
rep_
),
8
);
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
icmp_header
&
header
)
{
return
os
.
write
(
reinterpret_cast
<
const
char
*>
(
header
.
rep_
),
8
);
}
enum
{
echo_reply
=
0
,
destination_unreachable
=
3
,
source_quench
=
4
,
redirect
=
5
,
echo_request
=
8
,
time_exceeded
=
11
,
parameter_problem
=
12
,
timestamp_request
=
13
,
timestamp_reply
=
14
,
info_request
=
15
,
info_reply
=
16
,
address_request
=
17
,
address_reply
=
18
};
icmp_header
()
{
memset
(
rep_
,
0
,
sizeof
(
rep_
));
}
unsigned
char
type
()
const
{
return
rep_
[
0
];
}
unsigned
char
code
()
const
{
return
rep_
[
1
];
}
unsigned
short
checksum
()
const
{
return
decode
(
2
,
3
);
}
unsigned
short
identifier
()
const
{
return
decode
(
4
,
5
);
}
unsigned
short
sequence_number
()
const
{
return
decode
(
6
,
7
);
}
void
type
(
unsigned
char
n
)
{
rep_
[
0
]
=
n
;
}
void
code
(
unsigned
char
n
)
{
rep_
[
1
]
=
n
;
}
void
checksum
(
unsigned
short
n
)
{
encode
(
2
,
3
,
n
);
}
void
identifier
(
unsigned
short
n
)
{
encode
(
4
,
5
,
n
);
}
void
sequence_number
(
unsigned
short
n
)
{
encode
(
6
,
7
,
n
);
}
friend
std
::
istream
&
operator
>>
(
std
::
istream
&
is
,
icmp_header
&
header
)
{
return
is
.
read
(
reinterpret_cast
<
char
*>
(
header
.
rep_
),
8
);
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
icmp_header
&
header
)
{
return
os
.
write
(
reinterpret_cast
<
const
char
*>
(
header
.
rep_
),
8
);
}
private
:
unsigned
short
decode
(
int
a
,
int
b
)
const
{
return
((
rep_
[
a
]
<<
8
)
+
rep_
[
b
])
&
0xFFFF
;
}
void
encode
(
int
a
,
int
b
,
unsigned
short
n
)
{
rep_
[
a
]
=
static_cast
<
unsigned
char
>
(
n
>>
8
);
rep_
[
b
]
=
static_cast
<
unsigned
char
>
(
n
&
0xFF
);
}
unsigned
char
rep_
[
8
];
unsigned
short
decode
(
int
a
,
int
b
)
const
{
return
((
rep_
[
a
]
<<
8
)
+
rep_
[
b
])
&
0xFFFF
;
}
void
encode
(
int
a
,
int
b
,
unsigned
short
n
)
{
rep_
[
a
]
=
static_cast
<
unsigned
char
>
(
n
>>
8
);
rep_
[
b
]
=
static_cast
<
unsigned
char
>
(
n
&
0xFF
);
}
unsigned
char
rep_
[
8
];
};
template
<
typename
Iterator
>
void
compute_checksum
(
icmp_header
&
header
,
Iterator
body_begin
,
Iterator
body_end
)
Iterator
body_begin
,
Iterator
body_end
)
{
unsigned
int
sum
=
(
header
.
type
()
<<
8
)
+
header
.
code
()
+
header
.
identifier
()
+
header
.
sequence_number
();
Iterator
body_iter
=
body_begin
;
while
(
body_iter
!=
body_end
)
{
sum
+=
(
static_cast
<
unsigned
char
>
(
*
body_iter
++
)
<<
8
);
if
(
body_iter
!=
body_end
)
sum
+=
static_cast
<
unsigned
char
>
(
*
body_iter
++
);
}
sum
=
(
sum
>>
16
)
+
(
sum
&
0xFFFF
);
sum
+=
(
sum
>>
16
);
header
.
checksum
(
static_cast
<
unsigned
short
>
(
~
sum
));
unsigned
int
sum
=
(
header
.
type
()
<<
8
)
+
header
.
code
()
+
header
.
identifier
()
+
header
.
sequence_number
();
Iterator
body_iter
=
body_begin
;
while
(
body_iter
!=
body_end
)
{
sum
+=
(
static_cast
<
unsigned
char
>
(
*
body_iter
++
)
<<
8
);
if
(
body_iter
!=
body_end
)
sum
+=
static_cast
<
unsigned
char
>
(
*
body_iter
++
);
}
sum
=
(
sum
>>
16
)
+
(
sum
&
0xFFFF
);
sum
+=
(
sum
>>
16
);
header
.
checksum
(
static_cast
<
unsigned
short
>
(
~
sum
));
}
#endif // ICMP_HEADER_HPP
\ No newline at end of file
net/ipv4_header.hpp
View file @
58c8344c
...
...
@@ -51,52 +51,54 @@
class
ipv4_header
{
public
:
ipv4_header
()
{
std
::
fill
(
rep_
,
rep_
+
sizeof
(
rep_
),
0
);
}
ipv4_header
()
{
memset
(
rep_
,
0
,
sizeof
(
rep_
)
);
}
unsigned
char
version
()
const
{
return
(
rep_
[
0
]
>>
4
)
&
0xF
;
}
unsigned
short
header_length
()
const
{
return
((
rep_
[
0
]
&
0xF
)
*
4
)
&
0xFFFF
;
}
unsigned
char
type_of_service
()
const
{
return
rep_
[
1
];
}
unsigned
short
total_length
()
const
{
return
decode
(
2
,
3
);
}
unsigned
short
identification
()
const
{
return
decode
(
4
,
5
);
}
bool
dont_fragment
()
const
{
return
(
rep_
[
6
]
&
0x40
)
!=
0
;
}
bool
more_fragments
()
const
{
return
(
rep_
[
6
]
&
0x20
)
!=
0
;
}
unsigned
short
fragment_offset
()
const
{
return
decode
(
6
,
7
)
&
0x1FFF
;
}
unsigned
int
time_to_live
()
const
{
return
rep_
[
8
];
}
unsigned
char
protocol
()
const
{
return
rep_
[
9
];
}
unsigned
short
header_checksum
()
const
{
return
decode
(
10
,
11
);
}
unsigned
char
version
()
const
{
return
(
rep_
[
0
]
>>
4
)
&
0xF
;
}
unsigned
short
header_length
()
const
{
return
((
rep_
[
0
]
&
0xF
)
*
4
)
&
0xFFFF
;
}
unsigned
char
type_of_service
()
const
{
return
rep_
[
1
];
}
unsigned
short
total_length
()
const
{
return
decode
(
2
,
3
);
}
unsigned
short
identification
()
const
{
return
decode
(
4
,
5
);
}
bool
dont_fragment
()
const
{
return
(
rep_
[
6
]
&
0x40
)
!=
0
;
}
bool
more_fragments
()
const
{
return
(
rep_
[
6
]
&
0x20
)
!=
0
;
}
unsigned
short
fragment_offset
()
const
{
return
decode
(
6
,
7
)
&
0x1FFF
;
}
unsigned
int
time_to_live
()
const
{
return
rep_
[
8
];
}
unsigned
char
protocol
()
const
{
return
rep_
[
9
];
}
unsigned
short
header_checksum
()
const
{
return
decode
(
10
,
11
);
}
boost
::
asio
::
ip
::
address_v4
source_address
()
const
{
boost
::
asio
::
ip
::
address_v4
::
bytes_type
bytes
=
{
{
rep_
[
12
],
rep_
[
13
],
rep_
[
14
],
rep_
[
15
]
}
};
return
boost
::
asio
::
ip
::
address_v4
(
bytes
);
}
boost
::
asio
::
ip
::
address_v4
source_address
()
const
{
boost
::
asio
::
ip
::
address_v4
::
bytes_type
bytes
=
{
{
rep_
[
12
],
rep_
[
13
],
rep_
[
14
],
rep_
[
15
]
}
};
return
boost
::
asio
::
ip
::
address_v4
(
bytes
);
}
boost
::
asio
::
ip
::
address_v4
destination_address
()
const
{
boost
::
asio
::
ip
::
address_v4
::
bytes_type
bytes
=
{
{
rep_
[
16
],
rep_
[
17
],
rep_
[
18
],
rep_
[
19
]
}
};
return
boost
::
asio
::
ip
::
address_v4
(
bytes
);
}
boost
::
asio
::
ip
::
address_v4
destination_address
()
const
{
boost
::
asio
::
ip
::
address_v4
::
bytes_type
bytes
=
{
{
rep_
[
16
],
rep_
[
17
],
rep_
[
18
],
rep_
[
19
]
}
};
return
boost
::
asio
::
ip
::
address_v4
(
bytes
);
}
friend
std
::
istream
&
operator
>>
(
std
::
istream
&
is
,
ipv4_header
&
header
)
{
is
.
read
(
reinterpret_cast
<
char
*>
(
header
.
rep_
),
20
);
if
(
header
.
version
()
!=
4
)
is
.
setstate
(
std
::
ios
::
failbit
);
std
::
streamsize
options_length
=
header
.
header_length
()
-
20
;
if
(
options_length
<
0
||
options_length
>
40
)
is
.
setstate
(
std
::
ios
::
failbit
);
else
is
.
read
(
reinterpret_cast
<
char
*>
(
header
.
rep_
)
+
20
,
options_length
);
return
is
;
}
friend
std
::
istream
&
operator
>>
(
std
::
istream
&
is
,
ipv4_header
&
header
)
{
is
.
read
(
reinterpret_cast
<
char
*>
(
header
.
rep_
),
20
);
if
(
header
.
version
()
!=
4
)
is
.
setstate
(
std
::
ios
::
failbit
);
std
::
streamsize
options_length
=
header
.
header_length
()
-
20
;
if
(
options_length
<
0
||
options_length
>
40
)
is
.
setstate
(
std
::
ios
::
failbit
);
else
is
.
read
(
reinterpret_cast
<
char
*>
(
header
.
rep_
)
+
20
,
options_length
);
return
is
;
}
private
:
unsigned
short
decode
(
int
a
,
int
b
)
const
{
return
((
rep_
[
a
]
<<
8
)
+
rep_
[
b
])
&
0xFFFF
;
}
unsigned
short
decode
(
int
a
,
int
b
)
const
{
return
((
rep_
[
a
]
<<
8
)
+
rep_
[
b
])
&
0xFFFF
;
}
unsigned
char
rep_
[
60
];
unsigned
char
rep_
[
60
];
};
#endif // IPV4_HEADER_HPP
\ No newline at end of file
win32/mfc/FileOper.h
View file @
58c8344c
...
...
@@ -253,7 +253,7 @@ public:
num
.
ReleaseBuffer
();
num
.
Format
(
_T
(
"%03d"
),
nums
);
tittle
+=
num
;
newFileName
.
Format
(
_T
(
"%s%s"
),
tittle
,
ext
);
newFileName
.
Format
(
_T
(
"%s%s"
),
(
LPCWSTR
)
tittle
,
(
LPCWSTR
)
ext
);
LPCTSTR
szOldName
=
fileName
.
GetBuffer
(
fileName
.
GetLength
());
fileName
.
ReleaseBuffer
();
LPCTSTR
szNewName
=
newFileName
.
GetBuffer
(
newFileName
.
GetLength
());
...
...
@@ -281,7 +281,7 @@ public:
filepath
=
find
.
GetFilePath
();
if
(
DeleteFile
(
filepath
.
GetBuffer
(
filepath
.
GetLength
()))){
CString
trace
;
trace
.
Format
(
_T
(
"CFileOper::DeleteFilesInFolder delete file %s
\n
"
),
find
.
GetFilePath
());
(
LPCWSTR
)
find
.
GetFilePath
());
TRACE
(
trace
);
bfoundone
=
TRUE
;
dwDeletedFileNums
++
;
...
...
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