cbsatplugin/atmisccmdplugin/src/atcommandparser.cpp
author hgs
Mon, 12 Jul 2010 19:25:26 +0300
changeset 45 b0aebde9b1fb
parent 32 19bd632b5100
child 47 9e2a905b887f
permissions -rw-r--r--
201027_02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26
hgs
parents:
diff changeset
     1
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     2
// All rights reserved.
hgs
parents:
diff changeset
     3
// This component and the accompanying materials are made available
hgs
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     5
// which accompanies this distribution, and is available
hgs
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     7
//
hgs
parents:
diff changeset
     8
// Initial Contributors:
hgs
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    10
//
hgs
parents:
diff changeset
    11
// Contributors:
hgs
parents:
diff changeset
    12
//
hgs
parents:
diff changeset
    13
// Description:
hgs
parents:
diff changeset
    14
// This file contains the implementation of the AT command parser and common utilities
hgs
parents:
diff changeset
    15
// 
hgs
parents:
diff changeset
    16
//
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
#include "atcommandparser.h"
hgs
parents:
diff changeset
    19
#include <hash.h>
hgs
parents:
diff changeset
    20
hgs
parents:
diff changeset
    21
#include "debug.h"
32
hgs
parents: 26
diff changeset
    22
#include "atmisccmdpluginconsts.h"
26
hgs
parents:
diff changeset
    23
hgs
parents:
diff changeset
    24
TAtCommandParser::TAtCommandParser()
hgs
parents:
diff changeset
    25
    : iCmdType(EUnknown), iCmdHandlerType(ECmdHandlerTypeUndefined)  
hgs
parents:
diff changeset
    26
    {
32
hgs
parents: 26
diff changeset
    27
    TRACE_FUNC_ENTRY
hgs
parents: 26
diff changeset
    28
    TRACE_FUNC_EXIT
26
hgs
parents:
diff changeset
    29
    }
hgs
parents:
diff changeset
    30
hgs
parents:
diff changeset
    31
TAtCommandParser::TAtCommandParser(const TDesC8& aCmd)
hgs
parents:
diff changeset
    32
    : iCmdType(EUnknown), iCmdHandlerType(ECmdHandlerTypeUndefined)  
hgs
parents:
diff changeset
    33
    {
32
hgs
parents: 26
diff changeset
    34
    TRACE_FUNC_ENTRY
26
hgs
parents:
diff changeset
    35
    ParseAtCommand(aCmd);
32
hgs
parents: 26
diff changeset
    36
    TRACE_FUNC_EXIT
26
hgs
parents:
diff changeset
    37
    }
hgs
parents:
diff changeset
    38
hgs
parents:
diff changeset
    39
