This commit is contained in:
romkazvo
2023-08-07 19:29:24 +08:00
commit 34d6c5d489
4832 changed files with 1389451 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
#ifndef __CONFIGFILEPARSER_H__
#define __CONFIGFILEPARSER_H__
#include "define.h"
#include "GSTypes.h"
//////////////////////////////////////////////////
// Referrer string used in the config file parsing
// SERVER SECTION NAME
#define SERVER_SECTION_NAME "Servers"
// ROUTER KEYNAME
#define ROUTER_ADDRESS_REFERRER "RouterIP%d"
#define ROUTER_PORT_REFERRER "RouterPort%d"
// CDKEY SERVER KEYNAME
#define CDKEY_ADDRESS_REFERRER "CDKeyServerIP%d"
#define CDKEY_PORT_REFERRER "CDKeyServerPort%d"
// PROXY SERVER KEYNAME
#define PROXY_ADDRESS_REFERRER "ProxyIP%d"
#define PROXY_PORT_REFERRER "ProxyPort%d"
// NAT SERVER KEYNAME
#define NAT_ADDRESS_REFERRER "NATServerIP%d"
#define NAT_PORT_REFERRER "NATServerPort%d"
// CHAT SERVER KEYNAME
#define CHAT_ADDRESS_REFERRER "IRCIP%d"
#define CHAT_PORT_REFERRER "IRCPort%d"
// SERVER TYPES
enum SERVER_TYPE {
SRV_ROUTER,
SRV_CDKEY,
SRV_PROXY,
SRV_NAT,
SRV_CHAT
};
extern "C" {
GSbool __stdcall InitializeFileParser(const GSchar *szConfigFilePath);
GSbool __stdcall InitializeStreamParser(GSchar **pszStream);
GSbool __stdcall GetServerAddress(SERVER_TYPE eServerType,GSuint uiIndex, GSchar *szAddress, GSushort *usPort);
GSbool __stdcall GetConfigStringValue(GSchar *szSectionName, GSchar *szKeyName, GSchar *szDefaultValue, GSchar *szBuffer, GSint iSize);
GSint __stdcall GetConfigNumericValue(GSchar *szSectionName, GSchar *szKeyName, GSint iDefaultValue);
GSvoid __stdcall UninitializeParser();
} // extern "C"
#endif //__CONFIGFILEPARSER_H__

View File

@@ -0,0 +1,124 @@
//****************************************************************************
//* Author: Guillaume Plante gsdevelopers@ubisoft.com
//* Date: 2002-06-10 10:11:16
/*! \file GSCryptoDefines.h
* \brief Cryptographic sdk variable definitions
*
* This file defines all the global values and structures used by the
* gs-sdk-crypto.
*/
//****************************************************************************
#ifndef __GSCRYPTODEFINES_H__
#define __GSCRYPTODEFINES_H__
/*!
\brief Cryptographic hash algorithms enumeration
This structure contains the valid hash algorithms that can be used with this sdk.
E_MD5 represent the MD5 algorithm and E_SHA1 represent the Secure Hash Algorithm .
*/
enum GSCRYPTO_HASH_ALGO {
E_MD5,
E_SHA1
};
#define MD5_DIGESTSIZE 16 //!< One-way hash digest size (MD5)
#define SHA1_DIGESTSIZE 20 //!< One-way hash digest size (SHA1)
#define MD5_HEXASIZE (2 * MD5_DIGESTSIZE) //!< One-way hash hexadecimal output size (MD5)
#define SHA1_HEXASIZE (2 * SHA1_DIGESTSIZE) //!< One-way hash hexadecimal output size (SHA1)
/*!
\brief Symmetric cryptographic algorithms enumeration
This structure contains the valid cipher algorithms that can be used with this sdk.
E_BLOWFISH represent the blowfish algorithm and E_GSXOR represent the
bitshift algorithm use by the the ubi.com gs-client.
*/
enum GSCRYPTO_CIPHER_ALGO {
E_BLOWFISH,
E_GSXOR
};
/*!
\brief Asymmetric cryptographic algorithms enumeration
This structure contains the valid public/private key algorithms that can be used with this sdk.
E_RSA represent the RSA algorithm.
*/
enum GSCRYPTO_PKC_ALGO {
E_RSA
};
/*!
\brief Pseudo-Random Number Generator algorithms enumeration
This structure contains the valid PRNG algorithms that can be used with this sdk.
E_MGF1 represent the Mask Generation Function algorithm.
*/
enum GSCRYPTO_PRNG_ALGO {
E_MGF1
};
#define MGF1_HASHMULTIPLES 500 //!< Multiples of <HASH>_DIGESTSIZE for byte string size
///// BEGIN RSA CHANGES /////
/* RSA key lengths.
*/
#define MIN_RSA_MODULUS_BITS 508 //!< Minimum length in bits of the modulus used in the RSA algorithm
#define MAX_RSA_MODULUS_BITS 1024 //!< Maximum length in bits of the modulus used in the RSA algorithm
#define MAX_RSA_MODULUS_LEN ((MAX_RSA_MODULUS_BITS + 7) / 8) //!< Maximum length in bytes of the modulus used in the RSA algorithm
#define MAX_RSA_PRIME_BITS ((MAX_RSA_MODULUS_BITS + 1) / 2) //!< Maximum length in bits of a prime
#define MAX_RSA_PRIME_LEN ((MAX_RSA_PRIME_BITS + 7) / 8)
/* Maximum lengths of encoded and encrypted content, as a function of
content length len. Also, inverse functions.
*/
#define ENCODED_CONTENT_LEN(len) (4*(len)/3 + 3)
#define ENCRYPTED_CONTENT_LEN(len) ENCODED_CONTENT_LEN ((len)+8)
#define DECODED_CONTENT_LEN(len) (3*(len)/4 + 1)
#define DECRYPTED_CONTENT_LEN(len) DECODED_CONTENT_LEN ((len)-1)
/* Random structure.
*/
typedef struct {
GSuint bytesNeeded;
GSubyte state[16];
GSuint outputAvailable;
GSubyte output[16];
} RANDOM_STRUCT;
/* RSA public and private key.
*/
typedef struct {
GSuint bits; /* length in bits of modulus */
GSubyte modulus[MAX_RSA_MODULUS_LEN]; /* modulus */
GSubyte exponent[MAX_RSA_MODULUS_LEN]; /* public exponent */
} RSA_PUBLIC_KEY;
typedef struct {
GSuint bits; /* length in bits of modulus */
GSubyte modulus[MAX_RSA_MODULUS_LEN]; /* modulus */
GSubyte publicExponent[MAX_RSA_MODULUS_LEN]; /* public exponent */
GSubyte exponent[MAX_RSA_MODULUS_LEN]; /* private exponent */
GSubyte prime[2][MAX_RSA_PRIME_LEN]; /* prime factors */
GSubyte primeExponent[2][MAX_RSA_PRIME_LEN]; /* exponents for CRT */
GSubyte coefficient[MAX_RSA_PRIME_LEN]; /* CRT coefficient */
} RSA_PRIVATE_KEY;
/* RSA prototype key.
*/
typedef struct {
GSuint bits; /* length in bits of modulus */
GSint useFormat4; /* public exponent (1 = F4, 0 = 3) */
} RSA_PROTO_KEY;
///// END RSA CHANGES /////
#endif // __GSCRYPTODEFINES_H__

View File

