I'm experimenting with IP options and have added the following to the
file object.

void file_get_ip_options(INT32 args) {
  char buffer[44];
  socklen_t len = sizeof(buffer);
  int ret;

  pop_n_elems(args);
  ret = getsockopt(FD, IPPROTO_IP, IP_OPTIONS, buffer, &len);
  if(ret!=0)
  {
    push_int(0);
    return;
  }
  push_string( make_shared_binary_string( buffer, len ) );
}

void file_set_ip_options(INT32 args) {
  int ret;

  if(args!=1 || TYPEOF(Pike_sp[-args]) != PIKE_T_STRING)
    Pike_error("Illegal arguments to set_ip_options.\n");

  ret = setsockopt(FD, IPPROTO_IP, IP_OPTIONS, Pike_sp[-args].u.string->str,
                   Pike_sp[-args].u.string->len);
  pop_n_elems(args);
  push_int( ret==0 );
}

I can successfully set the NOP IP options with

Stdio.File f = Stdio.File();
f->open_socket();
f->set_ip_options("\1");

and can see it set in wireshark. However, I'm unable to read it out on
the server side. Is it my poor understanding of C or of network code
that is the problem?

Reply via email to