xref: /aosp_15_r20/external/iproute2/tipc/README (revision de1e4e894b0c224df933550f0afdecc354b238c4)
1*de1e4e89SAndroid Build Coastguard WorkerDESIGN DECISIONS
2*de1e4e89SAndroid Build Coastguard Worker----------------
3*de1e4e89SAndroid Build Coastguard Worker
4*de1e4e89SAndroid Build Coastguard WorkerHELP
5*de1e4e89SAndroid Build Coastguard Worker~~~~
6*de1e4e89SAndroid Build Coastguard Worker--help or -h is used for help. We do not reserve the bare word "help", which
7*de1e4e89SAndroid Build Coastguard Workerfor example the ip command does. Reserving a bare word like help quickly
8*de1e4e89SAndroid Build Coastguard Workerbecomes cumbersome to handle in the code. It might be simple to handle
9*de1e4e89SAndroid Build Coastguard Workerwhen it's passed early in the command chain like "ip addr help". But when
10*de1e4e89SAndroid Build Coastguard Workerthe user tries to pass "help" further down this requires manual checks and
11*de1e4e89SAndroid Build Coastguard Workerspecial treatment. For example, at the time of writing this tool, it's
12*de1e4e89SAndroid Build Coastguard Workerpossible to create a vlan named "help" with the ip tool, but it's impossible
13*de1e4e89SAndroid Build Coastguard Workerto remove it, the command just shows help. This is an effect of treating
14*de1e4e89SAndroid Build Coastguard Workerbare words specially.
15*de1e4e89SAndroid Build Coastguard Worker
16*de1e4e89SAndroid Build Coastguard WorkerHelp texts are not dynamically generated. That is, we do not pass datastructures
17*de1e4e89SAndroid Build Coastguard Workerlike command list or option lists and print them dynamically. This is
18*de1e4e89SAndroid Build Coastguard Workerintentional. There is always that exception and when it comes to help texts
19*de1e4e89SAndroid Build Coastguard Workerthese exceptions are normally neglected at the expence of usability.
20*de1e4e89SAndroid Build Coastguard Worker
21*de1e4e89SAndroid Build Coastguard WorkerKEY-VALUE
22*de1e4e89SAndroid Build Coastguard Worker~~~~~~~~~
23*de1e4e89SAndroid Build Coastguard WorkerAll options are key-values. There are both drawbacks and benefits to this.
24*de1e4e89SAndroid Build Coastguard WorkerThe main drawback is that it becomes more to write for the user and
25*de1e4e89SAndroid Build Coastguard Workerinformation might seem redundant. The main benefits is scalability and code
26*de1e4e89SAndroid Build Coastguard Workersimplification. Consistency is important.
27*de1e4e89SAndroid Build Coastguard Worker
28*de1e4e89SAndroid Build Coastguard WorkerConsider this.
29*de1e4e89SAndroid Build Coastguard Worker1. tipc link set priority PRIO link LINK
30*de1e4e89SAndroid Build Coastguard Worker2. tipc link set LINK priority PRIO
31*de1e4e89SAndroid Build Coastguard Worker
32*de1e4e89SAndroid Build Coastguard WorkerLink might seem redundant in (1). However, if the command should live for many
33*de1e4e89SAndroid Build Coastguard Workeryears and be able to evolve example (2) limits the set command to only work on a
34*de1e4e89SAndroid Build Coastguard Workersingle link with no ability to extend. As an example, lets say we introduce
35*de1e4e89SAndroid Build Coastguard Workergrouping on the kernel side.
36*de1e4e89SAndroid Build Coastguard Worker
37*de1e4e89SAndroid Build Coastguard Worker1. tipc link set priority PRIO group GROUP
38*de1e4e89SAndroid Build Coastguard Worker2. tipc link set ??? priority PRIO group GROUP
39*de1e4e89SAndroid Build Coastguard Worker
40*de1e4e89SAndroid Build Coastguard Worker2. breaks, we can't extend the command to cover a group.
41*de1e4e89SAndroid Build Coastguard Worker
42*de1e4e89SAndroid Build Coastguard WorkerPARSING
43*de1e4e89SAndroid Build Coastguard Worker~~~~~~~
44*de1e4e89SAndroid Build Coastguard WorkerCommands are single words. As an example, all words in "tipc link list" are
45*de1e4e89SAndroid Build Coastguard Workercommands. Options are key-values that can be given in any order. In
46*de1e4e89SAndroid Build Coastguard Worker"tipc link set priority PRIO link LINK" "tipc link set" are commands while
47*de1e4e89SAndroid Build Coastguard Workerpriority and link are options. Meaning that they can be given like
48*de1e4e89SAndroid Build Coastguard Worker"tipc link set link LINK priority PRIO".
49*de1e4e89SAndroid Build Coastguard Worker
50*de1e4e89SAndroid Build Coastguard WorkerAbbreviation matching works for both command and options. Meaning that
51*de1e4e89SAndroid Build Coastguard Worker"tipc link set priority PRIO link LINK" could be given as
52*de1e4e89SAndroid Build Coastguard Worker"tipc l s p PRIO l LINK" and "tipc link list" as "tipc l l".
53*de1e4e89SAndroid Build Coastguard Worker
54*de1e4e89SAndroid Build Coastguard WorkerMEMORY
55*de1e4e89SAndroid Build Coastguard Worker~~~~~~
56*de1e4e89SAndroid Build Coastguard WorkerThe tool strives to avoid allocating memory on the heap. Most (if not all)
57*de1e4e89SAndroid Build Coastguard Workermemory allocations are on the stack.
58*de1e4e89SAndroid Build Coastguard Worker
59*de1e4e89SAndroid Build Coastguard WorkerRETURNING
60*de1e4e89SAndroid Build Coastguard Worker~~~~~~~~~
61*de1e4e89SAndroid Build Coastguard WorkerThe tool could throw exit() deep down in functions but doing so always seems
62*de1e4e89SAndroid Build Coastguard Workerto limit the program in the long run. So we output the error and return an
63*de1e4e89SAndroid Build Coastguard Workerappropriate error code upon failure.
64