mirror of https://github.com/sipwise/sems.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
4.1 KiB
142 lines
4.1 KiB
************************************
|
|
* Early announcement Server Module *
|
|
************************************
|
|
|
|
Description:
|
|
------------
|
|
|
|
The annoucement server plays a wav file to the caller
|
|
in an early session: it replies to an invite with
|
|
183 Session Progress (with SDP), then sends the announcement
|
|
and finally replies the request with a response (by default
|
|
404 Not found ).
|
|
|
|
Additional Headers:
|
|
P-Final-Reply-Code integer (ex. P-Final-Reply-Code:405 )
|
|
P-Final-Reply-Reason string (e.g. P-Final-Reply-Reason:Prohibited)
|
|
|
|
|
|
It searches for files to play following these rules:
|
|
|
|
1) [AnnouncePath]/[Domain]/[User].wav
|
|
2) [AnnouncePath]/[User].wav
|
|
|
|
example sems (early_announce.conf) configuration:
|
|
|
|
announce_path=wav/
|
|
default_announce=default_en.wav
|
|
|
|
|
|
example ser configuration:
|
|
|
|
#
|
|
# simple single instance Ser config script with early media
|
|
# ----------- global configuration parameters ------------------------
|
|
|
|
debug=5 # debug level (cmd line: -dddddddddd)
|
|
fork=yes
|
|
log_stderror=yes # (cmd line: -E)
|
|
|
|
check_via=no # (cmd. line: -v)
|
|
dns=no # (cmd. line: -r)
|
|
rev_dns=no # (cmd. line: -R)
|
|
port=5060
|
|
#children=4
|
|
sip_warning=no
|
|
|
|
# Configure Ser to create a FIFO server
|
|
#fifo="/tmp/ser_fifo"
|
|
|
|
# Configure Ser to create an unix socket server
|
|
unix_sock="/tmp/ser_socket"
|
|
|
|
loadmodule "modules/sl/sl.so"
|
|
loadmodule "modules/tm/tm.so"
|
|
loadmodule "modules/rr/rr.so"
|
|
loadmodule "modules/maxfwd/maxfwd.so"
|
|
loadmodule "modules/avp/avp.so"
|
|
loadmodule "modules/avpops/avpops.so"
|
|
|
|
# -- rr params --
|
|
# add value to ;lr param to make some broken UAs happy
|
|
modparam("rr", "enable_full_lr", 1)
|
|
|
|
modparam( "avpops", "avp_aliases", "early_code=i:66 ; early_reason=i:67" )
|
|
|
|
# this is to be appended to the invite
|
|
modparam("tm", "tw_append","early_headers:P-Final-Reply-Code=avp[$early_code];P-Final-Reply-Reason=avp[$early_reason]")
|
|
|
|
# ------------------------- request routing logic -------------------
|
|
# main routing logic
|
|
route{
|
|
|
|
# initial sanity checks -- messages with
|
|
# max_forwards==0, or excessively long requests
|
|
if (!mf_process_maxfwd_header("10")) {
|
|
sl_send_reply("483","Too Many Hops");
|
|
break;
|
|
};
|
|
if ( msg:len > max_len ) {
|
|
sl_send_reply("513", "Message too big");
|
|
break;
|
|
};
|
|
# we record-route all messages -- to make sure that
|
|
# subsequent messages will go through our proxy; that's
|
|
# particularly good if upstream and downstream entities
|
|
# use different transport protocol
|
|
record_route();
|
|
# loose-route processing
|
|
if (loose_route()) {
|
|
t_relay();
|
|
break;
|
|
};
|
|
|
|
if (uri==myself) {
|
|
# filter unsupported requests
|
|
if (!(method=="REGISTER" || method=="ACK" || method=="INVITE" ||
|
|
method=="BYE" || method=="CANCEL" )) {
|
|
sl_send_reply("501", "method not understood here");
|
|
break;
|
|
}
|
|
|
|
if (method=="REGISTER") {
|
|
# make UAs which want to register unhappy
|
|
sl_send_reply("501","registration couldn't be accepted");
|
|
break;
|
|
};
|
|
|
|
if (!t_newtran()){
|
|
sl_send_reply("500","could not create transaction");
|
|
break;
|
|
};
|
|
|
|
if (method == "INVITE") {
|
|
|
|
avp_write("405", "$early_code");
|
|
avp_write("Prohiboted", "$early_reason");
|
|
|
|
if(!t_write_unix("/tmp/sems_sock","early_announce/early_headers")){
|
|
log("could not contact early_announce\n");
|
|
t_reply("404","not found");
|
|
};
|
|
break;
|
|
|
|
} else if (method=="BYE" || method=="CANCEL") {
|
|
if(!t_write_unix("/tmp/sems_sock","bye")) {
|
|
t_reply("500","error contacting sems");
|
|
};
|
|
break;
|
|
} else if (method=="ACK"){
|
|
# absorb ACKs
|
|
t_relay();
|
|
break;
|
|
};
|
|
break;
|
|
}
|
|
|
|
if (!t_relay()) {
|
|
sl_reply_error();
|
|
};
|
|
}
|
|
|