stun_internal.h 3.07 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 25 26 27 28 29 30 31 32 33
/*
 * 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
 *
 */

#ifndef STUN_INTERNAL_H /** Defined when stun_internal.h has been included. */
#define STUN_INTERNAL_H
/**@file stun_internal.h STUN client interface
 *
 * @author Tat Chan <Tat.Chan@nokia.com>
 * @author Pekka Pessi <Pekka.Pessi@nokia.com>
 * @author Kai Vehmanen <kai.vehmanen@nokia.com>
 */

34 35 36 37
#ifndef SU_DEBUG
#define SU_DEBUG 0
#endif

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

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

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

50
#ifndef STUN_COMMON_H
51
#include "sofia-sip/stun_common.h"
52 53 54 55
#endif



56
#define SU_LOG (stun_log)
57
#include <sofia-sip/su_debug.h>
58

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

61 62
SOFIA_BEGIN_DECLS

63 64
extern char const STUN_DEBUG[]; /* dummy declaration for Doxygen */

65 66
/* XXX -- mela: note that this are 100 times too small */
#if 1
Martti Mela's avatar
Martti Mela committed
67 68 69
#define STUN_LIFETIME_EST 3500      /**< 6 min? */
#define STUN_LIFETIME_MAX 18000     /**< 30 min? */
#define STUN_LIFETIME_CI  50        /**< 5 sec confidence interval */
70
#else
Martti Mela's avatar
Martti Mela committed
71 72 73
#define STUN_LIFETIME_EST 350      /**< 6 min? */
#define STUN_LIFETIME_MAX 1800     /**< 30 min? */
#define STUN_LIFETIME_CI  5        /**< 5 sec confidence interval */
74
#endif
Martti Mela's avatar
Martti Mela committed
75

76 77 78 79 80 81
#define STUN_ERROR(errno, what) \
        { int err = errno; \
        SU_DEBUG_5(("%s: %s: %s\n", __func__, #what, su_strerror(err))); \
        }


Martti Mela's avatar
Martti Mela committed
82 83 84
int stun_is_requested(tag_type_t tag, tag_value_t value, ...);

/** other functions */
Martti Mela's avatar
Martti Mela committed
85
int stun_set_uname_pwd(stun_handle_t *se, const char *uname, int len_uname, 
Martti Mela's avatar
Martti Mela committed
86 87 88 89 90
		       const char *pwd, int len_pwd);

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

91
int stun_send_message(su_socket_t s, su_sockaddr_t *srvr,
92
		      stun_msg_t *msg, stun_buffer_t *pwd);
93

94
int stun_make_binding_req(stun_handle_t *se, stun_request_t *req,
95 96
			  stun_msg_t *msg, 
			  tag_type_t, tag_value_t, ...);
Martti Mela's avatar
Martti Mela committed
97 98 99 100 101
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);

102
int stun_atoaddr(int ai_family, su_addrinfo_t *info, /* su_sockaddr_t *addr, */ char const *in);
Martti Mela's avatar
Martti Mela committed
103 104
int stun_add_response_address(stun_msg_t *req, struct sockaddr_in *mapped_addr);

105 106
SOFIA_END_DECLS

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