freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

lwip協(xié)議棧的學(xué)習(xí)與應(yīng)用-googlecode(參考版)

2024-11-18 04:10本頁面
  

【正文】 對(duì)于這個(gè)函數(shù)中的幾個(gè)調(diào)用,我們看一個(gè)就好了,別的實(shí)現(xiàn)也差不多,就是個(gè)賦值的過程 。 tcp_err(pcb, err_tcp)。 tcp_sent(pcb, sent_tcp)。 tcp_arg(pcb, conn)。 嗯接著看 recv_tcp 的 caller: * Setup a tcp_pcb with the correct callback function pointers * and their arguments. * param conn the TCP conn to setup static void setup_tcp(struct conn *conn) { struct tcp_pcb *pcb??纯春瘮?shù)的原型: * Receive callback function for TCP conns. * Posts the packet to connrecvmbox, but doesn39。 接著往下走,我們發(fā)現(xiàn),數(shù)據(jù)的來源是在 conn 的 recvmbox,剛才提到過的。從 conn 的 recvmbox中收取數(shù)據(jù),在這里有個(gè) do_recv 的調(diào)用,而 do_recv又調(diào)用了 tcp_recved,關(guān)于這個(gè)函數(shù)的注釋如下: * This function should be called by the application when it has * processed the data. The purpose is to advertise a larger window * when the data has been processed. 知道了,這里的 do_recv 只是起到一個(gè)知會(huì)的作用,可能的話會(huì)對(duì)接收條件做一些調(diào)整。這里主要涉及到 lwip_recvfrom 這個(gè)函數(shù)。文檔是這么解釋的:tcp_output 函數(shù)會(huì)檢查現(xiàn)在是不是能夠發(fā)送數(shù)據(jù),也就是判斷接收器窗口是否擁有足夠大的空間,阻塞窗口是否也足夠大,如果條件滿足,它先填充未被 tcp_enqueue 函數(shù)填充的 tcp報(bào)頭字段,接著就使用 ip_route 或者 ip_output_if 函數(shù)發(fā)送數(shù)據(jù)。這里也只做一個(gè)簡單介紹,具體請(qǐng)參閱 文檔。也就是說最后的執(zhí)行是 tcp_output 來實(shí)現(xiàn)的。 下面的這個(gè) tcp_enqueue 才是個(gè)大頭函數(shù), lwip協(xié)議棧的設(shè)計(jì)與 實(shí)現(xiàn)文檔中是這么介紹的:應(yīng)用層調(diào)用 tcp_write()函數(shù)以實(shí)現(xiàn)發(fā)送數(shù)據(jù),接著 tcp_write()函數(shù)再將控制權(quán)交給tcp_enqueue(),這個(gè)函數(shù)會(huì)在必要時(shí)將數(shù)據(jù)分割為適當(dāng)大小的 TCP 段,然后再把這些 TCP 段放到所屬連接的傳輸隊(duì)列中【 pcbunsent】。 } } 這個(gè)函數(shù)確實(shí)夠簡單的了,檢查 pcb 狀態(tài),直接入隊(duì)列。 } return ERR_OK。 } return pcb。 pcbkeep_t = TCP_KEEPCNT_DEFAULT。 endif /* LWIP_CALLBACK_API */ /* Init KEEPALIVE timer */ pcbkeep_idle = TCP_KEEPIDLE_DEFAULT。 pcbpolltmr = 0。 pcbsnd_lbb = iss。 pcbsnd_max = iss。 pcbsnd_wl2 = iss。 pcbcwnd = 1。 pcbsv = 3000 / TCP_SLOW_INTERVAL。 pcbrto = 3000 / TCP_SLOW_INTERVAL。 pcbttl = TCP_TTL。 pcbrcv_ann_wnd = TCP_WND。//對(duì)的,別的可以先不管,這就是我們要找的東西 pcbsnd_queuelen = 0。 pcbprio = TCP_PRIO_NORMAL。 struct tcp_pcb * tcp_alloc(u8_t prio)//是的,你沒看錯(cuò),這個(gè)參數(shù) 是學(xué)名是叫優(yōu)先級(jí) { pcb = memp_malloc(MEMP_TCP_PCB)。tcp_bound_pcbs, pcb)。作用是是否有與目前 pcb 的 ipaddr相同的 pcb 存在。 }分別檢查了 3 個(gè) pcb鏈表,本來我不想把這個(gè)函數(shù)的實(shí)現(xiàn)列在這里的,但是這里告訴了我們一些東西,至少我們知道有 3 個(gè) pcb 的鏈表,分別是 tcp_active_pcbs【處于接受發(fā)送數(shù)據(jù)狀態(tài)的 pcbs】、 tcp_tw_pcbs【處于時(shí)間等待狀態(tài)的 pcbs】、 tcp_listen_pcbs【處于監(jiān)聽狀態(tài)的 pcbs】。 pcb = pcbnext) { if (pcblocal_port == port) { goto again。 } } for(pcb = (struct tcp_pcb *)。 pcb != NULL。 pcb = pcbnext) { if (pcblocal_port == port) { goto again。 } for(pcb = tcp_active_pcbs。 28 ifndef TCP_LOCAL_PORT_RANGE_START define TCP_LOCAL_PORT_RANGE_START 4096 define TCP_LOCAL_PORT_RANGE_END 0x7fff endif static u16_t port = TCP_LOCAL_PORT_RANGE_START。這個(gè)函數(shù)也比較有意思,在進(jìn)入正題之 前先來了下面這么個(gè)調(diào)用 if (port == 0) { port = tcp_new_port()。 } 也許注釋的意義更大一些吧,哈哈,至此,我們從注釋可以知道, tcp_bind 的作用是把 tcp 的pcb 放入 list 中,至少是某一個(gè) list 既然都提到了,似乎不說說有點(diǎn)過意不去啊。 * Creates a new TCP protocol control block but doesn39。 哈哈,還記得吧,在前面我討論到了這里,就沒有再討論了。 define tcp_sndbuf(pcb) ((pcb)snd_buf)//由下面分析得這里直接返回 buf 大小 那就繼續(xù)跟蹤這個(gè) pcb好了。 好,先看 tcp_sndbuf 這個(gè)。 err = tcp_output_nagle(conn)。 這個(gè)函數(shù)的最直接調(diào)用有以下幾個(gè): available = tcp_sndbuf(conn)。//指針 = size。 27 現(xiàn)在先從小部 :我們知道這里的函數(shù)都是被 socket 那一層的最終調(diào)用的。在 LWIP 中基本的 TCP 處理過程被分割為六個(gè)功能函數(shù)的實(shí)現(xiàn): tcp_input(), tcp_process(), tcp_receive()【與 TCP 輸入有關(guān)】 , tcp_write(), tcp_enqueue(), tcp_output()【用于 TCP 輸出】。關(guān)鍵在于 msg union的設(shè)計(jì)。 }。 } lb。 } jl。 struct ip_addr *interface。 } r。 } w。 int len。 } ad。 u16_t *port。 26 } bc。 /** used for do_bind and do_connect */ struct { struct ip_addr *ipaddr。 /** used for do_newconn */ struct { u8_t proto。下面看下這個(gè)牛結(jié)構(gòu)的定義: /** This struct includes everything that is necessary to execute a function for a conn in another thread context (mainly used to process conns in the tcpip_thread context to be thread safe). */ struct api_msg_msg { /** The conn which to process always needed: it includes the semaphore which is used to block the application thread until the function finished. */ struct conn *conn。可以借鑒 焦海波 大俠的關(guān)于 ucos上對(duì) lwip 的移植筆記來看。 typedef u8_t sys_prot_t?!?】 再看 sys_mbox_t 的定義,在【 src\include\lwip\】中 /* For a totally minimal and standalone system, we provide null definitions of the sys_ functions. */ typedef u8_t sys_sem_t。既然如此,就不得不說 mbox 及其相關(guān)函數(shù)了。 } 說明一下, api_msg結(jié)構(gòu)幾乎都是在 conn_xxx 函數(shù)中被調(diào)用,方式千篇一律,除了 ms 的賦值不一樣外。msg)。 25 = local。 = addr。 = do_getaddr。但是具體怎么個(gè)操作法還是不知道,沒關(guān)系,接著看它的調(diào)用。 }。先看下它的定義: /** This struct contains a function to execute in another thread context and a struct api_msg_msg that serves as an argument for this function. This is passed to tcpip_apimsg to execute functions in tcpip_thread context. */ struct api_msg { /** function to execute in tcpip_thread context */ void (* function)(struct api_msg_msg *msg)。 到此整個(gè) APP 層,也就是傳輸層以上對(duì) socket 的封裝讱完了。 } 對(duì)了, accept 函數(shù)中從 mbox 中獲叏的連接就是這里放迚去的。 return ERR_MEM。 if (sys_mbox_trypost(connacceptmbox, newconn) != ERR_OK) { /* When returning != ERR_OK, the connection is aborted in tcp_process(), so do nothing here! */ newconn = NULL。 newconnerr = err。 } newconn = newpcb。 /* We have to set the callback here even though * the new socket is unknown. connsocket is marked as 1. */ newconn = conn_alloc(conntype, conncallback)。 struct conn *conn。 tcp_accept(msgconn, accept_function)。那就再次打斷一下,看看那個(gè) listen 操作。通過 mbox 叏得新的連接。 嗯,還是回過頭來接著看 accept 函數(shù)吧。 我們知道在這里建立了這個(gè) tcp 的連接。 } setup_tcp(msgconn)。 if(msgconn == NULL) { msgconnerr = ERR_MEM。 } /* Else? This new connection already has a PCB allocated. */ /* Is this an error condition? Should it be deleted? */ /* We currently just are happy and return. */ TCPIP_APIMSG_ACK(msg)。這么來 說 apimsgfunction 的調(diào)用很重要
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評(píng)公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1