ROHC compression/decompression library
c_udp.h
Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 2 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * This program is distributed in the hope that it will be useful,
00008  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00009  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010  * GNU General Public License for more details.
00011  *
00012  * You should have received a copy of the GNU General Public License
00013  * along with this program; if not, write to the Free Software
00014  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00015  */
00016 
00017 /**
00018  * @file c_udp.h
00019  * @brief ROHC compression context for the UDP profile.
00020  * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com>
00021  * @author The hackers from ROHC for Linux
00022  */
00023 
00024 #ifndef C_UDP_H
00025 #define C_UDP_H
00026 
00027 #include <netinet/ip.h>
00028 #include <netinet/udp.h>
00029 
00030 #include "c_generic.h"
00031 
00032 
00033 /**
00034  * @brief Define the UDP-specific temporary variables in the profile compression
00035  *        context.
00036  *
00037  * This object must be used by the UDP-specific decompression context sc_udp_context.
00038  *
00039  * @see sc_udp_context
00040  */
00041 struct udp_tmp_vars
00042 {
00043         /// The number of UDP fields that changed in the UDP header
00044         int send_udp_dynamic;
00045 };
00046 
00047 
00048 /**
00049  * @brief Define the UDP part of the profile decompression context.
00050  *
00051  * This object must be used with the generic part of the decompression
00052  * context c_generic_context.
00053  *
00054  * @see c_generic_context
00055  */
00056 struct sc_udp_context
00057 {
00058         /// The number of times the checksum field was added to the compressed header
00059         int udp_checksum_change_count;
00060 
00061         /// The previous UDP header
00062         struct udphdr old_udp;
00063 
00064         /// @brief UDP-specific temporary variables that are used during one single
00065         ///        compression of packet
00066         struct udp_tmp_vars tmp;
00067 };
00068 
00069 
00070 /*
00071  * Function prototypes.
00072  */
00073 
00074 int c_udp_create(struct c_context *const context, const struct ip_packet *ip);
00075 
00076 int c_udp_check_context(const struct c_context *context,
00077                         const struct ip_packet *ip);
00078 
00079 int c_udp_encode(struct c_context *const context,
00080                  const struct ip_packet *ip,
00081                  const int packet_size,
00082                  unsigned char *const dest,
00083                  const int dest_size,
00084                  rohc_packet_t *const packet_type,
00085                  int *const payload_offset);
00086 
00087 void udp_decide_state(struct c_context *const context);
00088 
00089 int udp_code_UO_packet_tail(const struct c_context *context,
00090                             const unsigned char *next_header,
00091                             unsigned char *const dest,
00092                             int counter);
00093 
00094 int udp_code_static_udp_part(const struct c_context *context,
00095                              const unsigned char *next_header,
00096                              unsigned char *const dest,
00097                              int counter);
00098 
00099 
00100 #endif
00101