• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ OLSR_PRINTF函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中OLSR_PRINTF函数的典型用法代码示例。如果您正苦于以下问题:C++ OLSR_PRINTF函数的具体用法?C++ OLSR_PRINTF怎么用?C++ OLSR_PRINTF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了OLSR_PRINTF函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: olsr_if_set_state

int olsr_if_set_state(const char *dev, bool up) {
  int oldflags;
  struct ifreq ifr;

  memset(&ifr, 0, sizeof(ifr));
  strscpy(ifr.ifr_name, dev, IFNAMSIZ);

  if (ioctl(olsr_cnf->ioctl_s, SIOCGIFFLAGS, &ifr) < 0) {
    OLSR_PRINTF(1, "ioctl SIOCGIFFLAGS (get flags) error on device %s: %s (%d)\n",
        dev, strerror(errno), errno);
    return 1;
  }

  oldflags = ifr.ifr_flags;
  if (up) {
    ifr.ifr_flags |= IFF_UP;
  }
  else {
    ifr.ifr_flags &= ~IFF_UP;
  }

  if (oldflags == ifr.ifr_flags) {
    /* interface is already up/down */
    return 0;
  }

  if (ioctl(olsr_cnf->ioctl_s, SIOCSIFFLAGS, &ifr) < 0) {
    OLSR_PRINTF(1, "ioctl SIOCSIFFLAGS (set flags %s) error on device %s: %s (%d)\n",
        up ? "up" : "down", dev, strerror(errno), errno);
    return 1;
  }
  return 0;
}
开发者ID:WachterJud,项目名称:qaul.net_legacy,代码行数:33,代码来源:net.c


示例2: is_if_link_up

bool
is_if_link_up(char *ifname)
{
  if (check_wireless_interface(ifname)) {
    /* No link checking on wireless devices */
    return true;
  } else {
    /* Mii wizardry */
    struct ifreq ifr;
    struct mii_data *mii = (struct mii_data *)&ifr.ifr_data;
    int bmsr;
    memset(&ifr, 0, sizeof(ifr));
    strscpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));

    if (ioctl(olsr_cnf->ioctl_s, SIOCGMIIPHY, &ifr) < 0) {
      if (errno != ENODEV)
        OLSR_PRINTF(1, "SIOCGMIIPHY on '%s' failed: %s\n", ifr.ifr_name, strerror(errno));
      return WEIGHT_ETHERNET_DEFAULT;
    }
    mii->reg_num = MII_BMSR;
    if (ioctl(olsr_cnf->ioctl_s, SIOCGMIIREG, &ifr) < 0) {
      OLSR_PRINTF(1, "SIOCGMIIREG on %s failed: %s\n", ifr.ifr_name, strerror(errno));
      return WEIGHT_ETHERNET_DEFAULT;
    }
    bmsr = mii->val_out;

    OLSR_PRINTF(1, "%s: ", ifr.ifr_name);
    OLSR_PRINTF(1, "%s\n", (bmsr & MII_BMSR_LINK_VALID) ? "link ok " : "no link ");

    return (bmsr & MII_BMSR_LINK_VALID);

  }
}
开发者ID:Dany3R9,项目名称:Proj,代码行数:33,代码来源:net.c


示例3: olsr_print_routing_table

/**
 * Print the routingtree to STDOUT
 *
 */
