oversip 1.4.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,6 +3,7 @@
3
3
 
4
4
  #include "../common/c_util.h"
5
5
  #include "ruby.h"
6
+ #include <ctype.h> // toupper()
6
7
 
7
8
 
8
9
  /* There are 20 headers with sort representation. */
@@ -16,7 +16,7 @@
16
16
 
17
17
  /** machine **/
18
18
 
19
- #line 571 "sip_message_parser.rl"
19
+ #line 572 "sip_message_parser.rl"
20
20
 
21
21
 
22
22
 
@@ -13038,11 +13038,11 @@ static const short _sip_message_parser_trans_keys[] = {
13038
13038
  97, 102, 13, 127, -64, -33, -32, -17,
13039
13039
  -16, -9, -8, -5, -4, -3, -2, 8,
13040
13040
  10, 31, 48, 57, 65, 70, 97, 102,
13041
- 13, 33, 35, 37, 44, 58, 59, 61,
13042
- 63, 64, 91, 93, 95, 126, 127, -64,
13043
- -33, -32, -17, -16, -9, -8, -5, -4,
13044
- -3, -2, 8, 10, 31, 36, 57, 65,
13045
- 90, 97, 122, 13, 33, 35, 37, 44,
13041
+ 9, 13, 32, 34, 35, 37, 44, 58,
13042
+ 60, 62, 64, 92, 94, 96, 127, -128,
13043
+ -65, -64, -33, -32, -17, -16, -9, -8,
13044
+ -5, -4, -3, -2, 31, 59, 63, 91,
13045
+ 93, 123, 125, 13, 33, 35, 37, 44,
13046
13046
  58, 59, 61, 62, 63, 64, 82, 91,
13047
13047
  93, 95, 114, 126, 127, -64, -33, -32,
13048
13048
  -17, -16, -9, -8, -5, -4, -3, -2,
@@ -25095,10 +25095,10 @@ static const short _sip_message_parser_indicies[] = {
25095
25095
  74, 75, 76, 77, 78, 1, 1, 7538,
25096
25096
  7538, 7538, 73, 79, 1, 74, 75, 76,
25097
25097
  77, 78, 1, 1, 7528, 7528, 7528, 73,
25098
- 79, 7517, 137, 7518, 137, 7511, 137, 137,
25099
- 137, 140, 184, 184, 7517, 7517, 1, 74,
25100
- 75, 76, 77, 78, 1, 1, 7517, 7517,
25101
- 7517, 73, 79, 7501, 137, 7502, 137, 7503,
25098
+ 73, 79, 73, 73, 137, 7518, 137, 7511,
25099
+ 73, 73, 140, 73, 73, 73, 1, 73,
25100
+ 74, 75, 76, 77, 78, 1, 137, 184,
25101
+ 73, 7517, 79, 7501, 137, 7502, 137, 7503,
25102
25102
  7504, 7505, 181, 7506, 140, 7539, 177, 177,
25103
25103
  7501, 7539, 7501, 1, 74, 75, 76, 77,
25104
25104
  78, 1, 1, 7501, 7501, 7501, 73, 73,
@@ -28749,7 +28749,7 @@ static const int sip_message_parser_error = 0;
28749
28749
  static const int sip_message_parser_en_main = 1;
28750
28750
 
28751
28751
 
28752
- #line 577 "sip_message_parser.rl"
28752
+ #line 578 "sip_message_parser.rl"
28753
28753
 
28754
28754
  int sip_message_parser_init(sip_message_parser *parser)
28755
28755
  {
@@ -28761,7 +28761,7 @@ int sip_message_parser_init(sip_message_parser *parser)
28761
28761
  cs = sip_message_parser_start;
28762
28762
  }
28763
28763
 
28764
- #line 583 "sip_message_parser.rl"
28764
+ #line 584 "sip_message_parser.rl"
28765
28765
  parser->cs = cs;
28766
28766
  parser->nread = 0;
28767
28767
  parser->error_start = NULL;
@@ -29487,28 +29487,29 @@ _match:
29487
29487
  case 81:
29488
29488
  #line 427 "sip_message_parser.rl"
29489
29489
  {
29490
- if (parser->do_uri)
29490
+ if (parser->do_uri) {
29491
29491
  if (!parser->uri_display_name_quoted)
29492
29492
  parser->uri.display_name(parser->parsed, parser->uri_owner, PTR_TO(mark), LEN(mark, p), parser->uri_scheme);
29493
29493
  else
29494
29494
  parser->uri.display_name(parser->parsed, parser->uri_owner, PTR_TO(mark)+1, LEN(mark, p)-2, parser->uri_scheme);
29495
+ }
29495
29496
  }
29496
29497
  break;
29497
29498
  case 82:
29498
- #line 436 "sip_message_parser.rl"
29499
+ #line 437 "sip_message_parser.rl"
29499
29500
  {
29500
29501
  parser->uri_display_name_quoted=1;
29501
29502
  }
29502
29503
  break;
29503
29504
  case 83:
29504
- #line 440 "sip_message_parser.rl"
29505
+ #line 441 "sip_message_parser.rl"
29505
29506
  {
29506
29507
  if (parser->do_uri)
29507
29508
  MARK(uri_start, p);
29508
29509
  }
29509
29510
  break;
29510
29511
  case 84:
29511
- #line 445 "sip_message_parser.rl"
29512
+ #line 446 "sip_message_parser.rl"
29512
29513
  {
29513
29514
  if (parser->do_uri)
29514
29515
  parser->uri.full(parser->parsed, parser->uri_owner, PTR_TO(uri_start), LEN(uri_start, p), parser->uri_scheme);
@@ -29520,29 +29521,29 @@ _match:
29520
29521
  }
29521
29522
  break;
29522
29523
  case 85:
29523
- #line 455 "sip_message_parser.rl"
29524
+ #line 456 "sip_message_parser.rl"
29524
29525
  { parser->message.init_component(parser->parsed, component_ruri); }
29525
29526
  break;
29526
29527
  case 86:
29527
- #line 457 "sip_message_parser.rl"
29528
+ #line 458 "sip_message_parser.rl"
29528
29529
  {
29529
29530
  parser->do_uri = 1;
29530
29531
  parser->uri_owner = uri_owner_ruri;
29531
29532
  }
29532
29533
  break;
29533
29534
  case 87:
29534
- #line 462 "sip_message_parser.rl"
29535
+ #line 463 "sip_message_parser.rl"
29535
29536
  {
29536
29537
  parser->message.init_component(parser->parsed, component_from);
29537
29538
  parser->hdr_field_name = header_field_from;
29538
29539
  }
29539
29540
  break;
29540
29541
  case 88:
29541
- #line 467 "sip_message_parser.rl"
29542
+ #line 468 "sip_message_parser.rl"
29542
29543
  { parser->num_from++; }
29543
29544
  break;
29544
29545
  case 89:
29545
- #line 469 "sip_message_parser.rl"
29546
+ #line 470 "sip_message_parser.rl"
29546
29547
  {
29547
29548
  if (parser->num_from == 1) {
29548
29549
  parser->do_uri = 1;
@@ -29551,18 +29552,18 @@ _match:
29551
29552
  }
29552
29553
  break;
29553
29554
  case 90:
29554
- #line 476 "sip_message_parser.rl"
29555
+ #line 477 "sip_message_parser.rl"
29555
29556
  {
29556
29557
  parser->message.init_component(parser->parsed, component_to);
29557
29558
  parser->hdr_field_name = header_field_to;
29558
29559
  }
29559
29560
  break;
29560
29561
  case 91:
29561
- #line 481 "sip_message_parser.rl"
29562
+ #line 482 "sip_message_parser.rl"
29562
29563
  { parser->num_to++; }
29563
29564
  break;
29564
29565
  case 92:
29565
- #line 483 "sip_message_parser.rl"
29566
+ #line 484 "sip_message_parser.rl"
29566
29567
  {
29567
29568
  if (parser->num_to == 1) {
29568
29569
  parser->do_uri = 1;
@@ -29571,19 +29572,19 @@ _match:
29571
29572
  }
29572
29573
  break;
29573
29574
  case 93:
29574
- #line 491 "sip_message_parser.rl"
29575
+ #line 492 "sip_message_parser.rl"
29575
29576
  {
29576
29577
  parser->message.from_tag(parser->parsed, PTR_TO(mark), LEN(mark, p));
29577
29578
  }
29578
29579
  break;
29579
29580
  case 94:
29580
- #line 495 "sip_message_parser.rl"
29581
+ #line 496 "sip_message_parser.rl"
29581
29582
  {
29582
29583
  parser->message.to_tag(parser->parsed, PTR_TO(mark), LEN(mark, p));
29583
29584
  }
29584
29585
  break;
29585
29586
  case 95:
29586
- #line 500 "sip_message_parser.rl"
29587
+ #line 501 "sip_message_parser.rl"
29587
29588
  {
29588
29589
  if (parser->route_found == 0) {
29589
29590
  parser->message.init_component(parser->parsed, component_route);
@@ -29593,30 +29594,30 @@ _match:
29593
29594
  }
29594
29595
  break;
29595
29596
  case 96:
29596
- #line 508 "sip_message_parser.rl"
29597
+ #line 509 "sip_message_parser.rl"
29597
29598
  {
29598
29599
  parser->message.init_component(parser->parsed, component_route_uri); }
29599
29600
  break;
29600
29601
  case 97:
29601
- #line 511 "sip_message_parser.rl"
29602
+ #line 512 "sip_message_parser.rl"
29602
29603
  {
29603
29604
  parser->do_uri = 1;
29604
29605
  parser->uri_owner = uri_owner_route;
29605
29606
  }
29606
29607
  break;
29607
29608
  case 98:
29608
- #line 517 "sip_message_parser.rl"
29609
+ #line 518 "sip_message_parser.rl"
29609
29610
  {
29610
29611
  parser->message.init_component(parser->parsed, component_contact);
29611
29612
  parser->hdr_field_name = header_field_contact;
29612
29613
  }
29613
29614
  break;
29614
29615
  case 99:
29615
- #line 522 "sip_message_parser.rl"
29616
+ #line 523 "sip_message_parser.rl"
29616
29617
  { parser->num_contact++; }
29617
29618
  break;
29618
29619
  case 100:
29619
- #line 524 "sip_message_parser.rl"
29620
+ #line 525 "sip_message_parser.rl"
29620
29621
  {
29621
29622
  if (parser->num_contact == 1) {
29622
29623
  parser->do_uri = 1;
@@ -29625,54 +29626,54 @@ _match:
29625
29626
  }
29626
29627
  break;
29627
29628
  case 101:
29628
- #line 536 "sip_message_parser.rl"
29629
+ #line 537 "sip_message_parser.rl"
29629
29630
  {
29630
29631
  if (parser->num_contact == 1)
29631
29632
  parser->message.contact_params(parser->parsed, PTR_TO(mark), LEN(mark, p));
29632
29633
  }
29633
29634
  break;
29634
29635
  case 102:
29635
- #line 541 "sip_message_parser.rl"
29636
+ #line 542 "sip_message_parser.rl"
29636
29637
  {
29637
29638
  if (parser->num_contact == 1)
29638
29639
  parser->message.contact_has_reg_id(parser->parsed);
29639
29640
  }
29640
29641
  break;
29641
29642
  case 103:
29642
- #line 546 "sip_message_parser.rl"
29643
+ #line 547 "sip_message_parser.rl"
29643
29644
  {
29644
29645
  parser->contact_is_valid = 1;
29645
29646
  }
29646
29647
  break;
29647
29648
  case 104:
29648
- #line 550 "sip_message_parser.rl"
29649
+ #line 551 "sip_message_parser.rl"
29649
29650
  {
29650
29651
  parser->contact_is_valid = 0;
29651
29652
  }
29652
29653
  break;
29653
29654
  case 105:
29654
- #line 555 "sip_message_parser.rl"
29655
+ #line 556 "sip_message_parser.rl"
29655
29656
  {
29656
29657
  parser->message.option_tag(parser->parsed, header_field_require, PTR_TO(mark), LEN(mark, p));
29657
29658
  }
29658
29659
  break;
29659
29660
  case 106:
29660
- #line 559 "sip_message_parser.rl"
29661
+ #line 560 "sip_message_parser.rl"
29661
29662
  {
29662
29663
  parser->message.option_tag(parser->parsed, header_field_proxy_require, PTR_TO(mark), LEN(mark, p));
29663
29664
  }
29664
29665
  break;
29665
29666
  case 107:
29666
- #line 563 "sip_message_parser.rl"
29667
+ #line 564 "sip_message_parser.rl"
29667
29668
  {
29668
29669
  parser->message.option_tag(parser->parsed, header_field_supported, PTR_TO(mark), LEN(mark, p));
29669
29670
  }
29670
29671
  break;
29671
29672
  case 108:
29672
- #line 568 "sip_message_parser.rl"
29673
+ #line 569 "sip_message_parser.rl"
29673
29674
  { {p++; goto _out; } }
29674
29675
  break;
29675
- #line 29676 "sip_message_parser.c"
29676
+ #line 29677 "sip_message_parser.c"
29676
29677
  }
29677
29678
  }
29678
29679
 
@@ -29685,7 +29686,7 @@ _again:
29685
29686
  _out: {}
29686
29687
  }
29687
29688
 
29688
- #line 640 "sip_message_parser.rl"
29689
+ #line 641 "sip_message_parser.rl"
29689
29690
 
29690
29691
  parser->cs = cs;
29691
29692
  parser->nread += p - (buffer + off);
@@ -201,6 +201,8 @@ static void header(VALUE parsed, const char *hdr_field, size_t hdr_field_len, co
201
201
  case header_field_route:
202
202
  rb_ivar_set(parsed, id_hdr_route, array);
203
203
  break;
204
+ default:
205
+ break;
204
206
  }
205
207
  }
206
208
  }
@@ -567,6 +569,7 @@ static void uri_known_param(VALUE parsed, enum uri_owner owner, enum uri_param_n
567
569
  case transport_ws: v = symbol_ws; break;
568
570
  case transport_wss: v = symbol_wss; break;
569
571
  case transport_unknown: v = my_rb_str_downcase(at, length); break;
572
+ default: break;
570
573
  }
571
574
  break;
572
575
  case uri_param_ovid:
@@ -582,6 +585,8 @@ static void uri_known_param(VALUE parsed, enum uri_owner owner, enum uri_param_n
582
585
  p = id_uri_phone_context_param;
583
586
  v = my_rb_str_downcase(at, length);
584
587
  break;
588
+ default:
589
+ break;
585
590
  }
586
591
 
587
592
  rb_ivar_set(get_uri_object(parsed, owner), p, v);
@@ -597,6 +602,7 @@ static void uri_has_param(VALUE parsed, enum uri_owner owner, enum uri_param_nam
597
602
  switch(param_name) {
598
603
  case uri_param_lr: p = id_uri_lr_param; break;
599
604
  case uri_param_ob: p = id_uri_ob_param; break;
605
+ default: break;
600
606
  }
601
607
 
602
608
  rb_ivar_set(get_uri_object(parsed, owner), p, Qtrue);
@@ -638,6 +644,7 @@ static void header_core_value(VALUE parsed, enum header_field header_field, cons
638
644
 
639
645
  switch(header_field) {
640
646
  case header_field_via: rb_ivar_set(parsed, id_via_core_value, v); break;
647
+ default: break;
641
648
  }
642
649
  }
643
650
 
@@ -671,6 +678,8 @@ static void header_param(VALUE parsed, enum header_field header_field, const cha
671
678
  v = Qnil;
672
679
  rb_hash_aset(header_params, my_rb_str_downcase(key, key_len), v);
673
680
  break; */
681
+ default:
682
+ break;
674
683
  }
675
684
  }
676
685
 
@@ -707,6 +716,7 @@ static void option_tag(VALUE parsed, enum header_field header_field, const char
707
716
  case header_field_require: id_option_tag_owner = id_require; break;
708
717
  case header_field_proxy_require: id_option_tag_owner = id_proxy_require; break;
709
718
  case header_field_supported: id_option_tag_owner = id_supported; break;
719
+ default: break;
710
720
  }
711
721
 
712
722
  if ((option_tag_owner = rb_ivar_get(parsed, id_option_tag_owner)) == Qnil) {
data/ext/utils/ip_utils.h CHANGED
@@ -5,6 +5,8 @@
5
5
  #include <netinet/in.h>
6
6
  #include <sys/types.h>
7
7
  #include <sys/socket.h>
8
+ #include <arpa/inet.h> // inet_pton()
9
+
8
10
 
9
11
  enum enum_ip_type {
10
12
  ip_type_ipv4 = 1,
@@ -10,6 +10,7 @@
10
10
  #include "ip_utils.h"
11
11
  #include "outbound_utils.h"
12
12
  #include "haproxy_protocol.h"
13
+ #include <arpa/inet.h> // inet_ntop()
13
14
 
14
15
 
15
16
  /* Export the Ruby C functions so other C libraries within OverSIP can use them. */
@@ -72,4 +73,4 @@ VALUE utils_normalize_ipv6(VALUE string, int force_pure_ipv6)
72
73
  }
73
74
 
74
75
 
75
- #endif
76
+ #endif
@@ -28,7 +28,8 @@ static const uint8_t utf8d[] = {
28
28
  1,3,1,1,1,1,1,3,1,3,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1 /* s7..s8 */
29
29
  };
30
30
 
31
- uint32_t inline utf8_decode(uint32_t* state, uint32_t* codep, uint32_t byte) {
31
+ static inline
32
+ uint32_t utf8_decode(uint32_t* state, uint32_t* codep, uint32_t byte) {
32
33
  uint32_t type = utf8d[byte];
33
34
 
34
35
  *codep = (*state != UTF8_ACCEPT) ? (byte & 0x3fu) | (*codep << 6) : (0xff >> type) & (byte);
@@ -101,7 +101,7 @@ VALUE Utf8Validator_validate(VALUE self, VALUE string)
101
101
  int i;
102
102
 
103
103
  REQUIRE_TYPE(string, T_STRING);
104
- str = RSTRING_PTR(string);
104
+ str = (uint8_t *)RSTRING_PTR(string);
105
105
 
106
106
  DATA_GET(self, utf8_validator, validator);
107
107
 
@@ -329,7 +329,7 @@ module OverSIP
329
329
 
330
330
  if ( @use_sip_udp_or_tcp or @use_sip_tls ) and @configuration[:sip][:listen_ipv4] == nil and @configuration[:sip][:enable_ipv4]
331
331
  unless (@configuration[:sip][:listen_ipv4] = discover_local_ip(:ipv4))
332
- log_system_warn "disabling IPv4 for SIP"
332
+ # log_system_notice "disabling IPv4 for SIP"
333
333
  @configuration[:sip][:listen_ipv4] = nil
334
334
  @configuration[:sip][:enable_ipv4] = false
335
335
  end
@@ -337,7 +337,7 @@ module OverSIP
337
337
 
338
338
  if ( @use_sip_udp_or_tcp or @use_sip_tls ) and @configuration[:sip][:listen_ipv6] == nil and @configuration[:sip][:enable_ipv6]
339
339
  unless (@configuration[:sip][:listen_ipv6] = discover_local_ip(:ipv6))
340
- log_system_warn "disabling IPv6 for SIP"
340
+ # log_system_notice "disabling IPv6 for SIP"
341
341
  @configuration[:sip][:listen_ipv6] = nil
342
342
  @configuration[:sip][:enable_ipv6] = false
343
343
  end
@@ -345,7 +345,7 @@ module OverSIP
345
345
 
346
346
  if ( @use_sip_ws or @use_sip_wss ) and @configuration[:websocket][:listen_ipv4] == nil and @configuration[:websocket][:enable_ipv4]
347
347
  unless (@configuration[:websocket][:listen_ipv4] = discover_local_ip(:ipv4))
348
- log_system_warn "disabling IPv4 for WebSocket"
348
+ # log_system_notice "disabling IPv4 for WebSocket"
349
349
  @configuration[:websocket][:listen_ipv4] = nil
350
350
  @configuration[:websocket][:enable_ipv4] = false
351
351
  end
@@ -353,7 +353,7 @@ module OverSIP
353
353
 
354
354
  if ( @use_sip_ws or @use_sip_wss ) and @configuration[:websocket][:listen_ipv6] == nil and @configuration[:websocket][:enable_ipv6]
355
355
  unless (@configuration[:websocket][:listen_ipv6] = discover_local_ip(:ipv6))
356
- log_system_warn "disabling IPv6 for WebSocket"
356
+ # log_system_notice "disabling IPv6 for WebSocket"
357
357
  @configuration[:websocket][:listen_ipv6] = nil
358
358
  @configuration[:websocket][:enable_ipv6] = false
359
359
  end
@@ -554,7 +554,7 @@ module OverSIP
554
554
  begin
555
555
  socket.bind ip, 0
556
556
  rescue => e
557
- log_system_warn "cannot bind in autodiscovered local #{type == :ipv4 ? "IPv4" : "IPv6"} '#{ip}': #{e.message} (#{e.class})"
557
+ # log_system_debug "cannot bind in autodiscovered local #{type == :ipv4 ? "IPv4" : "IPv6"} '#{ip}': #{e.message} (#{e.class})"
558
558
  return false
559
559
  ensure
560
560
  socket.close
@@ -562,7 +562,7 @@ module OverSIP
562
562
  # Valid IP, return it.
563
563
  return ip
564
564
  rescue => e
565
- log_system_warn "cannot autodiscover local #{type == :ipv4 ? "IPv4" : "IPv6"}: #{e.message} (#{e.class})"
565
+ # log_system_debug "cannot autodiscover local #{type == :ipv4 ? "IPv4" : "IPv6"}: #{e.message} (#{e.class})"
566
566
  return false
567
567
  end
568
568
  end
@@ -5,19 +5,15 @@ module OverSIP
5
5
  extend ::OverSIP::Logger
6
6
 
7
7
  def self.on_initialize
8
- log_system_notice "on_initialize() method is not defined"
9
8
  end
10
9
 
11
10
  def self.on_started
12
- log_system_notice "on_started() method is not defined"
13
11
  end
14
12
 
15
13
  def self.on_user_reload
16
- log_system_notice "on_user_reload() method is not defined"
17
14
  end
18
15
 
19
16
  def self.on_terminated error
20
- log_system_notice "on_terminated() method is not defined"
21
17
  end
22
18
 
23
19
 
@@ -28,15 +24,12 @@ module OverSIP
28
24
  extend ::OverSIP::Logger
29
25
 
30
26
  def self.on_request request
31
- log_system_notice "on_request() method is not defined"
32
27
  end
33
28
 
34
29
  def self.on_client_tls_handshake connection, pems
35
- log_system_notice "on_client_tls_handshake() method is not defined"
36
30
  end
37
31
 
38
32
  def self.on_server_tls_handshake connection, pems
39
- log_system_notice "on_server_tls_handshake() method is not defined"
40
33
  end
41
34
 
42
35
  end
@@ -46,15 +39,12 @@ module OverSIP
46
39
  extend ::OverSIP::Logger
47
40
 
48
41
  def self.on_connection connection, http_request
49
- log_system_notice "on_connection() method is not defined"
50
42
  end
51
43
 
52
44
  def self.on_disconnection connection, client_closed
53
- log_system_notice "on_disconnection() method is not defined"
54
45
  end
55
46
 
56
47
  def self.on_client_tls_handshake connection, pems
57
- log_system_notice "on_client_tls_handshake() method is not defined"
58
48
  end
59
49
 
60
50
  end