91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 431KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-29
  • 語言: 其他
  • 標簽: coap??c源代碼??

資源簡介

linux下對coap服務器和客戶端的仿真程序,適合初學者理解coap協議

資源截圖

代碼片段和文件信息

/*?async.c?--?state?management?for?asynchronous?messages
?*
?*?Copyright?(C)?20102011?Olaf?Bergmann?
?*
?*?This?file?is?part?of?the?CoAP?library?libcoap.?Please?see
?*?README?for?terms?of?use.?
?*/

/**?
?*?@file?async.c
?*?@brief?state?management?for?asynchronous?messages
?*/

#ifndef?WITHOUT_ASYNC

#include?“config.h“

#include?“utlist.h“

#include?“mem.h“
#include?“debug.h“
#include?“async.h“

coap_async_state_t?*
coap_register_async(coap_context_t?*context?coap_address_t?*peer
????coap_pdu_t?*request?unsigned?char?flags?void?*data)?{
??coap_async_state_t?*s;
??coap_opt_iterator_t?opt_iter;
??coap_tid_t?id;

??coap_transaction_id(peer?request?&id);
??LL_SEARCH_SCALAR(context->async_statesidid);

??if?(s?!=?NULL)?{
????/*?We?must?return?NULL?here?as?the?caller?must?know?that?he?is
?????*?responsible?for?releasing?@p?data.?*/
????debug(“asynchronous?state?for?transaction?%d?already?registered\n“?id);
????return?NULL;
??}

??/*?store?information?for?handling?the?asynchronous?task?*/
??s?=?(coap_async_state_t?*)coap_malloc(sizeof(coap_async_state_t)?+?
request->hdr->token_length);
??if?(!s)?{
????coap_log(LOG_CRIT?“coap_register_async:?insufficient?memory\n“);
????return?NULL;
??}

??memset(s?0?sizeof(coap_async_state_t)?+?request->hdr->token_length);

??/*?set?COAP_ASYNC_CONFIRM?according?to?request‘s?type?*/
??s->flags?=?flags?&?~COAP_ASYNC_CONFIRM;
??if?(request->hdr->type?==?COAP_MESSAGE_CON)
????s->flags?|=?COAP_ASYNC_CONFIRM;

??s->appdata?=?data;

??memcpy(&s->peer?peer?sizeof(coap_address_t));

??if?(request->hdr->token_length)?{
????s->tokenlen?=?request->hdr->token_length;
????memcpy(s->token?request->hdr->token?request->hdr->token_length);
??}
????
??memcpy(&s->id?&id?sizeof(coap_tid_t));

??coap_touch_async(s);

??LL_PREPEND(context->async_state?s);

??return?s;
}

coap_async_state_t?*
coap_find_async(coap_context_t?*context?coap_tid_t?id)?{
??coap_async_state_t?*tmp;
??LL_SEARCH_SCALAR(context->async_statetmpidid);??
??return?tmp;
}

int
coap_remove_async(coap_context_t?*context?coap_tid_t?id?
??coap_async_state_t?**s)?{
??coap_async_state_t?*tmp?=?coap_find_async(context?id);

??if?(tmp)
????LL_DELETE(context->async_statetmp);

??*s?=?tmp;
??return?tmp?!=?NULL;
}

void?
coap_free_async(coap_async_state_t?*s)?{
??if?(s?&&?(s->flags?&?COAP_ASYNC_RELEASE_DATA)?!=?0)
????coap_free(s->appdata);
??coap_free(s);?
}

#else
void?does_not_exist(); /*?make?some?compilers?happy?*/
#endif?/*?WITHOUT_ASYNC?*/

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-02-26?00:28??libcoap-4.0.1\
?????文件????????2968??2013-01-24?23:57??libcoap-4.0.1\ChangeLog
?????文件????????1315??2013-01-24?23:57??libcoap-4.0.1\LICENSE.BSD
?????文件???????15220??2013-01-24?23:57??libcoap-4.0.1\LICENSE.GPL
?????文件????????2020??2013-01-24?23:57??libcoap-4.0.1\Makefile.in
?????文件????????1010??2013-01-24?23:57??libcoap-4.0.1\README
?????文件????????3510??2013-01-24?23:57??libcoap-4.0.1\address.h
?????文件????????2508??2013-01-24?23:57??libcoap-4.0.1\async.c
?????文件????????5172??2013-01-24?23:57??libcoap-4.0.1\async.h
?????文件????????2024??2013-01-24?23:57??libcoap-4.0.1\bits.h
?????文件????????2923??2013-01-24?23:57??libcoap-4.0.1\block.c
?????文件????????4451??2013-01-24?23:57??libcoap-4.0.1\block.h
?????文件?????????535??2013-01-24?23:57??libcoap-4.0.1\coap.h
?????文件????????1671??2013-01-24?23:57??libcoap-4.0.1\coap_list.c
?????文件????????1294??2013-01-24?23:57??libcoap-4.0.1\coap_list.h
?????文件????????1850??2013-01-24?23:57??libcoap-4.0.1\coap_time.h
?????文件????????3714??2013-01-24?23:57??libcoap-4.0.1\config.h
?????文件????????3482??2013-01-24?23:57??libcoap-4.0.1\config.h.in
?????文件??????154909??2013-01-24?23:57??libcoap-4.0.1\configure
?????文件????????2522??2013-01-24?23:57??libcoap-4.0.1\configure.in
?????文件????????8420??2013-01-24?23:57??libcoap-4.0.1\debug.c
?????文件????????1651??2013-01-24?23:57??libcoap-4.0.1\debug.h
?????目錄???????????0??2013-02-26?00:28??libcoap-4.0.1\doc\
?????文件???????65441??2013-01-24?23:57??libcoap-4.0.1\doc\Doxyfile.in
?????文件????????1253??2013-01-24?23:57??libcoap-4.0.1\doc\Makefile.in
?????目錄???????????0??2013-02-26?00:28??libcoap-4.0.1\doc\html\
?????文件???????17884??2013-01-24?23:57??libcoap-4.0.1\doc\html\address_8h.html
?????文件???????26461??2013-01-24?23:57??libcoap-4.0.1\doc\html\address_8h_source.html
?????文件???????13245??2013-01-24?23:57??libcoap-4.0.1\doc\html\annotated.html
?????文件????????9854??2013-01-24?23:57??libcoap-4.0.1\doc\html\async_8c.html
?????文件???????25804??2013-01-24?23:57??libcoap-4.0.1\doc\html\async_8c_source.html
............此處省略99個文件信息

評論

共有 條評論