void TAtCommandParser::ParseAtCommand(const TDesC8& aCmd)
hgs
parents:
diff changeset
    40
    {
hgs
parents:
diff changeset
    41
    TRACE_FUNC_ENTRY
hgs
parents:
diff changeset
    42
    iCmd.Assign(aCmd);
hgs
parents:
diff changeset
    43
    iCmd.Mark();
hgs
parents:
diff changeset
    44
    TChar c = 0;
hgs
parents:
diff changeset
    45
    // First extract the AT command "AT+COMMAND"
hgs
parents:
diff changeset
    46
    while(!iCmd.Eos() && !(c=='=' || c=='?'))
hgs
parents:
diff changeset
    47
        {
hgs
parents:
diff changeset
    48
        iCmd.Inc();
hgs
parents:
diff changeset
    49
        c = iCmd.Peek();
hgs
parents:
diff changeset
    50
        }
hgs
parents:
diff changeset
    51
          
hgs
parents:
diff changeset
    52
    TPtrC8 token = iCmd.MarkedToken();   
hgs
parents:
diff changeset
    53
    
hgs
parents:
diff changeset
    54
    _LIT8(KAtCfun, "AT+CFUN");
hgs
parents:
diff changeset
    55
    _LIT8(KAtCbc, "AT+CBC");
hgs
parents:
diff changeset
    56
    _LIT8(KAtClck, "AT+CLCK");
hgs
parents:
diff changeset
    57
    _LIT8(KAtCpwd, "AT+CPWD");
hgs
parents:
diff changeset
    58
    _LIT8(KAtCpin, "AT+CPIN");
hgs
parents:
diff changeset
    59
    _LIT8(KAtCusd, "AT+CUSD");
hgs
parents:
diff changeset
    60
    _LIT8(KAtCnum, "AT+CNUM");
45
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
    61
	_LIT8(KAtCmee, "AT+CMEE");
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
    62
#ifdef PROTOCOL_TDSCDMA
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
    63
    _LIT8(KAtHver, "AT^HVER");
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
    64
    _LIT8(KAtCgsn, "AT+CGSN");
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
    65
    _LIT8(KAtCgmr, "AT+CGMR");
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
    66
    _LIT8(KAtCgmi, "AT+CGMI");
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
    67
    _LIT8(KAtCmgw, "AT+CMGW");
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
    68
	_LIT8(KAtCmgd, "AT+CMGD");
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
    69
	_LIT8(KAtCmgf, "AT+CMGF");
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
    70
#endif
26
hgs
parents:
diff changeset
    71
    
hgs
parents:
diff changeset
    72
    Trace(KDebugPrintS, "token: ", &token);
hgs
parents:
diff changeset
    73
    // Determine the AT command type
32
hgs
parents: 26
diff changeset
    74
    if(!token.CompareF(KAtCfun))
26
hgs
parents:
diff changeset
    75
        {
hgs
parents:
diff changeset
    76
        iCmdType = ECmdAtCfun;
hgs
parents:
diff changeset
    77
        }
32
hgs
parents: 26
diff changeset
    78
    else if(!token.CompareF(KAtCbc))
26
hgs
parents:
diff changeset
    79
        {
hgs
parents:
diff changeset
    80
        iCmdType = ECmdAtCbc;
hgs
parents:
diff changeset
    81
        }
32
hgs
parents: 26
diff changeset
    82
    else if(!token.CompareF(KAtClck))
26
hgs
parents:
diff changeset
    83
        {
hgs
parents:
diff changeset
    84
        iCmdType = ECmdAtClck;
hgs
parents:
diff changeset
    85
        }
32
hgs
parents: 26
diff changeset
    86
    else if(!token.CompareF(KAtCpwd))
26
hgs
parents:
diff changeset
    87
        {
hgs
parents:
diff changeset
    88
        iCmdType = ECmdAtCpwd;
hgs
parents:
diff changeset
    89
        }
32
hgs
parents: 26
diff changeset
    90
    else if(!token.CompareF(KAtCpin))
26
hgs
parents:
diff changeset
    91
        {
hgs
parents:
diff changeset
    92
        iCmdType = ECmdAtCpin;
hgs
parents:
diff changeset
    93
        }
32
hgs
parents: 26
diff changeset
    94
    else if(!token.CompareF(KAtCusd))
26
hgs
parents:
diff changeset
    95
        {
hgs
parents:
diff changeset
    96
        iCmdType = ECmdAtCusd;
hgs
parents:
diff changeset
    97
        }
32
hgs
parents: 26
diff changeset
    98
    else if(!token.CompareF(KAtCnum))
26
hgs
parents:
diff changeset
    99
        {
hgs
parents:
diff changeset
   100
        iCmdType = ECmdAtCnum;
hgs
parents:
diff changeset
   101
        }
32
hgs
parents: 26
diff changeset
   102
    else if(!token.Compare(KAtCmee))
hgs
parents: 26
diff changeset
   103
        {
hgs
parents: 26
diff changeset
   104
        iCmdType = ECmdAtCmee;
45
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   105
		}
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   106
#ifdef PROTOCOL_TDSCDMA
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   107
    else if(!token.CompareF(KAtHver))
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   108
        {
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   109
        iCmdType = ECmdAtHver;
32
hgs
parents: 26
diff changeset
   110
        }
45
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   111
    else if(!token.CompareF(KAtCgsn))
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   112
        {
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   113
        iCmdType = ECmdAtCgsn;
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   114
        }
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   115
    else if(!token.CompareF(KAtCgmr))
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   116
        {
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   117
        iCmdType = ECmdAtCgmr;
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   118
        }
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   119
    else if(!token.CompareF(KAtCgmi))
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   120
        {
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   121
        iCmdType = ECmdAtCgmi;
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   122
        }       
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   123
    else if(!token.CompareF(KAtCmgw))
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   124
        {
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   125
        iCmdType = ECmdAtCmgw;
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   126
        }
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   127
    else if(!token.CompareF(KAtCmgd))
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   128
        {
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   129
        iCmdType = ECmdAtCmgd;
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   130
        }
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   131
    else if(!token.CompareF(KAtCmgf))
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   132
        {
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   133
        iCmdType = ECmdAtCmgf;
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   134
        }
b0aebde9b1fb 201027_02
hgs
parents: 32
diff changeset
   135
#endif    
26
hgs
parents:
diff changeset
   136
    else
hgs
parents:
diff changeset
   137
        {
hgs
parents:
diff changeset
   138
        iCmdType = EUnknown;
hgs
parents:
diff changeset
   139
        TRACE_FUNC_EXIT
hgs
parents:
diff changeset
   140
        return;
hgs
parents:
diff changeset
   141
        }
hgs
parents:
diff changeset
   142
        
hgs
parents:
diff changeset
   143
    // Now find out the AT command handler type
hgs
parents:
diff changeset
   144
    if(iCmd.Eos())
hgs
parents:
diff changeset
   145
        {
hgs
parents:
diff changeset
   146
        iCmdHandlerType = ECmdHandlerTypeBase;
hgs
parents:
diff changeset
   147
        }
hgs
parents:
diff changeset
   148
    else if(iCmd.Peek() == '?')
hgs
parents:
diff changeset
   149
        {
hgs
parents:
diff changeset
   150
        iCmdHandlerType = ECmdHandlerTypeRead;
hgs
parents:
diff changeset
   151
        }
hgs
parents:
diff changeset
   152
    else if(iCmd.Peek() == '=')
hgs
parents:
diff changeset
   153
        {
hgs
parents:
diff changeset
   154
        iCmd.Inc();
hgs
parents:
diff changeset
   155
        if(iCmd.Peek() == '?')
hgs
parents:
diff changeset
   156
            {
hgs
parents:
diff changeset
   157
            iCmd.Inc();
hgs
parents:
diff changeset
   158
            iCmdHandlerType = ECmdHandlerTypeTest;
hgs
parents:
diff changeset
   159
            }
hgs
parents:
diff changeset
   160
        else
hgs
parents:
diff changeset
   161
            {
hgs
parents:
diff changeset
   162
            iCmdHandlerType = ECmdHandlerTypeSet;
hgs
parents:
diff changeset
   163
            }
hgs
parents:
diff changeset
   164
        }
hgs
parents:
diff changeset
   165
    else
hgs
parents:
diff changeset
   166
        {
hgs
parents:
diff changeset
   167
        iCmdHandlerType = ECmdHandlerTypeUndefined;
hgs
parents:
diff changeset
   168
        }
hgs
parents:
diff changeset
   169
    TRACE_FUNC_EXIT
hgs
parents:
diff changeset
   170
    }
