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