stun_internal.h 3.16 KB
Newer Older
Martti Mela's avatar
Martti Mela committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*
 * This file is part of the Sofia-SIP package
 *
 * Copyright (C) 2005 Nokia Corporation.
 *
 * Contact: Pekka Pessi <pekka.pessi@nokia.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

25 26
#ifndef STUN_INTERNAL_H
/** Defined when <stun_internal.h> has been included. */
Martti Mela's avatar
Martti Mela committed
27 28 29
#define STUN_INTERNAL_H
/**@file stun_internal.h STUN client interface
 *
30
 * @author Martti Mela <martti.mela@nokia.com>
Martti Mela's avatar
Martti Mela committed
31 32 33 34 35
 * @author Tat Chan <Tat.Chan@nokia.com>
 * @author Pekka Pessi <Pekka.Pessi@nokia.com>
 * @author Kai Vehmanen <kai.vehmanen@nokia.com>
 */

36 37 38 39
#ifndef SU_DEBUG
#define SU_DEBUG 0
#endif

Martti Mela's avatar
Martti Mela committed
40
#ifndef SU_WAIT_H
41
#include <sofia-sip/su_wait.h>
Martti Mela's avatar
Martti Mela committed
42
#endif
43

Martti Mela's avatar
Martti Mela committed
44
#ifndef SU_TAG_H
45
#include <sofia-sip/su_tag.h>
Martti Mela's avatar
Martti Mela committed
46 47 48
#endif

#ifndef STUN_H
49
#include "sofia-sip/stun.h"
Martti Mela's avatar
Martti Mela committed
50 51
#endif

52 53 54 55 56 57 58 59 60
#if defined(HAVE_OPENSSL)
/* avoid krb5-related build failures */
#define OPENSSL_NO_KRB5
#include <openssl/sha.h>
#include <openssl/hmac.h>
#include <openssl/ssl.h>
#include <openssl/x509.h>
#endif

61
#ifndef STUN_COMMON_H
62
#include "sofia-sip/stun_common.h"
63 64 65 66
#endif



67
#define SU_LOG (stun_log)
68
#include <sofia-sip/su_debug.h>
69

Martti Mela's avatar
Martti Mela committed
70 71
#define enter (void)SU_DEBUG_9(("%s: entering.\n", __func__))

72 73
SOFIA_BEGIN_DECLS

Michael Jerris's avatar
Michael Jerris committed
74
#ifdef DOXYGEN
75
extern char const STUN_DEBUG[]; /* dummy declaration for Doxygen */
Michael Jerris's avatar
Michael Jerris committed
76
#endif
77

78 79
/* XXX -- mela: note that this are 100 times too small */
#if 1
Martti Mela's avatar
Martti Mela committed
80 81 82
#define STUN_LIFETIME_EST 3500      /**< 6 min? */
#define STUN_LIFETIME_MAX 18000     /**< 30 min? */
#define STUN_LIFETIME_CI  50        /**< 5 sec confidence interval */
83
#else
Martti Mela's avatar
Martti Mela committed
84 85 86
#define STUN_LIFETIME_EST 350      /**< 6 min? */
#define STUN_LIFETIME_MAX 1800     /**< 30 min? */
#define STUN_LIFETIME_CI  5        /**< 5 sec confidence interval */
87
#endif
Martti Mela's avatar
Martti Mela committed
88

89 90 91
#define STUN_ERROR(err, what) \
  SU_DEBUG_5(("%s: %s: %s\n", __func__, #what, su_strerror(err))), \
    -1								   \
92

Martti Mela's avatar
Martti Mela committed
93 94 95 96 97
int stun_is_requested(tag_type_t tag, tag_value_t value, ...);

/* internal functions declaration */
int stun_make_sharedsecret_req(stun_msg_t *msg);

98
int stun_send_message(su_socket_t s, su_sockaddr_t *srvr,
99
		      stun_msg_t *msg, stun_buffer_t *pwd);
100

101
int stun_make_binding_req(stun_handle_t *se, stun_request_t *req,
102
			  stun_msg_t *msg,
103
			  tag_type_t, tag_value_t, ...);
Martti Mela's avatar
Martti Mela committed
104 105 106 107 108
int stun_process_response(stun_msg_t *msg);

int stun_process_binding_response(stun_msg_t *msg);
int stun_process_error_response(stun_msg_t *msg);

109
int stun_atoaddr(su_home_t *home, int ai_family, su_addrinfo_t *info, char const *in);
Martti Mela's avatar
Martti Mela committed
110 111
int stun_add_response_address(stun_msg_t *req, struct sockaddr_in *mapped_addr);

112 113
SOFIA_END_DECLS

Martti Mela's avatar
Martti Mela committed
114
#endif /* !defined(STUN_INTERNAL_H) */