void
olsr_print_routing_table(struct avl_tree *tree)
{
#ifndef NODEBUG
  /* The whole function makes no sense without it. */
  struct avl_node *rt_tree_node;
  struct lqtextbuffer lqbuffer;

  OLSR_PRINTF(6, "ROUTING TABLE\n");

  for (rt_tree_node = avl_walk_first(tree); rt_tree_node != NULL; rt_tree_node = avl_walk_next(rt_tree_node)) {
    struct avl_node *rtp_tree_node;
    struct ipaddr_str prefixstr, origstr, gwstr;
    struct rt_entry *rt = rt_tree2rt(rt_tree_node);

    /* first the route entry */
    OLSR_PRINTF(6, "%s/%u, via %s, best-originator %s\n", olsr_ip_to_string(&prefixstr, &rt->rt_dst.prefix), rt->rt_dst.prefix_len,
                olsr_ip_to_string(&origstr, &rt->rt_nexthop.gateway), olsr_ip_to_string(&gwstr, &rt->rt_best->rtp_originator));

    /* walk the per-originator path tree of routes */
    for (rtp_tree_node = avl_walk_first(&rt->rt_path_tree); rtp_tree_node != NULL; rtp_tree_node = avl_walk_next(rtp_tree_node)) {
      struct rt_path *rtp = rtp_tree2rtp(rtp_tree_node);
      OLSR_PRINTF(6, "\tfrom %s, cost %s, metric %u, via %s, %s, v %u\n", olsr_ip_to_string(&origstr, &rtp->rtp_originator),
                  get_linkcost_text(rtp->rtp_metric.cost, true, &lqbuffer), rtp->rtp_metric.hops, olsr_ip_to_string(&gwstr,
                                                                                                                    &rtp->
                                                                                                                    rtp_nexthop.
                                                                                                                    gateway),
                  if_ifwithindex_name(rt->rt_nexthop.iif_index), rtp->rtp_version);
    }
  }
#endif /* NODEBUG */
  tree = NULL;                  /* squelch compiler warnings */
}
开发者ID:fatielmahdi,项目名称:olsr,代码行数:37,代码来源:routing_table.c


示例4: add_will_always_nodes

/**
 * Adds all nodes with willingness set to WILL_ALWAYS
 */
static uint16_t
add_will_always_nodes(void)
{
  struct neighbor_entry *a_neighbor;
  uint16_t count = 0;

#if 0
  printf("\nAdding WILL ALWAYS nodes....\n");
#endif

  OLSR_FOR_ALL_NBR_ENTRIES(a_neighbor) {
    struct ipaddr_str buf;
    if ((a_neighbor->status == NOT_SYM) || (a_neighbor->willingness != WILL_ALWAYS)) {
      continue;
    }
    olsr_chosen_mpr(a_neighbor, &count);

    OLSR_PRINTF(3, "Adding WILL_ALWAYS: %s\n", olsr_ip_to_string(&buf, &a_neighbor->neighbor_main_addr));

  }
  OLSR_FOR_ALL_NBR_ENTRIES_END(a_neighbor);

#if 0
  OLSR_PRINTF(1, "Count: %d\n", count);
#endif
  return count;
}
开发者ID:abdollatiif,项目名称:android-manet-olsrd,代码行数:30,代码来源:mpr.c


示例5: is_at_least_linuxkernel_2_6_31

static bool is_at_least_linuxkernel_2_6_31(void) {
  struct utsname uts;
  char *next;
  int first = 0, second = 0, third = 0;

  memset(&uts, 0, sizeof(uts));
  if (uname(&uts)) {
    OLSR_PRINTF(1, "Error, could not read kernel version: %s (%d)\n", strerror(errno), errno);
    return false;
  }

  first = strtol(uts.release, &next, 10);
  /* check for linux 3.x */
  if (first >= 3) {
    return true;
  }

  if (*next != '.') {
    goto kernel_parse_error;
  }

  second = strtol(next+1, &next, 10);
  if (*next != '.') {
    goto kernel_parse_error;
  }

  third = strtol(next+1, NULL, 10);

  /* better or equal than linux 2.6.31 ? */
  return first == 2 && second == 6 && third >= 31;

kernel_parse_error:
  OLSR_PRINTF(1, "Error, cannot parse kernel version: %s\n", uts.release);
  return false;
}
开发者ID:Dany3R9,项目名称:Proj,代码行数:35,代码来源:net.c


示例6: net_os_set_global_ifoptions

/**
 * Setup global interface options (icmp redirect, ip forwarding, rp_filter)
 * @return 1 on success 0 on failure
 */
