ext/sctp/socket.c
/*
 * Set the initial parameters used by the socket when sending out the INIT message.
 *
 * Example:
 *
 *  socket = SCTP::Socket.new
 *  socket.set_initmsg(:output_streams => 5, :input_streams => 5, :max_attempts => 4, :timeout => 30)
 *
 * The following parameters can be configured:
 *
 * :output_streams - The number of outbound SCTP streams an application would like to request.
 * :input_streams - The maximum number of inbound streams an application is prepared to allow.
 * :max_attempts - How many times the the SCTP stack should send the initial INIT message before it's considered unreachable.
 * :timeout - The maximum RTO value for the INIT timer.
 *
 * By default these values are set to zero (i.e. ignored).
 */
Set the initial parameters used by the socket when sending out the INIT message.
Example.



The following parameters can be configured.

:output_streams - The number of outbound SCTP streams an application would like to request.
:input_streams - The maximum number of inbound streams an application is prepared to allow.
:max_attempts - How many times the the SCTP stack should send the initial INIT message before it's considered unreachable.
:timeout - The maximum RTO value for the INIT timer.

By default these values are set to zero .
Set the initial parameters used by the socket when sending out the INIT message . Example . The following parameters can be configured . : output_streams - The number of outbound SCTP streams an application would like to request . : input_streams - The maximum number of inbound streams an application is prepared to allow . : max_attempts - How many times the the SCTP stack should send the initial INIT message before it ' s considered unreachable . : timeout - The maximum RTO value for the INIT timer . By default these values are set to zero .
static VALUE rsctp_set_initmsg(VALUE self, VALUE v_options){
  int sock_fd;
  struct sctp_initmsg initmsg;
  VALUE v_output, v_input, v_attempts, v_timeout;
  bzero(&initmsg, sizeof(initmsg));
  v_output   = rb_hash_aref2(v_options, "output_streams");
  v_input    = rb_hash_aref2(v_options, "input_streams");
  v_attempts = rb_hash_aref2(v_options, "max_attempts");
  v_timeout  = rb_hash_aref2(v_options, "timeout");
  sock_fd = NUM2INT(rb_iv_get(self, "@sock_fd"));
  if(!NIL_P(v_output))
    initmsg.sinit_num_ostreams = NUM2INT(v_output);
  if(!NIL_P(v_input))
    initmsg.sinit_max_instreams = NUM2INT(v_input);
  if(!NIL_P(v_attempts))
    initmsg.sinit_max_attempts = NUM2INT(v_attempts);
  if(!NIL_P(v_timeout))
    initmsg.sinit_max_init_timeo = NUM2INT(v_timeout);
  if(setsockopt(sock_fd, IPPROTO_SCTP, SCTP_INITMSG, &initmsg, sizeof(initmsg)) < 0)
    rb_raise(rb_eSystemCallError, "setsockopt: %s", strerror(errno));
  return self;
}
static VALUE rsctp_set_initmsg ( VALUE self , VALUE v_options ) { int sock_fd ; struct sctp_initmsg initmsg ; VALUE v_output , v_input , v_attempts , v_timeout ; bzero ( & initmsg , sizeof ( initmsg ) ) ; v_output = rb_hash_aref2 ( v_options , " " ) ; v_input = rb_hash_aref2 ( v_options , " " ) ; v_attempts = rb_hash_aref2 ( v_options , " " ) ; v_timeout = rb_hash_aref2 ( v_options , " " ) ; sock_fd = NUM2INT ( rb_iv_get ( self , " " ) ) ; if ( ! NIL_P ( v_output ) ) initmsg . sinit_num_ostreams = NUM2INT ( v_output ) ; if ( ! NIL_P ( v_input ) ) initmsg . sinit_max_instreams = NUM2INT ( v_input ) ; if ( ! NIL_P ( v_attempts ) ) initmsg . sinit_max_attempts = NUM2INT ( v_attempts ) ; if ( ! NIL_P ( v_timeout ) ) initmsg . sinit_max_init_timeo = NUM2INT ( v_timeout ) ; if ( setsockopt ( sock_fd , IPPROTO_SCTP , SCTP_INITMSG , & initmsg , sizeof ( initmsg ) ) < 0 ) rb_raise ( rb_eSystemCallError , " " , strerror ( errno ) ) ; return self ; }
Set the initial parameters used by the socket when sending out the INIT message.
Set the initial parameters used by the socket when sending out the INIT message .