MTS: only used in this file buffer a packet (maintain order!)
| 1854 | // MTS: only used in this file |
| 1855 | // buffer a packet (maintain order!) |
| 1856 | void nw_psnet_buffer_packet(uint8_t *data, int length, network_address *from) { |
| 1857 | int idx; |
| 1858 | int found_buf = 0; |
| 1859 | |
| 1860 | // find the first empty packet |
| 1861 | for (idx = 0; idx < MAX_PACKET_BUFFERS; idx++) { |
| 1862 | if (Psnet_buffers[idx].sequence_number == -1) { |
| 1863 | found_buf = 1; |
| 1864 | break; |
| 1865 | } |
| 1866 | } |
| 1867 | |
| 1868 | // if we didn't find the buffer, report an overrun |
| 1869 | if (!found_buf) { |
| 1870 | mprintf(0, "WARNING - Buffer overrun in psnet\n"); |
| 1871 | } else { |
| 1872 | // copy in the data |
| 1873 | memcpy(Psnet_buffers[idx].data, data, length); |
| 1874 | Psnet_buffers[idx].len = length; |
| 1875 | memcpy(&Psnet_buffers[idx].from_addr, from, sizeof(network_address)); |
| 1876 | Psnet_buffers[idx].sequence_number = Psnet_seq_number; |
| 1877 | |
| 1878 | // keep track of the highest id# |
| 1879 | Psnet_highest_id = Psnet_seq_number++; |
| 1880 | |
| 1881 | // set the lowest id# for the first time |
| 1882 | if (Psnet_lowest_id == -1) { |
| 1883 | Psnet_lowest_id = Psnet_highest_id; |
| 1884 | } |
| 1885 | } |
| 1886 | } |
| 1887 | |
| 1888 | // MTS: only used in this file |
| 1889 | // get the index of the next packet in order! |
no outgoing calls
no test coverage detected