void client_handle(struct client *p) { printf("[%d] said: \"%s\"\n", p->s, p->input); /* Reset the input buffer */ p->in_filled = 0; p->input[0] = '\0'; p->in_ready = 0; send_client(p, "Testing"); send_client(p, "partial line output"); send_client(p, "\n"); }
int zebra_dispatch_rnh_table (vrf_id_t vrfid, int family, struct zserv *client) { struct route_table *ntable; struct route_node *nrn; struct rnh *rnh; ntable = lookup_rnh_table(vrfid, family); if (!ntable) { zlog_debug("dispatch_rnh_table: rnh table not found\n"); return -1; } for (nrn = route_top (ntable); nrn; nrn = route_next (nrn)) { if (!nrn->info) continue; rnh = nrn->info; if (IS_ZEBRA_DEBUG_NHT) { char bufn[INET6_ADDRSTRLEN]; prefix2str(&nrn->p, bufn, INET6_ADDRSTRLEN); zlog_debug("rnh %s - sending nexthop %s event to client %s", bufn, rnh->state ? "reachable" : "unreachable", zebra_route_string(client->proto)); } send_client(rnh, client, vrfid); } return 1; }
static void loop(struct conn_element_st *ce){ /* * The only job of this function is to read from the ce->cq, and * write to the ce->fd client file descriptor. The *data returned * points to a reusable internal storage in the ce->cq, and * should not be free()'d explicitly. It is released when the * main thread deletes the client from the table. */ int status; int dberror; void *data = NULL; uint32_t data_size; int timeout_ms = conn_element_get_queue_read_timeout_ms(ce); /* * The nbs1 and nbs2 threads receive the packetinfo->packet while * the emwin threads receive a "struct emwin_queue_info_st". */ status = connqueue_rcv(ce->cq, &data, &data_size, timeout_ms, &dberror); if(status == -1) log_err2_db("Error reading from queue for %s.", conn_element_get_nameorip(ce), dberror); else if(status == 1) log_errx("No data in queue for %s.", conn_element_get_nameorip(ce)); if(status != 0) return; status = send_client(ce, data, data_size); if(status != 0){ conn_stats_update_errors(&ce->cs); conn_element_set_exit_flag(ce); } }
void *request_handler(void *ptr) { #ifdef DEBUG printf("enter request_handler\n"); #endif int client_fd = ((Thread_Input*)ptr)->client_fd; Request request; Response response; parse_request_header(client_fd, &request); modify_request_header(&request); if (check_cache(&request, &response)) { send_client(client_fd, &response); } else { if (forward_request(client_fd, &request, &response) < 0) { Close(client_fd); return NULL; } else { if (response.content_size <= MAX_OBJECT_SIZE) save_to_cache(&request, &response); } } free(ptr); Close(client_fd); #ifdef DEBUG printf("connection close\n\n"); printf("leave request_handler\n"); #endif return NULL; }
int udp_main(int argc, char *argv[]) #endif { struct in_addr addr; /* Set up our host address */ addr.s_addr = HTONL(CONFIG_EXAMPLES_UDP_IPADDR); netlib_sethostaddr("eth0", &addr); /* Set up the default router address */ addr.s_addr = HTONL(CONFIG_EXAMPLES_UDP_DRIPADDR); netlib_setdraddr("eth0", &addr); /* Setup the subnet mask */ addr.s_addr = HTONL(CONFIG_EXAMPLES_UDP_NETMASK); netlib_setnetmask("eth0", &addr); #ifdef CONFIG_EXAMPLES_UDP_SERVER recv_server(); #else send_client(); #endif return 0; }
void send_client_status(unsigned char event, int status, struct chain_socket *cs) { union iod_value value; value.status = status; send_client(event, value, cs); }
void boardcast(int clients[], int maxi, const char *msg) { int i; for(i=0; i<=maxi; i++) { if(clients[i] >= 0) { send_client(clients[i], msg); } } }
void send_client_cord(unsigned char event, short int y, short int x, struct chain_socket *cs) { union iod_value value; value.cord.y = y; value.cord.x = x; send_client(event, value, cs); }
/** * test_server_loop() 関数テスト * * @return なし */ void test_server_loop(void) { pid_t cpid = 0; /* 子プロセスID */ pid_t w = 0; /* wait戻り値 */ int status = 0; /* wait引数 */ int retval = 0; /* 戻り値 */ int count = 1; /* ループカウント */ if (set_port_string(port) < 0) cut_error("set_port_string"); ssock = server_sock(); cpid = fork(); if (cpid < 0) { cut_error("fork(%d)", errno); return; } if (cpid == 0) { dbglog("child"); count = 2; g_sig_handled = 1; while (count--) server_loop(ssock); exit(EXIT_SUCCESS); } else { dbglog("parent: cpid=%d", (int)cpid); csock = inet_sock_client(); if (csock < 0) return; /* 送信 */ retval = send_client(csock, expr, sizeof(expr)); if (retval < 0) { cut_error("send_client: csock=%d(%d)", csock, errno); return; } /* 受信 */ retval = recv_client(csock, readbuf); if (retval < 0) { cut_error("recv_client: csock=%d(%d)", csock, errno); return; } cut_assert_equal_string((char *)expected, (char *)readbuf); w = wait(&status); if (w < 0) cut_notify("wait(%d)", errno); dbglog("w=%d", (int)w); } }
int udp_main(int argc, char *argv[]) #endif { #ifdef CONFIG_EXAMPLES_UDP_IPv6 #ifdef CONFIG_NET_ICMPv6_AUTOCONF /* Perform ICMPv6 auto-configuration */ netlib_icmpv6_autoconfiguration("eth0"); #else /* CONFIG_NET_ICMPv6_AUTOCONF */ /* Set up our fixed host address */ netlib_set_ipv6addr("eth0", (FAR const struct in6_addr *)g_ipv6_hostaddr); /* Set up the default router address */ netlib_set_dripv6addr("eth0", (FAR const struct in6_addr *)g_ipv6_draddr); /* Setup the subnet mask */ netlib_set_ipv6netmask("eth0", (FAR const struct in6_addr *)g_ipv6_netmask); #endif /* CONFIG_NET_ICMPv6_AUTOCONF */ #else /* CONFIG_EXAMPLES_UDP_IPv6 */ struct in_addr addr; /* Set up our host address */ addr.s_addr = HTONL(CONFIG_EXAMPLES_UDP_IPADDR); netlib_set_ipv4addr("eth0", &addr); /* Set up the default router address */ addr.s_addr = HTONL(CONFIG_EXAMPLES_UDP_DRIPADDR); netlib_set_dripv4addr("eth0", &addr); /* Setup the subnet mask */ addr.s_addr = HTONL(CONFIG_EXAMPLES_UDP_NETMASK); netlib_set_ipv4netmask("eth0", &addr); #endif /* CONFIG_EXAMPLES_UDP_IPv6 */ #ifdef CONFIG_EXAMPLES_UDP_SERVER recv_server(); #else send_client(); #endif return 0; }
int main(int argc, char **argv, char **envp) { #ifdef CONFIG_EXAMPLE_UDP_SERVER send_client(); #else recv_server(); #endif return 0; }
void cmd_tell(int clients[], int maxi, int user, const char *name, const char *msg) { if(strcmp(names[user], "anonymous") == 0) { #ifdef FLAVOR send_client(clients[user], "\033[1;31mERROR:\033[m\033[31m You are anonymous.\033[m"); #else send_client(clients[user], "ERROR: You are anonymous."); #endif return; } if(strcmp(name, "anonymous") == 0) { #ifdef FLAVOR send_client(clients[user], "\033[1;31mERROR:\033[m\033[31m The client to which you sent is anonymous.\033[m"); #else send_client(clients[user], "ERROR: The client to which you sent is anonymous."); #endif return; } int i; for(i=0; i<=maxi; i++) { if(clients[i] >= 0 && strcmp(names[i], name) == 0) { char buf[CMD_MAX]; #ifdef FLAVOR sprintf(buf, "\033[1;33m%s\033[m\033[33m tell you\033[m %s", names[user], msg); #else sprintf(buf, "%s tell you %s", names[user], msg); #endif send_client(clients[i], buf); #ifdef FLAVOR send_client(clients[user], "\033[1;32mSUCCESS:\033[m\033[32m Your message has been sent.\033[m"); #else send_client(clients[user], "SUCCESS: Your message has been sent."); #endif return; } } #ifdef FLAVOR send_client(clients[user], "\033[1;31mERROR:\033[m\033[31m The receiver doesn't exist.\033[m"); #else send_client(clients[user], "ERROR: The receiver doesn't exist."); #endif }
void user_init(int clients[], int id, const struct sockaddr_in *cli_addr) { char welcome_msg[CMD_MAX]; strcpy(names[id], "anonymous"); inet_ntop(AF_INET, &cli_addr->sin_addr, ips[id], sizeof(ips[id])); ports[id] = ntohs(cli_addr->sin_port); #ifdef FLAVOR sprintf(welcome_msg, "\033[1;33mHello, anonymous! \033[m\033[33mFrom: %s/%hu\033[m", ips[id], ports[id]); #else sprintf(welcome_msg, "Hello, anonymous! From: %s/%hu", ips[id], ports[id]); #endif send_client(clients[id], welcome_msg); }
int nettest_main(int argc, char *argv[]) #endif { #ifdef CONFIG_EXAMPLES_NETTEST_LOOPBACK pid_t child; #ifdef CONFIG_SCHED_WAITPID int statloc; #endif #endif #ifdef CONFIG_EXAMPLES_NETTEST_INIT /* Initialize the network */ netest_initialize(); #endif #if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) /* Then perform the server side of the test on a child task */ child = task_create("Nettest Child", CONFIG_EXAMPLES_NETTEST_PRIORITY, CONFIG_EXAMPLES_NETTEST_STACKSIZE, server_child, NULL); if (child < 0) { fprintf(stderr, "ERROR: Failed to server daemon\n"); return EXIT_FAILURE; } usleep(500*1000); #elif defined(CONFIG_EXAMPLES_NETTEST_SERVER) /* Then perform the server side of the test on this thread */ recv_server(); #endif #if !defined(CONFIG_EXAMPLES_NETTEST_SERVER) || \ defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) /* Then perform the client side of the test on this thread */ send_client(); #endif #if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && defined(CONFIG_SCHED_WAITPID) printf("main: Waiting for the server to exit\n"); (void)waitpid(child, &statloc, 0); #endif return EXIT_SUCCESS; }
char * message_view(View *v, IxpMsg *m) { Area *a; char *s; int i; s = getword(m); switch(getsym(s)) { case LSEND: return send_client(v, m, 0); case LSWAP: return send_client(v, m, 1); case LSELECT: return select_area(v->sel, m); case LCOLMODE: s = getword(m); if((a = strarea(v, s)) == nil || a->floating) return Ebadvalue; s = getword(m); if((i = str2colmode(s)) == -1) return Ebadvalue; a->mode = i; arrange_column(a, True); restack_view(v); if(v == screen->sel) focus_view(screen, v); draw_frames(); return nil; default: return Ebadcmd; } /* not reached */ }
void zebra_add_rnh_client (struct rnh *rnh, struct zserv *client, vrf_id_t vrf_id) { if (IS_ZEBRA_DEBUG_NHT) { char buf[INET6_ADDRSTRLEN]; zlog_debug("client %s registers rnh %s", zebra_route_string(client->proto), rnh_str(rnh, buf, INET6_ADDRSTRLEN)); } if (!listnode_lookup(rnh->client_list, client)) { listnode_add(rnh->client_list, client); send_client(rnh, client, vrf_id); } }
void cmd_name(int clients[], int maxi, int user, const char *name) { if(strcmp(name, "anonymous") == 0) { #ifdef FLAVOR send_client(clients[user], "\033[1;31mERROR:\033[m\033[31m Username cannot be anonymous.\033[m"); #else send_client(clients[user], "ERROR: Username cannot be anonymous."); #endif return; } int len = strlen(name); if(len < 2 || len > 12 || strspn(name, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz") != len) { #ifdef FLAVOR send_client(clients[user], "\033[1;31mERROR:\033[m\033[31m Username can only consists of 2~12 English letters.\033[m"); #else send_client(clients[user], "ERROR: Username can only consists of 2~12 English letters."); #endif return; } int i; for(i=0; i<=maxi; i++) { if(clients[i] >= 0 && i != user && strcmp(name, names[i]) == 0) { char msg[CMD_MAX]; #ifdef FLAVOR sprintf(msg, "\033[1;31mERROR:\033[m\033[31m %s has been used by others.\033[m", name); #else sprintf(msg, "ERROR: %s has been used by others.", name); #endif send_client(clients[user], msg); return; } } char msg[CMD_MAX]; int u_fd = clients[user]; clients[user] = -1; #ifdef FLAVOR sprintf(msg, "\033[1;33m%s\033[m\033[33m is now known as \033[1m%s.\033[m", names[user], name); #else sprintf(msg, "%s is now known as %s.", names[user], name); #endif strcpy(names[user], name); boardcast(clients, maxi, msg); clients[user] = u_fd; #ifdef FLAVOR sprintf(msg, "\033[32mYou're now known as \033[1m%s.\033[m", name); #else sprintf(msg, "You're now known as %s.", name); #endif send_client(u_fd, msg); }
int nettest_main(int argc, char *argv[]) #endif { struct in_addr addr; #ifdef CONFIG_EXAMPLES_NETTEST_NOMAC uint8_t mac[IFHWADDRLEN]; #endif /* Many embedded network interfaces must have a software assigned MAC */ #ifdef CONFIG_EXAMPLES_NETTEST_NOMAC mac[0] = 0x00; mac[1] = 0xe0; mac[2] = 0xde; mac[3] = 0xad; mac[4] = 0xbe; mac[5] = 0xef; netlib_setmacaddr("eth0", mac); #endif /* Set up our host address */ addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_IPADDR); netlib_sethostaddr("eth0", &addr); /* Set up the default router address */ addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_DRIPADDR); netlib_setdraddr("eth0", &addr); /* Setup the subnet mask */ addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_NETMASK); netlib_setnetmask("eth0", &addr); #ifdef CONFIG_EXAMPLES_NETTEST_SERVER recv_server(); #else send_client(); #endif return 0; }
void cmd_who(int clients[], int maxi, int user) { int i; for(i=0; i<=maxi; i++) { if(clients[i] < 0) continue; char msg[CMD_MAX]; #ifdef FLAVOR sprintf(msg, "\033[1;33m%s\033[m\033[33m %s/%hu\033[m", names[i], ips[i], ports[i]); #else sprintf(msg, "%s %s/%hu", names[i], ips[i], ports[i]); #endif if(i == user) { #ifdef FLAVOR strcat(msg, " \033[1;33m->me\033[m"); #else strcat(msg, " ->me"); #endif } send_client(clients[user], msg); } }
/* * request_handler - general function to handler each client request */ void *request_handler(int client_fd) { #ifdef DEBUG printf("enter request_handler\n"); #endif Request request; Response response; parse_request_header(client_fd, &request); modify_request_header(&request); if (check_cache(&request, &response)) { #ifdef DEBUG printf("in cache ! \n"); #endif send_client(client_fd, &response); } else { #ifdef DEBUG printf("not in cache !\n"); #endif if (forward_request(client_fd, &request, &response) < 0) { close(client_fd); return NULL; } else { /* save to cache if status code 2XX and < max size */ if (response.content_size <= MAX_OBJECT_SIZE && response.header[state_ofs] == '2') save_to_cache(&request, &response); } } close(client_fd); #ifdef DEBUG printf("connection close\n"); printf("leave request_handler\n"); #endif return NULL; }
int zebra_evaluate_rnh_table (vrf_id_t vrfid, int family) { struct route_table *ptable; struct route_table *ntable; struct route_node *prn; struct route_node *nrn; struct rnh *rnh; struct zserv *client; struct listnode *node; struct rib *rib; ntable = lookup_rnh_table(vrfid, family); if (!ntable) { zlog_debug("evaluate_rnh_table: rnh table not found\n"); return -1; } ptable = zebra_vrf_table(family2afi(family), SAFI_UNICAST, vrfid); if (!ptable) { zlog_debug("evaluate_rnh_table: prefix table not found\n"); return -1; } for (nrn = route_top (ntable); nrn; nrn = route_next (nrn)) { if (!nrn->info) continue; rnh = nrn->info; prn = route_node_match(ptable, &nrn->p); if (!prn) rib = NULL; else { RNODE_FOREACH_RIB(prn, rib) { if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED)) continue; if (! CHECK_FLAG (rib->status, RIB_ENTRY_SELECTED_FIB)) continue; if (CHECK_FLAG(rnh->flags, ZEBRA_NHT_CONNECTED)) { if (rib->type == ZEBRA_ROUTE_CONNECT) break; if (rib->type == ZEBRA_ROUTE_NHRP) { struct nexthop *nexthop; for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) if (nexthop->type == NEXTHOP_TYPE_IFINDEX || nexthop->type == NEXTHOP_TYPE_IFNAME) break; if (nexthop) break; } } else break; } } if (compare_state(rib, rnh->state)) { if (IS_ZEBRA_DEBUG_NHT) { char bufn[INET6_ADDRSTRLEN]; char bufp[INET6_ADDRSTRLEN]; prefix2str(&nrn->p, bufn, INET6_ADDRSTRLEN); if (prn) prefix2str(&prn->p, bufp, INET6_ADDRSTRLEN); else strcpy(bufp, "null"); zlog_debug("rnh %s resolved through route %s - sending " "nexthop %s event to clients", bufn, bufp, rib ? "reachable" : "unreachable"); } copy_state(rnh, rib); for (ALL_LIST_ELEMENTS_RO(rnh->client_list, node, client)) send_client(rnh, client, vrfid); } } return 1; }
/** * test_server_proc() 関数テスト * * @return なし */ void test_server_proc(void) { pid_t cpid = 0; /* 子プロセスID */ pid_t w = 0; /* wait戻り値 */ int status = 0; /* wait引数 */ int retval = 0; /* 戻り値 */ thread_data *dt = NULL; /* ソケット情報構造体 */ void *servret = NULL; /* テスト関数戻り値 */ if (set_port_string(port) < 0) cut_error("set_port_string"); ssock = server_sock(); cpid = fork(); if (cpid < 0) { cut_error("fork(%d)", errno); return; } if (cpid == 0) { dbglog("child"); dt = (thread_data *)malloc(sizeof(thread_data)); if (!dt) { outlog("malloc: size=%zu", sizeof(thread_data)); exit(EXIT_FAILURE); } (void)memset(dt, 0, sizeof(thread_data)); dt->len = (socklen_t)sizeof(dt->addr); dt->sock = accept(ssock, (struct sockaddr *)&dt->addr, &dt->len); if (dt->sock < 0) { outlog("accept: ssock=%d", ssock); memfree((void **)&dt, NULL); exit(EXIT_FAILURE); } g_sig_handled = 1; /* テスト関数実行 */ servret = server.server_proc(dt); if (servret) { outlog("server_proc"); exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); } else { dbglog("parent: cpid=%d", (int)cpid); csock = inet_sock_client(); if (csock < 0) return; /* 送信 */ retval = send_client(csock, expr, sizeof(expr)); if (retval < 0) { cut_error("send_client: csock=%d(%d)", csock, errno); return; } /* 受信 */ retval = recv_client(csock, readbuf); if (retval < 0) { cut_error("recv_client: csock=%d(%d)", csock, errno); return; } cut_assert_equal_string((char *)expected, (char *)readbuf); w = wait(&status); if (w < 0) cut_notify("wait(%d)", errno); dbglog("w=%d", (int)w); if (WEXITSTATUS(status)) cut_error("child failed"); } }
void redrobd_rc_net_server_thread::handle_clients(void) { long rc; socket_address client_sa; char client_ip[DOTTED_IP_ADDR_LEN]; ostringstream oss_msg; while (1) { oss_msg << "Wait for client on port:" << dec << m_server_port; redrobd_log_writeln(get_name() + " : " + oss_msg.str()); oss_msg.str(""); // Wait for client to connect rc = accept_socket(m_server_sd, &m_client_sd, &client_sa); // Check if controlled server shutdown if ( (rc != SOCKET_SUPPORT_SUCCESS) && (m_shutdown_requested) ) { // This was a controlled shutdown. // Quit server thread with no error. break; } else if (rc != SOCKET_SUPPORT_SUCCESS) { // This was not a controlled shutdown. // Quit server thread with error. THROW_EXP(REDROBD_INTERNAL_ERROR, REDROBD_SOCKET_OPERATION_FAILED, "Accept server socket failed in thread %s", get_name().c_str()); } else { m_client_connected = true; } // Get address info for connected client if (to_ip_address(client_sa.net_addr, client_ip, DOTTED_IP_ADDR_LEN) != SOCKET_SUPPORT_SUCCESS) { THROW_EXP(REDROBD_INTERNAL_ERROR, REDROBD_SOCKET_OPERATION_FAILED, "Client address for server socket failed in thread %s", get_name().c_str()); } oss_msg << "Client connected => " << client_ip << ", port:" << dec << client_sa.port; redrobd_log_writeln(get_name() + " : " + oss_msg.str()); oss_msg.str(""); // Handle client commands bool handle_command = true; while (handle_command) { try { uint16_t client_command; // Wait for command recv_client((void *)&client_command, sizeof(client_command)); ntoh16(&client_command); // Handle command if (client_command == CLI_CMD_STEER) { uint8_t steer_code; // Get steer code recv_client((void *)&steer_code, sizeof(steer_code)); // Update latest steer code pthread_mutex_lock(&m_steer_code_mutex); m_steer_code = steer_code; pthread_mutex_unlock(&m_steer_code_mutex); } else if (client_command == CLI_CMD_GET_VOLTAGE) { uint16_t voltage; // Reply with latest voltage pthread_mutex_lock(&m_voltage_mutex); voltage = m_voltage; pthread_mutex_unlock(&m_voltage_mutex); hton16(&voltage); send_client((void *)&voltage, sizeof(voltage)); } else if (client_command == CLI_CMD_CAMERA) { uint8_t camera_code; // Get camera code recv_client((void *)&camera_code, sizeof(camera_code)); // Update latest camera code pthread_mutex_lock(&m_camera_code_mutex); m_camera_code = camera_code; pthread_mutex_unlock(&m_camera_code_mutex); } else if (client_command == CLI_CMD_GET_SYS_STATS) { RC_NET_SYS_STAT sys_stat; // Reply with latest system statistics pthread_mutex_lock(&m_sys_stat_mutex); memcpy(&sys_stat, &m_sys_stat, sizeof(m_sys_stat)); pthread_mutex_unlock(&m_sys_stat_mutex); hton32(&sys_stat.mem_used); hton16(&sys_stat.irq); hton32(&sys_stat.uptime); hton32(&sys_stat.cpu_temp); hton16(&sys_stat.cpu_voltage); hton16(&sys_stat.cpu_freq); send_client((void *)&sys_stat, sizeof(sys_stat)); } else { oss_msg << "Unknown client command : 0x" << hex << (unsigned)client_command; redrobd_log_writeln(get_name() + " : " + oss_msg.str()); oss_msg.str(""); handle_command = false; } } catch (...) { handle_command = false; } } if (m_shutdown_requested) { // This was a controlled shutdown. // Quit server thread with no error. break; } // Shutdown client socket if (shutdown_socket(m_client_sd, true, true) != SOCKET_SUPPORT_SUCCESS) { THROW_EXP(REDROBD_INTERNAL_ERROR, REDROBD_SOCKET_OPERATION_FAILED, "Shutdown client socket failed in thread %s", get_name().c_str()); } // Close client socket if (close_socket(m_client_sd) != SOCKET_SUPPORT_SUCCESS) { THROW_EXP(REDROBD_INTERNAL_ERROR, REDROBD_SOCKET_OPERATION_FAILED, "Close client socket failed in thread %s", get_name().c_str()); } m_client_connected = false; } }
int nettest_main(int argc, char *argv[]) #endif { #ifndef CONFIG_EXAMPLES_NETTEST_IPv6 struct in_addr addr; #endif #ifdef CONFIG_EXAMPLES_NETTEST_NOMAC uint8_t mac[IFHWADDRLEN]; #endif /* Many embedded network interfaces must have a software assigned MAC */ #ifdef CONFIG_EXAMPLES_NETTEST_NOMAC mac[0] = 0x00; mac[1] = 0xe0; mac[2] = 0xde; mac[3] = 0xad; mac[4] = 0xbe; mac[5] = 0xef; netlib_setmacaddr("eth0", mac); #endif #ifdef CONFIG_EXAMPLES_NETTEST_IPv6 #ifdef CONFIG_NET_ICMPv6_AUTOCONF /* Perform ICMPv6 auto-configuration */ netlib_icmpv6_autoconfiguration("eth0"); #else /* CONFIG_NET_ICMPv6_AUTOCONF */ /* Set up our fixed host address */ netlib_set_ipv6addr("eth0", (FAR const struct in6_addr *)g_ipv6_hostaddr); /* Set up the default router address */ netlib_set_dripv6addr("eth0", (FAR const struct in6_addr *)g_ipv6_draddr); /* Setup the subnet mask */ netlib_set_ipv6netmask("eth0", (FAR const struct in6_addr *)g_ipv6_netmask); #endif /* CONFIG_NET_ICMPv6_AUTOCONF */ #else /* CONFIG_EXAMPLES_NETTEST_IPv6 */ /* Set up our host address */ addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_IPADDR); netlib_set_ipv4addr("eth0", &addr); /* Set up the default router address */ addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_DRIPADDR); netlib_set_dripv4addr("eth0", &addr); /* Setup the subnet mask */ addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_NETMASK); netlib_set_ipv4netmask("eth0", &addr); #endif /* CONFIG_EXAMPLES_NETTEST_IPv6 */ #ifdef CONFIG_EXAMPLES_NETTEST_SERVER recv_server(); #else send_client(); #endif return 0; }