|
Home --> Documentations --> PJLIB-UTIL Reference
stun_simple.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __PJSTUN_H__
00021 #define __PJSTUN_H__
00022
00028 #include <pjlib-util/types.h>
00029 #include <pj/sock.h>
00030
00031
00032 PJ_BEGIN_DECL
00033
00034
00035
00036
00037 typedef enum pjstun_msg_type
00038 {
00039 PJSTUN_BINDING_REQUEST = 0x0001,
00040 PJSTUN_BINDING_RESPONSE = 0x0101,
00041 PJSTUN_BINDING_ERROR_RESPONSE = 0x0111,
00042 PJSTUN_SHARED_SECRET_REQUEST = 0x0002,
00043 PJSTUN_SHARED_SECRET_RESPONSE = 0x0102,
00044 PJSTUN_SHARED_SECRET_ERROR_RESPONSE = 0x0112
00045 } pjstun_msg_type;
00046
00047
00048
00049
00050
00051 typedef enum pjstun_attr_type
00052 {
00053 PJSTUN_ATTR_MAPPED_ADDR = 1,
00054 PJSTUN_ATTR_RESPONSE_ADDR,
00055 PJSTUN_ATTR_CHANGE_REQUEST,
00056 PJSTUN_ATTR_SOURCE_ADDR,
00057 PJSTUN_ATTR_CHANGED_ADDR,
00058 PJSTUN_ATTR_USERNAME,
00059 PJSTUN_ATTR_PASSWORD,
00060 PJSTUN_ATTR_MESSAGE_INTEGRITY,
00061 PJSTUN_ATTR_ERROR_CODE,
00062 PJSTUN_ATTR_UNKNOWN_ATTRIBUTES,
00063 PJSTUN_ATTR_REFLECTED_FROM,
00064 PJSTUN_ATTR_XOR_MAPPED_ADDR = 0x0020
00065 } pjstun_attr_type;
00066
00067
00068
00069
00070
00071 typedef struct pjstun_msg_hdr
00072 {
00073 pj_uint16_t type;
00074 pj_uint16_t length;
00075 pj_uint32_t tsx[4];
00076 } pjstun_msg_hdr;
00077
00078
00079
00080
00081
00082 typedef struct pjstun_attr_hdr
00083 {
00084 pj_uint16_t type;
00085 pj_uint16_t length;
00086 } pjstun_attr_hdr;
00087
00088
00089
00090
00091
00092 typedef struct pjstun_mapped_addr_attr
00093 {
00094 pjstun_attr_hdr hdr;
00095 pj_uint8_t ignored;
00096 pj_uint8_t family;
00097 pj_uint16_t port;
00098 pj_uint32_t addr;
00099 } pjstun_mapped_addr_attr;
00100
00101 typedef pjstun_mapped_addr_attr pjstun_response_addr_attr;
00102 typedef pjstun_mapped_addr_attr pjstun_changed_addr_attr;
00103 typedef pjstun_mapped_addr_attr pjstun_src_addr_attr;
00104 typedef pjstun_mapped_addr_attr pjstun_reflected_form_attr;
00105
00106 typedef struct pjstun_change_request_attr
00107 {
00108 pjstun_attr_hdr hdr;
00109 pj_uint32_t value;
00110 } pjstun_change_request_attr;
00111
00112 typedef struct pjstun_username_attr
00113 {
00114 pjstun_attr_hdr hdr;
00115 pj_uint32_t value[1];
00116 } pjstun_username_attr;
00117
00118 typedef pjstun_username_attr pjstun_password_attr;
00119
00120 typedef struct pjstun_error_code_attr
00121 {
00122 pjstun_attr_hdr hdr;
00123 pj_uint16_t ignored;
00124 pj_uint8_t err_class;
00125 pj_uint8_t number;
00126 char reason[4];
00127 } pjstun_error_code_attr;
00128
00129 typedef struct pjstun_msg
00130 {
00131 pjstun_msg_hdr *hdr;
00132 int attr_count;
00133 pjstun_attr_hdr *attr[PJSTUN_MAX_ATTR];
00134 } pjstun_msg;
00135
00136
00137
00138 PJ_DECL(pj_status_t) pjstun_create_bind_req( pj_pool_t *pool,
00139 void **msg, pj_size_t *len,
00140 pj_uint32_t id_hi,
00141 pj_uint32_t id_lo);
00142 PJ_DECL(pj_status_t) pjstun_parse_msg( void *buf, pj_size_t len,
00143 pjstun_msg *msg);
00144 PJ_DECL(void*) pjstun_msg_find_attr( pjstun_msg *msg, pjstun_attr_type t);
00145
00146
00196 PJ_DECL(pj_status_t) pjstun_get_mapped_addr( pj_pool_factory *pf,
00197 int sock_cnt, pj_sock_t sock[],
00198 const pj_str_t *srv1, int port1,
00199 const pj_str_t *srv2, int port2,
00200 pj_sockaddr_in mapped_addr[]);
00201
00202 PJ_END_DECL
00203
00208 #endif
00209
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.
|