void
net_os_set_global_ifoptions(void) {

  if (writeToProc(olsr_cnf->ip_version == AF_INET ? PROC_IPFORWARD_V4 : PROC_IPFORWARD_V6, &orig_fwd_state,
          olsr_cnf->set_ip_forward ? OLSRD_FORWARD_VALUE : 0 )) {
    OLSR_PRINTF(1, "Warning, could not enable IP forwarding!\n"
        "you should manually ensure that IP forwarding is enabled!\n\n");
    olsr_startup_sleep(3);
  }
  else if ((!olsr_cnf->set_ip_forward) && (orig_fwd_state != OLSRD_FORWARD_VALUE)) {
    olsr_exit("IP forwarding not activated, shutting down.\n", 1);
  }

  if (olsr_cnf->smart_gw_active) {
    char procfile[FILENAME_MAX];

    /* Generate the procfile name */
    if (olsr_cnf->ip_version == AF_INET || olsr_cnf->use_niit) {
      snprintf(procfile, sizeof(procfile), PROC_IF_SPOOF, TUNNEL_ENDPOINT_IF);
      if (writeToProc(procfile, &orig_tunnel_rp_filter, OLSRD_SPOOF_VALUE)) {
        OLSR_PRINTF(0, "WARNING! Could not disable the IP spoof filter for tunnel!\n"
            "you should manually ensure that IP spoof filtering is disabled!\n\n");

        olsr_startup_sleep(3);
      }
    }

#if 0 // should not be necessary for IPv6
    if (olsr_cnf->ip_version == AF_INET6) {
      snprintf(procfile, sizeof(procfile), PROC_IF_SPOOF, TUNNEL_ENDPOINT_IF6);
      if (writeToProc(procfile, &orig_tunnel6_rp_filter, OLSRD_SPOOF_VALUE)) {
        OLSR_PRINTF(0, "WARNING! Could not disable the IP spoof filter for tunnel6!\n"
            "you should manually ensure that IP spoof filtering is disabled!\n\n");

        olsr_startup_sleep(3);
      }
    }
#endif
  }

  if (olsr_cnf->ip_version == AF_INET) {
    if (writeToProc(PROC_ALL_REDIRECT, &orig_global_redirect_state, OLSRD_REDIRECT_VALUE)) {
      OLSR_PRINTF(1, "WARNING! Could not disable ICMP redirects!\n"
          "you should manually ensure that ICMP redirects are disabled!\n\n");

      olsr_startup_sleep(3);
    }

    /* check kernel version and disable global rp_filter */
    if (is_at_least_linuxkernel_2_6_31()) {
      if (writeToProc(PROC_ALL_SPOOF, &orig_global_rp_filter, OLSRD_SPOOF_VALUE)) {
        OLSR_PRINTF(1, "WARNING! Could not disable global rp_filter (necessary for kernel 2.6.31 and higher!\n"
            "you should manually ensure that rp_filter is disabled!\n\n");

        olsr_startup_sleep(3);
      }
    }
  }
  return;
}
开发者ID:Dany3R9,项目名称:Proj,代码行数:64,代码来源:net.c


示例7: net_os_set_ifoptions

/**
 *
 *@return 1 on sucess 0 on failiure
 */
int
net_os_set_ifoptions(const char *if_name, struct interface *iface)
{
  char procfile[FILENAME_MAX];
  if (olsr_cnf->ip_version == AF_INET6)
    return -1;

  /* Generate the procfile name */
  snprintf(procfile, sizeof(procfile), PROC_IF_REDIRECT, if_name);

  if (writeToProc(procfile, &iface->nic_state.redirect, OLSRD_REDIRECT_VALUE)) {
    OLSR_PRINTF(0, "WARNING! Could not disable ICMP redirects!\n"
        "you should manually ensure that ICMP redirects are disabled!\n\n");
    olsr_startup_sleep(3);
    return 0;
  }

  /* Generate the procfile name */
  snprintf(procfile, sizeof(procfile), PROC_IF_SPOOF, if_name);

  if (writeToProc(procfile, &iface->nic_state.spoof, OLSRD_SPOOF_VALUE)) {
    OLSR_PRINTF(0, "WARNING! Could not disable the IP spoof filter!\n"
        "you should manually ensure that IP spoof filtering is disabled!\n\n");

    olsr_startup_sleep(3);
    return 0;
  }
  return 1;
}
开发者ID:Dany3R9,项目名称:Proj,代码行数:33,代码来源:net.c


示例8: netmask_to_prefix

