ackheader.hh

来自「COPE the first practical network coding 」· HH 代码 · 共 72 行

HH
72
字号
/* Header to ack encoded packet, implemented in the style of srcr packets */#ifndef CLICK_ENC_ACK_HH#define CLICK_ENC_ACK_HH#include <clicknet/ip.h>// packet formatCLICK_SIZE_PACKED_STRUCTURE(struct click_enc_ack {,  uint8_t    _nentries;              // length of this header in terms of number of ack entries  uint16_t _et_next;                  // Ethtype of the next packet    /* neighbour id */  /* highest magic_seq */  uint8_t    _nb;  uint16_t   _seq;  uint8_t _bmap;  // all methods below adapted from srpacket.hh  void set_entry(int entry_index, uint8_t nb_id, uint16_t seqno, uint8_t bmap) {    uint8_t *ndx = (uint8_t *) (this+1);    ndx += (entry_index - 1) * 4;    ndx[0] = nb_id;        uint16_t *seq = (uint16_t *)(ndx + 1);     seq[0] = htons(seqno);    ndx[3] = bmap;  }  uint8_t get_entry_nb(int entry_index) {    uint8_t *ndx = (uint8_t *) (this+1);    ndx += (entry_index - 1) * 4;    return ndx[0];  }  uint16_t get_entry_seq(int entry_index) {    uint8_t *ndx = (uint8_t *) (this+1);    ndx += (entry_index - 1) * 4;        uint16_t *seq = (uint16_t *)(ndx + 1);     return ntohs(seq[0]);  }  uint8_t get_entry_bmap(int entry_index) {    uint8_t *ndx = (uint8_t *) (this+1);    ndx += (entry_index - 1) * 4;    return ndx[3];  }  void set_nentries(int n) {    _nentries = n;  }  static size_t get_hlen(int nentries) {    return sizeof(struct click_enc_ack) + sizeof(uint8_t) * nentries + sizeof(uint16_t) * nentries + sizeof(uint8_t) * nentries - 4;  }  size_t nentries() {    return _nentries;  }});#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?