Пример #1
0
/**gjd : register/unregister rpa table, used for local board **/
int register_rpa_interface_table(struct interface *ifp)
{
	int fd, ret;
	int flag;
	index_table_info dev_index_info;

	
	ifp->slot = get_slot_num(ifp->name);
	
	dev_index_info.slotNum = ifp->slot - 1;
	dev_index_info.netdevNum =ifp->devnum;

	/**0: not rpa dev (real interface), 1:rpa dev**/
	flag = 0;
	dev_index_info.flag = flag;
	dev_index_info.ifindex = ifp->ifindex;
	fd = open(DEV_NAME, O_RDWR);
	if(fd < 0)
	{
		zlog_warn("ioctl open error : %s .\n",safe_strerror(errno));
		return -1;
	}
		
	ret = ioctl(fd, RPA_IOC_INDEX_TABLE_ADD, &dev_index_info);
	if(ret < 0)
	{
		zlog_warn("ioctl error : %s .\n",safe_strerror(errno));
		close(fd);
		return -1;
	}

	close(fd);
	ifp->devnum = ret;/**fetch the devnum**/
	return 0;
		

}
Пример #2
0
/* Get type specified information from netlink. */
static int
netlink_request (int family, int type, struct nlsock *nl)
{
  int ret;
  struct sockaddr_nl snl;
  int save_errno;

  struct
  {
    struct nlmsghdr nlh;
    struct rtgenmsg g;
  } req;


  /* Check netlink socket. */
  if (nl->sock < 0)
    {
      zlog (NULL, LOG_ERR, "%s socket isn't active.", nl->name);
      return -1;
    }

  memset (&snl, 0, sizeof snl);
  snl.nl_family = AF_NETLINK;

  memset (&req, 0, sizeof req);
  req.nlh.nlmsg_len = sizeof req;
  req.nlh.nlmsg_type = type;
  req.nlh.nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST;
  req.nlh.nlmsg_pid = nl->snl.nl_pid;
  req.nlh.nlmsg_seq = ++nl->seq;
  req.g.rtgen_family = family;

  /* linux appears to check capabilities on every message 
   * have to raise caps for every message sent
   */

  ret = sendto (nl->sock, (void *) &req, sizeof req, 0,
                (struct sockaddr *) &snl, sizeof snl);
  save_errno = errno;

  if (ret < 0)
    {
      zlog (NULL, LOG_ERR, "%s sendto failed: %s", nl->name,
            safe_strerror (save_errno));
      return -1;
    }

  return 0;
}
pthread_t
gdb_pthread_fork(pthread_fn_t function, void *arg)
{
  int result;
  pthread_t pthread = NULL;
  pthread_attr_t attr;

  result = pthread_attr_init(&attr);
  if (result != 0)
    {
      error("Unable to initialize thread attributes: %s (%d)",
            safe_strerror(errno), errno);
    }

  result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
  if (result != 0)
    {
      error("Unable to initialize thread attributes: %s (%d)",
            safe_strerror(errno), errno);
    }

  result = pthread_create(&pthread, &attr, function, arg);
  if (result != 0)
    {
      error("Unable to create thread: %s (%d)", safe_strerror(errno), errno);
    }

  result = pthread_attr_destroy(&attr);
  if (result != 0)
    {
      warning("Unable to deallocate thread attributes: %s (%d)",
              safe_strerror(errno), errno);
    }

  return pthread;
}
Пример #4
0
static struct btrace_target_info *
x86_linux_enable_btrace (struct target_ops *self, ptid_t ptid,
                         const struct btrace_config *conf)
{
    struct btrace_target_info *tinfo;

    errno = 0;
    tinfo = linux_enable_btrace (ptid, conf);

    if (tinfo == NULL)
        error (_("Could not enable branch tracing for %s: %s."),
               target_pid_to_str (ptid), safe_strerror (errno));

    return tinfo;
}
Пример #5
0
static void
ctf_start (struct trace_file_writer *self, const char *dirname)
{
  char *file_name;
  struct cleanup *old_chain;
  struct ctf_trace_file_writer *writer
    = (struct ctf_trace_file_writer *) self;
  int i;
  mode_t hmode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH;

  /* Create DIRNAME.  */
  if (mkdir (dirname, hmode) && errno != EEXIST)
    error (_("Unable to open directory '%s' for saving trace data (%s)"),
	   dirname, safe_strerror (errno));

  memset (&writer->tcs, '\0', sizeof (writer->tcs));

  file_name = xstrprintf ("%s/%s", dirname, CTF_METADATA_NAME);
  old_chain = make_cleanup (xfree, file_name);

  writer->tcs.metadata_fd = fopen (file_name, "w");
  if (writer->tcs.metadata_fd == NULL)
    error (_("Unable to open file '%s' for saving trace data (%s)"),
	   file_name, safe_strerror (errno));
  do_cleanups (old_chain);

  ctf_save_metadata_header (&writer->tcs);

  file_name = xstrprintf ("%s/%s", dirname, CTF_DATASTREAM_NAME);
  old_chain = make_cleanup (xfree, file_name);
  writer->tcs.datastream_fd = fopen (file_name, "w");
  if (writer->tcs.datastream_fd == NULL)
    error (_("Unable to open file '%s' for saving trace data (%s)"),
	   file_name, safe_strerror (errno));
  do_cleanups (old_chain);
}
Пример #6
0
static void
ctf_save_write_metadata (struct trace_write_handler *handler,
			 const char *format, ...)
{
  va_list args;

  va_start (args, format);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-nonliteral"
  if (vfprintf (handler->metadata_fd, format, args) < 0)
    error (_("Unable to write metadata file (%s)"),
	     safe_strerror (errno));
#pragma clang diagnostic pop
  va_end (args);
}
Пример #7
0
/* Return socket of sockunion. */
int sockunion_socket(const union sockunion *su)
{
	int sock;

	sock = socket(su->sa.sa_family, SOCK_STREAM, 0);
	if (sock < 0) {
		char buf[SU_ADDRSTRLEN];
		zlog_warn("Can't make socket for %s : %s",
			  sockunion_log(su, buf, SU_ADDRSTRLEN),
			  safe_strerror(errno));
		return -1;
	}

	return sock;
}
Пример #8
0
static void
pwd_command (char *args, int from_tty)
{
  if (args)
    error (_("The \"pwd\" command does not take an argument: %s"), args);
  if (! getcwd (gdb_dirbuf, sizeof (gdb_dirbuf)))
    error (_("Error finding name of working directory: %s"),
           safe_strerror (errno));

  if (strcmp (gdb_dirbuf, current_directory) != 0)
    printf_unfiltered (_("Working directory %s\n (canonically %s).\n"),
		       current_directory, gdb_dirbuf);
  else
    printf_unfiltered (_("Working directory %s.\n"), current_directory);
}
Пример #9
0
int
getsockopt_so_sendbuf (const int sock)
{
  u_int32_t optval;
  socklen_t optlen = sizeof (optval);
  int ret = getsockopt (sock, SOL_SOCKET, SO_SNDBUF,
    (char *)&optval, &optlen);
  if (ret < 0)
  {
    zlog_err ("fd %d: can't getsockopt SO_SNDBUF: %d (%s)",
      sock, errno, safe_strerror (errno));
    return ret;
  }
  return optval;
}
Пример #10
0
int
ospf6_recvmsg (struct in6_addr *src, struct in6_addr *dst,
               unsigned int *ifindex, struct iovec *message)
{
  int retval;
  struct msghdr rmsghdr;
  struct cmsghdr *rcmsgp;
  u_char cmsgbuf[CMSG_SPACE(sizeof (struct in6_pktinfo))];
  struct in6_pktinfo *pktinfo;
  struct sockaddr_in6 src_sin6;

  rcmsgp = (struct cmsghdr *)cmsgbuf;
  pktinfo = (struct in6_pktinfo *)(CMSG_DATA(rcmsgp));
  memset (&src_sin6, 0, sizeof (struct sockaddr_in6));

  /* receive control msg */
  rcmsgp->cmsg_level = IPPROTO_IPV6;
  rcmsgp->cmsg_type = IPV6_PKTINFO;
  rcmsgp->cmsg_len = CMSG_LEN (sizeof (struct in6_pktinfo));
  /* rcmsgp = CMSG_NXTHDR (&rmsghdr, rcmsgp); */

  /* receive msg hdr */
  memset (&rmsghdr, 0, sizeof (rmsghdr));
  rmsghdr.msg_iov = message;
  rmsghdr.msg_iovlen = iov_count (message);
  rmsghdr.msg_name = (caddr_t) &src_sin6;
  rmsghdr.msg_namelen = sizeof (struct sockaddr_in6);
  rmsghdr.msg_control = (caddr_t) cmsgbuf;
  rmsghdr.msg_controllen = sizeof (cmsgbuf);

  retval = recvmsg (ospf6_sock, &rmsghdr, 0);
  if (retval < 0)
    zlog_warn ("recvmsg failed: %s", safe_strerror (errno));
  else if (retval == iov_totallen (message))
    zlog_warn ("recvmsg read full buffer size: %d", retval);

  /* source address */
  assert (src);
  memcpy (src, &src_sin6.sin6_addr, sizeof (struct in6_addr));

  /* destination address */
  if (ifindex)
    *ifindex = pktinfo->ipi6_ifindex;
  if (dst)
    memcpy (dst, &pktinfo->ipi6_addr, sizeof (struct in6_addr));

  return retval;
}
Пример #11
0
/*gujd : 2012-08-02, pm 6:17 . Add for ve sub from ve1.100 change to ve01f1.100 .*/
int
ve_sub_inteface_name_check(const char *name, char *name_return)
{
	char name_str[64]={0};
	char *endp = NULL;
	unsigned int slot_id = 0;
	
	memcpy(name_str,name,strlen(name));

	slot_id = strtoul(name_str+2,&endp,10);/*use name_str+2, cut "ve" .*/
	if(slot_id <= 0)
	{
		zlog_warn("%s : strtoul get slot_id failed(%s).\n",__func__,safe_strerror(errno));
		return -1;
		
	}
	if(endp)
	{
		if(endp[0]=='.')/*like ve1.100*/
		{
			if(slot_id >=1 && slot_id <= 9)/*slot 1--9, add to '01, 02, ..., 09' */
			{
				sprintf(name_return,"ve0%df1%s",slot_id,endp);/*consider as first cpu, so add 'f1' .*/
				return 0;
			}
			else/* > 9*/
			{
				sprintf(name_return,"ve%df1%s",slot_id,endp);/*consider as first cpu, so add 'f1' .*/
				return 0;
			}
		}
		else if(endp[0]=='f'||endp[0]=='s')/*like ve01f1.100*/
		{
			return 1;
		}
		else
		{
			zlog_warn("%s: err parments!\n",__func__);
			return -1;
		}
			
	}
	else
		{
			return -1;
		}
	
}
Пример #12
0
int
isis_recv_pdu_p2p (struct isis_circuit *circuit, u_char * ssnpa)
{
    int bytesread;

    bytesread = stream_read (circuit->rcv_stream, circuit->fd,
                             circuit->interface->mtu);

    if (bytesread < 0)
    {
        zlog_warn ("isis_recv_pdu_p2p(): read () failed: %s", safe_strerror (errno));
        return ISIS_WARNING;
    }

    return ISIS_OK;
}
Пример #13
0
/* get interface flags */
void if_get_flags (struct interface *ifp)
{
	int ret = 0;
	struct ifreq ifreq;

	ifreq_set_name (&ifreq, ifp);

	ret = if_ioctl (SIOCGIFFLAGS, (caddr_t) &ifreq);
	if (ret < 0)
	{
		zlog_err("if_ioctl(SIOCGIFFLAGS) failed: %s", safe_strerror(errno));
		return;
	}

	if_flags_update (ifp, (ifreq.ifr_flags & 0x0000ffff));
}
Пример #14
0
/*
  pim_time_monotonic_dsec():
  number of deciseconds since some unspecified starting point
*/
int64_t pim_time_monotonic_dsec()
{
  struct timeval now_tv;
  int64_t        now_dsec;

  if (gettime_monotonic(&now_tv)) {
    zlog_err("%s: gettime_monotonic() failure: errno=%d: %s",
	     __PRETTY_FUNCTION__,
	     errno, safe_strerror(errno));
    return -1;
  }

  now_dsec = ((int64_t) now_tv.tv_sec) * 10 + ((int64_t) now_tv.tv_usec) / 100000;

  return now_dsec;
}
Пример #15
0
int ShiftWriter::Write(void* buf, int len)
{
    int ret = safe_write(_fd, buf, static_cast<size_t>(len));
    if (ret < 0) {
        _errmsg = safe_strerror(errno);
    }

    _cur_file_size += len;
    // shift最好放在后边,这样如果刚好写完一个文件,就会生成另一个文件
    // 否则可能会看到没有log主文件
    if (_cur_file_size > _max_file_size && !Shift()) {
        return -1;
    }

    return ret;
}
Пример #16
0
/* ospf6 set socket option */
void
ospf6_sso (u_int ifindex, struct in6_addr *group, int option)
{
  struct ipv6_mreq mreq6;
  int ret;

  assert (ifindex);
  mreq6.ipv6mr_interface = ifindex;
  memcpy (&mreq6.ipv6mr_multiaddr, group, sizeof (struct in6_addr));

  ret = setsockopt (ospf6_sock, IPPROTO_IPV6, option,
                    &mreq6, sizeof (mreq6));
  if (ret < 0)
    zlog_err ("Network: setsockopt (%d) on ifindex %d failed: %s",
              option, ifindex, safe_strerror (errno));
}
Пример #17
0
static int
ctf_save_fseek (struct trace_write_handler *handler, long offset,
		int whence)
{
  gdb_assert (whence != SEEK_END);
  gdb_assert (whence != SEEK_SET
	      || offset <= handler->content_size + handler->packet_start);

  if (fseek (handler->datastream_fd, offset, whence))
    error (_("Unable to seek file for saving trace data (%s)"),
	   safe_strerror (errno));

  if (whence == SEEK_CUR)
    handler->content_size += offset;

  return 0;
}
Пример #18
0
void safe_perror(const char *message) {
    // Note we cannot use strerror, because on Linux it uses gettext, which is not safe.
    int err = errno;

    char buff[384];
    buff[0] = '\0';

    if (message) {
        safe_append(buff, message, sizeof buff);
        safe_append(buff, ": ", sizeof buff);
    }
    safe_append(buff, safe_strerror(err), sizeof buff);
    safe_append(buff, "\n", sizeof buff);

    write_ignore(STDERR_FILENO, buff, strlen(buff));
    errno = err;
}
Пример #19
0
// Create SIS-IS listener from existing socket
static int sisis_listener (int sock, struct sockaddr *sa, socklen_t salen)
{
  struct sisis_listener *listener;
  int ret, en;

  sockopt_reuseaddr (sock);
  sockopt_reuseport (sock);

#ifdef IPTOS_PREC_INTERNETCONTROL
  if (sa->sa_family == AF_INET)
    setsockopt_ipv4_tos (sock, IPTOS_PREC_INTERNETCONTROL);
#endif

#ifdef IPV6_V6ONLY
  /* Want only IPV6 on ipv6 socket (not mapped addresses) */
  if (sa->sa_family == AF_INET6) {
    int on = 1;
    setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY,
		(void *) &on, sizeof (on));
  }
