move pcucontrol package into pcucontrol module.
[pcucontrol.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,PowerDown)) == false)
179                         {
180                                 return status;
181                         }
182                         sleep(10); */
183                         if ((status = ExecuteRemoteControl(server,true,PowerUp)) == false)
184                         {
185                                 return status;
186                         }
187                         sleep(5);
188                         if ((status = ExecuteRemoteControl(server,true,Reset)) == false)
189                         {
190                                 return status;
191                         }
192                         break;
193                 case OPT_REDUCED_API_TEST:                      
194                         if((status = ExecuteGetSystemPowerstate(server,verbose)) == false)
195                         {
196                                 return status;
197                         }
198                         if((status = ExecuteGetRemoteControlCapabilities(server,verbose)) == false)
199                         {
200                                 return status;
201                         }       
202                         break;
203                 default:
204                         status = false;
205         }
206
207         return status;
208 }
209
210 /*
211  * Prints a usage information for the user.
212  */
213 void Usage(char *cmd)
214 {
215         printf("Usage:\n");
216 #ifndef _WIN32
217     printf("\t %s <opt> [%s] [%s <name> %s <pass>] http[s]:", cmd, VERBOSE, CERT_NAME, CERT_PASS);
218 #else
219         printf("\t %s <opt> [%s] [%s <username> %s <password>] [%s <name>] http[s]:", 
220         cmd, VERBOSE, USER, PASS, CERT_NAME);
221 #endif
222         printf("//<Hostname>:<Port>/<RemoteControlUri> ");
223 #ifndef _WIN32
224         printf("[%s <username> %s <password>]\n",USER,PASS); 
225 #endif
226         printf("\nWhere <opt> is :\n");
227         printf("\t %s : GetSystemPowerstate\n",POWER);
228         printf("\t %s : GetRemoteControlCapabilities\n",CAPABILITIES);
229         printf("\t %s : RemoteControl\n",REMOTE);
230         printf("\t %s : perform API test\n",API_TEST);
231         printf("\t %s : perform API test without boot\n",REDUCED_API_TEST);
232         printf("\t To run API test in verbose mode include %s option\n", VERBOSE);
233         PrintAuthenticationNote();
234         printf("\nExample:\n");
235         printf("\t %s %s ", cmd, POWER);
236         printf("http://hostname:16992/RemoteControlService\n");
237 #ifndef _WIN32
238     printf("\t %s %s %s MyCert %s Pass https://hostname:16993/RemoteControlService\n",   
239         cmd, POWER, CERT_NAME, CERT_PASS);
240 #else
241         printf("\t %s %s %s MyCert https://hostname:16993/RemoteControlService\n",   
242                 cmd, POWER, CERT_NAME);
243 #endif
244 }
245
246 /*
247  * Queries (using SOAP) and display the system power state
248  * Arguments:
249  *  server      - pointer to the runtime environment 
250  *  url         - address of the web service            
251  *  verbose - boolean value for API test 
252  * Return value:
253  *  true  - on success
254  *  false - on failure
255  */
256 bool ExecuteGetSystemPowerstate(Soap* server, bool verbose)
257 {
258         int res;
259         bool status;
260
261         server->Init();
262
263         // gSOAP structures for handling 
264         // request and response information
265         _rci__GetSystemPowerState request;
266         _rci__GetSystemPowerStateResponse response;
267
268         FunctionCall("GetSystemPowerState");    
269         res = soap_call___rci__GetSystemPowerState(server->GetSoap(),
270                 server->GetIp(),NULL, &request, &response);
271
272         if((status = 
273                 CheckReturnStatus(res,
274                 response.Status,
275                 "GetSystemPowerState")) == true)
276         {
277                 if(verbose)
278                 {
279                         printf("\nSystemPowerstate is: %u\n", response.SystemPowerState);
280                 }
281                 else
282                 {
283                         PrintSuccess();
284                 }
285         }
286
287         return status;
288 }
289
290 /*
291  * Queries (using SOAP) and display the Intel(R) AMT
292  * device remote control capabilities
293  * Arguments:
294  *  server      - pointer to the runtime environment 
295  *  url         - address of the web service
296  *  verbose - boolean value for API test 
297  * Return value:
298  *  true  - on success
299  *  false - on failure
300  */
301 bool ExecuteGetRemoteControlCapabilities(Soap* server, bool verbose)
302 {
303         int res;
304         bool status;
305
306         server->Init();
307
308         // gSOAP structures for handling 
309         // request and response information
310         _rci__GetRemoteControlCapabilities request;
311         _rci__GetRemoteControlCapabilitiesResponse response;
312
313         FunctionCall("GetRemoteControlCapabilities");   
314         res = soap_call___rci__GetRemoteControlCapabilities(server->GetSoap(), 
315                 server->GetIp(),NULL, &request, &response);
316
317         if((status = CheckReturnStatus(res,response.Status,"GetRemoteControlCapabilities")) == true)
318         {
319                 if(verbose)
320                 {
321                         printf("\nRemote Control Capabilities\n");
322                         printf("---------------------------------------\n");
323
324                         printf("IanaOemNumber = %u\n", response.IanaOemNumber);
325
326                         DisplayOemDefinedCapabilities(response.OemDefinedCapabilities);
327
328                         printf("\n");
329                         DisplaySpecialCommand(response.SpecialCommandsSupported);
330
331                         printf("\n");
332                         DisplaySystemCapabilities(response.SystemCapabilitiesSupported);
333
334                         printf("\n");
335                         DisplaySystemFirmwareCapabilities(response.SystemFirmwareCapabilities);
336
337                         printf("\n");
338                 }
339                 else
340                 {
341                         PrintSuccess();
342                 }
343         }
344
345         return status;
346 }
347
348 /*
349  * Controls remotely (using SOAP) the boot and power state of 
350  * Intel(R) AMT-managed PC.
351  * Arguments:
352  *  server      - pointer to the runtime environment 
353  *  url         - address of the web service 
354  *  def_values - if false request values from user  
355  * Return value:
356  *  true  - on success
357  *  false - on failure
358  */
359 bool ExecuteRemoteControl(Soap* server,bool def_values, uint8 icommand)
360 {
361         int res;
362         bool status = true;
363
364         server->Init();
365
366         // gSOAP structures for handling 
367         // request and response information
368         _rci__RemoteControl request;
369         _rci__RemoteControlResponse response;
370
371         // example values
372         uint8 *command = new uint8(icommand);
373         uint32 *ianaOemNumber = new uint32(IntelIanaNumber);
374         uint8 *specialCommand = NULL; //none
375         uint16 *oemParameter = NULL; //none
376         uint16 *bootOptions = NULL; //none
377         uint16 *specialCommandParameters = NULL; //none
378
379         if(!def_values)
380         {
381                 // To use default values above, comment the following line.
382                 if(!GetUserValues(command, ianaOemNumber, specialCommand, oemParameter, 
383                         bootOptions, specialCommandParameters))
384                 {
385                         status = false;
386                 }
387         }
388
389         if(status == true)
390         {
391                 switch(*command)
392                 {
393                 case Reset:
394                         request.Command = rci__RemoteControlCommandType__16;
395                         break;
396                 case PowerUp:
397                         request.Command = rci__RemoteControlCommandType__17;
398                         break;
399                 case PowerDown:
400                         request.Command = rci__RemoteControlCommandType__18;
401                         break;
402                 case PowerCycleReset:
403                         request.Command = rci__RemoteControlCommandType__19;
404                         break;
405                 case SetBootOptions:
406                         request.Command = rci__RemoteControlCommandType__33;
407                         break;
408                 default:
409                         break;
410                 }
411
412                 if(specialCommand == NULL)
413                 {
414                         request.SpecialCommand = NULL;
415                 }
416                 else
417                 {
418                         request.SpecialCommand = new rci__SpecialCommandType;
419                         switch(*specialCommand)
420                         {
421                         case NOP:
422                                 *(request.SpecialCommand) = rci__SpecialCommandType__0;
423                                 break;
424                         case ForcePxeBoot:
425                                 *(request.SpecialCommand) = rci__SpecialCommandType__1;
426                                 break;
427                         case ForceHardDriveBoot:
428                                 *(request.SpecialCommand) = rci__SpecialCommandType__2;
429                                 break;
430                         case ForceHardDriveSafeModeBoot:
431                                 *(request.SpecialCommand) = rci__SpecialCommandType__3;
432                                 break;
433                         case ForceDiagnosticsBoot:
434                                 *(request.SpecialCommand) = rci__SpecialCommandType__4;
435                                 break;
436                         case ForceCdOrDvdBoot:
437                                 *(request.SpecialCommand) = rci__SpecialCommandType__5;
438                                 break;
439                         case IntelOemCommand:
440                                 *(request.SpecialCommand) = rci__SpecialCommandType__193;
441                                 break;
442                         default:
443                                 break;
444                         }
445                 }
446
447                 request.IanaOemNumber = *ianaOemNumber;
448                 request.BootOptions = bootOptions;
449                 request.OEMparameters = oemParameter;
450                 request.SpecialCommandParameter = specialCommandParameters;
451
452                 FunctionCall("RemoteControl");  
453                 res = soap_call___rci__RemoteControl(server->GetSoap(),
454                         server->GetIp(),NULL, &request, &response);
455
456                 if((status = CheckReturnStatus(res,response.Status,"RemoteControl")) == true)
457                 {
458                         PrintSuccess();
459                 }
460
461                 if(request.SpecialCommand != NULL)
462                 {
463                         delete request.SpecialCommand;
464                         request.SpecialCommand = NULL;
465                 }
466         }
467
468         // cleanup heap allocated memory 
469         if(command != NULL)
470         {
471                 delete command;
472                 command = NULL;
473         }
474         if(ianaOemNumber != NULL)
475         {
476                 delete ianaOemNumber;
477                 ianaOemNumber = NULL;
478         }
479         if(specialCommand != NULL)
480         {
481                 delete specialCommand;
482                 specialCommand = NULL;
483         }
484         if(oemParameter != NULL)
485         {
486                 delete oemParameter;
487                 oemParameter = NULL;
488         }
489         if(bootOptions != NULL)
490         {
491                 delete bootOptions;
492                 bootOptions = NULL;
493         }
494         if(specialCommandParameters != NULL)
495         {
496                 delete specialCommandParameters;
497                 specialCommandParameters = NULL;
498         }
499
500         return status;
501 }
502
503 /*
504  * Get user's settings for the RemoteControl function
505  * Arguments & return values:
506  *      command - specifies the boot or power state operation to be performed
507  *      ianaOemNumber   - specifies an IANA-assigned Enterprise Number
508  *      specialCommand  - specifies an optional modification to the boot behavior
509  *      OemParameter    - specifies IntelĀ® AMT proprietary boot options 
510  *      bootOptions             - specifies standard boot options 
511  *      specialCommandParameters - specifies an optional modification to the 
512  *                                                         boot behavior
513  * Return value:
514  *  true  - on success
515  *  false - on failure
516  */
517 bool GetUserValues(uint8 *&command, uint32 *&ianaOemNumber, 
518                                    uint8 *&specialCommand, uint16 *&oemParameter, 
519                                    uint16 *&bootOptions, uint16 *&specialCommandParameters)
520 {
521         uint32 tmp;
522
523         printf("Please specify the following parameters\n");
524
525         // Get mandatory parameters
526
527         // Get Command
528         printf("\n\tCommand");
529     printf("\n\t=======");
530         printf("\nPossible values:");
531         printf("\n\t%u (Reset)",Reset);
532         printf("\n\t%u (PowerUp)",PowerUp);
533         printf("\n\t%u (PowerDown)",PowerDown);
534         printf("\n\t%u (PowerCycleReset)",PowerCycleReset);
535         printf("\n\t%u (SetBootOptions)\n>",SetBootOptions);
536         scanf("%u", &tmp);
537
538         // verify command value 
539         if ( tmp == Reset ||
540                  tmp == PowerUp ||
541                  tmp == PowerDown ||
542                  tmp == PowerCycleReset ||
543                  tmp == SetBootOptions)
544         {
545                 // sanity check
546                 if ( command == NULL )
547                 {
548                         command = new uint8();
549                 }
550                 *command = (uint8)tmp;
551         }
552         else
553         {
554                 goto ILLEGAL_INPUT;
555         }
556
557         // If command is Set Boot Options, ianaOemNumber 
558         // should be IntelIanaNumber.
559         if( *command == SetBootOptions )
560         {
561                 // sanity check
562                 if ( ianaOemNumber == NULL )
563                 {
564                         ianaOemNumber = new uint32();
565                 }
566
567                 printf("\nSetBootOptions command selected. ");
568                 printf("Iana OEM Number is IntelIanaNumber (%u)\n",IntelIanaNumber);
569
570                 *ianaOemNumber = (uint32)IntelIanaNumber;
571
572         }
573         else
574         {
575                 // Get Iana number
576                 printf("\n\tIana OEM Number");
577         printf("\n\t===============");
578                 printf("\nPossible values:");
579                 printf("\n\t%u (IntelIanaNumber)", IntelIanaNumber);
580                 printf("\n\t%u (ASFIanaNumber)\n>", ASFIanaNumber);
581                 scanf("%u", &tmp);
582
583                 // verify ianaOemNumber value
584                 if ( tmp == IntelIanaNumber ||
585                         tmp == ASFIanaNumber )
586                 {
587                         // sanity check
588                         if ( ianaOemNumber == NULL )
589                         {
590                                 ianaOemNumber = new uint32();
591                         }
592                         *ianaOemNumber = (uint32)tmp;
593                 }
594                 else
595                 {
596                         goto ILLEGAL_INPUT;
597                 }
598         }
599
600         // if power down, all other parameters should not be sent.
601         if ( *command == PowerDown )
602         {
603                 specialCommand = NULL;
604                 oemParameter = NULL;
605                 bootOptions = NULL;
606                 specialCommandParameters = NULL;
607                 return true;
608         }
609
610         // Get optional parameters
611
612         // Get Special Command
613         printf("\n\tSpecial Command");
614     printf("\n\t===============");
615         printf("\nPossible values:");
616
617         printf("\n\t%d (No Special Command)",-1);
618         printf("\n\t%u (NOP)",NOP);
619         printf("\n\t%u (ForcePxeBoot)",ForcePxeBoot);
620         printf("\n\t%u (ForceHardDriveBoot)",ForceHardDriveBoot);
621         printf("\n\t%u (ForceHardDriveSafeModeBoot)",ForceHardDriveSafeModeBoot);
622         printf("\n\t%u (ForceDiagnosticsBoot)",ForceDiagnosticsBoot);
623         printf("\n\t%u (ForceCdOrDvdBoot)",ForceCdOrDvdBoot);
624         printf("\n\t%u (IntelOemCommand)\n>",IntelOemCommand);
625         scanf("%u", &tmp);
626
627         // verify specialCommand value
628         if ( tmp == NO_VALUE ||
629                  tmp == NOP ||
630                  tmp == ForcePxeBoot ||
631                  tmp == ForceHardDriveBoot ||
632                  tmp == ForceHardDriveSafeModeBoot ||
633                  tmp == ForceDiagnosticsBoot ||
634                  tmp == ForceCdOrDvdBoot ||
635                  tmp == IntelOemCommand )
636         {
637                 if ( tmp == NO_VALUE )
638                 {
639                         specialCommand = NULL;
640                 }
641         else if(tmp == IntelOemCommand &&
642                 *ianaOemNumber != IntelIanaNumber)
643         {
644             printf("Error: Special Command value %d is legal", IntelOemCommand);
645             printf(" only for IanaOemNumber value %d", IntelIanaNumber);
646             exit(1);
647         }
648                 else
649                 {
650                         // sanity check
651                         if ( specialCommand == NULL )
652                         {
653                                 specialCommand = new uint8();
654                         }
655                         *specialCommand = (uint8)tmp;
656                 }
657         }
658         else
659         {
660                 goto ILLEGAL_INPUT;
661         }
662
663         // Get OEM Parameter
664         // if ianaOemNumber is ASFIanaNumber, oemParameters should not be sent .
665         if ( *ianaOemNumber != IntelIanaNumber )
666         {
667                 oemParameter = NULL;
668         }
669         else
670         {
671                 printf("\n\tOEM Parameters");
672         printf("\n\t==============");
673         printf("\nPossible values:");
674         printf("\n\t%d (No OEM Parameters)",-1);
675                 printf("\n\t%d (Undefined OEM Parameter)",UndefinedOEMParameter);
676                 printf("\n\t%u (UseSol)\n>",UseSol);
677                 scanf("%u", &tmp);
678                 if ( tmp == NO_VALUE )
679                 {
680                         oemParameter = NULL;
681                 }
682                 else
683                 {
684                         // sanity check
685                         if ( oemParameter == NULL )
686                         {
687                                 oemParameter = new uint16();
688                         }
689                         *oemParameter = (uint16) tmp;
690                 }
691         }
692
693         // Get Special Command Parameters
694         printf("\n\tSpecial Command Parameters");
695     printf("\n\t==========================");
696         printf("\nPossible values:");
697
698         // Special Command is not equal to 0xC1 (IntelOemCommand)
699         if ( specialCommand == NULL ||
700                 (specialCommand != NULL) && (*specialCommand != IntelOemCommand) )
701         {
702                 printf("\n\tSpecial command not equal to %d",IntelOemCommand);
703                 printf("\n\tSee ASF specification for the Special Command Parameter legal values");
704                 printf("\n\n\t%d (No Special Command Parameter)\n>",-1);
705                 scanf("%u", &tmp);
706         }
707         // Special Command is 0xC1, hence Special Command Parameter
708         // used to augment the Special Command
709         else
710         {
711                 printf("\n\t%d (No Special Command Parameter)",-1);
712         printf("\n\t%d (Undefined Special Command Parameter)",
713             UndefinedSpecialCommandParameter);
714                 printf("\n\t%u (UseIderFloppy)",UseIderFloppy);
715                 printf("\n\t%u (ReflashBios)",ReflashBios);
716                 printf("\n\t%u (BiosSetup)",BiosSetup);
717                 printf("\n\t%u (BiosPause)",BiosPause);
718                 printf("\n\t%u (UseIderCD)\n",UseIderCD);
719
720                 printf("\nYou can choose several options by using bitwise OR operation\n\n>");
721                 scanf("%u", &tmp);
722
723                 // verify specialCommandParameters value
724                 if ( (tmp != NO_VALUE) && (tmp & SpecialCommandParametersReservedBits) )
725                 {
726                         goto ILLEGAL_INPUT;
727                 }
728         }
729
730         if ( tmp == NO_VALUE )
731         {
732                 specialCommandParameters = NULL;
733         }
734         else
735         {
736                 // sanity check
737                 if ( specialCommandParameters == NULL )
738                 {
739                         specialCommandParameters = new uint16();
740                 }
741                 *specialCommandParameters = (uint16)tmp;
742         }
743                 
744         
745
746         // Get Boot Options
747         printf("\n\tBoot Options");
748     printf("\n\t============");
749         printf("\nPossible values:");
750
751         printf("\n\t%d (No boot options)", -1);
752         printf("\n\t%u (LockPowerButton)",LockPowerButton);
753         printf("\n\t%u (LockResetButton)",LockResetButton);
754         printf("\n\t%u (LockKeyboard)",LockKeyboard);
755         printf("\n\t%u (LockSleepButton)",LockSleepButton);
756         printf("\n\t%u (UserPasswordBypass)",UserPasswordBypass);
757         printf("\n\t%u (ForceProgressEvents)",ForceProgressEvents);
758
759     printf("\n\n\tFirmware Verbosity Options:");
760     printf(  "\n\t---------------------------");
761         printf("\n\t%u (FirmwareVerbositySystemDefault)",FirmwareVerbositySystemDefault);
762         printf("\n\t%u (FirmwareVerbosityQuiet)",FirmwareVerbosityQuiet);
763         printf("\n\t%u (FirmwareVerbosityVerbose)",FirmwareVerbosityVerbose);
764         printf("\n\t%u (FirmwareVerbosityScreen)",FirmwareVerbosityScreen);
765         printf("\n\n\t%u (ConfigurationDataReset)\n",ConfigurationDataReset);
766
767         printf("\nYou can choose several options by using bitwise OR operation\n\n>");
768         scanf("%u", &tmp);
769
770         // verify bootOptions value
771         if ( (tmp != NO_VALUE) && (tmp & BootOptionsReservedBits) )
772         {
773                 goto ILLEGAL_INPUT;
774         }
775         else
776         {
777                 if ( tmp == NO_VALUE )
778                 {
779                         bootOptions = NULL;
780                 }
781                 else
782                 {
783                         // sanity check
784                         if ( bootOptions == NULL )
785                         {
786                                 bootOptions = new uint16();
787                         }
788                         *bootOptions = (uint16)tmp;
789                 }
790         }
791         return true;
792
793         ILLEGAL_INPUT:
794         printf("Error: %u is an illegal value. Aborting.\n", tmp);
795         return false;
796 }
797
798 /*
799  * Prints system capabilities supported by the Intel(R) AMT device
800  * Arguments:
801  *      systemCapabilitiesSupported     - set of flags that indicate the values
802  *                                                              the Intel(R) AMT device supports in the 
803  *                                                              Command parameter of the RemoteControl method
804  */
805 void DisplaySystemCapabilities(uint8 systemCapabilitiesSupported)
806 {
807         printf("\nSystemCapabilitiesSupported = %u", systemCapabilitiesSupported);
808
809         if ( systemCapabilitiesSupported & SuppPowerCycleReset )
810         {
811                 printf("\nPowerCycleReset ");
812         }
813         if ( systemCapabilitiesSupported & SuppPowerDown )
814         {
815                 printf("\nPowerDown ");
816         }
817         if ( systemCapabilitiesSupported & SuppPowerUp )
818         {
819                 printf("\nPowerUp ");
820         }
821         if ( systemCapabilitiesSupported & SuppReset )
822         {
823                 printf("\nReset");
824         }
825 }
826
827 /*
828  * Prints special commands supported by the Intel(R) AMT device
829  * Arguments:
830  *      specialCommandsSupported        - set of flags that indicate the values
831  *                                                              the Intel(R) AMT device supports in the 
832  *                                                              SpecialCommand parameter of the 
833  *                                                              RemoteControl method
834  */
835 void DisplaySpecialCommand(uint16 specialCommandsSupported)
836 {
837         printf("\nSpecialCommandsSupported = %u", specialCommandsSupported);
838
839         if ( specialCommandsSupported & SuppForcePXEBoot )
840         {
841                 printf("\nForcePXEBoot ");
842         }
843         if ( specialCommandsSupported & SuppForceHardDriveBoot )
844         {
845                 printf("\nForceHardDriveBoot ");
846         }
847         if ( specialCommandsSupported & SuppForceHardDriveSafeModeBoot )
848         {
849                 printf("\nForceHardDriveSafeModeBoot ");
850         }
851         if ( specialCommandsSupported & SuppForceDiagnosticBoot )
852         {
853                 printf("\nForceDiagnosticBoot ");
854         }
855         if ( specialCommandsSupported & SuppForceCDorDVDBoot )
856         {
857                 printf("\nForceCDorDVDBoot");
858         }
859 }
860
861
862 /*
863  * Prints firmware capabilities supported by the Intel(R) AMT device
864  * Arguments:
865  *      systemCapabilitiesSupported     - set of flags that indicate the values
866  *                                                              the Intel(R) AMT device supports in the 
867  *                                                              BootOptions parameter of the RemoteControl 
868  *                                                              method
869  */
870 void DisplaySystemFirmwareCapabilities(uint32 systemFirmwareCapabilities)
871 {
872         printf("\nSystemFirmwareCapabilities = %u", systemFirmwareCapabilities);
873
874         if ( systemFirmwareCapabilities & SuppVerbosityScreenBlank )
875         {
876                 printf("\nVerbosityScreenBlank ");
877         }
878         if ( systemFirmwareCapabilities & SuppPowerButtonLock )
879         {
880                 printf("\nPowerButtonLock ");
881         }
882         if ( systemFirmwareCapabilities & SuppResetButtonLock )
883         {
884                 printf("\nResetButtonLock ");
885         }
886         if ( systemFirmwareCapabilities & SuppKeyboardLock )
887         {
888                 printf("\nKeyboardLock ");
889         }
890         if ( systemFirmwareCapabilities & SuppSleepButtonLock )
891         {
892                 printf("\nSleepButtonLock ");
893         }
894         if ( systemFirmwareCapabilities & SuppUserPasswordBypass )
895         {
896                 printf("\nUserPasswordBypass ");
897         }
898         if ( systemFirmwareCapabilities & SuppForcedProgressEvents )
899         {
900                 printf("\nForcedProgressEvents ");
901         }
902         if ( systemFirmwareCapabilities & SuppVerbosityVerbose )
903         {
904                 printf("\nVerbosityVerbose ");
905         }
906         if ( systemFirmwareCapabilities & SuppVerbosityQuiet )
907         {
908                 printf("\nVerbosityQuiet ");
909         }
910         if ( systemFirmwareCapabilities & SuppConfigurationDataReset )
911         {
912                 printf("\nConfigurationDataReset");
913         }
914 }
915
916
917 /*
918  * Prints OEM defined capabilities supported by the Intel(R) AMT device
919  * Arguments:
920  *      systemCapabilitiesSupported     - set of flags that indicate the values
921  *                                                              the Intel(R) AMT device supports in the 
922  *                                                              OemParameters parameter of the RemoteControl 
923  *                                                              method
924  */
925 void DisplayOemDefinedCapabilities(uint32 oemDefinedCapabilities)
926 {
927         printf("\nOemDefinedCapabilities = %u", oemDefinedCapabilities);
928
929         if ( oemDefinedCapabilities & SuppIDER )
930         {
931                 printf("\nIDER");
932         }
933         if ( oemDefinedCapabilities & SuppSOL )
934         {
935                 printf("\nSOL");
936         }
937         if ( oemDefinedCapabilities & SuppBiosReflash )
938         {
939                 printf("\nBiosReflash");
940         }
941         if ( oemDefinedCapabilities & SuppBiosSetup )
942         {
943                 printf("\nBiosSetup");
944         }
945         if ( oemDefinedCapabilities & SuppBiosPause )
946         {
947                 printf("\nBiosPause");
948         }
949 }
950