internal void input(byte[] packet, ip_addr srcn, ip_addr destn, byte proto) { ip_addr src = new ip_addr(lwip.lwip_htonl(srcn.addr)); ip_addr dest = new ip_addr(lwip.lwip_htonl(destn.addr)); pbuf p = lwip.pbuf_alloc(pbuf_layer.PBUF_RAW, (ushort)packet.Length, pbuf_type.PBUF_POOL); int pos = 0, rest = packet.Length; for (pbuf q = p; q != null; q = q.next) { int len = rest; if (len > q.len) { len = q.len; } Buffer.BlockCopy(packet, pos, q.payload.data, q.payload.offset, len); pos += len; rest -= len; } if (lwip.ip.ip_input(p, src, dest, proto, this) != err_t.ERR_OK) { lwip.pbuf_free(p); } }
internal static err_t output(netif netif, pbuf p, ip_addr src, ip_addr dest, byte proto) { int pos = 0, rest = p.tot_len; byte[] packet = new byte[rest]; ip_addr srch = new ip_addr(lwip.lwip_ntohl(src.addr)); ip_addr desth = new ip_addr(lwip.lwip_ntohl(dest.addr)); for (pbuf q = p; q != null; q = q.next) { int len = rest; if (len > q.len) { len = q.len; } Buffer.BlockCopy(q.payload.data, q.payload.offset, packet, pos, len); pos += len; rest -= len; } netif.m_output(netif, packet, srch, desth, proto); return(err_t.ERR_OK); }
public netif(lwip lwip, string name, ip_addr ipaddr, ip_addr netmask, ip_addr gw, netif_output_t output) { this.lwip = lwip; this.name = name; this.m_output = output; set_ipaddr(ipaddr); set_netmask(netmask); set_gw(gw); }
public void set_gw(ip_addr gw) { ip_addr.ip_addr_set(this.gw, gw); lwip.LWIP_DEBUGF(opt.NETIF_DEBUG | lwip.LWIP_DBG_TRACE | lwip.LWIP_DBG_STATE, "netif: GW address of interface {0}{1} set to {2}.{3}.{4}.{5}\n", name[0], name[1], ip_addr.ip4_addr1_16(this.gw), ip_addr.ip4_addr2_16(this.gw), ip_addr.ip4_addr3_16(this.gw), ip_addr.ip4_addr4_16(this.gw)); }
public void set_netmask(ip_addr netmask) { ip_addr.ip_addr_set(this.netmask, netmask); lwip.LWIP_DEBUGF(opt.NETIF_DEBUG | lwip.LWIP_DBG_TRACE | lwip.LWIP_DBG_STATE, "netif: netmask of interface {0}{1} set to {2}.{3}.{4}.{5}\n", name[0], name[1], ip_addr.ip4_addr1_16(this.netmask), ip_addr.ip4_addr2_16(this.netmask), ip_addr.ip4_addr3_16(this.netmask), ip_addr.ip4_addr4_16(this.netmask)); }
private void set_ipaddr(ip_addr ipaddr) { ip_addr.ip_addr_set(this.ip_addr, ipaddr); lwip.LWIP_DEBUGF(opt.NETIF_DEBUG | lwip.LWIP_DBG_TRACE | lwip.LWIP_DBG_STATE, "netif: IP address of interface {0}{1} set to {2}.{3}.{4}.{5}\n", name[0], name[1], ip_addr.ip4_addr1_16(this.ip_addr), ip_addr.ip4_addr2_16(this.ip_addr), ip_addr.ip4_addr3_16(this.ip_addr), ip_addr.ip4_addr4_16(this.ip_addr)); }
internal void input(byte[] packet, ip_addr srcn, ip_addr destn, byte proto) { ip_addr src = new ip_addr(lwip.lwip_htonl(srcn.addr)); ip_addr dest = new ip_addr(lwip.lwip_htonl(destn.addr)); pbuf p = lwip.pbuf_alloc(pbuf_layer.PBUF_RAW, (ushort)packet.Length, pbuf_type.PBUF_POOL); int pos = 0, rest = packet.Length; for (pbuf q = p; q != null; q = q.next) { int len = rest; if (len > q.len) len = q.len; Buffer.BlockCopy(packet, pos, q.payload.data, q.payload.offset, len); pos += len; rest -= len; } if (lwip.ip.ip_input(p, src, dest, proto, this) != err_t.ERR_OK) lwip.pbuf_free(p); }
internal static err_t output(netif netif, pbuf p, ip_addr src, ip_addr dest, byte proto) { int pos = 0, rest = p.tot_len; byte[] packet = new byte[rest]; ip_addr srch = new ip_addr(lwip.lwip_ntohl(src.addr)); ip_addr desth = new ip_addr(lwip.lwip_ntohl(dest.addr)); for (pbuf q = p; q != null; q = q.next) { int len = rest; if (len > q.len) len = q.len; Buffer.BlockCopy(q.payload.data, q.payload.offset, packet, pos, len); pos += len; rest -= len; } netif.m_output(netif, packet, srch, desth, proto); return err_t.ERR_OK; }
internal static void netif_init(lwip lwip, string name, ip_addr ipaddr, ip_addr netmask, ip_addr gw, netif_output_t output) { lwip.netif = new netif(lwip, name, ipaddr, netmask, gw, output); }