-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlaunchlockrequester.cc
76 lines (51 loc) · 1.61 KB
/
launchlockrequester.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <click/config.h>
#include <elements/local/launch.hh>
#include <elements/local/launchlockrequester.hh>
#include <click/args.hh>
#include <click/error.hh>
#include <click/glue.hh>
#include <clicknet/ether.h>
CLICK_DECLS
LaunchLockRequester::LaunchLockRequester()
{
}
LaunchLockRequester::~LaunchLockRequester()
{
}
int
LaunchLockRequester::configure(Vector<String> &conf, ErrorHandler *errh)
{
return 0;
}
int
LaunchLockRequester::initialize(ErrorHandler *)
{
return 0;
}
// Function called from LaunchRouter to send lock request packets on certain channel to certain neighbor
void
LaunchLockRequester::send_lock_request(uint8_t channel, IPAddress distination_ip,uint8_t * destination_eth, uint8_t * source_eth )
{
int tailroom = 0;
int packetsize = sizeof(_lh);
int headroom = 0;
//WritablePacket *packet = Packet::make(headroom,0,packetsize, tailroom);
WritablePacket *packet = Packet::make((void *)&_lh, sizeof(_lh));
if (packet == 0 )
return click_chatter( "cannot make packet!");
// memset(packet->data(), 0, packet->length());
struct launch_ctrl_hdr * format = (struct launch_ctrl_hdr *) packet->data();
format->type = launch_ctrl_hdr::LAUNCH_LOCK_REQ;
format->channel = channel;
// memcpy(packet->data(), &_lh, sizeof(_lh));
//Push Ethernet header
struct click_ether ethh;
memcpy(ethh.ether_shost, source_eth, sizeof(ethh.ether_shost));
memcpy(ethh.ether_dhost, destination_eth, sizeof(ethh.ether_dhost));
ethh.ether_type = 0x0007;
WritablePacket *q = packet->push(14);
memcpy(q->data(), ðh, 14);
output(0).push(q);
}
CLICK_ENDDECLS
EXPORT_ELEMENT(LaunchLockRequester)