Last Modified: January 23, 1996

Using ACP Hooks - Applications

  

WARNING: This is currently an unsupported feature. Use it at your own risk. Xylogics will not provide porting assistance with this feature.

User Documentation:

For the first pass of this code to be integrated into R9.0, only the hooks will be implemented, and the upper-level code will be left as stub routines. The Annex code defaults to the old style (unhooked) operation if the erpcd in use is old or if the erpcd is compiled without implementing hooks.

This document briefly summarizes the work required for a user to implement several commonly-requested features. Since this requires the modification of acp_policy.c, it is assumed that only experienced users will attempt to do this. The upper-level code should be "productized" in the near future (perhaps by UBC) to allow easier configuration.

To add a macro-per-user capability:

  • Modify acp_validate to check for users with login profiles (perhaps as an added filename field in the acp_passwd file) and set a flag based on this. Don't worry about using static (or global) variables since each user session will be handled by a unique erpcd host process.
  • Modify port_to_annex to return REQ_GRANT_HOOK instead of REQ_GRANTED if this flag is set and set the hmask (hook callback mask) to CHOOK_PROMPTING
  • Modify hook_callback to intercept code HCB_BEFORE_PROMPT and call return_hook_callback(Acp,HCB_RETURN,) to return the next CLI command. If this is just an initialization macro and the user should get full CLI access after the macro is done, then use HCB_TERMINATE in place of HCB_RETURN on the last command and call terminate(). Otherwise, you may want to return hangup -q to prohibit access to the CLI. Substitute a return_hook_callback(Acp,HCB_PENDING,NULL) for the first call and hook_callback_string(Acp,HCB_RETURN,) for the second if use of promptstring/outputstring is needed during macro/script execution.

To add an "automatic telnet" capability (unknown CLI commands are automatically used as host names):

  • Modify acp_validate, if necessary, as above. If this feature should be shared by all users, then no modification is necessary.
  • Modify port_to_annex to return REQ_GRANT_HOOK instead of REQ_GRANTED for the appropriate users and set the hmask hook callback mask) to CHOOK_BADCMND
  • Modify hook_callback to intercept code HCB_BAD_COMMAND and build a string (perhaps with strcpy/strcat) which has "telnet " concatenated with the passed-in command line. Call return_hook_callback(Acp,HCB_RETURN,string) (or hook_callback_string if HCB_PENDING has already been called.)

To add new CLI commands (such as ch_passwd) which execute on the host ,or host-resident scripts/command languages:

  • Modify acp_validate, if necessary, as above. If this feature should be shared by all users, then no modification is necessary.
  • Modify port_to_annex to return REQ_GRANT_HOOK instead of REQ_GRANTED for the appropriate users and set the hmask hook callback mask) to CHOOK_USERLINE
  • Modify hook_callback to intercept code HCB_USER_LINE and inspect the passed-in command line. If it contains your new command, then call return_hook_callback(Acp,HCB_PENDING,NULL) to permit the outputstring function to work, and use this function to return the results of your command. Then call hook_callback_string(Acp,HCB_RETURN,"") to free up the CLI.

View Document 66K

Copyright (C) 1999 Nortel Networks Corporation, All rights reserved.