Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
(ARM).Porting TCP-IP programmer's guide.Ver 1.6.pdf
Скачиваний:
43
Добавлен:
23.08.2013
Размер:
2.64 Mб
Скачать

Miscellaneous Library Functions

9.8userpass.c

The userpass.c file contains code to implement a simple user/password database. It implements the following functions:

add_user() on page 9-24

check_permit() on page 9-25.

9.8.1add_user()

This function is used to add a username and password to the database.

Syntax

int add_user(char *username, char *password, void *permissions)

where:

 

username

Is the name of the user to add.

password

Is the user password.

permissions

Is unused (see Usage below).

Return value

Returns one of the following:

TRUE

If the user/password combination was accepted.

FALSE

If the user/password combination was not accepted.

Usage

The username and password combination specified is added to the table of valid users. The permissions parameter is ignored in the example applications and in this library implementation. However, it could be used for checking that the user has the required access permissions for the operation requested.

The number of users is limited by the value NUM_NETUSERS, defined in userpass.h. The maximum user name and password length are limited by the value

MAX_USERLENGTH, defined in userpass.h.

9-24

Copyright © 1998-2001 ARM Limited. All rights reserved.

ARM DUI 0144B

Miscellaneous Library Functions

9.8.2check_permit()

This function is used to authenticate users.

Syntax

int check_permit(char *username, char *password, int appcode, void *permissions)

where:

username

Is the name of the user to check.

password

Is the password that the user has entered.

appcode

Is the application asking for authentication (see Usage below).

permissions

 

 

is unused (see Usage below).

Return value

Returns one of the following:

TRUE

If the user has been successfully authenticated.

FALSE

If the user was not authenticated.

Usage

The check_permit() function is called by an application when it wishes to check if a particular user is authorized to use that application. The username and password values are as entered by the end user, and the appcode is selected from the list in userpass.h. Like add_user(), the permissions parameter is unused in the example applications and in this library implementation, but can be used for checking that the user has the required access permissions for a specific operation, such as writing a system file.

The example implementation of check_permit() simply performs a string comparison of the password and username, and if the two match, it is regarded as a positive authentication. Your implementation must implement a proper password authenticating mechanism in order to be secure.

ARM DUI 0144B

Copyright © 1998-2001 ARM Limited. All rights reserved.

9-25

Miscellaneous Library Functions

9-26

Copyright © 1998-2001 ARM Limited. All rights reserved.

ARM DUI 0144B

Chapter 10

Internal Functions

This chapter contains a list of internal routines that may be useful to programmers writing customized applications with the stack. These functions are a subset of the routines in the libraries that could be of interest to a TCP/IP application or network interface writer. It contains the following sections:

ARP routines on page 10-2

IP routines on page 10-4

ICMP routines on page 10-14.

ARM DUI 0144B

Copyright © 1998-2001 ARM Limited. All rights reserved.

10-1