mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-12 01:53:07 +03:00
lwip2: build: include and lib
This commit is contained in:
committed by
Ivan Grokhotkov
parent
84cf2f4b5e
commit
7315095e46
2
tools/sdk/lwip2/include/lwip/apps/FILES
Normal file
2
tools/sdk/lwip2/include/lwip/apps/FILES
Normal file
@ -0,0 +1,2 @@
|
||||
This directory contains application headers.
|
||||
Every application shall provide one api file APP.h and optionally one options file APP_opts.h
|
103
tools/sdk/lwip2/include/lwip/apps/fs.h
Normal file
103
tools/sdk/lwip2/include/lwip/apps/fs.h
Normal file
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_APPS_FS_H
|
||||
#define LWIP_HDR_APPS_FS_H
|
||||
|
||||
#include "httpd_opts.h"
|
||||
#include "lwip/err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define FS_READ_EOF -1
|
||||
#define FS_READ_DELAYED -2
|
||||
|
||||
#if HTTPD_PRECALCULATED_CHECKSUM
|
||||
struct fsdata_chksum {
|
||||
u32_t offset;
|
||||
u16_t chksum;
|
||||
u16_t len;
|
||||
};
|
||||
#endif /* HTTPD_PRECALCULATED_CHECKSUM */
|
||||
|
||||
#define FS_FILE_FLAGS_HEADER_INCLUDED 0x01
|
||||
#define FS_FILE_FLAGS_HEADER_PERSISTENT 0x02
|
||||
|
||||
struct fs_file {
|
||||
const char *data;
|
||||
int len;
|
||||
int index;
|
||||
void *pextension;
|
||||
#if HTTPD_PRECALCULATED_CHECKSUM
|
||||
const struct fsdata_chksum *chksum;
|
||||
u16_t chksum_count;
|
||||
#endif /* HTTPD_PRECALCULATED_CHECKSUM */
|
||||
u8_t flags;
|
||||
#if LWIP_HTTPD_CUSTOM_FILES
|
||||
u8_t is_custom_file;
|
||||
#endif /* LWIP_HTTPD_CUSTOM_FILES */
|
||||
#if LWIP_HTTPD_FILE_STATE
|
||||
void *state;
|
||||
#endif /* LWIP_HTTPD_FILE_STATE */
|
||||
};
|
||||
|
||||
#if LWIP_HTTPD_FS_ASYNC_READ
|
||||
typedef void (*fs_wait_cb)(void *arg);
|
||||
#endif /* LWIP_HTTPD_FS_ASYNC_READ */
|
||||
|
||||
err_t fs_open(struct fs_file *file, const char *name);
|
||||
void fs_close(struct fs_file *file);
|
||||
#if LWIP_HTTPD_DYNAMIC_FILE_READ
|
||||
#if LWIP_HTTPD_FS_ASYNC_READ
|
||||
int fs_read_async(struct fs_file *file, char *buffer, int count, fs_wait_cb callback_fn, void *callback_arg);
|
||||
#else /* LWIP_HTTPD_FS_ASYNC_READ */
|
||||
int fs_read(struct fs_file *file, char *buffer, int count);
|
||||
#endif /* LWIP_HTTPD_FS_ASYNC_READ */
|
||||
#endif /* LWIP_HTTPD_DYNAMIC_FILE_READ */
|
||||
#if LWIP_HTTPD_FS_ASYNC_READ
|
||||
int fs_is_file_ready(struct fs_file *file, fs_wait_cb callback_fn, void *callback_arg);
|
||||
#endif /* LWIP_HTTPD_FS_ASYNC_READ */
|
||||
int fs_bytes_left(struct fs_file *file);
|
||||
|
||||
#if LWIP_HTTPD_FILE_STATE
|
||||
/** This user-defined function is called when a file is opened. */
|
||||
void *fs_state_init(struct fs_file *file, const char *name);
|
||||
/** This user-defined function is called when a file is closed. */
|
||||
void fs_state_free(struct fs_file *file, void *state);
|
||||
#endif /* #if LWIP_HTTPD_FILE_STATE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_FS_H */
|
236
tools/sdk/lwip2/include/lwip/apps/httpd.h
Normal file
236
tools/sdk/lwip2/include/lwip/apps/httpd.h
Normal file
@ -0,0 +1,236 @@
|
||||
/**
|
||||
* @file
|
||||
* HTTP server
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* This version of the file has been modified by Texas Instruments to offer
|
||||
* simple server-side-include (SSI) and Common Gateway Interface (CGI)
|
||||
* capability.
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_APPS_HTTPD_H
|
||||
#define LWIP_HDR_APPS_HTTPD_H
|
||||
|
||||
#include "httpd_opts.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/pbuf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if LWIP_HTTPD_CGI
|
||||
|
||||
/*
|
||||
* Function pointer for a CGI script handler.
|
||||
*
|
||||
* This function is called each time the HTTPD server is asked for a file
|
||||
* whose name was previously registered as a CGI function using a call to
|
||||
* http_set_cgi_handler. The iIndex parameter provides the index of the
|
||||
* CGI within the ppcURLs array passed to http_set_cgi_handler. Parameters
|
||||
* pcParam and pcValue provide access to the parameters provided along with
|
||||
* the URI. iNumParams provides a count of the entries in the pcParam and
|
||||
* pcValue arrays. Each entry in the pcParam array contains the name of a
|
||||
* parameter with the corresponding entry in the pcValue array containing the
|
||||
* value for that parameter. Note that pcParam may contain multiple elements
|
||||
* with the same name if, for example, a multi-selection list control is used
|
||||
* in the form generating the data.
|
||||
*
|
||||
* The function should return a pointer to a character string which is the
|
||||
* path and filename of the response that is to be sent to the connected
|
||||
* browser, for example "/thanks.htm" or "/response/error.ssi".
|
||||
*
|
||||
* The maximum number of parameters that will be passed to this function via
|
||||
* iNumParams is defined by LWIP_HTTPD_MAX_CGI_PARAMETERS. Any parameters in the incoming
|
||||
* HTTP request above this number will be discarded.
|
||||
*
|
||||
* Requests intended for use by this CGI mechanism must be sent using the GET
|
||||
* method (which encodes all parameters within the URI rather than in a block
|
||||
* later in the request). Attempts to use the POST method will result in the
|
||||
* request being ignored.
|
||||
*
|
||||
*/
|
||||
typedef const char *(*tCGIHandler)(int iIndex, int iNumParams, char *pcParam[],
|
||||
char *pcValue[]);
|
||||
|
||||
/*
|
||||
* Structure defining the base filename (URL) of a CGI and the associated
|
||||
* function which is to be called when that URL is requested.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
const char *pcCGIName;
|
||||
tCGIHandler pfnCGIHandler;
|
||||
} tCGI;
|
||||
|
||||
void http_set_cgi_handlers(const tCGI *pCGIs, int iNumHandlers);
|
||||
|
||||
#endif /* LWIP_HTTPD_CGI */
|
||||
|
||||
#if LWIP_HTTPD_CGI || LWIP_HTTPD_CGI_SSI
|
||||
|
||||
#if LWIP_HTTPD_CGI_SSI
|
||||
/** Define this generic CGI handler in your application.
|
||||
* It is called once for every URI with parameters.
|
||||
* The parameters can be stored to
|
||||
*/
|
||||
extern void httpd_cgi_handler(const char* uri, int iNumParams, char **pcParam, char **pcValue
|
||||
#if defined(LWIP_HTTPD_FILE_STATE) && LWIP_HTTPD_FILE_STATE
|
||||
, void *connection_state
|
||||
#endif /* LWIP_HTTPD_FILE_STATE */
|
||||
);
|
||||
#endif /* LWIP_HTTPD_CGI_SSI */
|
||||
|
||||
#endif /* LWIP_HTTPD_CGI || LWIP_HTTPD_CGI_SSI */
|
||||
|
||||
#if LWIP_HTTPD_SSI
|
||||
|
||||
/*
|
||||
* Function pointer for the SSI tag handler callback.
|
||||
*
|
||||
* This function will be called each time the HTTPD server detects a tag of the
|
||||
* form <!--#name--> in a .shtml, .ssi or .shtm file where "name" appears as
|
||||
* one of the tags supplied to http_set_ssi_handler in the ppcTags array. The
|
||||
* returned insert string, which will be appended after the the string
|
||||
* "<!--#name-->" in file sent back to the client,should be written to pointer
|
||||
* pcInsert. iInsertLen contains the size of the buffer pointed to by
|
||||
* pcInsert. The iIndex parameter provides the zero-based index of the tag as
|
||||
* found in the ppcTags array and identifies the tag that is to be processed.
|
||||
*
|
||||
* The handler returns the number of characters written to pcInsert excluding
|
||||
* any terminating NULL or a negative number to indicate a failure (tag not
|
||||
* recognized, for example).
|
||||
*
|
||||
* Note that the behavior of this SSI mechanism is somewhat different from the
|
||||
* "normal" SSI processing as found in, for example, the Apache web server. In
|
||||
* this case, the inserted text is appended following the SSI tag rather than
|
||||
* replacing the tag entirely. This allows for an implementation that does not
|
||||
* require significant additional buffering of output data yet which will still
|
||||
* offer usable SSI functionality. One downside to this approach is when
|
||||
* attempting to use SSI within JavaScript. The SSI tag is structured to
|
||||
* resemble an HTML comment but this syntax does not constitute a comment
|
||||
* within JavaScript and, hence, leaving the tag in place will result in
|
||||
* problems in these cases. To work around this, any SSI tag which needs to
|
||||
* output JavaScript code must do so in an encapsulated way, sending the whole
|
||||
* HTML <script>...</script> section as a single include.
|
||||
*/
|
||||
typedef u16_t (*tSSIHandler)(
|
||||
#if LWIP_HTTPD_SSI_RAW
|
||||
const char* ssi_tag_name,
|
||||
#else /* LWIP_HTTPD_SSI_RAW */
|
||||
int iIndex,
|
||||
#endif /* LWIP_HTTPD_SSI_RAW */
|
||||
char *pcInsert, int iInsertLen
|
||||
#if LWIP_HTTPD_SSI_MULTIPART
|
||||
, u16_t current_tag_part, u16_t *next_tag_part
|
||||
#endif /* LWIP_HTTPD_SSI_MULTIPART */
|
||||
#if defined(LWIP_HTTPD_FILE_STATE) && LWIP_HTTPD_FILE_STATE
|
||||
, void *connection_state
|
||||
#endif /* LWIP_HTTPD_FILE_STATE */
|
||||
);
|
||||
|
||||
/** Set the SSI handler function
|
||||
* (if LWIP_HTTPD_SSI_RAW==1, only the first argument is used)
|
||||
*/
|
||||
void http_set_ssi_handler(tSSIHandler pfnSSIHandler,
|
||||
const char **ppcTags, int iNumTags);
|
||||
|
||||
/** For LWIP_HTTPD_SSI_RAW==1, return this to indicate the tag is unknown.
|
||||
* In this case, the webserver writes a warning into the page.
|
||||
* You can also just return 0 to write nothing for unknown tags.
|
||||
*/
|
||||
#define HTTPD_SSI_TAG_UNKNOWN 0xFFFF
|
||||
|
||||
#endif /* LWIP_HTTPD_SSI */
|
||||
|
||||
#if LWIP_HTTPD_SUPPORT_POST
|
||||
|
||||
/* These functions must be implemented by the application */
|
||||
|
||||
/** Called when a POST request has been received. The application can decide
|
||||
* whether to accept it or not.
|
||||
*
|
||||
* @param connection Unique connection identifier, valid until httpd_post_end
|
||||
* is called.
|
||||
* @param uri The HTTP header URI receiving the POST request.
|
||||
* @param http_request The raw HTTP request (the first packet, normally).
|
||||
* @param http_request_len Size of 'http_request'.
|
||||
* @param content_len Content-Length from HTTP header.
|
||||
* @param response_uri Filename of response file, to be filled when denying the
|
||||
* request
|
||||
* @param response_uri_len Size of the 'response_uri' buffer.
|
||||
* @param post_auto_wnd Set this to 0 to let the callback code handle window
|
||||
* updates by calling 'httpd_post_data_recved' (to throttle rx speed)
|
||||
* default is 1 (httpd handles window updates automatically)
|
||||
* @return ERR_OK: Accept the POST request, data may be passed in
|
||||
* another err_t: Deny the POST request, send back 'bad request'.
|
||||
*/
|
||||
err_t httpd_post_begin(void *connection, const char *uri, const char *http_request,
|
||||
u16_t http_request_len, int content_len, char *response_uri,
|
||||
u16_t response_uri_len, u8_t *post_auto_wnd);
|
||||
|
||||
/** Called for each pbuf of data that has been received for a POST.
|
||||
* ATTENTION: The application is responsible for freeing the pbufs passed in!
|
||||
*
|
||||
* @param connection Unique connection identifier.
|
||||
* @param p Received data.
|
||||
* @return ERR_OK: Data accepted.
|
||||
* another err_t: Data denied, http_post_get_response_uri will be called.
|
||||
*/
|
||||
err_t httpd_post_receive_data(void *connection, struct pbuf *p);
|
||||
|
||||
/** Called when all data is received or when the connection is closed.
|
||||
* The application must return the filename/URI of a file to send in response
|
||||
* to this POST request. If the response_uri buffer is untouched, a 404
|
||||
* response is returned.
|
||||
*
|
||||
* @param connection Unique connection identifier.
|
||||
* @param response_uri Filename of response file, to be filled when denying the request
|
||||
* @param response_uri_len Size of the 'response_uri' buffer.
|
||||
*/
|
||||
void httpd_post_finished(void *connection, char *response_uri, u16_t response_uri_len);
|
||||
|
||||
#if LWIP_HTTPD_POST_MANUAL_WND
|
||||
void httpd_post_data_recved(void *connection, u16_t recved_len);
|
||||
#endif /* LWIP_HTTPD_POST_MANUAL_WND */
|
||||
|
||||
#endif /* LWIP_HTTPD_SUPPORT_POST */
|
||||
|
||||
void httpd_init(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HTTPD_H */
|
323
tools/sdk/lwip2/include/lwip/apps/httpd_opts.h
Normal file
323
tools/sdk/lwip2/include/lwip/apps/httpd_opts.h
Normal file
@ -0,0 +1,323 @@
|
||||
/**
|
||||
* @file
|
||||
* HTTP server options list
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* This version of the file has been modified by Texas Instruments to offer
|
||||
* simple server-side-include (SSI) and Common Gateway Interface (CGI)
|
||||
* capability.
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_APPS_HTTPD_OPTS_H
|
||||
#define LWIP_HDR_APPS_HTTPD_OPTS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/**
|
||||
* @defgroup httpd_opts Options
|
||||
* @ingroup httpd
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** Set this to 1 to support CGI (old style) */
|
||||
#if !defined LWIP_HTTPD_CGI || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_CGI 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to support CGI (new style) */
|
||||
#if !defined LWIP_HTTPD_CGI_SSI || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_CGI_SSI 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to support SSI (Server-Side-Includes) */
|
||||
#if !defined LWIP_HTTPD_SSI || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_SSI 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to implement an SSI tag handler callback that gets a const char*
|
||||
* to the tag (instead of an index into a pre-registered array of known tags) */
|
||||
#if !defined LWIP_HTTPD_SSI_RAW || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_SSI_RAW 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to support HTTP POST */
|
||||
#if !defined LWIP_HTTPD_SUPPORT_POST || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_SUPPORT_POST 0
|
||||
#endif
|
||||
|
||||
/* The maximum number of parameters that the CGI handler can be sent. */
|
||||
#if !defined LWIP_HTTPD_MAX_CGI_PARAMETERS || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_MAX_CGI_PARAMETERS 16
|
||||
#endif
|
||||
|
||||
/** LWIP_HTTPD_SSI_MULTIPART==1: SSI handler function is called with 2 more
|
||||
* arguments indicating a counter for insert string that are too long to be
|
||||
* inserted at once: the SSI handler function must then set 'next_tag_part'
|
||||
* which will be passed back to it in the next call. */
|
||||
#if !defined LWIP_HTTPD_SSI_MULTIPART || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_SSI_MULTIPART 0
|
||||
#endif
|
||||
|
||||
/* The maximum length of the string comprising the tag name */
|
||||
#if !defined LWIP_HTTPD_MAX_TAG_NAME_LEN || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_MAX_TAG_NAME_LEN 8
|
||||
#endif
|
||||
|
||||
/* The maximum length of string that can be returned to replace any given tag */
|
||||
#if !defined LWIP_HTTPD_MAX_TAG_INSERT_LEN || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_MAX_TAG_INSERT_LEN 192
|
||||
#endif
|
||||
|
||||
#if !defined LWIP_HTTPD_POST_MANUAL_WND || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_POST_MANUAL_WND 0
|
||||
#endif
|
||||
|
||||
/** This string is passed in the HTTP header as "Server: " */
|
||||
#if !defined HTTPD_SERVER_AGENT || defined __DOXYGEN__
|
||||
#define HTTPD_SERVER_AGENT "lwIP/" LWIP_VERSION_STRING " (http://savannah.nongnu.org/projects/lwip)"
|
||||
#endif
|
||||
|
||||
/** Set this to 1 if you want to include code that creates HTTP headers
|
||||
* at runtime. Default is off: HTTP headers are then created statically
|
||||
* by the makefsdata tool. Static headers mean smaller code size, but
|
||||
* the (readonly) fsdata will grow a bit as every file includes the HTTP
|
||||
* header. */
|
||||
#if !defined LWIP_HTTPD_DYNAMIC_HEADERS || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_DYNAMIC_HEADERS 0
|
||||
#endif
|
||||
|
||||
#if !defined HTTPD_DEBUG || defined __DOXYGEN__
|
||||
#define HTTPD_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to use a memp pool for allocating
|
||||
* struct http_state instead of the heap.
|
||||
*/
|
||||
#if !defined HTTPD_USE_MEM_POOL || defined __DOXYGEN__
|
||||
#define HTTPD_USE_MEM_POOL 0
|
||||
#endif
|
||||
|
||||
/** The server port for HTTPD to use */
|
||||
#if !defined HTTPD_SERVER_PORT || defined __DOXYGEN__
|
||||
#define HTTPD_SERVER_PORT 80
|
||||
#endif
|
||||
|
||||
/** Maximum retries before the connection is aborted/closed.
|
||||
* - number of times pcb->poll is called -> default is 4*500ms = 2s;
|
||||
* - reset when pcb->sent is called
|
||||
*/
|
||||
#if !defined HTTPD_MAX_RETRIES || defined __DOXYGEN__
|
||||
#define HTTPD_MAX_RETRIES 4
|
||||
#endif
|
||||
|
||||
/** The poll delay is X*500ms */
|
||||
#if !defined HTTPD_POLL_INTERVAL || defined __DOXYGEN__
|
||||
#define HTTPD_POLL_INTERVAL 4
|
||||
#endif
|
||||
|
||||
/** Priority for tcp pcbs created by HTTPD (very low by default).
|
||||
* Lower priorities get killed first when running out of memory.
|
||||
*/
|
||||
#if !defined HTTPD_TCP_PRIO || defined __DOXYGEN__
|
||||
#define HTTPD_TCP_PRIO TCP_PRIO_MIN
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to enable timing each file sent */
|
||||
#if !defined LWIP_HTTPD_TIMING || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_TIMING 0
|
||||
#endif
|
||||
/** Set this to 1 to enable timing each file sent */
|
||||
#if !defined HTTPD_DEBUG_TIMING || defined __DOXYGEN__
|
||||
#define HTTPD_DEBUG_TIMING LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
/** Set this to one to show error pages when parsing a request fails instead
|
||||
of simply closing the connection. */
|
||||
#if !defined LWIP_HTTPD_SUPPORT_EXTSTATUS || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_SUPPORT_EXTSTATUS 0
|
||||
#endif
|
||||
|
||||
/** Set this to 0 to drop support for HTTP/0.9 clients (to save some bytes) */
|
||||
#if !defined LWIP_HTTPD_SUPPORT_V09 || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_SUPPORT_V09 1
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to enable HTTP/1.1 persistent connections.
|
||||
* ATTENTION: If the generated file system includes HTTP headers, these must
|
||||
* include the "Connection: keep-alive" header (pass argument "-11" to makefsdata).
|
||||
*/
|
||||
#if !defined LWIP_HTTPD_SUPPORT_11_KEEPALIVE || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_SUPPORT_11_KEEPALIVE 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to support HTTP request coming in in multiple packets/pbufs */
|
||||
#if !defined LWIP_HTTPD_SUPPORT_REQUESTLIST || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_SUPPORT_REQUESTLIST 1
|
||||
#endif
|
||||
|
||||
#if LWIP_HTTPD_SUPPORT_REQUESTLIST
|
||||
/** Number of rx pbufs to enqueue to parse an incoming request (up to the first
|
||||
newline) */
|
||||
#if !defined LWIP_HTTPD_REQ_QUEUELEN || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_REQ_QUEUELEN 5
|
||||
#endif
|
||||
|
||||
/** Number of (TCP payload-) bytes (in pbufs) to enqueue to parse and incoming
|
||||
request (up to the first double-newline) */
|
||||
#if !defined LWIP_HTTPD_REQ_BUFSIZE || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_REQ_BUFSIZE LWIP_HTTPD_MAX_REQ_LENGTH
|
||||
#endif
|
||||
|
||||
/** Defines the maximum length of a HTTP request line (up to the first CRLF,
|
||||
copied from pbuf into this a global buffer when pbuf- or packet-queues
|
||||
are received - otherwise the input pbuf is used directly) */
|
||||
#if !defined LWIP_HTTPD_MAX_REQ_LENGTH || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_MAX_REQ_LENGTH LWIP_MIN(1023, (LWIP_HTTPD_REQ_QUEUELEN * PBUF_POOL_BUFSIZE))
|
||||
#endif
|
||||
#endif /* LWIP_HTTPD_SUPPORT_REQUESTLIST */
|
||||
|
||||
/** This is the size of a static buffer used when URIs end with '/'.
|
||||
* In this buffer, the directory requested is concatenated with all the
|
||||
* configured default file names.
|
||||
* Set to 0 to disable checking default filenames on non-root directories.
|
||||
*/
|
||||
#if !defined LWIP_HTTPD_MAX_REQUEST_URI_LEN || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_MAX_REQUEST_URI_LEN 63
|
||||
#endif
|
||||
|
||||
/** Maximum length of the filename to send as response to a POST request,
|
||||
* filled in by the application when a POST is finished.
|
||||
*/
|
||||
#if !defined LWIP_HTTPD_POST_MAX_RESPONSE_URI_LEN || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_POST_MAX_RESPONSE_URI_LEN 63
|
||||
#endif
|
||||
|
||||
/** Set this to 0 to not send the SSI tag (default is on, so the tag will
|
||||
* be sent in the HTML page */
|
||||
#if !defined LWIP_HTTPD_SSI_INCLUDE_TAG || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_SSI_INCLUDE_TAG 1
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to call tcp_abort when tcp_close fails with memory error.
|
||||
* This can be used to prevent consuming all memory in situations where the
|
||||
* HTTP server has low priority compared to other communication. */
|
||||
#if !defined LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to kill the oldest connection when running out of
|
||||
* memory for 'struct http_state' or 'struct http_ssi_state'.
|
||||
* ATTENTION: This puts all connections on a linked list, so may be kind of slow.
|
||||
*/
|
||||
#if !defined LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to send URIs without extension without headers
|
||||
* (who uses this at all??) */
|
||||
#if !defined LWIP_HTTPD_OMIT_HEADER_FOR_EXTENSIONLESS_URI || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_OMIT_HEADER_FOR_EXTENSIONLESS_URI 0
|
||||
#endif
|
||||
|
||||
/** Default: Tags are sent from struct http_state and are therefore volatile */
|
||||
#if !defined HTTP_IS_TAG_VOLATILE || defined __DOXYGEN__
|
||||
#define HTTP_IS_TAG_VOLATILE(ptr) TCP_WRITE_FLAG_COPY
|
||||
#endif
|
||||
|
||||
/* By default, the httpd is limited to send 2*pcb->mss to keep resource usage low
|
||||
when http is not an important protocol in the device. */
|
||||
#if !defined HTTPD_LIMIT_SENDING_TO_2MSS || defined __DOXYGEN__
|
||||
#define HTTPD_LIMIT_SENDING_TO_2MSS 1
|
||||
#endif
|
||||
|
||||
/* Define this to a function that returns the maximum amount of data to enqueue.
|
||||
The function have this signature: u16_t fn(struct tcp_pcb* pcb); */
|
||||
#if !defined HTTPD_MAX_WRITE_LEN || defined __DOXYGEN__
|
||||
#if HTTPD_LIMIT_SENDING_TO_2MSS
|
||||
#define HTTPD_MAX_WRITE_LEN(pcb) (2 * tcp_mss(pcb))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*------------------- FS OPTIONS -------------------*/
|
||||
|
||||
/** Set this to 1 and provide the functions:
|
||||
* - "int fs_open_custom(struct fs_file *file, const char *name)"
|
||||
* Called first for every opened file to allow opening files
|
||||
* that are not included in fsdata(_custom).c
|
||||
* - "void fs_close_custom(struct fs_file *file)"
|
||||
* Called to free resources allocated by fs_open_custom().
|
||||
*/
|
||||
#if !defined LWIP_HTTPD_CUSTOM_FILES || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_CUSTOM_FILES 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to support fs_read() to dynamically read file data.
|
||||
* Without this (default=off), only one-block files are supported,
|
||||
* and the contents must be ready after fs_open().
|
||||
*/
|
||||
#if !defined LWIP_HTTPD_DYNAMIC_FILE_READ || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_DYNAMIC_FILE_READ 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to include an application state argument per file
|
||||
* that is opened. This allows to keep a state per connection/file.
|
||||
*/
|
||||
#if !defined LWIP_HTTPD_FILE_STATE || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_FILE_STATE 0
|
||||
#endif
|
||||
|
||||
/** HTTPD_PRECALCULATED_CHECKSUM==1: include precompiled checksums for
|
||||
* predefined (MSS-sized) chunks of the files to prevent having to calculate
|
||||
* the checksums at runtime. */
|
||||
#if !defined HTTPD_PRECALCULATED_CHECKSUM || defined __DOXYGEN__
|
||||
#define HTTPD_PRECALCULATED_CHECKSUM 0
|
||||
#endif
|
||||
|
||||
/** LWIP_HTTPD_FS_ASYNC_READ==1: support asynchronous read operations
|
||||
* (fs_read_async returns FS_READ_DELAYED and calls a callback when finished).
|
||||
*/
|
||||
#if !defined LWIP_HTTPD_FS_ASYNC_READ || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_FS_ASYNC_READ 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to include "fsdata_custom.c" instead of "fsdata.c" for the
|
||||
* file system (to prevent changing the file included in CVS) */
|
||||
#if !defined HTTPD_USE_CUSTOM_FSDATA || defined __DOXYGEN__
|
||||
#define HTTPD_USE_CUSTOM_FSDATA 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* LWIP_HDR_APPS_HTTPD_OPTS_H */
|
84
tools/sdk/lwip2/include/lwip/apps/lwiperf.h
Normal file
84
tools/sdk/lwip2/include/lwip/apps/lwiperf.h
Normal file
@ -0,0 +1,84 @@
|
||||
/**
|
||||
* @file
|
||||
* lwIP iPerf server implementation
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2014 Simon Goldschmidt
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Simon Goldschmidt
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_APPS_LWIPERF_H
|
||||
#define LWIP_HDR_APPS_LWIPERF_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LWIPERF_TCP_PORT_DEFAULT 5001
|
||||
|
||||
/** lwIPerf test results */
|
||||
enum lwiperf_report_type
|
||||
{
|
||||
/** The server side test is done */
|
||||
LWIPERF_TCP_DONE_SERVER,
|
||||
/** The client side test is done */
|
||||
LWIPERF_TCP_DONE_CLIENT,
|
||||
/** Local error lead to test abort */
|
||||
LWIPERF_TCP_ABORTED_LOCAL,
|
||||
/** Data check error lead to test abort */
|
||||
LWIPERF_TCP_ABORTED_LOCAL_DATAERROR,
|
||||
/** Transmit error lead to test abort */
|
||||
LWIPERF_TCP_ABORTED_LOCAL_TXERROR,
|
||||
/** Remote side aborted the test */
|
||||
LWIPERF_TCP_ABORTED_REMOTE
|
||||
};
|
||||
|
||||
/** Prototype of a report function that is called when a session is finished.
|
||||
This report function can show the test results.
|
||||
@param report_type contains the test result */
|
||||
typedef void (*lwiperf_report_fn)(void *arg, enum lwiperf_report_type report_type,
|
||||
const ip_addr_t* local_addr, u16_t local_port, const ip_addr_t* remote_addr, u16_t remote_port,
|
||||
u32_t bytes_transferred, u32_t ms_duration, u32_t bandwidth_kbitpsec);
|
||||
|
||||
|
||||
void* lwiperf_start_tcp_server(const ip_addr_t* local_addr, u16_t local_port,
|
||||
lwiperf_report_fn report_fn, void* report_arg);
|
||||
void* lwiperf_start_tcp_server_default(lwiperf_report_fn report_fn, void* report_arg);
|
||||
void lwiperf_abort(void* lwiperf_session);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_LWIPERF_H */
|
69
tools/sdk/lwip2/include/lwip/apps/mdns.h
Normal file
69
tools/sdk/lwip2/include/lwip/apps/mdns.h
Normal file
@ -0,0 +1,69 @@
|
||||
/**
|
||||
* @file
|
||||
* MDNS responder
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015 Verisure Innovation AB
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Erik Ekman <erik@kryo.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_MDNS_H
|
||||
#define LWIP_HDR_MDNS_H
|
||||
|
||||
#include "lwip/apps/mdns_opts.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
#if LWIP_MDNS_RESPONDER
|
||||
|
||||
enum mdns_sd_proto {
|
||||
DNSSD_PROTO_UDP = 0,
|
||||
DNSSD_PROTO_TCP = 1
|
||||
};
|
||||
|
||||
#define MDNS_LABEL_MAXLEN 63
|
||||
|
||||
struct mdns_host;
|
||||
struct mdns_service;
|
||||
|
||||
/** Callback function to add text to a reply, called when generating the reply */
|
||||
typedef void (*service_get_txt_fn_t)(struct mdns_service *service, void *txt_userdata);
|
||||
|
||||
void mdns_resp_init(void);
|
||||
|
||||
err_t mdns_resp_add_netif(struct netif *netif, const char *hostname, u32_t dns_ttl);
|
||||
err_t mdns_resp_remove_netif(struct netif *netif);
|
||||
|
||||
err_t mdns_resp_add_service(struct netif *netif, const char *name, const char *service, enum mdns_sd_proto proto, u16_t port, u32_t dns_ttl, service_get_txt_fn_t txt_fn, void *txt_userdata);
|
||||
err_t mdns_resp_add_service_txtitem(struct mdns_service *service, const char *txt, u8_t txt_len);
|
||||
void mdns_resp_netif_settings_changed(struct netif *netif);
|
||||
|
||||
#endif /* LWIP_MDNS_RESPONDER */
|
||||
|
||||
#endif /* LWIP_HDR_MDNS_H */
|
74
tools/sdk/lwip2/include/lwip/apps/mdns_opts.h
Normal file
74
tools/sdk/lwip2/include/lwip/apps/mdns_opts.h
Normal file
@ -0,0 +1,74 @@
|
||||
/**
|
||||
* @file
|
||||
* MDNS responder
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015 Verisure Innovation AB
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Erik Ekman <erik@kryo.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_APPS_MDNS_OPTS_H
|
||||
#define LWIP_HDR_APPS_MDNS_OPTS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/**
|
||||
* @defgroup mdns_opts Options
|
||||
* @ingroup mdns
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* LWIP_MDNS_RESPONDER==1: Turn on multicast DNS module. UDP must be available for MDNS
|
||||
* transport. IGMP is needed for IPv4 multicast.
|
||||
*/
|
||||
#ifndef LWIP_MDNS_RESPONDER
|
||||
#define LWIP_MDNS_RESPONDER 0
|
||||
#endif /* LWIP_MDNS_RESPONDER */
|
||||
|
||||
/** The maximum number of services per netif */
|
||||
#ifndef MDNS_MAX_SERVICES
|
||||
#define MDNS_MAX_SERVICES 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MDNS_DEBUG: Enable debugging for multicast DNS.
|
||||
*/
|
||||
#ifndef MDNS_DEBUG
|
||||
#define MDNS_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* LWIP_HDR_APPS_MDNS_OPTS_H */
|
||||
|
66
tools/sdk/lwip2/include/lwip/apps/mdns_priv.h
Normal file
66
tools/sdk/lwip2/include/lwip/apps/mdns_priv.h
Normal file
@ -0,0 +1,66 @@
|
||||
/**
|
||||
* @file
|
||||
* MDNS responder private definitions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015 Verisure Innovation AB
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Erik Ekman <erik@kryo.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_MDNS_PRIV_H
|
||||
#define LWIP_HDR_MDNS_PRIV_H
|
||||
|
||||
#include "lwip/apps/mdns_opts.h"
|
||||
#include "lwip/pbuf.h"
|
||||
|
||||
#if LWIP_MDNS_RESPONDER
|
||||
|
||||
/* Domain struct and methods - visible for unit tests */
|
||||
|
||||
#define MDNS_DOMAIN_MAXLEN 256
|
||||
#define MDNS_READNAME_ERROR 0xFFFF
|
||||
|
||||
struct mdns_domain {
|
||||
/* Encoded domain name */
|
||||
u8_t name[MDNS_DOMAIN_MAXLEN];
|
||||
/* Total length of domain name, including zero */
|
||||
u16_t length;
|
||||
/* Set if compression of this domain is not allowed */
|
||||
u8_t skip_compression;
|
||||
};
|
||||
|
||||
err_t mdns_domain_add_label(struct mdns_domain *domain, const char *label, u8_t len);
|
||||
u16_t mdns_readname(struct pbuf *p, u16_t offset, struct mdns_domain *domain);
|
||||
int mdns_domain_eq(struct mdns_domain *a, struct mdns_domain *b);
|
||||
u16_t mdns_compress_domain(struct pbuf *pbuf, u16_t *offset, struct mdns_domain *domain);
|
||||
|
||||
#endif /* LWIP_MDNS_RESPONDER */
|
||||
|
||||
#endif /* LWIP_HDR_MDNS_PRIV_H */
|
244
tools/sdk/lwip2/include/lwip/apps/mqtt.h
Normal file
244
tools/sdk/lwip2/include/lwip/apps/mqtt.h
Normal file
@ -0,0 +1,244 @@
|
||||
/**
|
||||
* @file
|
||||
* MQTT client
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016 Erik Andersson
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Erik Andersson
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_APPS_MQTT_CLIENT_H
|
||||
#define LWIP_HDR_APPS_MQTT_CLIENT_H
|
||||
|
||||
#include "lwip/apps/mqtt_opts.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct mqtt_client_t mqtt_client_t;
|
||||
|
||||
/** @ingroup mqtt
|
||||
* Default MQTT port */
|
||||
#define MQTT_PORT 1883
|
||||
|
||||
/*---------------------------------------------------------------------------------------------- */
|
||||
/* Connection with server */
|
||||
|
||||
/**
|
||||
* @ingroup mqtt
|
||||
* Client information and connection parameters */
|
||||
struct mqtt_connect_client_info_t {
|
||||
/** Client identifier, must be set by caller */
|
||||
const char *client_id;
|
||||
/** User name and password, set to NULL if not used */
|
||||
const char* client_user;
|
||||
const char* client_pass;
|
||||
/** keep alive time in seconds, 0 to disable keep alive functionality*/
|
||||
u16_t keep_alive;
|
||||
/** will topic, set to NULL if will is not to be used,
|
||||
will_msg, will_qos and will retain are then ignored */
|
||||
const char* will_topic;
|
||||
const char* will_msg;
|
||||
u8_t will_qos;
|
||||
u8_t will_retain;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup mqtt
|
||||
* Connection status codes */
|
||||
typedef enum
|
||||
{
|
||||
MQTT_CONNECT_ACCEPTED = 0,
|
||||
MQTT_CONNECT_REFUSED_PROTOCOL_VERSION = 1,
|
||||
MQTT_CONNECT_REFUSED_IDENTIFIER = 2,
|
||||
MQTT_CONNECT_REFUSED_SERVER = 3,
|
||||
MQTT_CONNECT_REFUSED_USERNAME_PASS = 4,
|
||||
MQTT_CONNECT_REFUSED_NOT_AUTHORIZED_ = 5,
|
||||
MQTT_CONNECT_DISCONNECTED = 256,
|
||||
MQTT_CONNECT_TIMEOUT = 257
|
||||
} mqtt_connection_status_t;
|
||||
|
||||
/**
|
||||
* @ingroup mqtt
|
||||
* Function prototype for mqtt connection status callback. Called when
|
||||
* client has connected to the server after initiating a mqtt connection attempt by
|
||||
* calling mqtt_connect() or when connection is closed by server or an error
|
||||
*
|
||||
* @param client MQTT client itself
|
||||
* @param arg Additional argument to pass to the callback function
|
||||
* @param status Connect result code or disconnection notification @see mqtt_connection_status_t
|
||||
*
|
||||
*/
|
||||
typedef void (*mqtt_connection_cb_t)(mqtt_client_t *client, void *arg, mqtt_connection_status_t status);
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup mqtt
|
||||
* Data callback flags */
|
||||
enum {
|
||||
/** Flag set when last fragment of data arrives in data callback */
|
||||
MQTT_DATA_FLAG_LAST = 1
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup mqtt
|
||||
* Function prototype for MQTT incoming publish data callback function. Called when data
|
||||
* arrives to a subscribed topic @see mqtt_subscribe
|
||||
*
|
||||
* @param arg Additional argument to pass to the callback function
|
||||
* @param data User data, pointed object, data may not be referenced after callback return,
|
||||
NULL is passed when all publish data are delivered
|
||||
* @param len Length of publish data fragment
|
||||
* @param flags MQTT_DATA_FLAG_LAST set when this call contains the last part of data from publish message
|
||||
*
|
||||
*/
|
||||
typedef void (*mqtt_incoming_data_cb_t)(void *arg, const u8_t *data, u16_t len, u8_t flags);
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup mqtt
|
||||
* Function prototype for MQTT incoming publish function. Called when an incoming publish
|
||||
* arrives to a subscribed topic @see mqtt_subscribe
|
||||
*
|
||||
* @param arg Additional argument to pass to the callback function
|
||||
* @param topic Zero terminated Topic text string, topic may not be referenced after callback return
|
||||
* @param tot_len Total length of publish data, if set to 0 (no publish payload) data callback will not be invoked
|
||||
*/
|
||||
typedef void (*mqtt_incoming_publish_cb_t)(void *arg, const char *topic, u32_t tot_len);
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup mqtt
|
||||
* Function prototype for mqtt request callback. Called when a subscribe, unsubscribe
|
||||
* or publish request has completed
|
||||
* @param arg Pointer to user data supplied when invoking request
|
||||
* @param err ERR_OK on success
|
||||
* ERR_TIMEOUT if no response was received within timeout,
|
||||
* ERR_ABRT if (un)subscribe was denied
|
||||
*/
|
||||
typedef void (*mqtt_request_cb_t)(void *arg, err_t err);
|
||||
|
||||
|
||||
/**
|
||||
* Pending request item, binds application callback to pending server requests
|
||||
*/
|
||||
struct mqtt_request_t
|
||||
{
|
||||
/** Next item in list, NULL means this is the last in chain,
|
||||
next pointing at itself means request is unallocated */
|
||||
struct mqtt_request_t *next;
|
||||
/** Callback to upper layer */
|
||||
mqtt_request_cb_t cb;
|
||||
void *arg;
|
||||
/** MQTT packet identifier */
|
||||
u16_t pkt_id;
|
||||
/** Expire time relative to element before this */
|
||||
u16_t timeout_diff;
|
||||
};
|
||||
|
||||
/** Ring buffer */
|
||||
struct mqtt_ringbuf_t {
|
||||
u16_t put;
|
||||
u16_t get;
|
||||
u8_t buf[MQTT_OUTPUT_RINGBUF_SIZE];
|
||||
};
|
||||
|
||||
/** MQTT client */
|
||||
struct mqtt_client_t
|
||||
{
|
||||
/** Timers and timeouts */
|
||||
u16_t cyclic_tick;
|
||||
u16_t keep_alive;
|
||||
u16_t server_watchdog;
|
||||
/** Packet identifier generator*/
|
||||
u16_t pkt_id_seq;
|
||||
/** Packet identifier of pending incoming publish */
|
||||
u16_t inpub_pkt_id;
|
||||
/** Connection state */
|
||||
u8_t conn_state;
|
||||
struct tcp_pcb *conn;
|
||||
/** Connection callback */
|
||||
void *connect_arg;
|
||||
mqtt_connection_cb_t connect_cb;
|
||||
/** Pending requests to server */
|
||||
struct mqtt_request_t *pend_req_queue;
|
||||
struct mqtt_request_t req_list[MQTT_REQ_MAX_IN_FLIGHT];
|
||||
void *inpub_arg;
|
||||
/** Incoming data callback */
|
||||
mqtt_incoming_data_cb_t data_cb;
|
||||
mqtt_incoming_publish_cb_t pub_cb;
|
||||
/** Input */
|
||||
u32_t msg_idx;
|
||||
u8_t rx_buffer[MQTT_VAR_HEADER_BUFFER_LEN];
|
||||
/** Output ring-buffer */
|
||||
struct mqtt_ringbuf_t output;
|
||||
};
|
||||
|
||||
|
||||
/** Connect to server */
|
||||
err_t mqtt_client_connect(mqtt_client_t *client, const ip_addr_t *ipaddr, u16_t port, mqtt_connection_cb_t cb, void *arg,
|
||||
const struct mqtt_connect_client_info_t *client_info);
|
||||
|
||||
/** Disconnect from server */
|
||||
void mqtt_disconnect(mqtt_client_t *client);
|
||||
|
||||
/** Create new client */
|
||||
mqtt_client_t *mqtt_client_new(void);
|
||||
|
||||
/** Check connection status */
|
||||
u8_t mqtt_client_is_connected(mqtt_client_t *client);
|
||||
|
||||
/** Set callback to call for incoming publish */
|
||||
void mqtt_set_inpub_callback(mqtt_client_t *client, mqtt_incoming_publish_cb_t,
|
||||
mqtt_incoming_data_cb_t data_cb, void *arg);
|
||||
|
||||
/** Common function for subscribe and unsubscribe */
|
||||
err_t mqtt_sub_unsub(mqtt_client_t *client, const char *topic, u8_t qos, mqtt_request_cb_t cb, void *arg, u8_t sub);
|
||||
|
||||
/** @ingroup mqtt
|
||||
*Subscribe to topic */
|
||||
#define mqtt_subscribe(client, topic, qos, cb, arg) mqtt_sub_unsub(client, topic, qos, cb, arg, 1)
|
||||
/** @ingroup mqtt
|
||||
* Unsubscribe to topic */
|
||||
#define mqtt_unsubscribe(client, topic, cb, arg) mqtt_sub_unsub(client, topic, 0, cb, arg, 0)
|
||||
|
||||
|
||||
/** Publish data to topic */
|
||||
err_t mqtt_publish(mqtt_client_t *client, const char *topic, const void *payload, u16_t payload_length, u8_t qos, u8_t retain,
|
||||
mqtt_request_cb_t cb, void *arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_MQTT_CLIENT_H */
|
103
tools/sdk/lwip2/include/lwip/apps/mqtt_opts.h
Normal file
103
tools/sdk/lwip2/include/lwip/apps/mqtt_opts.h
Normal file
@ -0,0 +1,103 @@
|
||||
/**
|
||||
* @file
|
||||
* MQTT client options
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016 Erik Andersson
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Erik Andersson
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_APPS_MQTT_OPTS_H
|
||||
#define LWIP_HDR_APPS_MQTT_OPTS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup mqtt_opts Options
|
||||
* @ingroup mqtt
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Output ring-buffer size, must be able to fit largest outgoing publish message topic+payloads
|
||||
*/
|
||||
#ifndef MQTT_OUTPUT_RINGBUF_SIZE
|
||||
#define MQTT_OUTPUT_RINGBUF_SIZE 256
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Number of bytes in receive buffer, must be at least the size of the longest incoming topic + 8
|
||||
* If one wants to avoid fragmented incoming publish, set length to max incoming topic length + max payload length + 8
|
||||
*/
|
||||
#ifndef MQTT_VAR_HEADER_BUFFER_LEN
|
||||
#define MQTT_VAR_HEADER_BUFFER_LEN 128
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Maximum number of pending subscribe, unsubscribe and publish requests to server .
|
||||
*/
|
||||
#ifndef MQTT_REQ_MAX_IN_FLIGHT
|
||||
#define MQTT_REQ_MAX_IN_FLIGHT 4
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Seconds between each cyclic timer call.
|
||||
*/
|
||||
#ifndef MQTT_CYCLIC_TIMER_INTERVAL
|
||||
#define MQTT_CYCLIC_TIMER_INTERVAL 5
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Publish, subscribe and unsubscribe request timeout in seconds.
|
||||
*/
|
||||
#ifndef MQTT_REQ_TIMEOUT
|
||||
#define MQTT_REQ_TIMEOUT 30
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Seconds for MQTT connect response timeout after sending connect request
|
||||
*/
|
||||
#ifndef MQTT_CONNECT_TIMOUT
|
||||
#define MQTT_CONNECT_TIMOUT 100
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_MQTT_OPTS_H */
|
43
tools/sdk/lwip2/include/lwip/apps/netbiosns.h
Normal file
43
tools/sdk/lwip2/include/lwip/apps/netbiosns.h
Normal file
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* @file
|
||||
* NETBIOS name service responder
|
||||
*/
|
||||
|
||||
/*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_APPS_NETBIOS_H
|
||||
#define LWIP_HDR_APPS_NETBIOS_H
|
||||
|
||||
#include "lwip/apps/netbiosns_opts.h"
|
||||
|
||||
void netbiosns_init(void);
|
||||
#ifndef NETBIOS_LWIP_NAME
|
||||
void netbiosns_set_name(const char* hostname);
|
||||
#endif
|
||||
void netbiosns_stop(void);
|
||||
|
||||
#endif /* LWIP_HDR_APPS_NETBIOS_H */
|
59
tools/sdk/lwip2/include/lwip/apps/netbiosns_opts.h
Normal file
59
tools/sdk/lwip2/include/lwip/apps/netbiosns_opts.h
Normal file
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* @file
|
||||
* NETBIOS name service responder options
|
||||
*/
|
||||
|
||||
/*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_APPS_NETBIOS_OPTS_H
|
||||
#define LWIP_HDR_APPS_NETBIOS_OPTS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/**
|
||||
* @defgroup netbiosns_opts Options
|
||||
* @ingroup netbiosns
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** NetBIOS name of lwip device
|
||||
* This must be uppercase until NETBIOS_STRCMP() is defined to a string
|
||||
* comparision function that is case insensitive.
|
||||
* If you want to use the netif's hostname, use this (with LWIP_NETIF_HOSTNAME):
|
||||
* (ip_current_netif() != NULL ? ip_current_netif()->hostname != NULL ? ip_current_netif()->hostname : "" : "")
|
||||
*
|
||||
* If this is not defined, netbiosns_set_name() can be called at runtime to change the name.
|
||||
*/
|
||||
#ifdef __DOXYGEN__
|
||||
#define NETBIOS_LWIP_NAME "NETBIOSLWIPDEV"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* LWIP_HDR_APPS_NETBIOS_OPTS_H */
|
128
tools/sdk/lwip2/include/lwip/apps/snmp.h
Normal file
128
tools/sdk/lwip2/include/lwip/apps/snmp.h
Normal file
@ -0,0 +1,128 @@
|
||||
/**
|
||||
* @file
|
||||
* SNMP server main API - start and basic configuration
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Leon Woestenberg <leon.woestenberg@axon.tv>
|
||||
* Copyright (c) 2001, 2002 Axon Digital Design B.V., The Netherlands.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Leon Woestenberg <leon.woestenberg@axon.tv>
|
||||
* Martin Hentschel <info@cl-soft.de>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_APPS_SNMP_H
|
||||
#define LWIP_HDR_APPS_SNMP_H
|
||||
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/apps/snmp_core.h"
|
||||
|
||||
/** SNMP variable binding descriptor (publically needed for traps) */
|
||||
struct snmp_varbind
|
||||
{
|
||||
/** pointer to next varbind, NULL for last in list */
|
||||
struct snmp_varbind *next;
|
||||
/** pointer to previous varbind, NULL for first in list */
|
||||
struct snmp_varbind *prev;
|
||||
|
||||
/** object identifier */
|
||||
struct snmp_obj_id oid;
|
||||
|
||||
/** value ASN1 type */
|
||||
u8_t type;
|
||||
/** object value length */
|
||||
u16_t value_len;
|
||||
/** object value */
|
||||
void *value;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup snmp_core
|
||||
* Agent setup, start listening to port 161.
|
||||
*/
|
||||
void snmp_init(void);
|
||||
void snmp_set_mibs(const struct snmp_mib **mibs, u8_t num_mibs);
|
||||
|
||||
void snmp_set_device_enterprise_oid(const struct snmp_obj_id* device_enterprise_oid);
|
||||
const struct snmp_obj_id* snmp_get_device_enterprise_oid(void);
|
||||
|
||||
void snmp_trap_dst_enable(u8_t dst_idx, u8_t enable);
|
||||
void snmp_trap_dst_ip_set(u8_t dst_idx, const ip_addr_t *dst);
|
||||
|
||||
/** Generic trap: cold start */
|
||||
#define SNMP_GENTRAP_COLDSTART 0
|
||||
/** Generic trap: warm start */
|
||||
#define SNMP_GENTRAP_WARMSTART 1
|
||||
/** Generic trap: link down */
|
||||
#define SNMP_GENTRAP_LINKDOWN 2
|
||||
/** Generic trap: link up */
|
||||
#define SNMP_GENTRAP_LINKUP 3
|
||||
/** Generic trap: authentication failure */
|
||||
#define SNMP_GENTRAP_AUTH_FAILURE 4
|
||||
/** Generic trap: EGP neighbor lost */
|
||||
#define SNMP_GENTRAP_EGP_NEIGHBOR_LOSS 5
|
||||
/** Generic trap: enterprise specific */
|
||||
#define SNMP_GENTRAP_ENTERPRISE_SPECIFIC 6
|
||||
|
||||
err_t snmp_send_trap_generic(s32_t generic_trap);
|
||||
err_t snmp_send_trap_specific(s32_t specific_trap, struct snmp_varbind *varbinds);
|
||||
err_t snmp_send_trap(const struct snmp_obj_id* oid, s32_t generic_trap, s32_t specific_trap, struct snmp_varbind *varbinds);
|
||||
|
||||
#define SNMP_AUTH_TRAPS_DISABLED 0
|
||||
#define SNMP_AUTH_TRAPS_ENABLED 1
|
||||
void snmp_set_auth_traps_enabled(u8_t enable);
|
||||
u8_t snmp_get_auth_traps_enabled(void);
|
||||
|
||||
const char * snmp_get_community(void);
|
||||
const char * snmp_get_community_write(void);
|
||||
const char * snmp_get_community_trap(void);
|
||||
void snmp_set_community(const char * const community);
|
||||
void snmp_set_community_write(const char * const community);
|
||||
void snmp_set_community_trap(const char * const community);
|
||||
|
||||
void snmp_coldstart_trap(void);
|
||||
void snmp_authfail_trap(void);
|
||||
|
||||
typedef void (*snmp_write_callback_fct)(const u32_t* oid, u8_t oid_len, void* callback_arg);
|
||||
void snmp_set_write_callback(snmp_write_callback_fct write_callback, void* callback_arg);
|
||||
|
||||
#endif /* LWIP_SNMP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_SNMP_H */
|
364
tools/sdk/lwip2/include/lwip/apps/snmp_core.h
Normal file
364
tools/sdk/lwip2/include/lwip/apps/snmp_core.h
Normal file
@ -0,0 +1,364 @@
|
||||
/**
|
||||
* @file
|
||||
* SNMP core API for implementing MIBs
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Axon Digital Design B.V., The Netherlands.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* Author: Christiaan Simons <christiaan.simons@axon.tv>
|
||||
* Martin Hentschel <info@cl-soft.de>
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_APPS_SNMP_CORE_H
|
||||
#define LWIP_HDR_APPS_SNMP_CORE_H
|
||||
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* basic ASN1 defines */
|
||||
#define SNMP_ASN1_CLASS_UNIVERSAL 0x00
|
||||
#define SNMP_ASN1_CLASS_APPLICATION 0x40
|
||||
#define SNMP_ASN1_CLASS_CONTEXT 0x80
|
||||
#define SNMP_ASN1_CLASS_PRIVATE 0xC0
|
||||
|
||||
#define SNMP_ASN1_CONTENTTYPE_PRIMITIVE 0x00
|
||||
#define SNMP_ASN1_CONTENTTYPE_CONSTRUCTED 0x20
|
||||
|
||||
/* universal tags (from ASN.1 spec.) */
|
||||
#define SNMP_ASN1_UNIVERSAL_END_OF_CONTENT 0
|
||||
#define SNMP_ASN1_UNIVERSAL_INTEGER 2
|
||||
#define SNMP_ASN1_UNIVERSAL_OCTET_STRING 4
|
||||
#define SNMP_ASN1_UNIVERSAL_NULL 5
|
||||
#define SNMP_ASN1_UNIVERSAL_OBJECT_ID 6
|
||||
#define SNMP_ASN1_UNIVERSAL_SEQUENCE_OF 16
|
||||
|
||||
/* application specific (SNMP) tags (from SNMPv2-SMI) */
|
||||
#define SNMP_ASN1_APPLICATION_IPADDR 0 /* [APPLICATION 0] IMPLICIT OCTET STRING (SIZE (4)) */
|
||||
#define SNMP_ASN1_APPLICATION_COUNTER 1 /* [APPLICATION 1] IMPLICIT INTEGER (0..4294967295) => u32_t */
|
||||
#define SNMP_ASN1_APPLICATION_GAUGE 2 /* [APPLICATION 2] IMPLICIT INTEGER (0..4294967295) => u32_t */
|
||||
#define SNMP_ASN1_APPLICATION_TIMETICKS 3 /* [APPLICATION 3] IMPLICIT INTEGER (0..4294967295) => u32_t */
|
||||
#define SNMP_ASN1_APPLICATION_OPAQUE 4 /* [APPLICATION 4] IMPLICIT OCTET STRING */
|
||||
#define SNMP_ASN1_APPLICATION_COUNTER64 6 /* [APPLICATION 6] IMPLICIT INTEGER (0..18446744073709551615) */
|
||||
|
||||
/* context specific (SNMP) tags (from RFC 1905) */
|
||||
#define SNMP_ASN1_CONTEXT_VARBIND_NO_SUCH_INSTANCE 1
|
||||
|
||||
/* full ASN1 type defines */
|
||||
#define SNMP_ASN1_TYPE_END_OF_CONTENT (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_END_OF_CONTENT)
|
||||
#define SNMP_ASN1_TYPE_INTEGER (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_INTEGER)
|
||||
#define SNMP_ASN1_TYPE_OCTET_STRING (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_OCTET_STRING)
|
||||
#define SNMP_ASN1_TYPE_NULL (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_NULL)
|
||||
#define SNMP_ASN1_TYPE_OBJECT_ID (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_OBJECT_ID)
|
||||
#define SNMP_ASN1_TYPE_SEQUENCE (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_CONSTRUCTED | SNMP_ASN1_UNIVERSAL_SEQUENCE_OF)
|
||||
#define SNMP_ASN1_TYPE_IPADDR (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_IPADDR)
|
||||
#define SNMP_ASN1_TYPE_IPADDRESS SNMP_ASN1_TYPE_IPADDR
|
||||
#define SNMP_ASN1_TYPE_COUNTER (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_COUNTER)
|
||||
#define SNMP_ASN1_TYPE_COUNTER32 SNMP_ASN1_TYPE_COUNTER
|
||||
#define SNMP_ASN1_TYPE_GAUGE (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_GAUGE)
|
||||
#define SNMP_ASN1_TYPE_GAUGE32 SNMP_ASN1_TYPE_GAUGE
|
||||
#define SNMP_ASN1_TYPE_UNSIGNED32 SNMP_ASN1_TYPE_GAUGE
|
||||
#define SNMP_ASN1_TYPE_TIMETICKS (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_TIMETICKS)
|
||||
#define SNMP_ASN1_TYPE_OPAQUE (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_OPAQUE)
|
||||
#define SNMP_ASN1_TYPE_COUNTER64 (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_COUNTER64)
|
||||
|
||||
#define SNMP_VARBIND_EXCEPTION_OFFSET 0xF0
|
||||
#define SNMP_VARBIND_EXCEPTION_MASK 0x0F
|
||||
|
||||
/** error codes predefined by SNMP prot. */
|
||||
typedef enum {
|
||||
SNMP_ERR_NOERROR = 0,
|
||||
/*
|
||||
outdated v1 error codes. do not use anmore!
|
||||
#define SNMP_ERR_NOSUCHNAME 2 use SNMP_ERR_NOSUCHINSTANCE instead
|
||||
#define SNMP_ERR_BADVALUE 3 use SNMP_ERR_WRONGTYPE,SNMP_ERR_WRONGLENGTH,SNMP_ERR_WRONGENCODING or SNMP_ERR_WRONGVALUE instead
|
||||
#define SNMP_ERR_READONLY 4 use SNMP_ERR_NOTWRITABLE instead
|
||||
*/
|
||||
SNMP_ERR_GENERROR = 5,
|
||||
SNMP_ERR_NOACCESS = 6,
|
||||
SNMP_ERR_WRONGTYPE = 7,
|
||||
SNMP_ERR_WRONGLENGTH = 8,
|
||||
SNMP_ERR_WRONGENCODING = 9,
|
||||
SNMP_ERR_WRONGVALUE = 10,
|
||||
SNMP_ERR_NOCREATION = 11,
|
||||
SNMP_ERR_INCONSISTENTVALUE = 12,
|
||||
SNMP_ERR_RESOURCEUNAVAILABLE = 13,
|
||||
SNMP_ERR_COMMITFAILED = 14,
|
||||
SNMP_ERR_UNDOFAILED = 15,
|
||||
SNMP_ERR_NOTWRITABLE = 17,
|
||||
SNMP_ERR_INCONSISTENTNAME = 18,
|
||||
|
||||
SNMP_ERR_NOSUCHINSTANCE = SNMP_VARBIND_EXCEPTION_OFFSET + SNMP_ASN1_CONTEXT_VARBIND_NO_SUCH_INSTANCE
|
||||
} snmp_err_t;
|
||||
|
||||
/** internal object identifier representation */
|
||||
struct snmp_obj_id
|
||||
{
|
||||
u8_t len;
|
||||
u32_t id[SNMP_MAX_OBJ_ID_LEN];
|
||||
};
|
||||
|
||||
struct snmp_obj_id_const_ref
|
||||
{
|
||||
u8_t len;
|
||||
const u32_t* id;
|
||||
};
|
||||
|
||||
extern const struct snmp_obj_id_const_ref snmp_zero_dot_zero; /* administrative identifier from SNMPv2-SMI */
|
||||
|
||||
/** SNMP variant value, used as reference in struct snmp_node_instance and table implementation */
|
||||
union snmp_variant_value
|
||||
{
|
||||
void* ptr;
|
||||
const void* const_ptr;
|
||||
u32_t u32;
|
||||
s32_t s32;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
SNMP MIB node types
|
||||
tree node is the only node the stack can process in order to walk the tree,
|
||||
all other nodes are assumed to be leaf nodes.
|
||||
This cannot be an enum because users may want to define their own node types.
|
||||
*/
|
||||
#define SNMP_NODE_TREE 0x00
|
||||
/* predefined leaf node types */
|
||||
#define SNMP_NODE_SCALAR 0x01
|
||||
#define SNMP_NODE_SCALAR_ARRAY 0x02
|
||||
#define SNMP_NODE_TABLE 0x03
|
||||
#define SNMP_NODE_THREADSYNC 0x04
|
||||
|
||||
/** node "base class" layout, the mandatory fields for a node */
|
||||
struct snmp_node
|
||||
{
|
||||
/** one out of SNMP_NODE_TREE or any leaf node type (like SNMP_NODE_SCALAR) */
|
||||
u8_t node_type;
|
||||
/** the number assigned to this node which used as part of the full OID */
|
||||
u32_t oid;
|
||||
};
|
||||
|
||||
/** SNMP node instance access types */
|
||||
typedef enum {
|
||||
SNMP_NODE_INSTANCE_ACCESS_READ = 1,
|
||||
SNMP_NODE_INSTANCE_ACCESS_WRITE = 2,
|
||||
SNMP_NODE_INSTANCE_READ_ONLY = SNMP_NODE_INSTANCE_ACCESS_READ,
|
||||
SNMP_NODE_INSTANCE_READ_WRITE = (SNMP_NODE_INSTANCE_ACCESS_READ | SNMP_NODE_INSTANCE_ACCESS_WRITE),
|
||||
SNMP_NODE_INSTANCE_WRITE_ONLY = SNMP_NODE_INSTANCE_ACCESS_WRITE,
|
||||
SNMP_NODE_INSTANCE_NOT_ACCESSIBLE = 0
|
||||
} snmp_access_t;
|
||||
|
||||
struct snmp_node_instance;
|
||||
|
||||
typedef s16_t (*node_instance_get_value_method)(struct snmp_node_instance*, void*);
|
||||
typedef snmp_err_t (*node_instance_set_test_method)(struct snmp_node_instance*, u16_t, void*);
|
||||
typedef snmp_err_t (*node_instance_set_value_method)(struct snmp_node_instance*, u16_t, void*);
|
||||
typedef void (*node_instance_release_method)(struct snmp_node_instance*);
|
||||
|
||||
#define SNMP_GET_VALUE_RAW_DATA 0x8000
|
||||
|
||||
/** SNMP node instance */
|
||||
struct snmp_node_instance
|
||||
{
|
||||
/** prefilled with the node, get_instance() is called on; may be changed by user to any value to pass an arbitrary node between calls to get_instance() and get_value/test_value/set_value */
|
||||
const struct snmp_node* node;
|
||||
/** prefilled with the instance id requested; for get_instance() this is the exact oid requested; for get_next_instance() this is the relative starting point, stack expects relative oid of next node here */
|
||||
struct snmp_obj_id instance_oid;
|
||||
|
||||
/** ASN type for this object (see snmp_asn1.h for definitions) */
|
||||
u8_t asn1_type;
|
||||
/** one out of instance access types defined above (SNMP_NODE_INSTANCE_READ_ONLY,...) */
|
||||
snmp_access_t access;
|
||||
|
||||
/** returns object value for the given object identifier. Return values <0 to indicate an error */
|
||||
node_instance_get_value_method get_value;
|
||||
/** tests length and/or range BEFORE setting */
|
||||
node_instance_set_test_method set_test;
|
||||
/** sets object value, only called when set_test() was successful */
|
||||
node_instance_set_value_method set_value;
|
||||
/** called in any case when the instance is not required anymore by stack (useful for freeing memory allocated in get_instance/get_next_instance methods) */
|
||||
node_instance_release_method release_instance;
|
||||
|
||||
/** reference to pass arbitrary value between calls to get_instance() and get_value/test_value/set_value */
|
||||
union snmp_variant_value reference;
|
||||
/** see reference (if reference is a pointer, the length of underlying data may be stored here or anything else) */
|
||||
u32_t reference_len;
|
||||
};
|
||||
|
||||
|
||||
/** SNMP tree node */
|
||||
struct snmp_tree_node
|
||||
{
|
||||
/** inherited "base class" members */
|
||||
struct snmp_node node;
|
||||
u16_t subnode_count;
|
||||
const struct snmp_node* const *subnodes;
|
||||
};
|
||||
|
||||
#define SNMP_CREATE_TREE_NODE(oid, subnodes) \
|
||||
{{ SNMP_NODE_TREE, (oid) }, \
|
||||
(u16_t)LWIP_ARRAYSIZE(subnodes), (subnodes) }
|
||||
|
||||
#define SNMP_CREATE_EMPTY_TREE_NODE(oid) \
|
||||
{{ SNMP_NODE_TREE, (oid) }, \
|
||||
0, NULL }
|
||||
|
||||
/** SNMP leaf node */
|
||||
struct snmp_leaf_node
|
||||
{
|
||||
/** inherited "base class" members */
|
||||
struct snmp_node node;
|
||||
snmp_err_t (*get_instance)(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
snmp_err_t (*get_next_instance)(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
};
|
||||
|
||||
/** represents a single mib with its base oid and root node */
|
||||
struct snmp_mib
|
||||
{
|
||||
const u32_t *base_oid;
|
||||
u8_t base_oid_len;
|
||||
const struct snmp_node *root_node;
|
||||
};
|
||||
|
||||
#define SNMP_MIB_CREATE(oid_list, root_node) { (oid_list), (u8_t)LWIP_ARRAYSIZE(oid_list), root_node }
|
||||
|
||||
/** OID range structure */
|
||||
struct snmp_oid_range
|
||||
{
|
||||
u32_t min;
|
||||
u32_t max;
|
||||
};
|
||||
|
||||
/** checks if incoming OID length and values are in allowed ranges */
|
||||
u8_t snmp_oid_in_range(const u32_t *oid_in, u8_t oid_len, const struct snmp_oid_range *oid_ranges, u8_t oid_ranges_len);
|
||||
|
||||
typedef enum {
|
||||
SNMP_NEXT_OID_STATUS_SUCCESS,
|
||||
SNMP_NEXT_OID_STATUS_NO_MATCH,
|
||||
SNMP_NEXT_OID_STATUS_BUF_TO_SMALL
|
||||
} snmp_next_oid_status_t;
|
||||
|
||||
/** state for next_oid_init / next_oid_check functions */
|
||||
struct snmp_next_oid_state
|
||||
{
|
||||
const u32_t* start_oid;
|
||||
u8_t start_oid_len;
|
||||
|
||||
u32_t* next_oid;
|
||||
u8_t next_oid_len;
|
||||
u8_t next_oid_max_len;
|
||||
|
||||
snmp_next_oid_status_t status;
|
||||
void* reference;
|
||||
};
|
||||
|
||||
void snmp_next_oid_init(struct snmp_next_oid_state *state,
|
||||
const u32_t *start_oid, u8_t start_oid_len,
|
||||
u32_t *next_oid_buf, u8_t next_oid_max_len);
|
||||
u8_t snmp_next_oid_precheck(struct snmp_next_oid_state *state, const u32_t *oid, const u8_t oid_len);
|
||||
u8_t snmp_next_oid_check(struct snmp_next_oid_state *state, const u32_t *oid, const u8_t oid_len, void* reference);
|
||||
|
||||
void snmp_oid_assign(struct snmp_obj_id* target, const u32_t *oid, u8_t oid_len);
|
||||
void snmp_oid_combine(struct snmp_obj_id* target, const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_len);
|
||||
void snmp_oid_prefix(struct snmp_obj_id* target, const u32_t *oid, u8_t oid_len);
|
||||
void snmp_oid_append(struct snmp_obj_id* target, const u32_t *oid, u8_t oid_len);
|
||||
u8_t snmp_oid_equal(const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_len);
|
||||
s8_t snmp_oid_compare(const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_len);
|
||||
|
||||
#if LWIP_IPV4
|
||||
u8_t snmp_oid_to_ip4(const u32_t *oid, ip4_addr_t *ip);
|
||||
void snmp_ip4_to_oid(const ip4_addr_t *ip, u32_t *oid);
|
||||
#endif /* LWIP_IPV4 */
|
||||
#if LWIP_IPV6
|
||||
u8_t snmp_oid_to_ip6(const u32_t *oid, ip6_addr_t *ip);
|
||||
void snmp_ip6_to_oid(const ip6_addr_t *ip, u32_t *oid);
|
||||
#endif /* LWIP_IPV6 */
|
||||
#if LWIP_IPV4 || LWIP_IPV6
|
||||
u8_t snmp_ip_to_oid(const ip_addr_t *ip, u32_t *oid);
|
||||
u8_t snmp_ip_port_to_oid(const ip_addr_t *ip, u16_t port, u32_t *oid);
|
||||
|
||||
u8_t snmp_oid_to_ip(const u32_t *oid, u8_t oid_len, ip_addr_t *ip);
|
||||
u8_t snmp_oid_to_ip_port(const u32_t *oid, u8_t oid_len, ip_addr_t *ip, u16_t *port);
|
||||
#endif /* LWIP_IPV4 || LWIP_IPV6 */
|
||||
|
||||
struct netif;
|
||||
u8_t netif_to_num(const struct netif *netif);
|
||||
|
||||
snmp_err_t snmp_set_test_ok(struct snmp_node_instance* instance, u16_t value_len, void* value); /* generic function which can be used if test is always successful */
|
||||
|
||||
err_t snmp_decode_bits(const u8_t *buf, u32_t buf_len, u32_t *bit_value);
|
||||
err_t snmp_decode_truthvalue(const s32_t *asn1_value, u8_t *bool_value);
|
||||
u8_t snmp_encode_bits(u8_t *buf, u32_t buf_len, u32_t bit_value, u8_t bit_count);
|
||||
u8_t snmp_encode_truthvalue(s32_t *asn1_value, u32_t bool_value);
|
||||
|
||||
struct snmp_statistics
|
||||
{
|
||||
u32_t inpkts;
|
||||
u32_t outpkts;
|
||||
u32_t inbadversions;
|
||||
u32_t inbadcommunitynames;
|
||||
u32_t inbadcommunityuses;
|
||||
u32_t inasnparseerrs;
|
||||
u32_t intoobigs;
|
||||
u32_t innosuchnames;
|
||||
u32_t inbadvalues;
|
||||
u32_t inreadonlys;
|
||||
u32_t ingenerrs;
|
||||
u32_t intotalreqvars;
|
||||
u32_t intotalsetvars;
|
||||
u32_t ingetrequests;
|
||||
u32_t ingetnexts;
|
||||
u32_t insetrequests;
|
||||
u32_t ingetresponses;
|
||||
u32_t intraps;
|
||||
u32_t outtoobigs;
|
||||
u32_t outnosuchnames;
|
||||
u32_t outbadvalues;
|
||||
u32_t outgenerrs;
|
||||
u32_t outgetrequests;
|
||||
u32_t outgetnexts;
|
||||
u32_t outsetrequests;
|
||||
u32_t outgetresponses;
|
||||
u32_t outtraps;
|
||||
};
|
||||
|
||||
extern struct snmp_statistics snmp_stats;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_SNMP */
|
||||
|
||||
#endif /* LWIP_HDR_APPS_SNMP_CORE_H */
|
78
tools/sdk/lwip2/include/lwip/apps/snmp_mib2.h
Normal file
78
tools/sdk/lwip2/include/lwip/apps/snmp_mib2.h
Normal file
@ -0,0 +1,78 @@
|
||||
/**
|
||||
* @file
|
||||
* SNMP MIB2 API
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Dirk Ziegelmeier <dziegel@gmx.de>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_APPS_SNMP_MIB2_H
|
||||
#define LWIP_HDR_APPS_SNMP_MIB2_H
|
||||
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
#if SNMP_LWIP_MIB2
|
||||
|
||||
#include "lwip/apps/snmp_core.h"
|
||||
|
||||
extern const struct snmp_mib mib2;
|
||||
|
||||
#if SNMP_USE_NETCONN
|
||||
#include "lwip/apps/snmp_threadsync.h"
|
||||
void snmp_mib2_lwip_synchronizer(snmp_threadsync_called_fn fn, void* arg);
|
||||
extern struct snmp_threadsync_instance snmp_mib2_lwip_locks;
|
||||
#endif
|
||||
|
||||
#ifndef SNMP_SYSSERVICES
|
||||
#define SNMP_SYSSERVICES ((1 << 6) | (1 << 3) | ((IP_FORWARD) << 2))
|
||||
#endif
|
||||
|
||||
void snmp_mib2_set_sysdescr(const u8_t* str, const u16_t* len); /* read-only be defintion */
|
||||
void snmp_mib2_set_syscontact(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize);
|
||||
void snmp_mib2_set_syscontact_readonly(const u8_t *ocstr, const u16_t *ocstrlen);
|
||||
void snmp_mib2_set_sysname(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize);
|
||||
void snmp_mib2_set_sysname_readonly(const u8_t *ocstr, const u16_t *ocstrlen);
|
||||
void snmp_mib2_set_syslocation(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize);
|
||||
void snmp_mib2_set_syslocation_readonly(const u8_t *ocstr, const u16_t *ocstrlen);
|
||||
|
||||
#endif /* SNMP_LWIP_MIB2 */
|
||||
#endif /* LWIP_SNMP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_SNMP_MIB2_H */
|
293
tools/sdk/lwip2/include/lwip/apps/snmp_opts.h
Normal file
293
tools/sdk/lwip2/include/lwip/apps/snmp_opts.h
Normal file
@ -0,0 +1,293 @@
|
||||
/**
|
||||
* @file
|
||||
* SNMP server options list
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015 Dirk Ziegelmeier
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Dirk Ziegelmeier
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_SNMP_OPTS_H
|
||||
#define LWIP_HDR_SNMP_OPTS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/**
|
||||
* @defgroup snmp_opts Options
|
||||
* @ingroup snmp
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* LWIP_SNMP==1: This enables the lwIP SNMP agent. UDP must be available
|
||||
* for SNMP transport.
|
||||
* If you want to use your own SNMP agent, leave this disabled.
|
||||
* To integrate MIB2 of an external agent, you need to enable
|
||||
* LWIP_MIB2_CALLBACKS and MIB2_STATS. This will give you the callbacks
|
||||
* and statistics counters you need to get MIB2 working.
|
||||
*/
|
||||
#if !defined LWIP_SNMP || defined __DOXYGEN__
|
||||
#define LWIP_SNMP 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_USE_NETCONN: Use netconn API instead of raw API.
|
||||
* Makes SNMP agent run in a worker thread, so blocking operations
|
||||
* can be done in MIB calls.
|
||||
*/
|
||||
#if !defined SNMP_USE_NETCONN || defined __DOXYGEN__
|
||||
#define SNMP_USE_NETCONN 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_USE_RAW: Use raw API.
|
||||
* SNMP agent does not run in a worker thread, so blocking operations
|
||||
* should not be done in MIB calls.
|
||||
*/
|
||||
#if !defined SNMP_USE_RAW || defined __DOXYGEN__
|
||||
#define SNMP_USE_RAW 1
|
||||
#endif
|
||||
|
||||
#if SNMP_USE_NETCONN && SNMP_USE_RAW
|
||||
#error SNMP stack can use only one of the APIs {raw, netconn}
|
||||
#endif
|
||||
|
||||
#if LWIP_SNMP && !SNMP_USE_NETCONN && !SNMP_USE_RAW
|
||||
#error SNMP stack needs a receive API and UDP {raw, netconn}
|
||||
#endif
|
||||
|
||||
#if SNMP_USE_NETCONN
|
||||
/**
|
||||
* SNMP_STACK_SIZE: Stack size of SNMP netconn worker thread
|
||||
*/
|
||||
#if !defined SNMP_STACK_SIZE || defined __DOXYGEN__
|
||||
#define SNMP_STACK_SIZE DEFAULT_THREAD_STACKSIZE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_THREAD_PRIO: SNMP netconn worker thread priority
|
||||
*/
|
||||
#if !defined SNMP_THREAD_PRIO || defined __DOXYGEN__
|
||||
#define SNMP_THREAD_PRIO DEFAULT_THREAD_PRIO
|
||||
#endif
|
||||
#endif /* SNMP_USE_NETCONN */
|
||||
|
||||
/**
|
||||
* SNMP_TRAP_DESTINATIONS: Number of trap destinations. At least one trap
|
||||
* destination is required
|
||||
*/
|
||||
#if !defined SNMP_TRAP_DESTINATIONS || defined __DOXYGEN__
|
||||
#define SNMP_TRAP_DESTINATIONS 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Only allow SNMP write actions that are 'safe' (e.g. disabling netifs is not
|
||||
* a safe action and disabled when SNMP_SAFE_REQUESTS = 1).
|
||||
* Unsafe requests are disabled by default!
|
||||
*/
|
||||
#if !defined SNMP_SAFE_REQUESTS || defined __DOXYGEN__
|
||||
#define SNMP_SAFE_REQUESTS 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The maximum length of strings used.
|
||||
*/
|
||||
#if !defined SNMP_MAX_OCTET_STRING_LEN || defined __DOXYGEN__
|
||||
#define SNMP_MAX_OCTET_STRING_LEN 127
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The maximum number of Sub ID's inside an object identifier.
|
||||
* Indirectly this also limits the maximum depth of SNMP tree.
|
||||
*/
|
||||
#if !defined SNMP_MAX_OBJ_ID_LEN || defined __DOXYGEN__
|
||||
#define SNMP_MAX_OBJ_ID_LEN 50
|
||||
#endif
|
||||
|
||||
#if !defined SNMP_MAX_VALUE_SIZE || defined __DOXYGEN__
|
||||
/**
|
||||
* The maximum size of a value.
|
||||
*/
|
||||
#define SNMP_MIN_VALUE_SIZE (2 * sizeof(u32_t*)) /* size required to store the basic types (8 bytes for counter64) */
|
||||
/**
|
||||
* The minimum size of a value.
|
||||
*/
|
||||
#define SNMP_MAX_VALUE_SIZE LWIP_MAX(LWIP_MAX((SNMP_MAX_OCTET_STRING_LEN), sizeof(u32_t)*(SNMP_MAX_OBJ_ID_LEN)), SNMP_MIN_VALUE_SIZE)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The snmp read-access community. Used for write-access and traps, too
|
||||
* unless SNMP_COMMUNITY_WRITE or SNMP_COMMUNITY_TRAP are enabled, respectively.
|
||||
*/
|
||||
#if !defined SNMP_COMMUNITY || defined __DOXYGEN__
|
||||
#define SNMP_COMMUNITY "public"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The snmp write-access community.
|
||||
* Set this community to "" in order to disallow any write access.
|
||||
*/
|
||||
#if !defined SNMP_COMMUNITY_WRITE || defined __DOXYGEN__
|
||||
#define SNMP_COMMUNITY_WRITE "private"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The snmp community used for sending traps.
|
||||
*/
|
||||
#if !defined SNMP_COMMUNITY_TRAP || defined __DOXYGEN__
|
||||
#define SNMP_COMMUNITY_TRAP "public"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The maximum length of community string.
|
||||
* If community names shall be adjusted at runtime via snmp_set_community() calls,
|
||||
* enter here the possible maximum length (+1 for terminating null character).
|
||||
*/
|
||||
#if !defined SNMP_MAX_COMMUNITY_STR_LEN || defined __DOXYGEN__
|
||||
#define SNMP_MAX_COMMUNITY_STR_LEN LWIP_MAX(LWIP_MAX(sizeof(SNMP_COMMUNITY), sizeof(SNMP_COMMUNITY_WRITE)), sizeof(SNMP_COMMUNITY_TRAP))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The OID identifiying the device. This may be the enterprise OID itself or any OID located below it in tree.
|
||||
*/
|
||||
#if !defined SNMP_DEVICE_ENTERPRISE_OID || defined __DOXYGEN__
|
||||
#define SNMP_LWIP_ENTERPRISE_OID 26381
|
||||
/**
|
||||
* IANA assigned enterprise ID for lwIP is 26381
|
||||
* @see http://www.iana.org/assignments/enterprise-numbers
|
||||
*
|
||||
* @note this enterprise ID is assigned to the lwIP project,
|
||||
* all object identifiers living under this ID are assigned
|
||||
* by the lwIP maintainers!
|
||||
* @note don't change this define, use snmp_set_device_enterprise_oid()
|
||||
*
|
||||
* If you need to create your own private MIB you'll need
|
||||
* to apply for your own enterprise ID with IANA:
|
||||
* http://www.iana.org/numbers.html
|
||||
*/
|
||||
#define SNMP_DEVICE_ENTERPRISE_OID {1, 3, 6, 1, 4, 1, SNMP_LWIP_ENTERPRISE_OID}
|
||||
/**
|
||||
* Length of SNMP_DEVICE_ENTERPRISE_OID
|
||||
*/
|
||||
#define SNMP_DEVICE_ENTERPRISE_OID_LEN 7
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_DEBUG: Enable debugging for SNMP messages.
|
||||
*/
|
||||
#if !defined SNMP_DEBUG || defined __DOXYGEN__
|
||||
#define SNMP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_MIB_DEBUG: Enable debugging for SNMP MIBs.
|
||||
*/
|
||||
#if !defined SNMP_MIB_DEBUG || defined __DOXYGEN__
|
||||
#define SNMP_MIB_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Indicates if the MIB2 implementation of LWIP SNMP stack is used.
|
||||
*/
|
||||
#if !defined SNMP_LWIP_MIB2 || defined __DOXYGEN__
|
||||
#define SNMP_LWIP_MIB2 LWIP_SNMP
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Value return for sysDesc field of MIB2.
|
||||
*/
|
||||
#if !defined SNMP_LWIP_MIB2_SYSDESC || defined __DOXYGEN__
|
||||
#define SNMP_LWIP_MIB2_SYSDESC "lwIP"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Value return for sysName field of MIB2.
|
||||
* To make sysName field settable, call snmp_mib2_set_sysname() to provide the necessary buffers.
|
||||
*/
|
||||
#if !defined SNMP_LWIP_MIB2_SYSNAME || defined __DOXYGEN__
|
||||
#define SNMP_LWIP_MIB2_SYSNAME "FQDN-unk"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Value return for sysContact field of MIB2.
|
||||
* To make sysContact field settable, call snmp_mib2_set_syscontact() to provide the necessary buffers.
|
||||
*/
|
||||
#if !defined SNMP_LWIP_MIB2_SYSCONTACT || defined __DOXYGEN__
|
||||
#define SNMP_LWIP_MIB2_SYSCONTACT ""
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Value return for sysLocation field of MIB2.
|
||||
* To make sysLocation field settable, call snmp_mib2_set_syslocation() to provide the necessary buffers.
|
||||
*/
|
||||
#if !defined SNMP_LWIP_MIB2_SYSLOCATION || defined __DOXYGEN__
|
||||
#define SNMP_LWIP_MIB2_SYSLOCATION ""
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This value is used to limit the repetitions processed in GetBulk requests (value == 0 means no limitation).
|
||||
* This may be useful to limit the load for a single request.
|
||||
* According to SNMP RFC 1905 it is allowed to not return all requested variables from a GetBulk request if system load would be too high.
|
||||
* so the effect is that the client will do more requests to gather all data.
|
||||
* For the stack this could be useful in case that SNMP processing is done in TCP/IP thread. In this situation a request with many
|
||||
* repetitions could block the thread for a longer time. Setting limit here will keep the stack more responsive.
|
||||
*/
|
||||
#if !defined SNMP_LWIP_GETBULK_MAX_REPETITIONS || defined __DOXYGEN__
|
||||
#define SNMP_LWIP_GETBULK_MAX_REPETITIONS 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/*
|
||||
------------------------------------
|
||||
---------- SNMPv3 options ----------
|
||||
------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* LWIP_SNMP_V3==1: This enables EXPERIMENTAL SNMPv3 support. LWIP_SNMP must
|
||||
* also be enabled.
|
||||
* THIS IS UNDER DEVELOPMENT AND SHOULD NOT BE ENABLED IN PRODUCTS.
|
||||
*/
|
||||
#ifndef LWIP_SNMP_V3
|
||||
#define LWIP_SNMP_V3 0
|
||||
#endif
|
||||
|
||||
#ifndef LWIP_SNMP_V3_CRYPTO
|
||||
#define LWIP_SNMP_V3_CRYPTO LWIP_SNMP_V3
|
||||
#endif
|
||||
|
||||
#ifndef LWIP_SNMP_V3_MBEDTLS
|
||||
#define LWIP_SNMP_V3_MBEDTLS LWIP_SNMP_V3
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_SNMP_OPTS_H */
|
113
tools/sdk/lwip2/include/lwip/apps/snmp_scalar.h
Normal file
113
tools/sdk/lwip2/include/lwip/apps/snmp_scalar.h
Normal file
@ -0,0 +1,113 @@
|
||||
/**
|
||||
* @file
|
||||
* SNMP server MIB API to implement scalar nodes
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Martin Hentschel <info@cl-soft.de>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_APPS_SNMP_SCALAR_H
|
||||
#define LWIP_HDR_APPS_SNMP_SCALAR_H
|
||||
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
#include "lwip/apps/snmp_core.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
/** basic scalar node */
|
||||
struct snmp_scalar_node
|
||||
{
|
||||
/** inherited "base class" members */
|
||||
struct snmp_leaf_node node;
|
||||
u8_t asn1_type;
|
||||
snmp_access_t access;
|
||||
node_instance_get_value_method get_value;
|
||||
node_instance_set_test_method set_test;
|
||||
node_instance_set_value_method set_value;
|
||||
};
|
||||
|
||||
|
||||
snmp_err_t snmp_scalar_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
snmp_err_t snmp_scalar_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
|
||||
#define SNMP_SCALAR_CREATE_NODE(oid, access, asn1_type, get_value_method, set_test_method, set_value_method) \
|
||||
{{{ SNMP_NODE_SCALAR, (oid) }, \
|
||||
snmp_scalar_get_instance, \
|
||||
snmp_scalar_get_next_instance }, \
|
||||
(asn1_type), (access), (get_value_method), (set_test_method), (set_value_method) }
|
||||
|
||||
#define SNMP_SCALAR_CREATE_NODE_READONLY(oid, asn1_type, get_value_method) SNMP_SCALAR_CREATE_NODE(oid, SNMP_NODE_INSTANCE_READ_ONLY, asn1_type, get_value_method, NULL, NULL)
|
||||
|
||||
/** scalar array node - a tree node which contains scalars only as children */
|
||||
struct snmp_scalar_array_node_def
|
||||
{
|
||||
u32_t oid;
|
||||
u8_t asn1_type;
|
||||
snmp_access_t access;
|
||||
};
|
||||
|
||||
typedef s16_t (*snmp_scalar_array_get_value_method)(const struct snmp_scalar_array_node_def*, void*);
|
||||
typedef snmp_err_t (*snmp_scalar_array_set_test_method)(const struct snmp_scalar_array_node_def*, u16_t, void*);
|
||||
typedef snmp_err_t (*snmp_scalar_array_set_value_method)(const struct snmp_scalar_array_node_def*, u16_t, void*);
|
||||
|
||||
/** basic scalar array node */
|
||||
struct snmp_scalar_array_node
|
||||
{
|
||||
/** inherited "base class" members */
|
||||
struct snmp_leaf_node node;
|
||||
u16_t array_node_count;
|
||||
const struct snmp_scalar_array_node_def* array_nodes;
|
||||
snmp_scalar_array_get_value_method get_value;
|
||||
snmp_scalar_array_set_test_method set_test;
|
||||
snmp_scalar_array_set_value_method set_value;
|
||||
};
|
||||
|
||||
snmp_err_t snmp_scalar_array_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
snmp_err_t snmp_scalar_array_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
|
||||
#define SNMP_SCALAR_CREATE_ARRAY_NODE(oid, array_nodes, get_value_method, set_test_method, set_value_method) \
|
||||
{{{ SNMP_NODE_SCALAR_ARRAY, (oid) }, \
|
||||
snmp_scalar_array_get_instance, \
|
||||
snmp_scalar_array_get_next_instance }, \
|
||||
(u16_t)LWIP_ARRAYSIZE(array_nodes), (array_nodes), (get_value_method), (set_test_method), (set_value_method) }
|
||||
|
||||
#endif /* LWIP_SNMP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_SNMP_SCALAR_H */
|
134
tools/sdk/lwip2/include/lwip/apps/snmp_table.h
Normal file
134
tools/sdk/lwip2/include/lwip/apps/snmp_table.h
Normal file
@ -0,0 +1,134 @@
|
||||
/**
|
||||
* @file
|
||||
* SNMP server MIB API to implement table nodes
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Martin Hentschel <info@cl-soft.de>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_APPS_SNMP_TABLE_H
|
||||
#define LWIP_HDR_APPS_SNMP_TABLE_H
|
||||
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
#include "lwip/apps/snmp_core.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
/** default (customizable) read/write table */
|
||||
struct snmp_table_col_def
|
||||
{
|
||||
u32_t index;
|
||||
u8_t asn1_type;
|
||||
snmp_access_t access;
|
||||
};
|
||||
|
||||
/** table node */
|
||||
struct snmp_table_node
|
||||
{
|
||||
/** inherited "base class" members */
|
||||
struct snmp_leaf_node node;
|
||||
u16_t column_count;
|
||||
const struct snmp_table_col_def* columns;
|
||||
snmp_err_t (*get_cell_instance)(const u32_t* column, const u32_t* row_oid, u8_t row_oid_len, struct snmp_node_instance* cell_instance);
|
||||
snmp_err_t (*get_next_cell_instance)(const u32_t* column, struct snmp_obj_id* row_oid, struct snmp_node_instance* cell_instance);
|
||||
/** returns object value for the given object identifier */
|
||||
node_instance_get_value_method get_value;
|
||||
/** tests length and/or range BEFORE setting */
|
||||
node_instance_set_test_method set_test;
|
||||
/** sets object value, only called when set_test() was successful */
|
||||
node_instance_set_value_method set_value;
|
||||
};
|
||||
|
||||
snmp_err_t snmp_table_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
snmp_err_t snmp_table_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
|
||||
#define SNMP_TABLE_CREATE(oid, columns, get_cell_instance_method, get_next_cell_instance_method, get_value_method, set_test_method, set_value_method) \
|
||||
{{{ SNMP_NODE_TABLE, (oid) }, \
|
||||
snmp_table_get_instance, \
|
||||
snmp_table_get_next_instance }, \
|
||||
(u16_t)LWIP_ARRAYSIZE(columns), (columns), \
|
||||
(get_cell_instance_method), (get_next_cell_instance_method), \
|
||||
(get_value_method), (set_test_method), (set_value_method)}
|
||||
|
||||
#define SNMP_TABLE_GET_COLUMN_FROM_OID(oid) ((oid)[1]) /* first array value is (fixed) row entry (fixed to 1) and 2nd value is column, follow3ed by instance */
|
||||
|
||||
|
||||
/** simple read-only table */
|
||||
typedef enum {
|
||||
SNMP_VARIANT_VALUE_TYPE_U32,
|
||||
SNMP_VARIANT_VALUE_TYPE_S32,
|
||||
SNMP_VARIANT_VALUE_TYPE_PTR,
|
||||
SNMP_VARIANT_VALUE_TYPE_CONST_PTR
|
||||
} snmp_table_column_data_type_t;
|
||||
|
||||
struct snmp_table_simple_col_def
|
||||
{
|
||||
u32_t index;
|
||||
u8_t asn1_type;
|
||||
snmp_table_column_data_type_t data_type; /* depending of what union member is used to store the value*/
|
||||
};
|
||||
|
||||
/** simple read-only table node */
|
||||
struct snmp_table_simple_node
|
||||
{
|
||||
/* inherited "base class" members */
|
||||
struct snmp_leaf_node node;
|
||||
u16_t column_count;
|
||||
const struct snmp_table_simple_col_def* columns;
|
||||
snmp_err_t (*get_cell_value)(const u32_t* column, const u32_t* row_oid, u8_t row_oid_len, union snmp_variant_value* value, u32_t* value_len);
|
||||
snmp_err_t (*get_next_cell_instance_and_value)(const u32_t* column, struct snmp_obj_id* row_oid, union snmp_variant_value* value, u32_t* value_len);
|
||||
};
|
||||
|
||||
snmp_err_t snmp_table_simple_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
snmp_err_t snmp_table_simple_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
|
||||
#define SNMP_TABLE_CREATE_SIMPLE(oid, columns, get_cell_value_method, get_next_cell_instance_and_value_method) \
|
||||
{{{ SNMP_NODE_TABLE, (oid) }, \
|
||||
snmp_table_simple_get_instance, \
|
||||
snmp_table_simple_get_next_instance }, \
|
||||
(u16_t)LWIP_ARRAYSIZE(columns), (columns), (get_cell_value_method), (get_next_cell_instance_and_value_method) }
|
||||
|
||||
s16_t snmp_table_extract_value_from_s32ref(struct snmp_node_instance* instance, void* value);
|
||||
s16_t snmp_table_extract_value_from_u32ref(struct snmp_node_instance* instance, void* value);
|
||||
s16_t snmp_table_extract_value_from_refconstptr(struct snmp_node_instance* instance, void* value);
|
||||
|
||||
#endif /* LWIP_SNMP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_SNMP_TABLE_H */
|
114
tools/sdk/lwip2/include/lwip/apps/snmp_threadsync.h
Normal file
114
tools/sdk/lwip2/include/lwip/apps/snmp_threadsync.h
Normal file
@ -0,0 +1,114 @@
|
||||
/**
|
||||
* @file
|
||||
* SNMP server MIB API to implement thread synchronization
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Dirk Ziegelmeier <dziegel@gmx.de>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_APPS_SNMP_THREADSYNC_H
|
||||
#define LWIP_HDR_APPS_SNMP_THREADSYNC_H
|
||||
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/apps/snmp_core.h"
|
||||
#include "lwip/sys.h"
|
||||
|
||||
typedef void (*snmp_threadsync_called_fn)(void* arg);
|
||||
typedef void (*snmp_threadsync_synchronizer_fn)(snmp_threadsync_called_fn fn, void* arg);
|
||||
|
||||
|
||||
/** Thread sync runtime data. For internal usage only. */
|
||||
struct threadsync_data
|
||||
{
|
||||
union {
|
||||
snmp_err_t err;
|
||||
s16_t s16;
|
||||
} retval;
|
||||
union {
|
||||
const u32_t *root_oid;
|
||||
void *value;
|
||||
} arg1;
|
||||
union {
|
||||
u8_t root_oid_len;
|
||||
u16_t len;
|
||||
} arg2;
|
||||
const struct snmp_threadsync_node *threadsync_node;
|
||||
struct snmp_node_instance proxy_instance;
|
||||
};
|
||||
|
||||
/** Thread sync instance. Needed EXCATLY once for every thread to be synced into. */
|
||||
struct snmp_threadsync_instance
|
||||
{
|
||||
sys_sem_t sem;
|
||||
sys_mutex_t sem_usage_mutex;
|
||||
snmp_threadsync_synchronizer_fn sync_fn;
|
||||
struct threadsync_data data;
|
||||
};
|
||||
|
||||
/** SNMP thread sync proxy leaf node */
|
||||
struct snmp_threadsync_node
|
||||
{
|
||||
/* inherited "base class" members */
|
||||
struct snmp_leaf_node node;
|
||||
|
||||
const struct snmp_leaf_node *target;
|
||||
struct snmp_threadsync_instance *instance;
|
||||
};
|
||||
|
||||
snmp_err_t snmp_threadsync_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
snmp_err_t snmp_threadsync_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
|
||||
/** Create thread sync proxy node */
|
||||
#define SNMP_CREATE_THREAD_SYNC_NODE(oid, target_leaf_node, threadsync_instance) \
|
||||
{{{ SNMP_NODE_THREADSYNC, (oid) }, \
|
||||
snmp_threadsync_get_instance, \
|
||||
snmp_threadsync_get_next_instance }, \
|
||||
(target_leaf_node), \
|
||||
(threadsync_instance) }
|
||||
|
||||
/** Create thread sync instance data */
|
||||
void snmp_threadsync_init(struct snmp_threadsync_instance *instance, snmp_threadsync_synchronizer_fn sync_fn);
|
||||
|
||||
#endif /* LWIP_SNMP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_SNMP_THREADSYNC_H */
|
90
tools/sdk/lwip2/include/lwip/apps/snmpv3.h
Normal file
90
tools/sdk/lwip2/include/lwip/apps/snmpv3.h
Normal file
@ -0,0 +1,90 @@
|
||||
/**
|
||||
* @file
|
||||
* Additional SNMPv3 functionality RFC3414 and RFC3826.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016 Elias Oenal.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* Author: Elias Oenal <lwip@eliasoenal.com>
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_APPS_SNMP_V3_H
|
||||
#define LWIP_HDR_APPS_SNMP_V3_H
|
||||
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
#include "lwip/err.h"
|
||||
|
||||
#if LWIP_SNMP && LWIP_SNMP_V3
|
||||
|
||||
#define SNMP_V3_AUTH_ALGO_INVAL 0
|
||||
#define SNMP_V3_AUTH_ALGO_MD5 1
|
||||
#define SNMP_V3_AUTH_ALGO_SHA 2
|
||||
|
||||
#define SNMP_V3_PRIV_ALGO_INVAL 0
|
||||
#define SNMP_V3_PRIV_ALGO_DES 1
|
||||
#define SNMP_V3_PRIV_ALGO_AES 2
|
||||
|
||||
#define SNMP_V3_PRIV_MODE_DECRYPT 0
|
||||
#define SNMP_V3_PRIV_MODE_ENCRYPT 1
|
||||
|
||||
/*
|
||||
* The following callback functions must be implemented by the application.
|
||||
* There is a dummy implementation in snmpv3_dummy.c.
|
||||
*/
|
||||
|
||||
void snmpv3_get_engine_id(const char **id, u8_t *len);
|
||||
err_t snmpv3_set_engine_id(const char* id, u8_t len);
|
||||
|
||||
u32_t snmpv3_get_engine_boots(void);
|
||||
void snmpv3_set_engine_boots(u32_t boots);
|
||||
|
||||
u32_t snmpv3_get_engine_time(void);
|
||||
void snmpv3_reset_engine_time(void);
|
||||
|
||||
err_t snmpv3_get_user(const char* username, u8_t *auth_algo, u8_t *auth_key, u8_t *priv_algo, u8_t *priv_key);
|
||||
|
||||
/* The following functions are provided by the SNMPv3 agent */
|
||||
|
||||
void snmpv3_engine_id_changed(void);
|
||||
|
||||
void snmpv3_password_to_key_md5(
|
||||
const u8_t *password, /* IN */
|
||||
u8_t passwordlen, /* IN */
|
||||
const u8_t *engineID, /* IN - pointer to snmpEngineID */
|
||||
u8_t engineLength, /* IN - length of snmpEngineID */
|
||||
u8_t *key); /* OUT - pointer to caller 16-octet buffer */
|
||||
|
||||
void snmpv3_password_to_key_sha(
|
||||
const u8_t *password, /* IN */
|
||||
u8_t passwordlen, /* IN */
|
||||
const u8_t *engineID, /* IN - pointer to snmpEngineID */
|
||||
u8_t engineLength, /* IN - length of snmpEngineID */
|
||||
u8_t *key); /* OUT - pointer to caller 20-octet buffer */
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_SNMP_V3_H */
|
76
tools/sdk/lwip2/include/lwip/apps/sntp.h
Normal file
76
tools/sdk/lwip2/include/lwip/apps/sntp.h
Normal file
@ -0,0 +1,76 @@
|
||||
/**
|
||||
* @file
|
||||
* SNTP client API
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007-2009 Frédéric Bernon, Simon Goldschmidt
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Frédéric Bernon, Simon Goldschmidt
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_APPS_SNTP_H
|
||||
#define LWIP_HDR_APPS_SNTP_H
|
||||
|
||||
#include "lwip/apps/sntp_opts.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* SNTP operating modes: default is to poll using unicast.
|
||||
The mode has to be set before calling sntp_init(). */
|
||||
#define SNTP_OPMODE_POLL 0
|
||||
#define SNTP_OPMODE_LISTENONLY 1
|
||||
void sntp_setoperatingmode(u8_t operating_mode);
|
||||
u8_t sntp_getoperatingmode(void);
|
||||
|
||||
void sntp_init(void);
|
||||
void sntp_stop(void);
|
||||
u8_t sntp_enabled(void);
|
||||
|
||||
void sntp_setserver(u8_t idx, const ip_addr_t *addr);
|
||||
const ip_addr_t* sntp_getserver(u8_t idx);
|
||||
|
||||
#if SNTP_SERVER_DNS
|
||||
void sntp_setservername(u8_t idx, char *server);
|
||||
char *sntp_getservername(u8_t idx);
|
||||
#endif /* SNTP_SERVER_DNS */
|
||||
|
||||
#if SNTP_GET_SERVERS_FROM_DHCP
|
||||
void sntp_servermode_dhcp(int set_servers_from_dhcp);
|
||||
#else /* SNTP_GET_SERVERS_FROM_DHCP */
|
||||
#define sntp_servermode_dhcp(x)
|
||||
#endif /* SNTP_GET_SERVERS_FROM_DHCP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_SNTP_H */
|
173
tools/sdk/lwip2/include/lwip/apps/sntp_opts.h
Normal file
173
tools/sdk/lwip2/include/lwip/apps/sntp_opts.h
Normal file
@ -0,0 +1,173 @@
|
||||
/**
|
||||
* @file
|
||||
* SNTP client options list
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007-2009 Frédéric Bernon, Simon Goldschmidt
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Frédéric Bernon, Simon Goldschmidt
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_APPS_SNTP_OPTS_H
|
||||
#define LWIP_HDR_APPS_SNTP_OPTS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/**
|
||||
* @defgroup sntp_opts Options
|
||||
* @ingroup sntp
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** SNTP macro to change system time in seconds
|
||||
* Define SNTP_SET_SYSTEM_TIME_US(sec, us) to set the time in microseconds instead of this one
|
||||
* if you need the additional precision.
|
||||
*/
|
||||
#if !defined SNTP_SET_SYSTEM_TIME || defined __DOXYGEN__
|
||||
#define SNTP_SET_SYSTEM_TIME(sec) LWIP_UNUSED_ARG(sec)
|
||||
#endif
|
||||
|
||||
/** The maximum number of SNTP servers that can be set */
|
||||
#if !defined SNTP_MAX_SERVERS || defined __DOXYGEN__
|
||||
#define SNTP_MAX_SERVERS LWIP_DHCP_MAX_NTP_SERVERS
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to implement the callback function called by dhcp when
|
||||
* NTP servers are received. */
|
||||
#if !defined SNTP_GET_SERVERS_FROM_DHCP || defined __DOXYGEN__
|
||||
#define SNTP_GET_SERVERS_FROM_DHCP LWIP_DHCP_GET_NTP_SRV
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to support DNS names (or IP address strings) to set sntp servers
|
||||
* One server address/name can be defined as default if SNTP_SERVER_DNS == 1:
|
||||
* \#define SNTP_SERVER_ADDRESS "pool.ntp.org"
|
||||
*/
|
||||
#if !defined SNTP_SERVER_DNS || defined __DOXYGEN__
|
||||
#define SNTP_SERVER_DNS 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNTP_DEBUG: Enable debugging for SNTP.
|
||||
*/
|
||||
#if !defined SNTP_DEBUG || defined __DOXYGEN__
|
||||
#define SNTP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
/** SNTP server port */
|
||||
#if !defined SNTP_PORT || defined __DOXYGEN__
|
||||
#define SNTP_PORT 123
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to allow config of SNTP server(s) by DNS name */
|
||||
#if !defined SNTP_SERVER_DNS || defined __DOXYGEN__
|
||||
#define SNTP_SERVER_DNS 0
|
||||
#endif
|
||||
|
||||
/** Sanity check:
|
||||
* Define this to
|
||||
* - 0 to turn off sanity checks (default; smaller code)
|
||||
* - >= 1 to check address and port of the response packet to ensure the
|
||||
* response comes from the server we sent the request to.
|
||||
* - >= 2 to check returned Originate Timestamp against Transmit Timestamp
|
||||
* sent to the server (to ensure response to older request).
|
||||
* - >= 3 @todo: discard reply if any of the LI, Stratum, or Transmit Timestamp
|
||||
* fields is 0 or the Mode field is not 4 (unicast) or 5 (broadcast).
|
||||
* - >= 4 @todo: to check that the Root Delay and Root Dispersion fields are each
|
||||
* greater than or equal to 0 and less than infinity, where infinity is
|
||||
* currently a cozy number like one second. This check avoids using a
|
||||
* server whose synchronization source has expired for a very long time.
|
||||
*/
|
||||
#if !defined SNTP_CHECK_RESPONSE || defined __DOXYGEN__
|
||||
#define SNTP_CHECK_RESPONSE 0
|
||||
#endif
|
||||
|
||||
/** According to the RFC, this shall be a random delay
|
||||
* between 1 and 5 minutes (in milliseconds) to prevent load peaks.
|
||||
* This can be defined to a random generation function,
|
||||
* which must return the delay in milliseconds as u32_t.
|
||||
* Turned off by default.
|
||||
*/
|
||||
#if !defined SNTP_STARTUP_DELAY || defined __DOXYGEN__
|
||||
#define SNTP_STARTUP_DELAY 0
|
||||
#endif
|
||||
|
||||
/** If you want the startup delay to be a function, define this
|
||||
* to a function (including the brackets) and define SNTP_STARTUP_DELAY to 1.
|
||||
*/
|
||||
#if !defined SNTP_STARTUP_DELAY_FUNC || defined __DOXYGEN__
|
||||
#define SNTP_STARTUP_DELAY_FUNC SNTP_STARTUP_DELAY
|
||||
#endif
|
||||
|
||||
/** SNTP receive timeout - in milliseconds
|
||||
* Also used as retry timeout - this shouldn't be too low.
|
||||
* Default is 3 seconds.
|
||||
*/
|
||||
#if !defined SNTP_RECV_TIMEOUT || defined __DOXYGEN__
|
||||
#define SNTP_RECV_TIMEOUT 3000
|
||||
#endif
|
||||
|
||||
/** SNTP update delay - in milliseconds
|
||||
* Default is 1 hour. Must not be beolw 15 seconds by specification (i.e. 15000)
|
||||
*/
|
||||
#if !defined SNTP_UPDATE_DELAY || defined __DOXYGEN__
|
||||
#define SNTP_UPDATE_DELAY 3600000
|
||||
#endif
|
||||
|
||||
/** SNTP macro to get system time, used with SNTP_CHECK_RESPONSE >= 2
|
||||
* to send in request and compare in response.
|
||||
*/
|
||||
#if !defined SNTP_GET_SYSTEM_TIME || defined __DOXYGEN__
|
||||
#define SNTP_GET_SYSTEM_TIME(sec, us) do { (sec) = 0; (us) = 0; } while(0)
|
||||
#endif
|
||||
|
||||
/** Default retry timeout (in milliseconds) if the response
|
||||
* received is invalid.
|
||||
* This is doubled with each retry until SNTP_RETRY_TIMEOUT_MAX is reached.
|
||||
*/
|
||||
#if !defined SNTP_RETRY_TIMEOUT || defined __DOXYGEN__
|
||||
#define SNTP_RETRY_TIMEOUT SNTP_RECV_TIMEOUT
|
||||
#endif
|
||||
|
||||
/** Maximum retry timeout (in milliseconds). */
|
||||
#if !defined SNTP_RETRY_TIMEOUT_MAX || defined __DOXYGEN__
|
||||
#define SNTP_RETRY_TIMEOUT_MAX (SNTP_RETRY_TIMEOUT * 10)
|
||||
#endif
|
||||
|
||||
/** Increase retry timeout with every retry sent
|
||||
* Default is on to conform to RFC.
|
||||
*/
|
||||
#if !defined SNTP_RETRY_TIMEOUT_EXP || defined __DOXYGEN__
|
||||
#define SNTP_RETRY_TIMEOUT_EXP 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* LWIP_HDR_APPS_SNTP_OPTS_H */
|
105
tools/sdk/lwip2/include/lwip/apps/tftp_opts.h
Normal file
105
tools/sdk/lwip2/include/lwip/apps/tftp_opts.h
Normal file
@ -0,0 +1,105 @@
|
||||
/****************************************************************//**
|
||||
*
|
||||
* @file tftp_opts.h
|
||||
*
|
||||
* @author Logan Gunthorpe <logang@deltatee.com>
|
||||
*
|
||||
* @brief Trivial File Transfer Protocol (RFC 1350) implementation options
|
||||
*
|
||||
* Copyright (c) Deltatee Enterprises Ltd. 2013
|
||||
* All rights reserved.
|
||||
*
|
||||
********************************************************************/
|
||||
|
||||
/*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification,are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Author: Logan Gunthorpe <logang@deltatee.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_APPS_TFTP_OPTS_H
|
||||
#define LWIP_HDR_APPS_TFTP_OPTS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/**
|
||||
* @defgroup tftp_opts Options
|
||||
* @ingroup tftp
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enable TFTP debug messages
|
||||
*/
|
||||
#if !defined TFTP_DEBUG || defined __DOXYGEN__
|
||||
#define TFTP_DEBUG LWIP_DBG_ON
|
||||
#endif
|
||||
|
||||
/**
|
||||
* TFTP server port
|
||||
*/
|
||||
#if !defined TFTP_PORT || defined __DOXYGEN__
|
||||
#define TFTP_PORT 69
|
||||
#endif
|
||||
|
||||
/**
|
||||
* TFTP timeout
|
||||
*/
|
||||
#if !defined TFTP_TIMEOUT_MSECS || defined __DOXYGEN__
|
||||
#define TFTP_TIMEOUT_MSECS 10000
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Max. number of retries when a file is read from server
|
||||
*/
|
||||
#if !defined TFTP_MAX_RETRIES || defined __DOXYGEN__
|
||||
#define TFTP_MAX_RETRIES 5
|
||||
#endif
|
||||
|
||||
/**
|
||||
* TFTP timer cyclic interval
|
||||
*/
|
||||
#if !defined TFTP_TIMER_MSECS || defined __DOXYGEN__
|
||||
#define TFTP_TIMER_MSECS 50
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Max. length of TFTP filename
|
||||
*/
|
||||
#if !defined TFTP_MAX_FILENAME_LEN || defined __DOXYGEN__
|
||||
#define TFTP_MAX_FILENAME_LEN 20
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Max. length of TFTP mode
|
||||
*/
|
||||
#if !defined TFTP_MAX_MODE_LEN || defined __DOXYGEN__
|
||||
#define TFTP_MAX_MODE_LEN 7
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* LWIP_HDR_APPS_TFTP_OPTS_H */
|
94
tools/sdk/lwip2/include/lwip/apps/tftp_server.h
Normal file
94
tools/sdk/lwip2/include/lwip/apps/tftp_server.h
Normal file
@ -0,0 +1,94 @@
|
||||
/****************************************************************//**
|
||||
*
|
||||
* @file tftp_server.h
|
||||
*
|
||||
* @author Logan Gunthorpe <logang@deltatee.com>
|
||||
*
|
||||
* @brief Trivial File Transfer Protocol (RFC 1350)
|
||||
*
|
||||
* Copyright (c) Deltatee Enterprises Ltd. 2013
|
||||
* All rights reserved.
|
||||
*
|
||||
********************************************************************/
|
||||
|
||||
/*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification,are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Author: Logan Gunthorpe <logang@deltatee.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_APPS_TFTP_SERVER_H
|
||||
#define LWIP_HDR_APPS_TFTP_SERVER_H
|
||||
|
||||
#include "lwip/apps/tftp_opts.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/pbuf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @ingroup tftp
|
||||
* TFTP context containing callback functions for TFTP transfers
|
||||
*/
|
||||
struct tftp_context {
|
||||
/**
|
||||
* Open file for read/write.
|
||||
* @param fname Filename
|
||||
* @param mode Mode string from TFTP RFC 1350 (netascii, octet, mail)
|
||||
* @param write Flag indicating read (0) or write (!= 0) access
|
||||
* @returns File handle supplied to other functions
|
||||
*/
|
||||
void* (*open)(const char* fname, const char* mode, u8_t write);
|
||||
/**
|
||||
* Close file handle
|
||||
* @param handle File handle returned by open()
|
||||
*/
|
||||
void (*close)(void* handle);
|
||||
/**
|
||||
* Read from file
|
||||
* @param handle File handle returned by open()
|
||||
* @param buf Target buffer to copy read data to
|
||||
* @param bytes Number of bytes to copy to buf
|
||||
* @returns >= 0: Success; < 0: Error
|
||||
*/
|
||||
int (*read)(void* handle, void* buf, int bytes);
|
||||
/**
|
||||
* Write to file
|
||||
* @param handle File handle returned by open()
|
||||
* @param pbuf PBUF adjusted such that payload pointer points
|
||||
* to the beginning of write data. In other words,
|
||||
* TFTP headers are stripped off.
|
||||
* @returns >= 0: Success; < 0: Error
|
||||
*/
|
||||
int (*write)(void* handle, struct pbuf* p);
|
||||
};
|
||||
|
||||
err_t tftp_init(const struct tftp_context* ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_TFTP_SERVER_H */
|
Reference in New Issue
Block a user