Date: Mon, 20 Aug 2007 13:43:54 GMT From: Matus Harvan <mharvan@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 125408 for review Message-ID: <200708201343.l7KDhsVm083156@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 */ }; /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708201343.l7KDhsVm083156>