Module: OverSIP::SIP

Defined in:
lib/oversip.rb,
lib/oversip/sip/sip.rb,
lib/oversip/sip/uac.rb,
lib/oversip/sip/uri.rb,
lib/oversip/sip/core.rb,
lib/oversip/sip/tags.rb,
lib/oversip/sip/proxy.rb,
lib/oversip/sip/client.rb,
lib/oversip/sip/timers.rb,
lib/oversip/sip/message.rb,
lib/oversip/sip/request.rb,
lib/oversip/sip/rfc3263.rb,
lib/oversip/sip/launcher.rb,
lib/oversip/sip/response.rb,
lib/oversip/sip/constants.rb,
lib/oversip/sip/name_addr.rb,
lib/oversip/sip/uac_request.rb,
lib/oversip/sip/message_processor.rb,
lib/oversip/sip/transport_manager.rb,
lib/oversip/sip/client_transaction.rb,
lib/oversip/sip/server_transaction.rb,
lib/oversip/sip/listeners/connection.rb,
lib/oversip/sip/listeners/tcp_client.rb,
lib/oversip/sip/listeners/tcp_server.rb,
lib/oversip/sip/listeners/tls_client.rb,
lib/oversip/sip/listeners/tls_server.rb,
lib/oversip/sip/listeners/tcp_connection.rb,
lib/oversip/sip/listeners/udp_connection.rb,
lib/oversip/sip/listeners/ipv4_tcp_client.rb,
lib/oversip/sip/listeners/ipv4_tcp_server.rb,
lib/oversip/sip/listeners/ipv4_tls_client.rb,
lib/oversip/sip/listeners/ipv4_tls_server.rb,
lib/oversip/sip/listeners/ipv4_udp_server.rb,
lib/oversip/sip/listeners/ipv6_tcp_client.rb,
lib/oversip/sip/listeners/ipv6_tcp_server.rb,
lib/oversip/sip/listeners/ipv6_tls_client.rb,
lib/oversip/sip/listeners/ipv6_tls_server.rb,
lib/oversip/sip/listeners/ipv6_udp_server.rb,
lib/oversip/sip/listeners/tls_tunnel_server.rb,
lib/oversip/sip/listeners/tls_tunnel_connection.rb,
lib/oversip/sip/listeners/ipv4_tls_tunnel_server.rb,
lib/oversip/sip/listeners/ipv6_tls_tunnel_server.rb,
ext/sip_parser/sip_parser_ruby.c

Overview

Pre-declare internal modules.

Defined Under Namespace

Modules: Core, Launcher, MessageProcessor, RFC3263, Tags, TransportManager Classes: Ack2xxForwarder, Client, ClientTransaction, Connection, IPv4TcpClient, IPv4TcpServer, IPv4TlsClient, IPv4TlsServer, IPv4TlsTunnelServer, IPv4UdpServer, IPv6TcpClient, IPv6TcpServer, IPv6TlsClient, IPv6TlsServer, IPv6TlsTunnelServer, IPv6UdpServer, InviteClientTransaction, InviteServerTransaction, Message, MessageParser, MessageParserError, NameAddr, NonInviteClientTransaction, NonInviteServerTransaction, Proxy, Request, Response, ServerTransaction, TcpClient, TcpConnection, TcpServer, TlsClient, TlsServer, TlsTunnelConnection, TlsTunnelServer, Uac, UacRequest, UdpConnection, Uri

Constant Summary collapse

T1 =

SIP timer values.

RTT Estimate (RFC 3261 17.1.2.1).

0.5
T2 =

The maximum retransmit interval for non-INVITE requests and INVITE responses (RFC 3261 17.1.2.2).

4
T4 =

Maximum duration a message will remain in the network (RFC 3261 17.1.2.2).

5
TIMER_A =

INVITE request retransmit interval, for UDP only (RFC 3261 17.1.1.2).

T1
TIMER_B =

INVITE transaction timeout timer (RFC 3261 17.1.1.2).

64*T1
TIMER_C =

Proxy INVITE transaction timeout (RFC 3261 16.6 bullet 11).

180
TIMER_C2 =

NOTE: This is a custom timer we use for INVITE server transactions in order to avoid they never end.

TIMER_C + 2
TIMER_D_UDP =

Wait time for response retransmits (RFC 3261 17.1.1.2).

