2005-11-04 16:27:45 +00:00
|
|
|
/**
|
|
|
|
* @file packet.h
|
|
|
|
*
|
2005-11-29 08:08:03 +00:00
|
|
|
* @brief Interface of packet_t.
|
2005-11-04 16:27:45 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2005 Jan Hutter, Martin Willi
|
|
|
|
* Hochschule fuer Technik Rapperswil
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PACKET_H_
|
|
|
|
#define PACKET_H_
|
|
|
|
|
|
|
|
|
2005-11-23 09:24:35 +00:00
|
|
|
#include <types.h>
|
2005-11-23 16:17:28 +00:00
|
|
|
#include <network/host.h>
|
2005-11-04 16:27:45 +00:00
|
|
|
|
|
|
|
|
2005-11-24 09:17:51 +00:00
|
|
|
typedef struct packet_t packet_t;
|
2005-11-04 16:27:45 +00:00
|
|
|
/**
|
2005-11-29 08:08:03 +00:00
|
|
|
* @brief Abstraction of an UDP-Packet, contains data, sender and receiver.
|
|
|
|
*
|
|
|
|
* @ingroup network
|
2005-11-04 16:27:45 +00:00
|
|
|
*/
|
2005-11-24 09:17:51 +00:00
|
|
|
struct packet_t {
|
2005-11-16 16:07:55 +00:00
|
|
|
|
2005-11-07 09:11:58 +00:00
|
|
|
/**
|
|
|
|
* source address structure
|
|
|
|
*/
|
2005-11-16 16:07:55 +00:00
|
|
|
host_t *source;
|
2005-11-04 16:27:45 +00:00
|
|
|
|
|
|
|
/**
|
2005-11-07 09:11:58 +00:00
|
|
|
* destination address structure
|
2005-11-04 16:27:45 +00:00
|
|
|
*/
|
2005-11-16 16:07:55 +00:00
|
|
|
host_t *destination;
|
2005-11-04 16:27:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* message data
|
|
|
|
*/
|
|
|
|
chunk_t data;
|
2005-11-07 11:46:18 +00:00
|
|
|
|
2005-11-10 15:38:12 +00:00
|
|
|
/**
|
2005-11-29 08:08:03 +00:00
|
|
|
* @brief Clones a packet_t object.
|
2005-11-10 15:38:12 +00:00
|
|
|
*
|
2005-11-29 08:08:03 +00:00
|
|
|
* @param packet calling object
|
2005-11-10 15:38:12 +00:00
|
|
|
* @param clone pointer to a packet_t object pointer where the new object is stored
|
|
|
|
*/
|
2005-11-29 08:08:03 +00:00
|
|
|
packet_t* (*clone) (packet_t *packet);
|
2005-11-07 09:11:58 +00:00
|
|
|
|
2005-11-04 16:27:45 +00:00
|
|
|
/**
|
2005-11-29 08:08:03 +00:00
|
|
|
* @brief Destroy the packet, freeing contained data.
|
2005-11-04 16:27:45 +00:00
|
|
|
*
|
2005-11-07 11:46:18 +00:00
|
|
|
* @param packet packet to destroy
|
2005-11-04 16:27:45 +00:00
|
|
|
*/
|
2005-11-29 08:08:03 +00:00
|
|
|
void (*destroy) (packet_t *packet);
|
2005-11-04 16:27:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2005-11-07 11:46:18 +00:00
|
|
|
* @brief create an empty packet
|
2005-11-04 16:27:45 +00:00
|
|
|
*
|
2005-11-29 08:08:03 +00:00
|
|
|
* @return created packet_t object
|
|
|
|
*
|
|
|
|
* @ingroup network
|
2005-11-04 16:27:45 +00:00
|
|
|
*/
|
2005-11-16 16:07:55 +00:00
|
|
|
packet_t *packet_create();
|
2005-11-04 16:27:45 +00:00
|
|
|
|
|
|
|
#endif /*PACKET_H_*/
|