~glyph/enie

093e6eb63ecae255398956dae8e84c64200aa6f5 — mycognosist 1 year, 6 months ago b54d879
Refactor status codes and messages, fix RUNNING bug
3 files changed, 19 insertions(+), 16 deletions(-)

M README.md
M enie.c
A enie.jpg
M README.md => README.md +10 -8
@@ 21,18 21,20 @@ Events are prefixed by an integer denoting event type and followed by the interf
States:

```
 0 - UP
 1 - DOWN
 2 - IP_ADD
 3 - IP_DEL
 0 - UP_CONNECTED
 1 - UP_DISCONNECTED
 2 - DOWN
 3 - IP_ASSIGNED
 4 - IP_DELETED
```

Examples:

`0_wlan0_UP_RUNNING` or `0_wlan0_UP_NOT_RUNNING`  
`1_wlan0`  
`2_wlan0_192.168.1.12`  
`3_wlan0`
`0_wlan0_UP_CONNECTED`  
`1_wlan0_UP_DISCONNECTED`  
`2_wlan0_DOWN`  
`3_wlan0_IP_ASSIGNED_192.168.1.12`  
`4_wlan0_IP_DELETED`

### Rationale


M enie.c => enie.c +9 -8
@@ 170,22 170,23 @@ int main(int argc, char *argv[])
                // match on the receive message type & take action
                switch (h->nlmsg_type) {
                    case RTM_DELADDR:
                        fprintf(stdout, "3_%s\n", ifName);
                        fflush(stdout);
                        break;

                    case RTM_DELLINK:
                        fprintf(stdout, "1_%s\n", ifName);
                        fprintf(stdout, "4_%s_%s\n", ifName, "IP_DELETED");
                        fflush(stdout);
                        break;

                    case RTM_NEWLINK:
                        fprintf(stdout, "0_%s_%s_%s\n", ifName, ifUpp, ifRunn);
                        if (strcmp(ifUpp, "DOWN") == 0) {
                            fprintf(stdout, "2_%s_%s\n", ifName, "DOWN");
                        } else if (strcmp(ifRunn, "RUNNING") == 0){
                            fprintf(stdout, "0_%s_%s_%s\n", ifName, ifUpp, "CONNECTED");
                        } else {
                            fprintf(stdout, "1_%s_%s_%s\n", ifName, ifUpp, "DISCONNECTED");
                        }
                        fflush(stdout);
                        break;

                    case RTM_NEWADDR:
                        fprintf(stdout, "2_%s_%s\n", ifName, ifAddress);
                        fprintf(stdout, "3_%s_%s_%s\n", ifName, "IP_ASSIGNED", ifAddress);
                        fflush(stdout);
                        break;
                }

A enie.jpg => enie.jpg +0 -0