Forum Discussion

Ken_Wong_48678's avatar
Ken_Wong_48678
Historic F5 Account
Sep 04, 2008

SIP via header modification

Hi,

 

 

my customers have a requirement to modify SIP via header, they want to insert the SIP client ip and port into the via header.

 

 

when CLIENT_ACCEPTED {

 

set ::clientip [IP::client_addr]

 

set ::clientport [UDP::remote_port]

 

}

 

 

when SIP_REQUEST_SEND {

 

SIP::header insert "Via" "[lindex [split [SIP::via 1] ";"] 0];received=$::clientip;rport=$::clientport;[lindex [split [SIP::via 1] ";"] 2]" 1

 

SIP::header remove "Via" 2

 

}

 

 

The above irule seems work but finally I find out the variable cannot be updated even another client ip connect to the virtual. I think it may be related to the variable but it cannot be retrieved in SIP_REQUEST_SEND event if I don't use global variable.

 

 

Is there any idea that I can get the client ip and port but don’t need to use global variable? Thanks!

 

 

Regards,

 

Ken

18 Replies

  • Hi,

     

     

    I did some testing in my lab and reproduce your error. It definitely seems like SIP_REQUEST_SEND doesn't share data with the other event including clientside data ...

     

     

    Anyway it works fine with SIP_REQUEST, cannot you do everything within this event ?
  • I think the reason it's failing is that there isn't a client side "connection" once the server side connection is established. I would have thought LTM would maintain a connection table entry until the response was sent. I also expected that LTM would preserve any variables set in a client side event for the duration of the server side connection. Both of these points seem odd, even for UDP. I'd be curious to see what F5 dev has to say about this.

     

     

    Aaron

     

     

  • I'm guessing the issue is specific to UDP and it's because the client side connection doesn't exist by the time the server side context is started. It's still very odd that the IP::client_addr and UDP::client_port values aren't stored like they are in TCP-based rules. It's even more strange that explicitly set local variables aren't preserved.

     

     

    Aaron
  • spark_86682's avatar
    spark_86682
    Historic F5 Account
    I agree that this is very strange behavior. It's almost like the serverside connection doesn't have a link back to the clientside, which would explain both the local variables not working and the clientside commands not working.

     

     

    The suggestion to use SIP_REQUEST is a good one; see if that solves the problem.

     

     

    In any case, I would strongly recommend opening a case with F5 support.
  • Ken_Wong_48678's avatar
    Ken_Wong_48678
    Historic F5 Account
    finally it seems work and I will pass to customer for further tests. Thanks for all who response...

     

     

    Ken

     

     

    when SIP_REQUEST {

     

    log local0. "client info is [IP::client_addr]:[UDP::client_port]"

     

    SIP::header insert "Via" "[lindex [split [SIP::via 0] ";"] 0];received=[IP::client_addr];rport=[UDP::client_port];[lindex [split [SIP::via 0] ";"] 1]"

     

    SIP::header remove "Via" 1

     

    }
  • When I try to apply this rule, I am getting following error.

     

    Btw I am using 9.2.5

     

     

    01070151:3: Rule [sip-request] error:

     

    line 1: [unknown event (SIP_REQUEST)] [when SIP_REQUEST {

     

    log local0. "client info is [IP::client_addr]:[UDP::client_port]"

     

    SIP::header insert "Via" "[lindex [split [SIP::via 0] ";"] 0];received=[IP::client_addr];rport=[UDP::client_port];[lindex [split [SIP::via 0] ";"] 1]"

     

    SIP::header remove "Via" 1

     

    }]
  • For versions before 9.4 that support the SIP events (and 9.2.x is included), you must have an Early Access license in order for the features to work.