Annotation of embedaddon/strongswan/src/libcharon/encoding/payloads/endpoint_notify.h, revision 1.1.1.1
1.1 misho 1: /*
2: * Copyright (C) 2007 Tobias Brunner
3: * HSR Hochschule fuer Technik Rapperswil
4: *
5: * This program is free software; you can redistribute it and/or modify it
6: * under the terms of the GNU General Public License as published by the
7: * Free Software Foundation; either version 2 of the License, or (at your
8: * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9: *
10: * This program is distributed in the hope that it will be useful, but
11: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13: * for more details.
14: */
15:
16: /**
17: * @defgroup endpoint_notify endpoint_notify
18: * @{ @ingroup payloads
19: */
20:
21: #ifndef ENDPOINT_NOTIFY_H_
22: #define ENDPOINT_NOTIFY_H_
23:
24: #define ME_PRIO_HOST 255
25: #define ME_PRIO_PEER 128
26: #define ME_PRIO_SERVER 64
27: #define ME_PRIO_RELAY 0
28:
29: typedef enum me_endpoint_family_t me_endpoint_family_t;
30: typedef enum me_endpoint_type_t me_endpoint_type_t;
31: typedef struct endpoint_notify_t endpoint_notify_t;
32:
33: #include <encoding/payloads/notify_payload.h>
34:
35: /**
36: * ME endpoint families.
37: */
38: enum me_endpoint_family_t {
39:
40: NO_FAMILY = 0,
41:
42: IPv4 = 1,
43:
44: IPv6 = 2,
45:
46: MAX_FAMILY = 3
47:
48: };
49:
50: /**
51: * ME endpoint types.
52: */
53: enum me_endpoint_type_t {
54:
55: NO_TYPE = 0,
56:
57: HOST = 1,
58:
59: PEER_REFLEXIVE = 2,
60:
61: SERVER_REFLEXIVE = 3,
62:
63: RELAYED = 4,
64:
65: MAX_TYPE = 5
66:
67: };
68:
69: /**
70: * enum name for me_endpoint_type_t.
71: */
72: extern enum_name_t *me_endpoint_type_names;
73:
74: /**
75: * Class representing a ME_ENDPOINT Notify payload. In fact it's not
76: * the notify per se, but the notification data of that notify that is
77: * handled with this class.
78: */
79: struct endpoint_notify_t {
80: /**
81: * Returns the priority of this endpoint.
82: *
83: * @return priority
84: */
85: uint32_t (*get_priority) (endpoint_notify_t *this);
86:
87: /**
88: * Sets the priority of this endpoint.
89: *
90: * @param priority priority
91: */
92: void (*set_priority) (endpoint_notify_t *this, uint32_t priority);
93:
94: /**
95: * Returns the endpoint type of this endpoint.
96: *
97: * @return endpoint type
98: */
99: me_endpoint_type_t (*get_type) (endpoint_notify_t *this);
100:
101: /**
102: * Returns the endpoint family of this endpoint.
103: *
104: * @return endpoint family
105: */
106: me_endpoint_family_t (*get_family) (endpoint_notify_t *this);
107:
108: /**
109: * Returns the host of this endpoint.
110: *
111: * @return host
112: */
113: host_t *(*get_host) (endpoint_notify_t *this);
114:
115: /**
116: * Returns the base of this endpoint.
117: *
118: * If this is not a SERVER_REFLEXIVE endpoint, the returned host is the same
119: * as the one returned by get_host.
120: *
121: * @return host
122: */
123: host_t *(*get_base) (endpoint_notify_t *this);
124:
125: /**
126: * Generates a notification payload from this endpoint.
127: *
128: * @return built notify_payload_t
129: */
130: notify_payload_t *(*build_notify) (endpoint_notify_t *this);
131:
132: /**
133: * Clones an endpoint_notify_t object.
134: *
135: * @return cloned object
136: */
137: endpoint_notify_t *(*clone) (endpoint_notify_t *this);
138:
139: /**
140: * Destroys an endpoint_notify_t object.
141: */
142: void (*destroy) (endpoint_notify_t *this);
143: };
144:
145: /**
146: * Creates an endpoint_notify_t object from a host.
147: *
148: * @param type the endpoint type
149: * @param host host to base the notify on (gets cloned)
150: * @param base base of the endpoint, applies only to reflexive
151: * endpoints (gets cloned)
152: * @return created endpoint_notify_t object
153: */
154: endpoint_notify_t *endpoint_notify_create_from_host(me_endpoint_type_t type,
155: host_t *host, host_t *base);
156:
157: /**
158: * Creates an endpoint_notify_t object from a notify payload.
159: *
160: * @param notify the notify payload
161: * @return - created endpoint_notify_t object
162: * - NULL if invalid payload
163: */
164: endpoint_notify_t *endpoint_notify_create_from_payload(notify_payload_t *notify);
165:
166: #endif /** ENDPOINT_NOTIFY_H_ @}*/
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>