X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fstp.c;h=0b32cb5b601f959532a4ce0cd29aad18bcdce255;hb=015cf2977473aa16fae4a14cddb6fe3d92694b08;hp=06ac0019bfa807f78d3978589edbffe95f9ddfdc;hpb=634408e0c5e9d99b55c40ab4df608f822ef923a7;p=sliver-openvswitch.git diff --git a/lib/stp.c b/lib/stp.c index 06ac0019b..0b32cb5b6 100644 --- a/lib/stp.c +++ b/lib/stp.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. @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include "byte-order.h" @@ -40,11 +39,12 @@ VLOG_DEFINE_THIS_MODULE(stp); #define STP_TYPE_CONFIG 0x00 #define STP_TYPE_TCN 0x80 +OVS_PACKED( struct stp_bpdu_header { ovs_be16 protocol_id; /* STP_PROTOCOL_ID. */ uint8_t protocol_version; /* STP_PROTOCOL_VERSION. */ uint8_t bpdu_type; /* One of STP_TYPE_*. */ -} __attribute__((packed)); +}); BUILD_ASSERT_DECL(sizeof(struct stp_bpdu_header) == 4); enum stp_config_bpdu_flags { @@ -52,6 +52,7 @@ enum stp_config_bpdu_flags { STP_CONFIG_TOPOLOGY_CHANGE = 0x01 }; +OVS_PACKED( struct stp_config_bpdu { struct stp_bpdu_header header; /* Type STP_TYPE_CONFIG. */ uint8_t flags; /* STP_CONFIG_* flags. */ @@ -63,12 +64,13 @@ struct stp_config_bpdu { ovs_be16 max_age; /* 8.5.1.6: Timeout for received data. */ ovs_be16 hello_time; /* 8.5.1.7: Time between BPDU generation. */ ovs_be16 forward_delay; /* 8.5.1.8: State progression delay. */ -} __attribute__((packed)); +}); BUILD_ASSERT_DECL(sizeof(struct stp_config_bpdu) == 35); +OVS_PACKED( struct stp_tcn_bpdu { struct stp_bpdu_header header; /* Type STP_TYPE_TCN. */ -} __attribute__((packed)); +}); BUILD_ASSERT_DECL(sizeof(struct stp_tcn_bpdu) == 4); struct stp_timer { @@ -151,7 +153,7 @@ stp_next_enabled_port(const struct stp *stp, const struct stp_port *port) { for (; port < &stp->ports[ARRAY_SIZE(stp->ports)]; port++) { if (port->state != STP_DISABLED) { - return (struct stp_port *) port; + return CONST_CAST(struct stp_port *, port); } } return NULL; @@ -481,7 +483,7 @@ stp_check_and_reset_fdb_flush(struct stp *stp) struct stp_port * stp_get_port(struct stp *stp, int port_no) { - assert(port_no >= 0 && port_no < ARRAY_SIZE(stp->ports)); + ovs_assert(port_no >= 0 && port_no < ARRAY_SIZE(stp->ports)); return &stp->ports[port_no]; } @@ -669,7 +671,7 @@ int stp_port_no(const struct stp_port *p) { struct stp *stp = p->stp; - assert(p >= stp->ports && p < &stp->ports[ARRAY_SIZE(stp->ports)]); + ovs_assert(p >= stp->ports && p < &stp->ports[ARRAY_SIZE(stp->ports)]); return p - stp->ports; } @@ -1228,7 +1230,7 @@ stp_hold_timer_expiry(struct stp_port *p) static void stp_initialize_port(struct stp_port *p, enum stp_state state) { - assert(state & (STP_DISABLED | STP_BLOCKING)); + ovs_assert(state & (STP_DISABLED | STP_BLOCKING)); stp_become_designated_port(p); stp_set_port_state(p, state); p->topology_change_ack = false; @@ -1371,7 +1373,7 @@ stp_unixctl_tcn(struct unixctl_conn *conn, int argc, struct stp *stp = stp_find(argv[1]); if (!stp) { - unixctl_command_reply(conn, 501, "no such stp object"); + unixctl_command_reply_error(conn, "no such stp object"); return; } stp_topology_change_detection(stp); @@ -1383,5 +1385,5 @@ stp_unixctl_tcn(struct unixctl_conn *conn, int argc, } } - unixctl_command_reply(conn, 200, "OK"); + unixctl_command_reply(conn, "OK"); }