1 /* $Id$ 2 * -------------------------------------------------------------------------- 3 * 4 * //===== //===== ===//=== //===// // // //===// 5 * // // // // // // // // // 6 * //====// // // //===// // // //===<< 7 * // // // // // // // // 8 * ======// //===== // // //===== // //===// 9 * 10 * -------------- An SCTP implementation according to RFC 4960 -------------- 11 * 12 * Copyright (C) 2001 by Andreas Lang 13 * 14 * This library is free software: you can redistribute it and/or modify it 15 * under the terms of the GNU Lesser General Public License as published by 16 * the Free Software Foundation, either version 2.1 of the License, or 17 * (at your option) any later version. 18 * 19 * This library is distributed in the hope that it will be useful, 20 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * GNU General Public License for more details. 23 * 24 * You should have received a copy of the GNU Lesser General Public License 25 * along with this program. If not, see <http://www.gnu.org/licenses/>. 26 * 27 * Contact: anla@gmx.net 28 */ 29 30 /* payload lengths */ 31 #define MIN_PAYLOAD_LENGTH 20 32 #define MAX_PAYLOAD_LENGTH 494 33 #define HEADER_LENGTH 6 34 35 /* constants used by processScriptCommand() */ 36 #define CHECK_SCRIPT 0 37 #define RUN_SCRIPT 1 38 39 /* receive mode constants */ 40 #define RECEIVE_DISCARD 0 41 #define RECEIVE_MIRROR 1 42 43 /* constants used by getIntParam() and getStrParam() */ 44 #define OPTIONAL 1 45 #define MANDATORY 0 46 #define DECIMAL 10 47 #define HEXADECIMAL 16 48 49 /* results returned by getScriptCommand() */ 50 #define PARSE_OK 0 51 #define END_OF_FILE 1 52 #define PARSE_ERROR -1 53 54 /* constants for sctptest_scriptCommand */ 55 #define MAX_NUM_OF_PARAMS 10 56 #define MAX_WORD_LENGTH 1000 /* (this includes the terminating '\0' character) */ 57 58 59 60 /** 61 * This structure is used to hold the data that is extracted from a script command by the parser. 62 * The variables in this structure are set by the function getScriptCommand() 63 */ 64 struct sctptest_scriptCommand 65 { 66 /* the number of parameters that are passed along with this command */ 67 unsigned int numOfParams; 68 69 /* the command string */ 70 char command[MAX_WORD_LENGTH]; 71 72 /* an array of structs containing the parameters; */ 73 /* each parameter consists of a key and a value */ 74 struct { 75 char key[MAX_WORD_LENGTH]; 76 char value[MAX_WORD_LENGTH]; 77 } param[MAX_NUM_OF_PARAMS]; 78 }; 79 80 81 82 /* FUNCTION DECLARATIONS */ 83 84 int sctptest_start(char *, int); 85 86 int getScriptCommand(FILE *, struct sctptest_scriptCommand *, unsigned int *, unsigned int *, int mode); 87 88 /* only for testing... */ 89 void printCommand(struct sctptest_scriptCommand *, unsigned int); 90 91 int processScriptCommand(struct sctptest_scriptCommand *, unsigned int, int); 92 93 char *getStrParam(struct sctptest_scriptCommand *, const char *, unsigned int *, int, unsigned int); 94 95 unsigned long getIntParam(struct sctptest_scriptCommand *, const char *, unsigned long, 96 unsigned long, int, unsigned int *, int, unsigned int); 97 98 void doReceive(unsigned int); 99 100 char *getTimeString(); 101 102 103 104 /* ULP CALLBACK FUNCTIONS */ 105 106 void timerCallback(unsigned int, void *, void *); 107 108 void dataArriveNotif(unsigned int assocID, unsigned short streamID, unsigned int length, 109 unsigned short streamSN,unsigned int TSN, unsigned int protoID, 110 unsigned int unordered, void *ulpData); 111 112 void sendFailureNotif(unsigned int assocID, unsigned char *unsentData, unsigned int dataLength, 113 unsigned int *context, void *ulpData); 114 115 void networkStatusChangeNotif(unsigned int assocID, short destinAddr, 116 unsigned short newState, void *ulpData); 117 118 void* communicationUpNotif(unsigned int assocID, int status, unsigned int noOfDestinAddrs, 119 unsigned short instreams, unsigned short outstreams, 120 int associationSupportsPRSCTP, void *ulpData); 121 122 void communicationLostNotif(unsigned int assocID, unsigned short status, void *ulpData); 123 124 void communicationErrorNotif(unsigned int assocID, unsigned short status, void *ulpData); 125 126 void restartNotif(unsigned int assocID, void *ulpData); 127 128 void shutdownCompleteNotif(unsigned int assocID, void *ulpData); 129 130