#endif

  if (sisisd_privs.change (ZPRIVS_RAISE) )
    zlog_err ("sisis_socket: could not raise privs");

	// Bind
  ret = bind (sock, sa, salen);
  en = errno;
  if (sisisd_privs.change (ZPRIVS_LOWER) )
    zlog_err ("sisis_bind_address: could not lower privs");

  if (ret < 0)
	{
		zlog_err ("bind: %s", safe_strerror (en));
		return ret;
	}
	
	// Update listener infprmation
  listener = XMALLOC (MTYPE_SISIS_LISTENER, sizeof(*listener));
  listener->fd = sock;
  memcpy(&listener->su, sa, salen);
  listener->thread = thread_add_read (sisis_info->master, sisis_recvfrom, listener, sock);
  listnode_add (sisis_info->listen_sockets, listener);
	
  return 0;
}
Пример #20
0
/* Get just the flags for the given name.
 * Used by the normal 'if_get_flags' function, as well
 * as the bootup interface-list code, which has to peek at per-address
 * flags in order to figure out which ones should be ignored..
 */
int if_get_flags_direct(const char *ifname, uint64_t *flags, unsigned int af)
{
	struct lifreq lifreq;
	int ret;

	lifreq_set_name(&lifreq, ifname);

	ret = AF_IOCTL(af, SIOCGLIFFLAGS, (caddr_t)&lifreq);

	if (ret)
		zlog_debug("%s: ifname %s, error %s (%d)", __func__, ifname,
			   safe_strerror(errno), errno);

	*flags = lifreq.lifr_flags;

	return ret;
}
Пример #21
0
static void
puts_e7000debug (char *buf)
{
  if (!e7000_desc)
    error ("Use \"target e7000 ...\" first.");

  if (remote_debug)
    printf_unfiltered ("Sending %s\n", buf);

  if (serial_write (e7000_desc, buf, strlen (buf)))
    fprintf_unfiltered (gdb_stderr, "serial_write failed: %s\n", safe_strerror (errno));

  /* And expect to see it echoed, unless using the pc interface */
#if 0
  if (!using_pc)
#endif
    expect (buf);
}
Пример #22
0
void
shim_join_allspfrouters (int ifindex)
{
  struct ipv6_mreq mreq6;
  int retval;
  
  assert(ifindex);
  mreq6.ipv6mr_interface = ifindex;
  memcpy (&mreq6.ipv6mr_multiaddr, &allspfrouters6,
          sizeof (struct in6_addr));

  retval = setsockopt (shim->fd, IPPROTO_IPV6, IPV6_JOIN_GROUP,
                       &mreq6, sizeof (mreq6));

 if (retval < 0)
   zlog_err ("Network: Join AllSPFRouters on ifindex %d failed: %s",
             ifindex, safe_strerror (errno));
}
Пример #23
0
void
uninstall_route(struct babel_route *route)
{
    int rc;

    if(!route->installed)
        return;

    rc = kernel_route(ROUTE_FLUSH, route->src->prefix, route->src->plen,
                      route->nexthop,
                      route->neigh->ifp->ifindex,
                      metric_to_kernel(route_metric(route)), NULL, 0, 0);
    if(rc < 0)
        flog_err(EC_BABEL_ROUTE, "kernel_route(FLUSH): %s",
		  safe_strerror(errno));

    route->installed = 0;
}
Пример #24
0
/* After TCP connection is established.  Get local address and port. */
union sockunion *
sockunion_getsockname (int fd)
{
  int ret;
  socklen_t len;
  union
  {
    struct sockaddr sa;
    struct sockaddr_in sin;
#ifdef HAVE_IPV6
    struct sockaddr_in6 sin6;
#endif /* HAVE_IPV6 */
    char tmp_buffer[128];
  } name;
  union sockunion *su;

  memset (&name, 0, sizeof name);
  len = sizeof name;

  ret = getsockname (fd, (struct sockaddr *)&name, &len);
  if (ret < 0)
    {
      zlog_warn ("Can't get local address and port by getsockname: %s",
		 safe_strerror (errno));
      return NULL;
    }

  if (name.sa.sa_family == AF_INET)
    {
      su = XCALLOC (MTYPE_SOCKUNION, sizeof (union sockunion));
      memcpy (su, &name, sizeof (struct sockaddr_in));
      return su;
    }
#ifdef HAVE_IPV6
  if (name.sa.sa_family == AF_INET6)
    {
      su = XCALLOC (MTYPE_SOCKUNION, sizeof (union sockunion));
      memcpy (su, &name, sizeof (struct sockaddr_in6));
      sockunion_normalise_mapped (su);
      return su;
    }
#endif /* HAVE_IPV6 */
  return NULL;
}
Пример #25
0
int
shim_sock_init(void)
{
  int shim_sock;

  if ( svd_privs.change (ZPRIVS_RAISE) )
    zlog_err ("shim_sock_init: could not raise privs, %s",
               safe_strerror (errno) );
    
  shim_sock = socket (AF_INET6, SOCK_RAW, IPPROTO_OSPFIGP);
  if (shim_sock < 0)
    {
      int save_errno = errno;
      if ( svd_privs.change (ZPRIVS_LOWER) )
        zlog_err ("shim_sock_init: could not lower privs, %s",
                   safe_strerror (errno) );
      zlog_err ("shim_sock_init: socket: %s", safe_strerror (save_errno));
      exit(1);
    }
    
  if (svd_privs.change (ZPRIVS_LOWER))
    {
      zlog_err ("shim_sock_init: could not lower privs, %s",
               safe_strerror (errno) );
    }

  sockopt_reuseaddr (shim_sock);

  u_int off = 0;
  if (setsockopt (shim_sock, IPPROTO_IPV6, IPV6_MULTICAST_LOOP,
                  &off, sizeof (u_int)) < 0)
    zlog_warn ("Network: reset IPV6_MULTICAST_LOOP failed: %s",
               safe_strerror (errno));

  if (setsockopt_ipv6_pktinfo (shim_sock, 1) < 0)
     zlog_warn ("Can't set pktinfo option for fd %d", shim_sock);

  int offset = 12;
#ifndef DISABLE_IPV6_CHECKSUM
  if (setsockopt (shim_sock, IPPROTO_IPV6, IPV6_CHECKSUM,
                  &offset, sizeof (offset)) < 0)
    zlog_warn ("Network: set IPV6_CHECKSUM failed: %s", safe_strerror (errno));
#else
  zlog_warn ("Network: Don't set IPV6_CHECKSUM");
#endif /* DISABLE_IPV6_CHECKSUM */

  inet_pton (AF_INET6, ALLSPFROUTERS6, &allspfrouters6);
  inet_pton (AF_INET6, ALLDROUTERS6, &alldrouters6);

  return shim_sock;
}
Пример #26
0
/* Bind socket to specified address. */
int
sockunion_bind (int sock, union sockunion *su, unsigned short port, 
		union sockunion *su_addr)
{
  int size = 0;
  int ret;

