本文整理汇总了C++中LWIP_UNUSED_ARG函数的典型用法代码示例。如果您正苦于以下问题:C++ LWIP_UNUSED_ARG函数的具体用法?C++ LWIP_UNUSED_ARG怎么用?C++ LWIP_UNUSED_ARG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LWIP_UNUSED_ARG函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: test_tcp_netif_output
static err_t test_tcp_netif_output(struct netif *netif, struct pbuf *p,
const ip4_addr_t *ipaddr)
{
struct test_tcp_txcounters *txcounters = (struct test_tcp_txcounters*)netif->state;
LWIP_UNUSED_ARG(ipaddr);
if (txcounters != NULL)
{
txcounters->num_tx_calls++;
txcounters->num_tx_bytes += p->tot_len;
if (txcounters->copy_tx_packets) {
struct pbuf *p_copy = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM);
err_t err;
EXPECT(p_copy != NULL);
err = pbuf_copy(p_copy, p);
EXPECT(err == ERR_OK);
if (txcounters->tx_packets == NULL) {
txcounters->tx_packets = p_copy;
} else {
pbuf_cat(txcounters->tx_packets, p_copy);
}
}
}
return ERR_OK;
}
开发者ID:LarchCoder,项目名称:lwip,代码行数:24,代码来源:tcp_helper.c
示例2: auth_withpeer_fail
/*
* We have failed to authenticate ourselves to the peer using `protocol'.
*/
void
auth_withpeer_fail(int unit, u16_t protocol)
{
int errCode = PPPERR_AUTHFAIL;
LWIP_UNUSED_ARG(protocol);
AUTHDEBUG((LOG_INFO, "auth_withpeer_fail: %d proto=%X\n", unit, protocol));
if (passwd_from_file) {
BZERO(ppp_settings.passwd, MAXSECRETLEN);
}
/*
* XXX Warning: the unit number indicates the interface which is
* not necessarily the PPP connection. It works here as long
* as we are only supporting PPP interfaces.
*/
pppIOCtl(unit, PPPCTLS_ERRCODE, &errCode);
/*
* We've failed to authenticate ourselves to our peer.
* He'll probably take the link down, and there's not much
* we can do except wait for that.
*/
}
开发者ID:malooei,项目名称:yeejoin-workspace,代码行数:27,代码来源:auth.c
示例3: sensorentry_get_object_def_a
static void
sensorentry_get_object_def_a(u8_t rid, u8_t ident_len, s32_t *ident, struct obj_def *od)
{
LWIP_UNUSED_ARG(rid);
/* return to object name, adding index depth (1) */
ident_len += 1;
ident -= 1;
if (ident_len == 2)
{
od->id_inst_len = ident_len;
od->id_inst_ptr = ident;
od->instance = MIB_OBJECT_TAB;
od->access = MIB_OBJECT_READ_WRITE;
od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
od->v_len = sizeof(s32_t);
}
else
{
LWIP_DEBUGF(SNMP_MIB_DEBUG,("sensorentry_get_object_def_a: no scalar\n"));
od->instance = MIB_OBJECT_NONE;
}
}
开发者ID:10code,项目名称:lwip,代码行数:24,代码来源:lwip_prvmib.c
示例4: sntp_retry
/**
* Retry: send a new request (and increase retry timeout).
*
* @param arg is unused (only necessary to conform to sys_timeout)
*/
static void
sntp_retry(void* arg)
{
LWIP_UNUSED_ARG(arg);
LWIP_DEBUGF(SNTP_DEBUG_STATE, ("sntp_retry: Next request will be sent in %"U32_F" ms\n",
sntp_retry_timeout));
/* set up a timer to send a retry and increase the retry delay */
sys_timeout(sntp_retry_timeout, sntp_request, NULL);
#if SNTP_RETRY_TIMEOUT_EXP
{
u32_t new_retry_timeout;
/* increase the timeout for next retry */
new_retry_timeout = sntp_retry_timeout << 1;
/* limit to maximum timeout and prevent overflow */
if ((new_retry_timeout <= SNTP_RETRY_TIMEOUT_MAX) &&
(new_retry_timeout > sntp_retry_timeout)) {
sntp_retry_timeout = new_retry_timeout;
}
}
#endif /* SNTP_RETRY_TIMEOUT_EXP */
}
开发者ID:Archcady,项目名称:mbed-os,代码行数:29,代码来源:sntp.c
示例5: etharp_find_addr
/**
* Finds (stable) ethernet/IP address pair from ARP table
* using interface and IP address index.
* @note the addresses in the ARP table are in network order!
*
* @param netif points to interface index
* @param ipaddr points to the (network order) IP address index
* @param eth_ret points to return pointer
* @param ip_ret points to return pointer
* @return table index if found, -1 otherwise
*/
s8_t
etharp_find_addr(struct netif *netif, ip_addr_t *ipaddr,
struct eth_addr **eth_ret, ip_addr_t **ip_ret)
{
s8_t i;
LWIP_ASSERT("eth_ret != NULL && ip_ret != NULL",
eth_ret != NULL && ip_ret != NULL);
LWIP_UNUSED_ARG(netif);
ARP_LOCK();
i = find_entry(ipaddr, ETHARP_FLAG_FIND_ONLY);
if((i >= 0) && arp_table[i].state == ETHARP_STATE_STABLE) {
*eth_ret = &arp_table[i].ethaddr;
*ip_ret = &arp_table[i].ipaddr;
ARP_UNLOCK();
return i;
}
ARP_UNLOCK();
return -1;
}
开发者ID:bacdor-factory,项目名称:Win64-Rovnix-VBR-Bootkit,代码行数:35,代码来源:etharp.c
示例6: tftp_tmr
static void
tftp_tmr(void* arg)
{
LWIP_UNUSED_ARG(arg);
tftp_state.timer++;
if (tftp_state.handle == NULL) {
return;
}
sys_timeout(TFTP_TIMER_MSECS, tftp_tmr, NULL);
if ((tftp_state.timer - tftp_state.last_pkt) > (TFTP_TIMEOUT_MSECS / TFTP_TIMER_MSECS)) {
if ((tftp_state.last_data != NULL) && (tftp_state.retries < TFTP_MAX_RETRIES)) {
LWIP_DEBUGF(TFTP_DEBUG | LWIP_DBG_STATE, ("tftp: timeout, retrying\n"));
resend_data();
tftp_state.retries++;
} else {
LWIP_DEBUGF(TFTP_DEBUG | LWIP_DBG_STATE, ("tftp: timeout\n"));
close_handle();
}
}
}
开发者ID:Archcady,项目名称:mbed-os,代码行数:24,代码来源:tftp_server.c
示例7: test_init
/* This function initializes this lwIP test. When NO_SYS=1, this is done in
* the main_loop context (there is no other one), when NO_SYS=0, this is done
* in the tcpip_thread context */
static void
test_init(void * arg)
{ /* remove compiler warning */
#if NO_SYS
LWIP_UNUSED_ARG(arg);
#else /* NO_SYS */
sys_sem_t *init_sem;
LWIP_ASSERT("arg != NULL", arg != NULL);
init_sem = (sys_sem_t*)arg;
#endif /* NO_SYS */
/* init randomizer again (seed per thread) */
srand((unsigned int)time(0));
/* init network interfaces */
msvc_netif_init();
/* init apps */
apps_init();
#if !NO_SYS
sys_sem_signal(init_sem);
#endif /* !NO_SYS */
}
开发者ID:NCTU-ivan,项目名称:embarc_osp,代码行数:27,代码来源:test.c
示例8: START_TEST
END_TEST
START_TEST(test_sockets_select)
{
#if LWIP_SOCKET_SELECT
int s;
int ret;
fd_set readset;
fd_set writeset;
fd_set errset;
struct timeval tv;
fail_unless(test_sockets_get_used_count() == 0);
s = lwip_socket(AF_INET, SOCK_STREAM, 0);
fail_unless(s >= 0);
fail_unless(test_sockets_get_used_count() == 0);
FD_ZERO(&readset);
FD_SET(s, &readset);
FD_ZERO(&writeset);
FD_SET(s, &writeset);
FD_ZERO(&errset);
FD_SET(s, &errset);
tv.tv_sec = tv.tv_usec = 0;
ret = lwip_select(s + 1, &readset, &writeset, &errset, &tv);
fail_unless(ret == 0);
fail_unless(test_sockets_get_used_count() == 0);
ret = lwip_close(s);
fail_unless(ret == 0);
#endif
LWIP_UNUSED_ARG(_i);
}
开发者ID:0xc0170,项目名称:mbed,代码行数:36,代码来源:test_sockets.c
示例9: snmp_recv
/* lwIP UDP receive callback function */
static void
snmp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port)
{
struct snmp_msg_pstat *msg_ps;
u8_t req_idx;
err_t err_ret;
u16_t payload_len = p->tot_len;
u16_t payload_ofs = 0;
u16_t varbind_ofs = 0;
/* suppress unused argument warning */
LWIP_UNUSED_ARG(arg);
/* traverse input message process list, look for SNMP_MSG_EMPTY */
msg_ps = &msg_input_list[0];
req_idx = 0;
while ((req_idx < SNMP_CONCURRENT_REQUESTS) && (msg_ps->state != SNMP_MSG_EMPTY)) {
req_idx++;
msg_ps++;
}
if (req_idx == SNMP_CONCURRENT_REQUESTS) {
/* exceeding number of concurrent requests */
pbuf_free(p);
return;
}
/* accepting request */
snmp_inc_snmpinpkts();
/* record used 'protocol control block' */
msg_ps->pcb = pcb;
/* source address (network order) */
msg_ps->sip = *addr;
/* source port (host order (lwIP oddity)) */
msg_ps->sp = port;
/* check total length, version, community, pdu type */
err_ret = snmp_pdu_header_check(p, payload_ofs, payload_len, &varbind_ofs, msg_ps);
/* Only accept requests and requests without error (be robust) */
/* Reject response and trap headers or error requests as input! */
if ((err_ret != ERR_OK) ||
((msg_ps->rt != SNMP_ASN1_PDU_GET_REQ) &&
(msg_ps->rt != SNMP_ASN1_PDU_GET_NEXT_REQ) &&
(msg_ps->rt != SNMP_ASN1_PDU_SET_REQ)) ||
((msg_ps->error_status != SNMP_ES_NOERROR) ||
(msg_ps->error_index != 0)) ) {
/* header check failed drop request silently, do not return error! */
pbuf_free(p);
LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_pdu_header_check() failed\n"));
return;
}
LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_recv ok, community %s\n", msg_ps->community));
/* Builds a list of variable bindings. Copy the varbinds from the pbuf
chain to glue them when these are divided over two or more pbuf's. */
err_ret = snmp_pdu_dec_varbindlist(p, varbind_ofs, &varbind_ofs, msg_ps);
/* we've decoded the incoming message, release input msg now */
pbuf_free(p);
if ((err_ret != ERR_OK) || (msg_ps->invb.count == 0)) {
/* varbind-list decode failed, or varbind list empty.
drop request silently, do not return error!
(errors are only returned for a specific varbind failure) */
LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_pdu_dec_varbindlist() failed\n"));
return;
}
msg_ps->error_status = SNMP_ES_NOERROR;
msg_ps->error_index = 0;
/* find object for each variable binding */
msg_ps->state = SNMP_MSG_SEARCH_OBJ;
/* first variable binding from list to inspect */
msg_ps->vb_idx = 0;
LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_recv varbind cnt=%"U16_F"\n",(u16_t)msg_ps->invb.count));
/* handle input event and as much objects as possible in one go */
snmp_msg_event(req_idx);
}
开发者ID:peterliu2,项目名称:tivaWare,代码行数:78,代码来源:msg_in.c
示例10: etharp_find_entry
/**
* Search the ARP table for a matching or new entry.
*
* If an IP address is given, return a pending or stable ARP entry that matches
* the address. If no match is found, create a new entry with this address set,
* but in state ETHARP_EMPTY. The caller must check and possibly change the
* state of the returned entry.
*
* If ipaddr is NULL, return a initialized new entry in state ETHARP_EMPTY.
*
* In all cases, attempt to create new entries from an empty entry. If no
* empty entries are available and ETHARP_FLAG_TRY_HARD flag is set, recycle
* old entries. Heuristic choose the least important entry for recycling.
*
* @param ipaddr IP address to find in ARP cache, or to add if not found.
* @param flags See @ref etharp_state
* @param netif netif related to this address (used for NETIF_HWADDRHINT)
*
* @return The ARP entry index that matched or is created, ERR_MEM if no
* entry is found or could be recycled.
*/
static s8_t
etharp_find_entry(const ip4_addr_t *ipaddr, u8_t flags, struct netif* netif)
{
s8_t old_pending = ARP_TABLE_SIZE, old_stable = ARP_TABLE_SIZE;
s8_t empty = ARP_TABLE_SIZE;
u8_t i = 0;
/* oldest entry with packets on queue */
s8_t old_queue = ARP_TABLE_SIZE;
/* its age */
u16_t age_queue = 0, age_pending = 0, age_stable = 0;
LWIP_UNUSED_ARG(netif);
/**
* a) do a search through the cache, remember candidates
* b) select candidate entry
* c) create new entry
*/
/* a) in a single search sweep, do all of this
* 1) remember the first empty entry (if any)
* 2) remember the oldest stable entry (if any)
* 3) remember the oldest pending entry without queued packets (if any)
* 4) remember the oldest pending entry with queued packets (if any)
* 5) search for a matching IP entry, either pending or stable
* until 5 matches, or all entries are searched for.
*/
for (i = 0; i < ARP_TABLE_SIZE; ++i) {
u8_t state = arp_table[i].state;
/* no empty entry found yet and now we do find one? */
if ((empty == ARP_TABLE_SIZE) && (state == ETHARP_STATE_EMPTY)) {
LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_find_entry: found empty entry %"U16_F"\n", (u16_t)i));
/* remember first empty entry */
empty = i;
} else if (state != ETHARP_STATE_EMPTY) {
LWIP_ASSERT("state == ETHARP_STATE_PENDING || state >= ETHARP_STATE_STABLE",
state == ETHARP_STATE_PENDING || state >= ETHARP_STATE_STABLE);
/* if given, does IP address match IP address in ARP entry? */
if (ipaddr && ip4_addr_cmp(ipaddr, &arp_table[i].ipaddr)
#if ETHARP_TABLE_MATCH_NETIF
&& ((netif == NULL) || (netif == arp_table[i].netif))
#endif /* ETHARP_TABLE_MATCH_NETIF */
) {
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_find_entry: found matching entry %"U16_F"\n", (u16_t)i));
/* found exact IP address match, simply bail out */
return i;
}
/* pending entry? */
if (state == ETHARP_STATE_PENDING) {
/* pending with queued packets? */
if (arp_table[i].q != NULL) {
if (arp_table[i].ctime >= age_queue) {
old_queue = i;
age_queue = arp_table[i].ctime;
}
} else
/* pending without queued packets? */
{
if (arp_table[i].ctime >= age_pending) {
old_pending = i;
age_pending = arp_table[i].ctime;
}
}
/* stable entry? */
} else if (state >= ETHARP_STATE_STABLE) {
#if ETHARP_SUPPORT_STATIC_ENTRIES
/* don't record old_stable for static entries since they never expire */
if (state < ETHARP_STATE_STATIC)
#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */
{
/* remember entry with oldest stable entry in oldest, its age in maxtime */
if (arp_table[i].ctime >= age_stable) {
old_stable = i;
age_stable = arp_table[i].ctime;
}
}
}
}
//.........这里部分代码省略.........
开发者ID:NXPmicro,项目名称:mbed,代码行数:101,代码来源:lwip_etharp.c
示例11: espconn_tcp_accept
/******************************************************************************
* FunctionName : espconn_tcp_accept
* Description : A new incoming connection has been accepted.
* Parameters : arg -- Additional argument to pass to the callback function
* pcb -- The connection pcb which is accepted
* err -- An unused error code, always ERR_OK currently
* Returns : acception result
*******************************************************************************/
static err_t ICACHE_FLASH_ATTR
espconn_tcp_accept(void *arg, struct tcp_pcb *pcb, err_t err)
{
struct espconn *espconn = arg;
espconn_msg *paccept = NULL;
remot_info *pinfo = NULL;
LWIP_UNUSED_ARG(err);
if (!espconn || !espconn->proto.tcp) {
return ERR_ARG;
}
tcp_arg(pcb, paccept);
tcp_err(pcb, esponn_server_err);
/*Ensure the active connection is less than the count of active connections on the server*/
espconn_get_connection_info(espconn, &pinfo , 0);
espconn_printf("espconn_tcp_accept link_cnt: %d\n", espconn->link_cnt);
if (espconn->link_cnt == espconn_tcp_get_max_con_allow(espconn))
return ERR_ISCONN;
/*Creates a new active connect control message*/
paccept = (espconn_msg *)malloc(sizeof(espconn_msg));
memset(paccept, 0, sizeof(espconn_msg));
tcp_arg(pcb, paccept);
if (paccept == NULL)
return ERR_MEM;
/*Insert the node to the active connection list*/
espconn_list_creat(&plink_active, paccept);
paccept->preverse = espconn;
paccept->pespconn = (struct espconn *)malloc(sizeof(struct espconn));
if (paccept->pespconn == NULL)
return ERR_MEM;
paccept->pespconn->proto.tcp = (esp_tcp *)malloc(sizeof(esp_tcp));
if (paccept->pespconn->proto.tcp == NULL)
return ERR_MEM;
/*Reserve the remote information for current active connection*/
paccept->pcommon.pcb = pcb;
paccept->pcommon.remote_port = pcb->remote_port;
paccept->pcommon.remote_ip[0] = ip4_addr1_16(&pcb->remote_ip.u_addr.ip4);
paccept->pcommon.remote_ip[1] = ip4_addr2_16(&pcb->remote_ip.u_addr.ip4);
paccept->pcommon.remote_ip[2] = ip4_addr3_16(&pcb->remote_ip.u_addr.ip4);
paccept->pcommon.remote_ip[3] = ip4_addr4_16(&pcb->remote_ip.u_addr.ip4);
paccept->pcommon.write_flag = true;
memcpy(espconn->proto.tcp->remote_ip, paccept->pcommon.remote_ip, 4);
espconn->proto.tcp->remote_port = pcb->remote_port;
espconn->state = ESPCONN_CONNECT;
espconn_copy_partial(paccept->pespconn, espconn);
/*Set the specify function that should be called
* when TCP data has been successfully delivered,
* when active connection receives data,
* or periodically from active connection*/
tcp_sent(pcb, espconn_server_sent);
tcp_recv(pcb, espconn_server_recv);
tcp_poll(pcb, espconn_server_poll, 8); /* every 1 seconds */
/*Disable Nagle algorithm default*/
tcp_nagle_disable(pcb);
/*Default set the total number of espconn_buf on the unsent lists for one*/
espconn_tcp_set_buf_count(paccept->pespconn, 1);
if (paccept->pespconn->proto.tcp->connect_callback != NULL) {
paccept->pespconn->proto.tcp->connect_callback(paccept->pespconn);
}
/*Enable keep alive option*/
if (espconn_keepalive_disabled(paccept))
espconn_keepalive_enable(pcb);
return ERR_OK;
}
开发者ID:Nicholas3388,项目名称:LuaNode,代码行数:83,代码来源:espconn_tcp.c
示例12: pcapifh_linkstate_get
enum pcapifh_link_event pcapifh_linkstate_get(struct pcapifh_linkstate* state)
{
LWIP_UNUSED_ARG(state);
LWIP_ASSERT("not implemented", 0);
return LINKEVENT_UNKNOWN;
}
开发者ID:evelinad,项目名称:cs244-final-proj,代码行数:6,代码来源:pcapif_helper.c
示例13: rtp_recv_thread
/**
* RTP recv thread
*/
static void
rtp_recv_thread(void *arg)
{
int sock;
struct sockaddr_in local;
struct sockaddr_in from;
int fromlen;
struct ip_mreq ipmreq;
struct rtp_hdr* rtphdr;
u32_t rtp_stream_address;
int timeout;
size_t result;
int recvrtppackets = 0;
int lostrtppackets = 0;
u16_t lastrtpseq = 0;
LWIP_UNUSED_ARG(arg);
/* initialize RTP stream address */
rtp_stream_address = RTP_STREAM_ADDRESS;
/* if we got a valid RTP stream address... */
if (rtp_stream_address != 0) {
/* create new socket */
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock >= 0) {
/* prepare local address */
memset(&local, 0, sizeof(local));
local.sin_family = AF_INET;
local.sin_port = PP_HTONS(RTP_STREAM_PORT);
local.sin_addr.s_addr = PP_HTONL(INADDR_ANY);
/* bind to local address */
if (bind(sock, (struct sockaddr *)&local, sizeof(local)) == 0) {
/* set recv timeout */
timeout = RTP_RECV_TIMEOUT;
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout));
/* prepare multicast "ip_mreq" struct */
ipmreq.imr_multiaddr.s_addr = rtp_stream_address;
ipmreq.imr_interface.s_addr = PP_HTONL(INADDR_ANY);
/* join multicast group */
if (setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &ipmreq, sizeof(ipmreq)) == 0) {
/* receive RTP packets */
while(1) {
fromlen = sizeof(from);
result = recvfrom(sock, rtp_recv_packet, sizeof(rtp_recv_packet), 0,
(struct sockaddr *)&from, (socklen_t *)&fromlen);
if (result >= sizeof(struct rtp_hdr)) {
rtphdr = (struct rtp_hdr *)rtp_recv_packet;
recvrtppackets++;
if ((lastrtpseq == 0) || ((lastrtpseq + 1) == lwip_ntohs(rtphdr->seqNum))) {
RTP_RECV_PROCESSING((rtp_recv_packet + sizeof(rtp_hdr)),(result-sizeof(rtp_hdr)));
} else {
lostrtppackets++;
}
lastrtpseq = lwip_ntohs(rtphdr->seqNum);
if ((recvrtppackets % RTP_RECV_STATS) == 0) {
LWIP_DEBUGF(RTP_DEBUG, ("rtp_recv_thread: recv %6i packet(s) / lost %4i packet(s) (%.4f%%)...\n", recvrtppackets, lostrtppackets, (lostrtppackets*100.0)/recvrtppackets));
}
} else {
LWIP_DEBUGF(RTP_DEBUG, ("rtp_recv_thread: recv timeout...\n"));
}
}
/* leave multicast group */
setsockopt(sock, IPPROTO_IP, IP_DROP_MEMBERSHIP, &ipmreq, sizeof(ipmreq));
}
}
/* close the socket */
closesocket(sock);
}
}
}
开发者ID:NCTU-ivan,项目名称:embarc_osp,代码行数:79,代码来源:rtp.c
示例14: pxudp_pmgr_pump
static int
pxudp_pmgr_pump(struct pollmgr_handler *handler, SOCKET fd, int revents)
{
struct pxudp *pxudp;
struct pbuf *p;
ssize_t nread;
err_t error;
pxudp = (struct pxudp *)handler->data;
LWIP_ASSERT1(handler == &pxudp->pmhdl);
LWIP_ASSERT1(fd == pxudp->sock);
LWIP_UNUSED_ARG(fd);
if (revents & ~(POLLIN|POLLERR)) {
DPRINTF(("%s: unexpected revents 0x%x\n", __func__, revents));
return pxudp_schedule_delete(pxudp);
}
/*
* XXX: AFAICS, there's no way to match the error with the
* outgoing datagram that triggered it, since we do non-blocking
* sends from lwip thread.
*/
if (revents & POLLERR) {
int sockerr = -1;
socklen_t optlen = (socklen_t)sizeof(sockerr);
int status;
status = getsockopt(pxudp->sock, SOL_SOCKET,
SO_ERROR, (char *)&sockerr, &optlen);
if (status < 0) {
DPRINTF(("%s: sock %d: SO_ERROR failed:%R[sockerr]\n",
__func__, pxudp->sock, SOCKERRNO()));
}
else {
DPRINTF(("%s: sock %d: %R[sockerr]\n",
__func__, pxudp->sock, sockerr));
}
}
if ((revents & POLLIN) == 0) {
return POLLIN;
}
nread = recv(pxudp->sock, pollmgr_udpbuf, sizeof(pollmgr_udpbuf), 0);
if (nread == SOCKET_ERROR) {
DPRINTF(("%s: %R[sockerr]\n", __func__, SOCKERRNO()));
return POLLIN;
}
p = pbuf_alloc(PBUF_RAW, (u16_t)nread, PBUF_RAM);
if (p == NULL) {
DPRINTF(("%s: pbuf_alloc(%d) failed\n", __func__, (int)nread));
return POLLIN;
}
error = pbuf_take(p, pollmgr_udpbuf, (u16_t)nread);
if (error != ERR_OK) {
DPRINTF(("%s: pbuf_take(%d) failed\n", __func__, (int)nread));
pbuf_free(p);
return POLLIN;
}
error = sys_mbox_trypost(&pxudp->inmbox, p);
if (error != ERR_OK) {
pbuf_free(p);
return POLLIN;
}
proxy_lwip_post(&pxudp->msg_inbound);
return POLLIN;
}
开发者ID:gvsurenderreddy,项目名称:virtualbox,代码行数:74,代码来源:pxudp.c
示例15: pxudp_pcb_accept
/**
* New proxied UDP conversation created.
* Global callback for udp_proxy_accept().
*/
static void
pxudp_pcb_accept(void *arg, struct udp_pcb *newpcb, struct pbuf *p,
ip_addr_t *addr, u16_t port)
{
struct pxudp *pxudp;
ipX_addr_t dst_addr;
int mapping;
int sdom;
SOCKET sock;
LWIP_ASSERT1(newpcb != NULL);
LWIP_ASSERT1(p != NULL);
LWIP_UNUSED_ARG(arg);
mapping = pxremap_outbound_ipX(PCB_ISIPV6(newpcb), &dst_addr, &newpcb->local_ip);
if (mapping != PXREMAP_MAPPED && pxudp_ttl_expired(p)) {
udp_remove(newpcb);
return;
}
pxudp = pxudp_allocate();
if (pxudp == NULL) {
DPRINTF(("pxudp_allocate: failed\n"));
udp_remove(newpcb);
pbuf_free(p);
return;
}
sdom = PCB_ISIPV6(newpcb) ? PF_INET6 : PF_INET;
pxudp->is_mapped = (mapping == PXREMAP_MAPPED);
#if 0 /* XXX: DNS IPv6->IPv4 remapping hack */
if (pxudp->is_mapped
&& newpcb->local_port == 53
&& PCB_ISIPV6(newpcb))
{
/*
* "Remap" DNS over IPv6 to IPv4 since Ubuntu dnsmasq does not
* listen on IPv6.
*/
sdom = PF_INET;
ipX_addr_set_loopback(0, &dst_addr);
}
#endif /* DNS IPv6->IPv4 remapping hack */
sock = proxy_connected_socket(sdom, SOCK_DGRAM,
&dst_addr, newpcb->local_port);
if (sock == INVALID_SOCKET) {
udp_remove(newpcb);
pbuf_free(p);
return;
}
pxudp->sock = sock;
pxudp->pcb = newpcb;
udp_recv(newpcb, pxudp_pcb_recv, pxudp);
pxudp->pmhdl.callback = pxudp_pmgr_pump;
pxudp_chan_send(POLLMGR_CHAN_PXUDP_ADD, pxudp);
/* dispatch directly instead of calling pxudp_pcb_recv() */
pxudp_pcb_forward_outbound(pxudp, p, addr, port);
}
开发者ID:gvsurenderreddy,项目名称:virtualbox,代码行数:67,代码来源:pxudp.c
示例16: pxudp_pcb_forward_outbound
static void
pxudp_pcb_forward_outbound(struct pxudp *pxudp, struct pbuf *p,
ip_addr_t *addr, u16_t port)
{
int status;
LWIP_UNUSED_ARG(addr);
LWIP_UNUSED_ARG(port);
if (!pxudp->is_mapped && pxudp_ttl_expired(p)) {
return;
}
if (!ip_current_is_v6()) { /* IPv4 */
const struct ip_hdr *iph = ip_current_header();
int ttl, tos, df;
/*
* Different OSes have different socket options for DF.
* Unlike pxping.c, we can't use IP_HDRINCL here as it's only
* valid for SOCK_RAW.
*/
# define USE_DF_OPTION(_Optname) \
const int dfopt = _Optname; \
const char * const dfoptname = #_Optname;
#if defined(IP_MTU_DISCOVER) /* Linux */
USE_DF_OPTION(IP_MTU_DISCOVER);
#elif defined(IP_DONTFRAG) /* Solaris 11+, FreeBSD */
USE_DF_OPTION(IP_DONTFRAG);
#elif defined(IP_DONTFRAGMENT) /* Windows */
USE_DF_OPTION(IP_DONTFRAGMENT);
#else
USE_DF_OPTION(0);
#endif
ttl = IPH_TTL(iph);
if (!pxudp->is_mapped) {
LWIP_ASSERT1(ttl > 1);
--ttl;
}
if (ttl != pxudp->ttl) {
status = setsockopt(pxudp->sock, IPPROTO_IP, IP_TTL,
(char *)&ttl, sizeof(ttl));
if (RT_LIKELY(status == 0)) {
pxudp->ttl = ttl;
}
else {
DPRINTF(("IP_TTL: %R[sockerr]\n", SOCKERRNO()));
}
}
tos = IPH_TOS(iph);
if (tos != pxudp->tos) {
status = setsockopt(pxudp->sock, IPPROTO_IP, IP_TOS,
(char *)&tos, sizeof(tos));
if (RT_LIKELY(status == 0)) {
pxudp->tos = tos;
}
else {
DPRINTF(("IP_TOS: %R[sockerr]\n", SOCKERRNO()));
}
}
if (dfopt) {
df = (IPH_OFFSET(iph) & PP_HTONS(IP_DF)) != 0;
#if defined(IP_MTU_DISCOVER)
df = df ? IP_PMTUDISC_DO : IP_PMTUDISC_DONT;
#endif
if (df != pxudp->df) {
status = setsockopt(pxudp->sock, IPPROTO_IP, dfopt,
(char *)&df, sizeof(df));
if (RT_LIKELY(status == 0)) {
pxudp->df = df;
}
else {
DPRINTF(("%s: %R[sockerr]\n", dfoptname, SOCKERRNO()));
}
}
}
}
else { /* IPv6 */
const struct ip6_hdr *iph = ip6_current_header();
int ttl;
ttl = IP6H_HOPLIM(iph);
if (!pxudp->is_mapped) {
LWIP_ASSERT1(ttl > 1);
--ttl;
}
if (ttl != pxudp->ttl) {
status = setsockopt(pxudp->sock, IPPROTO_IPV6, IPV6_UNICAST_HOPS,
(char *)&ttl, sizeof(ttl));
if (RT_LIKELY(status == 0)) {
pxudp->ttl = ttl;
}
else {
DPRINTF(("IPV6_UNICAST_HOPS: %R[sockerr]\n", SOCKERRNO()));
}
//.........这里部分代码省略.........
开发者ID:gvsurenderreddy,项目名称:virtualbox,代码行数:101,代码来源:pxudp.c
示例17: udp_input
/**
* Process an incoming UDP datagram.
*
* Given an incoming UDP datagram (as a chain of pbufs) this function
* finds a corresponding UDP PCB and hands over the pbuf to the pcbs
* recv function. If no pcb is found or the datagram is incorrect, the
* pbuf is freed.
*
* @param p pbuf to be demultiplexed to a UDP PCB (p->payload pointing to the UDP header)
* @param inp network interface on which the datagram was received.
*
*/
void
udp_input(struct pbuf *p, struct netif *inp)
{
struct udp_hdr *udphdr;
struct udp_pcb *pcb, *prev;
struct udp_pcb *uncon_pcb;
u16_t src, dest;
u8_t broadcast;
u8_t for_us = 0;
LWIP_UNUSED_ARG(inp);
PERF_START;
UDP_STATS_INC(udp.recv);
/* Check minimum length (UDP header) */
if (p->len < UDP_HLEN) {
/* drop short packets */
LWIP_DEBUGF(UDP_DEBUG,
("udp_input: short UDP datagram (%"U16_F" bytes) discarded\n", p->tot_len));
UDP_STATS_INC(udp.lenerr);
UDP_STATS_INC(udp.drop);
MIB2_STATS_INC(mib2.udpinerrors);
pbuf_free(p);
goto end;
}
udphdr = (struct udp_hdr *)p->payload;
/* is broadcast packet ? */
broadcast = ip_addr_isbroadcast(ip_current_dest_addr(), ip_current_netif());
LWIP_DEBUGF(UDP_DEBUG, ("udp_input: received datagram of length %"U16_F"\n", p->tot_len));
/* convert src and dest ports to host byte order */
src = lwip_ntohs(udphdr->src);
dest = lwip_ntohs(udphdr->dest);
udp_debug_print(udphdr);
/* print the UDP source and destination */
LWIP_DEBUGF(UDP_DEBUG, ("udp ("));
ip_addr_debug_print(UDP_DEBUG, ip_current_dest_addr());
LWIP_DEBUGF(UDP_DEBUG, (", %"U16_F") <-- (", lwip_ntohs(udphdr->dest)));
ip_addr_debug_print(UDP_DEBUG, ip_current_src_addr());
LWIP_DEBUGF(UDP_DEBUG, (", %"U16_F")\n", lwip_ntohs(udphdr->src)));
pcb = NULL;
prev = NULL;
uncon_pcb = NULL;
/* Iterate through the UDP pcb list for a matching pcb.
* 'Perfect match' pcbs (connected to the remote port & ip address) are
* preferred. If no perfect match is found, the first unconnected pcb that
* matches the local port and ip address gets the datagram. */
for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) {
/* print the PCB local and remote address */
LWIP_DEBUGF(UDP_DEBUG, ("pcb ("));
ip_addr_debug_print(UDP_DEBUG, &pcb->local_ip);
LWIP_DEBUGF(UDP_DEBUG, (", %"U16_F") <-- (", pcb->local_port));
ip_addr_debug_print(UDP_DEBUG, &pcb->remote_ip);
LWIP_DEBUGF(UDP_DEBUG, (", %"U16_F")\n", pcb->remote_port));
/* compare PCB local addr+port to UDP destination addr+port */
if ((pcb->local_port == dest) &&
(udp_input_local_match(pcb, inp, broadcast) != 0)) {
if (((pcb->flags & UDP_FLAGS_CONNECTED) == 0) &&
((uncon_pcb == NULL)
#if SO_REUSE
/* prefer specific IPs over cath-all */
|| !ip_addr_isany(&pcb->local_ip)
#endif /* SO_REUSE */
)) {
/* the first unconnected matching PCB */
uncon_pcb = pcb;
}
/* compare PCB remote addr+port to UDP source addr+port */
if ((pcb->remote_port == src) &&
(ip_addr_isany_val(pcb->remote_ip) ||
ip_addr_cmp(&pcb->remote_ip, ip_current_src_addr()))) {
/* the first fully matching PCB */
if (prev != NULL) {
/* move the pcb to the front of udp_pcbs so that is
found faster next time */
prev->next = pcb->next;
pcb->next = udp_pcbs;
udp_pcbs = pcb;
//.........这里部分代码省略.........
开发者ID:gastonfeng,项目名称:rt-thread,代码行数:101,代码来源:udp.c
示例18: netif_loop_output
/**
* Send an IP packet to be received on the same netif (loopif-like).
* The pbuf is simply copied and handed back to netif->input.
* In multithreaded mode, this is done directly since netif->input must put
* the packet on a queue.
* In callback mode, the packet is put on an internal queue and is fed to
* netif->input by netif_poll().
*
* @param netif the lwip network interface structure
* @param p the (IP) packet to 'send'
* @param ipaddr the ip address to send the packet to (not used)
* @return ERR_OK if the packet has been sent
* ERR_MEM if the pbuf used to copy the packet couldn't be allocated
*/
err_t
netif_loop_output(struct netif *netif, struct pbuf *p,
ip_addr_t *ipaddr)
{
struct pbuf *r;
err_t err;
struct pbuf *last;
#if LWIP_LOOPBACK_MAX_PBUFS
u8_t clen = 0;
#endif /* LWIP_LOOPBACK_MAX_PBUFS */
/* If we have a loopif, SNMP counters are adjusted for it,
* if not they are adjusted for 'netif'. */
#if LWIP_SNMP
#if LWIP_HAVE_LOOPIF
struct netif *stats_if = &loop_netif;
#else /* LWIP_HAVE_LOOPIF */
struct netif *stats_if = netif;
#endif /* LWIP_HAVE_LOOPIF */
#endif /* LWIP_SNMP */
SYS_ARCH_DECL_PROTECT(lev);
LWIP_UNUSED_ARG(ipaddr);
/* Allocate a new pbuf */
r = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM);
if (r == NULL) {
LINK_STATS_INC(link.memerr);
LINK_STATS_INC(link.drop);
snmp_inc_ifoutdiscards(stats_if);
return ERR_MEM;
}
#if LWIP_LOOPBACK_MAX_PBUFS
clen = pbuf_clen(r);
/* check for overflow or too many pbuf on queue */
if(((netif->loop_cnt_current + clen) < netif->loop_cnt_current) ||
((netif->loop_cnt_current + clen) > LWIP_LOOPBACK_MAX_PBUFS)) {
pbuf_free(r);
LINK_STATS_INC(link.memerr);
LINK_STATS_INC(link.drop);
snmp_inc_ifoutdiscards(stats_if);
return ERR_MEM;
}
netif->loop_cnt_current += clen;
#endif /* LWIP_LOOPBACK_MAX_PBUFS */
/* Copy the whole pbuf queue p into the single pbuf r */
if ((err = pbuf_copy(r, p)) != ERR_OK) {
pbuf_free(r);
LINK_STATS_INC(link.memerr);
LINK_STATS_INC(link.drop);
snmp_inc_ifoutdiscards(stats_if);
return err;
}
/* Put the packet on a linked list which gets emptied through calling
netif_poll(). */
/* let last point to the last pbuf in chain r */
for (last = r; last->next != NULL; last = last->next);
SYS_ARCH_PROTECT(lev);
if(netif->loop_first != NULL) {
LWIP_ASSERT("if first != NULL, last must also be != NULL", netif->loop_last != NULL);
netif->loop_last->next = r;
netif->loop_last = last;
} else {
netif->loop_first = r;
netif->loop_last = last;
}
SYS_ARCH_UNPROTECT(lev);
LINK_STATS_INC(link.xmit);
snmp_add_ifoutoctets(stats_if, p->tot_len);
snmp_inc_ifoutucastpkts(stats_if);
#if LWIP_NETIF_LOOPBACK_MULTITHREADING
/* For multithreading environment, schedule a call to netif_poll */
tcpip_callback((tcpip_callback_fn)netif_poll, netif);
#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */
return ERR_OK;
}
开发者ID:projectarkc,项目名称:psiphon,代码行数:95,代码来源:netif.c
示例19: tcpip_thread
/**
* The main lwIP thread. This thread has exclusive access to lwIP core functions
* (unless access to them is not locked). Other threads communicate with this
* thread using message boxes.
*
* It also starts all the timers to make sure they are running in the right
* thread context.
*
* @param arg unused argument
*/
static void
tcpip_thread(void *arg)
{
struct tcpip_msg *msg;
LWIP_UNUSED_ARG(arg);
#if IP_REASSEMBLY
sys_timeout(IP_TMR_INTERVAL, ip_reass_timer, NULL);
#endif /* IP_REASSEMBLY */
#if LWIP_ARP
sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL);
#endif /* LWIP_ARP */
#if LWIP_DHCP
sys_timeout(DHCP_COARSE_TIMER_MSECS, dhcp_timer_coarse, NULL);
sys_timeout(DHCP_FINE_TIMER_MSECS, dhcp_timer_fine, NULL);
#endif /* LWIP_DHCP */
#if LWIP_AUTOIP
sys_timeout(AUTOIP_TMR_INTERVAL, autoip_timer, NULL);
#endif /* LWIP_AUTOIP */
#if LWIP_IGMP
sys_timeout(IGMP_TMR_INTERVAL, igmp_timer, NULL);
#endif /* LWIP_IGMP */
#if LWIP_DNS
sys_timeout(DNS_TMR_INTERVAL, dns_timer, NULL);
#endif /* LWIP_DNS */
if (tcpip_init_done != NULL) {
tcpip_init_done(tcpip_init_done_arg);
}
LOCK_TCPIP_CORE();
while (1) { /* MAIN Loop */
sys_mbox_fetch(mbox, (void *)&msg);
switch (msg->type) {
#if LWIP_NETCONN
case TCPIP_MSG_API:
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: API message %p\n", (void *)msg));
msg->msg.apimsg->function(&(msg->msg.apimsg->msg));
break;
#endif /* LWIP_NETCONN */
case TCPIP_MSG_INPKT:
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: PACKET %p\n", (void *)msg));
#if LWIP_ARP
if (msg->msg.inp.netif->flags & NETIF_FLAG_ETHARP) {
ethernet_input(msg->msg.inp.p, msg->msg.inp.netif);
} else
#endif /* LWIP_ARP */
{ ip_input(msg->msg.inp.p, msg->msg.inp.netif);
}
memp_free(MEMP_TCPIP_MSG_INPKT, msg);
break;
#if LWIP_NETIF_API
case TCPIP_MSG_NETIFAPI:
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: Netif API message %p\n", (void *)msg));
msg->msg.netifapimsg->function(&(msg->msg.netifapimsg->msg));
break;
#endif /* LWIP_NETIF_API */
case TCPIP_MSG_CALLBACK:
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: CALLBACK %p\n", (void *)msg));
msg->msg.cb.f(msg->msg.cb.ctx);
memp_free(MEMP_TCPIP_MSG_API, msg);
break;
case TCPIP_MSG_TIMEOUT:
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: TIMEOUT %p\n", (void *)msg));
sys_timeout(msg->msg.tmo.msecs, msg->msg.tmo.h, msg->msg.tmo.arg);
memp_free(MEMP_TCPIP_MSG_API, msg);
break;
case TCPIP_MSG_UNTIMEOUT:
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: UNTIMEOUT %p\n", (void *)msg));
sys_untimeout(msg->msg.tmo.h, msg->msg.tmo.arg);
memp_free(MEMP_TCPIP_MSG_API, msg);
break;
default:
break;
}
}
}
开发者ID:racribeiro,项目名称:R2C2-Firmware-OS,代码行数:92,代码来源:tcpip.c
示例20: pcapifh_linkstate_init
|
请发表评论