32
TIMER_D_TCP =

> 32s for UDP.

0
TIMER_E =

Non-INVITE request retransmit interval, UDP only (RFC 3261 17.1.2.2).

T1
TIMER_F =

Non-INVITE transaction timeout timer.

64*T1
TIMER_G =

INVITE response retransmit interval (RFC 3261 17.2.1).

T1
TIMER_H =

Wait time for ACK receipt (RFC 3261 17.2.1).

64*T1
TIMER_I_UDP =

Wait time for ACK retransmits (RFC 3261 17.2.1).

T4
TIMER_I_TCP =

T4 for UDP.

0
TIMER_J_UDP =

Wait time for non-INVITE requests (RFC 3261 17.2.2).

64*T1
TIMER_J_TCP =

64*T1 for UDP.

0
TIMER_K_UDP =

Wait time for response retransmits (RFC 3261 17.1.2.2).

T4
TIMER_K_TCP =

T4 for UDP.

0
TIMER_L =

Wait time for accepted INVITE request retransmits (RFC 6026 17.2.1).

64*T1
TIMER_M =

Wait time for retransmission of 2xx to INVITE or additional 2xx from other branches of a forked INVITE (RFC 6026 17.1.1).

64*T1
INT1 =

Custom values.

Interval waiting in a non INVITE server transaction before sending 100 (RFC 4320 - Section 4.1).

T2 + 1
INT2 =

Interval waiting in a non INVITE server transaction before assuming timeout (RFC 4320 - Section 4.2).

TIMER_F - INT1
CRLF =
"\r\n"
DOUBLE_CRLF =
"\r\n\r\n"
REASON_PHRASE =
{
  100 => "Trying",
  180 => "Ringing",
  181 => "Call Is Being Forwarded",
  182 => "Queued",
  183 => "Session Progress",
  199 => "Early Dialog Terminated",  # draft-ietf-sipcore-199
  200 => "OK",
  202 => "Accepted",  # RFC 3265
  204 => "No Notification",  #RFC 5839
  300 => "Multiple Choices",
  301 => "Moved Permanently",
  302 => "Moved Temporarily",
  305 => "Use Proxy",
  380 => "Alternative Service",
  400 => "Bad Request",
  401 => "Unauthorized",
  402 => "Payment Required",
  403 => "Forbidden",
  404 => "Not Found",
  405 => "Method Not Allowed",
  406 => "Not Acceptable",
  407 => "Proxy Authentication Required",
  408 => "Request Timeout",
  410 => "Gone",
  412 => "Conditional Request Failed",  # RFC 3903
  413 => "Request Entity Too Large",
  414 => "Request-URI Too Long",
  415 => "Unsupported Media Type",
  416 => "Unsupported URI Scheme",
  417 => "Unknown Resource-Priority",  # RFC 4412
  420 => "Bad Extension",
  421 => "Extension Required",
  422 => "Session Interval Too Small",  # RFC 4028
  423 => "Interval Too Brief",
  424 => "Bad Location Information",  # RFC 6442
  428 => "Use Identity Header",  # RFC 4474
  429 => "Provide Referrer Identity",  # RFC 3892
  430 => "Flow Failed",  # RFC 5626
  433 => "Anonymity Disallowed",  # RFC 5079
  436 => "Bad Identity-Info",  # RFC 4474
  437 => "Unsupported Certificate",  # RFC 4744
  438 => "Invalid Identity Header",  # RFC 4744
  439 => "First Hop Lacks Outbound Support",  # RFC 5626
  440 => "Max-Breadth Exceeded",  # RFC 5393
  469 => "Bad Info Package",  # draft-ietf-sipcore-info-events
  470 => "Consent Needed",  # RF C5360
  478 => "Unresolvable Destination",  # Custom code copied from Kamailio.
  480 => "Temporarily Unavailable",
  481 => "Call/Transaction Does Not Exist",
  482 => "Loop Detected",
  483 => "Too Many Hops",
  484 => "Address Incomplete",
  485 => "Ambiguous",
  486 => "Busy Here",
  487 => "Request Terminated",
  488 => "Not Acceptable Here",
  489 => "Bad Event",  # RFC 3265
  491 => "Request Pending",
  493 => "Undecipherable",
  494 => "Security Agreement Required",  # RFC 3329
  500 => "Server Internal Error",
  501 => "Not Implemented",
  502 => "Bad Gateway",
  503 => "Service Unavailable",
  504 => "Server Time-out",
  505 => "Version Not Supported",
  513 => "Message Too Large",
  580 => "Precondition Failure",  # RFC 3312
  600 => "Busy Everywhere",
  603 => "Decline",
  604 => "Does Not Exist Anywhere",
  606 => "Not Acceptable"
}
REASON_PHRASE_NOT_SET =
"Reason Phrase Not Set"
HDR_SERVER =
"Server: #{::OverSIP::PROGRAM_NAME}/#{::OverSIP::VERSION}".freeze
HDR_USER_AGENT =
"User-Agent: #{::OverSIP::PROGRAM_NAME}/#{::OverSIP::VERSION}".freeze
HDR_ARRAY_CONTENT_LENGTH_0 =
[ "0" ].freeze

