Forum Discussion
SMPP IRULES that insert destination port in One Vip, as Port in Second Vip pool member
Thank you so much. I have played around with the scenario. I also agree with your postulations. My postulation is to add the port into a TLV tag for smpp, and then later pass it through, to be extracted on another irule. I tried the below on VIP 1, AND GOT following logs. I will try your approach and test it. Thanks so much.
when CLIENT_ACCEPTED {
set orig_port [TCP::local_port]
set session_key "[IP::client_addr]:[TCP::client_port]"
set session_data "port=$orig_port"
table set $session_key $session_data 300
set orig_port [TCP::local_port]
set session_key "[IP::client_addr]:[TCP::client_port]"
set session_data "port=$orig_port"
table set $session_key $session_data 300
log local0. "VIP1: Client connected from [IP::client_addr]:[TCP::client_port] on original port $orig_port"
}
when CLIENT_DATA {
if { [TCP::payload length] < 16 } { return }
binary scan [TCP::payload] I command_length
if { [TCP::payload length] < $command_length } { return }
binary scan [TCP::payload] x4I command_id x8I seq_number
set min_valid_len 37
if {
($command_id == 0x00000009 || $command_id == 0x00000004)
&& [TCP::payload length] >= $min_valid_len
} {
set session_key "[IP::client_addr]:[TCP::client_port]"
set session_data [table lookup $session_key]
if { [string length $session_data] == 0 } {
log local0. "VIP1: No session data found for $session_key"
return
}
set orig_port [lindex [split $session_data "="] 1]
# Prepare TLV
set tag 0x1401
set tlv_len 2
set value [binary format S $orig_port]
set tlv [binary format SSa* $tag $tlv_len $value]
# Append TLV and update command_length
set payload [TCP::payload]
set new_len [expr {$command_length + [string length $tlv]}]
# Replace first 4 bytes (command_length)
set updated_pdu [binary format I $new_len][string range $payload 4 end]$tlv
# Inject new payload
TCP::payload replace 0 $command_length $updated_pdu
log local0. "VIP1: TLV injected (port=$orig_port). New command_length=$new_len"
}
}
when CLIENT_CLOSED {
log local0. "VIP1: Client [IP::client_addr]:[TCP::client_port] closed connection"
table delete "[IP::client_addr]:[TCP::client_port]"
}
when SERVER_CLOSED {
log local0. "VIP1: SMS Firewall [IP::server_addr]:[TCP::server_port] closed connection"
}
Jun 4 04:36:21 unotelossaka.gloworld.com info tmm[18939]: Rule /Common/smsc1 <CLIENT_DATA>: VIP2: Expected TLV 0x1401 not found for 00000009. Using default port 10000.
Jun 4 04:36:21 unotelossaka.gloworld.com info tmm[18939]: Rule /Common/smsc1 <CLIENT_DATA>: VIP2: SERVER not yet connected; deferring node assignment
Jun 4 04:36:33 unotelossaka.gloworld.com info tmm[18939]: Rule /Common/smpp1 <CLIENT_CLOSED>: VIP1: Client 193.135.101.16:16715 closed connection
Jun 4 04:36:33 unotelossaka.gloworld.com info tmm[18939]: Rule /Common/smpp1 <SERVER_CLOSED>: VIP1: SMS Firewall 10.159.59.132:10000 closed connection
Jun 4 04:36:33 unotelossaka.gloworld.com info tmm[18939]: Rule /Common/smpp1 <CLIENT_CLOSED>: VIP1: Client 193.135.101.16:56925 closed connection
Jun 4 04:36:33 unotelossaka.gloworld.com info tmm[18939]: Rule /Common/smpp1 <SERVER_CLOSED>: VIP1: SMS Firewall 10.159.59.132:10000 closed connection
Jun 4 04:36:43 unotelossaka.gloworld.com info tmm2[18939]: Rule /Common/smpp1 <CLIENT_ACCEPTED>: VIP1: Client connected from 193.135.101.16:45599 on original port 5102
Jun 4 04:36:43 unotelossaka.gloworld.com info tmm3[18939]: Rule /Common/smpp1 <CLIENT_ACCEPTED>: VIP1: Client connected from 193.135.101.16:29867 on original port 5102
Jun 4 04:36:45 unotelossaka.gloworld.com info tmm1[18939]: Rule /Common/smsc1 <CLIENT_ACCEPTED>: VIP2: Connection received from SMS Firewall from 10.159.59.132:39024
Jun 4 04:36:45 unotelossaka.gloworld.com info tmm1[18939]: Rule /Common/smsc1 <CLIENT_DATA>: VIP2: Processing command: 00000009 (Length: 37)
Jun 4 04:36:45 unotelossaka.gloworld.com info tmm1[18939]: Rule /Common/smsc1 <CLIENT_DATA>: VIP2: Expected TLV 0x1401 not found for 00000009. Using default port 10000.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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
