source: mainline/uspace/lib/c/include/net/ip_codes.h@ 257feec

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 257feec was ff2a62d, checked in by Jakub Jermar <jakub@…>, 15 years ago

Move ip_codes.h to standard library and remove unused stuff.

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*
2 * Copyright (c) 2009 Lukas Mejdrech
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup libc
30 * @{
31 */
32
33/** @file
34 * IP codes and definitions.
35 */
36
37#ifndef LIBC_IP_CODES_H_
38#define LIBC_IP_CODES_H_
39
40#include <sys/types.h>
41
42/** IP time to live counter type definition. */
43typedef uint8_t ip_ttl_t;
44
45/** IP type of service type definition. */
46typedef uint8_t ip_tos_t;
47
48/** IP transport protocol type definition. */
49typedef uint8_t ip_protocol_t;
50
51/** Default IPVERSION. */
52#define IPVERSION 4
53
54/** Default time to live counter. */
55#define IPDEFTTL 64
56
57/** @name IP options definitions */
58/*@{*/
59
60/** Copy shift. */
61#define IPOPT_COPY_SHIFT 7
62
63/** Class shift. */
64#define IPOPT_CLASS_SHIFT 5
65
66/** Number shift. */
67#define IPOPT_NUMBER_SHIFT 0
68
69/** Class mask. */
70#define IPOPT_CLASS_MASK 0x60
71
72/** Number mask. */
73#define IPOPT_NUMBER_MASK 0x1f
74
75/** Copy flag. */
76#define IPOPT_COPY (1 << IPOPT_COPY_SHIFT)
77
78/** Returns IP option type.
79 *
80 * @param[in] copy The value indication whether the IP option should be
81 * copied.
82 * @param[in] class The IP option class.
83 * @param[in] number The IP option number.
84 */
85#define IPOPT_TYPE(copy, class, number) \
86 (((copy) & IPOPT_COPY) | ((class) & IPOPT_CLASS_MASK) | \
87 (((number) << IPOPT_NUMBER_SHIFT) & IPOPT_NUMBER_MASK))
88
89/** Returns a value indicating whether the IP option should be copied.
90 * @param[in] o The IP option.
91 */
92#define IPOPT_COPIED(o) ((o) & IPOPT_COPY)
93
94/*@}*/
95
96/** @name IP option class definitions */
97/*@{*/
98
99/** Control class. */
100#define IPOPT_CONTROL (0 << IPOPT_CLASS_SHIFT)
101
102/*@}*/
103
104/** @name IP option type definitions */
105/*@{*/
106
107/** End of list. */
108#define IPOPT_END IPOPT_TYPE(0, IPOPT_CONTROL, 0)
109
110/** No operation. */
111#define IPOPT_NOOP IPOPT_TYPE(0, IPOPT_CONTROL, 1)
112
113/*@}*/
114
115#endif
116
117/** @}
118 */
Note: See TracBrowser for help on using the repository browser.