diff options
Diffstat (limited to 'ipoe-util/ipses-create.c')
-rw-r--r-- | ipoe-util/ipses-create.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/ipoe-util/ipses-create.c b/ipoe-util/ipses-create.c index 5aaf1ab7..4c02cc67 100644 --- a/ipoe-util/ipses-create.c +++ b/ipoe-util/ipses-create.c @@ -1,4 +1,6 @@ +#include <net/ethernet.h> #include <netinet/in.h> +#include <netinet/ether.h> #include <arpa/inet.h> #include <string.h> #include <errno.h> @@ -22,14 +24,20 @@ int main(int argc, char **argv) int family; in_addr_t local, remote; int err; + union { + struct ether_addr a; + uint64_t u64; + } hwaddr; - if (argc != 4) { - printf("usage: ipses-create <ifname> <peer_addr> <addr>\n"); + if (argc != 4 && argc != 5) { + printf("usage: ipses-create <ifname> <hwaddr> <peer_addr> <addr>\n"); return 1; } - local = inet_addr(argv[2]); - remote = inet_addr(argv[3]); + ether_aton_r(argv[2], &hwaddr.a); + local = inet_addr(argv[3]); + if (argc == 5) + remote = inet_addr(argv[4]); #if LIBNL2 h = nl_socket_alloc(); @@ -42,8 +50,10 @@ int main(int argc, char **argv) msg = nlmsg_alloc(); genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, family, 0, NLM_F_REQUEST, IPOE_CMD_CREATE, IPOE_GENL_VERSION); nla_put_u32(msg, IPOE_ATTR_PEER_ADDR, local); - nla_put_u32(msg, IPOE_ATTR_ADDR, remote); nla_put_string(msg, IPOE_ATTR_IFNAME, argv[1]); + nla_put_u64(msg, IPOE_ATTR_HWADDR, hwaddr.u64); + if (argc == 5) + nla_put_u32(msg, IPOE_ATTR_ADDR, remote); nl_send_auto_complete(h, msg); err = nl_recvmsgs_default(h); |