From owner-p4-projects@FreeBSD.ORG Mon Aug 20 13:43:55 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E5A4716A468; Mon, 20 Aug 2007 13:43:54 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A18F916A419 for ; Mon, 20 Aug 2007 13:43:54 +0000 (UTC) (envelope-from mharvan@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 90A7C13C45D for ; Mon, 20 Aug 2007 13:43:54 +0000 (UTC) (envelope-from mharvan@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l7KDhsLV083159 for ; Mon, 20 Aug 2007 13:43:54 GMT (envelope-from mharvan@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l7KDhsVm083156 for perforce@freebsd.org; Mon, 20 Aug 2007 13:43:54 GMT (envelope-from mharvan@FreeBSD.org) Date: Mon, 20 Aug 2007 13:43:54 GMT Message-Id: <200708201343.l7KDhsVm083156@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to mharvan@FreeBSD.org using -f From: Matus Harvan To: Perforce Change Reviews Cc: Subject: PERFORCE change 125408 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Aug 2007 13:43:55 -0000 http://perforce.freebsd.org/chv.cgi?CH=125408 Change 125408 by mharvan@mharvan_bike-planet on 2007/08/20 13:43:46 added DISPATCH_PLUGIN_SELECT dispatch to explicitly notify the server of plugin failover Affected files ... .. //depot/projects/soc2007/mharvan-mtund/mtund.src/mtund.c#10 edit .. //depot/projects/soc2007/mharvan-mtund/mtund.src/mtund.h#5 edit Differences ... ==== //depot/projects/soc2007/mharvan-mtund/mtund.src/mtund.c#10 (text+ko) ==== @@ -105,6 +105,7 @@ static int send_next_frag(); static void cleanup(); +static void send_plugin_select(struct client *cl); /* GLOBAL VARIABLES */ int server = 0; /* are we a server or a client? */ @@ -201,6 +202,9 @@ cl->ping_counter = 0; if (pl != NULL && cl->tun_fd != -1) { + if (!server) /* client */ + send_plugin_select(cl); + if (cl->pl->is_ready_to_send(cl->pl, cl->clid) == WILL_SEND_IMMEDIATELY) event_add(&cl->tun_ev, NULL); @@ -423,6 +427,36 @@ } /* + * send a message to the server notifying it of plugin failover + */ +static void +send_plugin_select(struct client *cl) +{ + int nwrite = 0; + char data[10]; + char *datap = data; + int len=0; + int consumed; + + + if (cl->pl != NULL) { + /* client prepends the client ID */ + if (!server) { + *datap = cl->clid; + datap++; + len++; + } + + *datap = DISPATCH_PLUGIN_SELECT; + datap++; + len++; + + nwrite = cl->pl->send(cl->pl, cl->clid, + data, len, NORMAL_DATA, &consumed); + printf("send_plugin_select(): nwrite: 0x%x\n", nwrite); + } +} +/* * Send a tunnel probe - echo request. Note that this is different * from ICMP echo. */ @@ -617,6 +651,23 @@ break; + case DISPATCH_PLUGIN_SELECT: + printf("process_data_from_plugin(): PLUGIN_SELECT\n"); + /* only associated clients can send DATA to the server */ + if (server && *clid == 0) { + *conn_flag = CONN_DISCARD; + pl->conn_map(pl, *clid, *conn_flag); + return; + } + + *conn_flag = CONN_PERM; + pl->conn_map(pl, *clid, CONN_PERM); + + /* update the current plugin for this client */ + set_client_pl(cl, pl); + + break; + case DISPATCH_FRAG: /* fragment reassembly */ pl->conn_map(pl, *clid, CONN_PERM); @@ -1203,8 +1254,10 @@ signal(SIGTERM, sigcb); /* load the plugins */ -/* pl = load_plugin("./plugin_udp.so"); */ -/* pl->name = "udp_1234"; */ + pl = load_plugin("./plugin_udp.so"); + pl->name = "udp_1234"; + pl = load_plugin("./plugin_udp.so"); + pl->name = "udp_1235"; /* if (server) { */ /* pl = load_plugin("./plugin_udp_catchall.so"); */ /* pl->name = "udp_catchall"; */ @@ -1212,10 +1265,10 @@ /* pl = load_plugin("./plugin_udp.so"); */ /* pl->name = "udp_53"; */ /* } */ -/* pl = load_plugin("./plugin_tcp.so"); */ -/* pl->name = "tcp_1234"; */ -/* pl = load_plugin("./plugin_icmp.so"); */ -/* pl->name = "icmp"; */ + pl = load_plugin("./plugin_tcp.so"); + pl->name = "tcp_1234"; + pl = load_plugin("./plugin_icmp.so"); + pl->name = "icmp"; pl = load_plugin("./plugin_dns/plugin_dns.so"); pl->name = "dns_53"; ==== //depot/projects/soc2007/mharvan-mtund/mtund.src/mtund.h#5 (text+ko) ==== @@ -79,16 +79,14 @@ /* dispatch type - prepended before the payload */ enum { - DISPATCH_ECHO_REQUEST = 1, - DISPATCH_ECHO_REPLY = 2, - DISPATCH_FRAG = 3, + DISPATCH_ECHO_REQUEST, + DISPATCH_ECHO_REPLY, + DISPATCH_PLUGIN_SELECT, + DISPATCH_FRAG, DISPATCH_ID_REQUEST, /* client requesting an ID */ DISPATCH_ID_OFFER, /* daemon offering an ID to the client */ - //DISPATCH_ID_CANCEL, /* client ending a session */ DISPATCH_PLUGIN_DATA, /* plugin to plugin communication */ DISPATCH_DATA = 0x42, - DIPATCH_PLUGIN_RESERVED_MIN = 128, /* dispatch values used by plugins, */ - DIPATCH_PLUGIN_RESERVED_MAX = 255, /* i.e., not passed to the daemon */ }; /*