@@ -0,0 +1,629 @@
//****************************************************************************
//* Author: Guillaume Plante, Philippe Lalande gsdevelopers@ubisoft.com
//* Date: 2002-05-07 16:18:32
/*! \file GSCryptoInterface.h
* \brief Interface ubi.com's cryptographic library.
*
* This interface provides one-way hash,
* synchronous block cipher and pseudo-random number generator
* functionality to be use along with the ubi.com crypto interface.
*/
//****************************************************************************
/*!
\mainpage gs-sdk-crypto
\section intro Introduction
ubi.com's cryptographic interface.
\section description Description
The cryptographic interface contains one-way hash,
synchronous block cipher and pseudo-random number generator
functionality to be use along with the ubi.com interface.
*/
#ifndef __GSCRYPTOINTERFACE_H__
#define __GSCRYPTOINTERFACE_H__
#include "GSTypes.h"
#include "GSCryptoDefines.h"
extern "C" {
//============================================================================
// Function InitializeCrypto
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-05-07 15:49:51
/*!
\brief Initialize library
\par Description:
Initialize library
\return Status of the function call
\retval GS_TRUE the operation suceeded.
\retval GS_FALSE the operation failed.
*/
//============================================================================
// plalande (01/2004)
// Not necessary. Does no do anything
//GSbool __stdcall InitializeCrypto();
//============================================================================
// Function UninitializeCrypto
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-05-07 15:49:52
/*!
\brief Uninitialize library
\par Description:
Uninitialize library
\return void
*/
//============================================================================
// plalande (01/2004)
// Very dangerous to use these functions since they affect all of the
// cryptographic handles existing in the library
//GSvoid __stdcall UninitializeCrypto();
/*! @defgroup groupcrypto1 One-way hash functions
\brief One-way hash functions
These functions are used to get cryptographic checksums
from supplied input buffers.
@{
*/
//============================================================================
// Function GenerateRawHash
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-05-07 15:49:53
/*!
\brief Generate binary hash
\par Description:
This function generate a hash in binary form
from a supplied input value. The output buffer must be at
least (SHA1_DIGESTSIZE) byte long for the SHA1 (E_SHA1) algorithm
and at leat (MD5_DIGESTSIZE) byte long for the MD5 (E_MD5) algorithm.
The number of iteration can be modified to change the hashed
output value, it represent the number of passed the input value
is put through the hash algorithm.
\return Status of the function call
\retval GS_TRUE the operation suceeded.
\retval GS_FALSE the operation failed.
\param IN eAlgo The type of hash algorithm to use.
\param IN pucInBuffer The input buffer to be hashed.
\param IN uiBufferSize The lenght of the input buffer.
\param OUT pucOutBuffer Binary output of the generated hashed value.
\param IN uiIterations Nuber of time to hash the input value.
*/
//============================================================================
GSbool __stdcall GenerateRawHash(GSCRYPTO_HASH_ALGO eAlgo,
const GSubyte* pucInBuffer,
GSuint uiBufferSize,
GSubyte* pucOutBuffer,
GSuint uiIterations = 1);
//============================================================================
// Function GenerateHexaHash
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-05-07 15:49:53
/*!
\brief Generate hexadecimal hash
\par Description:
This function generate a hash in hexadecimal form
from a supplied input value. The output buffer must be at
least (SHA1_HEXASIZE) byte long for the SHA1 (E_SHA1) algorithm
and at leat (MD5_HEXASIZE) byte long for the MD5 (E_MD5) algorithm.
It is important to note that this function does not put a \0 at the end
of the output buffer, so the programmer will have to terminate the output
string once he gets it.
The number of iteration can be modified to change the hashed
output value, it represent the number of passed the input value
is put through the hash algorithm.
\return Status of the function call
\retval GS_TRUE the operation suceeded.
\retval GS_FALSE the operation failed.
\param IN eAlgo The type of hash algorithm to use.
\param IN pucInBuffer The input buffer to be hashed.
\param IN uiBufferSize The lenght of the input buffer.
\param OUT pszOutBuffer Hexadecimal output of the generated hashed value.
\param IN uiIterations = 1 Nuber of time to hash the input value.
*/
//============================================================================
GSbool __stdcall GenerateHexaHash(GSCRYPTO_HASH_ALGO eAlgo,
const GSubyte* pucInBuffer,
GSuint uiBufferSize,
GSchar* pszOutBuffer,
GSuint uiIterations = 1);
//============================================================================
// Function InitializeHash
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-05-07 16:27:15
/*!
\brief Initialize the hash context
\par Description:
This function will initialize the hash context. This must be called before
any call to the UpdateHash() function. This function will return GS_FALSE
if the hash context is not yet terminated.
\return Status of the function call
\retval Identification of the hash algorithm created
\retval NULL if the operation failed
\param IN eAlgo The type of hash algorithm to use.
*/
//============================================================================
GShandle __stdcall InitializeHash(GSCRYPTO_HASH_ALGO eAlgo);
//============================================================================
// Function UpdateHash
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-05-07 16:37:38
/*!
\brief Update the internal hash context
\par Description:
Update the internal hash context with the input value,
the number of iteration can be modified to change the hashed
output value, it represent the number of passed the input value
is put through the hash algorithm.
This function will return GS_FALSE if the hash context is already terminated.
\return Status of the function call
\retval GS_TRUE the operation suceeded.
\retval GS_FALSE the operation failed.
\param IN hHash Handle to the hash to be updated
\param IN pucInBuffer The input buffer to be hashed.
\param IN uiBufferSize The lenght of the input buffer.
\param IN uiIterations Nuber of time to hash the input value.
*/
//============================================================================
GSbool __stdcall UpdateHash(GShandle hHash, const GSubyte* pucInBuffer, GSuint uiBufferSize,GSuint uiIterations = 1);
//============================================================================
// Function TerminateRawHash
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-05-07 16:46:15
/*!
\brief Terminate the hash context, output binary hashed result
\par Description:
This function terminate the hash context and output the hashed
result in binary form. The output buffer must be at
least (SHA1_DIGESTSIZE) byte long for the SHA1 (E_SHA1) algorithm
and at leat (MD5_DIGESTSIZE) byte long for the MD5 (E_MD5) algorithm.
This function will return GS_FALSE if the hash context is already terminated.
\return Status of the function call
\retval GS_TRUE the operation suceeded.
\retval GS_FALSE the operation failed.
\param IN hHash Handle to the hash to be terminated
\param OUT pucOutBuffer Binary output of the generated hashed value.
*/
//============================================================================
GSbool __stdcall TerminateRawHash(GShandle hHash, GSubyte* pucOutBuffer);
//============================================================================
// Function TerminateRawHash
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-05-07 16:46:15
/*!
\brief Terminate the hash context, output hexadecimal hashed result
\par Description:
This function terminate the hash context and output the hashed
result in hexadecimal form. The output buffer must be at
least (SHA1_HEXASIZE) byte long for the SHA1 (E_SHA1) algorithm
and at leat (MD5_HEXASIZE) byte long for the MD5 (E_MD5) algorithm.
It is important to note that this function does not put a \0 at the end
of the output buffer, so the programmer will have to terminate the output
string once he gets it.
This function will return GS_FALSE if the hash context is already terminated.
\return Status of the function call
\retval GS_TRUE the operation suceeded.
\retval GS_FALSE the operation failed.
\param IN hHash Handle to the hash to be terminated
\param OUT pszOutBuffer Hexadecimal output of the generated hashed value.
*/
//============================================================================
GSbool __stdcall TerminateHexaHash(GShandle hHash, GSchar* pszOutBuffer);
//============================================================================
// Function ResetHash
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-06-03 17:05:49
/*!
\brief Reset the hash module
\par Description:
Reset the hash module
\return Status of the function call
\retval GS_TRUE the operation suceeded.
\retval GS_FALSE the operation failed.
\param hHash Handle on the hash module
*/
//============================================================================
GSbool __stdcall ResetHash(GShandle hHash);
//============================================================================
// Function UninitializeHash
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-06-03 17:05:49
/*!
\brief Uninitiaze the hash module
\par Description:
Uninitiaze the hash module
\return void
\param hHash Handle on the hash module
*/
//============================================================================
GSvoid __stdcall UninitializeHash(GShandle hHash);
/*! @} end of groupcrypto1 */
/*! @defgroup groupcrypto2 Pseudo random number generator functions
\brief PRNG functions
These functions are used to get random pseudo-generated numbers
@{
*/
//============================================================================
// Function StartNumberGenerator
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-06-03 16:35:30
/*!
\brief Initialize the pseudo-random number generator
\par Description:
Initialize the pseudo-random number generator
\return Status of the function call
\retval Identification of the PRNG algorithm created
\retval NULL if the operation failed
\param eAlgo The algo to use for the pseudo-random number generator
\param eHash The algo to use for the hash algorithm in the prng
\param pucSeed The seed value
\param uiSeedSize The size of the seed
*/
//============================================================================
GShandle __stdcall StartNumberGenerator(GSCRYPTO_PRNG_ALGO eAlgo,
GSCRYPTO_HASH_ALGO eHash,
const GSubyte *pucSeed,
GSuint uiSeedSize);
//============================================================================
// Function StopNumberGenerator
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-06-03 17:03:37
/*!
\brief Uninitiaze the pseudo-random number generator
\par Description:
Uninitiaze the pseudo-random number generator
\return void
\param hPRNG Handle on the PRNG object
*/
//============================================================================
GSvoid __stdcall StopNumberGenerator(GShandle hPRNG);
//============================================================================
// Function GenerateBit
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-06-03 16:35:36
/*!
\brief Generate random bit
\par Description:
This function is used to generate a random bit
\return Generated bit
\param hPRNG Handle on the PRNG object
*/
//============================================================================
GSubyte __stdcall GenerateBit(GShandle hPRNG);
//============================================================================
// Function GenerateBit
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-06-03 16:35:36
/*!
\brief Generate random byte
\par Description:
This function is used to generate a random byte
\return Generated byte
\param hPRNG Handle on the PRNG object
*/
//============================================================================
GSubyte __stdcall GenerateByte(GShandle hPRNG);
//============================================================================
// Function GenerateNumber
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-06-03 16:35:36
/*!
\brief Generate random number
\par Description:
This function is used to generate a random number
\return Generated number
\param hPRNG Handle on the PRNG object
\param ulMax Highest possible number that can be generated
\param ulMin Lowest possible number that can be generated
*/
//============================================================================
GSulong __stdcall GenerateNumber(GShandle hPRNG, GSulong ulMax = (GSulong)-1,GSulong ulMin = 0);
//============================================================================
// Function GenerateBlock
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-06-03 16:35:37
/*!
\brief Generate random array of bytes
\par Description:
This function is used to generate a random array of bytes
\return void
\param hPRNG Handle on the PRNG object
\param pucBlock Pointer to a block of byte to fill
\param uiBlockSize Block size
*/
//============================================================================
GSvoid __stdcall GenerateBlock(GShandle hPRNG, GSubyte *pucBlock,GSuint uiBlockSize);
/*! @} end of groupcrypto2 */
/*! @defgroup groupcrypto3 Data encryption functions
\brief Data encryption functions
These functions are used to the encrypt data using symmetric encryption algorithms.
@{
*/
//============================================================================
// Function InitializeCipher
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-06-06 09:25:38
/*!
\brief Initialize the encryption module
\par Description:
Initialize the encryption module
\return Status of the function call
\retval Identification of the cipher algorithm created
\retval 0 if the operation failed
\param eAlgo Encryption algorithm to be used
\param ucKey The key to be use for encryption and decryption
\param uiKeyLength Lentgh of the key
*/
//============================================================================
GShandle __stdcall InitializeCipher(GSCRYPTO_CIPHER_ALGO eAlgo,
const GSubyte* ucKey, GSuint uiKeyLength);
//============================================================================
// Function UnitializeCipher
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-06-06 09:30:12
/*!
\brief Uninitialize the encryption module
\par Description:
Uninitialize the encryption module
\return void
\param hCipher handle on the cipher algorithm
*/
//============================================================================
GSvoid __stdcall UninitializeCipher(GShandle hCipher);
//============================================================================
// Function ResetKey
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-06-06 09:31:48
/*!
\brief Reset the encryption key
\par Description:
Reset the encryption key without having to reinitialize the module
\return Status of the function call
\retval GS_TRUE the operation suceeded.
\retval GS_FALSE the operation failed.
\param hCipher Handle on the cipher algorithm
\param ucKey The key to be use for encryption and decryption
\param uiKeyLength Lentgh of the key
*/
//============================================================================
GSbool __stdcall ResetKey(GShandle hCipher,const GSubyte* ucKey, GSuint uiKeyLength);
//============================================================================
// Function Encrypt
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-06-06 09:34:15
/*!
\brief Encrypt a data buffer
\par Description:
This function encrypt a data buffer, and gives back the result in
the output buffer, if you pass NULL as the output buffer, the function
will return GS_FALSE and will give the predicted output buffer length.
\return Status of the function call
\retval GS_TRUE the operation suceeded.
\retval GS_FALSE the operation failed.
\param hCipher Handle on the cipher algorithm
\param pInputBuffer Input buffer to be encrypted
\param uiInBufferLength Input buffer length in bytes
\param pOutputBuffer Output buffer (encrypted data)
\param puiOutBufferLength Output buffer length in bytes
*/
//============================================================================
GSbool __stdcall Encrypt(GShandle hCipher,const GSvoid* pInputBuffer, GSuint uiInBufferLength,
GSvoid* pOutputBuffer, GSuint* puiOutBufferLength);
//============================================================================
// Function Decrypt
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-06-06 09:51:10
/*!
\brief Decrypt a data buffer
\par Description:
This function decrypt a data buffer, and gives back the result in
the output buffer, if you pass NULL as the output buffer, the function
will return GS_FALSE and will give the predicted output buffer length.
\return Status of the function call
\retval GS_TRUE the operation suceeded.
\retval GS_FALSE the operation failed.
\param hCipher Handle on the cipher algorithm
\param pInputBuffer Input buffer to be decrypted
\param uiInBufferLength Input buffer length in bytes
\param pOutputBuffer Output buffer (decrypted data)
\param puiOutBufferLength Output buffer length in bytes
*/
//============================================================================
GSbool __stdcall Decrypt(GShandle hCipher,const GSvoid* pInputBuffer, GSuint uiInBufferLength,
GSvoid* pOutputBuffer, GSuint* puiOutBufferLength);
/*! @} end of groupcrypto3 */
/*! @defgroup groupcrypto4 Public key cryptography
\brief Asymetric cryptosystem interface
These functions are used to the encrypt data using public key encryption algorithms.
@{
*/
//============================================================================
// Function InitializePKC
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-05-07 16:27:15
/*!
\brief Initialize the hash context
\par Description:
This function will initialize the hash context. This must be called before
any call to the UpdateHash() function. This function will return GS_FALSE
if the hash context is not yet terminated.
\return Status of the function call
\retval Identification of the hash algorithm created
\retval NULL if the operation failed
\param IN eAlgo The type of hash algorithm to use.
*/
//============================================================================
GShandle __stdcall InitializePKC(GSCRYPTO_PKC_ALGO eAlgo);
//============================================================================
// Function UninitializeHash
// Author: Guillaume Plante gplante@ubisoft.com
// Date: 2002-06-03 17:05:49
/*!
\brief Uninitiaze the hash module
\par Description:
Uninitiaze the hash module
\return void
\param hHash Handle on the hash module
*/
//============================================================================
GSvoid __stdcall UninitializePKC(GShandle hPKC);
GSbool __stdcall RandomInit(GShandle hPKC,RANDOM_STRUCT *pRandomData);
GSbool __stdcall RandomUpdate (GShandle hPKC,RANDOM_STRUCT *pRandomData, GSubyte *block, GSuint blockLen);
GSvoid __stdcall RandomFinal(GShandle hPKC,RANDOM_STRUCT *pRandomData);
GSint __stdcall GetRandomBytesNeeded(GShandle hPKC,GSuint *bytesNeeded,RANDOM_STRUCT * pRandomData);
GSbool __stdcall GenerateKeyPair(GShandle hPKC,RSA_PUBLIC_KEY *pPublicKey, RSA_PRIVATE_KEY *pPrivateKey,
RSA_PROTO_KEY *pProtoKey,RANDOM_STRUCT *pRandomData);
GSbool __stdcall PublicEncrypt(GShandle hPKC,GSubyte *pInputBuffer, GSuint uiInputBufferLength,
GSubyte *pOutputBuffer, GSuint *pOutputBufferLength,RSA_PUBLIC_KEY * pPublicKey, RANDOM_STRUCT * pRandomData);
GSbool __stdcall PrivateEncrypt(GShandle hPKC,GSubyte *pInputBuffer, GSuint uiInputBufferLength,
GSubyte *pOutputBuffer, GSuint *pOutputBufferLength,RSA_PRIVATE_KEY *pPrivateKey);
GSbool __stdcall PublicDecrypt(GShandle hPKC,GSubyte *pInputBuffer, GSuint uiInputBufferLength,
GSubyte *pOutputBuffer, GSuint *pOutputBufferLength,RSA_PUBLIC_KEY *pPublicKey);
GSbool __stdcall PrivateDecrypt(GShandle hPKC,GSubyte *pInputBuffer, GSuint uiInputBufferLength,
GSubyte *pOutputBuffer, GSuint *pOutputBufferLength,RSA_PRIVATE_KEY *pPrivateKey);
/*! @} end of groupcrypto4 */
} // extern "C"
#endif // __GSCRYPTOINTERFACE_H__

