From owner-freebsd-net Sat Jan 30 13:29:40 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id NAA16523 for freebsd-net-outgoing; Sat, 30 Jan 1999 13:29:40 -0800 (PST) (envelope-from owner-freebsd-net@FreeBSD.ORG) Received: from whistle.com (s205m131.whistle.com [207.76.205.131]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id NAA16516 for ; Sat, 30 Jan 1999 13:29:39 -0800 (PST) (envelope-from archie@whistle.com) Received: (from smap@localhost) by whistle.com (8.7.5/8.6.12) id NAA09270; Sat, 30 Jan 1999 13:22:00 -0800 (PST) Received: from bubba.whistle.com( 207.76.205.7) by whistle.com via smap (V2.0) id xma009268; Sat, 30 Jan 99 13:21:39 -0800 Received: (from archie@localhost) by bubba.whistle.com (8.8.7/8.6.12) id NAA10729; Sat, 30 Jan 1999 13:21:39 -0800 (PST) From: Archie Cobbs Message-Id: <199901302121.NAA10729@bubba.whistle.com> Subject: Re: netgraph... In-Reply-To: <11086.917730231@critter.freebsd.dk> from Poul-Henning Kamp at "Jan 30, 99 10:03:51 pm" To: phk@critter.freebsd.dk (Poul-Henning Kamp) Date: Sat, 30 Jan 1999 13:21:39 -0800 (PST) Cc: julian@whistle.com, net@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL38 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Poul-Henning Kamp writes: > Yeah, I saw it, and I'm convince that no matter how smart we do it, > it will end up being almost enough, and take up just as much space > to code. That's what I said too. Also, why invent a new language for specifying the translation? That's another step away from KISS. Anyway, I think we almost all agree :-) See how this sounds. We add three new control messages: NGM_ASCII_CTRL_MSG NGM_ENCODE_ASCII NGM_DECODE_ASCII NGM_ASCII_CTRL_MSG takes an ASCII formatted control message as argument. The node parses it and takes the corresponding action. NGM_ENCODE_ASCII and NGM_DECODE_ASCII convert between ASCII and binary formats for a control message. It is completely up to the node how it wants to implement this stuff, but it could look something like this.. static struct ng_mesg *my_private_decoder(const char *string); static char *my_private_encoder(const struct ng_mesg *msg); int my_rcv_ctrl_msg_method(node_p here, struct ng_mesg *msg, .... ) { ... case NGM_ASCII_CTRL_MSG: struct ng_mesg *binary_msg = my_private_decoder(msg->data); error = my_rcv_ctrl_msg_method(here, binary_msg, ... ) break; case NGM_DECODE_ASCII: struct ng_mesg *binary_msg = my_private_decoder(string); NG_MKRESPONSE(resp, ... ) bcopy(resp->data, binary_msg, msglen); break; case NGM_ENCODE_ASCII: char *ascii; ascii = my_private_encoder((struct ng_mesg *) msg->data); NG_MKRESPONSE(resp, ... ) bcopy(resp->data, ascii, strlen(ascii) + 1); break; ... } Now notice, if we exported my_private_decoder() and my_private_encoder() as normal node methods, then the NGM_ASCII_CTRL_MSG case could be completely handled by the generic code, and individual nodes would not even have to directly handle it. I think this would be the simplest way to do it.. thoughts? -Archie ___________________________________________________________________________ Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message