olsr_u8_t
netmask_to_prefix(const olsr_u8_t *adr, int len)
{
  struct ipaddr_str buf;
  const olsr_u8_t * const a_end = adr+len;
  olsr_u16_t prefix = 0;
  const olsr_u8_t *a;
  for (a = adr; a < a_end && *a == 0xff; a++) {
    prefix += 8;
  }
  if (a < a_end) {
    /* handle the last byte */
    switch (*a) {
    case   0: prefix += 0; break;
    case 128: prefix += 1; break;
    case 192: prefix += 2; break;
    case 224: prefix += 3; break;
    case 240: prefix += 4; break;
    case 248: prefix += 5; break;
    case 252: prefix += 6; break;
    case 254: prefix += 7; break;
    case 255: prefix += 8; break; /* Shouldn't happen */
    default:
      OLSR_PRINTF(0, "%s: Got bogus netmask %s\n", __func__, olsr_ip_to_string(&buf, (const union olsr_ip_addr *)adr));
      prefix = UCHAR_MAX;
      *(int *)0 = 0;
      break;
    }
  }
#ifdef DEBUG
  OLSR_PRINTF(3, "Netmask: %s = Prefix %d\n", olsr_ip_to_string(&buf, (const union olsr_ip_addr *)adr), prefix);
#endif
  return prefix;
}
开发者ID:TKr,项目名称:Wive-ng-rt8186,代码行数:34,代码来源:ipcalc.c


示例9: olsr_print_neighbor_table

/**
 *Prints the registered neighbors and two hop neighbors
 *to STDOUT.
 *
 *@return nada
 */
void
olsr_print_neighbor_table(void)
{
#ifdef NODEBUG
  /* The whole function doesn't do anything else. */
#ifndef NODEBUG
  const int iplen = olsr_cnf->ip_version == AF_INET ? 15 : 39;
#endif
  int idx;
  OLSR_PRINTF(1,
              "\n--- %02d:%02d:%02d.%02d ------------------------------------------------ NEIGHBORS\n\n"
              "%*s  LQ     NLQ    SYM   MPR   MPRS  will\n", nowtm->tm_hour, nowtm->tm_min, nowtm->tm_sec, (int)now.tv_usec / 10000,
              iplen, "IP address");

  for (idx = 0; idx < HASHSIZE; idx++) {
    struct neighbor_entry *neigh;
    for (neigh = neighbortable[idx].next; neigh != &neighbortable[idx]; neigh = neigh->next) {
      struct link_entry *lnk = get_best_link_to_neighbor(&neigh->neighbor_main_addr);
      if (lnk) {
        struct ipaddr_str buf;
        OLSR_PRINTF(1, "%-*s  %5.3f  %5.3f  %s  %s  %s  %d\n", iplen, olsr_ip_to_string(&buf, &neigh->neighbor_main_addr),
                    lnk->loss_link_quality, lnk->neigh_link_quality, neigh->status == SYM ? "YES " : "NO  ",
                    neigh->is_mpr ? "YES " : "NO  ", olsr_lookup_mprs_set(&neigh->neighbor_main_addr) == NULL ? "NO  " : "YES ",
                    neigh->willingness);
      }
    }
  }
#endif
}
开发者ID:Dany3R9,项目名称:Proj,代码行数:35,代码来源:neighbor_table.c


示例10: olsr_init_niit

void olsr_init_niit(void) {
  if (olsr_cnf->ip_version == AF_INET) {
    olsr_cnf->use_niit = false;
    return;
  }

  olsr_cnf->niit4to6_if_index = if_nametoindex(DEF_NIIT4TO6_IFNAME);
  if (olsr_cnf->niit4to6_if_index <= 0) {
    OLSR_PRINTF(1, "Warning, %s device is not available, deactivating NIIT\n", DEF_NIIT4TO6_IFNAME);
    olsr_cnf->use_niit = false;
    return;
  }
  olsr_cnf->niit6to4_if_index = if_nametoindex(DEF_NIIT6TO4_IFNAME);
  if (olsr_cnf->niit6to4_if_index <= 0) {
    OLSR_PRINTF(1, "Warning, %s device is not available, deactivating NIIT\n", DEF_NIIT6TO4_IFNAME);
    olsr_cnf->use_niit = false;
    return;
  }

  niit4to6_active = olsr_if_isup(DEF_NIIT4TO6_IFNAME);
  niit6to4_active = olsr_if_isup(DEF_NIIT6TO4_IFNAME);

  olsr_add_ifchange_handler(&handle_niit_ifchange);
  olsr_add_ifchange_handler(&handle_niit_ifchange);
  return;
}
开发者ID:Dany3R9,项目名称:Proj,代码行数:26,代码来源:olsr_niit.c


示例11: olsr_print_neighbor_table

