Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
click_for_comnet2
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
Packages
Packages
Container Registry
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
Jiachen,Chen
click_for_comnet2
Commits
1abb3705
Commit
1abb3705
authored
Apr 30, 2019
by
Jiachen,Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified TestTimer
parent
719e9000
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
126 additions
and
0 deletions
+126
-0
TestTimer.cc
TestTimer.cc
+78
-0
TestTimer.click
TestTimer.click
+6
-0
TestTimer.hh
TestTimer.hh
+42
-0
No files found.
TestTimer.cc
0 → 100644
View file @
1abb3705
/*
* File: TestTimer.cc
* Author: Jiachen Chen
*
* Created on April 30, 2019, 4:24 AM
*/
#include "TestTimer.hh"
#include <click/timestamp.hh>
CLICK_DECLS
#define TIMER_DEBUG
#ifdef TIMER_DEBUG
#define DEBUG(...) _DEBUG(__VA_ARGS__, "dummy")
#define _DEBUG(fmt, ...) printf("[%s.%s():%d] " fmt "%.0s\n", \
class_name(), __func__, __LINE__, __VA_ARGS__)
#define DEBUG_NO_CLASS(...) _DEBUG_NO_CLASS(__VA_ARGS__, "dummy")
#define _DEBUG_NO_CLASS(fmt, ...) printf("[%s():%d] " fmt "%.0s\n", \
__func__, __LINE__, __VA_ARGS__)
#else
#define DEBUG(...)
#endif
static
void
runPacketTimeout
(
Timer
*
timer
,
void
*
user_data
);
struct
TimeoutData
{
Packet
*
p
;
TestTimer
*
element
;
};
TestTimer
::
TestTimer
()
:
_timer
(
this
)
{
}
TestTimer
::~
TestTimer
()
=
default
;
int
TestTimer
::
initialize
(
ErrorHandler
*
errh
__attribute
((
__unused__
)))
{
_timer
.
initialize
(
this
);
_timer
.
schedule_after_sec
(
5
);
return
0
;
}
void
TestTimer
::
push
(
int
port
,
Packet
*
p
)
{
(
void
)
port
;
struct
TimeoutData
*
data
=
new
TimeoutData
{
p
,
this
};
DEBUG
(
"push, data=%p, pkt=%p"
,
data
,
p
);
Timer
*
t
=
new
Timer
(
runPacketTimeout
,
data
);
t
->
initialize
(
this
);
// t->initialize(this);
t
->
schedule_after_msec
(
1500
);
}
void
TestTimer
::
run_timer
(
Timer
*
timer
)
{
DEBUG
(
">>> Element timer, timer=%p"
,
timer
);
timer
->
reschedule_after_sec
(
5
);
}
void
TestTimer
::
handle_timeout
(
Packet
*
p
)
{
DEBUG
(
"timeout, pkt=%p"
,
p
);
p
->
kill
();
}
static
void
runPacketTimeout
(
Timer
*
timer
,
void
*
user_data
)
{
DEBUG_NO_CLASS
(
"Static run timer function, timer=%p, data=%p"
,
timer
,
user_data
);
timer
->
clear
();
delete
timer
;
struct
TimeoutData
*
d
=
static_cast
<
struct
TimeoutData
*>
(
user_data
);
d
->
element
->
handle_timeout
(
d
->
p
);
delete
d
;
}
CLICK_ENDDECLS
EXPORT_ELEMENT
(
TestTimer
)
\ No newline at end of file
TestTimer.click
0 → 100644
View file @
1abb3705
require(package "click_for_comnet");
test :: TestTimer;
TimedSource(INTERVAL 1s, DATA "HELLO", LIMIT 10, STOP false)
-> test;
TestTimer.hh
0 → 100644
View file @
1abb3705
/*
* File: TestTimer.hh
* Author: Jiachen Chen
*
* Created on April 30, 2019, 4:24 AM
*/
#ifndef TESTTIMER_HH
#define TESTTIMER_HH
#include <click/config.h>
#include <click/element.hh>
#include <click/glue.hh>
#include <click/timer.hh>
CLICK_DECLS
class
TestTimer
:
public
Element
{
public:
TestTimer
();
~
TestTimer
();
const
char
*
class_name
()
const
{
return
"TestTimer"
;
}
const
char
*
processing
()
const
{
return
PUSH
;
}
const
char
*
port_count
()
const
{
return
"-1/0"
;
}
int
initialize
(
ErrorHandler
*
errh
)
override
;
void
push
(
int
port
,
Packet
*
p
);
void
run_timer
(
Timer
*
timer
)
override
;
void
handle_timeout
(
Packet
*
p
);
private:
Timer
_timer
;
};
CLICK_ENDDECLS
#endif
/* TESTTIMER_HH */
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