Skip to content

Commit

Permalink
all: replace codeVersion with (git) revision
Browse files Browse the repository at this point in the history
  • Loading branch information
Axel Neumann committed Dec 18, 2012
1 parent 4d8a233 commit 7d31867
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# 02110-1301, USA



CFLAGS += -pedantic -Wall -W -Wno-unused-parameter -Os -g3 -std=gnu99 -I./
GIT_REV = $(shell [ -d .git ] && git --no-pager log -n 1 --oneline|cut -d " " -f 1 || echo 0)
CFLAGS += -pedantic -Wall -W -Wno-unused-parameter -Os -g3 -std=gnu99 -I./ -DGIT_REV=\"$(GIT_REV)\"
#-DHAVE_CONFIG_H

# optinal defines:
Expand Down
20 changes: 10 additions & 10 deletions bmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1256,8 +1256,8 @@ static void segmentation_fault(int32_t sig)
debug_function_calls();
#endif

dbg(DBGL_SYS, DBGT_ERR, "Terminating with error code %d (%s-%s-cv%d)! Please notify a developer",
sig, BMX_BRANCH, BRANCH_VERSION, CODE_VERSION);
dbg(DBGL_SYS, DBGT_ERR, "Terminating with error code %d (%s-%s-rev%s)! Please notify a developer",
sig, BMX_BRANCH, BRANCH_VERSION, GIT_REV);

