| skipped 22 lines |
23 | 23 | | // stack to set transport handlers. |
24 | 24 | | TransportHandler adapter.TransportHandler |
25 | 25 | | |
26 | | - | // PrintFunc is the function that will be called |
27 | | - | // to print internal stack events. |
28 | | - | PrintFunc func(string, ...any) |
29 | | - | |
30 | 26 | | // Options are supplement options to apply settings |
31 | 27 | | // for the internal stack. |
32 | 28 | | Options []option.Option |
| skipped 1 lines |
34 | 30 | | |
35 | 31 | | // CreateStack creates *stack.Stack with given config. |
36 | 32 | | func CreateStack(cfg *Config) (*stack.Stack, error) { |
37 | | - | if cfg.PrintFunc == nil { |
38 | | - | cfg.PrintFunc = func(string, ...any) {} |
39 | | - | } |
40 | | - | |
41 | 33 | | opts := []option.Option{option.WithDefault()} |
42 | 34 | | if len(opts) > 0 { |
43 | 35 | | opts = append(opts, cfg.Options...) |
| skipped 20 lines |
64 | 56 | | // before creating NIC, otherwise NIC would dispatch packets |
65 | 57 | | // to stack and cause race condition. |
66 | 58 | | // Initiate transport protocol (TCP/UDP) with given handler. |
67 | | - | withTCPHandler(cfg.TransportHandler.HandleTCP, cfg.PrintFunc), |
68 | | - | withUDPHandler(cfg.TransportHandler.HandleUDP, cfg.PrintFunc), |
| 59 | + | withTCPHandler(cfg.TransportHandler.HandleTCP), |
| 60 | + | withUDPHandler(cfg.TransportHandler.HandleUDP), |
69 | 61 | | |
70 | 62 | | // Create stack NIC and then bind link endpoint to it. |
71 | 63 | | withCreatingNIC(nicID, cfg.LinkEndpoint), |
| skipped 37 lines |