Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • feed/openwrt-core
  • markus.gothe/openwrt-core
2 results
Show changes
Commits on Source (1)
--- a/pppd/sys-linux.c 2021-12-15 14:42:59.958193562 +0100
+++ b/pppd/sys-linux.c 2022-02-15 13:12:20.963825923 +0100
@@ -630,6 +630,91 @@
}
}
+typedef struct mac_limit_arg{
+ uint32_t cmd;
+ uint32_t val;
+ union {
+ void *mac_limit;
+ char rsvd[8];
+ };
+}mac_limit_arg_t;
+
+enum mac_limit_cmd{
+ MAC_LIMIT_IOCTL_GET = 0,
+ MAC_LIMIT_IOCTL_SET,
+ MAC_LIMIT_IOCTL_CLR,
+ MAC_LIMIT_IOCTL_EN
+};
+
+enum mac_limit_set_op{
+ MAC_LIMIT_SET_MAX = 0,
+ MAC_LIMIT_SET_MIN,
+};
+
+/*------------------------------------------------------------------------*/
+/* BCM net character device for ioctl to get/set netdev BRCM private info */
+/*------------------------------------------------------------------------*/
+#define BCMNET_DRV_MAJOR 377
+#define BCMNET_DRV_NAME "bcmnet"
+#define BCMNET_DRV_DEVICE_NAME "/dev/" BCMNET_DRV_NAME
+
+typedef enum bcmnet_ioctl_cmd
+{
+ BCMNET_IOCTL_GET_EXT_FLAGS,
+ BCMNET_IOCTL_GET_LAST_CHANGE,
+ BCMNET_IOCTL_CLR_STATS,
+ BCMNET_IOCTL_ADD_NETDEV_PATH,
+ BCMNET_IOCTL_MAC_LIMIT,
+ BCMNET_IOCTL_MAX
+} bcmnet_ioctl_cmd_t;
+
+typedef struct {
+ unsigned int unused : 25;
+ unsigned int is_bcm_dev : 1;
+ unsigned int is_wlan : 1;
+ unsigned int is_hw_switch : 1;
+ unsigned int is_hw_fdb : 1;
+ unsigned int is_ppp : 1;
+ unsigned int is_vlan : 1;
+ unsigned int is_wan : 1;
+} bcmnet_extflags;
+
+typedef struct {
+ char if_name[IFNAMSIZ];
+ union {
+ struct {
+ bcmnet_extflags ret_val;
+ }st_get_ext_flags;
+ struct {
+ unsigned long last_change;
+ }st_get_last_change;
+ struct {
+ char next_if_name[IFNAMSIZ];
+ }st_add_netdev_path;
+ mac_limit_arg_t st_mac_limit;
+ };
+}bcmnet_info_t;
+
+#define FIELD0 4 /* ppp device number ppp0, ppp1, the third digit (max 16) */
+#define FIELD1 8 /* if 0, default mode, 1 vlan mux, 2 msc */
+#define FIELD2 19 /* if FILED1 is 0, add no extension, 1 add vlan id, 2 add conId for msc */
+
+static inline int bcmnet_ioctl_add_netdev_path(char const* dev_name, char const* next_dev_name)
+{
+ bcmnet_info_t info;
+ int fd, err;
+
+ fd = open(BCMNET_DRV_DEVICE_NAME, O_RDWR);
+ if (fd < 0)
+ return -1;
+
+ strncpy(info.if_name, dev_name, IFNAMSIZ);
+ strncpy(info.st_add_netdev_path.next_if_name, next_dev_name, IFNAMSIZ);
+ err = ioctl(fd, BCMNET_IOCTL_ADD_NETDEV_PATH, &info);
+ close(fd);
+ return err;
+}
+
/*
* make_ppp_unit - make a new ppp unit for ppp_dev_fd.
* Assumes new_style_driver.
@@ -637,6 +722,12 @@
static int make_ppp_unit()
{
int x, flags;
+#if 0
+ /* brcm */
+ unsigned num[3] = {0, 0, 0};
+ char *p;
+ /*end brcm */
+#endif
if (ppp_dev_fd >= 0) {
dbglog("in make_ppp_unit, already had /dev/ppp open?");
@@ -650,6 +741,40 @@
|| fcntl(ppp_dev_fd, F_SETFL, flags | O_NONBLOCK) == -1)
warn("Couldn't set /dev/ppp to nonblock: %m");
+#if 0
+ /* brcm */
+ /* req_name will beused as ifname and for
+ * num[1] == 0: default connection mdoe: ppp0, ppp1...
+ * num[1] == 1: vlanMux mode: ppp0.100, ppp1.200...
+ * num[1] == 2: msc (multiple service mode) ppp0_1, ppp1_3...
+ * num[1] == 3: pppoa0, pppoa1...
+ *
+ */
+ if ((p = strchr(req_ifname, '.')) != NULL)
+ {
+ /* vlan mux mode */
+ sscanf(&(req_ifname[3]), "%d.%d", num, num+2);
+ num[1] = 1;
+ }
+ else if ((p = strchr(req_ifname, '_')) != NULL)
+ {
+ /* msc mode */
+ sscanf(&(req_ifname[3]), "%d_%d", num, num+2);
+ num[1] = 2;
+ }
+ else if ((p = strstr(req_ifname, "pppoa")) != NULL)
+ {
+ /* pppoa */
+ num[0] = atoi(&req_ifname[5]);
+ num[1] = 3;
+ }
+ else /* must be default mode */
+ {
+ num[0] = atoi(&req_ifname[3]);
+ }
+ req_unit = num[0]<<(FIELD1+FIELD2) | num[1]<<FIELD2 | num[2];
+#endif
+
ifunit = req_unit;
x = ioctl(ppp_dev_fd, PPPIOCNEWUNIT, &ifunit);
if (x < 0 && req_unit >= 0 && errno == EEXIST) {
@@ -674,6 +799,10 @@
info("Renamed interface %s to %s", t, req_ifname);
}
+ if (bcmnet_ioctl_add_netdev_path(req_ifname, devnam) < 0) {
+ error("Couldn't set ppp real device (%s): %m", devnam);
+ }
+
return x;
}