ES-2024 reverter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cfgpatch.c 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <string.h>
  5. #include "configdata.h"
  6. #include "filedata.h"
  7. /*
  8. * $ cfgpatch <config-in>
  9. */
  10. int main(int argc, char *argv[])
  11. {
  12. struct filedata *config = get_filedata(argv[1]);
  13. config_patch(config->data, CFG_PASSWORD, "1234");
  14. config_patch(config->data, CFG_LOCATION, "location");
  15. config_patch(config->data, CFG_SYSNAME, "sysname");
  16. config_patch(config->data, CFG_CONTACT, "contact");
  17. config_patch(config->data, CFG_IPADDRESS, "10.10.200.10");
  18. config_patch(config->data, CFG_NETMASK, "16");
  19. config_patch(config->data, CFG_DEFAULTGW, "10.10.250.250");
  20. config_patch(config->data, CFG_NAMESERVER, "10.10.0.1");
  21. config_patch(config->data, CFG_MACAGEING, "301");
  22. config_patch(config->data, CFG_PORTNAME_MASK + 1, "PORT-001");
  23. config_patch(config->data, CFG_PORTNAME_MASK + 2, "PORT-002");
  24. config_patch(config->data, CFG_PORTNAME_MASK + 26, "UPLINK");
  25. config_patch(config->data, CFG_PORTENABLE_MASK + 25, "off");
  26. config_patch(config->data, CFG_SNMP_READ_COMMUNITY, "public1234");
  27. config_patch(config->data, CFG_SNMP_WRITE_COMMUNITY, "private1234");
  28. config_patch(config->data, CFG_CPUVLANID, "124");
  29. config_patch(config->data, CFG_PORTVLAN_MASK + 1, "124:check:all");
  30. config_patch(config->data, CFG_PORTVLAN_MASK + 2, "124:nocheck:tagged");
  31. config_patch(config->data, CFG_DOT1QVLAN_MASK + 2, "124:test");
  32. config_patch(config->data, CFG_DOT1QPORT_MASK + 2, "1:fixed:tagging");
  33. config_patch(config->data, CFG_DOT1QPORT_MASK + 2, "2:normal:notagging");
  34. config_patch(config->data, CFG_DOT1QPORT_MASK + 2, "3:forbidden:notagging");
  35. char outname[64];
  36. strncpy(outname, argv[1], sizeof(outname));
  37. strcat(outname, ".patched");
  38. put_filedata(outname, config);
  39. free(config);
  40. return 0;
  41. }