]>
git.proxmox.com Git - mirror_frr.git/blob - lib/iso.c
2 * ISO Network functions - iso_net.c
4 * Author: Olivier Dugeon <olivier.dugeon@orange.com>
6 * Copyright (C) 2023 Orange http://www.orange.com
8 * This file is part of Free Range Routing (FRR).
10 * FRR is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2, or (at your option) any
15 * FRR is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; see the file COPYING; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
39 * Print ISO System ID as 0000.0000.0000
42 * @param Print argument
43 * @param Pointer to the System ID to be printed
45 * @return Number of printed characters
47 printfrr_ext_autoreg_p("SY", printfrr_iso_sysid
);
48 static ssize_t
printfrr_iso_sysid(struct fbuf
*buf
, struct printfrr_eargs
*ea
,
51 const uint8_t *id
= vptr
;
54 return bputs(buf
, "(null)");
56 return bprintfrr(buf
, "%02x%02x.%02x%02x.%02x%02x",
57 id
[0], id
[1], id
[2], id
[3], id
[4], id
[5]);
61 * Print ISO Pseudo Node system ID as 0000.0000.0000.00
64 * @param Print argument
65 * @param Pointer to the System ID to be printed
67 * @return Number of printed characters
69 printfrr_ext_autoreg_p("PN", printfrr_iso_pseudo
);
70 static ssize_t
printfrr_iso_pseudo(struct fbuf
*buf
, struct printfrr_eargs
*ea
,
73 const uint8_t *id
= vptr
;
76 return bputs(buf
, "(null)");
78 return bprintfrr(buf
, "%02x%02x.%02x%02x.%02x%02x.%02x",
79 id
[0], id
[1], id
[2], id
[3], id
[4], id
[5], id
[6]);
83 * Print ISO LSP Fragment System ID as 0000.0000.0000.00-00
86 * @param Print argument
87 * @param Pointer to the System ID to be printed
89 * @return Number of printed characters
91 printfrr_ext_autoreg_p("LS", printfrr_iso_frag_id
);
92 static ssize_t
printfrr_iso_frag_id(struct fbuf
*buf
, struct printfrr_eargs
*ea
,
95 const uint8_t *id
= vptr
;
98 return bputs(buf
, "(null)");
100 return bprintfrr(buf
, "%02x%02x.%02x%02x.%02x%02x.%02x-%02x",
101 id
[0], id
[1], id
[2], id
[3], id
[4], id
[5], id
[6],
106 * Print ISO Network address as 00.0000.0000.0000 ... with the System ID
107 * as 0000.0000.0000.00 when long 'l' option is added to '%pIS'
109 * @param Print buffer
110 * @param Print argument
111 * @param Pointer to the ISO Network address
113 * @return Number of printed characters
115 printfrr_ext_autoreg_p("IS", printfrr_iso_addr
);
116 static ssize_t
printfrr_iso_addr(struct fbuf
*buf
, struct printfrr_eargs
*ea
,
119 const struct iso_address
*ia
= vptr
;
124 if (ea
->fmt
[0] == 'l') {
125 len
= 7; /* ISO SYSTEM ID + 1 */
130 return bputs(buf
, "(null)");
134 /* No dot for odd index and at the end of address */
135 if ((i
& 1) || (i
== (len
- 1)))
136 ret
+= bprintfrr(buf
, "%02x", ia
->area_addr
[i
]);
138 ret
+= bprintfrr(buf
, "%02x.", ia
->area_addr
[i
]);