Skip to content

Commit a3e5431

Browse files
Removed ExaBGP powered Flow Spec implementation. We've decided to use only GoBGP for flow spec as it's only developer friendly option we have in place
1 parent 4a7ee74 commit a3e5431

2 files changed

Lines changed: 0 additions & 618 deletions

File tree

src/bgp_protocol.hpp

Lines changed: 0 additions & 319 deletions
Original file line numberDiff line numberDiff line change
@@ -211,324 +211,5 @@ class flow_spec_rule_t {
211211
bgp_flow_spec_action_t action;
212212
};
213213

214-
class exabgp_flow_spec_rule_t : public flow_spec_rule_t {
215-
public:
216-
exabgp_flow_spec_rule_t() {
217-
four_spaces = " ";
218-
sentence_separator = ";";
219-
220-
this->enabled_indents = true;
221-
this->enble_block_headers = true;
222-
}
223-
224-
void disable_indents() {
225-
enabled_indents = false;
226-
}
227-
228-
std::string serialize_source_ports() {
229-
std::ostringstream output_buffer;
230-
231-
output_buffer << "source-port [ " << serialize_vector_by_string_with_prefix<uint16_t>(this->source_ports, " ", "=")
232-
<< " ]" << sentence_separator;
233-
234-
return output_buffer.str();
235-
}
236-
237-
std::string serialize_destination_ports() {
238-
std::ostringstream output_buffer;
239-
240-
output_buffer << "destination-port [ "
241-
<< serialize_vector_by_string_with_prefix<uint16_t>(this->destination_ports, " ", "=") << " ]"
242-
<< sentence_separator;
243-
244-
return output_buffer.str();
245-
}
246-
247-
std::string serialize_packet_lengths() {
248-
std::ostringstream output_buffer;
249-
250-
output_buffer << "packet-length [ " << serialize_vector_by_string_with_prefix<uint16_t>(this->packet_lengths, " ", "=")
251-
<< " ]" << sentence_separator;
252-
253-
return output_buffer.str();
254-
}
255-
256-
257-
std::string serialize_protocols() {
258-
std::ostringstream output_buffer;
259-
260-
output_buffer << "protocol [ " << serialize_vector_by_string(this->protocols, " ") << " ]" << sentence_separator;
261-
262-
return output_buffer.str();
263-
}
264-
std::string serialize_fragmentation_flags() {
265-
std::ostringstream output_buffer;
266-
267-
output_buffer << "fragment [ " << serialize_vector_by_string(this->fragmentation_flags, " ") << " ]" << sentence_separator;
268-
269-
return output_buffer.str();
270-
}
271-
272-
std::string serialize_tcp_flags() {
273-
std::ostringstream output_buffer;
274-
275-
output_buffer << "tcp-flags [ " << serialize_vector_by_string(this->tcp_flags, " ") << " ]" << sentence_separator;
276-
277-
return output_buffer.str();
278-
}
279-
280-
std::string serialize_source_subnet() {
281-
return "source " + convert_subnet_to_string(this->source_subnet) + sentence_separator;
282-
}
283-
284-
std::string serialize_destination_subnet() {
285-
return "destination " + convert_subnet_to_string(this->destination_subnet) + sentence_separator;
286-
}
287-
288-
// More details regarding format: https://github.com/Exa-Networks/exabgp/blob/master/qa/conf/api-flow.run
289-
// https://plus.google.com/+ThomasMangin/posts/bL6w16BXcJ4
290-
// This format is INCOMPATIBLE with ExaBGP v3, please be careful!
291-
std::string serialize_single_line_exabgp_v4_configuration() {
292-
this->enabled_indents = false;
293-
this->enble_block_headers = false;
294-
sentence_separator = " ";
295-
296-
return "flow route " + this->serialize_match() + this->serialize_then();
297-
298-
sentence_separator = ";";
299-
this->enabled_indents = true;
300-
this->enble_block_headers = true;
301-
}
302-
303-
std::string serialize_complete_exabgp_configuration() {
304-
std::ostringstream buffer;
305-
306-
buffer << "neighbor 127.0.0.1 {"
307-
<< "\n"
308-
<< four_spaces << "router-id 1.2.3.4;"
309-
<< "\n"
310-
<< four_spaces << "local-address 127.0.0.1;"
311-
<< "\n"
312-
<< four_spaces << "local-as 1;"
313-
<< "\n"
314-
<< four_spaces << "peer-as 1;"
315-
<< "\n"
316-
<< four_spaces << "group-updates false;"
317-
<< "\n\n";
318-
319-
buffer << four_spaces << "family {"
320-
<< "\n"
321-
<< four_spaces << four_spaces << "ipv4 flow;"
322-
<< "\n"
323-
<< four_spaces << four_spaces << "ipv6 flow;"
324-
<< "\n"
325-
<< four_spaces << "}"
326-
<< "\n";
327-
328-
buffer << "flow {"
329-
<< "\n";
330-
buffer << this->serialize();
331-
buffer << "}"
332-
<< "\n";
333-
334-
buffer << "}"
335-
<< "\n";
336-
337-
return buffer.str();
338-
}
339-
340-
std::string serialize() {
341-
std::ostringstream buffer;
342-
343-
buffer << "route {";
344-
345-
if (enabled_indents) {
346-
buffer << "\n";
347-
}
348-
349-
buffer << this->serialize_match();
350-
buffer << this->serialize_then();
351-
352-
if (enabled_indents) {
353-
buffer << "\n";
354-
}
355-
356-
buffer << "}";
357-
358-
if (enabled_indents) {
359-
buffer << "\n";
360-
}
361-
362-
return buffer.str();
363-
}
364-
365-
std::string serialize_match() {
366-
std::ostringstream buffer;
367-
368-
if (enabled_indents) {
369-
buffer << four_spaces;
370-
}
371-
372-
if (enble_block_headers) {
373-
buffer << "match {";
374-
}
375-
376-
if (enabled_indents) {
377-
buffer << "\n";
378-
}
379-
380-
// Match block
381-
if (this->source_subnet_used) {
382-
if (enabled_indents) {
383-
buffer << four_spaces << four_spaces;
384-
}
385-
386-
buffer << serialize_source_subnet();
387-
388-
if (enabled_indents) {
389-
buffer << "\n";
390-
}
391-
}
392-
393-
if (this->destination_subnet_used) {
394-
if (enabled_indents) {
395-
buffer << four_spaces << four_spaces;
396-
}
397-
398-
buffer << serialize_destination_subnet();
399-
400-
if (enabled_indents) {
401-
buffer << "\n";
402-
}
403-
}
404-
405-
if (!this->protocols.empty()) {
406-
if (enabled_indents) {
407-
buffer << four_spaces << four_spaces;
408-
}
409-
410-
buffer << this->serialize_protocols();
411-
412-
if (enabled_indents) {
413-
buffer << "\n";
414-
}
415-
}
416-
417-
// If we have TCP in protocols list explicitly, we add flags
418-
if (find(this->protocols.begin(), this->protocols.end(), FLOW_SPEC_PROTOCOL_TCP) != this->protocols.end()) {
419-
420-
if (!this->tcp_flags.empty()) {
421-
if (enabled_indents) {
422-
buffer << four_spaces << four_spaces;
423-
}
424-
425-
buffer << this->serialize_tcp_flags();
426-
427-
if (enabled_indents) {
428-
buffer << "\n";
429-
}
430-
}
431-
}
432-
433-
if (!this->source_ports.empty()) {
434-
if (enabled_indents) {
435-
buffer << four_spaces << four_spaces;
436-
}
437-
438-
buffer << this->serialize_source_ports();
439-
440-
if (enabled_indents) {
441-
buffer << "\n";
442-
}
443-
}
444-
445-
if (!this->destination_ports.empty()) {
446-
if (enabled_indents) {
447-
buffer << four_spaces << four_spaces;
448-
}
449-
450-
buffer << this->serialize_destination_ports();
451-
452-
if (enabled_indents) {
453-
buffer << "\n";
454-
}
455-
}
456-
457-
if (!this->packet_lengths.empty()) {
458-
if (enabled_indents) {
459-
buffer << four_spaces << four_spaces;
460-
}
461-
462-
buffer << this->serialize_packet_lengths();
463-
464-
if (enabled_indents) {
465-
buffer << "\n";
466-
}
467-
}
468-
469-
if (!this->fragmentation_flags.empty()) {
470-
if (enabled_indents) {
471-
buffer << four_spaces << four_spaces;
472-
}
473-
474-
buffer << this->serialize_fragmentation_flags();
475-
476-
if (enabled_indents) {
477-
buffer << "\n";
478-
}
479-
}
480-
481-
// Match block end
482-
if (enabled_indents) {
483-
buffer << four_spaces;
484-
}
485-
486-
if (enble_block_headers) {
487-
buffer << "}";
488-
}
489-
490-
return buffer.str();
491-
}
492-
493-
std::string serialize_then() {
494-
std::ostringstream buffer;
495-
496-
if (enabled_indents) {
497-
buffer << "\n" << four_spaces;
498-
}
499-
500-
if (enble_block_headers) {
501-
buffer << "then {";
502-
}
503-
504-
if (enabled_indents) {
505-
buffer << "\n";
506-
buffer << four_spaces << four_spaces;
507-
}
508-
509-
// Set same sentence separator as in main class
510-
this->action.set_sentence_separator(this->sentence_separator);
511-
512-
buffer << this->action.serialize();
513-
514-
if (enabled_indents) {
515-
buffer << "\n";
516-
buffer << four_spaces;
517-
}
518-
519-
if (enble_block_headers) {
520-
buffer << "}";
521-
}
522-
523-
return buffer.str();
524-
}
525-
526-
private:
527-
std::string four_spaces;
528-
bool enabled_indents;
529-
bool enble_block_headers;
530-
std::string sentence_separator;
531-
};
532-
533214
bool read_bgp_community_from_string(std::string community_as_string, bgp_community_attribute_element_t& bgp_community_attribute_element);
534215
bool is_bgp_community_valid(std::string community_as_string);

0 commit comments

Comments
 (0)