View File

@@ -0,0 +1,99 @@
#ifndef _GSERRORS_H
#define _GSERRORS_H
#include "GSTypes.h"
/////////////////////////////////////////////////////////////////////////////////////
// GSRESULT TYPE
// It is divided in 3 parts:
// Severity(bit 31): 1 = error, 0 = success
// Facility(bit 16 to 30): identify the system responsible of the error
// ID(bit 0 to 15): unique number that represent an error/warning/success
typedef GSint GSRESULT;
/////////////////////////////////////////////////////////////////////////////////////
// MACRO USED TO CHECK GSRESULT
// Return "TRUE" if the GSRESULT is an error
#define GSFAILED(GSR) ((GSRESULT)(GSR)<(GSint)0)
// Return "TRUE" if the GSRESULT is a success
#define GSSUCCEEDED(GSR) ((GSRESULT)(GSR)>=(GSint)0)
// Return the error or success code of a GSRESULT
#define GSRESULT_CODE(GSR) ((GSint)(GSR&0x8000FFFFL))
/////////////////////////////////////////////////////////////////////////////////////
// SUCCESS CODES
#define GSS_OK ((GSint) 0x00000000)
#define GSS_FALSE ((GSint) 0x00000001)
#define GSS_TIMEOUT ((GSint) 0x00005000)
#define GSS_KEYBUFFERTOOSMALL ((GSint) 0x00006200)
#define GSS_BUFFERTOOSMALL ((GSint) 0x00006201)
#define GSS_TRIGGERDETECTED ((GSint) 0x00006202)
/////////////////////////////////////////////////////////////////////////////////////
// ERROR CODES
#define GSE_ACCESSDENIED ((GSint) 0x80070005)
#define GSE_HANDLE ((GSint) 0x80070006)
#define GSE_OUTOFMEMORY ((GSint) 0x8007000E)
#define GSE_INVALIDARG ((GSint) 0x80070057)
#define GSE_NOTIMPL ((GSint) 0x80004001)
#define GSE_NOINTERFACE ((GSint) 0x80004002)
#define GSE_POINTER ((GSint) 0x80004003)
#define GSE_ABORT ((GSint) 0x80004004)
#define GSE_FAIL ((GSint) 0x80004005)
#define GSE_NOTGSMODULE ((GSint) 0x80004FFF)
#define GSE_UNEXPECTED ((GSint) 0x8000FFFF)
#define GSE_ALREADYINITIALIZED ((GSint) 0x80005000)
#define GSE_NOTINITIALIZED ((GSint) 0x80005001)
#define GSE_CANTFINDAPPLICATION ((GSint) 0x80005002)
#define GSE_CANTLOAD ((GSint) 0x80005003)
#define GSE_TIMEOUT ((GSint) 0x80005004)
#define GSE_BADMODE ((GSint) 0x80006000)
#define GSE_GSISALREADYUSEDBYOTHERGAME ((GSint) 0x80006001)
#define GSE_GAMEALREADYPRELOADED ((GSint) 0x80006100)
#define GSE_STATENOTSUPPORTED ((GSint) 0x80006101)
#define GSE_INVALIDGAMENAME ((GSint) 0x80006102)
#define GSE_NODATACONTAINER ((GSint) 0x80006103)
#define GSE_MESSAGENOTSUPPORTEDINCURRENTSTATE ((GSint) 0x80006104)
#define GSE_INVALIDKEY ((GSint) 0x80006200)
#define GSE_KEYALREADYEXIST ((GSint) 0x80006201)
#define GSE_BUFFERNOTVALID ((GSint) 0x80006202)
#define GSE_INVALIDINDEX ((GSint) 0x80006203)
#define GSE_NOTMASTER ((GSint) 0x80006204)
#define GSE_INVALIDEVENT ((GSint) 0x80006205)
#define GSE_MATCHNOTSTARTEDBYMASTER ((GSint) 0x80006206)
#define GSE_NOREPLY ((GSint) 0x80006207)
#define GSE_GAMENOTINITIATED ((GSint) 0x80006208)
#define GSE_MATCHNOTFINISHED ((GSint) 0x80006209)
#define GSE_MATCHNOTEXIST ((GSint) 0x8000620A)
#define GSE_MATCHSCORESSUBMISSIONALREDYSENT ((GSint) 0x8000620B)
#define GSE_MATCHSCORESSUBMISSIONFAIL ((GSint) 0x8000620C)
#define GSE_DETECTEDNEWVERSION ((GSint) 0x8000620D)
#define GSE_OTHERENDOFPIPECLOSED ((GSint) 0x8000620E)
#define GSE_SOCKETINVALID ((GSint) 0x8000620F)
#define GSE_OPENFILE ((GSint) 0x80006210)
#define GSE_CONNECTERROR ((GSint) 0x80006211)
#define GSE_CURRENTROOMDESTROYED ((GSint) 0x80006212)
#define GSE_SOCKETERROR ((GSint) 0x80006213)
#define GSE_HOSTUNREACHABLE ((GSint) 0x80006214)
#define GSE_ENDOFSTREAM ((GSint) 0x80006215)
#define GSE_ALREADYALLOCATED ((GSint) 0x80006216)
#define GSE_NOTALLOCATED ((GSint) 0x80006217)
#define GSE_INPROGRESS ((GSint) 0x80006218)
#define GSE_DATADOESNTEXIST ((GSint) 0x80006219)
#define GSE_INVALIDUSER ((GSint) 0x8000621A)
#define GSE_INVALIDPWD ((GSint) 0x8000621B)
#define GSE_INVALIDGUID ((GSint) 0x8000621C)
#define GSE_INVALIDPACKAGE ((GSint) 0x8000621D)
#define GSE_INVALIDXML ((GSint) 0x8000621E)
#define GSE_INVALIDCHUNK ((GSint) 0x8000621F)
#define GSE_XCEEDZIP ((GSint) 0x80006220)
#define GSE_DBFAILURE ((GSint) 0x80006221)
#define GSE_OUTOFBOUND ((GSint) 0x80006222)
#define GSE_BADARG ((GSint) 0x80006223)
#endif _GSERRORS_H

