From owner-svn-soc-all@FreeBSD.ORG Wed Jun 10 21:03:53 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 40617D50 for ; Wed, 10 Jun 2015 21:03:53 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2EB8910D6 for ; Wed, 10 Jun 2015 21:03:53 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5AL3rgt006721 for ; Wed, 10 Jun 2015 21:03:53 GMT (envelope-from roam@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t5AL3pho006621 for svn-soc-all@FreeBSD.org; Wed, 10 Jun 2015 21:03:51 GMT (envelope-from roam@FreeBSD.org) Date: Wed, 10 Jun 2015 21:03:51 GMT Message-Id: <201506102103.t5AL3pho006621@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to roam@FreeBSD.org using -f From: roam@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286926 - soc2015/roam/ng_ayiya MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jun 2015 21:03:53 -0000 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 #include #include +#include #include #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 $_; } }