etc/obsoleted/smsgw.cfg
85c1c941
 #
 # $Id$
 #
 # bat.iptel.org (sms gateway) real world configuration
 #
 
 # ----------- global configuration parameters ------------------------
 
9907e6e9
 debug=3          # debug level (cmd line: -dddddddddd)
 fork=yes
 #fork=no
 log_stderror=no     # (cmd line: -E)
 #log_stderror=yes   # (cmd line: -E)
85c1c941
 check_via=yes       # (cmd. line: -v)
 dns=on              # (cmd. line: -r)
 rev_dns=yes         # (cmd. line: -R)
 port=5070
 children=2
 
 # advertise IP address in Via (as opposed to advertising DNS name
 # which is annoying for downstream servers and some phones can
 # not handle DNS at all)
 listen=195.37.77.100
 
 # ------------------ module loading ----------------------------------
 
 loadmodule "../sip_router/modules/sl/sl.so"
 loadmodule "../sip_router/modules/print/print.so"
 loadmodule "../sip_router/modules/tm/tm.so"
 loadmodule "../sip_router/modules/maxfwd/maxfwd.so"
 loadmodule "../sip_router/modules/sms/sms.so"
 
 # ----------------- setting module-specific parameters ---------------
 
 # -- sms params --
3ddffe26
 modparam("sms","modems","Falcom [d=/dev/ttyS0;b=9600;p=9254;m=new;l=10;r=2]")
85c1c941
 modparam("sms","networks","D1[c=491710765000;m=10]")
 modparam("sms","links","Falcom[D1]")
9907e6e9
 modparam("sms","domain","iptel.org")
 modparam("sms","max_sms_parts",3)
 modparam("sms","use_contact",1)
85c1c941
 
 
 # -- tm params --
 modparam("tm", "fr_timer", 10 )
 modparam("tm", "fr_inv_timer", 10 )
 modparam("tm", "wt_timer", 10 )
 
 
 # -------------------------  request routing logic -------------------
 
 # main routing logic
 
 route{
 
 	if (len_gt( max_len )) {
 		sl_send_reply("513", "Riesengross -- Message too large");
 		break;
 	};
 
 	# filter too old messages
 	log("LOG: Checking maxfwd\n");
 	if (!mf_process_maxfwd_header("10")) {
 		log("LOG: Too many hops\n");
 		sl_send_reply("483","Too Many Hops");
 		break;
 	};
3ddffe26
 	
85c1c941
 	# accept only req coming from iptel.org
3ddffe26
 	if (!src_ip==195.37.77.101 |
9907e6e9
 	!( uri=~"iptel.org" | uri=~"195\.37\.77\.100" ))
85c1c941
 	{
3ddffe26
 		log("SER:Forbidden request: wrong src_ip or req_uri\n");
85c1c941
 		sl_send_reply("403","Forbidden");
 		break;
 	};
 
 	#accept only MESSAGE requests
3ddffe26
 	if (!method=="MESSAGE")
85c1c941
 	{
 		sl_send_reply("501","Not Implemented");
 		break;
 	};
 
8728d5ca
 	# SMS expects the numbers as follows <int> <area> <nr>
 	# align numbering to it
 	if (uri=~"sip:001" ) {
 		strip(2);
 		prefix("49");
 	} else if (uri=~"sip:\+491") {
 		strip(1);
 	} else if (uri=~"sip:000491") {
 		strip(3);
 	} else {
 		sl_send_reply("403", "SMS only to German 01* networks");
 		break;
 	};
 
85c1c941
 	if (! t_newtran())
 	{
 		# retransmit whatever we have 
9907e6e9
 		# it's useless to do any retransmision, because we haven't
 		# sent any statefull reply. (bogdan)
 		#t_retransmit_reply();
b5838ade
 		break;
85c1c941
 	} else {
 		# do what you want to do
 		if (sms_send_msg_to_net("D1"))
 		{
9907e6e9
 			# for sending replies, we woun't use the statefull 
 			# function because it is not able to add the Contact
 			# header (in fact to add any rpl_lump :-( )
85c1c941
 			# things went well, send ok upstream 
9907e6e9
 			if (!sl_send_reply("202", "yes sir, SMS sent over"))
85c1c941
 			{
 				# if replying failed, retry statelessly 
 				sl_reply_error(); 
 			};
 		} else {
9907e6e9
 			if (!sl_send_reply("502", "Bad gateway - SMS error"))
85c1c941
 			{
 				# if replying failed, retry statelessly 
 				sl_reply_error(); 
 			};
 		};
 		# transaction conclude it -- junk it now (it will
 		# stay there until WAIT timer hits)
 		t_release();
 	};
 	t_unref();
 }