MCPcopy Create free account
hub / github.com/F-Stack/f-stack / table_rule_show

Function table_rule_show

dpdk/examples/ip_pipeline/cli.c:4728–5041  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4726}
4727
4728static int
4729table_rule_show(const char *pipeline_name,
4730 uint32_t table_id,
4731 const char *file_name)
4732{
4733 struct pipeline *p;
4734 struct table *table;
4735 struct table_rule *rule;
4736 FILE *f = NULL;
4737 uint32_t i;
4738
4739 /* Check input params. */
4740 if ((pipeline_name == NULL) ||
4741 (file_name == NULL))
4742 return -1;
4743
4744 p = pipeline_find(pipeline_name);
4745 if ((p == NULL) ||
4746 (table_id >= p->n_tables))
4747 return -1;
4748
4749 table = &p->table[table_id];
4750
4751 /* Open file. */
4752 f = fopen(file_name, "w");
4753 if (f == NULL)
4754 return -1;
4755
4756 /* Write table rules to file. */
4757 TAILQ_FOREACH(rule, &table->rules, node) {
4758 struct table_rule_match *m = &rule->match;
4759 struct table_rule_action *a = &rule->action;
4760
4761 fprintf(f, "match ");
4762 switch (m->match_type) {
4763 case TABLE_ACL:
4764 fprintf(f, "acl priority %u ",
4765 m->match.acl.priority);
4766
4767 fprintf(f, m->match.acl.ip_version ? "ipv4 " : "ipv6 ");
4768
4769 if (m->match.acl.ip_version)
4770 ipv4_addr_show(f, m->match.acl.ipv4.sa);
4771 else
4772 ipv6_addr_show(f, m->match.acl.ipv6.sa);
4773
4774 fprintf(f, "%u", m->match.acl.sa_depth);
4775
4776 if (m->match.acl.ip_version)
4777 ipv4_addr_show(f, m->match.acl.ipv4.da);
4778 else
4779 ipv6_addr_show(f, m->match.acl.ipv6.da);
4780
4781 fprintf(f, "%u", m->match.acl.da_depth);
4782
4783 fprintf(f, "%u %u %u %u %u ",
4784 (uint32_t)m->match.acl.sp0,
4785 (uint32_t)m->match.acl.sp1,

Callers 1

Calls 5

ipv4_addr_showFunction · 0.85
ipv6_addr_showFunction · 0.85
policer_action_stringFunction · 0.85
ether_addr_showFunction · 0.85
pipeline_findFunction · 0.70

Tested by

no test coverage detected