svn merge -r 12308:13112 https://svn.planet-lab.org/svn/Monitor/branches/2.0/
[monitor.git] / pcucontrol / models / intelamt / RemoteControlSample.cpp
1 //----------------------------------------------------------------------------
2 //
3 //  Copyright (C) Intel Corporation, 2004 - 2006.
4 //
5 //  File:       RemoteControlSample.cpp 
6 //
7 //  Contents:   Sample code for an IntelĀ® AMT Network client.
8 //
9 //  Notes:      this file contains routines that call (using SOAP) 
10 //              the RemoteControl functions of the Intel(R) AMT 2.0 as 
11 //              defined in the "Intel(R) AMT Network Design Guide".
12 //
13 //----------------------------------------------------------------------------
14
15 #include "CommonDefinitions.h"
16 #include "RemoteControlTypes.h"
17 #include "RemoteControlSoapBinding.nsmap"
18
19 /*
20  * Function prototypes
21  */
22 void Usage(char *cmd);
23 bool GetUserValues(uint8 *&command, uint32 *&ianaOemNumber, 
24                                    uint8 *&specialCommand, uint16 *&specialCommandParameter, 
25                                    uint16 *&bootOptions, uint16 *&OEMParameters);
26 void DisplaySystemCapabilities(uint8 specialCommandsSupported);
27 void DisplaySpecialCommand(uint16 specialCommandsSupported);
28 void DisplaySystemFirmwareCapabilities(uint32 systemFirmwareCapabilities);
29 void DisplayOemDefinedCapabilities(uint32 OemDefinedCapabilities);
30 bool ExecuteGetSystemPowerstate(Soap *server, bool verbose = true);
31 bool ExecuteGetRemoteControlCapabilities(Soap *server, bool verbose = true);
32 bool ExecuteRemoteControl(Soap *server, bool default_val = false, uint8 icommand=Reset);
33 bool MainFlow(Soap *server,int option,bool verbose);
34 bool ValidateOption(char *option, int *parameter);
35
36 /*
37  * This is the main entry point
38  */
39 int main(int argc, char* argv[])
40 {
41         // Command line parameter
42         char *option = NULL;
43         // Client certificate's name
44         char *certName = NULL;
45 #ifndef _WIN32
46         // Password for keys file openning
47         char *certPass = NULL;
48 #else
49     // True if an authentication scheme is Kerberos, 
50     // otherwise the authentication scheme is digest
51     bool krb = true;
52 #endif
53         // Target URL
54         char *target = NULL;
55         // Target username
56         char *username = NULL;
57         // Target password
58         char *password = NULL;
59         // Command line without app name and parameter
60         char **commandLine = NULL;
61         int commandLineLength = argc;
62         int parameter;
63         bool verbose = false;
64         
65
66         if( !GetOption(&commandLineLength,argv,
67                 MIN_NUM_OF_CL_PARAMETERS,&option,&commandLine) ||
68                 !ValidateOption(option,&parameter) ||
69 #ifndef _WIN32
70                 !ParseCommandLine(commandLineLength,commandLine,&target,
71                 &certName,&certPass,&verbose,&username,&password)
72 #else
73                 !ParseCommandLine(commandLineLength,commandLine,&target,
74                 &certName,NULL,&krb,&verbose,&username,&password)
75 #endif
76                 )
77         {
78                 Usage(argv[0]);
79                 return 1;
80         }
81
82     // The last parameter should be true for local application
83     // and false for remote application
84 #ifndef _WIN32
85         Soap server(target,certName,certPass,username,password);
86 #else
87         Soap server(target,certName,username,password,false,krb);
88 #endif
89
90         if(MainFlow(&server,parameter,verbose) != true)
91         {
92                 return 1;
93         }
94         return 0;
95 }
96
97 /*
98  * Validates an option passed in the command line.
99  * Arguments:
100  *      option - command line option
101  *  parameter - pointer to the variable that will hold 
102  *              type of the action the apllication 
103  *              will perform.
104  * Return value:
105  *  true - on succeed
106  *  false - on failure (command line option not recognized)
107  */
108 bool ValidateOption(char *option, int *parameter)
109 {
110         if(!option)
111         {
112                 return false;
113         }
114         bool status = true;
115         if(!strcmp(option,POWER))
116         {
117                 *parameter = OPT_POWER;
118         }
119         else if(!strcmp(option,CAPABILITIES))
120         {
121                 *parameter = OPT_CAPABILITIES;
122         }
123         else if(!strcmp(option,REMOTE))
124         {
125                 *parameter = OPT_REMOTE;
126         }
127         else if(!strcmp(option,API_TEST))
128         {
129                 *parameter = OPT_API_TEST;
130         }
131         else if(!strcmp(option,REDUCED_API_TEST))
132         {
133                 *parameter = OPT_REDUCED_API_TEST;
134         }
135         else
136         {
137                 status = false;
138         }
139         return status;
140 }
141
142 /*
143  * Function that performs the main flow of Remote Control sample
144  * Arguments:
145  *  soap - pointer to the runtime environment 
146  *  option - variable that holds type of the action the apllication 
147  *           will perform
148  *  verbose - boolean value for API test 
149  * Return value:
150  *  true  - on success
151  *  false - on failure
152  */
153 bool MainFlow(Soap *server, int option, bool verbose)
154 {
155         bool status = true;
156         switch(option)
157         {
158                 case OPT_POWER:
159                         status = ExecuteGetSystemPowerstate(server);
160                         break;
161                 case OPT_CAPABILITIES:
162                         status = ExecuteGetRemoteControlCapabilities(server);
163                         break;
164                 case OPT_REMOTE:
165                         status = ExecuteRemoteControl(server);
166                         break;
167                 case OPT_API_TEST:
168                         if((status = ExecuteGetSystemPowerstate(server,verbose)) == false)
169                         {
170                                 return status;
171                         }
172                         if((status = ExecuteGetRemoteControlCapabilities(server,verbose)) == false)
173                         {
174                                 return status;
175                         }       
176                         /* Ensure that the machine is powered up before trying to
177                          * 'reset' it, since a reset on a down node will fail. */
178                         if ((status = ExecuteRemoteControl(server,true,PowerUp)) == false)
179                         {
180                                 return status;
181                         }
182                         if ((status = ExecuteRemoteControl(server,true,Reset)) == false)
183                         {
184                                 return status;
185                         }
186                         break;
187                 case OPT_REDUCED_API_TEST:                      
188                         if((status = ExecuteGetSystemPowerstate(server,verbose)) == false)
189                         {
190                                 return status;
191                         }
192                         if((status = ExecuteGetRemoteControlCapabilities(server,verbose)) == false)
193                         {
194                                 return status;
195                         }       
196                         break;
197                 default:
198                         status = false;
199         }
200
201         return status;
202 }
203
204 /*
205  * Prints a usage information for the user.
206  */
207 void Usage(char *cmd)
208 {
209         printf("Usage:\n");
210 #ifndef _WIN32
211     printf("\t %s <opt> [%s] [%s <name> %s <pass>] http[s]:", cmd, VERBOSE, CERT_NAME, CERT_PASS);
212 #else
213         printf("\t %s <opt> [%s] [%s <username> %s <password>] [%s <name>] http[s]:", 
214         cmd, VERBOSE, USER, PASS, CERT_NAME);
215 #endif
216         printf("//<Hostname>:<Port>/<RemoteControlUri> ");
217 #ifndef _WIN32
218         printf("[%s <username> %s <password>]\n",USER,PASS); 
219 #endif
220         printf("\nWhere <opt> is :\n");
221         printf("\t %s : GetSystemPowerstate\n",POWER);
222         printf("\t %s : GetRemoteControlCapabilities\n",CAPABILITIES);
223         printf("\t %s : RemoteControl\n",REMOTE);
224         printf("\t %s : perform API test\n",API_TEST);
225         printf("\t %s : perform API test without boot\n",REDUCED_API_TEST);
226         printf("\t To run API test in verbose mode include %s option\n", VERBOSE);
227         PrintAuthenticationNote();
228         printf("\nExample:\n");
229         printf("\t %s %s ", cmd, POWER);
230         printf("http://hostname:16992/RemoteControlService\n");
231 #ifndef _WIN32
232     printf("\t %s %s %s MyCert %s Pass https://hostname:16993/RemoteControlService\n",   
233         cmd, POWER, CERT_NAME, CERT_PASS);
234 #else
235         printf("\t %s %s %s MyCert https://hostname:16993/RemoteControlService\n",   
236                 cmd, POWER, CERT_NAME);
237 #endif
238 }
239
240 /*
241  * Queries (using SOAP) and display the system power state
242  * Arguments:
243  *  server      - pointer to the runtime environment 
244  *  url         - address of the web service            
245  *  verbose - boolean value for API test 
246  * Return value:
247  *  true  - on success
248  *  false - on failure
249  */
250 bool ExecuteGetSystemPowerstate(Soap* server, bool verbose)
251 {
252         int res;
253         bool status;
254
255         server->Init();
256
257         // gSOAP structures for handling 
258         // request and response information
259         _rci__GetSystemPowerState request;
260         _rci__GetSystemPowerStateResponse response;
261
262         FunctionCall("GetSystemPowerState");    
263         res = soap_call___rci__GetSystemPowerState(server->GetSoap(),
264                 server->GetIp(),NULL, &request, &response);
265
266         if((status = 
267                 CheckReturnStatus(res,
268                 response.Status,
269                 "GetSystemPowerState")) == true)
270         {
271                 if(verbose)
272                 {
273                         printf("\nSystemPowerstate is: %u\n", response.SystemPowerState);
274                 }
275                 else
276                 {
277                         PrintSuccess();
278                 }
279         }
280
281         return status;
282 }
283
284 /*
285  * Queries (using SOAP) and display the Intel(R) AMT
286  * device remote control capabilities
287  * Arguments:
288  *  server      - pointer to the runtime environment 
289  *  url         - address of the web service
290  *  verbose - boolean value for API test 
291  * Return value:
292  *  true  - on success
293  *  false - on failure
294  */
295 bool ExecuteGetRemoteControlCapabilities(Soap* server, bool verbose)
296 {
297         int res;
298         bool status;
299
300         server->Init();
301
302         // gSOAP structures for handling 
303         // request and response information
304         _rci__GetRemoteControlCapabilities request;
305         _rci__GetRemoteControlCapabilitiesResponse response;
306
307         FunctionCall("GetRemoteControlCapabilities");   
308         res = soap_call___rci__GetRemoteControlCapabilities(server->GetSoap(), 
309                 server->GetIp(),NULL, &request, &response);
310
311         if((status = CheckReturnStatus(res,response.Status,"GetRemoteControlCapabilities")) == true)
312         {
313                 if(verbose)
314                 {
315                         printf("\nRemote Control Capabilities\n");
316                         printf("---------------------------------------\n");
317
318                         printf("IanaOemNumber = %u\n", response.IanaOemNumber);
319
320                         DisplayOemDefinedCapabilities(response.OemDefinedCapabilities);
321
322                         printf("\n");
323                         DisplaySpecialCommand(response.SpecialCommandsSupported);
324
325                         printf("\n");
326                         DisplaySystemCapabilities(response.SystemCapabilitiesSupported);
327
328                         printf("\n");
329                         DisplaySystemFirmwareCapabilities(response.SystemFirmwareCapabilities);
330
331                         printf("\n");
332                 }
333                 else
334                 {
335                         PrintSuccess();
336                 }
337         }
338
339         return status;
340 }
341
342 /*
343  * Controls remotely (using SOAP) the boot and power state of 
344  * Intel(R) AMT-managed PC.
345  * Arguments:
346  *  server      - pointer to the runtime environment 
347  *  url         - address of the web service 
348  *  def_values - if false request values from user  
349  * Return value:
350  *  true  - on success
351  *  false - on failure
352  */
353 bool ExecuteRemoteControl(Soap* server,bool def_values, uint8 icommand)
354 {
355         int res;
356         bool status = true;
357
358         server->Init();
359
360         // gSOAP structures for handling 
361         // request and response information
362         _rci__RemoteControl request;
363         _rci__RemoteControlResponse response;
364
365         // example values
366         uint8 *command = new uint8(icommand);
367         uint32 *ianaOemNumber = new uint32(IntelIanaNumber);
368         uint8 *specialCommand = NULL; //none
369         uint16 *oemParameter = NULL; //none
370         uint16 *bootOptions = NULL; //none
371         uint16 *specialCommandParameters = NULL; //none
372
373         if(!def_values)
374         {
375                 // To use default values above, comment the following line.
376                 if(!GetUserValues(command, ianaOemNumber, specialCommand, oemParameter, 
377                         bootOptions, specialCommandParameters))
378                 {
379                         status = false;
380                 }
381         }
382
383         if(status == true)
384         {
385                 switch(*command)
386                 {
387                 case Reset:
388                         request.Command = rci__RemoteControlCommandType__16;
389                         break;
390                 case PowerUp:
391                         request.Command = rci__RemoteControlCommandType__17;
392                         break;
393                 case PowerDown:
394                         request.Command = rci__RemoteControlCommandType__18;
395                         break;
396                 case PowerCycleReset:
397                         request.Command = rci__RemoteControlCommandType__19;
398                         break;
399                 case SetBootOptions:
400                         request.Command = rci__RemoteControlCommandType__33;
401                         break;
402                 default:
403                         break;
404                 }
405
406                 if(specialCommand == NULL)
407                 {
408                         request.SpecialCommand = NULL;
409                 }
410                 else
411                 {
412                         request.SpecialCommand = new rci__SpecialCommandType;
413                         switch(*specialCommand)
414                         {
415                         case NOP:
416                                 *(request.SpecialCommand) = rci__SpecialCommandType__0;
417                                 break;
418                         case ForcePxeBoot:
419                                 *(request.SpecialCommand) = rci__SpecialCommandType__1;
420                                 break;
421                         case ForceHardDriveBoot:
422                                 *(request.SpecialCommand) = rci__SpecialCommandType__2;
423                                 break;
424                         case ForceHardDriveSafeModeBoot:
425                                 *(request.SpecialCommand) = rci__SpecialCommandType__3;
426                                 break;
427                         case ForceDiagnosticsBoot:
428                                 *(request.SpecialCommand) = rci__SpecialCommandType__4;
429                                 break;
430                         case ForceCdOrDvdBoot:
431                                 *(request.SpecialCommand) = rci__SpecialCommandType__5;
432                                 break;
433                         case IntelOemCommand:
434                                 *(request.SpecialCommand) = rci__SpecialCommandType__193;
435                                 break;
436                         default:
437                                 break;
438                         }
439                 }
440
441                 request.IanaOemNumber = *ianaOemNumber;
442                 request.BootOptions = bootOptions;
443                 request.OEMparameters = oemParameter;
444                 request.SpecialCommandParameter = specialCommandParameters;
445
446                 FunctionCall("RemoteControl");  
447                 res = soap_call___rci__RemoteControl(server->GetSoap(),
448                         server->GetIp(),NULL, &request, &response);
449
450                 if((status = CheckReturnStatus(res,response.Status,"RemoteControl")) == true)
451                 {
452                         PrintSuccess();
453                 }
454
455                 if(request.SpecialCommand != NULL)
456                 {
457                         delete request.SpecialCommand;
458                         request.SpecialCommand = NULL;
459                 }
460         }
461
462         // cleanup heap allocated memory 
463         if(command != NULL)
464         {
465                 delete command;
466                 command = NULL;
467         }
468         if(ianaOemNumber != NULL)
469         {
470                 delete ianaOemNumber;
471                 ianaOemNumber = NULL;
472         }
473         if(specialCommand != NULL)
474         {
475                 delete specialCommand;
476                 specialCommand = NULL;
477         }
478         if(oemParameter != NULL)
479         {
480                 delete oemParameter;
481                 oemParameter = NULL;
482         }
483         if(bootOptions != NULL)
484         {
485                 delete bootOptions;
486                 bootOptions = NULL;
487         }
488         if(specialCommandParameters != NULL)
489         {
490                 delete specialCommandParameters;
491                 specialCommandParameters = NULL;
492         }
493
494         return status;
495 }
496
497 /*
498  * Get user's settings for the RemoteControl function
499  * Arguments & return values:
500  *      command - specifies the boot or power state operation to be performed
501  *      ianaOemNumber   - specifies an IANA-assigned Enterprise Number
502  *      specialCommand  - specifies an optional modification to the boot behavior
503  *      OemParameter    - specifies IntelĀ® AMT proprietary boot options 
504  *      bootOptions             - specifies standard boot options 
505  *      specialCommandParameters - specifies an optional modification to the 
506  *                                                         boot behavior
507  * Return value:
508  *  true  - on success
509  *  false - on failure
510  */
511 bool GetUserValues(uint8 *&command, uint32 *&ianaOemNumber, 
512                                    uint8 *&specialCommand, uint16 *&oemParameter, 
513                                    uint16 *&bootOptions, uint16 *&specialCommandParameters)
514 {
515         uint32 tmp;
516
517         printf("Please specify the following parameters\n");
518
519         // Get mandatory parameters
520
521         // Get Command
522         printf("\n\tCommand");
523     printf("\n\t=======");
524         printf("\nPossible values:");
525         printf("\n\t%u (Reset)",Reset);
526         printf("\n\t%u (PowerUp)",PowerUp);
527         printf("\n\t%u (PowerDown)",PowerDown);
528         printf("\n\t%u (PowerCycleReset)",PowerCycleReset);
529         printf("\n\t%u (SetBootOptions)\n>",SetBootOptions);
530         scanf("%u", &tmp);
531
532         // verify command value 
533         if ( tmp == Reset ||
534                  tmp == PowerUp ||
535                  tmp == PowerDown ||
536                  tmp == PowerCycleReset ||
537                  tmp == SetBootOptions)
538         {
539                 // sanity check
540                 if ( command == NULL )
541                 {
542                         command = new uint8();
543                 }
544                 *command = (uint8)tmp;
545         }
546         else
547         {
548                 goto ILLEGAL_INPUT;
549         }
550
551         // If command is Set Boot Options, ianaOemNumber 
552         // should be IntelIanaNumber.
553         if( *command == SetBootOptions )
554         {
555                 // sanity check
556                 if ( ianaOemNumber == NULL )
557                 {
558                         ianaOemNumber = new uint32();
559                 }
560
561                 printf("\nSetBootOptions command selected. ");
562                 printf("Iana OEM Number is IntelIanaNumber (%u)\n",IntelIanaNumber);
563
564                 *ianaOemNumber = (uint32)IntelIanaNumber;
565
566         }
567         else
568         {
569                 // Get Iana number
570                 printf("\n\tIana OEM Number");
571         printf("\n\t===============");
572                 printf("\nPossible values:");
573                 printf("\n\t%u (IntelIanaNumber)", IntelIanaNumber);
574                 printf("\n\t%u (ASFIanaNumber)\n>", ASFIanaNumber);
575                 scanf("%u", &tmp);
576
577                 // verify ianaOemNumber value
578                 if ( tmp == IntelIanaNumber ||
579                         tmp == ASFIanaNumber )
580                 {
581                         // sanity check
582                         if ( ianaOemNumber == NULL )
583                         {
584                                 ianaOemNumber = new uint32();
585                         }
586                         *ianaOemNumber = (uint32)tmp;
587                 }
588                 else
589                 {
590                         goto ILLEGAL_INPUT;
591                 }
592         }
593
594         // if power down, all other parameters should not be sent.
595         if ( *command == PowerDown )
596         {
597                 specialCommand = NULL;
598                 oemParameter = NULL;
599                 bootOptions = NULL;
600                 specialCommandParameters = NULL;
601                 return true;
602         }
603
604         // Get optional parameters
605
606         // Get Special Command
607         printf("\n\tSpecial Command");
608     printf("\n\t===============");
609         printf("\nPossible values:");
610
611         printf("\n\t%d (No Special Command)",-1);
612         printf("\n\t%u (NOP)",NOP);
613         printf("\n\t%u (ForcePxeBoot)",ForcePxeBoot);
614         printf("\n\t%u (ForceHardDriveBoot)",ForceHardDriveBoot);
615         printf("\n\t%u (ForceHardDriveSafeModeBoot)",ForceHardDriveSafeModeBoot);
616         printf("\n\t%u (ForceDiagnosticsBoot)",ForceDiagnosticsBoot);
617         printf("\n\t%u (ForceCdOrDvdBoot)",ForceCdOrDvdBoot);
618         printf("\n\t%u (IntelOemCommand)\n>",IntelOemCommand);
619         scanf("%u", &tmp);
620
621         // verify specialCommand value
622         if ( tmp == NO_VALUE ||
623                  tmp == NOP ||
624                  tmp == ForcePxeBoot ||
625                  tmp == ForceHardDriveBoot ||
626                  tmp == ForceHardDriveSafeModeBoot ||
627                  tmp == ForceDiagnosticsBoot ||
628                  tmp == ForceCdOrDvdBoot ||
629                  tmp == IntelOemCommand )
630         {
631                 if ( tmp == NO_VALUE )
632                 {
633                         specialCommand = NULL;
634                 }
635         else if(tmp == IntelOemCommand &&
636                 *ianaOemNumber != IntelIanaNumber)
637         {
638             printf("Error: Special Command value %d is legal", IntelOemCommand);
639             printf(" only for IanaOemNumber value %d", IntelIanaNumber);
640             exit(1);
641         }
642                 else
643                 {
644                         // sanity check
645                         if ( specialCommand == NULL )
646                         {
647                                 specialCommand = new uint8();
648                         }
649                         *specialCommand = (uint8)tmp;
650                 }
651         }
652         else
653         {
654                 goto ILLEGAL_INPUT;
655         }
656
657         // Get OEM Parameter
658         // if ianaOemNumber is ASFIanaNumber, oemParameters should not be sent .
659         if ( *ianaOemNumber != IntelIanaNumber )
660         {
661                 oemParameter = NULL;
662         }
663         else
664         {
665                 printf("\n\tOEM Parameters");
666         printf("\n\t==============");
667         printf("\nPossible values:");
668         printf("\n\t%d (No OEM Parameters)",-1);
669                 printf("\n\t%d (Undefined OEM Parameter)",UndefinedOEMParameter);
670                 printf("\n\t%u (UseSol)\n>",UseSol);
671                 scanf("%u", &tmp);
672                 if ( tmp == NO_VALUE )
673                 {
674                         oemParameter = NULL;
675                 }
676                 else
677                 {
678                         // sanity check
679                         if ( oemParameter == NULL )
680                         {
681                                 oemParameter = new uint16();
682                         }
683                         *oemParameter = (uint16) tmp;
684                 }
685         }
686
687         // Get Special Command Parameters
688         printf("\n\tSpecial Command Parameters");
689     printf("\n\t==========================");
690         printf("\nPossible values:");
691
692         // Special Command is not equal to 0xC1 (IntelOemCommand)
693         if ( specialCommand == NULL ||
694                 (specialCommand != NULL) && (*specialCommand != IntelOemCommand) )
695         {
696                 printf("\n\tSpecial command not equal to %d",IntelOemCommand);
697                 printf("\n\tSee ASF specification for the Special Command Parameter legal values");
698                 printf("\n\n\t%d (No Special Command Parameter)\n>",-1);
699                 scanf("%u", &tmp);
700         }
701         // Special Command is 0xC1, hence Special Command Parameter
702         // used to augment the Special Command
703         else
704         {
705                 printf("\n\t%d (No Special Command Parameter)",-1);
706         printf("\n\t%d (Undefined Special Command Parameter)",
707             UndefinedSpecialCommandParameter);
708                 printf("\n\t%u (UseIderFloppy)",UseIderFloppy);
709                 printf("\n\t%u (ReflashBios)",ReflashBios);
710                 printf("\n\t%u (BiosSetup)",BiosSetup);
711                 printf("\n\t%u (BiosPause)",BiosPause);
712                 printf("\n\t%u (UseIderCD)\n",UseIderCD);
713
714                 printf("\nYou can choose several options by using bitwise OR operation\n\n>");
715                 scanf("%u", &tmp);
716
717                 // verify specialCommandParameters value
718                 if ( (tmp != NO_VALUE) && (tmp & SpecialCommandParametersReservedBits) )
719                 {
720                         goto ILLEGAL_INPUT;
721                 }
722         }
723
724         if ( tmp == NO_VALUE )
725         {
726                 specialCommandParameters = NULL;
727         }
728         else
729         {
730                 // sanity check
731                 if ( specialCommandParameters == NULL )
732                 {
733                         specialCommandParameters = new uint16();
734                 }
735                 *specialCommandParameters = (uint16)tmp;
736         }
737                 
738         
739
740         // Get Boot Options
741         printf("\n\tBoot Options");
742     printf("\n\t============");
743         printf("\nPossible values:");
744
745         printf("\n\t%d (No boot options)", -1);
746         printf("\n\t%u (LockPowerButton)",LockPowerButton);
747         printf("\n\t%u (LockResetButton)",LockResetButton);
748         printf("\n\t%u (LockKeyboard)",LockKeyboard);
749         printf("\n\t%u (LockSleepButton)",LockSleepButton);
750         printf("\n\t%u (UserPasswordBypass)",UserPasswordBypass);
751         printf("\n\t%u (ForceProgressEvents)",ForceProgressEvents);
752
753     printf("\n\n\tFirmware Verbosity Options:");
754     printf(  "\n\t---------------------------");
755         printf("\n\t%u (FirmwareVerbositySystemDefault)",FirmwareVerbositySystemDefault);
756         printf("\n\t%u (FirmwareVerbosityQuiet)",FirmwareVerbosityQuiet);
757         printf("\n\t%u (FirmwareVerbosityVerbose)",FirmwareVerbosityVerbose);
758         printf("\n\t%u (FirmwareVerbosityScreen)",FirmwareVerbosityScreen);
759         printf("\n\n\t%u (ConfigurationDataReset)\n",ConfigurationDataReset);
760
761         printf("\nYou can choose several options by using bitwise OR operation\n\n>");
762         scanf("%u", &tmp);
763
764         // verify bootOptions value
765         if ( (tmp != NO_VALUE) && (tmp & BootOptionsReservedBits) )
766         {
767                 goto ILLEGAL_INPUT;
768         }
769         else
770         {
771                 if ( tmp == NO_VALUE )
772                 {
773                         bootOptions = NULL;
774                 }
775                 else
776                 {
777                         // sanity check
778                         if ( bootOptions == NULL )
779                         {
780                                 bootOptions = new uint16();
781                         }
782                         *bootOptions = (uint16)tmp;
783                 }
784         }
785         return true;
786
787         ILLEGAL_INPUT:
788         printf("Error: %u is an illegal value. Aborting.\n", tmp);
789         return false;
790 }
791
792 /*
793  * Prints system capabilities supported by the Intel(R) AMT device
794  * Arguments:
795  *      systemCapabilitiesSupported     - set of flags that indicate the values
796  *                                                              the Intel(R) AMT device supports in the 
797  *                                                              Command parameter of the RemoteControl method
798  */
799 void DisplaySystemCapabilities(uint8 systemCapabilitiesSupported)
800 {
801         printf("\nSystemCapabilitiesSupported = %u", systemCapabilitiesSupported);
802
803         if ( systemCapabilitiesSupported & SuppPowerCycleReset )
804         {
805                 printf("\nPowerCycleReset ");
806         }
807         if ( systemCapabilitiesSupported & SuppPowerDown )
808         {
809                 printf("\nPowerDown ");
810         }
811         if ( systemCapabilitiesSupported & SuppPowerUp )
812         {
813                 printf("\nPowerUp ");
814         }
815         if ( systemCapabilitiesSupported & SuppReset )
816         {
817                 printf("\nReset");
818         }
819 }
820
821 /*
822  * Prints special commands supported by the Intel(R) AMT device
823  * Arguments:
824  *      specialCommandsSupported        - set of flags that indicate the values
825  *                                                              the Intel(R) AMT device supports in the 
826  *                                                              SpecialCommand parameter of the 
827  *                                                              RemoteControl method
828  */
829 void DisplaySpecialCommand(uint16 specialCommandsSupported)
830 {
831         printf("\nSpecialCommandsSupported = %u", specialCommandsSupported);
832
833         if ( specialCommandsSupported & SuppForcePXEBoot )
834         {
835                 printf("\nForcePXEBoot ");
836         }
837         if ( specialCommandsSupported & SuppForceHardDriveBoot )
838         {
839                 printf("\nForceHardDriveBoot ");
840         }
841         if ( specialCommandsSupported & SuppForceHardDriveSafeModeBoot )
842         {
843                 printf("\nForceHardDriveSafeModeBoot ");
844         }
845         if ( specialCommandsSupported & SuppForceDiagnosticBoot )
846         {
847                 printf("\nForceDiagnosticBoot ");
848         }
849         if ( specialCommandsSupported & SuppForceCDorDVDBoot )
850         {
851                 printf("\nForceCDorDVDBoot");
852         }
853 }
854
855
856 /*
857  * Prints firmware capabilities supported by the Intel(R) AMT device
858  * Arguments:
859  *      systemCapabilitiesSupported     - set of flags that indicate the values
860  *                                                              the Intel(R) AMT device supports in the 
861  *                                                              BootOptions parameter of the RemoteControl 
862  *                                                              method
863  */
864 void DisplaySystemFirmwareCapabilities(uint32 systemFirmwareCapabilities)
865 {
866         printf("\nSystemFirmwareCapabilities = %u", systemFirmwareCapabilities);
867
868         if ( systemFirmwareCapabilities & SuppVerbosityScreenBlank )
869         {
870                 printf("\nVerbosityScreenBlank ");
871         }
872         if ( systemFirmwareCapabilities & SuppPowerButtonLock )
873         {
874                 printf("\nPowerButtonLock ");
875         }
876         if ( systemFirmwareCapabilities & SuppResetButtonLock )
877         {
878                 printf("\nResetButtonLock ");
879         }
880         if ( systemFirmwareCapabilities & SuppKeyboardLock )
881         {
882                 printf("\nKeyboardLock ");
883         }
884         if ( systemFirmwareCapabilities & SuppSleepButtonLock )
885         {
886                 printf("\nSleepButtonLock ");
887         }
888         if ( systemFirmwareCapabilities & SuppUserPasswordBypass )
889         {
890                 printf("\nUserPasswordBypass ");
891         }
892         if ( systemFirmwareCapabilities & SuppForcedProgressEvents )
893         {
894                 printf("\nForcedProgressEvents ");
895         }
896         if ( systemFirmwareCapabilities & SuppVerbosityVerbose )
897         {
898                 printf("\nVerbosityVerbose ");
899         }
900         if ( systemFirmwareCapabilities & SuppVerbosityQuiet )
901         {
902                 printf("\nVerbosityQuiet ");
903         }
904         if ( systemFirmwareCapabilities & SuppConfigurationDataReset )
905         {
906                 printf("\nConfigurationDataReset");
907         }
908 }
909
910
911 /*
912  * Prints OEM defined capabilities supported by the Intel(R) AMT device
913  * Arguments:
914  *      systemCapabilitiesSupported     - set of flags that indicate the values
915  *                                                              the Intel(R) AMT device supports in the 
916  *                                                              OemParameters parameter of the RemoteControl 
917  *                                                              method
918  */
919 void DisplayOemDefinedCapabilities(uint32 oemDefinedCapabilities)
920 {
921         printf("\nOemDefinedCapabilities = %u", oemDefinedCapabilities);
922
923         if ( oemDefinedCapabilities & SuppIDER )
924         {
925                 printf("\nIDER");
926         }
927         if ( oemDefinedCapabilities & SuppSOL )
928         {
929                 printf("\nSOL");
930         }
931         if ( oemDefinedCapabilities & SuppBiosReflash )
932         {
933                 printf("\nBiosReflash");
934         }
935         if ( oemDefinedCapabilities & SuppBiosSetup )
936         {
937                 printf("\nBiosSetup");
938         }
939         if ( oemDefinedCapabilities & SuppBiosPause )
940         {
941                 printf("\nBiosPause");
942         }
943 }
944