| T a n e s h a N e t w o r k s |
Ser/J is a SIP Easy Router in Java.
Configuration of Ser/J consists of two parts.
This is done through Spring beans framework. You wire the Ser/J components depending on which configuration you would like.
The second part of Ser/J configuration is defining how we should route the incoming requests and outgoing responses. This part is done by editing familiar Java functions. You dont need to learn any new and strange syntax, simply use what you know. The functions will be compiled into a java .class which Ser/J loads and executes for each incoming request.
// defines the main route, a void method with no input.
public void route() {
// get rid of options and notifies immediately.
if (method.matches("(OPTIONS|NOTIFY)")) {
statelessReply(200, "OK -- happy natting.");
return;
}
// handle nat clients
if (natedClient()) {
setFlag(1);
fixNatedContact();
}
// set rport parameter
forceRport();
// authentication
if (!proxyAuthenticate("my_server")) {
proxyChallenge("my_server");
return;
}
// REGISTER.
if (method.matches("REGISTER")) {
locationSave("my_server");
statelessReply(200, "OK -- location registered");
return;
}
// this is implicit unless we send stateless reply, recordRoute();
// loose route check.
if (looseRoute()) {
relay();
return;
}
routeProxyDestinations();
}
public void routeProxyDestinations() {
if (!requestUri.matches("^sip:.*@gratissip.dk")) {
requestUri = "sip:test@gratissip.dk";
}
relay();
}