diff --git a/Makefile b/Makefile index 4f185f4..72648d6 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/bmx.c b/bmx.c index cdd8d45..954dfb5 100644 --- a/bmx.c +++ b/bmx.c @@ -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, @@ -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; @@ -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), @@ -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; @@ -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); diff --git a/bmx.h b/bmx.h index 55c2d41..e3eda69 100644 --- a/bmx.h +++ b/bmx.h @@ -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: */ diff --git a/dump.c b/dump.c index 920fabf..129f02e 100644 --- a/dump.c +++ b/dump.c @@ -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; diff --git a/hna.c b/hna.c index 626da71..cf6b121 100644 --- a/hna.c +++ b/hna.c @@ -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; diff --git a/lib/bmx6_http_info/http_info.c b/lib/bmx6_http_info/http_info.c index 6a18eeb..54e376c 100644 --- a/lib/bmx6_http_info/http_info.c +++ b/lib/bmx6_http_info/http_info.c @@ -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; diff --git a/lib/bmx6_json/json.c b/lib/bmx6_json/json.c index 5037f85..5979a3e 100644 --- a/lib/bmx6_json/json.c +++ b/lib/bmx6_json/json.c @@ -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; diff --git a/lib/bmx6_quagga/quagga.c b/lib/bmx6_quagga/quagga.c index a38493b..02cc1a6 100644 --- a/lib/bmx6_quagga/quagga.c +++ b/lib/bmx6_quagga/quagga.c @@ -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; diff --git a/lib/bmx6_sms/sms.c b/lib/bmx6_sms/sms.c index 326cf28..082b2b6 100644 --- a/lib/bmx6_sms/sms.c +++ b/lib/bmx6_sms/sms.c @@ -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; diff --git a/lib/bmx6_uci_config/uci_config.c b/lib/bmx6_uci_config/uci_config.c index f3a42b9..132ea35 100644 --- a/lib/bmx6_uci_config/uci_config.c +++ b/lib/bmx6_uci_config/uci_config.c @@ -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; diff --git a/metrics.c b/metrics.c index 15fca98..8a7f5b5 100644 --- a/metrics.c +++ b/metrics.c @@ -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; diff --git a/msg.c b/msg.c index d433374..60cf67f 100644 --- a/msg.c +++ b/msg.c @@ -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; @@ -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; diff --git a/msg.h b/msg.h index 774fd08..2f11e98 100644 --- a/msg.h +++ b/msg.h @@ -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 @@ -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" }, \ diff --git a/plugin.c b/plugin.c index 4a42434..0f177f2 100644 --- a/plugin.c +++ b/plugin.c @@ -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; } diff --git a/plugin.h b/plugin.h index 1490adc..63016a1 100644 --- a/plugin.h +++ b/plugin.h @@ -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 );