net/helpers.h File Reference

Helper functions for Modtronix TCP/IP Stack. More...

#include "net\compiler.h"

Functions

void base64Encode (char *out, char *in, BYTE inlen)
BYTE btohexa_high (BYTE b)
BYTE btohexa_low (BYTE b)
WORD CalcIPBufferChecksum (WORD len)
WORD CalcIPChecksum (BYTE *buffer, WORD len)
BYTE getHexNibble (BYTE c)
BYTE hextob (char *s, BYTE *c)
void memclr (void *dest, WORD size)
BOOL strBeginsWithIC (char *strRam, ROM char *strRom)
BYTE strcmpee2ram (char *strRam, WORD strEe)
BYTE strcpyee2ram (char *strDst, WORD strSrc, BYTE len)
BYTE strcpyram2ee (WORD strDst, char *strSrc, BYTE len)
DWORD swapl (DWORD v)
WORD swaps (WORD v)


Detailed Description

Helper functions for Modtronix TCP/IP Stack.

Author:
Modtronix Engineering
Dependencies:
stacktsk.h
Compiler:
MPLAB C18 v2.10 or higher
HITECH PICC-18 V8.35PL3 or higher

Description

This module contains general helper functions.

Function Documentation

void base64Encode ( char *  out,
char *  in,
BYTE  inlen 
)

Encode given ascii characters to base64 6-bit characters, adding padding characters where required

Parameters:
out Buffer where output is written to
in Input ascii string
inlen Length of input ascii string

BYTE btohexa_high ( BYTE  b  ) 

Convert the upper nibble (upper 4 bits) to an ASCII character.

Parameters:
b An ascii byte (always uppercase) between '0'-'9' or 'A'-'F' that corresponds to the upper 4 bits of the input byte. ex: b = 0xAE, btohexa_high() returns 'A'
Returns:
the resulting ASCII character

BYTE btohexa_low ( BYTE  b  ) 

Parameters:
b An ascii byte (always uppercase) between '0'-'9' or 'A'-'F' that corresponds to the lower 4 bits of the input byte. ex: b = 0xAE, btohexa_low() returns 'E'
Returns:
the resulting ASCII character

WORD CalcIPBufferChecksum ( WORD  len  ) 

This function performs checksum calculation in MAC buffer itself.

Pre-Condition:
TCPInit() is already called AND MAC buffer pointer set to start of buffer
Parameters:
len Total number of bytes to calculate checksum for
Returns:
16-bit checksum as defined by rfc 793

WORD CalcIPChecksum ( BYTE buffer,
WORD  len 
)

BYTE getHexNibble ( BYTE  c  ) 

Get the hex value for the given alpha numrical character. The returned value will be from 0 - 15. If the given byte is not a alphe numerical value, 0xff is returned!

BYTE hextob ( char *  s,
BYTE c 
)

Converts the given 2 character hex string to a byte value. Only the first two character of the given string is checked. No NULL terminating character is required.

Parameters:
s Input string. First two characters of string must contain hex string. For example "8F" or "8f"
c Will contain the byte representation of the given string on return.
Returns:
1 if a valid hex value was found, or 0 if s did NOT contain a valid hex value

void memclr ( void *  dest,
WORD  size 
)

Fills the given number of bytes in the given array with 0

Parameters:
dest Pointer to memory area in RAM that has to be set to 0
size Number of consecutive bytes to set to 0
Examples:
ex_udp.c, ex_udp_echo.c, ex_udp_echo2.c, and ex_udp_init.c.

BOOL strBeginsWithIC ( char *  strRam,
ROM char *  strRom 
)

Test if given string in RAM begins with given ROM string, and Ignores Case. The ROM string has to be in upper case.

Parameters:
strRam Pointer to string contained in RAM. This tring does not have to be NULL terminated.
strRom Pointer to null terminated string contained in ROM
Returns:
Returns TRUE if RAM string begins with ROM string

BYTE strcmpee2ram ( char *  strRam,
WORD  strEe 
)

Compare two strings.

Parameters:
strRam Pointer to null terminated string contained in RAM
strEe Address (offset) in EEPROM of null terminated string
Returns:
Returns 0 if both strings are the same, else non 0

BYTE strcpyee2ram ( char *  strDst,
WORD  strSrc,
BYTE  len 
)

Copies the source string (in EEPROM) to the given destination in buffer in RAM. Characters in strSrc are copied up to, and including, the terminating null character strSrc.

Parameters:
strDst Pointer to RAM buffer where EEPROM string will be copied to
strSrc Source address (offset) in the EEPROM
len The maximum string length that is allowed to be written (excluding NULL terminating char). If the source string is longer then this value, the destination will be truncated with a NULL! For example, if len = 8, then that string can have a maximum of 8 characters = 8 + NULL. The destination must always have len + 1 positions available!
Returns:
Returns the number of bytes written, excluding the terminating null. For example, if 8 is returned, then 8 characters + NULL terminating char were written.

BYTE strcpyram2ee ( WORD  strDst,
char *  strSrc,
BYTE  len 
)

Copies the source string (in RAM) to the given destination in EEPROM. Characters in strSrc are copied up to, and including, the terminating null character strSrc.

Parameters:
strSrc Pointer to null terminated Source string contained in RAM.
strDst Destination address (offset) in the EEPROM
len The maximum string length that is allowed to be written (excluding NULL terminating char). If the source string is longer then this value, the destination will be truncated with a NULL! To disable length checking, set this value to 255. For example, if len = 8, then that string can have a maximum of 8 characters = 8 + NULL. The destination must always have len + 1 positions available!
Returns:
Returns the number of bytes written, excluding the terminating null. For example, if 8 is returned, then 8 characters + NULL terminating char were written.

DWORD swapl ( DWORD  v  ) 

WORD swaps ( WORD  v  ) 


Generated on Wed Feb 3 12:45:35 2010 for SBC65EC Web Server by  doxygen 1.5.8