hgs
parents:
diff changeset
   171
hgs
parents:
diff changeset
   172
TAtCommandParser::TCommandType TAtCommandParser::Command() const
hgs
parents:
diff changeset
   173
    {
32
hgs
parents: 26
diff changeset
   174
    TRACE_FUNC_ENTRY
hgs
parents: 26
diff changeset
   175
    TRACE_FUNC_EXIT
26
hgs
parents:
diff changeset
   176
    return iCmdType;
hgs
parents:
diff changeset
   177
    }
hgs
parents:
diff changeset
   178
hgs
parents:
diff changeset
   179
TAtCommandParser::TCommandHandlerType TAtCommandParser::CommandHandlerType() const
hgs
parents:
diff changeset
   180
    {
32
hgs
parents: 26
diff changeset
   181
    TRACE_FUNC_ENTRY
hgs
parents: 26
diff changeset
   182
    TRACE_FUNC_EXIT
26
hgs
parents:
diff changeset
   183
    return iCmdHandlerType;
hgs
parents:
diff changeset
   184
    }
hgs
parents:
diff changeset
   185
hgs
parents:
diff changeset
   186
TPtrC8 TAtCommandParser::NextParam()
hgs
parents:
diff changeset
   187
    {
hgs
parents:
diff changeset
   188
    TRACE_FUNC_ENTRY
hgs
parents:
diff changeset
   189
    iCmd.SkipSpace(); // Skip front spaces
hgs
parents:
diff changeset
   190
    iCmd.Mark();
hgs
parents:
diff changeset
   191
    TChar chr = 0;
hgs
parents:
diff changeset
   192
    
hgs
parents:
diff changeset
   193
    if(!iCmd.Eos())
hgs
parents:
diff changeset
   194
        {
hgs
parents:
diff changeset
   195
        chr = iCmd.Peek();
hgs
parents:
diff changeset
   196
        while(!iCmd.Eos() && chr != ',' && !chr.IsSpace() && !chr.IsControl())
hgs
parents:
diff changeset
   197
            {// Stop at any of those chars: comma, space or control
hgs
parents:
diff changeset
   198
            iCmd.Inc();
hgs
parents:
diff changeset
   199
            chr = iCmd.Peek();
hgs
parents:
diff changeset
   200
            }
hgs
parents:
diff changeset
   201
        }
hgs
parents:
diff changeset
   202
    
hgs
parents:
diff changeset
   203
    // Extract the token at this point            
hgs
parents:
diff changeset
   204
    TPtrC8 retVal = iCmd.MarkedToken();
hgs
parents:
diff changeset
   205
    
hgs
parents:
diff changeset
   206
    // Skip comma, space and control chars
hgs
parents:
diff changeset
   207
    while(!iCmd.Eos() && (chr == ',' || chr.IsSpace() || chr.IsControl()))
hgs
parents:
diff changeset
   208
        {
hgs
parents:
diff changeset
   209
        iCmd.Inc();
hgs
parents:
diff changeset
   210
        chr = iCmd.Peek();
hgs
parents:
diff changeset
   211
        }
hgs
parents:
diff changeset
   212
    TRACE_FUNC_EXIT
hgs
parents:
diff changeset
   213
    return retVal;
hgs
parents:
diff changeset
   214
    }
