aboutgitcodelistschat:MatrixIRC
path: root/demo/routes.hjson
blob: 55340012da60ce2a23ead8ea41f2a71bfbc9d83f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
[
  {
    "match": [
      /* Is somebody trying to create a route? Hang on... */
      { "sendmsg": { "fd": { "set": "fd" },
                     "msg": { "iov": { "set": "buf", "value": { "netlink": { "type": "newroute", "flags": { "all": [ "create", "request" ] } } } } } }
      }
    ],
    "call": [
      /* Create a new socket, owned by us */
      { "socket": { "family": "netlink", "type": "raw", "flags": "nonblock", "protocol": "nl_route" }, "ret": "new_fd" },

      /* Bind it for netlink usage */
      { "bind": { "fd": { "get": "new_fd" }, "addr": { "family": "netlink", "pid": 0, "groups": 0 } }, "ret": "y" },

      /* And re-send the original message */
      { "sendmsg": { "fd": { "get": "new_fd" }, "msg": { "name": { "family": "netlink", "pid": 0, "groups": 0 }, "iovlen": 1, "iov": { "get": "buf" } }, "flags": 0 }, "ret": "n" }
    ],
    /* Then, sneak our socket back into the calling process */
    "fd": { "src": { "get": "fd" }, "new": { "set": "new_fd" }, "close_on_exec": false },

    /* And report success, or failure */
    "return": { "value": "n", "error": "n" }
  },
  {
    /* FIXME: Unblock subsequent recvmsg(). To keep this clean, we should proxy
     * it ourselves.
     */
    "match": [
      { "recvmsg": { "fd": 4 /* TODO: get *our* new number */ } }
    ],
    "return": { "value": 0, "error": 0 }
  }
]