| 1008 | } |
| 1009 | |
| 1010 | uint32_t |
| 1011 | sctp_select_initial_TSN(struct sctp_pcb *inp) |
| 1012 | { |
| 1013 | /* |
| 1014 | * A true implementation should use random selection process to get |
| 1015 | * the initial stream sequence number, using RFC1750 as a good |
| 1016 | * guideline |
| 1017 | */ |
| 1018 | uint32_t x, *xp; |
| 1019 | uint8_t *p; |
| 1020 | int store_at, new_store; |
| 1021 | |
| 1022 | if (inp->initial_sequence_debug != 0) { |
| 1023 | uint32_t ret; |
| 1024 | |
| 1025 | ret = inp->initial_sequence_debug; |
| 1026 | inp->initial_sequence_debug++; |
| 1027 | return (ret); |
| 1028 | } |
| 1029 | retry: |
| 1030 | store_at = inp->store_at; |
| 1031 | new_store = store_at + sizeof(uint32_t); |
| 1032 | if (new_store >= (SCTP_SIGNATURE_SIZE - 3)) { |
| 1033 | new_store = 0; |
| 1034 | } |
| 1035 | if (!atomic_cmpset_int(&inp->store_at, store_at, new_store)) { |
| 1036 | goto retry; |
| 1037 | } |
| 1038 | if (new_store == 0) { |
| 1039 | /* Refill the random store */ |
| 1040 | sctp_fill_random_store(inp); |
| 1041 | } |
| 1042 | p = &inp->random_store[store_at]; |
| 1043 | xp = (uint32_t *)p; |
| 1044 | x = *xp; |
| 1045 | return (x); |
| 1046 | } |
| 1047 | |
| 1048 | uint32_t |
| 1049 | sctp_select_a_tag(struct sctp_inpcb *inp, uint16_t lport, uint16_t rport, int check) |
no test coverage detected