LINE Notify 割韭菜了.
只好拿稍微麻煩一點的 pushbullet 來用.
產生 token:
登入 pushbullet 主頁.
在帳號的設定頁面建立 token.
請牢記你的 token, 保管好並且不要洩漏.
https://github.com/aimwang https://gitlab.com/aimwang
LINE Notify 割韭菜了.
只好拿稍微麻煩一點的 pushbullet 來用.
產生 token:
登入 pushbullet 主頁.
1 2 3 4 5 6 7 8 | #include <stdint.h> static uint8_t is_little_endian(void) { uint16_t value = 0x0001; uint8_t *byte_ptr = (uint8_t *)&value; return (*byte_ptr == 0x01); // If the system is little endian, the least significant byte is 0x01. } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | static int my_dirname(char *path) { char *p = strrchr(path, '/'); if (p == NULL || p == path) { return -1; } *p = '\0'; return 0; } static int my_mkdir(char *path) { struct stat st; char p[128]; char l[128]; mkdir(path, 0775); while ((stat(path, &st) != 0)) { memset(p, 0, 128); memcpy(p, path, strlen(path)); if (0 != my_dirname(p)) { return (-1); } while ((stat(p, &st) != 0)) { memset(l, 0, 128); memcpy(l, p, strlen(p)); // save the last not exist parent path. if (0 != my_dirname(p)) { return (-1); } } mkdir(l, 0775); if (stat(l, &st) != 0) { return (-1); } mkdir(path, 0775); } return (0); } |
netem relies on kernel module:
CONFIG_IFB
CONFIG_NET_SCHED
CONFIG_NET_SCH_NETEM.
tc qdisc add dev br-lan root handle 1: htb
tc class add dev br-lan parent 1: classid 1:1 htb rate 1000mbit
tc qdisc add dev br-lan parent 1:1 netem delay 100ms 10ms
tc filter add dev br-lan parent 1:0 protocol ip u32 match ip sport 5101 0xffff flowid 1:1
tc class add dev br-lan parent 1: classid 1:2 htb rate 1000mbit
tc qdisc add dev br-lan parent 1:2 netem loss 0% duplicate 0% delay 30ms 20ms
tc filter add dev br-lan parent 1:0 protocol ip u32 match ip sport 5001 0xffff flowid 1:2
Convert between hex string and byte array.
以空間換取時間, 盡量減少計算跟比較.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | static uint8_t HEX_VALUE[256] = { // x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, // 3x 0,10,11,12,13,14,15, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 4x 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 5x 0,10,11,12,13,14,15, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 6x 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 7x 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // Fx }; static uint8_t HEX_CHAR[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; void bytes2hex(uint8_t* src, char* dest, uint8_t srcsize) { uint8_t flag; uint8_t pos; flag = 0; pos = 0; while (srcsize--) { |