X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fstream.c;h=2ee5731eb23a79ea1b07d3e349bd0d7b6f435bbc;hb=e0d7fd09066712420ea076a8efb5559a3fe297b3;hp=2f418c42ae22b36f160ba0d59d2ded3ee246bc77;hpb=f125905cdd3dc0339ad968c0a70128807884b400;p=openvswitch diff --git a/lib/stream.c b/lib/stream.c index 2f418c42..2ee5731e 100644 --- a/lib/stream.c +++ b/lib/stream.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. + * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -489,6 +489,25 @@ pstream_verify_name(const char *name) return pstream_lookup_class(name, &class); } +/* Returns 1 if the stream or pstream specified by 'name' needs periodic probes + * to verify connectivity. For [p]streams which need probes, it can take a + * long time to notice the connection has been dropped. Returns 0 if the + * stream or pstream does not need probes, and -1 if 'name' is not valid. */ +int +stream_or_pstream_needs_probes(const char *name) +{ + const struct pstream_class *pclass; + const struct stream_class *class; + + if (!stream_lookup_class(name, &class)) { + return class->needs_probes; + } else if (!pstream_lookup_class(name, &pclass)) { + return pclass->needs_probes; + } else { + return -1; + } +} + /* Attempts to start listening for remote stream connections. 'name' is a * connection name in the form "TYPE:ARGS", where TYPE is an passive stream * class's name and ARGS are stream class-specific. @@ -594,6 +613,15 @@ pstream_wait(struct pstream *pstream) { (pstream->class->wait)(pstream); } + +int +pstream_set_dscp(struct pstream *pstream, uint8_t dscp) +{ + if (pstream->class->set_dscp) { + return pstream->class->set_dscp(pstream, dscp); + } + return 0; +} /* Initializes 'stream' as a new stream named 'name', implemented via 'class'. * The initial connection status, supplied as 'connect_status', is interpreted @@ -759,7 +787,7 @@ stream_guess_content(const uint8_t *data, ssize_t size) return STREAM_SSL; case PAIR('{', '"'): return STREAM_JSONRPC; - case PAIR(OFP10_VERSION, OFPT_HELLO): + case PAIR(OFP10_VERSION, 0 /* OFPT_HELLO */): return STREAM_OPENFLOW; } }