「Chan sip hikarihgw」の版間の差分

提供: VoIP-Info.jp
移動先: 案内検索
(ページの作成:「<pre> *** channels/chan_sip.c.bakup 2014-12-02 22:12:47.269411205 +0900 --- channels/chan_sip.c 2014-12-02 22:41:42.527274187 +0900 *************** *** 817,822 **** ---...」)
 
 
158行目: 158行目:
 
   #define DEFAULT_MAX_SE            1800  /*!< Session-Timer Default Session-Expires period (RFC 4028) */
 
   #define DEFAULT_MAX_SE            1800  /*!< Session-Timer Default Session-Expires period (RFC 4028) */
 
   #define DEFAULT_MIN_SE            90    /*!< Session-Timer Default Min-SE period (RFC 4028) */
 
   #define DEFAULT_MIN_SE            90    /*!< Session-Timer Default Min-SE period (RFC 4028) */
</nopre>
+
</pre>

2017年11月24日 (金) 14:34時点における最新版

*** channels/chan_sip.c.bakup   2014-12-02 22:12:47.269411205 +0900
--- channels/chan_sip.c 2014-12-02 22:41:42.527274187 +0900
***************
*** 817,822 ****
--- 817,826 ----
   */
  static int can_parse_xml;

+ /* Hikari denwa HGW HACK */
+ static char global_hikari_hgw[MAX_HGWS][20];
+ static int  global_hikari_hgw_cnt = 0;
+
  /*! \name Object counters @{
   *
   * \bug These counters are not handled in a thread-safe way ast_atomic_fetchadd_int()
***************
*** 1301,1306 ****
--- 1305,1311 ----
  static char *sip_unregister(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
  static char *sip_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
  static char *sip_show_mwi(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
+ static char *sip_show_hikarihgw(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
  static const char *subscription_type2str(enum subscriptiontype subtype) attribute_pure;
  static const struct cfsubscription_types *find_subscription_type(enum subscriptiontype subtype);
  static char *complete_sip_peer(const char *word, int state, int flags2);
***************
*** 18970,18975 ****
--- 18975,19009 ----
  #undef FORMAT2
  }

+ /*! \brief Show registered HGWs */
+ static char *sip_show_hikarihgw(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+ {
+       int     tmp_i;
+
+       switch (cmd) {
+          case CLI_INIT:
+                  e->command = "sip show hikarihgw";
+                  e->usage =
+                          "Usage: sip show hikarihgw\n"
+                          "       List Hikari-denwa HGWS(s) settings.\n";
+                  return NULL;
+          case CLI_GENERATE:
+                  return NULL;
+          }
+
+        if (a->argc != 3)
+                return CLI_SHOWUSAGE;
+        if (global_hikari_hgw_cnt == 0){
+                ast_cli(a->fd,"No Hikari-denwa HGW(s)\n");
+        } else {
+                ast_cli(a->fd,"Hikari-denwa HGW at ..\n");
+                for (tmp_i=0;tmp_i<global_hikari_hgw_cnt;tmp_i++){
+                        ast_cli(a->fd, "- %-16.16s\n", global_hikari_hgw[tmp_i]);
+                }
+        }
+
+        return CLI_SUCCESS;
+ }

  /*! \brief Convert transfer mode to text string */
  static char *transfermode2str(enum transfermodes mode)
***************
*** 22102,22107 ****
--- 22136,22146 ----
        struct sip_auth *auth;  /* Realm authentication credential */
        struct sip_auth_container *credentials;

+       /* Hikari-denwa HGW HACK */
+       char tmp_addr[20];
+       char tmp_uri[256];
+       int tmp_i;
+
        if (!ast_strlen_zero(p->domain))
                snprintf(uri, sizeof(uri), "%s:%s", p->socket.type == AST_TRANSPORT_TLS ? "sips" : "sip", p->domain);
        else if (!ast_strlen_zero(p->uri))
***************
*** 22109,22114 ****
--- 22148,22175 ----
        else
                snprintf(uri, sizeof(uri), "%s:%s@%s", p->socket.type == AST_TRANSPORT_TLS ? "sips" : "sip", p->username, ast_sockaddr_stringify_host_remote(&p->sa));

+       /* Hikari-denwa HGW HACK */
+       strcpy(tmp_addr, ast_sockaddr_stringify_host(&p->sa));
+       /* ast_verbose(VERBOSE_PREFIX_3 "inet is  %s \n", tmp_addr); */
+       for (tmp_i=0;tmp_i<global_hikari_hgw_cnt;tmp_i++){
+               if(strcmp(tmp_addr, global_hikari_hgw[tmp_i]) == 0){
+                       /* ast_verbose(VERBOSE_PREFIX_3 "Peer is Hikari-denwa HGW\n"); */
+                       if ((strcmp(uri, "domain") == 0) || (strcmp(uri, "sip:domain") == 0)) {
+                               strncpy(tmp_uri, p->uri, sizeof(tmp_uri));
+                               switch (method) {
+                               case    SIP_REGISTER:
+                                       sprintf(uri, "sip:%s",tmp_addr);
+                                       break;
+                               default:
+                                       *strchr(tmp_uri, '@') = '\0';
+                                       snprintf(uri, sizeof(uri), "%s@%s",tmp_uri,tmp_addr);
+                                       break;
+                               }
+                       }
+               }
+       }
+       /* Hikari-denwa HGW HACK END */
+
        snprintf(cnonce, sizeof(cnonce), "%08lx", (unsigned long)ast_random());

        /* Check if we have peer credentials */
***************
*** 31321,31326 ****
--- 31382,31391 ----

        sip_cfg.matchexternaddrlocally = DEFAULT_MATCHEXTERNADDRLOCALLY;

+       /* Hikari-denwa HGW HACK */
+       memset(global_hikari_hgw, 0, sizeof(global_hikari_hgw));
+       global_hikari_hgw_cnt = 0;
+
        /* Copy the default jb config over global_jbconf */
        memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));