View File

@@ -0,0 +1,144 @@
#ifndef __GSTYPES_H__
#define __GSTYPES_H__
#if defined ( GS_LINUX )
#include <stdlib.h>
// calling methods
#define __stdcall
#define __cdecl
// Special types
typedef unsigned char GSbool;
typedef void GSvoid;
typedef size_t GSsize_t;
// Signed types
typedef char GSbyte;
typedef char GSchar;
typedef short GSshort;
typedef int GSint;
typedef long long GSlong;
typedef float GSfloat;
typedef double GSdouble;
// Unsigned types
typedef unsigned char GSubyte;
typedef unsigned char GSuchar;
typedef unsigned short GSushort;
typedef unsigned int GSuint;
typedef unsigned long long GSulong;
#elif defined ( GS_WIN32 )
// Special types
typedef unsigned char GSbool;
typedef void GSvoid;
typedef size_t GSsize_t;
// Signed types
typedef char GSbyte;
typedef char GSchar;
typedef short GSshort;
typedef int GSint;
typedef __int64 GSlong;
typedef float GSfloat;
typedef double GSdouble;
// Unsigned types
typedef unsigned char GSubyte;
typedef unsigned char GSuchar;
typedef unsigned short GSushort;
typedef unsigned int GSuint;
typedef unsigned __int64 GSulong;
#elif defined ( GS_PSX2 )
#include <stdlib.h>
// calling methods
#define __stdcall
#define __cdecl
// Special types
typedef unsigned char GSbool;
typedef void GSvoid;
typedef size_t GSsize_t;
// Signed types
typedef char GSbyte;
typedef char GSchar;
typedef short GSshort;
typedef int GSint;
typedef long GSlong;
typedef float GSfloat;
typedef double GSdouble;
// Unsigned types
typedef unsigned char GSubyte;
typedef unsigned char GSuchar;
typedef unsigned short GSushort;
typedef unsigned int GSuint;
typedef unsigned long GSulong;
#elif defined ( GS_XBOX )
// Special types
typedef unsigned char GSbool;
typedef void GSvoid;
typedef size_t GSsize_t;
// Signed types
typedef char GSbyte;
typedef char GSchar;
typedef short GSshort;
typedef int GSint;
typedef __int64 GSlong;
typedef float GSfloat;
typedef double GSdouble;
// Unsigned types
typedef unsigned char GSubyte;
typedef unsigned char GSuchar;
typedef unsigned short GSushort;
typedef unsigned int GSuint;
typedef unsigned __int64 GSulong;
#elif defined ( GS_WIN64 )
// Special types
typedef unsigned char GSbool;
typedef void GSvoid;
typedef size_t GSsize_t;
// Signed types
typedef char GSbyte;
typedef char GSchar;
typedef short GSshort;
typedef int GSint;
typedef __int64 GSlong;
typedef float GSfloat;
typedef double GSdouble;
// Unsigned types
typedef unsigned char GSubyte;
typedef unsigned char GSuchar;
typedef unsigned short GSushort;
typedef unsigned int GSuint;
typedef unsigned __int64 GSulong;
#endif
// For GSbool
#define GS_TRUE 1
#define GS_FALSE 0
// Special type for instances identification
#ifdef GSvoid
typedef GSvoid* GShandle;
#else
typedef void* GShandle;
#endif
#endif // __GSTYPES_H__

