Hot!How to Disable/Enable The Web server in Harmony V1.11

Author
NKurzman
A Guy on the Net
  • Total Posts : 16433
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
2018/09/12 14:25:47 (permalink)
0

How to Disable/Enable The Web server in Harmony V1.11

They are doing a security scan, so this came up to.
I need to disable the Web Server and Close Port 80.
 
TCPIP_HTTP_NET_Deinitialize() ???  If so can it be brought back up?
 
Or is it the same issues as ICMP Ping?
 
#1

17 Replies Related Threads

    rainad
    Moderator
    • Total Posts : 1013
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: How to Disable/Enable The Web server in Harmony V1.11 2018/09/13 08:25:47 (permalink)
    0
    Unfortunately no way to do that right now other than what's been discussed about the ICMP.
    TCPIP_HTTP_Initialize/TCPIP_HTTP_NET_Deinitialize are not part of the API. They are internal functions that have some parameters not accessible from outside the stack.
    We'd need to create enable/disable functions for all modules if the functionality of network/stack down/up is not enough for you.
     
    Maybe you can make few comments about the usage model here so I can understand better: so you start with the HTTP server enabled, you keep it up for a while (I assume you need it) and then you want to disable it. Sometime later it needs to be brought up again. What exactly dictates this down/up operations?
     
    #2
    NKurzman
    A Guy on the Net
    • Total Posts : 16433
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: How to Disable/Enable The Web server in Harmony V1.11 2018/09/13 10:34:47 (permalink)
    0
    I this case the Web server is for Debugging only and needs to be off during normal use.
    I guess I need to make a dynamic copy of:
    const TCPIP_STACK_MODULE_CONFIG TCPIP_STACK_MODULE_CONFIG_TBL [] = {}
     
    removing the Items I do not want at initialization.
     
     
     
    #3
    rainad
    Moderator
    • Total Posts : 1013
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: How to Disable/Enable The Web server in Harmony V1.11 2018/09/13 15:38:38 (permalink)
    0
    Yes, that's the intended usage model: call stack initialize with just the modules that you need.
     
    #4
    NKurzman
    A Guy on the Net
    • Total Posts : 16433
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: How to Disable/Enable The Web server in Harmony V1.11 2018/09/13 16:02:20 (permalink)
    0
    I assume that const TCPIP_STACK_MODULE_CONFIG TCPIP_STACK_MODULE_CONFIG_TBL [] = {}
    does not need to be static?
    #5
    rainad
    Moderator
    • Total Posts : 1013
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: How to Disable/Enable The Web server in Harmony V1.11 2018/09/13 16:22:57 (permalink)
    0
    No need to be static, could be global if needed.
     
    #6
    NKurzman
    A Guy on the Net
    • Total Posts : 16433
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: How to Disable/Enable The Web server in Harmony V1.11 2018/09/13 16:44:26 (permalink)
    0
    I was thinking more of a local RAM array that I can copy to from the Harmony generated one.
     
    then copy to that in a modified version of TCPIP_STACK_Init()
     

    tcpipInit.moduleInit.sys.powerState = SYS_MODULE_POWER_RUN_FULL;
    tcpipInit.pNetConf = TCPIP_HOSTS_CONFIGURATION;
    tcpipInit.nNets = sizeof (TCPIP_HOSTS_CONFIGURATION) / sizeof (*TCPIP_HOSTS_CONFIGURATION);
     
     
    TCPIP_STACK_MODULE_CONFIG TCPIP_STACK_MODULE_CONFIG_TBL [sizeof (TCPIP_STACK_MODULE_CONFIG_TBL) / sizeof (*TCPIP_STACK_MODULE_CONFIG_TBL)];  Local variable?
    // load up MY_TCPIP_STACK_MODULE_CONFIG_TBL
    MyCount = The New Count;
     
    tcpipInit.pModConfig = MY_TCPIP_STACK_MODULE_CONFIG_TBL;
    tcpipInit.nModules = MyCount;
     
    return TCPIP_STACK_Initialize(0, &tcpipInit.moduleInit);
     

    post edited by NKurzman - 2018/09/13 16:45:58
    #7
    rainad
    Moderator
    • Total Posts : 1013
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: How to Disable/Enable The Web server in Harmony V1.11 2018/09/13 17:07:40 (permalink)
    0
    Yes, the whole initialization data structure can be in RAM, or pointer members to point to RAM locations. It doesn't need to be persistent after the call to the Initialize function.
     
    #8
    NKurzman
    A Guy on the Net
    • Total Posts : 16433
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: How to Disable/Enable The Web server in Harmony V1.11 2018/09/13 18:11:28 (permalink)
    0
    Ok, Thank you very Much.
    #9
    NKurzman
    A Guy on the Net
    • Total Posts : 16433
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: How to Disable/Enable The Web server in Harmony V1.11 2018/09/18 19:42:28 (permalink)
    0
    This appears to be more complicated.

    const TCPIP_STACK_MODULE_CONFIG TCPIP_STACK_MODULE_CONFIG_TBL [] =
     
    //{TCPIP_MODULE_ICMP, 0}, // TCPIP_MODULE_ICMP
    commenting that out does nothing.  It still responds to a PING.
     
    //{TCPIP_MODULE_HTTP_SERVER, &tcpipHTTPInitData}, // TCPIP_MODULE_HTTP_SERVER,
    commenting that out  kills the whole stack.
     
    So there is something else that affects this.
    #10
    rainad
    Moderator
    • Total Posts : 1013
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: How to Disable/Enable The Web server in Harmony V1.11 2018/09/20 09:39:28 (permalink)
    0
    I'll try to download the v1.11 and give it a try on my machine to see what's going on.
    I'll update you once I have some news for this.
     
    #11
    NKurzman
    A Guy on the Net
    • Total Posts : 16433
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: How to Disable/Enable The Web server in Harmony V1.11 2018/09/20 11:48:09 (permalink)
    0
    Thank You.
    #12
    rainad
    Moderator
    • Total Posts : 1013
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: How to Disable/Enable The Web server in Harmony V1.11 2018/09/21 09:57:19 (permalink)
    0
    Unfortunately I was wrong. The table with the stack modules is built in flash (saving RAM space...) at the build time.
    The initialization data that's passed to the TCPIP_STACK_Initialize() is meant to allow the changing of the module parameters, not to disable them.
    What happens is that ICMP doesn't need any initialization data and it will work OK, even if it doesn't show up in the initialization data structures.
    HTTP on the other hand will refuse to work if it's not configured properly, that's why the stack initialization will fail.
     
    To support what you need we have to:
    - build the tables at run time, based on the initialization data (not difficult to do but it will just consume some extra RAM. Probably the best thing here is to make it configurable). I'll add this feature to the TODO list, as it makes a lot of sense, IMO, especially when running the stack as a library.
    - provide on/off functionality for all modules, as we've discussed previously. This new feature is already captured but it is more time consuming because there are many modules. But more importantly it affects the run time processing of the RX traffic which cannot be based now solely on the build time settings.
     
    Sorry, but I don't have a quick workaround for this one, I'm afraid.
     
    #13
    NKurzman
    A Guy on the Net
    • Total Posts : 16433
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: How to Disable/Enable The Web server in Harmony V1.11 2018/09/21 15:07:02 (permalink)
    0
    Ok sad: sad it is what it is.
     
    I did make a RAM copy of the table.  it does work, if it is complete.
    I commented out the options in the const table as a debugging aid.
     
    If Add a disable function that calls TCPIP_HTTP_NET_Deinitialize()  will that do what I need?
    Since it is unsupported at the moment I can change it without worrying about updates for now.
    I guess can try MHC both ways and compare the code to see if an answer suggests itself.
    Or Look at the MLA Documentation since the 1.XX Stack is closer to that then 2.00 might be.
     
    Thank You for Looking in to it.
    #14
    rainad
    Moderator
    • Total Posts : 1013
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: How to Disable/Enable The Web server in Harmony V1.11 2018/09/24 08:55:42 (permalink)
    0
    To disable the module, you'll probably need to call
    _HTTP_CloseConnections(0); This will probably do - that function is currently static.
    But if you need to re-enable it at run time, you need to add some code in there, I think that it's easier than using TCPIP_HTTP_NET_Initialize() which needs access to all kind of internal data and structures.
     
    I think the best approach is to add Enable/Disable functions and the HTTP code to look at a variable that reflects that state. If it is disabled, its Task state does not do anything, simply return.
     
     
    #15
    NKurzman
    A Guy on the Net
    • Total Posts : 16433
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: How to Disable/Enable The Web server in Harmony V1.11 2018/09/24 09:19:00 (permalink)
    0
    I would need to close port 80 to pass the scan and insure that it is not tying up packets from the pool. Reenabling it run time is an option. But stopping the Http state machine from executing my be a safe point to stop it from opening any ports.
    #16
    rainad
    Moderator
    • Total Posts : 1013
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: How to Disable/Enable The Web server in Harmony V1.11 2018/09/24 13:17:34 (permalink)
    0
    The sockets are created in TCPIP_HTTP_Initialize(). The code that deals with that will have to be moved in its own function so it can be part of Enable when needed.
    Once the sockets are closed the HTTP task checks for sockets to be != INVALID_SOCKET before doing anything so it should be OK.
     
     
     
    #17
    NKurzman
    A Guy on the Net
    • Total Posts : 16433
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: How to Disable/Enable The Web server in Harmony V1.11 2018/09/24 16:16:59 (permalink)
    0
    I am at I will take what I can get at this point.  A reboot is Fine to enable /or disable.  I would like to avoid a recompile with a different configuration.  So that may work for me
     
    TCPIP_STACK_BringNetUp() or TCPIP_HTTP_Initialize() just returning false based on a disable flag should keep it inert I will need to test to make sure it does not kill the Stack.
     
    #18
    Jump to:
    © 2018 APG vNext Commercial Version 4.5