Class Method Summary collapse

Class Method Details

.callback_on_client_tls_handshakeObject



72
73
74
# File 'lib/oversip/sip/sip.rb', line 72

def self.callback_on_client_tls_handshake
  @callback_on_client_tls_handshake
end

.local_aliasesObject



56
57
58
# File 'lib/oversip/sip/sip.rb', line 56

def self.local_aliases
  @local_aliases
end

.local_ipv4Object



64
65
66
# File 'lib/oversip/sip/sip.rb', line 64

def self.local_ipv4
  @local_ipv4
end

.local_ipv6Object



68
69
70
# File 'lib/oversip/sip/sip.rb', line 68

def self.local_ipv6
  @local_ipv6
end

.module_initObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/oversip/sip/sip.rb', line 3

def self.module_init
  conf = ::OverSIP.configuration

  @local_ipv4 = conf[:sip][:listen_ipv4]
  @local_ipv6 = conf[:sip][:listen_ipv6]

  @tcp_keepalive_interval = conf[:sip][:tcp_keepalive_interval]

  @local_aliases = {}

  sip_local_domains = conf[:sip][:local_domains] || []
  sip_local_ips = []
  sip_local_ips << conf[:sip][:listen_ipv4]  if conf[:sip][:enable_ipv4]
  sip_local_ips << "[#{OverSIP::Utils.normalize_ipv6(conf[:sip][:listen_ipv6])}]"  if conf[:sip][:enable_ipv6]
  sip_local_ports = [ conf[:sip][:listen_port], conf[:sip][:listen_port_tls] ].compact
  sip_local_domains.each do |domain|
    @local_aliases[domain] = true
    sip_local_ports.each do |port|
      @local_aliases["#{domain}:#{port}"] = true
    end
  end
  sip_local_ips.each do |ip|
    sip_local_ports.each do |port|
      @local_aliases["#{ip}:#{port}"] = true
    end
  end
  sip_local_ips.each do |ip|
    @local_aliases[ip] = true  if conf[:sip][:listen_port] == 5060 or conf[:sip][:listen_port_tls] == 5061
  end

  ws_local_domains = conf[:sip][:local_domains] || []
  ws_local_ips = []
  ws_local_ips << conf[:websocket][:listen_ipv4]  if conf[:websocket][:enable_ipv4]
  ws_local_ips << "[#{OverSIP::Utils.normalize_ipv6(conf[:websocket][:listen_ipv6])}]"  if conf[:websocket][:enable_ipv6]
  ws_local_ports = [ conf[:websocket][:listen_port], conf[:websocket][:listen_port_tls] ].compact
  ws_local_domains.each do |domain|
    @local_aliases[domain] = true
    ws_local_ports.each do |port|
      @local_aliases["#{domain}:#{port}"] = true
    end
  end
  ws_local_ips.each do |ip|
    ws_local_ports.each do |port|
      @local_aliases["#{ip}:#{port}"] = true
    end
  end
  ws_local_ips.each do |ip|
    @local_aliases[ip] = true  if conf[:websocket][:listen_port] == 80 or conf[:websocket][:listen_port_tls] == 443
  end

  @callback_on_client_tls_handshake = conf[:sip][:callback_on_client_tls_handshake]
end

.tcp_keepalive_intervalObject



60
61
62
# File 'lib/oversip/sip/sip.rb', line 60

def self.tcp_keepalive_interval
  @tcp_keepalive_interval
end