View File

@@ -0,0 +1,264 @@
//****************************************************************************
//* Author: Scott Schmeisser gsdevelopers@ubisoft.com
//* Date: 5/15/01 10:05:17 AM
/*! \file InitSockets.h
* \brief Functions used to initialize the socket library in different
* platforms
* Socket loading/unloading for different platforms.
*/
//****************************************************************************
#ifndef _INITSOCKETS_H
#ifndef DOX_SKIP_THIS
#define _INITSOCKETS_H
#endif // DOX_SKIP_THIS
extern "C" {
#if defined(GS_WIN32) || defined(GS_WIN64)
//============================================================================
// Function InitializeSockets
// Author: Luc Bouchard lbouchard@ubisoft.qc.ca
// Date: 14/09/2001 9:48:06 AM
/*!
\brief (WIN32/XBOX/LINUX) Initialize the socket library
\par Description:
Initialize the socket library with an optional IP address to bind to.
\return The status of the call to the function
\retval GS_TRUE on success
\retval GS_FALSE on failure
\param szIPAddress the IP address to bind to
*/
//============================================================================
GSbool __stdcall InitializeSockets(const GSchar *szIPAddress = NULL);
//============================================================================
// Function InitializeSockets_SetOnConnectTimeout
// Author: Luc Bouchard lbouchard@ubisoft.qc.ca
// Date: 28/08/2002 10:05:51 AM
/*!
\brief (WIN32) Sets the Timeout value when connecting.
\par Description:
Set the amount of time to wait for a connection to establish.
Defaults to 5 seconds;
\return The status of the call to the function.
\retval GS_TRUE on success
\retval GS_FALSE on failure
\param iTimeOut The number of seconds to wait for the connection.
*/
//============================================================================
GSbool __stdcall InitializeSockets_SetOnConnectTimeout(GSint iTimeOut = 5);
//============================================================================
// Function UninitializeSockets
// Author: Luc Bouchard lbouchard@ubisoft.qc.ca
// Date: 14/09/2001 9:50:18 AM
/*!
\brief (WIN32/XBOX/LINUX/PSX2) Uninitialize the socket library
\par Description:
Unload the socket library.
\return The status of the call to the functions.
\retval GS_TRUE on success
\retval GS_FALSE on failure
*/
//============================================================================
GSbool __stdcall UninitializeSockets();
#endif //GS_WIN32
#ifdef GS_XBOX
//============================================================================
// Function InitializeSockets
// Author: Luc Bouchard lbouchard@ubisoft.qc.ca
// Date: 14/09/2001 9:48:06 AM
/*!
\brief (WIN32/XBOX/LINUX) Initialize the socket library
\par Description:
Initialize the socket library with an optional IP address to bind to.
\return The status of the call to the function
\retval GS_TRUE on success
\retval GS_FALSE on failure
\param szIPAddress the IP address to bind to
*/
//============================================================================
GSbool __stdcall InitializeSockets(GSchar *szIPAddress = NULL);
//============================================================================
// Function UninitializeSockets
// Author: Luc Bouchard lbouchard@ubisoft.qc.ca
// Date: 14/09/2001 9:50:18 AM
/*!
\brief (WIN32/XBOX/LINUX/PSX2) Uninitialize the socket library
\par Description:
Unload the socket library.
\return The status of the call to the functions.
\retval GS_TRUE on success
\retval GS_FALSE on failure
*/
//============================================================================
GSbool __stdcall UninitializeSockets();
#endif //GS_XBOX
#ifdef GS_PSX2
//============================================================================
// Function InitializeSockets
// Author: Luc Bouchard lbouchard@ubisoft.qc.ca
// Date: 14/09/2001 10:05:51 AM
/*!
\brief (PSX2) Initialize the socket library
\par Description:
This function now longer iInitializes the socket library on PSX2. The game must load all IOP modules
and network configuration itself. The ubi.com SDKs are not built using libeenet. See the libeenet
documantation in the SONY libraries on how to load and initialize the libeenet.
\return The status of the call to the function.
\retval GS_TRUE on success
\retval GS_FALSE on failure
\param szIPAddress The IP address to bound to.
*/
//============================================================================
GSbool __stdcall InitializeSockets(const GSchar *szIPAddress = NULL);
//============================================================================
// Function InitializeSockets_Test
// Author: Scott Schmeisser sschmeisser@ubisoft.com
// Date: 01/04/2003 10:05:51 AM
/*!
\brief (PSX2) Initialize the socket library
\par Description:
Initialize the socket library on PSX2. THIS FUNCTION IS NOT TO BE USED.
IT IS FOR TEST PURPOSES ONLY. USE THE ABOVE InitializeSockets() INSTEAD.
\return The status of the call to the function.
\retval GS_TRUE on success
\retval GS_FALSE on failure
\param szIPAddress The IP address to bound to.
*/
//============================================================================
GSbool __stdcall InitializeSockets_Test(GSchar *szIPAddress = NULL);
//============================================================================
// Function InitializeSockets_SetOnConnectTimeout
// Author: Luc Bouchard lbouchard@ubisoft.qc.ca
// Date: 28/08/2002 10:05:51 AM
/*!
\brief (PSX2) Sets the Timeout value when connecting.
\par Description:
Set the amount of time to wait for a connection to establish.
Defaults to 5 seconds;
\return The status of the call to the function.
\retval GS_TRUE on success
\retval GS_FALSE on failure
\param iTimeOut The number of seconds to wait for the connection.
*/
//============================================================================
GSbool __stdcall InitializeSockets_SetOnConnectTimeout(GSint iTimeOut = 5);
//============================================================================
// Function UninitializeSockets
// Author: Luc Bouchard lbouchard@ubisoft.qc.ca
// Date: 14/09/2001 9:50:18 AM
/*!
\brief (WIN32/XBOX/LINUX/PSX2) Uninitialize the socket library
\par Description:
Unload the socket library.
\return The status of the call to the functions.
\retval GS_TRUE on success
\retval GS_FALSE on failure
*/
//============================================================================
GSbool __stdcall UninitializeSockets();
#endif GS_PSX2
#ifdef GS_LINUX
//============================================================================
// Function InitializeSockets
// Author: Luc Bouchard lbouchard@ubisoft.qc.ca
// Date: 14/09/2001 9:48:06 AM
/*!
\brief (WIN32/XBOX/LINUX/PSX2) Initialize the socket library
\par Description:
Initialize the socket library with an optional IP address to bind to.
\return The status of the call to the function
\retval GS_TRUE on success
\retval GS_FALSE on failure
\param szIPAddress the IP address to bind to
*/
//============================================================================
GSbool __stdcall InitializeSockets(GSchar *szIPAddress = NULL);
//============================================================================
// Function InitializeSockets_SetOnConnectTimeout
// Author: Luc Bouchard lbouchard@ubisoft.qc.ca
// Date: 28/08/2002 10:05:51 AM
/*!
\brief (LINUX) Sets the Timeout value when connecting.
\par Description:
Set the amount of time to wait for a connection to establish.
Defaults to 5 seconds;
\return The status of the call to the function.
\retval GS_TRUE on success
\retval GS_FALSE on failure
\param iTimeOut The number of seconds to wait for the connection.
*/
//============================================================================
GSbool __stdcall InitializeSockets_SetOnConnectTimeout(GSint iTimeOut = 5);
//============================================================================
// Function UninitializeSockets
// Author: Luc Bouchard lbouchard@ubisoft.qc.ca
// Date: 14/09/2001 9:50:18 AM
/*!
\brief (WIN32/XBOX/LINUX/PSX2) Uninitialize the socket library
\par Description:
Unload the socket library.
\return The status of the call to the functions.
\retval GS_TRUE on success
\retval GS_FALSE on failure
*/
//============================================================================
GSbool __stdcall UninitializeSockets();
#endif
}
#endif //_INITSOCKETS_H