hgs
parents:
diff changeset
   215
32
hgs
parents: 26
diff changeset
   216
TInt TAtCommandParser::NextTextParam(TPtrC8& aParam)
26
hgs
parents:
diff changeset
   217
    {
32
hgs
parents: 26
diff changeset
   218
    TRACE_FUNC_ENTRY
hgs
parents: 26
diff changeset
   219
    TInt ret = KErrNone;
26
hgs
parents:
diff changeset
   220
    TPtrC8 param = NextParam();
hgs
parents:
diff changeset
   221
    
32
hgs
parents: 26
diff changeset
   222
    if (param.Length() == 0)
26
hgs
parents:
diff changeset
   223
        {
32
hgs
parents: 26
diff changeset
   224
        aParam.Set(NULL,0);
hgs
parents: 26
diff changeset
   225
        ret = KErrNotFound;
26
hgs
parents:
diff changeset
   226
        }
32
hgs
parents: 26
diff changeset
   227
    else if(param.Length() < 2 || param[0] != '"'
26
hgs
parents:
diff changeset
   228
            || param[param.Length()-1] != '"')
hgs
parents:
diff changeset
   229
        {
32
hgs
parents: 26
diff changeset
   230
        aParam.Set(NULL,0);
hgs
parents: 26
diff changeset
   231
        ret = KErrArgument;
26
hgs
parents:
diff changeset
   232
        }
32
hgs
parents: 26
diff changeset
   233
    else
hgs
parents: 26
diff changeset
   234
        {
hgs
parents: 26
diff changeset
   235
        aParam.Set(param.Mid(1, param.Length() - 2));
hgs
parents: 26
diff changeset
   236
        }
hgs
parents: 26
diff changeset
   237
    TRACE_FUNC_EXIT
hgs
parents: 26
diff changeset
   238
    return ret;
26
hgs
parents:
diff changeset
   239
    }
hgs
parents:
diff changeset
   240
hgs
parents:
diff changeset
   241
TInt TAtCommandParser::NextIntParam(TInt& aValue)
hgs
parents:
diff changeset
   242
    {
hgs
parents:
diff changeset
   243
    TRACE_FUNC_ENTRY
hgs
parents:
diff changeset
   244
    TInt retVal =KErrNone;
hgs
parents:
diff changeset
   245
    TPtrC8 param = NextParam();
32
hgs
parents: 26
diff changeset
   246
    if (param.Length() == 0)
26
hgs
parents:
diff changeset
   247
        {
hgs
parents:
diff changeset
   248
        retVal = KErrNotFound;
hgs
parents:
diff changeset
   249
        }
hgs
parents:
diff changeset
   250
    else
hgs
parents:
diff changeset
   251
        {
hgs
parents:
diff changeset
   252
        TLex8 lex(param);
hgs
parents:
diff changeset
   253
        retVal = lex.Val(aValue);
hgs
parents:
diff changeset
   254
        }
hgs
parents:
diff changeset
   255
    TRACE_FUNC_EXIT
hgs
parents:
diff changeset
   256
    return retVal;
hgs
parents:
diff changeset
   257
    }
