For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

beefy80's avatar
beefy80
Icon for Nimbostratus rankNimbostratus
Nov 11, 2019

EBCDIC to ASCII conversion

Hello!

 

I am trying to convert a string from EBCDIC to ASCII however I have found out the hard way that the encoding function is not available in TCL / iRules on F5. I have been researching how to possibly achieve this in an alternate way however I have hit a blank. Anyone got any ideas how I can achieve this? I am running 13.1.1.5.

 

Thanks James!

4 Replies

  • The enconding command exists in the tcl version used in F5 but is not available via iRules as you pointed out.

    [root@LABBIGIP1:Active:Changes Pending] images # tclsh
    % encoding convertto ebcdic "EXAMPLE"
    ÅçÁÔ×ÓÅ

    When I try via iRules:

    when HTTP_REQUEST {
        log local0. [encoding convertto ebcdic "EXAMPLE"]
    }
    Nov 11 17:51:20 LABBIGIP1 err tmm2[22248]: 01220001:3: TCL error: /Common/test1 <HTTP_REQUEST> - invalid command name "encoding"     while executing "encoding convertto ebcdic "EXAMPLE""

    One possible solution is to try to build the conversion yourself, using string map:

    when HTTP_REQUEST {
        log local0. [string map [list "Å" "b"] "Åbc"]
    }
    Nov 11 18:19:04 LABBIGIP1 info tmm5[22248]: Rule /Common/test1 <HTTP_REQUEST>: bbc

    If you can't do the mapping this way, you will have to look mapping using hex or binary.

  • Leonardo

     

    Thank you for the reply. Your suggestion of using a string map is something I thought about but was hoping there maybe a better way. I did read somewhere that iRulesLX can do it but I'll be honest to say that I would not know where to start with that.

     

    James

  • I have the same issue. I've tried the string list / string map approach both with a list declaration AND programatically and I can't get past the LTM validation.

    The declaration approach and code approach both work fine in a local TCL shell, but blow up the LTM validation step.

    Get this: the string list declaration version even blows up the validation step WHEN IT'S COMMENTED OUT.

    Error is always the same, regardless of declaration or programmatic version:

    01070151:3: Rule [/Common/ISO8583-EXTRACT] error: /Common/ISO8583-EXTRACT:75: error: [braces are required around the expression][proc getEbcdicMap {} {

     

    Surely someone has gotten past this before. But HOW?