View File

@@ -0,0 +1,58 @@
#ifndef __NETINTERFACE_H__
#define __NETINTERFACE_H__
#include "GSTypes.h"
enum INTERFACE_TYPE {
IT_LAN,
IT_INTERNET,
IT_ALL
};
//===================================================================================================
// MEMBER: GetNetInterface
// AUTHOR: Pierre-Luc Rigaux
// CREATION: May 2001
//
// DESCRIPTION: Get the local IP Address and the Net Mask of the first Eternet device
//===================================================================================================
// INPUT: null
// OUPUTS: IP Address and netmask in a string format
// RESULT: True on success, false else
// known bug: this funtion takes the first ip interface (we don't know if it is the good one)
//===================================================================================================
GSbool GetNetInterface(GSchar* szIPAddress, GSchar* szNetMask,
INTERFACE_TYPE type = IT_ALL, GSuint uiIndex = 0);
//===================================================================================================
// MEMBER: ResolveBroadcast
// AUTHOR: Guillaume Plante
// CREATION: May 2001
//
// DESCRIPTION: Resolve the broadcast address on the network from the netmask and local ip
// that has been specified by the user. If they are valid, the broadcast is resolve
// with these ip but if they arent, the function tries to resolve it with the
// detected local ip address and net mask, in this case the function return false.
//===================================================================================================
// INPUT: szLocalAddrees = local address in a string format
// INPUT: szNetmask = local netmask in a string format
// OUPUTS: szBroadcastAddress : network broadcast ip address in a string format
// RESULT: True on success, false else
//===================================================================================================
GSbool ResolveBroadcast(GSchar *szLocalAddress,GSchar *szNetmask,GSchar *szBroadcastAddress);
//===================================================================================================
// MEMBER: ResolveBroadcast
// AUTHOR: Guillaume Plante
// CREATION: May 2001
//
// DESCRIPTION: Check if a ip address is valid by comparing it with each of the detected
// address on the local machine.
//===================================================================================================
// INPUT: szLocalAddrees = local address in a string format
// RESULT: True on success, false else
//===================================================================================================
GSbool IPIsValid(GSchar *szIPAddress);
#endif

View File

@@ -0,0 +1,110 @@
#ifndef _GSSIMPLECONNECT_H
#define _GSSIMPLECONNECT_H
#include "define.h"
class clGSConnect;
class clConnectElem;
class clConnectList;
class clTCPClient;
class clUNIXClient;
//===================================================================================================
class clSimpleClient
{
private:
clConnectElem* m_pstConnectElem;
GSchar m_szAddress[129];
public:
/* Constructor/Destructor */
clSimpleClient( GSint lAliveDuring, GSint lRcvTimeout,
GSint iUDPSndBuf = 0, GSint iUDPRcvBuf = 0);
~clSimpleClient();
/* To connect on a peer address using TCP */
GSbool ConnectHost(GSchar *szHost, GSushort lPort);
#ifdef LINUX
/* To connect to a peer UNIX process */
GSbool ConnectUNIXHost(GSchar *sSockPipe);
#endif // LINUX
/* Disconnect from peer address */
GSbool Disconnect(GSvoid);
/* Update messages receive/send */
GSbool CheckConnection(GSvoid);
/* To send a message (put in the send queue) (Priority : 0-31) */
GSbool SendGuaranteed( GSubyte ucType, GSubyte ucPriority, GSvoid *pvMessage, GSint lMsgSize);
GSbool SendLostable( GSubyte ucType, GSubyte ucPriority, GSvoid *pvMessage, GSint lMsgSize);
/* To read a message (from the received queue) */
GSvoid* ReadGuaranteed( GSubyte& rucType, GSint& rlSize);
GSvoid* ReadLostable( GSubyte& rucType, GSint& rlSize);
/* IP management */
GSchar* GetPeerIPAddress(GSvoid);
GSchar* GetLocalIPAddress(GSvoid);
// Checks to see if the UDP connection has been established.
// You must call CheckConnection, ReadGuaranteed and ReadLostable
// between calls to IsUDPConnected to generate and send internal messages
// that establish the UDP connection
GSbool IsUDPConnected();
};
//===================================================================================================
class clSimpleServer
{
private:
clConnectList* m_pstConnectList;
GSint m_lConnectedMode;
GSint m_lStillAliveDuring;
GSint m_lRcvDuring;
GSchar m_szAddress[129];
public:
clSimpleServer( GSint lAliveDuring, GSint lRcvTimeout,
GSint iUDPSndBuf = 0, GSint iUDPRcvBuf = 0);
~clSimpleServer();
/* Return the port reserved */
GSbool ReservePort(GSushort lPort);
#ifdef LINUX
/* Puts the UNIX server into listening mode (UNIX Sockets) */
GSbool OpenSocket(GSchar *p_strSockPipe);
#endif // LINUX
/* Return the ID of the new connection */
GSint AcceptConnection(GSvoid);
/* Return the ID of the element disconnected */
GSint CheckDisconnection(GSvoid);
/* To disconnect an element */
GSbool DisconnectElement(GSint lId);
/* To send a message (put in the send queue) (Priority : 0-31) */
GSbool SendGuaranteed( GSint lId, GSubyte ucType, GSubyte ucPriority, GSvoid *pvMessage, GSint lMsgSize);
GSbool SendLostable( GSint lId, GSubyte ucType, GSubyte ucPriority, GSvoid *pvMessage, GSint lMsgSize);
GSbool SendGuaranteedToAll( GSubyte ucType, GSubyte ucPriority, GSvoid *pvMessage, GSint lMsgSize);
GSbool SendLostableToAll( GSubyte ucType, GSubyte ucPriority, GSvoid *pvMessage, GSint lMsgSize);
/* To read a message (from the received queue) */
GSvoid* ReadGuaranteed( GSint& rlId, GSubyte& rucType, GSint& rlSize);
GSvoid* ReadLostable( GSint& rlId, GSubyte& rucType, GSint& rlSize);
/* IP management */
GSchar* GetPeerIPAddress(GSint lId);
// Checks to see if the UDP connection has been established for that
// connection ID. You must call CheckDisconnection, ReadGuaranteed and
// ReadLostable between calls to IsUDPConnected to generate and send internal
// messages that establish the UDP connection
GSbool IsUDPConnected(GSint iID);
};
#endif // _GSSIMPLECONNECT_H

