5
import org.siprouter.*;
6
import org.siprouter.NativeInterface.*;
8
public class Kamailio extends NativeMethods
12
System.load("/opt/kamailio/lib/kamailio/modules/app_java.so");
15
/* Constructor. Do not remove !!! */
21
public int child_init(int rank)
26
LM_INFO("We're at PROC_MAIN\n");
28
case Ranks.PROC_TIMER:
29
LM_INFO("We're at PROC_TIMER\n");
32
LM_INFO("We're at PROC_RPC/PROC_FIFO\n");
34
case Ranks.PROC_TCP_MAIN:
35
LM_INFO("We're at PROC_TCP_MAIN\n");
37
case Ranks.PROC_UNIXSOCK:
38
LM_INFO("We're at PROC_UNIXSOCK\n");
40
case Ranks.PROC_ATTENDANT:
41
LM_INFO("We're at PROC_ATTENDANT\n");
44
LM_INFO("We're at PROC_INIT\n");
46
case Ranks.PROC_NOCHLDINIT:
47
LM_INFO("We're at PROC_NOCHLDINIT/PROC_MIN\n");
49
case Ranks.PROC_SIPINIT:
50
LM_INFO("We're at PROC_SIPINIT\n");
52
case Ranks.PROC_SIPRPC:
53
LM_INFO("We're at PROC_SIPRPC\n");
60
public int TestMethod()
63
LM_INFO(String.format("Msg Type: %s\n", SipMsg.getMsgType()));
65
IPPair src = SipMsg.getSrcAddress();
68
LM_INFO(String.format("src address=%s, src port=%d\n", src.ip, src.port));
72
LM_ERR("IPPair src is null!");
75
IPPair dst = SipMsg.getDstAddress();
78
LM_INFO(String.format("dst address=%s, dst port=%d\n", dst.ip, dst.port));
82
LM_ERR("IPPair dst is null!");
85
LM_INFO(String.format("buffer:\n%s\n", SipMsg.getBuffer().trim()));
87
SipMsg msg = SipMsg.ParseSipMsg();
91
LM_INFO(String.format("\tid=%d\n", msg.id));
92
LM_INFO(String.format("\tpid=%d\n", msg.pid));
93
LM_INFO(String.format("\teoh='%s'\n", msg.eoh));
94
LM_INFO(String.format("\tunparsed='%s'\n", msg.unparsed));
95
LM_INFO(String.format("\tbuf='%s'\n", msg.buf));
96
LM_INFO(String.format("\tlen=%d\n", msg.len));
97
LM_INFO(String.format("\tnew_uri='%s'\n", msg.new_uri));
98
LM_INFO(String.format("\tdst_uri='%s'\n", msg.dst_uri));
99
LM_INFO(String.format("\tparsed_uri_ok=%d\n", msg.parsed_uri_ok));
100
LM_INFO(String.format("\tparsed_orig_ruri_ok=%d\n", msg.parsed_orig_ruri_ok));
101
LM_INFO(String.format("\tadd_to_branch_s='%s'\n", msg.add_to_branch_s));
102
LM_INFO(String.format("\tadd_to_branch_len=%d\n", msg.add_to_branch_len));
103
LM_INFO(String.format("\thash_index=%d\n", msg.hash_index));
104
LM_INFO(String.format("\tmsg_flags=%d\n", msg.msg_flags));
105
LM_INFO(String.format("\tset_global_address='%s'\n", msg.set_global_address));
106
LM_INFO(String.format("\tset_global_port='%s'\n", msg.set_global_port));
110
LM_ERR("SipMsg msg is null!\n");