***************
*** 31795,31800 ****
--- 31860,31870 ----
                        }
                } else if (!strcasecmp(v->name, "matchexternaddrlocally") || !strcasecmp(v->name, "matchexterniplocally")) {
                        sip_cfg.matchexternaddrlocally = ast_true(v->value);
+               } else if (!strcasecmp(v->name, "hikarihgw")) { /*Hikari-denwa HGW HACK*/
+                       if (global_hikari_hgw_cnt < MAX_HGWS) {
+                               ast_copy_string(global_hikari_hgw[global_hikari_hgw_cnt], v->value, sizeof(global_hikari_hgw));
+                       global_hikari_hgw_cnt++;
+                       }
                } else if (!strcasecmp(v->name, "session-timers")) {
                        int i = (int) str2stmode(v->value);
                        if (i < 0) {
***************
*** 33240,33245 ****
--- 33310,33316 ----
        AST_CLI_DEFINE(sip_show_registry, "List SIP registration status"),
        AST_CLI_DEFINE(sip_unregister, "Unregister (force expiration) a SIP peer from the registry"),
        AST_CLI_DEFINE(sip_show_settings, "Show SIP global settings"),
+       AST_CLI_DEFINE(sip_show_hikarihgw, "Show Hikari-denwa HGW settings"),
        AST_CLI_DEFINE(sip_show_mwi, "Show MWI subscriptions"),
        AST_CLI_DEFINE(sip_cli_notify, "Send a notify packet to a SIP peer"),
        AST_CLI_DEFINE(sip_show_channel, "Show detailed SIP channel info"),
*** channels/sip/include/sip.h.org      2014-07-25 02:47:29.000000000 +0900
--- channels/sip/include/sip.h  2014-12-02 22:34:05.931283654 +0900
***************
*** 109,114 ****
--- 109,117 ----

  #define INITIAL_CSEQ              101    /*!< Our initial sip sequence number */

+ /* Hikari-denwa HGW HACK */
+ #define MAX_HGWS                  4       /* Number of HGWs */
+
  #define DEFAULT_MAX_SE            1800   /*!< Session-Timer Default Session-Expires period (RFC 4028) */
  #define DEFAULT_MIN_SE            90     /*!< Session-Timer Default Min-SE period (RFC 4028) */