  if (su->sa.sa_family == AF_INET)
    {
      size = sizeof (struct sockaddr_in);
      su->sin.sin_port = htons (port);
#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
      su->sin.sin_len = size;
#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */
      if (su_addr == NULL)
	su->sin.sin_addr.s_addr = htonl (INADDR_ANY);
    }
#ifdef HAVE_IPV6
  else if (su->sa.sa_family == AF_INET6)
    {
      size = sizeof (struct sockaddr_in6);
      su->sin6.sin6_port = htons (port);
#ifdef SIN6_LEN
      su->sin6.sin6_len = size;
#endif /* SIN6_LEN */
      if (su_addr == NULL)
	{
#if defined(LINUX_IPV6) || defined(NRL)
	  memset (&su->sin6.sin6_addr, 0, sizeof (struct in6_addr));
#else
	  su->sin6.sin6_addr = in6addr_any;
#endif /* LINUX_IPV6 */
	}
    }
#endif /* HAVE_IPV6 */
  

  ret = bind (sock, (struct sockaddr *)su, size);
  if (ret < 0)
    zlog (NULL, LOG_WARNING, "can't bind socket : %s", safe_strerror (errno));

  return ret;
}
/*
 * Set MD5 key for the socket, for the given IPv4 peer address.
 * If the password is NULL or zero-length, the option will be disabled.
 */
