Logo Search packages:      
Sourcecode: g2ipmsg version File versions  Download package

static int ipmsg_proc_get_public_key ( const udp_con_t *  con,
const msg_data_t *  msg 
) [static]

IPMSGのIPMSG_GETPUBKEYパケットを処理する

Parameters:
[in] con UDPコネクション情報
[in] msg 受信したメッセージのメッセージ情報
Return values:
0 正常終了
-EINVAL 引数異常
Attention:
内部リンケージ

Definition at line 629 of file protocol.c.

References IPMSG_PROTOCOL_MSG_NO_EXTENSION, IPMSG_PROTOCOL_PKTNUM_AUTO, ipmsg_send_packet(), and pcrypt_crypt_generate_anspubkey_string().

Referenced by ipmsg_dispatch_message().

                                                                      {
      int                         rc = 0;
      size_t                     len = 0;
      int                      index = 0;
      ipmsg_cap_t           peer_cap = 0;
      ipmsg_send_flags_t local_flags = 0;
      char                  *ans_msg = NULL;
      const char             *ipaddr = NULL;

      dbg_out("here\n");

      if ( (con == NULL) || (msg == NULL) ) {
            rc = -EINVAL;
            goto error_out;
      }

      /*
       * フラグ設定
       */
      local_flags = IPMSG_ANSPUBKEY;

      /*
       * ピアのIPアドレスを取得する.
       */
      ipaddr = udp_get_peeraddr(con);
      if (ipaddr == NULL) {
            rc = -ENOENT;
            goto error_out;
      }

#if defined(USE_OPENSSL)

      peer_cap = (ipmsg_cap_t)strtoul(msg->message, (char **)NULL, 16);

      dbg_out("Get public key:peer capability %x(%s)\n", peer_cap, msg->message);

      rc = pcrypt_crypt_generate_anspubkey_string(peer_cap, (const char **)&ans_msg);
      if (rc != 0) {
            g_assert(ans_msg == NULL);
            goto error_out;
      }
      /*
       * パケット送信
       */
      rc = ipmsg_send_packet(con, ipaddr,IPMSG_PROTOCOL_PKTNUM_AUTO, local_flags, 
          ans_msg, IPMSG_PROTOCOL_MSG_NO_EXTENSION);
      if (rc != 0) {
            goto free_ans_msg_out;
      }

      rc = 0; /* 正常終了 */

free_ans_msg_out:
      if (ans_msg != NULL)
            g_free(ans_msg);

#else
      rc = -ENOSYS;  /*  暗号化未サポート  */
#endif  /* USE_OPENSSL */

error_out:
      return rc;
}


Generated by  Doxygen 1.6.0   Back to index