#ifndef PWSN_PROTOCOL_H_ #define PWSN_PROTOCOL_H_ #include #include #define PWSN_PROTOCOL_NR 6 typedef enum { PWSN_HELLO, PWSN_CHAT, PWSN_DATA_REQ, PWSN_DATA_RESP, PWSN_SERVICE_REQ, PWSN_SERVICE_RESP, PWSN_SERVICE_SET, PWSN_DHCP_DISCOVER, PWSN_DHCP_OFFER, PWSN_DHCP_REQ, PWSN_DHCP_ACK, PWSN_DHCP_NAK } packet_types; typedef struct { uint16_t seq_nr; uint16_t dst; uint16_t src; uint8_t type; uint8_t ttl; } pwsn_packet_header_t; typedef struct __attribute__ ((packed)) { pwsn_packet_header_t header; double energy; uint8_t nb_size; uint16_t neighbors[16]; } pwsn_hello_pkt_t; typedef struct { pwsn_packet_header_t header; uint8_t len; char mesg[40]; } pwsn_chat_pkt_t; typedef struct { pwsn_packet_header_t header; uint16_t id; uint8_t type; } pwsn_data_req_pkt_t; typedef struct { pwsn_packet_header_t header; uint16_t id; uint8_t data_len; char data_buf[40]; } pwsn_data_resp_pkt_t; typedef struct { pwsn_packet_header_t header; uint16_t id; } pwsn_service_resp_pkt_t; typedef struct { pwsn_packet_header_t header; } pwsn_service_req_pkt_t; typedef struct { pwsn_packet_header_t header; uint8_t id; uint8_t value; } pwsn_service_set_pkt_t; typedef struct { pwsn_packet_header_t header; } pwsn_dhcp_discover_pkt_t; typedef struct { pwsn_packet_header_t header; uint16_t xid; uint16_t addr; } pwsn_dhcp_offer_pkt_t; typedef struct { pwsn_packet_header_t header; uint16_t xid; } pwsn_dhcp_req_pkt_t; typedef struct { pwsn_packet_header_t header; } pwsn_dhcp_ack_pkt_t; typedef struct { pwsn_packet_header_t header; } pwsn_dhcp_nak_pkt_t; #endif