3 * Copyright (C) 2020 Hiroki Shirokura, LINE Corporation
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 const char *seg6local_action2str(uint32_t action
)
26 case ZEBRA_SEG6_LOCAL_ACTION_END
:
28 case ZEBRA_SEG6_LOCAL_ACTION_END_X
:
30 case ZEBRA_SEG6_LOCAL_ACTION_END_T
:
32 case ZEBRA_SEG6_LOCAL_ACTION_END_DX2
:
34 case ZEBRA_SEG6_LOCAL_ACTION_END_DX6
:
36 case ZEBRA_SEG6_LOCAL_ACTION_END_DX4
:
38 case ZEBRA_SEG6_LOCAL_ACTION_END_DT6
:
40 case ZEBRA_SEG6_LOCAL_ACTION_END_DT4
:
42 case ZEBRA_SEG6_LOCAL_ACTION_END_B6
:
44 case ZEBRA_SEG6_LOCAL_ACTION_END_B6_ENCAP
:
45 return "End.B6.Encap";
46 case ZEBRA_SEG6_LOCAL_ACTION_END_BM
:
48 case ZEBRA_SEG6_LOCAL_ACTION_END_S
:
50 case ZEBRA_SEG6_LOCAL_ACTION_END_AS
:
52 case ZEBRA_SEG6_LOCAL_ACTION_END_AM
:
54 case ZEBRA_SEG6_LOCAL_ACTION_UNSPEC
:
61 int snprintf_seg6_segs(char *str
,
62 size_t size
, const struct seg6_segs
*segs
)
65 for (size_t i
= 0; i
< segs
->num_segs
; i
++) {
66 char addr
[INET6_ADDRSTRLEN
];
67 bool not_last
= (i
+ 1) < segs
->num_segs
;
69 inet_ntop(AF_INET6
, &segs
->segs
[i
], addr
, sizeof(addr
));
70 strlcat(str
, addr
, size
);
71 strlcat(str
, not_last
? "," : "", size
);
76 const char *seg6local_context2str(char *str
, size_t size
,
77 struct seg6local_context
*ctx
, uint32_t action
)
83 case ZEBRA_SEG6_LOCAL_ACTION_END
:
84 snprintf(str
, size
, "USP");
87 case ZEBRA_SEG6_LOCAL_ACTION_END_X
:
88 case ZEBRA_SEG6_LOCAL_ACTION_END_DX6
:
89 inet_ntop(AF_INET6
, &ctx
->nh6
, b0
, 128);
90 snprintf(str
, size
, "nh6 %s", b0
);
93 case ZEBRA_SEG6_LOCAL_ACTION_END_DX4
:
94 inet_ntop(AF_INET
, &ctx
->nh4
, b0
, 128);
95 snprintf(str
, size
, "nh4 %s", b0
);
98 case ZEBRA_SEG6_LOCAL_ACTION_END_T
:
99 case ZEBRA_SEG6_LOCAL_ACTION_END_DT6
:
100 case ZEBRA_SEG6_LOCAL_ACTION_END_DT4
:
101 snprintf(str
, size
, "table %u", ctx
->table
);
104 case ZEBRA_SEG6_LOCAL_ACTION_END_DX2
:
105 case ZEBRA_SEG6_LOCAL_ACTION_END_B6
:
106 case ZEBRA_SEG6_LOCAL_ACTION_END_B6_ENCAP
:
107 case ZEBRA_SEG6_LOCAL_ACTION_END_BM
:
108 case ZEBRA_SEG6_LOCAL_ACTION_END_S
:
109 case ZEBRA_SEG6_LOCAL_ACTION_END_AS
:
110 case ZEBRA_SEG6_LOCAL_ACTION_END_AM
:
111 case ZEBRA_SEG6_LOCAL_ACTION_UNSPEC
:
113 snprintf(str
, size
, "unknown(%s)", __func__
);