Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagetext
themeEclipse
import ultra.Example.Out;

sessionInit { 
  Accounting_Request_Int radUDR = 
    (Accounting_Request_Int) input;
  session.user = radUDR.User_Name; 
  session.IPAddress = radUDR.framedIPAddress; 
  session.sessionID = radUDR.acctSessionId; 
}

consume { 
  /* Radius UDRs. 
  If a matching session is found, then there are two Radius UDRs 
  and the session is considered completed. 
  Remove session and route the new UDR. */

  if (instanceOf(input, Accounting_Request_Int)) { 
    Accounting_Request_Int radUDR = (Accounting_Request_Int)input;

    if (radUDR.acctStatusType == 2 ) { 
      OutputUDR finalUDR = udrCreate( OutputUDR ); 
      finalUDR.user = session.user; 
      finalUDR.IPAddress = (string)session.IPAddress; 
      finalUDR.downloadedBytes = session.downloadedBytes; 
      finalUDR.uploadedBytes = session.uploadedBytes; 
      udrRoute( finalUDR );
      sessionRemove(session); 
      return; 
    } 
  }

  /* Netflow UDRs. 
  Depending on if the user downloaded or uploaded bytes, the 
  corresponding field data is used to update session variables. */

  if (instanceOf(input, V5UDR)) { 
    V5UDR nfUDR = (V5UDR)input;

      if ( session.IPAddress == nfUDR.SourceIP ) { 
        session.downloadedBytes = session.downloadedBytes + 
          nfUDR.BytesInFlow; 
      } else { 
        session.uploadedBytes = session.uploadedBytes + 
          nfUDR.BytesInFlow; 
      } 
  }

  // A session will be considered outdated in 5 days. 
  date timer=dateCreateNow(); 
  dateAddDays( timer, 5 ); 
  sessionTimeout( session, timer ); 
}

timeout { 
   // Outdated sessions are removed, and a resulting UDR is sent on. 
   OutputUDR finalUDR = udrCreate( OutputUDR ); 
   finalUDR.user = session.user; 
   finalUDR.IPAddress = (string)session.IPAddress; 
   finalUDR.downloadedBytes = session.downloadedBytes; 
   finalUDR.uploadedBytes = session.uploadedBytes; 
   udrRoute( finalUDR );
   sessionRemove(session); 
}


Scroll ignore
scroll-viewportfalse
scroll-pdftrue
scroll-officefalse
scroll-chmtrue
scroll-docbooktrue
scroll-eclipsehelptrue
scroll-epubtrue
scroll-htmlfalse


Next section:



Scroll pagebreak