void
olsr_print_neighbor_table(void)
{
  /* The whole function doesn't do anything else. */
  const int iplen = olsr_cnf->ip_version == AF_INET ? (INET_ADDRSTRLEN - 1) : (INET6_ADDRSTRLEN - 1);
  int idx;

  OLSR_PRINTF(1,
              "\n--- %s ------------------------------------------------ NEIGHBORS\n\n"
              "%*s\tHyst\tLQ\tETX\tSYM   MPR   MPRS  will\n", olsr_wallclock_string(),
              iplen, "IP address");

  for (idx = 0; idx < HASHSIZE; idx++) {
    struct neighbor_entry *neigh;
    for (neigh = neighbortable[idx].next; neigh != &neighbortable[idx]; neigh = neigh->next) {
      struct link_entry *lnk = get_best_link_to_neighbor(&neigh->neighbor_main_addr);
      if (lnk) {
        struct ipaddr_str buf;
        struct lqtextbuffer lqbuffer1, lqbuffer2;

        OLSR_PRINTF(1, "%-*s\t%5.3f\t%s\t%s\t%s  %s  %s  %d\n", iplen, olsr_ip_to_string(&buf, &neigh->neighbor_main_addr),
                    (double)lnk->L_link_quality,
                    get_link_entry_text(lnk, '/', &lqbuffer1),
                    get_linkcost_text(lnk->linkcost,false, &lqbuffer2),
                    neigh->status == SYM ? "YES " : "NO  ",
                    neigh->is_mpr ? "YES " : "NO  ",
                    olsr_lookup_mprs_set(&neigh->neighbor_main_addr) == NULL ? "NO  " : "YES ",
                    neigh->willingness);
      }
    }
  }
}
开发者ID:OLSR,项目名称:olsrd,代码行数:32,代码来源:neighbor_table.c


示例12: ipc_accept

void
ipc_accept(int fd)
{
  socklen_t addrlen;
  struct sockaddr_in pin;
  char *addr;  


  addrlen = sizeof (struct sockaddr_in);
  
  if ((ipc_conn = accept(fd, (struct sockaddr *)  &pin, &addrlen)) == -1)
    {
      perror("IPC accept");
      olsr_exit("IPC accept", EXIT_FAILURE);
    }
  else
    {
      OLSR_PRINTF(1, "Front end connected\n");
      addr = inet_ntoa(pin.sin_addr);
      if(ipc_check_allowed_ip((union olsr_ip_addr *)&pin.sin_addr.s_addr))
	{
	  ipc_active = OLSR_TRUE;
	  ipc_send_net_info(ipc_conn);
	  ipc_send_all_routes(ipc_conn);
	  OLSR_PRINTF(1, "Connection from %s\n",addr);
	}
      else
	{
	  OLSR_PRINTF(1, "Front end-connection from foregin host(%s) not allowed!\n", addr);
	  olsr_syslog(OLSR_LOG_ERR, "OLSR: Front end-connection from foregin host(%s) not allowed!\n", addr);
	  CLOSE(ipc_conn);
	}
    }

}
开发者ID:TKr,项目名称:Wive-ng-rt8186,代码行数:35,代码来源:ipc_frontend.c


示例13: delete_all_inet_gws

static int
delete_all_inet_gws(void)
{
  int s;
  char buf[BUFSIZ], *cp, *cplim;
  struct ifconf ifc;
  struct ifreq *ifr;

  OLSR_PRINTF(1, "Internet gateway detected...\nTrying to delete default gateways\n");

  /* Get a socket */
  if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
    olsr_syslog(OLSR_LOG_ERR, "socket: %m");
    return -1;
  }

  ifc.ifc_len = sizeof(buf);
  ifc.ifc_buf = buf;
  if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0) {
    olsr_syslog(OLSR_LOG_ERR, "ioctl (get interface configuration)");
    close(s);
    return -1;
  }

  ifr = ifc.ifc_req;
  cplim = buf + ifc.ifc_len;    /*skip over if's with big ifr_addr's */
  for (cp = buf; cp < cplim; cp += sizeof(ifr->ifr_name) + sizeof(ifr->ifr_addr)) {
    struct rtentry kernel_route;
    ifr = (struct ifreq *)cp;

    if (strcmp(ifr->ifr_ifrn.ifrn_name, "lo") == 0) {
      OLSR_PRINTF(1, "Skipping loopback...\n");
      continue;
    }

    OLSR_PRINTF(1, "Trying 0.0.0.0/0 %s...", ifr->ifr_ifrn.ifrn_name);

    memset(&kernel_route, 0, sizeof(struct rtentry));

    ((struct sockaddr_in *)&kernel_route.rt_dst)->sin_addr.s_addr = 0;
    ((struct sockaddr_in *)&kernel_route.rt_dst)->sin_family = AF_INET;
    ((struct sockaddr_in *)&kernel_route.rt_genmask)->sin_addr.s_addr = 0;
    ((struct sockaddr_in *)&kernel_route.rt_genmask)->sin_family = AF_INET;

    ((struct sockaddr_in *)&kernel_route.rt_gateway)->sin_addr.s_addr = INADDR_ANY;
    ((struct sockaddr_in *)&kernel_route.rt_gateway)->sin_family = AF_INET;

    kernel_route.rt_flags = RTF_UP | RTF_GATEWAY;

    kernel_route.rt_dev = ifr->ifr_ifrn.ifrn_name;

    if ((ioctl(s, SIOCDELRT, &kernel_route)) < 0)
      OLSR_PRINTF(1, "NO\n");
    else
      OLSR_PRINTF(1, "YES\n");
  }
  close(s);
  return 0;
}
开发者ID:WachterJud,项目名称:qaul.net_legacy,代码行数:59,代码来源:kernel_routes_ioctl.c


