⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ack.h

📁 This a framework to test new ideas in transmission technology. Actual development is a LDPC-coder in
💻 H
字号:
#ifndef ACK_H__#define ACK_H__#define MAX_ACK 256#define IP_BUF_LEN 0x10000struct ack {  // The position in the ring-buffer  int pos;  // The length in bytes  int len;  // Where to find the next ack  int next;  // Age in number of slots passed, if < 0, this ack is unused  int age;};/** * @short initialise an acknowledge * * The first element of an acknowledge-array is used to do * some housekeeping. The len is the actual length, pos * is the next free ack and next is the next filled ack. * * @param a_ret where to store everything */void ack_init( struct ack **a_ret );/** * @short clean up an ack-list */void ack_free( struct ack **a_ret );/** * @short gets a free place * * Tries to find a free acknowledgement * * @return -1 for error else the index of the free place */int ack_get_free( struct ack *a );/** * @short insert a sorted acknowledge  * * Tries to insert an ack in the list in a sorted way. * The smallest elements come in first. */int ack_ins_sorted( struct ack *a, int pos, int len );/** * @short appends the ack to the end of the list */int ack_append( struct ack *a, int pos, int len );/** * @short join blocks * * This function first joins all loose blocks and then returns * the first ack * * @param a the ack-list * @return the first ack */struct ack *ack_join_blocks( struct ack *a );/* * @short cuts the first n bytes from the ack-list * * This is supposed to work on the rx-side of the RF, to * get one IP-packet. If the n-bytes correspond to exactly * the first packet, so it's size is only set to zero, w/o * removing it. * * @param a the ack-list * @param len the length of the packet to remove * @return index of where the first packet started, -1 on error */int ack_cut_begin( struct ack *a, int len );/** * @short delete the ack pos * * Searches for the ack with pos and deletes it * * @param a the ack-list * @param pos the position * @return 0 OK, -1 not found */int ack_delete( struct ack *a, int pos );/** * @short gets the first ack and deletes it *  * @param a the ack-list * @return the ack or NULL for error */struct ack *ack_get_first( struct ack *a );/** * @short returns the first ack *  * @param a the ack-list * @return the ack or NULL for error */struct ack *ack_read_first( struct ack *a );/** * @short make the acks older * * @param a the ack-list */void ack_make_older( struct ack *a );/** * @short returns an old ack * * Given an age, it returns the first ack found that has at * least this age, deletes it and returns a pointer. * If all acks are younger than the given age, NULL is returned. * * Care should be taken as the returned pointer may be re-used * on subsequent calls to ack_*. * * @param a the ack-list * @param age the maximal age * @return a pointer to an ack having at least this age or NULL */struct ack *ack_delete_old( struct ack *a, int age );#endif

⌨️ 快捷键说明

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