if (initializing) {
dbg_sys(DBGT_ERR,
Expand Down Expand Up @@ -1767,8 +1767,8 @@ void register_status_handl(uint16_t min_msg_size, IDM_T multiline, const struct

struct bmx_status {
char version[(sizeof(BMX_BRANCH)-1) + (sizeof("-")-1) + (sizeof(BRANCH_VERSION)-1) + 1];
uint16_t compatibility;
uint16_t codeVersion;
uint16_t compat;
char* revision;
GLOBAL_ID_T *globalId;
IPX_T primaryIp;
struct net_key *tun6Address;
Expand All @@ -1781,8 +1781,8 @@ struct bmx_status {

static const struct field_format bmx_status_format[] = {
FIELD_FORMAT_INIT(FIELD_TYPE_STRING_CHAR, bmx_status, version, 1, FIELD_RELEVANCE_HIGH),
FIELD_FORMAT_INIT(FIELD_TYPE_UINT, bmx_status, compatibility, 1, FIELD_RELEVANCE_HIGH),
FIELD_FORMAT_INIT(FIELD_TYPE_UINT, bmx_status, codeVersion, 1, FIELD_RELEVANCE_HIGH),
FIELD_FORMAT_INIT(FIELD_TYPE_UINT, bmx_status, compat, 1, FIELD_RELEVANCE_HIGH),
FIELD_FORMAT_INIT(FIELD_TYPE_POINTER_CHAR, bmx_status, revision, 1, FIELD_RELEVANCE_HIGH),
FIELD_FORMAT_INIT(FIELD_TYPE_POINTER_GLOBAL_ID, bmx_status, globalId, 1, FIELD_RELEVANCE_HIGH),
FIELD_FORMAT_INIT(FIELD_TYPE_IPX, bmx_status, primaryIp, 1, FIELD_RELEVANCE_HIGH),
FIELD_FORMAT_INIT(FIELD_TYPE_NETP, bmx_status, tun6Address, 1, FIELD_RELEVANCE_HIGH),
Expand All @@ -1798,8 +1798,8 @@ static int32_t bmx_status_creator(struct status_handl *handl, void *data)
{
struct bmx_status *status = (struct bmx_status *) (handl->data = debugRealloc(handl->data, sizeof (struct bmx_status), -300365));
sprintf(status->version, "%s-%s", BMX_BRANCH, BRANCH_VERSION);
status->compatibility = COMPATIBILITY_VERSION;
status->codeVersion = CODE_VERSION;
status->compat = COMPATIBILITY_VERSION;
status->revision = GIT_REV;
status->globalId = &self->global_id;
status->primaryIp = self->primary_ip;
status->tun6Address = tun6_address.af ? &tun6_address : NULL;
Expand Down Expand Up @@ -2002,8 +2002,8 @@ int32_t opt_version(uint8_t cmd, uint8_t _save, struct opt_type *opt, struct opt

assertion(-501257, !strcmp(opt->name, ARG_VERSION));

dbg_printf(cn, "%s-%s compatibility=%d codeVersion=%d\n",
BMX_BRANCH, BRANCH_VERSION, COMPATIBILITY_VERSION, CODE_VERSION);
dbg_printf(cn, "%s-%s comPatibility=%d revision=%s\n",
BMX_BRANCH, BRANCH_VERSION, COMPATIBILITY_VERSION, GIT_REV);

if (initializing)
cleanup_all(CLEANUP_SUCCESS);
Expand Down
6 changes: 5 additions & 1 deletion bmx.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@
* dont touch this for compatibility reasons:
*/

#define CODE_VERSION 9 // to be incremented after each critical code change
#define BMX_BRANCH "BMX6"
#define BRANCH_VERSION "0.1-alpha" //put exactly one distinct word inside the string like "0.3-pre-alpha" or "0.3-rc1" or "0.3"

#define COMPATIBILITY_VERSION 16

#ifndef GIT_REV
#define GIT_REV "0" // to be incremented after each critical code change
#endif
extern uint32_t rev_u32;

/*
* from iid.h:
*/
Expand Down
1 change: 0 additions & 1 deletion dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,6 @@ struct plugin *dump_get_plugin( void ) {

dump_plugin.plugin_name = CODE_CATEGORY_NAME;
dump_plugin.plugin_size = sizeof ( struct plugin );
dump_plugin.plugin_code_version = CODE_VERSION;
dump_plugin.cb_init = init_dump;
dump_plugin.cb_cleanup = cleanup_dump;
dump_plugin.cb_plugin_handler[PLUGIN_CB_BMX_DEV_EVENT] = init_cleanup_dev_traffic_data;
Expand Down
1 change: 0 additions & 1 deletion hna.c
Original file line number Diff line number Diff line change
Expand Up @@ -2834,7 +2834,6 @@ struct plugin *hna_get_plugin( void ) {

hna_plugin.plugin_name = CODE_CATEGORY_NAME;
hna_plugin.plugin_size = sizeof ( struct plugin );
hna_plugin.plugin_code_version = CODE_VERSION;
hna_plugin.cb_init = hna_init;
hna_plugin.cb_cleanup = hna_cleanup;
hna_plugin.cb_plugin_handler[PLUGIN_CB_SYS_DEV_EVENT] = hna_dev_event_hook;
Expand Down
1 change: 0 additions & 1 deletion lib/bmx6_http_info/http_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ struct plugin* get_plugin( void ) {

http_info_plugin.plugin_name = "bmx6_http_info_plugin";
http_info_plugin.plugin_size = sizeof ( struct plugin );
http_info_plugin.plugin_code_version = CODE_VERSION;
http_info_plugin.cb_init = http_info_init;
http_info_plugin.cb_cleanup = http_info_cleanup;

Expand Down
1 change: 0 additions & 1 deletion lib/bmx6_json/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,6 @@ struct plugin* get_plugin( void ) {

json_plugin.plugin_name = CODE_CATEGORY_NAME;
json_plugin.plugin_size = sizeof ( struct plugin );
json_plugin.plugin_code_version = CODE_VERSION;
json_plugin.cb_init = json_init;
json_plugin.cb_cleanup = json_cleanup;
json_plugin.cb_plugin_handler[PLUGIN_CB_DESCRIPTION_CREATED] = (void (*) (int32_t, void*)) json_description_event_hook;
Expand Down
1 change: 0 additions & 1 deletion lib/bmx6_quagga/quagga.c
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,6 @@ struct plugin* get_plugin( void ) {

quagga_plugin.plugin_name = CODE_CATEGORY_NAME;
quagga_plugin.plugin_size = sizeof ( struct plugin );
quagga_plugin.plugin_code_version = CODE_VERSION;
quagga_plugin.cb_init = quagga_init;
quagga_plugin.cb_cleanup = quagga_cleanup;

Expand Down
1 change: 0 additions & 1 deletion lib/bmx6_sms/sms.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,6 @@ struct plugin* get_plugin( void ) {

sms_plugin.plugin_name = CODE_CATEGORY_NAME;
sms_plugin.plugin_size = sizeof ( struct plugin );
sms_plugin.plugin_code_version = CODE_VERSION;
sms_plugin.cb_init = sms_init;
sms_plugin.cb_cleanup = sms_cleanup;

Expand Down
1 change: 0 additions & 1 deletion lib/bmx6_uci_config/uci_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,6 @@ struct plugin* get_plugin( void ) {

conf_plugin.plugin_name = CODE_CATEGORY_NAME;
conf_plugin.plugin_size = sizeof ( struct plugin );
conf_plugin.plugin_code_version = CODE_VERSION;
conf_plugin.cb_init = init_conf;
conf_plugin.cb_cleanup = cleanup_conf;

Expand Down
1 change: 0 additions & 1 deletion metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -1621,7 +1621,6 @@ struct plugin *metrics_get_plugin( void ) {

metrics_plugin.plugin_name = CODE_CATEGORY_NAME;
metrics_plugin.plugin_size = sizeof ( struct plugin );
metrics_plugin.plugin_code_version = CODE_VERSION;
metrics_plugin.cb_init = init_metrics;
metrics_plugin.cb_cleanup = cleanup_metrics;

Expand Down
9 changes: 7 additions & 2 deletions msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -3510,7 +3510,13 @@ void update_my_description_adv(void)
dsc->ogmSqnRange = htons(self->ogmSqn_rangeSize);
dsc->txInterval = htons(my_tx_interval);

dsc->codeVersion = htons(CODE_VERSION);
uint32_t rev_u32;
char rev_string[5];
strncpy( rev_string, GIT_REV, sizeof(rev_string));
rev_string[sizeof(rev_string)-1] = 0;
sscanf(rev_string, "%X", &rev_u32);

dsc->revision = htons(rev_u32);
dsc->descSqn = htons(++(self->descSqn));
dsc->reservedTtl = my_ttl;

Expand Down Expand Up @@ -3899,7 +3905,6 @@ struct plugin *msg_get_plugin( void ) {

msg_plugin.plugin_name = CODE_CATEGORY_NAME;
msg_plugin.plugin_size = sizeof ( struct plugin );
msg_plugin.plugin_code_version = CODE_VERSION;
msg_plugin.cb_init = init_msg;
msg_plugin.cb_cleanup = cleanup_msg;

Expand Down
4 changes: 2 additions & 2 deletions msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ struct msg_dhash_adv { // 2 + X bytes
struct description { // 48 bytes
GLOBAL_ID_T globalId; // 32 bytes

uint16_t codeVersion; // 2 bytes
uint16_t revision; // 2 bytes //TODO: increase to 4 bytes
uint16_t capabilities;// 2 bytes

DESC_SQN_T descSqn; // 2 bytes
Expand Down Expand Up @@ -607,7 +607,7 @@ struct msg_description_adv { // IPv6: >= 92 bytes
#define DESCRIPTION_MSG_FORMAT { \
{FIELD_TYPE_UINT, -1, (8*sizeof(IID_T)), 0, FIELD_RELEVANCE_MEDI, "transmitterIid4x"}, \
{FIELD_TYPE_GLOBAL_ID, -1, (8*sizeof(GLOBAL_ID_T)), 1, FIELD_RELEVANCE_HIGH, "globalId"}, \
{FIELD_TYPE_UINT, -1, 16, 0, FIELD_RELEVANCE_MEDI, "codeVersion" }, \
{FIELD_TYPE_HEX, -1, 16, 0, FIELD_RELEVANCE_MEDI, "revision" }, \
{FIELD_TYPE_HEX, -1, 16, 0, FIELD_RELEVANCE_MEDI, "capabilities" }, \
{FIELD_TYPE_UINT, -1, 16, 0, FIELD_RELEVANCE_MEDI, "descSqn" }, \
{FIELD_TYPE_UINT, -1, (8*sizeof(OGM_SQN_T)), 0, FIELD_RELEVANCE_MEDI, "ogmSqnMin" }, \
Expand Down
6 changes: 3 additions & 3 deletions plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@ int activate_plugin(struct plugin *p, void *dlhandle, const char *dl_name)
return FAILURE;


if (p->plugin_size != sizeof ( struct plugin) || (p->plugin_code_version != CODE_VERSION)) {
if (p->plugin_size != sizeof ( struct plugin)) {

dbgf_sys(DBGT_ERR,
"plugin with unexpected size %d != %zu, revision %d != %d",
p->plugin_size, sizeof ( struct plugin), p->plugin_code_version, CODE_VERSION);
"plugin with unexpected size %d != %zu, revision=%s",
p->plugin_size, sizeof ( struct plugin), GIT_REV);

return FAILURE;
}
Expand Down
1 change: 0 additions & 1 deletion plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ void cb_packet_hooks(struct packet_buff *pb);
// for initializing:

struct plugin {
uint32_t plugin_code_version;
uint32_t plugin_size;
char *plugin_name;
int32_t (*cb_init) ( void );
Expand Down

0 comments on commit 7d31867

Please sign in to comment.