Date: Wed, 10 Jun 2015 21:03:51 GMT From: roam@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286926 - soc2015/roam/ng_ayiya Message-ID: <201506102103.t5AL3pho006621@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: roam Date: Wed Jun 10 21:03:50 2015 New Revision: 286926 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286926 Log: Add the "secrethash" control message. ObQuote: "I've known a secret for a week or two" Modified: soc2015/roam/ng_ayiya/Makefile soc2015/roam/ng_ayiya/ng_ayiya.c soc2015/roam/ng_ayiya/ng_ayiya.h soc2015/roam/ng_ayiya/scaffold.pl Modified: soc2015/roam/ng_ayiya/Makefile ============================================================================== --- soc2015/roam/ng_ayiya/Makefile Wed Jun 10 21:03:46 2015 (r286925) +++ soc2015/roam/ng_ayiya/Makefile Wed Jun 10 21:03:50 2015 (r286926) @@ -50,6 +50,6 @@ @printf "\n\n======================\n\nPlease create the tic-tunnels.txt with the output of the sixxs-tic-tunnels tool\n\n======================\n\n" false -tic: tic-tunnels.txt +tic: tic-tunnels.txt up ${SCAFFOLD} inet6 ${TIC_TUNNEL} ${SCAFFOLD} ayiya Modified: soc2015/roam/ng_ayiya/ng_ayiya.c ============================================================================== --- soc2015/roam/ng_ayiya/ng_ayiya.c Wed Jun 10 21:03:46 2015 (r286925) +++ soc2015/roam/ng_ayiya/ng_ayiya.c Wed Jun 10 21:03:50 2015 (r286926) @@ -32,6 +32,7 @@ #include <sys/mbuf.h> #include <sys/sbuf.h> #include <netgraph/ng_message.h> +#include <netgraph/ng_parse.h> #include <netgraph/netgraph.h> #include "ng_ayiya.h" @@ -48,6 +49,24 @@ static ng_disconnect_t ng_ayiya_disconnect; static ng_shutdown_t ng_ayiya_shutdown; +static ng_parse_array_getLength_t ng_ayiya_secrethash_getLength; + +static const struct ng_parse_type ng_ayiya_secrethash_type = { + &ng_parse_bytearray_type, + &ng_ayiya_secrethash_getLength, +}; + +static const struct ng_cmdlist ng_ayiya_cmds[] = { + { + NGM_AYIYA_COOKIE, + NGM_AYIYA_SECRETHASH, + "secrethash", + &ng_ayiya_secrethash_type, + NULL, + }, + { 0 } +}; + static struct ng_type typestruct = { .version = NG_ABI_VERSION, .name = NG_AYIYA_NODE_TYPE, @@ -57,6 +76,7 @@ .newhook = ng_ayiya_newhook, .disconnect = ng_ayiya_disconnect, .shutdown = ng_ayiya_shutdown, + .cmdlist = ng_ayiya_cmds, }; NETGRAPH_INIT(ayiya, &typestruct); @@ -80,7 +100,7 @@ struct ng_ayiya_private { node_p node; - char * secrethash; + u_char secrethash[16]; hook_p hooks[AYIYA_HOOK_LAST]; }; typedef struct ng_ayiya_private *priv_p; @@ -196,6 +216,26 @@ } break; + case NGM_AYIYA_COOKIE: + switch (msg->header.cmd) { + case NGM_AYIYA_SECRETHASH: + { + const priv_p priv = NG_NODE_PRIVATE(node); + if (msg->header.arglen != sizeof(priv->secrethash)) { + error = EINVAL; + break; + } + bcopy(msg->data, priv->secrethash, + sizeof(priv->secrethash)); + } + break; + + default: + error = EINVAL; + break; + } + break; + default: error = EINVAL; break; @@ -259,3 +299,10 @@ NG_NODE_UNREF(node); return (0); } + +static int +ng_ayiya_secrethash_getLength(const struct ng_parse_type * const type, + const u_char * const start, const u_char * const buf) +{ + return (sizeof(((const priv_p)NULL)->secrethash)); +} Modified: soc2015/roam/ng_ayiya/ng_ayiya.h ============================================================================== --- soc2015/roam/ng_ayiya/ng_ayiya.h Wed Jun 10 21:03:46 2015 (r286925) +++ soc2015/roam/ng_ayiya/ng_ayiya.h Wed Jun 10 21:03:50 2015 (r286926) @@ -31,4 +31,8 @@ #define NG_AYIYA_NODE_TYPE "ayiya" #define NGM_AYIYA_COOKIE 1432823247 +enum { + NGM_AYIYA_SECRETHASH = 1, +}; + #endif Modified: soc2015/roam/ng_ayiya/scaffold.pl ============================================================================== --- soc2015/roam/ng_ayiya/scaffold.pl Wed Jun 10 21:03:46 2015 (r286925) +++ soc2015/roam/ng_ayiya/scaffold.pl Wed Jun 10 21:03:50 2015 (r286926) @@ -179,6 +179,18 @@ # TODO: config, status, hooks, interfaces } +sub shutdown_node($) +{ + my ($node) = @_; + my $i6 = $node->{config}->{hooks}->{inet6}; + + if (defined $i6) { + ngctl 'shutdown', "[$i6->{id}]:"; + } + ngctl 'shutdown', "[$node->{id}]:"; + # TODO: the ksocket one, too +} + sub cmd_shutdown($ @) { my ($cmd, @args) = @_; @@ -194,7 +206,7 @@ my $ay = get_ayiya; if ($ay->{ours}) { debug "Shutting down our node $ay->{ours}->{id}"; - ngctl 'shutdown', "[$ay->{ours}->{id}]:"; + shutdown_node $ay->{ours}; } else { say "Our node not found"; } @@ -203,7 +215,7 @@ " other node(s)"; for (@{$ay->{others}}) { debug "- $_->{id}"; - ngctl 'shutdown', "[$_->{id}]:"; + shutdown_node $_; } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201506102103.t5AL3pho006621>