Skip to content

Commit

Permalink
Create hooks.c
Browse files Browse the repository at this point in the history
  • Loading branch information
azeria-labs authored Mar 20, 2020
1 parent 070c287 commit efed1c5
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions hooks.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
Hooks for emulating Tenda routers. This has only been tested on two different Tenda versions: AC6 and AC15.
Cross-compile for the Arm architecture and copy it into the squashfs-root folder.
*/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <dlfcn.h>
#include <string.h>

int j_get_cfm_blk_size_from_cache(const int i)
{
puts("j_get_cfm_blk_size_from_cache called....\n");
return 0x20000;
}

int get_flash_type()
{
puts("get_flash_type called....\n");
return 4;
}

int load_l7setting_file()
{
puts("load_l7setting_file called....\n");
return 1;
}

int restore_power(int a, int b)
{
puts("restore_power called....\n");
return 0;
}

char *bcm_nvram_get(char *key)
{
char *value = NULL;

if(strcmp(key, "et0macaddr") == 0)
{
value = strdup("DE:AD:BE:EF:CA:FE");
}

if(strcmp(key, "sb/1/macaddr") == 0)
{
value = strdup("DE:AD:BE:EF:CA:FD");
}

if(strcmp(key, "default_nvram") == 0)
{
value = strdup("default_nvram");
}

printf("bcm_nvram_get(%s) == %s\n", key, value);

return value;
}

0 comments on commit efed1c5

Please sign in to comment.