hgs
parents:
diff changeset
   258
hgs
parents:
diff changeset
   259
TInt TAtCommandParser::HashSecurityCode(const TDesC8& aPasscode, TDes8& aHashCode)
hgs
parents:
diff changeset
   260
    {
hgs
parents:
diff changeset
   261
    TRACE_FUNC_ENTRY
hgs
parents:
diff changeset
   262
    TInt ret = KErrNone;
hgs
parents:
diff changeset
   263
hgs
parents:
diff changeset
   264
    // Get MD5 Hash
hgs
parents:
diff changeset
   265
    // see remotemgmt component CSCPServer::HashISACode() for encoding algorithm
hgs
parents:
diff changeset
   266
    CMD5* hashObject = NULL;
hgs
parents:
diff changeset
   267
    TRAP( ret, hashObject = CMD5::NewL() );
hgs
parents:
diff changeset
   268
hgs
parents:
diff changeset
   269
    if(ret != KErrNone)
hgs
parents:
diff changeset
   270
        {
hgs
parents:
diff changeset
   271
        TRACE_FUNC_EXIT
hgs
parents:
diff changeset
   272
        return ret;
hgs
parents:
diff changeset
   273
        }
hgs
parents:
diff changeset
   274
    
hgs
parents:
diff changeset
   275
    RBuf pwdBuffer;
hgs
parents:
diff changeset
   276
    ret = pwdBuffer.Create(KSCPMaxHashLength);
hgs
parents:
diff changeset
   277
    if(ret != KErrNone)
hgs
parents:
diff changeset
   278
        {
hgs
parents:
diff changeset
   279
        delete hashObject;
hgs
parents:
diff changeset
   280
        TRACE_FUNC_EXIT
hgs
parents:
diff changeset
   281
        return ret;
hgs
parents:
diff changeset
   282
        }
hgs
parents:
diff changeset
   283
    pwdBuffer.Copy(aPasscode); // convert to TDes16
hgs
parents:
diff changeset
   284
hgs
parents:
diff changeset
   285
    // add TDes16 to a binary buffer
hgs
parents:
diff changeset
   286
    TUint16* inputPtr = const_cast<TUint16*>( pwdBuffer.Ptr() ); 
hgs
parents:
diff changeset
   287
    TPtrC8 inputData( reinterpret_cast<TUint8*>(inputPtr), pwdBuffer.Length()*2 );
hgs
parents:
diff changeset
   288
    
hgs
parents:
diff changeset
   289
    TPtrC8 hash = hashObject->Final( inputData );
hgs
parents:
diff changeset
   290
    delete hashObject;
hgs
parents:
diff changeset
   291
hgs
parents:
diff changeset
   292
    pwdBuffer.Zero();
hgs
parents:
diff changeset
   293
    pwdBuffer.Copy(hash);
hgs
parents:
diff changeset
   294
hgs
parents:
diff changeset
   295
    // Compute the hash sum as four 32-bit integers.
hgs
parents:
diff changeset
   296
    TInt64 hashSum = *(reinterpret_cast<TInt32*>(&pwdBuffer[0])) + 
hgs
parents:
diff changeset
   297
                     *(reinterpret_cast<TInt32*>(&pwdBuffer[4])) + 
hgs
parents:
diff changeset
   298
                     *(reinterpret_cast<TInt32*>(&pwdBuffer[8])) +
hgs
parents:
diff changeset
   299
                     *(reinterpret_cast<TInt32*>(&pwdBuffer[12]));
hgs
parents:
diff changeset
   300
    pwdBuffer.Close();
hgs
parents:
diff changeset
   301
     
hgs
parents:
diff changeset
   302
    // Create a five-digit security code from this number
hgs
parents:
diff changeset
   303
    TInt isaCode = ( hashSum % 90000 ) + 10000;
hgs
parents:
diff changeset
   304
hgs
parents:
diff changeset
   305
    // save encoded security code to TDes
hgs
parents:
diff changeset
   306
    aHashCode.Zero();
hgs
parents:
diff changeset
   307
    aHashCode.AppendNum(isaCode);
hgs
parents:
diff changeset
   308
hgs
parents:
diff changeset
   309
    TRACE_FUNC_EXIT
hgs
parents:
diff changeset
   310
    return KErrNone;
hgs
parents:
diff changeset
   311
    }
hgs
parents:
diff changeset
   312