[hipl-dev] adding hipconf actions and parameters

  • From: Dongsu Park <dpark1978@xxxxxxxxx>
  • To: hipl-dev <hipl-dev@xxxxxxxxxxxxx>
  • Date: Tue, 16 Sep 2008 16:06:31 +0200

Hi,

as I have recently experienced some problems with adding a new action
for hipconf, I wrote an introductory article about how to add actions
for hipconf and committed as doc/HACKING.

Below is my article:


ADDING HIPCONF ACTIONS AND PARAMETERS
=====================================

If you want to add some actions and parameters for hipconf, do the following
things carefully. Otherwise your codes could cause bugs not only for hipconf
but also for hipd.

Assume that you want to add an action named as 'NEWACT'.

1.1. ACTION_NEWACT in libinet6/hipconf.h
----------------------------------------
Define a constant ACTION_NEWACT which has value between 0 and ACTION_MAX.
Probably you also need to increase the value of ACTION_MAX.

1.2. hip_conf_get_action() in libinet6/hipconf.c
------------------------------------------------
Add a proper sentence in the strcmp() series, like that:

    ...
    else if (!strcmp("newaction", text))
        ret = ACTION_NEWONE;
    ...

1.3. hip_conf_check_action_argc() in libinet6/hipconf.c
-------------------------------------------------------
Add a case block for your ACTION_NEWACT constant in the switch(action)
block.

1.4. hip_conf_get_type_arg() in libinet6/hipconf.c
--------------------------------------------------
Add a case block for your ACTION_NEWACT constant in the switch(action)
block.

2.1. SO_HIP_NEWMODE in libinet6/icomm.h
---------------------------------------
Define a constant SO_HIP_NEWMODE which has value between 0 and
HIP_SO_ROOT_MAX. Take also care of the value of HIP_SO_ROOT_MAX.

2.2. hip_handle_user_msg() in hipd/user.c
-----------------------------------------
Add a case block for your SO_HIP_NEWMODE constant in the
switch(msg_type) block.

2.3. hip_message_type_name() in libinet6/builder.c
--------------------------------------------------
Add a case block for your SO_HIP_NEWMODE constant in the
switch(msg_type) block.
In this case, you just need to return the same string as the constant.

3.1. action_handler[] in libinet6/hipconf.c
-------------------------------------------
Add a handler function for your new action in the action_handler[] array.
NOTE: the location and the order of these handlers are important, because
each entry of the handler array is to be accessed via type index.

3.2. TYPE_NEWTYPE in libinet6/hipconf.h
---------------------------------------
Define a constant TYPE_NEWTYPE which has value between 0 and TYPE_MAX.
Probably you also need to increase the value of TYPE_MAX.
NOTE: the value of TYPE_NEWTYPE must be a correct index for looking up
each handler function in action_handler[], which you just added above
at the step 3.1.

3.3. hip_conf_handle_NEWACT() in libinet6/hipconf.c
---------------------------------------------------
Define a handler function added above at the step 3.1, somewhere in
hipconf.c.

3.4. hip_conf_handle_NEWACT() in libinet6/hipconf.h
---------------------------------------------------
Declare a prototype for your new handler function hip_conf_handle_NEWACT
defined above at the step 3.1.

4. hipconf_usage in libinet6/hipconf.c
--------------------------------------
Add a simple usage for your new action in the usage string.

Other related posts:

  • » [hipl-dev] adding hipconf actions and parameters