Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scapy
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
public-release-test-restored
platform
external
scapy
Commits
11f3a4fe
Commit
11f3a4fe
authored
8 years ago
by
Pierre LALET
Browse files
Options
Downloads
Patches
Plain Diff
TimeStampField.any2i() accepts a datetime object
parent
b9eb1fef
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scapy/layers/ntp.py
+4
-1
4 additions, 1 deletion
scapy/layers/ntp.py
with
4 additions
and
1 deletion
scapy/layers/ntp.py
+
4
−
1
View file @
11f3a4fe
...
@@ -8,6 +8,7 @@ NTP (Network Time Protocol).
...
@@ -8,6 +8,7 @@ NTP (Network Time Protocol).
"""
"""
import
time
import
time
import
datetime
from
scapy.packet
import
*
from
scapy.packet
import
*
from
scapy.fields
import
*
from
scapy.fields
import
*
from
scapy.layers.inet
import
UDP
from
scapy.layers.inet
import
UDP
...
@@ -29,8 +30,10 @@ class TimeStampField(FixedPointField):
...
@@ -29,8 +30,10 @@ class TimeStampField(FixedPointField):
return
time
.
strftime
(
"
%a, %d %b %Y %H:%M:%S +0000
"
,
time
.
gmtime
(
val
-
_NTP_BASETIME
))
return
time
.
strftime
(
"
%a, %d %b %Y %H:%M:%S +0000
"
,
time
.
gmtime
(
val
-
_NTP_BASETIME
))
def
any2i
(
self
,
pkt
,
val
):
def
any2i
(
self
,
pkt
,
val
):
if
type
(
val
)
is
str
:
if
isinstance
(
val
,
basestring
)
:
val
=
int
(
time
.
mktime
(
time
.
strptime
(
val
)))
+
_NTP_BASETIME
val
=
int
(
time
.
mktime
(
time
.
strptime
(
val
)))
+
_NTP_BASETIME
elif
isinstance
(
val
,
datetime
.
datetime
):
val
=
int
(
val
.
strftime
(
"
%s
"
))
+
_NTP_BASETIME
return
FixedPointField
.
any2i
(
self
,
pkt
,
val
)
return
FixedPointField
.
any2i
(
self
,
pkt
,
val
)
def
i2m
(
self
,
pkt
,
val
):
def
i2m
(
self
,
pkt
,
val
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment