rm mrpd mrpctl
indent:
- indent --linux-style mrpd.c mvrp.c msrp.c mmrp.c mrp.c mrpw.c
+ indent --linux-style mrpd.c mrpd.h mvrp.c mvrp.h msrp.c msrp.h mmrp.c mmrp.h mrp.c mrp.h mrpw.c que.c que.h
#define MMRP_SVCREQ_FOWARD_UNREGISTERED 1
/* MMRP uses ThreePackedEvents for all vector encodings */
-
struct mmrp_attribute {
- struct mmrp_attribute *prev;
- struct mmrp_attribute *next;
- uint32_t type;
+ struct mmrp_attribute *prev;
+ struct mmrp_attribute *next;
+ uint32_t type;
union {
- unsigned char macaddr[6];
- uint8_t svcreq;
+ unsigned char macaddr[6];
+ uint8_t svcreq;
} attribute;
- mrp_applicant_attribute_t applicant;
- mrp_registrar_attribute_t registrar;
+ mrp_applicant_attribute_t applicant;
+ mrp_registrar_attribute_t registrar;
};
struct mmrp_database {
- struct mrp_database mrp_db;
- struct mmrp_attribute *attrib_list;
+ struct mrp_database mrp_db;
+ struct mmrp_attribute *attrib_list;
};
int mmrp_init(int mmrp_enable);
int mmrp_reclaim(void);
void mmrp_bye(struct sockaddr_in *client);
int mmrp_recv_msg(void);
-void mmrp_increment_macaddr(uint8_t *macaddr);
+void mmrp_increment_macaddr(uint8_t * macaddr);
int mmrp_send_notifications(struct mmrp_attribute *attrib, int notify);
#define MRP_ENCODE_OPTIONAL 1 /* send if smaller */
typedef struct mrp_applicant_attribute {
- int mrp_state;
- int tx; /* tx=1 means transmit on next TX event */
- int sndmsg; /* sndmsg={NEW,IN,JOININ,JOINMT,MT, or LV} */
- int encode; /* when tx=1, NO, YES or OPTIONAL */
+ int mrp_state;
+ int tx; /* tx=1 means transmit on next TX event */
+ int sndmsg; /* sndmsg={NEW,IN,JOININ,JOINMT,MT, or LV} */
+ int encode; /* when tx=1, NO, YES or OPTIONAL */
} mrp_applicant_attribute_t;
typedef struct mrp_registrar_attribute {
- int mrp_state;
- int notify;
- short rsvd;
- unsigned char macaddr[6]; /* mac address of last registration */
+ int mrp_state;
+ int notify;
+ short rsvd;
+ unsigned char macaddr[6]; /* mac address of last registration */
} mrp_registrar_attribute_t;
/* MRP Application Notifications */
/* Registrar States */
#define MRP_IN_STATE 16 /* when Registrar state is IN */
-#define MRP_LV_STATE 17 /* registrar state - leaving */
-#define MRP_MT_STATE 18 /* whe Registrar state is MT or LV */
+#define MRP_LV_STATE 17 /* registrar state - leaving */
+#define MRP_MT_STATE 18 /* whe Registrar state is MT or LV */
/* MRP Events */
#define MRP_EVENT_BEGIN 100 /* Initialize state machine (10.7.5.1) */
#define MRP_PERIODTIMER_VAL 1000 /* periodic timeout in msec */
typedef struct mrp_timer {
- int state;
- int tx; /* tx=1 means transmit on next TX event */
- int sndmsg; /* sndmsg={NEW,JOIN,or LV} */
+ int state;
+ int tx; /* tx=1 means transmit on next TX event */
+ int sndmsg; /* sndmsg={NEW,JOIN,or LV} */
} mrp_timer_t;
#define MRP_TIMER_PASSIVE 0
((y) * 4) + (z))
typedef struct mrpdu_vectorattrib {
- uint16_t VectorHeader; /* LVA << 13 | NumberOfValues */
- uint8_t FirstValue_VectorEvents[];
+ uint16_t VectorHeader; /* LVA << 13 | NumberOfValues */
+ uint8_t FirstValue_VectorEvents[];
} mrpdu_vectorattrib_t;
#define MRPDU_VECT_NUMVALUES(x) ((x) & ((1 << 13) - 1))
#define MRPDU_VECT_LVA(x) ((x) & (1 << 13))
typedef struct client {
- struct client *next;
- struct sockaddr_in client;
+ struct client *next;
+ struct sockaddr_in client;
} client_t;
struct mrp_database {
- mrp_timer_t lva;
- mrp_timer_t periodic;
- HTIMER join_timer;
- HTIMER lv_timer;
- HTIMER lva_timer;
- client_t *clients;
- int registration;
- int participant;
+ mrp_timer_t lva;
+ mrp_timer_t periodic;
+ HTIMER join_timer;
+ HTIMER lv_timer;
+ HTIMER lva_timer;
+ client_t *clients;
+ int registration;
+ int participant;
};
-int mrp_client_add(client_t **list, struct sockaddr_in *newclient);
-int mrp_client_delete(client_t **list, struct sockaddr_in *newclient);
+int mrp_client_add(client_t ** list, struct sockaddr_in *newclient);
+int mrp_client_delete(client_t ** list, struct sockaddr_in *newclient);
int mrp_init(void);
int mrp_jointimer_stop(struct mrp_database *mrp_db);
int mrp_lvatimer_start(struct mrp_database *mrp_db);
int mrp_lvatimer_stop(struct mrp_database *mrp_db);
int mrp_lvatimer_fsm(struct mrp_database *mrp_db, int event);
-int mrp_applicant_fsm(mrp_applicant_attribute_t *attrib, int event);
-int mrp_registrar_fsm(mrp_registrar_attribute_t *attrib,
- struct mrp_database *mrp_db, int event);
-int mrp_decode_state(mrp_registrar_attribute_t *rattrib,
- mrp_applicant_attribute_t *aattrib, char *str, int strlen);
-
+int mrp_applicant_fsm(mrp_applicant_attribute_t * attrib, int event);
+int mrp_registrar_fsm(mrp_registrar_attribute_t * attrib,
+ struct mrp_database *mrp_db, int event);
+int mrp_decode_state(mrp_registrar_attribute_t * rattrib,
+ mrp_applicant_attribute_t * aattrib, char *str,
+ int strlen);
#endif
#endif
-#include <stdint.h> // for uint8_t etc
+#include <stdint.h> // for uint8_t etc
typedef struct eth_hdr {
- uint8_t destaddr[6];
- uint8_t srcaddr[6];
- uint16_t typelen;
+ uint8_t destaddr[6];
+ uint8_t srcaddr[6];
+ uint16_t typelen;
} eth_hdr_t;
/*
* operates on the (FirstEvent+1) attribute, and so forth.
*/
typedef struct mrpdu_message {
- uint8_t AttributeType;
- uint8_t AttributeLength; /* length of FirstValue */
+ uint8_t AttributeType;
+ uint8_t AttributeLength; /* length of FirstValue */
/* Microsoft does not support 0 length arrays
- * uint8_t Data[];
+ * uint8_t Data[];
* parsing of the data field is application specific - either
* a ushort with an attribute list length followed by vector
* attributes, or just a list of vector attributes ...
*(&a->AttributeLength + 1 + n) = d
typedef struct mrpdu {
- uint8_t ProtocolVersion;
+ uint8_t ProtocolVersion;
/* Microsoft does not support 0 length arrays
- * mrpdu_message_t MessageList[];
+ * mrpdu_message_t MessageList[];
* mrpdu should have trailing NULL (0x0000) indicating the ENDMARK */
} mrpdu_t;
int mrpd_timer_start(HTIMER timerfd, unsigned long value_ms);
int mrpd_timer_stop(HTIMER timerfd);
int mrpd_send_ctl_msg(struct sockaddr_in *client_addr, char *notify_data,
- int notify_len);
-int mrpd_init_protocol_socket(uint16_t etype, SOCKET *sock,
- unsigned char *multicast_addr);
+ int notify_len);
+int mrpd_init_protocol_socket(uint16_t etype, SOCKET * sock,
+ unsigned char *multicast_addr);
int mrpd_close_socket(SOCKET sock);
int mrpd_recvmsgbuf(SOCKET sock, char **buf);
-
-
******************************************************************************/
-
#define MSRP_ETYPE 0x22EA
#define MSRP_PROT_VER 0x00
#define MSRP_SR_PVID_DEFAULT 2
* FirstValue structure definition for MSRP Attributes
*/
typedef struct msrpdu_listen {
- uint8_t StreamID[8]; /* MSB bytes are talker MAC address */
+ uint8_t StreamID[8]; /* MSB bytes are talker MAC address */
} msrpdu_listen_t;
typedef struct msrpdu_talker_advertise {
- uint8_t StreamID[8];
+ uint8_t StreamID[8];
struct {
- uint8_t Dest_Addr[6];
- uint16_t Vlan_ID;
+ uint8_t Dest_Addr[6];
+ uint16_t Vlan_ID;
} DataFrameParameters;
struct {
- uint16_t MaxFrameSize;
- uint16_t MaxIntervalFrames;
+ uint16_t MaxFrameSize;
+ uint16_t MaxIntervalFrames;
} TSpec;
- uint8_t PriorityAndRank;
+ uint8_t PriorityAndRank;
/*
* PriorityAndRank := (3-bit priority | 1 bit rank | 4-bits reserved)
* 'rank=0 means emergency traffic, =1 otherwise
*/
- unsigned AccumulatedLatency; /* unsigned 32 bit nsec latency */
+ unsigned AccumulatedLatency; /* unsigned 32 bit nsec latency */
} msrpdu_talker_advertise_t;
typedef struct msrpdu_talker_fail {
- uint8_t StreamID[8];
+ uint8_t StreamID[8];
struct {
- uint8_t Dest_Addr[6];
- uint16_t Vlan_ID;
+ uint8_t Dest_Addr[6];
+ uint16_t Vlan_ID;
} DataFrameParameters;
struct {
- uint16_t MaxFrameSize;
- uint16_t MaxIntervalFrames;
+ uint16_t MaxFrameSize;
+ uint16_t MaxIntervalFrames;
} TSpec;
- uint8_t PriorityAndRank;
- unsigned AccumulatedLatency;
+ uint8_t PriorityAndRank;
+ unsigned AccumulatedLatency;
struct {
- uint8_t BridgeID[8];
- uint8_t FailureCode;
+ uint8_t BridgeID[8];
+ uint8_t FailureCode;
} FailureInformation;
} msrpdu_talker_fail_t;
/* Domain Discovery FirstValue definition */
typedef struct msrpdu_domain {
- uint8_t SRclassID;
- uint8_t SRclassPriority;
- uint16_t SRclassVID;
+ uint8_t SRclassID;
+ uint8_t SRclassPriority;
+ uint16_t SRclassVID;
} msrpdu_domain_t;
/* Class ID defitions */
#define MSRP_DIRECTION_LISTENER 1
struct msrp_attribute {
- struct msrp_attribute *prev;
- struct msrp_attribute *next;
- uint32_t type;
+ struct msrp_attribute *prev;
+ struct msrp_attribute *next;
+ uint32_t type;
union {
- msrpdu_talker_fail_t talk_listen;
- msrpdu_domain_t domain;
+ msrpdu_talker_fail_t talk_listen;
+ msrpdu_domain_t domain;
} attribute;
- uint32_t substate; /*for listener events*/
- uint32_t direction; /*for listener events*/
- mrp_applicant_attribute_t applicant;
- mrp_registrar_attribute_t registrar;
+ uint32_t substate; /*for listener events */
+ uint32_t direction; /*for listener events */
+ mrp_applicant_attribute_t applicant;
+ mrp_registrar_attribute_t registrar;
};
struct msrp_database {
- struct mrp_database mrp_db;
- struct msrp_attribute *attrib_list;
+ struct mrp_database mrp_db;
+ struct msrp_attribute *attrib_list;
};
int msrp_init(int msrp_enable);
******************************************************************************/
struct mvrp_attribute {
- struct mvrp_attribute *prev;
- struct mvrp_attribute *next;
- uint16_t attribute; /* 12-bit VID */
- mrp_applicant_attribute_t applicant;
- mrp_registrar_attribute_t registrar;
+ struct mvrp_attribute *prev;
+ struct mvrp_attribute *next;
+ uint16_t attribute; /* 12-bit VID */
+ mrp_applicant_attribute_t applicant;
+ mrp_registrar_attribute_t registrar;
};
struct mvrp_database {
- struct mrp_database mrp_db;
- struct mvrp_attribute *attrib_list;
+ struct mrp_database mrp_db;
+ struct mvrp_attribute *attrib_list;
};
-
#define MVRP_ETYPE 0x88F5
#define MVRP_PROT_VER 0x00
/* one attribute type defined for MVRP */
q = (struct que_def *)calloc(1, sizeof(struct que_def));
if (!q)
return q;
- q->buffer = (uint8_t *)calloc(entry_count, entry_size);
+ q->buffer = (uint8_t *) calloc(entry_count, entry_size);
if (!q->buffer) {
- free (q);
+ free(q);
return NULL;
}
q->entry_count = entry_count;
q->entry_size = entry_size;
- q->space_avail = CreateSemaphore(NULL, q->entry_count, q->entry_count, NULL);
+ q->space_avail =
+ CreateSemaphore(NULL, q->entry_count, q->entry_count, NULL);
q->data_avail = CreateSemaphore(NULL, 0, q->entry_count, NULL);
InitializeCriticalSection(&q->mutex);
-
+
return q;
}
void que_push(struct que_def *q, void *d)
{
- WaitForSingleObject(q->space_avail, INFINITE);
+ WaitForSingleObject(q->space_avail, INFINITE);
EnterCriticalSection(&q->mutex);
memcpy(&q->buffer[q->in_pos * q->entry_size], d, q->entry_size);
q->in_pos = (q->in_pos + 1) % q->entry_count;
#ifndef _QUE_H_
#define _QUE_H_
-#include <stdint.h> // for uint8_t etc
+#include <stdint.h> // for uint8_t etc
#include <windows.h>
#ifdef __cplusplus
extern "C" {
#endif
-struct que_def {
- HANDLE space_avail; // at least one slot empty
- HANDLE data_avail; // at least one slot full
- CRITICAL_SECTION mutex; // protect buffer, in_pos, out_pos
+ struct que_def {
+ HANDLE space_avail; // at least one slot empty
+ HANDLE data_avail; // at least one slot full
+ CRITICAL_SECTION mutex; // protect buffer, in_pos, out_pos
- uint8_t *buffer;
- int in_pos;
- int out_pos;
- int entry_count;
- int entry_size;
-};
+ uint8_t *buffer;
+ int in_pos;
+ int out_pos;
+ int entry_count;
+ int entry_size;
+ };
-struct que_def *que_new(int count, int entry_size);
-void que_delete(struct que_def *q);
-void que_push(struct que_def *q, void *d);
-void que_pop_nowait(struct que_def *q, void *d);
-void que_pop_wait(struct que_def *q, void *d);
-HANDLE que_data_available_object(struct que_def *q);
+ struct que_def *que_new(int count, int entry_size);
+ void que_delete(struct que_def *q);
+ void que_push(struct que_def *q, void *d);
+ void que_pop_nowait(struct que_def *q, void *d);
+ void que_pop_wait(struct que_def *q, void *d);
+ HANDLE que_data_available_object(struct que_def *q);
#ifdef __cplusplus
}
rm -f `find . -name "*~" -o -name "*.[oa]" -o -name "\#*\#" -o -name TAGS -o -name core -o -name "*.orig"`
indent:
- indent --linux-style mrpdclient.c mrpl.c mrpq.c
+ indent --linux-style mrpdclient.c mrpdclient.h mrpl.c mrpq.c
#define MRPDCLIENT_MAX_FRAME_SIZE 2000
-typedef int (*ptr_process_msg)(char *buf, int buflen);
+typedef int (*ptr_process_msg) (char *buf, int buflen);
int mrpdclient_init(int port);
int mrpdclient_recv(ptr_process_msg fn);