|
31 | 31 | } |
32 | 32 | [%- END -%] |
33 | 33 | [%- FOREACH struct IN apis.$api.structs %] |
34 | | - |
| 34 | + [%- NEXT IF struct.short_name == 'neighbor_entry' %] |
| 35 | + [%- NEXT IF struct.short_name == 'route_entry' %] |
35 | 36 |
|
36 | 37 | [%- PROCESS struct_helper_function_header %] { |
37 | 38 |
|
@@ -135,8 +136,57 @@ void sai_thrift_parse_[% struct.short_name %](const [% struct.thrift_name %] &th |
135 | 136 | [%- ######################################################################## -%] |
136 | 137 |
|
137 | 138 | [%- BLOCK special_helper_functions -%] |
| 139 | +extern sai_object_id_t gSwitchId; |
| 140 | +extern sai_object_id_t switch_id; |
| 141 | + |
138 | 142 | void sai_thrift_parse_buffer(const std::string &thrift_buffer, |
139 | 143 | void *buffer) { |
140 | 144 | /* not supported yet */ |
141 | 145 | } |
| 146 | + |
| 147 | +void sai_thrift_parse_neighbor_entry(const sai_thrift_neighbor_entry_t &thrift_neighbor_entry, |
| 148 | + sai_neighbor_entry_t *neighbor_entry) |
| 149 | +{ |
| 150 | + if (neighbor_entry == NULL) { |
| 151 | + return; |
| 152 | + } |
| 153 | + |
| 154 | + // OCP sai_test often omits switch_id on neighbor_entry; fall back to the |
| 155 | + // RPC-global switch_id (set by sai_thrift_create_switch) then gSwitchId. |
| 156 | + if (thrift_neighbor_entry.switch_id != 0) { |
| 157 | + neighbor_entry->switch_id = (sai_object_id_t)thrift_neighbor_entry.switch_id; |
| 158 | + } else if (switch_id != SAI_NULL_OBJECT_ID) { |
| 159 | + neighbor_entry->switch_id = switch_id; |
| 160 | + } else if (gSwitchId != SAI_NULL_OBJECT_ID) { |
| 161 | + neighbor_entry->switch_id = gSwitchId; |
| 162 | + } else { |
| 163 | + neighbor_entry->switch_id = SAI_NULL_OBJECT_ID; |
| 164 | + } |
| 165 | + |
| 166 | + neighbor_entry->rif_id = (sai_object_id_t)thrift_neighbor_entry.rif_id; |
| 167 | + sai_thrift_ip_address_t_parse(thrift_neighbor_entry.ip_address, |
| 168 | + &neighbor_entry->ip_address); |
| 169 | +} |
| 170 | + |
| 171 | +void sai_thrift_parse_route_entry(const sai_thrift_route_entry_t &thrift_route_entry, |
| 172 | + sai_route_entry_t *route_entry) |
| 173 | +{ |
| 174 | + if (route_entry == NULL) { |
| 175 | + return; |
| 176 | + } |
| 177 | + |
| 178 | + if (thrift_route_entry.switch_id != 0) { |
| 179 | + route_entry->switch_id = (sai_object_id_t)thrift_route_entry.switch_id; |
| 180 | + } else if (switch_id != SAI_NULL_OBJECT_ID) { |
| 181 | + route_entry->switch_id = switch_id; |
| 182 | + } else if (gSwitchId != SAI_NULL_OBJECT_ID) { |
| 183 | + route_entry->switch_id = gSwitchId; |
| 184 | + } else { |
| 185 | + route_entry->switch_id = SAI_NULL_OBJECT_ID; |
| 186 | + } |
| 187 | + |
| 188 | + route_entry->vr_id = (sai_object_id_t)thrift_route_entry.vr_id; |
| 189 | + sai_thrift_ip_prefix_t_parse(thrift_route_entry.destination, |
| 190 | + &route_entry->destination); |
| 191 | +} |
142 | 192 | [% END -%] |
0 commit comments