BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJLIB-UTIL Reference

stun_simple.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJSTUN_H__
20#define __PJSTUN_H__
21
27#include <pjlib-util/types.h>
28#include <pj/sock.h>
29
30
32
36typedef enum pjstun_msg_type
37{
45
46
50typedef enum pjstun_attr_type
51{
52 PJSTUN_ATTR_MAPPED_ADDR = 1,
53 PJSTUN_ATTR_RESPONSE_ADDR,
54 PJSTUN_ATTR_CHANGE_REQUEST,
55 PJSTUN_ATTR_SOURCE_ADDR,
56 PJSTUN_ATTR_CHANGED_ADDR,
57 PJSTUN_ATTR_USERNAME,
58 PJSTUN_ATTR_PASSWORD,
59 PJSTUN_ATTR_MESSAGE_INTEGRITY,
60 PJSTUN_ATTR_ERROR_CODE,
61 PJSTUN_ATTR_UNKNOWN_ATTRIBUTES,
62 PJSTUN_ATTR_REFLECTED_FROM,
63 PJSTUN_ATTR_XOR_MAPPED_ADDR = 0x0020
65
66
67/*
68 * This structre describes STUN message header.
69 */
70typedef struct pjstun_msg_hdr
71{
72 pj_uint16_t type;
73 pj_uint16_t length;
74 pj_uint32_t tsx[4];
76
77
78/*
79 * This structre describes STUN attribute header.
80 */
81typedef struct pjstun_attr_hdr
82{
83 pj_uint16_t type;
84 pj_uint16_t length;
86
87
88/*
89 * This structre describes STUN MAPPED-ADDR attribute.
90 */
92{
94 pj_uint8_t ignored;
95 pj_uint8_t family;
96 pj_uint16_t port;
97 pj_uint32_t addr;
99
104
106{
107 pjstun_attr_hdr hdr;
108 pj_uint32_t value;
110
112{
113 pjstun_attr_hdr hdr;
114 pj_uint32_t value[1];
116
118
120{
121 pjstun_attr_hdr hdr;
122 pj_uint16_t ignored;
123 pj_uint8_t err_class;
124 pj_uint8_t number;
125 char reason[4];
127
128typedef struct pjstun_msg
129{
130 pjstun_msg_hdr *hdr;
131 int attr_count;
133} pjstun_msg;
134
135/* STUN message API (stun.c). */
136
137PJ_DECL(pj_status_t) pjstun_create_bind_req( pj_pool_t *pool,
138 void **msg, pj_size_t *len,
139 pj_uint32_t id_hi,
140 pj_uint32_t id_lo);
141PJ_DECL(pj_status_t) pjstun_parse_msg( void *buf, pj_size_t len,
142 pjstun_msg *msg);
143PJ_DECL(void*) pjstun_msg_find_attr( pjstun_msg *msg, pjstun_attr_type t);
144
145
196 int sock_cnt, pj_sock_t sock[],
197 const pj_str_t *srv1, int port1,
198 const pj_str_t *srv2, int port2,
199 pj_sockaddr_in mapped_addr[]);
200
201
202/*
203 * This structre describes configurable setting for requesting mapped address.
204 */
205typedef struct pjstun_setting
206{
212
216 int af;
217
222
226 int port1;
227
232
236 int port2;
237
239
240
275 const pjstun_setting *opt,
276 int sock_cnt,
277 pj_sock_t sock[],
278 pj_sockaddr_in mapped_addr[]);
279
280
282
287#endif /* __PJSTUN_H__ */
288
#define PJSTUN_MAX_ATTR
Definition: config.h:225
pj_status_t pjstun_get_mapped_addr2(pj_pool_factory *pf, const pjstun_setting *opt, int sock_cnt, pj_sock_t sock[], pj_sockaddr_in mapped_addr[])
pj_status_t pjstun_get_mapped_addr(pj_pool_factory *pf, int sock_cnt, pj_sock_t sock[], const pj_str_t *srv1, int port1, const pj_str_t *srv2, int port2, pj_sockaddr_in mapped_addr[])
unsigned char pj_uint8_t
int pj_bool_t
unsigned short pj_uint16_t
long pj_sock_t
size_t pj_size_t
int pj_status_t
unsigned int pj_uint32_t
#define PJ_BEGIN_DECL
#define PJ_END_DECL
Definition: stun_simple.h:82
Definition: stun_simple.h:106
Definition: stun_simple.h:120
Definition: stun_simple.h:92
Definition: stun_simple.h:71
Definition: stun_simple.h:129
Definition: stun_simple.h:206
pj_str_t srv1
Definition: stun_simple.h:221
int port1
Definition: stun_simple.h:226
int af
Definition: stun_simple.h:216
pj_bool_t use_stun2
Definition: stun_simple.h:211
pj_str_t srv2
Definition: stun_simple.h:231
int port2
Definition: stun_simple.h:236
Definition: stun_simple.h:112
pjstun_msg_type
Definition: stun_simple.h:37
@ PJSTUN_SHARED_SECRET_REQUEST
Definition: stun_simple.h:41
@ PJSTUN_BINDING_RESPONSE
Definition: stun_simple.h:39
@ PJSTUN_BINDING_ERROR_RESPONSE
Definition: stun_simple.h:40
@ PJSTUN_SHARED_SECRET_RESPONSE
Definition: stun_simple.h:42
@ PJSTUN_BINDING_REQUEST
Definition: stun_simple.h:38
@ PJSTUN_SHARED_SECRET_ERROR_RESPONSE
Definition: stun_simple.h:43
pjstun_attr_type
Definition: stun_simple.h:51
PJLIB-UTIL types.

 


PJLIB-UTIL Open Source, small footprint, and portable asynchronous/caching DNS resolver, text scanner, STUN client, and XML library
Copyright (C) 2006-2009 Teluu Inc.