blob: d6a9cac7327b0597e455b558bdc2e999039b625d [file] [log] [blame]
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18#include <string.h>
19#ifdef _WIN32
20#define strcasecmp _stricmp
21#endif
Adam Tkacb6eb3992010-04-23 14:05:00 +000022#include <rfb/Security.h>
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000023#include <rfb/util.h>
24
Adam Tkac94d88c12010-04-23 13:59:52 +000025rdr::U8 rfb::secTypeNum(const char* name)
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000026{
27 if (strcasecmp(name, "None") == 0) return secTypeNone;
28 if (strcasecmp(name, "VncAuth") == 0) return secTypeVncAuth;
29 if (strcasecmp(name, "Tight") == 0) return secTypeTight;
30 if (strcasecmp(name, "RA2") == 0) return secTypeRA2;
31 if (strcasecmp(name, "RA2ne") == 0) return secTypeRA2ne;
32 if (strcasecmp(name, "SSPI") == 0) return secTypeSSPI;
33 if (strcasecmp(name, "SSPIne") == 0) return secTypeSSPIne;
34 return secTypeInvalid;
35}
36
Adam Tkac94d88c12010-04-23 13:59:52 +000037const char* rfb::secTypeName(rdr::U8 num)
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000038{
39 switch (num) {
40 case secTypeNone: return "None";
41 case secTypeVncAuth: return "VncAuth";
42 case secTypeTight: return "Tight";
43 case secTypeRA2: return "RA2";
44 case secTypeRA2ne: return "RA2ne";
45 case secTypeSSPI: return "SSPI";
46 case secTypeSSPIne: return "SSPIne";
47 default: return "[unknown secType]";
48 }
49}
50
Adam Tkac94d88c12010-04-23 13:59:52 +000051std::list<rdr::U8> rfb::parseSecTypes(const char* types_)
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000052{
Adam Tkac94d88c12010-04-23 13:59:52 +000053 std::list<rdr::U8> result;
Adam Tkacd36b6262009-09-04 10:57:20 +000054 CharArray types(strDup(types_)), type;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000055 while (types.buf) {
56 strSplit(types.buf, ',', &type.buf, &types.buf);
Adam Tkac94d88c12010-04-23 13:59:52 +000057 rdr::U8 typeNum = secTypeNum(type.buf);
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000058 if (typeNum != secTypeInvalid)
59 result.push_back(typeNum);
60 }
61 return result;
62}