PUBLIC int ioctl ARGS3
	(int,	d, 
	int,	request,
	char *, argp)
{
  int sdc, status;
  unsigned short fun, iosb[4];
  char *p5, *p6;
  struct comm
    {
      int command;
      char *addr;
    } ioctl_comm;
  struct it2
    {
      unsigned short len;
      unsigned short opt;
      struct comm *addr;
    } ioctl_desc;
  if ((sdc = vaxc$get_sdc (d)) == 0)
    {
      errno = EBADF;
      return -1;
    }
  ioctl_desc.opt  = UCX$C_IOCTL;
  ioctl_desc.len  = sizeof(struct comm);
  ioctl_desc.addr = &ioctl_comm;
  if (request & IOC_OUT)
    {
      fun = IO$_SENSEMODE;
      p5 = 0;
      p6 = (char *)&ioctl_desc;
    }
  else
    {
      fun = IO$_SETMODE;
      p5 = (char *)&ioctl_desc;
      p6 = 0;
    }
  ioctl_comm.command = request;
  ioctl_comm.addr = argp;
  status = sys$qiow (0, sdc, fun, iosb, 0, 0,
    0, 0, 0, 0, p5, p6);
  if (!(status & 01))
    {
      errno = status;
      return -1;
    }
  if (!(iosb[0] & 01))
    {
      errno = iosb[0];
      return -1;
    }
  return 0;
}
示例#2
0
pwr_tBoolean
inet_GetArpEntry (
  pwr_tStatus	*sts,
  int		isock,
  struct arpreq	*rp  
)
{
  struct ipaddr_in	*ipaddr;
  char			*hwaddr;
  pwr_tStatus		lsts;
  static int			retlen;
  static struct  ARPREQDEF	req;             /* ARP request ioctl block */
  static struct  ioctl_comm	command = {SIOCGARP, &req};
  struct  itmlist_3	desc = {sizeof(command), UCX$C_IOCTL, &command, &retlen};
  int			sdc;  /* socket device channel */
  int		sock = 0;

  if (isock == 0) {
    sock = socket(AF_INET, SOCK_DGRAM, 0);
  } else {
    sock = isock;
  }

  memset(&req, 0, sizeof(req));
  memcpy(&req.ARP$T_PA[4], &rp->arp_pa.sa_data, sizeof(rp->arp_pa.sa_data));

  req.ARP$T_PA[0] = AF_INET;
  retlen = sizeof(command);

  sdc = vaxc$get_sdc(sock);
  *sts = sys$qiow(0, sdc, IO$_SENSEMODE, &iosb, 0, 0, 0, 0, 0, 0, 0, &desc);
  if (ODD(*sts)) {
    if (EVEN(iosb.sts)) {
      *sts = iosb.sts;
    } else {
      memcpy(&rp->arp_ha.sa_data, &req.ARP$T_HA[2], sizeof(rp->arp_ha.sa_data));
    }
  }

  if (isock == 0) {
    close(sock);
  }

  return ODD(*sts);
}