# networking

Networking main procedures BETA

Author | Matthew Schinkel - borntechi.com, copyright © 2011, all rights reserved.
Adapted-by |
Compiler | >=2.4n

Description

    recieves packets and forwards them to the next next protocol

Sources

    http://www.comptechdoc.org/independent/networking/protocol/protnet.html

Dependencies

- random

## Summary

### Global variables/contants

- `var word network_packet_size = 0`
- `var byte network_remote_mac[6]`
- `var dword _network_remote_ip`
- `var byte network_remote_ip[4] at _network_remote_ip`
- `var word network_var_offset = 0`

### Procedures

- `network_poll()`
- `network_byte'put(word in variable,byte in value)`
- `network_received_packet()`
- `network_dword'put(word in variable, dword in value)`
- `network_switch_dword_bytes(dword in out data)`
- `network_set_remote_ip(byte in ip_0,byte in ip_1,byte in ip_2,byte in ip_3)`
- `network_word'put(word in variable, word in value)`

### Functions

- `network_word'get(word in variable) return word`
- `network_checksum_16_byte_verify(word in start, word in size) return bit`
- `network_dword'get(word in variable) return dword`
- `network_checksum_16_byte_calc(word in start, word in size) return word`
- `network_byte'get(word in variable) return byte`

## API details

### Global variables/contants

- `var word network_packet_size = 0`

  No documentation found

- `var byte network_remote_mac[6]`

      MAC address of other end

- `var dword _network_remote_ip`

      IP address of other end

- `var byte network_remote_ip[4] at _network_remote_ip`

  No documentation found

- `var word network_var_offset = 0`

      variable offset for variables in the network_data

### Procedures

- `network_poll()`

      poll to see if there are any packets waiting for us

- `network_byte'put(word in variable,byte in value)`

  No documentation found

- `network_received_packet()`

      Reads a recieve packet. Verifies IP Header data such as IP
      address and checksum (with ip_header.jal), then sends the
      rest of the data to the correct procedure depending on packet type.

- `network_dword'put(word in variable, dword in value)`

  No documentation found

- `network_switch_dword_bytes(dword in out data)`

      switch byte order in a dword

- `network_set_remote_ip(byte in ip_0,byte in ip_1,byte in ip_2,byte in ip_3)`

      set remote ip address

- `network_word'put(word in variable, word in value)`

  No documentation found

### Functions

- `network_word'get(word in variable) return word`

  No documentation found

- `network_checksum_16_byte_verify(word in start, word in size) return bit`

      Verify 16bit checksum from a byte array using every 2 bytes in the array.
      Mostly used for IP header checksums.

- `network_dword'get(word in variable) return dword`

  No documentation found

- `network_checksum_16_byte_calc(word in start, word in size) return word`

      Computes a 16bit checksum from a byte array using every 2 bytes in the array.
      Mostly used for IP header checksums.

- `network_byte'get(word in variable) return byte`

      functions to get/put variables into the network array

## Related samples

Here are the list of samples which use this library:

18f4620 | 18f4620_network_udp_server.jal
18f4620 | 18f4620_network_webserver_enc28j60.jal
18f4620 | 18f4620_network_udp_client.jal
18f4620 | 18f4620_network_all_in_one.jal
18f4620 | 18f4620_network_slip_isr_ping_udp.jal
18f4620 | 18f4620_network_tcp_client.jal
18f4620 | 18f4620_network_tcp_server.jal
18f4620 | 18f4620_network_ping.jal