Revision 026a7e5d

View differences:

include/msg_types.h
1
#ifndef MSG_TYPES_H
2
#define MSG_TYPES_H
3

  
4
#define MSG_TYPE_TOPOLOGY   0x10
5
#define MSG_TYPE_CHUNK      0x11
6
#define MSG_TYPE_SIGNALLING 0x12
7

  
8
#endif	/* MSG_TYPES_H */
som/ChunkTrading/chunk_delivery.c
11 11
#include "net_helper.h"
12 12
#include "trade_msg_la.h"
13 13
#include "trade_msg_ha.h"
14
#include "msg_types.h"
14 15

  
15 16
static struct nodeID *localID;
16 17

  
......
37 38
        return -1;
38 39
    }
39 40
    res = encodeChunk(c, buff + 1, buff_len);
40
    buff[0] = 12;
41
    buff[0] = MSG_TYPE_CHUNK;
41 42
    send_data(localID, to, buff, buff_len + 1);
42 43
    free(buff);
43 44

  
som/Tests/chunk_sending_test.c
15 15
#include "trade_msg_la.h"
16 16
#include "trade_msg_ha.h"
17 17
#include "net_helpers.h"
18
#include "msg_types.h"
18 19

  
19 20
static const char *my_addr = "127.0.0.1";
20 21
static int port = 6666;
......
107 108

  
108 109
    res = recv_data(my_sock, &remote, buff, BUFFSIZE);
109 110
    /* TODO: Error check! */
110
    if (buff[0] != 12) {
111
    if (buff[0] != MSG_TYPE_CHUNK) {
111 112
      fprintf(stderr, "Wrong message type!!!\n");
112 113

  
113 114
      return -1;
som/TopologyManager/ncast.c
10 10
#include "nccache.h"
11 11
#include "ncast_proto.h"
12 12
#include "proto.h"
13
#include "msg_types.h"
13 14

  
14 15
#define MAX_PEERS 30
15 16

  
......
65 66
    struct ncast_header *h = (struct ncast_header *)buff;
66 67
    struct cache_entry *new, *remote_cache;
67 68

  
68
    if (h->protocol != PROTO_NCAST) {
69
    if (h->protocol != MSG_TYPE_TOPOLOGY) {
69 70
      fprintf(stderr, "NCAST: Wrong protocol!\n");
70 71

  
71 72
      return -1;
som/TopologyManager/ncast_proto.c
6 6
#include "nccache.h"
7 7
#include "proto.h"
8 8
#include "ncast_proto.h"
9
#include "msg_types.h"
9 10

  
10 11
static struct cache_entry *myEntry;
11 12

  
......
44 45
  }
45 46
#endif
46 47
  dst = nodeid(c, 0);
47
  h->protocol = PROTO_NCAST;
48
  h->protocol = MSG_TYPE_TOPOLOGY;
48 49
  h->type = NCAST_REPLY;
49 50
  len = ncast_payload_fill(pkt + sizeof(struct ncast_header), 1500 - sizeof(struct ncast_header), local_cache, dst);
50 51

  
......
59 60
  struct ncast_header *h = (struct ncast_header *)pkt;
60 61
  int len;
61 62

  
62
  h->protocol = PROTO_NCAST;
63
  h->protocol = MSG_TYPE_TOPOLOGY;
63 64
  h->type = NCAST_QUERY;
64 65
  len = ncast_payload_fill(pkt + sizeof(struct ncast_header), 1500 - sizeof(struct ncast_header), local_cache, dst);
65 66
  return send_data(nodeid(myEntry, 0), dst, pkt, sizeof(struct ncast_header) + len);
som/TopologyManager/proto.h
3 3
  uint8_t type;
4 4
} __attribute__((packed));
5 5

  
6
#define PROTO_NCAST 0x10
7 6
#define NCAST_QUERY 0x01
8 7
#define NCAST_REPLY 0x02

Also available in: Unified diff