mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-16 21:01:31 +00:00
Change over unix line-endings to dos line endings.
This commit is contained in:
parent
842e219bf3
commit
27eb17cb93
@ -401,7 +401,7 @@ static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* cons
|
|||||||
ChannelData->PSM = ConnectionRequest.PSM;
|
ChannelData->PSM = ConnectionRequest.PSM;
|
||||||
ChannelData->LocalMTU = MAXIMUM_CHANNEL_MTU;
|
ChannelData->LocalMTU = MAXIMUM_CHANNEL_MTU;
|
||||||
ChannelData->State = Channel_Config_WaitConfig;
|
ChannelData->State = Channel_Config_WaitConfig;
|
||||||
|
|
||||||
ChannelStatus = BT_CONNECTION_SUCCESSFUL;
|
ChannelStatus = BT_CONNECTION_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
/* Enable C linkage for C++ Compilers: */
|
/* Enable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Preprocessor Checks: */
|
/* Preprocessor Checks: */
|
||||||
#if !defined(__INCLUDE_FROM_PRINTER_DRIVER)
|
#if !defined(__INCLUDE_FROM_PRINTER_DRIVER)
|
||||||
|
@ -1,165 +1,165 @@
|
|||||||
GNU LESSER GENERAL PUBLIC LICENSE
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
Version 3, 29 June 2007
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
|
||||||
This version of the GNU Lesser General Public License incorporates
|
This version of the GNU Lesser General Public License incorporates
|
||||||
the terms and conditions of version 3 of the GNU General Public
|
the terms and conditions of version 3 of the GNU General Public
|
||||||
License, supplemented by the additional permissions listed below.
|
License, supplemented by the additional permissions listed below.
|
||||||
|
|
||||||
0. Additional Definitions.
|
0. Additional Definitions.
|
||||||
|
|
||||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||||
General Public License.
|
General Public License.
|
||||||
|
|
||||||
"The Library" refers to a covered work governed by this License,
|
"The Library" refers to a covered work governed by this License,
|
||||||
other than an Application or a Combined Work as defined below.
|
other than an Application or a Combined Work as defined below.
|
||||||
|
|
||||||
An "Application" is any work that makes use of an interface provided
|
An "Application" is any work that makes use of an interface provided
|
||||||
by the Library, but which is not otherwise based on the Library.
|
by the Library, but which is not otherwise based on the Library.
|
||||||
Defining a subclass of a class defined by the Library is deemed a mode
|
Defining a subclass of a class defined by the Library is deemed a mode
|
||||||
of using an interface provided by the Library.
|
of using an interface provided by the Library.
|
||||||
|
|
||||||
A "Combined Work" is a work produced by combining or linking an
|
A "Combined Work" is a work produced by combining or linking an
|
||||||
Application with the Library. The particular version of the Library
|
Application with the Library. The particular version of the Library
|
||||||
with which the Combined Work was made is also called the "Linked
|
with which the Combined Work was made is also called the "Linked
|
||||||
Version".
|
Version".
|
||||||
|
|
||||||
The "Minimal Corresponding Source" for a Combined Work means the
|
The "Minimal Corresponding Source" for a Combined Work means the
|
||||||
Corresponding Source for the Combined Work, excluding any source code
|
Corresponding Source for the Combined Work, excluding any source code
|
||||||
for portions of the Combined Work that, considered in isolation, are
|
for portions of the Combined Work that, considered in isolation, are
|
||||||
based on the Application, and not on the Linked Version.
|
based on the Application, and not on the Linked Version.
|
||||||
|
|
||||||
The "Corresponding Application Code" for a Combined Work means the
|
The "Corresponding Application Code" for a Combined Work means the
|
||||||
object code and/or source code for the Application, including any data
|
object code and/or source code for the Application, including any data
|
||||||
and utility programs needed for reproducing the Combined Work from the
|
and utility programs needed for reproducing the Combined Work from the
|
||||||
Application, but excluding the System Libraries of the Combined Work.
|
Application, but excluding the System Libraries of the Combined Work.
|
||||||
|
|
||||||
1. Exception to Section 3 of the GNU GPL.
|
1. Exception to Section 3 of the GNU GPL.
|
||||||
|
|
||||||
You may convey a covered work under sections 3 and 4 of this License
|
You may convey a covered work under sections 3 and 4 of this License
|
||||||
without being bound by section 3 of the GNU GPL.
|
without being bound by section 3 of the GNU GPL.
|
||||||
|
|
||||||
2. Conveying Modified Versions.
|
2. Conveying Modified Versions.
|
||||||
|
|
||||||
If you modify a copy of the Library, and, in your modifications, a
|
If you modify a copy of the Library, and, in your modifications, a
|
||||||
facility refers to a function or data to be supplied by an Application
|
facility refers to a function or data to be supplied by an Application
|
||||||
that uses the facility (other than as an argument passed when the
|
that uses the facility (other than as an argument passed when the
|
||||||
facility is invoked), then you may convey a copy of the modified
|
facility is invoked), then you may convey a copy of the modified
|
||||||
version:
|
version:
|
||||||
|
|
||||||
a) under this License, provided that you make a good faith effort to
|
a) under this License, provided that you make a good faith effort to
|
||||||
ensure that, in the event an Application does not supply the
|
ensure that, in the event an Application does not supply the
|
||||||
function or data, the facility still operates, and performs
|
function or data, the facility still operates, and performs
|
||||||
whatever part of its purpose remains meaningful, or
|
whatever part of its purpose remains meaningful, or
|
||||||
|
|
||||||
b) under the GNU GPL, with none of the additional permissions of
|
b) under the GNU GPL, with none of the additional permissions of
|
||||||
this License applicable to that copy.
|
this License applicable to that copy.
|
||||||
|
|
||||||
3. Object Code Incorporating Material from Library Header Files.
|
3. Object Code Incorporating Material from Library Header Files.
|
||||||
|
|
||||||
The object code form of an Application may incorporate material from
|
The object code form of an Application may incorporate material from
|
||||||
a header file that is part of the Library. You may convey such object
|
a header file that is part of the Library. You may convey such object
|
||||||
code under terms of your choice, provided that, if the incorporated
|
code under terms of your choice, provided that, if the incorporated
|
||||||
material is not limited to numerical parameters, data structure
|
material is not limited to numerical parameters, data structure
|
||||||
layouts and accessors, or small macros, inline functions and templates
|
layouts and accessors, or small macros, inline functions and templates
|
||||||
(ten or fewer lines in length), you do both of the following:
|
(ten or fewer lines in length), you do both of the following:
|
||||||
|
|
||||||
a) Give prominent notice with each copy of the object code that the
|
a) Give prominent notice with each copy of the object code that the
|
||||||
Library is used in it and that the Library and its use are
|
Library is used in it and that the Library and its use are
|
||||||
covered by this License.
|
covered by this License.
|
||||||
|
|
||||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||||
document.
|
document.
|
||||||
|
|
||||||
4. Combined Works.
|
4. Combined Works.
|
||||||
|
|
||||||
You may convey a Combined Work under terms of your choice that,
|
You may convey a Combined Work under terms of your choice that,
|
||||||
taken together, effectively do not restrict modification of the
|
taken together, effectively do not restrict modification of the
|
||||||
portions of the Library contained in the Combined Work and reverse
|
portions of the Library contained in the Combined Work and reverse
|
||||||
engineering for debugging such modifications, if you also do each of
|
engineering for debugging such modifications, if you also do each of
|
||||||
the following:
|
the following:
|
||||||
|
|
||||||
a) Give prominent notice with each copy of the Combined Work that
|
a) Give prominent notice with each copy of the Combined Work that
|
||||||
the Library is used in it and that the Library and its use are
|
the Library is used in it and that the Library and its use are
|
||||||
covered by this License.
|
covered by this License.
|
||||||
|
|
||||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||||
document.
|
document.
|
||||||
|
|
||||||
c) For a Combined Work that displays copyright notices during
|
c) For a Combined Work that displays copyright notices during
|
||||||
execution, include the copyright notice for the Library among
|
execution, include the copyright notice for the Library among
|
||||||
these notices, as well as a reference directing the user to the
|
these notices, as well as a reference directing the user to the
|
||||||
copies of the GNU GPL and this license document.
|
copies of the GNU GPL and this license document.
|
||||||
|
|
||||||
d) Do one of the following:
|
d) Do one of the following:
|
||||||
|
|
||||||
0) Convey the Minimal Corresponding Source under the terms of this
|
0) Convey the Minimal Corresponding Source under the terms of this
|
||||||
License, and the Corresponding Application Code in a form
|
License, and the Corresponding Application Code in a form
|
||||||
suitable for, and under terms that permit, the user to
|
suitable for, and under terms that permit, the user to
|
||||||
recombine or relink the Application with a modified version of
|
recombine or relink the Application with a modified version of
|
||||||
the Linked Version to produce a modified Combined Work, in the
|
the Linked Version to produce a modified Combined Work, in the
|
||||||
manner specified by section 6 of the GNU GPL for conveying
|
manner specified by section 6 of the GNU GPL for conveying
|
||||||
Corresponding Source.
|
Corresponding Source.
|
||||||
|
|
||||||
1) Use a suitable shared library mechanism for linking with the
|
1) Use a suitable shared library mechanism for linking with the
|
||||||
Library. A suitable mechanism is one that (a) uses at run time
|
Library. A suitable mechanism is one that (a) uses at run time
|
||||||
a copy of the Library already present on the user's computer
|
a copy of the Library already present on the user's computer
|
||||||
system, and (b) will operate properly with a modified version
|
system, and (b) will operate properly with a modified version
|
||||||
of the Library that is interface-compatible with the Linked
|
of the Library that is interface-compatible with the Linked
|
||||||
Version.
|
Version.
|
||||||
|
|
||||||
e) Provide Installation Information, but only if you would otherwise
|
e) Provide Installation Information, but only if you would otherwise
|
||||||
be required to provide such information under section 6 of the
|
be required to provide such information under section 6 of the
|
||||||
GNU GPL, and only to the extent that such information is
|
GNU GPL, and only to the extent that such information is
|
||||||
necessary to install and execute a modified version of the
|
necessary to install and execute a modified version of the
|
||||||
Combined Work produced by recombining or relinking the
|
Combined Work produced by recombining or relinking the
|
||||||
Application with a modified version of the Linked Version. (If
|
Application with a modified version of the Linked Version. (If
|
||||||
you use option 4d0, the Installation Information must accompany
|
you use option 4d0, the Installation Information must accompany
|
||||||
the Minimal Corresponding Source and Corresponding Application
|
the Minimal Corresponding Source and Corresponding Application
|
||||||
Code. If you use option 4d1, you must provide the Installation
|
Code. If you use option 4d1, you must provide the Installation
|
||||||
Information in the manner specified by section 6 of the GNU GPL
|
Information in the manner specified by section 6 of the GNU GPL
|
||||||
for conveying Corresponding Source.)
|
for conveying Corresponding Source.)
|
||||||
|
|
||||||
5. Combined Libraries.
|
5. Combined Libraries.
|
||||||
|
|
||||||
You may place library facilities that are a work based on the
|
You may place library facilities that are a work based on the
|
||||||
Library side by side in a single library together with other library
|
Library side by side in a single library together with other library
|
||||||
facilities that are not Applications and are not covered by this
|
facilities that are not Applications and are not covered by this
|
||||||
License, and convey such a combined library under terms of your
|
License, and convey such a combined library under terms of your
|
||||||
choice, if you do both of the following:
|
choice, if you do both of the following:
|
||||||
|
|
||||||
a) Accompany the combined library with a copy of the same work based
|
a) Accompany the combined library with a copy of the same work based
|
||||||
on the Library, uncombined with any other library facilities,
|
on the Library, uncombined with any other library facilities,
|
||||||
conveyed under the terms of this License.
|
conveyed under the terms of this License.
|
||||||
|
|
||||||
b) Give prominent notice with the combined library that part of it
|
b) Give prominent notice with the combined library that part of it
|
||||||
is a work based on the Library, and explaining where to find the
|
is a work based on the Library, and explaining where to find the
|
||||||
accompanying uncombined form of the same work.
|
accompanying uncombined form of the same work.
|
||||||
|
|
||||||
6. Revised Versions of the GNU Lesser General Public License.
|
6. Revised Versions of the GNU Lesser General Public License.
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions
|
The Free Software Foundation may publish revised and/or new versions
|
||||||
of the GNU Lesser General Public License from time to time. Such new
|
of the GNU Lesser General Public License from time to time. Such new
|
||||||
versions will be similar in spirit to the present version, but may
|
versions will be similar in spirit to the present version, but may
|
||||||
differ in detail to address new problems or concerns.
|
differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
Each version is given a distinguishing version number. If the
|
||||||
Library as you received it specifies that a certain numbered version
|
Library as you received it specifies that a certain numbered version
|
||||||
of the GNU Lesser General Public License "or any later version"
|
of the GNU Lesser General Public License "or any later version"
|
||||||
applies to it, you have the option of following the terms and
|
applies to it, you have the option of following the terms and
|
||||||
conditions either of that published version or of any later version
|
conditions either of that published version or of any later version
|
||||||
published by the Free Software Foundation. If the Library as you
|
published by the Free Software Foundation. If the Library as you
|
||||||
received it does not specify a version number of the GNU Lesser
|
received it does not specify a version number of the GNU Lesser
|
||||||
General Public License, you may choose any version of the GNU Lesser
|
General Public License, you may choose any version of the GNU Lesser
|
||||||
General Public License ever published by the Free Software Foundation.
|
General Public License ever published by the Free Software Foundation.
|
||||||
|
|
||||||
If the Library as you received it specifies that a proxy can decide
|
If the Library as you received it specifies that a proxy can decide
|
||||||
whether future versions of the GNU Lesser General Public License shall
|
whether future versions of the GNU Lesser General Public License shall
|
||||||
apply, that proxy's public statement of acceptance of any version is
|
apply, that proxy's public statement of acceptance of any version is
|
||||||
permanent authorization for you to choose that version for the
|
permanent authorization for you to choose that version for the
|
||||||
Library.
|
Library.
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
|
|
||||||
#include "Descriptors.h"
|
#include "Descriptors.h"
|
||||||
|
|
||||||
#include <LUFA/Common/Common.h>
|
#include <LUFA/Common/Common.h>
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#include <LUFA/Drivers/USB/USB.h>
|
#include <LUFA/Drivers/USB/USB.h>
|
||||||
#include <LUFA/Drivers/USB/Class/MassStorage.h>
|
#include <LUFA/Drivers/USB/Class/MassStorage.h>
|
||||||
|
|
||||||
#include "../Descriptors.h"
|
#include "../Descriptors.h"
|
||||||
#include "DataflashManager.h"
|
#include "DataflashManager.h"
|
||||||
|
|
||||||
|
@ -1,38 +1,38 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/sfr_defs.h>
|
#include <avr/sfr_defs.h>
|
||||||
|
|
||||||
#include "clock.h"
|
#include "clock.h"
|
||||||
|
|
||||||
//Counted time
|
//Counted time
|
||||||
volatile clock_time_t clock_datetime = 0;
|
volatile clock_time_t clock_datetime = 0;
|
||||||
|
|
||||||
//Overflow interrupt
|
//Overflow interrupt
|
||||||
ISR(TIMER1_COMPA_vect)
|
ISR(TIMER1_COMPA_vect)
|
||||||
{
|
{
|
||||||
clock_datetime += 1;
|
clock_datetime += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Initialise the clock
|
//Initialise the clock
|
||||||
void clock_init()
|
void clock_init()
|
||||||
{
|
{
|
||||||
OCR1A = ((F_CPU / 1024) / 100);
|
OCR1A = ((F_CPU / 1024) / 100);
|
||||||
TCCR1B = ((1 << WGM12) | (1 << CS12) | (1 << CS10));
|
TCCR1B = ((1 << WGM12) | (1 << CS12) | (1 << CS10));
|
||||||
TIMSK1 = (1 << OCIE1A);
|
TIMSK1 = (1 << OCIE1A);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Return time
|
//Return time
|
||||||
clock_time_t clock_time()
|
clock_time_t clock_time()
|
||||||
{
|
{
|
||||||
clock_time_t time;
|
clock_time_t time;
|
||||||
|
|
||||||
ATOMIC_BLOCK(ATOMIC_FORCEON)
|
ATOMIC_BLOCK(ATOMIC_FORCEON)
|
||||||
{
|
{
|
||||||
time = clock_datetime;
|
time = clock_datetime;
|
||||||
}
|
}
|
||||||
|
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#ifndef __CLOCK_ARCH_H__
|
#ifndef __CLOCK_ARCH_H__
|
||||||
#define __CLOCK_ARCH_H__
|
#define __CLOCK_ARCH_H__
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <util/atomic.h>
|
#include <util/atomic.h>
|
||||||
|
|
||||||
|
@ -1,127 +1,127 @@
|
|||||||
/**
|
/**
|
||||||
* \addtogroup timer
|
* \addtogroup timer
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
* Timer library implementation.
|
* Timer library implementation.
|
||||||
* \author
|
* \author
|
||||||
* Adam Dunkels <adam@sics.se>
|
* Adam Dunkels <adam@sics.se>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* 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
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* This file is part of the uIP TCP/IP stack
|
* This file is part of the uIP TCP/IP stack
|
||||||
*
|
*
|
||||||
* Author: Adam Dunkels <adam@sics.se>
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
*
|
*
|
||||||
* $Id: timer.c,v 1.2 2006/06/12 08:00:30 adam Exp $
|
* $Id: timer.c,v 1.2 2006/06/12 08:00:30 adam Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "clock.h"
|
#include "clock.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* Set a timer.
|
* Set a timer.
|
||||||
*
|
*
|
||||||
* This function is used to set a timer for a time sometime in the
|
* This function is used to set a timer for a time sometime in the
|
||||||
* future. The function timer_expired() will evaluate to true after
|
* future. The function timer_expired() will evaluate to true after
|
||||||
* the timer has expired.
|
* the timer has expired.
|
||||||
*
|
*
|
||||||
* \param t A pointer to the timer
|
* \param t A pointer to the timer
|
||||||
* \param interval The interval before the timer expires.
|
* \param interval The interval before the timer expires.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
timer_set(struct timer *t, clock_time_t interval)
|
timer_set(struct timer *t, clock_time_t interval)
|
||||||
{
|
{
|
||||||
t->interval = interval;
|
t->interval = interval;
|
||||||
t->start = clock_time();
|
t->start = clock_time();
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* Reset the timer with the same interval.
|
* Reset the timer with the same interval.
|
||||||
*
|
*
|
||||||
* This function resets the timer with the same interval that was
|
* This function resets the timer with the same interval that was
|
||||||
* given to the timer_set() function. The start point of the interval
|
* given to the timer_set() function. The start point of the interval
|
||||||
* is the exact time that the timer last expired. Therefore, this
|
* is the exact time that the timer last expired. Therefore, this
|
||||||
* function will cause the timer to be stable over time, unlike the
|
* function will cause the timer to be stable over time, unlike the
|
||||||
* timer_rester() function.
|
* timer_rester() function.
|
||||||
*
|
*
|
||||||
* \param t A pointer to the timer.
|
* \param t A pointer to the timer.
|
||||||
*
|
*
|
||||||
* \sa timer_restart()
|
* \sa timer_restart()
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
timer_reset(struct timer *t)
|
timer_reset(struct timer *t)
|
||||||
{
|
{
|
||||||
t->start += t->interval;
|
t->start += t->interval;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* Restart the timer from the current point in time
|
* Restart the timer from the current point in time
|
||||||
*
|
*
|
||||||
* This function restarts a timer with the same interval that was
|
* This function restarts a timer with the same interval that was
|
||||||
* given to the timer_set() function. The timer will start at the
|
* given to the timer_set() function. The timer will start at the
|
||||||
* current time.
|
* current time.
|
||||||
*
|
*
|
||||||
* \note A periodic timer will drift if this function is used to reset
|
* \note A periodic timer will drift if this function is used to reset
|
||||||
* it. For preioric timers, use the timer_reset() function instead.
|
* it. For preioric timers, use the timer_reset() function instead.
|
||||||
*
|
*
|
||||||
* \param t A pointer to the timer.
|
* \param t A pointer to the timer.
|
||||||
*
|
*
|
||||||
* \sa timer_reset()
|
* \sa timer_reset()
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
timer_restart(struct timer *t)
|
timer_restart(struct timer *t)
|
||||||
{
|
{
|
||||||
t->start = clock_time();
|
t->start = clock_time();
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* Check if a timer has expired.
|
* Check if a timer has expired.
|
||||||
*
|
*
|
||||||
* This function tests if a timer has expired and returns true or
|
* This function tests if a timer has expired and returns true or
|
||||||
* false depending on its status.
|
* false depending on its status.
|
||||||
*
|
*
|
||||||
* \param t A pointer to the timer
|
* \param t A pointer to the timer
|
||||||
*
|
*
|
||||||
* \return Non-zero if the timer has expired, zero otherwise.
|
* \return Non-zero if the timer has expired, zero otherwise.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
timer_expired(struct timer *t)
|
timer_expired(struct timer *t)
|
||||||
{
|
{
|
||||||
return (clock_time_t)(clock_time() - t->start) >= (clock_time_t)t->interval;
|
return (clock_time_t)(clock_time() - t->start) >= (clock_time_t)t->interval;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
@ -1,86 +1,86 @@
|
|||||||
/**
|
/**
|
||||||
* \defgroup timer Timer library
|
* \defgroup timer Timer library
|
||||||
*
|
*
|
||||||
* The timer library provides functions for setting, resetting and
|
* The timer library provides functions for setting, resetting and
|
||||||
* restarting timers, and for checking if a timer has expired. An
|
* restarting timers, and for checking if a timer has expired. An
|
||||||
* application must "manually" check if its timers have expired; this
|
* application must "manually" check if its timers have expired; this
|
||||||
* is not done automatically.
|
* is not done automatically.
|
||||||
*
|
*
|
||||||
* A timer is declared as a \c struct \c timer and all access to the
|
* A timer is declared as a \c struct \c timer and all access to the
|
||||||
* timer is made by a pointer to the declared timer.
|
* timer is made by a pointer to the declared timer.
|
||||||
*
|
*
|
||||||
* \note The timer library uses the \ref clock "Clock library" to
|
* \note The timer library uses the \ref clock "Clock library" to
|
||||||
* measure time. Intervals should be specified in the format used by
|
* measure time. Intervals should be specified in the format used by
|
||||||
* the clock library.
|
* the clock library.
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
* Timer library header file.
|
* Timer library header file.
|
||||||
* \author
|
* \author
|
||||||
* Adam Dunkels <adam@sics.se>
|
* Adam Dunkels <adam@sics.se>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* 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
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* This file is part of the uIP TCP/IP stack
|
* This file is part of the uIP TCP/IP stack
|
||||||
*
|
*
|
||||||
* Author: Adam Dunkels <adam@sics.se>
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
*
|
*
|
||||||
* $Id: timer.h,v 1.3 2006/06/11 21:46:39 adam Exp $
|
* $Id: timer.h,v 1.3 2006/06/11 21:46:39 adam Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef __TIMER_H__
|
#ifndef __TIMER_H__
|
||||||
#define __TIMER_H__
|
#define __TIMER_H__
|
||||||
|
|
||||||
#include "clock.h"
|
#include "clock.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A timer.
|
* A timer.
|
||||||
*
|
*
|
||||||
* This structure is used for declaring a timer. The timer must be set
|
* This structure is used for declaring a timer. The timer must be set
|
||||||
* with timer_set() before it can be used.
|
* with timer_set() before it can be used.
|
||||||
*
|
*
|
||||||
* \hideinitializer
|
* \hideinitializer
|
||||||
*/
|
*/
|
||||||
struct timer {
|
struct timer {
|
||||||
clock_time_t start;
|
clock_time_t start;
|
||||||
clock_time_t interval;
|
clock_time_t interval;
|
||||||
};
|
};
|
||||||
|
|
||||||
void timer_set(struct timer *t, clock_time_t interval);
|
void timer_set(struct timer *t, clock_time_t interval);
|
||||||
void timer_reset(struct timer *t);
|
void timer_reset(struct timer *t);
|
||||||
void timer_restart(struct timer *t);
|
void timer_restart(struct timer *t);
|
||||||
int timer_expired(struct timer *t);
|
int timer_expired(struct timer *t);
|
||||||
|
|
||||||
#endif /* __TIMER_H__ */
|
#endif /* __TIMER_H__ */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
@ -1,141 +1,141 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* 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
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* Author: Adam Dunkels <adam@sics.se>
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
*
|
*
|
||||||
* $Id: uip-split.c,v 1.2 2008/10/14 13:39:12 julienabeille Exp $
|
* $Id: uip-split.c,v 1.2 2008/10/14 13:39:12 julienabeille Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "uip-split.h"
|
#include "uip-split.h"
|
||||||
|
|
||||||
|
|
||||||
#define BUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
|
#define BUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
uip_split_output(void)
|
uip_split_output(void)
|
||||||
{
|
{
|
||||||
#if UIP_TCP
|
#if UIP_TCP
|
||||||
u16_t tcplen, len1, len2;
|
u16_t tcplen, len1, len2;
|
||||||
|
|
||||||
/* We only try to split maximum sized TCP segments. */
|
/* We only try to split maximum sized TCP segments. */
|
||||||
if(BUF->proto == UIP_PROTO_TCP && uip_len == UIP_BUFSIZE) {
|
if(BUF->proto == UIP_PROTO_TCP && uip_len == UIP_BUFSIZE) {
|
||||||
|
|
||||||
tcplen = uip_len - UIP_TCPIP_HLEN - UIP_LLH_LEN;
|
tcplen = uip_len - UIP_TCPIP_HLEN - UIP_LLH_LEN;
|
||||||
/* Split the segment in two. If the original packet length was
|
/* Split the segment in two. If the original packet length was
|
||||||
odd, we make the second packet one byte larger. */
|
odd, we make the second packet one byte larger. */
|
||||||
len1 = len2 = tcplen / 2;
|
len1 = len2 = tcplen / 2;
|
||||||
if(len1 + len2 < tcplen) {
|
if(len1 + len2 < tcplen) {
|
||||||
++len2;
|
++len2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the first packet. This is done by altering the length
|
/* Create the first packet. This is done by altering the length
|
||||||
field of the IP header and updating the checksums. */
|
field of the IP header and updating the checksums. */
|
||||||
uip_len = len1 + UIP_TCPIP_HLEN + UIP_LLH_LEN;
|
uip_len = len1 + UIP_TCPIP_HLEN + UIP_LLH_LEN;
|
||||||
#if UIP_CONF_IPV6
|
#if UIP_CONF_IPV6
|
||||||
/* For IPv6, the IP length field does not include the IPv6 IP header
|
/* For IPv6, the IP length field does not include the IPv6 IP header
|
||||||
length. */
|
length. */
|
||||||
BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8);
|
BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8);
|
||||||
BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);
|
BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);
|
||||||
#else /* UIP_CONF_IPV6 */
|
#else /* UIP_CONF_IPV6 */
|
||||||
BUF->len[0] = (uip_len - UIP_LLH_LEN) >> 8;
|
BUF->len[0] = (uip_len - UIP_LLH_LEN) >> 8;
|
||||||
BUF->len[1] = (uip_len - UIP_LLH_LEN) & 0xff;
|
BUF->len[1] = (uip_len - UIP_LLH_LEN) & 0xff;
|
||||||
#endif /* UIP_CONF_IPV6 */
|
#endif /* UIP_CONF_IPV6 */
|
||||||
|
|
||||||
/* Recalculate the TCP checksum. */
|
/* Recalculate the TCP checksum. */
|
||||||
BUF->tcpchksum = 0;
|
BUF->tcpchksum = 0;
|
||||||
BUF->tcpchksum = ~(uip_tcpchksum());
|
BUF->tcpchksum = ~(uip_tcpchksum());
|
||||||
|
|
||||||
#if !UIP_CONF_IPV6
|
#if !UIP_CONF_IPV6
|
||||||
/* Recalculate the IP checksum. */
|
/* Recalculate the IP checksum. */
|
||||||
BUF->ipchksum = 0;
|
BUF->ipchksum = 0;
|
||||||
BUF->ipchksum = ~(uip_ipchksum());
|
BUF->ipchksum = ~(uip_ipchksum());
|
||||||
#endif /* UIP_CONF_IPV6 */
|
#endif /* UIP_CONF_IPV6 */
|
||||||
|
|
||||||
/* Transmit the first packet. */
|
/* Transmit the first packet. */
|
||||||
#if UIP_CONF_IPV6
|
#if UIP_CONF_IPV6
|
||||||
tcpip_ipv6_output();
|
tcpip_ipv6_output();
|
||||||
#else
|
#else
|
||||||
RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len);
|
RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len);
|
||||||
#endif /* UIP_CONF_IPV6 */
|
#endif /* UIP_CONF_IPV6 */
|
||||||
|
|
||||||
/* Now, create the second packet. To do this, it is not enough to
|
/* Now, create the second packet. To do this, it is not enough to
|
||||||
just alter the length field, but we must also update the TCP
|
just alter the length field, but we must also update the TCP
|
||||||
sequence number and point the uip_appdata to a new place in
|
sequence number and point the uip_appdata to a new place in
|
||||||
memory. This place is detemined by the length of the first
|
memory. This place is detemined by the length of the first
|
||||||
packet (len1). */
|
packet (len1). */
|
||||||
uip_len = len2 + UIP_TCPIP_HLEN + UIP_LLH_LEN;
|
uip_len = len2 + UIP_TCPIP_HLEN + UIP_LLH_LEN;
|
||||||
#if UIP_CONF_IPV6
|
#if UIP_CONF_IPV6
|
||||||
/* For IPv6, the IP length field does not include the IPv6 IP header
|
/* For IPv6, the IP length field does not include the IPv6 IP header
|
||||||
length. */
|
length. */
|
||||||
BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8);
|
BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8);
|
||||||
BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);
|
BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);
|
||||||
#else /* UIP_CONF_IPV6 */
|
#else /* UIP_CONF_IPV6 */
|
||||||
BUF->len[0] = (uip_len - UIP_LLH_LEN) >> 8;
|
BUF->len[0] = (uip_len - UIP_LLH_LEN) >> 8;
|
||||||
BUF->len[1] = (uip_len - UIP_LLH_LEN) & 0xff;
|
BUF->len[1] = (uip_len - UIP_LLH_LEN) & 0xff;
|
||||||
#endif /* UIP_CONF_IPV6 */
|
#endif /* UIP_CONF_IPV6 */
|
||||||
|
|
||||||
memcpy(uip_appdata, (u8_t *)uip_appdata + len1, len2);
|
memcpy(uip_appdata, (u8_t *)uip_appdata + len1, len2);
|
||||||
|
|
||||||
uip_add32(BUF->seqno, len1);
|
uip_add32(BUF->seqno, len1);
|
||||||
BUF->seqno[0] = uip_acc32[0];
|
BUF->seqno[0] = uip_acc32[0];
|
||||||
BUF->seqno[1] = uip_acc32[1];
|
BUF->seqno[1] = uip_acc32[1];
|
||||||
BUF->seqno[2] = uip_acc32[2];
|
BUF->seqno[2] = uip_acc32[2];
|
||||||
BUF->seqno[3] = uip_acc32[3];
|
BUF->seqno[3] = uip_acc32[3];
|
||||||
|
|
||||||
/* Recalculate the TCP checksum. */
|
/* Recalculate the TCP checksum. */
|
||||||
BUF->tcpchksum = 0;
|
BUF->tcpchksum = 0;
|
||||||
BUF->tcpchksum = ~(uip_tcpchksum());
|
BUF->tcpchksum = ~(uip_tcpchksum());
|
||||||
|
|
||||||
#if !UIP_CONF_IPV6
|
#if !UIP_CONF_IPV6
|
||||||
/* Recalculate the IP checksum. */
|
/* Recalculate the IP checksum. */
|
||||||
BUF->ipchksum = 0;
|
BUF->ipchksum = 0;
|
||||||
BUF->ipchksum = ~(uip_ipchksum());
|
BUF->ipchksum = ~(uip_ipchksum());
|
||||||
#endif /* UIP_CONF_IPV6 */
|
#endif /* UIP_CONF_IPV6 */
|
||||||
|
|
||||||
/* Transmit the second packet. */
|
/* Transmit the second packet. */
|
||||||
#if UIP_CONF_IPV6
|
#if UIP_CONF_IPV6
|
||||||
tcpip_ipv6_output();
|
tcpip_ipv6_output();
|
||||||
#else
|
#else
|
||||||
RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len);
|
RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len);
|
||||||
#endif /* UIP_CONF_IPV6 */
|
#endif /* UIP_CONF_IPV6 */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif /* UIP_TCP */
|
#endif /* UIP_TCP */
|
||||||
|
|
||||||
/* uip_fw_output();*/
|
/* uip_fw_output();*/
|
||||||
#if UIP_CONF_IPV6
|
#if UIP_CONF_IPV6
|
||||||
tcpip_ipv6_output();
|
tcpip_ipv6_output();
|
||||||
#else
|
#else
|
||||||
RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len);
|
RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len);
|
||||||
#endif /* UIP_CONF_IPV6 */
|
#endif /* UIP_CONF_IPV6 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
@ -1,103 +1,103 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* 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
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* Author: Adam Dunkels <adam@sics.se>
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
*
|
*
|
||||||
* $Id: uip-split.h,v 1.1 2006/06/17 22:41:19 adamdunkels Exp $
|
* $Id: uip-split.h,v 1.1 2006/06/17 22:41:19 adamdunkels Exp $
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* \addtogroup uip
|
* \addtogroup uip
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \defgroup uipsplit uIP TCP throughput booster hack
|
* \defgroup uipsplit uIP TCP throughput booster hack
|
||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
* The basic uIP TCP implementation only allows each TCP connection to
|
* The basic uIP TCP implementation only allows each TCP connection to
|
||||||
* have a single TCP segment in flight at any given time. Because of
|
* have a single TCP segment in flight at any given time. Because of
|
||||||
* the delayed ACK algorithm employed by most TCP receivers, uIP's
|
* the delayed ACK algorithm employed by most TCP receivers, uIP's
|
||||||
* limit on the amount of in-flight TCP segments seriously reduces the
|
* limit on the amount of in-flight TCP segments seriously reduces the
|
||||||
* maximum achievable throughput for sending data from uIP.
|
* maximum achievable throughput for sending data from uIP.
|
||||||
*
|
*
|
||||||
* The uip-split module is a hack which tries to remedy this
|
* The uip-split module is a hack which tries to remedy this
|
||||||
* situation. By splitting maximum sized outgoing TCP segments into
|
* situation. By splitting maximum sized outgoing TCP segments into
|
||||||
* two, the delayed ACK algorithm is not invoked at TCP
|
* two, the delayed ACK algorithm is not invoked at TCP
|
||||||
* receivers. This improves the throughput when sending data from uIP
|
* receivers. This improves the throughput when sending data from uIP
|
||||||
* by orders of magnitude.
|
* by orders of magnitude.
|
||||||
*
|
*
|
||||||
* The uip-split module uses the uip-fw module (uIP IP packet
|
* The uip-split module uses the uip-fw module (uIP IP packet
|
||||||
* forwarding) for sending packets. Therefore, the uip-fw module must
|
* forwarding) for sending packets. Therefore, the uip-fw module must
|
||||||
* be set up with the appropriate network interfaces for this module
|
* be set up with the appropriate network interfaces for this module
|
||||||
* to work.
|
* to work.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
* Module for splitting outbound TCP segments in two to avoid the
|
* Module for splitting outbound TCP segments in two to avoid the
|
||||||
* delayed ACK throughput degradation.
|
* delayed ACK throughput degradation.
|
||||||
* \author
|
* \author
|
||||||
* Adam Dunkels <adam@sics.se>
|
* Adam Dunkels <adam@sics.se>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __UIP_SPLIT_H__
|
#ifndef __UIP_SPLIT_H__
|
||||||
#define __UIP_SPLIT_H__
|
#define __UIP_SPLIT_H__
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <uip.h>
|
#include <uip.h>
|
||||||
|
|
||||||
#include "../../USBHostMode.h"
|
#include "../../USBHostMode.h"
|
||||||
|
|
||||||
#include <LUFA/Drivers/USB/Class/RNDIS.h>
|
#include <LUFA/Drivers/USB/Class/RNDIS.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle outgoing packets.
|
* Handle outgoing packets.
|
||||||
*
|
*
|
||||||
* This function inspects an outgoing packet in the uip_buf buffer and
|
* This function inspects an outgoing packet in the uip_buf buffer and
|
||||||
* sends it out using the uip_fw_output() function. If the packet is a
|
* sends it out using the uip_fw_output() function. If the packet is a
|
||||||
* full-sized TCP segment it will be split into two segments and
|
* full-sized TCP segment it will be split into two segments and
|
||||||
* transmitted separately. This function should be called instead of
|
* transmitted separately. This function should be called instead of
|
||||||
* the actual device driver output function, or the uip_fw_output()
|
* the actual device driver output function, or the uip_fw_output()
|
||||||
* function.
|
* function.
|
||||||
*
|
*
|
||||||
* The headers of the outgoing packet is assumed to be in the uip_buf
|
* The headers of the outgoing packet is assumed to be in the uip_buf
|
||||||
* buffer and the payload is assumed to be wherever uip_appdata
|
* buffer and the payload is assumed to be wherever uip_appdata
|
||||||
* points. The length of the outgoing packet is assumed to be in the
|
* points. The length of the outgoing packet is assumed to be in the
|
||||||
* uip_len variable.
|
* uip_len variable.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void uip_split_output(void);
|
void uip_split_output(void);
|
||||||
void uip_add32(u8_t *op32, u16_t op16);
|
void uip_add32(u8_t *op32, u16_t op16);
|
||||||
#endif /* __UIP_SPLIT_H__ */
|
#endif /* __UIP_SPLIT_H__ */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,431 +1,431 @@
|
|||||||
/**
|
/**
|
||||||
* \addtogroup uip
|
* \addtogroup uip
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \defgroup uiparp uIP Address Resolution Protocol
|
* \defgroup uiparp uIP Address Resolution Protocol
|
||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
* The Address Resolution Protocol ARP is used for mapping between IP
|
* The Address Resolution Protocol ARP is used for mapping between IP
|
||||||
* addresses and link level addresses such as the Ethernet MAC
|
* addresses and link level addresses such as the Ethernet MAC
|
||||||
* addresses. ARP uses broadcast queries to ask for the link level
|
* addresses. ARP uses broadcast queries to ask for the link level
|
||||||
* address of a known IP address and the host which is configured with
|
* address of a known IP address and the host which is configured with
|
||||||
* the IP address for which the query was meant, will respond with its
|
* the IP address for which the query was meant, will respond with its
|
||||||
* link level address.
|
* link level address.
|
||||||
*
|
*
|
||||||
* \note This ARP implementation only supports Ethernet.
|
* \note This ARP implementation only supports Ethernet.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
* Implementation of the ARP Address Resolution Protocol.
|
* Implementation of the ARP Address Resolution Protocol.
|
||||||
* \author Adam Dunkels <adam@dunkels.com>
|
* \author Adam Dunkels <adam@dunkels.com>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2003, Adam Dunkels.
|
* Copyright (c) 2001-2003, Adam Dunkels.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. The name of the author may not be used to endorse or promote
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
* products derived from this software without specific prior
|
* products derived from this software without specific prior
|
||||||
* written permission.
|
* written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* This file is part of the uIP TCP/IP stack.
|
* This file is part of the uIP TCP/IP stack.
|
||||||
*
|
*
|
||||||
* $Id: uip_arp.c,v 1.5 2008/02/07 01:35:00 adamdunkels Exp $
|
* $Id: uip_arp.c,v 1.5 2008/02/07 01:35:00 adamdunkels Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "uip_arp.h"
|
#include "uip_arp.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
struct arp_hdr {
|
struct arp_hdr {
|
||||||
struct uip_eth_hdr ethhdr;
|
struct uip_eth_hdr ethhdr;
|
||||||
u16_t hwtype;
|
u16_t hwtype;
|
||||||
u16_t protocol;
|
u16_t protocol;
|
||||||
u8_t hwlen;
|
u8_t hwlen;
|
||||||
u8_t protolen;
|
u8_t protolen;
|
||||||
u16_t opcode;
|
u16_t opcode;
|
||||||
struct uip_eth_addr shwaddr;
|
struct uip_eth_addr shwaddr;
|
||||||
uip_ipaddr_t sipaddr;
|
uip_ipaddr_t sipaddr;
|
||||||
struct uip_eth_addr dhwaddr;
|
struct uip_eth_addr dhwaddr;
|
||||||
uip_ipaddr_t dipaddr;
|
uip_ipaddr_t dipaddr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ethip_hdr {
|
struct ethip_hdr {
|
||||||
struct uip_eth_hdr ethhdr;
|
struct uip_eth_hdr ethhdr;
|
||||||
/* IP header. */
|
/* IP header. */
|
||||||
u8_t vhl,
|
u8_t vhl,
|
||||||
tos,
|
tos,
|
||||||
len[2],
|
len[2],
|
||||||
ipid[2],
|
ipid[2],
|
||||||
ipoffset[2],
|
ipoffset[2],
|
||||||
ttl,
|
ttl,
|
||||||
proto;
|
proto;
|
||||||
u16_t ipchksum;
|
u16_t ipchksum;
|
||||||
uip_ipaddr_t srcipaddr, destipaddr;
|
uip_ipaddr_t srcipaddr, destipaddr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ARP_REQUEST 1
|
#define ARP_REQUEST 1
|
||||||
#define ARP_REPLY 2
|
#define ARP_REPLY 2
|
||||||
|
|
||||||
#define ARP_HWTYPE_ETH 1
|
#define ARP_HWTYPE_ETH 1
|
||||||
|
|
||||||
struct arp_entry {
|
struct arp_entry {
|
||||||
uip_ipaddr_t ipaddr;
|
uip_ipaddr_t ipaddr;
|
||||||
struct uip_eth_addr ethaddr;
|
struct uip_eth_addr ethaddr;
|
||||||
u8_t time;
|
u8_t time;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct uip_eth_addr broadcast_ethaddr =
|
static const struct uip_eth_addr broadcast_ethaddr =
|
||||||
{{0xff,0xff,0xff,0xff,0xff,0xff}};
|
{{0xff,0xff,0xff,0xff,0xff,0xff}};
|
||||||
static const u16_t broadcast_ipaddr[2] = {0xffff,0xffff};
|
static const u16_t broadcast_ipaddr[2] = {0xffff,0xffff};
|
||||||
|
|
||||||
static struct arp_entry arp_table[UIP_ARPTAB_SIZE];
|
static struct arp_entry arp_table[UIP_ARPTAB_SIZE];
|
||||||
static uip_ipaddr_t ipaddr;
|
static uip_ipaddr_t ipaddr;
|
||||||
static u8_t i, c;
|
static u8_t i, c;
|
||||||
|
|
||||||
static u8_t arptime;
|
static u8_t arptime;
|
||||||
static u8_t tmpage;
|
static u8_t tmpage;
|
||||||
|
|
||||||
#define BUF ((struct arp_hdr *)&uip_buf[0])
|
#define BUF ((struct arp_hdr *)&uip_buf[0])
|
||||||
#define IPBUF ((struct ethip_hdr *)&uip_buf[0])
|
#define IPBUF ((struct ethip_hdr *)&uip_buf[0])
|
||||||
|
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#define PRINTF(...) printf(__VA_ARGS__)
|
#define PRINTF(...) printf(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define PRINTF(...)
|
#define PRINTF(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* Initialize the ARP module.
|
* Initialize the ARP module.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
uip_arp_init(void)
|
uip_arp_init(void)
|
||||||
{
|
{
|
||||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||||
memset(&arp_table[i].ipaddr, 0, 4);
|
memset(&arp_table[i].ipaddr, 0, 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* Periodic ARP processing function.
|
* Periodic ARP processing function.
|
||||||
*
|
*
|
||||||
* This function performs periodic timer processing in the ARP module
|
* This function performs periodic timer processing in the ARP module
|
||||||
* and should be called at regular intervals. The recommended interval
|
* and should be called at regular intervals. The recommended interval
|
||||||
* is 10 seconds between the calls.
|
* is 10 seconds between the calls.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
uip_arp_timer(void)
|
uip_arp_timer(void)
|
||||||
{
|
{
|
||||||
struct arp_entry *tabptr = NULL;
|
struct arp_entry *tabptr = NULL;
|
||||||
|
|
||||||
++arptime;
|
++arptime;
|
||||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||||
tabptr = &arp_table[i];
|
tabptr = &arp_table[i];
|
||||||
if(uip_ipaddr_cmp(&tabptr->ipaddr, &uip_all_zeroes_addr) &&
|
if(uip_ipaddr_cmp(&tabptr->ipaddr, &uip_all_zeroes_addr) &&
|
||||||
arptime - tabptr->time >= UIP_ARP_MAXAGE) {
|
arptime - tabptr->time >= UIP_ARP_MAXAGE) {
|
||||||
memset(&tabptr->ipaddr, 0, 4);
|
memset(&tabptr->ipaddr, 0, 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
uip_arp_update(uip_ipaddr_t *ipaddr, struct uip_eth_addr *ethaddr)
|
uip_arp_update(uip_ipaddr_t *ipaddr, struct uip_eth_addr *ethaddr)
|
||||||
{
|
{
|
||||||
register struct arp_entry *tabptr = NULL;
|
register struct arp_entry *tabptr = NULL;
|
||||||
/* Walk through the ARP mapping table and try to find an entry to
|
/* Walk through the ARP mapping table and try to find an entry to
|
||||||
update. If none is found, the IP -> MAC address mapping is
|
update. If none is found, the IP -> MAC address mapping is
|
||||||
inserted in the ARP table. */
|
inserted in the ARP table. */
|
||||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||||
|
|
||||||
tabptr = &arp_table[i];
|
tabptr = &arp_table[i];
|
||||||
/* Only check those entries that are actually in use. */
|
/* Only check those entries that are actually in use. */
|
||||||
if(!uip_ipaddr_cmp(&tabptr->ipaddr, &uip_all_zeroes_addr)) {
|
if(!uip_ipaddr_cmp(&tabptr->ipaddr, &uip_all_zeroes_addr)) {
|
||||||
|
|
||||||
/* Check if the source IP address of the incoming packet matches
|
/* Check if the source IP address of the incoming packet matches
|
||||||
the IP address in this ARP table entry. */
|
the IP address in this ARP table entry. */
|
||||||
if(uip_ipaddr_cmp(ipaddr, &tabptr->ipaddr)) {
|
if(uip_ipaddr_cmp(ipaddr, &tabptr->ipaddr)) {
|
||||||
|
|
||||||
/* An old entry found, update this and return. */
|
/* An old entry found, update this and return. */
|
||||||
memcpy(tabptr->ethaddr.addr, ethaddr->addr, 6);
|
memcpy(tabptr->ethaddr.addr, ethaddr->addr, 6);
|
||||||
tabptr->time = arptime;
|
tabptr->time = arptime;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we get here, no existing ARP table entry was found, so we
|
/* If we get here, no existing ARP table entry was found, so we
|
||||||
create one. */
|
create one. */
|
||||||
|
|
||||||
/* First, we try to find an unused entry in the ARP table. */
|
/* First, we try to find an unused entry in the ARP table. */
|
||||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||||
tabptr = &arp_table[i];
|
tabptr = &arp_table[i];
|
||||||
if(uip_ipaddr_cmp(&tabptr->ipaddr, &uip_all_zeroes_addr)) {
|
if(uip_ipaddr_cmp(&tabptr->ipaddr, &uip_all_zeroes_addr)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If no unused entry is found, we try to find the oldest entry and
|
/* If no unused entry is found, we try to find the oldest entry and
|
||||||
throw it away. */
|
throw it away. */
|
||||||
if(i == UIP_ARPTAB_SIZE) {
|
if(i == UIP_ARPTAB_SIZE) {
|
||||||
tmpage = 0;
|
tmpage = 0;
|
||||||
c = 0;
|
c = 0;
|
||||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||||
tabptr = &arp_table[i];
|
tabptr = &arp_table[i];
|
||||||
if(arptime - tabptr->time > tmpage) {
|
if(arptime - tabptr->time > tmpage) {
|
||||||
tmpage = arptime - tabptr->time;
|
tmpage = arptime - tabptr->time;
|
||||||
c = i;
|
c = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i = c;
|
i = c;
|
||||||
tabptr = &arp_table[i];
|
tabptr = &arp_table[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now, i is the ARP table entry which we will fill with the new
|
/* Now, i is the ARP table entry which we will fill with the new
|
||||||
information. */
|
information. */
|
||||||
uip_ipaddr_copy(&tabptr->ipaddr, ipaddr);
|
uip_ipaddr_copy(&tabptr->ipaddr, ipaddr);
|
||||||
memcpy(tabptr->ethaddr.addr, ethaddr->addr, 6);
|
memcpy(tabptr->ethaddr.addr, ethaddr->addr, 6);
|
||||||
tabptr->time = arptime;
|
tabptr->time = arptime;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* ARP processing for incoming IP packets
|
* ARP processing for incoming IP packets
|
||||||
*
|
*
|
||||||
* This function should be called by the device driver when an IP
|
* This function should be called by the device driver when an IP
|
||||||
* packet has been received. The function will check if the address is
|
* packet has been received. The function will check if the address is
|
||||||
* in the ARP cache, and if so the ARP cache entry will be
|
* in the ARP cache, and if so the ARP cache entry will be
|
||||||
* refreshed. If no ARP cache entry was found, a new one is created.
|
* refreshed. If no ARP cache entry was found, a new one is created.
|
||||||
*
|
*
|
||||||
* This function expects an IP packet with a prepended Ethernet header
|
* This function expects an IP packet with a prepended Ethernet header
|
||||||
* in the uip_buf[] buffer, and the length of the packet in the global
|
* in the uip_buf[] buffer, and the length of the packet in the global
|
||||||
* variable uip_len.
|
* variable uip_len.
|
||||||
*/
|
*/
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
#if 0
|
#if 0
|
||||||
void
|
void
|
||||||
uip_arp_ipin(void)
|
uip_arp_ipin(void)
|
||||||
{
|
{
|
||||||
uip_len -= sizeof(struct uip_eth_hdr);
|
uip_len -= sizeof(struct uip_eth_hdr);
|
||||||
|
|
||||||
/* Only insert/update an entry if the source IP address of the
|
/* Only insert/update an entry if the source IP address of the
|
||||||
incoming IP packet comes from a host on the local network. */
|
incoming IP packet comes from a host on the local network. */
|
||||||
if((IPBUF->srcipaddr[0] & uip_netmask[0]) !=
|
if((IPBUF->srcipaddr[0] & uip_netmask[0]) !=
|
||||||
(uip_hostaddr[0] & uip_netmask[0])) {
|
(uip_hostaddr[0] & uip_netmask[0])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if((IPBUF->srcipaddr[1] & uip_netmask[1]) !=
|
if((IPBUF->srcipaddr[1] & uip_netmask[1]) !=
|
||||||
(uip_hostaddr[1] & uip_netmask[1])) {
|
(uip_hostaddr[1] & uip_netmask[1])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uip_arp_update(IPBUF->srcipaddr, &(IPBUF->ethhdr.src));
|
uip_arp_update(IPBUF->srcipaddr, &(IPBUF->ethhdr.src));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif /* 0 */
|
#endif /* 0 */
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* ARP processing for incoming ARP packets.
|
* ARP processing for incoming ARP packets.
|
||||||
*
|
*
|
||||||
* This function should be called by the device driver when an ARP
|
* This function should be called by the device driver when an ARP
|
||||||
* packet has been received. The function will act differently
|
* packet has been received. The function will act differently
|
||||||
* depending on the ARP packet type: if it is a reply for a request
|
* depending on the ARP packet type: if it is a reply for a request
|
||||||
* that we previously sent out, the ARP cache will be filled in with
|
* that we previously sent out, the ARP cache will be filled in with
|
||||||
* the values from the ARP reply. If the incoming ARP packet is an ARP
|
* the values from the ARP reply. If the incoming ARP packet is an ARP
|
||||||
* request for our IP address, an ARP reply packet is created and put
|
* request for our IP address, an ARP reply packet is created and put
|
||||||
* into the uip_buf[] buffer.
|
* into the uip_buf[] buffer.
|
||||||
*
|
*
|
||||||
* When the function returns, the value of the global variable uip_len
|
* When the function returns, the value of the global variable uip_len
|
||||||
* indicates whether the device driver should send out a packet or
|
* indicates whether the device driver should send out a packet or
|
||||||
* not. If uip_len is zero, no packet should be sent. If uip_len is
|
* not. If uip_len is zero, no packet should be sent. If uip_len is
|
||||||
* non-zero, it contains the length of the outbound packet that is
|
* non-zero, it contains the length of the outbound packet that is
|
||||||
* present in the uip_buf[] buffer.
|
* present in the uip_buf[] buffer.
|
||||||
*
|
*
|
||||||
* This function expects an ARP packet with a prepended Ethernet
|
* This function expects an ARP packet with a prepended Ethernet
|
||||||
* header in the uip_buf[] buffer, and the length of the packet in the
|
* header in the uip_buf[] buffer, and the length of the packet in the
|
||||||
* global variable uip_len.
|
* global variable uip_len.
|
||||||
*/
|
*/
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
uip_arp_arpin(void)
|
uip_arp_arpin(void)
|
||||||
{
|
{
|
||||||
if(uip_len < sizeof(struct arp_hdr)) {
|
if(uip_len < sizeof(struct arp_hdr)) {
|
||||||
uip_len = 0;
|
uip_len = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uip_len = 0;
|
uip_len = 0;
|
||||||
|
|
||||||
switch(BUF->opcode) {
|
switch(BUF->opcode) {
|
||||||
case HTONS(ARP_REQUEST):
|
case HTONS(ARP_REQUEST):
|
||||||
/* ARP request. If it asked for our address, we send out a
|
/* ARP request. If it asked for our address, we send out a
|
||||||
reply. */
|
reply. */
|
||||||
/* if(BUF->dipaddr[0] == uip_hostaddr[0] &&
|
/* if(BUF->dipaddr[0] == uip_hostaddr[0] &&
|
||||||
BUF->dipaddr[1] == uip_hostaddr[1]) {*/
|
BUF->dipaddr[1] == uip_hostaddr[1]) {*/
|
||||||
PRINTF("uip_arp_arpin: request for %d.%d.%d.%d (we are %d.%d.%d.%d)\n",
|
PRINTF("uip_arp_arpin: request for %d.%d.%d.%d (we are %d.%d.%d.%d)\n",
|
||||||
BUF->dipaddr.u8[0], BUF->dipaddr.u8[1],
|
BUF->dipaddr.u8[0], BUF->dipaddr.u8[1],
|
||||||
BUF->dipaddr.u8[2], BUF->dipaddr.u8[3],
|
BUF->dipaddr.u8[2], BUF->dipaddr.u8[3],
|
||||||
uip_hostaddr.u8[0], uip_hostaddr.u8[1],
|
uip_hostaddr.u8[0], uip_hostaddr.u8[1],
|
||||||
uip_hostaddr.u8[2], uip_hostaddr.u8[3]);
|
uip_hostaddr.u8[2], uip_hostaddr.u8[3]);
|
||||||
if(uip_ipaddr_cmp(&BUF->dipaddr, &uip_hostaddr)) {
|
if(uip_ipaddr_cmp(&BUF->dipaddr, &uip_hostaddr)) {
|
||||||
/* First, we register the one who made the request in our ARP
|
/* First, we register the one who made the request in our ARP
|
||||||
table, since it is likely that we will do more communication
|
table, since it is likely that we will do more communication
|
||||||
with this host in the future. */
|
with this host in the future. */
|
||||||
uip_arp_update(&BUF->sipaddr, &BUF->shwaddr);
|
uip_arp_update(&BUF->sipaddr, &BUF->shwaddr);
|
||||||
|
|
||||||
BUF->opcode = HTONS(ARP_REPLY);
|
BUF->opcode = HTONS(ARP_REPLY);
|
||||||
|
|
||||||
memcpy(BUF->dhwaddr.addr, BUF->shwaddr.addr, 6);
|
memcpy(BUF->dhwaddr.addr, BUF->shwaddr.addr, 6);
|
||||||
memcpy(BUF->shwaddr.addr, uip_ethaddr.addr, 6);
|
memcpy(BUF->shwaddr.addr, uip_ethaddr.addr, 6);
|
||||||
memcpy(BUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
|
memcpy(BUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
|
||||||
memcpy(BUF->ethhdr.dest.addr, BUF->dhwaddr.addr, 6);
|
memcpy(BUF->ethhdr.dest.addr, BUF->dhwaddr.addr, 6);
|
||||||
|
|
||||||
uip_ipaddr_copy(&BUF->dipaddr, &BUF->sipaddr);
|
uip_ipaddr_copy(&BUF->dipaddr, &BUF->sipaddr);
|
||||||
uip_ipaddr_copy(&BUF->sipaddr, &uip_hostaddr);
|
uip_ipaddr_copy(&BUF->sipaddr, &uip_hostaddr);
|
||||||
|
|
||||||
BUF->ethhdr.type = HTONS(UIP_ETHTYPE_ARP);
|
BUF->ethhdr.type = HTONS(UIP_ETHTYPE_ARP);
|
||||||
uip_len = sizeof(struct arp_hdr);
|
uip_len = sizeof(struct arp_hdr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HTONS(ARP_REPLY):
|
case HTONS(ARP_REPLY):
|
||||||
/* ARP reply. We insert or update the ARP table if it was meant
|
/* ARP reply. We insert or update the ARP table if it was meant
|
||||||
for us. */
|
for us. */
|
||||||
if(uip_ipaddr_cmp(&BUF->dipaddr, &uip_hostaddr)) {
|
if(uip_ipaddr_cmp(&BUF->dipaddr, &uip_hostaddr)) {
|
||||||
uip_arp_update(&BUF->sipaddr, &BUF->shwaddr);
|
uip_arp_update(&BUF->sipaddr, &BUF->shwaddr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* Prepend Ethernet header to an outbound IP packet and see if we need
|
* Prepend Ethernet header to an outbound IP packet and see if we need
|
||||||
* to send out an ARP request.
|
* to send out an ARP request.
|
||||||
*
|
*
|
||||||
* This function should be called before sending out an IP packet. The
|
* This function should be called before sending out an IP packet. The
|
||||||
* function checks the destination IP address of the IP packet to see
|
* function checks the destination IP address of the IP packet to see
|
||||||
* what Ethernet MAC address that should be used as a destination MAC
|
* what Ethernet MAC address that should be used as a destination MAC
|
||||||
* address on the Ethernet.
|
* address on the Ethernet.
|
||||||
*
|
*
|
||||||
* If the destination IP address is in the local network (determined
|
* If the destination IP address is in the local network (determined
|
||||||
* by logical ANDing of netmask and our IP address), the function
|
* by logical ANDing of netmask and our IP address), the function
|
||||||
* checks the ARP cache to see if an entry for the destination IP
|
* checks the ARP cache to see if an entry for the destination IP
|
||||||
* address is found. If so, an Ethernet header is prepended and the
|
* address is found. If so, an Ethernet header is prepended and the
|
||||||
* function returns. If no ARP cache entry is found for the
|
* function returns. If no ARP cache entry is found for the
|
||||||
* destination IP address, the packet in the uip_buf[] is replaced by
|
* destination IP address, the packet in the uip_buf[] is replaced by
|
||||||
* an ARP request packet for the IP address. The IP packet is dropped
|
* an ARP request packet for the IP address. The IP packet is dropped
|
||||||
* and it is assumed that they higher level protocols (e.g., TCP)
|
* and it is assumed that they higher level protocols (e.g., TCP)
|
||||||
* eventually will retransmit the dropped packet.
|
* eventually will retransmit the dropped packet.
|
||||||
*
|
*
|
||||||
* If the destination IP address is not on the local network, the IP
|
* If the destination IP address is not on the local network, the IP
|
||||||
* address of the default router is used instead.
|
* address of the default router is used instead.
|
||||||
*
|
*
|
||||||
* When the function returns, a packet is present in the uip_buf[]
|
* When the function returns, a packet is present in the uip_buf[]
|
||||||
* buffer, and the length of the packet is in the global variable
|
* buffer, and the length of the packet is in the global variable
|
||||||
* uip_len.
|
* uip_len.
|
||||||
*/
|
*/
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
uip_arp_out(void)
|
uip_arp_out(void)
|
||||||
{
|
{
|
||||||
struct arp_entry *tabptr = NULL;
|
struct arp_entry *tabptr = NULL;
|
||||||
|
|
||||||
/* Find the destination IP address in the ARP table and construct
|
/* Find the destination IP address in the ARP table and construct
|
||||||
the Ethernet header. If the destination IP addres isn't on the
|
the Ethernet header. If the destination IP addres isn't on the
|
||||||
local network, we use the default router's IP address instead.
|
local network, we use the default router's IP address instead.
|
||||||
|
|
||||||
If not ARP table entry is found, we overwrite the original IP
|
If not ARP table entry is found, we overwrite the original IP
|
||||||
packet with an ARP request for the IP address. */
|
packet with an ARP request for the IP address. */
|
||||||
|
|
||||||
/* First check if destination is a local broadcast. */
|
/* First check if destination is a local broadcast. */
|
||||||
if(uip_ipaddr_cmp(&IPBUF->destipaddr, &uip_broadcast_addr)) {
|
if(uip_ipaddr_cmp(&IPBUF->destipaddr, &uip_broadcast_addr)) {
|
||||||
memcpy(IPBUF->ethhdr.dest.addr, broadcast_ethaddr.addr, 6);
|
memcpy(IPBUF->ethhdr.dest.addr, broadcast_ethaddr.addr, 6);
|
||||||
} else {
|
} else {
|
||||||
/* Check if the destination address is on the local network. */
|
/* Check if the destination address is on the local network. */
|
||||||
if(!uip_ipaddr_maskcmp(&IPBUF->destipaddr, &uip_hostaddr, &uip_netmask)) {
|
if(!uip_ipaddr_maskcmp(&IPBUF->destipaddr, &uip_hostaddr, &uip_netmask)) {
|
||||||
/* Destination address was not on the local network, so we need to
|
/* Destination address was not on the local network, so we need to
|
||||||
use the default router's IP address instead of the destination
|
use the default router's IP address instead of the destination
|
||||||
address when determining the MAC address. */
|
address when determining the MAC address. */
|
||||||
uip_ipaddr_copy(&ipaddr, &uip_draddr);
|
uip_ipaddr_copy(&ipaddr, &uip_draddr);
|
||||||
} else {
|
} else {
|
||||||
/* Else, we use the destination IP address. */
|
/* Else, we use the destination IP address. */
|
||||||
uip_ipaddr_copy(&ipaddr, &IPBUF->destipaddr);
|
uip_ipaddr_copy(&ipaddr, &IPBUF->destipaddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||||
tabptr = &arp_table[i];
|
tabptr = &arp_table[i];
|
||||||
if(uip_ipaddr_cmp(&ipaddr, &tabptr->ipaddr)) {
|
if(uip_ipaddr_cmp(&ipaddr, &tabptr->ipaddr)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i == UIP_ARPTAB_SIZE) {
|
if(i == UIP_ARPTAB_SIZE) {
|
||||||
/* The destination address was not in our ARP table, so we
|
/* The destination address was not in our ARP table, so we
|
||||||
overwrite the IP packet with an ARP request. */
|
overwrite the IP packet with an ARP request. */
|
||||||
|
|
||||||
memset(BUF->ethhdr.dest.addr, 0xff, 6);
|
memset(BUF->ethhdr.dest.addr, 0xff, 6);
|
||||||
memset(BUF->dhwaddr.addr, 0x00, 6);
|
memset(BUF->dhwaddr.addr, 0x00, 6);
|
||||||
memcpy(BUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
|
memcpy(BUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
|
||||||
memcpy(BUF->shwaddr.addr, uip_ethaddr.addr, 6);
|
memcpy(BUF->shwaddr.addr, uip_ethaddr.addr, 6);
|
||||||
|
|
||||||
uip_ipaddr_copy(&BUF->dipaddr, &ipaddr);
|
uip_ipaddr_copy(&BUF->dipaddr, &ipaddr);
|
||||||
uip_ipaddr_copy(&BUF->sipaddr, &uip_hostaddr);
|
uip_ipaddr_copy(&BUF->sipaddr, &uip_hostaddr);
|
||||||
BUF->opcode = HTONS(ARP_REQUEST); /* ARP request. */
|
BUF->opcode = HTONS(ARP_REQUEST); /* ARP request. */
|
||||||
BUF->hwtype = HTONS(ARP_HWTYPE_ETH);
|
BUF->hwtype = HTONS(ARP_HWTYPE_ETH);
|
||||||
BUF->protocol = HTONS(UIP_ETHTYPE_IP);
|
BUF->protocol = HTONS(UIP_ETHTYPE_IP);
|
||||||
BUF->hwlen = 6;
|
BUF->hwlen = 6;
|
||||||
BUF->protolen = 4;
|
BUF->protolen = 4;
|
||||||
BUF->ethhdr.type = HTONS(UIP_ETHTYPE_ARP);
|
BUF->ethhdr.type = HTONS(UIP_ETHTYPE_ARP);
|
||||||
|
|
||||||
uip_appdata = &uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN];
|
uip_appdata = &uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN];
|
||||||
|
|
||||||
uip_len = sizeof(struct arp_hdr);
|
uip_len = sizeof(struct arp_hdr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Build an ethernet header. */
|
/* Build an ethernet header. */
|
||||||
memcpy(IPBUF->ethhdr.dest.addr, tabptr->ethaddr.addr, 6);
|
memcpy(IPBUF->ethhdr.dest.addr, tabptr->ethaddr.addr, 6);
|
||||||
}
|
}
|
||||||
memcpy(IPBUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
|
memcpy(IPBUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
|
||||||
|
|
||||||
IPBUF->ethhdr.type = HTONS(UIP_ETHTYPE_IP);
|
IPBUF->ethhdr.type = HTONS(UIP_ETHTYPE_IP);
|
||||||
|
|
||||||
uip_len += sizeof(struct uip_eth_hdr);
|
uip_len += sizeof(struct uip_eth_hdr);
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
@ -1,145 +1,145 @@
|
|||||||
/**
|
/**
|
||||||
* \addtogroup uip
|
* \addtogroup uip
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \addtogroup uiparp
|
* \addtogroup uiparp
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
* Macros and definitions for the ARP module.
|
* Macros and definitions for the ARP module.
|
||||||
* \author Adam Dunkels <adam@dunkels.com>
|
* \author Adam Dunkels <adam@dunkels.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2003, Adam Dunkels.
|
* Copyright (c) 2001-2003, Adam Dunkels.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. The name of the author may not be used to endorse or promote
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
* products derived from this software without specific prior
|
* products derived from this software without specific prior
|
||||||
* written permission.
|
* written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* This file is part of the uIP TCP/IP stack.
|
* This file is part of the uIP TCP/IP stack.
|
||||||
*
|
*
|
||||||
* $Id: uip_arp.h,v 1.2 2006/08/26 23:58:45 oliverschmidt Exp $
|
* $Id: uip_arp.h,v 1.2 2006/08/26 23:58:45 oliverschmidt Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __UIP_ARP_H__
|
#ifndef __UIP_ARP_H__
|
||||||
#define __UIP_ARP_H__
|
#define __UIP_ARP_H__
|
||||||
|
|
||||||
#include "uip.h"
|
#include "uip.h"
|
||||||
|
|
||||||
|
|
||||||
extern struct uip_eth_addr uip_ethaddr;
|
extern struct uip_eth_addr uip_ethaddr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Ethernet header.
|
* The Ethernet header.
|
||||||
*/
|
*/
|
||||||
struct uip_eth_hdr {
|
struct uip_eth_hdr {
|
||||||
struct uip_eth_addr dest;
|
struct uip_eth_addr dest;
|
||||||
struct uip_eth_addr src;
|
struct uip_eth_addr src;
|
||||||
u16_t type;
|
u16_t type;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define UIP_ETHTYPE_ARP 0x0806
|
#define UIP_ETHTYPE_ARP 0x0806
|
||||||
#define UIP_ETHTYPE_IP 0x0800
|
#define UIP_ETHTYPE_IP 0x0800
|
||||||
#define UIP_ETHTYPE_IPV6 0x86dd
|
#define UIP_ETHTYPE_IPV6 0x86dd
|
||||||
|
|
||||||
|
|
||||||
/* The uip_arp_init() function must be called before any of the other
|
/* The uip_arp_init() function must be called before any of the other
|
||||||
ARP functions. */
|
ARP functions. */
|
||||||
void uip_arp_init(void);
|
void uip_arp_init(void);
|
||||||
|
|
||||||
/* The uip_arp_ipin() function should be called whenever an IP packet
|
/* The uip_arp_ipin() function should be called whenever an IP packet
|
||||||
arrives from the Ethernet. This function refreshes the ARP table or
|
arrives from the Ethernet. This function refreshes the ARP table or
|
||||||
inserts a new mapping if none exists. The function assumes that an
|
inserts a new mapping if none exists. The function assumes that an
|
||||||
IP packet with an Ethernet header is present in the uip_buf buffer
|
IP packet with an Ethernet header is present in the uip_buf buffer
|
||||||
and that the length of the packet is in the uip_len variable. */
|
and that the length of the packet is in the uip_len variable. */
|
||||||
/*void uip_arp_ipin(void);*/
|
/*void uip_arp_ipin(void);*/
|
||||||
#define uip_arp_ipin()
|
#define uip_arp_ipin()
|
||||||
|
|
||||||
/* The uip_arp_arpin() should be called when an ARP packet is received
|
/* The uip_arp_arpin() should be called when an ARP packet is received
|
||||||
by the Ethernet driver. This function also assumes that the
|
by the Ethernet driver. This function also assumes that the
|
||||||
Ethernet frame is present in the uip_buf buffer. When the
|
Ethernet frame is present in the uip_buf buffer. When the
|
||||||
uip_arp_arpin() function returns, the contents of the uip_buf
|
uip_arp_arpin() function returns, the contents of the uip_buf
|
||||||
buffer should be sent out on the Ethernet if the uip_len variable
|
buffer should be sent out on the Ethernet if the uip_len variable
|
||||||
is > 0. */
|
is > 0. */
|
||||||
void uip_arp_arpin(void);
|
void uip_arp_arpin(void);
|
||||||
|
|
||||||
/* The uip_arp_out() function should be called when an IP packet
|
/* The uip_arp_out() function should be called when an IP packet
|
||||||
should be sent out on the Ethernet. This function creates an
|
should be sent out on the Ethernet. This function creates an
|
||||||
Ethernet header before the IP header in the uip_buf buffer. The
|
Ethernet header before the IP header in the uip_buf buffer. The
|
||||||
Ethernet header will have the correct Ethernet MAC destination
|
Ethernet header will have the correct Ethernet MAC destination
|
||||||
address filled in if an ARP table entry for the destination IP
|
address filled in if an ARP table entry for the destination IP
|
||||||
address (or the IP address of the default router) is present. If no
|
address (or the IP address of the default router) is present. If no
|
||||||
such table entry is found, the IP packet is overwritten with an ARP
|
such table entry is found, the IP packet is overwritten with an ARP
|
||||||
request and we rely on TCP to retransmit the packet that was
|
request and we rely on TCP to retransmit the packet that was
|
||||||
overwritten. In any case, the uip_len variable holds the length of
|
overwritten. In any case, the uip_len variable holds the length of
|
||||||
the Ethernet frame that should be transmitted. */
|
the Ethernet frame that should be transmitted. */
|
||||||
void uip_arp_out(void);
|
void uip_arp_out(void);
|
||||||
|
|
||||||
/* The uip_arp_timer() function should be called every ten seconds. It
|
/* The uip_arp_timer() function should be called every ten seconds. It
|
||||||
is responsible for flushing old entries in the ARP table. */
|
is responsible for flushing old entries in the ARP table. */
|
||||||
void uip_arp_timer(void);
|
void uip_arp_timer(void);
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \addtogroup uipconffunc
|
* \addtogroup uipconffunc
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifiy the Ethernet MAC address.
|
* Specifiy the Ethernet MAC address.
|
||||||
*
|
*
|
||||||
* The ARP code needs to know the MAC address of the Ethernet card in
|
* The ARP code needs to know the MAC address of the Ethernet card in
|
||||||
* order to be able to respond to ARP queries and to generate working
|
* order to be able to respond to ARP queries and to generate working
|
||||||
* Ethernet headers.
|
* Ethernet headers.
|
||||||
*
|
*
|
||||||
* \note This macro only specifies the Ethernet MAC address to the ARP
|
* \note This macro only specifies the Ethernet MAC address to the ARP
|
||||||
* code. It cannot be used to change the MAC address of the Ethernet
|
* code. It cannot be used to change the MAC address of the Ethernet
|
||||||
* card.
|
* card.
|
||||||
*
|
*
|
||||||
* \param eaddr A pointer to a struct uip_eth_addr containing the
|
* \param eaddr A pointer to a struct uip_eth_addr containing the
|
||||||
* Ethernet MAC address of the Ethernet card.
|
* Ethernet MAC address of the Ethernet card.
|
||||||
*
|
*
|
||||||
* \hideinitializer
|
* \hideinitializer
|
||||||
*/
|
*/
|
||||||
#define uip_setethaddr(eaddr) do {uip_ethaddr.addr[0] = eaddr.addr[0]; \
|
#define uip_setethaddr(eaddr) do {uip_ethaddr.addr[0] = eaddr.addr[0]; \
|
||||||
uip_ethaddr.addr[1] = eaddr.addr[1];\
|
uip_ethaddr.addr[1] = eaddr.addr[1];\
|
||||||
uip_ethaddr.addr[2] = eaddr.addr[2];\
|
uip_ethaddr.addr[2] = eaddr.addr[2];\
|
||||||
uip_ethaddr.addr[3] = eaddr.addr[3];\
|
uip_ethaddr.addr[3] = eaddr.addr[3];\
|
||||||
uip_ethaddr.addr[4] = eaddr.addr[4];\
|
uip_ethaddr.addr[4] = eaddr.addr[4];\
|
||||||
uip_ethaddr.addr[5] = eaddr.addr[5];} while(0)
|
uip_ethaddr.addr[5] = eaddr.addr[5];} while(0)
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
||||||
#endif /* __UIP_ARP_H__ */
|
#endif /* __UIP_ARP_H__ */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user