int main(int argc, char const *argv[]){ struct phys_dev* physd; struct tun_dev* tund; // Init gums before devices (for gum adding and map initializing) init_gums(); tund = tun_init(); physd = phys_init(); init_bridge(physd, tund); pause(); return 0; }
int main(int argc, char *argv[]) { int pid_fd, pid, scr; char tmpbuf[100]; int chan; //if (parse_argument(argc, argv) != 0) // return 0; // become daemon /*if (daemon(0,1) == -1) { printf("fork daemon error!\n"); return 0; }*/ init_bridge(); sleep(3); //wait bridge forwarding }
DFBResult dfb_surface_pool_bridge_initialize( CoreDFB *core, const SurfacePoolBridgeFuncs *funcs, void *context, CoreSurfacePoolBridge **ret_bridge ) { DFBResult ret; CoreSurfacePoolBridge *bridge; FusionSHMPoolShared *shmpool; D_DEBUG_AT( Core_SurfPoolBridge, "%s( %p, %p )\n", __FUNCTION__, funcs, context ); D_ASSERT( core != NULL ); D_ASSERT( funcs != NULL ); D_ASSERT( ret_bridge != NULL ); /* Check against bridge limit. */ if (bridge_count == MAX_SURFACE_POOL_BRIDGES) { D_ERROR( "Core/SurfacePoolBridge: Maximum number of bridges (%d) reached!\n", MAX_SURFACE_POOL_BRIDGES ); return DFB_LIMITEXCEEDED; } D_ASSERT( bridge_funcs[bridge_count] == NULL ); shmpool = dfb_core_shmpool( core ); /* Allocate bridge structure. */ bridge = SHCALLOC( shmpool, 1, sizeof(CoreSurfacePoolBridge) ); if (!bridge) return D_OOSHM(); /* Assign a bridge ID. */ bridge->bridge_id = bridge_count++; /* Remember shared memory pool. */ bridge->shmpool = shmpool; /* Set function table of the bridge. */ bridge_funcs[bridge->bridge_id] = funcs; /* Add to global bridge list. */ bridge_array[bridge->bridge_id] = bridge; D_MAGIC_SET( bridge, CoreSurfacePoolBridge ); ret = init_bridge( core, bridge, funcs, context ); if (ret) { bridge_funcs[bridge->bridge_id] = NULL; bridge_array[bridge->bridge_id] = NULL; bridge_count--; D_MAGIC_CLEAR( bridge ); SHFREE( shmpool, bridge ); return ret; } /* Insert new bridge into priority order */ insert_bridge_local( bridge ); /* Return the new bridge. */ *ret_bridge = bridge; return DFB_OK; }
void init_router(void) { int log_remote, is_ap_mode, nvram_need_commit; #if defined (USE_RTL8367) rtl8367_node(); #endif #if defined (USE_MTK_ESW) || defined (USE_MTK_GSW) mtk_esw_node(); #endif nvram_convert_old_params(); nvram_need_commit = nvram_restore_defaults(); get_eeprom_params(); nvram_convert_misc_values(); if (nvram_need_commit) nvram_commit(); init_gpio_leds_buttons(); gen_ralink_config_2g(0); gen_ralink_config_5g(0); load_wireless_modules(); #if (BOARD_NUM_USB_PORTS > 0) load_usb_modules(); #endif recreate_passwd_unix(1); set_timezone(); set_pagecache_reclaim(); storage_load_time(); is_ap_mode = get_ap_mode(); log_remote = nvram_invmatch("log_ipaddr", ""); if (!log_remote) start_logger(1); init_loopback(); init_bridge(is_ap_mode); #if defined (USE_IPV6) init_ipv6(); #endif start_detect_link(); start_detect_internet(0); start_lan(is_ap_mode, 0); if (log_remote) start_logger(1); start_dns_dhcpd(is_ap_mode); #if defined(APP_SMBD) || defined(APP_NMBD) start_wins(); #endif if (!is_ap_mode) { ipt_nat_default(); ipt_filter_default(); #if defined (USE_IPV6) ip6t_filter_default(); #endif start_wan(); } start_services_once(is_ap_mode); notify_leds_detect_link(); // system ready system("/etc/storage/started_script.sh &"); }
int main(int argc, char *argv[]) { int pid_fd, pid, scr; char tmpbuf[100]; int chan; /* INBAND_HOST ---> */ struct iwreq wrq; /* INBAND_HOST <--- */ if (parse_argument(argc, argv) != 0) return 0; // become daemon if (daemon(0,1) == -1) { printf("fork daemon error!\n"); return 0; } // create pid file pid_fd = pidfile_acquire(PID_FILE); if (pid_fd < 0) { printf("Create PID file failed!\n"); return 0; } pidfile_write_release(pid_fd); DISPLAY_BANNER; // initialize mib init_config_mib(); // register signal handler #ifdef CMD_LINE signal(SIGUSR2, manual_cmd_handler); #endif signal(SIGCHLD, sigchld_handler); // open mdio driver #ifdef RTK_NFBI_AP_HCM mdio_fd = open(DEV_NAME, O_RDWR); if (!mdio_fd) { printf("open driver failed!\n"); return 1; } #endif init_bridge(); bring_up_lan(); bring_up_br(); sleep(1); chan = inband_open(INBAND_NETIF,NULL,ETH_P_RTK,INBAND_DEBUG); if(chan < 0) { printf(" inband_open failed!\n"); return -1; } else hcd_inband_chan = chan; // Set daemon pid to driver. // When this ioctl is set, driver will set AllSoftwareReady bit to 'CPU System Status' Register pid = getpid(); #ifdef RTK_NFBI_AP_HCM if (do_mdio_ioctl(id_set_host_pid, (void *)&pid)) //mark_issue , if it is need then mdio_open must be done return 1; #endif ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0); if (ioctl_sock < 0) { perror("socket[PF_INET,SOCK_DGRAM]"); return -1; } /* INBAND_HOST ---> */ /* Get wireless name */ memset(wrq.ifr_ifrn.ifrn_name, 0, sizeof wrq.ifr_ifrn.ifrn_name); strncpy(wrq.ifr_ifrn.ifrn_name, "wlan0", IFNAMSIZ); pid = getpid(); wrq.u.data.pointer = (caddr_t)&pid; wrq.u.data.length = sizeof(pid_t); if(ioctl(ioctl_sock, SIOCSAPPPID, &wrq) < 0) { // If no wireless name : no wireless extensions return(-1); } event_channel = inband_open(INBAND_INTF,INBAND_HOST,INBAND_EVENT_TYPE,INBAND_DEBUG); if( event_channel < 0 ) return -1; signal(SIGIO, notify_host); /* INBAND_HOST <--- */ //init_system(INIT_ALL); //mark_debug while(1){ inband_wait_event(); } }