Commit c07afc9a authored by Youness Alaoui's avatar Youness Alaoui

(WIP) Huge refactoring of functions... first step towards the agent

parent 90bbcfaa
/*
* This file is part of the Nice GLib ICE library.
*
* (C) 2008 Collabora Ltd.
* (C) 2008 Nokia Corporation. All rights reserved.
* Contact: Youness Alaoui
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Nice GLib ICE library.
*
* The Initial Developers of the Original Code are Collabora Ltd and Nokia
* Corporation. All Rights Reserved.
*
*
* Alternatively, the contents of this file may be used under the terms of the
* the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
* case the provisions of LGPL are applicable instead of those above. If you
* wish to allow use of your version of this file only under the terms of the
* LGPL and not to allow others to use your version of this file under the
* MPL, indicate your decision by deleting the provisions above and replace
* them with the notice and other provisions required by the LGPL. If you do
* not delete the provisions above, a recipient may use your version of this
* file under either the MPL or the LGPL.
*/
#ifndef _STUN_CONSTANTS_H
#define _STUN_CONSTANTS_H
#define STUN_MESSAGE_TYPE_POS 0
#define STUN_MESSAGE_TYPE_LEN 2
#define STUN_MESSAGE_LENGTH_POS \
(STUN_MESSAGE_TYPE_POS + STUN_MESSAGE_TYPE_LEN)
#define STUN_MESSAGE_LENGTH_LEN 2
#define STUN_MESSAGE_TRANS_ID_POS \
(STUN_MESSAGE_LENGTH_POS + STUN_MESSAGE_LENGTH_LEN)
#define STUN_MESSAGE_TRANS_ID_LEN 16
#define STUN_MESSAGE_ATTRIBUTES_POS \
(STUN_MESSAGE_TRANS_ID_POS + STUN_MESSAGE_TRANS_ID_LEN)
#define STUN_MESSAGE_HEADER_LENGTH STUN_MESSAGE_ATTRIBUTES_POS
#define STUN_ATTRIBUTE_TYPE_POS 0
#define STUN_ATTRIBUTE_TYPE_LEN 2
#define STUN_ATTRIBUTE_LENGTH_POS \
(STUN_ATTRIBUTE_TYPE_POS + STUN_ATTRIBUTE_TYPE_LEN)
#define STUN_ATTRIBUTE_LENGTH_LEN 2
#define STUN_ATTRIBUTE_VALUE_POS \
(STUN_ATTRIBUTE_LENGTH_POS + STUN_ATTRIBUTE_LENGTH_LEN)
#define STUN_ATTRIBUTE_HEADER_LENGTH STUN_ATTRIBUTE_VALUE_POS
#define STUN_MAX_MESSAGE_SIZE_IPV4 576
#define STUN_MAX_MESSAGE_SIZE_IPV6 1280
#define STUN_MAX_MESSAGE_SIZE MAX_STUN_SIZE_IPV4
#define STUN_ID_LEN 16
#define STUN_AGENT_MAX_SAVED_IDS 20
#define STUN_COOKIE 0x2112A442
#ifndef TRUE
#define TRUE (1 == 1)
#endif
#ifndef FALSE
#define FALSE (0 == 1)
#endif
#endif /* _STUN_CONSTANTS_H */
......@@ -46,6 +46,7 @@
#include <netinet/in.h>
#include <pthread.h>
#include "stun-msg.h"
#include "stunhmac.h"
#include <string.h>
#include <assert.h>
......
/*
* This file is part of the Nice GLib ICE library.
*
* (C) 2008 Collabora Ltd.
* (C) 2008 Nokia Corporation. All rights reserved.
* Contact: Youness Alaoui
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Nice GLib ICE library.
*
* The Initial Developers of the Original Code are Collabora Ltd and Nokia
* Corporation. All Rights Reserved.
*
*
* Alternatively, the contents of this file may be used under the terms of the
* the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
* case the provisions of LGPL are applicable instead of those above. If you
* wish to allow use of your version of this file only under the terms of the
* LGPL and not to allow others to use your version of this file under the
* MPL, indicate your decision by deleting the provisions above and replace
* them with the notice and other provisions required by the LGPL. If you do
* not delete the provisions above, a recipient may use your version of this
* file under either the MPL or the LGPL.
*/
#ifndef _STUN_HMAC_H
#define _STUN_HMAC_H
/**
* Computes the MESSAGE-INTEGRITY hash of a STUN message.
* @param msg pointer to the STUN message
* @param len size of the message from header (inclusive) and up to
* MESSAGE-INTEGRITY attribute (inclusive)
* @param sha output buffer for SHA1 hash (20 bytes)
* @param key HMAC key
* @param keylen HMAC key bytes length
*
* @return fingerprint value in <b>host</b> byte order.
*/
void stun_sha1 (const uint8_t *msg, size_t len,
uint8_t *sha, const void *key, size_t keylen);
/**
* SIP H(A1) computation
*/
void stun_hash_creds (const char *realm, const char *login, const char *pw,
unsigned char md5[16]);
/**
* Generates a pseudo-random secure STUN transaction ID.
*/
void stun_make_transid (stun_transid_t id);
/* _STUN_HMAC_H */
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment