1
/* $Id: stun.c 3553 2011-05-05 06:14:19Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
static int decode_test(void)
23
/* Invalid message type */
27
/* Long, random message */
29
/* Message length in header is shorter */
31
/* Message length in header is longer */
35
/* Attribute length is not valid */
37
/* Unknown mandatory attribute type should generate error */
39
/* Unknown but non-mandatory should be okay */
41
/* String/binary attribute length is larger than the message */
43
/* Valid message with MESSAGE-INTEGRITY */
45
/* Valid message with FINGERPRINT */
47
/* Valid message with MESSAGE-INTEGRITY and FINGERPRINT */
49
/* Another attribute not FINGERPRINT exists after MESSAGE-INTEGRITY */
51
/* Another attribute exists after FINGERPRINT */
56
static int decode_verify(void)
58
/* Decode all attribute types */
62
static int auth_test(void)
64
/* REALM and USERNAME is present, but MESSAGE-INTEGRITY is not present.
65
* For short term, must with reply 401 without REALM.
66
* For long term, must reply with 401 with REALM.
69
/* USERNAME is not present, server must respond with 432 (Missing
73
/* If long term credential is wanted and REALM is not present, server
74
* must respond with 434 (Missing Realm)
77
/* If REALM doesn't match, server must respond with 434 (Missing Realm)
78
* too, containing REALM and NONCE attribute.
81
/* When long term authentication is wanted and NONCE is NOT present,
82
* server must respond with 435 (Missing Nonce), containing REALM and
86
/* Simulate 438 (Stale Nonce) */
88
/* Simulate 436 (Unknown Username) */
90
/* When server wants to use short term credential, but request has
91
* REALM, reject with .... ???
96
/* Valid static short term, without NONCE */
98
/* Valid static short term, WITH NONCE */
100
/* Valid static long term (with NONCE */
102
/* Valid dynamic short term (without NONCE) */
104
/* Valid dynamic short term (with NONCE) */
106
/* Valid dynamic long term (with NONCE) */