static int
bgp_md5_set_socket (int socket, union sockunion *su, const char *password)
{
  int ret = -1;
  int en = ENOSYS;
  
  assert (socket >= 0);
  
#if HAVE_DECL_TCP_MD5SIG  
  ret = sockopt_tcp_signature (socket, su, password);
  en  = errno;
#endif /* HAVE_TCP_MD5SIG */
  
  if (ret < 0)
    zlog (NULL, LOG_WARNING, "can't set TCP_MD5SIG option on socket %d: %s",
          socket, safe_strerror (en));

  return ret;
}
Пример #28
0
static struct btrace_target_info *
amd64_linux_enable_btrace (struct target_ops *self, ptid_t ptid)
{
  struct btrace_target_info *tinfo;
  struct gdbarch *gdbarch;

  errno = 0;
  tinfo = linux_enable_btrace (ptid);

  if (tinfo == NULL)
    error (_("Could not enable branch tracing for %s: %s."),
	   target_pid_to_str (ptid), safe_strerror (errno));

  /* Fill in the size of a pointer in bits.  */
  gdbarch = target_thread_architecture (ptid);
  tinfo->ptr_bits = gdbarch_ptr_bit (gdbarch);

  return tinfo;
}
Пример #29
0
void
ospf6_join_alldrouters (u_int ifindex)
{
  struct ipv6_mreq mreq6;

  assert (ifindex);
  mreq6.ipv6mr_interface = ifindex;
  memcpy (&mreq6.ipv6mr_multiaddr, &alldrouters6,
          sizeof (struct in6_addr));

  if (setsockopt (ospf6_sock, IPPROTO_IPV6, IPV6_JOIN_GROUP,
                  &mreq6, sizeof (mreq6)) < 0)
    zlog_warn ("Network: Join AllDRouters on ifindex %d Failed: %s",
               ifindex, safe_strerror (errno));
#if 0
  else
    zlog_debug ("Network: Join AllDRouters on ifindex %d", ifindex);
#endif
}
Пример #30
0
int
ospf_if_drop_allspfrouters (struct ospf *top, struct prefix *p,
			    unsigned int ifindex)
{
  int ret;

  ret = setsockopt_multicast_ipv4 (top->fd, IP_DROP_MEMBERSHIP,
                                   p->u.prefix4, htonl (OSPF_ALLSPFROUTERS),
                                   ifindex);
  if (ret < 0)
    zlog_warn ("can't setsockopt IP_DROP_MEMBERSHIP (fd %d, addr %s, "
	       "ifindex %u, AllSPFRouters): %s",
               top->fd, inet_ntoa(p->u.prefix4), ifindex, safe_strerror(errno));
  else
    zlog_info ("interface %s [%u] leave AllSPFRouters Multicast group.",
	       inet_ntoa (p->u.prefix4), ifindex);

  return ret;
}