示例14: olsr_process_hysteresis

int
olsr_process_hysteresis(struct link_entry *entry)
{
  //printf("PROCESSING QUALITY: %f\n", entry->L_link_quality);
  if (entry->L_link_quality > hhigh) {
    if (entry->L_link_pending == 1) {
      struct ipaddr_str buf;
      OLSR_PRINTF(1, "HYST[%s] link set to NOT pending!\n", olsr_ip_to_string(&buf, &entry->neighbor_iface_addr));
      changes_neighborhood = true;
    }

    /* Pending = false */
    entry->L_link_pending = 0;

    if (!TIMED_OUT(entry->L_LOST_LINK_time))
      changes_neighborhood = true;

    /* time = now -1 */
    entry->L_LOST_LINK_time = now_times - 1;

    return 1;
  }

  if (entry->L_link_quality < hlow) {
    if (entry->L_link_pending == 0) {
      struct ipaddr_str buf;
      OLSR_PRINTF(1, "HYST[%s] link set to pending!\n", olsr_ip_to_string(&buf, &entry->neighbor_iface_addr));
      changes_neighborhood = true;
    }

    /* Pending = true */
    entry->L_link_pending = 1;

    if (TIMED_OUT(entry->L_LOST_LINK_time))
      changes_neighborhood = true;

    /* Timer = min (L_time, current time + NEIGHB_HOLD_TIME) */
    entry->L_LOST_LINK_time = MIN(GET_TIMESTAMP(NEIGHB_HOLD_TIME * MSEC_PER_SEC), entry->link_timer->timer_clock);

    /* (the link is then considered as lost according to section
       8.5 and this may produce a neighbor loss).
       WTF?
     */
    return -1;
  }

  /*
   *If we get here then:
   *(HYST_THRESHOLD_LOW <= entry->L_link_quality <= HYST_THRESHOLD_HIGH)
   */

  /* L_link_pending and L_LOST_LINK_time remain unchanged. */
  return 0;

}
开发者ID:WachterJud,项目名称:qaul.net_legacy,代码行数:55,代码来源:hysteresis.c


示例15: ipc_init

/**
 *Create the socket to use for IPC to the
 *GUI front-end
 *
 *@return the socket FD
 */
