Porting OpenWrt-nvram to Mac OS X
甚麼是NVRAM?
NVRAM 全名是 Non-Volatile Ram ,在 OpenWrt 裡是用了 Flash Rom 最後的 64K 區塊,用來儲存一些環境參數,OpenWrt 通過這些參數來設定網路,DHCP,DNS和記載硬體版本等。
常用的 nvram 指令有以下 4 種:
1. nvram show:列出 NVRAM 內所有參數,我們亦可以用 grep 命令來抽取部份資訊,
例如下列命令列出了所 有用關鍵字' lan_' 開頭的參數,結果如下:
$ nvram show | grep lan_ vlan_port_vid_0= vlan_port_vid_1= vlan_src_type_0=ip vlan_port_vid_2= vlan_src_type_1=ip vlan_port_vid_3= vlan_src_type_2=ip vlan_src_type_3=ip vlan_src_type_4=ip vlan_src_type_5=ip vlan_src_type_6=ip vlan_src_type_7=ip vlan_src_type_8=ip vlan_src_type_9=ip vlan_wan_port_prio= vlan_protocol_srcip_0= vlan_protocol_srcip_1= vlan_protocol_srcip_2= vlan_protocol_srcip_3= vlan_protocol_srcip_4= vlan_protocol_srcip_5= vlan_protocol_srcip_6= vlan_protocol_srcip_7= vlan_protocol_srcip_8= vlan_wan_port_vid= vlan_protocol_srcip_9= lan_proto=dhcp vlan_protocol_prio_0= vlan_protocol_prio_1= vlan_protocolbase_Enabled=0 vlan_protocol_prio_2= vlan_protocol_prio_3= vlan_protocol_prio_4= vlan_protocol_prio_5= vlan_protocol_prio_6= vlan_protocol_prio_7= vlan_protocol_prio_8= vlan_protocol_vid_0= vlan_protocol_prio_9= vlan_protocol_vid_1= vlan_protocol_vid_2= vlan_protocol_vid_3= vlan_protocol_vid_4= vlan_protocol_vid_5= vlan_protocol_vid_6= vlan_protocol_vid_7= vlan_protocol_vid_8= vlan_protocol_vid_9= lan_ifname=eth1 dhcp_vlan_id0= dhcp_vlan_id1= default_lan_netmask_br=255.255.255.0 default_lan_ipaddr_br=192.168.1.1 dhcp_vlan_id2= lan_netmask=255.255.255.0 lan_ipaddr=192.168.1.1 dhcp_vlan_id3= lan_hwaddr=00:11:22:33:44:55 vlan_port_prio_0= vlan_port_prio_1= vlan_portbase_Enabled=0 vlan_port_prio_2= vlan_port_prio_3=
2. nvram set 參數=數值:用來新增或修改一些參數,例如我想把 LAN 的 IP 改為 192.168.1.168,可執行此命令。
$ nvram set lan_ipaddr=192.168.1.2 $ nvram commit
第 1 行是修改 IP 地址,第 2 行使變更後的結果,儲存到nvram記憶體區塊或檔案裡。
3. nvram unset 參數:用來刪除參數。
例如刪除 “vlan_wan_port_prio” 這個參數,請執行:
$ nvram unset vlan_wan_port_prio
4. nvram commit 參數:當你對 NVRAM 做了一大堆修改後,你需要把這些修改儲存起來,否則路由器或閘道器 reboot 後,這些修改便會消失。
$ nvram commit
由於 Mac OS X 本身就有 'nvram' 這個命令,為避免混淆,在編譯產生執行檔前,會自動判斷更名為 'xnvram'。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# configure.ac # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. dnl AC_PREREQ(2.61) AC_INIT([nvram/nvram nvram/include/bcmnvram.h],[v1.0],[Jackie.CPlusPlus@gmail.com]) AM_INIT_AUTOMAKE(nvram, v1.0) AC_CONFIG_SRCDIR([config.h.in]) AC_CONFIG_HEADER([config.h]) dnl LT_INIT([dlopen]) dnl ----------------------------------------------- dnl Package name and version number (user defined) dnl ----------------------------------------------- GENERIC_LIBRARY_NAME=nvram #release versioning GENERIC_MAJOR_VERSION=1 GENERIC_MINOR_VERSION=0 GENERIC_MICRO_VERSION=0 #API version (often = GENERIC_MAJOR_VERSION.GENERIC_MINOR_VERSION) GENERIC_API_VERSION=1.0 AC_SUBST(GENERIC_API_VERSION) #shared library versioning GENERIC_LIBRARY_VERSION=1:2:0 # | | | # +------+ | +---+ # | | | # current:revision:age # | | | # | | +- increment if interfaces have been added # | | set to zero if interfaces have been removed # or changed # | +- increment if source code has changed # | set to zero if current is incremented # +- increment if interfaces have been added, removed or changed dnl -------------------------------- dnl Package name and version number dnl -------------------------------- AC_SUBST(GENERIC_LIBRARY_VERSION) PACKAGE=$GENERIC_LIBRARY_NAME AC_SUBST(GENERIC_LIBRARY_NAME) GENERIC_VERSION=$GENERIC_MAJOR_VERSION.$GENERIC_MINOR_VERSION.$GENERIC_MICRO_VERSION GENERIC_RELEASE=$GENERIC_MAJOR_VERSION.$GENERIC_MINOR_VERSION AC_SUBST(GENERIC_RELEASE) AC_SUBST(GENERIC_VERSION) VERSION=$GENERIC_VERSION AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define) AC_PREREQ dnl AC_REQUIRE_AUX_FILE([ltmain.sh]) # Checks for programs. AC_LANG_CPLUSPLUS AC_PROG_AWK AC_PROG_CC AC_PROG_CPP AC_PROG_CXX AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET AC_PROG_RANLIB AM_PROG_CC_C_O AM_PROG_LIBTOOL AM_SANITY_CHECK # #DX_HTML_FEATURE(ON) #DX_CHM_FEATURE(OFF) #DX_CHI_FEATURE(OFF) #DX_MAN_FEATURE(OFF) #DX_RTF_FEATURE(OFF) #DX_XML_FEATURE(OFF) #DX_PDF_FEATURE(ON) #DX_PS_FEATURE(ON) # #DX_INIT_DOXYGEN($PACKAGE_NAME, doxygen.cfg) # AM_INIT_AUTOMAKE # Checks for libraries. # Checks for header files. AC_HEADER_STDC AC_FUNC_ALLOCA AC_HEADER_STDC #AC_CHECK_HEADERS([fcntl.h limits.h malloc.h stddef.h stdlib.h string.h unistd.h]) AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netinet/in.h stdlib.h string.h sys/file.h sys/ioctl.h sys/socket.h sys/time.h termios.h unistd.h]) # Checks for command line options AC_ARG_ENABLE([async-exec], [AS_HELP_STRING([--disable-async-exec], [disable asynchronous execution @<:@default: no@:>@])], [async_exec=${enableval}], [async_exec=yes]) if test "x${async_exec}" = xyes; then have_pthreads=no AC_SEARCH_LIBS([pthread_create], [pthread], [have_pthreads=yes]) if test "x${have_pthreads}" = xyes; then AC_CHECK_HEADERS([pthread.h], [], [have_pthreads=no]) fi if test "x${have_pthreads}" = xno; then echo "---------------------------------------" echo "Unable to find pthreads on this system." echo "Building a single-threaded version. " echo "---------------------------------------" async_exec=no fi fi if test "x${async_exec}" = xyes; then AC_DEFINE([ASYNC_EXEC], 1, [async exec enabled]) fi # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_INT32_T AC_TYPE_PID_T AC_TYPE_MODE_T AC_TYPE_SIZE_T AC_TYPE_SSIZE_T AC_TYPE_UINT64_T AC_C_VOLATILE AC_CHECK_TYPES([ptrdiff_t]) AC_HEADER_STDBOOL AC_C_INLINE #AC_C_CONST # Checks for library functions. AC_FUNC_FORK AC_FUNC_MALLOC AC_FUNC_REALLOC AC_FUNC_STRTOD AC_CHECK_FUNCS([alarm bzero dup2 inet_ntoa memset mkdir select setenv socket strchr strcspn strncasecmp strcasecmp strspn strtol strtoul sysinfo]) # # Modules configuration # HostOS=`echo "$host" | sed 's/.*-//'` os_is_macosx=false nonLinuxOS=false AC_SUBST(HostOS) case ${HostOS} in darwin* | powerpc*-*-darwin*) os_is_macosx=true nonLinuxOS=true ;; *) echo host="$host" echo HostOS="$HostOS" os_is_macosx=false nonLinuxOS=false echo "nonLinuxOS=false ..." ;; esac AM_CONDITIONAL([NON_LINUX], [test x$nonLinuxOS = xtrue]) AM_COND_IF([NON_LINUX], [AC_DEFINE([NON_LINUX], [1], [Get HostOS Type])]) AM_CONDITIONAL([IS_DARWIN], [test x$os_is_macosx = xtrue]) AM_COND_IF([IS_DARWIN], [AC_DEFINE([IS_DARWIN], [1], [Get HostOS Type is Darwin])]) dnl Check for function sysctl (KERN_BOOTTIME) AC_MSG_CHECKING(for function sysctl (KERN_BOOTTIME)) AC_TRY_COMPILE( [ #include <sys/types.h> #include <sys/sysctl.h> #include <unistd.h> #include <time.h> #include <sys/time.h> ], [ struct timeval uptime; int mib[2],len; int now; mib[0]=CTL_KERN; mib[1]=KERN_BOOTTIME; len=sizeof(uptime); sysctl(mib,2,&uptime,&len,0,0); ], AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_BOOTTIME,1,[Define to 1 if 'KERN_BOOTTIME' exist.]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) dnl Check for function sysctl (KERN_MAXFILES) AC_MSG_CHECKING(for function sysctl (KERN_MAXFILES)) AC_TRY_COMPILE( [ #include <sys/types.h> #include <sys/sysctl.h> ], [ int mib[2],len; int maxfiles; mib[0]=CTL_KERN; mib[1]=KERN_MAXFILES; len=sizeof(maxfiles); sysctl(mib,2,&maxfiles,&len,0,0); ], AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_MAXFILES,1,[Define to 1 if 'KERN_MAXFILES' exist.]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) dnl Check for function sysctl (KENR_MAXPROC) AC_MSG_CHECKING(for function sysctl (KERN_MAXPROC)) AC_TRY_COMPILE( [ #include <sys/types.h> #include <sys/sysctl.h> ], [ int mib[2],len; int maxproc; mib[0]=CTL_KERN; mib[1]=KERN_MAXPROC; len=sizeof(maxproc); sysctl(mib,2,&maxproc,&len,0,0); ], AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_MAXPROC,1,[Define to 1 if 'KERN_MAXPROC' exist.]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) AC_CONFIG_FILES([Makefile nvram/include/Makefile nvram/Makefile nvram/testcase/Makefile nvram/conf/Makefile ]) AC_OUTPUT(nvram/nvram-1.0.pc) echo \ "------------------------------------------------- ${PACKAGE_NAME} Version ${PACKAGE_VERSION} Prefix: '${prefix}'. Compiler: '${CC} ${CFLAGS} ${CPPFLAGS}' Libraries: '${LIBS}' Package features: Async Execution: ${async_exec} Now type 'make @<:@<target>@:>@' where the optional <target> is: all - build all binaries install - install everything --------------------------------------------------" |
1 2 3 4 5 |
# $(top_srcdir)/Makefile.am SUBDIRS=nvram nvram/include nvram/testcase nvram/conf DISTCLEANFILES = Makefile.in aclocal.m4 autoscan.log compile config.guess config.sub configure configure.scan ltmain.sh *~ |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# $(top_srcdir)/nvram/Makefile.am # AUTOMAKE_OPTIONS= foreign if IS_DARWIN bin_PROGRAMS= xnvram else bin_PROGRAMS= nvram endif ## Source directory SUBDIRS= . #Distribute these directories: DIST_SUBDIRS = . #Build in these directories: COMMON_FILES=\ ./include/bcmconfig.h \ ./include/bcmnvram.h \ ./include/typedefs.h NVRAM_FILES= $(COMMON_FILES) \ ./src/nvram_cavium.c \ ./src/nvram_main.c if IS_DARWIN xnvram_SOURCES= $(NVRAM_FILES) else nvram_SOURCES= $(NVRAM_FILES) endif AM_CFLAGS= -Iinclude -Invram #LIBS= -L/usr/lib -lpthread pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = nvram-1.0.pc EXTRA_DIST=autogen.sh h_sources = ./include/bcmconfig.h ./include/bcmnvram.h ./include/typedefs.h c_sources = ./src/nvram_cavium.c library_includedir=$(includedir)/$(GENERIC_LIBRARY_NAME)-$(GENERIC_API_VERSION)/$(GENERIC_LIBRARY_NAME) library_include_HEADERS = $(h_sources) INCLUDES = -I$(top_srcdir) lib_LTLIBRARIES= libnvram-1.0.la libnvram_1_0_la_SOURCES= $(h_sources) $(c_sources) libnvram_1_0_la_CFLAGS = -fPIC $(AM_CFLAGS) #libnvram_1_0_la_LIBADD= libnvram.la libnvram_1_0_la_LDFLAGS= -version-info $(GENERIC_LIBRARY_VERSION) -release $(GENERIC_RELEASE) METASOURCES = AUTO DISTCLEANFILES = Makefile.in |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
/* * nvram_main.c * * Created by Jackie Xie on 2011-07-27. * Copyright 2011 Jackie Xie. All rights reserved. * */ #include <bcmnvram.h> extern void nvram_show(void); #define BUFSIZE 1024 char config_file_path[1024]; static void usage(void) { #ifndef TARGET fprintf(stderr, "usage: nvram [get <name>] [set <name>=<value>] [unset <name>] [show] [clean] [commit][import <file>][reload <file>]\n"); #else fprintf(stderr, "usage: nvram [get name] [set name=value] [unset name] [show] [clean] [commit]\n"); #endif exit(0); } extern char flag_force_read_file; int nvram_reload(); int main(int argc, char **argv) { //char *cmd,*name,*value,buf[BUFSIZE],*ptr; char *name,*value, buf[BUFSIZE]; char new_value[BUFSIZE]; char *f_value; //int i,size,running=1,len,shmid; sprintf( config_file_path,"%s",TMP_FILE_PATH); /* Skip program name */ --argc; ++argv; if (!*argv) usage(); // attach_share_memory(); /* Process the remaining arguments. */ for (; *argv; argv++) { if (!strncmp(*argv, "get", 3)) { if (*++argv) { if ((value = nvram_get(*argv))) { #if 0 //For 5vt rc.config only memcpy( (char *)new_value, value, strlen(value)-1); f_value = new_value + 1; puts(f_value); #else puts(value); #endif } } } else if (!strncmp(*argv, "set", 3)) { if (*++argv) { strncpy(value = buf, *argv, sizeof(buf)); name = strsep(&value, "="); nvram_set(name, value); } } else if (!strncmp(*argv, "unset", 5)) { if (*++argv) nvram_unset(*argv); } else if (!strncmp(*argv, "commit", 5)) { nvram_commit(); } else if (!strncmp(*argv, "show", 4) || !strncmp(*argv, "getall", 6)) { nvram_show(); } else if (!strncmp(*argv, "getalltest", 10)) { char *name; nvram_getall(buf, sizeof(buf)); for (name = buf; *name; name = name + strlen(name) + 1) { printf("%s\n", name); } } else if (!strncmp(*argv, "realloc", 7)) { re_alloc(); } #ifndef TARGET else if(!strncmp(*argv,"reload",6) && ++argv != 0x00 ){ sprintf( config_file_path,"%s", (char*) *argv ); printf("\n config_file_path = %s \n",config_file_path); nvram_reload(); } else if (!strncmp(*argv, "import", 6)) { if (*++argv) { if (*argv) { printf("\nDo nvram_import(%s) ...\n", *argv); nvram_import(*argv); } } } else if (!strncmp(*argv, "clean", 5)) { nvram_clean(); } #endif if (!*argv) break; } detach_shm(); #if 0 while (running) { fgets(line,BUFSIZE,stdin); ptr=line; clear_end(ptr); cmd=strsep(&ptr," "); if (!strncmp(cmd,"get",3)) printf ("call nvram get to get %s= %s\n",ptr, nvram_get(ptr) ); else if (!strncmp(cmd,"show",4)) showvars(""); else if (!strncmp(cmd,"set",3)) { name=strsep(&ptr,"="); value=ptr; nvram_set(name,value); } else if (!strncmp(cmd,"commit",6)) { nvram_commit(); } else if (!strncmp(cmd,"md",2)) { name=strsep(&ptr," "); value=ptr; len=atoi(value); dump_mem((void *)strtol(name,NULL,16),len); } else if (!strncmp(cmd,"end",3)) running = 0; } #endif //if 0 (for debug) return 0; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 |
/* * nvram_cavium.c * * Created by Jackie Xie on 2011-07-27. * Copyright 2011 Jackie Xie. All rights reserved. * */ #include <bcmnvram.h> #include <unistd.h> //For execv function #ifndef TARGET #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #endif int sem_id; /*semaphore identifier*/ void *pointer; /*pointer to current poisition in share memory*/ void *ptr_start; /*pointer to start poisition of share memory*/ static char nullstr[1]; /* zero length string */ char shm_flag=1; /*check to attach share memory */ char realloc_flag=0; /*prevent re_alloc function causing deadlock*/ int *var_start; /*start address of hash table*/ #define BOUNDARY_4X(x) (x = (int)(x + 3) & 0xfffffffc) /* X4 alignment */ //static inline void* ckmalloc (int sz) { return xmalloc(sz); } #if __linux__ union semun { #elif defined(__FreeBSD__) || defined(__APPLE__) || defined(MACOSX) typedef union { #endif int val; struct semid_ds *buf; unsigned short *array; #if __linux__ }; #elif defined(__FreeBSD__) || defined(__APPLE__) || defined(MACOSX) }semun; #endif inline void set_sem(int semid) { union semun sem_union; sem_union.val=1; if (semctl(semid,0,SETVAL,sem_union)==-1) printf ("set sem error\n"); } inline void sem_up(int semid) { struct sembuf sem_b; sem_b.sem_num=0; sem_b.sem_op=-1; sem_b.sem_flg=SEM_UNDO; if (semop(semid,&sem_b,1)==-1) printf ("semp p process error\n"); } inline void sem_down(int semid) { struct sembuf sem_b; sem_b.sem_num=0; sem_b.sem_op=1; sem_b.sem_flg=SEM_UNDO; if (semop(semid,&sem_b,1)==-1) printf ("semp v process error\n"); } inline void detach_shm(void) { /* detach the share memory*/ if (shmdt(ptr_start)==-1) perror ("shmdt1"); shm_flag=1; } void attach_share_memory() { int shmid; /*create share memory*/ shmid=shmget((key_t)NVRAMKEY,(size_t)SHARESIZE,IPC_CREAT|IPC_EXCL|0666); if(shmid==-1) { // perror("shmget 1"); if ((shmid=shmget((key_t)NVRAMKEY,(size_t)SHARESIZE,0666))==-1) perror ("attach_share_memory failed, shmid is -1"); } pointer=shmat(shmid,(void *)0, 0); shm_flag=0; ptr_start=pointer; /*set semaphore*/ if ((sem_id = semget(NVRAMKEY, 1, IPC_CREAT | 0666)) == -1) { perror("semget error"); } nvram_init(); } void *get_curr_pos() { char *tmp=(char *)ptr_start; int offset; /*skip MAGIC_ID*/ //tmp+=6; tmp+=8; offset=atol(tmp); return (void *)(ptr_start+offset); } void *ckmalloc(size_t size) { char *p,*ptr; char *tmp=ptr_start; char line[8]; int i; ptr=(char *)get_curr_pos(); /* add 1 byte for NULL character*/ p=ptr+size+1; BOUNDARY_4X(p); /*if out of share memory then re-allocate share memory*/ if (p>=tmp+SHARESIZE) { //printf ("out of memory...realloc memory....\n"); re_alloc(); ptr=(char *)get_curr_pos(); p=ptr+size+1; BOUNDARY_4X(p); /*if still out of share memory then return NULL*/ if (p>=tmp+SHARESIZE) { //printf ("out of memory...can't alloc memory...\n"); return NULL; } } tmp+=(strlen(MAGIC_ID)+1); i=atol(tmp); i+=(size+1); BOUNDARY_4X(i); sprintf(line,"%d-",i); strcpy(tmp,line); // p=(char *)pointer; pointer=(void *)p; return (void *)ptr; } inline void *get_addr(int offset) { // printf ("get_addr :: offset %x\n",offset); char *ptr; ptr=(char *)ptr_start; if (offset > (SHARESIZE-1)||offset<=0) { return NULL; } return (void *)(ptr+offset); } inline int get_offset(void *ptr) { int i; char *tmp1,*tmp2; tmp1=(char *)ptr; tmp2=(char *)ptr_start; i=tmp1-tmp2; // printf ("get_offset :: %x\n",i); if ((i>0)&&(i<SHARESIZE)) return i; else return 0; } void clear_end(char *value) { while(*value) { if((*value=='\r')||(*value=='\n')||(*value=='\0')) { *value='\0'; break; } value++; } return; } void hashvar(const char *p,int **ptr) { unsigned int hashval; hashval = ((unsigned char) *p) << 4; while (*p && *p != '=') hashval += (unsigned char) *p++; *ptr=&var_start[hashval % VTABSIZE]; //printf ("hashvar :: ptr[%x]\n",(int)(*ptr)); return; } static int varequal(const char *p, const char *q) { if (p==NULL) return 0; while (*p == *q++) { if (*p++ == '=') return 1; } if (*p == '=' && *(q - 1) == '\0') return 1; return 0; } static struct varinit * findvar(struct varinit *vp, const char *name) { for (; vp; vp = (struct varinit *)get_addr((vp->next_offset))) { if (varequal((char *)get_addr(vp->name_offset), name)) { break; } } return vp; } static char tmpbuf[17]; char* itoa (int n) { int i=0,j; char s[17]; do{ s[i++]=(char)( n%10+48 ); n-=n%10; } while((n/=10)>0); for (j=0;j<i;j++) tmpbuf[i-1-j]=s[j]; tmpbuf[j]='\0'; return tmpbuf; } int exists(char *FileName) { FILE *file_p; if(file_p = fopen(FileName, "r")) { fclose(file_p); printf("\nFile does exist !!!\n"); return TRUE; } printf("\nFile doesn't exist !!!\n"); return FALSE; } int nvram_import(char *FileName) { char *value,*name; char line[2048]; FILE *fp_ptr; if(exists(FileName)){ fp_ptr=fopen(FileName,"r+"); while(fgets(line,sizeof(line),fp_ptr)) { value=line; name=line; strsep(&value,"="); if (value) { clear_end(value); if(name) { nvram_set(name,value); printf("%s%s\n", name,value); } } } fclose(fp_ptr); nvram_commit(); return 0; } else{ printf("\File \"%s\" does not exist !!!\n", FileName); return -1; } } /* nvram log meaning - To record nvram operation status on nvram.log file value = 0 - do not need commit again. value = 1 - need commit when value was changed in memory. value = 2 - delete nvram.conf when do nvram clean. vaule = 4 - update nvram.conf when do nvram commit after some value was changed. */ int get_nvram_log() { FILE *file_p; char tmp[64]="\0"; int need_commit; if(file_p = fopen(LOG_FILE_PATH,"r")) { fgets(tmp, sizeof(tmp), file_p); //printf("\ntmp=%s\n", tmp); need_commit = atoi(tmp); //printf("\nget_commit() : need_commit=%d\n", need_commit); fclose(file_p); } return need_commit; } int set_nvram_log(int status) { FILE *file_p; int need_commit; //INTOFF; if(file_p= fopen(LOG_FILE_PATH,"w")) { fseek(file_p,0,SEEK_END); need_commit = status; fputs(itoa(need_commit), file_p); //printf("\nset_commit(%d) : need_commit=%d\n", need_commit, need_commit); fclose(file_p); return 0; } else return ERR_NO_MEM; //INTON; } void nvram_accessfile() { char *value,*name; char line[2048]; FILE *fp_ptr=NULL; /*open NVRAM file*/ if(get_nvram_log() == 1 || get_nvram_log() == 4){ fp_ptr=fopen(TMP_FILE_PATH,"w+"); printf("\nUpdate nvram.conf with a \"w+\" access mode ...\n"); } else{ fp_ptr=fopen(TMP_FILE_PATH,"a+"); printf("\nUpdate nvram.conf with a \"a+\" access mode ...\n"); } if (fp_ptr==NULL) { printf ("open %s error..\n",TMP_FILE_PATH); } else { printf ("\n\nNVRAM : R/W %s file !!!\n", TMP_FILE_PATH); while(fgets(line,sizeof(line),fp_ptr)) { value=line; name=line; strsep(&value,"="); if (value) { clear_end(value); if(name) { nvram_set(name,value); printf("%s%s\n", name,value); } } } } fclose(fp_ptr); //rename(TMP_FILE_PATH, BACKUP_FILE_PATH); } char * nvram_get(name) const char *name; { int *offset; struct varinit *v,*vp; if (shm_flag) attach_share_memory(); INTOFF; hashvar(name,&offset); vp=(struct varinit*)get_addr(*offset); if ((v = findvar(vp, name))) { INTON; //printf("nvram_get found %s :: %s\n",name,(char *)get_addr(v->text_offset)); return (char *)get_addr(v->text_offset); } //printf ("nvram_get found no var\n"); INTON; return NULL; } extern char flag_reload_nvram; int nvram_reload( ) { flag_reload_nvram=1; attach_share_memory(); } int nvram_set(name, val) const char *name, *val; { // const char *p; int len,*ptr; int namelen; char *line,*nameeq; int name_offset,value_offset; struct varinit *vp, *vpp; char *action_ptr; if (shm_flag) attach_share_memory(); // p = name; // p=strchr(p,'\0'); namelen = strlen(name); if (val) len = strlen(val); else len=0; action_ptr = NULL; if (strcmp(name, "action") == 0) { /* action queue */ action_ptr=nvram_get("action"); if (action_ptr) { len += strlen(action_ptr); len += 2; } } line=malloc(namelen+len+2); if (line==NULL) { printf("nvram_set :: malloc error...\n"); return ERR_NO_MEM; } if (action_ptr) sprintf(line,"%s=%s %s",name, action_ptr, val); else sprintf(line,"%s=%s",name,val); if (!realloc_flag) INTOFF; hashvar(line,&ptr); vpp=(struct varinit*)get_addr(*ptr); vp = findvar(vpp, line); if (vp) { // cprintf ("nvram_set found var :: set %s=%s\n",name,val); char *tmp=(char *)get_addr(vp->text_offset); /*if the length of new value is larger than old one, it will allocate a new memory area*/ if (strlen(tmp)>=len) { if (len) { memcpy(tmp , val, len); tmp[len]='\0'; } // else tmp[len]='\0'; } else { nameeq = ckmalloc(len); if (nameeq==NULL) { if (!realloc_flag) INTON; return ERR_NO_MEM; } value_offset=get_offset(nameeq); if (len) memcpy(nameeq , val, len); // else nameeq[len] = '\0'; vp->text_offset = value_offset; } } else { /*allocate memory for value and get the offset*/ nameeq = ckmalloc(len); if (nameeq==NULL) { if (!realloc_flag) INTON; return ERR_NO_MEM; } value_offset=get_offset(nameeq); if (len) memcpy(nameeq , val, len); // else nameeq[len] = '\0'; /*allocate memory for name and get the offset*/ len = namelen + 2; /* 2 is space for '=' and '\0' */ nameeq=ckmalloc(len); if (nameeq==NULL) { if (!realloc_flag) INTON; return ERR_NO_MEM; } name_offset=get_offset(nameeq); memcpy(nameeq, name, namelen); nameeq[namelen] = '='; /*allocate memory for varinit and get the offset*/ vp = ckmalloc(sizeof (*vp)); if (vp==NULL) { if (!realloc_flag) INTON; return ERR_NO_MEM; } vp->name_offset = name_offset; vp->text_offset = value_offset; vp->next_offset = get_offset(vpp); /*record current varinit offset to the entry of hash table*/ *ptr = get_offset(vp); //printf ("nvram_set found no var :: set %s=%s\n",(char *)get_addr(name_offset), // (char *)get_addr(value_offset)); } if (!realloc_flag) INTON; free(line); //send a signal to update nvram in monitor.sh immediately if (strcmp(name, "action") == 0) { system("killall -SIGUSR1 sleep.sh"); } set_nvram_log(1); return 0; } int nvram_unset(const char *s) { /*pointer to current varinit struct*/ struct varinit *vp; /*pointer to previous varinit struct*/ struct varinit *vpp; int *ptr; if (shm_flag) attach_share_memory(); INTOFF; hashvar(s,&ptr); vp=(struct varinit *)get_addr(*ptr); if (vp == NULL) goto exit; if (varequal((char *)get_addr(vp->name_offset), s)) { *ptr=vp->next_offset; } else { for (vpp=vp; vp; vpp=vp,vp = (struct varinit *)get_addr((vp->next_offset))) { if (varequal((char *)get_addr(vp->name_offset), s)) { break; } } if (vp) { vpp->next_offset=vp->next_offset; } } exit: INTON; return (0); } extern void nvram_show() { struct varinit *vp; int i=0; if (shm_flag) attach_share_memory(); INTOFF; //printf ("call nvram_show\n"); for ( i=0; i < VTABSIZE ; i++) { vp = (struct varinit *)get_addr(var_start[i]); for ( ;vp ; vp = (struct varinit*)get_addr(vp->next_offset)) { char *name,*value; int len; //printf("vp->name_offset = %08x\n", vp->name_offset); //printf("vp->text_offset = %08x\n", vp->text_offset); name=(char *)get_addr(vp->name_offset); value=(char *)get_addr(vp->text_offset); len = strlen(value); printf("%s%s\n", name,value); } } INTON; } int nvram_commit() { struct varinit *vp; int i; const char *sep = nullstr; FILE *fp=NULL; char *argv[]={ "commit",NULL,NULL,(char *)0}; //char *argv[]={ "ls","-al","/etc",(char *)0}; if (shm_flag) attach_share_memory(); //fp=fopen(DEVICE_PATH,"w+"); #ifndef TARGET mkdir("/var/nvram/conf", O_CREAT); printf("\nnvram_commit() : commit=%d\n", get_nvram_log()); if(get_nvram_log() >= 1){ nvram_accessfile(); set_nvram_log(0); printf ("\n\nNVRAM : Configures have commited to %s !!!\n", TMP_FILE_PATH); } #if 0 char tmp=""; int fd = open(TMP_FILE_PATH, O_CREAT|O_EXCL|O_WRONLY|O_TRUNC, S_IWOTH|S_IROTH); if(fd==-1) printf("\nAn error has occurred\n"); write(fd,tmp,sizeof(tmp)); close(fd); #endif #endif //#ifndef TARGET // if(!exists(TMP_FILE_PATH)) //#else fp=fopen(TMP_FILE_PATH, "w+"); if (fp==NULL) //#endif { //#ifndef TARGET // fp = fopen(TMP_FILE_PATH, "w+"); // printf("\nCreate the file : %s\n\n", TMP_FILE_PATH); //#else printf ("open %s error..\n",TMP_FILE_PATH); return -1; //#endif } #if 0 fp=fopen(TMP_FILE_PATH, "w+"); if (fp==NULL) { printf ("file open error\n"); return -1; } #endif INTOFF; for ( i=0; i < VTABSIZE ; i++) { vp = (struct varinit *)get_addr(var_start[i]); for (; vp ; vp = (struct varinit *)get_addr(vp->next_offset)) { char *name,*value; name=(char *)get_addr(vp->name_offset); value=(char *)get_addr(vp->text_offset); fprintf(fp,"%s%s%s\n", sep, name, value); } } INTON; fclose(fp); return 0; } int nvram_getall(char *buf, int count) { int i,len=0; char *line; struct varinit *vp; if (count==0) return 0; if (shm_flag) attach_share_memory(); if (!realloc_flag) INTOFF; for (i=0; i < VTABSIZE ; i++) { vp = (struct varinit *)get_addr(var_start[i]); for (; vp ; vp = (struct varinit *)get_addr(vp->next_offset)) { char *name,*value; name=(char *)get_addr(vp->name_offset); value=(char *)get_addr(vp->text_offset); line=malloc(strlen(name)+strlen(value)+1); if (line==NULL) goto END; sprintf(line,"%s%s", name, value); strcpy(buf,line); buf += strlen(line); *buf = '\0'; buf++; len+=(strlen(line)+1); free(line); } } END: if (!realloc_flag) INTON; return len; } /* * Match an NVRAM variable. * @param name name of variable to match * @param match value to compare against value of variable * @return TRUE if variable is defined and its value is string equal * to match or FALSE otherwise */ int nvram_match(char *name, char *match) { const char *value = BCMINIT(nvram_get)(name); return (value && !strcmp(value, match)); } /* * Inversely match an NVRAM variable. * @param name name of variable to match * @param match value to compare against value of variable * @return TRUE if variable is defined and its value is not string * equal to invmatch or FALSE otherwise */ int nvram_invmatch(char *name, char *invmatch) { const char *value = BCMINIT(nvram_get)(name); return (value && strcmp(value, invmatch)); } void dump_mem(void *p,int len) { int i; char *ptr; ptr=(char *)p; for (i=0;i<len;i++) printf ("%c",ptr[i]); printf ("\n"); } void init_share_ptr() { char *p=(char *)ptr_start,*ptr; int i; /*add 1 for NULL character*/ p+=(strlen(MAGIC_ID)+1); ptr=p; for (;;ptr++) if ((*ptr>='0')&&(*ptr<='9')) break; /*get current offset*/ i=atol(ptr); ptr=(char *)ptr_start; pointer=ptr+i; // printf ("get current offset :: %d\n",i); p+=8; // 8 bytes for restoring current offset for pointer /*hash table is allocated after MAGIC_ID and current offset (8 bytes)*/ var_start=(int*)p; } char flag_reload_nvram=0; int nvram_init() { char *value,*name,*p; char line[2048]; // int varid; FILE *fp_ptr=NULL; //printf ("pointer :: %x\n",(int) pointer); //printf("nvram_init\n"); #ifndef TARGET if (flag_reload_nvram || strncmp(pointer,MAGIC_ID,strlen(MAGIC_ID))!=0) #else if (strncmp(pointer,MAGIC_ID,strlen(MAGIC_ID))!=0) #endif { //printf("start new process...\n"); memset(pointer,0,SHARESIZE); set_sem(sem_id); //printf ("set semp ok...\n"); INTOFF; p=ckmalloc(strlen(MAGIC_ID)); strcpy(p,MAGIC_ID); //8 bytes for restoring current offset of pointer //ckmalloc will add 1 byte ckmalloc(7); var_start=ckmalloc(sizeof(int)*VTABSIZE); INTON; // if (varid==-1) // printf ("create share memory(var) error\n"); /*open NVRAM file*/ //#ifndef TARGET // if(!exists(TMP_FILE_PATH)) //#else fp_ptr=fopen(TMP_FILE_PATH,"r+"); if (fp_ptr==NULL) //#endif { //#ifndef TARGET // fp_ptr = fopen(TMP_FILE_PATH,"w"); // printf("\nCreate the file : %s\n\n", TMP_FILE_PATH); //#else printf ("open %s error..\n",TMP_FILE_PATH); fp_ptr = fopen(TMP_FILE_PATH,"w+"); //#endif } else { while(fgets(line,sizeof(line),fp_ptr)) { value=line; name=line; strsep(&value,"="); if (value) { clear_end(value); nvram_set(name,value); } } } fclose(fp_ptr); } else { //printf ("found MAGIC ID\n"); init_share_ptr(); } if(!get_nvram_log()) set_nvram_log(0); return 0; } void nvram_clean(void) { #ifndef TARGET char *value,*name; char line[2048]; FILE *fp_ptr=NULL; /*open NVRAM file*/ //#ifndef TARGET // if(!exists(TMP_FILE_PATH)) //#else fp_ptr=fopen(TMP_FILE_PATH,"r+"); if (fp_ptr==NULL) //#endif { //#ifndef TARGET // fp_ptr = fopen(TMP_FILE_PATH,"w"); // printf("\nCreate the file : %s\n\n", TMP_FILE_PATH); //#else printf ("open %s error..\n",TMP_FILE_PATH); //#endif } else { while(fgets(line,sizeof(line),fp_ptr)) { value=line; name=line; strsep(&value,"="); if (value) { clear_end(value); nvram_unset(name); } } } fclose(fp_ptr); rename(TMP_FILE_PATH, BACKUP_FILE_PATH); if(get_nvram_log() == 1) set_nvram_log(4); else set_nvram_log(2); #else /*erase MAGIC_ID, current pointer offset, and hash table*/ int len=(strlen(MAGIC_ID)+1)+8+(sizeof(struct varinit *)*VTABSIZE+1); memset(ptr_start,0,len); #endif } void re_alloc(void) { char *line,*value,*name; char *buf,*ptr; int len,total_len; if (shm_flag) attach_share_memory(); //printf ("before realloc...poniter [%x]...\n",(int)pointer); buf=malloc(SHARESIZE); if (buf==NULL) { perror("malloc"); return ; } /*save current settings to buf*/ realloc_flag=1; total_len=nvram_getall(buf,SHARESIZE); pointer=ptr_start; nvram_clean(); /*start initial data*/ ptr=ckmalloc(strlen(MAGIC_ID)); strcpy(ptr,MAGIC_ID); ckmalloc(7); var_start=ckmalloc(sizeof(int)*VTABSIZE); ptr=buf; /*restore variables*/ while(total_len) { len=strlen(ptr); line=malloc(len); if (line==NULL) { //printf("re_alloc :: malloc error....\n"); break; } sprintf(line,"%s",ptr); // len=strlen(line); if (len==0) break; value=line; name=line; strsep(&value,"="); if (value) { clear_end(value); nvram_set(name,value); } /*move to next data*/ len++; ptr+=len; total_len-=len; free(line); } realloc_flag=0; free(buf); //printf ("after realloc...poniter [%x]...\n",(int)pointer); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
/* * Copyright 2004, Broadcom Corporation * All Rights Reserved. * * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. */ #ifndef _TYPEDEFS_H_ #define _TYPEDEFS_H_ /* Define 'SITE_TYPEDEFS' in the compile to include a site specific * typedef file "site_typedefs.h". * * If 'SITE_TYPEDEFS' is not defined, then the "Inferred Typedefs" * section of this file makes inferences about the compile environment * based on defined symbols and possibly compiler pragmas. * * Following these two sections is the "Default Typedefs" * section. This section is only prcessed if 'USE_TYPEDEF_DEFAULTS' is * defined. This section has a default set of typedefs and a few * proprocessor symbols (TRUE, FALSE, NULL, ...). */ #ifdef SITE_TYPEDEFS /******************************************************************************* * Site Specific Typedefs *******************************************************************************/ #include "site_typedefs.h" #else /******************************************************************************* * Inferred Typedefs *******************************************************************************/ /* Infer the compile environment based on preprocessor symbols and pramas. * Override type definitions as needed, and include configuration dependent * header files to define types. */ #ifdef __cplusplus #define TYPEDEF_BOOL #ifndef FALSE #define FALSE false #endif #ifndef TRUE #define TRUE true #endif #else /* ! __cplusplus */ #if defined(_WIN32) #define TYPEDEF_BOOL typedef unsigned char bool; /* consistent w/BOOL */ #endif /* _WIN32 */ #endif /* ! __cplusplus */ #ifdef _MSC_VER /* Microsoft C */ #define TYPEDEF_INT64 #define TYPEDEF_UINT64 typedef signed __int64 int64; typedef unsigned __int64 uint64; #endif #if defined(__APPLE__) || defined(MACOSX) && defined(KERNEL) #define TYPEDEF_BOOL #endif #if defined(linux) #define TYPEDEF_UINT #define TYPEDEF_USHORT #define TYPEDEF_ULONG #endif #if !defined(linux) && !defined(_WIN32) && !defined(PMON) && !defined(_CFE_) && !defined(_HNDRTE_) && !defined(_MINOSL_) #define TYPEDEF_UINT #define TYPEDEF_USHORT #endif /* Do not support the (u)int64 types with strict ansi for GNU C */ #if defined(__GNUC__) && defined(__STRICT_ANSI__) #define TYPEDEF_INT64 #define TYPEDEF_UINT64 #endif /* ICL accepts unsigned 64 bit type only, and complains in ANSI mode * for singned or unsigned */ #if defined(__ICL) #define TYPEDEF_INT64 #if defined(__STDC__) #define TYPEDEF_UINT64 #endif #endif /* __ICL */ #if !defined(_WIN32) && !defined(PMON) && !defined(_CFE_) && !defined(_HNDRTE_) && !defined(_MINOSL_) /* pick up ushort & uint from standard types.h */ #if defined(linux) && defined(__KERNEL__) #include <linux/types.h> /* sys/types.h and linux/types.h are oil and water */ #else #include <sys/types.h> #endif #endif /* !_WIN32 && !PMON && !_CFE_ && !_HNDRTE_ && !_MINOSL_ */ #if defined(__APPLE__) || defined(MACOSX) && defined(KERNEL) #include <IOKit/IOTypes.h> #endif /* use the default typedefs in the next section of this file */ #define USE_TYPEDEF_DEFAULTS #endif /* SITE_TYPEDEFS */ /******************************************************************************* * Default Typedefs *******************************************************************************/ #ifdef USE_TYPEDEF_DEFAULTS #undef USE_TYPEDEF_DEFAULTS #ifndef TYPEDEF_BOOL typedef /*@abstract@*/ unsigned char bool; #endif /*----------------------- define uchar, ushort, uint, ulong ----------------*/ #ifndef TYPEDEF_UCHAR typedef unsigned char uchar; #endif #ifndef TYPEDEF_USHORT typedef unsigned short ushort; #endif #ifndef TYPEDEF_UINT typedef unsigned int uint; #endif #ifndef TYPEDEF_ULONG typedef unsigned long ulong; #endif /*----------------------- define [u]int8/16/32/64 --------------------------*/ #ifndef TYPEDEF_UINT8 typedef unsigned char uint8; #endif #ifndef TYPEDEF_UINT16 typedef unsigned short uint16; #endif #ifndef TYPEDEF_UINT32 typedef unsigned int uint32; #endif #ifndef TYPEDEF_UINT64 typedef unsigned long long uint64; #endif #ifndef TYPEDEF_INT8 typedef signed char int8; #endif #ifndef TYPEDEF_INT16 typedef signed short int16; #endif #ifndef TYPEDEF_INT32 typedef signed int int32; #endif #ifndef TYPEDEF_INT64 typedef signed long long int64; #endif /*----------------------- define float32/64, float_t -----------------------*/ #ifndef TYPEDEF_FLOAT32 typedef float float32; #endif #ifndef TYPEDEF_FLOAT64 typedef double float64; #endif /* * abstracted floating point type allows for compile time selection of * single or double precision arithmetic. Compiling with -DFLOAT32 * selects single precision; the default is double precision. */ #ifndef TYPEDEF_FLOAT_T #if defined(FLOAT32) typedef float32 float_t; #else /* default to double precision floating point */ typedef float64 float_t; #endif #endif /* TYPEDEF_FLOAT_T */ /*----------------------- define macro values -----------------------------*/ #ifndef FALSE #define FALSE 0 #endif #ifndef TRUE #define TRUE 1 #endif #ifndef NULL #define NULL 0 #endif #ifndef OFF #define OFF 0 #endif #ifndef ON #define ON 1 #endif #define AUTO (-1) /* Reclaiming text and data : The following macros specify special linker sections that can be reclaimed after a system is considered 'up'. */ #if defined(__GNUC__) && defined(BCMRECLAIM) extern bool bcmreclaimed; #define BCMINITDATA(_data) __attribute__ ((__section__ (".dataini." #_data))) _data##_ini #define BCMINITFN(_fn) __attribute__ ((__section__ (".textini." #_fn))) _fn##_ini #define BCMINIT(_id) _id##_ini #else #define BCMINITDATA(_data) _data #define BCMINITFN(_fn) _fn #define BCMINIT(_id) _id #define bcmreclaimed 0 #endif /*----------------------- define PTRSZ, INLINE ----------------------------*/ #ifndef PTRSZ #define PTRSZ sizeof (char*) #endif #ifndef INLINE #ifdef _MSC_VER #define INLINE __inline #elif __GNUC__ #define INLINE __inline__ #else #define INLINE #endif /* _MSC_VER */ #endif /* INLINE */ #undef TYPEDEF_BOOL #undef TYPEDEF_UCHAR #undef TYPEDEF_USHORT #undef TYPEDEF_UINT #undef TYPEDEF_ULONG #undef TYPEDEF_UINT8 #undef TYPEDEF_UINT16 #undef TYPEDEF_UINT32 #undef TYPEDEF_UINT64 #undef TYPEDEF_INT8 #undef TYPEDEF_INT16 #undef TYPEDEF_INT32 #undef TYPEDEF_INT64 #undef TYPEDEF_FLOAT32 #undef TYPEDEF_FLOAT64 #undef TYPEDEF_FLOAT_T #endif /* USE_TYPEDEF_DEFAULTS */ #endif /* _TYPEDEFS_H_ */ |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
/* * NVRAM variable manipulation * * Copyright 2004, Broadcom Corporation * All Rights Reserved. * * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. * * $Id: bcmnvram.h,v 1.3.2.2 2008/06/11 08:36:04 jackie Exp $ */ #ifndef _bcmnvram_h_ #define _bcmnvram_h_ #ifndef _LANGUAGE_ASSEMBLY #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/sem.h> #include <sys/shm.h> #include <semaphore.h> //#include <typedefs.h> #include <typedefs.h> struct nvram_header { uint32 magic; uint32 len; uint32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:27 init, mem. test 28, 29-31 reserved */ uint32 config_refresh; /* 0:15 config, 16:31 refresh */ uint32 config_ncdl; /* ncdl values for memc */ }; struct nvram_tuple { char *name; char *value; struct nvram_tuple *next; }; #define VTABSIZE 127 struct varinit { int name_offset; /*offset of name string : ex. wan_proto=*/ int text_offset; /*offset of value string : ex. pppoe*/ int next_offset; /*offset of next varinit struct*/ }; #define INTOFF sem_up(sem_id) /*set semaphore*/ #define INTON sem_down(sem_id) /*unset semaphore*/ /*share memory identifier (note. must greater than share memory size)*/ #define NVRAMKEY 655350 /*share memory size*/ #define SHARESIZE 65536 #define MAGIC_ID "<NVRAM>" #ifdef TARGET #define TMP_FILE_PATH "/flash/nvram.conf" //#define TMP_FILE_PATH "/tmp/config/nvram.config" //##define TMP_FILE_PATH "/var/run/rc.conf" #elif __linux__ #define TMP_FILE_PATH "/var/OpenAgentV2/conf/nvram.conf" #define LOG_FILE_PATH "/var/OpenAgentV2/conf/nvram.log" #define BACKUP_FILE_PATH "/var/OpenAgentV2/conf/nvram.bak" #elif defined(__FreeBSD__) || defined(__APPLE__) || defined(MACOSX) #define TMP_FILE_PATH "/var/conf/nvram.conf" #define LOG_FILE_PATH "/var/conf/nvram.log" #define BACKUP_FILE_PATH "/var/conf/nvram.bak" #elif defined(__CYGWIN__) || defined(_MSC_VER) #define TMP_FILE_PATH "c:\nvram.conf" #define LOG_FILE_PATH "c:\nvram.log" #define BACKUP_FILE_PATH "c:\nvram.bak" #endif #define ERR_NO_MEM -1 //void *xmalloc(size_t sz); void dump_mem(void*,int); int nvram_init(); void attach_share_memory(void); void nvram_clean(void); void re_alloc(void); void detach_shm(void); extern int nvram_invmatch(char *name, char *match); extern int nvram_match(char *name, char *match); extern int nvram_commit(void); extern char *nvram_get(const char *name); extern int nvram_set(const char *name, const char *val); extern int nvram_unset(const char *s); /* * Initialize NVRAM access. May be unnecessary or undefined on certain * platforms. */ #if 0 extern int BCMINIT(nvram_init)(void *sbh); #endif /* * Disable NVRAM access. May be unnecessary or undefined on certain * platforms. */ extern void BCMINIT(nvram_exit)(void); /* * Get the value of an NVRAM variable. The pointer returned may be * invalid after a set. * @param name name of variable to get * @return value of variable or NULL if undefined */ extern char * BCMINIT(nvram_get)(const char *name); /* * Get the value of an NVRAM variable. * @param name name of variable to get * @return value of variable or NUL if undefined */ #define nvram_safe_get(name) (BCMINIT(nvram_get)(name) ? : "") /* * Match an NVRAM variable. * @param name name of variable to match * @param match value to compare against value of variable * @return TRUE if variable is defined and its value is string equal * to match or FALSE otherwise */ #if 0 static INLINE int nvram_match(char *name, char *match) { const char *value = BCMINIT(nvram_get)(name); return (value && !strcmp(value, match)); } #endif /* * Inversely match an NVRAM variable. * @param name name of variable to match * @param match value to compare against value of variable * @return TRUE if variable is defined and its value is not string * equal to invmatch or FALSE otherwise */ #if 0 static INLINE int nvram_invmatch(char *name, char *invmatch) { const char *value = BCMINIT(nvram_get)(name); return (value && strcmp(value, invmatch)); } #endif /* * Set the value of an NVRAM variable. The name and value strings are * copied into private storage. Pointers to previously set values * may become invalid. The new value may be immediately * retrieved but will not be permanently stored until a commit. * @param name name of variable to set * @param value value of variable * @return 0 on success and errno on failure */ extern int BCMINIT(nvram_set)(const char *name, const char *value); /* * Unset an NVRAM variable. Pointers to previously set values * remain valid until a set. * @param name name of variable to unset * @return 0 on success and errno on failure * NOTE: use nvram_commit to commit this change to flash. */ extern int BCMINIT(nvram_unset)(const char *name); /* * Commit NVRAM variables to permanent storage. All pointers to values * may be invalid after a commit. * NVRAM values are undefined after a commit. * @return 0 on success and errno on failure */ extern int BCMINIT(nvram_commit)(void); /* * Get all NVRAM variables (format name=value\0 ... \0\0). * @param buf buffer to store variables * @param count size of buffer in bytes * @return 0 on success and errno on failure */ extern int BCMINIT(nvram_getall)(char *buf, int count); #endif /* _LANGUAGE_ASSEMBLY */ #define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */ #define NVRAM_VERSION 1 #define NVRAM_HEADER_SIZE 20 #define NVRAM_SPACE 0x8000 #endif /* _bcmnvram_h_ */ |
[ jackie macbook-pro ~ ]# xnvram show call_port1_forward_noans_timeout=30 call_waiting_enable=1 call_port0_ogCallBlk_maxnum=5 vlan_port_vid_0= dhcp_start=192.168.1.20 call_port1_ogCallBlk_maxnum=5 wait_tone1="_wait_autoindex=2465553060;_wait_on=300;_wait_off=5000;_wait_freq1=425;_wait_freq2=0;_wait_freq1db=5;_wait_freq2db=0;_wait_repeat=1" tone_country=3 IGD_INFO_ModemFirmwareVersion=1111111111 vlan_port_vid_1= dhcp_route= wan_pptp_idle_disconnect=0 sipsec_srtp_unprot_call=1 vlan_src_type_0=ip vlan_port_vid_2= wan_pppoe_idletime=300 sip_port0_mwi_auth_password= IGD_LANDeviceNumberOfEntries= acs_conn_req_ser_username= vlan_src_type_1=ip vlan_port_vid_3= rip_mode=0 dialing_digitmaps1="_port=all;_rule=x.t" qos_rtptos=0 sip_port0_nat_keep_alive_flag=0 sip_port1_mwi_auth_password= fw_disable=0 vlan_src_type_2=ip wl1_gmode=2 dialing_digitmaps2="_port=all;_rule=xxxxxxxxxxxxxxxxxxxxxxxx" sip_port1_nat_keep_alive_flag=0 sip_stun_enable=0 sip_port0_proxy_server_addr=172.16.5.48 vlan_src_type_3=ip wan_pppoe_mru=1492 sip_port1_proxy_server_addr=172.16.5.48 IGD_MS_PeriodicInformTime=`nvram get acs_periodic_inform_time` vlan_src_type_4=ip vlan_src_type_5=ip wl1_radio=0 wan_pppoe_mtu=1450 dhcp_end=192.168.1.200 lan1_enable=1 IGD_INFO_VCF_Version=1111111111 vlan_src_type_6=ip ipping_avresponsetime=0 vlan_src_type_7=ip sip_timeinterval=500 sip_port0_pstn_flag=0 acs_url=http://220.128.128.236/cpe/?pd128 vlan_src_type_8=ip fxs_callerid_type=2 fxo_cpt_detection=0 sip_port1_pstn_flag=0 vlan_src_type_9=ip dialing_supplementary_service_mode=0 call_port0_forward_option=1 acs_periodic_inform_time=2006-11-25T00:00:00 wl1_country_code=11 wan_hostname=localhost fxo_hook_flash_interval=450 call_port1_forward_option=1 router_disable=0 sip_auth_timeout=3600 IGD_WANDeviceNumberOfEntries= cli_enable=1 wan_aliasip= call_port0_auto_answer_enable=0 dhcp_vendorinfo= vlan_wan_port_prio= vlan_protocol_srcip_0= dialing_inter_digit_timeout=4 call_port1_auto_answer_enable=0 sipsec_port0_srtp_sec_type=3 vlan_protocol_srcip_1= dialing_fw_noanswer_deactive_key=*93 sipsec_port1_srtp_sec_type=3 vlan_protocol_srcip_2= dialing_callback_deactive_key=*86 fxo_port0_regulation_domain=64 vlan_protocol_srcip_3= fxo_port1_regulation_domain=64 vlan_protocol_srcip_4= IGD_MS_Username=`nvram get acs_username` vlan_protocol_srcip_5= dhcp_dns= wan_pppoe_username=guest fxo_dtmf_duration=70 acs_conn_req_ser_password= vlan_protocol_srcip_6= nat_type_fullcone=0 dialing_callwaiting_cancel_key=*70 dialing_first_digit_timeout=16 call_port0_dnd_enable=0 sipsec_port0_srtp_sec_key=0000000000000000 vlan_protocol_srcip_7= wl1_frag=2346 vdsl_port_profile_DsMinProtection=0 dialing_dnd_deactive_key=*79 call_port1_dnd_enable=0 sipsec_port1_srtp_sec_key=0000000000000000 IGD_INFO_FirstUseDate=2007-07-17T08:00:00Z vlan_protocol_srcip_8= vlan_wan_port_vid= voice_rtp_packet_lost_percent=100 IGD_INFO_SoftwareVersion=v1.00 vlan_protocol_srcip_9= pppoe_autodns=0 dialing_fw_busy_active_key=*90 IGD_INFO_AdditionalSoftwareVersion=1111111111 DHCPRelayEnabled=0 wl1_crypto=off call_port0_inCallSelect_enable=0 acs_username= url_filter_str_10= wan_ifname=eth0 call_port1_inCallSelect_enable=0 fax_port0_t38opt=0 IGD_MS_ConnectionRequestUsername=`nvram get acs_conn_req_ser_username` url_filter_str_11= rip_dir=0 wan_pppoe_demand=1 fax_port1_t38opt=0 IGD_INFO_VCF_Date=2000-00-00T00:00:00 url_filter_str_12= fax_port2_t38opt=0 dev_sipcli_port=8118 url_filter_str_13= wan_dns0= wan_gateway= voice_max_icmp_unreachable=10 fax_port3_t38opt=0 url_filter_str_14= ntp_dst_enabled=0 wan_dns1= wan_ipaddr= wan_netmask=255.255.0.0 time_zone=46 dialing_newcall_key=*01 dialing_transfer_key=*02 call_waiting_timeout=30 sip_ringback_timeout=180 IGD_INFO_VCF_Name=1111111111 dhcp_clientid=cht-001 url_filter_str_15= wan_dns2= voice_port0_codec_pri1=pcmu IGD_INFO_DC_ConfigFile= url_filter_str_16= voice_port1_codec_pri1=pcmu voice_port0_codec_pri2=pcma IGD_MS_ParameterKey=`nvram get acs_parameterkey` url_filter_str_17= wl1_Preamble=0 lan_proto=dhcp voice_port0_vad_type=0 voice_port1_codec_pri2=pcma voice_port0_codec_pri3=g729ab qos_enabled=0 ipping_failurecount= url_filter_str_18= wan_domain=localhost voice_port1_vad_type=0 voice_port1_codec_pri3=g729ab voice_port0_codec_pri4=g723 url_filter_str_19= voice_port1_codec_pri4=g723 voice_port0_codec_pri5=g726-16 sip_user_agent_name=VOIP_Agent_001 wl1_dtim=5 wan_pppoe_service= wan_hwaddr=00:22:33:44:55:66 voice_port1_codec_pri5=g726-16 voice_port0_codec_pri6=g726-24 sip_port0_outboundproxy_server_port=5060 sip_port0_registar_server_addr=172.16.5.48 voice_port1_codec_pri6=g726-24 voice_port0_codec_pri7=g726-32 sip_port1_outboundproxy_server_port=5060 sip_port1_registar_server_addr=172.16.5.48 voice_port1_codec_pri7=g726-32 voice_port0_codec_pri8=g726-40 IGD_MS_Password=`nvram get acs_password` vlan_protocol_prio_0= vdsl_port_profile_UsMinProtection=0 voice_port1_codec_pri8=g726-40 voice_port0_codec_pri9=ilbc sip_port0_asserted_identity_uri=2300 IGD_INFO_VCF_Description=1111111111 vlan_protocol_prio_1= vlan_protocolbase_Enabled=0 wl1_auth=0 dialing_screen_lastincoming_call_key=*60 call_hunting_timeout=30 voice_g726_32_payload_type=98 voice_port1_codec_pri9=ilbc sip_port1_asserted_identity_uri=2301 sip_media_port_start=5000 vlan_protocol_prio_2= wl1_ssid=localhost wan_autodns=1 rip_ver=2 sip_port0_username=30341 qos_port_0=0 vlan_protocol_prio_3= belkin_router=1 sip_port1_username=30342 qos_port_1=0 ipping_numberofrepetitions=1 vlan_protocol_prio_4= fxs_callerid_t1_alertsig=3 call_repeat_timeout=1800 voice_rtp_timeout=25 sip_port0_separated_port=5060 qos_port_2=0 vlan_protocol_prio_5= vdsl_port_profile_RateAdaptationMode=1 wan_pptp_conn_id= fxs_callerid_t2_alertsig=0 voice_2833_payload_type=100 sip_port1_separated_port=5060 qos_port_3=0 IGD_INFO_SerialNumber=000000002203 acs_password= vlan_protocol_prio_6= sip_port0_proxy_server_port=5060 IGD_MS_ConnectionRequestPassword=`nvram get acs_conn_req_ser_password` dhcp_vendorid=kwgr614 ipping_timout= vlan_protocol_prio_7= snmpd_enable=1 sip_port1_proxy_server_port=5060 sip_port0_enable=1 IGD_INFO_VendorConfigFileNumberOfEntries= vlan_protocol_prio_8= vlan_protocol_vid_0= wan_primary=1 call_port0_anonymous_reject_enable=0 call_port0_auto_answer_timeout=180 sip_port1_enable=1 sip_media_port_end=5009 vlan_protocol_prio_9= vlan_protocol_vid_1= wl1_auth_mode=open call_port1_anonymous_reject_enable=0 call_port1_auto_answer_timeout=180 vlan_protocol_vid_2= dialing_call_pond_key_enable=1 call_port0_inCallSelect_num1= dial_tone1="_dial_autoindex=2726772867;_dial_on=64000;_dial_off=0;_dial_freq1=350;_dial_freq2=440;_dial_freq1db=8;_dial_freq2db=8;_dial_repeat=1" sip_stun_server_addr=0.0.0.0 vlan_protocol_vid_3= dialing_fw_always_deactive_key=*73 call_port1_inCallSelect_num1= call_port0_inCallSelect_num2= sip_port=5060 IGD_INFO_UpTime= ipping_successcount= vlan_protocol_vid_4= wan_pptp_username=guest call_port1_inCallSelect_num2= call_port0_inCallSelect_num3= voice_port0_agc_rx_level=255 sip_port0_dnssrv_enable=0 ipping_dscp= vlan_protocol_vid_5= call_port1_inCallSelect_num3= call_port0_inCallSelect_num4= voice_port1_agc_rx_level=255 voice_port0_codec_g723_rate=2 sip_port1_dnssrv_enable=0 vlan_protocol_vid_6= call_port1_inCallSelect_num4= call_port0_inCallSelect_num5= voice_port0_agc_tx_level=255 voice_port1_codec_g723_rate=2 vlan_protocol_vid_7= wan_moreip=0 fxs_port0_ring_impedance=1 call_port1_inCallSelect_num5= voice_port1_agc_tx_level=255 sip_registration_retry_count=65535 vlan_protocol_vid_8= password1=password fxs_port1_ring_impedance=1 vlan_protocol_vid_9= password2=user http_login_timeout=10 sip_port0_mwi_subscribe_flag=1 password3=guest wan_pptp_idle_interval=5 sip_port1_mwi_subscribe_flag=1 fxs_tone_setting=0 busy_tone1="_busy_autoindex=1156581748;_busy_on=500;_busy_off=500;_busy_freq1=425;_busy_freq2=0;_busy_freq1db=5;_busy_freq2db=0;_busy_repeat=1" IGD_INFO_ProductClass=CPE-Customer-Premise-Equipment fxs_callerid_baring=0 ntp_server= sip_release_timeout=4 IGD_MS_PeriodicInformInterval=`nvram get acs_periodic_inform_interval` IGD_MS_PeriodicInformEnable=`nvram get acs_periodic_inform_enable` dhcp_vendor_id0= wl1_key=1 sip_port0_auth_username=30341 dhcp_vendor_id1= http_wanport=8080 sipsec_srtp_enable=0 sip_port1_auth_username=30342 dev_sipcli_enable=1 IGD_INFO_ManufacturerOUI=12756 acs_flag_reboot=0 dhcp_vendor_id2= rbt_tone1="_rbt_autoindex=3306898451;_rbt_on=2000;_rbt_off=4000;_rbt_freq1=440;_rbt_freq2=480;_rbt_freq1db=8;_rbt_freq2db=8;_rbt_repeat=1" IGD_MS_UpgradesManaged=0 dhcp_vendor_id3= wl1_wep=disabled product_id=localhost wan_pptp_server_ipaddr= IGD_MS_URL=`nvram get acs_url` ddns_enable=1 dialing_anonymouscall_key=*67 acs_command_key=empty acs_periodic_inform_interval=600 acs_periodic_inform_enable=1 wan_pppoe_passwd= http_passwd=admin wan_pptp_netmask=255.255.255.0 wan_pptp_ipaddr= wan_pptp_password= dialing_callback_active_key=*66 dialing_feature_invocation_key=flashhook IGD_MS_KickURL= acs_parameterkey=empty wan_desc="Default Connection" show_Product=1 ipping_host= call_port0_inCallSelect_maxnum=5 feature_voip_enable=1 IGD_MS_ConnectionRequestURL= wl1_wep_mode=off call_port1_inCallSelect_maxnum=5 voice_packet_length=20 EnablePPPoEPassThrough=0 wan0_ifname=eth0 os_version=1.00RC0 dialing_dnd_active_key=*78 sip_port0_outboundproxy_enable=0 acs_use_ca_pem=0 call_hunting_group= voice_poor_quality_threshold=20 sip_port1_outboundproxy_enable=0 url_filter_enabled=0 wan0_gateway=192.168.1.1 call_port0_anonymous_enable=0 wl1_rts=2346 call_port1_anonymous_enable=0 call_port0_ogCallBlk_enable=0 sip_port0_registar_server_port=5060 sip_rtcp_port=5060 call_port1_ogCallBlk_enable=0 sip_port1_registar_server_port=5060 user1=admin dhcp_autodns=0 sip_port0_nat_keep_alive_interval=15 IGD_INFO_Manufacturer= user2=user wl1_channel=06 sip_port1_nat_keep_alive_interval=15 sip_port0_auth_password=30341 user3=guest remote_config_ip=0.0.0.0 voice_port0_dtmf_method=0 sip_port1_auth_password=30342 IGD_INFO_DeviceLog=1111111111 IGD_INFO_ModelName=localhost fxo_port0_voice_rx_level=6 voice_port1_dtmf_method=0 sip_port0_mwi_refresh_timeout=3600 IGD_INFO_SpecVersion=v1.00 fxo_port1_voice_rx_level=6 sip_port1_mwi_refresh_timeout=3600 fxo_port0_voice_tx_level=6 call_port0_hotline_enable=0 wan_ping=0 fxo_port1_voice_tx_level=6 call_port1_hotline_enable=0 fxs_port0_voice_rx_level=6 dialing_reset2sysdefault_key=*47991 fxs_port1_voice_rx_level=6 sip_port0_mwi_username= ipping_diagnosticstate=None fxs_port0_voice_tx_level=6 sip_port1_mwi_username= dhcp_lease=0 fxs_port1_voice_tx_level=6 IGD_MS_DownloadProgressURL= wan_proto=dhcp lan_ifname=eth1 voice_port0_aec_tail_length=0 voice_port1_aec_tail_length=0 sip_transport=1 dhcp_vlan_id0= dhcp_vlan_id1= default_lan_netmask_br=255.255.255.0 default_lan_ipaddr_br=192.168.1.1 wan_mac_mode=2 dist_ring_rule1="_port=all;_rule=default;_drno=1" dhcp_vlan_id2= lan_netmask=255.255.255.0 lan_ipaddr=192.168.1.1 dhcp_vlan_id3= dialing_fw_busy_deactive_key=*91 dialing_3wayconf_key=*71 fxs_port0_hook_flash_detect_lbound=100 sip_port0_displayname=30341 acs_conn_req_ser_port=empty fxs_port1_hook_flash_detect_lbound=100 dist_ring_tone6=2000,4000 voice_port0_ilbc_mode=30 sip_port1_displayname=30342 remote_config_ip_start=0.0.0.0 dist_ring_tone7=3000,3000 voice_port1_ilbc_mode=30 ipping_datablocksizes=64 dist_ring_tone8=4000,2000 call_port0_ogCallBlk_num1= sip_ping_interval=0 IGD_INFO_Description=Access-Point+VDSL2-Router-Device lan_hwaddr=00:11:22:33:44:55 dialing_fw_always_active_key=*72 call_port1_ogCallBlk_num1= call_port0_ogCallBlk_num2= url_filter_str_0= call_port1_ogCallBlk_num2= call_port0_ogCallBlk_num3= voice_port0_lec_tail_length=16 IGD_INFO_ProvisioningCode=localhost.LIGHT url_filter_str_1= call_port1_ogCallBlk_num3= call_port0_ogCallBlk_num4= voice_port1_lec_tail_length=16 url_filter_str_2= vdsl_vdslsys_UPBO_Enable=1 nat_disable=0 logout=2 wan_pppoe_keepalive=0 fxs_reverse_enable=0 call_port1_ogCallBlk_num4= call_port0_ogCallBlk_num5= sip_invite_timeout=12 url_filter_str_3= remote_config_ip_end=255.255.255.255 fxs_port0_hook_flash_detect_ubound=300 fxo_ac_impedance=600 call_port1_ogCallBlk_num5= url_filter_str_4= wan_dns= fxs_port1_hook_flash_detect_ubound=300 fxs_dial_pulse_type=0 sip_alwaysuse_outboundproxy=0 url_filter_str_5= ntp_server1=time.stdtime.gov.tw sip_port0_mwi_auth_username= url_filter_str_6= upnp_enable=1 ntp_server2=watch.stdtime.gov.tw sip_port1_mwi_auth_username= url_filter_str_7= ntp_server3=clock.stdtime.gov.tw sip_port0_asserted_enable=1 url_filter_str_8= dmz_ipaddr= ntp_server4=tick.stdtime.gov.tw fxs_callerid_power_level=20 sip_port1_asserted_enable=1 url_filter_str_9= wl1_closed=0 wireless=0 ntp_server5=tock.stdtime.gov.tw dev_sipcli_addr=127.0.0.1 ntp_server6=time-a.nist.gov fxo_offhook_opening_time=1000 acs_retry_times=3 ntp_server7=time-b.nist.gov dialing_fw_noans_active_key=*92 sip_port0_asserted_identity_displayname=2300 sip_registration_retry_interval=30 ipping_minresponsetime=0 wl1_action= sip_port1_asserted_identity_displayname=2301 vlan_port_prio_0= dialing_callreturn_key=*69 ipping_maxresponsetime=0 vlan_port_prio_1= vlan_portbase_Enabled=0 qos_siptos=0 IGD_INFO_DC_PersistentData= agent_enable=0 vlan_port_prio_2= pmon_ver=1.0.1 sip_session_timer=1800 vlan_port_prio_3= sip_port0_outboundproxy_server_addr=10.20.0.2 IGD_INFO_HardwareVersion=light-001 wan_hwifname=eth0 call_port0_transfer_option=1 sip_port1_outboundproxy_server_addr=10.20.0.2 IGD_INFO_AdditionalHardwareVersion=1111111111 call_port1_transfer_option=1 call_port0_forward_noans_timeout=30 sip_upnp_enable=0 sip_prack_flag=0 IGD_INFO_EnabledOptions=localhost.LIGHT,0000001,11,2,2007-07-13T12:00:00Z,,1 wl1_transmitPower=1 [ jackie macbook-pro ~ ]# xnvram commit nvram_commit() : commit=0 [ jackie macbook-pro ~ ]# xnvram set jackie=xie [ jackie macbook-pro ~ ]# xnvram commit nvram_commit() : commit=1 Update nvram.conf with a "w+" access mode ... NVRAM : R/W /var/conf/nvram.conf file !!! NVRAM : Configures have commited to /var/conf/nvram.conf !!! [ jackie macbook-pro ~ ]# xnvram show | grep jackie jackie=xie [ jackie macbook-pro ~ ]# xnvram unset jackie [ jackie macbook-pro ~ ]# xnvram get jackie [ jackie macbook-pro ~ ]#
文章標籤
全站熱搜
留言列表