View File

@@ -0,0 +1,402 @@
//****************************************************************************
//* Author: Luc Bouchard lbouchard@ubisoft.qc.ca
//* Date: 16/05/2001 11:23:39 AM
/*! \file define.h
* \brief Global defines
*
* This file defines all the global values used by the different
* Game Service SDKs.
*/
//****************************************************************************
/*!
\mainpage gs-sdk-common
\section intro Introduction
This SDK contains the basic libraries used by all the Game Service SDKs
\section description Description
libgsconnect: connection management<br>
libgssocket: socket management<br>
libgsutility: message packaging management and other stuff. <br>
\section see_also See Also
<a href="../../gs-sdk-base/doc/index.html">gs-sdk-base</a><br>
<a href="../../gs-sdk-game/doc/index.html">gs-sdk-game</a><br>
<a href="../../gs-sdk-gameserver/doc/index.html">gs-sdk-gameserver</a><br>
<a href="../../gs-sdk-chat/doc/index.html">gs-sdk-chat</a><br>
*/
#ifndef _DEFINE_H_
#ifndef DOX_SKIP_THIS
#define _DEFINE_H_
#endif //DOX_SKIP_THIS
#include "GSTypes.h"
/*! @defgroup group1 Buffer lenghts
\brief The length of the buffer used throughout the SDKs.
The length of the buffer used throughout the SDKs.
@{
*/
#define STOREDPROCLENGTH 30
#define NICKNAMELENGTH 16
#define FIRSTNAMELENGTH 33
#define SURNAMELENGTH 33
#define PASSWORDLENGTH 17
#define ADDRESSLENGTH 129
#define CITYLENGTH 33
#define CODELENGTH 33
#define EMAILLENGTH 129
#define COMMENTSLENGTH 1025
#define WEBPAGELENGTH 129
#define GAMELENGTH 33
#define IRCIDLENGTH 10
#define NAMELENGTH 33
#define COUNTRYLENGTH 65
#define CHATLENGTH 1025
#define IPADDRESSLENGTH 129
#define IPDOTADDRESSLENGTH 16
#define GAMELENGTH 33
#define VERSIONLENGTH 33
#define INFOLENGTH 1025
#define FILELENGTH 129
#define ARENALENGTH 33
#define SESSIONLENGTH 33
#define SCORELENGTH 129
#define REASONLENGTH 129
#define URLLENGTH 1025
#define YESNOLENGTH 4
#define MOTDLENGTH 513
#define LANGUAGELENGTH 3
/*! @} end of group1 */
/*! @defgroup group2 Error/Success
\brief The Error/Success constant
The Error/Success constant
@{
*/
#ifndef GSSUCCESS
#define GSSUCCESS 38 /* c->r */
#endif
#ifndef GSFAIL
#define GSFAIL 39 /* r->c */
#endif
#ifndef GSPENDING
#define GSPENDING 40
#endif
/*! @} end of group2 */
#define CHARSIZE 1
#define SHORTSIZE 2
#define LONGSIZE 4
/*! @defgroup group3 Player statuses
\brief The possible status for a player
The possible status for a player
@{
*/
#define PLAYERONLINE 0
#define PLAYEROFFLINE 1 //Only set by Server
#define PLAYERAWAY 2
#define PLAYERBRB 3
//#define PLAYERSESSIONCANJOIN 4
//#define PLAYERSESSIONCANTJOIN 5
#define PLAYERINVISIBLE 6
#define PLAYERCOREONLINE 7
#define PLAYERINLOBBY 8 //Only set by Server
#define PLAYERINROOM 9 //Only set by Server
#define PLAYERINGAMEOPEN 10 //Only set by Server
#define PLAYERINGAMECLOSE 11 //Only set by Server
#define PLAYERSTATUSCOUNT 12
#define PLAYERCORESTART 3000000
#define PLAYERCOREEND 4999999
/*! @} end of group3 */
/*! @defgroup group4 Admin page types
\brief The possible type of a admin page message
The possible type of a admin page message
@{
*/
// SYSTEMPAGE subtypes
#define ADDEDASFRIEND 0
#define ADDEDASIGNOREE 1
#define REMOVEDASIGNOREE 2
#define ADMINPAGE 185
/*! @} end of group4 */
/*! @defgroup group5 Friends options
\brief The possible options to set when connecting to the FRIENDS service.
The possible options to set when connecting to the FRIENDS service.
@{
*/
#define MASK_PAGE (1L<<0)
#define MASK_FILES (1L<<1)
#define MASK_AUTOFILES (1L<<2)
#define MASK_INVISIBLE (1L<<3)
#define MASK_AWAY (1L<<4)
/*! @} end of group5 */
/*! @defgroup group6 Masks
\brief Masks used throughout the Game Service SDKs.
Masks used throughout the Game Service SDKs.
@{
*/
/*---------------- session and player mask ----------------------*/
#define MASKSESSIONNAME (1L<<0)
#define MASKSCORE (1L<<2)
#define MASKADDRESS (1L<<5)
const GSuint MASKPRIVATE = 0x00000001; //(1L<<0)
const GSuint MASKNEEDMASTER = 0x00000002; //(1L<<1)
const GSuint MASKETERNEL = 0x00000004; //(1L<<2)
const GSuint MASKACTIVE = 0x00000008; //(1L<<3)
const GSuint MASKOPEN = 0x00000010; //(1L<<4)
const GSuint STARTABLE = 0x00000020; //(1L<<5)
const GSuint MASKVISITOR = 0x00000040; //(1L<<6)
const GSuint DEFEREDSTARTGAME = 0x00000080; //(1L<<7)
const GSuint MASKPLAYERETERNEL = 0x00000100;
const GSuint MASKDEDICATEDSERVER = 0x00080000; //(1L<<19)
/*! @} end of group6 */
// ERROR CODES IN USE
// 0 @ 56
// 60 @ 68
// -1 @ -3
// 100, 501, 502, 512
/*! @defgroup group7 Error messages
\brief The error message returned by the different services.
The error message returned by the different services.
@{
*/
/*! @defgroup group7_1 LOGIN service.
\brief Errors returned by the LOGIN service.
Errors returned by the LOGIN service.
@{
*/
/*! Unknown error. */
#define ERRORROUTER_UNKNOWNERROR 0
/*! You are not registered, create a new account first. */
#define ERRORROUTER_NOTREGISTERED 1
/*! Your password is incorrect. */
#define ERRORROUTER_PASSWORDNOTCORRECT 2
/*! The arena has not yet detected your disconnection. */
#define ERRORROUTER_NOTDISCONNECTED 3
/*! The arena is not available. */
#define ERRORROUTER_ARENANOTAVAILABLE 4
/*! The Friends server is not available. */
#define ERRORROUTER_FRIENDSNOTAVAILABLE 5
/*! A player with the same name as yours is already connected. */
#define ERRORROUTER_NAMEALREADYUSED 6
/*! This player is not currently connected to the GameService. */
#define ERRORROUTER_PLAYERNOTCONNECTED 7
/*! This player is not registered on the GameService. */
#define ERRORROUTER_PLAYERNOTREGISTERED 8
/*! The name you chose is already used by another player. */
#define ERRORROUTER_PLAYERCONNECTED 9
/*! You are already registered. */
#define ERRORROUTER_PLAYERALREADYREGISTERED 10
/*! The version of GSClient you are using is too old and can't be upgraded. */
#define ERRORROUTER_CLIENTVERSIONTOOOLD 11
/*! GS Database problem. Some functions are disabled. */
#define ERRORROUTER_DBINBACKUPMODE 12
/*! GS Database problem. Please notify the administrator. */
#define ERRORROUTER_DBPROBLEM 13
/*! The client is incompatible with the server. */
#define ERRORROUTER_CLIENTINCOMPATIBLE 50
/*! @} end of group7_1 */
/*! @defgroup group7_2 FRIENDS service.
\brief Errors returned by the FRIENDS service.
Errors returned by the FRIENDS service.
@{
*/
/*! The Player does not exist. */
#define ERRORFRIENDS_FRIENDNOTEXIST 14
/*! The Player is not connected to an arena. */
#define ERRORFRIENDS_NOTINARENA 15
/*! The Player is not online. */
#define ERRORFRIENDS_PLAYERNOTONLINE 16
/*! The Player is not in a session. */
#define ERRORFRIENDS_NOTINSESSION 17
/*! The Player is ignoring you */
#define ERRORFRIENDS_PLAYERIGNORE 18
/*! The Player is already connected. */
#define ERRORFRIENDS_ALREADYCONNECTED 19
/*! The Friends server cannot accept more players. */
#define ERRORFRIENDS_NOMOREPLAYERS 20
/*! The Player has no scores in database. */
#define ERRORFRIENDS_NOPLAYERSCORE 47
/*! Search Player Finished. */
#define ERRORFRIENDS_SEARCHPLAYERFINISHED 48
/*! The Players status is COREONLINE and is not receiving pages/peer messages */
#define ERRORFRIENDS_PLAYERSTATUSCOREONLINE 56
/*! @} end of group7_2 */
/*! @defgroup group7_3 SESSION service.
\brief Errors returned by the SESSION service.
Errors returned by the SESSION service.
@{
*/
#define ERRORARENA_SESSIONEXIST 21
#define ERRORARENA_GAMENOTALLOWED 22
#define ERRORARENA_NUMBERPLAYER 23
#define ERRORARENA_NUMBERSPECTATOR 24
#define ERRORARENA_VISITORNOTALLOWED 25
#define ERRORARENA_NOTREGISTERED 26
#define ERRORARENA_NOMOREPLAYERS 27
#define ERRORARENA_NOMORESPECTATORS 28
#define ERRORARENA_PLAYERNOTREGISTERED 29
#define ERRORARENA_SESSIONNOTAVAILABLE 30
#define ERRORARENA_SESSIONINPROCESS 31
#define ERRORARENA_BADGAMEVERSION 32
#define ERRORARENA_PASSWORDNOTCORRECT 33
#define ERRORARENA_ALREADYINSESSION 34
#define ERRORARENA_NOTMASTER 35
#define ERRORARENA_NOTINSESSION 36
#define ERRORARENA_MINPLAYERS 37
#define ERRORARENA_ADMINGAMEDOESNOTEXIST 38
#define ERRORARENA_ADMINSESSIONDOESNOTEXIST 39
#define ERRORARENA_CONNECTADDCONNECTION 40
#define ERRORARENA_CONNECTSENDLOGINMSG 41
#define ERRORARENA_ERRORLOGINMESSAGE 42
#define ERRORARENA_NOHOSTARENA 43
#define ERRORARENA_ARENADISCONNECTED 44
#define ERRORARENA_INVALIDGROUPNAME 45
#define ERRORARENA_INVALIDGAMETYPE 46
#define ERRORARENA_NOMOREGAMEMODULE 47
#define ERRORARENA_PASSPORTLABELNOTFOUND 48
#define ERRORARENA_PASSPORTFAIL 49
#define ERRORARENA_CREATENOTALLOWED 50
#define ERRORARENA_INVALIDSESSIONTYPE 51
#define ERRORARENA_SESSIONCLOSE 52
#define ERRORARENA_NOTCREATOR 53
#define ERRORARENA_DEDICATEDSERVERONLY 54
/*! @} end of group7_3 */
/*! @defgroup group7_4 CLANMANAGER service.
Errors returned by the CLANMANAGER service.
@{
*/
#define ERRORCLAN_INVALIDPROFILE 49
/*! @} end of group7_4 */
/*! @defgroup group7_5 DB/Proxy
\briefError messages for db/proxy services
Error messages for db/proxy services
@{
*/
#define ERROR_SERVICENOTAVAILABLE 55
/*! @defgroup group7_5_1 Ladder Query Service
\brief Ladder Query Service Errors
Error codes for the proxy's ladder query service
@{
*/
#define ERRLQS_DUPLICATEFIELD 60
#define ERRLQS_DATABASEFAILURE 61
#define ERRLQS_INTERNAL_OUTOFMEMORY 62
#define ERRLQS_INTERNAL_WRONGRESULTVERSION 63
#define ERRLQS_INTERNAL_BADRESULTFORMAT 64
/*! @} end of group7_5_1 */
/*! @defgroup group7_5_2 Score Submission
\brief Score Submission Error Codes
Error codes for the proxy's score submission
@{
*/
#define ERRSS_BADFORMAT 65
#define ERRSS_DBFAILURE 66
#define ERRSS_SUBMISSIONFAILED 67
#define ERRSS_VALIDATIONFAILED 68
/*! @} end of group7_5_2 */
/*! @} end of group7_5 */
/*! @defgroup group7_6 Other
\brief Other error messages
Other error messages
@{
*/
#define ERROR_ROUTERCONNECTION -1
#define ERROR_ARENACONNECTION -2
#define ERROR_LOBBYSRVDISCONNECTED -3
/*! @} end of group7_6 */
/*! @defgroup group7_7 Secure Accounts
\brief Errors for Secure Accounts
These Error messages are for Secure Accounts
@{
*/
// CREATE: The username already exists
#define ERRORSECURE_USERNAMEEXISTS 1
// CREATE: The username is malformed
#define ERRORSECURE_USERNAMEMALFORMED 2
// CREATE: The username is not allowed to be used (e.g. contains smut)
#define ERRORSECURE_USERNAMEFORBIDDEN 3
// LOGIN: The account does not exist
#define ERRORSECURE_INVALIDACCOUNT 4
// CREATE: The username is reserved (e.g. Ubi_* usernames)
#define ERRORSECURE_USERNAMERESERVED 5
// CREATE/UPDATE: The password is malformed
#define ERRORSECURE_PASSWORDMALFORMED 11
// CREATE/UPDATE: The password is not allowed (e.g. contains username)
#define ERRORSECURE_PASSWORDFORBIDDEN 13
// LOGIN: The password is incorrect
#define ERRORSECURE_INVALIDPASSWORD 15
// ALL: The database returned an error
#define ERRORSECURE_DATABASEFAILED 100
// LOGIN: The account has been banned
#define ERRORSECURE_BANNEDACCOUNT 501
// LOGIN: The account has been blocked
#define ERRORSECURE_BLOCKEDACCOUNT 502
// LOGIN: The account has been locked
#define ERRORSECURE_LOCKEDACCOUNT 512
/*! @} end of group7_6 */
/*! @} end of group7 */
#endif