int
ipc_init(void)
{
  //int flags;
  struct   sockaddr_in sin;
  int yes = 1;

  /* Add parser function */
  olsr_parser_add_function(&frontend_msgparser, PROMISCUOUS, 0);

  /* get an internet domain socket */
  if ((ipc_sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) 
    {
      perror("IPC socket");
      olsr_exit("IPC socket", EXIT_FAILURE);
    }

  if(setsockopt(ipc_sock, SOL_SOCKET, SO_REUSEADDR, (char *)&yes, sizeof(yes)) < 0) 
    {
      perror("SO_REUSEADDR failed");
      return 0;
    }

  /* complete the socket structure */
  memset(&sin, 0, sizeof(sin));
  sin.sin_family = AF_INET;
  sin.sin_addr.s_addr = INADDR_ANY;
  sin.sin_port = htons(IPC_PORT);

  /* bind the socket to the port number */
  if(bind(ipc_sock, (struct sockaddr *) &sin, sizeof(sin)) == -1) 
    {
      perror("IPC bind");
      OLSR_PRINTF(1, "Will retry in 10 seconds...\n");
      sleep(10);
      if(bind(ipc_sock, (struct sockaddr *) &sin, sizeof(sin)) == -1) 
	{
	  perror("IPC bind");
	  olsr_exit("IPC bind", EXIT_FAILURE);
	}
      OLSR_PRINTF(1, "OK\n");
    }

  /* show that we are willing to listen */
  if(listen(ipc_sock, olsr_cnf->ipc_connections) == -1) 
    {
      perror("IPC listen");
      olsr_exit("IPC listen", EXIT_FAILURE);
    }

  /* Register the socket with the socket parser */
  add_olsr_socket(ipc_sock, &ipc_accept);

  return ipc_sock;
}
开发者ID:TKr,项目名称:Wive-ng-rt8186,代码行数:61,代码来源:ipc_frontend.c


示例16: olsr_print_mprs_set

/**
 *Print the current MPR selector set to STDOUT
 */
void
olsr_print_mprs_set(void)
{
  struct mpr_selector *mprs;
  OLSR_PRINTF(1, "MPR SELECTORS: ");
  for (mprs = mprs_list.next; mprs != &mprs_list; mprs = mprs->next) {
    struct ipaddr_str buf;
    OLSR_PRINTF(1, "%s ", olsr_ip_to_string(&buf, &mprs->MS_main_addr));
  }
  OLSR_PRINTF(1, "\n");
}
开发者ID:fatielmahdi,项目名称:olsr,代码行数:14,代码来源:mpr_selector_set.c


示例17: set_nameservice_float

static int set_nameservice_float(const char *value, void *data, set_plugin_parameter_addon addon __attribute__((unused)))
{
	if (data != NULL)
	{
		sscanf(value, "%f", (float*)data);
		OLSR_PRINTF(1, "%s float %f\n", "Got", *(float*)data);
	}
	else
	{
		OLSR_PRINTF(0, "%s float %s\n", "Ignored", value);
	}
	return 0;
}
开发者ID:TKr,项目名称:Wive-ng-rt8186,代码行数:13,代码来源:nameservice.c


示例18: net_os_set_global_ifoptions

/**
 * Setup global interface options (icmp redirect, ip forwarding, rp_filter)
 * @return 1 on success 0 on failure
 */
void
net_os_set_global_ifoptions(void) {
  if (writeToProc(olsr_cnf->ip_version == AF_INET ? PROC_IPFORWARD_V4 : PROC_IPFORWARD_V6, &orig_fwd_state, '1')) {
    OLSR_PRINTF(1, "Warning, could not enable IP forwarding!\n"
        "you should manually ensure that IP forwarding is enabled!\n\n");
    olsr_startup_sleep(3);
  }

  if (olsr_cnf->smart_gw_active) {
    char procfile[FILENAME_MAX];

    /* Generate the procfile name */
    snprintf(procfile, sizeof(procfile), PROC_IF_SPOOF, TUNNEL_ENDPOINT_IF);
    if (writeToProc(procfile, &orig_tunnel_rp_filter, '0')) {
      OLSR_PRINTF(0, "WARNING! Could not disable the IP spoof filter for tunnel!\n"
          "you should mannually ensure that IP spoof filtering is disabled!\n\n");

      olsr_startup_sleep(3);
    }

    if (olsr_cnf->ip_version == AF_INET6) {
      snprintf(procfile, sizeof(procfile), PROC_IF_SPOOF, TUNNEL_ENDPOINT_IF6);
      if (writeToProc(procfile, &orig_tunnel6_rp_filter, '0')) {
        OLSR_PRINTF(0, "WARNING! Could not disable the IP spoof filter for tunnel6!\n"
            "you should mannually ensure that IP spoof filtering is disabled!\n\n");

        olsr_startup_sleep(3);
      }
    }
  }

  if (olsr_cnf->ip_version == AF_INET) {
    if (writeToProc(PROC_ALL_REDIRECT, &orig_global_redirect_state, '0')) {
      OLSR_PRINTF(1, "WARNING! Could not disable ICMP redirects!\n"
          "you should manually ensure that ICMP redirects are disabled!\n\n");

      olsr_startup_sleep(3);
    }

    /* check kernel version and disable global rp_filter */
    if (is_at_least_linuxkernel_2_6_31()) {
      if (writeToProc(PROC_ALL_SPOOF, &orig_global_rp_filter, '0')) {
        OLSR_PRINTF(1, "WARNING! Could not disable global rp_filter (necessary for kernel 2.6.31 and higher!\n"
            "you should manually ensure that rp_filter is disabled!\n\n");

        olsr_startup_sleep(3);
      }
    }
  }
  return;
}
开发者ID:wlanslovenija,项目名称:MeshApp,代码行数:55,代码来源:net.c


示例19: net_os_restore_ifoptions

/**
 *Resets the spoof filter and ICMP redirect settings
 */
int
net_os_restore_ifoptions(void)
{
  struct interface *ifs;
  char procfile[FILENAME_MAX];

  OLSR_PRINTF(1, "Restoring network state\n");

  /* Restore IP forwarding to "off" */
  if (writeToProc(olsr_cnf->ip_version == AF_INET ? PROC_IPFORWARD_V4 : PROC_IPFORWARD_V6, NULL, orig_fwd_state)) {
    OLSR_PRINTF(1, "Error, could not restore ip_forward settings\n");
  }

  if (olsr_cnf->smart_gw_active) {
    /* Generate the procfile name */
    snprintf(procfile, sizeof(procfile), PROC_IF_SPOOF, TUNNEL_ENDPOINT_IF);
    if (writeToProc(procfile, NULL, orig_tunnel_rp_filter)) {
      OLSR_PRINTF(0, "WARNING! Could not restore the IP spoof filter for tunnel!\n");
    }

    if (olsr_cnf->ip_version == AF_INET6) {
      snprintf(procfile, sizeof(procfile), PROC_IF_SPOOF, TUNNEL_ENDPOINT_IF6);
      if (writeToProc(procfile, NULL, orig_tunnel6_rp_filter)) {
        OLSR_PRINTF(0, "WARNING! Could not restore the IP spoof filter for tunnel6!\n");
      }
    }
  }

  if (olsr_cnf->ip_version == AF_INET) {
    /* Restore global ICMP redirect setting */
    if (writeToProc(PROC_ALL_REDIRECT, NULL, orig_global_redirect_state)) {
      OLSR_PRINTF(1, "Error, could not restore global icmp_redirect setting\n");
    }

    /* Restore global rp_filter setting for linux 2.6.31+ */
    if (is_at_least_linuxkernel_2_6_31()) {
      if (writeToProc(PROC_ALL_SPOOF, NULL, orig_global_rp_filter)) {
        OLSR_PRINTF(1, "Error, could not restore global rp_filter setting\n");
      }
    }
    for (ifs = ifnet; ifs != NULL; ifs = ifs->int_next) {
      /* Discard host-emulation interfaces */
      if (ifs->is_hcif)
        continue;

      /* ICMP redirects */
      snprintf(procfile, sizeof(procfile), PROC_IF_REDIRECT, ifs->int_name);
      if (writeToProc(procfile, NULL, ifs->nic_state.redirect)) {
        OLSR_PRINTF(1, "Error, could not restore icmp_redirect for interface %s\n", ifs->int_name);
      }

      /* Spoof filter */
      sprintf(procfile, PROC_IF_SPOOF, ifs->int_name);
      if (writeToProc(procfile, NULL, ifs->nic_state.spoof)) {
        OLSR_PRINTF(1, "Error, could not restore rp_filter for interface %s\n", ifs->int_name);
      }
    }
  }
  return 1;
}
开发者ID:wlanslovenija,项目名称:MeshApp,代码行数:63,代码来源:net.c


示例20: activate_lq_handler

/**
 * Activate a LQ handler
 * @param name
 */
static void
activate_lq_handler(const char *name)
{
  struct lq_handler_node *node;

  node = (struct lq_handler_node *)avl_find(&lq_handler_tree, name);
  if (node == NULL) {
    OLSR_PRINTF(1, "Error, unknown lq_handler '%s'\n", name);
    olsr_exit("", 1);
  }

  OLSR_PRINTF(1, "Using '%s' algorithm for lq calculation.\n", name);
  active_lq_handler = node->handler;
  active_lq_handler->initialize();
}
开发者ID:sickrandir,项目名称:olsrd-hybrid-plc,代码行数:19,代码来源:lq_plugin.c



注:本文中的OLSR_PRINTF函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ OMAP2_L4_IO_ADDRESS函数代码示例发布时间:2022-05-30
下一篇:
C++ OLESTR函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap