aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2009-12-30 09:31:31 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2009-12-30 09:32:05 +0100
commitf7dbd589abdf321c9535d2bafa5b084474e83d4f (patch)
tree89f2acddb72383c2b9b84ae37bc2453e8c0d8e92
parent7992867f4b54dc99d5dbf0e03226ca844a6dc550 (diff)
[ipaccess] Remove some code duplication in the recently added firmware flashing.
Share the creation of the sw_load.
-rw-r--r--openbsc/src/ipaccess/ipaccess-config.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/openbsc/src/ipaccess/ipaccess-config.c b/openbsc/src/ipaccess/ipaccess-config.c
index 432179eb5..ceac7bdf4 100644
--- a/openbsc/src/ipaccess/ipaccess-config.c
+++ b/openbsc/src/ipaccess/ipaccess-config.c
@@ -411,6 +411,21 @@ int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj,
return 0;
}
+static struct sw_load *create_swload(struct sdp_header *header)
+{
+ struct sw_load *load;
+
+ load = talloc_zero(tall_ctx_config, struct sw_load);
+
+ strncpy((char *)load->file_id, header->firmware_info.sw_part, 20);
+ load->file_id_len = strlen(header->firmware_info.sw_part) + 1;
+
+ strncpy((char *)load->file_version, header->firmware_info.version, 20);
+ load->file_version_len = strlen(header->firmware_info.version) + 1;
+
+ return load;
+}
+
static void find_sw_load_params(const char *filename)
{
struct stat stat;
@@ -443,21 +458,9 @@ static void find_sw_load_params(const char *filename)
/* try to find what we are looking for */
llist_for_each_entry(header, entry, entry) {
if (ntohs(header->firmware_info.more_more_magic) == 0x1000) {
- sw_load1 = talloc_zero(tall_ctx_config, struct sw_load);
-
- strncpy((char *)sw_load1->file_id, header->firmware_info.sw_part, 20);
- sw_load1->file_id_len = strlen(header->firmware_info.sw_part) + 1;
-
- strncpy((char *)sw_load1->file_version, header->firmware_info.version, 20);
- sw_load1->file_version_len = strlen(header->firmware_info.version) + 1;
+ sw_load1 = create_swload(header);
} else if (ntohs(header->firmware_info.more_more_magic) == 0x2001) {
- sw_load2 = talloc_zero(tall_ctx_config, struct sw_load);
-
- strncpy((char *)sw_load2->file_id, header->firmware_info.sw_part, 20);
- sw_load2->file_id_len = strlen(header->firmware_info.sw_part) + 1;
-
- strncpy((char *)sw_load2->file_version, header->firmware_info.version, 20);
- sw_load2->file_version_len = strlen(header->firmware_info.version) + 1;
+ sw_load2 = create_swload(header);
}
}