Changeset bc9e939 in rtems-libbsd


Ignore:
Timestamp:
Aug 4, 2016, 11:20:04 AM (3 years ago)
Author:
Christian Mauderer <Christian.Mauderer@…>
Branches:
afaeccc05a556f6aa25ba044a7e49d6aa634a59e, freebsd-9.3, master
Children:
62c4755
Parents:
6cfb5c2
git-author:
Christian Mauderer <Christian.Mauderer@…> (08/04/16 11:20:04)
git-committer:
Christian Mauderer <Christian.Mauderer@…> (08/08/16 14:12:05)
Message:

pf: Add configuration via rc.conf.

Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • libbsd.py

    r6cfb5c2 rbc9e939  
    6666            'rtems/rtems-bsd-get-task-stack-size.c',
    6767            'rtems/rtems-bsd-rc-conf-net.c',
     68            'rtems/rtems-bsd-rc-conf-pf.c',
    6869            'rtems/rtems-bsd-rc-conf.c',
    6970            'rtems/rtems-bsd-shell.c',
  • libbsd_waf.py

    r6cfb5c2 rbc9e939  
    10801080              'rtemsbsd/rtems/rtems-bsd-get-task-stack-size.c',
    10811081              'rtemsbsd/rtems/rtems-bsd-rc-conf-net.c',
     1082              'rtemsbsd/rtems/rtems-bsd-rc-conf-pf.c',
    10821083              'rtemsbsd/rtems/rtems-bsd-rc-conf.c',
    10831084              'rtemsbsd/rtems/rtems-bsd-shell-dhcpcd.c',
  • rtemsbsd/include/machine/rtems-bsd-config.h

    r6cfb5c2 rbc9e939  
    124124#if defined(RTEMS_BSD_CONFIG_FIREWALL_PF)
    125125  #define RTEMS_BSD_CFGDECL_FIREWALL_PF SYSINIT_NEED_FIREWALL_PF
     126  #define RTEMS_BSD_CFGDECL_FIREWALL_PF_SERVICE \
     127      RTEMS_BSD_RC_CONF_SYSINT(rc_conf_firewall_pf)
    126128#else
    127129  #define RTEMS_BSD_CFGDECL_FIREWALL_PF
     130  #define RTEMS_BSD_CFGDECL_FIREWALL_PF_SERVICE
    128131#endif /* RTEMS_BSD_CONFIG_FIREWALL_PF */
    129132
     
    193196   */
    194197  RTEMS_BSD_CFGDECL_FIREWALL_PF;
     198  RTEMS_BSD_CFGDECL_FIREWALL_PF_SERVICE;
    195199  RTEMS_BSD_CFGDECL_FIREWALL_PFLOG;
    196200  RTEMS_BSD_CFGDECL_FIREWALL_PFSYNC;
  • rtemsbsd/include/machine/rtems-bsd-rc-conf-services.h

    r6cfb5c2 rbc9e939  
    156156 */
    157157void rc_conf_net_init(void* arg);           /* Installed by default. */
     158void rc_conf_firewall_pf_init(void* arg);   /* pf_enabled="YES" */
    158159void rc_conf_telnetd_init(void* arg);       /* telnetd_enabled="YES" */
    159160void rc_conf_ftpd_init(void* arg);          /* ftpd_enabled="YES" */
  • testsuite/rcconf02/test_main.c

    r6cfb5c2 rbc9e939  
    5454#include <ctype.h>
    5555#include <errno.h>
     56#include <fcntl.h>
    5657#include <string.h>
    5758#include <stdio.h>
     
    123124  "ftpd_enable=\"YES\"\n"                                  \
    124125  "ftpd_options=\"-v -p 21 -C 10 -P 150 -L -I 10 -R /\"\n" \
    125   "n";
     126  "\n"                                                     \
     127  "pf_enable=\"YES\"\n"                                    \
     128  "pf_rules=\"/etc/mypf.conf\"\n"                          \
     129  "pf_flags=\"-q -z\"\n"                                   \
     130  "\n";
     131
     132static const char* pf_conf_text = "pass all\n";
     133static const char* pf_os_text = "# empty\n";
     134
     135static void
     136prepare_files(void)
     137{
     138  size_t len;
     139  size_t written;
     140  int fd;
     141  int rv;
     142
     143  len = strlen(pf_conf_text);
     144  fd = open("/etc/mypf.conf", O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
     145  assert(fd != -1);
     146  written = write(fd, pf_conf_text, len);
     147  assert(written == len);
     148  rv = close(fd);
     149  assert(rv == 0);
     150
     151  len = strlen(pf_os_text);
     152  fd = open("/etc/pf.os", O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
     153  assert(fd != -1);
     154  written = write(fd, pf_os_text, len);
     155  assert(written == len);
     156  rv = close(fd);
     157  assert(rv == 0);
     158}
    126159
    127160static void
     
    134167    "netstat", "-rn", NULL
    135168  };
     169  const char* pfctl_args[] = {
     170    "pfctl", "-s", "rules", NULL
     171  };
    136172
    137173  printf("--------------- rc.conf -----------------\n");
     
    145181  printf("-------------- NETSTAT ------------------\n");
    146182  rtems_bsd_command_netstat(2, (char**) netstat_args);
     183  printf("-------------- PFCTL --------------------\n");
     184  rtems_bsd_command_pfctl(RTEMS_BSD_ARGC(pfctl_args), (char **) pfctl_args);
    147185  printf("-----------------------------------------\n");
    148186}
     
    182220test_main(void)
    183221{
     222  prepare_files();
    184223  test_rc_conf_script();
    185224  shell();
     
    202241  &rtems_shell_IFCONFIG_Command, \
    203242  &rtems_shell_TCPDUMP_Command, \
     243  &rtems_shell_PFCTL_Command, \
    204244  &rtems_shell_SYSCTL_Command
    205245
     
    230270#define RTEMS_BSD_CONFIG_TELNETD_STACK_SIZE (16 * 1024)
    231271#define RTEMS_BSD_CONFIG_SERVICE_FTPD
     272#define RTEMS_BSD_CONFIG_FIREWALL_PF
    232273
    233274#define CONFIGURE_MAXIMUM_DRIVERS 32
Note: See TracChangeset for help on using the changeset viewer.