![]() |
Rawsock library
v0.3.4
Library to make the use of raw sockets easier, under Linux. Currently supporting IPv4, UDP and a custom latency measurement protocol (LaMP - supported both in raw and non-raw sockets).
|
Go to the source code of this file.
Data Structures | |
| struct | lamphdr |
| Main LaMP packet header structure. More... | |
Enumerations | |
| enum | lamptype_t { PINGLIKE_REQ, PINGLIKE_REPLY, PINGLIKE_ENDREQ, PINGLIKE_ENDREPLY, UNIDIR_CONTINUE, UNIDIR_STOP, REPORT, ACK, INIT, PINGLIKE_REQ_TLESS, PINGLIKE_REPLY_TLESS, PINGLIKE_ENDREQ_TLESS, PINGLIKE_ENDREPLY_TLESS, FOLLOWUP_CTRL, FOLLOWUP_DATA } |
| LaMP type enumerator. More... | |
| enum | endflag_t { FLG_CONTINUE, FLG_STOP, FLG_NONE } |
| End flag type. More... | |
Functions | |
| void | lampHeadPopulate (struct lamphdr *lampHeader, unsigned char ctrl, unsigned short id, unsigned short seq) |
| Populate a LaMP header. More... | |
| void | lampHeadSetTimestamp (struct lamphdr *lampHeader, struct timeval *tStampPtr) |
| Set the timestamp inside a LaMP Header. More... | |
| void | lampEncapsulate (byte_t *packet, struct lamphdr *lampHeader, byte_t *data, size_t payloadsize) |
| Combine LaMP payload and header. More... | |
| void | lampSetUnidirStop (struct lamphdr *lampHeader) |
| Set the control field of a LaMP header to "Unidirectional stop". More... | |
| void | lampSetPinglikeEndreq (struct lamphdr *lampHeader) |
| Set the control field of a LaMP header to "Ping-like (bidirectional) end request". More... | |
| void | lampSetPinglikeEndreqTless (struct lamphdr *lampHeader) |
| Set the control field of a LaMP header to "Ping-like (bidirectional) end request (timestampless)". More... | |
| void | lampSetPinglikeEndreqAll (struct lamphdr *lampHeader) |
| Set the control field of a LaMP header to "Ping-like (bidirectional) end request". More... | |
| void | lampHeadSetConnType (struct lamphdr *initLampHeader, uint16_t mode_index) |
| Set the INIT type field ("length or packet type") inside a LaMP header. More... | |
| void | lampHeadSetFollowupCtrlType (struct lamphdr *followupLampHeader, uint16_t followup_type) |
| Set the FOLLOWUP_CTRL type field ("length or packet type") inside a LaMP header. More... | |
| void | lampHeadIncreaseSeq (struct lamphdr *inpacket_headerptr) |
| Increase the sequence number inside a LaMP header. More... | |
| int | rawLampSend (int descriptor, struct sockaddr_ll addrll, struct lamphdr *inpacket_headerptr, byte_t *ethernetpacket, size_t finalpacketsize, endflag_t end_flag, protocol_t llprot) |
| Send LaMP packet over a raw socket, automatically setting some fields such as the timestamp (when needed) More... | |
| void | lampHeadGetData (byte_t *lampPacket, lamptype_t *type, unsigned short *id, unsigned short *seq, unsigned short *len, struct timeval *timestamp, byte_t *payload) |
| Extract relevant data from a LaMP packet. More... | |
| byte_t * | lampGetPacketPointers (byte_t *pktbuf, struct lamphdr **lampHeader) |
| Get pointers to header and payload in a LaMP packet. More... | |
Extra Latency Measurement Protocol (custom protocol) support, developed in Politecnico di Torino.
This file represents an additional module of the Rawsock library, adding support for a custom L7 protocol, which can be encapsulated inside any packet and transported using any protocol, providing a tool to measure latency between wireless (and wired) devices. We decided to call it LaMP (Latency Measurement Protocol).
This file uses rawsock.h, but it is not included within the main module, allowing the user to include the Rawsock library without forcing him/her to include also the LaMP module, if he/she does not need it.
The version number of this module is set to be the same as the main Rawsock library version number.
Definition in file rawsock_lamp.h.
| #define CTRL_ACK 0xA7 |
LaMP type (full control field): Generic Acknowledgment (user can specify an additional custom payload, but it is not suggested to do so)
Definition at line 34 of file rawsock_lamp.h.
| #define CTRL_CONN_INIT 0xA8 |
LaMP type (full control field): Connection INIT packet (initial handshake INIT packet)
Definition at line 35 of file rawsock_lamp.h.
| #define CTRL_FOLLOWUP_CTRL 0xAD |
LaMP type (full control field): Follow up control message (request, deny or accept)
Definition at line 40 of file rawsock_lamp.h.
| #define CTRL_FOLLOWUP_DATA 0xAE |
LaMP type (full control field): Follow up data message (time delta message)
Definition at line 41 of file rawsock_lamp.h.
| #define CTRL_PINGLIKE_ENDREPLY 0xA3 |
LaMP type (full control field): Ping-like (bidirectional) end reply
Definition at line 30 of file rawsock_lamp.h.
| #define CTRL_PINGLIKE_ENDREPLY_TLESS 0xAC |
LaMP type (full control field): Ping-like (bidirectional) end reply - timestampless
Definition at line 39 of file rawsock_lamp.h.
| #define CTRL_PINGLIKE_ENDREQ 0xA2 |
LaMP type (full control field): Ping-like (bidirectional) end request
Definition at line 29 of file rawsock_lamp.h.
| #define CTRL_PINGLIKE_ENDREQ_TLESS 0xAB |
LaMP type (full control field): Ping-like (bidirectional) end request - timestampless
Definition at line 38 of file rawsock_lamp.h.
| #define CTRL_PINGLIKE_REPLY 0xA1 |
LaMP type (full control field): Ping-like (bidirectional) reply
Definition at line 28 of file rawsock_lamp.h.
| #define CTRL_PINGLIKE_REPLY_TLESS 0xAA |
LaMP type (full control field): Ping-like (bidirectional) reply - timestampless
Definition at line 37 of file rawsock_lamp.h.
| #define CTRL_PINGLIKE_REQ 0xA0 |
LaMP type (full control field): Ping-like (bidirectional) request
Definition at line 27 of file rawsock_lamp.h.
| #define CTRL_PINGLIKE_REQ_TLESS 0xA9 |
LaMP type (full control field): Ping-like (bidirectional) request - timestampless
Definition at line 36 of file rawsock_lamp.h.
| #define CTRL_TO_TYPE | ( | field | ) | (field & 0x0F) |
Conversion macro: Macro to convert a full control field (ctrl) value (0xA + 4 type bits) to the corresponding lamptype_t value (4 bits).
Definition at line 84 of file rawsock_lamp.h.
| #define CTRL_UNIDIR_CONTINUE 0xA4 |
LaMP type (full control field): Unidirectional continue packet (there will be more packets after the current one)
Definition at line 31 of file rawsock_lamp.h.
| #define CTRL_UNIDIR_REPORT 0xA6 |
LaMP type (full control field): Report packet (payload should contain user-defined data to be transmitted containing latency related statistics)
Definition at line 33 of file rawsock_lamp.h.
| #define CTRL_UNIDIR_STOP 0xA5 |
LaMP type (full control field): Unidirectional stop packet (last packet of the current session)
Definition at line 32 of file rawsock_lamp.h.
| #define ETHERTYPE_LAMP ETH_P_802_EX1 |
Local Experimental Ethertype should be used if LaMP is encapsulated directly inside a 802.11/Ethernet packet. You can use ETHERTYPE_LAMP for the sake of clarity (but ETH_P_802_EX1 is perfectly fine too).
Definition at line 76 of file rawsock_lamp.h.
| #define FOLLOWUP_ACCEPT 0x0200 |
LaMP follow-up control type: follow-up accept
Definition at line 46 of file rawsock_lamp.h.
| #define FOLLOWUP_DENY 0x0100 |
LaMP follow-up control type: follow-up deny
Definition at line 45 of file rawsock_lamp.h.
| #define FOLLOWUP_REQUEST 0x0000 |
LaMP follow-up control type: follow-up request (default request type: 0x00)
Definition at line 44 of file rawsock_lamp.h.
| #define FOLLOWUP_REQUEST_T_APP 0x0000 |
LaMP follow-up request type: application timestamps
Definition at line 50 of file rawsock_lamp.h.
| #define FOLLOWUP_REQUEST_T_HW 0x0003 |
LaMP follow-up request type: hardware timestamps
Definition at line 53 of file rawsock_lamp.h.
| #define FOLLOWUP_REQUEST_T_KRN 0x0002 |
LaMP follow-up request type: kernel timestamps
Definition at line 52 of file rawsock_lamp.h.
| #define FOLLOWUP_REQUEST_T_KRN_RX 0x0001 |
LaMP follow-up request type: kernel rx timestamps
Definition at line 51 of file rawsock_lamp.h.
| #define FOLLOWUP_UNKNOWN 0xFFFF |
LaMP follow-up control type: bad or unknown request
Definition at line 47 of file rawsock_lamp.h.
| #define INIT_PINGLIKE_INDEX 0x0001 |
INIT type field value: ping-like.
Definition at line 64 of file rawsock_lamp.h.
| #define INIT_UNIDIR_INDEX 0x0002 |
INIT type field value: undirectional.
Definition at line 65 of file rawsock_lamp.h.
| #define IS_CTRL_PINGLIKE_ENDREPLY | ( | ctrl | ) | (ctrl==CTRL_PINGLIKE_ENDREPLY || ctrl==CTRL_PINGLIKE_ENDREPLY_TLESS) |
Multi-type LaMP type check macro: checks if the control field of a LaMP header, specified as ctrl, corresponds to any kind of ping-like end reply
Definition at line 62 of file rawsock_lamp.h.
| #define IS_CTRL_PINGLIKE_ENDREQ | ( | ctrl | ) | (ctrl==CTRL_PINGLIKE_ENDREQ || ctrl==CTRL_PINGLIKE_ENDREQ_TLESS) |
Multi-type LaMP type check macro: checks if the control field of a LaMP header, specified as ctrl, corresponds to any kind of ping-like end request
Definition at line 61 of file rawsock_lamp.h.
| #define IS_CTRL_PINGLIKE_REPLY | ( | ctrl | ) | (ctrl==CTRL_PINGLIKE_REPLY || ctrl==CTRL_PINGLIKE_REPLY_TLESS) |
Multi-type LaMP type check macro: checks if the control field of a LaMP header, specified as ctrl, corresponds to any kind of ping-like reply
Definition at line 60 of file rawsock_lamp.h.
| #define IS_CTRL_PINGLIKE_REQ | ( | ctrl | ) | (ctrl==CTRL_PINGLIKE_REQ || ctrl==CTRL_PINGLIKE_REQ_TLESS) |
Multi-type LaMP type check macro: checks if the control field of a LaMP header, specified as ctrl, corresponds to any kind of ping-like request
Definition at line 59 of file rawsock_lamp.h.
| #define IS_FOLLOWUP_CTRL | ( | ctrl | ) | (ctrl == CTRL_FOLLOWUP_CTRL) |
LaMP Test macro: checks if the given control field value (specified as ctrl) is corresponding to "Follow-up control".
Definition at line 69 of file rawsock_lamp.h.
| #define IS_FOLLOWUP_CTRL_REQ_TYPE_VALID | ( | idx | ) | (idx == FOLLOWUP_REQUEST_T_APP || idx == FOLLOWUP_REQUEST_T_KRN_RX || idx == FOLLOWUP_REQUEST_T_KRN || idx == FOLLOWUP_REQUEST_T_HW || (idx >= 0x00F0 && idx<= 0x00FF)) |
LaMP Test macro: checks, given the full 16-bits long "payload length or packet type" field, whether it contains a valid follow-up request type or not (user defined values are included).
Definition at line 70 of file rawsock_lamp.h.
| #define IS_FOLLOWUP_CTRL_TYPE_VALID | ( | idx | ) | (idx == FOLLOWUP_REQUEST || idx == FOLLOWUP_DENY || idx == FOLLOWUP_ACCEPT || IS_FOLLOWUP_CTRL_REQ_TYPE_VALID(idx)) |
LaMP Test macro: checks whether the given FOLLOWUP_CTRL type field value (which can be extracted, for instance, from a received LaMP header and specified as idx) is valid or not.
Definition at line 71 of file rawsock_lamp.h.
| #define IS_FOLLOWUP_REQUEST | ( | lenortype_field | ) | ((lenortype_field & 0xFF00)==0x0000) |
LaMP Test macro: it checks, given a "payload length or packet type" field of a FOLLOWUP_CTRL packet, specified as 'lenortype_field', if it corresponds to a valid FOLLOWUP_REQUEST or not, no matter the request type (i.e. it checks if the first byte is set to 0x00)
Definition at line 56 of file rawsock_lamp.h.
| #define IS_INIT | ( | ctrl | ) | (ctrl == CTRL_CONN_INIT) |
LaMP Test macro: checks if the given control field value (specified as ctrl) is corresponding to "Connection INIT".
Definition at line 68 of file rawsock_lamp.h.
| #define IS_INIT_INDEX_VALID | ( | idx | ) | (idx == INIT_PINGLIKE_INDEX || idx == INIT_UNIDIR_INDEX) |
LaMP Test macro: checks whether the given INIT type field value (which can be extracted, for instance, from a received LaMP header and specified as idx) is valid or not.
Definition at line 67 of file rawsock_lamp.h.
| #define IS_LAMP | ( | reserved, | |
| ctrl | |||
| ) | (reserved==PROTO_LAMP && (ctrl & PROTO_LAMP_CTRL_MASK)==PROTO_LAMP_CTRL_MASK) |
LaMP Test macro: important macro: you can use this to check if a received packet is really encapsulating LaMP, after trying to extract the reserved (reserved) and control (ctrl) fields from it (threating the first bytes as if they were a LaMP header).
Definition at line 74 of file rawsock_lamp.h.
| #define IS_PINGLIKE | ( | ctrl | ) | (ctrl == CTRL_PINGLIKE_REQ || ctrl == CTRL_PINGLIKE_REPLY || ctrl == CTRL_PINGLIKE_ENDREQ || ctrl == CTRL_PINGLIKE_ENDREPLY || ctrl == CTRL_PINGLIKE_REQ_TLESS || ctrl == CTRL_PINGLIKE_REPLY_TLESS || ctrl == CTRL_PINGLIKE_ENDREQ_TLESS || ctrl == CTRL_PINGLIKE_ENDREPLY_TLESS) |
LaMP Test macro: checks, though the specified (as ctrl) control field value, if the current packet is ping-like.
Definition at line 73 of file rawsock_lamp.h.
| #define IS_UNIDIR | ( | ctrl | ) | (ctrl == CTRL_UNIDIR_CONTINUE || ctrl == CTRL_UNIDIR_STOP) |
LaMP Test macro: checks, though the specified (as ctrl) control field value, if the current packet is undirectional.
Definition at line 72 of file rawsock_lamp.h.
| #define LAMP_HDR_PAYLOAD_SIZE | ( | size | ) | sizeof(struct lamphdr)+size |
Size definition: given size, in bytes, the LaMP packet size (LaMP header + payload) containing a payload with the specified size is calculated and returned in bytes. This macro is similar to UDP_PACKET_SIZE_S, IP_UDP_PACKET_SIZE_S and ETH_IP_UDP_PACKET_SIZE_S, defined in rawsock.h
Definition at line 80 of file rawsock_lamp.h.
| #define LAMP_HDR_PAYLOAD_SIZE_STR | ( | data | ) | sizeof(struct lamphdr)+strlen(data) |
Size definition: given data, as a string, the LaMP packet size (header + payload) containing the specified string is calculated and returned in bytes.
Definition at line 79 of file rawsock_lamp.h.
| #define LAMP_HDR_SIZE | ( | ) | sizeof(struct lamphdr) |
Size definition: this macro returns the size of a LaMP header. Since the underlying struct lamphdr should be already "packed by design", this macro should be equivant to a call to ´sizeof(struct lamphdr)´, but a bit more compact.
Definition at line 81 of file rawsock_lamp.h.
| #define MAX_LAMP_LEN (65535) |
**LaMP size definition: maximum payload size a LaMP packet can bear.
Definition at line 77 of file rawsock_lamp.h.
| #define PROTO_LAMP 0xAA |
LaMP reserved field value: the reserved field of LaMP must always be checked against this constant, as it represents the value that every LaMP packet should contain inside the reserved field. It allows to distinguish LaMP packets with respect to non-LaMP payloads.
Definition at line 24 of file rawsock_lamp.h.
| #define PROTO_LAMP_CTRL_MASK 0xA0 |
LaMP control reserved field mask: every LaMP packet should contain 0xA as MSB of the control field, as extension of the reserved field itself. You can use this mask to check if the MSB is really 0xA (as rquired by LaMP); however, it is highly suggested to use
Definition at line 25 of file rawsock_lamp.h.
| #define TYPE_TO_CTRL | ( | field | ) | (field | PROTO_LAMP_CTRL_MASK) |
Conversion macro: Macro to convert a lamptype_t value (specified as field, 4 bits) to the corresponding full control field (ctrl) value (0xA + 4 type bits).
Definition at line 83 of file rawsock_lamp.h.
| enum endflag_t |
End flag type.
This enumerator can be used to tell rawLampSend() is the current packet whether the last one of the current session or not.
If it is FLG_STOP, the current packet will be threated as last one, and its type will be forced to "ping-like (bidirectional) end request" or "ping-like (bidirectional) end request - timestampless" or "unidirectional stop" (depending on the current session type).
If it is FLG_CONTINUE the current packet will not be threated as the last one, and its type won't be changed (it remains as specified before, for example by means of lampHeadPopulate().
FLG_NONE can be used in all the cases in which the user does not need to specify if the current packet is the last one or not (e.g. ACK and INIT packets).
Please see rawLampSend(), as the existence of this enumerator is directly linked to this function.
| Enumerator | |
|---|---|
| FLG_CONTINUE |
Flag CONTINUE: this is not the last packet of the session |
| FLG_STOP |
Flag STOP: this is the last packet of the session |
| FLG_NONE |
Flag NONE: the user does not want/need to specify any flag to rawLampSend() |
Definition at line 132 of file rawsock_lamp.h.
| enum lamptype_t |
LaMP type enumerator.
LaMP type enumerator: it can be used to manage the different types of LaMP packets without having to deal with the upper 4 bits of the control header field, which are always equal to 0xA.
The conversion from a control field value to the corresponding lamptype_t value, and vice versa, can be obtained through TYPE_TO_CTRL and CTRL_TO_TYPE.
Definition at line 99 of file rawsock_lamp.h.
| void lampEncapsulate | ( | byte_t * | packet, |
| struct lamphdr * | lampHeader, | ||
| byte_t * | data, | ||
| size_t | payloadsize | ||
| ) |
Combine LaMP payload and header.
This function combines a LaMP (optional) payload and header, the latter in the form of a struct lamphdr structure.
It can be used if an additional payload have to be inserted inside a LaMP packet. If the user does not want to insert any payload, he can directly send the LaMP header structure as payload of any other protocol, encapsulating LaMP, without the need of calling lampEncapsulate().
The user shall specify a buffer in which the full packet will be put, the LaMP header, the payload (byte_t *data) and its size in bytes.
| [out] | packet | Packet buffer (should be already allocated) that will contain the full LaMP packet (LaMP header + payload) |
| [in] | lampHeader | LaMP header, as struct lamphdr. Should be filled in with lampHeadPopulate() before being passed to this function. |
| [in] | data | Buffer containing the payload. |
| [in] | payloadsize | Size, in bytes, of the payload. |
Definition at line 246 of file rawsock_lamp.c.
Get pointers to header and payload in a LaMP packet.
This function can be used to obtain, given a certain buffer containing a full LaMP packet, including its payload, the pointers to the header (i.e. to the struct lamphdr and payload sections
Example of call:
payload=lampGetPacketPointers(packet,&lampHeader);
with:
struct lamphdr *lampHeader; byte_t *payload;
| [in] | pktbuf | Packet buffer, containing a full valid LaMP packet (the checksum or even the reserved field can be wrong, "valid" means here "that can be LaMP"). |
| [out] | lampHeader | This pointer will be written by the function, storing the pointer to the LaMP header inside the pktbuf packet buffer. |
Definition at line 383 of file rawsock_lamp.c.
| void lampHeadGetData | ( | byte_t * | lampPacket, |
| lamptype_t * | type, | ||
| unsigned short * | id, | ||
| unsigned short * | seq, | ||
| unsigned short * | len, | ||
| struct timeval * | timestamp, | ||
| byte_t * | payload | ||
| ) |
Extract relevant data from a LaMP packet.
This function can be used to extract all the relevant data, already converted to host byte order, from a LaMP packet.
The function takes as input the pointer to the LaMP packet (i.e. to a memory area where a struct lamphdr, plus the payload, is stored).
| [in] | lampPacket | Pointer to the LaMP packet buffer (with type byte_t). |
| [out] | id | Identification field (LaMP ID) value. |
| [out] | seq | Current sequence number inside the header. |
| [out] | len | Value stored inside the "length or INIT type" field. |
| [out] | timestamp | struct timeval which is filled using the timestamp stored inside the LaMP header. |
| [out] | payload | If this pointer is non-NULL, it should be related to a memory area big enough to contain a possible LaMP payload. Then, the function will copy the payload contained inside the LaMP packet buffer to that memory area. Il the length field is 0 (or NULL is specified), no copy operation will be performed. |
Definition at line 339 of file rawsock_lamp.c.
| void lampHeadIncreaseSeq | ( | struct lamphdr * | inpacket_headerptr | ) |
Increase the sequence number inside a LaMP header.
This function can be used to cyclically increase (up to 65535 and then back to 0) the sequence number inside an existing LaMP header of an existing LaMP packet.
The function takes as input the pointer to a LaMP header (i.e. to a memory area where a struct lamphdr is stored).
| [in,out] | inpacket_headerptr | Pointer to the LaMP header structure, in which the sequence number will be increased by 1. |
Definition at line 137 of file rawsock_lamp.c.
| void lampHeadPopulate | ( | struct lamphdr * | lampHeader, |
| unsigned char | ctrl, | ||
| unsigned short | id, | ||
| unsigned short | seq | ||
| ) |
Populate a LaMP header.
This function can be used to populate a LaMP header (struct lamphdr).
The user shall specify an already existing LaMP header structure to be filled in, the control field value (the full one), as ctrl, the identification value and the sequence number of the current packet.
| [in,out] | lampHeader | Pointer to the LaMP header structure. |
| [in] | ctrl | Full control field value (including the first 4 bits equal to 0xA) to be placed inside the header. |
| [in] | id | Identification field value. |
| [in] | seq | (Initial) sequence number to be put inside the LaMP header. |
Definition at line 34 of file rawsock_lamp.c.
| void lampHeadSetConnType | ( | struct lamphdr * | initLampHeader, |
| uint16_t | mode_index | ||
| ) |
Set the INIT type field ("length or packet type") inside a LaMP header.
This function can be used to set the "length or packet type" field inside an already populated LaMP header.
As it can be used to set an INIT type, this function has an effect only if the headers carries an "INIT" packet type and a valid index (see INIT_PINGLIKE_INDEX and INIT_UNIDIR_INDEX) is specified, otherwise it has no effect.
| [in,out] | initLampHeader | Pointer to the LaMP header structure, already populated by lampHeadPopulate(). |
| [in] | mode_index | INIT type index to be used (see INIT_PINGLIKE_INDEX and INIT_UNIDIR_INDEX) |
Definition at line 61 of file rawsock_lamp.c.
| void lampHeadSetFollowupCtrlType | ( | struct lamphdr * | followupLampHeader, |
| uint16_t | followup_type | ||
| ) |
Set the FOLLOWUP_CTRL type field ("length or packet type") inside a LaMP header.
This function can be used to set the "length or packet type" field inside an already populated LaMP header.
As it can be used to set a FOLLOWUP_CTRL type, this function has an effect only if the headers carries a "FOLLOWUP_CTRL" packet type and a valid type is specified, otherwise it has no effect.
| [in,out] | followupLampHeader | Pointer to the LaMP header structure, already populated by lampHeadPopulate(). |
| [in] | followup_type | FOLLOWUP_CTRL type to be used (see for instance FOLLOWUP_REQUEST) |
Definition at line 83 of file rawsock_lamp.c.
| void lampHeadSetTimestamp | ( | struct lamphdr * | lampHeader, |
| struct timeval * | tStampPtr | ||
| ) |
Set the timestamp inside a LaMP Header.
This function can be used to set the timestamp (seconds and microseconds fields) inside the specified LaMP header.
If tStampPtr is NULL, the timestamp is set to the time instant in which this function was called and started its execution. If it is not NULL, it will be set using the values stored inside the specified struct timeval.
A realtime clock is used (i.e. the one used for gettimeofday()).
This function has no effect if the packet is timestampless (i.e. if the control field is indicating a "TLESS" type)
| [in,out] | lampHeader | Pointer to the LaMP header structure. |
| [in] | tStampPtr | Pointer to a struct timeval to store a custom timestamp, or NULL to use the current time |
Definition at line 109 of file rawsock_lamp.c.
| void lampSetPinglikeEndreq | ( | struct lamphdr * | lampHeader | ) |
Set the control field of a LaMP header to "Ping-like (bidirectional) end request".
This function can be used to set the the control field inside an existing LaMP header of an existing LaMP packet, to "Ping-like (bidirectional) end request".
The function takes as input the pointer to a LaMP header (i.e. to a memory area where a struct lamphdr is stored).
| [in,out] | lampHeader | Pointer to the LaMP header structure. |
Definition at line 176 of file rawsock_lamp.c.
| void lampSetPinglikeEndreqAll | ( | struct lamphdr * | lampHeader | ) |
Set the control field of a LaMP header to "Ping-like (bidirectional) end request".
This function can be used to set the the control field inside an existing LaMP header of an existing LaMP packet, to "Ping-like (bidirectional) end request".
This function will look at the already existing control field and act accordingly:
The function takes as input the pointer to a LaMP header (i.e. to a memory area where a struct lamphdr is stored).
| [in,out] | lampHeader | Pointer to the LaMP header structure. |
Definition at line 214 of file rawsock_lamp.c.
| void lampSetPinglikeEndreqTless | ( | struct lamphdr * | lampHeader | ) |
Set the control field of a LaMP header to "Ping-like (bidirectional) end request (timestampless)".
This function can be used to set the the control field inside an existing LaMP header of an existing LaMP packet, to "Ping-like (bidirectional) end request (timestampless)".
The function takes as input the pointer to a LaMP header (i.e. to a memory area where a struct lamphdr is stored).
| [in,out] | lampHeader | Pointer to the LaMP header structure. |
Definition at line 192 of file rawsock_lamp.c.
| void lampSetUnidirStop | ( | struct lamphdr * | lampHeader | ) |
Set the control field of a LaMP header to "Unidirectional stop".
This function can be used to set the the control field inside an existing LaMP header of an existing LaMP packet, to "Unidirectional stop".
The function takes as input the pointer to a LaMP header (i.e. to a memory area where a struct lamphdr is stored).
| [in,out] | lampHeader | Pointer to the LaMP header structure. |
Definition at line 160 of file rawsock_lamp.c.
| int rawLampSend | ( | int | descriptor, |
| struct sockaddr_ll | addrll, | ||
| struct lamphdr * | inpacket_headerptr, | ||
| byte_t * | ethernetpacket, | ||
| size_t | finalpacketsize, | ||
| endflag_t | end_flag, | ||
| protocol_t | llprot | ||
| ) |
Send LaMP packet over a raw socket, automatically setting some fields such as the timestamp (when needed)
This function can be used to send a LaMP packet over a raw socket, automating some operations such as the insertion of the timestamp, which is performed as the last possible operation before sending.
It replaces any call to sendto().
This function allows the user to specify a certain protocol, which will be used to properly place the timestamp, when needed, inside the full packet. All the protocols defined inside protocol_t are supported by this function.
| [in] | descriptor | Socket descriptor related to the raw socket to be used to send the packet. |
| [in] | addrll | Socket address structure (struct sockaddr_ll, i.e. the same structure you would pass to a call to sendto()). |
| [in] | inpacket_headerptr | Pointer to the LaMP header inside the full packet, passed as ethernetpacket (a future improvement will remove the necessity of passing this pointer). |
| [in] | ethernetpacket | Pointer to the buffer storing the whole packet to be sent (i.e. the same buffer you would pass to a call to sendto()). |
| [in] | finalpacketsize | Size of the whole packet (i.e. the same size you would pass to a call to sendto()). |
| [in] | end_flag | End flag value: see endflag_t. |
| [in] | llprot | Protocol type, using the protocol_t definition inside rawsock.h. |
Definition at line 276 of file rawsock_lamp.c.