Forum Discussion
Ralf_Bruenig_74
Jun 02, 2008Historic F5 Account
workaround for 32 bit integer limitation
Hi all,
I need to extract the IP address out of the insert cookie. For this I found the following example on your page:
http://devcentral.f5.com/wiki/default.aspx/iRules/Persistence_Cookie_Logger.html
The problem is this works only for members with IP addresses a.b.c.d where d is < 128. This is most likely, because the integer of tcl is limited to 32 bit minus 1 bit for the sign.
Is there any way around this problem?
Thanks for your answer.
Ralf
2 Replies
- Deb_Allen_18Historic F5 AccountI found an interesting post with some suggestions to force from integer to float - Click here
I guess I'd try forcing to scientific notation first:
Hume Smith gave a clever solution in news:comp.lang.tcl :
append i "e0"
makes it look like scientific notation, meaning "multiplied by 10 to the 0th power, which is 1", which forces the string to a floatstring (i.e. that expr interprets as double) with pure string manipulation.
If I understand the recommendation correctly, you might be able to just change these 2 lines of code:set myIpH [format %08x $myIpE] set myPortH [format %x $myPortE]
to this:set myIpH [format %08x $myIpE] append "e0" myIpH set myPortH [format %x $myPortE] append "e0" myPortH
HTH, and please post back your results and/or update the codeshare with a better soluiton.
thx
/deb - Ralf_Bruenig_74Historic F5 AccountHi deb,
Thanks for your answer.
Actually it didn’t solve the problem since we have the issue already at the following line:
scan [HTTP::cookie $::myCookieName] "%d.%d.%d" myIpE myPortE unused
The problem is, that the string will be changed to integer with the %d statement. I did some further research and found that there is also a way to get the unsigned integer with the %u parameter. I really wonder why I haven’t seen that before.
With the following line it works fine:
scan [HTTP::cookie $::myCookieName] "%u.%d.%d" myIpE myPortE unused
It is actually not necessary to do the same thing with the ports since they anyway limited to 16 bits.
It would be great when somebody could fix this iRule in the iRules Samples list.
Cheers
Ralf
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects