06.12.2012 Views

F REQUENTLY A SKED Q UESTION - Snom

F REQUENTLY A SKED Q UESTION - Snom

F REQUENTLY A SKED Q UESTION - Snom

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

F <strong>REQUENTLY</strong><br />

A <strong>SKED</strong><br />

Q <strong>UESTION</strong><br />

Controlling the snom 4S<br />

Date: Aug-30-2003<br />

Author: Dr. Christian Stredicke<br />

Document: faq-02-09-30-cs<br />

from a Linux Shell


Problem Statement<br />

In some environments, users of the<br />

snom 4S would like to be able to automatically<br />

perform actions such as registering new users<br />

and deactivating accounts. In principle, these<br />

actions are not critical to performance.<br />

The snom 4S software components have<br />

a built-in web server that supports the features<br />

required. It therefore makes sense to have a<br />

“remote control” that uses the web interface<br />

of the Proxy or the Media Server in the same<br />

fashion as real users do. The snom 4S does<br />

not recognize that a shell script controls its<br />

behavior.<br />

Initiating Web Access from the<br />

Command Line Interface<br />

The problem of controlling a remote web<br />

server from a shell is well known. There are<br />

programs available for performing this task -<br />

“curl” is available for Linux and for Windows<br />

and can be integrated into shell scripts and<br />

PHP programs. For more information, see<br />

http://curl.haxx.se. Other web programs work<br />

in a similar way.<br />

The proxy and the media server do not<br />

differentiate between POST and GET with<br />

parameters in the URL.<br />

Parameter values are “url-encoded”. That<br />

means that some special characters have a<br />

particular meaning. For instance, the “&” is<br />

a separator symbol between the parameters,<br />

the “+” means a space character and “=” is<br />

used to indicate an assignment of a value to<br />

a variable. If you want to encode one of these<br />

special characters (and other characters that<br />

are not in the normal character set), you can<br />

use the % followed by the two-digit hex code<br />

of the character to encode the character that<br />

you need. If in doubt, you should use the %xx<br />

notation.<br />

[ F R E Q U E N T L Y A S K E D Q U E S T I O N ]<br />

Proxy Version 2.3x and Higher<br />

In the 3.x versions of the proxy, we use<br />

a scripting language to control the behavior of<br />

the proxy. When the proxy receives a request<br />

to post information to a predefined webpage<br />

(post.htm), it first determines the domain<br />

and the password for this domain. If there is<br />

a match, it sets all variables in the http post<br />

accordingly and calls the subroutine “on_post”.<br />

This function can then perform the necessary<br />

actions (a predefined behavior is available,<br />

see below). Sending information to the proxy<br />

does not require a session context.<br />

For example, if you use “curl http://<br />

myproxy:8080/post.htm?domain=abc.com&p<br />

ass=secret&var1=abc&var2=hello+here%21”<br />

, the proxy will execute the function “on_post”<br />

in the domain context of “abc.com” (if it exists<br />

and the password is “secret”). The variable<br />

“$var1” will be set to “abc” and the variable<br />

“$var2” will be set to “hello here!”.<br />

The Default on_post() Function<br />

The proxy comes with several predefined<br />

default functions. If you load another on_<br />

post() function in the domain, these functions<br />

are overwritten.<br />

The default script uses the variable<br />

“action” to indicate what the proxy should do.<br />

• create_user:<br />

This function uses the variables<br />

“account” (which indicates the account to<br />

use), “username” (which indicates the user<br />

name for challenging) and “password” (the<br />

password for challenging) to create or update<br />

a user account.<br />

• delete_user:<br />

This function deletes a user account<br />

(indicated in the variable “account”).<br />

• disable_user:<br />

This function disables a user account<br />

(indicated in the variable “account”).<br />

• enable_user:<br />

2 snom technology AG


This function enables a user account<br />

(indicated in the variable “account”).<br />

Available Actions for the Proxy<br />

Versions 2.2x<br />

We highly recommend upgrading to<br />

proxy versions 2.3x or higher. However, if<br />

you do wish to continue operating the 2.2x<br />

or previous versions, you will need to use a<br />

different web interface.<br />

You can take a look at the html source<br />

code before pressing the “save” button to a<br />

web request in order to see which parameters<br />

are used to post a request. This chapter shows<br />

and explains to you which parameters are<br />

valid.<br />

Setting Parameters in 2.2x<br />

Setting parameters is carried out with<br />

the SAVE=Save parameter. The table on<br />

the next page shows which parameters are<br />

available (also see the manual). For example,<br />

to set the retry_t1 time, you would use:<br />

curl -d save=save -d retry_t1=400 -u<br />

user:pass myproxy.com:5068 >/dev/null<br />

Add a User<br />

To add a user, use the parameters<br />

Domain, Account, Username and Password<br />

as described in the snom 4S Proxy/Registrar<br />

manual and add the ADD_USER=Add/Edit<br />

parameter.<br />

Example to add a new user:<br />

curl -u user:pass -d ADD_USER=add/<br />

edit -d domain=bla.com -d account=testc<br />

-d username=testc -d password=1234<br />

myproxy.com:5068 >/dev/null<br />

Remove a User in 2.2x<br />

To remove a user, set the argument<br />

userdel to the account name of the user you<br />

want to remove. No additional parameters are<br />

required. Make sure that the domain name is<br />

[ F R E Q U E N T L Y A S K E D Q U E S T I O N ]<br />

separated from the user name by a space.<br />

Example:<br />

curl -d userdel=”bla.com testc” -u user:<br />

pass myproxy.com:5068 >/dev/null<br />

Add a Dial Plan Element in 2.2x<br />

Adding an element to the Dial Plan<br />

is similar to adding a user. The parameter<br />

SaveAdr must be set to Save.<br />

The values for the dial plan are stored<br />

in the variables apa[x], apb[x], apc[x] and<br />

apd[x]. x starts from 0 for the first entry and<br />

continues until a empty line has been found.<br />

apa elements may have the value allow,<br />

deny, incomplete, gateway or notfound<br />

according to the meaning described in the<br />

manual. apb, apc and apd have the values<br />

described in the manual.<br />

Add Error-Info Element in 2.2x<br />

The error-information list is handled in a<br />

similar fashion to the dial plan.<br />

The variables manipulated here have the<br />

name eia[x] and eib[x]. eia takes the error<br />

code (e.g. 404), eib the destination url.<br />

Parameters for 2.2x<br />

The following list shows the available<br />

parameters:<br />

Remote Control for snom 4S 3


[ F R E Q U E N T L Y A S K E D Q U E S T I O N ]<br />

sip_port_number: The SIP port number.<br />

nat_proxy: The address of the NAT gateway<br />

save_registration: True or false if the registration should be saved.<br />

hostname: The list of the hostnames.<br />

config_file: The name of the config file.<br />

min_regtime, max_regtime: Minimum and maximum registration time.<br />

default_q: The default q value.<br />

log_register: True or false if REGISTER should go into the SIP message<br />

trace.<br />

seqfork_delay: The delay for sequential forking.<br />

reg_dir: The directory for storing the registrations.<br />

log_filename: The filename for logging.<br />

log_level: The log level.<br />

max_forwards: The maximum number of SIP message forwards.<br />

tcp_threshold: The TCP threshold.<br />

retry_t1: The retry timeout T1.<br />

timeout_408: The timeout value for responding with 408 No Response.<br />

call_log_length: The length of the call log.<br />

auth_realm: The realm for authentication.<br />

force_authorization: True or false if authorization should be forced.<br />

auth_exception: The exception pattern for the authentication.<br />

html_port_number: The number for the http port.<br />

pw_pass1, pw_pass2: The password for the web interface (including<br />

confirmation).<br />

pw_user: The username for the web interface.<br />

allow_pattern: The allow pattern in encoded form.<br />

license_code: The license code.<br />

error_info: A pattern for generating the error-information headers.<br />

reject_nat_register: True or false if NAT registrations should be rejected.<br />

no_loose_routing: True or false if loose routing should be turned off.<br />

no_route_on_record_route: True or false if no route should be carried out if record-<br />

route is already present.<br />

callog_filename: The name of the call log file.<br />

dirty_host_ttl: The time to live to dirty host detections.<br />

welcome_event: The name of the welcome event.<br />

welcome_type: The type of the welcome event.<br />

welcome_file: The file for the welcome event.<br />

welcome_method: The method used for the welcome event (MESSAGE or<br />

NOTIFY).<br />

no_tags_on_18x: True or false if tags in 18x codes should be removed.<br />

Posting to the media server<br />

You should keep as little database<br />

information as possible on the media server.<br />

The newer versions of the media server<br />

allow for example the automatic setup of<br />

mailbox accounts, which reduces the need for<br />

automatic access to the media server.<br />

However, if you need to post to the media<br />

server, you can do this in the same way as<br />

posting to the 2.2x proxy. The media server<br />

does not have the concept of a domain and<br />

uses basic authentication for checking the<br />

user credentials.<br />

For example, if you want to set up a new<br />

calling card account, you would use “curl -u<br />

user:pass -d savecc=save -d cc_account=cc<br />

-d cc_number=1234567890 -d cc_code=1234<br />

-d cc_credit=1000 mediaserver.com:8080 >/<br />

dev/null”<br />

Security<br />

Currently, the proxy uses only plain http to<br />

exchange the data. Future releases will allow<br />

privacy by using https as transport layers.<br />

4 snom technology AG


Europe & ROW:<br />

snom technology AG<br />

Pascalstr. 10B<br />

10587 Berlin, Germany<br />

Phone: +49 (30) 39833-0<br />

mailto:info@snom.de<br />

http://www.snom.com<br />

sip:info@snom.com<br />

© 2003 snom technology AG<br />

All rights reserved.<br />

USA and Americas:<br />

snom USA Representation<br />

ABP International, Inc.<br />

1203 Crestside Dr.<br />

Coppell, Texas 75019, USA<br />

Phone: +1-972-831-0280<br />

mailto:usa@snom.de<br />

sip:usa@snom.com<br />

India and SAARC:<br />

snom technology (India) Pvt Ltd.<br />

No. 417, International Trade Tower<br />

Nehru Place, New Delhi-110019<br />

Phone: +91 11 26234097<br />

Fax: +91 11 26234079<br />

http://www.snomindia.com<br />

mailto:info@snomindia.com<br />

sip:india@snom.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!